2 #ifndef PCAPPP_LIVE_DEVICE 3 #define PCAPPP_LIVE_DEVICE 16 typedef pcap_if pcap_if_t;
18 typedef struct pcap_addr pcap_addr_t;
60 typedef void* (*ThreadStart)(
void*);
89 pcap_t* m_PcapSendDescriptor;
91 std::string m_Description;
94 std::vector<pcap_addr_t> m_Addresses;
97 std::thread m_CaptureThread;
98 bool m_CaptureThreadStarted;
99 std::thread m_StatsThread;
100 bool m_StatsThreadStarted;
101 std::atomic<bool> m_StopThread;
103 void* m_cbOnPacketArrivesUserCookie;
105 void* m_cbOnStatsUpdateUserCookie;
107 void* m_cbOnPacketArrivesBlockingModeUserCookie;
108 int m_IntervalToUpdateStats;
110 bool m_CaptureCallbackMode;
114 PcapLiveDevice(pcap_if_t* pInterface,
bool calculateMTU,
bool calculateMacAddress,
bool calculateDefaultGateway);
120 void setDeviceMacAddress();
121 void setDefaultGateway();
124 void captureThreadMain();
125 void statsThreadMain();
127 static void onPacketArrives(uint8_t* user,
const struct pcap_pkthdr* pkthdr,
const uint8_t* packet);
128 static void onPacketArrivesNoCallback(uint8_t* user,
const struct pcap_pkthdr* pkthdr,
const uint8_t* packet);
129 static void onPacketArrivesBlockingMode(uint8_t* user,
const struct pcap_pkthdr* pkthdr,
const uint8_t* packet);
261 std::string
getName()
const {
return m_Name; }
266 std::string
getDesc()
const {
return m_Description; }
276 virtual uint32_t
getMtu()
const {
return m_DeviceMtu; }
286 const std::vector<pcap_addr_t>&
getAddresses()
const {
return m_Addresses; }
461 bool sendPacket(
const uint8_t* packetData,
int packetDataLength,
int packetPayloadLength);
520 virtual int sendPackets(
Packet** packetsArr,
int arrLength,
bool checkMtu =
true);
The main namespace for the PcapPlusPlus lib.
Definition: PcapLiveDevice.h:164
Definition: PcapLiveDevice.h:140
Definition: PcapLiveDevice.h:168
const std::vector< pcap_addr_t > & getAddresses() const
Definition: PcapLiveDevice.h:286
bool(* OnPacketArrivesStopBlocking)(RawPacket *pPacket, PcapLiveDevice *pDevice, void *userCookie)
Definition: PcapLiveDevice.h:48
Definition: PcapLiveDevice.h:177
bool sendPacket(RawPacket const &rawPacket, bool checkMtu=false)
DeviceMode
Definition: PcapLiveDevice.h:149
IPv6Address getIPv6Address() const
Definition: RawPacket.h:30
virtual MacAddress getMacAddress() const
Definition: PcapLiveDevice.h:291
Definition: PcapLiveDevice.h:152
bool doMtuCheck(int packetPayloadLength)
Definition: PcapDevice.h:27
Definition: PointerVector.h:24
LiveDeviceType
Definition: PcapLiveDevice.h:135
Definition: RawPacket.h:254
int packetBufferSize
Definition: PcapLiveDevice.h:196
PcapDirection
Definition: PcapLiveDevice.h:161
void(* OnStatsUpdateCallback)(IPcapDevice::PcapStats &stats, void *userCookie)
Definition: PcapLiveDevice.h:57
const std::vector< IPv4Address > & getDnsServers() const
DeviceConfiguration(DeviceMode mode=Promiscuous, int packetBufferTimeoutMs=0, int packetBufferSize=0, PcapDirection direction=PCPP_INOUT, int snapshotLength=0, unsigned int nflogGroup=0)
Definition: PcapLiveDevice.h:235
Definition: PcapLiveDevice.h:154
virtual uint32_t getMtu() const
Definition: PcapLiveDevice.h:276
int packetBufferTimeoutMs
Definition: PcapLiveDevice.h:186
Definition: PcapLiveDevice.h:142
PcapDirection direction
Definition: PcapLiveDevice.h:202
Definition: IpAddress.h:42
Definition: IpAddress.h:192
IPv4Address getIPv4Address() const
void(* OnPacketArrivesCallback)(RawPacket *pPacket, PcapLiveDevice *pDevice, void *userCookie)
Definition: PcapLiveDevice.h:38
Definition: PcapLiveDevice.h:138
Definition: PcapLiveDevice.h:82
std::string getDesc() const
Definition: PcapLiveDevice.h:266
unsigned int nflogGroup
Definition: PcapLiveDevice.h:218
LinkLayerType
Definition: RawPacket.h:25
virtual ~PcapLiveDevice()
virtual void getStatistics(IPcapDevice::PcapStats &stats) const
IPv4Address getDefaultGateway() const
DeviceMode mode
Definition: PcapLiveDevice.h:180
virtual bool startCapture(OnPacketArrivesCallback onPacketArrives, void *onPacketArrivesUserCookie)
int snapshotLength
Definition: PcapLiveDevice.h:212
virtual LiveDeviceType getDeviceType() const
Definition: PcapLiveDevice.h:256
bool getLoopback() const
Definition: PcapLiveDevice.h:271
Definition: PcapLiveDevice.h:166
virtual int startCaptureBlockingMode(OnPacketArrivesStopBlocking onPacketArrives, void *userCookie, int timeout)
virtual LinkLayerType getLinkType() const
Definition: PcapLiveDevice.h:281
Definition: MacAddress.h:28
Definition: PcapDevice.h:41
virtual int sendPackets(RawPacket *rawPacketsArr, int arrLength, bool checkMtu=false)
Definition: PcapLiveDeviceList.h:24
std::string getName() const
Definition: PcapLiveDevice.h:261