8 #define PCPP_DEPRECATED_TCP_OPTION_TYPE \
9 PCPP_DEPRECATED("enum TcpOptionType is deprecated; Use enum class TcpOptionEnumType instead")
30 #if (BYTE_ORDER == LITTLE_ENDIAN)
53 #elif (BYTE_ORDER == BIG_ENDIAN)
77 # error "Endian is not LE nor BE..."
88 static_assert(
sizeof(
tcphdr) == 20,
"tcphdr size is not 20 bytes");
203 #define PCPP_TCPOLEN_NOP 1
205 #define PCPP_TCPOLEN_EOL 1
207 #define PCPP_TCPOLEN_MSS 4
209 #define PCPP_TCPOLEN_WINDOW 3
211 #define PCPP_TCPOLEN_SACK_PERM 2
213 #define PCPP_TCPOLEN_SACK_MIN 2
215 #define PCPP_TCPOLEN_ECHO 6
217 #define PCPP_TCPOLEN_ECHOREPLY 6
219 #define PCPP_TCPOLEN_TIMESTAMP 10
221 #define PCPP_TCPOLEN_CC 6
223 #define PCPP_TCPOLEN_CCNEW 6
225 #define PCPP_TCPOLEN_CCECHO 6
227 #define PCPP_TCPOLEN_MD5 18
229 #define PCPP_TCPOLEN_MPTCP_MIN 8
231 #define PCPP_TCPOLEN_SCPS 4
233 #define PCPP_TCPOLEN_SNACK 6
235 #define PCPP_TCPOLEN_RECBOUND 2
237 #define PCPP_TCPOLEN_CORREXP 2
239 #define PCPP_TCPOLEN_QS 8
241 #define PCPP_TCPOLEN_USER_TO 4
243 #define PCPP_TCPOLEN_RVBD_PROBE_MIN 3
245 #define PCPP_TCPOLEN_RVBD_TRPY_MIN 16
247 #define PCPP_TCPOLEN_EXP_MIN 2
264 PCPP_DEPRECATED(
"Use getTcpOptionEnumType instead")
281 static bool canAssign(
const uint8_t* recordRawData,
size_t tlvDataLen)
283 const auto* data =
reinterpret_cast<const TLVRawData*
>(recordRawData);
287 if (tlvDataLen <
sizeof(TLVRawData::recordType))
301 if (m_Data ==
nullptr)
306 return sizeof(uint8_t);
308 return static_cast<size_t>(m_Data->recordLen);
313 if (m_Data ==
nullptr)
320 return static_cast<size_t>(m_Data->recordLen) - (2 *
sizeof(uint8_t));
326 if (optionRawData ==
nullptr)
329 return static_cast<TcpOptionType>(optionRawData->recordType);
334 if (optionRawData ==
nullptr)
367 PCPP_DEPRECATED_TCP_OPTION_TYPE
369 :
TLVRecordBuilder(static_cast<uint8_t>(optionType), optionValue, optionValueLen)
379 :
TLVRecordBuilder(static_cast<uint8_t>(optionType), optionValue, optionValueLen)
383 PCPP_DEPRECATED_TCP_OPTION_TYPE
385 : TLVRecordBuilder(static_cast<uint8_t>(optionType), optionValue)
393 : TLVRecordBuilder(static_cast<uint8_t>(optionType), optionValue)
397 PCPP_DEPRECATED_TCP_OPTION_TYPE
399 : TLVRecordBuilder(static_cast<uint8_t>(optionType), optionValue)
407 : TLVRecordBuilder(static_cast<uint8_t>(optionType), optionValue)
411 PCPP_DEPRECATED_TCP_OPTION_TYPE
413 : TLVRecordBuilder(static_cast<uint8_t>(optionType), optionValue)
421 : TLVRecordBuilder(static_cast<uint8_t>(optionType), optionValue)
425 PCPP_DEPRECATED(
"enum NopEolOptionTypes is deprecated; Use enum class NopEolOptionEnumType instead")
473 return reinterpret_cast<tcphdr*
>(m_Data);
483 PCPP_DEPRECATED_TCP_OPTION_TYPE
532 PCPP_DEPRECATED_TCP_OPTION_TYPE
544 bool removeAllTcpOptions();
550 uint16_t calculateChecksum(
bool writeResultToPacket);
556 static inline
bool isDataValid(const uint8_t* data,
size_t dataLen);
562 void parseNextLayer() override;
565 size_t getHeaderLen()
const override
567 return getTcpHeader()->dataOffset * 4;
582 int m_NumOfTrailingBytes;
585 uint8_t* getOptionsBasePtr()
const
587 return m_Data +
sizeof(
tcphdr);
589 TcpOption addTcpOptionAt(
const TcpOptionBuilder& optionBuilder,
int offset);
590 void adjustTcpOptionTrailer(
size_t totalOptSize);
591 void copyLayerData(
const TcpLayer& other);
598 const tcphdr* hdr =
reinterpret_cast<const tcphdr*
>(data);
600 && dataLen >= hdr->
dataOffset *
sizeof(uint32_t);
604 #undef PCPP_DEPRECATED_TCP_OPTION_TYPE
Definition: TLVData.h:357
static bool canAssign(const uint8_t *recordRawData, size_t tlvDataLen)
Definition: TLVData.h:66
Definition: TLVData.h:204
Definition: TcpLayer.h:442
tcphdr * getTcpHeader() const
Definition: TcpLayer.h:471
OsiModelLayer getOsiModelLayer() const override
Definition: TcpLayer.h:575
uint16_t getSrcPort() const
TcpOption getTcpOption(TcpOptionEnumType option) const
TcpLayer()
A constructor that allocates a new TCP header with zero TCP options.
TcpOption getFirstTcpOption() const
TcpLayer(const TcpLayer &other)
A copy constructor that copy the entire header from the other TcpLayer (including TCP options)
TcpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
uint16_t getDstPort() const
TcpLayer & operator=(const TcpLayer &other)
TcpOption addTcpOption(const TcpOptionBuilder &optionBuilder)
void computeCalculateFields() override
Calculate tcphdr::headerChecksum field.
TcpLayer(uint16_t portSrc, uint16_t portDst)
static bool isDataValid(const uint8_t *data, size_t dataLen)
Definition: TcpLayer.h:596
size_t getTcpOptionCount() const
std::string toString() const override
TcpOption getNextTcpOption(TcpOption &tcpOption) const
Definition: TcpLayer.h:345
PCPP_DEPRECATED("enum TcpOptionType is deprecated; Use enum class TcpOptionEnumType instead") TcpOptionBuilder(TcpOptionType optionType
NopEolOptionEnumType
An enum to describe NOP and EOL TCP options. Used in one of this class's c'tors.
Definition: TcpLayer.h:359
TcpOptionBuilder(NopEolOptionEnumType optionType)
NopEolOptionTypes
An enum to describe NOP and EOL TCP options. Used in one of this class's c'tors.
Definition: TcpLayer.h:350
@ EOL
EOL TCP option.
Definition: TcpLayer.h:354
@ NOP
NOP TCP option.
Definition: TcpLayer.h:352
Definition: TcpLayer.h:253
TcpOptionEnumType getTcpOptionEnumType() const
Definition: TcpLayer.h:272
TcpOptionType getTcpOptionType() const
Definition: TcpLayer.h:265
size_t getTotalSize() const override
Definition: TcpLayer.h:299
size_t getDataSize() const override
Definition: TcpLayer.h:311
~TcpOption() override=default
A d'tor for this class, currently does nothing.
static bool canAssign(const uint8_t *recordRawData, size_t tlvDataLen)
Definition: TcpLayer.h:281
TcpOption(uint8_t *optionRawData)
Definition: TcpLayer.h:257
The main namespace for the PcapPlusPlus lib.
TcpOptionEnumType
TCP options types.
Definition: TcpLayer.h:147
@ RvbdTrpy
Riverbed transparency option, non IANA registered option number.
@ RvbdProbe
Riverbed probe option, non IANA registered option number.
@ CorrExp
SCPS Corruption Experienced.
@ Mss
Segment size negotiating.
@ ExpFd
RFC3692-style Experiment 1 (also improperly used for shipping products)
@ Md5
MD5 Signature Option.
@ CcEcho
CC.ECHO(obsolete)
@ Timestamp
TCP Timestamps.
@ SackPerm
SACK Permitted.
@ Echo
Echo (obsoleted by option TcpOptionEnumType::Timestamp)
@ ExpFe
RFC3692-style Experiment 2 (also improperly used for shipping products)
@ UserTo
User Timeout Option (also, other known unauthorized use)
@ EchoReply
Echo Reply (obsoleted by option TcpOptionEnumType::Timestamp)
@ Qs
Quick-Start Response.
@ RecBound
SCPS Record Boundary.
OsiModelLayer
An enum representing OSI model layers.
Definition: ProtocolType.h:228
@ OsiModelTransportLayer
Transport layer (layer 4)
Definition: ProtocolType.h:236
TcpOptionType
TCP options types.
Definition: TcpLayer.h:92
@ TCPOPT_EXP_FD
RFC3692-style Experiment 1 (also improperly used for shipping products)
Definition: TcpLayer.h:134
@ TCPOPT_USER_TO
User Timeout Option (also, other known unauthorized use)
Definition: TcpLayer.h:132
@ TCPOPT_SCPS
SCPS Capabilities.
Definition: TcpLayer.h:122
@ TCPOPT_MSS
Segment size negotiating.
Definition: TcpLayer.h:98
@ PCPP_TCPOPT_NOP
Padding.
Definition: TcpLayer.h:94
@ TCPOPT_QS
Quick-Start Response.
Definition: TcpLayer.h:130
@ PCPP_TCPOPT_WINDOW
Window scaling.
Definition: TcpLayer.h:100
@ TCPOPT_CCNEW
CC.NEW (obsolete)
Definition: TcpLayer.h:114
@ TCPOPT_RVBD_TRPY
Riverbed transparency option, non IANA registered option number.
Definition: TcpLayer.h:140
@ PCPP_TCPOPT_EOL
End of options.
Definition: TcpLayer.h:96
@ TCPOPT_Unknown
Unknown option.
Definition: TcpLayer.h:142
@ TCPOPT_MPTCP
Multipath TCP.
Definition: TcpLayer.h:120
@ TCPOPT_EXP_FE
RFC3692-style Experiment 2 (also improperly used for shipping products)
Definition: TcpLayer.h:136
@ TCPOPT_CC
CC (obsolete)
Definition: TcpLayer.h:112
@ TCPOPT_ECHOREPLY
Echo Reply (obsoleted by option TcpOptionType::PCPP_TCPOPT_TIMESTAMP)
Definition: TcpLayer.h:108
@ TCPOPT_RVBD_PROBE
Riverbed probe option, non IANA registered option number.
Definition: TcpLayer.h:138
@ TCPOPT_MD5
MD5 Signature Option.
Definition: TcpLayer.h:118
@ TCPOPT_SNACK
SCPS SNACK.
Definition: TcpLayer.h:124
@ PCPP_TCPOPT_TIMESTAMP
TCP Timestamps.
Definition: TcpLayer.h:110
@ TCPOPT_CORREXP
SCPS Corruption Experienced.
Definition: TcpLayer.h:128
@ TCPOPT_RECBOUND
SCPS Record Boundary.
Definition: TcpLayer.h:126
@ TCPOPT_SACK_PERM
SACK Permitted.
Definition: TcpLayer.h:102
@ TCPOPT_CCECHO
CC.ECHO(obsolete)
Definition: TcpLayer.h:116
@ PCPP_TCPOPT_SACK
SACK Block.
Definition: TcpLayer.h:104
@ TCPOPT_ECHO
Echo (obsoleted by option TcpOptionType::PCPP_TCPOPT_TIMESTAMP)
Definition: TcpLayer.h:106
Definition: TcpLayer.h:21
uint16_t pshFlag
PSH flag.
Definition: TcpLayer.h:44
uint16_t cwrFlag
CWR flag.
Definition: TcpLayer.h:52
uint16_t urgFlag
URG flag.
Definition: TcpLayer.h:48
uint32_t sequenceNumber
Sequence number.
Definition: TcpLayer.h:27
uint16_t accurateEcnFlag
Accurate ECN flag.
Definition: TcpLayer.h:32
uint16_t rstFlag
RST flag.
Definition: TcpLayer.h:42
uint16_t urgentPointer
Definition: TcpLayer.h:85
uint16_t synFlag
SYN flag.
Definition: TcpLayer.h:40
uint16_t portDst
Destination TCP port.
Definition: TcpLayer.h:25
uint16_t portSrc
Source TCP port.
Definition: TcpLayer.h:23
uint16_t reserved
Reserved bits.
Definition: TcpLayer.h:34
uint16_t dataOffset
Specifies the size of the TCP header in 32-bit words.
Definition: TcpLayer.h:36
uint16_t eceFlag
ECE flag.
Definition: TcpLayer.h:50
uint16_t windowSize
The size of the receive window, which specifies the number of window size units (by default,...
Definition: TcpLayer.h:80
uint16_t finFlag
FIN flag.
Definition: TcpLayer.h:38
uint16_t ackFlag
ACK flag.
Definition: TcpLayer.h:46
uint32_t ackNumber
Acknowledgment number.
Definition: TcpLayer.h:29
uint16_t headerChecksum
The 16-bit checksum field is used for error-checking of the header and data.
Definition: TcpLayer.h:82