Esempio n. 1
0
def test_wifi_display_persistent_group(dev):
    """P2P persistent group formation and re-invocation with Wi-Fi Display enabled"""
    try:
        enable_wifi_display(dev[0])
        enable_wifi_display(dev[1])
        enable_wifi_display(dev[2])

        form(dev[0], dev[1])
        peer = dev[1].get_peer(dev[0].p2p_dev_addr())
        listen_freq = peer['listen_freq']
        invite_from_cli(dev[0], dev[1])
        invite_from_go(dev[0], dev[1])

        dev[0].dump_monitor()
        dev[1].dump_monitor()
        networks = dev[0].list_networks()
        if len(networks) != 1:
            raise Exception("Unexpected number of networks")
        if "[P2P-PERSISTENT]" not in networks[0]['flags']:
            raise Exception("Not the persistent group data")
        if "OK" not in dev[0].global_request("P2P_GROUP_ADD persistent=" + networks[0]['id'] + " freq=" + listen_freq):
            raise Exception("Could not state GO")
        connect_cli(dev[0], dev[2])
        invite_from_cli(dev[0], dev[1])

    finally:
        dev[0].request("SET wifi_display 0")
        dev[1].request("SET wifi_display 0")
        dev[2].request("SET wifi_display 0")
Esempio n. 2
0
def test_wifi_display_persistent_group(dev):
    """P2P persistent group formation and re-invocation with Wi-Fi Display enabled"""
    try:
        enable_wifi_display(dev[0])
        enable_wifi_display(dev[1])
        enable_wifi_display(dev[2])

        form(dev[0], dev[1])
        peer = dev[1].get_peer(dev[0].p2p_dev_addr())
        listen_freq = peer['listen_freq']
        invite_from_cli(dev[0], dev[1])
        invite_from_go(dev[0], dev[1])

        dev[0].dump_monitor()
        dev[1].dump_monitor()
        networks = dev[0].list_networks()
        if len(networks) != 1:
            raise Exception("Unexpected number of networks")
        if "[P2P-PERSISTENT]" not in networks[0]['flags']:
            raise Exception("Not the persistent group data")
        if "OK" not in dev[0].global_request("P2P_GROUP_ADD persistent=" +
                                             networks[0]['id'] + " freq=" +
                                             listen_freq):
            raise Exception("Could not state GO")
        connect_cli(dev[0], dev[2])
        invite_from_cli(dev[0], dev[1])

    finally:
        dev[0].request("SET wifi_display 0")
        dev[1].request("SET wifi_display 0")
        dev[2].request("SET wifi_display 0")
def _test_p2p_ext_vendor_elem_invitation(dev):
    addr0 = dev[0].p2p_dev_addr()
    addr1 = dev[1].p2p_dev_addr()
    form(dev[0], dev[1])
    if "OK" not in dev[0].request("VENDOR_ELEM_ADD 9 dd050011223306"):
        raise Exception("VENDOR_ELEM_ADD failed")
    if "OK" not in dev[0].request("VENDOR_ELEM_ADD 10 dd050011223307"):
        raise Exception("VENDOR_ELEM_ADD failed")
    dev[1].p2p_listen()
    if not dev[0].discover_peer(addr1):
        raise Exception("Device discovery timed out")
    peer = dev[0].get_peer(addr1)
    dev[0].p2p_stop_find()
    if "FAIL" in dev[1].request("SET ext_mgmt_frame_handling 1"):
        raise Exception("Failed to enable external management frame handling")
    dev[0].global_request("P2P_INVITE persistent=" + peer['persistent'] +
                          " peer=" + addr1)
    for i in range(5):
        ev = dev[1].wait_event(["MGMT-RX"], timeout=5)
        if ev is None:
            raise Exception("MGMT-RX timeout")
        if " d0" in ev:
            break
    if "dd050011223306" not in ev:
        raise Exception(
            "Vendor element not found from Invitation Request frame")
    dev[0].p2p_stop_find()
    dev[1].p2p_stop_find()

    dev[0].p2p_listen()
    if "FAIL" in dev[1].request("SET ext_mgmt_frame_handling 0"):
        raise Exception("Failed to disable external management frame handling")
    if not dev[1].discover_peer(addr0):
        raise Exception("Device discovery timed out")
    peer = dev[1].get_peer(addr0)
    dev[1].p2p_stop_find()
    if "FAIL" in dev[1].request("SET ext_mgmt_frame_handling 1"):
        raise Exception("Failed to enable external management frame handling")
    dev[1].global_request("P2P_INVITE persistent=" + peer['persistent'] +
                          " peer=" + addr0)
    for i in range(5):
        ev = dev[1].wait_event(["MGMT-RX"], timeout=5)
        if ev is None:
            raise Exception("MGMT-RX timeout")
        if " d0" in ev:
            break
    if "dd050011223307" not in ev:
        raise Exception(
            "Vendor element not found from Invitation Response frame")
    dev[0].p2p_stop_find()
    dev[1].p2p_stop_find()
