code wiki / (root) / nx_ice.nx

nx_ice.nx

buildroot/runtime/nx_ice.nx

8765 B166 linesdepth 5pulls 5 transitivereach 4 importersview sourcekind librarytopic ice
docsdependenciesstructsconstsfunctions

about

nx_ice.nx -- SOVEREIGN ICE (RFC 8445) primitives, NishiLang from the first byte up, composing nx_stun. Rung 2 of the Nishi P2P interop stack (rung 1 = nx_stun). ICE is how two peers behind NATs find a working path to each other: each gathers candidate addresses (host / server-reflexive via STUN / relayed), ranks them by PRIORITY, pairs them, and runs STUN Binding "connectivity checks" over each pair until one succeeds. This module provides the ICE-specific pieces on top of the sovereign STUN codec, with ZERO third-party code (no libnice, no libjuice), and KAT'd byte-exact against RFC 5769's own sample request. Provides: - the ICE STUN attributes: PRIORITY, USE-CANDIDATE, ICE-CONTROLLED, ICE-CONTROLLING, USERNAME - candidate PRIORITY (RFC 8445 5.1.2.1): 2^24*type_pref + 2^8*local_pref + (256 - component_id) - candidate-PAIR priority as an overflow-safe COMPARATOR (the 2^32 form overflows i64; we only ever need to order pairs, so we compare (min, max, controlling>controlled) lexicographically -- RFC 8445 6.1.2.3) - a full connectivity-check Binding Request builder (SOFTWARE, PRIORITY, ICE-CONTROLLED, USERNAME, MESSAGE-INTEGRITY, FINGERPRINT) that reproduces RFC 5769 2.1 byte-exact license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/ietf/rfc_8445 + rfc_5769

dependencies 2 imports · 3 importers

nx_syscalls.nx nx_stun.nx nx_ice.nx nx_ice_agent.nx nx_ice_check_gate.nx nx_ice_gate.nx

imports: nx_syscalls.nxnx_stun.nx

imported by: nx_ice_agent.nxnx_ice_check_gate.nxnx_ice_gate.nx

structs

none

consts

20const ICE_ATTR_USERNAME: i64 = 0x0006
21const ICE_ATTR_PRIORITY: i64 = 0x0024
22const ICE_ATTR_USE_CANDIDATE: i64 = 0x0025
23const ICE_ATTR_ICE_CONTROLLED: i64 = 0x8029
24const ICE_ATTR_ICE_CONTROLLING: i64 = 0x802A
25const ICE_ATTR_SOFTWARE: i64 = 0x8022
28const ICE_TYPEPREF_HOST: i64 = 126
29const ICE_TYPEPREF_PRFLX: i64 = 110
30const ICE_TYPEPREF_SRFLX: i64 = 100
31const ICE_TYPEPREF_RELAY: i64 = 0

functions

34func ic_priority(type_pref: i64, local_pref: i64, component_id: i64) -> i64
called by 2: mainmain
39func ic_write_attr(buf: *u8, off: i64, atype: i64, val: *u8, vlen: i64, pad: i64) -> i64
called by 1: ic_build_check calls 1: st_put16
49func ic_write_priority(buf: *u8, off: i64, priority: i64) -> i64
called by 1: ic_build_check calls 2: st_put16st_put32
53func ic_write_role(buf: *u8, off: i64, atype: i64, tb8: *u8) -> i64
called by 1: ic_build_check calls 1: st_put16
60func ic_write_use_candidate(buf: *u8, off: i64) -> i64 { st_put16(buf, off, ICE_ATTR_USE_CANDIDATE); st_put16(buf, off+2, 0); return off+4 }
called by 2: mainmain calls 1: st_put16
63func ic_imin(a: i64, b: i64) -> i64 { if a<b { return a } return b }
called by 1: ic_pair_cmp
64func ic_imax(a: i64, b: i64) -> i64 { if a>b { return a } return b }
called by 1: ic_pair_cmp
66func ic_pair_cmp(g1: i64, d1: i64, g2: i64, d2: i64) -> i64
called by 2: ag_form_pairsmain calls 2: ic_iminic_imax
80func ic_build_check(buf: *u8, txid: *u8, sw: *u8, swlen: i64, priority: i64, tb8: *u8,
106func ic_find_attr(msg: *u8, msglen: i64, atype: i64) -> i64
119func ic_has_use_candidate(msg: *u8, msglen: i64) -> i64 { if ic_find_attr(msg, msglen, ICE_ATTR_USE_CANDIDATE) >= 0 { return 1 } return 0 }
called by 1: main calls 1: ic_find_attr
122func ic_verify_fingerprint(msg: *u8, msglen: i64) -> i64
132func ic_verify_mi(msg: *u8, msglen: i64, key: *u8, keylen: i64) -> i64
148func ic_build_success_response(buf: *u8, txid: *u8, peer_port: i64, peer_addr: i64, key: *u8, keylen: i64) -> i64