Skip to content

Force pcapplusplus prefix in include #1586

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

Open
wants to merge 23 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
05913c7
cmake: force use of pcapplusplus/ prefix
clementperon Sep 19, 2024
fcac384
Remove ifdef inside cpp
clementperon Sep 21, 2024
4ac39c0
Fix fuzzer
clementperon Oct 5, 2024
2e64846
Fix tutorials
clementperon Oct 6, 2024
71c2d48
Fix toyvpn include path
clementperon Oct 6, 2024
e571893
More fixes
clementperon Oct 6, 2024
11a2699
Pkconfig don't add pcapplusplus prefix
clementperon Oct 6, 2024
9ccfe50
explicit for CPPcheck
clementperon Oct 6, 2024
3c436df
Revert "explicit for CPPcheck"
clementperon Oct 6, 2024
403eab8
fix gettimeofday
clementperon Oct 6, 2024
c99ded9
Update cppCheckSuppressions path
clementperon Oct 7, 2024
9d7bfd1
fix getopt include order
clementperon Oct 7, 2024
2349990
Merged remote-tracking branch 'upstream/dev' into 'pcapplusplus_inc'
Dimi1010 Apr 18, 2025
dfb204e
Added automatic generation of redirection headers for all public head…
Dimi1010 Apr 18, 2025
9a7fcb6
Added missing template.
Dimi1010 Apr 18, 2025
0049ac6
Replaced generated transition headers with an additional $<INSTALL_IN…
Dimi1010 Apr 18, 2025
b387944
Added option to selectively enable old include behavior.
Dimi1010 Apr 19, 2025
ac8e3cd
Merge remote-tracking branch 'upstream/dev' into pcapplusplus_inc
Dimi1010 Apr 19, 2025
58a9b2f
Fixed conditional generator expressions.
Dimi1010 Apr 19, 2025
68d773f
Merge remote-tracking branch 'upstream/dev' into pcapplusplus_inc
Dimi1010 Apr 26, 2025
2d35fe0
Added config variable to Config template.
Dimi1010 Apr 26, 2025
f7cd28c
Deprecateion message text improvement.
Dimi1010 Apr 26, 2025
2278cfc
Defined `PCAPP_ENABLE_OLD_STYLE_INCLUDE` as target properties to pcpp…
Dimi1010 Apr 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 3 additions & 5 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,11 @@ jobs:
run: |
TOYVPN_PCAPPLUSPLUS="./ToyVpn-PcapPlusPlus/app/libs/pcapplusplus"
PCAPPLUSPLUS_LIBS_PATH="$TOYVPN_PCAPPLUSPLUS/${{ matrix.target }}/${{ matrix.api-version }}"
PCAPPLUSPLUS_INCLUDE_PATH="$TOYVPN_PCAPPLUSPLUS/include"
cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR"
cmake --build "$BUILD_DIR" -j
cmake --install "$BUILD_DIR" --prefix ${TOYVPN_PCAPPLUSPLUS}
mkdir -p ${PCAPPLUSPLUS_LIBS_PATH} ${PCAPPLUSPLUS_INCLUDE_PATH}
mv ${TOYVPN_PCAPPLUSPLUS}/lib/*.a ${PCAPPLUSPLUS_LIBS_PATH}/
mv ${TOYVPN_PCAPPLUSPLUS}/include/pcapplusplus/*.h ${PCAPPLUSPLUS_INCLUDE_PATH}/
cmake --install "$BUILD_DIR" --prefix "${TOYVPN_PCAPPLUSPLUS}"
mkdir -p "${PCAPPLUSPLUS_LIBS_PATH}"
mv ${TOYVPN_PCAPPLUSPLUS}/lib/*.a "${PCAPPLUSPLUS_LIBS_PATH}/"

- name: Set up JDK
uses: actions/setup-java@v4
Expand Down
2 changes: 2 additions & 0 deletions 3rdParty/Getopt-for-Visual-Studio/getopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
/* Enforce Windows.h to use winsock2 */
#include <winsock2.h>
#include <windows.h>

#ifdef __cplusplus
Expand Down
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ option(PCAPPP_BUILD_COVERAGE "Generate Coverage Report" OFF)
option(PCAPPP_BUILD_FUZZERS "Build Fuzzers binaries" OFF)
option(PCAPPP_BUILD_REPRODUCIBLE "Build a reproducible version" OFF)

option(
PCAPPP_ENABLE_OLD_STYLE_INCLUDE
"Enables old style include paths that directly add pcapplusplus folder as an include root."
ON
)
if(PCAPPP_ENABLE_OLD_STYLE_INCLUDE)
message(
DEPRECATION
"PcapPlusPlus: Old style include directories are enabled, directly adding the <pcapplusplus> folder to the include directories."
"This functionality is deprecated and will be removed in the future."
"New include format should follow: \"#include <pcapplusplus/xxx.h>\" "
"This behaviour can be disabled by setting \"PCAPPP_ENABLE_OLD_STYLE_INCLUDE\" to OFF"
)
endif()

