Author: kp
Date: Thu Mar 21 08:15:46 2019
New Revision: 345367
URL: https://svnweb.freebsd.org/changeset/base/345367

Log:
  pf tests: Move Sniffer to its own file
  
  Make it easier to re-use the sniffer class in other test support
  scripts.

Added:
  head/tests/sys/netpfil/pf/sniffer.py   (contents, props changed)
Modified:
  head/tests/sys/netpfil/pf/Makefile
  head/tests/sys/netpfil/pf/pft_ping.py

Modified: head/tests/sys/netpfil/pf/Makefile
==============================================================================
--- head/tests/sys/netpfil/pf/Makefile  Thu Mar 21 08:09:52 2019        
(r345366)
+++ head/tests/sys/netpfil/pf/Makefile  Thu Mar 21 08:15:46 2019        
(r345367)
@@ -20,6 +20,7 @@ ATF_TESTS_SH+=        anchor \
 
 ${PACKAGE}FILES+=      utils.subr \
                        echo_inetd.conf \
+                       sniffer.py \
                        pft_ping.py \
                        CVE-2019-5597.py
 

Modified: head/tests/sys/netpfil/pf/pft_ping.py
==============================================================================
--- head/tests/sys/netpfil/pf/pft_ping.py       Thu Mar 21 08:09:52 2019        
(r345366)
+++ head/tests/sys/netpfil/pf/pft_ping.py       Thu Mar 21 08:15:46 2019        
(r345367)
@@ -3,30 +3,9 @@
 import argparse
 import scapy.all as sp
 import sys
-import threading
+from sniffer import Sniffer
 
 PAYLOAD_MAGIC = 0x42c0ffee
-
-class Sniffer(threading.Thread):
-       def __init__(self, args, check_function):
-               threading.Thread.__init__(self)
-
-               self._args = args
-               self._recvif = args.recvif[0]
-               self._check_function = check_function
-               self.foundCorrectPacket = False
-
-               self.start()
-
-       def _checkPacket(self, packet):
-               ret = self._check_function(self._args, packet)
-               if ret:
-                       self.foundCorrectPacket = True
-               return ret
-
-       def run(self):
-               self.packets = sp.sniff(iface=self._recvif,
-                               stop_filter=self._checkPacket, timeout=3)
 
 def check_ping_request(args, packet):
        if args.ip6:

Added: head/tests/sys/netpfil/pf/sniffer.py
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tests/sys/netpfil/pf/sniffer.py        Thu Mar 21 08:15:46 2019        
(r345367)
@@ -0,0 +1,25 @@
+# $FreeBSD$
+
+import threading
+import scapy.all as sp
+
+class Sniffer(threading.Thread):
+       def __init__(self, args, check_function):
+               threading.Thread.__init__(self)
+
+               self._args = args
+               self._recvif = args.recvif[0]
+               self._check_function = check_function
+               self.foundCorrectPacket = False
+
+               self.start()
+
+       def _checkPacket(self, packet):
+               ret = self._check_function(self._args, packet)
+               if ret:
+                       self.foundCorrectPacket = True
+               return ret
+
+       def run(self):
+               self.packets = sp.sniff(iface=self._recvif,
+                               stop_filter=self._checkPacket, timeout=3)
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to