tests: Verify multicast_to_unicast operation

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
This commit is contained in:
Michael Braun 2016-10-31 14:58:09 +01:00 committed by Jouni Malinen
parent 34f7c699a6
commit 80fe420ab2
2 changed files with 37 additions and 5 deletions

View file

@ -12,7 +12,8 @@ logger = logging.getLogger()
from wpasupplicant import WpaSupplicant 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):
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')
@ -114,8 +115,14 @@ def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False,
ev = dev1.wait_event(["DATA-TEST-RX"], timeout=timeout) ev = dev1.wait_event(["DATA-TEST-RX"], timeout=timeout)
if ev is None: if ev is None:
raise Exception("dev2->dev1 broadcast data delivery failed") raise Exception("dev2->dev1 broadcast data delivery failed")
if "DATA-TEST-RX ff:ff:ff:ff:ff:ff {}".format(addr2) not in ev: if multicast_to_unicast:
raise Exception("Unexpected dev2->dev1 broadcast data result") if "DATA-TEST-RX ff:ff:ff:ff:ff:ff {}".format(addr2) in ev:
raise Exception("Unexpected dev2->dev1 broadcast data result: multicast to unicast conversion missing")
if "DATA-TEST-RX {} {}".format(addr1, addr2) not in ev:
raise Exception("Unexpected dev2->dev1 broadcast data result (multicast to unicast enabled)")
else:
if "DATA-TEST-RX ff:ff:ff:ff:ff:ff {}".format(addr2) not in ev:
raise Exception("Unexpected dev2->dev1 broadcast data result")
break break
except Exception as e: except Exception as e:
if i == broadcast_retry_c - 1: if i == broadcast_retry_c - 1:
@ -133,7 +140,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):
if dscp: if dscp:
tos = dscp << 2 tos = dscp << 2
if not tos: if not tos:
@ -145,7 +153,8 @@ def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1,
try: try:
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)
success = True success = True
break break
except Exception, e: except Exception, e:

View file

@ -608,3 +608,26 @@ def test_ap_open_drv_fail(dev, apdev):
wait_connect=False) wait_connect=False)
wait_fail_trigger(dev[0], "GET_FAIL") wait_fail_trigger(dev[0], "GET_FAIL")
dev[0].request("REMOVE_NETWORK all") dev[0].request("REMOVE_NETWORK all")
def run_multicast_to_unicast(dev, apdev, convert):
params = { "ssid": "open" }
params["multicast_to_unicast"] = "1" if convert else "0"
hapd = hostapd.add_ap(apdev[0], params)
dev[0].scan_for_bss(hapd.own_addr(), freq=2412)
dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5)
if ev is None:
raise Exception("No connection event received from hostapd")
hwsim_utils.test_connectivity(dev[0], hapd, multicast_to_unicast=convert)
dev[0].request("DISCONNECT")
ev = hapd.wait_event([ "AP-STA-DISCONNECTED" ], timeout=5)
if ev is None:
raise Exception("No disconnection event received from hostapd")
def test_ap_open_multicast_to_unicast(dev, apdev):
"""Multicast-to-unicast conversion enabled"""
run_multicast_to_unicast(dev, apdev, True)
def test_ap_open_multicast_to_unicast_disabled(dev, apdev):
"""Multicast-to-unicast conversion disabled"""
run_multicast_to_unicast(dev, apdev, False)