tests: changes for scapy 2.4.3 migration
[vpp.git] / test / patches / scapy-2.4.3 / cdp.patch
1 diff --git a/scapy/contrib/cdp.py b/scapy/contrib/cdp.py
2 index c8b7f106..7b1ff64d 100644
3 --- a/scapy/contrib/cdp.py
4 +++ b/scapy/contrib/cdp.py
5 @@ -102,7 +102,8 @@ def _CDPGuessPayloadClass(p, **kargs):
6  class CDPMsgGeneric(Packet):
7      name = "CDP Generic Message"
8      fields_desc = [ XShortEnumField("type", None, _cdp_tlv_types),
9 -                    FieldLenField("len", None, "val", "!H"),
10 +                    FieldLenField("len", None, "val", "!H",
11 +                                  adjust=lambda pkt, x: x + 4),
12                      StrLenField("val", "", length_from=lambda x:x.len - 4) ]
13  
14  
15 @@ -178,5 +179,6 @@ class CDPMsgAddr(CDPMsgGeneric):
16  class CDPMsgPortID(CDPMsgGeneric):
17      name = "Port ID"
18      fields_desc = [ XShortEnumField("type", 0x0003, _cdp_tlv_types),
19 -                    FieldLenField("len", None, "iface", "!H"),
20 +                    FieldLenField("len", None, "iface", "!H",
21 +                                  adjust=lambda pkt, x: x + 4),
22                      StrLenField("iface", "Port 1", length_from=lambda x:x.len - 4) ]
23 @@ -319,7 +319,7 @@ class _CDPChecksum:
24          This padding is only used for checksum computation.  The original
25          packet should not be altered."""
26          if len(pkt) % 2:
27 -            last_chr = pkt[-1]
28 +            last_chr = pkt[len(pkt)-1:]
29              if last_chr <= b'\x80':
30                  return pkt[:-1] + b'\x00' + last_chr
31              else: