[ 1780874 ] c_ip doesn't check cdpCacheAddressType
This commit is contained in:
30
Info/CDP.pm
30
Info/CDP.pm
@@ -59,7 +59,7 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
|
|||||||
%FUNCS = (
|
%FUNCS = (
|
||||||
'c_index' => 'cdpCacheIfIndex',
|
'c_index' => 'cdpCacheIfIndex',
|
||||||
'c_proto' => 'cdpCacheAddressType',
|
'c_proto' => 'cdpCacheAddressType',
|
||||||
'c_ip' => 'cdpCacheAddress',
|
'c_addr' => 'cdpCacheAddress',
|
||||||
'c_ver' => 'cdpCacheVersion',
|
'c_ver' => 'cdpCacheVersion',
|
||||||
'c_id' => 'cdpCacheDeviceId',
|
'c_id' => 'cdpCacheDeviceId',
|
||||||
'c_port' => 'cdpCacheDevicePort',
|
'c_port' => 'cdpCacheDevicePort',
|
||||||
@@ -149,6 +149,26 @@ sub c_if {
|
|||||||
return \%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;
|
1;
|
||||||
__END__
|
__END__
|
||||||
|
|
||||||
@@ -356,7 +376,13 @@ See c_if() entry.
|
|||||||
|
|
||||||
=item $cdp->c_ip()
|
=item $cdp->c_ip()
|
||||||
|
|
||||||
Returns remote IP address
|
Returns remote IPV4 address only
|
||||||
|
|
||||||
|
(B<cdpCacheAddress>)
|
||||||
|
|
||||||
|
=item $cdp->c_addr()
|
||||||
|
|
||||||
|
Returns remote address
|
||||||
|
|
||||||
(B<cdpCacheAddress>)
|
(B<cdpCacheAddress>)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user