Esempio n. 4
0
def test_concurrent_persistent_group(dev, apdev):
    """Concurrent P2P persistent group"""
    logger.info("Connect to an infrastructure AP")
    hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open", "channel": "2" })
    dev[0].request("SET p2p_no_group_iface 0")
    dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2417")

    logger.info("Run persistent group test while associated to an AP")
    form(dev[0], dev[1])
    [go_res, cli_res] = invite_from_cli(dev[0], dev[1])
    if go_res['freq'] != '2417':
        raise Exception("Unexpected channel selected: " + go_res['freq'])
    [go_res, cli_res] = invite_from_go(dev[0], dev[1])
    if go_res['freq'] != '2417':
        raise Exception("Unexpected channel selected: " + go_res['freq'])
Esempio n. 5
0
def test_concurrent_persistent_group(dev, apdev):
    """Concurrent P2P persistent group"""
    logger.info("Connect to an infrastructure AP")
    hostapd.add_ap(apdev[0]['ifname'], {"ssid": "test-open", "channel": "2"})
    dev[0].request("SET p2p_no_group_iface 0")
    dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2417")

    logger.info("Run persistent group test while associated to an AP")
    form(dev[0], dev[1])
    [go_res, cli_res] = invite_from_cli(dev[0], dev[1])
    if go_res['freq'] != '2417':
        raise Exception("Unexpected channel selected: " + go_res['freq'])
    [go_res, cli_res] = invite_from_go(dev[0], dev[1])
    if go_res['freq'] != '2417':
        raise Exception("Unexpected channel selected: " + go_res['freq'])
Esempio n. 6
0
def test_concurrent_invitation_channel_mismatch(dev, apdev):
    """P2P persistent group invitation and channel mismatch"""
    form(dev[0], dev[1])
    dev[0].dump_monitor()
    dev[1].dump_monitor()

    logger.info("Connect to an infrastructure AP")
    hostapd.add_ap(apdev[0]['ifname'], {"ssid": "test-open", "channel": "2"})
    dev[0].request("SET p2p_no_group_iface 0")
    dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2417")
    invite(dev[1], dev[0], extra="freq=2412")
    ev = dev[1].wait_global_event(["P2P-INVITATION-RESULT"], timeout=15)
    if ev is None:
        raise Exception("P2P invitation result not received")
    if "status=7" not in ev:
        raise Exception("Unexpected P2P invitation result: " + ev)
def test_concurrent_invitation_channel_mismatch(dev, apdev):
    """P2P persistent group invitation and channel mismatch"""
    form(dev[0], dev[1])
    dev[0].dump_monitor()
    dev[1].dump_monitor()

    logger.info("Connect to an infrastructure AP")
    hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open", "channel": "2" })
    dev[0].request("SET p2p_no_group_iface 0")
    dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2417")
    invite(dev[1], dev[0], extra="freq=2412")
    ev = dev[1].wait_global_event(["P2P-INVITATION-RESULT"], timeout=15)
    if ev is None:
        raise Exception("P2P invitation result not received")
    if "status=7" not in ev:
        raise Exception("Unexpected P2P invitation result: " + ev)
Esempio n. 8
0
def test_wifi_display_persistent_group(dev):
    """P2P persistent group formation and re-invocation with Wi-Fi Display enabled"""
    try:
        enable_wifi_display(dev[0])
        enable_wifi_display(dev[1])
        enable_wifi_display(dev[2])

        form(dev[0], dev[1])
        peer = dev[1].get_peer(dev[0].p2p_dev_addr())
        listen_freq = peer['listen_freq']
        invite_from_cli(dev[0], dev[1])
        invite_from_go(dev[0], dev[1])

        dev[0].dump_monitor()
        dev[1].dump_monitor()
        networks = dev[0].list_networks(p2p=True)
        if len(networks) != 1:
            raise Exception("Unexpected number of networks")
        if "[P2P-PERSISTENT]" not in networks[0]['flags']:
            raise Exception("Not the persistent group data")
        if "OK" not in dev[0].global_request("P2P_GROUP_ADD persistent=" +
                                             networks[0]['id'] + " freq=" +
                                             listen_freq):
            raise Exception("Could not start GO")
        ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=2)
        if ev is None:
            raise Exception("GO start up timed out")
        dev[0].group_form_result(ev)

        connect_cli(dev[0], dev[2], social=True, freq=listen_freq)
        dev[0].dump_monitor()
        dev[1].dump_monitor()
        invite(dev[1], dev[0])
        ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=30)
        if ev is None:
            raise Exception("Timeout on group re-invocation (on client)")
        dev[1].group_form_result(ev)

        ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=0.1)
        if ev is not None:
            raise Exception("Unexpected P2P-GROUP-START on GO")
        hwsim_utils.test_connectivity_p2p(dev[0], dev[1])

    finally:
        dev[0].request("SET wifi_display 0")
        dev[1].request("SET wifi_display 0")
        dev[2].request("SET wifi_display 0")
