Pfx.band
You're seeing just the function
band
, go back to Pfx module for more information.
Specs
A bitwise AND of two prefix/0
's.
Both prefixes should, ultimately, have the same maxlen
.
If one or more arguments are nog a Pfx
-struct they are
are converted using Pfx.new/1
.
Examples
iex> x = new(<<128, 129, 130, 131>>, 32)
iex> y = new(<<255, 255>>, 32)
iex>
iex> band(x, y)
%Pfx{bits: <<128, 129, 0, 0>>, maxlen: 32}
iex>
iex> band(y,x)
%Pfx{bits: <<128, 129, 0, 0>>, maxlen: 32}
iex> band("1.2.3.4", "255.255.0.0")
"1.2.0.0"
iex> band("1.2.3.4", {255, 255, 0, 0})
"1.2.0.0"
iex> band({1, 2, 3, 4}, "255.255.0.0")
{1, 2, 0, 0}
# both will still have maxlen `32`
iex> band({{1, 2, 3, 4}, 24}, {{255, 255, 0, 0}, 32})
{{1, 2, 0, 0}, 32}
# the work of ancient astrounauts ..
iex> band("1.2.3.4", "255.255")
"1.0.0.4"