def test_ap_dtim_period(dev, apdev): """DTIM period configuration""" ssid = "dtim-period" params = {'ssid': ssid, 'dtim_period': "10"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") for i in range(10): dev[0].scan(freq="2412") bss = dev[0].get_bss(bssid) if 'beacon_ie' in bss: break time.sleep(0.2) if 'beacon_ie' not in bss: raise Exception("Did not find Beacon IEs") ie = parse_ie(bss['beacon_ie']) if 5 not in ie: raise Exception("TIM element missing") count, period = struct.unpack('BB', ie[5][0:2]) logger.info("DTIM count %d DTIM period %d" % (count, period)) if period != 10: raise Exception("Unexpected DTIM period: %d" % period) if count >= period: raise Exception("Unexpected DTIM count: %d" % count)
def _test_ap_track_sta_no_probe_resp(dev, apdev): dev[0].flush_scan_cache() params = {"ssid": "track", "country_code": "US", "hw_mode": "g", "channel": "6", "beacon_int": "10000", "no_probe_resp_if_seen_on": apdev[1]['ifname']} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] params = {"ssid": "track", "country_code": "US", "hw_mode": "a", "channel": "40", "track_sta_max_num": "100"} hapd2 = hostapd.add_ap(apdev[1], params) bssid2 = apdev[1]['bssid'] dev[0].scan_for_bss(bssid2, freq=5200, force_scan=True) dev[1].scan_for_bss(bssid, freq=2437, force_scan=True) dev[0].scan(freq=2437, type="ONLY") dev[0].scan(freq=2437, type="ONLY") bss = dev[0].get_bss(bssid) if bss: ie = parse_ie(bss['ie']) # Check whether this is from a Beacon frame (TIM element included) since # it is possible that a Beacon frame was received during the active # scan. This test should fail only if a Probe Response frame was # received. if 5 not in ie: raise Exception("2.4 GHz AP found unexpectedly")
def run_op_class(dev, apdev, hw_mode, channel, country, ht_capab, sec_chan, freq, opclass): clear_scan_cache(apdev[0]) try: params = { "ssid": "test-ht40", "hw_mode": hw_mode, "channel": channel, "ht_capab": ht_capab } if country: params['country_code'] = country hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) ev = hapd.wait_event(["AP-DISABLED", "AP-ENABLED"], timeout=10) if not ev: raise Exception("AP setup failure timed out") if "AP-DISABLED" in ev: raise HwsimSkip("Channel not supported") sec = hapd.get_status_field("secondary_channel") if sec != sec_chan: raise Exception("Unexpected secondary_channel: " + sec) dev[0].connect("test-ht40", key_mgmt="NONE", scan_freq=freq) bss = dev[0].get_bss(hapd.own_addr()) ie = parse_ie(bss['ie']) if 59 not in ie: raise Exception("Missing Supported Operating Classes element") rx_opclass, = struct.unpack('B', ie[59][0:1]) if rx_opclass != opclass: raise Exception("Unexpected operating class: %d" % rx_opclass) finally: set_world_reg(apdev[0], None, None)
def _test_ap_track_sta_no_probe_resp(dev, bssid, bssid2): dev[0].flush_scan_cache() dev[0].scan_for_bss(bssid2, freq=5200, force_scan=True) dev[1].scan_for_bss(bssid, freq=2437, force_scan=True) dev[0].scan(freq=2437, type="ONLY") dev[0].scan(freq=2437, type="ONLY") bss = dev[0].get_bss(bssid) if bss: ie = parse_ie(bss['ie']) # Check whether this is from a Beacon frame (TIM element included) since # it is possible that a Beacon frame was received during the active # scan. This test should fail only if a Probe Response frame was # received. if 5 not in ie: raise Exception("2.4 GHz AP found unexpectedly")