示例#1
0
def test_autogo_force_diff_channel(dev, apdev):
    """P2P autonomous GO and station interface operate on different channels"""
    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)

        if wpas.get_mcc() < 2:
            raise Exception("New radio does not support MCC")

        wpas.request("SET p2p_no_group_iface 0")

        hapd = hostapd.add_ap(apdev[0]['ifname'], {
            "ssid": 'ap-test',
            "channel": '1'
        })
        wpas.connect("ap-test", key_mgmt="NONE", scan_freq="2412")
        wpas.dump_monitor()
        channels = {2: 2417, 5: 2432, 9: 2452}
        for key in channels:
            res_go = autogo(wpas, channels[key])
            wpas.dump_monitor()
            hwsim_utils.test_connectivity(wpas, hapd)
            if int(res_go['freq']) == 2412:
                raise Exception("Group operation channel is: 2412 excepted: " +
                                res_go['freq'])
            wpas.remove_group(res_go['ifname'])
            wpas.dump_monitor()
def test_autogo_with_bss_on_disallowed_chan(dev, apdev):
    """P2P channel selection: Autonomous GO with BSS on a disallowed channel"""

    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)

        wpas.request("SET p2p_no_group_iface 0")

        if wpas.get_mcc() < 2:
            raise Exception("New radio does not support MCC")

        try:
            hapd = hostapd.add_ap(apdev[0]['ifname'], {
                "ssid": 'bss-2.4ghz',
                "channel": '1'
            })
            wpas.request("P2P_SET disallow_freq 2412")
            wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
            res = autogo(wpas)
            if res['freq'] == "2412":
                raise Exception("GO set on a disallowed channel")
            hwsim_utils.test_connectivity(wpas, hapd)
        finally:
            wpas.request("P2P_SET disallow_freq ")
def test_go_neg_with_bss_on_disallowed_chan(dev, apdev):
    """P2P channel selection: GO negotiation with station interface on a disallowed channel"""

    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)

        wpas.request("SET p2p_no_group_iface 0")

        if wpas.get_mcc() < 2:
            raise Exception("New radio does not support MCC")

        try:
            hapd = hostapd.add_ap(apdev[0]['ifname'], {
                "ssid": 'bss-2.4ghz',
                "channel": '1'
            })
            # make sure PBC overlap from old test cases is not maintained
            dev[1].flush_scan_cache()
            wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
            wpas.request("P2P_SET disallow_freq 2412")

            #wpas as GO
            [i_res, r_res] = go_neg_pbc(i_dev=wpas,
                                        i_intent=10,
                                        r_dev=dev[1],
                                        r_intent=1)
            check_grpform_results(i_res, r_res)
            if i_res['role'] != "GO":
                raise Exception("GO not selected according to go_intent")
            if i_res['freq'] == "2412":
                raise Exception("Group formed on a disallowed channel")
            hwsim_utils.test_connectivity(wpas, hapd)
            wpas.remove_group(i_res['ifname'])
            dev[1].wait_go_ending_session()
            dev[1].flush_scan_cache()

            wpas.dump_monitor()
            dev[1].dump_monitor()

            #wpas as client
            [i_res2, r_res2] = go_neg_pbc(i_dev=wpas,
                                          i_intent=1,
                                          r_dev=dev[1],
                                          r_intent=10)
            check_grpform_results(i_res2, r_res2)
            if i_res2['role'] != "client":
                raise Exception("GO not selected according to go_intent")
            if i_res2['freq'] == "2412":
                raise Exception("Group formed on a disallowed channel")
            hwsim_utils.test_connectivity(wpas, hapd)
            dev[1].remove_group(r_res2['ifname'])
            wpas.wait_go_ending_session()
            ev = dev[1].wait_global_event(["P2P-GROUP-REMOVED"], timeout=5)
            if ev is None:
                raise Exception("Group removal not indicated")
            wpas.request("DISCONNECT")
            hapd.disable()
        finally:
            wpas.request("P2P_SET disallow_freq ")
