├── .appveyor.yml ├── .ci-coverity-scan-build.sh ├── .cirrus.yml ├── .gitattributes ├── .gitignore ├── .mailmap ├── CHANGES ├── CMakeLists.txt ├── CONTRIBUTING.md ├── CREDITS ├── ChmodBPF ├── ChmodBPF └── StartupParameters.plist ├── INSTALL.md ├── LICENSE ├── Makefile-devel-adds ├── Makefile.in ├── README.md ├── VERSION ├── aclocal.m4 ├── autogen.sh ├── bpf_dump.c ├── bpf_filter.c ├── bpf_image.c ├── build.sh ├── build_common.sh ├── build_matrix.sh ├── cbpf-savefile.manfile.in ├── charconv.c ├── charconv.h ├── chmod_bpf ├── cmake ├── Modules │ ├── FindDAG.cmake │ ├── FindFseeko.cmake │ ├── FindLFS.cmake │ ├── FindPacket.cmake │ ├── FindSNF.cmake │ └── Finddpdk.cmake └── have_siocglifconf.c ├── cmake_uninstall.cmake.in ├── cmakeconfig.h.in ├── config.guess ├── config.sub ├── configure.ac ├── diag-control.h ├── dlpisubs.c ├── dlpisubs.h ├── doc ├── README.aix ├── README.capture-module ├── README.dag.md ├── README.haiku.md ├── README.hpux ├── README.hurd.md ├── README.linux ├── README.macos ├── README.snf.md ├── README.solaris.md └── README.windows.md ├── etherent.c ├── ethertype.h ├── extract.h ├── fad-getad.c ├── fad-gifc.c ├── fad-glifc.c ├── fmtutils.c ├── fmtutils.h ├── ftmacros.h ├── gencode.c ├── gencode.h ├── grammar.y.in ├── ieee80211.h ├── install-sh ├── instrument-functions.c ├── libpcap.pc.in ├── llc.h ├── missing ├── asprintf.c ├── getopt.c ├── getopt.h ├── strlcat.c ├── strlcpy.c ├── strtok_r.c └── win_asprintf.c ├── mkdep ├── nametoaddr.c ├── nametoaddr.h ├── nomkdep ├── optimize.c ├── optimize.h ├── org.tcpdump.chmod_bpf.plist ├── pcap-bpf.c ├── pcap-bpf.h ├── pcap-bt-linux.c ├── pcap-bt-linux.h ├── pcap-bt-monitor-linux.c ├── pcap-bt-monitor-linux.h ├── pcap-common.c ├── pcap-common.h ├── pcap-config.1 ├── pcap-config.in ├── pcap-dag.c ├── pcap-dag.h ├── pcap-dbus.c ├── pcap-dbus.h ├── pcap-dll.rc ├── pcap-dlpi.c ├── pcap-dpdk.c ├── pcap-dpdk.h ├── pcap-filter.manmisc.in ├── pcap-haiku.c ├── pcap-hurd.c ├── pcap-int.h ├── pcap-libdlpi.c ├── pcap-linktype.manmisc.in ├── pcap-linux.c ├── pcap-namedb.h ├── pcap-netfilter-linux.c ├── pcap-netfilter-linux.h ├── pcap-netmap.c ├── pcap-netmap.h ├── pcap-npf.c ├── pcap-null.c ├── pcap-options.c ├── pcap-rdmasniff.c ├── pcap-rdmasniff.h ├── pcap-rpcap.c ├── pcap-rpcap.h ├── pcap-savefile.manfile.in ├── pcap-snf.c ├── pcap-snf.h ├── pcap-tstamp.manmisc.in ├── pcap-types.h ├── pcap-usb-linux-common.h ├── pcap-usb-linux.c ├── pcap-usb-linux.h ├── pcap-util.c ├── pcap-util.h ├── pcap.3pcap.in ├── pcap.c ├── pcap.h ├── pcap ├── bluetooth.h ├── bpf.h ├── can_socketcan.h ├── compiler-tests.h ├── dlt.h ├── funcattrs.h ├── ipnet.h ├── namedb.h ├── nflog.h ├── pcap-inttypes.h ├── pcap.h ├── sll.h ├── socket.h ├── usb.h └── vlan.h ├── pcap_activate.3pcap ├── pcap_breakloop.3pcap ├── pcap_can_set_rfmon.3pcap ├── pcap_close.3pcap ├── pcap_compile.3pcap.in ├── pcap_create.3pcap ├── pcap_datalink.3pcap.in ├── pcap_datalink_name_to_val.3pcap ├── pcap_datalink_val_to_name.3pcap ├── pcap_dump.3pcap ├── pcap_dump_close.3pcap ├── pcap_dump_file.3pcap ├── pcap_dump_flush.3pcap ├── pcap_dump_ftell.3pcap ├── pcap_dump_open.3pcap.in ├── pcap_file.3pcap ├── pcap_fileno.3pcap ├── pcap_findalldevs.3pcap ├── pcap_freecode.3pcap ├── pcap_get_required_select_timeout.3pcap ├── pcap_get_selectable_fd.3pcap ├── pcap_get_tstamp_precision.3pcap.in ├── pcap_geterr.3pcap ├── pcap_init.3pcap ├── pcap_inject.3pcap ├── pcap_is_swapped.3pcap ├── pcap_lib_version.3pcap ├── pcap_list_datalinks.3pcap.in ├── pcap_list_tstamp_types.3pcap.in ├── pcap_lookupdev.3pcap ├── pcap_lookupnet.3pcap ├── pcap_loop.3pcap ├── pcap_major_version.3pcap ├── pcap_next_ex.3pcap ├── pcap_offline_filter.3pcap ├── pcap_open_dead.3pcap.in ├── pcap_open_live.3pcap ├── pcap_open_offline.3pcap.in ├── pcap_set_buffer_size.3pcap ├── pcap_set_datalink.3pcap ├── pcap_set_immediate_mode.3pcap.in ├── pcap_set_promisc.3pcap ├── pcap_set_protocol_linux.3pcap ├── pcap_set_rfmon.3pcap ├── pcap_set_snaplen.3pcap ├── pcap_set_timeout.3pcap ├── pcap_set_tstamp_precision.3pcap.in ├── pcap_set_tstamp_type.3pcap.in ├── pcap_setdirection.3pcap ├── pcap_setfilter.3pcap ├── pcap_setnonblock.3pcap ├── pcap_snapshot.3pcap ├── pcap_stats.3pcap ├── pcap_statustostr.3pcap ├── pcap_strerror.3pcap ├── pcap_tstamp_type_name_to_val.3pcap ├── pcap_tstamp_type_val_to_name.3pcap ├── pflog.h ├── portability.h ├── ppp.h ├── rpcap-protocol.c ├── rpcap-protocol.h ├── rpcapd ├── .gitignore ├── CMakeLists.txt ├── Makefile.in ├── config_params.h ├── daemon.c ├── daemon.h ├── fileconf.c ├── fileconf.h ├── log.c ├── log.h ├── org.tcpdump.rpcapd.plist ├── rpcapd-config.manfile.in ├── rpcapd.c ├── rpcapd.h ├── rpcapd.inetd.conf ├── rpcapd.manadmin.in ├── rpcapd.rc ├── rpcapd.socket ├── rpcapd.xinetd.conf ├── rpcapd@.service ├── win32-svc.c └── win32-svc.h ├── savefile.c ├── scanner.l ├── sf-pcap.c ├── sf-pcap.h ├── sf-pcapng.c ├── sf-pcapng.h ├── sockutils.c ├── sockutils.h ├── sslutils.c ├── sslutils.h ├── testprogs ├── .gitignore ├── BPF │ ├── 1.txt │ ├── 2.txt │ ├── 3.txt │ ├── 4.txt │ ├── 5.txt │ ├── 6.txt │ └── 7.txt ├── CMakeLists.txt ├── Makefile.in ├── TESTlib.pm ├── TESTmt.pm ├── TESTrun ├── TESTst.pm ├── activatetest.c ├── can_set_rfmon_test.c ├── capturetest.c ├── filtertest.c ├── findalldevstest-perf.c ├── findalldevstest.c ├── fuzz │ ├── CMakeLists.txt │ ├── fuzz_both.c │ ├── fuzz_both.options │ ├── fuzz_filter.c │ ├── fuzz_filter.options │ ├── fuzz_pcap.c │ ├── fuzz_pcap.options │ ├── fuzz_rclient.c │ ├── fuzz_rserver.c │ └── onefile.c ├── nonblocktest.c ├── opentest.c ├── reactivatetest.c ├── selpolltest.c ├── threadsignaltest.c ├── unix.h ├── valgrindtest.c ├── visopts.py └── writecaptest.c ├── tests ├── filter │ ├── AH-IPcomp-IPv4.pcap │ ├── AH-IPcomp-IPv6.pcap │ ├── ISIS_external_lsp.pcap │ ├── ISIS_p2p_adjacency.pcap │ ├── Network_Join_Nokia_Mobile.pcap │ ├── ah-ipip-ping.pcap │ ├── bacnet-arcnet-linux.pcap │ ├── decnet.pcap │ ├── dhcp-rfc3004.pcap │ ├── geneve.pcap │ ├── http_PPI.pcap │ ├── ipv6_ah_modes.pcap │ ├── ipv6_ext_headers.pcap │ ├── isakmp4500.pcap │ ├── isup_load_generator.pcap │ ├── loopback.pcap │ ├── pim-packet-assortment.pcap │ ├── pppoe.pcap │ ├── pppoes.pcap │ ├── rarp_req_reply.pcapng │ ├── slip-bad-direction.pcap │ ├── slip-compressed_sl_print-oobr.pcap │ ├── slip-sliplink_print-oobr.pcap │ ├── vrrp.pcap │ ├── vxlan.pcap │ ├── wpa-Induction.pcap │ └── wpa2linkuppassphraseiswireshark.pcap ├── linktype-reserved-field-not-zero.pcap ├── pcap-invalid-version-1.pcap ├── pcap-invalid-version-2.pcap ├── pcapng-invalid-vers-1.pcapng ├── pcapng-invalid-vers-2.pcapng └── shb-option-too-long.pcapng ├── thread-local.h └── varattrs.h /.cirrus.yml: -------------------------------------------------------------------------------- 1 | # The internal git client reads CIRRUS_CLONE_DEPTH. 2 | env: 3 | CIRRUS_CLONE_DEPTH: 3 4 | AUTOCONF_WARNINGS: no-obsolete 5 | 6 | freebsd_task: 7 | name: freebsd-amd64 8 | only_if: $CIRRUS_BRANCH != 'coverity_scan' 9 | freebsd_instance: 10 | cpu: 1 11 | memory: 2G 12 | image_family: freebsd-13-5 13 | env: 14 | IGNORE_OSVERSION: yes 15 | MATRIX_CC: clang17 gcc13 16 | script: 17 | - pkg install -qy autoconf gcc13 llvm17 18 | - pkg install -qy cmake-core git-tiny # for build_matrix.sh and build.sh 19 | - ./build_matrix.sh 20 | 21 | linux_task: 22 | name: linux-amd64 23 | only_if: $CIRRUS_BRANCH != 'coverity_scan' 24 | container: 25 | image: ubuntu:24.04 26 | cpu: 1 27 | memory: 1G 28 | env: 29 | DEBIAN_FRONTEND: noninteractive 30 | LANG: C 31 | script: 32 | - apt-get -qy update >/dev/null 33 | - apt-get -qy install flex bison autoconf make gcc >/dev/null # for "./configure" 34 | - apt-get -qy install cmake git >/dev/null # for "make releasecheck" 35 | - apt-get -qy install shellcheck >/dev/null 36 | - ./autogen.sh 37 | - ./configure --quiet # build the Makefile 38 | - make releasecheck 39 | - make whitespacecheck 40 | - make shellcheck 41 | 42 | macos_task: 43 | name: macos-aarch64 44 | only_if: $CIRRUS_BRANCH != 'coverity_scan' 45 | macos_instance: 46 | image: ghcr.io/cirruslabs/macos-runner:sonoma # last 3 versions of Xcode 47 | env: 48 | MAKEFLAGS: '-j 4' # macOS VMs run on 4 cores 49 | TESTRUN_JOBS: '4' 50 | script: 51 | - brew update >/dev/null 52 | - brew install openssl@3 53 | - ./build_matrix.sh 54 | 55 | coverity_task: 56 | name: Coverity Scan 57 | only_if: $CIRRUS_BRANCH == 'coverity_scan' 58 | container: 59 | image: ubuntu:24.04 60 | cpu: 1 61 | memory: 2G 62 | env: 63 | DEBIAN_FRONTEND: noninteractive 64 | COVERITY_SCAN_PROJECT_NAME: $CIRRUS_REPO_FULL_NAME 65 | COVERITY_SCAN_TOKEN: ENCRYPTED[58bfbfcf624e5b7b85fb9df95dd0b3f9f93642824e6ae94616e4d345af4848580932a6ece02337fee112194b29ce6593] 66 | COVERITY_SCAN_BUILD_COMMAND_PREPEND: ./configure --enable-remote --enable-optimizer-dbg --enable-yydebug 67 | COVERITY_SCAN_BUILD_COMMAND: make 68 | LANG: C 69 | script: 70 | - apt-get -qy update >/dev/null 71 | - apt-get -qy install libdbus-1-dev libbluetooth-dev libnl-genl-3-dev libibverbs-dev libssl-dev >/dev/null 72 | - apt-get -qy install flex bison autoconf make gcc >/dev/null 73 | - apt-get -qy install git curl wget ruby rubygems ruby-json >/dev/null # for the coverity script 74 | - apt list --installed 'lib*-dev' 75 | - ./autogen.sh 76 | - ./.ci-coverity-scan-build.sh 77 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # things that only make sense on github.com 5 | .github export-ignore 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.orig 3 | *.rej 4 | /Makefile 5 | *~ 6 | .*.swo 7 | .*.swp 8 | /*.o 9 | CMakeCache.txt 10 | cmake_install.cmake 11 | CMakeFiles/ 12 | /config.h 13 | /config.h.in 14 | /config.log 15 | /config.cache 16 | /config.status 17 | /configure 18 | /stamp-h 19 | /stamp-h.in 20 | /autom4te.cache/ 21 | /.devel 22 | /grammar.c 23 | /grammar.h 24 | /grammar.y 25 | /libpcap.a 26 | /libpcap.*.dylib 27 | /libpcap.pc 28 | /libpcap.sl 29 | /libpcap.so 30 | /libpcap.so.* 31 | /libpcap.shareda 32 | /libpcap-*.tar.gz 33 | /os-proto.h 34 | /pcap-config 35 | /pcap-filter.manmisc 36 | /pcap-linktype.manmisc 37 | /cbpf-savefile.manfile 38 | /pcap-savefile.manfile 39 | /pcap-tstamp.manmisc 40 | /pcap.3pcap 41 | /pcap_compile.3pcap 42 | /pcap_datalink.3pcap 43 | /pcap_dump_open.3pcap 44 | /pcap_get_tstamp_precision.3pcap 45 | /pcap_list_datalinks.3pcap 46 | /pcap_list_tstamp_types.3pcap 47 | /pcap_open_dead.3pcap 48 | /pcap_open_offline.3pcap 49 | /pcap_set_immediate_mode.3pcap 50 | /pcap_set_tstamp_precision.3pcap 51 | /pcap_set_tstamp_type.3pcap 52 | /scanner.c 53 | /scanner.c.bottom 54 | /scanner.h 55 | *.log 56 | *.tlog 57 | *.obj 58 | *.sdf 59 | *.opensdf 60 | *.suo 61 | *.pdb 62 | *.lib 63 | *.dll 64 | *.exp 65 | *.vcxproj.user 66 | Debug/ 67 | Release/ 68 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Assar Westerlund assar 2 | Bill Fenner fenner 3 | Denis Ovsienko 4 | Francois-Xavier Le Bail fxlb 5 | Francois-Xavier Le Bail 6 | Fulvio Risso risso 7 | Gianluca Varenni gianluca 8 | Guy Harris 9 | Guy Harris 10 | Guy Harris 11 | Guy Harris 12 | Guy Harris Guy (Core OS) Harris 13 | Guy Harris guy 14 | Hannes Gredler hannes 15 | Hannes Gredler 16 | Jun-ichiro itojun Hagino itojun 17 | Ken Hornstein kenh 18 | Loris Degioanni loris 19 | Michael Richardson 20 | Michael Richardson 21 | Michael Richardson mcr 22 | Michael Richardson 23 | Michael Richardson 24 | Stephen Donnelly 25 | Stephen Donnelly sfd 26 | Stephen Donnelly sfd 27 | Stephen Donnelly 28 | Torsten Landschoff torsten 29 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Guidelines for contributing 2 | =========================== 3 | 4 | To report a security issue (segfault, buffer overflow, infinite loop, arbitrary 5 | code execution etc), please send an e-mail to security@tcpdump.org, do not use 6 | the bug tracker! 7 | 8 | To report a non-security problem (failure to compile, failure to capture packets 9 | properly, missing support for a network interface type or DLT), please check 10 | first that it reproduces with the latest stable release of libpcap. If it does, 11 | please check that the problem reproduces with the current git master branch of 12 | libpcap. If it does (and it is not a security-related problem, otherwise see 13 | above), please navigate to the 14 | [bug tracker](https://github.com/the-tcpdump-group/libpcap/issues) 15 | and check if the problem has already been reported. If it has not, please open 16 | a new issue and provide the following details: 17 | 18 | * libpcap version (e.g. from `tcpdump --version`, `pcap-config --version` or 19 | `git describe`) 20 | * operating system name and version and any other details that may be relevant 21 | (`uname -a`, compiler name and version, CPU type etc.) 22 | * `configure` or `cmake` flags if any were used 23 | * statement of the problem 24 | * steps to reproduce 25 | 26 | Please note that if you know exactly how to solve the problem and the solution 27 | would not be too intrusive, it would be best to contribute some development time 28 | and open a pull request instead. 29 | 30 | If the proposed changes concern the BPF compiler code, please try to make sure 31 | the code is sufficiently covered with filter tests beforehand and `make check` 32 | passes on all CI-supported platforms as a minimum (this is done automatically 33 | for a pull request). Then with the changes applied the tests should prove that 34 | the resulting filter program has not changed where it is not expected to change, 35 | and has changed in the expected ways where it is supposed to change, also that 36 | the effect of the filter program has not (or has) changed as well. 37 | 38 | Still not sure how to do? Feel free to [subscribe](https://www.tcpdump.org/#mailing-lists) 39 | to the mailing list tcpdump-workers@lists.tcpdump.org and ask! 40 | -------------------------------------------------------------------------------- /ChmodBPF/ChmodBPF: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | . /etc/rc.common 4 | 5 | StartService () 6 | { 7 | # 8 | # Unfortunately, Mac OS X's devfs is based on the old FreeBSD 9 | # one, not the current one, so there's no way to configure it 10 | # to create BPF devices with particular owners or groups. 11 | # This startup item will make it owned by the admin group, 12 | # with permissions rw-rw----, so that anybody in the admin 13 | # group can use programs that capture or send raw packets. 14 | # 15 | # Change this as appropriate for your site, e.g. to make 16 | # it owned by a particular user without changing the permissions, 17 | # so only that user and the super-user can capture or send raw 18 | # packets, or give it the permissions rw-r-----, so that 19 | # only the super-user can send raw packets but anybody in the 20 | # admin group can capture packets. 21 | # 22 | chgrp admin /dev/bpf* 23 | chmod g+rw /dev/bpf* 24 | } 25 | 26 | StopService () 27 | { 28 | return 0; 29 | } 30 | 31 | RestartService () { StartService; } 32 | 33 | RunService "$1" 34 | -------------------------------------------------------------------------------- /ChmodBPF/StartupParameters.plist: -------------------------------------------------------------------------------- 1 | { 2 | Description = "Change BPF permissions"; 3 | Provides = ("ChmodBPF"); 4 | } 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | License: BSD 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | 3. The names of the authors may not be used to endorse or promote 14 | products derived from this software without specific prior 15 | written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 18 | IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | -------------------------------------------------------------------------------- /Makefile-devel-adds: -------------------------------------------------------------------------------- 1 | # 2 | # Auto-regenerate configure script or Makefile when things change. 3 | # From autoconf.info . Works best with GNU Make. 4 | # 5 | ${srcdir}/configure: configure.ac aclocal.m4 6 | (cd ${srcdir} && autoconf) 7 | 8 | # autoheader might not change config.h.in, so touch a stamp file. 9 | ${srcdir}/config.h.in: ${srcdir}/stamp-h.in 10 | ${srcdir}/stamp-h.in: configure.ac aclocal.m4 11 | (cd ${srcdir} && autoheader) 12 | echo timestamp > ${srcdir}/stamp-h.in 13 | 14 | config.h: stamp-h 15 | stamp-h: ${srcdir}/config.h.in config.status 16 | ./config.status 17 | 18 | Makefile: Makefile.in config.status 19 | ./config.status 20 | 21 | config.status: ${srcdir}/configure 22 | ./config.status --recheck 23 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.11.0-PRE-GIT 2 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | : "${AUTORECONF:=autoreconf}" 4 | : "${BUILD_YEAR2038:=no}" 5 | 6 | AUTORECONFVERSION=`$AUTORECONF --version 2>&1 | grep "^autoreconf" | sed 's/.*) *//'` 7 | 8 | maj=`echo "$AUTORECONFVERSION" | cut -d. -f1` 9 | min=`echo "$AUTORECONFVERSION" | cut -d. -f2` 10 | # The minimum required version of autoconf is currently 2.69. 11 | if [ "$maj" = "" ] || [ "$min" = "" ] || \ 12 | [ "$maj" -lt 2 ] || { [ "$maj" -eq 2 ] && [ "$min" -lt 69 ]; }; then 13 | cat >&2 <<-EOF 14 | Please install the 'autoconf' package version 2.69 or later. 15 | If version 2.69 or later is already installed and there is no 16 | autoconf default, it may be necessary to set the AUTORECONF 17 | environment variable to enable the one to use, like: 18 | AUTORECONF=autoreconf-2.69 ./autogen.sh 19 | or 20 | AUTORECONF=autoreconf-2.71 ./autogen.sh 21 | EOF 22 | exit 1 23 | fi 24 | 25 | echo "$AUTORECONF identification: $AUTORECONFVERSION" 26 | 27 | # On Linux, if Autoconf version >= 2.72 and GNU C Library version >= 2.34, 28 | # s/AC_SYS_LARGEFILE/AC_SYS_YEAR2038_RECOMMENDED/ to ensure time_t 29 | # is Y2038-safe. 30 | if [ "$BUILD_YEAR2038" = yes ] && [ "`uname -s`" = Linux ]; then 31 | if [ "$maj" -gt 2 ] || { [ "$maj" -eq 2 ] && [ "$min" -ge 72 ]; }; then 32 | GLIBC_VERSION=`ldd --version|head -1|grep GLIBC|sed 's/.* //'` 33 | maj_glibc=`echo "$GLIBC_VERSION" | cut -d. -f1` 34 | min_glibc=`echo "$GLIBC_VERSION" | cut -d. -f2` 35 | echo "GNU C Library identification: $GLIBC_VERSION" 36 | if [ "$maj_glibc" -gt 2 ] || { [ "$maj_glibc" -eq 2 ] && \ 37 | [ "$min_glibc" -ge 34 ]; }; then 38 | CONFIGURE_AC_NEW="configure.ac.new$$" 39 | sed 's/^AC_SYS_LARGEFILE/AC_SYS_YEAR2038_RECOMMENDED/' \ 40 | "$CONFIGURE_AC_NEW" 41 | cmp -s configure.ac "$CONFIGURE_AC_NEW" || \ 42 | cat "$CONFIGURE_AC_NEW" >configure.ac 43 | rm -f "$CONFIGURE_AC_NEW" 44 | echo 'Setup to ensure time_t is Y2038-safe.' 45 | fi 46 | fi 47 | fi 48 | 49 | # configure.ac is an Autoconf 2.69 file, but it works as expected even with 50 | # Autoconf 2.72. However, in Autoconf versions 2.70 and later obsolete 51 | # construct warnings are enabled by default, which adds varying (depending on 52 | # the branch) amount of noise to the build matrix output, so provide a means 53 | # to silence that. 54 | env ${AUTOCONF_WARNINGS:+WARNINGS="$AUTOCONF_WARNINGS"} "$AUTORECONF" -f 55 | 56 | # Autoconf 2.71 adds a blank line after the final "exit 0" on Linux, but not 57 | # on OpenBSD. Remove this difference to make it easier to compare the result 58 | # of "make releasetar" across different platforms. From sed one-liners: 59 | # "delete all trailing blank lines at end of file (works on all seds)". Don't 60 | # use mktemp(1) because AIX does not have it. 61 | CONFIGURE_NEW="configure.new$$" 62 | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' "$CONFIGURE_NEW" 63 | cmp -s configure "$CONFIGURE_NEW" || cat "$CONFIGURE_NEW" >configure 64 | rm -f "$CONFIGURE_NEW" 65 | -------------------------------------------------------------------------------- /bpf_dump.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1992, 1993, 1994, 1995, 1996 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | */ 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | #include "optimize.h" 28 | 29 | void 30 | bpf_dump(const struct bpf_program *p, int option) 31 | { 32 | const struct bpf_insn *insn; 33 | int i; 34 | int n = p->bf_len; 35 | 36 | insn = p->bf_insns; 37 | if (option > 2) { 38 | printf("%d\n", n); 39 | for (i = 0; i < n; ++insn, ++i) { 40 | printf("%u %u %u %u\n", insn->code, 41 | insn->jt, insn->jf, insn->k); 42 | } 43 | return ; 44 | } 45 | if (option > 1) { 46 | for (i = 0; i < n; ++insn, ++i) 47 | printf("{ 0x%x, %d, %d, 0x%08x },\n", 48 | insn->code, insn->jt, insn->jf, insn->k); 49 | return; 50 | } 51 | for (i = 0; i < n; ++insn, ++i) { 52 | #ifdef BDEBUG 53 | if (i < NBIDS && bids[i] > 0) 54 | printf("[%02d]", bids[i] - 1); 55 | else 56 | printf(" -- "); 57 | #endif 58 | puts(bpf_image(insn, i)); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /charconv.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ 2 | /* 3 | * Copyright (c) 1993, 1994, 1995, 1996, 1997 4 | * The Regents of the University of California. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by the Computer Systems 17 | * Engineering Group at Lawrence Berkeley Laboratory. 18 | * 4. Neither the name of the University nor of the Laboratory may be used 19 | * to endorse or promote products derived from this software without 20 | * specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef charconv_h 36 | #define charconv_h 37 | 38 | #ifdef _WIN32 39 | extern wchar_t *cp_to_utf_16le(UINT codepage, const char *cp_string, DWORD flags); 40 | extern char *utf_16le_to_cp(UINT codepage, const wchar_t *utf16le_string); 41 | extern void utf_8_to_acp_truncated(char *); 42 | #endif 43 | 44 | #endif /* charconv_h */ 45 | -------------------------------------------------------------------------------- /chmod_bpf: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # 4 | # Unfortunately, macOS's devfs is based on the old FreeBSD 5 | # one, not the current one, so there's no way to configure it 6 | # to create BPF devices with particular owners or groups. 7 | # This startup item will make it owned by the admin group, 8 | # with permissions rw-rw----, so that anybody in the admin 9 | # group can use programs that capture or send raw packets. 10 | # 11 | # Change this as appropriate for your site, e.g. to make 12 | # it owned by a particular user without changing the permissions, 13 | # so only that user and the super-user can capture or send raw 14 | # packets, or give it the permissions rw-r-----, so that 15 | # only the super-user can send raw packets but anybody in the 16 | # admin group can capture packets. 17 | # 18 | chgrp admin /dev/bpf* 19 | chmod g+rw /dev/bpf* 20 | -------------------------------------------------------------------------------- /cmake/Modules/FindDAG.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Try to find the Endace DAG library. 3 | # 4 | 5 | # Try to find the header 6 | find_path(DAG_INCLUDE_DIR dagapi.h) 7 | 8 | # 9 | # Try to find the libraries 10 | # 11 | # We assume that if we have libdag we have libdagconf, as they're 12 | # installed at the same time from the same package. 13 | # 14 | find_library(DAG_LIBRARY dag) 15 | find_library(DAGCONF_LIBRARY dagconf) 16 | 17 | # 18 | # Get link information from the _LIBRARY paths. 19 | # 20 | get_link_info_from_library_path(DAG dag) 21 | get_link_info_from_library_path(DAGCONF dagconf) 22 | 23 | include(FindPackageHandleStandardArgs) 24 | find_package_handle_standard_args(DAG 25 | DEFAULT_MSG 26 | DAG_INCLUDE_DIR 27 | DAG_LIBRARY 28 | DAGCONF_LIBRARY 29 | ) 30 | 31 | mark_as_advanced( 32 | DAG_INCLUDE_DIR 33 | DAG_LIBRARY 34 | DAGCONF_LIBRARY 35 | ) 36 | 37 | set(DAG_INCLUDE_DIRS ${DAG_INCLUDE_DIR}) 38 | set(DAG_LIBRARIES ${DAG_LIBRARY} ${DAGCONF_LIBRARY}) 39 | set(DAG_STATIC_LIBRARIES ${DAG_LIBRARY} ${DAGCONF_LIBRARY}) 40 | -------------------------------------------------------------------------------- /cmake/Modules/FindSNF.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Try to find the Myricom SNF library. 3 | # 4 | 5 | # Try to find the header 6 | find_path(SNF_INCLUDE_DIR snf.h /opt/snf) 7 | 8 | # Try to find the library 9 | find_library(SNF_LIBRARY snf /opt/snf) 10 | 11 | # 12 | # Get link information from the _LIBRARY paths. 13 | # 14 | get_link_info_from_library_path(SNF snf) 15 | 16 | include(FindPackageHandleStandardArgs) 17 | find_package_handle_standard_args(SNF 18 | DEFAULT_MSG 19 | SNF_INCLUDE_DIR 20 | SNF_LIBRARY 21 | ) 22 | 23 | mark_as_advanced( 24 | SNF_INCLUDE_DIR 25 | SNF_LIBRARY 26 | ) 27 | 28 | set(SNF_INCLUDE_DIRS ${SNF_INCLUDE_DIR}) 29 | set(SNF_LIBRARIES ${SNF_LIBRARY}) 30 | set(SNF_STATIC_LIBRARIES ${SNF_LIBRARY}) 31 | -------------------------------------------------------------------------------- /cmake/have_siocglifconf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | int main() { 5 | ioctl(0, SIOCGLIFCONF, (char *)0); 6 | } 7 | -------------------------------------------------------------------------------- /cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 3 | endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 4 | 5 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 6 | string(REGEX REPLACE "\n" ";" files "${files}") 7 | foreach(file ${files}) 8 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 9 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 10 | exec_program( 11 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 12 | OUTPUT_VARIABLE rm_out 13 | RETURN_VALUE rm_retval 14 | ) 15 | if(NOT "${rm_retval}" STREQUAL 0) 16 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 17 | endif(NOT "${rm_retval}" STREQUAL 0) 18 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 19 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 20 | endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 21 | endforeach(file) 22 | -------------------------------------------------------------------------------- /dlpisubs.h: -------------------------------------------------------------------------------- 1 | #ifndef dlpisubs_h 2 | #define dlpisubs_h 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /* 9 | * Private data for capturing on DLPI devices. 10 | */ 11 | struct pcap_dlpi { 12 | #ifdef HAVE_LIBDLPI 13 | dlpi_handle_t dlpi_hd; 14 | #endif /* HAVE_LIBDLPI */ 15 | #ifdef DL_HP_RAWDLS 16 | int send_fd; 17 | #endif /* DL_HP_RAWDLS */ 18 | 19 | struct pcap_stat stat; 20 | }; 21 | 22 | /* 23 | * Functions defined by dlpisubs.c. 24 | */ 25 | int pcap_stats_dlpi(pcap_t *, struct pcap_stat *); 26 | int pcap_process_pkts(pcap_t *, pcap_handler, u_char *, int, u_char *, int); 27 | int pcap_process_mactype(pcap_t *, u_int); 28 | #ifdef HAVE_SYS_BUFMOD_H 29 | int pcap_conf_bufmod(pcap_t *, int); 30 | #endif 31 | int pcap_alloc_databuf(pcap_t *); 32 | int strioctl(int, int, int, char *); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /doc/README.capture-module: -------------------------------------------------------------------------------- 1 | This document has moved to https://www.tcpdump.org/libpcap-module-HOWTO.html 2 | -------------------------------------------------------------------------------- /doc/README.haiku.md: -------------------------------------------------------------------------------- 1 | # Compiling and using libpcap on Haiku 2 | 3 | Haiku R1/beta4 and earlier versions do not support packet capture on the 4 | loopback interface. Using this version of libpcap, loopback capture works 5 | since Haiku R1/beta5. Packet timestamping and filtering always occur 6 | in userland. Wireless monitor mode is not supported. The "any" 7 | pseudo-interface is not supported. 8 | [**pcap_set_buffer_size**](https://www.tcpdump.org/manpages/pcap_set_buffer_size.3pcap.html)(3PCAP) 9 | has no effect. 10 | [**pcap_setdirection**](https://www.tcpdump.org/manpages/pcap_setdirection.3pcap.html)(3PCAP) 11 | is not supported. 12 | [**pcap_inject**](https://www.tcpdump.org/manpages/pcap_inject.3pcap.html)(3PCAP) 13 | is not supported. 14 | 15 | The statistics reported by 16 | [**pcap_stats**](https://www.tcpdump.org/manpages/pcap_stats.3pcap.html)(3PCAP) 17 | on Haiku are as follows: 18 | * `ps_recv` is the number of packets successfully delivered by the kernel, 19 | before libpcap applies a filter. 20 | * `ps_drop` is the number of packets rejected by the filter. 21 | * `ps_ifdrop` is the number of packets dropped by the network interface (as 22 | seen via `SIOCGIFSTATS`) since the capture handle became active. 23 | 24 | ## AMD64 R1/beta5 25 | 26 | * Autoconf 2.72 works. 27 | * CMake 3.28.3 works. 28 | * GCC 13.3.0 works. 29 | * Clang 18.1.7 works. 30 | * flex 2.6.4 works. 31 | * bison 3.8.2 works. 32 | 33 | The following command will install respective non-default packages: 34 | ``` 35 | pkgman install cmake llvm18_clang 36 | ``` 37 | 38 | For reference, the tests were done using a system installed from 39 | `haiku-r1beta5-x86_64-anyboot.iso`. 40 | -------------------------------------------------------------------------------- /doc/README.hurd.md: -------------------------------------------------------------------------------- 1 | # Compiling and using libpcap on GNU/Hurd 2 | 3 | libpcap on Hurd currently does not support packet capture on the loopback 4 | network interface. BPF works in kernel only if the filter length is not 5 | greater that 31 BPF instructions and does not use `BPF_MOD` or `BPF_XOR`. 6 | Packet timestamping always occurs in userland. Wireless monitor mode is not 7 | supported. Packet capture sees only packets received on the interface. 8 | [**pcap_set_buffer_size**](https://www.tcpdump.org/manpages/pcap_set_buffer_size.3pcap.html)(3PCAP) 9 | has no effect. 10 | [**pcap_setdirection**](https://www.tcpdump.org/manpages/pcap_setdirection.3pcap.html)(3PCAP) 11 | is not supported. 12 | [**pcap_set_promisc**](https://www.tcpdump.org/manpages/pcap_set_promisc.3pcap.html)(3PCAP) 13 | has no effect. 14 | 15 | ## Debian GNU/Hurd 12 16 | 17 | * flex 2.6.4 and GNU Bison 3.8.2 work. 18 | * CMake 3.25.1 works. 19 | * GCC 12.2.0 and Clang 14.0.6 work. 20 | 21 | For reference, the tests were done using a system installed from the 2023-06-08 22 | snapshot from [here](https://cdimage.debian.org/cdimage/ports/12.0/hurd-i386/). 23 | -------------------------------------------------------------------------------- /doc/README.linux: -------------------------------------------------------------------------------- 1 | Currently, libpcap supports packet capturing on Linux 2.6.27 and later; 2 | earlier versions are not supported. libpcap will not work if the kernel 3 | does not have the packet socket option enabled. 4 | 5 | You must configure 2.6.x kernels with the CONFIG_PACKET_MMAP option for 6 | this protocol. 3.x and later kernels do not require that. 7 | 8 | Note that, by default, libpcap will, if libnl is present, build with it; 9 | it uses libnl to support monitor mode on mac80211 devices. There is a 10 | configuration option to disable building with libnl, but, if that option 11 | is chosen, the monitor-mode APIs (as used by tcpdump's "-I" flag, and as 12 | will probably be used by other applications in the future) won't work 13 | properly on mac80211 devices. 14 | 15 | libnl-tiny can be used when libnl is not available. This works using 16 | Autoconf only and requires the provided libnl-tiny to have sufficient 17 | pkg-config support. 18 | 19 | Linux's run-time linker allows shared libraries to be linked with other 20 | shared libraries, which means that if an older version of a shared 21 | library doesn't require routines from some other shared library, and a 22 | later version of the shared library does require those routines, the 23 | later version of the shared library can be linked with that other shared 24 | library and, if it's otherwise binary-compatible with the older version, 25 | can replace that older version without breaking applications built with 26 | the older version, and without breaking configure scripts or the build 27 | procedure for applications whose configure script doesn't use the 28 | pcap-config script if they build with the shared library. (The build 29 | procedure for applications whose configure scripts use the pcap-config 30 | script if present will not break even if they build with the static 31 | library.) 32 | 33 | Statistics: 34 | Statistics reported by pcap are platform specific. The statistics 35 | reported by pcap_stats on Linux are as follows: 36 | 37 | ps_recv Number of packets that were accepted by the pcap filter 38 | ps_drop Number of packets that had passed filtering but were not 39 | passed on to pcap due to things like buffer shortage, etc. 40 | This is useful because these are packets you are interested in 41 | but won't be reported by, for example, tcpdump output. 42 | -------------------------------------------------------------------------------- /doc/README.solaris.md: -------------------------------------------------------------------------------- 1 | # Compiling libpcap on Solaris and related OSes 2 | 3 | * Autoconf works everywhere. 4 | * Neither Solaris lex nor Solaris yacc are suitable. 5 | * Neither illumos lex nor illumos yacc are suitable. 6 | * Solaris m4 and illumos m4 are suitable. 7 | 8 | ## OmniOS r151054/AMD64 9 | 10 | * flex 2.6.4 and GNU Bison 3.8.2 work. 11 | * CMake 4.0.1 works. 12 | * GCC 14.2.0 and Clang 20.1.2 work. 13 | 14 | ## OmniOS r151052/AMD64 15 | 16 | * flex 2.6.4 and GNU Bison 3.8.2 work. 17 | * CMake 3.30.5 works. 18 | * GCC 14.2.0 and Clang 19.1.2 work. 19 | 20 | ## OmniOS r151046/AMD64 21 | 22 | * flex 2.6.4 and GNU Bison 3.8.2 work. 23 | * CMake 3.26.4 works. 24 | * GCC 12.2.0 and Clang 16.0.4 work. 25 | 26 | ## OpenIndiana 2024.04/AMD64 27 | 28 | * flex 2.6.4 and GNU Bison 3.7.6 work. 29 | * CMake 3.30.2 works. 30 | * GCC 10.5.0, GCC 13.3.0 and Clang 18.1.8 work. 31 | 32 | For reference, the tests were done using a system installed from 33 | `OI-hipster-minimal-20240426.iso` plus the `build-essential` package. 34 | 35 | ## Solaris 11.4.72.176.1/SPARC 36 | * flex 2.6.4 and GNU Bison 3.8.2 work. 37 | * CMake 3.24.0 works. 38 | * Sun C 5.15 works. 39 | * GCC 13.2.0 and Clang 13.0.1 work, but require setting 40 | `PKG_CONFIG_PATH=/usr/lib/64/pkgconfig` 41 | 42 | ## Solaris 11.4.57.144.3/SPARC 43 | 44 | * flex 2.6.4 and GNU Bison 3.8.2 work. 45 | * CMake does not work. 46 | * GCC 12.2.0 and Clang 13.0.1 work. 47 | 48 | ## Solaris 11.4.42.111.0/AMD64 49 | 50 | * flex 2.6.4 and GNU Bison 3.7.3 work. 51 | * CMake 3.21.0 works. 52 | * Clang 11.0, GCC 11.2 and Sun C 5.15 work. 53 | 54 | ## Solaris 11.3/SPARC 55 | 56 | * flex 2.6.4 and GNU Bison 3.7.5 work. 57 | * CMake 3.14.3 works. 58 | * Sun C 5.13, Sun C 5.14 and Sun C 5.15 work; GCC 5.5.0 and GCC 7.3.0 work. 59 | 60 | ## Solaris 10/SPARC 61 | 62 | * libpcap build fails with rpcapd enabled. 63 | * flex 2.6.4 and GNU Bison 3.7.5 work. 64 | * CMake 3.14.3 works. 65 | * Sun C 5.13 works, GCC 5.5.0 works. 66 | 67 | ## Solaris 9 68 | 69 | This version of this OS is not supported because the snprintf(3) implementation 70 | in its libc is not suitable. 71 | -------------------------------------------------------------------------------- /fmtutils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1994, 1995, 1996 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the Computer Systems 16 | * Engineering Group at Lawrence Berkeley Laboratory. 17 | * 4. Neither the name of the University nor of the Laboratory may be used 18 | * to endorse or promote products derived from this software without 19 | * specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef fmtutils_h 35 | #define fmtutils_h 36 | 37 | #include /* we declare varargs functions */ 38 | 39 | #include "pcap/funcattrs.h" 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | void pcapint_fmt_set_encoding(unsigned int); 46 | 47 | void pcapint_fmt_errmsg_for_errno(char *, size_t, int, 48 | PCAP_FORMAT_STRING(const char *), ...) PCAP_PRINTFLIKE(4, 5); 49 | void pcapint_vfmt_errmsg_for_errno(char *, size_t, int, 50 | PCAP_FORMAT_STRING(const char *), va_list) PCAP_PRINTFLIKE(4, 0); 51 | 52 | #ifdef _WIN32 53 | void pcapint_fmt_errmsg_for_win32_err(char *, size_t, DWORD, 54 | PCAP_FORMAT_STRING(const char *), ...) PCAP_PRINTFLIKE(4, 5); 55 | void pcapint_vfmt_errmsg_for_win32_err(char *, size_t, DWORD, 56 | PCAP_FORMAT_STRING(const char *), va_list) PCAP_PRINTFLIKE(4, 0); 57 | #endif 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /libpcap.pc.in: -------------------------------------------------------------------------------- 1 | # 2 | # pkg-config file for libpcap. 3 | # 4 | # These variables come from the configure script, so includedir and 5 | # libdir may be defined in terms of prefix and exec_prefix, so the 6 | # latter must be defined as well. 7 | # 8 | prefix="@prefix@" 9 | exec_prefix="@exec_prefix@" 10 | includedir="@includedir@" 11 | libdir="@libdir@" 12 | 13 | Name: libpcap 14 | Description: Platform-independent network traffic capture library 15 | Version: @PACKAGE_VERSION@ 16 | Requires.private: @REQUIRES_PRIVATE@ 17 | Libs: -L${libdir} @RPATH@ -l@PACKAGE_NAME@ 18 | Libs.private: @LIBS_PRIVATE@ 19 | Cflags: -I${includedir} 20 | -------------------------------------------------------------------------------- /llc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | */ 21 | 22 | /* 23 | * Definitions for information in the LLC header. 24 | */ 25 | 26 | #define LLC_U_FMT 3 27 | #define LLC_GSAP 1 28 | #define LLC_IG 1 /* Individual / Group */ 29 | #define LLC_S_FMT 1 30 | 31 | #define LLC_U_POLL 0x10 32 | #define LLC_IS_POLL 0x0100 33 | #define LLC_XID_FI 0x81 34 | 35 | #define LLC_U_CMD_MASK 0xef 36 | #define LLC_UI 0x03 37 | #define LLC_UA 0x63 38 | #define LLC_DISC 0x43 39 | #define LLC_DM 0x0f 40 | #define LLC_SABME 0x6f 41 | #define LLC_TEST 0xe3 42 | #define LLC_XID 0xaf 43 | #define LLC_FRMR 0x87 44 | 45 | #define LLC_S_CMD_MASK 0x0f 46 | #define LLC_RR 0x0001 47 | #define LLC_RNR 0x0005 48 | #define LLC_REJ 0x0009 49 | 50 | #define LLC_IS_NR(is) (((is) >> 9) & 0x7f) 51 | #define LLC_I_NS(is) (((is) >> 1) & 0x7f) 52 | 53 | /* 54 | * 802.2 LLC SAP values. 55 | */ 56 | 57 | #ifndef LLCSAP_NULL 58 | #define LLCSAP_NULL 0x00 59 | #endif 60 | #ifndef LLCSAP_GLOBAL 61 | #define LLCSAP_GLOBAL 0xff 62 | #endif 63 | #ifndef LLCSAP_8021B_I 64 | #define LLCSAP_8021B_I 0x02 65 | #endif 66 | #ifndef LLCSAP_8021B_G 67 | #define LLCSAP_8021B_G 0x03 68 | #endif 69 | #ifndef LLCSAP_IP 70 | #define LLCSAP_IP 0x06 71 | #endif 72 | #ifndef LLCSAP_PROWAYNM 73 | #define LLCSAP_PROWAYNM 0x0e 74 | #endif 75 | #ifndef LLCSAP_8021D 76 | #define LLCSAP_8021D 0x42 77 | #endif 78 | #ifndef LLCSAP_RS511 79 | #define LLCSAP_RS511 0x4e 80 | #endif 81 | #ifndef LLCSAP_ISO8208 82 | #define LLCSAP_ISO8208 0x7e 83 | #endif 84 | #ifndef LLCSAP_PROWAY 85 | #define LLCSAP_PROWAY 0x8e 86 | #endif 87 | #ifndef LLCSAP_SNAP 88 | #define LLCSAP_SNAP 0xaa 89 | #endif 90 | #ifndef LLCSAP_IPX 91 | #define LLCSAP_IPX 0xe0 92 | #endif 93 | #ifndef LLCSAP_NETBEUI 94 | #define LLCSAP_NETBEUI 0xf0 95 | #endif 96 | #ifndef LLCSAP_ISONS 97 | #define LLCSAP_ISONS 0xfe 98 | #endif 99 | -------------------------------------------------------------------------------- /missing/getopt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Header for the getopt() we supply if the platform doesn't supply it. 3 | */ 4 | extern char *optarg; /* getopt(3) external variables */ 5 | extern int optind, opterr, optreset, optopt; 6 | 7 | extern int getopt(int nargc, char * const *nargv, const char *ostr); 8 | -------------------------------------------------------------------------------- /missing/strlcat.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: strlcat.c,v 1.15 2015/03/02 21:41:08 millert Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1998, 2015 Todd C. Miller 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #include "portability.h" 25 | 26 | /* 27 | * Appends src to string dst of size dsize (unlike strncat, dsize is the 28 | * full size of dst, not space left). At most dsize-1 characters 29 | * will be copied. Always NUL terminates (unless dsize <= strlen(dst)). 30 | * Returns strlen(src) + MIN(dsize, strlen(initial dst)). 31 | * If retval >= dsize, truncation occurred. 32 | */ 33 | size_t 34 | pcapint_strlcat(char * restrict dst, const char * restrict src, size_t dsize) 35 | { 36 | const char *odst = dst; 37 | const char *osrc = src; 38 | size_t n = dsize; 39 | size_t dlen; 40 | 41 | /* Find the end of dst and adjust bytes left but don't go past end. */ 42 | while (n-- != 0 && *dst != '\0') 43 | dst++; 44 | dlen = dst - odst; 45 | n = dsize - dlen; 46 | 47 | if (n-- == 0) 48 | return(dlen + strlen(src)); 49 | while (*src != '\0') { 50 | if (n != 0) { 51 | *dst++ = *src; 52 | n--; 53 | } 54 | src++; 55 | } 56 | *dst = '\0'; 57 | 58 | return(dlen + (src - osrc)); /* count does not include NUL */ 59 | } 60 | -------------------------------------------------------------------------------- /missing/strlcpy.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: strlcpy.c,v 1.12 2015/01/15 03:54:12 millert Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1998, 2015 Todd C. Miller 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #include "portability.h" 25 | 26 | /* 27 | * Copy string src to buffer dst of size dsize. At most dsize-1 28 | * chars will be copied. Always NUL terminates (unless dsize == 0). 29 | * Returns strlen(src); if retval >= dsize, truncation occurred. 30 | */ 31 | size_t 32 | pcapint_strlcpy(char * restrict dst, const char * restrict src, size_t dsize) 33 | { 34 | const char *osrc = src; 35 | size_t nleft = dsize; 36 | 37 | /* Copy as many bytes as will fit. */ 38 | if (nleft != 0) { 39 | while (--nleft != 0) { 40 | if ((*dst++ = *src++) == '\0') 41 | break; 42 | } 43 | } 44 | 45 | /* Not enough room in dst, add NUL and traverse rest of src. */ 46 | if (nleft == 0) { 47 | if (dsize != 0) 48 | *dst = '\0'; /* NUL-terminate dst */ 49 | while (*src++) 50 | ; 51 | } 52 | 53 | return(src - osrc - 1); /* count does not include NUL */ 54 | } 55 | -------------------------------------------------------------------------------- /missing/strtok_r.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1998 Softweyr LLC. All rights reserved. 3 | * 4 | * strtok_r, from Berkeley strtok 5 | * Oct 13, 1998 by Wes Peters 6 | * 7 | * Copyright (c) 1988, 1993 8 | * The Regents of the University of California. All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notices, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notices, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. Neither the name of the University nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND CONTRIBUTORS 23 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWEYR LLC, THE 26 | * REGENTS, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * From: @(#)strtok.c 8.1 (Berkeley) 6/4/93 35 | */ 36 | 37 | #include 38 | 39 | #include "portability.h" 40 | 41 | char * 42 | pcapint_strtok_r(char *s, const char *delim, char **last) 43 | { 44 | char *spanp, *tok; 45 | int c, sc; 46 | 47 | if (s == NULL && (s = *last) == NULL) 48 | return (NULL); 49 | 50 | /* 51 | * Skip (span) leading delimiters (s += strspn(s, delim), sort of). 52 | */ 53 | cont: 54 | c = *s++; 55 | for (spanp = (char *)delim; (sc = *spanp++) != 0;) { 56 | if (c == sc) 57 | goto cont; 58 | } 59 | 60 | if (c == 0) { /* no non-delimiter characters */ 61 | *last = NULL; 62 | return (NULL); 63 | } 64 | tok = s - 1; 65 | 66 | /* 67 | * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). 68 | * Note that delim must have one NUL; we stop if we see that, too. 69 | */ 70 | for (;;) { 71 | c = *s++; 72 | spanp = (char *)delim; 73 | do { 74 | if ((sc = *spanp++) == c) { 75 | if (c == 0) 76 | s = NULL; 77 | else 78 | s[-1] = '\0'; 79 | *last = s; 80 | return (tok); 81 | } 82 | } while (sc != 0); 83 | } 84 | /* NOTREACHED */ 85 | } 86 | -------------------------------------------------------------------------------- /missing/win_asprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "portability.h" 6 | 7 | int 8 | pcapint_vasprintf(char **strp, const char *format, va_list args) 9 | { 10 | int len; 11 | size_t str_size; 12 | char *str; 13 | int ret; 14 | 15 | len = _vscprintf(format, args); 16 | if (len == -1) { 17 | *strp = NULL; 18 | return (-1); 19 | } 20 | str_size = len + 1; 21 | str = malloc(str_size); 22 | if (str == NULL) { 23 | *strp = NULL; 24 | return (-1); 25 | } 26 | ret = vsnprintf(str, str_size, format, args); 27 | if (ret == -1) { 28 | free(str); 29 | *strp = NULL; 30 | return (-1); 31 | } 32 | *strp = str; 33 | /* 34 | * vsnprintf() shouldn't truncate the string, as we have 35 | * allocated a buffer large enough to hold the string, so its 36 | * return value should be the number of characters printed. 37 | */ 38 | return (ret); 39 | } 40 | 41 | int 42 | pcapint_asprintf(char **strp, const char *format, ...) 43 | { 44 | va_list args; 45 | int ret; 46 | 47 | va_start(args, format); 48 | ret = pcapint_vasprintf(strp, format, args); 49 | va_end(args); 50 | return (ret); 51 | } 52 | -------------------------------------------------------------------------------- /nametoaddr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1994, 1996 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the Computer Systems 16 | * Engineering Group at Lawrence Berkeley Laboratory. 17 | * 4. Neither the name of the University nor of the Laboratory may be used 18 | * to endorse or promote products derived from this software without 19 | * specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef nametoaddr_h_ 35 | #define nametoaddr_h_ 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /* 42 | * Routines used for name-or-address-string-to-address resolution 43 | * that are *not* exported to code using libpcap. 44 | */ 45 | extern int pcapint_atodn(const char *, bpf_u_int32 *); 46 | extern int pcapint_atoin(const char *, bpf_u_int32 *); 47 | extern int pcapint_atoan(const char *, uint8_t *); 48 | extern u_char pcapint_xdtoi(const u_char); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif // nametoaddr_h_ 55 | -------------------------------------------------------------------------------- /nomkdep: -------------------------------------------------------------------------------- 1 | #!/bin/sh - 2 | # 3 | # Does nothing; used if we don't have a command-line flag to the compiler 4 | # to get it to generate dependencies. 5 | # 6 | exit 0 7 | -------------------------------------------------------------------------------- /optimize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | */ 21 | 22 | /* 23 | * Some stuff for use when debugging the optimizer. 24 | */ 25 | #ifdef BDEBUG 26 | #define NBIDS 1000 27 | extern int bids[NBIDS]; 28 | #endif 29 | -------------------------------------------------------------------------------- /org.tcpdump.chmod_bpf.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Label 6 | org.tcpdump.chmod_bpf 7 | RunAtLoad 8 | 9 | Program 10 | /usr/local/bin/chmod_bpf 11 | ProgramArguments 12 | 13 | /usr/local/bin/chmod_bpf 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /pcap-bpf.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * This code is derived from the Stanford/CMU enet packet filter, 6 | * (net/enet.c) distributed as part of 4.3BSD, and code contributed 7 | * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 8 | * Berkeley Laboratory. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. All advertising materials mentioning features or use of this software 19 | * must display the following acknowledgement: 20 | * This product includes software developed by the University of 21 | * California, Berkeley and its contributors. 22 | * 4. Neither the name of the University nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 | * SUCH DAMAGE. 37 | */ 38 | 39 | /* 40 | * For backwards compatibility. 41 | * 42 | * Note to OS vendors: do NOT get rid of this file! Some applications 43 | * might expect to be able to include . 44 | */ 45 | #include 46 | -------------------------------------------------------------------------------- /pcap-bt-linux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006 Paolo Abeni (Italy) 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * Bluetooth sniffing API implementation for Linux platform 31 | * By Paolo Abeni 32 | */ 33 | 34 | /* 35 | * Prototypes for Bluetooth-related functions 36 | */ 37 | int bt_findalldevs(pcap_if_list_t *devlistp, char *err_str); 38 | pcap_t *bt_create(const char *device, char *ebuf, int *is_ours); 39 | -------------------------------------------------------------------------------- /pcap-bt-monitor-linux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Michal Labedzki for Tieto Corporation 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | int bt_monitor_findalldevs(pcap_if_list_t *devlistp, char *err_str); 32 | pcap_t *bt_monitor_create(const char *device, char *ebuf, int *is_ours); 33 | -------------------------------------------------------------------------------- /pcap-common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1995, 1996, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * pcap-common.h - common code for pcap and pcapng files 22 | */ 23 | 24 | extern int dlt_to_linktype(int dlt); 25 | 26 | extern int linktype_to_dlt(int linktype); 27 | 28 | extern u_int max_snaplen_for_dlt(int dlt); 29 | -------------------------------------------------------------------------------- /pcap-dag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pcap-dag.h: Packet capture interface for Endace DAG card. 3 | * 4 | * The functionality of this code attempts to mimic that of pcap-linux as much 5 | * as possible. This code is only needed when compiling in the DAG card code 6 | * at the same time as another type of device. 7 | * 8 | * Author: Richard Littin, Sean Irvine ({richard,sean}@reeltwo.com) 9 | */ 10 | 11 | pcap_t *dag_create(const char *, char *, int *); 12 | int dag_findalldevs(pcap_if_list_t *devlistp, char *errbuf); 13 | -------------------------------------------------------------------------------- /pcap-dbus.h: -------------------------------------------------------------------------------- 1 | pcap_t *dbus_create(const char *, char *, int *); 2 | int dbus_findalldevs(pcap_if_list_t *devlistp, char *errbuf); 3 | -------------------------------------------------------------------------------- /pcap-dll.rc: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #include 3 | 4 | VS_VERSION_INFO VERSIONINFO 5 | FILEVERSION PACKAGE_VERSION_DLL 6 | PRODUCTVERSION PACKAGE_VERSION_DLL 7 | FILEFLAGSMASK 0x3fL 8 | FILEOS VOS__WINDOWS32 9 | FILETYPE VFT_DLL 10 | #ifdef _DEBUG 11 | FILEFLAGS 0x1L 12 | #else 13 | FILEFLAGS 0x0L 14 | #endif 15 | BEGIN 16 | BLOCK "StringFileInfo" 17 | BEGIN 18 | BLOCK "040904b0" 19 | BEGIN 20 | VALUE "Comments", "https://github.com/the-tcpdump-group/libpcap/" 21 | VALUE "CompanyName", "The TCPdump Group" 22 | VALUE "FileDescription", "System-Independent Interface for User-Level Packet Capture" 23 | VALUE "FileVersion", PACKAGE_VERSION 24 | VALUE "InternalName", PACKAGE_NAME 25 | VALUE "LegalCopyright", "Copyright (c) The TCPdump Group" 26 | VALUE "LegalTrademarks", "" 27 | VALUE "OriginalFilename", PACKAGE_NAME ".dll" 28 | VALUE "ProductName", "libpcap" 29 | VALUE "ProductVersion", PACKAGE_VERSION 30 | END 31 | END 32 | BLOCK "VarFileInfo" 33 | BEGIN 34 | VALUE "Translation", 0x0, 1200 35 | END 36 | END 37 | -------------------------------------------------------------------------------- /pcap-dpdk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 jingle YANG. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | pcap_t *pcap_dpdk_create(const char *, char *, int *); 28 | int pcap_dpdk_findalldevs(pcap_if_list_t *devlistp, char *errbuf); 29 | -------------------------------------------------------------------------------- /pcap-namedb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1994, 1996 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the Computer Systems 16 | * Engineering Group at Lawrence Berkeley Laboratory. 17 | * 4. Neither the name of the University nor of the Laboratory may be used 18 | * to endorse or promote products derived from this software without 19 | * specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | */ 33 | 34 | /* 35 | * For backwards compatibility. 36 | * 37 | * Note to OS vendors: do NOT get rid of this file! Some applications 38 | * might expect to be able to include . 39 | */ 40 | #include 41 | -------------------------------------------------------------------------------- /pcap-netfilter-linux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Jakub Zawadzki 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /* 32 | * Prototypes for netlink-related functions 33 | */ 34 | int netfilter_findalldevs(pcap_if_list_t *devlistp, char *err_str); 35 | pcap_t *netfilter_create(const char *device, char *ebuf, int *is_ours); 36 | -------------------------------------------------------------------------------- /pcap-netmap.h: -------------------------------------------------------------------------------- 1 | pcap_t *pcap_netmap_create(const char *, char *, int *); 2 | int pcap_netmap_findalldevs(pcap_if_list_t *devlistp, char *errbuf); 3 | -------------------------------------------------------------------------------- /pcap-null.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1994, 1995, 1996 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | */ 21 | 22 | #include 23 | 24 | #include 25 | 26 | #include "pcap-int.h" 27 | 28 | static char nosup[] = "live packet capture not supported on this system"; 29 | 30 | pcap_t * 31 | pcapint_create_interface(const char *device _U_, char *ebuf) 32 | { 33 | (void)pcapint_strlcpy(ebuf, nosup, PCAP_ERRBUF_SIZE); 34 | return (NULL); 35 | } 36 | 37 | int 38 | pcapint_platform_finddevs(pcap_if_list_t *devlistp _U_, char *errbuf _U_) 39 | { 40 | /* 41 | * There are no interfaces on which we can capture. 42 | */ 43 | return (0); 44 | } 45 | 46 | #ifdef _WIN32 47 | int 48 | pcap_lookupnet(const char *device _U_, bpf_u_int32 *netp _U_, 49 | bpf_u_int32 *maskp _U_, char *errbuf) 50 | { 51 | (void)pcapint_strlcpy(errbuf, nosup, PCAP_ERRBUF_SIZE); 52 | return (-1); 53 | } 54 | #endif 55 | 56 | /* 57 | * Libpcap version string. 58 | */ 59 | const char * 60 | pcap_lib_version(void) 61 | { 62 | return (PCAP_VERSION_STRING); 63 | } 64 | -------------------------------------------------------------------------------- /pcap-rdmasniff.h: -------------------------------------------------------------------------------- 1 | pcap_t *rdmasniff_create(const char *device, char *ebuf, int *is_ours); 2 | int rdmasniff_findalldevs(pcap_if_list_t *devlistp, char *err_str); 3 | -------------------------------------------------------------------------------- /pcap-rpcap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1994, 1995, 1996 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the Computer Systems 16 | * Engineering Group at Lawrence Berkeley Laboratory. 17 | * 4. Neither the name of the University nor of the Laboratory may be used 18 | * to endorse or promote products derived from this software without 19 | * specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef pcap_rpcap_h 35 | #define pcap_rpcap_h 36 | 37 | /* 38 | * Internal interfaces for "pcap_open()". 39 | */ 40 | pcap_t *pcap_open_rpcap(const char *source, int snaplen, int flags, 41 | int read_timeout, struct pcap_rmtauth *auth, char *errbuf); 42 | 43 | /* 44 | * Internal interfaces for "pcap_findalldevs_ex()". 45 | */ 46 | int pcap_findalldevs_ex_remote(const char *source, 47 | struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /pcap-snf.h: -------------------------------------------------------------------------------- 1 | pcap_t *snf_create(const char *, char *, int *); 2 | int snf_findalldevs(pcap_if_list_t *devlistp, char *errbuf); 3 | int snf_get_if_flags(const char *, bpf_u_int32 *, char *); 4 | -------------------------------------------------------------------------------- /pcap-types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2009 CACE Technologies, Inc. Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | #ifndef pcap_types_h 32 | #define pcap_types_h 33 | 34 | /* 35 | * Get u_int defined, by hook or by crook. 36 | */ 37 | #ifdef _WIN32 38 | /* 39 | * This defines u_int. 40 | */ 41 | #include 42 | #else /* _WIN32 */ 43 | /* 44 | * This defines u_int, among other types. 45 | */ 46 | #include 47 | #endif 48 | 49 | #endif /* pcap_types_h */ 50 | -------------------------------------------------------------------------------- /pcap-usb-linux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006 Paolo Abeni (Italy) 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * USB sniffing API implementation for Linux platform 31 | * By Paolo Abeni 32 | */ 33 | 34 | /* 35 | * Prototypes for USB-related functions 36 | */ 37 | int usb_findalldevs(pcap_if_list_t *devlistp, char *err_str); 38 | pcap_t *usb_create(const char *device, char *ebuf, int *is_ours); 39 | -------------------------------------------------------------------------------- /pcap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1995, 1996, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the Computer Systems 16 | * Engineering Group at Lawrence Berkeley Laboratory. 17 | * 4. Neither the name of the University nor of the Laboratory may be used 18 | * to endorse or promote products derived from this software without 19 | * specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | */ 33 | 34 | /* 35 | * For backwards compatibility. 36 | * 37 | * Note to OS vendors: do NOT get rid of this file! Many applications 38 | * expect to be able to include , and at least some of them 39 | * go through contortions in their configure scripts to try to detect 40 | * OSes that have "helpfully" moved pcap.h to without 41 | * leaving behind a file. 42 | */ 43 | #include 44 | -------------------------------------------------------------------------------- /pcap/bluetooth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006 Paolo Abeni (Italy) 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * bluetooth data struct 31 | * By Paolo Abeni 32 | */ 33 | 34 | #ifndef lib_pcap_bluetooth_h 35 | #define lib_pcap_bluetooth_h 36 | 37 | #include 38 | 39 | /* 40 | * Header prepended libpcap to each bluetooth h4 frame, 41 | * fields are in network byte order 42 | */ 43 | typedef struct _pcap_bluetooth_h4_header { 44 | uint32_t direction; /* if first bit is set direction is incoming */ 45 | } pcap_bluetooth_h4_header; 46 | 47 | /* 48 | * Header prepended libpcap to each bluetooth linux monitor frame, 49 | * fields are in network byte order 50 | */ 51 | typedef struct _pcap_bluetooth_linux_monitor_header { 52 | uint16_t adapter_id; 53 | uint16_t opcode; 54 | } pcap_bluetooth_linux_monitor_header; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /pcap/ipnet.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * This code is derived from the Stanford/CMU enet packet filter, 6 | * (net/enet.c) distributed as part of 4.3BSD, and code contributed 7 | * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 8 | * Berkeley Laboratory. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. Neither the name of the University nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | */ 34 | 35 | #define IPH_AF_INET 2 /* Matches Solaris's AF_INET */ 36 | #define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */ 37 | 38 | #define IPNET_OUTBOUND 1 39 | #define IPNET_INBOUND 2 40 | -------------------------------------------------------------------------------- /pcap/vlan.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef lib_pcap_vlan_h 31 | #define lib_pcap_vlan_h 32 | 33 | #include 34 | 35 | struct vlan_tag { 36 | uint16_t vlan_tpid; /* ETH_P_8021Q */ 37 | uint16_t vlan_tci; /* VLAN TCI */ 38 | }; 39 | 40 | #define VLAN_TAG_LEN 4 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /pcap_close.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_CLOSE 3PCAP "12 October 2024" 21 | .SH NAME 22 | pcap_close \- close a capture device or savefile 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | void pcap_close(pcap_t *p); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_close () 35 | closes the files associated with 36 | .I p 37 | and deallocates resources. This means that, for example, if 38 | .I p 39 | refers to a savefile that was opened with 40 | .BR pcap_fopen_offline () 41 | or 42 | .BR pcap_fopen_offline_with_tstamp_precision (), 43 | the stream provided to the routine will be closed unless it is 44 | .BR stdin . 45 | .SH SEE ALSO 46 | .BR pcap (3PCAP), 47 | .BR pcap_open_offline (3PCAP) 48 | -------------------------------------------------------------------------------- /pcap_create.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_CREATE 3PCAP "11 March 2025" 21 | .SH NAME 22 | pcap_create \- create a live capture handle 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .nf 30 | .ft B 31 | char errbuf[PCAP_ERRBUF_SIZE]; 32 | .ft 33 | .LP 34 | .ft B 35 | pcap_t *pcap_create(const char *source, char *errbuf); 36 | .ft 37 | .fi 38 | .SH DESCRIPTION 39 | .BR pcap_create () 40 | is used to create a packet capture handle to capture packets on a device 41 | (typically a network interface, see 42 | .BR \%pcap_findalldevs (3PCAP) 43 | for a more detailed explanation). 44 | .I source 45 | is a string that specifies the capture device to open, in this function 46 | .B NULL 47 | means the same as the string "any". 48 | .I errbuf 49 | is a buffer large enough to hold at least 50 | .B PCAP_ERRBUF_SIZE 51 | chars. 52 | .PP 53 | The returned handle must be activated with 54 | .BR pcap_activate (3PCAP) 55 | before packets can be captured 56 | with it; options for the capture, such as promiscuous mode, can be set 57 | on the handle before activating it. 58 | .SH RETURN VALUE 59 | .BR pcap_create () 60 | returns a 61 | .B pcap_t * 62 | on success and 63 | .B NULL 64 | on failure. 65 | If 66 | .B NULL 67 | is returned, 68 | .I errbuf 69 | is filled in with an appropriate error message. 70 | .SH SEE ALSO 71 | .BR pcap (3PCAP) 72 | -------------------------------------------------------------------------------- /pcap_datalink.3pcap.in: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_DATALINK 3PCAP "7 April 2014" 21 | .SH NAME 22 | pcap_datalink \- get the link-layer header type 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | int pcap_datalink(pcap_t *p); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_datalink () 35 | returns the link-layer header type for the live capture or ``savefile'' 36 | specified by 37 | .IR p . 38 | .PP 39 | It must not be called on a pcap descriptor created by 40 | .BR \%pcap_create (3PCAP) 41 | that has not yet been activated by 42 | .BR \%pcap_activate (3PCAP). 43 | .PP 44 | .I https://www.tcpdump.org/linktypes.html 45 | lists the values 46 | .BR pcap_datalink () 47 | can return and describes the packet formats that 48 | correspond to those values. 49 | .PP 50 | Do 51 | .B NOT 52 | assume that the packets for a given capture or ``savefile`` will have 53 | any given link-layer header type, such as 54 | .B DLT_EN10MB 55 | for Ethernet. For example, the "any" device on Linux will have a 56 | link-layer header type of 57 | .B DLT_LINUX_SLL 58 | or 59 | .B DLT_LINUX_SLL2 60 | even if all devices on the system at the time the "any" device is opened 61 | have some other data link type, such as 62 | .B DLT_EN10MB 63 | for Ethernet. 64 | .SH RETURN VALUE 65 | .BR pcap_datalink () 66 | returns the link-layer header type on success and 67 | .B PCAP_ERROR_NOT_ACTIVATED 68 | if called on a capture handle that has been created but not activated. 69 | .SH SEE ALSO 70 | .BR pcap (3PCAP), 71 | .BR pcap_datalink_val_to_name (3PCAP), 72 | .BR pcap_set_datalink (3PCAP), 73 | .BR pcap_list_datalinks (3PCAP), 74 | .BR pcap-linktype (@MAN_MISC_INFO@) 75 | -------------------------------------------------------------------------------- /pcap_datalink_name_to_val.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_DATALINK_NAME_TO_VAL 3PCAP "25 July 2018" 21 | .SH NAME 22 | pcap_datalink_name_to_val \- get the link-layer header type value 23 | corresponding to a header type name 24 | .SH SYNOPSIS 25 | .nf 26 | .ft B 27 | #include 28 | .ft 29 | .LP 30 | .ft B 31 | int pcap_datalink_name_to_val(const char *name); 32 | .ft 33 | .fi 34 | .SH DESCRIPTION 35 | .BR pcap_datalink_name_to_val () 36 | translates a link-layer header type name, which is a 37 | .B DLT_ 38 | name with the 39 | .B DLT_ 40 | removed, to the corresponding link-layer header type value. The 41 | translation is case-insensitive. 42 | .SH RETURN VALUE 43 | .BR pcap_datalink_name_to_val () 44 | returns the type value on success and 45 | .B PCAP_ERROR 46 | if the name is not a known 47 | type name. 48 | .SH SEE ALSO 49 | .BR pcap (3PCAP), 50 | .BR pcap_set_datalink (3PCAP), 51 | .BR pcap_datalink_val_to_name (3PCAP) 52 | -------------------------------------------------------------------------------- /pcap_dump.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_DUMP 3PCAP "8 March 2015" 21 | .SH NAME 22 | pcap_dump \- write a packet to a capture file 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | void pcap_dump(u_char *user, struct pcap_pkthdr *h, 31 | u_char *sp); 32 | .ft 33 | .fi 34 | .SH DESCRIPTION 35 | .BR pcap_dump () 36 | outputs a packet to the ``savefile'' opened with 37 | .BR pcap_dump_open (3PCAP). 38 | Note that its calling arguments are suitable for use with 39 | .BR pcap_dispatch (3PCAP) 40 | or 41 | .BR pcap_loop (3PCAP). 42 | If called directly, the 43 | .I user 44 | parameter is of type 45 | .B pcap_dumper_t 46 | as returned by 47 | .BR pcap_dump_open (). 48 | .SH SEE ALSO 49 | .BR pcap (3PCAP) 50 | -------------------------------------------------------------------------------- /pcap_dump_close.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_DUMP_CLOSE 3PCAP "12 October 2024" 21 | .SH NAME 22 | pcap_dump_close \- close a savefile being written to 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | void pcap_dump_close(pcap_dumper_t *p); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_dump_close () 35 | closes the ``savefile'' associated with 36 | .I p 37 | and deallocates resources. This means that, for example, if 38 | .I p 39 | refers to a savefile that was opened with 40 | .BR pcap_dump_fopen (), 41 | the stream provided to that routine will be closed unless it is 42 | .BR stdout . 43 | .SH SEE ALSO 44 | .BR pcap (3PCAP), 45 | .BR pcap_dump_open (3PCAP), 46 | .BR pcap_dump (3PCAP) 47 | -------------------------------------------------------------------------------- /pcap_dump_file.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_DUMP_FILE 3PCAP "3 January 2014" 21 | .SH NAME 22 | pcap_dump_file \- get the standard I/O stream for a savefile being written 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | FILE *pcap_dump_file(pcap_dumper_t *p); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_dump_file () 35 | returns the standard I/O stream of the ``savefile'' opened by 36 | .BR pcap_dump_open (3PCAP). 37 | .SH SEE ALSO 38 | .BR pcap (3PCAP) 39 | -------------------------------------------------------------------------------- /pcap_dump_flush.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_DUMP_FLUSH 3PCAP "25 July 2018" 21 | .SH NAME 22 | pcap_dump_flush \- flush to a savefile packets dumped 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | int pcap_dump_flush(pcap_dumper_t *p); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_dump_flush () 35 | flushes the output buffer to the ``savefile'', so that any packets 36 | written with 37 | .BR pcap_dump (3PCAP) 38 | but not yet written to the ``savefile'' will be written. 39 | .SH RETURN VALUE 40 | .BR pcap_dump_flush () 41 | returns 42 | .B 0 43 | on success and 44 | .B PCAP_ERROR 45 | on failure. 46 | .SH SEE ALSO 47 | .BR pcap (3PCAP), 48 | .BR pcap_dump_open (3PCAP) 49 | -------------------------------------------------------------------------------- /pcap_dump_ftell.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_DUMP_FTELL 3PCAP "25 July 2018" 21 | .SH NAME 22 | pcap_dump_ftell, pcap_dump_ftell64 \- get the current file offset for a savefile being written 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | long pcap_dump_ftell(pcap_dumper_t *p); 31 | .ft B 32 | int64_t pcap_dump_ftell64(pcap_dumper_t *p); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .BR pcap_dump_ftell () 37 | returns the current file position for the ``savefile'', representing the 38 | number of bytes written by 39 | .BR pcap_dump_open (3PCAP) 40 | and 41 | .BR pcap_dump (3PCAP). 42 | .B PCAP_ERROR 43 | is returned on error. If the current file position does not fit in a 44 | .BR long , 45 | it will be truncated; this can happen on 32-bit UNIX-like systems with 46 | large file support and on Windows. 47 | .BR pcap_dump_ftell64 () 48 | returns the current file position in a 49 | .BR int64_t , 50 | so if file offsets that don't fit in a 51 | .B long 52 | but that fit in a 53 | .B int64_t 54 | are supported, this will return the file offset without truncation. 55 | .B PCAP_ERROR 56 | is returned on error. 57 | .SH BACKWARD COMPATIBILITY 58 | The function 59 | .BR pcap_dump_ftell64 () 60 | became available in libpcap release 1.9.0. In previous releases, there 61 | was no mechanism to obtain a file offset that is too large to fit in a 62 | .BR long . 63 | .SH SEE ALSO 64 | .BR pcap (3PCAP) 65 | -------------------------------------------------------------------------------- /pcap_file.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_FILE 3PCAP "3 January 2014" 21 | .SH NAME 22 | pcap_file \- get the standard I/O stream for a savefile being read 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | FILE *pcap_file(pcap_t *p); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_file () 35 | returns the standard I/O stream of the ``savefile'', if a ``savefile'' 36 | was opened with 37 | .BR pcap_open_offline (3PCAP), 38 | or 39 | .BR NULL , 40 | if a network device was opened with 41 | .BR pcap_create (3PCAP) 42 | and 43 | .BR \%pcap_activate (3PCAP), 44 | or with 45 | .BR pcap_open_live (3PCAP). 46 | .PP 47 | Note that the Packet Capture library is usually built with large file 48 | support, so the standard I/O stream of the ``savefile'' might refer to 49 | a file larger than 2 gigabytes; applications that use 50 | .BR pcap_file () 51 | should, if possible, use calls that support large files on the return 52 | value of 53 | .BR pcap_file () 54 | or the value returned by 55 | .BR fileno (3) 56 | when passed the return value of 57 | .BR pcap_file (). 58 | .SH SEE ALSO 59 | .BR pcap (3PCAP) 60 | -------------------------------------------------------------------------------- /pcap_fileno.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_FILENO 3PCAP "25 July 2018" 21 | .SH NAME 22 | pcap_fileno \- get the file descriptor for a live capture 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | int pcap_fileno(pcap_t *p); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | If 35 | .I p 36 | refers to a network device that was opened for a live capture using 37 | a combination of 38 | .BR pcap_create (3PCAP) 39 | and 40 | .BR pcap_activate (3PCAP), 41 | or using 42 | .BR pcap_open_live (3PCAP), 43 | .BR pcap_fileno () 44 | returns the file descriptor from which captured packets are read. 45 | .LP 46 | If 47 | .I p 48 | refers to a ``savefile'' that was opened using functions such as 49 | .BR pcap_open_offline (3PCAP) 50 | or 51 | .BR pcap_fopen_offline (3PCAP), 52 | a ``dead'' 53 | .B pcap_t 54 | opened using 55 | .BR pcap_open_dead (3PCAP), 56 | or a 57 | .B pcap_t 58 | that was created with 59 | .BR pcap_create () 60 | but that has not yet been activated with 61 | .BR pcap_activate (), 62 | it returns 63 | .BR PCAP_ERROR . 64 | .SH SEE ALSO 65 | .BR pcap (3PCAP) 66 | -------------------------------------------------------------------------------- /pcap_freecode.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_FREECODE 3PCAP "3 January 2014" 21 | .SH NAME 22 | pcap_freecode \- free a BPF program 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | void pcap_freecode(struct bpf_program *); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_freecode () 35 | is used to free up allocated memory pointed to by a 36 | .I bpf_program 37 | struct generated by 38 | .BR pcap_compile (3PCAP) 39 | when that BPF program is no longer needed, for example after it 40 | has been made the filter program for a pcap structure by a call to 41 | .BR pcap_setfilter (3PCAP). 42 | .SH SEE ALSO 43 | .BR pcap (3PCAP) 44 | -------------------------------------------------------------------------------- /pcap_get_tstamp_precision.3pcap.in: -------------------------------------------------------------------------------- 1 | .\"Copyright (c) 2013, Michal Sekletar 2 | .\"All rights reserved. 3 | .\" 4 | .\"Redistribution and use in source and binary forms, with or without 5 | .\"modification, are permitted provided that the following conditions 6 | .\"are met: 7 | .\" 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in 12 | .\" the documentation and/or other materials provided with the 13 | .\" distribution. 14 | .\" 3. The names of the authors may not be used to endorse or promote 15 | .\" products derived from this software without specific prior 16 | .\" written permission. 17 | .\" 18 | .\"THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 19 | .\"IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 20 | .\"WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | 22 | .TH PCAP_GET_TSTAMP_PRECISION 3PCAP "23 August 2018" 23 | .SH NAME 24 | pcap_get_tstamp_precision \- get the time stamp precision returned in 25 | captures 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .ft 31 | .LP 32 | .ft B 33 | int pcap_get_tstamp_precision(pcap_t *p); 34 | .ft 35 | .fi 36 | .SH DESCRIPTION 37 | .BR pcap_get_tstamp_precision () 38 | returns the precision of the time stamp returned in packet captures on the pcap 39 | descriptor. 40 | .SH RETURN VALUE 41 | .BR pcap_get_tstamp_precision () 42 | returns 43 | .B PCAP_TSTAMP_PRECISION_MICRO 44 | or 45 | .BR PCAP_TSTAMP_PRECISION_NANO , 46 | which indicates 47 | that pcap captures contains time stamps in microseconds or nanoseconds 48 | respectively. 49 | .SH BACKWARD COMPATIBILITY 50 | This function became available in libpcap release 1.5.1. In previous 51 | releases, time stamps from a capture device or savefile are always given 52 | in seconds and microseconds. 53 | .SH SEE ALSO 54 | .BR pcap (3PCAP), 55 | .BR pcap_set_tstamp_precision (3PCAP), 56 | .BR \%pcap-tstamp (@MAN_MISC_INFO@) 57 | -------------------------------------------------------------------------------- /pcap_geterr.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_GETERR 3PCAP "15 January 2016" 21 | .SH NAME 22 | pcap_geterr, pcap_perror \- get or print libpcap error message text 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | char *pcap_geterr(pcap_t *p); 31 | void pcap_perror(pcap_t *p, const char *prefix); 32 | .ft 33 | .fi 34 | .SH DESCRIPTION 35 | .BR pcap_geterr () 36 | returns the error text pertaining to the last pcap library error. 37 | .BR NOTE : 38 | the pointer it returns will no longer point to a valid error message 39 | string after the 40 | .B pcap_t 41 | passed to it is closed; you must use or copy the string before closing 42 | the 43 | .BR pcap_t . 44 | .PP 45 | .BR pcap_perror () 46 | prints the text of the last pcap library error on 47 | .BR stderr , 48 | prefixed by 49 | .IR prefix . 50 | .SH SEE ALSO 51 | .BR pcap (3PCAP), 52 | .BR pcap_strerror (3PCAP) 53 | -------------------------------------------------------------------------------- /pcap_is_swapped.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_IS_SWAPPED 3PCAP "7 April 2014" 21 | .SH NAME 22 | pcap_is_swapped \- find out whether a savefile has the native byte order 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | int pcap_is_swapped(pcap_t *p); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_is_swapped () 35 | returns true (\fB1\fP) if 36 | .I p 37 | refers to a ``savefile'' that uses a different byte order 38 | than the current system. For a live capture, it always returns false 39 | (\fB0\fP). 40 | .PP 41 | It must not be called on a pcap descriptor created by 42 | .BR \%pcap_create (3PCAP) 43 | that has not yet been activated by 44 | .BR \%pcap_activate (3PCAP). 45 | .SH RETURN VALUE 46 | .BR pcap_is_swapped () 47 | returns true (\fB1\fP) or false (\fB0\fP) on success and 48 | .B PCAP_ERROR_NOT_ACTIVATED 49 | if called on a capture handle that has been created but not activated. 50 | .SH SEE ALSO 51 | .BR pcap (3PCAP) 52 | -------------------------------------------------------------------------------- /pcap_lib_version.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_LIB_VERSION 3PCAP "22 December 2024" 21 | .SH NAME 22 | pcap_lib_version \- get the version information for libpcap 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | const char *pcap_lib_version(void); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_lib_version () 35 | returns a pointer to a string giving information about the version of 36 | the libpcap library being used. The string begins with the words "libpcap 37 | version". Then follows the version, which consists of three dot-separated 38 | numbers and the optional "-PRE-GIT" suffix to indicate a development 39 | snapshot, same as in the output of 40 | .B "pcap-config --version" 41 | in sufficiently recent libpcap releases. After the version often follows 42 | additional text to indicate particular features. For example: 43 | .IP "an old release, on any OS" 44 | .RS 45 | .nf 46 | .B 47 | libpcap version 1.5.3 48 | .fi 49 | .RE 50 | .IP "a newer release on a Linux host" 51 | .RS 52 | .nf 53 | .B 54 | libpcap version 1.10.4 (with TPACKET_V3) 55 | .fi 56 | .RE 57 | .IP "the same, built with DAG support only" 58 | .RS 59 | .nf 60 | .B 61 | libpcap version 1.10.4 (DAG-only) 62 | .fi 63 | .RE 64 | .IP "a development snapshot on a FreeBSD host" 65 | .RS 66 | .nf 67 | .B 68 | libpcap version 1.11.0-PRE-GIT (with zerocopy support) 69 | .fi 70 | .RE 71 | .SH SEE ALSO 72 | .BR pcap\-config (1), 73 | .BR pcap (3PCAP) 74 | -------------------------------------------------------------------------------- /pcap_list_datalinks.3pcap.in: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_LIST_DATALINKS 3PCAP "25 July 2018" 21 | .SH NAME 22 | pcap_list_datalinks, pcap_free_datalinks \- get a list of link-layer header 23 | types supported by a capture device, and free that list 24 | .SH SYNOPSIS 25 | .nf 26 | .ft B 27 | #include 28 | .ft 29 | .LP 30 | .ft B 31 | int pcap_list_datalinks(pcap_t *p, int **dlt_buf); 32 | void pcap_free_datalinks(int *dlt_list); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .BR pcap_list_datalinks () 37 | is used to get a list of the supported link-layer header types of the 38 | interface associated with the pcap descriptor. 39 | .BR pcap_list_datalinks () 40 | allocates an array to hold the list and sets 41 | .IR *dlt_buf 42 | to point to that array. 43 | .LP 44 | The caller is responsible for freeing the array with 45 | .BR pcap_free_datalinks (), 46 | which frees the list of link-layer header types pointed to by 47 | .IR dlt_list . 48 | .LP 49 | It must not be called on a pcap descriptor created by 50 | .BR \%pcap_create (3PCAP) 51 | that has not yet been activated by 52 | .BR \%pcap_activate (3PCAP). 53 | .SH RETURN VALUE 54 | .BR pcap_list_datalinks () 55 | returns the number of link-layer header types in the array on success, 56 | .B PCAP_ERROR_NOT_ACTIVATED 57 | if called on a capture handle that has been created but not activated, 58 | and 59 | .B PCAP_ERROR 60 | on other errors. 61 | If 62 | .B PCAP_ERROR 63 | is returned, 64 | .BR pcap_geterr (3PCAP) 65 | or 66 | .BR \%pcap_perror (3PCAP) 67 | may be called with 68 | .I p 69 | as an argument to fetch or display the error text. 70 | .SH SEE ALSO 71 | .BR pcap (3PCAP), 72 | .BR pcap_datalink_val_to_name (3PCAP), 73 | .BR pcap_datalink (3PCAP), 74 | .BR pcap_set_datalink (3PCAP), 75 | .BR pcap-linktype (@MAN_MISC_INFO@) 76 | -------------------------------------------------------------------------------- /pcap_lookupnet.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_LOOKUPNET 3PCAP "31 January 2025" 21 | .SH NAME 22 | pcap_lookupnet \- find the IPv4 network number and netmask for a device 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .nf 30 | .ft B 31 | char errbuf[PCAP_ERRBUF_SIZE]; 32 | .ft 33 | .LP 34 | .ft B 35 | int pcap_lookupnet(const char *device, bpf_u_int32 *netp, 36 | bpf_u_int32 *maskp, char *errbuf); 37 | .ft 38 | .fi 39 | .SH DESCRIPTION 40 | .BR pcap_lookupnet () 41 | is used to determine the IPv4 network number and mask 42 | associated with the network device 43 | .IR device . 44 | Both 45 | .I netp 46 | and 47 | .I maskp 48 | are 49 | .B bpf_u_int32 50 | pointers, on success both values will be set in network byte order. 51 | .I errbuf 52 | is a buffer large enough to hold at least 53 | .B PCAP_ERRBUF_SIZE 54 | chars. 55 | .LP 56 | This function is not available on Windows. It supports neither IPv6 nor 57 | multiple IPv4 addresses per interface, which obviously is not practical in 58 | modern networks. See 59 | .BR pcap_findalldevs (3PCAP) 60 | for a more elaborate solution to the problem. 61 | .SH RETURN VALUE 62 | .BR pcap_lookupnet () 63 | returns 64 | .B 0 65 | on success and 66 | .B PCAP_ERROR 67 | on failure. If 68 | .B PCAP_ERROR 69 | is returned, 70 | .I errbuf 71 | is filled in with an appropriate error message. 72 | .SH SEE ALSO 73 | .BR pcap (3PCAP) 74 | -------------------------------------------------------------------------------- /pcap_major_version.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_MAJOR_VERSION 3PCAP "8 January 2018" 21 | .SH NAME 22 | pcap_major_version, pcap_minor_version \- get the version number of a savefile 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | int pcap_major_version(pcap_t *p); 31 | int pcap_minor_version(pcap_t *p); 32 | .ft 33 | .fi 34 | .SH DESCRIPTION 35 | If 36 | .I p 37 | refers to a ``savefile'', 38 | .BR pcap_major_version () 39 | returns the major number of the file format of the ``savefile'' and 40 | .BR pcap_minor_version () 41 | returns the minor number of the file format of the ``savefile''. The 42 | version number is stored in the ``savefile''; note that the meaning of 43 | its values depends on the type of ``savefile'' (for example, pcap or 44 | pcapng). 45 | .PP 46 | If 47 | .I p 48 | refers to a live capture, the values returned by 49 | .BR pcap_major_version () 50 | and 51 | .BR pcap_minor_version () 52 | are not meaningful. 53 | .SH SEE ALSO 54 | .BR pcap (3PCAP) 55 | -------------------------------------------------------------------------------- /pcap_offline_filter.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_OFFLINE_FILTER 3PCAP "24 January 2025" 21 | .SH NAME 22 | pcap_offline_filter \- check whether a filter matches a packet 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | int pcap_offline_filter(const struct bpf_program *fp, 31 | const struct pcap_pkthdr *h, const u_char *pkt); 32 | .ft 33 | .fi 34 | .SH DESCRIPTION 35 | .BR pcap_offline_filter () 36 | checks whether a filter matches a packet. 37 | .I fp 38 | is a pointer to a 39 | .I bpf_program 40 | struct, usually the result of a call to 41 | .BR pcap_compile (3PCAP). 42 | .I h 43 | points to the 44 | .I pcap_pkthdr 45 | structure for the packet, and 46 | .I pkt 47 | points to the data in the packet. 48 | .PP 49 | The filter program must have been compiled for a link-layer header type 50 | that matches the packet data; also on Linux the filter must not use 51 | BPF extensions, see 52 | .BR \%pcap_compile () 53 | for more information. 54 | .SH RETURN VALUE 55 | .BR pcap_offline_filter () 56 | returns the return value of the filter program. This will be zero if 57 | the packet doesn't match the filter and non-zero if the packet matches 58 | the filter. 59 | .SH SEE ALSO 60 | .BR pcap (3PCAP) 61 | -------------------------------------------------------------------------------- /pcap_set_buffer_size.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_SET_BUFFER_SIZE 3PCAP "3 January 2014" 21 | .SH NAME 22 | pcap_set_buffer_size \- set the buffer size for a not-yet-activated 23 | capture handle 24 | .SH SYNOPSIS 25 | .nf 26 | .ft B 27 | #include 28 | .LP 29 | .ft B 30 | int pcap_set_buffer_size(pcap_t *p, int buffer_size); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_set_buffer_size () 35 | sets the buffer size that will be used on a capture handle when 36 | the handle is activated to 37 | .IR buffer_size , 38 | which is in units of bytes. 39 | .SH RETURN VALUE 40 | .BR pcap_set_buffer_size () 41 | returns 42 | .B 0 43 | on success or 44 | .B PCAP_ERROR_ACTIVATED 45 | if called on a capture handle that has been activated. 46 | .SH SEE ALSO 47 | .BR pcap (3PCAP), 48 | .BR pcap_create (3PCAP), 49 | .BR pcap_activate (3PCAP) 50 | -------------------------------------------------------------------------------- /pcap_set_datalink.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_SET_DATALINK 3PCAP "5 March 2022" 21 | .SH NAME 22 | pcap_set_datalink \- set the link-layer header type to be used by a 23 | capture device 24 | .SH SYNOPSIS 25 | .nf 26 | .ft B 27 | #include 28 | .ft 29 | .LP 30 | .ft B 31 | int pcap_set_datalink(pcap_t *p, int dlt); 32 | .ft 33 | .fi 34 | .SH DESCRIPTION 35 | .BR pcap_set_datalink () 36 | is used to set the current link-layer header type of the pcap descriptor 37 | to the type specified by 38 | .IR dlt . 39 | .SH RETURN VALUE 40 | .BR pcap_set_datalink () 41 | returns 42 | .B 0 43 | on success, 44 | .B PCAP_ERROR_NOT_ACTIVATED 45 | if called on a capture handle that has been created but not activated, or 46 | .B PCAP_ERROR 47 | on other errors. If 48 | .B PCAP_ERROR 49 | is returned, 50 | .BR pcap_geterr (3PCAP) 51 | or 52 | .BR pcap_perror (3PCAP) 53 | may be called with 54 | .I p 55 | as an argument to fetch or display the error text. 56 | .SH SEE ALSO 57 | .BR pcap (3PCAP), 58 | .BR pcap_datalink (3PCAP), 59 | .BR pcap_list_datalinks (3PCAP), 60 | .BR pcap_datalink_name_to_val (3PCAP) 61 | -------------------------------------------------------------------------------- /pcap_set_promisc.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_SET_PROMISC 3PCAP "3 January 2014" 21 | .SH NAME 22 | pcap_set_promisc \- set promiscuous mode for a not-yet-activated 23 | capture handle 24 | .SH SYNOPSIS 25 | .nf 26 | .ft B 27 | #include 28 | .LP 29 | .ft B 30 | int pcap_set_promisc(pcap_t *p, int promisc); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_set_promisc () 35 | sets whether promiscuous mode should be set on a capture handle when 36 | the handle is activated. 37 | If 38 | .I promisc 39 | is non-zero, promiscuous mode will be set, otherwise it will not be set. 40 | .SH RETURN VALUE 41 | .BR pcap_set_promisc () 42 | returns 43 | .B 0 44 | on success or 45 | .B PCAP_ERROR_ACTIVATED 46 | if called on a capture handle that has been activated. 47 | .SH SEE ALSO 48 | .BR pcap (3PCAP), 49 | .BR pcap_create (3PCAP), 50 | .BR pcap_activate (3PCAP) 51 | -------------------------------------------------------------------------------- /pcap_set_rfmon.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_SET_RFMON 3PCAP "3 January 2014" 21 | .SH NAME 22 | pcap_set_rfmon \- set monitor mode for a not-yet-activated capture 23 | handle 24 | .SH SYNOPSIS 25 | .nf 26 | .ft B 27 | #include 28 | .LP 29 | .ft B 30 | int pcap_set_rfmon(pcap_t *p, int rfmon); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_set_rfmon () 35 | sets whether monitor mode should be set on a capture handle when 36 | the handle is activated. 37 | If 38 | .I rfmon 39 | is non-zero, monitor mode will be set, otherwise it will not be set. 40 | .SH RETURN VALUE 41 | .BR pcap_set_rfmon () 42 | returns 43 | .B 0 44 | on success or 45 | .B PCAP_ERROR_ACTIVATED 46 | if called on a capture handle that has been activated. 47 | .SH SEE ALSO 48 | .BR pcap (3PCAP), 49 | .BR pcap_create (3PCAP), 50 | .BR pcap_activate (3PCAP), 51 | .BR pcap_can_set_rfmon (3PCAP) 52 | -------------------------------------------------------------------------------- /pcap_set_snaplen.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_SET_SNAPLEN 3PCAP "3 January 2014" 21 | .SH NAME 22 | pcap_set_snaplen \- set the snapshot length for a not-yet-activated 23 | capture handle 24 | .SH SYNOPSIS 25 | .nf 26 | .ft B 27 | #include 28 | .LP 29 | .ft B 30 | int pcap_set_snaplen(pcap_t *p, int snaplen); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_set_snaplen () 35 | sets the snapshot length to be used on a capture handle when the handle 36 | is activated to 37 | .IR snaplen . 38 | .SH RETURN VALUE 39 | .BR pcap_set_snaplen () 40 | returns 41 | .B 0 42 | on success or 43 | .B PCAP_ERROR_ACTIVATED 44 | if called on a capture handle that has been activated. 45 | .SH SEE ALSO 46 | .BR pcap (3PCAP), 47 | .BR pcap_create (3PCAP), 48 | .BR pcap_activate (3PCAP) 49 | -------------------------------------------------------------------------------- /pcap_set_timeout.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_SET_TIMEOUT 3PCAP "6 December 2017" 21 | .SH NAME 22 | pcap_set_timeout \- set the packet buffer timeout for a 23 | not-yet-activated capture handle 24 | .SH SYNOPSIS 25 | .nf 26 | .ft B 27 | #include 28 | .LP 29 | .ft B 30 | int pcap_set_timeout(pcap_t *p, int to_ms); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_set_timeout () 35 | sets the packet buffer timeout that will be used on a capture handle 36 | when the handle is activated to 37 | .IR to_ms , 38 | which is in units of milliseconds. (See 39 | .BR pcap (3PCAP) 40 | for an explanation of the packet buffer timeout.) 41 | .LP 42 | The behavior, if the timeout isn't specified, is undefined, as is the 43 | behavior if the timeout is set to zero or to a negative value. We 44 | recommend always setting the timeout to a non-zero value unless 45 | immediate mode is set, in which case the timeout has no effect. 46 | .SH RETURN VALUE 47 | .BR pcap_set_timeout () 48 | returns 49 | .B 0 50 | on success or 51 | .B PCAP_ERROR_ACTIVATED 52 | if called on a capture handle that has been activated. 53 | .SH SEE ALSO 54 | .BR pcap_create (3PCAP), 55 | .BR pcap_activate (3PCAP), 56 | .BR \%pcap_set_immediate_mode (3PCAP) 57 | -------------------------------------------------------------------------------- /pcap_set_tstamp_precision.3pcap.in: -------------------------------------------------------------------------------- 1 | .\"Copyright (c) 2013, Michal Sekletar 2 | .\"All rights reserved. 3 | .\" 4 | .\"Redistribution and use in source and binary forms, with or without 5 | .\"modification, are permitted provided that the following conditions 6 | .\"are met: 7 | .\" 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in 12 | .\" the documentation and/or other materials provided with the 13 | .\" distribution. 14 | .\" 3. The names of the authors may not be used to endorse or promote 15 | .\" products derived from this software without specific prior 16 | .\" written permission. 17 | .\" 18 | .\"THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 19 | .\"IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 20 | .\"WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | 22 | .TH PCAP_SET_TSTAMP_PRECISION 3PCAP "23 August 2018" 23 | .SH NAME 24 | pcap_set_tstamp_precision \- set the time stamp precision returned in 25 | captures 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .ft 31 | .LP 32 | .ft B 33 | int pcap_set_tstamp_precision(pcap_t *p, int tstamp_precision); 34 | .ft 35 | .fi 36 | .SH DESCRIPTION 37 | .BR pcap_set_tstamp_precision () 38 | sets the precision of the time stamp desired for packets captured on the pcap 39 | descriptor to the type specified by 40 | .IR tstamp_precision . 41 | It must be called on a pcap descriptor created by 42 | .BR pcap_create (3PCAP) 43 | that has not yet been activated by 44 | .BR pcap_activate (3PCAP). 45 | Two time stamp precisions are supported, microseconds and nanoseconds. One can 46 | use options 47 | .B PCAP_TSTAMP_PRECISION_MICRO 48 | and 49 | .B PCAP_TSTAMP_PRECISION_NANO 50 | to request desired precision. By default, time stamps are in microseconds. 51 | .SH RETURN VALUE 52 | .BR pcap_set_tstamp_precision () 53 | returns 54 | .B 0 55 | on success if the specified time stamp precision is expected to be 56 | supported by the capture device, 57 | .B PCAP_ERROR_TSTAMP_PRECISION_NOTSUP 58 | if the capture device does not support the requested time stamp 59 | precision, 60 | .B PCAP_ERROR_ACTIVATED 61 | if called on a capture handle that has been activated. 62 | .SH BACKWARD COMPATIBILITY 63 | This function became available in libpcap release 1.5.1. In previous 64 | releases, time stamps from a capture device or savefile are always given 65 | in seconds and microseconds. 66 | .SH SEE ALSO 67 | .BR pcap (3PCAP), 68 | .BR pcap_get_tstamp_precision (3PCAP), 69 | .BR pcap_set_tstamp_type (3PCAP), 70 | .BR \%pcap-tstamp (@MAN_MISC_INFO@) 71 | -------------------------------------------------------------------------------- /pcap_setdirection.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_SETDIRECTION 3PCAP "5 March 2022" 21 | .SH NAME 22 | pcap_setdirection \- set the direction for which packets will be captured 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | int pcap_setdirection(pcap_t *p, pcap_direction_t d); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_setdirection () 35 | is used to specify a direction that packets will be captured. 36 | .I d 37 | is one of the constants 38 | .BR PCAP_D_IN , 39 | .B PCAP_D_OUT 40 | or 41 | .BR PCAP_D_INOUT . 42 | .B PCAP_D_IN 43 | will only capture packets received by the device, 44 | .B PCAP_D_OUT 45 | will only capture packets sent by the device and 46 | .B PCAP_D_INOUT 47 | will capture packets received by or sent by the device. 48 | .B PCAP_D_INOUT 49 | is the default setting if this function is not called. 50 | .PP 51 | .BR pcap_setdirection () 52 | isn't necessarily fully supported on all platforms; some platforms might 53 | return an error for all values, and some other platforms might not 54 | support 55 | .BR PCAP_D_OUT . 56 | .PP 57 | This operation is not supported if a ``savefile'' is being read. 58 | .SH RETURN VALUE 59 | .BR pcap_setdirection () 60 | returns 61 | .B 0 62 | on success, 63 | .B PCAP_ERROR_NOT_ACTIVATED 64 | if called on a capture handle that has been created but not activated, or 65 | .B PCAP_ERROR 66 | on other errors. If 67 | .B PCAP_ERROR 68 | is returned, 69 | .BR pcap_geterr (3PCAP) 70 | or 71 | .BR pcap_perror (3PCAP) 72 | may be called with 73 | .I p 74 | as an argument to fetch or display the error text. 75 | .SH SEE ALSO 76 | .BR pcap (3PCAP) 77 | -------------------------------------------------------------------------------- /pcap_setfilter.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_SETFILTER 3PCAP "13 February 2025" 21 | .SH NAME 22 | pcap_setfilter \- set the filter 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | int pcap_setfilter(pcap_t *p, struct bpf_program *fp); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_setfilter () 35 | is used to specify a filter program. 36 | .I fp 37 | is a pointer to a 38 | .I bpf_program 39 | struct, usually the result of a call to 40 | .BR \%pcap_compile (3PCAP). 41 | .PP 42 | If the calls to 43 | .BR \%pcap_compile () 44 | and 45 | .BR \%pcap_setfilter () 46 | use the same 47 | .B pcap_t 48 | handle, packet filtering should either work correctly or fail correctly 49 | without additional efforts. Otherwise the filter program must have been 50 | compiled for the same link-layer header type as the one used by the 51 | .B pcap_t 52 | handle, also on Linux any usage of BPF extensions must match the use case. 53 | Specifically, if the 54 | .B pcap_t 55 | stands for an input savefile, the filter program must not use the extensions, 56 | but if it stands for a live packet capture, the filter program may use the 57 | extensions if necessary. See 58 | .BR pcap_compile () 59 | for more information. 60 | .SH RETURN VALUE 61 | .BR pcap_setfilter () 62 | returns 63 | .B 0 64 | on success, 65 | .B PCAP_ERROR_NOT_ACTIVATED 66 | if called on a capture handle that has been created but not activated, or 67 | .B PCAP_ERROR 68 | on other errors. If 69 | .B PCAP_ERROR 70 | is returned, 71 | .BR pcap_geterr (3PCAP) 72 | or 73 | .BR pcap_perror (3PCAP) 74 | may be called with 75 | .I p 76 | as an argument to fetch or display the error text. 77 | .SH SEE ALSO 78 | .BR pcap (3PCAP) 79 | -------------------------------------------------------------------------------- /pcap_snapshot.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_SNAPSHOT 3PCAP "7 April 2014" 21 | .SH NAME 22 | pcap_snapshot \- get the snapshot length 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | int pcap_snapshot(pcap_t *p); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_snapshot () 35 | returns the snapshot length specified when 36 | .BR pcap_set_snaplen (3PCAP) 37 | or 38 | .BR pcap_open_live (3PCAP) 39 | was called, for a live capture, or the snapshot length from the capture 40 | file, for a ``savefile''. 41 | .PP 42 | It must not be called on a pcap descriptor created by 43 | .BR \%pcap_create (3PCAP) 44 | that has not yet been activated by 45 | .BR \%pcap_activate (3PCAP). 46 | .SH RETURN VALUE 47 | .BR pcap_snapshot () 48 | returns the snapshot length on success and 49 | .B PCAP_ERROR_NOT_ACTIVATED 50 | if called on a capture handle that has been created but not activated. 51 | .SH SEE ALSO 52 | .BR pcap (3PCAP) 53 | -------------------------------------------------------------------------------- /pcap_statustostr.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_STATUSTOSTR 3PCAP "3 January 2014" 21 | .SH NAME 22 | pcap_statustostr \- convert a PCAP_ERROR_ or PCAP_WARNING_ value to a string 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | const char *pcap_statustostr(int error); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | .BR pcap_statustostr () 35 | converts a 36 | .B PCAP_ERROR_ 37 | or 38 | .B PCAP_WARNING_ 39 | value returned by a libpcap routine to an error string. 40 | .SH SEE ALSO 41 | .BR pcap (3PCAP) 42 | -------------------------------------------------------------------------------- /pcap_strerror.3pcap: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1994, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that: (1) source code distributions 6 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 7 | .\" distributions including binary code include the above copyright notice and 8 | .\" this paragraph in its entirety in the documentation or other materials 9 | .\" provided with the distribution, and (3) all advertising materials mentioning 10 | .\" features or use of this software display the following acknowledgement: 11 | .\" ``This product includes software developed by the University of California, 12 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 13 | .\" the University nor the names of its contributors may be used to endorse 14 | .\" or promote products derived from this software without specific prior 15 | .\" written permission. 16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | .\" 20 | .TH PCAP_STRERROR 3PCAP "26 August 2024" 21 | .SH NAME 22 | pcap_strerror \- convert an errno value to a string 23 | .SH SYNOPSIS 24 | .nf 25 | .ft B 26 | #include 27 | .ft 28 | .LP 29 | .ft B 30 | const char *pcap_strerror(int error); 31 | .ft 32 | .fi 33 | .SH DESCRIPTION 34 | This function returns an error message string corresponding to 35 | .IR error . 36 | It uses either 37 | .BR strerror (3) 38 | or its thread-safe variant if one is available, which currently is the case in 39 | every supported OS. 40 | .SH BACKWARD COMPATIBILITY 41 | This function was not thread-safe in libpcap before 1.8.1 on Windows and 42 | in libpcap before 1.10.5 on all other OSes. 43 | .SH SEE ALSO 44 | .BR pcap (3PCAP), 45 | .BR pcap_geterr (3PCAP) 46 | -------------------------------------------------------------------------------- /pcap_tstamp_type_name_to_val.3pcap: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (c) 1994, 1996, 1997 3 | .\" The Regents of the University of California. All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that: (1) source code distributions 7 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 8 | .\" distributions including binary code include the above copyright notice and 9 | .\" this paragraph in its entirety in the documentation or other materials 10 | .\" provided with the distribution, and (3) all advertising materials mentioning 11 | .\" features or use of this software display the following acknowledgement: 12 | .\" ``This product includes software developed by the University of California, 13 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | .\" the University nor the names of its contributors may be used to endorse 15 | .\" or promote products derived from this software without specific prior 16 | .\" written permission. 17 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | .\" 21 | .TH PCAP_TSTAMP_TYPE_NAME_TO_VAL 3PCAP "22 August 2018" 22 | .SH NAME 23 | pcap_tstamp_type_name_to_val \- get the time stamp type value 24 | corresponding to a time stamp type name 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | int pcap_tstamp_type_name_to_val(const char *name); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .BR pcap_tstamp_type_name_to_val () 37 | translates a time stamp type name to the corresponding time stamp type 38 | value. The translation is case-insensitive. 39 | .SH RETURN VALUE 40 | .BR pcap_tstamp_type_name_to_val () 41 | returns time stamp type value on success and 42 | .B PCAP_ERROR 43 | on failure. 44 | .SH BACKWARD COMPATIBILITY 45 | .PP 46 | This function became available in libpcap release 1.2.1. 47 | .SH SEE ALSO 48 | .BR pcap (3PCAP), 49 | .BR pcap_set_tstamp_type (3PCAP), 50 | .BR pcap_tstamp_type_val_to_name (3PCAP) 51 | -------------------------------------------------------------------------------- /pcap_tstamp_type_val_to_name.3pcap: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (c) 1994, 1996, 1997 3 | .\" The Regents of the University of California. All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that: (1) source code distributions 7 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 8 | .\" distributions including binary code include the above copyright notice and 9 | .\" this paragraph in its entirety in the documentation or other materials 10 | .\" provided with the distribution, and (3) all advertising materials mentioning 11 | .\" features or use of this software display the following acknowledgement: 12 | .\" ``This product includes software developed by the University of California, 13 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | .\" the University nor the names of its contributors may be used to endorse 15 | .\" or promote products derived from this software without specific prior 16 | .\" written permission. 17 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | .\" 21 | .TH PCAP_TSTAMP_TYPE_VAL_TO_NAME 3PCAP "22 August 2018" 22 | .SH NAME 23 | pcap_tstamp_type_val_to_name, pcap_tstamp_type_val_to_description \- get 24 | a name or description for a time stamp type value 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | const char *pcap_tstamp_type_val_to_name(int tstamp_type); 33 | const char *pcap_tstamp_type_val_to_description(int tstamp_type); 34 | .ft 35 | .fi 36 | .SH DESCRIPTION 37 | .BR pcap_tstamp_type_val_to_name () 38 | translates a time stamp type value to the corresponding time stamp type 39 | name. 40 | .B NULL 41 | is returned on failure. 42 | .PP 43 | .BR pcap_tstamp_type_val_to_description () 44 | translates a time stamp type value to a short description of that time 45 | stamp type. 46 | .B NULL 47 | is returned on failure. 48 | .SH BACKWARD COMPATIBILITY 49 | .PP 50 | These functions became available in libpcap release 1.2.1. 51 | .SH SEE ALSO 52 | .BR pcap (3PCAP), 53 | .BR pcap_list_tstamp_types (3PCAP), 54 | .BR pcap_tstamp_type_name_to_val (3PCAP) 55 | -------------------------------------------------------------------------------- /ppp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Point to Point Protocol (PPP) RFC1331 3 | * 4 | * Copyright 1989 by Carnegie Mellon. 5 | * 6 | * Permission to use, copy, modify, and distribute this program for any 7 | * purpose and without fee is hereby granted, provided that this copyright 8 | * and permission notice appear on all copies and supporting documentation, 9 | * the name of Carnegie Mellon not be used in advertising or publicity 10 | * pertaining to distribution of the program without specific prior 11 | * permission, and notice be given in supporting documentation that copying 12 | * and distribution is by permission of Carnegie Mellon and Stanford 13 | * University. Carnegie Mellon makes no representations about the 14 | * suitability of this software for any purpose. It is provided "as is" 15 | * without express or implied warranty. 16 | */ 17 | #define PPP_ADDRESS 0xff /* The address byte value */ 18 | #define PPP_CONTROL 0x03 /* The control byte value */ 19 | 20 | #define PPP_PPPD_IN 0x00 /* non-standard for DLT_PPP_PPPD */ 21 | #define PPP_PPPD_OUT 0x01 /* non-standard for DLT_PPP_PPPD */ 22 | 23 | /* Protocol numbers */ 24 | #define PPP_IP 0x0021 /* Raw IP */ 25 | #define PPP_OSI 0x0023 /* OSI Network Layer */ 26 | #define PPP_NS 0x0025 /* Xerox NS IDP */ 27 | #define PPP_DECNET 0x0027 /* DECnet Phase IV */ 28 | #define PPP_APPLE 0x0029 /* Appletalk */ 29 | #define PPP_IPX 0x002b /* Novell IPX */ 30 | #define PPP_VJC 0x002d /* Van Jacobson Compressed TCP/IP */ 31 | #define PPP_VJNC 0x002f /* Van Jacobson Uncompressed TCP/IP */ 32 | #define PPP_BRPDU 0x0031 /* Bridging PDU */ 33 | #define PPP_STII 0x0033 /* Stream Protocol (ST-II) */ 34 | #define PPP_VINES 0x0035 /* Banyan Vines */ 35 | #define PPP_IPV6 0x0057 /* Internet Protocol version 6 */ 36 | 37 | #define PPP_HELLO 0x0201 /* 802.1d Hello Packets */ 38 | #define PPP_LUXCOM 0x0231 /* Luxcom */ 39 | #define PPP_SNS 0x0233 /* Sigma Network Systems */ 40 | #define PPP_MPLS_UCAST 0x0281 /* rfc 3032 */ 41 | #define PPP_MPLS_MCAST 0x0283 /* rfc 3022 */ 42 | 43 | #define PPP_IPCP 0x8021 /* IP Control Protocol */ 44 | #define PPP_OSICP 0x8023 /* OSI Network Layer Control Protocol */ 45 | #define PPP_NSCP 0x8025 /* Xerox NS IDP Control Protocol */ 46 | #define PPP_DECNETCP 0x8027 /* DECnet Control Protocol */ 47 | #define PPP_APPLECP 0x8029 /* Appletalk Control Protocol */ 48 | #define PPP_IPXCP 0x802b /* Novell IPX Control Protocol */ 49 | #define PPP_STIICP 0x8033 /* Stream Protocol Control Protocol */ 50 | #define PPP_VINESCP 0x8035 /* Banyan Vines Control Protocol */ 51 | #define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */ 52 | #define PPP_MPLSCP 0x8281 /* rfc 3022 */ 53 | 54 | #define PPP_LCP 0xc021 /* Link Control Protocol */ 55 | #define PPP_PAP 0xc023 /* Password Authentication Protocol */ 56 | #define PPP_LQM 0xc025 /* Link Quality Monitoring */ 57 | #define PPP_CHAP 0xc223 /* Challenge Handshake Authentication Protocol */ 58 | -------------------------------------------------------------------------------- /rpcapd/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *~ 3 | *.o 4 | rpcapd 5 | rpcapd.manadmin 6 | rpcapd-config.manfile 7 | -------------------------------------------------------------------------------- /rpcapd/config_params.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 - 2003 3 | * NetGroup, Politecnico di Torino (Italy) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef __CONFIG_PARAMS_H__ 34 | #define __CONFIG_PARAMS_H__ 35 | 36 | // 37 | // Parameters set from the configuration file. 38 | // 39 | 40 | #define MAX_LINE 2048 /* Maximum chars allowed for the host list (in passive mode) */ 41 | #define MAX_HOST_LIST 64000 42 | #define MAX_ACTIVE_LIST 10 43 | 44 | struct active_pars 45 | { 46 | char address[MAX_LINE + 1]; // keeps the network address (either numeric or literal) to of the active client 47 | char port[MAX_LINE + 1]; // keeps the network port to bind to 48 | int ai_family; // address family to use 49 | }; 50 | 51 | extern char hostlist[MAX_HOST_LIST + 1]; //!< Keeps the list of the hosts that are allowed to connect to this server 52 | extern struct active_pars activelist[MAX_ACTIVE_LIST]; //!< Keeps the list of the hosts (host, port) on which I want to connect to (active mode) 53 | extern int nullAuthAllowed; //!< '1' if we permit NULL authentication, '0' otherwise 54 | extern char loadfile[MAX_LINE + 1]; //!< Name of the file from which we have to load the configuration 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /rpcapd/daemon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 - 2003 3 | * NetGroup, Politecnico di Torino (Italy) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef __DAEMON_H__ 34 | #define __DAEMON_H__ 35 | 36 | #include 37 | 38 | #include "sslutils.h" 39 | 40 | // 41 | // Returns 1 if the client closed the control connection explicitly, 0 42 | // otherwise; the return value is used only by callers that call us 43 | // for active mode. 44 | // 45 | int daemon_serviceloop(PCAP_SOCKET sockctrl, int isactive, char *passiveClients, 46 | int nullAuthAllowed, char *data_port, int uses_ssl); 47 | 48 | void sleep_secs(int secs); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /rpcapd/fileconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 - 2003 3 | * NetGroup, Politecnico di Torino (Italy) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef __FILECONF_H__ 34 | #define __FILECONF_H__ 35 | 36 | void fileconf_read(void); 37 | int fileconf_save(const char *savefile); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /rpcapd/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1995, 1996, 1998 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | */ 21 | 22 | #include "pcap/funcattrs.h" 23 | 24 | extern void rpcapd_log_set(int, int); 25 | 26 | typedef enum { 27 | LOGPRIO_DEBUG, 28 | LOGPRIO_INFO, 29 | LOGPRIO_WARNING, 30 | LOGPRIO_ERROR 31 | } log_priority; 32 | 33 | extern void rpcapd_log(log_priority priority, 34 | PCAP_FORMAT_STRING(const char *message), ...) PCAP_PRINTFLIKE(2, 3); 35 | -------------------------------------------------------------------------------- /rpcapd/org.tcpdump.rpcapd.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Disabled 6 | 7 | Label 8 | org.tcpdump.rpcapd 9 | Program 10 | /usr/local/libexec/rpcapd 11 | ProgramArguments 12 | 13 | /usr/local/libexec/rpcapd 14 | -i 15 | 16 | Sockets 17 | 18 | Listeners 19 | 20 | SockServiceName 21 | 2002 22 | 23 | 24 | inetdCompatibility 25 | 26 | Wait 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /rpcapd/rpcapd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 - 2003 3 | * NetGroup, Politecnico di Torino (Italy) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef __RPCAPD_H__ 34 | #define __RPCAPD_H__ 35 | 36 | #define PROGRAM_NAME "rpcapd" 37 | #define SOCKET_MAXCONN 10 /* Maximum number of connections queued into the accept() */ 38 | #ifdef _WIN32 39 | void send_shutdown_notification(void); // Send notification to shut down the daemon 40 | void send_reread_configuration_notification(void); // Send notification to re-read the configuration file 41 | #endif 42 | void main_startup(void); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /rpcapd/rpcapd.inetd.conf: -------------------------------------------------------------------------------- 1 | 2002 stream tcp nowait root /usr/local/sbin/rpcapd rpcapd -i 2 | -------------------------------------------------------------------------------- /rpcapd/rpcapd.rc: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #undef PACKAGE_NAME 3 | #include 4 | #include 5 | #define PACKAGE_NAME PROGRAM_NAME 6 | 7 | VS_VERSION_INFO VERSIONINFO 8 | FILEVERSION PACKAGE_VERSION_DLL 9 | PRODUCTVERSION PACKAGE_VERSION_DLL 10 | FILEFLAGSMASK 0x3fL 11 | FILEOS VOS__WINDOWS32 12 | FILETYPE VFT_APP 13 | #ifdef _DEBUG 14 | FILEFLAGS 0x1L 15 | #else 16 | FILEFLAGS 0x0L 17 | #endif 18 | BEGIN 19 | BLOCK "StringFileInfo" 20 | BEGIN 21 | BLOCK "040904b0" 22 | BEGIN 23 | VALUE "Comments", "https://github.com/the-tcpdump-group/libpcap/" 24 | VALUE "CompanyName", "The TCPdump Group" 25 | VALUE "FileDescription", "Remote Packet Capture Daemon" 26 | VALUE "FileVersion", "PACKAGE_VERSION_DLL" 27 | VALUE "InternalName", PACKAGE_NAME 28 | VALUE "LegalCopyright", "Copyright (c) The TCPdump Group" 29 | VALUE "LegalTrademarks", "" 30 | VALUE "OriginalFilename", "rpcapd.exe" 31 | VALUE "ProductName", PACKAGE_NAME 32 | VALUE "ProductVersion", PACKAGE_VERSION 33 | END 34 | END 35 | BLOCK "VarFileInfo" 36 | BEGIN 37 | VALUE "Translation", 0x0, 1200 38 | END 39 | END 40 | -------------------------------------------------------------------------------- /rpcapd/rpcapd.socket: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Rpcap Socket for Per-Connection Servers 3 | 4 | [Socket] 5 | ListenStream=2002 6 | Accept=yes 7 | 8 | [Install] 9 | WantedBy=sockets.target 10 | -------------------------------------------------------------------------------- /rpcapd/rpcapd.xinetd.conf: -------------------------------------------------------------------------------- 1 | service rpcap { 2 | socket_type = stream 3 | protocol = tcp 4 | wait = no 5 | user = root 6 | server = /usr/local/sbin/rpcapd 7 | server_args = -i 8 | } 9 | -------------------------------------------------------------------------------- /rpcapd/rpcapd@.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Rpcap Per-Connection Server 3 | 4 | [Service] 5 | ExecStart=-/usr/local/sbin/rpcapd -i 6 | StandardInput=socket 7 | -------------------------------------------------------------------------------- /rpcapd/win32-svc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 - 2003 3 | * NetGroup, Politecnico di Torino (Italy) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | BOOL svc_start(void); 34 | -------------------------------------------------------------------------------- /sf-pcap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1995, 1996, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * sf-pcap.h - libpcap-file-format-specific routines 22 | * Extraction/creation by Jeffrey Mogul, DECWRL 23 | * Modified by Steve McCanne, LBL. 24 | * 25 | * Used to save the received packet headers, after filtering, to 26 | * a file, and then read them later. 27 | * The first record in the file contains saved values for the machine 28 | * dependent values so we can print the dump file on any architecture. 29 | */ 30 | 31 | #ifndef sf_pcap_h 32 | #define sf_pcap_h 33 | 34 | extern pcap_t *pcap_check_header(const uint8_t *magic, FILE *fp, 35 | u_int precision, char *errbuf, int *err); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /sf-pcapng.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1995, 1996, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * sf-pcapng.h - pcapng-file-format-specific routines 22 | * 23 | * Used to read pcapng savefiles. 24 | */ 25 | 26 | #ifndef sf_pcapng_h 27 | #define sf_pcapng_h 28 | 29 | extern pcap_t *pcap_ng_check_header(const uint8_t *magic, FILE *fp, 30 | u_int precision, char *errbuf, int *err); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /sslutils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 - 2003 3 | * NetGroup, Politecnico di Torino (Italy) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef __SSLUTILS_H__ 34 | #define __SSLUTILS_H__ 35 | 36 | #ifdef HAVE_OPENSSL 37 | #include "pcap/socket.h" // for PCAP_SOCKET 38 | // If this is OpenSSL 1.0, at least one header may trigger a -Wdocumentation 39 | // in Clang, which should not be a problem of this header or a file that 40 | // includes it. 41 | #include "diag-control.h" 42 | DIAG_OFF_DOCUMENTATION 43 | #include 44 | #include 45 | DIAG_ON_DOCUMENTATION 46 | 47 | /* 48 | * Utility functions 49 | */ 50 | 51 | void ssl_set_certfile(const char *certfile); 52 | void ssl_set_keyfile(const char *keyfile); 53 | int ssl_init_once(int is_server, int enable_compression, char *errbuf, size_t errbuflen); 54 | SSL *ssl_promotion(int is_server, PCAP_SOCKET s, char *errbuf, size_t errbuflen); 55 | void ssl_finish(SSL *ssl); 56 | int ssl_send(SSL *, char const *buffer, int size, char *errbuf, size_t errbuflen); 57 | int ssl_recv(SSL *, char *buffer, int size, char *errbuf, size_t errbuflen); 58 | 59 | // The SSL parameters are used 60 | #define _U_NOSSL_ 61 | 62 | #else // HAVE_OPENSSL 63 | 64 | // This saves us from a lot of ifdefs: 65 | #define SSL void const 66 | 67 | // The SSL parameters are unused 68 | #define _U_NOSSL_ _U_ 69 | 70 | #endif // HAVE_OPENSSL 71 | 72 | #endif // __SSLUTILS_H__ 73 | -------------------------------------------------------------------------------- /testprogs/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *~ 3 | *.dSYM 4 | *.o 5 | /activatetest 6 | valgrindtest 7 | capturetest 8 | can_set_rfmon_test 9 | filtertest 10 | findalldevstest 11 | findalldevstest-perf 12 | opentest 13 | reactivatetest 14 | selpolltest 15 | threadsignaltest 16 | writecaptest 17 | nonblocktest 18 | -------------------------------------------------------------------------------- /testprogs/BPF/1.txt: -------------------------------------------------------------------------------- 1 | # common block merging, same block elimination, result propagation 2 | host 192.168.1.1 3 | -------------------------------------------------------------------------------- /testprogs/BPF/2.txt: -------------------------------------------------------------------------------- 1 | # common block merging 2 | port 80 3 | -------------------------------------------------------------------------------- /testprogs/BPF/3.txt: -------------------------------------------------------------------------------- 1 | tcp[tcpflags]&tcp-syn != 0 or tcp[tcpflags]&tcp-fin != 0 or tcp[tcpflags]&tcp-rst != 0 2 | -------------------------------------------------------------------------------- /testprogs/BPF/4.txt: -------------------------------------------------------------------------------- 1 | # or pullup 2 | ether[12:2] = 0x800 or ether[12:2] = 0x8100 or ether[0] & 0x80 != 0 or ether[12:2] = 0x9100 3 | -------------------------------------------------------------------------------- /testprogs/BPF/5.txt: -------------------------------------------------------------------------------- 1 | vlan 186 and ip 2 | -------------------------------------------------------------------------------- /testprogs/BPF/6.txt: -------------------------------------------------------------------------------- 1 | ip and ((icmp and dst host 1.1.1.1 and not host 2.2.2.2) or (host 1.1.1.1 and src host 3.3.3.3)) 2 | -------------------------------------------------------------------------------- /testprogs/BPF/7.txt: -------------------------------------------------------------------------------- 1 | not vlan and tcp port 80 2 | -------------------------------------------------------------------------------- /testprogs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(MSVC) 2 | file(GLOB PROJECT_SOURCE_LIST_WIN32_C ${pcap_SOURCE_DIR}/missing/getopt.c) 3 | include_directories(${pcap_SOURCE_DIR}/missing) 4 | endif(MSVC) 5 | 6 | add_custom_target(testprogs) 7 | 8 | macro(add_test_executable _executable) 9 | add_executable(${_executable} EXCLUDE_FROM_ALL 10 | ${_executable}.c ${PROJECT_SOURCE_LIST_WIN32_C}) 11 | if(NOT C_ADDITIONAL_FLAGS STREQUAL "") 12 | set_target_properties(${_executable} PROPERTIES 13 | COMPILE_FLAGS ${C_ADDITIONAL_FLAGS}) 14 | endif() 15 | if(WIN32) 16 | target_link_libraries(${_executable} 17 | ${ARGN} ${LIBRARY_NAME} ${PCAP_LINK_LIBRARIES}) 18 | else(WIN32) 19 | target_link_libraries(${_executable} 20 | ${ARGN} ${LIBRARY_NAME}_static ${PCAP_LINK_LIBRARIES}) 21 | endif(WIN32) 22 | if(NOT "${LINKER_FLAGS}" STREQUAL "") 23 | set_target_properties(${_executable} PROPERTIES 24 | LINK_FLAGS "${LINKER_FLAGS}") 25 | endif() 26 | add_dependencies(testprogs ${_executable}) 27 | endmacro() 28 | 29 | add_test_executable(activatetest) 30 | add_test_executable(can_set_rfmon_test) 31 | add_test_executable(capturetest) 32 | add_test_executable(filtertest) 33 | add_test_executable(findalldevstest) 34 | add_test_executable(findalldevstest-perf) 35 | add_test_executable(opentest) 36 | add_test_executable(reactivatetest) 37 | add_test_executable(writecaptest) 38 | 39 | if(NOT WIN32) 40 | add_test_executable(selpolltest) 41 | endif() 42 | 43 | add_test_executable(threadsignaltest ${CMAKE_THREAD_LIBS_INIT}) 44 | 45 | # Same as in configure.ac. 46 | if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR 47 | CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR 48 | CMAKE_SYSTEM_NAME STREQUAL "Linux") 49 | add_test_executable(valgrindtest) 50 | endif() 51 | 52 | if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR 53 | CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR 54 | CMAKE_SYSTEM_NAME STREQUAL "Linux") 55 | if(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git) 56 | add_subdirectory(fuzz) 57 | endif(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git) 58 | endif() 59 | -------------------------------------------------------------------------------- /testprogs/TESTmt.pm: -------------------------------------------------------------------------------- 1 | require 5.10.1; # Debian 6 2 | use strict; 3 | use warnings FATAL => qw(uninitialized); 4 | use threads; 5 | use Thread::Queue; 6 | # TESTlib.pm 7 | use subs qw(get_njobs); 8 | 9 | # TESTrun helper functions (multithreaded implementation). 10 | 11 | my $njobs; 12 | my $tmpid; 13 | my @tests; 14 | my @result_queues; 15 | my @tester_threads; 16 | my $next_to_dequeue; 17 | 18 | sub my_tmp_id { 19 | return $tmpid; 20 | } 21 | 22 | # Iterate over the list of tests, pick tests that belong to the current job, 23 | # run one test at a time and send the result to the job's results queue. 24 | sub tester_thread_func { 25 | my $jobid = shift; 26 | $tmpid = sprintf 'job%03u', $jobid; 27 | for (my $i = $jobid; $i < scalar @tests; $i += $njobs) { 28 | my $test = $tests[$i]; 29 | my $result = $test->{func} ($test); 30 | $result->{label} = $test->{label}; 31 | $result_queues[$jobid]->enqueue ($result); 32 | } 33 | # Instead of detaching let the receiver join, this works around File::Temp 34 | # not cleaning up. 35 | # No Thread::Queue->end() in Perl 5.10.1, so use an undef to mark the end. 36 | $result_queues[$jobid]->enqueue (undef); 37 | } 38 | 39 | sub start_tests { 40 | $njobs = get_njobs; 41 | print "INFO: This Perl supports threads, using $njobs tester thread(s).\n"; 42 | @tests = @_; 43 | for (0 .. $njobs - 1) { 44 | $result_queues[$_] = Thread::Queue->new; 45 | $tester_threads[$_] = threads->create (\&tester_thread_func, $_); 46 | } 47 | $next_to_dequeue = 0; 48 | } 49 | 50 | # Here ordering of the results is the same as ordering of the tests because 51 | # this function starts at job 0 and continues round-robin, which reverses the 52 | # interleaving done in the thread function above; also because every attempt 53 | # to dequeue blocks until it returns exactly one result. 54 | sub get_next_result { 55 | for (0 .. $njobs - 1) { 56 | my $jobid = $next_to_dequeue; 57 | $next_to_dequeue = ($next_to_dequeue + 1) % $njobs; 58 | # Skip queues that have already ended. 59 | next unless defined $result_queues[$jobid]; 60 | my $result = $result_queues[$jobid]->dequeue; 61 | # A test result? 62 | return $result if defined $result; 63 | # No, an end-of-queue marker. 64 | $result_queues[$jobid] = undef; 65 | $tester_threads[$jobid]->join; 66 | } 67 | # No results after one complete round, therefore done. 68 | return undef; 69 | } 70 | 71 | 1; 72 | -------------------------------------------------------------------------------- /testprogs/TESTst.pm: -------------------------------------------------------------------------------- 1 | require 5.8.4; # Solaris 10 2 | use strict; 3 | use warnings FATAL => qw(uninitialized); 4 | # TESTlib.pm 5 | use subs qw(get_njobs); 6 | 7 | # TESTrun helper functions (single-threaded implementation). 8 | 9 | my @tests; 10 | 11 | sub my_tmp_id { 12 | return 'main'; 13 | } 14 | 15 | sub start_tests { 16 | print "INFO: This Perl does not support threads.\n"; 17 | my $njobs = get_njobs; 18 | die "ERROR: Impossible to run $njobs tester threads!" if $njobs > 1; 19 | @tests = @_; 20 | } 21 | 22 | # Here ordering of the results is obviously the same as ordering of the tests. 23 | sub get_next_result { 24 | my $test = shift @tests; 25 | return undef unless defined $test; 26 | my $result = $test->{func} ($test); 27 | $result->{label} = $test->{label}; 28 | return $result; 29 | } 30 | 31 | 1; 32 | -------------------------------------------------------------------------------- /testprogs/activatetest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define CAPTURE_DEVICE "nosuchdevice" 5 | 6 | int main(void) 7 | { 8 | /* 9 | * When trying to use libpcap on a device that does not exist, the 10 | * expected behaviour is that pcap_create() does not return an error, 11 | * and pcap_activate() does return an error, and the error code 12 | * specifically tells that the interface does not exist. tcpdump 13 | * depends on this semantics to accept integer indices instead of 14 | * device names. This test provides means to verify the actual 15 | * behaviour, which is specific to each libpcap module. 16 | */ 17 | char errbuf[PCAP_ERRBUF_SIZE]; 18 | printf("Trying to use capture device \"%s\"...\n", CAPTURE_DEVICE); 19 | pcap_t *p = pcap_create(CAPTURE_DEVICE, errbuf); 20 | if (! p) { 21 | fprintf(stderr, 22 | "FAIL: Unexpected error from pcap_create() (%s).\n", 23 | errbuf); 24 | return 1; 25 | } 26 | int ret = 1, err = pcap_activate(p); 27 | switch (err) { 28 | case 0: 29 | fprintf(stderr, "FAIL: No error from pcap_activate().\n"); 30 | break; 31 | case PCAP_ERROR: 32 | fprintf(stderr, "FAIL: Generic error from pcap_activate().\n"); 33 | break; 34 | case PCAP_ERROR_PERM_DENIED: 35 | fprintf(stderr, "FAIL: Permission denied from pcap_activate(), " 36 | "retry with higher privileges.\n"); 37 | break; 38 | case PCAP_ERROR_NO_SUCH_DEVICE: 39 | printf("PASS: Correct specific error from pcap_activate().\n"); 40 | ret = 0; 41 | break; 42 | default: 43 | fprintf(stderr, 44 | "FAIL: Unexpected error %d from pcap_activate().\n", 45 | err); 46 | } 47 | pcap_close(p); 48 | return ret; 49 | } 50 | -------------------------------------------------------------------------------- /testprogs/fuzz/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(fuzz_pcap onefile.c fuzz_pcap.c) 2 | target_link_libraries(fuzz_pcap ${ARGN} ${LIBRARY_NAME}_static ${PCAP_LINK_LIBRARIES}) 3 | if(NOT "${SANITIZER_FLAGS}" STREQUAL "") 4 | set_target_properties(fuzz_pcap PROPERTIES 5 | LINK_FLAGS "${SANITIZER_FLAGS}") 6 | endif() 7 | 8 | add_executable(fuzz_filter onefile.c fuzz_filter.c) 9 | target_link_libraries(fuzz_filter ${ARGN} ${LIBRARY_NAME}_static ${PCAP_LINK_LIBRARIES}) 10 | if(NOT "${SANITIZER_FLAGS}" STREQUAL "") 11 | set_target_properties(fuzz_filter PROPERTIES 12 | LINK_FLAGS "${SANITIZER_FLAGS}") 13 | endif() 14 | 15 | add_executable(fuzz_both onefile.c fuzz_both.c) 16 | target_link_libraries(fuzz_both ${ARGN} ${LIBRARY_NAME}_static ${PCAP_LINK_LIBRARIES}) 17 | if(NOT "${SANITIZER_FLAGS}" STREQUAL "") 18 | set_target_properties(fuzz_both PROPERTIES 19 | LINK_FLAGS "${SANITIZER_FLAGS}") 20 | endif() 21 | 22 | if(ENABLE_REMOTE AND "$ENV{CFLAGS}" MATCHES "-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION") 23 | add_executable(fuzz_rclient onefile.c fuzz_rclient.c) 24 | target_link_libraries(fuzz_rclient ${ARGN} ${LIBRARY_NAME}_static ${PCAP_LINK_LIBRARIES}) 25 | if(NOT "${SANITIZER_FLAGS}" STREQUAL "") 26 | set_target_properties(fuzz_rclient PROPERTIES 27 | LINK_FLAGS "${SANITIZER_FLAGS}") 28 | endif() 29 | 30 | add_executable(fuzz_rserver onefile.c fuzz_rserver.c ../../rpcapd/daemon.c) 31 | check_function_exists(crypt HAVE_CRYPT_IN_SYSTEM_LIBRARIES) 32 | if(HAVE_CRYPT_IN_SYSTEM_LIBRARIES) 33 | set(HAVE_CRYPT TRUE) 34 | else(HAVE_CRYPT_IN_SYSTEM_LIBRARIES) 35 | set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} crypt) 36 | endif(HAVE_CRYPT_IN_SYSTEM_LIBRARIES) 37 | target_link_libraries(fuzz_rserver ${ARGN} ${LIBRARY_NAME}_static ${PCAP_LINK_LIBRARIES}) 38 | 39 | if(NOT "${SANITIZER_FLAGS}" STREQUAL "") 40 | set_target_properties(fuzz_rserver PROPERTIES 41 | LINK_FLAGS "${SANITIZER_FLAGS}") 42 | endif() 43 | endif(ENABLE_REMOTE AND "$ENV{CFLAGS}" MATCHES "-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION") 44 | -------------------------------------------------------------------------------- /testprogs/fuzz/fuzz_both.options: -------------------------------------------------------------------------------- 1 | [libfuzzer] 2 | max_len = 65535 3 | -------------------------------------------------------------------------------- /testprogs/fuzz/fuzz_filter.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | void fuzz_openFile(const char * name){ 8 | //do nothing 9 | } 10 | 11 | int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 12 | pcap_t * pkts; 13 | struct bpf_program bpf; 14 | char * filter; 15 | 16 | //we need at least 1 byte for linktype 17 | if (Size < 1) { 18 | return 0; 19 | } 20 | 21 | //initialize structure snaplen = 65535 22 | pkts = pcap_open_dead(Data[Size-1], 0xFFFF); 23 | if (pkts == NULL) { 24 | printf("pcap_open_dead failed\n"); 25 | return 0; 26 | } 27 | filter = malloc(Size); 28 | memcpy(filter, Data, Size); 29 | //null terminate string 30 | filter[Size-1] = 0; 31 | 32 | if (pcap_compile(pkts, &bpf, filter, 1, PCAP_NETMASK_UNKNOWN) == 0) { 33 | if (pcap_setfilter(pkts, &bpf) < 0) 34 | pcap_perror(pkts, "pcap_setfilter"); 35 | pcap_close(pkts); 36 | pcap_freecode(&bpf); 37 | } 38 | else { 39 | pcap_close(pkts); 40 | } 41 | free(filter); 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /testprogs/fuzz/fuzz_filter.options: -------------------------------------------------------------------------------- 1 | [libfuzzer] 2 | max_len = 4096 3 | -------------------------------------------------------------------------------- /testprogs/fuzz/fuzz_pcap.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | FILE * outfile = NULL; 11 | 12 | static int bufferToFile(const char * name, const uint8_t *Data, size_t Size) { 13 | FILE * fd; 14 | if (remove(name) != 0) { 15 | if (errno != ENOENT) { 16 | printf("failed remove, errno=%d\n", errno); 17 | return -1; 18 | } 19 | } 20 | fd = fopen(name, "wb"); 21 | if (fd == NULL) { 22 | printf("failed open, errno=%d\n", errno); 23 | return -2; 24 | } 25 | if (fwrite (Data, 1, Size, fd) != Size) { 26 | fclose(fd); 27 | return -3; 28 | } 29 | fclose(fd); 30 | return 0; 31 | } 32 | 33 | void fuzz_openFile(const char * name) { 34 | if (outfile != NULL) { 35 | fclose(outfile); 36 | } 37 | outfile = fopen(name, "w"); 38 | } 39 | 40 | int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 41 | pcap_t * pkts; 42 | char errbuf[PCAP_ERRBUF_SIZE]; 43 | char filename[FILENAME_MAX] = { 0 }; 44 | const u_char *pkt; 45 | struct pcap_pkthdr *header; 46 | struct pcap_stat stats; 47 | int fd = -1, r; 48 | 49 | //initialize output file 50 | if (outfile == NULL) { 51 | outfile = fopen("/dev/null", "w"); 52 | if (outfile == NULL) { 53 | return 0; 54 | } 55 | } 56 | 57 | //generate temporary file name 58 | snprintf(filename, FILENAME_MAX, "/tmp/libpcap_fuzz_pcap.XXXXXX"); 59 | if ((fd = mkstemp(filename)) < 0) { 60 | return 0; 61 | } 62 | close(fd); 63 | 64 | //rewrite buffer to a file as libpcap does not have buffer inputs 65 | if (bufferToFile(filename, Data, Size) < 0) { 66 | unlink(filename); 67 | return 0; 68 | } 69 | 70 | //initialize structure 71 | pkts = pcap_open_offline(filename, errbuf); 72 | if (pkts == NULL) { 73 | fprintf(outfile, "Couldn't open pcap file %s\n", errbuf); 74 | unlink(filename); 75 | return 0; 76 | } 77 | 78 | //loop over packets 79 | r = pcap_next_ex(pkts, &header, &pkt); 80 | while (r > 0) { 81 | //TODO pcap_offline_filter 82 | fprintf(outfile, "packet length=%d/%d\n",header->caplen, header->len); 83 | r = pcap_next_ex(pkts, &header, &pkt); 84 | } 85 | if (pcap_stats(pkts, &stats) == 0) { 86 | fprintf(outfile, "number of packets=%d\n", stats.ps_recv); 87 | } 88 | //close structure 89 | pcap_close(pkts); 90 | 91 | unlink(filename); 92 | return 0; 93 | } 94 | -------------------------------------------------------------------------------- /testprogs/fuzz/fuzz_pcap.options: -------------------------------------------------------------------------------- 1 | [libfuzzer] 2 | max_len = 65535 3 | -------------------------------------------------------------------------------- /testprogs/fuzz/fuzz_rclient.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | FILE * outfile = NULL; 9 | struct pcap_rmtauth auth; 10 | 11 | void fuzz_openFile(const char * name) { 12 | if (outfile != NULL) { 13 | fclose(outfile); 14 | } 15 | outfile = fopen(name, "w"); 16 | auth.type = RPCAP_RMTAUTH_PWD; 17 | auth.username = "user"; 18 | auth.password = "pass"; 19 | } 20 | 21 | void sock_initfuzz(const uint8_t *Data, size_t Size); 22 | int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 23 | pcap_t * pkts; 24 | char errbuf[PCAP_ERRBUF_SIZE]; 25 | const u_char *pkt; 26 | struct pcap_pkthdr *header; 27 | struct pcap_stat stats; 28 | int r; 29 | 30 | //initialization 31 | if (outfile == NULL) { 32 | fuzz_openFile("/dev/null"); 33 | } 34 | 35 | sock_initfuzz(Data, Size); 36 | //initialize structure 37 | pkts = pcap_open("rpcap://127.0.0.1/fuzz.pcap", 0, 0, 1000, &auth, errbuf); 38 | if (pkts == NULL) { 39 | fprintf(outfile, "Couldn't open pcap file %s\n", errbuf); 40 | return 0; 41 | } 42 | 43 | //loop over packets 44 | r = pcap_next_ex(pkts, &header, &pkt); 45 | while (r > 0) { 46 | fprintf(outfile, "packet length=%d/%d\n",header->caplen, header->len); 47 | r = pcap_next_ex(pkts, &header, &pkt); 48 | } 49 | if (pcap_stats(pkts, &stats) == 0) { 50 | fprintf(outfile, "number of packets=%d\n", stats.ps_recv); 51 | } 52 | //close structure 53 | pcap_close(pkts); 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /testprogs/fuzz/fuzz_rserver.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | FILE * outfile = NULL; 10 | 11 | void fuzz_openFile(const char * name) { 12 | if (outfile != NULL) { 13 | fclose(outfile); 14 | } 15 | outfile = fopen(name, "w"); 16 | } 17 | 18 | typedef enum { 19 | LOGPRIO_DEBUG, 20 | LOGPRIO_INFO, 21 | LOGPRIO_WARNING, 22 | LOGPRIO_ERROR 23 | } log_priority; 24 | 25 | void rpcapd_log(log_priority priority, const char *message, ...) 26 | { 27 | va_list ap; 28 | 29 | va_start(ap, message); 30 | fprintf(outfile, "rpcapd[%d]:", priority); 31 | vfprintf(outfile, message, ap); 32 | putc('\n', outfile); 33 | va_end(ap); 34 | } 35 | 36 | void sock_initfuzz(const uint8_t *Data, size_t Size); 37 | int daemon_serviceloop(int sockctrl, int isactive, char *passiveClients, int nullAuthAllowed, int uses_ssl); 38 | 39 | int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 40 | int sock; 41 | 42 | //initialization 43 | if (outfile == NULL) { 44 | fuzz_openFile("/dev/null"); 45 | } 46 | 47 | sock_initfuzz(Data, Size); 48 | sock = socket(AF_INET, SOCK_STREAM, 0); 49 | if (sock == INVALID_SOCKET) { 50 | abort(); 51 | } 52 | //dummy socket, active, null auth allowed, no ssl 53 | daemon_serviceloop(sock, 1, malloc(0), 1, 0); 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /testprogs/fuzz/onefile.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size); 6 | void fuzz_openFile(const char * name); 7 | 8 | int main(int argc, char** argv) 9 | { 10 | FILE * fp; 11 | uint8_t *Data; 12 | size_t Size; 13 | 14 | if (argc == 3) { 15 | fuzz_openFile(argv[2]); 16 | } else if (argc != 2) { 17 | return 1; 18 | } 19 | //opens the file, get its size, and reads it into a buffer 20 | fp = fopen(argv[1], "rb"); 21 | if (fp == NULL) { 22 | return 2; 23 | } 24 | if (fseek(fp, 0L, SEEK_END) != 0) { 25 | fclose(fp); 26 | return 2; 27 | } 28 | Size = ftell(fp); 29 | if (Size == (size_t) -1) { 30 | fclose(fp); 31 | return 2; 32 | } 33 | if (fseek(fp, 0L, SEEK_SET) != 0) { 34 | fclose(fp); 35 | return 2; 36 | } 37 | Data = malloc(Size); 38 | if (Data == NULL) { 39 | fclose(fp); 40 | return 2; 41 | } 42 | if (fread(Data, Size, 1, fp) != 1) { 43 | fclose(fp); 44 | free(Data); 45 | return 2; 46 | } 47 | 48 | //launch fuzzer 49 | LLVMFuzzerTestOneInput(Data, Size); 50 | free(Data); 51 | fclose(fp); 52 | return 0; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /tests/filter/AH-IPcomp-IPv4.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/AH-IPcomp-IPv4.pcap -------------------------------------------------------------------------------- /tests/filter/AH-IPcomp-IPv6.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/AH-IPcomp-IPv6.pcap -------------------------------------------------------------------------------- /tests/filter/ISIS_external_lsp.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/ISIS_external_lsp.pcap -------------------------------------------------------------------------------- /tests/filter/ISIS_p2p_adjacency.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/ISIS_p2p_adjacency.pcap -------------------------------------------------------------------------------- /tests/filter/Network_Join_Nokia_Mobile.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/Network_Join_Nokia_Mobile.pcap -------------------------------------------------------------------------------- /tests/filter/ah-ipip-ping.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/ah-ipip-ping.pcap -------------------------------------------------------------------------------- /tests/filter/bacnet-arcnet-linux.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/bacnet-arcnet-linux.pcap -------------------------------------------------------------------------------- /tests/filter/decnet.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/decnet.pcap -------------------------------------------------------------------------------- /tests/filter/dhcp-rfc3004.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/dhcp-rfc3004.pcap -------------------------------------------------------------------------------- /tests/filter/geneve.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/geneve.pcap -------------------------------------------------------------------------------- /tests/filter/http_PPI.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/http_PPI.pcap -------------------------------------------------------------------------------- /tests/filter/ipv6_ah_modes.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/ipv6_ah_modes.pcap -------------------------------------------------------------------------------- /tests/filter/ipv6_ext_headers.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/ipv6_ext_headers.pcap -------------------------------------------------------------------------------- /tests/filter/isakmp4500.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/isakmp4500.pcap -------------------------------------------------------------------------------- /tests/filter/isup_load_generator.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/isup_load_generator.pcap -------------------------------------------------------------------------------- /tests/filter/loopback.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/loopback.pcap -------------------------------------------------------------------------------- /tests/filter/pim-packet-assortment.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/pim-packet-assortment.pcap -------------------------------------------------------------------------------- /tests/filter/pppoe.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/pppoe.pcap -------------------------------------------------------------------------------- /tests/filter/pppoes.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/pppoes.pcap -------------------------------------------------------------------------------- /tests/filter/rarp_req_reply.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/rarp_req_reply.pcapng -------------------------------------------------------------------------------- /tests/filter/slip-bad-direction.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/slip-bad-direction.pcap -------------------------------------------------------------------------------- /tests/filter/slip-compressed_sl_print-oobr.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/slip-compressed_sl_print-oobr.pcap -------------------------------------------------------------------------------- /tests/filter/slip-sliplink_print-oobr.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/slip-sliplink_print-oobr.pcap -------------------------------------------------------------------------------- /tests/filter/vrrp.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/vrrp.pcap -------------------------------------------------------------------------------- /tests/filter/vxlan.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/vxlan.pcap -------------------------------------------------------------------------------- /tests/filter/wpa-Induction.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/wpa-Induction.pcap -------------------------------------------------------------------------------- /tests/filter/wpa2linkuppassphraseiswireshark.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/filter/wpa2linkuppassphraseiswireshark.pcap -------------------------------------------------------------------------------- /tests/linktype-reserved-field-not-zero.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/linktype-reserved-field-not-zero.pcap -------------------------------------------------------------------------------- /tests/pcap-invalid-version-1.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/pcap-invalid-version-1.pcap -------------------------------------------------------------------------------- /tests/pcap-invalid-version-2.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/pcap-invalid-version-2.pcap -------------------------------------------------------------------------------- /tests/pcapng-invalid-vers-1.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/pcapng-invalid-vers-1.pcapng -------------------------------------------------------------------------------- /tests/pcapng-invalid-vers-2.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/pcapng-invalid-vers-2.pcapng -------------------------------------------------------------------------------- /tests/shb-option-too-long.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-tcpdump-group/libpcap/b229fc0003c36ffcec040688d6c68d655c21ced3/tests/shb-option-too-long.pcapng -------------------------------------------------------------------------------- /varattrs.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ 2 | /* 3 | * Copyright (c) 1993, 1994, 1995, 1996, 1997 4 | * The Regents of the University of California. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by the Computer Systems 17 | * Engineering Group at Lawrence Berkeley Laboratory. 18 | * 4. Neither the name of the University nor of the Laboratory may be used 19 | * to endorse or promote products derived from this software without 20 | * specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef varattrs_h 36 | #define varattrs_h 37 | 38 | #include 39 | 40 | /* 41 | * Attributes to apply to variables, using various compiler-specific 42 | * extensions. 43 | */ 44 | 45 | #if __has_attribute(unused) \ 46 | || PCAP_IS_AT_LEAST_GNUC_VERSION(2,0) 47 | /* 48 | * Compiler with support for __attribute__((unused)), or GCC 2.0 and 49 | * later, so it supports __attribute__((unused)). 50 | */ 51 | #define _U_ __attribute__((unused)) 52 | #else 53 | /* 54 | * We don't know of any way to mark a variable as unused. 55 | */ 56 | #define _U_ 57 | #endif 58 | 59 | #endif 60 | --------------------------------------------------------------------------------