[OpenSIPS-Users] String to IP transformations

vasilevalex alexei.vasilyev at gmail.com
Thu Dec 13 06:34:36 EST 2018


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



More information about the Users mailing list