pub struct Ipv4PacketRaw<B> { /* private fields */ }
Expand description
A partially parsed and not yet validated IPv4 packet.
Ipv4PacketRaw
provides minimal parsing of an IPv4 packet, namely
it only requires that the fixed header part (HeaderPrefix
) be retrieved,
all the other parts of the packet may be missing when attempting to create
it.
Ipv4Packet
provides a [FromRaw
] implementation that can be used to
validate an Ipv4PacketRaw
.
Implementations§
Source§impl<B> Ipv4PacketRaw<B>
impl<B> Ipv4PacketRaw<B>
Sourcepub fn options(&self) -> &MaybeParsed<OptionsRaw<B, Ipv4OptionsImpl>, B>
pub fn options(&self) -> &MaybeParsed<OptionsRaw<B, Ipv4OptionsImpl>, B>
Gets the maybe parsed options from the raw packet.
Source§impl<B: SplitByteSlice> Ipv4PacketRaw<B>
impl<B: SplitByteSlice> Ipv4PacketRaw<B>
Sourcepub fn body(&self) -> MaybeParsed<&[u8], &[u8]>
pub fn body(&self) -> MaybeParsed<&[u8], &[u8]>
Return the body.
body
returns [MaybeParsed::Complete
] if the entire body is present
(as determined by the header’s “total length” and “internet header
length” fields), and [MaybeParsed::Incomplete
] otherwise.
Sourcepub fn into_body(self) -> MaybeParsed<B, B>
pub fn into_body(self) -> MaybeParsed<B, B>
Consumes self
returning the body.
See Ipv4PacketRaw::body
for details on parsing completeness.
Source§impl<B: SplitByteSliceMut> Ipv4PacketRaw<B>
impl<B: SplitByteSliceMut> Ipv4PacketRaw<B>
Sourcepub fn set_src_ip_and_update_checksum(&mut self, addr: Ipv4Addr)
pub fn set_src_ip_and_update_checksum(&mut self, addr: Ipv4Addr)
Set the source IP address.
Set the source IP address and update the header checksum accordingly.
Sourcepub fn set_dst_ip_and_update_checksum(&mut self, addr: Ipv4Addr)
pub fn set_dst_ip_and_update_checksum(&mut self, addr: Ipv4Addr)
Set the destination IP address.
Set the destination IP address and update the header checksum accordingly.
Trait Implementations§
Source§impl<B: SplitByteSlice> FromRaw<Ipv4PacketRaw<B>, ()> for Ipv4Packet<B>
impl<B: SplitByteSlice> FromRaw<Ipv4PacketRaw<B>, ()> for Ipv4Packet<B>
Source§type Error = IpParseError<Ipv4>
type Error = IpParseError<Ipv4>
Source§fn try_from_raw_with(
raw: Ipv4PacketRaw<B>,
_args: (),
) -> Result<Self, Self::Error>
fn try_from_raw_with( raw: Ipv4PacketRaw<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> Ipv4Header for Ipv4PacketRaw<B>
impl<B: SplitByteSlice> Ipv4Header for Ipv4PacketRaw<B>
Source§fn get_header_prefix(&self) -> &HeaderPrefix
fn get_header_prefix(&self) -> &HeaderPrefix
HeaderPrefix
.