PcapPlusPlus  Next
PayloadLayer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Layer.h"
4 
6 
11 namespace pcpp
12 {
13 
18  class PayloadLayer : public Layer
19  {
20  public:
27  PayloadLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet)
28  : Layer(data, dataLen, prevLayer, packet, GenericPayload)
29  {}
30 
36  PayloadLayer(const uint8_t* data, size_t dataLen);
37 
46  explicit PayloadLayer(const std::string& payloadAsHexStream);
47 
48  ~PayloadLayer() override = default;
49 
54  uint8_t* getPayload() const
55  {
56  return m_Data;
57  }
58 
63  size_t getPayloadLen() const
64  {
65  return m_DataLen;
66  }
67 
68  // implement abstract methods
69 
73  void parseNextLayer() override
74  {}
75 
79  size_t getHeaderLen() const override
80  {
81  return m_DataLen;
82  }
83 
87  void computeCalculateFields() override
88  {}
89 
96  void setPayload(const uint8_t* newPayload, size_t newPayloadLength);
97 
98  std::string toString() const override;
99 
101  {
103  }
104  };
105 
106 } // namespace pcpp
Definition: Layer.h:69
Definition: Packet.h:27
Definition: PayloadLayer.h:19
uint8_t * getPayload() const
Definition: PayloadLayer.h:54
OsiModelLayer getOsiModelLayer() const override
Definition: PayloadLayer.h:100
void parseNextLayer() override
Definition: PayloadLayer.h:73
void computeCalculateFields() override
Definition: PayloadLayer.h:87
PayloadLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: PayloadLayer.h:27
PayloadLayer(const std::string &payloadAsHexStream)
PayloadLayer(const uint8_t *data, size_t dataLen)
void setPayload(const uint8_t *newPayload, size_t newPayloadLength)
size_t getPayloadLen() const
Definition: PayloadLayer.h:63
std::string toString() const override
size_t getHeaderLen() const override
Definition: PayloadLayer.h:79
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:364
@ OsiModelApplicationLayer
Definition: ProtocolType.h:378
const ProtocolType GenericPayload
Definition: ProtocolType.h:178