The uri parser seems to fail in multiple ways on username-parameters. The ways it fails depends on the presence of user-params in the incoming request and on adjustments to $ru, $rd and $rU in the script.
My expectation is that the whole username, including user-params is always visible in $rU. In reality, the user-params are absent or present depending on manipulations to the uri in the script.
When setting $rU to a value with a user-param, that user-param is represented when reading $ru, but not in $rU.
I used below config script to test various scenario's.
debug=2
memlog=4
#fork=no # This option should not be present to enable forking but disable daemonize, also -D commandline parameter is needed
log_stderror=yes
log_name="kamailio-test"
log_facility=LOG_LOCAL5
sip_warning=no
children=2
shm_mem_size=128
check_via=no # (cmd. line: -v)
dns=no # (cmd. line: -r)
rev_dns=no # (cmd. line: -R)
dns_use_search_list=no
use_dns_failover=yes
dns_srv_lb=yes
disable_tcp=yes
auto_aliases=no
listen=172.16.1.19:7060
loadmodule "sl.so"
loadmodule "pv.so"
loadmodule "xlog.so"
modparam("xlog", "prefix", "")
route {
xnotice("Incoming $rm to $rU\n");
xinfo("$$ru = $ru\n");
switch ($rU) {
case "100":
xnotice("Set $$rU = \"1234;first=yes\"\n");
$rU = "1234;first=yes";
xinfo("$$ru: $ru\n");
xinfo("$$rU: $rU\n");
if ($rU != "1234;first=yes") {
xerr("Fail!\n");
} else {
xinfo("Success!\n");
}
break;
case "200":
xnotice("Set $$rd = \"example.com;transport=udp\"\n");
$rd = "example.com;transport=udp";
xinfo("$$ru: $ru\n");
xinfo("$$rU: $rU\n");
xnotice("Set $$rU = \"1234;first=yes\"\n");
$rU = "1234;first=yes";
xinfo("$$ru: $ru\n");
xinfo("$$rU: $rU\n");
if ($rU != "1234;first=yes") {
xerr("Fail!\n");
} else {
xinfo("Success!\n");
}
break;
case "300":
xnotice("Set $$ru = \"sip:1234@example.com;transport=udp\"\n");
$ru = "sip:1234@example.com;transport=udp";
xinfo("$$ru: $ru\n");
xinfo("$$rU: $rU\n");
xnotice("Set $$rU = \"1234;first=yes\"\n");
$rU = "1234;first=yes";
xinfo("$$ru: $ru\n");
xinfo("$$rU: $rU\n");
if ($rU != "1234;first=yes") {
xerr("Fail!\n");
} else {
xinfo("Success!\n");
}
break;
case "400":
xnotice("Set $$ru = \"sip:1234;first=yes@example.com;transport=udp\"\n");
$ru = "sip:1234;first=yes@example.com;transport=udp";
xinfo("$$ru: $ru\n");
xinfo("$$rU: $rU\n");
if ($rU != "1234;first=yes") {
xerr("Fail!\n");
} else {
xinfo("Success!\n");
}
xnotice("Set $$rU = \"1234;second=yes\"\n");
$rU = "1234;second=yes";
xinfo("$$ru: $ru\n");
xinfo("$$rU: $rU\n");
if ($rU != "1234;second=yes") {
xerr("Fail!\n");
} else {
xinfo("Success!\n");
}
break;
}
sl_send_reply(500, "Done");
exit;
}
1(2206122) NOTICE: Incoming INVITE to 100
1(2206122) INFO: $ru = sip:100@172.16.1.19:7060;user=phone
1(2206122) NOTICE: Set $rU = "1234;first=yes"
1(2206122) INFO: $ru: sip:1234;first=yes@172.16.1.19:7060;user=phone
1(2206122) INFO: $rU: 1234
1(2206122) ERROR: Fail!
Setting $rU with a user-param sets it correctly in $ru, but reading $rU back fails.
1(2206122) NOTICE: Incoming INVITE to 200
1(2206122) INFO: $ru = sip:200@172.16.1.19:7060;user=phone
1(2206122) NOTICE: Set $rd = "example.com;transport=udp"
1(2206122) INFO: $ru: sip:200@example.com;transport=udp:7060;user=phone
1(2206122) INFO: $rU: 200
1(2206122) NOTICE: Set $rU = "1234;first=yes"
1(2206122) INFO: $ru: sip:1234;first=yes@example.com;transport=udp:7060;user=phone
1(2206122) INFO: $rU: 1234
1(2206122) ERROR: Fail!
Same when setting $rd in advance.
1(2206122) NOTICE: Incoming INVITE to 300
1(2206122) INFO: $ru = sip:300@172.16.1.19:7060;user=phone
1(2206122) NOTICE: Set $ru = "sip:1234@example.com;transport=udp"
1(2206122) INFO: $ru: sip:1234@example.com;transport=udp
1(2206122) INFO: $rU: 1234
1(2206122) NOTICE: Set $rU = "1234;first=yes"
1(2206122) INFO: $ru: sip:1234;first=yes@example.com;transport=udp
1(2206122) INFO: $rU: 1234;first=yes
1(2206122) INFO: Success!
When setting $ru first with no user-param lets a later asssignment to $rU with user-param succeed.
1(2206122) NOTICE: Incoming INVITE to 400
1(2206122) INFO: $ru = sip:400@172.16.1.19:7060;user=phone
1(2206122) NOTICE: Set $ru = "sip:1234;first=yes@example.com;transport=udp"
1(2206122) INFO: $ru: sip:1234;first=yes@example.com;transport=udp
1(2206122) INFO: $rU: 1234;first=yes
1(2206122) INFO: Success!
1(2206122) NOTICE: Set $rU = "1234;second=yes"
1(2206122) INFO: $ru: sip:1234;second=yes@example.com;transport=udp
1(2206122) INFO: $rU: 1234;second=yes
1(2206122) INFO: Success!
Setting $ru with a user-params succeeds. Subsequently overwriting the user part with $rU with a user-param also succeeds.
1(2206122) NOTICE: Incoming INVITE to 400
1(2206122) INFO: $ru = sip:400;existing=yes@172.16.1.19:7060;user=phone
1(2206122) NOTICE: Set $ru = "sip:1234;first=yes@example.com;transport=udp"
1(2206122) INFO: $ru: sip:1234;first=yes@example.com;transport=udp
1(2206122) INFO: $rU: 1234;first=yes
1(2206122) INFO: Success!
1(2206122) NOTICE: Set $rU = "1234;second=yes"
1(2206122) INFO: $ru: sip:1234;second=yes@example.com;transport=udp
1(2206122) INFO: $rU: 1234;second=yes
1(2206122) INFO: Success!
Same as previous, but with incoming user-param.
1(2206122) NOTICE: Incoming INVITE to 100
1(2206122) INFO: $ru = sip:100;existing=yes@172.16.1.19:7060;user=phone
1(2206122) NOTICE: Set $rU = "1234;first=yes"
1(2206122) INFO: $ru: sip:1234;first=yes;existing=yes@172.16.1.19:7060;user=phone
1(2206122) INFO: $rU: 1234
1(2206122) ERROR: Fail!
This one fails in an interesting way. The incoming uri has a user-param. When overwriting $rU with a user-param, the user-param from the incoming request is kept in addition to the new one instead of being overwritten. $rU still misses (both) user-params.
I have no build (yet) with EXTRA_DEBUG enabled.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.