-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
Description
Brief description
Even though a binding exists with an empty packet, the empty packet class does not get instantiated for payload on dissection.
Scapy version
2.6.1
Python version
3.8.6
Operating system
Windows
Additional environment information
No response
How to reproduce
class A(Packet):
fields_desc = [
XByteField("b", default=0),
]
class B1(Packet):
fields_desc = [
XByteField("value", default=0)
]
class B0(Packet):
fields_desc = []
bind_layers(A, B1, b=0x01)
bind_layers(A, B0, b=0x00)
a = A(bytes.fromhex("0101"))
assert isinstance(a.payload, B1), f"Payload of {a!r} is not {B1!r}"
a = A(bytes.fromhex("00"))
assert isinstance(a.payload, B0), f"Payload of {a!r} is not {B0!r}"
Actual result
AssertionError: Payload of <A b=0x0 |> is not <class 'main.B0'>
Expected result
No exception.
Related resources
No response