1SNMP::Info::CDP(3)    User Contributed Perl Documentation   SNMP::Info::CDP(3)
2
3
4

NAME

6       SNMP::Info::CDP - SNMP Interface to Cisco Discovery Protocol (CDP)
7       using SNMP
8

AUTHOR

10       Max Baker
11

SYNOPSIS

13        my $cdp = new SNMP::Info (
14                                    AutoSpecify => 1,
15                                    Debug       => 1,
16                                    DestHost    => 'router',
17                                    Community   => 'public',
18                                    Version     => 2
19                                  );
20
21        my $class = $cdp->class();
22        print " Using device sub class : $class\n";
23
24        $hascdp   = $cdp->hasCDP() ? 'yes' : 'no';
25
26        # Print out a map of device ports with CDP neighbors:
27        my $interfaces   = $cdp->interfaces();
28        my $cdp_if       = $cdp->cdp_if();
29        my $cdp_ip       = $cdp->cdp_ip();
30        my $cdp_port     = $cdp->cdp_port();
31
32        foreach my $cdp_key (keys %$cdp_ip){
33           my $iid           = $cdp_if->{$cdp_key};
34           my $port          = $interfaces->{$iid};
35           my $neighbor      = $cdp_ip->{$cdp_key};
36           my $neighbor_port = $cdp_port->{$cdp_key};
37           print "Port : $port connected to $neighbor / $neighbor_port\n";
38        }
39

DESCRIPTION

41       SNMP::Info::CDP is a subclass of SNMP::Info that provides an object
42       oriented interface to CDP information through SNMP.
43
44       CDP is a Layer 2 protocol that supplies topology information of devices
45       that also speak CDP, mostly switches and routers.  CDP is implemented
46       by Cisco and several other vendors.
47
48       Create or use a device subclass that inherits this class.  Do not use
49       directly.
50
51       Each device implements a subset of the global and cache entries.  Check
52       the return value to see if that data is held by the device.
53
54   Inherited Classes
55       None.
56
57   Required MIBs
58       CISCO-CDP-MIB
59

GLOBALS

61       These are methods that return scalar values from SNMP
62
63       $cdp->hasCDP()
64           Is CDP is active in this device?
65
66           Accounts for SNMP version 1 devices which may have CDP but not
67           cdp_run()
68
69       $cdp->cdp_run()
70           Is CDP enabled on this device?  Note that a lot of Cisco devices
71           that implement CDP don't implement this value. @#%$!
72
73           ("cdpGlobalRun")
74
75       $cdp->cdp_interval()
76           Interval in seconds at which CDP messages are generated.
77
78           ("cdpGlobalMessageInterval")
79
80       $cdp->cdp_holdtime()
81           Time in seconds that CDP messages are kept.
82
83           ("cdpGlobalHoldTime")
84
85       $cdp->cdp_gid()
86           Returns CDP device ID.
87
88           This is the device id broadcast via CDP to other devices, and is
89           what is retrieved from remote devices with $cdp->id().
90
91           ("cdpGlobalDeviceId")
92

TABLE METHODS