示例#4
0
def test_pasn_sae_while_connected_diff_channel(dev, apdev):
    """PASN SAE authentication while connected diff channel"""
    check_pasn_capab(dev[0])
    check_sae_capab(dev[0])

    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)

        if wpas.get_mcc() < 2:
            raise HwsimSkip("PASN: New radio does not support MCC")

        params = hostapd.wpa2_params(ssid="test-pasn-wpa2-psk",
                                     passphrase="12345678")
        params['channel'] = "6"
        hapd = hostapd.add_ap(apdev[0], params)

        wpas.connect("test-pasn-wpa2-psk", psk="12345678", scan_freq="2437")

        params = hostapd.wpa2_params(ssid="test-pasn-sae",
                                     passphrase="12345678")

        params['wpa_key_mgmt'] = 'SAE PASN'
        hapd = start_pasn_ap(apdev[1], params)

        wpas.connect("test-pasn-sae",
                     psk="12345678",
                     key_mgmt="SAE",
                     scan_freq="2412",
                     only_add_network=True)

        check_pasn_akmp_cipher(wpas, hapd, "SAE", "CCMP", nid="1")
def test_go_pref_chan_bss_on_disallowed_chan(dev, apdev):
    """P2P channel selection: Station interface on different channel than GO configured pref channel, and station channel is disallowed"""
    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)

        if wpas.get_mcc() < 2:
            raise Exception("New radio does not support MCC")

        wpas.request("SET p2p_no_group_iface 0")

        try:
            hapd = hostapd.add_ap(apdev[0]['ifname'], {
                "ssid": 'bss-2.4ghz',
                "channel": '1'
            })
            wpas.request("P2P_SET disallow_freq 2412")
            wpas.request("SET p2p_pref_chan 81:2")
            wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
            res2 = autogo(wpas)
            if res2['freq'] != "2417":
                raise Exception(
                    "GO channel did not follow pref_chan configuration")
            hwsim_utils.test_connectivity(wpas, hapd)
        finally:
            wpas.request("P2P_SET disallow_freq ")
            wpas.request("SET p2p_pref_chan ")
示例#6
0
def test_p2p_go_move_scm_peer_does_not_support(dev, apdev):
    """No P2P GO move due to SCM operation (peer does not supports)"""
    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)

        if wpas.get_mcc() < 2:
            raise Exception("New radio does not support MCC")

        ndev = [wpas, dev[1]]
        _test_p2p_go_move_scm_peer_does_not_support(ndev, apdev)
示例#7
0
def test_p2p_go_move_active(dev, apdev):
    """P2P GO stays in freq although SCM is possible"""
    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)

        if wpas.get_mcc() < 2:
            raise Exception("New radio does not support MCC")

        ndev = [wpas, dev[1]]
        _test_p2p_go_move_active(ndev, apdev)
def test_go_neg_with_bss_on_disallowed_chan(dev, apdev):
    """P2P channel selection: GO negotiation with station interface on a disallowed channel"""

    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)

        wpas.global_request("SET p2p_no_group_iface 0")

        if wpas.get_mcc() < 2:
           raise Exception("New radio does not support MCC")

        try:
            hapd = hostapd.add_ap(apdev[0],
                                  { "ssid": 'bss-2.4ghz', "channel": '1' })
            # make sure PBC overlap from old test cases is not maintained
            dev[1].flush_scan_cache()
            wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
            wpas.global_request("P2P_SET disallow_freq 2412")

            #wpas as GO
            [i_res, r_res] = go_neg_pbc(i_dev=wpas, i_intent=10, r_dev=dev[1],
                                        r_intent=1)
            check_grpform_results(i_res, r_res)
            if i_res['role'] != "GO":
               raise Exception("GO not selected according to go_intent")
            if i_res['freq'] == "2412":
               raise Exception("Group formed on a disallowed channel")
            hwsim_utils.test_connectivity(wpas, hapd)
            wpas.remove_group(i_res['ifname'])
            dev[1].wait_go_ending_session()
            dev[1].flush_scan_cache()

            wpas.dump_monitor()
            dev[1].dump_monitor()

            #wpas as client
            [i_res2, r_res2] = go_neg_pbc(i_dev=wpas, i_intent=1, r_dev=dev[1],
                                          r_intent=10)
            check_grpform_results(i_res2, r_res2)
            if i_res2['role'] != "client":
               raise Exception("GO not selected according to go_intent")
            if i_res2['freq'] == "2412":
               raise Exception("Group formed on a disallowed channel")
            hwsim_utils.test_connectivity(wpas, hapd)
            dev[1].remove_group(r_res2['ifname'])
            wpas.wait_go_ending_session()
            ev = dev[1].wait_global_event(["P2P-GROUP-REMOVED"], timeout=5)
            if ev is None:
                raise Exception("Group removal not indicated")
            wpas.request("DISCONNECT")
            hapd.disable()
        finally:
            wpas.global_request("P2P_SET disallow_freq ")
