changeset 94:2c22b40408fb

sip-in BYE UAC: use new libsip function for response ident
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 24 Sep 2022 15:14:50 -0800
parents ff5e96162430
children f280328e7e2e
files sip-in/bye_out.c
diffstat 1 files changed, 16 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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 <strings.h>
 #include <syslog.h>
 #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)