PcapPlusPlus
Next
|
#include <ModbusLayer.h>
Classes | |
struct | ModbusReadInputRegisters |
Public Types | |
enum class | ModbusFunctionCode : uint8_t { ReadCoils = 1 , ReadDiscreteInputs = 2 , ReadHoldingRegisters = 3 , ReadInputRegisters = 4 , WriteSingleCoil = 5 , WriteSingleHoldingRegister = 6 , WriteMultipleCoils = 15 , WriteMultipleHoldingRegisters = 16 , ReadSlaveId = 17 , UnknownFunction = 0xFF } |
Enum class representing Modbus function codes. This enumeration defines the standard Modbus function codes used in request and response PDUs. Each value corresponds to a specific operation defined by the Modbus protocol. More... | |
Public Member Functions | |
ModbusLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet) | |
ModbusLayer (uint16_t transactionId, uint8_t unitId) | |
uint16_t | getTransactionId () const |
uint16_t | getProtocolId () const |
uint16_t | getLength () const |
uint8_t | getUnitId () const |
ModbusFunctionCode | getFunctionCode () const |
void | setTransactionId (uint16_t transactionId) |
set the MODBUS transaction id More... | |
void | setUnitId (uint8_t unitId) |
set the MODBUS header unit id More... | |
void | setFunctionCode (ModbusFunctionCode functionCode) |
set the MODBUS header function code More... | |
void | parseNextLayer () override |
Does nothing for this layer (ModbusLayer is always last) | |
size_t | getHeaderLen () const override |
Get the length of the MODBUS header. More... | |
void | computeCalculateFields () override |
Does nothing for this layer. | |
std::string | toString () const override |
OsiModelLayer | getOsiModelLayer () const override |
![]() | |
~Layer () override | |
Layer * | getNextLayer () const |
Layer * | getPrevLayer () 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 | isModbusPort (uint16_t port) |
Check if a port is a valid MODBUS port. More... | |
Additional Inherited Members | |
![]() | |
template<typename T , typename... Args> | |
Layer * | constructNextLayer (uint8_t *data, size_t dataLen, Packet *packet, Args &&... extraArgs) |
template<typename T , typename TFallback , typename... Args> | |
Layer * | tryConstructNextLayerWithFallback (uint8_t *data, size_t dataLen, Packet *packet, Args &&... extraArgs) |
![]() | |
template<typename T > | |
static bool | canReinterpretAs (const uint8_t *data, size_t dataLen) |
Check if the data is large enough to reinterpret as a type. More... | |
Represents the MODBUS Application Protocol layer
|
strong |
Enum class representing Modbus function codes. This enumeration defines the standard Modbus function codes used in request and response PDUs. Each value corresponds to a specific operation defined by the Modbus protocol.
|
inline |
A constructor that creates the layer from an existing packet raw data
[in] | data | A pointer to the raw data |
[in] | dataLen | Size of the data in bytes |
[in] | prevLayer | A pointer to the previous layer |
[in] | packet | A pointer to the Packet instance where layer will be stored in |
pcpp::ModbusLayer::ModbusLayer | ( | uint16_t | transactionId, |
uint8_t | unitId | ||
) |
A constructor that creates the layer from user inputs
[in] | transactionId | Transaction ID |
[in] | unitId | Unit ID |
ModbusFunctionCode pcpp::ModbusLayer::getFunctionCode | ( | ) | const |
|
inlineoverridevirtual |
Get the length of the MODBUS header.
Implements pcpp::Layer.
uint16_t pcpp::ModbusLayer::getLength | ( | ) | const |
|
inlineoverridevirtual |
Implements pcpp::Layer.
uint16_t pcpp::ModbusLayer::getProtocolId | ( | ) | const |
uint16_t pcpp::ModbusLayer::getTransactionId | ( | ) | const |
uint8_t pcpp::ModbusLayer::getUnitId | ( | ) | const |
|
inlinestatic |
Check if a port is a valid MODBUS port.
port | Port number to check |
void pcpp::ModbusLayer::setFunctionCode | ( | ModbusFunctionCode | functionCode | ) |
set the MODBUS header function code
functionCode | function code |
void pcpp::ModbusLayer::setTransactionId | ( | uint16_t | transactionId | ) |
set the MODBUS transaction id
transactionId | transaction id |
void pcpp::ModbusLayer::setUnitId | ( | uint8_t | unitId | ) |
set the MODBUS header unit id
unitId | unit id |
|
overridevirtual |
Implements pcpp::Layer.