Repository navigation
fix(l2tpv2): correct the Type enum and L bit against RFC 2661 (#1175) - #1183
Conversation
- vendor/l2tp/type.py: Data = 0, Control = 1, per RFC 2661 §3.1; the const is regenerated from it. BREAKING: Enum_Type values swap. - L2TPv2.make(): a control message sets L and defaults total_length to the real header-plus-payload length; a new length_flag keyword, fed by _make_data, keeps a captured control message without L byte-exact. An explicit total_length is written as given, as UDP does (#1155). - The offset pad is recorded as info.padding and passed back to make(), so from_data no longer zeroes it. Closes #1175
|
Cross-review verdict on
|
|
Coverage: 88.89% (unit tier, Python 3.14,
Per-file detail: the |
pcapkit/files with the Makefile flags; no new findings)make testpasses, and a test case covers the change (per-module only, see below; not the full suite)docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A, added centrallyWhat is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Closes #1175. Breaking: public
Enum_Typevalues swap toData = 0,Control = 1(RFC 2661 §3.1). The const is regenerated from the fixed vendor table.make()setsLon a control message and defaultstotal_lengthto header + payload. A newlength_flagkeyword, which_make_datafills in, keeps a control message captured withoutLbyte-exact. Atotal_lengththe caller passes is written as given (documented, not checked), like UDP after design(protocols): should from_data keep declared lengths on truncated captures? #1155, so a rebuild of a snaplen-truncated capture keeps the declared length.info.paddingand goes back throughmake().int(Type.Data), int(Type.Control)1 00 1L2TPv2(tunnel_id=1, session_id=2)800200010002(T=1)000200010002make(type=Control, ns=0, nr=1, …)0802…(L=0)c802000c……0003010203ff03…0003000000ff03Tests: new
tests/protocols/link/test_l2tpv2_type_unit.pypasses 8. With the source fix reverted, 6 fail. The 2 guards were proved by mutation: droppinglength_flagfrom_make_datafails the guard and 6 cases intest_l2tpv2_length_roundtrip_unit.test_link_unit24 passed, after one fixture edit giving its dummy flagslen=True.tests/project389 passed, 1 skipped.run_unittest_leg.py protocols --exclude protocols/internetreports 850 tests, 0 failures.