Closed
Description
Brief description
When cache is set with a packet, modifying a value either in the payload or in a packet field does not reset the cache in the main packet.
This does not seem consistent with cache being reset on a final packet being modified.
Scapy version
2.6.1
Python version
3.8.6
Operating system
Windows
Additional environment information
No response
How to reproduce
Final packet modification:
class F(Packet):
fields_desc = [
ByteField("value", default=0),
]
f = F(bytes.fromhex("01"))
print(f"(before) f.raw_packet_cache={f.raw_packet_cache!r}")
f.value = 2
print(f"(after) f.raw_packet_cache={f.raw_packet_cache!r}")
Output:
(before) f.raw_packet_cache=b'\x01'
(after) f.raw_packet_cache=None
Cache is automatically reset.
Payload modification:
class M1(Packet):
pass
bind_layers(M1, F)
m1 = M1(bytes.fromhex("01"))
print(f"(before) m1.raw_packet_cache={m1.raw_packet_cache!r}")
m1.value = 2
print(f"(after) m1.raw_packet_cache={m1.raw_packet_cache!r}")
Output:
(before) m1.raw_packet_cache=b''
(after) m1.raw_packet_cache=b''
Cache on the underlayer is unchanged.
Packet field modification:
class M2(Packet):
fields_desc = [
PacketField("f", pkt_cls=F, default=F()),
]
m2 = M2(bytes.fromhex("01"))
print(f"(before) m2.raw_packet_cache={m2.raw_packet_cache!r}")
m2.f.value = 2
print(f"(after) m2.raw_packet_cache={m2.raw_packet_cache!r}")
Output:
(before) m2.raw_packet_cache=b'\x01'
(after) m2.raw_packet_cache=b'\x01'
Cache on the parent packet is unchanged.
Actual result
Cache on underlayer and/or parent packets is unchanged.
Expected result
Cache of underlayer and parent packets should be automatically reset when a subpacket (either payload or packet field) is modified.
Related resources
No response