changeset 64:1f863c63f96b

sip-in: beginning of disconnect handling
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 18 Sep 2022 15:29:30 -0800
parents e5aee661e3b2
children 7c0309df59f8
files sip-in/Makefile sip-in/disconnect.c
diffstat 2 files changed, 60 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sip-in/Makefile	Sun Sep 18 15:01:11 2022 -0800
+++ b/sip-in/Makefile	Sun Sep 18 15:29:30 2022 -0800
@@ -1,8 +1,9 @@
 CC=	gcc
 CFLAGS=	-O2
 PROG=	themwi-sip-in
-OBJS=	call_list.o call_setup.o invite.o main.o mgw_ops.o mgw_sock.o \
-	mncc_handle.o mncc_sock.o readconf.o sip_log.o sip_uas.o sip_udp.o
+OBJS=	call_list.o call_setup.o disconnect.o invite.o main.o mgw_ops.o \
+	mgw_sock.o mncc_handle.o mncc_sock.o readconf.o sip_log.o sip_uas.o \
+	sip_udp.o
 LIBS=	../libnumdb/libnumdb.a ../libsip/libsip.a ../libutil/libutil.a
 INSTBIN=/usr/local/bin
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sip-in/disconnect.c	Sun Sep 18 15:29:30 2022 -0800
@@ -0,0 +1,57 @@
+/*
+ * In this module we implement call disconnection and clearing procedures.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <syslog.h>
+#include "../include/mncc.h"
+#include "../include/gsm48_const.h"
+#include "call.h"
+
+void
+disconnect_mncc(call, cause_loc, cause_val)
+	struct call *call;
+{
+	struct gsm_mncc msg;
+
+	switch (call->mncc_state) {
+	case MNCC_STATE_NO_EXIST:
+	case MNCC_STATE_DISCONNECT:
+	case MNCC_STATE_RELEASE:
+		return;
+	}
+	bzero(&msg, sizeof(struct gsm_mncc));
+	msg.msg_type = MNCC_DISC_REQ;
+	msg.callref = call->mncc_callref;
+	mncc_set_cause(&msg, cause_loc, cause_val);
+	send_mncc_to_gsm(&msg, sizeof(struct gsm_mncc));
+	call->mncc_state = MNCC_STATE_DISCONNECT;
+}
+
+void
+disconnect_tmgw(call)
+	struct call *call;
+{
+	switch (call->mgw_state) {
+	case MGW_STATE_NO_EXIST:
+	case MGW_STATE_CONNECTING:
+	case MGW_STATE_DELETING:
+		return;
+	case MGW_STATE_ALLOCATED:
+	case MGW_STATE_COMPLETE:
+		tmgw_send_dlcx(call);
+		return;
+	default:
+		syslog(LOG_CRIT,
+			"FATAL: invalid MGW state 0x%x in disconnect_tmgw()",
+			call->mgw_state);
+		exit(1);
+	}
+}