mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
IPv6 support for BGP peers in VRP devices (#11243)
* ipv6 support for BGP routes in VRP devices * reverse bgpPeers array to allow VRF aware BGP * codeclimate * codeclimate * codeclimate, finally * Split VRP out of bgp-peers for readabilty * Split VRP out of bgp-peers for readabilty * tests * CodeClimate * improve function description * improve function description * v6data * rebase * space * ipv6 support for BGP routes in VRP devices * reverse bgpPeers array to allow VRF aware BGP * codeclimate * codeclimate * codeclimate, finally * Split VRP out of bgp-peers for readabilty * Split VRP out of bgp-peers for readabilty * tests * CodeClimate * improve function description * improve function description * v6data * rebase * space * fixed corner case
This commit is contained in:
@@ -73,6 +73,30 @@ abstract class IP
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a decimal space-separated string to an IP address. For example:
|
||||
* "192 168 1 154" -> 192.168.1.254
|
||||
* "32 01 72 96 72 96 00 00 00 00 00 00 00 00 136 136" -> 2001:4860:4860::8888
|
||||
* @param string $snmpOid
|
||||
* @param bool $ignore_errors Do not throw exceptions, instead return null on error.
|
||||
* @return IP|null
|
||||
* @throws InvalidIpException
|
||||
*/
|
||||
public static function fromSnmpString($snmpOid, $ignore_errors = false)
|
||||
{
|
||||
$snmpOid = str_replace(['.', '"'], ' ', $snmpOid);
|
||||
$hex = implode(
|
||||
":",
|
||||
array_map(
|
||||
function ($dec) {
|
||||
return sprintf('%02x', $dec);
|
||||
},
|
||||
explode(" ", (string)$snmpOid)
|
||||
)
|
||||
);
|
||||
return IP::fromHexString($hex, $ignore_errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an IP or IP Network into an IP object. Works with IPv6 and IPv4 addresses.
|
||||
* @param string $ip
|
||||
|
Reference in New Issue
Block a user