-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaptureFuncs.h
More file actions
40 lines (36 loc) · 985 Bytes
/
captureFuncs.h
File metadata and controls
40 lines (36 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2021, Pejman Taslimi
// You may distribute under the terms of either the GNU General Public
// License or the Artistic License, as specified in the MYLICENSE file.
/*
* FILENAME :
* DESCRIPTION :
*
* Author : Mani Tasl
* Date : Jun 2021.
*
*/
#ifndef CAPTURE_FUNCS
#define CAPTURE_FUNCS
#include<iostream>
#include<pcap.h>
#include<chrono>
#include<vector>
#include<functional> //For std::function
using StatusUpdateHandler = std::function<void(int iPacketCount)>;
class PcapLib{
pcap_if_t* mIfDevs;
char* mcpDev;
std::string mwFilename;
pcap_t* mDescr;
pcap_dumper_t* mDumper;
time_t mtEndTime;
public:
PcapLib();
~PcapLib();
int miDurationSec;
std::vector<std::string> mvwIfNames;
std::vector<std::string>& getIfNames(void);
int captureInit(const std::string wDevName, const std::string wFilename);
int captureFor(int iDurationSec, StatusUpdateHandler);
};
#endif // CAPTURE_FUNCS