FreeCalypso > hg > themwi-system-sw
annotate libsip/req_supp.c @ 188:6aecee01cf0a
sip-manual-out: add RTP stream continuity analysis
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 17 Mar 2023 01:14:57 -0800 |
parents | dec31b1a8b96 |
children |
rev | line source |
---|---|
49
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Here we parse Require and Supported headers in a SIP request, |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * checking whether our supported extensions are also supported |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * or required by the client, and catching any client requirements |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * which we don't support. |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 */ |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <ctype.h> |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <string.h> |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <strings.h> |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "parse.h" |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "req_supp.h" |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 parse_require_supported(msg, lsupp, nlsupp, unsupp) |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 struct sip_pkt_rx *msg; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 struct supported_ext *lsupp; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 unsigned nlsupp; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 char **unsupp; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 { |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 struct sip_parse_hdr *hdr, *endhdr; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 char *cp, *np; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 unsigned n; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 endhdr = msg->hdr_fields + msg->num_hdr_fields; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 /* check Require first */ |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 for (hdr = msg->hdr_fields; hdr < endhdr; hdr++) { |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 if (strcasecmp(hdr->field_name, "Require")) |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 continue; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 cp = hdr->field_value; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 for (;;) { |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 while (isspace(*cp) || *cp == ',') |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 cp++; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 if (!*cp) |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 break; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 np = cp; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 while (*cp && !isspace(*cp) && *cp != ',') |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 cp++; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 if (*cp) |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 *cp++ = '\0'; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 for (n = 0; n < nlsupp; n++) { |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 if (!strcasecmp(np, lsupp[n].name)) { |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 *lsupp[n].req_flag = 1; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 break; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 } else { |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 if (unsupp) |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 *unsupp = np; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 return(-1); |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 } |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 } |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 } |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 } |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 /* now check Supported */ |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 for (hdr = msg->hdr_fields; hdr < endhdr; hdr++) { |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 if (strcasecmp(hdr->field_name, "Supported") && |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 strcasecmp(hdr->field_name, "k")) |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 continue; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 cp = hdr->field_value; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 for (;;) { |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 while (isspace(*cp) || *cp == ',') |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 cp++; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 if (!*cp) |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 break; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 np = cp; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 while (*cp && !isspace(*cp) && *cp != ',') |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 cp++; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 if (*cp) |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 *cp++ = '\0'; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 for (n = 0; n < nlsupp; n++) { |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 if (!strcasecmp(np, lsupp[n].name)) { |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 *lsupp[n].sup_flag = 1; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 break; |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 } |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 } |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 } |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 } |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 return(0); |
dec31b1a8b96
sip-in: check Require and Supported
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 } |