1 #ifndef PACKETPP_PACKET 2 #define PACKETPP_PACKET 33 uint64_t m_ProtocolTypes;
34 size_t m_MaxPacketLen;
36 bool m_CanReallocateData;
45 Packet(
size_t maxPacketLen = 1);
56 Packet(uint8_t* buffer,
size_t bufferSize);
263 template<
class TLayer>
274 template<
class TLayer>
285 template<
class TLayer>
307 std::string
toString(
bool timeAsLocalTime =
true)
const;
314 void toStringList(std::vector<std::string>& result,
bool timeAsLocalTime =
true)
const;
317 void copyDataFrom(
const Packet& other);
319 void destructPacketData();
321 bool extendLayer(
Layer* layer,
int offsetInLayer,
size_t numOfBytesToExtend);
322 bool shortenLayer(
Layer* layer,
int offsetInLayer,
size_t numOfBytesToShorten);
324 void reallocateRawData(
size_t newSize);
328 std::string printPacketInfo(
bool timeAsLocalTime)
const;
336 template<
class TLayer>
354 template<
class TLayer>
357 if (curLayer == NULL)
361 while ((curLayer != NULL) && (dynamic_cast<TLayer*>(curLayer) == NULL))
366 return dynamic_cast<TLayer*
>(curLayer);
369 template<
class TLayer>
372 if (curLayer == NULL)
376 while (curLayer != NULL && dynamic_cast<TLayer*>(curLayer) == NULL)
381 return dynamic_cast<TLayer*
>(curLayer);
386 inline std::ostream& operator<<(std::ostream& os,
const pcpp::Packet& packet)
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:298
void toStringList(std::vector< std::string > &result, bool timeAsLocalTime=true) const
TLayer * getNextLayerOfType(Layer *startLayer) const
Definition: Packet.h:355
Layer * getNextLayer() const
Definition: Layer.h:82
Definition: RawPacket.h:252
Packet(const Packet &other)
Definition: Packet.h:108
Layer * getFirstLayer() const
Definition: Packet.h:146
std::string toString(bool timeAsLocalTime=true) const
bool insertLayer(Layer *prevLayer, Layer *newLayer, bool ownInPacket=false)
RawPacket * getRawPacket() const
Definition: Packet.h:123
bool removeAllLayersAfter(Layer *layer)
const ProtocolType UnknownProtocol
Definition: ProtocolType.h:23
Definition: ProtocolType.h:315
virtual ~Packet()
Definition: Packet.h:101
uint64_t ProtocolType
Definition: ProtocolType.h:18
Layer * getLastLayer() const
Definition: Packet.h:152
bool addLayer(Layer *newLayer, bool ownInPacket=false)
Definition: Packet.h:163
Packet(size_t maxPacketLen=1)
Layer * getLayerOfType(ProtocolType layerType, int index=0) const
void computeCalculateFields()
void setRawPacket(RawPacket *rawPacket, bool freeRawPacket, ProtocolType parseUntil=UnknownProtocol, OsiModelLayer parseUntilLayer=OsiModelLayerUnknown)
LinkLayerType
Definition: RawPacket.h:25
bool isPacketOfType(ProtocolType protocolType) const
Definition: Packet.h:293
Layer * detachLayer(ProtocolType layerType, int index=0)
RawPacket * getRawPacketReadOnly() const
Definition: Packet.h:140
Packet & operator=(const Packet &other)
bool detachLayer(Layer *layer)
Definition: Packet.h:246
Layer * getPrevLayer() const
Definition: Layer.h:87
TLayer * getPrevLayerOfType(Layer *startLayer) const
Definition: Packet.h:370
bool removeLayer(ProtocolType layerType, int index=0)