Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into fix/issue-1664
Browse files Browse the repository at this point in the history
# Conflicts:
#	Pcap++/header/PfRingDevice.h
#	Pcap++/src/PfRingDevice.cpp
  • Loading branch information
Dimi1010 committed Jan 10, 2025
2 parents 379feac + 78b629f commit f22a741
Show file tree
Hide file tree
Showing 39 changed files with 2,818 additions and 3,964 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
apk update && apk add cppcheck python3-dev
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install pre-commit setuptools clang-format==18.1.6 clang-tidy==18.1.8
python3 -m pip install pre-commit setuptools clang-format==19.1.6 clang-tidy==18.1.8
- name: Run pre-commit
run: |
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Every code contribution to this project is highly valued and appreciated. I enco
- For Windows (using `choco`) `choco install cppcheck --version=2.7`
- For Windows (MSI install): https://github.com/danmar/cppcheck/releases/download/2.7/cppcheck-2.7-x64-Setup.msi
- Build from source: https://github.com/danmar/cppcheck/releases/tag/2.7
- `clang-format`: `pip install clang-format==18.1.6`
- `clang-format`: `pip install clang-format==19.1.6`
- After you commit the code and push it to GitHub, before creating the pull request please make sure that:
- You merge all new code from **dev** to your fork
- CI passes on all platforms
Expand Down
26 changes: 4 additions & 22 deletions Common++/header/IpAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -707,18 +707,9 @@ namespace pcpp
/// @return A reference to the assignee
IPNetwork& operator=(const IPv4Network& other)
{
if (m_IPv4Network)
{
m_IPv4Network = nullptr;
}

if (m_IPv6Network)
{
m_IPv6Network = nullptr;
}

// Create the new instance first to maintain strong exception guarantee.
m_IPv4Network = std::unique_ptr<IPv4Network>(new IPv4Network(other));

m_IPv6Network = nullptr;
return *this;
}

Expand All @@ -727,18 +718,9 @@ namespace pcpp
/// @return A reference to the assignee
IPNetwork& operator=(const IPv6Network& other)
{
if (m_IPv4Network)
{
m_IPv4Network = nullptr;
}

if (m_IPv6Network)
{
m_IPv6Network = nullptr;
}

// Create the new instance first to maintain strong exception guarantee.
m_IPv6Network = std::unique_ptr<IPv6Network>(new IPv6Network(other));

m_IPv4Network = nullptr;
return *this;
}

