view sip-in/shutdown.c @ 124:7e04d28fae8b

sip-in: default use-100rel to no BulkVS servers act badly when we send a reliable 180 Ringing response to an incoming call, even though they advertise 100rel support in the Supported header in the INVITE packet, and we probably won't be implementing 100rel for outbound because doing per-the-spec PRACK as a UAC is just too burdensome. Therefore, we need to consider 100rel extension as not-really-supported in themwi-system-sw.
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 01 Oct 2022 15:54:50 -0800
parents c1c94b7fc2e2
children
line wrap: on
line source

/*
 * In this module we handle the scenarios of themwi-mncc and/or themwi-mgw
 * shutting down while we are connected to them.  In both scenarios we
 * terminate all active calls (graceful disconnect signaling toward SIP
 * callers and toward whichever ThemWi daemon is still running, if either),
 * but our themwi-sip-in process itself stays running.  This way once
 * the other required processes restart, inbound calls will start working
 * once again, without needing to restart themwi-sip-in.
 */

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <syslog.h>
#include "../include/mncc.h"
#include "../include/gsm48_const.h"
#include "call.h"

extern struct call *call_list;

static struct gsm_mncc_cause shutdown_cause = {
	.coding		= GSM48_CAUSE_CODING_GSM,
	.location	= GSM48_CAUSE_LOC_PRN_S_LU,
	.value		= GSM48_CC_CAUSE_NETWORK_OOO,
};

void
shutdown_gsm_conn()
{
	struct call *call;

	for (call = call_list; call; call = call->next) {
		call->mncc_state = MNCC_STATE_NO_EXIST;
		if (call->overall_state != OVERALL_STATE_DEAD_SIP) {
			call->overall_state = OVERALL_STATE_TEARDOWN;
			disconnect_tmgw(call);
			disconnect_sip(call, &shutdown_cause);
			transition_dead_sip(call);
		}
	}
}

void
shutdown_mgw_conn()
{
	struct call *call;

	for (call = call_list; call; call = call->next) {
		call->mgw_state = MGW_STATE_NO_EXIST;
		call->mgw_xact = 0;
		if (call->overall_state != OVERALL_STATE_DEAD_SIP) {
			call->overall_state = OVERALL_STATE_TEARDOWN;
			disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU,
					GSM48_CC_CAUSE_NETWORK_OOO);
			disconnect_sip(call, &shutdown_cause);
			transition_dead_sip(call);
		}
	}
}