view sip-out/shutdown.c @ 199:e6c7ced3c031

mgw: accept zero-length RTP payload as BFI Mainline OsmoBTS now has an option (rtp continuous-streaming) that causes it to emit an RTP packet every 20 ms without gaps, sending a BFI marker in the form of zero-length RTP payload when it has nothing else to send. These codec-independent BFI markers don't indicate TAF, but this provision is a good start. Accept this BFI packet format in themwi-mgw.
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 29 Mar 2023 20:23:43 -0800
parents baaa6c1a3d3b
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 (in the case of MNCC socket closing, only
 * those calls that came on that socket), but our themwi-sip-out process
 * itself stays running.  This way once the other required processes restart,
 * outbound calls will start working once again, without needing to restart
 * themwi-sip-out.
 */

#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 "../include/out_routes.h"
#include "call.h"

extern struct call *call_list;

void
shutdown_mncc_socket(mncc)
	struct mncc_conn *mncc;
{
	struct call *call;

	for (call = call_list; call; call = call->next) {
		if (call->mncc != mncc)
			continue;
		call->mncc = 0;
		if (call->overall_state < OVERALL_STATE_TEARDOWN) {
			call->overall_state = OVERALL_STATE_TEARDOWN;
			disconnect_tmgw(call);
			disconnect_sip(call);
		}
		check_dead_call(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_TEARDOWN) {
			call->overall_state = OVERALL_STATE_TEARDOWN;
			disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU,
					GSM48_CC_CAUSE_NETWORK_OOO);
			disconnect_sip(call);
		}
		check_dead_call(call);
	}
}