示例#9
0
def test_p2p_go_move_scm_peer_does_not_support(dev, apdev):
    """No P2P GO move due to SCM operation (peer does not supports)"""
    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface="/tmp/wpas-wlan5")
        wpas.interface_add(iface)

        if wpas.get_mcc() < 2:
            raise Exception("New radio does not support MCC")

        ndev = [wpas, dev[1]]
        _test_p2p_go_move_scm_peer_does_not_support(ndev, apdev)
示例#10
0
def test_p2p_go_move_scm_multi(dev, apdev):
    """P2P GO move due to SCM operation preference multiple times"""
    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface="/tmp/wpas-wlan5")
        wpas.interface_add(iface)

        if wpas.get_mcc() < 2:
            raise Exception("New radio does not support MCC")

        ndev = [wpas, dev[1]]
        _test_p2p_go_move_scm_multi(ndev, apdev)
示例#11
0
def test_p2p_go_move_scm_multi(dev, apdev):
    """P2P GO move due to SCM operation preference multiple times"""
    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)

        if wpas.get_mcc() < 2:
            raise Exception("New radio does not support MCC")

        ndev = [wpas, dev[1]]
        _test_p2p_go_move_scm_multi(ndev, apdev)
示例#12
0
def test_p2p_go_move_active(dev, apdev):
    """P2P GO stays in freq although SCM is possible"""
    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface="/tmp/wpas-wlan5")
        wpas.interface_add(iface)

        if wpas.get_mcc() < 2:
            raise Exception("New radio does not support MCC")

        ndev = [wpas, dev[1]]
        _test_p2p_go_move_active(ndev, apdev)
def test_go_neg_forced_freq_diff_than_bss_freq(dev, apdev):
    """P2P channel selection: GO negotiation with forced freq different than station interface"""
    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)

        if wpas.get_mcc() < 2:
           raise Exception("New radio does not support MCC")

        # Clear possible PBC session overlap from previous test case
        dev[1].flush_scan_cache()

        wpas.global_request("SET p2p_no_group_iface 0")

        hapd = hostapd.add_ap(apdev[0],
                              { "country_code": 'US',
                                "ssid": 'bss-5ghz', "hw_mode": 'a',
                                "channel": '40' })
        wpas.connect("bss-5ghz", key_mgmt="NONE", scan_freq="5200")

        # GO and peer force the same freq, different than BSS freq,
        # wpas to become GO
        [i_res, r_res] = go_neg_pbc(i_dev=dev[1], i_intent=1, i_freq=5180,
                                    r_dev=wpas, r_intent=14, r_freq=5180)
        check_grpform_results(i_res, r_res)
        if i_res['freq'] != "5180":
           raise Exception("P2P group formed on unexpected frequency: " + i_res['freq'])
        if r_res['role'] != "GO":
           raise Exception("GO not selected according to go_intent")
        hwsim_utils.test_connectivity(wpas, hapd)
        wpas.remove_group(r_res['ifname'])
        dev[1].wait_go_ending_session()
        dev[1].flush_scan_cache()

        # GO and peer force the same freq, different than BSS freq, wpas to
        # become client
        [i_res2, r_res2] = go_neg_pbc(i_dev=dev[1], i_intent=14, i_freq=2422,
                                      r_dev=wpas, r_intent=1, r_freq=2422)
        check_grpform_results(i_res2, r_res2)
        if i_res2['freq'] != "2422":
           raise Exception("P2P group formed on unexpected frequency: " + i_res2['freq'])
        if r_res2['role'] != "client":
           raise Exception("GO not selected according to go_intent")
        hwsim_utils.test_connectivity(wpas, hapd)

        wpas.request("DISCONNECT")
        hapd.request("DISABLE")
        subprocess.call(['iw', 'reg', 'set', '00'])
        wpas.flush_scan_cache()
