FreeCalypso > hg > themwi-system-sw
annotate sip-in/invite.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 | f1d59210f7b2 |
children | 02761f1ae5e5 |
rev | line source |
---|---|
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Here we implement our handling of SIP INVITE method. |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/socket.h> |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <netinet/in.h> |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdlib.h> |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <string.h> |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <strings.h> |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <syslog.h> |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <unistd.h> |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "../libsip/parse.h" |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include "../libsip/uas_basic.h" |
51
36a30349b490
sip-in: parse INVITE From header
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
16 #include "../libsip/grok_from.h" |
49
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
17 #include "../libsip/req_supp.h" |
55
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
18 #include "../libsip/sdp.h" |
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 #include "../libsip/out_msg.h" |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
55
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
21 extern struct in_addr sip_bind_ip; |
49
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
22 extern int cfg_use_100rel; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
23 |
50
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
24 extern char *get_single_header(); |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
25 |
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 void |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 handle_sip_invite(req, ess, sin) |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 struct sip_pkt_rx *req; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 struct uas_parse_hdrs *ess; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 struct sockaddr_in *sin; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 { |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 char uri_user[13], *called_nanp; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 struct sip_msg_out resp; |
51
36a30349b490
sip-in: parse INVITE From header
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
34 struct grok_from gfrom; |
49
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
35 struct supported_ext supp_ext; |
50
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
36 char *hval, *unsup_ext; |
55
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
37 int ext_100rel_req, ext_100rel_sup, use_100rel, use_pcma; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
38 struct sdp_parse sdp_parse; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
39 struct sdp_gen sdp_gen; |
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 int rc; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 /* check for existing Call-ID will go here */ |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 /* extract called number from Request-URI */ |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 rc = user_from_sip_uri(req->req_uri, uri_user, 12); |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 if (rc < 0) { |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 not_nanp: start_response_out_msg(&resp, |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 "416 Request-URI is not a NANP number"); |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 error_resp: rc = add_resp_basic_headers(&resp, ess, req->req_method); |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 if (rc < 0) { |
49
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
50 error_resp_toolong: syslog(LOG_ERR, |
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 "INVITE error response length exceeded"); |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 return; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 } |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 out_msg_finish(&resp); |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 sip_tx_packet(&resp, sin); |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 return; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 } |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 if (uri_user[0] == '+') { |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 if (grok_number_string(uri_user+1, 0) != 11 || |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 uri_user[1] != '1') |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 goto not_nanp; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 called_nanp = uri_user + 2; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 } else switch (grok_number_string(uri_user)) { |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 case 10: |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 called_nanp = uri_user; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 break; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 case 11: |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 if (uri_user[0] != '1') |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 goto not_nanp; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 called_nanp = uri_user + 1; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 break; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 default: |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 goto not_nanp; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 } |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 if (!is_nanp_valid_prefix(called_nanp)) |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 goto not_nanp; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 /* it is valid NANP - but is it one of ours? */ |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 refresh_number_db(); |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 if (!is_nanp_locally_owned(called_nanp)) { |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 start_response_out_msg(&resp, |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 "404 Called number does not belong here"); |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 goto error_resp; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 } |
51
36a30349b490
sip-in: parse INVITE From header
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
84 /* parse and validate From header */ |
36a30349b490
sip-in: parse INVITE From header
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
85 rc = grok_from_header(ess->from, &gfrom); |
36a30349b490
sip-in: parse INVITE From header
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
86 if (rc < 0) { |
36a30349b490
sip-in: parse INVITE From header
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
87 start_response_out_msg(&resp, "400 Malformed From header"); |
36a30349b490
sip-in: parse INVITE From header
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
88 goto error_resp; |
36a30349b490
sip-in: parse INVITE From header
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
89 } |
49
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
90 /* check 100rel and catch any unsupported requirements */ |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
91 supp_ext.name = "100rel"; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
92 supp_ext.req_flag = &ext_100rel_req; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
93 supp_ext.sup_flag = &ext_100rel_sup; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
94 ext_100rel_req = ext_100rel_sup = 0; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
95 rc = parse_require_supported(req, &supp_ext, 1, &unsup_ext); |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
96 if (rc < 0) { |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
97 start_response_out_msg(&resp, "420 Extension not supported"); |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
98 rc = out_msg_add_header(&resp, "Unsupported", unsup_ext); |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
99 if (rc < 0) |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
100 goto error_resp_toolong; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
101 goto error_resp; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
102 } |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
103 if (ext_100rel_req) |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
104 use_100rel = 1; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
105 else if (ext_100rel_sup) |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
106 use_100rel = cfg_use_100rel; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
107 else |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
108 use_100rel = 0; |
50
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
109 /* did the caller send an SDP message body? */ |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
110 if (!req->msg_body_len) { |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
111 start_response_out_msg(&resp, "415 Missing SDP body"); |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
112 error_415: rc = out_msg_add_header(&resp, "Accept", "application/sdp"); |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
113 if (rc < 0) |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
114 goto error_resp_toolong; |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
115 goto error_resp; |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
116 } |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
117 hval = get_single_header(req, "Content-Type", "c", (int *) 0); |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
118 if (!hval) { |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
119 start_response_out_msg(&resp, |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
120 "415 Missing Content-Type header"); |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
121 goto error_415; |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
122 } |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
123 if (strcasecmp(hval, "application/sdp")) { |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
124 start_response_out_msg(&resp, "415 Unsupported Content-Type"); |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
125 goto error_415; |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
126 } |
55
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
127 rc = parse_incoming_sdp(req->msg_body, req->msg_body_len, &sdp_parse); |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
128 if (rc < 0) { |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
129 start_response_out_msg(&resp, "488 Malformed SDP body"); |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
130 goto error_resp; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
131 } |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
132 switch (sdp_parse.codec_mask) { |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
133 case SDP_CODEC_MASK_PCMU: |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
134 case SDP_CODEC_MASK_BOTH: |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
135 use_pcma = 0; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
136 break; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
137 case SDP_CODEC_MASK_PCMA: |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
138 case SDP_CODEC_MASK_BOTH | SDP_CODEC_MASK_PCMA_PREF: |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
139 use_pcma = 1; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
140 break; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
141 default: |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
142 start_response_out_msg(&resp, |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
143 "488 Unsupported codec selection"); |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
144 rc = add_resp_basic_headers(&resp, ess, req->req_method); |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
145 if (rc < 0) |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
146 goto error_resp_toolong; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
147 rc = out_msg_add_header(&resp, "Content-Type", |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
148 "application/sdp"); |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
149 if (rc < 0) |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
150 goto error_resp_toolong; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
151 bzero(&sdp_gen, sizeof sdp_gen); |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
152 sdp_gen.owner_ip = sip_bind_ip; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
153 sdp_gen.conn_ip = sip_bind_ip; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
154 sdp_gen.codec_mask = SDP_CODEC_MASK_BOTH; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
155 rc = out_msg_finish_sdp(&resp, &sdp_gen); |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
156 if (rc < 0) |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
157 goto error_resp_toolong; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
158 sip_tx_packet(&resp, sin); |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
159 return; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
160 } |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
161 /* SIP INVITE validation done - check if GSM service is up */ |
57
d61d0136f6a5
sip-in INVITE processing: return "GSM service is offline" indication
Mychaela Falconia <falcon@freecalypso.org>
parents:
55
diff
changeset
|
162 rc = connect_gsm_mtcall(); |
d61d0136f6a5
sip-in INVITE processing: return "GSM service is offline" indication
Mychaela Falconia <falcon@freecalypso.org>
parents:
55
diff
changeset
|
163 if (rc < 0) { |
d61d0136f6a5
sip-in INVITE processing: return "GSM service is offline" indication
Mychaela Falconia <falcon@freecalypso.org>
parents:
55
diff
changeset
|
164 start_response_out_msg(&resp, "480 GSM service is offline"); |
d61d0136f6a5
sip-in INVITE processing: return "GSM service is offline" indication
Mychaela Falconia <falcon@freecalypso.org>
parents:
55
diff
changeset
|
165 goto error_resp; |
d61d0136f6a5
sip-in INVITE processing: return "GSM service is offline" indication
Mychaela Falconia <falcon@freecalypso.org>
parents:
55
diff
changeset
|
166 } |
d61d0136f6a5
sip-in INVITE processing: return "GSM service is offline" indication
Mychaela Falconia <falcon@freecalypso.org>
parents:
55
diff
changeset
|
167 /* stateful processing begins */ |
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 } |