PcapPlusPlus
|
#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 () |
TcpOptionData * | getTcpOptionData (TcpOption option) |
TcpOptionData * | getFirstTcpOptionData () |
TcpOptionData * | getNextTcpOptionData (TcpOptionData *tcpOption) |
size_t | getTcpOptionsCount () |
TcpOptionData * | addTcpOption (TcpOption optionType, uint8_t optionLength, const uint8_t *optionData) |
TcpOptionData * | addTcpOptionAfter (TcpOption optionType, uint8_t optionLength, const uint8_t *optionData, TcpOptionData *prevOption) |
bool | removeTcpOption (TcpOption optionType) |
bool | removeAllTcpOptions () |
uint16_t | calculateChecksum (bool writeResultToPacket) |
void | parseNextLayer () |
size_t | getHeaderLen () |
void | computeCalculateFields () |
std::string | toString () |
OsiModelLayer | getOsiModelLayer () |
Public Member Functions inherited from pcpp::Layer | |
virtual | ~Layer () |
Layer * | getNextLayer () |
Layer * | getPrevLayer () |
ProtocolType | getProtocol () |
uint8_t * | getData () |
size_t | getDataLen () |
uint8_t * | getLayerPayload () |
size_t | getLayerPayloadSize () |
bool | isAllocatedToPacket () |
void | copyData (uint8_t *toArr) |
uint8_t * | getDataPtr (size_t offset=0) |
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)
TcpOptionData* pcpp::TcpLayer::addTcpOption | ( | TcpOption | optionType, |
uint8_t | optionLength, | ||
const uint8_t * | optionData | ||
) |
Add a new TCP option at the end of the layer (after the last TCP option)
[in] | optionType | The type of the newly added option |
[in] | optionLength | The length of the option data |
[in] | optionData | A pointer to the option data. This data will be copied to added option data. Notice the length of optionData must be optionLength |
TcpOptionData* pcpp::TcpLayer::addTcpOptionAfter | ( | TcpOption | optionType, |
uint8_t | optionLength, | ||
const uint8_t * | optionData, | ||
TcpOptionData * | prevOption | ||
) |
Add a new TCP option after an existing TCP option
[in] | optionType | The type of the newly added option |
[in] | optionLength | The length of the option data |
[in] | optionData | A pointer to the option data. This data will be copied to added option data. Notice the length of optionData must be optionLength |
[in] | prevOption | The TCP option which the newly added tag will come after. If set to NULL TCP option will be added as the first TCP option |
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.
TcpOptionData* pcpp::TcpLayer::getFirstTcpOptionData | ( | ) |
|
inlinevirtual |
Implements pcpp::Layer.
TcpOptionData* pcpp::TcpLayer::getNextTcpOptionData | ( | TcpOptionData * | tcpOption | ) |
Get the TCP option which comes next to "tcpOption" parameter. If "tcpOption" is NULL then NULL will be returned. If "tcpOption" is the last TCP option NULL will be returned. Notice the return value is a pointer to the real data casted to TcpOptionData type (as opposed to a copy of the option data). So changes in the return value will affect the packet data
[in] | tcpOption | The TCP option to start searching from |
|
inlinevirtual |
Implements pcpp::Layer.
|
inline |
Get a pointer to the TCP header. Notice this points directly to the data, so every change will change the actual packet data
TcpOptionData* pcpp::TcpLayer::getTcpOptionData | ( | TcpOption | option | ) |
Get a pointer to a TCP option. Notice this points directly to the data, so every change will change the actual packet data
[in] | option | The TCP option to get |
size_t pcpp::TcpLayer::getTcpOptionsCount | ( | ) |
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 | ( | TcpOption | 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.