Skip to content

Commit 55093ea

Browse files
authored
chore: upgrade pcapplusplus from 23.09 to 24.09 (#763)
1 parent c7c422a commit 55093ea

25 files changed

Lines changed: 279 additions & 280 deletions

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ if(WIN32)
6262
endif()
6363

6464
find_package(Corrade REQUIRED)
65+
66+
# After the first find_package() triggers conan install, load conan_toolchain.cmake to set
67+
# CMAKE_PROGRAM_PATH so that tool_requires (e.g. protoc) are preferred over system versions.
68+
# include_guard() in conan_toolchain.cmake makes this safe when -DCMAKE_TOOLCHAIN_FILE is also used.
69+
get_property(_conan_generators GLOBAL PROPERTY CONAN_GENERATORS_FOLDER)
70+
if(_conan_generators AND EXISTS "${_conan_generators}/conan_toolchain.cmake")
71+
include("${_conan_generators}/conan_toolchain.cmake")
72+
unset(PROTOC_PROGRAM CACHE)
73+
endif()
74+
unset(_conan_generators)
75+
6576
include(sanitizer)
6677
if(CODE_COVERAGE)
6778
include(CodeCoverage)

cmake/conan_provider.cmake

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,14 @@ function(detect_arch arch)
135135
endfunction()
136136

137137

138-
function(detect_cxx_standard cxx_standard)
138+
function(detect_cxx_standard compiler cxx_standard)
139139
set(${cxx_standard} ${CMAKE_CXX_STANDARD} PARENT_SCOPE)
140140
if(CMAKE_CXX_EXTENSIONS)
141-
set(${cxx_standard} "gnu${CMAKE_CXX_STANDARD}" PARENT_SCOPE)
141+
if(compiler STREQUAL "msvc")
142+
set(${cxx_standard} "${CMAKE_CXX_STANDARD}" PARENT_SCOPE)
143+
else()
144+
set(${cxx_standard} "gnu${CMAKE_CXX_STANDARD}" PARENT_SCOPE)
145+
endif()
142146
endif()
143147
endfunction()
144148

@@ -356,8 +360,10 @@ macro(append_compiler_executables_configuration)
356360
# Not necessary to warn if RC not defined
357361
endif()
358362
if(NOT "x${_conan_compilers_list}" STREQUAL "x")
359-
string(REPLACE ";" "," _conan_compilers_list "${_conan_compilers_list}")
360-
string(APPEND profile "tools.build:compiler_executables={${_conan_compilers_list}}\n")
363+
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
364+
string(REPLACE ";" "," _conan_compilers_list "${_conan_compilers_list}")
365+
string(APPEND profile "tools.build:compiler_executables={${_conan_compilers_list}}\n")
366+
endif()
361367
endif()
362368
unset(_conan_c_compiler)
363369
unset(_conan_cpp_compiler)
@@ -370,7 +376,7 @@ function(detect_host_profile output_file)
370376
detect_os(os os_api_level os_sdk os_subsystem os_version)
371377
detect_arch(arch)
372378
detect_compiler(compiler compiler_version compiler_runtime compiler_runtime_type)
373-
detect_cxx_standard(compiler_cppstd)
379+
detect_cxx_standard(${compiler} compiler_cppstd)
374380
detect_lib_cxx(compiler_libcxx)
375381
detect_build_type(build_type)
376382

@@ -461,10 +467,9 @@ endfunction()
461467

462468

463469
function(conan_install)
464-
cmake_parse_arguments(ARGS conan_args ${ARGN})
465470
set(conan_output_folder ${CMAKE_BINARY_DIR}/conan)
466471
# Invoke "conan install" with the provided arguments
467-
set(conan_args ${conan_args} -of=${conan_output_folder})
472+
set(conan_args -of=${conan_output_folder})
468473
message(STATUS "CMake-Conan: conan install ${CMAKE_SOURCE_DIR} ${conan_args} ${ARGN}")
469474

470475

@@ -567,7 +572,7 @@ macro(conan_provide_dependency method package_name)
567572
get_property(_conan_install_success GLOBAL PROPERTY CONAN_INSTALL_SUCCESS)
568573
if(NOT _conan_install_success)
569574
find_program(CONAN_COMMAND "conan" REQUIRED)
570-
conan_get_version(${CONAN_COMMAND} CONAN_CURRENT_VERSION)
575+
conan_get_version("${CONAN_COMMAND}" CONAN_CURRENT_VERSION)
571576
conan_version_check(MINIMUM ${CONAN_MINIMUM_VERSION} CURRENT ${CONAN_CURRENT_VERSION})
572577
message(STATUS "CMake-Conan: first find_package() found. Installing dependencies with Conan")
573578
if("default" IN_LIST CONAN_HOST_PROFILE OR "default" IN_LIST CONAN_BUILD_PROFILE)
@@ -580,30 +585,59 @@ macro(conan_provide_dependency method package_name)
580585
construct_profile_argument(_build_profile_flags CONAN_BUILD_PROFILE)
581586
if(EXISTS "${CMAKE_SOURCE_DIR}/conanfile.py")
582587
file(READ "${CMAKE_SOURCE_DIR}/conanfile.py" outfile)
583-
if(NOT "${outfile}" MATCHES ".*CMakeDeps.*")
584-
message(WARNING "Cmake-conan: CMakeDeps generator was not defined in the conanfile")
588+
if(NOT "${outfile}" MATCHES ".*CMakeConfigDeps.*")
589+
message(WARNING "Cmake-conan: CMakeConfigDeps generator was not defined in the conanfile")
585590
endif()
586-
set(generator "")
587591
elseif (EXISTS "${CMAKE_SOURCE_DIR}/conanfile.txt")
588592
file(READ "${CMAKE_SOURCE_DIR}/conanfile.txt" outfile)
589-
if(NOT "${outfile}" MATCHES ".*CMakeDeps.*")
590-
message(WARNING "Cmake-conan: CMakeDeps generator was not defined in the conanfile. "
591-
"Please define the generator as it will be mandatory in the future")
593+
if(NOT "${outfile}" MATCHES ".*CMakeConfigDeps.*")
594+
message(WARNING "Cmake-conan: CMakeConfigDeps generator was not defined in the conanfile")
592595
endif()
593-
set(generator "-g;CMakeDeps")
594596
endif()
597+
595598
get_property(_multiconfig_generator GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
596-
if(NOT _multiconfig_generator)
597-
message(STATUS "CMake-Conan: Installing single configuration ${CMAKE_BUILD_TYPE}")
598-
conan_install(${_host_profile_flags} ${_build_profile_flags} ${CONAN_INSTALL_ARGS} ${generator})
599+
600+
if(DEFINED CONAN_INSTALL_BUILD_CONFIGURATIONS)
601+
# Configurations are specified by the project or user
602+
set(_build_configs "${CONAN_INSTALL_BUILD_CONFIGURATIONS}")
603+
list(LENGTH _build_configs _build_configs_length)
604+
if(NOT _multiconfig_generator AND _build_configs_length GREATER 1)
605+
message(FATAL_ERROR "cmake-conan: when using a single-config CMake generator, "
606+
"please only specify a single configuration in CONAN_INSTALL_BUILD_CONFIGURATIONS")
607+
endif()
608+
unset(_build_configs_length)
599609
else()
600-
message(STATUS "CMake-Conan: Installing both Debug and Release")
601-
conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=Release ${CONAN_INSTALL_ARGS} ${generator})
602-
conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=Debug ${CONAN_INSTALL_ARGS} ${generator})
610+
# No configuration overrides, provide sensible defaults
611+
if(_multiconfig_generator)
612+
set(_build_configs Release Debug)
613+
else()
614+
set(_build_configs ${CMAKE_BUILD_TYPE})
615+
endif()
616+
603617
endif()
618+
619+
list(JOIN _build_configs ", " _build_configs_msg)
620+
message(STATUS "CMake-Conan: Installing configuration(s): ${_build_configs_msg}")
621+
foreach(_build_config IN LISTS _build_configs)
622+
set(_self_build_config "")
623+
if(NOT _multiconfig_generator AND NOT _build_config STREQUAL "${CMAKE_BUILD_TYPE}")
624+
set(_self_build_config -s &:build_type=${CMAKE_BUILD_TYPE})
625+
endif()
626+
conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=${_build_config} ${_self_build_config} ${CONAN_INSTALL_ARGS})
627+
endforeach()
628+
629+
get_property(_conan_generators_folder GLOBAL PROPERTY CONAN_GENERATORS_FOLDER)
630+
if(EXISTS "${_conan_generators_folder}/conan_cmakedeps_paths.cmake")
631+
message(STATUS "CMake-Conan: Loading conan_cmakedeps_paths.cmake file")
632+
include(${_conan_generators_folder}/conan_cmakedeps_paths.cmake)
633+
endif()
634+
635+
unset(_self_build_config)
636+
unset(_multiconfig_generator)
637+
unset(_build_configs)
638+
unset(_build_configs_msg)
604639
unset(_host_profile_flags)
605640
unset(_build_profile_flags)
606-
unset(_multiconfig_generator)
607641
unset(_conan_install_success)
608642
else()
609643
message(STATUS "CMake-Conan: find_package(${ARGV1}) found, 'conan install' already ran")

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def requirements(self):
2121
else:
2222
self.requires("npcap/1.70")
2323
self.requires("opentelemetry-cpp/1.17.0")
24-
self.requires("pcapplusplus/23.09")
24+
self.requires("pcapplusplus/24.09")
2525
self.requires("protobuf/5.27.0")
2626
self.requires("sigslot/1.2.2")
2727
self.requires("fmt/10.2.1", force=True)

