FreeCalypso > hg > themwi-system-sw
annotate sip-out/shutdown.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 | baaa6c1a3d3b |
children |
rev | line source |
---|---|
105
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we handle the scenarios of themwi-mncc and/or themwi-mgw |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * shutting down while we are connected to them. In both scenarios we |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
4 * terminate all active calls (in the case of MNCC socket closing, only |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
5 * those calls that came on that socket), but our themwi-sip-out process |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
6 * itself stays running. This way once the other required processes restart, |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
7 * outbound calls will start working once again, without needing to restart |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
8 * themwi-sip-out. |
105
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 */ |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <sys/types.h> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <sys/socket.h> |
109
9b87894704eb
sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
105
diff
changeset
|
13 #include <sys/time.h> |
105
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <netinet/in.h> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <stdio.h> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include <stdint.h> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include <stdlib.h> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include <string.h> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 #include <strings.h> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #include <syslog.h> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "../include/mncc.h" |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include "../include/gsm48_const.h" |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
23 #include "../include/out_routes.h" |
105
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #include "call.h" |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 extern struct call *call_list; |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 void |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
29 shutdown_mncc_socket(mncc) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
30 struct mncc_conn *mncc; |
105
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 { |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 struct call *call; |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 for (call = call_list; call; call = call->next) { |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
35 if (call->mncc != mncc) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
36 continue; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
37 call->mncc = 0; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
38 if (call->overall_state < OVERALL_STATE_TEARDOWN) { |
105
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 call->overall_state = OVERALL_STATE_TEARDOWN; |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 disconnect_tmgw(call); |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
41 disconnect_sip(call); |
105
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 } |
164
baaa6c1a3d3b
sip-out shutdown handling: always do check_dead_call()
Mychaela Falconia <falcon@freecalypso.org>
parents:
154
diff
changeset
|
43 check_dead_call(call); |
105
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 } |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 } |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 void |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 shutdown_mgw_conn() |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 { |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 struct call *call; |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 for (call = call_list; call; call = call->next) { |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 call->mgw_state = MGW_STATE_NO_EXIST; |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 call->mgw_xact = 0; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
55 if (call->overall_state < OVERALL_STATE_TEARDOWN) { |
105
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 call->overall_state = OVERALL_STATE_TEARDOWN; |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU, |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 GSM48_CC_CAUSE_NETWORK_OOO); |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
59 disconnect_sip(call); |
105
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 } |
164
baaa6c1a3d3b
sip-out shutdown handling: always do check_dead_call()
Mychaela Falconia <falcon@freecalypso.org>
parents:
154
diff
changeset
|
61 check_dead_call(call); |
105
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 } |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 } |