comparison sip-out/call_list.c @ 154:e54b0a9e322f

beginning of themwi-sip-out
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 11 Oct 2022 23:04:01 -0800
parents sip-in/call_list.c@6aa63cf4620a
children bfa9f0c0f0ac
comparison
equal deleted inserted replaced
153:99fd4ae573ae 154:e54b0a9e322f
1 /*
2 * In this module we implement call list management for themwi-sip-out.
3 */
4
5 #include <sys/types.h>
6 #include <sys/socket.h>
7 #include <sys/time.h>
8 #include <netinet/in.h>
9 #include <stdio.h>
10 #include <stdint.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <strings.h>
14 #include <syslog.h>
15 #include "../include/out_routes.h"
16 #include "call.h"
17
18 struct call *call_list;
19
20 struct call *
21 find_call_by_sip_id(sought_id)
22 char *sought_id;
23 {
24 struct call *call;
25
26 for (call = call_list; call; call = call->next) {
27 if (!call->sip_call_exists)
28 continue;
29 if (!strcmp(call->sip_call_id, sought_id))
30 return call;
31 }
32 return 0;
33 }
34
35 struct call *
36 find_call_by_mncc_callref(mncc, callref)
37 struct mncc_conn *mncc;
38 uint32_t callref;
39 {
40 struct call *call;
41
42 for (call = call_list; call; call = call->next)
43 if (call->mncc == mncc && call->mncc_callref == callref)
44 return call;
45 return 0;
46 }
47
48 void
49 scan_call_list_for_timeouts(retrans, dead_sip_flag, dead_sip_time)
50 int *retrans, *dead_sip_flag;
51 time_t *dead_sip_time;
52 {
53 struct call *call;
54 int got_dead_sip = 0;
55
56 for (call = call_list; call; call = call->next) {
57 if (!call->sip_call_exists)
58 continue;
59 switch (call->sip_state) {
60 case SIP_STATE_INV_SENT:
61 case SIP_STATE_CANCEL_SENT:
62 case SIP_STATE_BYE_SENT:
63 *retrans = 1;
64 break;
65 case SIP_STATE_ACCEPT_100:
66 case SIP_STATE_ACCEPT_200:
67 case SIP_STATE_ENDED:
68 if (call->overall_state != OVERALL_STATE_SIP_FINISH)
69 continue;
70 if (got_dead_sip) {
71 if (call->sip_clear_time < *dead_sip_time)
72 *dead_sip_time = call->sip_clear_time;
73 } else {
74 got_dead_sip = 1;
75 *dead_sip_flag = 1;
76 *dead_sip_time = call->sip_clear_time;
77 }
78 }
79 }
80 }