Repository navigation
fix(hip): rebuild parsed packets byte-exactly (Header Length, no parameters, PUZZLE lifetime, reserved bits) - #1342
Conversation
…meters, PUZZLE lifetime, reserved bits) - make(): pad a raw bytes parameter to 8 octets (RFC 7401 §5.2.1) and compute Header Length with ceiling division (#1313). - _make_data(): a packet with no parameters rebuilds; read only sets `parameters` when some exist (#1314). - PUZZLE: keep the raw Lifetime octet as `lifetime_exponent` and write it back; `lifetime` is derived, and None past timedelta.max (#1323). - Controls: name the 15 reserved bits (`Control.reserved`, `controls_reserved`); ESP_INFO: read `reserved` as a value (#1328). - test_hip_unit: fixtures gain the new fields; the octet-0x00 PUZZLE case now rebuilds instead of raising. Closes #1313 Closes #1314 Closes #1323 Closes #1328
|
Cross-review verdict on
PR body correction: it says 13 parameters drop reserved octets because each is a Nits: |
|
Correction to my verdict above. I wrote that the PR body claimed 13 parameters drop their reserved octets "because each is a |
TYPE_CHECKING__init__stub, as for every sibling fieldmake testpasses, and a test case covers the change — ran the modules listed below, not the full suiteWhat is the purpose of your pull request?
fix— corrects a defectDescription
from_dataround trip)make()AttributeErrorfffe, ESP_INFO reservedabcd0000,0000All 49 HIP frames in
options-internet.pcapstill round-trip.Breaking: these data-class fields are new and required:
Control.reserved,ESPInfoParameter.reservedandPuzzleParameter.lifetime_exponent.PuzzleParameter.lifetimeis now derived from the octet, and isNoneabove octet 78. The newmake()keyword iscontrols_reserved=0._make_param_esp_infogainsreserved=0, and_make_param_puzzlegainslifetime_exponent=None.Not done here: the unknown-parameter padding (
7ff00001 aa ffffff→aa000000) is aPaddingField, so it belongs to #1223. Other HIP reserved bits still rebuild as zero: 12PaddingFieldsites (now listed on #1223) and theLocatorflag bits (#1365).Tests:
test_hip_roundtrip_unit.pyis new. Run against the unfixed modules, all 6 of its tests fail (197 PUZZLE subtests fail). Intest_hip_unit.pyI updated fixtures for the new fields. One assertion there pinned the old raise for PUZZLE octet0x00; it now checks that the octet rebuilds. Results: test_hip_roundtrip 6 passed; test_hip_unit 34 passed; test_option_roundtrip 6 passed; 7 other HIP modules passed;tests/project389 passed;run_unittest_leg.py protocols/internet509 tests, 0 failures.Closes #1313
Closes #1314
Closes #1323
Closes #1328