Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate shared DeviceList functionality under a common base class. #1488

Open
wants to merge 83 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 79 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
59c8647
Changed RemoteDeviceList to hold devices in a PointerVector.
Dimi1010 Jun 30, 2024
2ce99c0
Merge remote-tracking branch 'upstream/dev' into refactor/device-list…
Dimi1010 Jul 7, 2024
415880e
Added iterator member type definitions conforming to the standard lib…
Dimi1010 Jul 7, 2024
1a678bb
Changed PcapLiveDeviceList to utilize a PointerVector iternally.
Dimi1010 Jul 7, 2024
40da178
Added iteration API to LiveDeviceList.
Dimi1010 Jul 7, 2024
e0eed6c
Updated usages of deprecated `getPcapLiveDevicesList`.
Dimi1010 Jul 7, 2024
265865c
Removed empty destructor.
Dimi1010 Jul 7, 2024
b479b08
Split overly long line.
Dimi1010 Jul 8, 2024
6a4c330
Formatting fixes.
Dimi1010 Jul 10, 2024
f28307a
Fixed documentation of iterator API.
Dimi1010 Jul 10, 2024
326d2cc
Updated PfRingDeviceList to use PointerVector internally.
Dimi1010 Jul 10, 2024
d940946
Moved include to cpp file.
Dimi1010 Jul 10, 2024
21391cb
Merge remote-tracking branch 'upstream/dev' into refactor/device-list…
Dimi1010 Jul 21, 2024
54c0efe
Merge branch 'dev' into refactor/device-list-management
seladb Jul 21, 2024
0b4230c
Merge branch 'dev' into refactor/device-list-management
seladb Jul 25, 2024
118578c
Merge branch 'dev' into refactor/device-list-management
seladb Jul 29, 2024
921dda4
Added a base device list class to contain common functionality betwee…
Dimi1010 Jul 29, 2024
7f3d810
Merge remote-tracking branch 'origin/refactor/device-list-management'…
Dimi1010 Jul 29, 2024
a3c533a
Updated PcapRemoteDeviceList and PfRingDeviceList to utilize DeviceLi…
Dimi1010 Jul 29, 2024
faeb1ee
Merge branch 'dev' into refactor/device-list-management
Dimi1010 Jul 29, 2024
6e990e9
Fixes and cleanup.
Dimi1010 Jul 29, 2024
b31b65f
Deprecation message fixes.
Dimi1010 Jul 29, 2024
d649dd9
Updated DpdkDeviceList to utilize DeviceListBase.
Dimi1010 Jul 29, 2024
e9143d1
Updated KniDeviceList to utilize DeviceListBase.
Dimi1010 Jul 29, 2024
c956f67
Fixed KniDevice device search.
Dimi1010 Jul 29, 2024
ccaac4e
Refactored KniDeviceList::createDevice to use smart pointers during c…
Dimi1010 Jul 29, 2024
df807f7
Fixed KniDevice deletion errors.
Dimi1010 Jul 29, 2024
38b5633
Lint
Dimi1010 Jul 29, 2024
7668b9f
Fixed namespace closure.
Dimi1010 Jul 29, 2024
91ccd0e
Fixed alias.
Dimi1010 Jul 29, 2024
df2730f
Fixed KniDeviceDeleter documentation.
Dimi1010 Jul 29, 2024
e434258
Reverted creation of KniDevice to raw ptr.
Dimi1010 Jul 29, 2024
85a35f5
Fixed KniDeviceDeleter documentation again.
Dimi1010 Jul 29, 2024
ed143d7
Attempt to fix dpdk device fetch by port.
Dimi1010 Jul 29, 2024
e5dc2da
Lint
Dimi1010 Jul 29, 2024
9cf44ce
Merge remote-tracking branch 'upstream/dev' into refactor/device-list…
Dimi1010 Jul 30, 2024
2ae51d2
Minor fixes.
Dimi1010 Jul 30, 2024
a73d4b9
Changed PcapLiveDeviceList getters to 'getDeviceBy*' syntax.
Dimi1010 Jul 31, 2024
75c4e32
Replaced usages of deprecated method 'getPcapLiveDevicesList()'.
Dimi1010 Jul 31, 2024
ab45201
Replaced usages of deprecated method 'getPfRingDevicesList()'.
Dimi1010 Jul 31, 2024
cee1e43
Deprecated old iterator aliases for RemoteDeviceList and updated usages.
Dimi1010 Jul 31, 2024
3b72143
Replaced deprecated function 'getRemoteDeviceList' usages.
Dimi1010 Jul 31, 2024
ffac432
Changed PcapRemoteDeviceList getters to 'getDeviceBy*' syntax.
Dimi1010 Jul 31, 2024
2245bb5
Fixed deprecation message.
Dimi1010 Jul 31, 2024
151f09f
Changed PfRingDeviceList getters to 'getDeviceBy*' syntax.
Dimi1010 Jul 31, 2024
0dbeb1f
Lint
Dimi1010 Jul 31, 2024
0317b91
Fixed documentation error.
Dimi1010 Jul 31, 2024
bb695b8
Attempt to fix the deprecation warning error.
Dimi1010 Aug 1, 2024
3dfe776
Lint
Dimi1010 Aug 1, 2024
5c3f9d3
Attempt to fix doxygen copydoc errors.
Dimi1010 Aug 1, 2024
f5bd24f
Copied the documentation manually as copydoc was causing issues.
Dimi1010 Aug 1, 2024
49ffbd6
Fixed missed copydoc.
Dimi1010 Aug 1, 2024
e473b64
Merge remote-tracking branch 'upstream/dev' into refactor/device-list…
Dimi1010 Aug 7, 2024
e8e86ca
Rename preprocessor macros to remove leading underscores
Dimi1010 Aug 7, 2024
1fabdd1
Merge branch 'dev' into refactor/device-list-management
Dimi1010 Aug 7, 2024
9d515c4
Merge branch 'dev' into refactor/device-list-management
Dimi1010 Aug 12, 2024
abf1171
Updated code to use PointerVector.
Dimi1010 Aug 12, 2024
6ffdc41
Merge branch 'dev' into refactor/device-list-management
Dimi1010 Aug 14, 2024
5215614
Merge branch 'dev' into refactor/device-list-management
Dimi1010 Aug 21, 2024
133c433
Fixed merge errors.
Dimi1010 Aug 23, 2024
87bd25d
Lint
Dimi1010 Aug 23, 2024
848afd5
Merge remote-tracking branch 'upstream/dev' into refactor/device-list…
Dimi1010 Aug 23, 2024
17f742e
Fixed device list name.
Dimi1010 Aug 23, 2024
be2db4b
Fixed pushBack signature.
Dimi1010 Aug 23, 2024
2ea0628
Merge remote-tracking branch 'upstream/dev' into refactor/device-list…
Dimi1010 Aug 25, 2024
8841b6b
Merge remote-tracking branch 'upstream/dev' into refactor/device-list…
Dimi1010 Oct 4, 2024
1a1c0b8
Lint
Dimi1010 Oct 6, 2024
2f890a4
Lint
Dimi1010 Oct 6, 2024
75a1df3
Lint
Dimi1010 Oct 6, 2024
2bdfd2a
Merge branch 'dev' into refactor/device-list-management
Dimi1010 Oct 11, 2024
344a656
Fixed empty line between methods.
Dimi1010 Oct 11, 2024
0cfbdd4
Merge remote-tracking branch 'upstream/dev' into refactor/device-list…
Dimi1010 Oct 24, 2024
274c02c
Merge remote-tracking branch 'upstream/dev' into refactor/device-list…
Dimi1010 Nov 5, 2024
e9ae72e
Lint
Dimi1010 Nov 5, 2024
afd6e92
Merge remote-tracking branch 'upstream/dev' into refactor/device-list…
Dimi1010 Nov 25, 2024
b0d2744
Added self-copy guards.
Dimi1010 Nov 25, 2024
9863b11
Fixed warnings.
Dimi1010 Nov 25, 2024
fc73879
Added tests for DeviceListBase.
Dimi1010 Nov 25, 2024
6bd0cbf
Lint
Dimi1010 Nov 25, 2024
1d84a3c
Add "venv" and "./out" directories to be ignored by codespell.
Dimi1010 Nov 27, 2024
68130d5
Suppress checkersReport messages for cppcheck.
Dimi1010 Nov 27, 2024
9ad70af
Lint
Dimi1010 Nov 27, 2024
871cca7
Added explicit defaulted public destructors to device lists.
Dimi1010 Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions Common++/header/DeprecationUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@

