pub struct IPv4Writer<'a> {
pub bytes: &'a mut [u8],
}
Expand description
Writes IPv4 header fields.
Fields§
§bytes: &'a mut [u8]
Implementations§
Source§impl<'a> IPv4Writer<'a>
impl<'a> IPv4Writer<'a>
Sourcepub fn new(bytes: &'a mut [u8]) -> Result<Self, &'static str>
pub fn new(bytes: &'a mut [u8]) -> Result<Self, &'static str>
Creates a new IPv4Writer
from the given slice.
Sourcepub fn header_len(&self) -> usize
pub fn header_len(&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.
Indicates the IP version number. Should be set to 4.
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.
Should include the entire packet (header and payload).
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 IPv4Writer<'a>
impl<'a> RefUnwindSafe for IPv4Writer<'a>
impl<'a> Send for IPv4Writer<'a>
impl<'a> Sync for IPv4Writer<'a>
impl<'a> Unpin for IPv4Writer<'a>
impl<'a> !UnwindSafe for IPv4Writer<'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