annotate sip-in/call_list.c @ 109:9b87894704eb

sip-in: first step toward final call clearing
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 28 Sep 2022 16:32:13 -0800
parents 0d6435808bcd
children 6aa63cf4620a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement call list management for themwi-sip-in.
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>
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include "call.h"
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 struct call *call_list;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 struct call *
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 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
21 char *sought_id;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 struct call *call;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 for (call = call_list; call; call = call->next)
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 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
27 return call;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 return 0;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 }
62
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
30
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
31 struct call *
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
32 find_call_by_mncc_callref(callref)
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
33 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
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 *call;
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
36
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
37 for (call = call_list; call; call = call->next)
63
e5aee661e3b2 sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 62
diff changeset
38 if (call->mncc_state && 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
39 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
40 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
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
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
43 allocate_mncc_callref(call)
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
44 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
45 {
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
46 static uint32_t next_callref;
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
47
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
48 for (;;) {
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
49 next_callref++;
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
50 if (!find_call_by_mncc_callref(next_callref)) {
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
51 call->mncc_callref = next_callref;
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
52 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
53 }
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
54 }
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
55 }
68
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
56
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
57 void
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
58 scan_call_list_for_timeouts(retrans)
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
59 int *retrans;
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
60 {
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
61 struct call *call;
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
62
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
63 for (call = call_list; call; call = call->next) {
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
64 switch (call->sip_state) {
108
0d6435808bcd sip-in: implement 100rel for 180 Ringing response
Mychaela Falconia <falcon@freecalypso.org>
parents: 81
diff changeset
65 case SIP_STATE_RINGING_REL:
68
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
66 case SIP_STATE_INVITE_200:
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
67 case SIP_STATE_INVITE_ERR:
81
915f0f397fb6 sip-in: beginning of outgoing BYE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 68
diff changeset
68 case SIP_STATE_BYE_SENT:
68
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
69 *retrans = 1;
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
70 break;
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
71 }
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
72 }
709b78a4ebf0 sip-in: implement retransmission of INVITE responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 63
diff changeset
73 }