Repository navigation
refactor(schema): share the IPv6-option and byte-order schema helpers (#1519) - #1528
Conversation
f4e32c8 to
e64f991
Compare
e64f991 to
8cab590
Compare
|
Coverage: 90.08% (unit tier, Python 3.14,
Per-file detail: the |
|
Verdict: NEEDS CHANGES at Confirmed:
To fix:
|
8cab590 to
88f93e4
Compare
|
Verdict: NEEDS CHANGES at Confirmed:
To fix:
Optional: the new |
…#1519) - Move the nine HOPOPT / IPv6-Opts option helpers into a new `pcapkit.protocols.schema.internet.ipv6_option`, parameterised by the error prefix and, for the selectors, by the option schemas to return. `hopopt.py` and `ipv6_opts.py` bind them in same-named functions, and use `rpl_opt_sub_tlv_len` and `pad_opt_data_len` unchanged. - Correct the TaggerID values in the `smf_i_dpd_tid_selector` docstring (IPv4 is 2 and IPv6 is 3, not 1 and 2). - Move `byteorder_callback` and `packet_byteorder` into a new `pcapkit.protocols.schema.misc.byteorder`, with the PCAP-NG body, and use it from both the PCAP frame header and PCAP-NG. - Let the callback introspection in `tests/corekit/test_fields_misc.py` (address-typed switches) and `tests/corekit/test_schema_roundtrip_unit.py` (driver fields) read the shared helper a callback delegates to. - Document both shared modules on new docs pages, and point the HOPOPT, IPv6-Opts and PCAP-NG pages at them. Byte-identical on every sample capture; new tests pin each helper, both error prefixes and the `__packet__` fallback.
88f93e4 to
31a76d1
Compare
|
Verdict: GOOD TO GO at
|
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeAdded a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingrelease— bumps the version or rolls up a distributionchore— anything elseDescription of your pull request and other information
schema/internet/ipv6_option.py. The AST diff found no difference beyond the error prefix and the module-local classes. The helpers takeprefix=, and the selectors also takebase=/unassigned=.hopopt.pyandipv6_opts.pybind them in functions with the same names, and importrpl_opt_sub_tlv_lenandpad_opt_data_lenunchanged. Thesmf_i_dpd_tid_selectordocstring had the TaggerID values off by one (IPv4 is 2, not 1), and this fixes it.byteorder_callbackandpacket_byteordernow live in the newschema/misc/byteorder.py, and bothpcap/frame.pyandpcapng.pyuse them. They take the PCAP-NG body, a strict superset: it also falls back to an enclosing__packet__. For Frame the answer is unchanged on every packet the library passes in: all 17,940 Frame calls on the samples carrybyteorderand none carries__packet__, and the old and new bodies agree on each one.from_data(info.to_dict())and make→parse on all 23 sample captures (1,495 Frame, 121 PCAPNG, 15 HOPOPT, 15 IPv6_Opts layers) give the same digest asorigin/main. So do 52 hand-built option cases covering the branches and every raise, under both headers.test_ipv6_option_helpers_1519_unit.pyhas 10 tests. They pin every helper, the exact error text under both prefixes, and the delegation; onorigin/main, 8 fail and the 2 header-behaviour pins pass.test_schema_byteorder_1519_unit.pyhas 4 tests. They pin the helper, its__packet__fallback, that both schemas use it, and a frame header read through an enclosing packet; all 4 fail onorigin/main.tests/corekit/test_fields_misc.pyfor switch discovery andtest_schema_roundtrip_unit.pyfor driver discovery. Without that, the round-trip harness lost thelendriver for CALIPSO, MPL and SMF I-DPD. Its driver census now matchesorigin/mainon all 447 schema classes.make mypygives 332 errors in 42 files, the same error set asmain, and this PR adds notype: ignore. The selectors typebaseasEnumMeta, and annotate the registry lookupOptional[Type[Schema]], because the registries aredefaultdict(lambda: None).internet/ipv6_option.rstandmisc/byteorder.rstpages, and the HOPOPT, IPv6-Opts and PCAP-NG pages point to them.Refs #1519