diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..77de7b89 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + commit-message: + prefix: "ci:" + labels: ["actions"] + # only needed for non-default branch + #target-branch: "develop" diff --git a/.github/workflows/conda-dev.yml b/.github/workflows/conda-dev.yml new file mode 100644 index 00000000..062a69da --- /dev/null +++ b/.github/workflows/conda-dev.yml @@ -0,0 +1,84 @@ +name: CondaDev + +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + +jobs: + build: + name: libtins ${{ matrix.python-version }} ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # does not like windows + os: ['ubuntu-22.04', 'ubuntu-24.04'] + python-version: ['3.9', '3.11'] + include: + - os: 'ubuntu-22.04' + generator: 'Ninja' + build_type: 'Release' + - os: 'ubuntu-24.04' + generator: 'Ninja' + build_type: 'RelWithDebInfo' + + env: + OS: ${{ matrix.os }} + PYTHON: ${{ matrix.python-version }} + PYTHONIOENCODING: utf-8 + + steps: + - uses: actions/checkout@v6 + + - name: Setup base python + uses: actions/setup-python@v6 + with: + python-version: '3.x' + + - name: Cache conda + id: cache + uses: actions/cache@v5 + env: + # Increase this value to reset cache if environment.devenv.yml has not changed + CACHE_NUMBER: 1 + with: + path: ~/conda_pkgs_dir + key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.devenv.yml') }} + + - uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + python-version: ${{ matrix.python-version }} + channels: conda-forge,defaults + channel-priority: strict + conda-remove-defaults: true + use-only-tar-bz2: true + + - name: Configure condadev environment + shell: bash -el {0} + env: + PY_VER: ${{ matrix.python-version }} + run: | + conda config --set always_yes yes --set changeps1 no + conda config --add channels conda-forge + conda install conda-devenv + conda info -a + conda devenv + + - name: Build and test + shell: bash -el {0} + env: + PY_VER: ${{ matrix.python-version }} + run: | + source activate libtins-test + cmake \ + -G "${{ matrix.generator }}" -S . -B build \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DLIBTINS_ENABLE_CXX11=ON \ + -DCMAKE_INSTALL_PREFIX:PATH=${CONDA_PREFIX} + cmake --build build --target install --parallel 4 + cmake --build build --target tests --parallel 4 + ctest -V --test-dir build/ diff --git a/.github/workflows/debs.yml b/.github/workflows/debs.yml new file mode 100644 index 00000000..86ffc6a2 --- /dev/null +++ b/.github/workflows/debs.yml @@ -0,0 +1,87 @@ +name: Debian packages + +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + +jobs: + get_version: + name: Get version info + runs-on: ubuntu-22.04 + defaults: + run: + shell: bash + outputs: + version: ${{ steps.git_ver.outputs.version }} + + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Get package version + id: git_ver + run: | + version=$(git describe --tags | sed -e "s|v||" -e "s|-g|+g|") + echo "Version from git: ${version}" + echo "version=${version}" >> $GITHUB_OUTPUT + + build_debs: + name: ${{ matrix.name }} + runs-on: ubuntu-22.04 + needs: [get_version] + + strategy: + fail-fast: false + matrix: + name: [ + x64_bookworm, + x64_trixie, + x64_sid, + ] + + include: + - name: x64_bookworm + dist: bookworm + + - name: x64_trixie + dist: trixie + + - name: x64_sid + dist: sid + + steps: + - name: Check github variables + env: + VERSION: ${{ needs.get_version.outputs.version }} + run: | + echo "Package version from git: ${VERSION}" + + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Install deps and update debian changelog + run: | + sudo apt-get update + sudo apt-get install devscripts + debchange -v ${{ needs.get_version.outputs.version }}-${{ matrix.dist }} -b -M --distribution ${{ matrix.dist }} "ci build" + + - name: Build deb packages + uses: jtdor/build-deb-action@v1 + env: + DEB_BUILD_OPTIONS: noautodbgsym + with: + apt-opts: --install-recommends + docker-image: "debian:${{ matrix.dist }}-slim" + buildpackage-opts: --build=binary --no-sign + extra-build-deps: git cmake + + - name: Upload deb files + uses: actions/upload-artifact@v7 + with: + name: "libtins_${{ needs.get_version.outputs.version }}-${{ matrix.dist }}" + path: ./debian/artifacts/*.deb diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 151766e4..5b2f322d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -10,19 +10,19 @@ jobs: Ubuntu-Tests: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + submodules: true - name: Install libpcap run: sudo apt-get install -y libpcap-dev - - name: Initialize submodules - run: git submodule init && git submodule update - - name: Initialize build system - run: mkdir build && cd build && cmake .. + run: cmake -G "Unix Makefiles" -S . -B build -DCMAKE_BUILD_TYPE=Release - name: Build tests run: cmake --build build --target tests - name: Run tests - run: ctest build + run: ctest -V --test-dir build/ diff --git a/.gitignore b/.gitignore index 6109d958..bfa8f1bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ build/** include/tins/config.h +.tox/ diff --git a/.gitmodules b/.gitmodules index 38d72db1..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +0,0 @@ -[submodule "googletest"] - path = googletest - url = https://github.com/google/googletest.git - ignore = dirty diff --git a/CMakeLists.txt b/CMakeLists.txt index 3eb435fa..f2b6d0ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,16 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.1) -PROJECT(libtins) +# pre-test discovery mode for gtest_discover_tests was added in 3.18 +cmake_minimum_required(VERSION 3.12...3.18) + +if(POLICY CMP0167) + cmake_policy(SET CMP0167 NEW) +endif() + +if(POLICY CMP0135) + cmake_policy(SET CMP0135 NEW) +endif() + +# Add cmake modules of this project to the module path +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) OPTION(LIBTINS_BUILD_EXAMPLES "Build examples" ON) OPTION(LIBTINS_BUILD_TESTS "Build tests" ON) @@ -12,6 +23,21 @@ ELSE(NOT CMAKE_BUILD_TYPE) MESSAGE(STATUS "Using specified '${CMAKE_BUILD_TYPE}' build type.") ENDIF(NOT CMAKE_BUILD_TYPE) +project( + libtins + LANGUAGES CXX +) + +# Check the thread library info early as setting compiler flags seems to +# interfere with the detection and causes CMAKE_THREAD_LIBS_INIT to not +# include -lpthread when it should. +if(LIBTINS_BUILD_TESTS) + if (NOT TARGET Threads::Threads) + find_package(Threads REQUIRED) + endif () + set(LINK_LIBS ${LINK_LIBS} Threads::Threads) +endif() + # Compilation flags. IF(MSVC) # Don't always use Wall, since VC's /Wall is ridiculously verbose. @@ -50,8 +76,14 @@ SET(TINS_VERSION_MINOR 6) SET(TINS_VERSION_PATCH 0) SET(LIBTINS_VERSION "${TINS_VERSION_MAJOR}.${TINS_VERSION_MINOR}") -# Required Packages -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS ON) + +if(CMAKE_CXX_COMPILER_ID STREQUAL Clang) + set(CLANG_DEFAULT_CXX_STDLIB libc++) + set(CLANG_DEFAULT_RTLIB compiler-rt) +endif() # Allow disabling packet capture mechanism OPTION(LIBTINS_ENABLE_PCAP "Enable capturing packets via libpcap" ON) @@ -87,7 +119,9 @@ IF(WIN32) ENDIF(WIN32) -INCLUDE(ExternalProject) +INCLUDE(CTest) +INCLUDE(GNUInstallDirs) +#INCLUDE(ExternalProject) # ******************* # Compilation options @@ -155,7 +189,7 @@ ELSE() ENDIF() # Search for libboost -FIND_PACKAGE(Boost) +FIND_PACKAGE(Boost, CONFIG) # Optionally enable the ACK tracker (on by default) OPTION(LIBTINS_ENABLE_ACK_TRACKER "Enable TCP ACK tracking support" ON) @@ -279,38 +313,29 @@ IF(LIBTINS_BUILD_EXAMPLES) ENDIF() IF(LIBTINS_BUILD_TESTS) - # Only include googletest if the git submodule has been fetched - IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/googletest/CMakeLists.txt") - # Enable tests and add the test directory - MESSAGE(STATUS "Tests have been enabled") - SET(GOOGLETEST_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/googletest) - SET(GOOGLETEST_INCLUDE ${GOOGLETEST_ROOT}/googletest/include) - SET(GOOGLETEST_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/googletest) - SET(GOOGLETEST_LIBRARY ${GOOGLETEST_BINARY_DIR}/googletest) - - ExternalProject_Add( + find_package(GTest) + include_directories(${GTEST_INCLUDE_DIRS}) + IF(NOT GTEST_FOUND) + message (WARNING "Can't find system Google Test") + include(FetchContent) + FetchContent_Declare( googletest - DOWNLOAD_COMMAND "" - SOURCE_DIR ${GOOGLETEST_ROOT} - BINARY_DIR ${GOOGLETEST_BINARY_DIR} - CMAKE_CACHE_ARGS "-DBUILD_GTEST:bool=ON" "-DBUILD_GMOCK:bool=OFF" - "-Dgtest_force_shared_crt:bool=ON" - "-DCMAKE_CXX_COMPILER:path=${CMAKE_CXX_COMPILER}" - INSTALL_COMMAND "" + # Specify the commit => this is release 1.12.1 + URL https://github.com/google/googletest/archive/58d77fa8070e8cec2dc1ed015d66b454c8d78850.zip ) - # Make sure we build googletest before anything else - ADD_DEPENDENCIES(tins googletest) - ENABLE_TESTING() - ADD_SUBDIRECTORY(tests) - ELSE() - FIND_PACKAGE(GTest QUIET) - IF(${GTest_FOUND}) - ENABLE_TESTING() - ADD_SUBDIRECTORY(tests) - ELSE() - MESSAGE(STATUS "googletest git submodule is absent. Run `git submodule init && git submodule update` to get it") - ENDIF() + FetchContent_GetProperties(googletest) + if(NOT googletest_POPULATED) + # Fetch the content using previously declared details + FetchContent_Populate(googletest) + add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) + endif() + include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) ENDIF() + # For Windows: Prevent overriding the parent project's compiler/linker settings + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + ENABLE_TESTING() + set(GTEST_LINK_LIBRARIES gtest gtest_main) + ADD_SUBDIRECTORY(tests) ENDIF() # ********************************** diff --git a/cmake/Modules/CheckCXXFeatures.cmake b/cmake/Modules/CheckCXXFeatures.cmake index b7b7f143..369b5222 100644 --- a/cmake/Modules/CheckCXXFeatures.cmake +++ b/cmake/Modules/CheckCXXFeatures.cmake @@ -50,7 +50,7 @@ if (NOT CMAKE_CXX_COMPILER_LOADED) message(FATAL_ERROR "CheckCXX11Features modules only works if language CXX is enabled") endif () -cmake_minimum_required(VERSION 2.8.3) +#cmake_minimum_required(VERSION 2.8.3) # ### Check for needed compiler flags diff --git a/cmake/Modules/FindPCAP.cmake b/cmake/Modules/FindPCAP.cmake index 388b30b6..ba4fb034 100644 --- a/cmake/Modules/FindPCAP.cmake +++ b/cmake/Modules/FindPCAP.cmake @@ -73,7 +73,9 @@ endif (NOT PCAP_LINKS_SOLO) include(CheckFunctionExists) set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY}) -check_function_exists(pcap_get_pfring_id HAVE_PF_RING) +# this is not actually used, is not part of normal libpcap, and +# causes breakage in some build environments, eg, bookworm docker image +#check_function_exists(pcap_get_pfring_id HAVE_PF_RING) check_function_exists(pcap_set_immediate_mode HAVE_PCAP_IMMEDIATE_MODE) check_function_exists(pcap_set_tstamp_precision HAVE_PCAP_TIMESTAMP_PRECISION) set(CMAKE_REQUIRED_LIBRARIES) diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..80d9f5bd --- /dev/null +++ b/debian/changelog @@ -0,0 +1,38 @@ +libtins (4.5-1build2) noble; urgency=medium + + * No-change rebuild for CVE-2024-3094 + + -- Steve Langasek Sun, 31 Mar 2024 19:47:29 +0000 + +libtins (4.5-1build1) noble; urgency=medium + + * No-change rebuild against libssl3t64 + + -- Steve Langasek Mon, 04 Mar 2024 18:29:00 +0000 + +libtins (4.5-1) unstable; urgency=medium + + * New upstream release (Closes: #1050161) + * Add multiarch support (Closes: #1024945) + Kudos to Helmut Grohne + + -- Federico Ceratto Thu, 15 Feb 2024 17:26:17 +0100 + +libtins (4.0-1) unstable; urgency=medium + + * New upstream release (Closes: #897440) + * Add dependency (Closes: #894343) + + -- Federico Ceratto Wed, 19 Sep 2018 22:31:41 +0100 + +libtins (3.4-2) unstable; urgency=medium + + * Include usr/lib/libtins.so, minor fixes. + + -- Federico Ceratto Thu, 16 Jun 2016 18:24:52 +0100 + +libtins (3.4-1) unstable; urgency=medium + + * Initial release (Closes: #825025) + + -- Federico Ceratto Mon, 06 Jun 2016 11:24:23 +0100 diff --git a/debian/clean b/debian/clean new file mode 100644 index 00000000..7fad5ba8 --- /dev/null +++ b/debian/clean @@ -0,0 +1 @@ +include/tins/config.h diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..d9605d7e --- /dev/null +++ b/debian/control @@ -0,0 +1,36 @@ +Source: libtins +Priority: optional +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Internet Measurement Packaging Team +Uploaders: Federico Ceratto +Build-Depends: debhelper-compat (= 12), + cmake, + libpcap-dev, + libssl-dev +Standards-Version: 4.2.1 +Section: libs +Homepage: https://libtins.github.io/ +Vcs-Git: https://salsa.debian.org/debian/libtins.git +Vcs-Browser: https://salsa.debian.org/debian/libtins + +Package: libtins4.5 +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: packet crafting and sniffing library + libtins is a high-level, multiplatform C++ network packet sniffing and + crafting library. + Its main purpose is to provide the C++ developer an easy, efficient, platform + and endianess-independent way to create tools which need to send, receive and + manipulate network packets. + +Package: libtins-dev +Section: libdevel +Architecture: any +Depends: libtins4.5 (= ${binary:Version}), ${misc:Depends}, libpcap-dev +Description: packet crafting and sniffing library - development files + libtins is a high-level, multiplatform C++ network packet sniffing and + crafting library. + Its main purpose is to provide the C++ developer an easy, efficient, platform + and endianess-independent way to create tools which need to send, receive and + manipulate network packets. + This package contains development files. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..a81c9fd0 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,38 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: libtins3 +Source: https://libtins.github.io/ + +Files: * +Copyright: 2011-2023 Matias Fontanini + 2011-2017 Santiago Alessandri +License: BSD-2-clause + +Files: debian/* +Copyright: 2016-2024 Federico Ceratto +License: BSD-2-clause + +License: BSD-2-clause + All rights reserved. + . + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + . + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/debian/gitlab-ci.yml b/debian/gitlab-ci.yml new file mode 100644 index 00000000..33c3a640 --- /dev/null +++ b/debian/gitlab-ci.yml @@ -0,0 +1,4 @@ +--- +include: + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml diff --git a/debian/libtins-dev.dirs b/debian/libtins-dev.dirs new file mode 100644 index 00000000..44188162 --- /dev/null +++ b/debian/libtins-dev.dirs @@ -0,0 +1,2 @@ +usr/lib +usr/include diff --git a/debian/libtins-dev.docs b/debian/libtins-dev.docs new file mode 100644 index 00000000..e4bd0a04 --- /dev/null +++ b/debian/libtins-dev.docs @@ -0,0 +1,2 @@ +README.md +CONTRIBUTING.md diff --git a/debian/libtins-dev.examples b/debian/libtins-dev.examples new file mode 100644 index 00000000..e39721e2 --- /dev/null +++ b/debian/libtins-dev.examples @@ -0,0 +1 @@ +examples/* diff --git a/debian/libtins-dev.install b/debian/libtins-dev.install new file mode 100644 index 00000000..82e8016f --- /dev/null +++ b/debian/libtins-dev.install @@ -0,0 +1,4 @@ +usr/include/* +usr/lib/*/cmake/libtins/*.cmake +usr/lib/*/pkgconfig/* +usr/lib/*/libtins.so diff --git a/debian/libtins4.0.dirs b/debian/libtins4.0.dirs new file mode 100644 index 00000000..68457717 --- /dev/null +++ b/debian/libtins4.0.dirs @@ -0,0 +1 @@ +usr/lib diff --git a/debian/libtins4.5.install b/debian/libtins4.5.install new file mode 100644 index 00000000..dca8376b --- /dev/null +++ b/debian/libtins4.5.install @@ -0,0 +1 @@ +usr/lib/*/libtins.so.4.* diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..af149a97 --- /dev/null +++ b/debian/rules @@ -0,0 +1,24 @@ +#!/usr/bin/make -f + +include /usr/share/dpkg/architecture.mk + +export DH_VERBOSE = 1 +export V=1 # verbose mode for make +export DEB_BUILD_MAINT_OPTIONS = hardening=+all +export DEB_LDFLAGS_MAINT_APPEND = -Wl,--no-undefined,--no-add-needed +export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +objdir = $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE) + +%: + dh $@ + +override_dh_auto_configure: + dh_auto_configure -- -DCROSS_COMPILING=$(if $(filter $(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)),OFF,ON) \ + -DLIBTINS_ENABLE_CXX11=1 \ + -DLIBTINS_ENABLE_ACK_TRACKER=0 \ + -DLIBTINS_ENABLE_WPA2=0 \ + -DLIBTINS_ENABLE_DOT11=0 \ + -DLIBTINS_BUILD_TESTS=0 + +override_dh_installchangelogs: + dh_installchangelogs CHANGES.md diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 00000000..163aaf8d --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/upstream/metadata b/debian/upstream/metadata new file mode 100644 index 00000000..90465f8c --- /dev/null +++ b/debian/upstream/metadata @@ -0,0 +1,5 @@ +--- +Bug-Database: https://github.com/mfontanini/libtins/issues +Bug-Submit: https://github.com/mfontanini/libtins/issues/new +Repository: https://github.com/mfontanini/libtins.git +Repository-Browse: https://github.com/mfontanini/libtins diff --git a/debian/watch b/debian/watch new file mode 100644 index 00000000..19bc6315 --- /dev/null +++ b/debian/watch @@ -0,0 +1,2 @@ +version=4 +opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/libtins3-$1\.tar\.gz/ https://github.com/mfontanini/libtins/tags .*/v?(\d\S*)\.tar\.gz diff --git a/environment.devenv.yml b/environment.devenv.yml new file mode 100644 index 00000000..ebed285e --- /dev/null +++ b/environment.devenv.yml @@ -0,0 +1,25 @@ +name: libtins-test + +dependencies: + - python ={{ get_env("PY_VER", default="3.9") }} + - cmake>=3.18 + - ninja + - make # [unix] + - pkg-config # [unix] + - gtest + - gmock + - libpcap + - boost + - boost-cpp + - lcov + - gcovr + - gxx_linux-64 # [linux] + - ccache # [unix] + - clcache # [win] + +environment: + CPATH: + - $CONDA_PREFIX/include # [unix] + - $CONDA_PREFIX/Library/include # [win] + + LD_LIBRARY_PATH: $CONDA_PREFIX/lib # [unix] diff --git a/googletest b/googletest deleted file mode 160000 index 13206d6f..00000000 --- a/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 13206d6f53aaff844f2d3595a01ac83a29e383db diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8dc4fc82..59d94aec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -206,9 +206,9 @@ SET(PCAP_DEPENDENT_HEADERS IF(LIBTINS_ENABLE_PCAP) SET(SOURCES ${SOURCES} ${PCAP_DEPENDENT_SOURCES}) SET(HEADERS ${HEADERS} ${PCAP_DEPENDENT_HEADERS}) -ENDIF() +ENDIF() -ADD_LIBRARY( +ADD_LIBRARY( tins ${LIBTINS_TYPE} ${SOURCES} ${HEADERS} @@ -220,7 +220,7 @@ SET_TARGET_PROPERTIES(tins PROPERTIES OUTPUT_NAME tins) SET_TARGET_PROPERTIES(tins PROPERTIES VERSION ${LIBTINS_VERSION} SOVERSION ${LIBTINS_VERSION} ) # Install instructions for this target -INSTALL( +INSTALL( TARGETS tins EXPORT libtinsTargets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/src/utils/resolve_utils.cpp b/src/utils/resolve_utils.cpp index 1be8fced..f86fdfd5 100644 --- a/src/utils/resolve_utils.cpp +++ b/src/utils/resolve_utils.cpp @@ -46,6 +46,7 @@ #include #include #include + #include #undef interface #endif #include diff --git a/tests/src/CMakeLists.txt b/tests/src/CMakeLists.txt index aa0c3777..db2b02cf 100644 --- a/tests/src/CMakeLists.txt +++ b/tests/src/CMakeLists.txt @@ -6,19 +6,15 @@ INCLUDE_DIRECTORIES( ${PCAP_INCLUDE_DIR} ) -# Find pthread library -FIND_PACKAGE(Threads REQUIRED) - LINK_DIRECTORIES( ${GOOGLETEST_LIBRARY} ) -# Link against GoogleTest, libtins and pthread. +# Link against GoogleTest, libtins # Pthread is required by GoogleTest +# (gtest now sets Thread::Thread automatically) LINK_LIBRARIES( - gtest - gtest_main - tins - ${CMAKE_THREAD_LIBS_INIT} + tins + ${GTEST_LINK_LIBRARIES} ${PCAP_LIBRARY} ) @@ -107,4 +103,3 @@ IF(LIBTINS_ENABLE_DOT11) CREATE_TEST(wpa2_decrypt) ENDIF() ENDIF() - diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..a853e196 --- /dev/null +++ b/tox.ini @@ -0,0 +1,87 @@ +[tox] +envlist = tools,run,test,clean +skip_missing_interpreters = true +skipsdist = true + +[testenv] +skip_install = true +install_command = pip install {opts} {packages} +#basepython= python3.9 + +[testenv:tools] +setenv = + CFLAGS = -march=native -O2 -g -DNDEBUG + CXXFLAGS = {env:CFLAGS:-march=native -O2 -g -DNDEBUG} + LDFLAGS = {env:CFLAGS:-march=native -O2 -g -DNDEBUG} -Wl,-O1 -Wl,--as-needed + PREFIX = {env:PREFIX:{envdir}} + +passenv = + CC + CXX + LD + AR + NM + RANLIB + PYTHON + DISPLAY + XAUTHORITY + HOME + USERNAME + USER + CI + XDG_* + GITHUB* + PIP_DOWNLOAD_CACHE + +allowlist_externals = + bash + +deps = + pip>=22.1 + cmake + ninja + +commands = + cmake -G {posargs:"Unix Makefiles"} -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX={env:PREFIX} -DLIBTINS_ENABLE_CXX11=ON -DLIBTINS_ENABLE_ACK_TRACKER=OFF -DLIBTINS_ENABLE_WPA2=OFF -DLIBTINS_ENABLE_DOT11=OFF -DLIBTINS_BUILD_TESTS=OFF + cmake --build build -j 4 --target install + bash -c 'ls -lh $PREFIX/*' + +[testenv:run] +envdir = {toxworkdir}/tools + +deps = + {[testenv:tools]deps} + +passenv = + {[testenv:tools]passenv} + +commands = + python --version + +[testenv:test] +envdir = {toxworkdir}/tools + +deps = + {[testenv:tools]deps} + +setenv = + {[testenv:tools]setenv} + +passenv = + {[testenv:tools]passenv} + +commands = + cmake -G {posargs:"Unix Makefiles"} -S . -B build -DCMAKE_BUILD_TYPE=Release + cmake --build build -j4 --target tests + ctest -V --test-dir build/ + +[testenv:clean] +skip_install = true +allowlist_externals = + {[testenv:tools]allowlist_externals} + +deps = + pip>=21.1 + +commands = + bash -c 'rm -rf build/'