From aa58a2ba56e0358abc0abd2c8da16a7ac82a9568 Mon Sep 17 00:00:00 2001 From: Eric Miller <> Date: Tue, 15 Jul 2008 02:15:59 +0000 Subject: [PATCH] - Document munge_power() - Move munge_caps() and munge_null() to Info.pm --- Info/CDP.pm | 76 +++++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/Info/CDP.pm b/Info/CDP.pm index cd09f138..689dcad9 100644 --- a/Info/CDP.pm +++ b/Info/CDP.pm @@ -72,33 +72,17 @@ $VERSION = '1.09'; ); %MUNGE = ( - 'c_capabilities' => \&munge_caps, - 'c_platform' => \&munge_null, - 'c_domain' => \&munge_null, - 'c_port' => \&munge_null, - 'c_id' => \&munge_null, - 'c_ver' => \&munge_null, + 'c_capabilities' => \&SNMP::Info::munge_caps, + 'c_platform' => \&SNMP::Info::munge_null, + 'c_domain' => \&SNMP::Info::munge_null, + 'c_port' => \&SNMP::Info::munge_null, + 'c_id' => \&SNMP::Info::munge_null, + 'c_ver' => \&SNMP::Info::munge_null, 'c_ip' => \&SNMP::Info::munge_ip, 'c_power' => \&munge_power, ); -# munge_null() - removes nulls (\0) -sub munge_null { - my $text = shift || return; - - $text =~ s/\0//g; - return $text; -} - -sub munge_caps { - my $caps = shift; - return unless defined $caps; - - my $bits = substr(unpack("B*",$caps),-7); - return $bits; -} - sub munge_power { my $power = shift; my $decimal = substr($power, -3); @@ -218,7 +202,8 @@ CDP is a Layer 2 protocol that supplies topology information of devices that also speak CDP, mostly switches and routers. CDP is implemented in Cisco and some HP devices. -Create or use a device subclass that inherits this class. Do not use directly. +Create or use a device subclass that inherits this class. Do not use +directly. Each device implements a subset of the global and cache entries. Check the return value to see if that data is held by the device. @@ -251,8 +236,8 @@ Accounts for SNMP version 1 devices which may have CDP but not cdp_run() =item $cdp->cdp_run() -Is CDP enabled on this device? Note that a lot of Cisco devices that implement -CDP don't implement this value. @#%$! +Is CDP enabled on this device? Note that a lot of Cisco devices that +implement CDP don't implement this value. @#%$! (C) @@ -302,17 +287,23 @@ From Lc_index(), So if it isn't around, -we fake it. +Note that a lot devices don't implement $cdp->c_index(), So if it isn't +around, we fake it. -In order to map the cdp table entry back to the interfaces() entry, we truncate -the last number off of it : +In order to map the cdp table entry back to the interfaces() entry, we +truncate the last number off of it : # it exists, yay. my $c_index = $device->c_index(); @@ -422,6 +413,23 @@ Returns the remote interface native VLAN. (C) +=item $cdp->c_power() + +Returns the amount of power consumed by remote device in milliwatts munged +for decimal placement. + +(C) + +=back + +=head1 Data Munging Callback Subroutines + +=over + +=item munge_power() + +Inserts a decimal at the proper location. + =back =cut