macula_net (macula v4.1.1)

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:

Lifecycle

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

Summary

Functions

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

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

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

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

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.