24 virtual uint8_t*
getDataPtr(
size_t offset = 0)
const = 0;
126 return m_Packet !=
nullptr;
137 return static_cast<uint8_t*
>(m_Data + offset);
165 bool m_IsAllocatedInPacket;
168 : m_Data(nullptr), m_DataLen(0), m_Packet(nullptr), m_Protocol(
UnknownProtocol), m_NextLayer(nullptr),
169 m_PrevLayer(nullptr), m_IsAllocatedInPacket(false)
173 : m_Data(data), m_DataLen(dataLen), m_Packet(packet), m_Protocol(protocol), m_NextLayer(nullptr),
174 m_PrevLayer(prevLayer), m_IsAllocatedInPacket(false)
178 Layer(
const Layer& other);
179 Layer& operator=(
const Layer& other);
181 void setNextLayer(Layer* nextLayer)
183 m_NextLayer = nextLayer;
185 void setPrevLayer(Layer* prevLayer)
187 m_PrevLayer = prevLayer;
190 virtual bool extendLayer(
int offsetInLayer,
size_t numOfBytesToExtend);
191 virtual bool shortenLayer(
int offsetInLayer,
size_t numOfBytesToShorten);
194 inline std::ostream& operator<<(std::ostream& os,
const pcpp::Layer& layer)
virtual uint8_t * getDataPtr(size_t offset=0) const =0
void copyData(uint8_t *toArr) const
uint8_t * getLayerPayload() const
Definition: Layer.h:104
virtual std::string toString() const =0
size_t getDataLen() const
Definition: Layer.h:98
uint8_t * getDataPtr(size_t offset=0) const override
Definition: Layer.h:135
uint8_t * getData() const
Definition: Layer.h:92
virtual void parseNextLayer()=0
Each layer is responsible for parsing the next layer.
bool isMemberOfProtocolFamily(ProtocolTypeFamily protocolTypeFamily) const
Layer * getNextLayer() const
Definition: Layer.h:69
bool isAllocatedToPacket() const
Definition: Layer.h:124
Layer * getPrevLayer() const
Definition: Layer.h:75
ProtocolType getProtocol() const
Definition: Layer.h:81
size_t getLayerPayloadSize() const
Definition: Layer.h:110
virtual void computeCalculateFields()=0
Each layer can compute field values automatically using this method. This is an abstract method.
virtual size_t getHeaderLen() const =0
virtual OsiModelLayer getOsiModelLayer() const =0
The main namespace for the PcapPlusPlus lib.
uint8_t ProtocolType
Definition: ProtocolType.h:13
OsiModelLayer
An enum representing OSI model layers.
Definition: ProtocolType.h:225
uint32_t ProtocolTypeFamily
Definition: ProtocolType.h:17
const ProtocolType UnknownProtocol
Unknown protocol (or unsupported by PcapPlusPlus)
Definition: ProtocolType.h:20