PcapPlusPlus  Next
pcpp::GvcpLayer Class Referenceabstract

#include <GvcpLayer.h>

Inheritance diagram for pcpp::GvcpLayer:
pcpp::Layer pcpp::IDataContainer pcpp::GvcpAcknowledgeLayer pcpp::GvcpRequestLayer pcpp::GvcpDiscoveryAcknowledgeLayer pcpp::GvcpForceIpAcknowledgeLayer pcpp::GvcpDiscoveryRequestLayer pcpp::GvcpForceIpRequestLayer

Classes

struct  SerializedFields
 

Public Types

enum class  GvcpCommand : uint16_t {
  DiscoveredCmd = 0x0002 , DiscoveredAck = 0x0003 , ForceIpCmd = 0x0004 , ForceIpAck = 0x0005 ,
  PacketResendCmd = 0x0040 , PacketResendAck = 0x0041 , ReadRegCmd = 0x0080 , ReadRegAck = 0x0081 ,
  WriteRegCmd = 0x0082 , WriteRegAck = 0x0083 , ReadMemCmd = 0x0084 , ReadMemAck = 0x0085 ,
  WriteMemCmd = 0x0086 , WriteMemAck = 0x0087 , PendingAck = 0x0089 , EventCmd = 0x00C0 ,
  EventAck = 0x00C1 , EventDataCmd = 0x00C2 , EventDataAck = 0x00C3 , ActionCmd = 0x0100 ,
  ActionAck = 0x0101 , Unknown = 0xFFFF
}
 

Public Member Functions

virtual GvcpCommand getCommand () const =0
 
virtual uint16_t getDataSize () const =0
 
void parseNextLayer () override
 Creates a PayloadLayer from the rest of the message, if there is data after this layer.
 
OsiModelLayer getOsiModelLayer () const override
 
- Public Member Functions inherited from pcpp::Layer
 ~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
 Copy the raw data of this layer to another array. More...
 
size_t copyData (uint8_t *dest, size_t destSize) const
 Copy the raw data of this layer to another array, with a specified maximum size. More...
 
void serialize (ISerializer &serializer) const
 
uint8_t * getDataPtr (size_t offset=0) const override
 
virtual size_t getHeaderLen () const =0
 
virtual void computeCalculateFields ()=0
 Each layer can compute field values automatically using this method. This is an abstract method.
 
virtual std::string toString () const =0
 

Static Public Member Functions

static bool isGvcpPort (uint16_t port)
 
static GvcpLayer * parseGvcpLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 

Protected Member Functions

void serializeLayer (ObjectScope &serializer) const override
 
void initLayer (size_t dataLen)
 
- Protected Member Functions inherited from pcpp::Layer
Packet * getAttachedPacket ()
 Get a pointer to the Packet this layer is attached to (if any). More...
 
Packet const * getAttachedPacket () const
 Get a pointer to the Packet this layer is attached to (if any). More...
 
void allocData (size_t dataLen, bool zeroInit=true)
 Requests the layer to allocate a new data buffer of the specified length. More...
 
template<typename T , typename... Args>
Layer * constructNextLayer (uint8_t *data, size_t dataLen, Args &&... extraArgs)
 Construct the next layer in the protocol stack. No validation is performed on the data. More...
 
template<typename T , typename... Args>
Layer * constructNextLayer (uint8_t *data, size_t dataLen, Packet *packet, Args &&... extraArgs)
 
template<typename TFactory , typename... Args>
Layer * constructNextLayerFromFactory (TFactory factoryFn, uint8_t *data, size_t dataLen, Args &&... extraArgs)
 Construct the next layer in the protocol stack using a factory functor. More...
 
template<typename TFactory , typename... Args>
Layer * constructNextLayerFromFactory (TFactory factoryFn, uint8_t *data, size_t dataLen, Packet *packet, Args &&... extraArgs)
 Construct the next layer in the protocol stack using a factory functor. More...
 
template<typename T , typename... Args>
Layer * tryConstructNextLayer (uint8_t *data, size_t dataLen, Args &&... extraArgs)
 
template<typename T , typename... Args>
Layer * tryConstructNextLayer (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, Args &&... extraArgs)
 Try to construct the next layer in the protocol stack with a fallback option. More...
 
template<typename T , typename TFallback , typename... Args>
Layer * tryConstructNextLayerWithFallback (uint8_t *data, size_t dataLen, Packet *packet, Args &&... extraArgs)
 
template<typename TFallback , typename TFactory , typename... Args>
Layer * tryConstructNextLayerFromFactoryWithFallback (TFactory factoryFn, uint8_t *data, size_t dataLen, Args &&... extraArgs)
 Try to construct the next layer in the protocol stack using a factory functor with a fallback option. More...
 
template<typename TFallback , typename TFactory , typename... Args>
Layer * tryConstructNextLayerFromFactoryWithFallback (TFactory factoryFn, uint8_t *data, size_t dataLen, Packet *packet, Args &&... extraArgs)
 Try to construct the next layer in the protocol stack using a factory functor with a fallback option. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from pcpp::Layer
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...
 