/// @file

#ifndef PCPP_DEPRECATED_GNU
# if defined(__GUNC__) || defined(__clang__)
# define PCPP_DEPRECATED_GNU(msg) __attribute__((deprecated(msg)))
# else
# define PCPP_DEPRECATED_GNU(msg)
# endif // defined(__GUNC__) || defined(__clang__)
#endif // !PCPP_DEPRECATED_GNU

#ifndef PCPP_DEPRECATED_MSVC
# ifdef _MSC_VER
# define PCPP_DEPRECATED_MSVC(msg) __declspec(deprecated(msg))
# else
# define PCPP_DEPRECATED_MSVC(msg)
# endif // __MSC_VER
#endif // !PCPP_DEPRECATED_MSVC

#ifndef PCPP_DEPRECATED
# if defined(__GNUC__) || defined(__clang__)
# define PCPP_DEPRECATED(msg) __attribute__((deprecated(msg)))
# define PCPP_DEPRECATED(msg) PCPP_DEPRECATED_GNU(msg)
# elif defined(_MSC_VER)
# define PCPP_DEPRECATED(msg) __declspec(deprecated(msg))
# define PCPP_DEPRECATED(msg) PCPP_DEPRECATED_MSVC(msg)
# else
# pragma message("WARNING: DEPRECATED feature is not implemented for this compiler")
# define PCPP_DEPRECATED(msg)
Expand Down
24 changes: 14 additions & 10 deletions Common++/header/PointerVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ namespace pcpp
* removed from the vector This class wraps std::vector and adds the capability of freeing objects once they're
* removed from it
*/
template <typename T> class PointerVector
template <typename T, typename Deleter = std::default_delete<T>> class PointerVector
{
public:
using deleter_type = Deleter;
/**
* Iterator object that is used for iterating all elements in the vector
*/
Expand Down Expand Up @@ -108,8 +109,11 @@ namespace pcpp
*/
PointerVector& operator=(const PointerVector& other)
{
// Saves a copy of the old pointer to defer cleanup.
auto oldValues = m_Vector;
if (this == &other)
return *this;

// Moves the old values to a temporary to defer cleanup.
auto oldValues = std::move(m_Vector);
try
{
m_Vector = deepCopyUnsafe(other.m_Vector);
Expand All @@ -133,6 +137,9 @@ namespace pcpp
*/
PointerVector& operator=(PointerVector&& other) noexcept
{
if (this == &other)
return *this;

// Releases all current elements.
clear();
// Moves the elements of the other vector.
Expand Down Expand Up @@ -177,7 +184,7 @@ namespace pcpp
{
if (freeElementOnError)
{
delete element;
Deleter()(element);
}
throw;
}
Expand Down Expand Up @@ -288,7 +295,7 @@ namespace pcpp
*/
VectorIterator erase(VectorIterator position)
{
delete (*position);
Deleter()(*position);
return m_Vector.erase(position);
}

Expand Down Expand Up @@ -386,10 +393,7 @@ namespace pcpp
}
catch (const std::exception&)
{
for (auto obj : copyVec)
{
delete obj;
}
freeVectorUnsafe(copyVec);
throw;
}

Expand All @@ -406,7 +410,7 @@ namespace pcpp
{
for (auto& obj : origin)
{
delete obj;
Deleter()(obj);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Examples/ArpSpoofing/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ int main(int argc, char* argv[])
EXIT_WITH_ERROR("Gateway address is not valid");
}

pcpp::PcapLiveDevice* pIfaceDevice = pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDeviceByIp(ifaceAddr);
pcpp::PcapLiveDevice* pIfaceDevice = pcpp::PcapLiveDeviceList::getInstance().getDeviceByIp(ifaceAddr);

// Verifying interface is valid
if (pIfaceDevice == nullptr)
Expand Down
5 changes: 2 additions & 3 deletions Examples/Arping/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ void printAppVersion()
*/
void listInterfaces()
{
const std::vector<pcpp::PcapLiveDevice*>& devList =
pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDevicesList();
const auto& devList = pcpp::PcapLiveDeviceList::getInstance();

std::cout << std::endl << "Network interfaces:" << std::endl;
for (const auto& dev : devList)
Expand Down Expand Up @@ -198,7 +197,7 @@ int main(int argc, char* argv[])
// Search interface by name or IP
if (!ifaceNameOrIP.empty())
{
dev = pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDeviceByIpOrName(ifaceNameOrIP);
dev = pcpp::PcapLiveDeviceList::getInstance().getDeviceByIpOrName(ifaceNameOrIP);
if (dev == nullptr)
EXIT_WITH_ERROR("Couldn't find interface by provided IP address or name");
}
Expand Down
10 changes: 3 additions & 7 deletions Examples/DNSResolver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,8 @@ void printAppVersion()
*/
void listInterfaces()
{
const std::vector<pcpp::PcapLiveDevice*>& devList =
pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDevicesList();

std::cout << std::endl << "Network interfaces:" << std::endl;
for (const auto& dev : devList)
for (const auto& dev : pcpp::PcapLiveDeviceList::getInstance())
{
std::cout << " -> Name: '" << dev->getName() << "' IP address: " << dev->getIPv4Address().toString()
<< std::endl;
Expand Down Expand Up @@ -182,15 +179,14 @@ int main(int argc, char* argv[])
// if interface name or IP was provided - find the device accordingly
if (interfaceNameOrIPProvided)
{
dev = pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDeviceByIpOrName(interfaceNameOrIP);
dev = pcpp::PcapLiveDeviceList::getInstance().getDeviceByIpOrName(interfaceNameOrIP);
if (dev == nullptr)
EXIT_WITH_ERROR("Couldn't find interface by provided IP address or name");
}
// if interface name or IP was not provided - find a device that has a default gateway
else
{
const std::vector<pcpp::PcapLiveDevice*>& devList =
pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDevicesList();
const auto& devList = pcpp::PcapLiveDeviceList::getInstance();

auto iter = std::find_if(devList.begin(), devList.end(), [](pcpp::PcapLiveDevice* dev) {
return dev->getDefaultGateway() != pcpp::IPv4Address::Zero;
Expand Down
5 changes: 2 additions & 3 deletions Examples/DnsSpoofing/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ void printAppVersion()
*/
void listInterfaces()
{
const std::vector<pcpp::PcapLiveDevice*>& devList =
pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDevicesList();
const auto& devList = pcpp::PcapLiveDeviceList::getInstance();

std::cout << std::endl << "Network interfaces:" << std::endl;
for (const auto& dev : devList)
Expand Down Expand Up @@ -450,7 +449,7 @@ int main(int argc, char* argv[])
EXIT_WITH_ERROR("Interface name or IP weren't provided. Please use the -i switch or -h for help");
}

dev = pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDeviceByIpOrName(interfaceNameOrIP);
dev = pcpp::PcapLiveDeviceList::getInstance().getDeviceByIpOrName(interfaceNameOrIP);
if (dev == nullptr)
EXIT_WITH_ERROR("Couldn't find interface by provided IP address or name");

Expand Down
8 changes: 2 additions & 6 deletions Examples/HttpAnalyzer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,8 @@ void printAppVersion()
*/
void listInterfaces()
{
const std::vector<pcpp::PcapLiveDevice*>& liveDevices =
pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDevicesList();

std::cout << std::endl << "Network interfaces:" << std::endl;
for (const auto& device : liveDevices)
for (const auto& device : pcpp::PcapLiveDeviceList::getInstance())
{
std::cout << " -> Name: '" << device->getName() << "' IP address: " << device->getIPv4Address().toString()
<< std::endl;
Expand Down Expand Up @@ -569,8 +566,7 @@ int main(int argc, char* argv[])
}
else // analyze in live traffic mode
{
pcpp::PcapLiveDevice* dev =
pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDeviceByIpOrName(interfaceNameOrIP);
pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getDeviceByIpOrName(interfaceNameOrIP);
if (dev == nullptr)
EXIT_WITH_ERROR("Couldn't find interface by provided IP address or name");

Expand Down
5 changes: 2 additions & 3 deletions Examples/IcmpFileTransfer/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ void printAppVersion()
*/
void listInterfaces()
{
const std::vector<pcpp::PcapLiveDevice*>& devList =
pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDevicesList();
const auto& devList = pcpp::PcapLiveDeviceList::getInstance();

std::cout << std::endl << "Network interfaces:" << std::endl;
for (const auto& dev : devList)
Expand Down Expand Up @@ -174,7 +173,7 @@ void readCommandLineArguments(int argc, char* argv[], const std::string& thisSid
}
catch (const std::exception&)
{
pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDeviceByName(interfaceNameOrIP);
pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getDeviceByName(interfaceNameOrIP);
if (dev == nullptr)
EXIT_WITH_ERROR_PRINT_USAGE("Cannot find interface by provided name");

Expand Down
4 changes: 2 additions & 2 deletions Examples/IcmpFileTransfer/IcmpFileTransfer-catcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static bool getFileContent(pcpp::RawPacket* rawPacket, pcpp::PcapLiveDevice* dev
void receiveFile(pcpp::IPv4Address pitcherIP, pcpp::IPv4Address catcherIP)
{
// identify the interface to listen and send packets to
pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDeviceByIp(catcherIP);
pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getDeviceByIp(catcherIP);
if (dev == nullptr)
EXIT_WITH_ERROR("Cannot find network interface with IP '" << catcherIP << "'");

Expand Down Expand Up @@ -416,7 +416,7 @@ static bool sendContent(pcpp::RawPacket* rawPacket, pcpp::PcapLiveDevice* dev, v
void sendFile(const std::string& filePath, pcpp::IPv4Address pitcherIP, pcpp::IPv4Address catcherIP, size_t blockSize)
{
// identify the interface to listen and send packets to
pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDeviceByIp(catcherIP);
pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getDeviceByIp(catcherIP);
if (dev == nullptr)
EXIT_WITH_ERROR("Cannot find network interface with IP '" << catcherIP << "'");

Expand Down
4 changes: 2 additions & 2 deletions Examples/IcmpFileTransfer/IcmpFileTransfer-pitcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ static void getFileContent(pcpp::RawPacket* rawPacket, pcpp::PcapLiveDevice* dev
void receiveFile(pcpp::IPv4Address pitcherIP, pcpp::IPv4Address catcherIP, int packetPerSec)
{
// identify the interface to listen and send packets to
pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDeviceByIp(pitcherIP);
pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getDeviceByIp(pitcherIP);
if (dev == nullptr)
EXIT_WITH_ERROR("Cannot find network interface with IP '" << pitcherIP << "'");

Expand Down Expand Up @@ -404,7 +404,7 @@ void sendFile(const std::string& filePath, pcpp::IPv4Address pitcherIP, pcpp::IP
int packetPerSec)
{
// identify the interface to listen and send packets to
pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDeviceByIp(pitcherIP);
pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getDeviceByIp(pitcherIP);
if (dev == nullptr)
EXIT_WITH_ERROR("Cannot find network interface with IP '" << pitcherIP << "'");

Expand Down
6 changes: 3 additions & 3 deletions Examples/PfRingExample-FilterTraffic/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void listPfRingDevices()
// suppress errors as there may be devices (like lo) that their MAC address can't be read, etc.
pcpp::Logger::getInstance().suppressLogs();

const std::vector<pcpp::PfRingDevice*>& devList = pcpp::PfRingDeviceList::getInstance().getPfRingDevicesList();
const auto& devList = pcpp::PfRingDeviceList::getInstance();
for (const auto& dev : devList)
{
std::ostringstream interfaceIndex;
Expand Down Expand Up @@ -277,15 +277,15 @@ int main(int argc, char* argv[])
case 'n':
{
std::string ifaceName = std::string(optarg);
dev = pcpp::PfRingDeviceList::getInstance().getPfRingDeviceByName(ifaceName);
dev = pcpp::PfRingDeviceList::getInstance().getDeviceByName(ifaceName);
if (dev == nullptr)
EXIT_WITH_ERROR("Could not find PF_RING device '" << ifaceName << "'");
break;
}
case 's':
{
std::string sendPacketsToIfaceName = std::string(optarg);
sendPacketsToIface = pcpp::PfRingDeviceList::getInstance().getPfRingDeviceByName(sendPacketsToIfaceName);
sendPacketsToIface = pcpp::PfRingDeviceList::getInstance().getDeviceByName(sendPacketsToIfaceName);
if (sendPacketsToIface == nullptr)
EXIT_WITH_ERROR("Could not find PF_RING device '" << sendPacketsToIfaceName << "'");

Expand Down
6 changes: 2 additions & 4 deletions Examples/SSLAnalyzer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ void printAppVersion()
*/
void listInterfaces()
{
const std::vector<pcpp::PcapLiveDevice*>& devList =
pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDevicesList();
const auto& devList = pcpp::PcapLiveDeviceList::getInstance();

std::cout << std::endl << "Network interfaces:" << std::endl;
for (const auto& dev : devList)
Expand Down Expand Up @@ -531,8 +530,7 @@ int main(int argc, char* argv[])
else // analyze in live traffic mode
{
// extract pcap live device by interface name or IP address
pcpp::PcapLiveDevice* dev =
pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDeviceByIpOrName(interfaceNameOrIP);
pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getDeviceByIpOrName(interfaceNameOrIP);
if (dev == nullptr)
EXIT_WITH_ERROR("Couldn't find interface by provided IP address or name");

Expand Down
5 changes: 2 additions & 3 deletions Examples/TLSFingerprinting/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ void printAppVersion()
*/
void listInterfaces()
{
const std::vector<pcpp::PcapLiveDevice*>& devList =
pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDevicesList();
const auto& devList = pcpp::PcapLiveDeviceList::getInstance();

std::cout << std::endl << "Network interfaces:" << std::endl;
for (const auto& dev : devList)
Expand Down Expand Up @@ -462,7 +461,7 @@ void doTlsFingerprintingOnLiveTraffic(const std::string& interfaceNameOrIP, std:
const std::string& separator, bool chFP, bool shFP, const std::string& bpfFilter)
{
// extract pcap live device by interface name or IP address
pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDeviceByIpOrName(interfaceNameOrIP);
pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getDeviceByIpOrName(interfaceNameOrIP);
if (dev == nullptr)
EXIT_WITH_ERROR("Couldn't find interface by given IP address or name");

Expand Down
7 changes: 2 additions & 5 deletions Examples/TcpReassembly/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,9 @@ void printAppVersion()
*/
void listInterfaces()
{
auto const& devList = pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDevicesList();

std::cout << std::endl << "Network interfaces:" << std::endl;

for (auto dev : devList)
for (auto dev : pcpp::PcapLiveDeviceList::getInstance())
{
std::cout << " -> Name: '" << dev->getName() << "' IP address: " << dev->getIPv4Address().toString()
<< std::endl;
Expand Down Expand Up @@ -689,8 +687,7 @@ int main(int argc, char* argv[])
else // analyze in live traffic mode
{
// extract pcap live device by interface name or IP address
pcpp::PcapLiveDevice* dev =
pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDeviceByIpOrName(interfaceNameOrIP);
pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getDeviceByIpOrName(interfaceNameOrIP);
if (dev == nullptr)
EXIT_WITH_ERROR("Couldn't find interface by provided IP address or name");

Expand Down
2 changes: 1 addition & 1 deletion Examples/XdpExample-FilterTraffic/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ void printAppVersion()
void listInterfaces()
{
std::cout << std::endl << "Network interfaces:" << std::endl;
for (const auto& device : pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDevicesList())
for (const auto& device : pcpp::PcapLiveDeviceList::getInstance())
{
if (device->getIPv4Address() != pcpp::IPv4Address::Zero)
{
Expand Down
1 change: 1 addition & 0 deletions Pcap++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ add_library(

set(public_headers
header/Device.h
header/DeviceListBase.h
header/NetworkUtils.h
header/PcapDevice.h
header/PcapFileDevice.h
Expand Down
Loading
Loading