changeset 246:74dae755f85a

themwi-test-mtc: convert to libnumdb2
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 14 Aug 2023 22:37:11 -0800
parents 5141e21596bb
children c6a3fb913c53
files mtctest/Makefile mtctest/setup.c
diffstat 2 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mtctest/Makefile	Mon Aug 14 22:23:27 2023 -0800
+++ b/mtctest/Makefile	Mon Aug 14 22:37:11 2023 -0800
@@ -2,7 +2,7 @@
 CFLAGS=	-O2
 PROG=	themwi-test-mtc
 OBJS=	disconnect.o dummy_rtp.o main.o setup.o sig_handler.o sock_conn.o
-LIBS=	../libnumdb/libnumdb.a ../libutil/libutil.a
+LIBS=	../libnumdb2/libnumdb.a ../libutil/libutil.a
 INSTBIN=/usr/local/bin
 
 all:	${PROG}
--- a/mtctest/setup.c	Mon Aug 14 22:23:27 2023 -0800
+++ b/mtctest/setup.c	Mon Aug 14 22:37:11 2023 -0800
@@ -13,6 +13,8 @@
 #include <strings.h>
 #include "../include/mncc.h"
 #include "../include/gsm48_const.h"
+#include "../include/number_db_v2.h"
+#include "../libnumdb2/lookup_func.h"
 
 struct gsm_mncc setup_msg;
 
@@ -22,6 +24,7 @@
 {
 	int rc, ndig;
 	char short_num[5], long_num[12];
+	struct short_number_rec *snum;
 
 	if (!strncmp(arg, "imsi:", 5)) {
 		rc = grok_imsi_user_arg(arg, setup_msg.imsi);
@@ -60,22 +63,31 @@
 			fprintf(stderr, "error reading number database\n");
 			exit(1);
 		}
-		rc = lookup_short_dial_number(short_num, long_num);
-		if (!rc) {
+		snum = numdb_lookup_short(short_num);
+		if (!snum) {
 			fprintf(stderr,
 				"error: short dial number %s is not valid\n",
 				short_num);
 			exit(1);
 		}
-		if (long_num[0]) {
+		switch (snum->short_num_type) {
+		case SHORT_NUM_TYPE_ABBREV:
 			setup_msg.called.type = GSM48_TON_INTERNATIONAL;
 			setup_msg.called.plan = GSM48_NPI_ISDN_E164;
-			setup_msg.called.number[0] = '1';
-			strcpy(setup_msg.called.number+1, long_num);
-		} else {
+			sprintf(setup_msg.called.number, "1%03u%03u%04u",
+				snum->fullnum_prefix[0],
+				snum->fullnum_prefix[1], snum->short_num);
+			break;
+		case SHORT_NUM_TYPE_ITN:
 			setup_msg.called.type = GSM48_TON_NET_SPEC;
 			setup_msg.called.plan = GSM48_NPI_PRIVATE;
 			strcpy(setup_msg.called.number, short_num);
+			break;
+		default:
+			fprintf(stderr,
+			"error: short dial number %s is not abbrev or ITN\n",
+				short_num);
+			exit(1);
 		}
 		setup_msg.fields |= MNCC_F_CALLED;
 		return;