code wiki / _hdl_build / nx_signaling_v2.nx

nx_signaling_v2.nx

buildroot/runtime/_hdl_build/nx_signaling_v2.nx

53459 B1070 linesdepth 6pulls 17 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_signaling_v2.nx -- bits-up N-party WebSocket signaling daemon for /video. Generation 2 of bench/nx_signaling.nx (1:1 rooms). What changed and why: - N-party rooms (NX_SIG2_MAX_PEERS=8 fds per room) -- the family call is more than two people. Relay = broadcast to every OTHER peer in the room; the browser JS addresses peers by its own from/to envelope fields and ignores frames not meant for it (server stays JSON-free, single responsibility: room membership + relay only). - Binds 127.0.0.1 ONLY. TLS termination happens in the sites daemon's fork-per-connection child, which pumps decrypted bytes to this loopback daemon (wss://nishifamily.com/signal/<room> on :8443) -- so the plaintext WS port is never exposed off-host. - Composes the SAME KAT'd primitives as v1: nx_websocket_upgrade (RFC 6455 4.1), nx_websocket_stream (5.3), nx_websocket_frame (5.7), nx_poll. Deploy: nx_sov_build_run nx_signaling_v2 -> push .sov.elf to the NAS. Gate: nx_signaling_v2_gate.nx (3-peer mesh relay proof over loopback). license_tier: ORIGINAL

dependencies 10 imports · 0 importers

nx_syscalls.nx nx_signal.nx nx_dgram_media.nx nx_sfu_select.nx nx_room_key.nx nx_websocket_frame.nx nx_websocket_stream.nx nx_websocket_upgrade.nx nx_poll.nx nx_sig2_txq.nx nx_signaling_v2.nx

imports: nx_syscalls.nxnx_signal.nxnx_dgram_media.nxnx_sfu_select.nxnx_room_key.nxnx_websocket_frame.nxnx_websocket_stream.nxnx_websocket_upgrade.nxnx_poll.nxnx_sig2_txq.nx

imported by: nobody (leaf or entry point)

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

main nx_signal_ignore nx_signal_action_new nx_signal_action_install sig2_atoi sys_mmap sig2_parse_ip sys_socket sys_exit sys_setsockopt sig2_sockaddr_loopback sys_bind sys_listen sys_write sig2_conn_ptr dgm_rx_init sfu_init sfu_act_ptr sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close nx_pollfd_set sys_now_us sys_mmap ↻ sys_clock_gettime_mono sig2_cascade_keepalive dgm_pack_frame dgm_wr_u32 sys_sendto sig2_find_room sig2_room_ptr sig2_alloc_room sig2_room_ptr ↻ sig2_udpm_upsert sig2_udpm_find sig2_emit_tel sys_openat_append

structs

none

consts

32const NX_SIG2_PORT: i64 = 8445
33const NX_SIG2_MAX_ROOMS: i64 = 64
34const NX_SIG2_MAX_PEERS: i64 = 8
35const NX_SIG2_MAX_CONNS: i64 = 128
36const NX_SIG2_HDR_BUF_BYTES: i64 = 4096
40const NX_SIG2_FRAME_BUF_BYTES: i64 = 65536
41const NX_SIG2_ROOM_ID_POOL_BYTES: i64 = 4096
42const NX_SIG2_ACCEPT_BACKLOG: i64 = 32
46const NX_SIG2_ROOM_BYTES: i64 = 96
52const R_ID_OFF: i64 = 0
53const R_ID_LEN: i64 = 1
54const R_USED: i64 = 2
55const R_NPEERS: i64 = 3
56const R_FD0: i64 = 4 // fd[i] at R_FD0 + i
59const NX_SIG2_CONN_BYTES: i64 = 16
153const NX_SIG2_TEL_LOG: *u8 = "/volume1/homes/elderwesto/nishihost/room_telemetry.log"
154const NX_SIG2_EMIT_US: i64 = 5000000
155const NX_SIG2_TEL_SLOTS: i64 = 1024 // MAX_ROOMS(64) * MAX_PEERS(8) * 2
164const NX_SIG2_UDP_PORT: i64 = 8471
165const NX_SIG2_UDPM: i64 = 16 // UDP members (addr16 | room:i64 | last_us:i64 = 32B each)
166const SIG2_DG_JOIN: i64 = 0x4A
167const SIG2_DG_ACK: i64 = 0x4B
168const SIG2_DG_ROOMFRAME: i64 = 0x4D // payload = a room-protocol BINARY frame (bridged <-> WS binary)
169const SIG2_DG_TEXT: i64 = 0x54 // payload = a room-protocol TEXT frame (bridged <-> WS text JSON)
170const SIG2_DG_CASCADE: i64 = 0x4E // CASCADE-JOIN (relay-to-relay, Octo-class): enroll the sender as a
536const SIG2_DOM_CHECK_US: i64 = 500000

