def test_p2p_channel_random_social_with_op_class_change(dev, apdev, params):
    """P2P group formation using random social channel with oper class change needed"""
    try:
        set_country("US", dev[0])
        logger.info("Start group on 5 GHz")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0],
                                               i_intent=15,
                                               r_dev=dev[1],
                                               r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq < 5000:
            raise Exception(
                "Unexpected channel %d MHz - did not pick 5 GHz preference" %
                freq)
        remove_group(dev[0], dev[1])

        logger.info(
            "Disable 5 GHz and try to re-start group based on 5 GHz preference"
        )
        dev[0].request("SET p2p_oper_reg_class 115")
        dev[0].request("SET p2p_oper_channel 36")
        dev[0].request("P2P_SET disallow_freq 5000-6000")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0],
                                               i_intent=15,
                                               r_dev=dev[1],
                                               r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq not in [2412, 2437, 2462]:
            raise Exception(
                "Unexpected channel %d MHz - did not pick random social channel"
                % freq)
        remove_group(dev[0], dev[1])

        out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
                         "wifi_p2p.public_action.subtype == 0")
        if out is not None:
            last = None
            for l in out.splitlines():
                if "Operating Channel:" not in l:
                    continue
                last = l
            if last is None:
                raise Exception("Could not find GO Negotiation Request")
            if "Operating Class 81" not in last:
                raise Exception("Unexpected operating class: " + last.strip())
    finally:
        set_country("00")
        dev[0].request("P2P_SET disallow_freq ")
        dev[0].request("SET p2p_oper_reg_class 0")
        dev[0].request("SET p2p_oper_channel 0")
        dev[1].flush_scan_cache()
Exemplo n.º 2
0
def test_p2p_channel_random_social_with_op_class_change(dev, apdev, params):
    """P2P group formation using random social channel with oper class change needed"""
    try:
        set_country("US")
        logger.info("Start group on 5 GHz")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=dev[1], r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq < 5000:
            raise Exception("Unexpected channel %d MHz - did not pick 5 GHz preference" % freq)
        remove_group(dev[0], dev[1])

        logger.info("Disable 5 GHz and try to re-start group based on 5 GHz preference")
        dev[0].request("SET p2p_oper_reg_class 115")
        dev[0].request("SET p2p_oper_channel 36")
        dev[0].request("P2P_SET disallow_freq 5000-6000")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=dev[1], r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq not in [ 2412, 2437, 2462 ]:
            raise Exception("Unexpected channel %d MHz - did not pick random social channel" % freq)
        remove_group(dev[0], dev[1])

        try:
            arg = [ "tshark",
                    "-r", os.path.join(params['logdir'], "hwsim0.pcapng"),
                    "-R", "wifi_p2p.public_action.subtype == 0",
                    "-V" ]
            cmd = subprocess.Popen(arg, stdout=subprocess.PIPE,
                                   stderr=open('/dev/null', 'w'))
        except Exception, e:
            logger.info("Could run run tshark check: " + str(e))
            cmd = None
            pass

        if cmd:
            last = None
            for l in cmd.stdout.read().splitlines():
                if "Operating Channel:" not in l:
                    continue
                last = l
            if last is None:
                raise Exception("Could not find GO Negotiation Request")
            if "Operating Class 81" not in last:
                raise Exception("Unexpected operating class: " + last.strip())
Exemplo n.º 3
0
def test_p2p_device_grpform(dev, apdev):
    """P2P group formation with driver using cfg80211 P2P Device"""
    with HWSimRadio(use_p2p_device=True) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=wpas, r_intent=0)
        check_grpform_results(i_res, r_res)
        wpas.dump_monitor()
        remove_group(dev[0], wpas)
        wpas.dump_monitor()

        res = wpas.global_request("IFNAME=p2p-dev-" + iface + " STATUS-DRIVER")
        lines = res.splitlines()
        found = False
        for l in lines:
            try:
                [name,value] = l.split('=', 1)
                if name == "wdev_id":
                    found = True
                    break
            except ValueError:
                pass
        if not found:
            raise Exception("wdev_id not found")
def test_p2p_device_grpform(dev, apdev):
    """P2P group formation with driver using cfg80211 P2P Device"""
    with HWSimRadio(use_p2p_device=True) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0],
                                               i_intent=15,
                                               r_dev=wpas,
                                               r_intent=0)
        check_grpform_results(i_res, r_res)
        remove_group(dev[0], wpas)

        res = wpas.global_request("IFNAME=p2p-dev-" + iface + " STATUS-DRIVER")
        lines = res.splitlines()
        found = False
        for l in lines:
            try:
                [name, value] = l.split('=', 1)
                if name == "wdev_id":
                    found = True
                    break
            except ValueError:
                pass
        if not found:
            raise Exception("wdev_id not found")
