code wiki / (root) / nx_nft_read.nx

nx_nft_read.nx

buildroot/runtime/nx_nft_read.nx

8410 B139 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_nft_read.nx -- R0/R1 of the SOVEREIGN NETFILTER ("our own iptables", from the syscall rung up). READ the kernel's "nat" table info via the LEGACY iptables getsockopt ABI (IPT_SO_GET_INFO) -- NO wheeler iptables binary. Grounds the DNAT mechanism: proves sovereign netfilter-comms + reveals the table (num_entries/size) we'll append a :443->:8444 DNAT to (R2), so DSM + Nishi COEXIST. READ-ONLY -- cannot disturb DSM's rules. The getsockopt return value is itself the grounding: 0=read ok ; -1 EPERM=need root (legacy ABI present) ; -92 ENOPROTOOPT= kernel is nft-only (switch to netlink) ; -2 ENOENT=no nat table. license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_nft_read.nx nx_nft_read_gate.nx

imports: nx_syscalls.nx

imported by: nx_nft_read_gate.nx

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

main sys_socket p sys_write pn sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_write ↻ sys_exit ↻ sys_mmap ↻ sys_close ru32 nr_validate nr_u16 nr_emit nr_u16 ↻ p ↻ pn ↻ nr_ip p ↻ pn ↻ nr_name sys_write ↻ p ↻ nr_hex sys_mmap ↻ sys_write ↻

structs

none

consts

14const NR_ENTRY_BYTES: i64 = 112
15const NR_EXTENSION_BYTES: i64 = 32
16const NR_TARGET_OFFSET: i64 = 88
17const NR_NEXT_OFFSET: i64 = 90

functions

9func p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 4: nr_ipnr_namenr_emitmain calls 1: sys_write
10func pn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var x: i64=v; if x<0 {b[0]=45;sys_write(1,b,1);x=0-x}; if x==0 {b[0]=48;sys_write(1,b,1);return 0} var d: i64=0; var y: i64=x; while y>0 {d=d+1;y=y/10} var i: i64=d-1; y=x; while i>=0 {b[i]=(48+(y%10)) as u8; y=y/10; i=i-1} sys_write(1,b,d); return 0 }
called by 3: nr_ipnr_emitmain calls 2: sys_mmapsys_write
11func ru32(b: *u8, o: i64) -> i64 { return (b[o] as i64) | ((b[o+1] as i64)<<8) | ((b[o+2] as i64)<<16) | ((b[o+3] as i64)<<24) }
called by 1: main
19func nr_u16(b: *u8, o: i64) -> i64 { return (b[o] as i64) | ((b[o+1] as i64)<<8) }
called by 2: nr_validatenr_emit
20func nr_hex(b: *u8, n: i64) -> i64
30func nr_ip(b: *u8) -> i64
called by 1: nr_emit calls 2: ppn
35func nr_name(b: *u8, n: i64) -> i64
called by 1: nr_emit calls 2: sys_writep
44func nr_validate(b: *u8, n: i64, expected: i64) -> i64
called by 2: mainmain calls 1: nr_u16
71func nr_emit(b: *u8, n: i64) -> i64
called by 1: main calls 6: nr_u16ppnnr_ipnr_namenr_hex
99func main() -> i64