From 80fe420ab264da8a8a03c0b7bbdbf7996de21fec Mon Sep 17 00:00:00 2001 From: Michael Braun Date: Mon, 31 Oct 2016 14:58:09 +0100 Subject: [PATCH] tests: Verify multicast_to_unicast operation Signed-off-by: Michael Braun --- tests/hwsim/hwsim_utils.py | 19 ++++++++++++++----- tests/hwsim/test_ap_open.py | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/tests/hwsim/hwsim_utils.py b/tests/hwsim/hwsim_utils.py index 3594585c9..b2a5814ab 100644 --- a/tests/hwsim/hwsim_utils.py +++ b/tests/hwsim/hwsim_utils.py @@ -12,7 +12,8 @@ logger = logging.getLogger() from wpasupplicant import WpaSupplicant 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() if not dev1group and isinstance(dev1, WpaSupplicant): 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) if ev is None: raise Exception("dev2->dev1 broadcast data delivery failed") - if "DATA-TEST-RX ff:ff:ff:ff:ff:ff {}".format(addr2) not in ev: - raise Exception("Unexpected dev2->dev1 broadcast data result") + if multicast_to_unicast: + 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 except Exception as e: 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, 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: tos = dscp << 2 if not tos: @@ -145,7 +153,8 @@ def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1, try: run_connectivity_test(dev1, dev2, tos, dev1group, dev2group, ifname1, ifname2, config=config, - timeout=timeout) + timeout=timeout, + multicast_to_unicast=multicast_to_unicast) success = True break except Exception, e: diff --git a/tests/hwsim/test_ap_open.py b/tests/hwsim/test_ap_open.py index 409d413e1..01cd5f87a 100644 --- a/tests/hwsim/test_ap_open.py +++ b/tests/hwsim/test_ap_open.py @@ -608,3 +608,26 @@ def test_ap_open_drv_fail(dev, apdev): wait_connect=False) wait_fail_trigger(dev[0], "GET_FAIL") 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)