Beispiel #1
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")
Beispiel #3
0
def test_p2ps_connect_p2ps_method_nonautoaccept(dev):
    """P2PS connect for non-auto-accept and P2PS config method"""
    addr0 = dev[0].p2p_dev_addr()
    addr1 = dev[1].p2p_dev_addr()
    p2ps_advertise(r_dev=dev[0], r_role='0', svc_name='org.wi-fi.wfds.send.rx',
                   srv_info='I can receive files upto size 2 GB')
    ev_list = p2ps_nonexact_seek(i_dev=dev[1], r_dev=dev[0],
                                 svc_name='org.wi-fi.wfds.send*',
                                 srv_info='2 GB')
    adv_id = ev_list[0].split(" ")[0]
    if "OK" not in dev[1].global_request("P2P_ASP_PROVISION " + addr0 + " adv_id=" + str(adv_id) + " adv_mac=" + addr0 + " session=1 session_mac=" + addr1 + " info='' method=1000"):
        raise Exception("Failed to request provisioning on seeker")
    ev0 = dev[0].wait_global_event(["P2PS-PROV-START"], timeout=10)
    if ev0 is None:
        raise Exception("P2PS-PROV-START timeout on advertiser side")
    ev1 = dev[1].wait_global_event(["P2P-PROV-DISC-FAILURE"], timeout=15)
    if ev1 is None:
        raise Exception("Provisioning deferred timeout on seeker side")
    dev[1].p2p_listen()
    if "OK" not in dev[0].global_request("P2P_ASP_PROVISION_RESP " + addr1 + " adv_id=" + str(adv_id) + " adv_mac=" + addr0 + " session=1 session_mac=" + addr1 + " status=12"):
        raise Exception("Failed to send deferred acceptance from advertizer")
    ev1 = dev[1].wait_global_event(["P2PS-PROV-DONE"], timeout=15)
    if ev1 is None:
        raise Exception("Failed to receive deferred acceptance at seeker")

    p2p_connect_p2ps_method(i_dev=dev[1], r_dev=dev[0], autoaccept=False)
    ev0 = dev[0].global_request("P2P_SERVICE_DEL asp " + str(adv_id))
    if ev0 is None:
        raise Exception("Unable to remove the advertisement instance")
    remove_group(dev[0], dev[1])
Beispiel #4
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()
Beispiel #5
0
def test_p2ps_connect_display_method_nonautoaccept(dev):
    """P2PS connection with non-auto-accept and seeker having display method"""
    addr0 = dev[0].p2p_dev_addr()
    addr1 = dev[1].p2p_dev_addr()
    p2ps_advertise(r_dev=dev[0], r_role='0', svc_name='org.wi-fi.wfds.send.rx',
                   srv_info='I can receive files upto size 2 GB')
    ev_list = p2ps_nonexact_seek(i_dev=dev[1], r_dev=dev[0],
                                 svc_name='org.wi-fi.wfds*', srv_info='2 GB')
    adv_id = ev_list[0].split(" ")[0]
    if "OK" not in dev[1].global_request("P2P_ASP_PROVISION " + addr0 + " adv_id=" + str(adv_id) + " adv_mac=" + addr0 + " session=1 session_mac=" + addr1 + " info='' method=100"):     # keypad method on seeker side
        raise Exception("Failed to request provisioning on seeker")
    pin = p2ps_provision_display_method(i_dev=dev[1], r_dev=dev[0],
                                        autoaccept=False,
                                        initiator_or_responder='initiator')
    dev[1].p2p_listen()

    if "OK" not in dev[0].global_request("P2P_ASP_PROVISION_RESP " + addr1 + " adv_id=" + str(adv_id) + " adv_mac=" + addr0 + " session=1 session_mac=" + addr1 + " status=12"):
        raise Exception("Failed to send deferred acceptance from advertiser")
    p2ps_provision_keypad_method(i_dev=dev[1], r_dev=dev[0], autoaccept=False,
                                 initiator_or_responder='responder')
    p2ps_connect_pin(pin, i_dev=dev[0], r_dev=dev[1], initiator_method="keypad")

    ev0 = dev[0].global_request("P2P_SERVICE_DEL asp " + str(adv_id))
    if ev0 is None:
        raise Exception("Unable to remove the advertisement instance")
    remove_group(dev[0], dev[1])
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])
Beispiel #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])
Beispiel #8
0
def test_p2ps_go_probe(dev):
    """P2PS GO discoverability on operating channel"""
    p2ps_connect_adv_go_pin_method(dev, keep_group=True)
    [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[2], r_dev=dev[0],
                                              svc_name='org.wi-fi.wfds.send.rx',
                                              single_peer_expected=False)
    dev[0].global_request("P2P_SERVICE_DEL asp " + str(adv_id))
    remove_group(dev[0], dev[1])
