chris
2010-02-16 13:58:05 UTC
Hi list,
scapy-developers,
I found old posts from October 2008 ("sniffing, thread and signal ?")
where somebody extended the sniff() function to be interruptable. The
code was put on the Wiki:
http://trac.secdev.org/scapy/wiki/PatchSelectStopperTimeout
Since I ran into the same problems than the franck34 in his post, I
followed a similar (light-weight) approach. I deliver an abortion
function as parameter to the sniff() method that is checked as break
condition in the outer while loop (instead of 'while true'). If this
function returns false, sniff() will return.
Actually this code is just a small change to the scapy code and yet very
useful, in particular if you aim at proper exit handling. I'd be glad if
you could re-consider including the following snippet in one of the next
scapy versions:
522c522,523
<
---
< def sniff(count=0, store=1, offline=None, prn = None, lfilter=None,
L2socket=None, timeout=None, opened_socket=None, *arg, **karg):
---
**karg):
558c559
< while 1:
---
I don't think that this causes too much performance overhead to the
sniff() function (and maybe there is even a better solution than the
work-around with the yes() function that returns always True).
Thanks in advance!
Best regards,
Chris
---------------------------------------------------------------------
To unsubscribe, send a mail to scapy.ml-***@secdev.org
scapy-developers,
I found old posts from October 2008 ("sniffing, thread and signal ?")
where somebody extended the sniff() function to be interruptable. The
code was put on the Wiki:
http://trac.secdev.org/scapy/wiki/PatchSelectStopperTimeout
Since I ran into the same problems than the franck34 in his post, I
followed a similar (light-weight) approach. I deliver an abortion
function as parameter to the sniff() method that is checked as break
condition in the outer while loop (instead of 'while true'). If this
function returns false, sniff() will return.
Actually this code is just a small change to the scapy code and yet very
useful, in particular if you aim at proper exit handling. I'd be glad if
you could re-consider including the following snippet in one of the next
scapy versions:
522c522,523
<
---
return True
525c526< def sniff(count=0, store=1, offline=None, prn = None, lfilter=None,
L2socket=None, timeout=None, opened_socket=None, *arg, **karg):
---
def sniff(count=0, store=1, offline=None, prn = None, lfilter=None,
L2socket=None, timeout=None, opened_socket=None, keepRunning=yes, *arg,**karg):
558c559
< while 1:
---
I don't think that this causes too much performance overhead to the
sniff() function (and maybe there is even a better solution than the
work-around with the yes() function that returns always True).
Thanks in advance!
Best regards,
Chris
---------------------------------------------------------------------
To unsubscribe, send a mail to scapy.ml-***@secdev.org