diff sip-in/mncc_handle.c @ 83:3e3fbf44f9d7

sip-in: disconnect and call clearing implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 20 Sep 2022 22:06:37 -0800
parents 5beb51de1bae
children f82157ac7303
line wrap: on
line diff
--- a/sip-in/mncc_handle.c	Tue Sep 20 20:33:09 2022 -0800
+++ b/sip-in/mncc_handle.c	Tue Sep 20 22:06:37 2022 -0800
@@ -18,6 +18,12 @@
 
 extern struct call *find_call_by_mncc_callref();
 
+static struct gsm_mncc_cause default_cause = {
+	.coding		= GSM48_CAUSE_CODING_GSM,
+	.location	= GSM48_CAUSE_LOC_PRN_S_LU,
+	.value		= GSM48_CC_CAUSE_NORMAL_UNSPEC,
+};
+
 static void
 handle_alerting(call, msg)
 	struct call *call;
@@ -54,7 +60,20 @@
 	struct call *call;
 	struct gsm_mncc *msg;
 {
-	/* handling to be implemented */
+	struct gsm_mncc_cause *cause;
+
+	/* release back to MNCC */
+	msg->msg_type = MNCC_REL_REQ;
+	send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
+	call->mncc_state = MNCC_STATE_RELEASE;
+	/* signal disconnect to SIP */
+	call->overall_state = OVERALL_STATE_TEARDOWN;
+	if (msg->fields & MNCC_F_CAUSE)
+		cause = &msg->cause;
+	else
+		cause = &default_cause;
+	disconnect_sip(call, cause);
+	disconnect_tmgw(call);
 }
 
 static void
@@ -62,7 +81,18 @@
 	struct call *call;
 	struct gsm_mncc *msg;
 {
-	/* handling to be implemented */
+	struct gsm_mncc_cause *cause;
+
+	/* MNCC call leg is gone */
+	call->mncc_state = MNCC_STATE_NO_EXIST;
+	/* signal disconnect to SIP */
+	call->overall_state = OVERALL_STATE_TEARDOWN;
+	if (msg->fields & MNCC_F_CAUSE)
+		cause = &msg->cause;
+	else
+		cause = &default_cause;
+	disconnect_sip(call, cause);
+	disconnect_tmgw(call);
 }
 
 static void