示例#14
0
def test_go_neg_forced_freq_diff_than_bss_freq(dev, apdev):
    """P2P channel selection: GO negotiation with forced freq different than station interface"""
    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)

        if wpas.get_mcc() < 2:
           raise Exception("New radio does not support MCC")

        # Clear possible PBC session overlap from previous test case
        dev[1].flush_scan_cache()

        wpas.request("SET p2p_no_group_iface 0")

        hapd = hostapd.add_ap(apdev[0]['ifname'],
                              { "country_code": 'US',
                                "ssid": 'bss-5ghz', "hw_mode": 'a',
                                "channel": '40' })
        wpas.connect("bss-5ghz", key_mgmt="NONE", scan_freq="5200")

        # GO and peer force the same freq, different than BSS freq,
        # wpas to become GO
        [i_res, r_res] = go_neg_pbc(i_dev=dev[1], i_intent=1, i_freq=5180,
                                    r_dev=wpas, r_intent=14, r_freq=5180)
        check_grpform_results(i_res, r_res)
        if i_res['freq'] != "5180":
           raise Exception("P2P group formed on unexpected frequency: " + i_res['freq'])
        if r_res['role'] != "GO":
           raise Exception("GO not selected according to go_intent")
        hwsim_utils.test_connectivity(wpas, hapd)
        wpas.remove_group(r_res['ifname'])
        dev[1].wait_go_ending_session()
        dev[1].flush_scan_cache()

        # GO and peer force the same freq, different than BSS freq, wpas to
        # become client
        [i_res2, r_res2] = go_neg_pbc(i_dev=dev[1], i_intent=14, i_freq=2422,
                                      r_dev=wpas, r_intent=1, r_freq=2422)
        check_grpform_results(i_res2, r_res2)
        if i_res2['freq'] != "2422":
           raise Exception("P2P group formed on unexpected frequency: " + i_res2['freq'])
        if r_res2['role'] != "client":
           raise Exception("GO not selected according to go_intent")
        hwsim_utils.test_connectivity(wpas, hapd)

        wpas.request("DISCONNECT")
        hapd.request("DISABLE")
        subprocess.call(['iw', 'reg', 'set', '00'])
        wpas.flush_scan_cache()
示例#15
0
def check_pasn_fils_connected_diff_channel(dev, apdev, params, key_mgmt):
    check_pasn_capab(dev[0])

    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)
        if wpas.get_mcc() < 2:
           raise Exception("New radio does not support MCC")

        hapd = pasn_fils_setup(wpas, apdev, params, key_mgmt);

        # Connect to another AP on a different channel
        hapd1 = hostapd.add_ap(apdev[1], {"ssid": "open", "channel" : "6"})
        wpas.connect("open", key_mgmt="NONE", scan_freq="2437",
                bg_scan_period="0")

        hwsim_utils.test_connectivity(wpas, hapd1)

        # And perform the PASN authentication with FILS
        check_pasn_akmp_cipher(wpas, hapd, key_mgmt, "CCMP", nid="0")
def test_autogo_force_diff_channel(dev, apdev):
    """P2P autonomous GO and station interface operate on different channels"""
    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)

        if wpas.get_mcc() < 2:
           raise Exception("New radio does not support MCC")

        wpas.request("SET p2p_no_group_iface 0")

        hapd = hostapd.add_ap(apdev[0]['ifname'],
                              {"ssid" : 'ap-test', "channel" : '1'})
        wpas.connect("ap-test", key_mgmt = "NONE", scan_freq = "2412")
        channels = { 2 : 2417, 5 : 2432, 9 : 2452 }
        for key in channels:
            res_go = autogo(wpas, channels[key])
            hwsim_utils.test_connectivity(wpas, hapd)
            if int(res_go['freq']) == 2412:
                raise Exception("Group operation channel is: 2412 excepted: " + res_go['freq'])
            wpas.remove_group(res_go['ifname'])
示例#17
0
def test_pasn_while_connected_diff_channel(dev, apdev):
    """PASN authentication with WPA2/CCMP AP while connected diff channel"""
    check_pasn_capab(dev[0])

    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)

        if wpas.get_mcc() < 2:
            raise HwsimSkip("PASN: New radio does not support MCC")

        params = hostapd.wpa2_params(ssid="test-wpa2-psk",
                                     passphrase="12345678")
        params['channel'] = "6"
        hapd = start_pasn_ap(apdev[0], params)
        wpas.connect("test-wpa2-psk", psk="12345678", scan_freq="2437")

        params = pasn_ap_params("PASN", "CCMP")
        hapd2 = start_pasn_ap(apdev[1], params)

        check_pasn_akmp_cipher(wpas, hapd2, "PASN", "CCMP")
