FreeCalypso > hg > themwi-system-sw
changeset 155:2730ccb44549
sip-out: initial UAC response handling
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 11 Oct 2022 23:30:00 -0800 |
parents | e54b0a9e322f |
children | 0bacca1f2f7b |
files | sip-out/Makefile sip-out/uac_resp.c |
diffstat | 2 files changed, 58 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- /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 <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 "../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); +}