diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-09-14 19:50:00 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-09-14 22:32:59 +0200 |
commit | 040c6bcb25f24b73839111dbce3a7114e7c59bf6 (patch) | |
tree | 0e62c747d7139fe6459244ec6aeb870acf789c5a | |
parent | fa15805e81de8fa01037c01db98e9aff3b4fa475 (diff) |
mgcp: Reset endpoints via the trunk config instead of all of them
This change is coming from OpenBSC and was adjusted to mgcp_ss7
-rw-r--r-- | include/mgcp/mgcp.h | 2 | ||||
-rw-r--r-- | include/mgcp_ss7.h | 2 | ||||
-rw-r--r-- | src/mgcp/mgcp_protocol.c | 15 | ||||
-rw-r--r-- | src/mgcp_ss7.c | 22 |
4 files changed, 23 insertions, 18 deletions
diff --git a/include/mgcp/mgcp.h b/include/mgcp/mgcp.h index 50b11cc..9f21a37 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_config *cfg); +typedef int (*mgcp_reset)(struct mgcp_trunk_config *cfg); #define PORT_ALLOC_STATIC 0 #define PORT_ALLOC_DYNAMIC 1 diff --git a/include/mgcp_ss7.h b/include/mgcp_ss7.h index 35f5b9c..eb17158 100644 --- a/include/mgcp_ss7.h +++ b/include/mgcp_ss7.h @@ -55,8 +55,6 @@ struct mgcp_ss7_cmd { uint32_t param; }; -void mgcp_ss7_reset(struct mgcp_ss7 *mgcp); - void mgcp_mgw_vty_init(); #endif diff --git a/src/mgcp/mgcp_protocol.c b/src/mgcp/mgcp_protocol.c index 6dc6090..f76342c 100644 --- a/src/mgcp/mgcp_protocol.c +++ b/src/mgcp/mgcp_protocol.c @@ -861,8 +861,21 @@ out_silent: static struct msgb *handle_rsip(struct mgcp_config *cfg, struct msgb *msg) { + struct mgcp_msg_ptr data_ptrs[6]; + const char *trans_id; + struct mgcp_endpoint *endp; + int found; + + found = mgcp_analyze_header(cfg, msg, data_ptrs, ARRAY_SIZE(data_ptrs), + &trans_id, &endp); + if (found != 0) { + LOGP(DMGCP, LOGL_ERROR, "Failed to find the endpoint.\n"); + return NULL; + } + if (cfg->reset_cb) - cfg->reset_cb(cfg); + cfg->reset_cb(endp->tcfg); + return NULL; } diff --git a/src/mgcp_ss7.c b/src/mgcp_ss7.c index 745f312..9a1b0b6 100644 --- a/src/mgcp_ss7.c +++ b/src/mgcp_ss7.c @@ -59,6 +59,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_endp_free(struct mgcp_endpoint *endp); @@ -649,9 +650,9 @@ static void mgcp_ss7_endp_free(struct mgcp_endpoint *endp) mgcp_ss7_exec(endp, MGCP_SS7_DELETE, 0); } -static int reset_cb(struct mgcp_config *cfg) +static int reset_cb(struct mgcp_trunk_config *trunk) { - mgcp_ss7_reset((struct mgcp_ss7 *) cfg->data); + mgcp_ss7_reset(trunk); return 0; } @@ -770,21 +771,14 @@ static void free_trunk(struct mgcp_trunk_config *trunk) } } -void mgcp_ss7_reset(struct mgcp_ss7 *mgcp) +static void mgcp_ss7_reset(struct mgcp_trunk_config *tcfg) { - struct mgcp_trunk_config *trunk; - - if (!mgcp) - return; - - LOGP(DMGCP, LOGL_INFO, "Resetting all endpoints.\n"); + 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); /* free UniPorte and MGCP data */ - - llist_for_each_entry(trunk, &mgcp->cfg->vtrunks, entry) - free_trunk(trunk); - llist_for_each_entry(trunk, &mgcp->cfg->trunks, entry) - free_trunk(trunk); + free_trunk(tcfg); } static void print_help() |