PcapPlusPlus
22.11
|
#include <TcpLayer.h>
Public Member Functions | |
TcpLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet) | |
TcpLayer () | |
TcpLayer (uint16_t portSrc, uint16_t portDst) | |
TcpLayer (const TcpLayer &other) | |
TcpLayer & | operator= (const TcpLayer &other) |
tcphdr * | getTcpHeader () const |
uint16_t | getSrcPort () const |
uint16_t | getDstPort () const |
TcpOption | getTcpOption (TcpOptionType option) const |
TcpOption | getFirstTcpOption () const |
TcpOption | getNextTcpOption (TcpOption &tcpOption) const |
size_t | getTcpOptionCount () const |
TcpOption | addTcpOption (const TcpOptionBuilder &optionBuilder) |
TcpOption | addTcpOptionAfter (const TcpOptionBuilder &optionBuilder, TcpOptionType prevOptionType=TCPOPT_Unknown) |
bool | removeTcpOption (TcpOptionType optionType) |
bool | removeAllTcpOptions () |
uint16_t | calculateChecksum (bool writeResultToPacket) |
void | parseNextLayer () |
size_t | getHeaderLen () const |
void | computeCalculateFields () |
std::string | toString () const |
OsiModelLayer | getOsiModelLayer () const |
Public Member Functions inherited from pcpp::Layer | |
virtual | ~Layer () |
Layer * | getNextLayer () const |
Layer * | getPrevLayer () const |
ProtocolType | getProtocol () const |
uint8_t * | getData () const |
size_t | getDataLen () const |
uint8_t * | getLayerPayload () const |
size_t | getLayerPayloadSize () const |
bool | isAllocatedToPacket () const |
void | copyData (uint8_t *toArr) const |
uint8_t * | getDataPtr (size_t offset=0) const |
Static Public Member Functions | |
static bool | isDataValid (const uint8_t *data, size_t dataLen) |
Represents a TCP (Transmission Control Protocol) protocol layer
pcpp::TcpLayer::TcpLayer | ( | ) |
A constructor that allocates a new TCP header with zero TCP options
pcpp::TcpLayer::TcpLayer | ( | uint16_t | portSrc, |
uint16_t | portDst | ||
) |
A constructor that allocates a new TCP header with source port and destination port and zero TCP options
[in] | portSrc | Source port |
[in] | portDst | Destination port |
pcpp::TcpLayer::TcpLayer | ( | const TcpLayer & | other | ) |
A copy constructor that copy the entire header from the other TcpLayer (including TCP options)
TcpOption pcpp::TcpLayer::addTcpOption | ( | const TcpOptionBuilder & | optionBuilder | ) |
Add a new TCP option at the end of the layer (after the last TCP option)
[in] | optionBuilder | A TcpOptionBuilder object that contains the TCP option data to be added |
TcpOption pcpp::TcpLayer::addTcpOptionAfter | ( | const TcpOptionBuilder & | optionBuilder, |
TcpOptionType | prevOptionType = TCPOPT_Unknown |
||
) |
Add a new TCP option after an existing one
[in] | optionBuilder | A TcpOptionBuilder object that contains the requested TCP option data to be added |
[in] | prevOptionType | The TCP option which the newly added option should come after. This is an optional parameter which gets a default value of TCPOPT_Unknown if omitted, which means the new option will be added as the first option in the layer |
uint16_t pcpp::TcpLayer::calculateChecksum | ( | bool | writeResultToPacket | ) |
Calculate the checksum from header and data and possibly write the result to tcphdr::headerChecksum
[in] | writeResultToPacket | If set to true then checksum result will be written to tcphdr::headerChecksum |
|
virtual |
Calculate tcphdr::headerChecksum field
Implements pcpp::Layer.
uint16_t pcpp::TcpLayer::getDstPort | ( | ) | const |
TcpOption pcpp::TcpLayer::getFirstTcpOption | ( | ) | const |
|
inlinevirtual |
Implements pcpp::Layer.
Get the TCP option that comes after a given option. If the given option was the last one, the returned value will contain a logical NULL (TcpOption::isNull() == true)
[in] | tcpOption | A TCP option object that exists in the current layer |
|
inlinevirtual |
Implements pcpp::Layer.
uint16_t pcpp::TcpLayer::getSrcPort | ( | ) | const |
|
inline |
Get a pointer to the TCP header. Notice this points directly to the data, so every change will change the actual packet data
TcpOption pcpp::TcpLayer::getTcpOption | ( | TcpOptionType | option | ) | const |
Get a TCP option by type
[in] | option | TCP option type to retrieve |
size_t pcpp::TcpLayer::getTcpOptionCount | ( | ) | const |
|
inlinestatic |
The static method makes validation of input data
[in] | data | The pointer to the beginning of byte stream of TCP packet |
[in] | dataLen | The length of byte stream |
An assignment operator that first delete all data from current layer and then copy the entire header from the other TcpLayer (including TCP options)
|
virtual |
Currently identifies the following next layers: HttpRequestLayer, HttpResponseLayer. Otherwise sets PayloadLayer
Implements pcpp::Layer.
bool pcpp::TcpLayer::removeAllTcpOptions | ( | ) |
Remove all TCP options in this layer
bool pcpp::TcpLayer::removeTcpOption | ( | TcpOptionType | optionType | ) |
Remove an existing TCP option from the layer. TCP option is found by type
[in] | optionType | The TCP option type to remove |
|
virtual |
Implements pcpp::Layer.