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

Function process_routeset

modules/tm/t_msgbuilder.c:287–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285
286
287static inline int process_routeset(struct sip_msg* msg, str* contact, struct rte** list, str* ruri, str* next_hop)
288{
289 struct hdr_field* ptr;
290 rr_t* p;
291 struct rte* t, *head;
292 struct sip_uri puri;
293
294 ptr = msg->record_route;
295 head = 0;
296 while(ptr) {
297 if (ptr->type == HDR_RECORDROUTE_T) {
298 if (parse_rr(ptr) < 0) {
299 LM_ERR("failed to parse Record-Route header\n");
300 return -1;
301 }
302
303 p = (rr_t*)ptr->parsed;
304 while(p) {
305 t = (struct rte*)pkg_malloc(sizeof(struct rte));
306 if (!t) {
307 LM_ERR("no more pkg memory\n");
308 free_rte_list(head);
309 return -1;
310 }
311 t->ptr = p;
312 t->next = head;
313 head = t;
314 p = p->next;
315 }
316 }
317 ptr = ptr->next;
318 }
319
320 if (head) {
321 if (parse_uri(head->ptr->nameaddr.uri.s, head->ptr->nameaddr.uri.len, &puri) < 0) {
322 LM_ERR("failed to parse URI\n");
323 free_rte_list(head);
324 return -1;
325 }
326
327 if (puri.lr.s) {
328 /* Next hop is loose router */
329 *ruri = *contact;
330 *next_hop = head->ptr->nameaddr.uri;
331 } else {
332 /* Next hop is strict router */
333 *ruri = head->ptr->nameaddr.uri;
334 *next_hop = *ruri;
335 t = head;
336 head = head->next;
337 pkg_free(t);
338 }
339 } else {
340 /* No routes */
341 *ruri = *contact;
342 *next_hop = *contact;
343 }
344

Callers 1

build_dlg_ackFunction · 0.85

Calls 3

parse_rrFunction · 0.85
free_rte_listFunction · 0.85
parse_uriFunction · 0.85

Tested by

no test coverage detected