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:
PipoCanaja
2020-04-10 13:22:26 +02:00
committed by GitHub
parent 07d4da21ca
commit ad1c7d0e19
7 changed files with 2117 additions and 903 deletions

View File

@@ -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