From b43ac5d5ab867623f302d07c3c968462be122dc2 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 10 Oct 2014 18:03:38 +0300 Subject: [PATCH] tests: P2P group formation with WSC_Done missing This verifies that GO is able to complete group formation even if the P2P Client does not send WSC_Done message (or that message is dropped for any reason) in case the P2P Client completes 4-way handshake successfully. Signed-off-by: Jouni Malinen --- tests/hwsim/test_p2p_grpform.py | 45 +++++++++++++++++++++++++++++++++ tests/hwsim/wpasupplicant.py | 4 ++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/tests/hwsim/test_p2p_grpform.py b/tests/hwsim/test_p2p_grpform.py index 73b35e272..97c2f5c4f 100644 --- a/tests/hwsim/test_p2p_grpform.py +++ b/tests/hwsim/test_p2p_grpform.py @@ -721,3 +721,48 @@ def test_grpform_cred_ready_timeout(dev, apdev, params): logger.info("GO Negotiation wait time: {} seconds".format(end - start)) if end - start < 120: raise Exception("Too short GO Negotiation wait time: {}".format(end - start)) + +def test_grpform_no_wsc_done(dev): + """P2P group formation with WSC-Done not sent""" + addr0 = dev[0].p2p_dev_addr() + addr1 = dev[1].p2p_dev_addr() + + for i in range(0, 2): + dev[0].request("SET ext_eapol_frame_io 1") + dev[1].request("SET ext_eapol_frame_io 1") + dev[0].p2p_listen() + dev[1].p2p_go_neg_auth(addr0, "12345670", "display", 0) + dev[1].p2p_listen() + dev[0].p2p_go_neg_init(addr1, "12345670", "enter", timeout=20, + go_intent=15, wait_group=False) + + while True: + ev = dev[0].wait_event(["EAPOL-TX"], timeout=15) + if ev is None: + raise Exception("Timeout on EAPOL-TX from GO") + res = dev[1].request("EAPOL_RX " + addr0 + " " + ev.split(' ')[2]) + if "OK" not in res: + raise Exception("EAPOL_RX failed") + ev = dev[1].wait_event(["EAPOL-TX"], timeout=15) + if ev is None: + raise Exception("Timeout on EAPOL-TX from P2P Client") + msg = ev.split(' ')[2] + if msg[46:56] == "102200010f": + logger.info("Drop WSC_Done") + dev[0].request("SET ext_eapol_frame_io 0") + dev[1].request("SET ext_eapol_frame_io 0") + # Fake EAP-Failure to complete session on the client + id = msg[10:12] + dev[1].request("EAPOL_RX " + addr0 + " 0300000404" + id + "0004") + break + res = dev[0].request("EAPOL_RX " + addr1 + " " + msg) + if "OK" not in res: + raise Exception("EAPOL_RX failed") + + ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=15) + if ev is None: + raise Exception("Group formation timed out on GO") + ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=15) + if ev is None: + raise Exception("Group formation timed out on P2P Client") + dev[0].remove_group() diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index fcb99f169..44efc1372 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -484,7 +484,7 @@ class WpaSupplicant: self.dump_monitor() return self.group_form_result(ev, expect_failure, go_neg_res) - def p2p_go_neg_init(self, peer, pin, method, timeout=0, go_intent=None, expect_failure=False, persistent=False, persistent_id=None, freq=None, provdisc=False): + def p2p_go_neg_init(self, peer, pin, method, timeout=0, go_intent=None, expect_failure=False, persistent=False, persistent_id=None, freq=None, provdisc=False, wait_group=True): if not self.discover_peer(peer): raise Exception("Peer " + peer + " not found") self.dump_monitor() @@ -514,6 +514,8 @@ class WpaSupplicant: return None raise Exception("Group formation timed out") if "P2P-GO-NEG-SUCCESS" in ev: + if not wait_group: + return ev go_neg_res = ev ev = self.wait_global_event(["P2P-GROUP-STARTED"], timeout) if ev is None: