Struct etherparse::Ipv4HeaderSlice
source · pub struct Ipv4HeaderSlice<'a> { /* private fields */ }
Expand description
A slice containing an ipv4 header of a network package.
Implementations§
source§impl<'a> Ipv4HeaderSlice<'a>
impl<'a> Ipv4HeaderSlice<'a>
sourcepub fn from_slice(slice: &'a [u8]) -> Result<Ipv4HeaderSlice<'a>, ReadError>
pub fn from_slice(slice: &'a [u8]) -> Result<Ipv4HeaderSlice<'a>, ReadError>
Creates a slice containing an ipv4 header (including header options).
sourcepub fn ihl(&self) -> u8
pub fn ihl(&self) -> u8
Read the “ip header length” (length of the ipv4 header + options in multiples of 4 bytes).
sourcepub fn total_len(&self) -> u16
pub fn total_len(&self) -> u16
Read the “total length” from the slice (total length of ip header + payload).
sourcepub fn payload_len(&self) -> u16
pub fn payload_len(&self) -> u16
Determine the payload length based on the ihl & total_length field of the header.
sourcepub fn identification(&self) -> u16
pub fn identification(&self) -> u16
Read the “identification” field from the slice.
sourcepub fn dont_fragment(&self) -> bool
pub fn dont_fragment(&self) -> bool
Read the “dont fragment” flag from the slice.
sourcepub fn more_fragments(&self) -> bool
pub fn more_fragments(&self) -> bool
Read the “more fragments” flag from the slice.
sourcepub fn fragments_offset(&self) -> u16
pub fn fragments_offset(&self) -> u16
Read the “fragment_offset” field from the slice.
sourcepub fn header_checksum(&self) -> u16
pub fn header_checksum(&self) -> u16
Read the “header checksum” field from the slice.
sourcepub fn source_addr(&self) -> Ipv4Addr
pub fn source_addr(&self) -> Ipv4Addr
Return the ipv4 source address as an std::net::Ipv4Addr
sourcepub fn destination(&self) -> [u8; 4]
pub fn destination(&self) -> [u8; 4]
Returns a slice containing the ipv4 source address.
sourcepub fn destination_addr(&self) -> Ipv4Addr
pub fn destination_addr(&self) -> Ipv4Addr
Return the ipv4 destination address as an std::net::Ipv4Addr
sourcepub fn options(&self) -> &'a [u8] ⓘ
pub fn options(&self) -> &'a [u8] ⓘ
Returns a slice containing the ipv4 header options (empty when there are no options).
sourcepub fn is_fragmenting_payload(&self) -> bool
pub fn is_fragmenting_payload(&self) -> bool
Returns true if the payload is fragmented.
Either data is missing (more_fragments set) or there is an fragment offset.
sourcepub fn to_header(&self) -> Ipv4Header
pub fn to_header(&self) -> Ipv4Header
Decode all the fields and copy the results to a Ipv4Header struct
Trait Implementations§
source§impl<'a> Clone for Ipv4HeaderSlice<'a>
impl<'a> Clone for Ipv4HeaderSlice<'a>
source§fn clone(&self) -> Ipv4HeaderSlice<'a>
fn clone(&self) -> Ipv4HeaderSlice<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more