Esempio n. 9
0
def _test_p2p_ext_vendor_elem_invitation(dev):
    addr0 = dev[0].p2p_dev_addr()
    addr1 = dev[1].p2p_dev_addr()
    form(dev[0], dev[1])
    if "OK" not in dev[0].request("VENDOR_ELEM_ADD 9 dd050011223306"):
        raise Exception("VENDOR_ELEM_ADD failed")
    if "OK" not in dev[0].request("VENDOR_ELEM_ADD 10 dd050011223307"):
        raise Exception("VENDOR_ELEM_ADD failed")
    dev[1].p2p_listen()
    if not dev[0].discover_peer(addr1):
        raise Exception("Device discovery timed out")
    peer = dev[0].get_peer(addr1)
    dev[0].p2p_stop_find()
    if "FAIL" in dev[1].request("SET ext_mgmt_frame_handling 1"):
        raise Exception("Failed to enable external management frame handling")
    dev[0].global_request("P2P_INVITE persistent=" + peer['persistent'] + " peer=" + addr1)
    for i in range(5):
        ev = dev[1].wait_event(["MGMT-RX"], timeout=5)
        if ev is None:
            raise Exception("MGMT-RX timeout")
        if " d0" in ev:
            break
    if "dd050011223306" not in ev:
        raise Exception("Vendor element not found from Invitation Request frame")
    dev[0].p2p_stop_find()
    dev[1].p2p_stop_find()

    dev[0].p2p_listen()
    if "FAIL" in dev[1].request("SET ext_mgmt_frame_handling 0"):
        raise Exception("Failed to disable external management frame handling")
    if not dev[1].discover_peer(addr0):
        raise Exception("Device discovery timed out")
    peer = dev[1].get_peer(addr0)
    dev[1].p2p_stop_find()
    if "FAIL" in dev[1].request("SET ext_mgmt_frame_handling 1"):
        raise Exception("Failed to enable external management frame handling")
    dev[1].global_request("P2P_INVITE persistent=" + peer['persistent'] + " peer=" + addr0)
    for i in range(5):
        ev = dev[1].wait_event(["MGMT-RX"], timeout=5)
        if ev is None:
            raise Exception("MGMT-RX timeout")
        if " d0" in ev:
            break
    if "dd050011223307" not in ev:
        raise Exception("Vendor element not found from Invitation Response frame")
    dev[0].p2p_stop_find()
    dev[1].p2p_stop_find()
Esempio n. 10
0
def test_wifi_display_persistent_group(dev):
    """P2P persistent group formation and re-invocation with Wi-Fi Display enabled"""
    try:
        enable_wifi_display(dev[0])
        enable_wifi_display(dev[1])
        enable_wifi_display(dev[2])

        form(dev[0], dev[1])
        peer = dev[1].get_peer(dev[0].p2p_dev_addr())
        listen_freq = peer['listen_freq']
        invite_from_cli(dev[0], dev[1])
        invite_from_go(dev[0], dev[1])

        dev[0].dump_monitor()
        dev[1].dump_monitor()
        networks = dev[0].list_networks(p2p=True)
        if len(networks) != 1:
            raise Exception("Unexpected number of networks")
        if "[P2P-PERSISTENT]" not in networks[0]['flags']:
            raise Exception("Not the persistent group data")
        if "OK" not in dev[0].global_request("P2P_GROUP_ADD persistent=" + networks[0]['id'] + " freq=" + listen_freq):
            raise Exception("Could not start GO")
        ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=2)
        if ev is None:
            raise Exception("GO start up timed out")
        dev[0].group_form_result(ev)

        connect_cli(dev[0], dev[2], social=True, freq=listen_freq)
        dev[0].dump_monitor()
        dev[1].dump_monitor()
        invite(dev[1], dev[0])
        ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=30)
        if ev is None:
            raise Exception("Timeout on group re-invocation (on client)")
        dev[1].group_form_result(ev)

        ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=0.1)
        if ev is not None:
            raise Exception("Unexpected P2P-GROUP-START on GO")
        hwsim_utils.test_connectivity_p2p(dev[0], dev[1])

    finally:
        dev[0].request("SET wifi_display 0")
        dev[1].request("SET wifi_display 0")
        dev[2].request("SET wifi_display 0")