PcapPlusPlus  Next
pcpp::S7CommLayer Class Reference

#include <S7CommLayer.h>

Inheritance diagram for pcpp::S7CommLayer:
pcpp::Layer pcpp::IDataContainer

Public Member Functions

 S7CommLayer (uint8_t msgType, uint16_t pduRef, uint16_t paramLength, uint16_t dataLength, uint8_t errorClass=0, uint8_t errorCode=0)
 
 S7CommLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
uint8_t getProtocolId () const
 
uint8_t getMsgType () const
 
uint16_t getPduRef () const
 
uint16_t getParamLength () const
 
uint16_t getDataLength () const
 
uint8_t getErrorCode () const
 
uint8_t getErrorClass () const
 
const S7CommParametergetParameter ()
 
void setMsgType (uint8_t msgType) const
 
void setPduRef (uint16_t pduRef) const
 
void setErrorCode (uint8_t errorCode) const
 
void setErrorClass (uint8_t errorClass) const
 
size_t getHeaderLen () const override
 
void computeCalculateFields () override
 Does nothing for this layer (S7CommLayer is always last)
 
void parseNextLayer () override
 Does nothing for this layer (S7CommLayer is always last)
 
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 isDataValid (const uint8_t *data, size_t dataSize)
 

Detailed Description

Represents a S7COMM (S7 Communication) protocol

Constructor & Destructor Documentation

◆ S7CommLayer() [1/2]

pcpp::S7CommLayer::S7CommLayer ( uint8_t  msgType,
uint16_t  pduRef,
uint16_t  paramLength,
uint16_t  dataLength,
uint8_t  errorClass = 0,
uint8_t  errorCode = 0 
)

A constructor that allocates a new S7comm header

Parameters
[in]msgTypeThe general type of the message
[in]pduRefLink responses to their requests
[in]paramLengthThe length of the parameter field
[in]dataLengthThe length of the data field
[in]errorClassThe value of the error class
[in]errorCodeThe value of the error code

◆ S7CommLayer() [2/2]

pcpp::S7CommLayer::S7CommLayer ( 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 s7commhdr)
[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

Member Function Documentation

◆ getDataLength()

uint16_t pcpp::S7CommLayer::getDataLength ( ) const
Returns
S7comm data length

◆ getErrorClass()

uint8_t pcpp::S7CommLayer::getErrorClass ( ) const
Returns
S7comm error class

◆ getErrorCode()

uint8_t pcpp::S7CommLayer::getErrorCode ( ) const
Returns
S7comm error code

◆ getHeaderLen()

size_t pcpp::S7CommLayer::getHeaderLen ( ) const
inlineoverridevirtual
Returns
Size of S7CommLayer

Implements pcpp::Layer.

◆ getMsgType()

uint8_t pcpp::S7CommLayer::getMsgType ( ) const
Returns
S7comm message type

◆ getOsiModelLayer()

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

Implements pcpp::Layer.

◆ getParameter()

const S7CommParameter* pcpp::S7CommLayer::getParameter ( )
Returns
S7comm parameter

◆ getParamLength()

uint16_t pcpp::S7CommLayer::getParamLength ( ) const
Returns
S7comm parameter length

◆ getPduRef()

uint16_t pcpp::S7CommLayer::getPduRef ( ) const
Returns
S7comm PDU ref

◆ getProtocolId()

uint8_t pcpp::S7CommLayer::getProtocolId ( ) const
Returns
S7comm protocol id

◆ isDataValid()

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

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

Parameters
[in]dataA byte array
[in]dataSizeThe byte array size (in bytes)
Returns
True if the data looks like a valid S7COMM layer

◆ setErrorClass()

void pcpp::S7CommLayer::setErrorClass ( uint8_t  errorClass) const

Set the value of the error class

Parameters
[in]errorClassThe value of the error class

◆ setErrorCode()

void pcpp::S7CommLayer::setErrorCode ( uint8_t  errorCode) const

Set the value of the error code

Parameters
[in]errorCodeThe value of the error code

◆ setMsgType()

void pcpp::S7CommLayer::setMsgType ( uint8_t  msgType) const

Set the value of the message type

Parameters
[in]msgTypeThe value of the message type

◆ setPduRef()

void pcpp::S7CommLayer::setPduRef ( uint16_t  pduRef) const

Set the value of the PDU ref

Parameters
[in]pduRefThe value of the PDU ref

◆ toString()

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

Implements pcpp::Layer.