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;
107 PcapLiveDevice(pcap_if_t* pInterface,
bool calculateMTU,
bool calculateMacAddress,
bool calculateDefaultGateway);
113 void setDeviceMacAddress();
114 void setDefaultGateway();
115 static void* captureThreadMain(
void *ptr);
116 static void* statsThreadMain(
void *ptr);
117 static void onPacketArrives(uint8_t *user,
const struct pcap_pkthdr *pkthdr,
const uint8_t *packet);
118 static void onPacketArrivesNoCallback(uint8_t *user,
const struct pcap_pkthdr *pkthdr,
const uint8_t *packet);
119 static void onPacketArrivesBlockingMode(uint8_t *user,
const struct pcap_pkthdr *pkthdr,
const uint8_t *packet);
120 std::string printThreadId(PcapThread*
id);
121 virtual ThreadStart getCaptureThreadStart();
158 inline const char*
getName() {
return m_Name; }
163 inline const char*
getDesc() {
return m_Description; }
173 virtual inline uint16_t
getMtu() {
return m_DeviceMtu; }
178 inline std::vector<pcap_addr_t>&
getAddresses() {
return m_Addresses; }
327 bool sendPacket(
const uint8_t* packetData,
int packetDataLength);
Definition: PcapLiveDevice.h:142
bool getLoopback()
Definition: PcapLiveDevice.h:168
const char * getDesc()
Definition: PcapLiveDevice.h:163
Definition: PcapLiveDeviceList.h:25
Definition: RawPacket.h:220
Definition: PcapDevice.h:38
bool(* OnPacketArrivesStopBlocking)(RawPacket *pPacket, PcapLiveDevice *pDevice, void *userData)
Definition: PcapLiveDevice.h:40
void(* OnPacketArrivesCallback)(RawPacket *pPacket, PcapLiveDevice *pDevice, void *userCookie)
Definition: PcapLiveDevice.h:30
The main namespace for the PcapPlusPlus lib.
bool sendPacket(RawPacket const &rawPacket)
Definition: IpAddress.h:113
Definition: PcapLiveDevice.h:76
void(* OnStatsUpdateCallback)(pcap_stat &stats, void *userCookie)
Definition: PcapLiveDevice.h:49
virtual ~PcapLiveDevice()
IPv4Address getDefaultGateway()
Definition: PointerVector.h:24
virtual MacAddress getMacAddress()
Definition: PcapLiveDevice.h:183
const char * getName()
Definition: PcapLiveDevice.h:158
virtual LiveDeviceType getDeviceType()
Definition: PcapLiveDevice.h:153
Definition: PcapLiveDevice.h:130
IPv4Address getIPv4Address()
virtual int sendPackets(RawPacket *rawPacketsArr, int arrLength)
Definition: PcapLiveDevice.h:132
DeviceMode
Definition: PcapLiveDevice.h:138
Definition: MacAddress.h:21
Definition: PcapLiveDevice.h:140
virtual int startCaptureBlockingMode(OnPacketArrivesStopBlocking onPacketArrives, void *userCookie, int timeout)
LiveDeviceType
Definition: PcapLiveDevice.h:126
std::vector< pcap_addr_t > & getAddresses()
Definition: PcapLiveDevice.h:178
virtual bool startCapture(OnPacketArrivesCallback onPacketArrives, void *onPacketArrivesUserCookie)
Definition: PcapLiveDevice.h:128
std::vector< IPv4Address > & getDnsServers()
virtual void getStatistics(pcap_stat &stats)
virtual uint16_t getMtu()
Definition: PcapLiveDevice.h:173