Coverage Report

Created: 2023-01-17 06:15

/src/PcapPlusPlus/Packet++/header/RawPacket.h
Line
Count
Source (jump to first uncovered line)
1
#ifndef PCAPPP_RAW_PACKET
2
#define PCAPPP_RAW_PACKET
3
4
#include <stdint.h>
5
#ifdef _MSC_VER
6
#include <WinSock2.h>
7
#include <time.h>
8
#else
9
#include <sys/time.h>
10
#endif
11
#include <stddef.h>
12
13
/// @file
14
15
/**
16
 * \namespace pcpp
17
 * \brief The main namespace for the PcapPlusPlus lib
18
 */
19
namespace pcpp
20
{
21
22
  /**
23
   * An enum describing all known link layer type. Taken from: http://www.tcpdump.org/linktypes.html .
24
   */
25
  enum LinkLayerType
26
  {
27
    /** BSD loopback encapsulation */
28
    LINKTYPE_NULL = 0,
29
    /** IEEE 802.3 Ethernet */
30
    LINKTYPE_ETHERNET = 1,
31
    /** AX.25 packet */
32
    LINKTYPE_AX25 = 3,
33
    /** IEEE 802.5 Token Ring */
34
    LINKTYPE_IEEE802_5 = 6,
35
    /** ARCNET Data Packets */
36
    LINKTYPE_ARCNET_BSD = 7,
37
    /** SLIP, encapsulated with a LINKTYPE_SLIP header */
38
    LINKTYPE_SLIP = 8,
39
    /** PPP, as per RFC 1661 and RFC 1662 */
40
    LINKTYPE_PPP = 9,
41
    /** FDDI, as specified by ANSI INCITS 239-1994 */
42
    LINKTYPE_FDDI = 10,
43
    /** Raw IP */
44
    LINKTYPE_DLT_RAW1 = 12,
45
    /** Raw IP (OpenBSD) */
46
    LINKTYPE_DLT_RAW2 = 14,
47
    /** PPP in HDLC-like framing, as per RFC 1662, or Cisco PPP with HDLC framing, as per section 4.3.1 of RFC 1547 */
48
    LINKTYPE_PPP_HDLC = 50,
49
    /** PPPoE */
50
    LINKTYPE_PPP_ETHER = 51,
51
    /** RFC 1483 LLC/SNAP-encapsulated ATM */
52
    LINKTYPE_ATM_RFC1483 = 100,
53
    /** Raw IP */
54
    LINKTYPE_RAW = 101,
55
    /** Cisco PPP with HDLC framing */
56
    LINKTYPE_C_HDLC = 104,
57
    /** IEEE 802.11 wireless LAN */
58
    LINKTYPE_IEEE802_11 = 105,
59
    /** Frame Relay */
60
    LINKTYPE_FRELAY = 107,
61
    /** OpenBSD loopback encapsulation */
62
    LINKTYPE_LOOP = 108,
63
    /** Linux "cooked" capture encapsulation */
64
    LINKTYPE_LINUX_SLL = 113,
65
    /** Apple LocalTalk */
66
    LINKTYPE_LTALK = 114,
67
    /** OpenBSD pflog */
68
    LINKTYPE_PFLOG = 117,
69
    /** Prism monitor mode information followed by an 802.11 header */
70
    LINKTYPE_IEEE802_11_PRISM = 119,
71
    /** RFC 2625 IP-over-Fibre Channel */
72
    LINKTYPE_IP_OVER_FC = 122,
73
    /** ATM traffic, encapsulated as per the scheme used by SunATM devices */
74
    LINKTYPE_SUNATM = 123,
75
    /** Radiotap link-layer information followed by an 802.11 header */
76
    LINKTYPE_IEEE802_11_RADIOTAP = 127,
77
    /** ARCNET Data Packets, as described by the ARCNET Trade Association standard ATA 878.1-1999 */
78
    LINKTYPE_ARCNET_LINUX = 129,
79
    /** Apple IP-over-IEEE 1394 cooked header */
80
    LINKTYPE_APPLE_IP_OVER_IEEE1394 = 138,
81
    /** Signaling System 7 Message Transfer Part Level 2 */
82
    LINKTYPE_MTP2_WITH_PHDR = 139,
83
    /** Signaling System 7 Message Transfer Part Level 2 */
84
    LINKTYPE_MTP2 = 140,
85
    /** Signaling System 7 Message Transfer Part Level 3 */
86
    LINKTYPE_MTP3 = 141,
87
    /** Signaling System 7 Signalling Connection Control Part */
88
    LINKTYPE_SCCP = 142,
89
    /** Signaling System 7 Signalling Connection Control Part */
90
    LINKTYPE_DOCSIS = 143,
91
    /** Linux-IrDA packets */
92
    LINKTYPE_LINUX_IRDA = 144,
93
    /** Reserved for private use */
94
    LINKTYPE_USER0 = 147,
95
    /** Reserved for private use */
96
    LINKTYPE_USER1 = 148,
97
    /** Reserved for private use */
98
    LINKTYPE_USER2 = 149,
99
    /** Reserved for private use */
100
    LINKTYPE_USER3 = 150,
101
    /** Reserved for private use */
102
    LINKTYPE_USER4 = 151,
103
    /** Reserved for private use */
104
    LINKTYPE_USER5 = 152,
105
    /** Reserved for private use */
106
    LINKTYPE_USER6 = 153,
107
    /** Reserved for private use */
108
    LINKTYPE_USER7 = 154,
109
    /** Reserved for private use */
110
    LINKTYPE_USER8 = 155,
111
    /** Reserved for private use */
112
    LINKTYPE_USER9 = 156,
113
    /** Reserved for private use */
114
    LINKTYPE_USER10 = 157,
115
    /** Reserved for private use */
116
    LINKTYPE_USER11 = 158,
117
    /** Reserved for private use */
118
    LINKTYPE_USER12 = 159,
119
    /** Reserved for private use */
120
    LINKTYPE_USER13 = 160,
121
    /** Reserved for private use */
122
    LINKTYPE_USER14 = 161,
123
    /** Reserved for private use */
124
    LINKTYPE_USER15 = 162,
125
    /** AVS monitor mode information followed by an 802.11 header */
126
    LINKTYPE_IEEE802_11_AVS = 163,
127
    /** BACnet MS/TP frames */
128
    LINKTYPE_BACNET_MS_TP = 165,
129
    /** PPP in HDLC-like encapsulation, like LINKTYPE_PPP_HDLC, but with the 0xff address byte replaced by a direction indication - 0x00 for incoming and 0x01 for outgoing */
130
    LINKTYPE_PPP_PPPD = 166,
131
    /** General Packet Radio Service Logical Link Control */
132
    LINKTYPE_GPRS_LLC = 169,
133
    /** Transparent-mapped generic framing procedure */
134
    LINKTYPE_GPF_T = 170,
135
    /** Frame-mapped generic framing procedure */
136
    LINKTYPE_GPF_F = 171,
137
    /** Link Access Procedures on the D Channel (LAPD) frames */
138
    LINKTYPE_LINUX_LAPD = 177,
139
    /** Bluetooth HCI UART transport layer */
140
    LINKTYPE_BLUETOOTH_HCI_H4 = 187,
141
    /** USB packets, beginning with a Linux USB header */
142
    LINKTYPE_USB_LINUX = 189,
143
    /** Per-Packet Information information */
144
    LINKTYPE_PPI = 192,
145
    /** IEEE 802.15.4 wireless Personal Area Network */
146
    LINKTYPE_IEEE802_15_4 = 195,
147
    /** Various link-layer types, with a pseudo-header, for SITA */
148
    LINKTYPE_SITA = 196,
149
    /** Various link-layer types, with a pseudo-header, for Endace DAG cards; encapsulates Endace ERF record */
150
    LINKTYPE_ERF = 197,
151
    /** Bluetooth HCI UART transport layer */
152
    LINKTYPE_BLUETOOTH_HCI_H4_WITH_PHDR = 201,
153
    /** AX.25 packet, with a 1-byte KISS header containing a type indicator */
154
    LINKTYPE_AX25_KISS = 202,
155
    /** Link Access Procedures on the D Channel (LAPD) frames */
156
    LINKTYPE_LAPD = 203,
157
    /** PPP, as per RFC 1661 and RFC 1662, preceded with a one-byte pseudo-header with a zero value meaning "received by this host" and a non-zero value meaning  "sent by this host" */
158
    LINKTYPE_PPP_WITH_DIR = 204,
159
    /** Cisco PPP with HDLC framing */
160
    LINKTYPE_C_HDLC_WITH_DIR = 205,
161
    /** Frame Relay */
162
    LINKTYPE_FRELAY_WITH_DIR = 206,
163
    /** IPMB over an I2C circuit */
164
    LINKTYPE_IPMB_LINUX = 209,
165
    /** IEEE 802.15.4 wireless Personal Area Network */
166
    LINKTYPE_IEEE802_15_4_NONASK_PHY = 215,
167
    /** USB packets, beginning with a Linux USB header */
168
    LINKTYPE_USB_LINUX_MMAPPED = 220,
169
    /** Fibre Channel FC-2 frames, beginning with a Frame_Header */
170
    LINKTYPE_FC_2 = 224,
171
    /** Fibre Channel FC-2 frames */
172
    LINKTYPE_FC_2_WITH_FRAME_DELIMS = 225,
173
    /** Solaris ipnet pseudo-header */
174
    LINKTYPE_IPNET = 226,
175
    /** CAN (Controller Area Network) frames, with a pseudo-header as supplied by Linux SocketCAN */
176
    LINKTYPE_CAN_SOCKETCAN = 227,
177
    /** Raw IPv4; the packet begins with an IPv4 header */
178
    LINKTYPE_IPV4 = 228,
179
    /** Raw IPv6; the packet begins with an IPv6 header */
180
    LINKTYPE_IPV6 = 229,
181
    /** IEEE 802.15.4 wireless Personal Area Network, without the FCS at the end of the frame */
182
    LINKTYPE_IEEE802_15_4_NOFCS = 230,
183
    /** Raw D-Bus messages, starting with the endianness flag, followed by the message type, etc., but without the authentication handshake before the message sequence */
184
    LINKTYPE_DBUS = 231,
185
    /** DVB-CI (DVB Common Interface for communication between a PC Card module and a DVB receiver), with the message format specified by the PCAP format for DVB-CI specification */
186
    LINKTYPE_DVB_CI = 235,
187
    /** Variant of 3GPP TS 27.010 multiplexing protocol (similar to, but not the same as, 27.010) */
188
    LINKTYPE_MUX27010 = 236,
189
    /** D_PDUs as described by NATO standard STANAG 5066, starting with the synchronization sequence, and including both header and data CRCs */
190
    LINKTYPE_STANAG_5066_D_PDU = 237,
191
    /** Linux netlink NETLINK NFLOG socket log messages */
192
    LINKTYPE_NFLOG = 239,
193
    /** Pseudo-header for Hilscher Gesellschaft für Systemautomation mbH netANALYZER devices, followed by an Ethernet frame, beginning with the MAC header and ending with the FCS */
194
    LINKTYPE_NETANALYZER = 240,
195
    /** Pseudo-header for Hilscher Gesellschaft für Systemautomation mbH netANALYZER devices, followed by an Ethernet frame, beginning with the preamble, SFD, and MAC header, and ending with the FCS */
196
    LINKTYPE_NETANALYZER_TRANSPARENT = 241,
197
    /** IP-over-InfiniBand, as specified by RFC 4391 section 6 */
198
    LINKTYPE_IPOIB = 242,
199
    /** MPEG-2 Transport Stream transport packets, as specified by ISO 13818-1/ITU-T Recommendation H.222.0 */
200
    LINKTYPE_MPEG_2_TS = 243,
201
    /** Pseudo-header for ng4T GmbH's UMTS Iub/Iur-over-ATM and Iub/Iur-over-IP format as used by their ng40 protocol tester */
202
    LINKTYPE_NG40 = 244,
203
    /** Pseudo-header for NFC LLCP packet captures, followed by frame data for the LLCP Protocol as specified by NFCForum-TS-LLCP_1.1 */
204
    LINKTYPE_NFC_LLCP = 245,
205
    /** Raw InfiniBand frames, starting with the Local Routing Header */
206
    LINKTYPE_INFINIBAND = 247,
207
    /** SCTP packets, as defined by RFC 4960, with no lower-level protocols such as IPv4 or IPv6 */
208
    LINKTYPE_SCTP = 248,
209
    /** USB packets, beginning with a USBPcap header */
210
    LINKTYPE_USBPCAP = 249,
211
    /** Serial-line packet header for the Schweitzer Engineering Laboratories "RTAC" product */
212
    LINKTYPE_RTAC_SERIAL = 250,
213
    /** Bluetooth Low Energy air interface Link Layer packets */
214
    LINKTYPE_BLUETOOTH_LE_LL = 251,
215
    /** Linux Netlink capture encapsulation */
216
    LINKTYPE_NETLINK = 253,
217
    /** Bluetooth Linux Monitor encapsulation of traffic for the BlueZ stack */
218
    LINKTYPE_BLUETOOTH_LINUX_MONITOR = 254,
219
    /** Bluetooth Basic Rate and Enhanced Data Rate baseband packets */
220
    LINKTYPE_BLUETOOTH_BREDR_BB = 255,
221
    /** Bluetooth Low Energy link-layer packets */
222
    LINKTYPE_BLUETOOTH_LE_LL_WITH_PHDR = 256,
223
    /** PROFIBUS data link layer packets, as specified by IEC standard 61158-6-3 */
224
    LINKTYPE_PROFIBUS_DL = 257,
225
    /** Apple PKTAP capture encapsulation */
226
    LINKTYPE_PKTAP = 258,
227
    /** Ethernet-over-passive-optical-network packets */
228
    LINKTYPE_EPON = 259,
229
    /** IPMI trace packets, as specified by Table 3-20 "Trace Data Block Format" in the PICMG HPM.2 specification */
230
    LINKTYPE_IPMI_HPM_2 = 260,
231
    /** Per Joshua Wright <jwright@hasborg.com>, formats for Z-Wave RF profiles R1 and R2 captures */
232
    LINKTYPE_ZWAVE_R1_R2 = 261,
233
    /** Per Joshua Wright <jwright@hasborg.com>, formats for Z-Wave RF profile R3 captures */
234
    LINKTYPE_ZWAVE_R3 = 262,
235
    /** Formats for WattStopper Digital Lighting Management (DLM) and Legrand Nitoo Open protocol common packet structure captures */
236
    LINKTYPE_WATTSTOPPER_DLM = 263,
237
    /** Messages between ISO 14443 contactless smartcards (Proximity Integrated Circuit Card, PICC) and card readers (Proximity Coupling Device, PCD), with the message format specified by the PCAP format for ISO14443 specification */
238
    LINKTYPE_ISO_14443 = 264
239
  };
240
241
  /**
242
   * Max packet size supported
243
   */
244
0
#define PCPP_MAX_PACKET_SIZE 65536
245
246
  /**
247
   * @class RawPacket
248
   * This class holds the packet as raw (not parsed) data. The data is held as byte array. In addition to the data itself
249
   * every instance also holds a timestamp representing the time the packet was received by the NIC.
250
   * RawPacket instance isn't read only. The user can change the packet data, add or remove data, etc.
251
   */
252
  class RawPacket
253
  {
254
  protected:
255
    uint8_t* m_RawData;
256
    int m_RawDataLen;
257
    int m_FrameLength;
258
    timespec m_TimeStamp;
259
    bool m_DeleteRawDataAtDestructor;
260
    bool m_RawPacketSet;
261
    LinkLayerType m_LinkLayerType;
262
    void init(bool deleteRawDataAtDestructor = true);
263
    void copyDataFrom(const RawPacket& other, bool allocateData = true);
264
  public:
265
    /**
266
     * A constructor that receives a pointer to the raw data (allocated elsewhere). This constructor is usually used when packet
267
     * is captured using a packet capturing engine (like libPcap. WinPcap, Npcap, PF_RING, etc.). The capturing engine allocates the raw data
268
     * memory and give the user a pointer to it + a timestamp it has arrived to the device
269
     * @param[in] pRawData A pointer to the raw data
270
     * @param[in] rawDataLen The raw data length in bytes
271
     * @param[in] timestamp The timestamp packet was received by the NIC (in usec precision)
272
     * @param[in] deleteRawDataAtDestructor An indicator whether raw data pointer should be freed when the instance is freed or not. If set
273
     * to 'true' than pRawData will be freed when instanced is being freed
274
     * @param[in] layerType The link layer type of this raw packet. The default is Ethernet
275
     */
276
    RawPacket(const uint8_t* pRawData, int rawDataLen, timeval timestamp, bool deleteRawDataAtDestructor, LinkLayerType layerType = LINKTYPE_ETHERNET);
277
278
    /**
279
     * A constructor that receives a pointer to the raw data (allocated elsewhere). This constructor is usually used when packet
280
     * is captured using a packet capturing engine (like libPcap. WinPcap, Npcap, PF_RING, etc.). The capturing engine allocates the raw data
281
     * memory and give the user a pointer to it + a timestamp it has arrived to the device
282
     * @param[in] pRawData A pointer to the raw data
283
     * @param[in] rawDataLen The raw data length in bytes
284
     * @param[in] timestamp The timestamp packet was received by the NIC (in nsec precision)
285
     * @param[in] deleteRawDataAtDestructor An indicator whether raw data pointer should be freed when the instance is freed or not. If set
286
     * to 'true' than pRawData will be freed when instanced is being freed
287
     * @param[in] layerType The link layer type of this raw packet. The default is Ethernet
288
     */
289
    RawPacket(const uint8_t* pRawData, int rawDataLen, timespec timestamp, bool deleteRawDataAtDestructor, LinkLayerType layerType = LINKTYPE_ETHERNET);
290
291
    /**
292
     * A default constructor that initializes class'es attributes to default value:
293
     * - data pointer is set to NULL
294
     * - data length is set to 0
295
     * - deleteRawDataAtDestructor is set to 'true'
296
     * @todo timestamp isn't set here to a default value
297
     */
298
    RawPacket();
299
300
    /**
301
     * A destructor for this class. Frees the raw data if deleteRawDataAtDestructor was set to 'true'
302
     */
303
    virtual ~RawPacket();
304
305
    /**
306
     * A copy constructor that copies all data from another instance. Notice all raw data is copied (using memcpy), so when the original or
307
     * the other instance are freed, the other won't be affected
308
     * @param[in] other The instance to copy from
309
     */
310
    RawPacket(const RawPacket& other);
311
312
    /**
313
     * Assignment operator overload for this class. When using this operator on an already initialized RawPacket instance,
314
     * the original raw data is freed first. Then the other instance is copied to this instance, the same way the copy constructor works
315
     * @todo free raw data only if deleteRawDataAtDestructor was set to 'true'
316
     * @param[in] other The instance to copy from
317
     */
318
    RawPacket& operator=(const RawPacket& other);
319
320
    /**
321
     * @return RawPacket object type. Each derived class should return a different value
322
     */
323
    virtual uint8_t getObjectType() const { return 0; }
324
325
    /**
326
     * Set a raw data. If data was already set and deleteRawDataAtDestructor was set to 'true' the old data will be freed first
327
     * @param[in] pRawData A pointer to the new raw data
328
     * @param[in] rawDataLen The new raw data length in bytes
329
     * @param[in] timestamp The timestamp packet was received by the NIC (in usec precision)
330
     * @param[in] layerType The link layer type for this raw data
331
     * @param[in] frameLength When reading from pcap files, sometimes the captured length is different from the actual packet length. This parameter represents the packet
332
     * length. This parameter is optional, if not set or set to -1 it is assumed both lengths are equal
333
     * @return True if raw data was set successfully, false otherwise
334
     */
335
    virtual bool setRawData(const uint8_t* pRawData, int rawDataLen, timeval timestamp, LinkLayerType layerType = LINKTYPE_ETHERNET, int frameLength = -1);
336
337
    /**
338
     * Set a raw data. If data was already set and deleteRawDataAtDestructor was set to 'true' the old data will be freed first
339
     * @param[in] pRawData A pointer to the new raw data
340
     * @param[in] rawDataLen The new raw data length in bytes
341
     * @param[in] timestamp The timestamp packet was received by the NIC (in nsec precision)
342
     * @param[in] layerType The link layer type for this raw data
343
     * @param[in] frameLength When reading from pcap files, sometimes the captured length is different from the actual packet length. This parameter represents the packet
344
     * length. This parameter is optional, if not set or set to -1 it is assumed both lengths are equal
345
     * @return True if raw data was set successfully, false otherwise
346
     */
347
    virtual bool setRawData(const uint8_t* pRawData, int rawDataLen, timespec timestamp, LinkLayerType layerType = LINKTYPE_ETHERNET, int frameLength = -1);
348
349
    /**
350
     * Get raw data pointer
351
     * @return A read-only pointer to the raw data
352
     */
353
1.23M
    const uint8_t* getRawData() const { return m_RawData; }
354
355
    /**
356
     * Get the link layer type
357
     * @return the type of the link layer
358
     */
359
997k
    LinkLayerType getLinkLayerType() const { return m_LinkLayerType; }
360
361
    /**
362
     * This static method validates whether a link type integer value is valid
363
     * @param[in] linkTypeValue Link type integer value
364
     * @return True if the link type value is valid and can be casted into LinkLayerType enum, false otherwise
365
     */
366
    static bool isLinkTypeValid(int linkTypeValue);
367
368
    /**
369
     * Get raw data length in bytes
370
     * @return Raw data length in bytes
371
     */
372
2.61M
    int getRawDataLen() const { return m_RawDataLen; }
373
374
    /**
375
     * Get frame length in bytes
376
     * @return frame length in bytes
377
     */
378
0
    int getFrameLength() const { return m_FrameLength; }
379
    /**
380
     * Get raw data timestamp
381
     * @return Raw data timestamp
382
     */
383
0
    timespec getPacketTimeStamp() const { return m_TimeStamp; }
384
385
    /**
386
     * Set raw packet timestamp with usec precision
387
     * @param[in] timestamp The timestamp to set (with usec precision)
388
     * @return True if timestamp was set successfully, false otherwise
389
     */
390
    virtual bool setPacketTimeStamp(timeval timestamp);
391
392
    /**
393
     * Set raw packet timestamp with nsec precision
394
     * @param[in] timestamp The timestamp to set (with nsec precision)
395
     * @return True if timestamp was set successfully, false otherwise
396
     */
397
    virtual bool setPacketTimeStamp(timespec timestamp);
398
399
    /**
400
     * Get an indication whether raw data was already set for this instance.
401
     * @return True if raw data was set for this instance. Raw data can be set using the non-default constructor, using setRawData(), using
402
     * the copy constructor or using the assignment operator. Returns false otherwise, for example: if the instance was created using the
403
     * default constructor or clear() was called
404
     */
405
    bool isPacketSet() const { return m_RawPacketSet; }
406
407
    /**
408
     * Clears all members of this instance, meaning setting raw data to NULL, raw data length to 0, etc. Currently raw data is always freed,
409
     * even if deleteRawDataAtDestructor was set to 'false'
410
     * @todo deleteRawDataAtDestructor was set to 'true', don't free the raw data
411
     * @todo set timestamp to a default value as well
412
     */
413
    virtual void clear();
414
415
    /**
416
     * Append data to the end of current data. This method works without allocating more memory, it just uses memcpy() to copy dataToAppend at
417
     * the end of the current data. This means that the method assumes this memory was already allocated by the user. If it isn't the case then
418
     * this method will cause memory corruption
419
     * @param[in] dataToAppend A pointer to the data to append to current raw data
420
     * @param[in] dataToAppendLen Length in bytes of dataToAppend
421
     */
422
    virtual void appendData(const uint8_t* dataToAppend, size_t dataToAppendLen);
423
424
    /**
425
     * Insert new data at some index of the current data and shift the remaining old data to the end. This method works without allocating more memory,
426
     * it just copies dataToAppend at the relevant index and shifts the remaining data to the end. This means that the method assumes this memory was
427
     * already allocated by the user. If it isn't the case then this method will cause memory corruption
428
     * @param[in] atIndex The index to insert the new data to
429
     * @param[in] dataToInsert A pointer to the new data to insert
430
     * @param[in] dataToInsertLen Length in bytes of dataToInsert
431
     */
432
    virtual void insertData(int atIndex, const uint8_t* dataToInsert, size_t dataToInsertLen);
433
434
    /**
435
     * Remove certain number of bytes from current raw data buffer. All data after the removed bytes will be shifted back
436
     * @param[in] atIndex The index to start removing bytes from
437
     * @param[in] numOfBytesToRemove Number of bytes to remove
438
     * @return True if all bytes were removed successfully, or false if atIndex+numOfBytesToRemove is out-of-bounds of the raw data buffer
439
     */
440
    virtual bool removeData(int atIndex, size_t numOfBytesToRemove);
441
442
    /**
443
     * Re-allocate raw packet buffer meaning add size to it without losing the current packet data. This method allocates the required buffer size as instructed
444
     * by the use and then copies the raw data from the current allocated buffer to the new one. This method can become useful if the user wants to insert or
445
     * append data to the raw data, and the previous allocated buffer is too small, so the user wants to allocate a larger buffer and get RawPacket instance to
446
     * point to it
447
     * @param[in] newBufferLength The new buffer length as required by the user. The method is responsible to allocate the memory
448
     * @return True if data was reallocated successfully, false otherwise
449
     */
450
    virtual bool reallocateData(size_t newBufferLength);
451
  };
452
453
} // namespace pcpp
454
455
#endif