An IPv4 or IPv6 address.
Construction
iex> Linx.IP.parse("10.0.0.5")
{:ok, ~IP"10.0.0.5"}
iex> Linx.IP.parse("fc00::1")
{:ok, ~IP"fc00::1"}The ~IP sigil
import Linx.IP and build addresses (or subnets, when the literal
contains /) at compile time:
iex> import Linx.IP
iex> ~IP"10.0.0.5"
~IP"10.0.0.5"
iex> ~IP"10.0.0.0/24"
~IP"10.0.0.0/24"Invalid input raises at compile time, so a bad literal can never reach the kernel.
Inspect
An IP renders as the same sigil that would build it — ~IP"10.0.0.5" —
so iex output round-trips back into source code.
Wire codec
encode/1 and decode/1 are the Linx.Netlink.Codec entry points: a
Linx.IP serializes to its raw bytes (4 for IPv4, 16 for IPv6), and the
family is recovered on decode from the byte length.
Summary
Functions
Parses a string into an Linx.IP — IPv4 or IPv6.
The ~IP sigil: builds an Linx.IP (or Linx.IP.Subnet if the literal
contains /) at compile time. Invalid input raises ArgumentError.
Renders an Linx.IP as a string — dotted-quad for IPv4, canonical
compressed for IPv6 (fc00::1, not fc00:0:0:0:0:0:0:1).
Types
Functions
Parses a string into an Linx.IP — IPv4 or IPv6.
The ~IP sigil: builds an Linx.IP (or Linx.IP.Subnet if the literal
contains /) at compile time. Invalid input raises ArgumentError.
Renders an Linx.IP as a string — dotted-quad for IPv4, canonical
compressed for IPv6 (fc00::1, not fc00:0:0:0:0:0:0:1).