2a884db1d1
CDP uses the running sytems host name, which caused different failures on different systems. The root cause was an python3 specific error in checksum calculation. Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I205436682d46e7e8cbb8c057c03a76dbbcab4d72
32 lines
1.4 KiB
Diff
32 lines
1.4 KiB
Diff
diff --git a/scapy/contrib/cdp.py b/scapy/contrib/cdp.py
|
|
index c8b7f106..7b1ff64d 100644
|
|
--- a/scapy/contrib/cdp.py
|
|
+++ b/scapy/contrib/cdp.py
|
|
@@ -102,7 +102,8 @@ def _CDPGuessPayloadClass(p, **kargs):
|
|
class CDPMsgGeneric(Packet):
|
|
name = "CDP Generic Message"
|
|
fields_desc = [ XShortEnumField("type", None, _cdp_tlv_types),
|
|
- FieldLenField("len", None, "val", "!H"),
|
|
+ FieldLenField("len", None, "val", "!H",
|
|
+ adjust=lambda pkt, x: x + 4),
|
|
StrLenField("val", "", length_from=lambda x:x.len - 4) ]
|
|
|
|
|
|
@@ -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"),
|
|
+ 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:
|