Beispiel #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)
Beispiel #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)
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()
Beispiel #12
0
def test_p2ps_connect_adv_go_persistent(dev):
    """P2PS auto-accept connection with advertisement as GO and having persistent group"""
    addr0 = dev[0].p2p_dev_addr()
    addr1 = dev[1].p2p_dev_addr()

    go_neg_pin_authorized_persistent(i_dev=dev[0], i_intent=15,
                                     r_dev=dev[1], r_intent=0)
    dev[0].remove_group()
    dev[1].wait_go_ending_session()

    p2ps_advertise(r_dev=dev[0], r_role='4', svc_name='org.wi-fi.wfds.send.rx',
                   srv_info='I can receive files upto size 2 GB')
    [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
                                              svc_name='org.wi-fi.wfds.send.rx',
                                              srv_info='2 GB')
    if "OK" not in dev[1].global_request("P2P_ASP_PROVISION " + addr0 + " adv_id=" + str(adv_id) + " adv_mac=" + addr0 + " session=1 session_mac=" + addr1 + " info='' method=1000"):
        raise Exception("Failed to request provisioning on seeker")

    ev0 = dev[0].wait_global_event(["P2PS-PROV-DONE"], timeout=10)
    if ev0 is None:
        raise Exception("Timed out while waiting for prov done on advertizer")
    if "persist=" not in ev0:
        raise Exception("Advertiser did not indicate persistent group")
    id0 = ev0.split("persist=")[1].split(" ")[0]
    if "OK" not in dev[0].global_request("P2P_GROUP_ADD persistent=" + id0 + " freq=2412"):
        raise Exception("Could not re-start persistent group")

    ev0 = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
    if ev0 is None:
        raise Exception("P2P-GROUP-STARTED timeout on advertiser side")
    dev[0].group_form_result(ev0)

    ev1 = dev[1].wait_global_event(["P2PS-PROV-DONE"], timeout=10)
    if ev1 is None:
        raise Exception("P2PS-PROV-DONE timeout on seeker side")

    if "persist=" not in ev1:
        raise Exception("Seeker did not indicate persistent group")
    id1 = ev1.split("persist=")[1].split(" ")[0]
    if "OK" not in dev[1].global_request("P2P_GROUP_ADD persistent=" + id1 + " freq=2412"):
        raise Exception("Could not re-start persistent group")

    ev1 = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
    if ev1 is None:
        raise Exception("P2P-GROUP-STARTED timeout on seeker side")
    dev[1].group_form_result(ev1)

    ev0 = dev[0].wait_global_event(["AP-STA-CONNECTED"], timeout=15)
    if ev0 is None:
        raise Exception("AP-STA-CONNECTED timeout on advertiser side")
    ev0 = dev[0].global_request("P2P_SERVICE_DEL asp " + str(adv_id))
    if ev0 is None:
        raise Exception("Unable to remove the advertisement instance")
    remove_group(dev[0], dev[1])
