Add LLDP support
This commit is contained in:
@@ -36,15 +36,19 @@ use Exporter;
|
||||
use SNMP::Info::SONMP;
|
||||
use SNMP::Info::NortelStack;
|
||||
use SNMP::Info::RapidCity;
|
||||
use SNMP::Info::LLDP;
|
||||
use SNMP::Info::Layer3;
|
||||
|
||||
@SNMP::Info::Layer2::Baystack::ISA = qw/SNMP::Info::SONMP SNMP::Info::NortelStack SNMP::Info::RapidCity SNMP::Info::Layer3 Exporter/;
|
||||
@SNMP::Info::Layer2::Baystack::ISA = qw/SNMP::Info::SONMP SNMP::Info::NortelStack
|
||||
SNMP::Info::RapidCity SNMP::Info::LLDP
|
||||
SNMP::Info::Layer3 Exporter/;
|
||||
@SNMP::Info::Layer2::Baystack::EXPORT_OK = qw//;
|
||||
|
||||
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::Layer3::MIBS,
|
||||
%SNMP::Info::LLDP::MIBS,
|
||||
%SNMP::Info::RapidCity::MIBS,
|
||||
%SNMP::Info::NortelStack::MIBS,
|
||||
%SNMP::Info::SONMP::MIBS,
|
||||
@@ -52,6 +56,7 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::Layer3::GLOBALS,
|
||||
%SNMP::Info::LLDP::GLOBALS,
|
||||
%SNMP::Info::RapidCity::GLOBALS,
|
||||
%SNMP::Info::NortelStack::GLOBALS,
|
||||
%SNMP::Info::SONMP::GLOBALS,
|
||||
@@ -59,6 +64,7 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::Layer3::FUNCS,
|
||||
%SNMP::Info::LLDP::FUNCS,
|
||||
%SNMP::Info::RapidCity::FUNCS,
|
||||
%SNMP::Info::NortelStack::FUNCS,
|
||||
%SNMP::Info::SONMP::FUNCS,
|
||||
@@ -71,6 +77,7 @@ $SNMP::Info::SPEED_MAP{2_000_000_000} = '1.0 Gbps';
|
||||
|
||||
%MUNGE = (
|
||||
%SNMP::Info::Layer3::MUNGE,
|
||||
%SNMP::Info::LLDP::MUNGE,
|
||||
%SNMP::Info::RapidCity::MUNGE,
|
||||
%SNMP::Info::NortelStack::MUNGE,
|
||||
%SNMP::Info::SONMP::MUNGE,
|
||||
@@ -217,6 +224,134 @@ sub index_factor {
|
||||
return $index_factor;
|
||||
}
|
||||
|
||||
# Use SONMP and/or LLDP
|
||||
|
||||
sub hasCDP {
|
||||
my $baystack = shift;
|
||||
|
||||
return $baystack->hasLLDP() || $baystack->SUPER::hasCDP();
|
||||
}
|
||||
|
||||
sub c_ip {
|
||||
my $baystack = shift;
|
||||
my $partial = shift;
|
||||
|
||||
my $cdp = $baystack->SUPER::c_ip($partial) || {};
|
||||
my $lldp = $baystack->lldp_ip($partial) || {};
|
||||
|
||||
my %c_ip;
|
||||
foreach my $iid (keys %$cdp){
|
||||
my $ip = $cdp->{$iid};
|
||||
next unless defined $ip;
|
||||
|
||||
$c_ip{$iid} = $ip;
|
||||
}
|
||||
|
||||
foreach my $iid (keys %$lldp){
|
||||
my $ip = $lldp->{$iid};
|
||||
next unless defined $ip;
|
||||
|
||||
$c_ip{$iid} = $ip;
|
||||
}
|
||||
return \%c_ip;
|
||||
}
|
||||
|
||||
sub c_if {
|
||||
my $baystack = shift;
|
||||
my $partial = shift;
|
||||
|
||||
my $lldp = $baystack->lldp_if($partial) || {};;
|
||||
my $cdp = $baystack->SUPER::c_if($partial) || {};
|
||||
|
||||
my %c_if;
|
||||
foreach my $iid (keys %$cdp){
|
||||
my $if = $cdp->{$iid};
|
||||
next unless defined $if;
|
||||
|
||||
$c_if{$iid} = $if;
|
||||
}
|
||||
|
||||
foreach my $iid (keys %$lldp){
|
||||
my $if = $lldp->{$iid};
|
||||
next unless defined $if;
|
||||
|
||||
$c_if{$iid} = $if;
|
||||
}
|
||||
return \%c_if;
|
||||
}
|
||||
|
||||
sub c_port {
|
||||
my $baystack = shift;
|
||||
my $partial = shift;
|
||||
|
||||
my $lldp = $baystack->lldp_port($partial) || {};
|
||||
my $cdp = $baystack->SUPER::c_port($partial) || {};
|
||||
|
||||
my %c_port;
|
||||
foreach my $iid (keys %$cdp){
|
||||
my $port = $cdp->{$iid};
|
||||
next unless defined $port;
|
||||
|
||||
$c_port{$iid} = $port;
|
||||
}
|
||||
|
||||
foreach my $iid (keys %$lldp){
|
||||
my $port = $lldp->{$iid};
|
||||
next unless defined $port;
|
||||
|
||||
$c_port{$iid} = $port;
|
||||
}
|
||||
return \%c_port;
|
||||
}
|
||||
|
||||
sub c_id {
|
||||
my $baystack = shift;
|
||||
my $partial = shift;
|
||||
|
||||
my $lldp = $baystack->lldp_id($partial) || {};
|
||||
my $cdp = $baystack->SUPER::c_id($partial) || {};
|
||||
|
||||
my %c_id;
|
||||
foreach my $iid (keys %$cdp){
|
||||
my $id = $cdp->{$iid};
|
||||
next unless defined $id;
|
||||
|
||||
$c_id{$iid} = $id;
|
||||
}
|
||||
|
||||
foreach my $iid (keys %$lldp){
|
||||
my $id = $lldp->{$iid};
|
||||
next unless defined $id;
|
||||
|
||||
$c_id{$iid} = $id;
|
||||
}
|
||||
return \%c_id;
|
||||
}
|
||||
|
||||
sub c_platform {
|
||||
my $baystack = shift;
|
||||
my $partial = shift;
|
||||
|
||||
my $lldp = $baystack->lldp_rem_sysdesc($partial) || {};
|
||||
my $cdp = $baystack->SUPER::c_platform($partial) || {};
|
||||
|
||||
my %c_platform;
|
||||
foreach my $iid (keys %$cdp){
|
||||
my $platform = $cdp->{$iid};
|
||||
next unless defined $platform;
|
||||
|
||||
$c_platform{$iid} = $platform;
|
||||
}
|
||||
|
||||
foreach my $iid (keys %$lldp){
|
||||
my $platform = $lldp->{$iid};
|
||||
next unless defined $platform;
|
||||
|
||||
$c_platform{$iid} = $platform;
|
||||
}
|
||||
return \%c_platform;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
@@ -265,6 +400,8 @@ my $baystack = new SNMP::Info::Layer2::Baystack(...);
|
||||
|
||||
=item SNMP::Info::RapidCity
|
||||
|
||||
=item SNMP::Info::LLDP
|
||||
|
||||
=item SNMP::Info::Layer3
|
||||
|
||||
=back
|
||||
@@ -283,6 +420,8 @@ See L<SNMP::Info::NortelStack/"Required MIBs"> for its MIB requirements.
|
||||
|
||||
See L<SNMP::Info::RapidCity/"Required MIBs"> for its MIB requirements.
|
||||
|
||||
See L<SNMP::Info::LLDP/"Required MIBs"> for its MIB requirements.
|
||||
|
||||
See L<SNMP::Info::Layer3/"Required MIBs"> for its MIB requirements.
|
||||
|
||||
=head1 GLOBALS
|
||||
@@ -345,6 +484,10 @@ See L<SNMP::Info::NortelStack/"GLOBALS"> for details.
|
||||
|
||||
See L<SNMP::Info::RapidCity/"GLOBALS"> for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::LLDP
|
||||
|
||||
See documentation in L<SNMP::Info::LLDP/"GLOBALS"> for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Layer3
|
||||
|
||||
See L<SNMP::Info::Layer3/"GLOBALS"> for details.
|
||||
@@ -386,6 +529,53 @@ Crosses ifName with ifAlias and returns the human set port name if exists.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Topology information
|
||||
|
||||
Based upon the software version devices may support SynOptics Network
|
||||
Management Protocol (SONMP) and Link Layer Discovery Protocol (LLDP). These
|
||||
methods will query both and return the combination of all information. As a
|
||||
result, there may be identical topology information returned from the two
|
||||
protocols causing duplicate entries. It is the calling program's
|
||||
responsibility to identify any duplicate entries and de-duplicate if necessary.
|
||||
|
||||
=over
|
||||
|
||||
=item $baystack->hasCDP()
|
||||
|
||||
Returns true if the device is running either SONMP or LLDP.
|
||||
|
||||
=item $baystack->c_if()
|
||||
|
||||
Returns reference to hash. Key: iid Value: local device port (interfaces)
|
||||
|
||||
=item $baystack->c_ip()
|
||||
|
||||
Returns reference to hash. Key: iid Value: remote IPv4 address
|
||||
|
||||
If multiple entries exist with the same local port, c_if(), with the same IPv4
|
||||
address, c_ip(), it may be a duplicate entry.
|
||||
|
||||
If multiple entries exist with the same local port, c_if(), with different IPv4
|
||||
addresses, c_ip(), there is either a non-SONMP/LLDP device in between two or
|
||||
more devices or multiple devices which are not directly connected.
|
||||
|
||||
Use the data from the Layer2 Topology Table below to dig deeper.
|
||||
|
||||
=item $baystack->c_port()
|
||||
|
||||
Returns reference to hash. Key: iid Value: remote port (interfaces)
|
||||
|
||||
=item $baystack->c_id()
|
||||
|
||||
Returns reference to hash. Key: iid Value: string value used to identify the
|
||||
chassis component associated with the remote system.
|
||||
|
||||
=item $baystack->c_platform()
|
||||
|
||||
Returns reference to hash. Key: iid Value: Remote Device Type
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::SONMP
|
||||
|
||||
See L<SNMP::Info::SONMP/"TABLE METHODS"> for details.
|
||||
@@ -398,6 +588,10 @@ See L<SNMP::Info::NortelStack/"TABLE METHODS"> for details.
|
||||
|
||||
See L<SNMP::Info::RapidCity/"TABLE METHODS"> for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::LLDP
|
||||
|
||||
See documentation in L<SNMP::Info::LLDP/"TABLE METHODS"> for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Layer3
|
||||
|
||||
See L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
|
||||
|
||||
Reference in New Issue
Block a user