rtnetlink interface addresses — the RTM_*ADDR messages.
list/1 and list/2 read addresses; add/4 and delete/4 assign and
remove them. IPv4 and IPv6 are both supported — the address family is
detected from the IP value.
Address fields (:address, :local) on a decoded %Address{} are
Linx.IP structs, not raw bytes; they accept either an Linx.IP or a
string at the verb's input.
Example
{:ok, sock} = Rtnl.open()
:ok = Address.add(sock, "eth0", "10.0.0.5", 24)
:ok = Address.add(sock, "eth0", "fd00::5", 64)
{:ok, addrs} = Address.list(sock, "eth0")
# => [#Linx.Netlink.Rtnl.Address<10.0.0.5/24 ifindex=2>,
# #Linx.Netlink.Rtnl.Address<fd00::5/64 ifindex=2>]
:ok = Address.delete(sock, "eth0", "10.0.0.5", 24)The wire format — struct ifaddrmsg and the IFA_* attributes
(include/uapi/linux/if_addr.h) — is declared with the
Linx.Netlink.Codec DSL.
Summary
Functions
Adds address ip with prefix length prefix to link link_name.
Decodes a netlink message body into a t/0.
Removes address ip/prefix from link link_name.
Encodes a t/0 into its netlink message body.
Lists every address in the socket's network namespace.
Lists the addresses on the link named link_name.
Types
Functions
@spec add( Linx.Netlink.Socket.t(), binary(), binary() | Linx.IP.t(), non_neg_integer() ) :: :ok | {:error, term()}
Adds address ip with prefix length prefix to link link_name.
ip may be a string ("10.0.0.5", "fc00::1") or a Linx.IP. The
address family is taken from the IP.
Decodes a netlink message body into a t/0.
@spec delete( Linx.Netlink.Socket.t(), binary(), binary() | Linx.IP.t(), non_neg_integer() ) :: :ok | {:error, term()}
Removes address ip/prefix from link link_name.
Encodes a t/0 into its netlink message body.
@spec list(Linx.Netlink.Socket.t()) :: {:ok, [t()]} | {:error, term()}
Lists every address in the socket's network namespace.
@spec list(Linx.Netlink.Socket.t(), binary()) :: {:ok, [t()]} | {:error, term()}
Lists the addresses on the link named link_name.