NetAddr.netaddr

You're seeing just the function netaddr, go back to NetAddr module for more information.

Specs

netaddr(<<_::8, _::_*8>>) ::
  NetAddr.Generic.t()
  | NetAddr.IPv4.t()
  | NetAddr.IPv6.t()
  | NetAddr.MAC_48.t()
  | {:error, :einval}

Constructs a NetAddr.t/0 struct given a network address binary.

Examples

iex> NetAddr.netaddr <<1, 2, 3, 4, 5, 6>>
%NetAddr.MAC_48{address: <<1, 2, 3, 4, 5, 6>>, length: 48}

iex> NetAddr.netaddr <<1, 2, 3, 4, 5>>
%NetAddr.Generic{address: <<1, 2, 3, 4, 5>>, length: 40}
Link to this function

netaddr(address, address_length)

View Source

Specs

netaddr(<<_::8, _::_*8>>, pos_integer()) ::
  NetAddr.Generic.t()
  | NetAddr.IPv4.t()
  | NetAddr.IPv6.t()
  | NetAddr.MAC_48.t()
  | {:error, :einval}

Constructs a NetAddr.t/0 struct given a network address binary and an address length.

Link to this function

netaddr(address, address_length, size_in_bytes)

View Source

Specs

Explicitly constructs a NetAddr.Generic.t/0 struct.

Examples

iex> NetAddr.netaddr(<<1, 2, 3, 4, 5, 6>>, 48, 6)
%NetAddr.Generic{address: <<1, 2, 3, 4, 5, 6>>, length: 48}

iex> NetAddr.netaddr(<<1, 2, 3, 4, 5>>, 48, 6)
%NetAddr.Generic{address: <<0, 1, 2, 3, 4, 5>>, length: 48}