diff --git a/ChangeLog b/ChangeLog index c3ab1a77..1c48599b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ SNMP::Info - Friendly OO-style interface to Network devices using SNMP. +version 3.29 () + + [ENHANCEMENTS] + + * Add IPv6::ipv6_addr() method to map IPv6 interface address indexes to actual addresses + version 3.28 (2015-06-18) [ENHANCEMENTS] diff --git a/Info/IPv6.pm b/Info/IPv6.pm index 0a0528a2..e7d8cf4c 100644 --- a/Info/IPv6.pm +++ b/Info/IPv6.pm @@ -321,6 +321,29 @@ sub ipv6_addr_prefix { return $return; } +sub ipv6_addr { + my $info = shift; + my $return; + my $indexes = $info->ipv6_index(); + foreach my $row (keys %$indexes) { + my @parts = split(/\./, $row); + my $is_valid = 0; + if (scalar @parts == 18) { + my $addrtype = shift @parts; + $is_valid = 1; + } elsif (scalar @parts == 17) { + $is_valid = 1; + } + my $addrsize = shift @parts; # First element now is addrsize, should be 16 + if ($is_valid && $addrsize == 16) { + $return->{$row} = join(':', unpack('(H4)*', pack('C*', @parts))); + } else { + warn sprintf("%s: unable to decode table index to IPv6 address. Raw data is [%s].\n", &_my_sub_name, $row); + } + } + return $return; +} + sub _method_used { my $info = shift; my $return = 'none of the MIBs'; @@ -459,6 +482,10 @@ Maps an IPv6 prefix with its origin (manual, well-known, dhcp, etc.) Maps IPv6 addresses with their prefixes +=item $info->ipv6_addr() + +Maps a table instance to an IPv6 address + =back =head2 Internet Address Translation Table