IPv6 related updated to Info::LLDP
- LLDP::lldp_addr() may now also return neighbor IPv6 addresses - Make more clear in POD that lldp_addr() will not return all management addresses reported by neighbor, it's a kind of roulette - Add LLDP::lldp_ipv6() and LLDP::lldp_mac() methods for remote management addresses of types IPv6 and MAC, respectively
This commit is contained in:
@@ -5,6 +5,9 @@ version 3.29 ()
|
|||||||
[ENHANCEMENTS]
|
[ENHANCEMENTS]
|
||||||
|
|
||||||
* Add IPv6::ipv6_addr() method to map IPv6 interface address indexes to actual addresses
|
* Add IPv6::ipv6_addr() method to map IPv6 interface address indexes to actual addresses
|
||||||
|
* Add support for (remote) IPv6 addresses to LLDP::lldp_addr()
|
||||||
|
* Add LLDP::lldp_ipv6() and LLDP::lldp_mac() so that remote management
|
||||||
|
addresses of specific types can be requested
|
||||||
|
|
||||||
version 3.28 (2015-06-18)
|
version 3.28 (2015-06-18)
|
||||||
|
|
||||||
|
|||||||
58
Info/LLDP.pm
58
Info/LLDP.pm
@@ -149,6 +149,38 @@ sub lldp_ip {
|
|||||||
return \%lldp_ip;
|
return \%lldp_ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub lldp_ipv6 {
|
||||||
|
my $lldp = shift;
|
||||||
|
my $partial = shift;
|
||||||
|
|
||||||
|
my $rman_addr = $lldp->lldp_rman_addr($partial) || {};
|
||||||
|
|
||||||
|
my %lldp_ipv6;
|
||||||
|
foreach my $key ( keys %$rman_addr ) {
|
||||||
|
my ( $index, $proto, $addr ) = _lldp_addr_index($key);
|
||||||
|
next unless defined $index;
|
||||||
|
next unless $proto == 2;
|
||||||
|
$lldp_ipv6{$index} = $addr;
|
||||||
|
}
|
||||||
|
return \%lldp_ipv6;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub lldp_mac {
|
||||||
|
my $lldp = shift;
|
||||||
|
my $partial = shift;
|
||||||
|
|
||||||
|
my $rman_addr = $lldp->lldp_rman_addr($partial) || {};
|
||||||
|
|
||||||
|
my %lldp_ipv6;
|
||||||
|
foreach my $key ( keys %$rman_addr ) {
|
||||||
|
my ( $index, $proto, $addr ) = _lldp_addr_index($key);
|
||||||
|
next unless defined $index;
|
||||||
|
next unless $proto == 6;
|
||||||
|
$lldp_ipv6{$index} = $addr;
|
||||||
|
}
|
||||||
|
return \%lldp_ipv6;
|
||||||
|
}
|
||||||
|
|
||||||
sub lldp_addr {
|
sub lldp_addr {
|
||||||
my $lldp = shift;
|
my $lldp = shift;
|
||||||
my $partial = shift;
|
my $partial = shift;
|
||||||
@@ -323,13 +355,19 @@ sub _lldp_addr_index {
|
|||||||
return ( $index, $proto, join( '.', @oids ) );
|
return ( $index, $proto, join( '.', @oids ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# IPv6
|
||||||
|
elsif ( $proto == 2 ) {
|
||||||
|
return ( $index, $proto,
|
||||||
|
join(':', unpack('(H4)*', pack('C*', @oids)) ) );
|
||||||
|
}
|
||||||
|
|
||||||
# MAC
|
# MAC
|
||||||
elsif ( $proto == 6 ) {
|
elsif ( $proto == 6 ) {
|
||||||
return ( $index, $proto,
|
return ( $index, $proto,
|
||||||
join( ':', map { sprintf "%02x", $_ } @oids ) );
|
join( ':', map { sprintf "%02x", $_ } @oids ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO - Need to handle other protocols, i.e. IPv6
|
# TODO - Other protocols may be used as well; implement when needed?
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -495,10 +533,24 @@ if unable defaults to (C<lldpRemLocalPortNum>).
|
|||||||
Returns remote IPv4 address. Returns for all other address types, use
|
Returns remote IPv4 address. Returns for all other address types, use
|
||||||
lldp_addr if you want any return address type.
|
lldp_addr if you want any return address type.
|
||||||
|
|
||||||
|
=item $lldp->lldp_ipv6()
|
||||||
|
|
||||||
|
Returns remote IPv6 address, if known. Returns for all other address types,
|
||||||
|
use lldp_addr if you don't care about return address type.
|
||||||
|
|
||||||
|
=item $lldp->lldp_mac()
|
||||||
|
|
||||||
|
Returns remote (management) MAC address, if known. Returns for all other
|
||||||
|
address types, use lldp_addr if you don't care about return address type.
|
||||||
|
|
||||||
=item $lldp->lldp_addr()
|
=item $lldp->lldp_addr()
|
||||||
|
|
||||||
Returns remote address. Type may be any IANA Address Family Number.
|
Returns remote address. Type may be any IANA Address Family Number.
|
||||||
Currently only returns IPv4 or MAC addresses.
|
Currently only returns IPv4, IPv6 or MAC addresses. If the remote device
|
||||||
|
returns more than one address type, this method will give only one. Which one
|
||||||
|
is returned is decided by chance, phase of the moon and Perl hash ordering.
|
||||||
|
|
||||||
|
Use lldp_mac, lldp_ip or lldp_ipv6 if you want a specific address type.
|
||||||
|
|
||||||
=item $lldp->lldp_port()
|
=item $lldp->lldp_port()
|
||||||
|
|
||||||
@@ -530,7 +582,7 @@ the remote system.
|
|||||||
|
|
||||||
=item $lldp->lldp_rem_id()
|
=item $lldp->lldp_rem_id()
|
||||||
|
|
||||||
Returns the string value used to identify the chassis component associated
|
Returns the string value used to identify the chassis component associated
|
||||||
with the remote system.
|
with the remote system.
|
||||||
|
|
||||||
(C<lldpRemChassisId>)
|
(C<lldpRemChassisId>)
|
||||||
|
|||||||
Reference in New Issue
Block a user