tests: Delayed M1+M3 retransmission and zero TK
Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
59cbfa7c86
commit
4bb2272bab
2 changed files with 82 additions and 49 deletions
|
@ -13,7 +13,7 @@ from wpasupplicant import WpaSupplicant
|
||||||
|
|
||||||
def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False,
|
def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False,
|
||||||
ifname1=None, ifname2=None, config=True, timeout=5,
|
ifname1=None, ifname2=None, config=True, timeout=5,
|
||||||
multicast_to_unicast=False):
|
multicast_to_unicast=False, broadcast=True):
|
||||||
addr1 = dev1.own_addr()
|
addr1 = dev1.own_addr()
|
||||||
if not dev1group and isinstance(dev1, WpaSupplicant):
|
if not dev1group and isinstance(dev1, WpaSupplicant):
|
||||||
addr1 = dev1.get_driver_status_field('addr')
|
addr1 = dev1.get_driver_status_field('addr')
|
||||||
|
@ -66,26 +66,27 @@ def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False,
|
||||||
if "DATA-TEST-RX {} {}".format(addr2, addr1) not in ev:
|
if "DATA-TEST-RX {} {}".format(addr2, addr1) not in ev:
|
||||||
raise Exception("Unexpected dev1->dev2 unicast data result")
|
raise Exception("Unexpected dev1->dev2 unicast data result")
|
||||||
|
|
||||||
cmd = "DATA_TEST_TX ff:ff:ff:ff:ff:ff {} {}".format(addr1, tos)
|
if broadcast:
|
||||||
for i in xrange(broadcast_retry_c):
|
cmd = "DATA_TEST_TX ff:ff:ff:ff:ff:ff {} {}".format(addr1, tos)
|
||||||
try:
|
for i in xrange(broadcast_retry_c):
|
||||||
if dev1group:
|
try:
|
||||||
dev1.group_request(cmd)
|
if dev1group:
|
||||||
else:
|
dev1.group_request(cmd)
|
||||||
dev1.request(cmd)
|
else:
|
||||||
if dev2group:
|
dev1.request(cmd)
|
||||||
ev = dev2.wait_group_event(["DATA-TEST-RX"],
|
if dev2group:
|
||||||
timeout=timeout)
|
ev = dev2.wait_group_event(["DATA-TEST-RX"],
|
||||||
else:
|
timeout=timeout)
|
||||||
ev = dev2.wait_event(["DATA-TEST-RX"], timeout=timeout)
|
else:
|
||||||
if ev is None:
|
ev = dev2.wait_event(["DATA-TEST-RX"], timeout=timeout)
|
||||||
raise Exception("dev1->dev2 broadcast data delivery failed")
|
if ev is None:
|
||||||
if "DATA-TEST-RX ff:ff:ff:ff:ff:ff {}".format(addr1) not in ev:
|
raise Exception("dev1->dev2 broadcast data delivery failed")
|
||||||
raise Exception("Unexpected dev1->dev2 broadcast data result")
|
if "DATA-TEST-RX ff:ff:ff:ff:ff:ff {}".format(addr1) not in ev:
|
||||||
break
|
raise Exception("Unexpected dev1->dev2 broadcast data result")
|
||||||
except Exception as e:
|
break
|
||||||
if i == broadcast_retry_c - 1:
|
except Exception as e:
|
||||||
raise
|
if i == broadcast_retry_c - 1:
|
||||||
|
raise
|
||||||
|
|
||||||
cmd = "DATA_TEST_TX {} {} {}".format(addr1, addr2, tos)
|
cmd = "DATA_TEST_TX {} {} {}".format(addr1, addr2, tos)
|
||||||
if dev2group:
|
if dev2group:
|
||||||
|
@ -101,32 +102,33 @@ def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False,
|
||||||
if "DATA-TEST-RX {} {}".format(addr1, addr2) not in ev:
|
if "DATA-TEST-RX {} {}".format(addr1, addr2) not in ev:
|
||||||
raise Exception("Unexpected dev2->dev1 unicast data result")
|
raise Exception("Unexpected dev2->dev1 unicast data result")
|
||||||
|
|
||||||
cmd = "DATA_TEST_TX ff:ff:ff:ff:ff:ff {} {}".format(addr2, tos)
|
if broadcast:
|
||||||
for i in xrange(broadcast_retry_c):
|
cmd = "DATA_TEST_TX ff:ff:ff:ff:ff:ff {} {}".format(addr2, tos)
|
||||||
try:
|
for i in xrange(broadcast_retry_c):
|
||||||
if dev2group:
|
try:
|
||||||
dev2.group_request(cmd)
|
if dev2group:
|
||||||
else:
|
dev2.group_request(cmd)
|
||||||
dev2.request(cmd)
|
else:
|
||||||
if dev1group:
|
dev2.request(cmd)
|
||||||
ev = dev1.wait_group_event(["DATA-TEST-RX"],
|
if dev1group:
|
||||||
timeout=timeout)
|
ev = dev1.wait_group_event(["DATA-TEST-RX"],
|
||||||
else:
|
timeout=timeout)
|
||||||
ev = dev1.wait_event(["DATA-TEST-RX"], timeout=timeout)
|
else:
|
||||||
if ev is None:
|
ev = dev1.wait_event(["DATA-TEST-RX"], timeout=timeout)
|
||||||
raise Exception("dev2->dev1 broadcast data delivery failed")
|
if ev is None:
|
||||||
if multicast_to_unicast:
|
raise Exception("dev2->dev1 broadcast data delivery failed")
|
||||||
if "DATA-TEST-RX ff:ff:ff:ff:ff:ff {}".format(addr2) in ev:
|
if multicast_to_unicast:
|
||||||
raise Exception("Unexpected dev2->dev1 broadcast data result: multicast to unicast conversion missing")
|
if "DATA-TEST-RX ff:ff:ff:ff:ff:ff {}".format(addr2) in ev:
|
||||||
if "DATA-TEST-RX {} {}".format(addr1, addr2) not in ev:
|
raise Exception("Unexpected dev2->dev1 broadcast data result: multicast to unicast conversion missing")
|
||||||
raise Exception("Unexpected dev2->dev1 broadcast data result (multicast to unicast enabled)")
|
if "DATA-TEST-RX {} {}".format(addr1, addr2) not in ev:
|
||||||
else:
|
raise Exception("Unexpected dev2->dev1 broadcast data result (multicast to unicast enabled)")
|
||||||
if "DATA-TEST-RX ff:ff:ff:ff:ff:ff {}".format(addr2) not in ev:
|
else:
|
||||||
raise Exception("Unexpected dev2->dev1 broadcast data result")
|
if "DATA-TEST-RX ff:ff:ff:ff:ff:ff {}".format(addr2) not in ev:
|
||||||
break
|
raise Exception("Unexpected dev2->dev1 broadcast data result")
|
||||||
except Exception as e:
|
break
|
||||||
if i == broadcast_retry_c - 1:
|
except Exception as e:
|
||||||
raise
|
if i == broadcast_retry_c - 1:
|
||||||
|
raise
|
||||||
finally:
|
finally:
|
||||||
if config:
|
if config:
|
||||||
if dev1group:
|
if dev1group:
|
||||||
|
@ -141,7 +143,8 @@ def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False,
|
||||||
def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1,
|
def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1,
|
||||||
dev1group=False, dev2group=False,
|
dev1group=False, dev2group=False,
|
||||||
ifname1=None, ifname2=None, config=True, timeout=5,
|
ifname1=None, ifname2=None, config=True, timeout=5,
|
||||||
multicast_to_unicast=False, success_expected=True):
|
multicast_to_unicast=False, success_expected=True,
|
||||||
|
broadcast=True):
|
||||||
if dscp:
|
if dscp:
|
||||||
tos = dscp << 2
|
tos = dscp << 2
|
||||||
if not tos:
|
if not tos:
|
||||||
|
@ -154,7 +157,8 @@ def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1,
|
||||||
run_connectivity_test(dev1, dev2, tos, dev1group, dev2group,
|
run_connectivity_test(dev1, dev2, tos, dev1group, dev2group,
|
||||||
ifname1, ifname2, config=config,
|
ifname1, ifname2, config=config,
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
multicast_to_unicast=multicast_to_unicast)
|
multicast_to_unicast=multicast_to_unicast,
|
||||||
|
broadcast=broadcast)
|
||||||
success = True
|
success = True
|
||||||
break
|
break
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
|
|
@ -558,3 +558,32 @@ def run_ap_wpa2_delayed_group_m1_retransmission(dev, apdev):
|
||||||
a = int(after[i], 16)
|
a = int(after[i], 16)
|
||||||
if a < b:
|
if a < b:
|
||||||
raise Exception("RX counter decreased: idx=%d before=%d after=%d" % (i, b, a))
|
raise Exception("RX counter decreased: idx=%d before=%d after=%d" % (i, b, a))
|
||||||
|
|
||||||
|
def test_ap_wpa2_delayed_m1_m3_zero_tk(dev, apdev):
|
||||||
|
"""Delayed M1+M3 retransmission and zero TK"""
|
||||||
|
params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678")
|
||||||
|
hapd = hostapd.add_ap(apdev[0], params)
|
||||||
|
|
||||||
|
Wlantest.setup(hapd)
|
||||||
|
wt = Wlantest()
|
||||||
|
wt.flush()
|
||||||
|
wt.add_passphrase("12345678")
|
||||||
|
|
||||||
|
dev[0].connect("test-wpa2-psk", psk="12345678", scan_freq="2412")
|
||||||
|
|
||||||
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
||||||
|
addr = dev[0].own_addr()
|
||||||
|
if "OK" not in hapd.request("RESEND_M1 " + addr + " change-anonce"):
|
||||||
|
raise Exception("RESEND_M1 failed")
|
||||||
|
if "OK" not in hapd.request("RESEND_M1 " + addr):
|
||||||
|
raise Exception("RESEND_M1 failed")
|
||||||
|
if "OK" not in hapd.request("RESEND_M3 " + addr):
|
||||||
|
raise Exception("RESEND_M3 failed")
|
||||||
|
|
||||||
|
if "OK" not in hapd.request("SET_KEY 3 %s %d %d %s %s" % (addr, 0, 1, 6*"00", 16*"00")):
|
||||||
|
raise Exception("SET_KEY failed")
|
||||||
|
time.sleep(0.1)
|
||||||
|
hwsim_utils.test_connectivity(dev[0], hapd, timeout=1, broadcast=False,
|
||||||
|
success_expected=False)
|
||||||
|
dev[0].request("DISCONNECT")
|
||||||
|
dev[0].wait_disconnected()
|
||||||
|
|
Loading…
Reference in a new issue