Expand Down
3 changes: 1 addition & 2 deletions Packet++/src/DnsResourceData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ namespace pcpp
{
if (m_DataLen == 0 || m_Data == nullptr)
{
PCPP_LOG_ERROR("Input data is null or illegal"
<< "|m_DataLen:" << m_DataLen);
PCPP_LOG_ERROR("Input data is null or illegal" << "|m_DataLen:" << m_DataLen);
return false;
}

Expand Down
3 changes: 1 addition & 2 deletions Packet++/src/VrrpLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,7 @@ namespace pcpp
auto* ipLayer = m_Packet->getLayerOfType<pcpp::IPLayer>();
if (ipLayer == nullptr)
{
PCPP_LOG_ERROR("Calculate checksum failed, for can not get IPLayer"
<< "");
PCPP_LOG_ERROR("Calculate checksum failed, for can not get IPLayer" << "");
return 0;
}

Expand Down
74 changes: 27 additions & 47 deletions Pcap++/header/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,16 @@
#include "RawPacket.h"
#include "PcapFilter.h"

/**
* \namespace pcpp
* \brief The main namespace for the PcapPlusPlus lib
*/
/// @namespace pcpp
/// @brief The main namespace for the PcapPlusPlus lib
namespace pcpp
{
/** A vector of pointers to RawPacket */
/// A vector of pointers to RawPacket
typedef PointerVector<RawPacket> RawPacketVector;

/**
* @class IDevice
* An abstract interface representing all packet processing devices. It stands as the root class for all devices.
* This is an abstract class that cannot be instantiated
*/
/// @class IDevice
/// An abstract interface representing all packet processing devices. It stands as the root class for all devices.
/// This is an abstract class that cannot be instantiated
class IDevice
{
protected:
Expand All @@ -33,69 +29,53 @@ namespace pcpp
virtual ~IDevice()
{}

/**
* Open the device
* @return True if device was opened successfully, false otherwise
*/
/// Open the device
/// @return True if device was opened successfully, false otherwise
virtual bool open() = 0;

/**
* Close the device
*/
/// Close the device
virtual void close() = 0;

/**
* @return True if the file is opened, false otherwise
*/
/// @return True if the file is opened, false otherwise
inline bool isOpened()
{
return m_DeviceOpened;
}
};

/**
* @class IFilterableDevice
* An abstract interface representing all devices that have BPF (Berkeley Packet Filter) filtering capabilities,
* meaning devices that can filter packets based on the BPF filtering syntax.
* This is an abstract class that cannot be instantiated
*/
/// @class IFilterableDevice
/// An abstract interface representing all devices that have BPF (Berkeley Packet Filter) filtering capabilities,
/// meaning devices that can filter packets based on the BPF filtering syntax.
/// This is an abstract class that cannot be instantiated
class IFilterableDevice
{
protected:
// c'tor should not be public
IFilterableDevice()
{}
IFilterableDevice() = default;

public:
virtual ~IFilterableDevice()
{}
virtual ~IFilterableDevice() = default;

/**
* Set a filter for the device. When implemented by the device, only packets that match the filter will be
* received
* @param[in] filter The filter to be set in PcapPlusPlus' GeneralFilter format
* @return True if filter set successfully, false otherwise
*/
/// Set a filter for the device. When implemented by the device, only packets that match the filter will be
/// received
/// @param[in] filter The filter to be set in PcapPlusPlus' GeneralFilter format
/// @return True if filter set successfully, false otherwise
virtual bool setFilter(GeneralFilter& filter)
{
std::string filterAsString;
filter.parseToString(filterAsString);
return setFilter(filterAsString);
}

/**
* Set a filter for the device. When implemented by the device, only packets that match the filter will be
* received
* @param[in] filterAsString The filter to be set in Berkeley Packet Filter (BPF) syntax
* (http://biot.com/capstats/bpf.html)
* @return True if filter set successfully, false otherwise
*/
/// Set a filter for the device. When implemented by the device, only packets that match the filter will be
/// received
/// @param[in] filterAsString The filter to be set in Berkeley Packet Filter (BPF) syntax
/// (http://biot.com/capstats/bpf.html)
/// @return True if filter set successfully, false otherwise
virtual bool setFilter(std::string filterAsString) = 0;

/**
* Clear the filter currently set on the device
* @return True if filter was removed successfully or if no filter was set, false otherwise
*/
/// Clear the filter currently set on the device
/// @return True if filter was removed successfully or if no filter was set, false otherwise
virtual bool clearFilter() = 0;
};
} // namespace pcpp
10 changes: 5 additions & 5 deletions Pcap++/header/DeviceUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
#include "IpAddress.h"
#include "PcapUtils.h"

/// @namespace pcpp
/// @brief The main namespace for the PcapPlusPlus lib
namespace pcpp
{
/// @cond PCPP_INTERNAL

namespace internal
{
/**
* Fetches a list of all network devices on the local machine that LibPcap/WinPcap/NPcap can find.
* @return A smart pointer to an interface list structure.
* @throws std::runtime_error The system encountered an error fetching the devices.
*/
/// Fetches a list of all network devices on the local machine that LibPcap/WinPcap/NPcap can find.
/// @return A smart pointer to an interface list structure.
/// @throws std::runtime_error The system encountered an error fetching the devices.
std::unique_ptr<pcap_if_t, PcapFreeAllDevsDeleter> getAllLocalPcapDevices();
} // namespace internal

Expand Down
Loading

0 comments on commit f22a741

Please sign in to comment.