Cooper. IPv6
(Cooper v0.1.0)
Copy Markdown
A parsed IPv6 address, with an optional CIDR prefix (CASC.md §6.7 --
::1 or ::1/128). new/2 is the only way to build one, and it's
the same validation Cooper.Actions runs on a bare literal at parse
time -- a malformed address or an out-of-range CIDR prefix is a
load-time Ichor.Error, never a crash or a silently-accepted garbage
value.
Unlike Cooper.IPv4, there's no broadcast/1 here -- IPv6 has no
broadcast address; its closest relative (multicast) isn't a function
of a single CIDR block the way an IPv4 broadcast address is, so
faking one would be misleading.
Summary
Functions
Whether other's address falls within cidr's block.
The first usable host address in the block. For a /127 or /128, where every address is usable, this is the network address itself.
The last usable host address in the block. For a /127 or /128, where every address is usable, this is the highest address in the block.
The netmask implied by the block's prefix, as a bare address (no prefix of its own).
The block's network address (its own prefix carried through unchanged).
Builds a validated address. address must be an 8-tuple of 0..65535
integers; prefix, if given, must be 0..128.
Types
@type t() :: %Cooper.IPv6{address: :inet.ip6_address(), prefix: 0..128 | nil}
Functions
Whether other's address falls within cidr's block.
The first usable host address in the block. For a /127 or /128, where every address is usable, this is the network address itself.
The last usable host address in the block. For a /127 or /128, where every address is usable, this is the highest address in the block.
The netmask implied by the block's prefix, as a bare address (no prefix of its own).
The block's network address (its own prefix carried through unchanged).
@spec new(:inet.ip6_address(), 0..128 | nil) :: {:ok, t()} | {:error, String.t()}
Builds a validated address. address must be an 8-tuple of 0..65535
integers; prefix, if given, must be 0..128.