Exemplo n.º 5
0
def test_connect_cmd_concurrent_grpform_while_connecting(dev, apdev):
    """Concurrent P2P group formation while connecting to an AP using cfg80211 connect command"""
    logger.info("Start connection to an infrastructure AP")
    hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })

    wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
    wpas.interface_add("wlan5", drv_params="force_connect_cmd=1")
    wpas.connect("test-open", key_mgmt="NONE", wait_connect=False)
    wpas.dump_monitor()

    logger.info("Form a P2P group while connecting to an AP")
    wpas.request("SET p2p_no_group_iface 0")

    [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_freq=2412,
                                           r_dev=wpas, r_freq=2412)
    check_grpform_results(i_res, r_res)
    remove_group(dev[0], wpas)
    wpas.dump_monitor()

    logger.info("Confirm AP connection after P2P group removal")
    hwsim_utils.test_connectivity(wpas, hapd)

    wpas.request("DISCONNECT")
    wpas.wait_disconnected()
    wpas.dump_monitor()
Exemplo n.º 6
0
def test_p2p_device_grpform2(dev, apdev):
    """P2P group formation with driver using cfg80211 P2P Device (reverse)"""
    wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
    wpas.interface_add("wlan5")
    [i_res, r_res] = go_neg_pin_authorized(i_dev=wpas, i_intent=15,
                                           r_dev=dev[0], r_intent=0)
    check_grpform_results(i_res, r_res)
    remove_group(wpas, dev[0])
Exemplo n.º 7
0
def test_p2p_device_grpform2(dev, apdev):
    """P2P group formation with driver using cfg80211 P2P Device (reverse)"""
    wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
    wpas.interface_add("wlan5")
    [i_res, r_res] = go_neg_pin_authorized(i_dev=wpas, i_intent=15,
                                           r_dev=dev[0], r_intent=0)
    check_grpform_results(i_res, r_res)
    remove_group(wpas, dev[0])
Exemplo n.º 8
0
def test_p2p_channel_random_social_with_op_class_change(dev, apdev, params):
    """P2P group formation using random social channel with oper class change needed"""
    try:
        set_country("US", dev[0])
        logger.info("Start group on 5 GHz")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=dev[1], r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq < 5000:
            raise Exception("Unexpected channel %d MHz - did not pick 5 GHz preference" % freq)
        remove_group(dev[0], dev[1])

        logger.info("Disable 5 GHz and try to re-start group based on 5 GHz preference")
        dev[0].request("SET p2p_oper_reg_class 115")
        dev[0].request("SET p2p_oper_channel 36")
        dev[0].request("P2P_SET disallow_freq 5000-6000")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=dev[1], r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq not in [ 2412, 2437, 2462 ]:
            raise Exception("Unexpected channel %d MHz - did not pick random social channel" % freq)
        remove_group(dev[0], dev[1])

        out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
                         "wifi_p2p.public_action.subtype == 0")
        if out is not None:
            last = None
            for l in out.splitlines():
                if "Operating Channel:" not in l:
                    continue
                last = l
            if last is None:
                raise Exception("Could not find GO Negotiation Request")
            if "Operating Class 81" not in last:
                raise Exception("Unexpected operating class: " + last.strip())
    finally:
        set_country("00")
        dev[0].request("P2P_SET disallow_freq ")
        dev[0].request("SET p2p_oper_reg_class 0")
        dev[0].request("SET p2p_oper_channel 0")
        dev[1].flush_scan_cache()
Exemplo n.º 9
0
def test_offchannel_tx_roc_grpform2(dev, apdev):
    """P2P group formation(2) using cfg80211 remain-on-channel for offchannel TX"""
    wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
    wpas.interface_add("wlan5", drv_params="no_offchannel_tx=1")

    [i_res, r_res] = go_neg_pin_authorized(i_dev=wpas, i_freq=2412,
                                           r_dev=dev[0], r_freq=2412)
    check_grpform_results(i_res, r_res)
    remove_group(dev[0], wpas)
