comparison libsip/resp_ident.c @ 93:ff5e96162430

libsip: new function for extracting Call-ID and CSeq from responses
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 24 Sep 2022 15:13:53 -0800
parents
children
comparison
equal deleted inserted replaced
92:a9137bdb6047 93:ff5e96162430
1 /*
2 * In this module we implement an essential step in the process
3 * of handling incoming SIP response messages: extracting Call-ID
4 * and CSeq headers and preparsing the latter, providing key info
5 * for matching these incoming responses with call state and
6 * with outstanding UAC requests.
7 */
8
9 #include <ctype.h>
10 #include <string.h>
11 #include <strings.h>
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include "parse.h"
15 #include "resp_ident.h"
16
17 extern char *get_single_header();
18
19 sip_resp_extract_ident(msg, id)
20 struct sip_pkt_rx *msg;
21 struct sip_resp_ident *id;
22 {
23 char *hval, *cp;
24 int dup_flag = 0;
25
26 hval = get_single_header(msg, "Call-ID", "i", &dup_flag);
27 if (!hval || dup_flag) {
28 id->error_field = "Call-ID";
29 return(-1);
30 }
31 id->call_id = hval;
32 hval = get_single_header(msg, "CSeq", (char *) 0, &dup_flag);
33 if (!hval || dup_flag) {
34 bad_cseq: id->error_field = "CSeq";
35 return(-1);
36 }
37 if (!isdigit(*hval))
38 goto bad_cseq;
39 id->cseq_num = strtoul(hval, &cp, 10);
40 if (!isspace(*cp))
41 goto bad_cseq;
42 while (isspace(*cp))
43 cp++;
44 if (!isupper(*cp))
45 goto bad_cseq;
46 id->cseq_method = cp;
47 while (isalnum(*cp))
48 cp++;
49 if (*cp)
50 goto bad_cseq;
51 return(0);
52 }