annotate sip-in/shutdown.c @ 275:def9f6e4f49e default tip

doc/Use-outside-USA: Fake-NANP-numbers article is here
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 27 Nov 2023 21:49:19 -0800
parents c1c94b7fc2e2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>
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"
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 #include "call.h"
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 extern struct call *call_list;
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 static struct gsm_mncc_cause shutdown_cause = {
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 .coding = GSM48_CAUSE_CODING_GSM,
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 .location = GSM48_CAUSE_LOC_PRN_S_LU,
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 .value = GSM48_CC_CAUSE_NETWORK_OOO,
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
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 void
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 shutdown_gsm_conn()
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 {
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 struct call *call;
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 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
39 call->mncc_state = MNCC_STATE_NO_EXIST;
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 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
41 call->overall_state = OVERALL_STATE_TEARDOWN;
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 disconnect_tmgw(call);
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 disconnect_sip(call, &shutdown_cause);
110
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
44 transition_dead_sip(call);
105
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 }
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 void
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 shutdown_mgw_conn()
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 struct call *call;
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 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
55 call->mgw_state = MGW_STATE_NO_EXIST;
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 call->mgw_xact = 0;
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 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
58 call->overall_state = OVERALL_STATE_TEARDOWN;
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 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
60 GSM48_CC_CAUSE_NETWORK_OOO);
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 disconnect_sip(call, &shutdown_cause);
110
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
62 transition_dead_sip(call);
105
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 }
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 }
9213ec8b434b sip-in: handle themwi-mncc shutdown without terminating
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 }