Cooper. IPv4
(Cooper v0.1.0)
Copy Markdown
A parsed IPv4 address, with an optional CIDR prefix (CASC.md §6.7 --
127.0.0.1 or 127.0.0.1/32). 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 -- an out-of-range octet or CIDR prefix is a load-time
Ichor.Error, never a crash or a silently-accepted garbage value.
Summary
Functions
The block's broadcast address (its own prefix carried through unchanged).
Whether other's address falls within cidr's block.
The first usable host address in the block. For a /31 or /32, where every address is usable (no address is reserved as a pure network id), this is the network address itself.
The last usable host address in the block. For a /31 or /32, where every address is usable (no address is reserved as a pure broadcast id), this is the broadcast address itself.
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 a 4-tuple of 0..255
integers; prefix, if given, must be 0..32.
Types
@type t() :: %Cooper.IPv4{address: :inet.ip4_address(), prefix: 0..32 | nil}
Functions
The block's broadcast address (its own prefix carried through unchanged).
Whether other's address falls within cidr's block.
The first usable host address in the block. For a /31 or /32, where every address is usable (no address is reserved as a pure network id), this is the network address itself.
The last usable host address in the block. For a /31 or /32, where every address is usable (no address is reserved as a pure broadcast id), this is the broadcast address itself.
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.ip4_address(), 0..32 | nil) :: {:ok, t()} | {:error, String.t()}
Builds a validated address. address must be a 4-tuple of 0..255
integers; prefix, if given, must be 0..32.