Struct pcap::CaptureBuilder [] [src]

pub struct CaptureBuilder {
    // some fields omitted
}

This is a builder for a Capture handle. It's useful when you want to specify certain parameters, like promiscuous mode, or buffer length, before opening.

You can use Capture::from_device() instead of this builder, with less flexibility.

Methods

impl CaptureBuilder
[src]

fn new() -> CaptureBuilder

Creates a CaptureBuilder with sensible defaults.

fn open<D: AsRef<str>>(&self, device: D) -> Result<CaptureError>

Open a Capture with this CaptureBuilder with the given device. You can provide a Device or an &str name of the device/source you would like to open.

fn timeout(&mut self, ms: i32) -> &mut CaptureBuilder

Set the read timeout for the Capture. By default, this is 0, so it will block indefinitely.

fn promisc(&mut self, to: bool) -> &mut CaptureBuilder

Set promiscuous mode on or off. By default, this is off.

fn rfmon(&mut self, to: bool) -> &mut CaptureBuilder

Set rfmon mode on or off. The default is maintained by pcap.

fn buffer_size(&mut self, to: i32) -> &mut CaptureBuilder

Set the buffer size for incoming packet data.

The default is 1000000. This should always be larger than the snaplen.

fn snaplen(&mut self, to: i32) -> &mut CaptureBuilder

Set the snaplen size (the maximum length of a packet captured into the buffer). Useful if you only want certain headers, but not the entire packet.

The default is 65535