FreeCalypso > hg > themwi-system-sw
annotate sip-out/call_clear.c @ 267:81958b35f74d
NANP validation: allow made-up area codes of N9X form
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 13 Nov 2023 15:28:09 -0800 |
parents | e54b0a9e322f |
children |
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> |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
116
diff
changeset
|
17 #include "../include/out_routes.h" |
109
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include "call.h" |
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 extern struct call *call_list; |
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 extern struct timeval cur_event_time; |
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 void |
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 sip_mark_end_time(call, linger) |
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 struct call *call; |
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 unsigned linger; |
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 { |
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 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
|
29 } |
110
c1c94b7fc2e2
sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
30 |
c1c94b7fc2e2
sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
31 void |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
116
diff
changeset
|
32 check_dead_call(call) |
110
c1c94b7fc2e2
sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
33 struct call *call; |
c1c94b7fc2e2
sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
34 { |
c1c94b7fc2e2
sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
35 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
|
36 return; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
116
diff
changeset
|
37 if (call->mncc) |
110
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->mgw_state != MGW_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_xact) |
c1c94b7fc2e2
sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
42 return; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
116
diff
changeset
|
43 if (call->sip_call_exists) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
116
diff
changeset
|
44 call->overall_state = OVERALL_STATE_SIP_FINISH; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
116
diff
changeset
|
45 else |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
116
diff
changeset
|
46 call->overall_state = OVERALL_STATE_GC; |
110
c1c94b7fc2e2
sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
47 } |
111
7a4d4b8d5f04
sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
48 |
7a4d4b8d5f04
sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
49 void |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
116
diff
changeset
|
50 clear_dead_calls() |
111
7a4d4b8d5f04
sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
51 { |
7a4d4b8d5f04
sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
52 struct call *call, **pp; |
7a4d4b8d5f04
sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
53 |
7a4d4b8d5f04
sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
54 for (pp = &call_list; *pp; ) { |
7a4d4b8d5f04
sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
55 call = *pp; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
116
diff
changeset
|
56 if (call->overall_state == OVERALL_STATE_GC || |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
116
diff
changeset
|
57 call->overall_state == OVERALL_STATE_SIP_FINISH && |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
116
diff
changeset
|
58 call->sip_state >= SIP_STATE_ACCEPT_100 && |
116
3a1f0e13a3ac
sip-in call clearing: time comparison was reversed
Mychaela Falconia <falcon@freecalypso.org>
parents:
114
diff
changeset
|
59 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
|
60 *pp = call->next; |
7a4d4b8d5f04
sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
61 free(call); |
7a4d4b8d5f04
sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
62 continue; |
7a4d4b8d5f04
sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
63 } |
7a4d4b8d5f04
sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
64 pp = &call->next; |
7a4d4b8d5f04
sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
65 } |
7a4d4b8d5f04
sip-in call clearing: unlink and free implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
66 } |