|
PcapPlusPlus
20.08
|
Go to the documentation of this file.
2 #ifndef PCAPPP_LIVE_DEVICE
3 #define PCAPPP_LIVE_DEVICE
52 typedef void* (*ThreadStart)(
void*);
83 pcap_t* m_PcapSendDescriptor;
85 const char* m_Description;
88 std::vector<pcap_addr_t> m_Addresses;
91 PcapThread* m_CaptureThread;
92 bool m_CaptureThreadStarted;
93 PcapThread* m_StatsThread;
94 bool m_StatsThreadStarted;
97 void* m_cbOnPacketArrivesUserCookie;
99 void* m_cbOnStatsUpdateUserCookie;
101 void* m_cbOnPacketArrivesBlockingModeUserCookie;
102 int m_IntervalToUpdateStats;
104 bool m_CaptureCallbackMode;
108 PcapLiveDevice(pcap_if_t* pInterface,
bool calculateMTU,
bool calculateMacAddress,
bool calculateDefaultGateway);
114 void setDeviceMacAddress();
115 void setDefaultGateway();
116 static void* captureThreadMain(
void* ptr);
117 static void* statsThreadMain(
void* ptr);
118 static void onPacketArrives(uint8_t* user,
const struct pcap_pkthdr* pkthdr,
const uint8_t* packet);
119 static void onPacketArrivesNoCallback(uint8_t* user,
const struct pcap_pkthdr* pkthdr,
const uint8_t* packet);
120 static void onPacketArrivesBlockingMode(uint8_t* user,
const struct pcap_pkthdr* pkthdr,
const uint8_t* packet);
121 std::string printThreadId(PcapThread*
id);
122 virtual ThreadStart getCaptureThreadStart();
246 const char*
getName()
const {
return m_Name; }
251 const char*
getDesc()
const {
return m_Description; }
261 virtual uint32_t
getMtu()
const {
return m_DeviceMtu; }
270 const std::vector<pcap_addr_t>&
getAddresses()
const {
return m_Addresses; }
425 bool sendPacket(
const uint8_t* packetData,
int packetDataLength);
494 bool open(
const DeviceConfiguration& config);
501 pcap_t* doOpen(
const DeviceConfiguration& config);
@ Promiscuous
Definition: PcapLiveDevice.h:147
Definition: IpAddress.h:26
@ RemoteDevice
Definition: PcapLiveDevice.h:135
Definition: PcapLiveDevice.h:76
@ LibPcapDevice
Definition: PcapLiveDevice.h:131
virtual bool startCapture(OnPacketArrivesCallback onPacketArrives, void *onPacketArrivesUserCookie)
Definition: PcapLiveDevice.h:170
IPv4Address getIPv4Address() const
int packetBufferTimeoutMs
Definition: PcapLiveDevice.h:179
PcapDirection direction
Definition: PcapLiveDevice.h:195
const char * getDesc() const
Definition: PcapLiveDevice.h:251
virtual uint32_t getMtu() const
Definition: PcapLiveDevice.h:261
Definition: MacAddress.h:27
DeviceMode mode
Definition: PcapLiveDevice.h:173
virtual int sendPackets(RawPacket *rawPacketsArr, int arrLength)
PcapDirection
Definition: PcapLiveDevice.h:154
@ PCPP_IN
Definition: PcapLiveDevice.h:159
virtual void getStatistics(pcap_stat &stats) const
virtual MacAddress getMacAddress() const
Definition: PcapLiveDevice.h:275
int snapshotLength
Definition: PcapLiveDevice.h:205
DeviceConfiguration(DeviceMode mode=Promiscuous, int packetBufferTimeoutMs=0, int packetBufferSize=0, PcapDirection direction=PCPP_INOUT, int snapshotLength=0)
Definition: PcapLiveDevice.h:221
const std::vector< IPv4Address > & getDnsServers() const
bool sendPacket(RawPacket const &rawPacket)
int packetBufferSize
Definition: PcapLiveDevice.h:189
@ PCPP_OUT
Definition: PcapLiveDevice.h:161
LiveDeviceType
Definition: PcapLiveDevice.h:128
bool getLoopback() const
Definition: PcapLiveDevice.h:256
void(* OnPacketArrivesCallback)(RawPacket *pPacket, PcapLiveDevice *pDevice, void *userCookie)
Definition: PcapLiveDevice.h:30
@ WinPcapDevice
Definition: PcapLiveDevice.h:133
virtual int startCaptureBlockingMode(OnPacketArrivesStopBlocking onPacketArrives, void *userCookie, int timeout)
@ PCPP_INOUT
Definition: PcapLiveDevice.h:157
@ Normal
Definition: PcapLiveDevice.h:145
virtual LinkLayerType getLinkType() const
Definition: PcapLiveDevice.h:266
Definition: PcapDevice.h:35
Definition: PcapLiveDeviceList.h:25
virtual ~PcapLiveDevice()
The main namespace for the PcapPlusPlus lib.
bool(* OnPacketArrivesStopBlocking)(RawPacket *pPacket, PcapLiveDevice *pDevice, void *userData)
Definition: PcapLiveDevice.h:40
LinkLayerType
Definition: RawPacket.h:25
virtual LiveDeviceType getDeviceType() const
Definition: PcapLiveDevice.h:241
const std::vector< pcap_addr_t > & getAddresses() const
Definition: PcapLiveDevice.h:270
DeviceMode
Definition: PcapLiveDevice.h:142
void(* OnStatsUpdateCallback)(pcap_stat &stats, void *userCookie)
Definition: PcapLiveDevice.h:49
IPv4Address getDefaultGateway() const
Definition: PointerVector.h:24
Definition: RawPacket.h:252
const char * getName() const
Definition: PcapLiveDevice.h:246