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