option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)

option(PCAPPP_USE_DPDK "Setup PcapPlusPlus with DPDK. In this case you must also set DPDK_ROOT")
Expand Down
37 changes: 21 additions & 16 deletions Common++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,36 @@ add_library(

set(
public_headers
header/DeprecationUtils.h
header/GeneralUtils.h
header/IpAddress.h
header/IpAddressUtils.h
header/IpUtils.h
header/Logger.h
header/LRUList.h
header/MacAddress.h
header/ObjectPool.h
header/OUILookup.h
header/PcapPlusPlusVersion.h
header/PointerVector.h
header/SystemUtils.h
header/TablePrinter.h
header/TimespecTimeval.h
header/pcapplusplus/DeprecationUtils.h
header/pcapplusplus/GeneralUtils.h
header/pcapplusplus/IpAddress.h
header/pcapplusplus/IpAddressUtils.h
header/pcapplusplus/IpUtils.h
header/pcapplusplus/Logger.h
header/pcapplusplus/LRUList.h
header/pcapplusplus/MacAddress.h
header/pcapplusplus/ObjectPool.h
header/pcapplusplus/OUILookup.h
header/pcapplusplus/PcapPlusPlusVersion.h
header/pcapplusplus/PointerVector.h
header/pcapplusplus/SystemUtils.h
header/pcapplusplus/TablePrinter.h
header/pcapplusplus/TimespecTimeval.h
)

# Set the public header that will be installed
set_property(TARGET Common++ PROPERTY PUBLIC_HEADER ${public_headers})

set_target_properties(Common++ PROPERTIES PCAPPP_ENABLE_OLD_STYLE_INCLUDE "${PCAPPP_ENABLE_OLD_STYLE_INCLUDE}")

target_compile_features(Common++ PUBLIC cxx_std_11)

target_include_directories(
Common++
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/header> $<INSTALL_INTERFACE:include/pcapplusplus>
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/header>
$<INSTALL_INTERFACE:include>
$<$<BOOL:$<TARGET_PROPERTY:Common++,PCAPPP_ENABLE_OLD_STYLE_INCLUDE>>:$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/header/pcapplusplus>$<INSTALL_INTERFACE:include/pcapplusplus>>
# Don't link with EndianPortable and json as it won't be exported
PRIVATE $<TARGET_PROPERTY:EndianPortable,INTERFACE_INCLUDE_DIRECTORIES>
PRIVATE $<TARGET_PROPERTY:json,INTERFACE_INCLUDE_DIRECTORIES>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions Common++/src/GeneralUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define LOG_MODULE CommonLogModuleGenericUtils

#include "GeneralUtils.h"
#include "Logger.h"
#include "pcapplusplus/GeneralUtils.h"
#include "pcapplusplus/Logger.h"
#include <sstream>
#include <iomanip>
#include <cstring>
Expand Down
6 changes: 3 additions & 3 deletions Common++/src/IpAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <sstream>
#include <stdexcept>
#include <bitset>
#include "Logger.h"
#include "IpUtils.h"
#include "IpAddress.h"
#include "pcapplusplus/Logger.h"
#include "pcapplusplus/IpUtils.h"
#include "pcapplusplus/IpAddress.h"
#include "EndianPortable.h"

// for AF_INET, AF_INET6
Expand Down
6 changes: 3 additions & 3 deletions Common++/src/IpAddressUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "IpAddressUtils.h"
#include "pcapplusplus/IpAddressUtils.h"

#include "IpAddress.h"
#include "IpUtils.h" // Just needing in_addr and in6_addr.
#include "pcapplusplus/IpAddress.h"
#include "pcapplusplus/IpUtils.h" // Just needing in_addr and in6_addr.

namespace pcpp
{
Expand Down
4 changes: 2 additions & 2 deletions Common++/src/IpUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define LOG_MODULE CommonLogModuleIpUtils

#include "IpUtils.h"
#include "Logger.h"
#include "pcapplusplus/IpUtils.h"
#include "pcapplusplus/Logger.h"
#include <cstring>
#include <stdexcept>
#ifndef NS_INADDRSZ
Expand Down
2 changes: 1 addition & 1 deletion Common++/src/Logger.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Logger.h"
#include "pcapplusplus/Logger.h"

#include <iostream>
#include <iomanip>
Expand Down
2 changes: 1 addition & 1 deletion Common++/src/MacAddress.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "MacAddress.h"
#include "pcapplusplus/MacAddress.h"

namespace pcpp
{
Expand Down
6 changes: 3 additions & 3 deletions Common++/src/OUILookup.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "OUILookup.h"
#include "Logger.h"
#include "pcapplusplus/OUILookup.h"
#include "pcapplusplus/Logger.h"

#include "json.hpp"
#include <json.hpp>

#include <fstream>

Expand Down
2 changes: 1 addition & 1 deletion Common++/src/PcapPlusPlusVersion.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "PcapPlusPlusVersion.h"
#include "pcapplusplus/PcapPlusPlusVersion.h"

namespace pcpp
{
Expand Down
2 changes: 1 addition & 1 deletion Common++/src/SystemUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "SystemUtils.h"
#include "pcapplusplus/SystemUtils.h"
#include "EndianPortable.h"

#ifndef _MSC_VER
Expand Down
4 changes: 2 additions & 2 deletions Common++/src/TablePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <iostream>
#include <numeric>
#include <utility>
#include "TablePrinter.h"
#include "Logger.h"
#include "pcapplusplus/TablePrinter.h"
#include "pcapplusplus/Logger.h"

namespace pcpp
{
Expand Down
19 changes: 10 additions & 9 deletions Examples/ArpSpoofing/main.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#include <iostream>
#include <fstream>
#include "MacAddress.h"
#include "IpAddress.h"
#include "PcapPlusPlusVersion.h"
#include "SystemUtils.h"
#include "PcapLiveDeviceList.h"
#include "PcapLiveDevice.h"
#include "Packet.h"
#include "EthLayer.h"
#include "ArpLayer.h"

#include "pcapplusplus/MacAddress.h"
#include "pcapplusplus/IpAddress.h"
#include "pcapplusplus/PcapPlusPlusVersion.h"
#include "pcapplusplus/SystemUtils.h"
#include "pcapplusplus/PcapLiveDeviceList.h"
#include "pcapplusplus/PcapLiveDevice.h"
#include "pcapplusplus/Packet.h"
#include "pcapplusplus/EthLayer.h"
#include "pcapplusplus/ArpLayer.h"
#include <getopt.h>

#define EXIT_WITH_ERROR(reason) \
Expand Down
16 changes: 8 additions & 8 deletions Examples/Arping/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
*/

#include <iostream>
#include <MacAddress.h>
#include <IpAddress.h>
#include <Logger.h>
#include <PcapPlusPlusVersion.h>
#include <PcapLiveDeviceList.h>
#include <PcapLiveDevice.h>
#include <NetworkUtils.h>
#include <getopt.h>
#include <SystemUtils.h>
#include "pcapplusplus/MacAddress.h"
#include "pcapplusplus/IpAddress.h"
#include "pcapplusplus/Logger.h"
#include "pcapplusplus/PcapPlusPlusVersion.h"
#include "pcapplusplus/PcapLiveDeviceList.h"
#include "pcapplusplus/PcapLiveDevice.h"
#include "pcapplusplus/NetworkUtils.h"
#include "pcapplusplus/SystemUtils.h"

#define EXIT_WITH_ERROR(reason) \
do \
Expand Down
12 changes: 6 additions & 6 deletions Examples/DNSResolver/main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <iostream>
#include "PcapPlusPlusVersion.h"
#include "PcapLiveDevice.h"
#include "PcapLiveDeviceList.h"
#include "NetworkUtils.h"
#include "SystemUtils.h"
#include "Logger.h"
#include "pcapplusplus/PcapPlusPlusVersion.h"
#include "pcapplusplus/PcapLiveDevice.h"
#include "pcapplusplus/PcapLiveDeviceList.h"
#include "pcapplusplus/NetworkUtils.h"
#include "pcapplusplus/SystemUtils.h"
#include "pcapplusplus/Logger.h"
#include <getopt.h>

#define EXIT_WITH_ERROR(reason) \
Expand Down
30 changes: 15 additions & 15 deletions Examples/DnsSpoofing/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
#if !defined(_WIN32)
# include <errno.h>
#endif
#include "IpAddress.h"
#include "RawPacket.h"
#include "ProtocolType.h"
#include "Packet.h"
#include "EthLayer.h"
#include "IPv4Layer.h"
#include "IPv6Layer.h"
#include "UdpLayer.h"
#include "DnsLayer.h"
#include "PcapFilter.h"
#include "PcapLiveDevice.h"
#include "PcapLiveDeviceList.h"
#include "TablePrinter.h"
#include "SystemUtils.h"
#include "PcapPlusPlusVersion.h"
#include "pcapplusplus/IpAddress.h"
#include "pcapplusplus/RawPacket.h"
#include "pcapplusplus/ProtocolType.h"
#include "pcapplusplus/Packet.h"
#include "pcapplusplus/EthLayer.h"
#include "pcapplusplus/IPv4Layer.h"
#include "pcapplusplus/IPv6Layer.h"
#include "pcapplusplus/UdpLayer.h"
#include "pcapplusplus/DnsLayer.h"
#include "pcapplusplus/PcapFilter.h"
#include "pcapplusplus/PcapLiveDevice.h"
#include "pcapplusplus/PcapLiveDeviceList.h"
#include "pcapplusplus/TablePrinter.h"
#include "pcapplusplus/SystemUtils.h"
#include "pcapplusplus/PcapPlusPlusVersion.h"
#include <getopt.h>

#define EXIT_WITH_ERROR(reason) \
Expand Down
8 changes: 4 additions & 4 deletions Examples/DpdkBridge/AppWorkerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#include "Common.h"

#include "PacketUtils.h"
#include "DpdkDevice.h"
#include "DpdkDeviceList.h"
#include "PcapFileDevice.h"
#include "pcapplusplus/PacketUtils.h"
#include "pcapplusplus/DpdkDevice.h"
#include "pcapplusplus/DpdkDeviceList.h"
#include "pcapplusplus/PcapFileDevice.h"

/**
* The worker thread class which does all the work. It's initialized with pointers to the RX and TX devices, then it
Expand Down
7 changes: 3 additions & 4 deletions Examples/DpdkBridge/Common.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#pragma once

#include "Packet.h"
#include "DpdkDevice.h"

#include <SystemUtils.h>
#include "pcapplusplus/Packet.h"
#include "pcapplusplus/DpdkDevice.h"
#include "pcapplusplus/SystemUtils.h"

#include <string>
#include <unordered_map>
Expand Down
8 changes: 4 additions & 4 deletions Examples/DpdkBridge/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#include "Common.h"
#include "AppWorkerThread.h"

#include "DpdkDeviceList.h"
#include "SystemUtils.h"
#include "PcapPlusPlusVersion.h"
#include "TablePrinter.h"
#include "pcapplusplus/DpdkDeviceList.h"
#include "pcapplusplus/SystemUtils.h"
#include "pcapplusplus/PcapPlusPlusVersion.h"
#include "pcapplusplus/TablePrinter.h"

#include <vector>
#include <iostream>
Expand Down
8 changes: 4 additions & 4 deletions Examples/DpdkExample-FilterTraffic/AppWorkerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include "Common.h"
#include "PacketMatchingEngine.h"

#include "PacketUtils.h"
#include "DpdkDevice.h"
#include "DpdkDeviceList.h"
#include "PcapFileDevice.h"
#include "pcapplusplus/PacketUtils.h"
#include "pcapplusplus/DpdkDevice.h"
#include "pcapplusplus/DpdkDeviceList.h"
#include "pcapplusplus/PcapFileDevice.h"

/**
* The worker thread class which does all the work: receive packets from relevant DPDK port(s), matched them with the
Expand Down
7 changes: 3 additions & 4 deletions Examples/DpdkExample-FilterTraffic/Common.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#pragma once

#include "Packet.h"
#include "DpdkDevice.h"

#include <SystemUtils.h>
#include "pcapplusplus/Packet.h"
#include "pcapplusplus/DpdkDevice.h"
#include "pcapplusplus/SystemUtils.h"

#include <string>
#include <unordered_map>
Expand Down
10 changes: 5 additions & 5 deletions Examples/DpdkExample-FilterTraffic/PacketMatchingEngine.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include "Packet.h"
#include "IPv4Layer.h"
#include "TcpLayer.h"
#include "UdpLayer.h"
#include "SystemUtils.h"
#include "pcapplusplus/Packet.h"
#include "pcapplusplus/IPv4Layer.h"
#include "pcapplusplus/TcpLayer.h"
#include "pcapplusplus/UdpLayer.h"
#include "pcapplusplus/SystemUtils.h"

/**
* Responsible for matching packets by match criteria received from the user. Current match criteria are a combination
Expand Down
12 changes: 6 additions & 6 deletions Examples/DpdkExample-FilterTraffic/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
#include "PacketMatchingEngine.h"
#include "AppWorkerThread.h"

#include "DpdkDeviceList.h"
#include "TcpLayer.h"
#include "UdpLayer.h"
#include "SystemUtils.h"
#include "PcapPlusPlusVersion.h"
#include "TablePrinter.h"
#include "pcapplusplus/DpdkDeviceList.h"
#include "pcapplusplus/TcpLayer.h"
#include "pcapplusplus/UdpLayer.h"
#include "pcapplusplus/SystemUtils.h"
#include "pcapplusplus/PcapPlusPlusVersion.h"
#include "pcapplusplus/TablePrinter.h"

#include <vector>
#include <iostream>
Expand Down
Loading
Loading