Exemplo n.º 10
0
def test_p2p_device_grpform(dev, apdev):
    """P2P group formation with driver using cfg80211 P2P Device"""
    with HWSimRadio(use_p2p_device=True) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=wpas, r_intent=0)
        check_grpform_results(i_res, r_res)
        remove_group(dev[0], wpas)
Exemplo n.º 11
0
def test_p2p_device_grpform(dev, apdev):
    """P2P group formation with driver using cfg80211 P2P Device"""
    with HWSimRadio(use_p2p_device=True) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0],
                                               i_intent=15,
                                               r_dev=wpas,
                                               r_intent=0)
        check_grpform_results(i_res, r_res)
        remove_group(dev[0], wpas)
Exemplo n.º 12
0
def test_p2p_channel_5ghz(dev):
    """P2P group formation with 5 GHz preference"""
    try:
        set_country("US")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=dev[1], r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq < 5000:
            raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq)
        remove_group(dev[0], dev[1])
    finally:
        set_country("00")
Exemplo n.º 13
0
def test_concurrent_grpform_while_connecting(dev, apdev):
    """Concurrent P2P group formation while connecting to an AP"""
    logger.info("Start connection to an infrastructure AP")
    hapd = hostapd.add_ap(apdev[0]["ifname"], {"ssid": "test-open"})
    dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False)

    logger.info("Form a P2P group while connecting to an AP")
    dev[0].request("SET p2p_no_group_iface 0")

    [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_freq=2412, r_dev=dev[1], r_freq=2412)
    check_grpform_results(i_res, r_res)
    remove_group(dev[0], dev[1])

    logger.info("Confirm AP connection after P2P group removal")
    hwsim_utils.test_connectivity(dev[0], hapd)
Exemplo n.º 14
0
def test_p2p_channel_5ghz(dev):
    """P2P group formation with 5 GHz preference"""
    try:
        set_country("US", dev[0])
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=dev[1], r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq < 5000:
            raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq)
        remove_group(dev[0], dev[1])
    finally:
        set_country("00")
        dev[1].flush_scan_cache()
Exemplo n.º 15
0
def test_concurrent_grpform_while_connecting(dev, apdev):
    """Concurrent P2P group formation while connecting to an AP"""
    logger.info("Start connection to an infrastructure AP")
    hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
    dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False)

    logger.info("Form a P2P group while connecting to an AP")
    dev[0].request("SET p2p_no_group_iface 0")

    [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_freq=2412,
                                           r_dev=dev[1], r_freq=2412)
    check_grpform_results(i_res, r_res)
    remove_group(dev[0], dev[1])

    logger.info("Confirm AP connection after P2P group removal")
    hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
Exemplo n.º 16
0
def test_concurrent_grpform_cli(dev, apdev):
    """Concurrent P2P group formation to become P2P Client"""
    logger.info("Connect to an infrastructure AP")
    hapd = hostapd.add_ap(apdev[0]["ifname"], {"ssid": "test-open"})
    dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
    hwsim_utils.test_connectivity(dev[0], hapd)

    logger.info("Form a P2P group while associated to an AP")
    dev[0].request("SET p2p_no_group_iface 0")

    [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0, r_dev=dev[1], r_intent=15)
    check_grpform_results(i_res, r_res)
    remove_group(dev[0], dev[1])

    logger.info("Confirm AP connection after P2P group removal")
    hwsim_utils.test_connectivity(dev[0], hapd)
Exemplo n.º 17
0
def test_p2p_channel_random(dev):
    """P2P group formation with 5 GHz preference but all 5 GHz channels and all social channels disabled"""
    try:
        set_country("US")
        dev[0].request("SET p2p_oper_channel 11")
        dev[0].request("P2P_SET disallow_freq 5000-6000,2412,2437,2462")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=dev[1], r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq > 2500 or freq in [ 2412, 2437, 2462 ]:
            raise Exception("Unexpected channel %d MHz" % freq)
        remove_group(dev[0], dev[1])
    finally:
        set_country("00")
        dev[0].request("P2P_SET disallow_freq ")
