| |
- __builtin__.object
-
- bpf
- pcap
class bpf(__builtin__.object) |
|
bpf(filter, dlt=DLT_RAW) -> BPF filter object |
|
Methods defined here:
- __init__(...)
- x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- filter(...)
- Return boolean match for buf against our filter.
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class pcap(__builtin__.object) |
|
pcap(name=None, snaplen=65535, promisc=True, immediate=False) -> packet capture object
Open a handle to a packet capture descriptor.
Keyword arguments:
name -- name of a network interface or dumpfile to open,
or None to open the first available up interface
snaplen -- maximum number of bytes to capture for each packet
promisc -- boolean to specify promiscuous mode sniffing
immediate -- disable buffering, if possible |
|
Methods defined here:
- __init__(...)
- x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- __iter__(...)
- x.__iter__() <==> iter(x)
- datalink(...)
- Return datalink type (DLT_* values).
- dispatch(...)
- Collect and process packets with a user callback,
return the number of packets processed, or 0 for a savefile.
Arguments:
callback -- function with (timestamp, pkt, arg) prototype
arg -- optional argument passed to callback on execution
cnt -- number of packets to process;
or 0 to process all packets until an error occurs,
EOF is reached, or the read times out;
or -1 to process all packets received in one buffer
- fileno(...)
- Return file descriptor (or Win32 HANDLE) for capture handle.
- geterr(...)
- Return the last error message associated with this handle.
- loop(...)
- Loop forever, processing packets with a user callback.
The loop can be exited with an exception, including KeyboardInterrupt.
Arguments:
callback -- function with (timestamp, pkt, arg) prototype
arg -- optional argument passed to callback on execution
- next(...)
- x.next() -> the next value, or raise StopIteration
- readpkts(...)
- Return a list of (timestamp, packet) tuples received in one buffer.
- setfilter(...)
- Set BPF-format packet capture filter.
- stats(...)
- Return a 3-tuple of the total number of packets received,
dropped, and dropped by the interface.
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
- dloff = <attribute 'dloff' of 'pcap.pcap' objects>
- Datalink offset (length of layer-2 frame header).
- fd = <attribute 'fd' of 'pcap.pcap' objects>
- File descriptor (or Win32 HANDLE) for capture handle.
- filter = <attribute 'filter' of 'pcap.pcap' objects>
- Current packet capture filter.
- name = <attribute 'name' of 'pcap.pcap' objects>
- Network interface or dumpfile name.
- snaplen = <attribute 'snaplen' of 'pcap.pcap' objects>
- Maximum number of bytes to capture for each packet.
| |