lmnet reference

Complete command-line subcommands and flags, Net context types and methods, standard lmcode_std_v3 REST and CLI interfaces, and exit codes for lmnet v0.1.1.

Host and CLI subcommands

Command or flagArgumentsDescription
--versionnonePrint the lmnet version string and exit 0.
--lmcode-schema[--json]Print a human-readable schema summary, or exact embedded host schema JSON bytes when --json is passed.
--lmcode-signaturesnonePrint all canonical context, function, and method signatures (host + 226 standard library signatures).
--lmcode[--dry-run] <file.dslb>...Load and execute (or dry-validate without network/file effects) compiled LMScript bytecode files.
ping<host> [iputils-options]Execute the embedded upstream iputils ping engine.
tracepath<host> [iputils-options]Execute the embedded upstream iputils tracepath engine.
iperf3[iperf3-options]Execute the embedded upstream iperf 3.22 throughput client or server engine.
dns<host>Resolve host addresses via getaddrinfo and print a JSON array of IP strings.
dig<name> [TYPE] [@server]Send an RFC 1035 UDP DNS query (3 s timeout) and print {"rcode":...,"answers":[{name,type,ttl,data}]}.
ifaddrsnonePrint address-bearing network interfaces as JSON [{name,addr,mtu,up,loopback}].
linknoneDump all link devices and 64-bit RX/TX counters over rtnetlink as JSON.
routenoneDump IPv4 and IPv6 kernel routing tables over rtnetlink as JSON [{dest,via,dev,proto,scope,metric,table,prefsrc}].
rulenoneDump policy routing rules over rtnetlink as JSON [{pref,family,table,action,from,to,fwmark,iif,oif,goto_target}].
neighnoneDump ARP/NDP neighbor cache over rtnetlink as JSON [{ip,dev,state,mac,family,router,proxy}].
countersnoneDump kernel protocol counters from /proc/net/{snmp,netstat,snmp6} as a flat sorted JSON object.
sockets[tcp|udp|unix] [--listen] [--summary]Dump /proc/net socket tables with PID/process attribution as JSON, or ss-style aggregate counts with --summary.
trace<host> [maxttl]Run an IPv4 UDP/ICMP traceroute (default 30 hops) and print {"dest_ip":...,"hops":[{ttl,from,rtt_ms,reached}]}.
scan<host> [--ports SPEC] [--timeout MS] [--concurrency N]Run a parallel TCP connect port scan (default top-15 ports, 750 ms timeout, 64 workers) and print JSON verdicts.
pipe<host> <port> | --listen <port> [--forever]Stream raw bytes between stdin/stdout and a TCP connection or listening port.

Host context net: Net and inspection types

