Repository navigation
refactor(protocols): every versioned family base dispatches on read, make and from_data - #2639
Conversation
|
GOOD TO GO at The review's notes are folded in:
The owner's later ruling is in too: IGMP's data model carries |
|
NEEDS CHANGES at
A fix round, rebased onto |
#2574) - IGMP.__new__ gives the version class: version= names it on either path; without it, octets go by _dispatch and fields raise ProtocolError. A subclass of the base is created as itself. - IGMP.__init__ takes version=: building, it must be the class's own version; parsing, it is handed on, as IP passes its own under that name. - The IGMPv1/v2 and IGMPv3 data models gain version, on no octet: read sets it, _make_data carries it, and IGMP.from_data dispatches on it. Data without it raises ProtocolError. - _member_of_version maps the int 1, 2 or 3, refusing a bool or a float; _dispatch uses it. - Octets of no version raise ProtocolError('IGMP: unknown version'). - Tests: version= on both paths, fields without it, octets by their own version, version in the data model only, from_data, subclasses, make->parse round trips; the abstract-base tests check object.__new__.
…2574) - IP.__new__ gives IPv4 or IPv6: version= names it on either path; without it, octets go by their Version nibble and fields raise ProtocolError. A subclass of the base is created as itself. - IP.__init__ takes version=: building, it must be the class's own, which a subclass outside the members lacks; parsing, it is handed on, as the enclosing IP layer passes its own under that name. - IPv4.unpack and IPv6.unpack check the Version nibble before the header schema, so another version's octets raise "[IPv4] invalid version: 6". - IP.from_data picks the member the data's version names. - Empty octets, or a version other than the int 4 or 6, raise ProtocolError. - The RFC-constants sweep lists the IP version 6 in ip.py and ipv6.py as no copy of the IPv6 Next Header offset. - Tests: version= on both paths, fields without it, octets by their own version, the Version check, from_data, subclasses, make->parse round trips.
#2574) - ICMP.__new__ gives the member version= names, from octets or fields. Without it both raise ProtocolError: an ICMP message carries no version, and no field picks a member. A subclass is created as itself. - ICMP.__init__ takes version=: building, it must be the class's own, which a subclass outside the members lacks; parsing, it is handed on, as the IP layer passes its own under that name. - ICMP.from_data picks the member whose data model it is handed; a dict, and a version other than the int 4 or 6, raise ProtocolError. - The RFC-constants sweep lists ICMPv6's version 6 as no copy of the IPv6 Next Header offset. - Tests: version= on both paths, octets and fields without it, from_data, subclasses, make->parse round trips.
…2574) - L2TP.__new__ gives the member the version field names, on either path; without it, octets go by the nibble in bits 12-15 and fields raise ProtocolError. A subclass of the base is created as itself. - L2TP.from_data picks the member the data's version names. - _member_of_version maps the int 2 to L2TPv2; any other version, a bool or a float, and octets shorter than the first word raise ProtocolError. - Module and API page prose: the base switches on version; UDP 1701 binds L2TPv2. - Tests: version on both paths, fields without it, octets by their own nibble, from_data, a subclass, make->parse round trips.
#2574) - LinuxSLL.__new__ gives the member version= names, from octets or fields. Without it both raise ProtocolError: neither header carries a version, and no field picks a member. A subclass is created as itself. - LinuxSLL.__init__ takes version=: building, it must be the class's own, which a subclass outside the members lacks; parsing, it is handed on. - LinuxSLL.from_data picks the member whose data model it is handed; a dict, and a version other than the int 1 or 2, raise ProtocolError. - Tests: version= on both paths, octets and fields without it, from_data, subclasses, make->parse round trips.
…ses (#2574) - Record the ruling: the member is the one version= names, or else the one the octets or the data model carry; no field picks one and no member is a default. - A table gives each base's versions and what it reads from octets without version= and in from_data; HTTP, which dispatches otherwise, is described apart. - ICMP and LinuxSLL octets and dicts, and a version a family has no member for, are refused with ProtocolError.
9cb46c4 to
fef0cb5
Compare
|
Fix round and rebase:
The patch-id changed, so the label is |
|
GOOD TO GO at
|
|
Coverage: 94.11% -- tests failure, so this is partial (unit tier, Python 3.15,
Per-file detail: the |
…shared value helpers into 1.6.0 (#2449) - Breaking: NoPayload and its data model and schema move from misc.null to misc.no_payload with no re-export, so a frame pickled by 1.5.x fails to load (#2636). 1.5.0's three NoPayload roles and 1.6.0's own point at misc.no_payload, 1.5.0's text unchanged. - Added: the IP, L2TP, ICMP, IGMP and LinuxSLL bases give a member on read, make and from_data, version= naming it, with the refusals and IPv4's Version check ahead of the header (#2639). - Changed: SCTP's chunk-flag and Invalid Stream Identifier reserved-octet messages (#2638). Folded into the TLS/DTLS entry: make() raises StructError for a value too wide for its field (#2638), and the DTLS_CIDCiphertext and TLS_ConnectionId package exports (#2641). - The conventions entry records the version= dispatch rule (#2639) and ARP as the member-order reference (#2638). - No entry for #2638's private value helpers or the Ethernet and PCAP-NG PAT_MAC_ADDR, as for #1844's OSPF copy; #2640's docstring fixes; or the test-only #2620, #2637, #2645 and #2646. - CHANGELOG.md regenerated; util/changelog_md.py --check passes.
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
refactor— changes neither behaviour nor performanceDescription of your pull request and other information
The versioned family bases — IGMP, IP, ICMP, L2TP and LinuxSLL — now dispatch on read, make and
from_data, under the owner's rulings on #2574. The series is one commit per family, plus the conventions page.version=picks the member. The member is the oneversion=names. Otherwise it is the one the octets carry (IP, IGMP, L2TP) or the data model carries; IGMP's data models gain aversionattribute for this. A field never picks the member.ProtocolErrorand namesversion=. So do versionless ICMP/LinuxSLL octets, and a non-intversion.IP(<v6 octets>, version=4)raises[IPv4] invalid version: 6.version=must be the class's own version.All 23 sample captures parse identically, and so do synthetic 6in4, IGMP-in-IPv4, L2TP and SLL frames. The bases raised
TypeErroron all three paths onmain. HTTP still predates the rule; #2628 follows up.A Sonnet cross-review returned GOOD TO GO, and its notes are folded in.
Closes #2574