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

Function ruri_del_param

modules/sipmsgops/uri.c:95–179  ·  view source on GitHub ↗

* Removes a given parameter from Request URI */

Source from the content-addressed store, hash-verified

93 * Removes a given parameter from Request URI
94 */
95int ruri_del_param(struct sip_msg* _msg, str* _param)
96{
97 str param = *_param;
98 str params;
99
100 char *tok_end;
101 struct sip_uri *parsed_uri;
102
103 str param_tok, key;
104 str new_uri, old_uri;
105
106 int begin_len, end_len;
107
108 if (param.len == 0)
109 return 1;
110
111 if (parse_sip_msg_uri(_msg) < 0) {
112 LM_ERR("ruri parsing failed\n");
113 return -1;
114 }
115
116 parsed_uri = &(_msg->parsed_uri);
117
118 params = parsed_uri->params;
119 if (0 == params.s || 0 == params.len) {
120 LM_DBG("RURI contains no params to delete! Returning...\n");
121 return -1;
122 }
123
124 while (params.len) {
125 tok_end = q_memchr(params.s, ';', params.len);
126
127 param_tok.s = params.s;
128 if (tok_end == NULL) {
129 param_tok.len = params.len;
130 params.len = 0;
131 } else {
132 param_tok.len = tok_end - params.s;
133 params.len -= (param_tok.len + 1/*';' char*/);
134 params.s += (param_tok.len + 1);
135 }
136
137 tok_end = q_memchr(param_tok.s, '=', param_tok.len);
138 if (tok_end == NULL) {
139 key = param_tok;
140 } else {
141 key.s = param_tok.s;
142 key.len = tok_end - param_tok.s;
143 }
144
145 if (!str_strcmp(&param, &key)) {
146 /* found the param to remove */
147 /* include the leading ';' */
148 param_tok.s--;
149 param_tok.len++;
150 old_uri = *GET_RURI(_msg);
151 new_uri.len = old_uri.len - param_tok.len;
152 new_uri.s = pkg_malloc(new_uri.len);

Callers

nothing calls this directly

Calls 3

parse_sip_msg_uriFunction · 0.85
q_memchrFunction · 0.85
set_ruriFunction · 0.85

Tested by

no test coverage detected