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

Function fix_fake_req_headers

modules/tm/t_msgbuilder.h:138–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138static inline int fix_fake_req_headers(struct sip_msg *req)
139{
140 struct hdr_field *hdr;
141 struct lump *ld, *la;
142 contact_t *c;
143
144 if (clone_headers(req, req) < 0) {
145 LM_ERR("could not clone headers list!\n");
146 return -1;
147 }
148 /*
149 * the fix_nated_contact() function in the nathelper module changes the
150 * contact to point to a buffer stored in a lump; the following code
151 * restores the pointer so that functions that use the contact header body
152 * to see the "fixed" contact, rather than the original header
153 */
154 for (hdr = req->contact; hdr; hdr = hdr->sibling) {
155
156 /* not something critical right now, so we can pass the error */
157 if (parse_contact(hdr) < 0 || !hdr->parsed)
158 continue;
159
160 for (c = ((contact_body_t *)hdr->parsed)->contacts; c; c = c->next) {
161 /* search for the lump */
162 for (ld = req->add_rm; ld; ld = ld->next) {
163 if (ld->op != LUMP_DEL && ld->op != LUMP_NOP)
164 continue;
165 for (la = ld->after; la; la = la->after) {
166 /* LM_DBG("matching contact lump op=%d type=%d offset=%d"
167 "len = %d c.offset=%d c.len=%d\n", la->op,
168 la->type, ld->u.offset, ld->len,
169 (int)(c->uri.s-req->buf), c->uri.len); */
170 if (la->op == LUMP_ADD && la->type == HDR_CONTACT_T &&
171 ld->u.offset == c->uri.s-req->buf &&
172 ld->len == c->uri.len) {
173 /* if enclosed, skip enclosing */
174 if (la->u.value[0] == '<') {
175 c->uri.s = la->u.value + 1;
176 c->uri.len = la->len - 2;
177 } else {
178 c->uri.s = la->u.value;
179 c->uri.len = la->len;
180 }
181 LM_DBG("buffer found <%.*s>\n", c->uri.len, c->uri.s);
182 goto next_contact;
183 }
184 }
185 }
186next_contact:
187 ;
188 }
189 }
190 return 0;
191}
192
193
194static inline int fake_req(struct sip_msg *faked_req, struct sip_msg *shm_msg,

Callers 1

fake_reqFunction · 0.85

Calls 2

clone_headersFunction · 0.85
parse_contactFunction · 0.85

Tested by

no test coverage detected