Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ if(WIN32)
endif()

find_package(Corrade REQUIRED)

# After the first find_package() triggers conan install, load conan_toolchain.cmake to set
# CMAKE_PROGRAM_PATH so that tool_requires (e.g. protoc) are preferred over system versions.
# include_guard() in conan_toolchain.cmake makes this safe when -DCMAKE_TOOLCHAIN_FILE is also used.
get_property(_conan_generators GLOBAL PROPERTY CONAN_GENERATORS_FOLDER)
if(_conan_generators AND EXISTS "${_conan_generators}/conan_toolchain.cmake")
include("${_conan_generators}/conan_toolchain.cmake")
unset(PROTOC_PROGRAM CACHE)
endif()
unset(_conan_generators)

include(sanitizer)
if(CODE_COVERAGE)
include(CodeCoverage)
Expand Down
78 changes: 56 additions & 22 deletions cmake/conan_provider.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,14 @@ function(detect_arch arch)
endfunction()


function(detect_cxx_standard cxx_standard)
function(detect_cxx_standard compiler cxx_standard)
set(${cxx_standard} ${CMAKE_CXX_STANDARD} PARENT_SCOPE)
if(CMAKE_CXX_EXTENSIONS)
set(${cxx_standard} "gnu${CMAKE_CXX_STANDARD}" PARENT_SCOPE)
if(compiler STREQUAL "msvc")
set(${cxx_standard} "${CMAKE_CXX_STANDARD}" PARENT_SCOPE)
else()
set(${cxx_standard} "gnu${CMAKE_CXX_STANDARD}" PARENT_SCOPE)
endif()
endif()
endfunction()

Expand Down Expand Up @@ -356,8 +360,10 @@ macro(append_compiler_executables_configuration)
# Not necessary to warn if RC not defined
endif()
if(NOT "x${_conan_compilers_list}" STREQUAL "x")
string(REPLACE ";" "," _conan_compilers_list "${_conan_compilers_list}")
string(APPEND profile "tools.build:compiler_executables={${_conan_compilers_list}}\n")
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
string(REPLACE ";" "," _conan_compilers_list "${_conan_compilers_list}")
string(APPEND profile "tools.build:compiler_executables={${_conan_compilers_list}}\n")
endif()
endif()
unset(_conan_c_compiler)
unset(_conan_cpp_compiler)
Expand All @@ -370,7 +376,7 @@ function(detect_host_profile output_file)
detect_os(os os_api_level os_sdk os_subsystem os_version)
detect_arch(arch)
detect_compiler(compiler compiler_version compiler_runtime compiler_runtime_type)
detect_cxx_standard(compiler_cppstd)
detect_cxx_standard(${compiler} compiler_cppstd)
detect_lib_cxx(compiler_libcxx)
detect_build_type(build_type)

Expand Down Expand Up @@ -461,10 +467,9 @@ endfunction()


function(conan_install)
cmake_parse_arguments(ARGS conan_args ${ARGN})
set(conan_output_folder ${CMAKE_BINARY_DIR}/conan)
# Invoke "conan install" with the provided arguments
set(conan_args ${conan_args} -of=${conan_output_folder})
set(conan_args -of=${conan_output_folder})
message(STATUS "CMake-Conan: conan install ${CMAKE_SOURCE_DIR} ${conan_args} ${ARGN}")


Expand Down Expand Up @@ -567,7 +572,7 @@ macro(conan_provide_dependency method package_name)
get_property(_conan_install_success GLOBAL PROPERTY CONAN_INSTALL_SUCCESS)
if(NOT _conan_install_success)
find_program(CONAN_COMMAND "conan" REQUIRED)
conan_get_version(${CONAN_COMMAND} CONAN_CURRENT_VERSION)
conan_get_version("${CONAN_COMMAND}" CONAN_CURRENT_VERSION)
conan_version_check(MINIMUM ${CONAN_MINIMUM_VERSION} CURRENT ${CONAN_CURRENT_VERSION})
message(STATUS "CMake-Conan: first find_package() found. Installing dependencies with Conan")
if("default" IN_LIST CONAN_HOST_PROFILE OR "default" IN_LIST CONAN_BUILD_PROFILE)
Expand All @@ -580,30 +585,59 @@ macro(conan_provide_dependency method package_name)
construct_profile_argument(_build_profile_flags CONAN_BUILD_PROFILE)
if(EXISTS "${CMAKE_SOURCE_DIR}/conanfile.py")
file(READ "${CMAKE_SOURCE_DIR}/conanfile.py" outfile)
if(NOT "${outfile}" MATCHES ".*CMakeDeps.*")
message(WARNING "Cmake-conan: CMakeDeps generator was not defined in the conanfile")
if(NOT "${outfile}" MATCHES ".*CMakeConfigDeps.*")
message(WARNING "Cmake-conan: CMakeConfigDeps generator was not defined in the conanfile")
endif()
set(generator "")
elseif (EXISTS "${CMAKE_SOURCE_DIR}/conanfile.txt")
file(READ "${CMAKE_SOURCE_DIR}/conanfile.txt" outfile)
if(NOT "${outfile}" MATCHES ".*CMakeDeps.*")
message(WARNING "Cmake-conan: CMakeDeps generator was not defined in the conanfile. "
"Please define the generator as it will be mandatory in the future")
if(NOT "${outfile}" MATCHES ".*CMakeConfigDeps.*")
message(WARNING "Cmake-conan: CMakeConfigDeps generator was not defined in the conanfile")
endif()
set(generator "-g;CMakeDeps")
endif()