94       These are methods that return tables of information in the form of a
95       reference to a hash.
96
97   CDP CACHE ENTRIES
98       $cdp->cdp_capabilities()
99           Returns Device Functional Capabilities.  Results are munged into an
100           ascii binary string, MSB.  Each digit represents a bit from the
101           table below from the CDP Capabilities Mapping to Smartport Type
102           table within the Cisco Small Business 200 Series Smart Switch
103           Administration Guide,
104           <http://www.cisco.com/c/en/us/support/switches/small-business-200-series-smart-switches/products-maintenance-guides-list.html>:
105
106           (Bit) - Description
107
108           (0x400) - Two-Port MAC Relay.
109           (0x200) - CAST Phone Port / CVTA / Supports-STP-Dispute depending
110           upon platform.
111           (0x100) - Remotely-Managed Device.
112           (0x80)  - VoIP Phone.
113           (0x40)  - Provides level 1 functionality.
114           (0x20)  - The bridge or switch does not forward IGMP Report packets
115           on non router ports.
116           (0x10)  - Sends and receives packets for at least one network layer
117           protocol. If the device is routing the protocol, this bit should
118           not be set.
119           (0x08)  - Performs level 2 switching. The difference between this
120           bit and bit 0x02 is that a switch does not run the Spanning-Tree
121           Protocol. This device is assumed to be deployed in a physical loop-
122           free topology.
123           (0x04)  - Performs level 2 source-route bridging. A source-route
124           bridge would set both this bit and bit 0x02.
125           (0x02)  - Performs level 2 transparent bridging.
126           (0x01)  - Performs level 3 routing for at least one network layer
127           protocol.
128
129           Thanks to Martin Lorensen for a pointer to the original information
130           and CPAN user Alex for updates.
131
132           ("cdpCacheCapabilities")
133
134       $cdp->cdp_domain()
135           Returns remote VTP Management Domain as defined in
136           "CISCO-VTP-MIB::managementDomainName"
137
138           ("cdpCacheVTPMgmtDomain")
139
140       $cdp->cdp_duplex()
141           Returns the port duplex status from remote devices.
142
143           ("cdpCacheDuplex")
144
145       $cdp->cdp_id()
146           Returns remote device id string
147
148           ("cdpCacheDeviceId")
149
150       $cdp->cdp_if()
151           Returns the mapping to the SNMP Interface Table.
152
153           Note that a lot devices don't implement $cdp->cdp_index(),  So if
154           it isn't around, we fake it.
155
156           In order to map the cdp table entry back to the interfaces() entry,
157           we truncate the last number off of it :
158
159             # it exists, yay.
160             my $cdp_index     = $device->cdp_index();
161             return $cdp_index if defined $cdp_index;
162
163             # if not, let's fake it
164             my $cdp_ip       = $device->cdp_ip();
165
166             my %cdp_if
167             foreach my $key (keys %$cdp_ip){
168                 $iid = $key;
169                 ## Truncate off .1 from cdp response
170                 $iid =~ s/\.\d+$//;
171                 $cdp_if{$key} = $iid;
172             }
173
174             return \%cdp_if;
175
176       $cdp->cdp_index()
177           Returns the mapping to the SNMP2 Interface table for CDP Cache
178           Entries.
179
180           Most devices don't implement this, so you probably want to use
181           $cdp->cdp_if() instead.
182
183           See cdp_if() entry.
184
185           ("cdpCacheIfIndex")
186
187       $cdp->cdp_ip()
188           If $cdp->cdp_proto() is supported, returns remote IPV4 address
189           only.  Otherwise it will return all addresses.
190
191           ("cdpCacheAddress")
192
193       $cdp->cdp_addr()
194           Returns remote address
195
196           ("cdpCacheAddress")
197
198       $cdp->cdp_platform()
199           Returns remote platform id
200
201           ("cdpCachePlatform")
202
203       $cdp->cdp_port()
204           Returns remote Port-ID. Most of the time this is a string with the
205           port name, but this is not guaranteed to be so.
206
207           ("cdpCacheDevicePort")
208
209       $cdp->cdp_proto()
210           Returns remote address type received.  Usually IP.
211
212           ("cdpCacheAddressType")
213
214       $cdp->cdp_ver()
215           Returns remote hardware version
216
217           ("cdpCacheVersion")
218
219       $cdp->cdp_vlan()
220           Returns the remote interface native VLAN.
221
222           ("cdpCacheNativeVLAN")
223
224       $cdp->cdp_power()
225           Returns the amount of power consumed by remote device in milliwatts
226           munged for decimal placement.
227
228           ("cdpCachePowerConsumption")
229
230       $cdp->cdp_cap()
231           Returns hash of arrays with each array containing the system
232           capabilities supported by the remote system.  Possible elements in
233           the array are "Router", "Trans-Bridge", "Source-Route-Bridge",
234           "Switch", "Host", "IGMP", "Repeater", "VoIP-Phone",
235           "Remotely-Managed-Device", "Supports-STP-Dispute", and "Two-port
236           Mac Relay".
237

Data Munging Callback Subroutines

239       $cdp->munge_power()
240           Inserts a decimal at the proper location.
241
242
243
244perl v5.36.0                      2022-07-22                SNMP::Info::CDP(3)
Impressum