Skip to main content

TcpPacketBuilder

Struct TcpPacketBuilder 

Source
pub struct TcpPacketBuilder { /* private fields */ }

Implementations§

Source§

impl TcpPacketBuilder

Source

pub fn new() -> Self

Source

pub fn source_port(self, port: u16) -> Self

Source

pub fn destination_port(self, port: u16) -> Self

Source

pub fn sequence(self, seq: u32) -> Self

Source

pub fn ack_number(self, ack: u32) -> Self

Source

pub fn window(self, w: u16) -> Self

Source

pub fn urgent_pointer(self, up: u16) -> Self

Source

pub fn syn(self, on: bool) -> Self

Source

pub fn ack(self, on: bool) -> Self

Source

pub fn fin(self, on: bool) -> Self

Source

pub fn rst(self, on: bool) -> Self

Source

pub fn psh(self, on: bool) -> Self

Source

pub fn urg(self, on: bool) -> Self

Source

pub fn add_option(self, data: &[u8]) -> Self

Add a TCP option as raw bytes (kind + length + data).

Source

pub fn mss(self, mss: u16) -> Self

Convenience: add MSS option.

Source

pub fn window_scale(self, shift: u8) -> Self

Convenience: add Window Scale option.

Source

pub fn sack_permitted(self) -> Self

Convenience: add SACK Permitted option.

Source

pub fn timestamp(self, ts_val: u32, ts_ecr: u32) -> Self

Convenience: add Timestamp option.

Source

pub fn payload(self, data: &[u8]) -> Self

Source

pub fn build(self, src: Ipv4Addr, dst: Ipv4Addr) -> Vec<u8>

Build the TCP packet, computing the checksum (IPv4 pseudo-header).

Trait Implementations§

Source§

impl Default for TcpPacketBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.