Struct pcap::Capture [] [src]

pub struct Capture {
    // some fields omitted
}

This represents an open capture handle attached to a device or file.

Internally it represents a pcap_t.

Methods

impl Capture
[src]

fn from_device<D: AsRef<str>>(device: D) -> Result<CaptureError>

Creates a capture handle from the specified device, or an error from pcap.

You can provide this a Device from Devices::list_all() or an &str name of the device such as "any" on Linux.

fn from_file<P: AsRef<Path>>(path: P) -> Result<CaptureError>

Creates a capture handle from the specified file, or an error from pcap.

List the datalink types that this captured device supports.

Set the datalink type for the current capture handle.

Get the current datalink type for this capture handle.

fn next<'a>(&'a mut self) -> Option<&'a [u8]>

Blocks until a packet is returned from the capture handle or an error occurs.

pcap captures packets and places them into a buffer which this function reads from. This buffer has a finite length, so if the buffer fills completely new packets will be discarded temporarily. This means that in realtime situations, you probably want to minimize the time between calls of this next() method.

fn filter(&mut self, program: &str) -> Result<()Error>

Adds a filter to the capture using the given BPF program string. Internally this is compiled using pcap_compile().

See http://biot.com/capstats/bpf.html for more information about this syntax.

Trait Implementations

impl Drop for Capture
[src]

fn drop(&mut self)

A method called when the value goes out of scope. Read more