diff libsip/resp_ident.c @ 0:35c0d9f03c0a

beginning with sipout-test-voice, a copy of sip-manual-out from themwi-system-sw
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 03 Mar 2024 23:20:19 -0800
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libsip/resp_ident.c	Sun Mar 03 23:20:19 2024 -0800
@@ -0,0 +1,52 @@
+/*
+ * In this module we implement an essential step in the process
+ * of handling incoming SIP response messages: extracting Call-ID
+ * and CSeq headers and preparsing the latter, providing key info
+ * for matching these incoming responses with call state and
+ * with outstanding UAC requests.
+ */
+
+#include <ctype.h>
+#include <string.h>
+#include <strings.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "parse.h"
+#include "resp_ident.h"
+
+extern char *get_single_header();
+
+sip_resp_extract_ident(msg, id)
+	struct sip_pkt_rx *msg;
+	struct sip_resp_ident *id;
+{
+	char *hval, *cp;
+	int dup_flag = 0;
+
+	hval = get_single_header(msg, "Call-ID", "i", &dup_flag);
+	if (!hval || dup_flag) {
+		id->error_field = "Call-ID";
+		return(-1);
+	}
+	id->call_id = hval;
+	hval = get_single_header(msg, "CSeq", (char *) 0, &dup_flag);
+	if (!hval || dup_flag) {
+bad_cseq:	id->error_field = "CSeq";
+		return(-1);
+	}
+	if (!isdigit(*hval))
+		goto bad_cseq;
+	id->cseq_num = strtoul(hval, &cp, 10);
+	if (!isspace(*cp))
+		goto bad_cseq;
+	while (isspace(*cp))
+		cp++;
+	if (!isupper(*cp))
+		goto bad_cseq;
+	id->cseq_method = cp;
+	while (isalnum(*cp))
+		cp++;
+	if (*cp)
+		goto bad_cseq;
+	return(0);
+}