diff --git a/src/call.c b/src/call.c index d9ca66e..48281a1 100644 --- a/src/call.c +++ b/src/call.c @@ -78,3 +78,15 @@ struct call *sip_call_mncc_create(void) llist_add(&call->entry, &g_call_list); return call; } + +struct call_leg *call_leg_other(struct call_leg *leg) +{ + if (leg->call->initial == leg) + return leg->call->remote; + if (leg->call->remote == leg) + return leg->call->initial; + + LOGP(DAPP, LOGL_NOTICE, "leg(0x%p) not belonging to call(%u)\n", + leg, leg->call->id); + return NULL; +} diff --git a/src/call.h b/src/call.h index dc82f97..102c366 100644 --- a/src/call.h +++ b/src/call.h @@ -81,6 +81,7 @@ struct mncc_call_leg { extern struct llist_head g_call_list; void calls_init(void); +struct call_leg *call_leg_other(struct call_leg *leg); void call_leg_release(struct call_leg *leg); diff --git a/src/mncc.c b/src/mncc.c index a44ecad..406f32d 100644 --- a/src/mncc.c +++ b/src/mncc.c @@ -315,8 +315,14 @@ static void check_rel_ind(struct mncc_connection *conn, char *buf, int rc) if (leg->base.in_release) stop_cmd_timer(leg, MNCC_REL_IND); + else { + struct call_leg *other_leg; + other_leg = call_leg_other(&leg->base); + if (other_leg) + other_leg->release_call(other_leg); + } LOGP(DMNCC, LOGL_DEBUG, "leg(%u) was released.\n", data->callref); - call_leg_release(leg); + call_leg_release(&leg->base); } static void check_hello(struct mncc_connection *conn, char *buf, int rc)