Beispiel #13
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)
Beispiel #14
0
def test_p2ps_connect_adv_client_pin_method(dev):
    """P2PS advertiser as client with keypad config method on seeker side and auto-accept"""
    addr0 = dev[0].p2p_dev_addr()
    addr1 = dev[1].p2p_dev_addr()
    dev[0].flush_scan_cache()
    p2ps_advertise(r_dev=dev[0], r_role='2', svc_name='org.wi-fi.wfds.send.rx',
                   srv_info='I can receive files upto size 2 GB')
    [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
                                              svc_name='org.wi-fi.wfds.send.rx',
                                              srv_info='2 GB')
    if "OK" not in dev[1].global_request("P2P_ASP_PROVISION " + addr0 + " adv_id=" + str(adv_id) + " adv_mac=" + addr0 + " session=1 session_mac=" + addr1 + " info='' method=8"):     # keypad method on seeker side
        raise Exception("Failed to request provisioning on seeker")

    seek_prov_ev = p2ps_provision_keypad_method(i_dev=dev[1], r_dev=dev[0],
                                                autoaccept=True,
                                                initiator_or_responder='initiator')

    adv_prov = dev[0].wait_global_event(["P2PS-PROV-DONE"], timeout=10)
    if adv_prov is None:
        raise Exception("Prov failed on advertiser")
    adv_conncap = adv_prov.split("conncap=")[1].split(" ")[0]
    if adv_conncap == "2":
        logger.info("Advertiser is Client")
    adv_pin_show_event = dev[0].wait_global_event(["P2P-PROV-DISC-SHOW-PIN"],
                                                  timeout=5)
    if adv_pin_show_event is None:
        raise Exception("PIN Display on advertiser side")
    pin = adv_pin_show_event.split(" ")[2]

    ev1 = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
    if ev1 is None:
        raise Exception("P2P-GROUP-STARTED timeout on seeker side")
    dev[1].group_form_result(ev1)

    ev1 = dev[1].group_request("WPS_PIN any " + pin)
    if ev1 is None:
        raise Exception("Failed to initiate Pin authorization on registrar side")

    if "join=" in adv_prov:
        if "OK" not in dev[0].global_request("P2P_CONNECT " + addr1 + " " + pin + " display persistent join"):
            raise Exception("P2P_CONNECT failed on advertiser side")
    ev0 = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
    if ev0 is None:
        raise Exception("Group formation failed to start on seeker side")
    dev[0].group_form_result(ev0)

    ev1 = dev[1].wait_global_event(["AP-STA-CONNECTED"], timeout=10)
    if ev1 is None:
        raise Exception("AP-STA-CONNECTED timeout on advertiser side")
    ev0 = dev[0].global_request("P2P_SERVICE_DEL asp " + str(adv_id))
    if ev0 is None:
        raise Exception("Unable to remove the advertisement instance")
    remove_group(dev[0], dev[1])
Beispiel #15
0
def test_p2ps_connect_adv_client_p2ps_method(dev):
    """P2PS auto-accept connection with advertisement as Client and P2PS method"""
    addr0 = dev[0].p2p_dev_addr()
    addr1 = dev[1].p2p_dev_addr()
    p2ps_advertise(r_dev=dev[0], r_role='2', svc_name='org.wi-fi.wfds.send.rx',
                   srv_info='I can receive files upto size 2 GB')
    [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
                                              svc_name='org.wi-fi.wfds.send.rx',
                                              srv_info='2 GB')
    if "OK" not in dev[1].global_request("P2P_ASP_PROVISION " + addr0 + " adv_id=" + str(adv_id) + " adv_mac=" + addr0 + " session=1 session_mac=" + addr1 + " info='' method=1000"):
        raise Exception("Failed to request provisioning on seeker")

    ev0 = dev[0].wait_global_event(["P2PS-PROV-DONE"], timeout=10)
    if ev0 is None:
        raise Exception("P2PS-PROV-DONE timeout on advertiser side")
    if "join=" not in ev0:
        raise Exception("Advertiser failed to become Client")

    adv_conncap = ev0.split("conncap=")[1].split(" ")[0]
    if adv_conncap == "2":
        logger.info("Advertiser is Client")

    ev1 = dev[1].wait_global_event(["P2PS-PROV-DONE"], timeout=5)
    if ev1 is None:
        raise Exception("Provisioning failed on seeker side")

    seeker_conncap = ev1.split("conncap=")[1].split(" ")[0]
    ev1 = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
    if ev1 is None:
        raise Exception("P2P-GROUP-STARTED timeout on seeker side")
    dev[1].group_form_result(ev1)

    if "join=" in ev0:
        if "OK" not in dev[0].global_request("P2P_CONNECT " + addr1 + " 12345670 p2ps persistent join"):
            raise Exception("P2P_CONNECT failed on seeker side")

    ev0 = dev[0].wait_global_event(["P2P-GROUP-FORMATION-SUCCESS"], timeout=15)
    if ev0 is None:
        raise Exception("P2P Group Formation failed on advertiser side")

    ev0 = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
    if ev0 is None:
        raise Exception("P2P-GROUP-STARTED timeout on advertiser side")
    dev[0].group_form_result(ev0)

    ev1 = dev[1].wait_global_event(["AP-STA-CONNECTED"], timeout=5)
    if ev1 is None:
        raise Exception("Group formation failed")
    ev0 = dev[0].global_request("P2P_SERVICE_DEL asp " + str(adv_id))
    if ev0 is None:
        raise Exception("Unable to remove the advertisement instance")
    remove_group(dev[0], dev[1])
