Revert "Remove snmp2ipv6 (#12683)" (#12725)

This reverts commit f5f72dd398.
This commit is contained in:
Jellyfrog
2021-04-08 14:57:17 +02:00
committed by GitHub
parent 04407db85b
commit c147be4505
22 changed files with 643 additions and 621 deletions

View File

@@ -731,6 +731,24 @@ function match_network($nets, $ip, $first = false)
return $return;
}
// FIXME port to LibreNMS\Util\IPv6 class
function snmp2ipv6($ipv6_snmp)
{
// Workaround stupid Microsoft bug in Windows 2008 -- this is fixed length!
// < fenestro> "because whoever implemented this mib for Microsoft was ignorant of RFC 2578 section 7.7 (2)"
$ipv6 = array_slice(explode('.', $ipv6_snmp), -16);
$ipv6_2 = [];
for ($i = 0; $i <= 15; $i++) {
$ipv6[$i] = zeropad(dechex($ipv6[$i]));
}
for ($i = 0; $i <= 15; $i += 2) {
$ipv6_2[] = $ipv6[$i] . $ipv6[$i + 1];
}
return implode(':', $ipv6_2);
}
function get_astext($asn)
{
global $cache;