self.status = status
self.is_running = False
- @dbus.service.method(NAME,
- in_signature='', out_signature='')
- def Start(self, device='mon0'):
- # FIXME: Prevent double Start()
+ def setup_monitor(device='mon0'):
# FIXME: Replace hardcoded interface
cmd = '/usr/sbin/iw wlan0 interface add mon0 type monitor'.split()
subprocess.call(cmd)
cmd = '/sbin/ifconfig mon0 up'.split()
subprocess.call(cmd)
+
+ @dbus.service.method(NAME,
+ in_signature='', out_signature='')
+ def Start(self):
+ # FIXME: Prevent double Start()
+ self.setup_monitor(self.device):
self.is_running = True
try:
self.cap = pcap.pcap(device)
def GetMessage(self):
return self.status
+
+ def tear_down_monitor(device='mon0'):
+ cmd = '/sbin/ifconfig mon0 down'.split()
+ subprocess.call(cmd)
+ cmd = '/usr/sbin/iw dev mon0 del'.split()
+ subprocess.call(cmd)
+
@dbus.service.method(NAME,
in_signature='', out_signature='')
def Stop(self):
self.is_running = False
print "Receive Stop"
gobject.source_remove(self.source_id)
- cmd = '/sbin/ifconfig mon0 down'.split()
- subprocess.call(cmd)
- cmd = '/usr/sbin/iw dev mon0 del'.split()
- subprocess.call(cmd)
+ self.tear_down_monitor(self.device)
loop.quit()