Struct zero_packet::network::ipv4::IPv4Builder
source · pub struct IPv4Builder<'a> {
pub data: &'a mut [u8],
}
Expand description
Represents an IPv4 packet.
Fields§
§data: &'a mut [u8]
Implementations§
source§impl<'a> IPv4Builder<'a>
impl<'a> IPv4Builder<'a>
sourcepub fn new(data: &'a mut [u8]) -> Result<Self, &'static str>
pub fn new(data: &'a mut [u8]) -> Result<Self, &'static str>
Creates a new IPv4Packet
from the given data slice.
Returns an error if the data Slice is too short to contain an IPv4 header.
sourcepub fn header_length(&self) -> usize
pub fn header_length(&self) -> usize
Returns the actual header length in bytes.
sourcepub fn set_version(&mut self, version: u8)
pub fn set_version(&mut self, version: u8)
Sets the version field.
sourcepub fn set_total_length(&mut self, total_length: u16)
pub fn set_total_length(&mut self, total_length: u16)
Sets the total length field.
sourcepub fn set_fragment_offset(&mut self, fragment_offset: u16)
pub fn set_fragment_offset(&mut self, fragment_offset: u16)
Sets the fragment offset field.
sourcepub fn set_protocol(&mut self, protocol: u8)
pub fn set_protocol(&mut self, protocol: u8)
Sets the protocol field.
sourcepub fn set_src_ip(&mut self, src_ip: &[u8; 4])
pub fn set_src_ip(&mut self, src_ip: &[u8; 4])
Sets the source IP address field.
sourcepub fn set_dest_ip(&mut self, dest_ip: &[u8; 4])
pub fn set_dest_ip(&mut self, dest_ip: &[u8; 4])
Sets the destination IP address field.
sourcepub fn set_checksum(&mut self)
pub fn set_checksum(&mut self)
Calculates the checksum field.
Only includes the header.
Auto Trait Implementations§
impl<'a> Freeze for IPv4Builder<'a>
impl<'a> RefUnwindSafe for IPv4Builder<'a>
impl<'a> Send for IPv4Builder<'a>
impl<'a> Sync for IPv4Builder<'a>
impl<'a> Unpin for IPv4Builder<'a>
impl<'a> !UnwindSafe for IPv4Builder<'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