struct

Cl8r::IPAM::IPv4CIDR

Inherits Struct < Value < Object

Represents an IPv4 Classless Inter-Domain Routing (CIDR) subnet block. Normalizes the network base address upon initialization and provides subnet slicing.

Constructors

new(network : IPv4Address, prefix : Int32)

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

Source
parse(cidr_str : String) : IPv4CIDR

Parses a CIDR string (e.g. "192.168.1.0/24") into an IPv4CIDR struct.

Source

Class methods

mask_for_prefix(prefix : Int32) : UInt32

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

Source

Instance methods

broadcast

Returns the broadcast address for this subnet.

Source
contains?(address : IPv4Address) : Bool

Returns true if this CIDR block contains the specified IPv4Address.

Source
contains?(other : IPv4CIDR) : Bool

Returns true if this CIDR block completely encloses another IPv4CIDR.

Source
first_usable

Returns the first usable host IP in the subnet.

Source
host_at(offset : Int) : IPv4Address

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

Source
last_usable

Returns the last usable host IP in the subnet.

Source
mask
Source
netmask

Returns the subnet mask as an IPv4Address.

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

Returns true if this CIDR block overlaps with another IPv4CIDR.

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

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. "192.168.1.0/24").

Source
total_hosts

Computes total host addresses in this subnet (including network and broadcast).

Source
usable_hosts

Computes usable host count taking RFC 3021 (/31) and /32 into account.

Source
wildcard_mask

Returns the wildcard mask (inverted subnet mask) as an IPv4Address.

Source