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 flag | Arguments | Description |
|---|---|---|
| --version | none | Print 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-signatures | none | Print 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}]}. |
| ifaddrs | none | Print address-bearing network interfaces as JSON [{name,addr,mtu,up,loopback}]. |
| link | none | Dump all link devices and 64-bit RX/TX counters over rtnetlink as JSON. |
| route | none | Dump IPv4 and IPv6 kernel routing tables over rtnetlink as JSON [{dest,via,dev,proto,scope,metric,table,prefsrc}]. |
| rule | none | Dump policy routing rules over rtnetlink as JSON [{pref,family,table,action,from,to,fwmark,iif,oif,goto_target}]. |
| neigh | none | Dump ARP/NDP neighbor cache over rtnetlink as JSON [{ip,dev,state,mac,family,router,proxy}]. |
| counters | none | Dump 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 / context | Method signature | Description |
|---|---|---|
| context net: Net | net.dns_lookup(string) -> StrList | Resolve a hostname and return a StrList of IPv4/IPv6 address strings. |
| Net | net.dns_query(string, string, string) -> DnsResult | Send an RFC 1035 UDP query for (name, record_type, server_or_empty) and return a DnsResult. |
| Net | net.interfaces() -> IfaceList | net.links() -> LinkList | Return address-bearing interfaces (getifaddrs) or all rtnetlink link devices with 64-bit RX/TX counters. |
| Net | net.routes() -> RouteList | net.rules() -> RuleList | net.neighbors() -> NeighborList | Return kernel routing table entries, policy routing rules, or ARP/NDP neighbor table entries over rtnetlink. |
| Net | net.counters() -> CounterList | Return sorted kernel networking counters from /proc/net/{snmp,netstat,snmp6}. |
| Net | net.sockets(string, bool) -> SocketList | net.socket_summary(string) -> SocketSummary | Return /proc/net socket rows filtered by protocol ("" for all) and listen_only flag, or aggregate summary counts. |
| Net | net.scan(string, string) -> ScanResult | net.check(string, int) -> bool | Scan a port specification ("" for default top-15) with 750 ms timeout, or test a single TCP port without throwing. |
| Net | net.trace(string, int) -> TraceResult | Run a UDP/ICMP traceroute to host up to max_ttl hops and return a TraceResult. |
| Net / function | net.tcp_connect(string, int) -> TcpConn | net.tcp_listen(int) -> TcpListener | println(string) -> void | Open a blocking TCP client connection, bind a loopback/TCP listener on port, or print diagnostics to stderr. |
| DnsResult / DnsAnswer | r.rcode() | r.error() -> string | r.answers() -> DnsAnswerList | a.name() | a.type() | a.data() -> string | a.ttl() -> int | Inspect DNS response code, error text, and answer records (DnsAnswerList supports len() and at(int)). |
| Iface / IfaceList | i.name() | i.addr() -> string | i.mtu() -> int | i.up() | i.loopback() -> bool | list.len() -> int | list.at(int) -> Iface | Inspect interface name, IP address, MTU, and UP/LOOPBACK flags. |
| Link / LinkList | l.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() -> bool | Inspect rtnetlink device attributes and 64-bit receive/transmit counters (LinkList supports len() and at(int)). |
| Route / RouteList | r.dest() | r.via() | r.dev() | r.proto() | r.scope() | r.table() | r.prefsrc() -> string | r.metric() -> int | Inspect kernel routing table entry attributes (RouteList supports len() and at(int)). |
| Rule / RuleList | r.pref() | r.goto_target() -> int | r.family() | r.table() | r.action() | r.from() | r.to() | r.fwmark() | r.iif() | r.oif() -> string | Inspect policy routing rule priority, selectors, and action (RuleList supports len() and at(int)). |
| Neighbor / NeighborList | n.ip() | n.dev() | n.state() | n.mac() | n.family() -> string | n.router() | n.proxy() -> bool | Inspect ARP/NDP neighbor entry fields (NeighborList supports len() and at(int)). |
| Counter / CounterList | c.name() -> string | c.value() -> int | list.len() -> int | list.at(int) -> Counter | Inspect kernel protocol counter name (Section.Field) and 64-bit integer value. |
| Socket / SocketList | s.proto() | s.local() | s.remote() | s.state() | s.process() -> string | s.pid() -> int | Inspect socket protocol, local/remote endpoints, state, owning PID, and process name (SocketList supports len() and at(int)). |
| SocketSummary | s.total() | s.listening() | s.tcp() | s.tcp6() | s.udp() | s.udp6() | s.unix() -> int | s.state_count(string) -> int | Inspect aggregate socket counts by family and kernel TCP state name. |
| ScanResult / Port | sr.host() | sr.resolved() -> string | sr.open() | sr.closed() | sr.filtered() -> int | sr.ports() -> PortList | p.number() -> int | p.state() | p.service() -> string | Inspect TCP scan summary counts and per-port number, state (open, closed, filtered), and well-known service name. |
| TraceResult / Hop | tr.dest_ip() | tr.error() -> string | tr.hops() -> HopList | h.ttl() -> int | h.from() -> string | h.rtt_ms() -> float | h.reached() -> bool | Inspect traceroute target IP, error string, and per-hop TTL, responder IP, RTT in ms, and destination reached flag. |
| TcpConn / TcpListener | conn.send(string) -> void | conn.recv(int) -> string | conn.close() -> void | listener.accept() -> TcpConn | Send 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 function | Signature / annotation | Description |
|---|---|---|
| RestGet .. RestOptions | @"/path/:param" fn h(x: RestExchange) -> void implements RestGet | Bind an HTTP GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS route handler. |
| RestHandler | @"/path" fn h(x: RestExchange) -> void implements RestHandler | Bind a method-agnostic HTTP route handler. |
| CliCommand | @"cmd" fn h(x: RestExchange) -> void implements CliCommand | Bind a named CLI subcommand dispatched by rest_cli. |
| CliOption | @"--flag" fn h(x: RestExchange) -> void implements CliOption | Bind a CLI option flag (--flag=val or --flag val) evaluated before the command handler. |
| rest_config | rest_config(key: string, value: string) -> void | Configure server or CLI settings such as host, port, and session (ephemeral or global). |
| rest_route | rest_route(method: string, path: string, handler: string) -> void | Dynamically register an HTTP method and route pattern to a handler function name. |
| rest_serve / rest_stop | rest_serve() -> void | rest_stop() -> void | Start or stop the embedded standard HTTP server loop. |
| rest_cli | rest_cli(args: StrList) -> string | Dispatch CLI options, commands, or path requests in-process without opening a socket. |
| RestExchange | x.method() | x.path() | x.body() | x.param(string) | x.query(string) | x.header(string) -> string | Read request method, path, body, :param segment, query parameter, or header. |
| RestExchange | x.has_query(string) | x.has_header(string) -> bool | Check whether a query parameter or request header is present. |
| RestExchange | x.status(int) | x.set_header(string, string) | x.send(string) | x.json(string) -> void | Set response status code and headers, and emit plain text or application/json bodies. |
| RestExchange | x.get(string) -> string | x.set(string, string) -> void | x.increment(string) -> int | Read, write, or atomically increment session state keys across global or ephemeral exchanges. |
Exit codes
| Exit code | Category | Meaning |
|---|---|---|
| 0 | Success | CLI diagnostic command, dry-run check, or _lmcode_ program succeeded and all assertions passed. |
| 1 | Operation error | Direct CLI network operation failed (resolution error, unreachable endpoint, or insufficient raw socket privileges). |
| 2 | Usage error | Invalid CLI flag, malformed port range or argument, retired flag name, or invocation metadata mismatch. |
| 3 | Host / load error | Bytecode format error, schema hash mismatch, or unhandled runtime error (such as socket bind/connect failure). |
| 4 | Contract failure | An assertion (assert, assert_eq) or result schema contract failed during script execution. |