Iptrie.Iana.get
You're seeing just the function
get
, go back to Iptrie.Iana module for more information.
Specs
Returns the list of IPv4 or IPv6 prefixes and their IANA special purpose address properties in a map.
Examples
iex> get(:ip4) |> length()
25
iex> get(:ip4) |> hd()
{%Pfx{bits: <<0, 0, 0, 0>>, maxlen: 32},
%{
allocation: "1981-09",
destination: false,
forward: false,
global: false,
name: "this-host-on-this-network",
prefix: "0.0.0.0/32",
reserved: true,
source: true,
spec: ["rfc1122"]
}}
iex> get(:ip6) |> length()
20
iex> get(:ip6) |> hd()
{%Pfx{bits: <<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>>, maxlen: 128},
%{
allocation: "2006-02",
destination: false,
forward: false,
global: false,
name: "unspecified-address",
prefix: "::/128",
reserved: true,
source: true,
spec: ["rfc4291"]
}}
# get all non-globally-routed IPv4 prefixes
iex> get(:ip4)
...> |> Enum.filter(fn {_, m} -> m.global != true end)
...> |> Enum.map(fn {pfx, _} -> "#{pfx}" end)
[
"0.0.0.0", "0.0.0.0/8", "10.0.0.0/8", "100.64.0.0/10", "127.0.0.0/8",
"169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/29", "192.0.0.0/24", "192.0.0.8",
"192.0.0.170", "192.0.0.171", "192.0.2.0/24", "192.88.99.0/24",
"192.168.0.0/16", "198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24",
"240.0.0.0/4", "255.255.255.255"
]