15 typedef pcap_if pcap_if_t;
17 typedef struct pcap_addr pcap_addr_t;
86 pcap_t* m_PcapSendDescriptor;
87 int m_PcapSelectableFd;
89 std::string m_Description;
92 std::vector<pcap_addr_t> m_Addresses;
95 std::thread m_CaptureThread;
96 std::thread m_StatsThread;
97 bool m_StatsThreadStarted;
100 std::atomic<bool> m_StopThread;
102 std::atomic<bool> m_CaptureThreadStarted;
105 void* m_cbOnPacketArrivesUserCookie;
107 void* m_cbOnStatsUpdateUserCookie;
109 void* m_cbOnPacketArrivesBlockingModeUserCookie;
110 int m_IntervalToUpdateStats;
112 bool m_CaptureCallbackMode;
117 PcapLiveDevice(pcap_if_t* pInterface,
bool calculateMTU,
bool calculateMacAddress,
118 bool calculateDefaultGateway);
124 void setDeviceMacAddress();
125 void setDefaultGateway();
128 void captureThreadMain();
129 void statsThreadMain();
131 static void onPacketArrives(uint8_t* user,
const struct pcap_pkthdr* pkthdr,
const uint8_t* packet);
132 static void onPacketArrivesNoCallback(uint8_t* user,
const struct pcap_pkthdr* pkthdr,
const uint8_t* packet);
133 static void onPacketArrivesBlockingMode(uint8_t* user,
const struct pcap_pkthdr* pkthdr,
const uint8_t* packet);
282 return m_Description;
316 PCPP_DEPRECATED(
"This method is deprecated and will be removed in future versions. Please use getIPAddresses() instead.")
409 void* onStatsUpdateUserCookie);
430 void* onStatsUpdateUserCookie);
474 const double timeout);
528 bool sendPacket(
const uint8_t* packetData,
int packetDataLength,
int packetPayloadLength);
547 bool sendPacket(
const uint8_t* packetData,
int packetDataLength,
bool checkMtu =
false,
647 virtual PcapLiveDevice* cloneInternal(pcap_if_t& devInterface)
const;
Definition: PcapDevice.h:114
Definition: IpAddress.h:32
Definition: IpAddress.h:199
Definition: MacAddress.h:25
Definition: PcapLiveDevice.h:79
PcapDirection
Definition: PcapLiveDevice.h:165
@ PCPP_IN
Definition: PcapLiveDevice.h:169
@ PCPP_OUT
Definition: PcapLiveDevice.h:171
@ PCPP_INOUT
Definition: PcapLiveDevice.h:167
LiveDeviceType
Definition: PcapLiveDevice.h:140
@ WinPcapDevice
Definition: PcapLiveDevice.h:144
@ RemoteDevice
Definition: PcapLiveDevice.h:146
@ LibPcapDevice
Definition: PcapLiveDevice.h:142
virtual int startCaptureBlockingMode(OnPacketArrivesStopBlocking onPacketArrives, void *userCookie, const double timeout)
DeviceMode
Definition: PcapLiveDevice.h:153
@ Normal
Definition: PcapLiveDevice.h:155
@ Promiscuous
Definition: PcapLiveDevice.h:157
virtual bool startCapture(int intervalInSecondsToUpdateStats, OnStatsUpdateCallback onStatsUpdate, void *onStatsUpdateUserCookie)
bool sendPacket(RawPacket const &rawPacket, bool checkMtu=false)
virtual uint32_t getMtu() const
Definition: PcapLiveDevice.h:296
virtual bool startCapture(OnPacketArrivesCallback onPacketArrives, void *onPacketArrivesUserCookie)
void getStatistics(IPcapDevice::PcapStats &stats) const override
bool open(const DeviceConfiguration &config)
bool doMtuCheck(int packetPayloadLength) const
virtual MacAddress getMacAddress() const
Definition: PcapLiveDevice.h:331
bool sendPacket(const uint8_t *packetData, int packetDataLength, int packetPayloadLength)
IPv4Address getDefaultGateway() const
std::string getDesc() const
Definition: PcapLiveDevice.h:280
bool sendPacket(const uint8_t *packetData, int packetDataLength, bool checkMtu=false, pcpp::LinkLayerType linkType=pcpp::LINKTYPE_ETHERNET)
const std::vector< pcap_addr_t > & getAddresses() const
Definition: PcapLiveDevice.h:318
const std::vector< IPv4Address > & getDnsServers() const
virtual int sendPackets(Packet **packetsArr, int arrLength, bool checkMtu=true)
virtual LiveDeviceType getDeviceType() const
Definition: PcapLiveDevice.h:263
virtual bool startCapture(OnPacketArrivesCallback onPacketArrives, void *onPacketArrivesUserCookie, int intervalInSecondsToUpdateStats, OnStatsUpdateCallback onStatsUpdate, void *onStatsUpdateUserCookie)
IPv6Address getIPv6Address() const
virtual bool startCapture(RawPacketVector &capturedPacketsVector)
~PcapLiveDevice() override
std::string getName() const
Definition: PcapLiveDevice.h:271
IPv4Address getIPv4Address() const
bool sendPacket(Packet *packet, bool checkMtu=true)
virtual int sendPackets(const RawPacketVector &rawPackets, bool checkMtu=false)
virtual int sendPackets(RawPacket *rawPacketsArr, int arrLength, bool checkMtu=false)
virtual LinkLayerType getLinkType() const
Definition: PcapLiveDevice.h:304
PcapLiveDevice * clone() const
bool getLoopback() const
Definition: PcapLiveDevice.h:288
std::vector< IPAddress > getIPAddresses() const
Definition: PcapLiveDeviceList.h:25
Definition: PointerVector.h:29
Definition: RawPacket.h:269
The main namespace for the PcapPlusPlus lib.
std::function< bool(RawPacket *, PcapLiveDevice *, void *)> OnPacketArrivesStopBlocking
Definition: PcapLiveDevice.h:45
std::function< void(RawPacket *, PcapLiveDevice *, void *)> OnPacketArrivesCallback
Definition: PcapLiveDevice.h:36
std::function< void(IPcapDevice::PcapStats &, void *)> OnStatsUpdateCallback
Definition: PcapLiveDevice.h:53
LinkLayerType
Definition: RawPacket.h:25
@ LINKTYPE_ETHERNET
Definition: RawPacket.h:29
Definition: PcapDevice.h:128
Definition: PcapLiveDevice.h:180
int packetBufferTimeoutMs
Definition: PcapLiveDevice.h:188
DeviceConfiguration(DeviceMode mode=Promiscuous, int packetBufferTimeoutMs=0, int packetBufferSize=0, PcapDirection direction=PCPP_INOUT, int snapshotLength=0, unsigned int nflogGroup=0, bool usePoll=false)
Definition: PcapLiveDevice.h:241
int snapshotLength
Definition: PcapLiveDevice.h:213
bool usePoll
In Unix-like system, use poll() for blocking mode.
Definition: PcapLiveDevice.h:222
int packetBufferSize
Definition: PcapLiveDevice.h:198
unsigned int nflogGroup
Definition: PcapLiveDevice.h:219
PcapDirection direction
Definition: PcapLiveDevice.h:204
DeviceMode mode
Definition: PcapLiveDevice.h:182