Pfx.nat64_decode
You're seeing just the function
nat64_decode
, go back to Pfx module for more information.
Specs
Returns the embedded IPv4 address of a nat64 pfx
The pfx
prefix should be a full IPv6 address. The len
defaults to 96
,
but if specified it should be one of [96, 64, 56, 48, 40, 32].
Examples
iex> nat64_decode("64:ff9b::10.10.10.10")
"10.10.10.10"
iex> nat64_decode("64:ff9b:1:0a0a:000a:0a00::", 48)
"10.10.10.10"
# from rfc6052, section 2.4
iex> nat64_decode("2001:db8:c000:221::", 32)
"192.0.2.33"
iex> nat64_decode("2001:db8:1c0:2:21::", 40)
"192.0.2.33"
iex> nat64_decode("2001:db8:122:c000:2:2100::", 48)
"192.0.2.33"
iex> nat64_decode("2001:db8:122:3c0:0:221::", 56)
"192.0.2.33"
iex> nat64_decode("2001:db8:122:344:c0:2:2100::", 64)
"192.0.2.33"
iex> nat64_decode({0x2001, 0xdb8, 0x122, 0x344, 0xC0, 0x2, 0x2100, 0x0}, 64)
{192, 0, 2, 33}
iex> nat64_decode({{0x2001, 0xdb8, 0x122, 0x344, 0xC0, 0x2, 0x2100, 0x0}, 128}, 64)
{{192, 0, 2, 33}, 32}
iex> nat64_decode("2001:db8:122:344::192.0.2.33", 96)
"192.0.2.33"
iex> nat64_decode("2001:db8:122:344::192.0.2.33", 90)
** (ArgumentError) nat64 prefix length not in [96, 64, 56, 48, 40, 32], got 90