comparison 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
comparison
equal deleted inserted replaced
104:ce3b1db7d1d7 105:9213ec8b434b
1 /*
2 * In this module we handle the scenarios of themwi-mncc and/or themwi-mgw
3 * shutting down while we are connected to them. In both scenarios we
4 * terminate all active calls (graceful disconnect signaling toward SIP
5 * callers and toward whichever ThemWi daemon is still running, if either),
6 * but our themwi-sip-in process itself stays running. This way once
7 * the other required processes restart, inbound calls will start working
8 * once again, without needing to restart themwi-sip-in.
9 */
10
11 #include <sys/types.h>
12 #include <sys/socket.h>
13 #include <netinet/in.h>
14 #include <stdio.h>
15 #include <stdint.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <strings.h>
19 #include <syslog.h>
20 #include "../include/mncc.h"
21 #include "../include/gsm48_const.h"
22 #include "call.h"
23
24 extern struct call *call_list;
25
26 static struct gsm_mncc_cause shutdown_cause = {
27 .coding = GSM48_CAUSE_CODING_GSM,
28 .location = GSM48_CAUSE_LOC_PRN_S_LU,
29 .value = GSM48_CC_CAUSE_NETWORK_OOO,
30 };
31
32 void
33 shutdown_gsm_conn()
34 {
35 struct call *call;
36
37 for (call = call_list; call; call = call->next) {
38 call->mncc_state = MNCC_STATE_NO_EXIST;
39 if (call->overall_state != OVERALL_STATE_DEAD_SIP) {
40 call->overall_state = OVERALL_STATE_TEARDOWN;
41 disconnect_tmgw(call);
42 disconnect_sip(call, &shutdown_cause);
43 }
44 }
45 }
46
47 void
48 shutdown_mgw_conn()
49 {
50 struct call *call;
51
52 for (call = call_list; call; call = call->next) {
53 call->mgw_state = MGW_STATE_NO_EXIST;
54 call->mgw_xact = 0;
55 if (call->overall_state != OVERALL_STATE_DEAD_SIP) {
56 call->overall_state = OVERALL_STATE_TEARDOWN;
57 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU,
58 GSM48_CC_CAUSE_NETWORK_OOO);
59 disconnect_sip(call, &shutdown_cause);
60 }
61 }
62 }