Type / contextMethod signatureDescription
context net: Netnet.dns_lookup(string) -> StrListResolve a hostname and return a StrList of IPv4/IPv6 address strings.
Netnet.dns_query(string, string, string) -> DnsResultSend an RFC 1035 UDP query for (name, record_type, server_or_empty) and return a DnsResult.
Netnet.interfaces() -> IfaceList | net.links() -> LinkListReturn address-bearing interfaces (getifaddrs) or all rtnetlink link devices with 64-bit RX/TX counters.
Netnet.routes() -> RouteList | net.rules() -> RuleList | net.neighbors() -> NeighborListReturn kernel routing table entries, policy routing rules, or ARP/NDP neighbor table entries over rtnetlink.
Netnet.counters() -> CounterListReturn sorted kernel networking counters from /proc/net/{snmp,netstat,snmp6}.
Netnet.sockets(string, bool) -> SocketList | net.socket_summary(string) -> SocketSummaryReturn /proc/net socket rows filtered by protocol ("" for all) and listen_only flag, or aggregate summary counts.
Netnet.scan(string, string) -> ScanResult | net.check(string, int) -> boolScan a port specification ("" for default top-15) with 750 ms timeout, or test a single TCP port without throwing.
Netnet.trace(string, int) -> TraceResultRun a UDP/ICMP traceroute to host up to max_ttl hops and return a TraceResult.
Net / functionnet.tcp_connect(string, int) -> TcpConn | net.tcp_listen(int) -> TcpListener | println(string) -> voidOpen a blocking TCP client connection, bind a loopback/TCP listener on port, or print diagnostics to stderr.
DnsResult / DnsAnswerr.rcode() | r.error() -> string | r.answers() -> DnsAnswerList | a.name() | a.type() | a.data() -> string | a.ttl() -> intInspect DNS response code, error text, and answer records (DnsAnswerList supports len() and at(int)).
Iface / IfaceListi.name() | i.addr() -> string | i.mtu() -> int | i.up() | i.loopback() -> bool | list.len() -> int | list.at(int) -> IfaceInspect interface name, IP address, MTU, and UP/LOOPBACK flags.
Link / LinkListl.name() | l.mac() -> string | l.index() | l.mtu() | l.txqlen() | l.rx_bytes() | l.rx_packets() | l.rx_errors() | l.rx_dropped() | l.tx_bytes() | l.tx_packets() | l.tx_errors() | l.tx_dropped() -> int | l.up() | l.loopback() -> boolInspect rtnetlink device attributes and 64-bit receive/transmit counters (LinkList supports len() and at(int)).
Route / RouteListr.dest() | r.via() | r.dev() | r.proto() | r.scope() | r.table() | r.prefsrc() -> string | r.metric() -> intInspect kernel routing table entry attributes (RouteList supports len() and at(int)).
Rule / RuleListr.pref() | r.goto_target() -> int | r.family() | r.table() | r.action() | r.from() | r.to() | r.fwmark() | r.iif() | r.oif() -> stringInspect policy routing rule priority, selectors, and action (RuleList supports len() and at(int)).
Neighbor / NeighborListn.ip() | n.dev() | n.state() | n.mac() | n.family() -> string | n.router() | n.proxy() -> boolInspect ARP/NDP neighbor entry fields (NeighborList supports len() and at(int)).
Counter / CounterListc.name() -> string | c.value() -> int | list.len() -> int | list.at(int) -> CounterInspect kernel protocol counter name (Section.Field) and 64-bit integer value.
Socket / SocketLists.proto() | s.local() | s.remote() | s.state() | s.process() -> string | s.pid() -> intInspect socket protocol, local/remote endpoints, state, owning PID, and process name (SocketList supports len() and at(int)).
SocketSummarys.total() | s.listening() | s.tcp() | s.tcp6() | s.udp() | s.udp6() | s.unix() -> int | s.state_count(string) -> intInspect aggregate socket counts by family and kernel TCP state name.
ScanResult / Portsr.host() | sr.resolved() -> string | sr.open() | sr.closed() | sr.filtered() -> int | sr.ports() -> PortList | p.number() -> int | p.state() | p.service() -> stringInspect TCP scan summary counts and per-port number, state (open, closed, filtered), and well-known service name.
TraceResult / Hoptr.dest_ip() | tr.error() -> string | tr.hops() -> HopList | h.ttl() -> int | h.from() -> string | h.rtt_ms() -> float | h.reached() -> boolInspect traceroute target IP, error string, and per-hop TTL, responder IP, RTT in ms, and destination reached flag.
TcpConn / TcpListenerconn.send(string) -> void | conn.recv(int) -> string | conn.close() -> void | listener.accept() -> TcpConnSend raw bytes, receive up to N bytes ("" on EOF), idempotently close a connection, or accept an incoming TCP peer.

Standard lmcode_std_v3 REST and CLI interfaces

Interface or functionSignature / annotationDescription
RestGet .. RestOptions@"/path/:param" fn h(x: RestExchange) -> void implements RestGetBind an HTTP GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS route handler.
RestHandler@"/path" fn h(x: RestExchange) -> void implements RestHandlerBind a method-agnostic HTTP route handler.
CliCommand@"cmd" fn h(x: RestExchange) -> void implements CliCommandBind a named CLI subcommand dispatched by rest_cli.
CliOption@"--flag" fn h(x: RestExchange) -> void implements CliOptionBind a CLI option flag (--flag=val or --flag val) evaluated before the command handler.
rest_configrest_config(key: string, value: string) -> voidConfigure server or CLI settings such as host, port, and session (ephemeral or global).
rest_routerest_route(method: string, path: string, handler: string) -> voidDynamically register an HTTP method and route pattern to a handler function name.
rest_serve / rest_stoprest_serve() -> void | rest_stop() -> voidStart or stop the embedded standard HTTP server loop.
rest_clirest_cli(args: StrList) -> stringDispatch CLI options, commands, or path requests in-process without opening a socket.
RestExchangex.method() | x.path() | x.body() | x.param(string) | x.query(string) | x.header(string) -> stringRead request method, path, body, :param segment, query parameter, or header.
RestExchangex.has_query(string) | x.has_header(string) -> boolCheck whether a query parameter or request header is present.
RestExchangex.status(int) | x.set_header(string, string) | x.send(string) | x.json(string) -> voidSet response status code and headers, and emit plain text or application/json bodies.
RestExchangex.get(string) -> string | x.set(string, string) -> void | x.increment(string) -> intRead, write, or atomically increment session state keys across global or ephemeral exchanges.

Exit codes

Exit codeCategoryMeaning
0SuccessCLI diagnostic command, dry-run check, or _lmcode_ program succeeded and all assertions passed.
1Operation errorDirect CLI network operation failed (resolution error, unreachable endpoint, or insufficient raw socket privileges).
2Usage errorInvalid CLI flag, malformed port range or argument, retired flag name, or invocation metadata mismatch.
3Host / load errorBytecode format error, schema hash mismatch, or unhandled runtime error (such as socket bind/connect failure).
4Contract failureAn assertion (assert, assert_eq) or result schema contract failed during script execution.