def test_rfkill_hostapd(dev, apdev): """rfkill block/unblock during and prior to hostapd operations""" hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" }) id = get_rfkill_id(hapd) if id is None: return "skip" try: subprocess.call(['rfkill', 'block', id]) ev = hapd.wait_event(["INTERFACE-DISABLED"], timeout=5) if ev is None: raise Exception("INTERFACE-DISABLED event not seen") subprocess.call(['rfkill', 'unblock', id]) ev = hapd.wait_event(["INTERFACE-ENABLED"], timeout=5) if ev is None: raise Exception("INTERFACE-ENABLED event not seen") # hostapd does not current re-enable beaconing automatically hapd.disable() hapd.enable() dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") subprocess.call(['rfkill', 'block', id]) ev = hapd.wait_event(["INTERFACE-DISABLED"], timeout=5) if ev is None: raise Exception("INTERFACE-DISABLED event not seen") ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10) if ev is None: raise Exception("Missing disconnection event") dev[0].request("DISCONNECT") hapd.disable() hglobal = HostapdGlobal() hglobal.flush() hglobal.remove(apdev[0]['ifname']) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open2" }, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): raise Exception("ENABLE succeeded unexpectedly (rfkill)") finally: subprocess.call(['rfkill', 'unblock', id])
def reset_devs(dev, apdev): ok = True for d in dev: try: d.reset() except Exception as e: logger.info("Failed to reset device " + d.ifname) print(str(e)) ok = False wpas = None try: wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5', monitor=False) ifaces = wpas.global_request("INTERFACES").splitlines() for iface in ifaces: if iface.startswith("wlan"): wpas.interface_remove(iface) except Exception as e: pass if wpas: wpas.close_ctrl() del wpas try: hapd = HostapdGlobal() hapd.flush() hapd.remove('wlan3-6') hapd.remove('wlan3-5') hapd.remove('wlan3-4') hapd.remove('wlan3-3') hapd.remove('wlan3-2') for ap in apdev: hapd.remove(ap['ifname']) except Exception as e: logger.info("Failed to remove hostapd interface") print(str(e)) ok = False return ok
def test_rfkill_hostapd(dev, apdev): """rfkill block/unblock during and prior to hostapd operations""" hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" }) rfk = get_rfkill(hapd) try: rfk.block() ev = hapd.wait_event(["INTERFACE-DISABLED"], timeout=5) if ev is None: raise Exception("INTERFACE-DISABLED event not seen") rfk.unblock() ev = hapd.wait_event(["INTERFACE-ENABLED"], timeout=5) if ev is None: raise Exception("INTERFACE-ENABLED event not seen") # hostapd does not current re-enable beaconing automatically hapd.disable() hapd.enable() dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") rfk.block() ev = hapd.wait_event(["INTERFACE-DISABLED"], timeout=5) if ev is None: raise Exception("INTERFACE-DISABLED event not seen") dev[0].wait_disconnected(timeout=10) dev[0].request("DISCONNECT") hapd.disable() hglobal = HostapdGlobal() hglobal.flush() hglobal.remove(apdev[0]['ifname']) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open2" }, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): raise Exception("ENABLE succeeded unexpectedly (rfkill)") finally: rfk.unblock()
wpas = None try: wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5', monitor=False) ifaces = wpas.global_request("INTERFACES").splitlines() for iface in ifaces: if iface.startswith("wlan"): wpas.interface_remove(iface) except Exception, e: pass if wpas: wpas.close_ctrl() try: hapd = HostapdGlobal() hapd.flush() hapd.remove('wlan3-6') hapd.remove('wlan3-5') hapd.remove('wlan3-4') hapd.remove('wlan3-3') hapd.remove('wlan3-2') for ap in apdev: hapd.remove(ap['ifname']) except Exception, e: logger.info("Failed to remove hostapd interface") print str(e) ok = False return ok def add_log_file(conn, test, run, type, path): if not os.path.exists(path):
wpas = None try: wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') ifaces = wpas.global_request("INTERFACES").splitlines() for iface in ifaces: if iface.startswith("wlan"): wpas.interface_remove(iface) except Exception, e: pass if wpas: wpas.close_ctrl() try: hapd = HostapdGlobal() hapd.flush() hapd.remove('wlan3-3') hapd.remove('wlan3-2') for ap in apdev: hapd.remove(ap['ifname']) except Exception, e: logger.info("Failed to remove hostapd interface") print str(e) ok = False return ok def add_log_file(conn, test, run, type, path): if not os.path.exists(path): return contents = None