Add IP address extension type (-7)#346
Open
gdamore wants to merge 1 commit into
Open
Conversation
Define a predefined extension type for IPv4 and IPv6 addresses: IPv4 as fixext 4 and IPv6 as fixext 16, stored in network byte order. The address family is determined by payload length (4 vs 16 bytes), so encoding/decoding is a direct byte copy with no textual parsing. Type code -7 avoids the contested -2..-5 range proposed by several outstanding extension-type PRs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a predefined extension type for IP addresses, assigned to extension type
-7.fixext 4(0xd6), 4-byte payloadfixext 16(0xd8), 16-byte payloadThe address family is determined solely by payload length (4 vs 16), so there is no discriminator byte and no ambiguity. Because the layout matches
struct in_addr/struct in6_addr, encoding and decoding are a direct byte copy — noinet_pton/inet_ntop, no string parsing. That is the entire motivation: parsing and (especially) formatting textual IPv6 is comparatively expensive, and shipping addresses as text wastes wire space.Design decisions
::ffff:0:0/96) in the 16-byte form when a 4-byte encoding is possible, so each address has one canonical encoding.Type code choice
-1is Timestamp. Type codes-2through-5are currently contested by multiple outstanding extension-type PRs (e.g. #340 UID/UUID, #338 length encoding, #304 geographic coordinate, #248 / #249 big numbers).-7sidesteps that range to avoid collisions, leaving-6as a buffer for those proposals to settle.