diff --git a/Info/CDP.pm b/Info/CDP.pm index 6a7706cf..67369aab 100644 --- a/Info/CDP.pm +++ b/Info/CDP.pm @@ -59,7 +59,7 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/; %FUNCS = ( 'c_index' => 'cdpCacheIfIndex', 'c_proto' => 'cdpCacheAddressType', - 'c_ip' => 'cdpCacheAddress', + 'c_addr' => 'cdpCacheAddress', 'c_ver' => 'cdpCacheVersion', 'c_id' => 'cdpCacheDeviceId', 'c_port' => 'cdpCacheDevicePort', @@ -149,6 +149,26 @@ sub c_if { return \%c_if; } +sub c_ip { + my $cdp = shift; + my $partial = shift; + + my $c_addr = $cdp->c_addr($partial) || {}; + my $c_proto = $cdp->c_proto($partial) || {}; + + my %c_ip; + foreach my $key (keys %$c_addr) { + my $addr = $c_addr->{$key}; + my $proto = $c_proto->{$key}; + next unless defined $addr; + next unless (defined $proto and $proto eq 'ip'); + + my $ip = join('.',unpack('C4',$addr)); + $c_ip{$key} = $ip; + } + return \%c_ip; +} + 1; __END__ @@ -356,7 +376,13 @@ See c_if() entry. =item $cdp->c_ip() -Returns remote IP address +Returns remote IPV4 address only + +(B) + +=item $cdp->c_addr() + +Returns remote address (B)