MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / ruri_has_param

Function ruri_has_param

modules/sipmsgops/uri.c:40–88  ·  view source on GitHub ↗

* Find if Request URI has a given parameter with matching value */

Source from the content-addressed store, hash-verified

38 * Find if Request URI has a given parameter with matching value
39 */
40int ruri_has_param(struct sip_msg* _msg, str* param, str* value)
41{
42 str t;
43 param_hooks_t hooks;
44 param_t *params, *p;
45
46 if (parse_sip_msg_uri(_msg) < 0) {
47 LM_ERR("ruri parsing failed\n");
48 return -1;
49 }
50
51 t = _msg->parsed_uri.params;
52
53 if (parse_params(&t, CLASS_ANY, &hooks, &params) < 0) {
54 LM_ERR("ruri parameter parsing failed\n");
55 return -1;
56 }
57
58 p = params;
59 while (p) {
60 if ((p->name.len == param->len) &&
61 (strncmp(p->name.s, param->s, param->len) == 0)) {
62 if (value) {
63 if ((value->len == p->body.len) &&
64 strncmp(value->s, p->body.s, value->len) == 0) {
65 goto ok;
66 } else {
67 goto nok;
68 }
69 } else {
70 if (p->body.len > 0) {
71 goto nok;
72 } else {
73 goto ok;
74 }
75 }
76 } else {
77 p = p->next;
78 }
79 }
80
81nok:
82 free_params(params);
83 return -1;
84
85ok:
86 free_params(params);
87 return 1;
88}
89
90
91

Callers

nothing calls this directly

Calls 3

parse_sip_msg_uriFunction · 0.85
parse_paramsFunction · 0.85
free_paramsFunction · 0.85

Tested by

no test coverage detected