FreeCalypso > hg > themwi-system-sw
annotate sip-in/retrans.c @ 69:8cf85edca543
sip-in: implement SIP ACK handling
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 19 Sep 2022 14:55:57 -0800 |
parents | 709b78a4ebf0 |
children | 72b7d85d6354 |
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> |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include "../libsip/out_msg.h" |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "call.h" |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 extern unsigned cfg_retrans_count; |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 extern struct call *call_list; |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 void |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 run_periodic_retrans() |
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 struct call *call; |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 struct sip_msg_out msg; |
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 for (call = call_list; call; call = call->next) { |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 switch (call->sip_state) { |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 case SIP_STATE_INVITE_200: |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 if (call->sip_tx_count < cfg_retrans_count) { |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 fill_invite_200_resp(&msg, call); |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 sip_tx_packet(&msg, &call->udp_sin); |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 call->sip_tx_count++; |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } else |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 /* error handling to be implemented */; |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 break; |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 case SIP_STATE_INVITE_ERR: |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 if (call->sip_tx_count < cfg_retrans_count) { |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 start_response_out_msg(&msg, call->invite_fail); |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 fill_invite_resp_from_call(&msg, call); |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 out_msg_finish(&msg); |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 sip_tx_packet(&msg, &call->udp_sin); |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 call->sip_tx_count++; |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 } else |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 /* error handling to be implemented */; |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 break; |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 } |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 } |