FreeCalypso > hg > themwi-system-sw
annotate mtctest/setup.c @ 57:d61d0136f6a5
sip-in INVITE processing: return "GSM service is offline" indication
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 08 Sep 2022 13:39:42 -0800 |
parents | 08d7794cdd0a |
children | 5141e21596bb |
rev | line source |
---|---|
21
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we compose the MNCC_SETUP_REQ message |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * initiating our test MT call. |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/socket.h> |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <ctype.h> |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdio.h> |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdint.h> |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdlib.h> |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <string.h> |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <strings.h> |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "../include/mncc.h" |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include "../include/gsm48_const.h" |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 struct gsm_mncc setup_msg; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 static void |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 set_called_number(arg) |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 char *arg; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 int rc, ndig; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 char short_num[5], long_num[12]; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 if (!strncmp(arg, "imsi:", 5)) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 rc = grok_imsi_user_arg(arg, setup_msg.imsi); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 if (rc < 0) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 fprintf(stderr, |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 "error: call-by-IMSI destination \"%s\" is invalid\n", |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 arg); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 exit(1); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 return; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 if (arg[0] == '+') { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 if (arg[1] != '1') { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 fprintf(stderr, |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 "error: plus-format call destination number must begin with 1\n"); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 exit(1); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 if (grok_number_string(arg+1, 1) != 11) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 bad_plus1: fprintf(stderr, |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 "error: malformed +1 call destination number\n"); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 exit(1); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 dehyphen_number_string(arg+1, setup_msg.called.number); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 if (!is_nanp_valid_prefix(setup_msg.called.number+1)) |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 goto bad_plus1; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 setup_msg.called.type = GSM48_TON_INTERNATIONAL; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 setup_msg.called.plan = GSM48_NPI_ISDN_E164; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 setup_msg.fields |= MNCC_F_CALLED; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 return; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 } |
31
08d7794cdd0a
themwi-test-mtc: fix bug in called number parsing
Mychaela Falconia <falcon@freecalypso.org>
parents:
21
diff
changeset
|
55 ndig = grok_number_string(arg, 1); |
21
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 switch (ndig) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 case 4: |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 dehyphen_number_string(arg, short_num); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 if (read_number_db() < 0) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 fprintf(stderr, "error reading number database\n"); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 exit(1); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 rc = lookup_short_dial_number(short_num, long_num); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 if (!rc) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 fprintf(stderr, |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 "error: short dial number %s is not valid\n", |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 short_num); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 exit(1); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 if (long_num[0]) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 setup_msg.called.type = GSM48_TON_INTERNATIONAL; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 setup_msg.called.plan = GSM48_NPI_ISDN_E164; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 setup_msg.called.number[0] = '1'; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 strcpy(setup_msg.called.number+1, long_num); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 } else { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 setup_msg.called.type = GSM48_TON_NET_SPEC; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 setup_msg.called.plan = GSM48_NPI_PRIVATE; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 strcpy(setup_msg.called.number, short_num); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 setup_msg.fields |= MNCC_F_CALLED; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 return; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 case 10: |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 dehyphen_number_string(arg, long_num); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 if (!is_nanp_valid_prefix(long_num)) |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 break; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 setup_msg.called.type = GSM48_TON_INTERNATIONAL; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 setup_msg.called.plan = GSM48_NPI_ISDN_E164; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 setup_msg.called.number[0] = '1'; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 strcpy(setup_msg.called.number+1, long_num); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 setup_msg.fields |= MNCC_F_CALLED; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 return; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 case 11: |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 dehyphen_number_string(arg, long_num); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 if (long_num[0] != '1') |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 break; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 if (!is_nanp_valid_prefix(long_num+1)) |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 break; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 setup_msg.called.type = GSM48_TON_INTERNATIONAL; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 setup_msg.called.plan = GSM48_NPI_ISDN_E164; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 strcpy(setup_msg.called.number, long_num); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 setup_msg.fields |= MNCC_F_CALLED; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 return; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 fprintf(stderr, "error: call destination number \"%s\" is invalid\n", |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 arg); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 exit(1); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 static void |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 set_calling_number(arg) |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 char *arg; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 unsigned ndig; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 int c; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 if (!strcmp(arg, "unavail")) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 setup_msg.calling.present = GSM48_PRES_UNAVAIL; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 return; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 if (!strcmp(arg, "blocked")) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 setup_msg.calling.present = GSM48_PRES_RESTR; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 return; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 if (*arg == '+') { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 setup_msg.calling.type = GSM48_TON_INTERNATIONAL; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 arg++; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 for (ndig = 0; *arg; ) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 c = *arg++; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 if (c == ',') |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 break; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 if (c == '-') |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 continue; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 if (!is_valid_ext_digit(c)) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 fprintf(stderr, |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 "error: calling number argument contains invalid digit \'%c\'\n", |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 c); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 exit(1); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 if (ndig >= 32) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 fprintf(stderr, |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 "error: calling number argument is too long\n"); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 exit(1); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 setup_msg.calling.number[ndig] = c; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 ndig++; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 if (!ndig) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 fprintf(stderr, |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 "error: calling number argument has no digits\n"); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 exit(1); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 setup_msg.calling.plan = GSM48_NPI_ISDN_E164; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 for (;;) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 while (*arg == ',') |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 arg++; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 if (!*arg) |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 return; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 if (!strncmp(arg, "ton=", 4)) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 arg += 4; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 if (arg[0] >= '0' && arg[1] <= '7' && !isdigit(arg[1])){ |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 setup_msg.calling.type = *arg - '0'; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 arg++; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 } else { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 fprintf(stderr, |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 "error: calling number argument contains invalid ton= part\n"); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 exit(1); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 } else if (!strncmp(arg, "npi=", 4)) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 arg += 4; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 if (arg[0] >= '0' && arg[1] <= '9' && !isdigit(arg[1])){ |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 setup_msg.calling.plan = *arg - '0'; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 arg++; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 } else if (arg[0] == '1' && arg[1] >= '0' && |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 arg[1] <= '5' && !isdigit(arg[2])) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 setup_msg.calling.plan = atoi(arg); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 arg += 2; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 } else { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 fprintf(stderr, |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 "error: calling number argument contains invalid npi= part\n"); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 exit(1); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 } else if (!strncmp(arg, "restr", 5)) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 arg += 5; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 setup_msg.calling.present = GSM48_PRES_RESTR; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 } else if (!strncmp(arg, "vp", 2)) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 arg += 2; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 setup_msg.calling.screen = GSM48_SCRN_USER_PASS; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 } else if (!strncmp(arg, "vf", 2)) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 arg += 2; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 setup_msg.calling.screen = GSM48_SCRN_USER_FAIL; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 } else if (!strncmp(arg, "net", 3)) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 arg += 3; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 setup_msg.calling.screen = GSM48_SCRN_NETWORK; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 } else { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 inv_qual: fprintf(stderr, |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 "error: calling number argument contains invalid qualifier\n"); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 exit(1); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 if (!*arg) |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 return; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 if (*arg != ',') |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 goto inv_qual; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 void |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 init_setup_msg(from, to) |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 char *from, *to; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 setup_msg.msg_type = MNCC_SETUP_REQ; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 setup_msg.callref = 1; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 set_called_number(to); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 if (from) { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 set_calling_number(from); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 setup_msg.fields |= MNCC_F_CALLING; |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 } |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 void |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 send_setup_msg() |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 { |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 if (setup_msg.imsi[0]) |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 printf("Calling IMSI %s\n", setup_msg.imsi); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 else |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 printf("Calling %s%s\n", |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 setup_msg.called.type == GSM48_TON_INTERNATIONAL ? "+" |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 : "", |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 setup_msg.called.number); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 send_mncc_to_gsm(&setup_msg, sizeof(struct gsm_mncc)); |
cc0e1c6e33c3
themwi-test-mtc utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 } |