FreeCalypso > hg > themwi-system-sw
annotate sip-out/call_list.c @ 224:62184b971c8e
smpp-send/input.c: copy-n-paste error
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 05 Aug 2023 12:27:36 -0800 |
parents | bfa9f0c0f0ac |
children |
rev | line source |
---|---|
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
2 * In this module we implement call list management for themwi-sip-out. |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
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> |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <netinet/in.h> |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdio.h> |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdint.h> |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdlib.h> |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <string.h> |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <strings.h> |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <syslog.h> |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
15 #include "../include/out_routes.h" |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "call.h" |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 struct call *call_list; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 struct call * |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 find_call_by_sip_id(sought_id) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 char *sought_id; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 { |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 struct call *call; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
26 for (call = call_list; call; call = call->next) { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
27 if (!call->sip_call_exists) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
28 continue; |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (!strcmp(call->sip_call_id, sought_id)) |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 return call; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
31 } |
60
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 return 0; |
02761f1ae5e5
sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 } |
62
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
34 |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
35 struct call * |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
36 find_call_by_mncc_callref(mncc, callref) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
37 struct mncc_conn *mncc; |
62
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
38 uint32_t callref; |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
39 { |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
40 struct call *call; |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
41 |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
42 for (call = call_list; call; call = call->next) |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
43 if (call->mncc == mncc && call->mncc_callref == callref) |
62
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
44 return call; |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
45 return 0; |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
46 } |
75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
60
diff
changeset
|
47 |
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
63
diff
changeset
|
48 void |
112
6aa63cf4620a
sip-in call clearing: select timeout implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
49 scan_call_list_for_timeouts(retrans, dead_sip_flag, dead_sip_time) |
6aa63cf4620a
sip-in call clearing: select timeout implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
50 int *retrans, *dead_sip_flag; |
6aa63cf4620a
sip-in call clearing: select timeout implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
51 time_t *dead_sip_time; |
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
63
diff
changeset
|
52 { |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
63
diff
changeset
|
53 struct call *call; |
112
6aa63cf4620a
sip-in call clearing: select timeout implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
54 int got_dead_sip = 0; |
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
63
diff
changeset
|
55 |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
63
diff
changeset
|
56 for (call = call_list; call; call = call->next) { |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
57 if (!call->sip_call_exists) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
58 continue; |
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
63
diff
changeset
|
59 switch (call->sip_state) { |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
60 case SIP_STATE_INV_SENT: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
61 case SIP_STATE_CANCEL_SENT: |
81
915f0f397fb6
sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
62 case SIP_STATE_BYE_SENT: |
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
63
diff
changeset
|
63 *retrans = 1; |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
63
diff
changeset
|
64 break; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
65 case SIP_STATE_ACCEPT_100: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
66 case SIP_STATE_ACCEPT_200: |
112
6aa63cf4620a
sip-in call clearing: select timeout implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
67 case SIP_STATE_ENDED: |
163
bfa9f0c0f0ac
sip-out: handle incoming BYE as UAS
Mychaela Falconia <falcon@freecalypso.org>
parents:
154
diff
changeset
|
68 case SIP_STATE_MSG_SIZE_ERR: |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
69 if (call->overall_state != OVERALL_STATE_SIP_FINISH) |
112
6aa63cf4620a
sip-in call clearing: select timeout implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
70 continue; |
6aa63cf4620a
sip-in call clearing: select timeout implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
71 if (got_dead_sip) { |
6aa63cf4620a
sip-in call clearing: select timeout implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
72 if (call->sip_clear_time < *dead_sip_time) |
6aa63cf4620a
sip-in call clearing: select timeout implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
73 *dead_sip_time = call->sip_clear_time; |
6aa63cf4620a
sip-in call clearing: select timeout implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
74 } else { |
6aa63cf4620a
sip-in call clearing: select timeout implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
75 got_dead_sip = 1; |
6aa63cf4620a
sip-in call clearing: select timeout implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
76 *dead_sip_flag = 1; |
6aa63cf4620a
sip-in call clearing: select timeout implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
77 *dead_sip_time = call->sip_clear_time; |
6aa63cf4620a
sip-in call clearing: select timeout implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
78 } |
68
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
63
diff
changeset
|
79 } |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
63
diff
changeset
|
80 } |
709b78a4ebf0
sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents:
63
diff
changeset
|
81 } |