Struct etherparse::TcpHeaderSlice
source · pub struct TcpHeaderSlice<'a> { /* private fields */ }
Expand description
A slice containing an tcp header of a network package.
Implementations§
source§impl<'a> TcpHeaderSlice<'a>
impl<'a> TcpHeaderSlice<'a>
sourcepub fn from_slice(slice: &'a [u8]) -> Result<TcpHeaderSlice<'a>, ReadError>
pub fn from_slice(slice: &'a [u8]) -> Result<TcpHeaderSlice<'a>, ReadError>
Creates a slice containing an tcp header.
sourcepub fn source_port(&self) -> u16
pub fn source_port(&self) -> u16
Read the destination port number.
sourcepub fn destination_port(&self) -> u16
pub fn destination_port(&self) -> u16
Read the destination port number.
sourcepub fn sequence_number(&self) -> u32
pub fn sequence_number(&self) -> u32
Read the sequence number of the first data octet in this segment (except when SYN is present).
If SYN is present the sequence number is the initial sequence number (ISN) and the first data octet is ISN+1. [copied from RFC 793, page 16]
sourcepub fn acknowledgment_number(&self) -> u32
pub fn acknowledgment_number(&self) -> u32
Reads the acknowledgment number.
If the ACK control bit is set this field contains the value of the next sequence number the sender of the segment is expecting to receive.
Once a connection is established this is always sent.
sourcepub fn data_offset(&self) -> u8
pub fn data_offset(&self) -> u8
Read the number of 32 bit words in the TCP Header.
This indicates where the data begins. The TCP header (even one including options) is an integral number of 32 bits long.
sourcepub fn cwr(&self) -> bool
pub fn cwr(&self) -> bool
Reads the cwr flag (Congestion Window Reduced).
This flag is set by the sending host to indicate that it received a TCP segment with the ECE flag set and had responded in congestion control mechanism (added to header by RFC 3168).
sourcepub fn window_size(&self) -> u16
pub fn window_size(&self) -> u16
The number of data octets beginning with the one indicated in the acknowledgment field which the sender of this segment is willing to accept.
sourcepub fn checksum(&self) -> u16
pub fn checksum(&self) -> u16
Checksum (16 bit one’s complement) of the pseudo ip header, this tcp header and the payload.
sourcepub fn urgent_pointer(&self) -> u16
pub fn urgent_pointer(&self) -> u16
This field communicates the current value of the urgent pointer as a positive offset from the sequence number in this segment.
The urgent pointer points to the sequence number of the octet following the urgent data. This field is only be interpreted in segments with the URG control bit set.
sourcepub fn options_iterator(&self) -> TcpOptionsIterator<'_> ⓘ
pub fn options_iterator(&self) -> TcpOptionsIterator<'_> ⓘ
Returns an iterator that allows to iterate through all known TCP header options.
sourcepub fn to_header(&self) -> TcpHeader
pub fn to_header(&self) -> TcpHeader
Decode all the fields and copy the results to a TcpHeader struct
sourcepub fn calc_checksum_ipv4(
&self,
ip_header: &Ipv4HeaderSlice<'_>,
payload: &[u8]
) -> Result<u16, ValueError>
pub fn calc_checksum_ipv4(
&self,
ip_header: &Ipv4HeaderSlice<'_>,
payload: &[u8]
) -> Result<u16, ValueError>
Calculates the upd header checksum based on a ipv4 header and returns the result. This does NOT set the checksum.
sourcepub fn calc_checksum_ipv4_raw(
&self,
source_ip: &[u8],
destination_ip: &[u8],
payload: &[u8]
) -> Result<u16, ValueError>
pub fn calc_checksum_ipv4_raw(
&self,
source_ip: &[u8],
destination_ip: &[u8],
payload: &[u8]
) -> Result<u16, ValueError>
Calculates the checksum for the current header in ipv4 mode and returns the result. This does NOT set the checksum.
sourcepub fn calc_checksum_ipv6(
&self,
ip_header: &Ipv6HeaderSlice<'_>,
payload: &[u8]
) -> Result<u16, ValueError>
pub fn calc_checksum_ipv6(
&self,
ip_header: &Ipv6HeaderSlice<'_>,
payload: &[u8]
) -> Result<u16, ValueError>
Calculates the upd header checksum based on a ipv6 header and returns the result. This does NOT set the checksum..
sourcepub fn calc_checksum_ipv6_raw(
&self,
source: &[u8],
destination: &[u8],
payload: &[u8]
) -> Result<u16, ValueError>
pub fn calc_checksum_ipv6_raw(
&self,
source: &[u8],
destination: &[u8],
payload: &[u8]
) -> Result<u16, ValueError>
Calculates the checksum for the current header in ipv6 mode and returns the result. This does NOT set the checksum.
Trait Implementations§
source§impl<'a> Clone for TcpHeaderSlice<'a>
impl<'a> Clone for TcpHeaderSlice<'a>
source§fn clone(&self) -> TcpHeaderSlice<'a>
fn clone(&self) -> TcpHeaderSlice<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more