FreeCalypso > hg > themwi-system-sw
annotate sip-in/shutdown.c @ 105:9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 27 Sep 2022 23:00:52 -0800 |
parents | |
children | 9b87894704eb |
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 |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * terminate all active calls (graceful disconnect signaling toward SIP |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * callers and toward whichever ThemWi daemon is still running, if either), |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * but our themwi-sip-in process itself stays running. This way once |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * the other required processes restart, inbound calls will start working |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 * once again, without needing to restart themwi-sip-in. |
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> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <netinet/in.h> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <stdio.h> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <stdint.h> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include <stdlib.h> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include <string.h> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include <strings.h> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 #include <syslog.h> |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #include "../include/mncc.h" |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "../include/gsm48_const.h" |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include "call.h" |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 extern struct call *call_list; |
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 static struct gsm_mncc_cause shutdown_cause = { |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 .coding = GSM48_CAUSE_CODING_GSM, |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 .location = GSM48_CAUSE_LOC_PRN_S_LU, |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 .value = GSM48_CC_CAUSE_NETWORK_OOO, |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 }; |
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 void |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 shutdown_gsm_conn() |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 { |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 struct call *call; |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 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
|
38 call->mncc_state = MNCC_STATE_NO_EXIST; |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 if (call->overall_state != OVERALL_STATE_DEAD_SIP) { |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 call->overall_state = OVERALL_STATE_TEARDOWN; |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 disconnect_tmgw(call); |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 disconnect_sip(call, &shutdown_cause); |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 } |
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; |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 if (call->overall_state != OVERALL_STATE_DEAD_SIP) { |
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); |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 disconnect_sip(call, &shutdown_cause); |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 } |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 } |
9213ec8b434b
sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 } |