Search documentation of macula

# macula_net (macula v4.4.9)

View Source

macula-net facade.

Sovereign IPv6 substrate for the macula realm. Crypto-derived addresses, multi-realm identity, no central allocation authority. See PLAN_MACULA_NET.md for the full spec.

This module orchestrates the slices:

- `macula_address` — pubkey -> IPv6
- `macula_tun` — kernel-side TUN
- `macula_net_transport_quic` — wire transport (Quinn)
- `macula_route_packet` — egress: TUN packet -> station
- `macula_deliver_packet` — ingress: envelope -> TUN

### Lifecycle

         {ok, _} = macula_net:start(#{
             realm_pubkey    => &lt;&lt;...32 bytes...&gt;&gt;,
             identity_pubkey => &lt;&lt;...32 bytes...&gt;&gt;,
             tun_name        => &lt;&lt;"macula0"&gt;&gt;,
             tun_mtu         => 1280,
             quic_port       => 4400,
             peers           => [
                 #{station   => &lt;&lt;"beam02"&gt;&gt;,
                   host      => "192.168.1.12", port =&gt; 4400,
                   addresses => [&lt;&lt;...16 bytes...&gt;&gt;]}
             ]
         }).

# Summary

## Types

node_config/0
peer_spec/0

## Functions

derive_address(RealmPk, IdentityPk)

Derive a macula-net IPv6 address. See `macula_address:derive/2`.

format_address(Addr)

Format a 16-byte IPv6 binary as RFC 5952 lowercase text.

own_address()

Return THIS node's macula-net address (set by `start/1`).

start(_)

Bring up macula-net for this node with the supplied config.

stop()

Bring everything down.

# Types

# node_config/0

    -type node_config() ::
              #{realm_pubkey := <<_:256>>,
                identity_pubkey := <<_:256>>,
                tun_name := binary(),
                tun_mtu := 1280..65535,
                quic_port := inet:port_number(),
                peers := [peer_spec()]}.

# peer_spec/0

    -type peer_spec() ::
              #{station := binary(),
                host := binary() | string(),
                port := inet:port_number(),
                addresses := [<<_:128>>]}.

# Functions

# derive_address(RealmPk, IdentityPk)

    -spec derive_address(<<_:256>>, <<_:256>>) -> <<_:128>>.

Derive a macula-net IPv6 address. See `macula_address:derive/2`.

# format_address(Addr)

    -spec format_address(<<_:128>>) -> binary().

Format a 16-byte IPv6 binary as RFC 5952 lowercase text.

# own_address()

    -spec own_address() -> <<_:128>> | undefined.

Return THIS node's macula-net address (set by `start/1`).

# start(_)

    -spec start(node_config()) -> {ok, pid()} | {error, term()}.

Bring up macula-net for this node with the supplied config.

# stop()

    -spec stop() -> ok.

Bring everything down.