aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-12-11 18:30:19 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2012-12-11 18:30:19 +0100
commit0206643a595010c0d61e0afe557cf5bc7903818e (patch)
treea3a346b5bf4d5819a3363e10e9c409b44cc3d8ba
parentb2fb37751db6c7da1cf498e6339eaab6adb6982c (diff)
wip: mgcp: Implement an even more specific RSIP handling.
Using spec-extended RSIP one can reset a single endpoint or a range of endpoints.
-rw-r--r--include/mgcp/mgcp.h2
-rw-r--r--src/mgcp/mgcp_protocol.c18
-rw-r--r--src/mgcp_ss7.c36
3 files changed, 44 insertions, 12 deletions
diff --git a/include/mgcp/mgcp.h b/include/mgcp/mgcp.h
index ad88bfd..6ac3896 100644
--- a/include/mgcp/mgcp.h
+++ b/include/mgcp/mgcp.h
@@ -82,7 +82,7 @@ struct mgcp_trunk_config;
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_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);
#define PORT_ALLOC_STATIC 0
diff --git a/src/mgcp/mgcp_protocol.c b/src/mgcp/mgcp_protocol.c
index be6ec00..f847caf 100644
--- a/src/mgcp/mgcp_protocol.c
+++ b/src/mgcp/mgcp_protocol.c
@@ -860,13 +860,29 @@ out_silent:
static struct msgb *handle_rsip(struct mgcp_parse_data *p)
{
+ int range = -1;
+ const char *line;
+
if (p->found != 0) {
LOGP(DMGCP, LOGL_ERROR, "Failed to find the endpoint.\n");
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)
- p->cfg->reset_cb(p->endp->tcfg);
+ p->cfg->reset_cb(p->endp->tcfg,
+ ENDPOINT_NUMBER(p->endp), range);
return NULL;
}
diff --git a/src/mgcp_ss7.c b/src/mgcp_ss7.c
index 5330ada..474e257 100644
--- a/src/mgcp_ss7.c
+++ b/src/mgcp_ss7.c
@@ -60,7 +60,7 @@ static int exit_on_failure = 0;
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);
@@ -766,9 +766,21 @@ static void mgcp_ss7_endp_free(struct mgcp_endpoint *endp)
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;
}
@@ -880,24 +892,28 @@ static struct mgcp_ss7 *mgcp_ss7_init(struct mgcp_config *cfg)
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;
- for (i = 1; i < trunk->number_endpoints; ++i) {
+ for (i = start; i < range; ++i) {
struct mgcp_endpoint *endp = &trunk->endpoints[i];
mgcp_ss7_endp_free(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",
- tcfg->trunk_type == MGCP_TRUNK_VIRTUAL ? "virtual" : "e1",
- tcfg->virtual_domain, tcfg->trunk_nr);
+ LOGP(DMGCP, LOGL_INFO,
+ "Resetting endpoints(%d+%d) on trunk type %s %s/%d\n",
+ start, range,
+ tcfg->trunk_type == MGCP_TRUNK_VIRTUAL ? "virtual" : "e1",
+ tcfg->virtual_domain, tcfg->trunk_nr);
/* free UniPorte and MGCP data */
- free_trunk(tcfg);
+ free_trunk(tcfg, start, range);
}
static void print_help()