Detailed Description

An abstract class representing the GigE Vision Control Protocol (GVCP). The class is implemented according to the GigE Vision specification 2.0. A GVCP layer holds the GVCP header, followed by the message fields that its class knows how to parse. parseNextLayer() puts the rest of the message, if any, in a PayloadLayer

See also
https://en.wikipedia.org/wiki/GigE_Vision
Note
The class cannot be instantiated directly, use GvcpRequestLayer, GvcpAcknowledgeLayer or their derived classes

Member Enumeration Documentation

◆ GvcpCommand

enum pcpp::GvcpLayer::GvcpCommand : uint16_t
strong

GVCP command defines the command values and the corresponding acknowledge values. See more in the spec "18 Command and Acknowledge Values"

Enumerator
DiscoveredCmd 

Discovery command (Discovery Protocol Control)

DiscoveredAck 

Discovery acknowledge (Discovery Protocol Control)

ForceIpCmd 

Force IP command (Discovery Protocol Control)

ForceIpAck 

Force IP acknowledge (Discovery Protocol Control)

PacketResendCmd 

Packet resend command (Streaming Protocol Control)

PacketResendAck 

Packet resend acknowledge (Streaming Protocol Control). The resent packet must be on the stream channel.

ReadRegCmd 

Read register command (Device Memory Access)

ReadRegAck 

Read register acknowledge (Device Memory Access)

WriteRegCmd 

Write register command (Device Memory Access)

WriteRegAck 

Write register acknowledge (Device Memory Access)

ReadMemCmd 

Read memory command (Device Memory Access)

ReadMemAck 

Read memory acknowledge (Device Memory Access)

WriteMemCmd 

Write memory command (Device Memory Access)

WriteMemAck 

Write memory acknowledge (Device Memory Access)

PendingAck 

Pending acknowledge (Device Memory Access)

EventCmd 

Event command (Asynchronous Events)

EventAck 

Event acknowledge (Asynchronous Events)

EventDataCmd 

Event data command (Asynchronous Events)

EventDataAck 

Event data acknowledge (Asynchronous Events)

ActionCmd 

Action command (Miscellaneous)

ActionAck 

Action acknowledge (Miscellaneous)

Unknown 

Unknown command.

Member Function Documentation

◆ getCommand()

virtual GvcpCommand pcpp::GvcpLayer::getCommand ( ) const
pure virtual
Returns
The command (or acknowledge) value of this message, GvcpCommand::Unknown if the value isn't defined by the spec

Implemented in pcpp::GvcpAcknowledgeLayer, and pcpp::GvcpRequestLayer.

◆ getDataSize()

virtual uint16_t pcpp::GvcpLayer::getDataSize ( ) const
pure virtual
Returns
The data size field from the header, meaning the size of the message without the GVCP header

Implemented in pcpp::GvcpAcknowledgeLayer, and pcpp::GvcpRequestLayer.

◆ getOsiModelLayer()

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

Implements pcpp::Layer.

◆ initLayer()

void pcpp::GvcpLayer::initLayer ( size_t  dataLen)
protected

Allocate zeroed data for a new layer and set the protocol

Parameters
[in]dataLenThe size of the data to allocate in bytes

◆ isGvcpPort()

static bool pcpp::GvcpLayer::isGvcpPort ( uint16_t  port)
inlinestatic

A static method that checks whether the port is considered as GVCP

Parameters
[in]portThe port number to be checked
Returns
True if the port is the GVCP port (3956), false otherwise

◆ parseGvcpLayer()

static GvcpLayer* pcpp::GvcpLayer::parseGvcpLayer ( uint8_t *  data,
size_t  dataLen,
Layer *  prevLayer,
Packet *  packet 
)
static

A static method that parses the raw data and creates the matching GVCP layer. If the data begins with the GVCP magic number, the method creates a request layer, otherwise an acknowledge layer. For Discovery and Force IP messages, the method creates their specific layers, unless the data is too short for the fields of these messages

Parameters
[in]dataA pointer to the raw data
[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
Returns
A pointer to the newly created GVCP layer, or nullptr if the data isn't a valid GVCP message

◆ serializeLayer()

void pcpp::GvcpLayer::serializeLayer ( ObjectScope &  serializer) const
overrideprotectedvirtual

Serializes the layer's data into a provided serializer object. This is used for generating serialized representations (like JSON) of the packet layers. This method should be overridden by derived layers to provide specific serialization logic.

Parameters
[in]serializerThe object scope serializer to which the layer details should be written.

Reimplemented from pcpp::Layer.

Reimplemented in pcpp::GvcpForceIpRequestLayer, pcpp::GvcpDiscoveryAcknowledgeLayer, pcpp::GvcpDiscoveryRequestLayer, pcpp::GvcpAcknowledgeLayer, and pcpp::GvcpRequestLayer.