Skip to main content

TcpSegment

Struct TcpSegment 

Source
pub struct TcpSegment<'a> { /* private fields */ }
Expand description

A structurally validated TCP segment.

Implementations§

Source§

impl TcpSegment<'_>

Source

pub fn checksum_is_valid_ipv4( &self, source: Ipv4Address, destination: Ipv4Address, ) -> Result<bool, TcpChecksumError>

Checks this TCP segment against its IPv4 pseudoheader.

Source§

impl TcpSegment<'_>

Source

pub fn checksum_is_valid_ipv6( &self, source: Ipv6Address, destination: Ipv6Address, ) -> Result<bool, TcpChecksumError>

Checks this TCP segment against its IPv6 pseudoheader.

Source§

impl<'a> TcpSegment<'a>

Source

pub fn parse(bytes: &'a [u8]) -> Result<Self, ParseError>

Parses a complete TCP segment without checking its checksum.

Source

pub fn source_port(&self) -> u16

Returns the source port.

Source

pub fn destination_port(&self) -> u16

Returns the destination port.

Source

pub fn sequence_number(&self) -> u32

Returns the sequence number.

Source

pub fn acknowledgment_number(&self) -> u32

Returns the acknowledgment number.

Source

pub fn data_offset(&self) -> u8

Returns the data offset in four-octet words.

Source

pub fn header_length(&self) -> usize

Returns the header length in octets.

Source

pub fn reserved(&self) -> u8

Returns the four reserved header bits.

Source

pub fn flags(&self) -> TcpFlags

Returns TCP control flags with their raw wire value preserved.

Source

pub fn window_size(&self) -> u16

Returns the window size.

Source

pub fn checksum(&self) -> u16

Returns the encoded checksum.

Source

pub fn urgent_pointer(&self) -> u16

Returns the urgent pointer.

Source

pub fn options(&self) -> &'a [u8]

Returns header options.

Source

pub fn payload(&self) -> &'a [u8]

Returns payload bytes.

Source

pub fn as_bytes(&self) -> &'a [u8]

Returns all represented segment bytes.

Trait Implementations§

Source§

impl<'a> Clone for TcpSegment<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for TcpSegment<'a>

Source§

impl<'a> Debug for TcpSegment<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for TcpSegment<'a>

Source§

impl<'a> PartialEq for TcpSegment<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for TcpSegment<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for TcpSegment<'a>

§

impl<'a> RefUnwindSafe for TcpSegment<'a>

§

impl<'a> Send for TcpSegment<'a>

§

impl<'a> Sync for TcpSegment<'a>

§

impl<'a> Unpin for TcpSegment<'a>

§

impl<'a> UnsafeUnpin for TcpSegment<'a>

§

impl<'a> UnwindSafe for TcpSegment<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.