PcapPlusPlus  24.09
pcpp::PcapLiveDeviceList Class Reference

#include <PcapLiveDeviceList.h>

Public Member Functions

const std::vector< PcapLiveDevice * > & getPcapLiveDevicesList () const
 
PcapLiveDevicegetPcapLiveDeviceByIp (const IPAddress &ipAddr) const
 
PcapLiveDevicegetPcapLiveDeviceByIp (const IPv4Address &ipAddr) const
 
PcapLiveDevicegetPcapLiveDeviceByIp (const IPv6Address &ip6Addr) const
 
PcapLiveDevicegetPcapLiveDeviceByIp (const std::string &ipAddrAsString) const
 
PcapLiveDevicegetPcapLiveDeviceByName (const std::string &name) const
 
PcapLiveDevicegetPcapLiveDeviceByIpOrName (const std::string &ipOrName) const
 
const std::vector< IPv4Address > & getDnsServers () const
 
PcapLiveDeviceListclone ()
 
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

◆ clone()

PcapLiveDeviceList* pcpp::PcapLiveDeviceList::clone ( )

Copies the current live device list

Returns
A pointer to the cloned device list

◆ 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 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. nullptr otherwise

◆ getPcapLiveDeviceByIp() [2/4]

PcapLiveDevice* pcpp::PcapLiveDeviceList::getPcapLiveDeviceByIp ( const 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. nullptr otherwise

◆ getPcapLiveDeviceByIp() [3/4]

PcapLiveDevice* pcpp::PcapLiveDeviceList::getPcapLiveDeviceByIp ( const 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. nullptr otherwise

◆ getPcapLiveDeviceByIp() [4/4]

PcapLiveDevice* pcpp::PcapLiveDeviceList::getPcapLiveDeviceByIp ( const std::string &  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. nullptr otherwise

◆ getPcapLiveDeviceByIpOrName()

PcapLiveDevice* pcpp::PcapLiveDeviceList::getPcapLiveDeviceByIpOrName ( const std::string &  ipOrName) const

Get a pointer to the live device by its IP address or name

Parameters
[in]ipOrNameAn IP address or name of the interface
Returns
A pointer to the live device if exists, nullptr 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. nullptr 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