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 more