view sip-in/call_clear.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 3a1f0e13a3ac
children
line wrap: on
line source

/*
 * In this module we implement final clearing of calls, i.e., freeing
 * of struct call, and all preliminary steps that need to happen
 * toward this ultimate end state.
 */

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

extern struct call *call_list;
extern struct timeval cur_event_time;

void
sip_mark_end_time(call, linger)
	struct call *call;
	unsigned linger;
{
	call->sip_clear_time = cur_event_time.tv_sec + linger;
}

void
transition_dead_sip(call)
	struct call *call;
{
	if (call->overall_state != OVERALL_STATE_TEARDOWN)
		return;
	if (call->sip_state != SIP_STATE_ENDED &&
	    call->sip_state != SIP_STATE_MSG_SIZE_ERR)
		return;
	if (call->mncc_state != MNCC_STATE_NO_EXIST)
		return;
	if (call->mgw_state != MGW_STATE_NO_EXIST)
		return;
	if (call->mgw_xact)
		return;
	call->overall_state = OVERALL_STATE_DEAD_SIP;
}

void
clear_dead_sip_calls()
{
	struct call *call, **pp;

	for (pp = &call_list; *pp; ) {
		call = *pp;
		if (call->overall_state == OVERALL_STATE_DEAD_SIP &&
		    cur_event_time.tv_sec >= call->sip_clear_time) {
			*pp = call->next;
			syslog(LOG_INFO, "Call in%06u finished",
				call->in_tag_num);
			free(call);
			continue;
		}
		pp = &call->next;
	}
}