annotate sip-in/call_clear.c @ 219:9ba474e918c0

smpp-test1: try sending some ID strings
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 01 Aug 2023 22:56:52 -0800
parents 3a1f0e13a3ac
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement final clearing of calls, i.e., freeing
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * of struct call, and all preliminary steps that need to happen
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * toward this ultimate end state.
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/types.h>
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <sys/socket.h>
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <sys/time.h>
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <netinet/in.h>
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <stdio.h>
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <stdint.h>
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <stdlib.h>
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include <string.h>
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include <strings.h>
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #include <syslog.h>
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 #include "call.h"
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 extern struct call *call_list;
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 extern struct timeval cur_event_time;
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 void
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 sip_mark_end_time(call, linger)
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 struct call *call;
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 unsigned linger;
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 {
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 call->sip_clear_time = cur_event_time.tv_sec + linger;
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 }
110
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
29
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
30 void
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
31 transition_dead_sip(call)
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
32 struct call *call;
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
33 {
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
34 if (call->overall_state != OVERALL_STATE_TEARDOWN)
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
35 return;
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
36 if (call->sip_state != SIP_STATE_ENDED &&
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
37 call->sip_state != SIP_STATE_MSG_SIZE_ERR)
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
38 return;
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
39 if (call->mncc_state != MNCC_STATE_NO_EXIST)
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
40 return;
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
41 if (call->mgw_state != MGW_STATE_NO_EXIST)
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
42 return;
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
43 if (call->mgw_xact)
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
44 return;
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
45 call->overall_state = OVERALL_STATE_DEAD_SIP;
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
46 }
111
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
47
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
48 void
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
49 clear_dead_sip_calls()
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
50 {
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
51 struct call *call, **pp;
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
52
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
53 for (pp = &call_list; *pp; ) {
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
54 call = *pp;
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
55 if (call->overall_state == OVERALL_STATE_DEAD_SIP &&
116
3a1f0e13a3ac sip-in call clearing: time comparison was reversed
Mychaela Falconia <falcon@freecalypso.org>
parents: 114
diff changeset
56 cur_event_time.tv_sec >= call->sip_clear_time) {
111
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
57 *pp = call->next;
114
a30c25fb4c2f sip-in: generate CDR syslog entries
Mychaela Falconia <falcon@freecalypso.org>
parents: 113
diff changeset
58 syslog(LOG_INFO, "Call in%06u finished",
113
bfc97065bf51 sip-in: syslog beginning and clearing of calls
Mychaela Falconia <falcon@freecalypso.org>
parents: 111
diff changeset
59 call->in_tag_num);
111
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
60 free(call);
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
61 continue;
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
62 }
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
63 pp = &call->next;
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
64 }
7a4d4b8d5f04 sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
65 }