diff --git a/html/pages/routing/bgp.inc.php b/html/pages/routing/bgp.inc.php
index 5e1dd3bfa..7a59a3e27 100644
--- a/html/pages/routing/bgp.inc.php
+++ b/html/pages/routing/bgp.inc.php
@@ -168,10 +168,17 @@ else
$graph_type = "bgp_updates";
$local_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150&&afi=ipv4&safi=unicast";
+ if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) {
+ $peer['bgpLocalAddr'] = Net_IPv6::compress($peer['bgpLocalAddr']);
+ }
$localaddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer['bgpLocalAddr'] . "";
$graph_type = "bgp_updates";
$peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150";
+ if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) {
+ $peer['bgpPeerIdentifier'] = Net_IPv6::compress($peer['bgpPeerIdentifier']);
+ }
+
$peeraddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer['bgpPeerIdentifier'] . "";
echo('
");
diff --git a/includes/discovery/bgp-peers.inc.php b/includes/discovery/bgp-peers.inc.php
index af9b931f5..b9a06ff36 100644
--- a/includes/discovery/bgp-peers.inc.php
+++ b/includes/discovery/bgp-peers.inc.php
@@ -37,6 +37,11 @@ if ($config['enable_bgp'])
list($ver, $peer) = explode(".", $peer,2);
}
list($peer_ip, $peer_as) = explode(" ", $peer);
+ if (strstr($peer_ip, ":")) {
+ $peer_ip_snmp = preg_replace("/:/", ' ', $peer_ip);
+ $peer_ip = preg_replace("/(\S+\s+\S+)\s/", '$1:', $peer_ip_snmp);
+ $peer_ip = str_replace('"','',str_replace(' ','',$peer_ip));
+ }
if ($peer && $peer_ip != "0.0.0.0")
{
diff --git a/includes/functions.php b/includes/functions.php
index ef4d92aa6..e293d80c6 100644
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -1202,20 +1202,6 @@ function first_oid_match($device, $list) {
}
}
-function ip_to_dec($ip) {
- $return = '';
- if (strstr($ip, ":")) {
- $ipv6 = explode(':', $ip);
- foreach ($ipv6 as $item) {
- $return .= hexdec($item).'.';
- }
- $return = substr($return, 0, -1);
- } else {
- $return = $ip;
- }
- return $return;
-}
-
function hex_to_ip($hex) {
$return = "";
if (filter_var($hex, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === FALSE && filter_var($hex, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE) {
diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php
index 47a2776ac..661377a80 100644
--- a/includes/polling/bgp-peers.inc.php
+++ b/includes/polling/bgp-peers.inc.php
@@ -23,7 +23,7 @@ if ($config['enable_bgp'])
}
if ($peer2 === TRUE) {
- $bgp_peer_ident = ip_to_dec($peer['bgpPeerIdentifier']);
+ $bgp_peer_ident = ipv62snmp($peer['bgpPeerIdentifier']);
if (strstr($peer['bgpPeerIdentifier'],":")) {
$ip_type = 2;
$ip_len = 16;
@@ -49,9 +49,11 @@ if ($config['enable_bgp'])
foreach ($peer_data_tmp[$ident] as $k => $v) {
if (strstr($k, "cbgpPeer2LocalAddr")) {
if ($ip_ver == 'ipv6') {
- $v = preg_replace("/ /", ":", $v);
+ $v = str_replace('"','',$v);
+ $v = rtrim($v);
+ echo "YEAH $v\n";
+ $v = preg_replace("/(\S+\s+\S+)\s/", '$1:', $v);
$v = strtolower($v);
- rtrim($v,":");
} else {
$v = hex_to_ip($v);
}
@@ -66,6 +68,7 @@ if ($config['enable_bgp'])
$peer_data = trim(`$peer_cmd`);
}
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
+ $bgpLocalAddr = str_replace('"','',str_replace(' ','',$bgpLocalAddr));
}
else
if ($device['os'] == "junos")
@@ -179,7 +182,7 @@ if ($config['enable_bgp'])
if ($debug) { echo("$afi $safi\n"); }
if ($device['os_group'] == "cisco") {
- $bgp_peer_ident = ip_to_dec($peer['bgpPeerIdentifier']);
+ $bgp_peer_ident = ipv62snmp($peer['bgpPeerIdentifier']);
if (strstr($peer['bgpPeerIdentifier'], ":")) {
$ip_type = 2;
$ip_len = 16;