pypcap (version 0.3)
index
/Volumes/DATA/devel/lib/python/pypcap.so

C/Python bindings for libpcap

 
Classes
       
__builtin__.object
pypcap

 
pcap = class pypcap(__builtin__.object)
    Python/C API for libpcap
 
  Methods defined here:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature
pcap_activate(...)
pcap_activate() -> bool
 
Activate a capture handle
Raises an exception with an appropriate message in case of errors
pcap_can_set_rfmon(...)
pcap_can_set_rfmon() -> bool
 
Check whether monitor mode can be set for a not-yet-activated capture handle
pcap_compile(...)
pcap_compile( capture_filter ) --> bool
 
Compile a filter expression
pcap_create(...)
pcap_create( interface ) -> bool
 
Create a live capture handle
Raises an exception with an appropriate message in case of errors
Returns a True if it was successful
pcap_datalink(...)
pcap_datalink() -> int
 
Get the link-layer header type
pcap_datalink_val_to_description(...)
pcap_datalink_val_to_description() -> s
 
get a name or description for a link-layer header type value
pcap_datalink_val_to_name(...)
pcap_datalink_val_to_name() -> s
 
get a name or description for a link-layer header type value
pcap_dump(...)
pcap_dump()
 
write packets to a capture file
@count = Number of packets to capture. Default = unlimited
@uid = UID of the user to run as. Ex: nobody's UID
pcap_dump_open(...)
pcap_dump_open( filename ) -> bool
 
open a file to which to write packets
pcap_list_datalinks(...)
pcap_list_datalinks() -> list
 
Get a list of link-layer header types supported by a capture device
pcap_loop(...)
pcap_loop( [count], [uid] ) -> bool
 
Starts the pcap capture loop
@count = Number of packets to capture. Default = unlimited
@uid = UID of the user to run as. Ex: nobody's UID 
 
For each packet captured, it will call the callback function 
that was set via pcap_set_callback()
For the UID, somehting like 'pwd.getpwnam('nobody').pw_uid)' can be used
pcap_open_offline(...)
pcap_open_offline( filepath ) -> bool
 
open a saved capture file for reading
pcap_sendpacket(...)
pcap_sendpacket( packet ) -> bool
 
Transmit a packet
Returns True if the packet is succesfully sent
Raises an exception otherwise.
The MAC CRC doesn't need to be included, because it is transparently calculated
and added by the network interface driver.
 
Also see pcap_inject()
pcap_set_buffer_size(...)
pcap_set_buffer_size( size ) -> bool
 
Set the buffer size for a not-yet-activated capture handle
pcap_set_callback(...)
pcap_set_callback( func ) -> bool
 
Set the callback which will be used by pcap_loop
Raises and exception with an appropriate message
Returns a True if it was successful
pcap_set_promisc(...)
pcap_set_promisc( bool ) -> bool
 
Set promiscuous mode for a not-yet-activated capture handle
pcap_set_rfmon(...)
pcap_set_rfmon( bool ) -> bool
 
Set monitor mode for a not-yet-activated capture handle
Returns True if sucessful else returns False
pcap_set_snaplen(...)
pcap_set_snaplen( len ) -> bool
 
Set the snapshot length for a not-yet-activated capture handle
pcap_set_timeout(...)
pcap_set_timeout( timeout ) -> bool
 
Set the read timeout for a not-yet-activated capture handle
pcap_snapshot(...)
pcap_snapshot() -> int
 
get the snapshot length
pcap_stats(...)
pcap_stats() -> dict
 
get capture statistics
ps_recv: number of packets received
ps_drop: number of packets dropped because there was no room in the operating system's buffer when they arrived, because packets weren't being read fast enoug
ps_ifdrop: number of packets dropped by the network interface or its driver
bs_capt: number of packets captured (Win32)

Data descriptors defined here:
callback
Callback function
config
Capture config
interface
Interface name

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

 
Functions
       
pcap_datalink_name_to_val(...)
pcap_datalink_name_to_val( name ) -> int
 
get  the  link-layer header type value corresponding to a header type name
pcap_findalldevs(...)
pcap_findalldevs() -> list
 
Get a list of capture devices
Raises an exception with an appropriate message in case of errors
pcap_lib_version(...)
pcap_lib_version() -> s
 
get the version information for libpcap
pcap_lookupdev(...)
pcap_lookupdev() -> s
 
Find the default device on which to capture
pcap_lookupnet(...)
pcap_lookupnet( interface ) -> (ip, netmask)
 
find the IPv4 network number and netmask for a device
Raises an exception with an appropriate message in case of errors

 
Data
        __version__ = '0.3'