Registry / networking / pcap
library2.4.0rscratesunverified

A packet capture API around pcap/wpcap for capturing and analyzing network traffic.

# Cargo.toml [dependencies] pcap = "2.4.0"
INSTALL
IMPORT
SIG · PCAP
P
pcap
networkingrustv2.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Capture
use pcap::Capture;

Opens a network device and captures packets.

use pcap::Capture; fn main() -> Result<(), Box<dyn std::error::Error>> { let mut cap = Capture::from_device("eth0")?.open()?; while let Ok(packet) = cap.next_packet() { println!("received packet: {} bytes", packet.len()); } Ok(()) }
Debug
Known issues
gotchaRequires libpcap or wpcap installed on the system; missing library causes build failure.
fix
Install libpcap-dev (Linux) or Npcap/WinPcap (Windows) before building.
affects: >=0
Upgrade
Version history
2.4.0latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
pcap — cargo add pcap · libregistry