code wiki / bin / nx_netdiag.nx

nx_netdiag.nx

buildroot/runtime/bin/nx_netdiag.nx

5953 B152 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_netdiag.nx -- sovereign NishiLang network path diagnostic. Substrate-honesty principle (same as nx_wire_logger): any time we'd reach for ping/curl/traceroute to ask "can I reach X, and how fast?", we owe ourselves a native primitive. This does BOUNDED non-blocking TCP-connect probes (via sys_poll) to a small table of candidate paths, classifies each CONNECTED(ms) / TIMEOUT / REFUSED, and prints a one-screen verdict + fix in a SINGLE run -- the 10-second / 3-step answer to "why is it shit on LAN and fine on the internet?". No external tools. Composes only nx_syscalls (socket/connect/poll). license_tier: ORIGINAL lineage_id: nishi_netdiag_q10

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_netdiag.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nd_puts sys_write nd_slen nd_tcp_probe sys_mmap nd_make_sockaddr sys_socket sys_now_us sys_mmap ↻ sys_clock_gettime_mono sys_connect nd_puts ↻ nd_putdec sys_write ↻ sys_mmap ↻ sys_close nd_report nd_puts ↻ nd_putdec ↻

structs

none

consts

17const ND_AF_INET: i64 = 2
18const ND_SOCK_NB: i64 = 2049 // SOCK_STREAM(1) | SOCK_NONBLOCK(0o4000=2048)
19const ND_POLLOUT: i64 = 4
20const ND_POLLERR: i64 = 8
21const ND_POLLHUP: i64 = 16
23const ND_TIMEOUT: i64 = 0 - 1
24const ND_REFUSED: i64 = 0 - 2
25const ND_SOCKFAIL: i64 = 0 - 3
26const ND_DEBUG: i64 = 0
27const ND_SYS_POLL: i64 = 7 // x86_64 poll(2); netdiag is x86_64-only, so pin it

functions

29func nd_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != 0 { n = n + 1 } return n }
called by 1: nd_puts
30func nd_puts(s: *u8) -> i64 { sys_write(1, s, nd_slen(s)); return 0 }
31func nd_putdec(v: i64) -> i64
46func nd_make_sockaddr(out: *u8, a: i64, b: i64, c: i64, d: i64, port: i64) -> i64
called by 1: nd_tcp_probe
62func nd_tcp_probe(a: i64, b: i64, c: i64, d: i64, port: i64, timeout_ms: i64) -> i64
115func nd_report(label: *u8, r: i64) -> i64
called by 1: main calls 2: nd_putsnd_putdec
128func main() -> i64