pub struct TcpPacket {
pub source: u16,
pub dest: u16,
pub seq: u32,
pub ack: u32,
pub flags: TcpFlags,
pub window: u16,
pub checksum: u16,
pub urg: u16,
pub option_data: Option<Vec<u8>>,
pub data: Vec<u8>,
}Expand description
TCP header and its associated data
Fields§
§source: u16Source port
dest: u16Destination port
seq: u32Sequence number
ack: u32Acknowledge number
flags: TcpFlagsTCP flags such as reset, ack, push, etc.
window: u16Window size
checksum: u16Checksum value
urg: u16Urgent pointer
option_data: Option<Vec<u8>>Option data if there was any
data: Vec<u8>TCP data
Implementations§
Source§impl TcpPacket
impl TcpPacket
Sourcepub fn parse_from_bytes(data: &dyn AsRef<[u8]>) -> Result<Self, TcpParseErr>
pub fn parse_from_bytes(data: &dyn AsRef<[u8]>) -> Result<Self, TcpParseErr>
Parse a TCP packet and data out of a stream of bytes
This method is meant to be called from the IpPacket::parse_from_bytes method.
§Errors
Returns an error if there are not enough bytes for a valid TCP packet.
Sourcepub fn pcap_write<W: Write>(&self, file: &mut W) -> Result<()>
pub fn pcap_write<W: Write>(&self, file: &mut W) -> Result<()>
Write packet to a pcap file
Writes a tcp packet to a pcap file. This is for use by the write_pcap_file function.
§Errors
Will return an error if any of the writes fail.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TcpPacket
impl RefUnwindSafe for TcpPacket
impl Send for TcpPacket
impl Sync for TcpPacket
impl Unpin for TcpPacket
impl UnwindSafe for TcpPacket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more