def test_p2p_go_move_scm_peer_supports(dev, apdev, params):
    """P2P GO move due to SCM operation preference (peer supports) [long]"""
    if dev[0].get_mcc() <= 1:
        raise HwsimSkip("Skip due to MCC not being enabled")

    if not params['long']:
        raise HwsimSkip(
            "Skip test case with long duration due to --long not specified")

    try:
        dev[0].global_request("SET p2p_go_freq_change_policy 1")
        set_country("US", dev[0])

        dev[0].request("SET p2p_no_group_iface 0")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0],
                                               i_intent=15,
                                               r_dev=dev[1],
                                               r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq < 5000:
            raise Exception(
                "Unexpected channel %d MHz - did not follow 5 GHz preference" %
                freq)

        hapd = hostapd.add_ap(apdev[0]['ifname'], {
            "ssid": 'ap-test',
            "channel": '11'
        })
        logger.info('Connecting client to to an AP on channel 11')
        dev[0].connect("ap-test", key_mgmt="NONE", scan_freq="2462")

        ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP"],
                                     timeout=3)
        if ev is None:
            raise Exception("P2P-REMOVE-AND-REFORM-GROUP not seen")

        freq = dev[0].get_group_status_field('freq')
        if freq != '2462':
            raise Exception("Unexpected freq after group reform=" + freq)

        dev[0].remove_group()
    finally:
        dev[0].global_request("SET p2p_go_freq_change_policy 2")
        set_country("00")
Exemplo n.º 19
0
def test_p2p_channel_5ghz_no_vht(dev):
    """P2P group formation with 5 GHz preference when VHT channels are disallowed"""
    try:
        set_country("US", dev[0])
        dev[0].request("P2P_SET disallow_freq 5180-5240")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=dev[1], r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq < 5000:
            raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq)
        remove_group(dev[0], dev[1])
    finally:
        set_country("00")
        dev[0].request("P2P_SET disallow_freq ")
        dev[1].flush_scan_cache()
Exemplo n.º 20
0
def test_concurrent_grpform_cli(dev, apdev):
    """Concurrent P2P group formation to become P2P Client"""
    logger.info("Connect to an infrastructure AP")
    hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
    dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
    hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])

    logger.info("Form a P2P group while associated to an AP")
    dev[0].request("SET p2p_no_group_iface 0")

    [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
                                           r_dev=dev[1], r_intent=15)
    check_grpform_results(i_res, r_res)
    remove_group(dev[0], dev[1])

    logger.info("Confirm AP connection after P2P group removal")
    hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
Exemplo n.º 21
0
def test_p2p_device_group_remove(dev, apdev):
    """P2P group removal via the P2P ctrl interface with driver using cfg80211 P2P Device"""
    with HWSimRadio(use_p2p_device=True) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=wpas, r_intent=0)
        check_grpform_results(i_res, r_res)
        # Issue the remove request on the interface which will be removed
        p2p_iface_wpas = WpaSupplicant(ifname=r_res['ifname'])
        res = p2p_iface_wpas.request("P2P_GROUP_REMOVE *")
        if "OK" not in res:
            raise Exception("Failed to remove P2P group")
        ev = wpas.wait_global_event(["P2P-GROUP-REMOVED"], timeout=10)
        if ev is None:
            raise Exception("Group removal event not received")
        if not wpas.global_ping():
            raise Exception("Could not ping global ctrl_iface after group removal")
Exemplo n.º 22
0
def test_p2p_device_group_remove(dev, apdev):
    """P2P group removal via the P2P ctrl interface with driver using cfg80211 P2P Device"""
    with HWSimRadio(use_p2p_device=True) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=wpas, r_intent=0)
        check_grpform_results(i_res, r_res)
        # Issue the remove request on the interface which will be removed
        p2p_iface_wpas = WpaSupplicant(ifname=r_res['ifname'])
        res = p2p_iface_wpas.request("P2P_GROUP_REMOVE *")
        if "OK" not in res:
            raise Exception("Failed to remove P2P group")
        ev = wpas.wait_global_event(["P2P-GROUP-REMOVED"], timeout=10)
        if ev is None:
            raise Exception("Group removal event not received")
        if not wpas.global_ping():
            raise Exception("Could not ping global ctrl_iface after group removal")
Exemplo n.º 23
0
def test_p2p_channel_random(dev):
    """P2P group formation with 5 GHz preference but all 5 GHz channels and all social channels disabled"""
    try:
        set_country("US", dev[0])
        dev[0].request("SET p2p_oper_channel 11")
        dev[0].request("P2P_SET disallow_freq 5000-6000,2412,2437,2462")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=dev[1], r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq > 2500 or freq in [ 2412, 2437, 2462 ]:
            raise Exception("Unexpected channel %d MHz" % freq)
        remove_group(dev[0], dev[1])
    finally:
        set_country("00")
        dev[0].request("P2P_SET disallow_freq ")
        dev[1].flush_scan_cache()
