comparison mtctest/setup.c @ 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
comparison
equal deleted inserted replaced
245:5141e21596bb 246:74dae755f85a
11 #include <stdlib.h> 11 #include <stdlib.h>
12 #include <string.h> 12 #include <string.h>
13 #include <strings.h> 13 #include <strings.h>
14 #include "../include/mncc.h" 14 #include "../include/mncc.h"
15 #include "../include/gsm48_const.h" 15 #include "../include/gsm48_const.h"
16 #include "../include/number_db_v2.h"
17 #include "../libnumdb2/lookup_func.h"
16 18
17 struct gsm_mncc setup_msg; 19 struct gsm_mncc setup_msg;
18 20
19 static void 21 static void
20 set_called_number(arg) 22 set_called_number(arg)
21 char *arg; 23 char *arg;
22 { 24 {
23 int rc, ndig; 25 int rc, ndig;
24 char short_num[5], long_num[12]; 26 char short_num[5], long_num[12];
27 struct short_number_rec *snum;
25 28
26 if (!strncmp(arg, "imsi:", 5)) { 29 if (!strncmp(arg, "imsi:", 5)) {
27 rc = grok_imsi_user_arg(arg, setup_msg.imsi); 30 rc = grok_imsi_user_arg(arg, setup_msg.imsi);
28 if (rc < 0) { 31 if (rc < 0) {
29 fprintf(stderr, 32 fprintf(stderr,
58 dehyphen_number_string(arg, short_num); 61 dehyphen_number_string(arg, short_num);
59 if (read_number_db() < 0) { 62 if (read_number_db() < 0) {
60 fprintf(stderr, "error reading number database\n"); 63 fprintf(stderr, "error reading number database\n");
61 exit(1); 64 exit(1);
62 } 65 }
63 rc = lookup_short_dial_number(short_num, long_num); 66 snum = numdb_lookup_short(short_num);
64 if (!rc) { 67 if (!snum) {
65 fprintf(stderr, 68 fprintf(stderr,
66 "error: short dial number %s is not valid\n", 69 "error: short dial number %s is not valid\n",
67 short_num); 70 short_num);
68 exit(1); 71 exit(1);
69 } 72 }
70 if (long_num[0]) { 73 switch (snum->short_num_type) {
74 case SHORT_NUM_TYPE_ABBREV:
71 setup_msg.called.type = GSM48_TON_INTERNATIONAL; 75 setup_msg.called.type = GSM48_TON_INTERNATIONAL;
72 setup_msg.called.plan = GSM48_NPI_ISDN_E164; 76 setup_msg.called.plan = GSM48_NPI_ISDN_E164;
73 setup_msg.called.number[0] = '1'; 77 sprintf(setup_msg.called.number, "1%03u%03u%04u",
74 strcpy(setup_msg.called.number+1, long_num); 78 snum->fullnum_prefix[0],
75 } else { 79 snum->fullnum_prefix[1], snum->short_num);
80 break;
81 case SHORT_NUM_TYPE_ITN:
76 setup_msg.called.type = GSM48_TON_NET_SPEC; 82 setup_msg.called.type = GSM48_TON_NET_SPEC;
77 setup_msg.called.plan = GSM48_NPI_PRIVATE; 83 setup_msg.called.plan = GSM48_NPI_PRIVATE;
78 strcpy(setup_msg.called.number, short_num); 84 strcpy(setup_msg.called.number, short_num);
85 break;
86 default:
87 fprintf(stderr,
88 "error: short dial number %s is not abbrev or ITN\n",
89 short_num);
90 exit(1);
79 } 91 }
80 setup_msg.fields |= MNCC_F_CALLED; 92 setup_msg.fields |= MNCC_F_CALLED;
81 return; 93 return;
82 case 10: 94 case 10:
83 dehyphen_number_string(arg, long_num); 95 dehyphen_number_string(arg, long_num);