summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-03-26 21:09:07 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-03-26 21:09:07 +0100
commitdac13bed500ad218143bab3fad95ec2ca316eabd (patch)
tree5e47636c1d1112d45f97e7ebf1da50ba35ccea95
parent7a30c94030babb10af3d8293d64011df7a2023a0 (diff)
sip/app: Route call from SIP to MNCC and deal with the release
Fix releasing of the leg in case it is not routable and make the differentation if we initiated the invite (send CANCEL) or send a final error. The error code was randomly picked and once we have an enum of causes we can decide where to map it to.
-rw-r--r--src/app.c2
-rw-r--r--src/sip.c11
2 files changed, 11 insertions, 2 deletions
diff --git a/src/app.c b/src/app.c
index 81b3dfc..36e7cb0 100644
--- a/src/app.c
+++ b/src/app.c
@@ -70,7 +70,7 @@ void app_route_call(struct call *call, const char *source, const char *dest)
else {
LOGP(DAPP, LOGL_ERROR, "Can not route call(%u) to MNCC yet\n",
call->id);
- call_leg_release(call->initial);
+ call->initial->release_call(call->initial);
}
}
diff --git a/src/sip.c b/src/sip.c
index f0ef1d7..4ef34b4 100644
--- a/src/sip.c
+++ b/src/sip.c
@@ -116,6 +116,8 @@ static void new_call(struct sip_agent *agent, nua_handle_t *nh,
leg->nua_handle = nh;
nua_handle_bind(nh, leg);
leg->sdp_payload = talloc_strdup(leg, sip->sip_payload->pl_data);
+
+ app_route_call(call, from, to);
}
void nua_callback(nua_event_t event, int status, char const *phrase, nua_t *nua, nua_magic_t *magic, nua_handle_t *nh, nua_hmagic_t *hmagic, sip_t const *sip, tagi_t tags[])
@@ -209,7 +211,14 @@ static void sip_release_call(struct call_leg *_leg)
break;
case SIP_CC_DLG_CNFD:
LOGP(DSIP, LOGL_NOTICE, "Canceling leg(%p) in cnfd state\n", leg);
- nua_cancel(leg->nua_handle, TAG_END());
+ if (leg->dir == SIP_DIR_MT)
+ nua_cancel(leg->nua_handle, TAG_END());
+ else {
+ nua_respond(leg->nua_handle, SIP_486_BUSY_HERE,
+ TAG_END());
+ nua_handle_destroy(leg->nua_handle);
+ call_leg_release(&leg->base);
+ }
break;
case SIP_CC_CONNECTED:
LOGP(DSIP, LOGL_NOTICE, "Ending leg(%p) in con\n", leg);