2013-03-09 15:30:25 +01:00
|
|
|
# P2P autonomous GO test cases
|
2015-03-14 09:58:17 +01:00
|
|
|
# Copyright (c) 2013-2015, Jouni Malinen <j@w1.fi>
|
2013-03-09 15:30:25 +01:00
|
|
|
#
|
|
|
|
# This software may be distributed under the terms of the BSD license.
|
|
|
|
# See README for more details.
|
|
|
|
|
2016-06-23 19:16:36 +02:00
|
|
|
from remotehost import remote_compatible
|
2013-03-09 17:24:32 +01:00
|
|
|
import time
|
2013-03-09 18:01:56 +01:00
|
|
|
import subprocess
|
2013-03-09 15:30:25 +01:00
|
|
|
import logging
|
2013-10-31 11:46:42 +01:00
|
|
|
logger = logging.getLogger()
|
2013-03-09 15:30:25 +01:00
|
|
|
|
|
|
|
import hwsim_utils
|
2013-11-24 14:32:52 +01:00
|
|
|
import utils
|
2015-01-07 13:19:30 +01:00
|
|
|
from utils import HwsimSkip
|
2013-04-01 09:37:44 +02:00
|
|
|
from wlantest import Wlantest
|
2014-04-06 11:49:52 +02:00
|
|
|
from wpasupplicant import WpaSupplicant
|
2015-10-25 10:12:21 +01:00
|
|
|
from p2p_utils import *
|
|
|
|
from test_p2p_messages import mgmt_tx, parse_p2p_public_action
|
2013-03-09 15:30:25 +01:00
|
|
|
|
|
|
|
def test_autogo(dev):
|
2013-03-17 10:19:24 +01:00
|
|
|
"""P2P autonomous GO and client joining group"""
|
2014-12-08 17:42:16 +01:00
|
|
|
addr0 = dev[0].p2p_dev_addr()
|
|
|
|
addr2 = dev[2].p2p_dev_addr()
|
2013-11-24 14:32:52 +01:00
|
|
|
res = autogo(dev[0])
|
|
|
|
if "p2p-wlan" in res['ifname']:
|
|
|
|
raise Exception("Unexpected group interface name on GO")
|
|
|
|
res = connect_cli(dev[0], dev[1])
|
|
|
|
if "p2p-wlan" in res['ifname']:
|
|
|
|
raise Exception("Unexpected group interface name on client")
|
2015-02-04 10:30:25 +01:00
|
|
|
bss = dev[1].get_bss("p2p_dev_addr=" + addr0, res['ifname'])
|
|
|
|
if not bss or bss['bssid'] != dev[0].p2p_interface_addr():
|
2013-12-25 20:03:47 +01:00
|
|
|
raise Exception("Unexpected BSSID in the BSS entry for the GO")
|
|
|
|
id = bss['id']
|
2015-02-04 10:30:25 +01:00
|
|
|
bss = dev[1].get_bss("ID-" + id, res['ifname'])
|
|
|
|
if not bss or bss['id'] != id:
|
2013-12-25 20:03:47 +01:00
|
|
|
raise Exception("Could not find BSS entry based on id")
|
2015-02-04 10:30:25 +01:00
|
|
|
res = dev[1].group_request("BSS RANGE=" + id + "- MASK=0x1")
|
2013-12-25 20:03:47 +01:00
|
|
|
if "id=" + id not in res:
|
|
|
|
raise Exception("Could not find BSS entry based on id range")
|
2014-01-01 17:46:28 +01:00
|
|
|
|
2014-12-07 22:27:45 +01:00
|
|
|
res = dev[1].request("SCAN_RESULTS")
|
|
|
|
if "[P2P]" not in res:
|
|
|
|
raise Exception("P2P flag missing from scan results: " + res)
|
|
|
|
|
2014-01-01 17:46:28 +01:00
|
|
|
# Presence request to increase testing coverage
|
2014-12-10 22:35:29 +01:00
|
|
|
if "FAIL" not in dev[1].group_request("P2P_PRESENCE_REQ 30000"):
|
|
|
|
raise Exception("Invald P2P_PRESENCE_REQ accepted")
|
|
|
|
if "FAIL" not in dev[1].group_request("P2P_PRESENCE_REQ 30000 102400 30001"):
|
|
|
|
raise Exception("Invald P2P_PRESENCE_REQ accepted")
|
2014-01-01 17:46:28 +01:00
|
|
|
if "FAIL" in dev[1].group_request("P2P_PRESENCE_REQ 30000 102400"):
|
|
|
|
raise Exception("Could not send presence request")
|
2015-02-06 02:30:57 +01:00
|
|
|
ev = dev[1].wait_group_event(["P2P-PRESENCE-RESPONSE"], 10)
|
2014-12-10 22:35:29 +01:00
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout while waiting for Presence Response")
|
|
|
|
if "FAIL" in dev[1].group_request("P2P_PRESENCE_REQ 30000 102400 20000 102400"):
|
|
|
|
raise Exception("Could not send presence request")
|
2015-06-17 15:24:50 +02:00
|
|
|
ev = dev[1].wait_group_event(["P2P-PRESENCE-RESPONSE"])
|
2014-12-10 22:35:29 +01:00
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout while waiting for Presence Response")
|
|
|
|
if "FAIL" in dev[1].group_request("P2P_PRESENCE_REQ"):
|
|
|
|
raise Exception("Could not send presence request")
|
2015-06-17 15:24:50 +02:00
|
|
|
ev = dev[1].wait_group_event(["P2P-PRESENCE-RESPONSE"])
|
2014-01-01 17:46:28 +01:00
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout while waiting for Presence Response")
|
|
|
|
|
2014-12-08 17:42:16 +01:00
|
|
|
if not dev[2].discover_peer(addr0):
|
|
|
|
raise Exception("Could not discover GO")
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[2].global_request("P2P_PROV_DISC " + addr0 + " display join")
|
|
|
|
ev = dev[0].wait_global_event(["P2P-PROV-DISC-SHOW-PIN"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("GO did not report P2P-PROV-DISC-SHOW-PIN")
|
|
|
|
if "p2p_dev_addr=" + addr2 not in ev:
|
|
|
|
raise Exception("Unexpected P2P Device Address in event: " + ev)
|
|
|
|
if "group=" + dev[0].group_ifname not in ev:
|
|
|
|
raise Exception("Unexpected group interface in event: " + ev)
|
|
|
|
ev = dev[2].wait_global_event(["P2P-PROV-DISC-ENTER-PIN"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("P2P-PROV-DISC-ENTER-PIN not reported")
|
|
|
|
|
2013-11-24 14:32:52 +01:00
|
|
|
dev[0].remove_group()
|
|
|
|
dev[1].wait_go_ending_session()
|
|
|
|
|
|
|
|
def test_autogo2(dev):
|
|
|
|
"""P2P autonomous GO with a separate group interface and client joining group"""
|
2016-04-07 12:32:03 +02:00
|
|
|
dev[0].global_request("SET p2p_no_group_iface 0")
|
2014-11-28 15:54:31 +01:00
|
|
|
res = autogo(dev[0], freq=2437)
|
2013-11-24 14:32:52 +01:00
|
|
|
if "p2p-wlan" not in res['ifname']:
|
|
|
|
raise Exception("Unexpected group interface name on GO")
|
|
|
|
if res['ifname'] not in utils.get_ifnames():
|
|
|
|
raise Exception("Could not find group interface netdev")
|
2014-11-28 15:54:31 +01:00
|
|
|
connect_cli(dev[0], dev[1], social=True, freq=2437)
|
2013-03-09 15:30:25 +01:00
|
|
|
dev[0].remove_group()
|
2013-09-01 18:30:08 +02:00
|
|
|
dev[1].wait_go_ending_session()
|
2013-11-24 14:32:52 +01:00
|
|
|
if res['ifname'] in utils.get_ifnames():
|
|
|
|
raise Exception("Group interface netdev was not removed")
|
|
|
|
|
|
|
|
def test_autogo3(dev):
|
|
|
|
"""P2P autonomous GO and client with a separate group interface joining group"""
|
2016-04-07 12:32:03 +02:00
|
|
|
dev[1].global_request("SET p2p_no_group_iface 0")
|
2014-11-28 15:54:31 +01:00
|
|
|
autogo(dev[0], freq=2462)
|
|
|
|
res = connect_cli(dev[0], dev[1], social=True, freq=2462)
|
2013-11-24 14:32:52 +01:00
|
|
|
if "p2p-wlan" not in res['ifname']:
|
|
|
|
raise Exception("Unexpected group interface name on client")
|
|
|
|
if res['ifname'] not in utils.get_ifnames():
|
|
|
|
raise Exception("Could not find group interface netdev")
|
|
|
|
dev[0].remove_group()
|
|
|
|
dev[1].wait_go_ending_session()
|
|
|
|
dev[1].ping()
|
|
|
|
if res['ifname'] in utils.get_ifnames():
|
|
|
|
raise Exception("Group interface netdev was not removed")
|
|
|
|
|
|
|
|
def test_autogo4(dev):
|
|
|
|
"""P2P autonomous GO and client joining group (both with a separate group interface)"""
|
2016-04-07 12:32:03 +02:00
|
|
|
dev[0].global_request("SET p2p_no_group_iface 0")
|
|
|
|
dev[1].global_request("SET p2p_no_group_iface 0")
|
2014-11-28 15:54:31 +01:00
|
|
|
res1 = autogo(dev[0], freq=2412)
|
|
|
|
res2 = connect_cli(dev[0], dev[1], social=True, freq=2412)
|
2013-11-24 14:32:52 +01:00
|
|
|
if "p2p-wlan" not in res1['ifname']:
|
|
|
|
raise Exception("Unexpected group interface name on GO")
|
|
|
|
if "p2p-wlan" not in res2['ifname']:
|
|
|
|
raise Exception("Unexpected group interface name on client")
|
|
|
|
ifnames = utils.get_ifnames()
|
|
|
|
if res1['ifname'] not in ifnames:
|
|
|
|
raise Exception("Could not find GO group interface netdev")
|
|
|
|
if res2['ifname'] not in ifnames:
|
|
|
|
raise Exception("Could not find client group interface netdev")
|
|
|
|
dev[0].remove_group()
|
|
|
|
dev[1].wait_go_ending_session()
|
|
|
|
dev[1].ping()
|
|
|
|
ifnames = utils.get_ifnames()
|
|
|
|
if res1['ifname'] in ifnames:
|
|
|
|
raise Exception("GO group interface netdev was not removed")
|
|
|
|
if res2['ifname'] in ifnames:
|
|
|
|
raise Exception("Client group interface netdev was not removed")
|
2013-03-09 15:30:25 +01:00
|
|
|
|
2014-04-06 11:49:52 +02:00
|
|
|
def test_autogo_m2d(dev):
|
|
|
|
"""P2P autonomous GO and clients not authorized"""
|
2014-11-28 15:54:31 +01:00
|
|
|
autogo(dev[0], freq=2412)
|
2014-04-06 11:49:52 +02:00
|
|
|
go_addr = dev[0].p2p_dev_addr()
|
|
|
|
|
|
|
|
dev[1].request("SET p2p_no_group_iface 0")
|
|
|
|
if not dev[1].discover_peer(go_addr, social=True):
|
|
|
|
raise Exception("GO " + go_addr + " not found")
|
|
|
|
dev[1].dump_monitor()
|
|
|
|
|
|
|
|
if not dev[2].discover_peer(go_addr, social=True):
|
|
|
|
raise Exception("GO " + go_addr + " not found")
|
|
|
|
dev[2].dump_monitor()
|
|
|
|
|
|
|
|
logger.info("Trying to join the group when GO has not authorized the client")
|
|
|
|
pin = dev[1].wps_read_pin()
|
|
|
|
cmd = "P2P_CONNECT " + go_addr + " " + pin + " join"
|
|
|
|
if "OK" not in dev[1].global_request(cmd):
|
|
|
|
raise Exception("P2P_CONNECT join failed")
|
|
|
|
|
|
|
|
pin = dev[2].wps_read_pin()
|
|
|
|
cmd = "P2P_CONNECT " + go_addr + " " + pin + " join"
|
|
|
|
if "OK" not in dev[2].global_request(cmd):
|
|
|
|
raise Exception("P2P_CONNECT join failed")
|
|
|
|
|
2015-04-24 16:54:13 +02:00
|
|
|
ev = dev[1].wait_global_event(["WPS-M2D"], timeout=16)
|
2014-04-06 11:49:52 +02:00
|
|
|
if ev is None:
|
|
|
|
raise Exception("No global M2D event")
|
|
|
|
ifaces = dev[1].request("INTERFACES").splitlines()
|
|
|
|
iface = ifaces[0] if "p2p-wlan" in ifaces[0] else ifaces[1]
|
|
|
|
wpas = WpaSupplicant(ifname=iface)
|
|
|
|
ev = wpas.wait_event(["WPS-M2D"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("No M2D event on group interface")
|
|
|
|
|
|
|
|
ev = dev[2].wait_global_event(["WPS-M2D"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("No global M2D event (2)")
|
|
|
|
ev = dev[2].wait_event(["WPS-M2D"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("No M2D event on group interface (2)")
|
|
|
|
|
2016-06-23 19:16:36 +02:00
|
|
|
@remote_compatible
|
2014-04-06 11:49:52 +02:00
|
|
|
def test_autogo_fail(dev):
|
|
|
|
"""P2P autonomous GO and incorrect PIN"""
|
2014-11-28 15:54:31 +01:00
|
|
|
autogo(dev[0], freq=2412)
|
2014-04-06 11:49:52 +02:00
|
|
|
go_addr = dev[0].p2p_dev_addr()
|
|
|
|
dev[0].p2p_go_authorize_client("00000000")
|
|
|
|
|
2016-04-07 12:32:03 +02:00
|
|
|
dev[1].global_request("SET p2p_no_group_iface 0")
|
2014-04-06 11:49:52 +02:00
|
|
|
if not dev[1].discover_peer(go_addr, social=True):
|
|
|
|
raise Exception("GO " + go_addr + " not found")
|
|
|
|
dev[1].dump_monitor()
|
|
|
|
|
|
|
|
logger.info("Trying to join the group when GO has not authorized the client")
|
|
|
|
pin = dev[1].wps_read_pin()
|
|
|
|
cmd = "P2P_CONNECT " + go_addr + " " + pin + " join"
|
|
|
|
if "OK" not in dev[1].global_request(cmd):
|
|
|
|
raise Exception("P2P_CONNECT join failed")
|
|
|
|
|
|
|
|
ev = dev[1].wait_global_event(["WPS-FAIL"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("No global WPS-FAIL event")
|
|
|
|
|
2013-03-09 16:51:22 +01:00
|
|
|
def test_autogo_2cli(dev):
|
2013-03-17 10:19:24 +01:00
|
|
|
"""P2P autonomous GO and two clients joining group"""
|
2014-11-28 15:54:31 +01:00
|
|
|
autogo(dev[0], freq=2412)
|
|
|
|
connect_cli(dev[0], dev[1], social=True, freq=2412)
|
|
|
|
connect_cli(dev[0], dev[2], social=True, freq=2412)
|
2013-03-09 16:51:22 +01:00
|
|
|
hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
|
2013-09-01 16:58:17 +02:00
|
|
|
dev[0].global_request("P2P_REMOVE_CLIENT " + dev[1].p2p_dev_addr())
|
2013-09-01 18:30:08 +02:00
|
|
|
dev[1].wait_go_ending_session()
|
2014-12-10 23:03:01 +01:00
|
|
|
dev[0].global_request("P2P_REMOVE_CLIENT iface=" + dev[2].p2p_interface_addr())
|
2013-09-01 18:30:08 +02:00
|
|
|
dev[2].wait_go_ending_session()
|
2014-12-10 23:03:01 +01:00
|
|
|
if "FAIL" not in dev[0].global_request("P2P_REMOVE_CLIENT foo"):
|
|
|
|
raise Exception("Invalid P2P_REMOVE_CLIENT command accepted")
|
|
|
|
dev[0].remove_group()
|
2013-03-09 16:51:22 +01:00
|
|
|
|
2014-04-06 15:22:46 +02:00
|
|
|
def test_autogo_pbc(dev):
|
|
|
|
"""P2P autonomous GO and PBC"""
|
2015-06-17 15:24:50 +02:00
|
|
|
dev[1].global_request("SET p2p_no_group_iface 0")
|
2014-11-28 15:54:31 +01:00
|
|
|
autogo(dev[0], freq=2412)
|
2014-04-06 15:22:46 +02:00
|
|
|
if "FAIL" not in dev[0].group_request("WPS_PBC p2p_dev_addr=00:11:22:33:44"):
|
|
|
|
raise Exception("Invalid WPS_PBC succeeded")
|
|
|
|
if "OK" not in dev[0].group_request("WPS_PBC p2p_dev_addr=" + dev[1].p2p_dev_addr()):
|
|
|
|
raise Exception("WPS_PBC failed")
|
|
|
|
dev[2].p2p_connect_group(dev[0].p2p_dev_addr(), "pbc", timeout=0,
|
|
|
|
social=True)
|
2015-06-17 15:24:53 +02:00
|
|
|
ev = dev[2].wait_global_event(["WPS-M2D"], timeout=15)
|
2014-04-06 15:22:46 +02:00
|
|
|
if ev is None:
|
|
|
|
raise Exception("WPS-M2D not reported")
|
|
|
|
if "config_error=12" not in ev:
|
|
|
|
raise Exception("Unexpected config_error: " + ev)
|
|
|
|
dev[1].p2p_connect_group(dev[0].p2p_dev_addr(), "pbc", timeout=15,
|
|
|
|
social=True)
|
|
|
|
|
2013-03-09 17:24:32 +01:00
|
|
|
def test_autogo_tdls(dev):
|
2013-03-17 10:19:24 +01:00
|
|
|
"""P2P autonomous GO and two clients using TDLS"""
|
2013-03-09 18:01:56 +01:00
|
|
|
go = dev[0]
|
|
|
|
logger.info("Start autonomous GO with fixed parameters " + go.ifname)
|
|
|
|
id = go.add_network()
|
|
|
|
go.set_network_quoted(id, "ssid", "DIRECT-tdls")
|
|
|
|
go.set_network_quoted(id, "psk", "12345678")
|
|
|
|
go.set_network(id, "mode", "3")
|
|
|
|
go.set_network(id, "disabled", "2")
|
2014-11-28 15:54:31 +01:00
|
|
|
res = go.p2p_start_go(persistent=id, freq="2462")
|
2013-03-09 18:01:56 +01:00
|
|
|
logger.debug("res: " + str(res))
|
2016-05-19 15:06:49 +02:00
|
|
|
Wlantest.setup(go, True)
|
|
|
|
wt = Wlantest()
|
2013-04-01 09:37:44 +02:00
|
|
|
wt.flush()
|
|
|
|
wt.add_passphrase("12345678")
|
2014-11-28 15:54:31 +01:00
|
|
|
connect_cli(go, dev[1], social=True, freq=2462)
|
|
|
|
connect_cli(go, dev[2], social=True, freq=2462)
|
2013-03-09 17:24:32 +01:00
|
|
|
hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
|
2013-03-09 18:01:56 +01:00
|
|
|
bssid = dev[0].p2p_interface_addr()
|
|
|
|
addr1 = dev[1].p2p_interface_addr()
|
2013-03-09 17:24:32 +01:00
|
|
|
addr2 = dev[2].p2p_interface_addr()
|
|
|
|
dev[1].tdls_setup(addr2)
|
|
|
|
time.sleep(1)
|
|
|
|
hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
|
2016-07-03 18:37:50 +02:00
|
|
|
conf = wt.get_tdls_counter("setup_conf_ok", bssid, addr1, addr2)
|
2013-03-09 18:01:56 +01:00
|
|
|
if conf == 0:
|
|
|
|
raise Exception("No TDLS Setup Confirm (success) seen")
|
2016-07-03 18:37:50 +02:00
|
|
|
dl = wt.get_tdls_counter("valid_direct_link", bssid, addr1, addr2)
|
2013-03-09 18:01:56 +01:00
|
|
|
if dl == 0:
|
|
|
|
raise Exception("No valid frames through direct link")
|
2016-07-03 18:37:50 +02:00
|
|
|
wt.tdls_clear(bssid, addr1, addr2)
|
2013-03-09 17:24:32 +01:00
|
|
|
dev[1].tdls_teardown(addr2)
|
|
|
|
time.sleep(1)
|
2016-07-03 18:37:50 +02:00
|
|
|
teardown = wt.get_tdls_counter("teardown", bssid, addr1, addr2)
|
2013-03-27 12:32:36 +01:00
|
|
|
if teardown == 0:
|
2013-03-09 18:01:56 +01:00
|
|
|
raise Exception("No TDLS Setup Teardown seen")
|
2016-07-03 18:37:50 +02:00
|
|
|
wt.tdls_clear(bssid, addr1, addr2)
|
2013-03-09 17:24:32 +01:00
|
|
|
hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
|
2016-07-03 18:37:50 +02:00
|
|
|
ap_path = wt.get_tdls_counter("valid_ap_path", bssid, addr1, addr2)
|
2013-03-09 18:01:56 +01:00
|
|
|
if ap_path == 0:
|
|
|
|
raise Exception("No valid frames via AP path")
|
2016-07-03 18:37:50 +02:00
|
|
|
direct_link = wt.get_tdls_counter("valid_direct_link", bssid, addr1, addr2)
|
2013-03-09 18:01:56 +01:00
|
|
|
if direct_link > 0:
|
|
|
|
raise Exception("Unexpected frames through direct link")
|
2013-04-01 09:37:44 +02:00
|
|
|
idirect_link = wt.get_tdls_counter("invalid_direct_link", bssid, addr1,
|
2016-07-03 18:37:50 +02:00
|
|
|
addr2)
|
2013-03-09 18:01:56 +01:00
|
|
|
if idirect_link > 0:
|
|
|
|
raise Exception("Unexpected frames through direct link (invalid)")
|
2013-03-09 17:24:32 +01:00
|
|
|
dev[2].remove_group()
|
|
|
|
dev[1].remove_group()
|
|
|
|
dev[0].remove_group()
|
2013-09-29 11:42:05 +02:00
|
|
|
|
|
|
|
def test_autogo_legacy(dev):
|
|
|
|
"""P2P autonomous GO and legacy clients"""
|
2014-11-28 15:54:31 +01:00
|
|
|
res = autogo(dev[0], freq=2462)
|
2014-04-06 15:52:14 +02:00
|
|
|
if dev[0].get_group_status_field("passphrase", extra="WPS") != res['passphrase']:
|
|
|
|
raise Exception("passphrase mismatch")
|
2015-02-04 10:30:17 +01:00
|
|
|
if dev[0].group_request("P2P_GET_PASSPHRASE") != res['passphrase']:
|
2014-12-08 00:04:19 +01:00
|
|
|
raise Exception("passphrase mismatch(2)")
|
2013-09-29 11:42:05 +02:00
|
|
|
|
|
|
|
logger.info("Connect P2P client")
|
2014-11-28 15:54:31 +01:00
|
|
|
connect_cli(dev[0], dev[1], social=True, freq=2462)
|
2013-09-29 11:42:05 +02:00
|
|
|
|
2014-12-08 20:10:03 +01:00
|
|
|
if "FAIL" not in dev[1].request("P2P_GET_PASSPHRASE"):
|
|
|
|
raise Exception("P2P_GET_PASSPHRASE succeeded on P2P Client")
|
|
|
|
|
2013-09-29 11:42:05 +02:00
|
|
|
logger.info("Connect legacy WPS client")
|
|
|
|
pin = dev[2].wps_read_pin()
|
|
|
|
dev[0].p2p_go_authorize_client(pin)
|
|
|
|
dev[2].request("P2P_SET disabled 1")
|
|
|
|
dev[2].dump_monitor()
|
|
|
|
dev[2].request("WPS_PIN any " + pin)
|
2014-12-20 10:51:30 +01:00
|
|
|
dev[2].wait_connected(timeout=30)
|
2013-09-29 11:42:05 +02:00
|
|
|
status = dev[2].get_status()
|
|
|
|
if status['wpa_state'] != 'COMPLETED':
|
|
|
|
raise Exception("Not fully connected")
|
|
|
|
hwsim_utils.test_connectivity_p2p_sta(dev[1], dev[2])
|
|
|
|
dev[2].request("DISCONNECT")
|
|
|
|
|
|
|
|
logger.info("Connect legacy non-WPS client")
|
|
|
|
dev[2].request("FLUSH")
|
|
|
|
dev[2].request("P2P_SET disabled 1")
|
|
|
|
dev[2].connect(ssid=res['ssid'], psk=res['passphrase'], proto='RSN',
|
|
|
|
key_mgmt='WPA-PSK', pairwise='CCMP', group='CCMP',
|
|
|
|
scan_freq=res['freq'])
|
|
|
|
hwsim_utils.test_connectivity_p2p_sta(dev[1], dev[2])
|
|
|
|
dev[2].request("DISCONNECT")
|
|
|
|
|
|
|
|
dev[0].remove_group()
|
|
|
|
dev[1].wait_go_ending_session()
|
2013-11-17 15:45:34 +01:00
|
|
|
|
|
|
|
def test_autogo_chan_switch(dev):
|
|
|
|
"""P2P autonomous GO switching channels"""
|
2017-01-05 15:11:31 +01:00
|
|
|
run_autogo_chan_switch(dev)
|
|
|
|
|
|
|
|
def run_autogo_chan_switch(dev):
|
2013-11-17 15:45:34 +01:00
|
|
|
autogo(dev[0], freq=2417)
|
2017-01-05 15:11:31 +01:00
|
|
|
connect_cli(dev[0], dev[1], freq=2417)
|
2016-12-29 10:37:58 +01:00
|
|
|
res = dev[0].group_request("CHAN_SWITCH 5 2422")
|
2013-11-17 15:45:34 +01:00
|
|
|
if "FAIL" in res:
|
|
|
|
# for now, skip test since mac80211_hwsim support is not yet widely
|
|
|
|
# deployed
|
2015-01-07 13:19:30 +01:00
|
|
|
raise HwsimSkip("Assume mac80211_hwsim did not support channel switching")
|
2016-12-29 10:37:58 +01:00
|
|
|
ev = dev[0].wait_group_event(["AP-CSA-FINISHED"], timeout=10)
|
2013-11-17 15:45:34 +01:00
|
|
|
if ev is None:
|
|
|
|
raise Exception("CSA finished event timed out")
|
|
|
|
if "freq=2422" not in ev:
|
|
|
|
raise Exception("Unexpected cahnnel in CSA finished event")
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[1].dump_monitor()
|
|
|
|
time.sleep(0.1)
|
|
|
|
hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
|
2014-04-13 10:46:26 +02:00
|
|
|
|
2017-01-05 15:11:31 +01:00
|
|
|
dev[0].remove_group()
|
|
|
|
dev[1].wait_go_ending_session()
|
|
|
|
|
|
|
|
def test_autogo_chan_switch_group_iface(dev):
|
|
|
|
"""P2P autonomous GO switching channels (separate group interface)"""
|
|
|
|
dev[0].global_request("SET p2p_no_group_iface 0")
|
|
|
|
run_autogo_chan_switch(dev)
|
|
|
|
|
2016-06-23 19:16:36 +02:00
|
|
|
@remote_compatible
|
2014-04-13 10:46:26 +02:00
|
|
|
def test_autogo_extra_cred(dev):
|
|
|
|
"""P2P autonomous GO sending two WPS credentials"""
|
|
|
|
if "FAIL" in dev[0].request("SET wps_testing_dummy_cred 1"):
|
|
|
|
raise Exception("Failed to enable test mode")
|
2014-11-28 15:54:31 +01:00
|
|
|
autogo(dev[0], freq=2412)
|
|
|
|
connect_cli(dev[0], dev[1], social=True, freq=2412)
|
2014-04-13 10:46:26 +02:00
|
|
|
dev[0].remove_group()
|
|
|
|
dev[1].wait_go_ending_session()
|
2014-04-14 23:23:55 +02:00
|
|
|
|
|
|
|
def test_autogo_ifdown(dev):
|
|
|
|
"""P2P autonomous GO and external ifdown"""
|
|
|
|
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
|
|
|
|
wpas.interface_add("wlan5")
|
|
|
|
res = autogo(wpas)
|
|
|
|
wpas.dump_monitor()
|
|
|
|
wpas.interface_remove("wlan5")
|
|
|
|
wpas.interface_add("wlan5")
|
|
|
|
res = autogo(wpas)
|
|
|
|
wpas.dump_monitor()
|
2015-02-06 23:22:32 +01:00
|
|
|
subprocess.call(['ifconfig', res['ifname'], 'down'])
|
2014-04-14 23:23:55 +02:00
|
|
|
ev = wpas.wait_global_event(["P2P-GROUP-REMOVED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Group removal not reported")
|
|
|
|
if res['ifname'] not in ev:
|
|
|
|
raise Exception("Unexpected group removal event: " + ev)
|
2014-05-14 01:31:55 +02:00
|
|
|
|
2016-06-23 19:16:36 +02:00
|
|
|
@remote_compatible
|
2014-05-14 01:31:55 +02:00
|
|
|
def test_autogo_start_during_scan(dev):
|
|
|
|
"""P2P autonomous GO started during ongoing manual scan"""
|
|
|
|
try:
|
|
|
|
# use autoscan to set scan_req = MANUAL_SCAN_REQ
|
|
|
|
if "OK" not in dev[0].request("AUTOSCAN periodic:1"):
|
|
|
|
raise Exception("Failed to set autoscan")
|
2014-11-28 15:54:31 +01:00
|
|
|
autogo(dev[0], freq=2462)
|
|
|
|
connect_cli(dev[0], dev[1], social=True, freq=2462)
|
2014-05-14 01:31:55 +02:00
|
|
|
dev[0].remove_group()
|
|
|
|
dev[1].wait_go_ending_session()
|
|
|
|
finally:
|
|
|
|
dev[0].request("AUTOSCAN ")
|
2014-06-21 23:17:18 +02:00
|
|
|
|
|
|
|
def test_autogo_passphrase_len(dev):
|
|
|
|
"""P2P autonomous GO and longer passphrase"""
|
|
|
|
try:
|
|
|
|
if "OK" not in dev[0].request("SET p2p_passphrase_len 13"):
|
|
|
|
raise Exception("Failed to set passphrase length")
|
2014-11-28 15:54:31 +01:00
|
|
|
res = autogo(dev[0], freq=2412)
|
2014-06-21 23:17:18 +02:00
|
|
|
if len(res['passphrase']) != 13:
|
|
|
|
raise Exception("Unexpected passphrase length")
|
|
|
|
if dev[0].get_group_status_field("passphrase", extra="WPS") != res['passphrase']:
|
|
|
|
raise Exception("passphrase mismatch")
|
|
|
|
|
|
|
|
logger.info("Connect P2P client")
|
2014-11-28 15:54:31 +01:00
|
|
|
connect_cli(dev[0], dev[1], social=True, freq=2412)
|
2014-06-21 23:17:18 +02:00
|
|
|
|
|
|
|
logger.info("Connect legacy WPS client")
|
|
|
|
pin = dev[2].wps_read_pin()
|
|
|
|
dev[0].p2p_go_authorize_client(pin)
|
|
|
|
dev[2].request("P2P_SET disabled 1")
|
|
|
|
dev[2].dump_monitor()
|
|
|
|
dev[2].request("WPS_PIN any " + pin)
|
2014-12-20 10:51:30 +01:00
|
|
|
dev[2].wait_connected(timeout=30)
|
2014-06-21 23:17:18 +02:00
|
|
|
status = dev[2].get_status()
|
|
|
|
if status['wpa_state'] != 'COMPLETED':
|
|
|
|
raise Exception("Not fully connected")
|
|
|
|
dev[2].request("DISCONNECT")
|
|
|
|
|
|
|
|
logger.info("Connect legacy non-WPS client")
|
|
|
|
dev[2].request("FLUSH")
|
|
|
|
dev[2].request("P2P_SET disabled 1")
|
|
|
|
dev[2].connect(ssid=res['ssid'], psk=res['passphrase'], proto='RSN',
|
|
|
|
key_mgmt='WPA-PSK', pairwise='CCMP', group='CCMP',
|
|
|
|
scan_freq=res['freq'])
|
|
|
|
hwsim_utils.test_connectivity_p2p_sta(dev[1], dev[2])
|
|
|
|
dev[2].request("DISCONNECT")
|
|
|
|
|
|
|
|
dev[0].remove_group()
|
|
|
|
dev[1].wait_go_ending_session()
|
|
|
|
finally:
|
|
|
|
dev[0].request("SET p2p_passphrase_len 8")
|
2014-09-01 15:27:27 +02:00
|
|
|
|
2016-06-23 19:16:36 +02:00
|
|
|
@remote_compatible
|
2014-09-01 15:27:27 +02:00
|
|
|
def test_autogo_bridge(dev):
|
|
|
|
"""P2P autonomous GO in a bridge"""
|
|
|
|
try:
|
|
|
|
# use autoscan to set scan_req = MANUAL_SCAN_REQ
|
|
|
|
if "OK" not in dev[0].request("AUTOSCAN periodic:1"):
|
|
|
|
raise Exception("Failed to set autoscan")
|
|
|
|
autogo(dev[0])
|
2015-02-06 02:31:00 +01:00
|
|
|
ifname = dev[0].get_group_ifname()
|
2016-06-23 19:16:29 +02:00
|
|
|
dev[0].cmd_execute(['brctl', 'addbr', 'p2p-br0'])
|
|
|
|
dev[0].cmd_execute(['brctl', 'setfd', 'p2p-br0', '0'])
|
|
|
|
dev[0].cmd_execute(['brctl', 'addif', 'p2p-br0', ifname])
|
|
|
|
dev[0].cmd_execute(['ip', 'link', 'set', 'dev', 'p2p-br0', 'up'])
|
2014-09-01 15:27:27 +02:00
|
|
|
time.sleep(0.1)
|
2016-06-23 19:16:29 +02:00
|
|
|
dev[0].cmd_execute(['brctl', 'delif', 'p2p-br0', ifname])
|
2014-09-01 15:27:27 +02:00
|
|
|
time.sleep(0.1)
|
2016-06-23 19:16:29 +02:00
|
|
|
dev[0].cmd_execute(['ip', 'link', 'set', 'dev', 'p2p-br0', 'down'])
|
2014-09-01 15:27:27 +02:00
|
|
|
time.sleep(0.1)
|
2016-06-23 19:16:29 +02:00
|
|
|
dev[0].cmd_execute(['brctl', 'delbr', 'p2p-br0'])
|
2014-09-01 15:27:27 +02:00
|
|
|
ev = dev[0].wait_global_event(["P2P-GROUP-REMOVED"], timeout=1)
|
|
|
|
if ev is not None:
|
|
|
|
raise Exception("P2P group removed unexpectedly")
|
2015-02-06 02:31:00 +01:00
|
|
|
if dev[0].get_group_status_field('wpa_state') != "COMPLETED":
|
2014-09-01 15:27:27 +02:00
|
|
|
raise Exception("Unexpected wpa_state")
|
|
|
|
dev[0].remove_group()
|
|
|
|
finally:
|
2014-09-27 11:16:06 +02:00
|
|
|
dev[0].request("AUTOSCAN ")
|
2016-06-23 19:16:29 +02:00
|
|
|
dev[0].cmd_execute(['brctl', 'delif', 'p2p-br0', ifname,
|
|
|
|
'2>', '/dev/null'], shell=True)
|
|
|
|
dev[0].cmd_execute(['ip', 'link', 'set', 'dev', 'p2p-br0', 'down',
|
|
|
|
'2>', '/dev/null'], shell=True)
|
|
|
|
dev[0].cmd_execute(['brctl', 'delbr', 'p2p-br0', '2>', '/dev/null'],
|
|
|
|
shell=True)
|
2014-12-14 12:16:05 +01:00
|
|
|
|
2016-06-23 19:16:36 +02:00
|
|
|
@remote_compatible
|
2014-12-14 12:16:05 +01:00
|
|
|
def test_presence_req_on_group_interface(dev):
|
|
|
|
"""P2P_PRESENCE_REQ on group interface"""
|
2016-04-07 12:32:03 +02:00
|
|
|
dev[1].global_request("SET p2p_no_group_iface 0")
|
2014-12-14 12:16:05 +01:00
|
|
|
res = autogo(dev[0], freq=2437)
|
|
|
|
res = connect_cli(dev[0], dev[1], social=True, freq=2437)
|
|
|
|
if "FAIL" in dev[1].group_request("P2P_PRESENCE_REQ 30000 102400"):
|
|
|
|
raise Exception("Could not send presence request")
|
|
|
|
ev = dev[1].wait_group_event(["P2P-PRESENCE-RESPONSE"])
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout while waiting for Presence Response")
|
|
|
|
dev[0].remove_group()
|
|
|
|
dev[1].wait_go_ending_session()
|
2015-02-08 11:18:03 +01:00
|
|
|
|
|
|
|
def test_autogo_join_auto_go_not_found(dev):
|
|
|
|
"""P2P_CONNECT-auto not finding GO"""
|
|
|
|
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
|
|
|
|
wpas.interface_add("wlan5")
|
|
|
|
wpas.request("P2P_SET listen_channel 1")
|
|
|
|
wpas.global_request("SET p2p_no_group_iface 0")
|
|
|
|
autogo(wpas, freq=2412)
|
|
|
|
addr = wpas.p2p_dev_addr()
|
|
|
|
bssid = wpas.p2p_interface_addr()
|
2015-10-04 00:42:42 +02:00
|
|
|
wpas.dump_monitor()
|
2015-02-08 11:18:03 +01:00
|
|
|
|
|
|
|
dev[1].global_request("SET p2p_no_group_iface 0")
|
|
|
|
dev[1].scan_for_bss(bssid, freq=2412)
|
|
|
|
# This makes the GO not show up in the scan iteration following the
|
|
|
|
# P2P_CONNECT command by stopping beaconing and handling Probe Request
|
|
|
|
# frames externally (but not really replying to them). P2P listen mode is
|
|
|
|
# needed to keep the GO listening on the operating channel for the PD
|
|
|
|
# exchange.
|
|
|
|
if "OK" not in wpas.group_request("STOP_AP"):
|
|
|
|
raise Exception("STOP_AP failed")
|
2015-10-04 00:42:42 +02:00
|
|
|
wpas.dump_monitor()
|
2015-02-08 11:18:03 +01:00
|
|
|
wpas.group_request("SET ext_mgmt_frame_handling 1")
|
|
|
|
wpas.p2p_listen()
|
2015-10-04 00:42:42 +02:00
|
|
|
wpas.dump_monitor()
|
2015-02-08 11:18:03 +01:00
|
|
|
time.sleep(0.02)
|
|
|
|
dev[1].global_request("P2P_CONNECT " + addr + " pbc auto")
|
|
|
|
|
2015-06-17 15:24:50 +02:00
|
|
|
ev = dev[1].wait_global_event(["P2P-FALLBACK-TO-GO-NEG-ENABLED"], 15)
|
2015-10-04 00:42:42 +02:00
|
|
|
wpas.dump_monitor()
|
2015-02-08 11:18:03 +01:00
|
|
|
if ev is None:
|
|
|
|
raise Exception("Could not trigger old-scan-only case")
|
|
|
|
return
|
|
|
|
|
2015-06-17 15:24:50 +02:00
|
|
|
ev = dev[1].wait_global_event(["P2P-FALLBACK-TO-GO-NEG"], 15)
|
2015-02-08 11:18:03 +01:00
|
|
|
wpas.remove_group()
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Fallback to GO Negotiation not seen")
|
|
|
|
if "reason=GO-not-found" not in ev:
|
|
|
|
raise Exception("Unexpected reason for fallback: " + ev)
|
2015-10-04 00:42:42 +02:00
|
|
|
wpas.dump_monitor()
|
2015-02-08 11:41:14 +01:00
|
|
|
|
|
|
|
def test_autogo_join_auto(dev):
|
|
|
|
"""P2P_CONNECT-auto joining a group"""
|
|
|
|
autogo(dev[0])
|
|
|
|
addr = dev[0].p2p_dev_addr()
|
|
|
|
if "OK" not in dev[1].global_request("P2P_CONNECT " + addr + " pbc auto"):
|
|
|
|
raise Exception("P2P_CONNECT failed")
|
|
|
|
|
|
|
|
ev = dev[0].wait_global_event(["P2P-PROV-DISC-PBC-REQ"], timeout=15)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout on P2P-PROV-DISC-PBC-REQ")
|
|
|
|
if "group=" + dev[0].group_ifname not in ev:
|
|
|
|
raise Exception("Unexpected PD event contents: " + ev)
|
|
|
|
dev[0].group_request("WPS_PBC")
|
|
|
|
|
|
|
|
ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Joining the group timed out")
|
|
|
|
dev[1].group_form_result(ev)
|
|
|
|
|
|
|
|
dev[0].remove_group()
|
|
|
|
dev[1].wait_go_ending_session()
|
|
|
|
dev[1].flush_scan_cache()
|
|
|
|
|
2016-06-23 19:16:36 +02:00
|
|
|
@remote_compatible
|
2015-02-08 11:41:14 +01:00
|
|
|
def test_autogo_join_auto_go_neg(dev):
|
|
|
|
"""P2P_CONNECT-auto fallback to GO Neg"""
|
2015-02-10 11:09:07 +01:00
|
|
|
dev[1].flush_scan_cache()
|
2015-02-08 11:41:14 +01:00
|
|
|
dev[0].p2p_listen()
|
|
|
|
addr = dev[0].p2p_dev_addr()
|
2015-12-01 23:40:17 +01:00
|
|
|
if not dev[1].discover_peer(addr, social=True):
|
|
|
|
raise Exception("Peer not found")
|
|
|
|
dev[1].p2p_stop_find()
|
2015-02-08 11:41:14 +01:00
|
|
|
if "OK" not in dev[1].global_request("P2P_CONNECT " + addr + " pbc auto"):
|
|
|
|
raise Exception("P2P_CONNECT failed")
|
|
|
|
|
|
|
|
ev = dev[0].wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=15)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout on P2P-GO-NEG-REQUEST")
|
|
|
|
peer = ev.split(' ')[1]
|
|
|
|
dev[0].p2p_go_neg_init(peer, None, "pbc", timeout=15, go_intent=15)
|
|
|
|
|
|
|
|
ev = dev[1].wait_global_event(["P2P-FALLBACK-TO-GO-NEG"], timeout=1)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("No P2P-FALLBACK-TO-GO-NEG event seen")
|
|
|
|
if "P2P-FALLBACK-TO-GO-NEG-ENABLED" in ev:
|
|
|
|
ev = dev[1].wait_global_event(["P2P-FALLBACK-TO-GO-NEG"], timeout=1)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("No P2P-FALLBACK-TO-GO-NEG event seen")
|
|
|
|
if "reason=peer-not-running-GO" not in ev:
|
|
|
|
raise Exception("Unexpected reason: " + ev)
|
|
|
|
|
|
|
|
ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Joining the group timed out")
|
|
|
|
dev[1].group_form_result(ev)
|
|
|
|
|
|
|
|
dev[0].remove_group()
|
|
|
|
dev[1].wait_go_ending_session()
|
|
|
|
dev[1].flush_scan_cache()
|
|
|
|
|
2016-06-23 19:16:36 +02:00
|
|
|
@remote_compatible
|
2015-02-08 11:41:14 +01:00
|
|
|
def test_autogo_join_auto_go_neg_after_seeing_go(dev):
|
|
|
|
"""P2P_CONNECT-auto fallback to GO Neg after seeing GO"""
|
|
|
|
autogo(dev[0], freq=2412)
|
|
|
|
addr = dev[0].p2p_dev_addr()
|
|
|
|
bssid = dev[0].p2p_interface_addr()
|
|
|
|
dev[1].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].remove_group()
|
|
|
|
dev[0].p2p_listen()
|
|
|
|
|
|
|
|
if "OK" not in dev[1].global_request("P2P_CONNECT " + addr + " pbc auto"):
|
|
|
|
raise Exception("P2P_CONNECT failed")
|
|
|
|
|
|
|
|
ev = dev[1].wait_global_event(["P2P-FALLBACK-TO-GO-NEG-ENABLED"],
|
|
|
|
timeout=15)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("No P2P-FALLBACK-TO-GO-NEG-ENABLED event seen")
|
|
|
|
|
|
|
|
ev = dev[0].wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=15)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout on P2P-GO-NEG-REQUEST")
|
|
|
|
peer = ev.split(' ')[1]
|
|
|
|
dev[0].p2p_go_neg_init(peer, None, "pbc", timeout=15, go_intent=15)
|
|
|
|
|
|
|
|
ev = dev[1].wait_global_event(["P2P-FALLBACK-TO-GO-NEG"], timeout=1)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("No P2P-FALLBACK-TO-GO-NEG event seen")
|
|
|
|
if "reason=no-ACK-to-PD-Req" not in ev and "reason=PD-failed" not in ev:
|
|
|
|
raise Exception("Unexpected reason: " + ev)
|
|
|
|
|
|
|
|
ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Joining the group timed out")
|
|
|
|
dev[1].group_form_result(ev)
|
|
|
|
|
|
|
|
dev[0].remove_group()
|
|
|
|
dev[1].wait_go_ending_session()
|
|
|
|
dev[1].flush_scan_cache()
|
2015-02-28 21:06:24 +01:00
|
|
|
|
|
|
|
def test_go_search_non_social(dev):
|
|
|
|
"""P2P_FIND with freq parameter to scan a single channel"""
|
|
|
|
addr0 = dev[0].p2p_dev_addr()
|
|
|
|
autogo(dev[0], freq=2422)
|
|
|
|
dev[1].p2p_find(freq=2422)
|
2015-06-17 15:24:50 +02:00
|
|
|
ev = dev[1].wait_global_event(["P2P-DEVICE-FOUND"], timeout=3.5)
|
2015-02-28 21:06:24 +01:00
|
|
|
if ev is None:
|
2017-02-07 10:08:24 +01:00
|
|
|
dev[1].p2p_stop_find()
|
|
|
|
dev[1].p2p_find(freq=2422)
|
|
|
|
ev = dev[1].wait_global_event(["P2P-DEVICE-FOUND"], timeout=3.5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Did not find GO quickly enough")
|
2015-02-28 21:06:24 +01:00
|
|
|
dev[2].p2p_listen()
|
2015-06-17 15:24:50 +02:00
|
|
|
ev = dev[1].wait_global_event(["P2P-DEVICE-FOUND"], timeout=5)
|
2015-02-28 21:06:24 +01:00
|
|
|
if ev is None:
|
|
|
|
raise Exception("Did not find peer")
|
|
|
|
dev[2].p2p_stop_find()
|
|
|
|
dev[1].p2p_stop_find()
|
|
|
|
dev[0].remove_group()
|
2015-03-01 19:54:21 +01:00
|
|
|
|
|
|
|
def test_autogo_many(dev):
|
|
|
|
"""P2P autonomous GO with large number of GO instances"""
|
2016-04-07 12:32:03 +02:00
|
|
|
dev[0].global_request("SET p2p_no_group_iface 0")
|
2015-03-01 19:54:21 +01:00
|
|
|
for i in range(100):
|
|
|
|
if "OK" not in dev[0].global_request("P2P_GROUP_ADD freq=2412"):
|
|
|
|
logger.info("Was able to add %d groups" % i)
|
|
|
|
if i < 5:
|
|
|
|
raise Exception("P2P_GROUP_ADD failed")
|
|
|
|
stop_ev = dev[0].wait_global_event(["P2P-GROUP-REMOVE"], timeout=1)
|
|
|
|
if stop_ev is not None:
|
|
|
|
raise Exception("Unexpected P2P-GROUP-REMOVE event")
|
|
|
|
break
|
|
|
|
ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("GO start up timed out")
|
|
|
|
dev[0].group_form_result(ev)
|
|
|
|
|
|
|
|
for i in dev[0].global_request("INTERFACES").splitlines():
|
|
|
|
dev[0].request("P2P_GROUP_REMOVE " + i)
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].request("P2P_GROUP_REMOVE *")
|
2015-03-14 09:58:17 +01:00
|
|
|
|
|
|
|
def test_autogo_many_clients(dev):
|
|
|
|
"""P2P autonomous GO and many clients (P2P IE fragmentation)"""
|
|
|
|
try:
|
|
|
|
_test_autogo_many_clients(dev)
|
|
|
|
finally:
|
2015-06-17 15:24:50 +02:00
|
|
|
dev[0].global_request("SET device_name Device A")
|
|
|
|
dev[1].global_request("SET device_name Device B")
|
|
|
|
dev[2].global_request("SET device_name Device C")
|
2015-03-14 09:58:17 +01:00
|
|
|
|
|
|
|
def _test_autogo_many_clients(dev):
|
|
|
|
# These long device names will push the P2P IE contents beyond the limit
|
|
|
|
# that requires fragmentation.
|
|
|
|
name0 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
|
|
|
name1 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
|
|
|
name2 = "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
|
|
|
|
name3 = "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
|
2015-06-17 15:24:50 +02:00
|
|
|
dev[0].global_request("SET device_name " + name0)
|
|
|
|
dev[1].global_request("SET device_name " + name1)
|
|
|
|
dev[2].global_request("SET device_name " + name2)
|
2015-03-14 09:58:17 +01:00
|
|
|
|
|
|
|
addr0 = dev[0].p2p_dev_addr()
|
|
|
|
res = autogo(dev[0], freq=2412)
|
|
|
|
bssid = dev[0].p2p_interface_addr()
|
|
|
|
|
|
|
|
connect_cli(dev[0], dev[1], social=True, freq=2412)
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
connect_cli(dev[0], dev[2], social=True, freq=2412)
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
|
|
|
|
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
|
|
|
|
wpas.interface_add("wlan5")
|
2015-06-17 15:24:50 +02:00
|
|
|
wpas.global_request("SET device_name " + name3)
|
|
|
|
wpas.global_request("SET sec_device_type 1-11111111-1")
|
|
|
|
wpas.global_request("SET sec_device_type 2-22222222-2")
|
|
|
|
wpas.global_request("SET sec_device_type 3-33333333-3")
|
|
|
|
wpas.global_request("SET sec_device_type 4-44444444-4")
|
|
|
|
wpas.global_request("SET sec_device_type 5-55555555-5")
|
2015-03-14 09:58:17 +01:00
|
|
|
connect_cli(dev[0], wpas, social=True, freq=2412)
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
|
|
|
|
dev[1].dump_monitor()
|
|
|
|
dev[1].p2p_find(freq=2412)
|
|
|
|
ev1 = dev[1].wait_global_event(["P2P-DEVICE-FOUND"], timeout=10)
|
|
|
|
if ev1 is None:
|
|
|
|
raise Exception("Could not find peer (1)")
|
|
|
|
ev2 = dev[1].wait_global_event(["P2P-DEVICE-FOUND"], timeout=10)
|
|
|
|
if ev2 is None:
|
|
|
|
raise Exception("Could not find peer (2)")
|
|
|
|
ev3 = dev[1].wait_global_event(["P2P-DEVICE-FOUND"], timeout=10)
|
|
|
|
if ev3 is None:
|
|
|
|
raise Exception("Could not find peer (3)")
|
|
|
|
dev[1].p2p_stop_find()
|
|
|
|
|
|
|
|
for i in [ name0, name2, name3 ]:
|
|
|
|
if i not in ev1 and i not in ev2 and i not in ev3:
|
|
|
|
raise Exception('name "%s" not found' % i)
|
2015-10-25 10:13:32 +01:00
|
|
|
|
|
|
|
def rx_pd_req(dev):
|
|
|
|
msg = dev.mgmt_rx()
|
|
|
|
if msg is None:
|
|
|
|
raise Exception("MGMT-RX timeout")
|
|
|
|
p2p = parse_p2p_public_action(msg['payload'])
|
|
|
|
if p2p is None:
|
|
|
|
raise Exception("Not a P2P Public Action frame " + str(dialog_token))
|
|
|
|
if p2p['subtype'] != P2P_PROV_DISC_REQ:
|
|
|
|
raise Exception("Unexpected subtype %d" % p2p['subtype'])
|
|
|
|
p2p['freq'] = msg['freq']
|
|
|
|
return p2p
|
|
|
|
|
2016-06-23 19:16:36 +02:00
|
|
|
@remote_compatible
|
2015-10-25 10:13:32 +01:00
|
|
|
def test_autogo_scan(dev):
|
|
|
|
"""P2P autonomous GO and no P2P IE in Probe Response scan results"""
|
|
|
|
addr0 = dev[0].p2p_dev_addr()
|
|
|
|
addr1 = dev[1].p2p_dev_addr()
|
|
|
|
dev[0].p2p_start_go(freq=2412, persistent=True)
|
|
|
|
bssid = dev[0].p2p_interface_addr()
|
|
|
|
|
|
|
|
dev[1].discover_peer(addr0)
|
|
|
|
dev[1].p2p_stop_find()
|
|
|
|
ev = dev[1].wait_global_event(["P2P-FIND-STOPPED"], timeout=2)
|
|
|
|
time.sleep(0.1)
|
|
|
|
dev[1].flush_scan_cache()
|
|
|
|
|
|
|
|
pin = dev[1].wps_read_pin()
|
|
|
|
dev[0].group_request("WPS_PIN any " + pin)
|
|
|
|
|
|
|
|
try:
|
|
|
|
dev[1].request("SET p2p_disabled 1")
|
|
|
|
dev[1].request("SCAN freq=2412")
|
|
|
|
ev = dev[1].wait_event(["CTRL-EVENT-SCAN-RESULTS"])
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Active scan did not complete")
|
|
|
|
finally:
|
|
|
|
dev[1].request("SET p2p_disabled 0")
|
|
|
|
|
|
|
|
for i in range(2):
|
|
|
|
dev[1].request("SCAN freq=2412 passive=1")
|
|
|
|
ev = dev[1].wait_event(["CTRL-EVENT-SCAN-RESULTS"])
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Scan did not complete")
|
|
|
|
|
|
|
|
# Disable management frame processing for a moment to skip Probe Response
|
|
|
|
# frame with P2P IE.
|
|
|
|
dev[0].group_request("SET ext_mgmt_frame_handling 1")
|
|
|
|
|
2016-04-07 12:31:57 +02:00
|
|
|
dev[1].global_request("P2P_CONNECT " + bssid + " " + pin + " freq=2412 join")
|
2015-10-25 10:13:32 +01:00
|
|
|
|
|
|
|
# Skip the first Probe Request frame
|
|
|
|
ev = dev[0].wait_group_event(["MGMT-RX"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("No Probe Request frame seen")
|
|
|
|
if not ev.split(' ')[4].startswith("40"):
|
|
|
|
raise Exception("Not a Probe Request frame")
|
|
|
|
|
2016-04-07 12:31:57 +02:00
|
|
|
# If a P2P Device is not used, the PD Request will be received on the group
|
|
|
|
# interface (which is actually wlan0, since a separate interface is not
|
|
|
|
# used), which was set to external management frame handling, so need to
|
|
|
|
# reply to it manually.
|
|
|
|
res = dev[0].get_driver_status()
|
|
|
|
if not (int(res['capa.flags'], 0) & 0x20000000):
|
|
|
|
# Reply to PD Request while still filtering Probe Request frames
|
|
|
|
msg = rx_pd_req(dev[0])
|
|
|
|
mgmt_tx(dev[0], "MGMT_TX {} {} freq={} wait_time=10 no_cck=1 action={}".format(addr1, addr0, 2412, "0409506f9a0908%02xdd0a0050f204100800020008" % msg['dialog_token']))
|
2015-10-25 10:13:32 +01:00
|
|
|
|
|
|
|
# Skip Probe Request frames until something else is received
|
|
|
|
for i in range(10):
|
|
|
|
ev = dev[0].wait_group_event(["MGMT-RX"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("No frame seen")
|
|
|
|
if not ev.split(' ')[4].startswith("40"):
|
|
|
|
break
|
|
|
|
|
|
|
|
# Allow wpa_supplicant to process authentication and association
|
|
|
|
dev[0].group_request("SET ext_mgmt_frame_handling 0")
|
|
|
|
|
|
|
|
# Joining the group should succeed and indicate persistent group based on
|
|
|
|
# Beacon frame P2P IE.
|
|
|
|
ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Failed to join group")
|
|
|
|
if "[PERSISTENT]" not in ev:
|
|
|
|
raise Exception("Did not recognize group as persistent")
|
|
|
|
dev[0].remove_group()
|
|
|
|
dev[1].wait_go_ending_session()
|
2015-11-26 14:17:06 +01:00
|
|
|
|
2016-06-23 19:16:36 +02:00
|
|
|
@remote_compatible
|
2015-11-26 14:17:06 +01:00
|
|
|
def test_autogo_join_before_found(dev):
|
|
|
|
"""P2P client joining a group before having found GO Device Address"""
|
2016-04-07 12:32:03 +02:00
|
|
|
dev[0].global_request("SET p2p_no_group_iface 0")
|
2015-11-26 14:17:06 +01:00
|
|
|
res = autogo(dev[0], freq=2412)
|
|
|
|
if "p2p-wlan" not in res['ifname']:
|
|
|
|
raise Exception("Unexpected group interface name on GO")
|
|
|
|
status = dev[0].get_group_status()
|
|
|
|
bssid = status['bssid']
|
|
|
|
|
|
|
|
pin = dev[1].wps_read_pin()
|
|
|
|
dev[0].p2p_go_authorize_client(pin)
|
|
|
|
cmd = "P2P_CONNECT " + bssid + " " + pin + " join freq=2412"
|
|
|
|
if "OK" not in dev[1].global_request(cmd):
|
|
|
|
raise Exception("P2P_CONNECT join failed")
|
|
|
|
ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Joining the group timed out")
|
|
|
|
dev[0].remove_group()
|
|
|
|
dev[1].wait_go_ending_session()
|