diff sip-in/sip_ack.c @ 69:8cf85edca543

sip-in: implement SIP ACK handling
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 19 Sep 2022 14:55:57 -0800
parents
children 3e3fbf44f9d7
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sip-in/sip_ack.c	Mon Sep 19 14:55:57 2022 -0800
@@ -0,0 +1,43 @@
+/*
+ * 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 <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();
+
+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:
+		call->sip_state = SIP_STATE_CONNECTED;
+		break;
+	case SIP_STATE_INVITE_ERR:
+		call->sip_state = SIP_STATE_ENDED;
+		break;
+	}
+}