1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! **pkttap** — cross-platform packet capture with pktbaffle filter expressions.
//!
//! # Quick start
//!
//! ```no_run
//! use pkttap::Capture;
//!
//! // Live capture
//! let mut cap = Capture::live("eth0")
//! .promiscuous(true)
//! .filter("tcp port 443")
//! .open()?;
//!
//! while let Some(pkt) = cap.next()? {
//! println!("{} bytes", pkt.data.len());
//! }
//!
//! // File capture
//! let mut cap = Capture::from_file("dump.pcap")
//! .filter("udp port 53")
//! .open()?;
//!
//! while let Some(pkt) = cap.next()? {
//! println!("{} bytes at {:?}", pkt.data.len(), pkt.timestamp);
//! }
//! # Ok::<(), pkttap::Error>(())
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
/// List available network interfaces by name.
/// Return the name of the default network interface for live capture.
///
/// This is the first non-loopback interface the OS makes available — the
/// same device `pcap_lookupdev` would return. Useful as a sensible default
/// in CLIs or UIs when the user has not specified an interface.
///
/// Returns `Err` if no usable interface is found, or if the platform capture
/// backend (e.g. Npcap on Windows) is not available.
/// Write `packets` to a pcap or pcapng file in one call.
///
/// The format is chosen by file extension (`.pcap` or `.pcapng`).
/// This is a convenience wrapper around [`Dump`]; for streaming use,
/// open a `Dump` directly.