Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Library:libpcap

From ReverseEngineering.wiki
Library
Developer The Tcpdump Group
License BSD-3-Clause
Website https://www.tcpdump.org
On this wiki Facts · Code · Notes · Topics

The portable packet capture library of the tcpdump group (BSD-3-Clause): live capture through pcap_open_live, offline reading and writing of Format:pcap savefiles, and the BPF filter compiler.

Overview

libpcap is what tcpdump, Wireshark (on most platforms), nmap, Suricata and many closed tools use to capture packets. Programs that link it import pcap_open_live, pcap_create, pcap_activate, pcap_loop, pcap_next_ex, pcap_compile, pcap_setfilter, pcap_dump_open, pcap_findalldevs; the Windows port (Npcap, WinPcap) exports the same names from wpcap.dll (the names are libpcap's public API: pcap/pcap.h, libpcap commit ba925f7be2ad4cc90ff00ea249310679094221a5, declares pcap_create line 428, pcap_activate 462, pcap_open_live 543, pcap_loop 597, pcap_next_ex 608, pcap_setfilter 618, pcap_compile 653, pcap_dump_open 736 and pcap_findalldevs 786; Unverified: the DLL name wpcap.dll, which the libpcap tree only hints at, its CMakeLists.txt line 3242 saying the library "might be called wpcap" in a Windows build).

Savefile code

sf-pcap.c reads and writes Format:pcap (libpcap savefile) (magic defines at the top of the file); pcap/pcap.h has struct pcap_file_header and struct pcap_pkthdr; pcap/dlt.h the DLT_ link-layer numbers.

Identifying it in a binary

  • Strings of its error messages and the version string returned by pcap_lib_version() ("libpcap version x.y.z"; Unverified).
  • The constants 0xA1B2C3D4 and 0xA1B23C4D in a program that writes captures.

Source

https://github.com/the-tcpdump-group/libpcap (BSD license).

Code & repositories

  • https://github.com/the-tcpdump-group/libpcap @ ba925f7be2ad4cc90ff00ea249310679094221a5 · license: BSD-3-Clause (declared by the contributor for the files used; GitHub reports BSD-2-Clause (read from LICENSE; GitHub's detector did not classify it) for the repository)
    libpcap: sf-pcap.c savefile reader/writer with the magic numbers, pcap/pcap.h file and record header structs, pcap/dlt.h link types.
    Tested on: source read, not run: source only · checked 2026-10-18; last activity 2026-10-17