<--previous | contents | next-->

# pcap

The pcap module is an Object Oriented interface to the OpenBSD pcap library.

## Example

The example program below does the following:

- It opens a live pcap dump on the interface "wi0".
- It applies a filter to the dump (see tcpdump(8)).
- It then captures 10 packets, and prints a hex representation of the packet, the timestamp (in the format (seconds, useconds)) and the length of the packet.

    import openbsd.pcap

    def callback(packet, tstamp, length):
        print repr(packet), tstamp, length

    p = openbsd.pcap.Live("wi0")
    p.filter("host basho and tcp port 22")
    p.loop(10, callback)

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

PyOpenbsd v0.1 Manual