Search documentation of macula

# macula_route_packet_ipv6 (macula v4.4.9)

View Source

Minimal IPv6 header parser for macula-net routing.

We only ever care about source + destination addresses (the routing layer is dst-based; src is preserved for ICMPv6 error replies). Per RFC 8200 the IPv6 fixed header is 40 bytes:

         bytes 0..1   version (4) + traffic class (8) + flow label start
         bytes 2..3   flow label rest
         bytes 4..5   payload length
         byte 6       next header
         byte 7       hop limit
         bytes 8..23  source address (128 bits)
         bytes 24..39 destination address (128 bits)

# Summary

## Types

address/0
header/0

## Functions

dst(_)

Quick extract of destination address (16 bytes).

parse_header(_)

Parse the 40-byte IPv6 fixed header. Returns the full header map. Raises `badarg` if the input is shorter than 40 bytes or version != 6.

src(_)

Quick extract of source address (16 bytes), without building the full header map. Useful on the hot path.

# Types

# address/0

    -type address() :: <<_:128>>.

# header/0

    -type header() ::
              #{version := 6,
                traffic_class := non_neg_integer(),
                flow_label := non_neg_integer(),
                payload_len := non_neg_integer(),
                next_header := non_neg_integer(),
                hop_limit := non_neg_integer(),
                src := address(),
                dst := address()}.

# Functions

# dst(_)

    -spec dst(binary()) -> address().

Quick extract of destination address (16 bytes).

# parse_header(_)

    -spec parse_header(binary()) -> header().

Parse the 40-byte IPv6 fixed header. Returns the full header map. Raises `badarg` if the input is shorter than 40 bytes or version != 6.

# src(_)

    -spec src(binary()) -> address().

Quick extract of source address (16 bytes), without building the full header map. Useful on the hot path.