示例#18
0
def test_autogo_with_bss_on_disallowed_chan(dev, apdev):
    """P2P channel selection: Autonomous GO with BSS on a disallowed channel"""

    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface="/tmp/wpas-wlan5")
        wpas.interface_add(iface)

        wpas.request("SET p2p_no_group_iface 0")

        if wpas.get_mcc() < 2:
            raise Exception("New radio does not support MCC")

        try:
            hapd = hostapd.add_ap(apdev[0]["ifname"], {"ssid": "bss-2.4ghz", "channel": "1"})
            wpas.request("P2P_SET disallow_freq 2412")
            wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
            res = autogo(wpas)
            if res["freq"] == "2412":
                raise Exception("GO set on a disallowed channel")
            hwsim_utils.test_connectivity(wpas, hapd)
        finally:
            wpas.request("P2P_SET disallow_freq ")
示例#19
0
def test_go_pref_chan_bss_on_disallowed_chan(dev, apdev):
    """P2P channel selection: Station interface on different channel than GO configured pref channel, and station channel is disallowed"""
    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface="/tmp/wpas-wlan5")
        wpas.interface_add(iface)

        if wpas.get_mcc() < 2:
            raise Exception("New radio does not support MCC")

        wpas.request("SET p2p_no_group_iface 0")

        try:
            hapd = hostapd.add_ap(apdev[0]["ifname"], {"ssid": "bss-2.4ghz", "channel": "1"})
            wpas.request("P2P_SET disallow_freq 2412")
            wpas.request("SET p2p_pref_chan 81:2")
            wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
            res2 = autogo(wpas)
            if res2["freq"] != "2417":
                raise Exception("GO channel did not follow pref_chan configuration")
            hwsim_utils.test_connectivity(wpas, hapd)
        finally:
            wpas.request("P2P_SET disallow_freq ")
            wpas.request("SET p2p_pref_chan ")
示例#20
0
def test_p2p_delay_go_csa(dev, apdev, params):
    """P2P GO CSA delayed when inviting a P2P Device to an active P2P Group"""
    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
        wpas.interface_add(iface)

        wpas.global_request("SET p2p_no_group_iface 0")

        if wpas.get_mcc() < 2:
            raise Exception("New radio does not support MCC")

        addr0 = wpas.p2p_dev_addr()
        addr1 = dev[1].p2p_dev_addr()

        try:
            dev[1].p2p_listen()
            if not wpas.discover_peer(addr1, social=True):
                raise Exception("Peer " + addr1 + " not found")
            wpas.p2p_stop_find()

            hapd = hostapd.add_ap(apdev[0]['ifname'], {
                "ssid": 'bss-2.4ghz',
                "channel": '1'
            })

            wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")

            wpas.global_request("SET p2p_go_freq_change_policy 0")
            wpas.dump_monitor()

            logger.info("Start GO on channel 6")
            res = autogo(wpas, freq=2437)
            if res['freq'] != "2437":
                raise Exception("GO set on a freq=%s instead of 2437" %
                                res['freq'])

            # Start find on dev[1] to run scans with dev[2] in parallel
            dev[1].p2p_find(social=True)

            # Use another client device to stop the initial client connection
            # timeout on the GO
            if not dev[2].discover_peer(addr0, social=True):
                raise Exception("Peer2 did not find the GO")
            dev[2].p2p_stop_find()
            pin = dev[2].wps_read_pin()
            wpas.p2p_go_authorize_client(pin)
            dev[2].global_request("P2P_CONNECT " + addr0 + " " + pin +
                                  " join freq=2437")
            ev = dev[2].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
            if ev is None:
                raise Exception("Peer2 did not get connected")

            if not dev[1].discover_peer(addr0, social=True):
                raise Exception("Peer did not find the GO")

            pin = dev[1].wps_read_pin()
            dev[1].global_request("P2P_CONNECT " + addr0 + " " + pin +
                                  " join auth")
            dev[1].p2p_listen()

            # Force P2P GO channel switch on successful invitation signaling
            wpas.group_request("SET p2p_go_csa_on_inv 1")

            logger.info("Starting invitation")
            wpas.p2p_go_authorize_client(pin)
            wpas.global_request("P2P_INVITE group=" + wpas.group_ifname +
                                " peer=" + addr1)
            ev = dev[1].wait_global_event(
                ["P2P-INVITATION-RECEIVED", "P2P-GROUP-STARTED"], timeout=10)

            if ev is None:
                raise Exception("Timeout on invitation on peer")
            if "P2P-INVITATION-RECEIVED" in ev:
                raise Exception(
                    "Unexpected request to accept pre-authorized invitation")

            # A P2P GO move is not expected at this stage, as during the
            # invitation signaling, the P2P GO includes only its current
            # operating channel in the channel list, and as the invitation
            # response can only include channels that were also in the
            # invitation request channel list, the group common channels
            # includes only the current P2P GO operating channel.
            ev = wpas.wait_group_event(
                ["P2P-REMOVE-AND-REFORM-GROUP", "AP-CSA-FINISHED"], timeout=1)
            if ev is not None:
                raise Exception("Unexpected + " + ev + " event")

        finally:
            wpas.global_request("SET p2p_go_freq_change_policy 2")
