pub struct Ipv4Packet<'a> { /* private fields */ }Expand description
Zero-copy IPv4 packet parser.
Implementations§
Source§impl<'a> Ipv4Packet<'a>
impl<'a> Ipv4Packet<'a>
Sourcepub fn new(buf: &'a [u8]) -> Option<Self>
pub fn new(buf: &'a [u8]) -> Option<Self>
Attempt to parse an IPv4 packet. Returns None if buf is shorter than
the minimum header length, or if the IHL-declared header length exceeds buf.
pub fn version(&self) -> u8
pub fn ihl(&self) -> u8
pub fn dscp(&self) -> u8
pub fn ecn(&self) -> u8
pub fn total_length(&self) -> u16
pub fn identification(&self) -> u16
pub fn flags(&self) -> u8
pub fn dont_fragment(&self) -> bool
pub fn more_fragments(&self) -> bool
pub fn fragment_offset(&self) -> u16
pub fn ttl(&self) -> u8
pub fn protocol(&self) -> IpProtocol
pub fn checksum(&self) -> u16
pub fn source(&self) -> Ipv4Addr
pub fn destination(&self) -> Ipv4Addr
Sourcepub fn header_length(&self) -> usize
pub fn header_length(&self) -> usize
Total header length in bytes (IHL × 4).
Sourcepub fn verify_checksum(&self) -> bool
pub fn verify_checksum(&self) -> bool
Verify the IPv4 header checksum.
Trait Implementations§
Source§impl<'a> Clone for Ipv4Packet<'a>
impl<'a> Clone for Ipv4Packet<'a>
Source§fn clone(&self) -> Ipv4Packet<'a>
fn clone(&self) -> Ipv4Packet<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<'a> Freeze for Ipv4Packet<'a>
impl<'a> RefUnwindSafe for Ipv4Packet<'a>
impl<'a> Send for Ipv4Packet<'a>
impl<'a> Sync for Ipv4Packet<'a>
impl<'a> Unpin for Ipv4Packet<'a>
impl<'a> UnsafeUnpin for Ipv4Packet<'a>
impl<'a> UnwindSafe for Ipv4Packet<'a>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more