<--previous | contents | next-->

# Dumper

The Dumper class is used to write pcap dumps to file.

## Interface

### Dumper(feed, file)

Dumper is instantiated with the following arguments:

- feed - An instance of the Live or Offline classes.
- file - A filename to write to.

### __call__(packet, tstamp, length)

A Dumper instance can be called like a function, with the following arguments:

- packet - The packet to be dumped, as a string.
- tstamp - A timestamp tuple of the form (seconds, useconds).
- length - The original length of the packet.

Note that this is the same interface as that of the callback argument to the loop and dispatch methods on PCap feeds.

### close()

Close the dump.

## Example

The example program below does the following:

- Opens an Live feed on an interface.
- Opens a dump from the Live feed to the file "dump".
- Captures 10 packets, writing them to the file.

    import openbsd.pcap

    p = openbsd.pcap.Live("wi0")
    d = openbsd.pcap.Dumper(p, "dump")
    p.loop(10, d)

<--previous | contents | next--> | (12/21/04)

PyOpenbsd v0.1 Manual