Skip to content

Commit

Permalink
Improve CDPMsgIPPrefix : allow more than one IP address (#4585)
Browse files Browse the repository at this point in the history
* Update cdp.py for CDPIPPrefix

if the length of IP addresses prefixes was more than one address all the following content wasn't interpreted (Raw payload). This seams to fix it

* Update cdp.py

A better approach with a list rather than packets

* Update cdp.py case error on Prefix

* Fix PEP8 formatting

* Rename IPPrefix -> CDPPrefix

---------

Co-authored-by: gpotter2 <[email protected]>
  • Loading branch information
itform-fr and gpotter2 authored Nov 23, 2024
1 parent 8e08cbf commit 680107d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions scapy/contrib/cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,23 @@ class CDPMsgIPGateway(CDPMsgGeneric):
IPField("defaultgw", "192.168.0.1")]


class CDPIPPrefix(Packet):
fields_desc = [
IPField("prefix", "192.168.0.1"),
ByteField("plen", 24),
]

def guess_payload_class(self, p):
return conf.padding_layer


class CDPMsgIPPrefix(CDPMsgGeneric):
name = "IP Prefix"
type = 0x0007
fields_desc = [XShortEnumField("type", 0x0007, _cdp_tlv_types),
ShortField("len", 9),
IPField("prefix", "192.168.0.1"),
ByteField("plen", 24)]
PacketListField("prefixes", [], CDPIPPrefix,
length_from=lambda p: p.len - 4)]


class CDPMsgProtoHello(CDPMsgGeneric):
Expand Down

0 comments on commit 680107d

Please sign in to comment.