[asterisk-users] OT: Patch to OSS app for CDP without a Cisco switch - TESTERS WANTED

Kristian Kielhofner kristian.kielhofner at gmail.com
Wed Feb 28 15:33:05 MST 2007


Hey everyone,

  I came across a situation where I needed to use CDP to advertise a
voice vlan to Polycom/Cisco (and other CDP capable phones) without a
Cisco switch.

  Sure I have Cisco switches in places but I like my Polycoms to work
out of the box and it isn't always practical to purchase a Cisco
switch for every location.

cdp-tools homepage:

http://gpl.internetconnection.net/

  So I found cdp-tools to try to advertise the voice vlan using CDP.
On Cisco switches this is used with "switchport voice vlan xxxx" where
xxx is the vlan.  But what if you don't have a Cisco switch or your
switch doesn't support CDP?

  I grabbed cdp-tools and started playing around.  You will need to
install libpcap (and headers if you are using package management) and
libnet (preferably 1.1 and headers).

  I got to work on cdp-tools and found that there were several problems:

- It only advertised CDPv1 (current is CDPv2)
- It didn't support Voice VLANs
- It didn't properly support native VLANs
- It didn't properly support advertising duplex

  I was fortunate enough to have access to some real Cisco switches.
I was able to grab the CDP advertisements (after defining a voice
vlan) and decode them using ethereal (wireshark).

  Using my handy capture of a "correct" CDP advert from a 2960G (CDP
v2), I started working on the cdp-tools source.  I was able to correct
all of the problems above.  I added a new argument (-V) to specify a
voice vlan to advertise.

  After some quick testing, I was able to trick a Polycom into
thinking that my laptop was a CDPv2 capable switch and the Polycom (IP
601) successfully discovered the correct VLAN when connected to my
laptop with a crossover cable (I had already used vconfig to add the
voice vlan to the laptop).

  A quick howto:

- Download and extract cdp-tools:
http://gpl.internetconnection.net/files/cdp-tools.tar.gz

- Apply my patch
http://www.krisk.org/asterisk/cdp-tools.patch

- Compile cdp-tools

- Run cdp-tools (as root):
sudo ./cdp-send -c l2sw -d -L 1 -V 20 -m i586 -n "pbx" -s "FakeSwitch"
-t 10 -P full eth0

Explanation:
-c (advertise as layer 2 switch)
-d (turn debugging on)
-L (Native VLAN)
-V (Voice VLAN)
-m (machine architecture)
-n (machine name)
-s (machine software)
-t (wait time between broadcasts)
-P (advertise duplex)

and eth0 is the interface to broadcast on...

  You should now be advertising VLAN 20 as your "voice vlan" and VLAN
1 as your default VLAN.  Your machine will also be visible from any
CDP v2 capable connected devices.  Try "sh cdp neigh" from any Cisco
switches on your network.  You should see your Linux machine!


  TO-DO:

- CDPv2 "support" is a very loose term...  It is NOWHERE near complete
and it appears to be the bare minimum to work with a Polycom phone.

- The variable names in my patch suck!

  I would appreciate some testing before I send this patch upstream.
Let me know how it works out (if at all).

Thanks!

-- 
Kristian Kielhofner


More information about the asterisk-users mailing list