Changeset View
Changeset View
Standalone View
Standalone View
src/app/Utils.php
Show First 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | public static function ip6Broadcast($net, $prefix) | ||||
$lastAddrHex = substr_replace($lastAddrHex, $new, $pos, 1); | $lastAddrHex = substr_replace($lastAddrHex, $new, $pos, 1); | ||||
// We processed one nibble, move to previous position | // We processed one nibble, move to previous position | ||||
$flexbits -= 4; | $flexbits -= 4; | ||||
$pos -= 1; | $pos -= 1; | ||||
} | } | ||||
// Convert the hexadecimal string to a binary string | // Convert the hexadecimal string to a binary string | ||||
# Using pack() here | $lastaddrbin = hex2bin($lastAddrHex); | ||||
# Newer PHP version can use hex2bin() | |||||
$lastaddrbin = pack('H*', $lastAddrHex); | |||||
// And create an IPv6 address from the binary string | // And create an IPv6 address from the binary string | ||||
$lastaddrstr = inet_ntop($lastaddrbin); | $lastaddrstr = inet_ntop($lastaddrbin); | ||||
return $lastaddrstr; | return $lastaddrstr; | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 193 Lines • Show Last 20 Lines |