def test_p2p_channel_avoid(dev):
    """P2P and avoid frequencies driver event"""
    try:
        set_country("US", dev[0])
        if "OK" not in dev[0].request(
                "DRIVER_EVENT AVOID_FREQUENCIES 5000-6000,2412,2437,2462"):
            raise Exception("Could not simulate driver event")
        ev = dev[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout=10)
        if ev is None:
            raise Exception("No CTRL-EVENT-AVOID-FREQ event")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0],
                                               i_intent=15,
                                               r_dev=dev[1],
                                               r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq > 2500 or freq in [2412, 2437, 2462]:
            raise Exception("Unexpected channel %d MHz" % freq)

        if "OK" not in dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES"):
            raise Exception("Could not simulate driver event(2)")
        ev = dev[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout=10)
        if ev is None:
            raise Exception("No CTRL-EVENT-AVOID-FREQ event")
        ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP"],
                                     timeout=1)
        if ev is not None:
            raise Exception("Unexpected P2P-REMOVE-AND-REFORM-GROUP event")

        if "OK" not in dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES " +
                                      str(freq)):
            raise Exception("Could not simulate driver event(3)")
        ev = dev[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout=10)
        if ev is None:
            raise Exception("No CTRL-EVENT-AVOID-FREQ event")
        ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP"],
                                     timeout=10)
        if ev is None:
            raise Exception("No P2P-REMOVE-AND-REFORM-GROUP event")
    finally:
        set_country("00")
        dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES")
        dev[1].flush_scan_cache()
Exemplo n.º 25
0
def test_p2p_channel_5ghz_no_vht(dev):
    """P2P group formation with 5 GHz preference when VHT channels are disallowed"""
    try:
        set_country("US")
        dev[0].request("P2P_SET disallow_freq 5180-5240")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0],
                                               i_intent=15,
                                               r_dev=dev[1],
                                               r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq < 5000:
            raise Exception(
                "Unexpected channel %d MHz - did not follow 5 GHz preference" %
                freq)
        remove_group(dev[0], dev[1])
    finally:
        set_country("00")
        dev[0].request("P2P_SET disallow_freq ")
Exemplo n.º 26
0
def test_p2p_channel_avoid(dev):
    """P2P and avoid frequencies driver event"""
    try:
        set_country("US", dev[0])
        if "OK" not in dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES 5000-6000,2412,2437,2462"):
            raise Exception("Could not simulate driver event")
        ev = dev[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout=10)
        if ev is None:
            raise Exception("No CTRL-EVENT-AVOID-FREQ event")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=dev[1], r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq > 2500 or freq in [ 2412, 2437, 2462 ]:
            raise Exception("Unexpected channel %d MHz" % freq)

        if "OK" not in dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES"):
            raise Exception("Could not simulate driver event(2)")
        ev = dev[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout=10)
        if ev is None:
            raise Exception("No CTRL-EVENT-AVOID-FREQ event")
        ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
                                      "AP-CSA-FINISHED"], timeout=1)
        if ev is not None:
            raise Exception("Unexpected + " + ev + " event")

        if "OK" not in dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES " + str(freq)):
            raise Exception("Could not simulate driver event(3)")
        ev = dev[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout=10)
        if ev is None:
            raise Exception("No CTRL-EVENT-AVOID-FREQ event")
        ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
                                      "AP-CSA-FINISHED"],
                                     timeout=10)
        if ev is None:
            raise Exception("No P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED event")
    finally:
        set_country("00")
        dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES")
        dev[1].flush_scan_cache()
def test_connect_cmd_concurrent_grpform_while_connecting(dev, apdev):
    """Concurrent P2P group formation while connecting to an AP using cfg80211 connect command"""
    logger.info("Start connection to an infrastructure AP")
    hapd = hostapd.add_ap(apdev[0]['ifname'], {"ssid": "test-open"})

    wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
    wpas.interface_add("wlan5", drv_params="force_connect_cmd=1")
    wpas.connect("test-open", key_mgmt="NONE", wait_connect=False)

    logger.info("Form a P2P group while connecting to an AP")
    wpas.request("SET p2p_no_group_iface 0")

    [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0],
                                           i_freq=2412,
                                           r_dev=wpas,
                                           r_freq=2412)
    check_grpform_results(i_res, r_res)
    remove_group(dev[0], wpas)

    logger.info("Confirm AP connection after P2P group removal")
    hwsim_utils.test_connectivity(wpas, hapd)
