|
|
|
@ -26,6 +26,7 @@ typedef struct {
|
|
|
|
|
Octstr *msisdn; /* my msisdn. */
|
|
|
|
|
Octstr *proxy; /* form is host:port. */
|
|
|
|
|
Octstr *gprs_on; /* Command to start GPRS link. Must not exit. */
|
|
|
|
|
Octstr *gprs_off; /* Command to stop GPRS link. */
|
|
|
|
|
Octstr *gprs_pid; /* command to call to get PID of GPRS for stopping GPRS link (i.e. pppd). */
|
|
|
|
|
Octstr *smsc_on; /* command to start smsc connection */
|
|
|
|
|
Octstr *smsc_off; /* commadn to stop smsc connection */
|
|
|
|
@ -57,6 +58,7 @@ typedef struct {
|
|
|
|
|
Octstr *error;
|
|
|
|
|
} MM1Request;
|
|
|
|
|
|
|
|
|
|
static void stop_gprs(Octstr *cmd);
|
|
|
|
|
static void handle_notify(MM1Settings *mm1);
|
|
|
|
|
static void handle_mm1(MM1Settings *mm1);
|
|
|
|
|
static int open_mm1(MmscGrp *mmc, MmsQueueHandlerFuncs *qfs,
|
|
|
|
@ -68,6 +70,7 @@ static int open_mm1(MmscGrp *mmc, MmsQueueHandlerFuncs *qfs,
|
|
|
|
|
Octstr *mmsc_url = NULL;
|
|
|
|
|
Octstr *proxy = NULL;
|
|
|
|
|
Octstr *gprs_on = NULL;
|
|
|
|
|
Octstr *gprs_off = NULL;
|
|
|
|
|
Octstr *gprs_pid = NULL;
|
|
|
|
|
Octstr *smsc_on = NULL;
|
|
|
|
|
Octstr *smsc_off = NULL;
|
|
|
|
@ -96,6 +99,8 @@ static int open_mm1(MmscGrp *mmc, MmsQueueHandlerFuncs *qfs,
|
|
|
|
|
proxy = value;
|
|
|
|
|
else if (octstr_str_case_compare(item, "gprs-on") == 0)
|
|
|
|
|
gprs_on = value;
|
|
|
|
|
else if (octstr_str_case_compare(item, "gprs-off") == 0)
|
|
|
|
|
gprs_off = value;
|
|
|
|
|
else if (octstr_str_case_compare(item, "gprs-pid") == 0)
|
|
|
|
|
gprs_pid = value;
|
|
|
|
|
else if (octstr_str_case_compare(item, "port") == 0) {
|
|
|
|
@ -129,6 +134,7 @@ static int open_mm1(MmscGrp *mmc, MmsQueueHandlerFuncs *qfs,
|
|
|
|
|
mm1->mmsc_url = mmsc_url;
|
|
|
|
|
mm1->proxy = proxy;
|
|
|
|
|
mm1->gprs_on = gprs_on;
|
|
|
|
|
mm1->gprs_off = gprs_off;
|
|
|
|
|
mm1->gprs_pid = gprs_pid;
|
|
|
|
|
mm1->smsc_on = smsc_on;
|
|
|
|
|
mm1->smsc_off = smsc_off;
|
|
|
|
@ -547,7 +553,10 @@ static void handle_mm1(MM1Settings *mm1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (pid > 0) { /* stop GPRS, restart SMSC connection. */
|
|
|
|
|
|
|
|
|
|
if (mm1->gprs_off) {
|
|
|
|
|
stop_gprs(mm1->gprs_off);
|
|
|
|
|
} else if (pid > 0) { /* stop GPRS, restart SMSC connection. */
|
|
|
|
|
int xkill, status;
|
|
|
|
|
pid_t wpid;
|
|
|
|
|
do {
|
|
|
|
@ -590,6 +599,7 @@ static int close_mm1(void *data)
|
|
|
|
|
octstr_destroy(s->msisdn);
|
|
|
|
|
octstr_destroy(s->proxy);
|
|
|
|
|
octstr_destroy(s->gprs_on);
|
|
|
|
|
octstr_destroy(s->gprs_off);
|
|
|
|
|
octstr_destroy(s->gprs_pid);
|
|
|
|
|
octstr_destroy(s->smsc_on);
|
|
|
|
|
octstr_destroy(s->smsc_off);
|
|
|
|
@ -669,6 +679,25 @@ static Octstr *fetch_content(Octstr *url, Octstr *proxy, Octstr *body, int *hsta
|
|
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
static void stop_gprs(Octstr *cmd)
|
|
|
|
|
{
|
|
|
|
|
pid_t pid = fork();
|
|
|
|
|
if (pid == 0) {
|
|
|
|
|
/* in child */
|
|
|
|
|
List *l = octstr_split_words(cmd);
|
|
|
|
|
int i, n = gwlist_len(l);
|
|
|
|
|
char **args = gw_malloc((n+1) * sizeof *args);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
|
Octstr *x = gwlist_get(l, i);
|
|
|
|
|
args[i] = octstr_get_cstr(x);
|
|
|
|
|
printf("arg %d: %s\n", i, args[i]);
|
|
|
|
|
}
|
|
|
|
|
args[i] = NULL;
|
|
|
|
|
printf("Not reached: %d!", execvp(args[0], args));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define MAX_GPRS_WAIT 80
|
|
|
|
|
#define GPRS_POLL 5
|
|
|
|
|
static long start_gprs(Octstr *cmd, Octstr *pid_cmd)
|
|
|
|
|