FreeCalypso > hg > themwi-system-sw
annotate sip-in/retrans.c @ 142:bb9a75557f59
sip-in: syslog SIP message retransmission failures
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 08 Oct 2022 13:42:27 -0800 |
parents | c1c94b7fc2e2 |
children | bf3b19bf57e9 |
rev | line source |
---|---|
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we handle retransmission of INVITE responses |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * and BYE requests. |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/socket.h> |
109
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
108
diff
changeset
|
8 #include <sys/time.h> |
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <netinet/in.h> |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdio.h> |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdint.h> |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <stdlib.h> |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <string.h> |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <strings.h> |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <syslog.h> |
78
72b7d85d6354
sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
16 #include "../include/gsm48_const.h" |
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "../libsip/out_msg.h" |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include "call.h" |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 extern unsigned cfg_retrans_count; |
109
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
108
diff
changeset
|
21 extern unsigned sip_linger_error; |
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 extern struct call *call_list; |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 void |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 run_periodic_retrans() |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 { |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 struct call *call; |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 struct sip_msg_out msg; |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 for (call = call_list; call; call = call->next) { |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 switch (call->sip_state) { |
108
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
32 case SIP_STATE_RINGING_REL: |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
33 if (call->sip_tx_count < cfg_retrans_count) { |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
34 start_response_out_msg(&msg, "180 Ringing"); |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
35 fill_invite_resp_from_call(&msg, call); |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
36 out_msg_add_header(&msg, "Require", "100rel"); |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
37 out_msg_add_header(&msg, "RSeq", "1"); |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
38 out_msg_finish(&msg); |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
39 sip_tx_packet(&msg, &call->udp_sin); |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
40 call->sip_tx_count++; |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
41 } else { |
142
bb9a75557f59
sip-in: syslog SIP message retransmission failures
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
42 syslog(LOG_ERR, |
bb9a75557f59
sip-in: syslog SIP message retransmission failures
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
43 "Call in%06u: 100rel retrans timeout"); |
108
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
44 call->overall_state = OVERALL_STATE_TEARDOWN; |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
45 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU, |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
46 GSM48_CC_CAUSE_INTERWORKING); |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
47 disconnect_tmgw(call); |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
48 strcpy(call->invite_fail, |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
49 "504 100rel retransmissions exhausted"); |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
50 signal_invite_error(call); |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
51 } |
0d6435808bcd
sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
52 break; |
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 case SIP_STATE_INVITE_200: |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 if (call->sip_tx_count < cfg_retrans_count) { |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 fill_invite_200_resp(&msg, call); |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 sip_tx_packet(&msg, &call->udp_sin); |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 call->sip_tx_count++; |
78
72b7d85d6354
sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
58 } else { |
142
bb9a75557f59
sip-in: syslog SIP message retransmission failures
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
59 syslog(LOG_ERR, |
bb9a75557f59
sip-in: syslog SIP message retransmission failures
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
60 "Call in%06u: 200 retrans timeout"); |
78
72b7d85d6354
sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
61 call->overall_state = OVERALL_STATE_TEARDOWN; |
72b7d85d6354
sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
62 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU, |
72b7d85d6354
sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
63 GSM48_CC_CAUSE_INTERWORKING); |
72b7d85d6354
sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
64 disconnect_tmgw(call); |
81
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
65 initiate_bye(call); |
78
72b7d85d6354
sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
66 } |
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 break; |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 case SIP_STATE_INVITE_ERR: |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 if (call->sip_tx_count < cfg_retrans_count) { |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 start_response_out_msg(&msg, call->invite_fail); |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 fill_invite_resp_from_call(&msg, call); |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 out_msg_finish(&msg); |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 sip_tx_packet(&msg, &call->udp_sin); |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 call->sip_tx_count++; |
109
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
108
diff
changeset
|
75 } else { |
142
bb9a75557f59
sip-in: syslog SIP message retransmission failures
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
76 syslog(LOG_ERR, |
bb9a75557f59
sip-in: syslog SIP message retransmission failures
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
77 "Call in%06u: late error retrans timeout"); |
78
72b7d85d6354
sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
78 call->sip_state = SIP_STATE_ENDED; |
109
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
108
diff
changeset
|
79 sip_mark_end_time(call, sip_linger_error); |
110
c1c94b7fc2e2
sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
80 transition_dead_sip(call); |
109
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
108
diff
changeset
|
81 } |
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 break; |
81
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
83 case SIP_STATE_BYE_SENT: |
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
84 if (call->sip_tx_count < cfg_retrans_count) { |
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
85 fill_bye_out_msg(&msg, call); |
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
86 sip_tx_packet(&msg, &call->udp_sin); |
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
87 call->sip_tx_count++; |
109
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
108
diff
changeset
|
88 } else { |
142
bb9a75557f59
sip-in: syslog SIP message retransmission failures
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
89 syslog(LOG_ERR, |
bb9a75557f59
sip-in: syslog SIP message retransmission failures
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
90 "Call in%06u: BYE-out retrans timeout"); |
81
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
91 call->sip_state = SIP_STATE_ENDED; |
109
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
108
diff
changeset
|
92 sip_mark_end_time(call, sip_linger_error); |
110
c1c94b7fc2e2
sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
93 transition_dead_sip(call); |
109
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
108
diff
changeset
|
94 } |
81
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
95 break; |
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 } |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 } |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 } |