Exemplo n.º 28
0
def test_p2p_go_move_scm_peer_supports(dev, apdev, params):
    """P2P GO move due to SCM operation preference (peer supports) [long]"""
    if dev[0].get_mcc() <= 1:
        raise HwsimSkip("Skip due to MCC not being enabled")

    if not params['long']:
        raise HwsimSkip("Skip test case with long duration due to --long not specified")

    try:
        dev[0].global_request("SET p2p_go_freq_change_policy 1")
        set_country("US", dev[0])

        dev[0].request("SET p2p_no_group_iface 0")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=dev[1], r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq < 5000:
            raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq)

        hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid" : 'ap-test',
                                                    "channel" : '11' })
        logger.info('Connecting client to to an AP on channel 11');
        dev[0].connect("ap-test", key_mgmt="NONE",
                       scan_freq="2462")

        ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
                                      "AP-CSA-FINISHED"], timeout=3)
        if ev is None:
            raise Exception("P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED not seen")

        freq = dev[0].get_group_status_field('freq')
        if freq != '2462':
            raise Exception("Unexpected freq after group reform=" + freq)

        dev[0].remove_group()
    finally:
        dev[0].global_request("SET p2p_go_freq_change_policy 2")
        set_country("00")
Exemplo n.º 29
0
def test_p2p_go_move_scm_peer_does_not_support(dev, apdev, params):
    """No P2P GO move due to SCM operation (peer does not supports) [long]"""
    if dev[0].get_mcc() <= 1:
        raise HwsimSkip("Skip due to MCC not being enabled")

    if not params['long']:
        raise HwsimSkip("Skip test case with long duration due to --long not specified")

    try:
        dev[0].global_request("SET p2p_go_freq_change_policy 1")
        set_country("US", dev[0])

        dev[0].request("SET p2p_no_group_iface 0")
        if "OK" not in dev[1].request("DRIVER_EVENT AVOID_FREQUENCIES 2400-2500"):
            raise Exception("Could not simulate driver event")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                               r_dev=dev[1], r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq < 5000:
            raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq)

        hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid" : 'ap-test',
                                                    "channel" : '11' })
        logger.info('Connecting client to to an AP on channel 11');
        dev[0].connect("ap-test", key_mgmt="NONE",
                       scan_freq="2462")

        ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP"],
                                     timeout=10)
        if ev is not None:
            raise Exception("Unexpected P2P-REMOVE-AND-REFORM-GROUP seen")

        dev[0].remove_group()
    finally:
        dev[0].global_request("SET p2p_go_freq_change_policy 2")
        set_country("00")
Exemplo n.º 30
0
def test_p2p_channel_random_social_with_op_class_change(dev, apdev, params):
    """P2P group formation using random social channel with oper class change needed"""
    try:
        set_country("US")
        logger.info("Start group on 5 GHz")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0],
                                               i_intent=15,
                                               r_dev=dev[1],
                                               r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq < 5000:
            raise Exception(
                "Unexpected channel %d MHz - did not pick 5 GHz preference" %
                freq)
        remove_group(dev[0], dev[1])

        logger.info(
            "Disable 5 GHz and try to re-start group based on 5 GHz preference"
        )
        dev[0].request("SET p2p_oper_reg_class 115")
        dev[0].request("SET p2p_oper_channel 36")
        dev[0].request("P2P_SET disallow_freq 5000-6000")
        [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0],
                                               i_intent=15,
                                               r_dev=dev[1],
                                               r_intent=0,
                                               test_data=False)
        check_grpform_results(i_res, r_res)
        freq = int(i_res['freq'])
        if freq not in [2412, 2437, 2462]:
            raise Exception(
                "Unexpected channel %d MHz - did not pick random social channel"
                % freq)
        remove_group(dev[0], dev[1])

        try:
            arg = [
                "tshark", "-r",
                os.path.join(params['logdir'], "hwsim0.pcapng"), "-R",
                "wifi_p2p.public_action.subtype == 0", "-V"
            ]
            cmd = subprocess.Popen(arg,
                                   stdout=subprocess.PIPE,
                                   stderr=open('/dev/null', 'w'))
        except Exception, e:
            logger.info("Could run run tshark check: " + str(e))
            cmd = None
            pass

        if cmd:
            last = None
            for l in cmd.stdout.read().splitlines():
                if "Operating Channel:" not in l:
                    continue
                last = l
            if last is None:
                raise Exception("Could not find GO Negotiation Request")
            if "Operating Class 81" not in last:
                raise Exception("Unexpected operating class: " + last.strip())