view sip-in/sip_ack.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

/*
 * Here we implement our handling of SIP ACK, the last step
 * in the 3-way INVITE handshake.
 */

#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 "../libsip/parse.h"
#include "../libsip/uas_basic.h"
#include "call.h"

extern struct call *find_call_by_sip_id();

extern unsigned sip_linger_acked;

void
handle_sip_ack(req, ess, sin)
	struct sip_pkt_rx *req;
	struct uas_parse_hdrs *ess;
	struct sockaddr_in *sin;
{
	struct call *call;

	call = find_call_by_sip_id(ess->call_id);
	if (!call)
		return;		/* ignore spurious ACK */
	/* weed out wrong CSeq */
	if (ess->cseq_num != call->invite_cseq)
		return;
	switch (call->sip_state) {
	case SIP_STATE_INVITE_200:
		switch (call->overall_state) {
		case OVERALL_STATE_ANSWERED:
			call->sip_state = SIP_STATE_CONNECTED;
			send_mncc_connect_ack(call);
			break;
		case OVERALL_STATE_TEARDOWN:
			initiate_bye(call);
			break;
		default:
			syslog(LOG_CRIT,
			"FATAL: invalid overall state 0x%x on SIP ACK",
				call->overall_state);
			exit(1);
		}
		break;
	case SIP_STATE_INVITE_ERR:
		call->sip_state = SIP_STATE_ENDED;
		sip_mark_end_time(call, sip_linger_acked);
		transition_dead_sip(call);
		break;
	}
}