pub struct TcpFlags {
pub fin: bool,
pub syn: bool,
pub rst: bool,
pub psh: bool,
pub ack: bool,
pub urg: bool,
pub ece: bool,
pub cwr: bool,
pub ns: bool,
}Expand description
TCP flags structure (9 bits).
Bit layout (from MSB to LSB in the 16-bit flags/reserved field):
- NS (Nonce Sum) - ECN nonce concealment
- CWR (Congestion Window Reduced)
- ECE (ECN-Echo)
- URG (Urgent)
- ACK (Acknowledgment)
- PSH (Push)
- RST (Reset)
- SYN (Synchronize)
- FIN (Finish)
Scapy uses the string “FSRPAUECN” for flags (reversed order).
Fields§
§fin: boolFIN - No more data from sender
syn: boolSYN - Synchronize sequence numbers
rst: boolRST - Reset the connection
psh: boolPSH - Push function
ack: boolACK - Acknowledgment field significant
urg: boolURG - Urgent pointer field significant
ece: boolECE - ECN-Echo (RFC 3168)
cwr: boolCWR - Congestion Window Reduced (RFC 3168)
ns: boolNS - ECN-nonce concealment protection (RFC 3540)
Implementations§
Source§impl TcpFlags
impl TcpFlags
pub const SYN_BIT: u16 = 0x002
pub const RST_BIT: u16 = 0x004
pub const PSH_BIT: u16 = 0x008
pub const ACK_BIT: u16 = 0x010
pub const URG_BIT: u16 = 0x020
pub const ECE_BIT: u16 = 0x040
pub const CWR_BIT: u16 = 0x080
pub const NS_BIT: u16 = 0x100
Sourcepub fn from_u16(value: u16) -> Self
pub fn from_u16(value: u16) -> Self
Create flags from a raw 16-bit value (data offset + reserved + flags).
The flags are in the lower 9 bits (with NS in bit 8 of the high byte).
Sourcepub fn from_bytes(hi: u8, lo: u8) -> Self
pub fn from_bytes(hi: u8, lo: u8) -> Self
Create flags from two bytes (data_offset_reserved + flags).
Sourcepub fn from_str(s: &str) -> Self
pub fn from_str(s: &str) -> Self
Create flags from a string like “S”, “SA”, “FA”, “PA”, “R”, etc. Uses Scapy’s “FSRPAUECN” convention.
Sourcepub fn is_syn_ack(&self) -> bool
pub fn is_syn_ack(&self) -> bool
Check if this is a SYN-ACK packet.
Trait Implementations§
Source§impl BitAndAssign for TcpFlags
impl BitAndAssign for TcpFlags
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl BitOrAssign for TcpFlags
impl BitOrAssign for TcpFlags
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreimpl Copy for TcpFlags
impl Eq for TcpFlags
impl StructuralPartialEq for TcpFlags
Auto Trait Implementations§
impl Freeze for TcpFlags
impl RefUnwindSafe for TcpFlags
impl Send for TcpFlags
impl Sync for TcpFlags
impl Unpin for TcpFlags
impl UnsafeUnpin for TcpFlags
impl UnwindSafe for TcpFlags
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more