struct

Cl8r::IPAM::IPv6CIDR

Inherits Struct < Value < Object

Represents an IPv6 Classless Inter-Domain Routing (CIDR) subnet prefix. Handles 128-bit bitwise prefix arithmetic and zero-allocation subnet slicing.

Constructors

new(network : IPv6Address, prefix : Int32)

Initializes an IPv6CIDR with a network address and prefix (0..128). Normalizes host bits in the network address to 0.

Source
parse(cidr_str : String) : IPv6CIDR

Parses a CIDR string (e.g. "fd41:10::/64") into an IPv6CIDR struct.

Source

Class methods

mask_for_prefix(prefix : Int32) : UInt128

Computes the 128-bit subnet mask for a given prefix length.

Source

Instance methods

contains?(address : IPv6Address) : Bool

Returns true if this CIDR block contains the specified IPv6Address.

Source
contains?(other : IPv6CIDR) : Bool

Returns true if this CIDR block completely encloses another IPv6CIDR.

Source
host_at(offset : Int | UInt128) : IPv6Address

Calculates the IP address at a specific numerical offset within the subnet.

Source
mask
Source
netmask

Returns the subnet mask as an IPv6Address.

Source
network
Source
overlaps?(other : IPv6CIDR) : Bool

Returns true if this CIDR block overlaps with another IPv6CIDR.

Source
prefix
Source
subnets(new_prefix : Int32) : Iterator(IPv6CIDR)

Slices this subnet into child subnets of prefix new_prefix without intermediate allocations.

Source
to_s(io : IO) : Nil

Outputs CIDR string representation (e.g. "fd41:10::/64").

Source
usable_hosts

Computes usable host count. For /128, returns 1; for /127, returns 2; otherwise 2^(128 - prefix).

Source