9
0
Fork 0

wip: mgcp: Implement an even more specific RSIP handling.

Using spec-extended RSIP one can reset a single endpoint or a
range of endpoints.
This commit is contained in:
Holger Hans Peter Freyther 2012-12-11 18:30:19 +01:00
parent b2fb37751d
commit 0206643a59
3 changed files with 44 additions and 12 deletions

View File

@ -82,7 +82,7 @@ struct mgcp_trunk_config;
typedef int (*mgcp_realloc)(struct mgcp_trunk_config *cfg, int endpoint); typedef int (*mgcp_realloc)(struct mgcp_trunk_config *cfg, int endpoint);
typedef int (*mgcp_change)(struct mgcp_trunk_config *cfg, int endpoint, int state); typedef int (*mgcp_change)(struct mgcp_trunk_config *cfg, int endpoint, int state);
typedef int (*mgcp_policy)(struct mgcp_trunk_config *cfg, int endpoint, int state, const char *transactio_id); typedef int (*mgcp_policy)(struct mgcp_trunk_config *cfg, int endpoint, int state, const char *transactio_id);
typedef int (*mgcp_reset)(struct mgcp_trunk_config *cfg); typedef int (*mgcp_reset)(struct mgcp_trunk_config *cfg, int endpoint, int range);
typedef int (*mgcp_rqnt)(struct mgcp_endpoint *endp, char tone); typedef int (*mgcp_rqnt)(struct mgcp_endpoint *endp, char tone);
#define PORT_ALLOC_STATIC 0 #define PORT_ALLOC_STATIC 0

View File

@ -860,13 +860,29 @@ out_silent:
static struct msgb *handle_rsip(struct mgcp_parse_data *p) static struct msgb *handle_rsip(struct mgcp_parse_data *p)
{ {
int range = -1;
const char *line;
if (p->found != 0) { if (p->found != 0) {
LOGP(DMGCP, LOGL_ERROR, "Failed to find the endpoint.\n"); LOGP(DMGCP, LOGL_ERROR, "Failed to find the endpoint.\n");
return NULL; return NULL;
} }
for_each_line(line, p->save) {
if (strlen(line) < 4)
continue;
switch (line[0]) {
case 'R':
range = atoi(line + 3);
break;
}
}
if (p->cfg->reset_cb) if (p->cfg->reset_cb)
p->cfg->reset_cb(p->endp->tcfg); p->cfg->reset_cb(p->endp->tcfg,
ENDPOINT_NUMBER(p->endp), range);
return NULL; return NULL;
} }

View File

@ -60,7 +60,7 @@ static int exit_on_failure = 0;
extern struct mgcp_config *g_cfg; extern struct mgcp_config *g_cfg;
static void mgcp_ss7_reset(struct mgcp_trunk_config *tcfg); static void mgcp_ss7_reset(struct mgcp_trunk_config *tcfg, int endpoint, int range);
static void mgcp_ss7_endp_free(struct mgcp_endpoint *endp); static void mgcp_ss7_endp_free(struct mgcp_endpoint *endp);
@ -766,9 +766,21 @@ static void mgcp_ss7_endp_free(struct mgcp_endpoint *endp)
mgcp_ss7_exec(endp, MGCP_SS7_DELETE, 0); mgcp_ss7_exec(endp, MGCP_SS7_DELETE, 0);
} }
static int reset_cb(struct mgcp_trunk_config *trunk) static int reset_cb(struct mgcp_trunk_config *trunk, int _endpoint, int _range)
{ {
mgcp_ss7_reset(trunk); int endpoint, range;
if (_range == -1) {
endpoint = 1;
range = trunk->number_endpoints;
} else {
endpoint = _endpoint;
range = OSMO_MIN(_range, trunk->number_endpoints);
#error "Check +1, -1... here continue next week"
}
mgcp_ss7_reset(trunk, endpoint, range);
return 0; return 0;
} }
@ -880,24 +892,28 @@ static struct mgcp_ss7 *mgcp_ss7_init(struct mgcp_config *cfg)
return conf; return conf;
} }
static void free_trunk(struct mgcp_trunk_config *trunk) /* range must be <= number_endpoints */
static void free_trunk(struct mgcp_trunk_config *trunk,
const int start, const int range)
{ {
int i; int i;
for (i = 1; i < trunk->number_endpoints; ++i) { for (i = start; i < range; ++i) {
struct mgcp_endpoint *endp = &trunk->endpoints[i]; struct mgcp_endpoint *endp = &trunk->endpoints[i];
mgcp_ss7_endp_free(endp); mgcp_ss7_endp_free(endp);
mgcp_free_endp(endp); mgcp_free_endp(endp);
} }
} }
static void mgcp_ss7_reset(struct mgcp_trunk_config *tcfg) static void mgcp_ss7_reset(struct mgcp_trunk_config *tcfg, int start, int range)
{ {
LOGP(DMGCP, LOGL_INFO, "Resetting endpoint on trunk type %s %s/%d\n", LOGP(DMGCP, LOGL_INFO,
tcfg->trunk_type == MGCP_TRUNK_VIRTUAL ? "virtual" : "e1", "Resetting endpoints(%d+%d) on trunk type %s %s/%d\n",
tcfg->virtual_domain, tcfg->trunk_nr); start, range,
tcfg->trunk_type == MGCP_TRUNK_VIRTUAL ? "virtual" : "e1",
tcfg->virtual_domain, tcfg->trunk_nr);
/* free UniPorte and MGCP data */ /* free UniPorte and MGCP data */
free_trunk(tcfg); free_trunk(tcfg, start, range);
} }
static void print_help() static void print_help()