@@ -275,79 +275,6 @@ namespace pcpp
275
275
bool openAppend ();
276
276
};
277
277
278
- // / @class SnoopFileReaderDevice
279
- // / A class for opening a snoop file in read-only mode. This class enable to open the file and read all packets,
280
- // / packet-by-packet
281
- class SnoopFileReaderDevice : public IFileReaderDevice
282
- {
283
- private:
284
- #pragma pack(1)
285
- // / File format header.
286
- typedef struct
287
- {
288
- uint64_t identification_pattern;
289
- uint32_t version_number;
290
- uint32_t datalink_type;
291
- } snoop_file_header_t ;
292
-
293
- // / Packet record header.
294
- typedef struct
295
- {
296
- uint32_t original_length; // /< original packet length
297
- uint32_t included_length; // /< saved packet length
298
- uint32_t packet_record_length; // /< total record length
299
- uint32_t ndrops_cumulative; // /< cumulative drops
300
- uint32_t time_sec; // /< timestamp
301
- uint32_t time_usec; // /< microsecond timestamp
302
- } snoop_packet_header_t ;
303
- #pragma pack()
304
-
305
- LinkLayerType m_PcapLinkLayerType;
306
- std::ifstream m_snoopFile;
307
-
308
- // private copy c'tor
309
- SnoopFileReaderDevice (const PcapFileReaderDevice& other);
310
- SnoopFileReaderDevice& operator =(const PcapFileReaderDevice& other);
311
-
312
- public:
313
- // / A constructor for this class that gets the snoop full path file name to open. Notice that after calling this
314
- // / constructor the file isn't opened yet, so reading packets will fail. For opening the file call open()
315
- // / @param[in] fileName The full path of the file to read
316
- SnoopFileReaderDevice (const std::string& fileName)
317
- : IFileReaderDevice(fileName), m_PcapLinkLayerType(LINKTYPE_ETHERNET)
318
- {}
319
-
320
- // / A destructor for this class
321
- virtual ~SnoopFileReaderDevice ();
322
-
323
- // / @return The link layer type of this file
324
- LinkLayerType getLinkLayerType () const
325
- {
326
- return m_PcapLinkLayerType;
327
- }
328
-
329
- // overridden methods
330
-
331
- // / Read the next packet from the file. Before using this method please verify the file is opened using open()
332
- // / @param[out] rawPacket A reference for an empty RawPacket where the packet will be written
333
- // / @return True if a packet was read successfully. False will be returned if the file isn't opened (also, an
334
- // / error log will be printed) or if reached end-of-file
335
- bool getNextPacket (RawPacket& rawPacket);
336
-
337
- // / Open the file name which path was specified in the constructor in a read-only mode
338
- // / @return True if file was opened successfully or if file is already opened. False if opening the file failed
339
- // / for some reason (for example: file path does not exist)
340
- bool open ();
341
-
342
- // / Get statistics of packets read so far. In the PcapStats struct, only the packetsRecv member is relevant. The
343
- // / rest of the members will contain 0
344
- // / @param[out] stats The stats struct where stats are returned
345
- void getStatistics (PcapStats& stats) const ;
346
-
347
- // / Close the snoop file
348
- void close ();
349
- };
350
-
351
278
// / @class PcapNgFileReaderDevice
352
279
// / A class for opening a pcap-ng file in read-only mode. This class enable to open the file and read all packets,
353
280
// / packet-by-packet
@@ -559,4 +486,76 @@ namespace pcpp
559
486
bool openAppend ();
560
487
};
561
488
489
+ // / @class SnoopFileReaderDevice
490
+ // / A class for opening a snoop file in read-only mode. This class enable to open the file and read all packets,
491
+ // / packet-by-packet
492
+ class SnoopFileReaderDevice : public IFileReaderDevice
493
+ {
494
+ private:
495
+ #pragma pack(1)
496
+ // / File format header.
497
+ typedef struct
498
+ {
499
+ uint64_t identification_pattern;
500
+ uint32_t version_number;
501
+ uint32_t datalink_type;
502
+ } snoop_file_header_t ;
503
+
504
+ // / Packet record header.
505
+ typedef struct
506
+ {
507
+ uint32_t original_length; // /< original packet length
508
+ uint32_t included_length; // /< saved packet length
509
+ uint32_t packet_record_length; // /< total record length
510
+ uint32_t ndrops_cumulative; // /< cumulative drops
511
+ uint32_t time_sec; // /< timestamp
512
+ uint32_t time_usec; // /< microsecond timestamp
513
+ } snoop_packet_header_t ;
514
+ #pragma pack()
515
+
516
+ LinkLayerType m_PcapLinkLayerType;
517
+ std::ifstream m_snoopFile;
518
+
519
+ // private copy c'tor
520
+ SnoopFileReaderDevice (const PcapFileReaderDevice& other);
521
+ SnoopFileReaderDevice& operator =(const PcapFileReaderDevice& other);
522
+
523
+ public:
524
+ // / A constructor for this class that gets the snoop full path file name to open. Notice that after calling this
525
+ // / constructor the file isn't opened yet, so reading packets will fail. For opening the file call open()
526
+ // / @param[in] fileName The full path of the file to read
527
+ SnoopFileReaderDevice (const std::string& fileName)
528
+ : IFileReaderDevice(fileName), m_PcapLinkLayerType(LINKTYPE_ETHERNET)
529
+ {}
530
+
531
+ // / A destructor for this class
532
+ virtual ~SnoopFileReaderDevice ();
533
+
534
+ // / @return The link layer type of this file
535
+ LinkLayerType getLinkLayerType () const
536
+ {
537
+ return m_PcapLinkLayerType;
538
+ }
539
+
540
+ // overridden methods
541
+
542
+ // / Read the next packet from the file. Before using this method please verify the file is opened using open()
543
+ // / @param[out] rawPacket A reference for an empty RawPacket where the packet will be written
544
+ // / @return True if a packet was read successfully. False will be returned if the file isn't opened (also, an
545
+ // / error log will be printed) or if reached end-of-file
546
+ bool getNextPacket (RawPacket& rawPacket);
547
+
548
+ // / Open the file name which path was specified in the constructor in a read-only mode
549
+ // / @return True if file was opened successfully or if file is already opened. False if opening the file failed
550
+ // / for some reason (for example: file path does not exist)
551
+ bool open ();
552
+
553
+ // / Get statistics of packets read so far. In the PcapStats struct, only the packetsRecv member is relevant. The
554
+ // / rest of the members will contain 0
555
+ // / @param[out] stats The stats struct where stats are returned
556
+ void getStatistics (PcapStats& stats) const ;
557
+
558
+ // / Close the snoop file
559
+ void close ();
560
+ };
562
561
} // namespace pcpp
0 commit comments