Struct Nat64Prefix
pub struct Nat64Prefix { /* private fields */ }Expand description
One operator-declared, network-specific NAT64 prefix.
Construct with Nat64Prefix::parse (or parse_nat64_prefixes for a
whole configured list); there is no other constructor, so a value of this
type is always one of the six RFC 6052 §2.2 prefix lengths with no bits set
beyond that length.
Implementations§
Source§impl Nat64Prefix
impl Nat64Prefix
Sourcepub fn parse(raw: &str) -> Result<Self>
pub fn parse(raw: &str) -> Result<Self>
Parse one <ipv6>/<len> entry, for example "2001:db8:122:344::/96".
§Errors
Returns an error describing the problem when the entry has no /, does
not parse as an IPv6 address, uses a prefix length outside
RFC 6052 §2.2’s /32, /40, /48, /56, /64, /96, or sets any
bit beyond the prefix length.
Sourcepub const fn prefix_len(&self) -> u8
pub const fn prefix_len(&self) -> u8
The prefix length in bits.
Sourcepub const fn network(&self) -> Ipv6Addr
pub const fn network(&self) -> Ipv6Addr
The prefix network address, with all bits beyond Self::prefix_len
zero.
Sourcepub fn embedded_ipv4(&self, v6: Ipv6Addr) -> Option<Ipv4Addr>
pub fn embedded_ipv4(&self, v6: Ipv6Addr) -> Option<Ipv4Addr>
Decode the IPv4 address v6 embeds under this prefix, or None when
v6 is not inside the prefix.
The layouts are RFC 6052 §2.2’s: the embedded IPv4 octets follow the
prefix and skip octet 8, the “u” octet, for every length below /96.
§The u-octet is decoded regardless of its value
RFC 6052 requires a translator to set octet 8 to zero, and §3.1 says
an address whose u-octet is non-zero is not a valid IPv4-embedded
address. This decoder deliberately ignores that rule, because here the
address comes from a DNS answer the attacker writes, not from a
translator. Requiring u == 0 would classify
<prefix>:ff:a:0:100::-style answers as opaque IPv6 while a permissive
translator still delivered them to the embedded IPv4 destination — a
bypass. Decoding unconditionally can only over-approximate what the
translator reaches, which is the safe direction for a deny boundary.
Trait Implementations§
Source§impl Clone for Nat64Prefix
impl Clone for Nat64Prefix
Source§fn clone(&self) -> Nat64Prefix
fn clone(&self) -> Nat64Prefix
1.0.0 (const: unstable) · §fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more