示例#21
0
def test_p2p_delay_go_csa(dev, apdev, params):
    """P2P GO CSA delayed when inviting a P2P Device to an active P2P Group"""
    with HWSimRadio(n_channels=2) as (radio, iface):
        wpas = WpaSupplicant(global_iface="/tmp/wpas-wlan5")
        wpas.interface_add(iface)

        wpas.global_request("SET p2p_no_group_iface 0")

        if wpas.get_mcc() < 2:
            raise Exception("New radio does not support MCC")

        addr0 = wpas.p2p_dev_addr()
        addr1 = dev[1].p2p_dev_addr()

        try:
            dev[1].p2p_listen()
            if not wpas.discover_peer(addr1, social=True):
                raise Exception("Peer " + addr1 + " not found")
            wpas.p2p_stop_find()

            hapd = hostapd.add_ap(apdev[0]["ifname"], {"ssid": "bss-2.4ghz", "channel": "1"})

            wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")

            wpas.global_request("SET p2p_go_freq_change_policy 0")
            wpas.dump_monitor()

            logger.info("Start GO on channel 6")
            res = autogo(wpas, freq=2437)
            if res["freq"] != "2437":
                raise Exception("GO set on a freq=%s instead of 2437" % res["freq"])

            # Start find on dev[1] to run scans with dev[2] in parallel
            dev[1].p2p_find(social=True)

            # Use another client device to stop the initial client connection
            # timeout on the GO
            if not dev[2].discover_peer(addr0, social=True):
                raise Exception("Peer2 did not find the GO")
            dev[2].p2p_stop_find()
            pin = dev[2].wps_read_pin()
            wpas.p2p_go_authorize_client(pin)
            dev[2].global_request("P2P_CONNECT " + addr0 + " " + pin + " join freq=2437")
            ev = dev[2].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
            if ev is None:
                raise Exception("Peer2 did not get connected")

            if not dev[1].discover_peer(addr0, social=True):
                raise Exception("Peer did not find the GO")

            pin = dev[1].wps_read_pin()
            dev[1].global_request("P2P_CONNECT " + addr0 + " " + pin + " join auth")
            dev[1].p2p_listen()

            # Force P2P GO channel switch on successful invitation signaling
            wpas.group_request("SET p2p_go_csa_on_inv 1")

            logger.info("Starting invitation")
            wpas.p2p_go_authorize_client(pin)
            wpas.global_request("P2P_INVITE group=" + wpas.group_ifname + " peer=" + addr1)
            ev = dev[1].wait_global_event(["P2P-INVITATION-RECEIVED", "P2P-GROUP-STARTED"], timeout=10)

            if ev is None:
                raise Exception("Timeout on invitation on peer")
            if "P2P-INVITATION-RECEIVED" in ev:
                raise Exception("Unexpected request to accept pre-authorized invitation")

            # A P2P GO move is not expected at this stage, as during the
            # invitation signaling, the P2P GO includes only its current
            # operating channel in the channel list, and as the invitation
            # response can only include channels that were also in the
            # invitation request channel list, the group common channels
            # includes only the current P2P GO operating channel.
            ev = wpas.wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP", "AP-CSA-FINISHED"], timeout=1)
            if ev is not None:
                raise Exception("Unexpected + " + ev + " event")

        finally:
            wpas.global_request("SET p2p_go_freq_change_policy 2")