Struct Ipv4Packet
pub struct Ipv4Packet<'a> { /* private fields */ }Expand description
A read/write wrapper around an Internet Protocol version 4 packet buffer.
Implementations§
§impl<'a> Packet<'a>
impl<'a> Packet<'a>
pub const fn new_unchecked(buffer: &'a mut [u8]) -> Packet<'a>
pub const fn new_unchecked(buffer: &'a mut [u8]) -> Packet<'a>
Imbue a raw octet buffer with IPv4 packet structure.
pub fn new_checked(buffer: &'a mut [u8]) -> Result<Packet<'a>, Malformed>
pub fn new_checked(buffer: &'a mut [u8]) -> Result<Packet<'a>, Malformed>
Shorthand for a combination of new_unchecked and check_len.
pub fn check_len(&self) -> Result<(), Malformed>
pub fn check_len(&self) -> Result<(), Malformed>
Ensure that no accessor method will panic if called.
The result of this check is invalidated by calling set_header_len and set_total_len.
§Errors
Malformed: if the buffer is too short, if the header length is greater than the total length, or if the header length is less than the minimum allowed IHL.
pub fn header_len(&self) -> u8
pub fn header_len(&self) -> u8
Return the header length, in octets.
pub fn more_frags(&self) -> bool
pub fn more_frags(&self) -> bool
Return the “more fragments” flag.
pub fn frag_offset(&self) -> u16
pub fn frag_offset(&self) -> u16
Return the fragment offset, in octets.
pub fn next_header(&self) -> Protocol
pub fn next_header(&self) -> Protocol
Return the next_header (protocol) field.
pub fn verify_checksum(&self) -> bool
pub fn verify_checksum(&self) -> bool
pub fn set_version(&mut self, value: u8)
pub fn set_version(&mut self, value: u8)
Set the version field.
pub fn set_header_len(&mut self, value: u8)
pub fn set_header_len(&mut self, value: u8)
Set the header length, in octets.
pub fn set_total_len(&mut self, value: u16)
pub fn set_total_len(&mut self, value: u16)
Set the total length field.
pub fn clear_flags(&mut self)
pub fn clear_flags(&mut self)
Clear the entire flags field.
pub fn set_dont_frag(&mut self, value: bool)
pub fn set_dont_frag(&mut self, value: bool)
Set the “don’t fragment” flag.
pub fn set_more_frags(&mut self, value: bool)
pub fn set_more_frags(&mut self, value: bool)
Set the “more fragments” flag.
pub fn set_frag_offset(&mut self, value: u16)
pub fn set_frag_offset(&mut self, value: u16)
Set the fragment offset, in octets.
pub fn set_hop_limit(&mut self, value: u8)
pub fn set_hop_limit(&mut self, value: u8)
Set the time to live field.
pub fn set_next_header(&mut self, value: Protocol)
pub fn set_next_header(&mut self, value: Protocol)
Set the next header (protocol) field.
pub fn set_checksum(&mut self, value: u16)
pub fn set_checksum(&mut self, value: u16)
Set the header checksum field.
pub fn set_src_addr(&mut self, value: Ipv4Addr)
pub fn set_src_addr(&mut self, value: Ipv4Addr)
Set the source address field.
pub fn set_dst_addr(&mut self, value: Ipv4Addr)
pub fn set_dst_addr(&mut self, value: Ipv4Addr)
Set the destination address field.
pub fn fill_checksum(&mut self)
pub fn fill_checksum(&mut self)
Compute and fill in the header checksum.
pub fn payload_mut(&mut self) -> &mut [u8] ⓘ
pub fn payload_mut(&mut self) -> &mut [u8] ⓘ
Return a mutable pointer to the payload.