[python] scapy a serializace paketu

Tomas Pelka tompelka na gmail.com
Pondělí Červenec 5 14:30:26 CEST 2010


Zdravim vsechny,

mam maly problem s ukladanim scapy paketu do fronty (multiprocess). Priklad:

from multiprocessing import Process
from multiprocessing.managers import BaseManager
from scapy.all import sniff

class Worker(Process):
         '''
         Class for sniffing packets, runnig as root
         '''
         def __init__(self):
                 super(Worker, self).__init__()
                 self.iface = ''
                 self.expr = ''
                 # key for queue daemon, remotely on localhost:5000
                 self._keyQ = '10b222970537b97919db36ec757370d2'
                 class QueueManager(BaseManager): pass
                 QueueManager.register('get_dataQueue')
                 self._m = QueueManager(address=('127.0.0.1', 5000), 
authkey=self._keyQ)
                 self._m.connect()
                 self.dataQueue = self._m.get_dataQueue()
         def go(self, iface, expr):
                 print "Starting sniffer"
                 self.iface = iface
                 self.expr = expr
                 super(Worker, self).start()
         def run(self):
                 print "sniffing ..."
                 print self.iface
                 print self.expr
                 print self.dataQueue
                 packets = sniff(filter=self.expr, count=10, timeout=10, 
iface=self.iface)
                 print packets
                 self.dataQueue.put(packets)
                 print "... done"


But always getting:
Traceback (most recent call last):
   File "/usr/lib/python2.6/multiprocessing/process.py", line 232, in 
_bootstrap
     self.run()
   File "/home/tom/web2py/applications/NetSim/DAEMON/Worker.py", line 
32, in run
     self.dataQueue.put(packets)
   File "<string>", line 2, in put
   File "/usr/lib/python2.6/multiprocessing/managers.py", line 725, in 
_callmethod
     conn.send((self._id, methodname, args, kwds))
PicklingError: Can't pickle <type 'function'>: attribute lookup 
__builtin__.function failed


PAkety nejsou snad serializovatelne? Nesetkal se s touto chybou uz nekdo 
drive?

Diky za rady

-- 
Tomas Pelka

------------- dal?í ?ást ---------------
HTML p?íloha byla odstran?na...
URL: <http://www.py.cz/pipermail/python/attachments/20100705/ae5b379b/attachment.html>


Další informace o konferenci Python