/src/opensips/parser/parse_uri.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (C) 2001-2003 FhG Fokus |
3 | | * |
4 | | * This file is part of opensips, a free SIP server. |
5 | | * |
6 | | * opensips is free software; you can redistribute it and/or modify |
7 | | * it under the terms of the GNU General Public License as published by |
8 | | * the Free Software Foundation; either version 2 of the License, or |
9 | | * (at your option) any later version |
10 | | * |
11 | | * opensips is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program; if not, write to the Free Software |
18 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | | * |
20 | | */ |
21 | | |
22 | | |
23 | | #ifndef PARSE_URI_H |
24 | | #define PARSE_URI_H |
25 | | |
26 | | /* |
27 | | * SIP URI parser |
28 | | */ |
29 | | |
30 | | |
31 | | #include "../ut.h" |
32 | | #include "../str.h" |
33 | | #include "../net/trans.h" |
34 | | #include "../parser/msg_parser.h" |
35 | | |
36 | 0 | #define SIP_SCH 0x3a706973 |
37 | 0 | #define SIPS_SCH 0x73706973 |
38 | 0 | #define TEL_SCH 0x3a6c6574 |
39 | 0 | #define URN_SERVICE_SCH 0x3a6e7275 |
40 | 0 | #define URN_SERVICE_STR ":service:" |
41 | 0 | #define URN_SERVICE_STR_LEN (sizeof(URN_SERVICE_STR) - 1) |
42 | 0 | #define URN_NENA_SERVICE_STR ":nena:service:" |
43 | 0 | #define URN_NENA_SERVICE_STR_LEN (sizeof(URN_NENA_SERVICE_STR) - 1) |
44 | | |
45 | | /* buf= pointer to beginning of uri (sip:x@foo.bar:5060;a=b?h=i) |
46 | | * len= len of uri |
47 | | * returns: fills uri & returns <0 on error or 0 if ok |
48 | | */ |
49 | | int parse_uri(char *buf, int len, struct sip_uri* uri); |
50 | | |
51 | | /* |
52 | | * Fully prints a given "struct sip_uri" into a given buffer |
53 | | * |
54 | | * The following "struct sip_uri" fields can be disabled by setting to NULL: |
55 | | * - passwd / host / port |
56 | | * - transport / ttl / user_param / maddr / method / lr / r2 / gr |
57 | | * - any of the unknown param names |
58 | | * |
59 | | * Returns 0 on success, -1 on failure |
60 | | */ |
61 | | int print_uri(struct sip_uri *uri, str *out_buf); |
62 | | |
63 | | /* headers : the list of headers to parse (taken from uri structure) |
64 | | * h_name[] : array of header names |
65 | | * h_val[] : array of header values |
66 | | * h_size : size of header array */ |
67 | | int parse_uri_headers(str headers, str h_name[], str h_val[], int h_size); |
68 | | int parse_sip_msg_uri(struct sip_msg* msg); |
69 | | int parse_orig_ruri(struct sip_msg* msg); |
70 | | int compare_uris(str *raw_uri_a,struct sip_uri* parsed_uri_a, |
71 | | str *raw_uri_b,struct sip_uri *parsed_uri_b); |
72 | | static inline int get_uri_param_val(const struct sip_uri *uri, |
73 | | const str *param, str *val); |
74 | | static inline int get_uri_param_idx(const str *param, |
75 | | const struct sip_uri *parsed_uri); |
76 | | |
77 | | /** |
78 | | * Test a given char or an entire string against the allowed characters |
79 | | * of a SIP URI 'username' field. |
80 | | * |
81 | | * Return 1 (success), 0 (failure) |
82 | | */ |
83 | | static inline int is_username_char(char c); |
84 | | static inline int is_username_str(const str *username); |
85 | | |
86 | | /** |
87 | | * Test a given char or an entire string against the allowed characters |
88 | | * of a SIP URI 'uri-parameter' field. Works for both 'pname' |
89 | | * and 'pvalue'. |
90 | | * |
91 | | * Return 1 (success), 0 (failure) |
92 | | */ |
93 | | static inline int is_uri_parameter_char(char c); |
94 | | static inline int is_uri_parameter_str(const str *uri_param); |
95 | | |
96 | | char * uri_type2str(const uri_type type, char *result); |
97 | | int uri_typestrlen(const uri_type type); |
98 | | uri_type str2uri_type(char * buf); |
99 | | |
100 | | /* Gets (in a SIP wise manner) the SIP port from a SIP URI ; if the port |
101 | | is not explicitly set in the URI, it returns the default port corresponding |
102 | | to the used transport protocol (if protocol misses, we assume the default |
103 | | protos according to the URI schema) */ |
104 | | static inline unsigned short get_uri_port(struct sip_uri* _uri, |
105 | | unsigned short *_proto) |
106 | 0 | { |
107 | 0 | unsigned short port; |
108 | 0 | unsigned short proto; |
109 | | |
110 | | /* known protocol? */ |
111 | 0 | if ((proto=_uri->proto)==PROTO_NONE) { |
112 | | /* use UDP as default proto, but TLS for secure schemas */ |
113 | 0 | proto = (_uri->type==SIPS_URI_T || _uri->type==TELS_URI_T)? |
114 | 0 | PROTO_TLS : PROTO_UDP ; |
115 | 0 | } |
116 | | |
117 | | /* known port? */ |
118 | 0 | if ((port=_uri->port_no)==0) |
119 | 0 | port = protos[proto].default_rfc_port; |
120 | |
|
121 | 0 | if (_proto) *_proto = proto; |
122 | |
|
123 | 0 | return port; |
124 | 0 | } Unexecuted instantiation: msg_parser.c:get_uri_port Unexecuted instantiation: parse_uri.c:get_uri_port Unexecuted instantiation: parse_to.c:get_uri_port Unexecuted instantiation: strcommon.c:get_uri_port Unexecuted instantiation: transformations.c:get_uri_port Unexecuted instantiation: pvar.c:get_uri_port Unexecuted instantiation: parse_ppi.c:get_uri_port Unexecuted instantiation: parse_from.c:get_uri_port Unexecuted instantiation: core_cmds.c:get_uri_port |
125 | | |
126 | | |
127 | | /** |
128 | | * get_uri_param_val() - Fetch the value of a given URI parameter |
129 | | * @uri - parsed SIP URI |
130 | | * @param - URI param name to search for |
131 | | * @val - output value |
132 | | * |
133 | | * Return: |
134 | | * 0 on RFC-recognized parameters (even if they are missing!) |
135 | | * or successful search of unknown ones |
136 | | * -1 otherwise |
137 | | */ |
138 | | static inline int get_uri_param_val(const struct sip_uri *uri, |
139 | | const str *param, str *val) |
140 | 0 | { |
141 | 0 | int i; |
142 | 0 |
|
143 | 0 | if (ZSTR(*param)) |
144 | 0 | return -1; |
145 | 0 |
|
146 | 0 | switch (param->s[0]) { |
147 | 0 | case 'p': |
148 | 0 | case 'P': |
149 | 0 | if (str_casematch(param, const_str("pn-provider"))) { |
150 | 0 | *val = uri->pn_provider_val; |
151 | 0 | return 0; |
152 | 0 | } |
153 | 0 |
|
154 | 0 | if (str_casematch(param, const_str("pn-prid"))) { |
155 | 0 | *val = uri->pn_prid_val; |
156 | 0 | return 0; |
157 | 0 | } |
158 | 0 |
|
159 | 0 | if (str_casematch(param, const_str("pn-param"))) { |
160 | 0 | *val = uri->pn_param_val; |
161 | 0 | return 0; |
162 | 0 | } |
163 | 0 |
|
164 | 0 | if (str_casematch(param, const_str("pn-purr"))) { |
165 | 0 | *val = uri->pn_purr_val; |
166 | 0 | return 0; |
167 | 0 | } |
168 | 0 | break; |
169 | 0 |
|
170 | 0 | case 't': |
171 | 0 | case 'T': |
172 | 0 | if (str_casematch(param, const_str("transport"))) { |
173 | 0 | *val = uri->transport_val; |
174 | 0 | return 0; |
175 | 0 | } |
176 | 0 |
|
177 | 0 | if (str_casematch(param, const_str("ttl"))) { |
178 | 0 | *val = uri->ttl_val; |
179 | 0 | return 0; |
180 | 0 | } |
181 | 0 | break; |
182 | 0 |
|
183 | 0 | case 'u': |
184 | 0 | case 'U': |
185 | 0 | if (str_casematch(param, const_str("user"))) { |
186 | 0 | *val = uri->user_param_val; |
187 | 0 | return 0; |
188 | 0 | } |
189 | 0 | break; |
190 | 0 |
|
191 | 0 | case 'm': |
192 | 0 | case 'M': |
193 | 0 | if (str_casematch(param, const_str("maddr"))) { |
194 | 0 | *val = uri->maddr_val; |
195 | 0 | return 0; |
196 | 0 | } |
197 | 0 |
|
198 | 0 | if (str_casematch(param, const_str("method"))) { |
199 | 0 | *val = uri->method_val; |
200 | 0 | return 0; |
201 | 0 | } |
202 | 0 | break; |
203 | 0 |
|
204 | 0 | case 'l': |
205 | 0 | case 'L': |
206 | 0 | if (str_casematch(param, const_str("lr"))) { |
207 | 0 | *val = uri->lr_val; |
208 | 0 | return 0; |
209 | 0 | } |
210 | 0 | break; |
211 | 0 |
|
212 | 0 | case 'r': |
213 | 0 | case 'R': |
214 | 0 | if (str_casematch(param, const_str("r2"))) { |
215 | 0 | *val = uri->r2_val; |
216 | 0 | return 0; |
217 | 0 | } |
218 | 0 | break; |
219 | 0 |
|
220 | 0 | case 'g': |
221 | 0 | case 'G': |
222 | 0 | if (str_casematch(param, const_str("gr"))) { |
223 | 0 | *val = uri->gr_val; |
224 | 0 | return 0; |
225 | 0 | } |
226 | 0 | break; |
227 | 0 | } |
228 | 0 |
|
229 | 0 | for (i = 0; i < uri->u_params_no; i++) |
230 | 0 | if (str_match(param, &uri->u_name[i])) { |
231 | 0 | *val = uri->u_val[i]; |
232 | 0 | return 0; |
233 | 0 | } |
234 | 0 |
|
235 | 0 | return -1; |
236 | 0 | } Unexecuted instantiation: msg_parser.c:get_uri_param_val Unexecuted instantiation: parse_uri.c:get_uri_param_val Unexecuted instantiation: parse_to.c:get_uri_param_val Unexecuted instantiation: strcommon.c:get_uri_param_val Unexecuted instantiation: transformations.c:get_uri_param_val Unexecuted instantiation: pvar.c:get_uri_param_val Unexecuted instantiation: parse_ppi.c:get_uri_param_val Unexecuted instantiation: parse_from.c:get_uri_param_val Unexecuted instantiation: core_cmds.c:get_uri_param_val |
237 | | |
238 | | |
239 | | /* Unknown URI param index. |
240 | | * |
241 | | * Returns >= 0 on success, -1 on failure. |
242 | | */ |
243 | | static inline int get_uri_param_idx(const str *param, |
244 | | const struct sip_uri *parsed_uri) |
245 | 0 | { |
246 | 0 | int i; |
247 | 0 |
|
248 | 0 | for (i = 0; i < parsed_uri->u_params_no; i++) |
249 | 0 | if (str_match(&parsed_uri->u_name[i], param)) |
250 | 0 | return i; |
251 | 0 |
|
252 | 0 | return -1; |
253 | 0 | } Unexecuted instantiation: msg_parser.c:get_uri_param_idx Unexecuted instantiation: parse_uri.c:get_uri_param_idx Unexecuted instantiation: parse_to.c:get_uri_param_idx Unexecuted instantiation: strcommon.c:get_uri_param_idx Unexecuted instantiation: transformations.c:get_uri_param_idx Unexecuted instantiation: pvar.c:get_uri_param_idx Unexecuted instantiation: parse_ppi.c:get_uri_param_idx Unexecuted instantiation: parse_from.c:get_uri_param_idx Unexecuted instantiation: core_cmds.c:get_uri_param_idx |
254 | | |
255 | | static inline int is_username_char(char c) |
256 | 0 | { |
257 | 0 | return (int[]){ |
258 | 0 | 0 /* 0 NUL */, |
259 | 0 | 0 /* 1 SOH */, |
260 | 0 | 0 /* 2 STX */, |
261 | 0 | 0 /* 3 ETX */, |
262 | 0 | 0 /* 4 EOT */, |
263 | 0 | 0 /* 5 ENQ */, |
264 | 0 | 0 /* 6 ACK */, |
265 | 0 | 0 /* 7 BEL */, |
266 | 0 | 0 /* 8 BS */, |
267 | 0 | 0 /* 9 HT */, |
268 | 0 | 0 /* 10 LF */, |
269 | 0 | 0 /* 11 VT */, |
270 | 0 | 0 /* 12 FF */, |
271 | 0 | 0 /* 13 CR */, |
272 | 0 | 0 /* 14 SO */, |
273 | 0 | 0 /* 15 SI */, |
274 | 0 | 0 /* 16 DLE */, |
275 | 0 | 0 /* 17 DC1 */, |
276 | 0 | 0 /* 18 DC2 */, |
277 | 0 | 0 /* 19 DC3 */, |
278 | 0 | 0 /* 20 DC4 */, |
279 | 0 | 0 /* 21 NAK */, |
280 | 0 | 0 /* 22 SYN */, |
281 | 0 | 0 /* 23 ETB */, |
282 | 0 | 0 /* 24 CAN */, |
283 | 0 | 0 /* 25 EM */, |
284 | 0 | 0 /* 26 SUB */, |
285 | 0 | 0 /* 27 ESC */, |
286 | 0 | 0 /* 28 FS */, |
287 | 0 | 0 /* 29 GS */, |
288 | 0 | 0 /* 30 RS */, |
289 | 0 | 0 /* 31 US */, |
290 | 0 | 0 /* 32 */, |
291 | 0 | 1 /* 33 ! */, |
292 | 0 | 0 /* 34 " */, |
293 | 0 | 0 /* 35 # */, |
294 | 0 | 1 /* 36 $ */, |
295 | 0 | 0 /* 37 % */, |
296 | 0 | 1 /* 38 & */, |
297 | 0 | 1 /* 39 ' */, |
298 | 0 | 1 /* 40 ( */, |
299 | 0 | 1 /* 41 ) */, |
300 | 0 | 1 /* 42 * */, |
301 | 0 | 1 /* 43 + */, |
302 | 0 | 1 /* 44 , */, |
303 | 0 | 1 /* 45 - */, |
304 | 0 | 1 /* 46 . */, |
305 | 0 | 1 /* 47 / */, |
306 | 0 | 1 /* 48 0 */, |
307 | 0 | 1 /* 49 1 */, |
308 | 0 | 1 /* 50 2 */, |
309 | 0 | 1 /* 51 3 */, |
310 | 0 | 1 /* 52 4 */, |
311 | 0 | 1 /* 53 5 */, |
312 | 0 | 1 /* 54 6 */, |
313 | 0 | 1 /* 55 7 */, |
314 | 0 | 1 /* 56 8 */, |
315 | 0 | 1 /* 57 9 */, |
316 | 0 | 0 /* 58 : */, |
317 | 0 | 1 /* 59 ; */, |
318 | 0 | 0 /* 60 < */, |
319 | 0 | 1 /* 61 = */, |
320 | 0 | 0 /* 62 > */, |
321 | 0 | 1 /* 63 ? */, |
322 | 0 | 0 /* 64 @ */, |
323 | 0 | 1 /* 65 A */, |
324 | 0 | 1 /* 66 B */, |
325 | 0 | 1 /* 67 C */, |
326 | 0 | 1 /* 68 D */, |
327 | 0 | 1 /* 69 E */, |
328 | 0 | 1 /* 70 F */, |
329 | 0 | 1 /* 71 G */, |
330 | 0 | 1 /* 72 H */, |
331 | 0 | 1 /* 73 I */, |
332 | 0 | 1 /* 74 J */, |
333 | 0 | 1 /* 75 K */, |
334 | 0 | 1 /* 76 L */, |
335 | 0 | 1 /* 77 M */, |
336 | 0 | 1 /* 78 N */, |
337 | 0 | 1 /* 79 O */, |
338 | 0 | 1 /* 80 P */, |
339 | 0 | 1 /* 81 Q */, |
340 | 0 | 1 /* 82 R */, |
341 | 0 | 1 /* 83 S */, |
342 | 0 | 1 /* 84 T */, |
343 | 0 | 1 /* 85 U */, |
344 | 0 | 1 /* 86 V */, |
345 | 0 | 1 /* 87 W */, |
346 | 0 | 1 /* 88 X */, |
347 | 0 | 1 /* 89 Y */, |
348 | 0 | 1 /* 90 Z */, |
349 | 0 | 0 /* 91 [ */, |
350 | 0 | 0 /* 92 \ */, |
351 | 0 | 0 /* 93 ] */, |
352 | 0 | 0 /* 94 ^ */, |
353 | 0 | 1 /* 95 _ */, |
354 | 0 | 0 /* 96 ` */, |
355 | 0 | 1 /* 97 a */, |
356 | 0 | 1 /* 98 b */, |
357 | 0 | 1 /* 99 c */, |
358 | 0 | 1 /* 100 d */, |
359 | 0 | 1 /* 101 e */, |
360 | 0 | 1 /* 102 f */, |
361 | 0 | 1 /* 103 g */, |
362 | 0 | 1 /* 104 h */, |
363 | 0 | 1 /* 105 i */, |
364 | 0 | 1 /* 106 j */, |
365 | 0 | 1 /* 107 k */, |
366 | 0 | 1 /* 108 l */, |
367 | 0 | 1 /* 109 m */, |
368 | 0 | 1 /* 110 n */, |
369 | 0 | 1 /* 111 o */, |
370 | 0 | 1 /* 112 p */, |
371 | 0 | 1 /* 113 q */, |
372 | 0 | 1 /* 114 r */, |
373 | 0 | 1 /* 115 s */, |
374 | 0 | 1 /* 116 t */, |
375 | 0 | 1 /* 117 u */, |
376 | 0 | 1 /* 118 v */, |
377 | 0 | 1 /* 119 w */, |
378 | 0 | 1 /* 120 x */, |
379 | 0 | 1 /* 121 y */, |
380 | 0 | 1 /* 122 z */, |
381 | 0 | 0 /* 123 { */, |
382 | 0 | 0 /* 124 | */, |
383 | 0 | 0 /* 125 } */, |
384 | 0 | 1 /* 126 ~ */, |
385 | 0 | 0 /* 127 DEL */ |
386 | 0 | }[(int)c]; |
387 | 0 | } Unexecuted instantiation: msg_parser.c:is_username_char Unexecuted instantiation: parse_uri.c:is_username_char Unexecuted instantiation: parse_to.c:is_username_char Unexecuted instantiation: strcommon.c:is_username_char Unexecuted instantiation: transformations.c:is_username_char Unexecuted instantiation: pvar.c:is_username_char Unexecuted instantiation: parse_ppi.c:is_username_char Unexecuted instantiation: parse_from.c:is_username_char Unexecuted instantiation: core_cmds.c:is_username_char |
388 | | |
389 | | |
390 | | static inline int is_username_str(const str *username) |
391 | 0 | { |
392 | 0 | char *p, *end, c; |
393 | 0 |
|
394 | 0 | for (p = username->s, end = p + username->len; p < end; p++) { |
395 | 0 | c = *p; |
396 | 0 |
|
397 | 0 | if (c < 0) |
398 | 0 | goto err; |
399 | 0 |
|
400 | 0 | if (c == '%') { |
401 | 0 | if ((p + 3) > end || !_isxdigit(*(p + 1)) || !_isxdigit(*(p + 2))) |
402 | 0 | goto err; |
403 | 0 | p += 2; |
404 | 0 | } else if (!is_username_char(c)) { |
405 | 0 | goto err; |
406 | 0 | } |
407 | 0 | } |
408 | 0 |
|
409 | 0 | return 1; |
410 | 0 |
|
411 | 0 | err: |
412 | 0 | LM_DBG("invalid character %c[%d] in username <%.*s> on index %d\n", |
413 | 0 | c, c, username->len, username->s, (int)(p - username->s)); |
414 | 0 | return 0; |
415 | 0 | } Unexecuted instantiation: msg_parser.c:is_username_str Unexecuted instantiation: parse_uri.c:is_username_str Unexecuted instantiation: parse_to.c:is_username_str Unexecuted instantiation: strcommon.c:is_username_str Unexecuted instantiation: transformations.c:is_username_str Unexecuted instantiation: pvar.c:is_username_str Unexecuted instantiation: parse_ppi.c:is_username_str Unexecuted instantiation: parse_from.c:is_username_str Unexecuted instantiation: core_cmds.c:is_username_str |
416 | | |
417 | | |
418 | | static inline int is_uri_parameter_char(char c) |
419 | 0 | { |
420 | 0 | return (int[]){ |
421 | 0 | 0 /* 0 NUL */, |
422 | 0 | 0 /* 1 SOH */, |
423 | 0 | 0 /* 2 STX */, |
424 | 0 | 0 /* 3 ETX */, |
425 | 0 | 0 /* 4 EOT */, |
426 | 0 | 0 /* 5 ENQ */, |
427 | 0 | 0 /* 6 ACK */, |
428 | 0 | 0 /* 7 BEL */, |
429 | 0 | 0 /* 8 BS */, |
430 | 0 | 0 /* 9 HT */, |
431 | 0 | 0 /* 10 LF */, |
432 | 0 | 0 /* 11 VT */, |
433 | 0 | 0 /* 12 FF */, |
434 | 0 | 0 /* 13 CR */, |
435 | 0 | 0 /* 14 SO */, |
436 | 0 | 0 /* 15 SI */, |
437 | 0 | 0 /* 16 DLE */, |
438 | 0 | 0 /* 17 DC1 */, |
439 | 0 | 0 /* 18 DC2 */, |
440 | 0 | 0 /* 19 DC3 */, |
441 | 0 | 0 /* 20 DC4 */, |
442 | 0 | 0 /* 21 NAK */, |
443 | 0 | 0 /* 22 SYN */, |
444 | 0 | 0 /* 23 ETB */, |
445 | 0 | 0 /* 24 CAN */, |
446 | 0 | 0 /* 25 EM */, |
447 | 0 | 0 /* 26 SUB */, |
448 | 0 | 0 /* 27 ESC */, |
449 | 0 | 0 /* 28 FS */, |
450 | 0 | 0 /* 29 GS */, |
451 | 0 | 0 /* 30 RS */, |
452 | 0 | 0 /* 31 US */, |
453 | 0 | 0 /* 32 */, |
454 | 0 | 1 /* 33 ! */, |
455 | 0 | 0 /* 34 " */, |
456 | 0 | 0 /* 35 # */, |
457 | 0 | 1 /* 36 $ */, |
458 | 0 | 0 /* 37 % */, |
459 | 0 | 1 /* 38 & */, |
460 | 0 | 1 /* 39 ' */, |
461 | 0 | 1 /* 40 ( */, |
462 | 0 | 1 /* 41 ) */, |
463 | 0 | 1 /* 42 * */, |
464 | 0 | 1 /* 43 + */, |
465 | 0 | 0 /* 44 , */, |
466 | 0 | 1 /* 45 - */, |
467 | 0 | 1 /* 46 . */, |
468 | 0 | 1 /* 47 / */, |
469 | 0 | 1 /* 48 0 */, |
470 | 0 | 1 /* 49 1 */, |
471 | 0 | 1 /* 50 2 */, |
472 | 0 | 1 /* 51 3 */, |
473 | 0 | 1 /* 52 4 */, |
474 | 0 | 1 /* 53 5 */, |
475 | 0 | 1 /* 54 6 */, |
476 | 0 | 1 /* 55 7 */, |
477 | 0 | 1 /* 56 8 */, |
478 | 0 | 1 /* 57 9 */, |
479 | 0 | 1 /* 58 : */, |
480 | 0 | 0 /* 59 ; */, |
481 | 0 | 0 /* 60 < */, |
482 | 0 | 0 /* 61 = */, |
483 | 0 | 0 /* 62 > */, |
484 | 0 | 0 /* 63 ? */, |
485 | 0 | 0 /* 64 @ */, |
486 | 0 | 1 /* 65 A */, |
487 | 0 | 1 /* 66 B */, |
488 | 0 | 1 /* 67 C */, |
489 | 0 | 1 /* 68 D */, |
490 | 0 | 1 /* 69 E */, |
491 | 0 | 1 /* 70 F */, |
492 | 0 | 1 /* 71 G */, |
493 | 0 | 1 /* 72 H */, |
494 | 0 | 1 /* 73 I */, |
495 | 0 | 1 /* 74 J */, |
496 | 0 | 1 /* 75 K */, |
497 | 0 | 1 /* 76 L */, |
498 | 0 | 1 /* 77 M */, |
499 | 0 | 1 /* 78 N */, |
500 | 0 | 1 /* 79 O */, |
501 | 0 | 1 /* 80 P */, |
502 | 0 | 1 /* 81 Q */, |
503 | 0 | 1 /* 82 R */, |
504 | 0 | 1 /* 83 S */, |
505 | 0 | 1 /* 84 T */, |
506 | 0 | 1 /* 85 U */, |
507 | 0 | 1 /* 86 V */, |
508 | 0 | 1 /* 87 W */, |
509 | 0 | 1 /* 88 X */, |
510 | 0 | 1 /* 89 Y */, |
511 | 0 | 1 /* 90 Z */, |
512 | 0 | 1 /* 91 [ */, |
513 | 0 | 0 /* 92 \ */, |
514 | 0 | 1 /* 93 ] */, |
515 | 0 | 0 /* 94 ^ */, |
516 | 0 | 1 /* 95 _ */, |
517 | 0 | 0 /* 96 ` */, |
518 | 0 | 1 /* 97 a */, |
519 | 0 | 1 /* 98 b */, |
520 | 0 | 1 /* 99 c */, |
521 | 0 | 1 /* 100 d */, |
522 | 0 | 1 /* 101 e */, |
523 | 0 | 1 /* 102 f */, |
524 | 0 | 1 /* 103 g */, |
525 | 0 | 1 /* 104 h */, |
526 | 0 | 1 /* 105 i */, |
527 | 0 | 1 /* 106 j */, |
528 | 0 | 1 /* 107 k */, |
529 | 0 | 1 /* 108 l */, |
530 | 0 | 1 /* 109 m */, |
531 | 0 | 1 /* 110 n */, |
532 | 0 | 1 /* 111 o */, |
533 | 0 | 1 /* 112 p */, |
534 | 0 | 1 /* 113 q */, |
535 | 0 | 1 /* 114 r */, |
536 | 0 | 1 /* 115 s */, |
537 | 0 | 1 /* 116 t */, |
538 | 0 | 1 /* 117 u */, |
539 | 0 | 1 /* 118 v */, |
540 | 0 | 1 /* 119 w */, |
541 | 0 | 1 /* 120 x */, |
542 | 0 | 1 /* 121 y */, |
543 | 0 | 1 /* 122 z */, |
544 | 0 | 0 /* 123 { */, |
545 | 0 | 0 /* 124 | */, |
546 | 0 | 0 /* 125 } */, |
547 | 0 | 1 /* 126 ~ */, |
548 | 0 | 0 /* 127 DEL */ |
549 | 0 | }[(int)c]; |
550 | 0 | } Unexecuted instantiation: msg_parser.c:is_uri_parameter_char Unexecuted instantiation: parse_uri.c:is_uri_parameter_char Unexecuted instantiation: parse_to.c:is_uri_parameter_char Unexecuted instantiation: strcommon.c:is_uri_parameter_char Unexecuted instantiation: transformations.c:is_uri_parameter_char Unexecuted instantiation: pvar.c:is_uri_parameter_char Unexecuted instantiation: parse_ppi.c:is_uri_parameter_char Unexecuted instantiation: parse_from.c:is_uri_parameter_char Unexecuted instantiation: core_cmds.c:is_uri_parameter_char |
551 | | |
552 | | |
553 | | static inline int is_uri_parameter_str(const str *uri_param) |
554 | 0 | { |
555 | 0 | char *p, *end, c; |
556 | 0 |
|
557 | 0 | for (p = uri_param->s, end = p + uri_param->len; p < end; p++) { |
558 | 0 | c = *p; |
559 | 0 |
|
560 | 0 | if (c < 0) |
561 | 0 | goto err; |
562 | 0 |
|
563 | 0 | if (c == '%') { |
564 | 0 | if ((p + 3) > end || !_isxdigit(*(p + 1)) || !_isxdigit(*(p + 2))) |
565 | 0 | goto err; |
566 | 0 | p += 2; |
567 | 0 | } else if (!is_uri_parameter_char(c)) { |
568 | 0 | goto err; |
569 | 0 | } |
570 | 0 | } |
571 | 0 |
|
572 | 0 | return 1; |
573 | 0 |
|
574 | 0 | err: |
575 | 0 | LM_DBG("invalid character %c[%d] in uri-parameter <%.*s> on index %d\n", |
576 | 0 | c, c, uri_param->len, uri_param->s, (int)(p - uri_param->s)); |
577 | 0 | return 0; |
578 | 0 | } Unexecuted instantiation: msg_parser.c:is_uri_parameter_str Unexecuted instantiation: parse_uri.c:is_uri_parameter_str Unexecuted instantiation: parse_to.c:is_uri_parameter_str Unexecuted instantiation: strcommon.c:is_uri_parameter_str Unexecuted instantiation: transformations.c:is_uri_parameter_str Unexecuted instantiation: pvar.c:is_uri_parameter_str Unexecuted instantiation: parse_ppi.c:is_uri_parameter_str Unexecuted instantiation: parse_from.c:is_uri_parameter_str Unexecuted instantiation: core_cmds.c:is_uri_parameter_str |
579 | | |
580 | | #endif /* PARSE_URI_H */ |