code wiki / (root) / nx_udp_rv.nx

nx_udp_rv.nx

buildroot/runtime/nx_udp_rv.nx

2584 B66 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind librarytopic udp
docsdependenciesstructsconstsfunctions

about

nx_udp_rv.nx -- native-lane UDP socket primitives. Twin of nx_udp.nx, but imports nx_syscalls.nx (RV64-numbered, @ifdef TARGET_X86_64) instead of nx_syscalls_x86_64.nx (raw x86_64 numbers). WHY THIS EXISTS: the native compiler (_offc/nx_compile_x86_native.elf) translates RV64 syscall numbers -> x86_64 at codegen time (nx_x86_64_ctx.nx: 198->41 socket, 200->49 bind, 206->44 sendto, 207->45 recvfrom, 73->7 poll, ...). Code that feeds it raw x86_64 numbers (nx_udp.nx -> nx_syscalls_x86_64.nx) hits a collision: x86_64 socket=41 == RV64 unshare=41, so socket() silently became unshare() and every UDP daemon died with -EINVAL before its banner. This is the same syscall-duality class as the documented fork()->openat() leak. Using nx_syscalls.nx (which yields RV64 numbers when TARGET_X86_64 is undefined, i.e. the native lane) makes the translation correct. This is the recipe the gated nx_netscope UDP code already uses successfully on the native lane. Use nx_udp_rv.* for daemons built via the native lane; use nx_udp.* for the nxc2.exe --target x86_64 (non-translating) lane.

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_udp_rv.nx nx_media_transport.nx nx_route_probe.nx

imports: nx_syscalls.nx

imported by: nx_media_transport.nxnx_route_probe.nx

structs

none

consts

none

functions

25func nx_udpr_open() -> i64
calls 1: sys_socket
30func nx_udpr_sa_any(out: *u8, port: i64) -> i64
called by 1: nx_udpr_bind_any
40func nx_udpr_bind_any(fd: i64, port: i64) -> i64
47func nx_udpr_sa_dest(out: *u8, a: i64, b: i64, c: i64, d: i64, port: i64) -> i64
58func nx_udpr_send(fd: i64, buf: *u8, n: i64, addr16: *u8) -> i64
64func nx_udpr_recv(fd: i64, buf: *u8, n: i64, from: *u8, fromlen: *i64) -> i64
called by 1: nx_route_probe_rtt calls 1: sys_recvfrom