diff sip-out/mncc_sig_out.c @ 154:e54b0a9e322f

beginning of themwi-sip-out
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 11 Oct 2022 23:04:01 -0800
parents sip-in/mncc_handle.c@99fd4ae573ae
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sip-out/mncc_sig_out.c	Tue Oct 11 23:04:01 2022 -0800
@@ -0,0 +1,145 @@
+/*
+ * In this module we implement functions that send MNCC messages
+ * to OsmoMSC via themwi-mncc, to be called by SIP and TMGW events.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.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 "../include/out_routes.h"
+#include "call.h"
+
+void
+mncc_signal_alerting(call)
+	struct call *call;
+{
+	struct gsm_mncc msg;
+
+	if (call->mncc_state == MNCC_STATE_ALERTING)
+		return;
+	bzero(&msg, sizeof(struct gsm_mncc));
+	msg.msg_type = MNCC_ALERT_REQ;
+	msg.callref = call->mncc_callref;
+	send_mncc_to_sock(call->mncc, &msg, sizeof(struct gsm_mncc));
+	call->mncc_state = MNCC_STATE_ALERTING;
+}
+
+void
+mncc_signal_ibt_ring(call)
+	struct call *call;
+{
+	struct gsm_mncc msg;
+
+	bzero(&msg, sizeof(struct gsm_mncc));
+	if (call->overall_state == OVERALL_STATE_RINGING &&
+	    call->mncc_state != MNCC_STATE_ALERTING) {
+		msg.msg_type = MNCC_ALERT_REQ;
+		call->mncc_state = MNCC_STATE_ALERTING;
+	} else
+		msg.msg_type = MNCC_PROGRESS_REQ;
+	msg.callref = call->mncc_callref;
+	msg.fields |= MNCC_F_PROGRESS;
+	msg.progress.coding = GSM48_CAUSE_CODING_GSM;
+	msg.progress.location = GSM48_CAUSE_LOC_NET_BEYOND;
+	msg.progress.descr = GSM48_PROGR_IN_BAND_AVAIL;
+	send_mncc_to_sock(call->mncc, &msg, sizeof(struct gsm_mncc));
+}
+
+void
+mncc_signal_answer_sup(call)
+	struct call *call;
+{
+	struct gsm_mncc msg;
+
+	bzero(&msg, sizeof(struct gsm_mncc));
+	msg.msg_type = MNCC_SETUP_RSP;
+	msg.callref = call->mncc_callref;
+	send_mncc_to_sock(call->mncc, &msg, sizeof(struct gsm_mncc));
+	call->mncc_state = MNCC_STATE_CONNECTED;
+}
+
+void
+mncc_dtmf_start_ok(call)
+	struct call *call;
+{
+	struct gsm_mncc msg;
+
+	bzero(&msg, sizeof(struct gsm_mncc));
+	msg.msg_type = MNCC_START_DTMF_RSP;
+	msg.callref = call->mncc_callref;
+	msg.fields |= MNCC_F_KEYPAD;
+	msg.keypad = call->dtmf_digit;
+	send_mncc_to_sock(call->mncc, &msg, sizeof(struct gsm_mncc));
+}
+
+void
+mncc_dtmf_start_err(call)
+	struct call *call;
+{
+	struct gsm_mncc msg;
+
+	bzero(&msg, sizeof(struct gsm_mncc));
+	msg.msg_type = MNCC_START_DTMF_REJ;
+	msg.callref = call->mncc_callref;
+	mncc_set_cause(&msg, GSM48_CAUSE_LOC_PRN_S_LU,
+			GSM48_CC_CAUSE_PROTO_ERR);
+	send_mncc_to_sock(call->mncc, &msg, sizeof(struct gsm_mncc));
+}
+
+void
+mncc_dtmf_stop_ok(call)
+	struct call *call;
+{
+	struct gsm_mncc msg;
+
+	bzero(&msg, sizeof(struct gsm_mncc));
+	msg.msg_type = MNCC_STOP_DTMF_RSP;
+	msg.callref = call->mncc_callref;
+	send_mncc_to_sock(call->mncc, &msg, sizeof(struct gsm_mncc));
+}
+
+void
+mncc_send_hold_ack(call)
+	struct call *call;
+{
+	struct gsm_mncc msg;
+
+	bzero(&msg, sizeof(struct gsm_mncc));
+	msg.msg_type = MNCC_HOLD_CNF;
+	msg.callref = call->mncc_callref;
+	send_mncc_to_sock(call->mncc, &msg, sizeof(struct gsm_mncc));
+}
+
+void
+mncc_send_retrieve_ack(call)
+	struct call *call;
+{
+	struct gsm_mncc msg;
+
+	bzero(&msg, sizeof(struct gsm_mncc));
+	msg.msg_type = MNCC_RETRIEVE_CNF;
+	msg.callref = call->mncc_callref;
+	send_mncc_to_sock(call->mncc, &msg, sizeof(struct gsm_mncc));
+}
+
+void
+send_rtp_connect(call)
+	struct call *call;
+{
+	struct gsm_mncc_rtp rtp;
+
+	bzero(&rtp, sizeof(struct gsm_mncc_rtp));
+	rtp.msg_type = MNCC_RTP_CONNECT;
+	rtp.callref = call->mncc_callref;
+	bcopy(&call->gsm_rtp_tmgw, &rtp.addr, sizeof(struct sockaddr_storage));
+	send_mncc_to_sock(call->mncc, &rtp, sizeof(struct gsm_mncc_rtp));
+}