34 size_t m_MaxPacketLen;
36 bool m_CanReallocateData;
45 explicit Packet(
size_t maxPacketLen = 1);
57 Packet(uint8_t* buffer,
size_t bufferSize);
128 destructPacketData();
216 return insertLayer(m_LastLayer, newLayer, ownInPacket);
323 template <
class TLayer> TLayer*
getLayerOfType(
bool reverseOrder =
false)
const;
374 std::string
toString(
bool timeAsLocalTime =
true)
const;
382 void toStringList(std::vector<std::string>& result,
bool timeAsLocalTime =
true)
const;
385 void copyDataFrom(
const Packet& other);
387 void destructPacketData();
389 bool extendLayer(
Layer* layer,
int offsetInLayer,
size_t numOfBytesToExtend);
390 bool shortenLayer(
Layer* layer,
int offsetInLayer,
size_t numOfBytesToShorten);
392 void reallocateRawData(
size_t newSize);
396 std::string printPacketInfo(
bool timeAsLocalTime)
const;
422 if (curLayer ==
nullptr)
426 while ((curLayer !=
nullptr) && (
dynamic_cast<TLayer*
>(curLayer) ==
nullptr))
431 return dynamic_cast<TLayer*
>(curLayer);
436 if (curLayer ==
nullptr)
440 while (curLayer !=
nullptr &&
dynamic_cast<TLayer*
>(curLayer) ==
nullptr)
445 return dynamic_cast<TLayer*
>(curLayer);
450 inline std::ostream& operator<<(std::ostream& os,
const pcpp::Packet& packet)
Layer * getNextLayer() const
Definition: Layer.h:83
Layer * getPrevLayer() const
Definition: Layer.h:91
bool isPacketOfType(ProtocolType protocolType) const
bool insertLayer(Layer *prevLayer, Layer *newLayer, bool ownInPacket=false)
Packet(const Packet &other)
Definition: Packet.h:136
Packet(size_t maxPacketLen=1)
RawPacket * getRawPacketReadOnly() const
Definition: Packet.h:181
Packet & operator=(const Packet &other)
bool removeLayer(ProtocolType layerType, int index=0)
virtual ~Packet()
Definition: Packet.h:126
Layer * detachLayer(ProtocolType layerType, int index=0)
Packet(uint8_t *buffer, size_t bufferSize)
RawPacket * getRawPacket() const
Definition: Packet.h:155
bool isPacketOfType(ProtocolTypeFamily protocolTypeFamily) const
bool removeAllLayersAfter(Layer *layer)
void setRawPacket(RawPacket *rawPacket, bool freeRawPacket, ProtocolTypeFamily parseUntil=UnknownProtocol, OsiModelLayer parseUntilLayer=OsiModelLayerUnknown)
Layer * getLayerOfType(ProtocolType layerType, int index=0) const
TLayer * getPrevLayerOfType(Layer *startLayer) const
Definition: Packet.h:434
Packet(RawPacket *rawPacket, OsiModelLayer parseUntilLayer)
Layer * getLastLayer() const
Definition: Packet.h:199
std::string toString(bool timeAsLocalTime=true) const
TLayer * getNextLayerOfType(Layer *startLayer) const
Definition: Packet.h:420
Packet(RawPacket *rawPacket, ProtocolType parseUntil)
Packet(RawPacket *rawPacket, bool freeRawPacket=false, ProtocolType parseUntil=UnknownProtocol, OsiModelLayer parseUntilLayer=OsiModelLayerUnknown)
void computeCalculateFields()
void toStringList(std::vector< std::string > &result, bool timeAsLocalTime=true) const
bool addLayer(Layer *newLayer, bool ownInPacket=false)
Definition: Packet.h:214
bool detachLayer(Layer *layer)
Definition: Packet.h:301
Packet(RawPacket *rawPacket, ProtocolTypeFamily parseUntilFamily)
Layer * getFirstLayer() const
Definition: Packet.h:190
Definition: RawPacket.h:269
The main namespace for the PcapPlusPlus lib.
uint8_t ProtocolType
Definition: ProtocolType.h:17
OsiModelLayer
Definition: ProtocolType.h:354
@ OsiModelLayerUnknown
Definition: ProtocolType.h:370
uint32_t ProtocolTypeFamily
Definition: ProtocolType.h:23
LinkLayerType
Definition: RawPacket.h:25
const ProtocolType UnknownProtocol
Definition: ProtocolType.h:28