#261 EIGRP Peer Neighbor Formatting / Munge
This commit is contained in:
4
Changes
4
Changes
@@ -7,6 +7,10 @@ Version 3.61
|
||||
IP-MIB::ipAddressTable if the deprecated IP-MIB::ipAddrTable doesn't
|
||||
return results
|
||||
|
||||
[BUG FIXES]
|
||||
|
||||
* #261 EIGRP Peer Neighbor Formatting / Munge
|
||||
|
||||
Version 3.60 (2018-05-06)
|
||||
|
||||
[ENHANCEMENTS]
|
||||
|
||||
@@ -97,22 +97,18 @@ $VERSION = '3.60';
|
||||
%SNMP::Info::LLDP::FUNCS,
|
||||
%SNMP::Info::CiscoVTP::FUNCS,
|
||||
|
||||
# EIGRP
|
||||
'eigrp_peers' => 'cEigrpPeerAddr',
|
||||
# CISCO-EIGRP-MIB::cEigrpPeerTable
|
||||
'c_eigrp_peer_types' => 'cEigrpPeerAddrType',
|
||||
'c_eigrp_peers' => 'cEigrpPeerAddr',
|
||||
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
%SNMP::Info::Layer3::MUNGE,
|
||||
%SNMP::Info::CiscoStpExtensions::MUNGE,
|
||||
%SNMP::Info::CiscoPower::MUNGE,
|
||||
%SNMP::Info::CiscoConfig::MUNGE,
|
||||
%SNMP::Info::CiscoQOS::MUNGE,
|
||||
%SNMP::Info::CiscoRTT::MUNGE,
|
||||
%SNMP::Info::CiscoStats::MUNGE,
|
||||
%SNMP::Info::CDP::MUNGE,
|
||||
%SNMP::Info::LLDP::MUNGE,
|
||||
%SNMP::Info::CiscoVTP::MUNGE,
|
||||
'eigrp_peers' => \&SNMP::Info::munge_ip,
|
||||
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::CiscoStpExtensions::MUNGE,
|
||||
%SNMP::Info::CiscoPower::MUNGE, %SNMP::Info::CiscoConfig::MUNGE,
|
||||
%SNMP::Info::CiscoQOS::MUNGE, %SNMP::Info::CiscoRTT::MUNGE,
|
||||
%SNMP::Info::CiscoStats::MUNGE, %SNMP::Info::CDP::MUNGE,
|
||||
%SNMP::Info::LLDP::MUNGE, %SNMP::Info::CiscoVTP::MUNGE,
|
||||
);
|
||||
|
||||
sub i_vlan {
|
||||
@@ -132,6 +128,7 @@ sub i_vlan {
|
||||
if ( $i_descr->{$idx} =~ /\.(\d+)$/ ) {
|
||||
$i_vlan->{$idx} = $1;
|
||||
}
|
||||
|
||||
# This matches 101 in 'Ethernet0.101-802.1Q vLAN subif'
|
||||
elsif ( $i_descr->{$idx} =~ /\.(\d+)-/ ) {
|
||||
$i_vlan->{$idx} = $1;
|
||||
@@ -141,14 +138,41 @@ sub i_vlan {
|
||||
return $i_vlan;
|
||||
}
|
||||
|
||||
sub cisco_comm_indexing {
|
||||
sub cisco_comm_indexing {
|
||||
my $cisco = shift;
|
||||
|
||||
# If we get a VTP version, it's *extremely* likely that the device needs
|
||||
# community based indexing
|
||||
my $vtp = $cisco->vtp_version() || '0';
|
||||
return $vtp ? 1 : 0;
|
||||
}
|
||||
|
||||
sub eigrp_peers {
|
||||
my $cisco = shift;
|
||||
|
||||
my $peers = $cisco->c_eigrp_peers() || {};
|
||||
my $types = $cisco->c_eigrp_peer_types() || {};
|
||||
|
||||
my %eigrp_peers;
|
||||
foreach my $idx ( keys %$peers ) {
|
||||
my $type = $types->{$idx};
|
||||
next unless $type;
|
||||
my $peer = $peers->{$idx};
|
||||
next unless $peer;
|
||||
|
||||
if ( ( $type eq 'ipv4' or $type eq 'ipv6' )
|
||||
and $peer =~ /^(?:\w|\.|\:)+$/x )
|
||||
{
|
||||
$eigrp_peers{$idx} = $peer;
|
||||
}
|
||||
elsif ( $type eq 'ipv4' ) {
|
||||
$eigrp_peers{$idx} = SNMP::Info::munge_ip($peer);
|
||||
}
|
||||
next;
|
||||
}
|
||||
return \%eigrp_peers;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
|
||||
@@ -46,11 +46,13 @@ sub setup : Tests(setup) {
|
||||
'_description' => $d_string,
|
||||
|
||||
# CISCO-PRODUCTS-MIB::cisco1721
|
||||
'_id' => '.1.3.6.1.4.1.9.1.444',
|
||||
'_vtp_version' => 2,
|
||||
'_i_type' => 1,
|
||||
'_i_description' => 1,
|
||||
'store' => {
|
||||
'_id' => '.1.3.6.1.4.1.9.1.444',
|
||||
'_vtp_version' => 2,
|
||||
'_i_type' => 1,
|
||||
'_i_description' => 1,
|
||||
'_c_eigrp_peers' => 1,
|
||||
'_c_eigrp_peer_types' => 1,
|
||||
'store' => {
|
||||
'i_type' => {
|
||||
1 => 'ppp',
|
||||
2 => 'ethernetCsmacd',
|
||||
@@ -65,6 +67,20 @@ sub setup : Tests(setup) {
|
||||
4 => 'FastEthernet0.101-802.1Q vLAN subif',
|
||||
5 => 'FastEthernet0.102-802.1Q vLAN subif'
|
||||
},
|
||||
'c_eigrp_peers' => {
|
||||
'0.5.0' => '1.2.3.4',
|
||||
'0.5.1' => pack("H*", '0A141E28'),
|
||||
'0.10.1' => 'host.my.dns',
|
||||
'65536.10.2' => '::1.2.3.4',
|
||||
'65536.10.3' => 'fe80::2d0:b7ff:fe21:c6c0'
|
||||
},
|
||||
'c_eigrp_peer_types' => {
|
||||
'0.5.0' => 'ipv4',
|
||||
'0.5.1' => 'ipv4',
|
||||
'0.10.1' => 'dns',
|
||||
'65536.10.2' => 'ipv6',
|
||||
'65536.10.3' => 'ipv6',
|
||||
},
|
||||
},
|
||||
};
|
||||
$test->{info}->cache($cache_data);
|
||||
@@ -98,4 +114,24 @@ sub cisco_comm_indexing : Tests(3) {
|
||||
is($test->{info}->cisco_comm_indexing(), 0, 'Cisco community indexing off');
|
||||
}
|
||||
|
||||
sub eigrp_peers : Tests(3) {
|
||||
my $test = shift;
|
||||
|
||||
can_ok($test->{info}, 'eigrp_peers');
|
||||
|
||||
my $expected = {
|
||||
'0.5.0' => '1.2.3.4',
|
||||
'0.5.1' => '10.20.30.40',
|
||||
'65536.10.2' => '::1.2.3.4',
|
||||
'65536.10.3' => 'fe80::2d0:b7ff:fe21:c6c0'
|
||||
};
|
||||
|
||||
cmp_deeply($test->{info}->eigrp_peers(),
|
||||
$expected, q(EIGRP peers have expected values));
|
||||
|
||||
$test->{info}->clear_cache();
|
||||
cmp_deeply($test->{info}->eigrp_peers(),
|
||||
{}, q(No data data returns empty hash));
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Reference in New Issue
Block a user