FreeCalypso > hg > themwi-system-sw
annotate sip-out/call_setup.c @ 267:81958b35f74d
NANP validation: allow made-up area codes of N9X form
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 13 Nov 2023 15:28:09 -0800 |
parents | 556cd78f750a |
children |
rev | line source |
---|---|
62
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
2 * In this module we implement our initial handling of MNCC_SETUP_IND. |
62
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/socket.h> |
109
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
63
diff
changeset
|
7 #include <sys/time.h> |
62
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <netinet/in.h> |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdio.h> |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdint.h> |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdlib.h> |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <string.h> |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <strings.h> |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <syslog.h> |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include "../include/mncc.h" |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "../include/gsm48_const.h" |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
17 #include "../include/out_routes.h" |
62
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include "call.h" |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
20 extern struct call *find_call_by_mncc_callref(); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
21 |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
22 extern int block_1900_numbers; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
23 extern struct call *call_list; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
24 |
62
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 static void |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
26 reject_mo_call(mncc, callref, cause_loc, cause_val) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
27 struct mncc_conn *mncc; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
28 uint32_t callref; |
62
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 { |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
30 struct gsm_mncc msg; |
62
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
32 bzero(&msg, sizeof(struct gsm_mncc)); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
33 msg.msg_type = MNCC_REJ_REQ; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
34 msg.callref = callref; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
35 mncc_set_cause(&msg, cause_loc, cause_val); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
36 send_mncc_to_sock(mncc, &msg, sizeof(struct gsm_mncc)); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
37 } |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
38 |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
39 static void |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
40 send_call_proceeding(call) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
41 struct call *call; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
42 { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
43 struct gsm_mncc msg; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
44 |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
45 bzero(&msg, sizeof(struct gsm_mncc)); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
46 msg.msg_type = MNCC_CALL_PROC_REQ; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
47 msg.callref = call->mncc_callref; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
48 send_mncc_to_sock(call->mncc, &msg, sizeof(struct gsm_mncc)); |
62
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 } |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 void |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
52 handle_setup_ind(mncc, msg, msglen) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
53 struct mncc_conn *mncc; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
54 struct gsm_mncc *msg; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
55 unsigned msglen; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
56 { |
62
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 struct call *call; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
58 struct sip_out_dest *dest; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
59 struct special_num_route *special_rt; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
60 char to_sip_user[MAX_SIP_USER_PART+1]; |
265
e4a93ad611f3
liboutrt: add prefix length output arg to route_e164_number()
Mychaela Falconia <falcon@freecalypso.org>
parents:
259
diff
changeset
|
61 int rc, prefix_len; |
62
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
63 if (msglen != sizeof(struct gsm_mncc)) { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
64 syslog(LOG_CRIT, |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
65 "FATAL: Rx MNCC_SETUP_IND has wrong length"); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
66 exit(1); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
67 } |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
68 /* check for duplicates */ |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
69 call = find_call_by_mncc_callref(mncc, msg->callref); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
70 if (call) { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
71 syslog(LOG_ERR, "duplicate MNCC_SETUP_IND for callref 0x%x", |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
72 msg->callref); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
73 /* drop it like OsmoMSC's mncc_builtin does */ |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
74 return; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
75 } |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
76 if (!(msg->fields & MNCC_F_CALLED) || |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
77 !(msg->fields & MNCC_F_BEARER_CAP)) { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
78 syslog(LOG_ERR, "rejecting MO call 0x%x: missing mandatory IE", |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
79 msg->callref); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
80 reject_mo_call(mncc, msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
81 GSM48_CC_CAUSE_INVAL_MAND_INF); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
82 return; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
83 } |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
84 /* route based on destination address */ |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
85 refresh_out_routes_db(); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
86 if (msg->called.type == GSM48_TON_INTERNATIONAL) { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
87 rc = grok_number_string(msg->called.number, 0); |
203
e89619893c1e
sip-out: require minimum of 7 digits for E.164 numbers
Mychaela Falconia <falcon@freecalypso.org>
parents:
154
diff
changeset
|
88 if (rc < 7 || rc > MAX_E164_NUMBER) { |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
89 inv_nr_format: reject_mo_call(mncc, msg->callref, |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
90 GSM48_CAUSE_LOC_PRN_S_LU, |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
91 GSM48_CC_CAUSE_INV_NR_FORMAT); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
92 return; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
93 } |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
94 if (msg->called.number[0] == '0') |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
95 goto inv_nr_format; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
96 if (msg->called.number[0] == '1') { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
97 if (rc != 11) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
98 goto inv_nr_format; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
99 if (!is_nanp_valid_prefix(msg->called.number+1)) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
100 goto inv_nr_format; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
101 if (msg->called.number[1] == '9' && |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
102 msg->called.number[2] == '0' && |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
103 msg->called.number[3] == '0' && |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
104 block_1900_numbers) { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
105 call_barred: reject_mo_call(mncc, msg->callref, |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
106 GSM48_CAUSE_LOC_PRN_S_LU, |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
107 GSM48_CC_CAUSE_OP_DET_BARRING); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
108 return; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
109 } |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
110 } |
265
e4a93ad611f3
liboutrt: add prefix length output arg to route_e164_number()
Mychaela Falconia <falcon@freecalypso.org>
parents:
259
diff
changeset
|
111 rc = route_e164_number(msg->called.number, &dest, &prefix_len); |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
112 if (!rc) { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
113 no_route_to_dest: reject_mo_call(mncc, msg->callref, |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
114 GSM48_CAUSE_LOC_PRN_S_LU, |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
115 GSM48_CC_CAUSE_NO_ROUTE); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
116 return; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
117 } |
266
556cd78f750a
sip-out: require explicit routes to made-up N9X area codes
Mychaela Falconia <falcon@freecalypso.org>
parents:
265
diff
changeset
|
118 /* made-up N9X area codes require explicit routes */ |
556cd78f750a
sip-out: require explicit routes to made-up N9X area codes
Mychaela Falconia <falcon@freecalypso.org>
parents:
265
diff
changeset
|
119 if (msg->called.number[0] == '1' && |
556cd78f750a
sip-out: require explicit routes to made-up N9X area codes
Mychaela Falconia <falcon@freecalypso.org>
parents:
265
diff
changeset
|
120 msg->called.number[2] == '9' && prefix_len < 4) |
556cd78f750a
sip-out: require explicit routes to made-up N9X area codes
Mychaela Falconia <falcon@freecalypso.org>
parents:
265
diff
changeset
|
121 goto no_route_to_dest; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
122 to_sip_user[0] = '+'; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
123 strcpy(to_sip_user+1, msg->called.number); |
259
9f96e5b14755
sip-out: implement E911 special handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
256
diff
changeset
|
124 special_rt = 0; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
125 } else { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
126 rc = route_special_number(msg->called.number, &dest, |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
127 &special_rt); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
128 if (!rc) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
129 goto no_route_to_dest; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
130 strcpy(to_sip_user, special_rt->sip_user); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
131 } |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
132 /* validate From number */ |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
133 if (!(msg->fields & MNCC_F_CALLING)) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
134 goto call_barred; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
135 if (msg->calling.type != GSM48_TON_INTERNATIONAL) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
136 goto call_barred; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
137 if (grok_number_string(msg->calling.number, 0) != 11 || |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
138 msg->calling.number[0] != '1') |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
139 goto call_barred; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
140 /* speech-only restriction */ |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
141 if (msg->bearer_cap.transfer != GSM48_BCAP_ITCAP_SPEECH || |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
142 msg->bearer_cap.mode != GSM48_BCAP_TMOD_CIRCUIT) { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
143 syslog(LOG_ERR, "rejecting MO call 0x%x: bad bearer cap", |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
144 msg->callref); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
145 reject_mo_call(mncc, msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
146 GSM48_CC_CAUSE_BEARER_CA_UNAVAIL); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
147 return; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
148 } |
259
9f96e5b14755
sip-out: implement E911 special handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
256
diff
changeset
|
149 /* E911 special handling */ |
9f96e5b14755
sip-out: implement E911 special handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
256
diff
changeset
|
150 if (special_rt && special_rt->flags & SPECIAL_NUM_FLAG_E911) { |
9f96e5b14755
sip-out: implement E911 special handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
256
diff
changeset
|
151 rc = e911_call_preen(msg); |
9f96e5b14755
sip-out: implement E911 special handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
256
diff
changeset
|
152 if (!rc) |
9f96e5b14755
sip-out: implement E911 special handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
256
diff
changeset
|
153 goto call_barred; |
9f96e5b14755
sip-out: implement E911 special handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
256
diff
changeset
|
154 } |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
155 /* TMGW must be up and running */ |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
156 rc = connect_tmgw_socket(); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
157 if (rc < 0) { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
158 reject_mo_call(mncc, msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
159 GSM48_CC_CAUSE_NETWORK_OOO); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
160 return; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
161 } |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
162 /* allocate struct call and being stateful processing */ |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
163 call = malloc(sizeof(struct call)); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
164 if (!call) { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
165 syslog(LOG_CRIT, "failed malloc for outbound call!"); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
166 reject_mo_call(mncc, msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
167 GSM48_CC_CAUSE_RESOURCE_UNAVAIL); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
168 return; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
169 } |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
170 bzero(call, sizeof(struct call)); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
171 call->mncc = mncc; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
172 call->mncc_callref = msg->callref; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
173 call->from_user[0] = '+'; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
174 strcpy(call->from_user+1, msg->calling.number); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
175 sprintf(call->to_uri, "sip:%s@%s", to_sip_user, dest->domain); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
176 bcopy(&dest->sin, &call->udp_sin, sizeof(struct sockaddr_in)); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
177 call->next = call_list; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
178 call_list = call; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
179 send_call_proceeding(call); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
180 call->overall_state = OVERALL_STATE_GSM_RTP; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
181 call->mncc_state = MNCC_STATE_MO_PROC; |
256
63252528a56c
sip-out: add CDR log line
Mychaela Falconia <falcon@freecalypso.org>
parents:
203
diff
changeset
|
182 syslog(LOG_INFO, "Outbound call from %s to %s", call->from_user, |
63252528a56c
sip-out: add CDR log line
Mychaela Falconia <falcon@freecalypso.org>
parents:
203
diff
changeset
|
183 call->to_uri); |
62
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 } |