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

Function path_rr_callback

modules/path/path.c:72–153  ·  view source on GitHub ↗

* rr callback */

Source from the content-addressed store, hash-verified

70 * rr callback
71 */
72void path_rr_callback(struct sip_msg *_m, str *r_param, void *cb_param)
73{
74 static str unescape_buf;
75
76 param_hooks_t hooks;
77 param_t *params;
78 param_t *first_param;
79 str received = {0, 0};
80 str transport = {0, 0};
81 str dst_uri = {0, 0};
82 char *p;
83
84 if (parse_params(r_param, CLASS_ANY, &hooks, &params) != 0) {
85 LM_ERR("failed to parse route parameters\n");
86 return;
87 }
88
89 first_param = params;
90
91 while(params)
92 {
93 if (params->name.len == 8 &&
94 !strncasecmp(params->name.s, "received", params->name.len)) {
95
96 received = params->body;
97 if (pkg_str_extend(&unescape_buf, received.len + 1) != 0) {
98 LM_ERR("oom\n");
99 goto out1;
100 }
101
102 if (unescape_param(&received, &unescape_buf) != 0) {
103 LM_ERR("failed to unescape received=%.*s\n",
104 received.len, received.s);
105 goto out1;
106 }
107
108 /* if there's a param here, it has to be ;transport= */
109 if ((p = q_memchr(unescape_buf.s, ';', unescape_buf.len))) {
110 received.len = p - unescape_buf.s;
111
112 if ((p = q_memchr(p, '=', unescape_buf.len))) {
113 transport.s = p + 1;
114 transport.len = unescape_buf.s + unescape_buf.len - transport.s;
115 }
116 }
117
118 break;
119 }
120
121 params = params->next;
122 }
123
124 LM_DBG("extracted received=%.*s, transport=%.*s\n",
125 received.len, received.s, transport.len, transport.s);
126
127 if (received.len > 0) {
128 if (transport.len > 0) {
129 dst_uri.len = received.len + PATH_TRANS_PARAM_LEN + 1 + transport.len;

Callers

nothing calls this directly

Calls 5

parse_paramsFunction · 0.85
pkg_str_extendFunction · 0.85
q_memchrFunction · 0.85
set_dst_uriFunction · 0.85
free_paramsFunction · 0.85

Tested by

no test coverage detected