2 #ifndef PCAPPP_LIVE_DEVICE 3 #define PCAPPP_LIVE_DEVICE 13 typedef pcap_if pcap_if_t;
15 typedef struct pcap_addr pcap_addr_t;
57 typedef void* (*ThreadStart)(
void*);
88 pcap_t* m_PcapSendDescriptor;
90 std::string m_Description;
93 std::vector<pcap_addr_t> m_Addresses;
96 PcapThread* m_CaptureThread;
97 bool m_CaptureThreadStarted;
98 PcapThread* m_StatsThread;
99 bool m_StatsThreadStarted;
102 void* m_cbOnPacketArrivesUserCookie;
104 void* m_cbOnStatsUpdateUserCookie;
106 void* m_cbOnPacketArrivesBlockingModeUserCookie;
107 int m_IntervalToUpdateStats;
109 bool m_CaptureCallbackMode;
113 PcapLiveDevice(pcap_if_t* pInterface,
bool calculateMTU,
bool calculateMacAddress,
bool calculateDefaultGateway);
119 void setDeviceMacAddress();
120 void setDefaultGateway();
121 static void* captureThreadMain(
void* ptr);
122 static void* statsThreadMain(
void* ptr);
123 static void onPacketArrives(uint8_t* user,
const struct pcap_pkthdr* pkthdr,
const uint8_t* packet);
124 static void onPacketArrivesNoCallback(uint8_t* user,
const struct pcap_pkthdr* pkthdr,
const uint8_t* packet);
125 static void onPacketArrivesBlockingMode(uint8_t* user,
const struct pcap_pkthdr* pkthdr,
const uint8_t* packet);
126 std::string printThreadId(PcapThread*
id);
127 virtual ThreadStart getCaptureThreadStart();
251 std::string
getName()
const {
return m_Name; }
256 std::string
getDesc()
const {
return m_Description; }
266 virtual uint32_t
getMtu()
const {
return m_DeviceMtu; }
276 const std::vector<pcap_addr_t>&
getAddresses()
const {
return m_Addresses; }
445 bool sendPacket(
const uint8_t* packetData,
int packetDataLength,
int packetPayloadLength);
504 virtual int sendPackets(
Packet** packetsArr,
int arrLength,
bool checkMtu =
true);
The main namespace for the PcapPlusPlus lib.
Definition: PcapLiveDevice.h:162
Definition: PcapLiveDevice.h:138
Definition: PcapLiveDevice.h:166
const std::vector< pcap_addr_t > & getAddresses() const
Definition: PcapLiveDevice.h:276
Definition: PcapLiveDevice.h:175
bool sendPacket(RawPacket const &rawPacket, bool checkMtu=false)
DeviceMode
Definition: PcapLiveDevice.h:147
Definition: RawPacket.h:30
virtual MacAddress getMacAddress() const
Definition: PcapLiveDevice.h:281
Definition: PcapLiveDevice.h:150
bool doMtuCheck(int packetPayloadLength)
Definition: PcapDevice.h:39
Definition: PointerVector.h:24
LiveDeviceType
Definition: PcapLiveDevice.h:133
Definition: RawPacket.h:252
int packetBufferSize
Definition: PcapLiveDevice.h:194
PcapDirection
Definition: PcapLiveDevice.h:159
void(* OnStatsUpdateCallback)(IPcapDevice::PcapStats &stats, void *userCookie)
Definition: PcapLiveDevice.h:54
const std::vector< IPv4Address > & getDnsServers() const
Definition: PcapLiveDevice.h:152
virtual uint32_t getMtu() const
Definition: PcapLiveDevice.h:266
int packetBufferTimeoutMs
Definition: PcapLiveDevice.h:184
Definition: PcapLiveDevice.h:140
PcapDirection direction
Definition: PcapLiveDevice.h:200
Definition: IpAddress.h:26
IPv4Address getIPv4Address() const
void(* OnPacketArrivesCallback)(RawPacket *pPacket, PcapLiveDevice *pDevice, void *userCookie)
Definition: PcapLiveDevice.h:35
Definition: PcapLiveDevice.h:136
Definition: PcapLiveDevice.h:81
std::string getDesc() const
Definition: PcapLiveDevice.h:256
LinkLayerType
Definition: RawPacket.h:25
bool(* OnPacketArrivesStopBlocking)(RawPacket *pPacket, PcapLiveDevice *pDevice, void *userData)
Definition: PcapLiveDevice.h:45
DeviceConfiguration(DeviceMode mode=Promiscuous, int packetBufferTimeoutMs=0, int packetBufferSize=0, PcapDirection direction=PCPP_INOUT, int snapshotLength=0)
Definition: PcapLiveDevice.h:226
virtual ~PcapLiveDevice()
virtual void getStatistics(IPcapDevice::PcapStats &stats) const
IPv4Address getDefaultGateway() const
DeviceMode mode
Definition: PcapLiveDevice.h:178
virtual bool startCapture(OnPacketArrivesCallback onPacketArrives, void *onPacketArrivesUserCookie)
int snapshotLength
Definition: PcapLiveDevice.h:210
virtual LiveDeviceType getDeviceType() const
Definition: PcapLiveDevice.h:246
bool getLoopback() const
Definition: PcapLiveDevice.h:261
Definition: PcapLiveDevice.h:164
virtual int startCaptureBlockingMode(OnPacketArrivesStopBlocking onPacketArrives, void *userCookie, int timeout)
virtual LinkLayerType getLinkType() const
Definition: PcapLiveDevice.h:271
Definition: MacAddress.h:27
Definition: PcapDevice.h:53
virtual int sendPackets(RawPacket *rawPacketsArr, int arrLength, bool checkMtu=false)
Definition: PcapLiveDeviceList.h:25
std::string getName() const
Definition: PcapLiveDevice.h:251