A TCPFlags object represents the eight bits of flags from a TCP session.
| value) |
Examples:
>>> a = TCPFlags('SA')
>>> b = TCPFlags(5)
Instance attributes (read-only):
| Attribute | Value |
|---|---|
| FIN | True if the FIN flag is set, False otherwise |
| SYN | True if the SYN flag is set, False otherwise |
| RST | True if the RST flag is set, False otherwise |
| PSH | True if the PSH flag is set, False otherwise |
| ACK | True if the ACK flag is set, False otherwise |
| URG | True if the URG flag is set, False otherwise |
| ECE | True if the ECE flag is set, False otherwise |
| CWR | True if the CWR flag is set, False otherwise |
Supported operations:
| Operation | Result |
|---|---|
f |
The bitwise inversion (not) of f |
f1 & f2 |
The bitwise intersection (and) of the flags from f1 and f2 |
f1 | f2 |
The bitwise union (or) of the flags from f1 and f2 |
f1 ^ f2 |
The bitwise exclusive disjunction (xor) of the flags from f1 and f2 |
int(f) |
The integer value of the flags f |
| f | Can be used as a truth value with any flag set == True, False otherwise |
Constants:
The following constants are defined:
| Constant | Meaning |
|---|---|
| FIN | A TCPFlags value with only the FIN flags set |
| SYN | A TCPFlags value with only the SYN flags set |
| RST | A TCPFlags value with only the RST flags set |
| PSH | A TCPFlags value with only the PSH flags set |
| ACK | A TCPFlags value with only the ACK flags set |
| URG | A TCPFlags value with only the URG flags set |
| ECE | A TCPFlags value with only the ECE flags set |
| CWR | A TCPFlags value with only the CWR flags set |
Supported methods:
| flagmask) |
"flags/mask", returns True if if the
flags of self match flags after being masked with
mask, False otherwise.
Given a flagmask without the "/", checks for literal equality, as if the mask contained all flags.
| ) |
str(f) returns the
a string representation of the flags set in f.