Improve CDPMsgIPPrefix : allow more than one IP address (#4585)

* 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 <10530980+gpotter2@users.noreply.github.com>
This commit is contained in:
itform-fr 2024-11-23 12:33:18 +01:00 committed by GitHub
parent 8e08cbf759
commit 680107d30f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 2 deletions

View File

@ -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):