Struct TcpPacket
pub struct TcpPacket<'a> { /* private fields */ }Expand description
A read/write wrapper around a Transmission Control Protocol 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 TCP packet structure.
pub fn new_checked(buffer: &'a mut [u8]) -> Result<Packet<'a>, Error>
pub fn new_checked(buffer: &'a mut [u8]) -> Result<Packet<'a>, Error>
Shorthand for a combination of new_unchecked and check_len.
pub fn check_len(&self) -> Result<(), Error>
pub fn check_len(&self) -> Result<(), Error>
Ensure that no accessor method will panic if called.
Returns Err(Error) if the buffer is too short.
Returns Err(Error) if the header length field has a value smaller
than the minimal header length.
The result of this check is invalidated by calling set_header_len.
pub fn seq_number(&self) -> SeqNumber
pub fn seq_number(&self) -> SeqNumber
Return the sequence number field.
pub fn ack_number(&self) -> SeqNumber
pub fn ack_number(&self) -> SeqNumber
Return the acknowledgement number field.
pub fn header_len(&self) -> u8
pub fn header_len(&self) -> u8
Return the header length, in octets.
pub fn window_len(&self) -> u16
pub fn window_len(&self) -> u16
Return the window size field.
pub fn verify_checksum(&self, src_addr: &Address, dst_addr: &Address) -> bool
pub fn verify_checksum(&self, src_addr: &Address, dst_addr: &Address) -> bool
pub fn set_src_port(&mut self, value: u16)
pub fn set_src_port(&mut self, value: u16)
Set the source port field.
pub fn set_dst_port(&mut self, value: u16)
pub fn set_dst_port(&mut self, value: u16)
Set the destination port field.
pub fn set_seq_number(&mut self, value: SeqNumber)
pub fn set_seq_number(&mut self, value: SeqNumber)
Set the sequence number field.
pub fn set_ack_number(&mut self, value: SeqNumber)
pub fn set_ack_number(&mut self, value: SeqNumber)
Set the acknowledgement number field.
pub fn clear_flags(&mut self)
pub fn clear_flags(&mut self)
Clear the entire flags 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_window_len(&mut self, value: u16)
pub fn set_window_len(&mut self, value: u16)
Set the window size field.
pub fn set_checksum(&mut self, value: u16)
pub fn set_checksum(&mut self, value: u16)
Set the checksum field.
pub fn set_urgent_at(&mut self, value: u16)
pub fn set_urgent_at(&mut self, value: u16)
Set the urgent pointer field.
pub fn fill_checksum(&mut self, src_addr: &Address, dst_addr: &Address)
pub fn fill_checksum(&mut self, src_addr: &Address, dst_addr: &Address)
Compute and fill in the header checksum.
§Panics
This function panics unless src_addr and dst_addr belong to the same family,
and that family is IPv4 or IPv6.
pub fn options_mut(&mut self) -> &mut [u8] ⓘ
pub fn options_mut(&mut self) -> &mut [u8] ⓘ
Return a mutable pointer to the options.
pub fn payload_mut(&mut self) -> &mut [u8] ⓘ
pub fn payload_mut(&mut self) -> &mut [u8] ⓘ
Return a mutable pointer to the payload data.