50 PcapHandle& operator=(std::nullptr_t) noexcept;
57 return m_PcapDescriptor !=
nullptr;
61 pcap_t*
get() const noexcept
63 return m_PcapDescriptor;
73 void reset(pcap_t* pcapDescriptor =
nullptr) noexcept;
101 explicit operator
bool() const noexcept
106 bool operator==(std::nullptr_t)
const noexcept
110 bool operator!=(std::nullptr_t)
const noexcept
116 pcap_t* m_PcapDescriptor =
nullptr;
Definition: PcapFilter.h:134
virtual bool setFilter(GeneralFilter &filter)
Definition: Device.h:63
Definition: PcapDevice.h:141
bool setFilter(std::string filterAsString) override
bool clearFilter() override
static bool matchPacketWithFilter(GeneralFilter &filter, RawPacket *rawPacket)
static std::string getPcapLibVersionInfo()
An interface for providing Pcap-based device statistics.
Definition: PcapDevice.h:122
virtual void getStatistics(PcapStats &stats) const =0
PcapStats getStatistics() const
Get statistics from the device.
Definition: RawPacket.h:259
A wrapper class for pcap_t* which is the libpcap packet capture descriptor. This class is used to man...
Definition: PcapDevice.h:37
pcap_t * release() noexcept
Releases ownership of the handle and returns the pcap descriptor.
char const * getLastError() const noexcept
Helper function to retrieve a view of the last error string for this handle.
bool setFilter(std::string const &filter)
Sets a filter on the handle. Only packets that match the filter will be captured by the handle.
void reset(pcap_t *pcapDescriptor=nullptr) noexcept
Replaces the managed handle with the provided one.
bool clearFilter()
Clears the filter currently set on the handle.
constexpr PcapHandle() noexcept=default
Creates an empty handle.
bool getStatistics(PcapStats &stats) const
Retrieves statistics from the pcap handle.
pcap_t * get() const noexcept
Definition: PcapDevice.h:61
bool isValid() const noexcept
Definition: PcapDevice.h:55
The main namespace for the PcapPlusPlus lib.
Definition: PcapDevice.h:24
uint64_t packetsDropByInterface
number of packets dropped by interface (not supported on all platforms)
Definition: PcapDevice.h:30
uint64_t packetsRecv
Number of packets received.
Definition: PcapDevice.h:26
uint64_t packetsDrop
Number of packets dropped.
Definition: PcapDevice.h:28