code wiki / _hdl_build / nx_cidr.nx
nx_cidr.nx
buildroot/runtime/_hdl_build/nx_cidr.nx
about
nx_cidr.nx -- CIDR longest-prefix matching for the access-provisioning wall (the network-tier + IP-allowlist
layers). Pure logic over caller rule arrays; reuses nx_ipaddr (ipv4_parse) for string parsing -- aligns with
the existing net stack, does NOT reinvent IP parsing. Used by nx_nettier (PUBLIC/LAN/VPN classification) and
any per-area IP allowlist. license_tier: ORIGINAL
dependencies 2 imports · 2 importers
imports: nx_ipaddr.nxnx_syscalls.nx
imported by: nx_cidr_gate.nxnx_nettier.nx
structs
| none |
consts
| 44 | const CIDR_ERR_FORMAT: i64 = 0 - 1 |
| 45 | const CIDR_ERR_BAD_PREFIX: i64 = 0 - 2 |
functions
| 9 | func cidr_mask(prefix: i64) -> i64 |
| 17 | func cidr_match(ip: i64, netw: i64, prefix: i64) -> i64 |
| 26 | func cidr_tier(ip: i64, nets: *i64, prefixes: *i64, tiers: *i64, n: i64, default_tier: i64) -> i64 |
| 40 | func cidr_ip(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return ipv4_parse(s, n) } |
| 48 | func cidr_parse(s: *u8, n: i64, ip_out: *i64, prefix_out: *i64) -> i64 |
| 62 | func cidr_network_address(ip: i64, prefix: i64) -> i64 { return (ip & cidr_mask(prefix)) & 0xFFFFFFFF } |
| 64 | func cidr_contains(network: i64, prefix: i64, addr: i64) -> i64 { return cidr_match(addr, network, prefix) } |