]>
git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_p2p_service.py
1 # P2P service discovery test cases
2 # Copyright (c) 2013, Jouni Malinen <j@w1.fi>
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
7 from remotehost
import remote_compatible
9 logger
= logging
.getLogger()
15 def add_bonjour_services(dev
):
16 dev
.global_request("P2P_SERVICE_ADD bonjour 0b5f6166706f766572746370c00c000c01 074578616d706c65c027")
17 dev
.global_request("P2P_SERVICE_ADD bonjour 076578616d706c650b5f6166706f766572746370c00c001001 00")
18 dev
.global_request("P2P_SERVICE_ADD bonjour 045f697070c00c000c01 094d795072696e746572c027")
19 dev
.global_request("P2P_SERVICE_ADD bonjour 096d797072696e746572045f697070c00c001001 09747874766572733d311a70646c3d6170706c69636174696f6e2f706f7374736372797074")
21 def add_upnp_services(dev
):
22 dev
.global_request("P2P_SERVICE_ADD upnp 10 uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice")
23 dev
.global_request("P2P_SERVICE_ADD upnp 10 uuid:5566d33e-9774-09ab-4822-333456785632::upnp:rootdevice")
24 dev
.global_request("P2P_SERVICE_ADD upnp 10 uuid:1122de4e-8574-59ab-9322-333456789044::urn:schemas-upnp-org:service:ContentDirectory:2")
25 dev
.global_request("P2P_SERVICE_ADD upnp 10 uuid:5566d33e-9774-09ab-4822-333456785632::urn:schemas-upnp-org:service:ContentDirectory:2")
26 dev
.global_request("P2P_SERVICE_ADD upnp 10 uuid:6859dede-8574-59ab-9332-123456789012::urn:schemas-upnp-org:device:InternetGatewayDevice:1")
28 def add_extra_services(dev
):
29 for i
in range(0, 100):
30 dev
.global_request("P2P_SERVICE_ADD upnp 10 uuid:" + str(uuid
.uuid4()) + "::upnp:rootdevice")
32 def run_sd(dev
, dst
, query
, exp_query
=None, fragment
=False, query2
=None):
33 addr0
= dev
[0].p2p_dev_addr()
34 addr1
= dev
[1].p2p_dev_addr()
35 add_bonjour_services(dev
[0])
36 add_upnp_services(dev
[0])
38 add_extra_services(dev
[0])
41 dev
[1].global_request("P2P_FLUSH")
42 dev
[1].global_request("P2P_SERV_DISC_REQ " + dst
+ " " + query
)
44 dev
[1].global_request("P2P_SERV_DISC_REQ " + dst
+ " " + query2
)
45 if not dev
[1].discover_peer(addr0
, social
=True, force_find
=True):
46 raise Exception("Peer " + addr0
+ " not found")
48 ev
= dev
[0].wait_global_event(["P2P-SERV-DISC-REQ"], timeout
=10)
50 raise Exception("Service discovery timed out")
52 raise Exception("Unexpected service discovery request source")
55 if exp_query
not in ev
and (query2
is None or query2
not in ev
):
56 raise Exception("Unexpected service discovery request contents")
61 ev
= dev
[1].wait_global_event(["P2P-SERV-DISC-RESP"], timeout
=10)
63 raise Exception("Service discovery timed out")
71 ev
= dev
[1].wait_global_event(["P2P-SERV-DISC-RESP"], timeout
=10)
73 raise Exception("Service discovery timed out")
77 dev
[0].p2p_stop_find()
78 dev
[1].p2p_stop_find()
80 if "OK" not in dev
[0].global_request("P2P_SERVICE_DEL upnp 10 uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice"):
81 raise Exception("Failed to delete a UPnP service")
82 if "FAIL" not in dev
[0].global_request("P2P_SERVICE_DEL upnp 10 uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice"):
83 raise Exception("Unexpected deletion success for UPnP service")
84 if "OK" not in dev
[0].global_request("P2P_SERVICE_DEL bonjour 0b5f6166706f766572746370c00c000c01"):
85 raise Exception("Failed to delete a Bonjour service")
86 if "FAIL" not in dev
[0].global_request("P2P_SERVICE_DEL bonjour 0b5f6166706f766572746370c00c000c01"):
87 raise Exception("Unexpected deletion success for Bonjour service")
92 def test_p2p_service_discovery(dev
):
93 """P2P service discovery"""
94 addr0
= dev
[0].p2p_dev_addr()
95 for dst
in [ "00:00:00:00:00:00", addr0
]:
96 ev
= run_sd(dev
, dst
, "02000001")
97 if "0b5f6166706f766572746370c00c000c01" not in ev
:
98 raise Exception("Unexpected service discovery response contents (Bonjour)")
99 if "496e7465726e6574" not in ev
:
100 raise Exception("Unexpected service discovery response contents (UPnP)")
102 for req
in [ "foo 02000001",
104 addr0
+ " upnp qq urn:schemas-upnp-org:device:InternetGatewayDevice:1",
108 if "FAIL" not in dev
[1].global_request("P2P_SERV_DISC_REQ " + req
):
109 raise Exception("Invalid P2P_SERV_DISC_REQ accepted: " + req
)
111 def test_p2p_service_discovery2(dev
):
112 """P2P service discovery with one peer having no services"""
114 for dst
in [ "00:00:00:00:00:00", dev
[0].p2p_dev_addr() ]:
115 ev
= run_sd(dev
, dst
, "02000001")
116 if "0b5f6166706f766572746370c00c000c01" not in ev
:
117 raise Exception("Unexpected service discovery response contents (Bonjour)")
118 if "496e7465726e6574" not in ev
:
119 raise Exception("Unexpected service discovery response contents (UPnP)")
121 def test_p2p_service_discovery3(dev
):
122 """P2P service discovery for Bonjour with one peer having no services"""
124 for dst
in [ "00:00:00:00:00:00", dev
[0].p2p_dev_addr() ]:
125 ev
= run_sd(dev
, dst
, "02000101")
126 if "0b5f6166706f766572746370c00c000c01" not in ev
:
127 raise Exception("Unexpected service discovery response contents (Bonjour)")
129 def test_p2p_service_discovery4(dev
):
130 """P2P service discovery for UPnP with one peer having no services"""
132 for dst
in [ "00:00:00:00:00:00", dev
[0].p2p_dev_addr() ]:
133 ev
= run_sd(dev
, dst
, "02000201")
134 if "496e7465726e6574" not in ev
:
135 raise Exception("Unexpected service discovery response contents (UPnP)")
138 def test_p2p_service_discovery_multiple_queries(dev
):
139 """P2P service discovery with multiple queries"""
140 for dst
in [ "00:00:00:00:00:00", dev
[0].p2p_dev_addr() ]:
141 ev
= run_sd(dev
, dst
, "02000201", query2
="02000101")
142 if "0b5f6166706f766572746370c00c000c01" not in ev
[0] + ev
[1]:
143 raise Exception("Unexpected service discovery response contents (Bonjour)")
144 if "496e7465726e6574" not in ev
[0] + ev
[1]:
145 raise Exception("Unexpected service discovery response contents (UPnP)")
147 def test_p2p_service_discovery_multiple_queries2(dev
):
148 """P2P service discovery with multiple queries with one peer having no services"""
150 for dst
in [ "00:00:00:00:00:00", dev
[0].p2p_dev_addr() ]:
151 ev
= run_sd(dev
, dst
, "02000201", query2
="02000101")
152 if "0b5f6166706f766572746370c00c000c01" not in ev
[0] + ev
[1]:
153 raise Exception("Unexpected service discovery response contents (Bonjour)")
154 if "496e7465726e6574" not in ev
[0] + ev
[1]:
155 raise Exception("Unexpected service discovery response contents (UPnP)")
157 def test_p2p_service_discovery_fragmentation(dev
):
158 """P2P service discovery with fragmentation"""
159 for dst
in [ "00:00:00:00:00:00", dev
[0].p2p_dev_addr() ]:
160 ev
= run_sd(dev
, dst
, "02000001", fragment
=True)
161 if not "long response" in ev
:
162 if "0b5f6166706f766572746370c00c000c01" not in ev
:
163 raise Exception("Unexpected service discovery response contents (Bonjour)")
164 if "496e7465726e6574" not in ev
:
165 raise Exception("Unexpected service discovery response contents (UPnP)")
168 def test_p2p_service_discovery_bonjour(dev
):
169 """P2P service discovery (Bonjour)"""
170 ev
= run_sd(dev
, "00:00:00:00:00:00", "02000101")
171 if "0b5f6166706f766572746370c00c000c01" not in ev
:
172 raise Exception("Unexpected service discovery response contents (Bonjour)")
173 if "045f697070c00c000c01" not in ev
:
174 raise Exception("Unexpected service discovery response contents (Bonjour)")
175 if "496e7465726e6574" in ev
:
176 raise Exception("Unexpected service discovery response contents (UPnP not expected)")
179 def test_p2p_service_discovery_bonjour2(dev
):
180 """P2P service discovery (Bonjour AFS)"""
181 ev
= run_sd(dev
, "00:00:00:00:00:00", "130001010b5f6166706f766572746370c00c000c01")
182 if "0b5f6166706f766572746370c00c000c01" not in ev
:
183 raise Exception("Unexpected service discovery response contents (Bonjour)")
184 if "045f697070c00c000c01" in ev
:
185 raise Exception("Unexpected service discovery response contents (Bonjour mismatching)")
186 if "496e7465726e6574" in ev
:
187 raise Exception("Unexpected service discovery response contents (UPnP not expected)")
190 def test_p2p_service_discovery_bonjour3(dev
):
191 """P2P service discovery (Bonjour AFS - no match)"""
192 ev
= run_sd(dev
, "00:00:00:00:00:00", "130001010b5f6166706f766572746370c00c000c02")
193 if "0300010102" not in ev
:
194 raise Exception("Requested-info-not-available was not indicated")
195 if "0b5f6166706f766572746370c00c000c01" in ev
:
196 raise Exception("Unexpected service discovery response contents (Bonjour)")
197 if "045f697070c00c000c01" in ev
:
198 raise Exception("Unexpected service discovery response contents (Bonjour mismatching)")
199 if "496e7465726e6574" in ev
:
200 raise Exception("Unexpected service discovery response contents (UPnP not expected)")
203 def test_p2p_service_discovery_upnp(dev
):
204 """P2P service discovery (UPnP)"""
205 ev
= run_sd(dev
, "00:00:00:00:00:00", "02000201")
206 if "0b5f6166706f766572746370c00c000c01" in ev
:
207 raise Exception("Unexpected service discovery response contents (Bonjour not expected)")
208 if "496e7465726e6574" not in ev
:
209 raise Exception("Unexpected service discovery response contents (UPnP)")
212 def test_p2p_service_discovery_upnp2(dev
):
213 """P2P service discovery (UPnP using request helper)"""
214 ev
= run_sd(dev
, "00:00:00:00:00:00", "upnp 10 ssdp:all", "0b00020110737364703a616c6c")
215 if "0b5f6166706f766572746370c00c000c01" in ev
:
216 raise Exception("Unexpected service discovery response contents (Bonjour not expected)")
217 if "496e7465726e6574" not in ev
:
218 raise Exception("Unexpected service discovery response contents (UPnP)")
221 def test_p2p_service_discovery_upnp3(dev
):
222 """P2P service discovery (UPnP using request helper - no match)"""
223 ev
= run_sd(dev
, "00:00:00:00:00:00", "upnp 10 ssdp:foo", "0b00020110737364703a666f6f")
224 if "0300020102" not in ev
:
225 raise Exception("Requested-info-not-available was not indicated")
226 if "0b5f6166706f766572746370c00c000c01" in ev
:
227 raise Exception("Unexpected service discovery response contents (Bonjour not expected)")
228 if "496e7465726e6574" in ev
:
229 raise Exception("Unexpected service discovery response contents (UPnP)")
232 def test_p2p_service_discovery_ws(dev
):
233 """P2P service discovery (WS-Discovery)"""
234 ev
= run_sd(dev
, "00:00:00:00:00:00", "02000301")
235 if "0b5f6166706f766572746370c00c000c01" in ev
:
236 raise Exception("Unexpected service discovery response contents (Bonjour not expected)")
237 if "496e7465726e6574" in ev
:
238 raise Exception("Unexpected service discovery response contents (UPnP not expected)")
239 if "0300030101" not in ev
:
240 raise Exception("Unexpected service discovery response contents (WS)")
243 def test_p2p_service_discovery_wfd(dev
):
244 """P2P service discovery (Wi-Fi Display)"""
245 dev
[0].global_request("SET wifi_display 1")
246 ev
= run_sd(dev
, "00:00:00:00:00:00", "02000401")
248 raise Exception("Unexpected response to invalid WFD SD query")
249 dev
[0].global_request("SET wifi_display 0")
250 ev
= run_sd(dev
, "00:00:00:00:00:00", "0300040100")
251 if "0300040101" not in ev
:
252 raise Exception("Unexpected response to WFD SD query (protocol was disabled)")
255 def test_p2p_service_discovery_req_cancel(dev
):
256 """Cancel a P2P service discovery request"""
257 if "FAIL" not in dev
[0].global_request("P2P_SERV_DISC_CANCEL_REQ ab"):
258 raise Exception("Unexpected SD cancel success")
259 if "FAIL" not in dev
[0].global_request("P2P_SERV_DISC_CANCEL_REQ qq"):
260 raise Exception("Unexpected SD cancel success")
261 query
= dev
[0].global_request("P2P_SERV_DISC_REQ " + dev
[1].p2p_dev_addr() + " 02000001")
262 if "OK" not in dev
[0].global_request("P2P_SERV_DISC_CANCEL_REQ " + query
):
263 raise Exception("Unexpected SD cancel failure")
264 query1
= dev
[0].global_request("P2P_SERV_DISC_REQ " + dev
[1].p2p_dev_addr() + " 02000001")
265 query2
= dev
[0].global_request("P2P_SERV_DISC_REQ " + dev
[1].p2p_dev_addr() + " 02000002")
266 query3
= dev
[0].global_request("P2P_SERV_DISC_REQ " + dev
[1].p2p_dev_addr() + " 02000003")
267 if "OK" not in dev
[0].global_request("P2P_SERV_DISC_CANCEL_REQ " + query2
):
268 raise Exception("Unexpected SD cancel failure")
269 if "OK" not in dev
[0].global_request("P2P_SERV_DISC_CANCEL_REQ " + query1
):
270 raise Exception("Unexpected SD cancel failure")
271 if "OK" not in dev
[0].global_request("P2P_SERV_DISC_CANCEL_REQ " + query3
):
272 raise Exception("Unexpected SD cancel failure")
274 query
= dev
[0].global_request("P2P_SERV_DISC_REQ 00:00:00:00:00:00 02000001")
275 if "OK" not in dev
[0].global_request("P2P_SERV_DISC_CANCEL_REQ " + query
):
276 raise Exception("Unexpected SD(broadcast) cancel failure")
279 def test_p2p_service_discovery_go(dev
):
280 """P2P service discovery from GO"""
281 addr0
= dev
[0].p2p_dev_addr()
282 addr1
= dev
[1].p2p_dev_addr()
284 add_bonjour_services(dev
[0])
285 add_upnp_services(dev
[0])
287 dev
[0].p2p_start_go(freq
=2412)
289 dev
[1].global_request("P2P_FLUSH")
290 dev
[1].global_request("P2P_SERV_DISC_REQ " + addr0
+ " 02000001")
291 if not dev
[1].discover_peer(addr0
, social
=True, force_find
=True):
292 raise Exception("Peer " + addr0
+ " not found")
294 ev
= dev
[0].wait_global_event(["P2P-SERV-DISC-REQ"], timeout
=10)
296 raise Exception("Service discovery timed out")
298 raise Exception("Unexpected service discovery request source")
300 ev
= dev
[1].wait_global_event(["P2P-SERV-DISC-RESP"], timeout
=10)
302 raise Exception("Service discovery timed out")
304 raise Exception("Unexpected service discovery response source")
305 if "0b5f6166706f766572746370c00c000c01" not in ev
:
306 raise Exception("Unexpected service discovery response contents (Bonjour)")
307 if "496e7465726e6574" not in ev
:
308 raise Exception("Unexpected service discovery response contents (UPnP)")
309 dev
[1].p2p_stop_find()
311 dev
[0].global_request("P2P_SERVICE_FLUSH")
313 dev
[1].global_request("P2P_FLUSH")
314 dev
[1].global_request("P2P_SERV_DISC_REQ " + addr0
+ " 02000001")
315 if not dev
[1].discover_peer(addr0
, social
=True, force_find
=True):
316 raise Exception("Peer " + addr0
+ " not found")
317 ev
= dev
[0].wait_global_event(["P2P-SERV-DISC-REQ"], timeout
=10)
319 raise Exception("Service discovery timed out")
321 raise Exception("Unexpected service discovery request source")
323 ev
= dev
[1].wait_global_event(["P2P-SERV-DISC-RESP"], timeout
=10)
325 raise Exception("Service discovery timed out")
327 raise Exception("Unexpected service discovery response source")
328 if "0300000101" not in ev
:
329 raise Exception("Unexpected service discovery response contents (Bonjour)")
330 dev
[1].p2p_stop_find()
332 def _test_p2p_service_discovery_external(dev
):
333 addr0
= dev
[0].p2p_dev_addr()
334 addr1
= dev
[1].p2p_dev_addr()
336 if "FAIL" not in dev
[0].global_request("P2P_SERV_DISC_EXTERNAL 2"):
337 raise Exception("Invalid P2P_SERV_DISC_EXTERNAL accepted")
338 if "OK" not in dev
[0].global_request("P2P_SERV_DISC_EXTERNAL 1"):
339 raise Exception("P2P_SERV_DISC_EXTERNAL failed")
341 dev
[1].global_request("P2P_FLUSH")
342 dev
[1].global_request("P2P_SERV_DISC_REQ " + addr0
+ " 02000001")
343 if not dev
[1].discover_peer(addr0
, social
=True, force_find
=True):
344 raise Exception("Peer " + addr0
+ " not found")
346 ev
= dev
[0].wait_global_event(["P2P-SERV-DISC-REQ"], timeout
=10)
348 raise Exception("Service discovery timed out")
350 raise Exception("Unexpected service discovery request source")
353 if "OK" not in dev
[0].global_request("P2P_SERV_DISC_RESP %s %s %s %s" % (arg
[2], arg
[3], arg
[4], resp
)):
354 raise Exception("P2P_SERV_DISC_RESP failed")
356 ev
= dev
[1].wait_global_event(["P2P-SERV-DISC-RESP"], timeout
=15)
358 raise Exception("Service discovery timed out")
360 raise Exception("Unexpected address in SD Response: " + ev
)
361 if ev
.split(' ')[4] != resp
:
362 raise Exception("Unexpected response data SD Response: " + ev
)
363 ver
= ev
.split(' ')[3]
365 dev
[0].global_request("P2P_SERVICE_UPDATE")
367 dev
[1].global_request("P2P_FLUSH")
368 dev
[1].global_request("P2P_SERV_DISC_REQ " + addr0
+ " 02000001")
369 if not dev
[1].discover_peer(addr0
, social
=True, force_find
=True):
370 raise Exception("Peer " + addr0
+ " not found")
372 ev
= dev
[0].wait_global_event(["P2P-SERV-DISC-REQ"], timeout
=10)
374 raise Exception("Service discovery timed out")
376 raise Exception("Unexpected service discovery request source")
379 if "OK" not in dev
[0].global_request("P2P_SERV_DISC_RESP %s %s %s %s" % (arg
[2], arg
[3], arg
[4], resp
)):
380 raise Exception("P2P_SERV_DISC_RESP failed")
382 ev
= dev
[1].wait_global_event(["P2P-SERV-DISC-RESP"], timeout
=15)
384 raise Exception("Service discovery timed out")
386 raise Exception("Unexpected address in SD Response: " + ev
)
387 if ev
.split(' ')[4] != resp
:
388 raise Exception("Unexpected response data SD Response: " + ev
)
389 ver2
= ev
.split(' ')[3]
391 raise Exception("Service list version did not change")
393 for cmd
in [ "%s%s%s%s" % (arg
[2], arg
[3], arg
[4], resp
),
394 "%s %s %s %s" % ("0", arg
[3], arg
[4], resp
),
395 "%s %s %s %s" % (arg
[2], "foo", arg
[4], resp
),
396 "%s %s%s%s" % (arg
[2], arg
[3], arg
[4], resp
),
397 "%s %s %s%s" % (arg
[2], arg
[3], arg
[4], resp
),
398 "%s %s %s %s" % (arg
[2], arg
[3], arg
[4], "12345"),
399 "%s %s %s %s" % (arg
[2], arg
[3], arg
[4], "qq") ]:
400 if "FAIL" not in dev
[0].global_request("P2P_SERV_DISC_RESP " + cmd
):
401 raise Exception("Invalid P2P_SERV_DISC_RESP accepted: " + cmd
)
404 def test_p2p_service_discovery_external(dev
):
405 """P2P service discovery using external response"""
407 _test_p2p_service_discovery_external(dev
)
409 dev
[0].global_request("P2P_SERV_DISC_EXTERNAL 0")
412 def test_p2p_service_discovery_invalid_commands(dev
):
413 """P2P service discovery invalid commands"""
414 for cmd
in [ "bonjour",
423 if "FAIL" not in dev
[0].global_request("P2P_SERVICE_ADD " + cmd
):
424 raise Exception("Invalid P2P_SERVICE_ADD accepted: " + cmd
)
426 for cmd
in [ "bonjour",
433 if "FAIL" not in dev
[0].global_request("P2P_SERVICE_DEL " + cmd
):
434 raise Exception("Invalid P2P_SERVICE_DEL accepted: " + cmd
)
436 def test_p2p_service_discovery_cancel_during_query(dev
):
437 """P2P service discovery and cancel during query"""
439 add_bonjour_services(dev
[i
])
440 add_upnp_services(dev
[i
])
441 add_extra_services(dev
[i
])
444 dev
[2].request("P2P_FLUSH")
445 id1
= dev
[2].request("P2P_SERV_DISC_REQ 00:00:00:00:00:00 02000201")
446 id2
= dev
[2].request("P2P_SERV_DISC_REQ 00:00:00:00:00:00 02000101")
447 dev
[2].p2p_find(social
=True)
448 ev
= dev
[2].wait_global_event(["P2P-DEVICE-FOUND"], timeout
=15)
450 raise Exception("Could not discover peer")
451 if "OK" not in dev
[2].request("P2P_SERV_DISC_CANCEL_REQ " + id1
):
452 raise Exception("Failed to cancel req1")
453 if "OK" not in dev
[2].request("P2P_SERV_DISC_CANCEL_REQ " + id2
):
454 raise Exception("Failed to cancel req2")
455 ev
= dev
[2].wait_global_event(["P2P-SERV-DISC-RESP"], timeout
=3)
456 # we may or may not get a response depending on timing, so ignore the result
457 dev
[2].p2p_stop_find()
458 dev
[1].p2p_stop_find()
459 dev
[0].p2p_stop_find()
461 def get_p2p_state(dev
):
462 res
= dev
.global_request("STATUS")
464 for line
in res
.splitlines():
465 if line
.startswith("p2p_state="):
466 p2p_state
= line
.split('=')[1]
468 if p2p_state
is None:
469 raise Exception("Could not get p2p_state")
473 def test_p2p_service_discovery_peer_not_listening(dev
):
474 """P2P service discovery and peer not listening"""
475 addr0
= dev
[0].p2p_dev_addr()
476 addr1
= dev
[1].p2p_dev_addr()
477 add_bonjour_services(dev
[0])
478 add_upnp_services(dev
[0])
480 dev
[1].global_request("P2P_FIND 1 type=social")
481 ev
= dev
[1].wait_global_event(["P2P-DEVICE-FOUND"], timeout
=4)
483 raise Exception("Peer not found")
484 dev
[0].p2p_stop_find()
485 ev
= dev
[1].wait_event(["CTRL-EVENT-SCAN-STARTED"], timeout
=1)
486 ev
= dev
[1].wait_event(["CTRL-EVENT-SCAN-STARTED"], timeout
=1)
488 dev
[1].request("P2P_SERV_DISC_REQ " + addr0
+ " 02000001")
489 ev
= dev
[0].wait_global_event(["P2P-SERV-DISC-REQ"], timeout
=1)
491 raise Exception("Service discovery request unexpectedly received")
492 ev
= dev
[1].wait_global_event(["P2P-FIND-STOPPED", "P2P-SERV-DISC-RESP"],
495 raise Exception("P2P-FIND-STOPPED event timed out")
496 if "P2P-SERV-DISC-RESP" in ev
:
497 raise Exception("Unexpected SD response")
498 p2p_state
= get_p2p_state(dev
[1])
499 if p2p_state
!= "IDLE":
500 raise Exception("Unexpected p2p_state after P2P_FIND timeout: " + p2p_state
)
503 def test_p2p_service_discovery_peer_not_listening2(dev
):
504 """P2P service discovery and peer not listening"""
505 addr0
= dev
[0].p2p_dev_addr()
506 addr1
= dev
[1].p2p_dev_addr()
507 add_bonjour_services(dev
[0])
508 add_upnp_services(dev
[0])
510 dev
[1].global_request("P2P_FIND type=social")
511 ev
= dev
[1].wait_global_event(["P2P-DEVICE-FOUND"], timeout
=10)
513 raise Exception("Peer not found")
514 dev
[0].p2p_stop_find()
516 dev
[1].request("P2P_SERV_DISC_REQ " + addr0
+ " 02000001")
517 ev
= dev
[0].wait_global_event(["P2P-SERV-DISC-REQ"], timeout
=0.5)
519 raise Exception("Service discovery request unexpectedly received")
520 dev
[1].p2p_stop_find()
521 ev
= dev
[1].wait_global_event(["P2P-FIND-STOPPED", "P2P-SERV-DISC-RESP"],
524 raise Exception("P2P-FIND-STOPPED event timed out")
525 if "P2P-SERV-DISC-RESP" in ev
:
526 raise Exception("Unexpected SD response")
527 p2p_state
= get_p2p_state(dev
[1])
528 if p2p_state
!= "IDLE":
529 raise Exception("Unexpected p2p_state after P2P_FIND timeout: " + p2p_state
)