# HG changeset patch # User Mychaela Falconia # Date 1665559800 28800 # Node ID 2730ccb445490e40e1add9eee1fb12133d40ba45 # Parent e54b0a9e322f39234c4b593371c9d6b8eae6b050 sip-out: initial UAC response handling diff -r e54b0a9e322f -r 2730ccb44549 sip-out/Makefile --- a/sip-out/Makefile Tue Oct 11 23:04:01 2022 -0800 +++ b/sip-out/Makefile Tue Oct 11 23:30:00 2022 -0800 @@ -3,7 +3,8 @@ PROG= themwi-sip-out OBJS= call_clear.o call_list.o call_setup.o disconnect.o main.o mgw_ops.o \ mgw_resp.o mgw_sock.o mncc_sig_in.o mncc_sig_out.o mncc_sock.o \ - readconf.o retrans.o shutdown.o sip_log.o sip_uas.o sip_udp.o uac_out.o + readconf.o retrans.o shutdown.o sip_log.o sip_uas.o sip_udp.o uac_out.o\ + uac_resp.o LIBS= ../liboutrt/liboutrt.a ../libsip/libsip.a ../libutil/libutil.a INSTBIN=/usr/local/bin diff -r e54b0a9e322f -r 2730ccb44549 sip-out/uac_resp.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sip-out/uac_resp.c Tue Oct 11 23:30:00 2022 -0800 @@ -0,0 +1,56 @@ +/* + * In this module we implement our handling of SIP responses in the UAC role. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../include/gsm48_const.h" +#include "../include/out_routes.h" +#include "../libsip/parse.h" +#include "../libsip/resp_ident.h" +#include "../libsip/sdp.h" +#include "../libsip/out_msg.h" +#include "call.h" + +extern struct call *find_call_by_sip_id(); + +void +process_sip_response(msg, sin) + struct sip_pkt_rx *msg; + struct sockaddr_in *sin; +{ + struct sip_resp_ident rid; + struct call *call; + int rc; + + rc = sip_resp_extract_ident(msg, &rid); + if (rc < 0) { + syslog(LOG_ERR, "SIP %03u response: bad or missing %s header", + msg->status_code, rid.error_field); + return; + } + call = find_call_by_sip_id(rid.call_id); + if (!call) { + syslog(LOG_ERR, "SIP %03u response: unmatched Call-ID", + msg->status_code); + return; + } + if (rid.cseq_num == 1 && !strcmp(rid.cseq_method, "INVITE")) + handle_invite_response(call, msg, sin); + else if (rid.cseq_num == 1 && !strcmp(rid.cseq_method, "CANCEL")) + handle_cancel_response(call, msg, sin); + else if (rid.cseq_num == 2 && !strcmp(rid.cseq_method, "BYE")) + handle_bye_response(call, msg, sin); + else + syslog(LOG_ERR, + "UAC received %03u response with unknown CSeq %u %.32s", + msg->status_code, rid.cseq_num, rid.cseq_method); +}