FreeCalypso > hg > themwi-system-sw
annotate sip-in/invite.c @ 68:709b78a4ebf0
sip-in: implement retransmission of INVITE responses
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 18 Sep 2022 21:56:20 -0800 |
parents | 5beb51de1bae |
children | 21276f045026 |
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> |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
8 #include <arpa/inet.h> |
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdio.h> |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
10 #include <stdint.h> |
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdlib.h> |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <string.h> |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <strings.h> |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <syslog.h> |
66
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
15 #include "../include/gsm48_const.h" |
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "../libsip/parse.h" |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "../libsip/uas_basic.h" |
51
36a30349b490
sip-in: parse INVITE From header
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
18 #include "../libsip/grok_from.h" |
49
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
19 #include "../libsip/req_supp.h" |
55
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
20 #include "../libsip/sdp.h" |
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "../libsip/out_msg.h" |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
22 #include "call.h" |
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
55
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
24 extern struct in_addr sip_bind_ip; |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
25 extern unsigned sip_bind_port; |
49
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
26 extern int cfg_use_100rel; |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
27 extern struct call *call_list; |
49
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
28 |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
29 extern struct call *find_call_by_sip_id(); |
50
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
30 extern char *get_single_header(); |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
31 |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
32 fill_invite_resp_from_call(msg, call) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
33 struct sip_msg_out *msg; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
34 struct call *call; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
35 { |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
36 char cseq_str[32]; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
37 int rc; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
38 |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
39 rc = out_msg_add_header(msg, "From", call->invite_from); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
40 if (rc < 0) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
41 return rc; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
42 rc = out_msg_add_header(msg, "To", call->invite_to); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
43 if (rc < 0) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
44 return rc; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
45 rc = out_msg_add_header(msg, "Call-ID", call->sip_call_id); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
46 if (rc < 0) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
47 return rc; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
48 sprintf(cseq_str, "%u INVITE", call->invite_cseq); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
49 rc = out_msg_add_header(msg, "CSeq", cseq_str); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
50 if (rc < 0) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
51 return rc; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
52 return out_msg_add_header(msg, "Via", call->invite_via); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
53 } |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
54 |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
55 fill_invite_200_resp(msg, call) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
56 struct sip_msg_out *msg; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
57 struct call *call; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
58 { |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
59 char contact_str[80]; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
60 struct sdp_gen sdp; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
61 int rc; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
62 |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
63 start_response_out_msg(msg, "200 CONNECT"); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
64 rc = fill_invite_resp_from_call(msg, call); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
65 if (rc < 0) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
66 return rc; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
67 sprintf(contact_str, "<sip:%s:%u;transport=udp>", |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
68 inet_ntoa(sip_bind_ip), sip_bind_port); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
69 rc = out_msg_add_header(msg, "Contact", contact_str); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
70 if (rc < 0) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
71 return rc; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
72 rc = out_msg_add_header(msg, "Content-Type", "application/sdp"); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
73 if (rc < 0) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
74 return rc; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
75 bzero(&sdp, sizeof sdp); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
76 sdp.conn_ip = call->pstn_rtp_local.sin_addr; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
77 sdp.conn_port = ntohs(call->pstn_rtp_local.sin_port); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
78 sdp.codec_mask = call->use_pcma ? SDP_CODEC_MASK_PCMA |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
79 : SDP_CODEC_MASK_PCMU; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
80 sdp.session_id = (sdp.conn_port << 16) | call->sdp_addend; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
81 sdp.owner_ip = sip_bind_ip; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
82 return out_msg_finish_sdp(msg, &sdp); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
83 } |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
84 |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
85 static void |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
86 invite_new_call(req, ess, sin) |
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 struct sip_pkt_rx *req; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 struct uas_parse_hdrs *ess; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 struct sockaddr_in *sin; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 { |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 char uri_user[13], *called_nanp; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 struct sip_msg_out resp; |
51
36a30349b490
sip-in: parse INVITE From header
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
93 struct grok_from gfrom; |
49
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
94 struct supported_ext supp_ext; |
50
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
95 char *hval, *unsup_ext; |
55
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
96 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
|
97 struct sdp_parse sdp_parse; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
98 struct sdp_gen sdp_gen; |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
99 struct call *call; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
100 char *dp; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
101 unsigned copylen; |
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 int rc; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 /* extract called number from Request-URI */ |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 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
|
106 if (rc < 0) { |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 not_nanp: start_response_out_msg(&resp, |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 "416 Request-URI is not a NANP number"); |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 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
|
110 if (rc < 0) { |
49
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
111 error_resp_toolong: syslog(LOG_ERR, |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
112 "INVITE early error response length exceeded"); |
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 return; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 } |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 out_msg_finish(&resp); |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 sip_tx_packet(&resp, sin); |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
117 return; |
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 } |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 if (uri_user[0] == '+') { |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 if (grok_number_string(uri_user+1, 0) != 11 || |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 uri_user[1] != '1') |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 goto not_nanp; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 called_nanp = uri_user + 2; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 } else switch (grok_number_string(uri_user)) { |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 case 10: |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 called_nanp = uri_user; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 break; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 case 11: |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 if (uri_user[0] != '1') |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 goto not_nanp; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 called_nanp = uri_user + 1; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 break; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 default: |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 goto not_nanp; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 } |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 if (!is_nanp_valid_prefix(called_nanp)) |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 goto not_nanp; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 /* 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
|
139 refresh_number_db(); |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 if (!is_nanp_locally_owned(called_nanp)) { |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 start_response_out_msg(&resp, |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 "404 Called number does not belong here"); |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 goto error_resp; |
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 } |
51
36a30349b490
sip-in: parse INVITE From header
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
145 /* parse and validate From header */ |
36a30349b490
sip-in: parse INVITE From header
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
146 rc = grok_from_header(ess->from, &gfrom); |
36a30349b490
sip-in: parse INVITE From header
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
147 if (rc < 0) { |
36a30349b490
sip-in: parse INVITE From header
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
148 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
|
149 goto error_resp; |
36a30349b490
sip-in: parse INVITE From header
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
150 } |
49
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
151 /* check 100rel and catch any unsupported requirements */ |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
152 supp_ext.name = "100rel"; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
153 supp_ext.req_flag = &ext_100rel_req; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
154 supp_ext.sup_flag = &ext_100rel_sup; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
155 ext_100rel_req = ext_100rel_sup = 0; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
156 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
|
157 if (rc < 0) { |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
158 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
|
159 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
|
160 if (rc < 0) |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
161 goto error_resp_toolong; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
162 goto error_resp; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
163 } |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
164 if (ext_100rel_req) |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
165 use_100rel = 1; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
166 else if (ext_100rel_sup) |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
167 use_100rel = cfg_use_100rel; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
168 else |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
169 use_100rel = 0; |
50
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
170 /* 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
|
171 if (!req->msg_body_len) { |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
172 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
|
173 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
|
174 if (rc < 0) |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
175 goto error_resp_toolong; |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
176 goto error_resp; |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
177 } |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
178 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
|
179 if (!hval) { |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
180 start_response_out_msg(&resp, |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
181 "415 Missing Content-Type header"); |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
182 goto error_415; |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
183 } |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
184 if (strcasecmp(hval, "application/sdp")) { |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
185 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
|
186 goto error_415; |
daf1c26d7ae2
sip-in: check INVITE Content-Type header
Mychaela Falconia <falcon@freecalypso.org>
parents:
49
diff
changeset
|
187 } |
55
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
188 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
|
189 if (rc < 0) { |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
190 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
|
191 goto error_resp; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
192 } |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
193 switch (sdp_parse.codec_mask) { |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
194 case SDP_CODEC_MASK_PCMU: |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
195 case SDP_CODEC_MASK_BOTH: |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
196 use_pcma = 0; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
197 break; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
198 case SDP_CODEC_MASK_PCMA: |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
199 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
|
200 use_pcma = 1; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
201 break; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
202 default: |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
203 start_response_out_msg(&resp, |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
204 "488 Unsupported codec selection"); |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
205 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
|
206 if (rc < 0) |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
207 goto error_resp_toolong; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
208 rc = out_msg_add_header(&resp, "Content-Type", |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
209 "application/sdp"); |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
210 if (rc < 0) |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
211 goto error_resp_toolong; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
212 bzero(&sdp_gen, sizeof sdp_gen); |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
213 sdp_gen.owner_ip = sip_bind_ip; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
214 sdp_gen.conn_ip = sip_bind_ip; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
215 sdp_gen.codec_mask = SDP_CODEC_MASK_BOTH; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
216 rc = out_msg_finish_sdp(&resp, &sdp_gen); |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
217 if (rc < 0) |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
218 goto error_resp_toolong; |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
219 sip_tx_packet(&resp, sin); |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
220 return; |
55
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
221 } |
f1d59210f7b2
sip-in INVITE processing: grok SDP
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
222 /* 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
|
223 rc = connect_gsm_mtcall(); |
d61d0136f6a5
sip-in INVITE processing: return "GSM service is offline" indication
Mychaela Falconia <falcon@freecalypso.org>
parents:
55
diff
changeset
|
224 if (rc < 0) { |
d61d0136f6a5
sip-in INVITE processing: return "GSM service is offline" indication
Mychaela Falconia <falcon@freecalypso.org>
parents:
55
diff
changeset
|
225 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
|
226 goto error_resp; |
d61d0136f6a5
sip-in INVITE processing: return "GSM service is offline" indication
Mychaela Falconia <falcon@freecalypso.org>
parents:
55
diff
changeset
|
227 } |
d61d0136f6a5
sip-in INVITE processing: return "GSM service is offline" indication
Mychaela Falconia <falcon@freecalypso.org>
parents:
55
diff
changeset
|
228 /* stateful processing begins */ |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
229 call = malloc(sizeof(struct call) + strlen(ess->call_id) + |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
230 strlen(ess->from) + strlen(ess->to) + strlen(ess->via) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
231 + 4); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
232 if (!call) { |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
233 syslog(LOG_CRIT, "failed malloc for incoming call!"); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
234 start_response_out_msg(&resp, |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
235 "503 Gateway resource allocation failure"); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
236 goto error_resp; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
237 } |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
238 bzero(call, sizeof(struct call)); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
239 dp = (char *)(call + 1); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
240 copylen = strlen(ess->call_id) + 1; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
241 call->sip_call_id = dp; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
242 bcopy(ess->call_id, dp, copylen); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
243 dp += copylen; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
244 copylen = strlen(ess->from) + 1; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
245 call->invite_from = dp; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
246 bcopy(ess->from, dp, copylen); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
247 dp += copylen; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
248 copylen = strlen(ess->to) + 1; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
249 call->invite_to = dp; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
250 bcopy(ess->to, dp, copylen); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
251 dp += copylen; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
252 copylen = strlen(ess->via) + 1; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
253 call->invite_via = dp; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
254 bcopy(ess->via, dp, copylen); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
255 call->invite_cseq = ess->cseq_num; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
256 bcopy(sin, &call->udp_sin, sizeof(struct sockaddr_in)); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
257 bcopy(called_nanp, call->called_nanp, 11); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
258 call->from_uri = call->invite_from + (gfrom.uri - ess->from); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
259 call->from_uri_len = gfrom.uri_len; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
260 call->from_user = call->invite_from + (gfrom.user - ess->from); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
261 call->from_user_len = gfrom.user_len; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
262 call->use_100rel = use_100rel; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
263 call->pstn_rtp_remote.sin_family = AF_INET; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
264 call->pstn_rtp_remote.sin_addr = sdp_parse.ip_addr; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
265 call->pstn_rtp_remote.sin_port = htons(sdp_parse.audio_port); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
266 call->use_pcma = use_pcma; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
267 /* generate 100 response */ |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
268 start_response_out_msg(&resp, "100 Proceeding"); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
269 rc = fill_invite_resp_from_call(&resp, call); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
270 if (rc < 0) { |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
271 syslog(LOG_ERR, "INVITE 100 response length exceeded"); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
272 free(call); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
273 return; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
274 } |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
275 out_msg_finish(&resp); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
276 sip_tx_packet(&resp, sin); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
277 /* add to call list */ |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
278 call->next = call_list; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
279 call_list = call; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
280 /* send CRCX to TMGW */ |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
281 tmgw_send_crcx(call); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
282 call->overall_state = OVERALL_STATE_CRCX; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
283 call->sip_state = SIP_STATE_INVITE_PROC; |
48
8117d8ee44a5
sip-in: beginning of INVITE handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 } |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
285 |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
286 static void |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
287 invite_existing_call(req, ess, sin, call) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
288 struct sip_pkt_rx *req; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
289 struct uas_parse_hdrs *ess; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
290 struct sockaddr_in *sin; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
291 struct call *call; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
292 { |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
293 struct sip_msg_out resp; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
294 int rc; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
295 |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
296 if (ess->cseq_num != call->invite_cseq) { |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
297 start_response_out_msg(&resp, "501 Re-INVITE not supported"); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
298 rc = add_resp_basic_headers(&resp, ess, req->req_method); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
299 if (rc < 0) { |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
300 syslog(LOG_ERR, |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
301 "sending 501 Re-INVITE error: response length exceeded"); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
302 return; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
303 } |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
304 out_msg_finish(&resp); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
305 sip_tx_packet(&resp, sin); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
306 return; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
307 } |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
308 /* it's a retransmission, not a re-INVITE */ |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
309 switch (call->sip_state) { |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
310 case SIP_STATE_INVITE_PROC: |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
311 start_response_out_msg(&resp, "100 Proceeding"); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
312 fill_invite_resp_from_call(&resp, call); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
313 out_msg_finish(&resp); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
314 sip_tx_packet(&resp, sin); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
315 return; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
316 case SIP_STATE_RINGING: |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
317 case SIP_STATE_RINGING_PRACK: |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
318 start_response_out_msg(&resp, "180 Ringing"); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
319 fill_invite_resp_from_call(&resp, call); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
320 out_msg_finish(&resp); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
321 sip_tx_packet(&resp, sin); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
322 return; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
323 case SIP_STATE_INVITE_200: |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
324 case SIP_STATE_CONNECTED: |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
325 fill_invite_200_resp(&resp, call); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
326 sip_tx_packet(&resp, sin); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
327 return; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
328 case SIP_STATE_INVITE_ERR: |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
329 start_response_out_msg(&resp, call->invite_fail); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
330 fill_invite_resp_from_call(&resp, call); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
331 out_msg_finish(&resp); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
332 sip_tx_packet(&resp, sin); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
333 return; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
334 default: |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
335 /* silently discard */ |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
336 return; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
337 } |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
338 } |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
339 |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
340 void |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
341 handle_sip_invite(req, ess, sin) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
342 struct sip_pkt_rx *req; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
343 struct uas_parse_hdrs *ess; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
344 struct sockaddr_in *sin; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
345 { |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
346 struct call *call; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
347 |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
348 call = find_call_by_sip_id(ess->call_id); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
349 if (call) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
350 invite_existing_call(req, ess, sin, call); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
351 else |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
352 invite_new_call(req, ess, sin); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
353 } |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
354 |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
355 void |
65
7c0309df59f8
sip-in: handling of ALERTING state
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
356 signal_invite_ringing(call) |
7c0309df59f8
sip-in: handling of ALERTING state
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
357 struct call *call; |
7c0309df59f8
sip-in: handling of ALERTING state
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
358 { |
7c0309df59f8
sip-in: handling of ALERTING state
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
359 struct sip_msg_out resp; |
7c0309df59f8
sip-in: handling of ALERTING state
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
360 |
7c0309df59f8
sip-in: handling of ALERTING state
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
361 start_response_out_msg(&resp, "180 Ringing"); |
7c0309df59f8
sip-in: handling of ALERTING state
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
362 fill_invite_resp_from_call(&resp, call); |
7c0309df59f8
sip-in: handling of ALERTING state
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
363 out_msg_finish(&resp); |
7c0309df59f8
sip-in: handling of ALERTING state
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
364 sip_tx_packet(&resp, &call->udp_sin); |
7c0309df59f8
sip-in: handling of ALERTING state
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
365 call->sip_state = SIP_STATE_RINGING; |
7c0309df59f8
sip-in: handling of ALERTING state
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
366 } |
7c0309df59f8
sip-in: handling of ALERTING state
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
367 |
7c0309df59f8
sip-in: handling of ALERTING state
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
368 void |
66
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
369 signal_invite_200(call) |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
370 struct call *call; |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
371 { |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
372 struct sip_msg_out resp; |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
373 int rc; |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
374 |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
375 rc = fill_invite_200_resp(&resp, call); |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
376 if (rc < 0) { |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
377 syslog(LOG_ERR, "INVITE 200 response length exceeded"); |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
378 call->sip_state = SIP_STATE_MSG_SIZE_ERR; |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
379 call->overall_state = OVERALL_STATE_TEARDOWN; |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
380 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU, |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
381 GSM48_CC_CAUSE_INTERWORKING); |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
382 disconnect_tmgw(call); |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
383 /* TODO: transition from TEARDOWN to DEAD_SIP */ |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
384 return; |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
385 } |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
386 sip_tx_packet(&resp, &call->udp_sin); |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
387 call->sip_state = SIP_STATE_INVITE_200; |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
388 call->sip_tx_count = 1; |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
389 } |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
390 |
5beb51de1bae
sip-in: got as far as propagating GSM CC CONNECT to INVITE 200
Mychaela Falconia <falcon@freecalypso.org>
parents:
65
diff
changeset
|
391 void |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
392 signal_invite_error(call) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
393 struct call *call; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
394 { |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
395 struct sip_msg_out resp; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
396 int rc; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
397 |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
398 start_response_out_msg(&resp, call->invite_fail); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
399 rc = fill_invite_resp_from_call(&resp, call); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
400 if (rc < 0) { |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
401 syslog(LOG_ERR, "INVITE late error response length exceeded"); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
402 call->sip_state = SIP_STATE_MSG_SIZE_ERR; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
403 /* TODO: transition from TEARDOWN to DEAD_SIP */ |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
404 return; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
405 } |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
406 out_msg_finish(&resp); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
407 sip_tx_packet(&resp, &call->udp_sin); |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
408 call->sip_state = SIP_STATE_INVITE_ERR; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
409 call->sip_tx_count = 1; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
57
diff
changeset
|
410 } |