PcapPlusPlus  19.12
pcpp::PcapLiveDeviceList Class Reference

#include <PcapLiveDeviceList.h>

Public Member Functions

const std::vector< PcapLiveDevice * > & getPcapLiveDevicesList () const
 
PcapLiveDevicegetPcapLiveDeviceByIp (IPAddress *ipAddr) const
 
PcapLiveDevicegetPcapLiveDeviceByIp (IPv4Address ipAddr) const
 
PcapLiveDevicegetPcapLiveDeviceByIp (IPv6Address ip6Addr) const
 
PcapLiveDevicegetPcapLiveDeviceByIp (const char *ipAddrAsString) const
 
PcapLiveDevicegetPcapLiveDeviceByName (const std::string &name) const
 
const std::vector< IPv4Address > & getDnsServers () const
 
void reset ()
 

Static Public Member Functions

static PcapLiveDeviceListgetInstance ()
 

Detailed Description

A singleton class that creates, stores and provides access to all PcapLiveDevice (on Linux) or WinPcapLiveDevice (on Windows) instances. All live devices are initialized on startup and wrap the network interfaces installed on the machine. This class enables access to them through their IP addresses or get a vector of all of them so the user can search them in some other way

Member Function Documentation

◆ getDnsServers()

const std::vector<IPv4Address>& pcpp::PcapLiveDeviceList::getDnsServers ( ) const
inline
Returns
A list of all DNS servers defined for this machine. If this list is empty it means no DNS servers were defined or they couldn't be extracted from some reason

◆ getInstance()

static PcapLiveDeviceList& pcpp::PcapLiveDeviceList::getInstance ( )
inlinestatic

The access method to the singleton

Returns
The singleton instance of this class

◆ getPcapLiveDeviceByIp() [1/4]

PcapLiveDevice* pcpp::PcapLiveDeviceList::getPcapLiveDeviceByIp ( const char *  ipAddrAsString) const

Get a pointer to the live device by its IP address represented as string. IP address can be both IPv4 or IPv6

Parameters
[in]ipAddrAsStringThe IP address defined for the device as string
Returns
A pointer to the live device if this IP address is valid and exists. NULL otherwise

◆ getPcapLiveDeviceByIp() [2/4]

PcapLiveDevice* pcpp::PcapLiveDeviceList::getPcapLiveDeviceByIp ( IPAddress ipAddr) const

Get a pointer to the live device by its IP address. IP address can be both IPv4 or IPv6

Parameters
[in]ipAddrThe IP address defined for the device
Returns
A pointer to the live device if this IP address exists. NULL otherwise

◆ getPcapLiveDeviceByIp() [3/4]

PcapLiveDevice* pcpp::PcapLiveDeviceList::getPcapLiveDeviceByIp ( IPv4Address  ipAddr) const

Get a pointer to the live device by its IPv4 address

Parameters
[in]ipAddrThe IPv4 address defined for the device
Returns
A pointer to the live device if this IPv4 address exists. NULL otherwise

◆ getPcapLiveDeviceByIp() [4/4]

PcapLiveDevice* pcpp::PcapLiveDeviceList::getPcapLiveDeviceByIp ( IPv6Address  ip6Addr) const

Get a pointer to the live device by its IPv6 address

Parameters
[in]ip6AddrThe IPv6 address defined for the device
Returns
A pointer to the live device if this IPv6 address exists. NULL otherwise

◆ getPcapLiveDeviceByName()

PcapLiveDevice* pcpp::PcapLiveDeviceList::getPcapLiveDeviceByName ( const std::string &  name) const

Get a pointer to the live device by its name

Parameters
[in]nameThe name of the interface (e.g eth0)
Returns
A pointer to the live device if this name exists. NULL otherwise

◆ getPcapLiveDevicesList()

const std::vector<PcapLiveDevice*>& pcpp::PcapLiveDeviceList::getPcapLiveDevicesList ( ) const
inline
Returns
A vector containing pointers to all live devices currently installed on the machine

◆ reset()

void pcpp::PcapLiveDeviceList::reset ( )

Reset the live device list and DNS server list, meaning clear and refetch them