Beispiel #16
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")
Beispiel #17
0
def p2ps_connect_adv_go_pin_method(dev, keep_group=False):
    p2ps_advertise(r_dev=dev[0], r_role='4', svc_name='org.wi-fi.wfds.send.rx',
                   srv_info='I can receive files upto size 2 GB')
    [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
                                              svc_name='org.wi-fi.wfds.send.rx',
                                              srv_info='2 GB')
    ev1, ev0, pin = p2ps_provision(dev[1], dev[0], adv_id, method="8")
    p2ps_connect_pd(dev[0], dev[1], ev0, ev1, pin)

    if not keep_group:
        ev0 = dev[0].global_request("P2P_SERVICE_DEL asp " + str(adv_id))
        if ev0 is None:
            raise Exception("Unable to remove the advertisement instance")
        remove_group(dev[0], dev[1])
Beispiel #18
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())
Beispiel #19
0
def test_p2ps_connect_adv_client_p2ps_method(dev):
    """P2PS auto-accept connection with advertisement as Client and P2PS method"""
    p2ps_advertise(r_dev=dev[0], r_role='2', svc_name='org.wi-fi.wfds.send.rx',
                   srv_info='I can receive files upto size 2 GB')
    [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
                                              svc_name='org.wi-fi.wfds.send.rx',
                                              srv_info='2 GB')

    ev1, ev0 = p2ps_provision(dev[1], dev[0], adv_id)
    p2ps_connect_pd(dev[0], dev[1], ev0, ev1)

    ev0 = dev[0].global_request("P2P_SERVICE_DEL asp " + str(adv_id))
    if ev0 is None:
        raise Exception("Unable to remove the advertisement instance")
    remove_group(dev[0], dev[1])
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)
Beispiel #21
0
def test_p2ps_connect_display_method_autoaccept(dev):
    """P2PS connection with auto-accept and display method on seeker side"""
    p2ps_advertise(r_dev=dev[0], r_role='1', svc_name='org.wi-fi.wfds.send.rx',
                   srv_info='I can receive files upto size 2 GB')
    [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
                                              svc_name='org.wi-fi.wfds.send.rx',
                                              srv_info='2 GB')

    ev1, ev0, pin = p2ps_provision(dev[1], dev[0], adv_id, method="100")
    p2ps_connect_pd(dev[0], dev[1], ev0, ev1, pin)

    ev0 = dev[0].global_request("P2P_SERVICE_DEL asp " + str(adv_id))
    if ev0 is None:
        raise Exception("Unable to remove the advertisement instance")
    remove_group(dev[0], dev[1])
Beispiel #22
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()
Beispiel #23
0
def test_p2ps_connect_display_method_nonautoaccept(dev):
    """P2PS connection with non-auto-accept and seeker having display method"""
    p2ps_advertise(r_dev=dev[0], r_role='0', svc_name='org.wi-fi.wfds.send.rx',
                   srv_info='I can receive files upto size 2 GB')
    ev_list = p2ps_nonexact_seek(i_dev=dev[1], r_dev=dev[0],
                                 svc_name='org.wi-fi.wfds*', srv_info='2 GB')
    adv_id = ev_list[0].split()[0]

    ev1, ev0, pin = p2ps_provision(dev[1], dev[0], adv_id, auto_accept=False, method="100")
    p2ps_connect_pd(dev[0], dev[1], ev0, ev1, pin)

    ev0 = dev[0].global_request("P2P_SERVICE_DEL asp " + str(adv_id))
    if ev0 is None:
        raise Exception("Unable to remove the advertisement instance")
    remove_group(dev[0], dev[1])
