Skip to main content

Crate pkttap

Crate pkttap 

Source
Expand description

pkttap — cross-platform packet capture with pktbaffle filter expressions.

§Quick start

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);
}

Structs§

Capture
A packet source: either a live network interface or a pcap/pcapng file.
CaptureBuilder
Builder for a Capture.
Dump
A packet sink that writes to a pcap or pcapng file.
DumpBuilder
Builder for a Dump.
Packet
An owned captured packet.

Enums§

Error
LinkType
Which link-layer framing wraps the packets.

Functions§

default_interface
Return the name of the default network interface for live capture.
dump_packets
Write packets to a pcap or pcapng file in one call.
interfaces
List available network interfaces by name.

Type Aliases§

Result