view sip-in/disconnect.c @ 82:ff4b76a107a1

sip-in: process responses as UAC for BYE
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 20 Sep 2022 20:33:09 -0800
parents 5beb51de1bae
children 3e3fbf44f9d7
line wrap: on
line source

/*
 * In this module we implement call disconnection and clearing procedures.
 */

#include <sys/types.h>
#include <sys/socket.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 "call.h"

void
disconnect_mncc(call, cause_loc, cause_val)
	struct call *call;
{
	struct gsm_mncc msg;

	switch (call->mncc_state) {
	case MNCC_STATE_NO_EXIST:
	case MNCC_STATE_DISCONNECT:
	case MNCC_STATE_RELEASE:
		return;
	}
	bzero(&msg, sizeof(struct gsm_mncc));
	msg.msg_type = MNCC_DISC_REQ;
	msg.callref = call->mncc_callref;
	mncc_set_cause(&msg, cause_loc, cause_val);
	send_mncc_to_gsm(&msg, sizeof(struct gsm_mncc));
	call->mncc_state = MNCC_STATE_DISCONNECT;
}

void
disconnect_tmgw(call)
	struct call *call;
{
	switch (call->mgw_state) {
	case MGW_STATE_NO_EXIST:
	case MGW_STATE_CONNECTING:
	case MGW_STATE_DELETING:
		return;
	case MGW_STATE_ALLOCATED:
	case MGW_STATE_COMPLETE:
		tmgw_send_dlcx(call);
		return;
	default:
		syslog(LOG_CRIT,
			"FATAL: invalid MGW state 0x%x in disconnect_tmgw()",
			call->mgw_state);
		exit(1);
	}
}