2 # Copyright (c) 2014, Jouni Malinen <j@w1.fi>
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
34 "ssid_postfix 123456789012345678901234" ]:
35 if "FAIL" not in dev[0].request("P2P_SET " + cmd):
36 raise Exception("Invalid P2P_SET accepted: " + cmd)
38 def test_p2p_set_discoverability(dev):
39 """P2P_SET discoverability"""
40 addr0 = dev[0].p2p_dev_addr()
41 addr1 = dev[1].p2p_dev_addr()
43 dev[0].p2p_start_go(freq="2412")
44 if "OK" not in dev[1].request("P2P_SET discoverability 0"):
45 raise Exception("P2P_SET discoverability 0 failed")
46 pin = dev[1].wps_read_pin()
47 dev[0].p2p_go_authorize_client(pin)
48 dev[1].p2p_connect_group(addr0, pin, timeout=20, social=True, freq="2412")
50 if not dev[2].discover_peer(addr1, timeout=10):
51 if not dev[2].discover_peer(addr1, timeout=10):
52 if not dev[2].discover_peer(addr1, timeout=10):
53 raise Exception("Could not discover group client")
55 peer = dev[2].get_peer(addr1)
56 if int(peer['dev_capab'], 16) & 0x02 != 0:
57 raise Exception("Discoverability dev_capab reported: " + peer['dev_capab'])
58 dev[2].p2p_stop_find()
60 if "OK" not in dev[1].request("P2P_SET discoverability 1"):
61 raise Exception("P2P_SET discoverability 1 failed")
63 dev[1].group_request("REASSOCIATE")
64 ev = dev[1].wait_group_event(["CTRL-EVENT-CONNECTED"], timeout=20)
66 raise Exception("Connection timed out")
68 dev[2].request("P2P_FLUSH")
69 if not dev[2].discover_peer(addr1, timeout=10):
70 if not dev[2].discover_peer(addr1, timeout=10):
71 if not dev[2].discover_peer(addr1, timeout=10):
72 raise Exception("Could not discover group client")
74 peer = dev[2].get_peer(addr1)
75 if int(peer['dev_capab'], 16) & 0x02 != 0x02:
76 raise Exception("Discoverability dev_capab reported: " + peer['dev_capab'])
77 dev[2].p2p_stop_find()
79 def test_p2p_set_managed(dev):
81 addr0 = dev[0].p2p_dev_addr()
83 if "OK" not in dev[0].request("P2P_SET managed 1"):
84 raise Exception("P2P_SET managed 1 failed")
87 if not dev[1].discover_peer(addr0):
88 raise Exception("Could not discover peer")
89 peer = dev[1].get_peer(addr0)
90 if int(peer['dev_capab'], 16) & 0x08 != 0x08:
91 raise Exception("Managed dev_capab not reported: " + peer['dev_capab'])
92 dev[1].p2p_stop_find()
94 if "OK" not in dev[0].request("P2P_SET managed 0"):
95 raise Exception("P2P_SET managed 0 failed")
97 if not dev[2].discover_peer(addr0):
98 raise Exception("Could not discover peer")
99 peer = dev[2].get_peer(addr0)
100 if int(peer['dev_capab'], 16) & 0x08 != 0:
101 raise Exception("Managed dev_capab reported: " + peer['dev_capab'])
102 dev[2].p2p_stop_find()
103 dev[0].p2p_stop_find()
105 def test_p2p_set_ssid_postfix(dev):
106 """P2P_SET ssid_postfix"""
107 addr0 = dev[0].p2p_dev_addr()
108 addr1 = dev[1].p2p_dev_addr()
109 postfix = "12345678901234567890123"
112 if "OK" not in dev[0].request("P2P_SET ssid_postfix " + postfix):
113 raise Exception("P2P_SET ssid_postfix failed")
114 dev[0].p2p_start_go(freq="2412")
115 pin = dev[1].wps_read_pin()
116 dev[0].p2p_go_authorize_client(pin)
117 dev[1].p2p_connect_group(addr0, pin, timeout=20, social=True, freq="2412")
118 if postfix not in dev[1].get_group_status_field("ssid"):
119 raise Exception("SSID postfix missing from status")
120 if postfix not in dev[1].group_request("SCAN_RESULTS"):
121 raise Exception("SSID postfix missing from scan results")
123 dev[0].request("P2P_SET ssid_postfix ")