From 211ad859de157c676bde6529a829e66db9fe4ff6 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 4 Apr 2016 19:52:41 +0200 Subject: sip/call/mncc: Move source/dest into the call structure In preparation of a better show calls VTY command it is of interest to know which number has been dialed by whom. For that store the source/dest in there. MNCC: Change the talloc root context to the call and don't try to free the strings after calling the routing code SIP: Use talloc_strdup to duplicate them. Call: Add null check because the talloc_strdup of the SIP layer could have failed. --- src/app.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/app.c') diff --git a/src/app.c b/src/app.c index 47ee150..4a88b36 100644 --- a/src/app.c +++ b/src/app.c @@ -59,25 +59,35 @@ void app_setup(struct app_config *cfg) cfg->mncc.conn.on_disconnect = app_mncc_disconnected; } -static void route_to_sip(struct call *call, const char *source, const char *dest) +static void route_to_sip(struct call *call) { - if (sip_create_remote_leg(&g_app.sip.agent, call, source, dest) != 0) + if (sip_create_remote_leg(&g_app.sip.agent, call) != 0) call->initial->release_call(call->initial); } -static void route_to_mncc(struct call *call, const char *source, - const char *dest) +static void route_to_mncc(struct call *call) { - if (mncc_create_remote_leg(&g_app.mncc.conn, call, source, dest) != 0) + if (mncc_create_remote_leg(&g_app.mncc.conn, call) != 0) call->initial->release_call(call->initial); } void app_route_call(struct call *call, const char *source, const char *dest) { + + if (!source || !dest) { + LOGP(DAPP, LOGL_ERROR, "call(%u) missing source(%p)/dest(%p)\n", + call->id, source, dest); + call->initial->release_call(call->initial); + return; + } + + call->source = source; + call->dest = dest; + if (call->initial->type == CALL_TYPE_MNCC) - route_to_sip(call, source, dest); + route_to_sip(call); else - route_to_mncc(call, source, dest); + route_to_mncc(call); } const char *app_media_name(int ptmsg) -- cgit v1.2.3