# HG changeset patch # User Mychaela Falconia # Date 1664061290 28800 # Node ID 2c22b40408fbec3f07c43132771cdc1d6d8bcf2b # Parent ff5e96162430f59f8f2ae1265e218beb536cbcfc sip-in BYE UAC: use new libsip function for response ident diff -r ff5e96162430 -r 2c22b40408fb sip-in/bye_out.c --- a/sip-in/bye_out.c Sat Sep 24 15:13:53 2022 -0800 +++ b/sip-in/bye_out.c Sat Sep 24 15:14:50 2022 -0800 @@ -13,10 +13,10 @@ #include #include #include "../libsip/parse.h" +#include "../libsip/resp_ident.h" #include "../libsip/out_msg.h" #include "call.h" -extern char *get_single_header(); extern struct call *find_call_by_sip_id(); extern struct in_addr sip_bind_ip; @@ -83,22 +83,26 @@ struct sip_pkt_rx *msg; struct sockaddr_in *sin; { - char *call_id_hdr, *cseq_hdr; + struct sip_resp_ident rid; struct call *call; + int rc; - call_id_hdr = get_single_header(msg, "Call-ID", "i", (int *) 0); - if (!call_id_hdr) + 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(call_id_hdr); - if (!call) + } + call = find_call_by_sip_id(rid.call_id); + if (!call) { + syslog(LOG_ERR, "SIP %03u response: unmatched Call-ID", + msg->status_code); return; - cseq_hdr = get_single_header(msg, "CSeq", (char *) 0, (int *) 0); - if (!cseq_hdr) - return; - if (strcmp(cseq_hdr, "1 BYE")) { + } + if (rid.cseq_num != 1 || strcmp(rid.cseq_method, "BYE")) { syslog(LOG_ERR, - "UAC received response with unknown CSeq %.32s", - cseq_hdr); + "UAC received %03u response with unknown CSeq %u %.32s", + msg->status_code, rid.cseq_num, rid.cseq_method); return; } if (msg->status_code < 200)