diff sip-in/disconnect.c @ 64:1f863c63f96b

sip-in: beginning of disconnect handling
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 18 Sep 2022 15:29:30 -0800
parents
children 5beb51de1bae
line wrap: on
line diff
--- /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);
+	}
+}