changeset 66:5beb51de1bae

sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 18 Sep 2022 16:17:31 -0800
parents 7c0309df59f8
children 15c9e1f8f756
files sip-in/disconnect.c sip-in/invite.c sip-in/mncc_handle.c
diffstat 3 files changed, 33 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sip-in/disconnect.c	Sun Sep 18 15:44:22 2022 -0800
+++ b/sip-in/disconnect.c	Sun Sep 18 16:17:31 2022 -0800
@@ -12,7 +12,6 @@
 #include <strings.h>
 #include <syslog.h>
 #include "../include/mncc.h"
-#include "../include/gsm48_const.h"
 #include "call.h"
 
 void
--- a/sip-in/invite.c	Sun Sep 18 15:44:22 2022 -0800
+++ b/sip-in/invite.c	Sun Sep 18 16:17:31 2022 -0800
@@ -12,6 +12,7 @@
 #include <string.h>
 #include <strings.h>
 #include <syslog.h>
+#include "../include/gsm48_const.h"
 #include "../libsip/parse.h"
 #include "../libsip/uas_basic.h"
 #include "../libsip/grok_from.h"
@@ -365,6 +366,29 @@
 }
 
 void
+signal_invite_200(call)
+	struct call *call;
+{
+	struct sip_msg_out resp;
+	int rc;
+
+	rc = fill_invite_200_resp(&resp, call);
+	if (rc < 0) {
+		syslog(LOG_ERR, "INVITE 200 response length exceeded");
+		call->sip_state = SIP_STATE_MSG_SIZE_ERR;
+		call->overall_state = OVERALL_STATE_TEARDOWN;
+		disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU,
+				GSM48_CC_CAUSE_INTERWORKING);
+		disconnect_tmgw(call);
+		/* TODO: transition from TEARDOWN to DEAD_SIP */
+		return;
+	}
+	sip_tx_packet(&resp, &call->udp_sin);
+	call->sip_state = SIP_STATE_INVITE_200;
+	call->sip_tx_count = 1;
+}
+
+void
 signal_invite_error(call)
 	struct call *call;
 {
--- a/sip-in/mncc_handle.c	Sun Sep 18 15:44:22 2022 -0800
+++ b/sip-in/mncc_handle.c	Sun Sep 18 16:17:31 2022 -0800
@@ -38,7 +38,15 @@
 	struct call *call;
 	struct gsm_mncc *msg;
 {
-	/* handling to be implemented */
+	if (call->mncc_state != MNCC_STATE_STARTED &&
+	    call->mncc_state != MNCC_STATE_ALERTING) {
+		syslog(LOG_ERR, "MNCC_SETUP_CNF in wrong MNCC state 0x%x",
+			call->mncc_state);
+		return;
+	}
+	call->mncc_state = MNCC_STATE_ANSWERED;
+	call->overall_state = OVERALL_STATE_ANSWERED;
+	signal_invite_200(call);
 }
 
 static void