[OpenSIPS-Users] String to IP transformations
Liviu Chircu
liviu at opensips.org
Thu Dec 13 07:23:17 EST 2018
Hi Alexey,
Nice catch! All four tests should produce DIFFERENT. We have to look
closer and figure out what is happening there... a quick assumption
could be that there are some \0 NULL bytes in the binary-stored
addresses which may not work very well with the script string comparison
implementation.
Cheers,
Liviu Chircu
OpenSIPS Developer
http://www.opensips-solutions.com
On 13.12.2018 13:34, vasilevalex wrote:
> Hi, all.
>
> OpenSIPS 2.4.3 this script:
>
> $var(ip_1_s) = "[2001:6c8:5e00:1::249]";
> $var(ip_1_b) = $(var(ip_1_s){ip.pton}); # Save binary IP to variable
> $var(ip_1) = $(var(ip_1_s){ip.pton}{ip.ntop}); # Save string from binary IP
> to variable
> $var(ip_2_s) = "[2001:6c8:5e00:1::250]";
> $var(ip_2_b) = $(var(ip_2_s){ip.pton}); # Save binary IP to variable
> $var(ip_2) = $(var(ip_2_s){ip.pton}{ip.ntop}); # Save string from binary IP
> to variable
> xlog("IP1 is $(var(ip_1)) af is $(var(ip_1_s){ip.pton}{ip.family})");
> xlog("IP2 is $(var(ip_2)) af is $(var(ip_2_s){ip.pton}{ip.family})");
> if ($(var(ip_1_s){ip.pton}) == $(var(ip_2_s){ip.pton})) {
> xlog("Binary addresses are EQUAL");
> } else {
> xlog("Binary addresses are DIFFERENT");
> }
> if ($(var(ip_1_s){ip.pton}{ip.ntop}) == $(var(ip_2_s){ip.pton}{ip.ntop})) {
> xlog("Binary to string addresses are EQUAL");
> } else {
> xlog("Binary to string addresses are DIFFERENT");
> }
> if ($var(ip_1_b) == $var(ip_2_b)) {
> xlog("Variable saved Binary addresses are EQUAL");
> } else {
> xlog("Variable saved Binary addresses are DIFFERENT");
> }
> if ($var(ip_1) == $var(ip_2)) {
> xlog("Variable saved Binary to string addresses are EQUAL");
> } else {
> xlog("Variable saved Binary to string addresses are DIFFERENT");
> }
>
>
> I thought, that all 4 conditions should be false. But I got this:
>
> Dec 13 11:23:09 test64 /usr/sbin/opensips[6063]: IP1 is
> 2001:6C8:5E00:1:0:0:0:249 af is INET6
> Dec 13 11:23:09 test64 /usr/sbin/opensips[6063]: IP2 is
> 2001:6C8:5E00:1:0:0:0:250 af is INET6
> Dec 13 11:23:09 test64 /usr/sbin/opensips[6063]: Binary addresses are EQUAL
> Dec 13 11:23:09 test64 /usr/sbin/opensips[6063]: Binary to string addresses
> are EQUAL
> Dec 13 11:23:09 test64 /usr/sbin/opensips[6063]: Variable saved Binary
> addresses are EQUAL
> Dec 13 11:23:09 test64 /usr/sbin/opensips[6063]: Variable saved Binary to
> string addresses are DIFFERENT
>
> Where am I wrong? what is incorrect?
>
>
>
>
> --
> Sent from: http://opensips-open-sip-server.1449251.n2.nabble.com/OpenSIPS-Users-f1449235.html
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
More information about the Users
mailing list