2 #ifndef PCAPPP_LIVE_DEVICE 3 #define PCAPPP_LIVE_DEVICE 14 typedef pcap_if pcap_if_t;
16 typedef struct pcap_addr pcap_addr_t;
58 typedef void* (*ThreadStart)(
void*);
87 pcap_t* m_PcapSendDescriptor;
89 std::string m_Description;
92 std::vector<pcap_addr_t> m_Addresses;
95 std::thread m_CaptureThread;
96 bool m_CaptureThreadStarted;
97 std::thread m_StatsThread;
98 bool m_StatsThreadStarted;
101 void* m_cbOnPacketArrivesUserCookie;
103 void* m_cbOnStatsUpdateUserCookie;
105 void* m_cbOnPacketArrivesBlockingModeUserCookie;
106 int m_IntervalToUpdateStats;
108 bool m_CaptureCallbackMode;
112 PcapLiveDevice(pcap_if_t* pInterface,
bool calculateMTU,
bool calculateMacAddress,
bool calculateDefaultGateway);
118 void setDeviceMacAddress();
119 void setDefaultGateway();
122 void captureThreadMain();
123 void statsThreadMain();
125 static void onPacketArrives(uint8_t* user,
const struct pcap_pkthdr* pkthdr,
const uint8_t* packet);
126 static void onPacketArrivesNoCallback(uint8_t* user,
const struct pcap_pkthdr* pkthdr,
const uint8_t* packet);
127 static void onPacketArrivesBlockingMode(uint8_t* user,
const struct pcap_pkthdr* pkthdr,
const uint8_t* packet);
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; }
451 bool sendPacket(
const uint8_t* packetData,
int packetDataLength,
int packetPayloadLength);
510 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
IPv6Address getIPv6Address() const
Definition: RawPacket.h:30
virtual MacAddress getMacAddress() const
Definition: PcapLiveDevice.h:281
Definition: PcapLiveDevice.h:150
bool doMtuCheck(int packetPayloadLength)
Definition: PcapDevice.h:27
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:55
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:27
Definition: IpAddress.h:167
IPv4Address getIPv4Address() const
void(* OnPacketArrivesCallback)(RawPacket *pPacket, PcapLiveDevice *pDevice, void *userCookie)
Definition: PcapLiveDevice.h:36
Definition: PcapLiveDevice.h:136
Definition: PcapLiveDevice.h:80
std::string getDesc() const
Definition: PcapLiveDevice.h:256
LinkLayerType
Definition: RawPacket.h:25
bool(* OnPacketArrivesStopBlocking)(RawPacket *pPacket, PcapLiveDevice *pDevice, void *userData)
Definition: PcapLiveDevice.h:46
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: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:251