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

Function clone_authorized_hooks

modules/tm/sip_msg.c:253–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251
252
253static inline int clone_authorized_hooks(struct sip_msg* new,
254 struct sip_msg* old)
255{
256 struct hdr_field* ptr, *new_ptr, *hook1, *hook2;
257 char stop = 0;
258
259 get_authorized_cred(old->authorization, &hook1);
260 if (!hook1) stop = 1;
261
262 get_authorized_cred(old->proxy_auth, &hook2);
263 if (!hook2) stop |= 2;
264
265 ptr = old->headers;
266 new_ptr = new->headers;
267
268 while(ptr) {
269 if (ptr == hook1) {
270 if (!new->authorization || !new->authorization->parsed) {
271 LM_CRIT("message cloner (authorization) failed\n");
272 return -1;
273 }
274 ((struct auth_body*)new->authorization->parsed)->authorized =
275 new_ptr;
276 stop |= 1;
277 }
278
279 if (ptr == hook2) {
280 if (!new->proxy_auth || !new->proxy_auth->parsed) {
281 LM_CRIT("message cloner (proxy_auth) failed\n");
282 return -1;
283 }
284 ((struct auth_body*)new->proxy_auth->parsed)->authorized =
285 new_ptr;
286 stop |= 2;
287 }
288
289 if (stop == 3) break;
290
291 ptr = ptr->next;
292 new_ptr = new_ptr->next;
293 }
294 return 0;
295}
296
297
298#define AUTH_BODY_SIZE sizeof(struct auth_body)

Callers 1

sip_msg_clonerFunction · 0.85

Calls 1

get_authorized_credFunction · 0.85

Tested by

no test coverage detected