get_property(_multiconfig_generator GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT _multiconfig_generator)
message(STATUS "CMake-Conan: Installing single configuration ${CMAKE_BUILD_TYPE}")
conan_install(${_host_profile_flags} ${_build_profile_flags} ${CONAN_INSTALL_ARGS} ${generator})

if(DEFINED CONAN_INSTALL_BUILD_CONFIGURATIONS)
# Configurations are specified by the project or user
set(_build_configs "${CONAN_INSTALL_BUILD_CONFIGURATIONS}")
list(LENGTH _build_configs _build_configs_length)
if(NOT _multiconfig_generator AND _build_configs_length GREATER 1)
message(FATAL_ERROR "cmake-conan: when using a single-config CMake generator, "
"please only specify a single configuration in CONAN_INSTALL_BUILD_CONFIGURATIONS")
endif()
unset(_build_configs_length)
else()
message(STATUS "CMake-Conan: Installing both Debug and Release")
conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=Release ${CONAN_INSTALL_ARGS} ${generator})
conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=Debug ${CONAN_INSTALL_ARGS} ${generator})
# No configuration overrides, provide sensible defaults
if(_multiconfig_generator)
set(_build_configs Release Debug)
else()
set(_build_configs ${CMAKE_BUILD_TYPE})
endif()

endif()

list(JOIN _build_configs ", " _build_configs_msg)
message(STATUS "CMake-Conan: Installing configuration(s): ${_build_configs_msg}")
foreach(_build_config IN LISTS _build_configs)
set(_self_build_config "")
if(NOT _multiconfig_generator AND NOT _build_config STREQUAL "${CMAKE_BUILD_TYPE}")
set(_self_build_config -s &:build_type=${CMAKE_BUILD_TYPE})
endif()
conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=${_build_config} ${_self_build_config} ${CONAN_INSTALL_ARGS})
endforeach()

get_property(_conan_generators_folder GLOBAL PROPERTY CONAN_GENERATORS_FOLDER)
if(EXISTS "${_conan_generators_folder}/conan_cmakedeps_paths.cmake")
message(STATUS "CMake-Conan: Loading conan_cmakedeps_paths.cmake file")
include(${_conan_generators_folder}/conan_cmakedeps_paths.cmake)
endif()

unset(_self_build_config)
unset(_multiconfig_generator)
unset(_build_configs)
unset(_build_configs_msg)
unset(_host_profile_flags)
unset(_build_profile_flags)
unset(_multiconfig_generator)
unset(_conan_install_success)
else()
message(STATUS "CMake-Conan: find_package(${ARGV1}) found, 'conan install' already ran")
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def requirements(self):
else:
self.requires("npcap/1.70")
self.requires("opentelemetry-cpp/1.17.0")
self.requires("pcapplusplus/23.09")
self.requires("pcapplusplus/24.09")
self.requires("protobuf/5.27.0")
self.requires("sigslot/1.2.2")
self.requires("fmt/10.2.1", force=True)
Expand Down
18 changes: 9 additions & 9 deletions libs/visor_dns/DnsLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ bool DnsLayer::parseResources(bool queryOnly, bool additionalOnly, bool forcePar
m_ResourceList = newGenResource;
curResource = m_ResourceList;
} else {
curResource->setNexResource(newGenResource);
curResource->setNextResource(newGenResource);
curResource = curResource->getNextResource();
}

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

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

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

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

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

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

// remove resourceToRemove from the resources linked list
if (m_ResourceList != resourceToRemove) {
prevResource->setNexResource(resourceToRemove->getNextResource());
prevResource->setNextResource(resourceToRemove->getNextResource());
} else {
m_ResourceList = resourceToRemove->getNextResource();
}
Expand Down
4 changes: 1 addition & 3 deletions libs/visor_dns/DnsLayer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef PV_PACKETPP_DNS_LAYER
#define PV_PACKETPP_DNS_LAYER
#pragma once

#ifdef __GNUC__
#pragma GCC diagnostic push
Expand Down Expand Up @@ -501,4 +500,3 @@ struct dnshdr {

} // namespace visor

#endif /* PV_PACKETPP_DNS_LAYER */
Loading
Loading