FreeCalypso > hg > themwi-system-sw
annotate sip-out/invite.c @ 157:7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 12 Oct 2022 07:56:14 -0800 |
parents | 0bacca1f2f7b |
children | 51cf5ea7f320 |
rev | line source |
---|---|
156
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we handle responses to INVITE. |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/socket.h> |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/time.h> |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <netinet/in.h> |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdio.h> |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdint.h> |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdlib.h> |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <string.h> |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <strings.h> |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <syslog.h> |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include "../include/gsm48_const.h" |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "../include/out_routes.h" |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "../libsip/parse.h" |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include "../libsip/sdp.h" |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 #include "../libsip/out_msg.h" |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #include "call.h" |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 extern char *get_single_header(); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 extern char *extract_to_tag(); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
157
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
25 extern unsigned sip_linger_invite_err; |
156
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 extern unsigned sip_linger_response_err; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 static |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 check_sdp_present(msg) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 struct sip_pkt_rx *msg; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 char *hval; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 if (!msg->msg_body_len) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 return 0; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 hval = get_single_header(msg, "Content-Type", "c", (int *) 0); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 if (!hval) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 return 0; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 if (!strcasecmp(hval, "application/sdp")) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 return 1; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 else |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 return 0; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 static |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 extract_sdp(call, msg) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 struct call *call; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 struct sip_pkt_rx *msg; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 struct sdp_parse sdp_parse; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 int rc, use_pcma; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 rc = parse_incoming_sdp(msg->msg_body, msg->msg_body_len, &sdp_parse); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 if (rc < 0) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 return rc; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 switch (sdp_parse.codec_mask) { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 case SDP_CODEC_MASK_PCMU: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 case SDP_CODEC_MASK_BOTH: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 use_pcma = 0; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 break; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 case SDP_CODEC_MASK_PCMA: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 case SDP_CODEC_MASK_BOTH | SDP_CODEC_MASK_PCMA_PREF: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 use_pcma = 1; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 break; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 default: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 return -2; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 call->pstn_rtp_remote.sin_family = AF_INET; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 call->pstn_rtp_remote.sin_addr = sdp_parse.ip_addr; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 call->pstn_rtp_remote.sin_port = htons(sdp_parse.audio_port); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 call->use_pcma = use_pcma; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 return 0; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 static void |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 handle_1xx(call, msg, tag, sin) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 struct call *call; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 struct sip_pkt_rx *msg; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 char *tag; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 struct sockaddr_in *sin; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 int rc; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 switch (call->sip_state) { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 case SIP_STATE_INV_SENT: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 call->sip_state = SIP_STATE_100_RCVD; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 /* FALL THRU */ |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 case SIP_STATE_100_RCVD: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 if (msg->status_code == 180) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 call->overall_state = OVERALL_STATE_RINGING; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 if (check_sdp_present(msg) && |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 call->mgw_state == MGW_STATE_ALLOCATED) { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 rc = extract_sdp(call, msg); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 if (rc < 0) { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 syslog(LOG_ERR, "bad SDP in %03u response", |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 msg->status_code); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 call->overall_state = OVERALL_STATE_TEARDOWN; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU, |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 GSM48_CC_CAUSE_BEARER_CA_UNAVAIL); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 disconnect_tmgw(call); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 initiate_sip_cancel(call); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 return; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 tmgw_send_mdcx_connect(call, 1); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 } else if (msg->status_code == 180) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 mncc_signal_alerting(call); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 return; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 case SIP_STATE_ACCEPT_100: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 initiate_sip_cancel(call); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 return; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 static |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 send_ack(call, tag, sin) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 struct call *call; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 char *tag; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 struct sockaddr_in *sin; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 struct sip_msg_out msg; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 int rc; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 rc = start_request_out_msg(&msg, "ACK", call->to_uri); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 if (rc < 0) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 return rc; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 rc = add_req_boilerplate(&msg, call, "1 ACK", tag); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 if (rc < 0) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 return rc; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 out_msg_finish(&msg); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 sip_tx_packet(&msg, sin); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 return 0; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 static void |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 handle_200(call, msg, tag, sin) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 struct call *call; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 struct sip_pkt_rx *msg; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 char *tag; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 struct sockaddr_in *sin; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 int rc; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 switch (call->sip_state) { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 case SIP_STATE_INV_SENT: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 case SIP_STATE_100_RCVD: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 rc = send_ack(call, tag, sin); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 if (rc < 0) { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 syslog(LOG_CRIT, |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 "ACK to %03u response exceeds msg size!", |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 msg->status_code); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 call->overall_state = OVERALL_STATE_TEARDOWN; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU, |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 GSM48_CC_CAUSE_DEST_OOO); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 disconnect_tmgw(call); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 call->sip_state = SIP_STATE_ENDED; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 sip_mark_end_time(call, sip_linger_response_err); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 return; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 if (tag) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 strcpy(call->to_tag, tag); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 call->sip_state = SIP_STATE_CONNECTED; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 if (!check_sdp_present(msg)) { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 syslog(LOG_ERR, "error: %03u response has no SDP", |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 msg->status_code); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 call->overall_state = OVERALL_STATE_TEARDOWN; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU, |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 GSM48_CC_CAUSE_DEST_OOO); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 disconnect_tmgw(call); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 initiate_bye(call); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 return; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 rc = extract_sdp(call, msg); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 if (rc < 0) { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 syslog(LOG_ERR, "bad SDP in %03u response", |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 msg->status_code); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 call->overall_state = OVERALL_STATE_TEARDOWN; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU, |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 GSM48_CC_CAUSE_BEARER_CA_UNAVAIL); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 disconnect_tmgw(call); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 initiate_bye(call); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 return; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 call->overall_state = OVERALL_STATE_CONNECTED; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 switch (call->mgw_state) { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 case MGW_STATE_ALLOCATED: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 case MGW_STATE_IBT_CONN: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 tmgw_send_mdcx_connect(call, 0); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 return; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 case MGW_STATE_MDCX_IBT: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 return; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 default: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 syslog(LOG_CRIT, |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 "FATAL: invalid MGW state 0x%x on INVITE %03u response", |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 call->mgw_state, msg->status_code); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 exit(1); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 case SIP_STATE_CONNECTED: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 case SIP_STATE_BYE_SENT: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 if (tag && call->to_tag[0] && strcmp(call->to_tag, tag)) { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 syslog(LOG_ERR, |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 "received %u response with different To tag, ignoring", |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 msg->status_code); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 return; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 send_ack(call, call->to_tag, sin); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 return; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 case SIP_STATE_CANCEL_SENT: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 case SIP_STATE_ACCEPT_100: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 case SIP_STATE_ACCEPT_200: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 rc = send_ack(call, tag, sin); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 if (rc < 0) { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 syslog(LOG_CRIT, |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 "ACK to %03u response exceeds msg size!", |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 msg->status_code); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 call->sip_state = SIP_STATE_ENDED; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 sip_mark_end_time(call, sip_linger_response_err); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 return; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 if (tag) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 strcpy(call->to_tag, tag); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 initiate_bye(call); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 return; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 case SIP_STATE_ENDED: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 return; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 default: |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 syslog(LOG_CRIT, |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 "FATAL: invalid SIP state 0x%x on INVITE %03u response", |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 call->sip_state, msg->status_code); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 exit(1); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 static void |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 handle_error(call, msg, tag, sin) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 struct call *call; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 struct sip_pkt_rx *msg; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 char *tag; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 struct sockaddr_in *sin; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 { |
157
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
240 int rc; |
156
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 |
157
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
242 rc = send_ack(call, tag, sin); |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
243 if (rc < 0) |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
244 syslog(LOG_CRIT, "ACK to %03u response exceeds msg size!", |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
245 msg->status_code); |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
246 switch (call->sip_state) { |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
247 case SIP_STATE_INV_SENT: |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
248 case SIP_STATE_100_RCVD: |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
249 call->overall_state = OVERALL_STATE_TEARDOWN; |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
250 disconnect_mncc(call, GSM48_CAUSE_LOC_NET_BEYOND, |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
251 sip_error_to_gsm_cause(msg->status_code)); |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
252 disconnect_tmgw(call); |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
253 call->sip_state = SIP_STATE_ENDED; |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
254 sip_mark_end_time(call, sip_linger_invite_err); |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
255 return; |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
256 case SIP_STATE_CANCEL_SENT: |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
257 case SIP_STATE_ACCEPT_100: |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
258 case SIP_STATE_ACCEPT_200: |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
259 call->sip_state = SIP_STATE_ENDED; |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
260 sip_mark_end_time(call, sip_linger_invite_err); |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
261 return; |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
262 case SIP_STATE_CONNECTED: |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
263 case SIP_STATE_BYE_SENT: |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
264 case SIP_STATE_ENDED: |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
265 return; |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
266 default: |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
267 syslog(LOG_CRIT, |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
268 "FATAL: invalid SIP state 0x%x on INVITE %03u response", |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
269 call->sip_state, msg->status_code); |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
270 exit(1); |
7643b779dbea
sip-out: handle INVITE errors, except for cause mapping
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
271 } |
156
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 void |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 handle_invite_response(call, msg, sin) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 struct call *call; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 struct sip_pkt_rx *msg; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 struct sockaddr_in *sin; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 char *tag; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 tag = extract_to_tag(msg, call->to_uri); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 if (tag) { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 if (!*tag) { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 syslog(LOG_ERR, |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 "To tag in INVITE %03u response is null", |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 msg->status_code); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 tag = 0; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 } else if (strlen(tag) > MAX_SIP_TO_TAG) { |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 syslog(LOG_ERR, |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 "To tag in INVITE %03u response exceeds length limit", |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 msg->status_code); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 tag = 0; |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 } |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 if (msg->status_code >= 100 && msg->status_code <= 199) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 handle_1xx(call, msg, tag, sin); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 else if (msg->status_code >= 200 && msg->status_code <= 299) |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 handle_200(call, msg, tag, sin); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 else |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 handle_error(call, msg, tag, sin); |
0bacca1f2f7b
sip-out: handle all INVITE responses, except errors
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 } |