FreeCalypso > hg > sipout-test-utils
comparison libsip/req_supp.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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:35c0d9f03c0a |
---|---|
1 /* | |
2 * Here we parse Require and Supported headers in a SIP request, | |
3 * checking whether our supported extensions are also supported | |
4 * or required by the client, and catching any client requirements | |
5 * which we don't support. | |
6 */ | |
7 | |
8 #include <ctype.h> | |
9 #include <string.h> | |
10 #include <strings.h> | |
11 #include "parse.h" | |
12 #include "req_supp.h" | |
13 | |
14 parse_require_supported(msg, lsupp, nlsupp, unsupp) | |
15 struct sip_pkt_rx *msg; | |
16 struct supported_ext *lsupp; | |
17 unsigned nlsupp; | |
18 char **unsupp; | |
19 { | |
20 struct sip_parse_hdr *hdr, *endhdr; | |
21 char *cp, *np; | |
22 unsigned n; | |
23 | |
24 endhdr = msg->hdr_fields + msg->num_hdr_fields; | |
25 /* check Require first */ | |
26 for (hdr = msg->hdr_fields; hdr < endhdr; hdr++) { | |
27 if (strcasecmp(hdr->field_name, "Require")) | |
28 continue; | |
29 cp = hdr->field_value; | |
30 for (;;) { | |
31 while (isspace(*cp) || *cp == ',') | |
32 cp++; | |
33 if (!*cp) | |
34 break; | |
35 np = cp; | |
36 while (*cp && !isspace(*cp) && *cp != ',') | |
37 cp++; | |
38 if (*cp) | |
39 *cp++ = '\0'; | |
40 for (n = 0; n < nlsupp; n++) { | |
41 if (!strcasecmp(np, lsupp[n].name)) { | |
42 *lsupp[n].req_flag = 1; | |
43 break; | |
44 } else { | |
45 if (unsupp) | |
46 *unsupp = np; | |
47 return(-1); | |
48 } | |
49 } | |
50 } | |
51 } | |
52 /* now check Supported */ | |
53 for (hdr = msg->hdr_fields; hdr < endhdr; hdr++) { | |
54 if (strcasecmp(hdr->field_name, "Supported") && | |
55 strcasecmp(hdr->field_name, "k")) | |
56 continue; | |
57 cp = hdr->field_value; | |
58 for (;;) { | |
59 while (isspace(*cp) || *cp == ',') | |
60 cp++; | |
61 if (!*cp) | |
62 break; | |
63 np = cp; | |
64 while (*cp && !isspace(*cp) && *cp != ',') | |
65 cp++; | |
66 if (*cp) | |
67 *cp++ = '\0'; | |
68 for (n = 0; n < nlsupp; n++) { | |
69 if (!strcasecmp(np, lsupp[n].name)) { | |
70 *lsupp[n].sup_flag = 1; | |
71 break; | |
72 } | |
73 } | |
74 } | |
75 } | |
76 return(0); | |
77 } |