Skip to content

Commit 680107d

Browse files
itform-frgpotter2
andauthored
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 <[email protected]>
1 parent 8e08cbf commit 680107d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

scapy/contrib/cdp.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,23 @@ class CDPMsgIPGateway(CDPMsgGeneric):
250250
IPField("defaultgw", "192.168.0.1")]
251251

252252

253+
class CDPIPPrefix(Packet):
254+
fields_desc = [
255+
IPField("prefix", "192.168.0.1"),
256+
ByteField("plen", 24),
257+
]
258+
259+
def guess_payload_class(self, p):
260+
return conf.padding_layer
261+
262+
253263
class CDPMsgIPPrefix(CDPMsgGeneric):
254264
name = "IP Prefix"
255265
type = 0x0007
256266
fields_desc = [XShortEnumField("type", 0x0007, _cdp_tlv_types),
257267
ShortField("len", 9),
258-
IPField("prefix", "192.168.0.1"),
259-
ByteField("plen", 24)]
268+
PacketListField("prefixes", [], CDPIPPrefix,
269+
length_from=lambda p: p.len - 4)]
260270

261271

262272
class CDPMsgProtoHello(CDPMsgGeneric):

0 commit comments

Comments
 (0)