Struct Nat64Prefix
pub struct Nat64Prefix { /* private fields */ }Expand description
Operator-declared, network-specific RFC 6052 NAT64 prefixes, and the parser that turns the configured strings into them.
Public because the tools that hold a prefix list name the type in their constructor signatures. Malformed input rejects the whole list, so a tool that cannot parse its configuration fails construction rather than running with a silently narrowed egress boundary. 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<Nat64Prefix, Error>
pub fn parse(raw: &str) -> Result<Nat64Prefix, Error>
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 moreimpl Copy for Nat64Prefix
Source§impl Debug for Nat64Prefix
impl Debug for Nat64Prefix
Source§impl Display for Nat64Prefix
impl Display for Nat64Prefix
impl Eq for Nat64Prefix
Source§impl Hash for Nat64Prefix
impl Hash for Nat64Prefix
Source§impl Ord for Nat64Prefix
impl Ord for Nat64Prefix
Source§fn cmp(&self, other: &Nat64Prefix) -> Ordering
fn cmp(&self, other: &Nat64Prefix) -> Ordering
1.21.0 (const: unstable) · §fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for Nat64Prefix
impl PartialEq for Nat64Prefix
Source§impl PartialOrd for Nat64Prefix
impl PartialOrd for Nat64Prefix
impl StructuralPartialEq for Nat64Prefix
Auto Trait Implementations§
impl Freeze for Nat64Prefix
impl RefUnwindSafe for Nat64Prefix
impl Send for Nat64Prefix
impl Sync for Nat64Prefix
impl Unpin for Nat64Prefix
impl UnsafeUnpin for Nat64Prefix
impl UnwindSafe for Nat64Prefix
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more