Home | Trees | Indices | Help |
|
---|
|
1 # $Id: cdp.py 23 2006-11-08 15:45:33Z dugsong $ 2 3 """Cisco Discovery Protocol.""" 4 5 import struct 6 import dpkt 7 8 CDP_DEVID = 1 # string 9 CDP_ADDRESS = 2 10 CDP_PORTID = 3 # string 11 CDP_CAPABILITIES = 4 # 32-bit bitmask 12 CDP_VERSION = 5 # string 13 CDP_PLATFORM = 6 # string 14 CDP_IPPREFIX = 7 15 16 CDP_VTP_MGMT_DOMAIN = 9 # string 17 CDP_NATIVE_VLAN = 10 # 16-bit integer 18 CDP_DUPLEX = 11 # 8-bit boolean 19 CDP_TRUST_BITMAP = 18 # 8-bit bitmask0x13 20 CDP_UNTRUST_COS = 19 # 8-bit port 21 CDP_SYSTEM_NAME = 20 # string 22 CDP_SYSTEM_OID = 21 # 10-byte binary string 23 CDP_MGMT_ADDRESS = 22 # 32-bit number of addrs, Addresses 24 CDP_LOCATION = 23 # string 2527 __hdr__ = ( 28 ('version', 'B', 2), 29 ('ttl', 'B', 180), 30 ('sum', 'H', 0) 31 )9633 # XXX - only handle NLPID/IP for now 34 __hdr__ = ( 35 ('ptype', 'B', 1), # protocol type (NLPID) 36 ('plen', 'B', 1), # protocol length 37 ('p', 'B', 0xcc), # IP 38 ('alen', 'H', 4) # address length 39 )4345 __hdr__ = ( 46 ('type', 'H', 0), 47 ('len', 'H', 4) 48 )7750 dpkt.Packet.unpack(self, buf) 51 self.data = self.data[:self.len - 4] 52 if self.type == CDP_ADDRESS: 53 n = struct.unpack('>I', self.data[:4])[0] 54 buf = self.data[4:] 55 l = [] 56 for i in range(n): 57 a = CDP.Address(buf) 58 l.append(a) 59 buf = buf[len(a):] 60 self.data = l6163 if self.type == CDP_ADDRESS: 64 n = 4 + sum(map(len, self.data)) 65 else: 66 n = len(self.data) 67 return self.__hdr_len__ + n6879 dpkt.Packet.unpack(self, buf) 80 buf = self.data 81 l = [] 82 while buf: 83 tlv = self.TLV(buf) 84 l.append(tlv) 85 buf = buf[len(tlv):] 86 self.data = l87 90
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Nov 16 14:12:44 2011 | http://epydoc.sourceforge.net |