added gprs-off command to mmsbox mm1 module
This commit is contained in:
parent
fae80063f8
commit
9a7952d200
|
@ -1,3 +1,5 @@
|
||||||
|
2011-01-12 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||||
|
* Improved mmsbox mm1 module -- added gprs-off command for better customisation of gprs on/off sequence
|
||||||
2011-01-06 P. A. Bagyenda <bagyenda@dsmagic.com>
|
2011-01-06 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||||
* More fixes for strip-prefixes -- now applies to sender address as well
|
* More fixes for strip-prefixes -- now applies to sender address as well
|
||||||
2011-01-05 P. A. Bagyenda <bagyenda@dsmagic.com>
|
2011-01-05 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||||
|
|
|
@ -26,6 +26,7 @@ typedef struct {
|
||||||
Octstr *msisdn; /* my msisdn. */
|
Octstr *msisdn; /* my msisdn. */
|
||||||
Octstr *proxy; /* form is host:port. */
|
Octstr *proxy; /* form is host:port. */
|
||||||
Octstr *gprs_on; /* Command to start GPRS link. Must not exit. */
|
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 *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_on; /* command to start smsc connection */
|
||||||
Octstr *smsc_off; /* commadn to stop smsc connection */
|
Octstr *smsc_off; /* commadn to stop smsc connection */
|
||||||
|
@ -57,6 +58,7 @@ typedef struct {
|
||||||
Octstr *error;
|
Octstr *error;
|
||||||
} MM1Request;
|
} MM1Request;
|
||||||
|
|
||||||
|
static void stop_gprs(Octstr *cmd);
|
||||||
static void handle_notify(MM1Settings *mm1);
|
static void handle_notify(MM1Settings *mm1);
|
||||||
static void handle_mm1(MM1Settings *mm1);
|
static void handle_mm1(MM1Settings *mm1);
|
||||||
static int open_mm1(MmscGrp *mmc, MmsQueueHandlerFuncs *qfs,
|
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 *mmsc_url = NULL;
|
||||||
Octstr *proxy = NULL;
|
Octstr *proxy = NULL;
|
||||||
Octstr *gprs_on = NULL;
|
Octstr *gprs_on = NULL;
|
||||||
|
Octstr *gprs_off = NULL;
|
||||||
Octstr *gprs_pid = NULL;
|
Octstr *gprs_pid = NULL;
|
||||||
Octstr *smsc_on = NULL;
|
Octstr *smsc_on = NULL;
|
||||||
Octstr *smsc_off = NULL;
|
Octstr *smsc_off = NULL;
|
||||||
|
@ -96,6 +99,8 @@ static int open_mm1(MmscGrp *mmc, MmsQueueHandlerFuncs *qfs,
|
||||||
proxy = value;
|
proxy = value;
|
||||||
else if (octstr_str_case_compare(item, "gprs-on") == 0)
|
else if (octstr_str_case_compare(item, "gprs-on") == 0)
|
||||||
gprs_on = value;
|
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)
|
else if (octstr_str_case_compare(item, "gprs-pid") == 0)
|
||||||
gprs_pid = value;
|
gprs_pid = value;
|
||||||
else if (octstr_str_case_compare(item, "port") == 0) {
|
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->mmsc_url = mmsc_url;
|
||||||
mm1->proxy = proxy;
|
mm1->proxy = proxy;
|
||||||
mm1->gprs_on = gprs_on;
|
mm1->gprs_on = gprs_on;
|
||||||
|
mm1->gprs_off = gprs_off;
|
||||||
mm1->gprs_pid = gprs_pid;
|
mm1->gprs_pid = gprs_pid;
|
||||||
mm1->smsc_on = smsc_on;
|
mm1->smsc_on = smsc_on;
|
||||||
mm1->smsc_off = smsc_off;
|
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;
|
int xkill, status;
|
||||||
pid_t wpid;
|
pid_t wpid;
|
||||||
do {
|
do {
|
||||||
|
@ -590,6 +599,7 @@ static int close_mm1(void *data)
|
||||||
octstr_destroy(s->msisdn);
|
octstr_destroy(s->msisdn);
|
||||||
octstr_destroy(s->proxy);
|
octstr_destroy(s->proxy);
|
||||||
octstr_destroy(s->gprs_on);
|
octstr_destroy(s->gprs_on);
|
||||||
|
octstr_destroy(s->gprs_off);
|
||||||
octstr_destroy(s->gprs_pid);
|
octstr_destroy(s->gprs_pid);
|
||||||
octstr_destroy(s->smsc_on);
|
octstr_destroy(s->smsc_on);
|
||||||
octstr_destroy(s->smsc_off);
|
octstr_destroy(s->smsc_off);
|
||||||
|
@ -669,6 +679,25 @@ static Octstr *fetch_content(Octstr *url, Octstr *proxy, Octstr *body, int *hsta
|
||||||
|
|
||||||
#include <unistd.h>
|
#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 MAX_GPRS_WAIT 80
|
||||||
#define GPRS_POLL 5
|
#define GPRS_POLL 5
|
||||||
static long start_gprs(Octstr *cmd, Octstr *pid_cmd)
|
static long start_gprs(Octstr *cmd, Octstr *pid_cmd)
|
||||||
|
|
|
@ -579,7 +579,8 @@ static void mmsbox_start_mmsc_conn(MmscGrp *m, List *errors, List *warnings)
|
||||||
{
|
{
|
||||||
if (m->type == CUSTOM_MMSC) {
|
if (m->type == CUSTOM_MMSC) {
|
||||||
if (m->fns == NULL ||
|
if (m->fns == NULL ||
|
||||||
m->fns->start_conn(m, qfs, unified_prefix, strip_prefixes, &m->data) != 0) {
|
m->fns->start_conn(m, qfs, unified_prefix,
|
||||||
|
m->strip_prefixes ? m->strip_prefixes : strip_prefixes, &m->data) != 0) {
|
||||||
WARNING("MMSBox: Failed to start custom MMSC [%s]", octstr_get_cstr(m->id));
|
WARNING("MMSBox: Failed to start custom MMSC [%s]", octstr_get_cstr(m->id));
|
||||||
m->started = 0;
|
m->started = 0;
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in New Issue