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

Function build_ruri

modules/drouting/drouting.c:2514–2578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2512
2513
2514static inline str* build_ruri(struct sip_uri *uri, int strip, str *pri,
2515 str *hostport)
2516{
2517 static str uri_str;
2518 int user_len;
2519 char *p;
2520
2521 if (uri->user.len<=strip)
2522 strip = uri->user.len;
2523 user_len = uri->user.len - strip + pri->len;
2524
2525 uri_str.len = 4 /*sip:*/ + user_len;
2526 if (uri->passwd.s && uri->passwd.len)
2527 uri_str.len += uri->passwd.len+1;
2528 if ((uri->passwd.s && uri->passwd.len) || user_len > 0)
2529 uri_str.len++; /*@*/
2530
2531 uri_str.len += hostport->len +
2532 (uri->params.s?(uri->params.len+1):0) +
2533 (uri->headers.s?(uri->headers.len+1):0);
2534
2535 if ( (uri_str.s=(char*)pkg_malloc( uri_str.len + 1))==0) {
2536 LM_ERR("no more pkg mem\n");
2537 return 0;
2538 }
2539
2540 p = uri_str.s;
2541 *(p++)='s';
2542 *(p++)='i';
2543 *(p++)='p';
2544 *(p++)=':';
2545 if (pri->len) {
2546 memcpy(p, pri->s, pri->len);
2547 p += pri->len;
2548 }
2549 memcpy(p, uri->user.s+strip, uri->user.len-strip);
2550 p += uri->user.len-strip;
2551 if (uri->passwd.s && uri->passwd.len) {
2552 *(p++)=':';
2553 memcpy(p, uri->passwd.s, uri->passwd.len);
2554 p += uri->passwd.len;
2555 }
2556 if ((uri->passwd.s && uri->passwd.len) || user_len > 0)
2557 *(p++)='@';
2558 memcpy(p, hostport->s, hostport->len);
2559 p += hostport->len;
2560 if (uri->params.s && uri->params.len) {
2561 *(p++)=';';
2562 memcpy(p, uri->params.s, uri->params.len);
2563 p += uri->params.len;
2564 }
2565 if (uri->headers.s && uri->headers.len) {
2566 *(p++)='?';
2567 memcpy(p, uri->headers.s, uri->headers.len);
2568 p += uri->headers.len;
2569 }
2570 *p = 0;
2571

Callers 1

push_gw_for_usageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected