pub struct Ipv6Packet<B> { /* private fields */ }
Expand description
An IPv6 packet.
An Ipv6Packet
shares its underlying memory with the byte slice it was
parsed from or serialized to, meaning that no copying or extra allocation is
necessary.
Implementations§
Source§impl<B: SplitByteSlice> Ipv6Packet<B>
impl<B: SplitByteSlice> Ipv6Packet<B>
Sourcepub fn iter_extension_hdrs(
&self,
) -> impl Iterator<Item = Ipv6ExtensionHeader<'_>>
pub fn iter_extension_hdrs( &self, ) -> impl Iterator<Item = Ipv6ExtensionHeader<'_>>
Returns an iterator over the extension headers.
Sourcepub fn dscp_and_ecn(&self) -> DscpAndEcn
pub fn dscp_and_ecn(&self) -> DscpAndEcn
The Differentiated Services Code Point (DSCP) and the Explicit Congestion Notification (ECN).
Sourcepub fn proto(&self) -> Ipv6Proto
pub fn proto(&self) -> Ipv6Proto
The Upper layer protocol for this packet.
This is found in the fixed header’s Next Header if there are no extension
headers, or the Next Header value in the last extension header if there are.
This also uses the same codes, encoded by the Rust type Ipv6Proto
.
Sourcepub fn src_ipv6(&self) -> Option<Ipv6SourceAddr>
pub fn src_ipv6(&self) -> Option<Ipv6SourceAddr>
The source IP address represented as an Ipv6SourceAddr
.
Unlike [IpHeader::src_ip
], src_ipv6
returns an Ipv6SourceAddr
,
which represents the valid values that a source address can take
(namely, a unicast or unspecified address) or None
if the address is
invalid (namely, a multicast address or an ipv4-mapped-ipv6 address).
Sourcepub fn copy_header_bytes_for_fragment(&self) -> Vec<u8>
pub fn copy_header_bytes_for_fragment(&self) -> Vec<u8>
Return a buffer that is a copy of the header bytes in this packet, including the fixed and extension headers, but without the first fragment extension header.
Note, if there are multiple fragment extension headers, only the first fragment extension header will be removed.
§Panics
Panics if there is no fragment extension header in this packet.
Sourcepub fn builder(&self) -> Ipv6PacketBuilder
pub fn builder(&self) -> Ipv6PacketBuilder
Construct a builder with the same contents as this packet.
Sourcepub fn nat64_translate(
&self,
v4_src_addr: Ipv4Addr,
v4_dst_addr: Ipv4Addr,
) -> Nat64TranslationResult<impl Serializer<Buffer = EmptyBuf> + Debug + '_, Nat64Error>
pub fn nat64_translate( &self, v4_src_addr: Ipv4Addr, v4_dst_addr: Ipv4Addr, ) -> Nat64TranslationResult<impl Serializer<Buffer = EmptyBuf> + Debug + '_, Nat64Error>
Performs the header translation part of NAT64 as described in RFC 7915.
nat64_translate
follows the rules described in RFC 7915 to construct
the IPv4 equivalent of this IPv6 packet. If the payload is a TCP segment
or a UDP packet, its checksum will be updated. If the payload is an
ICMPv6 packet, it will be converted to the equivalent ICMPv4 packet. For
all other payloads, the payload will be unchanged, and the IP header will
be translated. On success, a [Serializer
] is returned which describes
the new packet to be sent.
Note that the IPv4 TTL/IPv6 Hop Limit field is not modified. It is the caller’s responsibility to decrement and process this field per RFC 7915.
In some cases, the packet has no IPv4 equivalent, in which case the
value Nat64TranslationResult::Drop
will be returned, instructing the
caller to silently drop the packet.
§Errors
nat64_translate
will return an error if support has not yet been
implemented for translating a particular IP protocol.
Source§impl<B: SplitByteSliceMut> Ipv6Packet<B>
impl<B: SplitByteSliceMut> Ipv6Packet<B>
Sourcepub fn set_src_ip(&mut self, addr: Ipv6Addr)
pub fn set_src_ip(&mut self, addr: Ipv6Addr)
Set the source IP address.
Sourcepub fn set_dst_ip(&mut self, addr: Ipv6Addr)
pub fn set_dst_ip(&mut self, addr: Ipv6Addr)
Set the destination IP address.
Sourcepub fn set_hop_limit(&mut self, hlim: u8)
pub fn set_hop_limit(&mut self, hlim: u8)
Set the hop limit.
Trait Implementations§
Source§impl<B: SplitByteSlice> Debug for Ipv6Packet<B>
impl<B: SplitByteSlice> Debug for Ipv6Packet<B>
Source§impl<B: SplitByteSlice> FromRaw<Ipv6PacketRaw<B>, ()> for Ipv6Packet<B>
impl<B: SplitByteSlice> FromRaw<Ipv6PacketRaw<B>, ()> for Ipv6Packet<B>
Source§type Error = IpParseError<Ipv6>
type Error = IpParseError<Ipv6>
Source§fn try_from_raw_with(
raw: Ipv6PacketRaw<B>,
_args: (),
) -> Result<Self, Self::Error>
fn try_from_raw_with( raw: Ipv6PacketRaw<B>, _args: (), ) -> Result<Self, Self::Error>
Self
from the raw form in raw
with args
.§fn try_from_raw(raw: R) -> Result<Self, Self::Error>where
Self: FromRaw<R, (), Error = Self::Error>,
fn try_from_raw(raw: R) -> Result<Self, Self::Error>where
Self: FromRaw<R, (), Error = Self::Error>,
Self
from the raw form in raw
.Source§impl<B: SplitByteSlice, I: IpExt> GenericOverIp<I> for Ipv6Packet<B>
impl<B: SplitByteSlice, I: IpExt> GenericOverIp<I> for Ipv6Packet<B>
Source§impl<B: SplitByteSlice> IpPacket<B, Ipv6> for Ipv6Packet<B>
impl<B: SplitByteSlice> IpPacket<B, Ipv6> for Ipv6Packet<B>
Source§type Builder = Ipv6PacketBuilder
type Builder = Ipv6PacketBuilder
Source§type VersionSpecificMeta = ()
type VersionSpecificMeta = ()
Source§fn dscp_and_ecn(&self) -> DscpAndEcn
fn dscp_and_ecn(&self) -> DscpAndEcn
Source§fn set_ttl(&mut self, ttl: u8)where
B: SplitByteSliceMut,
fn set_ttl(&mut self, ttl: u8)where
B: SplitByteSliceMut,
Source§fn version_specific_meta(&self)
fn version_specific_meta(&self)
Source§fn as_ip_addr_ref(&self) -> IpAddr<&Ipv4Packet<B>, &Self>
fn as_ip_addr_ref(&self) -> IpAddr<&Ipv4Packet<B>, &Self>
Source§impl<B: SplitByteSlice> Ipv6Header for Ipv6Packet<B>
impl<B: SplitByteSlice> Ipv6Header for Ipv6Packet<B>
Source§fn get_fixed_header(&self) -> &FixedHeader
fn get_fixed_header(&self) -> &FixedHeader
FixedHeader
.