PcapPlusPlus
RawPacket.h
Go to the documentation of this file.
1 #ifndef PCAPPP_RAW_PACKET
2 #define PCAPPP_RAW_PACKET
3 
4 #include <stdint.h>
5 #ifdef _MSC_VER
6 #include <WinSock2.h>
7 #else
8 #include <sys/time.h>
9 #endif
10 #include <stddef.h>
11 
13 
18 namespace pcpp
19 {
20 
25  {
53  LINKTYPE_RAW = 101,
206  };
207 
211 #define PCPP_MAX_PACKET_SIZE 65536
212 
219  class RawPacket
220  {
221  protected:
222  uint8_t* m_pRawData;
223  int m_RawDataLen;
224  int m_FrameLength;
225  timeval m_TimeStamp;
226  bool m_DeleteRawDataAtDestructor;
227  bool m_RawPacketSet;
228  LinkLayerType m_linkLayerType;
229  void Init();
230  void copyDataFrom(const RawPacket& other, bool allocateData = true);
231  public:
243  RawPacket(const uint8_t* pRawData, int rawDataLen, timeval timestamp, bool deleteRawDataAtDestructor, LinkLayerType layerType = LINKTYPE_ETHERNET);
244 
252  RawPacket();
253 
257  virtual ~RawPacket();
258 
264  RawPacket(const RawPacket& other);
265 
272  RawPacket& operator=(const RawPacket& other);
273 
277  virtual inline uint8_t getObjectType() const { return 0; }
278 
289  virtual bool setRawData(const uint8_t* pRawData, int rawDataLen, timeval timestamp, LinkLayerType layerType = LINKTYPE_ETHERNET, int frameLength = -1);
290 
295  const uint8_t* getRawData();
296 
301  const uint8_t* getRawDataReadOnly() const;
302 
308 
313  int getRawDataLen() const;
314 
319  int getFrameLength() const;
324  timeval getPacketTimeStamp();
325 
332  inline bool isPacketSet() { return m_RawPacketSet; }
333 
340  virtual void clear();
341 
349  virtual void appendData(const uint8_t* dataToAppend, size_t dataToAppendLen);
350 
359  virtual void insertData(int atIndex, const uint8_t* dataToInsert, size_t dataToInsertLen);
360 
367  virtual bool removeData(int atIndex, size_t numOfBytesToRemove);
368 
377  virtual bool reallocateData(size_t newBufferLength);
378  };
379 
380 } // namespace pcpp
381 
382 #endif
Definition: RawPacket.h:167
Definition: RawPacket.h:93
virtual ~RawPacket()
Definition: RawPacket.h:125
Definition: RawPacket.h:81
Definition: RawPacket.h:47
Definition: RawPacket.h:175
Definition: RawPacket.h:159
Definition: RawPacket.h:89
Definition: RawPacket.h:59
Definition: RawPacket.h:157
Definition: RawPacket.h:183
Definition: RawPacket.h:143
Definition: RawPacket.h:35
Definition: RawPacket.h:171
Definition: RawPacket.h:117
bool isPacketSet()
Definition: RawPacket.h:332
Definition: RawPacket.h:95
Definition: RawPacket.h:65
Definition: RawPacket.h:199
Definition: RawPacket.h:165
Definition: RawPacket.h:39
Definition: RawPacket.h:113
Definition: RawPacket.h:73
Definition: RawPacket.h:45
Definition: RawPacket.h:49
Definition: RawPacket.h:163
Definition: RawPacket.h:67
Definition: RawPacket.h:53
Definition: RawPacket.h:75
Definition: RawPacket.h:137
Definition: RawPacket.h:203
Definition: RawPacket.h:101
int getRawDataLen() const
Definition: RawPacket.h:155
Definition: RawPacket.h:201
Definition: RawPacket.h:63
Definition: RawPacket.h:123
Definition: RawPacket.h:115
Definition: RawPacket.h:87
Definition: RawPacket.h:77
virtual uint8_t getObjectType() const
Definition: RawPacket.h:277
RawPacket & operator=(const RawPacket &other)
Definition: RawPacket.h:79
Definition: RawPacket.h:43
virtual bool removeData(int atIndex, size_t numOfBytesToRemove)
virtual void clear()
Definition: RawPacket.h:145
Definition: RawPacket.h:97
int getFrameLength() const
LinkLayerType getLinkLayerType() const
Definition: RawPacket.h:219
Definition: RawPacket.h:193
Definition: RawPacket.h:127
Definition: RawPacket.h:105
Definition: RawPacket.h:109
Definition: RawPacket.h:179
Definition: RawPacket.h:91
Definition: RawPacket.h:195
Definition: RawPacket.h:149
Definition: RawPacket.h:107
Definition: RawPacket.h:37
Definition: RawPacket.h:51
Definition: RawPacket.h:85
Definition: RawPacket.h:111
virtual void insertData(int atIndex, const uint8_t *dataToInsert, size_t dataToInsertLen)
timeval getPacketTimeStamp()
const uint8_t * getRawData()
Definition: RawPacket.h:205
virtual void appendData(const uint8_t *dataToAppend, size_t dataToAppendLen)
Definition: RawPacket.h:185
Definition: RawPacket.h:147
Definition: RawPacket.h:57
Definition: RawPacket.h:121
Definition: RawPacket.h:151
Definition: RawPacket.h:191
Definition: RawPacket.h:169
Definition: RawPacket.h:29
Definition: RawPacket.h:33
const uint8_t * getRawDataReadOnly() const
Definition: RawPacket.h:129
Definition: RawPacket.h:69
Definition: RawPacket.h:55
Definition: RawPacket.h:41
Definition: RawPacket.h:135
Definition: RawPacket.h:173
Definition: RawPacket.h:139
Definition: RawPacket.h:133
virtual bool setRawData(const uint8_t *pRawData, int rawDataLen, timeval timestamp, LinkLayerType layerType=LINKTYPE_ETHERNET, int frameLength=-1)
Definition: RawPacket.h:131
Definition: RawPacket.h:61
virtual bool reallocateData(size_t newBufferLength)
Definition: RawPacket.h:141
Definition: RawPacket.h:189
Definition: RawPacket.h:181
Definition: RawPacket.h:187
Definition: RawPacket.h:197
Definition: RawPacket.h:83
Definition: RawPacket.h:103
Definition: RawPacket.h:177
Definition: RawPacket.h:71
The main namespace for the PcapPlusPlus lib.
Definition: RawPacket.h:31
LinkLayerType
Definition: RawPacket.h:24
Definition: RawPacket.h:153
Definition: RawPacket.h:27
Definition: RawPacket.h:99
Definition: RawPacket.h:161