objects.logic.network.pcapyImplementation.pcapyImplementation Class Reference

the pcapyImplementation is the implementation of the captureInterface interface using pcapy's packet capture library. More...

Inherits objects::logic::network::captureInterface::captureInterface.

List of all members.

Public Member Functions

def __init__
def getDeviceList
 Returns a list of all known device names in their NPF form.
def queryDevice
 Does nothing.
def openDevice
 Opens a generic device.
def closeDevice
 Does nothing.
def startListening
 start listening to the supplied device.
def stopListening
 stops listening to a device.
def handleReceivePacet
 Callback method supplied to the pcapyWorkerThread class.

Public Attributes

 deviceObject
 decoder
 listenThread
 lck
 deviceName


Detailed Description

the pcapyImplementation is the implementation of the captureInterface interface using pcapy's packet capture library.

For further information see the captureInterface class.

Definition at line 65 of file pcapyImplementation.py.


Member Function Documentation

def objects.logic.network.pcapyImplementation.pcapyImplementation.__init__ (   self  ) 

Reimplemented from objects.logic.network.captureInterface.captureInterface.

Definition at line 66 of file pcapyImplementation.py.

00066                       :
00067         captureInterface.__init__(self)
00068         
00069         self.deviceObject = None
00070         
00071         self.decoder = packetDecoder()
00072         
00073         #Threading related objects
00074         self.listenThread = None
00075         
00076         self.lck = RLock()
00077     
00078     
00079         
    ## Returns a list of all known device names in their NPF form

def objects.logic.network.pcapyImplementation.pcapyImplementation.closeDevice (   self,
  device 
)

Does nothing.

Pcapy does not support querying a device.

Parameters:
device String representing a device name (NPF Form)

Reimplemented from objects.logic.network.captureInterface.captureInterface.

Definition at line 118 of file pcapyImplementation.py.

00118                                  :
00119         # no device close for pcapy ?
00120         pass
00121     
00122     
00123     
    ## start listening to the supplied device. Calling this method will

def objects.logic.network.pcapyImplementation.pcapyImplementation.getDeviceList (   self  ) 

Returns a list of all known device names in their NPF form.

Returns:
List of Strings

Reimplemented from objects.logic.network.captureInterface.captureInterface.

Definition at line 82 of file pcapyImplementation.py.

00082                            :
00083         try:
00084             devices = findalldevs()
00085         except pcapy.PcapError, pce:
00086             raise exception(str(pce), True)
00087         else:
00088             return devices
00089     
00090     
00091     
    ## Does nothing. Pcapy does not support querying a device.

def objects.logic.network.pcapyImplementation.pcapyImplementation.handleReceivePacet (   self,
  header,
  data 
)

Callback method supplied to the pcapyWorkerThread class.

Parameters:
header Raw DataLink header
data Raw DataLink frame

Definition at line 149 of file pcapyImplementation.py.

00149                                               :        
00150         self.lck.acquire(1)
00151         try:            
00152             # decode the packet...
00153             self.notify(header, data, self.deviceName)            
00154         except exception, e:
00155             logger.log(__name__ + ": Caught an exception while processing packet data: " + e.reason)
00156         except Exception, ex:
00157             logger.log(__name__ + ": Caught an unknown exception while processing packet data: " + str(ex))
00158             
00159         finally:
00160             self.lck.release()
00161     
00162     

def objects.logic.network.pcapyImplementation.pcapyImplementation.openDevice (   self,
  device 
)

Opens a generic device.

Parameters:
device Generic device object, defined by its implementors

Reimplemented from objects.logic.network.captureInterface.captureInterface.

Definition at line 102 of file pcapyImplementation.py.

00102                                 :
00103         logger.log(__name__ + ": Opening network Device: " + device)
00104         try:
00105             self.deviceObject = open_live(device, 8192, 0, 100)
00106         except pcapy.PcapError, pce:
00107             logger.log(__name__ + ": " + str(pce))
00108             raise exception(str(pce), 1)
00109         else:
00110             # pass the reader to the decoder
00111             self.decoder.setReader(self.deviceObject)
00112             self.deviceName = device
00113 
00114 
00115 
    ## Does nothing. Pcapy does not support querying a device.

def objects.logic.network.pcapyImplementation.pcapyImplementation.queryDevice (   self,
  device 
)

Does nothing.

Pcapy does not support querying a device.

Parameters:
device String representing a device name (NPF Form)

Reimplemented from objects.logic.network.captureInterface.captureInterface.

Definition at line 94 of file pcapyImplementation.py.

00094                                  :
00095         #no device queries for pcapy?
00096         return "no info"
00097     
00098     
00099     
00100     # Opens a device
00101     # @param device String representing a device name (NPF Form)
    def openDevice(self, device):

def objects.logic.network.pcapyImplementation.pcapyImplementation.startListening (   self,
  device 
)

start listening to the supplied device.

Calling this method will start the main instance of the pcapyWorkerThread class

Parameters:
device String representing a device name (NPF Form)

Reimplemented from objects.logic.network.captureInterface.captureInterface.

Definition at line 127 of file pcapyImplementation.py.

00127                                     :
00128                 
00129         self.stopListening()
00130             
00131         try:
00132             self.openDevice(device) # throws exception
00133         except exception, e:
00134             raise e
00135         else:                            
00136             self.listenThread  = pcapyWorkerThread(self)
00137             self.listenThread.start()
00138             
    ## stops listening to a device. It does little more than stopping the pcapyWorkerThread worker thread

def objects.logic.network.pcapyImplementation.pcapyImplementation.stopListening (   self  ) 

stops listening to a device.

It does little more than stopping the pcapyWorkerThread worker thread

Reimplemented from objects.logic.network.captureInterface.captureInterface.

Definition at line 140 of file pcapyImplementation.py.

00140                            :        
00141         if self.listenThread != None and self.listenThread.isAlive() == True:
00142             self.listenThread.killSignalAndWait(1)
00143 
00144         
00145     


Member Data Documentation

Definition at line 71 of file pcapyImplementation.py.

Definition at line 69 of file pcapyImplementation.py.

Definition at line 76 of file pcapyImplementation.py.

Definition at line 74 of file pcapyImplementation.py.


The documentation for this class was generated from the following file:

Generated on Mon Mar 30 00:26:45 2009 for EyeSpy by  doxygen 1.5.8