code wiki / (root) / cidr.nx

cidr.nx

buildroot/runtime/cidr.nx

3511 B101 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind tooltopic cidr
docsdependenciesstructsconstsfunctions

about

cidr.nx -- IPv4 CIDR (RFC 4632) parser + match. Parses "a.b.c.d/N" notation and provides address-in-range matching. Used by: ACLs, rate-limit rules, VPN route tables, service discovery (DHCP scope definition). IPv6 CIDR (a:b:c::d/prefix) deferred -- same algorithm but wider masks. Would share helpers with ipaddr.nx. Invariants: CIDR1 Prefix length range-checked: [0, 32] for IPv4. CIDR2 Host bits in the network address are IGNORED on parse (RFC 4632 permissive). Canonical form masks them out via cidr_network_address. CIDR3 Match is bit-exact against the computed network + mask; no regex, no partial parsing, no DNS resolution.

dependencies 2 imports · 0 importers

syscalls.nx ipaddr.nx cidr.nx

imports: syscalls.nxipaddr.nx

imported by: nobody (leaf or entry point)

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

main cidr_parse ipv4_parse cidr_mask cidr_contains cidr_mask ↻

structs

none

consts

21const CIDR_ERR_FORMAT: i64 = -1
22const CIDR_ERR_BAD_PREFIX: i64 = -2

functions

26func cidr_parse(s: *u8, n: i64, ip_out: *i64, prefix_out: *i64) -> i64 {
called by 1: main calls 1: ipv4_parse
63func cidr_mask(prefix: i64) -> i64 {
72func cidr_network_address(ip: i64, prefix: i64) -> i64 {
calls 1: cidr_mask
77func cidr_contains(network: i64, prefix: i64, addr: i64) -> i64 {
called by 1: main calls 1: cidr_mask
85func main() -> i64 {