hcap 0.0.2

A packet capture API around pcap/wpcap
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
extern crate pcap;

fn main() {
    // listen on the device named "any", which is only available on Linux. This is only for
    // demonstration purposes.
    let mut cap = pcap::Capture::from_device("any").unwrap().open().unwrap();

    // filter out all packets that don't have 127.0.0.1 as a source or destination.
    cap.filter("host 127.0.0.1").unwrap();

    while let Ok(packet) = cap.next() {
    	println!("got packet! {:?}", packet);
    }
}