FreeCalypso > hg > themwi-system-sw
annotate sip-in/retrans.c @ 83:3e3fbf44f9d7
sip-in: disconnect and call clearing implemented
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Tue, 20 Sep 2022 22:06:37 -0800 |
| parents | 915f0f397fb6 |
| children | 0d6435808bcd |
| 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> |
|
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" |
|
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "../libsip/out_msg.h" |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "call.h" |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 extern unsigned cfg_retrans_count; |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 extern struct call *call_list; |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 void |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 run_periodic_retrans() |
|
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 struct call *call; |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 struct sip_msg_out msg; |
|
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 for (call = call_list; call; call = call->next) { |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 switch (call->sip_state) { |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 case SIP_STATE_INVITE_200: |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 if (call->sip_tx_count < cfg_retrans_count) { |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 fill_invite_200_resp(&msg, call); |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 sip_tx_packet(&msg, &call->udp_sin); |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 call->sip_tx_count++; |
|
78
72b7d85d6354
sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
35 } else { |
|
72b7d85d6354
sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
36 call->overall_state = OVERALL_STATE_TEARDOWN; |
|
72b7d85d6354
sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
37 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU, |
|
72b7d85d6354
sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
38 GSM48_CC_CAUSE_INTERWORKING); |
|
72b7d85d6354
sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
39 disconnect_tmgw(call); |
|
81
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
40 initiate_bye(call); |
|
78
72b7d85d6354
sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
41 } |
|
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 break; |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 case SIP_STATE_INVITE_ERR: |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 if (call->sip_tx_count < cfg_retrans_count) { |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 start_response_out_msg(&msg, call->invite_fail); |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 fill_invite_resp_from_call(&msg, call); |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 out_msg_finish(&msg); |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 sip_tx_packet(&msg, &call->udp_sin); |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 call->sip_tx_count++; |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 } else |
|
78
72b7d85d6354
sip-in: retransmission error handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
51 call->sip_state = SIP_STATE_ENDED; |
|
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 break; |
|
81
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
53 case SIP_STATE_BYE_SENT: |
|
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
54 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
|
55 fill_bye_out_msg(&msg, call); |
|
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
56 sip_tx_packet(&msg, &call->udp_sin); |
|
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
57 call->sip_tx_count++; |
|
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
58 } else |
|
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
59 call->sip_state = SIP_STATE_ENDED; |
|
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
78
diff
changeset
|
60 break; |
|
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 } |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 } |
|
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 } |
