diff mncc/intswitch.c @ 28:660126bd5f59

themwi-mncc: fix one bug, add debug syslog output
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 28 Jun 2022 21:47:04 -0800
parents 52e801b5ebb1
children
line wrap: on
line diff
--- a/mncc/intswitch.c	Tue Jun 28 19:21:51 2022 -0800
+++ b/mncc/intswitch.c	Tue Jun 28 21:47:04 2022 -0800
@@ -16,6 +16,8 @@
 #include "struct.h"
 #include "gsm_call.h"
 
+extern char *mncc_msg_name();
+
 void
 internal_switch_mo_setup(call, msg)
 	struct gsm_call *call;
@@ -25,6 +27,8 @@
 	struct gsm_mncc callproc;
 
 	if (!(msg->fields & MNCC_F_BEARER_CAP)) {
+		syslog(LOG_ERR, "rejecting intsw call 0x%x: no bearer cap",
+			msg->callref);
 		reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU,
 				GSM48_CC_CAUSE_INVAL_MAND_INF);
 		call->gc_flag = 1;
@@ -33,6 +37,8 @@
 	/* same speech-only restriction as in OsmoMSC's mncc_builtin */
 	if (msg->bearer_cap.transfer != GSM48_BCAP_ITCAP_SPEECH ||
 	    msg->bearer_cap.mode != GSM48_BCAP_TMOD_CIRCUIT) {
+		syslog(LOG_ERR, "rejecting intsw call 0x%x: bad bearer cap",
+			msg->callref);
 		reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU,
 				GSM48_CC_CAUSE_BEARER_CA_UNAVAIL);
 		call->gc_flag = 1;
@@ -40,11 +46,15 @@
 	}
 	mt = create_new_mt_call();
 	if (!mt) {
+		syslog(LOG_ERR,
+			"rejecting intsw call 0x%x: no memory for MT call",
+			msg->callref);
 		reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU,
 				GSM48_CC_CAUSE_RESOURCE_UNAVAIL);
 		call->gc_flag = 1;
 		return;
 	}
+	syslog(LOG_DEBUG, "intsw: MO=0x%x MT=0x%x", call->callref, mt->callref);
 	call->other_leg = mt;
 	mt->other_leg = call;
 	/* send call proceeding */
@@ -73,8 +83,12 @@
 	ack.callref = call->callref;
 	send_mncc_to_gsm(&ack, sizeof(struct gsm_mncc));
 	/* do we have the far end? */
-	if (!call->other_leg)
+	if (!call->other_leg) {
+		syslog(LOG_ERR, "intsw: missing other leg for MNCC_SETUP_CNF");
 		return;
+	}
+	syslog(LOG_DEBUG, "MNCC_SETUP_CNF from 0x%x to 0x%x", call->callref,
+		call->other_leg->callref);
 	msg->msg_type = MNCC_SETUP_RSP;
 	msg->callref = call->other_leg->callref;
 	send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
@@ -93,6 +107,7 @@
 	uint32_t new_msg_type;
 {
 	if (!call->other_leg) {
+		syslog(LOG_ERR, "intsw: missing other leg for msg forwarding");
 		/* drop it like OsmoMSC's mncc_builtin does */
 		return;
 	}
@@ -113,8 +128,12 @@
 	send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
 	/* disconnect on far end */
 	remote = call->other_leg;
-	if (!remote)
+	if (!remote) {
+		syslog(LOG_ERR, "intsw: missing other leg for MNCC_DISC_IND");
 		return;
+	}
+	syslog(LOG_DEBUG, "MNCC_DISC_IND from 0x%x to 0x%x", call->callref,
+		remote->callref);
 	msg->msg_type = MNCC_DISC_REQ;
 	msg->callref = remote->callref;
 	send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
@@ -137,6 +156,8 @@
 	/* if no remote, nothing more to do */
 	if (!remote)
 		return;
+	syslog(LOG_DEBUG, "release with remote: from 0x%x to 0x%x",
+		call->callref, remote->callref);
 	/* send them a release request */
 	msg->msg_type = MNCC_REL_REQ;
 	msg->callref = remote->callref;
@@ -206,8 +227,7 @@
 		call->gc_flag = 1;
 		return;
 	default:
-		syslog(LOG_ERR,
-			"MNCC message type 0x%x unhandled for internal switch",
-			msg->msg_type);
+		syslog(LOG_ERR, "%s unhandled for internal switch",
+			mncc_msg_name(msg->msg_type));
 	}
 }