From 040c6bcb25f24b73839111dbce3a7114e7c59bf6 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 14 Sep 2011 19:50:00 +0200 Subject: mgcp: Reset endpoints via the trunk config instead of all of them This change is coming from OpenBSC and was adjusted to mgcp_ss7 --- src/mgcp/mgcp_protocol.c | 15 ++++++++++++++- src/mgcp_ss7.c | 22 ++++++++-------------- 2 files changed, 22 insertions(+), 15 deletions(-) (limited to 'src') 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() -- cgit v1.2.3