Beispiel #24
0
def test_p2ps_connect_adv_client_pin_method(dev):
    """P2PS advertiser as client with keypad config method on seeker side and auto-accept"""
    dev[0].flush_scan_cache()
    p2ps_advertise(r_dev=dev[0], r_role='2', svc_name='org.wi-fi.wfds.send.rx',
                   srv_info='I can receive files upto size 2 GB')
    [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
                                              svc_name='org.wi-fi.wfds.send.rx',
                                              srv_info='2 GB')

    ev1, ev0, pin = p2ps_provision(dev[1], dev[0], adv_id, method="8")
    p2ps_connect_pd(dev[0], dev[1], ev0, ev1, pin)

    ev0 = dev[0].global_request("P2P_SERVICE_DEL asp " + str(adv_id))
    if ev0 is None:
        raise Exception("Unable to remove the advertisement instance")
    remove_group(dev[0], dev[1])
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)
Beispiel #26
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'])
Beispiel #27
0
def p2ps_connect_p2ps_method(dev):
    addr0 = dev[0].p2p_dev_addr()
    addr1 = dev[1].p2p_dev_addr()
    dev[0].flush_scan_cache()
    dev[1].flush_scan_cache()
    p2ps_advertise(r_dev=dev[0], r_role='2', svc_name='org.wi-fi.wfds.send.rx',
                   srv_info='I can receive files upto size 2 GB')
    [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
                                              svc_name='org.wi-fi.wfds.send.rx',
                                              srv_info='2 GB')
    if "OK" not in dev[1].global_request("P2P_ASP_PROVISION " + addr0 + " adv_id=" + str(adv_id) + " adv_mac=" + addr0 + " session=1 session_mac=" + addr1 + " info='test-session-info-data' method=1000"):
        raise Exception("Failed to request provisioning on seeker")

    ev0 = dev[0].wait_global_event(["P2PS-PROV-DONE"], timeout=10)
    if ev0 is None:
        raise Exception("P2PS-PROV-DONE timeout on advertiser side")
    if "join=" not in ev0:
        raise Exception("join parameter missing from P2PS-PROV-DONE")

    ev1 = dev[1].wait_global_event(["P2PS-PROV-DONE"], timeout=5)
    if ev1 is None:
        raise Exception("Provisioning failed on seeker side")

    ev1 = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
    if ev1 is None:
        raise Exception("P2P-GROUP-STARTED timeout on seeker side")
    res1 = dev[1].group_form_result(ev1)
    ifnames1 = get_ifnames()

    if "OK" not in dev[0].global_request("P2P_CONNECT " + addr1 + " 12345670 p2ps persistent join"):
        raise Exception("P2P_CONNECT failed on seeker side")

    ev0 = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
    if ev0 is None:
        raise Exception("P2P-GROUP-STARTED timeout on advertiser side")
    res0 = dev[0].group_form_result(ev0)

    ev1 = dev[1].wait_global_event(["AP-STA-CONNECTED"], timeout=5)
    if ev1 is None:
        raise Exception("Group formation failed")
    ev0 = dev[0].global_request("P2P_SERVICE_DEL asp " + str(adv_id))
    if ev0 is None:
        raise Exception("Unable to remove the advertisement instance")
    ifnames2 = get_ifnames()
    remove_group(dev[0], dev[1])
    ifnames3 = get_ifnames()
    return (res0, res1, ifnames1 + ifnames2 + ifnames3)
