├── .appveyor.yml ├── .ci-coverity-scan-build.sh ├── .cirrus.yml ├── .gitattributes ├── .gitignore ├── .mailmap ├── Android.bp ├── CHANGES ├── CMakeLists.txt ├── CONTRIBUTING.md ├── CREDITS ├── ChmodBPF ├── ChmodBPF └── StartupParameters.plist ├── CleanSpec.mk ├── INSTALL.md ├── LICENSE ├── METADATA ├── MODULE_LICENSE_BSD ├── Makefile-devel-adds ├── Makefile.in ├── NOTICE ├── OWNERS ├── README.md ├── TODO ├── VERSION ├── aclocal.m4 ├── arcnet.h ├── atmuni31.h ├── autogen.sh ├── bpf_dump.c ├── bpf_filter.c ├── bpf_image.c ├── build.sh ├── build_common.sh ├── build_matrix.sh ├── charconv.c ├── charconv.h ├── chmod_bpf ├── cmake ├── Modules │ ├── FindAirPcap.cmake │ ├── FindDAG.cmake │ ├── FindFseeko.cmake │ ├── FindLFS.cmake │ ├── FindPacket.cmake │ ├── FindSNF.cmake │ ├── FindTC.cmake │ └── Finddpdk.cmake └── have_siocglifconf.c ├── cmake_uninstall.cmake.in ├── cmakeconfig.h.in ├── config.guess ├── config.h ├── config.sub ├── configure.ac ├── diag-control.h ├── dlpisubs.c ├── dlpisubs.h ├── doc ├── README.aix ├── README.dag ├── README.haiku.md ├── README.hpux ├── README.linux ├── README.macos ├── README.septel ├── README.sita ├── 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.c ├── grammar.h ├── grammar.y.in ├── ieee80211.h ├── install-sh ├── instrument-functions.c ├── lbl ├── os-aix4.h ├── os-aix7.h ├── os-hpux11.h ├── os-osf4.h ├── os-osf5.h ├── os-solaris2.h ├── os-sunos4.h └── os-ultrix4.h ├── libpcap.pc.in ├── llc.h ├── missing ├── asprintf.c ├── getopt.c ├── getopt.h ├── strlcat.c ├── strlcpy.c ├── strtok_r.c └── win_asprintf.c ├── mkdep ├── msdos ├── bin2c.c ├── makefile ├── makefile.dj ├── makefile.wc ├── pkt_rx0.asm ├── pkt_rx1.s ├── pktdrvr.c ├── pktdrvr.h └── readme.dos ├── nametoaddr.c ├── nametoaddr.h ├── nlpid.h ├── nomkdep ├── optimize.c ├── optimize.h ├── org.tcpdump.chmod_bpf.plist ├── pcap-airpcap.c ├── pcap-airpcap.h ├── 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-dos.c ├── pcap-dos.h ├── pcap-dpdk.c ├── pcap-dpdk.h ├── pcap-enet.c ├── pcap-filter.manmisc.in ├── pcap-haiku.c ├── pcap-int.h ├── pcap-libdlpi.c ├── pcap-linktype.manmisc.in ├── pcap-linux.c ├── pcap-namedb.h ├── pcap-netfilter-linux-android.c ├── pcap-netfilter-linux-android.h ├── pcap-netfilter-linux.c ├── pcap-netfilter-linux.h ├── pcap-netmap.c ├── pcap-netmap.h ├── pcap-new.c ├── pcap-nit.c ├── pcap-npf.c ├── pcap-null.c ├── pcap-pf.c ├── pcap-rdmasniff.c ├── pcap-rdmasniff.h ├── pcap-rpcap.c ├── pcap-rpcap.h ├── pcap-savefile.manfile.in ├── pcap-septel.c ├── pcap-septel.h ├── pcap-sita.c ├── pcap-sita.h ├── pcap-sita.html ├── pcap-snf.c ├── pcap-snf.h ├── pcap-snit.c ├── pcap-snoop.c ├── pcap-tc.c ├── pcap-tc.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 ├── post_update.sh ├── 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.c ├── scanner.h ├── scanner.l ├── sf-pcap.c ├── sf-pcap.h ├── sf-pcapng.c ├── sf-pcapng.h ├── sockutils.c ├── sockutils.h ├── sslutils.c ├── sslutils.h ├── sunatmpos.h ├── testprogs ├── .gitignore ├── BPF │ ├── 1.txt │ ├── 2.txt │ ├── 3.txt │ ├── 4.txt │ ├── 5.txt │ ├── 6.txt │ └── 7.txt ├── CMakeLists.txt ├── Makefile.in ├── 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 ├── 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 | 5 | freebsd_task: 6 | name: freebsd-amd64 7 | only_if: $CIRRUS_BRANCH != 'coverity_scan' 8 | freebsd_instance: 9 | cpu: 1 10 | memory: 2G 11 | image_family: freebsd-13-3 12 | env: 13 | IGNORE_OSVERSION: yes 14 | MATRIX_CC: clang17 gcc13 15 | script: 16 | - pkg install -qy autoconf gcc13 llvm17 17 | - pkg install -qy cmake-core git-tiny # for build_matrix.sh and build.sh 18 | - ./build_matrix.sh 19 | 20 | linux_task: 21 | name: linux-amd64 22 | only_if: $CIRRUS_BRANCH != 'coverity_scan' 23 | container: 24 | image: ubuntu:22.04 25 | cpu: 1 26 | memory: 1G 27 | env: 28 | DEBIAN_FRONTEND: noninteractive 29 | LANG: C 30 | script: 31 | - apt-get -qy update >/dev/null 32 | - apt-get -qy install flex bison autoconf make gcc >/dev/null # for "./configure" 33 | - apt-get -qy install cmake git >/dev/null # for "make releasecheck" 34 | - apt-get -qy install shellcheck >/dev/null 35 | - ./autogen.sh 36 | - ./configure --quiet # build the Makefile 37 | - make releasecheck 38 | - make whitespacecheck 39 | - make shellcheck 40 | 41 | macos_task: 42 | name: macos-aarch64 43 | only_if: $CIRRUS_BRANCH != 'coverity_scan' 44 | macos_instance: 45 | image: ghcr.io/cirruslabs/macos-ventura-xcode:14.1 # macOS 13 with Xcode 14.1 46 | env: 47 | MAKEFLAGS: '-j 4' # macOS VMs run on 4 cores 48 | script: 49 | - brew update >/dev/null 50 | - brew install openssl@3 51 | - ./build_matrix.sh 52 | 53 | coverity_task: 54 | name: Coverity Scan 55 | only_if: $CIRRUS_BRANCH == 'coverity_scan' 56 | container: 57 | image: ubuntu:22.04 58 | cpu: 1 59 | memory: 2G 60 | env: 61 | DEBIAN_FRONTEND: noninteractive 62 | COVERITY_SCAN_PROJECT_NAME: $CIRRUS_REPO_FULL_NAME 63 | COVERITY_SCAN_TOKEN: ENCRYPTED[58bfbfcf624e5b7b85fb9df95dd0b3f9f93642824e6ae94616e4d345af4848580932a6ece02337fee112194b29ce6593] 64 | COVERITY_SCAN_BUILD_COMMAND_PREPEND: ./configure --enable-remote --enable-optimizer-dbg --enable-yydebug 65 | COVERITY_SCAN_BUILD_COMMAND: make 66 | LANG: C 67 | script: 68 | - apt-get -qy update >/dev/null 69 | - apt-get -qy install libdbus-1-dev libbluetooth-dev libnl-genl-3-dev libibverbs-dev libssl-dev >/dev/null 70 | - apt-get -qy install flex bison autoconf make gcc >/dev/null 71 | - apt-get -qy install git curl wget ruby rubygems ruby-json >/dev/null # for the coverity script 72 | - apt list --installed 'lib*-dev' 73 | - ./autogen.sh 74 | - ./.ci-coverity-scan-build.sh 75 | -------------------------------------------------------------------------------- /.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 | /Makefile 3 | *~ 4 | /*.o 5 | CMakeCache.txt 6 | cmake_install.cmake 7 | CMakeFiles/ 8 | /config.h 9 | /config.h.in 10 | /config.log 11 | /config.cache 12 | /config.status 13 | /configure 14 | /stamp-h 15 | /stamp-h.in 16 | /autom4te.cache/ 17 | /.devel 18 | /grammar.c 19 | /grammar.h 20 | /grammar.y 21 | /libpcap.a 22 | /libpcap.*.dylib 23 | /libpcap.pc 24 | /libpcap.sl 25 | /libpcap.so 26 | /libpcap.so.* 27 | /libpcap.shareda 28 | /libpcap-*.tar.gz 29 | /os-proto.h 30 | /pcap-config 31 | /pcap-filter.manmisc 32 | /pcap-linktype.manmisc 33 | /pcap-savefile.manfile 34 | /pcap-tstamp.manmisc 35 | /pcap.3pcap 36 | /pcap_compile.3pcap 37 | /pcap_datalink.3pcap 38 | /pcap_dump_open.3pcap 39 | /pcap_get_tstamp_precision.3pcap 40 | /pcap_list_datalinks.3pcap 41 | /pcap_list_tstamp_types.3pcap 42 | /pcap_open_dead.3pcap 43 | /pcap_open_offline.3pcap 44 | /pcap_set_immediate_mode.3pcap 45 | /pcap_set_tstamp_precision.3pcap 46 | /pcap_set_tstamp_type.3pcap 47 | /scanner.c 48 | /scanner.c.bottom 49 | /scanner.h 50 | *.log 51 | *.tlog 52 | *.obj 53 | *.sdf 54 | *.opensdf 55 | *.suo 56 | *.pdb 57 | *.lib 58 | *.dll 59 | *.exp 60 | *.vcxproj.user 61 | Debug/ 62 | Release/ 63 | /msdos/.depend.dj 64 | /msdos/bin2c.exe 65 | /msdos/pkt_rx1.lst 66 | /msdos/pkt_stub.inc 67 | -------------------------------------------------------------------------------- /.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 https://github.com/the-tcpdump-group/libpcap/issues 14 | and check if the problem has already been reported. If it has not, please open 15 | a new issue and provide the following details: 16 | 17 | * libpcap version (e.g. from `tcpdump --version`) 18 | * operating system name and version and any other details that may be relevant 19 | (`uname -a`, compiler name and version, CPU type etc.) 20 | * `configure` or `cmake` flags if any were used 21 | * statement of the problem 22 | * steps to reproduce 23 | 24 | Please note that if you know exactly how to solve the problem and the solution 25 | would not be too intrusive, it would be best to contribute some development time 26 | and open a pull request instead. 27 | 28 | Still not sure how to do? Feel free to [subscribe](https://www.tcpdump.org/#mailing-lists) 29 | to the mailing list tcpdump-workers@lists.tcpdump.org and ask! 30 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /CleanSpec.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2007 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # If you don't need to do a full clean build but would like to touch 17 | # a file or delete some intermediate files, add a clean step to the end 18 | # of the list. These steps will only be run once, if they haven't been 19 | # run before. 20 | # 21 | # E.g.: 22 | # $(call add-clean-step, touch -c external/sqlite/sqlite3.h) 23 | # $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) 24 | # 25 | # Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with 26 | # files that are missing or have been moved. 27 | # 28 | # Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. 29 | # Use $(OUT_DIR) to refer to the "out" directory. 30 | # 31 | # If you need to re-do something that's already mentioned, just copy 32 | # the command and add it to the bottom of the list. E.g., if a change 33 | # that you made last week required touching a file and a change you 34 | # made today requires touching the same file, just copy the old 35 | # touch step and add it to the end of the list. 36 | # 37 | # ************************************************ 38 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 39 | # ************************************************ 40 | 41 | # For example: 42 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) 43 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) 44 | #$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) 45 | #$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) 46 | 47 | # ************************************************ 48 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 49 | # ************************************************ 50 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /METADATA: -------------------------------------------------------------------------------- 1 | # This project was upgraded with external_updater. 2 | # Usage: tools/external_updater/updater.sh update external/libpcap 3 | # For more info, check https://cs.android.com/android/platform/superproject/main/+/main:tools/external_updater/README.md 4 | 5 | name: "libpcap" 6 | description: "A system-independent interface for user-level packet capture." 7 | third_party { 8 | license_type: NOTICE 9 | security { 10 | tag: "NVD-CPE2.3:cpe:/a:tcpdump:libpcap:-" 11 | } 12 | last_upgrade_date { 13 | year: 2025 14 | month: 1 15 | day: 9 16 | } 17 | homepage: "https://www.tcpdump.org/" 18 | identifier { 19 | type: "Git" 20 | value: "https://github.com/the-tcpdump-group/libpcap.git" 21 | version: "libpcap-1.10.5" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /MODULE_LICENSE_BSD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aosp-mirror/platform_external_libpcap/dd978ad56aa6d908517d3ccc793523341206e31d/MODULE_LICENSE_BSD -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | include platform/system/core:/janitors/OWNERS 2 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | TODO list for libpcap 2 | ======================= 3 | 4 | Important stuff (to be done before the next release) 5 | --------------- 6 | 7 | General 8 | 9 | - The source files should be better documented. There is no official 10 | design guideline for what is done where. There should be a common coding 11 | style (okay, you can guess that by looking at the code) and a guide for 12 | what needs to be documented. 13 | 14 | Less urgent items 15 | ----------------- 16 | 17 | - Better documentation and cleanup of the interface. I am seeing a few 18 | problems at the first glance which needs fixing: 19 | + not very well suited for interactive programs (think ethereal). There 20 | should be a way for the application to get a file descriptor which it 21 | has to monitor and a callback in pcap which has to be called on 22 | activity (XXX - "pcap_fileno()" handles the first part, although 23 | "select()" and "poll()" don't work on BPF devices on most BSDs, and 24 | you can call "pcap_dispatch()" as the dispatch routine after putting 25 | the descriptor into non-blocking mode) 26 | + too many functions. There are a lot of functions for everything which 27 | violates the KISS principle. Why do we need pcap_strerror, pcap_perror 28 | and pcap_geterr? 29 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.10.5 2 | -------------------------------------------------------------------------------- /arcnet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1982, 1986, 1993 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 University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without 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 | * from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp 34 | */ 35 | 36 | /* RFC 1051 */ 37 | #define ARCTYPE_IP_OLD 240 /* IP protocol */ 38 | #define ARCTYPE_ARP_OLD 241 /* address resolution protocol */ 39 | 40 | /* RFC 1201 */ 41 | #define ARCTYPE_IP 212 /* IP protocol */ 42 | #define ARCTYPE_ARP 213 /* address resolution protocol */ 43 | #define ARCTYPE_REVARP 214 /* reverse addr resolution protocol */ 44 | 45 | #define ARCTYPE_ATALK 221 /* Appletalk */ 46 | #define ARCTYPE_BANIAN 247 /* Banyan Vines */ 47 | #define ARCTYPE_IPX 250 /* Novell IPX */ 48 | 49 | #define ARCTYPE_INET6 0xc4 /* IPng */ 50 | #define ARCTYPE_DIAGNOSE 0x80 /* as per ANSI/ATA 878.1 */ 51 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | : "${AUTORECONF:=autoreconf}" 4 | 5 | AUTORECONFVERSION=`$AUTORECONF --version 2>&1 | grep "^autoreconf" | sed 's/.*) *//'` 6 | 7 | maj=`echo "$AUTORECONFVERSION" | cut -d. -f1` 8 | min=`echo "$AUTORECONFVERSION" | cut -d. -f2` 9 | # The minimum required version of autoconf is currently 2.69. 10 | if [ "$maj" = "" ] || [ "$min" = "" ] || \ 11 | [ "$maj" -lt 2 ] || { [ "$maj" -eq 2 ] && [ "$min" -lt 69 ]; }; then 12 | cat >&2 <<-EOF 13 | Please install the 'autoconf' package version 2.69 or later. 14 | If version 2.69 or later is already installed and there is no 15 | autoconf default, it may be necessary to set the AUTORECONF 16 | environment variable to enable the one to use, like: 17 | AUTORECONF=autoreconf-2.69 ./autogen.sh 18 | or 19 | AUTORECONF=autoreconf-2.71 ./autogen.sh 20 | EOF 21 | exit 1 22 | fi 23 | 24 | echo "$AUTORECONF identification: $AUTORECONFVERSION" 25 | "$AUTORECONF" -f 26 | -------------------------------------------------------------------------------- /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/FindAirPcap.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # FindAirPcap 3 | # ========== 4 | # 5 | # Find the AirPcap library and include files. 6 | # 7 | # This module defines the following variables: 8 | # 9 | # AirPcap_INCLUDE_DIR - absolute path to the directory containing airpcap.h. 10 | # 11 | # AirPcap_LIBRARY - relative or absolute path to the AirPcap library to 12 | # link with. An absolute path is will be used if the 13 | # AirPcap library is not located in the compiler's 14 | # default search path. 15 | 16 | # AirPcap_FOUND - TRUE if the AirPcap library *and* header are found. 17 | # 18 | # Hints and Backward Compatibility 19 | # ================================ 20 | # 21 | # To tell this module where to look, a user may set the environment variable 22 | # AirPcap_ROOT to point cmake to the *root* of a directory with include and 23 | # lib subdirectories for airpcap.dll (e.g Airpcap_Devpack). 24 | # Alternatively, AirPcap_ROOT may also be set from the CMake command 25 | # line or GUI (e.g cmake -DAirPcap_ROOT=C:\path\to\airpcap_sdk [...]) 26 | # 27 | 28 | # The 64-bit airpcap.lib is located under /x64 29 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 30 | # 31 | # For the WinPcap and Npcap SDKs, the Lib subdirectory of the top-level 32 | # directory contains 32-bit libraries; the 64-bit libraries are in the 33 | # Lib/x64 directory. 34 | # 35 | # The only way to *FORCE* CMake to look in the Lib/x64 directory 36 | # without searching in the Lib directory first appears to be to set 37 | # CMAKE_LIBRARY_ARCHITECTURE to "x64". 38 | # 39 | # In newer versions of CMake, CMAKE_LIBRARY_ARCHITECTURE is set according to 40 | # the language, e.g., CMAKE__LIBRARY_ARCHITECTURE. So, set the new 41 | # variable, CMAKE_C_LIBRARY_ARCHITECTURE, so that CMAKE_LIBRARY_ARCHITECTURE 42 | # inherits the correct value. 43 | # 44 | set(CMAKE_C_LIBRARY_ARCHITECTURE "x64") 45 | set(CMAKE_LIBRARY_ARCHITECTURE "x64") 46 | endif() 47 | 48 | # Find the header 49 | find_path(AirPcap_INCLUDE_DIR airpcap.h 50 | PATH_SUFFIXES include 51 | ) 52 | 53 | # Find the library 54 | find_library(AirPcap_LIBRARY 55 | NAMES airpcap 56 | ) 57 | 58 | # Set AirPcap_FOUND to TRUE if AirPcap_INCLUDE_DIR and AirPcap_LIBRARY are TRUE. 59 | include(FindPackageHandleStandardArgs) 60 | find_package_handle_standard_args(AirPcap 61 | DEFAULT_MSG 62 | AirPcap_INCLUDE_DIR 63 | AirPcap_LIBRARY 64 | ) 65 | 66 | mark_as_advanced(AirPcap_INCLUDE_DIR AirPcap_LIBRARY) 67 | 68 | set(AirPcap_INCLUDE_DIRS ${AirPcap_INCLUDE_DIR}) 69 | set(AirPcap_LIBRARIES ${AirPcap_LIBRARY}) 70 | -------------------------------------------------------------------------------- /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/Modules/FindTC.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Try to find the Riverbed TurboCap library. 3 | # 4 | 5 | # Try to find the header 6 | find_path(TC_INCLUDE_DIR TcApi.h) 7 | 8 | # Try to find the library 9 | find_library(TC_LIBRARY TcApi) 10 | 11 | include(FindPackageHandleStandardArgs) 12 | find_package_handle_standard_args(TC 13 | DEFAULT_MSG 14 | TC_INCLUDE_DIR 15 | TC_LIBRARY 16 | ) 17 | 18 | mark_as_advanced( 19 | TC_INCLUDE_DIR 20 | TC_LIBRARY 21 | ) 22 | 23 | set(TC_INCLUDE_DIRS ${TC_INCLUDE_DIR}) 24 | set(TC_LIBRARIES ${TC_LIBRARY}) 25 | -------------------------------------------------------------------------------- /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.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 revision hrev57585 and is expected to work in Haiku R1/beta5 when 6 | the latter becomes available. Packet timestamping and filtering always occur 7 | in userland. Wireless monitor mode is not supported. The "any" 8 | pseudo-interface is not supported. 9 | [**pcap_set_buffer_size**](https://www.tcpdump.org/manpages/pcap_set_buffer_size.3pcap.html)(3PCAP) 10 | has no effect. 11 | [**pcap_setdirection**](https://www.tcpdump.org/manpages/pcap_setdirection.3pcap.html)(3PCAP) 12 | is not supported. 13 | [**pcap_inject**](https://www.tcpdump.org/manpages/pcap_inject.3pcap.html)(3PCAP) 14 | is not supported. 15 | 16 | The statistics reported by 17 | [**pcap_stats**](https://www.tcpdump.org/manpages/pcap_stats.3pcap.html)(3PCAP) 18 | on Haiku are as follows: 19 | * `ps_recv` is the number of packets successfully delivered by the kernel, 20 | before libpcap applies a filter. 21 | * `ps_drop` is the number of packets rejected by the filter. 22 | * `ps_ifdrop` is the number of packets dropped by the network interface (as 23 | seen via `SIOCGIFSTATS`) since the capture handle became active. 24 | 25 | ## 64-bit x86 R1/beta4 26 | 27 | * Autoconf 2.71 works. 28 | * CMake 3.28.3 works. 29 | * GCC 13.2.0 works. 30 | * Clang 12.0.1 works with the latest llvm12_clang-12.0.1-5 version. 31 | * flex 2.6.4 works. 32 | * bison 3.8.2 works. 33 | 34 | The following command will install respective non-default packages: 35 | ``` 36 | pkgman install cmake llvm12_clang 37 | ``` 38 | 39 | For reference, the tests were done using a system installed from 40 | `haiku-r1beta4-x86_64-anyboot.iso`. 41 | 42 | ## 32-bit x86 R1/beta4 43 | 44 | * Autoconf 2.71 works. 45 | * CMake 3.24.2 works. 46 | * GCC 11.2.0 works. 47 | * Clang does not work. 48 | * flex 2.6.4 works. 49 | * bison 3.0.5 works. 50 | 51 | The following command will install respective non-default packages: 52 | ``` 53 | pkgman install cmake_x86 54 | ``` 55 | 56 | For reference, the tests were done using a system installed from 57 | `haiku-r1beta4-x86_gcc2h-anyboot.iso`. 58 | -------------------------------------------------------------------------------- /doc/README.linux: -------------------------------------------------------------------------------- 1 | Currently, libpcap supports packet capturing on Linux 2.6.27 and later; 2 | earlier versions are not supported. 3 | 4 | You must configure 2.6.x kernels with the CONFIG_PACKET_MMAP option for 5 | this protocol. 3.x and later kernels do not require that. 6 | 7 | Note that, by default, libpcap will, if libnl is present, build with it; 8 | it uses libnl to support monitor mode on mac80211 devices. There is a 9 | configuration option to disable building with libnl, but, if that option 10 | is chosen, the monitor-mode APIs (as used by tcpdump's "-I" flag, and as 11 | will probably be used by other applications in the future) won't work 12 | properly on mac80211 devices. 13 | 14 | Linux's run-time linker allows shared libraries to be linked with other 15 | shared libraries, which means that if an older version of a shared 16 | library doesn't require routines from some other shared library, and a 17 | later version of the shared library does require those routines, the 18 | later version of the shared library can be linked with that other shared 19 | library and, if it's otherwise binary-compatible with the older version, 20 | can replace that older version without breaking applications built with 21 | the older version, and without breaking configure scripts or the build 22 | procedure for applications whose configure script doesn't use the 23 | pcap-config script if they build with the shared library. (The build 24 | procedure for applications whose configure scripts use the pcap-config 25 | script if present will not break even if they build with the static 26 | library.) 27 | 28 | Statistics: 29 | Statistics reported by pcap are platform specific. The statistics 30 | reported by pcap_stats on Linux are as follows: 31 | 32 | ps_recv Number of packets that were accepted by the pcap filter 33 | ps_drop Number of packets that had passed filtering but were not 34 | passed on to pcap due to things like buffer shortage, etc. 35 | This is useful because these are packets you are interested in 36 | but won't be reported by, for example, tcpdump output. 37 | -------------------------------------------------------------------------------- /doc/README.septel: -------------------------------------------------------------------------------- 1 | The following instructions apply if you have a Linux platform and want 2 | libpcap to support the Septel range of passive network monitoring cards 3 | from Intel (https://www.intel.com) 4 | 5 | 1) Install and build the Septel software distribution by following the 6 | instructions supplied with that package. 7 | 8 | 2) Configure libcap. To allow the 'configure' script to locate the Septel 9 | software distribution use the '--with-septel' option: 10 | 11 | ./configure --with-septel=DIR 12 | 13 | where DIR is the root of the Septel software distribution, for example 14 | /var/src/septel. 15 | 16 | By default (if you write only ./configure --with-septel) it takes 17 | ./../septel as argument for DIR. 18 | 19 | If the Septel software is correctly detected 'configure' will 20 | report: 21 | 22 | checking whether we have Septel API... yes 23 | 24 | If 'configure' reports that there is no Septel API, the directory may have been 25 | incorrectly specified or the Septel software was not built before configuring 26 | libpcap. 27 | 28 | See also the libpcap INSTALL.md file for further libpcap configuration 29 | options. 30 | 31 | Building libpcap at this stage will include support for both the native 32 | packet capture stream and for capturing from Septel cards. To build 33 | libpcap with only Septel support specify the capture type as 'septel' 34 | when configuring libpcap: 35 | 36 | ./configure --with-septel=DIR --with-pcap=septel 37 | 38 | Applications built with libpcap configured in this way will only detect Septel 39 | cards and will not capture from the native OS packet stream. 40 | 41 | Note: As mentioned in pcap-septel.c we should first edit the system.txt 42 | file to change the user part example (UPE) module id to 0xdd instead of 43 | 0x2d for technical reason. So this change in system.txt is crucial and 44 | things will go wrong if it's not done. System.txt along with config.txt 45 | are configuration files that are edited by the user before running the 46 | gctload program that uses these files for initialising modules and 47 | configuring parameters. 48 | 49 | ---------------------------------------------------------------------- 50 | for more information please contact me : gil_hoyek@hotmail.com 51 | -------------------------------------------------------------------------------- /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 r151042/AMD64 9 | 10 | * flex 2.6.4 and GNU Bison 3.8.2 work. 11 | * CMake 3.23.1 works. 12 | * GCC 11.2.0 and Clang 14.0.3 work. 13 | 14 | ## OpenIndiana 2021.04/AMD64 15 | 16 | * flex 2.6.4 and GNU Bison 3.7.6 work. 17 | * CMake 3.21.1 works. 18 | * GCC 7.5.0 and GCC 10.3.0 work, Clang 9.0.1 works. 19 | 20 | For reference, the tests were done using a system installed from 21 | `OI-hipster-text-20210430.iso` plus the following packages: 22 | ```shell 23 | xargs -L1 pkg install <. 26 | */ 27 | int snprintf(char *, size_t, const char *, ...); 28 | int vsnprintf(char *, size_t, const char *, va_list); 29 | int pfopen(char *, int); 30 | 31 | -------------------------------------------------------------------------------- /lbl/os-solaris2.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 | 22 | /* Prototypes missing in SunOS 5 */ 23 | char *strerror(int); 24 | int snprintf(char *, size_t, const char *, ...); 25 | -------------------------------------------------------------------------------- /lbl/os-ultrix4.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1990, 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 | /* Prototypes missing in Ultrix 4 */ 23 | int bcmp(const char *, const char *, u_int); 24 | void bcopy(const void *, void *, u_int); 25 | void bzero(void *, u_int); 26 | int getopt(int, char * const *, const char *); 27 | #ifdef __STDC__ 28 | struct timeval; 29 | struct timezone; 30 | #endif 31 | int gettimeofday(struct timeval *, struct timezone *); 32 | int ioctl(int, int, caddr_t); 33 | int pfopen(char *, int); 34 | int setlinebuf(FILE *); 35 | int socket(int, int, int); 36 | int strcasecmp(const char *, const char *); 37 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /msdos/bin2c.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | static void Abort (const char *fmt,...) 7 | { 8 | va_list args; 9 | va_start (args, fmt); 10 | vfprintf (stderr, fmt, args); 11 | va_end (args); 12 | exit (1); 13 | } 14 | 15 | int main (int argc, char **argv) 16 | { 17 | FILE *inFile; 18 | FILE *outFile = stdout; 19 | time_t now = time (NULL); 20 | int ch, i; 21 | 22 | if (argc != 2) 23 | Abort ("Usage: %s bin-file [> result]", argv[0]); 24 | 25 | if ((inFile = fopen(argv[1],"rb")) == NULL) 26 | Abort ("Cannot open %s\n", argv[1]); 27 | 28 | fprintf (outFile, 29 | "/* data statements for file %s at %.24s */\n" 30 | "/* Generated by BIN2C, G. Vanem 1995 */\n", 31 | argv[1], ctime(&now)); 32 | 33 | i = 0; 34 | while ((ch = fgetc(inFile)) != EOF) 35 | { 36 | if (i++ % 12 == 0) 37 | fputs ("\n ", outFile); 38 | fprintf (outFile, "0x%02X,", ch); 39 | } 40 | fputc ('\n', outFile); 41 | fclose (inFile); 42 | return (0); 43 | } 44 | -------------------------------------------------------------------------------- /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 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /* 39 | * Routines used for name-or-address-string-to-address resolution 40 | * that are *not* exported to code using libpcap. 41 | */ 42 | int __pcap_atodn(const char *, bpf_u_int32 *); 43 | int __pcap_atoin(const char *, bpf_u_int32 *); 44 | int __pcap_nametodnaddr(const char *, u_short *); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /nlpid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996 3 | * Juniper Networks, Inc. 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. The name of Juniper Networks may not 11 | * be used to endorse or promote products derived from this software 12 | * without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 15 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 16 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | /* Types missing from some systems */ 20 | 21 | /* 22 | * Network layer protocol identifiers 23 | */ 24 | #ifndef ISO8473_CLNP 25 | #define ISO8473_CLNP 0x81 26 | #endif 27 | #ifndef ISO9542_ESIS 28 | #define ISO9542_ESIS 0x82 29 | #endif 30 | #ifndef ISO9542X25_ESIS 31 | #define ISO9542X25_ESIS 0x8a 32 | #endif 33 | #ifndef ISO10589_ISIS 34 | #define ISO10589_ISIS 0x83 35 | #endif 36 | /* 37 | * this does not really belong in the nlpid.h file 38 | * however we need it for generating nice 39 | * IS-IS related BPF filters 40 | */ 41 | #define ISIS_L1_LAN_IIH 15 42 | #define ISIS_L2_LAN_IIH 16 43 | #define ISIS_PTP_IIH 17 44 | #define ISIS_L1_LSP 18 45 | #define ISIS_L2_LSP 20 46 | #define ISIS_L1_CSNP 24 47 | #define ISIS_L2_CSNP 25 48 | #define ISIS_L1_PSNP 26 49 | #define ISIS_L2_PSNP 27 50 | 51 | #ifndef ISO8878A_CONS 52 | #define ISO8878A_CONS 0x84 53 | #endif 54 | #ifndef ISO10747_IDRP 55 | #define ISO10747_IDRP 0x85 56 | #endif 57 | -------------------------------------------------------------------------------- /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-airpcap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2010 CACE Technologies, 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, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | pcap_t *airpcap_create(const char *, char *, int *); 35 | int airpcap_findalldevs(pcap_if_list_t *devlistp, char *errbuf); 36 | int device_is_airpcap(const char *device, char *ebuf); 37 | -------------------------------------------------------------------------------- /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.c: 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-linktype.manmisc.in: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 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-LINKTYPE @MAN_MISC_INFO@ "6 April 2020" 22 | .SH NAME 23 | pcap-linktype \- link-layer header types supported by libpcap 24 | .SH DESCRIPTION 25 | For a live capture or ``savefile'', libpcap supplies, as the return 26 | value of the 27 | .BR pcap_datalink (3PCAP) 28 | routine, a value that indicates the type of link-layer header at the 29 | beginning of the packets it provides. This is not necessarily the type 30 | of link-layer header that the packets being captured have on the network 31 | from which they're being captured; for example, packets from an IEEE 32 | 802.11 network might be provided by libpcap with Ethernet headers that 33 | the network adapter or the network adapter driver generates from the 34 | 802.11 headers. The names for those values begin with 35 | .BR DLT_ , 36 | so they are sometimes called "DLT_ values". 37 | .PP 38 | The values stored in the link-layer header type field in the savefile 39 | header are, in most but not all cases, the same as the values returned 40 | by 41 | .BR pcap_datalink (). 42 | The names for those values begin with 43 | .BR LINKTYPE_ . 44 | .PP 45 | The link-layer header types supported by libpcap are described at 46 | https://www.tcpdump.org/linktypes.html . 47 | .SH SEE ALSO 48 | .BR pcap (3PCAP) 49 | -------------------------------------------------------------------------------- /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-android.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "pcap-netfilter-linux.c" 18 | 19 | int 20 | android_nflog_send_config_cmd(int fd, u_int16_t group_id, u_int8_t cmd, u_int8_t family) 21 | { 22 | pcap_t handle; 23 | handle.fd = fd; 24 | return nflog_send_config_cmd(&handle, group_id, cmd, family); 25 | } 26 | -------------------------------------------------------------------------------- /pcap-netfilter-linux-android.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | int android_nflog_send_config_cmd(int fd, u_int16_t group_id, u_int8_t cmd, u_int8_t family); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /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-septel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pcap-septel.c: Packet capture interface for Intel Septel 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 Intel/Septel 6 | * card code at the same time as another type of device. 7 | * 8 | * Authors: Gilbert HOYEK (gil_hoyek@hotmail.com), Elias M. KHOURY 9 | * (+961 3 485343); 10 | */ 11 | 12 | pcap_t *septel_create(const char *device, char *ebuf, int *is_ours); 13 | int septel_findalldevs(pcap_if_list_t *devlistp, char *errbuf); 14 | -------------------------------------------------------------------------------- /pcap-sita.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pcap-sita.h: Packet capture interface for SITA WAN devices 3 | * 4 | * Authors: Fulko Hew (fulko.hew@sita.aero) (+1 905 6815570); 5 | */ 6 | 7 | extern int acn_parse_hosts_file(char *errbuf); 8 | extern int acn_findalldevs(char *errbuf); 9 | -------------------------------------------------------------------------------- /pcap-snf.h: -------------------------------------------------------------------------------- 1 | pcap_t *snf_create(const char *, char *, int *); 2 | int snf_findalldevs(pcap_if_list_t *devlistp, char *errbuf); 3 | -------------------------------------------------------------------------------- /pcap-tc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 CACE Technologies, Davis (California) 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. Neither the name of CACE Technologies nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written 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 | #ifndef __PCAP_TC_H__ 33 | #define __PCAP_TC_H__ 34 | 35 | /* 36 | * needed because gcc headers do not have C_ASSERT 37 | */ 38 | #ifndef C_ASSERT 39 | #define C_ASSERT(a) 40 | #endif 41 | 42 | #include 43 | 44 | /* 45 | * functions used effectively by the pcap library 46 | */ 47 | 48 | pcap_t * 49 | TcCreate(const char *device, char *ebuf, int *is_ours); 50 | 51 | int 52 | TcFindAllDevs(pcap_if_list_t *devlistp, char *errbuf); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /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-util.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-util.h - common code for various files 22 | */ 23 | 24 | /* 25 | * We use the "receiver-makes-right" approach to byte order; 26 | * because time is at a premium when we are writing the file. 27 | * In other words, the pcap_file_header and pcap_pkthdr, 28 | * records are written in host byte order. 29 | * Note that the bytes of packet data are written out in the order in 30 | * which they were received, so multi-byte fields in packets are not 31 | * written in host byte order, they're written in whatever order the 32 | * sending machine put them in. 33 | * 34 | * We also use this for fixing up packet data headers from a remote 35 | * capture, where the server may have a different byte order from the 36 | * client. 37 | * 38 | * ntoh[ls] aren't sufficient because we might need to swap on a big-endian 39 | * machine (if the file was written in little-end order). 40 | */ 41 | #define SWAPLONG(y) \ 42 | (((((u_int)(y))&0xff)<<24) | \ 43 | ((((u_int)(y))&0xff00)<<8) | \ 44 | ((((u_int)(y))&0xff0000)>>8) | \ 45 | ((((u_int)(y))>>24)&0xff)) 46 | #define SWAPSHORT(y) \ 47 | ((u_short)(((((u_int)(y))&0xff)<<8) | \ 48 | ((((u_int)(y))&0xff00)>>8))) 49 | 50 | extern void pcapint_post_process(int linktype, int swapped, 51 | struct pcap_pkthdr *hdr, u_char *data); 52 | -------------------------------------------------------------------------------- /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. 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 | #define IPH_AF_INET 2 /* Matches Solaris's AF_INET */ 40 | #define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */ 41 | 42 | #define IPNET_OUTBOUND 1 43 | #define IPNET_INBOUND 2 44 | -------------------------------------------------------------------------------- /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. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without 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 lib_pcap_vlan_h 35 | #define lib_pcap_vlan_h 36 | 37 | #include 38 | 39 | struct vlan_tag { 40 | uint16_t vlan_tpid; /* ETH_P_8021Q */ 41 | uint16_t vlan_tci; /* VLAN TCI */ 42 | }; 43 | 44 | #define VLAN_TAG_LEN 4 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /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 "3 January 2014" 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. 38 | .SH SEE ALSO 39 | .BR pcap (3PCAP) 40 | -------------------------------------------------------------------------------- /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 "30 November 2023" 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 look 41 | at packets on the network. 42 | .I source 43 | is a string that specifies the network device to open; on Linux systems 44 | with 2.2 or later kernels, a 45 | .I source 46 | argument of "any" or 47 | .B NULL 48 | can be used to capture packets from all interfaces. 49 | .I errbuf 50 | is a buffer large enough to hold at least 51 | .B PCAP_ERRBUF_SIZE 52 | chars. 53 | .PP 54 | The returned handle must be activated with 55 | .BR pcap_activate (3PCAP) 56 | before packets can be captured 57 | with it; options for the capture, such as promiscuous mode, can be set 58 | on the handle before activating it. 59 | .SH RETURN VALUE 60 | .BR pcap_create () 61 | returns a 62 | .B pcap_t * 63 | on success and 64 | .B NULL 65 | on failure. 66 | If 67 | .B NULL 68 | is returned, 69 | .I errbuf 70 | is filled in with an appropriate error message. 71 | .SH SEE ALSO 72 | .BR pcap (3PCAP) 73 | -------------------------------------------------------------------------------- /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-linktype (@MAN_MISC_INFO@) 72 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 "3 January 2014" 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.'' 36 | .SH SEE ALSO 37 | .BR pcap (3PCAP), 38 | .BR pcap_dump_open (3PCAP), 39 | .BR pcap_dump (3PCAP) 40 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 "3 January 2014" 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; note that it contains more information 37 | than just a version number. 38 | .SH SEE ALSO 39 | .BR pcap (3PCAP) 40 | -------------------------------------------------------------------------------- /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 "13 March 2024" 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. 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 "7 April 2014" 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 | .SH RETURN VALUE 49 | .BR pcap_offline_filter () 50 | returns the return value of the filter program. This will be zero if 51 | the packet doesn't match the filter and non-zero if the packet matches 52 | the filter. 53 | .SH SEE ALSO 54 | .BR pcap (3PCAP) 55 | -------------------------------------------------------------------------------- /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_name_to_val (3PCAP) 59 | -------------------------------------------------------------------------------- /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-tstamp (@MAN_MISC_INFO@) 70 | -------------------------------------------------------------------------------- /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 "5 March 2022" 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 | .SH RETURN VALUE 42 | .BR pcap_setfilter () 43 | returns 44 | .B 0 45 | on success, 46 | .B PCAP_ERROR_NOT_ACTIVATED 47 | if called on a capture handle that has been created but not activated, or 48 | .B PCAP_ERROR 49 | on other errors. If 50 | .B PCAP_ERROR 51 | is returned, 52 | .BR pcap_geterr (3PCAP) 53 | or 54 | .BR pcap_perror (3PCAP) 55 | may be called with 56 | .I p 57 | as an argument to fetch or display the error text. 58 | .SH SEE ALSO 59 | .BR pcap (3PCAP) 60 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_tstamp_type_val_to_name (3PCAP) 50 | -------------------------------------------------------------------------------- /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_tstamp_type_name_to_val (3PCAP) 54 | -------------------------------------------------------------------------------- /post_update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # $1 Path to the new version. 4 | # $2 Path to the old version. 5 | 6 | cp -a -n $2/config.h $1/ 7 | cp -a $2/.gitignore $1/ 8 | cp -a -n $2/pcap-netfilter-linux-android.h $1/ 9 | cp -a -n $2/pcap-netfilter-linux-android.c $1/ 10 | cp -a -n $2/grammar.c $1/ 11 | cp -a -n $2/grammar.h $1/ 12 | cp -a -n $2/scanner.c $1/ 13 | cp -a -n $2/scanner.h $1/ 14 | 15 | -------------------------------------------------------------------------------- /rpcapd/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *~ 3 | *.o 4 | rpcapd 5 | rpcapd.manadmin 6 | rpcapd-config.manfile 7 | -------------------------------------------------------------------------------- /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, 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 | -------------------------------------------------------------------------------- /sunatmpos.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997 Yen Yen Lim and North Dakota State University 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 | * 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 Yen Yen Lim and 16 | North Dakota State University 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 29 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* SunATM header for ATM packet */ 34 | #define SUNATM_DIR_POS 0 35 | #define SUNATM_VPI_POS 1 36 | #define SUNATM_VCI_POS 2 37 | #define SUNATM_PKT_BEGIN_POS 4 /* Start of ATM packet */ 38 | 39 | /* Protocol type values in the bottom for bits of the byte at SUNATM_DIR_POS. */ 40 | #define PT_LANE 0x01 /* LANE */ 41 | #define PT_LLC 0x02 /* LLC encapsulation */ 42 | #define PT_ILMI 0x05 /* ILMI */ 43 | #define PT_QSAAL 0x06 /* Q.SAAL */ 44 | -------------------------------------------------------------------------------- /testprogs/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *~ 3 | *.dSYM 4 | *.o 5 | valgrindtest 6 | capturetest 7 | can_set_rfmon_test 8 | filtertest 9 | findalldevstest 10 | findalldevstest-perf 11 | opentest 12 | reactivatetest 13 | selpolltest 14 | threadsignaltest 15 | writecaptest 16 | nonblocktest 17 | -------------------------------------------------------------------------------- /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(can_set_rfmon_test) 30 | add_test_executable(capturetest) 31 | add_test_executable(filtertest) 32 | add_test_executable(findalldevstest) 33 | add_test_executable(findalldevstest-perf) 34 | add_test_executable(opentest) 35 | add_test_executable(reactivatetest) 36 | add_test_executable(writecaptest) 37 | 38 | if(NOT WIN32) 39 | add_test_executable(selpolltest) 40 | endif() 41 | 42 | add_test_executable(threadsignaltest ${CMAKE_THREAD_LIBS_INIT}) 43 | 44 | # Same as in configure.ac. 45 | if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR 46 | CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR 47 | CMAKE_SYSTEM_NAME STREQUAL "Linux") 48 | add_test_executable(valgrindtest) 49 | endif() 50 | 51 | add_subdirectory(fuzz) 52 | -------------------------------------------------------------------------------- /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 | pcap_setfilter(pkts, &bpf); 34 | pcap_close(pkts); 35 | pcap_freecode(&bpf); 36 | } 37 | else { 38 | pcap_close(pkts); 39 | } 40 | free(filter); 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /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 | 6 | #include 7 | 8 | FILE * outfile = NULL; 9 | 10 | static int bufferToFile(const char * name, const uint8_t *Data, size_t Size) { 11 | FILE * fd; 12 | if (remove(name) != 0) { 13 | if (errno != ENOENT) { 14 | printf("failed remove, errno=%d\n", errno); 15 | return -1; 16 | } 17 | } 18 | fd = fopen(name, "wb"); 19 | if (fd == NULL) { 20 | printf("failed open, errno=%d\n", errno); 21 | return -2; 22 | } 23 | if (fwrite (Data, 1, Size, fd) != Size) { 24 | fclose(fd); 25 | return -3; 26 | } 27 | fclose(fd); 28 | return 0; 29 | } 30 | 31 | void fuzz_openFile(const char * name) { 32 | if (outfile != NULL) { 33 | fclose(outfile); 34 | } 35 | outfile = fopen(name, "w"); 36 | } 37 | 38 | int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 39 | pcap_t * pkts; 40 | char errbuf[PCAP_ERRBUF_SIZE]; 41 | const u_char *pkt; 42 | struct pcap_pkthdr *header; 43 | struct pcap_stat stats; 44 | int r; 45 | 46 | //initialize output file 47 | if (outfile == NULL) { 48 | outfile = fopen("/dev/null", "w"); 49 | if (outfile == NULL) { 50 | return 0; 51 | } 52 | } 53 | 54 | //rewrite buffer to a file as libpcap does not have buffer inputs 55 | if (bufferToFile("/tmp/fuzz.pcap", Data, Size) < 0) { 56 | return 0; 57 | } 58 | 59 | //initialize structure 60 | pkts = pcap_open_offline("/tmp/fuzz.pcap", errbuf); 61 | if (pkts == NULL) { 62 | fprintf(outfile, "Couldn't open pcap file %s\n", errbuf); 63 | return 0; 64 | } 65 | 66 | //loop over packets 67 | r = pcap_next_ex(pkts, &header, &pkt); 68 | while (r > 0) { 69 | //TODO pcap_offline_filter 70 | fprintf(outfile, "packet length=%d/%d\n",header->caplen, header->len); 71 | r = pcap_next_ex(pkts, &header, &pkt); 72 | } 73 | if (pcap_stats(pkts, &stats) == 0) { 74 | fprintf(outfile, "number of packets=%d\n", stats.ps_recv); 75 | } 76 | //close structure 77 | pcap_close(pkts); 78 | 79 | return 0; 80 | } 81 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /testprogs/unix.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 unix_h 35 | #define unix_h 36 | 37 | /* 38 | * Definitions to make MSVC C runtime library structures and functions 39 | * look like the UNIX structures and functions they are intended to 40 | * resemble. 41 | */ 42 | #ifdef _MSC_VER 43 | #define stat _stat 44 | #define fstat _fstat 45 | 46 | #define open _open 47 | #define O_RDONLY _O_RDONLY 48 | #define O_WRONLY _O_WRONLY 49 | #define O_RDWR _O_RDWR 50 | #define O_BINARY _O_BINARY 51 | #define O_CREAT _O_CREAT 52 | #define O_TRUNC _O_TRUNC 53 | #define read _read 54 | #define write _write 55 | #define close _close 56 | #endif 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /tests/pcap-invalid-version-1.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aosp-mirror/platform_external_libpcap/dd978ad56aa6d908517d3ccc793523341206e31d/tests/pcap-invalid-version-1.pcap -------------------------------------------------------------------------------- /tests/pcap-invalid-version-2.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aosp-mirror/platform_external_libpcap/dd978ad56aa6d908517d3ccc793523341206e31d/tests/pcap-invalid-version-2.pcap -------------------------------------------------------------------------------- /tests/pcapng-invalid-vers-1.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aosp-mirror/platform_external_libpcap/dd978ad56aa6d908517d3ccc793523341206e31d/tests/pcapng-invalid-vers-1.pcapng -------------------------------------------------------------------------------- /tests/pcapng-invalid-vers-2.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aosp-mirror/platform_external_libpcap/dd978ad56aa6d908517d3ccc793523341206e31d/tests/pcapng-invalid-vers-2.pcapng -------------------------------------------------------------------------------- /tests/shb-option-too-long.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aosp-mirror/platform_external_libpcap/dd978ad56aa6d908517d3ccc793523341206e31d/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 | --------------------------------------------------------------------------------