macula_tun_reader_proxy (macula v3.15.1)

View Source

Owns the inbound TUN-reader mailbox.

The native TUN reader (see macula_tun:start_reader/2) sends {macula_net_packet, Handle, Payload} to a registered consumer process. This module IS that consumer — a long-lived gen_server that dispatches every received payload to the configured dispatch_fn. Production wires it to macula_route_packet:dispatch/1; tests pass a capture fun.

Replaces an earlier hand-rolled receive...loop inside macula_net per the workspace rule "every receive loop is a gen_server candidate". OTP supervision, restart semantics, and sys/dbg tracing all come for free.

Summary

Types

config/0

-type config() :: #{dispatch_fn := dispatch_fn()}.

dispatch_fn/0

-type dispatch_fn() :: fun((Payload :: binary()) -> any()).

Functions

code_change(OldVsn, State, Extra)

handle_call(Other, From, State)

handle_cast(Msg, State)

handle_info(Other, State)

init(_)

start_link(Config)

-spec start_link(config()) -> {ok, pid()} | {error, term()}.

stop(Pid)

-spec stop(pid()) -> ok.

terminate(Reason, State)