Beispiel #28
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 ")
Beispiel #29
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'])
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()
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()
Beispiel #32
0
def test_concurrent_grpform_while_connecting2(dev, apdev):
    """Concurrent P2P group formation while connecting to an AP (2)"""
    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)
    dev[1].flush_scan_cache()

    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_pbc(i_dev=dev[0], i_intent=15, i_freq=2412,
                                r_dev=dev[1], r_intent=0, 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")
    dev[0].wait_completed()
    hwsim_utils.test_connectivity(dev[0], hapd)
Beispiel #33
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()
Beispiel #34
0
def test_p2ps_connect_adv_go_persistent(dev):
    """P2PS auto-accept connection with advertisement as GO and having persistent group"""
    go_neg_pin_authorized_persistent(i_dev=dev[0], i_intent=15,
                                     r_dev=dev[1], r_intent=0)
    dev[0].remove_group()
    dev[1].wait_go_ending_session()

    p2ps_advertise(r_dev=dev[0], r_role='4', svc_name='org.wi-fi.wfds.send.rx',
                   srv_info='I can receive files upto size 2 GB')
    [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
                                              svc_name='org.wi-fi.wfds.send.rx',
                                              srv_info='2 GB')
    ev1, ev0 = p2ps_provision(dev[1], dev[0], adv_id)
    if "persist=" not in ev0 or "persist=" not in ev1:
        raise Exception("Persistent group isn't used by peers")

    p2ps_connect_pd(dev[0], dev[1], ev0, ev1)
    remove_group(dev[0], dev[1])
def test_concurrent_grpform_while_connecting2(dev, apdev):
    """Concurrent P2P group formation while connecting to an AP (2)"""
    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)
    dev[1].request("BSS_FLUSH 0")
    dev[1].scan(freq="2412", only_new=True)

    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_pbc(i_dev=dev[0], i_intent=15, i_freq=2412,
                                r_dev=dev[1], r_intent=0, 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")
    dev[0].wait_completed()
    hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
Beispiel #36
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 ")
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)
Beispiel #38
0
def test_p2ps_connect_display_method_autoaccept(dev):
    """P2PS connection with auto-accept and display method on seeker side"""
    addr0 = dev[0].p2p_dev_addr()
    addr1 = dev[1].p2p_dev_addr()
    p2ps_advertise(r_dev=dev[0], r_role='1', svc_name='org.wi-fi.wfds.send.rx',
                   srv_info='I can receive files upto size 2 GB')
    [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
                                              svc_name='org.wi-fi.wfds.send.rx',
                                              srv_info='2 GB')
    if "OK" not in dev[1].global_request("P2P_ASP_PROVISION " + addr0 + " adv_id=" + str(adv_id) + " adv_mac=" + addr0 + " session=1 session_mac=" + addr1 + " info='' method=100"):     # display method on seeker side
        raise Exception("Failed to request provisioning on seeker")

    pin = p2ps_provision_display_method(i_dev=dev[1], r_dev=dev[0],
                                        autoaccept=True,
                                        initiator_or_responder='initiator')
    dev[1].p2p_listen()

    p2ps_connect_pin(pin, i_dev=dev[1], r_dev=dev[0], initiator_method="display")
    ev0 = dev[0].global_request("P2P_SERVICE_DEL asp " + str(adv_id))
    if ev0 is None:
        raise Exception("Unable to remove the advertisement instance")
    remove_group(dev[0], dev[1])
Beispiel #39
0
def test_p2ps_connect_p2ps_method_autoaccept(dev):
    """P2PS connection with P2PS default config method and auto-accept"""
    addr0 = dev[0].p2p_dev_addr()
    addr1 = dev[1].p2p_dev_addr()
    p2ps_advertise(r_dev=dev[0], r_role='1', svc_name='org.wi-fi.wfds.send.rx',
                   srv_info='I can receive files upto size 2 GB')
    [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
                                              svc_name='org.wi-fi.wfds.send.rx',
                                              srv_info='2 GB')
    if "OK" not in dev[1].global_request("P2P_ASP_PROVISION " + addr0 + " adv_id=" + str(adv_id) + " adv_mac=" + addr0 + " session=1 session_mac=" + addr1 + " info='' method=1000"):
        raise Exception("P2P_ASP_PROVISION failed on seeker side")

    ev0 = dev[0].wait_global_event(["P2PS-PROV-DONE"], timeout=10)
    if ev0 is None:
        raise Exception("P2PS-PROV-DONE timeout on advertiser side")

    p2p_connect_p2ps_method(i_dev=dev[1], r_dev=dev[0], autoaccept=True)

    ev0 = dev[0].global_request("P2P_SERVICE_DEL asp " + str(adv_id))
    if ev0 is None:
        raise Exception("Unable to remove the advertisement instance")
    remove_group(dev[0], dev[1])
Beispiel #40
0
def p2ps_connect_p2ps_method(dev, keep_group=False):
    dev[0].flush_scan_cache()
    dev[1].flush_scan_cache()
    p2ps_advertise(r_dev=dev[0], r_role='2', svc_name='org.wi-fi.wfds.send.rx',
                   srv_info='I can receive files upto size 2 GB')
    [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
                                              svc_name='org.wi-fi.wfds.send.rx',
                                              srv_info='2 GB')
    ev1, ev0 = p2ps_provision(dev[1], dev[0], adv_id)
    ifnames = get_ifnames()
    p2ps_connect_pd(dev[0], dev[1], ev0, ev1)

    grp_ifname0 = dev[0].get_group_ifname()
    grp_ifname1 = dev[1].get_group_ifname()
    if not keep_group:
        ev0 = dev[0].global_request("P2P_SERVICE_DEL asp " + str(adv_id))
        if ev0 is None:
            raise Exception("Unable to remove the advertisement instance")
        ifnames = ifnames + get_ifnames()
        remove_group(dev[0], dev[1])
        ifnames = ifnames + get_ifnames()

    return grp_ifname0, grp_ifname1, ifnames
Beispiel #41
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())