changeset 39:64b9f0f90726

themwi-test-mtc: handle DTMF from MS
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 03 Sep 2022 14:44:19 -0800
parents 020ba624bdd8
children 77d980126efd
files libutil/Makefile libutil/dtmf_valid.c mtctest/sig_handler.c
diffstat 3 files changed, 41 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libutil/Makefile	Sun Jul 10 00:36:31 2022 -0800
+++ b/libutil/Makefile	Sat Sep 03 14:44:19 2022 -0800
@@ -1,7 +1,7 @@
 CC=	gcc
 CFLAGS=	-O2
-OBJS=	extdigits.o imsi_entry.o mncc_debug.o mncc_utils.o nanp_valid.o \
-	numstring.o sockinit.o
+OBJS=	dtmf_valid.o extdigits.o imsi_entry.o mncc_debug.o mncc_utils.o \
+	nanp_valid.o numstring.o sockinit.o
 LIB=	libutil.a
 
 all:	${LIB}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libutil/dtmf_valid.c	Sat Sep 03 14:44:19 2022 -0800
@@ -0,0 +1,29 @@
+/*
+ * Here we implement a function that validates DTMF digits which arrive
+ * from GSM MS via MNCC_START_DTMF_IND.
+ */
+
+is_valid_dtmf_digit(c)
+{
+	switch (c) {
+	case '0':
+	case '1':
+	case '2':
+	case '3':
+	case '4':
+	case '5':
+	case '6':
+	case '7':
+	case '8':
+	case '9':
+	case '*':
+	case '#':
+	case 'A':
+	case 'B':
+	case 'C':
+	case 'D':
+		return(1);
+	default:
+		return(0);
+	}
+}
--- a/mtctest/sig_handler.c	Sun Jul 10 00:36:31 2022 -0800
+++ b/mtctest/sig_handler.c	Sat Sep 03 14:44:19 2022 -0800
@@ -216,9 +216,16 @@
 	case MNCC_START_DTMF_IND:
 		printf("MNCC_START_DTMF_IND: MS sending DTMF start\n");
 		print_fields(msg);
-		msg->msg_type = MNCC_START_DTMF_REJ;
-		mncc_set_cause(msg, GSM48_CAUSE_LOC_PRN_S_LU,
-				GSM48_CC_CAUSE_SERV_OPT_UNIMPL);
+		if (msg->fields & MNCC_F_KEYPAD &&
+		    is_valid_dtmf_digit(msg->keypad)) {
+			printf("Responding with ACK\n");
+			msg->msg_type = MNCC_START_DTMF_RSP;
+		} else {
+			printf("Responding with Reject\n");
+			msg->msg_type = MNCC_START_DTMF_REJ;
+			mncc_set_cause(msg, GSM48_CAUSE_LOC_PRN_S_LU,
+					GSM48_CC_CAUSE_INVAL_MAND_INF);
+		}
 		send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
 		return;
 	case MNCC_STOP_DTMF_IND: