Skip to content

Commit

Permalink
Vendor libpcap v1.10.4 under libpcap/
Browse files Browse the repository at this point in the history
Retrieved from https://github.com/the-tcpdump-group/libpcap/archive/refs/tags/libpcap-1.10.4.zip.

libpcap/.gitignore was modified to include bpf_filter.c.

Signed-off-by: Martynas Pumputis <m@lambda.lt>
  • Loading branch information
brb committed Jul 5, 2023
1 parent de5b0e9 commit b6e7f19
Show file tree
Hide file tree
Showing 324 changed files with 130,588 additions and 0 deletions.
104 changes: 104 additions & 0 deletions libpcap/.appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
version: '{build}'

clone_depth: 5

branches:
except:
- coverity_scan

matrix:
fast_finish: true

install:
- cinst winflexbison
- win_flex --version
- win_bison --version
- appveyor DownloadFile https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip
- 7z x .\WpdPack_4_1_2.zip -oc:\projects\libpcap\Win32
- appveyor DownloadFile https://npcap.com/dist/npcap-sdk-1.13.zip
- 7z x .\npcap-sdk-1.13.zip -oc:\projects\libpcap\Win32\npcap-sdk-1.13
- appveyor DownloadFile https://support.riverbed.com/bin/support/download?sid=l3vk3eu649usgu3rj60uncjqqu -FileName AirPcap_Devpack.zip
- 7z x .\AirPcap_Devpack.zip -oc:\projects\libpcap\Win32

environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
GENERATOR: "MinGW Makefiles"
SDK: WpdPack
AIRPCAP: -DDISABLE_AIRPCAP=YES
MINGW_ROOT: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
GENERATOR: "Visual Studio 14 2015 Win64"
SDK: WpdPack
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
GENERATOR: "Visual Studio 14 2015"
SDK: npcap-sdk-1.12
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
GENERATOR: "Visual Studio 14 2015 Win64"
SDK: npcap-sdk-1.12
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
GENERATOR: "Visual Studio 15 2017"
SDK: WpdPack
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
GENERATOR: "Visual Studio 15 2017 Win64"
SDK: WpdPack
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
GENERATOR: "Visual Studio 15 2017"
SDK: npcap-sdk-1.12
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
GENERATOR: "Visual Studio 15 2017 Win64"
SDK: npcap-sdk-1.12
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
GENERATOR: "Visual Studio 15 2017 Win64"
SDK: npcap-sdk-1.12
AIRPCAP: -DDISABLE_AIRPCAP=NO
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
GENERATOR: "Visual Studio 16 2019"
PLATFORM: Win32
SDK: WpdPack
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
GENERATOR: "Visual Studio 16 2019"
PLATFORM: x64
SDK: WpdPack
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
GENERATOR: "Visual Studio 16 2019"
PLATFORM: Win32
SDK: npcap-sdk-1.12
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
GENERATOR: "Visual Studio 16 2019"
PLATFORM: x64
SDK: npcap-sdk-1.12
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
GENERATOR: "Visual Studio 16 2019"
PLATFORM: x64
SDK: npcap-sdk-1.12
AIRPCAP: -DDISABLE_AIRPCAP=NO

build_script:
#
# Appveyor defaults to cmd.exe, so use cmd.exe syntax.
#
- type NUL >.devel
- md build
- cd build
# Remove the default MinGW path
- if "%GENERATOR%"=="MinGW Makefiles" set PATH=%PATH:C:\MinGW\bin;=%
# Add the specified MinGW path
- if "%GENERATOR%"=="MinGW Makefiles" set PATH=%MINGW_ROOT%\mingw64\bin;%PATH%
# Remove the path to Git, so that we don't pick up its sh.exe, as
# that breaks MinGW builds - CMake checks for that and fails in the
# configuration stage
- if "%GENERATOR%"=="MinGW Makefiles" set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
- if NOT DEFINED PLATFORM cmake %AIRPCAP% -DPacket_ROOT=c:\projects\libpcap\Win32\%SDK% -G"%GENERATOR%" -DPacket_ROOT=c:\projects\libpcap\Win32\%SDK% -DPacket_ROOT=c:\projects\libpcap\Win32\%SDK% -G"%GENERATOR%" -DAirPcap_ROOT=c:\projects\libpcap\Win32\Airpcap_Devpack -G"%GENERATOR%" ..
- if DEFINED PLATFORM cmake %AIRPCAP% -DPacket_ROOT=c:\projects\libpcap\Win32\%SDK% -G"%GENERATOR%" -DPacket_ROOT=c:\projects\libpcap\Win32\%SDK% -DPacket_ROOT=c:\projects\libpcap\Win32\%SDK% -G"%GENERATOR%" -DAirPcap_ROOT=c:\projects\libpcap\Win32\Airpcap_Devpack -G"%GENERATOR%" -A %PLATFORM% ..
- if NOT "%GENERATOR%"=="MinGW Makefiles" msbuild /m /nologo /p:Configuration=Release pcap.sln
- if "%GENERATOR%"=="MinGW Makefiles" mingw32-make
91 changes: 91 additions & 0 deletions libpcap/.ci-coverity-scan-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/sh

set -e

# Environment check
printf "\033[33;1mNote: COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN are available on Project Settings page on scan.coverity.com\033[0m\n"
[ -z "$COVERITY_SCAN_PROJECT_NAME" ] && echo "ERROR: COVERITY_SCAN_PROJECT_NAME must be set" && exit 1
#[ -z "$COVERITY_SCAN_NOTIFICATION_EMAIL" ] && echo "ERROR: COVERITY_SCAN_NOTIFICATION_EMAIL must be set" && exit 1
[ -z "$COVERITY_SCAN_BUILD_COMMAND" ] && echo "ERROR: COVERITY_SCAN_BUILD_COMMAND must be set" && exit 1
[ -z "$COVERITY_SCAN_TOKEN" ] && echo "ERROR: COVERITY_SCAN_TOKEN must be set" && exit 1

PLATFORM=$(uname)
TOOL_ARCHIVE=/tmp/cov-analysis-${PLATFORM}.tgz
TOOL_URL=https://scan.coverity.com/download/cxx/${PLATFORM}
TOOL_BASE=/tmp/coverity-scan-analysis
UPLOAD_URL="https://scan.coverity.com/builds"
SCAN_URL="https://scan.coverity.com"

# Verify upload is permitted
AUTH_RES=$(curl -s --form project="$COVERITY_SCAN_PROJECT_NAME" --form token="$COVERITY_SCAN_TOKEN" $SCAN_URL/api/upload_permitted)
if [ "$AUTH_RES" = "Access denied" ]; then
printf "\033[33;1mCoverity Scan API access denied. Check COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN.\033[0m\n"
exit 1
else
AUTH=$(echo "$AUTH_RES" | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['upload_permitted']")
if [ "$AUTH" = "true" ]; then
printf "\033[33;1mCoverity Scan analysis authorized per quota.\033[0m\n"
else
WHEN=$(echo "$AUTH_RES" | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['next_upload_permitted_at']")
printf "\033[33;1mCoverity Scan analysis NOT authorized until %s.\033[0m\n" "$WHEN"
exit 0
fi
fi

if [ ! -d $TOOL_BASE ]; then
# Download Coverity Scan Analysis Tool
if [ ! -e "$TOOL_ARCHIVE" ]; then
printf "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m\n"
wget -nv -O "$TOOL_ARCHIVE" "$TOOL_URL" --post-data "project=$COVERITY_SCAN_PROJECT_NAME&token=$COVERITY_SCAN_TOKEN"
fi

# Extract Coverity Scan Analysis Tool
printf "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m\n"
mkdir -p $TOOL_BASE
tar xzf "$TOOL_ARCHIVE" -C "$TOOL_BASE"
fi

TOOL_DIR=$(find $TOOL_BASE -type d -name 'cov-analysis*')
export PATH=$TOOL_DIR/bin:$PATH

# Build
printf "\033[33;1mRunning Coverity Scan Analysis Tool...\033[0m\n"
COV_BUILD_OPTIONS=""
#COV_BUILD_OPTIONS="--return-emit-failures 8 --parse-error-threshold 85"
RESULTS_DIR="cov-int"
eval "${COVERITY_SCAN_BUILD_COMMAND_PREPEND}"
# Do not quote COV_BUILD_OPTIONS so it collapses when it is empty and expands
# when it is not.
# shellcheck disable=SC2086
COVERITY_UNSUPPORTED=1 cov-build --dir "$RESULTS_DIR" $COV_BUILD_OPTIONS "$COVERITY_SCAN_BUILD_COMMAND"
cov-import-scm --dir $RESULTS_DIR --scm git --log $RESULTS_DIR/scm_log.txt 2>&1

# Upload results
printf "\033[33;1mTarring Coverity Scan Analysis results...\033[0m\n"
RESULTS_ARCHIVE=analysis-results.tgz
tar czf $RESULTS_ARCHIVE $RESULTS_DIR
SHA=$(git rev-parse --short HEAD)
VERSION_SHA=$(cat VERSION)#$SHA

# Verify Coverity Scan script test mode
if [ "${coverity_scan_script_test_mode:-false}" = true ]; then
printf "\033[33;1mCoverity Scan configured in script test mode. Exit.\033[0m\n"
exit 0
fi

printf "\033[33;1mUploading Coverity Scan Analysis results...\033[0m\n"
response=$(curl \
--silent --write-out "\n%{http_code}\n" \
--form project="$COVERITY_SCAN_PROJECT_NAME" \
--form token="$COVERITY_SCAN_TOKEN" \
--form email=blackhole@blackhole.io \
--form file=@$RESULTS_ARCHIVE \
--form version="$SHA" \
--form description="$VERSION_SHA" \
$UPLOAD_URL)
status_code=$(echo "$response" | sed -n '$p')
if [ "$status_code" != "200" ] && [ "$status_code" != "201" ]; then
TEXT=$(echo "$response" | sed '$d')
printf "\033[33;1mCoverity Scan upload failed with HTTP status code '%s': %s.\033[0m\n" "$status_code" "$TEXT"
exit 1
fi
86 changes: 86 additions & 0 deletions libpcap/.cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# The internal git client reads CIRRUS_CLONE_DEPTH.
env:
CIRRUS_CLONE_DEPTH: 3

freebsd_task:
name: freebsd-amd64
only_if: $CIRRUS_BRANCH != 'coverity_scan'
freebsd_instance:
matrix:
- image_family: freebsd-12-3
cpu: 2
memory: 2G
- image_family: freebsd-13-1
cpu: 4
memory: 4G
env:
IGNORE_OSVERSION: yes
MAKEFLAGS: -j 4
MATRIX_CC: clang14 gcc12
script:
- pkg install -qy autoconf gcc12 llvm14
- pkg install -qy cmake git-tiny # for build_matrix.sh and build.sh
- ./build_matrix.sh

linux_task:
name: linux-amd64
only_if: $CIRRUS_BRANCH != 'coverity_scan'
container:
image: ubuntu:22.04
cpu: 2
memory: 1G
env:
DEBIAN_FRONTEND: noninteractive
MAKEFLAGS: -j 3
script:
- apt-get -qy update >/dev/null
- apt-get -qy install libdbus-1-dev libbluetooth-dev libnl-genl-3-dev libibverbs-dev libssl-dev >/dev/null
- apt-get -qy install flex bison autoconf make clang gcc valgrind >/dev/null
- apt-get -qy install cmake git bc >/dev/null # for build_matrix.sh and build.sh
- apt list --installed 'lib*-dev'
- ./build_matrix.sh

macos_task:
name: macos-aarch64
only_if: $CIRRUS_BRANCH != 'coverity_scan'
macos_instance:
image: ghcr.io/cirruslabs/macos-ventura-xcode:14.1 # macOS 13 with Xcode 14.1
env:
MAKEFLAGS: '-j 4' # macOS VMs run on 4 cores
script:
- brew update >/dev/null
- brew install openssl@3
- ./build_matrix.sh

#
# Just testing for now.
#
windows_task:
name: windows-amd64
only_if: $CIRRUS_BRANCH != 'coverity_scan'
windows_container:
image: cirrusci/windowsservercore:2019
script:
- set/?

coverity_task:
name: Coverity Scan
only_if: $CIRRUS_BRANCH == 'coverity_scan'
container:
image: ubuntu:22.04
cpu: 2
memory: 2G
env:
DEBIAN_FRONTEND: noninteractive
MAKEFLAGS: -j 3
COVERITY_SCAN_PROJECT_NAME: $CIRRUS_REPO_FULL_NAME
COVERITY_SCAN_TOKEN: ENCRYPTED[58bfbfcf624e5b7b85fb9df95dd0b3f9f93642824e6ae94616e4d345af4848580932a6ece02337fee112194b29ce6593]
COVERITY_SCAN_BUILD_COMMAND_PREPEND: ./configure --enable-remote
COVERITY_SCAN_BUILD_COMMAND: make
script:
- apt-get -qy update >/dev/null
- apt-get -qy install libdbus-1-dev libbluetooth-dev libnl-genl-3-dev libibverbs-dev >/dev/null
- apt-get -qy install flex bison autoconf make gcc >/dev/null
- apt-get -qy install git curl wget ruby rubygems ruby-json >/dev/null # for the coverity script
- apt list --installed 'lib*-dev'
- ./.ci-coverity-scan-build.sh
5 changes: 5 additions & 0 deletions libpcap/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Auto detect text files and perform LF normalization
* text=auto

# things that only make sense on github.com
.github export-ignore
72 changes: 72 additions & 0 deletions libpcap/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
.DS_Store
Makefile
*~
*.o
capturetest
can_set_rfmon_test
CMakeCache.txt
cmake_install.cmake
CMakeFiles/
config.h
config.log
config.cache
config.status
stamp-h
stamp-h.in
autom4te.cache/
.devel
filtertest
findalldevstest
opentest
valgrindtest
reactivatetest
grammar.c
grammar.h
grammar.y
libpcap.a
libpcap.*.dylib
libpcap.pc
libpcap.sl
libpcap.so
libpcap.so.*
libpcap-*.tar.gz
net
os-proto.h
pcap-config
pcap-filter.manmisc
pcap-linktype.manmisc
pcap-savefile.manfile
pcap-tstamp.manmisc
pcap.3pcap
pcap_compile.3pcap
pcap_datalink.3pcap
pcap_dump_open.3pcap
pcap_get_tstamp_precision.3pcap
pcap_list_datalinks.3pcap
pcap_list_tstamp_types.3pcap
pcap_open_dead.3pcap
pcap_open_offline.3pcap
pcap_set_immediate_mode.3pcap
pcap_set_tstamp_precision.3pcap
pcap_set_tstamp_type.3pcap
scanner.c
scanner.c.bottom
scanner.h
selpolltest
*.log
*.tlog
*.obj
*.sdf
*.opensdf
*.suo
*.pdb
*.lib
*.dll
*.exp
*.vcxproj.user
Debug/
Release/
msdos/.depend.dj
msdos/bin2c.exe
msdos/pkt_rx1.lst
msdos/pkt_stub.inc
28 changes: 28 additions & 0 deletions libpcap/.mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Assar Westerlund <assar@sics.se> assar <assar>
Bill Fenner <fenner@gmail.com> fenner <fenner>
Denis Ovsienko <denis@ovsienko.info> <infrastation@yandex.ru>
Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> fxlb <fx.lebail@yahoo.com>
Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> <fx.lebail@yahoo.com>
Fulvio Risso <risso@polito.it> risso <risso>
Gianluca Varenni <gianluca.varenni@gmail.com> gianluca <gianluca>
Guy Harris <gharris@sonic.net> <gharris@localhost.localdomain>
Guy Harris <gharris@sonic.net> <gharris@steve.local>
Guy Harris <gharris@sonic.net> <gharris@ubu9-10.(none)>
Guy Harris <gharris@sonic.net> <guy@alum.mit.edu>
Guy Harris <gharris@sonic.net> Guy (Core OS) Harris <gharris@gharris.apple.com>
Guy Harris <gharris@sonic.net> guy <guy>
Hannes Gredler <hannes@gredler.at> hannes <hannes>
Hannes Gredler <hannes@gredler.at> <hannes@juniper.net>
Jun-ichiro itojun Hagino <itojun@iijlab.net> itojun <itojun>
Ken Hornstein <kenh@cmf.nrl.navy.mil> kenh <kenh>
Loris Degioanni <loris@netgroup-serv.polito.it> loris <loris>
Michael Richardson <mcr@sandelman.ca> <mcr@credil.org>
Michael Richardson <mcr@sandelman.ca> <mcr@finepoint.com>
Michael Richardson <mcr@sandelman.ca> mcr <mcr>
Michael Richardson <mcr@sandelman.ca> <mcr@sandelman.ottawa.on.ca>
Michael Richardson <mcr@sandelman.ca> <mcr@tcpdump.org>
Stephen Donnelly <stephen.donnelly@emulex.com> <sfd@nzhmlwks0033.(none)>
Stephen Donnelly <stephen.donnelly@emulex.com> sfd <stephen.donnelly@emulex.com>
Stephen Donnelly <stephen.donnelly@emulex.com> sfd <stephen.donnelly@endace.com>
Stephen Donnelly <stephen.donnelly@emulex.com> <stephen.donnelly@endace.com>
Torsten Landschoff <t.landschoff@gmx.net> torsten <torsten>
Loading

0 comments on commit b6e7f19

Please sign in to comment.