masque_ip_capsule (masque v0.7.0)
View SourceRFC 9484 §5 — CONNECT-IP capsule codec.
Encodes and decodes the three CONNECT-IP capsule types on top of masque_capsule (RFC 9297 framing):
ADDRESS_ASSIGN(0x01) — Request IDs may be 0 (unprompted).ADDRESS_REQUEST(0x02) — at least one entry, Request IDs MUST be nonzero and unique per sender.ROUTE_ADVERTISEMENT(0x03) — lexicographic ordering by (Version, IP Protocol, Start Address); ranges disjoint within equal (Version, Protocol); protocol-0 ranges MUST NOT overlap nonzero-protocol ranges for the same Version.
Every validation failure returns {error, Reason} — callers map this into an H3_MESSAGE_ERROR stream reset per RFC 9297 §3.3.
Summary
Functions
Decode the body bytes of a CONNECT-IP capsule into typed entries. The capsule type is determined by the caller from the capsule frame (e.g. via masque_capsule:decode/1).
Encode a typed capsule onto the RFC 9297 capsule frame. Dispatches on the capsule type atom.
Types
-type address_entry() :: #ip_assignment{request_id :: non_neg_integer(), version :: 4 | 6, address :: inet:ip_address(), prefix_len :: 0..128}.
-type decode_error() ::
truncated | malformed_varint | bad_ip_version | bad_prefix_length | empty_address_request |
duplicate_request_id | zero_request_id_in_request | unordered_routes | overlapping_routes |
proto_zero_overlap.
-type request_entry() :: #ip_prefix_request{request_id :: pos_integer(), version :: 4 | 6, address :: inet:ip_address(), prefix_len :: 0..128}.
-type route_entry() :: #ip_route{version :: 4 | 6, start_addr :: inet:ip_address(), end_addr :: inet:ip_address(), ip_protocol :: 0..255}.
Functions
-spec decode_address_assign(binary()) -> {ok, [address_entry()]} | {error, decode_error()}.
-spec decode_address_request(binary()) -> {ok, [request_entry()]} | {error, decode_error()}.
-spec decode_body(non_neg_integer(), binary()) -> {ok, [address_entry() | request_entry() | route_entry()]} | {error, decode_error()}.
Decode the body bytes of a CONNECT-IP capsule into typed entries. The capsule type is determined by the caller from the capsule frame (e.g. via masque_capsule:decode/1).
-spec decode_route_advertisement(binary()) -> {ok, [route_entry()]} | {error, decode_error()}.
-spec encode(address_assign | address_request | route_advertisement, [address_entry() | request_entry() | route_entry()]) -> iodata().
Encode a typed capsule onto the RFC 9297 capsule frame. Dispatches on the capsule type atom.
-spec encode_address_assign([address_entry()]) -> binary().
-spec encode_address_request([request_entry()]) -> binary().
-spec encode_route_advertisement([route_entry()]) -> binary().