Detect embedded IPv4 in non-canonical 6to4 addresses#110
Conversation
`Derived::isEmbedded()` only matched canonical 6to4 addresses with the trailing 80 bits zeroed, even though every address within `2002::/16` carries an IPv4 address in bits 16-47, as per RFC 3056. Widen detection to the whole 6to4 block; extraction keeps only the embedded IPv4 address, so an extract-pack round-trip reconstructs the canonical form (`2002:XXXX:XXXX::`) rather than the original.
Greptile SummaryThis PR widens
Confidence Score: 4/5The core logic change is small, well-reasoned against RFC 3056, and the docblocks clearly warn about the non-roundtrip extraction. The only gap is that the new non-canonical detection path has no test coverage. The implementation correctly drops a guard that made detection too narrow, and pack/extract behaviour is unchanged. The sole concern is that the test data only contains canonical 6to4 forms, so no test actually exercises the newly-widened isEmbedded() path with a non-zero SLA or interface ID. tests/DataProvider/Strategy/Derived.php — getValidSequences() and getInvalidSequences() should include at least one non-canonical 6to4 address to cover the new detection logic. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[16-byte binary input] --> B{First 2 bytes == 0x2002?}
B -- No --> C[isEmbedded = false]
B -- Yes --> D[isEmbedded = true]
D --> E[extract: return bytes 2-5 as IPv4]
E --> F{Canonical?\nbytes 6-15 == 0x00...?}
F -- Yes --> G[roundtrip safe:\npack extract = original]
F -- No --> H[lossy: SLA ID + Interface ID\ndiscarded by pack]
H --> I[pack produces canonical\n2002:XXXX:XXXX::]
Reviews (1): Last reviewed commit: "bugfix(strategy): 🐛 detect embedded IPv..." | Re-trigger Greptile |
Derived::isEmbedded()only matched canonical 6to4 addresses with the trailing 80 bits zeroed, even though every address within2002::/16carries an IPv4 address in bits 16-47, as per RFC 3056. Widen detection to the whole 6to4 block; extraction keeps only the embedded IPv4 address, so an extract-pack round-trip reconstructs the canonical form (2002:XXXX:XXXX::) rather than the original.