FreeCalypso > hg > themwi-system-sw
changeset 69:8cf85edca543
sip-in: implement SIP ACK handling
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 19 Sep 2022 14:55:57 -0800 |
parents | 709b78a4ebf0 |
children | 47976db01894 |
files | sip-in/Makefile sip-in/sip_ack.c sip-in/sip_uas.c |
diffstat | 3 files changed, 46 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- /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; + } +}
--- 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"))