self.assert_equal(system[:length], self.device_id[:length],
"CDP received invalid device id")
- @unittest.skipIf(sys.version_info[0] > 2,
- "not supported in python3/scapy")
def test_cdp_underflow_tlv(self):
self.send_bad_packet(3, ".")
- @unittest.skipIf(sys.version_info[0] > 2,
- "not supported in python3/scapy")
def test_cdp_overflow_tlv(self):
self.send_bad_packet(8, ".")
StrLenField("val", "", length_from=lambda x:x.len - 4) ]
-@@ -178,7 +179,8 @@ class CDPMsgAddr(CDPMsgGeneric):
+@@ -178,5 +179,6 @@ class CDPMsgAddr(CDPMsgGeneric):
class CDPMsgPortID(CDPMsgGeneric):
name = "Port ID"
fields_desc = [ XShortEnumField("type", 0x0003, _cdp_tlv_types),
+ FieldLenField("len", None, "iface", "!H",
+ adjust=lambda pkt, x: x + 4),
StrLenField("iface", "Port 1", length_from=lambda x:x.len - 4) ]
-
-
+@@ -319,7 +319,7 @@ class _CDPChecksum:
+ This padding is only used for checksum computation. The original
+ packet should not be altered."""
+ if len(pkt) % 2:
+- last_chr = pkt[-1]
++ last_chr = pkt[len(pkt)-1:]
+ if last_chr <= b'\x80':
+ return pkt[:-1] + b'\x00' + last_chr
+ else: