PcapPlusPlus
pcpp::PcapLiveDeviceList Class Reference

#include <PcapLiveDeviceList.h>

Public Member Functions

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

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()

std::vector<IPv4Address>& pcpp::PcapLiveDeviceList::getDnsServers ( )
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 ( IPAddress ipAddr)

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() [2/4]

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

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() [3/4]

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

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

◆ getPcapLiveDeviceByIp() [4/4]

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

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

◆ getPcapLiveDeviceByName()

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

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 ( )
inline
Returns
A vector containing pointers to all live devices currently installed on the machine