An IPv4 or IPv6 subnet — a network address and a prefix length, parsed from CIDR notation.
iex> Linx.IP.Subnet.parse("10.0.0.0/24")
{:ok, ~IP"10.0.0.0/24"}
iex> import Linx.IP
iex> ~IP"fc00::/16"
~IP"fc00::/16"Subnet operations
iex> import Linx.IP
iex> Linx.IP.Subnet.contains?(~IP"10.0.0.0/8", ~IP"10.99.0.5")
true
iex> Linx.IP.Subnet.network(~IP"10.0.42.5/24")
~IP"10.0.42.0"
iex> Linx.IP.Subnet.broadcast(~IP"10.0.42.5/24")
~IP"10.0.42.255"
Summary
Functions
Returns the IPv4 broadcast address of subnet, or nil for IPv6 (which
has no broadcast).
Returns whether subnet contains ip.
Returns subnet's network address — the input address with host bits
zeroed.
Parses a CIDR string ("10.0.0.0/24", "fc00::/16") into a subnet.
Types
@type t() :: %Linx.IP.Subnet{address: Linx.IP.t(), prefix: 0..128}
Functions
Returns the IPv4 broadcast address of subnet, or nil for IPv6 (which
has no broadcast).
Returns whether subnet contains ip.
False when the address families differ.
Returns subnet's network address — the input address with host bits
zeroed.
Parses a CIDR string ("10.0.0.0/24", "fc00::/16") into a subnet.