Skip to main content

TcpHeader

Struct TcpHeader 

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

Implementations§

Source§

impl TcpHeader

Source

pub fn get_src_port(&self) -> &u16

Source

pub fn get_dst_port(&self) -> &u16

Source

pub fn get_flags(&self) -> &u8

Source

pub fn get_window(&self) -> &u16

Source

pub fn get_pseudo_header_set(&self) -> &bool

Source§

impl TcpHeader

Source

pub fn set_src_port(&mut self, v: u16)

Source

pub fn set_dst_port(&mut self, v: u16)

Source

pub fn set_flags(&mut self, v: u8)

Source

pub fn set_window(&mut self, v: u16)

Source§

impl TcpHeader

Source

pub fn new(src_port: u16, dst_port: u16) -> Self

Source

pub fn set_flag(&mut self, f: TcpFlags)

Trait Implementations§

Source§

impl Header for TcpHeader

Source§

fn make(self) -> PacketData

‘cook’ the header, returning it as a Vec<u8>. this function will calculate checksums, even though they will be over-written by the OS if the packet is sent ‘down the wire’, likewise with a lot of length fields and such. Read more
Source§

fn parse(raw_data: &[u8]) -> Result<Box<Self>, ParseError>

parse() should never be run from a box
, is hould only ever br un as
::parse(). this is just here to complete the implementation of Header onto boxed structs that implement header
Source§

fn get_proto(&self) -> Protocol

Source§

fn get_length(&self) -> u8

get the current length of the header in bytes. this usually just returns a fixed value as most headers dont have variable length, only really IP does and even then its rare for it to be > 20 bytes
Source§

fn get_min_length() -> u8

get the minimum length (in bytes) that this type of header can be
Source§

fn into_transport_header(&mut self) -> Option<&mut dyn TransportHeader>

attempts to coerce the header (a type which implements the Header trait) into a &mut dyn TransportHeader. Only returns Option::Some when the underlying concrete type is a UdpHeader or a TcpHeader
Source§

impl TransportHeader for TcpHeader

Source§

fn set_pseudo_header(&mut self, src_ip: [u8; 4], dst_ip: [u8; 4], data_len: u16)

Sets the values of an internal value which represents the pseudo header that is used when calculating the checksum. This method must be called before the make method, which is called when the header is added to the Packet with the add_header method. If the IP header is already present in the Packet when this one is added, then this method will be called in the add_header method, using the data from the IP header. 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.