Change in osmo-sip-connector[master]: Implement Cause Mapping

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Keith Whyte gerrit-no-reply at lists.osmocom.org
Sun Sep 2 08:57:12 UTC 2018


Keith Whyte has submitted this change and it was merged. ( https://gerrit.osmocom.org/10728 )

Change subject: Implement Cause Mapping
......................................................................

Implement Cause Mapping

Adds cause field to the call_leg and sip_call_leg structs.

Translates the SIP status to MNCC cause and vice versa and
uses this information in the SIP/MNCC messages at call leg
release time.

Change-Id: Ic1b80dff7e583cd6fff2b662bc6cc4bad3f81cd4
---
M src/call.h
M src/mncc.c
M src/sip.c
3 files changed, 25 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/src/call.h b/src/call.h
index 5a11f6c..de92a24 100644
--- a/src/call.h
+++ b/src/call.h
@@ -43,6 +43,8 @@
 	struct call *call;
 
 	bool in_release;
+	/* Field to hold GSM 04.08 Cause Value. Section 10.5.4.11 Table 10.86 */
+	int cause;
 
 	/**
 	 * RTP data
@@ -130,6 +132,8 @@
 	int rsp_wanted;
 
 	struct mncc_connection *conn;
+	/* Field to hold GSM 04.08 Cause Value. Section 10.5.4.11 Table 10.86 */
+	int cause;
 };
 
 extern struct llist_head g_call_list;
diff --git a/src/mncc.c b/src/mncc.c
index 2ecf8d0..f41bb51 100644
--- a/src/mncc.c
+++ b/src/mncc.c
@@ -105,12 +105,16 @@
 
 static void mncc_fill_header(struct gsm_mncc *mncc, uint32_t msg_type, uint32_t callref)
 {
+	struct mncc_call_leg *mncc_leg;
+
 	mncc->msg_type = msg_type;
 	mncc->callref = callref;
 	if (MNCC_DISC_REQ == msg_type || MNCC_REL_REQ == msg_type) {
+		mncc_leg = mncc_find_leg(callref);
 		mncc->fields |= MNCC_F_CAUSE;
 		mncc->cause.coding = GSM48_CAUSE_CODING_GSM;
 		mncc->cause.location = GSM48_CAUSE_LOC_PUN_S_LU;
+		mncc->cause.value = mncc_leg->base.cause;
 	}
 }
 
@@ -511,6 +515,7 @@
 
 	other_leg = call_leg_other(&leg->base);
 	if (other_leg)
+		other_leg->cause = data->cause.value;
 		other_leg->release_call(other_leg);
 }
 
@@ -529,6 +534,7 @@
 		struct call_leg *other_leg;
 		other_leg = call_leg_other(&leg->base);
 		if (other_leg)
+			other_leg->cause = data->cause.value;
 			other_leg->release_call(other_leg);
 	}
 	LOGP(DMNCC, LOGL_DEBUG, "leg(%u) was released.\n", data->callref);
@@ -573,8 +579,10 @@
 	if (!leg)
 		return;
 
+	leg->cause = data->cause.value;
 	other_leg = call_leg_other(&leg->base);
 	if (other_leg)
+		other_leg->cause = data->cause.value;
 		other_leg->release_call(other_leg);
 	LOGP(DMNCC, LOGL_DEBUG, "leg(%u) was rejected.\n", data->callref);
 	mncc_leg_release(leg);
diff --git a/src/sip.c b/src/sip.c
index 07d2286..088dbc3 100644
--- a/src/sip.c
+++ b/src/sip.c
@@ -244,8 +244,10 @@
 			nua_handle_destroy(leg->nua_handle);
 			call_leg_release(&leg->base);
 
-			if (other)
+			if (other) {
+				other->cause = status2cause(status);
 				other->release_call(other);
+			}
 		}
 	} else if (event == nua_r_bye || event == nua_r_cancel) {
 		/* our bye or hang up is answered */
@@ -309,6 +311,10 @@
 static void sip_release_call(struct call_leg *_leg)
 {
 	struct sip_call_leg *leg;
+	char reason[64];
+	int sip_cause;
+	const char *sip_phrase;
+	const char *reason_text;
 
 	OSMO_ASSERT(_leg->type == CALL_TYPE_SIP);
 	leg = (struct sip_call_leg *) _leg;
@@ -319,6 +325,10 @@
 	 * and for a connected one bye. I don't see how sofia-sip is going
 	 * to help us here.
 	 */
+
+	cause2status(_leg->cause, &sip_cause, &sip_phrase, &reason_text);
+	snprintf(reason, sizeof reason, "Q.850;cause=%u;text=\"%s\"", _leg->cause, reason_text);
+
 	switch (leg->state) {
 	case SIP_CC_INITIAL:
 		LOGP(DSIP, LOGL_NOTICE, "Canceling leg(%p) in int state\n", leg);
@@ -330,7 +340,8 @@
 		if (leg->dir == SIP_DIR_MT)
 			nua_cancel(leg->nua_handle, TAG_END());
 		else {
-			nua_respond(leg->nua_handle, SIP_486_BUSY_HERE,
+			nua_respond(leg->nua_handle, sip_cause, sip_phrase,
+					SIPTAG_REASON_STR(reason),
 					TAG_END());
 			nua_handle_destroy(leg->nua_handle);
 			call_leg_release(&leg->base);

-- 
To view, visit https://gerrit.osmocom.org/10728
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sip-connector
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic1b80dff7e583cd6fff2b662bc6cc4bad3f81cd4
Gerrit-Change-Number: 10728
Gerrit-PatchSet: 3
Gerrit-Owner: Keith Whyte <keith at rhizomatica.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Keith Whyte <keith at rhizomatica.org>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180902/61fea5e5/attachment.htm>


More information about the gerrit-log mailing list