functions

48func sig2_room_ptr(rooms: *u8, idx: i64) -> *i64
61func sig2_conn_ptr(conns: *u8, idx: i64) -> *i64
66func sig2_sockaddr_loopback(addr: *u8, port: i64) -> i64
called by 1: main
76func sig2_find_room(rooms: *u8, id_pool: *u8, id: *u8, id_len: i64) -> i64
95func sig2_alloc_room(rooms: *u8, id_pool: *u8, id_pool_off_p: *i64, id: *u8, id_len: i64) -> i64
119func sig2_join(rooms: *u8, ridx: i64, fd: i64) -> i64
called by 1: main calls 1: sig2_room_ptr
134func sig2_leave(rooms: *u8, ridx: i64, fd: i64) -> i64
called by 1: main calls 1: sig2_room_ptr
174func sig2_atoi(s: *u8) -> i64
called by 1: main
179func sig2_parse_ip(s: *u8, out: *u8) -> i64
called by 1: main
191func sig2_udpm_find(m: *u8, addr: *u8) -> i64
205func sig2_udpm_upsert(m: *u8, addr: *u8, ridx: i64, now: i64) -> i64
227func sig2_udp_fanout(ufd: i64, m: *u8, ridx: i64, except: i64, dkind: i64, body: *u8, blen: i64,
250func sig2_telw(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
called by 2: sig2_emit_telsig2_tee_qoe calls 1: sys_write
251func sig2_teln(fd: i64, v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m} let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1} while m>0 {t[k]=(48+(m%10)) as u8; m=m/10; k=k+1} var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1} sys_write(fd, bb, k); return 0 }
255func sig2_emit_tel(rooms: *u8, tel: *i64, now: i64) -> i64
284func sig2_slot_of_fd(conns: *u8, fd: i64) -> i64
298func sig2_memidx(sfu_mem: *i64, mem_ids: *u8, mcount_p: *i64, id: *u8) -> i64
325func sig2_room_cand(conns: *u8, cmx: *i64, ridx: i64, cand: *i64) -> i64
345func sig2_broadcast(rooms: *u8, ridx: i64, from_fd: i64,
405func sig2_room_id_off(path: *u8, path_len: i64) -> i64
called by 1: main
422func sig2_udp_enroll(ufd: i64, pkt: *u8, rinfo: *i64, from: *u8, hctx: *i64, cflags: *i64, is_casc: i64) -> i64
449func sig2_udp_handle(ufd: i64, pkt: *u8, n: i64, from: *u8, hctx: *i64) -> i64
507func sig2_tee_qoe(pp: *u8, plen: i64, ridx: i64) -> i64
537func sig2_audio_activity(fd: i64, ridx: i64, pp: *u8, plen: i64, sfuctx: *i64, midx: i64) -> i64
564func sig2_broadcast_plain(sfuctx: *i64, ridx: i64, buf: *u8, n: i64) -> i64
577func sig2_lprod_eval(sfuctx: *i64, smidx: i64) -> i64
602func sig2_handle_frame(fd: i64, ridx: i64, rooms: *u8, buf: *u8, buf_cap: i64, tel: *i64, wuctx: *i64, sfuctx: *i64) -> i64
701func sig2_cascade_keepalive(ufd: i64, home_addr: *u8, room: *u8, roomlen: i64, hctx: *i64, cflags: *i64) -> i64
722func main(argc: i64, argv: *i64) -> i64