DHCPv6: Fix sorting of IPv6 static mappings (#4513)

* DHCPv6: Fix sorting of IPv6 static mappings

The ipcmp() function doesn't seem to return a correct result for IPv6 addresses. That's why the DHCPv6 static mappings are shown in the order they were added. This commit introduces ip6cmp() function and fixes sorting of IPv6 static mappings.

* DHCPv6: Fix sorting of IPv6 static mappings

Move ip6cmp() approach to ipcmp(), use single function for both IPv4 and IPv6.

* DHCPv6: Fix sorting of IPv6 static mappings

Oops, fixed a typo in ipcmp()
This commit is contained in:
vnxme 2020-12-10 15:09:24 +03:00 committed by GitHub
parent 854942b4e0
commit f8b7f92baf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1190,9 +1190,11 @@ function check_subnets_overlap($subnet1, $bits1, $subnet2, $bits2)
/* compare two IP addresses */
function ipcmp($a, $b)
{
if (ip_less_than($a, $b)) {
$na = inet_pton($a);
$nb = inet_pton($b);
if ($na < $nb) {
return -1;
} elseif (ip_greater_than($a, $b)) {
} elseif ($na > $nb) {
return 1;
} else {
return 0;