code wiki / (root) / nx_ice_agent.nx

nx_ice_agent.nx

buildroot/runtime/nx_ice_agent.nx

5900 B144 linesdepth 6pulls 6 transitivereach 1 importersview sourcekind librarytopic ice
docsdependenciesstructsconstsfunctions

about

nx_ice_agent.nx -- SOVEREIGN ICE AGENT state machine (RFC 8445 6), NishiLang, composing nx_ice. The orchestration on top of the check-exchange primitives: an agent holds its LOCAL candidates and the peer's REMOTE candidates, forms candidate PAIRS (same component), orders them by candidate-pair priority (RFC 8445 6.1.2.3, via the overflow-safe comparator), schedules connectivity checks highest-priority first, records each check's result, and NOMINATES the best valid pair as the selected path. Pure logic over the primitives -- the actual check send/recv is nx_ice's ic_build_check / ic_verify_* over UDP; this module decides WHICH pair to check next and WHICH becomes the path. Zero third-party code. license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/ietf/rfc_8445

dependencies 2 imports · 1 importers

nx_syscalls.nx nx_ice.nx nx_ice_agent.nx nx_ice_agent_gate.nx

imports: nx_syscalls.nxnx_ice.nx

imported by: nx_ice_agent_gate.nx

structs

none

consts

12const AG_MAGIC_4096: i64 = 4096
14const AG_MAX_LOCAL: i64 = 8
15const AG_MAX_REMOTE: i64 = 8
16const AG_MAX_PAIRS: i64 = 64
19const AG_NLOCAL: i64 = 0
20const AG_NREMOTE: i64 = 1
21const AG_NPAIRS: i64 = 2
22const AG_CONTROLLING: i64 = 3
23const AG_NOMINATED: i64 = 4 // pair index of the SELECTED pair, or -1
26const AG_LOCAL0: i64 = 8
27const AG_REMOTE0: i64 = 40 // AG_LOCAL0 + AG_MAX_LOCAL*4
28const AG_PAIRS0: i64 = 72 // AG_REMOTE0 + AG_MAX_REMOTE*4
31const AG_ST_WAITING: i64 = 0
32const AG_ST_INPROGRESS: i64 = 1
33const AG_ST_SUCCEEDED: i64 = 2
34const AG_ST_FAILED: i64 = 3
35const AG_ST_SELECTED: i64 = 4

functions

37func ag_new(controlling: i64) -> *i64
called by 1: main calls 1: sys_mmap
43func ag_add_local(a: *i64, ip: i64, port: i64, prio: i64, comp: i64) -> i64
called by 1: main
51func ag_add_remote(a: *i64, ip: i64, port: i64, prio: i64, comp: i64) -> i64
called by 1: main
59func ag_local_prio(a: *i64, i: i64) -> i64 { return a[AG_LOCAL0 + i*4 + 2] }
60func ag_local_comp(a: *i64, i: i64) -> i64 { return a[AG_LOCAL0 + i*4 + 3] }
called by 1: ag_form_pairs
61func ag_remote_prio(a: *i64, i: i64) -> i64 { return a[AG_REMOTE0 + i*4 + 2] }
62func ag_remote_comp(a: *i64, i: i64) -> i64 { return a[AG_REMOTE0 + i*4 + 3] }
called by 1: ag_form_pairs
63func ag_pair_local(a: *i64, p: i64) -> i64 { return a[AG_PAIRS0 + p*4] }
64func ag_pair_remote(a: *i64, p: i64) -> i64 { return a[AG_PAIRS0 + p*4 + 1] }
65func ag_pair_state(a: *i64, p: i64) -> i64 { return a[AG_PAIRS0 + p*4 + 2] }
68func ag_pair_G(a: *i64, p: i64) -> i64 { if a[AG_CONTROLLING]==1 { return ag_local_prio(a, ag_pair_local(a,p)) } return ag_remote_prio(a, ag_pair_remote(a,p)) }
69func ag_pair_D(a: *i64, p: i64) -> i64 { if a[AG_CONTROLLING]==1 { return ag_remote_prio(a, ag_pair_remote(a,p)) } return ag_local_prio(a, ag_pair_local(a,p)) }
72func ag_swap(a: *i64, p: i64, q: i64) -> i64
called by 1: ag_form_pairs
83func ag_form_pairs(a: *i64) -> i64
116func ag_next_check(a: *i64) -> i64
called by 1: main calls 1: ag_pair_state
125func ag_result(a: *i64, p: i64, success: i64) -> i64
called by 1: main
133func ag_nominate(a: *i64) -> i64
called by 1: main calls 1: ag_pair_state