| 1 |
cdpr - Cisco Discovery Protocol Reporter |
| 2 |
Copyright (c) 2002-2008 MonkeyMental.com |
| 3 |
|
| 4 |
*Version 2.4 |
| 5 |
|
| 6 |
Work around OSX buffering issue that prevented the bpf interface from passing the packets up to the decoder |
| 7 |
|
| 8 |
Allow reading from a pcap file using -r for debugging purposes. |
| 9 |
|
| 10 |
*Version 2.3 |
| 11 |
|
| 12 |
Decode IPv6 responses in the CDP packet and send them in the http response if |
| 13 |
using cdpr server updates. |
| 14 |
|
| 15 |
Sample of GET request: |
| 16 |
?switch_ip=6x.3x.2xx.2xx&switch_ip6=fxxx::2xx:cxxx:fxxx:2xxx&switch_ip6=2xxx:1xxx:2xx::1&port=GigabitEthernet1%2F45&host=monkeymental.com |
| 17 |
|
| 18 |
*Version 2.2.1 |
| 19 |
|
| 20 |
Fixed the logic that will select a default port of 80 if no port is specified. |
| 21 |
Updated copyrights and license details on all source files with the exception |
| 22 |
of the MS Visual Studio project files. I'm unsure if I can add license and |
| 23 |
copyright info to these files and still have them work. However, these are |
| 24 |
not source files, so think of them as nothing more than Makefiles for Visual |
| 25 |
Studio. |
| 26 |
|
| 27 |
*Version 2.2.0 |
| 28 |
|
| 29 |
Added the ability to specify what port to send the updates to. |
| 30 |
|
| 31 |
*Version 2.1.0 |
| 32 |
|
| 33 |
This version provides the ability to include a timeout so that you can put cdpr |
| 34 |
into startup scripts and not have it hang if for some reason a CDP packet is never |
| 35 |
received (i.e. CDP is disabled, machine is plugged into a hub, etc.) The following |
| 36 |
command line option has been added: |
| 37 |
|
| 38 |
-t timeout: Specify a timeout (in seconds) to wait for a CDP packet. |
| 39 |
|
| 40 |
Please note that the default time between CDP packets is 60 seconds so you should |
| 41 |
set your timeout to something greater than 60. There is a default timeout of 5 minutes |
| 42 |
so that should you not provide a timeout, cdpr will still exit if there is no CDP |
| 43 |
packet received within 5 minutes. |
| 44 |
|
| 45 |
This version also allows you to specify the server and URL to send CDP updates to on |
| 46 |
the command line. The following command line options have been added: |
| 47 |
|
| 48 |
-s server: Server to send information to requires -p (overridden by -u) |
| 49 |
-p path: Path of server script to send data to requires -s (overridden by -u) |
| 50 |
|
| 51 |
As you can see if you specify -s, -p and -u on the command line, the config file is actually |
| 52 |
used, and the -s and -p options are ignored. Both the -s and -p options must be specified and |
| 53 |
cdpr will exit if only one of them is given. An example as to how to use the -s and -p flags: |
| 54 |
|
| 55 |
cdpr -d eth0 -s localhost -p /cgi-bin/cdprs.cgi -t 120 |
| 56 |
|
| 57 |
This will listen for a CDP announcement on device eth0 for up to 2 minutes (120 seconds) and |
| 58 |
send the results to the webserver running on the local machine by calling the /cgi-bin/cdprs.cgi |
| 59 |
page. |
| 60 |
|
| 61 |
*Versions 2.0.1 - 2.0.5 |
| 62 |
These version were never officially released, they were code cleanups and timeout implementation. |
| 63 |
|
| 64 |
*Version 2.0.0 |
| 65 |
|
| 66 |
This version provides the functionallity to report CDP data back to a centralized server. |
| 67 |
Please see the file README.cdprs for details, but in general, the following command line |
| 68 |
options have been added: |
| 69 |
|
| 70 |
-u conf.file: Send updates to the host listed in the config file. |
| 71 |
-l location: Send a location string to help identify the port. |
| 72 |
-n hostname: Override the hostname sent to the server. |
| 73 |
|
| 74 |
Platform Update: Some of the newer HP Switch firmware will broadcast CDP packets. cdpr |
| 75 |
will decode these packets just the same as they would if they came from a Cisco product. |
| 76 |
It was tested on a HP ProCurve 4000M running revision C.09.16. |
| 77 |
|
| 78 |
*Version 1.0.8 |
| 79 |
|
| 80 |
Support for ARM processor. Tested on the Sharp Zaurus SL-5500. |
| 81 |
|
| 82 |
*Version 1.0.7 |
| 83 |
|
| 84 |
Support for Win32 clients please read README.Win32. |
| 85 |
To support the Win32 clients, modified so that if a network device is not specified |
| 86 |
on the command line with -d, then to find all devices that are capable of being used |
| 87 |
by the pcap libary and provide a selection list. |
| 88 |
|
| 89 |
*Version 1.0.6 |
| 90 |
|
| 91 |
Fixed up some more bus errors/segmentation faults. |
| 92 |
|
| 93 |
*Version 1.0.5 |
| 94 |
|
| 95 |
Copy packet data to local variable to resolve alignment issues that caused Bus Errors |
| 96 |
on some architectures. cdpr has now been compiled and tested on the following |
| 97 |
Operating Systems: |
| 98 |
- Linux 2.4.18 (x86) |
| 99 |
- FreeBSD 4.6 (x86) |
| 100 |
- Sun Solaris 8 (SPARC) |
| 101 |
- HP HP-UX 11.11 (PA-Risc) |
| 102 |
- IBM AIX 4.3.3 (PowerPC) |
| 103 |
|
| 104 |
On some operating systems (like Solaris) the u_int* typedefs are not defined, to resolve |
| 105 |
this issue, include u_ints.h in cdp.h. |
| 106 |
|
| 107 |
On AIX you must load the dlpi kernel module using the following command: |
| 108 |
|
| 109 |
strload -f /etc/dlpi.conf |
| 110 |
|
| 111 |
On AIX you may recieve some warnings about "Primitive issued in improper state", |
| 112 |
these can be safely ignored. |
| 113 |
|
| 114 |
On HP-UX you may recieve a warning about "any missing unit number", this can be |
| 115 |
safely ignored |
| 116 |
|
| 117 |
*Version 1.0.4 |
| 118 |
|
| 119 |
Added 1 ms timeout to pcap_open_live to fix BSD hang issues. |
| 120 |
|
| 121 |
*Version 1.0.3 |
| 122 |
|
| 123 |
Loop on pcap_next until a valid packet is received, some implementations of pcap will |
| 124 |
return a null. Patch provided by Martin Buck <[email protected]>. |
| 125 |
|
| 126 |
*Version 1.0.2 |
| 127 |
|
| 128 |
Use a new filter to better identify CDP packets. Solves the majority of the segfaults |
| 129 |
due to trying to decode a non-CDP packet (i.e. a VTP packet) |
| 130 |
|
| 131 |
*Version 1.0.1 |
| 132 |
|
| 133 |
Add preprocessor macros to only include the Link Type defines provided by the pcap and |
| 134 |
bpf headers. |
| 135 |
|
| 136 |
*Version 1.0.0 |
| 137 |
|
| 138 |
I originally wrote this program to report which switch, and port a machine |
| 139 |
is connected to. In a large environment sometimes it is difficult to determine |
| 140 |
which port on which switch a machine is connected to. |
| 141 |
|
| 142 |
By default (with no command line options) cdpr will determine a network interface |
| 143 |
to open, put into promiscuous mode and wait for a single CDP packet to be received. |
| 144 |
|
| 145 |
On multi-homed machines, you can specify which interface to use with the -d option. |
| 146 |
|
| 147 |
Example (to determine which switch/port eth1 is connected to): |
| 148 |
cdpr -d eth1 |
| 149 |
|
| 150 |
You can dump the whole cdp packet using -v (more v's = more output). |
| 151 |
|
| 152 |
Sample Output: |
| 153 |
cdpr - Cisco Discovery Protocol Reporter Version 1.0.0 |
| 154 |
Copyright (c) 2002 - MonkeyMental.com |
| 155 |
|
| 156 |
Using Device: eth0 |
| 157 |
Waiting for CDP advertisement, default config is to transmit CDP packets every 60 seconds |
| 158 |
Device ID |
| 159 |
value: mtview-3548-access-1.i2.com |
| 160 |
Addresses |
| 161 |
value: 10.100.230.14 |
| 162 |
Port ID |
| 163 |
value: FastEthernet0/4 |
| 164 |
|
| 165 |
As you can see above, by default CDP packets are broadcast every 60 seconds, cdpr will wait |
| 166 |
until a CDP packet is received. |
| 167 |
|
| 168 |
I hope you find this utility useful. Thanks to Manfred Siemsen for helping to decode the |
| 169 |
packet data. |
| 170 |
|
| 171 |
Regards, |
| 172 |
Lance O'Connor |
| 173 |
[email protected] |