nx_ice.nx
buildroot/runtime/nx_ice.nx
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
imports: nx_syscalls.nxnx_stun.nx
imported by: nx_ice_agent.nxnx_ice_check_gate.nxnx_ice_gate.nx
structs
| none |
consts
| 20 | const ICE_ATTR_USERNAME: i64 = 0x0006 |
| 21 | const ICE_ATTR_PRIORITY: i64 = 0x0024 |
| 22 | const ICE_ATTR_USE_CANDIDATE: i64 = 0x0025 |
| 23 | const ICE_ATTR_ICE_CONTROLLED: i64 = 0x8029 |
| 24 | const ICE_ATTR_ICE_CONTROLLING: i64 = 0x802A |
| 25 | const ICE_ATTR_SOFTWARE: i64 = 0x8022 |
| 28 | const ICE_TYPEPREF_HOST: i64 = 126 |
| 29 | const ICE_TYPEPREF_PRFLX: i64 = 110 |
| 30 | const ICE_TYPEPREF_SRFLX: i64 = 100 |
| 31 | const ICE_TYPEPREF_RELAY: i64 = 0 |
functions
| 34 | func ic_priority(type_pref: i64, local_pref: i64, component_id: i64) -> i64 |
| 39 | func ic_write_attr(buf: *u8, off: i64, atype: i64, val: *u8, vlen: i64, pad: i64) -> i64 |
| 49 | func ic_write_priority(buf: *u8, off: i64, priority: i64) -> i64 |
| 53 | func ic_write_role(buf: *u8, off: i64, atype: i64, tb8: *u8) -> i64 |
| 60 | func 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 } |
| 63 | func ic_imin(a: i64, b: i64) -> i64 { if a<b { return a } return b } called by 1: ic_pair_cmp |
| 64 | func ic_imax(a: i64, b: i64) -> i64 { if a>b { return a } return b } called by 1: ic_pair_cmp |
| 66 | func ic_pair_cmp(g1: i64, d1: i64, g2: i64, d2: i64) -> i64 |
| 80 | func ic_build_check(buf: *u8, txid: *u8, sw: *u8, swlen: i64, priority: i64, tb8: *u8, called by 2: mainmain calls 9: st_write_headeric_write_attric_write_priorityic_write_rolest_put16sys_mmap+3 |
| 106 | func ic_find_attr(msg: *u8, msglen: i64, atype: i64) -> i64 |
| 119 | func ic_has_use_candidate(msg: *u8, msglen: i64) -> i64 { if ic_find_attr(msg, msglen, ICE_ATTR_USE_CANDIDATE) >= 0 { return 1 } return 0 } |
| 122 | func ic_verify_fingerprint(msg: *u8, msglen: i64) -> i64 |
| 132 | func ic_verify_mi(msg: *u8, msglen: i64, key: *u8, keylen: i64) -> i64 |
| 148 | func ic_build_success_response(buf: *u8, txid: *u8, peer_port: i64, peer_addr: i64, key: *u8, keylen: i64) -> i64 called by 1: main calls 7: st_write_headerst_put16st_xma_encodesys_mmapst_message_integrityst_fingerprint+1 |