PcapPlusPlus  Next
pcpp::TpktLayer Class Reference

#include <TpktLayer.h>

Inheritance diagram for pcpp::TpktLayer:
pcpp::Layer pcpp::IDataContainer

Public Member Functions

 TpktLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 TpktLayer (uint8_t version, uint16_t length)
 
uint8_t getReserved () const
 
uint8_t getVersion () const
 
uint16_t getLength () const
 
void setVersion (uint8_t version) const
 
void setLength (uint16_t length) const
 
size_t getHeaderLen () const override
 
void computeCalculateFields () override
 
void parseNextLayer () override
 
std::string toString () const override
 
OsiModelLayer getOsiModelLayer () const override
 
- Public Member Functions inherited from pcpp::Layer
 ~Layer () override
 
LayergetNextLayer () const
 
LayergetPrevLayer () const
 
ProtocolType getProtocol () const
 
bool isMemberOfProtocolFamily (ProtocolTypeFamily protocolTypeFamily) 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 override
 

Static Public Member Functions

static bool isTpktPort (uint16_t portSrc, uint16_t portDst)
 
static bool isDataValid (const uint8_t *data, size_t dataSize)
 

Detailed Description

Represents a TPKT (Transport Service on top of the TCP) protocol layer

Constructor & Destructor Documentation

◆ TpktLayer() [1/2]

pcpp::TpktLayer::TpktLayer ( uint8_t *  data,
size_t  dataLen,
Layer prevLayer,
Packet packet 
)
inline

A constructor that creates the layer from an existing packet raw data

Parameters
[in]dataA pointer to the raw data (will be casted to tpkthdr)
[in]dataLenSize of the data in bytes
[in]prevLayerA pointer to the previous layer
[in]packetA pointer to the Packet instance where layer will be stored in

◆ TpktLayer() [2/2]

pcpp::TpktLayer::TpktLayer ( uint8_t  version,
uint16_t  length 
)

A constructor that allocates a new TPKT header

Parameters
[in]versionProtocol version number
[in]lengthPacket length

Member Function Documentation

◆ computeCalculateFields()

void pcpp::TpktLayer::computeCalculateFields ( )
inlineoverridevirtual

Does nothing for this layer

Implements pcpp::Layer.

◆ getHeaderLen()

size_t pcpp::TpktLayer::getHeaderLen ( ) const
inlineoverridevirtual
Returns
Size of tpkthdr

Implements pcpp::Layer.

◆ getLength()

uint16_t pcpp::TpktLayer::getLength ( ) const
Returns
TPKT length

◆ getOsiModelLayer()

OsiModelLayer pcpp::TpktLayer::getOsiModelLayer ( ) const
inlineoverridevirtual
Returns
The OSI Model layer this protocol belongs to

Implements pcpp::Layer.

◆ getReserved()

uint8_t pcpp::TpktLayer::getReserved ( ) const
Returns
TPKT reserved

◆ getVersion()

uint8_t pcpp::TpktLayer::getVersion ( ) const
Returns
TPKT version

◆ isDataValid()

static bool pcpp::TpktLayer::isDataValid ( const uint8_t *  data,
size_t  dataSize 
)
inlinestatic

A static method that takes a byte array and detects whether it is a TPKT message

Parameters
[in]dataA byte array
[in]dataSizeThe byte array size (in bytes)
Returns
True if the data size is greater or equal than the size of tpkthdr

◆ isTpktPort()

static bool pcpp::TpktLayer::isTpktPort ( uint16_t  portSrc,
uint16_t  portDst 
)
inlinestatic

A static method that checks whether a source or dest port match those associated with the TPKT protocol

Parameters
[in]portSrcSource port number to check
[in]portDstDest port number to check
Returns
True if the source or dest port match those associated with the TPKT protocol

◆ parseNextLayer()

void pcpp::TpktLayer::parseNextLayer ( )
overridevirtual

Currently parses the rest of the packet as a COTP protocol or generic payload (PayloadLayer)

Implements pcpp::Layer.

◆ setLength()

void pcpp::TpktLayer::setLength ( uint16_t  length) const

Set the value of the length

Parameters
[in]lengthThe value of the length

◆ setVersion()

void pcpp::TpktLayer::setVersion ( uint8_t  version) const

Set the value of the version

Parameters
[in]versionThe value of the version

◆ toString()

std::string pcpp::TpktLayer::toString ( ) const
overridevirtual
Returns
A string representation of the layer most important data (should look like the layer description in Wireshark)

Implements pcpp::Layer.