# HG changeset patch # User Mychaela Falconia # Date 1663628157 28800 # Node ID 8cf85edca543f6c2188fac9b24d35519a5145c0a # Parent 709b78a4ebf0bb1f16742e2c12b0d66180f0a954 sip-in: implement SIP ACK handling diff -r 709b78a4ebf0 -r 8cf85edca543 sip-in/Makefile --- a/sip-in/Makefile Sun Sep 18 21:56:20 2022 -0800 +++ b/sip-in/Makefile Mon Sep 19 14:55:57 2022 -0800 @@ -2,8 +2,8 @@ CFLAGS= -O2 PROG= themwi-sip-in OBJS= call_list.o call_setup.o disconnect.o invite.o main.o mgw_ops.o \ - mgw_sock.o mncc_handle.o mncc_sock.o readconf.o retrans.o sip_log.o \ - sip_uas.o sip_udp.o + mgw_sock.o mncc_handle.o mncc_sock.o readconf.o retrans.o sip_ack.o \ + sip_log.o sip_uas.o sip_udp.o LIBS= ../libnumdb/libnumdb.a ../libsip/libsip.a ../libutil/libutil.a INSTBIN=/usr/local/bin diff -r 709b78a4ebf0 -r 8cf85edca543 sip-in/sip_ack.c --- /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 +#include +#include +#include +#include +#include +#include +#include +#include +#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; + } +} diff -r 709b78a4ebf0 -r 8cf85edca543 sip-in/sip_uas.c --- a/sip-in/sip_uas.c Sun Sep 18 21:56:20 2022 -0800 +++ b/sip-in/sip_uas.c Mon Sep 19 14:55:57 2022 -0800 @@ -64,7 +64,7 @@ if (!strcmp(msg->req_method, "INVITE")) handle_sip_invite(msg, &ess, sin); else if (!strcmp(msg->req_method, "ACK")) - method_tbi(msg, &ess, sin); + handle_sip_ack(msg, &ess, sin); else if (!strcmp(msg->req_method, "CANCEL")) method_tbi(msg, &ess, sin); else if (!strcmp(msg->req_method, "BYE"))