PcapPlusPlus  19.12
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_RawData;
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 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() const;
296 
301  const uint8_t* getRawDataReadOnly() const;
302 
308 
313  int getRawDataLen() const;
314 
319  int getFrameLength() const;
324  timeval getPacketTimeStamp() const;
325 
332  bool isPacketSet() const { 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
pcpp::RawPacket::removeData
virtual bool removeData(int atIndex, size_t numOfBytesToRemove)
pcpp::LINKTYPE_DOCSIS
Definition: RawPacket.h:89
pcpp::LINKTYPE_IEEE802_11
Definition: RawPacket.h:57
pcpp::LINKTYPE_FC_2
Definition: RawPacket.h:137
pcpp::LINKTYPE_FRELAY
Definition: RawPacket.h:59
pcpp::LINKTYPE_BLUETOOTH_HCI_H4
Definition: RawPacket.h:107
pcpp::RawPacket::RawPacket
RawPacket()
pcpp::RawPacket::appendData
virtual void appendData(const uint8_t *dataToAppend, size_t dataToAppendLen)
pcpp::LINKTYPE_AX25_KISS
Definition: RawPacket.h:121
pcpp::LINKTYPE_BLUETOOTH_LE_LL_WITH_PHDR
Definition: RawPacket.h:189
pcpp::LINKTYPE_SCTP
Definition: RawPacket.h:175
pcpp::LINKTYPE_PROFIBUS_DL
Definition: RawPacket.h:191
pcpp::LINKTYPE_MTP2
Definition: RawPacket.h:83
pcpp::LINKTYPE_ETHERNET
Definition: RawPacket.h:29
pcpp::LINKTYPE_C_HDLC_WITH_DIR
Definition: RawPacket.h:127
pcpp::LINKTYPE_MTP2_WITH_PHDR
Definition: RawPacket.h:81
pcpp::RawPacket::setRawData
virtual bool setRawData(const uint8_t *pRawData, int rawDataLen, timeval timestamp, LinkLayerType layerType=LINKTYPE_ETHERNET, int frameLength=-1)
pcpp::LINKTYPE_LTALK
Definition: RawPacket.h:65
pcpp::LINKTYPE_NFC_LLCP
Definition: RawPacket.h:171
pcpp::LINKTYPE_NG40
Definition: RawPacket.h:169
pcpp::LINKTYPE_SLIP
Definition: RawPacket.h:37
pcpp::LINKTYPE_WATTSTOPPER_DLM
Definition: RawPacket.h:203
pcpp::LINKTYPE_DLT_RAW2
Definition: RawPacket.h:45
pcpp::LINKTYPE_LINUX_IRDA
Definition: RawPacket.h:91
pcpp::LINKTYPE_PPP_WITH_DIR
Definition: RawPacket.h:125
pcpp::LINKTYPE_IP_OVER_FC
Definition: RawPacket.h:71
pcpp::LINKTYPE_SITA
Definition: RawPacket.h:115
pcpp::RawPacket::getRawDataLen
int getRawDataLen() const
pcpp::RawPacket::getObjectType
virtual uint8_t getObjectType() const
Definition: RawPacket.h:277
pcpp::LINKTYPE_IEEE802_11_RADIOTAP
Definition: RawPacket.h:75
pcpp::RawPacket::reallocateData
virtual bool reallocateData(size_t newBufferLength)
pcpp::LINKTYPE_RAW
Definition: RawPacket.h:53
pcpp::RawPacket::getFrameLength
int getFrameLength() const
pcpp::LINKTYPE_NETANALYZER_TRANSPARENT
Definition: RawPacket.h:163
pcpp::LINKTYPE_IPV4
Definition: RawPacket.h:145
pcpp::LINKTYPE_USB_LINUX_MMAPPED
Definition: RawPacket.h:135
pcpp::LINKTYPE_MUX27010
Definition: RawPacket.h:155
pcpp::LINKTYPE_IPMI_HPM_2
Definition: RawPacket.h:197
pcpp::LINKTYPE_IPNET
Definition: RawPacket.h:141
pcpp::RawPacket::getPacketTimeStamp
timeval getPacketTimeStamp() const
pcpp::LINKTYPE_ERF
Definition: RawPacket.h:117
pcpp::LINKTYPE_C_HDLC
Definition: RawPacket.h:55
pcpp::RawPacket::getRawData
const uint8_t * getRawData() const
pcpp::LINKTYPE_PPP_HDLC
Definition: RawPacket.h:47
pcpp::LINKTYPE_FRELAY_WITH_DIR
Definition: RawPacket.h:129
pcpp::LINKTYPE_LINUX_SLL
Definition: RawPacket.h:63
pcpp::LINKTYPE_IEEE802_15_4
Definition: RawPacket.h:113
pcpp::LINKTYPE_IEEE802_11_PRISM
Definition: RawPacket.h:69
pcpp::RawPacket::getRawDataReadOnly
const uint8_t * getRawDataReadOnly() const
pcpp::LINKTYPE_PKTAP
Definition: RawPacket.h:193
pcpp::LINKTYPE_SCCP
Definition: RawPacket.h:87
pcpp::LINKTYPE_RTAC_SERIAL
Definition: RawPacket.h:179
pcpp::LINKTYPE_NETANALYZER
Definition: RawPacket.h:161
pcpp::RawPacket::~RawPacket
virtual ~RawPacket()
pcpp::RawPacket::operator=
RawPacket & operator=(const RawPacket &other)
pcpp::LINKTYPE_DVB_CI
Definition: RawPacket.h:153
pcpp::LINKTYPE_PPP
Definition: RawPacket.h:39
pcpp::LINKTYPE_PPP_PPPD
Definition: RawPacket.h:97
pcpp::LINKTYPE_GPF_F
Definition: RawPacket.h:103
pcpp::LINKTYPE_NULL
Definition: RawPacket.h:27
pcpp::RawPacket::insertData
virtual void insertData(int atIndex, const uint8_t *dataToInsert, size_t dataToInsertLen)
pcpp::LINKTYPE_LINUX_LAPD
Definition: RawPacket.h:105
pcpp::LINKTYPE_BLUETOOTH_LINUX_MONITOR
Definition: RawPacket.h:185
pcpp::LINKTYPE_NETLINK
Definition: RawPacket.h:183
pcpp::LINKTYPE_GPF_T
Definition: RawPacket.h:101
pcpp::LINKTYPE_USBPCAP
Definition: RawPacket.h:177
pcpp::LINKTYPE_FDDI
Definition: RawPacket.h:41
pcpp::LINKTYPE_ATM_RFC1483
Definition: RawPacket.h:51
pcpp::RawPacket::getLinkLayerType
LinkLayerType getLinkLayerType() const
pcpp::LINKTYPE_IEEE802_15_4_NONASK_PHY
Definition: RawPacket.h:133
pcpp::LINKTYPE_BLUETOOTH_LE_LL
Definition: RawPacket.h:181
pcpp::LINKTYPE_PPP_ETHER
Definition: RawPacket.h:49
pcpp::RawPacket::isPacketSet
bool isPacketSet() const
Definition: RawPacket.h:332
pcpp
The main namespace for the PcapPlusPlus lib.
pcpp::LINKTYPE_BLUETOOTH_HCI_H4_WITH_PHDR
Definition: RawPacket.h:119
pcpp::LINKTYPE_CAN_SOCKETCAN
Definition: RawPacket.h:143
pcpp::LINKTYPE_EPON
Definition: RawPacket.h:195
pcpp::LINKTYPE_DLT_RAW1
Definition: RawPacket.h:43
pcpp::LINKTYPE_APPLE_IP_OVER_IEEE1394
Definition: RawPacket.h:79
pcpp::LinkLayerType
LinkLayerType
Definition: RawPacket.h:24
pcpp::LINKTYPE_AX25
Definition: RawPacket.h:31
pcpp::LINKTYPE_MPEG_2_TS
Definition: RawPacket.h:167
pcpp::LINKTYPE_MTP3
Definition: RawPacket.h:85
pcpp::LINKTYPE_IEEE802_15_4_NOFCS
Definition: RawPacket.h:149
pcpp::LINKTYPE_ZWAVE_R1_R2
Definition: RawPacket.h:199
pcpp::LINKTYPE_BLUETOOTH_BREDR_BB
Definition: RawPacket.h:187
pcpp::LINKTYPE_SUNATM
Definition: RawPacket.h:73
pcpp::LINKTYPE_INFINIBAND
Definition: RawPacket.h:173
pcpp::LINKTYPE_ZWAVE_R3
Definition: RawPacket.h:201
pcpp::LINKTYPE_IPMB_LINUX
Definition: RawPacket.h:131
pcpp::LINKTYPE_FC_2_WITH_FRAME_DELIMS
Definition: RawPacket.h:139
pcpp::LINKTYPE_IEEE802_11_AVS
Definition: RawPacket.h:93
pcpp::LINKTYPE_IPV6
Definition: RawPacket.h:147
pcpp::LINKTYPE_LOOP
Definition: RawPacket.h:61
pcpp::LINKTYPE_STANAG_5066_D_PDU
Definition: RawPacket.h:157
pcpp::LINKTYPE_ISO_14443
Definition: RawPacket.h:205
pcpp::LINKTYPE_BACNET_MS_TP
Definition: RawPacket.h:95
pcpp::RawPacket::clear
virtual void clear()
pcpp::LINKTYPE_ARCNET_BSD
Definition: RawPacket.h:35
pcpp::LINKTYPE_LAPD
Definition: RawPacket.h:123
pcpp::LINKTYPE_NFLOG
Definition: RawPacket.h:159
pcpp::LINKTYPE_USB_LINUX
Definition: RawPacket.h:109
pcpp::LINKTYPE_IPOIB
Definition: RawPacket.h:165
pcpp::LINKTYPE_IEEE802_5
Definition: RawPacket.h:33
pcpp::LINKTYPE_PFLOG
Definition: RawPacket.h:67
pcpp::LINKTYPE_PPI
Definition: RawPacket.h:111
pcpp::LINKTYPE_ARCNET_LINUX
Definition: RawPacket.h:77
pcpp::RawPacket
Definition: RawPacket.h:219
pcpp::LINKTYPE_DBUS
Definition: RawPacket.h:151
pcpp::LINKTYPE_GPRS_LLC
Definition: RawPacket.h:99