libs/visor_dns/DnsLayer.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ bool DnsLayer::parseResources(bool queryOnly, bool additionalOnly, bool forcePar
182182
m_ResourceList = newGenResource;
183183
curResource = m_ResourceList;
184184
} else {
185-
curResource->setNexResource(newGenResource);
185+
curResource->setNextResource(newGenResource);
186186
curResource = curResource->getNextResource();
187187
}
188188

@@ -458,11 +458,11 @@ DnsResource *DnsLayer::addResource(DnsResourceType resType, const std::string &n
458458
// set next resource for new resource. This must happen here for extendLayer to succeed
459459
if (curResource != NULL) {
460460
if (curResource->getType() > newResource->getType())
461-
newResource->setNexResource(m_ResourceList);
461+
newResource->setNextResource(m_ResourceList);
462462
else
463-
newResource->setNexResource(curResource->getNextResource());
463+
newResource->setNextResource(curResource->getNextResource());
464464
} else // curResource != NULL
465-
newResource->setNexResource(m_ResourceList);
465+
newResource->setNextResource(m_ResourceList);
466466

467467
// extend layer to make room for the new resource
468468
if (!extendLayer(newResourceOffsetInLayer, newResource->getSize(), newResource)) {
@@ -476,7 +476,7 @@ DnsResource *DnsLayer::addResource(DnsResourceType resType, const std::string &n
476476

477477
// connect the new resource to the layer's resource list
478478
if (curResource != NULL) {
479-
curResource->setNexResource(newResource);
479+
curResource->setNextResource(newResource);
480480
// this means the new resource is the first of it's type
481481
if (curResource->getType() < newResource->getType()) {
482482
setFirstResource(resType, newResource);
@@ -522,9 +522,9 @@ DnsQuery *DnsLayer::addQuery(const std::string &name, DnsType dnsType, DnsClass
522522

523523
// set next resource for new query. This must happen here for extendLayer to succeed
524524
if (curQuery != NULL)
525-
newQuery->setNexResource(curQuery->getNextResource());
525+
newQuery->setNextResource(curQuery->getNextResource());
526526
else
527-
newQuery->setNexResource(m_ResourceList);
527+
newQuery->setNextResource(m_ResourceList);
528528

529529
// extend layer to make room for the new query
530530
if (!extendLayer(newQueryOffsetInLayer, newQuery->getSize(), newQuery)) {
@@ -538,7 +538,7 @@ DnsQuery *DnsLayer::addQuery(const std::string &name, DnsType dnsType, DnsClass
538538

539539
// connect the new query to the layer's resource list
540540
if (curQuery != NULL)
541-
curQuery->setNexResource(newQuery);
541+
curQuery->setNextResource(newQuery);
542542
else // curQuery == NULL, meaning this is the first query
543543
{
544544
m_ResourceList = newQuery;
@@ -747,7 +747,7 @@ bool DnsLayer::removeResource(IDnsResource *resourceToRemove)
747747

748748
// remove resourceToRemove from the resources linked list
749749
if (m_ResourceList != resourceToRemove) {
750-
prevResource->setNexResource(resourceToRemove->getNextResource());
750+
prevResource->setNextResource(resourceToRemove->getNextResource());
751751
} else {
752752
m_ResourceList = resourceToRemove->getNextResource();
753753
}

libs/visor_dns/DnsLayer.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef PV_PACKETPP_DNS_LAYER
2-
#define PV_PACKETPP_DNS_LAYER
1+
#pragma once
32

43
#ifdef __GNUC__
54
#pragma GCC diagnostic push
@@ -501,4 +500,3 @@ struct dnshdr {
501500

502501
} // namespace visor
503502

504-
#endif /* PV_PACKETPP_DNS_LAYER */

0 commit comments

Comments
 (0)