annotate sip-out/retrans.c @ 217:9f6a148ceb25

tcpserv-dump: brown paper bag
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 24 Jul 2023 22:33:01 -0800
parents e54b0a9e322f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
68
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
154
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
2 * In this module we handle retransmission of our outgoing SIP UAC packets.
68
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
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 #include <sys/types.h>
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/socket.h>
109
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents: 108
diff changeset
7 #include <sys/time.h>
68
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <netinet/in.h>
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdio.h>
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdint.h>
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <stdlib.h>
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <string.h>
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <strings.h>
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include <syslog.h>
78
72b7d85d6354 sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 68
diff changeset
15 #include "../include/gsm48_const.h"
154
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
16 #include "../include/out_routes.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;
154
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
21 extern unsigned sip_linger_timeout;
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
22 extern unsigned sip_linger_bye_out_err;
68
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 extern struct call *call_list;
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 void
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 run_periodic_retrans()
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 {
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 struct call *call;
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 struct sip_msg_out msg;
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 for (call = call_list; call; call = call->next) {
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 switch (call->sip_state) {
154
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
33 case SIP_STATE_INV_SENT:
108
0d6435808bcd sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents: 81
diff changeset
34 if (call->sip_tx_count < cfg_retrans_count) {
154
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
35 fill_invite_req_msg(&msg, call);
68
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 sip_tx_packet(&msg, &call->udp_sin);
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 call->sip_tx_count++;
78
72b7d85d6354 sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 68
diff changeset
38 } else {
142
bb9a75557f59 sip-in: syslog SIP message retransmission failures
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
39 syslog(LOG_ERR,
154
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
40 "outbound INVITE retrans timeout");
78
72b7d85d6354 sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 68
diff changeset
41 call->overall_state = OVERALL_STATE_TEARDOWN;
72b7d85d6354 sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 68
diff changeset
42 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU,
154
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
43 GSM48_CC_CAUSE_DEST_OOO);
78
72b7d85d6354 sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 68
diff changeset
44 disconnect_tmgw(call);
154
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
45 call->sip_state = SIP_STATE_ACCEPT_100;
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
46 sip_mark_end_time(call, sip_linger_timeout);
78
72b7d85d6354 sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents: 68
diff changeset
47 }
68
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 break;
154
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
49 case SIP_STATE_CANCEL_SENT:
68
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 if (call->sip_tx_count < cfg_retrans_count) {
154
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
51 fill_cancel_req_msg(&msg, call);
68
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 sip_tx_packet(&msg, &call->udp_sin);
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 call->sip_tx_count++;
109
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents: 108
diff changeset
54 } else {
142
bb9a75557f59 sip-in: syslog SIP message retransmission failures
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
55 syslog(LOG_ERR,
154
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
56 "outbound CANCEL retrans timeout");
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
57 call->sip_state = SIP_STATE_ACCEPT_200;
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
58 sip_mark_end_time(call, sip_linger_timeout);
109
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents: 108
diff changeset
59 }
68
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 break;
81
915f0f397fb6 sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 78
diff changeset
61 case SIP_STATE_BYE_SENT:
915f0f397fb6 sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 78
diff changeset
62 if (call->sip_tx_count < cfg_retrans_count) {
154
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
63 fill_bye_req_msg(&msg, call);
81
915f0f397fb6 sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 78
diff changeset
64 sip_tx_packet(&msg, &call->udp_sin);
915f0f397fb6 sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 78
diff changeset
65 call->sip_tx_count++;
109
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents: 108
diff changeset
66 } else {
154
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
67 syslog(LOG_ERR, "outbound BYE retrans timeout");
81
915f0f397fb6 sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 78
diff changeset
68 call->sip_state = SIP_STATE_ENDED;
154
e54b0a9e322f beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents: 143
diff changeset
69 sip_mark_end_time(call, sip_linger_bye_out_err);
109
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents: 108
diff changeset
70 }
81
915f0f397fb6 sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 78
diff changeset
71 break;
68
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 }
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 }
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 }