Found while verifying #494's fix (PR #499) and deliberately left out of it. Re-measured on main at d2d9bb80c, after #499, #500, #501, #502 and #503 all merged — still broken.
IPv4.from_data() cannot rebuild a parsed packet
proto = object.__new__(IPv4)
raw = proto.make(offset=5, protocol=6, payload=b'\xaa'*8).pack()
info = IPv4(io.BytesIO(raw), len(raw)).info
proto.from_data(info)
ProtocolUnbound: unsupported type <class 'pcapkit.protocols.misc.raw.Raw'>
Both with and without IPv4 options — measured separately, identical result.
This is not #494, and #494's fix did not cause it
#494 fixed _make_data: the fragment offset was returned unscaled, and .options was read unconditionally. Both are fixed and merged. But _make_data is only one input to from_data, and the remaining fault is downstream.
The failure mode shifted across that fix, which is worth recording so nobody mistakes one for the other:
| tree |
error |
| before #499 |
FieldValueError: Field options has invalid value |
after #499 (current main) |
ProtocolUnbound: unsupported type <class 'pcapkit.protocols.misc.raw.Raw'> |
So #499 moved the wall, it did not build it. The earlier error came from _make_data handing back a parsed options container; the current one comes from _make_payload being given a parsed Raw payload it has no binding for.
Where to look
_make_payload / _make_ipv4_options. Parsing produces a Raw instance for an unrecognised payload and a parsed options container for the options; the make path expects the constructor-shaped inputs make() takes, and the two shapes are not the same. The round trip is only closed for packets built by hand, not for packets read off the wire.
Scope worth checking before fixing
This may not be IPv4-specific. _make_payload is inherited, so any protocol whose parse yields a Raw payload could have the same hole. That is unverified — I measured IPv4 only — and sizing it is the first task.
A fix wants a test that round-trips a parsed packet rather than a hand-built one, since that is the case the current tests never exercise. tests/protocols/internet/test_ipv4_unit.py covers _make_data in isolation, which is why this survived #494.
Found while verifying #494's fix (PR #499) and deliberately left out of it. Re-measured on
mainatd2d9bb80c, after #499, #500, #501, #502 and #503 all merged — still broken.IPv4.from_data()cannot rebuild a parsed packetBoth with and without IPv4 options — measured separately, identical result.
This is not #494, and #494's fix did not cause it
#494 fixed
_make_data: the fragment offset was returned unscaled, and.optionswas read unconditionally. Both are fixed and merged. But_make_datais only one input tofrom_data, and the remaining fault is downstream.The failure mode shifted across that fix, which is worth recording so nobody mistakes one for the other:
FieldValueError: Field options has invalid valuemain)ProtocolUnbound: unsupported type <class 'pcapkit.protocols.misc.raw.Raw'>So #499 moved the wall, it did not build it. The earlier error came from
_make_datahanding back a parsed options container; the current one comes from_make_payloadbeing given a parsedRawpayload it has no binding for.Where to look
_make_payload/_make_ipv4_options. Parsing produces aRawinstance for an unrecognised payload and a parsed options container for the options; the make path expects the constructor-shaped inputsmake()takes, and the two shapes are not the same. The round trip is only closed for packets built by hand, not for packets read off the wire.Scope worth checking before fixing
This may not be IPv4-specific.
_make_payloadis inherited, so any protocol whose parse yields aRawpayload could have the same hole. That is unverified — I measured IPv4 only — and sizing it is the first task.A fix wants a test that round-trips a parsed packet rather than a hand-built one, since that is the case the current tests never exercise.
tests/protocols/internet/test_ipv4_unit.pycovers_make_datain isolation, which is why this survived #494.