From fdf22fb2c72e67c65feafd6b4b7fcbfe4f57f19a Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 15:00:21 +0200 Subject: [PATCH 001/453] PPM-30: Changes to bf plugins for docker-compose Signed-off-by: pablo --- .../devices/prplmesh_base.py | 130 +++++++++++++----- 1 file changed, 92 insertions(+), 38 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py index 700c5c2863..79eea79ea7 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py @@ -3,30 +3,95 @@ # This code is subject to the terms of the BSD+Patent license. # See LICENSE file for more details. -import pexpect - -from boardfarm.devices import linux - - -class CommandError(Exception): - """Raised on failed execution""" - pass - - -class PrplMeshBase(linux.LinuxDevice): - """PrplMesh abstract device.""" - - def _run_shell_cmd(self, cmd: str = "", args: list = None, timeout: int = 30): - """Wrapper that executes command with specified args on host machine and logs output.""" - - res, exitstatus = pexpect.run(cmd, args=args, timeout=timeout, encoding="utf-8", - withexitstatus=1) - entry = " ".join((cmd, " ".join(args))) - if exitstatus != 0: - raise CommandError("Error executing {}:\n{}".format(entry, res)) - - self.log_calls += entry - self.log += "$ " + entry + "\r\n" + res +import os +import time + +import boardfarm +from environment import ALEntityDocker, _get_bridge_interface +from .prplmesh_base import PrplMeshBase +from sniffer import Sniffer + +rootdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..')) + + +class PrplMeshCompose(PrplMeshBase): + """Dockerized prplMesh device.""" + + model = ("prplmesh_compose") + agent_entity = None + controller_entity = None + + def __init__(self, *args, **kwargs): + self.args = args + self.kwargs = kwargs + + config = kwargs.get("config", kwargs) + + # List of device's consoles test can interact with + self.consoles = [self] + + # Getting unic ID to distinguish devices and network they belong to + self.unique_id = os.getenv("RUN_ID") + self.user_id = os.getenv("SUDO_USER", os.getenv("USER", "")) + + self.name = "-".join((config.get("name", "prplmesh_compose"), self.unique_id)) + print('config.get("name") {}'.format(config.get("name"))) + # self.name = config.get("name") + self.role = config.get("role", "agent") + self.cleanup_cmd = config.get("cleanup_cmd", None) + self.conn_cmd = config.get("conn_cmd", None) + self.delay = config.get("delay", 7) + self.docker_network = "boardfarm-ci_default" + + if self.role == "controller": + self._docker_compose(["-d", "--name", self.name, "controller"], + "run", "start-controller") + time.sleep(self.delay) + self.controller_entity = \ + ALEntityDocker(self.name, is_controller=True, compose=True) + else: + self._docker_compose(["-d", "--name", self.name, "agent"], + "run", "start-agent") + time.sleep(self.delay) + self.agent_entity = ALEntityDocker(self.name, is_controller=False, compose=True) + + self.wired_sniffer = Sniffer(_get_bridge_interface(self.docker_network), + boardfarm.config.output_dir) + self.check_status() + + def _docker_compose(self, args, parameter=None, start=None): + print('_docker_compose: args {}'.format(args)) + yml_path = "tools/docker/boardfarm-ci/docker-compose.yml" + full_args = ["-f", os.path.join(rootdir, yml_path)] + if parameter == "run": + log_path = os.path.join(rootdir, "logs/{}".format(self.name)) + if not os.path.exists(log_path): + os.mkdir(log_path) + + pipeline_id = os.getenv('CI_PIPELINE_ID') + if pipeline_id is None or pipeline_id == 'latest': + vol = '{}:/tmp/{}/beerocks/logs'.format(log_path, self.user_id) + else: + vol = '{}:/tmp/beerocks/logs'.format(log_path) + + full_args += ["run", "--rm", "-v", vol] + # full_args += ["--entrypoint", entrypoint + ' ' + start] + full_args += args + + print('_docker_compose: {}'.format(' '.join(full_args))) + # os.environ['CURRENT_UID'] = '1000:998' + if os.getenv('CI_PIPELINE_ID') is None: + print('Setting CI_PIPELINE_ID "latest"') + os.environ['CI_PIPELINE_ID'] = 'latest' + self._run_shell_cmd("/usr/local/bin/docker-compose", + full_args, env=os.environ) + else: + self._run_shell_cmd("/usr/local/bin/docker-compose", full_args) + + def __del__(self): + # self._docker_compose(["stop", self.name]) + self._run_shell_cmd("docker", ["stop", self.name]) + self._run_shell_cmd("docker", ["container", "rm", "-f", self.name]) def check_status(self): """Method required by boardfarm. @@ -34,25 +99,14 @@ def check_status(self): It is used by boardfarm to indicate that spawned device instance is ready for test and also after test - to insure that device still operational. """ - pass - - def close(self): - """Method required by boardfarm. - - Purpose is to close connection to device's consoles. - """ + # self._run_shell_cmd(os.path.join(rootdir, "tools", "docker", "test.sh"), + # ["-v", "-n", "controller"]) pass def isalive(self): """Method required by boardfarm. States that device is operational and its consoles are accessible. - """ - pass - - def touch(self): - """Method required by boardfarm. - Purpose is to keep consoles active, so they don't disconnect for long running activities. """ - pass + return True From 5f6d2f4226596ef68d9ee05e184def04fd25e576 Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 15:04:25 +0200 Subject: [PATCH 002/453] PPM-30: Changes on class ALEntityDocker for compose Use directly the hostname instead of querying for the ip Signed-off-by: pablo --- tests/environment.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/environment.py b/tests/environment.py index 7da67bb6b0..888ff0fe71 100644 --- a/tests/environment.py +++ b/tests/environment.py @@ -191,6 +191,9 @@ def _docker_wait_for_log(container: str, programs: [str], regex: str, start_line timeout: float) -> bool: def logfilename(program): logfilename = os.path.join(rootdir, 'logs', container, 'beerocks_{}.log'.format(program)) + + print(' --- logfilename: {}'.format(logfilename)) + # WSL doesn't support symlinks on NTFS, so resolve the symlink manually if on_wsl: logfilename = os.path.join( @@ -249,9 +252,9 @@ class ALEntityDocker(ALEntity): The entity is defined from the name of the container, the rest is derived from that. ''' - # NOTE: name arg can be also extracted from the device class itself, but test_flows.py - # don't have it. We can remove this arg as soon, as we drop test_flows.py - def __init__(self, name: str, device: None = None, is_controller: bool = False): + def __init__(self, name: str, device: None = None, is_controller: bool = False, + compose: bool = False): + self.name = name self.bridge_name = 'br-lan' if device: @@ -268,16 +271,19 @@ def __init__(self, name: str, device: None = None, is_controller: bool = False): config_file.read()).group('port') # On WSL, connect to the locally exposed container port - if on_wsl: - published_port_output = subprocess.check_output( - ["docker", "port", name, ucc_port]).decode('utf-8').split(":") - device_ip = published_port_output[0] - ucc_port = int(published_port_output[1]) + if not compose: + if on_wsl: + published_port_output = subprocess.check_output( + ["docker", "port", name, ucc_port]).decode('utf-8').split(":") + device_ip = published_port_output[0] + ucc_port = int(published_port_output[1]) + else: + device_ip_output = self.command( + 'ip', '-f', 'inet', 'addr', 'show', self.bridge_name) + device_ip = re.search( + r'inet (?P[0-9.]+)', device_ip_output.decode('utf-8')).group('ip') else: - device_ip_output = self.command( - 'ip', '-f', 'inet', 'addr', 'show', self.bridge_name) - device_ip = re.search(r'inet (?P[0-9.]+)', - device_ip_output.decode('utf-8')).group('ip') + device_ip = name ucc_socket = UCCSocket(device_ip, ucc_port) mac = ucc_socket.dev_get_parameter('ALid') From 6ca354d77c5c7951c25f48a1f2e04a812873955b Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 15:06:16 +0200 Subject: [PATCH 003/453] PPM-30: Define test entrypoint and json config Entrypoint calls the json for "in compose" tests Signed-off-by: pablo --- .../prplmesh_config_compose.json | 15 +++++++++++++++ tests/run_bf_compose.sh | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config_compose.json create mode 100755 tests/run_bf_compose.sh diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config_compose.json b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config_compose.json new file mode 100644 index 0000000000..dbd3897cb8 --- /dev/null +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config_compose.json @@ -0,0 +1,15 @@ +{ + "prplmesh_docker": { + "name": "dockerized_device", + "board_type": "prplmesh_compose", + "role": "controller", + "conn_cmd": "", + "devices": [ + { + "name": "repeater1", + "type": "prplmesh_compose", + "conn_cmd": "" + } + ] + } +} diff --git a/tests/run_bf_compose.sh b/tests/run_bf_compose.sh new file mode 100755 index 0000000000..365e3a7671 --- /dev/null +++ b/tests/run_bf_compose.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# SPDX-License-Identifier: BSD-2-Clause-Patent +# SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) +# This code is subject to the terms of the BSD+Patent license. +# See LICENSE file for more details. + +scriptdir=$(dirname "$(readlink -f "${0}")") +bf_plugins_dir=${scriptdir}/boardfarm_plugins + +if [ -n "${PYTHONPATH}" ]; then + PYTHONPATH="${bf_plugins_dir}:${scriptdir}:${PYTHONPATH}" +else + PYTHONPATH="${bf_plugins_dir}:${scriptdir}" +fi +echo "$PYTHONPATH" +export PYTHONPATH + +exec bft -c "${bf_plugins_dir}"/boardfarm_prplmesh/prplmesh_config_compose.json -n prplmesh_docker -x test_flows From 53c28f1541437ffb8e7a5dc4f738ede5aed9b842 Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 15:10:11 +0200 Subject: [PATCH 004/453] PPM-30: Dockerfile and docker-compose.yml Dockerfile to create boardfarm docker image and docker-compose.yml with the configuration for boardfarm, controller and extender Signed-off-by: pablo --- tools/docker/boardfarm-ci/Dockerfile | 30 +++------- tools/docker/boardfarm-ci/docker-compose.yml | 60 ++++++++++++++++++++ 2 files changed, 69 insertions(+), 21 deletions(-) create mode 100644 tools/docker/boardfarm-ci/docker-compose.yml diff --git a/tools/docker/boardfarm-ci/Dockerfile b/tools/docker/boardfarm-ci/Dockerfile index 67fd3ed294..a5d2979de6 100644 --- a/tools/docker/boardfarm-ci/Dockerfile +++ b/tools/docker/boardfarm-ci/Dockerfile @@ -1,41 +1,29 @@ FROM python:3.8-slim-buster +# FROM tiangolo/docker-with-compose RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - apt-transport-https \ - ca-certificates curl \ - curl \ - gcc \ - git \ - gnupg \ - gnupg-agent \ - libsnmp-dev \ - netcat \ - software-properties-common \ - wireshark-common \ - && rm -rf /var/lib/apt/lists/* +&& apt-get install gcc libsnmp-dev -y \ +&& apt-get clean COPY requirements.txt /app/requirements.txt WORKDIR app RUN pip3 install -r requirements.txt -# TODO: what needs this? -#RUN pip3 install jsonschema distro +RUN apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y +RUN apt-get install curl -y RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - docker-ce \ - docker-ce-cli \ - containerd.io \ - && rm -rf /var/lib/apt/lists/* - +&& apt-get install docker-ce docker-ce-cli containerd.io -y RUN curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose RUN chmod 755 /usr/local/bin/docker-compose +RUN DEBIAN_FRONTEND=noninteractive apt-get install wireshark-common -y +# VOLUME "/home/pablo/assia/prpl/git" +# ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] RUN git clone https://github.com/mattsm/boardfarm.git \ && cd boardfarm \ && git checkout 100521fde1fb67536682cafecc2f91a6e2e8a6f8 \ diff --git a/tools/docker/boardfarm-ci/docker-compose.yml b/tools/docker/boardfarm-ci/docker-compose.yml new file mode 100644 index 0000000000..1f50b9cc75 --- /dev/null +++ b/tools/docker/boardfarm-ci/docker-compose.yml @@ -0,0 +1,60 @@ +version: '3' +services: + # Controller and agent are run from inside the boardfarm container + controller: + image: registry.gitlab.com/prpl-foundation/prplmesh/prplmesh-runner:${CI_PIPELINE_ID} + privileged: true # For the creation of the bridge to work + container_name: controller + environment: + - USER + - INSTALL_DIR=${FINAL_ROOT_DIR}/build/install + - ROOT_DIR=${FINAL_ROOT_DIR} + - CURRENT_ID + - CI_PIPELINE_ID + expose: + - "5000" + - "8002" + volumes: + - "$ROOT_DIR:${FINAL_ROOT_DIR}" + entrypoint: ["/root/entrypoint.sh", "/usr/bin/start-controller-agent"] + + agent: + image: registry.gitlab.com/prpl-foundation/prplmesh/prplmesh-runner:${CI_PIPELINE_ID} + privileged: true + container_name: agent + environment: + - USER + - INSTALL_DIR=${FINAL_ROOT_DIR}/build/install + - ROOT_DIR=${FINAL_ROOT_DIR} + # /builds/prpl-foundation/prplMesh + - CURRENT_ID + - CI_PIPELINE_ID + expose: + - "5000" + - "8002" + volumes: + - "$ROOT_DIR:${FINAL_ROOT_DIR}" + entrypoint: ["/root/entrypoint.sh", "/usr/bin/start-agent"] + + # Boardfarm image is launched from dctest.py, TARGET_DIR refers to the + # path inside the controller, will be referred as $ROOT_DIR inside + boardfarm: + build: . + privileged: true + container_name: boardfarm + environment: + - USER + - ROOT_DIR + - CURRENT_ID + - RUN_ID + - CI_PIPELINE_ID + - FINAL_ROOT_DIR + ports: + - "5000:5000" + volumes: + - "$ROOT_DIR:$ROOT_DIR" + - "/var/run/docker:/var/run/docker" + - "/var/run/docker.sock:/var/run/docker.sock" + user: ${CURRENT_UID} + working_dir: $ROOT_DIR/tests + entrypoint: ["bash", "run_bf_compose.sh"] From 14b69869f9d2a2d60c755dc5755951a35ef74bf4 Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 15:11:33 +0200 Subject: [PATCH 005/453] PPM-30: dctest.py script to wrap docker-compose It wraps docker-compose tests - Verifies versions of docker and docker-compose - Creates and launches boardfarm image with the correct environment variables - Cleans images after building - Returns value from boardfarm process inside the image Signed-off-by: pablo --- dctest.py | 255 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100755 dctest.py diff --git a/dctest.py b/dctest.py new file mode 100755 index 0000000000..3855209703 --- /dev/null +++ b/dctest.py @@ -0,0 +1,255 @@ +#!/usr/bin/env python3 +# +# Launch the test suite using docker and docker-compose. This script wraps +# the creation of the bridge(s) to be able to connect external devices with +# the docker network, launching the service for boardfarm. +# +# As this script is run outside containers, it does not use anything apart +# from Python 3.5 (will work on later versions but only uses 3.5 features) +# +# The best way to make sure no Python 3.5+ features are used is running the +# script with a Python 3.5.0 interpreter. Compile it from: +# +# https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz +# +# Also, when calling a function look for 'New in version 3.X' where X > 5 +# +from __future__ import print_function # To check for python2 or < 3.5 execution +import argparse +import fcntl +import os +import grp +import shutil +import getpass +import sys +from subprocess import Popen, PIPE + + +if not (sys.version_info.major == 3 and sys.version_info.minor >= 5): + print("This script requires Python 3.5 or higher!") + print("You are using Python {}.{}.".format(sys.version_info.major, sys.version_info.minor)) + sys.exit(1) + + +def check_docker_versions(): + DOCKER_MAJOR = 19 + DC_MAJOR = 1 + DC_MINOR = 25 + docker_version = os.popen('docker --version').read().split(' ')[2] + docker_major = int(docker_version.split('.')[0]) + if docker_major < DOCKER_MAJOR: + fmt = "This script requires docker {}.0 or higher" + print(fmt.format(DOCKER_MAJOR)) + print("You are usng version {}".format(docker_version)) + sys.exit(1) + dc_version = os.popen('docker-compose --version').read().split(' ')[2] + dc_major = int(dc_version.split('.')[0]) + dc_minor = int(dc_version.split('.')[1]) + if dc_major < DC_MAJOR: + fmt = "This script requires docker-compose {}.{} or higher" + print(fmt.format(DC_MAJOR, DC_MINOR)) + print("You are usng version {}".format(dc_version)) + sys.exit(1) + if dc_minor < DC_MINOR: + fmt = "This script requires docker-compose {}.{} or higher" + print(fmt.format(DC_MAJOR, DC_MINOR)) + print("You are usng version {}".format(dc_version)) + sys.exit(1) + + +class Services: + def __init__(self, bid=None): + self.scriptdir = os.path.dirname(os.path.realpath(__file__)) + os.chdir(self.scriptdir) + self.rootdir = self.scriptdir + + if bid is not None: + self.build_id = bid + print('Using ID {}'.format(self.build_id)) + # return + else: + self.build_id = self.get_build_id() + + self.logdir = os.path.join(self.scriptdir, 'logs') + device_name = 'dockerized_device-{}'.format(self.build_id) + self.devicedir = os.path.join(self.logdir, device_name) + repeater_name = 'repeater1-{}'.format(self.build_id) + self.repeaterdir = os.path.join(self.logdir, repeater_name) + if not os.path.exists(self.logdir): + os.makedirs(self.logdir) + if not os.path.exists(self.devicedir): + print('Making {}'.format(self.devicedir)) + os.makedirs(self.devicedir) + if not os.path.exists(self.repeaterdir): + print('Making {}'.format(self.repeaterdir)) + os.makedirs(self.repeaterdir) + + def cleanlogs(self): + shutil.rmtree(os.path.join(self.scriptdir, 'logs')) + + def _setNonBlocking(fd): + """ + Set the file description of the given file descriptor to non-blocking. + """ + flags = fcntl.fcntl(fd, fcntl.F_GETFL) + flags = flags | os.O_NONBLOCK + fcntl.fcntl(fd, fcntl.F_SETFL, flags) + + def get_build_id(self): + ci_pipeline_id = os.getenv('CI_PIPELINE_ID') + if ci_pipeline_id is not None: + return ci_pipeline_id + + # Otherwise we are running on the local machine, just find last id + # created and add one + last_id = 0 + if not os.path.exists('logs'): + return str(1) + for d in os.listdir('logs'): + if d.startswith('dockerized_device-'): + suffix = d[len('dockerized_device-'):] + isuffix = int(suffix) + if isuffix > last_id: + last_id = isuffix + if last_id == 0: + new_id = 1 + else: + new_id = last_id + 1 + return str(new_id) + + def copy_build_dir(self): + new_id = self.build_id + self.build_dir = 'build-{}'.format(new_id) + shutil.copytree('build', 'build-{}'.format(self.build_dir)) + print('Copied build/ into {}'.format(self.build_dir)) + + def dc(self, args, interactive=False): + params = ['docker-compose', '-f', + 'tools/docker/boardfarm-ci/docker-compose.yml'] + # params += ['-p', 'boardfarm-ci-{}'.format(self.build_id)] + params += args + local_env = os.environ + local_env['ROOT_DIR'] = self.rootdir + docker_gid = grp.getgrnam('docker')[2] + local_env['CURRENT_UID'] = str(os.getuid()) + ':' + str(docker_gid) + local_env['CURRENT_ID'] = str(os.getuid()) + local_env['RUN_ID'] = self.build_id + + if os.getenv('CI_PIPELINE_ID') is None: + # Running locally + local_env['CI_PIPELINE_ID'] = 'latest' + local_env['FINAL_ROOT_DIR'] = self.rootdir + else: + # Running inside gitlab-ci + local_env['FINAL_ROOT_DIR'] = '/builds/prpl-foundation/prplMesh' + + # local_env['CURRENT_UID']= str(os.getuid()) + ':' + str(os.getgid()) + if not interactive: + proc = Popen(params, stdout=PIPE, stderr=PIPE) + for line in proc.stdout: + print(line.decode(), end='') + proc.stdout.close() + else: + proc = Popen(params) + return_code = proc.wait() + return return_code + + +def vararg_callback(option, opt_str, value, parser): + assert value is None + value = [] + + def floatable(str): + try: + float(str) + return True + except ValueError: + return False + + for arg in parser.rargs: + # stop on --foo like options + if arg[:2] == "--" and len(arg) > 2: + break + # stop on -a, but not on -3 or -3.0 + if arg[:1] == "-" and len(arg) > 1 and not floatable(arg): + break + value.append(arg) + + del parser.rargs[:len(value)] + setattr(parser.values, option.dest, value) + + +def cleanup(rc): + if rc != 0: + print('Return code !=0 -> {}'.format(rc)) + if getpass.getuser() == 'gitlab-runner': + os.system('chown -R gitlab-runner:gitlab-runner .') + sys.exit(rc) + + +if __name__ == '__main__': + check_docker_versions() + parser = argparse.ArgumentParser(description='Dockerized test launcher') + parser.add_argument('--test', dest='test', type=str, help='Test to be run') + parser.add_argument('--clean', dest='clean', action='store_true', + help='Clean containers images and networks') + parser.add_argument('--build', dest='build', action='store_true', + help='Rebuild containers') + parser.add_argument('--shell', dest='shell', action='store_true', + help='Run a shell on the bf container') + parser.add_argument('--comp', dest='comp', action='store_true', + help='Pass the rest of arguments to docker-compose') + parser.add_argument('--id', dest='bid', type=str, + help='Specify the id to use for build/shell/comp/clean') + args, rest = parser.parse_known_args() + + if os.getenv('CI_PIPELINE_ID') is not None: + args.bid == os.getenv('CI_PIPELINE_ID') + + if args.comp: + if args.bid is None: + print('Specify --id for the --comp parameter') + sys.exit(0) + services = Services(bid=args.bid) + if len(rest) == 0: + print('Usage: dctest --id --comp ') + sys.exit(1) + sys.exit(services.dc(rest, interactive=True)) + else: + if len(rest) > 0: + print('Unknown parameters: {}'.format(rest)) + sys.exit(1) + + if args.clean: + if args.bid is None: + print('Specify --id for the --clean parameter') + sys.exit(0) + services = Services(bid=args.bid) + rc = services.dc(['down', '--remove-orphans', '--rmi', 'all']) + cleanup(rc) + elif args.shell: + if not args.bid: + print('Specify --id for the shell parameter') + sys.exit(0) + services = Services(bid=args.bid) + rc = services.dc(['run', '--rm', '--service-ports', '--entrypoint', + '/bin/bash', 'boardfarm'], interactive=True) + cleanup(rc) + elif args.build: + if not args.bid: + print('Specify --id for the build parameter') + sys.exit(0) + services = Services(bid=args.bid) + rc = services.dc(['build'], interactive=True) + cleanup(rc) + else: + if args.bid: + services = Services(bid=args.bid) # With new build id + else: + services = Services() # With new build id + # rc = services.dc(['up', 'boardfarm']) + # rc = services.dc(['run', '--service-ports', '--entrypoint', + # '/bin/bash', 'boardfarm'], interactive=True) + rc = services.dc(['run', '--rm', '--service-ports', '--use-aliases', + 'boardfarm'], interactive=True) + cleanup(rc) From b35bd3cf46146aae2962a3cff2a18e63bdaef83f Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 16:48:34 +0200 Subject: [PATCH 006/453] PPM-30: Add test to boardfarm-ci Signed-off-by: pablo --- .gitlab-ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 090b7315eb..7d5cda44ef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -180,6 +180,7 @@ upload-artifacts: - build-for-glinet-b1300 - build-for-turris-omnia + .run-test-in-docker: stage: test extends: .in-prplmesh-builder @@ -198,6 +199,15 @@ bwl_dummy_unit_tests: bcl_unit_tests: extends: .run-test-in-docker +dctest_one_test: + stage: test + script: + - ./dctest.py + tags: + - boardfarm-compose + needs: + - job: build-in-docker + mapf_common_encryption_tests: extends: .run-test-in-docker From d28e0e10979ededaf3008c72ee94cf48e527b5aa Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 15:04:25 +0200 Subject: [PATCH 007/453] PPM-30: Changes on class ALEntityDocker for compose Use directly the hostname instead of querying for the ip Signed-off-by: pablo --- tests/environment.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/environment.py b/tests/environment.py index 7da67bb6b0..888ff0fe71 100644 --- a/tests/environment.py +++ b/tests/environment.py @@ -191,6 +191,9 @@ def _docker_wait_for_log(container: str, programs: [str], regex: str, start_line timeout: float) -> bool: def logfilename(program): logfilename = os.path.join(rootdir, 'logs', container, 'beerocks_{}.log'.format(program)) + + print(' --- logfilename: {}'.format(logfilename)) + # WSL doesn't support symlinks on NTFS, so resolve the symlink manually if on_wsl: logfilename = os.path.join( @@ -249,9 +252,9 @@ class ALEntityDocker(ALEntity): The entity is defined from the name of the container, the rest is derived from that. ''' - # NOTE: name arg can be also extracted from the device class itself, but test_flows.py - # don't have it. We can remove this arg as soon, as we drop test_flows.py - def __init__(self, name: str, device: None = None, is_controller: bool = False): + def __init__(self, name: str, device: None = None, is_controller: bool = False, + compose: bool = False): + self.name = name self.bridge_name = 'br-lan' if device: @@ -268,16 +271,19 @@ def __init__(self, name: str, device: None = None, is_controller: bool = False): config_file.read()).group('port') # On WSL, connect to the locally exposed container port - if on_wsl: - published_port_output = subprocess.check_output( - ["docker", "port", name, ucc_port]).decode('utf-8').split(":") - device_ip = published_port_output[0] - ucc_port = int(published_port_output[1]) + if not compose: + if on_wsl: + published_port_output = subprocess.check_output( + ["docker", "port", name, ucc_port]).decode('utf-8').split(":") + device_ip = published_port_output[0] + ucc_port = int(published_port_output[1]) + else: + device_ip_output = self.command( + 'ip', '-f', 'inet', 'addr', 'show', self.bridge_name) + device_ip = re.search( + r'inet (?P[0-9.]+)', device_ip_output.decode('utf-8')).group('ip') else: - device_ip_output = self.command( - 'ip', '-f', 'inet', 'addr', 'show', self.bridge_name) - device_ip = re.search(r'inet (?P[0-9.]+)', - device_ip_output.decode('utf-8')).group('ip') + device_ip = name ucc_socket = UCCSocket(device_ip, ucc_port) mac = ucc_socket.dev_get_parameter('ALid') From 03a6c05b23962462aa781b7acfdd20baa26cbe33 Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 15:06:16 +0200 Subject: [PATCH 008/453] PPM-30: Define test entrypoint and json config Entrypoint calls the json for "in compose" tests Signed-off-by: pablo --- .../prplmesh_config_compose.json | 15 +++++++++++++++ tests/run_bf_compose.sh | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config_compose.json create mode 100755 tests/run_bf_compose.sh diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config_compose.json b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config_compose.json new file mode 100644 index 0000000000..dbd3897cb8 --- /dev/null +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config_compose.json @@ -0,0 +1,15 @@ +{ + "prplmesh_docker": { + "name": "dockerized_device", + "board_type": "prplmesh_compose", + "role": "controller", + "conn_cmd": "", + "devices": [ + { + "name": "repeater1", + "type": "prplmesh_compose", + "conn_cmd": "" + } + ] + } +} diff --git a/tests/run_bf_compose.sh b/tests/run_bf_compose.sh new file mode 100755 index 0000000000..365e3a7671 --- /dev/null +++ b/tests/run_bf_compose.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# SPDX-License-Identifier: BSD-2-Clause-Patent +# SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) +# This code is subject to the terms of the BSD+Patent license. +# See LICENSE file for more details. + +scriptdir=$(dirname "$(readlink -f "${0}")") +bf_plugins_dir=${scriptdir}/boardfarm_plugins + +if [ -n "${PYTHONPATH}" ]; then + PYTHONPATH="${bf_plugins_dir}:${scriptdir}:${PYTHONPATH}" +else + PYTHONPATH="${bf_plugins_dir}:${scriptdir}" +fi +echo "$PYTHONPATH" +export PYTHONPATH + +exec bft -c "${bf_plugins_dir}"/boardfarm_prplmesh/prplmesh_config_compose.json -n prplmesh_docker -x test_flows From 99387bf1b7aa8dbf0f3a20905f88e80012f3b512 Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 15:10:11 +0200 Subject: [PATCH 009/453] PPM-30: Dockerfile and docker-compose.yml Dockerfile to create boardfarm docker image and docker-compose.yml with the configuration for boardfarm, controller and extender Signed-off-by: pablo --- tools/docker/boardfarm-ci/Dockerfile | 30 +++------- tools/docker/boardfarm-ci/docker-compose.yml | 60 ++++++++++++++++++++ 2 files changed, 69 insertions(+), 21 deletions(-) create mode 100644 tools/docker/boardfarm-ci/docker-compose.yml diff --git a/tools/docker/boardfarm-ci/Dockerfile b/tools/docker/boardfarm-ci/Dockerfile index 67fd3ed294..a5d2979de6 100644 --- a/tools/docker/boardfarm-ci/Dockerfile +++ b/tools/docker/boardfarm-ci/Dockerfile @@ -1,41 +1,29 @@ FROM python:3.8-slim-buster +# FROM tiangolo/docker-with-compose RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - apt-transport-https \ - ca-certificates curl \ - curl \ - gcc \ - git \ - gnupg \ - gnupg-agent \ - libsnmp-dev \ - netcat \ - software-properties-common \ - wireshark-common \ - && rm -rf /var/lib/apt/lists/* +&& apt-get install gcc libsnmp-dev -y \ +&& apt-get clean COPY requirements.txt /app/requirements.txt WORKDIR app RUN pip3 install -r requirements.txt -# TODO: what needs this? -#RUN pip3 install jsonschema distro +RUN apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y +RUN apt-get install curl -y RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - docker-ce \ - docker-ce-cli \ - containerd.io \ - && rm -rf /var/lib/apt/lists/* - +&& apt-get install docker-ce docker-ce-cli containerd.io -y RUN curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose RUN chmod 755 /usr/local/bin/docker-compose +RUN DEBIAN_FRONTEND=noninteractive apt-get install wireshark-common -y +# VOLUME "/home/pablo/assia/prpl/git" +# ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] RUN git clone https://github.com/mattsm/boardfarm.git \ && cd boardfarm \ && git checkout 100521fde1fb67536682cafecc2f91a6e2e8a6f8 \ diff --git a/tools/docker/boardfarm-ci/docker-compose.yml b/tools/docker/boardfarm-ci/docker-compose.yml new file mode 100644 index 0000000000..1f50b9cc75 --- /dev/null +++ b/tools/docker/boardfarm-ci/docker-compose.yml @@ -0,0 +1,60 @@ +version: '3' +services: + # Controller and agent are run from inside the boardfarm container + controller: + image: registry.gitlab.com/prpl-foundation/prplmesh/prplmesh-runner:${CI_PIPELINE_ID} + privileged: true # For the creation of the bridge to work + container_name: controller + environment: + - USER + - INSTALL_DIR=${FINAL_ROOT_DIR}/build/install + - ROOT_DIR=${FINAL_ROOT_DIR} + - CURRENT_ID + - CI_PIPELINE_ID + expose: + - "5000" + - "8002" + volumes: + - "$ROOT_DIR:${FINAL_ROOT_DIR}" + entrypoint: ["/root/entrypoint.sh", "/usr/bin/start-controller-agent"] + + agent: + image: registry.gitlab.com/prpl-foundation/prplmesh/prplmesh-runner:${CI_PIPELINE_ID} + privileged: true + container_name: agent + environment: + - USER + - INSTALL_DIR=${FINAL_ROOT_DIR}/build/install + - ROOT_DIR=${FINAL_ROOT_DIR} + # /builds/prpl-foundation/prplMesh + - CURRENT_ID + - CI_PIPELINE_ID + expose: + - "5000" + - "8002" + volumes: + - "$ROOT_DIR:${FINAL_ROOT_DIR}" + entrypoint: ["/root/entrypoint.sh", "/usr/bin/start-agent"] + + # Boardfarm image is launched from dctest.py, TARGET_DIR refers to the + # path inside the controller, will be referred as $ROOT_DIR inside + boardfarm: + build: . + privileged: true + container_name: boardfarm + environment: + - USER + - ROOT_DIR + - CURRENT_ID + - RUN_ID + - CI_PIPELINE_ID + - FINAL_ROOT_DIR + ports: + - "5000:5000" + volumes: + - "$ROOT_DIR:$ROOT_DIR" + - "/var/run/docker:/var/run/docker" + - "/var/run/docker.sock:/var/run/docker.sock" + user: ${CURRENT_UID} + working_dir: $ROOT_DIR/tests + entrypoint: ["bash", "run_bf_compose.sh"] From 7b46cd5806081209da5ddd0a069a02521850998d Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 15:11:33 +0200 Subject: [PATCH 010/453] PPM-30: dctest.py script to wrap docker-compose It wraps docker-compose tests - Verifies versions of docker and docker-compose - Creates and launches boardfarm image with the correct environment variables - Cleans images after building - Returns value from boardfarm process inside the image Signed-off-by: pablo --- dctest.py | 255 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100755 dctest.py diff --git a/dctest.py b/dctest.py new file mode 100755 index 0000000000..3855209703 --- /dev/null +++ b/dctest.py @@ -0,0 +1,255 @@ +#!/usr/bin/env python3 +# +# Launch the test suite using docker and docker-compose. This script wraps +# the creation of the bridge(s) to be able to connect external devices with +# the docker network, launching the service for boardfarm. +# +# As this script is run outside containers, it does not use anything apart +# from Python 3.5 (will work on later versions but only uses 3.5 features) +# +# The best way to make sure no Python 3.5+ features are used is running the +# script with a Python 3.5.0 interpreter. Compile it from: +# +# https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz +# +# Also, when calling a function look for 'New in version 3.X' where X > 5 +# +from __future__ import print_function # To check for python2 or < 3.5 execution +import argparse +import fcntl +import os +import grp +import shutil +import getpass +import sys +from subprocess import Popen, PIPE + + +if not (sys.version_info.major == 3 and sys.version_info.minor >= 5): + print("This script requires Python 3.5 or higher!") + print("You are using Python {}.{}.".format(sys.version_info.major, sys.version_info.minor)) + sys.exit(1) + + +def check_docker_versions(): + DOCKER_MAJOR = 19 + DC_MAJOR = 1 + DC_MINOR = 25 + docker_version = os.popen('docker --version').read().split(' ')[2] + docker_major = int(docker_version.split('.')[0]) + if docker_major < DOCKER_MAJOR: + fmt = "This script requires docker {}.0 or higher" + print(fmt.format(DOCKER_MAJOR)) + print("You are usng version {}".format(docker_version)) + sys.exit(1) + dc_version = os.popen('docker-compose --version').read().split(' ')[2] + dc_major = int(dc_version.split('.')[0]) + dc_minor = int(dc_version.split('.')[1]) + if dc_major < DC_MAJOR: + fmt = "This script requires docker-compose {}.{} or higher" + print(fmt.format(DC_MAJOR, DC_MINOR)) + print("You are usng version {}".format(dc_version)) + sys.exit(1) + if dc_minor < DC_MINOR: + fmt = "This script requires docker-compose {}.{} or higher" + print(fmt.format(DC_MAJOR, DC_MINOR)) + print("You are usng version {}".format(dc_version)) + sys.exit(1) + + +class Services: + def __init__(self, bid=None): + self.scriptdir = os.path.dirname(os.path.realpath(__file__)) + os.chdir(self.scriptdir) + self.rootdir = self.scriptdir + + if bid is not None: + self.build_id = bid + print('Using ID {}'.format(self.build_id)) + # return + else: + self.build_id = self.get_build_id() + + self.logdir = os.path.join(self.scriptdir, 'logs') + device_name = 'dockerized_device-{}'.format(self.build_id) + self.devicedir = os.path.join(self.logdir, device_name) + repeater_name = 'repeater1-{}'.format(self.build_id) + self.repeaterdir = os.path.join(self.logdir, repeater_name) + if not os.path.exists(self.logdir): + os.makedirs(self.logdir) + if not os.path.exists(self.devicedir): + print('Making {}'.format(self.devicedir)) + os.makedirs(self.devicedir) + if not os.path.exists(self.repeaterdir): + print('Making {}'.format(self.repeaterdir)) + os.makedirs(self.repeaterdir) + + def cleanlogs(self): + shutil.rmtree(os.path.join(self.scriptdir, 'logs')) + + def _setNonBlocking(fd): + """ + Set the file description of the given file descriptor to non-blocking. + """ + flags = fcntl.fcntl(fd, fcntl.F_GETFL) + flags = flags | os.O_NONBLOCK + fcntl.fcntl(fd, fcntl.F_SETFL, flags) + + def get_build_id(self): + ci_pipeline_id = os.getenv('CI_PIPELINE_ID') + if ci_pipeline_id is not None: + return ci_pipeline_id + + # Otherwise we are running on the local machine, just find last id + # created and add one + last_id = 0 + if not os.path.exists('logs'): + return str(1) + for d in os.listdir('logs'): + if d.startswith('dockerized_device-'): + suffix = d[len('dockerized_device-'):] + isuffix = int(suffix) + if isuffix > last_id: + last_id = isuffix + if last_id == 0: + new_id = 1 + else: + new_id = last_id + 1 + return str(new_id) + + def copy_build_dir(self): + new_id = self.build_id + self.build_dir = 'build-{}'.format(new_id) + shutil.copytree('build', 'build-{}'.format(self.build_dir)) + print('Copied build/ into {}'.format(self.build_dir)) + + def dc(self, args, interactive=False): + params = ['docker-compose', '-f', + 'tools/docker/boardfarm-ci/docker-compose.yml'] + # params += ['-p', 'boardfarm-ci-{}'.format(self.build_id)] + params += args + local_env = os.environ + local_env['ROOT_DIR'] = self.rootdir + docker_gid = grp.getgrnam('docker')[2] + local_env['CURRENT_UID'] = str(os.getuid()) + ':' + str(docker_gid) + local_env['CURRENT_ID'] = str(os.getuid()) + local_env['RUN_ID'] = self.build_id + + if os.getenv('CI_PIPELINE_ID') is None: + # Running locally + local_env['CI_PIPELINE_ID'] = 'latest' + local_env['FINAL_ROOT_DIR'] = self.rootdir + else: + # Running inside gitlab-ci + local_env['FINAL_ROOT_DIR'] = '/builds/prpl-foundation/prplMesh' + + # local_env['CURRENT_UID']= str(os.getuid()) + ':' + str(os.getgid()) + if not interactive: + proc = Popen(params, stdout=PIPE, stderr=PIPE) + for line in proc.stdout: + print(line.decode(), end='') + proc.stdout.close() + else: + proc = Popen(params) + return_code = proc.wait() + return return_code + + +def vararg_callback(option, opt_str, value, parser): + assert value is None + value = [] + + def floatable(str): + try: + float(str) + return True + except ValueError: + return False + + for arg in parser.rargs: + # stop on --foo like options + if arg[:2] == "--" and len(arg) > 2: + break + # stop on -a, but not on -3 or -3.0 + if arg[:1] == "-" and len(arg) > 1 and not floatable(arg): + break + value.append(arg) + + del parser.rargs[:len(value)] + setattr(parser.values, option.dest, value) + + +def cleanup(rc): + if rc != 0: + print('Return code !=0 -> {}'.format(rc)) + if getpass.getuser() == 'gitlab-runner': + os.system('chown -R gitlab-runner:gitlab-runner .') + sys.exit(rc) + + +if __name__ == '__main__': + check_docker_versions() + parser = argparse.ArgumentParser(description='Dockerized test launcher') + parser.add_argument('--test', dest='test', type=str, help='Test to be run') + parser.add_argument('--clean', dest='clean', action='store_true', + help='Clean containers images and networks') + parser.add_argument('--build', dest='build', action='store_true', + help='Rebuild containers') + parser.add_argument('--shell', dest='shell', action='store_true', + help='Run a shell on the bf container') + parser.add_argument('--comp', dest='comp', action='store_true', + help='Pass the rest of arguments to docker-compose') + parser.add_argument('--id', dest='bid', type=str, + help='Specify the id to use for build/shell/comp/clean') + args, rest = parser.parse_known_args() + + if os.getenv('CI_PIPELINE_ID') is not None: + args.bid == os.getenv('CI_PIPELINE_ID') + + if args.comp: + if args.bid is None: + print('Specify --id for the --comp parameter') + sys.exit(0) + services = Services(bid=args.bid) + if len(rest) == 0: + print('Usage: dctest --id --comp ') + sys.exit(1) + sys.exit(services.dc(rest, interactive=True)) + else: + if len(rest) > 0: + print('Unknown parameters: {}'.format(rest)) + sys.exit(1) + + if args.clean: + if args.bid is None: + print('Specify --id for the --clean parameter') + sys.exit(0) + services = Services(bid=args.bid) + rc = services.dc(['down', '--remove-orphans', '--rmi', 'all']) + cleanup(rc) + elif args.shell: + if not args.bid: + print('Specify --id for the shell parameter') + sys.exit(0) + services = Services(bid=args.bid) + rc = services.dc(['run', '--rm', '--service-ports', '--entrypoint', + '/bin/bash', 'boardfarm'], interactive=True) + cleanup(rc) + elif args.build: + if not args.bid: + print('Specify --id for the build parameter') + sys.exit(0) + services = Services(bid=args.bid) + rc = services.dc(['build'], interactive=True) + cleanup(rc) + else: + if args.bid: + services = Services(bid=args.bid) # With new build id + else: + services = Services() # With new build id + # rc = services.dc(['up', 'boardfarm']) + # rc = services.dc(['run', '--service-ports', '--entrypoint', + # '/bin/bash', 'boardfarm'], interactive=True) + rc = services.dc(['run', '--rm', '--service-ports', '--use-aliases', + 'boardfarm'], interactive=True) + cleanup(rc) From d0246dfc2b0dbeab68ee8f88470ba6646456a37b Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 16:48:34 +0200 Subject: [PATCH 011/453] PPM-30: Add test to boardfarm-ci Signed-off-by: pablo --- .gitlab-ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 090b7315eb..7d5cda44ef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -180,6 +180,7 @@ upload-artifacts: - build-for-glinet-b1300 - build-for-turris-omnia + .run-test-in-docker: stage: test extends: .in-prplmesh-builder @@ -198,6 +199,15 @@ bwl_dummy_unit_tests: bcl_unit_tests: extends: .run-test-in-docker +dctest_one_test: + stage: test + script: + - ./dctest.py + tags: + - boardfarm-compose + needs: + - job: build-in-docker + mapf_common_encryption_tests: extends: .run-test-in-docker From 3dfa4e0144f6255b7b7903def36e73520a470243 Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 17:52:38 +0200 Subject: [PATCH 012/453] PPM-30: Check return error on _run_shell Signed-off-by: pablo --- .../boardfarm_prplmesh/devices/prplmesh_base.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py index 700c5c2863..c30bf08e28 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py @@ -4,6 +4,7 @@ # See LICENSE file for more details. import pexpect +from typing import Dict from boardfarm.devices import linux @@ -16,14 +17,18 @@ class CommandError(Exception): class PrplMeshBase(linux.LinuxDevice): """PrplMesh abstract device.""" - def _run_shell_cmd(self, cmd: str = "", args: list = None, timeout: int = 30): + def _run_shell_cmd(self, cmd: str = "", args: list = None, timeout: int = 30, + env: Dict[str, str] = None): """Wrapper that executes command with specified args on host machine and logs output.""" - - res, exitstatus = pexpect.run(cmd, args=args, timeout=timeout, encoding="utf-8", - withexitstatus=1) + if env is not None: + res, exitstatus = pexpect.run(cmd, args=args, timeout=timeout, encoding="utf-8", + withexitstatus=1, env=env) + else: + res, exitstatus = pexpect.run(cmd, args=args, timeout=timeout, encoding="utf-8", + withexitstatus=1) entry = " ".join((cmd, " ".join(args))) if exitstatus != 0: - raise CommandError("Error executing {}:\n{}".format(entry, res)) + raise CommandError("Error executing {}".format(entry)) self.log_calls += entry self.log += "$ " + entry + "\r\n" + res From 7fc24084c9b4c7847ab8926039d7b4832528e74b Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 18:13:21 +0200 Subject: [PATCH 013/453] Added device prplmesh_compose.py Signed-off-by: pablo --- .../devices/prplmesh_compose.py | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py new file mode 100644 index 0000000000..79eea79ea7 --- /dev/null +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py @@ -0,0 +1,112 @@ +# SPDX-License-Identifier: BSD-2-Clause-Patent +# SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) +# This code is subject to the terms of the BSD+Patent license. +# See LICENSE file for more details. + +import os +import time + +import boardfarm +from environment import ALEntityDocker, _get_bridge_interface +from .prplmesh_base import PrplMeshBase +from sniffer import Sniffer + +rootdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..')) + + +class PrplMeshCompose(PrplMeshBase): + """Dockerized prplMesh device.""" + + model = ("prplmesh_compose") + agent_entity = None + controller_entity = None + + def __init__(self, *args, **kwargs): + self.args = args + self.kwargs = kwargs + + config = kwargs.get("config", kwargs) + + # List of device's consoles test can interact with + self.consoles = [self] + + # Getting unic ID to distinguish devices and network they belong to + self.unique_id = os.getenv("RUN_ID") + self.user_id = os.getenv("SUDO_USER", os.getenv("USER", "")) + + self.name = "-".join((config.get("name", "prplmesh_compose"), self.unique_id)) + print('config.get("name") {}'.format(config.get("name"))) + # self.name = config.get("name") + self.role = config.get("role", "agent") + self.cleanup_cmd = config.get("cleanup_cmd", None) + self.conn_cmd = config.get("conn_cmd", None) + self.delay = config.get("delay", 7) + self.docker_network = "boardfarm-ci_default" + + if self.role == "controller": + self._docker_compose(["-d", "--name", self.name, "controller"], + "run", "start-controller") + time.sleep(self.delay) + self.controller_entity = \ + ALEntityDocker(self.name, is_controller=True, compose=True) + else: + self._docker_compose(["-d", "--name", self.name, "agent"], + "run", "start-agent") + time.sleep(self.delay) + self.agent_entity = ALEntityDocker(self.name, is_controller=False, compose=True) + + self.wired_sniffer = Sniffer(_get_bridge_interface(self.docker_network), + boardfarm.config.output_dir) + self.check_status() + + def _docker_compose(self, args, parameter=None, start=None): + print('_docker_compose: args {}'.format(args)) + yml_path = "tools/docker/boardfarm-ci/docker-compose.yml" + full_args = ["-f", os.path.join(rootdir, yml_path)] + if parameter == "run": + log_path = os.path.join(rootdir, "logs/{}".format(self.name)) + if not os.path.exists(log_path): + os.mkdir(log_path) + + pipeline_id = os.getenv('CI_PIPELINE_ID') + if pipeline_id is None or pipeline_id == 'latest': + vol = '{}:/tmp/{}/beerocks/logs'.format(log_path, self.user_id) + else: + vol = '{}:/tmp/beerocks/logs'.format(log_path) + + full_args += ["run", "--rm", "-v", vol] + # full_args += ["--entrypoint", entrypoint + ' ' + start] + full_args += args + + print('_docker_compose: {}'.format(' '.join(full_args))) + # os.environ['CURRENT_UID'] = '1000:998' + if os.getenv('CI_PIPELINE_ID') is None: + print('Setting CI_PIPELINE_ID "latest"') + os.environ['CI_PIPELINE_ID'] = 'latest' + self._run_shell_cmd("/usr/local/bin/docker-compose", + full_args, env=os.environ) + else: + self._run_shell_cmd("/usr/local/bin/docker-compose", full_args) + + def __del__(self): + # self._docker_compose(["stop", self.name]) + self._run_shell_cmd("docker", ["stop", self.name]) + self._run_shell_cmd("docker", ["container", "rm", "-f", self.name]) + + def check_status(self): + """Method required by boardfarm. + + It is used by boardfarm to indicate that spawned device instance is ready for test + and also after test - to insure that device still operational. + """ + # self._run_shell_cmd(os.path.join(rootdir, "tools", "docker", "test.sh"), + # ["-v", "-n", "controller"]) + pass + + def isalive(self): + """Method required by boardfarm. + + States that device is operational and its consoles are accessible. + + """ + return True From eda7536ebff01dba30b5a91722a8406ca85fbaa5 Mon Sep 17 00:00:00 2001 From: odkq Date: Wed, 5 Aug 2020 16:16:25 +0200 Subject: [PATCH 014/453] boardfarm-ci: Fix mangling of prplmesh_base.py Signed-off-by: odkq --- .../devices/prplmesh_base.py | 92 ------------------- 1 file changed, 92 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py index 50c3df2901..b8cd850d72 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py @@ -3,7 +3,6 @@ # This code is subject to the terms of the BSD+Patent license. # See LICENSE file for more details. -<<<<<<< HEAD import pexpect from typing import Dict @@ -33,97 +32,6 @@ def _run_shell_cmd(self, cmd: str = "", args: list = None, timeout: int = 30, self.log_calls += entry self.log += "$ " + entry + "\r\n" + res -======= -import os -import time - -import boardfarm -from environment import ALEntityDocker, _get_bridge_interface -from .prplmesh_base import PrplMeshBase -from sniffer import Sniffer - -rootdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..')) - - -class PrplMeshCompose(PrplMeshBase): - """Dockerized prplMesh device.""" - - model = ("prplmesh_compose") - agent_entity = None - controller_entity = None - - def __init__(self, *args, **kwargs): - self.args = args - self.kwargs = kwargs - - config = kwargs.get("config", kwargs) - - # List of device's consoles test can interact with - self.consoles = [self] - - # Getting unic ID to distinguish devices and network they belong to - self.unique_id = os.getenv("RUN_ID") - self.user_id = os.getenv("SUDO_USER", os.getenv("USER", "")) - - self.name = "-".join((config.get("name", "prplmesh_compose"), self.unique_id)) - print('config.get("name") {}'.format(config.get("name"))) - # self.name = config.get("name") - self.role = config.get("role", "agent") - self.cleanup_cmd = config.get("cleanup_cmd", None) - self.conn_cmd = config.get("conn_cmd", None) - self.delay = config.get("delay", 7) - self.docker_network = "boardfarm-ci_default" - - if self.role == "controller": - self._docker_compose(["-d", "--name", self.name, "controller"], - "run", "start-controller") - time.sleep(self.delay) - self.controller_entity = \ - ALEntityDocker(self.name, is_controller=True, compose=True) - else: - self._docker_compose(["-d", "--name", self.name, "agent"], - "run", "start-agent") - time.sleep(self.delay) - self.agent_entity = ALEntityDocker(self.name, is_controller=False, compose=True) - - self.wired_sniffer = Sniffer(_get_bridge_interface(self.docker_network), - boardfarm.config.output_dir) - self.check_status() - - def _docker_compose(self, args, parameter=None, start=None): - print('_docker_compose: args {}'.format(args)) - yml_path = "tools/docker/boardfarm-ci/docker-compose.yml" - full_args = ["-f", os.path.join(rootdir, yml_path)] - if parameter == "run": - log_path = os.path.join(rootdir, "logs/{}".format(self.name)) - if not os.path.exists(log_path): - os.mkdir(log_path) - - pipeline_id = os.getenv('CI_PIPELINE_ID') - if pipeline_id is None or pipeline_id == 'latest': - vol = '{}:/tmp/{}/beerocks/logs'.format(log_path, self.user_id) - else: - vol = '{}:/tmp/beerocks/logs'.format(log_path) - - full_args += ["run", "--rm", "-v", vol] - # full_args += ["--entrypoint", entrypoint + ' ' + start] - full_args += args - - print('_docker_compose: {}'.format(' '.join(full_args))) - # os.environ['CURRENT_UID'] = '1000:998' - if os.getenv('CI_PIPELINE_ID') is None: - print('Setting CI_PIPELINE_ID "latest"') - os.environ['CI_PIPELINE_ID'] = 'latest' - self._run_shell_cmd("/usr/local/bin/docker-compose", - full_args, env=os.environ) - else: - self._run_shell_cmd("/usr/local/bin/docker-compose", full_args) - - def __del__(self): - # self._docker_compose(["stop", self.name]) - self._run_shell_cmd("docker", ["stop", self.name]) - self._run_shell_cmd("docker", ["container", "rm", "-f", self.name]) ->>>>>>> b35bd3cf46146aae2962a3cff2a18e63bdaef83f def check_status(self): """Method required by boardfarm. From cc47e7cb2e9264f616f7f288f5abaefe31dc27b0 Mon Sep 17 00:00:00 2001 From: odkq Date: Wed, 5 Aug 2020 16:46:33 +0200 Subject: [PATCH 015/453] boardfarm-ci: Set device on prplmesh_compose.py Signed-off-by: odkq --- .../boardfarm_prplmesh/devices/prplmesh_compose.py | 4 ++-- tests/run_bf_compose.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py index 79eea79ea7..e94328fda3 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py @@ -48,12 +48,12 @@ def __init__(self, *args, **kwargs): "run", "start-controller") time.sleep(self.delay) self.controller_entity = \ - ALEntityDocker(self.name, is_controller=True, compose=True) + ALEntityDocker(self.name, device=self, is_controller=True, compose=True) else: self._docker_compose(["-d", "--name", self.name, "agent"], "run", "start-agent") time.sleep(self.delay) - self.agent_entity = ALEntityDocker(self.name, is_controller=False, compose=True) + self.agent_entity = ALEntityDocker(self.name, device=self, is_controller=False, compose=True) self.wired_sniffer = Sniffer(_get_bridge_interface(self.docker_network), boardfarm.config.output_dir) diff --git a/tests/run_bf_compose.sh b/tests/run_bf_compose.sh index 365e3a7671..df9b144dcc 100755 --- a/tests/run_bf_compose.sh +++ b/tests/run_bf_compose.sh @@ -14,5 +14,5 @@ else fi echo "$PYTHONPATH" export PYTHONPATH - +export BFT_DEBUG=y exec bft -c "${bf_plugins_dir}"/boardfarm_prplmesh/prplmesh_config_compose.json -n prplmesh_docker -x test_flows From f118ea25052ff8ba829041211e4aa6faf075c57e Mon Sep 17 00:00:00 2001 From: odkq Date: Wed, 5 Aug 2020 17:31:03 +0200 Subject: [PATCH 016/453] boardfarm-ci: Add mockup of prplmesh_status_check Signed-off-by: odkq --- .../boardfarm_prplmesh/devices/prplmesh_compose.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py index e94328fda3..9db700ecc8 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py @@ -45,7 +45,7 @@ def __init__(self, *args, **kwargs): if self.role == "controller": self._docker_compose(["-d", "--name", self.name, "controller"], - "run", "start-controller") + "run", "start-controller-agent") time.sleep(self.delay) self.controller_entity = \ ALEntityDocker(self.name, device=self, is_controller=True, compose=True) @@ -110,3 +110,7 @@ def isalive(self): """ return True + + def prprlmesh_status_check(self): + return True + From 3cc2b46791a5df2b09b6a3b9e9c357a942b89220 Mon Sep 17 00:00:00 2001 From: odkq Date: Thu, 6 Aug 2020 12:44:55 +0200 Subject: [PATCH 017/453] Use original name and docker-name for hostname in environment.py Signed-off-by: odkq --- .../boardfarm_prplmesh/devices/prplmesh_compose.py | 3 ++- tests/environment.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py index 9db700ecc8..62f83d9ff9 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py @@ -34,7 +34,8 @@ def __init__(self, *args, **kwargs): self.unique_id = os.getenv("RUN_ID") self.user_id = os.getenv("SUDO_USER", os.getenv("USER", "")) - self.name = "-".join((config.get("name", "prplmesh_compose"), self.unique_id)) + self.docker_name = "-".join((config.get("name", "prplmesh_compose"), self.unique_id)) + self.name = config.get("name", "prplmesh_compose") print('config.get("name") {}'.format(config.get("name"))) # self.name = config.get("name") self.role = config.get("role", "agent") diff --git a/tests/environment.py b/tests/environment.py index 888ff0fe71..4f80f73513 100644 --- a/tests/environment.py +++ b/tests/environment.py @@ -283,7 +283,7 @@ def __init__(self, name: str, device: None = None, is_controller: bool = False, device_ip = re.search( r'inet (?P[0-9.]+)', device_ip_output.decode('utf-8')).group('ip') else: - device_ip = name + device_ip = self.device.name ucc_socket = UCCSocket(device_ip, ucc_port) mac = ucc_socket.dev_get_parameter('ALid') From fd702eadc066b9fa4852075c73038127b5b22ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Wed, 10 Jun 2020 08:10:56 +0200 Subject: [PATCH 018/453] tools: openwrt: move the actual build to a separate script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moving the build part to a script makes it more readable, and easier to maintain. It also makes it easier to repeat the same steps in a container interactively, to debug a failing build for example. As a bonus, it makes it possible to run shellcheck and formatting tools on it. - Move the last "RUN" step to build-openwrt.sh. - Export the build arguments as environment variables to make them available to the script at build time, and to also keep them in the environment of the containers. - Copy build-openwrt.sh into the container. - Run build-openwrt.sh as the last RUN step. - While we're at it, add license headers to the files we modify. Signed-off-by: Raphaël Mélotte --- tools/docker/builder/openwrt/Dockerfile | 55 ++++++------------- .../builder/openwrt/scripts/build-openwrt.sh | 47 ++++++++++++++++ 2 files changed, 65 insertions(+), 37 deletions(-) create mode 100755 tools/docker/builder/openwrt/scripts/build-openwrt.sh diff --git a/tools/docker/builder/openwrt/Dockerfile b/tools/docker/builder/openwrt/Dockerfile index 44c2eb0ea4..ffd8c1a3b0 100644 --- a/tools/docker/builder/openwrt/Dockerfile +++ b/tools/docker/builder/openwrt/Dockerfile @@ -1,3 +1,10 @@ +############################################################### +# SPDX-License-Identifier: BSD-2-Clause-Patent +# SPDX-FileCopyrightText: 2019-2020 the prplMesh contributors (see AUTHORS.md) +# This code is subject to the terms of the BSD+Patent license. +# See LICENSE file for more details. +############################################################### + #### ## OpenWrt pre-requisites and "openwrt" user #### @@ -33,29 +40,38 @@ USER openwrt # # OpenWrt repository to use. Can also be a prplWrt repository: ARG OPENWRT_REPOSITORY +ENV OPENWRT_REPOSITORY=$OPENWRT_REPOSITORY # Which OpenWrt version (commit hash) to use: ARG OPENWRT_VERSION +ENV OPENWRT_VERSION=$OPENWRT_VERSION # The variant to build (nl80211 or dwpal) ARG PRPLMESH_VARIANT +ENV PRPLMESH_VARIANT=$PRPLMESH_VARIANT # The feed to use to build prplMesh. ARG PRPL_FEED +ENV PRPL_FEED=$PRPL_FEED # optional: intel feed to use. ARG INTEL_FEED +ENV INTEL_FEED=$INTEL_FEED # optional: iwlwav feed to use. ARG IWLWAV_FEED +ENV IWLWAV_FEED=$IWLWAV_FEED # Target to build for (CONFIG_TARGET_ will be prepended). # Example: TARGET_SYSTEM=mvebu ARG TARGET_SYSTEM +ENV TARGET_SYSTEM=$TARGET_SYSTEM # Subtarget (CONFIG_TARGET_${TARGET_SYSTEM}_ will be prepended). # Example: SUBTARGET=cortexa9 ARG SUBTARGET +ENV SUBTARGET=$SUBTARGET # Target profile (CONFIG_TARGET_${TARGET_SYSTEM}_${SUBTARGET}_ will be prepended). # Example: TARGET_PROFILE=DEVICE_cznic_turris-omnia ARG TARGET_PROFILE +ENV TARGET_PROFILE=$TARGET_PROFILE WORKDIR /home/openwrt @@ -66,41 +82,6 @@ RUN git clone "$OPENWRT_REPOSITORY" openwrt \ WORKDIR /home/openwrt/openwrt COPY --chown=openwrt:openwrt profiles_feeds/ /home/openwrt/openwrt/profiles_feeds +COPY --chown=openwrt:openwrt scripts/build-openwrt.sh /home/openwrt/openwrt/scripts/build-openwrt.sh -RUN mkdir -p files/etc \ - # We need to keep the hashes in the firmware, to later know if an upgrade is needed: - && printf '%s=%s\n' "OPENWRT_REPOSITORY" "$OPENWRT_REPOSITORY" >> files/etc/prplwrt-version \ - && printf '%s=%s\n' "OPENWRT_VERSION" "$OPENWRT_VERSION" >> files/etc/prplwrt-version \ - && if [ "$TARGET_PROFILE" = DEVICE_NETGEAR_RAX40 ] ; then \ - # Add prplmesh to the list of packages of the profile: - sed -i 's/packages:/packages:\n - prplmesh-dwpal/g' profiles/intel_mips.yml \ - && yq write --inplace profiles/intel_mips.yml feeds -f profiles_feeds/netgear-rax40.yml \ - && ./scripts/gen_config.py intel_mips \ - # Installing intel feed doesn't correctly regenerate kernel .package-info - # force regeneration by removing it - && rm -rf tmp \ - # For some reason we have to run gen_config a second time to get a correct .config: - && ./scripts/gen_config.py intel_mips \ - # make sure intel's bridge-utils is the only one that gets installed: - && rm -rf ./package/feeds/packages/bridge-utils \ - && scripts/feeds install -p feed_bridge_utils bridge-utils \ - && cat profiles_feeds/netgear-rax40.yml >> files/etc/prplwrt-version ;\ - else \ - cp feeds.conf.default feeds.conf \ - && echo "src-git prpl $PRPL_FEED" >> feeds.conf \ - && scripts/feeds update -a \ - && scripts/feeds install -a \ - && echo "CONFIG_TARGET_${TARGET_SYSTEM}=y" >> .config \ - && echo "CONFIG_TARGET_${TARGET_SYSTEM}_${SUBTARGET}=y" >> .config \ - && echo "CONFIG_TARGET_${TARGET_SYSTEM}_${SUBTARGET}_${TARGET_PROFILE}=y" >> .config \ - && echo "CONFIG_PACKAGE_prplmesh${PRPLMESH_VARIANT}=y" >> .config \ - && make defconfig \ - && printf '%s=%s\n' "PRPL_FEED" "$PRPL_FEED" >> files/etc/prplwrt-version ;\ - fi ;\ - make -j$(nproc) \ - && make package/prplmesh/clean -# note that the result from diffconfig.sh with a minimal -# configuration has the 3 CONFIG_TARGET items we set here, but NOT -# the individual CONFIG_TARGET_${SUBTARGET} and -# CONFIG_TARGET_${TARGET_PROFILE}, which means we don't need to -# set them. +RUN scripts/build-openwrt.sh diff --git a/tools/docker/builder/openwrt/scripts/build-openwrt.sh b/tools/docker/builder/openwrt/scripts/build-openwrt.sh new file mode 100755 index 0000000000..324f53468a --- /dev/null +++ b/tools/docker/builder/openwrt/scripts/build-openwrt.sh @@ -0,0 +1,47 @@ +#!/bin/sh -e +############################################################### +# SPDX-License-Identifier: BSD-2-Clause-Patent +# SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) +# This code is subject to the terms of the BSD+Patent license. +# See LICENSE file for more details. +############################################################### + +mkdir -p files/etc +# We need to keep the hashes in the firmware, to later know if an upgrade is needed: +printf '%s=%s\n' "OPENWRT_REPOSITORY" "$OPENWRT_REPOSITORY" >> files/etc/prplwrt-version +printf '%s=%s\n' "OPENWRT_VERSION" "$OPENWRT_VERSION" >> files/etc/prplwrt-version +if [ "$TARGET_PROFILE" = DEVICE_NETGEAR_RAX40 ] ; then + # Add prplmesh to the list of packages of the profile: + sed -i 's/packages:/packages:\n - prplmesh-dwpal/g' profiles/intel_mips.yml + yq write --inplace profiles/intel_mips.yml feeds -f profiles_feeds/netgear-rax40.yml + ./scripts/gen_config.py intel_mips + # Installing intel feed doesn't correctly regenerate kernel .package-info + # force regeneration by removing it + rm -rf tmp + # For some reason we have to run gen_config a second time to get a correct .config: + ./scripts/gen_config.py intel_mips + # make sure intel's bridge-utils is the only one that gets installed: + rm -rf ./package/feeds/packages/bridge-utils + scripts/feeds install -p feed_bridge_utils bridge-utils + cat profiles_feeds/netgear-rax40.yml >> files/etc/prplwrt-version +else + cp feeds.conf.default feeds.conf + echo "src-git prpl $PRPL_FEED" >> feeds.conf + scripts/feeds update -a + scripts/feeds install -a + { + # note that the result from diffconfig.sh with a minimal + # configuration has the 3 CONFIG_TARGET items we set here, but NOT + # the individual CONFIG_TARGET_${SUBTARGET} and + # CONFIG_TARGET_${TARGET_PROFILE}, which means we don't need to + # set them. + echo "CONFIG_TARGET_${TARGET_SYSTEM}=y" + echo "CONFIG_TARGET_${TARGET_SYSTEM}_${SUBTARGET}=y" + echo "CONFIG_TARGET_${TARGET_SYSTEM}_${SUBTARGET}_${TARGET_PROFILE}=y" + echo "CONFIG_PACKAGE_prplmesh${PRPLMESH_VARIANT}=y" + } >> .config + make defconfig + printf '%s=%s\n' "PRPL_FEED" "$PRPL_FEED" >> files/etc/prplwrt-version +fi +make -j"$(nproc)" +make package/prplmesh/clean From eedc64befe9a23acef0056060ad717671ce5f843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Wed, 10 Jun 2020 08:19:26 +0200 Subject: [PATCH 019/453] tools: openwrt: add an option to build an openwrt-builder image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some developers like to build OpenWrt interactively, to configure different build options for example, or to be able to debug failing builds more easily than what can be done when building a docker image. tools/docker/builder/openwrt/Dockerfile: - Add a new target, "openwrt-builder", that stops right before openwrt is actually built. tools/docker/builder/openwrt/build.sh: - Add a new option: "--docker-target-stage". When the option is used, the script will build the docker image only, and will stop at the specified target stage. - Use the content of DOCKER_TARGET_STAGE for the default tag. - Add the missing license header. With these changes, it's now possible to build the "openwrt-builder" image: tools/docker/builder/openwrt/build.sh --docker-target-stage openwrt-builder --target-device netgear-rax40 The image can then be used to compile OpenWrt interactively. Signed-off-by: Raphaël Mélotte --- tools/docker/builder/openwrt/Dockerfile | 9 +++++++-- tools/docker/builder/openwrt/build.sh | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/tools/docker/builder/openwrt/Dockerfile b/tools/docker/builder/openwrt/Dockerfile index ffd8c1a3b0..1e36eccfed 100644 --- a/tools/docker/builder/openwrt/Dockerfile +++ b/tools/docker/builder/openwrt/Dockerfile @@ -29,9 +29,9 @@ RUN apt-get update \ RUN useradd -ms /bin/bash openwrt #### -## Prebuilt OpenWrt and prplMesh dependencies, but not the prplMesh ipk itself +## OpenWrt tree and scripts to build it. #### -FROM openwrt-prerequisites as prplmesh-builder +FROM openwrt-prerequisites as openwrt-builder USER openwrt @@ -84,4 +84,9 @@ WORKDIR /home/openwrt/openwrt COPY --chown=openwrt:openwrt profiles_feeds/ /home/openwrt/openwrt/profiles_feeds COPY --chown=openwrt:openwrt scripts/build-openwrt.sh /home/openwrt/openwrt/scripts/build-openwrt.sh +#### +## Prebuilt OpenWrt and prplMesh dependencies, but not the prplMesh ipk itself +#### +FROM openwrt-builder as prplmesh-builder + RUN scripts/build-openwrt.sh diff --git a/tools/docker/builder/openwrt/build.sh b/tools/docker/builder/openwrt/build.sh index 142e5750f8..aa894403fc 100755 --- a/tools/docker/builder/openwrt/build.sh +++ b/tools/docker/builder/openwrt/build.sh @@ -1,4 +1,10 @@ #!/bin/sh -e +############################################################### +# SPDX-License-Identifier: BSD-2-Clause-Patent +# SPDX-FileCopyrightText: 2019-2020 the prplMesh contributors (see AUTHORS.md) +# This code is subject to the terms of the BSD+Patent license. +# See LICENSE file for more details. +############################################################### scriptdir="$(cd "${0%/*}"; pwd)" rootdir="${scriptdir%/*/*/*/*}" @@ -12,6 +18,7 @@ usage() { echo " -h|--help - show this help menu" echo " -v|--verbose - increase the script's verbosity" echo " -d|--target-device the device to build for" + echo " --docker-target-stage docker target build stage (implies -i)" echo " -i|--image - build the docker image only" echo " -o|--openwrt-version - the openwrt version to use" echo " -r|--openwrt-repository - the openwrt repository to use" @@ -34,6 +41,7 @@ build_image() { --build-arg TARGET_PROFILE="$TARGET_PROFILE" \ --build-arg PRPL_FEED="$PRPL_FEED" \ --build-arg PRPLMESH_VARIANT="$PRPLMESH_VARIANT" \ + --target="$DOCKER_TARGET_STAGE" \ "$scriptdir/" } @@ -67,7 +75,7 @@ main() { exit 1 fi - if ! OPTS=$(getopt -o 'hvd:io:r:t:' --long help,verbose,target-device:,image,openwrt-version:,openwrt-repository:,tag: -n 'parse-options' -- "$@"); then + if ! OPTS=$(getopt -o 'hvd:io:r:t:' --long help,verbose,target-device:,docker-target-stage:,image,openwrt-version:,openwrt-repository:,tag: -n 'parse-options' -- "$@"); then err "Failed parsing options." >&2 usage exit 1 @@ -82,6 +90,7 @@ main() { -h | --help) usage; exit 0; shift ;; -v | --verbose) VERBOSE=true; shift ;; -d | --target-device) TARGET_DEVICE="$2"; shift ; shift ;; + --docker-target-stage) DOCKER_TARGET_STAGE="$2"; IMAGE_ONLY=true; shift 2 ;; -i | --image) IMAGE_ONLY=true; shift ;; -o | --openwrt-version) OPENWRT_VERSION="$2"; shift; shift ;; -r | --openwrt-repository) OPENWRT_REPOSITORY="$2"; shift; shift ;; @@ -132,7 +141,7 @@ main() { if [ -n "$TAG" ] ; then image_tag="$TAG" else - image_tag="prplmesh-builder-${TARGET_DEVICE}:${OPENWRT_VERSION}" + image_tag="${DOCKER_TARGET_STAGE}-${TARGET_DEVICE}:${OPENWRT_VERSION}" dbg "image tag not set, using default value $image_tag" fi @@ -166,5 +175,6 @@ OPENWRT_REPOSITORY='https://git.prpl.dev/prplmesh/prplwrt.git' OPENWRT_VERSION='bd19f9ab26ad234b6f10cce23cd0dc41b9371929' PRPL_FEED='https://git.prpl.dev/prplmesh/feed-prpl.git^53d1e11003ce318c043c42063bbd2f57d15aac81' PRPLMESH_VARIANT="-nl80211" +DOCKER_TARGET_STAGE="prplmesh-builder" main "$@" From 7b289e2ac4302cd6ef289bbb32ed061e70fada8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Wed, 10 Jun 2020 18:05:41 +0200 Subject: [PATCH 020/453] tools: openwrt: output what is being done MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The grep filter in .gitlab-ci.yml is also not needed anymore, since we don't run make with with V=sc anymore. Signed-off-by: Raphaël Mélotte Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- .gitlab-ci.yml | 2 +- tools/docker/builder/openwrt/Dockerfile | 3 ++- tools/docker/builder/openwrt/scripts/build-openwrt.sh | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 14d36166b7..d4a7519b78 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -216,7 +216,7 @@ run-tests: stage: build script: - mkdir -p "build/$TARGET_DEVICE" - - tools/docker/builder/openwrt/build.sh --verbose -d "$TARGET_DEVICE" -t "prplmesh-builder-$TARGET_DEVICE:$CI_COMMIT_SHORT_SHA-$CI_PIPELINE_ID" 2>&1 | tee "build/$TARGET_DEVICE/openwrt-build.log" | grep -E '^[[:blank:]]?make\[[12]\]|^Step|^ --->' --color=never --line-buffered + - tools/docker/builder/openwrt/build.sh --verbose -d "$TARGET_DEVICE" -t "prplmesh-builder-$TARGET_DEVICE:$CI_COMMIT_SHORT_SHA-$CI_PIPELINE_ID" 2>&1 | tee "build/$TARGET_DEVICE/openwrt-build.log" artifacts: paths: - "build/$TARGET_DEVICE/" diff --git a/tools/docker/builder/openwrt/Dockerfile b/tools/docker/builder/openwrt/Dockerfile index 1e36eccfed..9073a1ef3c 100644 --- a/tools/docker/builder/openwrt/Dockerfile +++ b/tools/docker/builder/openwrt/Dockerfile @@ -75,7 +75,8 @@ ENV TARGET_PROFILE=$TARGET_PROFILE WORKDIR /home/openwrt -RUN git clone "$OPENWRT_REPOSITORY" openwrt \ +RUN printf '\033[1;35m%s Cloning prplWrt\n\033[0m' "$(date --iso-8601=seconds --universal)" \ + && git clone "$OPENWRT_REPOSITORY" openwrt \ && cd openwrt \ && git checkout "$OPENWRT_VERSION" diff --git a/tools/docker/builder/openwrt/scripts/build-openwrt.sh b/tools/docker/builder/openwrt/scripts/build-openwrt.sh index 324f53468a..7618c2e81c 100755 --- a/tools/docker/builder/openwrt/scripts/build-openwrt.sh +++ b/tools/docker/builder/openwrt/scripts/build-openwrt.sh @@ -6,6 +6,7 @@ # See LICENSE file for more details. ############################################################### +printf '\033[1;35m%s Configuring prplWrt\n\033[0m' "$(date --iso-8601=seconds --universal)" mkdir -p files/etc # We need to keep the hashes in the firmware, to later know if an upgrade is needed: printf '%s=%s\n' "OPENWRT_REPOSITORY" "$OPENWRT_REPOSITORY" >> files/etc/prplwrt-version @@ -43,5 +44,8 @@ else make defconfig printf '%s=%s\n' "PRPL_FEED" "$PRPL_FEED" >> files/etc/prplwrt-version fi +printf '\033[1;35m%s Building prplWrt\n\033[0m' "$(date --iso-8601=seconds --universal)" make -j"$(nproc)" + +printf '\033[1;35m%s Cleaning prplMesh\n\033[0m' "$(date --iso-8601=seconds --universal)" make package/prplmesh/clean From 3d059d9fb98b29c16aec82ff4a0013c1e4840758 Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Sun, 14 Jun 2020 12:24:57 +0000 Subject: [PATCH 021/453] cmake: Finddwpal.cmake add opt/intel/lib prplwrt-rc1 installs libdwpal.so to opt/intel/lib. Update Finddwpal.cmake to also search this path to fix out of tree build. Signed-off-by: Tomer Eliyahu --- cmake/Finddwpal.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Finddwpal.cmake b/cmake/Finddwpal.cmake index ed17c92ecb..f74c6bce51 100644 --- a/cmake/Finddwpal.cmake +++ b/cmake/Finddwpal.cmake @@ -5,7 +5,7 @@ # This code is subject to the terms of the BSD+Patent license. # See LICENSE file for more details. -find_library(DWPAL_LIBRARY "libdwpal.so") +find_library(DWPAL_LIBRARY "libdwpal.so" PATHS ${CMAKE_PREFIX_PATH}/opt/intel/lib) find_path(DWPAL_INCLUDE_DIRS NAMES dwpal.h PATH_SUFFIXES wav-dpal From e93df972a18c0ffb9cd66a5a83444825be73ff15 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 10 Jun 2020 16:46:19 +0000 Subject: [PATCH 022/453] bcl: update copyright message Change the copyright message in the beerocks version class from Intel Corporation to prplMesh Signed-off-by: Vitaly Bukhovsky --- common/beerocks/bcl/source/beerocks_version.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/beerocks/bcl/source/beerocks_version.cpp b/common/beerocks/bcl/source/beerocks_version.cpp index 949390d108..4f3a03c63d 100644 --- a/common/beerocks/bcl/source/beerocks_version.cpp +++ b/common/beerocks/bcl/source/beerocks_version.cpp @@ -105,8 +105,7 @@ void beerocks::version::print_version(bool verbose, const std::string &name, if (description.length() > 0) { std::cout << description << std::endl; } - std::cout << "Copyright (c) 2018 Intel Corporation, All Rights Reserved." << std::endl - << std::endl; + std::cout << "Copyright (c) 2020 prplMesh, All Rights Reserved." << std::endl << std::endl; } void beerocks::version::log_version(int argc, char **argv, const std::string &logger_id) From a79c648812f2f3a0ab145a11b8442da3ae79625f Mon Sep 17 00:00:00 2001 From: Klemen Porenta Date: Fri, 12 Jun 2020 12:43:34 +0200 Subject: [PATCH 023/453] controller: bml: call mac_to_string for members defined as uint8_t[6] BML structures (BML_NODE, BML_STAT, BML_EVENT) has members defined as open coded array (uint8_t[BML_MAC_ADDR_LEN]). Call mac_to_string function before display. Signed-off-by: Klemen Porenta --- controller/src/beerocks/bml/bml_utils.cpp | 31 ++++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/controller/src/beerocks/bml/bml_utils.cpp b/controller/src/beerocks/bml/bml_utils.cpp index 1973941d1c..b2497dc125 100644 --- a/controller/src/beerocks/bml/bml_utils.cpp +++ b/controller/src/beerocks/bml/bml_utils.cpp @@ -89,10 +89,11 @@ int bml_utils_node_to_string(const struct BML_NODE *node, char *buffer, int buff ss << ", Type: " << node_type_to_string(node->type) << " (" << std::to_string(node->type) << ")" << ", State: " << node_state_to_string(node->state) << " (" << std::to_string(node->state) << ")" - << ", MAC: " << node->mac << ", IP: " << network_utils::ipv4_to_string(node->ip_v4); + << ", MAC: " << tlvf::mac_to_string(node->mac) + << ", IP: " << network_utils::ipv4_to_string(node->ip_v4); if (node->type != BML_NODE_TYPE_CLIENT) { - ss << ", Backhaul: " << node->data.gw_ire.backhaul_mac; + ss << ", Backhaul: " << tlvf::mac_to_string(node->data.gw_ire.backhaul_mac); } if (node->channel) { @@ -100,8 +101,8 @@ int bml_utils_node_to_string(const struct BML_NODE *node, char *buffer, int buff } if (node->parent_bridge[0]) { - ss << ", Parent Bridge: " << node->parent_bridge - << ", Parent BSSID: " << node->parent_bssid; + ss << ", Parent Bridge: " << tlvf::mac_to_string(node->parent_bridge) + << ", Parent BSSID: " << tlvf::mac_to_string(node->parent_bssid); } // New line @@ -165,7 +166,7 @@ int bml_utils_stats_to_string(const struct BML_STATS *stats, char *buffer, int b ss << "Type: " << node_type_to_string(stats->type) << " (" << int(stats->type) << ")" ", MAC: " - << stats->mac + << tlvf::mac_to_string(stats->mac) << ", measurement_window_msec: " << std::to_string(stats->measurement_window_msec); if (stats->type == BML_STAT_TYPE_RADIO) { @@ -265,7 +266,7 @@ int bml_utils_stats_to_string_raw(const struct BML_STATS *stats, char *buffer, i { std::stringstream ss; - ss << "Type: " << int(stats->type) << ", mac: " << stats->mac + ss << "Type: " << int(stats->type) << ", mac: " << tlvf::mac_to_string(stats->mac) << ", measurement_window_msec: " << std::to_string(stats->measurement_window_msec); if (stats->type == BML_STAT_TYPE_RADIO) { @@ -330,42 +331,42 @@ int bml_utils_event_to_string(const struct BML_EVENT *event, char *buffer, int b case BML_EVENT_TYPE_BSS_TM_REQ: { ss << "BML_EVENT_TYPE_BSS_TM_REQ"; auto event_data = (BML_EVENT_BSS_TM_REQ *)(event->data); - ss << ", target bssid: " << event_data->target_bssid << ", " + ss << ", target bssid: " << tlvf::mac_to_string(event_data->target_bssid) << ", " << "disassoc imminent: " << std::to_string(event_data->disassoc_imminent) << std::endl; break; } case BML_EVENT_TYPE_BH_ROAM_REQ: { ss << "BML_EVENT_TYPE_BH_ROAM_REQ"; auto event_data = (BML_EVENT_BH_ROAM_REQ *)(event->data); - ss << ", bssid: " << event_data->bssid << ", " + ss << ", bssid: " << tlvf::mac_to_string(event_data->bssid) << ", " << "channel: " << std::to_string(event_data->channel) << std::endl; break; } case BML_EVENT_TYPE_CLIENT_ALLOW_REQ: { ss << "BML_EVENT_TYPE_CLIENT_ALLOW_REQ"; auto event_data = (BML_EVENT_CLIENT_ALLOW_REQ *)(event->data); - ss << ", hostap_mac: " << event_data->hostap_mac << ", " - << "sta_mac: " << event_data->sta_mac << ", " + ss << ", hostap_mac: " << tlvf::mac_to_string(event_data->hostap_mac) << ", " + << "sta_mac: " << tlvf::mac_to_string(event_data->sta_mac) << ", " << "ip: " << network_utils::ipv4_to_string(event_data->ip) << std::endl; break; } case BML_EVENT_TYPE_CLIENT_DISALLOW_REQ: { ss << "BML_EVENT_TYPE_CLIENT_DISALLOW_REQ"; auto event_data = (BML_EVENT_CLIENT_ALLOW_REQ *)(event->data); - ss << ", hostap_mac: " << event_data->hostap_mac << ", sta_mac: " << event_data->sta_mac - << std::endl; + ss << ", hostap_mac: " << tlvf::mac_to_string(event_data->hostap_mac) + << ", sta_mac: " << tlvf::mac_to_string(event_data->sta_mac) << std::endl; break; } case BML_EVENT_TYPE_ACS_START: { ss << "BML_EVENT_TYPE_ACS_START"; auto event_data = (BML_EVENT_ACS_START *)(event->data); - ss << ", hostap_mac: " << event_data->hostap_mac << std::endl; + ss << ", hostap_mac: " << tlvf::mac_to_string(event_data->hostap_mac) << std::endl; break; } case BML_EVENT_TYPE_CSA_NOTIFICATION: { ss << "BML_EVENT_TYPE_CSA_NOTIFICATION"; auto event_data = (BML_EVENT_CSA_NOTIFICATION *)(event->data); - ss << ", hostap_mac: " << event_data->hostap_mac + ss << ", hostap_mac: " << tlvf::mac_to_string(event_data->hostap_mac) << ", bandwidth: " << std::to_string(event_data->bandwidth) << ", channel: " << std::to_string(event_data->channel) << ", channel_ext_above_primary: " @@ -377,7 +378,7 @@ int bml_utils_event_to_string(const struct BML_EVENT *event, char *buffer, int b case BML_EVENT_TYPE_CAC_STATUS_CHANGED_NOTIFICATION: { ss << "BML_EVENT_TYPE_CAC_STATUS_CHANGED_NOTIFICATION"; auto event_data = (BML_EVENT_CAC_STATUS_CHANGED_NOTIFICATION *)(event->data); - ss << ", hostap_mac: " << event_data->hostap_mac + ss << ", hostap_mac: " << tlvf::mac_to_string(event_data->hostap_mac) << ", cac_completed: " << std::to_string(event_data->cac_completed) << std::endl; break; } From cd9c57149809640cf2ad94a443a048d7e6fc2b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Mon, 15 Jun 2020 07:19:55 +0200 Subject: [PATCH 024/453] deploy_firmware.py: try to kill the prplMesh init script first MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the rax40 has a firmware with non-working wireless interfaces, the S99prplmesh script prevents it from rebooting. Try to kill it first, before doing a reboot. Also pass the "-f" option to reboot, to avoid going through the init scripts. Fixes https://github.com/prplfoundation/prplMesh/issues/1436. Signed-off-by: Raphaël Mélotte --- tools/deploy_firmware.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/deploy_firmware.py b/tools/deploy_firmware.py index c3149d29f0..6e4d514194 100755 --- a/tools/deploy_firmware.py +++ b/tools/deploy_firmware.py @@ -174,8 +174,12 @@ def upgrade_uboot(self): # make the shell prompt appear: self.set_prompt(shell) shell.expect(self.serial_prompt) + # kill any instance of the init script, if the current + # firmware doesn't have working wireless interfaces it + # will prevent it from rebooting: + shell.sendline("pgrep -f 'S99prplmesh boot' | xargs kill") # reboot: - shell.sendline("reboot") + shell.sendline("reboot -f") shell.expect(["Hit any key to stop autoboot:", pexpect.EOF, pexpect.TIMEOUT], timeout=120) # stop autoboot: From f1cdf8410beca260e23acbcd41dcdff1d292bb99 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Tue, 16 Jun 2020 08:04:13 +0000 Subject: [PATCH 025/453] btlvf: format yaml files Signed-off-by: Vitaly Bukhovsky --- .../tlvf/beerocks_message_1905_vs.yaml | 16 +- .../tlvf/beerocks_message_action.yaml | 75 ++++---- .../tlvf/beerocks_message_apmanager.yaml | 22 +-- .../tlvf/beerocks_message_backhaul.yaml | 36 ++-- .../beerocks/tlvf/beerocks_message_bml.yaml | 90 ++++----- .../beerocks/tlvf/beerocks_message_cli.yaml | 39 ++-- .../tlvf/beerocks_message_cli_net_map.yaml | 38 ++-- .../tlvf/beerocks_message_control.yaml | 176 +++++++++--------- .../tlvf/beerocks_message_header.yaml | 13 +- .../tlvf/beerocks_message_monitor.yaml | 79 ++++---- .../tlvf/beerocks_message_platform.yaml | 68 +++---- 11 files changed, 322 insertions(+), 330 deletions(-) diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_1905_vs.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_1905_vs.yaml index 845bc2ba34..01b3ccf0ab 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_1905_vs.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_1905_vs.yaml @@ -1,9 +1,7 @@ # --- -_include: { - bcl/beerocks_message_structs.h, - beerocks/tlvf/beerocks_message_action.h, -} +_include: + { bcl/beerocks_message_structs.h, beerocks/tlvf/beerocks_message_action.h } _namespace: beerocks_message @@ -11,7 +9,7 @@ _multi_class: True _multi_class_auto_insert: action_op: _type: eActionOp_1905_VS - _value_const: ACTION_TLV_VENDOR_SPECIFIC + _value_const: ACTION_TLV_VENDOR_SPECIFIC _class_const: True ################################################# @@ -23,15 +21,15 @@ tlvVsClientAssociationEvent: mac: sMacAddr bssid: sMacAddr vap_id: int8_t - capabilities: + capabilities: _type: beerocks::message::sRadioCapabilities _comment: relevant only on connect event - disconnect_reason: + disconnect_reason: _type: uint8_t _comment: relevant only on disconnect event - disconnect_source: + disconnect_source: _type: uint8_t _comment: relevant only on disconnect event - disconnect_type: + disconnect_type: _type: uint8_t _comment: relevant only on disconnect event diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index e793c314b5..3cd129fdf0 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -48,7 +48,7 @@ eActionOp_CONTROL: ACTION_CONTROL_BACKHAUL_ROAM_REQUEST: 30 ACTION_CONTROL_BACKHAUL_DL_RSSI_REPORT_NOTIFICATION: 31 ACTION_CONTROL_BACKHAUL_RESET: 32 - + ACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST: 53 ACTION_CONTROL_HOSTAP_CSA_ERROR_NOTIFICATION: 54 ACTION_CONTROL_HOSTAP_CSA_NOTIFICATION: 55 @@ -79,7 +79,7 @@ eActionOp_CONTROL: ACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_NOTIFICATION: 106 ACTION_CONTROL_CLIENT_NO_RESPONSE_NOTIFICATION: 107 ACTION_CONTROL_CLIENT_NEW_IP_ADDRESS_NOTIFICATION: 108 - + ACTION_CONTROL_CLIENT_DISCONNECT_REQUEST: 111 ACTION_CONTROL_CLIENT_DISCONNECT_RESPONSE: 112 ACTION_CONTROL_CLIENT_DHCP_COMPLETE_NOTIFICATION: 115 @@ -98,19 +98,19 @@ eActionOp_CONTROL: ACTION_CONTROL_STEERING_CLIENT_SET_GROUP_RESPONSE: 128 ACTION_CONTROL_STEERING_CLIENT_SET_REQUEST: 129 ACTION_CONTROL_STEERING_CLIENT_SET_RESPONSE: 130 - ACTION_CONTROL_STEERING_EVENT_CLIENT_ACTIVITY_NOTIFICATION : 131 - ACTION_CONTROL_STEERING_EVENT_SNR_XING_NOTIFICATION : 132 - ACTION_CONTROL_STEERING_EVENT_PROBE_REQ_NOTIFICATION : 133 - ACTION_CONTROL_STEERING_EVENT_AUTH_FAIL_NOTIFICATION : 134 + ACTION_CONTROL_STEERING_EVENT_CLIENT_ACTIVITY_NOTIFICATION: 131 + ACTION_CONTROL_STEERING_EVENT_SNR_XING_NOTIFICATION: 132 + ACTION_CONTROL_STEERING_EVENT_PROBE_REQ_NOTIFICATION: 133 + ACTION_CONTROL_STEERING_EVENT_AUTH_FAIL_NOTIFICATION: 134 - ACTION_CONTROL_CHANNEL_SCAN_TRIGGER_SCAN_REQUEST : 140 - ACTION_CONTROL_CHANNEL_SCAN_TRIGGER_SCAN_RESPONSE : 141 + ACTION_CONTROL_CHANNEL_SCAN_TRIGGER_SCAN_REQUEST: 140 + ACTION_CONTROL_CHANNEL_SCAN_TRIGGER_SCAN_RESPONSE: 141 ACTION_CONTROL_CHANNEL_SCAN_DUMP_RESULTS_REQUEST: 142 ACTION_CONTROL_CHANNEL_SCAN_DUMP_RESULTS_RESPONSE: 143 - ACTION_CONTROL_CHANNEL_SCAN_TRIGGERED_NOTIFICATION : 144 - ACTION_CONTROL_CHANNEL_SCAN_RESULTS_NOTIFICATION : 145 - ACTION_CONTROL_CHANNEL_SCAN_ABORT_NOTIFICATION : 146 - ACTION_CONTROL_CHANNEL_SCAN_FINISHED_NOTIFICATION : 147 + ACTION_CONTROL_CHANNEL_SCAN_TRIGGERED_NOTIFICATION: 144 + ACTION_CONTROL_CHANNEL_SCAN_RESULTS_NOTIFICATION: 145 + ACTION_CONTROL_CHANNEL_SCAN_ABORT_NOTIFICATION: 146 + ACTION_CONTROL_CHANNEL_SCAN_FINISHED_NOTIFICATION: 147 ACTION_CONTROL_ENUM_END: 148 @@ -291,9 +291,9 @@ eActionOp_MONITOR: ACTION_MONITOR_HOSTAP_LOAD_MEASUREMENT_NOTIFICATION: 52 ACTION_MONITOR_HOSTAP_ACTIVITY_NOTIFICATION: 53 ACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION: 54 - - ACTION_MONITOR_CHANNEL_SCAN_TRIGGER_SCAN_REQUEST : 60 - ACTION_MONITOR_CHANNEL_SCAN_TRIGGER_SCAN_RESPONSE : 61 + + ACTION_MONITOR_CHANNEL_SCAN_TRIGGER_SCAN_REQUEST: 60 + ACTION_MONITOR_CHANNEL_SCAN_TRIGGER_SCAN_RESPONSE: 61 ACTION_MONITOR_CHANNEL_SCAN_TRIGGERED_NOTIFICATION: 62 ACTION_MONITOR_CHANNEL_SCAN_DUMP_RESULTS_REQUEST: 63 ACTION_MONITOR_CHANNEL_SCAN_DUMP_RESULTS_RESPONSE: 64 @@ -310,7 +310,6 @@ eActionOp_MONITOR: ACTION_MONITOR_ENUM_END: 86 - #################################################### #################################################### eActionOp_CLI: @@ -343,12 +342,12 @@ eActionOp_CLI: ACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST: 85 ACTION_CLI_CLIENT_BEACON_11K_REQUEST: 86 ACTION_CLI_CLIENT_STATISTICS_11K_REQUEST: 87 - + ACTION_CLI_HOSTAP_CHANNEL_SWITCH_REQUEST: 122 ACTION_CLI_HOSTAP_SET_NEIGHBOR_11K_REQUEST: 123 ACTION_CLI_HOSTAP_REMOVE_NEIGHBOR_11K_REQUEST: 124 ACTION_CLI_HOSTAP_STATS_MEASUREMENT: 125 - + ACTION_CLI_ENUM_END: 126 #################################################### @@ -404,12 +403,12 @@ eActionOp_BML: ACTION_BML_SET_SERVICE_FAIRNESS_RESPONSE: 77 ACTION_BML_GET_SERVICE_FAIRNESS_REQUEST: 78 ACTION_BML_GET_SERVICE_FAIRNESS_RESPONSE: 79 - + ACTION_BML_SET_CLIENT_ROAMING_PREFER_SIGNAL_STRENGTH_REQUEST: 80 ACTION_BML_SET_CLIENT_ROAMING_PREFER_SIGNAL_STRENGTH_RESPONSE: 81 ACTION_BML_GET_CLIENT_ROAMING_PREFER_SIGNAL_STRENGTH_REQUEST: 82 ACTION_BML_GET_CLIENT_ROAMING_PREFER_SIGNAL_STRENGTH_RESPONSE: 83 - + ACTION_BML_SET_DFS_REENTRY_REQUEST: 84 ACTION_BML_SET_DFS_REENTRY_RESPONSE: 85 ACTION_BML_GET_DFS_REENTRY_REQUEST: 86 @@ -434,7 +433,7 @@ eActionOp_BML: ACTION_BML_CHANGE_MODULE_LOGGING_LEVEL_REQUEST: 140 ACTION_BML_CHANGE_MODULE_LOGGING_LEVEL_RESPONSE: 141 - + ACTION_BML_SET_VAP_LIST_CREDENTIALS_REQUEST: 150 ACTION_BML_SET_VAP_LIST_CREDENTIALS_RESPONSE: 151 ACTION_BML_GET_VAP_LIST_CREDENTIALS_REQUEST: 152 @@ -448,8 +447,8 @@ eActionOp_BML: ACTION_BML_STEERING_EVENT_REGISTER_UNREGISTER_RESPONSE: 168 ACTION_BML_STEERING_CLIENT_DISCONNECT_REQUEST: 169 ACTION_BML_STEERING_CLIENT_DISCONNECT_RESPONSE: 170 - ACTION_BML_STEERING_CLIENT_MEASURE_REQUEST : 171 - ACTION_BML_STEERING_CLIENT_MEASURE_RESPONSE : 172 + ACTION_BML_STEERING_CLIENT_MEASURE_REQUEST: 171 + ACTION_BML_STEERING_CLIENT_MEASURE_RESPONSE: 172 ACTION_BML_STEERING_EVENT_PROBE_REQ_NOTIFICATION: 178 ACTION_BML_STEERING_EVENT_CLIENT_CONNECT_NOTIFICATION: 179 @@ -458,7 +457,7 @@ eActionOp_BML: ACTION_BML_STEERING_EVENT_SNR_XING_NOTIFICATION: 182 ACTION_BML_STEERING_EVENT_SNR_NOTIFICATION: 183 ACTION_BML_STEERING_EVENT_AUTH_FAIL_NOTIFICATION: 184 - ACTION_BML_STEERING_EVENTS_UPDATE : 185 + ACTION_BML_STEERING_EVENTS_UPDATE: 185 ACTION_BML_TRIGGER_CHANNEL_SELECTION_REQUEST: 190 ACTION_BML_TRIGGER_TOPOLOGY_QUERY: 191 @@ -466,19 +465,19 @@ eActionOp_BML: ACTION_BML_REGISTER_TOPOLOGY_QUERY: 193 ACTION_BML_UNREGISTER_TOPOLOGY_QUERY: 194 - ACTION_BML_CHANNEL_SCAN_SET_CONTINUOUS_PARAMS_REQUEST : 200 - ACTION_BML_CHANNEL_SCAN_SET_CONTINUOUS_PARAMS_RESPONSE : 201 - ACTION_BML_CHANNEL_SCAN_GET_CONTINUOUS_PARAMS_REQUEST : 202 - ACTION_BML_CHANNEL_SCAN_GET_CONTINUOUS_PARAMS_RESPONSE : 203 - ACTION_BML_CHANNEL_SCAN_SET_CONTINUOUS_ENABLE_REQUEST : 204 - ACTION_BML_CHANNEL_SCAN_SET_CONTINUOUS_ENABLE_RESPONSE : 205 - ACTION_BML_CHANNEL_SCAN_GET_CONTINUOUS_ENABLE_REQUEST : 206 - ACTION_BML_CHANNEL_SCAN_GET_CONTINUOUS_ENABLE_RESPONSE : 207 - ACTION_BML_CHANNEL_SCAN_START_SCAN_REQUEST : 208 - ACTION_BML_CHANNEL_SCAN_START_SCAN_RESPONSE : 209 - ACTION_BML_CHANNEL_SCAN_GET_RESULTS_REQUEST : 210 - ACTION_BML_CHANNEL_SCAN_GET_RESULTS_RESPONSE : 211 - ACTION_BML_CHANNEL_SCAN_DUMP_RESULTS_REQUEST : 212 - ACTION_BML_CHANNEL_SCAN_DUMP_RESULTS_RESPONSE : 213 + ACTION_BML_CHANNEL_SCAN_SET_CONTINUOUS_PARAMS_REQUEST: 200 + ACTION_BML_CHANNEL_SCAN_SET_CONTINUOUS_PARAMS_RESPONSE: 201 + ACTION_BML_CHANNEL_SCAN_GET_CONTINUOUS_PARAMS_REQUEST: 202 + ACTION_BML_CHANNEL_SCAN_GET_CONTINUOUS_PARAMS_RESPONSE: 203 + ACTION_BML_CHANNEL_SCAN_SET_CONTINUOUS_ENABLE_REQUEST: 204 + ACTION_BML_CHANNEL_SCAN_SET_CONTINUOUS_ENABLE_RESPONSE: 205 + ACTION_BML_CHANNEL_SCAN_GET_CONTINUOUS_ENABLE_REQUEST: 206 + ACTION_BML_CHANNEL_SCAN_GET_CONTINUOUS_ENABLE_RESPONSE: 207 + ACTION_BML_CHANNEL_SCAN_START_SCAN_REQUEST: 208 + ACTION_BML_CHANNEL_SCAN_START_SCAN_RESPONSE: 209 + ACTION_BML_CHANNEL_SCAN_GET_RESULTS_REQUEST: 210 + ACTION_BML_CHANNEL_SCAN_GET_RESULTS_RESPONSE: 211 + ACTION_BML_CHANNEL_SCAN_DUMP_RESULTS_REQUEST: 212 + ACTION_BML_CHANNEL_SCAN_DUMP_RESULTS_RESPONSE: 213 ACTION_BML_ENUM_END: 214 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_apmanager.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_apmanager.yaml index a92dbdeabd..7b0940678a 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_apmanager.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_apmanager.yaml @@ -1,21 +1,18 @@ # --- -_include: { - beerocks/tlvf/beerocks_message_common.h, - tlvf/WSC/WSC_Attributes.h, -} +_include: { beerocks/tlvf/beerocks_message_common.h, tlvf/WSC/WSC_Attributes.h } _namespace: beerocks_message _multi_class: True _multi_class_auto_insert: action_op: _type: eActionOp_APMANAGER - _value_const: [_auto_value_by_name, 1] + _value_const: [_auto_value_by_name, 1] _class_const: True ################################################# ################################################# - + cACTION_APMANAGER_UP_NOTIFICATION: _type: class iface_name_length: @@ -38,13 +35,13 @@ cACTION_APMANAGER_JOINED_NOTIFICATION: _length_var: True preferred_channels: _type: beerocks::message::sWifiChannel - _length: [ preferred_channels_size ] + _length: [preferred_channels_size] supported_channels_size: _type: uint8_t _length_var: True supported_channels: _type: beerocks::message::sWifiChannel - _length: [ supported_channels_size ] + _length: [supported_channels_size] cACTION_APMANAGER_ENABLE_APS_REQUEST: _type: class @@ -109,7 +106,7 @@ cACTION_APMANAGER_HOSTAP_ACS_NOTIFICATION: _length_var: True preferred_channels: _type: beerocks::message::sWifiChannel - _length: [ preferred_channels_size ] + _length: [preferred_channels_size] cACTION_APMANAGER_HOSTAP_DFS_CAC_COMPLETED_NOTIFICATION: _type: class @@ -143,7 +140,7 @@ cACTION_APMANAGER_CLIENT_ASSOCIATED_NOTIFICATION: vap_id: int8_t association_frame: _type: uint8_t - _length: [] + _length: [] cACTION_APMANAGER_CLIENT_DISCONNECTED_NOTIFICATION: _type: class @@ -219,7 +216,7 @@ cACTION_APMANAGER_WIFI_CREDENTIALS_UPDATE_REQUEST: _length_var: True wifi_credentials: _type: WSC::cConfigData - _length: [ wifi_credentials_size ] + _length: [wifi_credentials_size] cACTION_APMANAGER_START_WPS_PBC_REQUEST: _type: class @@ -237,5 +234,4 @@ cACTION_APMANAGER_READ_ACS_REPORT_RESPONSE: _length_var: True preferred_channels: _type: beerocks::message::sWifiChannel - _length: [ preferred_channels_size ] - + _length: [preferred_channels_size] diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml index 42257e6ced..0d1cf6b5da 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml @@ -6,7 +6,7 @@ _multi_class: True _multi_class_auto_insert: action_op: _type: eActionOp_BACKHAUL - _value_const: [_auto_value_by_name, 1] + _value_const: [_auto_value_by_name, 1] _class_const: True ################################################# @@ -16,10 +16,10 @@ cACTION_BACKHAUL_REGISTER_REQUEST: _type: class sta_iface: _type: char - _length: [ "beerocks::message::IFACE_NAME_LENGTH" ] + _length: ["beerocks::message::IFACE_NAME_LENGTH"] hostap_iface: _type: char - _length: [ "beerocks::message::IFACE_NAME_LENGTH" ] + _length: ["beerocks::message::IFACE_NAME_LENGTH"] local_master: uint8_t local_gw: uint8_t sta_iface_filter_low: uint8_t @@ -38,40 +38,40 @@ cACTION_BACKHAUL_ENABLE: iface_mac: sMacAddr wire_iface: _type: char - _length: [ "beerocks::message::IFACE_NAME_LENGTH" ] + _length: ["beerocks::message::IFACE_NAME_LENGTH"] sta_iface: _type: char - _length: [ "beerocks::message::IFACE_NAME_LENGTH" ] + _length: ["beerocks::message::IFACE_NAME_LENGTH"] ssid: _type: char - _length: [ "beerocks::message::WIFI_SSID_MAX_LENGTH" ] + _length: ["beerocks::message::WIFI_SSID_MAX_LENGTH"] pass: _type: char - _length: [ "beerocks::message::WIFI_PASS_MAX_LENGTH" ] + _length: ["beerocks::message::WIFI_PASS_MAX_LENGTH"] security_type: uint32_t # bwl::sta_wlan_hal::Security preferred_bssid: sMacAddr - wire_iface_type: uint8_t - wireless_iface_type: uint8_t + wire_iface_type: uint8_t + wireless_iface_type: uint8_t mem_only_psk: uint8_t backhaul_preferred_radio_band: uint8_t frequency_band: beerocks::eFreqType - max_bandwidth: beerocks::eWiFiBandwidth + max_bandwidth: beerocks::eWiFiBandwidth ht_supported: uint8_t #bool ht_capability: uint16_t ht_mcs_set: _type: uint8_t - _length: [ "beerocks::message::HT_MCS_SET_SIZE" ] + _length: ["beerocks::message::HT_MCS_SET_SIZE"] vht_supported: uint8_t #bool vht_capability: uint32_t vht_mcs_set: _type: uint8_t - _length: [ "beerocks::message::VHT_MCS_SET_SIZE" ] + _length: ["beerocks::message::VHT_MCS_SET_SIZE"] preferred_channels_size: _type: uint8_t _length_var: True preferred_channels: _type: beerocks::message::sWifiChannel - _length: [ preferred_channels_size ] + _length: [preferred_channels_size] cACTION_BACKHAUL_CONNECTED_NOTIFICATION: _type: class @@ -93,7 +93,7 @@ cACTION_BACKHAUL_ROAM_REQUEST: cACTION_BACKHAUL_ROAM_RESPONSE: _type: class - connected: uint8_t + connected: uint8_t cACTION_BACKHAUL_RESET: _type: class @@ -134,8 +134,8 @@ cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION: client_mac: sMacAddr bssid: sMacAddr association_frame: - _type: uint8_t - _length: [] + _type: uint8_t + _length: [] cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION: _type: class @@ -149,7 +149,7 @@ cACTION_BACKHAUL_ASSOCIATED_STA_LINK_METRICS_REQUEST: cACTION_BACKHAUL_ASSOCIATED_STA_LINK_METRICS_RESPONSE: _type: class - _is_tlv_class : True + _is_tlv_class: True length: uint16_t sta_mac: sMacAddr bssid_info_list_length: @@ -157,7 +157,7 @@ cACTION_BACKHAUL_ASSOCIATED_STA_LINK_METRICS_RESPONSE: _length_var: True bssid_info_list: _type: sBssidInfo - _length: [ bssid_info_list_length ] + _length: [bssid_info_list_length] cACTION_BACKHAUL_START_WPS_PBC_REQUEST: _type: class diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_bml.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_bml.yaml index 864163a033..065e0d05f6 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_bml.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_bml.yaml @@ -6,14 +6,14 @@ _multi_class: True _multi_class_auto_insert: action_op: _type: eActionOp_BML - _value_const: [_auto_value_by_name, 1] + _value_const: [_auto_value_by_name, 1] _class_const: True ################################################# ################################################# cACTION_BML_PING_REQUEST: - _type: class + _type: class cACTION_BML_PING_RESPONSE: _type: class @@ -27,9 +27,9 @@ cACTION_BML_NW_MAP_RESPONSE: buffer_size: _type: uint32_t _length_var: True - buffer: + buffer: _type: char - _length: [ buffer_size ] + _length: [buffer_size] cACTION_BML_NW_MAP_UPDATE: _type: class @@ -37,9 +37,9 @@ cACTION_BML_NW_MAP_UPDATE: buffer_size: _type: uint32_t _length_var: True - buffer: + buffer: _type: char - _length: [ buffer_size ] + _length: [buffer_size] cACTION_BML_STATS_UPDATE: _type: class @@ -47,18 +47,18 @@ cACTION_BML_STATS_UPDATE: buffer_size: _type: uint32_t _length_var: True - buffer: + buffer: _type: char - _length: [ buffer_size ] + _length: [buffer_size] cACTION_BML_EVENTS_UPDATE: _type: class buffer_size: _type: uint32_t _length_var: True - buffer: + buffer: _type: char - _length: [ buffer_size ] + _length: [buffer_size] cACTION_BML_REGISTER_TO_NW_MAP_UPDATES_REQUEST: _type: class @@ -79,28 +79,28 @@ cACTION_BML_GET_LEGACY_CLIENT_ROAMING_REQUEST: _type: class cACTION_BML_REGISTER_TO_EVENTS_UPDATES_REQUEST: - _type: class + _type: class cACTION_BML_REGISTER_TO_EVENTS_UPDATES_RESPONSE: - _type: class + _type: class cACTION_BML_UNREGISTER_FROM_EVENTS_UPDATES_REQUEST: - _type: class + _type: class cACTION_BML_UNREGISTER_FROM_EVENTS_UPDATES_RESPONSE: - _type: class + _type: class cACTION_BML_REGISTER_TO_STATS_UPDATES_REQUEST: - _type: class + _type: class cACTION_BML_REGISTER_TO_STATS_UPDATES_RESPONSE: - _type: class + _type: class cACTION_BML_UNREGISTER_FROM_STATS_UPDATES_REQUEST: - _type: class + _type: class cACTION_BML_UNREGISTER_FROM_STATS_UPDATES_RESPONSE: - _type: class + _type: class cACTION_BML_SET_LEGACY_CLIENT_ROAMING_REQUEST: _type: class @@ -109,16 +109,16 @@ cACTION_BML_SET_LEGACY_CLIENT_ROAMING_REQUEST: cACTION_BML_GET_LEGACY_CLIENT_ROAMING_RESPONSE: _type: class isEnable: uint8_t - + cACTION_BML_SET_CLIENT_ROAMING_REQUEST: _type: class isEnable: uint8_t cACTION_BML_SET_CLIENT_ROAMING_RESPONSE: _type: class - + cACTION_BML_GET_CLIENT_ROAMING_REQUEST: - _type: class + _type: class cACTION_BML_GET_CLIENT_ROAMING_RESPONSE: _type: class @@ -130,9 +130,9 @@ cACTION_BML_SET_DFS_REENTRY_REQUEST: cACTION_BML_SET_DFS_REENTRY_RESPONSE: _type: class - + cACTION_BML_GET_DFS_REENTRY_REQUEST: - _type: class + _type: class cACTION_BML_GET_DFS_REENTRY_RESPONSE: _type: class @@ -227,19 +227,19 @@ cACTION_BML_WIFI_CREDENTIALS_SET_REQUEST: _length_var: True ssid: _type: char - _length: [ ssid_size ] + _length: [ssid_size] network_key_size: _type: uint8_t _length_var: True network_key: _type: char - _length: [ network_key_size ] + _length: [network_key_size] operating_classes_size: _type: uint8_t _length_var: True operating_classes: _type: uint8_t - _length: [ operating_classes_size ] + _length: [operating_classes_size] cACTION_BML_WIFI_CREDENTIALS_SET_RESPONSE: _type: class @@ -276,37 +276,37 @@ cACTION_BML_GET_CERTIFICATION_MODE_RESPONSE: isEnable: uint8_t cACTION_BML_SET_VAP_LIST_CREDENTIALS_REQUEST: - _type: class + _type: class result: _type: uint32_t - _comment: # 0 - Failure, 1 - Success + _comment: # 0 - Failure, 1 - Success vap_list_size: _type: uint8_t _length_var: True vap_list: _type: sConfigVapInfo - _length: [ vap_list_size ] + _length: [vap_list_size] cACTION_BML_SET_VAP_LIST_CREDENTIALS_RESPONSE: - _type: class + _type: class result: _type: uint32_t - _comment: # 0 - Failure, 1 - Success - + _comment: # 0 - Failure, 1 - Success + cACTION_BML_GET_VAP_LIST_CREDENTIALS_RESPONSE: - _type: class + _type: class result: _type: uint32_t - _comment: # 0 - Failure, 1 - Success + _comment: # 0 - Failure, 1 - Success vap_list_size: _type: uint8_t _length_var: True vap_list: _type: sConfigVapInfo - _length: [ vap_list_size ] - + _length: [vap_list_size] + cACTION_BML_GET_VAP_LIST_CREDENTIALS_REQUEST: - _type: class + _type: class result: _type: uint32_t _comment: # 0 - Failure, 1 - Success @@ -320,7 +320,7 @@ cACTION_BML_STEERING_SET_GROUP_REQUEST: cACTION_BML_STEERING_SET_GROUP_RESPONSE: _type: class - error_code: int32_t + error_code: int32_t cACTION_BML_STEERING_CLIENT_SET_REQUEST: _type: class @@ -339,7 +339,7 @@ cACTION_BML_STEERING_EVENT_REGISTER_UNREGISTER_REQUEST: unregister: uint8_t cACTION_BML_STEERING_EVENT_REGISTER_UNREGISTER_RESPONSE: - _type: class + _type: class error_code: int32_t cACTION_BML_STEERING_CLIENT_DISCONNECT_REQUEST: @@ -351,7 +351,7 @@ cACTION_BML_STEERING_CLIENT_DISCONNECT_REQUEST: reason: uint32_t cACTION_BML_STEERING_CLIENT_DISCONNECT_RESPONSE: - _type: class + _type: class error_code: int32_t cACTION_BML_STEERING_CLIENT_MEASURE_REQUEST: @@ -361,7 +361,7 @@ cACTION_BML_STEERING_CLIENT_MEASURE_REQUEST: client_mac: sMacAddr cACTION_BML_STEERING_CLIENT_MEASURE_RESPONSE: - _type: class + _type: class error_code: int32_t ################################################ @@ -372,9 +372,9 @@ cACTION_BML_STEERING_EVENTS_UPDATE: buffer_size: _type: uint32_t _length_var: True - buffer: + buffer: _type: char - _length: [ buffer_size ] + _length: [buffer_size] cACTION_BML_TRIGGER_TOPOLOGY_QUERY: _type: class @@ -385,7 +385,7 @@ cACTION_BML_TOPOLOGY_RESPONSE: device_data: sDeviceData result: _type: uint32_t - _comment: # 0 - Failure, 1 - Success + _comment: # 0 - Failure, 1 - Success cACTION_BML_REGISTER_TOPOLOGY_QUERY: _type: class @@ -469,7 +469,7 @@ cACTION_BML_CHANNEL_SCAN_GET_RESULTS_RESPONSE: _length_var: True results: _type: sChannelScanResults - _length: [ results_size ] + _length: [results_size] cACTION_BML_CHANNEL_SCAN_DUMP_RESULTS_REQUEST: _type: class diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml index a4d9261105..b27cc65e4f 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml @@ -1,15 +1,16 @@ # --- -_include: { - beerocks/tlvf/beerocks_message_common.h, - beerocks/tlvf/beerocks_message_cli_net_map.h, -} +_include: + { + beerocks/tlvf/beerocks_message_common.h, + beerocks/tlvf/beerocks_message_cli_net_map.h, + } _namespace: beerocks_message _multi_class: True _multi_class_auto_insert: action_op: _type: eActionOp_CLI - _value_const: [_auto_value_by_name, 1] + _value_const: [_auto_value_by_name, 1] _class_const: True ################################################# @@ -41,9 +42,9 @@ cACTION_CLI_RESPONSE_STR: buffer_size: _type: uint32_t _length_var: True - buffer: + buffer: _type: char - _length: [ buffer_size ] + _length: [buffer_size] cACTION_CLI_CROSS_RX_RSSI_MEASUREMENT: _type: class @@ -127,22 +128,22 @@ cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST: cACTION_CLI_CLIENT_BEACON_11K_REQUEST: _type: class - client_mac: sMacAddr - bssid: sMacAddr + client_mac: sMacAddr + bssid: sMacAddr ssid: - _type: uint8_t - _length: [ "beerocks::message::WIFI_SSID_MAX_LENGTH" ] - use_optional_ssid: uint8_t - channel: uint8_t - measurement_mode: uint8_t - duration: uint16_t - rand_ival: uint16_t - repeats: uint16_t - op_class: int16_t + _type: uint8_t + _length: ["beerocks::message::WIFI_SSID_MAX_LENGTH"] + use_optional_ssid: uint8_t + channel: uint8_t + measurement_mode: uint8_t + duration: uint16_t + rand_ival: uint16_t + repeats: uint16_t + op_class: int16_t cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST: _type: class - hostap_mac: sMacAddr + hostap_mac: sMacAddr client_mac: sMacAddr peer_mac: sMacAddr group_identity: uint8_t diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli_net_map.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli_net_map.yaml index 37db87c93f..c04cff6c27 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli_net_map.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli_net_map.yaml @@ -17,23 +17,23 @@ sCliNetworkMapNodeSta: sCliNetworkMapsNodeInfo: _type: struct - mac: sMacAddr - ipv4: beerocks::net::sIpv4Addr + mac: sMacAddr + ipv4: beerocks::net::sIpv4Addr name: - _type: char - _length: [ "beerocks::message::NODE_NAME_LENGTH" ] - type: uint8_t - state: uint8_t - channel: uint8_t - bandwidth: uint8_t #beerocks::eWiFiBandwidth - channel_ext_above_secondary: uint8_t - is_dfs: uint8_t - cac_completed: uint8_t - tx_bytes: uint32_t - rx_bytes: uint32_t - stats_delta_ms: uint16_t - tx_load_percent: uint8_t # for HOSTAP it is the total sta tx_load - rx_load_percent: uint8_t # for HOSTAP it is the total sta rx_load - channel_load_percent: uint8_t # only for HOSTAP - iface_type: uint8_t #eIfaceType - vap_id: int8_t + _type: char + _length: ["beerocks::message::NODE_NAME_LENGTH"] + type: uint8_t + state: uint8_t + channel: uint8_t + bandwidth: uint8_t #beerocks::eWiFiBandwidth + channel_ext_above_secondary: uint8_t + is_dfs: uint8_t + cac_completed: uint8_t + tx_bytes: uint32_t + rx_bytes: uint32_t + stats_delta_ms: uint16_t + tx_load_percent: uint8_t # for HOSTAP it is the total sta tx_load + rx_load_percent: uint8_t # for HOSTAP it is the total sta rx_load + channel_load_percent: uint8_t # only for HOSTAP + iface_type: uint8_t #eIfaceType + vap_id: int8_t diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml index f2525acc42..ada2ccef08 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml @@ -6,7 +6,7 @@ _multi_class: True _multi_class_auto_insert: action_op: _type: eActionOp_CONTROL - _value_const: [_auto_value_by_name, 1] + _value_const: [_auto_value_by_name, 1] _class_const: True ################################################# @@ -17,59 +17,59 @@ _multi_class_auto_insert: ################################################# cACTION_CONTROL_SLAVE_HANDSHAKE_REQUEST: - _type: class + _type: class cACTION_CONTROL_SLAVE_HANDSHAKE_RESPONSE: - _type: class + _type: class cACTION_CONTROL_SLAVE_JOINED_NOTIFICATION: _type: class slave_version: _type: char - _length: [ "beerocks::message::VERSION_LENGTH" ] + _length: ["beerocks::message::VERSION_LENGTH"] platform_settings: sPlatformSettings - wlan_settings: sWlanSettings - backhaul_params: sBackhaulParams - hostap: sNodeHostap - cs_params: sApChannelSwitch - low_pass_filter_on: uint8_t # configuration - enable_repeater_mode: uint8_t + wlan_settings: sWlanSettings + backhaul_params: sBackhaulParams + hostap: sNodeHostap + cs_params: sApChannelSwitch + low_pass_filter_on: uint8_t # configuration + enable_repeater_mode: uint8_t radio_identifier: sMacAddr is_slave_reconf: uint8_t cACTION_CONTROL_SLAVE_JOINED_RESPONSE: _type: class master_version: - _type: char - _length: [ "beerocks::message::VERSION_LENGTH" ] - err_code: uint8_t #beerocks::eSlaveJoinResponseErrCode - config: sSonConfig + _type: char + _length: ["beerocks::message::VERSION_LENGTH"] + err_code: uint8_t #beerocks::eSlaveJoinResponseErrCode + config: sSonConfig cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION: _type: class - backhaul_iface_mac: sMacAddr - backhaul_ipv4: beerocks::net::sIpv4Addr - bridge_iface_mac: sMacAddr - bridge_ipv4: beerocks::net::sIpv4Addr - hostap: sNodeHostap + backhaul_iface_mac: sMacAddr + backhaul_ipv4: beerocks::net::sIpv4Addr + bridge_iface_mac: sMacAddr + bridge_ipv4: beerocks::net::sIpv4Addr + hostap: sNodeHostap cACTION_CONTROL_SON_CONFIG_UPDATE: _type: class - config: sSonConfig + config: sSonConfig cACTION_CONTROL_CONTROLLER_PING_REQUEST: _type: class - total: uint16_t - seq: uint16_t - size: uint16_t + total: uint16_t + seq: uint16_t + size: uint16_t data: _type: uint8_t _length: [] cACTION_CONTROL_CONTROLLER_PING_RESPONSE: _type: class - total: uint16_t - seq: uint16_t + total: uint16_t + seq: uint16_t size: uint16_t data: _type: uint8_t @@ -77,17 +77,17 @@ cACTION_CONTROL_CONTROLLER_PING_RESPONSE: cACTION_CONTROL_AGENT_PING_REQUEST: _type: class - total: uint16_t - seq: uint16_t - size: uint16_t + total: uint16_t + seq: uint16_t + size: uint16_t data: _type: uint8_t _length: [] cACTION_CONTROL_AGENT_PING_RESPONSE: _type: class - total: uint16_t - seq: uint16_t + total: uint16_t + seq: uint16_t size: uint16_t data: _type: uint8_t @@ -95,31 +95,31 @@ cACTION_CONTROL_AGENT_PING_RESPONSE: cACTION_CONTROL_ARP_QUERY_REQUEST: _type: class - params: sArpQuery + params: sArpQuery cACTION_CONTROL_ARP_QUERY_RESPONSE: _type: class - params: sArpMonitorData + params: sArpMonitorData cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION: _type: class - bridge_mac: sMacAddr - operational: uint8_t + bridge_mac: sMacAddr + operational: uint8_t cACTION_CONTROL_BACKHAUL_DL_RSSI_REPORT_NOTIFICATION: _type: class - params: sBackhaulRssi + params: sBackhaulRssi cACTION_CONTROL_BACKHAUL_RESET: _type: class cACTION_CONTROL_BACKHAUL_ROAM_REQUEST: _type: class - params: sBackhaulRoam + params: sBackhaulRoam cACTION_CONTROL_CHANGE_MODULE_LOGGING_LEVEL: _type: class - params: sLoggingLevelChange + params: sLoggingLevelChange ################################################# # HOSTAP @@ -127,95 +127,95 @@ cACTION_CONTROL_CHANGE_MODULE_LOGGING_LEVEL: cACTION_CONTROL_HOSTAP_CSA_ERROR_NOTIFICATION: _type: class - cs_params: sApChannelSwitch + cs_params: sApChannelSwitch cACTION_CONTROL_HOSTAP_CSA_NOTIFICATION: _type: class - cs_params: sApChannelSwitch + cs_params: sApChannelSwitch cACTION_CONTROL_HOSTAP_ACS_ERROR_NOTIFICATION: _type: class - cs_params: sApChannelSwitch + cs_params: sApChannelSwitch cACTION_CONTROL_HOSTAP_ACS_NOTIFICATION: _type: class - cs_params: sApChannelSwitch + cs_params: sApChannelSwitch preferred_channels_size: _type: uint8_t _length_var: True preferred_channels: _type: beerocks::message::sWifiChannel - _length: [ preferred_channels_size ] + _length: [preferred_channels_size] cACTION_CONTROL_HOSTAP_DFS_CAC_COMPLETED_NOTIFICATION: _type: class - params: sDfsCacCompleted + params: sDfsCacCompleted cACTION_CONTROL_HOSTAP_DFS_CHANNEL_AVAILABLE_NOTIFICATION: _type: class - params: sDfsChannelAvailable + params: sDfsChannelAvailable cACTION_CONTROL_HOSTAP_SET_RESTRICTED_FAILSAFE_CHANNEL_REQUEST: _type: class - params: sApSetRestrictedFailsafe + params: sApSetRestrictedFailsafe cACTION_CONTROL_HOSTAP_SET_RESTRICTED_FAILSAFE_CHANNEL_RESPONSE: _type: class - success: uint8_t + success: uint8_t cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_ACS_START: _type: class - cs_params: sApChannelSwitch + cs_params: sApChannelSwitch cACTION_CONTROL_HOSTAP_UPDATE_STOP_ON_FAILURE_ATTEMPTS_REQUEST: _type: class - attempts: uint32_t + attempts: uint32_t cACTION_CONTROL_HOSTAP_DISABLED_BY_MASTER: _type: class cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST: _type: class - cs_params: sApChannelSwitch + cs_params: sApChannelSwitch cACTION_CONTROL_HOSTAP_STATS_MEASUREMENT_REQUEST: _type: class - sync: uint8_t + sync: uint8_t cACTION_CONTROL_HOSTAP_STATS_MEASUREMENT_RESPONSE: _type: class ap_stats_size: _type: uint8_t _length_var: True - ap_stats: + ap_stats: _type: sApStatsParams - _length: [ ap_stats_size ] + _length: [ap_stats_size] sta_stats_size: _type: uint8_t _length_var: True sta_stats: _type: sStaStatsParams - _length: [ sta_stats_size ] + _length: [sta_stats_size] cACTION_CONTROL_HOSTAP_LOAD_MEASUREMENT_NOTIFICATION: _type: class - params: sApLoadNotificationParams + params: sApLoadNotificationParams cACTION_CONTROL_HOSTAP_SET_NEIGHBOR_11K_REQUEST: _type: class - params: sNeighborSetParams11k + params: sNeighborSetParams11k cACTION_CONTROL_HOSTAP_REMOVE_NEIGHBOR_11K_REQUEST: _type: class - params: sNeighborRemoveParams11k + params: sNeighborRemoveParams11k cACTION_CONTROL_HOSTAP_ACTIVITY_NOTIFICATION: _type: class - params: sApActivityNotificationParams + params: sApActivityNotificationParams cACTION_CONTROL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION: _type: class - params: sVapsList + params: sVapsList cACTION_CONTROL_HOSTAP_AP_DISABLED_NOTIFICATION: _type: class @@ -226,26 +226,24 @@ cACTION_CONTROL_HOSTAP_AP_ENABLED_NOTIFICATION: vap_id: int8_t vap_info: sVapInfo - ################################################# # CLIENT ################################################# cACTION_CONTROL_CLIENT_START_MONITORING_REQUEST: _type: class - params: sClientMonitoringParams + params: sClientMonitoringParams - cACTION_CONTROL_CLIENT_START_MONITORING_RESPONSE: _type: class success: uint8_t cACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_REQUEST: _type: class - params: sNodeRssiMeasurementRequest + params: sNodeRssiMeasurementRequest cACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_RESPONSE: _type: class - params: sNodeRssiMeasurement + params: sNodeRssiMeasurement cACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_START_NOTIFICATION: _type: class @@ -253,28 +251,28 @@ cACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_START_NOTIFICATION: cACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE: _type: class - mac: sMacAddr + mac: sMacAddr cACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_NOTIFICATION: _type: class - params: sNodeRssiMeasurement + params: sNodeRssiMeasurement cACTION_CONTROL_CLIENT_NO_ACTIVITY_NOTIFICATION: _type: class - mac: sMacAddr + mac: sMacAddr cACTION_CONTROL_CLIENT_NO_RESPONSE_NOTIFICATION: _type: class - mac: sMacAddr + mac: sMacAddr cACTION_CONTROL_CLIENT_NEW_IP_ADDRESS_NOTIFICATION: _type: class mac: sMacAddr - ipv4: beerocks::net::sIpv4Addr + ipv4: beerocks::net::sIpv4Addr cACTION_CONTROL_CLIENT_DISCONNECT_REQUEST: _type: class - mac: sMacAddr + mac: sMacAddr vap_id: int8_t type: eDisconnectType reason: uint32_t @@ -285,43 +283,43 @@ cACTION_CONTROL_CLIENT_DISCONNECT_RESPONSE: cACTION_CONTROL_CLIENT_DHCP_COMPLETE_NOTIFICATION: _type: class - mac: sMacAddr - ipv4: beerocks::net::sIpv4Addr - name: - _type: char - _length: [ "beerocks::message::NODE_NAME_LENGTH" ] + mac: sMacAddr + ipv4: beerocks::net::sIpv4Addr + name: + _type: char + _length: ["beerocks::message::NODE_NAME_LENGTH"] cACTION_CONTROL_CLIENT_ARP_MONITOR_NOTIFICATION: _type: class - params: sArpMonitorData + params: sArpMonitorData cACTION_CONTROL_CLIENT_BEACON_11K_REQUEST: _type: class - params: sBeaconRequest11k + params: sBeaconRequest11k cACTION_CONTROL_CLIENT_BEACON_11K_RESPONSE: _type: class - params: sBeaconResponse11k + params: sBeaconResponse11k cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST: _type: class - params: sStaChannelLoadRequest11k + params: sStaChannelLoadRequest11k cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE: _type: class - params: sStaChannelLoadResponse11k + params: sStaChannelLoadResponse11k cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST: _type: class - params: sStatisticsRequest11k + params: sStatisticsRequest11k cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE: _type: class - params: sStatisticsResponse11k + params: sStatisticsResponse11k cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST: _type: class - mac: sMacAddr + mac: sMacAddr cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE: _type: class @@ -330,19 +328,19 @@ cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE: ################################################# # MONITOR RDKB CONFIGURATIONS ################################################# -cACTION_CONTROL_STEERING_CLIENT_SET_GROUP_REQUEST: +cACTION_CONTROL_STEERING_CLIENT_SET_GROUP_REQUEST: _type: class params: sSteeringSetGroupRequest -cACTION_CONTROL_STEERING_CLIENT_SET_GROUP_RESPONSE: +cACTION_CONTROL_STEERING_CLIENT_SET_GROUP_RESPONSE: _type: class params: sSteeringSetGroupResponse -cACTION_CONTROL_STEERING_CLIENT_SET_REQUEST: +cACTION_CONTROL_STEERING_CLIENT_SET_REQUEST: _type: class params: sSteeringClientSetRequest -cACTION_CONTROL_STEERING_CLIENT_SET_RESPONSE: +cACTION_CONTROL_STEERING_CLIENT_SET_RESPONSE: _type: class params: sSteeringClientSetResponse ################################################ @@ -353,18 +351,18 @@ cACTION_CONTROL_STEERING_EVENT_CLIENT_ACTIVITY_NOTIFICATION: params: sSteeringEvActivity cACTION_CONTROL_STEERING_EVENT_SNR_XING_NOTIFICATION: - _type: class + _type: class params: sSteeringEvSnrXing ################################################ # AP_MANAGER RDKB NOTIFICATIONS(softblock) ################################################# cACTION_CONTROL_STEERING_EVENT_PROBE_REQ_NOTIFICATION: - _type: class + _type: class params: sSteeringEvProbeReq cACTION_CONTROL_STEERING_EVENT_AUTH_FAIL_NOTIFICATION: - _type: class + _type: class params: sSteeringEvAuthFail ################################################ diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_header.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_header.yaml index 1fb66d6ca7..9c163da338 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_header.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_header.yaml @@ -1,10 +1,11 @@ # --- _namespace: beerocks_message -_include: { - beerocks/tlvf/beerocks_message_common.h, - beerocks/tlvf/beerocks_message_action.h, -} +_include: + { + beerocks/tlvf/beerocks_message_common.h, + beerocks/tlvf/beerocks_message_action.h, + } cACTION_HEADER: _type: class @@ -14,11 +15,11 @@ cACTION_HEADER: version: _type: uint8_t _value_const: "beerocks::message::MESSAGE_VERSION" - action: eAction + action: eAction action_op: _type: uint8_t _comment: need to cast eActionOp_XXXX to uint8_t - direction: + direction: _type: uint8_t _value: 1 #BEEROCKS_DIRECTION_AGENT radio_mac: sMacAddr diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml index 4ff77ec5ef..55c1ce0db5 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml @@ -6,7 +6,7 @@ _multi_class: True _multi_class_auto_insert: action_op: _type: eActionOp_MONITOR - _value_const: [_auto_value_by_name, 1] + _value_const: [_auto_value_by_name, 1] _class_const: True ################################################# @@ -20,15 +20,15 @@ cACTION_MONITOR_JOINED_NOTIFICATION: cACTION_MONITOR_SON_CONFIG_UPDATE: _type: class - config: sSonConfig + config: sSonConfig cACTION_MONITOR_CHANGE_MODULE_LOGGING_LEVEL: _type: class - params: sLoggingLevelChange + params: sLoggingLevelChange cACTION_MONITOR_ERROR_NOTIFICATION: _type: class - error_code: uint32_t + error_code: uint32_t cACTION_MONITOR_ERROR_NOTIFICATION_ACK: _type: class @@ -42,7 +42,7 @@ cACTION_MONITOR_HEARTBEAT_NOTIFICATION: cACTION_MONITOR_CLIENT_START_MONITORING_REQUEST: _type: class - params: sClientMonitoringParams + params: sClientMonitoringParams cACTION_MONITOR_CLIENT_START_MONITORING_RESPONSE: _type: class @@ -50,41 +50,41 @@ cACTION_MONITOR_CLIENT_START_MONITORING_RESPONSE: cACTION_MONITOR_CLIENT_RX_RSSI_MEASUREMENT_REQUEST: _type: class - params: sNodeRssiMeasurementRequest + params: sNodeRssiMeasurementRequest cACTION_MONITOR_CLIENT_DISCONNECT_REQUEST: _type: class - mac: sMacAddr - ipv4: beerocks::net::sIpv4Addr - channel: uint8_t + mac: sMacAddr + ipv4: beerocks::net::sIpv4Addr + channel: uint8_t cACTION_MONITOR_CLIENT_RX_RSSI_MEASUREMENT_NOTIFICATION: _type: class - params: sNodeRssiMeasurement - + params: sNodeRssiMeasurement + cACTION_MONITOR_CLIENT_RX_RSSI_MEASUREMENT_RESPONSE: _type: class - params: sNodeRssiMeasurement + params: sNodeRssiMeasurement cACTION_MONITOR_CLIENT_NO_RESPONSE_NOTIFICATION: _type: class - mac: sMacAddr + mac: sMacAddr cACTION_MONITOR_CLIENT_RX_RSSI_MEASUREMENT_START_NOTIFICATION: _type: class - mac: sMacAddr - + mac: sMacAddr + cACTION_MONITOR_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE: _type: class - mac: sMacAddr + mac: sMacAddr cACTION_MONITOR_CLIENT_NO_ACTIVITY_NOTIFICATION: _type: class - mac: sMacAddr + mac: sMacAddr cACTION_MONITOR_HOSTAP_ACTIVITY_NOTIFICATION: _type: class - params: sApActivityNotificationParams + params: sApActivityNotificationParams cACTION_MONITOR_CLIENT_ASSOCIATED_STA_LINK_METRIC_REQUEST: _type: class @@ -93,7 +93,7 @@ cACTION_MONITOR_CLIENT_ASSOCIATED_STA_LINK_METRIC_REQUEST: cACTION_MONITOR_CLIENT_ASSOCIATED_STA_LINK_METRIC_RESPONSE: _type: class - _is_tlv_class : True + _is_tlv_class: True length: uint16_t sta_mac: sMacAddr bssid_info_list_length: @@ -101,7 +101,7 @@ cACTION_MONITOR_CLIENT_ASSOCIATED_STA_LINK_METRIC_RESPONSE: _length_var: True bssid_info_list: _type: sBssidInfo - _length: [ bssid_info_list_length ] + _length: [bssid_info_list_length] ################################################# # HOSTAP @@ -109,7 +109,7 @@ cACTION_MONITOR_CLIENT_ASSOCIATED_STA_LINK_METRIC_RESPONSE: cACTION_MONITOR_HOSTAP_STATS_MEASUREMENT_REQUEST: _type: class - sync: uint8_t + sync: uint8_t cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION: _type: class @@ -121,76 +121,76 @@ cACTION_MONITOR_HOSTAP_STATS_MEASUREMENT_RESPONSE: ap_stats_size: _type: uint8_t _length_var: True - ap_stats: + ap_stats: _type: sApStatsParams - _length: [ ap_stats_size ] + _length: [ap_stats_size] sta_stats_size: _type: uint8_t _length_var: True sta_stats: _type: sStaStatsParams - _length: [ sta_stats_size ] + _length: [sta_stats_size] cACTION_MONITOR_HOSTAP_LOAD_MEASUREMENT_NOTIFICATION: _type: class - params: sApLoadNotificationParams + params: sApLoadNotificationParams cACTION_MONITOR_CLIENT_BEACON_11K_REQUEST: _type: class - params: sBeaconRequest11k + params: sBeaconRequest11k cACTION_MONITOR_CLIENT_BEACON_11K_RESPONSE: _type: class - params: sBeaconResponse11k + params: sBeaconResponse11k cACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_REQUEST: _type: class - params: sStaChannelLoadRequest11k + params: sStaChannelLoadRequest11k cACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_RESPONSE: _type: class - params: sStaChannelLoadResponse11k + params: sStaChannelLoadResponse11k cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST: _type: class - params: sStatisticsRequest11k + params: sStatisticsRequest11k cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE: _type: class - params: sStatisticsResponse11k + params: sStatisticsResponse11k cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST: _type: class - mac: sMacAddr + mac: sMacAddr cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE: _type: class - params: sLinkMeasurementsResponse11k + params: sLinkMeasurementsResponse11k cACTION_MONITOR_CLIENT_NEW_IP_ADDRESS_NOTIFICATION: _type: class mac: sMacAddr - ipv4: beerocks::net::sIpv4Addr + ipv4: beerocks::net::sIpv4Addr ################################################# # CLIENT MONITOR RDKB HAL ################################################# -cACTION_MONITOR_STEERING_CLIENT_SET_GROUP_REQUEST: +cACTION_MONITOR_STEERING_CLIENT_SET_GROUP_REQUEST: _type: class params: sSteeringSetGroupRequest -cACTION_MONITOR_STEERING_CLIENT_SET_GROUP_RESPONSE: +cACTION_MONITOR_STEERING_CLIENT_SET_GROUP_RESPONSE: _type: class params: sSteeringSetGroupResponse -cACTION_MONITOR_STEERING_CLIENT_SET_REQUEST: +cACTION_MONITOR_STEERING_CLIENT_SET_REQUEST: _type: class params: sSteeringClientSetRequest -cACTION_MONITOR_STEERING_CLIENT_SET_RESPONSE: +cACTION_MONITOR_STEERING_CLIENT_SET_RESPONSE: _type: class params: sSteeringClientSetResponse - + cACTION_MONITOR_STEERING_EVENT_CLIENT_ACTIVITY_NOTIFICATION: _type: class params: sSteeringEvActivity @@ -231,4 +231,3 @@ cACTION_MONITOR_CHANNEL_SCAN_ABORT_NOTIFICATION: cACTION_MONITOR_CHANNEL_SCAN_FINISHED_NOTIFICATION: _type: class - diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_platform.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_platform.yaml index 1714cd2df6..b45ffa1bc3 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_platform.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_platform.yaml @@ -6,7 +6,7 @@ _multi_class: True _multi_class_auto_insert: action_op: _type: eActionOp_PLATFORM - _value_const: [_auto_value_by_name, 1] + _value_const: [_auto_value_by_name, 1] _class_const: True ################################################# @@ -19,72 +19,72 @@ cACTION_PLATFORM_SON_SLAVE_BACKHAUL_CONNECTION_COMPLETE_NOTIFICATION: cACTION_PLATFORM_SON_SLAVE_REGISTER_REQUEST: _type: class iface_name: - _type: char - _length: [ "beerocks::message::IFACE_NAME_LENGTH" ] + _type: char + _length: ["beerocks::message::IFACE_NAME_LENGTH"] cACTION_PLATFORM_SON_SLAVE_REGISTER_RESPONSE: _type: class - platform_settings: sPlatformSettings - wlan_settings: sWlanSettings + platform_settings: sPlatformSettings + wlan_settings: sWlanSettings valid: _type: uint32_t _comment: #Marks whether the settings are valid cACTION_PLATFORM_ARP_MONITOR_NOTIFICATION: _type: class - params: sArpMonitorData + params: sArpMonitorData cACTION_PLATFORM_WLAN_PARAMS_CHANGED_NOTIFICATION: _type: class - wlan_settings: sWlanSettings + wlan_settings: sWlanSettings cACTION_PLATFORM_DHCP_MONITOR_NOTIFICATION: _type: class dhcp_op: eDHCPOp - op: uint32_t - mac: sMacAddr - ipv4: beerocks::net::sIpv4Addr - hostname: - _type: char - _length: [ "beerocks::message::NODE_NAME_LENGTH" ] + op: uint32_t + mac: sMacAddr + ipv4: beerocks::net::sIpv4Addr + hostname: + _type: char + _length: ["beerocks::message::NODE_NAME_LENGTH"] cACTION_PLATFORM_CHANGE_MODULE_LOGGING_LEVEL: _type: class - params: sLoggingLevelChange + params: sLoggingLevelChange cACTION_PLATFORM_ARP_QUERY_REQUEST: _type: class - params: sArpQuery + params: sArpQuery cACTION_PLATFORM_ARP_QUERY_RESPONSE: _type: class - params: sArpMonitorData + params: sArpMonitorData cACTION_PLATFORM_ONBOARD_QUERY_REQUEST: _type: class cACTION_PLATFORM_ONBOARD_QUERY_RESPONSE: _type: class - params: sOnboarding + params: sOnboarding cACTION_PLATFORM_ONBOARD_SET_REQUEST: _type: class - params: sOnboarding + params: sOnboarding cACTION_PLATFORM_WPS_ONBOARDING_REQUEST: _type: class - iface_name: - _type: char - _length: [ "beerocks::message::IFACE_NAME_LENGTH" ] + iface_name: + _type: char + _length: ["beerocks::message::IFACE_NAME_LENGTH"] cACTION_PLATFORM_WIFI_CREDENTIALS_GET_REQUEST: _type: class - vap_id: uint8_t + vap_id: uint8_t cACTION_PLATFORM_WIFI_CREDENTIALS_GET_RESPONSE: _type: class - front_params: sWifiCredentials - back_params: sWifiCredentials + front_params: sWifiCredentials + back_params: sWifiCredentials result: _type: uint32_t _comment: # 0 - Failure, 1 - Success @@ -94,7 +94,7 @@ cACTION_PLATFORM_ADMIN_CREDENTIALS_GET_REQUEST: cACTION_PLATFORM_ADMIN_CREDENTIALS_GET_RESPONSE: _type: class - params: sAdminCredentials + params: sAdminCredentials result: _type: uint32_t _comment: # 0 - Failure, 1 - Success @@ -104,7 +104,7 @@ cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST: cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE: _type: class - params: sDeviceInfo + params: sDeviceInfo result: _type: uint32_t _comment: # 0 - Failure, 1 - Success @@ -114,31 +114,31 @@ cACTION_PLATFORM_LOCAL_MASTER_GET_REQUEST: cACTION_PLATFORM_LOCAL_MASTER_GET_RESPONSE: _type: class - local_master: uint8_t + local_master: uint8_t cACTION_PLATFORM_VERSION_MISMATCH_NOTIFICATION: _type: class - versions: sVersions + versions: sVersions cACTION_PLATFORM_MASTER_SLAVE_VERSIONS_NOTIFICATION: _type: class - versions: sVersions + versions: sVersions cACTION_PLATFORM_GET_MASTER_SLAVE_VERSIONS_REQUEST: _type: class cACTION_PLATFORM_GET_MASTER_SLAVE_VERSIONS_RESPONSE: _type: class - versions: sVersions + versions: sVersions result: _type: uint32_t _comment: # 0 - Failure, 1 - Success cACTION_PLATFORM_ERROR_NOTIFICATION: _type: class - code: uint32_t - data: - _type: char - _length: [ 256 ] + code: uint32_t + data: + _type: char + _length: [256] _comment: # Must match BPL_ERROR_STRING_LEN From adb722fae9f21093f996851ff07b4409037287e7 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 11 Jun 2020 13:50:14 +0300 Subject: [PATCH 026/453] documentation: agent: Add UML diaram for Backhaul STA steering According to the test plan and source code create the UML diagram which describes data flow and methods for Backhaul STA steering. Signed-off-by: Vladyslav Tupikin --- .../plantuml/agent/flows/bh_sta_steering.png | Bin 0 -> 44889 bytes .../plantuml/agent/flows/bh_sta_steering.puml | 19 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 documentation/images/plantuml/agent/flows/bh_sta_steering.png create mode 100644 documentation/images/plantuml/agent/flows/bh_sta_steering.puml diff --git a/documentation/images/plantuml/agent/flows/bh_sta_steering.png b/documentation/images/plantuml/agent/flows/bh_sta_steering.png new file mode 100644 index 0000000000000000000000000000000000000000..a4b9f7e837851f718aa571fa42c4d4179207f722 GIT binary patch literal 44889 zcmcG0byU>t+b1f5idZN}iwKGcNDD})bV^G%%23i>qN36vT>=tADkY7IbPq!ch%`ud z&RzrR^Zed-_nh6cyZ`7BXTEXAb$#mQ^+Q=P!c%0YaBy%4CB%glaBy(NaBz;!oHz|mITWxvq5mkW$b)DurqaQkGRgzyW~)F9ppJ-ba4 zA(>go|3Z0A%R%tU)`r&8b0^zxDzhjDu2=3fH&?RT7~SgWRyOjb(3y}_&u+ZH`Qj*v zbn?BXQ@gcVCJx7G{W*J1X#bqSStPZ2d|sAM{yLs-ZIOmyreI~Wfd%pYTWoV9$zZOTN7`i7FM6+o7Z%couE>3 z(=OA6b%vzf`WwxJrH(!>g7_Yqi zdi-AJ$BE`orOYC&@83U7kdCLSb+}cspmjEc*vVtQp_|P^QJq+EiZt2!bM`}P#ncV6 z%-*`HDm?@p;XHmHORmJ^#3+kHy$}8O+U&S>XWu?fOrV}eM`lzs&#~NaFI(l8+f`G2 z9^cX!sa+~^>+9Qm-6+oJdi7`Vc3Q^YKEpSXcE#?3bK%Q80{MveSXAickZW<(lI`@L zCp&Qbta-(5JpZ6>Xn{tVTQ`wV)XJ*M)4V{d-X<-gk>L`g2_|^=Hf#5J(7<%w`OhRq zDD}R=PdcYOPN4K2#BlY=Ck#1VH(WBYjeYTW?49TwegjEV+~iN>!ABz4C#jzumF!d%xW0FPgq2S4h)Vv+FX#m#R~#Hq90}ojN{;=% z2G1(RZn#algq)-yx=%m$F-(CuA|(Agk8J?66wBv;tBPzbw`jtY3rc;AlxM!qq(_7r zl_;tDgl*puet$|!gzgOznRO}a+}kT=eys7j&7As1_dmRmQc$LOq@1NMeN9+iIqT~E z6C332^OgzCcUNv-*>66*&=Zxsvbfm1u(h(oU$y17+PreE@HDJcoRM2^9$^3WRPv@A zx$c13T7Ta|ySWzX5uF@5 zFh$Q)DLWqnqhLf{(aMaEzfOf)2GbX9!Ch4DveW5ylBFb)@r#Mm3WFmWYAIw{bLAl_ zYxxO#GS4e4){2+@`zM}iSGdHNucpZn5)%3c1XM27l3P~otyj2gq}zH{z9Ol(k%l7^ zF>}VZ@haMLWoB?CrDA@JfTet~kug`Z#9Bo5EuX{u!)YA1^DNHtvPYts(Uin*MUY1( z(Pfhj#rr=TO-)T7KTeCinVg&q7v_3<=3mdKClAkf@B{^}OMz_(f-Gr`aP8Y19IF#C zmJ0uitA1l~Q*I5lbYF>?o14omUv4C~EWh{u*s4hRlnBr9C#6abkCccr@M2Y6ss8z4 z3Yh}ol<0I9PCE%}f8y^kN+E0a@60&zgFRmR;=#DbD0$}z=I*as4!|cDN!!}b#U9mQ zuYOgpWbnOjj!ezGb}B&0`{|6Rf&Nfccd@XD$d>e?)9GJhl~a19M`!PIrHm2Y@=^NA za4vYs;DJE5H?^*?A(D0e7q6(w09&ccWZb(qZ;pNVV6V1W?KQkz=Rt7=eWkpt!_HPO zg$#yU=>c-&;;V9{e9mv8*zcL$u)Xuy?18fKbi!UAiN`kTyc4?XF7xM?O5Wytxm0%@ zv$KBL*taPw}v4R5t3WJE=8 zFXiqd=~$PN`}$;OlXlypSUgI;jBEzo($v~Z@Vow2&I`uvd=w(Zb)^6m(_k` zq{T~%Z;HF_`c&=Bz07rA+Zg?+@2#2a(S!Isai)*mG%P`vLk6i>gvmJd=Z8} zTevF}baE@!nWFZW0(T56k)P8N_CInkW%M;RhInj6j3{fonx6eeQpGGK$!=33;6B}{ zn91dcdaK^N5p|niqQ{na^Yrbj4Cqbj*mRs*H*JrVz2c;F9hFj{aT1lmj9vFIcXsko z@@C@AjdxvM{O0R%m58PMY2);+GN+<|-#Ev^hMhJ{xr*%F!TIrB`37OK3Jy0EMk~ld zc4%{bfJK93oSmlXZKx!1X#P(Y%<`sc<+6?p!Pv^>S6xb>F|#3hv9Z6}1a{DM)EIM4 zkBxbqo$lfpW$LSOuTQryZ8Hxh)Ze)0VcgXG<%`^wgQl0Hd!!O=3=@CvN*i~h=f?&BR|4k%yIYKEtaKOVpDYkEGWM@k~8j5Jw$$G{o+ zcCAW^AXqX?-b7hB!;awOYUi=;2yNcb_E-BG$k2l1&knt1h2Y$PN}G<`MUxA0f}e7k)JE%;)ZC1Xr@}BOPRk z&7^|F>&feaTc!$x_h-wOqe@a`>-3-KZxi#MpAwAPyo+bAi|j~floQ-DN?TD)aGq(1 z&=J^yrI#Cxs9f?dg&_(lp28qccUc|3>9nHIqTX}4xsu%H)@qWT+o_s5kInTtRi$_d z8JX>}Dwl2y+bg+aC%W!u;eW=i^HHa5$TPI9}UU<6mL?;|l}@NFCH z>N>Jw_}FaHsnApviQ#+*uUwn!KRxn|SD^(dGJR4_!9x$mQx`uqntJyK&!FnmlBT9+ z);wvKe;2V^#D2DG^DN7|<1?R*zBSVnXy09XAFbPcxp|p~rz%J6tj7xXa4LzvpQ0{i zUrs7nd6-{O=e{BeiC48z;fvU&##jlFy|g1xTcdk_9Q8v+6~Q|E_{-`wty#5m85y;u z_ylb7W(p)9x|M7uTi-(+ohiMVfj8i!&A&A^0xLc_p2W~qy}GB;UTM%{{jtZo2+u~= zK*b={O1B0}#_G@f=7U#Q4#aF$rPCSlvMg|8$6E<$RVGN25YTx{Ts1L)I4C+gh3eOe zgU3des}i}T@cKfT-{1>Z_e^|=gZIi>NZwRVl_Qiw* z7>Ojv8iRdJT?$>{UewXuvjJ9*kIj8rDwNQwLE;Z@I}Ne--C~h}@^-S|_A`piu`v%?{FY5hXXlPZ{^N$W=?T+W^Naf< zXZh?18-H*zOnXR3?@k5NRwZNF--$qlT4U$Y=|Z_Emw&KWOl2<wvF84#`=&b^8pq zc1KcCjJD$STaB8AmcCLxTe!kO~@vO#B%EF@QxMB*Q*sH?Gm z#USzR%ld?5|N5#gq|dZ!y0Hkr?;6bSl&}3yMw$^?SpJfG9j~LK>(M5S7yf}7j#k<9UjV%wYh@G&{0Gu05N6=nCfg$5*)N;7 z`&yrBx6QEl4M`SBPL~qu{-7ys>{I6TJFR^c+(Q;1Pq;M5{u{!*G)BHF z_0G7ZK-g`sEwbp_X7CrWapNiy=IY+Wg2=tGgo#vqZPna}{nd>1($L{;?@=b5T>}&C z^UKbqFaGr_eIP#*qyL;uln7yREjQwH@_i#!Qyw2}OpU+Fj-qyg@ zR%zJ^@Ld7YQuJIOWgkNyXW!@IVfUCfFz`YwjSNDl_oZKxK8kZb3gjMg9Bq8d*cpHA zMzPr64`bnD2fXlqV7FPChDYil!ej5=y;J2vp{h3UbIoY}T;644ULL;DLEQT@AOMSq zCn!^890oG^gc0lyvA~$B^W`-PDFf#fc<5f~v?Rhs z76&@{n4kvNXU+uopH>1m`n;eho#M<<99~|}2|@&l41lB{j*u9Bd-*-&ktxC>o&jeP zofKnI$f~>0EPD=rKN+fY3~>FGkYEHB-v=H1>3Q%ooD?$QEAwo)hZivqL7W?Myn5~T z4d837)HsRB$DRybLF4?nRfdcLp^)VX99!E&C-44iXx-~SnIFKva9YT_=ri!(213ti z(byaHN@URAy!l+Ay}7wr)V!o;*8lZu1_lN-F)!2p1ICdOjbUJAwMs6!%gbAumiE}h z#DwyAjtM*V%Rz|l64q{lT!X4rjr%i^!c_k}rG*eODn7ootu4^szvAi0Gpf&Rt*yit zFA9r^x!k3S3g;muB_$#vVq@juDKYI~_PzadqB&}H)fRO>T($Bvy^R@HOw%~o<;y1u zO4B{o7BwtxAsij=FfvNH$3#Z=Q9z_k@k)w9F`Ab$b%3!Z{8#$ zCyxjZMQq zS{iDA=d7L(prN@ZBQ78zDH-y*vQogVxMFv9&6!ETztZhn)j9b`j~=P3-wZakvXZZA zvTaZv6%Nv%O22{nejhoqd*omqWz1jdAYTUra8aU6xng7{#8u=;xUX?tJ|>ZvuB%?Z z+(`TFyG3yp2Q#yUt!P5^E4Us3=9&39&Fs)X=01p z18Sl>8wK!ADrnwv4)U~oA zIAIwH(vj|pB4M6Hs`JbKB$1}B=R*Y(UI9NFUj}gSPCm9iTJCut+#B%u-|_`=kcW6_N&%QoU2rnluw2dxgKz% zaZCxg7*)-j-S-6DH>#-}J?14)ojZ)CTlz}#)fSNf+6qkF z=Z01(L5*F83Yy;+fE}*)gSv8Wxontsr^lCFfZ%Bajpr*dG5l!mbf^qpBDY;Q=Q;u} zv$SI09BP&ij1m>RavXQsor~}zC?$XYgpuhz{oUxqLE*v{lPl#*!s7oFlRxVY%G(_e zoWJGGbLbq-)RfQ)UZDi?vuq6v(9{&p;r-##o+reRSn2KDbO!y5PM;Z9*`WK6YOm?( z>8E`aQBhHA6(5R=i}Uhs`*FEAIzF1Y(QY|8Iq5LhZ?v6h+LJRrIVsgrTT>%G-rCw~ z(WTe50Q-JsVPVn`ifFZcDj9!8K|xnXhrEKq1?IAd$jDEX+{Q*mu%=#g7)#+1gdvDY zNU$qts#rEnamLm}L`KFRH^!gWZ(GayT7G^$PapQ-E@X(le*OAn%%HD&o9Zt-eEdNR zhs);c8&#OS2R>(xJF9AI57pEN-!_umXU+b;MkzX4Hs;tUuO&tU<8|d{M~4@*02^|J zmd;KEGqbFHbQJsJP87<>+1|b=G4Tp7Z~y4hlqGA!(d_JO`!X%O?rj&-uV25asi}Q5 z)YsRSl9CD%A$6+I-pXza8#MT@8KxNWbJR4yLh%PcA?+S+o8%1KX;jExODdGe(5 z?oEQQh=``LYuDE(Idkd2j6Ot$U`ub*yy~4wyZtB`PI5geM8@f6BmJFszqWTeMF>WYg?8@D( zvC!@X&Os^^8Ed6fKpKUz^8;+ZgN-s#^q!1KKtLO>(8k7QTa_(Z6$Q_QxE~^+pb(<1 zi$EZp#;`kH0Bb)q3*rQD;G~a&hDKlkeqDHXHMUpT~%2hb3o%Y%fkt+hLY9I z+P0-$qA8~rR~8b9SQx4R#jabbwysXY>|LA6aVL&56nD<8`F6_(LSM!|OBFWr$U!8g z`_+<`udnZHnaY3ExEp9CC8hcwo0F_L*-YHrsw_{(>VwDMl5-(5GwqBoQ&UIWD}U}K zp7n4ecO7eT@ zvHB{(kGg#)~aG(93LO=xWm;R&+l?=>+H%X_*BXZR^8d5a%&CFWf=q*q??F?ZDKhz=yX;(7VUS7 z2oFrMbF?fj&avZI(97Pdbj&QG3ga74wBdT+D3WBqCn-mV;nzOe1LK_=JE>0iuSP{= z(m#xmu&niZJnFtuh8gjN#<$b=Qx0ue^3StEM;kHE8i|>?;9q&?D=W5hK#zN{R}uYK zAg|8R3X5n#3B8LQ!`{~f3*|iD-ocOHLx+E!Q2zhbz=RIk7!J^^xU_ppUF+e)0|Oe5 z9;JtO{jx8s8!d6)+kTlfPqWdnItN8cSy>q>R7Xb#G`hL~N>o*JR8-%P_|>Eapm$bxdIfcxQ|1+ zvlqsM>swn>vD_h%OM>&&4ULu4pXX#ay}i9Hiuu|@?92G!qPDgLOLZkBC7YX@=SW}e zn0eyH*ikf?o2k}ryi`J-G&abJP%Fgcp&U#34HYFgd(Te>_RPMOFZ|oKCVu@gyLZp4 zdBgE8Teg@y0C9L$wyLx=v6k3>(}cC#QjHAE%;Bt7qN26!?Lo{du=mdRJg8lYi;Ht} za|3FU8E(m|l#N94dhC~DjD7x#gCA+E2>A1llIypJP1buY9%^-Uwwd=(< z^<&?o^e@iR3NPG@1M4}reOrbwJG%lR?oIdRm~{Cv1oIdlHU zkJi8}+~3B;FfP$XF3X5D@bK{TJ#nkD*VH>DZr9?BFJ7Phpt?PT?PG>!jgno=`vtU+cN z1J(yVot4$BkA}(>BAp@>bucI~MWQG|MGa=6G`R%e6yb!5qmEJ3Q=TzYUdl03BVT=# z)x-CAZKr~!&v&D|W^O#3WgEo9;8h`xv141%~!DTZ)Hl$y?k`$0sBxD3RVU zD?BVLMNHnAls`#QS~~1=j`a63hc*BwQEVzJ)Et?`xf!k~`HzDZJ>xr?nZYBLfO@_K z@wXQ>kORSUGv2mL!M-b*5#Y#|`641BY(G>+?Gnaiuy49WeG0`CQJhZq_%SGE0rced zi$CtUo%~{pURqj0R%c`|%s$ZDwnue8Db<4&NJmG<_Q7(vvcF$Fu#Of5yeeW$SDv8T z?s5O=RjP)nT4BArUz~X#QbrXqqm1)rP8K3GI#>Kjy8pi7Rj+SuCa}E>2(`c<54+O&)R3yM2Wg@_d~ zI~E@hD7Kzx#QtL=t%~T75PkJmChu|86lXI9_))WKrJBr?_l{-v7Z4vc55x={D-^{L zhPqxoB7`^pF-2M`^{oe;UHW(ZiWwoJoPOc8k&idJwzE5J7*E~LuM{s9{{V;8` zO~pOdch`4@y)}$Di8=65mb%U^YekXq-HWM~+~)pX{cpz-YHLN;Zdt;}D<`J*#37_( zyksSB-cutnDpkxZa!oikHT)x+{88d@!+eMSLNaXm=Zip1uR2$-jo5HE)zmzfE+{M< zpO{eh8v}VDfLf55NGy;_Yps%OO*j>h2C9tU8H>)~98+@h%nV|*-qO&prYe1FYYXPv zsqBp4=;$b0IoD9JZiP8u^jbdqUGB~TX_P+)zp&3)Y5}L^6y6^n3)5ud6u5oT@2`%Z zM@gQnOg&1eeG-pN@4L9~=VIKGq`Vqg+x5Y;uqOqMM^l|b6~q1+y?2|}>Zh=?bLlQ4 z3UFD-v#!cpn4jNnjH*&(KX_rn9wePRMl4S5ELs zwIB;dN7V-YXi|MJ^y$+lAOWQKQ;*x?(Uv_wM@Q+drN@-KINfMuIQ{gFY=VHfrth~R ztx8w5qR;xYGEE$V^+JIa0IL1`{oksKi;JgcWXSi(g{xXzWOa9Ftx|ZFn<3=GEhwn7 z>`9@GvSi#c%RAj?B!XCxR%IIf<+iilz$GP{FK{@$wcfhdlI7_z{gV` zj(}t){0YibdHLOduiN4eJ9KjU^DJ231X%IS_2rB4FY>ZUubnOw8Na*puFgWoIj-?I zG;jNKO6v$c6_svurfSCg4<3qu&!0cPfB(L}zyBEinIOc~S}gpseU%qSX1bY*#Z+kv z@6u;CVj?gTx5&}{o~uWZ%Ph}yu7@fot-JqK)u;c4ksVDaOcZ_ zh%D|JiP_cWVT_2_fQvu})!vjtET)H@dbjIg12qc-5sZVB%t zG4VMAnt$=)MZr~AH)et$U*?7Km7bH}1j+-&oxAb_P$dLHl0G~fPdV-pc`^Eo29yEN=B&dx=Q>V^mULPzx`Mco;!{(7HG?)jg~0jvO0Rm)vlTRUUY za2vQj{dbEESW{iiAa*=^b~NgViAhFQ*7xmX-aB`03_O_qX+y!628-&)?h(&+8BRzl zzzYFzgq4Mu04YpGCA?Vz+F^5Igc&@bloUHN4?llgLITUlu`e$OK>V_|S9#`hYhlUJ zuwS2GXM5ZA=R;{}zvrZ!6?u7A1RI4lHDlu$h?bM3DFj?UWoI*OPT8&hQuFyrQ}(^D zk6~6uLV|TZ7*HHFu%iPhw*91}wd(!*UjQ+!imE6p#|e7GcYm9_BhHC4c^1da11Uc| z9ims^H-VN;L-h?0vk*azyMS{mJS#o@iJ4hg6kE-P9Ov>tLxV)r6La&o$Dh5Xa4yZt z`qh=8sIa`dTRuj-##o^(vIh`g%D&7%wVn(_f-F^eHMNpYpKdtOb8~NOE{zJfTqC+! zzqY=fnwFLswM_il99r6xe{(}a2T4Hn-^Y2345q2{NMDpAOO>Lhr$=72S{UNTD1~A% z#kHtwbadGa=;qc|02ku5;!;wxzkVt8AV78YKn8z*Z~ZFe%xk?1K3S^o3<9UABt&n5 zav+}UL1#FM=DgZ>vmyoH#_zjTbB%(w&R3Gmj(3uupPgM%M~CIzmucJRA*SRse-gRf z2o8aW=IcROrL3aRKpGkvniz+L*jqQY%k0eNFIW_7tV^Aurlc(FZP8sn;Tk|2 zg5CW%Lh0_}G5)`7{xExsp>mTrL`X^3bCx5f9M+w5#?AIp~wC!r~> z8BRjikXTia(uT$$61+0mHXEbY9f3&U$n7aBU#@=Q_FB|F|HB7)dJqQu`{c|oLAAxf zIZ>j70@2pn#pkQl_NvLOQgXa?cyx6C(9nFwHvzL>Rnch0A_#C&Rx$VV&7vTfD1!6e|G7(6h*qRCk z&~LBeznVHYIInQ!@$Ab6N0&6K+}$W&;PR}{G{wfmfXF8)F8(SYKvqsp(EeBCJ{rWO zuhee{@BSr?{jQtdKn`KSJiMNv?U{jC$V>^ zZk6QxZ=CDGwF^W<8tUp@%^>K3@<^Kd*wFAaA>r1=s|(qgnJD&wfdM)@ao8UG#71Pr z_vB*Ew8zOl24Fj_eZ!fS;M6HYCaOTOR3_s_jn-J6(D?ZI{F&5LczBM{@V4gWvGH*_ zP#Kp$r`+L*{P5ueab|pc{7{)g?!_B*pKWuq9qMM+8YyC0Cag>F@bG}#v=zniyL68{ z6}Pjsw_jgdd!LeWd4suL88_NQJv&vb*;WLw;iKyZcGYAkJ_rBJwCMJNBgS>c4MN3)LEoR=1`||>>0VuU# zgs0t4kZh->cI!T~;k?y*g5^H?SOy!3u^jgY{)IuF5*j< z8ct|*&sLS2r9=mP0xWOHsyOuCq3#m`^WV7;(|_SY>tDWn0Xh3Mv9n^fqCYN^Zv}z- zrBrsAO!VrjsGL`AR=kXd-XnQ9A}liUGAHXnNz_qL_-V_#rq31AQV;}~s$PGlYJ>@I zD%B{56a57C8Mfar38TmPwuw;0&zYhOu-8LaL>urK;M~62rZw zzdi4Yx!*r9(A3nFE!LK5H1qn!i{rCOw6rD(j3V1ZmqwSjr5=i=vU|&Mf_U=L2`V+S z#v1vPmX;Q_nquw3$}nsfIiQ3hl0kNK*RKm2B2WH(f3>WCzkd*7VsaAVi-A=9NcVz) zIV^j)4Z;Q65D62{*=wkG|;dmxgMC+NMmc+$|^ zOhHPzL`tDk=~|MQSgpTmrk+YhUH9!<9G^ogFIrkoj)a&PuuZ>N(evleqoc{}IE8)< zR}F6t@&H*gD%H&S@PXAAOTzn>0H}drvc7JgfG-_mk>@w~n-VM;3|G2+YzaYSoqaJq z;N#=-{?yo=de=+ru4lePE68A%K52T!CN(SS5>xJ8RF`W2`^^IjJ1YVAk_09BU9&e+ zRqRB~=lN`>&dCrQ6#JI(r+2`$0R;?UYI>I9ju5i1mv((DRIao3K)37F1cU-Y6u?D` zViy2<1_a!D{g=f~ANpTVBhLGmo&Kj{Kj)4=aq_PZ=DC88bM;*^yFgzbeEV+vY)@|P zmZIRRs^O0`M&J&E*auY$%4u3!8a1E2GzO&U3B5YzvlX9fY1JM+d^+2m&6Hz{@;+x& z>)`lY3JuV%DXXXu!`h&x z){&QgcUC-6CPaT{X9vwzYa&oLodt*tTms%wU7uxW`Ji?I$fSwEqQsc!XmGyJ-Q8Ia zt3XZpKJhM4&ztTf2M0%ex5X0IBWm1)2Qwbe0dcg(@lCR?0F;C+DD(IL+e$=+eXT4= zDk@rkeLem}f#~bR8J;5_$1)VtQe0qW+^jR@b=g$syS0?CiYDo_#GUAmB{YWeN)0vOzW)jCPs5%$~im zu_$Ix*#ioGDt?VVA0$45F&qh_wki;wz&)_0SEzLwKdk^Lye=27BzWfR*``-2&x8-G zGv8<)K0Xai&0Akletv#njwRe5s{nu7+1SOUEaeQty_ZeIM$!9)E-0^D)O1#EF83h8 z9us|GFk4r6p(8{TiXs^-d2A-6ft0r)VcdYn`DrkJ-6$_FfBqa-O(62(b$rFZX&F`M zY84I(+6)f^yr;D_76Je>^FWy!wiD1mFp^uK9;xtVnoi>(6lF;HYHO`kW!ZK-1+<2#XdZ z(H4N!Q?s+7ujl72)T-}@^SiA73Z@nFqsv@iXt<%KW5CM9zNrLY?dnNDyCQgH*gBY_ z$x4~rBnnlrQP|WplZrT|HO%2(avvijBa7yzE9^%4XeD-T?wqk%*`ohm~FkwMW^RoQ_DOV zClqW(M-wmd6t0GQ`Lp4t=P9OXFJiue3&jaC_sZTR_}_WgF@!i8PS z8xg~elZsH4iNW#{Tze)A~;(YXCEvJ&u7UO|Dvp5iLD!4(v$7m2 z&mciLOzx0$g1W4&Z2_WLQx_2wh3<@6M=_ry49oDR@_mb#;OXWciZc58NoGUKjm1qW zdwA+LHu=}MXO(At1;JrF&}mdtaMe_UOlazr^2@DDjGsPz3jb3ZwXN=7H`>wmBpfF+ zA|fp!1BvV}bFh5yz}q7VR_gYQVNAEdCDxv!NAgq*AtaH5+6!EA#fU*mS4!O)kI9ss=!cQQeLQJ5=Sn7|ORm{V;%x!NL+U%A=L>BPjSGjx3zVAbjHU3 zRtrcRMMWxmtl@Ft2uOM9Il``JVZ`(ontnWmF^T4myOe>K$PGC+AHw#Ij$klxh=@k* z%hFO)xr(0p=K8+~i;t&TLw}UH`XW>C@ff?zN-7rbO&k)q!>9?UR$ZX(nJxI<#5p$) zjS%P8s`R&eAdP})2%zAgvjYVULYxae{9Xp$q0RZ6Tfh`reFy3pSeSoeb;)VRvjIzB zTRmJW+ZW<52l#S6U>@Q@+*NCoTM_ZZzcsa8Y|MsosAJG+&4p!G^4)2A$QfOBcy_4Q z0o|_k=5wecuiDe!7I;muyxoBsj45VTAoM(eeYz{pzr*()(8=93z$n%Ec&z-~p>nFN zoSd6i<+k&ON5?{%yd$gMq96^_v%fD!XHs9)RwGc<7yMG`*g-+!s#aKWJFF<8E+ z(3Xp-E85t-+grZ*p^eB4K7-8+LA2+}Ek51^Dejo<(;S{{RPv4zd2-&gr^_Mb$V1k4Q%&Q*#(9xe7?*!hBN zBJv*Yf8-TM{IB2t6GS_Z#12ApgbIXMtrJVLV}8#IL?jO*M)pY$Kd~^~yoqpWT9}(- zx^=5daD8K=Nn;yyFk*6QYVaWe^nn%wRpjH1s*H?`%F4?0bn!Py{zndY`+2OydZkNI z21McB-pG9`K&Ox(gvwlN1k4mtJg{8=SVGeVcGeclW1wF7hJ%g9$oTPN#VT;4FW{L` z9K8~z*z)5?;=mkNDr7+}zGj9yf+X3w0;FCx_Rc$xa_6;~`N6Wirk-HY;E?yO$jjJN zrRT%3HD~aK{wQw`*#TN%S#o9FXs`+YRKy2&b@k}xh3RQ|b^w=Pb3s#tzO5U_n-UBB zyKFE%IGB}#BcuvXo)x;#uI}!}=esVy zdRh5Bz%=Bx94e5N5eOEI<#Uj2Oe=)hP#`?_=GuMG5pLyv4-0`ZiDk#qe*i>FQ(_fX z3^kFs>QgSo(%0L2gWZS~D3ugaLlgKj^u&K#lrFoQOS+BRGMtAVC29pUe9P~jXoz}p zbt0}Ae;@X|z9lJt!DRhc-{=Y>gW8`*$a~%GrlSt^5o(Aq8IVuo`}dzk1L%;GlhgnUSfg$e z_vEYzYFQ?NBV0#G>EfENVZip=rg4Ryr?#5YzkYRzWDqE_p+=X0bdz(Vubw$_V(C9D z-vG;l2&Rf4P^~LO;t*LXT>_64_*6|@T`ny;GCcP>Hl>w|hQWp??HR%JW_)BNpIA>V(fr{4dAhHy}#+$J^8lrqH>GDD*By@vcL!Kz~y4-e_ zR*0XoaW#-=x^g=Q2bSEsI801T*~!UYJ&rvOo3Jla<|U(~9Iqtv^g0TKI0NrQ$I4>} z?6R|?jPoUw9xfR>jhmW)#xnuwo;?y>X+~6Y4W|>?Oq|B;+kwWjK@GzZdz^3kg|VM?A8_ zbR9=tTP)qg_WkQ=;YgsN>;3B5{`|**ZRT7!_rbOKoqBj==~_|2KEiG; z&!foy;Cy+^q3$=hs1JELdOFk_C`h;vF4^5(*=$ku*uj_w_R%_tY707-x)7+485oezXOWJ$_ArjFJKB~o5TWfsGj4Mpvw^_5{SfDHfKC{E{vNUZqjiv5ws_cM zmdl4gD8>HYN%CulN%Fs(8Qud5`75FS#|F@OBS?06`y7>**U)Sg&9<5iw70ah)YBXJ zy6|jz;K3pe68xS^Ya1IjGc+~W6#a?oP!dw2=Xm>JMxj8)6c7LjHjDr}h-d8p573a@ zzt4mQbrICi7t0+~2lO*0g7H2Vpnt1Aw^jjc4!=6usbUC1dw=xBt{aN-1hA`t6gRNJ zEnp*fH8#}OM@C1hYj4RpIOUd0r2;m`rd26QqQmK{%nuxzP^?JYP5T4fSCCppL%bSS zJ<5cmcXwSeX6y%C)vS2Hh-Ebwj18k$rf-cJs}VKQ+-Td>Fi;Dw*g&dH8ecuQtt00! z{KCAxy*69sun5xA`cBX1PCpcEX6=Zvo&V0$=O!xw zoy88@Si!6arAZ}=hbMu1?T8&sLuFVv9){h$8o`GOyO%E=E8xZp;rw^+?)fVkRelgc zb&eHta&m%p%(nY>?t?5O^zd%7Kcw03OHE2jf>0h-E`86zxw1I&^`@@4@f}Efe8Y=u z4P&G0YB(U9Sur{FpECYbej_Ial_Ev1+N8=XM)^}FU=UdwvP++pO3XgBfB4wf_?XMu zChuTj;Uf?nPU>EFum!UYd|5U!ZB0#%mp(%8u0G`XpXV~XmX{F@IZe;C%hpH|RJ1xD zrLM8^fJ3iM4{80{VF3cDvS1(OTH!8K9Z6+>FU`p+D3}0R=!dJLsr_^I6`svKJ+BN6 zZp}26g1SuvR+Qn-p$eB&AG&sx;~weM6OmKHja)UgwabT!2Vj@Hi2&K!mKhh7-_efb zM{0?cmD(44QPTylPO&|I+mU}-`aMNdct^=Dqn;3<`5L*56gzPl0=bk>bOSZHqtyt6 z8+e+#du64HL4IFWk5M_UUR1u#pj*kc7XaIE05^COi(q@9w^Vx2HX zC4j330ow`t{_z2=)3(kP+EKTMFjt6X_@ofA`~m`%d3ooia!$|Hye0zqYB^V$8|0=% z_4@&B_2_~EA8F3a@QkfV()US8_xas2tEzN{A1P>S=UAu&(;AfL($}9a590wtcg1_S zJ3J=F6eg%6y!SR6TaquY^J==ZCRk6yFZ9)QQrZ3GuH3<%Q4lxrn$KJsMy^rL*ijJe z4S-s_HmLe_@=h`v6j2+fOxU#qfiV!q;Jk(CSA=1CxwW7)7^KnjGczH`7kpZoB*jcQHk=>gV1H}vu2#~kg7(&LQI z%MI5bJkG_oD?Zsd0N^+{MdE%@c^V@1Gt<)$ryDZym$X;gqoX+ZCYA^N5KH_Ok;HW5$g2 z;Mw^~@g3#^_V;_@eI2C6f_ehu=ZDG(ub_c<2n&I|cCK?X>v$fDw-kE~4F7Th3uIWg z+Ay6}E|83c7TbyX&AOiMgNy25yZy6SL?fqEVC84sy4{^+ZobZT)U)p6znzNq4w<#n z8Q1c)SP)14GMKOSSO!DMXY~$(7dy@P>**;=a9G2Ii`kMO=Qq)V(BZsbkDkGpVcW9s9jyC`#q`)eu}|Z<;A5+#1X5rd1^)<3yK6)fK=TX& z0I*?EgM)+40lQq_-^fwld0K5zTvuBQL5QJJyQWX}GQ>A-+-R>tlcz#cK=<@${ED7l z*H|d*1moWZXx7n7HwGq_9CLK4sGbaDabuGqy}G|Q9vht6XpK)u03MJ@f0cg^6nV+o zc0urQ=lk;0kjTbJArS11^kJ8km%D;LoeDOXi;D}j$F5b>w9W+hParSVP@(2N1aNc@ zSbpeftaRG}6Asj`W0yWbzQMGIhv^~m-P{sSfH+b{*5oS4A!508cW1xVD(c{PXlANG&3sjw=?*w=7=v-mY7qk)G)<*9KgVf`V zFC{MUIW1qq-UX%%j{BW>tprav9ujf^qh#Qw@v1Els43Wn*u!m_YHAFSN?8)t(1?+? zwX@^j-yB7J0QiDwxm_{E`d8E4eJdOdS`9Aeeje1=c5PqCg^_bx)Yq)d_MkdDZ=EtT zF@Yxk9a}XI_r94t@;qCms?KSRjlyUzuOoJ}{ujsBoQ?D$SUGsfW^-|*wN=(v33}yd z0~Xu0~e2^=nG>_}c~BhAQwhxA}~reO$m%P*eoFsf!{FHN8T}vGum{ zm{}CT5Mh#?_q@ zQZ``9Tl70cDvjp%zzMYr)m?-4-n=oKi8>;1T#_qvR}^`~{-I9;4HWNH#TLMKpdrAE zz~O@^C*U*uVtXTGqZFVof}ppSEG>QxQsAsis5yJ7sMIPlU|qvxMD^PW{#LnkBUAV| zPp-?xK7{ddQiZ?~WHUfG!8V5H50U5L+|aDMdi8SSxNl@+B*>zpu`tu4)KeEhWq{0z zznZ*?3Ku8mrF3bAMu-4f=5FQY0Aaci{4GZfPK|ryIxGyC@6vKL?(J-#Nyhxf0TrpL zsLZ_Z#@M{)DETq?&!GgLqgVk7=XqvE{JWy`SS**p9znp$_gOG)Ajw=Y+%un3`_B_} z9F|x=Sohh1fJ0!)YMj0*zU)0JR}9DK+T5;T#)lnu`+6&WAEP@2dj}dI{&ShU;BeO^ zx4>27Jz0kt%ULPz!;4k>@O#E}b}aq8q?Zc}s2deK>emQM6b6No^4v^n`EbSMz4QRq zHrJvPeh&lWfIuOz8HnE&Ri%=VA>Cxkiq&^(7P@> z=8yBuZ2KLYG{BDZf27{9MHA;gQ*VE}sxa?CBm7-(|6d-{{WrPdlkxEIfa5nhI>V`F zoszTgDj-jMkD0Xj4M*9a_HSQN09iXogT|rpI`l8ke=pyd8&Cxc2o&Cm0m$}zB3%OK zGXtWMkg{-fxbBCYr-RHIh-kuymH6mrNePMIcOKT(%iTKdCoYO`72W9LD;uP$EF%)d zVsh8sV=&-(ge_&Doq@1RKQ?So7cjl0oy!d;+l=!|G;^Rz_(p+10RboQ!Y5~QwOZg5 zFbRoNczu2SWys)=PMtj@QW}Q|l5oOd(iOGNf~Q;NP-lOOTqo(#0JCQZ8E@PO;&ujW zuG_Q^90pK;%=|E1m(yg1=RF>|+WROSThu!XdSEp@*TTQ58Qt}%EjDRYr{v;dZhrnj z{RxPq!|w{p#oO>XL#e@AOcrqbuQKC1;{Ye>o_owW+E%$@{S-p?E||2;VJRZ zdm?_Mso6yk*$O63#NE7dYYAbou;mXY~4b zuyYJ+T?1il%?2&rQA8xwC}1h-2pa^-puhEPiY7#X52=+Lw8fUC$`0`crY~4$@o(ND zTk*Nc2$=pfF*lbaFzGCtmmxo&F^WaNm^rmak8Z=6w$W*uM_df(=ZC0O$EKiM!VPRCFwFRKaR!@;$;U|Iq;%pZ=gT7 z!MTU#a$r48_%JQ7bWD;kUj|UJY)>< zz?k+S_L4v+L!e`d45qlsM@Iwa5C`-@{5loJ13Coa$ZP7I^|{bOsb_myL7-^B(!c4~C)ezM^%$66a8+#j6Pc~ptsP~X`RWGJ*>sz~^>St+LN z^lQT}!UC%4?_-AkPfu~ppsDuKD{UYA`TYfa1x_ocHhO%k)U(ngIIDTVWjGMz{h3xO zlGFN=1U^_hv{-6wx13tY*<*3vT@l=D+yX$qTmYjCzr*ajiMIIO+~*Qz zsean8~FSZMC7r9S0Fr`(E^0TfcEb4I2*PYN_Ezbmq5Somp_Z?rSeHi%1qv@ zSFf%Q0k8rwaWy&^+)4e0&h5D&7{ zC3x*mZ!tbYY{=>ccw<^7U%E29$8(&w9eMnAy2}y!9{s+%#Nu>BPP<^wSZ=ybWrlJv(ujZC0K(8b(Y^s>^xZ3b+oi9d*%T1 z+RR}=CCvpWwJSHW7d})weuRD)UX z&4wOp?+h(V?d7mC8)6Kf>lb;AI4LV1?t#fAuNF@pnTLscDu9l6T9uI(+>;S*!JcQ@Wgc?@GJ$acPqYnXe}??s)McX_j=64;?WmHQ5v9{|yU zr+c49SHR8<(k7nS|Ziw!&6$m@I`jKLPVGGCXBAI|$mY<6&3!kvUj6x|icN zoVc<0lEz=K)OtOjb8daOyfqQ40M1xe=&wdEGPMI6K}Uq`3m^MQY%Z~fDJtqVyf+#IO(~AF++4QX9=}!5 zUsmScn!2B+qWaR=DJtHHr8V-bacLB%GwQ#og6;>Jp&qA)N-T6h>jgCItNln1JmA!_2XQ$g<9#Eei~Rf>J=q$k4@y%wfNu5) zm|(eV<*->6`>+?A&8iG4Mrh1!vT5q*=xAuLocytnuiqehEUd*EdYk}a%q21T+GIFJ z3|Od|k8<3nONu^JgZkt0#fwWPNTKPB=;?hxH<*@^a`zOZ+UUg@XYoQgA=H34NU%hu zd*Da9?yOA~Deh1+e``l4r{y0%RzgA9y9woHukmHg(%_JgdvV53hIteTaHJgymBpkC zTqc|$+2kow(hW_m5PpxN{yshcAr1#!4iSYa2c1fxfGvN~6S)53WmeXy;U;W{aq;3K zOG|cI+Iymk1oFpl+KCx?Zn(A3Nihy&IJ<*FA#5&E@h)JpvjrVjzQ0SO$n7;L864Na z97jqq_qdtg3W;7O{sRt$u0S$H7dow*k5cC=%nw&DSd}>+1pu52BA#P0InS$W5rO%E zXHc-rE(Xqj%p7)tUKFk?ca{ZbhHQezQEiu8nlR@`G%5ei*V<@s@zS-Qsa|lfr(ST?=v6++O$&dI~5aT`%u;PLs4k zA58|m@2~%V<@Pc6>YE?X} z$fI@;$kJiHFRpvpgJ+K-#&$$mg3~-8MubJ25dj-{1o@}CC@kcIrYl?$_P6AK?pxd| zSr@u(d4D~Q$@1XICzfReq_sqW5xOR7UfG@A_fNkF?4Tt}^U|#?w&hEH$6V*#P3!&Q z9$EGsnTR=C{bxkyd1%${keMdc7bK-N2e2!4a@~pUNhkLwH5CwjE^9K7o!%`b;z_7v zPA_|Si?g@NHK%-adg)Gq`cxnXuP-@>%>-bqd7>}oi z;Ssw(BgFj^I|I0r9a2FcI0}`Ha18LJjAbZMC=9+{aAh7FD4o0a8BO=ar zt=@w-bg<*|>9%%z`zvIi;9PgCgar^NeZ!Bj?bP64UdT}pktjf;$DnT`Tf(XcTnGn8 zE#GV>a&WI5b2(*#S);XD&I6CNy2mCahAJF5(PJQWgmoCWr+5|a@bGY`WDbiV%y|AIHWZ-K*3Qljbn-r< zfKGF@E2BX*Rpe?SDxd|7L1*Vl?d$uOfW|E@=2^9KcD@Gb9nsKCFN2USmtkd*KxkHW zM0s4l?r1WH&cCJ46d)QF7xx8Z63VBJQYMQPbU_Fu=-5P~33-Qs+X5dB2ws2OQjR^I z+E<%ulzdf+G4irj=ty{R-K&8Dl75+c`MFi?AN!;xFH>|_JM~%(x#_32f3IKS;_3SG zh4ox>t$5!dcPD*#7&U7x)JKYyWqGb$%lf992ts4P0-?dW$_?5iDFFQ>HCZeZt14(1 z5kHBNZ+|Am#fu>+4B%X+v#iJ|%*ipoe_vdP`N9RFjS;kKvhIhrwuJb2!gf3gs>jlu z#xkN{i}9>jb9qrsLY^RC+ccp0lZI@@CdU|5JO*Qo6A{*D$;e7AN4*r3$pT0k6@gNP zb|2o z-4`I$MZ6k5Sn4?IoL3|-1!HJRt#@soHNRN6rkdJw8v%-`zNOKI)oy(KPKn2%`XDdr z?RiXKwD0SZy>jP|Ugm@Eu1m&;U-m{K}w!K8;^>+mFD=N;est4p16ePK^L8WhDYzz@|r7l~=mmhSNT&KAWBGX|h z{kZyD6yB106+LR`>oV~d4_P%sbCU6$=kko z*PU|W;w5_Bg%gBYHljJ>6?^rv$?XB7My8S<+n>TN2X~pG;>6~Mycwd%6 zM_>WkcZRGue>6c)Pr_$L%L+N<@k@6Np<#|NlDzMGM>$3XjkeX1v+w)}7lNsG*b9h~ zNTzJ)?E5q}#;}EupDK8HX0UEgj*Wqq=SZ*e_u^vL#{n=$olR&<+r^Vbf4VI=JoPD2 z)Z;qMH0P(TRAQr#7eKO@`=l8V38>Xgt^-cXIME9#d*UO;GZi#9$_`|hmux}QN6#J8 zO*^O?r=H3&1=vztH9DIF;wHpGjb_My(mP}J@Zs(1^<&`LFB-af#{AS|gfCYG41J_p zt*EC=5)ru6UdDwkH#8miehcuu6&+A>fbR!_;?0@fi(R~%0O0Vo^_efh7)zLk9x&WI zN-eK1%0Yvy#;Dues6@X0$hF0{S4*l_lC}dHiODD_SuS0wJIUjHnAC-`Z!I_8($e4X zFmOr4`JSVKzQ30-4;TL(&I3Aormu##C>0;rJ-p;~h?bZ4v9a+{!$*OGbD$N5mBb9> zz3J)KyJuVM!OiEF`^|N*>eIfjL+;!P+(a?UlhtjXT~|wXbFbGDZzyXIJ4`eYt}wi< z`*^$-bO8!}$V(pxl~KC@MGGnfl?{T0gH39m=2 zyGGk^daA9BFu;f%D?(!5&@1vL+dXGUguMA*y{|bhew5uRWOH5|)!8WfCiFPu=>Dqh zLitD82w@1fF|Vz3uZg!>VKswouO-C8P2ou%cAbayR&^yMCe9fjyUf2bMinP)nMUK{&>YA>KljZNkWYcQvi=s7Dqx(diU@4T}$HP`Zh*YVI>h zGIodRs73_V4?GP1pYM^i1eHmPLLH;R-P=b*_W(fU{l3-M;}DI);jv%8pa;C7*neK{ zzJ9zG@ZFzd=(_1cFivTy*|N4)_r$cOy1D>(7+fij9Uw-T{yZErUsC{l#ow4cJpaFp5#?kzC&fXs1!aBj`T(kY;p*qZlkYz?wrs zA}8l^OBCm3GT{3;tEY0*=2VS9*WP#RJIY}KlLFxn?4`mZLSY^-DYt@y5E??+hot)i zuU=*Gfi57}Qn$CMW1rLwgQh8S24We7R=bo!`9Tbde*f`BOpMd=L~F3p>2MG}#=dw_ zXs99wetA{ZNdK~Fvv&g1$pARCv}IYTPP3F07fV}2)oO@UaIvukUElW$uPL`Ct8jx1 z=kfgK{BtisFcV-7Ek8yDP0ee9g4rBUy30sQGgv}v543}E)ZLK6Hzki&xcHHq=yxF?9*;F2npegZ^%90v(P-2&rJKYEN?>l15*g-`>p%?|EGQ9txFJSJC zz7aV)J>B%-LtX^9Q-QT7IcT-??foN_Lg@F_iZ*TSxJnJKEKYZ4(h{3NZ$Rudb7e)v zB@0Gy0cUYC(poS=V;5ArGuIx@&(4C+$f^k{%noz#_pJH@qcNV{JpNLWiJdYk%o7l?hBTCMJdCvg84P5q)|gc?UdiBFrKB;11%sN8^1IR9tV$ z%KG{EdNh9ePjEhHqUGQ~tXFd0SN$y+=2QZDO6pSs)DZJQbcRZNT>I zz5Z%|9jrPt{?jcATFrk=y0;%cF0sGlu^%;0pmtIPZ;LF(#faochEqAiT8Hq6OjqW7 z?E)g}ZA~=*mIY>a1L>Mm=cJm`psyG1>G|>&9kYp;hKdS21zK)4R#qQ#1?p#-2DdF> zAz@UPQ@^Qx9RKN>9OT|*XJtu#LUd+7=*RpS5=H94JwTdz%B@0*s zc=`(|GE`yAN3Xp+M)m7Pum_5X7`we!e|`0pKckYOVwf-Bq~k$o2%3|YtbpfHPK%6- zN1$syvH+-g6U=c%6p_uOImQgNO0=))>_`@;X!sOQs;`l?NpdOPzn>!ZVw3)cKyD7P zRIW`UEVgj9e;^jq1^VQmB3I@^;GH!axK5}Npa-niDWki0qmC!PrqmvKD5RfymQ?6e zeLUq&jxigqj(l*^&twu{AGdyYYS#GpeO44G_>9$e)l*)HQa}Hf2OYeMIRmo~;Hul* zo@wwBLBCmC*}%|n@K9@yAJYh9HnH(@8lM4j7FhU^fjIN{)!k*$A?C2%{!bfTv2V)d zrI-_9V_);j&5%D^*L?hr?`3^^uspmc=$D&`E*i%{uF%rer3}M8KlIVEc#}pVOni??oxtae&K?drXlDcYd1PW0RA-+}z-9`&{KR zC?pAZLq#}6W`$f^agVOb=cC%x%#6~B+8fnA4h%wA2lN6jDcp#ZQ_~H}}gKhXneN+js zWT01JJReLmRArQ0i4J}LUYz^XW`?;{Y57XxV*|4fhm!tv;7oo*l7Oyv*SuBaCdmae zx#Vku&#d}#G9KVBkphw9Kxyv8UudlFwjrQ2@fOK%0lY&*?40cE`Ng{ilSuNA!6aap zq7-du?P^yoaSsr4I#Sn8h{$J{fw#qM$D@6-#EiccoUKx^*Bm;SS(S4|FeGJ+abf%N zVa^~2$!SPPNU#gH$;=7=;`u(yhcrd(TKI1Vq>`;5I|rr~rPPoiI~$wt-XEkGH-9{D zcdnP6#MJYJ@-!8fma2WTkHO9zT|*2@hj3W!F|)MPOcjN<5K(tjaycMlO3nZY-oUi{ zMDQ8B90oc8>gnf}vk9k(;v@JJzcH5#x_|&-i$+Dz>=!_*7z1VXVUi=w&O!;B)tBKG zANB%bpMMQhoQh>lv2k(WqL5Zg1H+uw`Ow?)_oe$(!PmRHDv-)FC>OuAU9ary09(>B@{|&t&L{jiwX3DLI0D-9a`XzR;f; z4V^^tO2Bsfa=E>OpFX{ET{r`(bmPj$mp}ixdW=MpwUMN4Ti@$;?SDeL-d~Vz;uAdg z!WS`=RBOX8$s0pz0j>rgmuwNn3z+M|L7MCSkiT1U>`3lvs|@tuMoMblo|mxNQXMPh ztLO9t)AVySy}vMp^&`tSU%-Ho3857M0Z?fR2xGCF?^6G!WRmf@DI9z&_zfs(w)@YK z$j`i8?+agFjhb4zQ>_9!s6AC&vrAM@ptNEy7$WO{dJtbu#0ZwOUKP+j%Rl3 z&qz^U71(T!@5ezG)S-35BM2_J-i^Wm7Qk*emgLV*0Fvi7<}ApFcB8Jhu-TwWdFv2F znU~gYtKb2sriUCLUypqOC(JJ>cUycMlG5GnTl$T3@AKpT0ft+qyVvYji*i$UDKBzf z<*K(jjyiA@J`;|=9zr>a`uKAQT!D#M6Fxm9*^$+m6p zg?D2!U$tqij3>B!n`6lp>Nu?cwGayBL=8v~Z{b-B%PhwM)SpX6P6wrT_7`dO8&|@E!hXR!c%$$B zVbmq$$><`alLgWb`~yd8fVRVdO%=R9-(x8uwzdSwI{1?9W^Z2#Z(w*AbPP9lAn?lE zOvYN{+Rf3Cx4L;%RYNnYQ1Kf+co5HTE#bx`EL{CY;s`k)$56<+pUYb}*CSfFs}U3+ za4KlPWBsG@z*TFWSdfoG^SV|Dh6dnh)bZJts@GaU!9ae2Ym{8k3i|Evb}}&;0)YiM z6Vlwm!%4dby==Q~g8t2ksX`m-8Hn*2ntw!H%yGC!Ux9l|r2E6EkIl`4&Bv&&A9o8v zY6;Y=t0xyk;%aK1&45tjZ@{VnN!L^IR`=8B(rgIdRWu%*DGz(-oA0W>KH@M($bEsr zr2WWq=c)Nml-O-RnEwqW_9Wzgro{Bq)&F;lnEzo?9tj_V49LI%EuR+`m3b8acQEYd z_Ogt}rSp-?=0B6`)XQaxw-;d!v&<`rTv~i&ah&`>fEp->?aX%4TsD+tX{JELe@@6* zt%SrXtKE*4$q9l18qPV%YTmjfmJo8F-|D%+^j5$B=!0u=quW*-Y_V_dmfj7B3ekMe zM+i0luBotFfG9<`(Hn>>5h&!t!`?Xey3@=e6z9&}p?!86+7tVd7yxvl-yJ)06_Q67 za>9efb+m&+Ay+E&;`>>ZfUvMvH%Sn4F`sttU0ACN3h1awPn~+c{YbHzy{73eBJH4b z=XA~vM2`B@&u*P}V|;kkb~>!6Z1Khwgn2?B;0GDL3zK|Tt~>&xY;yV)gnWXw1(ZG_ z(S!?S$E!YwH-?ERtDHQJ4>T%NP^O@a%ZcFAW)AbLtn~M$tZeUN@3xkT6?EbOI!7Qi z>0Vz$_7Zwo#GE?afDQmVDDiE+39115GUF0(DoWLprGU`IMPqQDo1#UnfYkr@de;WCovN2 z5N^K-5L%W_gf!PX?7wH+f@bPd1n3|fdZ0&>! zfw27{9wm!dQCt;8vc>)`Lk72^h%13HOI!hlV+PuMj|&$=>susq^s+vyrRCfHx>S=& zhQr93?@p~>$R?*pX!}&|AN(A}jK$CzMxs~$_(vY)>U?z3?qWOx1H<=aGjsC@cfNnn zbE?I^>A3)I?(q0{^Q^jur@SKuVmGoLD{eRoQPoNq4?KJ(xpPGLS}3pAW7+)=6)H$} zK{V!<8eW|wpsWk~q(ncJQ>r&PCD2)>LDBZmdRfof{DJUSg@$`43B;LosXEdH*|lW{ zn?w!~y&E1y)~rYF&o__X@F4_&RzgHX>d^EsI=Nl|T4mD>PCk$4MD2ED=Dd^x@?GQ9 zw6y~rvn9l9HYZ0QR0JGy9v&WpB^EP!JTAu$?1x%-4cJhlS+wPIh9QEDBJI7~W~>%m zzSc72oZ@7X>!vM+t*1^XMBX%w?m5Hm-`kTVdhgoj?*Sp((p@4@NjXN83@@BHnZ9yI zx%JILRi?lzDhU?Glvlq7+`#9GyvK#9MPXteSbsv%yz$nfvJ&Ecc@$)zwv>_aV}Ni)DqEcZ$DH;LA0$5v zg$MNH7Sqeb+WZ)kGHKyuXD8O~2F0_!e)8Fz_W)r1#UAto2&}m@x3(6|_Z>k-Ai~ls zLv`EJlZvnD2zG}=9`AH%2%to$OXiM6-z&kMMK5?1at|Nz!I(uu#Rlp@9m!|)iC4~< zuSm?$sBNsI3CBf6U36poGBCg#eIu@UKwjIwV2F;CJ6hG%3MjdmTeL;&66NUiZn6gK zD+hPrN_mvE#!Xw&tthhY1o~A5XUXI>14ux!-ZDPC<<3Wjy#e#v;uUi!PD{iMj=GBm)X!jvIVq@lK5%{-a+%qs)cHBxG2C`?Z69uw*KGS(0(Wrq z*s=W838KU#i`;?Y`|OtkEuYFkkUH^dx;YCVpn^cby(*nIz@#17a$m4S*e||UXM?r8 zU||M&`{f`%hYwc{VIiL>gU`!1qE48_Wx`*No$k7K$Ck$Xk{rTq3S1K znnTu!cvTGuZHBUYa^U3E&J`R$J^$zy3pKH|`Fp(+9RR|xNN0^sx^Ja^+--bPXtU|&?w4ax)Il~=zy#jr zCVHBFmDe6v8kTx(U<;+fOP9wZ?@sSSm{vf6aZak$#P$oh52fg*a<_-f(u^f}5DSNe zd&obrIPSUSFGTkjQ;7XJa=!TgAQOIsWM@OZOuPZo4Ft6o^r{#cA%oHs?86+9 zk&&aWp;VN8BO@a)N1XLvump5ED+K7&{b|LgIbs!HsjODME6jKR#|X~HP&F;Bx$oaU zwC&xXAd{5n{BEx(HO?-!sjx5 z!7E?{OA~(wU{pE@e6J9wc^`KA0f)QfHwX*@;l)*98>pT-s5K9NMX|m-4!mj&;69J* zHKR))Fh4;+kkJAl5X=gVQc_aHt*>P4Y;Erw7^unM`kFrb%j}o*N->}jB^sd}-*K%* zo0VHaS_Bb)Sa2|noZ$5^33I@08!lxH*B|{+Zd_;a~ z%JpB%so7^$z~ph%Hm^!bUcJ&4#heF!ZJj>@>>x%!%n5Y0$&9?6xv8nLyxsi#{OPF_ zETP>{;dNs3YabQWUT>wQ1q`5#CXl6|Qh;{Ncm`y3tc z#r#<+J6?zKPIIOBfI5H5M`apv48LhP2mR@Clq3ND>4|ZGRixI!0}tELd4q=&R?Pl) z{5qE?}hBsQ6=55`OMLNi<=;=j`FI>JH9~alX0rn^8m%SwY>i&C*`%8y`o9a~X z*#9Bl@Yq2fHtKXawd*|%Nm*F{uV6hHSS)eXjD6R_+CzREA6~RdZ40n*LHrq#9eWdQ zjz)l1@#lLpk`TWNY3>%@0adFvzTyDWOJNjhOR@X=%6}GO*zvFA+t|a>S5&0p_~xBU zANB)af^MNkxoh3wMz#SE%ru55o@|&*Up0*OM@$r}c3-$x=o9jJNC-!+Ak{YCBaFnq z3L-qkq@|m{MXfvm#T*pEbu%~%Ic@lde4sl8IEfBFpAM#g$UxF4iir$RQ!YK4dRfr5xR|GS-y|fr zTe8Z=3G^AJs?cN@;2xWe<-OO!72VCJSMT-noMFBQve4A@ROPw-P!I4-M3fEhp+Y-# zY)=_iYbjIe_9T5tn!xEBKmyX-)WlF5VfU_ChDk+aOd3RdaKlsN8wPCb+s27hU~3H8 zj;V)e{e~dw-d;L?Ij3vqR7PfJvk;UAy$~qZP8lV>G0rs>d)OZvw|w3|N}`bBW=kIt zLX&}qR<8R3boZ1&_FGj}wgK%tXj_-RY#!&hqo|-j`@XAfk!N3d{>K0eMe8qOog`rX z5n9%pxw$;0K^sj#NVw@Nlubv+ZAR6YE=ufL>TdvT+ZASheh2VWU@-aeS1sriA3!lr z|G@Mxuy}CP!3<+4P*-xNfJuO%1~W{F#cZv+_G%nw@o zCqbit9J=%O1>fj~9g?_tc;aCrwMsczSqPF3sd)|jQaPI*?9@mC%MI<8u_q(~PfZ!c zeD7CF8z{c)@dI|>m{Wms1=+zMBtj}%Ton)i4&MeLv27H?r*JZdM$p-y-yth$o?V9o zHR1vav*=ub^gtj@MVPq=pDjHi-+ue{hLl=KgW92ci1^_58Deivo)nHm6UgcQn{vQ2 z@0W7GP%VRi6?`c$yVJg10v98+Ax)DE_2Za@z?1^he6cDw^kYGB1DFFeRx_(STwLjy z`)ZL6>iWlx9oLM`$z^2wyYro8n2?ifz6;#C zMi`^Fx!1x+o_~_*)>p_UgB7J}7LmxEWBoTsUrE2#DDO(L{s4JH7VpEtBeMPwS}e^_ zEJ{k^X6`RTO#vkV?0TiV$UNZQjUd-Qdb^iiu=(0wSQMGZulr-U*1i)ueW!uj*uk}< z6@32Fj7{xpcJ>dY$Q|&M$dGQ^8IhMkALWPqt=^u!k%>f6@BJR`Xh`n_9NXPlIer#~ zBOn!!|D4GX)`Lw5F<^5FYES~==MaNpBzgcSNR|3%d;qPWk?Fkc`aiIah796Iz;q>T z@woKF+EXG9^ay<{BoBW1LKW(;^i3QDC>>B7L5k5S_KWYT%5UlGk1ELvl4gj9AX$}) z1x(=hT(l!oq|rvZgu7eq%D#ks!L5!EaN&A zk6am?W-tRa%*aWMob6%}QaKx3Pv-8cA`@U96|Sr^#YA{V(>SWHY!FQG~JAqPOp z5P$zZ1uDg-p3OYA6nle}?2BNZGdDNqiGNn*CuOTBVrKMyVO?h6yb>Y*<9SWUN0ICV zl?ep*^u){j)P@-KRmYTylcY>fGxQzxJ7M&LG1yc2!l>>wldVp$QH7n2Y#v|UfN1U0 zLWg5+b4$Pbu5=ofjg@E7@KORAl44+DnxX7wNZfmuY9n9fc{XMDh8$ESmqFE#MXhVr z*$6!`qYKwsaVt;_3I_&=1Yfo5i86Q&^nL2>orH9t2OyAuy%iWO$D2qm>JlhIO^;oH z?tV#QP$;OX*UN%;4qS;u2O(kV^4s~EnwkJgUVrv-n;(b-u+(NMl+Z6A%1YV7Vgc$L z$<7hM+|0~3_DlaJ%7dcYk0azLdV33@(~_^yser9^sZ33_IX%?KW zB<~ZyFU)RXHG(WG&8aVYX9$LGUruQ9Alc__fFZbI(r&I`onw3oo-s^!Ag>^imw7WX zp7Mg3_N~o-UZqt2%T-D$`As=1=7HIcRlxU?QXto!J_cRHlJgkCH=37|F~nn8FxRcD z3XppsG@=LSgA{Jw%IQ|iwY=Nu98{>5Xp8~{uKTl(M(8&WHiXv!fPvwUBpkBJX7p%@ zvvbg3e)i4K`EIt~Mn8^Hg*zGuH>@C!;>(C+6roB4w_V8@BY-7z_)nmyam%77x4lq% zA~FO@lL&2yLH673lThKja^)4oRgyqlWxk!-u+{0^HShs-Fxt+sc!CT9kSx>AYeL%( zwzO3ZK1~4CvXFV{j9`b>-Mj6o_&=7Hp>fYpUy11PQXfxxtCAc(0J?lw=JIbLbRSIM zJycXjcQmSsDym9aec55mz+4_OpPfCdb$XTXHN?;RSruBq&M|jEHA#JRbmVBpjRC9l z(`PZ!MXSx+P?H7;uD#?|(#c$c?lgHToi3ELwox$Ffuc_;D&nsA2+a1*ZN8Y)_jpBe z*+x|jceCI`@o_89$Wn?}Iy3}fqoW>$SzzKkdr2_r>-OmliUI!qp0k+>?Rl;O5ek%K zGs-bP81;l8Z>ACh_Y#`BZ>%Q+r~jtN3%P~i0DUP!1R{-Xn^M@Nilpb(z;jQSQHU*g zmb;$FaZ~ z^deQmvX@xy*Odal28oroFxJka0lZ?zGTzO_#K*>VIT>aBzAO|y6uvY>SB6fLcHC>H{l&Ra|DAKArlvk~ z@&lh_RVXj*)30LPWa~35wR`=6-^(E=qG&bXI>)IaGwE(k8AqS%UwD7@+BHpW?W*Ek z8*gY;PmO?|w|j5Nzw5PmWoD*~F!9@8>j}z~l1^EKC&JXP`12N%5O{tn`)7$QfnXyx z9Wlby{WW*~UMx)~xZsi=@54b9UCPtt{fX?1`gSwVNP*FV)4wKy zyl96E5`pxr(-Ct0R`Ps2n`F)tfhbjZO(iL(ue??ZqC78m}jk^ z$P3m3rH^a1FfA=DE@>}y7y4xI<`oohWE`c&!=Bl%XV3A|h2 z;$uQ$?vX%B_#ixw8i3@0&Vh#lwToevjueHIWE^Zv^OFo@k|3*M$8n&4+zZ8+NLT_w zE`!(zVtzX}fIm#wT}fLVg!v4*lb0%7S&dF97Ip>2?89}kLE-GTZ20KW6%hH2TWvU3 zL9Bg73$Qt$U~F86rdH35>bgw;C!xZiM&y7%Eni<>=uuzRu6UR$fR6w1;|Jg{$lrii z3@uQk1CzIAe+|}Z*d2iMA_>;Qz-pBOxrdW}=aIZH&uu}N_C5+b|6H6KESXbLdX6SW zGRRy%A9u&f6#;l_#|qQYf=Mc`xauM!B-z}DP3gf6qDlfDg^u=$13QRJGBcBof9!%* z0ZhRhDK9HAA)&^8&7f}sC6H|#j==k&aO1`eV3%HO24EmV5}6n#sbNz)PzeRsftFLu z=WZMCHwK+tX@*uv;T91JjsC}Z&>M7ab-qbGv=3;KFl>n-y&uj5fP!PN<Q-Hxc(>xO8M&y}z*Om4 z6;*@>SQM7NAF7qG_K#ro958dOU4TgyPzG~V$@~K#X#*L6)nzO#QJ{js2Qho0kjZ7! zg-xu4Qnbf~dks^sR_z$;{*W}}0{jzM3Bk(;*+IvQw8D_UN*EX76I{N&aGR4&Eq5)uf|#jHqDG&t97j4rtF@$BGH`~ zA7S_XQ{r_RqE+&TaLW|axYEYFPpar==^V+!soFDlk;1e^kB6R01B2)E*?(H<<|{`U=^LSXY4k>wj0A7YfnpI`LbLNq*p=MD@k|Q9W*v zZ5bXOa#)*IbsJ*4|G>Lm&z=bM8ekbIt{i|8B!iq9uW$6vujli-MeMrnQYP>%Z*Lv_ zHJM-i^a46RoQH8#-=KDO7e5Eblc0S>7f`^7!8_c(VLjQO$+p4li_)FraAOb+`7oj(ZwM45mHZiA zwZ6A$ExgkV(jNE%HD8sOPI-SLGQq{F$vJ6u#ZrvrM``^ia5U<(jw{LbOySRRhisFlx zFTbxt#zT1#YpdDP*#PfDPv35CI_CC5NHJ{T<1o=ezS9mQ`aA`r0Ry0XsD>JB2I*i3 z!W-cKP6(@u?_0nwxrVvFR{*at07y_Mer#;)FT|vR)F(631h}`=;(Ju93czg+7V+Ej35xtBqwnj zO-uGi%NGKk-ucjG)SiNJ8oCET z_ebb{oA|ym^{rHK{a@~3E7Je-7O~%gwE)D^P%P_s*UqeBJjLn(9|*{H-M6WW04nlr z4g-uMDB-#;wrkse&mbJWy(959_~py=nG@s_}2oL}s>DwcLeg$-s4Km~WA5)xE-_e0?d%`2~l0$3Z*%a+U^$yenr zKc~-E3d=5I_Nw${9f)yl&6T^ie;$hef9AFS zKbhBvd|zNSthoBfWa9U_ANok{nK{Vnd!ZBAxU}IsEnFjZlmOxp2&n{49X^mGgePZ4 z5i;Tb#Yq@s$>8 z7fT5P*##$|OHl|iiI>0pnOzF@zWeQet2rM9Qfko8OyAj@|#yVGh%HTCy`GW<#0(dwGd%6U9{g@ItliOi${e zN0bBx*EH*k|10^imU-UPyKMTqii%0HCp2z6Xoa}98`{4ueBgid#6W+KA4HC;*N?n` zT8}Xwc0GeVKN9wyDh2<1lbCqVHV#_bY4MKI9Nu1DVXylfehHJUnvx1Y=LNaOYgrhG zss>M3D7$KZx=a-h2rUIMDI>S~!3{WmYL}y%mH8h;e=o{l&|NLg51p zbkcRGddYGSA%~c~qyxy|jAG7dS2}VtB*{ri20y>^-zZ!Twc2jUS7&W4UWeW5a$WMn8bPD4bW4Myx9YR#cbc~K@1p*jVUsb2KFhe zwlPURR1j=rpM`bz>&Gd?@nilC8!_HS;f$KPSV<}!t*v}yo%SY^vyWr9)=wzMNK*R4 zva++yEG!~rkG!mvVFk-|=ZPh%FS$l$wG4 zv~@pKAv+X+F#U)C?2jSl>KPltp!|Uk@&jsZZV(dpgH$TjCsIWM}eo`;@)E01a12Ww{bvgSB)q)+$~i?SOuA06lr* zp}H`z{(n0H&i^^aaAj3h85X*$;}^m&YNM6YA9_JA4^bi-DjNn)|J^rVr`l~6i%9Qq zH-e@A zu30DZl+Aa%e|^ve+N;12Ahuad^x_JZml!J0+#&?T3<_8EK_q`3 z8HhWCTqdp`G@f+`Qwj_RTdS^Llo|&|5Ko$sVDe)8j5*n%PCkksM&jbnPALh$w(#?a zoqYlESJLwGymv^(O|8SP%5 zsmr{7}5J1(8=`3o~^?w~WW1q|J zU@csHY8Z)cu!$eJPlW%Q`&mX8KXr7_`E;hqQ?7SIEpw9u*GQn8mW9OR=j2iqOZAj= z4?rjgF8|rjNZ|V{NNKZ+yJQ-H&dnpaJ&4ozDHWog_D3J49|d!V884wbVY@x*6X`l?aQ0!mlqgkI6s};gy(K&Wu5#E+ zXGJjC+hU>6L35YiAp?Iq&R=GzSrR3AH|^9<^Hq8KQP-xQ1>OKp5hDHm`gQjbmY@NB z15QW=!Wx|0{?AW7Tjzfy3go$?(s*sL2;@E{menC$?L1@qw2bRMmDtvx06KzSe}G zS8(XNALq`+-DdA5*zQn)J4n3)*CT>c9;})D^fHwF&1x;oI#_Zs+iEY|r`mbD&U)eE zCu#ldl7x9kT(E;3xR76fKP>jN)ftdpbjsy+&Vl?0>As5Xx&=B@)ZbloM56?{w2|iL zrV#vTcmMY(f4$z4K&@52@tuCh4H`k7E;y&&xs7dypI_s8+wei^EcEW+ALb5`*I}O` za#&J3^8GmW|CcNfg<>bfil49zCgkjJttI%cGC>{9KiID|-fP4pe@UbfVfF7uz@P7t zk7ch}AKqA4*V&jLtTx!4Rnr*WYoNJ zD)_y0tb40`!uP59+2{Lm9DJnJQb`@~4C4{dnrTtuHnGc6$-cI^mf-BQppWXI)6Png z-KTlRdO=4&(O6f1S-N66VQ)i&eXX3gqj{YjWkSq$MU$_*tIzULGq;6Q*At z^V8YZqam{27?0F(+p+a0tWmG?LvG)U-n`4bOQ2uR{V4=@_1B>kxZ&i#hX`tHYGByxpIF2{d;R?RUL5C-*iJFM#LnYfD+pne82aUDpl`FMbg zJ;OMQ>5WE6ck=UjAZHUI+C4qj%~yiKpBQ{#xB+#@fpwrsQCFw2xT_*y^_B6<{p=To zi^omAIJgtPz|=by#5~WkV=UjAf81bf!UD~Xlt<$4Z|;py=fER#V@r-vtA%$bOFW%I znLvqVO}X`>G9~u!obJ7~?C{>)Y-)3vU*DTbI6v0?Y4Hd#54?m$4y%hJycmp71ngBG z9=@crD--nbOz)|2){SS+_BOLiv^#cpCf$Z?zTd_)ug3rUnc%wgzAZyGz;SCeS4UE6 z15_-gTbSC(mNX%i8M|uvqY2kGsx_EYB%e7`=f_vhR{kAi_Y`u#d-;| zAEG4nQss$viAZ$oLNQ0EV@nVBk=am2J|`fkT4j`b908?V>_^ zWJCFU_^B6nm(IAg|G4S4vJgP}!{sf*&DLmQz7}3(vp+lfkO4nUMszU!If^;@h$1Ku5DRp8r)UGed(kMV# zJEEyG&Fv<~!m!)MQUkR{UMOV(aElqH-x;MVUQmY>1QK%0p!V(K~At4<4pJRf7cvPypU zsKJdZr>)C|^b74WR>x*^sv$V)oRNa>ieR?MkT1kO2JSYvId?nwQBEg@x-qjpt!Jjd zQ~DZZD5RpHK?|nEcnFCJiA0Mt$b8SZl%8wry#7XiYN}dyfi^^bPpFmaha^BpB+ zQR4|IGNvgB!y8!`iWpMU&d0CJdP(x91o!J~f1`e`F4|p_)5?WJD59HylPXIX>q6sa%hYWuvDgKHOqncz1Mmf@{gsCtgS_i5WF@g*Ik>xKQT?M&e@~G_XxLlZX^x+f6xz;1&epf@exmS~h@%S8 zW~;QhrDf!>IW=sXWb7X>Fy`%+P5CCDb=kZ+Gg^`b^gyl2YIHnl#^K7>YQ16-;6Wz{-x^?!NeahUM8XItb!sB*ibbi({Rj(C&gz=`Xtg;O6 z@5+~jz((55v?j@8s_1CyI86UTzgr)_P!#0(&d*%@x>T{ZyAv56&u?>K)na#IW3icr zmXN4XboS|27~0#rIzld+k9o!xLtKYHr(^na9K10OHZpb4t$ZFe+Tf;i_9fHRcjg~6 z-+7;Srh~V-A!JZ#ChL6$^l%E99Y-!^SoD3}BKwNML|5+&=6){{X|Qf=lyba(n=-?! z=kiX5bL&jZCpuQm5aZ&Aps;Fwl~J@f)A;i8o*|W>^NdDYfp2~NDL%&)`fsnNhd6Cd zMoY6Ct6CedX5Klm_ek#SyCKn}Dl`uhp@nJJd0~cov1rP;gD}u$Rj+vaej{cj20hk^ za}|mj8i_e9NyfUolif_hcb7Y4CcBoOWXT`<*(ofTy_VoIZ(Yr1-8QrUP0%678O9WC zktVThX(sd-_3lWu5+ntx{mk7E!sokUt`nh z?g{uX0&`kf@PfrEO$PRMuLe$6Z@oz@C}1j9=oT}!Ocs1?elQ{>RE3Kt)!kVYrng`= zX{o)my_GQMeBZ>PgYTpD%=1n4NB3wq8-_&bDh*OA7HbVf?K}thD)JR#winY5ddkBq zx!=T{SYQ6wVd}FpjS>QuGc$0l3WtU_9ap=TL8n;#-DDKTORK|bt1ttq_gVM4l$gL6gg$pyZMD!5-U2=v z%tYI6R{NZ5LKce7Vx^~hZ#!Y{8t3wv`vIYByOZ%-L5?@B{#+uflg#XiV8`x0Qi zfbk%8xD*=jihh)Hi50tFPq@n0GqcW3-v5-f{;AM+e)u9yd!lP<;lRkwoW;7yG3mwV z=uKfXdi!&RQg!xTdt!jMSox0ZgrB2hZYb~CKb~+8iatU)!17TR6XjH0cJ9sBVq#Rz zGc1BTXOe_`DOB*Ta^?QqvqaUXzjo6hp%izdJDvHkMb<-W!`nZE;tTy=AkX=|W0U7J z>FnwOrqG1K5Opv5PE%DebV9T0bK>rlnCLsEm12uK3d#f+FH#Gq$ivD6L{fR_`>vbj zh)=uvFZSMA8!^$DX=!ebkPwVtPY_rgtiPE7qqXByU+`12NIwYy1Mf;ImBJ%W%|}V{ zS#LeV?4vtU74#dF*;{6xuLn@JZ-Nx2#y`LXgRg>jDfyByoVwWSw>a3ti@{fuxZ4H0 z4cXsO&^`LK{3WFdUJJ|LJ}c1}R{!>i?vlMR&TlI0YoRZ`As6%ujD3m0;9Flsz#$J$ zuHMi0f5UWd{?FJ$dG*zSO{Iq5egFFp?##X)vOfG=?2oL|H`D*`x8L{ScfEx1di}Dx zxM!fDD_}d$#?0*7v)TDcCCDvDZcxk77&xlmWe40mCcgex5|83?Wp&l%YU)3}-Of+W z04h!pO$9l5F`473148kGgUmd<2clSDO;U)#9Y$jQLY*L+ zi{MIuEvJr!z`$%kZp7uVeN+@Y{>UeP-_K{S4O`~)&6zT1)|>~xq-baYY;kUYHiq?k ofZ+~moj3gD#ok_TIQ#KGbAZ#ewlx#tmVs1yy85}Sb4q9e04=Rcontroller: dev_reset_default +->controller: Prepare setup( execute 4.1.2 test) +controller->backhaul_manager: send_cmdu(Backhaul Steering Request with correct data) +backhaul_manager->backhaul_manager: handle_1905_msg(\n Backhaul Steering Request message,\n Backhaul Steering Request TLV(0x9E)) +backhaul_manager->controller: send_cmdu(ACK) +backhaul_manager->backhaul_manager: sta_wlan_hal->connect(bssid,channel) +backhaul_manager->wpa_supplicant: NETWORK_ENABLE +wpa_supplicant->ctt_agent_2: Association Request +ctt_agent_2->wpa_supplicant: Association Response +wpa_supplicant->backhaul_manager: ENABLED +backhaul_manager->controller: send_cmdu(Backhaul Steering Response message) +controller->controller: handle_1905_msg(Backhaul Steering Response message) +controller->backhaul_manager: send_cmdu(Backhaul Steering Request with bogus channel number) +backhaul_manager->backhaul_manager: handle_1905_msg(\n Backhaul Steering Request message,\n Backhaul Steering Request TLV(0x9E)) +backhaul_manager->controller: send_cmdu(ACK) +backhaul_manager->controller: send_cmdu(Backhaul Steering Response message) +controller->controller: handle_1905_msg(Backhaul Steering Response message) +@enduml From 1c44d2129ea50c5625acb70091d0a357081da9e2 Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Tue, 2 Jun 2020 11:20:52 +0300 Subject: [PATCH 027/453] tests: add device to boardfarm config Add "prplWRT" device "rax40-1" to boardfarm config. In order to this config to work, you have to: 1. Create docker bridge network with name "prplMesh-net-rax40-1". `docker network create --driver=bridge prplMesh-net-rax40-1` 2. Include interface connected to the board in docker network. `ip link set $RAX40_IFACE master $DOCKER_BRIDGE` 3. Config relies on RAX40 consoles to be at "/dev/ttyUSB0". You may have to adjust this path to fit your system. Those steps are required, as regular user is not permitted to attach interfaces to the bridge. Signed-off-by: Anton Bilohai --- .../boardfarm_prplmesh/prplmesh_config.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json index b8114775c1..e16a4b5bf3 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json @@ -16,5 +16,22 @@ "conn_cmd": "" } ] + }, + "netgear-rax40-1": { + "name": "agent-rax40", + "board_type": "prplWRT", + "role": "agent", + "docker_network": "prplMesh-net-rax40-1", + "connection_type": "local_serial", + "conn_cmd": "cu -s 115200 -l /dev/ttyUSB0", + "devices": [ + { + "name": "controller", + "type": "prplmesh_docker", + "role": "controller", + "docker_network": "prplMesh-net-rax40-1", + "conn_cmd": "" + } + ] } } From a6114bb89ea8fd76470b5183c7a2a430255eb330 Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Tue, 2 Jun 2020 11:48:54 +0300 Subject: [PATCH 028/453] tests: boardfarm: add prplWRT device Add prplWRT class which represents device running prplWRT with prplMesh installed. This class has required methods to init the board and execute InitialApConfig test on board. Signed-off-by: Anton Bilohai --- .../devices/prplmesh_prplwrt.py | 90 ++++++++++++++++--- 1 file changed, 80 insertions(+), 10 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py index 877373aadf..e159ea089d 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py @@ -6,19 +6,28 @@ ############################################################### import boardfarm -from boardfarm.devices import OpenWrtRouter -from environment import ALEntityPrplWrt, _get_bridge_interface +import json +import os +import pexpect +import subprocess +import sys + from .prplmesh_base import PrplMeshBase +from boardfarm.devices import connection_decider +from boardfarm.devices.openwrt_router import OpenWrtRouter +from environment import ALEntityPrplWrt, _get_bridge_interface +from ipaddress import IPv4Network, IPv4Address from sniffer import Sniffer class PrplMeshPrplWRT(OpenWrtRouter, PrplMeshBase): """prplWRT burned device with prplMesh installed.""" - model = "prplWRT" + model = ("prplWRT") prompt = ['root\\@OpenWrt:/#', '/#', '@OpenWrt:/#'] wan_iface = "eth1" uboot_eth = "eth0_1" + linesep = "\r" agent_entity = None controller_entity = None @@ -27,17 +36,41 @@ def __init__(self, *args, **kwargs): self.args = args self.kwargs = kwargs config = kwargs.get("config", kwargs) + + self.unique_id = os.getenv("SUDO_USER", os.getenv("USER", "")) self.docker_network = config.get("docker_network", "prplMesh-net-{}".format(self.unique_id)) self.role = config.get("role", "agent") - if self.role == "controller": - self.controller_entity = ALEntityPrplWrt(self.name, is_controller=True) - else: - self.agent_entity = ALEntityPrplWrt(self.name, is_controller=False) + self.connection_type = config.get("connection_type", None) + self.conn_cmd = config.get("conn_cmd", None) + + self.connection = connection_decider.connection(device=self, + conn_type=kwargs['connection_type'], + **kwargs) + self.connection.connect() + self.name = "-".join((config.get("name", "rax40"), self.unique_id)) + self.consoles = [self] + self.logfile_read = sys.stdout + + self.wan_network = self.get_docker_subnet(self.docker_network) + self.set_iface_to_bridge(self.wan_iface) + self.set_iface_ip("br-lan", self.wan_network[+245], self.wan_network.prefixlen) self.wired_sniffer = Sniffer(_get_bridge_interface(self.docker_network), boardfarm.config.output_dir) - self.check_status() + if self.role == "controller": + self.controller_entity = ALEntityPrplWrt(self, is_controller=True) + else: + self.agent_entity = ALEntityPrplWrt(self, is_controller=False) + self.prplMesh_start_agent() + + def _prplMesh_exec(self, mode: str): + """Send line to prplmesh initd script.""" + self.sendline("/etc/init.d/prplmesh {}".format(mode)) + + def kill_console_at_exit(self): + """Kill connections on device termination.""" + self.connection.close() def check_status(self) -> bool: """Check status of device, return bool to indicate state. @@ -45,11 +78,15 @@ def check_status(self) -> bool: It is used by boardfarm to indicate that spawned device instance is ready for test and also after test - to insure that device still operational. """ + return True + + def prplMesh_check_state(self) -> bool: + """ Check prplMesh status. Return True if operational.""" self.sendline("/etc/init.d/prplmesh status") match = self.expect( - ["OPERATIONAL", self.device.pexpect.EOF, self.device.pexpect.TIMEOUT], + ["operational", "FAIL", pexpect.EOF, pexpect.TIMEOUT], timeout=10) - if match == 1: + if match == 0: return True else: return False @@ -67,3 +104,36 @@ def touch(self): Purpose is to keep consoles active, so they don't disconnect for long running activities. """ pass + + def get_docker_subnet(self, docker_network: str) -> IPv4Network: + """Get subnet used by docker network.""" + docker_network_inspect_cmd = ('docker', 'network', 'inspect', docker_network) + inspect_raw = subprocess.run(docker_network_inspect_cmd, stdout=subprocess.PIPE) + if inspect_raw.returncode != 0: + # Assume network doesn't exist yet. Create it. + # Raise an exception if it fails (check=True). + subprocess.run(('docker', 'network', 'create', docker_network), check=True, + stdout=subprocess.DEVNULL) + # Inspect again, now raise if it fails (check=True). + inspect_raw = subprocess.run(docker_network_inspect_cmd, check=True, + stdout=subprocess.PIPE) + inspect_json = json.loads(inspect_raw.stdout) + + return IPv4Network(inspect_json[0]["IPAM"]["Config"][0]["Subnet"]) + + def set_iface_to_bridge(self, iface: str) -> bool: + """Add specified interface to the specified bridge.""" + ip_command = ("ip link set {} master br-lan".format(iface)) + self.sendline(ip_command) + self.expect(self.prompt, timeout=10) + + def set_iface_ip(self, iface: str, ip: IPv4Address, prefixlen :int) -> bool: + """Set interface IPv4 address.""" + self.sendline("ip a add {}/{} dev {}".format(ip, prefixlen, iface)) + self.expect(self.prompt, timeout=10) + + def prplMesh_start_agent(self) -> bool: + """Start prplMesh in certification_mode agent. Return true if done.""" + self._prplMesh_exec("certification_mode agent") + self.expect_exact("CAC timer expired", timeout=120) + self.expect_exact("device br-lan entered promiscuous mode", timeout=40) From 7c68831e329ffc02f15542dfdd2d9c942ccda96d Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Tue, 2 Jun 2020 12:05:03 +0300 Subject: [PATCH 029/453] tests: environment.py: complete prplWRT entities prplWRT entities are not debugged, as there was no way to test them at the moment of commit. `_device_wait_for_log` method: count in start_line given to it, format return as it's expected by callers. `ALEntityPrplWrt` constructor: get main bridge name from config. Parse output of console in Python to be less dependent on board. `RadioHostapd` constructor: remove usage of `ip -o` as `-o` option is bugged on RAX40 and mutes output of `ip` command. Signed-off-by: Anton Bilohai --- tests/environment.py | 97 ++++++++++++++++++++++++++++++-------------- 1 file changed, 67 insertions(+), 30 deletions(-) diff --git a/tests/environment.py b/tests/environment.py index 155436df41..08c31f9db8 100644 --- a/tests/environment.py +++ b/tests/environment.py @@ -225,16 +225,23 @@ def logfilename(program): def _device_wait_for_log(device: None, log_path: str, regex: str, - start_line: int, timeout: int) -> bool: - """Waits for log mathing regex expression to show up.""" - device.sendline("tail -n10 -f {}".format(log_path)) - match = device.expect( - pattern=[regex, device.pexpect.EOF, device.pexpect.TIMEOUT], - timeout=timeout) - if match == 1: - return True + timeout: int, start_line: int = 0): + """Waits for log matching regex expression to show up.""" + device.sendline("tail -f -n +{:d} {}".format(start_line + 1, log_path)) + device.expect(regex, timeout=timeout) + match = device.match.group(0) + # Send Ctrl-C to interrupt tail -f + device.send('\003') + device.expect(device.prompt) + if match: + device.sendline("tail -n +{:d} {} | grep -n \"{}\"".format(start_line, log_path, match)) + # Typical output of grep -n from log: "line_num:severity" + # this regex has to capture just number of line in log + device.expect(r"(?P[0-9]+):[A-Z]+\s[0-9]", timeout=timeout) + matched_line = int(device.match.group('line_number')) + start_line + return (True, matched_line, match) else: - return False + return (False, start_line, None) class ALEntityDocker(ALEntity): @@ -254,7 +261,8 @@ def __init__(self, name: str, is_controller: bool = False): config_file_name = 'beerocks_agent.conf' with open(os.path.join(installdir, 'config', config_file_name)) as config_file: ucc_port = \ - re.search(r'ucc_listener_port=(?P[0-9]+)', config_file.read()).group('port') + re.search(r'ucc_listener_port=(?P[0-9]+)', + config_file.read()).group('port') # On WSL, connect to the locally exposed container port if on_wsl: @@ -265,8 +273,8 @@ def __init__(self, name: str, is_controller: bool = False): else: device_ip_output = self.command( 'ip', '-f', 'inet', 'addr', 'show', self.bridge_name) - device_ip = re.search( - r'inet (?P[0-9.]+)', device_ip_output.decode('utf-8')).group('ip') + device_ip = re.search(r'inet (?P[0-9.]+)', + device_ip_output.decode('utf-8')).group('ip') ucc_socket = UCCSocket(device_ip, ucc_port) mac = ucc_socket.dev_get_parameter('ALid') @@ -293,7 +301,8 @@ class RadioDocker(Radio): def __init__(self, agent: ALEntityDocker, iface_name: str): self.iface_name = iface_name ip_output = agent.command("ip", "-o", "link", "list", "dev", self.iface_name).decode() - mac = re.search(r"link/ether (([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2})", ip_output).group(1) + mac = re.search(r"link/ether (([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2})", + ip_output).group(1) super().__init__(agent, mac) # Since dummy bwl always uses the first VAP, in practice we always have a single VAP with @@ -404,16 +413,16 @@ def launch_environment_docker(unique_id: str, skip_init: bool = False, tag: str class ALEntityPrplWrt(ALEntity): """Abstraction of ALEntity in real device.""" - def __init__(self, name: str, device: None, is_controller: bool = False): + def __init__(self, device: None, is_controller: bool = False): self.device = device - self.name = name - self.bridge_name = 'br-lan' + self.name = device.name if is_controller: self.config_file_name = '/opt/prplmesh/config/beerocks_controller.conf' else: self.config_file_name = '/opt/prplmesh/config/beerocks_agent.conf' +<<<<<<< HEAD ucc_port = self.command(("grep \"ucc_listener_port\" {} " "| cut -d'=' -f2 | cut -d\" \" -f 1").format(self.config_file_name)) @@ -425,45 +434,71 @@ def __init__(self, name: str, device: None, is_controller: bool = False): "grep log_files_path {} | cut -d=\'=\' -f2".format(self.config_file_name)) ucc_socket = UCCSocket(device_ip, ucc_port) +======= + ucc_port_raw = self.command("grep \"ucc_listener_port\" {}".format(self.config_file_name)) + ucc_port = int(re.search(r'ucc_listener_port=(?P[0-9]+)', + ucc_port_raw).group('port')) + bridge_name_raw = self.command("grep \"bridge_iface\" {}".format(self.config_file_name)) + self.bridge_name = re.search(r'bridge_iface=(?P.+)\r\n', + bridge_name_raw).group('bridge') + + # Multiple IPs may be set to same interface. We are interested in the last one, which is set + # by test during board init procedure. + device_ip_raw = self.command( + "ip -family inet addr show {} | tail -n 2".format(self.bridge_name)) + self.device_ip = re.search(r'inet (?P[0-9.]+)', + device_ip_raw).group('ip') + + log_folder_raw = self.command( + "grep log_files_path {}".format(self.config_file_name)) + self.log_folder = re.search(r'log_files_path=(?P[a-zA-Z0-9_\/]+)', + log_folder_raw).group('log_path') + + ucc_socket = UCCSocket(self.device_ip, int(ucc_port)) +>>>>>>> tests: environment.py: complete prplWRT entities mac = ucc_socket.dev_get_parameter('ALid') super().__init__(mac, ucc_socket, installdir, is_controller) # We always have two radios, wlan0 and wlan2 - RadioHostapd(self, "wlan0", device=self) - RadioHostapd(self, "wlan2", device=self) + RadioHostapd(self, "wlan0") + RadioHostapd(self, "wlan2") def command(self, *command: str) -> bytes: """Execute `command` in device and return its output.""" - self.device.sendline(command) - return self.device.read() + self.device.sendline(" ".join(command)) + self.device.expect(self.device.prompt, timeout=10) + return self.device.before def wait_for_log(self, regex: str, start_line: int, timeout: float) -> bool: """Poll the entity's logfile until it contains "regex" or times out.""" program = "controller" if self.is_controller else "agent" + # Multiply timeout by 100, as test sets it in float. return _device_wait_for_log(self.device, "{}/beerocks_{}.log".format(self.log_folder, program), - regex, start_line, timeout) + regex, start_line, timeout*100) class RadioHostapd(Radio): """Abstraction of real Radio in prplWRT device.""" - def __init__(self, agent: ALEntityPrplWrt, bssid: str, device: None): - self.iface_name = bssid - ip_output = agent.command("ip -o link list dev {}".format(self.iface_name)) - mac = re.search(r"link/ether (([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2})", ip_output).group(1) - self.log_folder = self.command( - "grep log_files_path {} | cut -d=\'=\' -f2".format(self.config_file_name)) + def __init__(self, agent: ALEntityPrplWrt, iface_name: str): + self.iface_name = iface_name + self.agent = agent + ip_raw = self.agent.command("ip link list dev {}".format(self.iface_name)) + mac = re.search(r"link/ether (([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2})", + ip_raw).group(1) + self.log_folder = agent.log_folder super().__init__(agent, mac) VirtualAPHostapd(self, mac) VirtualAPHostapd(self, mac) - def wait_for_log(self, regex: str, start_line: int, timeout: float) -> bool: + def wait_for_log(self, regex: str, start_line: int, timeout: float): ''' Poll the Radio's logfile until it match regular expression ''' - return _device_wait_for_log(self.device, "{}/beerocks_agent_{}.log".format( - self.log_folder, self.iface_name), regex, start_line, timeout) + # Multiply timeout by 100, as test sets it in float. + return _device_wait_for_log(self.agent.device, "{}/beerocks_agent_{}.log".format( + self.log_folder, self.iface_name), regex, timeout*100, start_line) class VirtualAPHostapd(VirtualAP): @@ -475,7 +510,9 @@ def __init__(self, radio: RadioHostapd, bssid: str): def associate(self, sta: Station) -> bool: ''' Associate "sta" with this VAP ''' # TODO: complete this stub + return True def disassociate(self, sta: Station) -> bool: ''' Disassociate "sta" from this VAP.''' # TODO: complete this stub + return True From 09c4df20d0a6677e6bb36a1388a1d83d7c9a5033 Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Tue, 2 Jun 2020 14:09:05 +0300 Subject: [PATCH 030/453] tests: boardfarm: InitialApConfig - too greedy regex search Currently, test is trying to match r".* Controller configuration \(WSC M2 Encrypted Settings\)") which is greedy and captures all chars before key message. Chars captured by `.*` are not important for us. Get rid of `.*` in the beginning of regex. Reorder expected logs to match them in right order. Signed-off-by: Anton Bilohai --- .../tests/initial_ap_config.py | 16 ++++++++++------ .../tests/prplmesh_base_test.py | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py index d8432cf1ba..0567c10f20 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py @@ -14,6 +14,10 @@ def runTest(self): if dev.agent_entity: dev.wired_sniffer.start(self.__class__.__name__ + "-" + dev.name) + self.check_log(dev.agent_entity.radios[0], + r"Controller configuration \(WSC M2 Encrypted Settings\)") + self.check_log(dev.agent_entity.radios[1], + r"Controller configuration \(WSC M2 Encrypted Settings\)") self.check_log(dev.agent_entity.radios[0], r"WSC Global authentication success") self.check_log(dev.agent_entity.radios[1], @@ -22,13 +26,13 @@ def runTest(self): r"KWA \(Key Wrap Auth\) success") self.check_log(dev.agent_entity.radios[1], r"KWA \(Key Wrap Auth\) success") - self.check_log(dev.agent_entity.radios[0], - r".* Controller configuration \(WSC M2 Encrypted Settings\)") - self.check_log(dev.agent_entity.radios[1], - r".* Controller configuration \(WSC M2 Encrypted Settings\)") - - dev.wired_sniffer.stop() @classmethod def teardown_class(cls): """Teardown method, optional for boardfarm tests.""" + test = cls.test_obj + for dev in test.dev: + if dev.agent_entity: + print("Sniffer - stop") + dev.agent_entity.device.send('\003') + dev.wired_sniffer.stop() diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/prplmesh_base_test.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/prplmesh_base_test.py index 9a9f32ef9f..e981fb65db 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/prplmesh_base_test.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/prplmesh_base_test.py @@ -16,7 +16,7 @@ class PrplMeshBaseTest(bft_base_test.BftBaseTest): """ def check_log(self, entity_or_radio: Union[env.ALEntity, env.Radio], regex: str, - start_line: int = 0, timeout: float = 0.3) -> bool: + start_line: int = 0, timeout: float = 0.6) -> bool: result, line, match = entity_or_radio.wait_for_log(regex, start_line, timeout) if not result: raise Exception From 7d460f30127f3d6d6523a31bb21ad54fd5d3d74f Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Fri, 5 Jun 2020 23:16:44 +0300 Subject: [PATCH 031/453] tests: boardfarm: move to ssh as primary connection Currently, boardfarm tests are using UART (serial) connection as main channel to interact with the board. Sadly, but UART on RAX40 board frequently suffers from tty overruns. Hence, tests are frequently failed due to corrupted input line. Moving to ssh as primary channel resolves issue above. It's faster, so chance of meeting input overruns is significantly low. But, via ssh we are unable to see logs from the Intel WiFi driver. Logs from the driver are used to detect when device has prplMesh in operational state. As those logs are not longer shown, we have to come up with other way to check when prplMesh is operational. Add fallback mechanism: if IP address of DUTs wan is not set - retrieve IP subnet from docker network of set up and choose .245 address. This configuration happens over UART. Move from UART to SSH as primary communication channel. Add prplmesh_status_check method to tests, to check if prplMesh on device is operational. Signed-off-by: Anton Bilohai --- .../devices/prplmesh_docker.py | 7 ++ .../devices/prplmesh_prplwrt.py | 99 +++++++++++++------ .../boardfarm_prplmesh/prplmesh_config.json | 1 - .../tests/initial_ap_config.py | 5 +- .../tests/prplmesh_base_test.py | 9 ++ tests/environment.py | 25 +---- 6 files changed, 91 insertions(+), 55 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py index aa41f53691..faad645446 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py @@ -83,3 +83,10 @@ def isalive(self): States that device is operational and its consoles are accessible. """ return True + + def prprlmesh_status_check(self) -> bool: + """Check prplMesh status by executing status command to initd service. + Return True if operational. + """ + self.check_status() + return True diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py index e159ea089d..e095e9c8fe 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py @@ -9,8 +9,10 @@ import json import os import pexpect +import signal import subprocess import sys +import time from .prplmesh_base import PrplMeshBase from boardfarm.devices import connection_decider @@ -23,8 +25,8 @@ class PrplMeshPrplWRT(OpenWrtRouter, PrplMeshBase): """prplWRT burned device with prplMesh installed.""" - model = ("prplWRT") - prompt = ['root\\@OpenWrt:/#', '/#', '@OpenWrt:/#'] + model = "prplWRT" + prompt = ['root\\@OpenWrt:/#', '/#', '@OpenWrt:/#', "@OpenWrt:~#"] wan_iface = "eth1" uboot_eth = "eth0_1" linesep = "\r" @@ -43,34 +45,67 @@ def __init__(self, *args, **kwargs): self.role = config.get("role", "agent") self.connection_type = config.get("connection_type", None) self.conn_cmd = config.get("conn_cmd", None) + self.wan_ip = config.get("wan_ip", None) + self.username = config.get("username", "root") + + self.name = "-".join((config.get("name", "netgear-rax40"), self.unique_id)) + + # If no WAN IP is set in config file retrieve IP from docker network set in config + # X.X.X.245 IP will be selected from docker network + if not self.wan_ip: + self.connection = connection_decider.connection(device=self, + conn_type="local_serial", + **kwargs) + self.connection.connect() + self.consoles = [self] + self.logfile_read = sys.stdout + self.wan_network = self.get_docker_subnet() + self.wan_ip = self.wan_network[+245] + self.set_iface_ip("br-lan", self.wan_ip, self.wan_network.prefixlen) + self.connection.close() + self.kill(signal.SIGTERM) + # Removal of PID is required by pexpect in order to spawn a new process + # serial connection should be terminated by 2 commands above + self.pid = None + self.wired_sniffer = Sniffer(_get_bridge_interface(self.docker_network), + boardfarm.config.output_dir) self.connection = connection_decider.connection(device=self, - conn_type=kwargs['connection_type'], - **kwargs) + conn_type="ssh", + conn_cmd="ssh {}@{}".format( + self.username, self.wan_ip)) self.connection.connect() - - self.name = "-".join((config.get("name", "rax40"), self.unique_id)) + # Append active connection to the general array for logging self.consoles = [self] + # Point what to log as data read from child process of pexpect + # Result: boardfarm will log communication in separate file self.logfile_read = sys.stdout + self.add_iface_to_bridge(self.wan_iface, "br-lan") - self.wan_network = self.get_docker_subnet(self.docker_network) - self.set_iface_to_bridge(self.wan_iface) - self.set_iface_ip("br-lan", self.wan_network[+245], self.wan_network.prefixlen) - self.wired_sniffer = Sniffer(_get_bridge_interface(self.docker_network), - boardfarm.config.output_dir) if self.role == "controller": self.controller_entity = ALEntityPrplWrt(self, is_controller=True) else: self.agent_entity = ALEntityPrplWrt(self, is_controller=False) - self.prplMesh_start_agent() + self.prplmesh_start_agent() def _prplMesh_exec(self, mode: str): """Send line to prplmesh initd script.""" self.sendline("/etc/init.d/prplmesh {}".format(mode)) - def kill_console_at_exit(self): - """Kill connections on device termination.""" - self.connection.close() + def _prplmesh_status_poll(self, timeout: int = 120) -> bool: + """Poll prplMesh status for timeout time. + + Main agent and wlan0, wlan2 radios should be operational. + Return True if status is operational and timeout not reached. + """ + deadline = time.monotonic() + timeout + while time.monotonic() < deadline: + if self.prplMesh_check_state(): + break + time.sleep(5) + else: + return False + return True def check_status(self) -> bool: """Check status of device, return bool to indicate state. @@ -83,10 +118,12 @@ def check_status(self) -> bool: def prplMesh_check_state(self) -> bool: """ Check prplMesh status. Return True if operational.""" self.sendline("/etc/init.d/prplmesh status") - match = self.expect( - ["operational", "FAIL", pexpect.EOF, pexpect.TIMEOUT], - timeout=10) - if match == 0: + self.expect( + ["(?POK) Main agent.+" + "(?POK) wlan0.+" + "(?POK) wlan2", pexpect.TIMEOUT], + timeout=5) + if self.match is not pexpect.TIMEOUT: return True else: return False @@ -105,14 +142,14 @@ def touch(self): """ pass - def get_docker_subnet(self, docker_network: str) -> IPv4Network: + def get_docker_subnet(self) -> IPv4Network: """Get subnet used by docker network.""" - docker_network_inspect_cmd = ('docker', 'network', 'inspect', docker_network) + docker_network_inspect_cmd = ('docker', 'network', 'inspect', self.docker_network) inspect_raw = subprocess.run(docker_network_inspect_cmd, stdout=subprocess.PIPE) if inspect_raw.returncode != 0: # Assume network doesn't exist yet. Create it. # Raise an exception if it fails (check=True). - subprocess.run(('docker', 'network', 'create', docker_network), check=True, + subprocess.run(('docker', 'network', 'create', self.docker_network), check=True, stdout=subprocess.DEVNULL) # Inspect again, now raise if it fails (check=True). inspect_raw = subprocess.run(docker_network_inspect_cmd, check=True, @@ -121,19 +158,25 @@ def get_docker_subnet(self, docker_network: str) -> IPv4Network: return IPv4Network(inspect_json[0]["IPAM"]["Config"][0]["Subnet"]) - def set_iface_to_bridge(self, iface: str) -> bool: + def add_iface_to_bridge(self, iface: str, bridge: str) -> bool: """Add specified interface to the specified bridge.""" - ip_command = ("ip link set {} master br-lan".format(iface)) + ip_command = ("ip link set {} master {}".format(iface, bridge)) self.sendline(ip_command) self.expect(self.prompt, timeout=10) - def set_iface_ip(self, iface: str, ip: IPv4Address, prefixlen :int) -> bool: + def set_iface_ip(self, iface: str, ip: IPv4Address, prefixlen: int) -> bool: """Set interface IPv4 address.""" self.sendline("ip a add {}/{} dev {}".format(ip, prefixlen, iface)) self.expect(self.prompt, timeout=10) - def prplMesh_start_agent(self) -> bool: + def prplmesh_start_agent(self) -> bool: """Start prplMesh in certification_mode agent. Return true if done.""" self._prplMesh_exec("certification_mode agent") - self.expect_exact("CAC timer expired", timeout=120) - self.expect_exact("device br-lan entered promiscuous mode", timeout=40) + self.expect(self.prompt) + return True + + def prprlmesh_status_check(self) -> bool: + """Check prplMesh status by executing status command to initd service. + Return True if operational. + """ + return self._prplmesh_status_poll() diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json index e16a4b5bf3..7a55f651c2 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json @@ -22,7 +22,6 @@ "board_type": "prplWRT", "role": "agent", "docker_network": "prplMesh-net-rax40-1", - "connection_type": "local_serial", "conn_cmd": "cu -s 115200 -l /dev/ttyUSB0", "devices": [ { diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py index 0567c10f20..d80d0ce8c2 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py @@ -14,10 +14,11 @@ def runTest(self): if dev.agent_entity: dev.wired_sniffer.start(self.__class__.__name__ + "-" + dev.name) + self.prplmesh_status_check(dev.agent_entity.device) self.check_log(dev.agent_entity.radios[0], - r"Controller configuration \(WSC M2 Encrypted Settings\)") + r"\(WSC M2 Encrypted Settings\)") self.check_log(dev.agent_entity.radios[1], - r"Controller configuration \(WSC M2 Encrypted Settings\)") + r"\(WSC M2 Encrypted Settings\)") self.check_log(dev.agent_entity.radios[0], r"WSC Global authentication success") self.check_log(dev.agent_entity.radios[1], diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/prplmesh_base_test.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/prplmesh_base_test.py index e981fb65db..5e03247c77 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/prplmesh_base_test.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/prplmesh_base_test.py @@ -21,3 +21,12 @@ def check_log(self, entity_or_radio: Union[env.ALEntity, env.Radio], regex: str, if not result: raise Exception return result, line, match + + def prplmesh_status_check(self, entity_or_radio: Union[env.ALEntity, env.Radio]) -> bool: + """Check prplMesh status by executing status command to initd service. + Return True if operational. + """ + result = entity_or_radio.prprlmesh_status_check() + if not result: + raise Exception + return result diff --git a/tests/environment.py b/tests/environment.py index 08c31f9db8..42e75cc07c 100644 --- a/tests/environment.py +++ b/tests/environment.py @@ -422,40 +422,17 @@ def __init__(self, device: None, is_controller: bool = False): else: self.config_file_name = '/opt/prplmesh/config/beerocks_agent.conf' -<<<<<<< HEAD - ucc_port = self.command(("grep \"ucc_listener_port\" {} " - "| cut -d'=' -f2 | cut -d\" \" -f 1").format(self.config_file_name)) - - device_ip_output = self.command( - "ip -f inet addr show {} | head -n 2".format(self.bridge_name)) - device_ip = re.search( - r'inet (?P[0-9.]+)', device_ip_output.decode('utf-8')).group('ip') - self.log_folder = self.command( - "grep log_files_path {} | cut -d=\'=\' -f2".format(self.config_file_name)) - - ucc_socket = UCCSocket(device_ip, ucc_port) -======= ucc_port_raw = self.command("grep \"ucc_listener_port\" {}".format(self.config_file_name)) ucc_port = int(re.search(r'ucc_listener_port=(?P[0-9]+)', ucc_port_raw).group('port')) bridge_name_raw = self.command("grep \"bridge_iface\" {}".format(self.config_file_name)) self.bridge_name = re.search(r'bridge_iface=(?P.+)\r\n', bridge_name_raw).group('bridge') - - # Multiple IPs may be set to same interface. We are interested in the last one, which is set - # by test during board init procedure. - device_ip_raw = self.command( - "ip -family inet addr show {} | tail -n 2".format(self.bridge_name)) - self.device_ip = re.search(r'inet (?P[0-9.]+)', - device_ip_raw).group('ip') - log_folder_raw = self.command( "grep log_files_path {}".format(self.config_file_name)) self.log_folder = re.search(r'log_files_path=(?P[a-zA-Z0-9_\/]+)', log_folder_raw).group('log_path') - - ucc_socket = UCCSocket(self.device_ip, int(ucc_port)) ->>>>>>> tests: environment.py: complete prplWRT entities + ucc_socket = UCCSocket(str(self.device.wan_ip), int(ucc_port)) mac = ucc_socket.dev_get_parameter('ALid') super().__init__(mac, ucc_socket, installdir, is_controller) From 311e931775c0aa5076d8a93d014ca9e54a65bb61 Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Wed, 10 Jun 2020 12:01:44 +0300 Subject: [PATCH 032/453] tests: boardfarm: docker devices support of InitialAPConfig teardown Teardown section of InitialAPConfig test introduced by port of this test to prplWRT devices is incompatible with dockerized devices. It uses `device.send` method which is not available for docker devices. Also, prplmesh_status_check method isn't working for docker devices due to missing link between AlEntityDocker and PrplMeshDocker device. Following EAFP strategy, surround sent of Ctrl+C in try-catch block. Add link between AlEntityDocker and PrplMeshDocker as it done for prplWRT device and restore prplmesh_status_check method functionality. Signed-off-by: Anton Bilohai --- .../devices/prplmesh_docker.py | 4 ++-- .../devices/prplmesh_prplwrt.py | 4 ++-- .../tests/initial_ap_config.py | 9 +++++++-- tests/environment.py | 18 +++++++++++++----- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py index faad645446..d4f9870d3c 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py @@ -51,14 +51,14 @@ def __init__(self, *args, **kwargs): self._run_shell_cmd(docker_cmd, docker_args) time.sleep(self.delay) - self.controller_entity = ALEntityDocker(self.name, is_controller=True) + self.controller_entity = ALEntityDocker(self.name, device=self, is_controller=True) else: # Spawn dockerized agent docker_args.append("start-agent") self._run_shell_cmd(docker_cmd, docker_args) time.sleep(self.delay) - self.agent_entity = ALEntityDocker(self.name, is_controller=False) + self.agent_entity = ALEntityDocker(self.name, device=self, is_controller=False) self.wired_sniffer = Sniffer(_get_bridge_interface(self.docker_network), boardfarm.config.output_dir) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py index e095e9c8fe..b8e9120c6c 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py @@ -100,7 +100,7 @@ def _prplmesh_status_poll(self, timeout: int = 120) -> bool: """ deadline = time.monotonic() + timeout while time.monotonic() < deadline: - if self.prplMesh_check_state(): + if self.get_prplMesh_status(): break time.sleep(5) else: @@ -115,7 +115,7 @@ def check_status(self) -> bool: """ return True - def prplMesh_check_state(self) -> bool: + def get_prplMesh_status(self) -> bool: """ Check prplMesh status. Return True if operational.""" self.sendline("/etc/init.d/prplmesh status") self.expect( diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py index d80d0ce8c2..c959dadb21 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py @@ -14,7 +14,7 @@ def runTest(self): if dev.agent_entity: dev.wired_sniffer.start(self.__class__.__name__ + "-" + dev.name) - self.prplmesh_status_check(dev.agent_entity.device) + self.prplmesh_status_check(dev.agent_entity) self.check_log(dev.agent_entity.radios[0], r"\(WSC M2 Encrypted Settings\)") self.check_log(dev.agent_entity.radios[1], @@ -35,5 +35,10 @@ def teardown_class(cls): for dev in test.dev: if dev.agent_entity: print("Sniffer - stop") - dev.agent_entity.device.send('\003') + # Send Ctrl+C to the device to terminate "tail -f" + # Which is used to read log from device. Required only for tests on HW + try: + dev.agent_entity.device.send('\003') + except AttributeError: + pass dev.wired_sniffer.stop() diff --git a/tests/environment.py b/tests/environment.py index 42e75cc07c..675397d33f 100644 --- a/tests/environment.py +++ b/tests/environment.py @@ -249,10 +249,13 @@ class ALEntityDocker(ALEntity): The entity is defined from the name of the container, the rest is derived from that. ''' - - def __init__(self, name: str, is_controller: bool = False): + # NOTE: name arg can be also extracted from the device class itself, but test_flows.py + # don't have it. We can remove this arg as soon, as we drop test_flows.py + def __init__(self, name: str, device: None = None, is_controller: bool = False): self.name = name self.bridge_name = 'br-lan' + if device: + self.device = device # First, get the UCC port from the config file if is_controller: @@ -294,10 +297,12 @@ def wait_for_log(self, regex: str, start_line: int, timeout: float) -> bool: program = "controller" if self.is_controller else "agent" return _docker_wait_for_log(self.name, [program], regex, start_line, timeout) + def prprlmesh_status_check(self): + return self.device.prprlmesh_status_check() + class RadioDocker(Radio): '''Docker implementation of a radio.''' - def __init__(self, agent: ALEntityDocker, iface_name: str): self.iface_name = iface_name ip_output = agent.command("ip", "-o", "link", "list", "dev", self.iface_name).decode() @@ -398,8 +403,8 @@ def launch_environment_docker(unique_id: str, skip_init: bool = False, tag: str wired_sniffer.stop() global controller, agents - controller = ALEntityDocker(gateway, True) - agents = (ALEntityDocker(repeater1), ALEntityDocker(repeater2)) + controller = ALEntityDocker(name=gateway, is_controller=True) + agents = (ALEntityDocker(name=repeater1), ALEntityDocker(name=repeater2)) debug('controller: {}'.format(controller.mac)) debug('agent1: {}'.format(agents[0].mac)) @@ -455,6 +460,9 @@ def wait_for_log(self, regex: str, start_line: int, timeout: float) -> bool: "{}/beerocks_{}.log".format(self.log_folder, program), regex, start_line, timeout*100) + def prprlmesh_status_check(self): + return self.device.prprlmesh_status_check() + class RadioHostapd(Radio): """Abstraction of real Radio in prplWRT device.""" From 7eb8636b954c26bc749413bea2444ff0eb5913b1 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Mon, 15 Jun 2020 19:35:12 +0200 Subject: [PATCH 033/453] btl: add if_index to UDS header of received message Modify transport to include which interface the message was received on. Interface index will later be stored in topology database whenever a Topology Discovery message is received. Signed-off-by: Mario Maz --- common/beerocks/bcl/include/bcl/beerocks_message_structs.h | 1 + common/beerocks/btl/btl_local_bus.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/common/beerocks/bcl/include/bcl/beerocks_message_structs.h b/common/beerocks/bcl/include/bcl/beerocks_message_structs.h index 7533dfc8cf..119f5fe218 100644 --- a/common/beerocks/bcl/include/bcl/beerocks_message_structs.h +++ b/common/beerocks/bcl/include/bcl/beerocks_message_structs.h @@ -17,6 +17,7 @@ namespace beerocks { namespace message { typedef struct { + uint32_t if_index = 0; // index of the network interface the message was received on uint8_t dst_bridge_mac[net::MAC_ADDR_LEN] = {}; uint8_t src_bridge_mac[net::MAC_ADDR_LEN] = {}; uint16_t length = 0; diff --git a/common/beerocks/btl/btl_local_bus.cpp b/common/beerocks/btl/btl_local_bus.cpp index 0bd71b308c..3dea49233d 100644 --- a/common/beerocks/btl/btl_local_bus.cpp +++ b/common/beerocks/btl/btl_local_bus.cpp @@ -200,6 +200,7 @@ bool transport_socket_thread::handle_cmdu_message_bus() // fill UDS Header message::sUdsHeader *uds_header = (message::sUdsHeader *)rx_buffer; + uds_header->if_index = cmdu_rx_msg->metadata()->if_index; std::copy_n((uint8_t *)cmdu_rx_msg->metadata()->src, sizeof(mapf::CmduRxMessage::Metadata::src), uds_header->src_bridge_mac); std::copy_n((uint8_t *)cmdu_rx_msg->metadata()->dst, sizeof(mapf::CmduRxMessage::Metadata::dst), From 0ec63f4657c3eb2e7df8ffa48937f4188298f3ce Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Mon, 15 Jun 2020 19:39:41 +0200 Subject: [PATCH 034/453] agent: backhaul: extend topology database with if_index and MAC When processing Topology Discovery message we must store the IEEE 1905.1 AL MAC address of the transmitting device together with the MAC address of the interface on which the message is transmitted and the interface on which such message is received. Currently we are storing AL MAC address only. This additional information is required to build Topology Response and Link Metric Response messages properly. Signed-off-by: Mario Maz --- .../backhaul_manager_thread.cpp | 16 +++++++++++++-- .../backhaul_manager_thread.h | 20 +++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 7a57169f5e..1632e174e2 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -523,7 +523,7 @@ void backhaul_manager::after_select(bool timeout) // and send a Topology Notification message. bool neighbors_list_changed = false; for (auto it = m_1905_neighbor_devices.begin(); it != m_1905_neighbor_devices.end();) { - const auto &last_topology_discovery = it->second; + const auto &last_topology_discovery = it->second.timestamp; if (last_topology_discovery + std::chrono::seconds(DISCOVERY_NEIGHBOUR_REMOVAL_TIMEOUT) < std::chrono::steady_clock::now()) { const auto &device_al_mac = it->first; @@ -3290,11 +3290,23 @@ bool backhaul_manager::handle_1905_topology_discovery(const std::string &src_mac LOG(INFO) << "Received TOPOLOGY_DISCOVERY_MESSAGE from AL MAC=" << tlvAlMac->mac() << ", mid=" << std::hex << int(mid); + auto tlvMac = cmdu_rx.getClass(); + if (!tlvMac) { + LOG(ERROR) << "getClass tlvMacAddress failed"; + return false; + } + auto new_device = m_1905_neighbor_devices.find(tlvAlMac->mac()) == m_1905_neighbor_devices.end(); // Add/Update the device on our list. - m_1905_neighbor_devices[tlvAlMac->mac()] = std::chrono::steady_clock::now(); + sNeighborDevice neighbor_device; + neighbor_device.al_mac = tlvAlMac->mac(); + neighbor_device.mac = tlvMac->mac(); + neighbor_device.if_index = message_com::get_uds_header(cmdu_rx)->if_index; + neighbor_device.timestamp = std::chrono::steady_clock::now(); + + m_1905_neighbor_devices[tlvAlMac->mac()] = neighbor_device; // If it is a new device, then our 1905.1 neighbors list has changed and we are required to send // Topology Notification Message. diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index e44fbc8c86..1980241986 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -454,16 +454,32 @@ class backhaul_manager : public btl::transport_socket_thread { get_neighbor_links(const sMacAddr &neighbor_mac_filter, std::map> &neighbor_links_map); + /** + * @brief 1905.1 Neighbor device information + * + * Information gathered from a neighbor device upon reception of a Topology Discovery message. + */ + struct sNeighborDevice { + sMacAddr al_mac = beerocks::net::network_utils:: + ZERO_MAC; /**< 1905.1 AL MAC address of the Topology Discovery message transmitting device. */ + sMacAddr mac = beerocks::net::network_utils:: + ZERO_MAC; /**< MAC address of the interface on which the Topology Discovery message is transmitted. */ + uint32_t if_index = + 0; /**< Index of the network interface the Topology Discovery message was received on */ + std::chrono::steady_clock::time_point + timestamp; /**< Timestamp of the last Topology Discovery message received from this neighbor device. */ + }; + /* * @brief List of known 1905 neighbor devices * * key: 1905.1 device AL-MAC - * value: Last timestamp receiving discovery message from AL-MAC + * value: 1905.1 device information * Devices are being added to the list when receiving a 1905.1 Topology Discovery message from * an unknown 1905.1 device. Every 1905.1 device shall send this message every 60 seconds, and * we update the time stamp in which the message is received. */ - std::unordered_map m_1905_neighbor_devices; + std::unordered_map m_1905_neighbor_devices; /** * @brief Adds an AP HT Capabilities TLV to AP Capability Report message. From 745a384c6df2b17541a8fdf92376964aad6b92d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Wed, 17 Jun 2020 18:57:07 +0200 Subject: [PATCH 035/453] bwl: initialize SStaStats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SStaStats values were not initialized, which could have lead to unexpected results if they are read before being assigned to. Signed-off-by: Raphaël Mélotte --- .../bwl/include/bwl/mon_wlan_hal_types.h | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/common/beerocks/bwl/include/bwl/mon_wlan_hal_types.h b/common/beerocks/bwl/include/bwl/mon_wlan_hal_types.h index 906e9d33c6..ea078a0b85 100644 --- a/common/beerocks/bwl/include/bwl/mon_wlan_hal_types.h +++ b/common/beerocks/bwl/include/bwl/mon_wlan_hal_types.h @@ -64,29 +64,29 @@ struct SVapStats { }; struct SStaStats { - float rx_rssi_watt; - uint8_t rx_rssi_watt_samples_cnt; - float rx_snr_watt; - uint8_t rx_snr_watt_samples_cnt; + float rx_rssi_watt = 0; + uint8_t rx_rssi_watt_samples_cnt = 0; + float rx_snr_watt = 0; + uint8_t rx_snr_watt_samples_cnt = 0; // int8_t rx_rssi_prev=beerocks::RSSI_INVALID; // int8_t rx_rssi_curr=beerocks::RSSI_INVALID; - uint16_t tx_phy_rate_100kb; + uint16_t tx_phy_rate_100kb = 0; // uint16_t tx_phy_rate_100kb_avg; // uint16_t tx_phy_rate_100kb_min; // uint16_t tx_phy_rate_100kb_acc; - uint16_t rx_phy_rate_100kb; + uint16_t rx_phy_rate_100kb = 0; // uint16_t rx_phy_rate_100kb_avg; // uint16_t rx_phy_rate_100kb_min; // uint16_t rx_phy_rate_100kb_acc; - uint64_t tx_bytes_cnt; - uint64_t rx_bytes_cnt; - uint64_t tx_packets_cnt; - uint64_t rx_packets_cnt; - uint32_t tx_packets; - uint32_t tx_bytes; - uint32_t rx_packets; - uint32_t rx_bytes; - uint32_t retrans_count; + uint64_t tx_bytes_cnt = 0; + uint64_t rx_bytes_cnt = 0; + uint64_t tx_packets_cnt = 0; + uint64_t rx_packets_cnt = 0; + uint32_t tx_packets = 0; + uint32_t tx_bytes = 0; + uint32_t rx_packets = 0; + uint32_t rx_bytes = 0; + uint32_t retrans_count = 0; // uint8_t tx_load_percent_curr=0; // uint8_t tx_load_percent_prev=0; // uint8_t rx_load_percent_curr=0; From 862b174fd64341c146a3e6e15db85c447cf4f9b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Wed, 17 Jun 2020 22:41:59 +0200 Subject: [PATCH 036/453] mon_wlan_hal_dwpal: parse SNR and ShortTermRSSIAverage as strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous parsing of SNR and ShortTermRSSIAverage was failing, leading to a segmentation fault of beerocks_fronthaul. Parse them as strings instead. Since they contain space-separated values, split them later. Fixes https://github.com/prplfoundation/prplMesh/issues/1438 MAP-4.3.2_ETH_FH24G:netgear-rax40 Signed-off-by: Raphaël Mélotte --- .../beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp index 940f9fb61e..d38f60eace 100644 --- a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp @@ -689,9 +689,9 @@ bool mon_wlan_hal_dwpal::update_stations_stats(const std::string &vap_iface_name size_t numOfValidArgs[10] = {0}, replyLen = strnlen(reply, HOSTAPD_TO_DWPAL_MSG_LENGTH); uint64_t BytesSent = 0, BytesReceived = 0, PacketsSent = 0, PacketsReceived = 0, LastDataDownlinkRate = 0, LastDataUplinkRate = 0, Active = 0; - char ShortTermRSSIAverage[32][HOSTAPD_TO_DWPAL_VALUE_STRING_LENGTH] = {'\0'}; - char SNR[32][HOSTAPD_TO_DWPAL_VALUE_STRING_LENGTH] = {'\0'}; - FieldsToParse fieldsToParse[] = { + char ShortTermRSSIAverage[32] = {'\0'}; + char SNR[32] = {'\0'}; + FieldsToParse fieldsToParse[] = { {(void *)&BytesSent, &numOfValidArgs[0], DWPAL_LONG_LONG_INT_PARAM, "BytesSent=", 0}, {(void *)&BytesReceived, &numOfValidArgs[1], DWPAL_LONG_LONG_INT_PARAM, "BytesReceived=", 0}, @@ -699,9 +699,9 @@ bool mon_wlan_hal_dwpal::update_stations_stats(const std::string &vap_iface_name {(void *)&PacketsReceived, &numOfValidArgs[3], DWPAL_LONG_LONG_INT_PARAM, "PacketsReceived=", 0}, {(void *)&sta_stats.retrans_count, &numOfValidArgs[4], DWPAL_INT_PARAM, "RetransCount=", 0}, - {(void *)ShortTermRSSIAverage, &numOfValidArgs[5], DWPAL_STR_ARRAY_PARAM, + {(void *)ShortTermRSSIAverage, &numOfValidArgs[5], DWPAL_STR_PARAM, "ShortTermRSSIAverage=", sizeof(ShortTermRSSIAverage)}, - {(void *)SNR, &numOfValidArgs[6], DWPAL_STR_ARRAY_PARAM, "SNR=", sizeof(SNR)}, + {(void *)SNR, &numOfValidArgs[6], DWPAL_STR_PARAM, "SNR=", sizeof(SNR)}, {(void *)&Active, &numOfValidArgs[7], DWPAL_LONG_LONG_INT_PARAM, "Active=", 0}, {(void *)&LastDataDownlinkRate, &numOfValidArgs[8], DWPAL_LONG_LONG_INT_PARAM, "LastDataDownlinkRate=", 0}, @@ -738,18 +738,20 @@ bool mon_wlan_hal_dwpal::update_stations_stats(const std::string &vap_iface_name } } - //save avarage RSSI in watt - for (uint8_t i = 0; i < numOfValidArgs[5]; i++) { - float s_float = float(beerocks::string_utils::stoi(std::string(ShortTermRSSIAverage[i]))); + //save average RSSI in watt + // ShortTermRSSIAverage values are space-separated: + for (const auto &rssi : beerocks::string_utils::str_split(ShortTermRSSIAverage, ' ')) { + float s_float = float(beerocks::string_utils::stoi(std::string(rssi))); if (s_float > beerocks::RSSI_MIN) { sta_stats.rx_rssi_watt += std::pow(10, s_float / float(10)); sta_stats.rx_rssi_watt_samples_cnt++; } } - //save avarage SNR in watt - for (uint8_t i = 0; i < numOfValidArgs[6]; i++) { - float s_float = float(beerocks::string_utils::stoi(std::string(SNR[i]))); + //save average SNR in watt + // SNR values are space-separated: + for (const auto &snr : beerocks::string_utils::str_split(SNR, ' ')) { + float s_float = float(beerocks::string_utils::stoi(std::string(snr))); if (s_float > beerocks::SNR_MIN) { sta_stats.rx_snr_watt += std::pow(10, s_float / float(10)); sta_stats.rx_snr_watt_samples_cnt++; From a93a6fda002e83916a512b2a8612d5ed11337b6e Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 10 Jun 2020 16:38:58 +0000 Subject: [PATCH 037/453] devcontainer: add missing packages Latest changes introduced dependecies to new tools that are not currently installed in the devcontainer. Install the missing tools as part of the creation of the devcontainer. Signed-off-by: Vitaly Bukhovsky --- .devcontainer/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 7005476a41..0493bcd02f 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -13,13 +13,13 @@ RUN apt-get update \ # Install C++ tools && apt-get -y install build-essential cmake cppcheck valgrind \ # Libraries - libjson-c-dev python-yaml libzmq3-dev libssl-dev \ + libjson-c-dev python-yaml python3-yaml libzmq3-dev libssl-dev \ libncurses-dev libreadline-dev libnl-3-dev libnl-route-3-dev libnl-genl-3-dev \ # Install Helper tools bash-completion locales ninja-build pkg-config shellcheck \ flake8 clang-format vim \ # Network capturing - tcpdump openssh-server + tcpdump tshark wireshark-common openssh-server # Install podman RUN echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_$(lsb_release -sr)/ /" \ From 583119d4c3f956f3a1c2d94a257e7d860c2a996f Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 10 Jun 2020 16:41:10 +0000 Subject: [PATCH 038/453] vscode_launch: beerocks_fronthaul support Change beerocks_monitor attach tasks to beerocks_fronthaul Signed-off-by: Vitaly Bukhovsky --- .vscode/launch.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 2781aaaa6d..beff1b83f6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -53,10 +53,10 @@ } }, { - "name": "(gdb) GATEWAY - Attach to beerocks_monitor", + "name": "(gdb) GATEWAY - Attach to beerocks_fronthaul", "type": "cppdbg", "request": "attach", - "program": "${workspaceFolder}/build/install/bin/beerocks_monitor", + "program": "${workspaceFolder}/build/install/bin/beerocks_fronthaul", "processId": "${command:pickRemoteProcess}", "pipeTransport": { "pipeCwd": "${workspaceRoot}", @@ -125,10 +125,10 @@ } }, { - "name": "(gdb) REPEATER #1 - Attach to beerocks_monitor", + "name": "(gdb) REPEATER #1 - Attach to beerocks_fronthaul", "type": "cppdbg", "request": "attach", - "program": "${workspaceFolder}/build/install/bin/beerocks_monitor", + "program": "${workspaceFolder}/build/install/bin/beerocks_fronthaul", "processId": "${command:pickRemoteProcess}", "pipeTransport": { "pipeCwd": "${workspaceRoot}", @@ -173,10 +173,10 @@ } }, { - "name": "(gdb) REPEATER #2 - Attach to beerocks_monitor", + "name": "(gdb) REPEATER #2 - Attach to beerocks_fronthaul", "type": "cppdbg", "request": "attach", - "program": "${workspaceFolder}/build/install/bin/beerocks_monitor", + "program": "${workspaceFolder}/build/install/bin/beerocks_fronthaul", "processId": "${command:pickRemoteProcess}", "pipeTransport": { "pipeCwd": "${workspaceRoot}", From 5cbb28bf183d3b5322a7746582c493a45cc27016 Mon Sep 17 00:00:00 2001 From: Ran Regev Date: Thu, 18 Jun 2020 13:41:05 +0300 Subject: [PATCH 039/453] slave: backhaul manager: fixed weird curly brackets fixed a strange code in handle_1905_1_message's switch case Signed-off-by: Ran Regev --- .../beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 1632e174e2..e8f8b1bab3 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -2212,6 +2212,7 @@ bool backhaul_manager::handle_1905_1_message(ieee1905_1::CmduMessageRx &cmdu_rx, } case ieee1905_1::eMessageType::MULTI_AP_POLICY_CONFIG_REQUEST_MESSAGE: { return handle_multi_ap_policy_config_request(cmdu_rx, src_mac); + } case ieee1905_1::eMessageType::AP_METRICS_QUERY_MESSAGE: { return handle_ap_metrics_query(cmdu_rx, src_mac); } @@ -2227,7 +2228,6 @@ bool backhaul_manager::handle_1905_1_message(ieee1905_1::CmduMessageRx &cmdu_rx, return false; } } - } } bool backhaul_manager::handle_slave_1905_1_message(ieee1905_1::CmduMessageRx &cmdu_rx, const std::string &src_mac) From f55d74392292bc5e16856025039a2c62998dae96 Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Wed, 10 Jun 2020 15:46:00 +0000 Subject: [PATCH 040/453] common: prplmesh_utils.sh: add bml execute func This is a preparative commit for "common: prplmesh_utils.sh: use BML for operational check" Add execute BML function Signed-off-by: itay elenzweig --- common/beerocks/scripts/prplmesh_utils.sh.in | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/beerocks/scripts/prplmesh_utils.sh.in b/common/beerocks/scripts/prplmesh_utils.sh.in index a1d73839fb..36e855d830 100755 --- a/common/beerocks/scripts/prplmesh_utils.sh.in +++ b/common/beerocks/scripts/prplmesh_utils.sh.in @@ -246,6 +246,17 @@ stop_function() { [ "$DELETE_LOGS" = "true" ] && prplmesh_delete_logs } +execute_beerocks_command() { + dbg "Executing beerocks cli command: $*" + if [ -e $PRPLMESH_BIN_DIR/beerocks_cli ]; then + output=$(${PRPLMESH_BIN_DIR}/beerocks_cli -c "$@") + return $? + else + err "BML CLI not found" + return 1 + fi +} + # Note: Apparently on some Linux version space is added to the process name. # Therefore added "($|[[:blank:]])" to the end of the regex expression which means the end of the # line ($) or blank character ([[:blank:]]) From 5dfafe7b10326a16ce535b64bd44347beafc0c7e Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Wed, 10 Jun 2020 15:46:18 +0000 Subject: [PATCH 041/453] common: prplmesh_utils.sh: use BML operational check prplmesh_utils.sh status returns an operational status determined by parsing the logs. In some platforms logs wrap around could return "fail" status although system is operational state. To resolve this issue, the status check should use the BML command bml_get_device_operational_radios which returns the status of the current device using the bridge's MAC address. Use BML to check operational status Signed-off-by: itay elenzweig --- common/beerocks/scripts/prplmesh_utils.sh.in | 49 +++++++++++++++----- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/common/beerocks/scripts/prplmesh_utils.sh.in b/common/beerocks/scripts/prplmesh_utils.sh.in index 36e855d830..30528c47c7 100755 --- a/common/beerocks/scripts/prplmesh_utils.sh.in +++ b/common/beerocks/scripts/prplmesh_utils.sh.in @@ -253,6 +253,7 @@ execute_beerocks_command() { return $? else err "BML CLI not found" + output="" return 1 fi } @@ -287,21 +288,45 @@ status_function() { pgrep -l ieee1905_transport pgrep -l local_bus - # check for operational status - LOGS_PATH=@BEEROCKS_LOG_FILES_PATH@ + bridge_mac="$(ip link show dev @BEEROCKS_BRIDGE_IFACE@ | awk '/^ *link\/ether / {print $2}')" + bml_cmd="bml_get_device_operational_radios $bridge_mac" + + if pgrep -l beerocks_cont ; then + if execute_beerocks_command "$bml_cmd" ; then + # Expecting + # > OK Main radio agent operational + # > OK wlan0 radio agent operational + # > OK wlan2 radio agent operational + OK_Count=$(echo "$output" | grep -c -e "OK.*operational") + if [ "$OK_Count" -eq 3 ]; then + success "operational test success!" + exit 0 + else + err "operational test failed!" + err "$output" + exit 1 + fi + else + err "Beerocks command failed to execute!" + exit 1 + fi + else + # check for operational status + LOGS_PATH=@BEEROCKS_LOG_FILES_PATH@ - error=0 - report "Main agent operational" main_agent_operational $LOGS_PATH - report "@BEEROCKS_WLAN1_IFACE@ radio agent operational" radio_agent_operational $LOGS_PATH @BEEROCKS_WLAN1_IFACE@ - report "@BEEROCKS_WLAN2_IFACE@ radio agent operational" radio_agent_operational $LOGS_PATH @BEEROCKS_WLAN2_IFACE@ + error=0 + report "Main agent operational" main_agent_operational $LOGS_PATH + report "@BEEROCKS_WLAN1_IFACE@ radio agent operational" radio_agent_operational $LOGS_PATH @BEEROCKS_WLAN1_IFACE@ + report "@BEEROCKS_WLAN2_IFACE@ radio agent operational" radio_agent_operational $LOGS_PATH @BEEROCKS_WLAN2_IFACE@ - [ "$VERBOSE" = "true" ] && [ $error = 1 ] && { - cat $LOGS_PATH/beerocks_agent@BEEROCKS_LOG_FILES_SUFFIX@ - cat $LOGS_PATH/beerocks_agent_@BEEROCKS_WLAN1_IFACE@@BEEROCKS_LOG_FILES_SUFFIX@ - cat $LOGS_PATH/beerocks_agent_@BEEROCKS_WLAN2_IFACE@@BEEROCKS_LOG_FILES_SUFFIX@ - } + [ "$VERBOSE" = "true" ] && [ $error = 1 ] && { + cat $LOGS_PATH/beerocks_agent@BEEROCKS_LOG_FILES_SUFFIX@ + cat $LOGS_PATH/beerocks_agent_@BEEROCKS_WLAN1_IFACE@@BEEROCKS_LOG_FILES_SUFFIX@ + cat $LOGS_PATH/beerocks_agent_@BEEROCKS_WLAN2_IFACE@@BEEROCKS_LOG_FILES_SUFFIX@ + } - exit $error + exit $error + fi } usage() { From 1a293394c0c57870ebd1f8d1fa167b3c68fc66bc Mon Sep 17 00:00:00 2001 From: Alex Kanter Date: Thu, 18 Jun 2020 13:40:40 +0000 Subject: [PATCH 042/453] prplmesh_uttils.sh: use SIGTERM in killall_program() Currently prplmesh_utills.sh stop sends SIGKILL to all processes. Since SIGKILL cannot be handled monitor/agent/controller processes are not shutdown properly. As a result old wpa ctrl socket are not detached and files are not deleted. Change killall_program() to send SIGTERM instead on default. Signed-off-by: Alex Kanter --- common/beerocks/scripts/prplmesh_utils.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/beerocks/scripts/prplmesh_utils.sh.in b/common/beerocks/scripts/prplmesh_utils.sh.in index 30528c47c7..432111949c 100755 --- a/common/beerocks/scripts/prplmesh_utils.sh.in +++ b/common/beerocks/scripts/prplmesh_utils.sh.in @@ -27,7 +27,7 @@ run() { killall_program() { PROGRAM_NAME=$1 - KILL_SIG=${2:-KILL} + KILL_SIG=${2:-TERM} echo "killing $PROGRAM_NAME ($KILL_SIG)" start-stop-daemon -K -s "$KILL_SIG" -x "$PRPLMESH_BIN_DIR"/"$PROGRAM_NAME" > /dev/null 2>&1 } From d3c13924b94f75f7bc8f86eac671800cd541e597 Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Mon, 22 Jun 2020 11:22:03 +0200 Subject: [PATCH 043/453] mergify: allow status check failures We have a requirement for mergify that no status checks should fail. This is kind of redundant, because mergify will only do the merge if no *required* status checks fail anyway. Since we now have a non-required status check (UTAF) that often fails, we really need to remove that redundant requirement. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- .mergify.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.mergify.yml b/.mergify.yml index 06b02b686b..e71849589b 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -5,7 +5,6 @@ pull_request_rules: - "#changes-requested-reviews-by=0" # Changes requested blocks the merge - "label=ready for merge" # Must have ready for merge label - "label!=don't merge" # Don't merge label blocks the merge - - "#status-failure=0" # Just to be sure that we don't consider it as passed when the status checks haven't even # started yet. - "#status-success>=3" From fd60577077fffd8ae68ae41521bf9b41ab0334fc Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Wed, 10 Jun 2020 16:10:46 +0200 Subject: [PATCH 044/453] tlvf: fix tlv_mac_tlv in msgTopologyDiscovery Change the type of field tlv_mac_tlv from tlvAlMacAddressType to tlvMacAddress. Note that this change does not affect to autogenerated files nor to source code. Signed-off-by: Mario Maz --- .../tlvf/yaml/tlvf/ieee_1905_1_msg/msgTopologyDiscovery.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgTopologyDiscovery.yaml b/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgTopologyDiscovery.yaml index 4445a61c20..df28ce6d45 100644 --- a/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgTopologyDiscovery.yaml +++ b/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgTopologyDiscovery.yaml @@ -8,6 +8,6 @@ msgTopologyDiscovery: _type: cmduHeader _setValue: { "messageType" : TOPOLOGY_DISCOVERY_MESSAGE } tlv_al_mac_tlv: tlvAlMacAddressType - tlv_mac_tlv: tlvAlMacAddressType + tlv_mac_tlv: tlvMacAddress tlv_eof: tlvEndOfMessage \ No newline at end of file From 4d26747d842cafc98a74fcb437cd019eda53bf83 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Wed, 10 Jun 2020 16:15:36 +0200 Subject: [PATCH 045/453] tlvf: rename tlvAlMacAddressType to tlvAlMacAddress No TLV type ends with prefix 'Type' except this one. Rename it to look like the rest of TLVs Signed-off-by: Mario Maz --- .../backhaul_manager_thread.cpp | 18 +-- agent/src/beerocks/slave/son_slave_thread.cpp | 4 +- .../src/beerocks/master/son_actions.cpp | 4 +- controller/src/beerocks/master/son_actions.h | 2 +- .../src/beerocks/master/son_master_thread.cpp | 10 +- .../include/tlvf/ieee_1905_1/eTlvType.h | 2 +- .../tlvf/ieee_1905_1/tlvAlMacAddress.h | 52 ++++++++ .../src/tlvf/ieee_1905_1/tlvAlMacAddress.cpp | 118 ++++++++++++++++++ framework/tlvf/src/src/CmduMessageRx.cpp | 4 +- .../tlvf/yaml/tlvf/ieee_1905_1/eTlvType.yaml | 2 +- ...cAddressType.yaml => tlvAlMacAddress.yaml} | 4 +- .../msgApAutoConfigurationRenew.yaml | 2 +- .../msgApAutoConfigurationSearch.yaml | 2 +- .../msgPushButtonEventNotification.yaml | 2 +- .../msgPushButtonJoinNotification.yaml | 2 +- .../ieee_1905_1_msg/msgTopologyDiscovery.yaml | 2 +- .../msgTopologyNotification.yaml | 2 +- 17 files changed, 201 insertions(+), 31 deletions(-) create mode 100644 framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/tlvAlMacAddress.h create mode 100644 framework/tlvf/AutoGenerated/src/tlvf/ieee_1905_1/tlvAlMacAddress.cpp rename framework/tlvf/yaml/tlvf/ieee_1905_1/{tlvAlMacAddressType.yaml => tlvAlMacAddress.yaml} (67%) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index e8f8b1bab3..0ae2123b0f 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -50,7 +50,7 @@ */ #include #include -#include +#include #include #include #include @@ -1125,9 +1125,9 @@ bool backhaul_manager::send_1905_topology_discovery_message() LOG(ERROR) << "Failed to create TOPOLOGY_DISCOVERY_MESSAGE cmdu"; return false; } - auto tlvAlMac = cmdu_tx.addClass(); + auto tlvAlMac = cmdu_tx.addClass(); if (!tlvAlMac) { - LOG(ERROR) << "Failed to create tlvAlMacAddressType tlv"; + LOG(ERROR) << "Failed to create tlvAlMacAddress tlv"; return false; } tlvAlMac->mac() = tlvf::mac_from_string(bridge_info.mac); @@ -1162,12 +1162,12 @@ bool backhaul_manager::send_autoconfig_search_message(std::shared_ptr(); - if (!tlvAlMacAddressType) { - LOG(ERROR) << "addClass ieee1905_1::tlvAlMacAddressType failed"; + auto tlvAlMacAddress = cmdu_tx.addClass(); + if (!tlvAlMacAddress) { + LOG(ERROR) << "addClass ieee1905_1::tlvAlMacAddress failed"; return false; } - tlvf::mac_from_string(tlvAlMacAddressType->mac().oct, bridge_info.mac); + tlvf::mac_from_string(tlvAlMacAddress->mac().oct, bridge_info.mac); auto tlvSearchedRole = cmdu_tx.addClass(); if (!tlvSearchedRole) { @@ -3275,9 +3275,9 @@ bool backhaul_manager::handle_1905_combined_infrastructure_metrics( bool backhaul_manager::handle_1905_topology_discovery(const std::string &src_mac, ieee1905_1::CmduMessageRx &cmdu_rx) { - auto tlvAlMac = cmdu_rx.getClass(); + auto tlvAlMac = cmdu_rx.getClass(); if (!tlvAlMac) { - LOG(ERROR) << "getClass tlvAlMacAddressType failed"; + LOG(ERROR) << "getClass tlvAlMacAddress failed"; return false; } diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 79298fe5ea..d3a6297977 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include @@ -3990,7 +3990,7 @@ bool slave_thread::handle_autoconfiguration_renew(Socket *sd, ieee1905_1::CmduMe { LOG(INFO) << "received autoconfig renew message"; - auto tlvAlMac = cmdu_rx.getClass(); + auto tlvAlMac = cmdu_rx.getClass(); if (tlvAlMac) { LOG(DEBUG) << "tlvAlMac=" << tlvAlMac->mac(); // TODO register/update mapping of AL-MAC to interface, cfr. #81 diff --git a/controller/src/beerocks/master/son_actions.cpp b/controller/src/beerocks/master/son_actions.cpp index babe5e49ec..4896823aaa 100644 --- a/controller/src/beerocks/master/son_actions.cpp +++ b/controller/src/beerocks/master/son_actions.cpp @@ -467,9 +467,9 @@ bool son_actions::send_ap_config_renew_msg(ieee1905_1::CmduMessageTx &cmdu_tx, d LOG(ERROR) << "Failed building IEEE1905 AP_AUTOCONFIGURATION_RENEW_MESSAGE"; } - auto tlvAlMac = cmdu_tx.addClass(); + auto tlvAlMac = cmdu_tx.addClass(); if (!tlvAlMac) { - LOG(ERROR) << "Failed addClass ieee1905_1::tlvAlMacAddressType"; + LOG(ERROR) << "Failed addClass ieee1905_1::tlvAlMacAddress"; result = false; } diff --git a/controller/src/beerocks/master/son_actions.h b/controller/src/beerocks/master/son_actions.h index 024dc42f80..fba85f867b 100644 --- a/controller/src/beerocks/master/son_actions.h +++ b/controller/src/beerocks/master/son_actions.h @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include #include diff --git a/controller/src/beerocks/master/son_master_thread.cpp b/controller/src/beerocks/master/son_master_thread.cpp index 1a5e6970b0..9e0e1e7805 100644 --- a/controller/src/beerocks/master/son_master_thread.cpp +++ b/controller/src/beerocks/master/son_master_thread.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -326,9 +326,9 @@ bool master_thread::handle_cmdu_1905_autoconfiguration_search(const std::string { LOG(DEBUG) << "Received AP_AUTOCONFIGURATION_SEARCH_MESSAGE"; - auto tlvAlMacAddressType = cmdu_rx.getClass(); - if (!tlvAlMacAddressType) { - LOG(ERROR) << "getClass failed"; + auto tlvAlMacAddress = cmdu_rx.getClass(); + if (!tlvAlMacAddress) { + LOG(ERROR) << "getClass failed"; return false; } auto tlvSearchedRole = cmdu_rx.getClass(); @@ -352,7 +352,7 @@ bool master_thread::handle_cmdu_1905_autoconfiguration_search(const std::string return false; } - auto al_mac = tlvf::mac_to_string((const unsigned char *)tlvAlMacAddressType->mac().oct); + auto al_mac = tlvf::mac_to_string((const unsigned char *)tlvAlMacAddress->mac().oct); LOG(DEBUG) << "mac=" << al_mac; LOG(DEBUG) << "searched_role=" << int(tlvSearchedRole->value()); diff --git a/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eTlvType.h b/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eTlvType.h index fd14a9497a..c5b6f6d168 100644 --- a/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eTlvType.h +++ b/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eTlvType.h @@ -21,7 +21,7 @@ namespace ieee1905_1 { enum class eTlvType : uint8_t { TLV_END_OF_MESSAGE = 0x0, - TLV_AL_MAC_ADDRESS_TYPE = 0x1, + TLV_AL_MAC_ADDRESS = 0x1, TLV_MAC_ADDRESS = 0x2, TLV_DEVICE_INFORMATION = 0x3, TLV_DEVICE_BRIDGING_CAPABILITY = 0x4, diff --git a/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/tlvAlMacAddress.h b/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/tlvAlMacAddress.h new file mode 100644 index 0000000000..0544c3bc15 --- /dev/null +++ b/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/tlvAlMacAddress.h @@ -0,0 +1,52 @@ +/////////////////////////////////////// +// AUTO GENERATED FILE - DO NOT EDIT // +/////////////////////////////////////// + +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#ifndef _TLVF_IEEE_1905_1_TLVALMACADDRESS_H_ +#define _TLVF_IEEE_1905_1_TLVALMACADDRESS_H_ + +#include +#include +#include +#include +#include +#include +#include +#include "tlvf/ieee_1905_1/eTlvType.h" +#include "tlvf/common/sMacAddr.h" + +namespace ieee1905_1 { + + +class tlvAlMacAddress : public BaseClass +{ + public: + tlvAlMacAddress(uint8_t* buff, size_t buff_len, bool parse = false); + explicit tlvAlMacAddress(std::shared_ptr base, bool parse = false); + ~tlvAlMacAddress(); + + const eTlvType& type(); + const uint16_t& length(); + sMacAddr& mac(); + void class_swap() override; + bool finalize() override; + static size_t get_initial_size(); + + private: + bool init(); + eTlvType* m_type = nullptr; + uint16_t* m_length = nullptr; + sMacAddr* m_mac = nullptr; +}; + +}; // close namespace: ieee1905_1 + +#endif //_TLVF/IEEE_1905_1_TLVALMACADDRESS_H_ diff --git a/framework/tlvf/AutoGenerated/src/tlvf/ieee_1905_1/tlvAlMacAddress.cpp b/framework/tlvf/AutoGenerated/src/tlvf/ieee_1905_1/tlvAlMacAddress.cpp new file mode 100644 index 0000000000..165c28e51c --- /dev/null +++ b/framework/tlvf/AutoGenerated/src/tlvf/ieee_1905_1/tlvAlMacAddress.cpp @@ -0,0 +1,118 @@ +/////////////////////////////////////// +// AUTO GENERATED FILE - DO NOT EDIT // +/////////////////////////////////////// + +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include +#include + +using namespace ieee1905_1; + +tlvAlMacAddress::tlvAlMacAddress(uint8_t* buff, size_t buff_len, bool parse) : + BaseClass(buff, buff_len, parse) { + m_init_succeeded = init(); +} +tlvAlMacAddress::tlvAlMacAddress(std::shared_ptr base, bool parse) : +BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ + m_init_succeeded = init(); +} +tlvAlMacAddress::~tlvAlMacAddress() { +} +const eTlvType& tlvAlMacAddress::type() { + return (const eTlvType&)(*m_type); +} + +const uint16_t& tlvAlMacAddress::length() { + return (const uint16_t&)(*m_length); +} + +sMacAddr& tlvAlMacAddress::mac() { + return (sMacAddr&)(*m_mac); +} + +void tlvAlMacAddress::class_swap() +{ + tlvf_swap(16, reinterpret_cast(m_length)); + m_mac->struct_swap(); +} + +bool tlvAlMacAddress::finalize() +{ + if (m_parse__) { + TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; + return true; + } + if (m_finalized__) { + TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; + return true; + } + if (!isPostInitSucceeded()) { + TLVF_LOG(ERROR) << "post init check failed"; + return false; + } + if (m_inner__) { + if (!m_inner__->finalize()) { + TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; + return false; + } + auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); + m_buff_ptr__ -= tailroom; + *m_length -= tailroom; + } + class_swap(); + m_finalized__ = true; + return true; +} + +size_t tlvAlMacAddress::get_initial_size() +{ + size_t class_size = 0; + class_size += sizeof(eTlvType); // type + class_size += sizeof(uint16_t); // length + class_size += sizeof(sMacAddr); // mac + return class_size; +} + +bool tlvAlMacAddress::init() +{ + if (getBuffRemainingBytes() < get_initial_size()) { + TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; + return false; + } + m_type = reinterpret_cast(m_buff_ptr__); + if (!m_parse__) *m_type = eTlvType::TLV_AL_MAC_ADDRESS; + if (!buffPtrIncrementSafe(sizeof(eTlvType))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(eTlvType) << ") Failed!"; + return false; + } + m_length = reinterpret_cast(m_buff_ptr__); + if (!m_parse__) *m_length = 0; + if (!buffPtrIncrementSafe(sizeof(uint16_t))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; + return false; + } + m_mac = reinterpret_cast(m_buff_ptr__); + if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; + return false; + } + if(m_length && !m_parse__){ (*m_length) += sizeof(sMacAddr); } + if (!m_parse__) { m_mac->struct_init(); } + if (m_parse__) { class_swap(); } + if (m_parse__) { + if (*m_type != eTlvType::TLV_AL_MAC_ADDRESS) { + TLVF_LOG(ERROR) << "TLV type mismatch. Expected value: " << int(eTlvType::TLV_AL_MAC_ADDRESS) << ", received value: " << int(*m_type); + return false; + } + } + return true; +} + + diff --git a/framework/tlvf/src/src/CmduMessageRx.cpp b/framework/tlvf/src/src/CmduMessageRx.cpp index ea730cc5e9..6080528575 100644 --- a/framework/tlvf/src/src/CmduMessageRx.cpp +++ b/framework/tlvf/src/src/CmduMessageRx.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -88,7 +88,7 @@ std::shared_ptr CmduMessageRx::parseNextTlv() return msg.addClass(); } case (1): { - return msg.addClass(); + return msg.addClass(); } case (2): { return msg.addClass(); diff --git a/framework/tlvf/yaml/tlvf/ieee_1905_1/eTlvType.yaml b/framework/tlvf/yaml/tlvf/ieee_1905_1/eTlvType.yaml index cf445c9edf..32a76b42af 100644 --- a/framework/tlvf/yaml/tlvf/ieee_1905_1/eTlvType.yaml +++ b/framework/tlvf/yaml/tlvf/ieee_1905_1/eTlvType.yaml @@ -6,7 +6,7 @@ eTlvType: _type: enum_class _enum_storage: uint8_t TLV_END_OF_MESSAGE: 0x00 - TLV_AL_MAC_ADDRESS_TYPE: 0x01 + TLV_AL_MAC_ADDRESS: 0x01 TLV_MAC_ADDRESS: 0x02 TLV_DEVICE_INFORMATION: 0x03 TLV_DEVICE_BRIDGING_CAPABILITY: 0x04 diff --git a/framework/tlvf/yaml/tlvf/ieee_1905_1/tlvAlMacAddressType.yaml b/framework/tlvf/yaml/tlvf/ieee_1905_1/tlvAlMacAddress.yaml similarity index 67% rename from framework/tlvf/yaml/tlvf/ieee_1905_1/tlvAlMacAddressType.yaml rename to framework/tlvf/yaml/tlvf/ieee_1905_1/tlvAlMacAddress.yaml index 1ed526a3b5..df7450587c 100755 --- a/framework/tlvf/yaml/tlvf/ieee_1905_1/tlvAlMacAddressType.yaml +++ b/framework/tlvf/yaml/tlvf/ieee_1905_1/tlvAlMacAddress.yaml @@ -2,11 +2,11 @@ --- _namespace: ieee1905_1 -tlvAlMacAddressType: +tlvAlMacAddress: _type: class _is_tlv_class: True type: _type: eTlvType - _value_const: TLV_AL_MAC_ADDRESS_TYPE + _value_const: TLV_AL_MAC_ADDRESS length: uint16_t mac: sMacAddr diff --git a/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgApAutoConfigurationRenew.yaml b/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgApAutoConfigurationRenew.yaml index 4d39c26107..2400f483ac 100644 --- a/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgApAutoConfigurationRenew.yaml +++ b/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgApAutoConfigurationRenew.yaml @@ -7,7 +7,7 @@ msgApAutoConfigurationRenew: header: _type: cmduHeader _setValue: { "messageType" : AP_AUTOCONFIGURATION_RENEW_MESSAGE } - tlv_al_mac_tlv: tlvAlMacAddressType + tlv_al_mac_tlv: tlvAlMacAddress tlv_supported_role: tlvSupportedRole tlv_supported_freq_band: tlvSupportedFreqBand tlv_eof: tlvEndOfMessage \ No newline at end of file diff --git a/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgApAutoConfigurationSearch.yaml b/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgApAutoConfigurationSearch.yaml index c52087c503..c93b28e73c 100644 --- a/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgApAutoConfigurationSearch.yaml +++ b/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgApAutoConfigurationSearch.yaml @@ -7,7 +7,7 @@ msgApAutoConfigurationSearch: header: _type: cmduHeader _setValue: { "messageType" : AP_AUTOCONFIGURATION_SEARCH_MESSAGE } - tlv_al_mac_tlv: tlvAlMacAddressType + tlv_al_mac_tlv: tlvAlMacAddress tlv_searched_role: tlvSearchedRole tlv_auto_conf_freq_band: tlvAutoconfigFreqBand tlv_eof: tlvEndOfMessage \ No newline at end of file diff --git a/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgPushButtonEventNotification.yaml b/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgPushButtonEventNotification.yaml index 5e4264e544..09ed65658a 100644 --- a/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgPushButtonEventNotification.yaml +++ b/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgPushButtonEventNotification.yaml @@ -7,6 +7,6 @@ msgPushButtonEventNotification: header: _type: cmduHeader _setValue: { "messageType" : PUSH_BUTTON_EVENT_NOTIFICATION_MESSAGE } - tlv_al_mac_tlv: tlvAlMacAddressType + tlv_al_mac_tlv: tlvAlMacAddress tlv_push_butt_event_notif: tlvPushButtonEventNotification tlv_eof: tlvEndOfMessage \ No newline at end of file diff --git a/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgPushButtonJoinNotification.yaml b/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgPushButtonJoinNotification.yaml index 5f8ccd82be..f2ccf9d12b 100644 --- a/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgPushButtonJoinNotification.yaml +++ b/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgPushButtonJoinNotification.yaml @@ -7,6 +7,6 @@ msgPushButtonJoinNotification: header: _type: cmduHeader _setValue: { "messageType" : PUSH_BUTTON_JOIN_NOTIFICATION_MESSAGE } - tlv_al_mac_tlv: tlvAlMacAddressType + tlv_al_mac_tlv: tlvAlMacAddress tlv_push_butt_join_notif: tlvPushButtonJoinNotification tlv_eof: tlvEndOfMessage \ No newline at end of file diff --git a/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgTopologyDiscovery.yaml b/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgTopologyDiscovery.yaml index df28ce6d45..90c011dbac 100644 --- a/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgTopologyDiscovery.yaml +++ b/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgTopologyDiscovery.yaml @@ -7,7 +7,7 @@ msgTopologyDiscovery: header: _type: cmduHeader _setValue: { "messageType" : TOPOLOGY_DISCOVERY_MESSAGE } - tlv_al_mac_tlv: tlvAlMacAddressType + tlv_al_mac_tlv: tlvAlMacAddress tlv_mac_tlv: tlvMacAddress tlv_eof: tlvEndOfMessage \ No newline at end of file diff --git a/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgTopologyNotification.yaml b/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgTopologyNotification.yaml index e870ec7d22..aae39736c6 100644 --- a/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgTopologyNotification.yaml +++ b/framework/tlvf/yaml/tlvf/ieee_1905_1_msg/msgTopologyNotification.yaml @@ -7,5 +7,5 @@ msgTopologyNotification: header: _type: cmduHeader _setValue: { "messageType" : TOPOLOGY_NOTIFICATION_MESSAGE } - tlv_al_mac_tlv: tlvAlMacAddressType + tlv_al_mac_tlv: tlvAlMacAddress tlv_eof: tlvEndOfMessage \ No newline at end of file From 487d2436ceb2d7f7049810410724cfdf1a026aad Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Wed, 10 Jun 2020 19:46:11 +0200 Subject: [PATCH 046/453] bcl: change return type of linux_get_iface_index Method linux_get_iface_index() is a wrapper for if_nametoindex but return types differ. Change return type of linux_get_iface_index from int to uint32_t and also write a message to log in case of error. This is a preparatory commit. This method is currently not used but it will be in next commits. Signed-off-by: Mario Maz --- common/beerocks/bcl/include/bcl/network/network_utils.h | 9 ++++++++- common/beerocks/bcl/source/network/network_utils.cpp | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/common/beerocks/bcl/include/bcl/network/network_utils.h b/common/beerocks/bcl/include/bcl/network/network_utils.h index ce81205ddd..939a516a89 100644 --- a/common/beerocks/bcl/include/bcl/network/network_utils.h +++ b/common/beerocks/bcl/include/bcl/network/network_utils.h @@ -111,7 +111,14 @@ class network_utils { static std::string get_mac_from_arp_table(const std::string &ipv4); static std::vector linux_get_iface_list_from_bridge(const std::string &bridge); - static int linux_get_iface_index(const std::string &iface); + + /** + * @brief Gets the interface index corresponding to a particular name. + * + * @param iface_name The name of the network interface. + * @return interface index or 0 if no interface exists with the name given. + */ + static uint32_t linux_get_iface_index(const std::string &iface_name); static bool linux_add_iface_to_bridge(const std::string &bridge, const std::string &iface); static bool linux_remove_iface_from_bridge(const std::string &bridge, const std::string &iface); static bool linux_iface_ctrl(const std::string &iface, bool up, std::string ip = "", diff --git a/common/beerocks/bcl/source/network/network_utils.cpp b/common/beerocks/bcl/source/network/network_utils.cpp index abcacc250d..3e4277633a 100644 --- a/common/beerocks/bcl/source/network/network_utils.cpp +++ b/common/beerocks/bcl/source/network/network_utils.cpp @@ -525,9 +525,12 @@ std::vector network_utils::linux_get_iface_list_from_bridge(const s return ifs; } -int network_utils::linux_get_iface_index(const std::string &iface) +uint32_t network_utils::linux_get_iface_index(const std::string &iface_name) { - return if_nametoindex(iface.c_str()); + uint32_t iface_index = if_nametoindex(iface_name.c_str()); + LOG_IF(!iface_index, ERROR) << "Failed to read the index of interface " << iface_name << ": " + << strerror(errno); + return iface_index; } bool network_utils::linux_add_iface_to_bridge(const std::string &bridge, const std::string &iface) From ca98024f462b8302a1fc377cb653efa80e34e0fd Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Thu, 11 Jun 2020 12:25:10 +0200 Subject: [PATCH 047/453] btl: add iface_name param to send_cmdu functions Add new iface_name parameter to send_cmdu() functions to specify on which interface the transport should send given CMDU. This is a preparatory commit to later implement neighbor multicast of Topology Discovery message. Signed-off-by: Mario Maz --- common/beerocks/btl/btl.cpp | 10 +++++---- common/beerocks/btl/btl_local_bus.cpp | 6 ++++-- common/beerocks/btl/btl_uds.cpp | 6 ++++-- common/beerocks/btl/include/btl/btl.h | 30 +++++++++++++++++++++++---- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/common/beerocks/btl/btl.cpp b/common/beerocks/btl/btl.cpp index 87dfc5e331..4275cb0787 100644 --- a/common/beerocks/btl/btl.cpp +++ b/common/beerocks/btl/btl.cpp @@ -40,19 +40,21 @@ void transport_socket_thread::set_select_timeout(unsigned msec) { poll_timeout_m bool transport_socket_thread::send_cmdu_to_bus(ieee1905_1::CmduMessageTx &cmdu_tx, const std::string &dst_mac, - const std::string &src_mac) + const std::string &src_mac, + const std::string &iface_name) { if (!cmdu_tx.finalize()) { THREAD_LOG(ERROR) << "finalize failed"; return false; } - return send_cmdu_to_bus(cmdu_tx, dst_mac, src_mac, cmdu_tx.getMessageLength()); + return send_cmdu_to_bus(cmdu_tx, dst_mac, src_mac, cmdu_tx.getMessageLength(), iface_name); } bool transport_socket_thread::send_cmdu_to_bus(ieee1905_1::CmduMessage &cmdu, const std::string &dst_mac, - const std::string &src_mac, uint16_t length) + const std::string &src_mac, uint16_t length, + const std::string &iface_name) { // This method should be used by Message Routers only. It is used to forward CMDU messages from UDS socket to the BUS. LOG_IF(!bus, FATAL) << "Bus is not allocated!"; @@ -68,5 +70,5 @@ bool transport_socket_thread::send_cmdu_to_bus(ieee1905_1::CmduMessage &cmdu, return false; } - return bus_send(cmdu, dst_mac, src_mac, length); + return bus_send(cmdu, iface_name, dst_mac, src_mac, length); } diff --git a/common/beerocks/btl/btl_local_bus.cpp b/common/beerocks/btl/btl_local_bus.cpp index 3dea49233d..6ef31c595b 100644 --- a/common/beerocks/btl/btl_local_bus.cpp +++ b/common/beerocks/btl/btl_local_bus.cpp @@ -225,8 +225,9 @@ bool transport_socket_thread::handle_cmdu_message_bus() return true; } -bool transport_socket_thread::bus_send(ieee1905_1::CmduMessage &cmdu, const std::string &dst_mac, - const std::string &src_mac, uint16_t length) +bool transport_socket_thread::bus_send(ieee1905_1::CmduMessage &cmdu, const std::string &iface_name, + const std::string &dst_mac, const std::string &src_mac, + uint16_t length) { mapf::CmduTxMessage msg; @@ -237,6 +238,7 @@ bool transport_socket_thread::bus_send(ieee1905_1::CmduMessage &cmdu, const std: msg.metadata()->length = length; msg.metadata()->msg_type = static_cast(cmdu.getMessageType()); msg.metadata()->preset_message_id = cmdu.getMessageId() ? 1 : 0; + msg.metadata()->if_index = if_nametoindex(iface_name.c_str()); std::copy_n((uint8_t *)cmdu.getMessageBuff(), msg.metadata()->length, (uint8_t *)msg.data()); return bus->publisher().Send(msg); diff --git a/common/beerocks/btl/btl_uds.cpp b/common/beerocks/btl/btl_uds.cpp index ab2931e14f..54e327d048 100644 --- a/common/beerocks/btl/btl_uds.cpp +++ b/common/beerocks/btl/btl_uds.cpp @@ -108,8 +108,10 @@ void transport_socket_thread::bus_connected(Socket *sd) add_socket(bus); } -bool transport_socket_thread::bus_send(ieee1905_1::CmduMessage &cmdu, const std::string &dst_mac, - const std::string &src_mac, uint16_t length) +bool transport_socket_thread::bus_send(ieee1905_1::CmduMessage &cmdu, + [[gnu::unused]] const std::string &iface_name, + const std::string &dst_mac, const std::string &src_mac, + uint16_t length) { auto uds_header = message_com::get_uds_header(cmdu); if (!uds_header) { diff --git a/common/beerocks/btl/include/btl/btl.h b/common/beerocks/btl/include/btl/btl.h index 544d402ccd..6fcb9ed484 100644 --- a/common/beerocks/btl/include/btl/btl.h +++ b/common/beerocks/btl/include/btl/btl.h @@ -35,8 +35,18 @@ class transport_socket_thread : public socket_thread { virtual void set_select_timeout(unsigned msec) override; virtual bool work() override; + /** + * @brief Sends CDMU to transport for dispatching. + * + * @param cmdu Control Message Data Unit to send. + * @param dst_mac Destination MAC address. + * @param src_mac Source MAC address. + * @param iface_name Name of the network interface to use (set to empty string to send on all + * available interfaces). + * @return True on success and false otherwise. + */ bool send_cmdu_to_bus(ieee1905_1::CmduMessageTx &cmdu, const std::string &dst_mac, - const std::string &src_mac); + const std::string &src_mac, const std::string &iface_name = ""); protected: void add_socket(Socket *s, bool add_to_vector = true) override; @@ -50,13 +60,25 @@ class transport_socket_thread : public socket_thread { bool bus_connect(const std::string &beerocks_temp_path, const bool local_master); void bus_connected(Socket *sd); + /** + * @brief Sends CDMU to transport for dispatching. + * + * @param cmdu Control Message Data Unit to send. + * @param dst_mac Destination MAC address. + * @param src_mac Source MAC address. + * @param length Message length. + * @param iface_name Name of the network interface to use (set to empty string to send on all + * available interfaces). + * @return True on success and false otherwise. + */ bool send_cmdu_to_bus(ieee1905_1::CmduMessage &cmdu, const std::string &dst_mac, - const std::string &src_mac, uint16_t length); + const std::string &src_mac, uint16_t length, + const std::string &iface_name = ""); private: bool bus_init(); - bool bus_send(ieee1905_1::CmduMessage &cmdu, const std::string &dst_mac, - const std::string &src_mac, uint16_t length); + bool bus_send(ieee1905_1::CmduMessage &cmdu, const std::string &iface_name, + const std::string &dst_mac, const std::string &src_mac, uint16_t length); bool handle_cmdu_message_bus(); int poll_timeout_ms = 500; From d6e0ef86cc94862bfdedfe25f7b82203e978cad3 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Thu, 11 Jun 2020 12:44:15 +0200 Subject: [PATCH 048/453] agent: backhaul: send Topology Discovery on all interfaces Currently, we sent a single Topology Discovery message through the bridge. However, according to IEEE1905.1, the message should include a MAC Address TLV which contains the address of the interface on which you send the message. Thus, a different message should be sent on each interface. Therefore, the agent should send a separate Discovery message on each interface. Signed-off-by: Mario Maz --- .../backhaul_manager_thread.cpp | 49 ++++++++++++++++--- .../backhaul_manager_thread.h | 9 ++++ 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 0ae2123b0f..4ab978b7f9 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -1120,26 +1120,59 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) bool backhaul_manager::send_1905_topology_discovery_message() { + // TODO: get the list of interfaces that are up_and_running using the event-driven mechanism + // to be implemented in #866 + + /** + * Transmission type of Topology Discovery message is 'neighbor multicast'. + * That is, the CMDU must be transmitted once on each and every of its 1905.1 interfaces. + * Also, according to IEEE1905.1, the message should include a MAC Address TLV which contains + * the address of the interface on which the message is sent. Thus, a different message should + * be sent on each interface. + */ + auto ifaces = network_utils::linux_get_iface_list_from_bridge(m_sConfig.bridge_iface); + for (const auto &iface_name : ifaces) { + if (!network_utils::linux_iface_is_up_and_running(iface_name)) { + continue; + } + + send_1905_topology_discovery_message(iface_name); + } + + return true; +} + +bool backhaul_manager::send_1905_topology_discovery_message(const std::string &iface_name) +{ + sMacAddr iface_mac; + if (!get_iface_mac(iface_name, iface_mac)) { + return false; + } + auto cmdu_hdr = cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_DISCOVERY_MESSAGE); if (!cmdu_hdr) { LOG(ERROR) << "Failed to create TOPOLOGY_DISCOVERY_MESSAGE cmdu"; return false; } - auto tlvAlMac = cmdu_tx.addClass(); - if (!tlvAlMac) { + + auto tlvAlMacAddress = cmdu_tx.addClass(); + if (!tlvAlMacAddress) { LOG(ERROR) << "Failed to create tlvAlMacAddress tlv"; return false; } - tlvAlMac->mac() = tlvf::mac_from_string(bridge_info.mac); - auto tlvMac = cmdu_tx.addClass(); - if (!tlvMac) { + tlvAlMacAddress->mac() = tlvf::mac_from_string(bridge_info.mac); + + auto tlvMacAddress = cmdu_tx.addClass(); + if (!tlvMacAddress) { LOG(ERROR) << "Failed to create tlvMacAddress tlv"; return false; } - tlvMac->mac() = tlvf::mac_from_string(bridge_info.mac); + tlvMacAddress->mac() = iface_mac; - LOG(DEBUG) << "send_1905_topology_discovery_message, bridge_mac=" << bridge_info.mac; - return send_cmdu_to_bus(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac); + LOG(DEBUG) << "send_1905_topology_discovery_message, bridge_mac=" << bridge_info.mac + << ", iface=" << iface_name; + return send_cmdu_to_bus(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac, + iface_name); } bool backhaul_manager::send_autoconfig_search_message(std::shared_ptr soc) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 1980241986..64a244c41c 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -91,6 +91,15 @@ class backhaul_manager : public btl::transport_socket_thread { bool send_autoconfig_search_message(std::shared_ptr soc); bool send_1905_topology_discovery_message(); + + /** + * @brief Sends Topology Discovery message on given interface. + * + * @param iface_name Name of the network interface on which the message is transmitted. + * @return True on success and false otherwise + */ + bool send_1905_topology_discovery_message(const std::string &iface_name); + bool send_slave_ap_metric_query_message(uint16_t mid, std::vector const &bssid_list); // cmdu handlers From 38673377a17a0d97b09fa311121057b54cc5e6a0 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 11 Jun 2020 16:37:55 +0300 Subject: [PATCH 049/453] framework: tlvf: Turn on Backhaul STA Steering TLV's For auto-generating TLV for Backhaul STA Steering Request/Response needs to add yaml files to the tlv_conf.yaml. It is turning on auto-generation code from those TLV. Signed-off-by: Vladyslav Tupikin --- .../tlvf/wfa_map/tlvBackhaulSteeringRequest.h | 58 +++++++ .../wfa_map/tlvBackhaulSteeringResponse.h | 61 +++++++ .../wfa_map/tlvBackhaulSteeringRequest.cpp | 153 ++++++++++++++++++ .../wfa_map/tlvBackhaulSteeringResponse.cpp | 143 ++++++++++++++++ framework/tlvf/tlvf_conf.yaml | 2 + 5 files changed, 417 insertions(+) create mode 100644 framework/tlvf/AutoGenerated/include/tlvf/wfa_map/tlvBackhaulSteeringRequest.h create mode 100644 framework/tlvf/AutoGenerated/include/tlvf/wfa_map/tlvBackhaulSteeringResponse.h create mode 100644 framework/tlvf/AutoGenerated/src/tlvf/wfa_map/tlvBackhaulSteeringRequest.cpp create mode 100644 framework/tlvf/AutoGenerated/src/tlvf/wfa_map/tlvBackhaulSteeringResponse.cpp diff --git a/framework/tlvf/AutoGenerated/include/tlvf/wfa_map/tlvBackhaulSteeringRequest.h b/framework/tlvf/AutoGenerated/include/tlvf/wfa_map/tlvBackhaulSteeringRequest.h new file mode 100644 index 0000000000..4298516803 --- /dev/null +++ b/framework/tlvf/AutoGenerated/include/tlvf/wfa_map/tlvBackhaulSteeringRequest.h @@ -0,0 +1,58 @@ +/////////////////////////////////////// +// AUTO GENERATED FILE - DO NOT EDIT // +/////////////////////////////////////// + +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#ifndef _TLVF_WFA_MAP_TLVBACKHAULSTEERINGREQUEST_H_ +#define _TLVF_WFA_MAP_TLVBACKHAULSTEERINGREQUEST_H_ + +#include +#include +#include +#include +#include +#include +#include +#include "tlvf/wfa_map/eTlvTypeMap.h" +#include "tlvf/common/sMacAddr.h" + +namespace wfa_map { + + +class tlvBackhaulSteeringRequest : public BaseClass +{ + public: + tlvBackhaulSteeringRequest(uint8_t* buff, size_t buff_len, bool parse = false); + explicit tlvBackhaulSteeringRequest(std::shared_ptr base, bool parse = false); + ~tlvBackhaulSteeringRequest(); + + const eTlvTypeMap& type(); + const uint16_t& length(); + sMacAddr& backhaul_station_mac(); + sMacAddr& target_bssid(); + uint8_t& operating_class(); + uint8_t& target_channel_number(); + void class_swap() override; + bool finalize() override; + static size_t get_initial_size(); + + private: + bool init(); + eTlvTypeMap* m_type = nullptr; + uint16_t* m_length = nullptr; + sMacAddr* m_backhaul_station_mac = nullptr; + sMacAddr* m_target_bssid = nullptr; + uint8_t* m_operating_class = nullptr; + uint8_t* m_target_channel_number = nullptr; +}; + +}; // close namespace: wfa_map + +#endif //_TLVF/WFA_MAP_TLVBACKHAULSTEERINGREQUEST_H_ diff --git a/framework/tlvf/AutoGenerated/include/tlvf/wfa_map/tlvBackhaulSteeringResponse.h b/framework/tlvf/AutoGenerated/include/tlvf/wfa_map/tlvBackhaulSteeringResponse.h new file mode 100644 index 0000000000..c3536d1dc0 --- /dev/null +++ b/framework/tlvf/AutoGenerated/include/tlvf/wfa_map/tlvBackhaulSteeringResponse.h @@ -0,0 +1,61 @@ +/////////////////////////////////////// +// AUTO GENERATED FILE - DO NOT EDIT // +/////////////////////////////////////// + +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#ifndef _TLVF_WFA_MAP_TLVBACKHAULSTEERINGRESPONSE_H_ +#define _TLVF_WFA_MAP_TLVBACKHAULSTEERINGRESPONSE_H_ + +#include +#include +#include +#include +#include +#include +#include +#include "tlvf/wfa_map/eTlvTypeMap.h" +#include "tlvf/common/sMacAddr.h" + +namespace wfa_map { + + +class tlvBackhaulSteeringResponse : public BaseClass +{ + public: + tlvBackhaulSteeringResponse(uint8_t* buff, size_t buff_len, bool parse = false); + explicit tlvBackhaulSteeringResponse(std::shared_ptr base, bool parse = false); + ~tlvBackhaulSteeringResponse(); + + enum eResultCode: uint8_t { + SUCCESS = 0x0, + FAILURE = 0x1, + }; + + const eTlvTypeMap& type(); + const uint16_t& length(); + sMacAddr& backhaul_station_mac(); + sMacAddr& target_bssid(); + eResultCode& result_code(); + void class_swap() override; + bool finalize() override; + static size_t get_initial_size(); + + private: + bool init(); + eTlvTypeMap* m_type = nullptr; + uint16_t* m_length = nullptr; + sMacAddr* m_backhaul_station_mac = nullptr; + sMacAddr* m_target_bssid = nullptr; + eResultCode* m_result_code = nullptr; +}; + +}; // close namespace: wfa_map + +#endif //_TLVF/WFA_MAP_TLVBACKHAULSTEERINGRESPONSE_H_ diff --git a/framework/tlvf/AutoGenerated/src/tlvf/wfa_map/tlvBackhaulSteeringRequest.cpp b/framework/tlvf/AutoGenerated/src/tlvf/wfa_map/tlvBackhaulSteeringRequest.cpp new file mode 100644 index 0000000000..f8d211cd5f --- /dev/null +++ b/framework/tlvf/AutoGenerated/src/tlvf/wfa_map/tlvBackhaulSteeringRequest.cpp @@ -0,0 +1,153 @@ +/////////////////////////////////////// +// AUTO GENERATED FILE - DO NOT EDIT // +/////////////////////////////////////// + +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include +#include + +using namespace wfa_map; + +tlvBackhaulSteeringRequest::tlvBackhaulSteeringRequest(uint8_t* buff, size_t buff_len, bool parse) : + BaseClass(buff, buff_len, parse) { + m_init_succeeded = init(); +} +tlvBackhaulSteeringRequest::tlvBackhaulSteeringRequest(std::shared_ptr base, bool parse) : +BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ + m_init_succeeded = init(); +} +tlvBackhaulSteeringRequest::~tlvBackhaulSteeringRequest() { +} +const eTlvTypeMap& tlvBackhaulSteeringRequest::type() { + return (const eTlvTypeMap&)(*m_type); +} + +const uint16_t& tlvBackhaulSteeringRequest::length() { + return (const uint16_t&)(*m_length); +} + +sMacAddr& tlvBackhaulSteeringRequest::backhaul_station_mac() { + return (sMacAddr&)(*m_backhaul_station_mac); +} + +sMacAddr& tlvBackhaulSteeringRequest::target_bssid() { + return (sMacAddr&)(*m_target_bssid); +} + +uint8_t& tlvBackhaulSteeringRequest::operating_class() { + return (uint8_t&)(*m_operating_class); +} + +uint8_t& tlvBackhaulSteeringRequest::target_channel_number() { + return (uint8_t&)(*m_target_channel_number); +} + +void tlvBackhaulSteeringRequest::class_swap() +{ + tlvf_swap(16, reinterpret_cast(m_length)); + m_backhaul_station_mac->struct_swap(); + m_target_bssid->struct_swap(); +} + +bool tlvBackhaulSteeringRequest::finalize() +{ + if (m_parse__) { + TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; + return true; + } + if (m_finalized__) { + TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; + return true; + } + if (!isPostInitSucceeded()) { + TLVF_LOG(ERROR) << "post init check failed"; + return false; + } + if (m_inner__) { + if (!m_inner__->finalize()) { + TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; + return false; + } + auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); + m_buff_ptr__ -= tailroom; + *m_length -= tailroom; + } + class_swap(); + m_finalized__ = true; + return true; +} + +size_t tlvBackhaulSteeringRequest::get_initial_size() +{ + size_t class_size = 0; + class_size += sizeof(eTlvTypeMap); // type + class_size += sizeof(uint16_t); // length + class_size += sizeof(sMacAddr); // backhaul_station_mac + class_size += sizeof(sMacAddr); // target_bssid + class_size += sizeof(uint8_t); // operating_class + class_size += sizeof(uint8_t); // target_channel_number + return class_size; +} + +bool tlvBackhaulSteeringRequest::init() +{ + if (getBuffRemainingBytes() < get_initial_size()) { + TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; + return false; + } + m_type = reinterpret_cast(m_buff_ptr__); + if (!m_parse__) *m_type = eTlvTypeMap::TLV_BACKHAUL_STEERING_REQUEST; + if (!buffPtrIncrementSafe(sizeof(eTlvTypeMap))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(eTlvTypeMap) << ") Failed!"; + return false; + } + m_length = reinterpret_cast(m_buff_ptr__); + if (!m_parse__) *m_length = 0; + if (!buffPtrIncrementSafe(sizeof(uint16_t))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; + return false; + } + m_backhaul_station_mac = reinterpret_cast(m_buff_ptr__); + if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; + return false; + } + if(m_length && !m_parse__){ (*m_length) += sizeof(sMacAddr); } + if (!m_parse__) { m_backhaul_station_mac->struct_init(); } + m_target_bssid = reinterpret_cast(m_buff_ptr__); + if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; + return false; + } + if(m_length && !m_parse__){ (*m_length) += sizeof(sMacAddr); } + if (!m_parse__) { m_target_bssid->struct_init(); } + m_operating_class = reinterpret_cast(m_buff_ptr__); + if (!buffPtrIncrementSafe(sizeof(uint8_t))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; + return false; + } + if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } + m_target_channel_number = reinterpret_cast(m_buff_ptr__); + if (!buffPtrIncrementSafe(sizeof(uint8_t))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; + return false; + } + if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } + if (m_parse__) { class_swap(); } + if (m_parse__) { + if (*m_type != eTlvTypeMap::TLV_BACKHAUL_STEERING_REQUEST) { + TLVF_LOG(ERROR) << "TLV type mismatch. Expected value: " << int(eTlvTypeMap::TLV_BACKHAUL_STEERING_REQUEST) << ", received value: " << int(*m_type); + return false; + } + } + return true; +} + + diff --git a/framework/tlvf/AutoGenerated/src/tlvf/wfa_map/tlvBackhaulSteeringResponse.cpp b/framework/tlvf/AutoGenerated/src/tlvf/wfa_map/tlvBackhaulSteeringResponse.cpp new file mode 100644 index 0000000000..9d3b307777 --- /dev/null +++ b/framework/tlvf/AutoGenerated/src/tlvf/wfa_map/tlvBackhaulSteeringResponse.cpp @@ -0,0 +1,143 @@ +/////////////////////////////////////// +// AUTO GENERATED FILE - DO NOT EDIT // +/////////////////////////////////////// + +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include +#include + +using namespace wfa_map; + +tlvBackhaulSteeringResponse::tlvBackhaulSteeringResponse(uint8_t* buff, size_t buff_len, bool parse) : + BaseClass(buff, buff_len, parse) { + m_init_succeeded = init(); +} +tlvBackhaulSteeringResponse::tlvBackhaulSteeringResponse(std::shared_ptr base, bool parse) : +BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ + m_init_succeeded = init(); +} +tlvBackhaulSteeringResponse::~tlvBackhaulSteeringResponse() { +} +const eTlvTypeMap& tlvBackhaulSteeringResponse::type() { + return (const eTlvTypeMap&)(*m_type); +} + +const uint16_t& tlvBackhaulSteeringResponse::length() { + return (const uint16_t&)(*m_length); +} + +sMacAddr& tlvBackhaulSteeringResponse::backhaul_station_mac() { + return (sMacAddr&)(*m_backhaul_station_mac); +} + +sMacAddr& tlvBackhaulSteeringResponse::target_bssid() { + return (sMacAddr&)(*m_target_bssid); +} + +tlvBackhaulSteeringResponse::eResultCode& tlvBackhaulSteeringResponse::result_code() { + return (eResultCode&)(*m_result_code); +} + +void tlvBackhaulSteeringResponse::class_swap() +{ + tlvf_swap(16, reinterpret_cast(m_length)); + m_backhaul_station_mac->struct_swap(); + m_target_bssid->struct_swap(); + tlvf_swap(8*sizeof(eResultCode), reinterpret_cast(m_result_code)); +} + +bool tlvBackhaulSteeringResponse::finalize() +{ + if (m_parse__) { + TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; + return true; + } + if (m_finalized__) { + TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; + return true; + } + if (!isPostInitSucceeded()) { + TLVF_LOG(ERROR) << "post init check failed"; + return false; + } + if (m_inner__) { + if (!m_inner__->finalize()) { + TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; + return false; + } + auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); + m_buff_ptr__ -= tailroom; + *m_length -= tailroom; + } + class_swap(); + m_finalized__ = true; + return true; +} + +size_t tlvBackhaulSteeringResponse::get_initial_size() +{ + size_t class_size = 0; + class_size += sizeof(eTlvTypeMap); // type + class_size += sizeof(uint16_t); // length + class_size += sizeof(sMacAddr); // backhaul_station_mac + class_size += sizeof(sMacAddr); // target_bssid + class_size += sizeof(eResultCode); // result_code + return class_size; +} + +bool tlvBackhaulSteeringResponse::init() +{ + if (getBuffRemainingBytes() < get_initial_size()) { + TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; + return false; + } + m_type = reinterpret_cast(m_buff_ptr__); + if (!m_parse__) *m_type = eTlvTypeMap::TLV_BACKHAUL_STEERING_RESPONSE; + if (!buffPtrIncrementSafe(sizeof(eTlvTypeMap))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(eTlvTypeMap) << ") Failed!"; + return false; + } + m_length = reinterpret_cast(m_buff_ptr__); + if (!m_parse__) *m_length = 0; + if (!buffPtrIncrementSafe(sizeof(uint16_t))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; + return false; + } + m_backhaul_station_mac = reinterpret_cast(m_buff_ptr__); + if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; + return false; + } + if(m_length && !m_parse__){ (*m_length) += sizeof(sMacAddr); } + if (!m_parse__) { m_backhaul_station_mac->struct_init(); } + m_target_bssid = reinterpret_cast(m_buff_ptr__); + if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; + return false; + } + if(m_length && !m_parse__){ (*m_length) += sizeof(sMacAddr); } + if (!m_parse__) { m_target_bssid->struct_init(); } + m_result_code = reinterpret_cast(m_buff_ptr__); + if (!buffPtrIncrementSafe(sizeof(eResultCode))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(eResultCode) << ") Failed!"; + return false; + } + if(m_length && !m_parse__){ (*m_length) += sizeof(eResultCode); } + if (m_parse__) { class_swap(); } + if (m_parse__) { + if (*m_type != eTlvTypeMap::TLV_BACKHAUL_STEERING_RESPONSE) { + TLVF_LOG(ERROR) << "TLV type mismatch. Expected value: " << int(eTlvTypeMap::TLV_BACKHAUL_STEERING_RESPONSE) << ", received value: " << int(*m_type); + return false; + } + } + return true; +} + + diff --git a/framework/tlvf/tlvf_conf.yaml b/framework/tlvf/tlvf_conf.yaml index 702c5ca15a..4c936eaf83 100644 --- a/framework/tlvf/tlvf_conf.yaml +++ b/framework/tlvf/tlvf_conf.yaml @@ -46,6 +46,8 @@ include_yaml_path: { "tlvf/wfa_map/tlvSupportedService.yaml", "tlvf/wfa_map/tlvTimestamp.yaml", "tlvf/wfa_map/tlvTransmitPowerLimit.yaml", + "tlvf/wfa_map/tlvBackhaulSteeringRequest.yaml", + "tlvf/wfa_map/tlvBackhaulSteeringResponse.yaml", } # Relative to tlvf.py src_path variable From 17731a6aa6c498225a43087835a967c5d575c07a Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Mon, 15 Jun 2020 15:40:58 +0300 Subject: [PATCH 050/453] tlvf: CmduMessageRx: Add case for Backhaul STA Steering In the method parseNextTlv() missing cases for Backhaul STA Steering Request/Response TLV's. Add missing cases with correct values for message types. Signed-off-by: Vladyslav Tupikin --- framework/tlvf/src/src/CmduMessageRx.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/framework/tlvf/src/src/CmduMessageRx.cpp b/framework/tlvf/src/src/CmduMessageRx.cpp index 6080528575..db43454d90 100644 --- a/framework/tlvf/src/src/CmduMessageRx.cpp +++ b/framework/tlvf/src/src/CmduMessageRx.cpp @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include #include #include @@ -230,6 +232,12 @@ std::shared_ptr CmduMessageRx::parseNextTlv() case (157): { return msg.addClass(); } + case (158): { + return msg.addClass(); + } + case (159): { + return msg.addClass(); + } case (160): { return msg.addClass(); } From 1416a7753e2cb8ecf0199bd6fb7cc0f7268804f8 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Fri, 19 Jun 2020 13:52:19 +0200 Subject: [PATCH 051/453] bcl: add new method network_utils::linux_get_iface_name Add new method to network utils to get the interface name for a given interface index. Signed-off-by: Mario Maz --- .../beerocks/bcl/include/bcl/network/network_utils.h | 9 +++++++++ common/beerocks/bcl/source/network/network_utils.cpp | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/common/beerocks/bcl/include/bcl/network/network_utils.h b/common/beerocks/bcl/include/bcl/network/network_utils.h index 939a516a89..46cf681f25 100644 --- a/common/beerocks/bcl/include/bcl/network/network_utils.h +++ b/common/beerocks/bcl/include/bcl/network/network_utils.h @@ -119,6 +119,15 @@ class network_utils { * @return interface index or 0 if no interface exists with the name given. */ static uint32_t linux_get_iface_index(const std::string &iface_name); + + /** + * @brief Gets the interface name corresponding to a particular index. + * + * @param iface_index The index of the network interface. + * @return interface name or empty string if no interface exists with the index given. + */ + static std::string linux_get_iface_name(uint32_t iface_index); + static bool linux_add_iface_to_bridge(const std::string &bridge, const std::string &iface); static bool linux_remove_iface_from_bridge(const std::string &bridge, const std::string &iface); static bool linux_iface_ctrl(const std::string &iface, bool up, std::string ip = "", diff --git a/common/beerocks/bcl/source/network/network_utils.cpp b/common/beerocks/bcl/source/network/network_utils.cpp index 3e4277633a..4d8050da8d 100644 --- a/common/beerocks/bcl/source/network/network_utils.cpp +++ b/common/beerocks/bcl/source/network/network_utils.cpp @@ -533,6 +533,18 @@ uint32_t network_utils::linux_get_iface_index(const std::string &iface_name) return iface_index; } +std::string network_utils::linux_get_iface_name(uint32_t iface_index) +{ + char iface_name[IF_NAMESIZE] = {0}; + if (!if_indextoname(iface_index, iface_name)) { + LOG(ERROR) << "Failed to read the name of interface with index " << iface_index << ": " + << strerror(errno); + return ""; + } + + return iface_name; +} + bool network_utils::linux_add_iface_to_bridge(const std::string &bridge, const std::string &iface) { LOG(DEBUG) << "add iface " << iface << " to bridge " << bridge; From 81f3221ae0215936fc414aa52cf3dd83b1bcb645 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Fri, 19 Jun 2020 13:55:00 +0200 Subject: [PATCH 052/453] agent: backhaul_manager: use iface name instead of index in topology db Use interface names everywhere, rather than interface indexes. - Interfaces are not renamed while prplmesh is running, so interface name is as stable as interface index; - Conversely, interface index is likely to change, e.g. when an AP is reconfigured all its VAP interfaces are brought down and up again, so they will have the same name but a different ifindex; - In addition, the name is easier for debugging. Signed-off-by: Mario Maz --- .../slave/backhaul_manager/backhaul_manager_thread.cpp | 9 ++++++++- .../slave/backhaul_manager/backhaul_manager_thread.h | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 4ab978b7f9..213f0707cf 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -3329,6 +3329,13 @@ bool backhaul_manager::handle_1905_topology_discovery(const std::string &src_mac return false; } + uint32_t if_index = message_com::get_uds_header(cmdu_rx)->if_index; + std::string if_name = network_utils::linux_get_iface_name(if_index); + if (if_name.empty()) { + LOG(ERROR) << "Failed getting interface name for index: " << if_index; + return false; + } + auto new_device = m_1905_neighbor_devices.find(tlvAlMac->mac()) == m_1905_neighbor_devices.end(); @@ -3336,7 +3343,7 @@ bool backhaul_manager::handle_1905_topology_discovery(const std::string &src_mac sNeighborDevice neighbor_device; neighbor_device.al_mac = tlvAlMac->mac(); neighbor_device.mac = tlvMac->mac(); - neighbor_device.if_index = message_com::get_uds_header(cmdu_rx)->if_index; + neighbor_device.if_name = if_name; neighbor_device.timestamp = std::chrono::steady_clock::now(); m_1905_neighbor_devices[tlvAlMac->mac()] = neighbor_device; diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 64a244c41c..063cb4efb1 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -473,8 +473,8 @@ class backhaul_manager : public btl::transport_socket_thread { ZERO_MAC; /**< 1905.1 AL MAC address of the Topology Discovery message transmitting device. */ sMacAddr mac = beerocks::net::network_utils:: ZERO_MAC; /**< MAC address of the interface on which the Topology Discovery message is transmitted. */ - uint32_t if_index = - 0; /**< Index of the network interface the Topology Discovery message was received on */ + std::string + if_name; /**< Name of the network interface the Topology Discovery message was received on */ std::chrono::steady_clock::time_point timestamp; /**< Timestamp of the last Topology Discovery message received from this neighbor device. */ }; From 5363c885eeaccecdb59b0ec43ef4a0893bfb06d0 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Fri, 19 Jun 2020 16:56:21 +0200 Subject: [PATCH 053/453] agent: backhaul: add one 1905.1 neighbor device TLV for each local interface When building the Topology Response message, the tlv1905NeighborDevice we construct is not entirely correct. We should create a tlv1905NeighborDevice for every local interface on which a 1905 neighbor is visible, and then add a list of neighbors visible on that interface. However, since we dind't keep track of the incoming interface of the received Topology Discovery messages, we couldn't do that. Instead, we modeled it as a single interface, the bridge interface, behind which all neighbors are visible, with a bridge between them. Now, when we receive a Topology Discovery, we store the interface on which it has been received together with the neighbor discovered and fill Topology Response message correctly. Add a 1905.1 neighbor device TLV for each local interface for which this management entity has inferred the presence of a 1905.1 neighbor device. Include each discovered neighbor device in its corresponding 1905.1 neighbor device TLV. Signed-off-by: Mario Maz --- .../backhaul_manager_thread.cpp | 80 ++++++++++++------- 1 file changed, 52 insertions(+), 28 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 213f0707cf..672a2e45da 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -2927,40 +2927,64 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd } } - // The tlv1905NeighborDevice we construct here is not entirely correct, but close enough. - // We should create a tlv1905NeighborDevice for every local interface on which a 1905 neighbor - // is visible, and then add a list of neighbors visible on that interface. However, since we - // don't keep track of the incoming interface of the received topology discovery messages, we - // can't do that. Instead, we model it as a single interface, the bridge interface, behind which - // all neighbors are visible, with a bridge between them. This is accurate enough to allow us to - // work in practice. - auto tlv1905NeighborDevice = cmdu_tx.addClass(); - if (!tlv1905NeighborDevice) { - LOG(ERROR) << "addClass ieee1905_1::tlv1905NeighborDevice failed, mid=" << std::hex - << (int)mid; - return false; - } - tlv1905NeighborDevice->mac_local_iface() = tlvf::mac_from_string(bridge_info.mac); + /** + * Add a 1905.1 neighbor device TLV for each local interface for which this management entity + * has inferred the presence of a 1905.1 neighbor device. Include each discovered neighbor + * device in its corresponding 1905.1 neighbor device TLV. + * + * First, group known 1905 neighbor devices by the local interface that links to them. Create + * a map which key is the name of the local interface and the value is the list of neighbor + * devices inferred from that interface. + */ + std::unordered_map> neighbor_devices_by_local_iface; + for (const auto &entry : m_1905_neighbor_devices) { + const auto &neighbor_device = entry.second; + auto &neighbor_devices = neighbor_devices_by_local_iface[neighbor_device.if_name]; - if (!tlv1905NeighborDevice->alloc_mac_al_1905_device(m_1905_neighbor_devices.size())) { - LOG(ERROR) << "alloc_mac_al_1905_device() has failed"; - return true; + neighbor_devices.emplace_back(neighbor_device); } - size_t index = 0; - for (const auto &neighbor_device : m_1905_neighbor_devices) { - const auto &neighbor_al_mac = neighbor_device.first; + /** + * Second, create a tlv1905NeighborDevice for every local interface on which a 1905 neighbor + * is visible, and then add the list of neighbors visible on that interface + */ + for (const auto &entry : neighbor_devices_by_local_iface) { + const auto &iface_name = entry.first; + const auto &neighbor_devices = entry.second; + + sMacAddr iface_mac; + if (!get_iface_mac(iface_name, iface_mac)) { + return false; + } + + auto tlv1905NeighborDevice = cmdu_tx.addClass(); + if (!tlv1905NeighborDevice) { + LOG(ERROR) << "addClass ieee1905_1::tlv1905NeighborDevice failed, mid=" << std::hex + << mid; + return false; + } + + tlv1905NeighborDevice->mac_local_iface() = iface_mac; - auto mac_al_1905_device_tuple = tlv1905NeighborDevice->mac_al_1905_device(index); - if (!std::get<0>(mac_al_1905_device_tuple)) { - LOG(ERROR) << "getting mac_al_1905_device element has failed"; + if (!tlv1905NeighborDevice->alloc_mac_al_1905_device(neighbor_devices.size())) { + LOG(ERROR) << "alloc_mac_al_1905_device() has failed"; return true; } - auto &mac_al_1905_device = std::get<1>(mac_al_1905_device_tuple); - mac_al_1905_device.mac = neighbor_al_mac; - mac_al_1905_device.bridges_exist = - ieee1905_1::tlv1905NeighborDevice::eBridgesExist::AT_LEAST_ONE_BRIDGES_EXIST; - index++; + + size_t index = 0; + for (const auto &neighbor_device : neighbor_devices) { + auto mac_al_1905_device_tuple = tlv1905NeighborDevice->mac_al_1905_device(index); + if (!std::get<0>(mac_al_1905_device_tuple)) { + LOG(ERROR) << "getting mac_al_1905_device element has failed"; + return true; + } + + auto &mac_al_1905_device = std::get<1>(mac_al_1905_device_tuple); + mac_al_1905_device.mac = neighbor_device.al_mac; + mac_al_1905_device.bridges_exist = + ieee1905_1::tlv1905NeighborDevice::eBridgesExist::AT_LEAST_ONE_BRIDGES_EXIST; + index++; + } } auto tlvSupportedService = cmdu_tx.addClass(); From 6567416ce32cdbd59d29c83a7f36b39371c84eef Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Thu, 11 Jun 2020 15:16:41 +0000 Subject: [PATCH 054/453] agent: Add unified agent shared DB infrastructure This DB is meant to be used by all Agent threads (Agent, Platform manager, Backhaul manager), to prevent data duplication from thread to thread. Signed-off-by: Moran Shoeg --- agent/src/beerocks/slave/agent_db.h | 79 +++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 agent/src/beerocks/slave/agent_db.h diff --git a/agent/src/beerocks/slave/agent_db.h b/agent/src/beerocks/slave/agent_db.h new file mode 100644 index 0000000000..9da322f5aa --- /dev/null +++ b/agent/src/beerocks/slave/agent_db.h @@ -0,0 +1,79 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2019-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include +#include +#include + +namespace beerocks { + +/** + * @brief AgentDB is a class used by all main Agent threads on the Agent process to store the Agent + * common data. + * + * The class is implemented using singleton design pattern. + * It is thread safe and being locked and released automatically. + * + * How to use: + * @code + * auto db = AgentDB::get(); // Get DB and automatically lock it. The lock will be + * // Released when 'db' will be destructed. + * + * db->foo = 42; // Change database member 'foo' to value 42. + * db->bar = "prpl" // Set another database member. + * auto &my_foo = db->foo; // Get a refernce to a member. + * + * AgentDB::get()->foo = 44; // Set database member directly. + * + * + * Unsafe operation which should never be done: + * auto my_foo = AgentDB::get()->foo; // Unsafe! Don't do it! The database might be unlocked, + * // if used on ranged loop. So better not use it. + * + * auto &foo = AgentDB::get()->foo; // Unsafe! Don't do it! The database will be unlocked, + * // but the reference will remain. + * + * std::string &get_foo() { // Unsafe! Don't do it! Returning refernce to the database + * auto db = AgentDB::get(); // on a wrapper function is unsafe because the database will + * return db->foo; // be unlocked when the function ends, and the caller will + * } // hold a refernce to it. // hold a refernce to it. + * @endcode + */ +class AgentDB { +public: + class SafeDB { + public: + SafeDB(AgentDB &db) : m_db(db) { m_db.db_lock(); } + ~SafeDB() { m_db.db_unlock(); } + AgentDB *operator->() { return &m_db; } + + private: + AgentDB &m_db; + }; + static SafeDB get() + { + // Guaranteed to be destroyed. + // Instantiated on first use. + static AgentDB instance; + return SafeDB(instance); + } + AgentDB(const AgentDB &) = delete; + void operator=(const AgentDB &) = delete; + +private: + // Private constructor so that no objects can be created. + AgentDB() = default; + std::recursive_mutex m_db_mutex; + void db_lock() { m_db_mutex.lock(); } + void db_unlock() { m_db_mutex.unlock(); } + +public: + /* Put here database members used by the Agent modules */ +}; + +} // namespace beerocks From 5f4facae15470c52d0335e59d7b2d6127bc982cc Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 24 Jun 2020 11:45:21 +0000 Subject: [PATCH 055/453] tlvf: Fix typo on eMediaType enum +Auto generated code. Fix typo on all occurrences. Signed-off-by: Moran Shoeg --- .../backhaul_manager/backhaul_manager_thread.cpp | 14 +++++++------- .../backhaul_manager/backhaul_manager_thread.h | 2 +- .../include/tlvf/ieee_1905_1/eMediaType.h | 2 +- framework/tlvf/README.md | 2 +- .../tlvf/yaml/tlvf/ieee_1905_1/eMediaType.yaml | 3 +-- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 672a2e45da..1896264611 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -161,7 +161,7 @@ static const std::vectorhostap_iface; ieee1905_1::eMediaTypeGroup media_type_group = ieee1905_1::eMediaTypeGroup::IEEE_802_11; - ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType::UNKNONWN_MEDIA; + ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; if (!get_media_type(local_interface_name, media_type_group, media_type)) { LOG(ERROR) << "Unable to compute media type for interface " << local_interface_name; return false; @@ -4138,7 +4138,7 @@ bool backhaul_manager::get_media_type(const std::string &interface_name, } else if (SPEED_1000 <= speed) { media_type = ieee1905_1::eMediaType::IEEE_802_3AB_GIGABIT_ETHERNET; } else { - media_type = ieee1905_1::eMediaType::UNKNONWN_MEDIA; + media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; } result = true; @@ -4163,7 +4163,7 @@ bool backhaul_manager::get_media_type(const std::string &interface_name, // TODO: Not supported yet LOG(ERROR) << "MoCA media is not supported yet"; } else { - media_type = ieee1905_1::eMediaType::UNKNONWN_MEDIA; + media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; result = true; } @@ -4242,7 +4242,7 @@ bool backhaul_manager::get_neighbor_links( interface.media_type = beerocks::get_802_11_media_type(slave->freq_type, slave->max_bandwidth); - if (ieee1905_1::eMediaType::UNKNONWN_MEDIA == interface.media_type) { + if (ieee1905_1::eMediaType::UNKNOWN_MEDIA == interface.media_type) { LOG(ERROR) << "Unknown media type for interface " << interface.iface_name; return false; } diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 063cb4efb1..165e10c5fd 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -398,7 +398,7 @@ class backhaul_manager : public btl::transport_socket_thread { sMacAddr iface_mac = beerocks::net::network_utils::ZERO_MAC; /**< The MAC address of the interface. */ ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType:: - UNKNONWN_MEDIA; /**< The underlying network technology of the connecting interface. */ + UNKNOWN_MEDIA; /**< The underlying network technology of the connecting interface. */ bool operator<(const sLinkInterface &rhs) const { return iface_name < rhs.iface_name; } }; diff --git a/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eMediaType.h b/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eMediaType.h index f9874404ab..bf2900728f 100644 --- a/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eMediaType.h +++ b/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eMediaType.h @@ -34,7 +34,7 @@ enum eMediaType: uint16_t { IEEE_1901_WAVELET = 0x200, IEEE_1901_FFT = 0x201, MOCA_V1_1 = 0x300, - UNKNONWN_MEDIA = 0xffff, + UNKNOWN_MEDIA = 0xffff, }; enum eMediaTypeGroup: uint8_t { diff --git a/framework/tlvf/README.md b/framework/tlvf/README.md index 51105e4dde..1fda4340d8 100644 --- a/framework/tlvf/README.md +++ b/framework/tlvf/README.md @@ -485,7 +485,7 @@ eMediaType: IEEE_802_11G_2_4_GHZ: 0x0101 IEEE_802_11A_5_GHZ: 0x0102 MOCA_V1_1: 0x0300 - UNKNONWN_MEDIA: 0xFFFF + UNKNOWN_MEDIA: 0xFFFF ``` #### Multi class diff --git a/framework/tlvf/yaml/tlvf/ieee_1905_1/eMediaType.yaml b/framework/tlvf/yaml/tlvf/ieee_1905_1/eMediaType.yaml index 3aeb679382..020aeb6380 100755 --- a/framework/tlvf/yaml/tlvf/ieee_1905_1/eMediaType.yaml +++ b/framework/tlvf/yaml/tlvf/ieee_1905_1/eMediaType.yaml @@ -19,7 +19,7 @@ eMediaType: IEEE_1901_WAVELET: 0x0200 IEEE_1901_FFT: 0x0201 MOCA_V1_1: 0x0300 - UNKNONWN_MEDIA: 0xFFFF + UNKNOWN_MEDIA: 0xFFFF eMediaTypeGroup: _type: enum @@ -29,4 +29,3 @@ eMediaTypeGroup: IEEE_1901: 0x02 MoCA: 0x03 UNKNOWN: 0xFF - From fd92ab65508e5177ccb211e20dd46a7720cb9359 Mon Sep 17 00:00:00 2001 From: Vitalii Komisarenko Date: Wed, 24 Jun 2020 15:57:24 +0300 Subject: [PATCH 056/453] prplmesh_utils.sh: send SIGKILL after SIGTERM Sometimes SIGTERM does not stop prplMesh properly. This commit adds a timeout to do it. If prplMesh remains running SIGKILL is sent. Basic busybox start-stop-daemon doesn't support the -R and -T options, so we have to emulate them with a timeout loop and pgrep. Signed-off-by: Vitalii Komisarenko Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- common/beerocks/scripts/prplmesh_utils.sh.in | 21 +++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/common/beerocks/scripts/prplmesh_utils.sh.in b/common/beerocks/scripts/prplmesh_utils.sh.in index 432111949c..5fc8b523d0 100755 --- a/common/beerocks/scripts/prplmesh_utils.sh.in +++ b/common/beerocks/scripts/prplmesh_utils.sh.in @@ -27,9 +27,24 @@ run() { killall_program() { PROGRAM_NAME=$1 - KILL_SIG=${2:-TERM} - echo "killing $PROGRAM_NAME ($KILL_SIG)" - start-stop-daemon -K -s "$KILL_SIG" -x "$PRPLMESH_BIN_DIR"/"$PROGRAM_NAME" > /dev/null 2>&1 + TERM_SIG=${2:-TERM} + TIMEOUT=10 + echo "terminating $PROGRAM_NAME ($TERM_SIG)" + start-stop-daemon -K -s "$TERM_SIG" -x "$PRPLMESH_BIN_DIR"/"$PROGRAM_NAME" > /dev/null 2>&1 + + # If an explicit signal was provided, we don't do a SIGKILL + if [ -n "$2" ]; then return; fi + + # `-R` option is not always available for `start-stop-daemon`, we need to imitate it + for _ in $(seq 1 "$TIMEOUT"); do + if ! pgrep "$PROGRAM_NAME" > /dev/null; then + return + fi + sleep 1 + done + + echo "killing $PROGRAM_NAME (KILL)" + start-stop-daemon -K -s "KILL" -x "$PRPLMESH_BIN_DIR"/"$PROGRAM_NAME" > /dev/null 2>&1 } platform_init() { From 305d4874c86cf26202a80260e2953c30648069e4 Mon Sep 17 00:00:00 2001 From: Vitalii Komisarenko Date: Wed, 17 Jun 2020 17:45:42 +0300 Subject: [PATCH 057/453] bcl: UCC listener: prevent buffer overflow The code inside `beerocks_ucc_listener::custom_message_handler` does not check the value returned by `readBytes`. It is treated as a length of a string, the assumed end of the string is then marked by '\0'. This approach has three issues: * if `readBytes` returns an error (negative number): * memory before the read buffer is written * old buffer content (a previous message or potentially a non-null-terminated garbage) is processed * if `readBytes` returns a number equal to the length of the buffer, '\0' is written right after the buffer. This commit prevents these issues. Signed-off-by: Vitalii Komisarenko --- common/beerocks/bcl/source/beerocks_ucc_listener.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/beerocks/bcl/source/beerocks_ucc_listener.cpp b/common/beerocks/bcl/source/beerocks_ucc_listener.cpp index 051c73a7a1..6219442655 100644 --- a/common/beerocks/bcl/source/beerocks_ucc_listener.cpp +++ b/common/beerocks/bcl/source/beerocks_ucc_listener.cpp @@ -438,9 +438,15 @@ bool beerocks_ucc_listener::custom_message_handler(Socket *sd, uint8_t *rx_buffe size_t rx_buffer_size) { std::string command_string; - auto available_bytes = sd->readBytes(rx_buffer, rx_buffer_size, true); + auto available_bytes = sd->readBytes(rx_buffer, rx_buffer_size, true); + + if (available_bytes <= 0) { + LOG(ERROR) << "Cannot read from socket"; + return true; + } + rx_buffer[available_bytes] = '\0'; - command_string.assign(reinterpret_cast(rx_buffer)); + command_string.assign(reinterpret_cast(rx_buffer), available_bytes); beerocks::string_utils::trim(command_string); From 587cbc1b459e62c513580cda5c8de8c130171ac6 Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Mon, 15 Jun 2020 13:07:21 +0300 Subject: [PATCH 058/453] tests: boardfarm: keep MAC and ucc_socket in prplWRT and docker devices We are not saving MAC address of radio and ucc socket of ALEntity. As consequence, we can't reach methods of ucc sockets. Methods of ucc socket are required for ApConfigurationRenew to work. Keep ucc_socket and MAC address as members of ALEntityDocker, ALEntityPrplWrt classes. Signed-off-by: Anton Bilohai --- tests/environment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/environment.py b/tests/environment.py index 675397d33f..9e6594c70f 100644 --- a/tests/environment.py +++ b/tests/environment.py @@ -458,7 +458,7 @@ def wait_for_log(self, regex: str, start_line: int, timeout: float) -> bool: # Multiply timeout by 100, as test sets it in float. return _device_wait_for_log(self.device, "{}/beerocks_{}.log".format(self.log_folder, program), - regex, start_line, timeout*100) + regex, start_line, timeout) def prprlmesh_status_check(self): return self.device.prprlmesh_status_check() @@ -483,7 +483,7 @@ def wait_for_log(self, regex: str, start_line: int, timeout: float): ''' Poll the Radio's logfile until it match regular expression ''' # Multiply timeout by 100, as test sets it in float. return _device_wait_for_log(self.agent.device, "{}/beerocks_agent_{}.log".format( - self.log_folder, self.iface_name), regex, timeout*100, start_line) + self.log_folder, self.iface_name), regex, timeout, start_line) class VirtualAPHostapd(VirtualAP): From 4946e91602fd72525e896ded272372d3e33a520e Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Mon, 15 Jun 2020 13:17:37 +0300 Subject: [PATCH 059/453] tests: boardfarm: port ApConfigRenew test Port ApConfigRenew test from "test_flows.py". Add ApConfigRenew to the general test suite. Signed-off-by: Anton Bilohai --- .../tests/ap_config_renew.py | 67 +++++++++++++++++++ .../boardfarm_prplmesh/testsuites.cfg | 1 + 2 files changed, 68 insertions(+) create mode 100644 tests/boardfarm_plugins/boardfarm_prplmesh/tests/ap_config_renew.py diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/ap_config_renew.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/ap_config_renew.py new file mode 100644 index 0000000000..aeebe2a07b --- /dev/null +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/ap_config_renew.py @@ -0,0 +1,67 @@ +############################################################### +# SPDX-License-Identifier: BSD-2-Clause-Patent +# SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) +# This code is subject to the terms of the BSD+Patent license. +# See LICENSE file for more details. +############################################################### +import time + +from .prplmesh_base_test import PrplMeshBaseTest +from capi import tlv + + +class ApConfigRenew(PrplMeshBaseTest): + """Check initial configuration on device.""" + + def runTest(self): + # Locate agents and controller + for dev in self.dev: + if dev.controller_entity: + controller = dev.controller_entity + if dev.agent_entity: + agent = dev.agent_entity + + dev.wired_sniffer.start(self.__class__.__name__ + "-" + dev.name) + # Regression test: MAC address should be case insensitive + mac_repeater1_upper = agent.mac.upper() + controller.ucc_socket.cmd_reply("DEV_RESET_DEFAULT") + controller.ucc_socket.cmd_reply( + "DEV_SET_CONFIG," + "bss_info1,{} 8x Multi-AP-24G-1 0x0020 0x0008 maprocks1 0 1," + "bss_info2,{} 8x Multi-AP-24G-2 0x0020 0x0008 maprocks2 1 0" + .format(mac_repeater1_upper, agent.mac)) + controller.ucc_socket.dev_send_1905(agent.mac, 0x000A, + tlv(0x01, 0x0006, "{" + controller.mac + "}"), + tlv(0x0F, 0x0001, "{0x00}"), + tlv(0x10, 0x0001, "{0x00}")) + + time.sleep(30) + self.check_log(agent.radios[0], + r"ssid: Multi-AP-24G-1 .*" + r"fronthaul: true backhaul: false", + timeout=60) + self.check_log(agent.radios[0], + r"ssid: Multi-AP-24G-2 .*" + r"fronthaul: false backhaul: true", + timeout=60) + self.check_log(agent.radios[1], + r"tear down radio", + timeout=60) + bssid1 = agent.ucc_socket.dev_get_parameter('macaddr', + ruid='0x' + + agent.radios[0].mac.replace(':', ''), + ssid='Multi-AP-24G-1') + if not bssid1: + self.fail("repeater1 didn't configure Multi-AP-24G-1") + # simulate wps onboarding to the backhaul vap + agent.ucc_socket.start_wps_registration("24G") + self.check_log(agent.radios[0], r"Start WPS PBC", timeout=60) + + @classmethod + def teardown_class(cls): + """Teardown method, optional for boardfarm tests.""" + test = cls.test_obj + for dev in test.dev: + if dev.agent_entity: + print("Sniffer - stop") + dev.wired_sniffer.stop() diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/testsuites.cfg b/tests/boardfarm_plugins/boardfarm_prplmesh/testsuites.cfg index 85eae1fce6..004c17c028 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/testsuites.cfg +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/testsuites.cfg @@ -5,3 +5,4 @@ [test_flows] InitialApConfig +ApConfigRenew From f739ff7849ab89ccdb3c21e0c99804adcd525116 Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Mon, 22 Jun 2020 17:43:47 +0200 Subject: [PATCH 060/453] agent: ucc listener: remove EOL whitespace in comments clang-format doesn't clean whitespace in comments. However, some editors do clean whitespace when saving. Clean whitespace now. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- agent/src/beerocks/slave/agent_ucc_listener.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/agent/src/beerocks/slave/agent_ucc_listener.cpp b/agent/src/beerocks/slave/agent_ucc_listener.cpp index 6416478644..61dac6389b 100644 --- a/agent/src/beerocks/slave/agent_ucc_listener.cpp +++ b/agent/src/beerocks/slave/agent_ucc_listener.cpp @@ -44,7 +44,7 @@ bool agent_ucc_listener::init() /** * @brief Returns string filled with reply to "DEVICE_GET_INFO" command. - * + * * @return const std::string Device info in UCC reply format. */ std::string agent_ucc_listener::fill_version_reply_string() @@ -55,7 +55,7 @@ std::string agent_ucc_listener::fill_version_reply_string() /** * @brief Clear configuration on Agent, and initiate onboarding sequence. - * + * * @return None. */ void agent_ucc_listener::clear_configuration() @@ -80,7 +80,7 @@ void agent_ucc_listener::clear_configuration() /** * @brief Update list of VAPs for ruid. - * + * * @return None. */ @@ -146,7 +146,7 @@ bool agent_ucc_listener::handle_dev_get_param(std::unordered_map Date: Mon, 22 Jun 2020 17:43:47 +0200 Subject: [PATCH 061/453] agent: backhaul_manager: remove EOL whitespace in comments clang-format doesn't clean whitespace in comments. However, some editors do clean whitespace when saving. Clean whitespace now. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- .../slave/backhaul_manager/backhaul_manager_thread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 1896264611..aa900eb338 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -986,7 +986,7 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) * The high CPU load is due to a call to linux_iface_is_up_and_running() performed every * second to check if the wired interface changed its state. The implementation of the above * polls the interface flags using ioctl() which is very costly (~120 milliseconds). - * + * * An event-driven solution will be implemented as part of the task: * [TASK] Dynamic switching between wired and wireless * https://github.com/prplfoundation/prplMesh/issues/866 @@ -1966,7 +1966,7 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr /* * NOTE: Why moving to RESTART state? It causing BACKHAUL DISCONNECTED to the son slaves, * which in the past (when we had TCP socket to the controller instead of the bus) - * disconnected the socket, but now when we have bus it is not happening anyway. + * disconnected the socket, but now when we have bus it is not happening anyway. * Another thing it is causing is to re-scan the for networks. Is it really necessary? * Can we just move immediately to WIRELESS_ASSOCIATE_4ADDR, and then when successfully * connected, notify the agent about the ne bssid? From f6c8b65b37f5a84464388a97804ce970d4f2c87d Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Mon, 22 Jun 2020 17:55:29 +0200 Subject: [PATCH 062/453] agent: UCC listener: dev_set_config: don't wait for autoconfig When the dev_set_config command was implemented for the agent UCC listener, we thought that it should wait for AP autoconfig to complete before returning. However: - for wired backhaul, it's not really needed because it is always followed by a 5 second sleep, plenty of time for onboarding to finish; - for wireless backhaul, it's not possible because there is no backhaul connection until WPS is done, so it never completes. Therefore, we can simply return immediately from handle_dev_set_config rather than waiting for onboarding success. This also allows us to vastly simplify the onboarding state handling. Rather than exposing the onboarding state to the backhaul manager, we can simply replace it by the is_in_reset() check. We still do need the WAIT_FOR_RESET state to make sure DEV_RESET_DEFAULT doesn't return until the reset is complete, but all other states can be replaced by a single state CONFIGURED. This in turns allows us to simplify the onboarding state handling in the backhaul manager thread. Instead of checking and "advancing" the state in different places, we can simply check at the beginning of backhaul_fsm_main if we should stay in reset. Handling of ACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION is no longer needed. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- .../src/beerocks/slave/agent_ucc_listener.cpp | 66 ++++--------------- agent/src/beerocks/slave/agent_ucc_listener.h | 21 +++--- .../backhaul_manager_thread.cpp | 52 ++++++--------- 3 files changed, 41 insertions(+), 98 deletions(-) diff --git a/agent/src/beerocks/slave/agent_ucc_listener.cpp b/agent/src/beerocks/slave/agent_ucc_listener.cpp index 61dac6389b..b2159c3bb2 100644 --- a/agent/src/beerocks/slave/agent_ucc_listener.cpp +++ b/agent/src/beerocks/slave/agent_ucc_listener.cpp @@ -65,7 +65,7 @@ void agent_ucc_listener::clear_configuration() auto timeout = std::chrono::steady_clock::now() + std::chrono::seconds(UCC_REPLY_COMPLETE_TIMEOUT_SEC); - while (m_onboarding_state != eOnboardingState::WAIT_FOR_CONFIG) { + while (m_onboarding_state != eOnboardingState::RESET_TO_DEFAULT) { if (std::chrono::steady_clock::now() > timeout) { LOG(ERROR) << "Reached timeout!"; @@ -231,65 +231,27 @@ bool agent_ucc_listener::handle_dev_set_config(std::unordered_map timeout) { - err_string = "onboarding timeout"; - m_onboarding_state = eOnboardingState::NOT_IN_PROGRESS; - m_selected_backhaul.clear(); - return false; - } - // Unlock the thread mutex and allow the Agent thread to work while this thread sleeps - unlock(); - UTILS_SLEEP_MSEC(1000); - } - - if (m_onboarding_state != eOnboardingState::SUCCESS) { - err_string = "onboarding failed"; - m_onboarding_state = eOnboardingState::NOT_IN_PROGRESS; - m_selected_backhaul.clear(); - return false; - } - - m_onboarding_state = eOnboardingState::NOT_IN_PROGRESS; - m_selected_backhaul.clear(); + m_onboarding_state = eOnboardingState::CONFIGURED; return true; } -/** - * @brief Get the onboarding state, and update the state if needed. - * - * @return eOnboardingState The onboarding state. +/** @brief Check if reset CAPI command was given. + * + * When the DEV_RESET_DEFAULT CAPI command is given, the agent must be held in reset until the + * DEV_SET_CONFIG command is given. This function returns true when this is the case. + * + * In addition, it flags the UCC thread that the reset was "seen" by the backhaul manager thread, + * so the DEV_RESET_DEFAULT command can return. */ -eOnboardingState agent_ucc_listener::get_and_update_onboarding_state() +bool agent_ucc_listener::is_in_reset() { + if (m_onboarding_state == eOnboardingState::CONFIGURED) { + return false; + } if (m_onboarding_state == eOnboardingState::WAIT_FOR_RESET) { m_onboarding_state = eOnboardingState::RESET_TO_DEFAULT; - } else if (m_onboarding_state == eOnboardingState::RESET_TO_DEFAULT) { - m_onboarding_state = eOnboardingState::WAIT_FOR_CONFIG; - return eOnboardingState::RESET_TO_DEFAULT; - } else if (m_onboarding_state == eOnboardingState::WAIT_FOR_CONFIG) { - if (!m_selected_backhaul.empty()) { - m_onboarding_state = eOnboardingState::IN_PROGRESS; - } } - - return m_onboarding_state; -} - -/** - * @brief Set the Agent onboarding status. Calling this function will trigger sending the UCC - * COMPLETE/ERROR status. - * - * @param success Onboarding success status. - * @return None. - */ -void agent_ucc_listener::set_onboarding_status(bool success) -{ - m_onboarding_state = success ? eOnboardingState::SUCCESS : eOnboardingState::FAIL; + return true; } /** diff --git a/agent/src/beerocks/slave/agent_ucc_listener.h b/agent/src/beerocks/slave/agent_ucc_listener.h index af609a2f66..ef284975ca 100644 --- a/agent/src/beerocks/slave/agent_ucc_listener.h +++ b/agent/src/beerocks/slave/agent_ucc_listener.h @@ -19,16 +19,6 @@ namespace beerocks { static const auto DEV_SET_ETH = std::string("eth"); -enum class eOnboardingState { - NOT_IN_PROGRESS, - WAIT_FOR_RESET, - RESET_TO_DEFAULT, - WAIT_FOR_CONFIG, - IN_PROGRESS, - SUCCESS, - FAIL -}; - // Forward decleration for backhaul_manager context saving class backhaul_manager; @@ -44,12 +34,17 @@ class agent_ucc_listener : public beerocks_ucc_listener { void lock() override { mutex.lock(); } void unlock() override { mutex.unlock(); } - eOnboardingState get_and_update_onboarding_state(); - void set_onboarding_status(bool success); + bool is_in_reset(); std::string get_selected_backhaul(); void update_vaps_list(std::string ruid, beerocks_message::sVapsList &vaps); private: + enum class eOnboardingState { + WAIT_FOR_RESET, + RESET_TO_DEFAULT, + CONFIGURED, + }; + std::string fill_version_reply_string() override; void clear_configuration() override; bool send_cmdu_to_destination(ieee1905_1::CmduMessageTx &cmdu_tx, @@ -67,7 +62,7 @@ class agent_ucc_listener : public beerocks_ucc_listener { const std::string &m_bridge_iface; std::string m_bridge_mac; - eOnboardingState m_onboarding_state = eOnboardingState::NOT_IN_PROGRESS; + eOnboardingState m_onboarding_state = eOnboardingState::CONFIGURED; std::string m_selected_backhaul; // "ETH" or "" std::unordered_map vaps_map; diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index aa900eb338..5d7ed0d702 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -291,16 +291,6 @@ bool backhaul_manager::work() { bool skip_select = false; - // Calling get_and_update_onboarding_state returns RESET_TO_DEFAULT only once - if (m_agent_ucc_listener && m_agent_ucc_listener->get_and_update_onboarding_state() == - eOnboardingState::RESET_TO_DEFAULT) { - auto active_hal = get_wireless_hal(); - if (active_hal) { - active_hal->disconnect(); - } - FSM_MOVE_STATE(RESTART); - } - if (!backhaul_fsm_main(skip_select)) return false; @@ -763,6 +753,20 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) // Process internal FSMs before the main one, to prevent // falling into the "default" case... + // UCC FSM. If UCC is in RESET, we have to stay in (or move to) ENABLED state. + if (m_agent_ucc_listener && m_agent_ucc_listener->is_in_reset()) { + if (m_eFSMState == EState::ENABLED) { + // Stay in ENABLE state until onboarding_state will change + return true; + } else if (m_eFSMState > EState::ENABLED) { + auto active_hal = get_wireless_hal(); + if (active_hal) { + active_hal->disconnect(); + } + FSM_MOVE_STATE(RESTART); + } + } + // Wireless FSM if (m_eFSMState > EState::_WIRELESS_START_ && m_eFSMState < EState::_WIRELESS_END_) { return backhaul_fsm_wireless(skip_select); @@ -793,19 +797,12 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) // Received Backhaul Enable command case EState::ENABLED: { - // If reached here without getting DEV_REST_DEFAULT from UCC, 'selected_backhaul' will stay - // empty, and the state machine will not be affected. std::string selected_backhaul; - if (m_agent_ucc_listener) { - auto onboarding_state = m_agent_ucc_listener->get_and_update_onboarding_state(); - if (onboarding_state == eOnboardingState::WAIT_FOR_CONFIG) { - // Stay in ENABLE state until onboarding_state will change - break; - } else if (onboarding_state == eOnboardingState::IN_PROGRESS) { - selected_backhaul = m_agent_ucc_listener->get_selected_backhaul(); - } + selected_backhaul = m_agent_ucc_listener->get_selected_backhaul(); } + // If reached here without getting DEV_RESET_DEFAULT from UCC, 'selected_backhaul' will stay + // empty, and the state machine will not be affected. LOG(TRACE) << "backhaul manager state=ENABLED"; @@ -1052,14 +1049,6 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) LOG(DEBUG) << "Restarting ..."; - if (m_agent_ucc_listener) { - auto onboarding_state = m_agent_ucc_listener->get_and_update_onboarding_state(); - if (onboarding_state == eOnboardingState::WAIT_FOR_CONFIG || - onboarding_state == eOnboardingState::IN_PROGRESS) { - m_agent_ucc_listener->set_onboarding_status(false); - } - } - for (auto soc : slaves_sockets) { std::string iface = soc->sta_iface; @@ -2062,9 +2051,6 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr } case beerocks_message::ACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION: { LOG(DEBUG) << "ACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION"; - if (m_agent_ucc_listener) { - m_agent_ucc_listener->set_onboarding_status(true); - } break; } @@ -2144,8 +2130,8 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr if (!cmdu_tx.create( mid, ieee1905_1::eMessageType::ASSOCIATED_STA_LINK_METRICS_RESPONSE_MESSAGE)) { - LOG(ERROR) - << "cmdu creation of type ASSOCIATED_STA_LINK_METRICS_RESPONSE_MESSAGE has failed"; + LOG(ERROR) << "cmdu creation of type ASSOCIATED_STA_LINK_METRICS_RESPONSE_MESSAGE " + "has failed"; return false; } From c8ce08815cf29ebfe9b76ec38c33cba03d788965 Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Mon, 22 Jun 2020 18:07:18 +0200 Subject: [PATCH 063/453] agent: remove ACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION Since it is no longer needed for UCC onboarding state, we can remove this message from the flow. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- .../backhaul_manager/backhaul_manager_thread.cpp | 5 ----- agent/src/beerocks/slave/son_slave_thread.cpp | 11 ----------- 2 files changed, 16 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 5d7ed0d702..998f276d33 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -2049,11 +2049,6 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr } break; } - case beerocks_message::ACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION: { - LOG(DEBUG) << "ACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION"; - - break; - } case beerocks_message::ACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION: { LOG(DEBUG) << "ACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION received from iface " << soc->hostap_iface; diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index d3a6297977..7b31c5e593 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -4144,17 +4144,6 @@ bool slave_thread::handle_autoconfiguration_wsc(Socket *sd, ieee1905_1::CmduMess LOG(WARNING) << "non-EasyMesh mode - skip updating VAP credentials"; } - // Notify backhaul manager that onboarding has finished (certification flow) - auto onboarding_finished_notification = message_com::create_vs_message< - beerocks_message::cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION>(cmdu_tx); - - if (onboarding_finished_notification == nullptr) { - LOG(ERROR) << "Failed building message!"; - return false; - } - - message_com::send_cmdu(backhaul_manager_socket, cmdu_tx); - if (slave_state != STATE_WAIT_FOR_JOINED_RESPONSE) { LOG(ERROR) << "slave_state != STATE_WAIT_FOR_JOINED_RESPONSE"; return false; From e7e9cd47b8905b5ebf2a1b0fbc4721e03534ee49 Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Mon, 22 Jun 2020 18:09:17 +0200 Subject: [PATCH 064/453] btlvf: remove ACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION It is no longer used so the message can be removed. Update AutoGenerated as well. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- .../beerocks/tlvf/beerocks_message_action.h | 1 - .../beerocks/tlvf/beerocks_message_backhaul.h | 19 ------ .../tlvf/beerocks_message_backhaul.cpp | 58 ------------------- .../tlvf/beerocks_message_action.yaml | 1 - .../tlvf/beerocks_message_backhaul.yaml | 3 - 5 files changed, 82 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index db364c5af3..b7a0f1c61a 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -131,7 +131,6 @@ enum eActionOp_BACKHAUL: uint8_t { ACTION_BACKHAUL_RESET = 0xa, ACTION_BACKHAUL_BUSY_NOTIFICATION = 0xb, ACTION_BACKHAUL_ENABLE_APS_REQUEST = 0xc, - ACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION = 0xd, ACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION = 0xe, ACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION = 0xf, ACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION = 0x10, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h index 5a5296c940..ba3c15aebb 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h @@ -383,25 +383,6 @@ class cACTION_BACKHAUL_UPDATE_STOP_ON_FAILURE_ATTEMPTS_REQUEST : public BaseClas uint32_t* m_attempts = nullptr; }; -class cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION : public BaseClass -{ - public: - cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION(std::shared_ptr base, bool parse = false); - ~cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION(); - - static eActionOp_BACKHAUL get_action_op(){ - return (eActionOp_BACKHAUL)(ACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION); - } - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_BACKHAUL* m_action_op = nullptr; -}; - class cACTION_BACKHAUL_CLIENT_RX_RSSI_MEASUREMENT_REQUEST : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp index 0b2bd6c5a8..8b72637c1f 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp @@ -1395,64 +1395,6 @@ bool cACTION_BACKHAUL_UPDATE_STOP_ON_FAILURE_ATTEMPTS_REQUEST::init() return true; } -cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION::cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION::cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION::~cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION() { -} -void cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_BACKHAUL), reinterpret_cast(m_action_op)); -} - -bool cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION::get_initial_size() -{ - size_t class_size = 0; - return class_size; -} - -bool cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_BACKHAUL_CLIENT_RX_RSSI_MEASUREMENT_REQUEST::cACTION_BACKHAUL_CLIENT_RX_RSSI_MEASUREMENT_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index 3cd129fdf0..cd9131e57d 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -132,7 +132,6 @@ eActionOp_BACKHAUL: ACTION_BACKHAUL_RESET: 10 ACTION_BACKHAUL_BUSY_NOTIFICATION: 11 ACTION_BACKHAUL_ENABLE_APS_REQUEST: 12 - ACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION: 13 ACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION: 14 ACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION: 15 ACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION: 16 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml index 0d1cf6b5da..2470990648 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml @@ -110,9 +110,6 @@ cACTION_BACKHAUL_UPDATE_STOP_ON_FAILURE_ATTEMPTS_REQUEST: _type: class attempts: uint32_t -cACTION_BACKHAUL_ONBOARDING_FINISHED_NOTIFICATION: - _type: class - cACTION_BACKHAUL_CLIENT_RX_RSSI_MEASUREMENT_REQUEST: _type: class params: sNodeRssiMeasurementRequest From ecb1ddc0d25163de08420d2ace9ccfc703f0254c Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Tue, 23 Jun 2020 14:06:56 +0200 Subject: [PATCH 065/453] agent: UCC listener: add explicit reset_completed() function When DEV_RESET_DEFAULT is done, we currently return immediately, before the reset has actually completed (i.e. before the slaves are ready). Up to now, this wasn't a problem because DEV_SET_CONFIG will wait until onboarding is done. However, we changed DEV_SET_CONFIG to return immediately. Tests will wait for a few seconds after DEV_SET_CONFIG for onboarding to complete, but the slaves may take a lot longer to become ready. In addition. when DEV_RESET_DEFAULT finished, we should be sure that the agent really is reset. Currently we return before the RESTART state is reached. Therefore, track the reset state explicitly in the UCC listener. The backhaul will signal reset_completed() as soon as it reaches ENABLED state. To simplify things, keep track of the state as two separate booleans: m_in_reset and m_reset_completed. Certification tests should still pass: MAP-4.3.2_ETH_FH24G:netgear-rax40 Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- .../src/beerocks/slave/agent_ucc_listener.cpp | 27 ++++-------------- agent/src/beerocks/slave/agent_ucc_listener.h | 28 +++++++++++++------ .../backhaul_manager_thread.cpp | 1 + 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/agent/src/beerocks/slave/agent_ucc_listener.cpp b/agent/src/beerocks/slave/agent_ucc_listener.cpp index b2159c3bb2..50e3042c02 100644 --- a/agent/src/beerocks/slave/agent_ucc_listener.cpp +++ b/agent/src/beerocks/slave/agent_ucc_listener.cpp @@ -60,12 +60,13 @@ std::string agent_ucc_listener::fill_version_reply_string() */ void agent_ucc_listener::clear_configuration() { - m_onboarding_state = eOnboardingState::WAIT_FOR_RESET; + m_in_reset = true; + m_reset_completed = false; auto timeout = std::chrono::steady_clock::now() + std::chrono::seconds(UCC_REPLY_COMPLETE_TIMEOUT_SEC); - while (m_onboarding_state != eOnboardingState::RESET_TO_DEFAULT) { + while (!m_reset_completed) { if (std::chrono::steady_clock::now() > timeout) { LOG(ERROR) << "Reached timeout!"; @@ -231,26 +232,8 @@ bool agent_ucc_listener::handle_dev_set_config(std::unordered_map" std::unordered_map vaps_map; diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 998f276d33..acb47ea258 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -756,6 +756,7 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) // UCC FSM. If UCC is in RESET, we have to stay in (or move to) ENABLED state. if (m_agent_ucc_listener && m_agent_ucc_listener->is_in_reset()) { if (m_eFSMState == EState::ENABLED) { + m_agent_ucc_listener->reset_completed(); // Stay in ENABLE state until onboarding_state will change return true; } else if (m_eFSMState > EState::ENABLED) { From 7a97e07eed3825fdbbf66270d653e69cbf802e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Mon, 22 Jun 2020 10:27:39 +0200 Subject: [PATCH 066/453] ci: add a script to reset a git repository to a specific revision MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To make sure the easymesh_cert repository is always in the state we expect it to be, we need to reset it to a specific version, and also clean any untracked file. Add "ci/git-clean-reset.sh" to help us doing that. Signed-off-by: Raphaël Mélotte --- ci/git-clean-reset.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 ci/git-clean-reset.sh diff --git a/ci/git-clean-reset.sh b/ci/git-clean-reset.sh new file mode 100755 index 0000000000..4b92c0eb1c --- /dev/null +++ b/ci/git-clean-reset.sh @@ -0,0 +1,14 @@ +#!/bin/sh -e + +# Reset the repository pointed by $1 to the revision given by $2 + +cd "$1" || { + echo "Failed to cd into \"$1 \". Skipping reset." + exit 1 +} + +git fetch --recurse-submodules +git clean -fd +git submodule foreach --recursive git clean -fd +git checkout --force "$2" +git submodule update --init --force From ec070d3141d71d4779862cd23d32f0fee8b1ede7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Mon, 22 Jun 2020 11:04:56 +0200 Subject: [PATCH 067/453] ci: add the easymesh_cert repository version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This revision is the current latest one from the "pending-wfa-approval" branch: https://git.prpl.dev/prplmesh/wfa-certification/easymesh_cert/-/commit/62f9067f2894441b7d825b51e1b8d7c76fb640e4 Signed-off-by: Raphaël Mélotte --- ci/easymesh_cert_version | 1 + 1 file changed, 1 insertion(+) create mode 100644 ci/easymesh_cert_version diff --git a/ci/easymesh_cert_version b/ci/easymesh_cert_version new file mode 100644 index 0000000000..23f0331dfb --- /dev/null +++ b/ci/easymesh_cert_version @@ -0,0 +1 @@ +62f9067f2894441b7d825b51e1b8d7c76fb640e4 From 23ed8f082ebc985fe6da4fed5dbaa1c72de63794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Mon, 22 Jun 2020 13:18:41 +0200 Subject: [PATCH 068/453] ci: reset the easymesh_cert repository before running the tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tracking the easymesh_cert repository in the prplMesh repository will allow us to test new changes to the UCC test files, but more importantly it will make the CI pipelines easier to repeat at two different points in time. Signed-off-by: Raphaël Mélotte --- .gitlab-ci.yml | 1 + ci/certification/generic.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d4a7519b78..09792ce3c7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -300,6 +300,7 @@ run-certification-tests: echo "Deploying to $DEVICE_UNDER_TEST" tools/deploy_ipk.sh --certification-mode $DEVICE_UNDER_TEST build/$DEVICE_UNDER_TEST/prplmesh.ipk fi + - ci/git-clean-reset.sh /easymesh_cert "$(<"ci/easymesh_cert_version")" - sudo /easymesh_cert/run_test_file.py --upload-results --verbose --log-folder logs --device-under-test $DEVICE_UNDER_TEST $TESTS_TO_RUN artifacts: paths: diff --git a/ci/certification/generic.yml b/ci/certification/generic.yml index a1a7e381c7..68b20505a5 100644 --- a/ci/certification/generic.yml +++ b/ci/certification/generic.yml @@ -4,6 +4,7 @@ GIT_CLONE_PATH: "/builds/prpl-foundation/prplMesh/" script: - echo $CI_COMMIT_DESCRIPTION + - ci/git-clean-reset.sh /easymesh_cert "$(<"ci/easymesh_cert_version")" - sudo /easymesh_cert/run_test_file.py -v -o logs -d $DEVICE_UNDER_TEST "${CI_JOB_NAME%%:*}" artifacts: paths: From 09c50c48ffebdefc27917267c3f063458b4cc276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Fri, 19 Jun 2020 16:54:52 +0200 Subject: [PATCH 069/453] ci: run_easymesh_cert.sh: add an option to reset to a specific hash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new option, --reset-easymesh-cert. When it's provided, the easymesh_cert repository (including its submodules) is cleaned and the version from ci/easymesh_cert_version is checked out. When the option is not provided, the script's behavior is the same as before. This allows developers to work with local changes. Fixes https://github.com/prplfoundation/prplMesh/issues/1184. Make sure at least some of the tests still pass with the changes we did in the certification scripts: MAP-4.2.1:netgear-rax40 MAP-5.3.1:dummy Signed-off-by: Raphaël Mélotte --- ci/run_easymesh_cert.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ci/run_easymesh_cert.sh b/ci/run_easymesh_cert.sh index f2a71d8551..94eec81eae 100755 --- a/ci/run_easymesh_cert.sh +++ b/ci/run_easymesh_cert.sh @@ -24,6 +24,7 @@ usage() { echo " -v|--verbose - set verbosity (ucc logs also redirected to stdout)" echo " -o|--log-folder - path to put the logs to (make sure it does not contain previous logs)." echo " -e|--easymesh-cert - path to easymesh_cert repository (default ../easymesh_cert)" + echo " --reset-easymesh-cert - reset the easymesh_cert repository to the version specified in this file." echo " -d|--device - select DUT device to use, valid options - glinet-1300, netgear-rax40, turris-omnia, marvell, qualcomm, broadcom, mediatek (default: netgear-rax40)" echo " -s|--ssh - target device ssh name (defined in ~/.ssh/config). (default: $TARGET_DEVICE_SSH)" echo " --owncloud-upload - whether or not to upload results to owncloud. (default: false)" @@ -80,7 +81,7 @@ main() { then echo "this script has to be run as root, aborting" exit 1 fi - if ! OPTS=$(getopt -o 'hvb:o:e:d:s:' --long help,verbose,log-folder:,easymesh-cert:,device:,ssh:,owncloud-upload,owncloud-path:,skip-upgrade -n 'parse-options' -- "$@"); then + if ! OPTS=$(getopt -o 'hvb:o:e:d:s:' --long help,verbose,log-folder:,easymesh-cert:,device:,ssh:,owncloud-upload,owncloud-path:,reset-easymesh-cert,skip-upgrade -n 'parse-options' -- "$@"); then err "Failed parsing options." >&2 usage exit 1 @@ -95,6 +96,7 @@ main() { -o | --log-folder) LOG_FOLDER="$2"; shift 2;; -e | --easymesh-cert) EASYMESH_CERT_PATH="$2"; shift 2;; -d | --device) TARGET_DEVICE="$2"; shift 2;; + --reset-easymesh-cert) RESET_EASYMESH_CERT=true; shift ;; -s | --ssh) TARGET_DEVICE_SSH="$2"; shift 2;; --owncloud-upload) OWNCLOUD_UPLOAD=true; shift;; --owncloud-path) OWNCLOUD_PATH="$2"; shift 2;; @@ -109,6 +111,10 @@ main() { [ -n "$TESTS" ] || TESTS="$EASYMESH_CERT_PATH/tests/all_agent_tests.txt" [ -n "$LOG_FOLDER" ] || LOG_FOLDER="$EASYMESH_CERT_PATH/logs/$(date +%F_%H-%M-%S)" + if [ -n "$RESET_EASYMESH_CERT" ] ; then + "$rootdir"/ci/git-clean-reset.sh "$EASYMESH_CERT_PATH" "$(<"$rootdir/ci/easymesh_cert_version")" + fi + mkdir -p "$LOG_FOLDER" info "Logs location: $LOG_FOLDER" info "Tests to run: $TESTS" From 88f5ac307635016ba7f8b984a978c97fb2a5ce60 Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Sat, 30 May 2020 17:02:43 +0200 Subject: [PATCH 070/453] bcl: wireless_unit_test: use parameters for GetOperatingClassByChannelTest Instead of open-coding the test with a few boundary values, use a parameterized test and cover the entire range. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) Signed-off-by: Mario Maz --- .../bcl/source/son/son_wireless_utils.cpp | 4 +- .../bcl/unit_tests/wireless_utils_test.cpp | 321 +++++++++++++----- 2 files changed, 238 insertions(+), 87 deletions(-) diff --git a/common/beerocks/bcl/source/son/son_wireless_utils.cpp b/common/beerocks/bcl/source/son/son_wireless_utils.cpp index 58233d3962..ec2431be42 100644 --- a/common/beerocks/bcl/source/son/son_wireless_utils.cpp +++ b/common/beerocks/bcl/source/son/son_wireless_utils.cpp @@ -38,8 +38,8 @@ static const std::map operating_classes_list = { {119, {{52, 60}, beerocks::BANDWIDTH_40}}, {120, {{56, 64}, beerocks::BANDWIDTH_40}}, {121, {{100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144}, beerocks::BANDWIDTH_20}}, - {122, {{100, 108, 116, 124, 132, 140}, beerocks::BANDWIDTH_40}}, - {123, {{104, 112, 120, 128, 136, 144}, beerocks::BANDWIDTH_40}}, + {122, {{100, 108, 116, 124, 132, 136, 140}, beerocks::BANDWIDTH_40}}, + {123, {{104, 112, 120, 128, 134, 136, 138, 144}, beerocks::BANDWIDTH_40}}, {124, {{149, 153, 157, 161}, beerocks::BANDWIDTH_20}}, {125, {{149, 153, 157, 161, 165, 169}, beerocks::BANDWIDTH_20}}, {126, {{149, 157}, beerocks::BANDWIDTH_40}}, diff --git a/common/beerocks/bcl/unit_tests/wireless_utils_test.cpp b/common/beerocks/bcl/unit_tests/wireless_utils_test.cpp index cc26eb6b8c..4aa018d4a4 100644 --- a/common/beerocks/bcl/unit_tests/wireless_utils_test.cpp +++ b/common/beerocks/bcl/unit_tests/wireless_utils_test.cpp @@ -13,120 +13,271 @@ namespace { -/** @brief Helper function for testing get_operating_class_by_channel +// See https://docs.google.com/spreadsheets/d/1J2IYuGjFX_OQQpgb4OgsyDx73klAUk6qSmeB4acJ5us +// for the table we need to conform to in the get_operating_class_by_channel() function +// implementation. + +struct sOperatingClass { + uint8_t operating_class; + beerocks::eWiFiBandwidth bandwidth; + std::set channels; +}; + +// clang-format off +const std::vector + table_E_4_global_operating_classes_802_11{ + { 81, beerocks::BANDWIDTH_20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}}, + { 82, beerocks::BANDWIDTH_20, {14}}, + { 83, beerocks::BANDWIDTH_40, {1, 2, 3, 4, 5, 6, 7, 8, 9}}, + /* Note: we have no way to distinguish 40- and 40+, so operating class 83 is used for all bandwidth=40MHz */ + { 84, beerocks::BANDWIDTH_40, {/*5, 6, 7, 8, 9, */10, 11, 12, 13}}, + {115, beerocks::BANDWIDTH_20, {36, 40, 44, 48}}, + {116, beerocks::BANDWIDTH_40, {36, 44}}, + {117, beerocks::BANDWIDTH_40, {40, 48}}, + {118, beerocks::BANDWIDTH_20, {52, 56, 60, 64}}, + {119, beerocks::BANDWIDTH_40, {52, 60}}, + {120, beerocks::BANDWIDTH_40, {56, 64}}, + {121, beerocks::BANDWIDTH_20, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144}}, + {122, beerocks::BANDWIDTH_40, {100, 108, 116, 124, 132, 136, 140}}, + {123, beerocks::BANDWIDTH_40, {104, 112, 120, 128, 134, 138, 144}}, + {124, beerocks::BANDWIDTH_20, {149, 153, 157, 161}}, + /* Note: we have no way to distinguish repeated channels in operating classes 124 and 125 used for bandwidth=20MHz */ + {125, beerocks::BANDWIDTH_20, {/*149, 153, 157, 161,*/ 165, 169}}, + {126, beerocks::BANDWIDTH_40, {149, 157}}, + {127, beerocks::BANDWIDTH_40, {153, 161}}, + {128, beerocks::BANDWIDTH_80, {42, 58, 106, 122, 138, 155}}, + {129, beerocks::BANDWIDTH_160, {50, 114}}, + {130, beerocks::BANDWIDTH_80_80, {42, 58, 106, 122, 138, 155}} +}; +// clang-format on + +/** + * Parameter type used in value-parameterized tests of get_operating_class_by_channel() function. + * Tuple elements are the WiFi channel used as parameter to the function and the expected + * operating class obtained as result. + */ +typedef std::tuple tGetOperatingClassByChannelParam; + +/** + * @brief Gets starting channel for given center channel and bandwidth values. * - * get_operating_class_by_channel takes sWifiChannel as argument. This function builds that struct - * based on channel and bandwith arguments (the only ones relevant for - * get_operating_class_by_channel) and calls get_operating_class_by_channel. + * Operating classes 128, 129 and 130 defined in table_E_4_global_operating_classes_802_11 use + * center channel **unlike the other classes**. Calls to get_operating_class_by_channel() + * require a starting channel number and this function is used to compute it. * - * @return The operating class, as an unsigned (to make it easier to log) + * @param center_channel Center channel number. + * @param bandwidth Channel bandwidth. + * @return Starting channel number. */ -static unsigned get_operating_class_by_channel_helper(uint8_t channel, uint8_t bandwidth) +uint8_t get_starting_channel(uint8_t center_channel, beerocks::eWiFiBandwidth bandwidth) { - beerocks::message::sWifiChannel ch; - ch.channel = channel; - ch.channel_bandwidth = beerocks::utils::convert_bandwidth_to_enum(bandwidth); - return son::wireless_utils::get_operating_class_by_channel(ch); + const uint8_t first_vht_20_mhz_channel = 36; + const uint8_t first_vht_80_mhz_channel = 42; + const uint8_t first_vht_160_mhz_channel = 50; + + if (bandwidth == beerocks::eWiFiBandwidth::BANDWIDTH_160) { + return center_channel - (first_vht_160_mhz_channel - first_vht_20_mhz_channel); + } + + if (bandwidth >= beerocks::eWiFiBandwidth::BANDWIDTH_80) { + return center_channel - (first_vht_80_mhz_channel - first_vht_20_mhz_channel); + } + + return center_channel; } -// See https://docs.google.com/spreadsheets/d/1J2IYuGjFX_OQQpgb4OgsyDx73klAUk6qSmeB4acJ5us -// for the table we need to conform to. -TEST(wireless_utils_test, get_operating_class_by_channel_should_return_valid) +/** + * @brief Gets a list of all possible valid parameters to get_operating_class_by_channel() function + * together with the expected result for each one of them. + * + * Creates a container with all possible combinations of channel number and channel bandwidth to + * create a valid sWifiChannel to use as parameter to get_operating_class_by_channel() function and + * the expected operating class to be obtained as result. + * + * @return vector with pairs of valid WiFi channels and their expected operating class result. + */ +std::vector get_operating_class_by_channel_valid_parameters() { - EXPECT_EQ(get_operating_class_by_channel_helper(1, 20), 81); - EXPECT_EQ(get_operating_class_by_channel_helper(13, 20), 81); + std::vector result; - EXPECT_EQ(get_operating_class_by_channel_helper(14, 20), 82); + for (const auto &entry : table_E_4_global_operating_classes_802_11) { + for (const auto channel : entry.channels) { + beerocks::message::sWifiChannel ch; + ch.channel = get_starting_channel(channel, entry.bandwidth); + ch.channel_bandwidth = entry.bandwidth; - EXPECT_EQ(get_operating_class_by_channel_helper(1, 40), 83); - EXPECT_EQ(get_operating_class_by_channel_helper(9, 40), 83); + result.emplace_back(std::make_tuple(ch, entry.operating_class)); + } + } - /* Note: we have no way to distinguish 40- and 40+ */ - EXPECT_EQ(get_operating_class_by_channel_helper(10, 40), 84); - EXPECT_EQ(get_operating_class_by_channel_helper(13, 40), 84); + return result; +} - EXPECT_EQ(get_operating_class_by_channel_helper(36, 20), 115); - EXPECT_EQ(get_operating_class_by_channel_helper(48, 20), 115); +/** + * @brief Gets a list of invalid parameters to get_operating_class_by_channel() function. + * + * Creates a container of sWifiChannel objects built up with invalid combinations of channel + * number and channel bandwidth. The get_operating_class_by_channel() function returns 0 when + * called with any of these invalid channels as parameter. + * + * @return vector of invalid WiFi channels. + */ +std::vector get_operating_class_by_channel_invalid_parameters() +{ + // clang-format off + const beerocks::eWiFiBandwidth bandwidths[]{ + beerocks::BANDWIDTH_UNKNOWN, + beerocks::BANDWIDTH_20, + beerocks::BANDWIDTH_40, + beerocks::BANDWIDTH_80, + beerocks::BANDWIDTH_80_80, + beerocks::BANDWIDTH_160 + }; + // clang-format on + + std::vector result; - EXPECT_EQ(get_operating_class_by_channel_helper(36, 40), 116); - EXPECT_EQ(get_operating_class_by_channel_helper(44, 40), 116); + /** + * Note: Google Test documentation says that using value-parameterized tests to test your code + * over various inputs (a.k.a. data-driven testing) is a feature easy to abuse of. + * This might well be a good example of such an abuse. + */ - EXPECT_EQ(get_operating_class_by_channel_helper(40, 40), 117); - EXPECT_EQ(get_operating_class_by_channel_helper(48, 40), 117); + /** + * Why do-while instead of for loop? + * So that the loop executes up until and INCLUDING channel == UINT8_MAX, + * for (uint8_t channel = 0; channel <= UINT8_MAX; ++channel) would loop forever !!! + */ + uint8_t channel = 0; + do { + for (auto bandwidth : bandwidths) { + const auto &table = table_E_4_global_operating_classes_802_11; - EXPECT_EQ(get_operating_class_by_channel_helper(52, 20), 118); - EXPECT_EQ(get_operating_class_by_channel_helper(64, 20), 118); + auto it = std::find_if( + table.begin(), table.end(), [&](const sOperatingClass &operating_class) { + if (operating_class.bandwidth != bandwidth) { + return false; + } + return operating_class.channels.end() != operating_class.channels.find(channel); + }); + if (it == table.end()) { + beerocks::message::sWifiChannel ch; + ch.channel = get_starting_channel(channel, bandwidth); + ch.channel_bandwidth = bandwidth; - EXPECT_EQ(get_operating_class_by_channel_helper(52, 40), 119); - EXPECT_EQ(get_operating_class_by_channel_helper(60, 40), 119); + result.emplace_back(std::make_tuple(ch, 0)); + } + } + } while (channel++ < UINT8_MAX); - EXPECT_EQ(get_operating_class_by_channel_helper(56, 40), 120); - EXPECT_EQ(get_operating_class_by_channel_helper(64, 40), 120); + return result; +} - EXPECT_EQ(get_operating_class_by_channel_helper(100, 20), 121); - EXPECT_EQ(get_operating_class_by_channel_helper(144, 20), 121); +/** + * @brief Converts a channel number to its string representation. + * + * Helper function to build the channel part of the name of a value-parameterized test parameter. + * + * @param value Channel number. + * @return Channel number as a string. + */ +std::string channel_to_string(uint8_t value) { return "channel_" + std::to_string(value); } - EXPECT_EQ(get_operating_class_by_channel_helper(100, 40), 122); - EXPECT_EQ(get_operating_class_by_channel_helper(140, 40), 122); +/** + * @brief Converts a channel bandwidth to its string representation. + * + * Helper function to build the bandwidth part of the name of a value-parameterized test parameter. + * + * @param value Channel bandwidth. + * @return Channel bandwidth as a string. + */ +std::string bandwidth_to_string(uint8_t value) +{ + // clang-format off + const std::map bandwidths{ + {beerocks::BANDWIDTH_UNKNOWN, "0"}, + {beerocks::BANDWIDTH_20, "20"}, + {beerocks::BANDWIDTH_40, "40"}, + {beerocks::BANDWIDTH_80, "80"}, + {beerocks::BANDWIDTH_80_80, "80_80"}, + {beerocks::BANDWIDTH_160, "160"} + }; + // clang-format on - EXPECT_EQ(get_operating_class_by_channel_helper(104, 40), 123); - EXPECT_EQ(get_operating_class_by_channel_helper(144, 40), 123); + std::string result = "bandwidth_"; - EXPECT_EQ(get_operating_class_by_channel_helper(149, 20), 124); - EXPECT_EQ(get_operating_class_by_channel_helper(161, 20), 124); + auto bandwidth = static_cast(value); - EXPECT_EQ(get_operating_class_by_channel_helper(165, 20), 125); - EXPECT_EQ(get_operating_class_by_channel_helper(169, 20), 125); + const auto &it = bandwidths.find(bandwidth); + if (bandwidths.end() == it) { + result += "invalid_" + std::to_string(value); + } else { + result += it->second; + } - EXPECT_EQ(get_operating_class_by_channel_helper(149, 40), 126); - EXPECT_EQ(get_operating_class_by_channel_helper(157, 40), 126); + return result; +} - EXPECT_EQ(get_operating_class_by_channel_helper(153, 40), 127); - EXPECT_EQ(get_operating_class_by_channel_helper(161, 40), 127); +/** + * @brief Converts a operating class code to its string representation. + * + * Helper function to build the operating class part of the name of a value-parameterized test + * parameter. + * + * @param value Operating class code. + * @return Operating class as a string. + */ +std::string operating_class_to_string(uint8_t value) +{ + return "operating_class_" + std::to_string(value); +} - /* For 80MHz+, we use starting freq but the table uses center freq */ - EXPECT_EQ(get_operating_class_by_channel_helper(36, 80), 128); - EXPECT_EQ(get_operating_class_by_channel_helper(52, 80), 128); - EXPECT_EQ(get_operating_class_by_channel_helper(100, 80), 128); - EXPECT_EQ(get_operating_class_by_channel_helper(116, 80), 128); - EXPECT_EQ(get_operating_class_by_channel_helper(132, 80), 128); - EXPECT_EQ(get_operating_class_by_channel_helper(149, 80), 128); +/** + * Fixture class to write value-parameterized tests for method + * wireless_utils::get_operating_class_by_channel() + * + * See Value-Parameterized Tests documentation at + * https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#value-parameterized-tests + */ +class WirelessUtilsGetOperatingClassByChannelTest + : public testing::TestWithParam { +}; - EXPECT_EQ(get_operating_class_by_channel_helper(36, 160), 129); - EXPECT_EQ(get_operating_class_by_channel_helper(100, 160), 129); +/** + * @brief Converts a parameter of a get_operating_class_by_channel() value-parameterized test to + * its string representation. + * + * Helper function to create a custom test name suffix based on the test parameter value. + * + * @param info Information of the value-parameterized test parameter. + * @return Value-parameterized test parameter as a string. + */ +std::string operating_class_by_channel_param_to_string( + const testing::TestParamInfo &info) +{ + const auto ¶m = info.param; - /* The helper function doesn't support 80+80 */ - beerocks::message::sWifiChannel channel; - channel.channel_bandwidth = static_cast(beerocks::BANDWIDTH_80_80); - channel.channel = 36; - EXPECT_EQ(+son::wireless_utils::get_operating_class_by_channel(channel), 130); - channel.channel = 149; - EXPECT_EQ(+son::wireless_utils::get_operating_class_by_channel(channel), 130); + return channel_to_string(std::get<0>(param).channel) + "_" + + bandwidth_to_string(std::get<0>(param).channel_bandwidth) + "_" + + operating_class_to_string(std::get<1>(param)); } -TEST(wireless_utils_test, get_operating_class_by_channel_should_return_invalid) +TEST_P(WirelessUtilsGetOperatingClassByChannelTest, should_return_expected) { - EXPECT_EQ(get_operating_class_by_channel_helper(0, 20), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(1, 19), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(1, 1), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(15, 20), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(14, 40), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(32, 20), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(34, 20), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(42, 20), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(68, 20), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(96, 20), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(148, 20), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(165, 40), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(40, 80), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(42, 80), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(44, 80), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(68, 80), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(106, 80), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(40, 160), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(42, 160), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(52, 160), 0); - EXPECT_EQ(get_operating_class_by_channel_helper(149, 160), 0); + beerocks::message::sWifiChannel channel; + uint8_t expected_operating_class; + std::tie(channel, expected_operating_class) = GetParam(); + + EXPECT_EQ(son::wireless_utils::get_operating_class_by_channel(channel), + expected_operating_class); } +INSTANTIATE_TEST_SUITE_P(ValidParamsInstance, WirelessUtilsGetOperatingClassByChannelTest, + testing::ValuesIn(get_operating_class_by_channel_valid_parameters()), + operating_class_by_channel_param_to_string); + +INSTANTIATE_TEST_SUITE_P(InvalidParamsInstance, WirelessUtilsGetOperatingClassByChannelTest, + testing::ValuesIn(get_operating_class_by_channel_invalid_parameters()), + operating_class_by_channel_param_to_string); + } // namespace From 10706c5e85f1bc43a6ae9b1ccda5f7a920ced57f Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Sun, 14 Jun 2020 16:16:38 +0000 Subject: [PATCH 071/453] easylogging: enable logging some stl containers Turn on the STL logging capabilities of the easylogging++ library. With these options enable, it's now possible to easily log unordered_map and unordered_set containers (e.g. LOG(DEBUG) << map). Signed-off-by: Vitaly Bukhovsky --- cmake/Findelpp.cmake | 2 +- framework/external/easylogging/CMakeLists.txt | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/Findelpp.cmake b/cmake/Findelpp.cmake index 5a03815aa0..cb24e70c12 100644 --- a/cmake/Findelpp.cmake +++ b/cmake/Findelpp.cmake @@ -5,7 +5,7 @@ set(ELPP_LIBRARY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libelpp.so.1.4.0) add_library(${ELPP_LIB_NAME} UNKNOWN IMPORTED) set_target_properties(${ELPP_LIB_NAME} PROPERTIES - INTERFACE_COMPILE_DEFINITIONS "ELPP_SYSLOG;ELPP_THREAD_SAFE;ELPP_NO_DEFAULT_LOG_FILE;ELPP_FORCE_USE_STD_THREAD" + INTERFACE_COMPILE_DEFINITIONS "ELPP_SYSLOG;ELPP_THREAD_SAFE;ELPP_STL_LOGGING;ELPP_LOG_UNORDERED_MAP;ELPP_LOG_UNORDERED_SET;ELPP_NO_DEFAULT_LOG_FILE;ELPP_FORCE_USE_STD_THREAD" ) # Include directory diff --git a/framework/external/easylogging/CMakeLists.txt b/framework/external/easylogging/CMakeLists.txt index 239864df9d..e08bd382c0 100644 --- a/framework/external/easylogging/CMakeLists.txt +++ b/framework/external/easylogging/CMakeLists.txt @@ -9,6 +9,9 @@ target_compile_definitions(${PROJECT_NAME} ELPP_THREAD_SAFE ELPP_FORCE_USE_STD_THREAD ELPP_NO_DEFAULT_LOG_FILE + ELPP_STL_LOGGING + ELPP_LOG_UNORDERED_MAP + ELPP_LOG_UNORDERED_SET ELPP_SYSLOG PRIVATE AUTO_INITIALIZE_EASYLOGGINGPP From 7e1a2f18761e08f90ff3ff540dd709c3053f5ee5 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Sun, 21 Jun 2020 13:49:02 +0000 Subject: [PATCH 072/453] bcl: clear socket error before returning Store the error string in a temporary variable and clear the data member before the return statement. Signed-off-by: Vitaly Bukhovsky --- common/beerocks/bcl/include/bcl/network/socket.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/beerocks/bcl/include/bcl/network/socket.h b/common/beerocks/bcl/include/bcl/network/socket.h index 853bd0f836..649ae9fcfd 100644 --- a/common/beerocks/bcl/include/bcl/network/socket.h +++ b/common/beerocks/bcl/include/bcl/network/socket.h @@ -127,8 +127,9 @@ class SocketSelect { bool isBlocking() { return m_isBlocking; } std::string getError() { - return m_error; + auto error = m_error; m_error.clear(); + return error; } private: From de1ea11b131d29f16a631e5b03d36166721fe66e Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Fri, 26 Jun 2020 17:17:10 +0000 Subject: [PATCH 073/453] bcl: template argument validation helper Using type traits, add a helper template class for checking if a template argument is derived from std::chrono::duration. An example usage of this helper can be to statically fail the build if the provided template class is of incorrect type: static_assert(is_chrono_duration::value, "T must be derived from std::chrono::duration"); Signed-off-by: Vitaly Bukhovsky --- common/beerocks/bcl/include/bcl/beerocks_backport.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common/beerocks/bcl/include/bcl/beerocks_backport.h b/common/beerocks/bcl/include/bcl/beerocks_backport.h index 32e18bb45a..8799eb5f78 100644 --- a/common/beerocks/bcl/include/bcl/beerocks_backport.h +++ b/common/beerocks/bcl/include/bcl/beerocks_backport.h @@ -9,7 +9,9 @@ #ifndef _BEEROCKS_BACKPORT_H_ #define _BEEROCKS_BACKPORT_H_ +#include #include +#include #if __cplusplus < 201402L namespace std { @@ -21,4 +23,14 @@ template std::unique_ptr make_unique(Args &&.. } // namespace std #endif +// Until prplMesh will be built using C++20, there's no simple way to fail +// the built if a template argument is not derived from std::chrono::duration. +// This little trick allows using static_assert and fail the build in this case. +template struct is_chrono_duration : std::false_type { +}; + +template +struct is_chrono_duration> : std::true_type { +}; + #endif // _BEEROCKS_BACKPORT_H_ From ae0747449b5a61618ef341d73f2f2b3df4a39856 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Sun, 21 Jun 2020 09:57:48 +0000 Subject: [PATCH 074/453] bcl: event loop interface The event loop is a programming construct that waits for and dispatches events in a program. It works by making a request to some "event provider" (which generally blocks the request until an event has arrived), and then it calls the relevant event handler (i.e.: dispatches the event). Signed-off-by: Vitaly Bukhovsky --- .../bcl/include/bcl/beerocks_event_loop.h | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 common/beerocks/bcl/include/bcl/beerocks_event_loop.h diff --git a/common/beerocks/bcl/include/bcl/beerocks_event_loop.h b/common/beerocks/bcl/include/bcl/beerocks_event_loop.h new file mode 100644 index 0000000000..e8d66d2771 --- /dev/null +++ b/common/beerocks/bcl/include/bcl/beerocks_event_loop.h @@ -0,0 +1,174 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#ifndef _BEEROCKS_EVENT_LOOP_H_ +#define _BEEROCKS_EVENT_LOOP_H_ + +#include "beerocks_backport.h" + +#include +#include + +namespace beerocks { + +/** + * @brief The event loop is a programming construct that waits for and dispatches events + * in a program. + * + * It works by making a request to some "event provider" (which generally blocks the request + * until an event has arrived), and then it calls the relevant event handler (i.e.: dispatches + * the event). + * + * The event provider used by the event loop follows the file interface, which can be selected + * or 'polled' (the Unix system call, not actual polling). The event loop operates + * asynchronously with the event originator. + * + * When the event loop forms the central control flow construct of a program, as it often does, + * it may be termed the main loop or main event loop. This title is appropriate because such an + * event loop is at the highest level of control within the program. + */ + +template class EventLoop { + // Fail the build if T (timeout type) is not derived from std::chrono::duration + static_assert(is_chrono_duration::value, "T must be derived from std::chrono::duration"); + +public: + /** + * The type of the event source (e.g. file descriptor). + */ + using EventType = E; + + /** + * The type of the event loop. + */ + using EventLoopType = EventLoop; + + /** + * The type of the timeout units for the event loop. + */ + using TimeoutType = T; + + /** + * @brief Event handler function definition. + * + * Parameters to the event handler function are: + * @param[in] event The resource where the event was originated at. + * @param[in] loop The event loop where the event was caught. Event handler can install new handlers, + * remove existing handlers and even ask for loop termination. + * + * @returns True on success or false otherwise + */ + using EventHandler = std::function; + + /** + * Set of event handler functions, one function to handle each possible event happened. + * Handlers are grouped into a struct to facilitate passing them as a single parameter to the install and + * remove handlers functions of the event loop. + * Event handlers are optional and if not set for a given event, that event will be silently + * ignored. + */ + struct EventHandlers { + /** + * Hook method that is called back by the event loop to handle read events. + * Read events are dispatched when the socket is ready for a read operation (a read + * operation will not block). + * @param socket Socket the event was originated at. + * @param loop Event loop where the event was caught on. + */ + EventHandler on_read; + + /** + * Hook method that is called back by the event loop to handle write events. + * Write events are dispatched when the socket is ready for a write operation (a write + * operation will not block). + * @param socket Socket the event was originated at. + * @param loop Event loop where the event was caught on. + */ + EventHandler on_write; + + /** + * Hook method that is called back by the event loop to handle timeout events. + * Timeout events are dispatched when timeout expires while waiting for the socket to + * be ready for a read or write operation. + * @param socket Socket the event was originated at. + * @param loop Event loop where the event was caught on. + */ + EventHandler on_timeout; + + /** + * Hook method that is called back by the event loop to handle disconnect events. + * Disconnect events are dispatched when the remote socket is closed. + * @param socket Socket the event was originated at. + * @param loop Event loop where the event was caught on. + */ + EventHandler on_disconnect; + + /** + * Hook method that is called back by the event loop to handle error events. + * Error events are dispatched when an error occurs while waiting for the socket to + * be ready for a read or write operation. + * @param socket Socket the event was originated at. + * @param loop Event loop where the event was caught on. + */ + EventHandler on_error; + }; + + /** + * Default destructor. + */ + virtual ~EventLoop() = default; + + /** + * @brief Registers a set of event handlers for the given event source (e.g. socket). + * + * Event handler for the event that occurred will be called back when the event source is + * ready for a read/write operation, when a disconnect/error occurs or when given timeout expires. + * + * @param event Event source object. + * @param handlers Set of event handlers: class with the methods to be called back when an + * event occurs. + * @param timeout Time to wait in milliseconds (-1 to wait indefinitely) for a read/write + * event to occur. + * @return True on success and false otherwise. + */ + virtual bool add_event(EventType event, EventHandlers handlers, + TimeoutType timeout = TimeoutType::min()) = 0; + + /** + * @brief Removes previously registered event handlers for the given event source. + * + * @param event Event source object. + * @return True on success and false otherwise. + */ + virtual bool del_event(EventType socket) = 0; + + /** + * @brief Runs message loop. + * + * Method returns when loop is explicitly terminated, when an error or timeout occurs + * or when there is no event to wait for (i.e.: no handler installed). + * + * @return -1 on critical errors + * @return 0 on timeout without any socket events + * @return >0 number of socket events processed during the class to this method. + */ + virtual int run() = 0; + + /** + * @brief Terminates a running event loop. + * + * This method asks for loop termination and returns immediately. It is not thread-safe and + * should only be called from an event handler (which runs on the same thread as the event + * loop). + */ + virtual void die() = 0; +}; + +} // namespace beerocks + +#endif // _BEEROCKS_EVENT_LOOP_H_ From e79dece1015a6c91ff2685a3437d282228017096 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Sun, 21 Jun 2020 10:00:35 +0000 Subject: [PATCH 075/453] bcl: epoll based event loop implementation This implementation uses the Linux epoll APIs for monitoring the provided sockets for I/O operations. Timeout operations are achieved by using the timerfd mechanism, which delivers timer expiration notifications via a file descriptor. Signed-off-by: Vitaly Bukhovsky --- .../include/bcl/beerocks_socket_event_loop.h | 128 ++++++ .../bcl/source/beerocks_socket_event_loop.cpp | 366 ++++++++++++++++++ 2 files changed, 494 insertions(+) create mode 100644 common/beerocks/bcl/include/bcl/beerocks_socket_event_loop.h create mode 100644 common/beerocks/bcl/source/beerocks_socket_event_loop.cpp diff --git a/common/beerocks/bcl/include/bcl/beerocks_socket_event_loop.h b/common/beerocks/bcl/include/bcl/beerocks_socket_event_loop.h new file mode 100644 index 0000000000..cb1f26e266 --- /dev/null +++ b/common/beerocks/bcl/include/bcl/beerocks_socket_event_loop.h @@ -0,0 +1,128 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#ifndef _BEEROCKS_SOCKET_EVENT_LOOP_H_ +#define _BEEROCKS_SOCKET_EVENT_LOOP_H_ + +#include "beerocks_event_loop.h" +#include "network/socket.h" + +#include +#include + +namespace beerocks { + +/** + * @brief ePoll based implementation of the EventLoop interface. + * @see EventLoop + * + * This class uses the Linux epoll APIs for monitoring the provided sockets for I/O operations. + * Timeout operations are achieved by using the timerfd mechanism, which delivers timer + * expiration notifications via a file descriptor. + */ +class SocketEventLoop : public EventLoop, std::chrono::milliseconds> { +public: + /** + * @brief Class constructor. + * + * Initializes an epoll file descriptor. + * + * @param [in] timeout Sets the master timeout (in milliseconds) for the event loop. + */ + explicit SocketEventLoop(TimeoutType timeout = TimeoutType::min()); + + /** + * @brief Class destructor. + */ + virtual ~SocketEventLoop(); + + /** + * @see EventPoll::add_event + */ + virtual bool add_event(SocketEventLoop::EventType socket, + SocketEventLoop::EventHandlers handlers, + TimeoutType timeout = TimeoutType::min()) override; + + /** + * @see EventPoll::del_event + */ + virtual bool del_event(SocketEventLoop::EventType socket) override; + + /** + * @see EventPoll::run + */ + virtual int run() override; + + /** + * @see EventPoll::die + */ + virtual void die() override; + +protected: + /** + * @brief Main event loop method. + * + * Executes the epoll_wait() function and processes ocurred events. + * + * @return -1 on critical errors + * @return 0 on timeout without any socket events + * @return >0 number of socket events processed during the call to this method. + */ + virtual int event_loop(); + +private: + /** + * epoll file descriptor. + */ + int m_epoll_fd = -1; + + /** + * Event loop master timeout (used for the epoll_wait function). + */ + TimeoutType m_timeout = TimeoutType::min(); + + /** + * Flag to mark whether the event loop is running. + */ + bool m_running = false; + + /** + * @brief Data structure representing a socket added to the poll. + * This structure groups all the information required for processing socket events. + */ + struct EventData { + /** + * Socket event handler functions structure. + */ + SocketEventLoop::EventHandlers handlers; + + /** + * Shared pointer to the socket object. + */ + SocketEventLoop::EventType socket = nullptr; + + /** + * timer file descriptor. + */ + int timerfd = -1; + + /** + * Socket timeout value in milliseconds. + */ + TimeoutType timeout_value = TimeoutType::min(); + }; + + /** + * Map file descriptors to EventData structure instances. + */ + std::unordered_map> m_fd_to_event_data; +}; + +} // namespace beerocks + +#endif // _BEEROCKS_SOCKET_EVENT_LOOP_H_ diff --git a/common/beerocks/bcl/source/beerocks_socket_event_loop.cpp b/common/beerocks/bcl/source/beerocks_socket_event_loop.cpp new file mode 100644 index 0000000000..99231f339f --- /dev/null +++ b/common/beerocks/bcl/source/beerocks_socket_event_loop.cpp @@ -0,0 +1,366 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include + +#include +#include +#include + +#include + +namespace beerocks { + +////////////////////////////////////////////////////////////////////////////// +////////////////////////// Local module definitions ////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +// Maximal number of events to process in a single epoll_wait call +static constexpr int MAX_POLL_EVENTS = 17; + +////////////////////////////////////////////////////////////////////////////// +/////////////////////////////// Implementation /////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +SocketEventLoop::SocketEventLoop(TimeoutType timeout) : m_timeout(timeout) +{ + m_epoll_fd = epoll_create1(0); + LOG_IF(m_epoll_fd == -1, FATAL) << "Failed creating epoll: " << strerror(errno); +} + +SocketEventLoop::~SocketEventLoop() +{ + // Delete all the sockets in the poll + LOG(DEBUG) << "Removing " << m_fd_to_event_data.size() + << " FDs from the event loop: " << m_fd_to_event_data; + + while (!m_fd_to_event_data.empty()) { + auto event_data = m_fd_to_event_data.begin()->second; + del_event(event_data->socket); + } + + // Close the poll fd + LOG_IF(close(m_epoll_fd) == -1, ERROR) + << "Failed closing epoll file descriptor: " << strerror(errno); +} + +bool SocketEventLoop::add_event(SocketEventLoop::EventType socket, + EventLoop::EventHandlers handlers, TimeoutType timeout) +{ + if (!socket) { + LOG(ERROR) << "Invalid socket pointer!"; + return false; + } + + // Make sure that the FD is not already part of the poll + if (m_fd_to_event_data.find(socket->getSocketFd()) != m_fd_to_event_data.end()) { + LOG(WARNING) << "Requested to add FD (" << socket->getSocketFd() + << ") to the poll, but it's already there..."; + + return false; + } + + // Build EventData structure + auto event_data = std::make_shared(); + event_data->socket = socket; + event_data->handlers = handlers; + + // If timeout is set and a handler is defined, initialize a timerfd + if (timeout > TimeoutType::zero()) { + if (handlers.on_timeout) { + + // TODO: timerfd may not be supported on all kernels. + // Implement a check at creation, and in case it's not supported + // base the timeouts mechanism on the main timeout of the loop. + + // Create a new timerfd file descriptor and initialize the timeout values + event_data->timeout_value = timeout; + event_data->timerfd = timerfd_create(CLOCK_MONOTONIC, 0); + + if (event_data->timerfd == -1) { + LOG(ERROR) << "Failed creating timerfd: " << strerror(errno); + return false; + } + + // Convert the timeout into seconds and nano-seconds + auto timeout_sec = std::chrono::duration_cast(timeout); + auto timeout_nanosec = + std::chrono::duration_cast(timeout - timeout_sec); + + timespec timeout_spec({.tv_sec = static_cast(timeout_sec.count()), + .tv_nsec = static_cast(timeout_nanosec.count())}); + itimerspec timer_val({.it_interval = timeout_spec, .it_value = timeout_spec}); + + // Set the timerfd timeout value + if (timerfd_settime(event_data->timerfd, 0, &timer_val, nullptr) == -1) { + LOG(ERROR) << "Failed setting timerfd value: " << strerror(errno); + return false; + } + } else { + LOG(WARNING) << "Timeout was requested for '" << timeout.count() + << "' milliseconds, but not handler is provided. Ignoring."; + } + } + + // Helper lambda function for adding a fd to the poll, and register for the following events: + // EPOLLIN: The associated fd is available for read operations. + // EPOLLOUT: The associated fd is available for write operations. + // EPOLLRDHUP: Socket peer closed connection, or shut down writing half of connection. + // EPOLLERR: Error condition happened on the associated fd. + // EPOLLHUP: Hang up happened on the associated fd. + auto add_fd_to_epoll = [&](int fd) -> bool { + epoll_event event = {}; + event.data.fd = fd; + event.events = EPOLLRDHUP | EPOLLERR | EPOLLHUP; + + // If read or timeout handlers were set, also listen for POLL-IN events + if (event_data->handlers.on_read || event_data->handlers.on_timeout) { + event.events |= EPOLLIN; + } + + // If write handler was set, also listen for POLL-OUT events + if (event_data->handlers.on_write) { + event.events |= EPOLLOUT; + } + + if (epoll_ctl(m_epoll_fd, EPOLL_CTL_ADD, fd, &event) == -1) { + LOG(ERROR) << "Failed adding FD (" << fd << ") to the poll: " << strerror(errno); + return false; + } + + // Map the fd to the event data structure + m_fd_to_event_data[fd] = event_data; + + return true; + }; + + // Add the socket fd to the poll + if (!add_fd_to_epoll(event_data->socket->getSocketFd())) { + return false; + } + + // Add the timeout fd to the poll + if (event_data->timerfd != -1) { + if (!add_fd_to_epoll(event_data->timerfd)) { + // Remove the socket from the poll and fail + del_event(socket); + return false; + } + } + + return true; +} + +bool SocketEventLoop::del_event(SocketEventLoop::EventType socket) +{ + if (!socket) { + LOG(ERROR) << "Invalid socket pointer!"; + return false; + } + + // Make sure that the fd was previously added to the poll + auto event_data_itr = m_fd_to_event_data.find(socket->getSocketFd()); + if (event_data_itr == m_fd_to_event_data.end()) { + LOG(WARNING) << "Requested to delete FD (" << socket->getSocketFd() + << ") from the poll, but it wasn't previously added."; + + return false; + } + + // Store a copy of the shared_ptr to prevent loosing the reference + // when removing the instance from the map + auto event_data = event_data_itr->second; + + // Delete the socket fd from the poll + auto error = false; + if (epoll_ctl(m_epoll_fd, EPOLL_CTL_DEL, event_data->socket->getSocketFd(), nullptr) == -1) { + LOG(ERROR) << "Failed deleting socket FD (" << event_data->socket->getSocketFd() + << ") from the poll: " << strerror(errno); + + error = true; + } + + // Erase the fd from the map + m_fd_to_event_data.erase(event_data->socket->getSocketFd()); + + // Delete the timeout fd from the poll + if (event_data->timerfd != -1) { + if (epoll_ctl(m_epoll_fd, EPOLL_CTL_DEL, event_data->timerfd, nullptr) == -1) { + LOG(ERROR) << "Failed deleting timeout FD (" << event_data->timerfd + << ") from the poll: " << strerror(errno); + + error = true; + } + + // Remove the fd from the map. Since timeout sockets are created + // automatically by the event pool, also close the fd. + m_fd_to_event_data.erase(event_data->timerfd); + close(event_data->timerfd); + } + + return !error; +} + +int SocketEventLoop::run() +{ + if (m_running) { + return 0; + } + + // Event loop is running + m_running = true; + + // Run the event loop and exit on failures or timeouts (if defined) + while (m_running) { + auto ret = event_loop(); + if (ret <= 0) { + return ret; + } + } + + return 0; +} + +void SocketEventLoop::die() { m_running = false; } + +int SocketEventLoop::event_loop() +{ + // Poll events + epoll_event events[MAX_POLL_EVENTS] = {0}; + + // Convert the global event loop timeout (if set) to milliseconds + int timeout_millis = + (m_timeout > TimeoutType::zero()) + ? static_cast( + std::chrono::duration_cast(m_timeout).count()) + : -1; + + // Poll the sockets + auto num_events = epoll_wait(m_epoll_fd, events, sizeof(events), timeout_millis); + + if (num_events == -1) { + LOG(ERROR) << "Error during epoll_wait: " << strerror(errno); + return -1; + } else if (num_events == 0) { + // Timeout... Do nothing + return 0; + } + + // Trigger event handlers + for (int i = 0; i < num_events; i++) { + int fd = events[i].data.fd; + auto event_data_itr = m_fd_to_event_data.find(fd); + + if (event_data_itr == m_fd_to_event_data.end()) { + LOG(ERROR) << "Event on unknown FD: " << fd; + continue; + } + + // Store a copy of the shared_ptr to prevent loosing the reference + // when removing the instance from the map + auto event_data = event_data_itr->second; + auto &socket = event_data->socket; + + // Handle errors + if (events[i].events & EPOLLERR) { + + // Read the error from the socket + int error = 0; + socklen_t errlen = sizeof(error); + getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&error, &errlen); + LOG(ERROR) << "Error on FD (" << fd << "): " << strerror(error); + + // Remove the socket from the poll + del_event(socket); + + // Call the on_error handler of this socket + if (event_data->handlers.on_error) { + if (!event_data->handlers.on_error(socket, *this)) { + return -1; + } + } + + // Handle Disconnected Sockets + } else if ((events[i].events & EPOLLRDHUP) || (events[i].events & EPOLLHUP)) { + LOG(DEBUG) << "Socket with FD (" << fd << ") disconnected"; + + // Remove the socket from the poll + del_event(socket); + + // Call the on_disconnect handler of this socket + if (event_data->handlers.on_disconnect) { + if (!event_data->handlers.on_disconnect(socket, *this)) { + return -1; + } + } + + // Handle Data & Timeouts + } else if (events[i].events & EPOLLIN) { + + // Handle incoming data + if (event_data->socket->getSocketFd() == fd) { + if (!event_data->handlers.on_read) { + LOG(WARNING) << "Incoming data on socket FD (" << fd + << ") without handler. Removing."; + del_event(socket); + } else { + if (!event_data->handlers.on_read(socket, *this)) { + return -1; + } + } + // Handle timeouts + } else if (event_data->timerfd == fd) { + if (!event_data->handlers.on_timeout) { + // This shouldn't happen as the timeout socket is created only if + // a handler was provided... If somehow if does happen, remove the + // associated socket and the timeout socket. + LOG(ERROR) << "Event on timeout FD (" << fd << ") without handler. Removing."; + del_event(socket); + } else { + // Read the number of expirations occurred on this timerfd + uint64_t num_exp; + if (read(event_data->timerfd, &num_exp, sizeof(num_exp)) != sizeof(num_exp)) { + LOG(ERROR) + << "Failed reading timerfd number of expirations: " << strerror(errno); + return -1; + } + + // If a timer has expired more than once, it means that there is some + // delay in processing events, so print a warning + if (num_exp > 1) { + LOG(WARNING) << "Timer on FD (" << fd << ") expired " << num_exp + << " times since it was previously handled"; + } + + if (!event_data->handlers.on_timeout(socket, *this)) { + return -1; + } + } + } + + // Handle socket is ready for write operations + } else if (events[i].events & EPOLLOUT) { + if (!event_data->handlers.on_write) { + LOG(WARNING) << "Socket FD (" << fd + << ") is ready for write, but there's no handler. Removing."; + del_event(socket); + } else { + if (!event_data->handlers.on_write(socket, *this)) { + return -1; + } + } + + } else { + LOG(ERROR) << "FD (" << fd << ") generated unknown event: " << events[i].events; + } + } + + return num_events; +} + +} // namespace beerocks From e91c940edecab5af72702861f227506969f89434 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Sun, 21 Jun 2020 10:02:35 +0000 Subject: [PATCH 076/453] bcl: tests: epoll event loop unit tests Basic implementation of tests for the epoll based event loop. Tests are implemented using gtest and gmock frameworks. Signed-off-by: Vitaly Bukhovsky --- common/beerocks/bcl/CMakeLists.txt | 3 +- .../bcl/unit_tests/socket_event_loop_test.cpp | 197 ++++++++++++++++++ 2 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 common/beerocks/bcl/unit_tests/socket_event_loop_test.cpp diff --git a/common/beerocks/bcl/CMakeLists.txt b/common/beerocks/bcl/CMakeLists.txt index 3c8871899e..ba0485e795 100644 --- a/common/beerocks/bcl/CMakeLists.txt +++ b/common/beerocks/bcl/CMakeLists.txt @@ -45,6 +45,7 @@ if (BUILD_TESTS) set(TEST_PROJECT_NAME ${PROJECT_NAME}_unit_tests) set(unit_tests_sources ${bcl_sources} + ${MODULE_PATH}/unit_tests/socket_event_loop_test.cpp ${MODULE_PATH}/unit_tests/wireless_utils_test.cpp ) add_executable(${TEST_PROJECT_NAME} @@ -61,7 +62,7 @@ if (BUILD_TESTS) $ ) target_link_libraries(${TEST_PROJECT_NAME} nl-3 nl-route-3 tlvf elpp mapfcommon) - target_link_libraries(${TEST_PROJECT_NAME} gtest_main) + target_link_libraries(${TEST_PROJECT_NAME} gtest_main gmock) install(TARGETS ${TEST_PROJECT_NAME} DESTINATION bin/tests) add_test(NAME ${TEST_PROJECT_NAME} COMMAND $) endif() diff --git a/common/beerocks/bcl/unit_tests/socket_event_loop_test.cpp b/common/beerocks/bcl/unit_tests/socket_event_loop_test.cpp new file mode 100644 index 0000000000..06608d7ae1 --- /dev/null +++ b/common/beerocks/bcl/unit_tests/socket_event_loop_test.cpp @@ -0,0 +1,197 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include + +#include +#include + +#include + +// Initialize easylogging++ +INITIALIZE_EASYLOGGINGPP + +using namespace beerocks; + +using ::testing::InSequence; +using ::testing::Invoke; +using ::testing::StrictMock; + +static constexpr std::chrono::milliseconds s_test_timeout(100); + +// Define Event and Loop types for the use of the unit tests +using EventType = std::shared_ptr; +using LoopType = EventLoop; + +/** + * @brief Mockable event handlers class + */ +class EventHandlersMock : public LoopType::EventHandlers { + +public: + EventHandlersMock() + { + on_read = [&](EventType socket, LoopType &loop) { return handle_read(socket, &loop); }; + on_write = [&](EventType socket, LoopType &loop) { return handle_write(socket, &loop); }; + on_timeout = [&](EventType socket, LoopType &loop) { + return handle_timeout(socket, &loop); + }; + on_disconnect = [&](EventType socket, LoopType &loop) { + return handle_disconnect(socket, &loop); + }; + on_error = [&](EventType socket, LoopType &loop) { return handle_error(socket, &loop); }; + } + + MOCK_METHOD(bool, handle_read, ((EventType &), LoopType *)); + MOCK_METHOD(bool, handle_write, ((EventType &), LoopType *)); + MOCK_METHOD(bool, handle_timeout, ((EventType &), LoopType *)); + MOCK_METHOD(bool, handle_disconnect, ((EventType &), LoopType *)); + MOCK_METHOD(bool, handle_error, ((EventType &), LoopType *)); +}; + +TEST(beerocks_socket_event_loop, setup) +{ + // Configure easylogging++ formatting + el::Configurations defaultConf; + defaultConf.setToDefault(); + defaultConf.setGlobally(el::ConfigurationType::Format, + "%level %datetime{%H:%m:%s:%g} <%thread> %fbase[%line] --> %msg"); + + // el::Loggers::addFlag(el::LoggingFlag::ColoredTerminalOutput); + el::Loggers::reconfigureLogger("default", defaultConf); +} + +TEST(beerocks_socket_event_loop, simple_timeout) +{ + SocketEventLoop loop(s_test_timeout); + StrictMock timeout; + + // Disable the on_write handler (to prevent the loop from firing "write ready" events) + timeout.on_write = nullptr; + + // Create a dummy socket for checking the timeout mechanism + auto timeout_socket = std::make_shared(socket(AF_UNIX, SOCK_DGRAM, 0)); + ASSERT_TRUE(timeout_socket && timeout_socket->getSocketFd() != -1); + + { + InSequence sequence; + + // Socket timeout handler + EXPECT_CALL(timeout, handle_timeout(timeout_socket, &loop)) + .WillOnce(Invoke([](EventType socket, LoopType *loop) -> bool { + loop->die(); + return true; + })); + }; + + // Add the dummy socket into the event loop + ASSERT_TRUE(loop.add_event(timeout_socket, timeout, std::chrono::milliseconds{1})); + + // Execute the event loop + ASSERT_GE(loop.run(), 0); + + // Remove the socket from the event loop + ASSERT_TRUE(loop.del_event(timeout_socket)); + close(timeout_socket->getSocketFd()); +} + +TEST(beerocks_socket_event_loop, repeated_timeout) +{ + SocketEventLoop loop(s_test_timeout); + StrictMock timeout; + + // Disable the on_write handler (to prevent the loop from firing "write ready" events) + timeout.on_write = nullptr; + + // Create a dummy socket for checking the timeout mechanism + auto timeout_socket = std::make_shared(socket(AF_UNIX, SOCK_DGRAM, 0)); + ASSERT_NE(timeout_socket, nullptr); + + // Timeout event counter + int timeout_seq = 0; + + { + InSequence sequence; + + // Expect the timeout handler to be executed exactly 3 times + EXPECT_CALL(timeout, handle_timeout(timeout_socket, &loop)).Times(3); + + ON_CALL(timeout, handle_timeout(timeout_socket, &loop)) + .WillByDefault([&](EventType socket, LoopType *loop) -> bool { + if (++timeout_seq == 3) { + loop->die(); + } + return true; + }); + }; + + // Add the dummy socket into the event loop + ASSERT_TRUE(loop.add_event(timeout_socket, timeout, std::chrono::milliseconds{1})); + + // Execute the event loop + ASSERT_GE(loop.run(), 0); + + // Remove the socket from the event loop + ASSERT_TRUE(loop.del_event(timeout_socket)); + close(timeout_socket->getSocketFd()); +} + +TEST(beerocks_socket_event_loop, simple_read_write) +{ + SocketEventLoop loop(s_test_timeout); + StrictMock reader; + StrictMock writer; + + // Disable the on_write handler (to prevent the loop from firing "write ready" events) + reader.on_write = nullptr; + + // Create a socketpair for reader/writer simulation + int sv[2]; + int rc = socketpair(AF_UNIX, SOCK_STREAM, 0, sv); + ASSERT_NE(-1, rc); + + auto writer_socket = std::make_shared(sv[0]); + auto reader_socket = std::make_shared(sv[1]); + + ASSERT_NE(writer_socket, nullptr); + ASSERT_NE(reader_socket, nullptr); + + { + InSequence sequence; + + EXPECT_CALL(writer, handle_write(writer_socket, &loop)) + .WillOnce(Invoke([](EventType socket, LoopType *loop) -> bool { + // Send a dummy byte and remove the socket from the loop to prevent additional timeouts + EXPECT_EQ(1, send(socket->getSocketFd(), "X", 1, 0)); + EXPECT_TRUE(loop->del_event(socket)); + return true; + })); + + EXPECT_CALL(reader, handle_read(reader_socket, &loop)) + .WillOnce(Invoke([](EventType socket, LoopType *loop) -> bool { + char dummy; + EXPECT_EQ(1, read(socket->getSocketFd(), &dummy, 1)); + loop->die(); + return true; + })); + }; + + // Add the reader/writer sockets and handlers to the loop + ASSERT_TRUE(loop.add_event(writer_socket, writer, std::chrono::milliseconds{1})); + ASSERT_TRUE(loop.add_event(reader_socket, reader)); + + // Run the loop + ASSERT_GE(loop.run(), 0); + + // Delete the reader socket + ASSERT_TRUE(loop.del_event(reader_socket)); + + // Close the file descriptors + close(sv[0]); + close(sv[1]); +} From 5a42705f106124d5263c0e49d8e2d60c185eeeca Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Sun, 21 Jun 2020 14:12:06 +0000 Subject: [PATCH 077/453] cppcheck: inline suppression and issues update Add a flag to cppcheck for enabling inline suppression. Update the list of known cppcheck issues. Signed-off-by: Vitaly Bukhovsky --- ci/cppcheck/cppcheck_existing_issues.txt | 4 +++- tools/docker/static-analysis/cppcheck.sh | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ci/cppcheck/cppcheck_existing_issues.txt b/ci/cppcheck/cppcheck_existing_issues.txt index 4c38b9d649..c4d23407ac 100644 --- a/ci/cppcheck/cppcheck_existing_issues.txt +++ b/ci/cppcheck/cppcheck_existing_issues.txt @@ -1,4 +1,6 @@ agent/src/beerocks/fronthaul_manager/monitor/monitor_rssi.cpp: style: Local variable 'sta_vap_id' shadows outer variable [shadowVariable] auto sta_vap_id = sta_node->get_vap_id(); +agent/src/beerocks/fronthaul_manager/monitor/monitor_rssi.cpp: style: Parameter 'sta_mac' can be declared with const [constParameter]void monitor_rssi::monitor_idle_station(std::string &sta_mac, monitor_sta_node *sta_node) +agent/src/beerocks/fronthaul_manager/monitor/monitor_rssi.cpp: style: Parameter 'sta_mac' can be declared with const [constParameter]void monitor_rssi::send_rssi_measurement_response(std::string &sta_mac, monitor_sta_node *sta_node) agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp: style: Local variable 'time_span' shadows outer variable [shadowVariable] auto time_span = agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp: style: The if condition is the same as the previous if condition [duplicateCondition] if (poll_last) { agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp: style: Variable 'id' is assigned a value that is never used. [unreadVariable] int id = 0; @@ -19,7 +21,6 @@ agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp: warning: agent/src/beerocks/slave/son_slave_thread.cpp: style: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm] if (channel_to_check == ch.channel) { agent/src/beerocks/slave/son_slave_thread.cpp: style: Local variable 'notification' shadows outer variable [shadowVariable] auto notification = message_com::create_vs_message< common/beerocks/bcl/include/bcl/beerocks_logging.h: style: Class 'logging' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] logging(const std::string &module_name, const std::string &config_path = std::string(), -common/beerocks/bcl/include/bcl/network/socket.h: style: Statements following return, break, continue, goto or throw will never be executed. [unreachableCode] m_error.clear(); common/beerocks/bcl/source/beerocks_logging.cpp: style: Consider using std::accumulate algorithm instead of a raw loop. [useStlAlgorithm] str += elt + ", "; common/beerocks/bcl/source/beerocks_logging.cpp: style: The class 'NetLogger' does not have a constructor although it has private member variables. [noConstructor]class NetLogger : public el::LogDispatchCallback { common/beerocks/bcl/source/beerocks_ucc_listener.cpp: style: Consider using std::find_if algorithm instead of a raw loop. [useStlAlgorithm] validate_binary_notation(value) || validate_decimal_notation(value))) { @@ -106,6 +107,7 @@ controller/src/beerocks/master/db/network_map.cpp: style: Variable 'size' is ass controller/src/beerocks/master/db/network_map.cpp: style: Variable 'size' is assigned a value that is never used. [unreadVariable] event->data = GET_MESSAGE_POINTER(BML_EVENT_CLIENT_DISALLOW_REQ, response->buffer(0), size); controller/src/beerocks/master/db/network_map.cpp: style: Variable 'size' is assigned a value that is never used. [unreadVariable] event->data = GET_MESSAGE_POINTER(BML_EVENT_CSA_NOTIFICATION, response->buffer(0), size); controller/src/beerocks/master/son_actions.cpp: performance: Function parameter 'bssid' should be passed by const reference. [passedByValue] std::string sta_mac, std::string bssid) +controller/src/beerocks/master/son_actions.cpp: performance: Function parameter 'hostap_mac' should be passed by const reference. [passedByValue]void son_actions::handle_dead_node(std::string mac, std::string hostap_mac, db &database, controller/src/beerocks/master/son_actions.cpp: performance: Function parameter 'sta_mac' should be passed by const reference. [passedByValue] std::string sta_mac, std::string bssid) controller/src/beerocks/master/son_actions.cpp: style: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm] if (operating_class == operating_class_info.operating_class()) { controller/src/beerocks/master/son_actions.cpp: style: Local variable 'prev_task_id' shadows outer variable [shadowVariable] int prev_task_id = database.get_association_handling_task_id(mac); diff --git a/tools/docker/static-analysis/cppcheck.sh b/tools/docker/static-analysis/cppcheck.sh index 0f4a282beb..bb737b9054 100755 --- a/tools/docker/static-analysis/cppcheck.sh +++ b/tools/docker/static-analysis/cppcheck.sh @@ -24,6 +24,7 @@ run_cppcheck() { -i"$rootdir/common/beerocks/bwl/unit_tests" \ -i"$rootdir/common/beerocks/bcl/unit_tests" \ -i"$rootdir/build" \ + --inline-suppr \ --suppressions-list="$rootdir"/tools/docker/static-analysis/suppressions.txt \ -rp="$rootdir" \ -j"$(nproc)" \ From 40cf8683e92e6d7336d5f5c5a917b0c4f1a3d398 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Fri, 26 Jun 2020 18:00:05 +0000 Subject: [PATCH 078/453] vscode: update settings.json Automaically add new line on save. Resolve gtest/gmock include files. Signed-off-by: Vitaly Bukhovsky --- .vscode/settings.json | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 73a6ed1256..557264d22d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -58,11 +58,14 @@ "streambuf": "cpp", "thread": "cpp", "cinttypes": "cpp", - "typeinfo": "cpp" + "typeinfo": "cpp", + "future": "cpp" }, "files.exclude": { "build": true }, + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true, "editor.formatOnSave": true, "C_Cpp.default.defines": [ "BEEROCKS_LINUX", @@ -79,7 +82,9 @@ "${workspaceFolder}/agent/**", "${workspaceFolder}/common/**", "${workspaceFolder}/framework/**", - "${workspaceFolder}/controller/**" + "${workspaceFolder}/controller/**", + "${workspaceFolder}/build/googletest-src/googletest/include", + "${workspaceFolder}/build/googletest-src/googlemock/include" ], "python.linting.flake8Enabled": true, "cSpell.words": [ @@ -100,4 +105,4 @@ "fronthaul" ], "git.alwaysSignOff": true -} \ No newline at end of file +} From fe6fb80c2844b51af05ab877bd45d69593290ebd Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Mon, 22 Jun 2020 15:10:13 +0300 Subject: [PATCH 079/453] hotfix! Change bssid type for roam() method All bssid which passes as method parameters should be with type sMacAddr instead string. roam() method will be used in the Backhaul STA Steering impelemntation. That activity triggered to do hotfix for the bssid type. Also fixed roam() call in the backhaul manager: tranformed give argument from string to the sMacAddr structure. Signed-off-by: Vladyslav Tupikin --- .../slave/backhaul_manager/backhaul_manager_thread.cpp | 2 +- common/beerocks/bwl/dummy/sta_wlan_hal_dummy.cpp | 2 +- common/beerocks/bwl/dummy/sta_wlan_hal_dummy.h | 2 +- common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp | 8 +++++--- common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.h | 2 +- common/beerocks/bwl/include/bwl/sta_wlan_hal.h | 2 +- common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp | 2 +- common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h | 2 +- 8 files changed, 12 insertions(+), 10 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index acb47ea258..45f6ab875a 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -1537,7 +1537,7 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) if (roam_flag) { selected_bssid = roam_selected_bssid; selected_bssid_channel = roam_selected_bssid_channel; - if (!active_hal->roam(selected_bssid, selected_bssid_channel)) { + if (!active_hal->roam(tlvf::mac_from_string(selected_bssid), selected_bssid_channel)) { platform_notify_error(bpl::eErrorCode::BH_ROAMING, "BSSID='" + selected_bssid + "'"); stop_on_failure_attempts--; diff --git a/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.cpp b/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.cpp index e9abec433e..fa9edadad2 100644 --- a/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.cpp +++ b/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.cpp @@ -43,7 +43,7 @@ bool sta_wlan_hal_dummy::connect(const std::string &ssid, const std::string &pas bool sta_wlan_hal_dummy::disconnect() { return true; } -bool sta_wlan_hal_dummy::roam(const std::string &bssid, uint8_t channel) { return true; } +bool sta_wlan_hal_dummy::roam(const sMacAddr &bssid, uint8_t channel) { return true; } bool sta_wlan_hal_dummy::get_4addr_mode() { return true; } diff --git a/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.h b/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.h index d1cfe9c2a8..8af18e02d6 100644 --- a/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.h +++ b/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.h @@ -43,7 +43,7 @@ class sta_wlan_hal_dummy : public base_wlan_hal_dummy, public sta_wlan_hal { virtual bool disconnect() override; - virtual bool roam(const std::string &bssid, uint8_t channel) override; + virtual bool roam(const sMacAddr &bssid, uint8_t channel) override; virtual bool get_4addr_mode() override; virtual bool set_4addr_mode(bool enable) override; diff --git a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp index bbd4ce10b3..69b371967e 100644 --- a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp @@ -288,7 +288,7 @@ bool sta_wlan_hal_dwpal::disconnect() return true; } -bool sta_wlan_hal_dwpal::roam(const std::string &bssid, uint8_t channel) +bool sta_wlan_hal_dwpal::roam(const sMacAddr &bssid, uint8_t channel) { if (m_active_network_id == -1) { LOG(ERROR) << "Incorrect active network " << m_active_network_id; @@ -300,7 +300,9 @@ bool sta_wlan_hal_dwpal::roam(const std::string &bssid, uint8_t channel) return false; } - const std::string cmd = "ROAM " + bssid; + auto bssid_str = tlvf::mac_to_string(bssid); + + const std::string cmd = "ROAM " + bssid_str; if (!dwpal_send_cmd(cmd)) { LOG(ERROR) << get_iface_name() << " ROAM failed!"; return false; @@ -313,7 +315,7 @@ bool sta_wlan_hal_dwpal::roam(const std::string &bssid, uint8_t channel) } // Update the active channel and bssid - m_active_bssid.assign(bssid); + m_active_bssid.assign(bssid_str); m_active_channel = channel; return false; diff --git a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.h b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.h index ea8515d357..6c8b1cb94a 100644 --- a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.h +++ b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.h @@ -41,7 +41,7 @@ class sta_wlan_hal_dwpal : public base_wlan_hal_dwpal, public sta_wlan_hal { virtual bool disconnect() override; - virtual bool roam(const std::string &bssid, uint8_t channel) override; + virtual bool roam(const sMacAddr &bssid, uint8_t channel) override; virtual bool get_4addr_mode() override; virtual bool set_4addr_mode(bool enable) override; diff --git a/common/beerocks/bwl/include/bwl/sta_wlan_hal.h b/common/beerocks/bwl/include/bwl/sta_wlan_hal.h index 460412339b..4d70688bf5 100644 --- a/common/beerocks/bwl/include/bwl/sta_wlan_hal.h +++ b/common/beerocks/bwl/include/bwl/sta_wlan_hal.h @@ -50,7 +50,7 @@ class sta_wlan_hal : public virtual base_wlan_hal { virtual bool disconnect() = 0; - virtual bool roam(const std::string &bssid, uint8_t channel) = 0; + virtual bool roam(const sMacAddr &bssid, uint8_t channel) = 0; virtual bool get_4addr_mode() = 0; virtual bool set_4addr_mode(bool enable) = 0; diff --git a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp index 29294b7251..a58002bf39 100644 --- a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp +++ b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp @@ -42,7 +42,7 @@ bool sta_wlan_hal_nl80211::connect(const std::string &ssid, const std::string &p bool sta_wlan_hal_nl80211::disconnect() { return true; } -bool sta_wlan_hal_nl80211::roam(const std::string &bssid, uint8_t channel) { return true; } +bool sta_wlan_hal_nl80211::roam(const sMacAddr &bssid, uint8_t channel) { return true; } bool sta_wlan_hal_nl80211::get_4addr_mode() { return true; } diff --git a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h index 147a608cde..96495e0836 100644 --- a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h +++ b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h @@ -43,7 +43,7 @@ class sta_wlan_hal_nl80211 : public base_wlan_hal_nl80211, public sta_wlan_hal { virtual bool disconnect() override; - virtual bool roam(const std::string &bssid, uint8_t channel) override; + virtual bool roam(const sMacAddr &bssid, uint8_t channel) override; virtual bool get_4addr_mode() override; virtual bool set_4addr_mode(bool enable) override; From ea1033d39ef216c3a0d160ce09c6fbf5456a292b Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Sun, 28 Jun 2020 12:26:18 +0000 Subject: [PATCH 080/453] bcl: copy copy_string() from mapf::common BCL depends on mapf::common for one function only: copy_string Copy the implementation from mapf::common::utils to beerocks::string_utils Signed-off-by: Vitaly Bukhovsky --- .../bcl/include/bcl/beerocks_string_utils.h | 2 ++ .../beerocks/bcl/source/beerocks_string_utils.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/common/beerocks/bcl/include/bcl/beerocks_string_utils.h b/common/beerocks/bcl/include/bcl/beerocks_string_utils.h index feba2113b5..b06954427d 100644 --- a/common/beerocks/bcl/include/bcl/beerocks_string_utils.h +++ b/common/beerocks/bcl/include/bcl/beerocks_string_utils.h @@ -83,6 +83,8 @@ class string_utils { static std::string int_to_hex_string(const unsigned int integer, const uint8_t number_of_digits); + + static void copy_string(char *dst, const char *src, size_t dst_len); }; } // namespace beerocks diff --git a/common/beerocks/bcl/source/beerocks_string_utils.cpp b/common/beerocks/bcl/source/beerocks_string_utils.cpp index 76afc6b51c..a3bbcad9da 100644 --- a/common/beerocks/bcl/source/beerocks_string_utils.cpp +++ b/common/beerocks/bcl/source/beerocks_string_utils.cpp @@ -133,3 +133,18 @@ std::string string_utils::int_to_hex_string(const unsigned int integer, return ss_hex_string.str(); }; + +void string_utils::copy_string(char *dst, const char *src, size_t dst_len) +{ + const char *src_end = std::find(src, src + dst_len, '\0'); + std::copy(src, src_end, dst); + std::ptrdiff_t src_size = src_end - src; + std::ptrdiff_t dst_size = dst_len; + if (src_size < dst_size) { + dst[src_size] = 0; + } else { + dst[dst_size - 1] = 0; + LOG(ERROR) << "copy_string() overflow, src string:'" << src << "'" + << " dst_size=" << dst_size; + } +} From 4946b303f5d00bf608104dcb800c95bf6b56d0ef Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Sun, 28 Jun 2020 12:30:58 +0000 Subject: [PATCH 081/453] treewide: use copy_string from string_utils Signed-off-by: Vitaly Bukhovsky --- .../ap_manager/ap_manager_thread.cpp | 19 ++--- .../monitor/monitor_thread.cpp | 4 +- .../backhaul_manager_thread.cpp | 3 +- .../slave/gate/1905_beacon_query_to_vs.cpp | 6 +- .../platform_manager_thread.cpp | 36 +++++----- agent/src/beerocks/slave/son_slave_thread.cpp | 71 ++++++++++--------- .../beerocks/bcl/include/bcl/beerocks_utils.h | 2 - .../bcl/source/network/network_utils.cpp | 25 ++++--- common/beerocks/bcl/source/network/socket.cpp | 5 +- common/beerocks/btl/btl_local_bus.cpp | 8 +-- controller/src/beerocks/bml/bml.cpp | 8 +-- controller/src/beerocks/bml/bml_utils.cpp | 9 +-- .../beerocks/bml/internal/bml_internal.cpp | 51 ++++++------- .../src/beerocks/cli/beerocks_cli_bml.cpp | 2 +- .../src/beerocks/cli/beerocks_cli_main.cpp | 3 +- .../src/beerocks/cli/beerocks_cli_socket.cpp | 4 +- .../src/beerocks/master/db/network_map.cpp | 20 +++--- .../src/beerocks/master/son_management.cpp | 4 +- .../src/beerocks/master/son_master_thread.cpp | 12 ++-- .../tasks/association_handling_task.cpp | 2 +- 20 files changed, 148 insertions(+), 146 deletions(-) diff --git a/agent/src/beerocks/fronthaul_manager/ap_manager/ap_manager_thread.cpp b/agent/src/beerocks/fronthaul_manager/ap_manager/ap_manager_thread.cpp index 5c3f29d55b..0784487634 100644 --- a/agent/src/beerocks/fronthaul_manager/ap_manager/ap_manager_thread.cpp +++ b/agent/src/beerocks/fronthaul_manager/ap_manager/ap_manager_thread.cpp @@ -8,6 +8,7 @@ #include "ap_manager_thread.h" +#include #include #include #include @@ -78,8 +79,8 @@ static void copy_vaps_info(std::shared_ptr &ap_wlan_hal, // Copy the VAP MAC and SSID vaps[i].mac = tlvf::mac_from_string(curr_vap.mac); - mapf::utils::copy_string(vaps[i].ssid, curr_vap.ssid.c_str(), - beerocks::message::WIFI_SSID_MAX_LENGTH); + beerocks::string_utils::copy_string(vaps[i].ssid, curr_vap.ssid.c_str(), + beerocks::message::WIFI_SSID_MAX_LENGTH); } } } @@ -1477,11 +1478,11 @@ void ap_manager_thread::handle_hostapd_attached() return; } - mapf::utils::copy_string(notification->params().iface_name, - ap_wlan_hal->get_iface_name().c_str(), message::IFACE_NAME_LENGTH); - mapf::utils::copy_string(notification->params().driver_version, - ap_wlan_hal->get_radio_driver_version().c_str(), - message::WIFI_DRIVER_VER_LENGTH); + string_utils::copy_string(notification->params().iface_name, + ap_wlan_hal->get_iface_name().c_str(), message::IFACE_NAME_LENGTH); + string_utils::copy_string(notification->params().driver_version, + ap_wlan_hal->get_radio_driver_version().c_str(), + message::WIFI_DRIVER_VER_LENGTH); notification->params().iface_type = uint8_t(ap_wlan_hal->get_iface_type()); notification->params().iface_mac = tlvf::mac_from_string(ap_wlan_hal->get_radio_mac()); @@ -1632,8 +1633,8 @@ bool ap_manager_thread::handle_ap_enabled(int vap_id) // Copy the VAP MAC and SSID notification->vap_info().mac = tlvf::mac_from_string(vap_info.mac); - mapf::utils::copy_string(notification->vap_info().ssid, vap_info.ssid.c_str(), - beerocks::message::WIFI_SSID_MAX_LENGTH); + string_utils::copy_string(notification->vap_info().ssid, vap_info.ssid.c_str(), + beerocks::message::WIFI_SSID_MAX_LENGTH); notification->vap_info().backhaul_vap = vap_info.backhaul; message_com::send_cmdu(slave_socket, cmdu_tx); diff --git a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp index 0e81470aee..b7c870c8cf 100644 --- a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp +++ b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp @@ -1870,8 +1870,8 @@ bool monitor_thread::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t event auto &out_result = notification->scan_results(); // Arrays - mapf::utils::copy_string(out_result.ssid, in_result.ssid, - beerocks::message::WIFI_SSID_MAX_LENGTH); + string_utils::copy_string(out_result.ssid, in_result.ssid, + beerocks::message::WIFI_SSID_MAX_LENGTH); std::copy_n(in_result.bssid.oct, sizeof(out_result.bssid.oct), out_result.bssid.oct); std::copy(in_result.basic_data_transfer_rates_kbps.begin(), in_result.basic_data_transfer_rates_kbps.end(), diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 45f6ab875a..dd492d3cab 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -456,7 +456,8 @@ void backhaul_manager::platform_notify_error(bpl::eErrorCode code, const std::st error->code() = uint32_t(code); - mapf::utils::copy_string(error->data(0), error_data.c_str(), message::PLATFORM_ERROR_DATA_SIZE); + string_utils::copy_string(error->data(0), error_data.c_str(), + message::PLATFORM_ERROR_DATA_SIZE); LOG(ERROR) << "platform_notify_error: " << error_data; diff --git a/agent/src/beerocks/slave/gate/1905_beacon_query_to_vs.cpp b/agent/src/beerocks/slave/gate/1905_beacon_query_to_vs.cpp index 12908ddc97..117e48443b 100644 --- a/agent/src/beerocks/slave/gate/1905_beacon_query_to_vs.cpp +++ b/agent/src/beerocks/slave/gate/1905_beacon_query_to_vs.cpp @@ -1,7 +1,7 @@ #include "1905_beacon_query_to_vs.h" #include -#include +#include namespace beerocks { namespace gate { @@ -49,8 +49,8 @@ bool load(std::shared_ptrssid_str().c_str(), - beerocks::message::WIFI_SSID_MAX_LENGTH); + string_utils::copy_string(lhs_params.ssid, beacon_metrics_query->ssid_str().c_str(), + beerocks::message::WIFI_SSID_MAX_LENGTH); // how many elements in the list of channels, we support only 1 at the moment auto ap_ch_report_length = beacon_metrics_query->ap_channel_reports_list_length(); diff --git a/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp b/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp index f4645edc61..10ea6d30d7 100644 --- a/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp +++ b/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp @@ -430,7 +430,7 @@ void main_thread::send_dhcp_notification(const std::string &op, const std::strin dhcp_notif->mac() = tlvf::mac_from_string(mac); dhcp_notif->ipv4() = network_utils::ipv4_from_string(ip); - mapf::utils::copy_string(dhcp_notif->hostname(0), hostname.c_str(), message::NODE_NAME_LENGTH); + string_utils::copy_string(dhcp_notif->hostname(0), hostname.c_str(), message::NODE_NAME_LENGTH); // Get a slave socket Socket *sd = get_backhaul_socket(); @@ -745,7 +745,7 @@ bool main_thread::handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_rx) response->result() = 1; } - mapf::utils::copy_string(response->params().user_password, pass, message::USER_PASS_LEN); + string_utils::copy_string(response->params().user_password, pass, message::USER_PASS_LEN); // Sent with unsafe because BML is reachable only on platform thread message_com::send_cmdu(sd, cmdu_tx); @@ -764,10 +764,10 @@ bool main_thread::handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_rx) return false; } if (!master_version.empty() && !slave_version.empty()) { - mapf::utils::copy_string(response->versions().master_version, master_version.c_str(), - message::VERSION_LENGTH); - mapf::utils::copy_string(response->versions().slave_version, slave_version.c_str(), - message::VERSION_LENGTH); + string_utils::copy_string(response->versions().master_version, master_version.c_str(), + message::VERSION_LENGTH); + string_utils::copy_string(response->versions().slave_version, slave_version.c_str(), + message::VERSION_LENGTH); response->result() = 1; } else { response->result() = 0; @@ -928,8 +928,8 @@ bool main_thread::handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_rx) } } - mapf::utils::copy_string(msg_ssid, ssid, message::WIFI_SSID_MAX_LENGTH); - mapf::utils::copy_string(msg_pass, pass, message::WIFI_PASS_MAX_LENGTH); + string_utils::copy_string(msg_ssid, ssid, message::WIFI_SSID_MAX_LENGTH); + string_utils::copy_string(msg_pass, pass, message::WIFI_PASS_MAX_LENGTH); //clear the pwd in the memory memset(&pass, 0, sizeof(pass)); @@ -1020,22 +1020,22 @@ bool main_thread::handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_rx) response->result() = 1; } - mapf::utils::copy_string(params.manufacturer, bpl_device_info.manufacturer, - message::DEV_INFO_STR_MAX_LEN); - mapf::utils::copy_string(params.model_name, bpl_device_info.model_name, - message::DEV_INFO_STR_MAX_LEN); - mapf::utils::copy_string(params.serial_number, bpl_device_info.serial_number, - message::DEV_INFO_STR_MAX_LEN); + string_utils::copy_string(params.manufacturer, bpl_device_info.manufacturer, + message::DEV_INFO_STR_MAX_LEN); + string_utils::copy_string(params.model_name, bpl_device_info.model_name, + message::DEV_INFO_STR_MAX_LEN); + string_utils::copy_string(params.serial_number, bpl_device_info.serial_number, + message::DEV_INFO_STR_MAX_LEN); // LAN - mapf::utils::copy_string(params.lan_iface_name, bpl_device_info.lan_iface_name, - message::IFACE_NAME_LENGTH); + string_utils::copy_string(params.lan_iface_name, bpl_device_info.lan_iface_name, + message::IFACE_NAME_LENGTH); params.lan_ip_address = bpl_device_info.lan_ip_address; params.lan_network_mask = bpl_device_info.lan_network_mask; // WAN - mapf::utils::copy_string(params.wan_iface_name, bpl_device_info.wan_iface_name, - message::IFACE_NAME_LENGTH); + string_utils::copy_string(params.wan_iface_name, bpl_device_info.wan_iface_name, + message::IFACE_NAME_LENGTH); params.wan_ip_address = bpl_device_info.wan_ip_address; params.wan_network_mask = bpl_device_info.wan_network_mask; diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 7b31c5e593..6a7a7e761f 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -186,7 +186,8 @@ void slave_thread::platform_notify_error(beerocks::bpl::eErrorCode code, } error->code() = uint32_t(code); - mapf::utils::copy_string(error->data(0), error_data.c_str(), message::PLATFORM_ERROR_DATA_SIZE); + string_utils::copy_string(error->data(0), error_data.c_str(), + message::PLATFORM_ERROR_DATA_SIZE); // Send the message message_com::send_cmdu(platform_manager_socket, cmdu_tx); @@ -867,8 +868,8 @@ bool slave_thread::handle_cmdu_control_message(Socket *sd, if (request_in->params().use_optional_ssid && std::string((char *)request_in->params().ssid).empty()) { //LOG(DEBUG) << "ssid field is empty! using slave ssid -> " << config.ssid; - mapf::utils::copy_string(request_in->params().ssid, platform_settings.front_ssid, - message::WIFI_SSID_MAX_LENGTH); + string_utils::copy_string(request_in->params().ssid, platform_settings.front_ssid, + message::WIFI_SSID_MAX_LENGTH); } auto request_out = message_com::create_vs_message< @@ -1544,9 +1545,9 @@ bool slave_thread::handle_cmdu_platform_manager_message( master_notification->mac() = notification->mac(); master_notification->ipv4() = notification->ipv4(); - mapf::utils::copy_string(master_notification->name(message::NODE_NAME_LENGTH), - notification->hostname(message::NODE_NAME_LENGTH), - message::NODE_NAME_LENGTH); + string_utils::copy_string(master_notification->name(message::NODE_NAME_LENGTH), + notification->hostname(message::NODE_NAME_LENGTH), + message::NODE_NAME_LENGTH); send_cmdu_to_controller(cmdu_tx); } @@ -3134,8 +3135,8 @@ bool slave_thread::slave_fsm(bool &call_slave_select) return false; } - mapf::utils::copy_string(request->iface_name(message::IFACE_NAME_LENGTH), - config.hostap_iface.c_str(), message::IFACE_NAME_LENGTH); + string_utils::copy_string(request->iface_name(message::IFACE_NAME_LENGTH), + config.hostap_iface.c_str(), message::IFACE_NAME_LENGTH); message_com::send_cmdu(platform_manager_socket, cmdu_tx); LOG(TRACE) << "send ACTION_PLATFORM_SON_SLAVE_REGISTER_REQUEST"; @@ -3193,12 +3194,12 @@ bool slave_thread::slave_fsm(bool &call_slave_select) if (platform_settings.local_gw || config.backhaul_wireless_iface.empty()) { memset(request->sta_iface(message::IFACE_NAME_LENGTH), 0, message::IFACE_NAME_LENGTH); } else { - mapf::utils::copy_string(request->sta_iface(message::IFACE_NAME_LENGTH), - config.backhaul_wireless_iface.c_str(), - message::IFACE_NAME_LENGTH); + string_utils::copy_string(request->sta_iface(message::IFACE_NAME_LENGTH), + config.backhaul_wireless_iface.c_str(), + message::IFACE_NAME_LENGTH); } - mapf::utils::copy_string(request->hostap_iface(message::IFACE_NAME_LENGTH), - config.hostap_iface.c_str(), message::IFACE_NAME_LENGTH); + string_utils::copy_string(request->hostap_iface(message::IFACE_NAME_LENGTH), + config.hostap_iface.c_str(), message::IFACE_NAME_LENGTH); request->local_master() = platform_settings.local_master; request->local_gw() = platform_settings.local_gw; @@ -3315,19 +3316,19 @@ bool slave_thread::slave_fsm(bool &call_slave_select) // TODO: On passive mode, mem_only_psk is always be set, so supplying the credentials // to the backhaul manager will no longer be necessary, and therefore should be be // removed completely from beerocks including the BPL. - mapf::utils::copy_string(bh_enable->ssid(message::WIFI_SSID_MAX_LENGTH), - platform_settings.back_ssid, message::WIFI_SSID_MAX_LENGTH); - mapf::utils::copy_string(bh_enable->pass(message::WIFI_PASS_MAX_LENGTH), - platform_settings.back_pass, message::WIFI_PASS_MAX_LENGTH); + string_utils::copy_string(bh_enable->ssid(message::WIFI_SSID_MAX_LENGTH), + platform_settings.back_ssid, message::WIFI_SSID_MAX_LENGTH); + string_utils::copy_string(bh_enable->pass(message::WIFI_PASS_MAX_LENGTH), + platform_settings.back_pass, message::WIFI_PASS_MAX_LENGTH); bh_enable->security_type() = static_cast( platform_to_bwl_security(platform_settings.back_security_type)); bh_enable->mem_only_psk() = platform_settings.mem_only_psk; bh_enable->backhaul_preferred_radio_band() = platform_settings.backhaul_preferred_radio_band; - mapf::utils::copy_string(bh_enable->wire_iface(message::IFACE_NAME_LENGTH), - config.backhaul_wire_iface.c_str(), - message::IFACE_NAME_LENGTH); + string_utils::copy_string(bh_enable->wire_iface(message::IFACE_NAME_LENGTH), + config.backhaul_wire_iface.c_str(), + message::IFACE_NAME_LENGTH); bh_enable->wire_iface_type() = config.backhaul_wire_iface_type; bh_enable->wireless_iface_type() = config.backhaul_wireless_iface_type; @@ -3336,9 +3337,9 @@ bool slave_thread::slave_fsm(bool &call_slave_select) bh_enable->iface_mac() = hostap_params.iface_mac; bh_enable->preferred_bssid() = tlvf::mac_from_string(config.backhaul_preferred_bssid); - mapf::utils::copy_string(bh_enable->sta_iface(message::IFACE_NAME_LENGTH), - config.backhaul_wireless_iface.c_str(), - message::IFACE_NAME_LENGTH); + string_utils::copy_string(bh_enable->sta_iface(message::IFACE_NAME_LENGTH), + config.backhaul_wireless_iface.c_str(), + message::IFACE_NAME_LENGTH); bh_enable->frequency_band() = hostap_params.frequency_band; bh_enable->max_bandwidth() = hostap_params.max_bandwidth; @@ -3517,8 +3518,8 @@ bool slave_thread::slave_fsm(bool &call_slave_select) is_backhual_reconf = false; // Version - mapf::utils::copy_string(notification->slave_version(message::VERSION_LENGTH), - BEEROCKS_VERSION, message::VERSION_LENGTH); + string_utils::copy_string(notification->slave_version(message::VERSION_LENGTH), + BEEROCKS_VERSION, message::VERSION_LENGTH); // Platform Configuration notification->low_pass_filter_on() = config.backhaul_wireless_iface_filter_low; @@ -4237,10 +4238,10 @@ bool slave_thread::parse_intel_join_response(Socket *sd, beerocks::beerocks_head return false; } - mapf::utils::copy_string(notification->versions().master_version, master_version.c_str(), - sizeof(beerocks_message::sVersions::master_version)); - mapf::utils::copy_string(notification->versions().slave_version, BEEROCKS_VERSION, - sizeof(beerocks_message::sVersions::slave_version)); + string_utils::copy_string(notification->versions().master_version, master_version.c_str(), + sizeof(beerocks_message::sVersions::master_version)); + string_utils::copy_string(notification->versions().slave_version, BEEROCKS_VERSION, + sizeof(beerocks_message::sVersions::slave_version)); message_com::send_cmdu(platform_manager_socket, cmdu_tx); } @@ -4262,10 +4263,10 @@ bool slave_thread::parse_intel_join_response(Socket *sd, beerocks::beerocks_head LOG(ERROR) << "Failed building message!"; return false; } - mapf::utils::copy_string(notification->versions().master_version, master_version.c_str(), - sizeof(beerocks_message::sVersions::master_version)); - mapf::utils::copy_string(notification->versions().slave_version, BEEROCKS_VERSION, - sizeof(beerocks_message::sVersions::slave_version)); + string_utils::copy_string(notification->versions().master_version, master_version.c_str(), + sizeof(beerocks_message::sVersions::master_version)); + string_utils::copy_string(notification->versions().slave_version, BEEROCKS_VERSION, + sizeof(beerocks_message::sVersions::slave_version)); message_com::send_cmdu(platform_manager_socket, cmdu_tx); LOG(DEBUG) << "send ACTION_PLATFORM_MASTER_SLAVE_VERSIONS_NOTIFICATION"; @@ -4298,9 +4299,9 @@ bool slave_thread::parse_non_intel_join_response(Socket *sd) // LOG(ERROR) << "Failed building message!"; // return false; // } - // mapf::utils::copy_string(notification->versions().master_version, master_version.c_str(), + // string_utils::copy_string(notification->versions().master_version, master_version.c_str(), // sizeof(beerocks_message::sVersions::master_version)); - // mapf::utils::copy_string(notification->versions().slave_version, BEEROCKS_VERSION, + // string_utils::copy_string(notification->versions().slave_version, BEEROCKS_VERSION, // sizeof(beerocks_message::sVersions::slave_version)); // message_com::send_cmdu(platform_manager_socket, cmdu_tx); // LOG(DEBUG) << "send ACTION_PLATFORM_MASTER_SLAVE_VERSIONS_NOTIFICATION"; diff --git a/common/beerocks/bcl/include/bcl/beerocks_utils.h b/common/beerocks/bcl/include/bcl/beerocks_utils.h index 4a73127b60..783aad376d 100644 --- a/common/beerocks/bcl/include/bcl/beerocks_utils.h +++ b/common/beerocks/bcl/include/bcl/beerocks_utils.h @@ -9,8 +9,6 @@ #ifndef _BEEROCKS_UTILS_H_ #define _BEEROCKS_UTILS_H_ -#include - #include "beerocks_defines.h" #include "beerocks_string_utils.h" diff --git a/common/beerocks/bcl/source/network/network_utils.cpp b/common/beerocks/bcl/source/network/network_utils.cpp index 4d8050da8d..08cbcb3b91 100644 --- a/common/beerocks/bcl/source/network/network_utils.cpp +++ b/common/beerocks/bcl/source/network/network_utils.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -60,7 +59,7 @@ static int read_iface_flags(const std::string &strIface, struct ifreq &if_req) return errno; // Read the interface flags - mapf::utils::copy_string(if_req.ifr_name, strIface.c_str(), sizeof(if_req.ifr_name)); + beerocks::string_utils::copy_string(if_req.ifr_name, strIface.c_str(), sizeof(if_req.ifr_name)); int rv = ioctl(socId, SIOCGIFFLAGS, &if_req); close(socId); @@ -225,7 +224,7 @@ bool network_utils::get_raw_iface_info(const std::string &iface_name, raw_iface_ // MAC Address ifr = {}; - mapf::utils::copy_string(ifr.ifr_name, iface_name.c_str(), IF_NAMESIZE); + string_utils::copy_string(ifr.ifr_name, iface_name.c_str(), IF_NAMESIZE); if ((ioctl(fd, SIOCGIFHWADDR, &ifr)) == -1) { LOG(ERROR) << "ioctl failed: " << strerror(errno); close(fd); @@ -235,7 +234,7 @@ bool network_utils::get_raw_iface_info(const std::string &iface_name, raw_iface_ // IP Address ifr = {}; - mapf::utils::copy_string(ifr.ifr_name, iface_name.c_str(), IF_NAMESIZE); + string_utils::copy_string(ifr.ifr_name, iface_name.c_str(), IF_NAMESIZE); if ((ioctl(fd, SIOCGIFADDR, &ifr)) == -1) { LOG(ERROR) << "ioctl failed: " << strerror(errno); close(fd); @@ -245,7 +244,7 @@ bool network_utils::get_raw_iface_info(const std::string &iface_name, raw_iface_ // Network Mask ifr = {}; - mapf::utils::copy_string(ifr.ifr_name, iface_name.c_str(), IF_NAMESIZE); + string_utils::copy_string(ifr.ifr_name, iface_name.c_str(), IF_NAMESIZE); if ((ioctl(fd, SIOCGIFNETMASK, &ifr)) == -1) { LOG(ERROR) << "ioctl failed: " << strerror(errno); close(fd); @@ -255,7 +254,7 @@ bool network_utils::get_raw_iface_info(const std::string &iface_name, raw_iface_ // Broadcast Address ifr = {}; - mapf::utils::copy_string(ifr.ifr_name, iface_name.c_str(), IF_NAMESIZE); + string_utils::copy_string(ifr.ifr_name, iface_name.c_str(), IF_NAMESIZE); if ((ioctl(fd, SIOCGIFBRDADDR, &ifr)) == -1) { LOG(ERROR) << "ioctl failed: " << strerror(errno); close(fd); @@ -563,7 +562,7 @@ bool network_utils::linux_add_iface_to_bridge(const std::string &bridge, const s return false; } - mapf::utils::copy_string(ifr.ifr_name, bridge.c_str(), IFNAMSIZ); + string_utils::copy_string(ifr.ifr_name, bridge.c_str(), IFNAMSIZ); #ifdef SIOCBRADDIF ifr.ifr_ifindex = ifindex; err = ioctl(br_socket_fd, SIOCBRADDIF, &ifr); @@ -607,7 +606,7 @@ bool network_utils::linux_remove_iface_from_bridge(const std::string &bridge, return false; } - mapf::utils::copy_string(ifr.ifr_name, bridge.c_str(), IFNAMSIZ); + string_utils::copy_string(ifr.ifr_name, bridge.c_str(), IFNAMSIZ); #ifdef SIOCBRDELIF ifr.ifr_ifindex = ifindex; err = ioctl(br_socket_fd, SIOCBRDELIF, &ifr); @@ -654,7 +653,7 @@ bool network_utils::linux_iface_ctrl(const std::string &iface, bool up, std::str return false; } - mapf::utils::copy_string(ifr.ifr_name, iface.c_str(), IFNAMSIZ); + string_utils::copy_string(ifr.ifr_name, iface.c_str(), IFNAMSIZ); while (up) { ifr.ifr_addr.sa_family = AF_INET; if (!ip.empty()) { @@ -722,7 +721,7 @@ bool network_utils::linux_iface_get_mac(const std::string &iface, std::string &m } ifr.ifr_addr.sa_family = AF_INET; - mapf::utils::copy_string(ifr.ifr_name, iface.c_str(), IFNAMSIZ); + string_utils::copy_string(ifr.ifr_name, iface.c_str(), IFNAMSIZ); if (ioctl(fd, SIOCGIFHWADDR, &ifr) == -1) { LOG(ERROR) << "SIOCGIFHWADDR"; close(fd); @@ -769,7 +768,7 @@ bool network_utils::linux_iface_get_ip(const std::string &iface, std::string &ip } ifr.ifr_addr.sa_family = AF_INET; - mapf::utils::copy_string(ifr.ifr_name, iface.c_str(), IFNAMSIZ); + string_utils::copy_string(ifr.ifr_name, iface.c_str(), IFNAMSIZ); if (ioctl(fd, SIOCGIFADDR, &ifr) == -1) { LOG(ERROR) << "SIOCGIFADDR"; @@ -871,7 +870,7 @@ bool network_utils::linux_iface_get_speed(const std::string &iface, uint32_t &sp } ecmd; int rc; - mapf::utils::copy_string(ifr.ifr_name, iface.c_str(), sizeof(ifr.ifr_name)); + string_utils::copy_string(ifr.ifr_name, iface.c_str(), sizeof(ifr.ifr_name)); ifr.ifr_data = reinterpret_cast(&ecmd); /* Handshake with kernel to determine number of words for link @@ -1010,7 +1009,7 @@ std::vector network_utils::get_ip_list() ip_info.iface = std::string(rtInfo->ifName); ifr.ifr_addr.sa_family = AF_INET; - mapf::utils::copy_string(ifr.ifr_name, rtInfo->ifName, IFNAMSIZ); + string_utils::copy_string(ifr.ifr_name, rtInfo->ifName, IFNAMSIZ); if (ioctl(fd, SIOCGIFADDR, &ifr) == -1) { continue; // skip, if can't read ip diff --git a/common/beerocks/bcl/source/network/socket.cpp b/common/beerocks/bcl/source/network/socket.cpp index 64f65c4763..04dbc9bf14 100644 --- a/common/beerocks/bcl/source/network/socket.cpp +++ b/common/beerocks/bcl/source/network/socket.cpp @@ -22,7 +22,6 @@ typedef int socklen_t; #include #include -#include #define closesocket close #define ioctlsocket ioctl @@ -248,7 +247,7 @@ SocketServer::SocketServer(const std::string &uds_path, int connections, SocketM memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; - mapf::utils::copy_string(addr.sun_path, uds_path.c_str(), sizeof(addr.sun_path)); + beerocks::string_utils::copy_string(addr.sun_path, uds_path.c_str(), sizeof(addr.sun_path)); if (mode == SocketModeNonBlocking) { u_long arg = 1; @@ -357,7 +356,7 @@ SocketClient::SocketClient(const std::string &uds_path, long readTimeout) struct sockaddr_un addr; memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; - mapf::utils::copy_string(addr.sun_path, uds_path.c_str(), sizeof(addr.sun_path)); + beerocks::string_utils::copy_string(addr.sun_path, uds_path.c_str(), sizeof(addr.sun_path)); if (::connect(m_socket, (sockaddr *)&addr, sizeof(addr))) { m_error = "connect() to " + uds_path + " failed: " + strerror(errno); diff --git a/common/beerocks/btl/btl_local_bus.cpp b/common/beerocks/btl/btl_local_bus.cpp index 6ef31c595b..5a3e7bb33c 100644 --- a/common/beerocks/btl/btl_local_bus.cpp +++ b/common/beerocks/btl/btl_local_bus.cpp @@ -111,17 +111,17 @@ bool transport_socket_thread::configure_ieee1905_transport_interfaces( using Flags = mapf::InterfaceConfigurationRequestMessage::Flags; uint32_t n = 0; - mapf::utils::copy_string(interface_configuration_request_msg.metadata()->interfaces[n].ifname, - bridge_iface.c_str(), IF_NAMESIZE); + string_utils::copy_string(interface_configuration_request_msg.metadata()->interfaces[n].ifname, + bridge_iface.c_str(), IF_NAMESIZE); interface_configuration_request_msg.metadata()->interfaces[n].flags |= Flags::IS_BRIDGE; n++; THREAD_LOG(DEBUG) << "adding bridge " << bridge_iface << " to ieee1905 transport, bridge iface=" << bridge_iface; for (const auto &iface : ifaces) { - mapf::utils::copy_string( + string_utils::copy_string( interface_configuration_request_msg.metadata()->interfaces[n].ifname, iface.c_str(), IF_NAMESIZE); - mapf::utils::copy_string( + string_utils::copy_string( interface_configuration_request_msg.metadata()->interfaces[n].bridge_ifname, bridge_iface.c_str(), IF_NAMESIZE); interface_configuration_request_msg.metadata()->interfaces[n].flags |= diff --git a/controller/src/beerocks/bml/bml.cpp b/controller/src/beerocks/bml/bml.cpp index 096810bdea..303357f430 100644 --- a/controller/src/beerocks/bml/bml.cpp +++ b/controller/src/beerocks/bml/bml.cpp @@ -9,9 +9,9 @@ #include "bml.h" #include "internal/bml_internal.h" +#include #include #include -#include #include @@ -319,7 +319,7 @@ int bml_get_serial_number(BML_CTX ctx, char *serial_number) } // Copy only the serial number - mapf::utils::copy_string(serial_number, device_info.serial_number, BML_DEV_INFO_LEN); + beerocks::string_utils::copy_string(serial_number, device_info.serial_number, BML_DEV_INFO_LEN); return 0; } @@ -540,8 +540,8 @@ int bml_get_master_slave_versions(BML_CTX ctx, char *master_version, char *slave bml_internal *pBML = (bml_internal *)ctx; if (pBML->is_local_master()) { - mapf::utils::copy_string(master_version, bml_get_bml_version(), BML_VERSION_LEN); - mapf::utils::copy_string(slave_version, bml_get_bml_version(), BML_VERSION_LEN); + beerocks::string_utils::copy_string(master_version, bml_get_bml_version(), BML_VERSION_LEN); + beerocks::string_utils::copy_string(slave_version, bml_get_bml_version(), BML_VERSION_LEN); return BML_RET_OK; } diff --git a/controller/src/beerocks/bml/bml_utils.cpp b/controller/src/beerocks/bml/bml_utils.cpp index b2497dc125..aae1c6a0ae 100644 --- a/controller/src/beerocks/bml/bml_utils.cpp +++ b/controller/src/beerocks/bml/bml_utils.cpp @@ -8,6 +8,7 @@ #include "bml_utils.h" +#include #include #include @@ -154,7 +155,7 @@ int bml_utils_node_to_string(const struct BML_NODE *node, char *buffer, int buff std::cout << "ERROR: bml_node length > given buffer length" << std::endl; return 0; } else { - mapf::utils::copy_string(buffer, ss.str().c_str(), buffer_len); + beerocks::string_utils::copy_string(buffer, ss.str().c_str(), buffer_len); return offset; } } @@ -257,7 +258,7 @@ int bml_utils_stats_to_string(const struct BML_STATS *stats, char *buffer, int b std::cout << "ERROR: bml_stats length > given buffer length" << std::endl; return 0; } else { - mapf::utils::copy_string(buffer, ss.str().c_str(), buffer_len); + beerocks::string_utils::copy_string(buffer, ss.str().c_str(), buffer_len); return offset; } } @@ -318,7 +319,7 @@ int bml_utils_stats_to_string_raw(const struct BML_STATS *stats, char *buffer, i std::cout << "ERROR: bml_stats length > given buffer length" << std::endl; return 0; } else { - mapf::utils::copy_string(buffer, ss.str().c_str(), buffer_len); + beerocks::string_utils::copy_string(buffer, ss.str().c_str(), buffer_len); return offset; } } @@ -434,7 +435,7 @@ int bml_utils_event_to_string(const struct BML_EVENT *event, char *buffer, int b std::cout << "ERROR: bml_stats length > given buffer length" << std::endl; return 0; } else { - mapf::utils::copy_string(buffer, ss.str().c_str(), buffer_len); + beerocks::string_utils::copy_string(buffer, ss.str().c_str(), buffer_len); return offset; } } diff --git a/controller/src/beerocks/bml/internal/bml_internal.cpp b/controller/src/beerocks/bml/internal/bml_internal.cpp index 0cda44bb4d..f235226bbe 100644 --- a/controller/src/beerocks/bml/internal/bml_internal.cpp +++ b/controller/src/beerocks/bml/internal/bml_internal.cpp @@ -67,7 +67,8 @@ static void config_logger(const std::string log_file = std::string()) static void translate_channel_scan_results(const beerocks_message::sChannelScanResults &res_in, BML_NEIGHBOR_AP &res_out) { - mapf::utils::copy_string(res_out.ap_SSID, res_in.ssid, beerocks::message::WIFI_SSID_MAX_LENGTH); + string_utils::copy_string(res_out.ap_SSID, res_in.ssid, + beerocks::message::WIFI_SSID_MAX_LENGTH); std::copy_n(res_in.bssid.oct, BML_MAC_ADDR_LEN, res_out.ap_BSSID); std::copy_n(res_in.security_mode_enabled, beerocks::message::CHANNEL_SCAN_LIST_LENGTH, res_out.ap_SecurityModeEnabled); @@ -1256,12 +1257,12 @@ int bml_internal::process_cmdu_header(std::shared_ptr beerocks_ // Signal any waiting threads if (m_prmMasterSlaveVersions) { if (m_master_slave_versions != nullptr) { - mapf::utils::copy_string(m_master_slave_versions->master_version, - response->versions().master_version, - message::VERSION_LENGTH); - mapf::utils::copy_string(m_master_slave_versions->slave_version, - response->versions().slave_version, - message::VERSION_LENGTH); + string_utils::copy_string(m_master_slave_versions->master_version, + response->versions().master_version, + message::VERSION_LENGTH); + string_utils::copy_string(m_master_slave_versions->slave_version, + response->versions().slave_version, + message::VERSION_LENGTH); m_prmMasterSlaveVersions->set_value(response->result() == 0); } else { LOG(DEBUG) << "m_master_slave_versions == nullptr !"; @@ -1927,9 +1928,9 @@ int bml_internal::device_oper_radios_query(BML_DEVICE_DATA *device_data) device_data->radios[idx].is_connected = true; device_data->radios[idx].is_operational = (iface_status == beerocks::eNodeState::STATE_CONNECTED) ? true : false; - mapf::utils::copy_string(device_data->radios[idx].iface_name, - DeviceData.radios[idx].iface_name, - beerocks::message::IFACE_NAME_LENGTH); + string_utils::copy_string(device_data->radios[idx].iface_name, + DeviceData.radios[idx].iface_name, + beerocks::message::IFACE_NAME_LENGTH); } return iRet; @@ -2393,9 +2394,9 @@ int bml_internal::get_wifi_credentials(int vap_id, char *ssid, char *pass, int * // Clear the promise holder m_prmWiFiCredentialsGet = nullptr; - mapf::utils::copy_string(ssid, sWifiCredentials.ssid, BML_NODE_SSID_LEN); + string_utils::copy_string(ssid, sWifiCredentials.ssid, BML_NODE_SSID_LEN); if (pass != nullptr) { - mapf::utils::copy_string(pass, sWifiCredentials.pass, BML_NODE_PASS_LEN); + string_utils::copy_string(pass, sWifiCredentials.pass, BML_NODE_PASS_LEN); } *sec = sWifiCredentials.sec; @@ -2504,8 +2505,8 @@ int bml_internal::bml_wps_onboarding(const char *iface) return (-BML_RET_OP_FAILED); } - mapf::utils::copy_string(request->iface_name(message::IFACE_NAME_LENGTH), iface, - message::IFACE_NAME_LENGTH); + string_utils::copy_string(request->iface_name(message::IFACE_NAME_LENGTH), iface, + message::IFACE_NAME_LENGTH); if (!message_com::send_cmdu(m_sockPlatform, cmdu_tx)) { LOG(ERROR) << "Failed sending ACTION_PLATFORM_WPS_ONBOARDING_REQUEST message!"; @@ -2567,7 +2568,8 @@ int bml_internal::get_administrator_credentials(char *user_password) // Clear the promise holder m_prmAdminCredentialsGet = nullptr; - mapf::utils::copy_string(user_password, AdminCredentials.user_password, BML_NODE_USER_PASS_LEN); + string_utils::copy_string(user_password, AdminCredentials.user_password, + BML_NODE_USER_PASS_LEN); //clear the memory with password in it. volatile char *creds_pass = const_cast(AdminCredentials.user_password); @@ -2624,19 +2626,20 @@ int bml_internal::get_device_info(BML_DEVICE_INFO &device_info) // Clear the promise holder m_prmDeviceInfoGet = nullptr; - mapf::utils::copy_string(device_info.manufacturer, DeviceInfo.manufacturer, BML_DEV_INFO_LEN); - mapf::utils::copy_string(device_info.model_name, DeviceInfo.model_name, BML_DEV_INFO_LEN); - mapf::utils::copy_string(device_info.serial_number, DeviceInfo.serial_number, BML_DEV_INFO_LEN); + string_utils::copy_string(device_info.manufacturer, DeviceInfo.manufacturer, BML_DEV_INFO_LEN); + string_utils::copy_string(device_info.model_name, DeviceInfo.model_name, BML_DEV_INFO_LEN); + string_utils::copy_string(device_info.serial_number, DeviceInfo.serial_number, + BML_DEV_INFO_LEN); // LAN - mapf::utils::copy_string(device_info.lan_iface_name, DeviceInfo.lan_iface_name, - BML_IFACE_NAME_LEN); + string_utils::copy_string(device_info.lan_iface_name, DeviceInfo.lan_iface_name, + BML_IFACE_NAME_LEN); device_info.lan_ip_address = DeviceInfo.lan_ip_address; device_info.lan_network_mask = DeviceInfo.lan_network_mask; // WAN - mapf::utils::copy_string(device_info.wan_iface_name, DeviceInfo.wan_iface_name, - BML_IFACE_NAME_LEN); + string_utils::copy_string(device_info.wan_iface_name, DeviceInfo.wan_iface_name, + BML_IFACE_NAME_LEN); device_info.wan_ip_address = DeviceInfo.wan_ip_address; device_info.wan_network_mask = DeviceInfo.wan_network_mask; @@ -3076,8 +3079,8 @@ int bml_internal::get_master_slave_versions(char *master_version, char *slave_ve // Clear the promise holder m_prmMasterSlaveVersions = nullptr; - mapf::utils::copy_string(master_version, sVersion.master_version, message::VERSION_LENGTH); - mapf::utils::copy_string(slave_version, sVersion.slave_version, message::VERSION_LENGTH); + string_utils::copy_string(master_version, sVersion.master_version, message::VERSION_LENGTH); + string_utils::copy_string(slave_version, sVersion.slave_version, message::VERSION_LENGTH); if (iRet != BML_RET_OK) { LOG(ERROR) << "master_slave_versions request failed!"; diff --git a/controller/src/beerocks/cli/beerocks_cli_bml.cpp b/controller/src/beerocks/cli/beerocks_cli_bml.cpp index f73e0ada1b..efe45117e6 100644 --- a/controller/src/beerocks/cli/beerocks_cli_bml.cpp +++ b/controller/src/beerocks/cli/beerocks_cli_bml.cpp @@ -641,7 +641,7 @@ void cli_bml::map_query_cb(const struct BML_NODE_ITER *node_iter, bool to_consol std::cout << "ERROR: MARK sign > print_buffer available length" << std::endl; return; } else { - mapf::utils::copy_string(p, ss.str().c_str(), sizeof(pThis->print_buffer)); + string_utils::copy_string(p, ss.str().c_str(), sizeof(pThis->print_buffer)); p += offset; } } diff --git a/controller/src/beerocks/cli/beerocks_cli_main.cpp b/controller/src/beerocks/cli/beerocks_cli_main.cpp index aba023b5b9..22a610565f 100644 --- a/controller/src/beerocks/cli/beerocks_cli_main.cpp +++ b/controller/src/beerocks/cli/beerocks_cli_main.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include @@ -110,7 +109,7 @@ static char *dupstr(const std::string &s) sigterm_handler(0); return nullptr; } - mapf::utils::copy_string(r, s.c_str(), r_len); + beerocks::string_utils::copy_string(r, s.c_str(), r_len); return r; } diff --git a/controller/src/beerocks/cli/beerocks_cli_socket.cpp b/controller/src/beerocks/cli/beerocks_cli_socket.cpp index 4bf2538249..536cc20590 100644 --- a/controller/src/beerocks/cli/beerocks_cli_socket.cpp +++ b/controller/src/beerocks/cli/beerocks_cli_socket.cpp @@ -810,8 +810,8 @@ int cli_socket::client_beacon_11k_req(std::string client_mac, std::string bssid, if (!ssid.empty()) { request->use_optional_ssid() = true; - mapf::utils::copy_string(reinterpret_cast(request->ssid()), ssid.c_str(), - message::WIFI_SSID_MAX_LENGTH); + string_utils::copy_string(reinterpret_cast(request->ssid()), ssid.c_str(), + message::WIFI_SSID_MAX_LENGTH); } wait_response = true; message_com::send_cmdu(master_socket, cmdu_tx); diff --git a/controller/src/beerocks/master/db/network_map.cpp b/controller/src/beerocks/master/db/network_map.cpp index c0c532bb93..c7be0e2b19 100644 --- a/controller/src/beerocks/master/db/network_map.cpp +++ b/controller/src/beerocks/master/db/network_map.cpp @@ -245,7 +245,7 @@ std::ptrdiff_t network_map::fill_bml_node_data(db &database, std::shared_ptrip_v4, n->ipv4); - mapf::utils::copy_string(node->name, n->name.c_str(), sizeof(node->name)); + string_utils::copy_string(node->name, n->name.c_str(), sizeof(node->name)); // GW/IRE specific parameters if (n_type != beerocks::TYPE_CLIENT) { @@ -264,9 +264,9 @@ std::ptrdiff_t network_map::fill_bml_node_data(db &database, std::shared_ptrmac); // local parent backhaul // Copy the interface name - mapf::utils::copy_string(node->data.gw_ire.radio[i].iface_name, - database.get_hostap_iface_name(c->mac).c_str(), - BML_NODE_IFACE_NAME_LEN); + string_utils::copy_string(node->data.gw_ire.radio[i].iface_name, + database.get_hostap_iface_name(c->mac).c_str(), + BML_NODE_IFACE_NAME_LEN); // Radio Vendor switch (database.get_hostap_iface_type(c->mac)) { @@ -278,9 +278,9 @@ std::ptrdiff_t network_map::fill_bml_node_data(db &database, std::shared_ptrdata.gw_ire.radio[i].driver_version, - database.get_hostap_driver_version(c->mac).c_str(), - BML_WLAN_DRIVER_VERSION_LEN); + string_utils::copy_string(node->data.gw_ire.radio[i].driver_version, + database.get_hostap_driver_version(c->mac).c_str(), + BML_WLAN_DRIVER_VERSION_LEN); node->data.gw_ire.radio[i].channel = !c->channel ? 255 : c->channel; node->data.gw_ire.radio[i].cac_completed = c->hostap->cac_completed; @@ -297,9 +297,9 @@ std::ptrdiff_t network_map::fill_bml_node_data(db &database, std::shared_ptrhostap->vaps_info.size()); vap_id++) { const auto &vap = (c->hostap->vaps_info[vap_id]); tlvf::mac_from_string(node->data.gw_ire.radio[i].vap[vap_id].bssid, vap.mac); - mapf::utils::copy_string(node->data.gw_ire.radio[i].vap[vap_id].ssid, - vap.ssid.c_str(), - sizeof(node->data.gw_ire.radio[i].vap[0].ssid)); + string_utils::copy_string(node->data.gw_ire.radio[i].vap[vap_id].ssid, + vap.ssid.c_str(), + sizeof(node->data.gw_ire.radio[i].vap[0].ssid)); node->data.gw_ire.radio[i].vap[vap_id].backhaul_vap = vap.backhaul_vap; } ++i; diff --git a/controller/src/beerocks/master/son_management.cpp b/controller/src/beerocks/master/son_management.cpp index 76c20245c0..657678414e 100644 --- a/controller/src/beerocks/master/son_management.cpp +++ b/controller/src/beerocks/master/son_management.cpp @@ -523,8 +523,8 @@ void son_management::handle_cli_message(Socket *sd, // Optional: if (cli_request->use_optional_ssid()) { request->params().use_optional_ssid = 1; // bool - mapf::utils::copy_string(request->params().ssid, (char *)cli_request->ssid(), - beerocks::message::WIFI_SSID_MAX_LENGTH); + string_utils::copy_string(request->params().ssid, (char *)cli_request->ssid(), + beerocks::message::WIFI_SSID_MAX_LENGTH); } else { request->params().use_optional_ssid = 0; } diff --git a/controller/src/beerocks/master/son_master_thread.cpp b/controller/src/beerocks/master/son_master_thread.cpp index 9e0e1e7805..4ddb5bf6f3 100644 --- a/controller/src/beerocks/master/son_master_thread.cpp +++ b/controller/src/beerocks/master/son_master_thread.cpp @@ -2035,8 +2035,8 @@ bool master_thread::handle_intel_slave_join( auto slave_version_s = version::version_from_string(slave_version); auto master_version_s = version::version_from_string(BEEROCKS_VERSION); - mapf::utils::copy_string(join_response->master_version(), BEEROCKS_VERSION, - message::VERSION_LENGTH); + string_utils::copy_string(join_response->master_version(), BEEROCKS_VERSION, + message::VERSION_LENGTH); // check if fatal mismatch if (slave_version_s.major != master_version_s.major || @@ -2047,8 +2047,8 @@ bool master_thread::handle_intel_slave_join( LOG(INFO) << " bridge_mac=" << bridge_mac << " bridge_ipv4=" << bridge_ipv4; join_response->err_code() = beerocks::JOIN_RESP_VERSION_MISMATCH; - mapf::utils::copy_string(join_response->master_version(message::VERSION_LENGTH), - BEEROCKS_VERSION, message::VERSION_LENGTH); + string_utils::copy_string(join_response->master_version(message::VERSION_LENGTH), + BEEROCKS_VERSION, message::VERSION_LENGTH); return son_actions::send_cmdu_to_agent(src_mac, cmdu_tx, database); } @@ -2172,8 +2172,8 @@ bool master_thread::handle_intel_slave_join( // send JOINED_RESPONSE with son config { - mapf::utils::copy_string(join_response->master_version(message::VERSION_LENGTH), - BEEROCKS_VERSION, message::VERSION_LENGTH); + string_utils::copy_string(join_response->master_version(message::VERSION_LENGTH), + BEEROCKS_VERSION, message::VERSION_LENGTH); join_response->config().monitor_total_ch_load_notification_hi_th_percent = database.config.monitor_total_ch_load_notification_hi_th_percent; join_response->config().monitor_total_ch_load_notification_lo_th_percent = diff --git a/controller/src/beerocks/master/tasks/association_handling_task.cpp b/controller/src/beerocks/master/tasks/association_handling_task.cpp index 6c6f89e1ae..bfe84471d7 100644 --- a/controller/src/beerocks/master/tasks/association_handling_task.cpp +++ b/controller/src/beerocks/master/tasks/association_handling_task.cpp @@ -155,7 +155,7 @@ void association_handling_task::work() parent_mac); // the bssid which will be reported. for all bssid, use wildcard "ff:ff:ff:ff:ff:ff" //measurement_request.params.use_optional_ssid = true; measurement_request->params().expected_reports_count = 1; - //mapf::utils::copy_string(measurement_request.params.ssid, database.get_hostap_vap_ssid(parent_mac).c_str(), sizeof(measurement_request.params.ssid)); + //string_utils::copy_string(measurement_request.params.ssid, database.get_hostap_vap_ssid(parent_mac).c_str(), sizeof(measurement_request.params.ssid)); add_pending_mac(radio_mac, beerocks_message::ACTION_CONTROL_CLIENT_BEACON_11K_RESPONSE); TASK_LOG(DEBUG) << "requested beacon measurement request from sta: " << sta_mac << " on hostap: " << parent_mac; From c8eaa28074acef63928ebae8fcfae83a605afb22 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Sun, 28 Jun 2020 12:34:53 +0000 Subject: [PATCH 082/453] bcl: cmake: remove mapfcommon dependency Signed-off-by: Vitaly Bukhovsky --- common/beerocks/bcl/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/beerocks/bcl/CMakeLists.txt b/common/beerocks/bcl/CMakeLists.txt index ba0485e795..dc312523a1 100644 --- a/common/beerocks/bcl/CMakeLists.txt +++ b/common/beerocks/bcl/CMakeLists.txt @@ -25,7 +25,7 @@ target_include_directories(${PROJECT_NAME} $ ) -target_link_libraries(${PROJECT_NAME} PUBLIC nl-3 nl-route-3 tlvf elpp mapfcommon) +target_link_libraries(${PROJECT_NAME} PUBLIC nl-3 nl-route-3 tlvf elpp) install(TARGETS ${PROJECT_NAME} EXPORT bclConfig ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -61,7 +61,7 @@ if (BUILD_TESTS) PUBLIC $ ) - target_link_libraries(${TEST_PROJECT_NAME} nl-3 nl-route-3 tlvf elpp mapfcommon) + target_link_libraries(${TEST_PROJECT_NAME} nl-3 nl-route-3 tlvf elpp) target_link_libraries(${TEST_PROJECT_NAME} gtest_main gmock) install(TARGETS ${TEST_PROJECT_NAME} DESTINATION bin/tests) add_test(NAME ${TEST_PROJECT_NAME} COMMAND $) From fa981381536a83e7ed603a89d6fd25c5ebbd4686 Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Sun, 21 Jun 2020 14:47:12 +0000 Subject: [PATCH 083/453] framework: bpl: add DB stubs To support the persistent DB feature, BPL APIs that support the reading/writing functionality are needed. These APIs will be used to access the persistent database. Add BPL DB APIs on both platforms that support UCI and ones that do not. Signed-off-by: Itay Elenzweig --- framework/platform/bpl/include/bpl/bpl_db.h | 96 +++++++++++++++++++++ framework/platform/bpl/linux/bpl_db.cpp | 62 +++++++++++++ framework/platform/bpl/uci/db/bpl_db.cpp | 62 +++++++++++++ 3 files changed, 220 insertions(+) create mode 100644 framework/platform/bpl/include/bpl/bpl_db.h create mode 100644 framework/platform/bpl/linux/bpl_db.cpp create mode 100644 framework/platform/bpl/uci/db/bpl_db.cpp diff --git a/framework/platform/bpl/include/bpl/bpl_db.h b/framework/platform/bpl/include/bpl/bpl_db.h new file mode 100644 index 0000000000..784b7df733 --- /dev/null +++ b/framework/platform/bpl/include/bpl/bpl_db.h @@ -0,0 +1,96 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#ifndef _BPL_DB_H_ +#define _BPL_DB_H_ + +#include "bpl.h" +#include "bpl_err.h" +#include +#include +#include + +namespace beerocks { +namespace bpl { + +/****************************************************************************/ +/******************************* Definitions ********************************/ +/****************************************************************************/ + +/****************************************************************************/ +/******************************* Structures *********************************/ +/****************************************************************************/ + +/****************************************************************************/ +/******************************** Functions *********************************/ +/****************************************************************************/ + +/** + * @brief find if entry exists + * + * @param[in] entry_type type of the requested entry. + * @param[in] entry_name name of the requested entry. + * @return true if entry exists in db, false otherwise + */ +bool db_has_entry(const std::string &entry_type, const std::string &entry_name); + +/** + * @brief Add new entry with initial value. + * + * @param[in] entry_type type of the requested entry. + * @param[in] entry_name name of the requested entry. + * @param[in] params initial params of the entry. + * @return true on success, false otherwise + */ +bool db_add_entry(const std::string &entry_type, const std::string &entry_name, + const std::unordered_map ¶ms); +/** + * @brief Set values in entry, append attributes and override existing. + * + * @param[in] entry_type type of the requested entry. + * @param[in] entry_name name of the requested entry. + * @param[in] params unordered_map containing the params the requested entry, to be set. + * @return true on success, false otherwise. + */ +bool db_set_entry(const std::string &entry_type, const std::string &entry_name, + const std::unordered_map ¶ms); +/** + * @brief Get values of entry, return all avaliable values. + * + * @param[in] entry_type type of the requested entry. + * @param[in] entry_name name of the requested entry. + * @param [in/out] params unordered_map containing the params of the requested entry. + * @return true on success, false otherwise. + */ +bool db_get_entry(const std::string &entry_type, const std::string &entry_name, + std::unordered_map ¶ms); + +/** + * @brief Get all entries by type as a nested map >. + * + * @param[in] entry_type type of the requested entries. + * @param[in/out] nested_params nested map of params (with entry's name as key). + * @return true on success, false otherwise. + */ +bool db_get_entries_by_type( + const std::string &entry_type, + std::unordered_map> &nested_params); + +/** + * @brief Remove entry by name. + * + * @param[in] entry_type type of the requested entry. + * @param[in] entry_name name of the requested entry. + * @return true on success, false otherwise. + */ +bool db_remove_entry(const std::string &entry_type, const std::string &entry_name); + +} // namespace bpl +} // namespace beerocks + +#endif /* _BPL_DB_H_ */ diff --git a/framework/platform/bpl/linux/bpl_db.cpp b/framework/platform/bpl/linux/bpl_db.cpp new file mode 100644 index 0000000000..1eeb912a5e --- /dev/null +++ b/framework/platform/bpl/linux/bpl_db.cpp @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include "bpl/bpl_db.h" + +#include + +////////////////////////////////////////////////////////////////////////////// +/////////////////////////////// Implementation /////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +namespace beerocks { +namespace bpl { + +bool db_has_entry(const std::string &entry_type, const std::string &entry_name) +{ + LOG(TRACE) << " - NOT IMPLEMENTED!"; + return false; +} + +bool db_add_entry(const std::string &entry_type, const std::string &entry_name, + const std::unordered_map ¶ms) +{ + LOG(TRACE) << " - NOT IMPLEMENTED!"; + return true; +} + +bool db_set_entry(const std::string &entry_type, const std::string &entry_name, + const std::unordered_map ¶ms) +{ + LOG(TRACE) << " - NOT IMPLEMENTED!"; + return true; +} + +bool db_get_entry(const std::string &entry_type, const std::string &entry_name, + std::unordered_map ¶ms) +{ + LOG(TRACE) << " - NOT IMPLEMENTED!"; + return true; +} + +bool db_get_entries_by_type( + const std::string &entry_type, + std::unordered_map> &nested_params) +{ + LOG(TRACE) << " - NOT IMPLEMENTED!"; + return true; +} + +bool db_remove_entry(const std::string &entry_type, const std::string &entry_name) +{ + LOG(TRACE) << " - NOT IMPLEMENTED!"; + return true; +} + +} // namespace bpl +} // namespace beerocks diff --git a/framework/platform/bpl/uci/db/bpl_db.cpp b/framework/platform/bpl/uci/db/bpl_db.cpp new file mode 100644 index 0000000000..1eeb912a5e --- /dev/null +++ b/framework/platform/bpl/uci/db/bpl_db.cpp @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include "bpl/bpl_db.h" + +#include + +////////////////////////////////////////////////////////////////////////////// +/////////////////////////////// Implementation /////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +namespace beerocks { +namespace bpl { + +bool db_has_entry(const std::string &entry_type, const std::string &entry_name) +{ + LOG(TRACE) << " - NOT IMPLEMENTED!"; + return false; +} + +bool db_add_entry(const std::string &entry_type, const std::string &entry_name, + const std::unordered_map ¶ms) +{ + LOG(TRACE) << " - NOT IMPLEMENTED!"; + return true; +} + +bool db_set_entry(const std::string &entry_type, const std::string &entry_name, + const std::unordered_map ¶ms) +{ + LOG(TRACE) << " - NOT IMPLEMENTED!"; + return true; +} + +bool db_get_entry(const std::string &entry_type, const std::string &entry_name, + std::unordered_map ¶ms) +{ + LOG(TRACE) << " - NOT IMPLEMENTED!"; + return true; +} + +bool db_get_entries_by_type( + const std::string &entry_type, + std::unordered_map> &nested_params) +{ + LOG(TRACE) << " - NOT IMPLEMENTED!"; + return true; +} + +bool db_remove_entry(const std::string &entry_type, const std::string &entry_name) +{ + LOG(TRACE) << " - NOT IMPLEMENTED!"; + return true; +} + +} // namespace bpl +} // namespace beerocks From c1bbbca179d039ba0dc4f7261a8c2ad7f08aebab Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Mon, 29 Jun 2020 16:49:46 +0000 Subject: [PATCH 084/453] cppcheck: bpl issues update Currently the APIs are not yet implemented which causes the cppcheck to mark them as issues, but once they are implemented the issues will not appear. Add known BPL issues, that will be removed once the BPL DB functions will be implemented. Signed-off-by: Itay Elenzweig --- ci/cppcheck/cppcheck_existing_issues.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci/cppcheck/cppcheck_existing_issues.txt b/ci/cppcheck/cppcheck_existing_issues.txt index c4d23407ac..27477d428c 100644 --- a/ci/cppcheck/cppcheck_existing_issues.txt +++ b/ci/cppcheck/cppcheck_existing_issues.txt @@ -219,6 +219,8 @@ framework/platform/bpl/common/utils/utils.cpp: performance: Function parameter ' framework/platform/bpl/common/utils/utils.cpp: style: Unused variable: return_string [unusedVariable] std::string return_string; framework/platform/bpl/linux/bpl_cfg.cpp: information: Skipping configuration 'PLATFORM_DB_PATH' since the value of 'PLATFORM_DB_PATH' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly. [ConfigurationNotChecked] MAPF_ERR("Failed oppening file " << PLATFORM_DB_PATH); framework/platform/bpl/linux/bpl_cfg.cpp: information: Skipping configuration 'PLATFORM_DB_PATH' since the value of 'PLATFORM_DB_PATH' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly. [ConfigurationNotChecked] in_conf_file.open(PLATFORM_DB_PATH); +framework/platform/bpl/linux/bpl_db.cpp: style: Parameter 'nested_params' can be declared with const [constParameter] std::unordered_map> &nested_params) +framework/platform/bpl/linux/bpl_db.cpp: style: Parameter 'params' can be declared with const [constParameter] std::unordered_map ¶ms) framework/platform/bpl/test/bpl_test.cpp: portability: fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux systems. [fflushOnInputStream] fflush(stdin); framework/platform/bpl/test/bpl_test.cpp: portability: fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux systems. [fflushOnInputStream] fflush(stdin); framework/platform/bpl/uci/arp/bpl_arp.cpp: style: C-style pointer casting [cstyleCast] arp_monitor *pArpMon = (arp_monitor *)ctx; @@ -228,6 +230,8 @@ framework/platform/bpl/uci/arp/monitor/arp_monitor.cpp: style: Unused variable: framework/platform/bpl/uci/cfg/bpl_cfg.cpp: style: The scope of the variable 'retVal' can be reduced. [variableScope] int retVal = 0; framework/platform/bpl/uci/cfg/bpl_cfg.cpp: style: Variable 'retVal' is assigned a value that is never used. [unreadVariable] int retVal = 0; framework/platform/bpl/uci/cfg/bpl_cfg_uci.cpp: style: The scope of the variable 'scanf_res' can be reduced. [variableScope] int scanf_res; +framework/platform/bpl/uci/db/bpl_db.cpp: style: Parameter 'nested_params' can be declared with const [constParameter] std::unordered_map> &nested_params) +framework/platform/bpl/uci/db/bpl_db.cpp: style: Parameter 'params' can be declared with const [constParameter] std::unordered_map ¶ms) framework/platform/bpl/uci/dhcp/bpl_dhcp.cpp: style: struct member 'dhcp_event_request::data' is never used. [unusedStructMember] char data[]; framework/tlvf/src/src/ClassList.cpp: style: Consider using std::accumulate algorithm instead of a raw loop. [useStlAlgorithm] msg_len += c->getLen(); framework/tlvf/test/tlvf_test.cpp: style: Local variable 'cmplx' shadows outer variable [shadowVariable] auto cmplx = std::get<1>(tlv4->complex_list(0)); From 107e1d2d4e5aef3d04f014c7f257b086109e8f99 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Mon, 22 Jun 2020 20:44:52 +0300 Subject: [PATCH 085/453] agent: wireless_utils: Add validate_channel method For correct implementation Backhaul STA Steering need to add new method in the wireless_utils for the channel validation. Add implementation for the method. Signed-off-by: Vladyslav Tupikin --- common/beerocks/bcl/include/bcl/son/son_wireless_utils.h | 9 +++++++++ common/beerocks/bcl/source/son/son_wireless_utils.cpp | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/common/beerocks/bcl/include/bcl/son/son_wireless_utils.h b/common/beerocks/bcl/include/bcl/son/son_wireless_utils.h index a469d69bbc..4ea6fadfe0 100644 --- a/common/beerocks/bcl/include/bcl/son/son_wireless_utils.h +++ b/common/beerocks/bcl/include/bcl/son/son_wireless_utils.h @@ -171,6 +171,15 @@ class wireless_utils { static std::list get_channel_preferences(const beerocks::message::sWifiChannel supported_channels[]); + /** + * @brief Match channel number in the given operating class. + * + * @param operating_class operating class + * @param channel channel number + * @return True if channel matches to operating class + */ + static bool is_channel_in_operating_class(uint8_t operating_class, uint8_t channel); + private: enum eAntennaFactor { ANT_FACTOR_1X1 = 0, diff --git a/common/beerocks/bcl/source/son/son_wireless_utils.cpp b/common/beerocks/bcl/source/son/son_wireless_utils.cpp index ec2431be42..029c7cd53b 100644 --- a/common/beerocks/bcl/source/son/son_wireless_utils.cpp +++ b/common/beerocks/bcl/source/son/son_wireless_utils.cpp @@ -869,3 +869,10 @@ std::list wireless_utils::string_to_wsc_oper_class(const std::string &o return {}; } } + +bool wireless_utils::is_channel_in_operating_class(uint8_t operating_class, uint8_t channel) +{ + auto channel_set = operating_class_to_channel_set(operating_class); + + return (channel_set.find(channel) != channel_set.end()); +} From d2fd1ef6fe9ccfdc5a56d6a35204ffbd6ca854ef Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Thu, 11 Jun 2020 15:14:11 +0200 Subject: [PATCH 086/453] docker: openwrt: bump prplwrt version The prplwrt branch at git.prpl.dev:prplmesh/prplwrt was update to re-sync with upstream prplwrt. Make sure we use the new version. This will fix build errors that people see when doing a clean build, without any docker cache. The problem is (probably) that the package feeds don't have hashes, so we're using the latest for them rather than the ones corresponding to our prplwrt fork. In CI this issue doesn't occur because the feeds are taken from the docker cache. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) Signed-off-by: Tomer Eliyahu --- tools/docker/builder/openwrt/build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/docker/builder/openwrt/build.sh b/tools/docker/builder/openwrt/build.sh index aa894403fc..ff4be4b53c 100755 --- a/tools/docker/builder/openwrt/build.sh +++ b/tools/docker/builder/openwrt/build.sh @@ -172,8 +172,9 @@ main() { VERBOSE=false IMAGE_ONLY=false OPENWRT_REPOSITORY='https://git.prpl.dev/prplmesh/prplwrt.git' -OPENWRT_VERSION='bd19f9ab26ad234b6f10cce23cd0dc41b9371929' -PRPL_FEED='https://git.prpl.dev/prplmesh/feed-prpl.git^53d1e11003ce318c043c42063bbd2f57d15aac81' +OPENWRT_VERSION='add783ec25be542fdf3ba414a6b08345b5d76a5e' +# TODO use hash instead of branch +PRPL_FEED='https://git.prpl.dev/prplmesh/feed-prpl.git^590ba854951ec3a24594c3e030980edb9cbe18ed' PRPLMESH_VARIANT="-nl80211" DOCKER_TARGET_STAGE="prplmesh-builder" From fa0a95692fbfb58b3dc6bee92868e59d3020da9b Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Sun, 14 Jun 2020 19:16:45 +0000 Subject: [PATCH 087/453] feed_prpl: enable sta_ifaces in default config Bump up feed_prpl to the following commit (unmerged): c9f9407 - Arnout Vandecappelle (Essensium/Mind), 3 days ago : prplmesh: enable sta_ifaces in default config Signed-off-by: Tomer Eliyahu --- tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml b/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml index 95f3292681..845c9cbeba 100644 --- a/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml +++ b/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml @@ -18,7 +18,7 @@ hash: 8b7ff7d902f35b41864fbf306d45ad4ed91eaa89 - name: feed_prpl uri: https://git.prpl.dev/prplmesh/feed-prpl.git - hash: 6453bb7a20eff2efb031ae4aecbc51a329d68957 + hash: c9f9407af79dd7ae8cfbe424ab6cf31fb09f5d57 - name: feed_opensource_apps uri: https://intel.prpl.dev/intel/feed_opensource_apps.git hash: 4ab5c90e08ce40b5208e6aea3e594a275f8940e9 From d4e87642ac71e429ac15aee80978308234ffe560 Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Sun, 21 Jun 2020 11:03:34 +0000 Subject: [PATCH 088/453] docker:builder: openwrt wireless bh support 1. Bump openwrt hush to add wireless bh support in prplwrt. 2. Stop using profile_feeds/netgear0rax40.yml since now prplwrt already includes prplmesh support with fixed hashes. Signed-off-by: Tomer Eliyahu --- tools/docker/builder/openwrt/build.sh | 2 +- tools/docker/builder/openwrt/scripts/build-openwrt.sh | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tools/docker/builder/openwrt/build.sh b/tools/docker/builder/openwrt/build.sh index ff4be4b53c..1e7a8454b4 100755 --- a/tools/docker/builder/openwrt/build.sh +++ b/tools/docker/builder/openwrt/build.sh @@ -172,7 +172,7 @@ main() { VERBOSE=false IMAGE_ONLY=false OPENWRT_REPOSITORY='https://git.prpl.dev/prplmesh/prplwrt.git' -OPENWRT_VERSION='add783ec25be542fdf3ba414a6b08345b5d76a5e' +OPENWRT_VERSION='345ca6855ac59690f74ab1258d12b2c68bb034e3' # TODO use hash instead of branch PRPL_FEED='https://git.prpl.dev/prplmesh/feed-prpl.git^590ba854951ec3a24594c3e030980edb9cbe18ed' PRPLMESH_VARIANT="-nl80211" diff --git a/tools/docker/builder/openwrt/scripts/build-openwrt.sh b/tools/docker/builder/openwrt/scripts/build-openwrt.sh index 7618c2e81c..6a5d07b842 100755 --- a/tools/docker/builder/openwrt/scripts/build-openwrt.sh +++ b/tools/docker/builder/openwrt/scripts/build-openwrt.sh @@ -12,9 +12,6 @@ mkdir -p files/etc printf '%s=%s\n' "OPENWRT_REPOSITORY" "$OPENWRT_REPOSITORY" >> files/etc/prplwrt-version printf '%s=%s\n' "OPENWRT_VERSION" "$OPENWRT_VERSION" >> files/etc/prplwrt-version if [ "$TARGET_PROFILE" = DEVICE_NETGEAR_RAX40 ] ; then - # Add prplmesh to the list of packages of the profile: - sed -i 's/packages:/packages:\n - prplmesh-dwpal/g' profiles/intel_mips.yml - yq write --inplace profiles/intel_mips.yml feeds -f profiles_feeds/netgear-rax40.yml ./scripts/gen_config.py intel_mips # Installing intel feed doesn't correctly regenerate kernel .package-info # force regeneration by removing it @@ -24,7 +21,7 @@ if [ "$TARGET_PROFILE" = DEVICE_NETGEAR_RAX40 ] ; then # make sure intel's bridge-utils is the only one that gets installed: rm -rf ./package/feeds/packages/bridge-utils scripts/feeds install -p feed_bridge_utils bridge-utils - cat profiles_feeds/netgear-rax40.yml >> files/etc/prplwrt-version + cat profiles/intel_mips.yml >> files/etc/prplwrt-version else cp feeds.conf.default feeds.conf echo "src-git prpl $PRPL_FEED" >> feeds.conf From d4c7c403720b0aa0be03dc4b07a41fb348e862ac Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Sun, 21 Jun 2020 11:06:55 +0000 Subject: [PATCH 089/453] docker:builder:openrt: cleanups - Since we don't use yq anymore, remove it from docker - remove unused profile_feeds Signed-off-by: Tomer Eliyahu --- tools/docker/builder/openwrt/Dockerfile | 6 ---- .../openwrt/profiles_feeds/netgear-rax40.yml | 30 ------------------- 2 files changed, 36 deletions(-) delete mode 100644 tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml diff --git a/tools/docker/builder/openwrt/Dockerfile b/tools/docker/builder/openwrt/Dockerfile index 9073a1ef3c..7c655d1ec4 100644 --- a/tools/docker/builder/openwrt/Dockerfile +++ b/tools/docker/builder/openwrt/Dockerfile @@ -15,11 +15,6 @@ RUN apt-get update \ build-essential libncurses5 libncurses5-dev python python3 \ unzip git ca-certificates gawk wget file bash \ python-yaml python3-yaml rsync less vim gnupg software-properties-common \ - # yq is available in a separate ppa (needs gnupg and software-properties-common): - && if [ -n "$HTTP_PROXY" ]; then KEYSERVER_OPTIONS="--keyserver-options http-proxy=$HTTP_PROXY"; fi \ - && apt-key adv --keyserver keyserver.ubuntu.com $KEYSERVER_OPTIONS --recv-keys CC86BB64 \ - && add-apt-repository ppa:rmescandon/yq \ - && apt-get -y install --no-install-recommends yq \ && rm -rf /var/lib/apt/lists/* # Building tlvfs currently uses the docker # container's python (not the one from OpenWrt) @@ -82,7 +77,6 @@ RUN printf '\033[1;35m%s Cloning prplWrt\n\033[0m' "$(date --iso-8601=seconds -- WORKDIR /home/openwrt/openwrt -COPY --chown=openwrt:openwrt profiles_feeds/ /home/openwrt/openwrt/profiles_feeds COPY --chown=openwrt:openwrt scripts/build-openwrt.sh /home/openwrt/openwrt/scripts/build-openwrt.sh #### diff --git a/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml b/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml deleted file mode 100644 index 845c9cbeba..0000000000 --- a/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml +++ /dev/null @@ -1,30 +0,0 @@ - - name: feed_target_mips - uri: https://intel.prpl.dev/prplmesh/feed_target_mips.git - hash: 78b0b2e9675ced7dd57829da7a27592dbb483fd3 - - name: feed_datapath - uri: https://intel.prpl.dev/intel/feed_datapath.git - hash: 23afe7e659ed6717224659aef74af2bb11d8091a - - name: feed_ppa - uri: https://intel.prpl.dev/intel/feed_ppa.git - hash: 4f49fa34bbd51c7dd218df164e32c17694bed421 - - name: feed_gphy_firmware - uri: https://intel.prpl.dev/intel/feed_gphy_firmware.git - hash: cbf75f2abde587ac2c5462d117b98e3dadaae5b6 - - name: feed_switch_api - uri: https://intel.prpl.dev/intel/feed_switch_api.git - hash: af078af5408654ca2e759ea7afcf92163282e86e - - name: feed_wlan_6x - uri: https://intel.prpl.dev/prplmesh/feed_wlan_6x.git - hash: 8b7ff7d902f35b41864fbf306d45ad4ed91eaa89 - - name: feed_prpl - uri: https://git.prpl.dev/prplmesh/feed-prpl.git - hash: c9f9407af79dd7ae8cfbe424ab6cf31fb09f5d57 - - name: feed_opensource_apps - uri: https://intel.prpl.dev/intel/feed_opensource_apps.git - hash: 4ab5c90e08ce40b5208e6aea3e594a275f8940e9 - - name: feed_pending - uri: https://intel.prpl.dev/intel/feed-pending.git - hash: 352365b31f968ab37e772b23c30ea32dbff9e337 - - name: feed_bridge_utils - uri: https://git.prpl.dev/prplmesh/feed-intel-bridge-utils.git - hash: 35de289cc67706f1016fa8f34512eb4c337bca47 From a270c4cc4206d75a53eb83cc2d5b610ba8282efc Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Sun, 21 Jun 2020 11:08:32 +0000 Subject: [PATCH 090/453] docker: builder: prplmesh build.sh clean all Cleanup prplmesh folder is not complete since removing the build dir is not enough when it was built with USE_SOURCE_DIR natively. Add cleanup to delete all openwrt artifacts. Signed-off-by: Tomer Eliyahu --- tools/docker/builder/openwrt/scripts/build.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/docker/builder/openwrt/scripts/build.sh b/tools/docker/builder/openwrt/scripts/build.sh index 0aa190a709..462e93d95e 100755 --- a/tools/docker/builder/openwrt/scripts/build.sh +++ b/tools/docker/builder/openwrt/scripts/build.sh @@ -4,8 +4,10 @@ # write access to it, and openwrt needs to at least write '.source_dir': cp -r /home/openwrt/prplMesh_source /home/openwrt/prplMesh # We want to make sure that we do not keep anything built from the host: -rm -rf /home/openwrt/prplMesh/build +cd /home/openwrt/prplMesh && \ + rm -rf build ipkg-* .built* .configured* .pkgdir .prepared .quilt_checked .source_dir +cd /home/openwrt/openwrt make package/prplmesh/prepare USE_SOURCE_DIR="/home/openwrt/prplMesh" V=s make package/prplmesh/compile V=sc -j"$(nproc)" mkdir -p artifacts From b5892d5425fad8b5b98a30ceab1873e7722530dc Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Thu, 25 Jun 2020 10:45:02 +0000 Subject: [PATCH 091/453] build:docker:openwrt remove workarounds for building prplwrt Now these are fixed in prplmesh prplwrt fork itself so are no longer needed. Bump the prplwrt hash to include all fixes. Signed-off-by: Tomer Eliyahu --- tools/docker/builder/openwrt/build.sh | 2 +- tools/docker/builder/openwrt/scripts/build-openwrt.sh | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/tools/docker/builder/openwrt/build.sh b/tools/docker/builder/openwrt/build.sh index 1e7a8454b4..d50da6de76 100755 --- a/tools/docker/builder/openwrt/build.sh +++ b/tools/docker/builder/openwrt/build.sh @@ -172,7 +172,7 @@ main() { VERBOSE=false IMAGE_ONLY=false OPENWRT_REPOSITORY='https://git.prpl.dev/prplmesh/prplwrt.git' -OPENWRT_VERSION='345ca6855ac59690f74ab1258d12b2c68bb034e3' +OPENWRT_VERSION='c0071bec0771e5c0a908aa56ea4e961a7d1f2c12' # TODO use hash instead of branch PRPL_FEED='https://git.prpl.dev/prplmesh/feed-prpl.git^590ba854951ec3a24594c3e030980edb9cbe18ed' PRPLMESH_VARIANT="-nl80211" diff --git a/tools/docker/builder/openwrt/scripts/build-openwrt.sh b/tools/docker/builder/openwrt/scripts/build-openwrt.sh index 6a5d07b842..0bd71ff3eb 100755 --- a/tools/docker/builder/openwrt/scripts/build-openwrt.sh +++ b/tools/docker/builder/openwrt/scripts/build-openwrt.sh @@ -13,14 +13,6 @@ printf '%s=%s\n' "OPENWRT_REPOSITORY" "$OPENWRT_REPOSITORY" >> files/etc/prplwrt printf '%s=%s\n' "OPENWRT_VERSION" "$OPENWRT_VERSION" >> files/etc/prplwrt-version if [ "$TARGET_PROFILE" = DEVICE_NETGEAR_RAX40 ] ; then ./scripts/gen_config.py intel_mips - # Installing intel feed doesn't correctly regenerate kernel .package-info - # force regeneration by removing it - rm -rf tmp - # For some reason we have to run gen_config a second time to get a correct .config: - ./scripts/gen_config.py intel_mips - # make sure intel's bridge-utils is the only one that gets installed: - rm -rf ./package/feeds/packages/bridge-utils - scripts/feeds install -p feed_bridge_utils bridge-utils cat profiles/intel_mips.yml >> files/etc/prplwrt-version else cp feeds.conf.default feeds.conf From 8f4cf0453eb267e15afdfce4324c77d3b081e537 Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Thu, 25 Jun 2020 11:59:07 +0000 Subject: [PATCH 092/453] tools:docker:builder: openwrt bump prplwrt hash for ebtables package Signed-off-by: Tomer Eliyahu --- tools/docker/builder/openwrt/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/docker/builder/openwrt/build.sh b/tools/docker/builder/openwrt/build.sh index d50da6de76..0fcda4bdb1 100755 --- a/tools/docker/builder/openwrt/build.sh +++ b/tools/docker/builder/openwrt/build.sh @@ -172,7 +172,7 @@ main() { VERBOSE=false IMAGE_ONLY=false OPENWRT_REPOSITORY='https://git.prpl.dev/prplmesh/prplwrt.git' -OPENWRT_VERSION='c0071bec0771e5c0a908aa56ea4e961a7d1f2c12' +OPENWRT_VERSION='c9b7e11b9607b47e949c7ced508dafa844d27dd0' # TODO use hash instead of branch PRPL_FEED='https://git.prpl.dev/prplmesh/feed-prpl.git^590ba854951ec3a24594c3e030980edb9cbe18ed' PRPLMESH_VARIANT="-nl80211" From 960ebe0a9c53b6f400a291d0b8e9ed0ee9aaa426 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Thu, 25 Jun 2020 13:19:07 +0000 Subject: [PATCH 093/453] agent: Add task infrastructure to the Agent Add Task base class and Task Pool for the Agent. Notice that on Task::eType the "Topology" type has been added. This is will be the first task that will be added. It is required to add at least one enum in order that the prplMesh will compile. Signed-off-by: Moran Shoeg --- agent/src/beerocks/slave/tasks/task.h | 74 ++++++++++++++++++++ agent/src/beerocks/slave/tasks/task_pool.cpp | 53 ++++++++++++++ agent/src/beerocks/slave/tasks/task_pool.h | 66 +++++++++++++++++ 3 files changed, 193 insertions(+) create mode 100644 agent/src/beerocks/slave/tasks/task.h create mode 100644 agent/src/beerocks/slave/tasks/task_pool.cpp create mode 100644 agent/src/beerocks/slave/tasks/task_pool.h diff --git a/agent/src/beerocks/slave/tasks/task.h b/agent/src/beerocks/slave/tasks/task.h new file mode 100644 index 0000000000..8f68104513 --- /dev/null +++ b/agent/src/beerocks/slave/tasks/task.h @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#ifndef _TASK_H_ +#define _TASK_H_ + +#include +#include + +namespace beerocks { + +/** +* @brief Enum which defines all tasks type. +* +* Each task must have an entry on the enum eType, so it will be possible to send the task an +* event. +*/ +enum eTaskType : uint8_t { + TOPOLOGY, +}; + +class Task { +public: + Task() = delete; + explicit Task(eTaskType task_type) : m_task_type(task_type) {} + virtual ~Task() {} + + /** + * @brief Retrun the task type. + * + * Called by TaskPool send_event(). + * + * @return eType Task type. + */ + virtual eTaskType get_task_type() { return m_task_type; } + + /** + * @brief Work function. Shall do the task routine. Called by TaskPool run_task() function. + */ + virtual void work(){}; + + /** + * @brief Handle events, which are being send from containing thread. + * + * @param event_enum_value Event enum value which shall be defined on the task. + */ + virtual void handle_event(uint8_t event_enum_value){}; + + /** + * @brief Handle CMDU message. + * + * @param cmdu_rx CMDU object conataining the message. + * @param src_mac AL Mac of the sender. + * @param beerocks_header Beerocks Message header (Only on VS message). + * @return true if the message has been handled, otherwise false. + */ + virtual bool handle_cmdu(ieee1905_1::CmduMessageRx &cmdu_rx, const sMacAddr &src_mac, + std::shared_ptr beerocks_header) + { + return false; + } + +private: + eTaskType m_task_type; +}; + +} // namespace beerocks + +#endif // _TASK_H_ diff --git a/agent/src/beerocks/slave/tasks/task_pool.cpp b/agent/src/beerocks/slave/tasks/task_pool.cpp new file mode 100644 index 0000000000..634f7df888 --- /dev/null +++ b/agent/src/beerocks/slave/tasks/task_pool.cpp @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include "task_pool.h" + +using namespace beerocks; + +bool TaskPool::add_task(const std::shared_ptr &new_task) +{ + if (!new_task) { + LOG(ERROR) << "new task pointer is nullptr"; + return false; + } + m_task_pool[new_task->get_task_type()] = new_task; + return true; +} + +void TaskPool::run_tasks() +{ + for (auto &task_element : m_task_pool) { + auto &task = task_element.second; + task->work(); + } +} + +void TaskPool::send_event(eTaskType task_type, uint8_t event) +{ + auto task_it = m_task_pool.find(task_type); + if (task_it == m_task_pool.end()) { + LOG(ERROR) << "task of type " << int(task_type) << " does not exist in the task_pool"; + return; + } + + auto &task = task_it->second; + task->handle_event(event); +} + +bool TaskPool::handle_cmdu(ieee1905_1::CmduMessageRx &cmdu_rx, sMacAddr src_mac, + std::shared_ptr beerocks_header) +{ + for (auto &task_element : m_task_pool) { + auto &task = task_element.second; + if (task->handle_cmdu(cmdu_rx, src_mac, beerocks_header)) { + return true; + } + } + return false; +} diff --git a/agent/src/beerocks/slave/tasks/task_pool.h b/agent/src/beerocks/slave/tasks/task_pool.h new file mode 100644 index 0000000000..e2b36b4fef --- /dev/null +++ b/agent/src/beerocks/slave/tasks/task_pool.h @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#ifndef _TASK_POOL_H_ +#define _TASK_POOL_H_ + +#include "task.h" +#include + +namespace beerocks { + +/** + * @brief The TaskPool is single instance tasks container which responsible to run each + * task and allow passing messages and events from the Agent to the task. + * + */ +class TaskPool { +public: + /** + * @brief Add new task to the task pool. + * + * @param new_task Shared pointer to the task. + * @return true on success, otherwise false. + */ + bool add_task(const std::shared_ptr &new_task); + + /** + * @brief Run all tasks on the pool, by calling each task work() function. + */ + void run_tasks(); + + /** + * @brief Send an 'event' defined on a specific task 'task_type'. + * + * @param task_type Task type, defined on Task base class. + * @param event Event type, defined on the task itself. + */ + void send_event(eTaskType task_type, uint8_t event); + + /** + * @brief Iterate over all tasks on the pool and pass them the message on 'cmdu_rx'. + * + * @param cmdu_rx CMDU object containing the message. + * @param src_mac MAC address of the message sender. + * @param beerocks_header Beerocks header (Only on VS message). + * @return true if the message has been handled, otherwise false. + */ + bool handle_cmdu(ieee1905_1::CmduMessageRx &cmdu_rx, sMacAddr src_mac, + std::shared_ptr beerocks_header = nullptr); + +private: + // Decalaring unordered_map with key which is an enum, does not compiles on older gcc version. + // It was considered a defect in the standard, and was fixed in C++14, and also fixed in the + // version of libstdc++ shipping with gcc as of 6.1. + // To make unordered_map work with an enum as key, std::hash function was added as third + // template argument. + std::unordered_map, std::hash> m_task_pool; +}; + +} // namespace beerocks +#endif // _TASK_POOL_H_ From 3d91b3455a83ffe3fddc29c68f89e131984e125f Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Thu, 25 Jun 2020 13:21:11 +0000 Subject: [PATCH 094/453] cmake: Add 'tasks' folder path to Agent CMake file Signed-off-by: Moran Shoeg --- agent/src/beerocks/slave/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/agent/src/beerocks/slave/CMakeLists.txt b/agent/src/beerocks/slave/CMakeLists.txt index 72d6752d78..98cf8b686d 100644 --- a/agent/src/beerocks/slave/CMakeLists.txt +++ b/agent/src/beerocks/slave/CMakeLists.txt @@ -10,6 +10,7 @@ file(GLOB beerocks_agent_sources # [TASK] Move link metric related classes to BPL #910 ${MODULE_PATH}/link_metrics/*.c* ${MODULE_PATH}/platform_manager/*.c* + ${MODULE_PATH}/tasks/*.c* ${MODULE_PATH}/gate/*.c* ${MODULE_PATH}/*.c* ) From ec734ca3ca28b149ca780b5a3468fc529af7866b Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Thu, 25 Jun 2020 13:25:44 +0000 Subject: [PATCH 095/453] agent: Add task pool to the backhual manager Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 24 ++++++++++++++----- .../backhaul_manager_thread.h | 3 +++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index dd492d3cab..1c8d4856c4 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -536,6 +536,9 @@ void backhaul_manager::after_select(bool timeout) } send_cmdu_to_bus(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac); } + + // Run Tasks + m_task_pool.run_tasks(); } bool backhaul_manager::finalize_slaves_connect_state(bool fConnected, @@ -2170,9 +2173,13 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr break; } default: { - LOG(ERROR) << "Unhandled message received from master: " - << int(beerocks_header->action_op()); - return false; + bool handled = m_task_pool.handle_cmdu(cmdu_rx, sMacAddr(), beerocks_header); + if (!handled) { + LOG(ERROR) << "Unhandled message received from the Controller: " + << int(beerocks_header->action_op()); + return false; + } + return true; } } @@ -2241,10 +2248,11 @@ bool backhaul_manager::handle_1905_1_message(ieee1905_1::CmduMessageRx &cmdu_rx, default: { // TODO add a warning once all vendor specific flows are replaced with EasyMesh // flows, since we won't expect a 1905 message not handled in this function - return false; + return m_task_pool.handle_cmdu(cmdu_rx, tlvf::mac_from_string(src_mac)); } } } + bool backhaul_manager::handle_slave_1905_1_message(ieee1905_1::CmduMessageRx &cmdu_rx, const std::string &src_mac) { @@ -2256,8 +2264,12 @@ bool backhaul_manager::handle_slave_1905_1_message(ieee1905_1::CmduMessageRx &cm return handle_slave_channel_selection_response(cmdu_rx, src_mac); } default: { - LOG(DEBUG) << "Unexpected 1905 message " << int(cmdu_rx.getMessageType()); - return false; + bool handled = m_task_pool.handle_cmdu(cmdu_rx, tlvf::mac_from_string(src_mac)); + if (!handled) { + LOG(DEBUG) << "Unexpected 1905 message " << int(cmdu_rx.getMessageType()); + return false; + } + return true; } } } diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 165e10c5fd..085f6d7a0e 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -9,6 +9,7 @@ #ifndef _BACKHAUL_MANAGER_THREAD_H #define _BACKHAUL_MANAGER_THREAD_H +#include "../tasks/task_pool.h" #include "wan_monitor.h" #include @@ -273,6 +274,8 @@ class backhaul_manager : public btl::transport_socket_thread { std::unique_ptr m_agent_ucc_listener; + TaskPool m_task_pool; + /** * AP Metrics Reporting configuration and status information type. */ From 3328d755ad5fce8d38eba51935280d240b4e30f7 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 17 Jun 2020 16:47:31 +0300 Subject: [PATCH 096/453] agent: backhaul_manager: Create handler for Backhaul STA Steering Request According to the UML diagram need to implement handler for Backhaul STA Steering Request in the backhaul manager wih name handle_backhaul_steering_request. Add implementation for handler, add new method for handler 1905 messages, add BACKHAUL_STEERING_REQUEST_MESSAGE type to bus_subscribe method. handle_backhaul_steering_request should parse tlvBackhaulSteeringRequest, trigger the associate method from current HAL and send ACK message to the controller. Signed-off-by: Vladyslav Tupikin --- .../backhaul_manager_thread.cpp | 64 +++++++++++++++++++ .../backhaul_manager_thread.h | 3 + 2 files changed, 67 insertions(+) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 1c8d4856c4..70dbac9892 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -73,6 +73,8 @@ #include #include #include +#include +#include #include #include #include @@ -279,6 +281,7 @@ bool backhaul_manager::init() ieee1905_1::eMessageType::TOPOLOGY_DISCOVERY_MESSAGE, ieee1905_1::eMessageType::TOPOLOGY_QUERY_MESSAGE, ieee1905_1::eMessageType::VENDOR_SPECIFIC_MESSAGE, + ieee1905_1::eMessageType::BACKHAUL_STEERING_REQUEST_MESSAGE, })) { LOG(ERROR) << "Failed to init mapf_bus"; return false; @@ -2245,6 +2248,9 @@ bool backhaul_manager::handle_1905_1_message(ieee1905_1::CmduMessageRx &cmdu_rx, case ieee1905_1::eMessageType::CHANNEL_SELECTION_REQUEST_MESSAGE: { return handle_channel_selection_request(cmdu_rx, src_mac); } + case ieee1905_1::eMessageType::BACKHAUL_STEERING_REQUEST_MESSAGE: { + return handle_backhaul_steering_request(cmdu_rx, src_mac); + } default: { // TODO add a warning once all vendor specific flows are replaced with EasyMesh // flows, since we won't expect a 1905 message not handled in this function @@ -4517,6 +4523,64 @@ bool backhaul_manager::handle_slave_channel_selection_response(ieee1905_1::CmduM return send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); } +bool backhaul_manager::handle_backhaul_steering_request(ieee1905_1::CmduMessageRx &cmdu_rx, + const std::string &src_mac) +{ + const auto mid = cmdu_rx.getMessageId(); + LOG(DEBUG) << "Received BACKHAUL_STA_STEERING message, mid=" << std::hex << mid; + + auto bh_sta_steering_req = cmdu_rx.getClass(); + if (!bh_sta_steering_req) { + LOG(WARNING) << "Failed cmdu_rx.getClass(), mid=" + << std::hex << mid; + return false; + } + + // build ACK message CMDU + auto cmdu_tx_header = cmdu_tx.create(mid, ieee1905_1::eMessageType::ACK_MESSAGE); + if (!cmdu_tx_header) { + LOG(ERROR) << "cmdu creation of type ACK_MESSAGE, has failed"; + return false; + } + + LOG(DEBUG) << "Sending ACK message to the originator, mid=" << std::hex << mid; + send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); + + /* + TODO: Need to do channel validation. If channel invalid, send ACK and Backhaul STA Steering + Response with the error code without trigerring HAL. + */ + + /* + TODO: BACKHAUL_STA_STEERING can be accepted in wired backhaul too. + Code below is incorrect in that case. + */ + auto active_hal = get_wireless_hal(); + if (!active_hal) { + LOG(ERROR) << "Couldn't get active HAL"; + return false; + } + + auto channel = bh_sta_steering_req->target_channel_number(); + auto bssid = bh_sta_steering_req->target_bssid(); + + auto associate = active_hal->roam(bssid, channel); + if (!associate) { + LOG(ERROR) << "Couldn't associate active HAL with bssid: " << bssid; + + LOG(DEBUG) << "Sending ACK message to the originator, mid=" << std::hex << mid; + send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); + + /* + TODO: Need to add sending Backhaul STA Steering Response with the FAILURE error code. + */ + + return false; + } + + return true; +} + const std::string backhaul_manager::freq_to_radio_mac(eFreqType freq) const { auto it = diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 085f6d7a0e..1276dbae8a 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -140,6 +140,9 @@ class backhaul_manager : public btl::transport_socket_thread { const std::string &src_mac); bool handle_slave_channel_selection_response(ieee1905_1::CmduMessageRx &cmdu_rx, const std::string &src_mac); + bool handle_backhaul_steering_request(ieee1905_1::CmduMessageRx &cmdu_rx, + const std::string &src_mac); + //bool sta_handle_event(const std::string &iface,const std::string& event_name, void* event_obj); bool hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t event_ptr, std::string iface); From 49128f28ed59b16da59e94d7a0ea956febb09ce5 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 17 Jun 2020 17:23:11 +0300 Subject: [PATCH 097/453] agent: backhaul_manager: Add method for sending Backhaul STA Steering Response Need to add method which creates Backhaul STA Steering Response message with filled up parameters target_bssid, target_bssid, result_code in tlvBackhaulSteeringResponse. Add implementation for method create_backhaul_steering_response. Signed-off-by: Vladyslav Tupikin --- .../backhaul_manager_thread.cpp | 50 +++++++++++++++++++ .../backhaul_manager_thread.h | 11 ++++ 2 files changed, 61 insertions(+) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 70dbac9892..b0bad86e94 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -4581,6 +4581,56 @@ bool backhaul_manager::handle_backhaul_steering_request(ieee1905_1::CmduMessageR return true; } +bool backhaul_manager::create_backhaul_steering_response( + const wfa_map::tlvErrorCode::eReasonCode &error_code) +{ + auto cmdu_tx_header = + cmdu_tx.create(0, ieee1905_1::eMessageType::BACKHAUL_STEERING_RESPONSE_MESSAGE); + if (!cmdu_tx_header) { + LOG(ERROR) << "Failed to create Backhoul STA Steering Response message"; + return false; + } + + auto bh_steering_resp_tlv = cmdu_tx.addClass(); + if (!bh_steering_resp_tlv) { + LOG(ERROR) << "Couldn't addClass"; + return false; + } + + auto active_hal = get_wireless_hal(); + if (!active_hal) { + LOG(ERROR) << "Couldn't get active HAL"; + return false; + } + + sMacAddr sta_mac; + auto interface = active_hal->get_iface_name(); + get_iface_mac(interface, sta_mac); + + LOG(DEBUG) << "Interface: " << interface << "MAC: " << sta_mac; + + bh_steering_resp_tlv->target_bssid() = tlvf::mac_from_string(active_hal->get_bssid()); + bh_steering_resp_tlv->backhaul_station_mac() = sta_mac; + + if (!error_code) { + bh_steering_resp_tlv->result_code() = + wfa_map::tlvBackhaulSteeringResponse::eResultCode::SUCCESS; + } else { + bh_steering_resp_tlv->result_code() = + wfa_map::tlvBackhaulSteeringResponse::eResultCode::FAILURE; + + auto error_code_tlv = cmdu_tx.addClass(); + if (!bh_steering_resp_tlv) { + LOG(ERROR) << "Couldn't addClass"; + return false; + } + + error_code_tlv->reason_code() = error_code; + } + + return true; +} + const std::string backhaul_manager::freq_to_radio_mac(eFreqType freq) const { auto it = diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 1276dbae8a..d39d78fc06 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -25,9 +25,11 @@ #include #include +#include #include #include #include +#include #include "../agent_ucc_listener.h" #include "../link_metrics/link_metrics.h" @@ -103,6 +105,15 @@ class backhaul_manager : public btl::transport_socket_thread { bool send_slave_ap_metric_query_message(uint16_t mid, std::vector const &bssid_list); + /** + * @brief Creates Backhaul STA Steering Response message with 2 tlvs Steering Response + * and Error Code. + * + * @param error_code One of the error codes presented in wfa_map::tlvErrorCode::eReasonCode. + * @return True on success and false otherwise + */ + bool create_backhaul_steering_response(const wfa_map::tlvErrorCode::eReasonCode &error_code); + // cmdu handlers bool handle_master_message(ieee1905_1::CmduMessageRx &cmdu_rx, std::shared_ptr beerocks_header); From 193775e80c5a6846afd25a38fe8f40cb904dcc3c Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 18 Jun 2020 21:16:56 +0300 Subject: [PATCH 098/453] agent: backhaul_manager: Add logic for sending Backhaul STA Steering Response Need to add sending Backhaul STA Steering Response message when backhaul_thread recieves ENABLED event from the wpa_supplicant. Signed-off-by: Vladyslav Tupikin --- .../backhaul_manager_thread.cpp | 27 ++++++++++++++++--- .../backhaul_manager_thread.h | 2 ++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index b0bad86e94..7117d9156d 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -973,6 +973,18 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) eth_link_poll_timer = std::chrono::steady_clock::now(); m_eth_link_up = network_utils::linux_iface_is_up_and_running(m_sConfig.wire_iface); FSM_MOVE_STATE(OPERATIONAL); + + // This event may come as a result of enabling the backhaul, but also as a result + // of steering. *Only* in case it was the result of steering, we need to send a steering + // response. + if (m_backhaul_sta_steering_enable) { + m_backhaul_sta_steering_enable = false; + + create_backhaul_steering_response(wfa_map::tlvErrorCode::eReasonCode::RESERVED); + + LOG(DEBUG) << "Sending BACKHAUL_STA_STEERING_RESPONSE_MESSAGE"; + send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); + } break; } // Backhaul manager is OPERATIONAL! @@ -4571,13 +4583,22 @@ bool backhaul_manager::handle_backhaul_steering_request(ieee1905_1::CmduMessageR LOG(DEBUG) << "Sending ACK message to the originator, mid=" << std::hex << mid; send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); - /* - TODO: Need to add sending Backhaul STA Steering Response with the FAILURE error code. - */ + auto response = create_backhaul_steering_response( + wfa_map::tlvErrorCode::eReasonCode:: + BACKHAUL_STEERING_REQUEST_REJECTED_TARGET_BSS_SIGNAL_NOT_SUITABLE); + + if (!response) { + LOG(ERROR) << "Failed to build Backhaul STA Steering Response message."; + return false; + } + + send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); return false; } + m_backhaul_sta_steering_enable = true; + return true; } diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index d39d78fc06..3c0092e13b 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -611,6 +611,8 @@ class backhaul_manager : public btl::transport_socket_thread { sExpectedChannelSelection m_expected_channel_selection; + bool m_backhaul_sta_steering_enable = false; + /* * State Machines */ From 00a2a3ba857125b76e304ccab590ee593b5c327e Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 18 Jun 2020 23:05:31 +0300 Subject: [PATCH 099/453] controller: son_master: Add handler for BACKHAUL_STA_STEERING_RESPONSE_MESSAGE Need to add handler for the BACKHAUL_STA_STEERING_RESPONSE_MESSAGE. Add handler with printing the type of message, MID, result of BACKHAUL_STA_STEERING_RESPONSE_MESSAGE and the error code. Also add sendind ACK message to the controller according to the paragraph 6 section 12 Easy Mesh R1 specification. Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/master/son_master_thread.cpp | 43 +++++++++++++++++++ .../src/beerocks/master/son_master_thread.h | 3 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/controller/src/beerocks/master/son_master_thread.cpp b/controller/src/beerocks/master/son_master_thread.cpp index 4ddb5bf6f3..c944b37bfa 100644 --- a/controller/src/beerocks/master/son_master_thread.cpp +++ b/controller/src/beerocks/master/son_master_thread.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -111,6 +112,7 @@ bool master_thread::init() ieee1905_1::eMessageType::TOPOLOGY_NOTIFICATION_MESSAGE, ieee1905_1::eMessageType::TOPOLOGY_RESPONSE_MESSAGE, ieee1905_1::eMessageType::VENDOR_SPECIFIC_MESSAGE, + ieee1905_1::eMessageType::BACKHAUL_STEERING_RESPONSE_MESSAGE, })) { LOG(ERROR) << "Failed subscribing to the Bus"; @@ -312,6 +314,9 @@ bool master_thread::handle_cmdu_1905_1_message(const std::string &src_mac, return handle_cmdu_1905_topology_notification(src_mac, cmdu_rx); case ieee1905_1::eMessageType::TOPOLOGY_RESPONSE_MESSAGE: return handle_cmdu_1905_topology_response(src_mac, cmdu_rx); + case ieee1905_1::eMessageType::BACKHAUL_STEERING_RESPONSE_MESSAGE: + return handle_cmdu_1905_backhaul_sta_steering_response(src_mac, cmdu_rx); + default: break; } @@ -1794,6 +1799,44 @@ bool master_thread::handle_cmdu_1905_topology_response(const std::string &src_ma return true; } +bool master_thread::handle_cmdu_1905_backhaul_sta_steering_response( + const std::string &src_mac, ieee1905_1::CmduMessageRx &cmdu_rx) +{ + auto mid = cmdu_rx.getMessageId(); + LOG(DEBUG) << "Received BACKHAUL_STA_STEERING_MESSAGE from " << src_mac << ", mid=" << std::hex + << mid; + + auto tlv_backhaul_sta_steering_resp = cmdu_rx.getClass(); + if (!tlv_backhaul_sta_steering_resp) { + LOG(ERROR) << "Failed getClass"; + return false; + } + + auto bh_steering_resp_code = tlv_backhaul_sta_steering_resp->result_code(); + LOG(DEBUG) << "BACKHAUL_STA_STEERING_MESSAGE result_code: " << int(bh_steering_resp_code); + + if (bh_steering_resp_code) { + auto error_code_tlv = cmdu_rx.getClass(); + if (!error_code_tlv) { + LOG(ERROR) << "Failed getClass"; + return false; + } + LOG(DEBUG) << "BACKHAUL_STA_STEERING_MESSAGE error_code: " + << int(error_code_tlv->reason_code()); + } + + // build ACK message CMDU + auto cmdu_tx_header = cmdu_tx.create(mid, ieee1905_1::eMessageType::ACK_MESSAGE); + if (!cmdu_tx_header) { + LOG(ERROR) << "cmdu creation of type ACK_MESSAGE, has failed"; + return false; + } + + LOG(DEBUG) << "sending ACK message to the agent, mid=" << std::hex << mid; + + return son_actions::send_cmdu_to_agent(src_mac, cmdu_tx, database); +} + bool master_thread::handle_cmdu_1905_beacon_response(const std::string &src_mac, ieee1905_1::CmduMessageRx &cmdu_rx) { diff --git a/controller/src/beerocks/master/son_master_thread.h b/controller/src/beerocks/master/son_master_thread.h index 0db5f32cb3..3228683b22 100644 --- a/controller/src/beerocks/master/son_master_thread.h +++ b/controller/src/beerocks/master/son_master_thread.h @@ -102,7 +102,8 @@ class master_thread : public beerocks::btl::transport_socket_thread { ieee1905_1::CmduMessageRx &cmdu_rx); bool handle_cmdu_1905_beacon_response(const std::string &src_mac, ieee1905_1::CmduMessageRx &cmdu_rx); - + bool handle_cmdu_1905_backhaul_sta_steering_response(const std::string &src_mac, + ieee1905_1::CmduMessageRx &cmdu_rx); bool autoconfig_wsc_parse_radio_caps( std::string radio_mac, std::shared_ptr radio_caps); // Autoconfig encryption support From 17f76a41b562e8c39bc0af540fd223e52ab86852 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 30 Jun 2020 17:19:45 +0300 Subject: [PATCH 100/453] agent: backhaul_manager: Add channel validation in handler Need to add channel validation for Backhaul STA Steering Request handler. If channel is invalid - send ACK message and Backhaul STA Steering Response message with FAILURE code. Remove TODO commentary and add changes described above. Signed-off-by: Vladyslav Tupikin --- .../backhaul_manager_thread.cpp | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 7117d9156d..9f73184a05 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -4558,10 +4558,27 @@ bool backhaul_manager::handle_backhaul_steering_request(ieee1905_1::CmduMessageR LOG(DEBUG) << "Sending ACK message to the originator, mid=" << std::hex << mid; send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); - /* - TODO: Need to do channel validation. If channel invalid, send ACK and Backhaul STA Steering - Response with the error code without trigerring HAL. - */ + auto channel = bh_sta_steering_req->target_channel_number(); + auto oper_class = bh_sta_steering_req->operating_class(); + + auto is_valid_channel = son::wireless_utils::is_channel_in_operating_class(oper_class, channel); + + if (!is_valid_channel) { + LOG(WARNING) << "Invalid channel number"; + + auto response = create_backhaul_steering_response( + wfa_map::tlvErrorCode::eReasonCode:: + BACKHAUL_STEERING_REQUEST_REJECTED_CANNOT_OPERATE_ON_CHANNEL_SPECIFIED); + + if (!response) { + LOG(ERROR) << "Failed to build Backhaul STA Steering Response message."; + return false; + } + + send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); + + return false; + } /* TODO: BACKHAUL_STA_STEERING can be accepted in wired backhaul too. @@ -4573,8 +4590,7 @@ bool backhaul_manager::handle_backhaul_steering_request(ieee1905_1::CmduMessageR return false; } - auto channel = bh_sta_steering_req->target_channel_number(); - auto bssid = bh_sta_steering_req->target_bssid(); + auto bssid = bh_sta_steering_req->target_bssid(); auto associate = active_hal->roam(bssid, channel); if (!associate) { From 7c7586e4bc9cde6b39e55c74ae9283f032c1c046 Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Thu, 2 Jul 2020 09:53:35 +0200 Subject: [PATCH 101/453] README.md: add link to latest build artifacts. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6c328afd49..ad094a2849 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ This project is part of a wider collaboration between Prpl Foundation and Broadb Architecture documentation can be found in the [documentation](documentation/) folder. +The latest build artifacts are [always accessible](https://ftp.essensium.com/owncloud/index.php/s/xidrhY3JKEYS9dK?path=%2Fartifacts%2Flatest%2Fbuild). + ## Requirements To build prplMesh, you need (on Ubuntu) the following packages: From 79cc771b128a7286c90bf37d84188e38d1bd5253 Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Wed, 17 Jun 2020 18:14:59 +0300 Subject: [PATCH 102/453] tests: boardfarm: port Client association link metrics test Port test_client_association_link_metrics from test_flows.py to boardfarm. As it works only for dockerized devices, do not include it to the "test_flows" test suite. Signed-off-by: Anton Bilohai --- .../tests/client_association_link_metrics.py | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py new file mode 100644 index 0000000000..9481712c2c --- /dev/null +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py @@ -0,0 +1,64 @@ +############################################################### +# SPDX-License-Identifier: BSD-2-Clause-Patent +# SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) +# This code is subject to the terms of the BSD+Patent license. +# See LICENSE file for more details. +############################################################### + +import time + +from .prplmesh_base_test import PrplMeshBaseTest +from capi import tlv +from environment import Station +from opts import debug + + +class ClientAssociationLinkMetrics(PrplMeshBaseTest): + ''' This test verifies that a MAUT with an associated STA responds to + an Associated STA Link Metrics Query message with an Associated STA Link Metrics + Response message containing an Associated STA Link Metrics TLV for the associated STA.''' + + def runTest(self): + # Locate test participants in array + for dev in self.dev: + if dev.controller_entity: + controller = dev.controller_entity + if dev.agent_entity: + agent = dev.agent_entity + + # Regression check + # Don't connect not existing STAtion + dev.wired_sniffer.start(self.__class__.__name__ + "-" + dev.name) + sta_mac = "11:11:33:44:55:66" + debug("Send link metrics query for unconnected STA") + controller.ucc_socket.dev_send_1905(agent.mac, 0x800D, + tlv(0x95, 0x0006, '{sta_mac}'.format(sta_mac=sta_mac))) + self.check_log(agent, + "client with mac address {sta_mac} not found".format(sta_mac=sta_mac), + timeout=30) + time.sleep(1) + + sta = Station.create() + debug('sta: {}'.format(sta.mac)) + + agent.radios[0].vaps[0].associate(sta) + + time.sleep(1) + + mid = controller.ucc_socket.dev_send_1905(agent.mac, 0x800D, + tlv(0x95, 0x0006, + '{sta_mac}'.format(sta_mac=sta.mac))) + time.sleep(1) + self.check_log(agent, + "Send AssociatedStaLinkMetrics to controller, mid = {}".format(mid), + timeout=30) + dev.agent_entity.radios[0].vaps[0].disassociate(sta) + + @classmethod + def teardown_class(cls): + """Teardown method, optional for boardfarm tests.""" + test = cls.test_obj + for dev in test.dev: + if dev.agent_entity: + print("Sniffer - stop") + dev.wired_sniffer.stop() From aa6cdc9ba1cd8783c429905a4e7d36625fbc535a Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Wed, 24 Jun 2020 21:24:30 +0300 Subject: [PATCH 103/453] tests: boardfarm: add dummy STA device Currently, we are using "Station" from environment.py to emulate station device required for some of the tests. It's not suitable for HW. Thus, test for dummy device and real one will be different. To avoid it, we have to create separate dummy station device. As it's boardfarm device, test will be same for dummy and real STA. Add dummy STA boardfarm class. Signed-off-by: Anton Bilohai --- .../devices/prplmesh_station_dummy.py | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station_dummy.py diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station_dummy.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station_dummy.py new file mode 100644 index 0000000000..99295ee22e --- /dev/null +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station_dummy.py @@ -0,0 +1,38 @@ +############################################################### +# SPDX-License-Identifier: BSD-2-Clause-Patent +# SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) +# This code is subject to the terms of the BSD+Patent license. +# See LICENSE file for more details. +############################################################### + +from .prplmesh_base import PrplMeshBase +from environment import VirtualAPDocker +from opts import err + + +class PrplMeshStationDummy(PrplMeshBase): + + model = "STA_dummy" + __mac_base = 0 + + def __init__(self, *args, **kwargs): + '''Generate dummy Station.''' + self.args = args + self.kwargs = kwargs + config = kwargs.get("config", kwargs) + + self.name = config.get("name", "station") + self.mac = config.get("mac", None) + + if self.mac is None: + raise ValueError(err("{} device \"{}\" has no MAC!".format(self.model, self.name))) + + def wifi_connect(self, vap: VirtualAPDocker) -> bool: + """Connect to the Access Point. Return True if successful.""" + vap.radio.send_bwl_event("EVENT AP-STA-CONNECTED {}".format(self.mac)) + return True + + def wifi_disconnect(self, vap: VirtualAPDocker) -> bool: + '''Disassociate "sta" from this VAP.''' + vap.radio.send_bwl_event("EVENT AP-STA-DISCONNECTED {}".format(self.mac)) + return True From e3231a2a9e037b39ceca70bb5d5fb4eda452af2e Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Wed, 24 Jun 2020 23:54:13 +0300 Subject: [PATCH 104/453] tests: boardfarm: use dummy STA device in ClientAssociationLinkMetrics We are using "Station" class to emulate STA for dummy device. But separate dummy STA boardfarm device exists. We should use it instead. This will allow to have same test for HW and dummy devices, as they share same interfaces. Use dummy STA device in ClientAssociationLinkMetrics test. Change naming of devices in configuration file, to call test participants directly by name. To keep dummy docker devices names unique for every user, split device name and docker image name to separate variables. Signed-off-by: Anton Bilohai --- .../devices/prplmesh_docker.py | 15 ++++---- .../boardfarm_prplmesh/prplmesh_config.json | 12 +++++-- .../tests/client_association_link_metrics.py | 34 +++++++++---------- .../boardfarm_prplmesh/testsuites.cfg | 1 + 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py index d4f9870d3c..ae46897104 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py @@ -5,10 +5,10 @@ import os import time - import boardfarm -from environment import ALEntityDocker, _get_bridge_interface + from .prplmesh_base import PrplMeshBase +from environment import ALEntityDocker, _get_bridge_interface from sniffer import Sniffer rootdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..')) @@ -33,7 +33,8 @@ def __init__(self, *args, **kwargs): # Getting unic ID to distinguish devices and network they belong to self.unique_id = os.getenv("SUDO_USER", os.getenv("USER", "")) - self.name = "-".join((config.get("name", "prplmesh_docker"), self.unique_id)) + self.name = config.get("name", "prplmesh_docker") + self.docker_name = "-".join((config.get("name", "prplmesh_docker"), self.unique_id)) self.role = config.get("role", "agent") self.cleanup_cmd = config.get("cleanup_cmd", None) self.conn_cmd = config.get("conn_cmd", None) @@ -42,7 +43,7 @@ def __init__(self, *args, **kwargs): "prplMesh-net-{}".format(self.unique_id)) docker_cmd = os.path.join(rootdir, "tools", "docker", "run.sh") - docker_args = ["--verbose", "--detach", "--force", "--name", self.name, + docker_args = ["--verbose", "--detach", "--force", "--name", self.docker_name, "--network", self.docker_network, "--expose", "8002"] if self.role == "controller": @@ -51,14 +52,16 @@ def __init__(self, *args, **kwargs): self._run_shell_cmd(docker_cmd, docker_args) time.sleep(self.delay) - self.controller_entity = ALEntityDocker(self.name, device=self, is_controller=True) + self.controller_entity = ALEntityDocker(self.docker_name, + device=self, is_controller=True) else: # Spawn dockerized agent docker_args.append("start-agent") self._run_shell_cmd(docker_cmd, docker_args) time.sleep(self.delay) - self.agent_entity = ALEntityDocker(self.name, device=self, is_controller=False) + self.agent_entity = ALEntityDocker(self.docker_name, + device=self, is_controller=False) self.wired_sniffer = Sniffer(_get_bridge_interface(self.docker_network), boardfarm.config.output_dir) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json index 7a55f651c2..7ae9c49423 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json @@ -1,19 +1,25 @@ { "prplmesh_docker": { - "name": "dockerized_device", + "name": "controller", "board_type": "prplmesh_docker", "role": "controller", "conn_cmd": "", "devices": [ { - "name": "repeater1", + "name": "lan", "type": "prplmesh_docker", "conn_cmd": "" }, { - "name": "repeater2", + "name": "lan2", "type": "prplmesh_docker", "conn_cmd": "" + }, + { + "name": "wifi", + "type": "STA_dummy", + "mac": "51:a1:10:20:00:01", + "conn_cmd": "" } ] }, diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py index 9481712c2c..3055c5463a 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py @@ -8,8 +8,9 @@ import time from .prplmesh_base_test import PrplMeshBaseTest +# TODO: Remove as soon, as test works for prplWRT device +from ..devices.prplmesh_prplwrt import PrplMeshPrplWRT from capi import tlv -from environment import Station from opts import debug @@ -19,16 +20,20 @@ class ClientAssociationLinkMetrics(PrplMeshBaseTest): Response message containing an Associated STA Link Metrics TLV for the associated STA.''' def runTest(self): - # Locate test participants in array - for dev in self.dev: - if dev.controller_entity: - controller = dev.controller_entity - if dev.agent_entity: - agent = dev.agent_entity + # Locate test participants + controller = self.dev.DUT.controller_entity + agent = self.dev.lan.agent_entity + sta = self.dev.wifi + + # This test doesn't work for real HW. + # Skip it for prplWRT device. + # TODO: Remove as soon, as test works for prplWRT device + if self.dev.DUT is PrplMeshPrplWRT: + self.skipTest("This test isn't ready for prplWRT devices") # Regression check - # Don't connect not existing STAtion - dev.wired_sniffer.start(self.__class__.__name__ + "-" + dev.name) + # Don't connect nonexistent Station + self.dev.lan.wired_sniffer.start(self.__class__.__name__ + "-" + self.dev.lan.name) sta_mac = "11:11:33:44:55:66" debug("Send link metrics query for unconnected STA") controller.ucc_socket.dev_send_1905(agent.mac, 0x800D, @@ -38,10 +43,8 @@ def runTest(self): timeout=30) time.sleep(1) - sta = Station.create() debug('sta: {}'.format(sta.mac)) - - agent.radios[0].vaps[0].associate(sta) + sta.wifi_connect(agent.radios[0].vaps[0]) time.sleep(1) @@ -52,13 +55,10 @@ def runTest(self): self.check_log(agent, "Send AssociatedStaLinkMetrics to controller, mid = {}".format(mid), timeout=30) - dev.agent_entity.radios[0].vaps[0].disassociate(sta) + sta.wifi_disconnect(agent.radios[0].vaps[0]) @classmethod def teardown_class(cls): """Teardown method, optional for boardfarm tests.""" test = cls.test_obj - for dev in test.dev: - if dev.agent_entity: - print("Sniffer - stop") - dev.wired_sniffer.stop() + test.dev.lan.wired_sniffer.stop() diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/testsuites.cfg b/tests/boardfarm_plugins/boardfarm_prplmesh/testsuites.cfg index 004c17c028..d441fb2640 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/testsuites.cfg +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/testsuites.cfg @@ -6,3 +6,4 @@ [test_flows] InitialApConfig ApConfigRenew +ClientAssociationLinkMetrics From f6cfeea79b03fd851413e5504fe05f6966517b5c Mon Sep 17 00:00:00 2001 From: Sinan Akpolat Date: Thu, 25 Jun 2020 00:57:07 +0300 Subject: [PATCH 105/453] tests: wrap exceptions thrown by individual tests This way script can continue executing the next test even if one of tests throws an exception. Also we can use assert statements inside tests since AssertionErrors are handled and they fail the test with an assertion failed message. If we want to fail the test when an assertion has failed we can do the following: assert False, "Some assertion failed and we don't want to continue" produces FAIL: Some assertion failed and we don't want to continue If we don't add an assertion failed message a generic "Assertion failed" message will be printed, so please add messages to assert statements. assert False produces FAIL: Assertion failed But, if self.fail() is called somewhere with a proper message and we want to end the test there without adding anything to that message you can assert without a message. self.fail("Something failed and we don't want to go on") assert False produces FAIL: Something failed and we don't want to go on When a test throws an unexpected run-time error the test is marked as failed and a stack trace is printed in debug mode. FAIL: Test failed unexpectedly: SomeRuntimeException('some error message') Traceback (most recent call last): ... stack trace showing the method ... which has thrown the unhandled exception SomeRuntimeException: some error message Please make sure to wrap all exceptions and throw only AssertionErrors to fail the tests. Signed-off-by: Sinan Akpolat --- tests/test_flows.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_flows.py b/tests/test_flows.py index 065e806d22..4e8d9c909a 100755 --- a/tests/test_flows.py +++ b/tests/test_flows.py @@ -10,6 +10,7 @@ import os import sys import time +import traceback from typing import Callable, Union import connmap @@ -278,6 +279,17 @@ def run_tests(self, tests): self.check_error = 0 try: getattr(self, test_full)() + except AssertionError as ae: + # do not add empty message if test has already been marked as failed + # and AssertionError does not contain a message + if str(ae): + self.fail("{}".format(ae)) + elif not self.check_error: + self.fail("Assertion failed") + + except Exception as e: + self.fail("Test failed unexpectedly: {}\n{}" + .format(e.__repr__(), traceback.format_exc())) finally: env.wired_sniffer.stop() if self.check_error != 0: From 54df875359737d1573c9a7ee9833fac69c0a4abd Mon Sep 17 00:00:00 2001 From: Sinan Akpolat Date: Fri, 26 Jun 2020 18:35:15 +0300 Subject: [PATCH 106/453] tests: raise exception instead of returning None in check CMDU methods Signed-off-by: Sinan Akpolat --- tests/test_flows.py | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/tests/test_flows.py b/tests/test_flows.py index 4e8d9c909a..ee10805df2 100755 --- a/tests/test_flows.py +++ b/tests/test_flows.py @@ -11,7 +11,7 @@ import sys import time import traceback -from typing import Callable, Union +from typing import Callable, Union, NoReturn import connmap import environment as env @@ -78,8 +78,7 @@ def check_cmdu( """ debug("Checking for CMDU {}".format(msg)) result = env.wired_sniffer.get_cmdu_capture(match_function) - if not result: - self.fail("No CMDU {} found".format(msg)) + assert result, "No CMDU {} found".format(msg) return result def check_cmdu_type( @@ -115,20 +114,19 @@ def check_cmdu_type( """ debug("Checking for CMDU {} (0x{:04x}) from {}".format(msg, msg_type, eth_src)) result = env.wired_sniffer.get_cmdu_capture_type(msg_type, eth_src, eth_dst, mid) - if not result: - self.fail("No CMDU {} found".format(msg)) + assert result, "No CMDU {} found".format(msg) return result def check_cmdu_type_single( self, msg: str, msg_type: int, eth_src: str, eth_dst: str = None, mid: int = None - ) -> Union[sniffer.Packet, None]: + ) -> sniffer.Packet: '''Like check_cmdu_type, but also check that only a single CMDU is found.''' cmdus = self.check_cmdu_type(msg, msg_type, eth_src, eth_dst, mid) if not cmdus: - return None # Failure already reported by check_cmdu + assert False # Failure already reported by check_cmdu if len(cmdus) > 1: self.fail("Multiple CMDUs {} found".format(msg)) - return None + assert False return cmdus[0] def check_no_cmdu_type( @@ -141,10 +139,11 @@ def check_no_cmdu_type( self.fail("Unexpected CMDU {}".format(msg)) for packet in result: debug(" {}".format(packet)) + assert False return result def check_cmdu_has_tlvs( - self, packet: Union[sniffer.Packet, None], tlv_type: int + self, packet: sniffer.Packet, tlv_type: int ) -> [sniffer.Tlv]: '''Check that the packet has at least one TLV of the given type. @@ -174,42 +173,38 @@ def check_cmdu_has_tlvs( if not tlvs: self.fail("No TLV of type 0x{:02x} found in packet".format(tlv_type)) debug(" {}".format(packet)) + assert False return tlvs def check_cmdu_has_tlv_single( self, packet: Union[sniffer.Packet, None], tlv_type: int - ) -> Union[sniffer.Tlv, None]: + ) -> sniffer.Tlv: '''Like check_cmdu_has_tlvs, but also check that only one TLV of that type is found.''' tlvs = self.check_cmdu_has_tlvs(packet, tlv_type) if not tlvs: - return None + assert False if len(tlvs) > 1: self.fail("More than one ({}) TLVs of type 0x{:02x} found".format(len(tlvs), tlv_type)) debug(" {}".format(packet)) - return None + assert False return tlvs[0] def check_cmdu_has_tlvs_exact( self, packet: Union[sniffer.Packet, None], tlvs: [sniffer.Tlv] - ) -> None: + ) -> NoReturn: '''Check that the CMDU has exactly the TLVs given.''' - if not packet: - return False - if not packet.ieee1905: - self.fail("Packet is not IEEE1905: {}".format(packet)) - return False + assert packet, "Packet not found" + assert packet.ieee1905, "Packet is not IEEE1905: {}".format(packet) + packet_tlvs = list(packet.ieee1905_tlvs) - result = True for t in tlvs: if t in packet_tlvs: packet_tlvs.remove(t) else: - self.fail("Packet misses tlv:\n {}".format(str(t))) - result = False - if packet_tlvs: - self.fail("Packet has unexpected tlvs:\n {}".format("\n ".join(map(str, packet_tlvs)))) - result = False - return result + assert False, "Packet misses tlv:\n {}".format(str(t)) + + assert not packet_tlvs, "Packet has unexpected tlvs:\n {}".format( + "\n ".join(map(str, packet_tlvs))) def check_topology_notification(self, eth_src: str, neighbors: list, sta: env.Station, event: env.StationEvent, bssid: str) -> bool: From 80c7d9200840aa16e576b71e324c62afe4e74158 Mon Sep 17 00:00:00 2001 From: Sinan Akpolat Date: Mon, 29 Jun 2020 01:35:10 +0300 Subject: [PATCH 107/453] tests: add method to check fail conditions without terminating the test Prepare for "tests: test_link_metric_query: use assert statements" and "tests: add method to check fail conditions without terminating the test" Signed-off-by: Sinan Akpolat --- tests/test_flows.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/test_flows.py b/tests/test_flows.py index ee10805df2..fb293101d0 100755 --- a/tests/test_flows.py +++ b/tests/test_flows.py @@ -11,7 +11,7 @@ import sys import time import traceback -from typing import Callable, Union, NoReturn +from typing import Callable, Union, Any, NoReturn import connmap import environment as env @@ -262,6 +262,15 @@ def check_topology_notification(self, eth_src: str, neighbors: list, return True + def safe_check_obj_attribute(self, obj: object, attrib_name: str, + expected_val: Any, fail_str: str) -> NoReturn: + """Check if expected attrib exists first, fail test if it does not exist""" + try: + if getattr(obj, attrib_name) != expected_val: + self.fail(fail_str) + except AttributeError: + self.fail("{} has no attribute {}".format(type(obj).__name__, attrib_name)) + def run_tests(self, tests): '''Run all tests as specified on the command line.''' total_errors = 0 From 104087f2e7c1d0da6f72a05616e159f067105d9a Mon Sep 17 00:00:00 2001 From: Sinan Akpolat Date: Fri, 26 Jun 2020 18:52:28 +0300 Subject: [PATCH 108/453] tests: test_link_metric_query: use sniffer and assert statements Signed-off-by: Sinan Akpolat --- tests/test_flows.py | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/tests/test_flows.py b/tests/test_flows.py index fb293101d0..c8126c42f1 100755 --- a/tests/test_flows.py +++ b/tests/test_flows.py @@ -711,17 +711,32 @@ def test_ap_capability_query(self): self.check_log(env.controller, "AP_CAPABILITY_REPORT_MESSAGE") def test_link_metric_query(self): - env.controller.dev_send_1905(env.agents[0].mac, 0x0005, - tlv(0x08, 0x0002, "0x00 0x02")) + mid = env.controller.dev_send_1905(env.agents[0].mac, 0x0005, + tlv(0x08, 0x0002, "0x00 0x02")) time.sleep(1) - debug("Confirming link metric query has been received on agent") - self.check_log(env.agents[0], "Received LINK_METRIC_QUERY_MESSAGE") + query = self.check_cmdu_type_single("link metric query", 0x0005, + env.controller.mac, env.agents[0].mac, + mid) + query_tlv = self.check_cmdu_has_tlv_single(query, 0x08) + + debug("Checking query type and queried metrics are correct") + self.safe_check_obj_attribute(query_tlv, 'link_metric_query_type', str(0x00), + "Query type is not 'All neighbors'") + self.safe_check_obj_attribute(query_tlv, 'link_metrics_requested', str(0x02), + "Metrics for both Tx and Rx is not requested") + + resp = self.check_cmdu_type_single("link metric response", 0x0006, + env.agents[0].mac, env.controller.mac, + mid) + + debug("Checking response contains both Tx and Rx metrics") + assert self.check_cmdu_has_tlvs(resp, 0x09) + assert self.check_cmdu_has_tlvs(resp, 0x0a) - debug("Confirming link metric response has been received on controller") - self.check_log(env.controller, "Received LINK_METRIC_RESPONSE_MESSAGE") - self.check_log(env.controller, "Received TLV_TRANSMITTER_LINK_METRIC") - self.check_log(env.controller, "Received TLV_RECEIVER_LINK_METRIC") + # TODO: we can't verify each reported link because + # TODO: tshark reports all tlv types using same key + # TODO: postponing test implementation until this is solved def test_combined_infra_metrics(self): From 4333b5a3e7c49ecd6313e3de6930cda2e451f152 Mon Sep 17 00:00:00 2001 From: Sinan Akpolat Date: Mon, 29 Jun 2020 01:18:59 +0300 Subject: [PATCH 109/453] tests: test_client_capability_query: split the test and use sniffer and assert statements The test is split into two tests. One of them is testing the case where there is no client connected and client capability query is replied with a report containing an error. The other one is testing the case where one client is connected and its association frame is verified. The base of the test where client capability query is sent and a valid report is returned is tested in base_test_capability_query to avoid code duplication. Signed-off-by: Sinan Akpolat --- tests/test_flows.py | 111 +++++++++++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 43 deletions(-) diff --git a/tests/test_flows.py b/tests/test_flows.py index c8126c42f1..37706b6e35 100755 --- a/tests/test_flows.py +++ b/tests/test_flows.py @@ -841,58 +841,83 @@ def test_combined_infra_metrics(self): vap1.disassociate(sta1) vap2.disassociate(sta2) - def test_client_capability_query(self): - sta1 = env.Station.create() - sta2 = env.Station.create() + def base_test_client_capability_query(self, sta: env.Station): + mid = env.controller.dev_send_1905(env.agents[0].mac, 0x8009, tlv( + 0x90, 0x000C, '{} {}'.format(env.agents[0].radios[0].mac, sta.mac))) + time.sleep(1) + + query = self.check_cmdu_type_single("client capability query", 0x8009, + env.controller.mac, env.agents[0].mac, mid) + + query_tlv = self.check_cmdu_has_tlv_single(query, 0x90) + self.safe_check_obj_attribute(query_tlv, 'client_info_mac_addr', sta.mac, + "Wrong mac address in query") + self.safe_check_obj_attribute(query_tlv, 'client_info_bssid', + env.agents[0].radios[0].mac, + "Wrong bssid in query") - association_frame = """00 0e 4d 75 6c 74 69 2d 41 50 2d 32 34 47 2d 31 -01 08 02 04 0b 0c 12 16 18 24 21 02 00 14 30 14 -01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f -ac 02 00 00 32 04 30 48 60 6c 3b 10 51 51 53 54 -73 74 75 76 77 78 7c 7d 7e 7f 80 82 3b 16 0c 01 -02 03 04 05 0c 16 17 18 19 1a 1b 1c 1d 1e 1f 20 -21 80 81 82 46 05 70 00 00 00 00 46 05 71 50 50 -00 04 7f 0a 04 00 0a 82 21 40 00 40 80 00 dd 07 -00 50 f2 02 00 01 00 2d 1a 2d 11 03 ff ff 00 00 -00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 e6 -e1 09 00 bf 0c b0 79 d1 33 fa ff 0c 03 fa ff 0c -03 c7 01 10 """ + report = self.check_cmdu_type_single("client capability report", 0x800a, + env.agents[0].mac, env.controller.mac, mid) + + client_info_tlv = self.check_cmdu_has_tlv_single(report, 0x90) + self.safe_check_obj_attribute(client_info_tlv, 'client_info_mac_addr', sta.mac, + "Wrong mac address in report") + self.safe_check_obj_attribute(client_info_tlv, 'client_info_bssid', + env.agents[0].radios[0].mac, + "Wrong bssid in report") + return report + + def test_client_capability_query_fails_with_no_sta(self): + sta = env.Station.create() debug("Send client capability query for unconnected STA") - env.controller.dev_send_1905(env.agents[0].mac, 0x8009, - tlv(0x90, 0x000C, - '{} {}'.format(env.agents[0].radios[0].mac, sta1.mac))) - time.sleep(1) - debug("Confirming client capability query has been received on agent") - # check that both radio agents received it, in the future we'll add a check to verify which - # radio the query was intended for. - self.check_log(env.agents[0], r"CLIENT_CAPABILITY_QUERY_MESSAGE") + report = self.base_test_client_capability_query(sta) - debug("Confirming client capability report message has been received on controller") - self.check_log(env.controller, r"Received CLIENT_CAPABILITY_REPORT_MESSAGE") - self.check_log(env.controller, - r"Result Code= FAILURE, client MAC= {}, BSSID= {}" - .format(sta1.mac, env.agents[0].radios[0].mac)) + cap_report_tlv = self.check_cmdu_has_tlv_single(report, 0x91) + self.safe_check_obj_attribute(cap_report_tlv, 'client_capability_result', '0x00000001', + "Capability query was successful for disconnected STA") - debug("Connect dummy STA to wlan0") - env.agents[0].radios[0].vaps[0].associate(sta2) + error_tlv = self.check_cmdu_has_tlv_single(report, 0xa3) + self.safe_check_obj_attribute(error_tlv, 'error_code_reason', '0x00000002', + "Wrong error reason code") + self.safe_check_obj_attribute(error_tlv, 'error_code_mac_addr', sta.mac, + "Wrong mac address in error code") - debug("Send client capability query for connected STA") - env.controller.dev_send_1905(env.agents[0].mac, 0x8009, - tlv(0x90, 0x000C, - '{} {}'.format(env.agents[0].radios[0].mac, sta2.mac))) - time.sleep(1) + def test_client_capability_query_successful(self): + sta = env.Station.create() - debug("Confirming client capability report message has been received on controller") - self.check_log(env.controller, r"Received CLIENT_CAPABILITY_REPORT_MESSAGE") - self.check_log(env.controller, - r"Result Code= SUCCESS, client MAC= {}, BSSID= {}" - .format(sta2.mac, env.agents[0].radios[0].mac)) + expected_association_frame = "00:0e:4d:75:6c:74:69:2d:41:50:2d:32:34:47:2d:31:"\ + "01:08:02:04:0b:0c:12:16:18:24:21:02:00:14:30:14:"\ + "01:00:00:0f:ac:04:01:00:00:0f:ac:04:01:00:00:0f:"\ + "ac:02:00:00:32:04:30:48:60:6c:3b:10:51:51:53:54:"\ + "73:74:75:76:77:78:7c:7d:7e:7f:80:82:3b:16:0c:01:"\ + "02:03:04:05:0c:16:17:18:19:1a:1b:1c:1d:1e:1f:20:"\ + "21:80:81:82:46:05:70:00:00:00:00:46:05:71:50:50:"\ + "00:04:7f:0a:04:00:0a:82:21:40:00:40:80:00:dd:07:"\ + "00:50:f2:02:00:01:00:2d:1a:2d:11:03:ff:ff:00:00:"\ + "00:00:00:00:00:00:00:00:00:00:00:00:00:00:18:e6:"\ + "e1:09:00:bf:0c:b0:79:d1:33:fa:ff:0c:03:fa:ff:0c:"\ + "03:c7:01:10" + # connect a station + debug("Connect dummy STA to wlan0") + env.agents[0].radios[0].vaps[0].associate(sta) - for line in association_frame.splitlines(): - self.check_log(env.controller, r"{}".format(line)) + # then check capability query is successful with connected station + try: + report = self.base_test_client_capability_query(sta) - env.agents[0].radios[0].vaps[0].disassociate(sta2) + cap_report_tlv = self.check_cmdu_has_tlvs(report, 0x91)[0] + self.safe_check_obj_attribute(cap_report_tlv, 'client_capability_result', '0x00000000', + "Capability report result is not successful") + try: + if cap_report_tlv.client_capability_frame != expected_association_frame: + self.fail("Capability report does not contain expected frame") + debug(f"Frame received\n{cap_report_tlv.client_capability_frame}") + debug(f"Frame expected\n{expected_association_frame}") + except AttributeError: + self.fail("Report does not contain capability frame") + finally: # cleanup + env.agents[0].radios[0].vaps[0].disassociate(sta) def test_client_association_dummy(self): sta = env.Station.create() From 163a5e11f46ec4db6d44e52cc98243c7435009a2 Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Mon, 29 Jun 2020 14:51:43 +0000 Subject: [PATCH 110/453] docker: builder: prplmesh build.sh use () Review comment fix for https://github.com/prplfoundation/prplMesh/pull/1426#discussion_r444788777 Explanation - using () opens a new shell so we don't need to cd to the original folder afterwards. Signed-off-by: Tomer Eliyahu --- tools/docker/builder/openwrt/scripts/build.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/docker/builder/openwrt/scripts/build.sh b/tools/docker/builder/openwrt/scripts/build.sh index 462e93d95e..62edf9df97 100755 --- a/tools/docker/builder/openwrt/scripts/build.sh +++ b/tools/docker/builder/openwrt/scripts/build.sh @@ -4,10 +4,9 @@ # write access to it, and openwrt needs to at least write '.source_dir': cp -r /home/openwrt/prplMesh_source /home/openwrt/prplMesh # We want to make sure that we do not keep anything built from the host: -cd /home/openwrt/prplMesh && \ - rm -rf build ipkg-* .built* .configured* .pkgdir .prepared .quilt_checked .source_dir +(cd /home/openwrt/prplMesh && \ + rm -rf build ipkg-* .built* .configured* .pkgdir .prepared .quilt_checked .source_dir) -cd /home/openwrt/openwrt make package/prplmesh/prepare USE_SOURCE_DIR="/home/openwrt/prplMesh" V=s make package/prplmesh/compile V=sc -j"$(nproc)" mkdir -p artifacts From 5d316bb350b68561311470ef18c1f1b1340d330e Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Mon, 29 Jun 2020 21:39:06 +0000 Subject: [PATCH 111/453] docker: builder: openwrt bump to prplwrt-1.0-rc1-prplmesh Upgrade prplWrt to prplwrt-1.0-rc1-prplmesh: - update prplwrt hash to latest prplwrt-1.0-rc1-prplmesh - update prpl-feed hash to latest prpl-19.07 - update netgear-rax40.yml to latest hashes on all repos - remove workaround of removing the tmp folder which is no longer needed - add axepoint support - bring back yq and profile_feeds for fixed hashes (review fixes for Signed-off-by: Tomer Eliyahu --- tools/docker/builder/openwrt/Dockerfile | 6 +++++ tools/docker/builder/openwrt/build.sh | 11 +++++--- .../openwrt/profiles_feeds/netgear-rax40.yml | 27 +++++++++++++++++++ .../builder/openwrt/scripts/build-openwrt.sh | 13 +++++++-- 4 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml diff --git a/tools/docker/builder/openwrt/Dockerfile b/tools/docker/builder/openwrt/Dockerfile index 7c655d1ec4..9073a1ef3c 100644 --- a/tools/docker/builder/openwrt/Dockerfile +++ b/tools/docker/builder/openwrt/Dockerfile @@ -15,6 +15,11 @@ RUN apt-get update \ build-essential libncurses5 libncurses5-dev python python3 \ unzip git ca-certificates gawk wget file bash \ python-yaml python3-yaml rsync less vim gnupg software-properties-common \ + # yq is available in a separate ppa (needs gnupg and software-properties-common): + && if [ -n "$HTTP_PROXY" ]; then KEYSERVER_OPTIONS="--keyserver-options http-proxy=$HTTP_PROXY"; fi \ + && apt-key adv --keyserver keyserver.ubuntu.com $KEYSERVER_OPTIONS --recv-keys CC86BB64 \ + && add-apt-repository ppa:rmescandon/yq \ + && apt-get -y install --no-install-recommends yq \ && rm -rf /var/lib/apt/lists/* # Building tlvfs currently uses the docker # container's python (not the one from OpenWrt) @@ -77,6 +82,7 @@ RUN printf '\033[1;35m%s Cloning prplWrt\n\033[0m' "$(date --iso-8601=seconds -- WORKDIR /home/openwrt/openwrt +COPY --chown=openwrt:openwrt profiles_feeds/ /home/openwrt/openwrt/profiles_feeds COPY --chown=openwrt:openwrt scripts/build-openwrt.sh /home/openwrt/openwrt/scripts/build-openwrt.sh #### diff --git a/tools/docker/builder/openwrt/build.sh b/tools/docker/builder/openwrt/build.sh index 0fcda4bdb1..0e1c3af9df 100755 --- a/tools/docker/builder/openwrt/build.sh +++ b/tools/docker/builder/openwrt/build.sh @@ -117,6 +117,12 @@ main() { TARGET_PROFILE=DEVICE_NETGEAR_RAX40 PRPLMESH_VARIANT="-dwpal" ;; + axepoint) + TARGET_SYSTEM=intel_mips + SUBTARGET=xrx500 + TARGET_PROFILE=DEVICE_AX6000_2000_ETH_11AXUCI + PRPLMESH_VARIANT="-dwpal" + ;; *) err "Unknown target device: $TARGET_DEVICE" info "Currently supported targets are:" @@ -172,9 +178,8 @@ main() { VERBOSE=false IMAGE_ONLY=false OPENWRT_REPOSITORY='https://git.prpl.dev/prplmesh/prplwrt.git' -OPENWRT_VERSION='c9b7e11b9607b47e949c7ced508dafa844d27dd0' -# TODO use hash instead of branch -PRPL_FEED='https://git.prpl.dev/prplmesh/feed-prpl.git^590ba854951ec3a24594c3e030980edb9cbe18ed' +OPENWRT_VERSION='f5f3a2cdba6102cffb10d442fae8a8fb67b61d81' +PRPL_FEED='https://git.prpl.dev/prplmesh/feed-prpl.git^89e6602655713f8487c72d8d636daa610d76a468' PRPLMESH_VARIANT="-nl80211" DOCKER_TARGET_STAGE="prplmesh-builder" diff --git a/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml b/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml new file mode 100644 index 0000000000..c357947c83 --- /dev/null +++ b/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml @@ -0,0 +1,27 @@ +- name: feed_target_mips + uri: https://intel.prpl.dev/intel/feed_target_mips.git + hash: 245dca06475e84571e4ccb5e02eb4e336ba77cbe +- name: feed_datapath + uri: https://intel.prpl.dev/intel/feed_datapath.git + hash: 23afe7e659ed6717224659aef74af2bb11d8091a +- name: feed_ppa + uri: https://intel.prpl.dev/intel/feed_ppa.git + hash: 4f49fa34bbd51c7dd218df164e32c17694bed421 +- name: feed_gphy_firmware + uri: https://intel.prpl.dev/intel/feed_gphy_firmware.git + hash: cbf75f2abde587ac2c5462d117b98e3dadaae5b6 +- name: feed_switch_api + uri: https://intel.prpl.dev/intel/feed_switch_api.git + hash: af078af5408654ca2e759ea7afcf92163282e86e +- name: feed_wlan_6x + uri: https://intel.prpl.dev/prplmesh/feed_wlan_6x.git + hash: 1acf2f19c489c72478d3ae74ee59b5fb06a6ee7e +- name: feed_prpl + uri: https://git.prpl.dev/prplmesh/feed-prpl.git + hash: 89e6602655713f8487c72d8d636daa610d76a468 +- name: feed_opensource_apps + uri: https://intel.prpl.dev/prplmesh/feed_opensource_apps.git + hash: f22c4f0b1d594598b1d38298fba513e5948dd1e4 +- name: feed_pending + uri: https://intel.prpl.dev/intel/feed-pending.git + hash: 352365b31f968ab37e772b23c30ea32dbff9e337 diff --git a/tools/docker/builder/openwrt/scripts/build-openwrt.sh b/tools/docker/builder/openwrt/scripts/build-openwrt.sh index 0bd71ff3eb..a94b3e68ba 100755 --- a/tools/docker/builder/openwrt/scripts/build-openwrt.sh +++ b/tools/docker/builder/openwrt/scripts/build-openwrt.sh @@ -12,8 +12,17 @@ mkdir -p files/etc printf '%s=%s\n' "OPENWRT_REPOSITORY" "$OPENWRT_REPOSITORY" >> files/etc/prplwrt-version printf '%s=%s\n' "OPENWRT_VERSION" "$OPENWRT_VERSION" >> files/etc/prplwrt-version if [ "$TARGET_PROFILE" = DEVICE_NETGEAR_RAX40 ] ; then - ./scripts/gen_config.py intel_mips - cat profiles/intel_mips.yml >> files/etc/prplwrt-version + # Add prplmesh to the list of packages of the profile: + sed -i 's/packages:/packages:\n - prplmesh-dwpal/g' profiles/intel_mips.yml + yq write --inplace profiles/netgear_rax40.yml feeds -f profiles_feeds/netgear-rax40.yml + ./scripts/gen_config.py netgear_rax40 debug + cat profiles_feeds/netgear-rax40.yml >> files/etc/prplwrt-version +elif [ "$TARGET_PROFILE" = DEVICE_AX6000_2000_ETH_11AXUCI ]; then + # Add prplmesh to the list of packages of the profile: + sed -i 's/packages:/packages:\n - prplmesh-dwpal/g' profiles/axepoint.yml + yq write --inplace profiles/axepoint.yml feeds -f profiles_feeds/netgear-rax40.yml + ./scripts/gen_config.py axepoint debug + cat profiles_feeds/netgear-rax40.yml >> files/etc/prplwrt-version else cp feeds.conf.default feeds.conf echo "src-git prpl $PRPL_FEED" >> feeds.conf From 98db4fb2f3a96132e36b21a91fc8c8ff513a670e Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Mon, 29 Jun 2020 21:44:35 +0000 Subject: [PATCH 112/453] .gitlab-ci.yml: add build-for-axepoint Add build-for-axepoint stage for building axepoint image. Check that some test still passes: MAP-4.2.1:netgear-rax40 Signed-off-by: Tomer Eliyahu --- .gitlab-ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 09792ce3c7..c64ba84133 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -169,6 +169,7 @@ upload-artifacts: needs: - build-in-docker - build-for-netgear-rax40 + - build-for-axepoint - build-for-glinet-b1300 - build-for-turris-omnia @@ -262,6 +263,11 @@ build-for-netgear-rax40: variables: TARGET_DEVICE: "netgear-rax40" +build-for-axepoint: + extends: .build-for-openwrt + variables: + TARGET_DEVICE: "axepoint" + test-on-turris-omnia: extends: .test-on-target variables: From 3de4a9460e7531719e133b5b67948c831bc6d0c9 Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Tue, 30 Jun 2020 08:03:56 +0000 Subject: [PATCH 113/453] tools: deploy_firmware.py remove overlay When flashing a new image, intel uboot retains the rootfs_data partition (overlay), so make sure to remove the relvant parts from the overlay before rebooting. Check that some test still passes: MAP-4.2.1:netgear-rax40 Signed-off-by: Tomer Eliyahu --- tools/deploy_firmware.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/deploy_firmware.py b/tools/deploy_firmware.py index 6e4d514194..8717d7986a 100755 --- a/tools/deploy_firmware.py +++ b/tools/deploy_firmware.py @@ -178,7 +178,8 @@ def upgrade_uboot(self): # firmware doesn't have working wireless interfaces it # will prevent it from rebooting: shell.sendline("pgrep -f 'S99prplmesh boot' | xargs kill") - # reboot: + # remove overlay and reboot + shell.sendline("rm -rf /overlay/upper/usr /overlay/upper/opt") shell.sendline("reboot -f") shell.expect(["Hit any key to stop autoboot:", pexpect.EOF, pexpect.TIMEOUT], timeout=120) From ae991c3c3bde0cd7419da6acf0564435cfcf1937 Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Thu, 2 Jul 2020 11:49:44 +0000 Subject: [PATCH 114/453] tools:docker:builder openwrt support multiple builds Add intel_mips target which allows to build both rax40 and axepoint in the same build. Check that some test still passes: MAP-4.2.1:netgear-rax40 Signed-off-by: Tomer Eliyahu --- tools/docker/builder/openwrt/build.sh | 8 +++++++- tools/docker/builder/openwrt/scripts/build-openwrt.sh | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/docker/builder/openwrt/build.sh b/tools/docker/builder/openwrt/build.sh index 0e1c3af9df..9e458d2bb3 100755 --- a/tools/docker/builder/openwrt/build.sh +++ b/tools/docker/builder/openwrt/build.sh @@ -83,7 +83,7 @@ main() { eval set -- "$OPTS" - SUPPORTED_TARGETS="turris-omnia glinet-b1300 netgear-rax40" + SUPPORTED_TARGETS="turris-omnia glinet-b1300 netgear-rax40 axepoint intel_mips" while true; do case "$1" in @@ -123,6 +123,12 @@ main() { TARGET_PROFILE=DEVICE_AX6000_2000_ETH_11AXUCI PRPLMESH_VARIANT="-dwpal" ;; + intel_mips) + TARGET_SYSTEM=intel_mips + SUBTARGET=xrx500 + TARGET_PROFILE=INTEL_MIPS + PRPLMESH_VARIANT="-dwpal" + ;; *) err "Unknown target device: $TARGET_DEVICE" info "Currently supported targets are:" diff --git a/tools/docker/builder/openwrt/scripts/build-openwrt.sh b/tools/docker/builder/openwrt/scripts/build-openwrt.sh index a94b3e68ba..dec507b729 100755 --- a/tools/docker/builder/openwrt/scripts/build-openwrt.sh +++ b/tools/docker/builder/openwrt/scripts/build-openwrt.sh @@ -23,6 +23,12 @@ elif [ "$TARGET_PROFILE" = DEVICE_AX6000_2000_ETH_11AXUCI ]; then yq write --inplace profiles/axepoint.yml feeds -f profiles_feeds/netgear-rax40.yml ./scripts/gen_config.py axepoint debug cat profiles_feeds/netgear-rax40.yml >> files/etc/prplwrt-version +elif [ "$TARGET_PROFILE" = INTEL_MIPS ]; then + # Add prplmesh to the list of packages of the profile: + sed -i 's/packages:/packages:\n - prplmesh-dwpal/g' profiles/intel_mips.yml + yq write --inplace profiles/intel_mips.yml feeds -f profiles_feeds/netgear-rax40.yml + ./scripts/gen_config.py intel_mips debug + cat profiles_feeds/netgear-rax40.yml >> files/etc/prplwrt-version else cp feeds.conf.default feeds.conf echo "src-git prpl $PRPL_FEED" >> feeds.conf From 0a5550e7a1d9c77894d73121e286a08a53964d1e Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Thu, 2 Jul 2020 15:53:03 +0000 Subject: [PATCH 115/453] tools:docker:builder openwrt refactor build scripts Refactor build scripts based on https://github.com/prplfoundation/prplMesh/pull/1506#discussion_r448964439 Signed-off-by: Tomer Eliyahu --- tools/docker/builder/openwrt/Dockerfile | 5 ++ tools/docker/builder/openwrt/build.sh | 21 ++---- .../builder/openwrt/scripts/build-openwrt.sh | 66 ++++++++----------- 3 files changed, 39 insertions(+), 53 deletions(-) diff --git a/tools/docker/builder/openwrt/Dockerfile b/tools/docker/builder/openwrt/Dockerfile index 9073a1ef3c..b030c20c6d 100644 --- a/tools/docker/builder/openwrt/Dockerfile +++ b/tools/docker/builder/openwrt/Dockerfile @@ -73,6 +73,11 @@ ENV SUBTARGET=$SUBTARGET ARG TARGET_PROFILE ENV TARGET_PROFILE=$TARGET_PROFILE +# Target device used for prplwrt gen_config.py script (intel_mips/axepoint/netgear-rax40). +# Example: TARGET_DEVICE=axepoint +ARG TARGET_DEVICE +ENV TARGET_DEVICE=$TARGET_DEVICE + WORKDIR /home/openwrt RUN printf '\033[1;35m%s Cloning prplWrt\n\033[0m' "$(date --iso-8601=seconds --universal)" \ diff --git a/tools/docker/builder/openwrt/build.sh b/tools/docker/builder/openwrt/build.sh index 9e458d2bb3..8e5dbc4aca 100755 --- a/tools/docker/builder/openwrt/build.sh +++ b/tools/docker/builder/openwrt/build.sh @@ -38,6 +38,7 @@ build_image() { --build-arg OPENWRT_VERSION="$OPENWRT_VERSION" \ --build-arg TARGET_SYSTEM="$TARGET_SYSTEM" \ --build-arg SUBTARGET="$SUBTARGET" \ + --build-arg TARGET_DEVICE="$TARGET_DEVICE" \ --build-arg TARGET_PROFILE="$TARGET_PROFILE" \ --build-arg PRPL_FEED="$PRPL_FEED" \ --build-arg PRPLMESH_VARIANT="$PRPLMESH_VARIANT" \ @@ -54,6 +55,7 @@ build_prplmesh() { --name "$container_name" \ -e TARGET_SYSTEM \ -e SUBTARGET \ + -e TARGET_DEVICE \ -e TARGET_PROFILE \ -e OPENWRT_VERSION \ -e PRPLMESH_VERSION \ @@ -111,23 +113,10 @@ main() { SUBTARGET=generic TARGET_PROFILE=DEVICE_glinet_gl-b1300 ;; - netgear-rax40) + netgear-rax40|axepoint|intel_mips) TARGET_SYSTEM=intel_mips SUBTARGET=xrx500 - TARGET_PROFILE=DEVICE_NETGEAR_RAX40 - PRPLMESH_VARIANT="-dwpal" - ;; - axepoint) - TARGET_SYSTEM=intel_mips - SUBTARGET=xrx500 - TARGET_PROFILE=DEVICE_AX6000_2000_ETH_11AXUCI - PRPLMESH_VARIANT="-dwpal" - ;; - intel_mips) - TARGET_SYSTEM=intel_mips - SUBTARGET=xrx500 - TARGET_PROFILE=INTEL_MIPS - PRPLMESH_VARIANT="-dwpal" + TARGET_PROFILE= ;; *) err "Unknown target device: $TARGET_DEVICE" @@ -184,7 +173,7 @@ main() { VERBOSE=false IMAGE_ONLY=false OPENWRT_REPOSITORY='https://git.prpl.dev/prplmesh/prplwrt.git' -OPENWRT_VERSION='f5f3a2cdba6102cffb10d442fae8a8fb67b61d81' +OPENWRT_VERSION='3d511d477e72bd1845c75101a7f3d4e00780991d' PRPL_FEED='https://git.prpl.dev/prplmesh/feed-prpl.git^89e6602655713f8487c72d8d636daa610d76a468' PRPLMESH_VARIANT="-nl80211" DOCKER_TARGET_STAGE="prplmesh-builder" diff --git a/tools/docker/builder/openwrt/scripts/build-openwrt.sh b/tools/docker/builder/openwrt/scripts/build-openwrt.sh index dec507b729..e3043e5c76 100755 --- a/tools/docker/builder/openwrt/scripts/build-openwrt.sh +++ b/tools/docker/builder/openwrt/scripts/build-openwrt.sh @@ -11,43 +11,35 @@ mkdir -p files/etc # We need to keep the hashes in the firmware, to later know if an upgrade is needed: printf '%s=%s\n' "OPENWRT_REPOSITORY" "$OPENWRT_REPOSITORY" >> files/etc/prplwrt-version printf '%s=%s\n' "OPENWRT_VERSION" "$OPENWRT_VERSION" >> files/etc/prplwrt-version -if [ "$TARGET_PROFILE" = DEVICE_NETGEAR_RAX40 ] ; then - # Add prplmesh to the list of packages of the profile: - sed -i 's/packages:/packages:\n - prplmesh-dwpal/g' profiles/intel_mips.yml - yq write --inplace profiles/netgear_rax40.yml feeds -f profiles_feeds/netgear-rax40.yml - ./scripts/gen_config.py netgear_rax40 debug - cat profiles_feeds/netgear-rax40.yml >> files/etc/prplwrt-version -elif [ "$TARGET_PROFILE" = DEVICE_AX6000_2000_ETH_11AXUCI ]; then - # Add prplmesh to the list of packages of the profile: - sed -i 's/packages:/packages:\n - prplmesh-dwpal/g' profiles/axepoint.yml - yq write --inplace profiles/axepoint.yml feeds -f profiles_feeds/netgear-rax40.yml - ./scripts/gen_config.py axepoint debug - cat profiles_feeds/netgear-rax40.yml >> files/etc/prplwrt-version -elif [ "$TARGET_PROFILE" = INTEL_MIPS ]; then - # Add prplmesh to the list of packages of the profile: - sed -i 's/packages:/packages:\n - prplmesh-dwpal/g' profiles/intel_mips.yml - yq write --inplace profiles/intel_mips.yml feeds -f profiles_feeds/netgear-rax40.yml - ./scripts/gen_config.py intel_mips debug - cat profiles_feeds/netgear-rax40.yml >> files/etc/prplwrt-version -else - cp feeds.conf.default feeds.conf - echo "src-git prpl $PRPL_FEED" >> feeds.conf - scripts/feeds update -a - scripts/feeds install -a - { - # note that the result from diffconfig.sh with a minimal - # configuration has the 3 CONFIG_TARGET items we set here, but NOT - # the individual CONFIG_TARGET_${SUBTARGET} and - # CONFIG_TARGET_${TARGET_PROFILE}, which means we don't need to - # set them. - echo "CONFIG_TARGET_${TARGET_SYSTEM}=y" - echo "CONFIG_TARGET_${TARGET_SYSTEM}_${SUBTARGET}=y" - echo "CONFIG_TARGET_${TARGET_SYSTEM}_${SUBTARGET}_${TARGET_PROFILE}=y" - echo "CONFIG_PACKAGE_prplmesh${PRPLMESH_VARIANT}=y" - } >> .config - make defconfig - printf '%s=%s\n' "PRPL_FEED" "$PRPL_FEED" >> files/etc/prplwrt-version -fi +case $TARGET_DEVICE in + netgear-rax40|axepoint|intel_mips) + # Add prplmesh to the list of packages of the profile: + sed -i 's/packages:/packages:\n - prplmesh-dwpal/g' profiles/"$TARGET_DEVICE".yml + yq write --inplace profiles/"$TARGET_DEVICE".yml feeds -f profiles_feeds/netgear-rax40.yml + ./scripts/gen_config.py "$TARGET_DEVICE" debug + cat profiles_feeds/netgear-rax40.yml >> files/etc/prplwrt-version + ;; + *) + cp feeds.conf.default feeds.conf + echo "src-git prpl $PRPL_FEED" >> feeds.conf + scripts/feeds update -a + scripts/feeds install -a + { + # note that the result from diffconfig.sh with a minimal + # configuration has the 3 CONFIG_TARGET items we set here, but NOT + # the individual CONFIG_TARGET_${SUBTARGET} and + # CONFIG_TARGET_${TARGET_PROFILE}, which means we don't need to + # set them. + echo "CONFIG_TARGET_${TARGET_SYSTEM}=y" + echo "CONFIG_TARGET_${TARGET_SYSTEM}_${SUBTARGET}=y" + echo "CONFIG_TARGET_${TARGET_SYSTEM}_${SUBTARGET}_${TARGET_PROFILE}=y" + echo "CONFIG_PACKAGE_prplmesh${PRPLMESH_VARIANT}=y" + } >> .config + make defconfig + printf '%s=%s\n' "PRPL_FEED" "$PRPL_FEED" >> files/etc/prplwrt-version + ;; +esac + printf '\033[1;35m%s Building prplWrt\n\033[0m' "$(date --iso-8601=seconds --universal)" make -j"$(nproc)" From fd247201c6cbea877709ae854b0f33f27f60f077 Mon Sep 17 00:00:00 2001 From: Sinan Akpolat Date: Mon, 29 Jun 2020 04:18:42 +0300 Subject: [PATCH 116/453] tests: sniffer: multiple tlvs with same type can be captured now If an ieee1905 packet contains multiple tlvs of same type they all will have the same key (e.g. "1905 receiver link metric") in tshark JSON output. When that output is parsed with json.loads() method only one of the tlvs will appear in the resulting Python dictionary. Now the first occurence of the key will be, for example "1905 receiver link metric" and subsequent keys will be "1905 receiver link metric 2", "1905 receiver link metric 3" etc. Signed-off-by: Sinan Akpolat --- tests/sniffer.py | 28 ++++++++++++++++++++++++++-- tests/test_flows.py | 3 ++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/tests/sniffer.py b/tests/sniffer.py index 1af11fbf08..5709f9940f 100644 --- a/tests/sniffer.py +++ b/tests/sniffer.py @@ -7,6 +7,7 @@ import os import json +from collections import OrderedDict import subprocess from opts import debug, err, status from typing import Callable @@ -145,10 +146,33 @@ def get_packet_capture(self): debug("tshark failed: {}".format(tshark_result.returncode)) # Regardless of the exit code, try to make something of the JSON that comes out, if any. try: - capture = json.loads(tshark_result.stdout) + # tlvs which have the same type are all recorded with the same key therefore we lose + # all but one of them if we use json.loads(tshark_result.stdout) directly. + # https://stackoverflow.com/questions/29321677/python-json-parser-allow-duplicate-keys + def rename_duplicate_key(key, dct): + counter = 0 + unique_key = key + + while unique_key in dct: + counter += 1 + unique_key = '{} {}'.format(key, counter + 1) + return unique_key + + def rename_duplicates(pairs): + dct = OrderedDict() + for key, value in pairs: + if key in dct: + key = rename_duplicate_key(key, dct) + dct[key] = value + + return dct + + decoder = json.JSONDecoder(object_pairs_hook=rename_duplicates) + capture = decoder.decode(tshark_result.stdout.decode('utf8')) + return [Packet(x) for x in capture] except json.JSONDecodeError as error: - err("capture JSON decoding failed: %s".format(error)) + err("capture JSON decoding failed: {}".format(error)) return [] def get_cmdu_capture(self, match_function: Callable[[Packet], bool]) -> [Packet]: diff --git a/tests/test_flows.py b/tests/test_flows.py index 37706b6e35..1847894686 100755 --- a/tests/test_flows.py +++ b/tests/test_flows.py @@ -289,7 +289,8 @@ def run_tests(self, tests): if str(ae): self.fail("{}".format(ae)) elif not self.check_error: - self.fail("Assertion failed") + self.fail("Assertion failed\n{}" + .format(traceback.format_exc())) except Exception as e: self.fail("Test failed unexpectedly: {}\n{}" From d5cbdbfcea67e1045e4f120b1a44f65e070e7d84 Mon Sep 17 00:00:00 2001 From: Sinan Akpolat Date: Mon, 29 Jun 2020 12:50:40 +0300 Subject: [PATCH 117/453] tests: test_link_metric_query: check all reported links Verify all the expected links are reported in link metric report. Report any extra links which should not have been in the link metric report. Signed-off-by: Sinan Akpolat --- tests/test_flows.py | 48 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/tests/test_flows.py b/tests/test_flows.py index 1847894686..44ad6d22c9 100755 --- a/tests/test_flows.py +++ b/tests/test_flows.py @@ -11,6 +11,7 @@ import sys import time import traceback +from collections import Counter from typing import Callable, Union, Any, NoReturn import connmap @@ -731,13 +732,46 @@ def test_link_metric_query(self): env.agents[0].mac, env.controller.mac, mid) - debug("Checking response contains both Tx and Rx metrics") - assert self.check_cmdu_has_tlvs(resp, 0x09) - assert self.check_cmdu_has_tlvs(resp, 0x0a) - - # TODO: we can't verify each reported link because - # TODO: tshark reports all tlv types using same key - # TODO: postponing test implementation until this is solved + debug("Checking response contains expected links to/from agent and nothing else") + # neighbor macs are based on the setup in "launch_environment_docker" method + expected_tx_link_neighbors = [env.controller.mac, env.agents[1].mac] + expected_rx_link_neighbors = [env.controller.mac, env.agents[1].mac] + actual_tx_links = self.check_cmdu_has_tlvs(resp, 0x09) + actual_rx_links = self.check_cmdu_has_tlvs(resp, 0x0a) + + def verify_links(links, expected_neighbors, link_type): + verified_neighbors = [] + unexpected_neighbors = [] + for link in links: + self.safe_check_obj_attribute(link, 'responder_mac_addr', env.agents[0].mac, + "Responder MAC address is wrong") + + try: + # a tshark (v3.2.4) bug causes "neighbor_mac_addr" field to + # show up as "responder_mac_addr_2" + if link.responder_mac_addr_2 in expected_neighbors: + verified_neighbors += [link.responder_mac_addr_2] + else: + unexpected_neighbors += [link.responder_mac_addr_2] + except AttributeError as e: + self.fail(e) + + # we expect each neighbor to appear only once + for neighbor, count in Counter(verified_neighbors).items(): + if count != 1: + self.fail("{} link to neighbor {} appears {} times." + "It was expected to appear only once" + .format(link_type, neighbor, count)) + + # report any extra neighbors that show up + for unexpected_neighbor in unexpected_neighbors: + self.fail("An unexpected {} link for neighbor with MAC address {} exists" + "It was expected to appear only once" + .format(link_type, unexpected_neighbor)) + + # check responder mac is our own mac, neighbor is one of the expected macs for each link + verify_links(actual_tx_links, expected_tx_link_neighbors, "tx") + verify_links(actual_rx_links, expected_rx_link_neighbors, "rx") def test_combined_infra_metrics(self): From d49ea954f296cd935f3fea149a2c01ff66f589cc Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Fri, 26 Jun 2020 20:09:55 +0300 Subject: [PATCH 118/453] tests: boardfarm: set agent as DUT in all setups We have 2 setups defined in boardfarm configuration file: dummy docker devices setup and RAX40 set up. In dummy docker devices setup first device (which is considered as DUT by boardfarm) is controller, "netgear-rax40-1" has agent as first device. As consequence, DUT device name for those 2 setups mean controller and agent respectively. To keep tests same for dummy and real devices, we should have persistent naming across all setups. So DUT have to be agent or controller across all tests. As we are testing agent, mainly. It makes sense to have it as DUT across all devices. Set agent as DUT for "prplmesh_docker" set up. Remove extra agent, as it not used in any of tests of "test_flows.py". Rename controller to "wan". Rename controller to wan in "netgear-rax40-1" set up. Signed-off-by: Anton Bilohai --- .../boardfarm_prplmesh/prplmesh_config.json | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json index 7ae9c49423..6a6a2d1998 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json @@ -2,17 +2,13 @@ "prplmesh_docker": { "name": "controller", "board_type": "prplmesh_docker", - "role": "controller", + "role": "agent", "conn_cmd": "", "devices": [ { - "name": "lan", - "type": "prplmesh_docker", - "conn_cmd": "" - }, - { - "name": "lan2", + "name": "wan", "type": "prplmesh_docker", + "role": "controller", "conn_cmd": "" }, { @@ -31,7 +27,7 @@ "conn_cmd": "cu -s 115200 -l /dev/ttyUSB0", "devices": [ { - "name": "controller", + "name": "wan", "type": "prplmesh_docker", "role": "controller", "docker_network": "prplMesh-net-rax40-1", From f1ce55525d0af13ce3a5984ab722869508eb4cfb Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Thu, 25 Jun 2020 16:00:54 +0300 Subject: [PATCH 119/453] tests: boardfarm: initial_ap_config.py: address devices by name In the "initial_ap_config" test we are locating devices by checking "agent_entity" field in the device class. This works only in case if all devices defined in boardfarm configuration are same (or have this field). Adding some device, which doesn't have such field will cause test to crash. Recently, we changed boardfarm configuration file to use names which are part of build-in boardfarm enum, as consequence we can address devices by name. So, we can now safely address devices by name and avoid crash described above. Test still will crash, if we try to reach non-defined in boardfarm configuration file device. Assign devices based on name, rather than search through whole array of devices given to the test. Reformatting due to changes of devices names. Signed-off-by: Anton Bilohai --- .../tests/initial_ap_config.py | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py index c959dadb21..b971044518 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/initial_ap_config.py @@ -10,35 +10,36 @@ class InitialApConfig(PrplMeshBaseTest): """Check initial configuration on device.""" def runTest(self): - for dev in self.dev: - if dev.agent_entity: - dev.wired_sniffer.start(self.__class__.__name__ + "-" + dev.name) + # Locate test participants + agent = self.dev.DUT.agent_entity - self.prplmesh_status_check(dev.agent_entity) - self.check_log(dev.agent_entity.radios[0], - r"\(WSC M2 Encrypted Settings\)") - self.check_log(dev.agent_entity.radios[1], - r"\(WSC M2 Encrypted Settings\)") - self.check_log(dev.agent_entity.radios[0], - r"WSC Global authentication success") - self.check_log(dev.agent_entity.radios[1], - r"WSC Global authentication success") - self.check_log(dev.agent_entity.radios[0], - r"KWA \(Key Wrap Auth\) success") - self.check_log(dev.agent_entity.radios[1], - r"KWA \(Key Wrap Auth\) success") + self.dev.DUT.wired_sniffer.start(self.__class__.__name__ + "-" + self.dev.DUT.name) + + self.prplmesh_status_check(agent) + self.check_log(agent.radios[0], + r"\(WSC M2 Encrypted Settings\)") + self.check_log(agent.radios[1], + r"\(WSC M2 Encrypted Settings\)") + self.check_log(agent.radios[0], + r"WSC Global authentication success") + self.check_log(agent.radios[1], + r"WSC Global authentication success") + self.check_log(agent.radios[0], + r"KWA \(Key Wrap Auth\) success") + self.check_log(agent.radios[1], + r"KWA \(Key Wrap Auth\) success") @classmethod def teardown_class(cls): """Teardown method, optional for boardfarm tests.""" test = cls.test_obj - for dev in test.dev: - if dev.agent_entity: - print("Sniffer - stop") - # Send Ctrl+C to the device to terminate "tail -f" - # Which is used to read log from device. Required only for tests on HW - try: - dev.agent_entity.device.send('\003') - except AttributeError: - pass - dev.wired_sniffer.stop() + print("Sniffer - stop") + test.dev.DUT.wired_sniffer.stop() + # Send additional Ctrl+C to the device to terminate "tail -f" + # Which is used to read log from device. Required only for tests on HW + try: + test.dev.DUT.agent_entity.device.send('\003') + except AttributeError: + # If AttributeError was raised - we are dealing with dummy devices. + # We don't have to additionaly send Ctrl+C for dummy devices. + pass From 9673d18ac97ddd3803798b6b5f7127beb62e37b4 Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Fri, 26 Jun 2020 13:34:20 +0300 Subject: [PATCH 120/453] tests: boardfarm: ap_config_renew.py: address devices by name Assign devices based on name, rather than search through whole array of devices given to the test. Reformatting due to changes of devices names. Signed-off-by: Anton Bilohai --- .../tests/ap_config_renew.py | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/ap_config_renew.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/ap_config_renew.py index aeebe2a07b..5ce4d52ac6 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/ap_config_renew.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/ap_config_renew.py @@ -14,14 +14,11 @@ class ApConfigRenew(PrplMeshBaseTest): """Check initial configuration on device.""" def runTest(self): - # Locate agents and controller - for dev in self.dev: - if dev.controller_entity: - controller = dev.controller_entity - if dev.agent_entity: - agent = dev.agent_entity + # Locate test participants + agent = self.dev.DUT.agent_entity + controller = self.dev.wan.controller_entity - dev.wired_sniffer.start(self.__class__.__name__ + "-" + dev.name) + self.dev.DUT.wired_sniffer.start(self.__class__.__name__ + "-" + self.dev.DUT.name) # Regression test: MAC address should be case insensitive mac_repeater1_upper = agent.mac.upper() controller.ucc_socket.cmd_reply("DEV_RESET_DEFAULT") @@ -35,7 +32,7 @@ def runTest(self): tlv(0x0F, 0x0001, "{0x00}"), tlv(0x10, 0x0001, "{0x00}")) - time.sleep(30) + time.sleep(5) self.check_log(agent.radios[0], r"ssid: Multi-AP-24G-1 .*" r"fronthaul: true backhaul: false", @@ -61,7 +58,13 @@ def runTest(self): def teardown_class(cls): """Teardown method, optional for boardfarm tests.""" test = cls.test_obj - for dev in test.dev: - if dev.agent_entity: - print("Sniffer - stop") - dev.wired_sniffer.stop() + print("Sniffer - stop") + test.dev.DUT.wired_sniffer.stop() + # Send additional Ctrl+C to the device to terminate "tail -f" + # Which is used to read log from device. Required only for tests on HW + try: + test.dev.DUT.agent_entity.device.send('\003') + except AttributeError: + # If AttributeError was raised - we are dealing with dummy devices. + # We don't have to additionaly send Ctrl+C for dummy devices. + pass From 3e075dd77e52276a91d7e00108b87b3a8a96bc03 Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Fri, 26 Jun 2020 20:19:38 +0300 Subject: [PATCH 121/453] tests: boardfarm: client_association_link_metrics.py: correct naming Due to changes in boardfarm configuration files, controller become the "wan" and agent is always the "DUT" Set "DUT" as agent, "wan" as controller. Signed-off-by: Anton Bilohai --- .../tests/client_association_link_metrics.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py index 3055c5463a..00c9a61499 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py @@ -21,8 +21,8 @@ class ClientAssociationLinkMetrics(PrplMeshBaseTest): def runTest(self): # Locate test participants - controller = self.dev.DUT.controller_entity - agent = self.dev.lan.agent_entity + agent = self.dev.DUT.agent_entity + controller = self.dev.wan.controller_entity sta = self.dev.wifi # This test doesn't work for real HW. @@ -33,7 +33,7 @@ def runTest(self): # Regression check # Don't connect nonexistent Station - self.dev.lan.wired_sniffer.start(self.__class__.__name__ + "-" + self.dev.lan.name) + self.dev.DUT.wired_sniffer.start(self.__class__.__name__ + "-" + self.dev.DUT.name) sta_mac = "11:11:33:44:55:66" debug("Send link metrics query for unconnected STA") controller.ucc_socket.dev_send_1905(agent.mac, 0x800D, @@ -61,4 +61,13 @@ def runTest(self): def teardown_class(cls): """Teardown method, optional for boardfarm tests.""" test = cls.test_obj - test.dev.lan.wired_sniffer.stop() + print("Sniffer - stop") + test.dev.DUT.wired_sniffer.stop() + # Send additional Ctrl+C to the device to terminate "tail -f" + # Which is used to read log from device. Required only for tests on HW + try: + test.dev.DUT.agent_entity.device.send('\003') + except AttributeError: + # If AttributeError was raised - we are dealing with dummy devices. + # We don't have to additionaly send Ctrl+C for dummy devices. + pass From f2ade90670934399d682366a949f23690a4c8a89 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Thu, 2 Jul 2020 19:58:24 +0200 Subject: [PATCH 122/453] tlvf: remove tlvAlMacAddressType header and source Remove tlvAlMacAddressType.h and tlvAlMacAddressType.cpp auto-generated files. This TLV was renamed to tlvAlMacAddress but these files were forgotten. Signed-off-by: Mario Maz --- .../tlvf/ieee_1905_1/tlvAlMacAddressType.h | 52 -------- .../tlvf/ieee_1905_1/tlvAlMacAddressType.cpp | 118 ------------------ 2 files changed, 170 deletions(-) delete mode 100644 framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/tlvAlMacAddressType.h delete mode 100644 framework/tlvf/AutoGenerated/src/tlvf/ieee_1905_1/tlvAlMacAddressType.cpp diff --git a/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/tlvAlMacAddressType.h b/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/tlvAlMacAddressType.h deleted file mode 100644 index 9f1e8e6b6d..0000000000 --- a/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/tlvAlMacAddressType.h +++ /dev/null @@ -1,52 +0,0 @@ -/////////////////////////////////////// -// AUTO GENERATED FILE - DO NOT EDIT // -/////////////////////////////////////// - -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef _TLVF_IEEE_1905_1_TLVALMACADDRESSTYPE_H_ -#define _TLVF_IEEE_1905_1_TLVALMACADDRESSTYPE_H_ - -#include -#include -#include -#include -#include -#include -#include -#include "tlvf/ieee_1905_1/eTlvType.h" -#include "tlvf/common/sMacAddr.h" - -namespace ieee1905_1 { - - -class tlvAlMacAddressType : public BaseClass -{ - public: - tlvAlMacAddressType(uint8_t* buff, size_t buff_len, bool parse = false); - explicit tlvAlMacAddressType(std::shared_ptr base, bool parse = false); - ~tlvAlMacAddressType(); - - const eTlvType& type(); - const uint16_t& length(); - sMacAddr& mac(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eTlvType* m_type = nullptr; - uint16_t* m_length = nullptr; - sMacAddr* m_mac = nullptr; -}; - -}; // close namespace: ieee1905_1 - -#endif //_TLVF/IEEE_1905_1_TLVALMACADDRESSTYPE_H_ diff --git a/framework/tlvf/AutoGenerated/src/tlvf/ieee_1905_1/tlvAlMacAddressType.cpp b/framework/tlvf/AutoGenerated/src/tlvf/ieee_1905_1/tlvAlMacAddressType.cpp deleted file mode 100644 index 2203a7c63c..0000000000 --- a/framework/tlvf/AutoGenerated/src/tlvf/ieee_1905_1/tlvAlMacAddressType.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/////////////////////////////////////// -// AUTO GENERATED FILE - DO NOT EDIT // -/////////////////////////////////////// - -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include -#include - -using namespace ieee1905_1; - -tlvAlMacAddressType::tlvAlMacAddressType(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -tlvAlMacAddressType::tlvAlMacAddressType(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -tlvAlMacAddressType::~tlvAlMacAddressType() { -} -const eTlvType& tlvAlMacAddressType::type() { - return (const eTlvType&)(*m_type); -} - -const uint16_t& tlvAlMacAddressType::length() { - return (const uint16_t&)(*m_length); -} - -sMacAddr& tlvAlMacAddressType::mac() { - return (sMacAddr&)(*m_mac); -} - -void tlvAlMacAddressType::class_swap() -{ - tlvf_swap(16, reinterpret_cast(m_length)); - m_mac->struct_swap(); -} - -bool tlvAlMacAddressType::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - *m_length -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t tlvAlMacAddressType::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(eTlvType); // type - class_size += sizeof(uint16_t); // length - class_size += sizeof(sMacAddr); // mac - return class_size; -} - -bool tlvAlMacAddressType::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_type = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_type = eTlvType::TLV_AL_MAC_ADDRESS_TYPE; - if (!buffPtrIncrementSafe(sizeof(eTlvType))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(eTlvType) << ") Failed!"; - return false; - } - m_length = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_length = 0; - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if(m_length && !m_parse__){ (*m_length) += sizeof(sMacAddr); } - if (!m_parse__) { m_mac->struct_init(); } - if (m_parse__) { class_swap(); } - if (m_parse__) { - if (*m_type != eTlvType::TLV_AL_MAC_ADDRESS_TYPE) { - TLVF_LOG(ERROR) << "TLV type mismatch. Expected value: " << int(eTlvType::TLV_AL_MAC_ADDRESS_TYPE) << ", received value: " << int(*m_type); - return false; - } - } - return true; -} - - From c33a7cb7b1455a5930f6fff5842c99edc26d5df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Fri, 26 Jun 2020 15:59:55 +0200 Subject: [PATCH 123/453] docker: add a Dockerfile containing boardfarm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To run the boardfarm tests, we need an image containing boardfarm. Add an image that contains all the boardfarm dependencies, fetch a specific commit (the latest one from the master branch) and install it. The dockerfile was adapted from the existing work on: https://github.com/prplfoundation/prplMesh/pull/1483 Also add the image to .gitlab-ci to get it built automatically. Signed-off-by: Raphaël Mélotte --- .gitlab-ci.yml | 3 ++ tools/docker/boardfarm-ci/Dockerfile | 41 ++++++++++++++++++ tools/docker/boardfarm-ci/requirements.txt | 48 ++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 tools/docker/boardfarm-ci/Dockerfile create mode 100644 tools/docker/boardfarm-ci/requirements.txt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c64ba84133..51597517dc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,6 +35,9 @@ image-build-builder/ubuntu/bionic: image-build-tests-runner: extends: .image-build +image-build-boardfarm-ci: + extends: .image-build + .in-prplmesh-builder: image: name: $CI_REGISTRY_IMAGE/prplmesh-builder-ubuntu-bionic:$CI_PIPELINE_ID diff --git a/tools/docker/boardfarm-ci/Dockerfile b/tools/docker/boardfarm-ci/Dockerfile new file mode 100644 index 0000000000..a7e1bc06c4 --- /dev/null +++ b/tools/docker/boardfarm-ci/Dockerfile @@ -0,0 +1,41 @@ +FROM python:3.8-slim-buster + +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + apt-transport-https \ + ca-certificates curl \ + curl \ + gcc \ + git \ + gnupg \ + gnupg-agent \ + libsnmp-dev \ + software-properties-common \ + wireshark-common \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt /app/requirements.txt + +WORKDIR app +RUN pip3 install -r requirements.txt + +# TODO: what needs this? +#RUN pip3 install jsonschema distro + + +RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - +RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + docker-ce \ + docker-ce-cli \ + containerd.io \ + && rm -rf /var/lib/apt/lists/* + +RUN curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose +RUN chmod 755 /usr/local/bin/docker-compose + +RUN git clone https://github.com/mattsm/boardfarm.git \ + && cd boardfarm \ + && git checkout 100521fde1fb67536682cafecc2f91a6e2e8a6f8 \ + && python3 setup.py install diff --git a/tools/docker/boardfarm-ci/requirements.txt b/tools/docker/boardfarm-ci/requirements.txt new file mode 100644 index 0000000000..aaaea868c8 --- /dev/null +++ b/tools/docker/boardfarm-ci/requirements.txt @@ -0,0 +1,48 @@ +aenum +argparse +beautifulsoup4 +boto3 +cdrouter +debtcollector +distro +dlipower +dnspython +docutils<0.16 +easysnmp +elasticsearch>=1.0.0 +Faker +future +ipaddress +jira +jsonschema +marshmallow<3 +matplotlib +nested_lookup==0.2.19 +netaddr +pexpect +pre-commit +psutil +pycountry +pycryptodome +pyflakes +pymongo +pyserial +pysmi +pysnmp +pytest==5.3.5 +pytest-html +pytest-mock +pytest-randomly +pyvirtualdisplay +requests +retry +selenium +simplejson +six +sphinx +termcolor +unittest2 +xmltodict +xvfbwrapper +yapf +zeep From 95c67add8fcdfd8386bf40be816999ecaab76d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Fri, 26 Jun 2020 16:02:33 +0200 Subject: [PATCH 124/453] tests: boardfarm: use the installed version of boardfarm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To use an already-installed boardfarm version we don't need to know it's path, we can assume it's already in PATH. Signed-off-by: Raphaël Mélotte --- tests/run_bf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run_bf.sh b/tests/run_bf.sh index 8c71953b2f..0dbbea4d12 100755 --- a/tests/run_bf.sh +++ b/tests/run_bf.sh @@ -15,4 +15,4 @@ else fi export PYTHONPATH -exec python3 "${bf_dir}"/bft -c "${bf_plugins_dir}"/boardfarm_prplmesh/prplmesh_config.json -n prplmesh_docker -x test_flows +exec bft -c "${bf_plugins_dir}"/boardfarm_prplmesh/prplmesh_config.json -n prplmesh_docker -x test_flows From 8355525ce8327069add02b1836107ad49618db9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Fri, 26 Jun 2020 16:04:36 +0200 Subject: [PATCH 125/453] ci: add a job to run the boardfarm tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because prplMesh is not currently relocatable, we have to run it both in the same directory it was built in, but also as the same user. It is currently built with the root user inside a docker container, with the USER variable set as ''. As a consequence, we have to run it as root as well, and explicitly set USER to an empty string (because boardfarm relies on it's presence). Since we want to run boardfarm in docker and boardfarm starts containers itself, we have to use a docker image where docker itself is available from within the container. For this 3 options were possible: - The current one, running another docker daemon inside the first docker container. It is a little bit overkill, and makes it hard to preserve the cache between runs. - Run with a Docker executor and bind-mount the Docker socket. It requires some care when we want to mount volumes from within a container, because the volumes have to be available on the host. - Run with a shell executor. This approach has the benefit of always having the prplMesh tree cloned and the artifacts available on the host. Since we currently run the containers as root however, the Gitlab runner won't be able to clean up files in-between runs. The option 2 was chosen, because it was the easiest to use at the moment. For now the job also needs only the docker builds, so add a "need" for it. Signed-off-by: Raphaël Mélotte --- .gitlab-ci.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 51597517dc..a706e7ed2a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -216,6 +216,21 @@ run-tests: - job: image-build-tests-runner - job: image-build-runner +boardfarm-tests: + stage: test + image: $CI_REGISTRY_IMAGE/prplmesh-boardfarm-ci:$CI_PIPELINE_ID + script: + - export USER='' + - tests/run_bf.sh + artifacts: + paths: + - logs + - results + needs: + - job: build-in-docker + tags: + - boardfarm + .build-for-openwrt: stage: build script: From 955ac731f57a766e6dc9f323fe9f230fa043217e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Mon, 29 Jun 2020 07:41:35 +0200 Subject: [PATCH 126/453] tests: boardfarm: error out and print the result when pexpect run fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a command failed to run, raise an exception early, and add the stdout and stderr output of the command in the message. These changes were taken and adapted from: https://github.com/prplfoundation/prplMesh/pull/1483 Signed-off-by: Raphaël Mélotte --- .../boardfarm_prplmesh/devices/prplmesh_base.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py index 227e8cd27b..700c5c2863 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py @@ -8,14 +8,23 @@ from boardfarm.devices import linux +class CommandError(Exception): + """Raised on failed execution""" + pass + + class PrplMeshBase(linux.LinuxDevice): """PrplMesh abstract device.""" def _run_shell_cmd(self, cmd: str = "", args: list = None, timeout: int = 30): """Wrapper that executes command with specified args on host machine and logs output.""" - res = pexpect.run(cmd, args=args, timeout=timeout, encoding="utf-8") + res, exitstatus = pexpect.run(cmd, args=args, timeout=timeout, encoding="utf-8", + withexitstatus=1) entry = " ".join((cmd, " ".join(args))) + if exitstatus != 0: + raise CommandError("Error executing {}:\n{}".format(entry, res)) + self.log_calls += entry self.log += "$ " + entry + "\r\n" + res From 47f312834c0afd53a3f86abffa9a3f654eb9c76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Mon, 6 Jul 2020 16:31:40 +0200 Subject: [PATCH 127/453] tests: boardfarm: use docker_name for check_status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With https://github.com/prplfoundation/prplMesh/pull/1486, "name" was changed to "docker_name". The name in "check_status" was not updated, so do it now. It fixes the following error: Error: No such container: controller See for example: https://gitlab.com/prpl-foundation/prplMesh/-/jobs/625370585 Signed-off-by: Raphaël Mélotte --- .../boardfarm_prplmesh/devices/prplmesh_docker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py index ae46897104..17aea4407b 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py @@ -78,7 +78,7 @@ def check_status(self): and also after test - to insure that device still operational. """ self._run_shell_cmd(os.path.join(rootdir, "tools", "docker", "test.sh"), - ["-v", "-n", self.name]) + ["-v", "-n", self.docker_name]) def isalive(self): """Method required by boardfarm. From 33696c9fd3fd4924b551f83bd75ab1477723d059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Mon, 6 Jul 2020 19:18:22 +0200 Subject: [PATCH 128/453] tests: boardfarm: use device_get_info for check_status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With https://github.com/prplfoundation/prplMesh/pull/1486, the first device to start has been changed to be the agent. Since the agent cannot be operational unless there is a controller already running on the same network, something else has to be used for "check_status". For now, use netcat to check that "device_get_info" works. Signed-off-by: Raphaël Mélotte --- .../boardfarm_prplmesh/devices/prplmesh_docker.py | 4 ++-- tools/docker/boardfarm-ci/Dockerfile | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py index 17aea4407b..7e890c800d 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_docker.py @@ -77,8 +77,8 @@ def check_status(self): It is used by boardfarm to indicate that spawned device instance is ready for test and also after test - to insure that device still operational. """ - self._run_shell_cmd(os.path.join(rootdir, "tools", "docker", "test.sh"), - ["-v", "-n", self.docker_name]) + self._run_shell_cmd("printf", + ["device_get_info", "|", "nc", "-w", "1", "controller-rme", "8002"]) def isalive(self): """Method required by boardfarm. diff --git a/tools/docker/boardfarm-ci/Dockerfile b/tools/docker/boardfarm-ci/Dockerfile index a7e1bc06c4..67fd3ed294 100644 --- a/tools/docker/boardfarm-ci/Dockerfile +++ b/tools/docker/boardfarm-ci/Dockerfile @@ -10,6 +10,7 @@ RUN apt-get update \ gnupg \ gnupg-agent \ libsnmp-dev \ + netcat \ software-properties-common \ wireshark-common \ && rm -rf /var/lib/apt/lists/* From 7ef1306f6902b461641482cfd4e1421445edf2bc Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Thu, 2 Jul 2020 06:58:43 +0000 Subject: [PATCH 129/453] controller: db: persistent-db configurations in master config PPM-5. Preparative commit. Extend sDbMasterConfig struct to hold: persistent_db - is persistent db enabled. clients_persistent_db_max_size - max number of clients in persistent db. max_timelife_delay_days - max timelife delay for client (scale:days). unfriendly_device_max_timelife_delay_days - max timelife delay for unfriendly clients (scale: days). Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index fc744fe3a5..ee2ec0f200 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -75,6 +75,7 @@ class db { bool load_health_check; bool load_monitor_on_vaps; bool certification_mode; + bool persistent_db; int roaming_5ghz_failed_attemps_threshold; int roaming_24ghz_failed_attemps_threshold; int roaming_11v_failed_attemps_threshold; @@ -107,6 +108,9 @@ class db { int blacklist_channel_remove_timeout; int failed_roaming_counter_threshold; int roaming_sticky_client_rssi_threshold; + int clients_persistent_db_max_size; + int max_timelife_delay_days; + int unfriendly_device_max_timelife_delay_days; } sDbMasterConfig; From 8634f9667bc47e949bbf90ebb5c0bed45f52fe70 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Thu, 2 Jul 2020 07:10:55 +0000 Subject: [PATCH 130/453] framework: bpl: get persistent db enable PPM-5. Preparative commit. Added API to get the persistent_db value from the prplmesh config. Added both UCI and Linux implementations. Signed-off-by: Adam Dov --- framework/platform/bpl/include/bpl/bpl_cfg.h | 11 +++++++++++ framework/platform/bpl/linux/bpl_cfg.cpp | 15 +++++++++++++++ framework/platform/bpl/uci/cfg/bpl_cfg.cpp | 14 ++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/framework/platform/bpl/include/bpl/bpl_cfg.h b/framework/platform/bpl/include/bpl/bpl_cfg.h index ae16b15b93..8a29493e3d 100644 --- a/framework/platform/bpl/include/bpl/bpl_cfg.h +++ b/framework/platform/bpl/include/bpl/bpl_cfg.h @@ -91,6 +91,9 @@ namespace bpl { #define DEFAULT_BAND_STEERING 1 #define DEFAULT_DFS_REENTRY 1 #define DEFAULT_CLIENT_ROAMING 1 +// by-default the persistent DB is disabled to allow backwards compatability +// if the parameter is not configured in the prplmesh config and set to 1, DB is disabled +constexpr int DEFAULT_PERSISTENT_DB = 0; /****************************************************************************/ /******************************* Structures *********************************/ @@ -490,6 +493,14 @@ int cfg_get_hostap_iface(int32_t radio_num, char hostap_iface[BPL_IFNAME_LEN]); */ int cfg_get_all_prplmesh_wifi_interfaces(BPL_WLAN_IFACE *interfaces, int *num_of_interfaces); +/** + * @brief Returns whether the persistent DB is enabled. + * + * @param [out] enable true if the DB is enabled and false otherwise. + * @return true on success, otherwise false. + */ +bool cfg_get_persistent_db_enable(bool &enable); + } // namespace bpl } // namespace beerocks diff --git a/framework/platform/bpl/linux/bpl_cfg.cpp b/framework/platform/bpl/linux/bpl_cfg.cpp index 375a2d7033..9a1bbb90cb 100644 --- a/framework/platform/bpl/linux/bpl_cfg.cpp +++ b/framework/platform/bpl/linux/bpl_cfg.cpp @@ -335,5 +335,20 @@ int cfg_get_all_prplmesh_wifi_interfaces(BPL_WLAN_IFACE *interfaces, int *num_of return RETURN_OK; } +bool cfg_get_persistent_db_enable(bool &enable) +{ + int persistent_db_enable = DEFAULT_PERSISTENT_DB; + + // persistent db value is optional + if (cfg_get_param_int("persistent_db=", persistent_db_enable) < 0) { + MAPF_DBG("Failed to read persistent-db-enable parameter - setting default value"); + persistent_db_enable = DEFAULT_PERSISTENT_DB; + } + + enable = (persistent_db_enable == 1); + + return true; +} + } // namespace bpl } // namespace beerocks diff --git a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp index 8d1308edc5..5888ad8f63 100644 --- a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp +++ b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp @@ -401,5 +401,19 @@ int cfg_get_all_prplmesh_wifi_interfaces(BPL_WLAN_IFACE *interfaces, int *num_of return RETURN_OK; } +bool cfg_get_persistent_db_enable(bool &enable) +{ + int retVal = -1; + if (cfg_get_prplmesh_param_int_default("persistent_db", &retVal, DEFAULT_PERSISTENT_DB) == + RETURN_ERR) { + MAPF_ERR("Failed to read persistent-db-enable parameter"); + return false; + } + + enable = (retVal == 1); + + return true; +} + } // namespace bpl } // namespace beerocks From 6cff08c4bb35389354b6ba9c48f3f6bd14d77fac Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Thu, 2 Jul 2020 07:37:33 +0000 Subject: [PATCH 131/453] framework: bpl: get max number of clients in persistent db PPM-5. Preparative commit. Added API to get the max number of clients in persistent_db from the prplmesh config. Added both UCI and Linux implementations. Signed-off-by: Adam Dov --- framework/platform/bpl/include/bpl/bpl_cfg.h | 12 ++++++++++++ framework/platform/bpl/linux/bpl_cfg.cpp | 13 +++++++++++++ framework/platform/bpl/uci/cfg/bpl_cfg.cpp | 14 ++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/framework/platform/bpl/include/bpl/bpl_cfg.h b/framework/platform/bpl/include/bpl/bpl_cfg.h index 8a29493e3d..fcca9a434a 100644 --- a/framework/platform/bpl/include/bpl/bpl_cfg.h +++ b/framework/platform/bpl/include/bpl/bpl_cfg.h @@ -94,6 +94,10 @@ namespace bpl { // by-default the persistent DB is disabled to allow backwards compatability // if the parameter is not configured in the prplmesh config and set to 1, DB is disabled constexpr int DEFAULT_PERSISTENT_DB = 0; +// the DB of clients is limited in size to prevent high memory consumption +// this is configurable to enable flexibility and support for low-memory platforms +// by default, the number of clients's configuration to be cached is limited to 256 +constexpr int DEFAULT_CLIENTS_PERSISTENT_DB_MAX_SIZE = 256; /****************************************************************************/ /******************************* Structures *********************************/ @@ -501,6 +505,14 @@ int cfg_get_all_prplmesh_wifi_interfaces(BPL_WLAN_IFACE *interfaces, int *num_of */ bool cfg_get_persistent_db_enable(bool &enable); +/** + * @brief Returns the max number of clients in the persistent DB. + * + * @param [out] max_size Max number of clients the persistent-db supports. + * @return true on success, otherwise false. + */ +bool cfg_get_clients_persistent_db_max_size(int &max_size); + } // namespace bpl } // namespace beerocks diff --git a/framework/platform/bpl/linux/bpl_cfg.cpp b/framework/platform/bpl/linux/bpl_cfg.cpp index 9a1bbb90cb..3b40d7ce36 100644 --- a/framework/platform/bpl/linux/bpl_cfg.cpp +++ b/framework/platform/bpl/linux/bpl_cfg.cpp @@ -350,5 +350,18 @@ bool cfg_get_persistent_db_enable(bool &enable) return true; } +bool cfg_get_clients_persistent_db_max_size(int &max_size) +{ + int max_size_val = -1; + if (cfg_get_param_int("clients_persistent_db_max_size=", max_size_val) == RETURN_ERR) { + MAPF_ERR("Failed to read clients-persistent-db-max-size parameter - setting default value"); + max_size_val = DEFAULT_CLIENTS_PERSISTENT_DB_MAX_SIZE; + } + + max_size = max_size_val; + + return true; +} + } // namespace bpl } // namespace beerocks diff --git a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp index 5888ad8f63..e1f12f0398 100644 --- a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp +++ b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp @@ -415,5 +415,19 @@ bool cfg_get_persistent_db_enable(bool &enable) return true; } +bool cfg_get_clients_persistent_db_max_size(int &max_size) +{ + int retVal = -1; + if (cfg_get_prplmesh_param_int_default("clients_persistent_db_max_size", &retVal, + DEFAULT_CLIENTS_PERSISTENT_DB_MAX_SIZE) == RETURN_ERR) { + MAPF_ERR("Failed to read clients-persistent-db-max-size parameter"); + return false; + } + + max_size = retVal; + + return true; +} + } // namespace bpl } // namespace beerocks From 8904739b325a35070f067a5eeabdeaeaa993c6d0 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Thu, 2 Jul 2020 08:22:15 +0000 Subject: [PATCH 132/453] framework: bpl: get clients max time life delay PPM-5. Preparative commit. Added API to get the clients' max time life delay from the prplmesh config. Added both UCI and Linux implementations. Signed-off-by: Adam Dov --- framework/platform/bpl/include/bpl/bpl_cfg.h | 11 +++++++++++ framework/platform/bpl/linux/bpl_cfg.cpp | 13 +++++++++++++ framework/platform/bpl/uci/cfg/bpl_cfg.cpp | 14 ++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/framework/platform/bpl/include/bpl/bpl_cfg.h b/framework/platform/bpl/include/bpl/bpl_cfg.h index fcca9a434a..825496bf34 100644 --- a/framework/platform/bpl/include/bpl/bpl_cfg.h +++ b/framework/platform/bpl/include/bpl/bpl_cfg.h @@ -98,6 +98,9 @@ constexpr int DEFAULT_PERSISTENT_DB = 0; // this is configurable to enable flexibility and support for low-memory platforms // by default, the number of clients's configuration to be cached is limited to 256 constexpr int DEFAULT_CLIENTS_PERSISTENT_DB_MAX_SIZE = 256; +// the persistent data of clients has aging limit +// by default, the limit is 365 days, but it is configurable via the UCI +constexpr int DEFAULT_MAX_TIMELIFE_DELAY_DAYS = 365; /****************************************************************************/ /******************************* Structures *********************************/ @@ -513,6 +516,14 @@ bool cfg_get_persistent_db_enable(bool &enable); */ bool cfg_get_clients_persistent_db_max_size(int &max_size); +/** + * @brief Returns the max time-life delay of clients (used for aging of client's persistent data). + * + * @param [out] max_timelife_delay_days Max clients' timelife delay. + * @return true on success, otherwise false. + */ +bool cfg_get_max_timelife_delay_days(int &max_timelife_delay_days); + } // namespace bpl } // namespace beerocks diff --git a/framework/platform/bpl/linux/bpl_cfg.cpp b/framework/platform/bpl/linux/bpl_cfg.cpp index 3b40d7ce36..aa353de0ac 100644 --- a/framework/platform/bpl/linux/bpl_cfg.cpp +++ b/framework/platform/bpl/linux/bpl_cfg.cpp @@ -363,5 +363,18 @@ bool cfg_get_clients_persistent_db_max_size(int &max_size) return true; } +bool cfg_get_max_timelife_delay_days(int &max_timelife_delay_days) +{ + int val = -1; + if (cfg_get_param_int("max_timelife_delay_days=", val) == RETURN_ERR) { + MAPF_ERR("Failed to read max-timelife-delay-days parameter - setting default value"); + val = DEFAULT_MAX_TIMELIFE_DELAY_DAYS; + } + + max_timelife_delay_days = val; + + return true; +} + } // namespace bpl } // namespace beerocks diff --git a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp index e1f12f0398..982f264d3f 100644 --- a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp +++ b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp @@ -429,5 +429,19 @@ bool cfg_get_clients_persistent_db_max_size(int &max_size) return true; } +bool cfg_get_max_timelife_delay_days(int &max_timelife_delay_days) +{ + int retVal = -1; + if (cfg_get_prplmesh_param_int_default("max_timelife_delay_days", &retVal, + DEFAULT_MAX_TIMELIFE_DELAY_DAYS) == RETURN_ERR) { + MAPF_ERR("Failed to read max-timelife-delay-days parameter"); + return false; + } + + max_timelife_delay_days = retVal; + + return true; +} + } // namespace bpl } // namespace beerocks From 3282942b2000d7c878e69fc69a3b7b4c7d4e2b79 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Thu, 2 Jul 2020 08:24:45 +0000 Subject: [PATCH 133/453] framework: bpl: get unfriendly clients max time life delay PPM-5. Preparative commit. Added API to get the unfriendly clients' max time life delay from the prplmesh config. Added both UCI and Linux implementations. Signed-off-by: Adam Dov --- framework/platform/bpl/include/bpl/bpl_cfg.h | 13 +++++++++++++ framework/platform/bpl/linux/bpl_cfg.cpp | 15 +++++++++++++++ framework/platform/bpl/uci/cfg/bpl_cfg.cpp | 16 ++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/framework/platform/bpl/include/bpl/bpl_cfg.h b/framework/platform/bpl/include/bpl/bpl_cfg.h index 825496bf34..78a52fdd83 100644 --- a/framework/platform/bpl/include/bpl/bpl_cfg.h +++ b/framework/platform/bpl/include/bpl/bpl_cfg.h @@ -101,6 +101,10 @@ constexpr int DEFAULT_CLIENTS_PERSISTENT_DB_MAX_SIZE = 256; // the persistent data of clients has aging limit // by default, the limit is 365 days, but it is configurable via the UCI constexpr int DEFAULT_MAX_TIMELIFE_DELAY_DAYS = 365; +// the timelife of unfriendly-devices is set separately and can be shorter than the timelife +// TODO: add description of "unfriendly-device" and how it is determined +// by default, the limit is 1 day, but it is configurable via the UCI +constexpr int DEFAULT_UNFRIENDLY_DEVICE_MAX_TIMELIFE_DELAY_DAYS = 1; /****************************************************************************/ /******************************* Structures *********************************/ @@ -524,6 +528,15 @@ bool cfg_get_clients_persistent_db_max_size(int &max_size); */ bool cfg_get_max_timelife_delay_days(int &max_timelife_delay_days); +/** + * @brief Returns the max time-life delay for unfriendly clients. + * + * @param [out] unfriendly_device_max_timelife_delay_days Max unfriendly clients' timelife delay. + * @return true on success, otherwise false. + */ +bool cfg_get_unfriendly_device_max_timelife_delay_days( + int &unfriendly_device_max_timelife_delay_days); + } // namespace bpl } // namespace beerocks diff --git a/framework/platform/bpl/linux/bpl_cfg.cpp b/framework/platform/bpl/linux/bpl_cfg.cpp index aa353de0ac..ddeca479d8 100644 --- a/framework/platform/bpl/linux/bpl_cfg.cpp +++ b/framework/platform/bpl/linux/bpl_cfg.cpp @@ -376,5 +376,20 @@ bool cfg_get_max_timelife_delay_days(int &max_timelife_delay_days) return true; } +bool cfg_get_unfriendly_device_max_timelife_delay_days( + int &unfriendly_device_max_timelife_delay_days) +{ + int val = -1; + if (cfg_get_param_int("unfriendly_device_max_timelife_delay_days=", val) == RETURN_ERR) { + MAPF_ERR("Failed to read unfriendly-device-max-timelife-delay-days parameter - setting " + "default value"); + val = DEFAULT_MAX_TIMELIFE_DELAY_DAYS; + } + + unfriendly_device_max_timelife_delay_days = val; + + return true; +} + } // namespace bpl } // namespace beerocks diff --git a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp index 982f264d3f..baf449d795 100644 --- a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp +++ b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp @@ -443,5 +443,21 @@ bool cfg_get_max_timelife_delay_days(int &max_timelife_delay_days) return true; } +bool cfg_get_unfriendly_device_max_timelife_delay_days( + int &unfriendly_device_max_timelife_delay_days) +{ + int retVal = -1; + if (cfg_get_prplmesh_param_int_default("unfriendly_device_max_timelife_delay_days", &retVal, + DEFAULT_UNFRIENDLY_DEVICE_MAX_TIMELIFE_DELAY_DAYS) == + RETURN_ERR) { + MAPF_ERR("Failed to read unfriendly-device-max-timelife-delay-days parameter"); + return false; + } + + unfriendly_device_max_timelife_delay_days = retVal; + + return true; +} + } // namespace bpl } // namespace beerocks From 9b2763dadef0747740888bb14769e2f8fddddcf7 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Thu, 2 Jul 2020 09:23:57 +0000 Subject: [PATCH 134/453] controller: read persistent-db configurations to master config Added updates of persistent-db configurations as part of fill_master_config(). If for any reason the read fails, the parameter is configured to the default-value as defined in the bpl_cfg.h Signed-off-by: Adam Dov --- .../beerocks/master/beerocks_master_main.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/controller/src/beerocks/master/beerocks_master_main.cpp b/controller/src/beerocks/master/beerocks_master_main.cpp index 201102a5b4..7466130c5b 100644 --- a/controller/src/beerocks/master/beerocks_master_main.cpp +++ b/controller/src/beerocks/master/beerocks_master_main.cpp @@ -218,6 +218,34 @@ static void fill_master_config(son::db::sDbMasterConfig &master_conf, } else { master_conf.load_steer_on_vaps = std::string(load_steer_on_vaps); } + + if (!beerocks::bpl::cfg_get_persistent_db_enable(master_conf.persistent_db)) { + LOG(DEBUG) << "failed to read persistent db enable, setting to default value: " + << bool(beerocks::bpl::DEFAULT_PERSISTENT_DB); + master_conf.persistent_db = bool(beerocks::bpl::DEFAULT_PERSISTENT_DB); + } + if (!beerocks::bpl::cfg_get_clients_persistent_db_max_size( + master_conf.clients_persistent_db_max_size)) { + LOG(DEBUG) + << "failed to read max number of clients in persistent db, setting to default value: " + << beerocks::bpl::DEFAULT_CLIENTS_PERSISTENT_DB_MAX_SIZE; + master_conf.clients_persistent_db_max_size = + beerocks::bpl::DEFAULT_CLIENTS_PERSISTENT_DB_MAX_SIZE; + } + if (!beerocks::bpl::cfg_get_max_timelife_delay_days(master_conf.max_timelife_delay_days)) { + LOG(DEBUG) + << "failed to read max lifetime of clients in persistent db, setting to default value: " + << beerocks::bpl::DEFAULT_MAX_TIMELIFE_DELAY_DAYS << " days"; + master_conf.max_timelife_delay_days = beerocks::bpl::DEFAULT_MAX_TIMELIFE_DELAY_DAYS; + } + if (!beerocks::bpl::cfg_get_unfriendly_device_max_timelife_delay_days( + master_conf.unfriendly_device_max_timelife_delay_days)) { + LOG(DEBUG) << "failed to read max lifetime of unfriendly clients in persistent db, setting " + "to default value: " + << beerocks::bpl::DEFAULT_UNFRIENDLY_DEVICE_MAX_TIMELIFE_DELAY_DAYS << " days"; + master_conf.unfriendly_device_max_timelife_delay_days = + beerocks::bpl::DEFAULT_UNFRIENDLY_DEVICE_MAX_TIMELIFE_DELAY_DAYS; + } } int main(int argc, char *argv[]) From 622de603c4c9455dfde58d818e9c1ad697131c23 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Sun, 5 Jul 2020 12:26:06 +0000 Subject: [PATCH 135/453] framework: bpl: replace defines with constexpr replaced defines with constexpr int. Signed-off-by: Adam Dov --- framework/platform/bpl/include/bpl/bpl_cfg.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/framework/platform/bpl/include/bpl/bpl_cfg.h b/framework/platform/bpl/include/bpl/bpl_cfg.h index 78a52fdd83..4bfc95345f 100644 --- a/framework/platform/bpl/include/bpl/bpl_cfg.h +++ b/framework/platform/bpl/include/bpl/bpl_cfg.h @@ -86,11 +86,11 @@ namespace bpl { #define BPL_GW_DB_OPER_MODE_LEN (127 + 1) /* Maximal length of OPERATING MODE string */ /* Default values */ -#define DEFAULT_STOP_ON_FAILURE_ATTEMPTS 1 -#define DEFAULT_RDKB_EXTENSIONS 0 -#define DEFAULT_BAND_STEERING 1 -#define DEFAULT_DFS_REENTRY 1 -#define DEFAULT_CLIENT_ROAMING 1 +constexpr int DEFAULT_STOP_ON_FAILURE_ATTEMPTS = 1; +constexpr int DEFAULT_RDKB_EXTENSIONS = 0; +constexpr int DEFAULT_BAND_STEERING = 1; +constexpr int DEFAULT_DFS_REENTRY = 1; +constexpr int DEFAULT_CLIENT_ROAMING = 1; // by-default the persistent DB is disabled to allow backwards compatability // if the parameter is not configured in the prplmesh config and set to 1, DB is disabled constexpr int DEFAULT_PERSISTENT_DB = 0; From 142fbf37d9a0007481eb8f107c35345a8dc9b990 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Thu, 18 Jun 2020 10:04:12 +0000 Subject: [PATCH 136/453] bwl: Add KeyValueParser class Bring from the dead the WAV parser as a separate common class so all BWL types could be derived from it. Signed-off-by: Moran Shoeg --- .../beerocks/bwl/common/key_value_parser.cpp | 224 ++++++++++++++++++ .../bwl/include/bwl/key_value_parser.h | 66 ++++++ 2 files changed, 290 insertions(+) create mode 100644 common/beerocks/bwl/common/key_value_parser.cpp create mode 100644 common/beerocks/bwl/include/bwl/key_value_parser.h diff --git a/common/beerocks/bwl/common/key_value_parser.cpp b/common/beerocks/bwl/common/key_value_parser.cpp new file mode 100644 index 0000000000..eb32c51797 --- /dev/null +++ b/common/beerocks/bwl/common/key_value_parser.cpp @@ -0,0 +1,224 @@ + +#include + +#include +#include +#include + +#include +#include + +namespace bwl { +constexpr char EVENT_KEYLESS_PARAM_OPCODE[] = "_opcode"; +constexpr char EVENT_KEYLESS_PARAM_MAC[] = "_mac"; +constexpr char EVENT_KEYLESS_PARAM_IFACE[] = "_iface"; + +////////////////////////////////////////////////////////////////////////////// +////////////////////////// Local Module Functions //////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +/** + * @brief Finds first occurrence of two delimiters with string between them, on given string 'str': + * <'delim_near'><'delim_far'> + * + * @param[in] str String to find the first occurrence of two delimiters with string between them. + * @param[in] pos Postion of the first characters on 'str' to be considered in the search. + * @param[in] delim_near Near delimiter. + * @param[in] delim_far Near delimiter. + * @return std::string::size_type Postion of the first character that matches. If no matches is + * found, returns string::npos. + */ +static std::string::size_type find_first_of_delimiter_pair(const std::string &str, + std::string::size_type pos, + char delim_near, char delim_far) +{ + // First search the end delimiter. + auto idx = str.find_first_of(delim_far, pos); + if (idx == std::string::npos) { + return idx; + } + // Search back for the start delimiter from there. + idx = str.rfind(delim_near, idx); + return idx; +} + +////////////////////////////////////////////////////////////////////////////// +/////////////////////////////// Implementation /////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +void KeyValueParser::parse_line(std::istringstream &iss_in, std::list delimiter_list, + parsed_line_t &parsed_line) +{ + if (delimiter_list.empty()) { + return; + } + + std::string str_storage, key; + bool kv = true; // '1'=key, '0'=val + while (std::getline(iss_in, str_storage, delimiter_list.front())) { + // If reached to 1 delimiter resolution, the data can be parsed into key and value + if (delimiter_list.size() == 1) { + if (kv) { + // Save key + key = str_storage; + } else { + // Save Value + parsed_line[key] = str_storage; + } + kv = !kv; + + } else { + auto delimiter_list_out(delimiter_list); + // Delete first delimiter + delimiter_list_out.erase(delimiter_list_out.begin()); + std::istringstream iss_out(str_storage); + parse_line(iss_out, delimiter_list_out, parsed_line); + } + } +} + +void KeyValueParser::parse_multiline(std::istringstream &iss_in, std::list delimiter_list, + parsed_multiline_t &parsed_multiline) +{ + if (delimiter_list.empty()) { + return; + } + + std::string str_storage; + while (std::getline(iss_in, str_storage, delimiter_list.front())) { + auto delimiter_list_out(delimiter_list); + + // Delete first delimiter + delimiter_list_out.erase(delimiter_list_out.begin()); + std::istringstream iss_out(str_storage); + parsed_line_t parsed_line; + parse_line(iss_out, delimiter_list_out, parsed_line); + parsed_multiline.push_back(parsed_line); + } +} + +void KeyValueParser::parse_event(std::string event_str, parsed_line_t &parsed_line) +{ + // Eliminate event log level from the begining of the event string : "<3>". + size_t idx_start = event_buffer_start_process_idx(event_str); + + // An event string might start with keyless values such as Even Name. + // Find where the keyless parameters ends by finding where is the first parameter with key, + // assuming it has a preceding " ='". + auto idx = find_first_of_delimiter_pair(event_str, idx_start, ' ', '='); + + // Put null terminator at the end of our key=val, for string stream construction. + if (idx != std::string::npos) { + event_str[idx] = '\0'; + } + + // Parse keyless params part and insert to the 'parsed_line' map object. + parse_event_keyless_params(event_str, idx_start, parsed_line); + + // Fill the map with the rest of event data. + while (idx != std::string::npos) { + + idx_start = ++idx; + + // Find first '=' to skip on it + idx = event_str.find_first_of('=', idx_start); + + // Find the next pair of delimiters index. + idx = find_first_of_delimiter_pair(event_str, ++idx, ' ', '='); + + if (idx != std::string::npos) { + // Put null terminator at the end of our key=val, for ss_in construction. + event_str[idx] = '\0'; + } + + // Parse key=value + std::istringstream iss_in(event_str.c_str() + idx_start); + parse_line(iss_in, {'='}, parsed_line); + } +} + +size_t KeyValueParser::event_buffer_start_process_idx(const std::string &event_str) +{ + // Eliminate event log level from the begining of the event string : "<3>" + auto idx_start = event_str.find_first_of(">"); + if (idx_start != std::string::npos) { + idx_start++; + } else { + LOG(WARNING) << "Empty event! event_string: " << event_str; + } + return idx_start; +} + +void KeyValueParser::parse_event_keyless_params(const std::string &event_str, size_t idx_start, + parsed_line_t &parsed_line) +{ + // Insert to map known prams without key + std::istringstream iss(event_str.c_str() + idx_start); + std::string str_storage; + bool opcode = true; + while (std::getline(iss, str_storage, ' ')) { + if (opcode) { + // assume that the second param is data or event name + parsed_line[EVENT_KEYLESS_PARAM_OPCODE] = str_storage; + opcode = false; + } else if (beerocks::net::network_utils::is_valid_mac(str_storage)) { + parsed_line[EVENT_KEYLESS_PARAM_MAC] = str_storage; + } else if (!strncmp(str_storage.c_str(), "wlan", 4)) { + parsed_line[EVENT_KEYLESS_PARAM_IFACE] = str_storage; + } + } +} + +bool KeyValueParser::read_param(const std::string &key, parsed_line_t &obj, int64_t &value, + bool ignore_unknown) +{ + auto val_iter = obj.find(key); + if (val_iter == obj.end()) { + LOG(ERROR) << "param :" << key << " does not exist"; + return false; + } + + static const std::string unknown_string = "UNKNOWN"; + + if (ignore_unknown && !unknown_string.compare(val_iter->second)) { + value = 0; + return true; + } + + value = beerocks::string_utils::stoi(val_iter->second); + + return true; +} + +bool KeyValueParser::read_param(const std::string &key, parsed_line_t &obj, const char **value) +{ + auto val_iter = obj.find(key); + if (val_iter == obj.end()) { + LOG(ERROR) << "param :" << key << " does not exist"; + return false; + } + + *value = reinterpret_cast((val_iter->second).c_str()); + return true; +} + +void KeyValueParser::parsed_obj_debug(const parsed_line_t &obj) +{ + LOG(DEBUG) << std::endl << "parsed_obj_debug: "; + for (const auto &kv_element : obj) { + LOG(DEBUG) << "key: " << kv_element.first << ", value: " << kv_element.second; + } +} + +void KeyValueParser::parsed_obj_debug(const parsed_multiline_t &obj) +{ + LOG(DEBUG) << std::endl << "parsed_obj_debug: "; + int element_num = 0; + for (const auto &list_element : obj) { + LOG(DEBUG) << "vector element: " << element_num; + parsed_obj_debug(list_element); + element_num++; + } +} + +} // namespace bwl diff --git a/common/beerocks/bwl/include/bwl/key_value_parser.h b/common/beerocks/bwl/include/bwl/key_value_parser.h new file mode 100644 index 0000000000..4e6d614747 --- /dev/null +++ b/common/beerocks/bwl/include/bwl/key_value_parser.h @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * Copyright (c) 2016-2019 Intel Corporation + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#ifndef _BWL_KEY_VALUE_PARSER_H_ +#define _BWL_KEY_VALUE_PARSER_H_ + +#include +#include +#include + +namespace bwl { + +/** + * @brief On KeyValueParser there are two types of object that can be parsed: + * parsed_line_t - Shall be used on key-value data with unique keys for each element, seperated by + * a space or a new line (Default seperator, can be modified on use). For example: + * "key1=value1 key2=value2 key3=value3 ..." + * --Or-- + * "key1=value1 + * key2=value2 + * key3=value3 + * ..." + * + * parsed_multiline_t - Shall be used in case there are 2 or more "parsed_line_t" which each "line" + * could have the same keys as the previous one. For example: + * "key1=Line1value1 key2=Line1value2 key3=Line1value3 ... + * key1=Line2value1 key2=Line2value2 key3=Line2value3 ... + * key1=Line3value1 key2=Line3value2 key3=Line3value3 ... + * ..."" + */ + +typedef std::unordered_map parsed_line_t; +typedef std::list parsed_multiline_t; + +class KeyValueParser { +protected: + static void parse_line(std::istringstream &iss, std::list delimiter_list, + parsed_line_t &parsed_line); + + static void parse_multiline(std::istringstream &iss, std::list delimiter_list, + parsed_multiline_t &parsed_multiline); + + static bool read_param(const std::string &key, parsed_line_t &obj, int64_t &value, + bool ignore_unknown = false); + + static bool read_param(const std::string &key, parsed_line_t &obj, const char **value); + + static void parsed_obj_debug(const parsed_line_t &obj); + static void parsed_obj_debug(const parsed_multiline_t &obj); + + virtual void parse_event(std::string event_str, parsed_line_t &parsed_line); + + virtual size_t event_buffer_start_process_idx(const std::string &event_str); + + virtual void parse_event_keyless_params(const std::string &event_str, size_t idx_start, + parsed_line_t &parsed_line); +}; + +} // namespace bwl + +#endif // _BWL_KEY_VALUE_PARSER_H_ From fed506844fdaa850775236c4e986c881b3806ab3 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Thu, 18 Jun 2020 10:05:07 +0000 Subject: [PATCH 137/453] bwl: Make dwpal derived from new class KeyValueParser Make dwpal derived from new class KeyValueParser: Add adaptation to sending a command to hostapd with automatic parsing. Also, fix some capital letter typo on print to the log. Signed-off-by: Moran Shoeg --- .../bwl/dwpal/base_wlan_hal_dwpal.cpp | 33 ++++++++++++++++++- .../beerocks/bwl/dwpal/base_wlan_hal_dwpal.h | 14 ++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp index 38c3fad7cb..6c150588a8 100644 --- a/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp @@ -442,7 +442,7 @@ bool base_wlan_hal_dwpal::set(const std::string ¶m, const std::string &value { const std::string cmd = "SET " + param + " " + value; if (!dwpal_send_cmd(cmd, vap_id)) { - LOG(ERROR) << "FAiled setting param " << param; + LOG(ERROR) << "Failed setting param " << param; return false; } @@ -458,6 +458,37 @@ bool base_wlan_hal_dwpal::ping() return true; } +bool base_wlan_hal_dwpal::dwpal_send_cmd(const std::string &cmd, parsed_line_t &reply, int vap_id) +{ + if (!dwpal_send_cmd(cmd, vap_id)) { + return false; + } + + if (m_wpa_ctrl_buffer[0] != '\0') { + // if reply is not empty + std::istringstream iss_in(m_wpa_ctrl_buffer); + parse_line(iss_in, {'\n', '='}, reply); + } + + return true; +} + +bool base_wlan_hal_dwpal::dwpal_send_cmd(const std::string &cmd, parsed_multiline_t &reply, + int vap_id) +{ + if (!dwpal_send_cmd(cmd, vap_id)) { + return false; + } + + if (m_wpa_ctrl_buffer[0] != '\0') { + // if reply is not empty + std::istringstream iss_in(m_wpa_ctrl_buffer); + parse_multiline(iss_in, {'\n', ' ', '='}, reply); + } + + return true; +} + bool base_wlan_hal_dwpal::dwpal_send_cmd(const std::string &cmd, int vap_id) { int result; diff --git a/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.h b/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.h index eeecc8d9eb..76b3f20204 100644 --- a/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.h +++ b/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.h @@ -12,6 +12,7 @@ #include "base_wlan_hal_dwpal_types.h" #include +#include #include #include @@ -35,7 +36,8 @@ enum class dwpal_fsm_event { Attach, Detach }; * Read more about virtual inheritance: https://en.wikipedia.org/wiki/Virtual_inheritance */ class base_wlan_hal_dwpal : public virtual base_wlan_hal, - protected beerocks::beerocks_fsm { + protected beerocks::beerocks_fsm, + public KeyValueParser { // Public methods: public: @@ -77,8 +79,16 @@ class base_wlan_hal_dwpal : public virtual base_wlan_hal, bool set(const std::string ¶m, const std::string &value, int vap_id = beerocks::IFACE_RADIO_ID); + bool dwpal_send_cmd(const std::string &cmd, parsed_line_t &reply, + int vap_id = beerocks::IFACE_RADIO_ID); + + bool dwpal_send_cmd(const std::string &cmd, parsed_multiline_t &reply, + int vap_id = beerocks::IFACE_RADIO_ID); + + // for external process bool dwpal_send_cmd(const std::string &cmd, char **reply, - int vap_id = beerocks::IFACE_RADIO_ID); // for external process + int vap_id = beerocks::IFACE_RADIO_ID); + bool dwpal_send_cmd(const std::string &cmd, int vap_id = beerocks::IFACE_RADIO_ID); bool attach_ctrl_interface(int vap_id); From 70705a65923a2de2eee373ef801144219ae7d56d Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Thu, 18 Jun 2020 10:05:10 +0000 Subject: [PATCH 138/453] bwl: Use KeyValueParser on update_stations_stats on dwpal Change the parser of update_stations_stats on dwpal monitor from dwpal parser to KeyValueParser. Signed-off-by: Moran Shoeg --- .../beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp | 130 +++++++++--------- 1 file changed, 62 insertions(+), 68 deletions(-) diff --git a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp index d38f60eace..00d078613b 100644 --- a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp @@ -677,94 +677,88 @@ bool mon_wlan_hal_dwpal::update_vap_stats(const std::string &vap_iface_name, SVa bool mon_wlan_hal_dwpal::update_stations_stats(const std::string &vap_iface_name, const std::string &sta_mac, SStaStats &sta_stats) { - char *reply = nullptr; + const char *tmp_str; + int64_t tmp_int; + parsed_line_t reply; std::string cmd = "GET_STA_MEASUREMENTS " + vap_iface_name + " " + sta_mac; - if (!dwpal_send_cmd(cmd, &reply)) { + if (!dwpal_send_cmd(cmd, reply)) { LOG(ERROR) << __func__ << " failed"; return false; } - size_t numOfValidArgs[10] = {0}, replyLen = strnlen(reply, HOSTAPD_TO_DWPAL_MSG_LENGTH); - uint64_t BytesSent = 0, BytesReceived = 0, PacketsSent = 0, PacketsReceived = 0, - LastDataDownlinkRate = 0, LastDataUplinkRate = 0, Active = 0; - char ShortTermRSSIAverage[32] = {'\0'}; - char SNR[32] = {'\0'}; - FieldsToParse fieldsToParse[] = { - {(void *)&BytesSent, &numOfValidArgs[0], DWPAL_LONG_LONG_INT_PARAM, "BytesSent=", 0}, - {(void *)&BytesReceived, &numOfValidArgs[1], DWPAL_LONG_LONG_INT_PARAM, - "BytesReceived=", 0}, - {(void *)&PacketsSent, &numOfValidArgs[2], DWPAL_LONG_LONG_INT_PARAM, "PacketsSent=", 0}, - {(void *)&PacketsReceived, &numOfValidArgs[3], DWPAL_LONG_LONG_INT_PARAM, - "PacketsReceived=", 0}, - {(void *)&sta_stats.retrans_count, &numOfValidArgs[4], DWPAL_INT_PARAM, "RetransCount=", 0}, - {(void *)ShortTermRSSIAverage, &numOfValidArgs[5], DWPAL_STR_PARAM, - "ShortTermRSSIAverage=", sizeof(ShortTermRSSIAverage)}, - {(void *)SNR, &numOfValidArgs[6], DWPAL_STR_PARAM, "SNR=", sizeof(SNR)}, - {(void *)&Active, &numOfValidArgs[7], DWPAL_LONG_LONG_INT_PARAM, "Active=", 0}, - {(void *)&LastDataDownlinkRate, &numOfValidArgs[8], DWPAL_LONG_LONG_INT_PARAM, - "LastDataDownlinkRate=", 0}, - {(void *)&LastDataUplinkRate, &numOfValidArgs[9], DWPAL_LONG_LONG_INT_PARAM, - "LastDataUplinkRate=", 0}, - - /* Must be at the end */ - {NULL, NULL, DWPAL_NUM_OF_PARSING_TYPES, NULL, 0}}; - - if (dwpal_string_to_struct_parse(reply, replyLen, fieldsToParse, sizeof(SStaStats)) == - DWPAL_FAILURE) { - LOG(ERROR) << "DWPAL parse error ==> Abort"; + // RSSI + if (!read_param("ShortTermRSSIAverage", reply, &tmp_str)) { + LOG(ERROR) << "Failed reading ShortTermRSSIAverage parameter!"; return false; } - - /* TEMP: Traces... */ - // LOG(DEBUG) << "GET_STA_MEASUREMENTS reply= \n" << reply; - // LOG(DEBUG) << "numOfValidArgs[0]= " << numOfValidArgs[0] << " BytesSent= " << BytesSent; - // LOG(DEBUG) << "numOfValidArgs[1]= " << numOfValidArgs[1] << " BytesReceived= " << BytesReceived; - // LOG(DEBUG) << "numOfValidArgs[2]= " << numOfValidArgs[2] << " PacketsSent= " << PacketsSent; - // LOG(DEBUG) << "numOfValidArgs[3]= " << numOfValidArgs[3] << " PacketsReceived= " << PacketsReceived; - // LOG(DEBUG) << "numOfValidArgs[4]= " << numOfValidArgs[4] << " RetransCount= " << sta_stats.retrans_count; - // LOG(DEBUG) << "numOfValidArgs[5]= " << numOfValidArgs[5] << " ShortTermRSSIAverage= " << ShortTermRSSIAverage; - // LOG(DEBUG) << "numOfValidArgs[6]= " << numOfValidArgs[6] << " SNR= " << SNR; - // LOG(DEBUG) << "numOfValidArgs[0]= " << numOfValidArgs[7] << " Active= " << Active; - // LOG(DEBUG) << "numOfValidArgs[7]= " << numOfValidArgs[8] << " LastDataDownlinkRate= " << LastDataDownlinkRate; - // LOG(DEBUG) << "numOfValidArgs[8]= " << numOfValidArgs[9] << " LastDataUplinkRate= " << LastDataUplinkRate; - /* End of TEMP: Traces... */ - - for (uint8_t i = 0; i < (sizeof(numOfValidArgs) / sizeof(size_t)); i++) { - if (numOfValidArgs[i] == 0) { - LOG(ERROR) << "Failed reading parsed parameter " << (int)i << " ==> Abort"; - return false; - } - } - - //save average RSSI in watt - // ShortTermRSSIAverage values are space-separated: - for (const auto &rssi : beerocks::string_utils::str_split(ShortTermRSSIAverage, ' ')) { - float s_float = float(beerocks::string_utils::stoi(std::string(rssi))); + // Format "ShortTermRSSIAverage=%d %d %d %d" + auto samples = beerocks::string_utils::str_split(tmp_str, ' '); + for (const auto &s : samples) { + float s_float = float(beerocks::string_utils::stoi(s)); if (s_float > beerocks::RSSI_MIN) { sta_stats.rx_rssi_watt += std::pow(10, s_float / float(10)); sta_stats.rx_rssi_watt_samples_cnt++; } } - //save average SNR in watt - // SNR values are space-separated: - for (const auto &snr : beerocks::string_utils::str_split(SNR, ' ')) { - float s_float = float(beerocks::string_utils::stoi(std::string(snr))); - if (s_float > beerocks::SNR_MIN) { + // SNR + if (!read_param("SNR", reply, &tmp_str)) { + LOG(ERROR) << "Failed reading SNR parameter!"; + return false; + } + // Format "SNR=%d %d %d %d" + samples = beerocks::string_utils::str_split(tmp_str, ' '); + for (const auto &s : samples) { + float s_float = float(beerocks::string_utils::stoi(s)); + if (s_float >= beerocks::SNR_MIN) { sta_stats.rx_snr_watt += std::pow(10, s_float / float(10)); sta_stats.rx_snr_watt_samples_cnt++; } } - // TODO: Update RSSI externally! - sta_stats.tx_phy_rate_100kb = (LastDataDownlinkRate / 100); - sta_stats.rx_phy_rate_100kb = (LastDataUplinkRate / 100); - calc_curr_traffic(BytesSent, sta_stats.tx_bytes_cnt, sta_stats.tx_bytes); - calc_curr_traffic(BytesReceived, sta_stats.rx_bytes_cnt, sta_stats.rx_bytes); - calc_curr_traffic(PacketsSent, sta_stats.tx_packets_cnt, sta_stats.tx_packets); - calc_curr_traffic(PacketsReceived, sta_stats.rx_packets_cnt, sta_stats.rx_packets); + // Last Downlink (TX) Rate + if (!read_param("LastDataDownlinkRate", reply, tmp_int)) { + LOG(ERROR) << "Failed reading LastDataDownlinkRate parameter!"; + return false; + } + sta_stats.tx_phy_rate_100kb = (tmp_int / 100); + + // Last Uplink (RX) Rate + if (!read_param("LastDataUplinkRate", reply, tmp_int)) { + LOG(ERROR) << "Failed reading LastDataUplinkRate parameter!"; + return false; + } + sta_stats.rx_phy_rate_100kb = (tmp_int / 100); + + // TX Bytes + if (!read_param("BytesSent", reply, tmp_int)) { + LOG(ERROR) << "Failed reading BytesSent parameter!"; + return false; + } + calc_curr_traffic(tmp_int, sta_stats.tx_bytes_cnt, sta_stats.tx_bytes); + + // RX Bytes + if (!read_param("BytesReceived", reply, tmp_int)) { + LOG(ERROR) << "Failed reading BytesReceived parameter!"; + return false; + } + calc_curr_traffic(tmp_int, sta_stats.rx_bytes_cnt, sta_stats.rx_bytes); + + // TX Packets + if (!read_param("PacketsSent", reply, tmp_int)) { + LOG(ERROR) << "Failed reading PacketsSent parameter!"; + return false; + } + calc_curr_traffic(tmp_int, sta_stats.rx_packets_cnt, sta_stats.rx_packets); + + // Retranmission Count + if (!read_param("RetransCount", reply, tmp_int, true)) { + LOG(ERROR) << "Failed reading RetransCount parameter!"; + return false; + } + sta_stats.retrans_count = tmp_int; return true; } From fe061ff922a63692ac18dcbf6d8c55d612800ee7 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Mon, 29 Jun 2020 06:57:30 +0000 Subject: [PATCH 139/453] controller: db: node: add persistent client params PPM-5. Preparative commit. Added client persistent parameters to the Node class. The parameters persistency will be handled by the db class and the BPL will provide the interface to save/read/clear the client's persistent parameters. The client persistent parameters enable the smart-client-steering feature by enabling client's steering configurations and decisions persistency across prplmesh restarts/reboots. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/node.cpp | 32 +++++++++++++++++ controller/src/beerocks/master/db/node.h | 40 ++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/controller/src/beerocks/master/db/node.cpp b/controller/src/beerocks/master/db/node.cpp index 9e5784e0dd..7a61d90731 100644 --- a/controller/src/beerocks/master/db/node.cpp +++ b/controller/src/beerocks/master/db/node.cpp @@ -29,6 +29,18 @@ node::node(beerocks::eType type_, const std::string &mac_) } namespace son { +std::ostream &operator<<(std::ostream &os, ePersistentParamBool value) +{ + if (value == ePersistentParamBool::DISABLE) { + os << "Disabled"; + } else if (value == ePersistentParamBool::ENABLE) { + os << "Enabled"; + } else { + os << "Not-Configured"; + } + return os; +} + std::ostream &operator<<(std::ostream &os, const node &n) { std::chrono::steady_clock::time_point tCurrTime = std::chrono::steady_clock::now(); @@ -121,6 +133,26 @@ std::ostream &operator<<(std::ostream &os, const node &n) << " Failed5ghzSteerAttemps: " << int(n.failed_5ghz_steer_attemps) << std::endl << " Failed24ghzSteerAttemps: " << int(n.failed_24ghz_steer_attemps) << std::endl; } + + // persistent db + if (node_type == beerocks::TYPE_CLIENT) { + auto client_parameters_last_edit_hours = std::chrono::duration_cast( + tCurrTime - n.client_parameters_last_edit) + .count(); + auto client_time_life_delay_hours = + std::chrono::duration_cast(n.client_time_life_delay_sec) + .count(); + os << "Persistent configuration and data:" << std::endl + << " ClientParametersLastEdit: " << (client_parameters_last_edit_hours / 24) + << " days, " << (client_parameters_last_edit_hours % 24) << " hours" << std::endl + << " ClientTimeLifeDelay: " << (client_time_life_delay_hours / 24) << " days, " + << (client_time_life_delay_hours % 24) << " hours" << std::endl + << " ClientStayOnInitialRadio: " << n.client_stay_on_initial_radio << std::endl + << " ClientInitialRadio: " << n.client_initial_radio << std::endl + << " ClientStayOnSelectedBand: " << n.client_stay_on_selected_band << std::endl + << " ClientSelectedBands: " << n.client_selected_bands << std::endl; + } + } else if (node_type == beerocks::TYPE_SLAVE) { os << " Type: HOSTAP" << std::endl << " IfaceType: " << utils::get_iface_type_string(n.hostap->iface_type) << std::endl diff --git a/controller/src/beerocks/master/db/node.h b/controller/src/beerocks/master/db/node.h index 638b9203b2..f9978022ab 100644 --- a/controller/src/beerocks/master/db/node.h +++ b/controller/src/beerocks/master/db/node.h @@ -35,6 +35,14 @@ typedef struct { bool backhaul_vap; } sVapElement; +/** + * @brief Extended boolean parameter to support "not configured" value for persistent configuration. + * For persistent data, it is important to differ between configured enable/disable to uncofigured value. + */ +enum class ePersistentParamBool : int8_t { NOT_CONFIGURED = -1, DISABLE = 0, ENABLE = 1 }; + +std::ostream &operator<<(std::ostream &os, ePersistentParamBool value); + class node { public: node(beerocks::eType type_, const std::string &mac_); @@ -267,6 +275,38 @@ class node { friend std::ostream &operator<<(std::ostream &os, const node &node); friend std::ostream &operator<<(std::ostream &os, const node *node); + /* + * Persistent configurations - start + * Client persistent configuration aging is refreshed on persistent configurations set + * persistent configuration of aged clients removed from the persistent-db and cleared in the runtime-db + */ + + // Indicates when client parameters were last updated (even if not updated yet to persistent-db) + // minimal value is used as invalid value. + std::chrono::steady_clock::time_point client_parameters_last_edit = + std::chrono::steady_clock::time_point::min(); + + // Optional - if configured the client has its own configured timelife delay. + std::chrono::seconds client_time_life_delay_sec = std::chrono::seconds::zero(); + + // If enabled, the client will be steered to the initial radio it connected to - save at client_initial_radio. + ePersistentParamBool client_stay_on_initial_radio = ePersistentParamBool::NOT_CONFIGURED; + + // The client_initial_radio bssid must be set. + sMacAddr client_initial_radio; + + // If enabled, the client will be steered to pre-selected-bands defined by client_selected_bands. + // Not enforced if client_selected_bands is not set. + ePersistentParamBool client_stay_on_selected_band = ePersistentParamBool::NOT_CONFIGURED; + + // The selected bands the client should be steered to if the client_stay_on_selected_band is set. + // Default value is FREQ_UNKNOWN (also indicates value is not configured) + beerocks::eFreqType client_selected_bands = beerocks::eFreqType::FREQ_UNKNOWN; + + /* + * Persistent configurations - end + */ + private: class rssi_measurement { public: From 0665c9280ae2f6318534a024a3a9c22a219e0db4 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Mon, 29 Jun 2020 09:58:33 +0000 Subject: [PATCH 140/453] controller: db: add persistent client params set/get stubs PPM-5. Preparative commit. Added setters and getters APIs stubs for the new client persistent params and clients get, clear, and update APIs. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 94 +++++++++++++ controller/src/beerocks/master/db/db.h | 160 +++++++++++++++++++++++ 2 files changed, 254 insertions(+) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index affa76da39..ebc281250b 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -2418,6 +2418,85 @@ const std::list &db::get_channel_scan_results(const sMacAdd return (single_scan ? hostap->single_scan_results : hostap->continuous_scan_results); } +// +// Client Persistent Data +// +bool db::is_client_in_persistent_db(const sMacAddr &mac) { return false; } + +bool db::add_client_to_persistent_db(const sMacAddr &mac, + std::unordered_map params) +{ + return true; +} + +std::chrono::steady_clock::time_point db::get_client_parameters_last_edit(const sMacAddr &mac) +{ + return std::chrono::steady_clock::time_point::min(); +} + +bool db::set_client_time_life_delay(const sMacAddr &mac, + const std::chrono::seconds &time_life_delay_sec, + bool save_to_persistent_db) +{ + return true; +} + +std::chrono::seconds db::get_client_time_life_delay(const sMacAddr &mac) +{ + return std::chrono::seconds::zero(); +} + +bool db::set_client_stay_on_initial_radio(const sMacAddr &mac, bool stay_on_initial_radio, + bool save_to_persistent_db) +{ + return true; +} + +ePersistentParamBool db::get_client_stay_on_initial_radio(const sMacAddr &mac) +{ + return ePersistentParamBool::NOT_CONFIGURED; +} + +bool db::set_client_initial_radio(const sMacAddr &mac, const sMacAddr &initial_radio_mac, + bool save_to_persistent_db) +{ + return true; +} + +sMacAddr db::get_client_initial_radio(const sMacAddr &mac) { return network_utils::ZERO_MAC; } + +bool db::set_client_stay_on_selected_band(const sMacAddr &mac, bool stay_on_selected_band, + bool save_to_persistent_db) +{ + return true; +} + +ePersistentParamBool db::get_client_stay_on_selected_band(const sMacAddr &mac) +{ + return ePersistentParamBool::NOT_CONFIGURED; +} + +bool db::set_client_selected_bands(const sMacAddr &mac, beerocks::eFreqType selected_bands, + bool save_to_persistent_db) +{ + return true; +} + +beerocks::eFreqType db::get_client_selected_bands(const sMacAddr &mac) +{ + return beerocks::eFreqType::FREQ_UNKNOWN; +} + +bool db::clear_client_persistent_db(const sMacAddr &mac) { return true; } + +bool db::update_client_persistent_db(const sMacAddr &mac) { return true; } + +std::unordered_map> +db::load_persistent_db_clients() +{ + return {}; +} + // // CLI // @@ -3493,6 +3572,21 @@ std::shared_ptr db::get_node(sMacAddr al_mac, sMacAddr ruid) return get_node(key); } +std::shared_ptr db::get_node_verify_type(const sMacAddr &mac, beerocks::eType type) +{ + auto node = get_node(mac); + if (!node) { + LOG(ERROR) << "node not found for mac " << mac; + return nullptr; + } else if (node->get_type() != type) { + LOG(ERROR) << __FUNCTION__ << "node " << mac << " type(" << node->get_type() + << ") != requested-type(" << type << ")"; + return nullptr; + } + + return node; +} + std::shared_ptr db::get_hostap_by_mac(const sMacAddr &mac) { auto n = get_node(mac); diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index ee2ec0f200..e4d6fbfc0c 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -593,6 +593,157 @@ class db { const std::list &get_channel_scan_results(const sMacAddr &mac, bool single_scan); + // + // Client Persistent Data + // + /** + * @brief Check if client exists in persistent db. + * + * @param mac MAC address of a client. + * @return true if client exists, false otherwise. + */ + bool is_client_in_persistent_db(const sMacAddr &mac); + + /** + * @brief Adds a client to the persistent db, if already exists, remove old entry and add a new one. + * + * @param mac MAC address of a client. + * @param params An unordered map of key-value of client parameters. + * @return true on success, otherwise false. + */ + bool add_client_to_persistent_db(const sMacAddr &mac, + std::unordered_map params = + std::unordered_map()); + + /** + * @brief Get the client's parameters last edit time. + * + * @param mac MAC address of a client. + * @return Client persistent data last edit time (even if edit was done only to runtime-dbb and not saved to persistent db), or time_point::min() if not-configured or failure. + */ + std::chrono::steady_clock::time_point get_client_parameters_last_edit(const sMacAddr &mac); + + /** + * @brief Set the client's time-life delay. + * + * @param mac MAC address of a client. + * @param time_life_delay_sec Client-specific aging time. + * @param save_to_persistent_db If set to true, update the persistent-db (write-through), default is true. + * @return true on success, otherwise false. + */ + bool set_client_time_life_delay(const sMacAddr &mac, + const std::chrono::seconds &time_life_delay_sec, + bool save_to_persistent_db = true); + + /** + * @brief Get the client's time-life delay. + * + * @param mac MAC address of a client. + * @return Client time-life delay, value of 0 means not-configured. + */ + std::chrono::seconds get_client_time_life_delay(const sMacAddr &mac); + + /** + * @brief Set the client's stay-on-initial-radio. + * + * @param mac MAC address of a client. + * @param stay_on_initial_radio Enable client stay on the radio it initially connected to. + * @param save_to_persistent_db If set to true, update the persistent-db (write-through), default is true. + * @return true on success, otherwise false. + */ + bool set_client_stay_on_initial_radio(const sMacAddr &mac, bool stay_on_initial_radio, + bool save_to_persistent_db = true); + + /** + * @brief Get the client's stay-on-initial-radio. + * + * @param mac MAC address of a client. + * @return Enable client stay on the radio it initially connected to. + */ + ePersistentParamBool get_client_stay_on_initial_radio(const sMacAddr &mac); + + /** + * @brief Set the client's initial-radio. + * + * @param mac MAC address of a client. + * @param initial_radio_mac The MAC address of the radio that the client has initially connected to. + * @param save_to_persistent_db If set to true, update the persistent-db (write-through), default is true. + * @return true on success, otherwise false. + */ + bool set_client_initial_radio(const sMacAddr &mac, const sMacAddr &initial_radio_mac, + bool save_to_persistent_db = true); + + /** + * @brief Get the client's initial-radio. + * + * @param mac MAC address of a client. + * @return MAC adddress of the radio that the client has initially connected to. + */ + sMacAddr get_client_initial_radio(const sMacAddr &mac); + + /** + * @brief Set the client's stay-on-selected-band. + * + * @param mac MAC address of a client. + * @param stay_on_selected_band Enable client stay on the selected band/bands. + * @param save_to_persistent_db If set to true, update the persistent-db (write-through), default is true. + * @return true on success, otherwise false. + */ + bool set_client_stay_on_selected_band(const sMacAddr &mac, bool stay_on_selected_band, + bool save_to_persistent_db = true); + + /** + * @brief Get the client's stay-on-selected-band. + * + * @param mac MAC address of a client. + * @return Enable client stay on the selected band/bands. + */ + ePersistentParamBool get_client_stay_on_selected_band(const sMacAddr &mac); + + /** + * @brief Set the client's selected-bands. + * + * @param mac MAC address of a client. + * @param selected_bands Client selected band/bands. FREQ_UNKNOWN is considered as "not-configured". + * @param save_to_persistent_db If set to true, update the persistent-db (write-through), default is true. + * @return true on success, otherwise false. + */ + bool set_client_selected_bands(const sMacAddr &mac, beerocks::eFreqType selected_bands, + bool save_to_persistent_db = true); + + /** + * @brief Get the client's selected-bands. + * + * @param mac MAC address of a client. + * @return Selected band/bands. + */ + beerocks::eFreqType get_client_selected_bands(const sMacAddr &mac); + + /** + * @brief Clear client's persistent information. + * + * @param mac MAC address of a client. + * @return true on success, otherwise false. + */ + bool clear_client_persistent_db(const sMacAddr &mac); + + /** + * @brief Update client's persistent information with the runtime information. + * + * @param mac MAC address of a client. + * @return true on success, otherwise false. + */ + bool update_client_persistent_db(const sMacAddr &mac); + + /** + * @brief Load all clients from persistent db. + * + * @return An unordered map of clients, for each client unordered map of params as key-value. + * @return An empty map of clients is returned if the persistent db is empty. + */ + std::unordered_map> + load_persistent_db_clients(); + // // CLI // @@ -865,6 +1016,15 @@ class db { std::shared_ptr get_node(std::string key); //key can be or _ std::shared_ptr get_node(sMacAddr mac); std::shared_ptr get_node(sMacAddr al_mac, sMacAddr ruid); + /** + * @brief Returns the node object after verifing node type. + * if node is found but type is not requested type a nullptr is returned. + * + * @param mac MAC address of the node. + * @param type The type of node used for node-type verification. + * @return std::shared_ptr pointer to the node on success, nullptr otherwise. + */ + std::shared_ptr get_node_verify_type(const sMacAddr &mac, beerocks::eType type); std::shared_ptr get_hostap_by_mac(const sMacAddr &mac); int get_node_hierarchy(std::shared_ptr n); std::set> get_node_subtree(std::shared_ptr n); From fc4ef08a9718e33f214e03603ef15bb1851ff7f5 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Mon, 29 Jun 2020 11:21:07 +0000 Subject: [PATCH 141/453] controller: db: implement client params set/get in runtime DB PPM-5. The operation of getting the client's persistent parameter is by reading it from the runtime controller DB. The operation of getting the client's persistent parameter can be to the runtime controller DB only, or write-through (if the set-persistent-db is set to true). Implemented getters from runtime controller DB. Implemented setters only to runtime controller DB. (Implementation of set to persistent DB using BPL is provided as a separate commit) Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 155 ++++++++++++++++++++++- 1 file changed, 148 insertions(+), 7 deletions(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index ebc281250b..19b660c2eb 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -2431,63 +2431,204 @@ bool db::add_client_to_persistent_db(const sMacAddr &mac, std::chrono::steady_clock::time_point db::get_client_parameters_last_edit(const sMacAddr &mac) { - return std::chrono::steady_clock::time_point::min(); + auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); + if (!node) { + LOG(ERROR) << "client node not found for mac " << mac; + return std::chrono::steady_clock::time_point::min(); + } + + return node->client_parameters_last_edit; } bool db::set_client_time_life_delay(const sMacAddr &mac, const std::chrono::seconds &time_life_delay_sec, bool save_to_persistent_db) { + auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); + if (!node) { + LOG(ERROR) << "client node not found for mac " << mac; + return false; + } + + LOG(DEBUG) << "time_life_delay_sec = " << time_life_delay_sec.count(); + + auto timestamp = std::chrono::steady_clock::now(); + if (save_to_persistent_db) { + LOG(DEBUG) << "configuring persistent-db, timelife = " << time_life_delay_sec.count(); + } + + node->client_time_life_delay_sec = time_life_delay_sec; + node->client_parameters_last_edit = timestamp; + return true; } std::chrono::seconds db::get_client_time_life_delay(const sMacAddr &mac) { - return std::chrono::seconds::zero(); + auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); + if (!node) { + LOG(ERROR) << "client node not found for mac " << mac; + return std::chrono::seconds::zero(); + } + + return node->client_time_life_delay_sec; } bool db::set_client_stay_on_initial_radio(const sMacAddr &mac, bool stay_on_initial_radio, bool save_to_persistent_db) { + auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); + if (!node) { + LOG(ERROR) << "client node not found for mac " << mac; + return false; + } + + LOG(DEBUG) << "stay_on_initial_radio = " << stay_on_initial_radio; + + auto timestamp = std::chrono::steady_clock::now(); + if (save_to_persistent_db) { + LOG(DEBUG) << "configuring persistent-db, initial_radio_enable = " << stay_on_initial_radio; + } + + node->client_stay_on_initial_radio = + (stay_on_initial_radio) ? ePersistentParamBool::ENABLE : ePersistentParamBool::DISABLE; + node->client_parameters_last_edit = timestamp; + return true; } ePersistentParamBool db::get_client_stay_on_initial_radio(const sMacAddr &mac) { - return ePersistentParamBool::NOT_CONFIGURED; + auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); + if (!node) { + LOG(ERROR) << "client node not found for mac " << mac; + return ePersistentParamBool::NOT_CONFIGURED; + } + + return node->client_stay_on_initial_radio; } bool db::set_client_initial_radio(const sMacAddr &mac, const sMacAddr &initial_radio_mac, bool save_to_persistent_db) { + auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); + if (!node) { + LOG(ERROR) << "client node not found for mac " << mac; + return false; + } + + LOG(DEBUG) << "initial_radio = " << initial_radio_mac; + + auto timestamp = std::chrono::steady_clock::now(); + if (save_to_persistent_db) { + LOG(DEBUG) << "configuring persistent-db, initial_radio = " << initial_radio_mac; + } + + node->client_initial_radio = initial_radio_mac; + node->client_parameters_last_edit = timestamp; + return true; } -sMacAddr db::get_client_initial_radio(const sMacAddr &mac) { return network_utils::ZERO_MAC; } +sMacAddr db::get_client_initial_radio(const sMacAddr &mac) +{ + auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); + if (!node) { + LOG(ERROR) << "client node not found for mac " << mac; + return network_utils::ZERO_MAC; + } + + return node->client_initial_radio; +} bool db::set_client_stay_on_selected_band(const sMacAddr &mac, bool stay_on_selected_band, bool save_to_persistent_db) { + auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); + if (!node) { + LOG(ERROR) << "client node not found for mac " << mac; + return false; + } + + LOG(DEBUG) << "stay_on_selected_band = " << stay_on_selected_band; + + auto timestamp = std::chrono::steady_clock::now(); + if (save_to_persistent_db) { + LOG(DEBUG) << "configuring persistent-db, selected_band_enable = " << stay_on_selected_band; + } + + node->client_stay_on_selected_band = + (stay_on_selected_band) ? ePersistentParamBool::ENABLE : ePersistentParamBool::DISABLE; + node->client_parameters_last_edit = timestamp; + return true; } ePersistentParamBool db::get_client_stay_on_selected_band(const sMacAddr &mac) { - return ePersistentParamBool::NOT_CONFIGURED; + auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); + if (!node) { + LOG(ERROR) << "client node not found for mac " << mac; + return ePersistentParamBool::NOT_CONFIGURED; + } + + return node->client_stay_on_selected_band; } bool db::set_client_selected_bands(const sMacAddr &mac, beerocks::eFreqType selected_bands, bool save_to_persistent_db) { + auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); + if (!node) { + LOG(ERROR) << "client node not found for mac " << mac; + return false; + } + + LOG(DEBUG) << "selected_band = " << int(selected_bands); + + auto timestamp = std::chrono::steady_clock::now(); + if (save_to_persistent_db) { + LOG(DEBUG) << ", configuring persistent-db, selected_bands = " << int(selected_bands); + } + + node->client_selected_bands = selected_bands; + node->client_parameters_last_edit = timestamp; + return true; } beerocks::eFreqType db::get_client_selected_bands(const sMacAddr &mac) { - return beerocks::eFreqType::FREQ_UNKNOWN; + auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); + if (!node) { + LOG(ERROR) << "client node not found for mac " << mac; + return beerocks::eFreqType::FREQ_UNKNOWN; + } + + return node->client_selected_bands; } -bool db::clear_client_persistent_db(const sMacAddr &mac) { return true; } +bool db::clear_client_persistent_db(const sMacAddr &mac) +{ + auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); + if (!node) { + LOG(ERROR) << "client node not found for mac " << mac; + return false; + } + + LOG(DEBUG) << "setting client " << mac << " runtime info to default values"; + + node->client_parameters_last_edit = std::chrono::steady_clock::time_point::min(); + node->client_time_life_delay_sec = std::chrono::seconds::zero(); + node->client_stay_on_initial_radio = ePersistentParamBool::NOT_CONFIGURED; + node->client_initial_radio = network_utils::ZERO_MAC; + node->client_stay_on_selected_band = ePersistentParamBool::NOT_CONFIGURED; + node->client_selected_bands = beerocks::eFreqType::FREQ_UNKNOWN; + + LOG(DEBUG) << "removing client " << mac << " from persistent db"; + + return true; +} bool db::update_client_persistent_db(const sMacAddr &mac) { return true; } From dd602f1c5514844e73972a38413e8207356681f6 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Tue, 30 Jun 2020 13:07:04 +0000 Subject: [PATCH 142/453] controller: db: add static helper functions PPM-5. Preparative commit. added helper functions for translation of persistent client configurations to/from string. added helper functions for translation of db_entry of client to/from mac address. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 53 ++++++++++++++++++++++++ controller/src/beerocks/master/db/db.h | 42 +++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index 19b660c2eb..ea5effd010 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -19,6 +19,59 @@ using namespace beerocks_message; using namespace son; using namespace net; +// static +std::string db::type_to_string(beerocks::eType type) +{ + switch (type) { + case beerocks::eType::TYPE_GW: + return "gateway"; + case beerocks::eType::TYPE_IRE: + return "ire"; + case beerocks::eType::TYPE_IRE_BACKHAUL: + return "ire_bh"; + case beerocks::eType::TYPE_SLAVE: + return "slave"; + case beerocks::eType::TYPE_CLIENT: + return "client"; + case beerocks::eType::TYPE_ETH_SWITCH: + return "eth_switch"; + case beerocks::eType::TYPE_ANY: + return "any"; + default: + return {}; + } +} + +std::string db::client_db_entry_from_mac(const sMacAddr &mac) +{ + std::string db_entry = tlvf::mac_to_string(mac); + std::replace(db_entry.begin(), db_entry.end(), ':', '_'); + + return db_entry; +} + +sMacAddr db::client_db_entry_to_mac(const std::string &db_entry) +{ + std::string entry = db_entry; + + std::replace(entry.begin(), entry.end(), '_', ':'); + + return tlvf::mac_from_string(entry); +} + +std::string db::timestamp_to_string_seconds(const std::chrono::steady_clock::time_point timestamp) +{ + return std::to_string( + std::chrono::duration_cast(timestamp.time_since_epoch()).count()); +} + +std::chrono::steady_clock::time_point db::timestamp_from_seconds(int timestamp_sec) +{ + return std::chrono::steady_clock::time_point(std::chrono::seconds(timestamp_sec)); +} + +// static - end + void db::set_log_level_state(const beerocks::eLogLevel &log_level, const bool &new_state) { logger.set_log_level_state(log_level, new_state); diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index e4d6fbfc0c..20c003e06b 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -161,6 +161,48 @@ class db { } ~db(){}; + //static + /** + * @brief Get string representation of node type. + * + * @param type Type of a node. + * @return std::string the string representation of the type. + */ + static std::string type_to_string(beerocks::eType type); + + /** + * @brief Get db entry from MAC address. + * + * @param mac MAC address of a client. + * @return std::string the string representation of the MAC address with ':' replaced with '_' removed. + */ + static std::string client_db_entry_from_mac(const sMacAddr &mac); + + /** + * @brief Get client MAC address from db entry. + * + * @param db_entry Client entry name in persistent db. + * @return sMacAddr MAC address of the client the db_entry is representing. + */ + static sMacAddr client_db_entry_to_mac(const std::string &db_entry); + + /** + * @brief Get string representation of number of seconds in timestamp. + * + * @param timestamp A time-point. + * @return std::string the string representation of the integer number of seconds in the timestamp. + */ + static std::string + timestamp_to_string_seconds(const std::chrono::steady_clock::time_point timestamp); + + /** + * @brief Translate an integer number of seconds to a timepoint. + * + * @param timestamp_sec Number of seconds in the timestamp. + * @return std::chrono::steady_clock::time_point a time-point representation of the number of seconds. + */ + static std::chrono::steady_clock::time_point timestamp_from_seconds(int timestamp_sec); + //logger void set_log_level_state(const beerocks::eLogLevel &log_level, const bool &new_state); From 26cda20600e464986de9f92b595973bc7afb22ce Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Tue, 30 Jun 2020 14:34:15 +0000 Subject: [PATCH 143/453] controller: db: add private function to update client entry PPM-5. Preparative commit. Added a private function that encapsulates any required validation before updating or adding the client entry in the persistent db using the BPL APIs. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 20 ++++++++++++++++++++ controller/src/beerocks/master/db/db.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index ea5effd010..a2cb0a18ec 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -3992,3 +3993,22 @@ void db::set_prplmesh(const sMacAddr &mac) } get_node(mac)->is_prplmesh = true; } + +bool db::update_client_entry_in_persistent_db( + const sMacAddr &mac, std::unordered_map values_map) +{ + auto db_entry = client_db_entry_from_mac(mac); + auto type_client_str = type_to_string(beerocks::eType::TYPE_CLIENT); + + if (!bpl::db_has_entry(type_client_str, db_entry)) { + if (!add_client_to_persistent_db(mac, values_map)) { + LOG(ERROR) << "failed to add client entry in persistent-db for " << mac; + return false; + } + } else if (!bpl::db_set_entry(type_client_str, db_entry, values_map)) { + LOG(ERROR) << "failed to set client in persistent-db for " << mac; + return false; + } + + return true; +} diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index 20c003e06b..cfa94506eb 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -1081,6 +1081,9 @@ class db { void rewind(); bool get_next_node(std::shared_ptr &n, int &hierarchy); bool get_next_node(std::shared_ptr &n); + bool + update_client_entry_in_persistent_db(const sMacAddr &mac, + std::unordered_map values_map); int network_optimization_task_id = -1; int channel_selection_task_id = -1; From 0743a3a1090026af3a19b77f6982bada71c923b7 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Tue, 30 Jun 2020 14:49:23 +0000 Subject: [PATCH 144/453] controller: db: save client persistent params to bpl db PPM-5. Implemented saving client persistent data to the persistent DB using the "bpl::db_" APIs. Implemented function to check if the client exists in persistent DB. Implemented add/remove of client entry to/from persistent DB. Implemented a function to save all client's configured persistent data from runtime controller DB to persistent controller DB. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 175 ++++++++++++++++++++++- 1 file changed, 172 insertions(+), 3 deletions(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index a2cb0a18ec..3e5d39af26 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -20,6 +20,13 @@ using namespace beerocks_message; using namespace son; using namespace net; +static const std::string timestamp_str = "timestamp"; +static const std::string timelife_delay_str = "timelife"; +static const std::string initial_radio_enable_str = "initial_radio_enable"; +static const std::string initial_radio_str = "initial_radio"; +static const std::string selected_band_enable_str = "selected_band_enable"; +static const std::string selected_bands_str = "selected_bands"; + // static std::string db::type_to_string(beerocks::eType type) { @@ -2475,11 +2482,38 @@ const std::list &db::get_channel_scan_results(const sMacAdd // // Client Persistent Data // -bool db::is_client_in_persistent_db(const sMacAddr &mac) { return false; } +bool db::is_client_in_persistent_db(const sMacAddr &mac) +{ + auto client_db_entry = client_db_entry_from_mac(mac); + + return bpl::db_has_entry(type_to_string(beerocks::eType::TYPE_CLIENT), client_db_entry); +} bool db::add_client_to_persistent_db(const sMacAddr &mac, std::unordered_map params) { + auto db_entry = client_db_entry_from_mac(mac); + + if (!bpl::db_has_entry(std::string("type"), db_entry)) { + // if entry already exists in DB + if (!bpl::db_remove_entry(std::string("type"), db_entry)) { + LOG(ERROR) << "failed to remove client entry " << db_entry + << "from persistent db (for re-adding)"; + return false; + } + } else if (!bpl::db_has_entry(std::string(), db_entry)) { + // if entry exists in db but with different type + LOG(ERROR) << "client entry cannot be added to persistent db, " << db_entry + << " already exists but with different type"; + return false; + } + // add entry to the persistent db + if (!bpl::db_add_entry(type_to_string(beerocks::eType::TYPE_CLIENT), db_entry, params)) { + LOG(ERROR) << "failed to add client entry " << db_entry << " to persistent db"; + return false; + } + LOG(DEBUG) << "added client entry " << db_entry << " to persistent db"; + return true; } @@ -2509,6 +2543,16 @@ bool db::set_client_time_life_delay(const sMacAddr &mac, auto timestamp = std::chrono::steady_clock::now(); if (save_to_persistent_db) { LOG(DEBUG) << "configuring persistent-db, timelife = " << time_life_delay_sec.count(); + + std::unordered_map values_map; + values_map.at(timestamp_str) = timestamp_to_string_seconds(timestamp); + values_map.at(timelife_delay_str) = std::to_string(time_life_delay_sec.count()); + + // update the persistent db + if (!update_client_entry_in_persistent_db(mac, values_map)) { + LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; + return false; + } } node->client_time_life_delay_sec = time_life_delay_sec; @@ -2542,6 +2586,16 @@ bool db::set_client_stay_on_initial_radio(const sMacAddr &mac, bool stay_on_init auto timestamp = std::chrono::steady_clock::now(); if (save_to_persistent_db) { LOG(DEBUG) << "configuring persistent-db, initial_radio_enable = " << stay_on_initial_radio; + + std::unordered_map values_map; + values_map.at(timestamp_str) = timestamp_to_string_seconds(timestamp); + values_map.at(initial_radio_enable_str) = std::to_string(stay_on_initial_radio); + + // update the persistent db + if (!update_client_entry_in_persistent_db(mac, values_map)) { + LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; + return false; + } } node->client_stay_on_initial_radio = @@ -2576,6 +2630,16 @@ bool db::set_client_initial_radio(const sMacAddr &mac, const sMacAddr &initial_r auto timestamp = std::chrono::steady_clock::now(); if (save_to_persistent_db) { LOG(DEBUG) << "configuring persistent-db, initial_radio = " << initial_radio_mac; + + std::unordered_map values_map; + values_map.at(timestamp_str) = timestamp_to_string_seconds(timestamp); + values_map.at(initial_radio_str) = tlvf::mac_to_string(initial_radio_mac); + + // update the persistent db + if (!update_client_entry_in_persistent_db(mac, values_map)) { + LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; + return false; + } } node->client_initial_radio = initial_radio_mac; @@ -2609,6 +2673,16 @@ bool db::set_client_stay_on_selected_band(const sMacAddr &mac, bool stay_on_sele auto timestamp = std::chrono::steady_clock::now(); if (save_to_persistent_db) { LOG(DEBUG) << "configuring persistent-db, selected_band_enable = " << stay_on_selected_band; + + std::unordered_map values_map; + values_map.at(timestamp_str) = timestamp_to_string_seconds(timestamp); + values_map.at(selected_band_enable_str) = std::to_string(stay_on_selected_band); + + // update the persistent db + if (!update_client_entry_in_persistent_db(mac, values_map)) { + LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; + return false; + } } node->client_stay_on_selected_band = @@ -2643,6 +2717,16 @@ bool db::set_client_selected_bands(const sMacAddr &mac, beerocks::eFreqType sele auto timestamp = std::chrono::steady_clock::now(); if (save_to_persistent_db) { LOG(DEBUG) << ", configuring persistent-db, selected_bands = " << int(selected_bands); + + std::unordered_map values_map; + values_map.at(timestamp_str) = timestamp_to_string_seconds(timestamp); + values_map.at(selected_bands_str) = std::to_string(selected_bands); + + // update the persistent db + if (!update_client_entry_in_persistent_db(mac, values_map)) { + LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; + return false; + } } node->client_selected_bands = selected_bands; @@ -2680,16 +2764,101 @@ bool db::clear_client_persistent_db(const sMacAddr &mac) node->client_selected_bands = beerocks::eFreqType::FREQ_UNKNOWN; LOG(DEBUG) << "removing client " << mac << " from persistent db"; + auto db_entry = client_db_entry_from_mac(mac); + auto type_client_str = type_to_string(beerocks::eType::TYPE_CLIENT); + if (!bpl::db_has_entry(type_client_str, db_entry)) { + LOG(DEBUG) << "client entry does not exist in persistent-db for " << db_entry; + return true; + } + + if (!bpl::db_remove_entry(type_client_str, db_entry)) { + LOG(ERROR) << "failed to remove client entry " << db_entry; + return false; + } return true; } -bool db::update_client_persistent_db(const sMacAddr &mac) { return true; } +bool db::update_client_persistent_db(const sMacAddr &mac) +{ + auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); + if (!node) { + LOG(ERROR) << "client node not found for mac " << mac; + return false; + } + + // any persistent parameter update also sets the last-edit timestamp + // if it is with default value - no other persistent configuration was performed + if (node->client_parameters_last_edit == std::chrono::steady_clock::time_point::min()) { + LOG(DEBUG) << "persistent client parameters are empty for " << mac + << ", no need to update persistent-db"; + return true; + } + + std::unordered_map values_map; + + //fill values map of client persistent params + values_map.at(timestamp_str) = timestamp_to_string_seconds(node->client_parameters_last_edit); + + if (node->client_time_life_delay_sec != std::chrono::seconds::zero()) { + LOG(DEBUG) << "setting client time-life-delay in persistent-db to for " << mac << " to " + << node->client_time_life_delay_sec.count(); + values_map.at(timelife_delay_str) = + std::to_string(node->client_time_life_delay_sec.count()); + } + + if (node->client_stay_on_initial_radio != ePersistentParamBool::NOT_CONFIGURED) { + auto enable = (node->client_stay_on_initial_radio == ePersistentParamBool::ENABLE); + LOG(DEBUG) << "setting client stay-on-initial-radio in persistent-db to for " << mac + << " to " << enable; + values_map.at(initial_radio_enable_str) = std::to_string(enable); + } + + if (node->client_initial_radio != network_utils::ZERO_MAC) { + LOG(DEBUG) << "setting client initial-radio in persistent-db to for " << mac << " to " + << node->client_initial_radio; + values_map.at(initial_radio_str) = tlvf::mac_to_string(node->client_initial_radio); + } + + if (node->client_stay_on_selected_band != ePersistentParamBool::NOT_CONFIGURED) { + auto enable = (node->client_stay_on_selected_band == ePersistentParamBool::ENABLE); + LOG(DEBUG) << "setting client stay-on-selected-band in persistent-db to for " << mac + << " to " << enable; + values_map.at(selected_band_enable_str) = std::to_string(enable); + } + + if (node->client_selected_bands != beerocks::eFreqType::FREQ_UNKNOWN) { + LOG(DEBUG) << "setting client selected-bands in persistent-db to for " << mac << " to " + << node->client_selected_bands; + values_map.at(selected_bands_str) = std::to_string(node->client_selected_bands); + } + + // update the persistent db + if (!update_client_entry_in_persistent_db(mac, values_map)) { + LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; + return false; + } + + LOG(DEBUG) << "client successfully updated in persistent-db for " << mac; + + return true; +} std::unordered_map> db::load_persistent_db_clients() { - return {}; + std::unordered_map> clients; + if (!bpl::db_get_entries_by_type(type_to_string(beerocks::eType::TYPE_CLIENT), clients)) { + LOG(ERROR) << "failed to get all clients from persistent DB"; + return {}; + } + + if (clients.empty()) { + LOG(DEBUG) << "persistent DB doesn't exist (or empty) or doesn't contain clients"; + return {}; + } + + return clients; } // From 34054c65fbf4fbdcd8fd44dee5b9a6ea5e680764 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 15:42:06 +0000 Subject: [PATCH 145/453] bcl: event_loop: interface update Change the definition of run() to single iteration of the loop. Remove die() as the loop will return after a single iteration anyway. Signed-off-by: Vitaly Bukhovsky --- .../bcl/include/bcl/beerocks_event_loop.h | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/common/beerocks/bcl/include/bcl/beerocks_event_loop.h b/common/beerocks/bcl/include/bcl/beerocks_event_loop.h index e8d66d2771..4e087147ae 100644 --- a/common/beerocks/bcl/include/bcl/beerocks_event_loop.h +++ b/common/beerocks/bcl/include/bcl/beerocks_event_loop.h @@ -150,23 +150,14 @@ template class EventLoop { /** * @brief Runs message loop. * - * Method returns when loop is explicitly terminated, when an error or timeout occurs - * or when there is no event to wait for (i.e.: no handler installed). + * Performs a single loop iteration and returns after processing IO events + * or when an error or timeout occurs. * * @return -1 on critical errors - * @return 0 on timeout without any socket events + * @return 0 on timeout without any socket events * @return >0 number of socket events processed during the class to this method. */ virtual int run() = 0; - - /** - * @brief Terminates a running event loop. - * - * This method asks for loop termination and returns immediately. It is not thread-safe and - * should only be called from an event handler (which runs on the same thread as the event - * loop). - */ - virtual void die() = 0; }; } // namespace beerocks From 11b07c9e6b26a203a7cf1b5044a9856b5c54a955 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 15:45:01 +0000 Subject: [PATCH 146/453] bcl: socket_event_loop: align to base event loop Align the socket event loop implementation to the changes in the base event loop. Change replace run() with event_loop() and remove die(). Signed-off-by: Vitaly Bukhovsky --- .../include/bcl/beerocks_socket_event_loop.h | 32 ++++--------------- .../bcl/source/beerocks_socket_event_loop.cpp | 22 ------------- 2 files changed, 6 insertions(+), 48 deletions(-) diff --git a/common/beerocks/bcl/include/bcl/beerocks_socket_event_loop.h b/common/beerocks/bcl/include/bcl/beerocks_socket_event_loop.h index cb1f26e266..6158d746fe 100644 --- a/common/beerocks/bcl/include/bcl/beerocks_socket_event_loop.h +++ b/common/beerocks/bcl/include/bcl/beerocks_socket_event_loop.h @@ -44,36 +44,21 @@ class SocketEventLoop : public EventLoop, std::chrono::m /** * @see EventPoll::add_event */ - virtual bool add_event(SocketEventLoop::EventType socket, - SocketEventLoop::EventHandlers handlers, + virtual bool add_event(EventType socket, EventHandlers handlers, TimeoutType timeout = TimeoutType::min()) override; /** * @see EventPoll::del_event */ - virtual bool del_event(SocketEventLoop::EventType socket) override; + virtual bool del_event(EventType socket) override; - /** - * @see EventPoll::run - */ - virtual int run() override; - - /** - * @see EventPoll::die - */ - virtual void die() override; - -protected: /** * @brief Main event loop method. + * @see EventPoll::run * * Executes the epoll_wait() function and processes ocurred events. - * - * @return -1 on critical errors - * @return 0 on timeout without any socket events - * @return >0 number of socket events processed during the call to this method. */ - virtual int event_loop(); + virtual int run() override; private: /** @@ -86,11 +71,6 @@ class SocketEventLoop : public EventLoop, std::chrono::m */ TimeoutType m_timeout = TimeoutType::min(); - /** - * Flag to mark whether the event loop is running. - */ - bool m_running = false; - /** * @brief Data structure representing a socket added to the poll. * This structure groups all the information required for processing socket events. @@ -99,12 +79,12 @@ class SocketEventLoop : public EventLoop, std::chrono::m /** * Socket event handler functions structure. */ - SocketEventLoop::EventHandlers handlers; + EventHandlers handlers; /** * Shared pointer to the socket object. */ - SocketEventLoop::EventType socket = nullptr; + EventType socket = nullptr; /** * timer file descriptor. diff --git a/common/beerocks/bcl/source/beerocks_socket_event_loop.cpp b/common/beerocks/bcl/source/beerocks_socket_event_loop.cpp index 99231f339f..597cf152d0 100644 --- a/common/beerocks/bcl/source/beerocks_socket_event_loop.cpp +++ b/common/beerocks/bcl/source/beerocks_socket_event_loop.cpp @@ -207,28 +207,6 @@ bool SocketEventLoop::del_event(SocketEventLoop::EventType socket) } int SocketEventLoop::run() -{ - if (m_running) { - return 0; - } - - // Event loop is running - m_running = true; - - // Run the event loop and exit on failures or timeouts (if defined) - while (m_running) { - auto ret = event_loop(); - if (ret <= 0) { - return ret; - } - } - - return 0; -} - -void SocketEventLoop::die() { m_running = false; } - -int SocketEventLoop::event_loop() { // Poll events epoll_event events[MAX_POLL_EVENTS] = {0}; From 97c1b1e1ee08db2ea5fe015bd6334769b57b0b4b Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 15:47:24 +0000 Subject: [PATCH 147/453] bcl: socket: fix memory leakage valgrind detected memory leakge when setting the SO_REUSEADDR option for server sockets. Use regular int instead of a pointer to avoid the issue. Signed-off-by: Vitaly Bukhovsky --- common/beerocks/bcl/source/network/socket.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/common/beerocks/bcl/source/network/socket.cpp b/common/beerocks/bcl/source/network/socket.cpp index 04dbc9bf14..1a9a0f128d 100644 --- a/common/beerocks/bcl/source/network/socket.cpp +++ b/common/beerocks/bcl/source/network/socket.cpp @@ -284,14 +284,8 @@ SocketServer::SocketServer(int port, int connections, SocketMode mode) addr.sin_addr.s_addr = INADDR_ANY; addr.sin_port = htons(port); -#ifdef IS_WINDOWS - BOOL enable_b = TRUE; - char *enable = (char *)&enable_b; -#else - int enable_b = 1; - int *enable = &enable_b; -#endif - if (setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, enable, sizeof(enable)) < 0) { + int enable = 1; + if (setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)) < 0) { closesocket(m_socket); m_socket = INVALID_SOCKET; return; From 3872e868cd526e4510045b561f162990bacacfc6 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 15:47:51 +0000 Subject: [PATCH 148/453] bcl: add broker specific definitions Signed-off-by: Vitaly Bukhovsky --- common/beerocks/bcl/include/bcl/beerocks_defines.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common/beerocks/bcl/include/bcl/beerocks_defines.h b/common/beerocks/bcl/include/bcl/beerocks_defines.h index 174466fbb9..b380de6d50 100644 --- a/common/beerocks/bcl/include/bcl/beerocks_defines.h +++ b/common/beerocks/bcl/include/bcl/beerocks_defines.h @@ -22,6 +22,7 @@ namespace beerocks { #define BEEROCKS_MONITOR "beerocks_monitor" #define BEEROCKS_CLI "beerocks_cli" +#define BEEROCKS_BROKER_UDS "uds_broker" #define BEEROCKS_SLAVE_UDS "uds_slave" #define BEEROCKS_MASTER_UDS "uds_master" #define BEEROCKS_PLAT_MGR_UDS "uds_platform_manager" From 4c69cf5c190abc22cfd539dd8ad3eb890389887a Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 15:48:48 +0000 Subject: [PATCH 149/453] bcl: tests: adjust socket event loop unit tests Adjust the socket event loop unit tests to the updated interface. Signed-off-by: Vitaly Bukhovsky --- .../bcl/unit_tests/socket_event_loop_test.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/common/beerocks/bcl/unit_tests/socket_event_loop_test.cpp b/common/beerocks/bcl/unit_tests/socket_event_loop_test.cpp index 06608d7ae1..66e07b4207 100644 --- a/common/beerocks/bcl/unit_tests/socket_event_loop_test.cpp +++ b/common/beerocks/bcl/unit_tests/socket_event_loop_test.cpp @@ -83,10 +83,7 @@ TEST(beerocks_socket_event_loop, simple_timeout) // Socket timeout handler EXPECT_CALL(timeout, handle_timeout(timeout_socket, &loop)) - .WillOnce(Invoke([](EventType socket, LoopType *loop) -> bool { - loop->die(); - return true; - })); + .WillOnce(Invoke([](EventType socket, LoopType *loop) -> bool { return true; })); }; // Add the dummy socket into the event loop @@ -123,9 +120,7 @@ TEST(beerocks_socket_event_loop, repeated_timeout) ON_CALL(timeout, handle_timeout(timeout_socket, &loop)) .WillByDefault([&](EventType socket, LoopType *loop) -> bool { - if (++timeout_seq == 3) { - loop->die(); - } + ++timeout_seq; return true; }); }; @@ -134,7 +129,10 @@ TEST(beerocks_socket_event_loop, repeated_timeout) ASSERT_TRUE(loop.add_event(timeout_socket, timeout, std::chrono::milliseconds{1})); // Execute the event loop - ASSERT_GE(loop.run(), 0); + ASSERT_EQ(1, loop.run()); + ASSERT_EQ(1, loop.run()); + ASSERT_EQ(1, loop.run()); + ASSERT_EQ(3, timeout_seq); // Remove the socket from the event loop ASSERT_TRUE(loop.del_event(timeout_socket)); @@ -176,7 +174,6 @@ TEST(beerocks_socket_event_loop, simple_read_write) .WillOnce(Invoke([](EventType socket, LoopType *loop) -> bool { char dummy; EXPECT_EQ(1, read(socket->getSocketFd(), &dummy, 1)); - loop->die(); return true; })); }; @@ -186,7 +183,8 @@ TEST(beerocks_socket_event_loop, simple_read_write) ASSERT_TRUE(loop.add_event(reader_socket, reader)); // Run the loop - ASSERT_GE(loop.run(), 0); + ASSERT_EQ(1, loop.run()); + ASSERT_EQ(1, loop.run()); // Delete the reader socket ASSERT_TRUE(loop.del_event(reader_socket)); From 735dbb7df82f2db08f1889989e74401a37845369 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 15:55:43 +0000 Subject: [PATCH 150/453] framework: common: update internal Message class Replace the previously used Topic string with an unsigned integer message type. Since the topic is no longer transmitted on the local bus, add the message type into the header. Also add a magic value while we're at it, to detect synchronization loss on streaming sockets (UDS/TCP). Signed-off-by: Vitaly Bukhovsky --- .../common/include/mapf/common/message.h | 40 ++++++++++--------- framework/common/message.cpp | 21 ++++++++++ 2 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 framework/common/message.cpp diff --git a/framework/common/include/mapf/common/message.h b/framework/common/include/mapf/common/message.h index a5a9c8cdb0..4abe720492 100644 --- a/framework/common/include/mapf/common/message.h +++ b/framework/common/include/mapf/common/message.h @@ -21,14 +21,16 @@ namespace mapf { class Message { public: - static const uint32_t kMessageHeaderVersion = 0x1; - static const uint32_t kMaxTopicSize = 128; - static const uint32_t kMaxFrameLength = 0x100000U; // 1MB max for now + static constexpr uint32_t kMessageMagic = 0xB8C16F47; + static constexpr uint32_t kMessageHeaderVersion = 0x1; + static constexpr uint32_t kMaxTopicSize = 128; + static constexpr uint32_t kMaxFrameLength = 0x100000U; // 1MB max for now class Frame { public: explicit Frame(size_t len, const void *init_data = nullptr) - : data_(std::make_shared>(len)) + : data_(std::make_shared>(len < kMaxFrameLength ? len + : kMaxFrameLength)) { if (init_data) set_data(init_data, len); @@ -60,15 +62,17 @@ class Message { }; // class Frame struct Header { + uint32_t magic = kMessageMagic; // magic value uint32_t version = kMessageHeaderVersion; // header version + uint32_t type = 0; // message type uint32_t len = 0; // total length of the message (excluding topic & header) }; Message() {} - explicit Message(const std::string &topic) : topic_(topic) {} + explicit Message(uint32_t type) : m_type(type) {} - Message(const std::string &topic, std::initializer_list frames) : Message(topic) + Message(uint32_t type, std::initializer_list frames) : Message(type) { for (auto frame : frames) Add(frame); @@ -76,47 +80,47 @@ class Message { virtual ~Message(){}; - void Add(Frame &frame) { frames_.push_back(frame); } + void Add(Frame &frame) { m_frames.push_back(frame); } void Clear() { - frames_.clear(); - topic_.clear(); + m_frames.clear(); + m_frames.clear(); } // Get the first frame - Frame frame() const { return frames_.empty() ? Frame() : frames_.back(); } + Frame frame() const { return m_frames.empty() ? Frame() : m_frames.back(); } // Accessors & Mutators const Header header() const { Header hdr; - for (auto f : frames_) + hdr.type = m_type; + for (auto f : m_frames) hdr.len += f.len(); return hdr; } uint32_t version() const { return header().version; } uint32_t len() const { return header().len; } + uint32_t type() const { return m_type; } - std::vector &frames() const { return frames_; } - virtual const std::string topic() const { return topic_; } - virtual void set_topic(const std::string &topic) { topic_ = topic; } + std::vector &frames() const { return m_frames; } virtual std::ostream &print(std::ostream &os) const { std::stringstream ss; - ss << " topic : " << topic() << std::endl; ss << " version : " << version() << std::endl; + ss << " type : " << type() << std::endl; ss << " len : " << len() << std::endl; - ss << " frames : " << frames_.size() << std::endl; + ss << " frames : " << m_frames.size() << std::endl; return os << ss.str(); } private: - std::string topic_; - mutable std::vector frames_; + uint32_t m_type = 0; + mutable std::vector m_frames; }; inline std::ostream &operator<<(std::ostream &os, const Message::Frame &f) { return f.print(os); } diff --git a/framework/common/message.cpp b/framework/common/message.cpp new file mode 100644 index 0000000000..154c76d1ac --- /dev/null +++ b/framework/common/message.cpp @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include + +#include + +namespace mapf { + +// Static members definition +constexpr uint32_t Message::kMessageMagic; +constexpr uint32_t Message::kMessageHeaderVersion; +constexpr uint32_t Message::kMaxTopicSize; +constexpr uint32_t Message::kMaxFrameLength; + +} // namespace mapf From 9b7df0a4b8297c1e5bd1bd433488cd60623ebf92 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 16:17:40 +0000 Subject: [PATCH 151/453] framework: transport: update internal messages Update the internal transport messages with types instead of topics. Add new SubscribeMessage for subscribing/unsubscribing to specific message types. Signed-off-by: Vitaly Bukhovsky --- .../ieee1905_transport_messages.cpp | 18 +- .../transport/ieee1905_transport_messages.h | 248 +++++++++++------- 2 files changed, 161 insertions(+), 105 deletions(-) diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp index 4031c83b67..f0a0fbf100 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp @@ -8,15 +8,17 @@ #include -namespace mapf { +#include -const std::string CmduRxMessage::kTopicPrefix = "cmdu.rx."; -const std::string CmduTxMessage::kTopicPrefix = "cmdu.tx."; +#include -const std::string CmduTxConfirmationMessage::kTopicPrefix = "cmdu.conf.tx."; +namespace beerocks { +namespace transport { +namespace messages { -const std::string InterfaceConfigurationQueryMessage::kTopicPrefix = "if_config.qry."; -const std::string InterfaceConfigurationRequestMessage::kTopicPrefix = "if_config.req."; -const std::string InterfaceConfigurationIndicationMessage::kTopicPrefix = "if_config.ind."; +// Declaration of static members +constexpr int SubscribeMessage::MAX_SUBSCRIBE_TYPES; -}; // namespace mapf +} // namespace messages +} // namespace transport +} // namespace beerocks diff --git a/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h b/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h index e4521cd9d2..6590d7e478 100644 --- a/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h +++ b/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h @@ -9,6 +9,7 @@ #ifndef MAP_IEEE1905_TRANSPORT_MESSAGES_H_ #define MAP_IEEE1905_TRANSPORT_MESSAGES_H_ +#include #include #include @@ -23,7 +24,27 @@ #define ETH_P_LLDP 0x88CC #endif -namespace mapf { +namespace beerocks { +namespace transport { +namespace messages { + +// NOTE: Use the base mapf::Message class +// Remove this once mapf common namespace is merged with beerocks +using mapf::Message; + +/** + * Transport internal message types + */ +enum class Type { + Invalid = 0, + CmduRxMessage = 1, + CmduTxMessage = 2, + SubscribeMessage = 3, + CmduTxConfirmationMessage = 4, + InterfaceConfigurationQueryMessage = 5, + InterfaceConfigurationRequestMessage = 6, + InterfaceConfigurationIndicationMessage = 7 +}; // Notes: // @@ -57,12 +78,8 @@ class CmduXxMessage : public Message { 0; // payload length (including IEEE1905 header, excluding Ethernet header) }; - CmduXxMessage() : CmduXxMessage("", {}) {} - - CmduXxMessage(const std::string &topic) : CmduXxMessage(topic, {}) {} - - CmduXxMessage(const std::string &topic, std::initializer_list frames) - : Message(topic, frames) + explicit CmduXxMessage(uint32_t type, std::initializer_list frames = {}) + : Message(type, frames) { // maximum one frame is allowed (if none are given we will allocate one below) mapf_assert(this->frames().size() <= 1); @@ -75,13 +92,6 @@ class CmduXxMessage : public Message { } } - virtual const std::string topic_prefix() const = 0; - - virtual const std::string topic() const - { - return build_topic(topic_prefix(), metadata()->ether_type, metadata()->msg_type); - } - Metadata *metadata() const { return (Metadata *)frames().back().data(); }; uint8_t *data() const @@ -127,49 +137,108 @@ class CmduXxMessage : public Message { return os << ss.str(); } +}; -protected: - static const std::string build_topic(const std::string prefix, uint16_t ether_type, - uint16_t msg_type) +class CmduRxMessage : public CmduXxMessage { +public: + explicit CmduRxMessage(std::initializer_list frame = {}) + : CmduXxMessage(uint32_t(Type::CmduRxMessage), frame) { - std::ostringstream topic; - topic << prefix << std::setfill('0') << std::setw(4) << std::hex << ether_type << "." - << std::setfill('0') << std::setw(4) << std::hex << msg_type; - return topic.str(); } }; -class CmduRxMessage : public CmduXxMessage { - using CmduXxMessage::CmduXxMessage; // inherit base class constructors +class CmduTxMessage : public CmduXxMessage { +public: + explicit CmduTxMessage(std::initializer_list frame = {}) + : CmduXxMessage(uint32_t(Type::CmduTxMessage), frame) + { + } +}; + +class SubscribeMessage : public Message { + static const uint8_t kVersion = 0; public: - static const std::string kTopicPrefix; + /** + * Maximal number of types for a single subscribe/unsubscribe message + */ + static constexpr int MAX_SUBSCRIBE_TYPES = 64; + + /** + * The type of the request + */ + enum class ReqType : uint8_t { + INVALID = 0, + SUBSCRIBE = 1, + UNSUBSCRIBE = 2, + }; - virtual const std::string topic_prefix() const override { return kTopicPrefix; } + /** + * Message type to subscribe/unsubscribe + */ + union MsgType { + struct { + uint32_t internal : 1; // 0 - external [cmdu], 1 - internal + uint32_t vendor_specific : 1; // 0 - easymesh, 1 - vendor specific + uint32_t reserved : 14; // unused + uint32_t type : 16; // message type (opcode) + } bits; + uint32_t value = 0; + }; - static const std::string ieee1905_topic(uint16_t msg_type) + struct Metadata { + uint8_t version = kVersion; + ReqType type = ReqType::INVALID; + uint8_t msg_types_num = 0; + MsgType msg_types[MAX_SUBSCRIBE_TYPES]; + }; + + explicit SubscribeMessage(std::initializer_list frames = {}) + : Message(uint32_t(Type::SubscribeMessage), frames) { - return build_topic(kTopicPrefix, ETH_P_1905_1, msg_type); + // maximum one frame is allowed (if none are given we will allocate one below) + mapf_assert(this->frames().size() <= 1); + + if (this->frames().empty()) { + Message::Frame frame(sizeof(Metadata)); + Add(frame); + } else if (this->frames().back().len() < sizeof(Metadata)) { + this->frames().back().set_size(sizeof(Metadata)); + } } - static const std::string lldp_topic() { return build_topic(kTopicPrefix, ETH_P_LLDP, 0x0000); } -}; + Metadata *metadata() const + { + mapf_assert(!frames().empty()); -class CmduTxMessage : public CmduXxMessage { - using CmduXxMessage::CmduXxMessage; // inherit base class constructors + return (Metadata *)frames().back().data(); + }; -public: - static const std::string kTopicPrefix; + virtual std::ostream &print(std::ostream &os) const + { + Message::print(os); - virtual const std::string topic_prefix() const override { return kTopicPrefix; } + std::stringstream ss; + Metadata *m = metadata(); + os << " metadata:" << std::endl; + os << " version : " << static_cast(m->version) << std::endl; + os << " type : " << static_cast(m->type) << std::endl; + os << " msg_types_num : " << std::dec << int(m->msg_types_num) << std::endl; + os << " msg_types : " << std::hex << std::setfill('0') << std::setw(4) + << m->msg_types[0].value; + for (int i = 1; i < m->msg_types_num; i++) { + os << ", " << m->msg_types[i].value; + } + os << std::endl; + + return os << ss.str(); + } }; class CmduTxConfirmationMessage : public Message { static const uint8_t kVersion = 0; public: - static const std::string kTopicPrefix; - struct Metadata { uint8_t version = kVersion; uint16_t cookie = @@ -182,15 +251,8 @@ class CmduTxConfirmationMessage : public Message { 0; // The IEEE1905 messageId used by the IEEE1905 Transport to send the CmduTxMessage that triggered this confirmation }; - CmduTxConfirmationMessage() : CmduTxConfirmationMessage("", {}) {} - - explicit CmduTxConfirmationMessage(const std::string &topic) - : CmduTxConfirmationMessage(topic, {}) - { - } - - CmduTxConfirmationMessage(const std::string &topic, std::initializer_list frames) - : Message(topic, frames) + explicit CmduTxConfirmationMessage(std::initializer_list frames = {}) + : Message(uint32_t(Type::CmduTxConfirmationMessage), frames) { // maximum one frame is allowed (if none are given we will allocate one below) mapf_assert(this->frames().size() <= 1); @@ -203,18 +265,6 @@ class CmduTxConfirmationMessage : public Message { } } - virtual const std::string topic_prefix() const { return kTopicPrefix; } - - virtual const std::string topic() const - { - return build_topic(topic_prefix(), metadata()->ether_type, metadata()->msg_type); - } - - static const std::string ieee1905_topic(uint16_t msg_type) - { - return build_topic(kTopicPrefix, ETH_P_1905_1, msg_type); - } - Metadata *metadata() const { mapf_assert(!frames().empty()); @@ -240,25 +290,16 @@ class CmduTxConfirmationMessage : public Message { return os << ss.str(); } - -protected: - static const std::string build_topic(const std::string prefix, uint16_t ether_type, - uint16_t msg_type) - { - std::ostringstream topic; - topic << prefix << std::setfill('0') << std::setw(4) << std::hex << ether_type << "." - << std::setfill('0') << std::setw(4) << std::hex << msg_type; - return topic.str(); - } }; class InterfaceConfigurationQueryMessage : public Message { - using Message::Message; // inherit base class constructors - public: - static const std::string kTopicPrefix; + explicit InterfaceConfigurationQueryMessage(std::initializer_list frames = {}) + : Message(uint32_t(Type::InterfaceConfigurationQueryMessage), frames) + { + } - virtual const std::string topic_prefix() const { return kTopicPrefix; } + virtual ~InterfaceConfigurationQueryMessage() {} }; class InterfaceConfigurationMessage : public Message { @@ -285,15 +326,8 @@ class InterfaceConfigurationMessage : public Message { Interface interfaces[kMaxInterfaces]; }; - InterfaceConfigurationMessage() : InterfaceConfigurationMessage("", {}) {} - - InterfaceConfigurationMessage(const std::string &topic) - : InterfaceConfigurationMessage(topic, {}) - { - } - - InterfaceConfigurationMessage(const std::string &topic, std::initializer_list frames) - : Message(topic, frames) + explicit InterfaceConfigurationMessage(uint32_t type, std::initializer_list frames) + : Message(type, frames) { // maximum one frame is allowed (if none are given we will allocate one below) mapf_assert(this->frames().size() <= 1); @@ -328,31 +362,51 @@ class InterfaceConfigurationMessage : public Message { return os << ss.str(); } - - virtual const std::string topic_prefix() const = 0; - virtual const std::string topic() const { return topic_prefix(); } }; class InterfaceConfigurationRequestMessage : public InterfaceConfigurationMessage { - using InterfaceConfigurationMessage:: - InterfaceConfigurationMessage; // inherit base class constructors - public: - static const std::string kTopicPrefix; - - virtual const std::string topic_prefix() const override { return kTopicPrefix; } + explicit InterfaceConfigurationRequestMessage(std::initializer_list frames = {}) + : InterfaceConfigurationMessage(uint32_t(Type::InterfaceConfigurationRequestMessage), + frames) + { + } }; -// same as InterfaceConfigurationRequestMessage - only with different topic -class InterfaceConfigurationIndicationMessage : public InterfaceConfigurationMessage { - using InterfaceConfigurationMessage:: - InterfaceConfigurationMessage; // inherit base class constructors +// same as InterfaceConfigurationRequestMessage - only with different type +class InterfaceConfigurationIndicationMessage : public InterfaceConfigurationMessage { public: - static const std::string kTopicPrefix; - - virtual const std::string topic_prefix() const override { return kTopicPrefix; } + explicit InterfaceConfigurationIndicationMessage(std::initializer_list frames = {}) + : InterfaceConfigurationMessage(uint32_t(Type::InterfaceConfigurationIndicationMessage), + frames) + { + } }; -}; // namespace mapf +/** + * @brief Read and parse internal transport message from a socket. + * + * @param [in] sd Socket of the incoming message. + * + * @return Unique pointer to the received message object or nullptr on error. + */ +std::unique_ptr read_transport_message(Socket &sd); + +/** + * @brief Send internal message to a socket. + * + * @param [in] sd Socket for sending the message. + * @param [in] msg The message to send. + * @param [in] header OPTIONAL: Pointer to a custom header. + * Calculated automatically if not provided. + * + * @return true on success of false otherwise. + */ +bool send_transport_message(Socket &sd, const Message &msg, + const Message::Header *header = nullptr); + +} // namespace messages +} // namespace transport +} // namespace beerocks #endif // MAP_IEEE1905_TRANSPORT_MESSAGES_H_ From 146ad5730681cec4351c486b7182982eee0c8267 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 16:20:10 +0000 Subject: [PATCH 152/453] framework: transport: helper functions Add helper functions for sending and receiving internal messages. Signed-off-by: Vitaly Bukhovsky --- .../ieee1905_transport_messages.cpp | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp index f0a0fbf100..dda3a485ec 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp @@ -19,6 +19,132 @@ namespace messages { // Declaration of static members constexpr int SubscribeMessage::MAX_SUBSCRIBE_TYPES; +////////////////////////////////////////////////////////////////////////////// +////////////////////////////// Helper Functions ////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +static std::unique_ptr +create_transport_message(Type type, std::initializer_list frame) +{ + switch (messages::Type(type)) { + case messages::Type::CmduRxMessage: + return std::unique_ptr{new messages::CmduRxMessage(frame)}; + case messages::Type::CmduTxMessage: + return std::unique_ptr{new messages::CmduTxMessage(frame)}; + case messages::Type::SubscribeMessage: + return std::unique_ptr{new messages::SubscribeMessage(frame)}; + case messages::Type::CmduTxConfirmationMessage: + return std::unique_ptr{ + new messages::CmduTxConfirmationMessage(frame)}; + case messages::Type::InterfaceConfigurationQueryMessage: + return std::unique_ptr{ + new messages::InterfaceConfigurationQueryMessage(frame)}; + case messages::Type::InterfaceConfigurationRequestMessage: + return std::unique_ptr{ + new messages::InterfaceConfigurationRequestMessage(frame)}; + case messages::Type::InterfaceConfigurationIndicationMessage: + return std::unique_ptr{ + new messages::InterfaceConfigurationIndicationMessage(frame)}; + default: + LOG(WARNING) << "Received unknown message type: " << int(type); + return std::unique_ptr{new messages::Message(0, frame)}; + } +} + +std::unique_ptr read_transport_message(Socket &sd) +{ + // Peek into the header to check if the entire message received + messages::Message::Header header; + auto bytes_ready = sd.getBytesReady(); + auto read_bytes = + sd.readBytes(reinterpret_cast(&header), sizeof(header), false, sizeof(header)); + + if (read_bytes != sizeof(header)) { + LOG(ERROR) << "Error peeking into the message header: " << read_bytes; + return nullptr; + } + + auto discard_pending_bytes = [&]() { + if (!sd.getBytesReady()) { + return; + } + + // Discard all the "ready" bytes in the socket + // Reading an invalid message magic means that somehow the data synchronization + // was lost. Since the data is not necessarily aligned to any known size, we have + // two options here: + // 1. Safe - Discard 1 byte at a time, until finding the magic word + // 2. Faster - Discard sizeof(Header) bytes and hope to find a valid header afterwads + // 2. Fastest - Discard all the bytes and assume the sender will re-send the message + // For now we'll use the "Faster" method. + auto discarded_bytes = sd.readBytes(reinterpret_cast(&header), sizeof(header), + false, sd.getBytesReady()); + + LOG(DEBUG) << "Discarded " << discarded_bytes << " bytes from fd = " << sd.getSocketFd(); + }; + + // Validate the header + if (header.magic != messages::Message::kMessageMagic) { + LOG(ERROR) << "Invalid message header: magic = 0x" << std::hex << header.magic << std::dec + << ", length = " << header.len << ", fd = " << sd.getSocketFd(); + + discard_pending_bytes(); + return nullptr; + } + + // Check if all the message was received + if (header.len >= uint32_t(bytes_ready)) { + LOG(DEBUG) << "Message received partially " << bytes_ready << "/" << header.len; + return nullptr; + } + + // Validate message length + if (header.len > messages::Message::kMaxFrameLength) { + LOG(ERROR) << "Message length is too large: " << header.len << " > " + << messages::Message::kMaxFrameLength; + + discard_pending_bytes(); + return nullptr; + } + + std::unique_ptr message; + + if (!header.len) { + message = create_transport_message(Type(header.type), {}); + } else { + // Read and build the message (blocking operation) + // TODO: Convert to non-blocking + messages::Message::Frame frame(size_t(header.len)); + size_t received_bytes = sd.readBytes(frame.data(), header.len, true, header.len); + + if (received_bytes != header.len) { + LOG(ERROR) << "Received bytes = " << received_bytes + << ", Message size = " << header.len; + return nullptr; + } + + message = create_transport_message(Type(header.type), {frame}); + } + + LOG_IF(!message, ERROR) << "Failed creating message object for type: " << header.type; + return message; +} + +bool send_transport_message(Socket &sd, const Message &msg, const Message::Header *header) +{ + auto hdr = (header) ? *header : msg.header(); + iovec iov[] = {{.iov_base = (void *)&hdr, .iov_len = sizeof(hdr)}, + {.iov_base = (void *)(msg.frame().data()), .iov_len = hdr.len}}; + + // Write the header and the data to the socket + if (writev(sd.getSocketFd(), iov, sizeof(iov) / sizeof(struct iovec)) < 0) { + LOG(ERROR) << "writev failed: " << strerror(errno); + return false; + } + + return true; +} + } // namespace messages } // namespace transport } // namespace beerocks From 958fcdd27066111c4998dbfe747feb18ea1e9f0f Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 16:33:02 +0000 Subject: [PATCH 153/453] framework: transport: broker server implementation Implement a broker server that is based on a socket event loop. Unlike the existing bus, this broker filters messages on the broker side, meaning that the clients will receive only the messages they subscribed to. Subscribing to and unsubscribing from CMDU message types is achieved by sending an internal transport message (SubscribeMessage) to the broker. Signed-off-by: Vitaly Bukhovsky --- .../ieee1905_transport_broker.cpp | 355 ++++++++++++++++++ .../ieee1905_transport_broker.h | 180 +++++++++ 2 files changed, 535 insertions(+) create mode 100644 framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp create mode 100644 framework/transport/ieee1905_transport/ieee1905_transport_broker.h diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp new file mode 100644 index 0000000000..8eac4d9403 --- /dev/null +++ b/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp @@ -0,0 +1,355 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include "ieee1905_transport_broker.h" + +#include + +#include +#include + +// System +#include +#include +#include + +#include + +namespace beerocks { +namespace transport { +namespace broker { + +////////////////////////////////////////////////////////////////////////////// +////////////////////////// Local Module Definitions ////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +// Number of concurrent connections on the server socket +static constexpr int listen_buffer_size = 10; + +////////////////////////////////////////////////////////////////////////////// +/////////////////////////// Local Module Functions /////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +static bool is_restricted_type(uint32_t type) +{ + // TODO: Until VS message filtering is implemented (based on action and action_op) + // assume there are no restricted types. After the implementation, + // subscribing to BROKER specific message should be restricted. + + return false; +} + +////////////////////////////////////////////////////////////////////////////// +/////////////////////////// Broker Implementation //////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +BrokerServer::BrokerServer(const std::string &broker_uds_path, SocketEventLoop::TimeoutType timeout) + : SocketEventLoop(timeout) +{ + m_broker_uds_path = broker_uds_path; + + // Server sockets event handlers + EventHandlers server_socket_handlers{ + // Accept incoming connections + .on_read = + [&](EventType socket, EventLoopType &loop) { + // cppcheck falsely detects the call to socket_connected() as a call to a + // virtual method from whithin the constructor, so suppress this warning, + // by explicitly calling BrokerServer::socket_connected(). + + // Handle connections to one of the server sockets + if (!BrokerServer::socket_connected( + std::dynamic_pointer_cast(socket))) { + // NOTE: Do NOT stop the broker on connection errors... + } + + return true; + }, + + // Not implemented + .on_write = nullptr, + .on_timeout = nullptr, + + // Fail on server socket disconnections or errors + .on_disconnect = + [&](EventType socket, EventLoopType &loop) { + LOG(ERROR) << "Broker socket disconnected!"; + return false; + }, + .on_error = + [&](EventType socket, EventLoopType &loop) { + LOG(ERROR) << "Broker socket error!"; + return false; + }, + }; + + // Connect to the message broker + m_broker_socket_uds = std::make_shared(m_broker_uds_path, listen_buffer_size); + LOG_IF(!m_broker_socket_uds, FATAL) << "Failed allocating memory!"; + + // Check for errors + LOG_IF(!m_broker_socket_uds->getError().empty(), FATAL) + << "Failed opening UDS socket: " << m_broker_uds_path + << " [ERROR: " << m_broker_socket_uds->getError() << "]"; + + // Add the socket to the poll + LOG_IF(!add_event(m_broker_socket_uds, server_socket_handlers), FATAL) + << "Failed adding the broker socket into the poll"; + + LOG(INFO) << "Listening on UDS: " << m_broker_uds_path; +} + +bool BrokerServer::publish(const mapf::Message &msg) +{ + messages::SubscribeMessage::MsgType msg_opcode; + + switch (messages::Type(msg.type())) { + // External message + case messages::Type::CmduRxMessage: { + auto &cmdu_msg = dynamic_cast(msg); + msg_opcode.bits = {.internal = 0, // external message + .vendor_specific = 0, + .reserved = 0, + .type = cmdu_msg.metadata()->msg_type}; + } break; + // Internal messages + default: { + msg_opcode.bits = {.internal = 1, // internal message + .vendor_specific = 0, + .reserved = 0, + .type = msg.type()}; + } + } + + // Get the list of subscribers + auto types_set_it = m_type_to_soc.find(msg_opcode.value); + if (types_set_it == m_type_to_soc.end()) { + LOG(DEBUG) << "No subscribers for message (internal = " << msg_opcode.bits.internal + << ", type = " << std::hex << msg_opcode.bits.type << ")" << std::dec + << " with length: " << msg.header().len; + + return true; + } + + // Send the message to subscribed FDs + for (auto soc : types_set_it->second) { + LOG(DEBUG) << "Sending message with type (0x" << std::hex << msg_opcode.value << std::dec + << ") to FD (" << soc->getSocketFd() << ")"; + + if (!messages::send_transport_message(*soc, msg)) { + LOG(ERROR) << "Failed sending message with type (0x" << std::hex << msg_opcode.value + << std::dec << ") to FD (" << soc->getSocketFd() << ")"; + + continue; + } + } + + return true; +} + +void BrokerServer::register_internal_message_handler(MessageHandler handler) +{ + LOG_IF(m_internal_message_handler, WARNING) << "Overriding previously registered handler"; + m_internal_message_handler = handler; +} + +void BrokerServer::register_external_message_handler(MessageHandler handler) +{ + LOG_IF(m_internal_message_handler, WARNING) << "Overriding previously registered handler"; + m_external_message_handler = handler; +} + +bool BrokerServer::handle_msg(std::shared_ptr sd) +{ + // Check if the socket contains enough bytes for the header + if (sd->getBytesReady() < static_cast(sizeof(messages::Message::Header))) { + // Received partial header - do nothing... + return true; + } + + // Read and parse the message + auto message = messages::read_transport_message(*sd); + if (!message) { + return false; + } + + // Handle the specific message + switch (messages::Type(message->type())) { + // Broker Subscribe/Unsubscribe + case messages::Type::SubscribeMessage: { + auto msg_ptr = dynamic_cast(message.get()); + return handle_subscribe(sd, *msg_ptr); + } + // Outgoing CMDU messages + case messages::Type::CmduTxMessage: { + LOG(DEBUG) << "Processing external message from FD: " << sd->getSocketFd(); + if (!m_external_message_handler) { + LOG(ERROR) << "External message handler not registered!"; + return false; + } + + return m_external_message_handler(message, *this); + } + // Internal messages + default: { + LOG(DEBUG) << "Processing internal message from FD: " << sd->getSocketFd(); + if (!m_internal_message_handler) { + LOG(ERROR) << "Internal message handler not registered!"; + return false; + } + + return m_internal_message_handler(message, *this); + } + } + + return true; +} + +bool BrokerServer::handle_subscribe(std::shared_ptr &sd, + const messages::SubscribeMessage &msg) +{ + // Validate the message type + if (msg.metadata()->type == messages::SubscribeMessage::ReqType::INVALID) { + LOG(ERROR) << "Invalid subscribe message type!"; + return false; + } + + // Make sure there's at least one message type + if (msg.metadata()->msg_types_num == 0) { + LOG(ERROR) << "Subscribe message does not contain any types!"; + return false; + } + + // Iterate over the message types and subscribe/unsubscribe + bool subscribe = msg.metadata()->type == messages::SubscribeMessage::ReqType::SUBSCRIBE; + std::stringstream types_stream; + for (auto i = 0; i < msg.metadata()->msg_types_num; ++i) { + auto msg_type = msg.metadata()->msg_types[i]; + + // Skip restricted types + if (is_restricted_type(msg_type.value)) { + LOG(WARNING) << "FD (" << sd->getSocketFd() + << ") attempt subscribing to forbidden type " << msg_type.value; + + continue; + } + + // Add to the list of requested types + types_stream << "0x" << std::hex << msg_type.value << std::string(" "); + + // Subscribe + if (subscribe) { + // Add the type to the list of this Socket subscriptions + m_soc_to_type[sd].insert(msg_type.value); + + // Add the Socket to the list of this type subscriptions + m_type_to_soc[msg_type.value].insert(sd); + + // Unsubscribe + } else { + // Delete the type from the list of this Socket subscriptions + m_soc_to_type[sd].erase(msg_type.value); + + // Add the Socket from the list of this type subscriptions + m_type_to_soc[msg_type.value].erase(sd); + } + } + + LOG(INFO) << "FD (" << sd->getSocketFd() << ") " + << std::string(subscribe ? "subscribed to" : "unsubscribed from") + << " the following types: " << types_stream.str(); + + LOG(DEBUG) << "FD (" << sd->getSocketFd() << ") subscriptions: " << std::hex + << m_soc_to_type[sd] << std::dec; + + return true; +} + +bool BrokerServer::socket_connected(std::shared_ptr sd) +{ + // Accept the connection + auto new_socket = std::shared_ptr(sd->acceptConnections()); + + // Check for errors + const auto error_msg = sd->getError(); + if ((!new_socket) || (!error_msg.empty())) { + LOG(ERROR) << "Socket error: " << error_msg; + return false; + } + + if (!sd->getUdsPath().empty()) { + LOG(DEBUG) << "New connection on " << sd->getUdsPath() + << " fd = " << uintptr_t(new_socket->getSocketFd()); + } else { + LOG(DEBUG) << "New connection from ip = " << new_socket->getPeerIP() + << " port = " << new_socket->getPeerPort() + << " fd = " << uint64_t(new_socket->getSocketFd()); + } + + // Socket event handlers + SocketEventLoop::EventHandlers socket_handlers{ + // Handle incoming data + .on_read = + [&](SocketEventLoop::EventType socket, SocketEventLoop::EventLoopType &loop) { + if (!handle_msg(socket)) { + // NOTE: Do NOT stop the broker on parsing errors... + } + + return true; + }, + + // Not implemented + .on_write = nullptr, + .on_timeout = nullptr, + + // Remove the socket on disconnections or errors + .on_disconnect = + [&](SocketEventLoop::EventType socket, SocketEventLoop::EventLoopType &loop) { + if (!socket_disconnected(socket)) { + // NOTE: Do NOT stop the broker on errors... + } + + return true; + }, + .on_error = + [&](SocketEventLoop::EventType socket, SocketEventLoop::EventLoopType &loop) { + if (!socket_disconnected(socket)) { + // NOTE: Do NOT stop the broker on errors... + } + + return true; + }, + }; + + // Add the newly accepted socket into the poll + if (!add_event(new_socket, socket_handlers)) { + LOG(ERROR) << "Failed adding new socket into the poll!"; + return false; + } + + return true; +} + +bool BrokerServer::socket_disconnected(std::shared_ptr sd) +{ + LOG(DEBUG) << "Socket disconnected: FD(" << sd->getSocketFd() << ")"; + + // Delete the Socket from the list of types subscriptions + for (auto &type : m_soc_to_type[sd]) { + m_type_to_soc[type].erase(sd); + } + + // Delete the type from the list of this Socket subscriptions + m_soc_to_type.erase(sd); + + return true; +} + +} // namespace broker +} // namespace transport +} // namespace beerocks diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_broker.h b/framework/transport/ieee1905_transport/ieee1905_transport_broker.h new file mode 100644 index 0000000000..64bae3fb00 --- /dev/null +++ b/framework/transport/ieee1905_transport/ieee1905_transport_broker.h @@ -0,0 +1,180 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#ifndef BROKER_SERVER_H +#define BROKER_SERVER_H + +#include + +#include + +#include +#include + +namespace beerocks { +namespace transport { +namespace broker { + +/** + * @brief prplMesh internal message broker server. + * + * Implements a broker server that is responsible for the internal communication + * between the different prplMesh components (transport, controller, agent etc.) + * + * The broker accepts connection over a UDS file. + * Once connected to the server, a client can subscribe CMDU types. + * Message filtering is implemented inside the server, so that clients receive only + * the message types they subscribed to. + */ +class BrokerServer : public SocketEventLoop { +public: + /** + * @brief Transport messages (@see mapf::Message) handler function definition. + * + * Parameters to the event handler function are: + * @param[in] msg Pointer to the message to handle. + * @param[in] broker Reference to the BrokerServer instance. + * + * @returns True on success or false otherwise + */ + using MessageHandler = + std::function &msg, BrokerServer &broker)>; + + /** + * Constructor. + * + * @param [in] broker_uds_path The path and file name to the server UDS file. + */ + explicit BrokerServer( + const std::string &broker_uds_path, + SocketEventLoop::TimeoutType timeout = SocketEventLoop::TimeoutType::min()); + + /** + * Destructor. + */ + virtual ~BrokerServer() = default; + + /** + * @brief Publishes the message with the broker subscribers. + * Sends the message to all the clients that subscribed for the type of the message. + * + * @param [in] msg Reference to the message to publish. + * + * @returns true on success or false otherwise. + */ + virtual bool publish(const mapf::Message &msg); + + /** + * @brief Register a handler function for internal (non-CMDU) messages + * + * The registered handler will be called for processing non-CMDU messages, + * with the exception of the Subscribe/Unsubscribe messages that will be + * processed internally by the broker. + * + * @param [in] handler Handler function. + */ + virtual void register_internal_message_handler(MessageHandler handler); + + /** + * @brief Register a handler function for external (CMDU_TX/CMDU_RX) messages + * + * The registered handler will be called for processing CMDU messages. + * + * @param [in] handler Handler function. + */ + virtual void register_external_message_handler(MessageHandler handler); + +protected: + /** + * @brief Handle incoming message. + * + * @param [in] sd The socket interface on which the incoming data event originated. + * + * @return true on success of false otherwise. + */ + virtual bool handle_msg(std::shared_ptr sd); + + /** + * @brief Handle broker subscribe/unsubscribe messages. + * + * @param [in] sd The socket interface on which the incoming data event originated. + * @param [in] msg The internal SubscribeMessage message. + * + * @return true on success of false otherwise. + */ + virtual bool handle_subscribe(std::shared_ptr &sd, + const messages::SubscribeMessage &msg); + + /** + * @brief Handler method for socket connections. + * + * @param [in] sd The socket interface on which the connection event originated. + * + * @return true on success of false otherwise. + */ + virtual bool socket_connected(std::shared_ptr sd); + + /** + * @brief Handler method for socket disconnections. + * + * @param [in] sd The socket interface on which the disconnection event originated. + * + * @return true on success of false otherwise. + */ + virtual bool socket_disconnected(std::shared_ptr sd); + +private: + // Union for storing the subscribed CMDU message type with additional VS metadata (if applicable) + // union uOpcode { + // /// Opcode as separate fields + // struct fields { + // uint16_t cmdu_type; + // uint8_t vs_action; + // uint8_t vs_action_op; + // } __attribute__((packed)); + + // /// Opcode as 32bit unsigned integer + // uint32_t data; + // }; + + /** + * Path and filename to the server's UDS file. + */ + std::string m_broker_uds_path; + + /** + * Shared pointer to the server's UDS socket. + */ + std::shared_ptr m_broker_socket_uds = nullptr; + + /** + * Map for storing Socket->CMDU Type subscriptions. + */ + std::unordered_map, std::unordered_set> m_soc_to_type; + + /** + * Map for storing CMDU Type->Socket subscriptions. + */ + std::unordered_map>> m_type_to_soc; + + /** + * Handler for internal (non-CMDU) messages. + */ + MessageHandler m_internal_message_handler = nullptr; + + /** + * Handler for external (CMDU) messages. + */ + MessageHandler m_external_message_handler = nullptr; +}; + +} // namespace broker +} // namespace transport +} // namespace beerocks + +#endif // BROKER_SERVER_H From e1e8f286701056466977c8f893dc7b1d383ef0ce Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 16:43:07 +0000 Subject: [PATCH 154/453] framework: transport: broker: unit tests Signed-off-by: Vitaly Bukhovsky --- .../test/ieee1905_transport_broker_tests.cpp | 320 ++++++++++++++++++ 1 file changed, 320 insertions(+) create mode 100644 framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp diff --git a/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp b/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp new file mode 100644 index 0000000000..f20ff9f5fd --- /dev/null +++ b/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp @@ -0,0 +1,320 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include + +#include "../ieee1905_transport_broker.h" + +#include + +#include +#include + +#include + +#include + +#include + +#include + +// Initialize easylogging++ +INITIALIZE_EASYLOGGINGPP + +namespace beerocks { +namespace transport { +namespace broker { +namespace tests { + +using namespace beerocks::transport::messages; + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////// Global Variables ////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +// UDS file for the tests +static constexpr char broker_uds_file[] = "beerocks_broker_test_uds"; + +// Invalid message magic value +static constexpr uint32_t INVALID_MAGIC = 0x12345678; + +////////////////////////////////////////////////////////////////////////////// +/////////////////////////////// Helper Classes /////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +// Wrapper class for the BrokerServer for capturing errors +class BrokerServerWrapper : public BrokerServer { +public: + BrokerServerWrapper(std::string broker_uds_path) + : BrokerServer(broker_uds_path, std::chrono::milliseconds(100)) + { + } + + bool error() { return m_error_occurred; } + +protected: + bool m_error_occurred = false; + + virtual bool handle_msg(std::shared_ptr sd) override + { + if (BrokerServer::handle_msg(sd) == false) { + m_error_occurred = true; + return false; + } + + m_error_occurred = false; + return true; + } +}; + +////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////// Tests //////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +// Suppress cppcheck syntax error for gtest TEST macro +// cppcheck-suppress syntaxError +TEST(broker_server, setup) +{ + // Configure easylogging++ formatting + el::Configurations defaultConf; + defaultConf.setToDefault(); + defaultConf.setGlobally(el::ConfigurationType::Format, + "%level %datetime{%H:%m:%s:%g} <%thread> %fbase[%line] --> %msg"); + + // el::Loggers::addFlag(el::LoggingFlag::ColoredTerminalOutput); + el::Loggers::reconfigureLogger("default", defaultConf); +} + +TEST(broker_server, invalid_message_magic) +{ + BrokerServerWrapper broker_wrapper(broker_uds_file); + + // Register a dummy internal message handler + broker_wrapper.register_internal_message_handler( + [](std::unique_ptr &msg, BrokerServer &broker) -> bool { return true; }); + + // Create a random message + mapf::Message dummy; + + // Invalid header + mapf::Message::Header header; + header.magic = INVALID_MAGIC; + + SocketClient sock1(broker_uds_file); + ASSERT_EQ(1, broker_wrapper.run()); // Accept the connection + + LOG(DEBUG) << "Sending INVALID magic..."; + ASSERT_TRUE(messages::send_transport_message(sock1, dummy, &header)); + ASSERT_EQ(1, broker_wrapper.run()); // Process + ASSERT_TRUE(broker_wrapper.error()); + + LOG(DEBUG) << "Sending VALID magic..."; + ASSERT_TRUE(messages::send_transport_message(sock1, dummy)); + ASSERT_EQ(1, broker_wrapper.run()); + ASSERT_FALSE(broker_wrapper.error()); +} + +TEST(broker_server, subscribe_empty_message) +{ + BrokerServerWrapper broker_wrapper(broker_uds_file); + + // Create a subscribe message + SubscribeMessage subscribe; + subscribe.metadata()->type = SubscribeMessage::ReqType::SUBSCRIBE; + + // Connect to the broker and send the message + SocketClient sock1(broker_uds_file); + ASSERT_EQ(1, broker_wrapper.run()); // Accept the connection + + ASSERT_TRUE(messages::send_transport_message(sock1, subscribe)); + ASSERT_EQ(1, broker_wrapper.run()); // Process + + ASSERT_TRUE(broker_wrapper.error()); +} + +TEST(broker_server, subscribe_single_type) +{ + BrokerServerWrapper broker_wrapper(broker_uds_file); + + // Create a subscribe message + SubscribeMessage subscribe; + subscribe.metadata()->type = SubscribeMessage::ReqType::SUBSCRIBE; + subscribe.metadata()->msg_types_num = 1; + subscribe.metadata()->msg_types[0].value = 5; + + // Connect to the broker and send the message + SocketClient sock1(broker_uds_file); + ASSERT_EQ(1, broker_wrapper.run()); // Accept the connection + + ASSERT_TRUE(messages::send_transport_message(sock1, subscribe)); + ASSERT_EQ(1, broker_wrapper.run()); // Process + + ASSERT_FALSE(broker_wrapper.error()); +} + +TEST(broker_server, subscribe_multiple_types) +{ + BrokerServerWrapper broker_wrapper(broker_uds_file); + + // Create a subscribe message + SubscribeMessage subscribe; + subscribe.metadata()->type = SubscribeMessage::ReqType::SUBSCRIBE; + subscribe.metadata()->msg_types_num = 3; + subscribe.metadata()->msg_types[0].value = 1; + subscribe.metadata()->msg_types[1].value = 2; + subscribe.metadata()->msg_types[2].value = 3; + + // Connect to the broker and send the message + SocketClient sock1(broker_uds_file); + ASSERT_EQ(1, broker_wrapper.run()); // Accept the connection + + ASSERT_TRUE(messages::send_transport_message(sock1, subscribe)); + ASSERT_EQ(1, broker_wrapper.run()); // Process + + ASSERT_FALSE(broker_wrapper.error()); +} + +TEST(broker_server, unsubscribe_empty_message) +{ + BrokerServerWrapper broker_wrapper(broker_uds_file); + + // Create a subscribe message + SubscribeMessage subscribe; + subscribe.metadata()->type = SubscribeMessage::ReqType::UNSUBSCRIBE; + + // Connect to the broker and send the message + SocketClient sock1(broker_uds_file); + ASSERT_EQ(1, broker_wrapper.run()); // Accept the connection + + ASSERT_TRUE(messages::send_transport_message(sock1, subscribe)); + ASSERT_EQ(1, broker_wrapper.run()); // Process + + ASSERT_TRUE(broker_wrapper.error()); +} + +TEST(broker_server, unsubscribe_single_type) +{ + BrokerServerWrapper broker_wrapper(broker_uds_file); + + // Create a subscribe message + SubscribeMessage subscribe; + subscribe.metadata()->type = SubscribeMessage::ReqType::UNSUBSCRIBE; + subscribe.metadata()->msg_types_num = 1; + subscribe.metadata()->msg_types[0].value = 5; + + // Connect to the broker and send the message + SocketClient sock1(broker_uds_file); + ASSERT_EQ(1, broker_wrapper.run()); // Accept the connection + + ASSERT_TRUE(messages::send_transport_message(sock1, subscribe)); + ASSERT_EQ(1, broker_wrapper.run()); // Process + + ASSERT_FALSE(broker_wrapper.error()); +} + +TEST(broker_server, unsubscribe_multiple_types) +{ + BrokerServerWrapper broker_wrapper(broker_uds_file); + + // Create a subscribe message + SubscribeMessage subscribe; + subscribe.metadata()->type = SubscribeMessage::ReqType::UNSUBSCRIBE; + subscribe.metadata()->msg_types_num = 3; + subscribe.metadata()->msg_types[0].value = 1; + subscribe.metadata()->msg_types[1].value = 2; + subscribe.metadata()->msg_types[2].value = 3; + + // Connect to the broker and send the message + SocketClient sock1(broker_uds_file); + ASSERT_EQ(1, broker_wrapper.run()); // Accept the connection + + ASSERT_TRUE(messages::send_transport_message(sock1, subscribe)); + ASSERT_EQ(1, broker_wrapper.run()); // Process + + ASSERT_FALSE(broker_wrapper.error()); +} + +TEST(broker_server, subscribe_unsubscribe) +{ + BrokerServerWrapper broker_wrapper(broker_uds_file); + + // Create a subscribe message + SubscribeMessage subscribe; + subscribe.metadata()->type = SubscribeMessage::ReqType::SUBSCRIBE; + subscribe.metadata()->msg_types_num = 3; + subscribe.metadata()->msg_types[0].value = 1; + subscribe.metadata()->msg_types[1].value = 2; + subscribe.metadata()->msg_types[2].value = 3; + + // Connect to the broker and send the message + SocketClient sock1(broker_uds_file); + ASSERT_EQ(1, broker_wrapper.run()); // Accept the connection + ASSERT_FALSE(broker_wrapper.error()); + + ASSERT_TRUE(messages::send_transport_message(sock1, subscribe)); + ASSERT_EQ(1, broker_wrapper.run()); // Process + ASSERT_FALSE(broker_wrapper.error()); + + // Unsubscribe + subscribe.metadata()->type = SubscribeMessage::ReqType::UNSUBSCRIBE; + ASSERT_TRUE(messages::send_transport_message(sock1, subscribe)); + ASSERT_EQ(1, broker_wrapper.run()); // Process + ASSERT_FALSE(broker_wrapper.error()); +} + +TEST(broker_server, publish_internal_message) +{ + BrokerServerWrapper broker_wrapper(broker_uds_file); + + // Connect to the broker + SocketClient sock1(broker_uds_file); + ASSERT_EQ(1, broker_wrapper.run()); // Accept the connection + ASSERT_FALSE(broker_wrapper.error()); + + // Build a subscribe message + SubscribeMessage subscribe; + subscribe.metadata()->type = SubscribeMessage::ReqType::SUBSCRIBE; + subscribe.metadata()->msg_types_num = 1; + subscribe.metadata()->msg_types[0].bits = { + .internal = 1, + .vendor_specific = 0, + .reserved = 0, + .type = uint32_t(Type::InterfaceConfigurationIndicationMessage), + }; + + // Subscribe to the InterfaceConfigurationIndicationMessage message + ASSERT_TRUE(messages::send_transport_message(sock1, subscribe)); + ASSERT_EQ(1, broker_wrapper.run()); // Process + ASSERT_FALSE(broker_wrapper.error()); + + // Publish an InterfaceConfigurationIndicationMessage message to subscribers + constexpr int NUM_OF_IFACES = 17; + InterfaceConfigurationIndicationMessage iface_indication_msg_tx; + iface_indication_msg_tx.metadata()->numInterfaces = NUM_OF_IFACES; + ASSERT_TRUE(broker_wrapper.publish(iface_indication_msg_tx)); + + // Verify the data is received on the subscribed socket + ASSERT_TRUE(size_t(sock1.getBytesReady()) > sizeof(mapf::Message::Header)); + + // Read, parse and validate the message + auto iface_indication_msg_rx_ptr = messages::read_transport_message(sock1); + ASSERT_TRUE(iface_indication_msg_rx_ptr); + ASSERT_TRUE(iface_indication_msg_rx_ptr->type() == + uint32_t(Type::InterfaceConfigurationIndicationMessage)); + + auto &iface_indication_msg_rx = + dynamic_cast(*iface_indication_msg_rx_ptr); + + // Validate the number of interfaces matches the sent message + ASSERT_TRUE(iface_indication_msg_rx.metadata()->numInterfaces == NUM_OF_IFACES); +} + +} // namespace tests +} // namespace broker +} // namespace transport +} // namespace beerocks From e66cfe88cbf41f90173430697f18a11f4e7e7a52 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 16:44:59 +0000 Subject: [PATCH 155/453] framework: transport: cmake updates Disable transport tests (until aligned with the new broker). Add broker unit tests. Signed-off-by: Vitaly Bukhovsky --- .../ieee1905_transport/test/CMakeLists.txt | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/framework/transport/ieee1905_transport/test/CMakeLists.txt b/framework/transport/ieee1905_transport/test/CMakeLists.txt index bbdc427b51..702e85e773 100644 --- a/framework/transport/ieee1905_transport/test/CMakeLists.txt +++ b/framework/transport/ieee1905_transport/test/CMakeLists.txt @@ -1,6 +1,18 @@ if(BUILD_TESTS) - add_executable(ieee1905_transport_test ieee1905_transport_test.cpp) - target_link_libraries(ieee1905_transport_test ieee1905_transport_lib ieee1905_transport_messages mapfcommon elpp) - install(TARGETS ieee1905_transport_test DESTINATION bin/tests) - add_test(NAME ieee1905_transport_test COMMAND $) + # TODO: Temporarily transport tests, until local_bus/zmq dependecies are removed from the tests + # add_executable(ieee1905_transport_test ieee1905_transport_test.cpp) + # target_link_libraries(ieee1905_transport_test ieee1905_transport_lib ieee1905_transport_messages mapfcommon elpp) + # install(TARGETS ieee1905_transport_test DESTINATION bin/tests) + # add_test(NAME ieee1905_transport_test COMMAND $) + + # Broker Tests + add_executable(ieee1905_transport_broker_tests + ieee1905_transport_broker_tests.cpp + ) + + target_link_libraries(ieee1905_transport_broker_tests ieee1905_transport_lib gtest_main) + + install(TARGETS ieee1905_transport_broker_tests DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}/tests) + add_test(NAME ieee1905_transport_broker_tests COMMAND $) + endif() From 8e30df18741d30bfd8f0181dc9f2236dd20e7869 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 16:49:40 +0000 Subject: [PATCH 156/453] framework: transport: replace the broker Overall transport changes for replacing the existing broker implementation with the new one. Also move all transport related logic into a beerocks::transport namesapce. Signed-off-by: Vitaly Bukhovsky --- .../ieee1905_transport/ieee1905_transport.cpp | 139 +++++++++--------- .../mapf/transport => }/ieee1905_transport.h | 35 +++-- .../ieee1905_transport_local_bus.cpp | 45 +++--- .../ieee1905_transport_netlink.cpp | 8 +- .../ieee1905_transport_network.cpp | 122 +++++++++++---- .../ieee1905_transport_packet_processing.cpp | 35 +++-- .../transport/ieee1905_transport/main.cpp | 4 +- 7 files changed, 234 insertions(+), 154 deletions(-) rename framework/transport/ieee1905_transport/{include/mapf/transport => }/ieee1905_transport.h (93%) diff --git a/framework/transport/ieee1905_transport/ieee1905_transport.cpp b/framework/transport/ieee1905_transport/ieee1905_transport.cpp index e790113925..e234b80b67 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport.cpp @@ -6,94 +6,91 @@ * See LICENSE file for more details. */ -#include +#include +#include + +#include "ieee1905_transport.h" #include -namespace mapf { +namespace beerocks { +namespace transport { + +using broker::BrokerServer; void Ieee1905Transport::run() { - MAPF_INFO("starting 1905 transport."); + m_broker = std::make_unique(TMP_PATH "/" BEEROCKS_BROKER_UDS); + LOG_IF(!m_broker, FATAL) << "Failed creating broker server!"; - // init Local Bus interface, subscribe to specific topics - local_bus_ = new LocalBusInterface(Context::Instance()); - local_bus_->Init(); - if (local_bus_->subscriber().Subscribe() < 0) { - MAPF_ERR("cannot subscribe to local bus."); - return; - } - if (local_bus_->subscriber().Subscribe() < 0) { - MAPF_ERR("cannot subscribe to local bus."); - return; - } - local_bus_->Sync(); - poller_.Add(local_bus_->subscriber()); + LOG(INFO) << "starting 1905 transport."; + + // Register broker handlers for internal and external messages + m_broker->register_external_message_handler( + [&](std::unique_ptr &msg, BrokerServer &broker) -> bool { + LOG(DEBUG) << "Processing external message: " << msg->type(); + handle_broker_pollin_event(msg); + return true; + }); + + m_broker->register_internal_message_handler( + [&](std::unique_ptr &msg, BrokerServer &broker) -> bool { + LOG(DEBUG) << "Processing internal message: " << msg->type(); + handle_broker_pollin_event(msg); + return true; + }); // init netlink socket if (!open_netlink_socket()) { MAPF_ERR("cannot open netlink socket."); return; } - poller_.Add(netlink_fd_); - - // --------------------------------- - // Poller Items Type - // --------------------------------- - // local bus mapf::Socket - // netlink socket fd - // interface socket(s) fd - // --------------------------------- - while (1) { - MAPF_DBG("polling..."); - int nready = poller_.Poll(); - MAPF_DBG("poll returned " << nready << "."); - - // check for events on the Local Bus socket - MAPF_DBG("check for events on local bus subscriber socket."); - auto revents = poller_.CheckEvent(local_bus_->subscriber()); - if (revents & MAPF_POLLIN) { - handle_local_bus_pollin_event(); - } - if (revents & MAPF_POLLERR) { - MAPF_ERR("poll error on local bus subscriber socket."); - // TODO: handle this - } - // check for events on the netlink socket - MAPF_DBG("check for events on netlink socket."); - revents = poller_.CheckEvent(netlink_fd_); - if (revents & MAPF_POLLIN) { - MAPF_DBG("got MAPF_POLLIN event on netlink socket."); - handle_netlink_pollin_event(); - } - if (revents & MAPF_POLLERR) { - MAPF_ERR("got MAPF_POLLERR event on netlink socket."); - // TODO: handle this + // Create a shared_ptr socket wrapper for the netlink socket + auto netlink_socket = std::shared_ptr(new Socket(netlink_fd_), [](Socket *socket) { + // Close the socket file descriptor + if (socket) { + close(socket->getSocketFd()); } + }); + + // Add the netlink socket into the broker's event loop + m_broker->add_event( + netlink_socket, + { + // Accept incoming connections + .on_read = + [&](BrokerServer::EventType socket, BrokerServer::EventLoopType &loop) { + LOG(DEBUG) << "incoming message on the netlink socket"; + handle_netlink_pollin_event(); + return true; + }, + + // Not implemented + .on_write = nullptr, + .on_timeout = nullptr, + + // Fail on server socket disconnections or errors + .on_disconnect = + [&](BrokerServer::EventType socket, BrokerServer::EventLoopType &loop) { + LOG(ERROR) << "netlink socket disconnected"; + return false; + }, + .on_error = + [&](BrokerServer::EventType socket, BrokerServer::EventLoopType &loop) { + LOG(ERROR) << "netlink socket error"; + return false; + }, + }); - // check for events on all active network interface sockets - for (auto it = network_interfaces_.begin(); it != network_interfaces_.end(); ++it) { - auto &network_interface = it->second; - - if (network_interface.fd >= 0 && !network_interface.is_bridge) { - MAPF_DBG("check for events on interface " << network_interface.ifname << "."); - revents = poller_.CheckEvent(network_interface.fd); - if (revents & MAPF_POLLIN) { - MAPF_DBG("got MAPF_POLLIN event on interface " << network_interface.ifname - << "."); - handle_interface_pollin_event(network_interface.fd); - } - if (revents & MAPF_POLLERR) { - // this could happen whenever an interface comes down - MAPF_DBG("got MAPF_POLLERR event on interface " << network_interface.ifname - << " (disabling it)."); - handle_interface_status_change(if_nametoindex(network_interface.ifname.c_str()), - false); - } - } + // Run the broker event loop + for (;;) { + if (m_broker->run() < 0) { + LOG(ERROR) << "Broker event loop failure!"; + return; } } } -} // namespace mapf +} // namespace transport +} // namespace beerocks diff --git a/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport.h b/framework/transport/ieee1905_transport/ieee1905_transport.h similarity index 93% rename from framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport.h rename to framework/transport/ieee1905_transport/ieee1905_transport.h index 619931ead6..032d37a5d9 100644 --- a/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport.h +++ b/framework/transport/ieee1905_transport/ieee1905_transport.h @@ -9,9 +9,11 @@ #ifndef MAP_TRANSPORT_IEEE1905_TRANSPORT_H_ #define MAP_TRANSPORT_IEEE1905_TRANSPORT_H_ -#include "ieee1905_transport_messages.h" -#include -#include +#include +#include + +#include "ieee1905_transport_broker.h" + #include #include @@ -46,7 +48,8 @@ // TODO: this could be considered a platform bug that should be solved at the platform level - see https://jira-chd.intel.com/browse/UGW_SW-25961 // -namespace mapf { +namespace beerocks { +namespace transport { class Ieee1905Transport { public: @@ -64,7 +67,7 @@ class Ieee1905Transport { struct NetworkInterface { /// the file descriptor of the socket bound to this interface (or -1 if inactive) - int fd = -1; + std::shared_ptr fd; /// mac address of the interface uint8_t addr[ETH_ALEN] = {0}; /// interface name @@ -84,8 +87,7 @@ class Ieee1905Transport { // netlink socket file descriptor (used to track network interface status) int netlink_fd_ = -1; - mapf::LocalBusInterface *local_bus_; - mapf::Poller poller_; + std::unique_ptr m_broker; uint16_t message_id_ = 0; uint8_t al_mac_addr_[ETH_ALEN] = {0}; @@ -140,9 +142,9 @@ class Ieee1905Transport { // an internal data structure used for manipulating packets (CMDUs, LLDP, etc.) class Packet { public: - uint8_t dst_if_type = CmduRxMessage::IF_TYPE_NONE; + uint8_t dst_if_type = messages::CmduRxMessage::IF_TYPE_NONE; unsigned int dst_if_index = 0; - uint8_t src_if_type = CmduRxMessage::IF_TYPE_NONE; + uint8_t src_if_type = messages::CmduRxMessage::IF_TYPE_NONE; unsigned int src_if_index = 0; sMacAddr dst = {.oct = {0}}; // destination mac address sMacAddr src = {.oct = {0}}; // source mac address @@ -280,13 +282,13 @@ class Ieee1905Transport { void handle_netlink_pollin_event(); // - // LOCAL BUS STUFF + // BROKER STUFF // - void handle_local_bus_pollin_event(); - void handle_local_bus_cmdu_tx_message(CmduTxMessage &msg); - void handle_local_bus_interface_configuration_request_message( - InterfaceConfigurationRequestMessage &msg); - bool send_packet_to_local_bus(Packet &packet); + void handle_broker_pollin_event(std::unique_ptr &msg); + void handle_broker_cmdu_tx_message(messages::CmduTxMessage &msg); + void handle_broker_interface_configuration_request_message( + messages::InterfaceConfigurationRequestMessage &msg); + bool send_packet_to_broker(Packet &packet); void publish_interface_configuration_indication(); uint16_t get_next_message_id(); @@ -309,6 +311,7 @@ inline std::ostream &operator<<(std::ostream &os, const Ieee1905Transport::Packe return m.print(os); } -}; // namespace mapf +} // namespace transport +} // namespace beerocks #endif // MAP_TRANSPORT_IEEE1905_TRANSPORT_H_ diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp index baceaee510..5c807e0716 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp @@ -7,27 +7,29 @@ */ #include -#include + +#include "ieee1905_transport.h" #include #include -namespace mapf { +namespace beerocks { +namespace transport { -void Ieee1905Transport::handle_local_bus_pollin_event() -{ - auto msg = local_bus_->subscriber().Receive(); +// Use transport messaging classes +using namespace beerocks::transport::messages; +void Ieee1905Transport::handle_broker_pollin_event(std::unique_ptr &msg) +{ if (auto *cmdu_tx_msg = dynamic_cast(msg.get())) { MAPF_DBG("received CmduTxMessage message:" << std::endl << *cmdu_tx_msg); - handle_local_bus_cmdu_tx_message(*cmdu_tx_msg); + handle_broker_cmdu_tx_message(*cmdu_tx_msg); } else if (auto *interface_configuration_request_msg = dynamic_cast(msg.get())) { MAPF_DBG("received InterfaceConfigurationRequestMessage message:" << std::endl << *interface_configuration_request_msg); - handle_local_bus_interface_configuration_request_message( - *interface_configuration_request_msg); + handle_broker_interface_configuration_request_message(*interface_configuration_request_msg); } else if (auto *interface_configuration_query_msg = dynamic_cast(msg.get())) { MAPF_DBG("received InterfaceConfigurationQueryMessage message:" @@ -40,13 +42,13 @@ void Ieee1905Transport::handle_local_bus_pollin_event() } } -void Ieee1905Transport::handle_local_bus_cmdu_tx_message(CmduTxMessage &msg) +void Ieee1905Transport::handle_broker_cmdu_tx_message(CmduTxMessage &msg) { - // parse Local Bus CmduTxMessage message + // parse CmduTxMessage message struct Packet packet; packet.dst_if_type = msg.metadata()->if_type; packet.dst_if_index = msg.metadata()->if_index; - packet.src_if_type = CmduRxMessage::IF_TYPE_LOCAL_BUS; + packet.src_if_type = CmduTxMessage::IF_TYPE_LOCAL_BUS; packet.src_if_index = 0; std::copy_n(msg.metadata()->dst, ETH_ALEN, packet.dst.oct); std::copy_n(msg.metadata()->src, ETH_ALEN, packet.src.oct); @@ -77,8 +79,8 @@ void Ieee1905Transport::handle_local_bus_cmdu_tx_message(CmduTxMessage &msg) confMsg.metadata()->msg_id = ntohs(ch->messageId); MAPF_DBG("publishing CmduTxConfirmationMessage:" << std::endl << confMsg); - if (local_bus_->publisher().Send(confMsg) == false) { - MAPF_ERR("cannot publish message on local bus."); + if (!m_broker->publish(confMsg)) { + MAPF_ERR("cannot publish message to broker."); } } @@ -93,7 +95,7 @@ void Ieee1905Transport::handle_local_bus_cmdu_tx_message(CmduTxMessage &msg) handle_packet(packet); } -void Ieee1905Transport::handle_local_bus_interface_configuration_request_message( +void Ieee1905Transport::handle_broker_interface_configuration_request_message( InterfaceConfigurationRequestMessage &msg) { std::map updated_network_interfaces; @@ -128,9 +130,9 @@ void Ieee1905Transport::handle_local_bus_interface_configuration_request_message publish_interface_configuration_indication(); } -bool Ieee1905Transport::send_packet_to_local_bus(Packet &packet) +bool Ieee1905Transport::send_packet_to_broker(Packet &packet) { - // create and fill an CmduRxMessage to be sent on the local bus + // Create and fill an CmduRxMessage to be sent to the broker CmduRxMessage msg; std::copy_n(packet.src.oct, ETH_ALEN, msg.metadata()->src); @@ -154,8 +156,8 @@ bool Ieee1905Transport::send_packet_to_local_bus(Packet &packet) counters_[CounterId::INCOMMING_LOCAL_BUS_PACKETS]++; MAPF_DBG("publishing CmduRxMessage:" << std::endl << msg); - if (local_bus_->publisher().Send(msg) == false) { - MAPF_ERR("failed to publish message on local bus."); + if (!m_broker->publish(msg)) { + MAPF_ERR("failed to publish message to broker."); return false; } @@ -187,8 +189,8 @@ void Ieee1905Transport::publish_interface_configuration_indication() indication_msg.metadata()->numInterfaces = n; MAPF_DBG("publishing InterfaceConfigurationIndicationMessage:" << std::endl << indication_msg); - if (local_bus_->publisher().Send(indication_msg) == false) { - MAPF_ERR("failed to publish message on local bus."); + if (!m_broker->publish(indication_msg)) { + MAPF_ERR("failed to publish message to broker."); } } @@ -204,4 +206,5 @@ uint16_t Ieee1905Transport::get_next_message_id() return message_id_; } -} // namespace mapf +} // namespace transport +} // namespace beerocks diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_netlink.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_netlink.cpp index 62e58c2c85..059058351a 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_netlink.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_netlink.cpp @@ -6,7 +6,7 @@ * See LICENSE file for more details. */ -#include +#include "ieee1905_transport.h" #include #include @@ -21,7 +21,8 @@ // and we should then re-open the interface's raw socket, and add it to the poll list. To do that we need an event // to tell us that the interface is up and running - This is what we use netlink for. -namespace mapf { +namespace beerocks { +namespace transport { bool Ieee1905Transport::open_netlink_socket() { @@ -117,4 +118,5 @@ void Ieee1905Transport::handle_netlink_pollin_event() return; } -} // namespace mapf \ No newline at end of file +} // namespace transport +} // namespace beerocks diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_network.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_network.cpp index 51034da0f9..079b436e66 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_network.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_network.cpp @@ -6,7 +6,7 @@ * See LICENSE file for more details. */ -#include +#include "ieee1905_transport.h" #include #include @@ -19,7 +19,11 @@ #include #include -namespace mapf { +namespace beerocks { +namespace transport { + +// Use transport messaging classes +using namespace beerocks::transport::messages; // helper class to manage socket filter programs (Berkely Socket Filter) // @@ -90,9 +94,10 @@ void Ieee1905Transport::update_network_interfaces( if (updated_network_interfaces.count(ifname) == 0) { MAPF_INFO("interface " << ifname << " is no longer used."); - if (network_interface.fd >= 0) { - poller_.Remove(network_interface.fd); - close(network_interface.fd); + if (network_interface.fd) { + m_broker->del_event(network_interface.fd); + close(network_interface.fd->getSocketFd()); + network_interface.fd = nullptr; } it = network_interfaces_.erase(it); @@ -118,15 +123,44 @@ void Ieee1905Transport::update_network_interfaces( MAPF_WARN("cannot get address of interface " << if_index << "."); } - if (network_interfaces_[ifname].fd < 0) { + if (!network_interfaces_[ifname].fd) { // if the interface is not already open, try to open it and add it to the poller loop if (!open_interface_socket(if_index)) { MAPF_WARN("cannot open interface " << if_index << "."); } // add interface raw socket fd to poller loop (unless it's a bridge interface) - if (!network_interfaces_[ifname].is_bridge && network_interfaces_[ifname].fd >= 0) { - poller_.Add(network_interfaces_[ifname].fd); + if (!network_interfaces_[ifname].is_bridge && network_interfaces_[ifname].fd) { + // TODO: Move to a separate method + m_broker->add_event( + network_interfaces_[ifname].fd, + { + // Accept incoming connections + .on_read = + [&](broker::BrokerServer::EventType socket, + broker::BrokerServer::EventLoopType &loop) { + LOG(DEBUG) << "Incoming message on interface fd: " + << socket->getSocketFd(); + handle_interface_pollin_event(socket->getSocketFd()); + return true; + }, + + // Not implemented + .on_write = nullptr, + .on_timeout = nullptr, + .on_disconnect = nullptr, + + // Handle interface errors + .on_error = + [&](broker::BrokerServer::EventType socket, + broker::BrokerServer::EventLoopType &loop) { + LOG(DEBUG) << "Error on interface fd: " << socket->getSocketFd() + << " (disabling it)."; + + handle_interface_status_change(socket->getSocketFd(), false); + return true; + }, + }); } } @@ -147,9 +181,9 @@ bool Ieee1905Transport::open_interface_socket(unsigned int if_index) } MAPF_DBG("opening raw socket on interface " << ifname << "."); - if (network_interfaces_[ifname].fd != -1) { - close(network_interfaces_[ifname].fd); - network_interfaces_[ifname].fd = -1; + if (network_interfaces_[ifname].fd) { + close(network_interfaces_[ifname].fd->getSocketFd()); + network_interfaces_[ifname].fd = nullptr; } // Note to developer: The current implementation uses AF_PACKET socket with SOCK_RAW protocol which means we receive @@ -185,7 +219,8 @@ bool Ieee1905Transport::open_interface_socket(unsigned int if_index) return false; } - network_interfaces_[ifname].fd = sockfd; + network_interfaces_[ifname].fd = std::make_shared(sockfd); + LOG_IF(!sockfd, FATAL) << "Failed creating new Socket for fd: " << sockfd; attach_interface_socket_filter(if_index); @@ -212,8 +247,8 @@ bool Ieee1905Transport::attach_interface_socket_filter(unsigned int if_index) struct packet_mreq mr = {0}; mr.mr_ifindex = if_index; mr.mr_type = PACKET_MR_PROMISC; - if (setsockopt(network_interfaces_[ifname].fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr, - sizeof(mr)) == -1) { + if (setsockopt(network_interfaces_[ifname].fd->getSocketFd(), SOL_PACKET, PACKET_ADD_MEMBERSHIP, + &mr, sizeof(mr)) == -1) { MAPF_ERR("cannot put interface in promiscuous mode \"" << strerror(errno) << "\" (" << errno << ")."); return false; @@ -224,8 +259,8 @@ bool Ieee1905Transport::attach_interface_socket_filter(unsigned int if_index) Ieee1905SocketFilter(al_mac_addr_, network_interfaces_[ifname].addr).sock_fprog(); // attach filter - if (setsockopt(network_interfaces_[ifname].fd, SOL_SOCKET, SO_ATTACH_FILTER, &fprog, - sizeof(fprog)) == -1) { + if (setsockopt(network_interfaces_[ifname].fd->getSocketFd(), SOL_SOCKET, SO_ATTACH_FILTER, + &fprog, sizeof(fprog)) == -1) { MAPF_ERR("cannot attach socket filter \"" << strerror(errno) << "\" (" << errno << ")."); return false; } @@ -248,18 +283,47 @@ void Ieee1905Transport::handle_interface_status_change(unsigned int if_index, bo MAPF_INFO("interface " << ifname << " is now " << (is_active ? "active" : "inactive") << "."); - if (!is_active && network_interfaces_[ifname].fd >= 0) { - poller_.Remove(network_interfaces_[ifname].fd); - close(network_interfaces_[ifname].fd); - network_interfaces_[ifname].fd = -1; + if (!is_active && network_interfaces_[ifname].fd) { + m_broker->del_event(network_interfaces_[ifname].fd); + close(network_interfaces_[ifname].fd->getSocketFd()); + network_interfaces_[ifname].fd = nullptr; } - if (is_active && network_interfaces_[ifname].fd < 0) { + if (is_active && !network_interfaces_[ifname].fd) { if (!open_interface_socket(if_index)) { MAPF_ERR("cannot open network interface " << if_index << "."); } - if (network_interfaces_[ifname].fd >= 0) - poller_.Add(network_interfaces_[ifname].fd); + if (network_interfaces_[ifname].fd) + // Handle network events + m_broker->add_event( + network_interfaces_[ifname].fd, + { + // Accept incoming connections + .on_read = + [&](broker::BrokerServer::EventType socket, + broker::BrokerServer::EventLoopType &loop) { + LOG(DEBUG) + << "Incoming message on interface fd: " << socket->getSocketFd(); + handle_interface_pollin_event(socket->getSocketFd()); + return true; + }, + + // Not implemented + .on_write = nullptr, + .on_timeout = nullptr, + .on_disconnect = nullptr, + + // Handle interface errors + .on_error = + [&](broker::BrokerServer::EventType socket, + broker::BrokerServer::EventLoopType &loop) { + LOG(DEBUG) << "Error on interface fd: " << socket->getSocketFd() + << " (disabling it)."; + + handle_interface_status_change(socket->getSocketFd(), false); + return true; + }, + }); } } @@ -364,6 +428,11 @@ bool Ieee1905Transport::send_packet_to_network_interface(unsigned int if_index, return false; } + if (!network_interfaces_[ifname].fd) { + LOG(ERROR) << "Invalid fd for iface: " << ifname; + return false; + } + counters_[CounterId::OUTGOING_NETWORK_PACKETS]++; struct ether_header eh; @@ -373,7 +442,7 @@ bool Ieee1905Transport::send_packet_to_network_interface(unsigned int if_index, packet.header = {.iov_base = &eh, .iov_len = sizeof(eh)}; - int fd = network_interfaces_[ifname].fd; + int fd = network_interfaces_[ifname].fd->getSocketFd(); struct iovec iov[] = {packet.header, packet.payload}; int n = writev(fd, iov, sizeof(iov) / sizeof(struct iovec)); @@ -400,13 +469,14 @@ void Ieee1905Transport::set_al_mac_addr(const uint8_t *addr) auto &ifname = network_interface.ifname; unsigned int if_index = if_nametoindex(ifname.c_str()); - if (network_interface.fd >= 0) { + if (network_interface.fd) { attach_interface_socket_filter(if_index); } } } -} // namespace mapf +} // namespace transport +} // namespace beerocks #if 0 static const uint8_t ieee1905_multicast_address[ETH_ALEN] = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x13 }; // 01:80:c2:00:00:13 diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp index 389f833635..de6d013963 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp @@ -6,7 +6,7 @@ * See LICENSE file for more details. */ -#include +#include "ieee1905_transport.h" #include #include @@ -18,7 +18,11 @@ #define ETHER_IS_SAME(addr1, addr2) (memcmp((addr1), (addr2), ETH_ALEN) == 0) -namespace mapf { +namespace beerocks { +namespace transport { + +// Use transport messaging classes +using namespace beerocks::transport::messages; static const uint8_t ieee1905_max_message_version = 0x00; @@ -210,7 +214,7 @@ bool Ieee1905Transport::de_duplicate_packet(Packet &packet) return !is_duplicate; } -// De-fragmentation (reassembly) of received packets will be done before publishing a CMDU on the local bus (defragmentation is +// De-fragmentation (reassembly) of received packets will be done before publishing a CMDU to the broker (defragmentation is // not required for tunneling and relayed packets). // // De-fragmentation could fail if one or more fragments are never received - thus the fragments of a CMDU should be @@ -463,8 +467,8 @@ bool Ieee1905Transport::fragment_and_send_packet_to_network_interface(unsigned i bool Ieee1905Transport::forward_packet_single(Packet &packet) { if (packet.dst_if_type == CmduRxMessage::IF_TYPE_LOCAL_BUS) { - MAPF_DBG("forwarding packet to local bus."); - if (!send_packet_to_local_bus(packet)) { + MAPF_DBG("forwarding packet to broker."); + if (!send_packet_to_broker(packet)) { return false; } } else if (packet.dst_if_type == CmduRxMessage::IF_TYPE_NET && packet.dst_if_index != 0) { @@ -482,7 +486,7 @@ bool Ieee1905Transport::forward_packet_single(Packet &packet) return false; } } else { // no dst interface is specified - bool forward_to_local_bus = false; + bool forward_to_broker = false; bool forward_to_bridge = false; bool forward_to_network_interfaces = false; @@ -490,7 +494,7 @@ bool Ieee1905Transport::forward_packet_single(Packet &packet) // Step 1: decide on forwarding sink(s) // if (ETHER_IS_MULTICAST(packet.dst.oct)) { - forward_to_local_bus = true; + forward_to_broker = true; // Note: IEEE1905 multicast packets have special treatment due to the conditional forwarding logic (based on the // relayIndicator field) @@ -528,7 +532,7 @@ bool Ieee1905Transport::forward_packet_single(Packet &packet) } } if (addressed_to_this_device) { - forward_to_local_bus = true; + forward_to_broker = true; } else if (packet.src_if_type == CmduRxMessage::IF_TYPE_LOCAL_BUS) { forward_to_bridge = true; } @@ -537,21 +541,21 @@ bool Ieee1905Transport::forward_packet_single(Packet &packet) // // Step 2: forward to sink(s) decided in Step 1 // - if (forward_to_local_bus || forward_to_bridge || forward_to_network_interfaces) { + if (forward_to_broker || forward_to_bridge || forward_to_network_interfaces) { MAPF_DBG("forwarding packet to" - << (forward_to_local_bus ? " local bus," : "") + << (forward_to_broker ? " broker," : "") << (forward_to_bridge ? " bridge," : "") << (forward_to_network_interfaces ? " network interfaces" : "")); } else { MAPF_ERR("dropping packet: " << std::endl << packet); return false; } - if (forward_to_local_bus) { + if (forward_to_broker) { Packet defragmented_packet = packet; // create a copy because de_fragment_packet may modify Packet. if (de_fragment_packet(defragmented_packet)) { - if (!send_packet_to_local_bus(defragmented_packet)) { - MAPF_ERR("cannot forward packet to Local Bus."); + if (!send_packet_to_broker(defragmented_packet)) { + MAPF_ERR("cannot forward packet to broker."); return false; } } @@ -564,7 +568,7 @@ bool Ieee1905Transport::forward_packet_single(Packet &packet) if (((forward_to_bridge && network_interface.is_bridge) || (forward_to_network_interfaces && !network_interface.is_bridge)) && - (network_interface.fd >= 0) && + (network_interface.fd) && !(packet.src_if_type == CmduRxMessage::IF_TYPE_NET && packet.src_if_index == if_index)) { /* avoid loop-back */ if (!fragment_and_send_packet_to_network_interface(if_index, packet)) { @@ -686,4 +690,5 @@ std::ostream &Ieee1905Transport::Packet::print(std::ostream &os) const return os << ss.str(); } -} //namespace mapf +} // namespace transport +} // namespace beerocks diff --git a/framework/transport/ieee1905_transport/main.cpp b/framework/transport/ieee1905_transport/main.cpp index 31c6df525c..6c0b357017 100644 --- a/framework/transport/ieee1905_transport/main.cpp +++ b/framework/transport/ieee1905_transport/main.cpp @@ -6,12 +6,12 @@ * See LICENSE file for more details. */ -#include +#include "ieee1905_transport.h" #include #include -using namespace mapf; +using namespace beerocks::transport; int main(int argc, char *argv[]) { From 3a8e39ad57aa6732f1e5d9c12953270ce1e05cac Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 16:52:55 +0000 Subject: [PATCH 157/453] framework: common: remove no longer used files Signed-off-by: Vitaly Bukhovsky --- framework/common/broker_config.cpp | 92 ----- framework/common/broker_interface.cpp | 80 ---- framework/common/include/mapf/broker/broker.h | 51 --- .../include/mapf/broker/broker_config.h | 63 --- .../include/mapf/broker/broker_interface.h | 59 --- .../include/mapf/broker/broker_monitor.h | 41 -- .../common/include/mapf/common/context.h | 34 -- .../include/mapf/common/message_factory.h | 45 --- .../include/mapf/common/message_maker.h | 55 --- framework/common/include/mapf/common/poller.h | 55 --- framework/common/include/mapf/common/socket.h | 122 ------ framework/common/include/mapf/local_bus.h | 26 -- framework/common/local_bus.conf | 23 -- framework/common/local_bus.conf.in | 23 -- framework/common/local_bus.cpp | 62 --- framework/common/message_factory.cpp | 63 --- framework/common/nng/broker.cpp | 111 ------ framework/common/nng/context.cpp | 27 -- framework/common/nng/msglib.h | 22 -- framework/common/nng/poller.cpp | 131 ------- framework/common/nng/socket.cpp | 289 -------------- framework/common/nng/version.cpp | 18 - framework/common/test/local_bus_test.cpp | 130 ------ framework/common/test/poller_test.cpp | 194 --------- framework/common/test/socket_test.cpp | 369 ------------------ framework/common/zmq/broker.cpp | 130 ------ framework/common/zmq/context.cpp | 36 -- framework/common/zmq/msglib.h | 22 -- framework/common/zmq/poller.cpp | 186 --------- framework/common/zmq/socket.cpp | 358 ----------------- framework/common/zmq/version.cpp | 20 - 31 files changed, 2937 deletions(-) delete mode 100644 framework/common/broker_config.cpp delete mode 100644 framework/common/broker_interface.cpp delete mode 100644 framework/common/include/mapf/broker/broker.h delete mode 100644 framework/common/include/mapf/broker/broker_config.h delete mode 100644 framework/common/include/mapf/broker/broker_interface.h delete mode 100644 framework/common/include/mapf/broker/broker_monitor.h delete mode 100644 framework/common/include/mapf/common/context.h delete mode 100644 framework/common/include/mapf/common/message_factory.h delete mode 100644 framework/common/include/mapf/common/message_maker.h delete mode 100644 framework/common/include/mapf/common/poller.h delete mode 100644 framework/common/include/mapf/common/socket.h delete mode 100644 framework/common/include/mapf/local_bus.h delete mode 100644 framework/common/local_bus.conf delete mode 100644 framework/common/local_bus.conf.in delete mode 100644 framework/common/local_bus.cpp delete mode 100644 framework/common/message_factory.cpp delete mode 100644 framework/common/nng/broker.cpp delete mode 100644 framework/common/nng/context.cpp delete mode 100644 framework/common/nng/msglib.h delete mode 100644 framework/common/nng/poller.cpp delete mode 100644 framework/common/nng/socket.cpp delete mode 100644 framework/common/nng/version.cpp delete mode 100644 framework/common/test/local_bus_test.cpp delete mode 100644 framework/common/test/poller_test.cpp delete mode 100644 framework/common/test/socket_test.cpp delete mode 100644 framework/common/zmq/broker.cpp delete mode 100644 framework/common/zmq/context.cpp delete mode 100644 framework/common/zmq/msglib.h delete mode 100644 framework/common/zmq/poller.cpp delete mode 100644 framework/common/zmq/socket.cpp delete mode 100644 framework/common/zmq/version.cpp diff --git a/framework/common/broker_config.cpp b/framework/common/broker_config.cpp deleted file mode 100644 index 75c6caee19..0000000000 --- a/framework/common/broker_config.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include -#include -#include -#include - -namespace mapf { - -void BrokerConfig::Print() -{ - MAPF_INFO("name: " << name); - MAPF_INFO("monitor: " << monitor); - MAPF_INFO("path: " << path); - MAPF_INFO("sockets: "); - MAPF_INFO(" frontend: "); - for (auto &endpoint : frontend) - MAPF_INFO(" " << endpoint); - MAPF_INFO(" backend: "); - for (auto &endpoint : backend) - MAPF_INFO(" " << endpoint); - MAPF_INFO(" capture: "); - for (auto &endpoint : capture) - MAPF_INFO(" " << endpoint); - - MAPF_INFO("security: "); - MAPF_INFO(" enable: " << security.enable); - MAPF_INFO(" key_len: " << security.key_len); - MAPF_INFO(" xsub_secret: " << security.xsub_secret); - MAPF_INFO(" xsub_public: " << security.xsub_public); - MAPF_INFO(" pub_secret: " << security.pub_secret); - MAPF_INFO(" pub_public: " << security.pub_public); - MAPF_INFO(" xpub_secret: " << security.xpub_secret); - MAPF_INFO(" xpub_public: " << security.xpub_public); - MAPF_INFO(" sub_secret: " << security.sub_secret); - MAPF_INFO(" sub_public: " << security.sub_public); -} - -int BrokerConfig::Parse() -{ - struct json_object *jobj = json_object_from_file(path.c_str()); - mapf_assert(jobj); - - struct json_object *jsecurity, *jsockets, *jbroker, *jtmp; - - if (json_object_object_get_ex(jobj, "broker", &jbroker)) { - if (json_object_object_get_ex(jbroker, "name", &jtmp)) - name = json_object_get_string(jtmp); - if (json_object_object_get_ex(jbroker, "monitor", &jtmp)) - monitor = json_object_get_boolean(jtmp); - if (json_object_object_get_ex(jbroker, "sockets", &jsockets)) { - if (json_object_object_get_ex(jsockets, "frontend", &jtmp)) - frontend.insert(json_object_get_string(jtmp)); - if (json_object_object_get_ex(jsockets, "backend", &jtmp)) - backend.insert(json_object_get_string(jtmp)); - if (json_object_object_get_ex(jsockets, "capture", &jtmp)) - capture.insert(json_object_get_string(jtmp)); - } - if (json_object_object_get_ex(jbroker, "security", &jsecurity)) { - if (json_object_object_get_ex(jsecurity, "enable", &jtmp)) - security.enable = json_object_get_boolean(jtmp); - if (json_object_object_get_ex(jsecurity, "key_size", &jtmp)) - security.key_len = json_object_get_int(jtmp); - if (json_object_object_get_ex(jsecurity, "XSUB_secret", &jtmp)) - security.xsub_secret = json_object_get_string(jtmp); - if (json_object_object_get_ex(jsecurity, "XSUB_public", &jtmp)) - security.xsub_public = json_object_get_string(jtmp); - if (json_object_object_get_ex(jsecurity, "PUB_secret", &jtmp)) - security.pub_secret = json_object_get_string(jtmp); - if (json_object_object_get_ex(jsecurity, "PUB_public", &jtmp)) - security.pub_public = json_object_get_string(jtmp); - if (json_object_object_get_ex(jsecurity, "XPUB_secret", &jtmp)) - security.xpub_secret = json_object_get_string(jtmp); - if (json_object_object_get_ex(jsecurity, "XPUB_public", &jtmp)) - security.xpub_public = json_object_get_string(jtmp); - if (json_object_object_get_ex(jsecurity, "SUB_secret", &jtmp)) - security.sub_secret = json_object_get_string(jtmp); - if (json_object_object_get_ex(jsecurity, "SUB_public", &jtmp)) - security.sub_public = json_object_get_string(jtmp); - } - } - - return 0; -} - -} // namespace mapf diff --git a/framework/common/broker_interface.cpp b/framework/common/broker_interface.cpp deleted file mode 100644 index 20c15e0938..0000000000 --- a/framework/common/broker_interface.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include - -namespace mapf { - -int BrokerInterface::syncCount = 0; -void BrokerInterface::Init() -{ - int rc = config_.Parse(); - mapf_assert(rc == 0); - for (auto &backend : config_.backend) { - MAPF_INFO("connect " << config_.name << "@" << backend); - rc = sub_.Connect(backend); - mapf_assert(rc == 0); - } - for (auto &frontend : config_.frontend) { - MAPF_INFO("connect " << config_.name << "@" << frontend); - pub_.Connect(frontend); - mapf_assert(rc == 0); - } -} - -void BrokerInterface::PrintConfig() -{ - MAPF_DBG("BrokerInterface configuration"); - config_.Print(); -} - -void BrokerInterface::Sync() -{ - if (!Socket::SyncRequired()) { - return; - } - - syncCount++; - const std::string &msg_topic = sync_topic(); - Message tx_msg(msg_topic); - int rc, attempts = 0, max_attempts = 1000; - Poller poller; - - rc = sub_.Subscribe(msg_topic); - mapf_assert(rc == 0); - rc = poller.Add(sub_); - mapf_assert(rc == 0); - - while (attempts++ < max_attempts) { - SyncSend(tx_msg); - rc = poller.Poll(1); - if (rc > 0) { - mapf_assert(poller.CheckEvent(sub_) == MAPF_POLLIN); - if (SyncRecv(msg_topic)) - break; - } - } - mapf_assert(attempts < max_attempts); - rc = sub_.Unsubscribe(msg_topic); - mapf_assert(rc == 0); -} - -void BrokerInterface::SyncSend(Message &msg) -{ - bool rc = pub_.Send(msg); - mapf_assert(rc == true); -} - -bool BrokerInterface::SyncRecv(const std::string &msg_topic) -{ - Message msg; - bool rc = sub_.Receive(msg); - return rc && (msg_topic == msg.topic()); -} - -} /* namespace mapf */ diff --git a/framework/common/include/mapf/broker/broker.h b/framework/common/include/mapf/broker/broker.h deleted file mode 100644 index c6127340fb..0000000000 --- a/framework/common/include/mapf/broker/broker.h +++ /dev/null @@ -1,51 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_BROKER_H__ -#define __MAPF_BROKER_H__ - -#include -#include -#include -#include -#include - -namespace mapf { -struct msglib_socket; - -enum class BrokerSocket : int { FRONTEND, BACKEND }; - -class Broker { -public: - Broker(); - - explicit Broker(const std::string &cfg); - Broker(const Broker &) = delete; - Broker &operator=(const Broker &) = delete; - - ~Broker(); - - void Bind(BrokerSocket socket_type, const std::string &endpoint); - void Run(); - void PrintConfig(); - -private: - void Init(const std::string &cfg); - void Bind(); - - BrokerConfig config_; - -protected: - msglib_socket *frontend_; - msglib_socket *backend_; - void *context_; -}; - -} /* namespace mapf */ - -#endif /* __MAPF_BROKER_H__ */ diff --git a/framework/common/include/mapf/broker/broker_config.h b/framework/common/include/mapf/broker/broker_config.h deleted file mode 100644 index 6c661bf709..0000000000 --- a/framework/common/include/mapf/broker/broker_config.h +++ /dev/null @@ -1,63 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_BROKER_CONFIG_H__ -#define __MAPF_BROKER_CONFIG_H__ - -#include -#include - -namespace mapf { - -struct BrokerSecurity { -public: - BrokerSecurity() {} - - BrokerSecurity(bool enable, unsigned int key_len, std::string xsub_secret, - std::string xsub_public, std::string pub_secret, std::string pub_public, - std::string xpub_secret, std::string xpub_public, std::string sub_secret, - std::string sub_public) - : enable(enable), key_len(key_len), xsub_secret(xsub_secret), xsub_public(xsub_public), - pub_secret(pub_secret), pub_public(pub_public), xpub_secret(xpub_secret), - xpub_public(xpub_public), sub_secret(sub_secret), sub_public(sub_public) - { - } - - ~BrokerSecurity() {} - - bool enable = false; - unsigned int key_len = 41; - // PUB <--> broker (XSUB) set of keys - std::string xsub_secret; - std::string xsub_public; - std::string pub_secret; - std::string pub_public; - // SUB <--> to broker (XPUB) set of keys - std::string xpub_secret; - std::string xpub_public; - std::string sub_secret; - std::string sub_public; -}; - -struct BrokerConfig { - BrokerConfig() {} - explicit BrokerConfig(const std::string &path) : path(path) {} - ~BrokerConfig(){}; - int Parse(); - void Print(); - - bool verbose = false; - bool monitor = false; - std::string path; - std::string name; - std::set frontend, backend, capture; // endpoints - BrokerSecurity security; -}; - -} /* namespace mapf */ -#endif /* __MAPF_BROKER_CONFIG_H__ */ diff --git a/framework/common/include/mapf/broker/broker_interface.h b/framework/common/include/mapf/broker/broker_interface.h deleted file mode 100644 index 02e1c047ab..0000000000 --- a/framework/common/include/mapf/broker/broker_interface.h +++ /dev/null @@ -1,59 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_BROKER_IF_H__ -#define __MAPF_BROKER_IF_H__ - -#include "broker_config.h" -#include -#include -#include -#include - -extern char *__progname; -namespace mapf { - -class BrokerInterface { -public: - BrokerInterface(Context &ctx, const std::string &cfg, std::string sync_topic = "hello") - : config_(cfg), sub_(ctx), pub_(ctx), kSyncTopic(sync_topic) - { - } - - ~BrokerInterface() {} - - void Init(); - - void PrintConfig(); - - void Sync(); - - SubSocket &subscriber() const { return sub_; } - PubSocket &publisher() const { return pub_; } - -protected: - BrokerConfig config_; - mutable SubSocket sub_; - mutable PubSocket pub_; - -private: - BrokerInterface(); - const std::string kSyncTopic; - static int syncCount; - const std::string sync_topic() - { - return kSyncTopic + std::string(__progname) + std::to_string(syncCount); - } - - void SyncSend(Message &msg); - - bool SyncRecv(const std::string &msg_topic); -}; - -} /* namespace mapf */ -#endif /* __MAPF_BROKER_IF_H__ */ diff --git a/framework/common/include/mapf/broker/broker_monitor.h b/framework/common/include/mapf/broker/broker_monitor.h deleted file mode 100644 index cab5b1bd35..0000000000 --- a/framework/common/include/mapf/broker/broker_monitor.h +++ /dev/null @@ -1,41 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_BROKER_MONITOR_H__ -#define __MAPF_BROKER_MONITOR_H__ - -#include - -namespace mapf { - -class BrokerMonitor : public zmq::monitor_t { -public: - BrokerMonitor(); - BrokerMonitor(const std::string &name); - ~BrokerMonitor(); - void on_monitor_started(); - void on_event_connected(const zmq_event_t &event_, const char *addr_); - void on_event_connect_delayed(const zmq_event_t &event_, const char *addr_); - void on_event_connect_retried(const zmq_event_t &event_, const char *addr_); - void on_event_listening(const zmq_event_t &event_, const char *addr_); - void on_event_bind_failed(const zmq_event_t &event_, const char *addr_); - void on_event_accepted(const zmq_event_t &event_, const char *addr_); - void on_event_accept_failed(const zmq_event_t &event_, const char *addr_); - void on_event_closed(const zmq_event_t &event_, const char *addr_); - void on_event_close_failed(const zmq_event_t &event_, const char *addr_); - void on_event_disconnected(const zmq_event_t &event_, const char *addr_); - void on_event_handshake_failed(const zmq_event_t &event_, const char *addr_); - void on_event_handshake_succeed(const zmq_event_t &event_, const char *addr_); - void on_event_unknown(const zmq_event_t &event_, const char *addr_); - -private: - const std::string name_; -}; - -} // namespace mapf -#endif /* __MAPF_BROKER_MONITOR_H__ */ diff --git a/framework/common/include/mapf/common/context.h b/framework/common/include/mapf/common/context.h deleted file mode 100644 index e29b742c92..0000000000 --- a/framework/common/include/mapf/common/context.h +++ /dev/null @@ -1,34 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_COMMON_CONTEXT_H__ -#define __MAPF_COMMON_CONTEXT_H__ - -#include -#include -#include - -namespace mapf { - -class Context { -public: - static Context &Instance(); - ~Context(); - void *get(); - -private: - Context(); - void Close(); - Context(const Context &) = delete; - void operator=(const Context &) = delete; - void *ctx_; -}; - -} /* namespace mapf */ - -#endif /* __MAPF_COMMON_CONTEXT_H__ */ diff --git a/framework/common/include/mapf/common/message_factory.h b/framework/common/include/mapf/common/message_factory.h deleted file mode 100644 index b691aadca1..0000000000 --- a/framework/common/include/mapf/common/message_factory.h +++ /dev/null @@ -1,45 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_COMMON_MESSAGE_FACTORY_H__ -#define __MAPF_COMMON_MESSAGE_FACTORY_H__ - -#include "message.h" -#include -#include -#include -#include - -namespace mapf { - -class MessageMakerBase; - -class MessageFactory { -public: - static MessageFactory &Instance(); - void RegisterMaker(const std::string &topic_prefix, MessageMakerBase *maker); - std::unique_ptr Create(const std::string &topic) const; - std::unique_ptr Create(const std::string &topic, - std::initializer_list frames) const; - - void DumpMakers() - { - std::cout << "Factory registered Message Makers:" << std::endl; - for (auto m : makers_) - std::cout << m.first << std::endl; - } - -private: - std::map::const_iterator Find(const std::string &topic) const; - - // map of all Message Makers where the key is the topic prefix - std::map makers_; -}; - -} /* namespace mapf */ -#endif /* __MAPF_COMMON_MESSAGE_FACTORY_H__ */ diff --git a/framework/common/include/mapf/common/message_maker.h b/framework/common/include/mapf/common/message_maker.h deleted file mode 100644 index b6497b4774..0000000000 --- a/framework/common/include/mapf/common/message_maker.h +++ /dev/null @@ -1,55 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_COMMON_MESSAGE_MAKER_H__ -#define __MAPF_COMMON_MESSAGE_MAKER_H__ - -#include "message_factory.h" -#include -#include -#include - -namespace mapf { - -class Message; - -class MessageMakerBase { -public: - virtual std::unique_ptr Create(const std::string &topic) const = 0; - virtual std::unique_ptr Create(const std::string &topic, - std::initializer_list frames) const = 0; - virtual const std::string &topic_prefix() const = 0; - virtual ~MessageMakerBase() {} -}; - -template class MessageMaker : public MessageMakerBase { -public: - explicit MessageMaker(const std::string &topic_prefix) : topic_prefix_(topic_prefix) - { - MessageFactory::Instance().RegisterMaker(topic_prefix, this); - } - - virtual std::unique_ptr Create(const std::string &topic) const - { - return std::unique_ptr{new T(topic)}; - } - - virtual std::unique_ptr Create(const std::string &topic, - std::initializer_list frames) const - { - return std::unique_ptr{new T(topic, frames)}; - } - - virtual const std::string &topic_prefix() const { return topic_prefix_; } - -private: - const std::string topic_prefix_; -}; - -} /* namespace mapf */ -#endif /* __MAPF_COMMON_MESSAGE_MAKER_H__ */ diff --git a/framework/common/include/mapf/common/poller.h b/framework/common/include/mapf/common/poller.h deleted file mode 100644 index 7b648bd386..0000000000 --- a/framework/common/include/mapf/common/poller.h +++ /dev/null @@ -1,55 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_COMMON_POLLER_H__ -#define __MAPF_COMMON_POLLER_H__ - -#include -#include -#include -#include -#include - -#define MAPF_POLLIN POLLIN -#define MAPF_POLLOUT POLLOUT -#define MAPF_POLLERR POLLERR -#define MAPF_POLLPRI POLLPRI - -namespace mapf { - -struct msglib_pollitems; - -class Poller { -public: - Poller(); - virtual ~Poller(); - Poller(const Poller &) = delete; - Poller &operator=(const Poller &) = delete; - - int Add(const Socket &socket, short events = MAPF_POLLIN); - int Modify(const Socket &socket, short events); - int Remove(const Socket &socket); - int Add(int fd, short events = MAPF_POLLIN); - int Modify(int fd, short events); - int Remove(int fd); - - int getLinuxfd(const Socket &socket); - int Poll(long timeout = -1); - short CheckEvent(const Socket &socket); - short CheckEvent(int fd); - - void PrintItems() const; - -private: - int Remove(const Socket *socket, int fd); - - msglib_pollitems *items_; -}; - -} /* namespace mapf */ -#endif /* __MAPF_COMMON_POLLER_H__ */ diff --git a/framework/common/include/mapf/common/socket.h b/framework/common/include/mapf/common/socket.h deleted file mode 100644 index 3d3e66941a..0000000000 --- a/framework/common/include/mapf/common/socket.h +++ /dev/null @@ -1,122 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_COMMON_SOCKET_H__ -#define __MAPF_COMMON_SOCKET_H__ - -#include -#include -#include -#include -#include -#include -#include - -namespace mapf { - -struct msglib_socket; -class Socket { - friend inline std::ostream &operator<<(std::ostream &os, const Socket &socket); - -public: - Socket(); - virtual ~Socket(); - Socket(const Socket &) = delete; - Socket &operator=(const Socket &) = delete; - - // -1 - endless, 0 - one shot, >0 - num of retries - int Connect(const std::string &addr, int max_retries = -1); - - void Close(); - - virtual std::ostream &Print(std::ostream &s) const = 0; - virtual bool Pollable() const = 0; - int fd() const; - msglib_socket *handle() const { return sock; }; - static bool SyncRequired(); - -protected: - msglib_socket *sock; -}; - -class PubSocket : public Socket { -public: - explicit PubSocket(Context &ctx); - std::ostream &Print(std::ostream &s) const override; - bool Pollable() const override { return false; } - bool Send(const std::unique_ptr &msg, int flags = 0); - bool Send(const Message &msg, int flags = 0); - size_t Send(void *buf, size_t len, int flags); //TODO - change to private - -private: - PubSocket(); - static std::string padTopic(const std::string &topic); - static const char topic_pad_char = '\0'; -}; - -class SubSocket : public Socket { -public: - explicit SubSocket(Context &ctx); - - std::ostream &Print(std::ostream &s) const override; - - bool Pollable() const override { return true; } - - /** (Un)Subscribe APIs - prefer templated versions (uses factory) */ - - int Subscribe(std::string const &topic); - template int Subscribe(std::string const &topic = T::kTopicPrefix) - { - static MessageMaker maker(T::kTopicPrefix); - return Subscribe(topic); - } - int Subscribe(const std::initializer_list &topics); - template int Subscribe(std::initializer_list topics) - { - mapf_assert(topics.size() > 0); - for (const auto &topic : topics) - Subscribe(topic); - } - - int Unsubscribe(const std::string &topic); - template int Unsubscribe(const std::string &topic = T::kTopicPrefix) - { - return Unsubscribe(topic); - } - int Unsubscribe(std::initializer_list topics); - template int Unsubscribe(std::initializer_list topics) - { - mapf_assert(topics.size() > 0); - for (const auto &topic : topics) - return Unsubscribe(topic); - } - - /** Receive APIs - prefer unique_ptr versions (uses factory) */ - bool Receive(Message &msg, int flags = 0); - std::unique_ptr Receive(int flags = 0); - ssize_t Receive(void *buf, size_t len, int flags = 0); //TODO - change to private - bool Receive(Message::Frame &frame, int flags = 0); //TODO - change to private - -private: - SubSocket(); - std::vector::iterator FindSubscription(const std::string &topic); - bool More() const; - std::unique_ptr ReceiveTopic(int flags); - std::unique_ptr ReceiveHeader(int flags); - Message::Frame ReceiveFrames(size_t total_len, int flags); - void EraseSubscription(const std::string &topic); - void AddSubscription(const std::string &topic); - - std::vector topics_; -}; - -inline std::ostream &operator<<(std::ostream &os, const Socket &socket) { return socket.Print(os); } - -} //namespace mapf - -#endif /* __MAPF_COMMON_SOCKET_H__ */ diff --git a/framework/common/include/mapf/local_bus.h b/framework/common/include/mapf/local_bus.h deleted file mode 100644 index 9f88dacd9a..0000000000 --- a/framework/common/include/mapf/local_bus.h +++ /dev/null @@ -1,26 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_LOCAL_BUS_API_H__ -#define __MAPF_LOCAL_BUS_API_H__ - -#include -#include - -namespace mapf { - -static const std::string kLocalBusConf(std::string(MAPF_ROOT) + "/share/local_bus.conf"); - -class LocalBusInterface : public BrokerInterface { -public: - explicit LocalBusInterface(Context &ctx) : BrokerInterface(ctx, kLocalBusConf) {} - ~LocalBusInterface() {} -}; -} // namespace mapf - -#endif /* __MAPF_LOCAL_BUS_API_H__ */ diff --git a/framework/common/local_bus.conf b/framework/common/local_bus.conf deleted file mode 100644 index 0b0e9688f8..0000000000 --- a/framework/common/local_bus.conf +++ /dev/null @@ -1,23 +0,0 @@ -{ - "broker": { - "name": "local_bus", - "verbose": true, - "sockets": { - "frontend" : "ipc:///tmp//publishers", - "backend" : "ipc:///tmp//subscribers" - }, - "security": { - "enable": false, - "proto": "CURVE", - "key_size": 41, - "XSUB_secret": "SH64O[L:u!-B?OGgX&c+IW9cGNA-ZLr5HPBt3#lG", - "XSUB_public": "BaDJcijQ+x+c![N})@8a#vvctotg:6KTE", - "PUB_secret": "gWie.%dscPTfQM]1D", - "XPUB_secret": "D:)Q[IlAW!ahhC2ac:9*A}h:p?([4%wOTJ%JR%cs", - "XPUB_public": "Yne@$w-vo+}o?pNmC{O&4W4b!Ni{Lh6", - "SUB_public": "rq:rM>}U?@Lns47E1%kR.o@n%FcmmsL/@{H8]yf7" - } - } -} diff --git a/framework/common/local_bus.conf.in b/framework/common/local_bus.conf.in deleted file mode 100644 index e6f21a9fc2..0000000000 --- a/framework/common/local_bus.conf.in +++ /dev/null @@ -1,23 +0,0 @@ -{ - "broker": { - "name": "local_bus", - "verbose": true, - "sockets": { - "frontend" : "ipc://@TMP_PATH@/publishers", - "backend" : "ipc://@TMP_PATH@/subscribers" - }, - "security": { - "enable": false, - "proto": "CURVE", - "key_size": 41, - "XSUB_secret": "SH64O[L:u!-B?OGgX&c+IW9cGNA-ZLr5HPBt3#lG", - "XSUB_public": "BaDJcijQ+x+c@f6yUA@![N})@8a#vvctotg:6KTE", - "PUB_secret": "gWie.%dscPTfQM]1D", - "XPUB_secret": "D:)Q[IlAW!ahhC2ac:9*A}h:p?([4%wOTJ%JR%cs", - "XPUB_public": "Yne@$w-vo+}o?pNmC{O&4W4b!Ni{Lh6", - "SUB_public": "rq:rM>}U?@Lns47E1%kR.o@n%FcmmsL/@{H8]yf7" - } - } -} diff --git a/framework/common/local_bus.cpp b/framework/common/local_bus.cpp deleted file mode 100644 index 8b8d97647e..0000000000 --- a/framework/common/local_bus.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include -#include -#include -#include -#include - -void usage() -{ - std::cout << "usage: broker -[cfbdsh]" << std::endl; - std::cout << " c - broker.conf path" << std::endl; - std::cout << " f - extra frontend endpoints (comma seperated list)" << std::endl; - std::cout << " b - extra backend endpoints (comma seperated list)" << std::endl; - std::cout << " h - show this help menu" << std::endl; -} -int main(int argc, char *argv[]) -{ - mapf::Logger::Instance().LoggerInit("local_bus"); - std::string conf = std::string(MAPF_ROOT) + "/share/local_bus.conf"; - std::string endpoint, frontend, backend; - int opt; - - while ((opt = getopt(argc, argv, "c:f:b:h")) != EOF) { - switch (opt) { - case 'c': - conf = optarg; - std::cout << "conf path: " << conf << std::endl; - break; - case 'f': - frontend = optarg; - break; - case 'b': - backend = optarg; - break; - case 'h': - default: - usage(); - return -1; - } - } - - mapf::Broker broker(conf); - std::istringstream f_endpoints(frontend); - while (std::getline(f_endpoints, endpoint, ',')) - broker.Bind(mapf::BrokerSocket::FRONTEND, endpoint); - - std::istringstream b_endpoints(backend); - while (std::getline(b_endpoints, endpoint, ',')) - broker.Bind(mapf::BrokerSocket::BACKEND, endpoint); - - broker.PrintConfig(); - broker.Run(); - - return 0; -} diff --git a/framework/common/message_factory.cpp b/framework/common/message_factory.cpp deleted file mode 100644 index b2d6112751..0000000000 --- a/framework/common/message_factory.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace mapf { - -MessageFactory &MessageFactory::Instance() -{ - static MessageFactory factory; - return factory; -} - -void MessageFactory::RegisterMaker(const std::string &topic_prefix, MessageMakerBase *maker) -{ - auto it = Find(topic_prefix); - mapf_assert(it == makers_.end()); // we don't allow multiple makers for the same topic prefix - makers_[topic_prefix] = maker; -} - -std::unique_ptr MessageFactory::Create(const std::string &topic) const -{ - auto it = Find(topic); - if (it != makers_.end()) { - MessageMakerBase *maker = it->second; - return maker->Create(topic); - } - return std::unique_ptr{new Message(topic)}; -} - -std::unique_ptr MessageFactory::Create(const std::string &topic, - std::initializer_list frames) const -{ - auto it = Find(topic); - if (it != makers_.end()) { - MessageMakerBase *maker = it->second; - return maker->Create(topic, frames); - } - return std::unique_ptr{new Message(topic, frames)}; -} - -std::map::const_iterator -MessageFactory::Find(const std::string &topic) const -{ - return std::find_if(makers_.begin(), makers_.end(), - [&topic](const std::pair &m) { - return (topic.find(m.first) == 0); - }); -} - -} /* namespace mapf */ diff --git a/framework/common/nng/broker.cpp b/framework/common/nng/broker.cpp deleted file mode 100644 index e934ce5bc4..0000000000 --- a/framework/common/nng/broker.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include "msglib.h" -#include -#include -#include -#include -#include -#include - -namespace mapf { - -Broker::Broker() : frontend_(new msglib_socket), backend_(new msglib_socket), context_(nullptr) -{ - int rc = nng_pub0_open_raw(&backend_->sd_); - if (rc) { - fprintf(stderr, "nng: %s\n", nng_strerror(rc)); - mapf_assert(0); - } - rc = nng_sub0_open_raw(&frontend_->sd_); - if (rc) { - fprintf(stderr, "nng: %s\n", nng_strerror(rc)); - mapf_assert(0); - } -} - -Broker::Broker(const std::string &cfg) : Broker() { Init(cfg); } - -Broker::~Broker() -{ - delete frontend_; - delete backend_; -} - -void Broker::PrintConfig() -{ - MAPF_INFO("Broker configuration"); - config_.Print(); -} - -void Broker::Init(const std::string &cfg) -{ - config_ = std::move(BrokerConfig(cfg)); - config_.Parse(); - Bind(); -} - -void Broker::Bind() -{ - for (auto &frontend : config_.frontend) - Bind(BrokerSocket::FRONTEND, frontend); - for (auto &backend : config_.backend) - Bind(BrokerSocket::BACKEND, backend); -} - -void Broker::Bind(BrokerSocket socket_type, const std::string &endpoint) -{ - int rc; - - switch (socket_type) { - case BrokerSocket::FRONTEND: - if (config_.security.enable) { - //Not supported - } - if (config_.verbose) - MAPF_INFO("bind frontend: " + endpoint); - std::cout << "bind sub frontend: " << endpoint << std::endl; - config_.frontend.insert(endpoint); - rc = nng_listen(frontend_->sd_, endpoint.c_str(), nullptr, 0); - if (rc) { - fprintf(stderr, "nng: %s\n", nng_strerror(rc)); - mapf_assert(0); - } - break; - case BrokerSocket::BACKEND: - if (config_.security.enable) { - //Not supported - } - if (config_.verbose) - MAPF_INFO("bind backend: " + endpoint); - std::cout << "bind pub frontend: " << endpoint << std::endl; - config_.backend.insert(endpoint); - rc = nng_listen(backend_->sd_, endpoint.c_str(), nullptr, 0); - if (rc) { - fprintf(stderr, "nng: %s\n", nng_strerror(rc)); - mapf_assert(0); - } - break; - default: - mapf_assert(0); - } -} - -void Broker::Run() -{ - if (config_.verbose) - MAPF_DBG("start proxy (secure=" << std::boolalpha << config_.security.enable << ")"); - int rc = nng_device(frontend_->sd_, backend_->sd_); - if (rc) { - fprintf(stderr, "nng: %s\n", nng_strerror(rc)); - mapf_assert(0); - } -} - -} // namespace mapf diff --git a/framework/common/nng/context.cpp b/framework/common/nng/context.cpp deleted file mode 100644 index 37ad25a212..0000000000 --- a/framework/common/nng/context.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include - -namespace mapf { - -Context &Context::Instance() -{ - static Context instance; - return instance; -} - -Context::~Context() { Close(); } - -Context::Context() : ctx_(nullptr) {} - -void Context::Close() {} - -void *Context::get() { return ctx_; } - -} /* namespace mapf */ diff --git a/framework/common/nng/msglib.h b/framework/common/nng/msglib.h deleted file mode 100644 index f3935d941e..0000000000 --- a/framework/common/nng/msglib.h +++ /dev/null @@ -1,22 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_COMMON_MSGLIB_H__ -#define __MAPF_COMMON_MSGLIB_H__ - -#include - -namespace mapf { - -struct msglib_socket { - nng_socket sd_; -}; - -} //namespace mapf - -#endif /*__MAPF_COMMON_MSGLIB_H__ */ \ No newline at end of file diff --git a/framework/common/nng/poller.cpp b/framework/common/nng/poller.cpp deleted file mode 100644 index c4b6d91e88..0000000000 --- a/framework/common/nng/poller.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include "msglib.h" -#include -#include -#include -#include - -namespace mapf { - -struct msglib_pollitems { - std::vector items_; - - std::vector::iterator Find(const Socket &socket) { return Find(socket.fd()); } - - std::vector::iterator Find(int fd) - { - return std::find_if(items_.begin(), items_.end(), - [&fd](const pollfd &item) { return item.fd == fd; }); - } -}; - -Poller::Poller() : items_(new msglib_pollitems) {} - -Poller::~Poller() { delete items_; } - -int Poller::Add(int fd, short events) -{ - errno = 0; - MAPF_INFO("Adding polling socket " << fd); - if (fd < 0) { - errno = EINVAL; - MAPF_ERR("Invalid fd=" << fd << ", can't add to poller"); - return -1; - } - - auto it = items_->Find(fd); - if (it == items_->items_.end()) { - items_->items_.push_back({fd, events, 0}); - } else { - errno = EEXIST; - MAPF_ERR("fd " << fd << " already added, skipping..."); - return -1; - } - - return 0; -} - -int Poller::Add(const Socket &socket, short events) -{ - errno = 0; - if (socket.Pollable() == false) { - errno = EINVAL; - MAPF_ERR("socket " << socket << " not pollable!"); - return -1; - } - return Add(socket.fd(), events); -} - -int Poller::Modify(const Socket &socket, short events) { return Modify(socket.fd(), events); } - -int Poller::Modify(int fd, short events) -{ - errno = 0; - auto it = items_->Find(fd); - if (it != items_->items_.end()) { - it->events = events; - } else { - errno = ENONET; - MAPF_ERR("fd " << fd << " not added, skipping..."); - return -1; - } - - return 0; -} - -int Poller::Remove(const Socket &socket) { return Remove(socket.fd()); } - -int Poller::Remove(int fd) -{ - errno = 0; - auto it = items_->Find(fd); - if (it != items_->items_.end()) { - items_->items_.erase(it); - return 0; - } else { - MAPF_ERR("fd " << fd << " not added, skipping..."); - errno = ENOENT; - return -1; - } -} - -int Poller::Poll(long timeout) -{ - int result = 0; - if (items_->items_.empty()) - return 0; - errno = 0; - result += poll(items_->items_.data(), items_->items_.size(), timeout); - - return result; -} - -short Poller::CheckEvent(const Socket &socket) { return CheckEvent(socket.fd()); } - -short Poller::CheckEvent(int fd) -{ - auto it = items_->Find(fd); - if (it != items_->items_.end()) - return (*it).revents; - - MAPF_ERR("fd " << fd << " not added, skipping..."); - errno = ENOENT; - return -1; -} - -void Poller::PrintItems() const -{ - MAPF_INFO("Poll Items:"); - for (auto item : items_->items_) - MAPF_INFO("socket. fd:" << item.fd << ", events: " << item.events - << ", revents: " << item.revents); -} - -} /* namespace mapf */ diff --git a/framework/common/nng/socket.cpp b/framework/common/nng/socket.cpp deleted file mode 100644 index 8b5e8f2d07..0000000000 --- a/framework/common/nng/socket.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include "msglib.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#define MAPF_DEBUG -#ifdef MAPF_DEBUG -#define DBG MAPF_DBG -#else -#define DBG(...) -#endif - -namespace mapf { - -/* Socket API */ - -Socket::Socket() : sock(new msglib_socket) {} - -Socket::~Socket() -{ - Close(); - delete sock; -} - -bool Socket::SyncRequired() { return false; } - -int Socket::Connect(const std::string &addr, int max_retries) -{ - mapf_assert(!addr.empty()); - int rc, retries = 0; - do { - rc = nng_dial(sock->sd_, addr.c_str(), nullptr, 0); - if (rc == 0) - break; - MAPF_DBG("nng_dial failed: " << nng_strerror(rc) << " retry #" << retries); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } while (max_retries < 0 || retries++ < max_retries); - - MAPF_ERR_IF(rc, "nng_dial failed"); - return rc; -} - -void Socket::Close() -{ - //failure occures only when socket is already closed, so no need to check return value - nng_close(sock->sd_); -} - -int Socket::fd() const -{ - int fd = -1; - size_t sz = sizeof(fd); - int rc = nng_getopt(sock->sd_, NNG_OPT_RECVFD, &fd, &sz); - MAPF_ERR_IF(rc, "Can't get fd for socket. errno=" << nng_strerror(rc)); - - return fd; -} - -/* PUB socket API */ -PubSocket::PubSocket(Context &ctx) -{ - int rc = nng_pub0_open(&sock->sd_); - mapf_assert(rc == 0); -} - -size_t PubSocket::Send(void *buf, size_t len, int flags) -{ - int rc = nng_send(sock->sd_, buf, len, flags); - if (rc == 0) { - return len; - } else { - return -1; - } -} - -bool PubSocket::Send(const Message &msg, int flags) -{ - mapf_assert(msg.version() == Message::kMessageHeaderVersion); - mapf_assert(msg.len() <= Message::kMaxFrameLength); - - std::string paddedTopic = padTopic(msg.topic()); - - uint totalLen = paddedTopic.length(); - for (auto frame : msg.frames()) { - totalLen += frame.len(); - } - - uint8_t buf[totalLen]; - int copied = 0; - memcpy(buf, (void *)paddedTopic.data(), paddedTopic.length()); - copied = paddedTopic.length(); - for (auto frame : msg.frames()) { - memcpy(buf + copied, frame.data(), frame.len()); - copied += frame.len(); - } - int rc = nng_send(sock->sd_, buf, copied, flags); - - return rc == 0; -} - -bool PubSocket::Send(const std::unique_ptr &msg, int flags) -{ - mapf_assert(msg); - return Send(*msg, flags); -} - -std::string PubSocket::padTopic(const std::string &topic) -{ - std::ostringstream s; - s << topic << std::setfill(PubSocket::topic_pad_char) - << std::setw(Message::kMaxTopicSize - topic.length()) << '\0'; - return s.str(); -} - -std::ostream &PubSocket::Print(std::ostream &s) const -{ - s << "PUB socket, fd=" << fd() << std::endl; - return s; -} - -/* SUB socket API */ -SubSocket::SubSocket(Context &ctx) -{ - int rc = nng_sub0_open(&sock->sd_); - mapf_assert(rc == 0); -} - -int SubSocket::Subscribe(const std::string &topic) -{ - errno = 0; - int rc = nng_setopt(sock->sd_, NNG_OPT_SUB_SUBSCRIBE, topic.c_str(), topic.length()); - if (rc) { - MAPF_ERR("Subscribe " << topic << " failed, errno=" << nng_strerror(rc)); - return rc; - } - - AddSubscription(topic); - return 0; -} - -int SubSocket::Subscribe(const std::initializer_list &topics) -{ - for (auto &topic : topics) { - Subscribe(topic); - } - return 0; -} - -int SubSocket::Unsubscribe(const std::string &topic) -{ - if (topic.empty()) - return 0; - int rc = nng_setopt(sock->sd_, NNG_OPT_SUB_UNSUBSCRIBE, topic.c_str(), topic.length()); - if (rc == 0) - EraseSubscription(topic); - return rc; -} - -int SubSocket::Unsubscribe(std::initializer_list topics) -{ - for (auto &topic : topics) - Unsubscribe(topic); - - return 0; -} - -ssize_t SubSocket::Receive(void *buf, size_t len, int flags) -{ - void *alloc_buf = nullptr; - size_t size; - int rc = nng_recv(sock->sd_, &alloc_buf, &size, NNG_FLAG_ALLOC); - - memcpy(buf, alloc_buf, int(len)); - if (rc != 0) { - if (errno == EAGAIN) - return 0; - return -1; - } - - return size; -} - -bool SubSocket::Receive(Message::Frame &frame, int flags) -{ - int nbytes = Receive(frame.data(), frame.len(), flags); - if (nbytes == -1) { - MAPF_ERR("nng_recv failed with error " << strerror(errno)); - return false; - } - - return true; -} - -bool SubSocket::Receive(Message &msg, int flags) -{ - msg.Clear(); - - void *buf = nullptr; - size_t size; - int rc = nng_recv(sock->sd_, &buf, &size, NNG_FLAG_ALLOC); //buffer is allocated by nanomsg - if (rc != 0) { - MAPF_ERR("Can't allocate buffer for message"); - return false; - } - msg.set_topic(std::string((char *)buf, 0, Message::kMaxTopicSize)); - Message::Frame frame( - size, - (uint8_t *)buf + - Message:: - kMaxTopicSize); //The constructor copies the data into the frame internal buffer - msg.Add(frame); - nng_free(buf, size); - - DBG("message received"); - return true; -} - -std::unique_ptr SubSocket::Receive(int flags) -{ - void *buf = nullptr; - size_t size; - int rc = nng_recv(sock->sd_, &buf, &size, NNG_FLAG_ALLOC); //buffer is allocated by nanomsg - if (rc != 0) { - MAPF_ERR("Can't allocate buffer for message"); - return nullptr; - } - std::string topic = std::string((char *)buf, 0, Message::kMaxTopicSize); - int nbytes = size - Message::kMaxTopicSize; - Message::Frame frame( - nbytes, - (uint8_t *)buf + - Message:: - kMaxTopicSize); //The constructor copies the data into the frame internal buffer - nng_free(buf, size); - DBG("message received"); - return MessageFactory::Instance().Create(topic, {frame}); -} - -bool SubSocket::More() const { return false; } -std::unique_ptr SubSocket::ReceiveTopic(int flags) { return nullptr; } -std::unique_ptr SubSocket::ReceiveHeader(int flags) { return nullptr; } -Message::Frame SubSocket::ReceiveFrames(size_t total_len, int flags) { return Message::Frame(); } - -std::vector::iterator SubSocket::FindSubscription(const std::string &topic) -{ - return std::find_if(topics_.begin(), topics_.end(), - [&topic](const std::string &item) { return item == topic; }); -} - -void SubSocket::AddSubscription(const std::string &topic) -{ - auto it = FindSubscription(topic); - if (it == topics_.end()) - topics_.push_back(topic); -} - -void SubSocket::EraseSubscription(const std::string &topic) -{ - auto it = FindSubscription(topic); - if (it != topics_.end()) - it = topics_.erase(it); -} - -std::ostream &SubSocket::Print(std::ostream &s) const -{ - s << "SUB socket, fd = " << fd() << ". topics:"; - for (const auto &topic : topics_) { - s << std::endl << topic; - } - - return s; -} - -} // namespace mapf diff --git a/framework/common/nng/version.cpp b/framework/common/nng/version.cpp deleted file mode 100644 index 3b86e7c13b..0000000000 --- a/framework/common/nng/version.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include -#include -#include - -int main(void) -{ - printf("Current nng version: %s\n", nng_version()); - printf("Current MAPF version is %s\n", MAPF_VERSION); - return 0; -} diff --git a/framework/common/test/local_bus_test.cpp b/framework/common/test/local_bus_test.cpp deleted file mode 100644 index 9fdfcd7d0a..0000000000 --- a/framework/common/test/local_bus_test.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class LocalBusTestMessage : public mapf::Message { -public: - static const std::string kTopicPrefix; - explicit LocalBusTestMessage(const std::string &topic) : Message(topic) {} - LocalBusTestMessage(const std::string &topic, std::initializer_list frames) - : Message(topic, frames) - { - } - virtual ~LocalBusTestMessage() {} -}; -const std::string LocalBusTestMessage::kTopicPrefix = "test."; -const std::string kTopic(LocalBusTestMessage::kTopicPrefix + "1"); -const std::string kData1("0123456789"); -const std::string kData2("ABCDEFGHIJKLMNOP"); - -class LocalBusTest { -public: - LocalBusTest() : lbus_(mapf::Context::Instance()) - { - lbus_.Init(); - int rc = lbus_.subscriber().Subscribe(); - mapf_assert(rc == 0); - rc = poller_.Add(lbus_.subscriber()); - mapf_assert(rc == 0); - lbus_.Sync(); - mapf_assert(rc == 0); - // print makers - should be LocalBusTest topic prefix only - mapf::MessageFactory::Instance().DumpMakers(); - } - - void Run() - { - Send(); - Poll(); - Recv(); - } - -protected: - virtual void Send() - { - // sends a message created by the factory - mapf::Message::Frame data1(kData1.size(), kData1.data()); - mapf::Message::Frame data2(kData2.size(), kData2.data()); - auto msg = mapf::MessageFactory::Instance().Create(kTopic, {data1, data2}); - mapf_assert(msg); - - bool rc = lbus_.publisher().Send(msg); - mapf_assert(rc == true); - auto frames = [&msg]() { - std::string frames; - for (auto f : msg->frames()) - frames += f.str() + ", "; - return frames; - }; - MAPF_INFO("sending multi frame message:\n\tMessage: " << *msg - << "\n\tFrames: " << frames()); - } - - virtual void Poll() - { - int rc = poller_.Poll(); - mapf_assert(rc == 1); - } - - virtual void Recv() - { - - // receive message using socket factory APIs - auto msg = lbus_.subscriber().Receive(); - assert(msg); - MAPF_INFO("received message:\n\tMessage: " << *msg << "\n\tFrame: " << msg->frame().str()); - } - -private: - mapf::LocalBusInterface lbus_; - mapf::Poller poller_; -}; - -void signal_handler(int signum) -{ - MAPF_INFO("PID #" << getpid() << ": Interrupt Signal (" << signum << ") received."); - exit(signum); -} - -int local_bus() -{ - pid_t pid = fork(); - mapf_assert(pid >= 0); - - if (pid == 0) { - signal(SIGTERM, signal_handler); - MAPF_INFO("staring local bus broker"); - mapf::Broker localbus(mapf::kLocalBusConf); - localbus.PrintConfig(); - localbus.Run(); - } - usleep(1000); //wait till broker is ready... - return pid; -} - -int main(int argc, char *argv[]) -{ - mapf::Logger::Instance().LoggerInit("local_bus_test"); - pid_t pid = local_bus(); - MAPF_INFO("local_bus pid = " << pid); - - LocalBusTest test; - test.Run(); - - kill(pid, SIGTERM); - return 0; -} diff --git a/framework/common/test/poller_test.cpp b/framework/common/test/poller_test.cpp deleted file mode 100644 index 1df21c0594..0000000000 --- a/framework/common/test/poller_test.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class PollerTest { -public: - explicit PollerTest(mapf::Context &ctx, const char *name = "") - : name_(name), pub_(ctx), sub_(ctx), sub2_(ctx) - { - int rc = pub_.Connect(kPubAddr); - mapf_assert(rc == 0); - rc = sub_.Connect(kSubAddr); - mapf_assert(rc == 0); - rc = sub_.Subscribe(kTopic); - mapf_assert(rc == 0); - rc = sub2_.Connect(kSubAddr); - mapf_assert(rc == 0); - rc = sub2_.Subscribe(kTopic2); - mapf_assert(rc == 0); - std::cout << "\nTEST START: " << name_ << "\n\tsub1 socket: " << sub_ - << "\nsub2 socket: " << sub2_ << "\npublisher socket: " << pub_ << std::endl; - } - - void SlowJoinerMultipleAttempts() - { - int attempts = 0, max_attempts = 100, rc; - - std::cout << "sending first message multiple attempts (slow joiner fix)" << std::endl; - // slow joiner syndrom - send multiple times untill received - while (attempts++ < max_attempts) { - Send(); - rc = poller_.Poll(10); - if (rc > 0) { - mapf_assert(poller_.CheckEvent(sub_) == MAPF_POLLIN || - poller_.CheckEvent(sub2_) == MAPF_POLLIN); - - break; - } - } - mapf_assert(attempts < max_attempts); - Recv(); - std::cout << "finished first message send after " << attempts << " attempts" << std::endl; - } - - void Run() - { - int rc; - MAPF_INFO("START"); - rc = poller_.Add(sub_); - mapf_assert(rc == 0); - rc = poller_.Add(sub2_); - mapf_assert(rc == 0); - SlowJoinerMultipleAttempts(); - Send(); - Recv(); - - // verify poll doesn't return false events - rc = poller_.Poll(10); - - // Send and receive once more - std::cout << "sending second message" << std::endl; - Send(); - - // Verify delete - rc = poller_.Remove(sub_); - mapf_assert(rc == 0); - rc = poller_.Remove(sub2_); - mapf_assert(rc == 0); - // poll should return 0 - rc = poller_.Poll(); - mapf_assert(rc == 0); - - // verify add again - rc = poller_.Add(sub_); - mapf_assert(rc == 0); - rc = poller_.Add(sub2_); - mapf_assert(rc == 0); - rc = poller_.Poll(); - mapf_assert(rc > 0); - Recv(); - MAPF_INFO(name_ << ": finished second message send (single attempt)"); - } - -protected: - void Send() - { - mapf::Message::Frame data(kData.size(), kData.data()); - mapf::Message msg(kTopic, {data}); - mapf::Message::Frame data2(kData2.size(), kData2.data()); - mapf::Message msg2(kTopic2, {data2}); - - MAPF_INFO("send message #1: " << msg << "\nFrame: " << msg.frame().str()); - bool rc = pub_.Send(msg); - mapf_assert(rc == true); - - MAPF_INFO("send message #2: " << msg2 << "\nFrame: " << msg2.frame().str()); - rc = pub_.Send(msg2); - mapf_assert(rc == true); - } - - void Recv() - { - mapf::Message msg; - - int received = 0; - while (received < 2) { - int rc = poller_.Poll(); - mapf_assert(rc > 0); - - MAPF_INFO("rc = " << rc); - poller_.PrintItems(); - bool ret = false; - if (poller_.CheckEvent(sub_)) { - ret = sub_.Receive(msg); - mapf_assert(ret); - MAPF_INFO("received message: " << msg << "\nFrame: " << msg.frame().str()); - received++; - } - if (poller_.CheckEvent(sub2_)) { - ret = sub2_.Receive(msg); - mapf_assert(ret); - MAPF_INFO("received message: " << msg << "\nFrame: " << msg.frame().str()); - received++; - } - } - } - - const std::string name_; - mapf::PubSocket pub_; - mapf::SubSocket sub_; - mapf::SubSocket sub2_; - mapf::Poller poller_; - -private: - PollerTest(); -}; - -void sighandler(int signum) -{ - MAPF_INFO("PID #" << getpid() << ": Interrupt Signal (" << signum << ") received."); - // if we got abort(), it means there was an assert. Send abort to all sub processes and exit - if (signum == SIGABRT) - kill(0, SIGABRT); - exit(signum); -} - -int start_broker() -{ - pid_t pid = fork(); - mapf_assert(pid >= 0); - - if (pid == 0) { - signal(SIGTERM, sighandler); - MAPF_INFO("broker starting"); - mapf::Broker broker; - broker.Bind(mapf::BrokerSocket::FRONTEND, kPubAddr); - broker.Bind(mapf::BrokerSocket::BACKEND, kSubAddr); - broker.Run(); - } - return pid; -} - -int main(int argc, char *argv[]) -{ - mapf::Logger::Instance().LoggerInit("poller_test"); - signal(SIGABRT, sighandler); - - pid_t pid = start_broker(); - MAPF_INFO("broker pid = " << pid); - - mapf::Context &ctx = mapf::Context::Instance(); - - PollerTest test(ctx); - test.Run(); - - kill(pid, SIGTERM); - return 0; -} diff --git a/framework/common/test/socket_test.cpp b/framework/common/test/socket_test.cpp deleted file mode 100644 index 3bcf62a1b6..0000000000 --- a/framework/common/test/socket_test.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class SocketTest { -public: - struct SocketTestConfig { - unsigned iterations = 1; - unsigned max_attempts = 1000; - unsigned init_delay = 0; - bool verbose = false; - }; - - explicit SocketTest(mapf::Context &context, SocketTestConfig *cfg = nullptr, - const char *name = "") - : name_(name), pub_(context), sub_(context) - { - if (cfg) - cfg_ = SocketTestConfig(*cfg); - int rc = pub_.Connect(kPubAddr); - mapf_assert(rc == 0); - rc = sub_.Connect(kSubAddr); - mapf_assert(rc == 0); - rc = sub_.Subscribe(kTopic); - mapf_assert(rc == 0); - mapf::MessageFactory::Instance().DumpMakers(); - } - - void Run() - { - for (int i = 0; i < int(cfg_.iterations); i++) { - if (cfg_.verbose) { - std::cout << "\n#" << i << ": TEST START: " << name_ << std::endl; - std::cout << "subscriber socket: " << sub_ << "\npublisher socket: " << pub_ - << std::endl; - } - - if (mapf::Socket::SyncRequired()) { - usleep(200000); //handle slow joiner syndrom - best effort:) - } - - // Send and receive once more - if (cfg_.verbose) - std::cout << "sending second message" << std::endl; - Send(); - Recv(); - if (cfg_.verbose) { - std::cout << "finished second message send (single attempt)" << std::endl; - std::cout << "#" << i << ": TEST PASSED: " << name_ << std::endl; - } - } - } - -protected: - virtual void Recv() = 0; - virtual void Send() = 0; - - const std::string name_; - SocketTestConfig cfg_; - mapf::PubSocket pub_; - mapf::SubSocket sub_; - -private: - SocketTest(); -}; - -// test sending single string -class SocketTestString : public SocketTest { -public: - explicit SocketTestString(mapf::Context &ctx, SocketTestConfig *cfg = nullptr) - : SocketTest(ctx, cfg, "SocketTestString") - { - } - - void Send() override - { - int rc = pub_.Send((void *)(kTopic.data()), kTopic.size(), 0); - mapf_assert(rc >= 0); - } - - void Recv() override - { - char buf[256]; - int nbytes = sub_.Receive(buf, sizeof(buf)); - mapf_assert(nbytes > 0); - if (cfg_.verbose) - MAPF_INFO(name_ << ": received message: " - << std::string(static_cast(buf), nbytes)); - } -}; - -// test sending single frame -class SocketTestFrame : public SocketTest { -public: - explicit SocketTestFrame(mapf::Context &ctx, SocketTestConfig *cfg = nullptr) - : SocketTest(ctx, cfg, "SocketTestFrame") - { - } - - void Send() override - { - bool rc = pub_.Send((void *)kTopic.data(), (size_t)kTopic.size(), 0); - mapf_assert(rc == true); - } - - void Recv() override - { - mapf::Message::Frame topic(kTopic.size()); - memset(topic.data(), 0, topic.len()); - bool rc = sub_.Receive(topic); - mapf_assert(rc == true); - if (cfg_.verbose) - MAPF_INFO(name_ << ": received frame " << topic << " data: " << topic.data()); - } -}; - -// test sending a message with a single frame -class SocketTestMessage : public SocketTest { -public: - explicit SocketTestMessage(mapf::Context &ctx, SocketTestConfig *cfg = nullptr) - : SocketTest(ctx, cfg, "SocketTestMessage") - { - } - - void Send() override - { - mapf::Message::Frame data(kData.size(), kData.data()); - mapf::Message::Frame data2(kData2.size(), kData2.data()); - mapf::Message msg(kTopic, {data, mapf::Message::Frame(0), data2}); - bool rc = pub_.Send(msg); - mapf_assert(rc == true); - } - - void Recv() override - { - mapf::Message msg; - bool rc = sub_.Receive(msg); - mapf_assert(rc == true); - if (cfg_.verbose) - MAPF_INFO("received single frame message: " << msg << "\nFrame: " << msg.frame().str()); - } -}; - -// test sending a message with a 2 frames -class SocketTestMessageMult : public SocketTest { -public: - explicit SocketTestMessageMult(mapf::Context &ctx, SocketTestConfig *cfg = nullptr) - : SocketTest(ctx, cfg, "SocketTestMessageMult") - { - } - - void Send() override - { - mapf::Message::Frame data1(kData.size(), kData.data()); - mapf::Message::Frame data2(kData2.size(), kData2.data()); - mapf::Message msg(kTopic, {data1, data2}); - - bool rc = pub_.Send(msg); - auto frames = [&msg]() { - std::string frames; - for (auto f : msg.frames()) - frames += f.str() + ", "; - return frames; - }; - if (cfg_.verbose) - MAPF_INFO("sending multi frame message:\n\tMessage: " << msg - << "\n\tFrames: " << frames()); - mapf_assert(rc == true); - } - - void Recv() override - { - mapf::Message msg; - bool rc = sub_.Receive(msg); - mapf_assert(rc == true); - if (cfg_.verbose) - MAPF_INFO("received multi frame message:\n\tMessage: " << msg << "\n\tFrame: " - << msg.frame().str()); - } -}; - -// test sending a message with a 2 frames, receive with MessageFactory -class SocketTestMessageMultFactory : public SocketTest { -public: - explicit SocketTestMessageMultFactory(mapf::Context &ctx, SocketTestConfig *cfg = nullptr) - : SocketTest(ctx, cfg, "SocketTestMessageMultFactory") - { - } - - void Send() override - { - mapf::Message::Frame data1(kData.size(), kData.data()); - mapf::Message::Frame data2(kData2.size(), kData2.data()); - auto msg = mapf::MessageFactory::Instance().Create(kTopic, {data1, data2}); - - bool rc = pub_.Send(msg); - auto frames = [&msg]() { - std::string frames; - for (auto f : msg->frames()) - frames += f.str() + ", "; - return frames; - }; - if (cfg_.verbose) - MAPF_INFO("sending multi frame message:\n\tMessage: " << *msg - << "\n\tFrames: " << frames()); - mapf_assert(rc == true); - } - - void Recv() override - { - auto msg = sub_.Receive(); - mapf_assert(msg); - if (cfg_.verbose) - MAPF_INFO("received multi frame message:\n\tMessage: " << *msg << "\n\tFrame: " - << msg->frame().str()); - } -}; - -SocketTest::SocketTestConfig g_cfg; -std::string g_test = "all"; - -void PrintHelp() -{ - std::cout << "-d/--delay : Init delay (wait before start test)\n" - "-i/--iterations : Iterations for each test case\n" - "-a/--attempts : Max attempts for slow joiner WA\n" - "-t/--test : Test to run (all | string | frame | message | mult | factory)\n" - "-v/--verbose: Enable verbose printing\n" - "-h/--help: Show help\n"; - exit(1); -} - -void ProcessArgs(int argc, char **argv) -{ - const char *const short_opts = "i:a:t:d:vh"; - const option long_opts[] = {{"iterations", 1, nullptr, 'i'}, {"delay", 1, nullptr, 'd'}, - {"attempts", 1, nullptr, 'a'}, {"test", 1, nullptr, 't'}, - {"verbose", 0, nullptr, 'v'}, {"help", 0, nullptr, 'h'}, - {nullptr, 0, nullptr, 0}}; - - while (true) { - const auto opt = getopt_long(argc, argv, short_opts, long_opts, nullptr); - - if (-1 == opt) - break; - - switch (opt) { - case 'd': - g_cfg.init_delay = std::strtoul(optarg, nullptr, 10); - std::cout << "Init Delay[us]: " << g_cfg.init_delay << std::endl; - break; - case 'i': - g_cfg.iterations = std::strtoul(optarg, nullptr, 10); - std::cout << "Iterations: " << g_cfg.iterations << std::endl; - break; - case 'a': - g_cfg.max_attempts = std::strtoul(optarg, nullptr, 10); - std::cout << "Max Attempts (slow joiner): " << g_cfg.max_attempts << std::endl; - break; - case 't': - g_test = std::string(optarg); - if (g_test != "all" && g_test != "string" && g_test != "frame" && g_test != "message" && - g_test != "mult" && g_test != "factory") { - std::cout << "Invalid test name: " << g_test << std::endl; - PrintHelp(); - } - std::cout << "Test: " << g_test << std::endl; - break; - case 'v': - g_cfg.verbose = true; - std::cout << "Verbose\n"; - break; - case 'h': // -h or --help - case '?': // Unrecognized option - default: - PrintHelp(); - break; - } - } -} - -void sighandler(int signum) -{ - MAPF_INFO("PID #" << getpid() << ": Interrupt Signal (" << signum << ") received."); - // if we got abort(), it means there was an assert. Send abort to all sub processes and exit - if (signum == SIGABRT) - kill(0, SIGABRT); - exit(signum); -} - -int start_broker(SocketTest::SocketTestConfig &cfg) -{ - pid_t pid = fork(); - mapf_assert(pid >= 0); - - if (pid == 0) { - signal(SIGTERM, sighandler); - if (cfg.verbose) - MAPF_INFO("broker starting"); - mapf::Broker broker; - broker.Bind(mapf::BrokerSocket::FRONTEND, kPubAddr); - broker.Bind(mapf::BrokerSocket::BACKEND, kSubAddr); - broker.Run(); - } - - return pid; -} - -int main(int argc, char *argv[]) -{ - mapf::Logger::Instance().LoggerInit("socket_test"); - ProcessArgs(argc, argv); - - signal(SIGABRT, sighandler); - pid_t pid = start_broker(g_cfg); - - mapf::Context &ctx = mapf::Context::Instance(); - - if (g_test == "all" || g_test == "string") { - MAPF_INFO("Socket test string start"); - SocketTestString test_string(ctx, &g_cfg); - test_string.Run(); - } - - if (g_test == "all" || g_test == "frame") { - MAPF_INFO("Socket test frame start"); - SocketTestFrame test_frame(ctx, &g_cfg); - test_frame.Run(); - } - - if (g_test == "all" || g_test == "message") { - MAPF_INFO("Socket test message start"); - SocketTestMessage test_message(ctx, &g_cfg); - test_message.Run(); - } - - if (g_test == "all" || g_test == "mult") { - MAPF_INFO("Socket test message mult start"); - SocketTestMessageMult test_multi(ctx, &g_cfg); - test_multi.Run(); - } - - if (g_test == "all" || g_test == "factory") { - MAPF_INFO("Socket test message mult factory start"); - SocketTestMessageMultFactory test_factory(ctx, &g_cfg); - test_factory.Run(); - } - - kill(pid, SIGTERM); - return 0; -} diff --git a/framework/common/zmq/broker.cpp b/framework/common/zmq/broker.cpp deleted file mode 100644 index fa86aa5a52..0000000000 --- a/framework/common/zmq/broker.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include "msglib.h" -#include -#include - -namespace mapf { - -Broker::Broker() : frontend_(new msglib_socket), backend_(new msglib_socket) -{ - context_ = zmq_ctx_new(); - errno_assert(context_); - - frontend_->sd_ = zmq_socket(context_, ZMQ_XSUB); - errno_assert(frontend_->sd_); - - backend_->sd_ = zmq_socket(context_, ZMQ_XPUB); - errno_assert(backend_->sd_); -} - -Broker::Broker(const std::string &cfg) : Broker() { Init(cfg); } - -Broker::~Broker() -{ - int rc = zmq_close(frontend_->sd_); - errno_assert(rc == 0); - rc = zmq_close(backend_->sd_); - errno_assert(rc == 0); - rc = zmq_ctx_destroy(context_); - errno_assert(rc == 0); - delete frontend_; - delete backend_; -} - -void Broker::PrintConfig() -{ - MAPF_INFO("Borker configuration"); - config_.Print(); -} - -void Broker::Init(const std::string &cfg) -{ - config_ = std::move(BrokerConfig(cfg)); - config_.Parse(); - Bind(); -} - -void Broker::Bind() -{ - for (auto &frontend : config_.frontend) - Bind(BrokerSocket::FRONTEND, frontend); - for (auto &backend : config_.backend) - Bind(BrokerSocket::BACKEND, backend); -} - -void Broker::Bind(BrokerSocket socket_type, const std::string &endpoint) -{ - int rc; - - switch (socket_type) { - case BrokerSocket::FRONTEND: - if (config_.security.enable) { - rc = zmq_setsockopt(frontend_->sd_, ZMQ_CURVE_SERVERKEY, - config_.security.pub_public.c_str(), config_.security.key_len); - errno_assert(rc == 0); - rc = zmq_setsockopt(frontend_->sd_, ZMQ_CURVE_PUBLICKEY, - config_.security.xsub_public.c_str(), config_.security.key_len); - errno_assert(rc == 0); - rc = zmq_setsockopt(frontend_->sd_, ZMQ_CURVE_SECRETKEY, - config_.security.xsub_secret.c_str(), config_.security.key_len); - errno_assert(rc == 0); - } - if (config_.verbose) - MAPF_DBG("bind frontend: " + endpoint); - config_.frontend.insert(endpoint); - rc = zmq_bind(frontend_->sd_, endpoint.c_str()); - errno_assert(rc == 0); - break; - case BrokerSocket::BACKEND: - if (config_.security.enable) { - int as_server = 1; - rc = zmq_setsockopt(backend_->sd_, ZMQ_CURVE_SERVER, &as_server, sizeof(int)); - errno_assert(rc == 0); - rc = zmq_setsockopt(backend_->sd_, ZMQ_CURVE_SECRETKEY, - config_.security.xpub_secret.c_str(), config_.security.key_len); - errno_assert(rc == 0); - } - if (config_.verbose) - MAPF_DBG("bind backend: " + endpoint); - config_.backend.insert(endpoint); - rc = zmq_bind(backend_->sd_, endpoint.c_str()); - errno_assert(rc == 0); - break; - default: - errno_assert(0); - } -} - -void Broker::Run() -{ - //Sanity - char endpoint[128]; - size_t len = sizeof(endpoint); - - zmq_getsockopt(frontend_->sd_, ZMQ_LAST_ENDPOINT, endpoint, &len); - if (std::string(endpoint) == "") { - MAPF_ERR("broker '" + config_.name + "' frontend socket not binded!"); - errno_assert(0); - } - - len = sizeof(endpoint); - zmq_getsockopt(backend_->sd_, ZMQ_LAST_ENDPOINT, endpoint, &len); - if (std::string(endpoint) == "") { - MAPF_ERR("broker '" + config_.name + "' backend socket not binded!"); - errno_assert(0); - } - - // Start broker - if (config_.verbose) - MAPF_DBG("start proxy (secure=" << std::boolalpha << config_.security.enable << ")"); - zmq_proxy(frontend_->sd_, backend_->sd_, nullptr); -} - -} // namespace mapf diff --git a/framework/common/zmq/context.cpp b/framework/common/zmq/context.cpp deleted file mode 100644 index 8a612f30b0..0000000000 --- a/framework/common/zmq/context.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include -#include - -namespace mapf { - -Context &Context::Instance() -{ - static Context instance; - return instance; -} - -Context::~Context() { Close(); } - -Context::Context() : ctx_(zmq_ctx_new()) { mapf_assert(ctx_); } - -void Context::Close() -{ - if (ctx_ == nullptr) - return; - - int rc = zmq_ctx_destroy(ctx_); - mapf_assert(rc == 0); - ctx_ = nullptr; -} - -void *Context::get() { return ctx_; } - -} /* namespace mapf */ \ No newline at end of file diff --git a/framework/common/zmq/msglib.h b/framework/common/zmq/msglib.h deleted file mode 100644 index f29546f88f..0000000000 --- a/framework/common/zmq/msglib.h +++ /dev/null @@ -1,22 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_COMMON_MSGLIB_H__ -#define __MAPF_COMMON_MSGLIB_H__ - -#include - -namespace mapf { - -struct msglib_socket { - void *sd_; -}; - -} //namespace mapf - -#endif /*__MAPF_COMMON_MSGLIB_H__ */ \ No newline at end of file diff --git a/framework/common/zmq/poller.cpp b/framework/common/zmq/poller.cpp deleted file mode 100644 index acd60c2b53..0000000000 --- a/framework/common/zmq/poller.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include "msglib.h" -#include -#include -#include -#include -#include - -namespace mapf { - -struct msglib_pollitems { - std::vector items_; - - std::vector::iterator Find(const Socket *socket) - { - return std::find_if(items_.begin(), items_.end(), [&socket](const zmq_pollitem_t &item) { - return item.socket == socket->handle()->sd_; - }); - } - - std::vector::iterator Find(int fd) - { - return std::find_if(items_.begin(), items_.end(), - [&fd](const zmq_pollitem_t &item) { return item.fd == fd; }); - } -}; - -Poller::Poller() : items_(new msglib_pollitems) {} - -Poller::~Poller() { delete items_; } - -int Poller::Add(int fd, short events) -{ - errno = 0; - MAPF_INFO("Adding polling socket " << fd); - if (fd < 0) { - errno = EINVAL; - MAPF_ERR("Invalid fd=" << fd << ", can't add to poller"); - return -1; - } - - auto it = items_->Find(fd); - if (it == items_->items_.end()) { - items_->items_.push_back({nullptr, fd, events, 0}); - } else { - errno = EEXIST; - MAPF_ERR("fd " << fd << " already added, skipping..."); - return -1; - } - - return 0; -} - -int Poller::Add(const Socket &socket, short events) -{ - errno = 0; - if (socket.Pollable() == false) { - errno = EINVAL; - MAPF_ERR("socket " << socket << " not pollable!"); - return -1; - } - MAPF_INFO("Adding polling socket " << socket); - - auto it = items_->Find(&socket); - if (it == items_->items_.end()) { - items_->items_.push_back({socket.handle()->sd_, -1, events, 0}); - } else { - errno = EEXIST; - MAPF_ERR("socket " << socket << " already added, skipping..."); - return -1; - } - - return 0; -} - -int Poller::Modify(const Socket &socket, short events) -{ - errno = 0; - auto it = items_->Find(&socket); - if (it != items_->items_.end()) { - it->events = events; - } else { - errno = ENONET; - MAPF_ERR("socket " << socket << " not added, skipping..."); - return -1; - } - - return 0; -} - -int Poller::Modify(int fd, short events) -{ - errno = 0; - auto it = items_->Find(fd); - if (it != items_->items_.end()) { - it->events = events; - } else { - errno = ENONET; - MAPF_ERR("fd " << fd << " not added, skipping..."); - return -1; - } - - return 0; -} - -int Poller::Remove(const Socket &socket) -{ - errno = 0; - auto it = items_->Find(&socket); - if (it != items_->items_.end()) { - it = items_->items_.erase(it); - return 0; - } else { - errno = ENONET; - MAPF_ERR("socket " << socket << " not added, skipping..."); - return -1; - } - - return 0; -} - -int Poller::Remove(int fd) -{ - errno = 0; - auto it = items_->Find(fd); - if (it != items_->items_.end()) { - it = items_->items_.erase(it); - return 0; - } else { - errno = ENONET; - MAPF_ERR("fd " << fd << " not added, skipping..."); - } - - return 0; -} - -int Poller::Poll(long timeout) -{ - int result = 0; - if (items_->items_.empty()) - return 0; - errno = 0; - result += zmq_poll(items_->items_.data(), items_->items_.size(), timeout); - - return result; -} - -short Poller::CheckEvent(const Socket &socket) -{ - errno = 0; - auto it = items_->Find(&socket); - if (it != items_->items_.end()) - return (*it).revents; - - MAPF_ERR("socket " << socket << " not added, skipping..."); - errno = ENOENT; - return -1; -} - -short Poller::CheckEvent(int fd) -{ - auto it = items_->Find(fd); - if (it != items_->items_.end()) - return (*it).revents; - - MAPF_ERR("fd " << fd << " not added, skipping..."); - errno = ENOENT; - return -1; -} - -void Poller::PrintItems() const -{ - MAPF_INFO("Poll Items:"); - for (auto item : items_->items_) - MAPF_INFO("socket. fd:" << item.fd << ", events: " << item.events - << ", revents: " << item.revents); -} - -} /* namespace mapf */ diff --git a/framework/common/zmq/socket.cpp b/framework/common/zmq/socket.cpp deleted file mode 100644 index 47ddab00f1..0000000000 --- a/framework/common/zmq/socket.cpp +++ /dev/null @@ -1,358 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include "msglib.h" -#include -#include -#include -#include -#include -#include -#include -#include - -//#define MAPF_DEBUG -#ifdef MAPF_DEBUG -#define DBG MAPF_DBG -#else -#define DBG(...) -#endif - -namespace mapf { - -/* Socket API */ -Socket::Socket() : sock(new msglib_socket) {} - -Socket::~Socket() -{ - Close(); - delete sock; -} - -bool Socket::SyncRequired() { return true; } - -int Socket::Connect(const std::string &addr, int max_retries) -{ - mapf_assert(!addr.empty()); - int rc, retries = 0; - do { - rc = zmq_connect(sock->sd_, addr.c_str()); - if (rc == 0) - break; - MAPF_DBG("zmq_connect failed: " << strerror(zmq_errno()) << " retry #" << retries); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } while (max_retries < 0 || retries++ < max_retries); - - MAPF_ERR_IF(rc, "nng_dial failed"); - return rc; -} - -void Socket::Close() -{ - if (sock->sd_ == nullptr) - return; // already closed - int rc = zmq_close(sock->sd_); - errno_assert(rc == 0); - sock->sd_ = nullptr; -} - -int Socket::fd() const -{ -#if 0 - int fd = -1; - size_t sz = sizeof(fd); - int rc = zmq_getsockopt(sock->sd_, ZMQ_FD, &fd, &sz); - MAPF_ERR_IF(rc, "Can't get fd for socket. errno=" << strerror(zmq_errno())); - - return fd; -#endif - mapf_assert(0); //Not supported -} - -/* PUB socket API */ -PubSocket::PubSocket(Context &ctx) -{ - sock->sd_ = zmq_socket(ctx.get(), ZMQ_PUB); - mapf_assert(sock->sd_); -} - -std::ostream &PubSocket::Print(std::ostream &s) const -{ - s << "PUB socket" << std::endl; - return s; -} - -size_t PubSocket::Send(void *buf, size_t len, int flags) -{ - int nbytes = zmq_send(sock->sd_, buf, len, flags); - if (nbytes >= 0) { - if (nbytes != int(len)) - errno = EIO; - return (size_t)nbytes; - } - if (zmq_errno() == EAGAIN) - return 0; - return -1; -} - -bool PubSocket::Send(const Message &msg, int flags) -{ - mapf_assert(msg.version() == Message::kMessageHeaderVersion); - mapf_assert(msg.len() <= Message::kMaxFrameLength); - - size_t nframes = msg.frames().size(); - - // first, send the topic - flags |= ZMQ_SNDMORE; - DBG("sending topic=" << msg.topic() << " flags=" << flags); - size_t nbytes = Send(const_cast(msg.topic().data()), msg.topic().length(), flags); - //size_t nbytes = Send(msg.topic().data(), msg.topic().length(), flags); - if (nbytes != msg.topic().length()) { - MAPF_ERR("topic send failed, errno=" << strerror(errno)); - return false; - } - - // next send the header - Message::Header hdr = msg.header(); - flags = (nframes) ? flags | ZMQ_SNDMORE : flags & ~ZMQ_SNDMORE; - DBG("sending header len=" << msg.len() << " flags=" << flags); - nbytes = Send(&hdr, sizeof(hdr), flags); - if (nbytes != sizeof(hdr)) { - MAPF_ERR("header send failed, errno=" << strerror(errno)); - return false; - } - - // Finally, Send all data frames - for (auto frame : msg.frames()) { - flags = (--nframes) ? flags | ZMQ_SNDMORE : flags & ~ZMQ_SNDMORE; - nbytes = Send(frame.data(), frame.len(), flags); - if (nbytes != frame.len()) { - MAPF_ERR("message send failed, errno=" << strerror(errno)); - return false; - } - } - - DBG("message sent"); - return true; -} - -bool PubSocket::Send(const std::unique_ptr &msg, int flags) -{ - mapf_assert(msg); - return Send(*msg, flags); -} - -/* SUB socket API */ -SubSocket::SubSocket(Context &ctx) -{ - sock->sd_ = zmq_socket(ctx.get(), ZMQ_SUB); - mapf_assert(sock->sd_); -} - -std::ostream &SubSocket::Print(std::ostream &s) const -{ - s << "SUB socket. topics:"; - for (const auto &topic : topics_) { - s << std::endl << topic; - } - - return s; -} - -int SubSocket::Subscribe(const std::string &topic) -{ - errno = 0; - int rc = zmq_setsockopt(sock->sd_, ZMQ_SUBSCRIBE, topic.c_str(), topic.length()); - if (rc) { - MAPF_ERR("Subscribe " << topic << "failed, errno=" << strerror(errno)); - return rc; - } - - AddSubscription(topic); - return 0; -} - -int SubSocket::Subscribe(const std::initializer_list &topics) -{ - for (auto &topic : topics) { - Subscribe(topic); - } - return 0; -} - -int SubSocket::Unsubscribe(const std::string &topic) -{ - if (topic.empty()) - return 0; - int rc = zmq_setsockopt(sock->sd_, ZMQ_UNSUBSCRIBE, topic.c_str(), topic.length()); - if (rc == 0) - EraseSubscription(topic); - return rc; -} - -int SubSocket::Unsubscribe(std::initializer_list topics) -{ - for (auto &topic : topics) - Unsubscribe(topic); - - return 0; -} - -ssize_t SubSocket::Receive(void *buf, size_t len, int flags) -{ - int nbytes = zmq_recv(sock->sd_, buf, len, flags); - if (nbytes >= 0) - return (size_t)nbytes; - if (zmq_errno() == EAGAIN) - return 0; - - return -1; -} - -bool SubSocket::Receive(Message::Frame &frame, int flags) -{ - int nbytes = Receive(frame.data(), frame.len(), flags); - if (nbytes == -1) { - MAPF_ERR("zmq_recv failed with error " << strerror(errno)); - return false; - } - - return true; -} - -bool SubSocket::Receive(Message &msg, int flags) -{ - msg.Clear(); - - /** first, receive the topic */ - auto topic = ReceiveTopic(flags); - if (topic == nullptr) - return false; - msg.set_topic(*topic); - - if (false == More()) - return true; // message with topic only, allowed - - /** next, receive the header */ - auto hdr = ReceiveHeader(flags); - if (hdr == nullptr) - return false; - - if (false == More()) { - mapf_assert(hdr->len == 0); - DBG("message with topic only received"); - return true; // message with header only, allowed - } - - /** finally, receive all the rest of the message parts to a - * single frame */ - Message::Frame frame = ReceiveFrames(hdr->len, flags); - msg.Add(frame); - - DBG("message received"); - return true; -} - -std::unique_ptr SubSocket::Receive(int flags) -{ - /** first, receive the topic */ - auto topic = ReceiveTopic(flags); - if (topic == nullptr) - return nullptr; - - /** next, receive the header */ - auto hdr = ReceiveHeader(flags); - if (hdr == nullptr) - return nullptr; - - if (false == More()) { - mapf_assert(hdr->len == 0); - DBG("message with topic only received"); - return MessageFactory::Instance().Create(*topic); // message with header only, allowed - } - - /** finally, receive all the rest of the message parts to a - * single frame */ - Message::Frame frame = ReceiveFrames(hdr->len, flags); - DBG("message received"); - return MessageFactory::Instance().Create(*topic, {frame}); -} - -/* SUB Socket Private */ -std::unique_ptr SubSocket::ReceiveTopic(int flags) -{ - char topic[Message::kMaxTopicSize]; - int nbytes = Receive(topic, sizeof(topic) - 1, flags); - if (nbytes == -1) { - MAPF_ERR("topic receive failed, errno=" << strerror(errno)); - return nullptr; - } - topic[nbytes] = 0; - DBG("received topic=" << topic); - return std::unique_ptr(new std::string(topic)); -} - -std::unique_ptr SubSocket::ReceiveHeader(int flags) -{ - Message::Header hdr; - ssize_t nbytes = Receive(&hdr, sizeof(hdr), flags); - if (nbytes == -1) { - MAPF_ERR("header receive failed, errno=" << strerror(errno)); - return nullptr; - } - DBG("received header len=" << hdr.len << " more=" << More()); - // we do not support different header versions YET - mapf_assert(hdr.version == Message::kMessageHeaderVersion); - mapf_assert(hdr.len <= Message::kMaxFrameLength); - return std::unique_ptr(new Message::Header(hdr)); -} - -Message::Frame SubSocket::ReceiveFrames(size_t total_len, int flags) -{ - Message::Frame frame(total_len); - uint8_t *ptr = frame.data(); - size_t len = 0; - do { - len += Receive(ptr + len, total_len - len, flags); - mapf_assert(len <= total_len); //total length mismatch! - } while (More()); - - mapf_assert(len == total_len); - return frame; // allowed since Message::Frame contains a shared pointer -} - -bool SubSocket::More() const -{ - int more; - size_t len = sizeof(more); - int rc = zmq_getsockopt(sock->sd_, ZMQ_RCVMORE, &more, &len); - errno_assert(rc == 0); - return more; -} - -std::vector::iterator SubSocket::FindSubscription(const std::string &topic) -{ - return std::find_if(topics_.begin(), topics_.end(), - [&topic](const std::string &item) { return item == topic; }); -} - -void SubSocket::AddSubscription(const std::string &topic) -{ - auto it = FindSubscription(topic); - if (it == topics_.end()) - topics_.push_back(topic); -} - -void SubSocket::EraseSubscription(const std::string &topic) -{ - auto it = FindSubscription(topic); - if (it != topics_.end()) - it = topics_.erase(it); -} - -} // namespace mapf diff --git a/framework/common/zmq/version.cpp b/framework/common/zmq/version.cpp deleted file mode 100644 index 8beff9d3fa..0000000000 --- a/framework/common/zmq/version.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include -#include -#include - -int main(void) -{ - int major, minor, patch; - zmq_version(&major, &minor, &patch); - printf("Current 0MQ version is %d.%d.%d\n", major, minor, patch); - printf("Current MAPF version is %s\n", MAPF_VERSION); - return 0; -} From 15c2faffabedfca36010a946f940384052e4faa0 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 16:57:29 +0000 Subject: [PATCH 158/453] framework: cmake: adjust to new broker Remove MSGLIB references. Add the new broker files. Disable common tests (until adjusted to the new broker). Signed-off-by: Vitaly Bukhovsky --- framework/CMakeLists.txt | 5 --- framework/common/CMakeLists.txt | 35 ++----------------- framework/common/test/CMakeLists.txt | 25 +++++-------- .../ieee1905_transport/CMakeLists.txt | 15 ++++++-- 4 files changed, 24 insertions(+), 56 deletions(-) diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt index 17f6bb53b5..d954239aa9 100644 --- a/framework/CMakeLists.txt +++ b/framework/CMakeLists.txt @@ -1,17 +1,12 @@ project(multiap_framework C CXX) -set(MSGLIB "zmq" CACHE STRING "Which messaging library backend to use") -set_property(CACHE MSGLIB PROPERTY STRINGS "zmq" "nng" "None") - find_package(json-c REQUIRED) add_subdirectory(platform) add_subdirectory(external) add_subdirectory(tlvf) add_subdirectory(common) -if (NOT MSGLIB STREQUAL "None") add_subdirectory(transport) -endif() add_dependencies(mapfcommon elpp) add_dependencies(tlvf elpp) diff --git a/framework/common/CMakeLists.txt b/framework/common/CMakeLists.txt index cf46196b64..37dfe0703c 100644 --- a/framework/common/CMakeLists.txt +++ b/framework/common/CMakeLists.txt @@ -6,35 +6,8 @@ configure_file( install(FILES "${CMAKE_CURRENT_BINARY_DIR}/logging.conf" DESTINATION share) file(COPY "${CMAKE_CURRENT_BINARY_DIR}/logging.conf" DESTINATION "${CMAKE_MULTIAP_OUTPUT_DIRECTORY}/share/") -# Messaging -if(MSGLIB STREQUAL "None") - -message(STATUS "${BoldYellow}Messaging library - None${ColourReset}") -set(sources logger.cpp encryption.cpp utils.cpp) - -else() - -message(STATUS "${BoldGreen}Messaging library - ${MSGLIB}${ColourReset}") -find_package(${MSGLIB} REQUIRED) -set(MSGLIB_TARGET ${MSGLIB}::${MSGLIB}) -set(sources logger.cpp encryption.cpp utils.cpp message_factory.cpp broker_config.cpp broker_interface.cpp ${MSGLIB}/broker.cpp ${MSGLIB}/socket.cpp ${MSGLIB}/context.cpp ${MSGLIB}/poller.cpp ) - -add_executable(version ${MSGLIB}/version.cpp) -target_link_libraries(version mapfcommon elpp ${MSGLIB_TARGET}) - -add_executable(local_bus local_bus.cpp) -target_link_libraries(local_bus PRIVATE mapfcommon elpp json-c) - -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/local_bus.conf.in" - "${CMAKE_CURRENT_BINARY_DIR}/local_bus.conf" - ) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/local_bus.conf" DESTINATION share) -file(COPY "${CMAKE_CURRENT_BINARY_DIR}/local_bus.conf" DESTINATION "${CMAKE_MULTIAP_OUTPUT_DIRECTORY}/share") -install(TARGETS version DESTINATION bin) -install(TARGETS local_bus DESTINATION bin) - -endif() +# mapfcommon sources +set(sources message.cpp logger.cpp encryption.cpp utils.cpp) # We use OpenSSL 1.1.x for Encryption find_package(OpenSSL 1.1 QUIET) @@ -49,7 +22,6 @@ add_library(mapfcommon ${sources}) set_target_properties(mapfcommon PROPERTIES VERSION ${prplmesh_VERSION} SOVERSION ${prplmesh_VERSION_MAJOR}) target_link_libraries(mapfcommon PRIVATE - ${MSGLIB_TARGET} elpp json-c PUBLIC @@ -70,7 +42,6 @@ target_include_directories(mapfcommon PUBLIC $ $ - $ PRIVATE $ ) @@ -81,4 +52,4 @@ install(TARGETS mapfcommon EXPORT mapfCommon RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(EXPORT mapfCommon NAMESPACE mapf:: DESTINATION lib/cmake/mapfCommon) -add_subdirectory(test) +# add_subdirectory(test) diff --git a/framework/common/test/CMakeLists.txt b/framework/common/test/CMakeLists.txt index 9b94507553..961fbe8fb4 100644 --- a/framework/common/test/CMakeLists.txt +++ b/framework/common/test/CMakeLists.txt @@ -1,18 +1,11 @@ if(BUILD_TESTS) - if(MSGLIB STREQUAL "None") - add_executable(encryption_test encryption_test.cpp) - target_link_libraries(encryption_test mapfcommon elpp) - install(TARGETS encryption_test DESTINATION bin/tests/common) - add_test(NAME encryption_test COMMAND $) - else() - add_subdirectory(messages) - file(GLOB tests *_test.cpp) - foreach(test ${tests}) - get_filename_component(target ${test} NAME_WE) - add_executable(${target} ${test}) - target_link_libraries(${target} mapfcommon dummy_messages elpp) - install(TARGETS ${target} DESTINATION bin/tests/common) - add_test(NAME ${target} COMMAND $) - endforeach(test ${tests}) - endif() + add_subdirectory(messages) + file(GLOB tests *_test.cpp) + foreach(test ${tests}) + get_filename_component(target ${test} NAME_WE) + add_executable(${target} ${test}) + target_link_libraries(${target} mapfcommon dummy_messages elpp) + install(TARGETS ${target} DESTINATION bin/tests/common) + add_test(NAME ${target} COMMAND $) + endforeach(test ${tests}) endif() diff --git a/framework/transport/ieee1905_transport/CMakeLists.txt b/framework/transport/ieee1905_transport/CMakeLists.txt index d547f52ac0..89ff9eb7cf 100644 --- a/framework/transport/ieee1905_transport/CMakeLists.txt +++ b/framework/transport/ieee1905_transport/CMakeLists.txt @@ -1,11 +1,20 @@ -add_library(ieee1905_transport_lib ieee1905_transport.cpp ieee1905_transport_network.cpp ieee1905_transport_netlink.cpp ieee1905_transport_local_bus.cpp ieee1905_transport_packet_processing.cpp) +add_library(ieee1905_transport_lib + ieee1905_transport.cpp + ieee1905_transport_broker.cpp + ieee1905_transport_network.cpp + ieee1905_transport_netlink.cpp + ieee1905_transport_local_bus.cpp + ieee1905_transport_packet_processing.cpp) + set_target_properties(ieee1905_transport_lib PROPERTIES VERSION ${prplmesh_VERSION} SOVERSION ${prplmesh_VERSION_MAJOR}) -target_link_libraries(ieee1905_transport_lib PUBLIC tlvf ieee1905_transport_messages mapfcommon PRIVATE elpp) +target_link_libraries(ieee1905_transport_lib + PUBLIC bcl tlvf btlvf ieee1905_transport_messages mapfcommon + PRIVATE elpp) target_include_directories(ieee1905_transport_lib PUBLIC include/) add_library(ieee1905_transport_messages ieee1905_transport_messages.cpp) set_target_properties(ieee1905_transport_messages PROPERTIES VERSION ${prplmesh_VERSION} SOVERSION ${prplmesh_VERSION_MAJOR}) -target_link_libraries(ieee1905_transport_messages PUBLIC mapfcommon PRIVATE elpp) +target_link_libraries(ieee1905_transport_messages PUBLIC mapfcommon bcl PRIVATE elpp) target_include_directories(ieee1905_transport_messages PUBLIC $ ) From ea6bebc4d9b757078ffa2fd3c4ddbacda0f084cf Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 16:51:48 +0000 Subject: [PATCH 159/453] framework: tlvf: prevent double swap Prevent double swapping on CMDU header getters/setters. Fixes a transport logging issue. Signed-off-by: Vitaly Bukhovsky --- framework/tlvf/src/src/CmduMessage.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/tlvf/src/src/CmduMessage.cpp b/framework/tlvf/src/src/CmduMessage.cpp index 7fc59e5d03..d432cd0f56 100644 --- a/framework/tlvf/src/src/CmduMessage.cpp +++ b/framework/tlvf/src/src/CmduMessage.cpp @@ -15,7 +15,7 @@ eMessageType CmduMessage::getMessageType() uint16_t msgValue = 0; auto cmduhdr = getCmduHeader(); msgValue = (uint16_t)cmduhdr->message_type(); - if (cmduhdr->is_finalized()) + if (cmduhdr->is_finalized() || is_swapped()) swap_16(msgValue); return (eMessageType)msgValue; @@ -26,7 +26,7 @@ uint16_t CmduMessage::getMessageId() auto cmduhdr = getCmduHeader(); uint16_t mid = cmduhdr->message_id(); - if (cmduhdr->is_finalized()) + if (cmduhdr->is_finalized() || is_swapped()) swap_16(mid); return mid; @@ -36,7 +36,7 @@ void CmduMessage::setMessageId(uint16_t mid) { auto cmduhdr = getCmduHeader(); - if (cmduhdr->is_finalized()) + if (cmduhdr->is_finalized() || is_swapped()) swap_16(mid); cmduhdr->message_id() = mid; } From 8144a44c864187c4bfefc1e2e462ee6d8507c7ea Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 16:59:36 +0000 Subject: [PATCH 160/453] btl: add a new broker implementation This implementation is somewhat based on the existing bus/uds versions with adjustments for the new broker. Signed-off-by: Vitaly Bukhovsky --- common/beerocks/btl/btl_broker.cpp | 300 ++++++++++++++++++++++++++ common/beerocks/btl/include/btl/btl.h | 12 +- 2 files changed, 301 insertions(+), 11 deletions(-) create mode 100644 common/beerocks/btl/btl_broker.cpp diff --git a/common/beerocks/btl/btl_broker.cpp b/common/beerocks/btl/btl_broker.cpp new file mode 100644 index 0000000000..540237fabf --- /dev/null +++ b/common/beerocks/btl/btl_broker.cpp @@ -0,0 +1,300 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include +#include +#include +#include + +#include +#include + +#include + +#include + +using namespace beerocks::btl; +using namespace beerocks::net; +using namespace beerocks::transport::messages; + +bool transport_socket_thread::bus_init() +{ + if (bus) { + remove_socket(bus.get()); + bus->closeSocket(); + bus.reset(nullptr); + } + + auto unix_socket_path_broker = TMP_PATH "/" BEEROCKS_BROKER_UDS; + + bus = std::make_unique(unix_socket_path_broker); + if (!bus) { + LOG(ERROR) << "bus == nullptr"; + return false; + } else if (!bus->getError().empty()) { + LOG(ERROR) << "Failed connecting to the broker, error:" << bus->getError(); + return false; + } + + LOG(DEBUG) << "Broker socket connected on: " << unix_socket_path_broker; + add_socket(bus.get(), false); + return true; +} + +bool transport_socket_thread::configure_ieee1905_transport_interfaces( + const std::string &bridge_iface, const std::vector &ifaces) +{ + LOG_IF(!bus, FATAL) << "Broker socket is not connected!"; + + InterfaceConfigurationRequestMessage interface_configuration_request_msg; + using Flags = InterfaceConfigurationRequestMessage::Flags; + + uint32_t n = 0; + string_utils::copy_string(interface_configuration_request_msg.metadata()->interfaces[n].ifname, + bridge_iface.c_str(), IF_NAMESIZE); + + interface_configuration_request_msg.metadata()->interfaces[n].flags |= Flags::IS_BRIDGE; + n++; + THREAD_LOG(DEBUG) << "adding bridge " << bridge_iface + << " to ieee1905 transport, bridge iface=" << bridge_iface; + for (const auto &iface : ifaces) { + string_utils::copy_string( + interface_configuration_request_msg.metadata()->interfaces[n].ifname, iface.c_str(), + IF_NAMESIZE); + string_utils::copy_string( + interface_configuration_request_msg.metadata()->interfaces[n].bridge_ifname, + bridge_iface.c_str(), IF_NAMESIZE); + interface_configuration_request_msg.metadata()->interfaces[n].flags |= + Flags::ENABLE_IEEE1905_TRANSPORT; + n++; + THREAD_LOG(DEBUG) << "adding interface " << iface << " to ieee1905 transport" + << " bridge=" << bridge_iface; + } + interface_configuration_request_msg.metadata()->numInterfaces = n; + THREAD_LOG(DEBUG) << "numInterfaces=" << n; + + return transport::messages::send_transport_message(*bus, interface_configuration_request_msg); +} + +void transport_socket_thread::add_socket(Socket *s, bool add_to_vector) +{ + socket_thread::add_socket(s, add_to_vector); +} + +void transport_socket_thread::remove_socket(Socket *s) { socket_thread::remove_socket(s); } + +bool transport_socket_thread::read_ready(Socket *s) { return socket_thread::read_ready(s); } + +bool transport_socket_thread::bus_subscribe(const std::vector &msg_types) +{ + LOG_IF(!bus, FATAL) << "Broker socket not initialized!"; + + if (msg_types.size() > SubscribeMessage::MAX_SUBSCRIBE_TYPES) { + LOG(ERROR) << "Subscribing to " << msg_types.size() + << " is not supported. Maximal allowed types: " + << SubscribeMessage::MAX_SUBSCRIBE_TYPES; + + return false; + } + + // Build a subscription message + SubscribeMessage subscribe; + subscribe.metadata()->type = SubscribeMessage::ReqType::SUBSCRIBE; + + subscribe.metadata()->msg_types_num = 0; + for (const auto &msg_type : msg_types) { + subscribe.metadata()->msg_types[subscribe.metadata()->msg_types_num].bits = { + .internal = 0, .vendor_specific = 0, .reserved = 0, .type = uint32_t(msg_type)}; + + ++subscribe.metadata()->msg_types_num; + } + + return transport::messages::send_transport_message(*bus, subscribe); +} + +bool transport_socket_thread::bus_connect(const std::string &beerocks_temp_path, + const bool local_master) +{ + return true; +} + +bool transport_socket_thread::bus_send(ieee1905_1::CmduMessage &cmdu, const std::string &iface_name, + const std::string &dst_mac, const std::string &src_mac, + uint16_t length) +{ + LOG_IF(!bus, FATAL) << "Broker socket not initialized!"; + + CmduTxMessage msg; + + tlvf::mac_from_string(msg.metadata()->src, src_mac); + tlvf::mac_from_string(msg.metadata()->dst, dst_mac); + + // LOG(DEBUG) << "Message Type: " << std::hex << uint16_t(cmdu.getMessageType()) << std::dec + // << ", Finalized: " << cmdu.is_finalized() << ", Swapped: " << cmdu.is_swapped(); + + msg.metadata()->ether_type = ETH_P_1905_1; + msg.metadata()->length = length; + msg.metadata()->msg_type = uint16_t(cmdu.getMessageType()); + msg.metadata()->preset_message_id = cmdu.getMessageId() ? 1 : 0; + msg.metadata()->if_index = if_nametoindex(iface_name.c_str()); + + std::copy_n((uint8_t *)cmdu.getMessageBuff(), msg.metadata()->length, (uint8_t *)msg.data()); + return transport::messages::send_transport_message(*bus, msg); +} + +bool transport_socket_thread::handle_cmdu_message_bus() +{ + auto msg = transport::messages::read_transport_message(*bus); + if (msg == nullptr) { + THREAD_LOG(ERROR) << "Received msg is null"; + return false; + } + + auto cmdu_rx_msg = dynamic_cast(msg.get()); + if (cmdu_rx_msg) { + } else { + THREAD_LOG(ERROR) << "Received non CmduRxMessage:\n\tMessage: " << *msg + << "\n\tFrame: " << msg->frame().str(); + return false; + } + + // Copy the data to rx_buffer + if (sizeof(message::sUdsHeader) + cmdu_rx_msg->metadata()->length > sizeof(rx_buffer)) { + THREAD_LOG(ERROR) + << "sizeof(message::sUdsHeader) + cmdu_rx_msg->metadata()->length > sizeof(rx_buffer)"; + return false; + } + + std::copy_n((uint8_t *)cmdu_rx_msg->data(), cmdu_rx_msg->metadata()->length, + rx_buffer + sizeof(message::sUdsHeader)); + + // fill UDS Header + message::sUdsHeader *uds_header = (message::sUdsHeader *)rx_buffer; + uds_header->if_index = cmdu_rx_msg->metadata()->if_index; + std::copy_n((uint8_t *)cmdu_rx_msg->metadata()->src, sizeof(CmduRxMessage::Metadata::src), + uds_header->src_bridge_mac); + std::copy_n((uint8_t *)cmdu_rx_msg->metadata()->dst, sizeof(CmduRxMessage::Metadata::dst), + uds_header->dst_bridge_mac); + uds_header->length = cmdu_rx_msg->metadata()->length; + + if (!verify_cmdu(uds_header)) { + THREAD_LOG(ERROR) << "Failed verifying cmdu header"; + return false; + } + + if (!cmdu_rx.parse()) { + THREAD_LOG(ERROR) << "parsing cmdu failure, rx_buffer" << std::hex << rx_buffer << std::dec + << ", uds_header->length=" << int(uds_header->length); + return false; + } + + if (!handle_cmdu(bus.get(), cmdu_rx)) { + return false; + } + + return true; +} + +bool transport_socket_thread::from_bus(Socket *sd) +{ + if (!sd || !bus) { + return false; + } + + return sd->getSocketFd() == bus->getSocketFd(); +} + +bool transport_socket_thread::work() +{ + before_select(); + + int sel_ret = select.selectSocket(); + if (sel_ret < 0) { + // Do not fail for the following "errors" + if (errno == EAGAIN || errno == EINTR) { + THREAD_LOG(DEBUG) << "Select returned: " << strerror(errno); + return true; + } + + THREAD_LOG(ERROR) << "select error: " << strerror(errno); + return false; + } + + after_select(bool(sel_ret == 0)); + + if (sel_ret == 0) { + return true; + } + + // If something happened on the server socket (UDS), then its an incoming connection + if (server_socket && read_ready(server_socket.get())) { + clear_ready(server_socket.get()); + THREAD_LOG(DEBUG) << "accept new connection on server socket sd=" << server_socket.get(); + Socket *sd = server_socket->acceptConnections(); + if (sd == nullptr || (!server_socket->getError().empty())) { + THREAD_LOG(ERROR) << "acceptConnections == nullptr: " << server_socket->getError(); + return false; + } else { + if (unix_socket_path.empty()) { + THREAD_LOG(DEBUG) << "new connection from ip=" << sd->getPeerIP() + << " port=" << sd->getPeerPort() << " sd=" << sd; + } else { + THREAD_LOG(DEBUG) << "new connection on " << unix_socket_path << " sd=" << sd; + } + socket_connected(sd); + } + } + + int sockets_count; + int i = 0; + do { + sockets_count = select.count(); + for (i = 0; i < sockets_count; i++) { + if (read_ready(select.at(i))) { + Socket *sd = select.at(i); + if (!sd) { + THREAD_LOG(WARNING) + << "sd at select with index i=" << int(i) << " is nullptr, skipping"; + continue; + } + + bool bus_socket_event = bus && (bus->getSocketFd() == sd->getSocketFd()); + + // '0' - socket not disconnected (bytes to read), '1' - socket disconnected, '-1' - error + auto ret = socket_disconnected_uds(sd); + if (ret == 1) { + if (bus_socket_event) { + THREAD_LOG(FATAL) << "setting bus to nullptr"; + bus = nullptr; + } + // breaking instead of continue because socket_disconnected_uds() may erase element from Select Socket Vector while iterating it + break; + } else if (ret == -1) { + continue; + } + + // LOG(DEBUG) << "Received message on FD: " << sd->getSocketFd() + // << " (bus_socket_event = " << bus_socket_event << ")"; + + if (bus_socket_event) { + if (!handle_cmdu_message_bus()) { + continue; + } + } else { + if (!handle_cmdu_message_uds(sd)) { + continue; + } + } + } + } + // The loop should go over all the sockets. In case something break the for loop before it ended, + // start iterating over the sockets again. + } while (i < sockets_count); + + return true; +} diff --git a/common/beerocks/btl/include/btl/btl.h b/common/beerocks/btl/include/btl/btl.h index 6fcb9ed484..28fd5b7109 100644 --- a/common/beerocks/btl/include/btl/btl.h +++ b/common/beerocks/btl/include/btl/btl.h @@ -58,7 +58,6 @@ class transport_socket_thread : public socket_thread { bool bus_subscribe(const std::vector &msg_types); bool bus_connect(const std::string &beerocks_temp_path, const bool local_master); - void bus_connected(Socket *sd); /** * @brief Sends CDMU to transport for dispatching. @@ -83,16 +82,7 @@ class transport_socket_thread : public socket_thread { int poll_timeout_ms = 500; -#ifdef UDS_BUS - bool skip_filtered_message_type(Socket *sd, ieee1905_1::eMessageType msg_type) override; - - Socket *bus = nullptr; - std::unique_ptr bus_server_socket; - std::unordered_set m_subscribed_messages; -#else - std::shared_ptr bus = nullptr; - std::shared_ptr poller = nullptr; -#endif + std::unique_ptr bus; }; } // namespace btl From 59b8dd5a8604a8f17c05178e5d6f7315500765e4 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 17:00:47 +0000 Subject: [PATCH 161/453] btl: remove old implementations and cleanup cmake Signed-off-by: Vitaly Bukhovsky --- common/beerocks/btl/CMakeLists.txt | 19 +- common/beerocks/btl/btl_local_bus.cpp | 328 -------------------------- common/beerocks/btl/btl_uds.cpp | 237 ------------------- 3 files changed, 2 insertions(+), 582 deletions(-) delete mode 100644 common/beerocks/btl/btl_local_bus.cpp delete mode 100644 common/beerocks/btl/btl_uds.cpp diff --git a/common/beerocks/btl/CMakeLists.txt b/common/beerocks/btl/CMakeLists.txt index b89452ab77..ed1c84b1ff 100644 --- a/common/beerocks/btl/CMakeLists.txt +++ b/common/beerocks/btl/CMakeLists.txt @@ -1,16 +1,8 @@ project(btl VERSION ${prplmesh_VERSION}) message("${BoldWhite}Preparing ${BoldGreen}${PROJECT_NAME}${BoldWhite} for the ${BoldGreen}${TARGET_PLATFORM}${BoldWhite} platform${ColourReset}") -if (NOT MSGLIB STREQUAL "None") message(STATUS "${BoldGreen}Using MultiAP Framework for BTL transport${ColourReset}") -set(BTL_TYPE "LOCAL_BUS" PARENT_SCOPE) -set(btl_sources btl.cpp btl_local_bus.cpp) -else() -message(STATUS "${BoldYellow}Failed to find MultiAP Framework transport, fall back to BTL over UDS - supporting single node only!${ColourReset}") -set(BTL_TYPE "UDS" PARENT_SCOPE) -add_definitions(-DUDS_BUS) -set(btl_sources btl.cpp btl_uds.cpp) -endif() +set(btl_sources btl.cpp btl_broker.cpp) # Set the base path for the current module set(MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) @@ -18,14 +10,7 @@ set(MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) # Build the library add_library(${PROJECT_NAME} ${btl_sources}) set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${prplmesh_VERSION} SOVERSION ${prplmesh_VERSION_MAJOR}) -target_link_libraries(${PROJECT_NAME} PUBLIC bcl tlvf elpp btlvf mapfcommon) -if (NOT MSGLIB STREQUAL "None") - target_link_libraries(${PROJECT_NAME} PRIVATE ieee1905_transport_messages) -else() - # Export the UDS_BUS definition publicly to any target that - # may include the header - target_compile_definitions(${PROJECT_NAME} PUBLIC UDS_BUS) -endif() +target_link_libraries(${PROJECT_NAME} PRIVATE ieee1905_transport_messages PUBLIC bcl tlvf elpp btlvf mapfcommon) # Include paths target_include_directories(${PROJECT_NAME} PUBLIC $) diff --git a/common/beerocks/btl/btl_local_bus.cpp b/common/beerocks/btl/btl_local_bus.cpp deleted file mode 100644 index 5a3e7bb33c..0000000000 --- a/common/beerocks/btl/btl_local_bus.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include -#include -#include -#include -#include -#include - -using namespace beerocks::btl; -using namespace beerocks::net; - -////////////////////////////////////////////////////////////////////////////// -/////////////////////////// Local Module Functions /////////////////////////// -////////////////////////////////////////////////////////////////////////////// -static bool local_bus_read_ready(std::shared_ptr bus, - std::shared_ptr poller) -{ - LOG_IF(!poller, FATAL) << "Poller is not allocated!"; - - int rc = poller->CheckEvent(bus->subscriber()); - if (rc & MAPF_POLLIN) { - return true; - } else if (rc & MAPF_POLLERR) { - return false; - } else if (rc == 0) { - return false; - } - - LOG(ERROR) << "check event error on local bus sub socket, rc=" << rc; - return false; -} - -static bool subscribe_topic_to_bus(std::shared_ptr bus, - const ieee1905_1::eMessageType msg_type) -{ - LOG(INFO) << "subscribing topic=" << (int)msg_type; - int rc = bus->subscriber().Subscribe( - mapf::CmduRxMessage::ieee1905_topic((uint16_t)msg_type)); - if (rc) { - LOG(ERROR) << "Subscribe error rc=" << rc << ", on topic=" << (int)msg_type; - return false; - } - return true; -} - -////////////////////////////////////////////////////////////////////////////// -/////////////////////////// Implementation /////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -bool transport_socket_thread::bus_init() -{ - bus = std::make_shared(mapf::Context::Instance()); - if (!bus) { - LOG(FATAL) << "Failed allocating bus!"; - return false; - } - - poller = std::make_shared(); - if (!poller) { - LOG(FATAL) << "Failed allocating Poller!"; - return false; - } - - return true; -} - -bool transport_socket_thread::bus_subscribe(const std::vector &msg_types) -{ - LOG_IF(!bus, FATAL) << "Bus is not allocated!"; - LOG_IF(!poller, FATAL) << "Poller is not allocaed!"; - bus->Init(); - for (const auto &msg_type : msg_types) { - if (!subscribe_topic_to_bus(bus, msg_type)) { - LOG(ERROR) << "failed to subscribe msg_type=" << std::hex << int(msg_type) << std::dec; - return false; - } - } - - LOG(ERROR) << "Adding bus to poller"; - auto rc = poller->Add(bus->subscriber()); - if (rc && errno != EEXIST) { - LOG(ERROR) << "Add to poller error rc=" << rc; - return false; - } else if (errno == EEXIST) { - LOG(DEBUG) << "Adding subscriber already exist"; - } - - return true; -} - -bool transport_socket_thread::bus_connect(const std::string &beerocks_temp_path, - const bool local_master) -{ - return true; -} - -void transport_socket_thread::bus_connected(Socket *sd) {} - -bool transport_socket_thread::configure_ieee1905_transport_interfaces( - const std::string &bridge_iface, const std::vector &ifaces) -{ - LOG_IF(!bus, FATAL) << "Bus is not allocated!"; - - mapf::InterfaceConfigurationRequestMessage interface_configuration_request_msg; - using Flags = mapf::InterfaceConfigurationRequestMessage::Flags; - - uint32_t n = 0; - string_utils::copy_string(interface_configuration_request_msg.metadata()->interfaces[n].ifname, - bridge_iface.c_str(), IF_NAMESIZE); - interface_configuration_request_msg.metadata()->interfaces[n].flags |= Flags::IS_BRIDGE; - n++; - THREAD_LOG(DEBUG) << "adding bridge " << bridge_iface - << " to ieee1905 transport, bridge iface=" << bridge_iface; - for (const auto &iface : ifaces) { - string_utils::copy_string( - interface_configuration_request_msg.metadata()->interfaces[n].ifname, iface.c_str(), - IF_NAMESIZE); - string_utils::copy_string( - interface_configuration_request_msg.metadata()->interfaces[n].bridge_ifname, - bridge_iface.c_str(), IF_NAMESIZE); - interface_configuration_request_msg.metadata()->interfaces[n].flags |= - Flags::ENABLE_IEEE1905_TRANSPORT; - n++; - THREAD_LOG(DEBUG) << "adding interface " << iface << " to ieee1905 transport" - << " bridge=" << bridge_iface; - } - interface_configuration_request_msg.metadata()->numInterfaces = n; - THREAD_LOG(DEBUG) << "numInterfaces=" << n; - - return bus->publisher().Send(interface_configuration_request_msg); -} - -void transport_socket_thread::add_socket(Socket *s, bool add_to_vector) -{ - LOG_IF(!poller, FATAL) << "Poller is not allocated!"; - - poller->Add(s->getSocketFd(), MAPF_POLLIN | MAPF_POLLERR); - if (add_to_vector && std::find(sockets.begin(), sockets.end(), s) == sockets.end()) { - sockets.push_back(s); - } -} - -void transport_socket_thread::remove_socket(Socket *s) -{ - LOG_IF(!poller, FATAL) << "Poller is not allocated!"; - - poller->Remove(s->getSocketFd()); - sockets.erase(std::remove(sockets.begin(), sockets.end(), s), sockets.end()); -} - -bool transport_socket_thread::read_ready(Socket *s) -{ - LOG_IF(!poller, FATAL) << "Poller is not allocated!"; - - int rc = poller->CheckEvent(s->getSocketFd()); - if (rc & MAPF_POLLIN) { - return true; - } else if (rc & MAPF_POLLERR) { - THREAD_LOG(DEBUG) << "Received POLLER"; - return true; - } else if (rc == 0) { - return false; - } else { - THREAD_LOG(ERROR) << "check event error on local bus sub socket, rc=" << rc; - return false; - } -} - -bool transport_socket_thread::handle_cmdu_message_bus() -{ - auto msg = bus->subscriber().Receive(); - if (msg == nullptr) { - THREAD_LOG(ERROR) << "Received msg is null"; - return false; - } - - auto cmdu_rx_msg = dynamic_cast(msg.get()); - if (cmdu_rx_msg) { - } else { - THREAD_LOG(ERROR) << "received non CmduRxMessage:\n\tMessage: " << *msg - << "\n\tFrame: " << msg->frame().str(); - return false; - } - - // Copy the data to rx_buffer - if (sizeof(message::sUdsHeader) + cmdu_rx_msg->metadata()->length > sizeof(rx_buffer)) { - THREAD_LOG(ERROR) - << "sizeof(message::sUdsHeader) + cmdu_rx_msg->metadata()->length > sizeof(rx_buffer)"; - return false; - } - - std::copy_n((uint8_t *)cmdu_rx_msg->data(), cmdu_rx_msg->metadata()->length, - rx_buffer + sizeof(message::sUdsHeader)); - - // fill UDS Header - message::sUdsHeader *uds_header = (message::sUdsHeader *)rx_buffer; - uds_header->if_index = cmdu_rx_msg->metadata()->if_index; - std::copy_n((uint8_t *)cmdu_rx_msg->metadata()->src, sizeof(mapf::CmduRxMessage::Metadata::src), - uds_header->src_bridge_mac); - std::copy_n((uint8_t *)cmdu_rx_msg->metadata()->dst, sizeof(mapf::CmduRxMessage::Metadata::dst), - uds_header->dst_bridge_mac); - uds_header->length = cmdu_rx_msg->metadata()->length; - - if (!verify_cmdu(uds_header)) { - THREAD_LOG(ERROR) << "Failed verifying cmdu header"; - return false; - } - - if (!cmdu_rx.parse()) { - THREAD_LOG(ERROR) << "parsing cmdu failure, rx_buffer" << std::hex << rx_buffer << std::dec - << ", uds_header->length=" << int(uds_header->length); - return false; - } - - if (!handle_cmdu(nullptr, cmdu_rx)) { - return false; - } - - return true; -} - -bool transport_socket_thread::bus_send(ieee1905_1::CmduMessage &cmdu, const std::string &iface_name, - const std::string &dst_mac, const std::string &src_mac, - uint16_t length) -{ - mapf::CmduTxMessage msg; - - tlvf::mac_from_string(msg.metadata()->src, src_mac); - tlvf::mac_from_string(msg.metadata()->dst, dst_mac); - - msg.metadata()->ether_type = ETH_P_1905_1; - msg.metadata()->length = length; - msg.metadata()->msg_type = static_cast(cmdu.getMessageType()); - msg.metadata()->preset_message_id = cmdu.getMessageId() ? 1 : 0; - msg.metadata()->if_index = if_nametoindex(iface_name.c_str()); - - std::copy_n((uint8_t *)cmdu.getMessageBuff(), msg.metadata()->length, (uint8_t *)msg.data()); - return bus->publisher().Send(msg); -} - -bool transport_socket_thread::from_bus(Socket *sd) { return sd == nullptr; } - -bool transport_socket_thread::work() -{ - LOG_IF(!bus, FATAL) << "Bus is not allocated!"; - LOG_IF(!poller, FATAL) << "Poller is not allocated!"; - - before_select(); - - int num_events = poller->Poll(poll_timeout_ms); - if (num_events < 0) { - // Do not fail for the following "errors" - if (errno == EINTR) { - THREAD_LOG(DEBUG) << "Poll returned: " << strerror(errno); - return true; - } - - THREAD_LOG(ERROR) << "Poll error: " << strerror(errno); - return false; - } - - after_select(num_events == 0); - - if (num_events == 0) { - //THREAD_LOG(DEBUG) << "poll timeout"; - return true; - } - - //If something happened on the server socket , then its an incoming connection - if (server_socket && read_ready(server_socket.get())) { - THREAD_LOG(DEBUG) << "accept new connection on server socket sd=" << server_socket.get(); - Socket *sd = server_socket->acceptConnections(); - if (sd == nullptr || (!server_socket->getError().empty())) { - THREAD_LOG(ERROR) << "acceptConnections == nullptr: " << server_socket->getError(); - return false; - } else { - if (unix_socket_path.empty()) { - THREAD_LOG(DEBUG) << "new connection from ip=" << sd->getPeerIP() - << " port=" << sd->getPeerPort() << " sd=" << sd; - } else { - THREAD_LOG(DEBUG) << "new connection on " << unix_socket_path << " sd=" << sd; - } - socket_connected(sd); - } - - num_events--; - } - - if (!num_events) - return true; - // read from bus - if (local_bus_read_ready(bus, poller)) { - handle_cmdu_message_bus(); - num_events--; - } - - if (!num_events) - return true; - - // read from UDS - do { - for (unsigned int i = 0; i < sockets.size() && num_events > 0; i++) { - if (read_ready(sockets.at(i))) { - num_events--; - Socket *sd = sockets.at(i); - - auto ret = socket_disconnected_uds( - sd); // '0' - socket not disconnected (bytes to read), '1' - socket disconnected, '-1' - error - if (ret != 0) { - // breaking instead of continue because socket_disconnected_uds() may erase element from Select Socket Vector while iterating it - break; - } - - if (!handle_cmdu_message_uds(sd)) { - continue; - } - } - } - } while (num_events); - - return true; -} diff --git a/common/beerocks/btl/btl_uds.cpp b/common/beerocks/btl/btl_uds.cpp deleted file mode 100644 index 54e327d048..0000000000 --- a/common/beerocks/btl/btl_uds.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include -#include -#include -#include - -using namespace beerocks::btl; -using namespace beerocks::net; - -bool transport_socket_thread::bus_init() -{ - if (bus_server_socket) { - remove_socket(bus_server_socket.get()); - bus_server_socket->closeSocket(); - bus_server_socket.reset(nullptr); - } - - auto unix_socket_path_bus = unix_socket_path + "_bus"; - - bus_server_socket = std::make_unique(unix_socket_path_bus, 1); - if (!bus_server_socket) { - LOG(ERROR) << "bus_server_socket == nullptr"; - return false; - } else if (!bus_server_socket->getError().empty()) { - LOG(ERROR) << "failed to create server_socket, error:" << server_socket->getError(); - return false; - } - - LOG(DEBUG) << "new SocketServer on BUS " << unix_socket_path_bus; - add_socket(bus_server_socket.get(), false); - return true; -} - -bool transport_socket_thread::configure_ieee1905_transport_interfaces( - const std::string &bridge_iface, const std::vector &ifaces) -{ - return true; -} - -void transport_socket_thread::add_socket(Socket *s, bool add_to_vector) -{ - socket_thread::add_socket(s, add_to_vector); -} - -void transport_socket_thread::remove_socket(Socket *s) { socket_thread::remove_socket(s); } - -bool transport_socket_thread::read_ready(Socket *s) { return socket_thread::read_ready(s); } - -bool transport_socket_thread::bus_subscribe(const std::vector &msg_types) -{ - m_subscribed_messages.insert(msg_types.begin(), msg_types.end()); - return true; -} - -bool transport_socket_thread::bus_connect(const std::string &beerocks_temp_path, - const bool local_master) -{ - // This function must be use by the Agent side only to open UDS Bus socket to the controller - if (!local_master) { - LOG(FATAL) << "UDS_BUS is defined on non local master platform! STOPPING!"; - should_stop = true; - return false; - } - - // Delete previous connections - if (bus) { - remove_socket(bus); - delete bus; - bus = nullptr; - } - - // Open a new connection to the master TCP - THREAD_LOG(DEBUG) << "Connecting to controller on UDS..."; - std::string mrouter_uds = - beerocks_temp_path + std::string(BEEROCKS_MASTER_UDS + std::string("_bus")); - - bus = new SocketClient(mrouter_uds); - std::string err = bus->getError(); - if (!err.empty()) { - delete bus; - bus = nullptr; - THREAD_LOG(ERROR) << "Can't connect to controller using UDS: err=" << err; - return false; - } - - THREAD_LOG(DEBUG) - << "Link to between agent & controller has succesfully established!, bus_socket=" - << intptr_t(bus); - add_socket(bus); - - return true; -} - -void transport_socket_thread::bus_connected(Socket *sd) -{ - if (bus) { - remove_socket(bus); - delete bus; - } - bus = sd; - add_socket(bus); -} - -bool transport_socket_thread::bus_send(ieee1905_1::CmduMessage &cmdu, - [[gnu::unused]] const std::string &iface_name, - const std::string &dst_mac, const std::string &src_mac, - uint16_t length) -{ - auto uds_header = message_com::get_uds_header(cmdu); - if (!uds_header) { - THREAD_LOG(ERROR) << "uds_header=nullptr"; - return false; - } - uds_header->length = length; - tlvf::mac_from_string(uds_header->src_bridge_mac, src_mac); - tlvf::mac_from_string(uds_header->dst_bridge_mac, dst_mac); - return message_com::send_data(bus, cmdu.getMessageBuff() - sizeof(message::sUdsHeader), - uds_header->length + sizeof(message::sUdsHeader)); -} - -bool transport_socket_thread::from_bus(Socket *sd) { return sd == bus; } - -bool transport_socket_thread::skip_filtered_message_type(Socket *sd, - ieee1905_1::eMessageType msg_type) -{ - // Don't filter out internal messages - if (!from_bus(sd)) { - return false; - } - - if (m_subscribed_messages.find(msg_type) == m_subscribed_messages.end()) { - return true; - } - return false; -} - -bool transport_socket_thread::work() -{ - before_select(); - - int sel_ret = select.selectSocket(); - if (sel_ret < 0) { - // Do not fail for the following "errors" - if (errno == EAGAIN || errno == EINTR) { - THREAD_LOG(DEBUG) << "Select returned: " << strerror(errno); - return true; - } - - THREAD_LOG(ERROR) << "select error: " << strerror(errno); - return false; - } - - after_select(bool(sel_ret == 0)); - - if (sel_ret == 0) { - return true; - } - - //If something happened on the server socket (BUS), then its an incoming connection - if (bus_server_socket && read_ready(bus_server_socket.get())) { - clear_ready(bus_server_socket.get()); - THREAD_LOG(DEBUG) << "accept new connection on BUS server socket sd=" - << bus_server_socket.get(); - Socket *sd = bus_server_socket->acceptConnections(); - if (sd == nullptr || (!bus_server_socket->getError().empty())) { - THREAD_LOG(ERROR) << "acceptConnections == nullptr: " << bus_server_socket->getError(); - return false; - } - THREAD_LOG(DEBUG) << "new connection on " << unix_socket_path << "_bus, sd=" << sd; - bus_connected(sd); - } - - //If something happened on the server socket (UDS), then its an incoming connection - if (server_socket && read_ready(server_socket.get())) { - clear_ready(server_socket.get()); - THREAD_LOG(DEBUG) << "accept new connection on server socket sd=" << server_socket.get(); - Socket *sd = server_socket->acceptConnections(); - if (sd == nullptr || (!server_socket->getError().empty())) { - THREAD_LOG(ERROR) << "acceptConnections == nullptr: " << server_socket->getError(); - return false; - } else { - if (unix_socket_path.empty()) { - THREAD_LOG(DEBUG) << "new connection from ip=" << sd->getPeerIP() - << " port=" << sd->getPeerPort() << " sd=" << sd; - } else { - THREAD_LOG(DEBUG) << "new connection on " << unix_socket_path << " sd=" << sd; - } - socket_connected(sd); - } - } - - int sockets_count; - int i = 0; - do { - sockets_count = select.count(); - for (i = 0; i < sockets_count; i++) { - if (read_ready(select.at(i))) { - Socket *sd = select.at(i); - if (!sd) { - THREAD_LOG(WARNING) - << "sd at select with index i=" << int(i) << " is nullptr, skipping"; - continue; - } - - bool bus_socket_event = (sd == bus); - - auto ret = socket_disconnected_uds( - sd); // '0' - socket not disconnected (bytes to read), '1' - socket disconnected, '-1' - error - if (ret == 1) { - if (bus_socket_event) { - THREAD_LOG(FATAL) << "setting bus to nullptr"; - bus = nullptr; - } - // breaking instead of continue because socket_disconnected_uds() may erase element from Select Socket Vector while iterating it - break; - } else if (ret == -1) { - continue; - } - - if (!handle_cmdu_message_uds(sd)) { - continue; - } - } - } - // The loop should go over all the sockets. In case something break the for loop before it ended, - // start iterating over the sockets again. - } while (i < sockets_count); - - return true; -} From f453582e05848807b0e7869e3e7c0d6c55cb33a9 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 17:02:28 +0000 Subject: [PATCH 162/453] scripts: prplmesh_utils: remove local_bus The local_bus process no longer exists, so remove it from the script and make sure to always start the transport. Signed-off-by: Vitaly Bukhovsky --- common/beerocks/scripts/prplmesh_utils.sh.in | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/common/beerocks/scripts/prplmesh_utils.sh.in b/common/beerocks/scripts/prplmesh_utils.sh.in index 5fc8b523d0..7cc22b66ad 100755 --- a/common/beerocks/scripts/prplmesh_utils.sh.in +++ b/common/beerocks/scripts/prplmesh_utils.sh.in @@ -103,8 +103,7 @@ prplmesh_platform_db_init() { } prplmesh_framework_init() { - echo "prplmesh_framework_init - starting local_bus and ieee1905_transport processes..." - @INSTALL_PATH@/bin/local_bus & + echo "prplmesh_framework_init - starting ieee1905_transport process..." @INSTALL_PATH@/bin/ieee1905_transport & # This is required for solveing issue which causing meesges not geeting to their destination. @@ -113,8 +112,7 @@ prplmesh_framework_init() { } prplmesh_framework_deinit() { - echo "prplmesh_framework_deinit - killing local_bus and ieee1905_transport processes..." - killall_program local_bus + echo "prplmesh_framework_deinit - killing ieee1905_transport process..." killall_program ieee1905_transport ebtables -D FORWARD -d 01:80:c2:00:00:13 -j DROP } @@ -228,8 +226,7 @@ start_function() { # shellcheck disable=SC2050 [ "@BWL_TYPE@" = "DUMMY" ] && [ "$PLATFORM_INIT" = "true" ] && platform_init - # shellcheck disable=SC2050 - [ "@BTL_TYPE@" = "LOCAL_BUS" ] && prplmesh_framework_init + prplmesh_framework_init case "$PRPLMESH_MODE" in CA | ca) prplmesh_platform_db_init "Multi-AP-Controller-and-Agent" @@ -254,8 +251,7 @@ stop_function() { # shellcheck disable=SC2050 [ "@BWL_TYPE@" = "DUMMY" ] && [ "$PLATFORM_INIT" = "true" ] && platform_deinit - # shellcheck disable=SC2050 - [ "@BTL_TYPE@" = "LOCAL_BUS" ] && prplmesh_framework_deinit + prplmesh_framework_deinit prplmesh_controller_stop prplmesh_agent_stop [ "$DELETE_LOGS" = "true" ] && prplmesh_delete_logs @@ -301,7 +297,6 @@ status_function() { pgrep -l beerocks pgrep -l ieee1905_transport - pgrep -l local_bus bridge_mac="$(ip link show dev @BEEROCKS_BRIDGE_IFACE@ | awk '/^ *link\/ether / {print $2}')" bml_cmd="bml_get_device_operational_radios $bridge_mac" From 2006363283bf8a214b9341c5986f35be274cc48e Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 17:03:45 +0000 Subject: [PATCH 163/453] docker: remove zmq development packages Signed-off-by: Vitaly Bukhovsky --- tools/docker/README.md | 4 ++-- tools/docker/all/Dockerfile | 1 - tools/docker/builder/alpine/Dockerfile | 1 - tools/docker/builder/ubuntu/bionic/Dockerfile | 1 - tools/docker/builder/ubuntu/xenial/Dockerfile | 1 - tools/docker/runner/Dockerfile | 1 - 6 files changed, 2 insertions(+), 7 deletions(-) diff --git a/tools/docker/README.md b/tools/docker/README.md index 1ff0b6e22d..1ce12978f5 100644 --- a/tools/docker/README.md +++ b/tools/docker/README.md @@ -67,13 +67,13 @@ Build prplMesh (build/install directory will be the only directory mapped to the containers). ```bash -./maptools.py build map -f MSGLIB=zmq BUILD_TESTS=ON CMAKE_BUILD_TYPE=Debug +./maptools.py build map BUILD_TESTS=ON CMAKE_BUILD_TYPE=Debug ``` If you want to see more verbose build output use "--make-verbose" option ```bash -./maptools.py build map -f MSGLIB=zmq BUILD_TESTS=ON CMAKE_BUILD_TYPE=Debug --make-verbose +./maptools.py build map BUILD_TESTS=ON CMAKE_BUILD_TYPE=Debug --make-verbose ``` ### Run the Containers diff --git a/tools/docker/all/Dockerfile b/tools/docker/all/Dockerfile index 6a10c09211..9d6344fb11 100644 --- a/tools/docker/all/Dockerfile +++ b/tools/docker/all/Dockerfile @@ -28,7 +28,6 @@ RUN apt-get update && apt-get install -y \ libnl-3-dev \ libnl-route-3-dev \ libnl-genl-3-dev \ - libzmq3-dev \ python \ python-yaml \ python3 \ diff --git a/tools/docker/builder/alpine/Dockerfile b/tools/docker/builder/alpine/Dockerfile index fdb061eb88..bd92a4fbf7 100644 --- a/tools/docker/builder/alpine/Dockerfile +++ b/tools/docker/builder/alpine/Dockerfile @@ -15,7 +15,6 @@ RUN apk add --update --no-cache \ libtool \ musl-dev \ zeromq-dev \ - libzmq \ linux-headers \ make \ ncurses-dev \ diff --git a/tools/docker/builder/ubuntu/bionic/Dockerfile b/tools/docker/builder/ubuntu/bionic/Dockerfile index aa4fd6b151..e48926361b 100644 --- a/tools/docker/builder/ubuntu/bionic/Dockerfile +++ b/tools/docker/builder/ubuntu/bionic/Dockerfile @@ -18,7 +18,6 @@ RUN apt-get update && apt-get install -y \ libreadline-dev \ libssl-dev \ libtool \ - libzmq3-dev \ ninja-build \ pkg-config \ python \ diff --git a/tools/docker/builder/ubuntu/xenial/Dockerfile b/tools/docker/builder/ubuntu/xenial/Dockerfile index 8e63fa0260..826fe54d2c 100644 --- a/tools/docker/builder/ubuntu/xenial/Dockerfile +++ b/tools/docker/builder/ubuntu/xenial/Dockerfile @@ -17,7 +17,6 @@ RUN apt-get update && apt-get install -y \ libreadline-dev \ libssl-dev \ libtool \ - libzmq3-dev \ ninja-build \ pkg-config \ python \ diff --git a/tools/docker/runner/Dockerfile b/tools/docker/runner/Dockerfile index 824d949fef..5f6d2cacc1 100644 --- a/tools/docker/runner/Dockerfile +++ b/tools/docker/runner/Dockerfile @@ -19,7 +19,6 @@ RUN apt-get update && apt-get install -y \ libnl-3-dev \ libnl-route-3-dev \ libnl-genl-3-dev \ - libzmq3-dev \ python \ python-yaml \ python3 \ From 8d555f2856968e04e246a86e62da038f151e38f7 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 17:04:44 +0000 Subject: [PATCH 164/453] scripts: kw: update compilation script generation Remove the MSGLIB=zmq argument from the generated compilation line Signed-off-by: Vitaly Bukhovsky --- tools/klocwork/kw.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/klocwork/kw.sh b/tools/klocwork/kw.sh index af29640546..65a0589ba7 100755 --- a/tools/klocwork/kw.sh +++ b/tools/klocwork/kw.sh @@ -38,8 +38,8 @@ if [ "$PLATFORM_TYPE" = "rdkb" ]; then echo -e "echo starting kw from folder: \`pwd\`" echo -e "echo cleaning prplMesh build: ./maptools.sh build map -c clean" echo -e "./maptools.sh build map -c clean" - echo -e "echo building prplMesh: ./maptools.sh build map -f MSGLIB=None CMAKE_BUILD_TYPE=DEBUG" - echo -e "./maptools.sh build map -f MSGLIB=None CMAKE_BUILD_TYPE=DEBUG" + echo -e "echo building prplMesh: ./maptools.sh build map CMAKE_BUILD_TYPE=DEBUG" + echo -e "./maptools.sh build map CMAKE_BUILD_TYPE=DEBUG" echo -e "exit" } > _GO_KW @@ -54,8 +54,8 @@ elif [ "$PLATFORM_TYPE" = "ugw" ]; then echo -e "echo starting kw from folder: \`pwd\`" echo -e "echo cleaning prplMesh build: ./maptools.sh build map -c clean" echo -e "./maptools.sh build map -c clean" - echo -e "echo building prplMesh: ./maptools.sh build map -f MSGLIB=None CMAKE_BUILD_TYPE=DEBUG" - echo -e "./maptools.sh build map -f MSGLIB=None CMAKE_BUILD_TYPE=DEBUG" + echo -e "echo building prplMesh: ./maptools.sh build map CMAKE_BUILD_TYPE=DEBUG" + echo -e "./maptools.sh build map CMAKE_BUILD_TYPE=DEBUG" echo -e "exit" } > _GO_KW @@ -68,8 +68,8 @@ else # Linux echo -e "echo starting kw from folder: \`pwd\`" echo -e "echo cleaning prplMesh build: ./maptools.sh build map -c clean" echo -e "./maptools.sh build map -c clean" - echo -e "echo building prplMesh: ./maptools.sh build map -f MSGLIB=zmq CMAKE_BUILD_TYPE=DEBUG" - echo -e "./maptools.sh build map -f MSGLIB=zmq CMAKE_BUILD_TYPE=DEBUG" + echo -e "echo building prplMesh: ./maptools.sh build map CMAKE_BUILD_TYPE=DEBUG" + echo -e "./maptools.sh build map CMAKE_BUILD_TYPE=DEBUG" echo -e "exit" } > _GO_KW From 91011594b0bfdfd0081df7014187069c8bdab469 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 17:05:21 +0000 Subject: [PATCH 165/453] github: issue template: update documentation Signed-off-by: Vitaly Bukhovsky --- .github/ISSUE_TEMPLATE/bug_report.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 988024e409..a22858cf77 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -30,8 +30,8 @@ If applicable, add screenshots to help explain your problem. ## Target - Host: [e.g. Ubuntu 18.04] -- Platform: [e.g. Linux DUMMY mode with ZMQ] -- How you built prplMesh - full build command (for example `sudo ./build-image.sh && sudo ./build.sh -f MSGLIB=zmq CMAKE_BUILD_TYPE=Debug BUILD_TESTS=ON` +- Platform: [e.g. Linux DUMMY mode] +- How you built prplMesh - full build command (for example `sudo ./build-image.sh && sudo ./build.sh CMAKE_BUILD_TYPE=Debug BUILD_TESTS=ON` - How you ran prplMesh - for example `sudo build/install/scripts/prplmesh_utils.sh start` ## Additional context From 190d10f64233a4c5434f57fb21de637f5fdb7cab Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 17:07:10 +0000 Subject: [PATCH 166/453] docs: update documentation files Remove MSGLIB references from the documentation files. Signed-off-by: Vitaly Bukhovsky --- CONTRIBUTING.md | 2 +- README.md | 2 +- agent/README.md | 4 ++-- controller/README.md | 4 ++-- framework/README.md | 32 +++++++++++++++++--------------- tools/README.md | 2 +- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8b6f3c60a1..ddf9f89b71 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -306,7 +306,7 @@ That means the following conditions must hold. * All commits have a Signed-off-by. Automatic with the DCO check. * At least one maintainer has reviewed and approvied. -* Code builds on Ubuntu, with `MSGLIB=zmq` and `BWL_TYPE=DUMMY`. Automatic with gitlab CI. +* Code builds on Ubuntu, with `BWL_TYPE=DUMMY`. Automatic with gitlab CI. * Unit tests run successfully. Automatic with gitlab CI. * For each new flow being added, `tests/test_flows.py` must be updated accordingly to test the new flow, and the corresponding certification test (if any) must be added to `tests/certification/passing_agent_tests.txt`. * Run clang-format.sh. If it fixes lines you did not change, commit that separately. diff --git a/README.md b/README.md index ad094a2849..8771980505 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ To build prplMesh, you need (on Ubuntu) the following packages: ```bash sudo apt install curl gcc cmake binutils git autoconf autogen libtool pkg-config \ - libreadline-dev libncurses-dev libssl-dev libjson-c-dev libnl-genl-3-dev libzmq3-dev \ + libreadline-dev libncurses-dev libssl-dev libjson-c-dev libnl-genl-3-dev \ python python-yaml python-paramiko repo bridge-utils clang-format ninja-build ``` diff --git a/agent/README.md b/agent/README.md index fd2208d37d..b9d582f454 100644 --- a/agent/README.md +++ b/agent/README.md @@ -10,7 +10,7 @@ Some of the components are skipped / built as stubs in this mode. Running the agent on Linux allows easier development process without the need for real hardware. Instead, mac80211_hwsim can be used to simulate WLAN radios. A dummy bridge named br-lan must also exist since the agent uses the bridge MAC as the MultiAP AL-MAC. -Last, the controller needs to run either on the same host or in another host with L2 connectivity (provided the BTL is using the local bus and not UDS mode). +Last, the controller needs to run either on the same host or in another host with L2 connectivity. Currently, this mode was tested on an Ubuntu18.04 with hwsim, the agent was compiled to UDS mode. @@ -31,4 +31,4 @@ Run the agent `sudo ./build/install/bin/beerocks_agent` Run the cli to see network map `sudo ./build/install/bin/beerocks_cli -c bml_conn_map` ->Note - Logs are available in /tmp/beerocks/logs \ No newline at end of file +>Note - Logs are available in /tmp/beerocks/logs diff --git a/controller/README.md b/controller/README.md index 103ee17437..3b9984b67d 100644 --- a/controller/README.md +++ b/controller/README.md @@ -9,7 +9,7 @@ Building natively (Linux only) is partially supported only for development proce # Run Controller on Linux -The agent needs to run either on the same host as the controller or in another host with L2 connectivity (provided the BTL is using the local bus and not UDS mode). +The agent needs to run either on the same host as the controller or in another host with L2 connectivity. Currently, this mode was tested on an Ubuntu18.04 with hwsim, the agent was compiled to UDS mode. @@ -31,4 +31,4 @@ Run the agent `sudo ./build/install/bin/beerocks_agent` Run the cli to see network map `sudo ./build/install/bin/beerocks_cli -c bml_conn_map` ->Note - Logs are available in /tmp/beerocks/logs \ No newline at end of file +>Note - Logs are available in /tmp/beerocks/logs diff --git a/framework/README.md b/framework/README.md index 33535a2401..b37b7baacb 100644 --- a/framework/README.md +++ b/framework/README.md @@ -7,25 +7,28 @@ The MultiAP controller and agent are external to this project. ### Table of Contents -+ [Prerequisites](#prereq) -+ [Build & Install](#build) -+ [Tests](#test) -+ [References](#ref) -+ [Versioning](#ver) -+ [Authors](#authors) -+ [License](#license) +- [MultiAP Framework](#multiap-framework) + - [Table of Contents](#table-of-contents) + - [Prerequisites](#prerequisites) + - [Build & Install](#build--install) + - [Tests](#tests) + - [Unit Tests](#unit-tests) + - [References](#references) + - [Versioning](#versioning) + - [Authors](#authors) + - [License](#license) ## Prerequisites The following are needed for building the MultiAP framework on any Linux machine (local and cross compile): -| Package | Version | -| --------- | -----:| -| cmake | >=2.8 | -| c++11 | | -| json-c | 0.12.1 | -| ubus | any | +| Package | Version | +| ------- | ------: | +| cmake | >=2.8 | +| c++11 | | +| json-c | 0.12.1 | +| ubus | any | Cross compiling - currently supporting UGW & RDKB cross compiling, see [feed_multiap](https://gts-chd.intel.com/projects/SW_UGW/repos/feed_multiap/browse). @@ -53,7 +56,7 @@ Supported Unit Tests: - broker_test - test the broker functionality by running a broker, subscriber and publisher that sends a single message - socket_test - test socket class - poller_test - test poller class -- transport_test - Sending 1905 CMDUs over 1905.1 Transport service over local bus + raw socket +- transport_test - Sending 1905 CMDUs over 1905.1 Transport service over raw socket ## References @@ -72,4 +75,3 @@ Supported Unit Tests: This project is licensed under the BSD+Pantet License - see the [LICENSE](LICENSE) file for details [__Table Of contents__](#table-of-contents) - diff --git a/tools/README.md b/tools/README.md index 0191210d04..2097859a79 100644 --- a/tools/README.md +++ b/tools/README.md @@ -57,7 +57,7 @@ build only dep modules(nng, safeclib, dwpal): Build map with nng messaging library (needs to have nng installed): ``` -./maptools.py build map -f MSGLIB=nng +./maptools.py build map ``` Clean and rebuild controller only: From 0c2473dcef0f38baa1f52035083528c9b75f9897 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 17:08:12 +0000 Subject: [PATCH 167/453] vscode: tasks: update the default build command Signed-off-by: Vitaly Bukhovsky --- .vscode/tasks.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 2d85140eaa..654a6c113a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -8,7 +8,7 @@ "type": "shell", "options": { "env": { - "BUILD_ARGS": "-G Ninja -f MSGLIB=zmq BUILD_TESTS=ON CMAKE_BUILD_TYPE=Debug" + "BUILD_ARGS": "-G Ninja -f BUILD_TESTS=ON CMAKE_BUILD_TYPE=Debug" } }, "linux": { @@ -116,4 +116,4 @@ ] } ] -} \ No newline at end of file +} From d73b92876d48b222fd9f99f36686fdb2bf10eb84 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 17:08:37 +0000 Subject: [PATCH 168/453] vscode: settings: set python3 path Signed-off-by: Vitaly Bukhovsky --- .vscode/settings.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 557264d22d..a276751ad3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -104,5 +104,6 @@ "backhual", "fronthaul" ], - "git.alwaysSignOff": true + "git.alwaysSignOff": true, + "python.pythonPath": "/usr/bin/python3" } From d36e0ce0de4491ca6940e9f38576f3e3c2ea73a0 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Wed, 1 Jul 2020 17:17:55 +0000 Subject: [PATCH 169/453] cppcheck: update existing issues file Signed-off-by: Vitaly Bukhovsky --- ci/cppcheck/cppcheck_existing_issues.txt | 27 ------------------------ 1 file changed, 27 deletions(-) diff --git a/ci/cppcheck/cppcheck_existing_issues.txt b/ci/cppcheck/cppcheck_existing_issues.txt index 27477d428c..5d3bea0444 100644 --- a/ci/cppcheck/cppcheck_existing_issues.txt +++ b/ci/cppcheck/cppcheck_existing_issues.txt @@ -39,7 +39,6 @@ common/beerocks/bcl/source/network/socket.cpp: style: Unused variable: it [unuse common/beerocks/bcl/source/son/son_wireless_utils.cpp: style: Condition 'prev_bw<=bw' is always true [knownConditionTrueFalse] } else if (prev_bw <= bw) { common/beerocks/bcl/source/son/son_wireless_utils.cpp: style: The scope of the variable 'diff_temp' can be reduced. [variableScope] uint16_t diff_temp; common/beerocks/bcl/source/son/son_wireless_utils.cpp: style: The scope of the variable 'rate_temp' can be reduced. [variableScope] uint16_t rate_temp; -common/beerocks/btl/btl_local_bus.cpp: style: Consider using std::find_if algorithm instead of a raw loop. [useStlAlgorithm] if (!subscribe_topic_to_bus(bus, msg_type)) { common/beerocks/bwl/dummy/ap_wlan_hal_dummy.cpp: style: struct member 'DUMMY_acs_report_get::BW' is never used. [unusedStructMember] int BW; common/beerocks/bwl/dummy/ap_wlan_hal_dummy.cpp: style: struct member 'DUMMY_acs_report_get::Ch' is never used. [unusedStructMember] int Ch; common/beerocks/bwl/dummy/ap_wlan_hal_dummy.cpp: style: struct member 'DUMMY_acs_report_get::DFS' is never used. [unusedStructMember] int DFS; @@ -182,19 +181,9 @@ controller/src/beerocks/master/tasks/rdkb/rdkb_wlan_task_db.cpp: style: Paramete controller/src/beerocks/master/tasks/task.cpp: performance: Function parameter 'mac' should be passed by const reference. [passedByValue]void task::add_pending_mac(std::string mac, beerocks_message::eActionOp_CONTROL action_op) controller/src/beerocks/master/tasks/task.cpp: performance: Function parameter 'node_mac' should be passed by const reference. [passedByValue]task::task(std::string task_name_, std::string node_mac) controller/src/beerocks/master/tasks/task.cpp: performance: Function parameter 'task_name_' should be passed by const reference. [passedByValue]task::task(std::string task_name_, std::string node_mac) -framework/common/broker_interface.cpp: style: Parameter 'msg' can be declared with const [constParameter]void BrokerInterface::SyncSend(Message &msg) framework/common/encryption.cpp: style: Variable 'kdf_iter.i' is assigned a value that is never used. [unreadVariable] kdf_iter.i = htonl(iter); framework/common/encryption.cpp: style: Variable 'kdf_key_length.i' is assigned a value that is never used. [unreadVariable] kdf_key_length.i = htonl(sizeof(keys.keys) * 8); framework/common/encryption.cpp: style: struct member 'Anonymous1::emsk' is never used. [unusedStructMember] uint8_t emsk[32]; -framework/common/include/mapf/broker/broker_config.h: performance: Function parameter 'pub_public' should be passed by const reference. [passedByValue] std::string xsub_public, std::string pub_secret, std::string pub_public, -framework/common/include/mapf/broker/broker_config.h: performance: Function parameter 'pub_secret' should be passed by const reference. [passedByValue] std::string xsub_public, std::string pub_secret, std::string pub_public, -framework/common/include/mapf/broker/broker_config.h: performance: Function parameter 'sub_public' should be passed by const reference. [passedByValue] std::string sub_public) -framework/common/include/mapf/broker/broker_config.h: performance: Function parameter 'sub_secret' should be passed by const reference. [passedByValue] std::string xpub_secret, std::string xpub_public, std::string sub_secret, -framework/common/include/mapf/broker/broker_config.h: performance: Function parameter 'xpub_public' should be passed by const reference. [passedByValue] std::string xpub_secret, std::string xpub_public, std::string sub_secret, -framework/common/include/mapf/broker/broker_config.h: performance: Function parameter 'xpub_secret' should be passed by const reference. [passedByValue] std::string xpub_secret, std::string xpub_public, std::string sub_secret, -framework/common/include/mapf/broker/broker_config.h: performance: Function parameter 'xsub_public' should be passed by const reference. [passedByValue] std::string xsub_public, std::string pub_secret, std::string pub_public, -framework/common/include/mapf/broker/broker_config.h: performance: Function parameter 'xsub_secret' should be passed by const reference. [passedByValue] BrokerSecurity(bool enable, unsigned int key_len, std::string xsub_secret, -framework/common/include/mapf/broker/broker_interface.h: performance: Function parameter 'sync_topic' should be passed by const reference. [passedByValue] BrokerInterface(Context &ctx, const std::string &cfg, std::string sync_topic = "hello") framework/common/include/mapf/common/logger.h: performance: Function parameter 'param' should be passed by const reference. [passedByValue] void set_file_path(std::string param) { file_path_ = param; } framework/common/include/mapf/common/logger.h: performance: Function parameter 'param' should be passed by const reference. [passedByValue] void set_level(std::string param) { level_ = param; } framework/common/include/mapf/common/message.h: style: Local variable 'frame' shadows outer function [shadowFunction] for (auto frame : frames) @@ -202,16 +191,9 @@ framework/common/logger.cpp: performance: Function parameter 'logger_name' shoul framework/common/logger.cpp: style: Condition '!init_performed' is always true [knownConditionTrueFalse] if (!init_performed) { framework/common/logger.cpp: style: The scope of the variable 'length' can be reduced. [variableScope] int fd = -1, length = -1, i = 0, ret = 0; framework/common/logger.cpp: style: Variable 'length' is assigned a value that is never used. [unreadVariable] int fd = -1, length = -1, i = 0, ret = 0; -framework/common/nng/socket.cpp: style: Consider using std::accumulate algorithm instead of a raw loop. [useStlAlgorithm] totalLen += frame.len(); -framework/common/nng/socket.cpp: style: Parameter 'frame' can be declared with const [constParameter]bool SubSocket::Receive(Message::Frame &frame, int flags) framework/common/test/encryption_test.cpp: performance: Function parameter 'message' should be passed by const reference. [passedByValue]static bool check(int &errors, bool check, std::string message) framework/common/test/encryption_test.cpp: style: Variable 'key1_length' is assigned a value that is never used. [unreadVariable] key1_length = sizeof(key1); framework/common/test/message_test.cpp: style: Local variable 'f1' shadows outer variable [shadowVariable] mapf::Message::Frame f1; -framework/common/test/poller_test.cpp: style: The scope of the variable 'rc' can be reduced. [variableScope] int attempts = 0, max_attempts = 100, rc; -framework/common/test/poller_test.cpp: style: Variable 'rc' is reassigned a value before the old one has been used. [redundantAssignment] rc = poller_.Remove(sub_); -framework/common/test/socket_test.cpp: style: Consider using std::accumulate algorithm instead of a raw loop. [useStlAlgorithm] frames += f.str() + ", "; -framework/common/test/socket_test.cpp: style: Parameter 'cfg' can be declared with const [constParameter]int start_broker(SocketTest::SocketTestConfig &cfg) -framework/common/zmq/socket.cpp: style: Parameter 'frame' can be declared with const [constParameter]bool SubSocket::Receive(Message::Frame &frame, int flags) framework/external/easylogging/easylogging++.cc: information: This file is not analyzed. Cppcheck failed to extract a valid configuration. Use -v for more details. [noValidConfiguration] framework/platform/bpl/common/utils/utils.cpp: performance: Function parameter 'additional_chars' should be passed by const reference. [passedByValue]void ltrim(std::string &str, std::string additional_chars) framework/platform/bpl/common/utils/utils.cpp: performance: Function parameter 'additional_chars' should be passed by const reference. [passedByValue]void rtrim(std::string &str, std::string additional_chars) @@ -242,18 +224,9 @@ framework/tlvf/test/tlvf_test.cpp: style: Variable 'tlv1' is assigned a value th framework/tlvf/test/tlvf_test.cpp: style: Variable 'tlv2' is assigned a value that is never used. [unreadVariable] auto tlv2 = msg.addClass(); framework/tlvf/test/tlvf_test.cpp: style: Variable 'tlv3' is assigned a value that is never used. [unreadVariable] auto tlv3 = msg.addClass(); framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp: style: C-style pointer casting [cstyleCast] Ieee1905CmduHeader *ch = (Ieee1905CmduHeader *)packet.payload.iov_base; -framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp: style: C-style pointer casting [cstyleCast] Ieee1905CmduHeader *ch = (Ieee1905CmduHeader *)packet.payload.iov_base; -framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp: style: Parameter 'msg' can be declared with const [constParameter] InterfaceConfigurationRequestMessage &msg) -framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp: style: Parameter 'msg' can be declared with const [constParameter]void Ieee1905Transport::handle_local_bus_cmdu_tx_message(CmduTxMessage &msg) framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp: style: C-style pointer casting [cstyleCast] Ieee1905CmduHeader *ch = (Ieee1905CmduHeader *)packet.payload.iov_base; framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp: style: C-style pointer casting [cstyleCast] Ieee1905CmduHeader *ch = (Ieee1905CmduHeader *)packet.payload.iov_base; framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp: style: C-style pointer casting [cstyleCast] Ieee1905CmduHeader *ch = (Ieee1905CmduHeader *)packet.payload.iov_base; framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp: style: Parameter 'packet' can be declared with const [constParameter]bool Ieee1905Transport::verify_packet(Packet &packet) -framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport.h: style: The class 'Ieee1905Transport' does not have a constructor although it has private member variables. [noConstructor]class Ieee1905Transport { -framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h: performance: Function parameter 'prefix' should be passed by const reference. [passedByValue] static const std::string build_topic(const std::string prefix, uint16_t ether_type, framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h: style: C-style pointer casting [cstyleCast] return (Metadata *)frames().back().data(); framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h: style: C-style pointer casting [cstyleCast] Metadata *metadata() const { return (Metadata *)frames().back().data(); }; -framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h: style: Local variable 'topic' shadows outer function [shadowFunction] std::ostringstream topic; -framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h: style: The function 'print' overrides a function in a base class but is not marked with a 'override' specifier. [missingOverride] virtual std::ostream &print(std::ostream &os) const -framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h: style: The function 'topic' overrides a function in a base class but is not marked with a 'override' specifier. [missingOverride] virtual const std::string topic() const -framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h: style: The function 'topic' overrides a function in a base class but is not marked with a 'override' specifier. [missingOverride] virtual const std::string topic() const { return topic_prefix(); } From 95e0669c55ce0b73986282594d4fc2757f436bad Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Thu, 2 Jul 2020 18:06:01 +0200 Subject: [PATCH 170/453] tlvf: simplify cConfigData Prepare cConfigData used in vendor specific message ACTION_APMANAGER_WIFI_CREDENTIALS_UPDATE_REQUEST to replace the struct `sWscAttrVendorExtMultiAp` with a single `bss_type` byte (this struct is wrong and is going to be removed in a future commit). Signed-off-by: Mario Maz --- framework/tlvf/yaml/tlvf/WSC/WSC_Attributes.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/framework/tlvf/yaml/tlvf/WSC/WSC_Attributes.yaml b/framework/tlvf/yaml/tlvf/WSC/WSC_Attributes.yaml index 1eba12063f..7974a095c9 100644 --- a/framework/tlvf/yaml/tlvf/WSC/WSC_Attributes.yaml +++ b/framework/tlvf/yaml/tlvf/WSC/WSC_Attributes.yaml @@ -139,6 +139,9 @@ cConfigData: _length_max: WSC_MAX_NETWORK_KEY_LENGTH bssid_attr: sWscAttrBssid multiap_attr: sWscAttrVendorExtMultiAp + bss_type: + _type: uint8_t + _value: TEARDOWN cWscAttrEncryptedSettings: _type: class From 8623123a64053721abe8cce47ab436b4b20541bd Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Thu, 2 Jul 2020 18:29:07 +0200 Subject: [PATCH 171/453] tlvf: Update auto-generated files Signed-off-by: Mario Maz --- .../AutoGenerated/include/tlvf/WSC/WSC_Attributes.h | 2 ++ .../AutoGenerated/src/tlvf/WSC/WSC_Attributes.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/framework/tlvf/AutoGenerated/include/tlvf/WSC/WSC_Attributes.h b/framework/tlvf/AutoGenerated/include/tlvf/WSC/WSC_Attributes.h index 95cfca8376..628399d893 100644 --- a/framework/tlvf/AutoGenerated/include/tlvf/WSC/WSC_Attributes.h +++ b/framework/tlvf/AutoGenerated/include/tlvf/WSC/WSC_Attributes.h @@ -208,6 +208,7 @@ class cConfigData : public BaseClass bool alloc_network_key(size_t count = 1); sWscAttrBssid& bssid_attr(); sWscAttrVendorExtMultiAp& multiap_attr(); + uint8_t& bss_type(); void class_swap() override; bool finalize() override; static size_t get_initial_size(); @@ -227,6 +228,7 @@ class cConfigData : public BaseClass size_t m_network_key_idx__ = 0; sWscAttrBssid* m_bssid_attr = nullptr; sWscAttrVendorExtMultiAp* m_multiap_attr = nullptr; + uint8_t* m_bss_type = nullptr; }; class cWscAttrEncryptedSettings : public BaseClass diff --git a/framework/tlvf/AutoGenerated/src/tlvf/WSC/WSC_Attributes.cpp b/framework/tlvf/AutoGenerated/src/tlvf/WSC/WSC_Attributes.cpp index 28da837627..8e7fb095a1 100644 --- a/framework/tlvf/AutoGenerated/src/tlvf/WSC/WSC_Attributes.cpp +++ b/framework/tlvf/AutoGenerated/src/tlvf/WSC/WSC_Attributes.cpp @@ -89,6 +89,7 @@ bool cConfigData::alloc_ssid(size_t count) { m_network_key = (char *)((uint8_t *)(m_network_key) + len); m_bssid_attr = (sWscAttrBssid *)((uint8_t *)(m_bssid_attr) + len); m_multiap_attr = (sWscAttrVendorExtMultiAp *)((uint8_t *)(m_multiap_attr) + len); + m_bss_type = (uint8_t *)((uint8_t *)(m_bss_type) + len); m_ssid_idx__ += count; *m_ssid_length += count; if (!buffPtrIncrementSafe(len)) { @@ -165,6 +166,7 @@ bool cConfigData::alloc_network_key(size_t count) { } m_bssid_attr = (sWscAttrBssid *)((uint8_t *)(m_bssid_attr) + len); m_multiap_attr = (sWscAttrVendorExtMultiAp *)((uint8_t *)(m_multiap_attr) + len); + m_bss_type = (uint8_t *)((uint8_t *)(m_bss_type) + len); m_network_key_idx__ += count; *m_network_key_length += count; if (!buffPtrIncrementSafe(len)) { @@ -182,6 +184,10 @@ sWscAttrVendorExtMultiAp& cConfigData::multiap_attr() { return (sWscAttrVendorExtMultiAp&)(*m_multiap_attr); } +uint8_t& cConfigData::bss_type() { + return (uint8_t&)(*m_bss_type); +} + void cConfigData::class_swap() { tlvf_swap(16, reinterpret_cast(m_ssid_type)); @@ -232,6 +238,7 @@ size_t cConfigData::get_initial_size() class_size += sizeof(uint16_t); // network_key_length class_size += sizeof(sWscAttrBssid); // bssid_attr class_size += sizeof(sWscAttrVendorExtMultiAp); // multiap_attr + class_size += sizeof(uint8_t); // bss_type return class_size; } @@ -305,6 +312,12 @@ bool cConfigData::init() return false; } if (!m_parse__) { m_multiap_attr->struct_init(); } + m_bss_type = reinterpret_cast(m_buff_ptr__); + if (!m_parse__) *m_bss_type = TEARDOWN; + if (!buffPtrIncrementSafe(sizeof(uint8_t))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; + return false; + } if (m_parse__) { class_swap(); } return true; } From 5da496a077b34dcae47e5b9f6db96bfa6ff21b27 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Thu, 2 Jul 2020 18:32:35 +0200 Subject: [PATCH 172/453] agent: replace multiap_attr with bss_type byte Modify reading and writing of cConfigData used in vendor specific message ACTION_APMANAGER_WIFI_CREDENTIALS_UPDATE_REQUEST so it does not use the struct sWscAttrVendorExtMultiAp anymore but the new bss_type byte (this struct is wrong and is going to be removed in a future commit). Signed-off-by: Mario Maz --- .../fronthaul_manager/ap_manager/ap_manager_thread.cpp | 4 ++-- agent/src/beerocks/slave/son_slave_thread.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/agent/src/beerocks/fronthaul_manager/ap_manager/ap_manager_thread.cpp b/agent/src/beerocks/fronthaul_manager/ap_manager/ap_manager_thread.cpp index 0784487634..eddb61e3d1 100644 --- a/agent/src/beerocks/fronthaul_manager/ap_manager/ap_manager_thread.cpp +++ b/agent/src/beerocks/fronthaul_manager/ap_manager/ap_manager_thread.cpp @@ -887,8 +887,8 @@ bool ap_manager_thread::handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_ // value set to one (see Table 4), it shall tear down all currently operating BSS(s) // on the radio indicated by the Radio Unique Identifier, and shall ignore the other // attributes in the M2. - auto bss_type = static_cast( - config_data.multiap_attr().subelement_value); + auto bss_type = + static_cast(config_data.bss_type()); if ((bss_type & WSC::eWscVendorExtSubelementBssType::TEARDOWN) != 0) { LOG(DEBUG) << "received teardown"; bss_info_conf_list.clear(); diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 6a7a7e761f..f9def7e844 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -4124,7 +4124,7 @@ bool slave_thread::handle_autoconfiguration_wsc(Socket *sd, ieee1905_1::CmduMess c->bssid_attr().data = config.bssid; c->authentication_type_attr().data = config.auth_type; c->encryption_type_attr().data = config.encr_type; - c->multiap_attr().subelement_value = config.bss_type; + c->bss_type() = config.bss_type; request->add_wifi_credentials(c); } From 7d4a2ce24da4395a29bc215ff21f362a6f74437e Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Wed, 1 Jul 2020 18:03:37 +0200 Subject: [PATCH 173/453] tlvf: add class for WSC Vendor Extension and subelements Add new class for WSC Vendor Extension attribute (type 0x1049) using by default Vendor ID 0x00372A (i.e.: WFA). Add new structs for the WFA Vendor Extension subelements that we use: Version2 (0x00) and Multi-AP Identifier (0x06). Signed-off-by: Mario Maz --- .../tlvf/yaml/tlvf/WSC/WSC_Attributes.yaml | 47 +++++++++++++++++++ .../tlvf/WSC/eWscWfaVendorExtSubelement.yaml | 15 ++++++ 2 files changed, 62 insertions(+) create mode 100644 framework/tlvf/yaml/tlvf/WSC/eWscWfaVendorExtSubelement.yaml diff --git a/framework/tlvf/yaml/tlvf/WSC/WSC_Attributes.yaml b/framework/tlvf/yaml/tlvf/WSC/WSC_Attributes.yaml index 7974a095c9..886c935eda 100644 --- a/framework/tlvf/yaml/tlvf/WSC/WSC_Attributes.yaml +++ b/framework/tlvf/yaml/tlvf/WSC/WSC_Attributes.yaml @@ -6,6 +6,7 @@ _include: { tlvf/WSC/eWscVendorId.h, tlvf/WSC/eWscVendorExt.h, tlvf/WSC/eWscDev.h, + tlvf/WSC/eWscWfaVendorExtSubelement.h, tlvf/common/sMacAddr.h, } _namespace: WSC @@ -113,6 +114,52 @@ sWscAttrBssid: data: _type: sMacAddr +sWscWfaVendorExtSubelementVersion2: + _type: struct + id: + _type: uint8_t + _value: VERSION2 + length: + _type: uint8_t + _value: 0x1 + value: + _type: uint8_t + _value: WSC_VERSION2 + +sWscWfaVendorExtSubelementMultiApIdentifier: + _type: struct + id: + _type: uint8_t + _value: MULTI_AP_IDENTIFIER + length: + _type: uint8_t + _value: 0x1 + value: + _type: uint8_t + _value: TEARDOWN + +cWscAttrVendorExtension: + _type: class + _is_tlv_class: True + type: + _type: eWscAttributes + _value: ATTR_VENDOR_EXTENSION + length: + _type: uint16_t + _length_var: True + vendor_id_0: + _type: uint8_t + _value: WSC_VENDOR_ID_WFA_1 + vendor_id_1: + _type: uint8_t + _value: WSC_VENDOR_ID_WFA_2 + vendor_id_2: + _type: uint8_t + _value: WSC_VENDOR_ID_WFA_3 + vendor_data: + _type: uint8_t + _length: [] + cConfigData: _type: class ssid_type: diff --git a/framework/tlvf/yaml/tlvf/WSC/eWscWfaVendorExtSubelement.yaml b/framework/tlvf/yaml/tlvf/WSC/eWscWfaVendorExtSubelement.yaml new file mode 100644 index 0000000000..14ab5aaa81 --- /dev/null +++ b/framework/tlvf/yaml/tlvf/WSC/eWscWfaVendorExtSubelement.yaml @@ -0,0 +1,15 @@ +# +--- +_namespace: WSC + +eWscWfaVendorExtSubelement: + _type: enum + VERSION2: 0x00 + AUTHORIZED_MACS: 0x01 + NETWORK_KEY_SHAREABLE: 0x02 + REQUEST_TO_ENROLL: 0x03 + SETTINGS_DELAY_TIME: 0x04 + REGISTRAR_CONFIGURATION_METHODS: 0x05 + MULTI_AP_IDENTIFIER: 0x06 + MULTI_AP_PROFILE: 0x07 + MULTI_AP_DEFAULT_802_1Q_SETTING: 0x08 From a02a186a6900c089b84e6040210b95dd03a517e6 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Thu, 2 Jul 2020 18:55:00 +0200 Subject: [PATCH 174/453] tlvf: Update auto-generated files Signed-off-by: Mario Maz --- .../include/tlvf/WSC/WSC_Attributes.h | 60 ++++++ .../tlvf/WSC/eWscWfaVendorExtSubelement.h | 37 ++++ .../src/tlvf/WSC/WSC_Attributes.cpp | 172 ++++++++++++++++++ 3 files changed, 269 insertions(+) create mode 100644 framework/tlvf/AutoGenerated/include/tlvf/WSC/eWscWfaVendorExtSubelement.h diff --git a/framework/tlvf/AutoGenerated/include/tlvf/WSC/WSC_Attributes.h b/framework/tlvf/AutoGenerated/include/tlvf/WSC/WSC_Attributes.h index 628399d893..7bc3924542 100644 --- a/framework/tlvf/AutoGenerated/include/tlvf/WSC/WSC_Attributes.h +++ b/framework/tlvf/AutoGenerated/include/tlvf/WSC/WSC_Attributes.h @@ -35,10 +35,12 @@ #include "tlvf/WSC/eWscVendorId.h" #include "tlvf/WSC/eWscVendorExt.h" #include "tlvf/WSC/eWscDev.h" +#include "tlvf/WSC/eWscWfaVendorExtSubelement.h" #include "tlvf/common/sMacAddr.h" namespace WSC { +class cConfigData; class cWscAttrEncryptedSettings; class cWscVendorExtWfa; class cWscAttrVersion; @@ -182,6 +184,64 @@ typedef struct sWscAttrBssid { } } __attribute__((packed)) sWscAttrBssid; +typedef struct sWscWfaVendorExtSubelementVersion2 { + uint8_t id; + uint8_t length; + uint8_t value; + void struct_swap(){ + } + void struct_init(){ + id = VERSION2; + length = 0x1; + value = WSC_VERSION2; + } +} __attribute__((packed)) sWscWfaVendorExtSubelementVersion2; + +typedef struct sWscWfaVendorExtSubelementMultiApIdentifier { + uint8_t id; + uint8_t length; + uint8_t value; + void struct_swap(){ + } + void struct_init(){ + id = MULTI_AP_IDENTIFIER; + length = 0x1; + value = TEARDOWN; + } +} __attribute__((packed)) sWscWfaVendorExtSubelementMultiApIdentifier; + + +class cWscAttrVendorExtension : public BaseClass +{ + public: + cWscAttrVendorExtension(uint8_t* buff, size_t buff_len, bool parse = false); + explicit cWscAttrVendorExtension(std::shared_ptr base, bool parse = false); + ~cWscAttrVendorExtension(); + + eWscAttributes& type(); + const uint16_t& length(); + uint8_t& vendor_id_0(); + uint8_t& vendor_id_1(); + uint8_t& vendor_id_2(); + size_t vendor_data_length() { return m_vendor_data_idx__ * sizeof(uint8_t); } + uint8_t* vendor_data(size_t idx = 0); + bool set_vendor_data(const void* buffer, size_t size); + bool alloc_vendor_data(size_t count = 1); + void class_swap() override; + bool finalize() override; + static size_t get_initial_size(); + + private: + bool init(); + eWscAttributes* m_type = nullptr; + uint16_t* m_length = nullptr; + uint8_t* m_vendor_id_0 = nullptr; + uint8_t* m_vendor_id_1 = nullptr; + uint8_t* m_vendor_id_2 = nullptr; + uint8_t* m_vendor_data = nullptr; + size_t m_vendor_data_idx__ = 0; + int m_lock_order_counter__ = 0; +}; class cConfigData : public BaseClass { diff --git a/framework/tlvf/AutoGenerated/include/tlvf/WSC/eWscWfaVendorExtSubelement.h b/framework/tlvf/AutoGenerated/include/tlvf/WSC/eWscWfaVendorExtSubelement.h new file mode 100644 index 0000000000..e69efcd913 --- /dev/null +++ b/framework/tlvf/AutoGenerated/include/tlvf/WSC/eWscWfaVendorExtSubelement.h @@ -0,0 +1,37 @@ +/////////////////////////////////////// +// AUTO GENERATED FILE - DO NOT EDIT // +/////////////////////////////////////// + +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#ifndef _TLVF_WSC_EWSCWFAVENDOREXTSUBELEMENT_H_ +#define _TLVF_WSC_EWSCWFAVENDOREXTSUBELEMENT_H_ + +#include +#include +#include + +namespace WSC { + +enum eWscWfaVendorExtSubelement { + VERSION2 = 0x0, + AUTHORIZED_MACS = 0x1, + NETWORK_KEY_SHAREABLE = 0x2, + REQUEST_TO_ENROLL = 0x3, + SETTINGS_DELAY_TIME = 0x4, + REGISTRAR_CONFIGURATION_METHODS = 0x5, + MULTI_AP_IDENTIFIER = 0x6, + MULTI_AP_PROFILE = 0x7, + MULTI_AP_DEFAULT_802_1Q_SETTING = 0x8, +}; + + +}; // close namespace: WSC + +#endif //_TLVF/WSC_EWSCWFAVENDOREXTSUBELEMENT_H_ diff --git a/framework/tlvf/AutoGenerated/src/tlvf/WSC/WSC_Attributes.cpp b/framework/tlvf/AutoGenerated/src/tlvf/WSC/WSC_Attributes.cpp index 8e7fb095a1..8567d1c80b 100644 --- a/framework/tlvf/AutoGenerated/src/tlvf/WSC/WSC_Attributes.cpp +++ b/framework/tlvf/AutoGenerated/src/tlvf/WSC/WSC_Attributes.cpp @@ -15,6 +15,178 @@ using namespace WSC; +cWscAttrVendorExtension::cWscAttrVendorExtension(uint8_t* buff, size_t buff_len, bool parse) : + BaseClass(buff, buff_len, parse) { + m_init_succeeded = init(); +} +cWscAttrVendorExtension::cWscAttrVendorExtension(std::shared_ptr base, bool parse) : +BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ + m_init_succeeded = init(); +} +cWscAttrVendorExtension::~cWscAttrVendorExtension() { +} +eWscAttributes& cWscAttrVendorExtension::type() { + return (eWscAttributes&)(*m_type); +} + +const uint16_t& cWscAttrVendorExtension::length() { + return (const uint16_t&)(*m_length); +} + +uint8_t& cWscAttrVendorExtension::vendor_id_0() { + return (uint8_t&)(*m_vendor_id_0); +} + +uint8_t& cWscAttrVendorExtension::vendor_id_1() { + return (uint8_t&)(*m_vendor_id_1); +} + +uint8_t& cWscAttrVendorExtension::vendor_id_2() { + return (uint8_t&)(*m_vendor_id_2); +} + +uint8_t* cWscAttrVendorExtension::vendor_data(size_t idx) { + if ( (m_vendor_data_idx__ == 0) || (m_vendor_data_idx__ <= idx) ) { + TLVF_LOG(ERROR) << "Requested index is greater than the number of available entries"; + return nullptr; + } + return &(m_vendor_data[idx]); +} + +bool cWscAttrVendorExtension::set_vendor_data(const void* buffer, size_t size) { + if (buffer == nullptr) { + TLVF_LOG(WARNING) << "set_vendor_data received a null pointer."; + return false; + } + if (!alloc_vendor_data(size)) { return false; } + std::copy_n(reinterpret_cast(buffer), size, m_vendor_data); + return true; +} +bool cWscAttrVendorExtension::alloc_vendor_data(size_t count) { + if (m_lock_order_counter__ > 0) {; + TLVF_LOG(ERROR) << "Out of order allocation for variable length list vendor_data, abort!"; + return false; + } + size_t len = sizeof(uint8_t) * count; + if(getBuffRemainingBytes() < len ) { + TLVF_LOG(ERROR) << "Not enough available space on buffer - can't allocate"; + return false; + } + m_lock_order_counter__ = 0; + uint8_t *src = (uint8_t *)m_vendor_data; + uint8_t *dst = src + len; + if (!m_parse__) { + size_t move_length = getBuffRemainingBytes(src) - len; + std::copy_n(src, move_length, dst); + } + m_vendor_data_idx__ += count; + if (!buffPtrIncrementSafe(len)) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << len << ") Failed!"; + return false; + } + if(m_length){ (*m_length) += len; } + return true; +} + +void cWscAttrVendorExtension::class_swap() +{ + tlvf_swap(16, reinterpret_cast(m_type)); + tlvf_swap(16, reinterpret_cast(m_length)); +} + +bool cWscAttrVendorExtension::finalize() +{ + if (m_parse__) { + TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; + return true; + } + if (m_finalized__) { + TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; + return true; + } + if (!isPostInitSucceeded()) { + TLVF_LOG(ERROR) << "post init check failed"; + return false; + } + if (m_inner__) { + if (!m_inner__->finalize()) { + TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; + return false; + } + auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); + m_buff_ptr__ -= tailroom; + *m_length -= tailroom; + } + class_swap(); + m_finalized__ = true; + return true; +} + +size_t cWscAttrVendorExtension::get_initial_size() +{ + size_t class_size = 0; + class_size += sizeof(eWscAttributes); // type + class_size += sizeof(uint16_t); // length + class_size += sizeof(uint8_t); // vendor_id_0 + class_size += sizeof(uint8_t); // vendor_id_1 + class_size += sizeof(uint8_t); // vendor_id_2 + return class_size; +} + +bool cWscAttrVendorExtension::init() +{ + if (getBuffRemainingBytes() < get_initial_size()) { + TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; + return false; + } + m_type = reinterpret_cast(m_buff_ptr__); + if (!m_parse__) *m_type = ATTR_VENDOR_EXTENSION; + if (!buffPtrIncrementSafe(sizeof(eWscAttributes))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(eWscAttributes) << ") Failed!"; + return false; + } + m_length = reinterpret_cast(m_buff_ptr__); + if (!m_parse__) *m_length = 0; + if (!buffPtrIncrementSafe(sizeof(uint16_t))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; + return false; + } + m_vendor_id_0 = reinterpret_cast(m_buff_ptr__); + if (!m_parse__) *m_vendor_id_0 = WSC_VENDOR_ID_WFA_1; + if (!buffPtrIncrementSafe(sizeof(uint8_t))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; + return false; + } + if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } + m_vendor_id_1 = reinterpret_cast(m_buff_ptr__); + if (!m_parse__) *m_vendor_id_1 = WSC_VENDOR_ID_WFA_2; + if (!buffPtrIncrementSafe(sizeof(uint8_t))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; + return false; + } + if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } + m_vendor_id_2 = reinterpret_cast(m_buff_ptr__); + if (!m_parse__) *m_vendor_id_2 = WSC_VENDOR_ID_WFA_3; + if (!buffPtrIncrementSafe(sizeof(uint8_t))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; + return false; + } + if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } + m_vendor_data = (uint8_t*)m_buff_ptr__; + if (m_length && m_parse__) { + size_t len = *m_length; + tlvf_swap(16, reinterpret_cast(&len)); + len -= (m_buff_ptr__ - sizeof(*m_type) - sizeof(*m_length) - m_buff__); + m_vendor_data_idx__ = len/sizeof(uint8_t); + if (!buffPtrIncrementSafe(len)) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << len << ") Failed!"; + return false; + } + } + if (m_parse__) { class_swap(); } + return true; +} + cConfigData::cConfigData(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); From 862cbf4dd84d28490ad50de5173c72e87be7d970 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Wed, 8 Jul 2020 13:53:33 +0200 Subject: [PATCH 175/453] tlvf: add getAttrList() method Currently there is a getAttr() method in class AttrList to get an attribute of a given type. However, message can include several Vendor Extension attributes so we need a AttrList::getAttrList() method to get all of them. Later we will iterate over all Vendor Extension attributes in the list until we find one that matches the WFA ID. Signed-off-by: Mario Maz --- framework/tlvf/src/include/tlvf/WSC/AttrList.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/framework/tlvf/src/include/tlvf/WSC/AttrList.h b/framework/tlvf/src/include/tlvf/WSC/AttrList.h index 0cdfc00a01..c67fb35f6d 100644 --- a/framework/tlvf/src/include/tlvf/WSC/AttrList.h +++ b/framework/tlvf/src/include/tlvf/WSC/AttrList.h @@ -35,6 +35,10 @@ class AttrList : public ClassList { virtual ~AttrList() = default; bool init(); + template std::list> getAttrList() const + { + return this->getClassList(); + }; template std::shared_ptr getAttr() const { return this->getClass(); }; template std::shared_ptr addAttr() { return this->addClass(); }; bool finalize() { return ClassList::finalize(); }; From e95e097a14643c8fa66e5f147816a408f40465f3 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Thu, 2 Jul 2020 19:17:57 +0200 Subject: [PATCH 176/453] tlfv: use new WSC Vendor Extension class We currently have multiple attributes and classes all with the same attribute type - vendor extension attribute - `sWscAttrVersion2`, `sWscAttrVendorExtMultiAp`, `cWscVendorExtWfa`, and `cWscAttrVersion2`. All are basically wrong since they do not support the generic vendor extension attribute which does not necessarily have to be WFA vendor extension. Modify config_data, m1 and m2 messages to use the new WSC Vendor Extension class. Add Version2 subelement as the first subelement in the config data WFA Vendor Extension where the second subelement is the MultiAP Identifier subelement according to the WSC specification. Signed-off-by: Mario Maz --- .../tlvf/src/include/tlvf/WSC/configData.h | 37 ++++++++++++++++++- framework/tlvf/src/src/WSC/AttrList.cpp | 4 +- framework/tlvf/src/src/WSC/configData.cpp | 32 +++++++++++++--- framework/tlvf/src/src/WSC/m1.cpp | 23 +++++++----- framework/tlvf/src/src/WSC/m2.cpp | 19 ++++++++-- 5 files changed, 93 insertions(+), 22 deletions(-) diff --git a/framework/tlvf/src/include/tlvf/WSC/configData.h b/framework/tlvf/src/include/tlvf/WSC/configData.h index 96ccb0991e..8f105cb5e8 100644 --- a/framework/tlvf/src/include/tlvf/WSC/configData.h +++ b/framework/tlvf/src/include/tlvf/WSC/configData.h @@ -10,6 +10,9 @@ #define _TLVF_WSC_CONFIGDATA_H_ #include +#include + +#include namespace WSC { @@ -60,7 +63,39 @@ class configData : public AttrList { auto attr = getAttr(); return attr ? attr->data() : sMacAddr(); }; - uint8_t bss_type() const { return getAttr()->subelement_value(); }; + eWscVendorExtSubelementBssType bss_type() const + { + constexpr eWscVendorExtSubelementBssType default_value = + eWscVendorExtSubelementBssType::TEARDOWN; + + // Iterate over all Vendor Extension attributes until we find one that matches the WFA ID. + for (auto &vendor_ext_attr : getAttrList()) { + + // Skip Vendor Extension attribute if it is not a WFA Vendor Extension attribute + if ((eWscVendorId::WSC_VENDOR_ID_WFA_1 != vendor_ext_attr->vendor_id_0()) || + (eWscVendorId::WSC_VENDOR_ID_WFA_2 != vendor_ext_attr->vendor_id_1()) || + (eWscVendorId::WSC_VENDOR_ID_WFA_3 != vendor_ext_attr->vendor_id_2())) { + continue; + } + + size_t index = 0; + auto vendor_data = vendor_ext_attr->vendor_data(); + while ((index + sizeof(sWscWfaVendorExtSubelementMultiApIdentifier)) <= + vendor_ext_attr->vendor_data_length()) { + auto subelement_type = static_cast(vendor_data[index]); + auto subelement_length = vendor_data[index + 1]; + if ((eWscWfaVendorExtSubelement::MULTI_AP_IDENTIFIER == subelement_type) && + (1 == subelement_length)) { + return static_cast(vendor_data[index + 2]); + } + + // Skip this subelement + index += 2 + subelement_length; + } + } + + return default_value; + }; }; } // namespace WSC diff --git a/framework/tlvf/src/src/WSC/AttrList.cpp b/framework/tlvf/src/src/WSC/AttrList.cpp index cd239bbc31..5474c3731d 100644 --- a/framework/tlvf/src/src/WSC/AttrList.cpp +++ b/framework/tlvf/src/src/WSC/AttrList.cpp @@ -143,8 +143,8 @@ bool AttrList::init() } break; case ATTR_VENDOR_EXTENSION: - if (!addAttr()) { - TLVF_LOG(ERROR) << "Failed to add cWscVendorExtWfa"; + if (!addAttr()) { + TLVF_LOG(ERROR) << "Failed to add cWscAttrVendorExtension"; return false; } break; diff --git a/framework/tlvf/src/src/WSC/configData.cpp b/framework/tlvf/src/src/WSC/configData.cpp index 0dbf7d9148..1aae7d350d 100644 --- a/framework/tlvf/src/src/WSC/configData.cpp +++ b/framework/tlvf/src/src/WSC/configData.cpp @@ -8,7 +8,6 @@ #include #include -#include using namespace WSC; @@ -81,12 +80,33 @@ bool configData::init(const config &cfg) } bssid_attr->data() = cfg.bssid; - auto vendor_ext_attr = addAttr(); + auto vendor_ext_attr = addAttr(); if (!vendor_ext_attr) { - TLVF_LOG(ERROR) << "addAttr failed"; + TLVF_LOG(ERROR) << "addAttr failed"; return false; } - vendor_ext_attr->subelement_value() = cfg.bss_type; + + // WFA Vendor Data + const size_t vendor_data_size = sizeof(sWscWfaVendorExtSubelementVersion2) + + sizeof(sWscWfaVendorExtSubelementMultiApIdentifier); + if (!vendor_ext_attr->alloc_vendor_data(vendor_data_size)) { + LOG(ERROR) << "Failed to allocate vendor data [" << vendor_data_size << "]!"; + return false; + } + auto vendor_data = vendor_ext_attr->vendor_data(); + + // WFA Vendor Extension Subelement at #0: Version2 + size_t index = 0; + sWscWfaVendorExtSubelementVersion2 version2{eWscWfaVendorExtSubelement::VERSION2, 0x01, + eWscVendorExtVersionIE::WSC_VERSION2}; + std::copy_n(reinterpret_cast(&version2), sizeof(version2), &vendor_data[index]); + + // WFA Vendor Extension Subelement at #1: Multi-AP Identifier + index += sizeof(version2); + sWscWfaVendorExtSubelementMultiApIdentifier multi_ap_identifier{ + eWscWfaVendorExtSubelement::MULTI_AP_IDENTIFIER, 0x01, cfg.bss_type}; + std::copy_n(reinterpret_cast(&multi_ap_identifier), sizeof(multi_ap_identifier), + &vendor_data[index]); return true; } @@ -94,8 +114,8 @@ bool configData::init(const config &cfg) bool configData::valid() const { bool valid = true; - if (!getAttr()) { - TLVF_LOG(ERROR) << "getAttr failed"; + if (!getAttr()) { + TLVF_LOG(ERROR) << "getAttr failed"; valid = false; } if (!getAttr()) { diff --git a/framework/tlvf/src/src/WSC/m1.cpp b/framework/tlvf/src/src/WSC/m1.cpp index 901572811c..5febe5cbfb 100644 --- a/framework/tlvf/src/src/WSC/m1.cpp +++ b/framework/tlvf/src/src/WSC/m1.cpp @@ -204,21 +204,24 @@ bool m1::init(const config &cfg) return false; } - auto vendor_ext_attr = addAttr(); + auto vendor_ext_attr = addAttr(); if (!vendor_ext_attr) { - TLVF_LOG(ERROR) << "addAttr failed"; + TLVF_LOG(ERROR) << "addAttr failed"; return false; } - if (!vendor_ext_attr->alloc_vs_data(sizeof(sWscAttrVersion2))) { - LOG(ERROR) << "buffer allocation failed for version2 attribute"; + // WFA Vendor Data + const size_t vendor_data_size = sizeof(sWscWfaVendorExtSubelementVersion2); + if (!vendor_ext_attr->alloc_vendor_data(vendor_data_size)) { + LOG(ERROR) << "Failed to allocate vendor data [" << vendor_data_size << "]!"; return false; } + auto vendor_data = vendor_ext_attr->vendor_data(); - sWscAttrVersion2 version2; - version2.struct_swap(); - uint8_t *version2_buf = reinterpret_cast(&version2); - std::copy(version2_buf, version2_buf + sizeof(version2), vendor_ext_attr->vs_data()); + // WFA Vendor Extension Subelement at #0: Version2 + sWscWfaVendorExtSubelementVersion2 version2{eWscWfaVendorExtSubelement::VERSION2, 0x01, + eWscVendorExtVersionIE::WSC_VERSION2}; + std::copy_n(reinterpret_cast(&version2), sizeof(version2), vendor_data); return true; } @@ -309,8 +312,8 @@ bool m1::valid() const TLVF_LOG(ERROR) << "getAttr failed"; return false; } - if (!getAttr()) { - TLVF_LOG(ERROR) << "getAttr failed"; + if (!getAttr()) { + TLVF_LOG(ERROR) << "getAttr failed"; return false; } return true; diff --git a/framework/tlvf/src/src/WSC/m2.cpp b/framework/tlvf/src/src/WSC/m2.cpp index 19b5b22848..55f4fcfe27 100644 --- a/framework/tlvf/src/src/WSC/m2.cpp +++ b/framework/tlvf/src/src/WSC/m2.cpp @@ -193,12 +193,25 @@ bool m2::init(const config &cfg) return false; } - auto version2_attr = addAttr(); - if (!version2_attr) { - TLVF_LOG(ERROR) << "addAttr failed"; + auto vendor_ext_attr = addAttr(); + if (!vendor_ext_attr) { + TLVF_LOG(ERROR) << "addAttr failed"; return false; } + // WFA Vendor Data + const size_t vendor_data_size = sizeof(sWscWfaVendorExtSubelementVersion2); + if (!vendor_ext_attr->alloc_vendor_data(vendor_data_size)) { + LOG(ERROR) << "Failed to allocate vendor data [" << vendor_data_size << "]!"; + return false; + } + auto vendor_data = vendor_ext_attr->vendor_data(); + + // WFA Vendor Extension Subelement at #0: Version2 + sWscWfaVendorExtSubelementVersion2 version2{eWscWfaVendorExtSubelement::VERSION2, 0x01, + eWscVendorExtVersionIE::WSC_VERSION2}; + std::copy_n(reinterpret_cast(&version2), sizeof(version2), vendor_data); + auto encrypted_settings = addAttr(); if (!encrypted_settings) { TLVF_LOG(ERROR) << "addAttr failed"; From ab14d60063a6a78bc6e5f8402d5cd6b2602c3e01 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Wed, 1 Jul 2020 18:21:26 +0200 Subject: [PATCH 177/453] agent: slave: remove unnecessary cast Signed-off-by: Mario Maz --- agent/src/beerocks/slave/son_slave_thread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index f9def7e844..170c2ff657 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -3943,7 +3943,7 @@ bool slave_thread::autoconfig_wsc_parse_m2_encrypted_settings(WSC::m2 &m2, uint8 config.bssid = config_data->bssid(); config.network_key = config_data->network_key(); config.ssid = config_data->ssid(); - config.bss_type = static_cast(config_data->bss_type()); + config.bss_type = config_data->bss_type(); // Swap to network byte order for KWA HMAC calculation // from this point config data is not readable! config_data->swap(); From 744fe0f5103352da66e7eb39347ea1c6a78f5b39 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Wed, 1 Jul 2020 18:29:52 +0200 Subject: [PATCH 178/453] tlvf: remove unused deprecated classes and structs Remove the following unused deprecated classes and structs: - sWscAttrVersion2 - cWscAttrVersion2 - sWscAttrVendorExtMultiAp - cWscVendorExtWfa Signed-off-by: Mario Maz --- .../tlvf/yaml/tlvf/WSC/WSC_Attributes.yaml | 114 ------------------ 1 file changed, 114 deletions(-) diff --git a/framework/tlvf/yaml/tlvf/WSC/WSC_Attributes.yaml b/framework/tlvf/yaml/tlvf/WSC/WSC_Attributes.yaml index 886c935eda..0748ade4d5 100644 --- a/framework/tlvf/yaml/tlvf/WSC/WSC_Attributes.yaml +++ b/framework/tlvf/yaml/tlvf/WSC/WSC_Attributes.yaml @@ -11,60 +11,6 @@ _include: { } _namespace: WSC -sWscAttrVersion2: - _type: struct - attribute_type: - _type: eWscAttributes - _value: ATTR_VENDOR_EXTENSION - data_length: - _type: uint16_t - _value: WSC_VENDOR_EXTENSIONS_LENGTH - vendor_id_0: - _type: uint8_t - _value: WSC_VENDOR_ID_WFA_1 - vendor_id_1: - _type: uint8_t - _value: WSC_VENDOR_ID_WFA_2 - vendor_id_2: - _type: uint8_t - _value: WSC_VENDOR_ID_WFA_3 - subelement_id: - _type: uint8_t - _value: 0x0 - subelement_length: - _type: uint8_t - _value: 0x1 - subelement_value: - _type: uint8_t - _value: WSC_VERSION2 - -sWscAttrVendorExtMultiAp: - _type: struct - attribute_type: - _type: eWscAttributes - _value: ATTR_VENDOR_EXTENSION - data_length: - _type: uint16_t - _value: WSC_VENDOR_EXTENSIONS_LENGTH - vendor_id_0: - _type: uint8_t - _value: WSC_VENDOR_ID_WFA_1 - vendor_id_1: - _type: uint8_t - _value: WSC_VENDOR_ID_WFA_2 - vendor_id_2: - _type: uint8_t - _value: WSC_VENDOR_ID_WFA_3 - subelement_id: - _type: uint8_t - _value: 0x6 - subelement_length: - _type: uint8_t - _value: 0x1 - subelement_value: - _type: uint8_t - _value: TEARDOWN - sWscAttrKeyWrapAuthenticator: _type: struct attribute_type: @@ -185,7 +131,6 @@ cConfigData: _length: [ network_key_length ] _length_max: WSC_MAX_NETWORK_KEY_LENGTH bssid_attr: sWscAttrBssid - multiap_attr: sWscAttrVendorExtMultiAp bss_type: _type: uint8_t _value: TEARDOWN @@ -206,37 +151,6 @@ cWscAttrEncryptedSettings: _type: char _length: [] -cWscVendorExtWfa: - _type: class - _is_tlv_class: True - type: - _type: eWscAttributes - _value: ATTR_VENDOR_EXTENSION - length: - _type: uint16_t - _length_var: True - vendor_id_0: - _type: uint8_t - _value: WSC_VENDOR_ID_WFA_1 - vendor_id_1: - _type: uint8_t - _value: WSC_VENDOR_ID_WFA_2 - vendor_id_2: - _type: uint8_t - _value: WSC_VENDOR_ID_WFA_3 - subelement_id: - _type: uint8_t - _value: 0x6 - subelement_length: - _type: uint8_t - _value: 0x1 - subelement_value: - _type: uint8_t - _value: TEARDOWN - vs_data: - _type: uint8_t - _length: [] - cWscAttrVersion: _type: class _is_tlv_class: True @@ -564,34 +478,6 @@ cWscAttrRegistrarNonce: _type: uint8_t _length: [ WSC_NONCE_LENGTH ] -cWscAttrVersion2: - _type: class - _is_tlv_class: True - type: - _type: eWscAttributes - _value: ATTR_VENDOR_EXTENSION - length: - _type: uint16_t - _value_const: WSC_VENDOR_EXTENSIONS_LENGTH - vendor_id_0: - _type: uint8_t - _value: WSC_VENDOR_ID_WFA_1 - vendor_id_1: - _type: uint8_t - _value: WSC_VENDOR_ID_WFA_2 - vendor_id_2: - _type: uint8_t - _value: WSC_VENDOR_ID_WFA_3 - subelement_id: - _type: uint8_t - _value: 0x0 - subelement_length: - _type: uint8_t - _value: 0x1 - subelement_value: - _type: uint8_t - _value: WSC_VERSION2 - cWscAttrSsid: _type: class _is_tlv_class: True From d21ebdc92e179ce97aba5b5ee4a1203f803d56b3 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Thu, 2 Jul 2020 19:50:27 +0200 Subject: [PATCH 179/453] tlvf: Update auto-generated files Signed-off-by: Mario Maz --- .../include/tlvf/WSC/WSC_Attributes.h | 123 ------ .../src/tlvf/WSC/WSC_Attributes.cpp | 376 ------------------ 2 files changed, 499 deletions(-) diff --git a/framework/tlvf/AutoGenerated/include/tlvf/WSC/WSC_Attributes.h b/framework/tlvf/AutoGenerated/include/tlvf/WSC/WSC_Attributes.h index 7bc3924542..628bc88ece 100644 --- a/framework/tlvf/AutoGenerated/include/tlvf/WSC/WSC_Attributes.h +++ b/framework/tlvf/AutoGenerated/include/tlvf/WSC/WSC_Attributes.h @@ -42,7 +42,6 @@ namespace WSC { class cConfigData; class cWscAttrEncryptedSettings; -class cWscVendorExtWfa; class cWscAttrVersion; class cWscAttrMessageType; class cWscAttrEnrolleeNonce; @@ -68,61 +67,10 @@ class cWscAttrWscState; class cWscAttrUuidR; class cWscAttrAuthenticator; class cWscAttrRegistrarNonce; -class cWscAttrVersion2; class cWscAttrSsid; class cWscAttrAuthenticationType; class cWscAttrEncryptionType; class cWscAttrNetworkKey; -typedef struct sWscAttrVersion2 { - eWscAttributes attribute_type; - uint16_t data_length; - uint8_t vendor_id_0; - uint8_t vendor_id_1; - uint8_t vendor_id_2; - uint8_t subelement_id; - uint8_t subelement_length; - uint8_t subelement_value; - void struct_swap(){ - tlvf_swap(16, reinterpret_cast(&attribute_type)); - tlvf_swap(16, reinterpret_cast(&data_length)); - } - void struct_init(){ - attribute_type = ATTR_VENDOR_EXTENSION; - data_length = WSC_VENDOR_EXTENSIONS_LENGTH; - vendor_id_0 = WSC_VENDOR_ID_WFA_1; - vendor_id_1 = WSC_VENDOR_ID_WFA_2; - vendor_id_2 = WSC_VENDOR_ID_WFA_3; - subelement_id = 0x0; - subelement_length = 0x1; - subelement_value = WSC_VERSION2; - } -} __attribute__((packed)) sWscAttrVersion2; - -typedef struct sWscAttrVendorExtMultiAp { - eWscAttributes attribute_type; - uint16_t data_length; - uint8_t vendor_id_0; - uint8_t vendor_id_1; - uint8_t vendor_id_2; - uint8_t subelement_id; - uint8_t subelement_length; - uint8_t subelement_value; - void struct_swap(){ - tlvf_swap(16, reinterpret_cast(&attribute_type)); - tlvf_swap(16, reinterpret_cast(&data_length)); - } - void struct_init(){ - attribute_type = ATTR_VENDOR_EXTENSION; - data_length = WSC_VENDOR_EXTENSIONS_LENGTH; - vendor_id_0 = WSC_VENDOR_ID_WFA_1; - vendor_id_1 = WSC_VENDOR_ID_WFA_2; - vendor_id_2 = WSC_VENDOR_ID_WFA_3; - subelement_id = 0x6; - subelement_length = 0x1; - subelement_value = TEARDOWN; - } -} __attribute__((packed)) sWscAttrVendorExtMultiAp; - typedef struct sWscAttrKeyWrapAuthenticator { eWscAttributes attribute_type; uint16_t data_length; @@ -267,7 +215,6 @@ class cConfigData : public BaseClass bool set_network_key(const char buffer[], size_t size); bool alloc_network_key(size_t count = 1); sWscAttrBssid& bssid_attr(); - sWscAttrVendorExtMultiAp& multiap_attr(); uint8_t& bss_type(); void class_swap() override; bool finalize() override; @@ -287,7 +234,6 @@ class cConfigData : public BaseClass char* m_network_key = nullptr; size_t m_network_key_idx__ = 0; sWscAttrBssid* m_bssid_attr = nullptr; - sWscAttrVendorExtMultiAp* m_multiap_attr = nullptr; uint8_t* m_bss_type = nullptr; }; @@ -325,44 +271,6 @@ class cWscAttrEncryptedSettings : public BaseClass size_t m_encrypted_settings_idx__ = 0; }; -class cWscVendorExtWfa : public BaseClass -{ - public: - cWscVendorExtWfa(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cWscVendorExtWfa(std::shared_ptr base, bool parse = false); - ~cWscVendorExtWfa(); - - eWscAttributes& type(); - const uint16_t& length(); - uint8_t& vendor_id_0(); - uint8_t& vendor_id_1(); - uint8_t& vendor_id_2(); - uint8_t& subelement_id(); - uint8_t& subelement_length(); - uint8_t& subelement_value(); - size_t vs_data_length() { return m_vs_data_idx__ * sizeof(uint8_t); } - uint8_t* vs_data(size_t idx = 0); - bool set_vs_data(const void* buffer, size_t size); - bool alloc_vs_data(size_t count = 1); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eWscAttributes* m_type = nullptr; - uint16_t* m_length = nullptr; - uint8_t* m_vendor_id_0 = nullptr; - uint8_t* m_vendor_id_1 = nullptr; - uint8_t* m_vendor_id_2 = nullptr; - uint8_t* m_subelement_id = nullptr; - uint8_t* m_subelement_length = nullptr; - uint8_t* m_subelement_value = nullptr; - uint8_t* m_vs_data = nullptr; - size_t m_vs_data_idx__ = 0; - int m_lock_order_counter__ = 0; -}; - class cWscAttrVersion : public BaseClass { public: @@ -945,37 +853,6 @@ class cWscAttrRegistrarNonce : public BaseClass int m_lock_order_counter__ = 0; }; -class cWscAttrVersion2 : public BaseClass -{ - public: - cWscAttrVersion2(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cWscAttrVersion2(std::shared_ptr base, bool parse = false); - ~cWscAttrVersion2(); - - eWscAttributes& type(); - const uint16_t& length(); - uint8_t& vendor_id_0(); - uint8_t& vendor_id_1(); - uint8_t& vendor_id_2(); - uint8_t& subelement_id(); - uint8_t& subelement_length(); - uint8_t& subelement_value(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eWscAttributes* m_type = nullptr; - uint16_t* m_length = nullptr; - uint8_t* m_vendor_id_0 = nullptr; - uint8_t* m_vendor_id_1 = nullptr; - uint8_t* m_vendor_id_2 = nullptr; - uint8_t* m_subelement_id = nullptr; - uint8_t* m_subelement_length = nullptr; - uint8_t* m_subelement_value = nullptr; -}; - class cWscAttrSsid : public BaseClass { public: diff --git a/framework/tlvf/AutoGenerated/src/tlvf/WSC/WSC_Attributes.cpp b/framework/tlvf/AutoGenerated/src/tlvf/WSC/WSC_Attributes.cpp index 8567d1c80b..415eb9aeee 100644 --- a/framework/tlvf/AutoGenerated/src/tlvf/WSC/WSC_Attributes.cpp +++ b/framework/tlvf/AutoGenerated/src/tlvf/WSC/WSC_Attributes.cpp @@ -260,7 +260,6 @@ bool cConfigData::alloc_ssid(size_t count) { m_network_key_length = (uint16_t *)((uint8_t *)(m_network_key_length) + len); m_network_key = (char *)((uint8_t *)(m_network_key) + len); m_bssid_attr = (sWscAttrBssid *)((uint8_t *)(m_bssid_attr) + len); - m_multiap_attr = (sWscAttrVendorExtMultiAp *)((uint8_t *)(m_multiap_attr) + len); m_bss_type = (uint8_t *)((uint8_t *)(m_bss_type) + len); m_ssid_idx__ += count; *m_ssid_length += count; @@ -337,7 +336,6 @@ bool cConfigData::alloc_network_key(size_t count) { std::copy_n(src, move_length, dst); } m_bssid_attr = (sWscAttrBssid *)((uint8_t *)(m_bssid_attr) + len); - m_multiap_attr = (sWscAttrVendorExtMultiAp *)((uint8_t *)(m_multiap_attr) + len); m_bss_type = (uint8_t *)((uint8_t *)(m_bss_type) + len); m_network_key_idx__ += count; *m_network_key_length += count; @@ -352,10 +350,6 @@ sWscAttrBssid& cConfigData::bssid_attr() { return (sWscAttrBssid&)(*m_bssid_attr); } -sWscAttrVendorExtMultiAp& cConfigData::multiap_attr() { - return (sWscAttrVendorExtMultiAp&)(*m_multiap_attr); -} - uint8_t& cConfigData::bss_type() { return (uint8_t&)(*m_bss_type); } @@ -369,7 +363,6 @@ void cConfigData::class_swap() tlvf_swap(16, reinterpret_cast(m_network_key_type)); tlvf_swap(16, reinterpret_cast(m_network_key_length)); m_bssid_attr->struct_swap(); - m_multiap_attr->struct_swap(); } bool cConfigData::finalize() @@ -409,7 +402,6 @@ size_t cConfigData::get_initial_size() class_size += sizeof(eWscAttributes); // network_key_type class_size += sizeof(uint16_t); // network_key_length class_size += sizeof(sWscAttrBssid); // bssid_attr - class_size += sizeof(sWscAttrVendorExtMultiAp); // multiap_attr class_size += sizeof(uint8_t); // bss_type return class_size; } @@ -478,12 +470,6 @@ bool cConfigData::init() return false; } if (!m_parse__) { m_bssid_attr->struct_init(); } - m_multiap_attr = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sWscAttrVendorExtMultiAp))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sWscAttrVendorExtMultiAp) << ") Failed!"; - return false; - } - if (!m_parse__) { m_multiap_attr->struct_init(); } m_bss_type = reinterpret_cast(m_buff_ptr__); if (!m_parse__) *m_bss_type = TEARDOWN; if (!buffPtrIncrementSafe(sizeof(uint8_t))) { @@ -680,214 +666,6 @@ bool cWscAttrEncryptedSettings::init() return true; } -cWscVendorExtWfa::cWscVendorExtWfa(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cWscVendorExtWfa::cWscVendorExtWfa(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cWscVendorExtWfa::~cWscVendorExtWfa() { -} -eWscAttributes& cWscVendorExtWfa::type() { - return (eWscAttributes&)(*m_type); -} - -const uint16_t& cWscVendorExtWfa::length() { - return (const uint16_t&)(*m_length); -} - -uint8_t& cWscVendorExtWfa::vendor_id_0() { - return (uint8_t&)(*m_vendor_id_0); -} - -uint8_t& cWscVendorExtWfa::vendor_id_1() { - return (uint8_t&)(*m_vendor_id_1); -} - -uint8_t& cWscVendorExtWfa::vendor_id_2() { - return (uint8_t&)(*m_vendor_id_2); -} - -uint8_t& cWscVendorExtWfa::subelement_id() { - return (uint8_t&)(*m_subelement_id); -} - -uint8_t& cWscVendorExtWfa::subelement_length() { - return (uint8_t&)(*m_subelement_length); -} - -uint8_t& cWscVendorExtWfa::subelement_value() { - return (uint8_t&)(*m_subelement_value); -} - -uint8_t* cWscVendorExtWfa::vs_data(size_t idx) { - if ( (m_vs_data_idx__ == 0) || (m_vs_data_idx__ <= idx) ) { - TLVF_LOG(ERROR) << "Requested index is greater than the number of available entries"; - return nullptr; - } - return &(m_vs_data[idx]); -} - -bool cWscVendorExtWfa::set_vs_data(const void* buffer, size_t size) { - if (buffer == nullptr) { - TLVF_LOG(WARNING) << "set_vs_data received a null pointer."; - return false; - } - if (!alloc_vs_data(size)) { return false; } - std::copy_n(reinterpret_cast(buffer), size, m_vs_data); - return true; -} -bool cWscVendorExtWfa::alloc_vs_data(size_t count) { - if (m_lock_order_counter__ > 0) {; - TLVF_LOG(ERROR) << "Out of order allocation for variable length list vs_data, abort!"; - return false; - } - size_t len = sizeof(uint8_t) * count; - if(getBuffRemainingBytes() < len ) { - TLVF_LOG(ERROR) << "Not enough available space on buffer - can't allocate"; - return false; - } - m_lock_order_counter__ = 0; - uint8_t *src = (uint8_t *)m_vs_data; - uint8_t *dst = src + len; - if (!m_parse__) { - size_t move_length = getBuffRemainingBytes(src) - len; - std::copy_n(src, move_length, dst); - } - m_vs_data_idx__ += count; - if (!buffPtrIncrementSafe(len)) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << len << ") Failed!"; - return false; - } - if(m_length){ (*m_length) += len; } - return true; -} - -void cWscVendorExtWfa::class_swap() -{ - tlvf_swap(16, reinterpret_cast(m_type)); - tlvf_swap(16, reinterpret_cast(m_length)); -} - -bool cWscVendorExtWfa::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - *m_length -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cWscVendorExtWfa::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(eWscAttributes); // type - class_size += sizeof(uint16_t); // length - class_size += sizeof(uint8_t); // vendor_id_0 - class_size += sizeof(uint8_t); // vendor_id_1 - class_size += sizeof(uint8_t); // vendor_id_2 - class_size += sizeof(uint8_t); // subelement_id - class_size += sizeof(uint8_t); // subelement_length - class_size += sizeof(uint8_t); // subelement_value - return class_size; -} - -bool cWscVendorExtWfa::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_type = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_type = ATTR_VENDOR_EXTENSION; - if (!buffPtrIncrementSafe(sizeof(eWscAttributes))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(eWscAttributes) << ") Failed!"; - return false; - } - m_length = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_length = 0; - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_vendor_id_0 = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_vendor_id_0 = WSC_VENDOR_ID_WFA_1; - if (!buffPtrIncrementSafe(sizeof(uint8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; - return false; - } - if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } - m_vendor_id_1 = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_vendor_id_1 = WSC_VENDOR_ID_WFA_2; - if (!buffPtrIncrementSafe(sizeof(uint8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; - return false; - } - if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } - m_vendor_id_2 = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_vendor_id_2 = WSC_VENDOR_ID_WFA_3; - if (!buffPtrIncrementSafe(sizeof(uint8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; - return false; - } - if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } - m_subelement_id = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_subelement_id = 0x6; - if (!buffPtrIncrementSafe(sizeof(uint8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; - return false; - } - if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } - m_subelement_length = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_subelement_length = 0x1; - if (!buffPtrIncrementSafe(sizeof(uint8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; - return false; - } - if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } - m_subelement_value = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_subelement_value = TEARDOWN; - if (!buffPtrIncrementSafe(sizeof(uint8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; - return false; - } - if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } - m_vs_data = (uint8_t*)m_buff_ptr__; - if (m_length && m_parse__) { - size_t len = *m_length; - tlvf_swap(16, reinterpret_cast(&len)); - len -= (m_buff_ptr__ - sizeof(*m_type) - sizeof(*m_length) - m_buff__); - m_vs_data_idx__ = len/sizeof(uint8_t); - if (!buffPtrIncrementSafe(len)) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << len << ") Failed!"; - return false; - } - } - if (m_parse__) { class_swap(); } - return true; -} - cWscAttrVersion::cWscAttrVersion(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); @@ -3624,160 +3402,6 @@ bool cWscAttrRegistrarNonce::init() return true; } -cWscAttrVersion2::cWscAttrVersion2(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cWscAttrVersion2::cWscAttrVersion2(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cWscAttrVersion2::~cWscAttrVersion2() { -} -eWscAttributes& cWscAttrVersion2::type() { - return (eWscAttributes&)(*m_type); -} - -const uint16_t& cWscAttrVersion2::length() { - return (const uint16_t&)(*m_length); -} - -uint8_t& cWscAttrVersion2::vendor_id_0() { - return (uint8_t&)(*m_vendor_id_0); -} - -uint8_t& cWscAttrVersion2::vendor_id_1() { - return (uint8_t&)(*m_vendor_id_1); -} - -uint8_t& cWscAttrVersion2::vendor_id_2() { - return (uint8_t&)(*m_vendor_id_2); -} - -uint8_t& cWscAttrVersion2::subelement_id() { - return (uint8_t&)(*m_subelement_id); -} - -uint8_t& cWscAttrVersion2::subelement_length() { - return (uint8_t&)(*m_subelement_length); -} - -uint8_t& cWscAttrVersion2::subelement_value() { - return (uint8_t&)(*m_subelement_value); -} - -void cWscAttrVersion2::class_swap() -{ - tlvf_swap(16, reinterpret_cast(m_type)); - tlvf_swap(16, reinterpret_cast(m_length)); -} - -bool cWscAttrVersion2::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - *m_length -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cWscAttrVersion2::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(eWscAttributes); // type - class_size += sizeof(uint16_t); // length - class_size += sizeof(uint8_t); // vendor_id_0 - class_size += sizeof(uint8_t); // vendor_id_1 - class_size += sizeof(uint8_t); // vendor_id_2 - class_size += sizeof(uint8_t); // subelement_id - class_size += sizeof(uint8_t); // subelement_length - class_size += sizeof(uint8_t); // subelement_value - return class_size; -} - -bool cWscAttrVersion2::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_type = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_type = ATTR_VENDOR_EXTENSION; - if (!buffPtrIncrementSafe(sizeof(eWscAttributes))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(eWscAttributes) << ") Failed!"; - return false; - } - m_length = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_length = 0; - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_vendor_id_0 = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_vendor_id_0 = WSC_VENDOR_ID_WFA_1; - if (!buffPtrIncrementSafe(sizeof(uint8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; - return false; - } - if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } - m_vendor_id_1 = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_vendor_id_1 = WSC_VENDOR_ID_WFA_2; - if (!buffPtrIncrementSafe(sizeof(uint8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; - return false; - } - if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } - m_vendor_id_2 = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_vendor_id_2 = WSC_VENDOR_ID_WFA_3; - if (!buffPtrIncrementSafe(sizeof(uint8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; - return false; - } - if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } - m_subelement_id = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_subelement_id = 0x0; - if (!buffPtrIncrementSafe(sizeof(uint8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; - return false; - } - if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } - m_subelement_length = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_subelement_length = 0x1; - if (!buffPtrIncrementSafe(sizeof(uint8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; - return false; - } - if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } - m_subelement_value = reinterpret_cast(m_buff_ptr__); - if (!m_parse__) *m_subelement_value = WSC_VERSION2; - if (!buffPtrIncrementSafe(sizeof(uint8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; - return false; - } - if(m_length && !m_parse__){ (*m_length) += sizeof(uint8_t); } - if (m_parse__) { class_swap(); } - return true; -} - cWscAttrSsid::cWscAttrSsid(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); From 6bc66e8090adb870ac3c85746b8c4a5bb968cecf Mon Sep 17 00:00:00 2001 From: Vitalii Komisarenko Date: Wed, 8 Jul 2020 12:45:47 +0300 Subject: [PATCH 180/453] bcl: socket_thread: exit potentially endless loop on shutdown beerocks_socket_thread has a `work` method that among other things queries all its sockets in a loop. If this operation returns error on any of its sockets the loop starts from the beginning. According to the comments it is done so because sockets can be removed from the vector thus invalidating the iterator. If one of the sockets for some reason starts returning error code all the time the loop will be endless. This commit adds a check to quit this loop on socket thread shutdown. It is a very crude fix, but it is should be enough for the time being. Socket thread will be most likely refactored/redesigned in the nearest future. Signed-off-by: Vitalii Komisarenko --- common/beerocks/bcl/source/beerocks_socket_thread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/beerocks/bcl/source/beerocks_socket_thread.cpp b/common/beerocks/bcl/source/beerocks_socket_thread.cpp index 3f73f163f8..ba6e479373 100644 --- a/common/beerocks/bcl/source/beerocks_socket_thread.cpp +++ b/common/beerocks/bcl/source/beerocks_socket_thread.cpp @@ -349,6 +349,6 @@ bool socket_thread::work() } // The loop should go over all the sockets. In case something break the for loop before it ended, // start iterating over the sockets again. - } while (i < sockets_count); + } while ((i < sockets_count) && !should_stop); return true; } From 4d7d997f7ccc4abb3b9615a83e45de475cd54f60 Mon Sep 17 00:00:00 2001 From: Vitalii Komisarenko Date: Wed, 8 Jul 2020 12:58:14 +0300 Subject: [PATCH 181/453] bcl: thread_base: call before_stop method of appropriate class Jira issue ID: https://jira.prplfoundation.org/browse/PPM-7 The OOP stucture of beerocks_thread_base class and its descendants has been corrupted. The `stop` method is expected to call `before_stop` method of the same class, but due to a mistake `before_stop` of the base class was called. As a result, asynchronous work queues could block infinitely. It resulted in prplMesh being unable to terminate on receipt of SIGTERM. Signed-off-by: Vitalii Komisarenko --- common/beerocks/bcl/source/beerocks_thread_base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/beerocks/bcl/source/beerocks_thread_base.cpp b/common/beerocks/bcl/source/beerocks_thread_base.cpp index 0d4f3b537f..f8674e17a7 100644 --- a/common/beerocks/bcl/source/beerocks_thread_base.cpp +++ b/common/beerocks/bcl/source/beerocks_thread_base.cpp @@ -43,7 +43,7 @@ void thread_base::join() void thread_base::stop(bool block) { should_stop = true; - thread_base::before_stop(); + before_stop(); if (block) { join(); } From 0ca7ed0dbbb45a5ec8957241904b8ffe05e9938f Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Wed, 8 Jul 2020 13:54:01 +0200 Subject: [PATCH 182/453] CODEOWNERS: add Mario as a code owner With Tomer leaving, we need an additional code owner for final approval of PRs. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 2186541589..2975166513 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @tomereli @arnout @morantr @rmelotte @vitalybu @kantera800 +* @tomereli @arnout @mariomaz @morantr @rmelotte @vitalybu @kantera800 From eb0b904e4fc4421e9e0d757950085f4ed24c8a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Tue, 7 Jul 2020 11:26:38 +0200 Subject: [PATCH 183/453] deploy_firmware.py: don't fail on EOF when device is not reachable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After a successful upgrade and when the device is not yet reachable, the script sometimes reaches a pexpect.exceptions.EOF and fail. See for example: https://gitlab.com/prpl-foundation/prplMesh/-/jobs/626283944 If a pexpect.exceptions.EOF is raised in reach(), just continue to loop. Fixes https://jira.prplfoundation.org/browse/PPM-228 Signed-off-by: Raphaël Mélotte --- tools/deploy_firmware.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/deploy_firmware.py b/tools/deploy_firmware.py index 8717d7986a..ee944db045 100755 --- a/tools/deploy_firmware.py +++ b/tools/deploy_firmware.py @@ -104,7 +104,7 @@ def needs_upgrade(self): print(diff_str) return bool(diff_str) - def reach(self, attempts: int = 5, wait: int = 5): + def reach(self, attempts: int = 5, wait: int = 5) -> bool: """Check if the device is reachable via SSH (and optionally try multiple times). Parameters @@ -124,7 +124,7 @@ def reach(self, attempts: int = 5, wait: int = 5): with pexpect.pxssh.pxssh() as shell: shell.login(self.name, self.username, login_timeout=5) return True - except pexpect.pxssh.ExceptionPxssh: + except (pexpect.pxssh.ExceptionPxssh, pexpect.exceptions.EOF): print("Waiting for the device to be reachable") time.sleep(wait) return False From b7fc991aa386fba207a0e72923ec8ec7729ceb54 Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Thu, 9 Jul 2020 12:06:36 +0200 Subject: [PATCH 184/453] tlvf: cCmduHeader.h: remove execute permission This generated file was accidentally committed with execute permission. Observed by removing the AutoGenerated directory and rebuilding. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- .../tlvf/AutoGenerated/include/tlvf/ieee_1905_1/cCmduHeader.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/cCmduHeader.h diff --git a/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/cCmduHeader.h b/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/cCmduHeader.h old mode 100755 new mode 100644 From ab0f9d33f4b17c8643e5645a210c580daf5046ab Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Fri, 3 Jul 2020 17:54:35 +0200 Subject: [PATCH 185/453] gitlab-ci: remove AutoGenerated before building We check that the AutoGenerated is unchanged after the tlvf has been generated. However, that check doesn't take into account removed files. To do so, remove the AutoGenerated directories before the build. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a706e7ed2a..fd577d19c7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -122,6 +122,8 @@ build-in-docker: CMAKE_BUILD_TYPE: "Release" EXTRA_CMAKE_FLAGS: "" script: + # To be sure that AutoGenerated is correct, remove it first and check later that it's unchanged. + - rm -rf framework/tlvf/AutoGenerated common/beerocks/tlvf/AutoGenerated - cmake -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCMAKE_INSTALL_PREFIX=build/install \ $EXTRA_CMAKE_FLAGS -H. -Bbuild -G Ninja - ninja -C build install From 4702b1982c104236c71c18791235ae460d51581b Mon Sep 17 00:00:00 2001 From: Frederik Van Bogaert Date: Wed, 1 Jul 2020 13:46:39 +0200 Subject: [PATCH 186/453] documentation: Add information about JIRA Update CONTRIBUTING.md with information on how to tie it in with JIRA https://jira.prplfoundation.org/browse/PPM-220 Signed-off-by: Frederik Van Bogaert --- CONTRIBUTING.md | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ddf9f89b71..d9ef7dc01c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,7 +18,8 @@ If you encounter a problem with someone's conduct, contact the prpl Community Ma ## Reporting bugs -To report bugs, use the [github issues](https://github.com/prplfoundation/prplMesh/issues/new/choose) entry form. +To report bugs, use the [JIRA create issue](https://jira.prplfoundation.org/secure/CreateIssue!default.jspa) entry form. +Select Prplmesh as the project, and "Bug" as the issue type (you can use "Task" for feature requests) ## Improving documentation @@ -31,8 +32,9 @@ It is intended to be migrated to Jekyll markdown and to be published with github ## Contributing code +Before development is started, a [JIRA task or bug](#working-with-jira) should have been created for the issue. All development is managed using [pull requests](#pull-requests-workflow). -[Commits](#commits) must be in logical, consistent units and have a good commit message. +[Commits](#commits) must be in logical, consistent units and have a good commit message that includes the JIRA key of the corresponding issue. Every commit must carry a Signed-off-by tag to assert your agreement with the [DCO](#developers-certificate-of-origin). Pull requests are reviewed and checks are performed on them before they are merged. Code should adhere to the [coding style](#coding-style). @@ -40,6 +42,28 @@ Code should adhere to the [coding style](#coding-style). Note that everybody follows these same guidelines. Core contributors, occasional contributors and maintainers are all alike. +### Working with JIRA + +Every bug or feature needs to have a JIRA task associated with it, so that we can track the progress and see what people are working on. +An exception is made for "hotfixes": small fixes that are uncontroversial, e.g. fixing whitespace in one file. Those don't need an explicit JIRA issue. + +To enable automatic tracking between JIRA and git, we ask that all branches (except for hotfixes) contain the JIRA id, and all commits contain it as well. +This is unfortunately necessary for matching up the information between the two systems. +Adding the JIRA key to pull/merge request names is also recommended, but not required. + +The JIRA issue should be created before any work is started. +When work is started, the developer should transition the issue to "In progress" and assign his- or herself to the issue. +Please also make sure that any issue you work on is part of the current sprint (even if you don't think it'll be finished in the sprint) +Usage of the time tracking features is also recommended; for this to work, make sure that you add an estimation of how much time the work is going to take before you start, and then remember to log the time it takes you to work on the issue. +Time spent reviewing other issues is not counted, but time spent implementing review feedback is. +When it's time for review, please transition the issue manually to the "In review" state. +We're looking at possibly automating this in the future, but it still needs to be done manually for now. +Make sure the JIRA issue has an informative description; it will form the basis of any discussion of the feature or bug in question, so you want to make sure that the description makes the problem clear. +You can then copy the description to the pull request description (it's OK if they're the same). +You may need to adjust the syntax manually if you do this, though. + +JIRA uses a syntax that's different from the markdown used by github/gitlab. It's described [here](https://jira.prplfoundation.org/secure/WikiRendererHelpAction.jspa) + ### Copyright The copyright over the code is shared between all contributors. @@ -80,6 +104,8 @@ A commit message consists of a subject, a message body and a set of tags. Do this thing and do that thing. + https://jira.prplfoundation.org/browse/PPM-204 + Signed-off-by: The Author Co-Authored-by: The Other Author Signed-off-by: The Other Author @@ -112,6 +138,7 @@ It generally describes the "why" and "what" according to the following pattern: * the chosen solution and why it was chosen; * the (core) change itself - in the imperative (i.e. "add foo()", not ("added foo()"); * additional changes needed to keep things working (e.g. "Update callers with the new argument"). +* The JIRA key should ideally be part of every commit. It can be either on its own (PPM-204) or as a link to JIRA (https://jira.prplfoundation.org/browse/PPM-204). Since commits should be split up, there will be many commits that are not useful on their own, but just prepare for another commit. In that case, the preparatory commits should refer to what they prepare for. @@ -122,6 +149,8 @@ For example, you could have the preparatory commit: Prepare for "tlvf: message_com::send_cmdu(): don't swap internal messages". + PPM-204 + Signed-off-by: Joe Developer Followed by the commit that actually makes the change: @@ -138,6 +167,8 @@ Followed by the commit that actually makes the change: Use the swap_needed parameter of CmduMessageTx::finalize() to avoid swapping. + https://jira.prplfoundation.org/browse/PPM-204 + Signed-off-by: Joe Developer The extended description only needs to be added if there is actually something to say. @@ -196,6 +227,7 @@ The workflow is explained in detail below. In summary, it consists of these step Start by creating a branch. We give branches a name following `/`. Types are `feature` for feature development, `bugfix` for fixing bugs from the issues list, `hotfix` for small fixes without an issue, and `dev/` for personal development branches that are not meant for merging. +Both `bugfix` and `feature` branches should have a JIRA identifier in their branch name (e.g. feature/PPM-204-implement-dynamic-steering) This branch is immediately pushed, and a draft pull request is created for it. The pull request can be created with the [`hub`](https://github.com/github/hub) tool: `hub pull-request -d`. From a21efae200bd61dec4d04177b52b22461618159f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Wed, 1 Jul 2020 17:55:30 +0200 Subject: [PATCH 187/453] ci: bump easymesh_cert to add support for the Omnia and Axepoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This new revision contain all that is required to be able to use "turris-omnia" and "axepoint" as the DUT. Signed-off-by: Raphaël Mélotte --- ci/easymesh_cert_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/easymesh_cert_version b/ci/easymesh_cert_version index 23f0331dfb..ba7f7e89f1 100644 --- a/ci/easymesh_cert_version +++ b/ci/easymesh_cert_version @@ -1 +1 @@ -62f9067f2894441b7d825b51e1b8d7c76fb640e4 +efaa40ec857e3724954b297cc812ff871569322a From 19c312529b0f80e0d8cb63c3208a44123fbd3b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Thu, 2 Jul 2020 15:25:26 +0200 Subject: [PATCH 188/453] ci: add support for running certification tests on the Omnia MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /ci/certification/turris-omnia.yml is essentially the same as /ci/certification/netgear-rax40.yml, only with the device-specific parts replaced. MAP-4.2.1:turris-omnia MAP-4.12.2_ETH:turris-omnia MAP-4.8.1_ETH_FH5GH:turris-omnia Signed-off-by: Raphaël Mélotte --- .gitlab-ci.yml | 2 + ci/certification/turris-omnia.yml | 641 ++++++++++++++++++++++++++++++ 2 files changed, 643 insertions(+) create mode 100644 ci/certification/turris-omnia.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd577d19c7..8f18a6cc2e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,7 @@ stages: - certification-dummy - certification-netgear-rax40 - certification-netgear-rax40-bhwifi + - certification-turris-omnia - upload .image-build: @@ -346,3 +347,4 @@ include: - local: "/ci/certification/dummy.yml" - local: "/ci/certification/netgear-rax40.yml" - local: "/ci/certification/netgear-rax40-bhwifi.yml" + - local: "/ci/certification/turris-omnia.yml" diff --git a/ci/certification/turris-omnia.yml b/ci/certification/turris-omnia.yml new file mode 100644 index 0000000000..811e1617fd --- /dev/null +++ b/ci/certification/turris-omnia.yml @@ -0,0 +1,641 @@ +.certification:turris-omnia: + stage: certification-turris-omnia + extends: .certification-generic + variables: + DEVICE_UNDER_TEST: "turris-omnia" + before_script: + - tools/deploy_firmware.py --device turris-omnia --target-name "$DEVICE_UNDER_TEST" --image openwrt-mvebu-cortexa9-cznic_turris-omnia-sysupgrade.img.gz + - tools/deploy_ipk.sh --certification-mode $DEVICE_UNDER_TEST build/$DEVICE_UNDER_TEST/prplmesh.ipk + needs: + - job: build-for-turris-omnia + +MAP-4.2.1:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.1:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.2.3_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.3_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.2.3_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.3_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.2.3_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.3_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.3.1_ETH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.1_ETH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.3.2_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.2_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.3.2_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.2_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.3.2_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.2_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.4.1_ETH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.1_ETH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.4.2_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.2_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.4.2_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.2_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.4.2_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.2_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.4.3_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.3_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.4.3_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.3_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.4.3_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.3_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.5.1_ETH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.1_ETH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.5.2_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.2_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.5.3_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.3_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.5.3_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.3_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.6.1_ETH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.1_ETH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.6.2_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.2_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.6.2_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.2_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.6.2_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.2_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.6.3_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.3_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.3_ETH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.3_ETH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.4_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.4_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.4_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.4_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.4_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.4_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.5_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.5_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.5_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.5_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.5_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.5_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.6_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.6_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.6_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.6_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.6_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.6_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.7_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.7_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.7_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.7_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.7_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.7_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.8_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.8_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.8_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.8_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.8_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.8_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.9_ETH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.9_ETH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.1_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.1_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.1_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.1_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.1_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.1_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.2_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.2_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.2_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.2_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.2_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.2_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.3_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.3_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.4_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.4_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.4_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.4_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.4_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.4_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.5_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.5_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.5_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.5_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.5_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.5_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.10.3_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.3_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.10.3_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.3_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.10.3_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.3_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.10.4_ETH_FH24G:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.4_ETH_FH24G:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.10.4_ETH_FH5GL:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.4_ETH_FH5GL:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.10.4_ETH_FH5GH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.4_ETH_FH5GH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.11.1_ETH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.11.1_ETH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.12.1_ETH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.12.1_ETH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.12.2_ETH:turris-omnia: + extends: .certification:turris-omnia + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.12.2_ETH:turris-omnia.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + From 1b8f5e7f9d31bbfc12cfbfa76002d051e0845638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Mon, 6 Jul 2020 10:07:43 +0200 Subject: [PATCH 189/453] ci: add support for running certification tests on the Axepoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /ci/certification/axepoint.yml is essentially the same as /ci/certification/netgear-rax40.yml, only with the device-specific parts replaced. The deploy script is also updated to use uboot for the axepoint as well. There are only a few tests that are passing with the Omnia and the Axepoint at the moment. Run at least one for each device, to check that at least the plumbing is working: MAP-4.12.2_ETH:axepoint MAP-4.12.2_ETH:turris-omnia Signed-off-by: Raphaël Mélotte --- .gitlab-ci.yml | 2 + ci/certification/axepoint.yml | 641 ++++++++++++++++++++++++++++++++++ tools/deploy_firmware.py | 2 +- 3 files changed, 644 insertions(+), 1 deletion(-) create mode 100644 ci/certification/axepoint.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8f18a6cc2e..3a54d0cbd6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,6 +9,7 @@ stages: - certification-netgear-rax40 - certification-netgear-rax40-bhwifi - certification-turris-omnia + - certification-axepoint - upload .image-build: @@ -348,3 +349,4 @@ include: - local: "/ci/certification/netgear-rax40.yml" - local: "/ci/certification/netgear-rax40-bhwifi.yml" - local: "/ci/certification/turris-omnia.yml" + - local: "/ci/certification/axepoint.yml" diff --git a/ci/certification/axepoint.yml b/ci/certification/axepoint.yml new file mode 100644 index 0000000000..dd81e937f5 --- /dev/null +++ b/ci/certification/axepoint.yml @@ -0,0 +1,641 @@ +.certification:axepoint: + stage: certification-axepoint + extends: .certification-generic + variables: + DEVICE_UNDER_TEST: "axepoint" + before_script: + - tools/deploy_firmware.py --device axepoint --target-name "$DEVICE_UNDER_TEST" --image AX6000_2000_ETH_11AXUCI-squashfs-fullimage.img + - tools/deploy_ipk.sh --certification-mode $DEVICE_UNDER_TEST build/$DEVICE_UNDER_TEST/prplmesh.ipk + needs: + - job: build-for-axepoint + +MAP-4.2.1:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.1:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.2.3_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.3_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.2.3_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.3_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.2.3_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.3_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.3.1_ETH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.1_ETH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.3.2_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.2_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.3.2_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.2_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.3.2_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.2_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.4.1_ETH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.1_ETH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.4.2_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.2_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.4.2_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.2_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.4.2_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.2_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.4.3_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.3_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.4.3_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.3_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.4.3_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.3_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.5.1_ETH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.1_ETH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.5.2_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.2_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.5.3_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.3_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.5.3_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.3_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.6.1_ETH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.1_ETH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.6.2_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.2_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.6.2_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.2_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.6.2_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.2_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.6.3_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.3_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.3_ETH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.3_ETH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.4_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.4_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.4_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.4_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.4_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.4_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.5_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.5_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.5_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.5_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.5_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.5_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.6_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.6_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.6_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.6_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.6_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.6_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.7_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.7_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.7_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.7_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.7_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.7_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.8_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.8_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.8_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.8_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.8_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.8_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.7.9_ETH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.9_ETH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.1_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.1_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.1_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.1_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.1_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.1_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.2_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.2_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.2_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.2_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.2_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.2_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.3_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.3_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.4_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.4_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.4_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.4_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.4_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.4_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.5_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.5_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.5_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.5_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.8.5_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.5_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.10.3_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.3_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.10.3_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.3_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.10.3_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.3_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.10.4_ETH_FH24G:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.4_ETH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.10.4_ETH_FH5GL:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.4_ETH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.10.4_ETH_FH5GH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.4_ETH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.11.1_ETH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.11.1_ETH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.12.1_ETH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.12.1_ETH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + +MAP-4.12.2_ETH:axepoint: + extends: .certification:axepoint + rules: + # If the last commit description contains the test name and we're not on master, run it. + # Otherwise, make it a manual job + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.12.2_ETH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' + when: on_success + - when: manual + allow_failure: true + diff --git a/tools/deploy_firmware.py b/tools/deploy_firmware.py index ee944db045..dd3a404d9a 100755 --- a/tools/deploy_firmware.py +++ b/tools/deploy_firmware.py @@ -270,7 +270,7 @@ def main(): args = parser.parse_args() - if args.device == "netgear-rax40": + if args.device in ["netgear-rax40", "axepoint"]: dev = NetgearRax40(args.device, args.target_name, args.image) else: dev = Generic(args.device, args.target_name, args.image) From e819d852fa8c362caafaa637c0868525a46fa887 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Thu, 9 Jul 2020 11:45:28 +0000 Subject: [PATCH 190/453] controller: db: rename ePersistentParamBool to eTriStateBool The extension of not-configured value to a boolean can be useful for non-persistent and persistent configurations alike. Thus, limiting the parameter to describe persistent-configurations is flawed. Renamed to a more suitable name that doesn't limit the use to persistent configuration. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 24 +++++++++++----------- controller/src/beerocks/master/db/db.h | 4 ++-- controller/src/beerocks/master/db/node.cpp | 6 +++--- controller/src/beerocks/master/db/node.h | 10 ++++----- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index 3e5d39af26..7c523f98ff 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -2599,18 +2599,18 @@ bool db::set_client_stay_on_initial_radio(const sMacAddr &mac, bool stay_on_init } node->client_stay_on_initial_radio = - (stay_on_initial_radio) ? ePersistentParamBool::ENABLE : ePersistentParamBool::DISABLE; + (stay_on_initial_radio) ? eTriStateBool::ENABLE : eTriStateBool::DISABLE; node->client_parameters_last_edit = timestamp; return true; } -ePersistentParamBool db::get_client_stay_on_initial_radio(const sMacAddr &mac) +eTriStateBool db::get_client_stay_on_initial_radio(const sMacAddr &mac) { auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); if (!node) { LOG(ERROR) << "client node not found for mac " << mac; - return ePersistentParamBool::NOT_CONFIGURED; + return eTriStateBool::NOT_CONFIGURED; } return node->client_stay_on_initial_radio; @@ -2686,18 +2686,18 @@ bool db::set_client_stay_on_selected_band(const sMacAddr &mac, bool stay_on_sele } node->client_stay_on_selected_band = - (stay_on_selected_band) ? ePersistentParamBool::ENABLE : ePersistentParamBool::DISABLE; + (stay_on_selected_band) ? eTriStateBool::ENABLE : eTriStateBool::DISABLE; node->client_parameters_last_edit = timestamp; return true; } -ePersistentParamBool db::get_client_stay_on_selected_band(const sMacAddr &mac) +eTriStateBool db::get_client_stay_on_selected_band(const sMacAddr &mac) { auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); if (!node) { LOG(ERROR) << "client node not found for mac " << mac; - return ePersistentParamBool::NOT_CONFIGURED; + return eTriStateBool::NOT_CONFIGURED; } return node->client_stay_on_selected_band; @@ -2758,9 +2758,9 @@ bool db::clear_client_persistent_db(const sMacAddr &mac) node->client_parameters_last_edit = std::chrono::steady_clock::time_point::min(); node->client_time_life_delay_sec = std::chrono::seconds::zero(); - node->client_stay_on_initial_radio = ePersistentParamBool::NOT_CONFIGURED; + node->client_stay_on_initial_radio = eTriStateBool::NOT_CONFIGURED; node->client_initial_radio = network_utils::ZERO_MAC; - node->client_stay_on_selected_band = ePersistentParamBool::NOT_CONFIGURED; + node->client_stay_on_selected_band = eTriStateBool::NOT_CONFIGURED; node->client_selected_bands = beerocks::eFreqType::FREQ_UNKNOWN; LOG(DEBUG) << "removing client " << mac << " from persistent db"; @@ -2807,8 +2807,8 @@ bool db::update_client_persistent_db(const sMacAddr &mac) std::to_string(node->client_time_life_delay_sec.count()); } - if (node->client_stay_on_initial_radio != ePersistentParamBool::NOT_CONFIGURED) { - auto enable = (node->client_stay_on_initial_radio == ePersistentParamBool::ENABLE); + if (node->client_stay_on_initial_radio != eTriStateBool::NOT_CONFIGURED) { + auto enable = (node->client_stay_on_initial_radio == eTriStateBool::ENABLE); LOG(DEBUG) << "setting client stay-on-initial-radio in persistent-db to for " << mac << " to " << enable; values_map.at(initial_radio_enable_str) = std::to_string(enable); @@ -2820,8 +2820,8 @@ bool db::update_client_persistent_db(const sMacAddr &mac) values_map.at(initial_radio_str) = tlvf::mac_to_string(node->client_initial_radio); } - if (node->client_stay_on_selected_band != ePersistentParamBool::NOT_CONFIGURED) { - auto enable = (node->client_stay_on_selected_band == ePersistentParamBool::ENABLE); + if (node->client_stay_on_selected_band != eTriStateBool::NOT_CONFIGURED) { + auto enable = (node->client_stay_on_selected_band == eTriStateBool::ENABLE); LOG(DEBUG) << "setting client stay-on-selected-band in persistent-db to for " << mac << " to " << enable; values_map.at(selected_band_enable_str) = std::to_string(enable); diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index cfa94506eb..87880c773a 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -702,7 +702,7 @@ class db { * @param mac MAC address of a client. * @return Enable client stay on the radio it initially connected to. */ - ePersistentParamBool get_client_stay_on_initial_radio(const sMacAddr &mac); + eTriStateBool get_client_stay_on_initial_radio(const sMacAddr &mac); /** * @brief Set the client's initial-radio. @@ -740,7 +740,7 @@ class db { * @param mac MAC address of a client. * @return Enable client stay on the selected band/bands. */ - ePersistentParamBool get_client_stay_on_selected_band(const sMacAddr &mac); + eTriStateBool get_client_stay_on_selected_band(const sMacAddr &mac); /** * @brief Set the client's selected-bands. diff --git a/controller/src/beerocks/master/db/node.cpp b/controller/src/beerocks/master/db/node.cpp index 7a61d90731..8ece5b5913 100644 --- a/controller/src/beerocks/master/db/node.cpp +++ b/controller/src/beerocks/master/db/node.cpp @@ -29,11 +29,11 @@ node::node(beerocks::eType type_, const std::string &mac_) } namespace son { -std::ostream &operator<<(std::ostream &os, ePersistentParamBool value) +std::ostream &operator<<(std::ostream &os, eTriStateBool value) { - if (value == ePersistentParamBool::DISABLE) { + if (value == eTriStateBool::DISABLE) { os << "Disabled"; - } else if (value == ePersistentParamBool::ENABLE) { + } else if (value == eTriStateBool::ENABLE) { os << "Enabled"; } else { os << "Not-Configured"; diff --git a/controller/src/beerocks/master/db/node.h b/controller/src/beerocks/master/db/node.h index f9978022ab..99838dce25 100644 --- a/controller/src/beerocks/master/db/node.h +++ b/controller/src/beerocks/master/db/node.h @@ -36,12 +36,12 @@ typedef struct { } sVapElement; /** - * @brief Extended boolean parameter to support "not configured" value for persistent configuration. + * @brief Extended boolean parameter to support "not configured" value for configuration. * For persistent data, it is important to differ between configured enable/disable to uncofigured value. */ -enum class ePersistentParamBool : int8_t { NOT_CONFIGURED = -1, DISABLE = 0, ENABLE = 1 }; +enum class eTriStateBool : int8_t { NOT_CONFIGURED = -1, DISABLE = 0, ENABLE = 1 }; -std::ostream &operator<<(std::ostream &os, ePersistentParamBool value); +std::ostream &operator<<(std::ostream &os, eTriStateBool value); class node { public: @@ -290,14 +290,14 @@ class node { std::chrono::seconds client_time_life_delay_sec = std::chrono::seconds::zero(); // If enabled, the client will be steered to the initial radio it connected to - save at client_initial_radio. - ePersistentParamBool client_stay_on_initial_radio = ePersistentParamBool::NOT_CONFIGURED; + eTriStateBool client_stay_on_initial_radio = eTriStateBool::NOT_CONFIGURED; // The client_initial_radio bssid must be set. sMacAddr client_initial_radio; // If enabled, the client will be steered to pre-selected-bands defined by client_selected_bands. // Not enforced if client_selected_bands is not set. - ePersistentParamBool client_stay_on_selected_band = ePersistentParamBool::NOT_CONFIGURED; + eTriStateBool client_stay_on_selected_band = eTriStateBool::NOT_CONFIGURED; // The selected bands the client should be steered to if the client_stay_on_selected_band is set. // Default value is FREQ_UNKNOWN (also indicates value is not configured) From 97e95c8c95228e047ac235de0bc51a0775a25e3a Mon Sep 17 00:00:00 2001 From: Ran Regev Date: Sun, 5 Jul 2020 15:47:31 +0300 Subject: [PATCH 191/453] bwl: build: replaced nl-tiny with nl-genl-3 There is no need in nl-tiny at all, so removed it. tested on Turrin Omnia device Signed-off-by: Ran Regev --- common/beerocks/bwl/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/beerocks/bwl/CMakeLists.txt b/common/beerocks/bwl/CMakeLists.txt index 5bf4864b4a..125f8eb0ce 100644 --- a/common/beerocks/bwl/CMakeLists.txt +++ b/common/beerocks/bwl/CMakeLists.txt @@ -76,6 +76,9 @@ if(BWL_TYPE STREQUAL "DWPAL") elseif(BWL_TYPE STREQUAL "NL80211") + find_package(nl-genl-3 REQUIRED) + list(APPEND BWL_LIBS nl-genl-3) + file(GLOB bwl_platform_sources ${MODULE_PATH}/shared/*.c* ${MODULE_PATH}/nl80211/*.c* @@ -96,7 +99,6 @@ elseif(BWL_TYPE STREQUAL "NL80211") ${HOSTAPD_DIR}/src/utils ${HOSTAPD_DIR}/src/common ${HOSTAPD_DIR}/src/drivers - ${PLATFORM_INCLUDE_DIR}/libnl-tiny ) # Platform libraries @@ -104,8 +106,6 @@ elseif(BWL_TYPE STREQUAL "NL80211") ${PLATFORM_STAGING_DIR}/usr/lib ) - list(APPEND BWL_LIBS nl-tiny) - elseif(BWL_TYPE STREQUAL "DUMMY") set(bwl_platform_sources From d655adbd1257b5000f22417b6f2b0136030cedc6 Mon Sep 17 00:00:00 2001 From: Alex Kanter Date: Thu, 9 Jul 2020 06:55:23 +0000 Subject: [PATCH 192/453] association handling task: beacon request cleanup parent mac is always bssid in this case so using it instead. Signed-off-by: Alex Kanter --- .../master/tasks/association_handling_task.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/controller/src/beerocks/master/tasks/association_handling_task.cpp b/controller/src/beerocks/master/tasks/association_handling_task.cpp index bfe84471d7..97f1325e47 100644 --- a/controller/src/beerocks/master/tasks/association_handling_task.cpp +++ b/controller/src/beerocks/master/tasks/association_handling_task.cpp @@ -132,9 +132,9 @@ void association_handling_task::work() TASK_LOG(DEBUG) << "started association_handling_task, looking for beacon measurement " "capabilities on " << sta_mac; - std::string parent_mac = database.get_node_parent(sta_mac); - std::string radio_mac = database.get_node_parent_radio(parent_mac); - auto agent_mac = database.get_node_parent_ire(parent_mac); + std::string bssid = database.get_node_parent(sta_mac); + std::string radio_mac = database.get_node_parent_radio(bssid); + auto agent_mac = database.get_node_parent_ire(bssid); auto measurement_request = message_com::create_vs_message< beerocks_message::cACTION_CONTROL_CLIENT_BEACON_11K_REQUEST>(cmdu_tx, id); @@ -145,20 +145,19 @@ void association_handling_task::work() } measurement_request->params().measurement_mode = beerocks::MEASURE_MODE_ACTIVE; // son::eMeasurementMode11K "passive"/"active"/"table" - measurement_request->params().channel = database.get_node_channel(parent_mac); + measurement_request->params().channel = database.get_node_channel(bssid); measurement_request->params().rand_ival = beerocks:: BEACON_MEASURE_DEFAULT_RANDOMIZATION_INTERVAL; // random interval - specifies the upper bound of the random delay to be used prior to making the measurement, expressed in units of TUs [=1024usec] measurement_request->params().duration = beerocks:: BEACON_MEASURE_DEFAULT_ACTIVE_DURATION; // measurement duration, expressed in units of TUs [=1024usec] measurement_request->params().sta_mac = tlvf::mac_from_string(sta_mac); - measurement_request->params().bssid = tlvf::mac_from_string( - parent_mac); // the bssid which will be reported. for all bssid, use wildcard "ff:ff:ff:ff:ff:ff" + measurement_request->params().bssid = tlvf::mac_from_string(bssid); //measurement_request.params.use_optional_ssid = true; measurement_request->params().expected_reports_count = 1; - //string_utils::copy_string(measurement_request.params.ssid, database.get_hostap_vap_ssid(parent_mac).c_str(), sizeof(measurement_request.params.ssid)); + //mapf::utils::copy_string(measurement_request.params.ssid, database.get_hostap_vap_ssid(bssid).c_str(), sizeof(measurement_request.params.ssid)); add_pending_mac(radio_mac, beerocks_message::ACTION_CONTROL_CLIENT_BEACON_11K_RESPONSE); TASK_LOG(DEBUG) << "requested beacon measurement request from sta: " << sta_mac - << " on hostap: " << parent_mac; + << " on bssid: " << bssid; son_actions::send_cmdu_to_agent(agent_mac, cmdu_tx, database, radio_mac); set_responses_timeout(BEACON_MEASURE_REQ_TIME_SPAN); From bdfad2a59bfedb6adf9b6f53e77fab2e5cca831a Mon Sep 17 00:00:00 2001 From: Alex Kanter Date: Thu, 9 Jul 2020 07:04:27 +0000 Subject: [PATCH 193/453] controller: add operating class to beacon request msg radio operation class is always 0 in beacon request message as a result hostapd message validation fails and messages are not really sent to the air. add operation class when creating the request. Signed-off-by: Alex Kanter --- .../beerocks/master/tasks/association_handling_task.cpp | 2 ++ .../src/beerocks/master/tasks/optimal_path_task.cpp | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/controller/src/beerocks/master/tasks/association_handling_task.cpp b/controller/src/beerocks/master/tasks/association_handling_task.cpp index 97f1325e47..cfab15d3b8 100644 --- a/controller/src/beerocks/master/tasks/association_handling_task.cpp +++ b/controller/src/beerocks/master/tasks/association_handling_task.cpp @@ -146,6 +146,8 @@ void association_handling_task::work() measurement_request->params().measurement_mode = beerocks::MEASURE_MODE_ACTIVE; // son::eMeasurementMode11K "passive"/"active"/"table" measurement_request->params().channel = database.get_node_channel(bssid); + measurement_request->params().op_class = + database.get_hostap_operating_class(tlvf::mac_from_string(bssid)); measurement_request->params().rand_ival = beerocks:: BEACON_MEASURE_DEFAULT_RANDOMIZATION_INTERVAL; // random interval - specifies the upper bound of the random delay to be used prior to making the measurement, expressed in units of TUs [=1024usec] measurement_request->params().duration = beerocks:: diff --git a/controller/src/beerocks/master/tasks/optimal_path_task.cpp b/controller/src/beerocks/master/tasks/optimal_path_task.cpp index 835dfa2bd2..19f536b779 100644 --- a/controller/src/beerocks/master/tasks/optimal_path_task.cpp +++ b/controller/src/beerocks/master/tasks/optimal_path_task.cpp @@ -278,7 +278,7 @@ void optimal_path_task::work() measurement_request.duration = beerocks::BEACON_MEASURE_DEFAULT_ACTIVE_DURATION; } - // ap_mac is a radio mac, but we need to request measurment on some vap since radio don't beacon + // ap_mac is a radio mac, but we need to request measurement on some vap since radio don't beacon const std::string vap_mac = database.get_hostap_vap_with_ssid(ap_mac, current_hostap_ssid); if (vap_mac.empty()) { @@ -289,8 +289,10 @@ void optimal_path_task::work() ++potential_ap_iter; continue; } - measurement_request.bssid = tlvf::mac_from_string(vap_mac); - measurement_request.channel = database.get_node_channel(ap_mac); + measurement_request.bssid = tlvf::mac_from_string(vap_mac); + measurement_request.channel = database.get_node_channel(ap_mac); + measurement_request.op_class = + database.get_hostap_operating_class(tlvf::mac_from_string(ap_mac)); measurement_request.expected_reports_count = 1; /////////////// FOR DEBUG ONLY //////////////// From 593de25308a73f1a26d1bb7af761e68757e28bcc Mon Sep 17 00:00:00 2001 From: Alex Kanter Date: Thu, 9 Jul 2020 08:56:13 +0000 Subject: [PATCH 194/453] optimal path task: increase 11k responsiveness threshold to 80% Beacon measurement responsiveness threshold is currently set to 50% below that optimal path task flags the client as 11k non responsive and switch to legacy cross rssi measurement algorithm. In case of band steering scenario where there are only 2 radio candidates, 50% responsiveness means only 1 candidate for optimal path task to decide from which ends the task. Increase to responsiveness threshold to 80%. Signed-off-by: Alex Kanter --- .../master/tasks/optimal_path_task.cpp | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/controller/src/beerocks/master/tasks/optimal_path_task.cpp b/controller/src/beerocks/master/tasks/optimal_path_task.cpp index 19f536b779..1692ef04b7 100644 --- a/controller/src/beerocks/master/tasks/optimal_path_task.cpp +++ b/controller/src/beerocks/master/tasks/optimal_path_task.cpp @@ -31,6 +31,18 @@ using namespace son; #define ONE_PERCENT 0.01f #define EIGHTY_PERCENT 0.80f +/* +* Responsiveness may be less than 100% since the station might refuse to the measurement +* request or failed to measure it due to incapability (to measure in another band for +* example), missed the probe or due to the AP bad reception. +* There is a high probability to get responsiveness less than 100% and therefore, the +* threshold was changed to 50% as part of demo optimizations. +* This hardcoded threshold is temporary and shall be revised in the future. +* update: increasing to 80% since in bandsteering scenario there are only 2 radios +* and 50% means optimal path always will fail to find an additional candidate. +*/ +static constexpr uint8_t RESPONSIVENESS_PRECENT_11K_THRESHOLD = 80; + /////////////// FOR DEBUG ONLY //////////////// int optimal_path_task::cli_beacon_request_duration = -1; int optimal_path_task::cli_beacon_request_rand_ival = -1; @@ -357,16 +369,9 @@ void optimal_path_task::work() TASK_LOG(DEBUG) << "responsiveness_precentage_11k: " << int(responsiveness_precentage_11k) << "%"; - /* - * Responsiveness may be less than 100% since the station might refuse to the measurement - * request or failed to measure it due to incapability (to measure in another band for - * example), missed the probe or due to the AP bad reception. - * There is a high probability to get responsiveness less than 100% and therefore, the - * threshold was changed to 50% as part of demo optimizations. - * This hardcoded threshold is temporary and shall be revised in the future. - */ - if (responsiveness_precentage_11k < 50) { - TASK_LOG(DEBUG) << "11k measurement request responsiveness is less than 50%"; + if (responsiveness_precentage_11k < RESPONSIVENESS_PRECENT_11K_THRESHOLD) { + TASK_LOG(DEBUG) << "11k measurement request responsiveness is less than " + << RESPONSIVENESS_PRECENT_11K_THRESHOLD << "%"; if (database.settings_front_measurements()) { /////////////// FOR DEBUG ONLY //////////////// if (use_cli_value) { From 78367d9985042cb31074b39b729df42bcbf44b81 Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Mon, 29 Jun 2020 23:09:18 +0000 Subject: [PATCH 195/453] bwl: add start_wps_pbc API Add API to start STA wps_pbc in the sta_wlan_hal. This will be used by the backhaul manager when starting wps onboarding with wireless backhaul. Signed-off-by: Tomer Eliyahu Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- common/beerocks/bwl/dummy/sta_wlan_hal_dummy.cpp | 2 ++ common/beerocks/bwl/dummy/sta_wlan_hal_dummy.h | 1 + common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp | 11 +++++++++++ common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.h | 1 + common/beerocks/bwl/include/bwl/sta_wlan_hal.h | 2 ++ common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp | 2 ++ common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h | 1 + 7 files changed, 20 insertions(+) diff --git a/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.cpp b/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.cpp index fa9edadad2..cc74396ce0 100644 --- a/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.cpp +++ b/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.cpp @@ -24,6 +24,8 @@ sta_wlan_hal_dummy::sta_wlan_hal_dummy(const std::string &iface_name, hal_event_ sta_wlan_hal_dummy::~sta_wlan_hal_dummy() { sta_wlan_hal_dummy::detach(); } +bool sta_wlan_hal_dummy::start_wps_pbc() { return true; } + bool sta_wlan_hal_dummy::detach() { return true; } bool sta_wlan_hal_dummy::initiate_scan() { return true; } diff --git a/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.h b/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.h index 8af18e02d6..e99662496a 100644 --- a/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.h +++ b/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.h @@ -31,6 +31,7 @@ class sta_wlan_hal_dummy : public base_wlan_hal_dummy, public sta_wlan_hal { sta_wlan_hal_dummy(const std::string &iface_name, hal_event_cb_t callback); virtual ~sta_wlan_hal_dummy(); + virtual bool start_wps_pbc() override; virtual bool detach() override; virtual bool initiate_scan() override; diff --git a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp index 69b371967e..efc11de72f 100644 --- a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp @@ -99,6 +99,17 @@ sta_wlan_hal_dwpal::sta_wlan_hal_dwpal(const std::string &iface_name, hal_event_ sta_wlan_hal_dwpal::~sta_wlan_hal_dwpal() {} +bool sta_wlan_hal_dwpal::start_wps_pbc() +{ + LOG(DEBUG) << "Initiating wps_pbc multi_ap=1 on interface: " << get_iface_name(); + + if (!dwpal_send_cmd("WPS_PBC multi_ap=1")) { + LOG(ERROR) << "start_wps_pbc - wpa_ctrl_send_msg failed for " << get_iface_name(); + return false; + } + return true; +} + bool sta_wlan_hal_dwpal::initiate_scan() { LOG(DEBUG) << "Initiating scan on interface: " << get_iface_name(); diff --git a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.h b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.h index 6c8b1cb94a..7b12365883 100644 --- a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.h +++ b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.h @@ -32,6 +32,7 @@ class sta_wlan_hal_dwpal : public base_wlan_hal_dwpal, public sta_wlan_hal { virtual ~sta_wlan_hal_dwpal(); virtual bool initiate_scan() override; + virtual bool start_wps_pbc() override; virtual int get_scan_results(const std::string &ssid, std::vector &list, bool parse_vsie) override; diff --git a/common/beerocks/bwl/include/bwl/sta_wlan_hal.h b/common/beerocks/bwl/include/bwl/sta_wlan_hal.h index 4d70688bf5..4d89fd49df 100644 --- a/common/beerocks/bwl/include/bwl/sta_wlan_hal.h +++ b/common/beerocks/bwl/include/bwl/sta_wlan_hal.h @@ -39,6 +39,8 @@ class sta_wlan_hal : public virtual base_wlan_hal { public: virtual ~sta_wlan_hal() = default; + virtual bool start_wps_pbc() = 0; + virtual bool initiate_scan() = 0; virtual int get_scan_results(const std::string &ssid, std::vector &list, diff --git a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp index a58002bf39..b0c8784374 100644 --- a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp +++ b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp @@ -25,6 +25,8 @@ sta_wlan_hal_nl80211::~sta_wlan_hal_nl80211() { sta_wlan_hal_nl80211::detach(); bool sta_wlan_hal_nl80211::detach() { return true; } +bool sta_wlan_hal_nl80211::start_wps_pbc() { return true; } + bool sta_wlan_hal_nl80211::initiate_scan() { return true; } int sta_wlan_hal_nl80211::get_scan_results(const std::string &ssid, std::vector &list, diff --git a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h index 96495e0836..c3224a7694 100644 --- a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h +++ b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h @@ -31,6 +31,7 @@ class sta_wlan_hal_nl80211 : public base_wlan_hal_nl80211, public sta_wlan_hal { sta_wlan_hal_nl80211(const std::string &iface_name, hal_event_cb_t callback); virtual ~sta_wlan_hal_nl80211(); + virtual bool start_wps_pbc() override; virtual bool detach() override; virtual bool initiate_scan() override; From 4082e3dab48dd0e2ce8ec57154b2779db171ed3d Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Mon, 29 Jun 2020 23:10:18 +0000 Subject: [PATCH 196/453] agent: ucc listener remove redundant wps sanity for vaps When starting wps registration as STA, the VAPs are not yet active. When starting wps registtration as AP, we don't care if they are active or not - the command will fail in the backhaul manager. So 0 remove the redundant check for searching the VAP with the requested radio mac. Signed-off-by: Tomer Eliyahu --- agent/src/beerocks/slave/agent_ucc_listener.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/agent/src/beerocks/slave/agent_ucc_listener.cpp b/agent/src/beerocks/slave/agent_ucc_listener.cpp index 50e3042c02..b707c60b21 100644 --- a/agent/src/beerocks/slave/agent_ucc_listener.cpp +++ b/agent/src/beerocks/slave/agent_ucc_listener.cpp @@ -181,13 +181,6 @@ bool agent_ucc_listener::handle_start_wps_registration(const std::string &band, return false; } - auto it = vaps_map.find(radio_mac); - if (it == vaps_map.end()) { - LOG(ERROR) << "radio_mac " + radio_mac + " not found"; - err_string = "Failed to get radio for " + band; - return false; - } - LOG(DEBUG) << "Trigger WPS PBC on radio mac " << radio_mac; err_string = "Failed to start wps pbc"; return m_backhaul_manager_ctx.start_wps_pbc(tlvf::mac_from_string(radio_mac)); From c15d7e3d7ca85b1910044569793a29b191216800 Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Fri, 3 Jul 2020 14:18:12 +0000 Subject: [PATCH 197/453] bcl: socket_thread: handle sd->readBytes() < 0 readBytes return -1 for failure, which is converted to a huge number since available_bytes type is size_t, which results in failures afterwards. Fix it by using ssize_t for available_bytes and handle the case when it is negative. Signed-off-by: Tomer Eliyahu --- common/beerocks/bcl/source/beerocks_socket_thread.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common/beerocks/bcl/source/beerocks_socket_thread.cpp b/common/beerocks/bcl/source/beerocks_socket_thread.cpp index ba6e479373..3b9e2971ee 100644 --- a/common/beerocks/bcl/source/beerocks_socket_thread.cpp +++ b/common/beerocks/bcl/source/beerocks_socket_thread.cpp @@ -147,13 +147,17 @@ int socket_thread::socket_disconnected_uds(Socket *sd) bool socket_thread::handle_cmdu_message_uds(Socket *sd) { - size_t available_bytes; + ssize_t available_bytes; // Check if UDS Header exists available_bytes = sd->readBytes(rx_buffer, sizeof(rx_buffer), true, sizeof(message::sUdsHeader), true); // PEEK UDS Header, blocking + if (available_bytes < 0) { + LOG(ERROR) << "Error reading from socket"; + return false; + } - if (available_bytes < sizeof(message::sUdsHeader)) { + if (static_cast(available_bytes) < sizeof(message::sUdsHeader)) { THREAD_LOG(ERROR) << "available bytes = " << available_bytes << " is less then sizeof(sUdsHeader)=" << sizeof(message::sUdsHeader); return false; @@ -167,7 +171,7 @@ bool socket_thread::handle_cmdu_message_uds(Socket *sd) available_bytes = sd->readBytes(rx_buffer, sizeof(rx_buffer), true, message_size); // blocking read - if (available_bytes != message_size) { + if (static_cast(available_bytes) != message_size) { THREAD_LOG(ERROR) << "available bytes = " << available_bytes << " message_size = " << message_size; return false; From 304fe74c3eb8c339897e2089447fa0ce6faf8c78 Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Thu, 9 Jul 2020 18:03:59 +0200 Subject: [PATCH 198/453] gitlab-ci: replace netgear-rax40 bhwifi tests with axepoint Since wireless backhaul doesn't work on RAX40 and never will, it doesn't make any sense to have these tests in CI. Instead, add them for axepoint. The yml file is created my simply renaming it and replacing "netgear-rax40" with "axepoint". Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- .gitlab-ci.yml | 4 +- ...r-rax40-bhwifi.yml => axepoint-bhwifi.yml} | 564 +++++++++--------- 2 files changed, 284 insertions(+), 284 deletions(-) rename ci/certification/{netgear-rax40-bhwifi.yml => axepoint-bhwifi.yml} (51%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3a54d0cbd6..9d8f491446 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,9 +7,9 @@ stages: - test - certification-dummy - certification-netgear-rax40 - - certification-netgear-rax40-bhwifi - certification-turris-omnia - certification-axepoint + - certification-axepoint-bhwifi - upload .image-build: @@ -347,6 +347,6 @@ include: - local: "/ci/certification/generic.yml" - local: "/ci/certification/dummy.yml" - local: "/ci/certification/netgear-rax40.yml" - - local: "/ci/certification/netgear-rax40-bhwifi.yml" - local: "/ci/certification/turris-omnia.yml" - local: "/ci/certification/axepoint.yml" + - local: "/ci/certification/axepoint-bhwifi.yml" diff --git a/ci/certification/netgear-rax40-bhwifi.yml b/ci/certification/axepoint-bhwifi.yml similarity index 51% rename from ci/certification/netgear-rax40-bhwifi.yml rename to ci/certification/axepoint-bhwifi.yml index 622b50720c..932c2aafe9 100644 --- a/ci/certification/netgear-rax40-bhwifi.yml +++ b/ci/certification/axepoint-bhwifi.yml @@ -1,933 +1,933 @@ -.certification:netgear-rax40-bhwifi: - stage: certification-netgear-rax40-bhwifi - extends: .certification:netgear-rax40 +.certification:axepoint-bhwifi: + stage: certification-axepoint-bhwifi + extends: .certification:axepoint -MAP-4.2.2_BH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.2.2_BH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.2_BH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.2_BH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.2.2_BH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.2.2_BH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.2_BH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.2_BH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.2.3_BHWIFI_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.2.3_BHWIFI_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.3_BHWIFI_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.3_BHWIFI_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.2.3_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.2.3_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.3_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.3_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.2.3_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.2.3_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.3_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.2.3_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.3.1_BHWIFI:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.3.1_BHWIFI:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.1_BHWIFI:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.1_BHWIFI:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.3.2_BHWIFI_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.3.2_BHWIFI_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.2_BHWIFI_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.2_BHWIFI_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.3.2_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.3.2_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.2_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.2_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.3.2_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.3.2_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.2_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.3.2_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.4.1_BHWIFI:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.4.1_BHWIFI:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.1_BHWIFI:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.1_BHWIFI:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.4.2_BHWIFI_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.4.2_BHWIFI_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.2_BHWIFI_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.2_BHWIFI_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.4.2_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.4.2_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.2_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.2_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.4.2_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.4.2_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.2_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.2_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.4.3_BHWIFI_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.4.3_BHWIFI_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.3_BHWIFI_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.3_BHWIFI_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.4.3_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.4.3_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.3_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.3_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.4.3_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.4.3_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.3_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.4.3_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.5.1_BHWIFI:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.5.1_BHWIFI:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.1_BHWIFI:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.1_BHWIFI:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.5.2_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.5.2_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.2_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.2_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.5.3_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.5.3_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.3_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.3_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.5.3_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.5.3_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.3_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.5.3_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.6.1_BHWIFI:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.6.1_BHWIFI:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.1_BHWIFI:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.1_BHWIFI:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.6.2_BHWIFI_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.6.2_BHWIFI_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.2_BHWIFI_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.2_BHWIFI_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.6.2_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.6.2_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.2_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.2_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.6.2_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.6.2_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.2_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.2_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.6.3_BHWIFI:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.6.3_BHWIFI:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.3_BHWIFI:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.6.3_BHWIFI:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.1_BH24G_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.1_BH24G_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.1_BH24G_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.1_BH24G_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.1_BH5GL_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.1_BH5GL_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.1_BH5GL_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.1_BH5GL_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.1_BH5GH_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.1_BH5GH_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.1_BH5GH_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.1_BH5GH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.2_BH24G_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.2_BH24G_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.2_BH24G_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.2_BH24G_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.2_BH5GL_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.2_BH5GL_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.2_BH5GL_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.2_BH5GL_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.2_BH5GH_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.2_BH5GH_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.2_BH5GH_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.2_BH5GH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.4_BHWIFI_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.4_BHWIFI_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.4_BHWIFI_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.4_BHWIFI_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.4_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.4_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.4_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.4_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.4_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.4_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.4_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.4_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.5_BHWIFI_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.5_BHWIFI_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.5_BHWIFI_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.5_BHWIFI_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.5_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.5_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.5_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.5_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.5_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.5_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.5_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.5_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.6_BHWIFI_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.6_BHWIFI_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.6_BHWIFI_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.6_BHWIFI_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.6_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.6_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.6_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.6_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.6_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.6_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.6_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.6_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.7_BHWIFI_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.7_BHWIFI_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.7_BHWIFI_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.7_BHWIFI_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.7_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.7_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.7_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.7_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.7_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.7_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.7_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.7_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.8_BHWIFI_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.8_BHWIFI_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.8_BHWIFI_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.8_BHWIFI_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.8_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.8_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.8_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.8_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.8_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.8_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.8_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.8_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.7.9_BHWIFI:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.7.9_BHWIFI:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.9_BHWIFI:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.7.9_BHWIFI:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.8.1_BHWIFI_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.8.1_BHWIFI_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.1_BHWIFI_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.1_BHWIFI_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.8.1_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.8.1_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.1_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.1_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.8.1_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.8.1_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.1_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.1_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.8.2_BHWIFI_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.8.2_BHWIFI_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.2_BHWIFI_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.2_BHWIFI_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.8.2_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.8.2_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.2_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.2_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.8.2_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.8.2_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.2_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.2_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.8.3_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.8.3_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.3_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.3_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.8.4_BHWIFI_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.8.4_BHWIFI_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.4_BHWIFI_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.4_BHWIFI_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.8.4_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.8.4_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.4_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.4_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.8.4_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.8.4_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.4_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.4_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.8.5_BHWIFI_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.8.5_BHWIFI_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.5_BHWIFI_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.5_BHWIFI_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.8.5_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.8.5_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.5_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.5_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.8.5_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.8.5_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.5_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.8.5_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.9.1_BH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.9.1_BH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.9.1_BH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.9.1_BH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.9.1_BH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.9.1_BH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.9.1_BH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.9.1_BH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.9.1_BH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.9.1_BH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.9.1_BH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.9.1_BH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.1_BH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.1_BH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.1_BH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.1_BH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.1_BH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.1_BH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.1_BH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.1_BH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.1_BH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.1_BH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.1_BH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.1_BH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.2_BH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.2_BH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.2_BH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.2_BH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.2_BH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.2_BH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.2_BH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.2_BH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.2_BH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.2_BH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.2_BH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.2_BH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.3_BHWIFI_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.3_BHWIFI_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.3_BHWIFI_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.3_BHWIFI_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.3_BHWIFI_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.3_BHWIFI_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.3_BHWIFI_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.3_BHWIFI_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.3_BHWIFI_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.3_BHWIFI_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.3_BHWIFI_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.3_BHWIFI_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.5_BH24G_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.5_BH24G_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH24G_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH24G_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.5_BH24G_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.5_BH24G_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH24G_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH24G_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.5_BH24G_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.5_BH24G_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH24G_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH24G_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.5_BH5GL_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.5_BH5GL_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH5GL_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH5GL_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.5_BH5GL_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.5_BH5GL_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH5GL_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH5GL_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.5_BH5GL_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.5_BH5GL_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH5GL_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH5GL_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.5_BH5GH_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.5_BH5GH_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH5GH_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH5GH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.5_BH5GH_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.5_BH5GH_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH5GH_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH5GH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.5_BH5GH_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.5_BH5GH_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH5GH_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.5_BH5GH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.6_BH24G_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.6_BH24G_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH24G_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH24G_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.6_BH24G_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.6_BH24G_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH24G_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH24G_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.6_BH24G_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.6_BH24G_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH24G_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH24G_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.6_BH5GL_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.6_BH5GL_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH5GL_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH5GL_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.6_BH5GL_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.6_BH5GL_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH5GL_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH5GL_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.6_BH5GL_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.6_BH5GL_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH5GL_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH5GL_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.6_BH5GH_FH24G:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.6_BH5GH_FH24G:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH5GH_FH24G:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH5GH_FH24G:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.6_BH5GH_FH5GL:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.6_BH5GH_FH5GL:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH5GH_FH5GL:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH5GH_FH5GL:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.10.6_BH5GH_FH5GH:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.10.6_BH5GH_FH5GH:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH5GH_FH5GH:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.10.6_BH5GH_FH5GH:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.11.1_BHWIFI:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.11.1_BHWIFI:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.11.1_BHWIFI:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.11.1_BHWIFI:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.12.1_BHWIFI:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.12.1_BHWIFI:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.12.1_BHWIFI:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.12.1_BHWIFI:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true -MAP-4.12.2_BHWIFI:netgear-rax40: - extends: .certification:netgear-rax40-bhwifi +MAP-4.12.2_BHWIFI:axepoint: + extends: .certification:axepoint-bhwifi rules: # If the last commit description contains the test name and we're not on master, run it. # Otherwise, make it a manual job - - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.12.2_BHWIFI:netgear-rax40.*/ && $CI_COMMIT_REF_NAME != "master"' + - if: '$CI_COMMIT_DESCRIPTION =~ /.*MAP-4.12.2_BHWIFI:axepoint.*/ && $CI_COMMIT_REF_NAME != "master"' when: on_success - when: manual allow_failure: true From 3751146617f5840691cf6d0bc14f3da1111378f3 Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Sun, 5 Jul 2020 14:48:07 +0000 Subject: [PATCH 199/453] tools: docker: builder openwrt bump feed_wlan_6x Update feed_wlan_6x dddeadc60130cf90b620b36719b8cfe267555bee: "swpal: add patch to associate sta interface to br-lan" With this patch, supplicant will always put STA interfaces in br-lan (currently hard coded) when they get connected, and remove them when they get disconnected. Signed-off-by: Tomer Eliyahu --- tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml b/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml index c357947c83..b228190ec1 100644 --- a/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml +++ b/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml @@ -15,7 +15,7 @@ hash: af078af5408654ca2e759ea7afcf92163282e86e - name: feed_wlan_6x uri: https://intel.prpl.dev/prplmesh/feed_wlan_6x.git - hash: 1acf2f19c489c72478d3ae74ee59b5fb06a6ee7e + hash: dddeadc60130cf90b620b36719b8cfe267555bee - name: feed_prpl uri: https://git.prpl.dev/prplmesh/feed-prpl.git hash: 89e6602655713f8487c72d8d636daa610d76a468 From 79a1e77e8b3ca389a5723789040d5c8c58bef651 Mon Sep 17 00:00:00 2001 From: Tomer Eliyahu Date: Sun, 5 Jul 2020 15:02:15 +0000 Subject: [PATCH 200/453] agent: backhaul manager wps onboarding support Add wps onboarding initial support by modifying the wireless backhaul FSM to always wait for WPS. This is good enough for certification, but not for product, since after reboot the whole process needs to start all over again. In addition, the only support added in this patch is for UCC command which triggers the onboarding. Summary of changes: - On WPA_ATTACH, move to WAIT_WPS state without checking for connected - On Event:Connected, move to MASTER_DISCOVERY This assumes that the platform is handling the backhaul link, e.g. when it gets connected it is automatically added to the bridge. Signed-off-by: Tomer Eliyahu Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- .../backhaul_manager_thread.cpp | 108 +++++++++++------- .../backhaul_manager_thread.h | 4 + 2 files changed, 69 insertions(+), 43 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 9f73184a05..bba99d6fb3 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -1335,8 +1335,7 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) } case EState::WPA_ATTACH: { - bool success = true; - bool connected = false; + bool success = true; for (auto soc : slaves_sockets) { std::string iface = soc->sta_iface; @@ -1376,22 +1375,6 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) success = false; break; } - - if (!roam_flag && soc->sta_wlan_hal->is_connected()) { - if (!soc->sta_wlan_hal->update_status()) { - LOG(ERROR) << "failed to update sta status"; - success = false; - break; - } - connected = true; - m_sConfig.wireless_iface = iface; - m_sConfig.eType = SBackhaulConfig::EType::Wireless; - selected_bssid = soc->sta_wlan_hal->get_bssid(); - selected_bssid_channel = soc->sta_wlan_hal->get_channel(); - soc->slave_is_backhaul_manager = true; - break; - } - } else if (attach_state == bwl::HALState::Failed) { // Delete the HAL instance soc->sta_wlan_hal.reset(); @@ -1414,12 +1397,19 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) state_attempts = 0; // for next state - if (connected) { - FSM_MOVE_STATE(MASTER_DISCOVERY); - } else { - FSM_MOVE_STATE(INITIATE_SCAN); + state_time_stamp_timeout = + std::chrono::steady_clock::now() + std::chrono::seconds(STATE_WAIT_WPS_TIMEOUT_SECONDS); + FSM_MOVE_STATE(WAIT_WPS); + break; + } + // Wait for WPS command + case EState::WAIT_WPS: { + if (!onboarding && !local_gw && + std::chrono::steady_clock::now() > state_time_stamp_timeout) { + LOG(ERROR) << STATE_WAIT_WPS_TIMEOUT_SECONDS + << " seconds has passed on state WAIT_WPS, stopping thread!"; + return false; } - break; } case EState::INITIATE_SCAN: { @@ -3657,6 +3647,10 @@ bool backhaul_manager::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t eve //this is generally not supposed to happen LOG(WARNING) << "event iface != wireless iface!"; } + if (FSM_IS_IN_STATE(WAIT_WPS)) { + m_sConfig.wireless_iface = iface; + FSM_MOVE_STATE(MASTER_DISCOVERY); + } if (FSM_IS_IN_STATE(WIRELESS_ASSOCIATE_4ADDR_WAIT)) { LOG(DEBUG) << "successful connect on iface=" << iface; if (hidden_ssid) { @@ -3715,11 +3709,12 @@ bool backhaul_manager::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t eve FSM_MOVE_STATE(OPERATIONAL); } } - } break; case Event::Disconnected: { - + if (FSM_IS_IN_STATE(WAIT_WPS)) { + return true; + } if (iface == m_sConfig.wireless_iface) { if (FSM_IS_IN_STATE(OPERATIONAL) || FSM_IS_IN_STATE(CONNECTED)) { platform_notify_error(bpl::eErrorCode::BH_DISCONNECTED, @@ -3775,7 +3770,9 @@ bool backhaul_manager::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t eve } break; case Event::ScanResults: { - + if (FSM_IS_IN_STATE(WAIT_WPS)) { + return true; + } if (!FSM_IS_IN_STATE(WAIT_FOR_SCAN_RESULTS)) { LOG(DEBUG) << "not waiting for scan results, ignoring event"; return true; @@ -3856,7 +3853,7 @@ bool backhaul_manager::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t eve } return true; -} +} // namespace beerocks bool backhaul_manager::select_bssid() { @@ -4685,25 +4682,50 @@ const std::string backhaul_manager::freq_to_radio_mac(eFreqType freq) const bool backhaul_manager::start_wps_pbc(const sMacAddr &radio_mac) { - auto msg = - message_com::create_vs_message( - cmdu_tx); - if (!msg) { - LOG(ERROR) << "Failed building message!"; - return false; - } + if ((m_eFSMState == EState::OPERATIONAL)) { + // WPS PBC registration on AP interface + auto msg = message_com::create_vs_message< + beerocks_message::cACTION_BACKHAUL_START_WPS_PBC_REQUEST>(cmdu_tx); + if (!msg) { + LOG(ERROR) << "Failed building message!"; + return false; + } - auto it = std::find_if( - slaves_sockets.begin(), slaves_sockets.end(), - [&](std::shared_ptr slave) { return slave->radio_mac == radio_mac; }); - if (it == slaves_sockets.end()) { - LOG(ERROR) << "couldn't find slave for radio mac " << radio_mac; - return false; + auto it = std::find_if( + slaves_sockets.begin(), slaves_sockets.end(), + [&](std::shared_ptr slave) { return slave->radio_mac == radio_mac; }); + if (it == slaves_sockets.end()) { + LOG(ERROR) << "couldn't find slave for radio mac " << radio_mac; + return false; + } + + auto soc = *it; + LOG(DEBUG) << "Start WPS PBC registration on interface " << soc->hostap_iface; + return message_com::send_cmdu(soc->slave, cmdu_tx); + } else { + // WPS PBC registration on STA interface + auto sta_wlan_hal = get_selected_backhaul_sta_wlan_hal(); + if (!sta_wlan_hal) { + LOG(ERROR) << "Failed to get backhaul STA hal"; + return false; + } + return sta_wlan_hal->start_wps_pbc(); } +} - auto soc = *it; - LOG(DEBUG) << "Start WPS PBC registration on interface " << soc->hostap_iface; - return message_com::send_cmdu(soc->slave, cmdu_tx); +std::shared_ptr backhaul_manager::get_selected_backhaul_sta_wlan_hal() +{ + std::string selected_backhaul = m_agent_ucc_listener->get_selected_backhaul(); + auto selected_backhaul_it = + std::find_if(slaves_sockets.begin(), slaves_sockets.end(), + [&selected_backhaul](std::shared_ptr soc) { + return tlvf::mac_from_string(selected_backhaul) == soc->radio_mac; + }); + if (selected_backhaul_it == slaves_sockets.end()) { + LOG(ERROR) << "Invalid backhaul"; + return nullptr; + } + return (*selected_backhaul_it)->sta_wlan_hal; } } // namespace beerocks diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 3c0092e13b..6c2a130b8b 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -76,6 +76,8 @@ class backhaul_manager : public btl::transport_socket_thread { // Forward declaration struct sRadioInfo; + std::shared_ptr get_selected_backhaul_sta_wlan_hal(); + virtual bool handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_rx) override; virtual void before_select() override; virtual void after_select(bool timeout) override; @@ -253,6 +255,7 @@ class backhaul_manager : public btl::transport_socket_thread { const int WIRELESS_WAIT_FOR_RECONNECT_TIMEOUT = 2; const int RSSI_POLL_INTERVAL_MS = 1000; const int STATE_WAIT_ENABLE_TIMEOUT_SECONDS = 600; + const int STATE_WAIT_WPS_TIMEOUT_SECONDS = 600; const int AP_BLACK_LIST_TIMEOUT_SECONDS = 120; const int AP_BLACK_LIST_FAILED_ATTEMPTS_THRESHOLD = 2; const int INTERFACE_BRING_UP_TIMEOUT_SECONDS = 600; @@ -630,6 +633,7 @@ class backhaul_manager : public btl::transport_socket_thread { STATE(INIT_HAL) \ STATE(WPA_ATTACH) \ STATE(INITIATE_SCAN) \ + STATE(WAIT_WPS) \ STATE(WAIT_FOR_SCAN_RESULTS) \ STATE(WIRELESS_CONFIG_4ADDR_MODE) \ STATE(WIRELESS_ASSOCIATE_4ADDR) \ From 417b1154de4ac35e4d49a63bea73d230ecaa4189 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Mon, 13 Jul 2020 12:55:42 +0000 Subject: [PATCH 201/453] common: dwpal: Replace parsing of dfs-cac-completed event to kv parser Signed-off-by: Moran Shoeg --- .../beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp | 56 ++++++++----------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp index ba2d21a7fd..a24c5a42d6 100644 --- a/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp @@ -1693,6 +1693,9 @@ bool ap_wlan_hal_dwpal::process_dwpal_event(char *buffer, int bufLen, const std: { LOG(TRACE) << __func__ << " - opcode: |" << opcode << "|"; + // For key-value parser. + int64_t tmp_int; + auto event = dwpal_to_bwl_event(opcode); switch (event) { @@ -2330,6 +2333,9 @@ bool ap_wlan_hal_dwpal::process_dwpal_event(char *buffer, int bufLen, const std: case Event::DFS_CAC_Completed: { LOG(DEBUG) << buffer; + parsed_line_t parsed_obj; + parse_event(buffer, parsed_obj); + if (!get_radio_info().is_5ghz) { LOG(WARNING) << "DFS event on 2.4Ghz radio. Ignoring..."; return true; @@ -2344,44 +2350,30 @@ bool ap_wlan_hal_dwpal::process_dwpal_event(char *buffer, int bufLen, const std: // Initialize the message memset(msg_buff.get(), 0, sizeof(sACTION_APMANAGER_HOSTAP_DFS_CAC_COMPLETED_NOTIFICATION)); - uint8_t chan_width = 0; - size_t numOfValidArgs[6] = {0}; - FieldsToParse fieldsToParse[] = { - {NULL /*opCode*/, &numOfValidArgs[0], DWPAL_STR_PARAM, NULL, 0}, - {NULL, &numOfValidArgs[1], DWPAL_STR_PARAM, NULL, 0}, - {(void *)&msg->params.success, &numOfValidArgs[2], DWPAL_CHAR_PARAM, "cac_status=", 0}, - {(void *)&msg->params.frequency, &numOfValidArgs[3], DWPAL_INT_PARAM, "freq=", 0}, - {(void *)&msg->params.timeout, &numOfValidArgs[4], DWPAL_INT_PARAM, "timeout=", 0}, - {(void *)&chan_width, &numOfValidArgs[5], DWPAL_CHAR_PARAM, "chan_width=", 0}, - /* Must be at the end */ - {NULL, NULL, DWPAL_NUM_OF_PARSING_TYPES, NULL, 0}}; - - if (dwpal_string_to_struct_parse(buffer, bufLen, fieldsToParse, sizeof(int)) == - DWPAL_FAILURE) { - LOG(ERROR) << "DWPAL parse error ==> Abort"; + if (!read_param("cac_status", parsed_obj, tmp_int)) { + LOG(ERROR) << "Failed reading success parameter!"; return false; } + msg->params.success = tmp_int; - /* TEMP: Traces... */ - // HOSTAPD_CAC_STAT_FAILED = 0, HOSTAPD_CAC_STAT_SUCCESS = 1, HOSTAPD_CAC_STAT_PAUSED = 2 - LOG(DEBUG) << "numOfValidArgs[2]= " << numOfValidArgs[2] - << " cac_status= " << (int)msg->params.success; - LOG(DEBUG) << "numOfValidArgs[3]= " << numOfValidArgs[3] - << " freq= " << msg->params.frequency; - LOG(DEBUG) << "numOfValidArgs[4]= " << numOfValidArgs[4] - << " timeout= " << msg->params.timeout; - LOG(DEBUG) << "numOfValidArgs[5]= " << numOfValidArgs[5] - << " chan_width= " << (int)chan_width; + if (!read_param("freq", parsed_obj, tmp_int)) { + LOG(ERROR) << "Failed reading freq parameter!"; + return false; + } + msg->params.frequency = tmp_int; + msg->params.channel = son::wireless_utils::freq_to_channel(msg->params.frequency); - for (uint8_t i = 0; i < (sizeof(numOfValidArgs) / sizeof(size_t)); i++) { - if (numOfValidArgs[i] == 0) { - LOG(ERROR) << "Failed reading parsed parameter " << (int)i << " ==> Abort"; - return false; - } + if (!read_param("timeout", parsed_obj, tmp_int)) { + LOG(ERROR) << "Failed reading timeout parameter!"; + return false; } + msg->params.timeout = tmp_int; - msg->params.channel = son::wireless_utils::freq_to_channel(msg->params.frequency); - msg->params.bandwidth = dwpal_bw_to_beerocks_bw(chan_width); + if (!read_param("chan_width", parsed_obj, tmp_int)) { + LOG(ERROR) << "Failed reading chan_width parameter!"; + return false; + } + msg->params.bandwidth = dwpal_bw_to_beerocks_bw(tmp_int); // Add the message to the queue event_queue_push(Event::DFS_CAC_Completed, msg_buff); From 099b15ab6974a0fc978b0d0ea6d1b5fc9c2ab323 Mon Sep 17 00:00:00 2001 From: Alex Kanter Date: Mon, 13 Jul 2020 14:40:07 +0000 Subject: [PATCH 202/453] bwl: dwpal: support older hostapd version DFS-CAC-COMPLETED event Older intel hostapd versions and openWrt are using "success" parameter instead of "cac_status". Add support for that . Signed-off-by: Alex Kanter --- common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp index a24c5a42d6..2bfba983da 100644 --- a/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp @@ -2351,8 +2351,12 @@ bool ap_wlan_hal_dwpal::process_dwpal_event(char *buffer, int bufLen, const std: memset(msg_buff.get(), 0, sizeof(sACTION_APMANAGER_HOSTAP_DFS_CAC_COMPLETED_NOTIFICATION)); if (!read_param("cac_status", parsed_obj, tmp_int)) { - LOG(ERROR) << "Failed reading success parameter!"; - return false; + // older intel hostapd versions still use "success" parameter + // same as the original openWrt syntax , we should support it as well. + if (!read_param("success", parsed_obj, tmp_int)) { + LOG(ERROR) << "Failed reading cac finished success parameter!"; + return false; + } } msg->params.success = tmp_int; From d52db204bb53f8d3446acdca5f484081b1c78f4c Mon Sep 17 00:00:00 2001 From: Alex Kanter Date: Mon, 13 Jul 2020 21:32:02 +0000 Subject: [PATCH 203/453] kv parser: remove error print from read method read_param should remain clean, prints are not needed here. User should decide what to do depends on the return value. Signed-off-by: Alex Kanter --- common/beerocks/bwl/common/key_value_parser.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/common/beerocks/bwl/common/key_value_parser.cpp b/common/beerocks/bwl/common/key_value_parser.cpp index eb32c51797..4981d24eb3 100644 --- a/common/beerocks/bwl/common/key_value_parser.cpp +++ b/common/beerocks/bwl/common/key_value_parser.cpp @@ -174,7 +174,6 @@ bool KeyValueParser::read_param(const std::string &key, parsed_line_t &obj, int6 { auto val_iter = obj.find(key); if (val_iter == obj.end()) { - LOG(ERROR) << "param :" << key << " does not exist"; return false; } From ef8cd50d32de278182c3c0508d488627bf4f75d4 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Mon, 6 Jul 2020 21:52:54 +0200 Subject: [PATCH 204/453] bwl: remove unused SRadioStats.bss_load SRadioStats::bss_load isn't used at all, so it is better to remove it. Signed-off-by: Mario Maz --- common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp | 14 ++++++-------- .../beerocks/bwl/include/bwl/mon_wlan_hal_types.h | 1 - .../beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp | 1 - 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp index 00d078613b..ee6a37bb39 100644 --- a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp @@ -567,11 +567,10 @@ bool mon_wlan_hal_dwpal::update_radio_stats(SRadioStats &radio_stats) {(void *)&PacketsSent, &numOfValidArgs[2], DWPAL_LONG_LONG_INT_PARAM, "PacketsSent=", 0}, {(void *)&PacketsReceived, &numOfValidArgs[3], DWPAL_LONG_LONG_INT_PARAM, "PacketsReceived=", 0}, - {(void *)&radio_stats.bss_load, &numOfValidArgs[4], DWPAL_CHAR_PARAM, "BSS load=", 0}, - {(void *)&radio_stats.errors_sent, &numOfValidArgs[5], DWPAL_INT_PARAM, "ErrorsSent=", 0}, - {(void *)&radio_stats.errors_received, &numOfValidArgs[6], DWPAL_INT_PARAM, + {(void *)&radio_stats.errors_sent, &numOfValidArgs[4], DWPAL_INT_PARAM, "ErrorsSent=", 0}, + {(void *)&radio_stats.errors_received, &numOfValidArgs[5], DWPAL_INT_PARAM, "ErrorsReceived=", 0}, - {(void *)&radio_stats.noise, &numOfValidArgs[7], DWPAL_CHAR_PARAM, "Noise=", 0}, + {(void *)&radio_stats.noise, &numOfValidArgs[6], DWPAL_CHAR_PARAM, "Noise=", 0}, /* Must be at the end */ {NULL, NULL, DWPAL_NUM_OF_PARSING_TYPES, NULL, 0}}; @@ -587,10 +586,9 @@ bool mon_wlan_hal_dwpal::update_radio_stats(SRadioStats &radio_stats) // LOG(DEBUG) << "numOfValidArgs[1]= " << numOfValidArgs[1] << " BytesReceived= " << BytesReceived; // LOG(DEBUG) << "numOfValidArgs[2]= " << numOfValidArgs[2] << " PacketsSent= " << PacketsSent; // LOG(DEBUG) << "numOfValidArgs[3]= " << numOfValidArgs[3] << " PacketsReceived= " << PacketsReceived; - // LOG(DEBUG) << "numOfValidArgs[4]= " << numOfValidArgs[4] << " BSS load= " << (int)radio_stats.bss_load; - // LOG(DEBUG) << "numOfValidArgs[5]= " << numOfValidArgs[5] << " ErrorsSent= " << radio_stats.errors_sent; - // LOG(DEBUG) << "numOfValidArgs[6]= " << numOfValidArgs[6] << " ErrorsReceived= " << radio_stats.errors_received; - // LOG(DEBUG) << "numOfValidArgs[7]= " << numOfValidArgs[7] << " Noise= " << (int)radio_stats.noise; + // LOG(DEBUG) << "numOfValidArgs[4]= " << numOfValidArgs[4] << " ErrorsSent= " << radio_stats.errors_sent; + // LOG(DEBUG) << "numOfValidArgs[5]= " << numOfValidArgs[5] << " ErrorsReceived= " << radio_stats.errors_received; + // LOG(DEBUG) << "numOfValidArgs[6]= " << numOfValidArgs[6] << " Noise= " << (int)radio_stats.noise; /* End of TEMP: Traces... */ for (uint8_t i = 0; i < (sizeof(numOfValidArgs) / sizeof(size_t)); i++) { diff --git a/common/beerocks/bwl/include/bwl/mon_wlan_hal_types.h b/common/beerocks/bwl/include/bwl/mon_wlan_hal_types.h index ea078a0b85..3d4f36af11 100644 --- a/common/beerocks/bwl/include/bwl/mon_wlan_hal_types.h +++ b/common/beerocks/bwl/include/bwl/mon_wlan_hal_types.h @@ -33,7 +33,6 @@ struct SRadioStats { uint32_t rx_bytes; uint32_t errors_sent; uint32_t errors_received; - uint8_t bss_load; int8_t noise; // uint8_t channel_load_tot_prev; // uint8_t channel_load_tot_curr; diff --git a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp index f670e43507..76b46bbff6 100644 --- a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp +++ b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp @@ -110,7 +110,6 @@ bool mon_wlan_hal_nl80211::update_radio_stats(SRadioStats &radio_stats) radio_stats.rx_packets_cnt = 0; radio_stats.rx_packets = 0; - radio_stats.bss_load = 0; radio_stats.errors_sent = 0; radio_stats.errors_received = 0; radio_stats.noise = 0; From 92231bcf3aca33bd02e6d2e02d3e25f10c7f067e Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Mon, 6 Jul 2020 22:24:47 +0200 Subject: [PATCH 205/453] bwl: move calc_curr_traffic() to base class This is a preparatory commit. Method calc_curr_traffic() is defined in mon_wlan_hal_dwpal and used when getting radio and VAP statistics. In order to later use it also from mon_wlan_hal_nl80211, move it to a common base class. Signed-off-by: Mario Maz --- common/beerocks/bwl/common/base_wlan_hal.cpp | 10 ++++++++++ .../beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp | 19 ++++--------------- .../beerocks/bwl/include/bwl/base_wlan_hal.h | 2 ++ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/common/beerocks/bwl/common/base_wlan_hal.cpp b/common/beerocks/bwl/common/base_wlan_hal.cpp index dc105208e7..7bc2ad7d7e 100644 --- a/common/beerocks/bwl/common/base_wlan_hal.cpp +++ b/common/beerocks/bwl/common/base_wlan_hal.cpp @@ -90,4 +90,14 @@ bool base_wlan_hal::process_int_events() return m_int_event_cb(event); } +void base_wlan_hal::calc_curr_traffic(uint64_t val, uint64_t &total, uint32_t &curr) +{ + if (val >= total) { + curr = val - total; + } else { + curr = val; + } + total = val; +} + } // namespace bwl diff --git a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp index ee6a37bb39..8a5d7832fc 100644 --- a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp @@ -101,16 +101,6 @@ static mon_wlan_hal::Event dwpal_nl_to_bwl_event(uint8_t cmd) } } -static void calc_curr_traffic(const uint64_t val, uint64_t &total, uint32_t &curr) -{ - if (val >= total) { - curr = val - total; - } else { - curr = val; - } - total = val; -} - /** * @brief get channel pool frquencies for channel scan parameters. * @@ -598,11 +588,10 @@ bool mon_wlan_hal_dwpal::update_radio_stats(SRadioStats &radio_stats) } } - calc_curr_traffic((uint64_t)BytesSent, radio_stats.tx_bytes_cnt, radio_stats.tx_bytes); - calc_curr_traffic((uint64_t)BytesReceived, radio_stats.rx_bytes_cnt, radio_stats.rx_bytes); - calc_curr_traffic((uint64_t)PacketsSent, radio_stats.tx_packets_cnt, radio_stats.tx_packets); - calc_curr_traffic((uint64_t)PacketsReceived, radio_stats.rx_packets_cnt, - radio_stats.rx_packets); + calc_curr_traffic(BytesSent, radio_stats.tx_bytes_cnt, radio_stats.tx_bytes); + calc_curr_traffic(BytesReceived, radio_stats.rx_bytes_cnt, radio_stats.rx_bytes); + calc_curr_traffic(PacketsSent, radio_stats.tx_packets_cnt, radio_stats.tx_packets); + calc_curr_traffic(PacketsReceived, radio_stats.rx_packets_cnt, radio_stats.rx_packets); return true; } diff --git a/common/beerocks/bwl/include/bwl/base_wlan_hal.h b/common/beerocks/bwl/include/bwl/base_wlan_hal.h index 2d4cda09d2..6de1cc5224 100644 --- a/common/beerocks/bwl/include/bwl/base_wlan_hal.h +++ b/common/beerocks/bwl/include/bwl/base_wlan_hal.h @@ -231,6 +231,8 @@ class base_wlan_hal { hal_conf_t m_hal_conf; + void calc_curr_traffic(uint64_t val, uint64_t &total, uint32_t &curr); + // Private data-members: private: HALType m_type = HALType::Invalid; From 4a873fdf8cd4859acdeafe760f99d6bdece4c4e3 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Mon, 6 Jul 2020 22:28:46 +0200 Subject: [PATCH 206/453] bcl: network_utils: create method to get iface stats Create method to get usage statistics of a local network interface. This method is copied and extended from 802_3 link metrics collector. In a future commit, code will be refactored to avoid duplication. Signed-off-by: Mario Maz --- .../bcl/include/bcl/network/net_struct.h | 38 +++ .../bcl/include/bcl/network/network_utils.h | 10 + .../bcl/source/network/get_iface_stats.cpp | 239 ++++++++++++++++++ 3 files changed, 287 insertions(+) create mode 100644 common/beerocks/bcl/source/network/get_iface_stats.cpp diff --git a/common/beerocks/bcl/include/bcl/network/net_struct.h b/common/beerocks/bcl/include/bcl/network/net_struct.h index 8c0e4854b5..a2c983b7fd 100644 --- a/common/beerocks/bcl/include/bcl/network/net_struct.h +++ b/common/beerocks/bcl/include/bcl/network/net_struct.h @@ -52,6 +52,44 @@ typedef struct sScanResult { bool operator!=(sScanResult const &rhs) const { return !(rhs == *this); } } __attribute__((packed)) sScanResult; +/** + * @brief Interface statistics. + * + * Information in this structure is obtained from IFLA_STATS attribute of a rtnetlink message + * through a Rtnetlink socket. + */ +struct sInterfaceStats { + /** + * Total bytes transmitted. + */ + uint32_t tx_bytes = 0; + + /** + * Packet transmit problems. + */ + uint32_t tx_errors = 0; + + /** + * Total packets transmitted. + */ + uint32_t tx_packets = 0; + + /** + * Total bytes received. + */ + uint32_t rx_bytes = 0; + + /** + * Bad packets received. + */ + uint32_t rx_errors = 0; + + /** + * Total packets received. + */ + uint32_t rx_packets = 0; +}; + } // namespace net } // namespace beerocks diff --git a/common/beerocks/bcl/include/bcl/network/network_utils.h b/common/beerocks/bcl/include/bcl/network/network_utils.h index 46cf681f25..b7cc177b19 100644 --- a/common/beerocks/bcl/include/bcl/network/network_utils.h +++ b/common/beerocks/bcl/include/bcl/network/network_utils.h @@ -161,6 +161,16 @@ class network_utils { */ static bool linux_iface_get_speed(const std::string &iface, uint32_t &speed); + /** + * @brief Gets interface statistics for the given network interface. + * + * @param[in] iface Name of the local network interface. + * @param[out] iface_stats Interface statistics. + * + * @return True on success and false otherwise. + */ + static bool get_iface_stats(const std::string &iface, sInterfaceStats &iface_stats); + static bool arp_send(const std::string &iface, const std::string &dst_ip, const std::string &src_ip, sMacAddr dst_mac, sMacAddr src_mac, int count, int arp_socket = -1); diff --git a/common/beerocks/bcl/source/network/get_iface_stats.cpp b/common/beerocks/bcl/source/network/get_iface_stats.cpp new file mode 100644 index 0000000000..c7c51f43f4 --- /dev/null +++ b/common/beerocks/bcl/source/network/get_iface_stats.cpp @@ -0,0 +1,239 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define IFLIST_REPLY_BUFFER 8192 + +namespace beerocks { +namespace net { + +/** + * @brief Netlink request type. + */ +struct nl_req_t { + /** + * Netlink message + */ + nlmsghdr hdr; + + /** + * "general form of address family dependent" message, i.e. how to tell which AF we are + * interested in. */ + rtgenmsg gen; +}; + +/** + * @brief Gets interface statistics for the given network interface. + * + * Gets interface stats for given network interface from the specified Netlink message of type + * RTM_NEWLINK. + * + * @param[in] msg_ptr Pointer to the Netlink message containing the data. + * @param[in] iface_name Name of the network interface. + * @param[in, out] iface_stats Interface statistics structure with values read. + * + * @return True on success and false otherwise. + */ +static bool get_iface_stats(const nlmsghdr *msg_ptr, const std::string &iface_name, + sInterfaceStats &iface_stats) +{ + size_t length = 0; + if (msg_ptr->nlmsg_len <= NLMSG_LENGTH(sizeof(ifinfomsg))) { + return false; + } + + length = msg_ptr->nlmsg_len - NLMSG_LENGTH(sizeof(ifinfomsg)); + + /** + * Loop over all attributes of the RTM_NEWLINK message + */ + bool iface_name_matched = false; + ifinfomsg *iface = static_cast(NLMSG_DATA(msg_ptr)); + for (const rtattr *attribute = IFLA_RTA(iface); RTA_OK(attribute, length); + attribute = RTA_NEXT(attribute, length)) { + switch (attribute->rta_type) { + case IFLA_IFNAME: + /** + * This message contains the stats for the interface we are interested in + */ + if (0 == std::strncmp(iface_name.c_str(), static_cast(RTA_DATA(attribute)), + iface_name.length() + 1)) { + iface_name_matched = true; + } + break; + case IFLA_STATS: + if (iface_name_matched) { + rtnl_link_stats *stats = static_cast(RTA_DATA(attribute)); + + iface_stats.tx_bytes = stats->tx_bytes; + iface_stats.tx_errors = stats->tx_errors; + iface_stats.tx_packets = stats->tx_packets; + iface_stats.rx_bytes = stats->rx_bytes; + iface_stats.rx_errors = stats->rx_errors; + iface_stats.rx_packets = stats->rx_packets; + + return true; + } + break; + } + } + + return false; +} + +/** + * @brief Gets interface statistics for the given network interface. + * + * Gets interface stats for given network interface by sending a RTM_GETLINK Netlink request + * through the specified Netlink socket and parsing received response. + * + * @param[in] fd File descriptor of a connected Netlink socket. + * @param[in] iface_name Name of the network interface. + * @param[in, out] iface_stats Interface statistics structure with values read. + * + * @return True on success and false otherwise. + */ +static bool get_iface_stats(int fd, const std::string &iface_name, sInterfaceStats &iface_stats) +{ + bool result = false; + + sockaddr_nl socket{}; /* the remote (kernel space) side of the communication */ + msghdr rtnl_msg{}; /* generic msghdr struct for use with sendmsg */ + iovec io{}; /* IO vector for sendmsg */ + nl_req_t req{}; /* structure that describes the Netlink packet itself */ + + /** + * Netlink socket is ready for use, prepare and send request + */ + socket.nl_family = AF_NETLINK; /* fill-in kernel address (destination of our message) */ + + req.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(rtgenmsg)); + req.hdr.nlmsg_type = RTM_GETLINK; + req.hdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP; + req.hdr.nlmsg_seq = 1; + req.hdr.nlmsg_pid = 0; + req.gen.rtgen_family = AF_PACKET; /* no preferred AF, we will get *all* interfaces */ + + io.iov_base = &req; + io.iov_len = req.hdr.nlmsg_len; + rtnl_msg.msg_iov = &io; + rtnl_msg.msg_iovlen = 1; + rtnl_msg.msg_name = &socket; + rtnl_msg.msg_namelen = sizeof(socket); + + if (sendmsg(fd, static_cast(&rtnl_msg), 0) < 0) { + LOG(ERROR) << "Unable to send message through Netlink socket: " << strerror(errno); + return false; + } + + bool msg_done = false; /* flag to end loop parsing */ + + /** + * Parse reply until message is done + */ + while (!msg_done) { + msghdr rtnl_reply{}; /* generic msghdr structure for use with recvmsg */ + + /* a large buffer to receive lots of link information */ + char reply[IFLIST_REPLY_BUFFER]; + + io.iov_base = reply; + io.iov_len = IFLIST_REPLY_BUFFER; + rtnl_reply.msg_iov = &io; + rtnl_reply.msg_iovlen = 1; + rtnl_reply.msg_name = &socket; + rtnl_reply.msg_namelen = sizeof(socket); + + /** + * Read as much data as fits in the receive buffer + */ + int length = recvmsg(fd, &rtnl_reply, 0); + for (const nlmsghdr *msg_ptr = reinterpret_cast(reply); + NLMSG_OK(msg_ptr, length); msg_ptr = NLMSG_NEXT(msg_ptr, length)) { + switch (msg_ptr->nlmsg_type) { + case NLMSG_DONE: + /** + * This is the special meaning NLMSG_DONE message we asked for by using NLM_F_DUMP flag + */ + msg_done = true; + break; + case RTM_NEWLINK: + /** + * This is a RTM_NEWLINK message, which contains lots of information about a link + */ + if (get_iface_stats(msg_ptr, iface_name, iface_stats)) { + msg_done = true; + result = true; + } + break; + } + } + } + + return result; +} + +/** + * @brief Gets interface statistics for the given network interface. + * + * Gets interface stats for given network by means of a Netlink socket using NETLINK_ROUTE + * protocol. + * + * @param[in] iface_name Name of the network interface. + * @param[in, out] iface_stats Interface statistics structure with values read. + * + * @return True on success and false otherwise. + */ +static bool get_iface_stats(const std::string &iface_name, sInterfaceStats &iface_stats) +{ + /** + * Create Netlink socket for kernel/user-space communication. + * No need to call bind() as packets are sent only between the kernel and the originating + * process (no multicasting). + */ + int fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); + if (fd < 0) { + LOG(ERROR) << "Failed creating Netlink socket: " << strerror(errno); + return false; + } + + /** + * Get interface stats using Netlink socket + */ + bool result = get_iface_stats(fd, iface_name, iface_stats); + + /** + * Clean up and finish properly + */ + close(fd); + + return result; +} + +bool network_utils::get_iface_stats(const std::string &iface_name, sInterfaceStats &iface_stats) +{ + return beerocks::net::get_iface_stats(iface_name, iface_stats); +} + +} // namespace net +} // namespace beerocks From e64c31ba934a74333900e426bb4f3fdda8304fe7 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Mon, 6 Jul 2020 22:32:18 +0200 Subject: [PATCH 207/453] bwl: monitor: get radio and VAP stats for nl80211 Use network_utils::get_iface_stats() to obtain radio and VAP stats in the nl80211 flavor of the BWL. Signed-off-by: Mario Maz --- .../bwl/nl80211/mon_wlan_hal_nl80211.cpp | 52 ++++++++----------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp index 76b46bbff6..f872db6def 100644 --- a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp +++ b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp @@ -98,20 +98,19 @@ mon_wlan_hal_nl80211::~mon_wlan_hal_nl80211() {} bool mon_wlan_hal_nl80211::update_radio_stats(SRadioStats &radio_stats) { - radio_stats.tx_bytes_cnt = 0; - radio_stats.tx_bytes = 0; - - radio_stats.rx_bytes_cnt = 0; - radio_stats.rx_bytes = 0; - - radio_stats.tx_packets_cnt = 0; - radio_stats.tx_packets = 0; + beerocks::net::sInterfaceStats iface_stats; + if (!beerocks::net::network_utils::get_iface_stats(get_iface_name(), iface_stats)) { + LOG(ERROR) << "Failed to get interface statistics for interface " << get_iface_name(); + return false; + } - radio_stats.rx_packets_cnt = 0; - radio_stats.rx_packets = 0; + calc_curr_traffic(iface_stats.tx_bytes, radio_stats.tx_bytes_cnt, radio_stats.tx_bytes); + calc_curr_traffic(iface_stats.rx_bytes, radio_stats.rx_bytes_cnt, radio_stats.rx_bytes); + calc_curr_traffic(iface_stats.tx_packets, radio_stats.tx_packets_cnt, radio_stats.tx_packets); + calc_curr_traffic(iface_stats.rx_packets, radio_stats.rx_packets_cnt, radio_stats.rx_packets); - radio_stats.errors_sent = 0; - radio_stats.errors_received = 0; + radio_stats.errors_sent = iface_stats.tx_errors; + radio_stats.errors_received = iface_stats.rx_errors; radio_stats.noise = 0; return true; @@ -119,28 +118,21 @@ bool mon_wlan_hal_nl80211::update_radio_stats(SRadioStats &radio_stats) bool mon_wlan_hal_nl80211::update_vap_stats(const std::string &vap_iface_name, SVapStats &vap_stats) { - vap_stats.tx_bytes_cnt = 0; - vap_stats.tx_bytes = 0; - - vap_stats.rx_bytes_cnt = 0; - vap_stats.rx_bytes = 0; - - vap_stats.tx_packets_cnt = 0; - vap_stats.tx_packets = 0; + beerocks::net::sInterfaceStats iface_stats; + if (!beerocks::net::network_utils::get_iface_stats(vap_iface_name, iface_stats)) { + LOG(ERROR) << "Failed to get interface statistics for interface " << vap_iface_name; + return false; + } - vap_stats.rx_packets_cnt = 0; - vap_stats.rx_packets = 0; + calc_curr_traffic(iface_stats.tx_bytes, vap_stats.tx_bytes_cnt, vap_stats.tx_bytes); + calc_curr_traffic(iface_stats.rx_bytes, vap_stats.rx_bytes_cnt, vap_stats.rx_bytes); + calc_curr_traffic(iface_stats.tx_packets, vap_stats.tx_packets_cnt, vap_stats.tx_packets); + calc_curr_traffic(iface_stats.rx_packets, vap_stats.rx_packets_cnt, vap_stats.rx_packets); - vap_stats.errors_sent = 0; - vap_stats.errors_received = 0; + vap_stats.errors_sent = iface_stats.tx_errors; + vap_stats.errors_received = iface_stats.rx_errors; vap_stats.retrans_count = 0; - // TODO: Handle timeouts/deltas externally! - // auto now = std::chrono::steady_clock::now(); - // auto time_span = std::chrono::duration_cast(now - vap_stats->last_update_time); - // vap_stats->delta_ms = float(time_span.count()); - // vap_stats->last_update_time = now; - return true; } From afe701b3b577b90ead10860714e3620bd96c981b Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Tue, 7 Jul 2020 13:45:43 +0200 Subject: [PATCH 208/453] bcl: network_utils: add unit test for get_iface_status Signed-off-by: Mario Maz --- common/beerocks/bcl/CMakeLists.txt | 1 + .../bcl/unit_tests/network_utils_test.cpp | 57 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 common/beerocks/bcl/unit_tests/network_utils_test.cpp diff --git a/common/beerocks/bcl/CMakeLists.txt b/common/beerocks/bcl/CMakeLists.txt index dc312523a1..f5dcacf620 100644 --- a/common/beerocks/bcl/CMakeLists.txt +++ b/common/beerocks/bcl/CMakeLists.txt @@ -45,6 +45,7 @@ if (BUILD_TESTS) set(TEST_PROJECT_NAME ${PROJECT_NAME}_unit_tests) set(unit_tests_sources ${bcl_sources} + ${MODULE_PATH}/unit_tests/network_utils_test.cpp ${MODULE_PATH}/unit_tests/socket_event_loop_test.cpp ${MODULE_PATH}/unit_tests/wireless_utils_test.cpp ) diff --git a/common/beerocks/bcl/unit_tests/network_utils_test.cpp b/common/beerocks/bcl/unit_tests/network_utils_test.cpp new file mode 100644 index 0000000000..7c72efead4 --- /dev/null +++ b/common/beerocks/bcl/unit_tests/network_utils_test.cpp @@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include + +#include + +#include + +namespace { + +std::vector get_iface_names() +{ + + std::vector iface_names; + + const char *path = "/sys/class/net"; + + DIR *dir = opendir(path); + if (dir) { + struct dirent *entry; + while ((entry = readdir(dir)) != NULL) { + std::string iface_name = entry->d_name; + if (iface_name == "." || iface_name == "..") { + continue; + } + iface_names.push_back(iface_name); + } + closedir(dir); + } + + return iface_names; +} + +TEST(NetworkUtilsTest, get_iface_stats_should_succeed) +{ + beerocks::net::sInterfaceStats iface_stats; + + for (const auto &iface_name : get_iface_names()) { + ASSERT_TRUE(beerocks::net::network_utils::get_iface_stats(iface_name, iface_stats)); + + std::cout << iface_name << ":" << std::endl; + std::cout << "\ttx_bytes: " << std::to_string(iface_stats.tx_bytes) << std::endl; + std::cout << "\ttx_packets: " << std::to_string(iface_stats.tx_packets) << std::endl; + std::cout << "\ttx_errors: " << std::to_string(iface_stats.tx_errors) << std::endl; + std::cout << "\trx_bytes: " << std::to_string(iface_stats.rx_bytes) << std::endl; + std::cout << "\trx_packets: " << std::to_string(iface_stats.rx_packets) << std::endl; + std::cout << "\trx_errors: " << std::to_string(iface_stats.rx_errors) << std::endl; + } +} + +} // namespace From e531e012e70e52080a43bb48d1e700774697799b Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Tue, 7 Jul 2020 14:32:35 +0200 Subject: [PATCH 209/453] agent: slave: remove duplicated code in ieee_802_3_link_metrics_collector Complete moving code from ieee_802_3_link_metrics_collector to network_utils::get_iface_stats() by removing code here. Signed-off-by: Mario Maz --- .../ieee802_3_link_metrics_collector.cpp | 278 +++--------------- ci/cppcheck/cppcheck_existing_issues.txt | 1 - 2 files changed, 33 insertions(+), 246 deletions(-) diff --git a/agent/src/beerocks/slave/link_metrics/ieee802_3_link_metrics_collector.cpp b/agent/src/beerocks/slave/link_metrics/ieee802_3_link_metrics_collector.cpp index 832d47e83a..e4a546b970 100644 --- a/agent/src/beerocks/slave/link_metrics/ieee802_3_link_metrics_collector.cpp +++ b/agent/src/beerocks/slave/link_metrics/ieee802_3_link_metrics_collector.cpp @@ -12,264 +12,52 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - // SPEED values #include -#define IFLIST_REPLY_BUFFER 8192 - namespace beerocks { -/** - * @brief Netlink request type. - */ -struct nl_req_t { - /** - * Netlink message - */ - struct nlmsghdr hdr; - - /** - * "general form of address family dependent" message, i.e. how to tell which AF we are - * interested in. */ - struct rtgenmsg gen; -}; - -/** - * @brief Gets link metrics of an Ethernet network interface. - * - * Gets link metrics for given Ethernet network interface from the specified Netlink message of - * type RTM_NEWLINK. - * - * @param[in] h Pointer to the Netlink message containing the data. - * @param[in] local_interface_name Name of the Ethernet network interface. - * @param[in, out] link_metris Link metrics structure with read values. - * - * @return True on success and false otherwise. - */ -static bool get_link_metrics(const struct nlmsghdr *h, const std::string &local_interface_name, - sLinkMetrics &link_metrics) +bool ieee802_3_link_metrics_collector::get_link_metrics( + const std::string &local_interface_name, + [[gnu::unused]] const sMacAddr &neighbor_interface_address, sLinkMetrics &link_metrics) { - bool result = false; - - struct ifinfomsg *iface = static_cast(NLMSG_DATA(h)); - - size_t length = 0; - if (h->nlmsg_len > NLMSG_LENGTH(sizeof(*iface))) { - length = h->nlmsg_len - NLMSG_LENGTH(sizeof(*iface)); + net::sInterfaceStats iface_stats; + if (!net::network_utils::get_iface_stats(local_interface_name, iface_stats)) { + LOG(ERROR) << "Failed getting interface statistics for interface " << local_interface_name; + return false; } /** - * Loop over all attributes of the RTM_NEWLINK message - */ - for (struct rtattr *attribute = IFLA_RTA(iface); RTA_OK(attribute, length); - attribute = RTA_NEXT(attribute, length)) { - switch (attribute->rta_type) { - case IFLA_IFNAME: - /** - * This message contains the stats for the interface we are interested in - */ - if (0 == std::strncmp(local_interface_name.c_str(), (char *)RTA_DATA(attribute), - local_interface_name.length() + 1)) { - result = true; - } - break; - case IFLA_STATS: - if (result) { - struct rtnl_link_stats *stats = (struct rtnl_link_stats *)RTA_DATA(attribute); - - /** - * Get interface speed into PHY rate. - */ - uint32_t phy_rate_mbps = UINT32_MAX; - beerocks::net::network_utils::linux_iface_get_speed(local_interface_name, - phy_rate_mbps); - - link_metrics.transmitter.packet_errors = stats->tx_errors; - link_metrics.transmitter.transmitted_packets = stats->tx_packets; - /** - * Note: The MAC throughput capacity is a function of the physical data rate and - * of the MAC overhead. We could somehow compute such overhead or, for simplicity, - * set the MAC throughput as a percentage of the physical data rate. - * For Ethernet, we can estimate the overhead: 7 bytes preamble, 1 byte SFD, 14 - * bytes header, 4 bytes CRC and 12 bytes of interpacket gap on a 1500 byte - * payload. So 1500/1538. - * (see https://en.wikipedia.org/wiki/Ethernet_frame) - */ - const float layer2_payload_size = 1500; - const float layer1_total_size = 1538; - link_metrics.transmitter.mac_throughput_capacity_mbps = - phy_rate_mbps * (layer2_payload_size / layer1_total_size); - // Note: For simplicity, link availability is set to "100% of the time" - link_metrics.transmitter.link_availability = 100; - link_metrics.transmitter.phy_rate_mbps = phy_rate_mbps; - - link_metrics.receiver.packet_errors = stats->rx_errors; - link_metrics.receiver.packets_received = stats->rx_packets; - link_metrics.receiver.rssi = UINT8_MAX; - } - break; - } - } - - return result; -} - -/** - * @brief Gets link metrics of an Ethernet network interface. - * - * Gets link metrics for given Ethernet network interface by sending a RTM_GETLINK Netlink request - * through the specified Netlink socket and parsing received response. - * - * @param[in] fd File descriptor of a connected Netlink socket. - * @param[in] local_interface_name Name of the Ethernet network interface. - * @param[in, out] link_metris Link metrics structure with read values. - * - * @return True on success and false otherwise. - */ -static bool get_link_metrics(int fd, const std::string &local_interface_name, - sLinkMetrics &link_metrics) -{ - bool result = false; - - struct sockaddr_nl socket; /* the remote (kernel space) side of the communication */ - - struct msghdr rtnl_msg { - }; /* generic msghdr struct for use with sendmsg */ - struct iovec io { - }; /* IO vector for sendmsg */ - struct nl_req_t req { - }; /* structure that describes the Netlink packet itself */ - - /** - * Netlink socket is ready for use, prepare and send request + * Get interface speed into PHY rate. */ - socket.nl_family = AF_NETLINK; /* fill-in kernel address (destination of our message) */ - - req.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtgenmsg)); - req.hdr.nlmsg_type = RTM_GETLINK; - req.hdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP; - req.hdr.nlmsg_seq = 1; - req.hdr.nlmsg_pid = 0; - req.gen.rtgen_family = AF_PACKET; /* no preferred AF, we will get *all* interfaces */ - - io.iov_base = &req; - io.iov_len = req.hdr.nlmsg_len; - rtnl_msg.msg_iov = &io; - rtnl_msg.msg_iovlen = 1; - rtnl_msg.msg_name = &socket; - rtnl_msg.msg_namelen = sizeof(socket); - - if (sendmsg(fd, (struct msghdr *)&rtnl_msg, 0) < 0) { - LOG(ERROR) << "Unable to send message through Netlink socket: " << strerror(errno); - } else { - int msg_done = 0; /* flag to end loop parsing */ - - /** - * Parse reply until message is done - */ - while (!msg_done) { - int length; - struct nlmsghdr *msg_ptr; /* pointer to current message part */ - - struct msghdr rtnl_reply { - }; /* generic msghdr structure for use with recvmsg */ - - /* a large buffer to receive lots of link information */ - char reply[IFLIST_REPLY_BUFFER]; - - io.iov_base = reply; - io.iov_len = IFLIST_REPLY_BUFFER; - rtnl_reply.msg_iov = &io; - rtnl_reply.msg_iovlen = 1; - rtnl_reply.msg_name = &socket; - rtnl_reply.msg_namelen = sizeof(socket); - - /** - * Read as much data as fits in the receive buffer - */ - if ((length = recvmsg(fd, &rtnl_reply, 0)) != 0) { - for (msg_ptr = (struct nlmsghdr *)reply; NLMSG_OK(msg_ptr, length); - msg_ptr = NLMSG_NEXT(msg_ptr, length)) { - switch (msg_ptr->nlmsg_type) { - case NLMSG_DONE: - /** - * This is the special meaning NLMSG_DONE message we asked for by using NLM_F_DUMP flag - */ - msg_done = 1; - break; - case RTM_NEWLINK: - /** - * This is a RTM_NEWLINK message, which contains lots of information about a link - */ - if (get_link_metrics(msg_ptr, local_interface_name, link_metrics)) { - msg_done = 1; - result = true; - } - break; - } - } - } - } - } - - return result; -} - -/** - * @brief Gets link metrics of an Ethernet network interface. - * - * Gets link metrics for given Ethernet network by means of a Netlink socket using NETLINK_ROUTE - * protocol. - * - * @param[in] local_interface_name Name of the Ethernet network interface. - * @param[in, out] link_metris Link metrics structure with read values. - * - * @return True on success and false otherwise. - */ -static bool get_link_metrics(const std::string &local_interface_name, sLinkMetrics &link_metrics) -{ - bool result = false; + uint32_t phy_rate_mbps = UINT32_MAX; + net::network_utils::linux_iface_get_speed(local_interface_name, phy_rate_mbps); /** - * Create Netlink socket for kernel/user-space communication. - * No need to call bind() as packets are sent only between the kernel and the originating - * process (no multicasting). + * Note: The MAC throughput capacity is a function of the physical data rate and + * of the MAC overhead. We could somehow compute such overhead or, for simplicity, + * set the MAC throughput as a percentage of the physical data rate. + * For Ethernet, we can estimate the overhead: 7 bytes preamble, 1 byte SFD, 14 + * bytes header, 4 bytes CRC and 12 bytes of interpacket gap on a 1500 byte + * payload. So 1500/1538. + * (see https://en.wikipedia.org/wiki/Ethernet_frame) */ - int fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); - if (fd < 0) { - LOG(ERROR) << "Failed creating Netlink socket: " << strerror(errno); - } else { - /** - * Get link metrics using Netlink socket - */ - result = get_link_metrics(fd, local_interface_name, link_metrics); - - /** - * Clean up and finish properly - */ - close(fd); - } - - return result; -} - -bool ieee802_3_link_metrics_collector::get_link_metrics( - const std::string &local_interface_name, - [[gnu::unused]] const sMacAddr &neighbor_interface_address, sLinkMetrics &link_metrics) -{ - return beerocks::get_link_metrics(local_interface_name, link_metrics); + const float layer2_payload_size = 1500; + const float layer1_total_size = 1538; + link_metrics.transmitter.mac_throughput_capacity_mbps = + phy_rate_mbps * (layer2_payload_size / layer1_total_size); + // Note: For simplicity, link availability is set to "100% of the time" + link_metrics.transmitter.link_availability = 100; + link_metrics.transmitter.phy_rate_mbps = phy_rate_mbps; + + link_metrics.transmitter.packet_errors = iface_stats.tx_errors; + link_metrics.transmitter.transmitted_packets = iface_stats.tx_packets; + + link_metrics.receiver.packet_errors = iface_stats.rx_errors; + link_metrics.receiver.packets_received = iface_stats.rx_packets; + link_metrics.receiver.rssi = UINT8_MAX; + + return true; } } // namespace beerocks diff --git a/ci/cppcheck/cppcheck_existing_issues.txt b/ci/cppcheck/cppcheck_existing_issues.txt index 5d3bea0444..7695660119 100644 --- a/ci/cppcheck/cppcheck_existing_issues.txt +++ b/ci/cppcheck/cppcheck_existing_issues.txt @@ -14,7 +14,6 @@ agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Lo agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Local variable 'supportedServiceTuple' shadows outer variable [shadowVariable] auto supportedServiceTuple = tlvSupportedService->supported_service_list(1); agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Variable 'p_cmdu_header' is assigned a value that is never used. [unreadVariable] auto p_cmdu_header = agent/src/beerocks/slave/beerocks_slave_main.cpp: style: Parameter 'beerocks_slave_conf' can be declared with const [constParameter]static int run_son_slave(int slave_num, beerocks::config_file::sConfigSlave &beerocks_slave_conf, -agent/src/beerocks/slave/link_metrics/ieee802_3_link_metrics_collector.cpp: style: The scope of the variable 'msg_ptr' can be reduced. [variableScope] struct nlmsghdr *msg_ptr; /* pointer to current message part */ agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp: warning: Comparison of a boolean expression with an integer. [compareBoolExpressionWithInt] if (bpl::dhcp_mon_stop() == false) { agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp: warning: Redundant assignment of '*(volatile char*)pass' to itself. [selfAssignment] *(volatile char *)pass = *(volatile char *)pass; agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp: warning: Redundant assignment of '*(volatile char*)pass' to itself. [selfAssignment] *(volatile char *)pass = *(volatile char *)pass; From f7eb6eace89b00e237ead378af80dec1feade0e9 Mon Sep 17 00:00:00 2001 From: Alex Kanter Date: Sun, 12 Jul 2020 06:47:58 +0000 Subject: [PATCH 210/453] prplmesh utils: increase prplmesh_watchdog sleep time High CPU was noticed in platforms that use prplmesh_watchdog. Currently, polling time is configured to 1 sec which is too frequent and can be optimized. In openWrt based platforms the init.d provides respawn functionality which starts the process again (up to 5 tries) if it ends "too soon" (configurable). However, the prplmesh processes are started using the prplmesh utils script and if the script fulfills its purpose and exists the init.d will again start the prplmesh using the prplmesh utils script as it things the process ended too soon. This means we need to "hang" the script until we really wish to exit it (on user request or on failure). Watchdog serves 2 purposes: steady-state: check that one of the controller/agent/agent_wlan prplmesh processes did not end and if so - end the script. on failure: make sure all processes are closed properly to prevent duplicate of prplmesh processes as was previously experienced. Testing shows that increasing to 5 sec is more optimal and still serves the same purpose. Signed-off-by: Alex Kanter --- common/beerocks/scripts/prplmesh_utils.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/beerocks/scripts/prplmesh_utils.sh.in b/common/beerocks/scripts/prplmesh_utils.sh.in index 7cc22b66ad..a3a3879d36 100755 --- a/common/beerocks/scripts/prplmesh_utils.sh.in +++ b/common/beerocks/scripts/prplmesh_utils.sh.in @@ -159,7 +159,7 @@ prplmesh_watchdog() { # Monitor the number of running processes while [ "$CURR_PIDS" -ge "$PREV_PIDS" ]; do - sleep 1 + sleep 5 CURR_PIDS="$(pgrep 'beerocks_(agent|controller)' | wc -l)" if [ "$CURR_PIDS" -gt "$PREV_PIDS" ]; then PREV_PIDS=$CURR_PIDS From 86edcfdbeab2a729f0170684ee64e25e5e86e4d6 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sun, 12 Jul 2020 01:10:48 +0300 Subject: [PATCH 211/453] framework: bpl: Add generation for prplmesh_platform_db file Need to create new folder with cmake and prplmesh_platform_db.in files, modify prplmesh_platform_db.in by adding new variables for hostapd control path and wpa supplicant control path. Add 6 variables 3 for hostapd and 3 for wpa supplicant, modify cmake file for building bpl by adding directory with new cmake file for generation prplmesh_platform_db file. Signed-off-by: Vladyslav Tupikin --- framework/platform/bpl/CMakeLists.txt | 19 +++++++++++++++++-- .../platform/bpl/linux/prplmesh_platform_db | 4 ---- .../platform/bpl/platform_db/CMakeLists.txt | 7 +++++++ .../bpl/platform_db/prplmesh_platform_db.in | 10 ++++++++++ 4 files changed, 34 insertions(+), 6 deletions(-) delete mode 100644 framework/platform/bpl/linux/prplmesh_platform_db create mode 100644 framework/platform/bpl/platform_db/CMakeLists.txt create mode 100644 framework/platform/bpl/platform_db/prplmesh_platform_db.in diff --git a/framework/platform/bpl/CMakeLists.txt b/framework/platform/bpl/CMakeLists.txt index 942c0c20be..3fe9d810f4 100644 --- a/framework/platform/bpl/CMakeLists.txt +++ b/framework/platform/bpl/CMakeLists.txt @@ -8,6 +8,23 @@ set(MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) # Common Sources file(GLOB_RECURSE bpl_common_sources ${MODULE_PATH}/common/*.c*) +# Common prplmesh_db values +set(BEEROCKS_MANAGEMENT_MODE "Multi-AP-Controller-and-Agent" CACHE STRING "Set management mode") +set(BEEROCKS_OPERATING_MODE "Gateway" CACHE STRING "Set operating mode") +set(BEEROCKS_STOP_ON_FAILURE_ATTEMPTS 0 CACHE INT "In common config stop on failure disabled") +set(BEEROCKS_CERTIFICATION_MODE 1 CACHE INT "In certification, agent must retry onboarding indefinitely") + +set(BEEROCKS_HOSTAP_WLAN1_CTRL_IFACE "/var/run/hostapd/${BEEROCKS_WLAN1_IFACE}" CACHE PATH "hostapd ctrl iface path for 1st WLAN") +set(BEEROCKS_HOSTAP_WLAN2_CTRL_IFACE "/var/run/hostapd/${BEEROCKS_WLAN2_IFACE}" CACHE PATH "hostapd ctrl iface path for 2nd WLAN") +set(BEEROCKS_HOSTAP_WLAN3_CTRL_IFACE "/var/run/hostapd/${BEEROCKS_WLAN3_IFACE}" CACHE PATH "hostapd ctrl iface path for 3rd WLAN") + +set(BEEROCKS_WPA_SUPPLICANT_WLAN1_CTRL_IFACE "/var/run/wpa_supplicant/${BEEROCKS_WLAN1_IFACE}" CACHE PATH "wpa_supplicant ctrl iface path for 1st WLAN") +set(BEEROCKS_WPA_SUPPLICANT_WLAN2_CTRL_IFACE "/var/run/wpa_supplicant/${BEEROCKS_WLAN2_IFACE}" CACHE PATH "wpa_supplicant ctrl iface path for 2nd WLAN") +set(BEEROCKS_WPA_SUPPLICANT_WLAN3_CTRL_IFACE "/var/run/wpa_supplicant/${BEEROCKS_WLAN3_IFACE}" CACHE PATH "wpa_supplicant ctrl iface path for 3rd WLAN") + +# Add prplmesh_platform_db config generation +add_subdirectory(platform_db) + # OpenWRT if (TARGET_PLATFORM STREQUAL "openwrt") @@ -48,7 +65,6 @@ if (TARGET_PLATFORM STREQUAL "openwrt") add_definitions(-DPLATFORM_DB_PATH="${INSTALL_PATH}/share/prplmesh_platform_db") add_definitions(-DPLATFORM_DB_PATH_TEMP="${TMP_PATH}/prplmesh_platform_db") - install(FILES "${MODULE_PATH}/linux/prplmesh_platform_db" DESTINATION ${CMAKE_INSTALL_PREFIX}/share) endif() @@ -84,7 +100,6 @@ elseif (TARGET_PLATFORM STREQUAL "linux") add_definitions(-DPLATFORM_DB_PATH="${INSTALL_PATH}/share/prplmesh_platform_db") add_definitions(-DPLATFORM_DB_PATH_TEMP="${TMP_PATH}/prplmesh_platform_db") - install(FILES "${MODULE_PATH}/linux/prplmesh_platform_db" DESTINATION ${CMAKE_INSTALL_PREFIX}/share) else() diff --git a/framework/platform/bpl/linux/prplmesh_platform_db b/framework/platform/bpl/linux/prplmesh_platform_db deleted file mode 100644 index a138678b5f..0000000000 --- a/framework/platform/bpl/linux/prplmesh_platform_db +++ /dev/null @@ -1,4 +0,0 @@ -management_mode=Multi-AP-Controller-and-Agent -operating_mode=Gateway -stop_on_failure_attempts=1 -certification_mode=1 diff --git a/framework/platform/bpl/platform_db/CMakeLists.txt b/framework/platform/bpl/platform_db/CMakeLists.txt new file mode 100644 index 0000000000..7b2e282ef5 --- /dev/null +++ b/framework/platform/bpl/platform_db/CMakeLists.txt @@ -0,0 +1,7 @@ +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/prplmesh_platform_db.in" + "${CMAKE_CURRENT_BINARY_DIR}/prplmesh_platform_db" + ) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/prplmesh_platform_db DESTINATION share) +file(COPY ${CMAKE_CURRENT_BINARY_DIR}/prplmesh_platform_db DESTINATION "${CMAKE_MULTIAP_OUTPUT_DIRECTORY}/share") diff --git a/framework/platform/bpl/platform_db/prplmesh_platform_db.in b/framework/platform/bpl/platform_db/prplmesh_platform_db.in new file mode 100644 index 0000000000..33f8515a95 --- /dev/null +++ b/framework/platform/bpl/platform_db/prplmesh_platform_db.in @@ -0,0 +1,10 @@ +management_mode=@BEEROCKS_MANAGEMENT_MODE@ +operating_mode=@BEEROCKS_OPERATING_MODE@ +stop_on_failure_attempts=@BEEROCKS_STOP_ON_FAILURE_ATTEMPTS@ +certification_mode=@BEEROCKS_CERTIFICATION_MODE@ +hostapd_ctrl_path_@BEEROCKS_WLAN1_IFACE@=@BEEROCKS_HOSTAP_WLAN1_CTRL_IFACE@ +hostapd_ctrl_path_@BEEROCKS_WLAN2_IFACE@=@BEEROCKS_HOSTAP_WLAN2_CTRL_IFACE@ +hostapd_ctrl_path_@BEEROCKS_WLAN3_IFACE@=@BEEROCKS_HOSTAP_WLAN3_CTRL_IFACE@ +wpa_supplicant_ctrl_path_@BEEROCKS_WLAN1_IFACE@=@BEEROCKS_WPA_SUPPLICANT_WLAN1_CTRL_IFACE@ +wpa_supplicant_ctrl_path_@BEEROCKS_WLAN2_IFACE@=@BEEROCKS_WPA_SUPPLICANT_WLAN2_CTRL_IFACE@ +wpa_supplicant_ctrl_path_@BEEROCKS_WLAN3_IFACE@=@BEEROCKS_WPA_SUPPLICANT_WLAN3_CTRL_IFACE@ From 79bed4f87795c4da842e774b45bb01c65d83aa71 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sun, 12 Jul 2020 01:13:35 +0300 Subject: [PATCH 212/453] common: scripts: Remove creating prplmesh_platform_db Need to remove prplmesh_platform_db creation from the prplmesh_platform_db_init() function because now prplmesh_platform_db generates by cmake. Signed-off-by: Vladyslav Tupikin --- common/beerocks/scripts/prplmesh_utils.sh.in | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/common/beerocks/scripts/prplmesh_utils.sh.in b/common/beerocks/scripts/prplmesh_utils.sh.in index a3a3879d36..d4bbd290f2 100755 --- a/common/beerocks/scripts/prplmesh_utils.sh.in +++ b/common/beerocks/scripts/prplmesh_utils.sh.in @@ -92,14 +92,13 @@ prplmesh_platform_db_init() { operating_mode=${2-Gateway} mkdir -p @TMP_PATH@ - { - echo "management_mode=${management_mode}" - echo "operating_mode=${operating_mode}" - - # In certification, agent must retry onboarding indefinitely - echo "certification_mode=1" - echo "stop_on_failure_attempts=0" - } > @TMP_PATH@/prplmesh_platform_db + + # Put generated prplmesh_platform_db file to the temporary directory + cp @INSTALL_PATH@/share/prplmesh_platform_db @TMP_PATH@/prplmesh_platform_db + + # Modify generated parameters to current + sed -i "s/management_mode=.*/management_mode=${management_mode}/g" @TMP_PATH@/prplmesh_platform_db + sed -i "s/operating_mode=.*/operating_mode=${operating_mode}/g" @TMP_PATH@/prplmesh_platform_db } prplmesh_framework_init() { From 9e3145054ffdf92b5a3e9f14d696c4fefbec4502 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 10 Jul 2020 11:54:21 +0300 Subject: [PATCH 213/453] framework: bpl: Create stub for get_ctrl_path methods Need to create 2 stubs for 2 methods: bpl_cfg_get_wpa_supplicant_ctrl_path bpl_cfg_get_hostapd_ctrl_path Create stubs and prototypes with documentation for the new methods for linux and uci platforms. Signed-off-by: Vladyslav Tupikin --- framework/platform/bpl/include/bpl/bpl_cfg.h | 19 +++++++++++++++++++ framework/platform/bpl/linux/bpl_cfg.cpp | 10 ++++++++++ framework/platform/bpl/uci/cfg/bpl_cfg.cpp | 10 ++++++++++ 3 files changed, 39 insertions(+) diff --git a/framework/platform/bpl/include/bpl/bpl_cfg.h b/framework/platform/bpl/include/bpl/bpl_cfg.h index 4bfc95345f..e1ab131aba 100644 --- a/framework/platform/bpl/include/bpl/bpl_cfg.h +++ b/framework/platform/bpl/include/bpl/bpl_cfg.h @@ -13,6 +13,7 @@ #include "bpl_err.h" #include +#include namespace beerocks { namespace bpl { @@ -537,6 +538,24 @@ bool cfg_get_max_timelife_delay_days(int &max_timelife_delay_days); bool cfg_get_unfriendly_device_max_timelife_delay_days( int &unfriendly_device_max_timelife_delay_days); +/** + * @brief Returns configured WPA Control Path for the given interface. + * + * @param [in] Interface name + * @param [out] WPA Control Path + * @return true on success, otherwise false. + */ +bool bpl_cfg_get_wpa_supplicant_ctrl_path(const std::string &iface, std::string &wpa_ctrl_path); + +/** + * @brief Returns configured Hostapd Control Path for the given interface. + * + * @param [in] Interface name + * @param [out] Hostapd Control Path + * @return true on success, otherwise false. + */ +bool bpl_cfg_get_hostapd_ctrl_path(const std::string &iface, std::string &hostapd_ctrl_path); + } // namespace bpl } // namespace beerocks diff --git a/framework/platform/bpl/linux/bpl_cfg.cpp b/framework/platform/bpl/linux/bpl_cfg.cpp index ddeca479d8..9ce4fdcfe8 100644 --- a/framework/platform/bpl/linux/bpl_cfg.cpp +++ b/framework/platform/bpl/linux/bpl_cfg.cpp @@ -391,5 +391,15 @@ bool cfg_get_unfriendly_device_max_timelife_delay_days( return true; } +bool bpl_cfg_get_wpa_supplicant_ctrl_path(const std::string &iface, std::string &wpa_ctrl_path) +{ + return true; +} + +bool bpl_cfg_get_hostapd_ctrl_path(const std::string &iface, std::string &hostapd_ctrl_path) +{ + return true; +} + } // namespace bpl } // namespace beerocks diff --git a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp index baf449d795..b17a588f7d 100644 --- a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp +++ b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp @@ -459,5 +459,15 @@ bool cfg_get_unfriendly_device_max_timelife_delay_days( return true; } +bool bpl_cfg_get_wpa_supplicant_ctrl_path(const std::string &iface, std::string &wpa_ctrl_path) +{ + return true; +} + +bool bpl_cfg_get_hostapd_ctrl_path(const std::string &iface, std::string &hostapd_ctrl_path) +{ + return true; +} + } // namespace bpl } // namespace beerocks From 8c86826eb0c3bb8d6485b30dc05e774b10efaccc Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 10 Jul 2020 11:57:52 +0300 Subject: [PATCH 214/453] framework: bpl: Add implementation for bpl_cfg_get_wpa_supplicant_ctrl_path() Add implementation in linux platform for bpl_cfg_get_wpa_supplicant_ctrl_path() method. Signed-off-by: Vladyslav Tupikin --- framework/platform/bpl/linux/bpl_cfg.cpp | 11 +++++++++++ framework/platform/bpl/uci/cfg/bpl_cfg.cpp | 2 ++ 2 files changed, 13 insertions(+) diff --git a/framework/platform/bpl/linux/bpl_cfg.cpp b/framework/platform/bpl/linux/bpl_cfg.cpp index 9ce4fdcfe8..ff884448e9 100644 --- a/framework/platform/bpl/linux/bpl_cfg.cpp +++ b/framework/platform/bpl/linux/bpl_cfg.cpp @@ -393,6 +393,17 @@ bool cfg_get_unfriendly_device_max_timelife_delay_days( bool bpl_cfg_get_wpa_supplicant_ctrl_path(const std::string &iface, std::string &wpa_ctrl_path) { + + std::string param = "wpa_supplicant_ctrl_path_"; + + param += iface; + param += '='; + + if (cfg_get_param(param, wpa_ctrl_path) < 0) { + MAPF_ERR("Failed to read: " << param); + return false; + } + return true; } diff --git a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp index b17a588f7d..8c4f64a625 100644 --- a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp +++ b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp @@ -461,6 +461,8 @@ bool cfg_get_unfriendly_device_max_timelife_delay_days( bool bpl_cfg_get_wpa_supplicant_ctrl_path(const std::string &iface, std::string &wpa_ctrl_path) { + const char *path{"/var/run/wpa_supplicant/"}; + wpa_ctrl_path = path + iface; return true; } From 861bf5dc130d85d3c4f8cc6d5552353864cededf Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 10 Jul 2020 11:59:59 +0300 Subject: [PATCH 215/453] framework: bpl: Add implementation for bpl_cfg_get_hostapd_ctrl_path() Add implementation in lunux platform for bpl_cfg_get_hostapd_ctrl_path() method. Signed-off-by: Vladyslav Tupikin --- framework/platform/bpl/linux/bpl_cfg.cpp | 11 +++++++++++ framework/platform/bpl/uci/cfg/bpl_cfg.cpp | 2 ++ 2 files changed, 13 insertions(+) diff --git a/framework/platform/bpl/linux/bpl_cfg.cpp b/framework/platform/bpl/linux/bpl_cfg.cpp index ff884448e9..93975c385a 100644 --- a/framework/platform/bpl/linux/bpl_cfg.cpp +++ b/framework/platform/bpl/linux/bpl_cfg.cpp @@ -409,6 +409,17 @@ bool bpl_cfg_get_wpa_supplicant_ctrl_path(const std::string &iface, std::string bool bpl_cfg_get_hostapd_ctrl_path(const std::string &iface, std::string &hostapd_ctrl_path) { + + std::string param = "hostapd_ctrl_path_"; + + param += iface; + param += '='; + + if (cfg_get_param(param, hostapd_ctrl_path) < 0) { + MAPF_ERR("Failed to read: " << param); + return false; + } + return true; } diff --git a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp index 8c4f64a625..3a5ba6066f 100644 --- a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp +++ b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp @@ -468,6 +468,8 @@ bool bpl_cfg_get_wpa_supplicant_ctrl_path(const std::string &iface, std::string bool bpl_cfg_get_hostapd_ctrl_path(const std::string &iface, std::string &hostapd_ctrl_path) { + const char *path{"/var/run/hostapd/"}; + hostapd_ctrl_path = path + iface; return true; } From f3ee02872203a50f3003cfcb33cda5237e847564 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sun, 12 Jul 2020 01:27:32 +0300 Subject: [PATCH 216/453] agent: fronthaul_manager: Add wpa_ctrl_path in hal_conf Need to add correct wpa_ctrl_path for ap_manager (for AP manager it's hostapd_ctrl_path) using method from the bpl library. Signed-off-by: Vladyslav Tupikin --- agent/src/beerocks/fronthaul_manager/CMakeLists.txt | 2 +- .../fronthaul_manager/ap_manager/ap_manager_thread.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/agent/src/beerocks/fronthaul_manager/CMakeLists.txt b/agent/src/beerocks/fronthaul_manager/CMakeLists.txt index 0695fc5c72..d9db993872 100644 --- a/agent/src/beerocks/fronthaul_manager/CMakeLists.txt +++ b/agent/src/beerocks/fronthaul_manager/CMakeLists.txt @@ -32,7 +32,7 @@ endif() add_executable(${PROJECT_NAME} ${fronthaul_manager_sources}) set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-Wl,-z,defs") -target_link_libraries(${PROJECT_NAME} bcl btlvf rt dl tlvf elpp bwl ${LIBS}) +target_link_libraries(${PROJECT_NAME} bcl btlvf rt dl tlvf elpp bwl mapfcommon bpl ${LIBS}) # Install install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/agent/src/beerocks/fronthaul_manager/ap_manager/ap_manager_thread.cpp b/agent/src/beerocks/fronthaul_manager/ap_manager/ap_manager_thread.cpp index eddb61e3d1..3e78044054 100644 --- a/agent/src/beerocks/fronthaul_manager/ap_manager/ap_manager_thread.cpp +++ b/agent/src/beerocks/fronthaul_manager/ap_manager/ap_manager_thread.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -114,6 +115,11 @@ bool ap_manager_thread::create_ap_wlan_hal() bwl::hal_conf_t hal_conf; hal_conf.ap_acs_enabled = acs_enabled; + if (!beerocks::bpl::bpl_cfg_get_hostapd_ctrl_path(m_iface, hal_conf.wpa_ctrl_path)) { + LOG(ERROR) << "Couldn't get hostapd control path for interface " << m_iface; + return false; + } + // Create a new AP HAL instance ap_wlan_hal = bwl::ap_wlan_hal_create( m_iface, hal_conf, std::bind(&ap_manager_thread::hal_event_handler, this, _1)); From 9e333f476298f91860025e4d9d0653d836a09611 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sun, 12 Jul 2020 10:07:10 +0300 Subject: [PATCH 217/453] common: bwl: Add wpa_ctrl_path as a part of hal_conf structure Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/include/bwl/base_wlan_hal_types.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common/beerocks/bwl/include/bwl/base_wlan_hal_types.h b/common/beerocks/bwl/include/bwl/base_wlan_hal_types.h index bcd51d0662..9b0d45d92f 100644 --- a/common/beerocks/bwl/include/bwl/base_wlan_hal_types.h +++ b/common/beerocks/bwl/include/bwl/base_wlan_hal_types.h @@ -100,6 +100,7 @@ struct RadioInfo { struct hal_conf_t { bool ap_acs_enabled = false; + std::string wpa_ctrl_path; }; //sta_wlan_hal From 26f00c73006790a0290601474405652f3f1080ea Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sun, 12 Jul 2020 10:12:35 +0300 Subject: [PATCH 218/453] bwl: dummy: Modify ap_wlan_hal_dummy constructor Need to update ap_wlan_hal_dummy() method by adding argument for hal_conf_t structure, and update dummy HAL for using new argument. Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/dummy/ap_wlan_hal_dummy.cpp | 2 +- common/beerocks/bwl/dummy/ap_wlan_hal_dummy.h | 3 ++- common/beerocks/bwl/dummy/base_wlan_hal_dummy.cpp | 2 +- common/beerocks/bwl/dummy/base_wlan_hal_dummy.h | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common/beerocks/bwl/dummy/ap_wlan_hal_dummy.cpp b/common/beerocks/bwl/dummy/ap_wlan_hal_dummy.cpp index ea9b9cfa14..b7fa3d058d 100644 --- a/common/beerocks/bwl/dummy/ap_wlan_hal_dummy.cpp +++ b/common/beerocks/bwl/dummy/ap_wlan_hal_dummy.cpp @@ -103,7 +103,7 @@ static ap_wlan_hal::Event dummy_to_bwl_event(const std::string &opcode) // NOTE: Since *base_wlan_hal_dummy* inherits *base_wlan_hal* virtually, we // need to explicitly call it's from any deriving class ap_wlan_hal_dummy::ap_wlan_hal_dummy(const std::string &iface_name, hal_event_cb_t callback, - hal_conf_t hal_conf) + const hal_conf_t &hal_conf) : base_wlan_hal(bwl::HALType::AccessPoint, iface_name, IfaceType::Intel, callback, hal_conf), base_wlan_hal_dummy(bwl::HALType::AccessPoint, iface_name, callback, hal_conf) { diff --git a/common/beerocks/bwl/dummy/ap_wlan_hal_dummy.h b/common/beerocks/bwl/dummy/ap_wlan_hal_dummy.h index 1eb2b1346d..fb51962d20 100644 --- a/common/beerocks/bwl/dummy/ap_wlan_hal_dummy.h +++ b/common/beerocks/bwl/dummy/ap_wlan_hal_dummy.h @@ -28,7 +28,8 @@ class ap_wlan_hal_dummy : public base_wlan_hal_dummy, public ap_wlan_hal { * @param [in] iface_name AP interface name. * @param [in] callback Callback for handling internal events. */ - ap_wlan_hal_dummy(const std::string &iface_name, hal_event_cb_t callback, hal_conf_t hal_conf); + ap_wlan_hal_dummy(const std::string &iface_name, hal_event_cb_t callback, + const hal_conf_t &hal_conf); virtual ~ap_wlan_hal_dummy(); diff --git a/common/beerocks/bwl/dummy/base_wlan_hal_dummy.cpp b/common/beerocks/bwl/dummy/base_wlan_hal_dummy.cpp index dd4e0db6e5..478d4246d8 100644 --- a/common/beerocks/bwl/dummy/base_wlan_hal_dummy.cpp +++ b/common/beerocks/bwl/dummy/base_wlan_hal_dummy.cpp @@ -230,7 +230,7 @@ void base_wlan_hal_dummy::parsed_obj_debug(parsed_obj_listed_map_t &obj) } base_wlan_hal_dummy::base_wlan_hal_dummy(HALType type, const std::string &iface_name, - hal_event_cb_t callback, hal_conf_t hal_conf) + hal_event_cb_t callback, const hal_conf_t &hal_conf) : base_wlan_hal(type, iface_name, IfaceType::Intel, callback, hal_conf), beerocks::beerocks_fsm(dummy_fsm_state::Delay) { diff --git a/common/beerocks/bwl/dummy/base_wlan_hal_dummy.h b/common/beerocks/bwl/dummy/base_wlan_hal_dummy.h index 408fabdc8c..769f1c3905 100644 --- a/common/beerocks/bwl/dummy/base_wlan_hal_dummy.h +++ b/common/beerocks/bwl/dummy/base_wlan_hal_dummy.h @@ -67,7 +67,7 @@ class base_wlan_hal_dummy : public virtual base_wlan_hal, // Protected methods protected: base_wlan_hal_dummy(HALType type, const std::string &iface_name, hal_event_cb_t callback, - hal_conf_t hal_conf = {}); + const hal_conf_t &hal_conf = {}); void parsed_obj_debug(parsed_obj_map_t &obj); void parsed_obj_debug(parsed_obj_listed_map_t &obj); From 62d937b92e32a5b7187efdd3e6d0131592c9c527 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sun, 12 Jul 2020 10:18:35 +0300 Subject: [PATCH 219/453] bwl: dwpal: Modify ap_wlan_hal_dwpal constructor Need to update ap_wlan_hal_dwpal() method by adding argument for hal_conf_t structure, and update dummy HAL for using new argument. Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp | 2 +- common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.h | 3 ++- common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp | 2 +- common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.h | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp index 2bfba983da..5c071bc9cf 100644 --- a/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp @@ -709,7 +709,7 @@ update_vap_credentials_configure_wpa(const std::string &vap_if, // NOTE: Since *base_wlan_hal_dwpal* inherits *base_wlan_hal* virtually, we // need to explicitly call it's from any deriving class ap_wlan_hal_dwpal::ap_wlan_hal_dwpal(const std::string &iface_name, hal_event_cb_t callback, - hal_conf_t hal_conf) + const hal_conf_t &hal_conf) : base_wlan_hal(bwl::HALType::AccessPoint, iface_name, IfaceType::Intel, callback, hal_conf), base_wlan_hal_dwpal(bwl::HALType::AccessPoint, iface_name, callback, hal_conf) { diff --git a/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.h b/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.h index 2cc3e9d182..e810cc2507 100644 --- a/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.h +++ b/common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.h @@ -28,7 +28,8 @@ class ap_wlan_hal_dwpal : public base_wlan_hal_dwpal, public ap_wlan_hal { * @param [in] iface_name AP interface name. * @param [in] callback Callback for handling internal events. */ - ap_wlan_hal_dwpal(const std::string &iface_name, hal_event_cb_t callback, hal_conf_t hal_conf); + ap_wlan_hal_dwpal(const std::string &iface_name, hal_event_cb_t callback, + const hal_conf_t &hal_conf); virtual ~ap_wlan_hal_dwpal(); diff --git a/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp index 6c150588a8..cd359cd7d0 100644 --- a/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp @@ -76,7 +76,7 @@ std::ostream &operator<<(std::ostream &out, const dwpal_fsm_event &value) ////////////////////////////////////////////////////////////////////////////// base_wlan_hal_dwpal::base_wlan_hal_dwpal(HALType type, const std::string &iface_name, - hal_event_cb_t callback, hal_conf_t hal_conf) + hal_event_cb_t callback, const hal_conf_t &hal_conf) : base_wlan_hal(type, iface_name, IfaceType::Intel, callback, hal_conf), beerocks::beerocks_fsm(dwpal_fsm_state::Delay), m_nl80211_client(nl80211_client_factory::create_instance()) diff --git a/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.h b/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.h index 76b3f20204..3c62cfbff4 100644 --- a/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.h +++ b/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.h @@ -70,7 +70,7 @@ class base_wlan_hal_dwpal : public virtual base_wlan_hal, // Protected methods protected: base_wlan_hal_dwpal(HALType type, const std::string &iface_name, hal_event_cb_t callback, - hal_conf_t hal_conf = {}); + const hal_conf_t &hal_conf = {}); // Process dwpal event virtual bool process_dwpal_event(char *buffer, int bufLen, const std::string &opcode) = 0; From 6fe2eaae639134eb0529735da9e9aa59198aca34 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sun, 12 Jul 2020 10:20:32 +0300 Subject: [PATCH 220/453] bwl: nl80211: Modify ap_wlan_hal_nl80211 constructor Need to update ap_wlan_hal_nl80211() method by adding argument for hal_conf_t structure, and update dummy HAL for using new argument. Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/nl80211/ap_wlan_hal_nl80211.cpp | 4 ++-- common/beerocks/bwl/nl80211/ap_wlan_hal_nl80211.h | 2 +- common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp | 2 +- common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/beerocks/bwl/nl80211/ap_wlan_hal_nl80211.cpp b/common/beerocks/bwl/nl80211/ap_wlan_hal_nl80211.cpp index f7de483523..aa54592dc2 100644 --- a/common/beerocks/bwl/nl80211/ap_wlan_hal_nl80211.cpp +++ b/common/beerocks/bwl/nl80211/ap_wlan_hal_nl80211.cpp @@ -113,9 +113,9 @@ static uint8_t wpa_bw_to_beerocks_bw(const std::string &chan_width) // NOTE: Since *base_wlan_hal_nl80211* inherits *base_wlan_hal* virtually, we // need to explicitly call it's from any deriving class ap_wlan_hal_nl80211::ap_wlan_hal_nl80211(const std::string &iface_name, hal_event_cb_t callback, - hal_conf_t hal_conf) + const hal_conf_t &hal_conf) : base_wlan_hal(bwl::HALType::AccessPoint, iface_name, IfaceType::Intel, callback, hal_conf), - base_wlan_hal_nl80211(bwl::HALType::AccessPoint, iface_name, callback, BUFFER_SIZE) + base_wlan_hal_nl80211(bwl::HALType::AccessPoint, iface_name, callback, BUFFER_SIZE, hal_conf) { } diff --git a/common/beerocks/bwl/nl80211/ap_wlan_hal_nl80211.h b/common/beerocks/bwl/nl80211/ap_wlan_hal_nl80211.h index b738a08d6d..8dec533dd9 100644 --- a/common/beerocks/bwl/nl80211/ap_wlan_hal_nl80211.h +++ b/common/beerocks/bwl/nl80211/ap_wlan_hal_nl80211.h @@ -29,7 +29,7 @@ class ap_wlan_hal_nl80211 : public base_wlan_hal_nl80211, public ap_wlan_hal { * @param [in] callback Callback for handling internal events. */ ap_wlan_hal_nl80211(const std::string &iface_name, hal_event_cb_t callback, - hal_conf_t hal_conf); + const hal_conf_t &hal_conf); virtual ~ap_wlan_hal_nl80211(); diff --git a/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp b/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp index 8a50ccd798..5e4ffed100 100644 --- a/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp +++ b/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp @@ -202,7 +202,7 @@ static void parsed_obj_debug(base_wlan_hal_nl80211::parsed_obj_listed_map_t &obj base_wlan_hal_nl80211::base_wlan_hal_nl80211(HALType type, const std::string &iface_name, hal_event_cb_t callback, int wpa_ctrl_buffer_size, - hal_conf_t hal_conf) + const hal_conf_t &hal_conf) : base_wlan_hal(type, iface_name, IfaceType::Intel, callback, hal_conf), beerocks::beerocks_fsm(nl80211_fsm_state::Delay), m_nl80211_client(nl80211_client_factory::create_instance()), diff --git a/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.h b/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.h index 7f6f67ff5c..40bde474c4 100644 --- a/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.h +++ b/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.h @@ -72,7 +72,7 @@ class base_wlan_hal_nl80211 // Protected methods protected: base_wlan_hal_nl80211(HALType type, const std::string &iface_name, hal_event_cb_t callback, - int wpa_ctrl_buffer_size, hal_conf_t hal_conf = {}); + int wpa_ctrl_buffer_size, const hal_conf_t &hal_conf = {}); // Process hostapd/wpa_supplicant event virtual bool process_nl80211_event(parsed_obj_map_t &event) = 0; From a520dfad9a83ff3a303bf4dd0cc89c1a5c01f02c Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sun, 12 Jul 2020 10:40:07 +0300 Subject: [PATCH 221/453] agent: fronthaul_manager: Modify monitor_thread Add wpa_ctrl_path object of hal_conf structure and fill up using bpl method bpl_cfg_get_hostapd_ctrl_path. Signed-off-by: Vladyslav Tupikin --- .../fronthaul_manager/monitor/monitor_thread.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp index b7c870c8cf..2abfcee8c7 100644 --- a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp +++ b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp @@ -13,6 +13,7 @@ #define BEEROCKS_CUSTOM_LOGGER_ID BEEROCKS_MONITOR #include +#include #include @@ -64,9 +65,15 @@ monitor_thread::monitor_thread(const std::string &slave_uds_, const std::string using namespace std::placeholders; // for `_1` + bwl::hal_conf_t hal_conf; + + if (!beerocks::bpl::bpl_cfg_get_hostapd_ctrl_path(monitor_iface, hal_conf.wpa_ctrl_path)) { + LOG(ERROR) << "Couldn't get hostapd control path for interface " << monitor_iface; + } + // Create new Monitor HAL instance mon_wlan_hal = bwl::mon_wlan_hal_create( - monitor_iface_, std::bind(&monitor_thread::hal_event_handler, this, _1)); + monitor_iface_, std::bind(&monitor_thread::hal_event_handler, this, _1), hal_conf); LOG_IF(!mon_wlan_hal, FATAL) << "Failed creating HAL instance!"; } From 5811c75fee35a46264c7c3881ef1a70bf8374fe9 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sat, 27 Jun 2020 12:39:27 +0300 Subject: [PATCH 222/453] bwl: dummy: Modify mon_wlan_hal_dummy constructor Need to update mon_wlan_hal_create() method by adding argument for hal_conf_t structure, and update dummy HAL for using new argument. Signed-off-by: Ivan Efimov Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/dummy/mon_wlan_hal_dummy.cpp | 14 ++++++++------ common/beerocks/bwl/dummy/mon_wlan_hal_dummy.h | 3 ++- common/beerocks/bwl/include/bwl/mon_wlan_hal.h | 5 +++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.cpp b/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.cpp index 7479f2df18..7f104ccd18 100644 --- a/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.cpp +++ b/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.cpp @@ -66,9 +66,10 @@ static mon_wlan_hal_dummy::Data dummy_to_bwl_data(const std::string &opcode) /////////////////////////////// Implementation /////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -mon_wlan_hal_dummy::mon_wlan_hal_dummy(const std::string &iface_name, hal_event_cb_t callback) - : base_wlan_hal(bwl::HALType::Monitor, iface_name, IfaceType::Intel, callback), - base_wlan_hal_dummy(bwl::HALType::Monitor, iface_name, callback) +mon_wlan_hal_dummy::mon_wlan_hal_dummy(const std::string &iface_name, hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf) + : base_wlan_hal(bwl::HALType::Monitor, iface_name, IfaceType::Intel, callback, hal_conf), + base_wlan_hal_dummy(bwl::HALType::Monitor, iface_name, callback, hal_conf) { } @@ -421,10 +422,11 @@ bool mon_wlan_hal_dummy::set(const std::string ¶m, const std::string &value, } // namespace dummy -std::shared_ptr mon_wlan_hal_create(std::string iface_name, - base_wlan_hal::hal_event_cb_t callback) +std::shared_ptr mon_wlan_hal_create(const std::string &iface_name, + base_wlan_hal::hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf) { - return std::make_shared(iface_name, callback); + return std::make_shared(iface_name, callback, hal_conf); } } // namespace bwl diff --git a/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.h b/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.h index 9f1fa6d812..f07281037f 100644 --- a/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.h +++ b/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.h @@ -32,7 +32,8 @@ class mon_wlan_hal_dummy : public base_wlan_hal_dummy, public mon_wlan_hal { * @param [in] iface_name Monitor interface name. * @param [in] callback Callback for handling internal events. */ - mon_wlan_hal_dummy(const std::string &iface_name, hal_event_cb_t callback); + mon_wlan_hal_dummy(const std::string &iface_name, hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf); virtual ~mon_wlan_hal_dummy(); virtual bool update_radio_stats(SRadioStats &radio_stats) override; diff --git a/common/beerocks/bwl/include/bwl/mon_wlan_hal.h b/common/beerocks/bwl/include/bwl/mon_wlan_hal.h index bbd36bff52..d9a9cb09d1 100644 --- a/common/beerocks/bwl/include/bwl/mon_wlan_hal.h +++ b/common/beerocks/bwl/include/bwl/mon_wlan_hal.h @@ -64,8 +64,9 @@ class mon_wlan_hal : public virtual base_wlan_hal { }; // mon HAL factory types -std::shared_ptr mon_wlan_hal_create(std::string iface_name, - base_wlan_hal::hal_event_cb_t cb); +std::shared_ptr mon_wlan_hal_create(const std::string &iface_name, + base_wlan_hal::hal_event_cb_t cb, + const bwl::hal_conf_t &hal_conf); } // namespace bwl From db8488c92786476d13e922e6c6187059e92769dc Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sat, 27 Jun 2020 13:00:40 +0300 Subject: [PATCH 223/453] bwl: dwpal: Modify mon_wlan_hal_dwpal constructor Need to update mon_wlan_hal_create() method by adding argument for hal_conf_t structure, and update dwpal HAL for using new argument. Signed-off-by: Ivan Efimov Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp | 14 ++++++++------ common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.h | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp index 8a5d7832fc..1262ddb58e 100644 --- a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp @@ -531,9 +531,10 @@ static std::shared_ptr generate_client_assoc_event(const std::string &even /////////////////////////////// Implementation /////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -mon_wlan_hal_dwpal::mon_wlan_hal_dwpal(const std::string &iface_name, hal_event_cb_t callback) - : base_wlan_hal(bwl::HALType::Monitor, iface_name, IfaceType::Intel, callback), - base_wlan_hal_dwpal(bwl::HALType::Monitor, iface_name, callback) +mon_wlan_hal_dwpal::mon_wlan_hal_dwpal(const std::string &iface_name, hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf) + : base_wlan_hal(bwl::HALType::Monitor, iface_name, IfaceType::Intel, callback, hal_conf), + base_wlan_hal_dwpal(bwl::HALType::Monitor, iface_name, callback, hal_conf) { } @@ -1419,10 +1420,11 @@ bool mon_wlan_hal_dwpal::process_dwpal_nl_event(struct nl_msg *msg) } // namespace dwpal -std::shared_ptr mon_wlan_hal_create(std::string iface_name, - base_wlan_hal::hal_event_cb_t callback) +std::shared_ptr mon_wlan_hal_create(const std::string &iface_name, + base_wlan_hal::hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf) { - return std::make_shared(iface_name, callback); + return std::make_shared(iface_name, callback, hal_conf); } } // namespace bwl diff --git a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.h b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.h index b506e80ef9..811ac330e9 100644 --- a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.h +++ b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.h @@ -29,7 +29,8 @@ class mon_wlan_hal_dwpal : public base_wlan_hal_dwpal, public mon_wlan_hal { * @param [in] iface_name Monitor interface name. * @param [in] callback Callback for handling internal events. */ - mon_wlan_hal_dwpal(const std::string &iface_name, hal_event_cb_t callback); + mon_wlan_hal_dwpal(const std::string &iface_name, hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf); virtual ~mon_wlan_hal_dwpal(); virtual bool update_radio_stats(SRadioStats &radio_stats) override; From a83024e85f725aa68a7ff5c1579a10106cdf877b Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sat, 27 Jun 2020 13:14:26 +0300 Subject: [PATCH 224/453] bwl: nl80211: Modify mon_wlan_hal_nl80211 constructor Need to update mon_wlan_hal_create() method by adding argument for hal_conf_t structure, and update nl80211 HAL for using new argument. Signed-off-by: Ivan Efimov Signed-off-by: Vladyslav Tupikin --- .../beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp | 14 ++++++++------ common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.h | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp index f872db6def..13fb9e5627 100644 --- a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp +++ b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp @@ -88,9 +88,10 @@ static void calc_curr_traffic(std::string buff, uint64_t &total, uint32_t &curr) /////////////////////////////// Implementation /////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -mon_wlan_hal_nl80211::mon_wlan_hal_nl80211(const std::string &iface_name, hal_event_cb_t callback) - : base_wlan_hal(bwl::HALType::Monitor, iface_name, IfaceType::Intel, callback), - base_wlan_hal_nl80211(bwl::HALType::Monitor, iface_name, callback, BUFFER_SIZE) +mon_wlan_hal_nl80211::mon_wlan_hal_nl80211(const std::string &iface_name, hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf) + : base_wlan_hal(bwl::HALType::Monitor, iface_name, IfaceType::Intel, callback, hal_conf), + base_wlan_hal_nl80211(bwl::HALType::Monitor, iface_name, callback, BUFFER_SIZE, hal_conf) { } @@ -583,10 +584,11 @@ bool mon_wlan_hal_nl80211::process_nl80211_event(parsed_obj_map_t &parsed_obj) } // namespace nl80211 -std::shared_ptr mon_wlan_hal_create(std::string iface_name, - base_wlan_hal::hal_event_cb_t callback) +std::shared_ptr mon_wlan_hal_create(const std::string &iface_name, + base_wlan_hal::hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf) { - return std::make_shared(iface_name, callback); + return std::make_shared(iface_name, callback, hal_conf); } } // namespace bwl diff --git a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.h b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.h index 074414d2e0..f2448e1237 100644 --- a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.h +++ b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.h @@ -28,7 +28,8 @@ class mon_wlan_hal_nl80211 : public base_wlan_hal_nl80211, public mon_wlan_hal { * @param [in] iface_name Monitor interface name. * @param [in] callback Callback for handling internal events. */ - mon_wlan_hal_nl80211(const std::string &iface_name, hal_event_cb_t callback); + mon_wlan_hal_nl80211(const std::string &iface_name, hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf); virtual ~mon_wlan_hal_nl80211(); virtual bool update_radio_stats(SRadioStats &radio_stats) override; From 2d1926595b104d8b0ba3b5f95c2f02225a1f68c2 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sun, 12 Jul 2020 10:48:30 +0300 Subject: [PATCH 225/453] agent: backhaul_manager: Update WPA_ATTACH handler Need to update WPA_ATTACH handler - create ojcect of hal_conf_t structure, fill up wpa_ctrl_path using bpl_cfg_get_wpa_supplicant_ctrl_path() method, tranfer hal_conf_t object to the sta_wlan_hal_create() method. Also need to update arguments in sta_wlan_hal_create() method - add new argument for hal_conf_t structure. Signed-off-by: Vladyslav Tupikin --- .../backhaul_manager/backhaul_manager_thread.cpp | 12 +++++++++++- common/beerocks/bwl/include/bwl/sta_wlan_hal.h | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index bba99d6fb3..de78718fec 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -1346,9 +1346,19 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) // Create a HAL instance if doesn't exists if (!soc->sta_wlan_hal) { + + bwl::hal_conf_t hal_conf; + + if (!beerocks::bpl::bpl_cfg_get_wpa_supplicant_ctrl_path(iface, + hal_conf.wpa_ctrl_path)) { + LOG(ERROR) << "Couldn't get hostapd control path"; + return false; + } + using namespace std::placeholders; // for `_1` soc->sta_wlan_hal = bwl::sta_wlan_hal_create( - iface, std::bind(&backhaul_manager::hal_event_handler, this, _1, iface)); + iface, std::bind(&backhaul_manager::hal_event_handler, this, _1, iface), + hal_conf); LOG_IF(!soc->sta_wlan_hal, FATAL) << "Failed creating HAL instance!"; } else { LOG(DEBUG) << "STA HAL exists..."; diff --git a/common/beerocks/bwl/include/bwl/sta_wlan_hal.h b/common/beerocks/bwl/include/bwl/sta_wlan_hal.h index 4d89fd49df..333c0020c3 100644 --- a/common/beerocks/bwl/include/bwl/sta_wlan_hal.h +++ b/common/beerocks/bwl/include/bwl/sta_wlan_hal.h @@ -70,7 +70,8 @@ class sta_wlan_hal : public virtual base_wlan_hal { // STA HAL factory types std::shared_ptr sta_wlan_hal_create(const std::string &iface_name, - base_wlan_hal::hal_event_cb_t cb); + base_wlan_hal::hal_event_cb_t cb, + const bwl::hal_conf_t &hal_conf); } // namespace bwl From 878d50278c614da70959d57131621a720769aa4d Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sat, 27 Jun 2020 13:51:43 +0300 Subject: [PATCH 226/453] bwl: dummy: Modify sta_wlan_hal_dummy constructor Need to update sta_wlan_hal_create() method by adding argument for hal_conf_t structure, and update dummy HAL for using new argument. Signed-off-by: Ivan Efimov Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/dummy/sta_wlan_hal_dummy.cpp | 12 +++++++----- common/beerocks/bwl/dummy/sta_wlan_hal_dummy.h | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.cpp b/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.cpp index cc74396ce0..a0ec157e7f 100644 --- a/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.cpp +++ b/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.cpp @@ -16,9 +16,10 @@ namespace bwl { namespace dummy { -sta_wlan_hal_dummy::sta_wlan_hal_dummy(const std::string &iface_name, hal_event_cb_t callback) - : base_wlan_hal(bwl::HALType::Station, iface_name, IfaceType::Intel, callback, {}), - base_wlan_hal_dummy(bwl::HALType::Station, iface_name, callback, {}) +sta_wlan_hal_dummy::sta_wlan_hal_dummy(const std::string &iface_name, hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf) + : base_wlan_hal(bwl::HALType::Station, iface_name, IfaceType::Intel, callback, hal_conf), + base_wlan_hal_dummy(bwl::HALType::Station, iface_name, callback, hal_conf) { } @@ -81,9 +82,10 @@ bool sta_wlan_hal_dummy::update_status() } // namespace dummy std::shared_ptr sta_wlan_hal_create(const std::string &iface_name, - base_wlan_hal::hal_event_cb_t callback) + base_wlan_hal::hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf) { - return std::make_shared(iface_name, callback); + return std::make_shared(iface_name, callback, hal_conf); } } // namespace bwl diff --git a/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.h b/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.h index e99662496a..3c9307f005 100644 --- a/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.h +++ b/common/beerocks/bwl/dummy/sta_wlan_hal_dummy.h @@ -28,7 +28,8 @@ class sta_wlan_hal_dummy : public base_wlan_hal_dummy, public sta_wlan_hal { * @param [in] iface_name STA/Client interface name. * @param [in] callback Callback for handling internal events. */ - sta_wlan_hal_dummy(const std::string &iface_name, hal_event_cb_t callback); + sta_wlan_hal_dummy(const std::string &iface_name, hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf); virtual ~sta_wlan_hal_dummy(); virtual bool start_wps_pbc() override; From a71c4bdbf83703afca2cc61e1ccdbb13c1d8e9d4 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sat, 27 Jun 2020 13:55:18 +0300 Subject: [PATCH 227/453] bwl: dwpal: Modify sta_wlan_hal_dwpal constructor Need to update sta_wlan_hal_create() method by adding argument for hal_conf_t structure, and update dwpal HAL for using new argument. Signed-off-by: Ivan Efimov Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp | 12 +++++++----- common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.h | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp index efc11de72f..000ae0aa76 100644 --- a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp @@ -91,9 +91,10 @@ static std::string dwpal_security_val(WiFiSec sec) /////////////////////////////// Implementation /////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -sta_wlan_hal_dwpal::sta_wlan_hal_dwpal(const std::string &iface_name, hal_event_cb_t callback) - : base_wlan_hal(bwl::HALType::Station, iface_name, IfaceType::Intel, callback), - base_wlan_hal_dwpal(bwl::HALType::Station, iface_name, callback) +sta_wlan_hal_dwpal::sta_wlan_hal_dwpal(const std::string &iface_name, hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf) + : base_wlan_hal(bwl::HALType::Station, iface_name, IfaceType::Intel, callback, hal_conf), + base_wlan_hal_dwpal(bwl::HALType::Station, iface_name, callback, hal_conf) { } @@ -845,9 +846,10 @@ bool sta_wlan_hal_dwpal::parse_fapi_event(const std::string& opcode, std::shared } // namespace dwpal std::shared_ptr sta_wlan_hal_create(const std::string &iface_name, - base_wlan_hal::hal_event_cb_t callback) + base_wlan_hal::hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf) { - return std::make_shared(iface_name, callback); + return std::make_shared(iface_name, callback, hal_conf); } } // namespace bwl diff --git a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.h b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.h index 7b12365883..fb0708a4b0 100644 --- a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.h +++ b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.h @@ -28,7 +28,8 @@ class sta_wlan_hal_dwpal : public base_wlan_hal_dwpal, public sta_wlan_hal { * @param [in] iface_name STA/Client interface name. * @param [in] callback Callback for handling internal events. */ - sta_wlan_hal_dwpal(const std::string &iface_name, hal_event_cb_t callback); + sta_wlan_hal_dwpal(const std::string &iface_name, hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf); virtual ~sta_wlan_hal_dwpal(); virtual bool initiate_scan() override; From efc9f3d2325983763e675c15ca1896d4f92ba463 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sat, 27 Jun 2020 14:21:59 +0300 Subject: [PATCH 228/453] bwl: nl80211: Modify sta_wlan_hal_nl80211 constructor Need to update sta_wlan_hal_create() method by adding argument for hal_conf_t structure, and update nl80211 HAL for using new argument. Signed-off-by: Ivan Efimov Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp | 11 +++++++---- common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp index b0c8784374..15838ccb07 100644 --- a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp +++ b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp @@ -16,8 +16,10 @@ namespace bwl { namespace nl80211 { -sta_wlan_hal_nl80211::sta_wlan_hal_nl80211(const std::string &iface_name, hal_event_cb_t callback) - : base_wlan_hal(), base_wlan_hal_nl80211(bwl::HALType::Station, iface_name, callback, {}) +sta_wlan_hal_nl80211::sta_wlan_hal_nl80211(const std::string &iface_name, hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf) + : base_wlan_hal(bwl::HALType::Station, iface_name, IfaceType::Intel, callback, hal_conf), + base_wlan_hal_nl80211(bwl::HALType::Station, iface_name, callback, BUFFER_SIZE, hal_conf) { } @@ -72,9 +74,10 @@ bool sta_wlan_hal_nl80211::update_status() { return false; } } // namespace nl80211 std::shared_ptr sta_wlan_hal_create(const std::string &iface_name, - base_wlan_hal::hal_event_cb_t callback) + base_wlan_hal::hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf) { - return std::make_shared(iface_name, callback); + return std::make_shared(iface_name, callback, hal_conf); } } // namespace bwl diff --git a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h index c3224a7694..edffd40cff 100644 --- a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h +++ b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h @@ -12,6 +12,8 @@ #include "base_wlan_hal_nl80211.h" #include +#define BUFFER_SIZE 4096 + namespace bwl { namespace nl80211 { @@ -28,7 +30,8 @@ class sta_wlan_hal_nl80211 : public base_wlan_hal_nl80211, public sta_wlan_hal { * @param [in] iface_name STA/Client interface name. * @param [in] callback Callback for handling internal events. */ - sta_wlan_hal_nl80211(const std::string &iface_name, hal_event_cb_t callback); + sta_wlan_hal_nl80211(const std::string &iface_name, hal_event_cb_t callback, + const bwl::hal_conf_t &hal_conf); virtual ~sta_wlan_hal_nl80211(); virtual bool start_wps_pbc() override; From 8ea1c515abef481b4f57d8f70b825af0e2b55076 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Sat, 27 Jun 2020 14:34:36 +0300 Subject: [PATCH 229/453] bwl: nl80211: Update initialization for m_wpa_ctrl_path Need to remove useless condition and change initialization for m_wpa_ctrl_path variable from hal_conf_t structure. Signed-off-by: Vladyslav Tupikin --- .../beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp b/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp index 5e4ffed100..b333e7b61a 100644 --- a/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp +++ b/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp @@ -218,17 +218,7 @@ base_wlan_hal_nl80211::base_wlan_hal_nl80211(HALType type, const std::string &if }); } - m_wpa_ctrl_path = BASE_CTRL_PATH; - if (get_type() == HALType::AccessPoint || get_type() == HALType::Monitor) { - m_wpa_ctrl_path += "hostapd/"; - } else if (get_type() == HALType::Station) { - m_wpa_ctrl_path += "wpa_supplicant/"; - } else { - LOG(ERROR) << "Unsupported HAL Type: " << int(get_type()); - return; // HACK TODO what should we do in that case? - } - - m_wpa_ctrl_path += m_radio_info.iface_name; + m_wpa_ctrl_path = hal_conf.wpa_ctrl_path; // Initialize the FSM fsm_setup(); From f5dab27ebccaa47237f2ef7556ec968849273157 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 14 Jul 2020 14:49:35 +0300 Subject: [PATCH 230/453] AUTHORS.md: Add new author Add Ivan Efimov in AUTHORS.md because half of commits was prepared by Ivan Efimov. Signed-off-by: Vladyslav Tupikin --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 1e1628ed04..4807ca840f 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -20,6 +20,7 @@ This file lists all contributors. - Gal Wiener - Intel Corporation - Itay Elenzweig +- Ivan Efimov - Juan Schroeder - KC Chen - Lior Amram From cd34216047cb97f3ea1216d75e86a8d1d50a907b Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Tue, 14 Jul 2020 11:00:15 +0200 Subject: [PATCH 231/453] CODEOWNERS: add Adam Dov as a code owner While we're at it, sort alphabetically (according to username). Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 2975166513..d581891202 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @tomereli @arnout @mariomaz @morantr @rmelotte @vitalybu @kantera800 +* @adam1985d @arnout @kantera800 @mariomaz @morantr @rmelotte @tomereli @vitalybu From e9c14b2f7eedf3331ac934ba5462481422ee81d5 Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Thu, 2 Jul 2020 08:55:04 +0000 Subject: [PATCH 232/453] controller: bml: fix for comment Small fix for two DCS comments Signed-off-by: itay elenzweig --- controller/src/beerocks/bml/bml.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controller/src/beerocks/bml/bml.cpp b/controller/src/beerocks/bml/bml.cpp index 303357f430..ca5b9a5e33 100644 --- a/controller/src/beerocks/bml/bml.cpp +++ b/controller/src/beerocks/bml/bml.cpp @@ -686,7 +686,7 @@ int bml_get_dcs_scan_results(BML_CTX ctx, const char *radio_mac, unsigned int *output_results_size, unsigned char *output_result_status, bool is_single_scan) { - // Validate intput params; + // Validate input parameters if (!ctx) { return (-BML_RET_INVALID_ARGS); } @@ -700,7 +700,7 @@ int bml_get_dcs_scan_results(BML_CTX ctx, const char *radio_mac, int bml_start_dcs_single_scan(BML_CTX ctx, const char *radio_mac, int dwell_time, int channel_pool_size, unsigned int *channel_pool) { - // Validate intput params; + // Validate input parameters if (!ctx) { return (-BML_RET_INVALID_ARGS); } From d3ba21c77b5600697f92504e8051f079b29237c3 Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Wed, 24 Jun 2020 08:52:06 +0000 Subject: [PATCH 233/453] bcl: add BML structs const defines preparative commit In this commit we introduce two structures that will be used for client smart-steering. Also to support optional configurations and parameters which are not yet configured, we need a constant to represent "Non-configured" values. Add a const-expression to represent parameter-not-configured. Add enum-like defines for the client's Selected-Bands Add structures for the client configuration. Relates to JIRA PPM-5 Signed-off-by: itay elenzweig --- .../bcl/include/bcl/beerocks_defines.h | 2 + controller/src/beerocks/bml/bml_defs.h | 48 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/common/beerocks/bcl/include/bcl/beerocks_defines.h b/common/beerocks/bcl/include/bcl/beerocks_defines.h index b380de6d50..ff453597a3 100644 --- a/common/beerocks/bcl/include/bcl/beerocks_defines.h +++ b/common/beerocks/bcl/include/bcl/beerocks_defines.h @@ -474,6 +474,8 @@ enum class eChannelScanOperationCode : uint8_t { #define CHANNEL_SCAN_INVALID_PARAM -1 #define SCAN_ALL_CHANNELS 0 +constexpr int PARAMETER_NOT_CONFIGURED = -1; + } // namespace beerocks #endif //_BEEROCKS_DEFINES_H_ diff --git a/controller/src/beerocks/bml/bml_defs.h b/controller/src/beerocks/bml/bml_defs.h index 0badfd77a2..d005b82cbb 100644 --- a/controller/src/beerocks/bml/bml_defs.h +++ b/controller/src/beerocks/bml/bml_defs.h @@ -122,6 +122,15 @@ extern "C" { #define BML_CHANNEL_SCAN_MAX_CHANNEL_POOL_SIZE 32 /* Maximal size of the channel pool */ #define BML_CHANNEL_SCAN_ENUM_LIST_SIZE 8 +/* BML Client Selected Bands */ +#define BML_CLIENT_SELECTED_BANDS_DISABLED 0 +#define BML_CLIENT_SELECTED_BANDS_24G 1 +#define BML_CLIENT_SELECTED_BANDS_5G 2 +#define BML_CLIENT_SELECTED_BANDS_6G 4 +#define BML_CLIENT_SELECTED_BANDS_60G 8 + +#define BML_PARAMETER_NOT_CONFIGURED -1 + /****************************************************************************/ /******************************* General Types ******************************/ /****************************************************************************/ @@ -610,6 +619,45 @@ struct BML_NEIGHBOR_AP { uint32_t ap_ChannelUtilization; }; +struct BML_CLIENT_CONFIG { + // 1 for true, 0 for false, -1 for "not configured". + int8_t stay_on_initial_radio; + + // 1 for true, 0 for false, -1 for "not configured". + int8_t stay_on_selected_device; + + // Bitwise value of selected bands for the client. + // Correlates to BML_CLIENT_SELECTED_BANDS + int8_t selected_bands; +}; + +struct BML_CLIENT { + // Client MAC. + char sta_mac[BML_MAC_ADDR_LEN]; + + // Time of last client configuration edit (in Seconds) + uint32_t timestamp_sec; + + // 1 for true, 0 for false, -1 for "parameter is not configured". + int8_t single_band; + + // 1 for true, 0 for false, -1 for "not configured". + int8_t stay_on_initial_radio; + + // 1 for true, 0 for false, -1 for "not configured". + int8_t stay_on_selected_device; + + // Bitwise value of selected bands for the client. + // Correlates to BML_CLIENT_SELECTED_BANDS + int8_t selected_bands; + + // Optional parameter, + // Determines the period of time after which the client configuration should be cleared, + // 0 - Never age. + // -1 - Not Configured. + uint32_t time_life_delay_days; +}; + /****************************************************************************/ /****************************** Callback Types ******************************/ /****************************************************************************/ From 1322bc0aae1b0a1d896e161d269355cd4bcdc16f Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Wed, 24 Jun 2020 11:14:02 +0000 Subject: [PATCH 234/453] tlvf: add BML_CLIENT messages for smart-steering preparative commit Add client set/get CMDUs to enable smart-steering Relates to JIRA PPM-5 Signed-off-by: itay elenzweig --- .../beerocks/tlvf/beerocks_message_action.h | 8 +- .../beerocks/tlvf/beerocks_message_bml.h | 136 +++++ .../beerocks/tlvf/beerocks_message_common.h | 55 ++ .../beerocks/tlvf/beerocks_message_bml.cpp | 486 ++++++++++++++++++ .../tlvf/beerocks_message_action.yaml | 9 +- .../beerocks/tlvf/beerocks_message_bml.yaml | 34 ++ .../tlvf/beerocks_message_common.yaml | 56 ++ 7 files changed, 782 insertions(+), 2 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index b7a0f1c61a..1da7caf339 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -415,7 +415,13 @@ enum eActionOp_BML: uint8_t { ACTION_BML_CHANNEL_SCAN_GET_RESULTS_RESPONSE = 0xd3, ACTION_BML_CHANNEL_SCAN_DUMP_RESULTS_REQUEST = 0xd4, ACTION_BML_CHANNEL_SCAN_DUMP_RESULTS_RESPONSE = 0xd5, - ACTION_BML_ENUM_END = 0xd6, + ACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST = 0xd7, + ACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE = 0xd8, + ACTION_BML_CLIENT_SET_CLIENT_REQUEST = 0xd9, + ACTION_BML_CLIENT_SET_CLIENT_RESPONSE = 0xda, + ACTION_BML_CLIENT_GET_CLIENT_REQUEST = 0xdb, + ACTION_BML_CLIENT_GET_CLIENT_RESPONSE = 0xdc, + ACTION_BML_ENUM_END = 0xe1, }; diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_bml.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_bml.h index 008504c86f..03b1658add 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_bml.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_bml.h @@ -2219,6 +2219,142 @@ class cACTION_BML_WIFI_CREDENTIALS_CLEAR_RESPONSE : public BaseClass uint32_t* m_error_code = nullptr; }; +class cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST : public BaseClass +{ + public: + cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); + explicit cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST(std::shared_ptr base, bool parse = false); + ~cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST(); + + static eActionOp_BML get_action_op(){ + return (eActionOp_BML)(ACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST); + } + void class_swap() override; + bool finalize() override; + static size_t get_initial_size(); + + private: + bool init(); + eActionOp_BML* m_action_op = nullptr; +}; + +class cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE : public BaseClass +{ + public: + cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE(uint8_t* buff, size_t buff_len, bool parse = false); + explicit cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE(std::shared_ptr base, bool parse = false); + ~cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE(); + + static eActionOp_BML get_action_op(){ + return (eActionOp_BML)(ACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE); + } + uint32_t& client_list_size(); + std::string client_list_str(); + char* client_list(size_t length = 0); + bool set_client_list(const std::string& str); + bool set_client_list(const char buffer[], size_t size); + bool alloc_client_list(size_t count = 1); + void class_swap() override; + bool finalize() override; + static size_t get_initial_size(); + + private: + bool init(); + eActionOp_BML* m_action_op = nullptr; + uint32_t* m_client_list_size = nullptr; + char* m_client_list = nullptr; + size_t m_client_list_idx__ = 0; + int m_lock_order_counter__ = 0; +}; + +class cACTION_BML_CLIENT_SET_CLIENT_REQUEST : public BaseClass +{ + public: + cACTION_BML_CLIENT_SET_CLIENT_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); + explicit cACTION_BML_CLIENT_SET_CLIENT_REQUEST(std::shared_ptr base, bool parse = false); + ~cACTION_BML_CLIENT_SET_CLIENT_REQUEST(); + + static eActionOp_BML get_action_op(){ + return (eActionOp_BML)(ACTION_BML_CLIENT_SET_CLIENT_REQUEST); + } + sMacAddr& sta_mac(); + sClientConfig& client_config(); + void class_swap() override; + bool finalize() override; + static size_t get_initial_size(); + + private: + bool init(); + eActionOp_BML* m_action_op = nullptr; + sMacAddr* m_sta_mac = nullptr; + sClientConfig* m_client_config = nullptr; +}; + +class cACTION_BML_CLIENT_SET_CLIENT_RESPONSE : public BaseClass +{ + public: + cACTION_BML_CLIENT_SET_CLIENT_RESPONSE(uint8_t* buff, size_t buff_len, bool parse = false); + explicit cACTION_BML_CLIENT_SET_CLIENT_RESPONSE(std::shared_ptr base, bool parse = false); + ~cACTION_BML_CLIENT_SET_CLIENT_RESPONSE(); + + static eActionOp_BML get_action_op(){ + return (eActionOp_BML)(ACTION_BML_CLIENT_SET_CLIENT_RESPONSE); + } + uint8_t& result(); + void class_swap() override; + bool finalize() override; + static size_t get_initial_size(); + + private: + bool init(); + eActionOp_BML* m_action_op = nullptr; + uint8_t* m_result = nullptr; +}; + +class cACTION_BML_CLIENT_GET_CLIENT_REQUEST : public BaseClass +{ + public: + cACTION_BML_CLIENT_GET_CLIENT_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); + explicit cACTION_BML_CLIENT_GET_CLIENT_REQUEST(std::shared_ptr base, bool parse = false); + ~cACTION_BML_CLIENT_GET_CLIENT_REQUEST(); + + static eActionOp_BML get_action_op(){ + return (eActionOp_BML)(ACTION_BML_CLIENT_GET_CLIENT_REQUEST); + } + sMacAddr& sta_mac(); + void class_swap() override; + bool finalize() override; + static size_t get_initial_size(); + + private: + bool init(); + eActionOp_BML* m_action_op = nullptr; + sMacAddr* m_sta_mac = nullptr; +}; + +class cACTION_BML_CLIENT_GET_CLIENT_RESPONSE : public BaseClass +{ + public: + cACTION_BML_CLIENT_GET_CLIENT_RESPONSE(uint8_t* buff, size_t buff_len, bool parse = false); + explicit cACTION_BML_CLIENT_GET_CLIENT_RESPONSE(std::shared_ptr base, bool parse = false); + ~cACTION_BML_CLIENT_GET_CLIENT_RESPONSE(); + + static eActionOp_BML get_action_op(){ + return (eActionOp_BML)(ACTION_BML_CLIENT_GET_CLIENT_RESPONSE); + } + uint8_t& result(); + sClient& client(); + void class_swap() override; + bool finalize() override; + static size_t get_initial_size(); + + private: + bool init(); + eActionOp_BML* m_action_op = nullptr; + uint8_t* m_result = nullptr; + sClient* m_client = nullptr; +}; + }; // close namespace: beerocks_message #endif //_BEEROCKS/TLVF_BEEROCKS_MESSAGE_BML_H_ diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h index e0194572c2..3e4fea8e48 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h @@ -1364,6 +1364,61 @@ typedef struct sBssidInfo { } } __attribute__((packed)) sBssidInfo; +enum eClientSelectedBands: uint8_t { + eSelectedBands_Disabled = 0x0, + eSelectedBands_24G = 0x1, + eSelectedBands_5G = 0x2, + eSelectedBands_6G = 0x4, + eSelectedBands_60G = 0x8, +}; + +typedef struct sClientConfig { + //1 for true, 0 for false, -1 for "not configured". + int8_t stay_on_initial_radio; + //1 for true, 0 for false, -1 for "not configured". + int8_t stay_on_selected_device; + //Bitset of selected bands supported by the client according to eClientSelectedBands + int8_t selected_bands; + void struct_swap(){ + } + void struct_init(){ + stay_on_initial_radio = -0x1; + stay_on_selected_device = -0x1; + } +} __attribute__((packed)) sClientConfig; + +typedef struct sClient { + //Client MAC + sMacAddr sta_mac; + //Time of last client configuration edit (in Seconds) + uint32_t timestamp_sec; + //1 for true, 0 for false, -1 for "not configured". + int8_t stay_on_initial_radio; + //1 for true, 0 for false, -1 for "not configured". + int8_t stay_on_selected_device; + //Bitset of selected bands supported by the client according to eClientSelectedBands + int8_t selected_bands; + //1 for true, 0 for false, -1 for "not configured". + int8_t single_band; + //Optional parameter, + //Determines the period of time after which the client configuration should be cleared, + //0 - Never age. + //-1 - Not Configured. + int32_t time_life_delay_days; + void struct_swap(){ + sta_mac.struct_swap(); + tlvf_swap(32, reinterpret_cast(×tamp_sec)); + tlvf_swap(32, reinterpret_cast(&time_life_delay_days)); + } + void struct_init(){ + timestamp_sec = 0x0; + stay_on_initial_radio = -0x1; + stay_on_selected_device = -0x1; + single_band = -0x1; + time_life_delay_days = -0x1; + } +} __attribute__((packed)) sClient; + }; // close namespace: beerocks_message diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_bml.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_bml.cpp index c1106aca71..83c640541c 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_bml.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_bml.cpp @@ -7534,4 +7534,490 @@ bool cACTION_BML_WIFI_CREDENTIALS_CLEAR_RESPONSE::init() return true; } +cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST::cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : + BaseClass(buff, buff_len, parse) { + m_init_succeeded = init(); +} +cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST::cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST(std::shared_ptr base, bool parse) : +BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ + m_init_succeeded = init(); +} +cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST::~cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST() { +} +void cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST::class_swap() +{ + tlvf_swap(8*sizeof(eActionOp_BML), reinterpret_cast(m_action_op)); +} + +bool cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST::finalize() +{ + if (m_parse__) { + TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; + return true; + } + if (m_finalized__) { + TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; + return true; + } + if (!isPostInitSucceeded()) { + TLVF_LOG(ERROR) << "post init check failed"; + return false; + } + if (m_inner__) { + if (!m_inner__->finalize()) { + TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; + return false; + } + auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); + m_buff_ptr__ -= tailroom; + } + class_swap(); + m_finalized__ = true; + return true; +} + +size_t cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST::get_initial_size() +{ + size_t class_size = 0; + return class_size; +} + +bool cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST::init() +{ + if (getBuffRemainingBytes() < get_initial_size()) { + TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; + return false; + } + if (m_parse__) { class_swap(); } + return true; +} + +cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE(uint8_t* buff, size_t buff_len, bool parse) : + BaseClass(buff, buff_len, parse) { + m_init_succeeded = init(); +} +cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE(std::shared_ptr base, bool parse) : +BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ + m_init_succeeded = init(); +} +cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::~cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE() { +} +uint32_t& cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::client_list_size() { + return (uint32_t&)(*m_client_list_size); +} + +std::string cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::client_list_str() { + char *client_list_ = client_list(); + if (!client_list_) { return std::string(); } + return std::string(client_list_, m_client_list_idx__); +} + +char* cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::client_list(size_t length) { + if( (m_client_list_idx__ == 0) || (m_client_list_idx__ < length) ) { + TLVF_LOG(ERROR) << "client_list length is smaller than requested length"; + return nullptr; + } + return ((char*)m_client_list); +} + +bool cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::set_client_list(const std::string& str) { return set_client_list(str.c_str(), str.size()); } +bool cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::set_client_list(const char str[], size_t size) { + if (str == nullptr) { + TLVF_LOG(WARNING) << "set_client_list received a null pointer."; + return false; + } + if (!alloc_client_list(size)) { return false; } + std::copy(str, str + size, m_client_list); + return true; +} +bool cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::alloc_client_list(size_t count) { + if (m_lock_order_counter__ > 0) {; + TLVF_LOG(ERROR) << "Out of order allocation for variable length list client_list, abort!"; + return false; + } + size_t len = sizeof(char) * count; + if(getBuffRemainingBytes() < len ) { + TLVF_LOG(ERROR) << "Not enough available space on buffer - can't allocate"; + return false; + } + m_lock_order_counter__ = 0; + uint8_t *src = (uint8_t *)&m_client_list[*m_client_list_size]; + uint8_t *dst = src + len; + if (!m_parse__) { + size_t move_length = getBuffRemainingBytes(src) - len; + std::copy_n(src, move_length, dst); + } + m_client_list_idx__ += count; + *m_client_list_size += count; + if (!buffPtrIncrementSafe(len)) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << len << ") Failed!"; + return false; + } + return true; +} + +void cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::class_swap() +{ + tlvf_swap(8*sizeof(eActionOp_BML), reinterpret_cast(m_action_op)); + tlvf_swap(32, reinterpret_cast(m_client_list_size)); +} + +bool cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::finalize() +{ + if (m_parse__) { + TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; + return true; + } + if (m_finalized__) { + TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; + return true; + } + if (!isPostInitSucceeded()) { + TLVF_LOG(ERROR) << "post init check failed"; + return false; + } + if (m_inner__) { + if (!m_inner__->finalize()) { + TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; + return false; + } + auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); + m_buff_ptr__ -= tailroom; + } + class_swap(); + m_finalized__ = true; + return true; +} + +size_t cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::get_initial_size() +{ + size_t class_size = 0; + class_size += sizeof(uint32_t); // client_list_size + return class_size; +} + +bool cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::init() +{ + if (getBuffRemainingBytes() < get_initial_size()) { + TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; + return false; + } + m_client_list_size = reinterpret_cast(m_buff_ptr__); + if (!m_parse__) *m_client_list_size = 0; + if (!buffPtrIncrementSafe(sizeof(uint32_t))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint32_t) << ") Failed!"; + return false; + } + m_client_list = (char*)m_buff_ptr__; + uint32_t client_list_size = *m_client_list_size; + if (m_parse__) { tlvf_swap(32, reinterpret_cast(&client_list_size)); } + m_client_list_idx__ = client_list_size; + if (!buffPtrIncrementSafe(sizeof(char) * (client_list_size))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(char) * (client_list_size) << ") Failed!"; + return false; + } + if (m_parse__) { class_swap(); } + return true; +} + +cACTION_BML_CLIENT_SET_CLIENT_REQUEST::cACTION_BML_CLIENT_SET_CLIENT_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : + BaseClass(buff, buff_len, parse) { + m_init_succeeded = init(); +} +cACTION_BML_CLIENT_SET_CLIENT_REQUEST::cACTION_BML_CLIENT_SET_CLIENT_REQUEST(std::shared_ptr base, bool parse) : +BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ + m_init_succeeded = init(); +} +cACTION_BML_CLIENT_SET_CLIENT_REQUEST::~cACTION_BML_CLIENT_SET_CLIENT_REQUEST() { +} +sMacAddr& cACTION_BML_CLIENT_SET_CLIENT_REQUEST::sta_mac() { + return (sMacAddr&)(*m_sta_mac); +} + +sClientConfig& cACTION_BML_CLIENT_SET_CLIENT_REQUEST::client_config() { + return (sClientConfig&)(*m_client_config); +} + +void cACTION_BML_CLIENT_SET_CLIENT_REQUEST::class_swap() +{ + tlvf_swap(8*sizeof(eActionOp_BML), reinterpret_cast(m_action_op)); + m_sta_mac->struct_swap(); + m_client_config->struct_swap(); +} + +bool cACTION_BML_CLIENT_SET_CLIENT_REQUEST::finalize() +{ + if (m_parse__) { + TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; + return true; + } + if (m_finalized__) { + TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; + return true; + } + if (!isPostInitSucceeded()) { + TLVF_LOG(ERROR) << "post init check failed"; + return false; + } + if (m_inner__) { + if (!m_inner__->finalize()) { + TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; + return false; + } + auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); + m_buff_ptr__ -= tailroom; + } + class_swap(); + m_finalized__ = true; + return true; +} + +size_t cACTION_BML_CLIENT_SET_CLIENT_REQUEST::get_initial_size() +{ + size_t class_size = 0; + class_size += sizeof(sMacAddr); // sta_mac + class_size += sizeof(sClientConfig); // client_config + return class_size; +} + +bool cACTION_BML_CLIENT_SET_CLIENT_REQUEST::init() +{ + if (getBuffRemainingBytes() < get_initial_size()) { + TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; + return false; + } + m_sta_mac = reinterpret_cast(m_buff_ptr__); + if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; + return false; + } + if (!m_parse__) { m_sta_mac->struct_init(); } + m_client_config = reinterpret_cast(m_buff_ptr__); + if (!buffPtrIncrementSafe(sizeof(sClientConfig))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sClientConfig) << ") Failed!"; + return false; + } + if (!m_parse__) { m_client_config->struct_init(); } + if (m_parse__) { class_swap(); } + return true; +} + +cACTION_BML_CLIENT_SET_CLIENT_RESPONSE::cACTION_BML_CLIENT_SET_CLIENT_RESPONSE(uint8_t* buff, size_t buff_len, bool parse) : + BaseClass(buff, buff_len, parse) { + m_init_succeeded = init(); +} +cACTION_BML_CLIENT_SET_CLIENT_RESPONSE::cACTION_BML_CLIENT_SET_CLIENT_RESPONSE(std::shared_ptr base, bool parse) : +BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ + m_init_succeeded = init(); +} +cACTION_BML_CLIENT_SET_CLIENT_RESPONSE::~cACTION_BML_CLIENT_SET_CLIENT_RESPONSE() { +} +uint8_t& cACTION_BML_CLIENT_SET_CLIENT_RESPONSE::result() { + return (uint8_t&)(*m_result); +} + +void cACTION_BML_CLIENT_SET_CLIENT_RESPONSE::class_swap() +{ + tlvf_swap(8*sizeof(eActionOp_BML), reinterpret_cast(m_action_op)); +} + +bool cACTION_BML_CLIENT_SET_CLIENT_RESPONSE::finalize() +{ + if (m_parse__) { + TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; + return true; + } + if (m_finalized__) { + TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; + return true; + } + if (!isPostInitSucceeded()) { + TLVF_LOG(ERROR) << "post init check failed"; + return false; + } + if (m_inner__) { + if (!m_inner__->finalize()) { + TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; + return false; + } + auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); + m_buff_ptr__ -= tailroom; + } + class_swap(); + m_finalized__ = true; + return true; +} + +size_t cACTION_BML_CLIENT_SET_CLIENT_RESPONSE::get_initial_size() +{ + size_t class_size = 0; + class_size += sizeof(uint8_t); // result + return class_size; +} + +bool cACTION_BML_CLIENT_SET_CLIENT_RESPONSE::init() +{ + if (getBuffRemainingBytes() < get_initial_size()) { + TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; + return false; + } + m_result = reinterpret_cast(m_buff_ptr__); + if (!buffPtrIncrementSafe(sizeof(uint8_t))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; + return false; + } + if (m_parse__) { class_swap(); } + return true; +} + +cACTION_BML_CLIENT_GET_CLIENT_REQUEST::cACTION_BML_CLIENT_GET_CLIENT_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : + BaseClass(buff, buff_len, parse) { + m_init_succeeded = init(); +} +cACTION_BML_CLIENT_GET_CLIENT_REQUEST::cACTION_BML_CLIENT_GET_CLIENT_REQUEST(std::shared_ptr base, bool parse) : +BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ + m_init_succeeded = init(); +} +cACTION_BML_CLIENT_GET_CLIENT_REQUEST::~cACTION_BML_CLIENT_GET_CLIENT_REQUEST() { +} +sMacAddr& cACTION_BML_CLIENT_GET_CLIENT_REQUEST::sta_mac() { + return (sMacAddr&)(*m_sta_mac); +} + +void cACTION_BML_CLIENT_GET_CLIENT_REQUEST::class_swap() +{ + tlvf_swap(8*sizeof(eActionOp_BML), reinterpret_cast(m_action_op)); + m_sta_mac->struct_swap(); +} + +bool cACTION_BML_CLIENT_GET_CLIENT_REQUEST::finalize() +{ + if (m_parse__) { + TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; + return true; + } + if (m_finalized__) { + TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; + return true; + } + if (!isPostInitSucceeded()) { + TLVF_LOG(ERROR) << "post init check failed"; + return false; + } + if (m_inner__) { + if (!m_inner__->finalize()) { + TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; + return false; + } + auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); + m_buff_ptr__ -= tailroom; + } + class_swap(); + m_finalized__ = true; + return true; +} + +size_t cACTION_BML_CLIENT_GET_CLIENT_REQUEST::get_initial_size() +{ + size_t class_size = 0; + class_size += sizeof(sMacAddr); // sta_mac + return class_size; +} + +bool cACTION_BML_CLIENT_GET_CLIENT_REQUEST::init() +{ + if (getBuffRemainingBytes() < get_initial_size()) { + TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; + return false; + } + m_sta_mac = reinterpret_cast(m_buff_ptr__); + if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; + return false; + } + if (!m_parse__) { m_sta_mac->struct_init(); } + if (m_parse__) { class_swap(); } + return true; +} + +cACTION_BML_CLIENT_GET_CLIENT_RESPONSE::cACTION_BML_CLIENT_GET_CLIENT_RESPONSE(uint8_t* buff, size_t buff_len, bool parse) : + BaseClass(buff, buff_len, parse) { + m_init_succeeded = init(); +} +cACTION_BML_CLIENT_GET_CLIENT_RESPONSE::cACTION_BML_CLIENT_GET_CLIENT_RESPONSE(std::shared_ptr base, bool parse) : +BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ + m_init_succeeded = init(); +} +cACTION_BML_CLIENT_GET_CLIENT_RESPONSE::~cACTION_BML_CLIENT_GET_CLIENT_RESPONSE() { +} +uint8_t& cACTION_BML_CLIENT_GET_CLIENT_RESPONSE::result() { + return (uint8_t&)(*m_result); +} + +sClient& cACTION_BML_CLIENT_GET_CLIENT_RESPONSE::client() { + return (sClient&)(*m_client); +} + +void cACTION_BML_CLIENT_GET_CLIENT_RESPONSE::class_swap() +{ + tlvf_swap(8*sizeof(eActionOp_BML), reinterpret_cast(m_action_op)); + m_client->struct_swap(); +} + +bool cACTION_BML_CLIENT_GET_CLIENT_RESPONSE::finalize() +{ + if (m_parse__) { + TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; + return true; + } + if (m_finalized__) { + TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; + return true; + } + if (!isPostInitSucceeded()) { + TLVF_LOG(ERROR) << "post init check failed"; + return false; + } + if (m_inner__) { + if (!m_inner__->finalize()) { + TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; + return false; + } + auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); + m_buff_ptr__ -= tailroom; + } + class_swap(); + m_finalized__ = true; + return true; +} + +size_t cACTION_BML_CLIENT_GET_CLIENT_RESPONSE::get_initial_size() +{ + size_t class_size = 0; + class_size += sizeof(uint8_t); // result + class_size += sizeof(sClient); // client + return class_size; +} + +bool cACTION_BML_CLIENT_GET_CLIENT_RESPONSE::init() +{ + if (getBuffRemainingBytes() < get_initial_size()) { + TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; + return false; + } + m_result = reinterpret_cast(m_buff_ptr__); + if (!buffPtrIncrementSafe(sizeof(uint8_t))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; + return false; + } + m_client = reinterpret_cast(m_buff_ptr__); + if (!buffPtrIncrementSafe(sizeof(sClient))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sClient) << ") Failed!"; + return false; + } + if (!m_parse__) { m_client->struct_init(); } + if (m_parse__) { class_swap(); } + return true; +} + diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index cd9131e57d..2f2127ab25 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -479,4 +479,11 @@ eActionOp_BML: ACTION_BML_CHANNEL_SCAN_DUMP_RESULTS_REQUEST: 212 ACTION_BML_CHANNEL_SCAN_DUMP_RESULTS_RESPONSE: 213 - ACTION_BML_ENUM_END: 214 + ACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST: 215 + ACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE: 216 + ACTION_BML_CLIENT_SET_CLIENT_REQUEST: 217 + ACTION_BML_CLIENT_SET_CLIENT_RESPONSE: 218 + ACTION_BML_CLIENT_GET_CLIENT_REQUEST: 219 + ACTION_BML_CLIENT_GET_CLIENT_RESPONSE: 220 + + ACTION_BML_ENUM_END: 225 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_bml.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_bml.yaml index 065e0d05f6..fe395e82c9 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_bml.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_bml.yaml @@ -492,3 +492,37 @@ cACTION_BML_WIFI_CREDENTIALS_CLEAR_REQUEST: cACTION_BML_WIFI_CREDENTIALS_CLEAR_RESPONSE: _type: class error_code: uint32_t + +cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST: + _type: class + +cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE: + _type: class + client_list_size: + _type: uint32_t + _length_var: True + client_list: + _type: char + _length: [client_list_size] + +cACTION_BML_CLIENT_SET_CLIENT_REQUEST: + _type: class + sta_mac: sMacAddr + client_config: sClientConfig + +cACTION_BML_CLIENT_SET_CLIENT_RESPONSE: + _type: class + result: + _type: uint8_t + _comment: # 0 - Failure, 1 - Success + +cACTION_BML_CLIENT_GET_CLIENT_REQUEST: + _type: class + sta_mac: sMacAddr + +cACTION_BML_CLIENT_GET_CLIENT_RESPONSE: + _type: class + result: + _type: uint8_t + _comment: # 0 - Failure, 1 - Success + client: sClient diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml index d9a4bb60c3..f93e34a4b4 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml @@ -989,3 +989,59 @@ sBssidInfo: downlink_estimated_mac_data_rate_mbps: uint32_t uplink_estimated_mac_data_rate_mbps: uint32_t sta_measured_uplink_rssi_dbm_enc: uint8_t + +eClientSelectedBands: + _type: enum + _enum_storage: uint8_t + eSelectedBands_Disabled: 0 + eSelectedBands_24G: 1 + eSelectedBands_5G: 2 + eSelectedBands_6G: 4 + eSelectedBands_60G: 8 + +sClientConfig: + _type: struct + stay_on_initial_radio: + _type: int8_t + _value: -1 + _comment: 1 for true, 0 for false, -1 for "not configured". + stay_on_selected_device: + _type: int8_t + _value: -1 + _comment: 1 for true, 0 for false, -1 for "not configured". + selected_bands: + _type: int8_t + _comment: Bitset of selected bands supported by the client according to eClientSelectedBands + +sClient: + _type: struct + sta_mac: + _type: sMacAddr + _comment: Client MAC + timestamp_sec: + _type: uint32_t + _value: 0 + _comment: Time of last client configuration edit (in Seconds) + stay_on_initial_radio: + _type: int8_t + _value: -1 + _comment: 1 for true, 0 for false, -1 for "not configured". + stay_on_selected_device: + _type: int8_t + _value: -1 + _comment: 1 for true, 0 for false, -1 for "not configured". + selected_bands: + _type: int8_t + _comment: Bitset of selected bands supported by the client according to eClientSelectedBands + single_band: + _type: int8_t + _value: -1 + _comment: 1 for true, 0 for false, -1 for "not configured". + time_life_delay_days: + _type: int32_t + _value: -1 + _comment: | + Optional parameter, + Determines the period of time after which the client configuration should be cleared, + 0 - Never age. + -1 - Not Configured. From e50b4236949b65b18efddfcc46e99b55216958a1 Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Thu, 25 Jun 2020 08:04:09 +0000 Subject: [PATCH 235/453] controller: bml: add client smart-steering APIs This commit introduces the BML APIs for the smart-steering feature which allows a user to configure a client's steering behavior. Add BML API to get list of configured clients. Add BML client set and get APIs. Add BML-internal implementation Relates to JIRA PPM-5 Signed-off-by: itay elenzweig --- controller/src/beerocks/bml/bml.cpp | 45 ++++ controller/src/beerocks/bml/bml.h | 31 +++ .../beerocks/bml/internal/bml_internal.cpp | 224 ++++++++++++++++++ .../src/beerocks/bml/internal/bml_internal.h | 33 +++ 4 files changed, 333 insertions(+) diff --git a/controller/src/beerocks/bml/bml.cpp b/controller/src/beerocks/bml/bml.cpp index ca5b9a5e33..d0094e8859 100644 --- a/controller/src/beerocks/bml/bml.cpp +++ b/controller/src/beerocks/bml/bml.cpp @@ -709,3 +709,48 @@ int bml_start_dcs_single_scan(BML_CTX ctx, const char *radio_mac, int dwell_time return pBML->start_dcs_single_scan(tlvf::mac_from_string(std::string(radio_mac)), dwell_time, channel_pool, channel_pool_size); } + +int bml_client_get_client_list(BML_CTX ctx, char *client_list, unsigned int *client_list_size) +{ + // Validate input parameters + if (!ctx || !client_list || !client_list_size) { + return (-BML_RET_INVALID_ARGS); + } + + if (*client_list_size == 0) { + return (-BML_RET_INVALID_ARGS); + } + + auto pBML = static_cast(ctx); + std::string temp_client_list; + int ret = pBML->client_get_client_list(temp_client_list, client_list_size); + if (ret == BML_RET_OK) { + beerocks::string_utils::copy_string(client_list, temp_client_list.c_str(), + *client_list_size); + } + + return ret; +} + +int bml_client_set_client(BML_CTX ctx, const char *sta_mac, + const struct BML_CLIENT_CONFIG *client_config) +{ + // Validate input parameters + if (!ctx || !sta_mac || !client_config) { + return (-BML_RET_INVALID_ARGS); + } + + auto pBML = static_cast(ctx); + return pBML->client_set_client(tlvf::mac_from_string(std::string(sta_mac)), *client_config); +} + +int bml_client_get_client(BML_CTX ctx, const char *sta_mac, struct BML_CLIENT *client) +{ + // Validate input parameters + if (!ctx || !sta_mac || !client) { + return (-BML_RET_INVALID_ARGS); + } + + auto pBML = static_cast(ctx); + return pBML->client_get_client(tlvf::mac_from_string(std::string(sta_mac)), client); +} diff --git a/controller/src/beerocks/bml/bml.h b/controller/src/beerocks/bml/bml.h index 344c6a09d7..fa62ad23be 100644 --- a/controller/src/beerocks/bml/bml.h +++ b/controller/src/beerocks/bml/bml.h @@ -648,6 +648,37 @@ int bml_get_dcs_scan_results(BML_CTX ctx, const char *radio_mac, int bml_start_dcs_single_scan(BML_CTX ctx, const char *radio_mac, int dwell_time_ms, int channel_pool_size, unsigned int *channel_pool); +/** + * Get client list. + * + * @param [in] ctx BML Context. + * @param [in,out] client_list List of MAC addresses sepereted by a comma. + * @param [in,out] client_list_size Size of client list. + * @return BML_RET_OK on success. + */ +int bml_client_get_client_list(BML_CTX ctx, char *client_list, unsigned int *client_list_size); + +/** + * Set client configuration. + * + * @param [in] ctx BML Context. + * @param [in] sta_mac MAC address of a station. + * @param [in] client_config Client configuration to be set. + * @return BML_RET_OK on success. + */ +int bml_client_set_client(BML_CTX ctx, const char *sta_mac, + const struct BML_CLIENT_CONFIG *client_config); + +/** + * Get client info. + * + * @param [in] ctx BML Context. + * @param [in] sta_mac MAC address of a station. + * @param [in,out] client Client information. + * @return BML_RET_OK on success. + */ +int bml_client_get_client(BML_CTX ctx, const char *sta_mac, struct BML_CLIENT *client); + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/controller/src/beerocks/bml/internal/bml_internal.cpp b/controller/src/beerocks/bml/internal/bml_internal.cpp index f235226bbe..bcb2e3c052 100644 --- a/controller/src/beerocks/bml/internal/bml_internal.cpp +++ b/controller/src/beerocks/bml/internal/bml_internal.cpp @@ -1128,6 +1128,79 @@ int bml_internal::process_cmdu_header(std::shared_ptr beerocks_ << " response, but no one is waiting..."; } } break; + case beerocks_message::ACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE: { + LOG(DEBUG) << "ACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE received"; + auto response = + beerocks_header + ->addClass(); + if (!response) { + LOG(ERROR) << "addClass cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE failed"; + return BML_RET_OP_FAILED; + } + + //Signal any waiting threads + if (m_prmClientListGet) { + bool promise_result = false; + if (m_client_list && m_client_list_size) { + *m_client_list_size = *m_client_list_size <= response->client_list_size() + ? response->client_list_size() + : *m_client_list_size; + *m_client_list = response->client_list_str(); + promise_result = true; + } + m_prmClientListGet->set_value(promise_result); + } else { + LOG(WARNING) << "Received ACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE response, " + << "but no one is waiting..."; + } + } break; + case beerocks_message::ACTION_BML_CLIENT_SET_CLIENT_RESPONSE: { + LOG(DEBUG) << "ACTION_BML_CLIENT_SET_CLIENT_RESPONSE received"; + auto response = + beerocks_header + ->addClass(); + if (!response) { + LOG(ERROR) << "addClass cACTION_BML_CLIENT_SET_CLIENT_RESPONSE failed"; + return BML_RET_OP_FAILED; + } + + ///Signal any waiting threads + if (!wake_up(beerocks_message::ACTION_BML_CLIENT_SET_CLIENT_REQUEST, + response->result())) { + LOG(WARNING) << "Received ACTION_BML_CLIENT_SET_CLIENT_RESPONSE" + << " response, but no one is waiting..."; + } + } break; + case beerocks_message::ACTION_BML_CLIENT_GET_CLIENT_RESPONSE: { + LOG(DEBUG) << "ACTION_BML_CLIENT_GET_CLIENT_RESPONSE received"; + auto response = + beerocks_header + ->addClass(); + if (!response) { + LOG(ERROR) << "addClass cACTION_BML_CLIENT_GET_CLIENT_RESPONSE failed"; + return BML_RET_OP_FAILED; + } + + //Signal any waiting threads + if (m_prmClientGet) { + bool promise_result = false; + if (m_client) { + std::copy_n(response->client().sta_mac.oct, BML_MAC_ADDR_LEN, + m_client->sta_mac); + m_client->timestamp_sec = response->client().timestamp_sec; + m_client->stay_on_initial_radio = response->client().stay_on_initial_radio; + m_client->stay_on_selected_device = response->client().stay_on_selected_device; + m_client->selected_bands = response->client().selected_bands; + m_client->time_life_delay_days = response->client().time_life_delay_days; + //Resolve promise to "true" + promise_result = true; + } + m_prmClientGet->set_value(promise_result); + } else { + LOG(WARNING) << "Received ACTION_BML_CLIENT_GET_CLIENT_RESPONSE response, " + << "but no one is waiting..."; + } + } break; default: { LOG(WARNING) << "unhandled header BML action type 0x" << std::hex << int(beerocks_header->action_op()); @@ -1767,6 +1840,157 @@ int bml_internal::start_dcs_single_scan(const sMacAddr &mac, int dwell_time_ms, return BML_RET_OK; } +int bml_internal::client_get_client_list(std::string &client_list, unsigned int *client_list_size) +{ + LOG(DEBUG) << "client_get_client_list"; + + if (!client_list_size) { + LOG(ERROR) << "Size param must be initialized"; + return (-BML_RET_INVALID_DATA); + } + + // If the socket is not valid, attempt to re-establish the connection + if (!m_sockMaster) { + int iRet = connect_to_master(); + if (iRet != BML_RET_OK) { + LOG(ERROR) << " Unable to create context, connect_to_master failed!"; + return iRet; + } + } + + // Initialize the promise for receiving the response + beerocks::promise prmClientListGet; + m_prmClientListGet = &prmClientListGet; + int iOpTimeout = RESPONSE_TIMEOUT; // Default timeout + m_client_list = &client_list; + m_client_list_size = client_list_size; + + auto request = message_com::create_vs_message< + beerocks_message::cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST>(cmdu_tx); + + if (!request) { + LOG(ERROR) << "Failed building cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST message!"; + return (-BML_RET_OP_FAILED); + } + + // Build and send the message + if (!message_com::send_cmdu(m_sockMaster, cmdu_tx)) { + LOG(ERROR) << "Failed sending param get message!"; + m_prmClientListGet = nullptr; + m_client_list = nullptr; + m_client_list_size = nullptr; + return (-BML_RET_OP_FAILED); + } + LOG(DEBUG) << "cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST sent"; + + int iRet = BML_RET_OK; + + if (!m_prmClientListGet->wait_for(iOpTimeout)) { + LOG(WARNING) << "Timeout while waiting for client list get response..."; + iRet = -BML_RET_TIMEOUT; + } + + // Clear the get client list members + m_client_list = nullptr; + m_client_list_size = nullptr; + + // Clear the promise holder + m_prmClientListGet = nullptr; + + LOG_IF(iRet != BML_RET_OK, ERROR) + << "Get client list request returned with error code:" << iRet; + + return BML_RET_OK; +} + +int bml_internal::client_set_client(const sMacAddr &sta_mac, const BML_CLIENT_CONFIG &client_config) +{ + LOG(DEBUG) << "client_set_client"; + + auto request = + message_com::create_vs_message( + cmdu_tx); + + if (!request) { + LOG(ERROR) << "Failed building cACTION_BML_CLIENT_SET_CLIENT_REQUEST message!"; + return (-BML_RET_OP_FAILED); + } + + request->sta_mac() = sta_mac; + request->client_config().stay_on_initial_radio = client_config.stay_on_initial_radio; + request->client_config().stay_on_selected_device = client_config.stay_on_selected_device; + request->client_config().selected_bands = client_config.selected_bands; + + int result = 0; + if (send_bml_cmdu(result, request->get_action_op()) != BML_RET_OK) { + LOG(ERROR) << "Send cACTION_BML_CLIENT_SET_CLIENT_REQUEST failed"; + return (-BML_RET_OP_FAILED); + } + + if (result != 0) { + LOG(ERROR) << "Set client request returned error code:" << result; + return result; + } + + return BML_RET_OK; +} + +int bml_internal::client_get_client(const sMacAddr &sta_mac, BML_CLIENT *client) +{ + LOG(DEBUG) << "client_get_client"; + + // If the socket is not valid, attempt to re-establish the connection + if (!m_sockMaster) { + int iRet = connect_to_master(); + if (iRet != BML_RET_OK) { + LOG(ERROR) << " Unable to create context, connect_to_master failed!"; + return iRet; + } + } + + // Initialize the promise for receiving the response + beerocks::promise prmClientGet; + m_prmClientGet = &prmClientGet; + int iOpTimeout = RESPONSE_TIMEOUT; // Default timeout + m_client = client; + + auto request = + message_com::create_vs_message( + cmdu_tx); + + if (!request) { + LOG(ERROR) << "Failed building cACTION_BML_CLIENT_GET_CLIENT_REQUEST message!"; + return (-BML_RET_OP_FAILED); + } + + request->sta_mac() = sta_mac; + // Build and send the message + if (!message_com::send_cmdu(m_sockMaster, cmdu_tx)) { + LOG(ERROR) << "Failed sending param get message!"; + m_prmClientGet = nullptr; + m_client = nullptr; + return (-BML_RET_OP_FAILED); + } + LOG(DEBUG) << "cACTION_BML_CLIENT_GET_CLIENT_REQUEST sent"; + + int iRet = BML_RET_OK; + + if (!m_prmClientGet->wait_for(iOpTimeout)) { + LOG(WARNING) << "Timeout while waiting for client get response..."; + iRet = -BML_RET_TIMEOUT; + } + + // Clear the get client members + m_client = nullptr; + + // Clear the promise holder + m_prmClientGet = nullptr; + + LOG_IF(iRet != BML_RET_OK, ERROR) << "Get client request returned with error code:" << iRet; + + return BML_RET_OK; +} + int bml_internal::ping() { // Command supported only on local master diff --git a/controller/src/beerocks/bml/internal/bml_internal.h b/controller/src/beerocks/bml/internal/bml_internal.h index 3fda3860f0..06124416c9 100644 --- a/controller/src/beerocks/bml/internal/bml_internal.h +++ b/controller/src/beerocks/bml/internal/bml_internal.h @@ -263,6 +263,34 @@ class bml_internal : public beerocks::socket_thread { */ int start_dcs_single_scan(const sMacAddr &mac, int dwell_time_ms, unsigned int *channel_pool, int channel_pool_size); + + /** + * Get client list. + * + * @param [in,out] client_list List of MAC addresses sepereted by a comma. + * @param [in,out] client_list_size Size of client list. + * @return BML_RET_OK on success. + */ + int client_get_client_list(std::string &client_list, unsigned int *client_list_size); + + /** + * Set client configuration. + * + * @param [in] sta_mac MAC address of a station. + * @param [in] client_config Client configuration to be set. + * @return BML_RET_OK on success. + */ + int client_set_client(const sMacAddr &sta_mac, const BML_CLIENT_CONFIG &client_config); + + /** + * Get client info. + * + * @param [in] sta_mac MAC address of a station. + * @param [in,out] client Client information. + * @return BML_RET_OK on success. + */ + int client_get_client(const sMacAddr &sta_mac, BML_CLIENT *client); + /* * Public static methods: */ @@ -334,6 +362,8 @@ class bml_internal : public beerocks::socket_thread { beerocks::promise *m_prmChannelScanParamsGet = nullptr; //Promise used to indicate the GetResults response was received beerocks::promise *m_prmChannelScanResultsGet = nullptr; + beerocks::promise *m_prmClientListGet = nullptr; + beerocks::promise *m_prmClientGet = nullptr; std::map *> m_prmCliResponses; @@ -357,6 +387,9 @@ class bml_internal : public beerocks::socket_thread { uint8_t *m_scan_results_status = nullptr; //m_scan_results_maxsize is used to indicate the maximum capacity of the requested results uint32_t *m_scan_results_maxsize = nullptr; + std::string *m_client_list = nullptr; + uint32_t *m_client_list_size = nullptr; + BML_CLIENT *m_client = nullptr; BML_VAP_INFO *m_vaps = nullptr; uint8_t *m_pvaps_list_size = nullptr; uint16_t id = 0; From 03f095b07f87f77e6459057751bb0aac0fec49b8 Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Wed, 24 Jun 2020 15:53:58 +0000 Subject: [PATCH 236/453] son_management: add client smart-steering support Added BML client requests handling stubs to the son_management. Response messages are filled with default values. Integration to the controller DB will be handled in a separate PR. Relates to JIRA PPM-5 Signed-off-by: Itay Elenzweig --- .../src/beerocks/master/son_management.cpp | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/controller/src/beerocks/master/son_management.cpp b/controller/src/beerocks/master/son_management.cpp index 657678414e..a6aee2a626 100644 --- a/controller/src/beerocks/master/son_management.cpp +++ b/controller/src/beerocks/master/son_management.cpp @@ -2308,6 +2308,91 @@ void son_management::handle_bml_message(Socket *sd, LOG(TRACE) << "ACTION_BML_CHANNEL_SCAN_DUMP_RESULTS_REQUEST"; break; } + case beerocks_message::ACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST: { + LOG(TRACE) << "ACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST"; + + auto request = + beerocks_header + ->addClass(); + if (!request) { + LOG(ERROR) << "addClass cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST failed"; + break; + } + + auto response = message_com::create_vs_message< + beerocks_message::cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE>(cmdu_tx); + if (!response) { + LOG(ERROR) << "Failed building message " + "cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE !"; + break; + } + + std::string client_list = ""; + // TODO: replace empty string with a list of configured clients read from controller-db + if (!response->alloc_client_list(client_list.size())) { + LOG(ERROR) << "Failed client_list allocation to size=" << client_list.size(); + break; + } + response->set_client_list(client_list); + + message_com::send_cmdu(sd, cmdu_tx); + break; + } + case beerocks_message::ACTION_BML_CLIENT_SET_CLIENT_REQUEST: { + LOG(TRACE) << "ACTION_BML_CLIENT_SET_CLIENT_REQUEST"; + + auto request = + beerocks_header->addClass(); + if (!request) { + LOG(ERROR) << "addClass cACTION_BML_CLIENT_SET_CLIENT_REQUEST failed"; + break; + } + + auto response = message_com::create_vs_message< + beerocks_message::cACTION_BML_CLIENT_SET_CLIENT_RESPONSE>(cmdu_tx); + if (!response) { + LOG(ERROR) << "Failed building message " + "cACTION_BML_CLIENT_SET_CLIENT_RESPONSE !"; + break; + } + + //TODO: add client to persistent DB if required and set client parameters + response->result() = 0; //Success. + + message_com::send_cmdu(sd, cmdu_tx); + break; + } + case beerocks_message::ACTION_BML_CLIENT_GET_CLIENT_REQUEST: { + LOG(TRACE) << "ACTION_BML_CLIENT_GET_CLIENT_REQUEST"; + + auto request = + beerocks_header->addClass(); + if (!request) { + LOG(ERROR) << "addClass cACTION_BML_CLIENT_GET_CLIENT_REQUEST failed"; + break; + } + + auto response = message_com::create_vs_message< + beerocks_message::cACTION_BML_CLIENT_GET_CLIENT_RESPONSE>(cmdu_tx); + if (!response) { + LOG(ERROR) << "Failed building message " + "cACTION_BML_CLIENT_GET_CLIENT_RESPONSE !"; + break; + } + + //TODO: fill client information from controller DB + response->client().sta_mac = request->sta_mac(); + response->client().timestamp_sec = 0; + response->client().stay_on_initial_radio = PARAMETER_NOT_CONFIGURED; + response->client().stay_on_selected_device = PARAMETER_NOT_CONFIGURED; + response->client().selected_bands = eClientSelectedBands::eSelectedBands_Disabled; + response->client().single_band = PARAMETER_NOT_CONFIGURED; + response->client().time_life_delay_days = PARAMETER_NOT_CONFIGURED; + response->result() = 0; //Success. + + message_com::send_cmdu(sd, cmdu_tx); + break; + } default: { LOG(ERROR) << "Unsupported BML action_op:" << int(beerocks_header->action_op()); break; From 479f00f9d2ce1c862d1812403c5ab53515d724b4 Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Sun, 28 Jun 2020 11:59:46 +0000 Subject: [PATCH 237/453] beerocks_cli: add smart-steering client APIs. Add BML CLI functions for the smart-steering APIs: bml_client_get_client_list - Retrieve full client list. bml_client_set_client - Update client by STA MAC. bml_client_get_client - Retrieve client by STA MAC. Relates to JIRA PPM-5 Signed-off-by: itay elenzweig --- .../src/beerocks/cli/beerocks_cli_bml.cpp | 195 ++++++++++++++++++ .../src/beerocks/cli/beerocks_cli_bml.h | 7 + 2 files changed, 202 insertions(+) diff --git a/controller/src/beerocks/cli/beerocks_cli_bml.cpp b/controller/src/beerocks/cli/beerocks_cli_bml.cpp index efe45117e6..2ae4084a5b 100644 --- a/controller/src/beerocks/cli/beerocks_cli_bml.cpp +++ b/controller/src/beerocks/cli/beerocks_cli_bml.cpp @@ -557,6 +557,19 @@ void cli_bml::setFunctionsMapAndArray() " is-single-scan - 0 for continuous-scan results (default), 1 for single scan.", static_cast(&cli_bml::get_dcs_scan_results_caller), 2, 3, STRING_ARG, INT_ARG, INT_ARG); + insertCommandToMap("bml_client_get_client_list", "", "Get client list.", + static_cast(&cli_bml::client_get_client_list_caller), 0, 0); + insertCommandToMap( + "bml_client_set_client", " []", + "Set client with the given STA MAC:" + " selected_bands - Bitwise parameter, 1 for 2.4G, 2 for 5G, 3 for both, 0 for Disabled" + " stay_on_initial_radio - 1 for true, 0 for false or (default) -1 for not configured," + " stay_on_selected_device - 1 for true, 0 for false or (default) -1 for not configured", + static_cast(&cli_bml::client_set_client_caller), 2, 4, STRING_ARG, INT_ARG, + INT_ARG, INT_ARG); + insertCommandToMap("bml_client_get_client", "", "Get client with the given STA MAC.", + static_cast(&cli_bml::client_get_client_caller), 1, 1, + STRING_ARG); //bool insertCommandToMap(std::string command, std::string help_args, std::string help, pFunction funcPtr, uint8_t minNumOfArgs, uint8_t maxNumOfArgs, } @@ -1307,6 +1320,78 @@ int cli_bml::get_dcs_scan_results_caller(int numOfArgs) return -1; } +/** + * Caller function for client_get_client_list_caller. + * + * @param [in] numOfArgs Number of received arguments + * @return 0 on success. + */ +int cli_bml::client_get_client_list_caller(int numOfArgs) +{ + if (numOfArgs == 0) { + return client_get_client_list(); + } + return -1; +} + +/** + * Caller function for client_set_client_caller. + * + * @param [in] numOfArgs Number of received arguments + * @return 0 on success. + */ +int cli_bml::client_set_client_caller(int numOfArgs) +{ + + /* + * Mandatory: + * sta_mac= + * Optional: + * selected_bands= + * stay_on_initial_radio= + * stay_on_selected_device= + ]*/ + std::string::size_type pos; + std::string sta_mac(network_utils::WILD_MAC_STRING); + int8_t selected_bands = BML_PARAMETER_NOT_CONFIGURED; + int8_t stay_on_initial_radio = BML_PARAMETER_NOT_CONFIGURED; + int8_t stay_on_selected_device = BML_PARAMETER_NOT_CONFIGURED; + if (numOfArgs > 1) { + sta_mac = args.stringArgs[0]; + for (int i = 1; i < numOfArgs; i++) { //first optional arg + if ((pos = args.stringArgs[i].find("selected_bands=")) != std::string::npos) { + selected_bands = beerocks::string_utils::stoi( + args.stringArgs[i].substr(pos + sizeof("selected_bands"))); + } else if ((pos = args.stringArgs[i].find("stay_on_initial_radio=")) != + std::string::npos) { + stay_on_initial_radio = string_utils::stoi( + args.stringArgs[i].substr(pos + sizeof("stay_on_initial_radio"))); + } else if ((pos = args.stringArgs[i].find("stay_on_selected_device=")) != + std::string::npos) { + stay_on_selected_device = string_utils::stoi( + args.stringArgs[i].substr(pos + sizeof("stay_on_selected_device"))); + } + } + return client_set_client(sta_mac, selected_bands, stay_on_initial_radio, + stay_on_selected_device); + } + return -1; +} + +/** + * Caller function for client_get_client_caller. + * + * @param [in] numOfArgs Number of received arguments + * @return 0 on success. + */ +int cli_bml::client_get_client_caller(int numOfArgs) +{ + if (numOfArgs == 1) { + return client_get_client(args.stringArgs[0]); + } + return -1; +} + // // Functions // @@ -2144,6 +2229,116 @@ int cli_bml::get_dcs_scan_results(const std::string &radio_mac, uint32_t max_res return 0; } +/** + * get all client list. + * + * @return 0 on success. + */ +int cli_bml::client_get_client_list() +{ + char client_list[256]; + unsigned int client_list_size; + + int ret = bml_client_get_client_list(ctx, client_list, &client_list_size); + auto client_list_vec = + beerocks::string_utils::str_split(std::string(client_list, client_list_size), ','); + + std::cout << "client list:" << std::endl; + for (const auto &client : client_list_vec) { + std::cout << "- " << client << std::endl; + } + + printBmlReturnVals("bml_client_get_client_list", ret); + + return 0; +} + +/** + * Set specific client according to MAC. + * + * @param [in] sta_mac MAC address of requested client. + * @param [in] selected_bands comma-seperated selected bands. + * @param [in] stay_on_initial_radio Whather to stay on initial radio or not. + * @param [in] stay_on_selected_device Whather to stay on selected device or not. + * @return 0 on success. + */ +int cli_bml::client_set_client(const std::string &sta_mac, int8_t selected_bands, + int8_t stay_on_initial_radio, int8_t stay_on_selected_device) +{ + std::cout << "client_set_client: " << std::endl + << " sta_mac: " << sta_mac << std::endl + << " selected_bands: " << selected_bands << std::endl + << " stay_on_initial_radio: " << stay_on_initial_radio << std::endl + << " stay_on_selected_device: " << stay_on_selected_device << std::endl; + + BML_CLIENT_CONFIG cfg{ + .stay_on_initial_radio = stay_on_initial_radio, + .stay_on_selected_device = stay_on_selected_device, + .selected_bands = selected_bands, + }; + + int ret = bml_client_set_client(ctx, sta_mac.c_str(), &cfg); + + printBmlReturnVals("bml_client_set_client", ret); + + return 0; +} + +/** + * get specific client according to MAC. + * + * @param [in] sta_mac MAC address of requested client + * + * @return 0 on success. + */ +int cli_bml::client_get_client(const std::string &sta_mac) +{ + BML_CLIENT client; + int ret = bml_client_get_client(ctx, sta_mac.c_str(), &client); + + if (ret == BML_RET_OK) { + auto client_bool_print = [](int8_t val) -> std::string { + if (val == BML_PARAMETER_NOT_CONFIGURED) + return "Not configured"; + return val ? "True" : "False"; + }; + auto client_selected_bands_print = [](int8_t val) -> std::string { + std::string ret = ""; + if (val == BML_CLIENT_SELECTED_BANDS_DISABLED) + return "Disabled"; + if (val & BML_CLIENT_SELECTED_BANDS_24G) + ret += "2.4 Ghz,"; + if (val & BML_CLIENT_SELECTED_BANDS_5G) + ret += "5 Ghz,"; + if (val & BML_CLIENT_SELECTED_BANDS_6G) + ret += "6 Ghz,"; + if (val & BML_CLIENT_SELECTED_BANDS_60G) + ret += "60 Ghz,"; + + // remove ending comma + if (!ret.empty() && (ret.back() == ',')) { + ret.pop_back(); + } + + return ret; + }; + std::cout << "client: " << client.sta_mac << std::endl + << " timestamp_sec: " << client.timestamp_sec << std::endl + << " stay_on_initial_radio: " << client_bool_print(client.stay_on_initial_radio) + << std::endl + << " stay_on_selected_device: " + << client_bool_print(client.stay_on_selected_device) << std::endl + << " selected_bands: " << client_selected_bands_print(client.selected_bands) + << std::endl + << " single_band: " << client_bool_print(client.single_band) << std::endl + << " time_life_delay_days:" << client.time_life_delay_days << std::endl; + } + + printBmlReturnVals("bml_client_get_client", ret); + + return 0; +} + template const std::string cli_bml::string_from_int_array(T *arr, size_t arr_max_size) { std::stringstream ss; diff --git a/controller/src/beerocks/cli/beerocks_cli_bml.h b/controller/src/beerocks/cli/beerocks_cli_bml.h index 00434dc188..26d3684617 100644 --- a/controller/src/beerocks/cli/beerocks_cli_bml.h +++ b/controller/src/beerocks/cli/beerocks_cli_bml.h @@ -150,6 +150,9 @@ class cli_bml : public cli { int get_dcs_continuous_scan_params_caller(int numOfArgs); int start_dcs_single_scan_caller(int numOfArgs); int get_dcs_scan_results_caller(int numOfArgs); + int client_get_client_list_caller(int numOfArgs); + int client_set_client_caller(int numOfArgs); + int client_get_client_caller(int numOfArgs); // Functions int onboard_status(); int ping(); @@ -214,6 +217,10 @@ class cli_bml : public cli { const std::string &channel_pool); int get_dcs_scan_results(const std::string &radio_mac, uint32_t max_results_size, bool is_single_scan = false); + int client_get_client_list(); + int client_set_client(const std::string &sta_mac, int8_t selected_bands, + int8_t stay_on_initial_radio, int8_t stay_on_selected_device); + int client_get_client(const std::string &sta_mac); template const std::string string_from_int_array(T *arr, size_t arr_max_size); // Variable std::string beerocks_conf_path; From 32bfbe310ff0d025c30a03ef24ff289ef4845b0e Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 14 Jul 2020 17:32:15 +0300 Subject: [PATCH 238/453] common: bwl: Fix building nl80211 for linux For fixing build nl80211 fir linux platform need to create new variable NEEDS_HOSTAPD_PATH and add condition for linux platform. NEEDS_HOSTAPD_PATH variable should be true when it is build for rdkb, ugw, openwrt and linux. For dummy it should be turned off. Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/CMakeLists.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/common/beerocks/bwl/CMakeLists.txt b/common/beerocks/bwl/CMakeLists.txt index 125f8eb0ce..7ec702efad 100644 --- a/common/beerocks/bwl/CMakeLists.txt +++ b/common/beerocks/bwl/CMakeLists.txt @@ -28,11 +28,6 @@ elseif(TARGET_PLATFORM STREQUAL "openwrt") set(BWL_TYPE "NL80211") endif() - # hostapd directory - file(GLOB HOSTAPD_SEARCH_PATHS "${PLATFORM_BUILD_DIR}/hostapd*/hostapd-*") - find_path(HOSTAPD_INCLUDE_DIR NAMES "src/common/wpa_ctrl.h" PATHS ${HOSTAPD_SEARCH_PATHS} NO_CMAKE_FIND_ROOT_PATH) - set(HOSTAPD_DIR "${HOSTAPD_INCLUDE_DIR}") - endif() set(BWL_TYPE ${BWL_TYPE} CACHE STRING "Which BWL backend to use") @@ -43,6 +38,10 @@ set(BWL_TYPE ${BWL_TYPE} CACHE STRING "Which BWL backend to use") if(BWL_TYPE STREQUAL "DWPAL") + file(GLOB HOSTAPD_SEARCH_PATHS "${PLATFORM_BUILD_DIR}/hostapd*/hostapd-*") + find_path(HOSTAPD_INCLUDE_DIR NAMES "src/common/wpa_ctrl.h" PATHS ${HOSTAPD_SEARCH_PATHS} NO_CMAKE_FIND_ROOT_PATH) + set(HOSTAPD_DIR "${HOSTAPD_INCLUDE_DIR}") + include_directories( ${HOSTAPD_DIR}/src/drivers ${PLATFORM_BUILD_DIR}/iwlwav-iw-4.14 @@ -76,6 +75,10 @@ if(BWL_TYPE STREQUAL "DWPAL") elseif(BWL_TYPE STREQUAL "NL80211") + file(GLOB HOSTAPD_SEARCH_PATHS "${PLATFORM_BUILD_DIR}/hostapd*/hostapd-*") + find_path(HOSTAPD_INCLUDE_DIR NAMES "src/common/wpa_ctrl.h" PATHS ${HOSTAPD_SEARCH_PATHS} NO_CMAKE_FIND_ROOT_PATH) + set(HOSTAPD_DIR "${HOSTAPD_INCLUDE_DIR}") + find_package(nl-genl-3 REQUIRED) list(APPEND BWL_LIBS nl-genl-3) From 4c484600a200f0dd6e571c4d00fe3bf02c1236ca Mon Sep 17 00:00:00 2001 From: Ran Regev Date: Thu, 25 Jun 2020 16:08:33 +0300 Subject: [PATCH 239/453] tests: gate unit test: added google test Added google tests to check gate::load functionality 1905->vs: beacon query. vs->1905: beacon response. Added unit_tests directory and changed cmake accordingly Signed-off-by: Ran Regev --- agent/src/beerocks/slave/CMakeLists.txt | 31 +++ .../slave/gate/unit_tests/gate_test.cpp | 191 ++++++++++++++++++ 2 files changed, 222 insertions(+) create mode 100644 agent/src/beerocks/slave/gate/unit_tests/gate_test.cpp diff --git a/agent/src/beerocks/slave/CMakeLists.txt b/agent/src/beerocks/slave/CMakeLists.txt index 98cf8b686d..dec96a8420 100644 --- a/agent/src/beerocks/slave/CMakeLists.txt +++ b/agent/src/beerocks/slave/CMakeLists.txt @@ -35,3 +35,34 @@ target_link_libraries(${PROJECT_NAME} rt dl bcl btl tlvf elpp btlvf bwl bpl ${LI # Install install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) + +# Tests +if (BUILD_TESTS) + set(TEST_PROJECT_NAME ${PROJECT_NAME}_unit_tests) + set(unit_tests_sources + gate/unit_tests/gate_test.cpp + ${MODULE_PATH}/gate/1905_beacon_query_to_vs.cpp + ${MODULE_PATH}/gate/vs_beacon_response_to_1905.cpp + ) + add_executable(${TEST_PROJECT_NAME} + ${unit_tests_sources} + ) + if (COVERAGE) + set_target_properties(${TEST_PROJECT_NAME} PROPERTIES COMPILE_FLAGS "--coverage -fPIC -O0") + set_target_properties(${TEST_PROJECT_NAME} PROPERTIES LINK_FLAGS "--coverage") + endif() + target_include_directories(${TEST_PROJECT_NAME} + PRIVATE + ${PLATFORM_INCLUDE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/gate + PUBLIC + $ + ) + target_link_libraries(${TEST_PROJECT_NAME} btlvf tlvf mapfcommon) + target_link_libraries(${TEST_PROJECT_NAME} gtest_main) + install(TARGETS ${TEST_PROJECT_NAME} DESTINATION bin/tests) + add_test(NAME ${TEST_PROJECT_NAME} COMMAND $) +endif() + + + diff --git a/agent/src/beerocks/slave/gate/unit_tests/gate_test.cpp b/agent/src/beerocks/slave/gate/unit_tests/gate_test.cpp new file mode 100644 index 0000000000..d399d0f0c2 --- /dev/null +++ b/agent/src/beerocks/slave/gate/unit_tests/gate_test.cpp @@ -0,0 +1,191 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include "1905_beacon_query_to_vs.h" +#include "vs_beacon_response_to_1905.h" +#include +#include +#include + +#include + +namespace { + +/////// 1905 --> vs //////////////////////////////////////////////////////////////////////////////////// + +/** +* const values to be used for both assignment and test +*/ + +const auto associated_sta_mac_1 = sMacAddr{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}; +const uint8_t operating_class = 0x73; +const uint8_t channel_number = 255; +const uint8_t channel_1 = 46; +const uint8_t channel_2 = 31; + +/** +* helper function to fill 1905 values +*/ +static bool set_1905_values(ieee1905_1::CmduMessageTx &cmdu1905) +{ + auto beacon_metrics_query = cmdu1905.getClass(); + if (!beacon_metrics_query) { + return false; + } + + // fill some values + beacon_metrics_query->associated_sta_mac() = associated_sta_mac_1; + beacon_metrics_query->operating_class() = operating_class; + // for ap channel report list, this must be set to 255 + beacon_metrics_query->channel_number() = channel_number; + + auto ap_channel_list = beacon_metrics_query->create_ap_channel_reports_list(); + if (!ap_channel_list) { + return false; + } + + ap_channel_list->alloc_ap_channel_report_list(3); + // the first is operating class, which is currently ignored system wide + *ap_channel_list->ap_channel_report_list(0) = operating_class; + *ap_channel_list->ap_channel_report_list(1) = channel_1; + *ap_channel_list->ap_channel_report_list(2) = channel_2; + + beacon_metrics_query->add_ap_channel_reports_list(ap_channel_list); + + return true; +} + +TEST(gate_beacon_query_test, loading_vs_from_1905_beacon_query) +{ + // preperation for beerocks + + // class list + + constexpr uint16_t buf_size_beerocks = 10000; // just an arbitrary size + uint8_t buff_beerocks[buf_size_beerocks]; + ClassList cl(buff_beerocks, buf_size_beerocks); + + // beerocks + auto added_class_vs = + cl.addClass(); + + EXPECT_NE(added_class_vs, nullptr); + + auto beerocks = cl.getClass(); + + EXPECT_NE(beerocks, nullptr); + + // build 1905 message whthin a Tx message + + // construct a Tx message with beacon metrics query + constexpr uint16_t buf_size_1905_tx = 10000; // just an arbitrary size + uint8_t buff_1905_tx[buf_size_1905_tx]; + ieee1905_1::CmduMessageTx cmdu_1905(buff_1905_tx, buf_size_1905_tx); + + auto metrics_query = + cmdu_1905.create(0x1, ieee1905_1::eMessageType::BEACON_METRICS_QUERY_MESSAGE); + EXPECT_NE(metrics_query, nullptr); + + auto added_class_1905 = cmdu_1905.addClass(); + EXPECT_NE(added_class_1905, nullptr); + + // fill 1905 message with values + bool filled = set_1905_values(cmdu_1905); + EXPECT_TRUE(filled); + + // Rx - built from the tx message above + ieee1905_1::CmduMessageRx rx(cmdu_1905.getMessageBuff(), cmdu_1905.getMessageBuffLength()); + + bool parse_ok = rx.parse(); + EXPECT_EQ(parse_ok, true); + + auto tlv_becon_metrics_query = rx.getClass(); + EXPECT_NE(tlv_becon_metrics_query, nullptr); + + // DUT - + bool load_ok = beerocks::gate::load(/*dst*/ beerocks, /*src*/ rx); + EXPECT_EQ(load_ok, true); + + auto &beerocks_params = beerocks->params(); + + // variables that were set in the test + EXPECT_EQ(beerocks_params.channel, channel_number); + EXPECT_EQ(beerocks_params.sta_mac, associated_sta_mac_1); + EXPECT_EQ(beerocks_params.op_class, operating_class); + + // default values + EXPECT_EQ(beerocks_params.bssid, beerocks::net::network_utils::ZERO_MAC); + EXPECT_EQ(beerocks_params.measurement_mode, beerocks::MEASURE_MODE_ACTIVE); + EXPECT_EQ(beerocks_params.duration, beerocks::BEACON_MEASURE_DEFAULT_ACTIVE_DURATION); + EXPECT_EQ(beerocks_params.expected_reports_count, 1); + EXPECT_EQ(beerocks_params.rand_ival, beerocks::BEACON_MEASURE_DEFAULT_RANDOMIZATION_INTERVAL); + EXPECT_EQ(beerocks_params.report, 0); + EXPECT_EQ(beerocks_params.repeats, 0); + EXPECT_EQ(beerocks_params.parallel, 0); + EXPECT_EQ(beerocks_params.enable, 0); + EXPECT_EQ(beerocks_params.request, 1); + EXPECT_EQ(beerocks_params.mandatory_duration, 0); + EXPECT_EQ(beerocks_params.use_optional_ssid, 0); +} + +/////// vs --> 1905 //////////////////////////////////////////////////////////////////////////////////// + +/** +* const values to be used for both assignment and test +*/ +const auto associated_sta_mac_2 = sMacAddr{0xba, 0xd0, 0xde, 0xad, 0xbe, 0xef}; + +void fill_vs_values(beerocks_message::cACTION_MONITOR_CLIENT_BEACON_11K_RESPONSE &vs) +{ + vs.params().sta_mac = associated_sta_mac_2; +} + +TEST(gate_beacon_response_test, loading_1905_from_vs_response) +{ + // preperation for beerocks + + // class list + constexpr uint16_t buf_size_beerocks = 10000; + uint8_t buff_beerocks[buf_size_beerocks]; + ClassList cl(buff_beerocks, buf_size_beerocks); + + // beerocks + auto added_class_vs = + cl.addClass(); + EXPECT_NE(added_class_vs, nullptr); + + auto beerocks = cl.getClass(); + EXPECT_NE(beerocks, nullptr); + + // fill the vs message with values + fill_vs_values(*beerocks); + + // build tx message from vs message + + // construct a Tx message with beacon metrics query + constexpr uint16_t buf_size_1905_tx = 10000; + uint8_t buff_1905_response[buf_size_1905_tx]; + ieee1905_1::CmduMessageTx response(buff_1905_response, buf_size_1905_tx); + + auto metrics_response = + response.create(0x1, ieee1905_1::eMessageType::BEACON_METRICS_QUERY_MESSAGE); + EXPECT_NE(metrics_response, nullptr); + + auto added_class_1905 = response.addClass(); + EXPECT_NE(added_class_1905, nullptr); + + // DUT - + bool load_ok = beerocks::gate::load(/*dst*/ response, /*src*/ beerocks); + EXPECT_EQ(load_ok, true); + + auto check_response = response.getClass(); + EXPECT_NE(check_response, nullptr); + EXPECT_EQ(check_response->associated_sta_mac(), associated_sta_mac_2); +} + +} // namespace From aced81258fb6a235fa1dbeb25779b22af1696814 Mon Sep 17 00:00:00 2001 From: Ran Regev Date: Wed, 15 Jul 2020 16:42:51 +0300 Subject: [PATCH 240/453] tests: added beerocks_agent_unit_tests to ci Signed-off-by: Ran Regev --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9d8f491446..058d977b6c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -198,6 +198,9 @@ bwl_dummy_unit_tests: bcl_unit_tests: extends: .run-test-in-docker +beerocks_agent_unit_tests: + extends: .run-test-in-docker + run-tests: stage: test image: $CI_REGISTRY_IMAGE/prplmesh-tests-runner:$CI_PIPELINE_ID From 6310d5b8520b3649622e10cb8b22bede354017c4 Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Wed, 15 Jul 2020 18:42:36 +0200 Subject: [PATCH 241/453] test_flows: test_capi_wireless_onboarding: trigger WPS Now we have WPS support implemented, we can add it to the test. It doesn't actually do much on dummy, but at least we replicate the flow from certification. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- tests/test_flows.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/test_flows.py b/tests/test_flows.py index 44ad6d22c9..3216962321 100755 --- a/tests/test_flows.py +++ b/tests/test_flows.py @@ -332,14 +332,18 @@ def test_capi_wireless_onboarding(self): # Step 2: config env.checkpoint() agent.cmd_reply("dev_set_config,backhaul,0x{}".format(agent.radios[0].mac.replace(':', ''))) - # TODO + # At this point, the wired backhaul should be removed from the bridge so autoconfig search # should still not come through. time.sleep(2) - # self.check_no_cmdu_type("autoconfig search while awaiting onboarding", 0x0007, agent.mac) + self.check_no_cmdu_type("autoconfig search while awaiting onboarding", 0x0007, agent.mac) # Step 3: start WPS - # TODO do backhaul onboarding + agent.cmd_reply("start_wps_registration,band,24G,WpsConfigMethod,PBC") + + # TODO start WPS on CTT agent as well to complete onboarding + # On dummy, it does nothing anyway + time.sleep(2) # Clean up: reset to ethernet backhaul self.test_dev_reset_default() From c750ef615cdf935bbf328e90db560e970d47144a Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Wed, 15 Jul 2020 19:07:02 +0200 Subject: [PATCH 242/453] agent: ucc_listener: implement missing dev_get_parameter for macaddr The dev_get_parameter command is overloaded with a few different functions. Apparently one of them is to get the backhaul STA MAC address: dev_get_parameter,program,map,ruid,,parameter,macaddr We had already implemented this, but in commit 65b625d0a0 it was changed to behave the same as when requesting and SSID. Reimplement the request for macaddr. Since we now use the MAC address as radio UID, we can simply return the RUID given as a parameter directly. https://jira.prplfoundation.org/browse/PPM-297 Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- agent/src/beerocks/slave/agent_ucc_listener.cpp | 13 +++++++++++-- tests/test_flows.py | 7 +++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/agent/src/beerocks/slave/agent_ucc_listener.cpp b/agent/src/beerocks/slave/agent_ucc_listener.cpp index b707c60b21..acec998774 100644 --- a/agent/src/beerocks/slave/agent_ucc_listener.cpp +++ b/agent/src/beerocks/slave/agent_ucc_listener.cpp @@ -115,7 +115,16 @@ bool agent_ucc_listener::handle_dev_get_param(std::unordered_map Date: Thu, 9 Jul 2020 14:57:06 +0000 Subject: [PATCH 243/453] cmake: remove Findzmq.cmake file As ZMQ support was removed, Findzmq.cmake file is not longer used. Signed-off-by: Vitaly Bukhovsky --- cmake/Findzmq.cmake | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 cmake/Findzmq.cmake diff --git a/cmake/Findzmq.cmake b/cmake/Findzmq.cmake deleted file mode 100644 index 58317f184a..0000000000 --- a/cmake/Findzmq.cmake +++ /dev/null @@ -1,22 +0,0 @@ -find_package(PkgConfig REQUIRED) - -pkg_check_modules(ZMQ libzmq>=4.0.4 REQUIRED) - -find_library(ZMQ_LIBRARY "${ZMQ_LIBRARIES}") -if(NOT ZMQ_LIBRARY) - message(FATAL_ERROR "libzmq not found!") -endif() - -add_library(zmq::zmq UNKNOWN IMPORTED) - -# Include directory -set_target_properties(zmq::zmq PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${ZMQ_INCLUDE_DIRS}" -) - -# Library -set_target_properties(zmq::zmq PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" - IMPORTED_LOCATION "${ZMQ_LIBRARY}" -) - From 02e1d2cff854f929dc9e4eb505a6551f89d6d8e4 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Thu, 9 Jul 2020 14:58:30 +0000 Subject: [PATCH 244/453] vscode: devcontainer: remove zmq dependencies Remove the libzmq3-dev package from the development container Signed-off-by: Vitaly Bukhovsky --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 0493bcd02f..25bd0f0a25 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -13,7 +13,7 @@ RUN apt-get update \ # Install C++ tools && apt-get -y install build-essential cmake cppcheck valgrind \ # Libraries - libjson-c-dev python-yaml python3-yaml libzmq3-dev libssl-dev \ + libjson-c-dev python-yaml python3-yaml libssl-dev \ libncurses-dev libreadline-dev libnl-3-dev libnl-route-3-dev libnl-genl-3-dev \ # Install Helper tools bash-completion locales ninja-build pkg-config shellcheck \ From 7c46b85bf41728859e0c9514f32623b5eb0ad384 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Thu, 9 Jul 2020 15:06:59 +0000 Subject: [PATCH 245/453] transport: move Message class into the transport No mapf components use the base Message class except the transport, so move it into the transport module. Once the class is moved, use a specific message type (enum class) instead of a generic uint32_t. Signed-off-by: Vitaly Bukhovsky --- framework/common/CMakeLists.txt | 2 +- .../common/include/mapf/common/message.h | 131 ---------------- framework/common/message.cpp | 21 --- .../ieee1905_transport/ieee1905_transport.cpp | 8 +- .../ieee1905_transport/ieee1905_transport.h | 2 +- .../ieee1905_transport_broker.cpp | 4 +- .../ieee1905_transport_broker.h | 6 +- .../ieee1905_transport_local_bus.cpp | 2 +- .../ieee1905_transport_messages.cpp | 6 +- .../transport/ieee1905_transport_messages.h | 142 +++++++++++++++--- .../test/ieee1905_transport_broker_tests.cpp | 10 +- 11 files changed, 140 insertions(+), 194 deletions(-) delete mode 100644 framework/common/include/mapf/common/message.h delete mode 100644 framework/common/message.cpp diff --git a/framework/common/CMakeLists.txt b/framework/common/CMakeLists.txt index 37dfe0703c..cef36436a6 100644 --- a/framework/common/CMakeLists.txt +++ b/framework/common/CMakeLists.txt @@ -7,7 +7,7 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/logging.conf" DESTINATION share) file(COPY "${CMAKE_CURRENT_BINARY_DIR}/logging.conf" DESTINATION "${CMAKE_MULTIAP_OUTPUT_DIRECTORY}/share/") # mapfcommon sources -set(sources message.cpp logger.cpp encryption.cpp utils.cpp) +set(sources logger.cpp encryption.cpp utils.cpp) # We use OpenSSL 1.1.x for Encryption find_package(OpenSSL 1.1 QUIET) diff --git a/framework/common/include/mapf/common/message.h b/framework/common/include/mapf/common/message.h deleted file mode 100644 index 4abe720492..0000000000 --- a/framework/common/include/mapf/common/message.h +++ /dev/null @@ -1,131 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_COMMON_MESSAGE_H__ -#define __MAPF_COMMON_MESSAGE_H__ - -#include "err.h" -#include -#include -#include -#include -#include -#include - -namespace mapf { - -class Message { -public: - static constexpr uint32_t kMessageMagic = 0xB8C16F47; - static constexpr uint32_t kMessageHeaderVersion = 0x1; - static constexpr uint32_t kMaxTopicSize = 128; - static constexpr uint32_t kMaxFrameLength = 0x100000U; // 1MB max for now - - class Frame { - public: - explicit Frame(size_t len, const void *init_data = nullptr) - : data_(std::make_shared>(len < kMaxFrameLength ? len - : kMaxFrameLength)) - { - if (init_data) - set_data(init_data, len); - } - - Frame() : Frame(0) {} - virtual ~Frame() {} - - size_t len() const { return data_->size(); } - - uint8_t *data() const { return data_->data(); } - std::string str() const { return std::string(reinterpret_cast(data()), len()); } - - void set_size(size_t size) { data_->resize(size); } - - void set_data(const void *data, size_t len) - { - set_size(len); - std::copy_n((uint8_t *)data, len, data_->data()); - } - - virtual std::ostream &print(std::ostream &os) const - { - return os << "size=" << len() << " use_count=" << data_.use_count(); - } - - private: - std::shared_ptr> data_ = nullptr; - }; // class Frame - - struct Header { - uint32_t magic = kMessageMagic; // magic value - uint32_t version = kMessageHeaderVersion; // header version - uint32_t type = 0; // message type - uint32_t len = 0; // total length of the message (excluding topic & header) - }; - - Message() {} - - explicit Message(uint32_t type) : m_type(type) {} - - Message(uint32_t type, std::initializer_list frames) : Message(type) - { - for (auto frame : frames) - Add(frame); - } - - virtual ~Message(){}; - - void Add(Frame &frame) { m_frames.push_back(frame); } - - void Clear() - { - m_frames.clear(); - m_frames.clear(); - } - - // Get the first frame - Frame frame() const { return m_frames.empty() ? Frame() : m_frames.back(); } - - // Accessors & Mutators - const Header header() const - { - Header hdr; - hdr.type = m_type; - for (auto f : m_frames) - hdr.len += f.len(); - return hdr; - } - - uint32_t version() const { return header().version; } - uint32_t len() const { return header().len; } - uint32_t type() const { return m_type; } - - std::vector &frames() const { return m_frames; } - - virtual std::ostream &print(std::ostream &os) const - { - std::stringstream ss; - ss << " version : " << version() << std::endl; - ss << " type : " << type() << std::endl; - ss << " len : " << len() << std::endl; - ss << " frames : " << m_frames.size() << std::endl; - - return os << ss.str(); - } - -private: - uint32_t m_type = 0; - mutable std::vector m_frames; -}; - -inline std::ostream &operator<<(std::ostream &os, const Message::Frame &f) { return f.print(os); } - -inline std::ostream &operator<<(std::ostream &os, const Message &m) { return m.print(os); } - -} /* namespace mapf */ -#endif /* __MAPF_COMMON_MESSAGE_H__ */ diff --git a/framework/common/message.cpp b/framework/common/message.cpp deleted file mode 100644 index 154c76d1ac..0000000000 --- a/framework/common/message.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include - -#include - -namespace mapf { - -// Static members definition -constexpr uint32_t Message::kMessageMagic; -constexpr uint32_t Message::kMessageHeaderVersion; -constexpr uint32_t Message::kMaxTopicSize; -constexpr uint32_t Message::kMaxFrameLength; - -} // namespace mapf diff --git a/framework/transport/ieee1905_transport/ieee1905_transport.cpp b/framework/transport/ieee1905_transport/ieee1905_transport.cpp index e234b80b67..ff186cf3e1 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport.cpp @@ -27,15 +27,15 @@ void Ieee1905Transport::run() // Register broker handlers for internal and external messages m_broker->register_external_message_handler( - [&](std::unique_ptr &msg, BrokerServer &broker) -> bool { - LOG(DEBUG) << "Processing external message: " << msg->type(); + [&](std::unique_ptr &msg, BrokerServer &broker) -> bool { + LOG(DEBUG) << "Processing external message: " << uint32_t(msg->type()); handle_broker_pollin_event(msg); return true; }); m_broker->register_internal_message_handler( - [&](std::unique_ptr &msg, BrokerServer &broker) -> bool { - LOG(DEBUG) << "Processing internal message: " << msg->type(); + [&](std::unique_ptr &msg, BrokerServer &broker) -> bool { + LOG(DEBUG) << "Processing internal message: " << uint32_t(msg->type()); handle_broker_pollin_event(msg); return true; }); diff --git a/framework/transport/ieee1905_transport/ieee1905_transport.h b/framework/transport/ieee1905_transport/ieee1905_transport.h index 032d37a5d9..44b08016bd 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport.h +++ b/framework/transport/ieee1905_transport/ieee1905_transport.h @@ -284,7 +284,7 @@ class Ieee1905Transport { // // BROKER STUFF // - void handle_broker_pollin_event(std::unique_ptr &msg); + void handle_broker_pollin_event(std::unique_ptr &msg); void handle_broker_cmdu_tx_message(messages::CmduTxMessage &msg); void handle_broker_interface_configuration_request_message( messages::InterfaceConfigurationRequestMessage &msg); diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp index 8eac4d9403..6729e0538e 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp @@ -104,7 +104,7 @@ BrokerServer::BrokerServer(const std::string &broker_uds_path, SocketEventLoop:: LOG(INFO) << "Listening on UDS: " << m_broker_uds_path; } -bool BrokerServer::publish(const mapf::Message &msg) +bool BrokerServer::publish(const messages::Message &msg) { messages::SubscribeMessage::MsgType msg_opcode; @@ -122,7 +122,7 @@ bool BrokerServer::publish(const mapf::Message &msg) msg_opcode.bits = {.internal = 1, // internal message .vendor_specific = 0, .reserved = 0, - .type = msg.type()}; + .type = uint16_t(msg.type())}; } } diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_broker.h b/framework/transport/ieee1905_transport/ieee1905_transport_broker.h index 64bae3fb00..c5e53d22ea 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_broker.h +++ b/framework/transport/ieee1905_transport/ieee1905_transport_broker.h @@ -34,13 +34,13 @@ namespace broker { class BrokerServer : public SocketEventLoop { public: /** - * @brief Transport messages (@see mapf::Message) handler function definition. + * @brief Transport messages (@see Message) handler function definition. * * Parameters to the event handler function are: * @param[in] msg Pointer to the message to handle. * @param[in] broker Reference to the BrokerServer instance. * - * @returns True on success or false otherwise + * @returns true on success or false otherwise */ using MessageHandler = std::function &msg, BrokerServer &broker)>; @@ -67,7 +67,7 @@ class BrokerServer : public SocketEventLoop { * * @returns true on success or false otherwise. */ - virtual bool publish(const mapf::Message &msg); + virtual bool publish(const messages::Message &msg); /** * @brief Register a handler function for internal (non-CMDU) messages diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp index 5c807e0716..59f0d4bb35 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp @@ -19,7 +19,7 @@ namespace transport { // Use transport messaging classes using namespace beerocks::transport::messages; -void Ieee1905Transport::handle_broker_pollin_event(std::unique_ptr &msg) +void Ieee1905Transport::handle_broker_pollin_event(std::unique_ptr &msg) { if (auto *cmdu_tx_msg = dynamic_cast(msg.get())) { MAPF_DBG("received CmduTxMessage message:" << std::endl << *cmdu_tx_msg); diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp index dda3a485ec..6cf025e361 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp @@ -17,7 +17,9 @@ namespace transport { namespace messages { // Declaration of static members -constexpr int SubscribeMessage::MAX_SUBSCRIBE_TYPES; +constexpr uint32_t Message::kMessageMagic; +constexpr uint32_t Message::kMaxFrameLength; +constexpr uint8_t SubscribeMessage::MAX_SUBSCRIBE_TYPES; ////////////////////////////////////////////////////////////////////////////// ////////////////////////////// Helper Functions ////////////////////////////// @@ -47,7 +49,7 @@ create_transport_message(Type type, std::initializer_list{new messages::Message(0, frame)}; + return std::unique_ptr{new messages::Message(Type::Invalid, frame)}; } } diff --git a/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h b/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h index 6590d7e478..3ba3a3b0d0 100644 --- a/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h +++ b/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h @@ -10,11 +10,14 @@ #define MAP_IEEE1905_TRANSPORT_MESSAGES_H_ #include -#include +#include -#include #include #include + +#include +#include +#include #include #ifndef ETH_P_1905_1 @@ -28,10 +31,6 @@ namespace beerocks { namespace transport { namespace messages { -// NOTE: Use the base mapf::Message class -// Remove this once mapf common namespace is merged with beerocks -using mapf::Message; - /** * Transport internal message types */ @@ -46,6 +45,105 @@ enum class Type { InterfaceConfigurationIndicationMessage = 7 }; +class Message { +public: + static constexpr uint32_t kMessageMagic = 0xB8C16F47; + static constexpr uint32_t kMaxFrameLength = 0x100000; // 100kb max for now + + class Frame { + public: + explicit Frame(size_t len, const void *init_data = nullptr) + : data_(std::make_shared>( + (len < kMaxFrameLength) ? len : kMaxFrameLength)) + { + if (init_data) + set_data(init_data, len); + } + + Frame() : Frame(0) {} + virtual ~Frame() = default; + + size_t len() const { return data_->size(); } + + uint8_t *data() const { return data_->data(); } + std::string str() const { return std::string(reinterpret_cast(data()), len()); } + + void set_size(size_t size) { data_->resize(size); } + + void set_data(const void *data, size_t len) + { + set_size(len); + std::copy_n((uint8_t *)data, len, data_->data()); + } + + virtual std::ostream &print(std::ostream &os) const + { + return os << "size=" << len() << " use_count=" << data_.use_count(); + } + + private: + std::shared_ptr> data_ = nullptr; + }; // class Frame + + struct Header { + uint32_t magic = kMessageMagic; // magic value + uint32_t type = 0; // message type + uint32_t len = 0; // total length of the message (excluding topic & header) + }; + + Message() {} + + explicit Message(Type type) : m_type(type) {} + + Message(Type type, std::initializer_list frames) : Message(type) + { + for (auto f : frames) + Add(f); + } + + virtual ~Message() = default; + + void Add(Frame &frame) { m_frames.push_back(frame); } + + void Clear() { m_frames.clear(); } + + // Get the first frame + Frame frame() const { return m_frames.empty() ? Frame() : m_frames.back(); } + + // Accessors & Mutators + const Header header() const + { + Header hdr; + hdr.type = uint32_t(m_type); + for (const auto &f : m_frames) + hdr.len += f.len(); + return hdr; + } + + uint32_t len() const { return header().len; } + Type type() const { return m_type; } + + std::vector &frames() const { return m_frames; } + + virtual std::ostream &print(std::ostream &os) const + { + std::stringstream ss; + ss << " type : " << uint32_t(type()) << std::endl; + ss << " len : " << len() << std::endl; + ss << " frames : " << m_frames.size() << std::endl; + + return os << ss.str(); + } + +private: + Type m_type = Type::Invalid; + mutable std::vector m_frames; +}; + +inline std::ostream &operator<<(std::ostream &os, const Message::Frame &f) { return f.print(os); } + +inline std::ostream &operator<<(std::ostream &os, const Message &m) { return m.print(os); } + // Notes: // // This class will use one and only one Frame!!! @@ -78,7 +176,7 @@ class CmduXxMessage : public Message { 0; // payload length (including IEEE1905 header, excluding Ethernet header) }; - explicit CmduXxMessage(uint32_t type, std::initializer_list frames = {}) + explicit CmduXxMessage(Type type, std::initializer_list frames = {}) : Message(type, frames) { // maximum one frame is allowed (if none are given we will allocate one below) @@ -102,7 +200,7 @@ class CmduXxMessage : public Message { return frames().back().data() + sizeof(Metadata); }; - virtual std::ostream &print(std::ostream &os) const + virtual std::ostream &print(std::ostream &os) const override { Message::print(os); @@ -142,7 +240,7 @@ class CmduXxMessage : public Message { class CmduRxMessage : public CmduXxMessage { public: explicit CmduRxMessage(std::initializer_list frame = {}) - : CmduXxMessage(uint32_t(Type::CmduRxMessage), frame) + : CmduXxMessage(Type::CmduRxMessage, frame) { } }; @@ -150,7 +248,7 @@ class CmduRxMessage : public CmduXxMessage { class CmduTxMessage : public CmduXxMessage { public: explicit CmduTxMessage(std::initializer_list frame = {}) - : CmduXxMessage(uint32_t(Type::CmduTxMessage), frame) + : CmduXxMessage(Type::CmduTxMessage, frame) { } }; @@ -162,7 +260,7 @@ class SubscribeMessage : public Message { /** * Maximal number of types for a single subscribe/unsubscribe message */ - static constexpr int MAX_SUBSCRIBE_TYPES = 64; + static constexpr uint8_t MAX_SUBSCRIBE_TYPES = 64; /** * The type of the request @@ -194,7 +292,7 @@ class SubscribeMessage : public Message { }; explicit SubscribeMessage(std::initializer_list frames = {}) - : Message(uint32_t(Type::SubscribeMessage), frames) + : Message(Type::SubscribeMessage, frames) { // maximum one frame is allowed (if none are given we will allocate one below) mapf_assert(this->frames().size() <= 1); @@ -214,7 +312,7 @@ class SubscribeMessage : public Message { return (Metadata *)frames().back().data(); }; - virtual std::ostream &print(std::ostream &os) const + virtual std::ostream &print(std::ostream &os) const override { Message::print(os); @@ -252,7 +350,7 @@ class CmduTxConfirmationMessage : public Message { }; explicit CmduTxConfirmationMessage(std::initializer_list frames = {}) - : Message(uint32_t(Type::CmduTxConfirmationMessage), frames) + : Message(Type::CmduTxConfirmationMessage, frames) { // maximum one frame is allowed (if none are given we will allocate one below) mapf_assert(this->frames().size() <= 1); @@ -272,7 +370,7 @@ class CmduTxConfirmationMessage : public Message { return (Metadata *)frames().back().data(); }; - virtual std::ostream &print(std::ostream &os) const + virtual std::ostream &print(std::ostream &os) const override { Message::print(os); @@ -295,11 +393,11 @@ class CmduTxConfirmationMessage : public Message { class InterfaceConfigurationQueryMessage : public Message { public: explicit InterfaceConfigurationQueryMessage(std::initializer_list frames = {}) - : Message(uint32_t(Type::InterfaceConfigurationQueryMessage), frames) + : Message(Type::InterfaceConfigurationQueryMessage, frames) { } - virtual ~InterfaceConfigurationQueryMessage() {} + virtual ~InterfaceConfigurationQueryMessage() = default; }; class InterfaceConfigurationMessage : public Message { @@ -326,7 +424,7 @@ class InterfaceConfigurationMessage : public Message { Interface interfaces[kMaxInterfaces]; }; - explicit InterfaceConfigurationMessage(uint32_t type, std::initializer_list frames) + explicit InterfaceConfigurationMessage(Type type, std::initializer_list frames) : Message(type, frames) { // maximum one frame is allowed (if none are given we will allocate one below) @@ -342,7 +440,7 @@ class InterfaceConfigurationMessage : public Message { Metadata *metadata() const { return (Metadata *)frames().back().data(); }; - virtual std::ostream &print(std::ostream &os) const + virtual std::ostream &print(std::ostream &os) const override { Message::print(os); @@ -367,8 +465,7 @@ class InterfaceConfigurationMessage : public Message { class InterfaceConfigurationRequestMessage : public InterfaceConfigurationMessage { public: explicit InterfaceConfigurationRequestMessage(std::initializer_list frames = {}) - : InterfaceConfigurationMessage(uint32_t(Type::InterfaceConfigurationRequestMessage), - frames) + : InterfaceConfigurationMessage(Type::InterfaceConfigurationRequestMessage, frames) { } }; @@ -377,8 +474,7 @@ class InterfaceConfigurationRequestMessage : public InterfaceConfigurationMessag class InterfaceConfigurationIndicationMessage : public InterfaceConfigurationMessage { public: explicit InterfaceConfigurationIndicationMessage(std::initializer_list frames = {}) - : InterfaceConfigurationMessage(uint32_t(Type::InterfaceConfigurationIndicationMessage), - frames) + : InterfaceConfigurationMessage(Type::InterfaceConfigurationIndicationMessage, frames) { } }; diff --git a/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp b/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp index f20ff9f5fd..dc4760bda6 100644 --- a/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp +++ b/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp @@ -96,13 +96,13 @@ TEST(broker_server, invalid_message_magic) // Register a dummy internal message handler broker_wrapper.register_internal_message_handler( - [](std::unique_ptr &msg, BrokerServer &broker) -> bool { return true; }); + [](std::unique_ptr &msg, BrokerServer &broker) -> bool { return true; }); // Create a random message - mapf::Message dummy; + messages::Message dummy; // Invalid header - mapf::Message::Header header; + messages::Message::Header header; header.magic = INVALID_MAGIC; SocketClient sock1(broker_uds_file); @@ -299,13 +299,13 @@ TEST(broker_server, publish_internal_message) ASSERT_TRUE(broker_wrapper.publish(iface_indication_msg_tx)); // Verify the data is received on the subscribed socket - ASSERT_TRUE(size_t(sock1.getBytesReady()) > sizeof(mapf::Message::Header)); + ASSERT_TRUE(size_t(sock1.getBytesReady()) > sizeof(messages::Message::Header)); // Read, parse and validate the message auto iface_indication_msg_rx_ptr = messages::read_transport_message(sock1); ASSERT_TRUE(iface_indication_msg_rx_ptr); ASSERT_TRUE(iface_indication_msg_rx_ptr->type() == - uint32_t(Type::InterfaceConfigurationIndicationMessage)); + Type::InterfaceConfigurationIndicationMessage); auto &iface_indication_msg_rx = dynamic_cast(*iface_indication_msg_rx_ptr); From 2b97ade25441994f7f15bd07a91cba686e17fd2f Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Thu, 9 Jul 2020 15:13:58 +0000 Subject: [PATCH 246/453] mapf: common: cleanup and re-enable unit tests Message tests assume string based topics, which are no longer exist after the removal of ZMQ support. Remove these tests. Re-enable the build of the remaining encryption test and execute it as part of the GitLab CI. Signed-off-by: Vitaly Bukhovsky --- .gitlab-ci.yml | 3 + framework/common/CMakeLists.txt | 2 +- framework/common/test/CMakeLists.txt | 20 +- framework/common/test/config.h | 22 --- framework/common/test/message_test.cpp | 173 ------------------ framework/common/test/messages/CMakeLists.txt | 3 - framework/common/test/messages/dummy1.cpp | 14 -- framework/common/test/messages/dummy1.h | 37 ---- framework/common/test/messages/dummy2.cpp | 14 -- framework/common/test/messages/dummy2.h | 37 ---- .../common/test/messages/dummy_messages.h | 15 -- 11 files changed, 15 insertions(+), 325 deletions(-) delete mode 100644 framework/common/test/config.h delete mode 100644 framework/common/test/message_test.cpp delete mode 100644 framework/common/test/messages/CMakeLists.txt delete mode 100644 framework/common/test/messages/dummy1.cpp delete mode 100644 framework/common/test/messages/dummy1.h delete mode 100644 framework/common/test/messages/dummy2.cpp delete mode 100644 framework/common/test/messages/dummy2.h delete mode 100644 framework/common/test/messages/dummy_messages.h diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 058d977b6c..c789748001 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -198,6 +198,9 @@ bwl_dummy_unit_tests: bcl_unit_tests: extends: .run-test-in-docker +mapf_common_encryption_tests: + extends: .run-test-in-docker + beerocks_agent_unit_tests: extends: .run-test-in-docker diff --git a/framework/common/CMakeLists.txt b/framework/common/CMakeLists.txt index cef36436a6..c892eac6d9 100644 --- a/framework/common/CMakeLists.txt +++ b/framework/common/CMakeLists.txt @@ -52,4 +52,4 @@ install(TARGETS mapfcommon EXPORT mapfCommon RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(EXPORT mapfCommon NAMESPACE mapf:: DESTINATION lib/cmake/mapfCommon) -# add_subdirectory(test) +add_subdirectory(test) diff --git a/framework/common/test/CMakeLists.txt b/framework/common/test/CMakeLists.txt index 961fbe8fb4..498245e3be 100644 --- a/framework/common/test/CMakeLists.txt +++ b/framework/common/test/CMakeLists.txt @@ -1,11 +1,13 @@ if(BUILD_TESTS) - add_subdirectory(messages) - file(GLOB tests *_test.cpp) - foreach(test ${tests}) - get_filename_component(target ${test} NAME_WE) - add_executable(${target} ${test}) - target_link_libraries(${target} mapfcommon dummy_messages elpp) - install(TARGETS ${target} DESTINATION bin/tests/common) - add_test(NAME ${target} COMMAND $) - endforeach(test ${tests}) + + # Encryption Tests + set(TEST_NAME mapf_common_encryption_tests) + add_executable(${TEST_NAME} + encryption_test.cpp + ) + + target_link_libraries(${TEST_NAME} mapfcommon elpp) + + install(TARGETS ${TEST_NAME} DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}/tests) + add_test(NAME ${TEST_NAME} COMMAND $) endif() diff --git a/framework/common/test/config.h b/framework/common/test/config.h deleted file mode 100644 index 5b808c1709..0000000000 --- a/framework/common/test/config.h +++ /dev/null @@ -1,22 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_COMMON_TESTS_CONFIG_H__ -#define __MAPF_COMMON_TESTS_CONFIG_H__ - -#include -#include - -static const std::string kTopic = "test.topic1"; -static const std::string kTopic2 = "test.topic2"; -static const std::string kData = "0123456789"; -static const std::string kData2 = "abcdef"; -static constexpr const char *kSubAddr = "ipc://" TMP_PATH "/subscribers"; -static constexpr const char *kPubAddr = "ipc://" TMP_PATH "/publishers"; - -#endif // __MAPF_COMMON_TESTS_CONFIG_H__ diff --git a/framework/common/test/message_test.cpp b/framework/common/test/message_test.cpp deleted file mode 100644 index a3340a69d9..0000000000 --- a/framework/common/test/message_test.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include "config.h" -#include "messages/dummy_messages.h" -#include -#include -#include -#include -#include -#include -#include - -namespace mapf { - -class MessageTest1 : public Message { -public: - static const std::string kTopicPrefix; - explicit MessageTest1(const std::string &topic) : Message(topic) - { - std::cout << "Building MessageTest1, prefix=" << kTopicPrefix << std::endl; - } - - MessageTest1(const std::string &topic, std::initializer_list frames) - : Message(topic, frames) - { - } - - virtual ~MessageTest1() - { - std::cout << "Destroying MessageTest1, prefix=" << kTopicPrefix << std::endl; - } -}; -const std::string MessageTest1::kTopicPrefix = "test1."; - -class MessageTest2 : public Message { -public: - static const std::string kTopicPrefix; - explicit MessageTest2(const std::string &topic) : Message(topic) - { - std::cout << "Building MessageTest2, prefix=" << kTopicPrefix << std::endl; - } - - MessageTest2(const std::string &topic, std::initializer_list frames) - : Message(topic, frames) - { - } - - virtual ~MessageTest2() - { - std::cout << "Destroying MessageTest2, prefix=" << kTopicPrefix << std::endl; - } -}; -const std::string MessageTest2::kTopicPrefix = "test2."; -} // namespace mapf - -void test1() -{ - std::cout << "START test1" << std::endl; - mapf::Message::Frame f1; - mapf::Message::Frame f2(512); - std::string str("valkiry"); - mapf::Message::Frame f3(str.size(), str.c_str()); - std::cout << f3.data() << std::endl; - f3.set_data("1234567890", sizeof("1234567890")); - std::cout << f3.data() << std::endl; - mapf::Message::Frame f4 = f3; - mapf::Message::Frame *f5 = new mapf::Message::Frame(f4); - std::cout << "f1: " << f1 << std::endl; - std::cout << "f2: " << f2 << std::endl; - std::cout << "f3: " << f3 << std::endl; - std::cout << "f4: " << f4 << std::endl; - delete f5; - std::cout << "f1: " << f1 << std::endl; - std::cout << "f2: " << f2 << std::endl; - std::cout << "f3: " << f3 << std::endl; - std::cout << "f4: " << f4 << std::endl; - std::cout << "END test1" << std::endl; -} - -void test2_thread_handler(mapf::Message::Frame f) -{ - int count = 10; - - while (count--) { - //sleep(1); - std::cout << "thread f: " << f << std::endl; - } - - std::cout << "thread exiting" << std::endl; -} - -void test2() -{ - std::cout << "START test2" << std::endl; - std::thread *thread_obj; - { - mapf::Message::Frame f1(100); - std::cout << "MAIN: f1 before: " << f1 << std::endl; - thread_obj = new std::thread(test2_thread_handler, f1); - std::cout << "MAIN: f1 after: " << f1 << std::endl; - } - std::cout << "MAIN went out of scope" << std::endl; - thread_obj->join(); - delete thread_obj; - std::cout << "END test2" << std::endl; -} - -void test3() -{ - std::cout << "START test3" << std::endl; - mapf::Message m1("kratos"); - mapf::Message::Frame f1, f2, f3; - mapf::Message m2("boy", {f1, f2, f3}); - std::cout << "m2: " << m2 << std::endl; - - std::cout << "m1: " << m1 << std::endl; - { - mapf::Message::Frame f1; - std::cout << "f1 before adding: " << f1 << std::endl; - m1.Add(f1); - std::cout << "f1 after adding: " << f1 << std::endl; - std::cout << "in scope m1: " << m1 << std::endl; - for (auto f : m1.frames()) { - std::cout << "frame: " << f << std::endl; - } - } - std::cout << "after scope f1: " << m1.frames().data()[0] << std::endl; - std::cout << "after scope m1: " << m1 << std::endl; - for (auto f : m1.frames()) { - std::cout << "frame: " << f << std::endl; - } - std::cout << "END test3" << std::endl; -} - -void test4() -{ - mapf::MessageFactory::Instance().DumpMakers(); - mapf::Message::Frame f1(kTopic.size(), kTopic.data()); - std::cout << "f1: " << f1 << std::endl; - { - auto m1 = mapf::MessageFactory::Instance().Create("test1.thanos", {f1}); - std::cout << "m1 = " << *m1 << std::endl; - std::cout << "f1: " << f1 << std::endl; - auto m2 = mapf::MessageFactory::Instance().Create("test2.ironman"); - std::cout << "m2 = " << *m2 << std::endl; - auto m3 = mapf::MessageFactory::Instance().Create("base", {f1}); - std::cout << "m3 = " << *m3 << std::endl; - std::cout << "f1: " << f1 << std::endl; - } - std::cout << "f1: " << f1 << std::endl; -} - -int main() -{ - /*mapf::Logger::Instance().LoggerInit("message_test"); - mapf::LocalBusInterface bus(mapf::Context::Instance()); - bus.subscriber().Subscribe(); - bus.subscriber().Subscribe(); - mapf::MessageFactory::Instance().DumpMakers(); - std::cout << "Subscriber: " << bus.subscriber() << std::endl;*/ - - test1(); - test2(); - test3(); - test4(); - return 0; -} diff --git a/framework/common/test/messages/CMakeLists.txt b/framework/common/test/messages/CMakeLists.txt deleted file mode 100644 index 55e15c6f42..0000000000 --- a/framework/common/test/messages/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_library(dummy_messages dummy1.cpp dummy2.cpp) -target_link_libraries(dummy_messages PRIVATE mapfcommon) -install(TARGETS dummy_messages DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/framework/common/test/messages/dummy1.cpp b/framework/common/test/messages/dummy1.cpp deleted file mode 100644 index 6e70fcac7a..0000000000 --- a/framework/common/test/messages/dummy1.cpp +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include "dummy1.h" - -namespace mapf { - -const std::string Dummy1Message::kTopicPrefix = "dummy1."; -} diff --git a/framework/common/test/messages/dummy1.h b/framework/common/test/messages/dummy1.h deleted file mode 100644 index ba7bcd8841..0000000000 --- a/framework/common/test/messages/dummy1.h +++ /dev/null @@ -1,37 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_COMMON_TEST_MESSAGES_DUMMY1_H__ -#define __MAPF_COMMON_TEST_MESSAGES_DUMMY1_H__ - -#include -#include - -namespace mapf { - -class Dummy1Message : public Message { -public: - static const std::string kTopicPrefix; - explicit Dummy1Message(const std::string &topic) : Message(topic) - { - std::cout << "Building Dummy1Message, prefix=" << kTopicPrefix << std::endl; - } - - Dummy1Message(const std::string &topic, std::initializer_list frames) - : Message(topic, frames) - { - } - - virtual ~Dummy1Message() - { - std::cout << "Destroying Dummy1Message, prefix=" << kTopicPrefix << std::endl; - } -}; -} // namespace mapf - -#endif //ifndef __MAPF_COMMON_TEST_MESSAGES_DUMMY1_H__ diff --git a/framework/common/test/messages/dummy2.cpp b/framework/common/test/messages/dummy2.cpp deleted file mode 100644 index fc9de0b20d..0000000000 --- a/framework/common/test/messages/dummy2.cpp +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include "dummy2.h" - -namespace mapf { - -const std::string Dummy2Message::kTopicPrefix = "dummy2."; -} diff --git a/framework/common/test/messages/dummy2.h b/framework/common/test/messages/dummy2.h deleted file mode 100644 index 343e88bd3c..0000000000 --- a/framework/common/test/messages/dummy2.h +++ /dev/null @@ -1,37 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_COMMON_TEST_MESSAGES_DUMMY2_H__ -#define __MAPF_COMMON_TEST_MESSAGES_DUMMY2_H__ - -#include -#include - -namespace mapf { - -class Dummy2Message : public Message { -public: - static const std::string kTopicPrefix; - explicit Dummy2Message(const std::string &topic) : Message(topic) - { - std::cout << "Building Dummy2Message, prefix=" << kTopicPrefix << std::endl; - } - - Dummy2Message(const std::string &topic, std::initializer_list frames) - : Message(topic, frames) - { - } - - virtual ~Dummy2Message() - { - std::cout << "Destroying Dummy2Message, prefix=" << kTopicPrefix << std::endl; - } -}; -} // namespace mapf - -#endif //#ifndef __MAPF_COMMON_TEST_MESSAGES_DUMMY2_H__ diff --git a/framework/common/test/messages/dummy_messages.h b/framework/common/test/messages/dummy_messages.h deleted file mode 100644 index 5cfebd70a5..0000000000 --- a/framework/common/test/messages/dummy_messages.h +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#ifndef __MAPF_COMMON_TEST_MESSAGES_H__ -#define __MAPF_COMMON_TEST_MESSAGES_H__ - -#include "dummy1.h" -#include "dummy2.h" - -#endif //#ifndef __MAPF_COMMON_TEST_MESSAGES_H__ From a7f76ff94d26c7537895e68b963d9036e91d44ce Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Thu, 9 Jul 2020 15:34:10 +0000 Subject: [PATCH 247/453] transport: broker: various review fixes Pass arguments by references where possible to prevent increasing the reference count of shared pointers. Store the broker's uds path as a constant. Fix incorrect comments and remove useless if conditions. Signed-off-by: Vitaly Bukhovsky --- .../ieee1905_transport_broker.cpp | 41 ++++++------------- .../ieee1905_transport_broker.h | 17 +------- .../test/ieee1905_transport_broker_tests.cpp | 4 +- 3 files changed, 17 insertions(+), 45 deletions(-) diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp index 6729e0538e..259ab1e4a0 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp @@ -49,10 +49,8 @@ static bool is_restricted_type(uint32_t type) ////////////////////////////////////////////////////////////////////////////// BrokerServer::BrokerServer(const std::string &broker_uds_path, SocketEventLoop::TimeoutType timeout) - : SocketEventLoop(timeout) + : SocketEventLoop(timeout), m_broker_uds_path(broker_uds_path) { - m_broker_uds_path = broker_uds_path; - // Server sockets event handlers EventHandlers server_socket_handlers{ // Accept incoming connections @@ -88,7 +86,7 @@ BrokerServer::BrokerServer(const std::string &broker_uds_path, SocketEventLoop:: }, }; - // Connect to the message broker + // Start the broker server socket m_broker_socket_uds = std::make_shared(m_broker_uds_path, listen_buffer_size); LOG_IF(!m_broker_socket_uds, FATAL) << "Failed allocating memory!"; @@ -164,7 +162,7 @@ void BrokerServer::register_external_message_handler(MessageHandler handler) m_external_message_handler = handler; } -bool BrokerServer::handle_msg(std::shared_ptr sd) +bool BrokerServer::handle_msg(std::shared_ptr &sd) { // Check if the socket contains enough bytes for the header if (sd->getBytesReady() < static_cast(sizeof(messages::Message::Header))) { @@ -227,7 +225,7 @@ bool BrokerServer::handle_subscribe(std::shared_ptr &sd, // Iterate over the message types and subscribe/unsubscribe bool subscribe = msg.metadata()->type == messages::SubscribeMessage::ReqType::SUBSCRIBE; - std::stringstream types_stream; + std::stringstream log_types; for (auto i = 0; i < msg.metadata()->msg_types_num; ++i) { auto msg_type = msg.metadata()->msg_types[i]; @@ -240,7 +238,7 @@ bool BrokerServer::handle_subscribe(std::shared_ptr &sd, } // Add to the list of requested types - types_stream << "0x" << std::hex << msg_type.value << std::string(" "); + log_types << "0x" << std::hex << msg_type.value << " "; // Subscribe if (subscribe) { @@ -262,7 +260,7 @@ bool BrokerServer::handle_subscribe(std::shared_ptr &sd, LOG(INFO) << "FD (" << sd->getSocketFd() << ") " << std::string(subscribe ? "subscribed to" : "unsubscribed from") - << " the following types: " << types_stream.str(); + << " the following types: " << log_types.str(); LOG(DEBUG) << "FD (" << sd->getSocketFd() << ") subscriptions: " << std::hex << m_soc_to_type[sd] << std::dec; @@ -282,24 +280,15 @@ bool BrokerServer::socket_connected(std::shared_ptr sd) return false; } - if (!sd->getUdsPath().empty()) { - LOG(DEBUG) << "New connection on " << sd->getUdsPath() - << " fd = " << uintptr_t(new_socket->getSocketFd()); - } else { - LOG(DEBUG) << "New connection from ip = " << new_socket->getPeerIP() - << " port = " << new_socket->getPeerPort() - << " fd = " << uint64_t(new_socket->getSocketFd()); - } + LOG(DEBUG) << "Accepted new connection, fd = " << new_socket->getSocketFd(); // Socket event handlers SocketEventLoop::EventHandlers socket_handlers{ // Handle incoming data .on_read = [&](SocketEventLoop::EventType socket, SocketEventLoop::EventLoopType &loop) { - if (!handle_msg(socket)) { - // NOTE: Do NOT stop the broker on parsing errors... - } - + // NOTE: Do NOT stop the broker on parsing errors... + handle_msg(socket); return true; }, @@ -310,18 +299,14 @@ bool BrokerServer::socket_connected(std::shared_ptr sd) // Remove the socket on disconnections or errors .on_disconnect = [&](SocketEventLoop::EventType socket, SocketEventLoop::EventLoopType &loop) { - if (!socket_disconnected(socket)) { - // NOTE: Do NOT stop the broker on errors... - } - + // NOTE: Do NOT stop the broker on errors... + socket_disconnected(socket); return true; }, .on_error = [&](SocketEventLoop::EventType socket, SocketEventLoop::EventLoopType &loop) { - if (!socket_disconnected(socket)) { - // NOTE: Do NOT stop the broker on errors... - } - + // NOTE: Do NOT stop the broker on errors... + socket_disconnected(socket); return true; }, }; diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_broker.h b/framework/transport/ieee1905_transport/ieee1905_transport_broker.h index c5e53d22ea..a00e0f780d 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_broker.h +++ b/framework/transport/ieee1905_transport/ieee1905_transport_broker.h @@ -97,7 +97,7 @@ class BrokerServer : public SocketEventLoop { * * @return true on success of false otherwise. */ - virtual bool handle_msg(std::shared_ptr sd); + virtual bool handle_msg(std::shared_ptr &sd); /** * @brief Handle broker subscribe/unsubscribe messages. @@ -129,23 +129,10 @@ class BrokerServer : public SocketEventLoop { virtual bool socket_disconnected(std::shared_ptr sd); private: - // Union for storing the subscribed CMDU message type with additional VS metadata (if applicable) - // union uOpcode { - // /// Opcode as separate fields - // struct fields { - // uint16_t cmdu_type; - // uint8_t vs_action; - // uint8_t vs_action_op; - // } __attribute__((packed)); - - // /// Opcode as 32bit unsigned integer - // uint32_t data; - // }; - /** * Path and filename to the server's UDS file. */ - std::string m_broker_uds_path; + const std::string m_broker_uds_path; /** * Shared pointer to the server's UDS socket. diff --git a/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp b/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp index dc4760bda6..59c9c0efa7 100644 --- a/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp +++ b/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp @@ -38,7 +38,7 @@ using namespace beerocks::transport::messages; ////////////////////////////////////////////////////////////////////////////// // UDS file for the tests -static constexpr char broker_uds_file[] = "beerocks_broker_test_uds"; +static const std::string broker_uds_file = "beerocks_broker_test_uds"; // Invalid message magic value static constexpr uint32_t INVALID_MAGIC = 0x12345678; @@ -60,7 +60,7 @@ class BrokerServerWrapper : public BrokerServer { protected: bool m_error_occurred = false; - virtual bool handle_msg(std::shared_ptr sd) override + virtual bool handle_msg(std::shared_ptr &sd) override { if (BrokerServer::handle_msg(sd) == false) { m_error_occurred = true; From 8b29adab2f770aae9191ecd82e9a8391982b7288 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Thu, 9 Jul 2020 15:39:53 +0000 Subject: [PATCH 248/453] transport: messages: various review fixes Rename a metadata field of the subscribe/unsubscribe message from msg_types_num to msg_types_count. Fix an incorrect error message and remove redundant argument in a Socket's readBytes() call. Signed-off-by: Vitaly Bukhovsky --- common/beerocks/btl/btl_broker.cpp | 6 +++--- .../ieee1905_transport_broker.cpp | 4 ++-- .../ieee1905_transport_messages.cpp | 6 +++--- .../transport/ieee1905_transport_messages.h | 19 +++++++++---------- .../test/ieee1905_transport_broker_tests.cpp | 12 ++++++------ 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/common/beerocks/btl/btl_broker.cpp b/common/beerocks/btl/btl_broker.cpp index 540237fabf..b93118e269 100644 --- a/common/beerocks/btl/btl_broker.cpp +++ b/common/beerocks/btl/btl_broker.cpp @@ -106,12 +106,12 @@ bool transport_socket_thread::bus_subscribe(const std::vectortype = SubscribeMessage::ReqType::SUBSCRIBE; - subscribe.metadata()->msg_types_num = 0; + subscribe.metadata()->msg_types_count = 0; for (const auto &msg_type : msg_types) { - subscribe.metadata()->msg_types[subscribe.metadata()->msg_types_num].bits = { + subscribe.metadata()->msg_types[subscribe.metadata()->msg_types_count].bits = { .internal = 0, .vendor_specific = 0, .reserved = 0, .type = uint32_t(msg_type)}; - ++subscribe.metadata()->msg_types_num; + ++subscribe.metadata()->msg_types_count; } return transport::messages::send_transport_message(*bus, subscribe); diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp index 259ab1e4a0..b1e59eb58b 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp @@ -218,7 +218,7 @@ bool BrokerServer::handle_subscribe(std::shared_ptr &sd, } // Make sure there's at least one message type - if (msg.metadata()->msg_types_num == 0) { + if (msg.metadata()->msg_types_count == 0) { LOG(ERROR) << "Subscribe message does not contain any types!"; return false; } @@ -226,7 +226,7 @@ bool BrokerServer::handle_subscribe(std::shared_ptr &sd, // Iterate over the message types and subscribe/unsubscribe bool subscribe = msg.metadata()->type == messages::SubscribeMessage::ReqType::SUBSCRIBE; std::stringstream log_types; - for (auto i = 0; i < msg.metadata()->msg_types_num; ++i) { + for (auto i = 0; i < msg.metadata()->msg_types_count; ++i) { auto msg_type = msg.metadata()->msg_types[i]; // Skip restricted types diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp index 6cf025e361..02de818ec1 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_messages.cpp @@ -62,7 +62,7 @@ std::unique_ptr read_transport_message(Socket &sd) sd.readBytes(reinterpret_cast(&header), sizeof(header), false, sizeof(header)); if (read_bytes != sizeof(header)) { - LOG(ERROR) << "Error peeking into the message header: " << read_bytes; + LOG(ERROR) << "Error reading the message header: " << read_bytes; return nullptr; } @@ -79,8 +79,8 @@ std::unique_ptr read_transport_message(Socket &sd) // 2. Faster - Discard sizeof(Header) bytes and hope to find a valid header afterwads // 2. Fastest - Discard all the bytes and assume the sender will re-send the message // For now we'll use the "Faster" method. - auto discarded_bytes = sd.readBytes(reinterpret_cast(&header), sizeof(header), - false, sd.getBytesReady()); + auto discarded_bytes = + sd.readBytes(reinterpret_cast(&header), sizeof(header), false); LOG(DEBUG) << "Discarded " << discarded_bytes << " bytes from fd = " << sd.getSocketFd(); }; diff --git a/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h b/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h index 3ba3a3b0d0..4bb74704d4 100644 --- a/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h +++ b/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h @@ -285,9 +285,9 @@ class SubscribeMessage : public Message { }; struct Metadata { - uint8_t version = kVersion; - ReqType type = ReqType::INVALID; - uint8_t msg_types_num = 0; + uint8_t version = kVersion; + ReqType type = ReqType::INVALID; + uint8_t msg_types_count = 0; MsgType msg_types[MAX_SUBSCRIBE_TYPES]; }; @@ -316,20 +316,19 @@ class SubscribeMessage : public Message { { Message::print(os); - std::stringstream ss; Metadata *m = metadata(); os << " metadata:" << std::endl; - os << " version : " << static_cast(m->version) << std::endl; - os << " type : " << static_cast(m->type) << std::endl; - os << " msg_types_num : " << std::dec << int(m->msg_types_num) << std::endl; - os << " msg_types : " << std::hex << std::setfill('0') << std::setw(4) + os << " version : " << static_cast(m->version) << std::endl; + os << " type : " << static_cast(m->type) << std::endl; + os << " msg_types_count : " << std::dec << int(m->msg_types_count) << std::endl; + os << " msg_types : " << std::hex << std::setfill('0') << std::setw(4) << m->msg_types[0].value; - for (int i = 1; i < m->msg_types_num; i++) { + for (int i = 1; i < m->msg_types_count; i++) { os << ", " << m->msg_types[i].value; } os << std::endl; - return os << ss.str(); + return os; } }; diff --git a/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp b/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp index 59c9c0efa7..5fc424183d 100644 --- a/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp +++ b/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp @@ -144,7 +144,7 @@ TEST(broker_server, subscribe_single_type) // Create a subscribe message SubscribeMessage subscribe; subscribe.metadata()->type = SubscribeMessage::ReqType::SUBSCRIBE; - subscribe.metadata()->msg_types_num = 1; + subscribe.metadata()->msg_types_count = 1; subscribe.metadata()->msg_types[0].value = 5; // Connect to the broker and send the message @@ -164,7 +164,7 @@ TEST(broker_server, subscribe_multiple_types) // Create a subscribe message SubscribeMessage subscribe; subscribe.metadata()->type = SubscribeMessage::ReqType::SUBSCRIBE; - subscribe.metadata()->msg_types_num = 3; + subscribe.metadata()->msg_types_count = 3; subscribe.metadata()->msg_types[0].value = 1; subscribe.metadata()->msg_types[1].value = 2; subscribe.metadata()->msg_types[2].value = 3; @@ -204,7 +204,7 @@ TEST(broker_server, unsubscribe_single_type) // Create a subscribe message SubscribeMessage subscribe; subscribe.metadata()->type = SubscribeMessage::ReqType::UNSUBSCRIBE; - subscribe.metadata()->msg_types_num = 1; + subscribe.metadata()->msg_types_count = 1; subscribe.metadata()->msg_types[0].value = 5; // Connect to the broker and send the message @@ -224,7 +224,7 @@ TEST(broker_server, unsubscribe_multiple_types) // Create a subscribe message SubscribeMessage subscribe; subscribe.metadata()->type = SubscribeMessage::ReqType::UNSUBSCRIBE; - subscribe.metadata()->msg_types_num = 3; + subscribe.metadata()->msg_types_count = 3; subscribe.metadata()->msg_types[0].value = 1; subscribe.metadata()->msg_types[1].value = 2; subscribe.metadata()->msg_types[2].value = 3; @@ -246,7 +246,7 @@ TEST(broker_server, subscribe_unsubscribe) // Create a subscribe message SubscribeMessage subscribe; subscribe.metadata()->type = SubscribeMessage::ReqType::SUBSCRIBE; - subscribe.metadata()->msg_types_num = 3; + subscribe.metadata()->msg_types_count = 3; subscribe.metadata()->msg_types[0].value = 1; subscribe.metadata()->msg_types[1].value = 2; subscribe.metadata()->msg_types[2].value = 3; @@ -279,7 +279,7 @@ TEST(broker_server, publish_internal_message) // Build a subscribe message SubscribeMessage subscribe; subscribe.metadata()->type = SubscribeMessage::ReqType::SUBSCRIBE; - subscribe.metadata()->msg_types_num = 1; + subscribe.metadata()->msg_types_count = 1; subscribe.metadata()->msg_types[0].bits = { .internal = 1, .vendor_specific = 0, From 16cc0091a84b9276ea7880dacaa6c980053af00e Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Thu, 9 Jul 2020 15:41:40 +0000 Subject: [PATCH 249/453] transport: tests: remove unused tests Remove unused, local bus/zmq, unit tests. Add the broker unit tests into GitLab CI pipeline. Signed-off-by: Vitaly Bukhovsky --- .gitlab-ci.yml | 3 + .../ieee1905_transport/test/CMakeLists.txt | 7 - .../test/ieee1905_transport_test.cpp | 721 ------------------ 3 files changed, 3 insertions(+), 728 deletions(-) delete mode 100644 framework/transport/ieee1905_transport/test/ieee1905_transport_test.cpp diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c789748001..5659353779 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -201,6 +201,9 @@ bcl_unit_tests: mapf_common_encryption_tests: extends: .run-test-in-docker +ieee1905_transport_broker_tests: + extends: .run-test-in-docker + beerocks_agent_unit_tests: extends: .run-test-in-docker diff --git a/framework/transport/ieee1905_transport/test/CMakeLists.txt b/framework/transport/ieee1905_transport/test/CMakeLists.txt index 702e85e773..55c01fc355 100644 --- a/framework/transport/ieee1905_transport/test/CMakeLists.txt +++ b/framework/transport/ieee1905_transport/test/CMakeLists.txt @@ -1,10 +1,4 @@ if(BUILD_TESTS) - # TODO: Temporarily transport tests, until local_bus/zmq dependecies are removed from the tests - # add_executable(ieee1905_transport_test ieee1905_transport_test.cpp) - # target_link_libraries(ieee1905_transport_test ieee1905_transport_lib ieee1905_transport_messages mapfcommon elpp) - # install(TARGETS ieee1905_transport_test DESTINATION bin/tests) - # add_test(NAME ieee1905_transport_test COMMAND $) - # Broker Tests add_executable(ieee1905_transport_broker_tests ieee1905_transport_broker_tests.cpp @@ -14,5 +8,4 @@ if(BUILD_TESTS) install(TARGETS ieee1905_transport_broker_tests DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}/tests) add_test(NAME ieee1905_transport_broker_tests COMMAND $) - endif() diff --git a/framework/transport/ieee1905_transport/test/ieee1905_transport_test.cpp b/framework/transport/ieee1905_transport/test/ieee1905_transport_test.cpp deleted file mode 100644 index 00bc865da4..0000000000 --- a/framework/transport/ieee1905_transport/test/ieee1905_transport_test.cpp +++ /dev/null @@ -1,721 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause-Patent - * - * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) - * - * This code is subject to the terms of the BSD+Patent license. - * See LICENSE file for more details. - */ - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Suggestions for unit testing (none of this is currently happening in this simple test program): -// ---------------------------------------------------------------------------------------------- -// connect external Tester PC (with many interfaces) to DUT network interfaces: -// - connect multiple Ethernet links -// - connect Tester Wi-Fi to DUT AP -// - connect DUT STA (EP) to Tester AP -// -// /------------------------------------------------------------------------------\ -// | | -// | | -// | Tester | -// | Linux PC | -// | Running Test Application | -// | | -// | STA AP | -// | /--------\ /--------\ /--------\ /--------\ /--------\ /--------\ /--------\ | -// | | eth1 | | eth2 | | eth3 | | eth4 | | eth5 | | wlan0 | | wlan1 | | -// \------------------------------------------------------------------------------/ -// [] | | | | | : : [] -// | | | | | : : -// | | | | | : : -// /------------------------------------------------------------------------------\ -// | | eth1 | | eth0_1 | | eth0_2 | | eth0_3 | | eth0_4 | | wlan0 | | wlan1 | | -// | \--------/ \--------/ \--------/ \--------/ \--------/ \--------/ \--------/ | -// | Excluded AP STA | -// | | -// | DUT | -// | EASY350 Platform | -// | Running Multi-AP Framework | -// | Running Dummy Agent | -// | Multi-AP Agent and Multi-AP Controller disabled | -// | | -// | | -// \------------------------------------------------------------------------------/ -// [] [] -// -// -// The Test Application on the Tester PC should be able to generate arbitrary packets on any specific interface. And capture -// all packets on all the interfaces. -// -// Generate cooked packets from Tester on each one of the above connections (one at a time) and verify that: -// 1. IEEE1905 unicast packets with DUT dest address are not looped back to any of the other Tester's interfaces. -// 2. IEEE1905 unicast packets with non-DUT dest address are forwarded to all the Tester's interfaces (flooded). (this address -// should not be the address of any interface in the setup). Verify each packet is forwarded exactly once per interface (e.g. not -// duplicated by GSWIP-L). -// 3. IEEE1905 neighbor multicast packets are not looped back to any of the Tester's interfaces. -// 4. IEEE1905 relayed multicast packets are forwarded to all of the Tester's interfaces (and not to the originating interface). -// 5. Duplicate IEEE1905 multicast packets are not forwarded. -// 6. Generate non IEEE1905 packets (multicast, unicast, etc.) - verify that they are handled normally. -// 7. Send fragmented CMDUs (many valid and invalid varieties) with a predefined messageType to which the Dummy Agent will loop-back -// the CMDUs. -// - missing fragments -// - huge CMDU (e.g. 256 fragments) -// - send fragmented CMDU that when reassembled would contain a huge TLV - this should not be looped-back by the Dummy Agent -// (the fragmentation code should drop this CMDU once the Dummy Agent tries to send it) -// - send many many interleaved threads of fragmented CMDUs -// 8. Send duplicate CMDUs with a predefined messageType to which the Dummy Agent will loop-back the CMDUs. -// - short delay between duplicate - verify duplicate is dropped -// - long delay between duplicate - verify duplicate is accepted -// - many duplicates - verify are dropped -// - duplicates from multiple interfaces -// - send many many concurrent different duplicate packets (many types of packets each duplicate many times) -// 9. Have one of the DUT ports excluded from the Transport -// - verify zero IEEE1905 packets are transmitted by the excluded interface (e.g. in all the above tests) -// - verify zero IEEE1905 packets are forwarded from this interface (when the Tester sends a IEEE1905 packet to it - e.g. in all -// the above tests). -// 10. Send many many random / rogue packets and verify the transport does not crash. -// -// Note 1: This setup could also be used to unit-test the Discovery Agent and other high level entities. -// -// Note 2: The Tester PC could be replaced with a VM and a smart switch (using VLANs) like so: -// -// /------------------------------------------------------------------------------\ -// | | -// | Tester | -// | Linux VM | -// | Running Test Application | -// | | -// | | -// | /--------\ /--------\ /--------\ /--------\ /--------\ /--------\ /--------\ | \ -// | | eth1.1 | | eth1.2 | | eth1.3 | | eth1.4 | | eth1.5 | | eth1.6 | | eth1.7 | | } VLAN interfaces -// | \--------/ \--------/ \--------/ \--------/ \--------/ \--------/ \--------/ | / -// | | -// | | -// | T1,T2,T3,T4,T5,T6,T7 <- All VLANs are tagged on this physical interface | -// | /--------\ | -// | | eth1 | | -// \------------------------------------------------------------------------------/ -// | -// | All VLANs are tagged on this link -// | -// /------------------------------------------------------------------------------\ -// | | port0 | | -// | \--------/ | -// | T1,T2,T3,T4,T5,T6,T7 <- All VLANs are configured tagged on this port | -// | | -// | Managed Switch | -// | | -// | U1 U2 U3 U4 U5 U6 U7 | } each VLAN is configured un-tagged on a single specific port -// | /--------\ /--------\ /--------\ /--------\ /--------\ /--------\ /--------\ | -// | | port1 | | port2 | | port3 | | port4 | | port5 | | port6 | | port7 | | -// \------------------------------------------------------------------------------/ -// | | | | | | | -// | | | | | | | -// | | | | | /--------\ /--------\ \ -// | | | | | | STA | | AP | } Two APs one configured for WDS mode (acting as a STA) -// | | | | | \--------/ \--------/ / -// | | | | | : : -// | | | | | : : -// -// To DUT -// - -#define MAX_IFS 16 -static std::string ieee1905_bridge_ifname; -static std::string ieee1905_ifnames[MAX_IFS]; -static bool only_configure_interfaces = false; -static bool use_unicast_address = false; -static uint8_t unicast_address[6]; -using namespace mapf; - -int fork_local_bus() -{ - pid_t pid = fork(); - mapf_assert(pid >= 0); - - if (pid != 0) - return pid; - - MAPF_INFO("staring local bus broker"); - Broker localbus(kLocalBusConf); - localbus.PrintConfig(); - localbus.Run(); - - exit(0); -} - -int fork_ieee1905_transport() -{ - pid_t pid = fork(); - mapf_assert(pid >= 0); - - if (pid != 0) - return pid; - - MAPF_INFO("staring ieee1905 transport"); - - Ieee1905Transport ieee1905_transport; - - MAPF_INFO("starting ieee1905 transport main loop..."); - ieee1905_transport.run(); - - exit(0); -} - -int isValidMacAddress(const char *mac) -{ - int digits = 0; - int seperators = 0; - - while (*mac) { - if (isxdigit(*mac)) { - digits++; - } else if (*mac == ':') { - if (digits == 0 || digits / 2 - 1 != seperators) - break; - - seperators++; - } else { - seperators = -1; - break; - } - mac++; - } - - return (digits == 12 && (seperators == 5 || seperators == 0)); -} - -bool convertStringToMacAddress(const char *address, uint8_t *mac) -{ - if (!address) { - return false; - } - int digits = 0; - int seperators = 0; - std::string cleanAddress; - - //validate mac address - while (*address) { - if (isxdigit(*address)) { - digits++; - cleanAddress += *address; - } else if (*address == ':') { - if (digits == 0 || digits / 2 - 1 != seperators) - break; - - seperators++; - } else { - seperators = -1; - break; - } - address++; - } - - if (digits == 12 && (seperators == 5 || seperators == 0)) { - unsigned long tempaddr = strtoul(cleanAddress.c_str(), NULL, 16); - - for (int i = 5; i >= 0; i--) { - mac[i] = tempaddr % 0x100; - tempaddr /= 0x100; - } - } else { - return false; - } - - return true; -} - -int main(int argc, char *argv[]) -{ - - mapf::Logger::Instance().LoggerInit("transport_test"); - - int c; - int interfaces = 0; - while ((c = getopt(argc, argv, "b:i:u:x")) != -1) { - switch (c) { - case 'b': - ieee1905_bridge_ifname = std::string(optarg); - break; - case 'i': - ieee1905_ifnames[interfaces] = std::string(optarg); - interfaces++; - break; - case 'x': - only_configure_interfaces = true; - break; - case 'u': - if (convertStringToMacAddress(optarg, unicast_address)) { - use_unicast_address = true; - } else { - fprintf(stderr, "Invalid MAC address\n"); - return false; - } - break; - case '?': - if (optopt == 'i') { - fprintf(stderr, "Option -%c requires a network interface name as an argument.\n", - optopt); - } else if (isprint(optopt)) { - fprintf(stderr, "Unknown option `-%c'.\n", optopt); - } else { - fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt); - } - // intentional fallthrough - default: - fprintf(stderr, "usage: %s [-b ] [-i ] [-x]...\n", - argv[0]); - return false; - } - } - - pid_t local_bus_pid = 0; - pid_t ieee1905_transport_pid = 0; - if (!only_configure_interfaces) { - local_bus_pid = fork_local_bus(); - ieee1905_transport_pid = fork_ieee1905_transport(); - } - - bool success = true; - - do { - MAPF_INFO("initializing local bus interface"); - LocalBusInterface bus(Context::Instance()); - bus.Init(); - - int rc; - - Poller poller; - rc = poller.Add(bus.subscriber()); - if (rc != 0) - break; - - // messageType 0x8000 is used exclusively to make sure the Ieee1905Transport proccess is up and running - MAPF_INFO("subscribing to CmduRxMessage with topic " - << CmduRxMessage::ieee1905_topic(0x8000)); - rc = bus.subscriber().Subscribe(CmduRxMessage::ieee1905_topic(0x8000)); - if (rc != 0) - break; - bus.Sync(); - - // this loop is not part of the test it is just to make sure - // the Ieee1905Transport has started (it is running in a forked process) - for (int i = 100; i > 0; i--) { - // Send a multicast CmduTxMessage on the local bus - expect a CmduRxMessage (due to multicast) - CmduTxMessage cmdu_tx_msg; - std::copy_n("\x01\x80\xc2\x00\x00\x13", 6, cmdu_tx_msg.metadata()->dst); - cmdu_tx_msg.metadata()->ether_type = ETH_P_1905_1; - cmdu_tx_msg.metadata()->msg_type = 0x8000; - cmdu_tx_msg.metadata()->length = 32; - std::fill_n(cmdu_tx_msg.data(), cmdu_tx_msg.metadata()->length, 0x00); - uint8_t ieee1905_header[] = {0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0xc0}; - std::copy_n(ieee1905_header, sizeof(ieee1905_header), cmdu_tx_msg.data()); - - MAPF_INFO("sending CmduTxMessage: " << std::endl << cmdu_tx_msg); - bool ret = bus.publisher().Send(cmdu_tx_msg); - if (!ret) { - success = false; - break; - } - - MAPF_INFO("polling..."); - rc = poller.Poll(100); - if (rc == 0) { - continue; // timeout - } - rc = poller.CheckEvent(bus.subscriber()); - if (rc != MAPF_POLLIN) { - success = false; - break; - } - - //receive the message - auto msg = bus.subscriber().Receive(); - - if (auto cmdu_rx_msg = dynamic_cast(msg.get())) { - MAPF_INFO("received CmduRxMessage (initial synchronization): " << std::endl - << *cmdu_rx_msg); - break; - } else { - MAPF_INFO("received other message: " << std::endl << *msg); - success = false; - break; - } - } - if (!success) { - MAPF_INFO("failed to synchronize with Ieee1905Transport proccess"); - break; - } - - MAPF_INFO("subscribing to CmduRxMessage with topic " - << CmduRxMessage::ieee1905_topic(0x8016)); - rc = bus.subscriber().Subscribe(CmduRxMessage::ieee1905_topic(0x8016)); - if (rc != 0) { - success = false; - break; - } - bus.Sync(); - - MAPF_INFO("subscribing to CmduTxConfirmationMessage with topic " - << CmduTxConfirmationMessage::ieee1905_topic(0x8016)); - rc = bus.subscriber().Subscribe( - CmduTxConfirmationMessage::ieee1905_topic(0x8016)); - if (rc != 0) { - success = false; - break; - } - bus.Sync(); - - // inform the 1905 Transport on the required interface configuration (as specified on the command line) - InterfaceConfigurationRequestMessage interface_configuration_request_msg; - uint32_t n = 0; - if (!ieee1905_bridge_ifname.empty()) { - using Flags = InterfaceConfigurationRequestMessage::Flags; - mapf::utils::copy_string( - interface_configuration_request_msg.metadata()->interfaces[n].ifname, - ieee1905_bridge_ifname.c_str(), IF_NAMESIZE); - interface_configuration_request_msg.metadata()->interfaces[n].flags |= Flags::IS_BRIDGE; - n++; - } - for (int i = 0; i < MAX_IFS; i++) { - if (!ieee1905_ifnames[i].empty()) { - using Flags = InterfaceConfigurationRequestMessage::Flags; - mapf::utils::copy_string( - interface_configuration_request_msg.metadata()->interfaces[n].ifname, - ieee1905_ifnames[i].c_str(), IF_NAMESIZE); - interface_configuration_request_msg.metadata()->interfaces[n].flags |= - Flags::ENABLE_IEEE1905_TRANSPORT; - n++; - } - } - interface_configuration_request_msg.metadata()->numInterfaces = n; - - MAPF_INFO("sending InterfaceConfigurationRequestMessage: " - << std::endl - << interface_configuration_request_msg); - bool ret = bus.publisher().Send(interface_configuration_request_msg); - if (!ret) { - MAPF_INFO("failed to send"); - success = false; - break; - } - - if (only_configure_interfaces) { - break; - } - - // Send a multicast CmduTxMessage on the local bus - expect a CmduRxMessage (due to multicast) - // and a CmduTxConfirmationMessage. - do { - bool got_cmdu_rx_msg = false; - bool got_cmdu_tx_confirmation_msg = false; - - CmduTxMessage cmdu_tx_msg; - std::copy_n("\x01\x80\xc2\x00\x00\x13", 6, cmdu_tx_msg.metadata()->dst); - cmdu_tx_msg.metadata()->ether_type = ETH_P_1905_1; - cmdu_tx_msg.metadata()->msg_type = 0x8016; - cmdu_tx_msg.metadata()->length = 32; - cmdu_tx_msg.metadata()->cookie = 1; - std::fill_n(cmdu_tx_msg.data(), cmdu_tx_msg.metadata()->length, 0x00); - uint8_t ieee1905_header[] = {0x00, 0x00, 0x80, 0x16, 0x00, 0x00, 0x00, 0xc0}; - std::copy_n(ieee1905_header, sizeof(ieee1905_header), cmdu_tx_msg.data()); - - MAPF_INFO("sending CmduTxMessage: " << std::endl << cmdu_tx_msg); - ret = bus.publisher().Send(cmdu_tx_msg); - if (!ret) { - MAPF_INFO("failed to send"); - success = false; - break; - } - - for (int i = 10; i > 0; i--) { - MAPF_INFO("polling..."); - rc = poller.Poll(100); - if (rc == 0) { - continue; - } - - rc = poller.CheckEvent(bus.subscriber()); - if (rc != MAPF_POLLIN) { - MAPF_INFO("unexpected event"); - success = false; - break; - } - - auto msg = bus.subscriber().Receive(); - - if (auto cmdu_rx_msg = dynamic_cast(msg.get())) { - MAPF_INFO("received CmduRxMessage: " << std::endl << *cmdu_rx_msg); - if (cmdu_rx_msg->metadata()->length != cmdu_tx_msg.metadata()->length) { - MAPF_INFO("message length mismatch"); - } else if (cmdu_rx_msg->metadata()->ether_type != - cmdu_tx_msg.metadata()->ether_type) { - MAPF_INFO("message metadata mismatch"); - } else if (cmdu_rx_msg->metadata()->msg_type != - cmdu_tx_msg.metadata()->msg_type) { - MAPF_INFO("message metadata mismatch"); - } else { - MAPF_INFO("this is the expected message"); - got_cmdu_rx_msg = true; - } - } else if (auto cmdu_tx_confirmation_msg = - dynamic_cast(msg.get())) { - MAPF_INFO("received CmduTxConfirmationMessage: " << std::endl - << *cmdu_tx_confirmation_msg); - got_cmdu_tx_confirmation_msg = true; - } else { - MAPF_INFO("received other message: " << std::endl << *msg); - } - - if (got_cmdu_rx_msg && got_cmdu_tx_confirmation_msg) { - break; - } - } - if (!(got_cmdu_rx_msg && got_cmdu_tx_confirmation_msg)) { - MAPF_INFO("did not receive all expected messages"); - success = false; - break; - } - } while (0); - - // Send a non-relayed multicast CmduTxMessage on the local bus (helps to manually verify relayed multicast mechanism) - { - CmduTxMessage cmdu_tx_msg; - std::copy_n("\x01\x80\xc2\x00\x00\x13", 6, cmdu_tx_msg.metadata()->dst); - cmdu_tx_msg.metadata()->ether_type = ETH_P_1905_1; - cmdu_tx_msg.metadata()->msg_type = 0x8017; - cmdu_tx_msg.metadata()->length = 32; - std::fill_n(cmdu_tx_msg.data(), cmdu_tx_msg.metadata()->length, 0x00); - uint8_t ieee1905_header[] = {0x00, 0x00, 0x80, 0x17, 0x00, 0x00, 0x00, 0x80}; - std::copy_n(ieee1905_header, sizeof(ieee1905_header), cmdu_tx_msg.data()); - - MAPF_INFO("sending CmduTxMessage: " << std::endl << cmdu_tx_msg); - ret = bus.publisher().Send(cmdu_tx_msg); - if (!ret) - break; - } - - // Send a relayed multicast CmduTxMessage on the local bus (helps to manually verify relayed multicast mechanism) - { - CmduTxMessage cmdu_tx_msg; - std::copy_n("\x01\x80\xc2\x00\x00\x13", 6, cmdu_tx_msg.metadata()->dst); - cmdu_tx_msg.metadata()->ether_type = ETH_P_1905_1; - cmdu_tx_msg.metadata()->msg_type = 0x8018; - cmdu_tx_msg.metadata()->length = (8) + (3 + 0); - std::fill_n(cmdu_tx_msg.data(), cmdu_tx_msg.metadata()->length, 0x00); - - uint8_t ieee1905_header[] = {0x00, 0x00, 0x80, 0x18, 0x00, 0x00, 0x00, 0xc0}; - std::copy_n(ieee1905_header, sizeof(ieee1905_header), cmdu_tx_msg.data()); - - MAPF_INFO("sending CmduTxMessage: " << std::endl << cmdu_tx_msg); - ret = bus.publisher().Send(cmdu_tx_msg); - if (!ret) - break; - } - - // Send a large CmduTxMessage on the local bus (helps to manually verify fragmentation code) - { - CmduTxMessage cmdu_tx_msg; - std::copy_n("\x01\x80\xc2\x00\x00\x13", 6, cmdu_tx_msg.metadata()->dst); - cmdu_tx_msg.metadata()->ether_type = ETH_P_1905_1; - cmdu_tx_msg.metadata()->msg_type = 0x8019; - cmdu_tx_msg.metadata()->length = 8; - std::fill_n(cmdu_tx_msg.data(), cmdu_tx_msg.metadata()->length, 0x00); - - uint8_t ieee1905_header[] = {0x00, 0x00, 0x80, 0x19, 0x00, 0x00, 0x00, 0xc0}; - std::copy_n(ieee1905_header, sizeof(ieee1905_header), cmdu_tx_msg.data()); - - uint16_t tlvlen = 1024; - uint8_t *tlv; - cmdu_tx_msg.metadata()->length += 3 + tlvlen; - tlv = cmdu_tx_msg.data() + cmdu_tx_msg.metadata()->length - (3 + tlvlen); - *tlv = 1; // tlvType - *(uint16_t *)(tlv + 1) = htons(tlvlen); // tlvLength - std::fill_n(tlv + 3, tlvlen, *tlv); - tlv = tlv + 3 + tlvlen; - - tlvlen = 0; - cmdu_tx_msg.metadata()->length += 3 + tlvlen; - tlv = cmdu_tx_msg.data() + cmdu_tx_msg.metadata()->length - (3 + tlvlen); - *tlv = 2; // tlvType - *(uint16_t *)(tlv + 1) = htons(tlvlen); // tlvLength - std::fill_n(tlv + 3, tlvlen, *tlv); - tlv = tlv + 3 + tlvlen; - - tlvlen = 1; - cmdu_tx_msg.metadata()->length += 3 + tlvlen; - tlv = cmdu_tx_msg.data() + cmdu_tx_msg.metadata()->length - (3 + tlvlen); - *tlv = 3; // tlvType - *(uint16_t *)(tlv + 1) = htons(1); // tlvLength - std::fill_n(tlv + 3, tlvlen, *tlv); - tlv = tlv + 3 + 1; - - tlvlen = 2; - cmdu_tx_msg.metadata()->length += 3 + tlvlen; - tlv = cmdu_tx_msg.data() + cmdu_tx_msg.metadata()->length - (3 + tlvlen); - *tlv = 4; // tlvType - *(uint16_t *)(tlv + 1) = htons(tlvlen); // tlvLength - std::fill_n(tlv + 3, tlvlen, *tlv); - tlv = tlv + 3 + tlvlen; - - tlvlen = 3; - cmdu_tx_msg.metadata()->length += 3 + tlvlen; - tlv = cmdu_tx_msg.data() + cmdu_tx_msg.metadata()->length - (3 + tlvlen); - *tlv = 5; // tlvType - *(uint16_t *)(tlv + 1) = htons(tlvlen); // tlvLength - std::fill_n(tlv + 3, tlvlen, *tlv); - tlv = tlv + 3 + tlvlen; - - tlvlen = 4; - cmdu_tx_msg.metadata()->length += 3 + tlvlen; - tlv = cmdu_tx_msg.data() + cmdu_tx_msg.metadata()->length - (3 + tlvlen); - *tlv = 6; // tlvType - *(uint16_t *)(tlv + 1) = htons(tlvlen); // tlvLength - std::fill_n(tlv + 3, tlvlen, *tlv); - tlv = tlv + 3 + tlvlen; - - tlvlen = 1000; - cmdu_tx_msg.metadata()->length += 3 + tlvlen; - tlv = cmdu_tx_msg.data() + cmdu_tx_msg.metadata()->length - (3 + tlvlen); - *tlv = 7; // tlvType - *(uint16_t *)(tlv + 1) = htons(tlvlen); // tlvLength - std::fill_n(tlv + 3, tlvlen, *tlv); - tlv = tlv + 3 + tlvlen; - - tlvlen = 0; - cmdu_tx_msg.metadata()->length += 3 + tlvlen; - tlv = cmdu_tx_msg.data() + cmdu_tx_msg.metadata()->length - (3 + tlvlen); - *tlv = 0; // tlvType - *(uint16_t *)(tlv + 1) = htons(tlvlen); // tlvLength - std::fill_n(tlv + 3, tlvlen, *tlv); - - MAPF_INFO("sending CmduTxMessage: " << std::endl << cmdu_tx_msg); - ret = bus.publisher().Send(cmdu_tx_msg); - if (!ret) - break; - } - - // Send a unicast CmduTxMessage on the local bus - if (use_unicast_address) { - CmduTxMessage cmdu_tx_msg; - std::copy_n(unicast_address, 6, cmdu_tx_msg.metadata()->dst); - cmdu_tx_msg.metadata()->ether_type = ETH_P_1905_1; - cmdu_tx_msg.metadata()->msg_type = 0x8020; - cmdu_tx_msg.metadata()->length = (8) + (3 + 0); - std::fill_n(cmdu_tx_msg.data(), cmdu_tx_msg.metadata()->length, 0x00); - - uint8_t ieee1905_header[] = {0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x00, 0x80}; - std::copy_n(ieee1905_header, sizeof(ieee1905_header), cmdu_tx_msg.data()); - - MAPF_INFO("sending CmduTxMessage: " << std::endl << cmdu_tx_msg); - ret = bus.publisher().Send(cmdu_tx_msg); - if (!ret) - break; - } - - // Send a multicast CmduTxMessage on the local bus - expect a CmduRxMessage (due to multicast) - // and a CmduTxConfirmationMessage. - //Done to verify that all the messages were sent on the local bus before terminating - do { - bool got_cmdu_rx_msg = false; - bool got_cmdu_tx_confirmation_msg = false; - - CmduTxMessage cmdu_tx_msg; - std::copy_n("\x01\x80\xc2\x00\x00\x13", 6, cmdu_tx_msg.metadata()->dst); - cmdu_tx_msg.metadata()->ether_type = ETH_P_1905_1; - cmdu_tx_msg.metadata()->msg_type = 0x8016; - cmdu_tx_msg.metadata()->length = 32; - cmdu_tx_msg.metadata()->cookie = 1; - std::fill_n(cmdu_tx_msg.data(), cmdu_tx_msg.metadata()->length, 0x00); - uint8_t ieee1905_header[] = {0x00, 0x00, 0x80, 0x16, 0x00, 0x00, 0x00, 0xc0}; - std::copy_n(ieee1905_header, sizeof(ieee1905_header), cmdu_tx_msg.data()); - - MAPF_INFO("sending CmduTxMessage: " << std::endl << cmdu_tx_msg); - ret = bus.publisher().Send(cmdu_tx_msg); - if (!ret) { - MAPF_INFO("failed to send"); - success = false; - break; - } - - for (int i = 10; i > 0; i--) { - MAPF_INFO("polling..."); - rc = poller.Poll(100); - if (rc == 0) { - continue; - } - - rc = poller.CheckEvent(bus.subscriber()); - if (rc != MAPF_POLLIN) { - MAPF_INFO("unexpected event"); - success = false; - break; - } - - auto msg = bus.subscriber().Receive(); - - if (auto cmdu_rx_msg = dynamic_cast(msg.get())) { - MAPF_INFO("received CmduRxMessage: " << std::endl << *cmdu_rx_msg); - if (cmdu_rx_msg->metadata()->length != cmdu_tx_msg.metadata()->length) { - MAPF_INFO("message length mismatch"); - } else if (cmdu_rx_msg->metadata()->ether_type != - cmdu_tx_msg.metadata()->ether_type) { - MAPF_INFO("message metadata mismatch"); - } else if (cmdu_rx_msg->metadata()->msg_type != - cmdu_tx_msg.metadata()->msg_type) { - MAPF_INFO("message metadata mismatch"); - } else { - MAPF_INFO("this is the expected message"); - got_cmdu_rx_msg = true; - } - } else if (auto cmdu_tx_confirmation_msg = - dynamic_cast(msg.get())) { - MAPF_INFO("received CmduTxConfirmationMessage: " << std::endl - << *cmdu_tx_confirmation_msg); - got_cmdu_tx_confirmation_msg = true; - } else { - MAPF_INFO("received other message: " << std::endl << *msg); - } - - if (got_cmdu_rx_msg && got_cmdu_tx_confirmation_msg) { - break; - } - } - if (!(got_cmdu_rx_msg && got_cmdu_tx_confirmation_msg)) { - MAPF_INFO("did not receive all expected messages"); - success = false; - break; - } - } while (0); - } while (0); - - usleep(300000); - - MAPF_INFO("terminating forked proccesses..."); - if (ieee1905_transport_pid) - kill(ieee1905_transport_pid, SIGTERM); - if (local_bus_pid) - kill(local_bus_pid, SIGTERM); - - MAPF_INFO("DONE - TEST " << (success ? "PASSED" : "FAILED")); - mapf_assert(success); - - return success ? 0 : 1; -} From 8b0b2281dd5cfa0fc1fa5260cf39442cb98b569b Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Thu, 9 Jul 2020 15:55:12 +0000 Subject: [PATCH 250/453] treewide: rename btl bus references to broker Also remove no longer used socket_thread overrides Signed-off-by: Vitaly Bukhovsky --- .../src/beerocks/slave/agent_ucc_listener.cpp | 2 +- .../backhaul_manager_thread.cpp | 68 ++++++++--------- common/beerocks/btl/CMakeLists.txt | 2 +- common/beerocks/btl/btl.cpp | 26 +++---- common/beerocks/btl/btl_broker.cpp | 75 +++++++++---------- common/beerocks/btl/include/btl/btl.h | 36 ++++----- .../src/beerocks/master/son_actions.cpp | 3 +- .../src/beerocks/master/son_master_thread.cpp | 7 +- documentation/images/plantuml/agent.wsd | 14 ++-- .../beerocks_cli/update_credentials.puml | 2 +- .../images/plantuml/beerocks_common.iuml | 14 ++-- 11 files changed, 116 insertions(+), 133 deletions(-) diff --git a/agent/src/beerocks/slave/agent_ucc_listener.cpp b/agent/src/beerocks/slave/agent_ucc_listener.cpp index acec998774..6e2ecff874 100644 --- a/agent/src/beerocks/slave/agent_ucc_listener.cpp +++ b/agent/src/beerocks/slave/agent_ucc_listener.cpp @@ -164,7 +164,7 @@ bool agent_ucc_listener::handle_dev_get_param(std::unordered_map{ + if (!broker_subscribe(std::vector{ ieee1905_1::eMessageType::ACK_MESSAGE, ieee1905_1::eMessageType::AP_AUTOCONFIGURATION_RENEW_MESSAGE, ieee1905_1::eMessageType::AP_AUTOCONFIGURATION_RESPONSE_MESSAGE, @@ -349,8 +349,8 @@ void backhaul_manager::socket_connected(Socket *sd) bool backhaul_manager::socket_disconnected(Socket *sd) { - if (from_bus(sd)) { - LOG(ERROR) << "bus socket to the controller disconnected " << intptr_t(sd) + if (from_broker(sd)) { + LOG(ERROR) << "broker socket to the controller disconnected " << intptr_t(sd) << " restarting backhaul manager"; FSM_MOVE_STATE(RESTART); return true; @@ -425,7 +425,8 @@ bool backhaul_manager::socket_disconnected(Socket *sd) return false; } - send_cmdu_to_bus(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, + bridge_info.mac); } return false; } else { @@ -537,7 +538,7 @@ void backhaul_manager::after_select(bool timeout) LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; return; } - send_cmdu_to_bus(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac); } // Run Tasks @@ -909,7 +910,7 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) break; } - if (!bus_connect(beerocks_temp_path, local_master)) { + if (!broker_connect(beerocks_temp_path, local_master)) { platform_notify_error(bpl::eErrorCode::BH_CONNECTING_TO_MASTER, ""); FSM_MOVE_STATE(RESTART); break; @@ -983,7 +984,7 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) create_backhaul_steering_response(wfa_map::tlvErrorCode::eReasonCode::RESERVED); LOG(DEBUG) << "Sending BACKHAUL_STA_STEERING_RESPONSE_MESSAGE"; - send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, bridge_info.mac); } break; } @@ -1180,8 +1181,8 @@ bool backhaul_manager::send_1905_topology_discovery_message(const std::string &i LOG(DEBUG) << "send_1905_topology_discovery_message, bridge_mac=" << bridge_info.mac << ", iface=" << iface_name; - return send_cmdu_to_bus(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac, - iface_name); + return send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac, + iface_name); } bool backhaul_manager::send_autoconfig_search_message(std::shared_ptr soc) @@ -1271,7 +1272,7 @@ bool backhaul_manager::send_autoconfig_search_message(std::shared_ptractionhdr()->direction() = beerocks::BEEROCKS_DIRECTION_CONTROLLER; LOG(DEBUG) << "sending autoconfig search message, bridge_mac=" << bridge_info.mac; - return send_cmdu_to_bus(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac); } bool backhaul_manager::send_slave_ap_metric_query_message(uint16_t mid, @@ -1699,10 +1700,7 @@ bool backhaul_manager::handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_r std::string src_mac = tlvf::mac_to_string(uds_header->src_bridge_mac); std::string dst_mac = tlvf::mac_to_string(uds_header->dst_bridge_mac); - // LOG(DEBUG) << "handle_cmdu() - received msg from " << std::string(from_bus(sd) ? "bus" : "uds") << ", src=" << src_mac - // << ", dst=" << dst_mac << ", " << int(cmdu_rx.getMessageType()); // floods the log - - if (from_bus(sd)) { + if (from_broker(sd)) { // Filter messages which are not destined to this agent if (dst_mac != network_utils::MULTICAST_1905_MAC_ADDR && dst_mac != bridge_info.mac) { @@ -1780,7 +1778,7 @@ bool backhaul_manager::handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_r } else { // Forward the data (cmdu) to bus // LOG(DEBUG) << "forwarding slave->master message, controller_bridge_mac=" << controller_bridge_mac; cmdu_rx.swap(); //swap back before forwarding - send_cmdu_to_bus(cmdu_rx, dst_mac, bridge_info.mac, length); + send_cmdu_to_broker(cmdu_rx, dst_mac, bridge_info.mac, length); } } @@ -1898,7 +1896,7 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; return false; } - send_cmdu_to_bus(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac); } // If we're already connected, send a notification to the slave @@ -2184,7 +2182,7 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr bss_out.sta_measured_uplink_rssi_dbm_enc = bss_in.sta_measured_uplink_rssi_dbm_enc; } LOG(DEBUG) << "Send AssociatedStaLinkMetrics to controller, mid = " << mid; - send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, bridge_info.mac); break; } default: { @@ -2389,7 +2387,7 @@ bool backhaul_manager::handle_multi_ap_policy_config_request(ieee1905_1::CmduMes return false; } - return send_cmdu_to_bus(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); } bool backhaul_manager::handle_associated_sta_link_metrics_query(ieee1905_1::CmduMessageRx &cmdu_rx, @@ -2434,7 +2432,7 @@ bool backhaul_manager::handle_associated_sta_link_metrics_query(ieee1905_1::Cmdu error_code_tlv->sta_mac() = mac->sta_mac(); LOG(DEBUG) << "Send a ASSOCIATED_STA_LINK_METRICS_RESPONSE_MESSAGE back to controller"; - return send_cmdu_to_bus(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); } else { sMacAddr bssid = get_sta_bssid(radio->associated_clients_map, mac->sta_mac()); if (bssid == network_utils::ZERO_MAC) { @@ -2533,7 +2531,7 @@ bool backhaul_manager::handle_client_capability_query(ieee1905_1::CmduMessageRx error_code_tlv->sta_mac() = client_info_tlv_r->client_mac(); } LOG(DEBUG) << "Send a CLIENT_CAPABILITY_REPORT_MESSAGE back to controller"; - return send_cmdu_to_bus(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); } bool backhaul_manager::handle_ap_capability_query(ieee1905_1::CmduMessageRx &cmdu_rx, @@ -2579,7 +2577,7 @@ bool backhaul_manager::handle_ap_capability_query(ieee1905_1::CmduMessageRx &cmd } LOG(DEBUG) << "Sending AP_CAPABILITY_REPORT_MESSAGE , mid: " << std::hex << (int)mid; - return send_cmdu_to_bus(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); } bool backhaul_manager::handle_ap_metrics_query(ieee1905_1::CmduMessageRx &cmdu_rx, @@ -2627,7 +2625,7 @@ bool backhaul_manager::handle_slave_ap_metrics_response(ieee1905_1::CmduMessageR if (0 == mid) { uint16_t length = message_com::get_uds_header(cmdu_rx)->length; cmdu_rx.swap(); //swap back before forwarding - return send_cmdu_to_bus(cmdu_rx, controller_bridge_mac, bridge_info.mac, length); + return send_cmdu_to_broker(cmdu_rx, controller_bridge_mac, bridge_info.mac, length); } /** @@ -2788,7 +2786,7 @@ bool backhaul_manager::handle_slave_ap_metrics_response(ieee1905_1::CmduMessageR m_ap_metric_response.clear(); LOG(DEBUG) << "Sending AP_METRICS_RESPONSE_MESSAGE, mid=" << std::hex << int(mid); - return send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, bridge_info.mac); } /** @@ -3134,7 +3132,7 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd } LOG(DEBUG) << "Sending topology response message, mid: " << std::hex << (int)mid; - return send_cmdu_to_bus(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); } bool backhaul_manager::handle_1905_higher_layer_data_message(ieee1905_1::CmduMessageRx &cmdu_rx, @@ -3161,7 +3159,7 @@ bool backhaul_manager::handle_1905_higher_layer_data_message(ieee1905_1::CmduMes return false; } LOG(DEBUG) << "sending ACK message to the originator, mid=" << std::hex << int(mid); - return send_cmdu_to_bus(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); } bool backhaul_manager::handle_1905_link_metric_query(ieee1905_1::CmduMessageRx &cmdu_rx, @@ -3318,7 +3316,7 @@ bool backhaul_manager::handle_1905_link_metric_query(ieee1905_1::CmduMessageRx & } LOG(DEBUG) << "Sending LINK_METRIC_RESPONSE_MESSAGE, mid: " << std::hex << (int)mid; - return send_cmdu_to_bus(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); } bool backhaul_manager::handle_1905_combined_infrastructure_metrics( @@ -3339,7 +3337,7 @@ bool backhaul_manager::handle_1905_combined_infrastructure_metrics( return false; } LOG(DEBUG) << "sending ACK message to the originator, mid=" << std::hex << int(mid); - return send_cmdu_to_bus(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); } bool backhaul_manager::handle_1905_topology_discovery(const std::string &src_mac, @@ -3395,7 +3393,7 @@ bool backhaul_manager::handle_1905_topology_discovery(const std::string &src_mac LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; return false; } - send_cmdu_to_bus(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac); } return true; } @@ -3569,7 +3567,7 @@ bool backhaul_manager::handle_1905_beacon_metrics_query(ieee1905_1::CmduMessageR << int(mid) << " tlv error code: " << errorSS.str(); // send the error - return send_cmdu_to_bus(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); } forward_to = radio->slave; @@ -3580,7 +3578,7 @@ bool backhaul_manager::handle_1905_beacon_metrics_query(ieee1905_1::CmduMessageR LOG(DEBUG) << "BEACON METRICS QUERY: sending ACK message to the originator mid: " << int(mid); // USED IN TESTS - send_cmdu_to_bus(cmdu_tx, src_mac, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); // continue processing return false; @@ -4539,7 +4537,7 @@ bool backhaul_manager::handle_slave_channel_selection_response(ieee1905_1::CmduM m_expected_channel_selection.responses.clear(); LOG(DEBUG) << "Sending CHANNEL_SELECTION_RESPONSE_MESSAGE, mid=" << std::hex << int(mid); - return send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, bridge_info.mac); } bool backhaul_manager::handle_backhaul_steering_request(ieee1905_1::CmduMessageRx &cmdu_rx, @@ -4563,7 +4561,7 @@ bool backhaul_manager::handle_backhaul_steering_request(ieee1905_1::CmduMessageR } LOG(DEBUG) << "Sending ACK message to the originator, mid=" << std::hex << mid; - send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, bridge_info.mac); auto channel = bh_sta_steering_req->target_channel_number(); auto oper_class = bh_sta_steering_req->operating_class(); @@ -4582,7 +4580,7 @@ bool backhaul_manager::handle_backhaul_steering_request(ieee1905_1::CmduMessageR return false; } - send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, bridge_info.mac); return false; } @@ -4604,7 +4602,7 @@ bool backhaul_manager::handle_backhaul_steering_request(ieee1905_1::CmduMessageR LOG(ERROR) << "Couldn't associate active HAL with bssid: " << bssid; LOG(DEBUG) << "Sending ACK message to the originator, mid=" << std::hex << mid; - send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, bridge_info.mac); auto response = create_backhaul_steering_response( wfa_map::tlvErrorCode::eReasonCode:: @@ -4615,7 +4613,7 @@ bool backhaul_manager::handle_backhaul_steering_request(ieee1905_1::CmduMessageR return false; } - send_cmdu_to_bus(cmdu_tx, controller_bridge_mac, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, bridge_info.mac); return false; } diff --git a/common/beerocks/btl/CMakeLists.txt b/common/beerocks/btl/CMakeLists.txt index ed1c84b1ff..31182bd4c5 100644 --- a/common/beerocks/btl/CMakeLists.txt +++ b/common/beerocks/btl/CMakeLists.txt @@ -1,7 +1,7 @@ project(btl VERSION ${prplmesh_VERSION}) message("${BoldWhite}Preparing ${BoldGreen}${PROJECT_NAME}${BoldWhite} for the ${BoldGreen}${TARGET_PLATFORM}${BoldWhite} platform${ColourReset}") -message(STATUS "${BoldGreen}Using MultiAP Framework for BTL transport${ColourReset}") +# BTL source files set(btl_sources btl.cpp btl_broker.cpp) # Set the base path for the current module diff --git a/common/beerocks/btl/btl.cpp b/common/beerocks/btl/btl.cpp index 4275cb0787..33995df3de 100644 --- a/common/beerocks/btl/btl.cpp +++ b/common/beerocks/btl/btl.cpp @@ -23,8 +23,8 @@ transport_socket_thread::~transport_socket_thread() {} bool transport_socket_thread::init() { - if (!bus_init()) { - THREAD_LOG(ERROR) << "bus_init failed"; + if (!broker_init()) { + THREAD_LOG(ERROR) << "broker_init failed"; return false; } @@ -38,26 +38,26 @@ bool transport_socket_thread::init() void transport_socket_thread::set_select_timeout(unsigned msec) { poll_timeout_ms = msec; } -bool transport_socket_thread::send_cmdu_to_bus(ieee1905_1::CmduMessageTx &cmdu_tx, - const std::string &dst_mac, - const std::string &src_mac, - const std::string &iface_name) +bool transport_socket_thread::send_cmdu_to_broker(ieee1905_1::CmduMessageTx &cmdu_tx, + const std::string &dst_mac, + const std::string &src_mac, + const std::string &iface_name) { if (!cmdu_tx.finalize()) { THREAD_LOG(ERROR) << "finalize failed"; return false; } - return send_cmdu_to_bus(cmdu_tx, dst_mac, src_mac, cmdu_tx.getMessageLength(), iface_name); + return send_cmdu_to_broker(cmdu_tx, dst_mac, src_mac, cmdu_tx.getMessageLength(), iface_name); } -bool transport_socket_thread::send_cmdu_to_bus(ieee1905_1::CmduMessage &cmdu, - const std::string &dst_mac, - const std::string &src_mac, uint16_t length, - const std::string &iface_name) +bool transport_socket_thread::send_cmdu_to_broker(ieee1905_1::CmduMessage &cmdu, + const std::string &dst_mac, + const std::string &src_mac, uint16_t length, + const std::string &iface_name) { // This method should be used by Message Routers only. It is used to forward CMDU messages from UDS socket to the BUS. - LOG_IF(!bus, FATAL) << "Bus is not allocated!"; + LOG_IF(!m_broker, FATAL) << "Broker is not connected!"; // set bridge address if (src_mac.empty()) { @@ -70,5 +70,5 @@ bool transport_socket_thread::send_cmdu_to_bus(ieee1905_1::CmduMessage &cmdu, return false; } - return bus_send(cmdu, iface_name, dst_mac, src_mac, length); + return broker_send(cmdu, iface_name, dst_mac, src_mac, length); } diff --git a/common/beerocks/btl/btl_broker.cpp b/common/beerocks/btl/btl_broker.cpp index b93118e269..064e54409e 100644 --- a/common/beerocks/btl/btl_broker.cpp +++ b/common/beerocks/btl/btl_broker.cpp @@ -22,34 +22,34 @@ using namespace beerocks::btl; using namespace beerocks::net; using namespace beerocks::transport::messages; -bool transport_socket_thread::bus_init() +bool transport_socket_thread::broker_init() { - if (bus) { - remove_socket(bus.get()); - bus->closeSocket(); - bus.reset(nullptr); + if (m_broker) { + remove_socket(m_broker.get()); + m_broker->closeSocket(); + m_broker.reset(nullptr); } auto unix_socket_path_broker = TMP_PATH "/" BEEROCKS_BROKER_UDS; - bus = std::make_unique(unix_socket_path_broker); - if (!bus) { - LOG(ERROR) << "bus == nullptr"; + m_broker = std::make_unique(unix_socket_path_broker); + if (!m_broker) { + LOG(ERROR) << "m_broker == nullptr"; return false; - } else if (!bus->getError().empty()) { - LOG(ERROR) << "Failed connecting to the broker, error:" << bus->getError(); + } else if (!m_broker->getError().empty()) { + LOG(ERROR) << "Failed connecting to the broker, error:" << m_broker->getError(); return false; } LOG(DEBUG) << "Broker socket connected on: " << unix_socket_path_broker; - add_socket(bus.get(), false); + add_socket(m_broker.get(), false); return true; } bool transport_socket_thread::configure_ieee1905_transport_interfaces( const std::string &bridge_iface, const std::vector &ifaces) { - LOG_IF(!bus, FATAL) << "Broker socket is not connected!"; + LOG_IF(!m_broker, FATAL) << "Broker socket is not connected!"; InterfaceConfigurationRequestMessage interface_configuration_request_msg; using Flags = InterfaceConfigurationRequestMessage::Flags; @@ -78,7 +78,8 @@ bool transport_socket_thread::configure_ieee1905_transport_interfaces( interface_configuration_request_msg.metadata()->numInterfaces = n; THREAD_LOG(DEBUG) << "numInterfaces=" << n; - return transport::messages::send_transport_message(*bus, interface_configuration_request_msg); + return transport::messages::send_transport_message(*m_broker, + interface_configuration_request_msg); } void transport_socket_thread::add_socket(Socket *s, bool add_to_vector) @@ -86,13 +87,10 @@ void transport_socket_thread::add_socket(Socket *s, bool add_to_vector) socket_thread::add_socket(s, add_to_vector); } -void transport_socket_thread::remove_socket(Socket *s) { socket_thread::remove_socket(s); } - -bool transport_socket_thread::read_ready(Socket *s) { return socket_thread::read_ready(s); } - -bool transport_socket_thread::bus_subscribe(const std::vector &msg_types) +bool transport_socket_thread::broker_subscribe( + const std::vector &msg_types) { - LOG_IF(!bus, FATAL) << "Broker socket not initialized!"; + LOG_IF(!m_broker, FATAL) << "Broker socket not initialized!"; if (msg_types.size() > SubscribeMessage::MAX_SUBSCRIBE_TYPES) { LOG(ERROR) << "Subscribing to " << msg_types.size() @@ -114,20 +112,20 @@ bool transport_socket_thread::bus_subscribe(const std::vectormsg_types_count; } - return transport::messages::send_transport_message(*bus, subscribe); + return transport::messages::send_transport_message(*m_broker, subscribe); } -bool transport_socket_thread::bus_connect(const std::string &beerocks_temp_path, - const bool local_master) +bool transport_socket_thread::broker_connect(const std::string &beerocks_temp_path, + const bool local_master) { return true; } -bool transport_socket_thread::bus_send(ieee1905_1::CmduMessage &cmdu, const std::string &iface_name, - const std::string &dst_mac, const std::string &src_mac, - uint16_t length) +bool transport_socket_thread::broker_send(ieee1905_1::CmduMessage &cmdu, + const std::string &iface_name, const std::string &dst_mac, + const std::string &src_mac, uint16_t length) { - LOG_IF(!bus, FATAL) << "Broker socket not initialized!"; + LOG_IF(!m_broker, FATAL) << "Broker socket not initialized!"; CmduTxMessage msg; @@ -144,12 +142,12 @@ bool transport_socket_thread::bus_send(ieee1905_1::CmduMessage &cmdu, const std: msg.metadata()->if_index = if_nametoindex(iface_name.c_str()); std::copy_n((uint8_t *)cmdu.getMessageBuff(), msg.metadata()->length, (uint8_t *)msg.data()); - return transport::messages::send_transport_message(*bus, msg); + return transport::messages::send_transport_message(*m_broker, msg); } -bool transport_socket_thread::handle_cmdu_message_bus() +bool transport_socket_thread::handle_cmdu_message_broker() { - auto msg = transport::messages::read_transport_message(*bus); + auto msg = transport::messages::read_transport_message(*m_broker); if (msg == nullptr) { THREAD_LOG(ERROR) << "Received msg is null"; return false; @@ -193,20 +191,20 @@ bool transport_socket_thread::handle_cmdu_message_bus() return false; } - if (!handle_cmdu(bus.get(), cmdu_rx)) { + if (!handle_cmdu(m_broker.get(), cmdu_rx)) { return false; } return true; } -bool transport_socket_thread::from_bus(Socket *sd) +bool transport_socket_thread::from_broker(Socket *sd) { - if (!sd || !bus) { + if (!sd || !m_broker) { return false; } - return sd->getSocketFd() == bus->getSocketFd(); + return sd->getSocketFd() == m_broker->getSocketFd(); } bool transport_socket_thread::work() @@ -263,14 +261,14 @@ bool transport_socket_thread::work() continue; } - bool bus_socket_event = bus && (bus->getSocketFd() == sd->getSocketFd()); + bool bus_socket_event = m_broker && (m_broker->getSocketFd() == sd->getSocketFd()); // '0' - socket not disconnected (bytes to read), '1' - socket disconnected, '-1' - error auto ret = socket_disconnected_uds(sd); if (ret == 1) { if (bus_socket_event) { - THREAD_LOG(FATAL) << "setting bus to nullptr"; - bus = nullptr; + THREAD_LOG(FATAL) << "setting m_broker to nullptr"; + m_broker = nullptr; } // breaking instead of continue because socket_disconnected_uds() may erase element from Select Socket Vector while iterating it break; @@ -278,11 +276,8 @@ bool transport_socket_thread::work() continue; } - // LOG(DEBUG) << "Received message on FD: " << sd->getSocketFd() - // << " (bus_socket_event = " << bus_socket_event << ")"; - if (bus_socket_event) { - if (!handle_cmdu_message_bus()) { + if (!handle_cmdu_message_broker()) { continue; } } else { diff --git a/common/beerocks/btl/include/btl/btl.h b/common/beerocks/btl/include/btl/btl.h index 28fd5b7109..7a2d305fb5 100644 --- a/common/beerocks/btl/include/btl/btl.h +++ b/common/beerocks/btl/include/btl/btl.h @@ -17,13 +17,6 @@ #include -// Forward Declarations -namespace mapf { -class Poller; -class LocalBusInterface; -class SubSocket; -} // namespace mapf - namespace beerocks { namespace btl { class transport_socket_thread : public socket_thread { @@ -45,19 +38,18 @@ class transport_socket_thread : public socket_thread { * available interfaces). * @return True on success and false otherwise. */ - bool send_cmdu_to_bus(ieee1905_1::CmduMessageTx &cmdu, const std::string &dst_mac, - const std::string &src_mac, const std::string &iface_name = ""); + bool send_cmdu_to_broker(ieee1905_1::CmduMessageTx &cmdu, const std::string &dst_mac, + const std::string &src_mac, const std::string &iface_name = ""); protected: void add_socket(Socket *s, bool add_to_vector = true) override; - void remove_socket(Socket *s) override; - bool read_ready(Socket *s) override; bool configure_ieee1905_transport_interfaces(const std::string &bridge_iface, const std::vector &ifaces); - bool from_bus(Socket *sd); - bool bus_subscribe(const std::vector &msg_types); - bool bus_connect(const std::string &beerocks_temp_path, const bool local_master); + bool from_broker(Socket *sd); + + bool broker_connect(const std::string &beerocks_temp_path, const bool local_master); + bool broker_subscribe(const std::vector &msg_types); /** * @brief Sends CDMU to transport for dispatching. @@ -70,19 +62,19 @@ class transport_socket_thread : public socket_thread { * available interfaces). * @return True on success and false otherwise. */ - bool send_cmdu_to_bus(ieee1905_1::CmduMessage &cmdu, const std::string &dst_mac, - const std::string &src_mac, uint16_t length, - const std::string &iface_name = ""); + bool send_cmdu_to_broker(ieee1905_1::CmduMessage &cmdu, const std::string &dst_mac, + const std::string &src_mac, uint16_t length, + const std::string &iface_name = ""); private: - bool bus_init(); - bool bus_send(ieee1905_1::CmduMessage &cmdu, const std::string &iface_name, - const std::string &dst_mac, const std::string &src_mac, uint16_t length); - bool handle_cmdu_message_bus(); + bool broker_init(); + bool broker_send(ieee1905_1::CmduMessage &cmdu, const std::string &iface_name, + const std::string &dst_mac, const std::string &src_mac, uint16_t length); + bool handle_cmdu_message_broker(); int poll_timeout_ms = 500; - std::unique_ptr bus; + std::unique_ptr m_broker; }; } // namespace btl diff --git a/controller/src/beerocks/master/son_actions.cpp b/controller/src/beerocks/master/son_actions.cpp index 4896823aaa..f628f30035 100644 --- a/controller/src/beerocks/master/son_actions.cpp +++ b/controller/src/beerocks/master/son_actions.cpp @@ -445,7 +445,8 @@ bool son_actions::send_cmdu_to_agent(const std::string &dest_mac, return false; } - return master_thread_ctx->send_cmdu_to_bus(cmdu_tx, dest_mac, database.get_local_bridge_mac()); + return master_thread_ctx->send_cmdu_to_broker(cmdu_tx, dest_mac, + database.get_local_bridge_mac()); } bool son_actions::send_ap_config_renew_msg(ieee1905_1::CmduMessageTx &cmdu_tx, db &database, diff --git a/controller/src/beerocks/master/son_master_thread.cpp b/controller/src/beerocks/master/son_master_thread.cpp index c944b37bfa..1d91b21f2a 100644 --- a/controller/src/beerocks/master/son_master_thread.cpp +++ b/controller/src/beerocks/master/son_master_thread.cpp @@ -94,7 +94,7 @@ bool master_thread::init() return false; } - if (!bus_subscribe(std::vector{ + if (!broker_subscribe(std::vector{ ieee1905_1::eMessageType::ACK_MESSAGE, ieee1905_1::eMessageType::AP_AUTOCONFIGURATION_SEARCH_MESSAGE, ieee1905_1::eMessageType::AP_AUTOCONFIGURATION_WSC_MESSAGE, @@ -219,10 +219,7 @@ bool master_thread::handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_rx) std::string src_mac = tlvf::mac_to_string(uds_header->src_bridge_mac); std::string dst_mac = tlvf::mac_to_string(uds_header->dst_bridge_mac); - // LOG(DEBUG) << "handle_cmdu() - received msg from " << std::string(from_bus(sd) ? "bus" : "uds") << ", src=" << src_mac - // << ", dst=" << dst_mac << ", " << print_cmdu_types(uds_header); // floods the log - - if (from_bus(sd)) { + if (from_broker(sd)) { if (src_mac == network_utils::ZERO_MAC_STRING) { LOG(ERROR) << "src_mac is zero!"; diff --git a/documentation/images/plantuml/agent.wsd b/documentation/images/plantuml/agent.wsd index 1df528c86a..dfd0567c22 100644 --- a/documentation/images/plantuml/agent.wsd +++ b/documentation/images/plantuml/agent.wsd @@ -100,12 +100,12 @@ class transport_socket_thread { #remove_socket() override #read_ready() override #configure_ieee1905_transport_interfaces() - #bus_subscribe() - #bus_connect() - #send_cmdu_to_bus() - -bus_init() - -bus_send() - -handle_cmdu_message_bus() + #broker_subscribe() + #broker_connect() + #send_cmdu_to_broker() + -broker_init() + -broker_send() + -handle_cmdu_message_broker() -bus : LocalBusInterface -poller : Poller } @@ -294,4 +294,4 @@ ap_manager -> bwl : ap_wlan_hal->switch_channel() bwl -> hostapd : CHAN_SWITCH -@enduml \ No newline at end of file +@enduml diff --git a/documentation/images/plantuml/beerocks_cli/update_credentials.puml b/documentation/images/plantuml/beerocks_cli/update_credentials.puml index e81741a386..075f270336 100644 --- a/documentation/images/plantuml/beerocks_cli/update_credentials.puml +++ b/documentation/images/plantuml/beerocks_cli/update_credentials.puml @@ -5,6 +5,6 @@ beerocks_cli -> beerocks_cli: cli_bml::update_wifi_credentials(\n args.stringArg beerocks_cli -> beerocks_cli: bml_update_wifi_credentials(\n ctx,\n al-mac.c_str()) beerocks_cli -> bml_internal: update_wifi_credentials(const sMacAddr &al_mac) bml_internal -> controller: message_com::send_cmdu(\n m_sockMaster,\n ACTION_BML_WIFI_CREDENTIALS_UPDATE_REQUEST) -controller -> controller: send_cmdu_to_bus(\n AP_AUTOCONFIGURATION_RENEW_MESSAGE,\n al_mac, db.get_local_bridge_mac()); +controller -> controller: send_cmdu_to_broker(\n AP_AUTOCONFIGURATION_RENEW_MESSAGE,\n al_mac, db.get_local_bridge_mac()); controller -> bml_internal: message_com::send_cmdu(\n m_sockMaster,\n ACTION_BML_WIFI_CREDENTIALS_UPDATE_RESPONSE) @enduml diff --git a/documentation/images/plantuml/beerocks_common.iuml b/documentation/images/plantuml/beerocks_common.iuml index 518c8fd55d..1619bfd00a 100644 --- a/documentation/images/plantuml/beerocks_common.iuml +++ b/documentation/images/plantuml/beerocks_common.iuml @@ -62,12 +62,12 @@ class transport_socket_thread { #remove_socket() override #read_ready() override #configure_ieee1905_transport_interfaces() - #bus_subscribe() - #bus_connect() - #send_cmdu_to_bus() - -bus_init() - -bus_send() - -handle_cmdu_message_bus() + #broker_subscribe() + #broker_connect() + #send_cmdu_to_broker() + -broker_init() + -broker_send() + -handle_cmdu_message_broker() -bus : LocalBusInterface -poller : Poller } @@ -77,4 +77,4 @@ socket_thread --|> transport_socket_thread transport_socket_thread --* Poller transport_socket_thread --* LocalBusInterface -@enduml \ No newline at end of file +@enduml From 0f6e5646e6b4d9add4d4f617855e0ee0272bf842 Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Thu, 9 Jul 2020 17:00:42 +0000 Subject: [PATCH 251/453] cppcheck: mapf issues cleanup While moving stuff around mapf modules, fix some cppcheck issues Signed-off-by: Vitaly Bukhovsky --- ci/cppcheck/cppcheck_existing_issues.txt | 20 ------------------- framework/common/encryption.cpp | 17 +++++++--------- framework/common/include/mapf/common/logger.h | 8 ++++---- framework/common/logger.cpp | 20 +++++++++---------- framework/common/test/encryption_test.cpp | 3 +-- .../ieee1905_transport/ieee1905_transport.h | 2 +- .../ieee1905_transport_local_bus.cpp | 2 +- .../ieee1905_transport_packet_processing.cpp | 11 +++++----- .../transport/ieee1905_transport_messages.h | 8 ++++---- 9 files changed, 34 insertions(+), 57 deletions(-) diff --git a/ci/cppcheck/cppcheck_existing_issues.txt b/ci/cppcheck/cppcheck_existing_issues.txt index 7695660119..07bba2ae39 100644 --- a/ci/cppcheck/cppcheck_existing_issues.txt +++ b/ci/cppcheck/cppcheck_existing_issues.txt @@ -180,19 +180,6 @@ controller/src/beerocks/master/tasks/rdkb/rdkb_wlan_task_db.cpp: style: Paramete controller/src/beerocks/master/tasks/task.cpp: performance: Function parameter 'mac' should be passed by const reference. [passedByValue]void task::add_pending_mac(std::string mac, beerocks_message::eActionOp_CONTROL action_op) controller/src/beerocks/master/tasks/task.cpp: performance: Function parameter 'node_mac' should be passed by const reference. [passedByValue]task::task(std::string task_name_, std::string node_mac) controller/src/beerocks/master/tasks/task.cpp: performance: Function parameter 'task_name_' should be passed by const reference. [passedByValue]task::task(std::string task_name_, std::string node_mac) -framework/common/encryption.cpp: style: Variable 'kdf_iter.i' is assigned a value that is never used. [unreadVariable] kdf_iter.i = htonl(iter); -framework/common/encryption.cpp: style: Variable 'kdf_key_length.i' is assigned a value that is never used. [unreadVariable] kdf_key_length.i = htonl(sizeof(keys.keys) * 8); -framework/common/encryption.cpp: style: struct member 'Anonymous1::emsk' is never used. [unusedStructMember] uint8_t emsk[32]; -framework/common/include/mapf/common/logger.h: performance: Function parameter 'param' should be passed by const reference. [passedByValue] void set_file_path(std::string param) { file_path_ = param; } -framework/common/include/mapf/common/logger.h: performance: Function parameter 'param' should be passed by const reference. [passedByValue] void set_level(std::string param) { level_ = param; } -framework/common/include/mapf/common/message.h: style: Local variable 'frame' shadows outer function [shadowFunction] for (auto frame : frames) -framework/common/logger.cpp: performance: Function parameter 'logger_name' should be passed by const reference. [passedByValue]void Logger::Config::SetValuesFromJson(struct json_object *jlogger, std::string logger_name) -framework/common/logger.cpp: style: Condition '!init_performed' is always true [knownConditionTrueFalse] if (!init_performed) { -framework/common/logger.cpp: style: The scope of the variable 'length' can be reduced. [variableScope] int fd = -1, length = -1, i = 0, ret = 0; -framework/common/logger.cpp: style: Variable 'length' is assigned a value that is never used. [unreadVariable] int fd = -1, length = -1, i = 0, ret = 0; -framework/common/test/encryption_test.cpp: performance: Function parameter 'message' should be passed by const reference. [passedByValue]static bool check(int &errors, bool check, std::string message) -framework/common/test/encryption_test.cpp: style: Variable 'key1_length' is assigned a value that is never used. [unreadVariable] key1_length = sizeof(key1); -framework/common/test/message_test.cpp: style: Local variable 'f1' shadows outer variable [shadowVariable] mapf::Message::Frame f1; framework/external/easylogging/easylogging++.cc: information: This file is not analyzed. Cppcheck failed to extract a valid configuration. Use -v for more details. [noValidConfiguration] framework/platform/bpl/common/utils/utils.cpp: performance: Function parameter 'additional_chars' should be passed by const reference. [passedByValue]void ltrim(std::string &str, std::string additional_chars) framework/platform/bpl/common/utils/utils.cpp: performance: Function parameter 'additional_chars' should be passed by const reference. [passedByValue]void rtrim(std::string &str, std::string additional_chars) @@ -222,10 +209,3 @@ framework/tlvf/test/tlvf_test.cpp: style: The scope of the variable 'expected' c framework/tlvf/test/tlvf_test.cpp: style: Variable 'tlv1' is assigned a value that is never used. [unreadVariable] auto tlv1 = msg.addClass(); framework/tlvf/test/tlvf_test.cpp: style: Variable 'tlv2' is assigned a value that is never used. [unreadVariable] auto tlv2 = msg.addClass(); framework/tlvf/test/tlvf_test.cpp: style: Variable 'tlv3' is assigned a value that is never used. [unreadVariable] auto tlv3 = msg.addClass(); -framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp: style: C-style pointer casting [cstyleCast] Ieee1905CmduHeader *ch = (Ieee1905CmduHeader *)packet.payload.iov_base; -framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp: style: C-style pointer casting [cstyleCast] Ieee1905CmduHeader *ch = (Ieee1905CmduHeader *)packet.payload.iov_base; -framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp: style: C-style pointer casting [cstyleCast] Ieee1905CmduHeader *ch = (Ieee1905CmduHeader *)packet.payload.iov_base; -framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp: style: C-style pointer casting [cstyleCast] Ieee1905CmduHeader *ch = (Ieee1905CmduHeader *)packet.payload.iov_base; -framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp: style: Parameter 'packet' can be declared with const [constParameter]bool Ieee1905Transport::verify_packet(Packet &packet) -framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h: style: C-style pointer casting [cstyleCast] return (Metadata *)frames().back().data(); -framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h: style: C-style pointer casting [cstyleCast] Metadata *metadata() const { return (Metadata *)frames().back().data(); }; diff --git a/framework/common/encryption.cpp b/framework/common/encryption.cpp index 38b1b12171..875974ef97 100644 --- a/framework/common/encryption.cpp +++ b/framework/common/encryption.cpp @@ -429,7 +429,8 @@ void wps_calculate_keys(const diffie_hellman &dh, const uint8_t *remote_pubkey, struct { uint8_t authkey[32]; uint8_t keywrapkey[16]; - uint8_t emsk[32]; + // Currently unused, commented out to prevent cppcheck warnings + // uint8_t emsk[32]; } keys; uint8_t buf[3][32]; } keys; @@ -440,23 +441,19 @@ void wps_calculate_keys(const diffie_hellman &dh, const uint8_t *remote_pubkey, // The output is stored in the memory buffer pointed by 'res', which must be // "SHA256_MAC_LEN" bytes long (ie. 're_len' must always be "SHA256_MAC_LEN", // even if it is an input argument) - // - union { - uint32_t i; - uint8_t buf[4]; - } kdf_iter, kdf_key_length; - kdf_key_length.i = htonl(sizeof(keys.keys) * 8); + uint32_t kdf_key_length = htonl(sizeof(keys.keys) * 8); std::string personalization_string("Wi-Fi Easy and Secure Key Derivation"); for (unsigned iter = 1; iter < sizeof(keys) / 32; iter++) { - kdf_iter.i = htonl(iter); + uint32_t kdf_iter = htonl(iter); hmac hmac_iter(kdk, sizeof(kdk)); - hmac_iter.update(kdf_iter.buf, sizeof(kdf_iter.buf)); + hmac_iter.update(reinterpret_cast(&kdf_iter), sizeof(kdf_iter)); hmac_iter.update(reinterpret_cast(personalization_string.data()), personalization_string.length()); - hmac_iter.update(kdf_key_length.buf, sizeof(kdf_key_length.buf)); + hmac_iter.update(reinterpret_cast(&kdf_key_length), + sizeof(kdf_key_length)); static_assert(sizeof(keys.buf[1]) == 32, "Correct size"); hmac_iter.digest(keys.buf[iter - 1]); } diff --git a/framework/common/include/mapf/common/logger.h b/framework/common/include/mapf/common/logger.h index 40eb630d4b..c148374aee 100644 --- a/framework/common/include/mapf/common/logger.h +++ b/framework/common/include/mapf/common/logger.h @@ -38,8 +38,8 @@ class Logger { class Config { public: Config() {} - void set_level(std::string param) { level_ = param; } - void set_file_path(std::string param) { file_path_ = param; } + void set_level(const std::string ¶m) { level_ = param; } + void set_file_path(const std::string ¶m) { file_path_ = param; } void set_write_to_syslog(bool param) { write_to_syslog_ = param; } void set_write_to_console(bool param) { write_to_console_ = param; } void set_write_to_file(bool param) { write_to_file_ = param; } @@ -53,7 +53,7 @@ class Logger { bool write_to_file() { return write_to_file_; } size_t max_file_size() { return max_file_size_; } size_t log_flush_threshold() { return log_flush_threshold_; } - int SetValuesFromJson(std::string file_path, std::string logger_name); + int SetValuesFromJson(const std::string &file_path, const std::string &logger_name); std::string ToEasyLoggingString(); private: @@ -61,7 +61,7 @@ class Logger { bool write_to_syslog_ = false, write_to_console_ = true, write_to_file_ = false; size_t max_file_size_ = 1024, log_flush_threshold_ = 100; const char *kMessageFormat = "%datetime{%H:%m:%s} [%proc] [%level] %fbase[%line]: %msg"; - void SetValuesFromJson(struct json_object *jlogger, std::string logger_name); + void SetValuesFromJson(struct json_object *jlogger, const std::string &logger_name); }; public: diff --git a/framework/common/logger.cpp b/framework/common/logger.cpp index 6ec3d5dfce..90fb32c44b 100644 --- a/framework/common/logger.cpp +++ b/framework/common/logger.cpp @@ -30,27 +30,27 @@ static inline std::string const bool_to_string(bool b) static void *watch_log_file(void *args) { const char *logger_name = (const char *)args; - int fd = -1, length = -1, i = 0, ret = 0; - int event_buf_len = (sizeof(struct inotify_event) + 16) * 1024; + int event_buf_len = (sizeof(struct inotify_event) + 16) * 1024; char buffer[event_buf_len]; struct inotify_event *fileEvent; - fd = inotify_init(); + int fd = inotify_init(); if (fd < 0) { return nullptr; } - ret = inotify_add_watch(fd, std::string(CONF_FILE_PATH).c_str(), - IN_MODIFY | IN_CLOSE_WRITE | IN_IGNORED | IN_DELETE_SELF); + int ret = inotify_add_watch(fd, std::string(CONF_FILE_PATH).c_str(), + IN_MODIFY | IN_CLOSE_WRITE | IN_IGNORED | IN_DELETE_SELF); if (ret < 0) { return nullptr; } while (1) { - length = read(fd, buffer, event_buf_len); + int length = read(fd, buffer, event_buf_len); if (length < 0) { MAPF_ERR("can't watch logger configuration file"); } else { + int i = 0; while (i < length) { fileEvent = (struct inotify_event *)&buffer[i]; if (fileEvent->mask) { @@ -92,9 +92,9 @@ void Logger::LoggerInit(const char *logger_name) LoggerConfig(logger_name); static bool init_performed = false; if (!init_performed) { + init_performed = true; el::Helpers::installCustomFormatSpecifier(el::CustomFormatSpecifier("%proc", get_name)); #ifdef USE_INOTIFY - init_performed = true; pthread_t watchThread; int rc = pthread_create(&watchThread, NULL, watch_log_file, (void *)logger_name); if (rc) @@ -137,7 +137,7 @@ void Logger::LoggerConfig(Logger::Config &cfg) el::Loggers::reconfigureLogger(DEFAULT_LOGGER_NAME, conf); } -int Logger::Config::SetValuesFromJson(std::string file_path, std::string logger_name) +int Logger::Config::SetValuesFromJson(const std::string &file_path, const std::string &logger_name) { struct json_object *jobj = json_object_from_file(file_path.c_str()); if (!jobj) { @@ -150,7 +150,7 @@ int Logger::Config::SetValuesFromJson(std::string file_path, std::string logger_ SetValuesFromJson(jlogger, logger_name); } - if (std::string(logger_name).compare(DEFAULT_LOGGER_NAME) != 0) //string are not equal + if (logger_name.compare(DEFAULT_LOGGER_NAME) != 0) //string are not equal { if (json_object_object_get_ex(jobj, logger_name.c_str(), &jlogger)) { SetValuesFromJson(jlogger, logger_name); @@ -160,7 +160,7 @@ int Logger::Config::SetValuesFromJson(std::string file_path, std::string logger_ return 0; } -void Logger::Config::SetValuesFromJson(struct json_object *jlogger, std::string logger_name) +void Logger::Config::SetValuesFromJson(struct json_object *jlogger, const std::string &logger_name) { struct json_object *jfile, *jtmp; if (json_object_object_get_ex(jlogger, "level", &jtmp)) { diff --git a/framework/common/test/encryption_test.cpp b/framework/common/test/encryption_test.cpp index 71e4012600..1f9ab480d5 100644 --- a/framework/common/test/encryption_test.cpp +++ b/framework/common/test/encryption_test.cpp @@ -12,7 +12,7 @@ #include -static bool check(int &errors, bool check, std::string message) +static bool check(int &errors, bool check, const std::string &message) { if (check) { MAPF_INFO(" OK ") << message; @@ -39,7 +39,6 @@ int main() std::fill(key1, key1 + key1_length, 1); std::fill(key2, key2 + key2_length, 2); - key1_length = sizeof(key1); uint8_t mac[6] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66}; uint8_t authkey1[32]; uint8_t keywrapkey1[16]; diff --git a/framework/transport/ieee1905_transport/ieee1905_transport.h b/framework/transport/ieee1905_transport/ieee1905_transport.h index 44b08016bd..0eb12d39c0 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport.h +++ b/framework/transport/ieee1905_transport/ieee1905_transport.h @@ -297,7 +297,7 @@ class Ieee1905Transport { // void handle_packet(Packet &packet); void update_neighbours(const Packet &packet); - bool verify_packet(Packet &packet); + bool verify_packet(const Packet &packet); bool de_duplicate_packet(Packet &packet); void remove_packet_from_de_duplication_map(const Packet &packet); bool de_fragment_packet(Packet &packet); diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp index 59f0d4bb35..3726b40776 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_local_bus.cpp @@ -145,7 +145,7 @@ bool Ieee1905Transport::send_packet_to_broker(Packet &packet) std::copy_n((uint8_t *)packet.payload.iov_base, packet.payload.iov_len, msg.data()); if (packet.ether_type == ETH_P_1905_1) { - Ieee1905CmduHeader *ch = (Ieee1905CmduHeader *)packet.payload.iov_base; + Ieee1905CmduHeader *ch = reinterpret_cast(packet.payload.iov_base); msg.metadata()->msg_type = ntohs(ch->messageType); msg.metadata()->relay = ch->GetRelayIndicator() ? 1 : 0; } else { diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp index de6d013963..fe29bb165d 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_packet_processing.cpp @@ -89,7 +89,7 @@ void Ieee1905Transport::handle_packet(Packet &packet) } // do some basic sanity checking on the packet -bool Ieee1905Transport::verify_packet(Packet &packet) +bool Ieee1905Transport::verify_packet(const Packet &packet) { if (packet.ether_type == ETH_P_1905_1) { // verify minimum packet length (should at least contain an IEEE1905 header + End of Message TLV) @@ -99,7 +99,7 @@ bool Ieee1905Transport::verify_packet(Packet &packet) return false; } - Ieee1905CmduHeader *ch = (Ieee1905CmduHeader *)packet.payload.iov_base; + Ieee1905CmduHeader *ch = reinterpret_cast(packet.payload.iov_base); if (ch->messageVersion > ieee1905_max_message_version) { MAPF_DBG("packet verification failed - unsupported IEEE1905 messageVersion " << (unsigned)ch->messageVersion << "."); @@ -231,7 +231,7 @@ bool Ieee1905Transport::de_fragment_packet(Packet &packet) return true; } - Ieee1905CmduHeader *ch = (Ieee1905CmduHeader *)packet.payload.iov_base; + Ieee1905CmduHeader *ch = reinterpret_cast(packet.payload.iov_base); if (ch->fragmentId == 0 && ch->GetLastFragmentIndicator() == 1) { return true; // not a fragmented CMDU. } @@ -505,7 +505,8 @@ bool Ieee1905Transport::forward_packet_single(Packet &packet) forward_to_network_interfaces = true; } - Ieee1905CmduHeader *ch = (Ieee1905CmduHeader *)packet.payload.iov_base; + Ieee1905CmduHeader *ch = + reinterpret_cast(packet.payload.iov_base); if (ch->GetRelayIndicator()) { forward_to_network_interfaces = true; } @@ -611,7 +612,7 @@ bool Ieee1905Transport::forward_packet(Packet &packet) return true; } // 2. Message is relayed multicast - Ieee1905CmduHeader *ch = (Ieee1905CmduHeader *)packet.payload.iov_base; + Ieee1905CmduHeader *ch = reinterpret_cast(packet.payload.iov_base); if (!ch->GetRelayIndicator()) { return true; } diff --git a/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h b/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h index 4bb74704d4..481e02578c 100644 --- a/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h +++ b/framework/transport/ieee1905_transport/include/mapf/transport/ieee1905_transport_messages.h @@ -190,7 +190,7 @@ class CmduXxMessage : public Message { } } - Metadata *metadata() const { return (Metadata *)frames().back().data(); }; + Metadata *metadata() const { return reinterpret_cast(frames().back().data()); }; uint8_t *data() const { @@ -309,7 +309,7 @@ class SubscribeMessage : public Message { { mapf_assert(!frames().empty()); - return (Metadata *)frames().back().data(); + return reinterpret_cast(frames().back().data()); }; virtual std::ostream &print(std::ostream &os) const override @@ -366,7 +366,7 @@ class CmduTxConfirmationMessage : public Message { { mapf_assert(!frames().empty()); - return (Metadata *)frames().back().data(); + return reinterpret_cast(frames().back().data()); }; virtual std::ostream &print(std::ostream &os) const override @@ -437,7 +437,7 @@ class InterfaceConfigurationMessage : public Message { } } - Metadata *metadata() const { return (Metadata *)frames().back().data(); }; + Metadata *metadata() const { return reinterpret_cast(frames().back().data()); }; virtual std::ostream &print(std::ostream &os) const override { From 2a30392c1c893d4d44c3a928c2c05368189035cf Mon Sep 17 00:00:00 2001 From: Vitaly Bukhovsky Date: Sun, 12 Jul 2020 16:24:32 +0000 Subject: [PATCH 252/453] broker: interface vs inheritance refactoring Refactor the Broker to accept an EventLoop via constructor instead of inheriting a specific implementation. This allows a more generic use of the Broker (using different EventLoops) and better testability. The Broker does not accept a completley generic EventLoop but expects a Socket based one. This simplifies the Broker's implementation as it's main purpose is to send messages (over sockets). Signed-off-by: Vitaly Bukhovsky --- .../ieee1905_transport/ieee1905_transport.cpp | 83 +++++---- .../ieee1905_transport_broker.cpp | 169 +++++++++--------- .../ieee1905_transport_broker.h | 52 ++++-- .../ieee1905_transport_network.cpp | 16 +- .../test/ieee1905_transport_broker_tests.cpp | 49 +++-- 5 files changed, 221 insertions(+), 148 deletions(-) diff --git a/framework/transport/ieee1905_transport/ieee1905_transport.cpp b/framework/transport/ieee1905_transport/ieee1905_transport.cpp index ff186cf3e1..8bdc2d0989 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport.cpp @@ -7,6 +7,8 @@ */ #include +#include + #include #include "ieee1905_transport.h" @@ -18,12 +20,31 @@ namespace transport { using broker::BrokerServer; +////////////////////////////////////////////////////////////////////////////// +////////////////////////// Local Module Definitions ////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +// Number of concurrent connections on the server socket +static constexpr int listen_buffer_size = 10; + +////////////////////////////////////////////////////////////////////////////// +/////////////////////////////// Implementation /////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + void Ieee1905Transport::run() { - m_broker = std::make_unique(TMP_PATH "/" BEEROCKS_BROKER_UDS); - LOG_IF(!m_broker, FATAL) << "Failed creating broker server!"; + // Broker server UDS socket + SocketServer broker_server_socket(std::string(TMP_PATH "/" BEEROCKS_BROKER_UDS), + listen_buffer_size); - LOG(INFO) << "starting 1905 transport."; + // Broker socket based event loop + SocketEventLoop broker_event_loop; + + LOG(INFO) << "Starting 1905 transport..."; + + // Create the broker server + m_broker = std::make_unique(broker_server_socket, broker_event_loop); + LOG_IF(!m_broker, FATAL) << "Failed creating broker server!"; // Register broker handlers for internal and external messages m_broker->register_external_message_handler( @@ -55,33 +76,35 @@ void Ieee1905Transport::run() }); // Add the netlink socket into the broker's event loop - m_broker->add_event( - netlink_socket, - { - // Accept incoming connections - .on_read = - [&](BrokerServer::EventType socket, BrokerServer::EventLoopType &loop) { - LOG(DEBUG) << "incoming message on the netlink socket"; - handle_netlink_pollin_event(); - return true; - }, - - // Not implemented - .on_write = nullptr, - .on_timeout = nullptr, - - // Fail on server socket disconnections or errors - .on_disconnect = - [&](BrokerServer::EventType socket, BrokerServer::EventLoopType &loop) { - LOG(ERROR) << "netlink socket disconnected"; - return false; - }, - .on_error = - [&](BrokerServer::EventType socket, BrokerServer::EventLoopType &loop) { - LOG(ERROR) << "netlink socket error"; - return false; - }, - }); + broker_event_loop.add_event(netlink_socket, + { + // Accept incoming connections + .on_read = + [&](BrokerServer::BrokerEventLoop::EventType socket, + BrokerServer::BrokerEventLoop::EventLoopType &loop) { + LOG(DEBUG) << "incoming message on the netlink socket"; + handle_netlink_pollin_event(); + return true; + }, + + // Not implemented + .on_write = nullptr, + .on_timeout = nullptr, + + // Fail on server socket disconnections or errors + .on_disconnect = + [&](BrokerServer::BrokerEventLoop::EventType socket, + BrokerServer::BrokerEventLoop::EventLoopType &loop) { + LOG(ERROR) << "netlink socket disconnected"; + return false; + }, + .on_error = + [&](BrokerServer::BrokerEventLoop::EventType socket, + BrokerServer::BrokerEventLoop::EventLoopType &loop) { + LOG(ERROR) << "netlink socket error"; + return false; + }, + }); // Run the broker event loop for (;;) { diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp index b1e59eb58b..9ebf82f40f 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_broker.cpp @@ -24,13 +24,6 @@ namespace beerocks { namespace transport { namespace broker { -////////////////////////////////////////////////////////////////////////////// -////////////////////////// Local Module Definitions ////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -// Number of concurrent connections on the server socket -static constexpr int listen_buffer_size = 10; - ////////////////////////////////////////////////////////////////////////////// /////////////////////////// Local Module Functions /////////////////////////// ////////////////////////////////////////////////////////////////////////////// @@ -48,60 +41,73 @@ static bool is_restricted_type(uint32_t type) /////////////////////////// Broker Implementation //////////////////////////// ////////////////////////////////////////////////////////////////////////////// -BrokerServer::BrokerServer(const std::string &broker_uds_path, SocketEventLoop::TimeoutType timeout) - : SocketEventLoop(timeout), m_broker_uds_path(broker_uds_path) +BrokerServer::BrokerServer(SocketServer &broker_server, BrokerEventLoop &event_loop) + : m_broker_server(std::make_shared(broker_server)), + m_broker_event_loop(event_loop) { - // Server sockets event handlers - EventHandlers server_socket_handlers{ - // Accept incoming connections - .on_read = - [&](EventType socket, EventLoopType &loop) { - // cppcheck falsely detects the call to socket_connected() as a call to a - // virtual method from whithin the constructor, so suppress this warning, - // by explicitly calling BrokerServer::socket_connected(). - - // Handle connections to one of the server sockets - if (!BrokerServer::socket_connected( - std::dynamic_pointer_cast(socket))) { - // NOTE: Do NOT stop the broker on connection errors... - } - - return true; - }, - - // Not implemented - .on_write = nullptr, - .on_timeout = nullptr, - - // Fail on server socket disconnections or errors - .on_disconnect = - [&](EventType socket, EventLoopType &loop) { - LOG(ERROR) << "Broker socket disconnected!"; - return false; - }, - .on_error = - [&](EventType socket, EventLoopType &loop) { - LOG(ERROR) << "Broker socket error!"; - return false; - }, - }; - - // Start the broker server socket - m_broker_socket_uds = std::make_shared(m_broker_uds_path, listen_buffer_size); - LOG_IF(!m_broker_socket_uds, FATAL) << "Failed allocating memory!"; + LOG_IF(!m_broker_server, FATAL) << "Failed allocating memory!"; // Check for errors - LOG_IF(!m_broker_socket_uds->getError().empty(), FATAL) - << "Failed opening UDS socket: " << m_broker_uds_path - << " [ERROR: " << m_broker_socket_uds->getError() << "]"; + LOG_IF(!m_broker_server->getError().empty(), FATAL) + << "Failed opening server socket: " << m_broker_server + << " [ERROR: " << m_broker_server->getError() << "]"; // Add the socket to the poll - LOG_IF(!add_event(m_broker_socket_uds, server_socket_handlers), FATAL) + LOG_IF( + !m_broker_event_loop.add_event( + m_broker_server, + { + // Accept incoming connections + .on_read = + [&](BrokerEventLoop::EventType socket, BrokerEventLoop::EventLoopType &loop) { + // cppcheck falsely detects the call to socket_connected() as a call to a + // virtual method from whithin the constructor, so suppress this warning, + // by explicitly calling BrokerServer::socket_connected(). + + // Handle connections to one of the server sockets + if (!BrokerServer::socket_connected( + std::dynamic_pointer_cast(socket))) { + // NOTE: Do NOT stop the broker on connection errors... + } + + return true; + }, + + // Not implemented + .on_write = nullptr, + .on_timeout = nullptr, + + // Fail on server socket disconnections or errors + .on_disconnect = + [&](BrokerEventLoop::EventType socket, BrokerEventLoop::EventLoopType &loop) { + LOG(ERROR) << "Broker socket disconnected!"; + return false; + }, + .on_error = + [&](BrokerEventLoop::EventType socket, BrokerEventLoop::EventLoopType &loop) { + LOG(ERROR) << "Broker socket error!"; + return false; + }, + }), + FATAL) << "Failed adding the broker socket into the poll"; - LOG(INFO) << "Listening on UDS: " << m_broker_uds_path; + LOG(INFO) << "Broker server is running!"; +} + +bool BrokerServer::add_event(BrokerEventLoop::EventType event, + BrokerEventLoop::EventHandlers handlers) +{ + return m_broker_event_loop.add_event(event, handlers); +} + +bool BrokerServer::del_event(BrokerEventLoop::EventType event) +{ + return m_broker_event_loop.del_event(event); } +int BrokerServer::run() { return m_broker_event_loop.run(); } + bool BrokerServer::publish(const messages::Message &msg) { messages::SubscribeMessage::MsgType msg_opcode; @@ -282,37 +288,36 @@ bool BrokerServer::socket_connected(std::shared_ptr sd) LOG(DEBUG) << "Accepted new connection, fd = " << new_socket->getSocketFd(); - // Socket event handlers - SocketEventLoop::EventHandlers socket_handlers{ - // Handle incoming data - .on_read = - [&](SocketEventLoop::EventType socket, SocketEventLoop::EventLoopType &loop) { - // NOTE: Do NOT stop the broker on parsing errors... - handle_msg(socket); - return true; - }, - - // Not implemented - .on_write = nullptr, - .on_timeout = nullptr, - - // Remove the socket on disconnections or errors - .on_disconnect = - [&](SocketEventLoop::EventType socket, SocketEventLoop::EventLoopType &loop) { - // NOTE: Do NOT stop the broker on errors... - socket_disconnected(socket); - return true; - }, - .on_error = - [&](SocketEventLoop::EventType socket, SocketEventLoop::EventLoopType &loop) { - // NOTE: Do NOT stop the broker on errors... - socket_disconnected(socket); - return true; - }, - }; - // Add the newly accepted socket into the poll - if (!add_event(new_socket, socket_handlers)) { + if (!m_broker_event_loop.add_event( + new_socket, + { + // Handle incoming data + .on_read = + [&](BrokerEventLoop::EventType socket, BrokerEventLoop::EventLoopType &loop) { + // NOTE: Do NOT stop the broker on parsing errors... + handle_msg(socket); + return true; + }, + + // Not implemented + .on_write = nullptr, + .on_timeout = nullptr, + + // Remove the socket on disconnections or errors + .on_disconnect = + [&](BrokerEventLoop::EventType socket, BrokerEventLoop::EventLoopType &loop) { + // NOTE: Do NOT stop the broker on errors... + socket_disconnected(socket); + return true; + }, + .on_error = + [&](BrokerEventLoop::EventType socket, BrokerEventLoop::EventLoopType &loop) { + // NOTE: Do NOT stop the broker on errors... + socket_disconnected(socket); + return true; + }, + })) { LOG(ERROR) << "Failed adding new socket into the poll!"; return false; } diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_broker.h b/framework/transport/ieee1905_transport/ieee1905_transport_broker.h index a00e0f780d..fc8384716d 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_broker.h +++ b/framework/transport/ieee1905_transport/ieee1905_transport_broker.h @@ -9,7 +9,7 @@ #ifndef BROKER_SERVER_H #define BROKER_SERVER_H -#include +#include #include @@ -26,13 +26,18 @@ namespace broker { * Implements a broker server that is responsible for the internal communication * between the different prplMesh components (transport, controller, agent etc.) * - * The broker accepts connection over a UDS file. - * Once connected to the server, a client can subscribe CMDU types. + * The broker accepts connection over a SocketServer. + * Once connected to the server, a client can subscribe to CMDU types. * Message filtering is implemented inside the server, so that clients receive only * the message types they subscribed to. */ -class BrokerServer : public SocketEventLoop { +class BrokerServer { public: + /** + * The type of the supported EventLoop. + */ + using BrokerEventLoop = EventLoop, std::chrono::milliseconds>; + /** * @brief Transport messages (@see Message) handler function definition. * @@ -50,15 +55,32 @@ class BrokerServer : public SocketEventLoop { * * @param [in] broker_uds_path The path and file name to the server UDS file. */ - explicit BrokerServer( - const std::string &broker_uds_path, - SocketEventLoop::TimeoutType timeout = SocketEventLoop::TimeoutType::min()); + explicit BrokerServer(SocketServer &broker_server, BrokerEventLoop &event_loop); /** * Destructor. */ virtual ~BrokerServer() = default; + /** + * @brief Add an event to the Broker's event loop. + * @see EventLoop::add_event + */ + virtual bool add_event(BrokerEventLoop::EventType event, + BrokerEventLoop::EventHandlers handlers); + + /** + * @brief Delete an event from the Broker's event loop. + * @see EventLoop::del_event + */ + virtual bool del_event(BrokerEventLoop::EventType event); + + /** + * @brief Run the Broker's event loop. + * @see EventLoop::run + */ + virtual int run(); + /** * @brief Publishes the message with the broker subscribers. * Sends the message to all the clients that subscribed for the type of the message. @@ -99,6 +121,7 @@ class BrokerServer : public SocketEventLoop { */ virtual bool handle_msg(std::shared_ptr &sd); +private: /** * @brief Handle broker subscribe/unsubscribe messages. * @@ -107,8 +130,7 @@ class BrokerServer : public SocketEventLoop { * * @return true on success of false otherwise. */ - virtual bool handle_subscribe(std::shared_ptr &sd, - const messages::SubscribeMessage &msg); + bool handle_subscribe(std::shared_ptr &sd, const messages::SubscribeMessage &msg); /** * @brief Handler method for socket connections. @@ -117,7 +139,7 @@ class BrokerServer : public SocketEventLoop { * * @return true on success of false otherwise. */ - virtual bool socket_connected(std::shared_ptr sd); + bool socket_connected(std::shared_ptr sd); /** * @brief Handler method for socket disconnections. @@ -126,18 +148,18 @@ class BrokerServer : public SocketEventLoop { * * @return true on success of false otherwise. */ - virtual bool socket_disconnected(std::shared_ptr sd); + bool socket_disconnected(std::shared_ptr sd); private: /** - * Path and filename to the server's UDS file. + * Shared pointer to the broker server socket. */ - const std::string m_broker_uds_path; + std::shared_ptr m_broker_server = nullptr; /** - * Shared pointer to the server's UDS socket. + * Reference to the event loop that should be used by the broker. */ - std::shared_ptr m_broker_socket_uds = nullptr; + BrokerEventLoop &m_broker_event_loop; /** * Map for storing Socket->CMDU Type subscriptions. diff --git a/framework/transport/ieee1905_transport/ieee1905_transport_network.cpp b/framework/transport/ieee1905_transport/ieee1905_transport_network.cpp index 079b436e66..be117709a4 100644 --- a/framework/transport/ieee1905_transport/ieee1905_transport_network.cpp +++ b/framework/transport/ieee1905_transport/ieee1905_transport_network.cpp @@ -137,8 +137,8 @@ void Ieee1905Transport::update_network_interfaces( { // Accept incoming connections .on_read = - [&](broker::BrokerServer::EventType socket, - broker::BrokerServer::EventLoopType &loop) { + [&](broker::BrokerServer::BrokerEventLoop::EventType socket, + broker::BrokerServer::BrokerEventLoop::EventLoopType &loop) { LOG(DEBUG) << "Incoming message on interface fd: " << socket->getSocketFd(); handle_interface_pollin_event(socket->getSocketFd()); @@ -152,8 +152,8 @@ void Ieee1905Transport::update_network_interfaces( // Handle interface errors .on_error = - [&](broker::BrokerServer::EventType socket, - broker::BrokerServer::EventLoopType &loop) { + [&](broker::BrokerServer::BrokerEventLoop::EventType socket, + broker::BrokerServer::BrokerEventLoop::EventLoopType &loop) { LOG(DEBUG) << "Error on interface fd: " << socket->getSocketFd() << " (disabling it)."; @@ -300,8 +300,8 @@ void Ieee1905Transport::handle_interface_status_change(unsigned int if_index, bo { // Accept incoming connections .on_read = - [&](broker::BrokerServer::EventType socket, - broker::BrokerServer::EventLoopType &loop) { + [&](broker::BrokerServer::BrokerEventLoop::EventType socket, + broker::BrokerServer::BrokerEventLoop::EventLoopType &loop) { LOG(DEBUG) << "Incoming message on interface fd: " << socket->getSocketFd(); handle_interface_pollin_event(socket->getSocketFd()); @@ -315,8 +315,8 @@ void Ieee1905Transport::handle_interface_status_change(unsigned int if_index, bo // Handle interface errors .on_error = - [&](broker::BrokerServer::EventType socket, - broker::BrokerServer::EventLoopType &loop) { + [&](broker::BrokerServer::BrokerEventLoop::EventType socket, + broker::BrokerServer::BrokerEventLoop::EventLoopType &loop) { LOG(DEBUG) << "Error on interface fd: " << socket->getSocketFd() << " (disabling it)."; diff --git a/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp b/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp index 5fc424183d..26b56bdb61 100644 --- a/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp +++ b/framework/transport/ieee1905_transport/test/ieee1905_transport_broker_tests.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -40,6 +41,12 @@ using namespace beerocks::transport::messages; // UDS file for the tests static const std::string broker_uds_file = "beerocks_broker_test_uds"; +// Broker SocketServer listen buffer depth +static constexpr int broker_listen_buffer = 1; + +// Default broker server timeout +static constexpr auto broker_timeout = std::chrono::milliseconds(100); + // Invalid message magic value static constexpr uint32_t INVALID_MAGIC = 0x12345678; @@ -50,10 +57,8 @@ static constexpr uint32_t INVALID_MAGIC = 0x12345678; // Wrapper class for the BrokerServer for capturing errors class BrokerServerWrapper : public BrokerServer { public: - BrokerServerWrapper(std::string broker_uds_path) - : BrokerServer(broker_uds_path, std::chrono::milliseconds(100)) - { - } + // Inherit BrokerServer's constructor + using BrokerServer::BrokerServer; bool error() { return m_error_occurred; } @@ -92,7 +97,9 @@ TEST(broker_server, setup) TEST(broker_server, invalid_message_magic) { - BrokerServerWrapper broker_wrapper(broker_uds_file); + SocketServer broker_server_socket(broker_uds_file, broker_listen_buffer); + SocketEventLoop broker_event_loop(broker_timeout); + BrokerServerWrapper broker_wrapper(broker_server_socket, broker_event_loop); // Register a dummy internal message handler broker_wrapper.register_internal_message_handler( @@ -121,7 +128,9 @@ TEST(broker_server, invalid_message_magic) TEST(broker_server, subscribe_empty_message) { - BrokerServerWrapper broker_wrapper(broker_uds_file); + SocketServer broker_server_socket(broker_uds_file, broker_listen_buffer); + SocketEventLoop broker_event_loop(broker_timeout); + BrokerServerWrapper broker_wrapper(broker_server_socket, broker_event_loop); // Create a subscribe message SubscribeMessage subscribe; @@ -139,7 +148,9 @@ TEST(broker_server, subscribe_empty_message) TEST(broker_server, subscribe_single_type) { - BrokerServerWrapper broker_wrapper(broker_uds_file); + SocketServer broker_server_socket(broker_uds_file, broker_listen_buffer); + SocketEventLoop broker_event_loop(broker_timeout); + BrokerServerWrapper broker_wrapper(broker_server_socket, broker_event_loop); // Create a subscribe message SubscribeMessage subscribe; @@ -159,7 +170,9 @@ TEST(broker_server, subscribe_single_type) TEST(broker_server, subscribe_multiple_types) { - BrokerServerWrapper broker_wrapper(broker_uds_file); + SocketServer broker_server_socket(broker_uds_file, broker_listen_buffer); + SocketEventLoop broker_event_loop(broker_timeout); + BrokerServerWrapper broker_wrapper(broker_server_socket, broker_event_loop); // Create a subscribe message SubscribeMessage subscribe; @@ -181,7 +194,9 @@ TEST(broker_server, subscribe_multiple_types) TEST(broker_server, unsubscribe_empty_message) { - BrokerServerWrapper broker_wrapper(broker_uds_file); + SocketServer broker_server_socket(broker_uds_file, broker_listen_buffer); + SocketEventLoop broker_event_loop(broker_timeout); + BrokerServerWrapper broker_wrapper(broker_server_socket, broker_event_loop); // Create a subscribe message SubscribeMessage subscribe; @@ -199,7 +214,9 @@ TEST(broker_server, unsubscribe_empty_message) TEST(broker_server, unsubscribe_single_type) { - BrokerServerWrapper broker_wrapper(broker_uds_file); + SocketServer broker_server_socket(broker_uds_file, broker_listen_buffer); + SocketEventLoop broker_event_loop(broker_timeout); + BrokerServerWrapper broker_wrapper(broker_server_socket, broker_event_loop); // Create a subscribe message SubscribeMessage subscribe; @@ -219,7 +236,9 @@ TEST(broker_server, unsubscribe_single_type) TEST(broker_server, unsubscribe_multiple_types) { - BrokerServerWrapper broker_wrapper(broker_uds_file); + SocketServer broker_server_socket(broker_uds_file, broker_listen_buffer); + SocketEventLoop broker_event_loop(broker_timeout); + BrokerServerWrapper broker_wrapper(broker_server_socket, broker_event_loop); // Create a subscribe message SubscribeMessage subscribe; @@ -241,7 +260,9 @@ TEST(broker_server, unsubscribe_multiple_types) TEST(broker_server, subscribe_unsubscribe) { - BrokerServerWrapper broker_wrapper(broker_uds_file); + SocketServer broker_server_socket(broker_uds_file, broker_listen_buffer); + SocketEventLoop broker_event_loop(broker_timeout); + BrokerServerWrapper broker_wrapper(broker_server_socket, broker_event_loop); // Create a subscribe message SubscribeMessage subscribe; @@ -269,7 +290,9 @@ TEST(broker_server, subscribe_unsubscribe) TEST(broker_server, publish_internal_message) { - BrokerServerWrapper broker_wrapper(broker_uds_file); + SocketServer broker_server_socket(broker_uds_file, broker_listen_buffer); + SocketEventLoop broker_event_loop(broker_timeout); + BrokerServerWrapper broker_wrapper(broker_server_socket, broker_event_loop); // Connect to the broker SocketClient sock1(broker_uds_file); From 68298eca303886c9090047f523505eed1f9edcf3 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Thu, 16 Jul 2020 08:24:14 +0000 Subject: [PATCH 253/453] tlvf: Fix dropped out vs messages PR #1501 introduced a replacement to transport/btl infrastructure. After this PR it was observed that some vendor-specific messages are dropped out and not reach their destination. Apparently, there was a bug in the transport that allowed duplicate messages (CMDUs with same message type and MID), to pass the transport layer, and was fixed in this PR. create_vs_message() has put the beerocks message-id as the CMDU MID wrongly and thus caused to the transport layer to drop the message. Change create_vs_message() function so it would always put MID=0 on the CMDU header as it should. Signed-off-by: Moran Shoeg --- .../beerocks/tlvf/src/include/beerocks/tlvf/beerocks_message.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/beerocks/tlvf/src/include/beerocks/tlvf/beerocks_message.h b/common/beerocks/tlvf/src/include/beerocks/tlvf/beerocks_message.h index 5d6f4dfb40..291f376550 100644 --- a/common/beerocks/tlvf/src/include/beerocks/tlvf/beerocks_message.h +++ b/common/beerocks/tlvf/src/include/beerocks/tlvf/beerocks_message.h @@ -117,7 +117,7 @@ class message_com { template static std::shared_ptr create_vs_message(ieee1905_1::CmduMessageTx &cmdu_tx, uint16_t id = 0) { - auto cmduhdr = cmdu_tx.create(id, ieee1905_1::eMessageType::VENDOR_SPECIFIC_MESSAGE); + auto cmduhdr = cmdu_tx.create(0, ieee1905_1::eMessageType::VENDOR_SPECIFIC_MESSAGE); if (!cmduhdr) { std::cout << "beerocks_message.h[ " << __LINE__ << "]: " << __FUNCTION__ << " failed!" << std::endl; From 891d391d27c99015c39a12396cb4bf4d4287d3f6 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Thu, 16 Jul 2020 09:02:09 +0000 Subject: [PATCH 254/453] dwpal: Fix dwpal parsing Commit d171269a84948d49910f1829616367dc47712e53 has removed parsing of "bss_load" from radio statistics. This commit should have decreased the size of numOfValidArgs[] by one so it wll not be checked for error, which is now being printed to the log: "monitor_thread.cpp[803] --> Failed updating Radio statistics! mon_wlan_hal_dwpal.cpp[587] --> Failed reading parsed parameter 7 ==> Abort" Decreased numOfValidArgs[] by one on update_radio_stats(). (This just another example why dwpal parser is evil). Signed-off-by: Moran Shoeg --- common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp index 1262ddb58e..42f7e4fc6b 100644 --- a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp @@ -549,7 +549,7 @@ bool mon_wlan_hal_dwpal::update_radio_stats(SRadioStats &radio_stats) return false; } - size_t numOfValidArgs[8] = {0}, replyLen = strnlen(reply, HOSTAPD_TO_DWPAL_MSG_LENGTH); + size_t numOfValidArgs[7] = {0}, replyLen = strnlen(reply, HOSTAPD_TO_DWPAL_MSG_LENGTH); uint64_t BytesSent = 0, BytesReceived = 0, PacketsSent = 0, PacketsReceived = 0; FieldsToParse fieldsToParse[] = { {(void *)&BytesSent, &numOfValidArgs[0], DWPAL_LONG_LONG_INT_PARAM, "BytesSent=", 0}, From 4eeaae921f42dc70903ceeb9bb9ea42071ad71ea Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Thu, 16 Jul 2020 09:05:07 +0000 Subject: [PATCH 255/453] agent: Add/Fix prints on monitor thread Signed-off-by: Moran Shoeg --- .../beerocks/fronthaul_manager/monitor/monitor_thread.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp index 2abfcee8c7..d87b4a3d4d 100644 --- a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp +++ b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp @@ -974,7 +974,7 @@ bool monitor_thread::handle_cmdu_vs_message(Socket &sd, ieee1905_1::CmduMessageR std::string sta_ipv4 = network_utils::ipv4_to_string(request->params().ipv4); std::string set_bridge_4addr_mac = tlvf::mac_to_string(request->params().bridge_4addr_mac); LOG(INFO) << "ACTION_MONITOR_CLIENT_START_MONITORING_REQUEST=" << sta_mac - << " ip=" << sta_ipv4; + << " ip=" << sta_ipv4 << " set_bridge_4addr_mac=" << set_bridge_4addr_mac; auto response = message_com::create_vs_message< beerocks_message::cACTION_MONITOR_CLIENT_START_MONITORING_RESPONSE>( @@ -982,12 +982,13 @@ bool monitor_thread::handle_cmdu_vs_message(Socket &sd, ieee1905_1::CmduMessageR if (!response) { LOG(ERROR) - << "Failed building ACTION_CONTROL_CLIENT_START_MONITORING_RESPONSE message!"; + << "Failed building ACTION_MONITOR_CLIENT_START_MONITORING_RESPONSE message!"; return false; } auto sta_node = mon_db.sta_find(sta_mac); if (!sta_node) { + LOG(ERROR) << "Could not find sta_node " << sta_mac; response->success() = false; message_com::send_cmdu(slave_socket, cmdu_tx); return false; From 911c9d7ce8a1fc1748845791df0dea260e3732bb Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Tue, 30 Jun 2020 21:31:15 +0300 Subject: [PATCH 256/453] tests: boardfarm: add "prplWRT_STA" device Add "prplWRT_STA" boardfarm device which represents real STA required for tests. This just a basic device, with code enough to make "Client association link metrics" test run. As new device properly initializes, add it to the boardfarm configuration file. Signed-off-by: Anton Bilohai --- .../devices/prplmesh_station.py | 71 +++++++++++++++++++ .../boardfarm_prplmesh/prplmesh_config.json | 9 +++ 2 files changed, 80 insertions(+) create mode 100644 tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station.py diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station.py new file mode 100644 index 0000000000..dc7bd77336 --- /dev/null +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station.py @@ -0,0 +1,71 @@ +############################################################### +# SPDX-License-Identifier: BSD-2-Clause-Patent +# SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) +# This code is subject to the terms of the BSD+Patent license. +# See LICENSE file for more details. +############################################################### + +from boardfarm.devices.debian_wifi import DebianWifi +from boardfarm.devices import connection_decider +from environment import VirtualAPHostapd + + +class PrplMeshStation(DebianWifi): + """Client of prplMesh enabled Access Point.""" + + linesep = "\r" + model = "prplWRT_STA" + prompt = ['.*:~', '/.*#'] + + def __init__(self, *args, **kwargs): + """Init station and wlan iface.""" + self.args = args + self.kwargs = kwargs + + config = kwargs.get("config", kwargs) + self.connection_type = config.get("connection_type", None) + self.connection = connection_decider.connection(device=self, + conn_type=self.connection_type, + **kwargs) + self.connection.connect() + self.consoles = [self] + super(PrplMeshStation, self).__init__(*args, **kwargs) + self.iface_dut = self.iface_wifi = self.kwargs.get( + 'iface', 'wlan0') + self.driver_name = config.get("driver", "nl80211,wext") + self.mac = self.get_mac() + + self.wifi_disconnect() + # kill all wpa_supplicant relevant to active interface + + def wifi_connect(self, vap: VirtualAPHostapd) -> bool: + """Connect to the Access Point. Return True if successful.""" + config_file_name = "boardfarm_tmp.conf" + config_file_path = "/tmp/{}".format(config_file_name) + + # Create network configuration for SSID + bssid = "bssid={}".format(vap.bssid) + ssid = "ssid=\"{}\"".format(vap.get_ssid()) + key = "psk=\"{}\"".format(vap.get_psk()) + network_config = "network={{\n{}\n{}\n{}\n}}".format(bssid, ssid, key) + # Clean up previous configuration + self.sendline("rm -f \"{}\"".format(config_file_path)) + self.expect(self.prompt) + self.sendline("echo \'{}\' > \"{}\"".format(network_config, config_file_path)) + self.expect(self.prompt) + # Start wpa_supplicant with created configuration + # Typical coommand on RPI: wpa_supplicant -B -c/tmp/temp.conf -iwlan0 -Dnl80211,wext + self.sudo_sendline("wpa_supplicant -B -D{} -i {} -c {}".format( + self.driver_name, self.iface_wifi, config_file_path)) + self.expect("Successfully initialized wpa_supplicant") + return bool(self.match) + + def get_mac(self) -> str: + """Get MAC of STA iface""" + self.sendline("iw {} info".format(self.iface_dut)) + # We are looking for MAC definition of STA + # wdev 0x1 + # addr 96:4e:c9:cc:7a:2c + # type managed + self.expect("addr (?P..:..:..:..:..:..)\r\n\ttype") + return self.match.group('mac') diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json index 6a6a2d1998..2494116933 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json @@ -32,6 +32,15 @@ "role": "controller", "docker_network": "prplMesh-net-rax40-1", "conn_cmd": "" + }, + { + "name": "wifi", + "type": "prplWRT_STA", + "iface": "wlan0", + "driver": "nl80211,wext", + "connection_type": "local_cmd", + "conn_cmd": "bash", + "color": "yellow" } ] } From 64ba87dae113ad588ff45a2ff7ca4dacb62327e3 Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Mon, 6 Jul 2020 16:08:57 +0300 Subject: [PATCH 257/453] boardfarm: environment.py: VirtualAPHostapd add get_ssid and get_psk As part of some of the tests, we have to connect some station to the VirtualAPHostapd. In order to do so, we need to get SSID and PSK (personal key) of AP. As they are changed during the tests, there is not much point in saving SSID and AP during object creation. Thus, just add two getters to obtain SSID and PSK when they are needed. As there is no clear, generic way to obtain PSK from AP (prplMesh isn't yet saving PSK set by the test in the UCI), get it from logfile of agent. Signed-off-by: Anton Bilohai --- tests/environment.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/environment.py b/tests/environment.py index 9e6594c70f..603e25b016 100644 --- a/tests/environment.py +++ b/tests/environment.py @@ -492,6 +492,27 @@ class VirtualAPHostapd(VirtualAP): def __init__(self, radio: RadioHostapd, bssid: str): super().__init__(radio, bssid) + def get_ssid(self) -> str: + """Get current SSID of attached radio. Return string.""" + device = self.radio.agent.device + device.sendline("iw {}.0 info".format(self.radio.iface_name)) + # We are looking for SSID definition + # ssid Multi-AP-24G-1 + # type AP + device.expect("ssid (?P.*)\r\n\ttype AP\r\n\t") + return device.match.group('ssid') + + def get_psk(self) -> str: + """Get SSIDs personal key set during last autoconfiguration. Return string""" + device = self.radio.agent.device + device.sendline("grep \"network_key\" \"{}/beerocks_agent_{}.log\" | tail -n 1".format( + self.radio.log_folder, self.radio.iface_name)) + # We looking for key, which was set during last autoconfiguration. E.g of such string: + # network_key: maprocks2 fronthaul: + device.expect("network_key: (?P.*) fronthaul") + return device.match.group('psk') + + def associate(self, sta: Station) -> bool: ''' Associate "sta" with this VAP ''' # TODO: complete this stub From 5c173e763429babea4792c862c4fdc858ccbda83 Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Mon, 6 Jul 2020 16:17:01 +0300 Subject: [PATCH 258/453] boardfarm: environment.py: ALEntityPrplWrt: incorrect usage of log read "ALEntityPrplWrt" class uses "_device_wait_for_log" method in wrong way: it has "timeout" and "start_line" arguments misplaces. Set arguments in right order: "timeout" should be before "start_line". Signed-off-by: Anton Bilohai --- tests/environment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/environment.py b/tests/environment.py index 603e25b016..d810eadcd1 100644 --- a/tests/environment.py +++ b/tests/environment.py @@ -458,7 +458,7 @@ def wait_for_log(self, regex: str, start_line: int, timeout: float) -> bool: # Multiply timeout by 100, as test sets it in float. return _device_wait_for_log(self.device, "{}/beerocks_{}.log".format(self.log_folder, program), - regex, start_line, timeout) + regex, timeout, start_line) def prprlmesh_status_check(self): return self.device.prprlmesh_status_check() From 13cf57639da2fe7bae1bdc977d293a01676d9948 Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Tue, 7 Jul 2020 00:49:08 +0300 Subject: [PATCH 259/453] boardfarm: environment.py: set VirtualAPHostapd according to device VAPs Currently, we are spawning 2 VirtualAPHostapd for prplWRT device no matter how much(and if) device actually have VAPs. Make RadioHostapd spawn VirtualHostapds corresponding to the amount of VAPs present on the device. Add necessary methods. Signed-off-by: Anton Bilohai --- tests/environment.py | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/tests/environment.py b/tests/environment.py index d810eadcd1..7da67bb6b0 100644 --- a/tests/environment.py +++ b/tests/environment.py @@ -476,8 +476,18 @@ def __init__(self, agent: ALEntityPrplWrt, iface_name: str): self.log_folder = agent.log_folder super().__init__(agent, mac) - VirtualAPHostapd(self, mac) - VirtualAPHostapd(self, mac) + # Find out amount of VAPs avalaible on device. + # If 0 - spawn one VAP to represent AP. + self.agent.device.sendline("ip link list | grep -c \"{}\\.\"".format(self.iface_name)) + # Look for number of 1 or 2 digits surrounded by CRLF. + self.agent.device.expect("\r\n(?P[0-9]{1,2})\r\n") + vap_amount = int(self.agent.device.match.group('vaps')) + if vap_amount == 0: + VirtualAPHostapd(self, mac) + else: + for vap_number in range(0, vap_amount): + vap_mac = self.get_mac("{}.{}".format(self.iface_name, vap_number)) + VirtualAPHostapd(self, vap_mac) def wait_for_log(self, regex: str, start_line: int, timeout: float): ''' Poll the Radio's logfile until it match regular expression ''' @@ -485,17 +495,25 @@ def wait_for_log(self, regex: str, start_line: int, timeout: float): return _device_wait_for_log(self.agent.device, "{}/beerocks_agent_{}.log".format( self.log_folder, self.iface_name), regex, timeout, start_line) + def get_mac(self, iface: str) -> str: + """Return mac of specified iface""" + device = self.agent.device + device.sendline("ip link show {}".format(iface)) + device.expect("link/ether (?P([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2})") + return device.match.group('mac') + class VirtualAPHostapd(VirtualAP): """Docker implementation of a VAP.""" def __init__(self, radio: RadioHostapd, bssid: str): super().__init__(radio, bssid) + self.iface = self.get_iface(self.bssid) def get_ssid(self) -> str: """Get current SSID of attached radio. Return string.""" device = self.radio.agent.device - device.sendline("iw {}.0 info".format(self.radio.iface_name)) + device.sendline("iw {} info".format(self.iface)) # We are looking for SSID definition # ssid Multi-AP-24G-1 # type AP @@ -505,13 +523,20 @@ def get_ssid(self) -> str: def get_psk(self) -> str: """Get SSIDs personal key set during last autoconfiguration. Return string""" device = self.radio.agent.device - device.sendline("grep \"network_key\" \"{}/beerocks_agent_{}.log\" | tail -n 1".format( - self.radio.log_folder, self.radio.iface_name)) + ssid = self.get_ssid() + device.sendline(("grep \"Autoconfiguration for ssid: " + + "{}\" \"{}/beerocks_agent_{}.log\" | tail -n 1") + .format(ssid, self.radio.log_folder, self.radio.iface_name)) # We looking for key, which was set during last autoconfiguration. E.g of such string: # network_key: maprocks2 fronthaul: device.expect("network_key: (?P.*) fronthaul") return device.match.group('psk') + def get_iface(self, bssid: str) -> str: + device = self.radio.agent.device + device.sendline("ip link list | grep -B1 \"{}\"".format(bssid)) + device.expect("[0-9]{1,4}: (?Pwlan[0-9.]{1,4}): <") + return device.match.group('iface_name') def associate(self, sta: Station) -> bool: ''' Associate "sta" with this VAP ''' From b75622589f102138cf0b03008a00fde0d52d1b9e Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Tue, 7 Jul 2020 02:28:12 +0300 Subject: [PATCH 260/453] boardfarm: station: add wifi_connect_check method Currently, we only have "wifi_connect" methods. As we are working with HW, it may not react immediately to the commands. In order to check if wlan STA was successfully associated with given VAP, add "wifi_connect_check" methods to HW STA, dummy STA and use it in test itself. Signed-off-by: Anton Bilohai --- .../devices/prplmesh_station.py | 31 +++++++++++++++++-- .../devices/prplmesh_station_dummy.py | 8 +++++ .../tests/client_association_link_metrics.py | 17 +++------- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station.py index dc7bd77336..d5f63561dc 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station.py @@ -5,6 +5,8 @@ # See LICENSE file for more details. ############################################################### +import pexpect + from boardfarm.devices.debian_wifi import DebianWifi from boardfarm.devices import connection_decider from environment import VirtualAPHostapd @@ -35,8 +37,10 @@ def __init__(self, *args, **kwargs): self.driver_name = config.get("driver", "nl80211,wext") self.mac = self.get_mac() - self.wifi_disconnect() # kill all wpa_supplicant relevant to active interface + self.wifi_disconnect() + # Turn on and off wlan iface just in case + self.disable_and_enable_wifi() def wifi_connect(self, vap: VirtualAPHostapd) -> bool: """Connect to the Access Point. Return True if successful.""" @@ -55,11 +59,32 @@ def wifi_connect(self, vap: VirtualAPHostapd) -> bool: self.expect(self.prompt) # Start wpa_supplicant with created configuration # Typical coommand on RPI: wpa_supplicant -B -c/tmp/temp.conf -iwlan0 -Dnl80211,wext - self.sudo_sendline("wpa_supplicant -B -D{} -i {} -c {}".format( + self.sudo_sendline("wpa_supplicant -B -D{} -i{} -c{}".format( self.driver_name, self.iface_wifi, config_file_path)) self.expect("Successfully initialized wpa_supplicant") return bool(self.match) + def wifi_connect_check(self, vap: VirtualAPHostapd) -> bool: + """Connect to a SSID and verify WIFI connectivity""" + for _ in range(5): + self.wifi_connect(vap) + self.expect(pexpect.TIMEOUT, timeout=10) + verify_connect = self.wifi_connectivity_verify() + if verify_connect: + break + else: + self.wifi_disconnect() + return verify_connect + + def wifi_connectivity_verify(self): + """Verify that wifi is connected. Return bool""" + self.sendline("iw %s link" % self.iface_wifi) + matched = self.expect(["Connected", "Not connected", pexpect.TIMEOUT]) + if matched == 0: + return True + else: + return False + def get_mac(self) -> str: """Get MAC of STA iface""" self.sendline("iw {} info".format(self.iface_dut)) @@ -67,5 +92,5 @@ def get_mac(self) -> str: # wdev 0x1 # addr 96:4e:c9:cc:7a:2c # type managed - self.expect("addr (?P..:..:..:..:..:..)\r\n\ttype") + self.expect("addr (?P..:..:..:..:..:..)\r\n\t(type|ssid)") return self.match.group('mac') diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station_dummy.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station_dummy.py index 99295ee22e..b406e3f3be 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station_dummy.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_station_dummy.py @@ -36,3 +36,11 @@ def wifi_disconnect(self, vap: VirtualAPDocker) -> bool: '''Disassociate "sta" from this VAP.''' vap.radio.send_bwl_event("EVENT AP-STA-DISCONNECTED {}".format(self.mac)) return True + + def wifi_connect_check(self, vap: VirtualAPDocker) -> bool: + """Connect and verify connection""" + return self.wifi_connect(vap) + + def disable_wifi(self) -> bool: + """Disable wifi connection""" + return True diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py index 00c9a61499..78649ed9dd 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py @@ -8,8 +8,6 @@ import time from .prplmesh_base_test import PrplMeshBaseTest -# TODO: Remove as soon, as test works for prplWRT device -from ..devices.prplmesh_prplwrt import PrplMeshPrplWRT from capi import tlv from opts import debug @@ -25,12 +23,6 @@ def runTest(self): controller = self.dev.wan.controller_entity sta = self.dev.wifi - # This test doesn't work for real HW. - # Skip it for prplWRT device. - # TODO: Remove as soon, as test works for prplWRT device - if self.dev.DUT is PrplMeshPrplWRT: - self.skipTest("This test isn't ready for prplWRT devices") - # Regression check # Don't connect nonexistent Station self.dev.DUT.wired_sniffer.start(self.__class__.__name__ + "-" + self.dev.DUT.name) @@ -39,12 +31,11 @@ def runTest(self): controller.ucc_socket.dev_send_1905(agent.mac, 0x800D, tlv(0x95, 0x0006, '{sta_mac}'.format(sta_mac=sta_mac))) self.check_log(agent, - "client with mac address {sta_mac} not found".format(sta_mac=sta_mac), - timeout=30) + "client with mac address {sta_mac} not found".format(sta_mac=sta_mac)) time.sleep(1) debug('sta: {}'.format(sta.mac)) - sta.wifi_connect(agent.radios[0].vaps[0]) + sta.wifi_connect_check(agent.radios[0].vaps[0]) time.sleep(1) @@ -54,8 +45,7 @@ def runTest(self): time.sleep(1) self.check_log(agent, "Send AssociatedStaLinkMetrics to controller, mid = {}".format(mid), - timeout=30) - sta.wifi_disconnect(agent.radios[0].vaps[0]) + timeout=20) @classmethod def teardown_class(cls): @@ -71,3 +61,4 @@ def teardown_class(cls): # If AttributeError was raised - we are dealing with dummy devices. # We don't have to additionaly send Ctrl+C for dummy devices. pass + test.dev.wifi.disable_wifi() From 0035ae30f2d28896b55d0d72eefacd22190e8568 Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Tue, 7 Jul 2020 11:22:36 +0300 Subject: [PATCH 261/453] boardfarm: prplWRT device: close serial connection When device doesn't have IP or hostname set in boardfarm configuration file, it fallbacks to the serial connection and tries to set up an IP address to continue over ssh. Currently, we are closing serial connection using wrong object. Close serial connection with proper object. Signed-off-by: Anton Bilohai --- .../boardfarm_prplmesh/devices/prplmesh_prplwrt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py index b8e9120c6c..71e6f8291e 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_prplwrt.py @@ -62,7 +62,7 @@ def __init__(self, *args, **kwargs): self.wan_network = self.get_docker_subnet() self.wan_ip = self.wan_network[+245] self.set_iface_ip("br-lan", self.wan_ip, self.wan_network.prefixlen) - self.connection.close() + self.close() self.kill(signal.SIGTERM) # Removal of PID is required by pexpect in order to spawn a new process # serial connection should be terminated by 2 commands above From a1ec103c75d28b219d4a692a3989ac6c9b09dffa Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 15 Jul 2020 14:29:41 +0300 Subject: [PATCH 262/453] common: tlvf: Remove SLAVE_JOINED_4ADDR_MODE_NOTIFICATION Need to remove ACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION message and all related code because this message is not used and will not be used in the future. https://jira.prplfoundation.org/browse/PPM-284 Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 1 - .../beerocks/tlvf/beerocks_message_control.h | 29 ----- .../tlvf/beerocks_message_control.cpp | 118 ------------------ .../tlvf/beerocks_message_action.yaml | 1 - .../tlvf/beerocks_message_control.yaml | 8 -- 5 files changed, 157 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index 1da7caf339..ac72c99da9 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -47,7 +47,6 @@ enum eActionOp_CONTROL: uint8_t { ACTION_CONTROL_CONTROLLER_PING_RESPONSE = 0x7, ACTION_CONTROL_AGENT_PING_REQUEST = 0x8, ACTION_CONTROL_AGENT_PING_RESPONSE = 0x9, - ACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION = 0xa, ACTION_CONTROL_CHANGE_MODULE_LOGGING_LEVEL = 0xb, ACTION_CONTROL_ARP_QUERY_REQUEST = 0xc, ACTION_CONTROL_ARP_QUERY_RESPONSE = 0xd, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h index 1249627ee1..ca3795752d 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h @@ -138,35 +138,6 @@ class cACTION_CONTROL_SLAVE_JOINED_RESPONSE : public BaseClass sSonConfig* m_config = nullptr; }; -class cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION : public BaseClass -{ - public: - cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION(std::shared_ptr base, bool parse = false); - ~cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION(); - - static eActionOp_CONTROL get_action_op(){ - return (eActionOp_CONTROL)(ACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION); - } - sMacAddr& backhaul_iface_mac(); - beerocks::net::sIpv4Addr& backhaul_ipv4(); - sMacAddr& bridge_iface_mac(); - beerocks::net::sIpv4Addr& bridge_ipv4(); - sNodeHostap& hostap(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CONTROL* m_action_op = nullptr; - sMacAddr* m_backhaul_iface_mac = nullptr; - beerocks::net::sIpv4Addr* m_backhaul_ipv4 = nullptr; - sMacAddr* m_bridge_iface_mac = nullptr; - beerocks::net::sIpv4Addr* m_bridge_ipv4 = nullptr; - sNodeHostap* m_hostap = nullptr; -}; - class cACTION_CONTROL_SON_CONFIG_UPDATE : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp index 27450f439a..1e18f05da5 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp @@ -439,124 +439,6 @@ bool cACTION_CONTROL_SLAVE_JOINED_RESPONSE::init() return true; } -cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION::cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION::cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION::~cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION() { -} -sMacAddr& cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION::backhaul_iface_mac() { - return (sMacAddr&)(*m_backhaul_iface_mac); -} - -beerocks::net::sIpv4Addr& cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION::backhaul_ipv4() { - return (beerocks::net::sIpv4Addr&)(*m_backhaul_ipv4); -} - -sMacAddr& cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION::bridge_iface_mac() { - return (sMacAddr&)(*m_bridge_iface_mac); -} - -beerocks::net::sIpv4Addr& cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION::bridge_ipv4() { - return (beerocks::net::sIpv4Addr&)(*m_bridge_ipv4); -} - -sNodeHostap& cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION::hostap() { - return (sNodeHostap&)(*m_hostap); -} - -void cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CONTROL), reinterpret_cast(m_action_op)); - m_backhaul_iface_mac->struct_swap(); - m_backhaul_ipv4->struct_swap(); - m_bridge_iface_mac->struct_swap(); - m_bridge_ipv4->struct_swap(); - m_hostap->struct_swap(); -} - -bool cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sMacAddr); // backhaul_iface_mac - class_size += sizeof(beerocks::net::sIpv4Addr); // backhaul_ipv4 - class_size += sizeof(sMacAddr); // bridge_iface_mac - class_size += sizeof(beerocks::net::sIpv4Addr); // bridge_ipv4 - class_size += sizeof(sNodeHostap); // hostap - return class_size; -} - -bool cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_backhaul_iface_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_backhaul_iface_mac->struct_init(); } - m_backhaul_ipv4 = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(beerocks::net::sIpv4Addr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(beerocks::net::sIpv4Addr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_backhaul_ipv4->struct_init(); } - m_bridge_iface_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_bridge_iface_mac->struct_init(); } - m_bridge_ipv4 = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(beerocks::net::sIpv4Addr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(beerocks::net::sIpv4Addr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_bridge_ipv4->struct_init(); } - m_hostap = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sNodeHostap))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sNodeHostap) << ") Failed!"; - return false; - } - if (!m_parse__) { m_hostap->struct_init(); } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_CONTROL_SON_CONFIG_UPDATE::cACTION_CONTROL_SON_CONFIG_UPDATE(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index 2f2127ab25..be0cdeb7d3 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -39,7 +39,6 @@ eActionOp_CONTROL: ACTION_CONTROL_CONTROLLER_PING_RESPONSE: 7 ACTION_CONTROL_AGENT_PING_REQUEST: 8 ACTION_CONTROL_AGENT_PING_RESPONSE: 9 - ACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION: 10 ACTION_CONTROL_CHANGE_MODULE_LOGGING_LEVEL: 11 ACTION_CONTROL_ARP_QUERY_REQUEST: 12 ACTION_CONTROL_ARP_QUERY_RESPONSE: 13 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml index ada2ccef08..604cf41b41 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml @@ -45,14 +45,6 @@ cACTION_CONTROL_SLAVE_JOINED_RESPONSE: err_code: uint8_t #beerocks::eSlaveJoinResponseErrCode config: sSonConfig -cACTION_CONTROL_SLAVE_JOINED_4ADDR_MODE_NOTIFICATION: - _type: class - backhaul_iface_mac: sMacAddr - backhaul_ipv4: beerocks::net::sIpv4Addr - bridge_iface_mac: sMacAddr - bridge_ipv4: beerocks::net::sIpv4Addr - hostap: sNodeHostap - cACTION_CONTROL_SON_CONFIG_UPDATE: _type: class config: sSonConfig From 2988e42e993a562794da4b4407edf81cb52bd857 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 15 Jul 2020 17:45:16 +0300 Subject: [PATCH 263/453] beerocks: network_utils: Add 0 terminator in linux_get_iface_name Method linux_get_iface_name() operates C-style strings and returns result as C++ string container. In some places when we need to use this method need to put result in C-style string and it can cause a problem when we can get the string without zero terminator. Add '\0' as last character for iface_name char array in the linux_get_iface_name() method. Signed-off-by: Vladyslav Tupikin --- common/beerocks/bcl/source/network/network_utils.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/beerocks/bcl/source/network/network_utils.cpp b/common/beerocks/bcl/source/network/network_utils.cpp index 08cbcb3b91..8600e7b46a 100644 --- a/common/beerocks/bcl/source/network/network_utils.cpp +++ b/common/beerocks/bcl/source/network/network_utils.cpp @@ -541,6 +541,8 @@ std::string network_utils::linux_get_iface_name(uint32_t iface_index) return ""; } + iface_name[IF_NAMESIZE - 1] = '\0'; + return iface_name; } From 611f730437f5eb6949ccaa22c0562e3743187ce1 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 14 Jul 2020 20:21:38 +0300 Subject: [PATCH 264/453] agent: backhaul_manager: Replace if_indextoname() Need to replace if_indextoname() to the wrapper network_utils::linux_get_iface_name. Signed-off-by: Vladyslav Tupikin --- .../beerocks/slave/backhaul_manager/wan_monitor.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/wan_monitor.cpp b/agent/src/beerocks/slave/backhaul_manager/wan_monitor.cpp index ce35bd8c5e..9a21f65656 100644 --- a/agent/src/beerocks/slave/backhaul_manager/wan_monitor.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/wan_monitor.cpp @@ -130,20 +130,21 @@ wan_monitor::ELinkState wan_monitor::process() // LINK related message if (hnl->nlmsg_type == RTM_NEWLINK || hnl->nlmsg_type == RTM_DELLINK) { - char name[IFNAMSIZ] = {0}; + struct ifinfomsg *ifi = (struct ifinfomsg *)NLMSG_DATA(hnl); // Convert the interface index to name - if_indextoname(ifi->ifi_index, name); + auto iface_name = network_utils::linux_get_iface_name(ifi->ifi_index); // Skip events for other interfaces - if (m_strWanIfaceName.compare(name) != 0) { - LOG(DEBUG) << "Link detected for non-WAN interface '" << name << "'. Skipping..."; + if (m_strWanIfaceName != iface_name) { + LOG(DEBUG) << "Link detected for non-WAN interface '" << iface_name + << "'. Skipping..."; continue; } - LOG(DEBUG) << "Interface '" << name << "', msg_type: " << int(hnl->nlmsg_type) + LOG(DEBUG) << "Interface '" << iface_name << "', msg_type: " << int(hnl->nlmsg_type) << ", running: " << int(ifi->ifi_flags & IFF_RUNNING); // Return WAN interface link state From 83a8707d053048709c79c3aea8747fe2ade293a7 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 14 Jul 2020 20:24:25 +0300 Subject: [PATCH 265/453] agent: platform_manager: Replace if_indextoname() Need to replace if_indextoname() to the wrapper network_utils::linux_get_iface_name. Signed-off-by: Vladyslav Tupikin --- .../platform_manager/platform_manager_thread.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp b/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp index 10ea6d30d7..4257bf7235 100644 --- a/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp +++ b/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp @@ -1122,15 +1122,14 @@ bool main_thread::handle_arp_monitor() Socket *sd = nullptr; auto iIfaceIndex = arp_notif->params().iface_idx; - char if_name_buffer[IF_NAMESIZE]; - if (!if_indextoname(iIfaceIndex, if_name_buffer)) { + auto iface_name = network_utils::linux_get_iface_name(iIfaceIndex); + + if (iface_name.empty()) { LOG(ERROR) << "Failed to find iface of iface_index" << int(iIfaceIndex); return false; } - std::string strIfaceName(if_name_buffer); - - sd = get_slave_socket_from_hostap_iface_name(strIfaceName); + sd = get_slave_socket_from_hostap_iface_name(iface_name); // Use the Backhaul Manager Slave as the default destination if ((sd == nullptr) && ((sd = get_backhaul_socket()) == nullptr)) { @@ -1138,7 +1137,7 @@ bool main_thread::handle_arp_monitor() return false; } - auto it_iface = m_mapIfaces.find(strIfaceName); + auto it_iface = m_mapIfaces.find(iface_name); if (it_iface != m_mapIfaces.end()) { auto &pIfaceParams = it_iface->second; arp_notif->params().source = pIfaceParams.eType; @@ -1158,9 +1157,8 @@ bool main_thread::handle_arp_monitor() : "FRONT"; // Send the message to the Slave - LOG(INFO) << "ARP - Interface: " << strIfaceName - << ", State: " << int(arp_notif->params().state) << ", IP: " << client_ipv4 << " (" - << client_mac << ")" + LOG(INFO) << "ARP - Interface: " << iface_name << ", State: " << int(arp_notif->params().state) + << ", IP: " << client_ipv4 << " (" << client_mac << ")" << ", Source: " << source << ", Type: " << int(arp_notif->params().type); // Check if the master should be notified From 1a3d5725c3fa415fd5454949c3bbc33c298e8a40 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 14 Jul 2020 20:25:08 +0300 Subject: [PATCH 266/453] common: bcl: Replace if_indextoname() Need to replace if_indextoname() to the wrapper network_utils::linux_get_iface_name. Signed-off-by: Vladyslav Tupikin --- common/beerocks/bcl/source/network/network_utils.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/beerocks/bcl/source/network/network_utils.cpp b/common/beerocks/bcl/source/network/network_utils.cpp index 8600e7b46a..635edc1f8c 100644 --- a/common/beerocks/bcl/source/network/network_utils.cpp +++ b/common/beerocks/bcl/source/network/network_utils.cpp @@ -338,9 +338,12 @@ static int parseRoutes(struct nlmsghdr *nlHdr, std::shared_ptr rtInf rtLen = RTM_PAYLOAD(nlHdr); for (; RTA_OK(rtAttr, rtLen); rtAttr = RTA_NEXT(rtAttr, rtLen)) { switch (rtAttr->rta_type) { - case RTA_OIF: - if_indextoname(*(int *)RTA_DATA(rtAttr), rtInfo->ifName); + case RTA_OIF: { + auto index = *(int *)RTA_DATA(rtAttr); + auto iface_index_name = network_utils::linux_get_iface_name(index); + std::copy_n(iface_index_name.begin(), iface_index_name.length(), rtInfo->ifName); break; + } case RTA_GATEWAY: rtInfo->gateWay.s_addr = *(u_int *)RTA_DATA(rtAttr); break; From 0bfd3a676b54c7b35420a0027e269dd01445d3fc Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 14 Jul 2020 20:25:52 +0300 Subject: [PATCH 267/453] common: bwl: Replace if_indextoname() Need to replace if_indextoname() to the wrapper network_utils::linux_get_iface_name. Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp index 42f7e4fc6b..6ee6857f83 100644 --- a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp @@ -1311,21 +1311,23 @@ bool mon_wlan_hal_dwpal::process_dwpal_event(char *buffer, int bufLen, const std bool mon_wlan_hal_dwpal::process_dwpal_nl_event(struct nl_msg *msg) { - struct nlmsghdr *nlh = nlmsg_hdr(msg); - struct genlmsghdr *gnlh = (genlmsghdr *)nlmsg_data(nlh); - char ifname[IF_NAMESIZE] = "\0"; + struct nlmsghdr *nlh = nlmsg_hdr(msg); + struct genlmsghdr *gnlh = (genlmsghdr *)nlmsg_data(nlh); + std::string iface_name; + struct nlattr *tb[NL80211_ATTR_MAX + 1]; nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL); if (tb[NL80211_ATTR_IFINDEX]) { - if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), ifname); + auto index = nla_get_u32(tb[NL80211_ATTR_IFINDEX]); + iface_name = beerocks::net::network_utils::linux_get_iface_name(index); } auto event = dwpal_nl_to_bwl_event(gnlh->cmd); switch (event) { case Event::Channel_Scan_Triggered: { - if (m_radio_info.iface_name.compare(ifname) != 0) { + if (m_radio_info.iface_name != iface_name) { // ifname doesn't match current interface // meaning the event was recevied for a diffrent channel return true; @@ -1338,7 +1340,7 @@ bool mon_wlan_hal_dwpal::process_dwpal_nl_event(struct nl_msg *msg) break; } case Event::Channel_Scan_Dump_Result: { - if (m_radio_info.iface_name.compare(ifname) != 0) { + if (m_radio_info.iface_name != iface_name) { // ifname doesn't match current interface // meaning the event was received for a diffrent channel return true; @@ -1380,7 +1382,7 @@ bool mon_wlan_hal_dwpal::process_dwpal_nl_event(struct nl_msg *msg) } case Event::Channel_Scan_Abort: { - if (m_radio_info.iface_name.compare(ifname) != 0) { + if (m_radio_info.iface_name != iface_name) { // ifname doesn't match current interface // meaning the event was recevied for a diffrent channel return true; From 5fe4e82030043f1c5b9ac2122410174f4e097910 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Sun, 12 Jul 2020 13:02:03 +0000 Subject: [PATCH 268/453] controller: db: make persistent params param names public PPM-5. Preparative Commit. Add header file public forward declaration of persistent db param names to allow controller-db to construct a one-shot set/add of a client with a map of key-value of params. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 44 ++++++++++++------------ controller/src/beerocks/master/db/db.h | 12 +++++++ 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index 7c523f98ff..778f2c2d95 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -20,12 +20,12 @@ using namespace beerocks_message; using namespace son; using namespace net; -static const std::string timestamp_str = "timestamp"; -static const std::string timelife_delay_str = "timelife"; -static const std::string initial_radio_enable_str = "initial_radio_enable"; -static const std::string initial_radio_str = "initial_radio"; -static const std::string selected_band_enable_str = "selected_band_enable"; -static const std::string selected_bands_str = "selected_bands"; +const std::string db::TIMESTAMP_STR = "timestamp"; +const std::string db::TIMELIFE_DELAY_STR = "timelife"; +const std::string db::INITIAL_RADIO_ENABLE_STR = "initial_radio_enable"; +const std::string db::INITIAL_RADIO_STR = "initial_radio"; +const std::string db::SELECTED_BAND_ENABLE_STR = "selected_band_enable"; +const std::string db::SELECTED_BANDS_STR = "selected_bands"; // static std::string db::type_to_string(beerocks::eType type) @@ -2545,8 +2545,8 @@ bool db::set_client_time_life_delay(const sMacAddr &mac, LOG(DEBUG) << "configuring persistent-db, timelife = " << time_life_delay_sec.count(); std::unordered_map values_map; - values_map.at(timestamp_str) = timestamp_to_string_seconds(timestamp); - values_map.at(timelife_delay_str) = std::to_string(time_life_delay_sec.count()); + values_map.at(TIMESTAMP_STR) = timestamp_to_string_seconds(timestamp); + values_map.at(TIMELIFE_DELAY_STR) = std::to_string(time_life_delay_sec.count()); // update the persistent db if (!update_client_entry_in_persistent_db(mac, values_map)) { @@ -2588,8 +2588,8 @@ bool db::set_client_stay_on_initial_radio(const sMacAddr &mac, bool stay_on_init LOG(DEBUG) << "configuring persistent-db, initial_radio_enable = " << stay_on_initial_radio; std::unordered_map values_map; - values_map.at(timestamp_str) = timestamp_to_string_seconds(timestamp); - values_map.at(initial_radio_enable_str) = std::to_string(stay_on_initial_radio); + values_map.at(TIMESTAMP_STR) = timestamp_to_string_seconds(timestamp); + values_map.at(INITIAL_RADIO_ENABLE_STR) = std::to_string(stay_on_initial_radio); // update the persistent db if (!update_client_entry_in_persistent_db(mac, values_map)) { @@ -2632,8 +2632,8 @@ bool db::set_client_initial_radio(const sMacAddr &mac, const sMacAddr &initial_r LOG(DEBUG) << "configuring persistent-db, initial_radio = " << initial_radio_mac; std::unordered_map values_map; - values_map.at(timestamp_str) = timestamp_to_string_seconds(timestamp); - values_map.at(initial_radio_str) = tlvf::mac_to_string(initial_radio_mac); + values_map.at(TIMESTAMP_STR) = timestamp_to_string_seconds(timestamp); + values_map.at(INITIAL_RADIO_STR) = tlvf::mac_to_string(initial_radio_mac); // update the persistent db if (!update_client_entry_in_persistent_db(mac, values_map)) { @@ -2675,8 +2675,8 @@ bool db::set_client_stay_on_selected_band(const sMacAddr &mac, bool stay_on_sele LOG(DEBUG) << "configuring persistent-db, selected_band_enable = " << stay_on_selected_band; std::unordered_map values_map; - values_map.at(timestamp_str) = timestamp_to_string_seconds(timestamp); - values_map.at(selected_band_enable_str) = std::to_string(stay_on_selected_band); + values_map.at(TIMESTAMP_STR) = timestamp_to_string_seconds(timestamp); + values_map.at(SELECTED_BAND_ENABLE_STR) = std::to_string(stay_on_selected_band); // update the persistent db if (!update_client_entry_in_persistent_db(mac, values_map)) { @@ -2719,8 +2719,8 @@ bool db::set_client_selected_bands(const sMacAddr &mac, beerocks::eFreqType sele LOG(DEBUG) << ", configuring persistent-db, selected_bands = " << int(selected_bands); std::unordered_map values_map; - values_map.at(timestamp_str) = timestamp_to_string_seconds(timestamp); - values_map.at(selected_bands_str) = std::to_string(selected_bands); + values_map.at(TIMESTAMP_STR) = timestamp_to_string_seconds(timestamp); + values_map.at(SELECTED_BANDS_STR) = std::to_string(selected_bands); // update the persistent db if (!update_client_entry_in_persistent_db(mac, values_map)) { @@ -2798,12 +2798,12 @@ bool db::update_client_persistent_db(const sMacAddr &mac) std::unordered_map values_map; //fill values map of client persistent params - values_map.at(timestamp_str) = timestamp_to_string_seconds(node->client_parameters_last_edit); + values_map.at(TIMESTAMP_STR) = timestamp_to_string_seconds(node->client_parameters_last_edit); if (node->client_time_life_delay_sec != std::chrono::seconds::zero()) { LOG(DEBUG) << "setting client time-life-delay in persistent-db to for " << mac << " to " << node->client_time_life_delay_sec.count(); - values_map.at(timelife_delay_str) = + values_map.at(TIMELIFE_DELAY_STR) = std::to_string(node->client_time_life_delay_sec.count()); } @@ -2811,26 +2811,26 @@ bool db::update_client_persistent_db(const sMacAddr &mac) auto enable = (node->client_stay_on_initial_radio == eTriStateBool::ENABLE); LOG(DEBUG) << "setting client stay-on-initial-radio in persistent-db to for " << mac << " to " << enable; - values_map.at(initial_radio_enable_str) = std::to_string(enable); + values_map.at(INITIAL_RADIO_ENABLE_STR) = std::to_string(enable); } if (node->client_initial_radio != network_utils::ZERO_MAC) { LOG(DEBUG) << "setting client initial-radio in persistent-db to for " << mac << " to " << node->client_initial_radio; - values_map.at(initial_radio_str) = tlvf::mac_to_string(node->client_initial_radio); + values_map.at(INITIAL_RADIO_STR) = tlvf::mac_to_string(node->client_initial_radio); } if (node->client_stay_on_selected_band != eTriStateBool::NOT_CONFIGURED) { auto enable = (node->client_stay_on_selected_band == eTriStateBool::ENABLE); LOG(DEBUG) << "setting client stay-on-selected-band in persistent-db to for " << mac << " to " << enable; - values_map.at(selected_band_enable_str) = std::to_string(enable); + values_map.at(SELECTED_BAND_ENABLE_STR) = std::to_string(enable); } if (node->client_selected_bands != beerocks::eFreqType::FREQ_UNKNOWN) { LOG(DEBUG) << "setting client selected-bands in persistent-db to for " << mac << " to " << node->client_selected_bands; - values_map.at(selected_bands_str) = std::to_string(node->client_selected_bands); + values_map.at(SELECTED_BANDS_STR) = std::to_string(node->client_selected_bands); } // update the persistent db diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index 87880c773a..5ef455f9aa 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -45,6 +45,18 @@ class db { } sBmlListener; public: + /** + * @brief Client parameter names. + * The parameter names can be used to set/get multiple parameters in one-shot. + * This is done using key-value map (where key is the param name and value is it value) + */ + static const std::string TIMESTAMP_STR; + static const std::string TIMELIFE_DELAY_STR; + static const std::string INITIAL_RADIO_ENABLE_STR; + static const std::string INITIAL_RADIO_STR; + static const std::string SELECTED_BAND_ENABLE_STR; + static const std::string SELECTED_BANDS_STR; + // VAPs info list type typedef std::list> vaps_list_t; From 90d9131339efb79387d1684c5df78a2c22a9876f Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Tue, 14 Jul 2020 12:32:37 +0000 Subject: [PATCH 269/453] controller: db: replace .at() with operator[] in unordered map The .at() function of unordered-map should be used for const maps and for items in the map we are certain exist and not for addition of new items where operator[]. Replaced all occurences of .at() with use of operator[]. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 33 ++++++++++++------------ 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index 778f2c2d95..23dc33e413 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -2545,8 +2545,8 @@ bool db::set_client_time_life_delay(const sMacAddr &mac, LOG(DEBUG) << "configuring persistent-db, timelife = " << time_life_delay_sec.count(); std::unordered_map values_map; - values_map.at(TIMESTAMP_STR) = timestamp_to_string_seconds(timestamp); - values_map.at(TIMELIFE_DELAY_STR) = std::to_string(time_life_delay_sec.count()); + values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); + values_map[TIMELIFE_DELAY_STR] = std::to_string(time_life_delay_sec.count()); // update the persistent db if (!update_client_entry_in_persistent_db(mac, values_map)) { @@ -2588,8 +2588,8 @@ bool db::set_client_stay_on_initial_radio(const sMacAddr &mac, bool stay_on_init LOG(DEBUG) << "configuring persistent-db, initial_radio_enable = " << stay_on_initial_radio; std::unordered_map values_map; - values_map.at(TIMESTAMP_STR) = timestamp_to_string_seconds(timestamp); - values_map.at(INITIAL_RADIO_ENABLE_STR) = std::to_string(stay_on_initial_radio); + values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); + values_map[INITIAL_RADIO_ENABLE_STR] = std::to_string(stay_on_initial_radio); // update the persistent db if (!update_client_entry_in_persistent_db(mac, values_map)) { @@ -2632,8 +2632,8 @@ bool db::set_client_initial_radio(const sMacAddr &mac, const sMacAddr &initial_r LOG(DEBUG) << "configuring persistent-db, initial_radio = " << initial_radio_mac; std::unordered_map values_map; - values_map.at(TIMESTAMP_STR) = timestamp_to_string_seconds(timestamp); - values_map.at(INITIAL_RADIO_STR) = tlvf::mac_to_string(initial_radio_mac); + values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); + values_map[INITIAL_RADIO_STR] = tlvf::mac_to_string(initial_radio_mac); // update the persistent db if (!update_client_entry_in_persistent_db(mac, values_map)) { @@ -2675,8 +2675,8 @@ bool db::set_client_stay_on_selected_band(const sMacAddr &mac, bool stay_on_sele LOG(DEBUG) << "configuring persistent-db, selected_band_enable = " << stay_on_selected_band; std::unordered_map values_map; - values_map.at(TIMESTAMP_STR) = timestamp_to_string_seconds(timestamp); - values_map.at(SELECTED_BAND_ENABLE_STR) = std::to_string(stay_on_selected_band); + values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); + values_map[SELECTED_BAND_ENABLE_STR] = std::to_string(stay_on_selected_band); // update the persistent db if (!update_client_entry_in_persistent_db(mac, values_map)) { @@ -2719,8 +2719,8 @@ bool db::set_client_selected_bands(const sMacAddr &mac, beerocks::eFreqType sele LOG(DEBUG) << ", configuring persistent-db, selected_bands = " << int(selected_bands); std::unordered_map values_map; - values_map.at(TIMESTAMP_STR) = timestamp_to_string_seconds(timestamp); - values_map.at(SELECTED_BANDS_STR) = std::to_string(selected_bands); + values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); + values_map[SELECTED_BANDS_STR] = std::to_string(selected_bands); // update the persistent db if (!update_client_entry_in_persistent_db(mac, values_map)) { @@ -2798,39 +2798,38 @@ bool db::update_client_persistent_db(const sMacAddr &mac) std::unordered_map values_map; //fill values map of client persistent params - values_map.at(TIMESTAMP_STR) = timestamp_to_string_seconds(node->client_parameters_last_edit); + values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(node->client_parameters_last_edit); if (node->client_time_life_delay_sec != std::chrono::seconds::zero()) { LOG(DEBUG) << "setting client time-life-delay in persistent-db to for " << mac << " to " << node->client_time_life_delay_sec.count(); - values_map.at(TIMELIFE_DELAY_STR) = - std::to_string(node->client_time_life_delay_sec.count()); + values_map[TIMELIFE_DELAY_STR] = std::to_string(node->client_time_life_delay_sec.count()); } if (node->client_stay_on_initial_radio != eTriStateBool::NOT_CONFIGURED) { auto enable = (node->client_stay_on_initial_radio == eTriStateBool::ENABLE); LOG(DEBUG) << "setting client stay-on-initial-radio in persistent-db to for " << mac << " to " << enable; - values_map.at(INITIAL_RADIO_ENABLE_STR) = std::to_string(enable); + values_map[INITIAL_RADIO_ENABLE_STR] = std::to_string(enable); } if (node->client_initial_radio != network_utils::ZERO_MAC) { LOG(DEBUG) << "setting client initial-radio in persistent-db to for " << mac << " to " << node->client_initial_radio; - values_map.at(INITIAL_RADIO_STR) = tlvf::mac_to_string(node->client_initial_radio); + values_map[INITIAL_RADIO_STR] = tlvf::mac_to_string(node->client_initial_radio); } if (node->client_stay_on_selected_band != eTriStateBool::NOT_CONFIGURED) { auto enable = (node->client_stay_on_selected_band == eTriStateBool::ENABLE); LOG(DEBUG) << "setting client stay-on-selected-band in persistent-db to for " << mac << " to " << enable; - values_map.at(SELECTED_BAND_ENABLE_STR) = std::to_string(enable); + values_map[SELECTED_BAND_ENABLE_STR] = std::to_string(enable); } if (node->client_selected_bands != beerocks::eFreqType::FREQ_UNKNOWN) { LOG(DEBUG) << "setting client selected-bands in persistent-db to for " << mac << " to " << node->client_selected_bands; - values_map.at(SELECTED_BANDS_STR) = std::to_string(node->client_selected_bands); + values_map[SELECTED_BANDS_STR] = std::to_string(node->client_selected_bands); } // update the persistent db From bd934335dc245ab2ca0860b099f1fcb243e56c95 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Mon, 13 Jul 2020 05:39:03 +0000 Subject: [PATCH 270/453] controller: db: check persistent db enabled before bpl access PPM-5. Added check of persistent_db value in the controller config before accessing the BPL. For relevant APIs, return an error if called with persistent-db is disabled. For relevant APIs, skip BPL-access and perform only runtime-db configuration. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 147 +++++++++++++++-------- 1 file changed, 97 insertions(+), 50 deletions(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index 23dc33e413..b1db5588be 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -2492,6 +2492,12 @@ bool db::is_client_in_persistent_db(const sMacAddr &mac) bool db::add_client_to_persistent_db(const sMacAddr &mac, std::unordered_map params) { + // if persistent db is disabled + if (!config.persistent_db) { + LOG(ERROR) << "persistent db is disabled"; + return false; + } + auto db_entry = client_db_entry_from_mac(mac); if (!bpl::db_has_entry(std::string("type"), db_entry)) { @@ -2542,16 +2548,21 @@ bool db::set_client_time_life_delay(const sMacAddr &mac, auto timestamp = std::chrono::steady_clock::now(); if (save_to_persistent_db) { - LOG(DEBUG) << "configuring persistent-db, timelife = " << time_life_delay_sec.count(); + // if persistent db is disabled + if (!config.persistent_db) { + LOG(DEBUG) << "persistent db is disabled"; + } else { + LOG(DEBUG) << "configuring persistent-db, timelife = " << time_life_delay_sec.count(); - std::unordered_map values_map; - values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); - values_map[TIMELIFE_DELAY_STR] = std::to_string(time_life_delay_sec.count()); + std::unordered_map values_map; + values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); + values_map[TIMELIFE_DELAY_STR] = std::to_string(time_life_delay_sec.count()); - // update the persistent db - if (!update_client_entry_in_persistent_db(mac, values_map)) { - LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; - return false; + // update the persistent db + if (!update_client_entry_in_persistent_db(mac, values_map)) { + LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; + return false; + } } } @@ -2585,16 +2596,22 @@ bool db::set_client_stay_on_initial_radio(const sMacAddr &mac, bool stay_on_init auto timestamp = std::chrono::steady_clock::now(); if (save_to_persistent_db) { - LOG(DEBUG) << "configuring persistent-db, initial_radio_enable = " << stay_on_initial_radio; + // if persistent db is disabled + if (!config.persistent_db) { + LOG(DEBUG) << "persistent db is disabled"; + } else { + LOG(DEBUG) << "configuring persistent-db, initial_radio_enable = " + << stay_on_initial_radio; - std::unordered_map values_map; - values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); - values_map[INITIAL_RADIO_ENABLE_STR] = std::to_string(stay_on_initial_radio); + std::unordered_map values_map; + values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); + values_map[INITIAL_RADIO_ENABLE_STR] = std::to_string(stay_on_initial_radio); - // update the persistent db - if (!update_client_entry_in_persistent_db(mac, values_map)) { - LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; - return false; + // update the persistent db + if (!update_client_entry_in_persistent_db(mac, values_map)) { + LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; + return false; + } } } @@ -2629,16 +2646,21 @@ bool db::set_client_initial_radio(const sMacAddr &mac, const sMacAddr &initial_r auto timestamp = std::chrono::steady_clock::now(); if (save_to_persistent_db) { - LOG(DEBUG) << "configuring persistent-db, initial_radio = " << initial_radio_mac; + // if persistent db is disabled + if (!config.persistent_db) { + LOG(DEBUG) << "persistent db is disabled"; + } else { + LOG(DEBUG) << "configuring persistent-db, initial_radio = " << initial_radio_mac; - std::unordered_map values_map; - values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); - values_map[INITIAL_RADIO_STR] = tlvf::mac_to_string(initial_radio_mac); + std::unordered_map values_map; + values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); + values_map[INITIAL_RADIO_STR] = tlvf::mac_to_string(initial_radio_mac); - // update the persistent db - if (!update_client_entry_in_persistent_db(mac, values_map)) { - LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; - return false; + // update the persistent db + if (!update_client_entry_in_persistent_db(mac, values_map)) { + LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; + return false; + } } } @@ -2672,16 +2694,22 @@ bool db::set_client_stay_on_selected_band(const sMacAddr &mac, bool stay_on_sele auto timestamp = std::chrono::steady_clock::now(); if (save_to_persistent_db) { - LOG(DEBUG) << "configuring persistent-db, selected_band_enable = " << stay_on_selected_band; + // if persistent db is disabled + if (!config.persistent_db) { + LOG(DEBUG) << "persistent db is disabled"; + } else { + LOG(DEBUG) << "configuring persistent-db, selected_band_enable = " + << stay_on_selected_band; - std::unordered_map values_map; - values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); - values_map[SELECTED_BAND_ENABLE_STR] = std::to_string(stay_on_selected_band); + std::unordered_map values_map; + values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); + values_map[SELECTED_BAND_ENABLE_STR] = std::to_string(stay_on_selected_band); - // update the persistent db - if (!update_client_entry_in_persistent_db(mac, values_map)) { - LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; - return false; + // update the persistent db + if (!update_client_entry_in_persistent_db(mac, values_map)) { + LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; + return false; + } } } @@ -2716,16 +2744,21 @@ bool db::set_client_selected_bands(const sMacAddr &mac, beerocks::eFreqType sele auto timestamp = std::chrono::steady_clock::now(); if (save_to_persistent_db) { - LOG(DEBUG) << ", configuring persistent-db, selected_bands = " << int(selected_bands); + // if persistent db is disabled + if (!config.persistent_db) { + LOG(DEBUG) << "persistent db is disabled"; + } else { + LOG(DEBUG) << ", configuring persistent-db, selected_bands = " << int(selected_bands); - std::unordered_map values_map; - values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); - values_map[SELECTED_BANDS_STR] = std::to_string(selected_bands); + std::unordered_map values_map; + values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); + values_map[SELECTED_BANDS_STR] = std::to_string(selected_bands); - // update the persistent db - if (!update_client_entry_in_persistent_db(mac, values_map)) { - LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; - return false; + // update the persistent db + if (!update_client_entry_in_persistent_db(mac, values_map)) { + LOG(ERROR) << "failed to update client entry in persistent-db to for " << mac; + return false; + } } } @@ -2763,17 +2796,19 @@ bool db::clear_client_persistent_db(const sMacAddr &mac) node->client_stay_on_selected_band = eTriStateBool::NOT_CONFIGURED; node->client_selected_bands = beerocks::eFreqType::FREQ_UNKNOWN; - LOG(DEBUG) << "removing client " << mac << " from persistent db"; - auto db_entry = client_db_entry_from_mac(mac); - auto type_client_str = type_to_string(beerocks::eType::TYPE_CLIENT); - if (!bpl::db_has_entry(type_client_str, db_entry)) { - LOG(DEBUG) << "client entry does not exist in persistent-db for " << db_entry; - return true; - } + // if persistent db is enabled + if (config.persistent_db) { + auto db_entry = client_db_entry_from_mac(mac); + auto type_client_str = type_to_string(beerocks::eType::TYPE_CLIENT); + if (!bpl::db_has_entry(type_client_str, db_entry)) { + LOG(DEBUG) << "client entry does not exist in persistent-db for " << db_entry; + return true; + } - if (!bpl::db_remove_entry(type_client_str, db_entry)) { - LOG(ERROR) << "failed to remove client entry " << db_entry; - return false; + if (!bpl::db_remove_entry(type_client_str, db_entry)) { + LOG(ERROR) << "failed to remove client entry " << db_entry; + return false; + } } return true; @@ -2781,6 +2816,12 @@ bool db::clear_client_persistent_db(const sMacAddr &mac) bool db::update_client_persistent_db(const sMacAddr &mac) { + // if persistent db is disabled + if (!config.persistent_db) { + LOG(ERROR) << "persistent db is disabled"; + return false; + } + auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); if (!node) { LOG(ERROR) << "client node not found for mac " << mac; @@ -2846,6 +2887,12 @@ bool db::update_client_persistent_db(const sMacAddr &mac) std::unordered_map> db::load_persistent_db_clients() { + // if persistent db is disabled + if (!config.persistent_db) { + LOG(ERROR) << "persistent db is disabled"; + return {}; + } + std::unordered_map> clients; if (!bpl::db_get_entries_by_type(type_to_string(beerocks::eType::TYPE_CLIENT), clients)) { LOG(ERROR) << "failed to get all clients from persistent DB"; From f71ef9764d3868c18c2f4397708aef58d1d55e04 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Mon, 13 Jul 2020 06:01:32 +0000 Subject: [PATCH 271/453] controller: db: add missing function description PPM-5. Added missing function description to update_client_entry_in_persistent_db(). Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index 5ef455f9aa..d88d985c30 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -1093,6 +1093,14 @@ class db { void rewind(); bool get_next_node(std::shared_ptr &n, int &hierarchy); bool get_next_node(std::shared_ptr &n); + + /** + * @brief Updates the client values in the persistent db. + * + * @param mac MAC address of a client. + * @param values_map A map of client params and their values. + * @return true on success, otherwise false. + */ bool update_client_entry_in_persistent_db(const sMacAddr &mac, std::unordered_map values_map); From eaa7de6fa244528731f3f2a1daac280857e11126 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Mon, 13 Jul 2020 06:30:15 +0000 Subject: [PATCH 272/453] controller: db: add persistent db clients counter PPM-5. Preparative commit. Added persistent db clients counter to the db class. Added private functions to add/remove clients that encapsulate the increment/decrement of the counter. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 25 ++++++++++++++++++++++++ controller/src/beerocks/master/db/db.h | 21 ++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index b1db5588be..7d31f34d7a 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -4227,3 +4227,28 @@ bool db::update_client_entry_in_persistent_db( return true; } + +bool db::add_client_entry_and_update_counter( + const std::string &entry_name, const std::unordered_map &values_map) +{ + if (!bpl::db_add_entry(type_to_string(beerocks::eType::TYPE_CLIENT), entry_name, values_map)) { + LOG(ERROR) << "failed to add client entry " << entry_name << " to persistent db"; + return false; + } + + ++m_persistent_db_clients_count; + + return true; +} + +bool db::remove_client_entry_and_update_counter(const std::string &entry_name) +{ + if (!bpl::db_remove_entry(type_to_string(beerocks::eType::TYPE_CLIENT), entry_name)) { + LOG(ERROR) << "failed to remove entry " << entry_name << "from persistent db"; + return false; + } + --m_persistent_db_clients_count; + + return false; +} + diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index d88d985c30..8853cea8c1 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -1105,6 +1105,25 @@ class db { update_client_entry_in_persistent_db(const sMacAddr &mac, std::unordered_map values_map); + /** + * @brief Adds a client entry to persistent_db with configured parameters and increments clients counter. + * + * @param entry_name Client entry name in persistent db. + * @param values_map A map of client params and their values. + * @return true on success, otherwise false. + */ + bool add_client_entry_and_update_counter( + const std::string &entry_name, + const std::unordered_map &values_map); + + /** + * @brief Removes a client entry from persistent_db and decrements clients counter. + * + * @param entry_name Client entry name in persistent db. + * @return true on success, otherwise false. + */ + bool remove_client_entry_and_update_counter(const std::string &entry_name); + int network_optimization_task_id = -1; int channel_selection_task_id = -1; int bml_task_id = -1; @@ -1165,6 +1184,8 @@ class db { master_thread *m_master_thread_ctx = nullptr; const std::string m_local_bridge_mac; + + int m_persistent_db_clients_count = 0; }; } // namespace son From 312cf313b845a52c11d98f87b8eb20dab770c6f1 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Mon, 13 Jul 2020 07:21:59 +0000 Subject: [PATCH 273/453] controller: db: replace bpl direct add/remove with db APIs PPM-5. Replaced direct BPL calls to add/remove a client from to/from the persistent db with calls to the db class APIs which encapsulate the increment/decrement of the persistent db clients' counter respectively. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 30 +++++++++++++----------- controller/src/beerocks/master/db/db.h | 7 +++--- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index 7d31f34d7a..b114446387 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -2490,7 +2490,7 @@ bool db::is_client_in_persistent_db(const sMacAddr &mac) } bool db::add_client_to_persistent_db(const sMacAddr &mac, - std::unordered_map params) + const std::unordered_map ¶ms) { // if persistent db is disabled if (!config.persistent_db) { @@ -2500,25 +2500,28 @@ bool db::add_client_to_persistent_db(const sMacAddr &mac, auto db_entry = client_db_entry_from_mac(mac); - if (!bpl::db_has_entry(std::string("type"), db_entry)) { + if (bpl::db_has_entry(type_to_string(beerocks::eType::TYPE_CLIENT), db_entry)) { // if entry already exists in DB - if (!bpl::db_remove_entry(std::string("type"), db_entry)) { + if (!remove_client_entry_and_update_counter(db_entry)) { LOG(ERROR) << "failed to remove client entry " << db_entry << "from persistent db (for re-adding)"; return false; } - } else if (!bpl::db_has_entry(std::string(), db_entry)) { + } else if (bpl::db_has_entry(std::string(), db_entry)) { // if entry exists in db but with different type LOG(ERROR) << "client entry cannot be added to persistent db, " << db_entry << " already exists but with different type"; return false; } // add entry to the persistent db - if (!bpl::db_add_entry(type_to_string(beerocks::eType::TYPE_CLIENT), db_entry, params)) { + if (!add_client_entry_and_update_counter(db_entry, params)) { LOG(ERROR) << "failed to add client entry " << db_entry << " to persistent db"; return false; } - LOG(DEBUG) << "added client entry " << db_entry << " to persistent db"; + + LOG(DEBUG) << "added client entry " << db_entry + << " to persistent db, total clients count in persisttent-db: " + << m_persistent_db_clients_count; return true; } @@ -2798,14 +2801,14 @@ bool db::clear_client_persistent_db(const sMacAddr &mac) // if persistent db is enabled if (config.persistent_db) { - auto db_entry = client_db_entry_from_mac(mac); - auto type_client_str = type_to_string(beerocks::eType::TYPE_CLIENT); - if (!bpl::db_has_entry(type_client_str, db_entry)) { + auto db_entry = client_db_entry_from_mac(mac); + if (!bpl::db_has_entry(type_to_string(beerocks::eType::TYPE_CLIENT), db_entry)) { LOG(DEBUG) << "client entry does not exist in persistent-db for " << db_entry; return true; } - if (!bpl::db_remove_entry(type_client_str, db_entry)) { + LOG(DEBUG) << "removing client entry " << db_entry << " from persistent db"; + if (!remove_client_entry_and_update_counter(db_entry)) { LOG(ERROR) << "failed to remove client entry " << db_entry; return false; } @@ -3989,8 +3992,8 @@ std::shared_ptr db::get_node_verify_type(const sMacAddr &mac, beerocks::eT LOG(ERROR) << "node not found for mac " << mac; return nullptr; } else if (node->get_type() != type) { - LOG(ERROR) << __FUNCTION__ << "node " << mac << " type(" << node->get_type() - << ") != requested-type(" << type << ")"; + LOG(ERROR) << "node " << mac << " type(" << node->get_type() << ") != requested-type(" + << type << ")"; return nullptr; } @@ -4210,7 +4213,7 @@ void db::set_prplmesh(const sMacAddr &mac) } bool db::update_client_entry_in_persistent_db( - const sMacAddr &mac, std::unordered_map values_map) + const sMacAddr &mac, const std::unordered_map &values_map) { auto db_entry = client_db_entry_from_mac(mac); auto type_client_str = type_to_string(beerocks::eType::TYPE_CLIENT); @@ -4251,4 +4254,3 @@ bool db::remove_client_entry_and_update_counter(const std::string &entry_name) return false; } - diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index 8853cea8c1..f8dff93a4b 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -666,7 +666,7 @@ class db { * @return true on success, otherwise false. */ bool add_client_to_persistent_db(const sMacAddr &mac, - std::unordered_map params = + const std::unordered_map ¶ms = std::unordered_map()); /** @@ -1101,9 +1101,8 @@ class db { * @param values_map A map of client params and their values. * @return true on success, otherwise false. */ - bool - update_client_entry_in_persistent_db(const sMacAddr &mac, - std::unordered_map values_map); + bool update_client_entry_in_persistent_db( + const sMacAddr &mac, const std::unordered_map &values_map); /** * @brief Adds a client entry to persistent_db with configured parameters and increments clients counter. From 13db0cb935873e09c719087f5b538384fa725407 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Mon, 13 Jul 2020 07:24:37 +0000 Subject: [PATCH 274/453] controller: db: add API to set node params from map PPM-5. Added API to set node-params from a map of . This API enables us to update multiple params in a node in a single-shot which provides efficiency compared to performing a separate call update using the existing db class APIs. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 48 ++++++++++++++++++++++++ controller/src/beerocks/master/db/db.h | 10 +++++ 2 files changed, 58 insertions(+) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index b114446387..93e0bd8ed9 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -4231,6 +4231,54 @@ bool db::update_client_entry_in_persistent_db( return true; } +bool db::set_node_params_from_map(const sMacAddr &mac, + const std::unordered_map &values_map) +{ + auto node = get_node(mac); + if (!node) { + LOG(WARNING) << " - node " << mac << " does not exist!"; + return false; + } + + for (const auto ¶m : values_map) { + if (param.first == TIMESTAMP_STR) { + LOG(DEBUG) << "setting node client_parameters_last_edit to " << param.second << " for " + << mac; + node->client_parameters_last_edit = + timestamp_from_seconds(string_utils::stoi(param.second)); + } else if (param.first == TIMELIFE_DELAY_STR) { + LOG(DEBUG) << "setting node client_time_life_delay_sec to " << param.second << " for " + << mac; + node->client_time_life_delay_sec = + std::chrono::seconds(string_utils::stoi(param.second)); + } else if (param.first == INITIAL_RADIO_ENABLE_STR) { + LOG(DEBUG) << "setting node client_stay_on_initial_radio to " << param.second << " for " + << mac; + + node->client_stay_on_initial_radio = + (param.second == "1") ? eTriStateBool::ENABLE : eTriStateBool::DISABLE; + } else if (param.first == INITIAL_RADIO_STR) { + LOG(DEBUG) << "setting node client_initial_radio to " << param.second << " for " << mac; + + node->client_initial_radio = tlvf::mac_from_string(param.second); + } else if (param.first == SELECTED_BAND_ENABLE_STR) { + LOG(DEBUG) << "setting node client_stay_on_selected_band to " << param.second << " for " + << mac; + + node->client_stay_on_selected_band = + (param.second == "1") ? eTriStateBool::ENABLE : eTriStateBool::DISABLE; + } else if (param.first == SELECTED_BANDS_STR) { + LOG(DEBUG) << "setting node client_selected_bands to " << param.second << " for " + << mac; + node->client_selected_bands = beerocks::eFreqType(string_utils::stoi(param.second)); + } else { + LOG(WARNING) << "Unknown parameter, skipping: " << param.first << " for " << mac; + } + } + + return true; +} + bool db::add_client_entry_and_update_counter( const std::string &entry_name, const std::unordered_map &values_map) { diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index f8dff93a4b..b4f2e5440f 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -1104,6 +1104,16 @@ class db { bool update_client_entry_in_persistent_db( const sMacAddr &mac, const std::unordered_map &values_map); + /** + * @brief Sets the node params (runtime db) from a param-value map. + * + * @param mac MAC address of node to be updated. + * @param values_map A map of client params and their values. + * @return true on success, otherwise false. + */ + bool set_node_params_from_map(const sMacAddr &mac, + const std::unordered_map &values_map); + /** * @brief Adds a client entry to persistent_db with configured parameters and increments clients counter. * From adc9461469a4ec63fae3b816618c2d621389dfaa Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Mon, 13 Jul 2020 08:05:34 +0000 Subject: [PATCH 275/453] controller: db: add function to get client to be removed PPM-5. Added function to get the preferred client to be removed from the persistent-db. The preference mentioned above is according to the following, and is detailed in the function description: - prefer disconnected clients over connected clients. - according to the above, find the client with the least time left before aging. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 64 ++++++++++++++++++++++++ controller/src/beerocks/master/db/db.h | 10 ++++ 2 files changed, 74 insertions(+) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index 93e0bd8ed9..147fa5a32d 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -4302,3 +4302,67 @@ bool db::remove_client_entry_and_update_counter(const std::string &entry_name) return false; } + +sMacAddr db::get_candidate_client_for_removal() +{ + const auto max_timelife_delay_sec = + std::chrono::seconds(config.max_timelife_delay_days * 24 * 3600); + + sMacAddr candidate_client_to_be_removed = network_utils::ZERO_MAC; + bool is_disconnected_candidate_available = false; + auto candidate_client_expiry_due_time = std::chrono::steady_clock::time_point::max(); + + for (const auto &node_map : nodes) { + for (const auto &key_value : node_map) { + const auto client = key_value.second; + if (client->get_type() == beerocks::eType::TYPE_CLIENT) { + //TODO: improvement - stop search if "already-aged" candidate is found (don't-care of connectivity status) + + // Skip clients which have no persistent information. + if (client->client_parameters_last_edit == + std::chrono::steady_clock::time_point::min()) { + continue; + } + + // Preferring disconnected clients over connected ones (even if less aged). + if (is_disconnected_candidate_available && + client->state != beerocks::STATE_DISCONNECTED) { + continue; + } + + // Client timelife delay + //TODO: use max_timelife_delay_sec/unfriendly_max_timelife_delay_sec according to "is_unfriendly" check which is yet-to-be-defined + auto timelife_delay = + (client->client_time_life_delay_sec != std::chrono::seconds::zero()) + ? client->client_time_life_delay_sec + : max_timelife_delay_sec; + + // Calculate client expiry due time + auto current_client_expiry_due = + client->client_parameters_last_edit + timelife_delay; + + // Compare to currently chosen candidate expiry due time. + // The case where a client is connected and we already found a disconnected cadidate + // is handled above - meaning we can assume that either we didn't find any candidate + // yet or the candidate found is connected (meaning only the remaining timelife + // should be compared) + if (current_client_expiry_due < candidate_client_expiry_due_time) { + candidate_client_expiry_due_time = current_client_expiry_due; + if (client->state == beerocks::STATE_DISCONNECTED) { + is_disconnected_candidate_available = true; + } + candidate_client_to_be_removed = tlvf::mac_from_string(key_value.first); + } + } + } + } + + if (candidate_client_to_be_removed == network_utils::ZERO_MAC) { + LOG(DEBUG) << "no client to be removed is found"; + } else { + LOG(DEBUG) << "candidate client to be removed is currently " + << ((is_disconnected_candidate_available) ? "disconnected" : "connected"); + } + + return candidate_client_to_be_removed; +} diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index b4f2e5440f..fd60efea0a 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -1133,6 +1133,16 @@ class db { */ bool remove_client_entry_and_update_counter(const std::string &entry_name); + /** + * @brief Returns the preferred client to be removed. + * Preference is determined as follows: + * - Prefer disconnected clients over connected ones. + * - According to above, the client with least time left before aging. + * + * @return sMacAddr mac of candidate client to be removed - if not found, string_utils::ZERO_MAC is returned. + */ + sMacAddr get_candidate_client_for_removal(); + int network_optimization_task_id = -1; int channel_selection_task_id = -1; int bml_task_id = -1; From 49cc08d95f5cfe13f94c39a03049939fc7b9206a Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Mon, 13 Jul 2020 08:15:26 +0000 Subject: [PATCH 276/453] controller: db: add function to remove most aged client PPM-5. Added function to remove the client provided by the get_candidate_client_for_removal() function. The function uses the clear_client_persistent_db() which clears any persistent parameters from the runtime DB and removes the client from the persistent DB. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 20 ++++++++++++++++++++ controller/src/beerocks/master/db/db.h | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index 147fa5a32d..405d2a315f 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -4303,6 +4303,26 @@ bool db::remove_client_entry_and_update_counter(const std::string &entry_name) return false; } +bool db::remove_candidate_client() +{ + + // find cadidate client to be removed + sMacAddr client_to_remove = get_candidate_client_for_removal(); + if (client_to_remove == network_utils::ZERO_MAC) { + LOG(ERROR) << "failed to find client to be removed, number of persistent db clients is " + << m_persistent_db_clients_count; + return false; + } + + // clear persistent data in runtime db and remove from persistent db + if (!clear_client_persistent_db(client_to_remove)) { + LOG(ERROR) << "failed to clear client persistent data and remove it from persistent db"; + return false; + } + + return true; +} + sMacAddr db::get_candidate_client_for_removal() { const auto max_timelife_delay_sec = diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index fd60efea0a..5f908cc53e 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -1133,6 +1133,13 @@ class db { */ bool remove_client_entry_and_update_counter(const std::string &entry_name); + /** + * @brief Removes client with least timelife remaining from persistent db (with preference to disconnected clients). + * + * @return true on success, otherwise false. + */ + bool remove_candidate_client(); + /** * @brief Returns the preferred client to be removed. * Preference is determined as follows: From 61372415b5eb014647e70cf2932b5132a2e0a96b Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Mon, 13 Jul 2020 08:19:59 +0000 Subject: [PATCH 277/453] controller: db: remove a client if persistent db is full PPM-5. Added a check of the clients counter to the add_client_to_persistent_db() function. If persistent DB is full, a client is removed before adding the new client to the persistent DB. The removal of a client utilizes the remove_candidate_client() function. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index 405d2a315f..b90f90170d 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -2513,6 +2513,17 @@ bool db::add_client_to_persistent_db(const sMacAddr &mac, << " already exists but with different type"; return false; } + + if (m_persistent_db_clients_count >= config.clients_persistent_db_max_size) { + LOG(DEBUG) << "reached max clients size in persistent db - removing a client before adding " + "new client"; + if (!remove_candidate_client()) { + LOG(ERROR) << "failed to remove next-to-be-aged client entry " << db_entry + << "from persistent db (due to full persistent db)"; + return false; + } + } + // add entry to the persistent db if (!add_client_entry_and_update_counter(db_entry, params)) { LOG(ERROR) << "failed to add client entry " << db_entry << " to persistent db"; From 3f0c7e683e7e63cd4114cabcf913fe05dec45b76 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Mon, 13 Jul 2020 08:26:19 +0000 Subject: [PATCH 278/453] controller: db: refactor load_persistent_db_clients() PPM-5. The load_persistent_db_clients() API current implementation, and purpose is to provide an interface to read all the clients from the BPL, and the responsibility of adding nodes for those clients as well as filter-out aged clients was on the caller. A more suitable approach is to handle all of the above internally and leave the caller of the API only the responsibility of triggering it. Changed the API return value to success/fail instead of a map of clients. Filtered-out aged client-entries and client-entries not containing a valid timestamp. The filtered-out clients are removed from persistent DB as well as not added to runtime DB. Added nodes for "valid" client entries with the persistent data read from persistent DB. While at it, added an is_valid_mac() check to the client_db_entry_to_mac() implementation. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 131 +++++++++++++++++++++-- controller/src/beerocks/master/db/db.h | 11 +- 2 files changed, 127 insertions(+), 15 deletions(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index b90f90170d..e9ac8bc703 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -53,6 +53,7 @@ std::string db::type_to_string(beerocks::eType type) std::string db::client_db_entry_from_mac(const sMacAddr &mac) { std::string db_entry = tlvf::mac_to_string(mac); + std::replace(db_entry.begin(), db_entry.end(), ':', '_'); return db_entry; @@ -64,6 +65,10 @@ sMacAddr db::client_db_entry_to_mac(const std::string &db_entry) std::replace(entry.begin(), entry.end(), '_', ':'); + if (!network_utils::is_valid_mac(entry)) { + return network_utils::ZERO_MAC; + } + return tlvf::mac_from_string(entry); } @@ -2898,27 +2903,133 @@ bool db::update_client_persistent_db(const sMacAddr &mac) return true; } -std::unordered_map> -db::load_persistent_db_clients() +bool db::load_persistent_db_clients() { - // if persistent db is disabled + // If persistent db is disabled function should not be called if (!config.persistent_db) { - LOG(ERROR) << "persistent db is disabled"; - return {}; + LOG(ERROR) << "Persistent db is disabled"; + return false; } std::unordered_map> clients; if (!bpl::db_get_entries_by_type(type_to_string(beerocks::eType::TYPE_CLIENT), clients)) { - LOG(ERROR) << "failed to get all clients from persistent DB"; - return {}; + LOG(ERROR) << "Failed to get all clients from persistent DB"; + return false; } if (clients.empty()) { - LOG(DEBUG) << "persistent DB doesn't exist (or empty) or doesn't contain clients"; - return {}; + LOG(DEBUG) << "Persistent DB doesn't exist, is empty, or doesn't contain clients"; + return false; + } + + // Counters for client nodes-add success/fail (filtered-out client entries are not counted) + int add_node_error_count = 0; + int set_node_error_count = 0; + int clients_added_no_error = 0; + + // Add clients to runtime db - invalid client (no timestamp or aged entries) are filtered out + for (const auto &client : clients) { + const auto &client_entry = client.first; + auto &client_data_map = client.second; + + // Add node for client and fill with persistent data. + auto add_new_client_with_persistent_data_to_nodes_list = + [&](const sMacAddr &client_mac, + const std::unordered_map values_map) -> bool { + // Add client node with defaults and in default location + if (!add_node(client_mac)) { + LOG(ERROR) << "Failed to add client node for client_entry " << client_entry; + ++add_node_error_count; + return false; + } + + // Set clients persistent information in the node + if (!set_node_params_from_map(client_mac, values_map)) { + LOG(ERROR) << "Failed to set client " << client_mac + << " node in runtime db with values read from persistent db: " + << values_map; + ++set_node_error_count; + return false; + } + + LOG(DEBUG) << "Client " << client_mac + << " added successfully to node-list with parameters: " << values_map; + + ++clients_added_no_error; + return true; + }; + + static const auto type_client_str = db::type_to_string(beerocks::eType::TYPE_CLIENT); + + // Clients with invalid mac are invalid. + // Invalid clients are removed from persistent db and not added to runtime db + auto client_mac = client_db_entry_to_mac(client_entry); + if (client_mac == network_utils::ZERO_MAC) { + LOG(ERROR) << "Invalid entry - not a valid mac as client entry " << client_entry; + // Calling BPL API directly as there's no need to increment/decrement counter at this point + if (!beerocks::bpl::db_remove_entry(type_client_str, client_entry)) { + // Failure to remove the client will not fail the adding rest of valid client + LOG(ERROR) << "Failed to remove client entry " << client_entry; + } + continue; + } + + // Clients without timestamp are invalid. + // Invalid clients are removed from persistent db and not added to runtime db + auto timestamp_it = client_data_map.find(TIMESTAMP_STR); + if (timestamp_it == client_data_map.end()) { + LOG(ERROR) << "Invalid entry - no timestamp is configured for client entry " + << client_entry; + // Calling BPL API directly as there's no need to increment/decrement counter at this point + if (!beerocks::bpl::db_remove_entry(type_client_str, client_entry)) { + // Failure to remove the client will not fail the adding rest of valid client + LOG(ERROR) << "Failed to remove client entry " << client_entry; + } + continue; + } + + // Aged clients are removed from persistent db and not added to runtime db + auto timestamp_sec = beerocks::string_utils::stoi(timestamp_it->second); + auto timestamp = db::timestamp_from_seconds(timestamp_sec); + auto client_timelife_passed_sec = std::chrono::duration_cast( + std::chrono::steady_clock::now() - timestamp) + .count(); + + /* TODO: aging validation against specific client configuration and unfriendly-device-max-timelife-delay: + * 1. If client has timelife_delay_str param configured, it should be checked against it instead of global max-timelife-delay param. + * 2.a. If client is unfriendly - and timelife_delay_str is not configured - check against the global unfriendly-device-max-timelife-delay param. + * 2.b. Is "unfriendly" something we know at boot? + */ + static const int max_timelife_delay_sec = config.max_timelife_delay_days * 24 * 3600; + if (client_timelife_passed_sec > max_timelife_delay_sec) { + LOG(ERROR) << "Invalid entry - configured data has aged for client entry " + << client_entry; + // Calling BPL API directly as there's no need to increment/decrement counter at this point + if (!beerocks::bpl::db_remove_entry(type_client_str, client_entry)) { + // Failure to remove the client will not fail the adding rest of valid client + LOG(ERROR) << "Failed to remove client entry " << client_entry; + } + continue; + } + + // Add client node + if (!add_new_client_with_persistent_data_to_nodes_list(client_mac, client_data_map)) { + LOG(ERROR) << "Failed to add client node with persistent data for client " << client_mac + << ", client-params=" << client_data_map; + } } - return clients; + // Print counters + LOG_IF(add_node_error_count, ERROR) + << "Failed to add nodes for " << add_node_error_count << " clients"; + LOG_IF(set_node_error_count, ERROR) << "Failed to set nodes with values from persistent db for " + << set_node_error_count << " clients"; + LOG(DEBUG) << "Added " << clients_added_no_error << " clients successfully"; + + // Set clients count to number of clients added successfully to runtime db + m_persistent_db_clients_count = clients_added_no_error; + + return true; } // diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index 5f908cc53e..9166d6dfab 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -187,6 +187,7 @@ class db { * * @param mac MAC address of a client. * @return std::string the string representation of the MAC address with ':' replaced with '_' removed. + * @return An empty string is returned on failure. */ static std::string client_db_entry_from_mac(const sMacAddr &mac); @@ -194,7 +195,7 @@ class db { * @brief Get client MAC address from db entry. * * @param db_entry Client entry name in persistent db. - * @return sMacAddr MAC address of the client the db_entry is representing. + * @return sMacAddr MAC address of the client the db_entry is representing. On failure ZERO_MAC is returned. */ static sMacAddr client_db_entry_to_mac(const std::string &db_entry); @@ -791,12 +792,12 @@ class db { /** * @brief Load all clients from persistent db. + * Creates nodes for the clients in runtime-db and set persistent parameters values accordingly. + * Aged Clients and Clients with invalid data are filtered-out and removed from persistent-DB. * - * @return An unordered map of clients, for each client unordered map of params as key-value. - * @return An empty map of clients is returned if the persistent db is empty. + * @return true on success, otherwise false. */ - std::unordered_map> - load_persistent_db_clients(); + bool load_persistent_db_clients(); // // CLI From 7a37d3baca0bd9d6f34ef0d0f94d21ee30936e33 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Mon, 13 Jul 2020 08:53:28 +0000 Subject: [PATCH 279/453] controller: son_master: load clients from persistent db PPM-5. Added a call to the load_persistent_db_clients() API, if the persistent DB is enabled. The call is performed at the beginning of the master_thread::init() to make sure the clients persistent information is loaded before any task is started. Signed-off-by: Adam Dov --- controller/src/beerocks/master/son_master_thread.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/controller/src/beerocks/master/son_master_thread.cpp b/controller/src/beerocks/master/son_master_thread.cpp index 1d91b21f2a..b3d11241e0 100644 --- a/controller/src/beerocks/master/son_master_thread.cpp +++ b/controller/src/beerocks/master/son_master_thread.cpp @@ -88,6 +88,16 @@ bool master_thread::init() set_server_max_connections(SOCKET_MAX_CONNECTIONS); set_select_timeout(SOCKETS_SELECT_TIMEOUT_MSEC); + LOG(DEBUG) << "persistent db enable=" << database.config.persistent_db; + if (database.config.persistent_db) { + LOG(DEBUG) << "loading clients from persistent db"; + if (!database.load_persistent_db_clients()) { + LOG(WARNING) << "failed to load clients from persistent db"; + } else { + LOG(DEBUG) << "load clients from persistent db finished successfully"; + } + } + if (!transport_socket_thread::init()) { LOG(ERROR) << "Failed init of transport_socket_thread"; stop(); From 2fc4443aff54910509501015fcf9cd26faf4bb72 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 1 Jul 2020 09:05:57 +0000 Subject: [PATCH 280/453] agent: Add parameters needed by the Topology flow to AgentDB On future PR all Topology related code will be moved to the Topology Task, so it would be easy to switch the code to the Unified Agent thread. To do that, moved all Agent parameters/configurations needed by the Topology flows to the AgentDB. This includes some of the basic Agent information such as Agent Radios, bridge, ethernet and etc, information. On the follow-up commits, the Agent code (on son_slave/backhaul/platform) will switch to use the parameters from the AgentDB instead of its local copy. PPM-216 Signed-off-by: Moran Shoeg --- agent/src/beerocks/slave/agent_db.cpp | 99 +++++++++++++++ agent/src/beerocks/slave/agent_db.h | 170 +++++++++++++++++++++++++- 2 files changed, 266 insertions(+), 3 deletions(-) create mode 100644 agent/src/beerocks/slave/agent_db.cpp diff --git a/agent/src/beerocks/slave/agent_db.cpp b/agent/src/beerocks/slave/agent_db.cpp new file mode 100644 index 0000000000..c675f44562 --- /dev/null +++ b/agent/src/beerocks/slave/agent_db.cpp @@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2019-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include "agent_db.h" + +#include + +namespace beerocks { + +AgentDB::sRadio *AgentDB::radio(const std::string &iface_name) +{ + if (iface_name.empty()) { + LOG(ERROR) << "Given radio iface name is empty"; + return nullptr; + } + + auto radio_it = std::find_if(m_radios.begin(), m_radios.end(), [&](const sRadio &radio_entry) { + return iface_name == radio_entry.front.iface_name || + iface_name == radio_entry.back.iface_name; + }); + + return radio_it == m_radios.end() ? nullptr : &(*radio_it); +} + +bool AgentDB::add_radio(const std::string &front_iface_name, const std::string &back_iface_name) +{ + if (front_iface_name.empty() && back_iface_name.empty()) { + LOG(ERROR) << "Both front and back interface names are empty!"; + return false; + } + + if (!front_iface_name.empty() && radio(front_iface_name)) { + LOG(DEBUG) << "Radio entry of front iface " << front_iface_name + << " already exists. Ignore."; + return true; + } + + if (!back_iface_name.empty() && radio(back_iface_name)) { + LOG(DEBUG) << "Radio entry of back iface " << back_iface_name << " already exists. Ignore."; + return true; + } + + m_radios.emplace_back(front_iface_name, back_iface_name); + m_radios_list.push_back(&m_radios.back()); + + return true; +} + +AgentDB::sRadio *AgentDB::get_radio_by_mac(const sMacAddr &mac, eMacType mac_type_hint) +{ + bool all_mac_types = mac_type_hint == eMacType::ALL; + auto radio_it = std::find_if(m_radios.begin(), m_radios.end(), [&](const sRadio &radio_entry) { + if (all_mac_types || mac_type_hint == eMacType::RADIO) { + if (radio_entry.front.iface_mac == mac || radio_entry.back.iface_mac == mac) { + return true; + } + } + if (all_mac_types || mac_type_hint == eMacType::BSSID) { + auto &bssid_list = radio_entry.front.bssids; + auto bssid_it = + std::find_if(bssid_list.begin(), bssid_list.end(), + [&](const sRadio::sFront::sBssid &bssid) { return bssid.mac == mac; }); + if (bssid_it != bssid_list.end()) { + return true; + } + } + if (all_mac_types || mac_type_hint == eMacType::CLIENT) { + auto client_it = radio_entry.associated_clients.find(mac); + return client_it != radio_entry.associated_clients.end(); + } + // MAC is not one of the front\back radio MACs nor bssid MAC. + return false; + }); + + return radio_it == m_radios.end() ? nullptr : &(*radio_it); +} + +void AgentDB::erase_client(const sMacAddr &client_mac, sMacAddr bssid) +{ + if (bssid != net::network_utils::ZERO_MAC) { + auto radio = get_radio_by_mac(bssid, eMacType::BSSID); + if (!radio) { + return; + } + radio->associated_clients.erase(client_mac); + return; + } + + for (auto &radio : m_radios) { + radio.associated_clients.erase(client_mac); + } +} + +} // namespace beerocks diff --git a/agent/src/beerocks/slave/agent_db.h b/agent/src/beerocks/slave/agent_db.h index 9da322f5aa..b9a89d3baf 100644 --- a/agent/src/beerocks/slave/agent_db.h +++ b/agent/src/beerocks/slave/agent_db.h @@ -5,6 +5,9 @@ * This code is subject to the terms of the BSD+Patent license. * See LICENSE file for more details. */ +#include +#include +#include #include #include @@ -41,14 +44,14 @@ namespace beerocks { * std::string &get_foo() { // Unsafe! Don't do it! Returning refernce to the database * auto db = AgentDB::get(); // on a wrapper function is unsafe because the database will * return db->foo; // be unlocked when the function ends, and the caller will - * } // hold a refernce to it. // hold a refernce to it. + * } // hold a refernce to it. * @endcode */ class AgentDB { public: class SafeDB { public: - SafeDB(AgentDB &db) : m_db(db) { m_db.db_lock(); } + explicit SafeDB(AgentDB &db) : m_db(db) { m_db.db_lock(); } ~SafeDB() { m_db.db_unlock(); } AgentDB *operator->() { return &m_db; } @@ -72,8 +75,169 @@ class AgentDB { void db_lock() { m_db_mutex.lock(); } void db_unlock() { m_db_mutex.unlock(); } + /* Put down from here database members and functions used by the Agent modules */ + public: - /* Put here database members used by the Agent modules */ + /* Agent Configuration */ + struct sDeviceConf { + struct sFrontRadio { + + } front_radio; + + struct sBackRadio { + + } back_radio; + + bool local_gw; + bool local_controller; + } device_conf; + + /** + * Agent Sub Entities Data + */ + struct sBridge { + sMacAddr mac; + std::string iface_name; + } bridge; + + struct sBackhaul { + enum class eConnectionType { Invalid = 0, Wired, Wireless } connection_type; + std::string selected_iface_name; + } backhaul; + + struct sEthernet { + sMacAddr mac; + std::string iface_name; + } ethernet; + + struct sRadio { + sRadio(const std::string &front_iface_name, const std::string &back_iface_name) + : front(front_iface_name), back(back_iface_name) + { + } + + struct sFront { + explicit sFront(const std::string &iface_name_) + : iface_name(iface_name_), max_supported_bw(eWiFiBandwidth::BANDWIDTH_UNKNOWN), + freq_type(eFreqType::FREQ_UNKNOWN) + { + } + std::string iface_name; + sMacAddr iface_mac; + eWiFiBandwidth max_supported_bw; + eFreqType freq_type; + + struct sBssid { + sMacAddr mac; + std::string ssid; + enum class eType { fAP, bAP } type; + }; + std::array bssids; + } front; + + struct sBack { + explicit sBack(const std::string &iface_name_) : iface_name(iface_name_) {} + std::string iface_name; + sMacAddr iface_mac; + } back; + + struct sClient { + sClient(sMacAddr bssid_, size_t association_frame_length_, uint8_t *association_frame_) + : bssid(bssid_), association_time(std::chrono::steady_clock::now()), + association_frame_length(association_frame_length_) + { + std::copy_n(association_frame_, association_frame_length_, + association_frame.begin()); + } + sMacAddr bssid; + std::chrono::steady_clock::time_point association_time; + size_t association_frame_length; + std::array association_frame; + }; + // Associated clients grouped by Client MAC. + std::unordered_map associated_clients; + }; + + /** + * @brief Get pointer to the radio data struct of a specific interface. The function can + * accepts either front or back interface name. + * + * @param iface_name Interface name of a radio, front or back. + * @return std::unique_ptr to the radio struct if exist, otherwise, nullptr. + */ + sRadio *radio(const std::string &iface_name); + + /** + * @brief Add radio node to the database. At least one of the input arguments must not be empty. + * This function should be called only once with valid arguments. If called once and then called + * again, the radio struct on the database will not be updated with new arguments, and the + * function will return false. + * + * @param front_iface_name Front interface name. + * @param back_iface_name Back interface name. + * @return true if a radio struct has been added to the database, otherwise return false. + */ + bool add_radio(const std::string &front_iface_name, const std::string &back_iface_name); + + /** + * @brief Get list of all radio objects on the database. + * This function shall be used in order to iterate over all the radios. + * + * @return const std::vector& Intefaces names list. + */ + const std::vector &get_radios_list() { return m_radios_list; }; + + /* Helper enum for get_radio_by_mac() function */ + enum class eMacType : uint8_t { ALL, RADIO, BSSID, CLIENT }; + + /** + * @brief Get a pointer to the parent radio struct of given MAC address. + * + * @param mac MAC address of radio interface or bssid. + * @param mac_type_hint Hint for the MAC type, for faster lookup. + * @return sRadio* A pointer to the radio struct containing the given MAC address. + */ + sRadio *get_radio_by_mac(const sMacAddr &mac, eMacType mac_type_hint = eMacType::ALL); + + /** + * @brief Erase client from associated_clients list. + * If @a bssid is given, then remove client only from its radio, otherwise remove from all + * radios. + * + * @param client_mac The client MAC address. + * @param bssid The bssid that the client will be removed from its radio. + */ + void erase_client(const sMacAddr &client_mac, sMacAddr bssid = net::network_utils::ZERO_MAC); + + /** + * @brief 1905.1 Neighbor device information + * Information gathered from a neighbor device upon reception of a Topology Discovery message. + */ + struct sNeighborDevice { + // MAC address of the interface on which the Topology Discovery message is transmitted. + sMacAddr transmitting_iface_mac; + + // Timestamp of the last Topology Discovery message received from this neighbor device. + std::chrono::steady_clock::time_point timestamp; + }; + + /* + * @brief List of known 1905 neighbor devices. + * + * Upper key: Local interface MAC on which the Topology Discovery message was received from. + * Upper value: Map containing 1905.1 device information ordered by neighbor device al_mac - + * Sub-key: 1905.1 AL MAC address of the Topology Discovery message transmitting device. + * Sub-value: 1905.1 device information. + * + * Devices are being added to the list when receiving a 1905.1 Topology Discovery message from + * an unknown 1905.1 device. Every 1905.1 device shall send this message every 60 seconds, and + * we update the time stamp in which the message is received. + */ + std::unordered_map> neighbor_devices; + +private: + std::list m_radios; + std::vector m_radios_list; }; } // namespace beerocks From 43966cb6fcc4619e9d999b8064d3bc9e66e9ce75 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 1 Jul 2020 12:46:20 +0000 Subject: [PATCH 281/453] agent: Use local_gw and local_controller from AgentDB Replace the use of local_master and local_gw on the Agent thread to the one on the AgentDB. Remove sending of these flags on messages. Remove it from debug print before sending/after receiving messages. Remove local copy from Agent threads. Removing of the flags from the tlvf will take place on the cleanup phase. On the way, rename "local_master" to "local_controller". PPM-216 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 46 +++++++++++++------ .../backhaul_manager_thread.h | 4 +- .../platform_manager_thread.cpp | 28 ++++++----- agent/src/beerocks/slave/son_slave_thread.cpp | 36 +++++++++------ 4 files changed, 72 insertions(+), 42 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 0c1817e4fc..75394dac12 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -29,6 +29,7 @@ */ #include "backhaul_manager_thread.h" +#include "../agent_db.h" #include "../link_metrics/ieee802_11_link_metrics_collector.h" #include "../link_metrics/ieee802_3_link_metrics_collector.h" @@ -562,6 +563,8 @@ bool backhaul_manager::finalize_slaves_connect_state(bool fConnected, return false; } + auto db = AgentDB::get(); + std::string strIface; network_utils::iface_info iface_info; bool backhaul_manager_exist = false; @@ -569,7 +572,7 @@ bool backhaul_manager::finalize_slaves_connect_state(bool fConnected, notification->params().is_prplmesh_controller = is_prplmesh_controller; notification->params().controller_bridge_mac = tlvf::mac_from_string(controller_bridge_mac); - if (!local_gw) { + if (!db->device_conf.local_gw) { if (m_sConfig.eType == SBackhaulConfig::EType::Wired) { strIface = m_sConfig.wire_iface; @@ -710,7 +713,7 @@ bool backhaul_manager::finalize_slaves_connect_state(bool fConnected, // note: On wired connections ore GW, the first connected slave is selected as the backhaul manager notification->params().is_backhaul_manager = sc->slave_is_backhaul_manager; - if (local_gw) { + if (db->device_conf.local_gw) { LOG(DEBUG) << "Sending GW_MASTER CONNECTED notification to slave of '" << sc->hostap_iface << "'"; } else { @@ -791,7 +794,8 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) } // Wait for Enable command case EState::WAIT_ENABLE: { - if (!onboarding && !local_gw && + auto db = AgentDB::get(); + if (!onboarding && !db->device_conf.local_gw && std::chrono::steady_clock::now() > state_time_stamp_timeout) { LOG(ERROR) << STATE_WAIT_ENABLE_TIMEOUT_SECONDS << " seconds has passed on state WAIT_ENABLE, stopping thread!"; @@ -829,9 +833,11 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) << intptr_t(m_scPlatform.get()); } + auto db = AgentDB::get(); + // Ignore 'selected_backhaul' since this case is not covered by certification flows - if (local_master && local_gw) { - LOG(DEBUG) << "local master && local gw"; + if (db->device_conf.local_controller && db->device_conf.local_gw) { + LOG(DEBUG) << "local controller && local gw"; FSM_MOVE_STATE(MASTER_DISCOVERY); } else { // link establish @@ -895,6 +901,8 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) break; } case EState::MASTER_DISCOVERY: { + + auto db = AgentDB ::get(); if (network_utils::get_iface_info(bridge_info, m_sConfig.bridge_iface) != 0) { LOG(ERROR) << "Failed reading addresses from the bridge!"; platform_notify_error(bpl::eErrorCode::BH_READING_DATA_FROM_THE_BRIDGE, ""); @@ -910,7 +918,7 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) break; } - if (!broker_connect(beerocks_temp_path, local_master)) { + if (!broker_connect(beerocks_temp_path, db->device_conf.local_controller)) { platform_notify_error(bpl::eErrorCode::BH_CONNECTING_TO_MASTER, ""); FSM_MOVE_STATE(RESTART); break; @@ -1817,18 +1825,18 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr return false; } + auto db = AgentDB::get(); + soc->sta_iface.assign(request->sta_iface(message::IFACE_NAME_LENGTH)); soc->hostap_iface.assign(request->hostap_iface(message::IFACE_NAME_LENGTH)); soc->sta_iface_filter_low = request->sta_iface_filter_low(); - local_master = request->local_master(); - local_gw = request->local_gw(); onboarding = request->onboarding(); // Add the slave socket to the backhaul configuration m_sConfig.slave_iface_socket[soc->sta_iface] = soc; if (!m_agent_ucc_listener && request->certification_mode() && - m_sConfig.ucc_listener_port != 0 && !bpl::cfg_is_master()) { + m_sConfig.ucc_listener_port != 0 && !db->device_conf.local_controller) { m_agent_ucc_listener = std::make_unique( *this, m_sConfig.ucc_listener_port, m_sConfig.vendor, m_sConfig.model, m_sConfig.bridge_iface, cert_cmdu_tx); @@ -1839,7 +1847,6 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr } LOG(DEBUG) << "ACTION_BACKHAUL_REGISTER_REQUEST sta_iface=" << soc->sta_iface - << " local_master=" << int(local_master) << " local_gw=" << int(local_gw) << " hostap_iface=" << soc->hostap_iface; auto register_response = @@ -1922,7 +1929,9 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr */ pending_enable = true; - if (local_gw) { + auto db = AgentDB::get(); + + if (db->device_conf.local_gw) { LOG(DEBUG) << "All slaves ready, proceeding, local GW, Bridge: " << m_sConfig.bridge_iface; } else { @@ -2807,6 +2816,8 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd return false; } + auto db = AgentDB::get(); + auto tlvDeviceInformation = cmdu_tx.addClass(); if (!tlvDeviceInformation) { LOG(ERROR) << "addClass ieee1905_1::tlvDeviceInformation failed, mid=" << std::hex @@ -2883,7 +2894,8 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd // BSSID field is not defined well for interface. The common definition is in simple // words "the AP/ETH mac that we are connected to". // For fronthaul radio interface or unused backhaul interface put zero mac. - if (local_gw || m_sConfig.eType == SBackhaulConfig::EType::Wired || front_iface || + if (db->device_conf.local_gw || m_sConfig.eType == SBackhaulConfig::EType::Wired || + front_iface || (m_sConfig.eType == SBackhaulConfig::EType::Wireless && soc->sta_iface != m_sConfig.wireless_iface)) { media_info.network_membership = network_utils::ZERO_MAC; @@ -3005,7 +3017,7 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd } size_t number_of_supported_services = 1; - if (local_master) { + if (db->device_conf.local_controller) { number_of_supported_services++; } @@ -3023,7 +3035,7 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd std::get<1>(supportedServiceTuple) = wfa_map::tlvSupportedService::eSupportedService::MULTI_AP_AGENT; - if (local_master) { + if (db->device_conf.local_controller) { auto supportedServiceTuple = tlvSupportedService->supported_service_list(1); if (!std::get<0>(supportedServiceTuple)) { LOG(ERROR) << "Failed accessing supported_service_list(1)"; @@ -3651,6 +3663,8 @@ bool backhaul_manager::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t eve LOG(DEBUG) << "successfully connected to bssid=" << (iface_hal->get_bssid()) << " on channel=" << (iface_hal->get_channel()) << " on iface=" << iface; + auto db = AgentDB::get(); + if (iface == m_sConfig.wireless_iface && !hidden_ssid) { //this is generally not supposed to happen LOG(WARNING) << "event iface != wireless iface!"; @@ -3711,7 +3725,9 @@ bool backhaul_manager::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t eve FSM_MOVE_STATE(MASTER_DISCOVERY); } else if (FSM_IS_IN_STATE(WIRELESS_WAIT_FOR_RECONNECT)) { LOG(DEBUG) << "reconnected successfully, continuing"; - if (local_master && !local_gw) { // ire_master + + // IRE running controller + if (db->device_conf.local_controller && !db->device_conf.local_gw) { FSM_MOVE_STATE(CONNECT_TO_MASTER); } else { FSM_MOVE_STATE(OPERATIONAL); diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 6c2a130b8b..0c6738f88c 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -224,9 +224,7 @@ class backhaul_manager : public btl::transport_socket_thread { const std::string config_const_bh_slave; int stop_on_failure_attempts; - bool local_master = false; - bool local_gw = false; - bool onboarding = true; + bool onboarding = true; //backlist bssid and timers (remove con(or wrong passphrase) ap from select bssid for limited time ) struct ap_blacklist_entry { diff --git a/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp b/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp index 4257bf7235..e160d8f148 100644 --- a/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp +++ b/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp @@ -10,6 +10,8 @@ #include "platform_manager_thread.h" +#include "../agent_db.h" + #include #include @@ -62,6 +64,8 @@ static bool fill_platform_settings( &iface_wlan_params_map, Socket *sd) { + auto db = AgentDB::get(); + if (bpl::cfg_get_beerocks_credentials(BPL_RADIO_FRONT, msg->platform_settings().front_ssid, msg->platform_settings().front_pass, msg->platform_settings().front_security_type) < 0) { @@ -126,6 +130,8 @@ static bool fill_platform_settings( BPL_BACK_VAPS_GROUPS * BPL_BACK_VAPS_IN_GROUP * BPL_MAC_ADDR_OCTETS_LEN; char back_vaps[back_vaps_buff_len]; + int temp_int; + if ((platform_common_conf.onboarding = bpl::cfg_is_onboarding()) < 0) { LOG(ERROR) << "Failed reading 'onboarding'"; return false; @@ -142,10 +148,11 @@ static bool fill_platform_settings( LOG(ERROR) << "Failed reading 'client_roaming"; return false; } - if ((platform_common_conf.local_master = bpl::cfg_is_master()) < 0) { - LOG(ERROR) << "Failed reading 'local_master'"; + if ((temp_int = bpl::cfg_is_master()) < 0) { + LOG(ERROR) << "Failed reading 'local_controller'"; return false; } + db->device_conf.local_controller = temp_int; if ((platform_common_conf.management_mode = bpl::cfg_get_management_mode()) < 0) { LOG(ERROR) << "Failed reading 'management_mode'"; return false; @@ -180,10 +187,9 @@ static bool fill_platform_settings( return false; } - // set local_gw flag - platform_common_conf.local_gw = - (platform_common_conf.operating_mode == BPL_OPER_MODE_GATEWAY || - platform_common_conf.operating_mode == BPL_OPER_MODE_GATEWAY_WISP); + // Set local_gw flag + db->device_conf.local_gw = (platform_common_conf.operating_mode == BPL_OPER_MODE_GATEWAY || + platform_common_conf.operating_mode == BPL_OPER_MODE_GATEWAY_WISP); msg->platform_settings().onboarding = uint8_t(platform_common_conf.onboarding); msg->platform_settings().dfs_reentry_enabled = uint8_t(platform_common_conf.dfs_reentry); @@ -197,13 +203,13 @@ static bool fill_platform_settings( 0; // TODO add platform DB flag msg->platform_settings().client_11k_roaming_enabled = uint8_t(platform_common_conf.client_roaming || platform_common_conf.band_steering); - msg->platform_settings().local_gw = uint8_t(platform_common_conf.local_gw); + msg->platform_settings().local_gw = uint8_t(db->device_conf.local_gw); msg->platform_settings().operating_mode = uint8_t(platform_common_conf.operating_mode); msg->platform_settings().management_mode = uint8_t(platform_common_conf.management_mode); msg->platform_settings().certification_mode = uint8_t(platform_common_conf.certification_mode); msg->platform_settings().stop_on_failure_attempts = uint8_t(platform_common_conf.stop_on_failure_attempts); - msg->platform_settings().local_master = uint8_t(platform_common_conf.local_master); + msg->platform_settings().local_master = uint8_t(db->device_conf.local_controller); msg->platform_settings().backhaul_max_vaps = uint8_t(platform_common_conf.backhaul_max_vaps); msg->platform_settings().backhaul_network_enabled = uint8_t(platform_common_conf.backhaul_network_enabled); @@ -223,8 +229,8 @@ static bool fill_platform_settings( << (unsigned)msg->platform_settings() .client_optimal_path_roaming_prefer_signal_strength_enabled; LOG(DEBUG) << "band_enabled: " << (unsigned)msg->wlan_settings().band_enabled; - LOG(DEBUG) << "local_gw: " << (unsigned)msg->platform_settings().local_gw; - LOG(DEBUG) << "local_master: " << (unsigned)msg->platform_settings().local_master; + LOG(DEBUG) << "local_gw: " << db->device_conf.local_gw; + LOG(DEBUG) << "local_controller: " << db->device_conf.local_controller; LOG(DEBUG) << "dfs_reentry_enabled: " << (unsigned)msg->platform_settings().dfs_reentry_enabled; LOG(DEBUG) << "backhaul_preferred_radio_band: " << (unsigned)msg->platform_settings().backhaul_preferred_radio_band; @@ -832,7 +838,7 @@ bool main_thread::handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_rx) } // Start DHCP monitor - if (platform_common_conf.local_gw) { + if (AgentDB::get()->device_conf.local_gw) { if (!init_dhcp_monitor()) { LOG(ERROR) << "can't start DHCP monitor"; return false; diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 170c2ff657..1724f5e828 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -7,6 +7,8 @@ */ #include "son_slave_thread.h" +#include "agent_db.h" + #include "../fronthaul_manager/monitor/monitor_thread.h" #include "tlvf_utils.h" @@ -1461,13 +1463,16 @@ bool slave_thread::handle_cmdu_platform_manager_message( platform_settings = response->platform_settings(); wlan_settings = response->wlan_settings(); + auto db = AgentDB::get(); + + // Local copy on cuurent process database instance, to be removed on PPM-83 phase 5 + db->device_conf.local_gw = response->platform_settings().local_gw; + db->device_conf.local_controller = response->platform_settings().local_master; + configuration_stop_on_failure_attempts = response->platform_settings().stop_on_failure_attempts; stop_on_failure_attempts = configuration_stop_on_failure_attempts; - LOG(INFO) << "local_master=" << (int)platform_settings.local_master; - LOG(INFO) << "local_gw=" << (int)platform_settings.local_gw; - LOG(TRACE) << "goto STATE_CONNECT_TO_BACKHAUL_MANAGER"; slave_state = STATE_CONNECT_TO_BACKHAUL_MANAGER; } else { @@ -3191,7 +3196,9 @@ bool slave_thread::slave_fsm(bool &call_slave_select) break; } - if (platform_settings.local_gw || config.backhaul_wireless_iface.empty()) { + auto db = AgentDB::get(); + + if (db->device_conf.local_gw || config.backhaul_wireless_iface.empty()) { memset(request->sta_iface(message::IFACE_NAME_LENGTH), 0, message::IFACE_NAME_LENGTH); } else { string_utils::copy_string(request->sta_iface(message::IFACE_NAME_LENGTH), @@ -3201,15 +3208,11 @@ bool slave_thread::slave_fsm(bool &call_slave_select) string_utils::copy_string(request->hostap_iface(message::IFACE_NAME_LENGTH), config.hostap_iface.c_str(), message::IFACE_NAME_LENGTH); - request->local_master() = platform_settings.local_master; - request->local_gw() = platform_settings.local_gw; request->sta_iface_filter_low() = config.backhaul_wireless_iface_filter_low; request->onboarding() = platform_settings.onboarding; request->certification_mode() = platform_settings.certification_mode; - LOG(INFO) << "ACTION_BACKHAUL_REGISTER_REQUEST local_master=" - << int(platform_settings.local_master) - << " local_gw=" << int(platform_settings.local_gw) + LOG(INFO) << "ACTION_BACKHAUL_REGISTER_REQUEST " << " hostap_iface=" << request->hostap_iface(message::IFACE_NAME_LENGTH) << " sta_iface=" << request->sta_iface(message::IFACE_NAME_LENGTH) << " onboarding=" << int(request->onboarding()); @@ -3234,6 +3237,7 @@ bool slave_thread::slave_fsm(bool &call_slave_select) } case STATE_JOIN_INIT: { + auto db = AgentDB::get(); LOG(DEBUG) << "onboarding: " << int(platform_settings.onboarding); if (platform_settings.onboarding) { LOG(TRACE) << "goto STATE_ONBOARDING"; @@ -3246,7 +3250,7 @@ bool slave_thread::slave_fsm(bool &call_slave_select) break; } - if (!platform_settings.local_gw) { + if (!db->device_conf.local_gw) { is_backhaul_manager = false; } @@ -3310,7 +3314,9 @@ bool slave_thread::slave_fsm(bool &call_slave_select) break; } - if (!platform_settings.local_gw) { + auto db = AgentDB::get(); + + if (!db->device_conf.local_gw) { // Wireless config // TODO: On passive mode, mem_only_psk is always be set, so supplying the credentials @@ -3392,13 +3398,14 @@ bool slave_thread::slave_fsm(bool &call_slave_select) master_socket = backhaul_manager_socket; master_socket->setPeerMac(backhaul_params.controller_bridge_mac); + auto db = AgentDB::get(); if (!wlan_settings.band_enabled) { LOG(TRACE) << "goto STATE_OPERATIONAL"; slave_state = STATE_OPERATIONAL; break; } - if (platform_settings.local_gw) { + if (db->device_conf.local_gw) { //TODO get bridge_iface from platform manager network_utils::iface_info bridge_info; network_utils::get_iface_info(bridge_info, config.bridge_iface); @@ -3487,6 +3494,8 @@ bool slave_thread::slave_fsm(bool &call_slave_select) return false; } + auto db = AgentDB::get(); + std::array supported_channels_arr{{}}; std::copy_n(supported_channels.begin(), supported_channels.size(), @@ -3575,7 +3584,8 @@ bool slave_thread::slave_fsm(bool &call_slave_select) } //Platform Settings - notification->platform_settings() = platform_settings; + notification->platform_settings() = platform_settings; + notification->platform_settings().local_master = db->device_conf.local_controller; //Wlan Settings notification->wlan_settings() = wlan_settings; From 1d05ad7068dca2490cdadfe901bf31507fd11dbb Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Thu, 2 Jul 2020 09:56:38 +0000 Subject: [PATCH 282/453] agent: Use bridge iface_name and mac from AgentDB Replace the use of bridge iface_name and mac on the Agent threads to the one from the AgentDB. Remove duplicate on backhaul_params on son_slave. Remove duplicate on m_sConfig on the backhaul manager. Removing of the flags from the tlvf will take place on the cleanup phase. PPM-216 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 134 ++++++++++++------ .../backhaul_manager_thread.h | 1 - agent/src/beerocks/slave/son_slave_thread.cpp | 50 ++++--- agent/src/beerocks/slave/son_slave_thread.h | 2 - 4 files changed, 122 insertions(+), 65 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 75394dac12..2400d5a51b 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -242,10 +242,13 @@ backhaul_manager::backhaul_manager(const config_file::sConfigSlave &config, stop_on_failure_attempts = stop_on_failure_attempts_; LOG(DEBUG) << "stop_on_failure_attempts=" << stop_on_failure_attempts; m_sConfig.ucc_listener_port = string_utils::stoi(config.ucc_listener_port); - m_sConfig.bridge_iface = config.bridge_iface; m_sConfig.vendor = config.vendor; m_sConfig.model = config.model; + // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 + auto db = AgentDB::get(); + db->bridge.iface_name = config.bridge_iface; + m_eFSMState = EState::INIT; set_select_timeout(SELECT_TIMEOUT_MSC); } @@ -425,9 +428,9 @@ bool backhaul_manager::socket_disconnected(Socket *sd) LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; return false; } - + auto db = AgentDB::get(); send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, - bridge_info.mac); + tlvf::mac_to_string(db->bridge.mac)); } return false; } else { @@ -501,6 +504,8 @@ void backhaul_manager::after_select(bool timeout) } } + auto db = AgentDB::get(); + // Send topology discovery every 60 seconds according to IEEE_Std_1905.1-2013 specification static std::chrono::steady_clock::time_point discovery_timestamp = std::chrono::steady_clock::now(); @@ -539,7 +544,8 @@ void backhaul_manager::after_select(bool timeout) LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; return; } - send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, + tlvf::mac_to_string(db->bridge.mac)); } // Run Tasks @@ -587,7 +593,7 @@ bool backhaul_manager::finalize_slaves_connect_state(bool fConnected, notification->params().gw_ipv4 = network_utils::ipv4_from_string(bridge_info.ip_gw); notification->params().gw_bridge_mac = tlvf::mac_from_string(bssid_bridge_mac); - notification->params().bridge_mac = tlvf::mac_from_string(bridge_info.mac); + notification->params().bridge_mac = db->bridge.mac; notification->params().bridge_ipv4 = network_utils::ipv4_from_string(bridge_info.ip); notification->params().backhaul_mac = tlvf::mac_from_string(iface_info.mac); notification->params().backhaul_ipv4 = network_utils::ipv4_from_string(iface_info.ip); @@ -841,7 +847,7 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) FSM_MOVE_STATE(MASTER_DISCOVERY); } else { // link establish - auto ifaces = network_utils::linux_get_iface_list_from_bridge(m_sConfig.bridge_iface); + auto ifaces = network_utils::linux_get_iface_list_from_bridge(db->bridge.iface_name); // If a wired (WAN) interface was provided, try it first, check if the interface is UP wan_monitor::ELinkState wired_link_state = wan_monitor::ELinkState::eInvalid; @@ -903,7 +909,7 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) case EState::MASTER_DISCOVERY: { auto db = AgentDB ::get(); - if (network_utils::get_iface_info(bridge_info, m_sConfig.bridge_iface) != 0) { + if (network_utils::get_iface_info(bridge_info, db->bridge.iface_name) != 0) { LOG(ERROR) << "Failed reading addresses from the bridge!"; platform_notify_error(bpl::eErrorCode::BH_READING_DATA_FROM_THE_BRIDGE, ""); stop_on_failure_attempts--; @@ -911,8 +917,11 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) break; } - auto ifaces = network_utils::linux_get_iface_list_from_bridge(m_sConfig.bridge_iface); - if (!configure_ieee1905_transport_interfaces(m_sConfig.bridge_iface, ifaces)) { + // Update bridge parameters on AgentDB. + db->bridge.mac = tlvf::mac_from_string(bridge_info.mac); + + auto ifaces = network_utils::linux_get_iface_list_from_bridge(db->bridge.iface_name); + if (!configure_ieee1905_transport_interfaces(db->bridge.iface_name, ifaces)) { LOG(ERROR) << "configure_ieee1905_transport_interfaces() failed!"; FSM_MOVE_STATE(RESTART); break; @@ -1148,7 +1157,8 @@ bool backhaul_manager::send_1905_topology_discovery_message() * the address of the interface on which the message is sent. Thus, a different message should * be sent on each interface. */ - auto ifaces = network_utils::linux_get_iface_list_from_bridge(m_sConfig.bridge_iface); + auto db = AgentDB::get(); + auto ifaces = network_utils::linux_get_iface_list_from_bridge(db->bridge.iface_name); for (const auto &iface_name : ifaces) { if (!network_utils::linux_iface_is_up_and_running(iface_name)) { continue; @@ -1173,12 +1183,14 @@ bool backhaul_manager::send_1905_topology_discovery_message(const std::string &i return false; } + auto db = AgentDB::get(); + auto tlvAlMacAddress = cmdu_tx.addClass(); if (!tlvAlMacAddress) { LOG(ERROR) << "Failed to create tlvAlMacAddress tlv"; return false; } - tlvAlMacAddress->mac() = tlvf::mac_from_string(bridge_info.mac); + tlvAlMacAddress->mac() = db->bridge.mac; auto tlvMacAddress = cmdu_tx.addClass(); if (!tlvMacAddress) { @@ -1187,14 +1199,16 @@ bool backhaul_manager::send_1905_topology_discovery_message(const std::string &i } tlvMacAddress->mac() = iface_mac; - LOG(DEBUG) << "send_1905_topology_discovery_message, bridge_mac=" << bridge_info.mac + LOG(DEBUG) << "send_1905_topology_discovery_message, bridge_mac=" << db->bridge.mac << ", iface=" << iface_name; - return send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac, - iface_name); + return send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, + tlvf::mac_to_string(db->bridge.mac), iface_name); } bool backhaul_manager::send_autoconfig_search_message(std::shared_ptr soc) { + auto db = AgentDB::get(); + ieee1905_1::tlvAutoconfigFreqBand::eValue freq_band = ieee1905_1::tlvAutoconfigFreqBand::IEEE_802_11_2_4_GHZ; /* @@ -1218,7 +1232,7 @@ bool backhaul_manager::send_autoconfig_search_message(std::shared_ptrmac().oct, bridge_info.mac); + tlvAlMacAddress->mac() = db->bridge.mac; auto tlvSearchedRole = cmdu_tx.addClass(); if (!tlvSearchedRole) { @@ -1279,8 +1293,9 @@ bool backhaul_manager::send_autoconfig_search_message(std::shared_ptractionhdr()->direction() = beerocks::BEEROCKS_DIRECTION_CONTROLLER; - LOG(DEBUG) << "sending autoconfig search message, bridge_mac=" << bridge_info.mac; - return send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac); + LOG(DEBUG) << "sending autoconfig search message, bridge_mac=" << db->bridge.mac; + return send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, + tlvf::mac_to_string(db->bridge.mac)); } bool backhaul_manager::send_slave_ap_metric_query_message(uint16_t mid, @@ -1423,7 +1438,8 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) } // Wait for WPS command case EState::WAIT_WPS: { - if (!onboarding && !local_gw && + auto db = AgentDB::get(); + if (!onboarding && !db->device_conf.local_gw && std::chrono::steady_clock::now() > state_time_stamp_timeout) { LOG(ERROR) << STATE_WAIT_WPS_TIMEOUT_SECONDS << " seconds has passed on state WAIT_WPS, stopping thread!"; @@ -1708,12 +1724,15 @@ bool backhaul_manager::handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_r std::string src_mac = tlvf::mac_to_string(uds_header->src_bridge_mac); std::string dst_mac = tlvf::mac_to_string(uds_header->dst_bridge_mac); + auto db = AgentDB::get(); + if (from_broker(sd)) { // Filter messages which are not destined to this agent - if (dst_mac != network_utils::MULTICAST_1905_MAC_ADDR && dst_mac != bridge_info.mac) { + if (dst_mac != network_utils::MULTICAST_1905_MAC_ADDR && + dst_mac != tlvf::mac_to_string(db->bridge.mac)) { LOG(DEBUG) << "handle_cmdu() - dropping msg, dst_mac=" << dst_mac - << ", local_bridge_mac=" << bridge_info.mac; + << ", local_bridge_mac=" << db->bridge.mac; return true; } @@ -1786,7 +1805,7 @@ bool backhaul_manager::handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_r } else { // Forward the data (cmdu) to bus // LOG(DEBUG) << "forwarding slave->master message, controller_bridge_mac=" << controller_bridge_mac; cmdu_rx.swap(); //swap back before forwarding - send_cmdu_to_broker(cmdu_rx, dst_mac, bridge_info.mac, length); + send_cmdu_to_broker(cmdu_rx, dst_mac, tlvf::mac_to_string(db->bridge.mac), length); } } @@ -1839,7 +1858,7 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr m_sConfig.ucc_listener_port != 0 && !db->device_conf.local_controller) { m_agent_ucc_listener = std::make_unique( *this, m_sConfig.ucc_listener_port, m_sConfig.vendor, m_sConfig.model, - m_sConfig.bridge_iface, cert_cmdu_tx); + db->bridge.iface_name, cert_cmdu_tx); if (m_agent_ucc_listener && !m_agent_ucc_listener->start("ucc_listener")) { LOG(ERROR) << "failed start agent_ucc_listener"; return false; @@ -1870,6 +1889,8 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr return false; } + auto db = AgentDB::get(); + auto tuple_preferred_channels = request->preferred_channels(0); if (!std::get<0>(tuple_preferred_channels)) { LOG(ERROR) << "access to supported channels list failed!"; @@ -1903,7 +1924,8 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; return false; } - send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, + tlvf::mac_to_string(db->bridge.mac)); } // If we're already connected, send a notification to the slave @@ -1929,11 +1951,9 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr */ pending_enable = true; - auto db = AgentDB::get(); - if (db->device_conf.local_gw) { LOG(DEBUG) << "All slaves ready, proceeding, local GW, Bridge: " - << m_sConfig.bridge_iface; + << db->bridge.iface_name; } else { m_sConfig.preferred_bssid = tlvf::mac_to_string(request->preferred_bssid()); @@ -1960,7 +1980,7 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr LOG(DEBUG) << "All slaves ready, proceeding" << std::endl << "SSID: " << m_sConfig.ssid << ", Pass: ****" << ", Security: " << int(m_sConfig.security_type) - << ", Bridge: " << m_sConfig.bridge_iface + << ", Bridge: " << db->bridge.iface_name << ", Wired: " << m_sConfig.wire_iface; } } @@ -2190,8 +2210,10 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr bss_in.uplink_estimated_mac_data_rate_mbps; bss_out.sta_measured_uplink_rssi_dbm_enc = bss_in.sta_measured_uplink_rssi_dbm_enc; } + + auto db = AgentDB::get(); LOG(DEBUG) << "Send AssociatedStaLinkMetrics to controller, mid = " << mid; - send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, tlvf::mac_to_string(db->bridge.mac)); break; } default: { @@ -2343,6 +2365,8 @@ bool backhaul_manager::handle_multi_ap_policy_config_request(ieee1905_1::CmduMes // For the time being, agent doesn't do steering so steering policy is ignored. } + auto db = AgentDB::get(); + auto metric_reporting_policy_tlv = cmdu_rx.getClass(); if (metric_reporting_policy_tlv) { /** @@ -2396,7 +2420,7 @@ bool backhaul_manager::handle_multi_ap_policy_config_request(ieee1905_1::CmduMes return false; } - return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); } bool backhaul_manager::handle_associated_sta_link_metrics_query(ieee1905_1::CmduMessageRx &cmdu_rx, @@ -2425,6 +2449,8 @@ bool backhaul_manager::handle_associated_sta_link_metrics_query(ieee1905_1::Cmdu return false; } + auto db = AgentDB::get(); + // Check if it is an error scenario - if the STA specified in the STA link Query message is not associated // with any of the BSS operated by the Multi-AP Agent std::shared_ptr radio = get_sta_radio(mac->sta_mac()); @@ -2441,7 +2467,7 @@ bool backhaul_manager::handle_associated_sta_link_metrics_query(ieee1905_1::Cmdu error_code_tlv->sta_mac() = mac->sta_mac(); LOG(DEBUG) << "Send a ASSOCIATED_STA_LINK_METRICS_RESPONSE_MESSAGE back to controller"; - return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); } else { sMacAddr bssid = get_sta_bssid(radio->associated_clients_map, mac->sta_mac()); if (bssid == network_utils::ZERO_MAC) { @@ -2477,6 +2503,8 @@ bool backhaul_manager::handle_client_capability_query(ieee1905_1::CmduMessageRx return false; } + auto db = AgentDB::get(); + //Check if it is an error scenario - if the STA specified in the Client Capability Query message is not associated //with any of the BSS operated by the Multi-AP Agent [ though the TLV does contain a BSSID, the specification // says that we should answer if the client is associated with any BSS on this agent.] @@ -2540,7 +2568,7 @@ bool backhaul_manager::handle_client_capability_query(ieee1905_1::CmduMessageRx error_code_tlv->sta_mac() = client_info_tlv_r->client_mac(); } LOG(DEBUG) << "Send a CLIENT_CAPABILITY_REPORT_MESSAGE back to controller"; - return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); } bool backhaul_manager::handle_ap_capability_query(ieee1905_1::CmduMessageRx &cmdu_rx, @@ -2560,6 +2588,8 @@ bool backhaul_manager::handle_ap_capability_query(ieee1905_1::CmduMessageRx &cmd return false; } + auto db = AgentDB::get(); + // Capability bitmask is set to 0 because neither unassociated STA link metrics // reporting or agent-initiated RCPI-based steering are supported @@ -2586,7 +2616,7 @@ bool backhaul_manager::handle_ap_capability_query(ieee1905_1::CmduMessageRx &cmd } LOG(DEBUG) << "Sending AP_CAPABILITY_REPORT_MESSAGE , mid: " << std::hex << (int)mid; - return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); } bool backhaul_manager::handle_ap_metrics_query(ieee1905_1::CmduMessageRx &cmdu_rx, @@ -2624,6 +2654,8 @@ bool backhaul_manager::handle_slave_ap_metrics_response(ieee1905_1::CmduMessageR auto mid = cmdu_rx.getMessageId(); LOG(DEBUG) << "Received AP_METRICS_RESPONSE_MESSAGE, mid=" << std::hex << int(mid); + auto db = AgentDB::get(); + /** * If AP Metrics Response message does not correspond to a previously received and forwarded * AP Metrics Query message (which we know because message id is not set), then forward message @@ -2634,7 +2666,8 @@ bool backhaul_manager::handle_slave_ap_metrics_response(ieee1905_1::CmduMessageR if (0 == mid) { uint16_t length = message_com::get_uds_header(cmdu_rx)->length; cmdu_rx.swap(); //swap back before forwarding - return send_cmdu_to_broker(cmdu_rx, controller_bridge_mac, bridge_info.mac, length); + return send_cmdu_to_broker(cmdu_rx, controller_bridge_mac, + tlvf::mac_to_string(db->bridge.mac), length); } /** @@ -2795,7 +2828,7 @@ bool backhaul_manager::handle_slave_ap_metrics_response(ieee1905_1::CmduMessageR m_ap_metric_response.clear(); LOG(DEBUG) << "Sending AP_METRICS_RESPONSE_MESSAGE, mid=" << std::hex << int(mid); - return send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, tlvf::mac_to_string(db->bridge.mac)); } /** @@ -2828,7 +2861,7 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd /** * 1905.1 AL MAC address of the device. */ - tlvDeviceInformation->mac() = tlvf::mac_from_string(bridge_info.mac); + tlvDeviceInformation->mac() = db->bridge.mac; /** * Set the number of local interfaces and fill info of each of the local interfaces, according @@ -3144,7 +3177,7 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd } LOG(DEBUG) << "Sending topology response message, mid: " << std::hex << (int)mid; - return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); } bool backhaul_manager::handle_1905_higher_layer_data_message(ieee1905_1::CmduMessageRx &cmdu_rx, @@ -3171,7 +3204,8 @@ bool backhaul_manager::handle_1905_higher_layer_data_message(ieee1905_1::CmduMes return false; } LOG(DEBUG) << "sending ACK message to the originator, mid=" << std::hex << int(mid); - return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); + auto db = AgentDB::get(); + return send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); } bool backhaul_manager::handle_1905_link_metric_query(ieee1905_1::CmduMessageRx &cmdu_rx, @@ -3205,10 +3239,12 @@ bool backhaul_manager::handle_1905_link_metric_query(ieee1905_1::CmduMessageRx & } } + auto db = AgentDB::get(); + /** * 1905.1 AL MAC address of the device that transmits the response message. */ - sMacAddr reporter_al_mac = tlvf::mac_from_string(bridge_info.mac); + sMacAddr reporter_al_mac = db->bridge.mac; /** * 1905.1 AL MAC address of a neighbor of the receiving device. @@ -3328,7 +3364,7 @@ bool backhaul_manager::handle_1905_link_metric_query(ieee1905_1::CmduMessageRx & } LOG(DEBUG) << "Sending LINK_METRIC_RESPONSE_MESSAGE, mid: " << std::hex << (int)mid; - return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); } bool backhaul_manager::handle_1905_combined_infrastructure_metrics( @@ -3349,7 +3385,8 @@ bool backhaul_manager::handle_1905_combined_infrastructure_metrics( return false; } LOG(DEBUG) << "sending ACK message to the originator, mid=" << std::hex << int(mid); - return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); + auto db = AgentDB::get(); + return send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); } bool backhaul_manager::handle_1905_topology_discovery(const std::string &src_mac, @@ -3361,8 +3398,10 @@ bool backhaul_manager::handle_1905_topology_discovery(const std::string &src_mac return false; } + auto db = AgentDB::get(); + // Filter out the messages we have sent. - if (tlvAlMac->mac() == tlvf::mac_from_string(bridge_info.mac)) { + if (tlvAlMac->mac() == db->bridge.mac) { return true; } @@ -3405,7 +3444,8 @@ bool backhaul_manager::handle_1905_topology_discovery(const std::string &src_mac LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; return false; } - send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, + tlvf::mac_to_string(db->bridge.mac)); } return true; } @@ -3550,6 +3590,8 @@ bool backhaul_manager::handle_1905_beacon_metrics_query(ieee1905_1::CmduMessageR return false; } + auto db = AgentDB::get(); + if (!radio) { LOG(DEBUG) << "STA with MAC [" << requested_sta_mac << "] is not associated with any BSS operated by the agent"; @@ -3579,7 +3621,7 @@ bool backhaul_manager::handle_1905_beacon_metrics_query(ieee1905_1::CmduMessageR << int(mid) << " tlv error code: " << errorSS.str(); // send the error - return send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); } forward_to = radio->slave; @@ -3590,7 +3632,7 @@ bool backhaul_manager::handle_1905_beacon_metrics_query(ieee1905_1::CmduMessageR LOG(DEBUG) << "BEACON METRICS QUERY: sending ACK message to the originator mid: " << int(mid); // USED IN TESTS - send_cmdu_to_broker(cmdu_tx, src_mac, bridge_info.mac); + send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); // continue processing return false; @@ -4511,6 +4553,8 @@ bool backhaul_manager::handle_slave_channel_selection_response(ieee1905_1::CmduM return false; } + auto db = AgentDB::get(); + m_expected_channel_selection.responses.push_back( {channel_selection_response->radio_uid(), channel_selection_response->response_code()}); @@ -4553,7 +4597,7 @@ bool backhaul_manager::handle_slave_channel_selection_response(ieee1905_1::CmduM m_expected_channel_selection.responses.clear(); LOG(DEBUG) << "Sending CHANNEL_SELECTION_RESPONSE_MESSAGE, mid=" << std::hex << int(mid); - return send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, bridge_info.mac); + return send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, tlvf::mac_to_string(db->bridge.mac)); } bool backhaul_manager::handle_backhaul_steering_request(ieee1905_1::CmduMessageRx &cmdu_rx, diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 0c6738f88c..48a887bbd0 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -186,7 +186,6 @@ class backhaul_manager : public btl::transport_socket_thread { std::string ssid; std::string pass; - std::string bridge_iface; std::string wire_iface; std::string wireless_iface; std::string preferred_bssid; diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 1724f5e828..d98f30702e 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -103,6 +103,11 @@ slave_thread::slave_thread(sSlaveConfig conf, beerocks::logging &logger_) configuration_stop_on_failure_attempts = conf.stop_on_failure_attempts; stop_on_failure_attempts = configuration_stop_on_failure_attempts; + // Set configuration on Agent database. + auto db = AgentDB::get(); + + db->bridge.iface_name = conf.bridge_iface; + slave_state = STATE_INIT; set_select_timeout(SELECT_TIMEOUT_MSEC); } @@ -1214,13 +1219,17 @@ bool slave_thread::handle_cmdu_backhaul_manager_message( is_backhaul_manager = (bool)notification->params().is_backhaul_manager; LOG_IF(is_backhaul_manager, DEBUG) << "Selected as backhaul manager"; + auto db = AgentDB::get(); + + // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 + db->bridge.mac = notification->params().bridge_mac; + backhaul_params.gw_ipv4 = network_utils::ipv4_to_string(notification->params().gw_ipv4); backhaul_params.gw_bridge_mac = tlvf::mac_to_string(notification->params().gw_bridge_mac); backhaul_params.controller_bridge_mac = tlvf::mac_to_string(notification->params().controller_bridge_mac); backhaul_params.is_prplmesh_controller = notification->params().is_prplmesh_controller; - backhaul_params.bridge_mac = tlvf::mac_to_string(notification->params().bridge_mac); backhaul_params.bridge_ipv4 = network_utils::ipv4_to_string(notification->params().bridge_ipv4); backhaul_params.backhaul_mac = tlvf::mac_to_string(notification->params().backhaul_mac); @@ -2448,8 +2457,10 @@ bool slave_thread::handle_cmdu_monitor_message(Socket *sd, LOG(ERROR) << "Failed building message!"; return false; } + auto db = AgentDB::get(); + notification_out->operational() = agent_operational; - notification_out->bridge_mac() = tlvf::mac_from_string(backhaul_params.bridge_mac); + notification_out->bridge_mac() = db->bridge.mac; send_cmdu_to_controller(cmdu_tx); break; @@ -3408,15 +3419,15 @@ bool slave_thread::slave_fsm(bool &call_slave_select) if (db->device_conf.local_gw) { //TODO get bridge_iface from platform manager network_utils::iface_info bridge_info; - network_utils::get_iface_info(bridge_info, config.bridge_iface); - backhaul_params.bridge_iface = config.bridge_iface; - // + network_utils::get_iface_info(bridge_info, db->bridge.iface_name); + + // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 + db->bridge.mac = tlvf::mac_from_string(bridge_info.mac); backhaul_params.gw_ipv4 = bridge_info.ip; backhaul_params.gw_bridge_mac = bridge_info.mac; - backhaul_params.bridge_mac = bridge_info.mac; backhaul_params.bridge_ipv4 = bridge_info.ip; - backhaul_params.backhaul_iface = backhaul_params.bridge_iface; + backhaul_params.backhaul_iface = db->bridge.iface_name; backhaul_params.backhaul_mac = bridge_info.mac; backhaul_params.backhaul_ipv4 = bridge_info.ip; backhaul_params.backhaul_bssid = network_utils::ZERO_MAC_STRING; @@ -3434,7 +3445,7 @@ bool slave_thread::slave_fsm(bool &call_slave_select) LOG(INFO) << "gw_bridge_mac=" << backhaul_params.gw_bridge_mac; LOG(INFO) << "controller_bridge_mac=" << backhaul_params.controller_bridge_mac; LOG(INFO) << "is_prplmesh_controller=" << backhaul_params.is_prplmesh_controller; - LOG(INFO) << "bridge_mac=" << backhaul_params.bridge_mac; + LOG(INFO) << "bridge_mac=" << db->bridge.mac; LOG(INFO) << "bridge_ipv4=" << backhaul_params.bridge_ipv4; LOG(INFO) << "backhaul_iface=" << backhaul_params.backhaul_iface; LOG(INFO) << "backhaul_mac=" << backhaul_params.backhaul_mac; @@ -3552,9 +3563,8 @@ bool slave_thread::slave_fsm(bool &call_slave_select) notification->backhaul_params().backhaul_is_wireless = backhaul_params.backhaul_is_wireless; - if (!config.bridge_iface.empty()) { - notification->backhaul_params().bridge_mac = - tlvf::mac_from_string(backhaul_params.bridge_mac); + if (!db->bridge.iface_name.empty()) { + notification->backhaul_params().bridge_mac = db->bridge.mac; notification->backhaul_params().bridge_ipv4 = network_utils::ipv4_from_string(backhaul_params.bridge_ipv4); notification->backhaul_params().backhaul_ipv4 = @@ -3831,7 +3841,10 @@ bool slave_thread::send_cmdu_to_controller(ieee1905_1::CmduMessageTx &cmdu_tx) cmdu_tx.getMessageType() == ieee1905_1::eMessageType::TOPOLOGY_NOTIFICATION_MESSAGE ? network_utils::MULTICAST_1905_MAC_ADDR : backhaul_params.controller_bridge_mac; - return message_com::send_cmdu(master_socket, cmdu_tx, dst_addr, backhaul_params.bridge_mac); + + auto db = AgentDB::get(); + return message_com::send_cmdu(master_socket, cmdu_tx, dst_addr, + tlvf::mac_to_string(db->bridge.mac)); } /** @@ -3852,10 +3865,11 @@ bool slave_thread::autoconfig_wsc_calculate_keys(WSC::m2 &m2, uint8_t authkey[32 LOG(ERROR) << "diffie hellman member not initialized"; return false; } - auto mac = tlvf::mac_from_string(backhaul_params.bridge_mac); - mapf::encryption::wps_calculate_keys(*dh, m2.public_key(), - WSC::eWscLengths::WSC_PUBLIC_KEY_LENGTH, dh->nonce(), - mac.oct, m2.registrar_nonce(), authkey, keywrapkey); + + auto db = AgentDB::get(); + mapf::encryption::wps_calculate_keys( + *dh, m2.public_key(), WSC::eWscLengths::WSC_PUBLIC_KEY_LENGTH, dh->nonce(), + db->bridge.mac.oct, m2.registrar_nonce(), authkey, keywrapkey); return true; } @@ -4932,8 +4946,10 @@ bool slave_thread::autoconfig_wsc_add_m1() tlv->alloc_payload(payload_length); WSC::m1::config cfg; + auto db = AgentDB::get(); + cfg.msg_type = WSC::eWscMessageType::WSC_MSG_TYPE_M1; - cfg.mac = tlvf::mac_from_string(backhaul_params.bridge_mac); + cfg.mac = db->bridge.mac; dh = std::make_unique(); std::copy(dh->nonce(), dh->nonce() + dh->nonce_length(), cfg.enrollee_nonce); copy_pubkey(*dh, cfg.pub_key); diff --git a/agent/src/beerocks/slave/son_slave_thread.h b/agent/src/beerocks/slave/son_slave_thread.h index ed0c293a1d..7fb2080904 100644 --- a/agent/src/beerocks/slave/son_slave_thread.h +++ b/agent/src/beerocks/slave/son_slave_thread.h @@ -59,8 +59,6 @@ class slave_thread : public beerocks::socket_thread { std::string gw_bridge_mac; std::string controller_bridge_mac; bool is_prplmesh_controller; - std::string bridge_iface; - std::string bridge_mac; std::string bridge_ipv4; std::string backhaul_iface; std::string backhaul_mac; From 82c4d9130e76480f343ff2c271132dc5b77b3021 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Sun, 5 Jul 2020 12:54:51 +0000 Subject: [PATCH 283/453] agent: Use ethernet interface name from AgentDB Replace the use of wire_iface on the Agent threads to the one from the AgentDB. Remove duplicate on m_sConfig on the backhaul manager. PPM-216 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 31 +++++++++++-------- .../backhaul_manager_thread.h | 1 - agent/src/beerocks/slave/son_slave_thread.cpp | 15 ++++----- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 2400d5a51b..22304d1887 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -581,7 +581,7 @@ bool backhaul_manager::finalize_slaves_connect_state(bool fConnected, if (!db->device_conf.local_gw) { if (m_sConfig.eType == SBackhaulConfig::EType::Wired) { - strIface = m_sConfig.wire_iface; + strIface = db->ethernet.iface_name; } else { strIface = m_sConfig.wireless_iface; } @@ -851,8 +851,8 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) // If a wired (WAN) interface was provided, try it first, check if the interface is UP wan_monitor::ELinkState wired_link_state = wan_monitor::ELinkState::eInvalid; - if (!m_sConfig.wire_iface.empty()) { - wired_link_state = wan_mon.initialize(m_sConfig.wire_iface); + if (!db->ethernet.iface_name.empty()) { + wired_link_state = wan_mon.initialize(db->ethernet.iface_name); // Failure might be due to insufficient permissions, datailed error message is being // printed inside. if (wired_link_state == wan_monitor::ELinkState::eInvalid) { @@ -862,9 +862,10 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) if ((wired_link_state == wan_monitor::ELinkState::eUp) && (selected_backhaul.empty() || selected_backhaul == DEV_SET_ETH)) { - auto it = std::find(ifaces.begin(), ifaces.end(), m_sConfig.wire_iface); + auto it = std::find(ifaces.begin(), ifaces.end(), db->ethernet.iface_name); if (it == ifaces.end()) { - LOG(ERROR) << "wire iface " << m_sConfig.wire_iface << " is not on the bridge"; + LOG(ERROR) << "wire iface " << db->ethernet.iface_name + << " is not on the bridge"; FSM_MOVE_STATE(RESTART); break; } @@ -988,8 +989,10 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) LOG(DEBUG) << "clearing blacklist"; ap_blacklist.clear(); + auto db = AgentDB::get(); + eth_link_poll_timer = std::chrono::steady_clock::now(); - m_eth_link_up = network_utils::linux_iface_is_up_and_running(m_sConfig.wire_iface); + m_eth_link_up = network_utils::linux_iface_is_up_and_running(db->ethernet.iface_name); FSM_MOVE_STATE(OPERATIONAL); // This event may come as a result of enabling the backhaul, but also as a result @@ -1026,7 +1029,7 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) * [TASK] Dynamic switching between wired and wireless * https://github.com/prplfoundation/prplMesh/issues/866 */ - + // auto db = AgentDB::get(); // int time_elapsed_ms = // std::chrono::duration_cast(now - eth_link_poll_timer) // .count(); @@ -1034,9 +1037,9 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) // if (time_elapsed_ms > POLL_TIMER_TIMEOUT_MS) { // eth_link_poll_timer = now; - // bool eth_link_up = network_utils::linux_iface_is_up_and_running(m_sConfig.wire_iface); + // bool eth_link_up = network_utils::linux_iface_is_up_and_running(db->ethernet.iface_name); // if (eth_link_up != m_eth_link_up) { - // m_eth_link_up = network_utils::linux_iface_is_up_and_running(m_sConfig.wire_iface); + // m_eth_link_up = network_utils::linux_iface_is_up_and_running(db->ethernet.iface_name); // FSM_MOVE_STATE(RESTART); // } // } else { @@ -1974,14 +1977,14 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr if (m_sConfig.security_type == bwl::WiFiSec::WPA_WPA2_PSK) { m_sConfig.security_type = bwl::WiFiSec::WPA2_PSK; } - m_sConfig.wire_iface.assign(request->wire_iface(message::IFACE_NAME_LENGTH)); + db->ethernet.iface_name.assign(request->wire_iface(message::IFACE_NAME_LENGTH)); m_sConfig.wire_iface_type = (beerocks::eIfaceType)request->wire_iface_type(); LOG(DEBUG) << "All slaves ready, proceeding" << std::endl << "SSID: " << m_sConfig.ssid << ", Pass: ****" << ", Security: " << int(m_sConfig.security_type) << ", Bridge: " << db->bridge.iface_name - << ", Wired: " << m_sConfig.wire_iface; + << ", Wired: " << db->ethernet.iface_name; } } } @@ -2871,7 +2874,7 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd /** * Add a LocalInterfaceInfo field for the wired interface, if any. */ - std::string local_interface_name = m_sConfig.wire_iface; + std::string local_interface_name = db->ethernet.iface_name; if (!local_interface_name.empty() && network_utils::linux_iface_is_up_and_running(local_interface_name)) { ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; @@ -4279,7 +4282,9 @@ bool backhaul_manager::get_neighbor_links( // address of the transmitting device together with the interface that such message is // received through. sLinkInterface wired_interface; - wired_interface.iface_name = m_sConfig.wire_iface; + auto db = AgentDB::get(); + + wired_interface.iface_name = db->ethernet.iface_name; if (!get_media_type(wired_interface.iface_name, ieee1905_1::eMediaTypeGroup::IEEE_802_3, wired_interface.media_type)) { diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 48a887bbd0..2c46db1e76 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -186,7 +186,6 @@ class backhaul_manager : public btl::transport_socket_thread { std::string ssid; std::string pass; - std::string wire_iface; std::string wireless_iface; std::string preferred_bssid; std::string vendor; diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index d98f30702e..793ab1917e 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -106,7 +106,8 @@ slave_thread::slave_thread(sSlaveConfig conf, beerocks::logging &logger_) // Set configuration on Agent database. auto db = AgentDB::get(); - db->bridge.iface_name = conf.bridge_iface; + db->bridge.iface_name = conf.bridge_iface; + db->ethernet.iface_name = conf.backhaul_wire_iface; slave_state = STATE_INIT; set_select_timeout(SELECT_TIMEOUT_MSEC); @@ -1259,7 +1260,7 @@ bool slave_thread::handle_cmdu_backhaul_manager_message( if (notification->params().backhaul_is_wireless) { backhaul_params.backhaul_iface = config.backhaul_wireless_iface; } else { - backhaul_params.backhaul_iface = config.backhaul_wire_iface; + backhaul_params.backhaul_iface = db->ethernet.iface_name; } LOG(DEBUG) << "goto STATE_BACKHAUL_MANAGER_CONNECTED"; @@ -3282,7 +3283,8 @@ bool slave_thread::slave_fsm(bool &call_slave_select) } case STATE_BACKHAUL_ENABLE: { bool error = false; - if (!config.backhaul_wire_iface.empty()) { + auto db = AgentDB::get(); + if (!db->ethernet.iface_name.empty()) { if (config.backhaul_wire_iface_type == beerocks::IFACE_TYPE_UNSUPPORTED) { LOG(DEBUG) << "backhaul_wire_iface_type is UNSUPPORTED"; platform_notify_error( @@ -3298,7 +3300,7 @@ bool slave_thread::slave_fsm(bool &call_slave_select) error = true; } } - if (config.backhaul_wire_iface.empty() && config.backhaul_wireless_iface.empty()) { + if (db->ethernet.iface_name.empty() && config.backhaul_wireless_iface.empty()) { LOG(DEBUG) << "No valid backhaul iface!"; platform_notify_error(bpl::eErrorCode::CONFIG_NO_VALID_BACKHAUL_INTERFACE, ""); error = true; @@ -3344,8 +3346,7 @@ bool slave_thread::slave_fsm(bool &call_slave_select) platform_settings.backhaul_preferred_radio_band; string_utils::copy_string(bh_enable->wire_iface(message::IFACE_NAME_LENGTH), - config.backhaul_wire_iface.c_str(), - message::IFACE_NAME_LENGTH); + db->ethernet.iface_name.c_str(), message::IFACE_NAME_LENGTH); bh_enable->wire_iface_type() = config.backhaul_wire_iface_type; bh_enable->wireless_iface_type() = config.backhaul_wireless_iface_type; @@ -3436,7 +3437,7 @@ bool slave_thread::slave_fsm(bool &call_slave_select) backhaul_params.backhaul_is_wireless = 0; backhaul_params.backhaul_iface_type = beerocks::IFACE_TYPE_GW_BRIDGE; if (is_backhaul_manager) { - backhaul_params.backhaul_iface = config.backhaul_wire_iface; + backhaul_params.backhaul_iface = db->ethernet.iface_name; } } From b9fd9e4e2ba04ebb60123446090a2c4655c10e2b Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Mon, 6 Jul 2020 07:34:48 +0000 Subject: [PATCH 284/453] agent: Use radio interface name and mac from AgentDB Replace the use of front and back interfaces names and macs from a local copy on the son_slave and the backhaul manager to the AgentDB. On the backhaul manager, create a local copy only and not a full transition to the AgentDB since this information is attached to other pieces of information on "slave_sockets" so a full transition could only be made after moving all the information on "sRadioInfo" to the AgentDB. PPM-216 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 14 ++- agent/src/beerocks/slave/son_slave_thread.cpp | 119 ++++++++++++++---- agent/src/beerocks/slave/son_slave_thread.h | 1 + 3 files changed, 110 insertions(+), 24 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 22304d1887..d450223147 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -1851,6 +1851,8 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr soc->sta_iface.assign(request->sta_iface(message::IFACE_NAME_LENGTH)); soc->hostap_iface.assign(request->hostap_iface(message::IFACE_NAME_LENGTH)); + // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 + db->add_radio(request->hostap_iface(), request->sta_iface()); soc->sta_iface_filter_low = request->sta_iface_filter_low(); onboarding = request->onboarding(); @@ -1892,7 +1894,12 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr return false; } - auto db = AgentDB::get(); + auto db = AgentDB::get(); + auto radio = db->radio(soc->hostap_iface); + if (!radio) { + LOG(DEBUG) << "Radio of iface " << soc->hostap_iface << " does not exist on the db"; + return false; + } auto tuple_preferred_channels = request->preferred_channels(0); if (!std::get<0>(tuple_preferred_channels)) { @@ -1904,7 +1911,10 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr std::copy_n(channels, request->preferred_channels_size(), soc->preferred_channels.begin()); - soc->radio_mac = request->iface_mac(); + soc->radio_mac = request->iface_mac(); + // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 + radio->front.iface_mac = soc->radio_mac; + soc->freq_type = request->frequency_band(); soc->controller_discovered = false; soc->max_bandwidth = request->max_bandwidth(); diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 793ab1917e..8e72ee2ea4 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -108,6 +108,7 @@ slave_thread::slave_thread(sSlaveConfig conf, beerocks::logging &logger_) db->bridge.iface_name = conf.bridge_iface; db->ethernet.iface_name = conf.backhaul_wire_iface; + db->add_radio(conf.hostap_iface, conf.backhaul_wireless_iface); slave_state = STATE_INIT; set_select_timeout(SELECT_TIMEOUT_MSEC); @@ -418,8 +419,15 @@ bool slave_thread::handle_cmdu_control_message(Socket *sd, // LOG(DEBUG) << "handle_cmdu_control_message(), INTEL_VS: action=" + std::to_string(beerocks_header->action()) + ", action_op=" + std::to_string(beerocks_header->action_op()); // LOG(DEBUG) << "received radio_mac=" << beerocks_header->radio_mac() << ", local radio_mac=" << hostap_params.iface_mac; + auto db = AgentDB::get(); + auto radio = db->radio(m_fronthaul_iface); + if (!radio) { + LOG(DEBUG) << "Radio of interface " << m_fronthaul_iface << " does not exist on the db"; + return false; + } + // to me or not to me, this is the question... - if (beerocks_header->actionhdr()->radio_mac() != hostap_params.iface_mac) { + if (beerocks_header->actionhdr()->radio_mac() != radio->front.iface_mac) { return true; } @@ -1661,8 +1669,19 @@ bool slave_thread::handle_cmdu_ap_manager_message(Socket *sd, LOG(ERROR) << "addClass cACTION_APMANAGER_JOINED_NOTIFICATION failed"; return false; } - hostap_params = notification->params(); - hostap_cs_params = notification->cs_params(); + auto db = AgentDB::get(); + + hostap_params = notification->params(); + + m_fronthaul_iface = notification->params().iface_name; + auto radio = db->radio(m_fronthaul_iface); + if (!radio) { + LOG(DEBUG) << "Radio of interface " << m_fronthaul_iface << " does not exist on the db"; + return false; + } + + radio->front.iface_mac = hostap_params.iface_mac; + hostap_cs_params = notification->cs_params(); auto tuple_preferred_channels = notification->preferred_channels(0); if (!std::get<0>(tuple_preferred_channels)) { @@ -2302,6 +2321,13 @@ bool slave_thread::handle_cmdu_ap_manager_message(Socket *sd, return false; } + auto db = AgentDB::get(); + auto radio = db->radio(m_fronthaul_iface); + if (!radio) { + LOG(DEBUG) << "Radio of interface " << m_fronthaul_iface << " does not exist on the db"; + return false; + } + auto preferences = wireless_utils::get_channel_preferences(&std::get<1>(tuple_preferred_channels)); @@ -2311,7 +2337,7 @@ bool slave_thread::handle_cmdu_ap_manager_message(Socket *sd, return false; } - channel_preference_tlv->radio_uid() = hostap_params.iface_mac; + channel_preference_tlv->radio_uid() = radio->front.iface_mac; for (auto preference : preferences) { // Create operating class object @@ -2349,7 +2375,7 @@ bool slave_thread::handle_cmdu_ap_manager_message(Socket *sd, } } - LOG(DEBUG) << "sending channel preference report for ruid=" << hostap_params.iface_mac; + LOG(DEBUG) << "sending channel preference report for ruid=" << radio->front.iface_mac; send_cmdu_to_controller(cmdu_tx); @@ -3327,7 +3353,12 @@ bool slave_thread::slave_fsm(bool &call_slave_select) break; } - auto db = AgentDB::get(); + auto db = AgentDB::get(); + auto radio = db->radio(m_fronthaul_iface); + if (!radio) { + LOG(DEBUG) << "Radio of interface " << m_fronthaul_iface << " does not exist on the db"; + return false; + } if (!db->device_conf.local_gw) { // Wireless config @@ -3352,7 +3383,7 @@ bool slave_thread::slave_fsm(bool &call_slave_select) bh_enable->wireless_iface_type() = config.backhaul_wireless_iface_type; } - bh_enable->iface_mac() = hostap_params.iface_mac; + bh_enable->iface_mac() = radio->front.iface_mac; bh_enable->preferred_bssid() = tlvf::mac_from_string(config.backhaul_preferred_bssid); string_utils::copy_string(bh_enable->sta_iface(message::IFACE_NAME_LENGTH), @@ -3506,14 +3537,19 @@ bool slave_thread::slave_fsm(bool &call_slave_select) return false; } - auto db = AgentDB::get(); + auto db = AgentDB::get(); + auto radio = db->radio(m_fronthaul_iface); + if (!radio) { + LOG(DEBUG) << "Radio of interface " << m_fronthaul_iface << " does not exist on the db"; + return false; + } std::array supported_channels_arr{{}}; std::copy_n(supported_channels.begin(), supported_channels.size(), supported_channels_arr.begin()); - if (!tlvf_utils::add_ap_radio_basic_capabilities(cmdu_tx, hostap_params.iface_mac, + if (!tlvf_utils::add_ap_radio_basic_capabilities(cmdu_tx, radio->front.iface_mac, supported_channels_arr)) { LOG(ERROR) << "Failed adding AP Radio Basic Capabilities TLV"; return false; @@ -3545,7 +3581,7 @@ bool slave_thread::slave_fsm(bool &call_slave_select) // Platform Configuration notification->low_pass_filter_on() = config.backhaul_wireless_iface_filter_low; notification->enable_repeater_mode() = config.enable_repeater_mode; - notification->radio_identifier() = hostap_params.iface_mac; + notification->radio_identifier() = radio->front.iface_mac; tlvf::mac_from_string(config.radio_identifier); // Backhaul Params @@ -3824,6 +3860,13 @@ bool slave_thread::send_cmdu_to_controller(ieee1905_1::CmduMessageTx &cmdu_tx) return false; } + auto db = AgentDB::get(); + auto radio = db->radio(m_fronthaul_iface); + if (!radio) { + LOG(DEBUG) << "Radio of interface " << m_fronthaul_iface << " does not exist on the db"; + return false; + } + if (cmdu_tx.getMessageType() == ieee1905_1::eMessageType::VENDOR_SPECIFIC_MESSAGE) { if (!backhaul_params.is_prplmesh_controller) { return true; // don't send VS messages to non prplmesh controllers @@ -3834,7 +3877,7 @@ bool slave_thread::send_cmdu_to_controller(ieee1905_1::CmduMessageTx &cmdu_tx) return false; } - beerocks_header->actionhdr()->radio_mac() = hostap_params.iface_mac; + beerocks_header->actionhdr()->radio_mac() = radio->front.iface_mac; beerocks_header->actionhdr()->direction() = beerocks::BEEROCKS_DIRECTION_CONTROLLER; } @@ -3843,7 +3886,6 @@ bool slave_thread::send_cmdu_to_controller(ieee1905_1::CmduMessageTx &cmdu_tx) ? network_utils::MULTICAST_1905_MAC_ADDR : backhaul_params.controller_bridge_mac; - auto db = AgentDB::get(); return message_com::send_cmdu(master_socket, cmdu_tx, dst_addr, tlvf::mac_to_string(db->bridge.mac)); } @@ -4082,9 +4124,17 @@ bool slave_thread::handle_autoconfiguration_wsc(Socket *sd, ieee1905_1::CmduMess LOG(ERROR) << "getClass failed"; return false; } + + auto db = AgentDB::get(); + auto radio = db->radio(m_fronthaul_iface); + if (!radio) { + LOG(DEBUG) << "Radio of interface " << m_fronthaul_iface << " does not exist on the db"; + return false; + } // Check if the message is for this radio agent by comparing the ruid - if (hostap_params.iface_mac != ruid->radio_uid()) { - LOG(DEBUG) << "not to me - ruid " << hostap_params.iface_mac << " != " << ruid->radio_uid(); + if (radio->front.iface_mac != ruid->radio_uid()) { + LOG(DEBUG) << "Message should be handled by another son_slave - ruid " + << radio->front.iface_mac << " != " << ruid->radio_uid(); return true; } @@ -4696,12 +4746,18 @@ bool slave_thread::channel_selection_current_channel_restricted() bool slave_thread::channel_selection_get_channel_preference(ieee1905_1::CmduMessageRx &cmdu_rx) { channel_preferences.clear(); + auto db = AgentDB::get(); + auto radio = db->radio(m_fronthaul_iface); + if (!radio) { + LOG(DEBUG) << "Radio of interface " << m_fronthaul_iface << " does not exist on the db"; + return false; + } for (auto channel_preference_tlv : cmdu_rx.getClassList()) { const auto &ruid = channel_preference_tlv->radio_uid(); - if (ruid != hostap_params.iface_mac) { - LOG(DEBUG) << "ruid_rx=" << ruid << ", son_slave_ruid=" << hostap_params.iface_mac; + if (ruid != radio->front.iface_mac) { + LOG(DEBUG) << "ruid_rx=" << ruid << ", son_slave_ruid=" << radio->front.iface_mac; continue; } @@ -4772,11 +4828,17 @@ bool slave_thread::channel_selection_get_channel_preference(ieee1905_1::CmduMess bool slave_thread::channel_selection_get_transmit_power_limit(ieee1905_1::CmduMessageRx &cmdu_rx, int &power_limit) { + auto db = AgentDB::get(); + auto radio = db->radio(m_fronthaul_iface); + if (!radio) { + LOG(DEBUG) << "Radio of interface " << m_fronthaul_iface << " does not exist on the db"; + return false; + } for (const auto &tx_power_limit_tlv : cmdu_rx.getClassList()) { const auto &ruid = tx_power_limit_tlv->radio_uid(); - if (ruid != hostap_params.iface_mac) { - LOG(DEBUG) << "ruid_rx=" << ruid << ", son_slave_ruid=" << hostap_params.iface_mac; + if (ruid != radio->front.iface_mac) { + LOG(DEBUG) << "ruid_rx=" << ruid << ", son_slave_ruid=" << radio->front.iface_mac; continue; } @@ -4793,6 +4855,13 @@ bool slave_thread::handle_channel_selection_request(Socket *sd, ieee1905_1::Cmdu const auto mid = cmdu_rx.getMessageId(); LOG(DEBUG) << "Received CHANNEL_SELECTION_REQUEST_MESSAGE, mid=" << std::dec << int(mid); + auto db = AgentDB::get(); + auto radio = db->radio(m_fronthaul_iface); + if (!radio) { + LOG(DEBUG) << "Radio of interface " << m_fronthaul_iface << " does not exist on the db"; + return false; + } + int power_limit = 0; bool power_limit_received = channel_selection_get_transmit_power_limit(cmdu_rx, power_limit); @@ -4808,7 +4877,7 @@ bool slave_thread::handle_channel_selection_request(Socket *sd, ieee1905_1::Cmdu LOG(INFO) << "Switch to channel " << +channel_to_switch.channel << " bw " << +channel_to_switch.channel_bandwidth; } else { - LOG(INFO) << "Decline channel selection request " << hostap_params.iface_mac; + LOG(INFO) << "Decline channel selection request " << radio->front.iface_mac; response_code = wfa_map::tlvChannelSelectionResponse::eResponseCode:: DECLINE_VIOLATES_MOST_RECENTLY_REPORTED_PREFERENCES; } @@ -4831,7 +4900,7 @@ bool slave_thread::handle_channel_selection_request(Socket *sd, ieee1905_1::Cmdu return false; } - channel_selection_response_tlv->radio_uid() = hostap_params.iface_mac; + channel_selection_response_tlv->radio_uid() = radio->front.iface_mac; channel_selection_response_tlv->response_code() = response_code; if (!message_com::send_cmdu(backhaul_manager_socket, cmdu_tx)) { LOG(ERROR) << "failed to send CHANNEL_SELECTION_RESPONSE_MESSAGE"; @@ -4893,13 +4962,19 @@ bool slave_thread::send_operating_channel_report() return false; } + auto db = AgentDB::get(); + auto radio = db->radio(m_fronthaul_iface); + if (!radio) { + LOG(DEBUG) << "Radio of interface " << m_fronthaul_iface << " does not exist on the db"; + return false; + } + auto operating_channel_report_tlv = cmdu_tx.addClass(); if (!operating_channel_report_tlv) { LOG(ERROR) << "addClass ieee1905_1::operating_channel_report_tlv has failed"; return false; } - - operating_channel_report_tlv->radio_uid() = hostap_params.iface_mac; + operating_channel_report_tlv->radio_uid() = radio->front.iface_mac; auto op_classes_list = operating_channel_report_tlv->alloc_operating_classes_list(); if (!op_classes_list) { diff --git a/agent/src/beerocks/slave/son_slave_thread.h b/agent/src/beerocks/slave/son_slave_thread.h index 7fb2080904..a6ce66db4b 100644 --- a/agent/src/beerocks/slave/son_slave_thread.h +++ b/agent/src/beerocks/slave/son_slave_thread.h @@ -198,6 +198,7 @@ class slave_thread : public beerocks::socket_thread { Socket *monitor_socket = nullptr; Socket *ap_manager_socket = nullptr; + std::string m_fronthaul_iface; std::chrono::steady_clock::time_point master_last_seen; std::chrono::steady_clock::time_point monitor_last_seen; From dd8c41b1ae2b866def5c9af4d17893e3b46ed134 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Mon, 6 Jul 2020 09:12:25 +0000 Subject: [PATCH 285/453] agent: Use backhaul connection type from AgentDB Replace the use of backhaul connection type from backhaul manager data member to the AgentDB member. PPM-216 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 53 +++++++++++++++---- .../backhaul_manager_thread.h | 9 ---- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index d450223147..2600d0f73a 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -368,6 +368,8 @@ bool backhaul_manager::socket_disconnected(Socket *sd) return true; } + auto db = AgentDB::get(); + for (auto it = slaves_sockets.begin(); it != slaves_sockets.end();) { auto soc = *it; std::string iface = soc->hostap_iface; @@ -408,7 +410,7 @@ bool backhaul_manager::socket_disconnected(Socket *sd) it = slaves_sockets.erase(it); if ((m_eFSMState > EState::_WIRELESS_START_ && m_eFSMState < EState::_WIRELESS_END_) || (soc->slave_is_backhaul_manager && - m_sConfig.eType == SBackhaulConfig::EType::Wireless)) { + db->backhaul.connection_type == AgentDB::sBackhaul::eConnectionType::Wireless)) { LOG(INFO) << "Not in operational state OR backhaul manager slave disconnected, " "restarting backhaul manager. Backhaul connection is probably lost"; FSM_MOVE_STATE(RESTART); @@ -428,7 +430,6 @@ bool backhaul_manager::socket_disconnected(Socket *sd) LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; return false; } - auto db = AgentDB::get(); send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, tlvf::mac_to_string(db->bridge.mac)); } @@ -580,7 +581,7 @@ bool backhaul_manager::finalize_slaves_connect_state(bool fConnected, if (!db->device_conf.local_gw) { - if (m_sConfig.eType == SBackhaulConfig::EType::Wired) { + if (db->backhaul.connection_type == AgentDB::sBackhaul::eConnectionType::Wired) { strIface = db->ethernet.iface_name; } else { strIface = m_sConfig.wireless_iface; @@ -598,7 +599,7 @@ bool backhaul_manager::finalize_slaves_connect_state(bool fConnected, notification->params().backhaul_mac = tlvf::mac_from_string(iface_info.mac); notification->params().backhaul_ipv4 = network_utils::ipv4_from_string(iface_info.ip); - if (m_sConfig.eType == SBackhaulConfig::EType::Wired) { + if (db->backhaul.connection_type == AgentDB::sBackhaul::eConnectionType::Wired) { notification->params().backhaul_bssid = tlvf::mac_from_string(network_utils::ZERO_MAC_STRING); notification->params().backhaul_iface_type = IFACE_TYPE_ETHERNET; @@ -871,7 +872,7 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) } // Mark the connection as WIRED - m_sConfig.eType = SBackhaulConfig::EType::Wired; + db->backhaul.connection_type = AgentDB::sBackhaul::eConnectionType::Wired; } else { auto selected_ruid_it = std::find_if( @@ -893,11 +894,11 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) } // Mark the connection as WIRELESS - m_sConfig.eType = SBackhaulConfig::EType::Wireless; + db->backhaul.connection_type = AgentDB::sBackhaul::eConnectionType::Wireless; } // Move to the next state immediately - if (m_sConfig.eType == SBackhaulConfig::EType::Wireless) { + if (db->backhaul.connection_type == AgentDB::sBackhaul::eConnectionType::Wireless) { FSM_MOVE_STATE(INIT_HAL); } else { // EType::Wired FSM_MOVE_STATE(MASTER_DISCOVERY); @@ -1043,7 +1044,9 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) // FSM_MOVE_STATE(RESTART); // } // } else { - if (pending_enable && m_sConfig.eType != SBackhaulConfig::EType::Invalid) { + auto db = AgentDB::get(); + if (pending_enable && + db->backhaul.connection_type != AgentDB::sBackhaul::eConnectionType::Invalid) { pending_enable = false; } @@ -1090,6 +1093,8 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) LOG(DEBUG) << "Restarting ..."; + auto db = AgentDB::get(); + for (auto soc : slaves_sockets) { std::string iface = soc->sta_iface; @@ -1120,7 +1125,7 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) pending_slave_ifaces = slave_ap_ifaces; pending_enable = false; - m_sConfig.eType = SBackhaulConfig::EType::Invalid; + db->backhaul.connection_type = AgentDB::sBackhaul::eConnectionType::Invalid; controller_bridge_mac.clear(); @@ -1364,6 +1369,8 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) bool success = true; + auto db = AgentDB::get(); + for (auto soc : slaves_sockets) { std::string iface = soc->sta_iface; if (iface.empty()) @@ -1412,6 +1419,29 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) success = false; break; } + + /** + * This code was disabled as part of the effort to pass certification flow + * (PR #1469), and broke wirless backhual flow. + * If a connected backhual interface has been discovered, the backhaul fsm was set + * to MASTER_DISCOVERY state, otherwise, to INITIATE_SCAN. + */ + + // if (!roam_flag && soc->sta_wlan_hal->is_connected()) { + // if (!soc->sta_wlan_hal->update_status()) { + // LOG(ERROR) << "failed to update sta status"; + // success = false; + // break; + // } + // connected = true; + // db->backhaul.selected_iface_name = iface; + // db->backhaul.connection_type = AgentDB::sBackhaul::eConnectionType::Wireless; + // selected_bssid = soc->sta_wlan_hal->get_bssid(); + // selected_bssid_channel = soc->sta_wlan_hal->get_channel(); + // soc->slave_is_backhaul_manager = true; + // break; + // } + } else if (attach_state == bwl::HALState::Failed) { // Delete the HAL instance soc->sta_wlan_hal.reset(); @@ -2940,9 +2970,10 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd // BSSID field is not defined well for interface. The common definition is in simple // words "the AP/ETH mac that we are connected to". // For fronthaul radio interface or unused backhaul interface put zero mac. - if (db->device_conf.local_gw || m_sConfig.eType == SBackhaulConfig::EType::Wired || + if (db->device_conf.local_gw || + db->backhaul.connection_type == AgentDB::sBackhaul::eConnectionType::Wired || front_iface || - (m_sConfig.eType == SBackhaulConfig::EType::Wireless && + (db->backhaul.connection_type == AgentDB::sBackhaul::eConnectionType::Wireless && soc->sta_iface != m_sConfig.wireless_iface)) { media_info.network_membership = network_utils::ZERO_MAC; } else { diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 2c46db1e76..7b0298f870 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -175,15 +175,6 @@ class backhaul_manager : public btl::transport_socket_thread { SocketClient *master_discovery_socket = nullptr; struct SBackhaulConfig { - - // Current connection type - enum class EType { - Invalid = 0, //!< Invalid connection - Wired, //!< Wired connection - Wireless //!< Wireless connection - - } eType; - std::string ssid; std::string pass; std::string wireless_iface; From 0b3776176921a19c1b86e1bccae6ab21746f3dfd Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Mon, 6 Jul 2020 11:35:53 +0000 Subject: [PATCH 286/453] agent: Use selected backhaul from AgentDB Replace the use of the "wireless_iface" data member from the backhaul manager with the "backhaul.selected_iface_name" on AgentDB. Previously "wireless_iface" stored only the selected wireless interface, but in this commit, change it to store the selected interface, whether it is a wireless, wired, or none (in case of gw). PPM-216 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 92 ++++++++++--------- .../backhaul_manager_thread.h | 1 - 2 files changed, 48 insertions(+), 45 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 2600d0f73a..27c194421d 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -572,7 +572,6 @@ bool backhaul_manager::finalize_slaves_connect_state(bool fConnected, auto db = AgentDB::get(); - std::string strIface; network_utils::iface_info iface_info; bool backhaul_manager_exist = false; @@ -580,15 +579,9 @@ bool backhaul_manager::finalize_slaves_connect_state(bool fConnected, notification->params().controller_bridge_mac = tlvf::mac_from_string(controller_bridge_mac); if (!db->device_conf.local_gw) { - - if (db->backhaul.connection_type == AgentDB::sBackhaul::eConnectionType::Wired) { - strIface = db->ethernet.iface_name; - } else { - strIface = m_sConfig.wireless_iface; - } // Read the IP addresses of the bridge interface - if (network_utils::get_iface_info(iface_info, strIface) != 0) { - LOG(ERROR) << "Failed reading addresses for: " << strIface; + if (network_utils::get_iface_info(iface_info, db->backhaul.selected_iface_name) != 0) { + LOG(ERROR) << "Failed reading addresses for: " << db->backhaul.selected_iface_name; return false; } @@ -625,7 +618,7 @@ bool backhaul_manager::finalize_slaves_connect_state(bool fConnected, // Find the slave handling the wireless interface for (auto soc : slaves_sockets) { - if (soc->sta_iface == m_sConfig.wireless_iface) { + if (soc->sta_iface == db->backhaul.selected_iface_name) { // Mark the slave as the backhaul manager soc->slave_is_backhaul_manager = true; @@ -846,6 +839,8 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) if (db->device_conf.local_controller && db->device_conf.local_gw) { LOG(DEBUG) << "local controller && local gw"; FSM_MOVE_STATE(MASTER_DISCOVERY); + db->backhaul.connection_type = AgentDB::sBackhaul::eConnectionType::Invalid; + db->backhaul.selected_iface_name.clear(); } else { // link establish auto ifaces = network_utils::linux_get_iface_list_from_bridge(db->bridge.iface_name); @@ -872,7 +867,8 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) } // Mark the connection as WIRED - db->backhaul.connection_type = AgentDB::sBackhaul::eConnectionType::Wired; + db->backhaul.connection_type = AgentDB::sBackhaul::eConnectionType::Wired; + db->backhaul.selected_iface_name = db->ethernet.iface_name; } else { auto selected_ruid_it = std::find_if( @@ -1422,9 +1418,9 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) /** * This code was disabled as part of the effort to pass certification flow - * (PR #1469), and broke wirless backhual flow. + * (PR #1469), and broke wireless backhual flow. * If a connected backhual interface has been discovered, the backhaul fsm was set - * to MASTER_DISCOVERY state, otherwise, to INITIATE_SCAN. + * to MASTER_DISCOVERY state, otherwise to INITIATE_SCAN. */ // if (!roam_flag && soc->sta_wlan_hal->is_connected()) { @@ -1623,6 +1619,8 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) } } + auto db = AgentDB::get(); + if (hidden_ssid) { std::string iface; @@ -1652,8 +1650,8 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) break; } - m_sConfig.wireless_iface = iface; - active_hal = get_wireless_hal(); + db->backhaul.selected_iface_name = iface; + active_hal = get_wireless_hal(); } if (active_hal->connect(m_sConfig.ssid, m_sConfig.pass, m_sConfig.security_type, @@ -1661,9 +1659,9 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) hidden_ssid)) { LOG(DEBUG) << "successful call to active_hal->connect(), bssid=" << selected_bssid << ", channel=" << selected_bssid_channel - << ", iface=" << m_sConfig.wireless_iface; + << ", iface=" << db->backhaul.selected_iface_name; } else { - LOG(ERROR) << "connect command failed for iface " << m_sConfig.wireless_iface; + LOG(ERROR) << "connect command failed for iface " << db->backhaul.selected_iface_name; FSM_MOVE_STATE(INITIATE_SCAN); break; } @@ -1677,6 +1675,7 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) } case EState::WIRELESS_ASSOCIATE_4ADDR_WAIT: { + auto db = AgentDB::get(); auto now = std::chrono::steady_clock::now(); if (now > state_time_stamp_timeout) { LOG(ERROR) << "associate wait timeout"; @@ -1702,7 +1701,7 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) stop_on_failure_attempts--; platform_notify_error(bpl::eErrorCode::BH_ASSOCIATE_4ADDR_TIMEOUT, "SSID='" + m_sConfig.ssid + "', iface='" + - m_sConfig.wireless_iface + "'"); + db->backhaul.selected_iface_name + "'"); if (!selected_bssid.empty()) { ap_blacklist_entry &entry = ap_blacklist[selected_bssid]; @@ -2974,7 +2973,7 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd db->backhaul.connection_type == AgentDB::sBackhaul::eConnectionType::Wired || front_iface || (db->backhaul.connection_type == AgentDB::sBackhaul::eConnectionType::Wireless && - soc->sta_iface != m_sConfig.wireless_iface)) { + soc->sta_iface != db->backhaul.selected_iface_name)) { media_info.network_membership = network_utils::ZERO_MAC; } else { media_info.network_membership = @@ -3686,6 +3685,7 @@ bool backhaul_manager::send_slaves_enable() { auto iface_hal = get_wireless_hal(); + auto db = AgentDB::get(); for (auto soc : slaves_sockets) { auto notification = message_com::create_vs_message( @@ -3696,7 +3696,7 @@ bool backhaul_manager::send_slaves_enable() return false; } - if (soc->sta_iface == m_sConfig.wireless_iface) { + if (soc->sta_iface == db->backhaul.selected_iface_name) { notification->channel() = iface_hal->get_channel(); } LOG(DEBUG) << "Sending enable to slave " << soc->hostap_iface @@ -3751,12 +3751,12 @@ bool backhaul_manager::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t eve auto db = AgentDB::get(); - if (iface == m_sConfig.wireless_iface && !hidden_ssid) { + if (iface == db->backhaul.selected_iface_name && !hidden_ssid) { //this is generally not supposed to happen LOG(WARNING) << "event iface != wireless iface!"; } if (FSM_IS_IN_STATE(WAIT_WPS)) { - m_sConfig.wireless_iface = iface; + db->backhaul.selected_iface_name = iface; FSM_MOVE_STATE(MASTER_DISCOVERY); } if (FSM_IS_IN_STATE(WIRELESS_ASSOCIATE_4ADDR_WAIT)) { @@ -3825,7 +3825,8 @@ bool backhaul_manager::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t eve if (FSM_IS_IN_STATE(WAIT_WPS)) { return true; } - if (iface == m_sConfig.wireless_iface) { + auto db = AgentDB::get(); + if (iface == db->backhaul.selected_iface_name) { if (FSM_IS_IN_STATE(OPERATIONAL) || FSM_IS_IN_STATE(CONNECTED)) { platform_notify_error(bpl::eErrorCode::BH_DISCONNECTED, "Backhaul disconnected on operational state"); @@ -3979,6 +3980,8 @@ bool backhaul_manager::select_bssid() // Support up to 256 scan results std::vector scan_results; + auto db = AgentDB::get(); + LOG(DEBUG) << "select_bssid: SSID = " << m_sConfig.ssid; for (auto soc : slaves_sockets) { @@ -4020,14 +4023,14 @@ bool backhaul_manager::select_bssid() LOG(DEBUG) << "roaming flag on - found bssid match = " << roam_selected_bssid << " roam_selected_bssid_channel = " << int(roam_selected_bssid_channel); - m_sConfig.wireless_iface = iface; + db->backhaul.selected_iface_name = iface; return true; } } else if (!m_sConfig.preferred_bssid.empty() && bssid == m_sConfig.preferred_bssid) { LOG(DEBUG) << "preferred bssid - found bssid match = " << bssid; - selected_bssid_channel = scan_result.channel; - selected_bssid = bssid; - m_sConfig.wireless_iface = iface; + selected_bssid_channel = scan_result.channel; + selected_bssid = bssid; + db->backhaul.selected_iface_name = iface; return true; } else if (son::wireless_utils::which_freq(scan_result.channel) == eFreqType::FREQ_5G) { if (soc->sta_iface_filter_low && @@ -4140,29 +4143,29 @@ bool backhaul_manager::select_bssid() // TODO: ??? return false; } else if (max_rssi_24 == beerocks::RSSI_INVALID) { - selected_bssid = best_bssid_5; - selected_bssid_channel = best_bssid_channel_5; - m_sConfig.wireless_iface = best_5_sta_iface; + selected_bssid = best_bssid_5; + selected_bssid_channel = best_bssid_channel_5; + db->backhaul.selected_iface_name = best_5_sta_iface; } else if (max_rssi_5_best == beerocks::RSSI_INVALID) { - selected_bssid = best_bssid_24; - selected_bssid_channel = best_bssid_channel_24; - m_sConfig.wireless_iface = best_24_sta_iface; + selected_bssid = best_bssid_24; + selected_bssid_channel = best_bssid_channel_24; + db->backhaul.selected_iface_name = best_24_sta_iface; } else if ((max_rssi_5_best > RSSI_THRESHOLD_5GHZ)) { - selected_bssid = best_bssid_5; - selected_bssid_channel = best_bssid_channel_5; - m_sConfig.wireless_iface = best_5_sta_iface; + selected_bssid = best_bssid_5; + selected_bssid_channel = best_bssid_channel_5; + db->backhaul.selected_iface_name = best_5_sta_iface; } else if (max_rssi_24 < max_rssi_5_best + RSSI_BAND_DELTA_THRESHOLD) { - selected_bssid = best_bssid_5; - selected_bssid_channel = best_bssid_channel_5; - m_sConfig.wireless_iface = best_5_sta_iface; + selected_bssid = best_bssid_5; + selected_bssid_channel = best_bssid_channel_5; + db->backhaul.selected_iface_name = best_5_sta_iface; } else { - selected_bssid = best_bssid_24; - selected_bssid_channel = best_bssid_channel_24; - m_sConfig.wireless_iface = best_24_sta_iface; + selected_bssid = best_bssid_24; + selected_bssid_channel = best_bssid_channel_24; + db->backhaul.selected_iface_name = best_24_sta_iface; } if (!get_wireless_hal()) { - LOG(ERROR) << "Slave for interface " << m_sConfig.wireless_iface << " NOT found!"; + LOG(ERROR) << "Slave for interface " << db->backhaul.selected_iface_name << " NOT found!"; return false; } @@ -4232,8 +4235,9 @@ void backhaul_manager::get_scan_measurement() std::shared_ptr backhaul_manager::get_wireless_hal(std::string iface) { // If the iface argument is empty, use the default wireless interface + auto db = AgentDB::get(); if (iface.empty()) { - iface = m_sConfig.wireless_iface; + iface = db->backhaul.selected_iface_name; } auto slave_sk = m_sConfig.slave_iface_socket.find(iface); diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 7b0298f870..1836461720 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -177,7 +177,6 @@ class backhaul_manager : public btl::transport_socket_thread { struct SBackhaulConfig { std::string ssid; std::string pass; - std::string wireless_iface; std::string preferred_bssid; std::string vendor; std::string model; From 180c4d59aae1d61e4108608a77fe84661c2042b8 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Tue, 7 Jul 2020 07:57:16 +0000 Subject: [PATCH 287/453] agent: Use freq_type and max_bandwidth from AgentDB "freq_type" and "max_bandwidth" are being sent from the sin_slave to the backhaul manager which saves a local copy of it. Replace their use to be from the AgentDB instead of a local copy. The local backhaul manager copies yet not been removed since at this point we are still dependent on other members on "slave_sockets". PPM-216 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 82 +++++++++++-------- .../backhaul_manager_thread.h | 2 +- agent/src/beerocks/slave/son_slave_thread.cpp | 11 ++- 3 files changed, 54 insertions(+), 41 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 27c194421d..e2efe36660 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -871,13 +871,10 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) db->backhaul.selected_iface_name = db->ethernet.iface_name; } else { - auto selected_ruid_it = std::find_if( - slaves_sockets.begin(), slaves_sockets.end(), - [&selected_backhaul](std::shared_ptr soc) { - return tlvf::mac_from_string(selected_backhaul) == soc->radio_mac; - }); + auto selected_ruid = db->get_radio_by_mac(tlvf::mac_from_string(selected_backhaul), + AgentDB::eMacType::RADIO); - if (!selected_backhaul.empty() && selected_ruid_it == slaves_sockets.end()) { + if (!selected_backhaul.empty() && !selected_ruid) { LOG(ERROR) << "UCC configured backhaul RUID which is not enabled"; // Restart state will update the onboarding status to failure. FSM_MOVE_STATE(RESTART); @@ -885,8 +882,8 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) } // Override backhaul_preferred_radio_band if UCC set it - if (selected_ruid_it != slaves_sockets.end()) { - m_sConfig.backhaul_preferred_radio_band = (*selected_ruid_it)->freq_type; + if (!selected_ruid) { + m_sConfig.backhaul_preferred_radio_band = selected_ruid->front.freq_type; } // Mark the connection as WIRELESS @@ -945,18 +942,23 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) bool sent_for_2g = false; bool sent_for_5g = false; + auto db = AgentDB::get(); - for (auto soc : slaves_sockets) { - if (soc->freq_type == eFreqType::FREQ_24G) { + for (const auto &radio : db->get_radios_list()) { + if (!radio) { + continue; + } + //for (auto soc : slaves_sockets) { + if (radio->front.freq_type == eFreqType::FREQ_24G) { if (sent_for_2g) continue; - if (send_autoconfig_search_message(soc)) { + if (send_autoconfig_search_message(radio->front.iface_name)) { sent_for_2g = true; } - } else if (soc->freq_type == eFreqType::FREQ_5G) { + } else if (radio->front.freq_type == eFreqType::FREQ_5G) { if (sent_for_5g) continue; - if (send_autoconfig_search_message(soc)) { + if (send_autoconfig_search_message(radio->front.iface_name)) { sent_for_5g = true; } } @@ -1209,7 +1211,7 @@ bool backhaul_manager::send_1905_topology_discovery_message(const std::string &i tlvf::mac_to_string(db->bridge.mac), iface_name); } -bool backhaul_manager::send_autoconfig_search_message(std::shared_ptr soc) +bool backhaul_manager::send_autoconfig_search_message(const std::string &front_radio_iface_name) { auto db = AgentDB::get(); @@ -1219,13 +1221,18 @@ bool backhaul_manager::send_autoconfig_search_message(std::shared_ptrfreq_type == beerocks::eFreqType::FREQ_24G) { + auto radio = db->radio(front_radio_iface_name); + if (!radio) { + LOG(DEBUG) << "Radio of iface " << front_radio_iface_name << " does not exist on the db"; + return false; + } + if (radio->front.freq_type == beerocks::eFreqType::FREQ_24G) { freq_band = ieee1905_1::tlvAutoconfigFreqBand::IEEE_802_11_2_4_GHZ; - } else if (soc->freq_type == beerocks::eFreqType::FREQ_5G) { + } else if (radio->front.freq_type == beerocks::eFreqType::FREQ_5G) { freq_band = ieee1905_1::tlvAutoconfigFreqBand::IEEE_802_11_5_GHZ; } else { - LOG(ERROR) << "unsupported freq_type=" << int(soc->freq_type) - << ", iface=" << soc->hostap_iface; + LOG(ERROR) << "unsupported freq_type=" << int(radio->front.freq_type) + << ", iface=" << front_radio_iface_name; return false; } auto p_cmdu_header = @@ -1944,9 +1951,13 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 radio->front.iface_mac = soc->radio_mac; - soc->freq_type = request->frequency_band(); + soc->freq_type = request->frequency_band(); + // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 + radio->front.freq_type = request->frequency_band(); soc->controller_discovered = false; soc->max_bandwidth = request->max_bandwidth(); + // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 + radio->front.max_supported_bw = request->max_bandwidth(); soc->ht_supported = request->ht_supported(); soc->ht_capability = request->ht_capability(); @@ -1972,7 +1983,7 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr // If we're already connected, send a notification to the slave if (FSM_IS_IN_STATE(OPERATIONAL)) { - send_autoconfig_search_message(soc); + send_autoconfig_search_message(radio->front.iface_name); } else if (pending_enable) { auto notification = message_com::create_vs_message< beerocks_message::cACTION_BACKHAUL_BUSY_NOTIFICATION>(cmdu_tx); @@ -4269,14 +4280,12 @@ bool backhaul_manager::get_media_type(const std::string &interface_name, } } else if (ieee1905_1::eMediaTypeGroup::IEEE_802_11 == media_type_group) { - auto it = std::find_if(slaves_sockets.begin(), slaves_sockets.end(), - [&](const std::shared_ptr &radio_info) { - return interface_name == radio_info->hostap_iface; - }); - if (it != slaves_sockets.end()) { - auto radio_info = *it; + auto db = AgentDB::get(); + + auto radio = db->radio(interface_name); + if (radio) { media_type = - beerocks::get_802_11_media_type(radio_info->freq_type, radio_info->max_bandwidth); + get_802_11_media_type(radio->front.freq_type, radio->front.max_supported_bw); result = true; } @@ -4785,17 +4794,18 @@ bool backhaul_manager::create_backhaul_steering_response( const std::string backhaul_manager::freq_to_radio_mac(eFreqType freq) const { - auto it = - std::find_if(slaves_sockets.begin(), slaves_sockets.end(), - [&](std::shared_ptr slave) { return slave->freq_type == freq; }); - - if (it == slaves_sockets.end()) { - LOG(ERROR) << "couldn't find slave for freq " << int(freq); - return std::string(); + auto db = AgentDB::get(); + for (const auto &radio : db->get_radios_list()) { + if (!radio) { + continue; + } + if (radio->front.freq_type == freq) { + return tlvf::mac_to_string(radio->front.iface_mac); + } } - auto slave = *it; - return tlvf::mac_to_string(slave->radio_mac); + LOG(ERROR) << "Radio not found for freq " << int(freq); + return std::string(); } bool backhaul_manager::start_wps_pbc(const sMacAddr &radio_mac) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 1836461720..8f7f2c560c 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -94,7 +94,7 @@ class backhaul_manager : public btl::transport_socket_thread { finalize_slaves_connect_state(bool fConnected, std::shared_ptr pSocket = nullptr); // cmdu_duplicate - bool send_autoconfig_search_message(std::shared_ptr soc); + bool send_autoconfig_search_message(const std::string &front_radio_iface_name); bool send_1905_topology_discovery_message(); /** diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 8e72ee2ea4..154b735121 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -3390,10 +3390,13 @@ bool slave_thread::slave_fsm(bool &call_slave_select) config.backhaul_wireless_iface.c_str(), message::IFACE_NAME_LENGTH); - bh_enable->frequency_band() = hostap_params.frequency_band; - bh_enable->max_bandwidth() = hostap_params.max_bandwidth; - bh_enable->ht_supported() = hostap_params.ht_supported; - bh_enable->ht_capability() = hostap_params.ht_capability; + bh_enable->frequency_band() = hostap_params.frequency_band; + radio->front.freq_type = hostap_params.frequency_band; + bh_enable->max_bandwidth() = hostap_params.max_bandwidth; + radio->front.max_supported_bw = hostap_params.max_bandwidth; + + bh_enable->ht_supported() = hostap_params.ht_supported; + bh_enable->ht_capability() = hostap_params.ht_capability; std::copy_n(hostap_params.ht_mcs_set, beerocks::message::HT_MCS_SET_SIZE, bh_enable->ht_mcs_set()); bh_enable->vht_supported() = hostap_params.vht_supported; From 75a8ab4155b9f4a9649b5b9dd9b03854a339c2ec Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Tue, 7 Jul 2020 15:30:48 +0000 Subject: [PATCH 288/453] agent: Use bssids (vaps) list from AgentDB The bssids (vaps) list is being sent from the son_slave to the backhaul manager when updated, and the backhaul manager saves a copy of it. Replace the use of the backhaul manager's local copy of it with the list on the AgentDB. On this opportunity, refactor the function "send_slave_ap_metric_query_message" to be more efficient, by not require a mandatory bssid list, and be able to send the query on all bssids if the given bssid list is empty. PPM-216 Signed-off-by: Moran Shoeg --- .../src/beerocks/slave/agent_ucc_listener.cpp | 41 ++--- agent/src/beerocks/slave/agent_ucc_listener.h | 1 - .../backhaul_manager_thread.cpp | 151 +++++++++--------- .../backhaul_manager_thread.h | 15 +- agent/src/beerocks/slave/son_slave_thread.cpp | 14 ++ 5 files changed, 117 insertions(+), 105 deletions(-) diff --git a/agent/src/beerocks/slave/agent_ucc_listener.cpp b/agent/src/beerocks/slave/agent_ucc_listener.cpp index 6e2ecff874..bda7b31f21 100644 --- a/agent/src/beerocks/slave/agent_ucc_listener.cpp +++ b/agent/src/beerocks/slave/agent_ucc_listener.cpp @@ -7,6 +7,7 @@ */ #include "agent_ucc_listener.h" +#include "agent_db.h" #include #include @@ -79,24 +80,6 @@ void agent_ucc_listener::clear_configuration() } } -/** - * @brief Update list of VAPs for ruid. - * - * @return None. - */ - -typedef struct { - std::string mac; - std::string ssid; - bool backhaul_vap; -} sVapElement; -void agent_ucc_listener::update_vaps_list(std::string ruid, beerocks_message::sVapsList &vaps) -{ - LOG(INFO) << "Update VAP map for ruid " << ruid << " bssid " << vaps.vaps->mac << " ssid " - << std::string(vaps.vaps->ssid, 36); - vaps_map[ruid] = vaps; -} - /** * @brief get parameter command * @@ -136,14 +119,16 @@ bool agent_ucc_listener::handle_dev_get_param(std::unordered_mapget_radio_by_mac(tlvf::mac_from_string(ruid), AgentDB::eMacType::RADIO); + if (!radio) { value = "ruid " + ruid + " not found"; return false; } - for (const auto &vap : it->second.vaps) { - if (std::string(vap.ssid) == ssid) { - value = tlvf::mac_to_string(vap.mac); + + for (const auto &bssid : radio->front.bssids) { + if (bssid.ssid == ssid) { + value = tlvf::mac_to_string(bssid.mac); return true; } } @@ -183,16 +168,16 @@ static enum eFreqType band_to_freq(const std::string &band) bool agent_ucc_listener::handle_start_wps_registration(const std::string &band, std::string &err_string) { - auto freq = band_to_freq(band); - auto radio_mac = m_backhaul_manager_ctx.freq_to_radio_mac(freq); - if (radio_mac.empty()) { + auto freq = band_to_freq(band); + auto radio_mac_str = m_backhaul_manager_ctx.freq_to_radio_mac(freq); + if (radio_mac_str.empty()) { err_string = "Failed to get radio for " + band; return false; } - LOG(DEBUG) << "Trigger WPS PBC on radio mac " << radio_mac; + LOG(DEBUG) << "Trigger WPS PBC on radio mac " << radio_mac_str; err_string = "Failed to start wps pbc"; - return m_backhaul_manager_ctx.start_wps_pbc(tlvf::mac_from_string(radio_mac)); + return m_backhaul_manager_ctx.start_wps_pbc(tlvf::mac_from_string(radio_mac_str)); } /** diff --git a/agent/src/beerocks/slave/agent_ucc_listener.h b/agent/src/beerocks/slave/agent_ucc_listener.h index 0f0e456c60..6de697dd8e 100644 --- a/agent/src/beerocks/slave/agent_ucc_listener.h +++ b/agent/src/beerocks/slave/agent_ucc_listener.h @@ -76,7 +76,6 @@ class agent_ucc_listener : public beerocks_ucc_listener { bool m_in_reset = false; bool m_reset_completed = false; std::string m_selected_backhaul; // "ETH" or "" - std::unordered_map vaps_map; std::mutex mutex; }; diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index e2efe36660..c232a10ed8 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -1060,16 +1060,6 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) if (elapsed_time_s >= ap_metrics_reporting_info.reporting_interval_s) { ap_metrics_reporting_info.last_reporting_time_point = now; - std::vector bssid_list; - for (const auto &socket : slaves_sockets) { - if (socket) { - for (int i = 0; i < beerocks::IFACE_TOTAL_VAPS; ++i) { - if (socket->vaps_list.vaps[i].mac != network_utils::ZERO_MAC) { - bssid_list.push_back(socket->vaps_list.vaps[i].mac); - } - } - } - } // We must generate a new MID for the periodic AP Metrics Response messages that // do not correspond to an AP Metrics Query message. // We cannot set MID to 0 here because we must also differentiate periodic @@ -1077,11 +1067,9 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) // due to channel utilization crossed configured threshold value. // As a temporary solution, set MID to UINT16_MAX here. // TODO: to be fixed as part of #1328 - if (!bssid_list.empty()) { - send_slave_ap_metric_query_message(UINT16_MAX, bssid_list); - } else { - LOG(DEBUG) << "Skipping AP_METRICS_QUERY for slave, empty BSSID list"; - } + + // Send ap_metrics query on all bssids exists on the Agent. + send_slave_ap_metric_query_message(UINT16_MAX); } } @@ -1149,7 +1137,7 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) } return (true); -} +} // namespace beerocks bool backhaul_manager::send_1905_topology_discovery_message() { @@ -1309,53 +1297,58 @@ bool backhaul_manager::send_autoconfig_search_message(const std::string &front_r tlvf::mac_to_string(db->bridge.mac)); } -bool backhaul_manager::send_slave_ap_metric_query_message(uint16_t mid, - const std::vector &bssid_list) +bool backhaul_manager::send_slave_ap_metric_query_message( + uint16_t mid, const std::unordered_set &bssid_list) { - bool ret = false; - for (auto socket : slaves_sockets) { - for (const auto &mac : bssid_list) { - int i = 0; - if (mac == socket->vaps_list.vaps[i].mac) { - LOG(DEBUG) << "Forwarding AP_METRICS_QUERY_MESSAGE message to son_slave, bssid: " - << std::hex << tlvf::mac_to_string(mac); - - auto forward = - cmdu_tx.create(mid, ieee1905_1::eMessageType::AP_METRICS_QUERY_MESSAGE); - if (!forward) { - LOG(ERROR) << "Failed to create AP_METRICS_QUERY_MESSAGE"; - return false; - } + auto db = AgentDB::get(); - auto query = cmdu_tx.addClass(); - if (!query) { - LOG(ERROR) << "Failed addClass"; - return false; - } + for (const auto &radio : db->get_radios_list()) { + if (!radio) { + continue; + } + for (const auto &bssid : radio->front.bssids) { + if (!bssid_list.empty() && bssid_list.find(bssid.mac) == bssid_list.end()) { + continue; + } + LOG(DEBUG) << "Forwarding AP_METRICS_QUERY_MESSAGE message to son_slave, bssid: " + << bssid.mac; - if (!query->alloc_bssid_list(1)) { - LOG(ERROR) << "Failed allocate memory for bssid_list"; - return false; - } + if (!cmdu_tx.create(mid, ieee1905_1::eMessageType::AP_METRICS_QUERY_MESSAGE)) { + LOG(ERROR) << "Failed to create AP_METRICS_QUERY_MESSAGE"; + return false; + } - auto list = query->bssid_list(0); - std::get<0>(list) = true; - std::get<1>(list) = mac; + auto query = cmdu_tx.addClass(); + if (!query) { + LOG(ERROR) << "Failed addClass"; + return false; + } - if (!message_com::send_cmdu(socket->slave, cmdu_tx)) { - LOG(ERROR) << "Failed forwarding AP_METRICS_QUERY_MESSAGE message to son_slave"; - ret = false; - continue; - } else { - ret = true; - // Fill a query vector - m_ap_metric_query.push_back({socket->slave, mac}); - } + if (!query->alloc_bssid_list(1)) { + LOG(ERROR) << "Failed to allocate memory for bssid_list"; + return false; } - i++; + + auto list = query->bssid_list(0); + if (!std::get<0>(list)) { + LOG(ERROR) << "Failed to get element of bssid_list"; + } + std::get<1>(list) = bssid.mac; + + auto radio_info = get_radio(radio->front.iface_mac); + if (!radio_info) { + LOG(ERROR) << "Failed to get radio info for " << radio->front.iface_mac; + return false; + } + + if (!message_com::send_cmdu(radio_info->slave, cmdu_tx)) { + LOG(ERROR) << "Failed forwarding AP_METRICS_QUERY_MESSAGE message to son_slave"; + } + + m_ap_metric_query.push_back({radio_info->slave, bssid.mac}); } } - return ret; + return true; } bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) @@ -2159,10 +2152,19 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr return false; } - soc->vaps_list = msg->params(); - if (m_agent_ucc_listener) { - m_agent_ucc_listener->update_vaps_list(tlvf::mac_to_string(soc->radio_mac), - msg->params()); + // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 + auto db = AgentDB::get(); + auto radio = db->radio(soc->hostap_iface); + if (!radio) { + LOG(DEBUG) << "Radio of iface " << soc->hostap_iface << " does not exist on the db"; + return false; + } + for (uint8_t vap_idx = 0; vap_idx < eBeeRocksIfaceIds::IFACE_TOTAL_VAPS; vap_idx++) { + radio->front.bssids[vap_idx].mac = msg->params().vaps[vap_idx].mac; + radio->front.bssids[vap_idx].ssid = msg->params().vaps[vap_idx].ssid; + radio->front.bssids[vap_idx].type = msg->params().vaps[vap_idx].backhaul_vap + ? AgentDB::sRadio::sFront::sBssid::eType::bAP + : AgentDB::sRadio::sFront::sBssid::eType::fAP; } break; } @@ -2675,25 +2677,26 @@ bool backhaul_manager::handle_ap_capability_query(ieee1905_1::CmduMessageRx &cmd bool backhaul_manager::handle_ap_metrics_query(ieee1905_1::CmduMessageRx &cmdu_rx, const std::string &src_mac) { - std::vector bssid; const auto mid = cmdu_rx.getMessageId(); auto ap_metric_query_tlv = cmdu_rx.getClass(); if (!ap_metric_query_tlv) { LOG(ERROR) << "AP Metrics Query CMDU mid=" << mid << " does not have AP Metric Query TLV"; return false; } + + std::unordered_set bssids; for (size_t bssid_idx = 0; bssid_idx < ap_metric_query_tlv->bssid_list_length(); bssid_idx++) { auto bssid_tuple = ap_metric_query_tlv->bssid_list(bssid_idx); if (!std::get<0>(bssid_tuple)) { LOG(ERROR) << "Failed to get bssid " << bssid_idx << " from AP_METRICS_QUERY"; return false; } - bssid.push_back(std::get<1>(bssid_tuple)); + bssids.insert(std::get<1>(bssid_tuple)); LOG(DEBUG) << "Received AP_METRICS_QUERY_MESSAGE, mid=" << std::hex << int(mid) << " bssid " << std::get<1>(bssid_tuple); } - if (!send_slave_ap_metric_query_message(mid, bssid)) { + if (!send_slave_ap_metric_query_message(mid, bssids)) { LOG(ERROR) << "Failed to forward AP_METRICS_RESPONSE to the son_slave_thread"; return false; } @@ -3139,22 +3142,24 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd return false; } - for (const auto &slave : slaves_sockets) { - // TODO skip slaves that are not operational - auto vaps_list = slave->vaps_list; + for (const auto &radio : db->get_radios_list()) { + if (!radio) { + continue; + } auto radio_list = tlvApOperationalBSS->create_radio_list(); - radio_list->radio_uid() = slave->radio_mac; - for (const auto &vap : vaps_list.vaps) { - if (vap.mac == network_utils::ZERO_MAC) + radio_list->radio_uid() = radio->front.iface_mac; + for (const auto &bssid : radio->front.bssids) { + if (bssid.mac == network_utils::ZERO_MAC) { continue; - if (vap.ssid[0] == '\0') + } + if (bssid.ssid.empty()) { continue; + } auto radio_bss_list = radio_list->create_radio_bss_list(); - radio_bss_list->radio_bssid() = vap.mac; - auto ssid = - std::string(vap.ssid, strnlen(vap.ssid, beerocks::message::WIFI_SSID_MAX_LENGTH)); - radio_bss_list->set_ssid(ssid); + radio_bss_list->radio_bssid() = bssid.mac; + radio_bss_list->set_ssid(bssid.ssid); + radio_list->add_radio_bss_list(radio_bss_list); } tlvApOperationalBSS->add_radio_list(radio_list); diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 8f7f2c560c..b92c179e44 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -105,7 +105,17 @@ class backhaul_manager : public btl::transport_socket_thread { */ bool send_1905_topology_discovery_message(const std::string &iface_name); - bool send_slave_ap_metric_query_message(uint16_t mid, std::vector const &bssid_list); + /** + * @brief Sends an AP Metrics Query message for each bssid on 'bssid_list' to the son_slaves. + * If the 'bssid_list' is empty, sends a query on each bssid that exists on the Agent. + * + * @param mid MID of the message to be sent. + * @param bssid_list List of bssids to send a query on. + * @return true on success, otherwise false. + */ + bool send_slave_ap_metric_query_message( + uint16_t mid, + const std::unordered_set &bssid_list = std::unordered_set()); /** * @brief Creates Backhaul STA Steering Response message with 2 tlvs Steering Response @@ -369,8 +379,7 @@ class backhaul_manager : public btl::transport_socket_thread { uint32_t vht_capability = 0; /**< VHT capabilities */ std::array vht_mcs_set; /**< 32-byte attribute containing the MCS set as defined in 802.11ac */ - bool he_supported = false; /**< Is HE supported flag */ - beerocks_message::sVapsList vaps_list; /**< List of VAPs in radio. */ + bool he_supported = false; /**< Is HE supported flag */ std::array preferred_channels; /**< Array of supported channels in radio. */ std::unordered_map diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 154b735121..ce81538875 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -1815,6 +1815,20 @@ bool slave_thread::handle_cmdu_ap_manager_message(Socket *sd, LOG(INFO) << "received ACTION_APMANAGER_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION"; + auto db = AgentDB::get(); + auto radio = db->radio(m_fronthaul_iface); + if (!radio) { + LOG(DEBUG) << "Radio of iface " << m_fronthaul_iface << " does not exist on the db"; + return false; + } + for (uint8_t vap_idx = 0; vap_idx < eBeeRocksIfaceIds::IFACE_TOTAL_VAPS; vap_idx++) { + radio->front.bssids[vap_idx].mac = notification_in->params().vaps[vap_idx].mac; + radio->front.bssids[vap_idx].ssid = notification_in->params().vaps[vap_idx].ssid; + radio->front.bssids[vap_idx].type = notification_in->params().vaps[vap_idx].backhaul_vap + ? AgentDB::sRadio::sFront::sBssid::eType::bAP + : AgentDB::sRadio::sFront::sBssid::eType::fAP; + } + auto notification_out = message_com::create_vs_message< beerocks_message::cACTION_CONTROL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION>(cmdu_tx); if (notification_out == nullptr) { From d228d1b5f0a74b7ccf83cda6fb31cd51a2f3e2b3 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 8 Jul 2020 11:14:12 +0000 Subject: [PATCH 289/453] agent: Use associated_clients list from AgentDB Replace the use of the backhaul manager's local associated_clients data member to the list on the AgentDB. Functions and Backhual Manager data members that are no longer being used were removed. PPM-216 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 306 ++++++++---------- .../backhaul_manager_thread.h | 50 --- 2 files changed, 131 insertions(+), 225 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index c232a10ed8..11c448e201 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -2169,35 +2169,35 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr break; } case beerocks_message::ACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION: { - LOG(DEBUG) << "ACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION received from iface " - << soc->hostap_iface; + LOG(DEBUG) << "ACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION"; auto msg = beerocks_header ->addClass(); if (!msg) { LOG(ERROR) << "Failed building ACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION message!"; - return false; + break; } - // Set client association information for associated client - //remove this client from other radios - remove_client_from_all_radios(msg->client_mac()); + // Remove this client from other radios. + auto db = AgentDB::get(); + db->erase_client(msg->client_mac()); - auto &associated_clients = soc->associated_clients_map[msg->bssid()]; + // Set client association information for associated client + auto radio = db->get_radio_by_mac(msg->bssid(), AgentDB::eMacType::BSSID); + if (!radio) { + LOG(DEBUG) << "Radio containing bssid " << msg->bssid() << " not found"; + break; + } - sClientInfo client_info; - client_info.client_mac = msg->client_mac(); - client_info.bssid = msg->bssid(); - client_info.time_stamp = std::chrono::steady_clock::now(); - client_info.asso_len = msg->association_frame_length(); - memcpy(client_info.assoc_req, msg->association_frame(), client_info.asso_len); - associated_clients[msg->client_mac()] = client_info; + radio->associated_clients.emplace(msg->client_mac(), + AgentDB::sRadio::sClient{msg->bssid(), + msg->association_frame_length(), + msg->association_frame()}); break; } case beerocks_message::ACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION: { - LOG(DEBUG) << "ACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION received from iface " - << soc->hostap_iface; + LOG(DEBUG) << "ACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION"; auto msg = beerocks_header ->addClass(); @@ -2207,12 +2207,9 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr return false; } - // If exists, remove client association information for disconnected client - auto &associated_clients = soc->associated_clients_map[msg->bssid()]; - auto it = associated_clients.find(msg->client_mac()); - if (it != associated_clients.end()) { - it = associated_clients.erase(it); - } + // If exists, remove client association information for disconnected client. + auto db = AgentDB::get(); + db->erase_client(msg->client_mac(), msg->bssid()); break; } case beerocks_message::ACTION_BACKHAUL_ASSOCIATED_STA_LINK_METRICS_RESPONSE: { @@ -2241,18 +2238,23 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr response_out->sta_mac() = response_in->sta_mac(); + auto db = AgentDB::get(); + for (size_t i = 0; i < response_out->bssid_info_list_length(); ++i) { auto &bss_in = std::get<1>(response_in->bssid_info_list(i)); auto &bss_out = std::get<1>(response_out->bssid_info_list(i)); - auto mac = response_out->sta_mac(); - auto radio = get_sta_radio(mac); + auto &client_mac = response_out->sta_mac(); + + auto radio = db->get_radio_by_mac(client_mac, AgentDB::eMacType::CLIENT); if (!radio) { - LOG(ERROR) << "radio for mac " << mac << " is null"; + LOG(ERROR) << "radio for client mac " << client_mac << " not found"; return false; } - bss_out.bssid = get_sta_bssid(radio->associated_clients_map, mac); + // If get_radio_by_mac() found the radio, it means that 'client_mac' is on the radio + // 'associated_clients' list. + bss_out.bssid = radio->associated_clients.at(client_mac).bssid; if (bss_out.bssid == network_utils::ZERO_MAC) { LOG(ERROR) << "bssid is ZERO_MAC"; return false; @@ -2266,7 +2268,6 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr bss_out.sta_measured_uplink_rssi_dbm_enc = bss_in.sta_measured_uplink_rssi_dbm_enc; } - auto db = AgentDB::get(); LOG(DEBUG) << "Send AssociatedStaLinkMetrics to controller, mid = " << mid; send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, tlvf::mac_to_string(db->bridge.mac)); break; @@ -2376,19 +2377,6 @@ bool backhaul_manager::handle_slave_1905_1_message(ieee1905_1::CmduMessageRx &cm } } -sMacAddr backhaul_manager::get_sta_bssid( - const std::unordered_map &clients_map, const sMacAddr &sta_mac) -{ - sMacAddr bssid = network_utils::ZERO_MAC; - std::for_each(clients_map.begin(), clients_map.end(), - [&sta_mac, &bssid](std::pair vap) { - if (vap.second.find(sta_mac) != vap.second.end()) { - bssid = vap.first; - } - }); - return bssid; -} - std::shared_ptr backhaul_manager::get_radio(const sMacAddr &radio_mac) const { @@ -2399,16 +2387,6 @@ backhaul_manager::get_radio(const sMacAddr &radio_mac) const return it != slaves_sockets.end() ? *it : nullptr; } -std::shared_ptr -backhaul_manager::get_sta_radio(const sMacAddr &sta_mac) -{ - auto radio = std::find_if( - slaves_sockets.begin(), slaves_sockets.end(), [&sta_mac](std::shared_ptr r) { - return get_sta_bssid(r->associated_clients_map, sta_mac) != network_utils::ZERO_MAC; - }); - return radio != slaves_sockets.end() ? *radio : nullptr; -} - bool backhaul_manager::handle_multi_ap_policy_config_request(ieee1905_1::CmduMessageRx &cmdu_rx, const std::string &src_mac) { @@ -2508,7 +2486,7 @@ bool backhaul_manager::handle_associated_sta_link_metrics_query(ieee1905_1::Cmdu // Check if it is an error scenario - if the STA specified in the STA link Query message is not associated // with any of the BSS operated by the Multi-AP Agent - std::shared_ptr radio = get_sta_radio(mac->sta_mac()); + auto radio = db->get_radio_by_mac(mac->sta_mac(), AgentDB::eMacType::CLIENT); if (!radio) { LOG(ERROR) << "client with mac address " << mac->sta_mac() << " not found"; //Add an Error Code TLV @@ -2523,27 +2501,36 @@ bool backhaul_manager::handle_associated_sta_link_metrics_query(ieee1905_1::Cmdu LOG(DEBUG) << "Send a ASSOCIATED_STA_LINK_METRICS_RESPONSE_MESSAGE back to controller"; return send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); - } else { - sMacAddr bssid = get_sta_bssid(radio->associated_clients_map, mac->sta_mac()); - if (bssid == network_utils::ZERO_MAC) { - LOG(ERROR) << "Cannot find sta bssid"; - return false; - } - LOG(DEBUG) << "client with mac address " << mac->sta_mac() << " connected to " << bssid; + } + auto client_it = radio->associated_clients.find(mac->sta_mac()); + if (client_it == radio->associated_clients.end()) { + LOG(ERROR) << "Cannot find sta sta " << mac->sta_mac(); + return false; + } + if (client_it->second.bssid == network_utils::ZERO_MAC) { + LOG(ERROR) << "Cannot find sta bssid"; + return false; + } + LOG(DEBUG) << "Client with mac address " << mac->sta_mac() << " connected to " + << client_it->second.bssid; - auto request_out = message_com::create_vs_message< - beerocks_message::cACTION_BACKHAUL_ASSOCIATED_STA_LINK_METRICS_REQUEST>(cmdu_tx, mid); + auto request_out = message_com::create_vs_message< + beerocks_message::cACTION_BACKHAUL_ASSOCIATED_STA_LINK_METRICS_REQUEST>(cmdu_tx, mid); - if (!request_out) { - LOG(ERROR) << "Failed to build ACTION_BACKHAUL_ASSOCIATED_STA_LINK_METRICS_REQUEST"; - return false; - } + if (!request_out) { + LOG(ERROR) << "Failed to build ACTION_BACKHAUL_ASSOCIATED_STA_LINK_METRICS_REQUEST"; + return false; + } - request_out->sync() = true; - request_out->sta_mac() = mac->sta_mac(); + request_out->sync() = true; + request_out->sta_mac() = mac->sta_mac(); - return message_com::send_cmdu(radio->slave, cmdu_tx); + auto radio_info = get_radio(radio->front.iface_mac); + if (!radio_info) { + LOG(ERROR) << "Failed to get radio info for " << radio->front.iface_mac; + return false; } + return message_com::send_cmdu(radio_info->slave, cmdu_tx); } bool backhaul_manager::handle_client_capability_query(ieee1905_1::CmduMessageRx &cmdu_rx, @@ -2558,25 +2545,6 @@ bool backhaul_manager::handle_client_capability_query(ieee1905_1::CmduMessageRx return false; } - auto db = AgentDB::get(); - - //Check if it is an error scenario - if the STA specified in the Client Capability Query message is not associated - //with any of the BSS operated by the Multi-AP Agent [ though the TLV does contain a BSSID, the specification - // says that we should answer if the client is associated with any BSS on this agent.] - bool associated_client_found = false; - sClientInfo client_info; - for (const auto &slave : slaves_sockets) { - auto associated_clients_map = slave->associated_clients_map; - for (const auto &vap : associated_clients_map) { - auto it = vap.second.find(client_info_tlv_r->client_mac()); - if (it != vap.second.end()) { - associated_client_found = true; - client_info = it->second; - break; - } - } - } - // send CLIENT_CAPABILITY_REPORT_MESSAGE back to the controller if (!cmdu_tx.create(mid, ieee1905_1::eMessageType::CLIENT_CAPABILITY_REPORT_MESSAGE)) { LOG(ERROR) << "cmdu creation of type CLIENT_CAPABILITY_REPORT_MESSAGE, has failed"; @@ -2597,16 +2565,17 @@ bool backhaul_manager::handle_client_capability_query(ieee1905_1::CmduMessageRx return false; } - // if it is an error scenario, set Success status to 0x01 = Failure and do nothing after it. - if (associated_client_found) { - client_capability_report_tlv->result_code() = wfa_map::tlvClientCapabilityReport::SUCCESS; - LOG(DEBUG) << "Result Code: SUCCESS"; - // Add frame body of the most recently received (Re)Association Request frame from this client + auto db = AgentDB::get(); - client_capability_report_tlv->set_association_frame(client_info.assoc_req, - client_info.asso_len); + // Check if it is an error scenario - if the STA specified in the Client Capability Query + // message is not associated with any of the BSS operated by the Multi-AP Agent [ though the + // TLV does contain a BSSID, the specification says that we should answer if the client is + // associated with any BSS on this agent.] + auto radio = db->get_radio_by_mac(client_info_tlv_r->client_mac(), AgentDB::eMacType::CLIENT); + if (!radio) { + LOG(ERROR) << "radio for client mac " << client_info_tlv_r->client_mac() << " not found"; - } else { + // If it is an error scenario, set Success status to 0x01 = Failure and do nothing after it. client_capability_report_tlv->result_code() = wfa_map::tlvClientCapabilityReport::FAILURE; LOG(DEBUG) << "Result Code: FAILURE"; @@ -2621,7 +2590,17 @@ bool backhaul_manager::handle_client_capability_query(ieee1905_1::CmduMessageRx error_code_tlv->reason_code() = wfa_map::tlvErrorCode::STA_NOT_ASSOCIATED_WITH_ANY_BSS_OPERATED_BY_THE_AGENT; error_code_tlv->sta_mac() = client_info_tlv_r->client_mac(); + return send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); } + + client_capability_report_tlv->result_code() = wfa_map::tlvClientCapabilityReport::SUCCESS; + LOG(DEBUG) << "Result Code: SUCCESS"; + + // Add frame body of the most recently received (Re)Association Request frame from this client. + auto &client_info = radio->associated_clients.at(client_info_tlv_r->client_mac()); + client_capability_report_tlv->set_association_frame(client_info.association_frame.data(), + client_info.association_frame_length); + LOG(DEBUG) << "Send a CLIENT_CAPABILITY_REPORT_MESSAGE back to controller"; return send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); } @@ -3168,26 +3147,21 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd // The Multi-AP Agent shall include an Associated Clients TLV in the message if there is at // least one 802.11 client directly associated with any of the BSS(s) that is operated by the // Multi-AP Agent - bool shall_include_associated_clients_tlv = false; - for (auto slave : slaves_sockets) { - auto associated_clients_map = slave->associated_clients_map; - for (const auto &associated_clients_entry : associated_clients_map) { - auto associated_clients = associated_clients_entry.second; - if (associated_clients.size() > 0) { - shall_include_associated_clients_tlv = true; - break; - } + bool include_associated_clients_tlv = false; + for (const auto &radio : db->get_radios_list()) { + if (!radio) { + continue; } - if (shall_include_associated_clients_tlv) { + if (radio->associated_clients.size() > 0) { + include_associated_clients_tlv = true; break; } } - if (shall_include_associated_clients_tlv) { + if (include_associated_clients_tlv) { auto tlvAssociatedClients = cmdu_tx.addClass(); if (!tlvAssociatedClients) { - LOG(ERROR) << "addClass wfa_map::tlvAssociatedClients failed, mid=" << std::hex - << (int)mid; + LOG(ERROR) << "addClass wfa_map::tlvAssociatedClients failed, mid=" << std::hex << mid; return false; } @@ -3195,42 +3169,36 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd auto now = std::chrono::steady_clock::now(); // Fill in Associated Clients TLV - for (auto slave : slaves_sockets) { - auto associated_clients_map = slave->associated_clients_map; - - // Associated clients map contains sets of associated clients grouped by BSSID - for (const auto &associated_clients_entry : associated_clients_map) { - auto bssid = associated_clients_entry.first; - auto associated_clients = associated_clients_entry.second; - - if (associated_clients.size() > 0) { - auto bss_list = tlvAssociatedClients->create_bss_list(); - - bss_list->bssid() = bssid; - - // Information for each associated client includes its MAC address and - // the timestamp of its last association. - for (const auto &associated_client : associated_clients) { - auto client_mac = associated_client.first; - auto association_time = associated_client.second.time_stamp; - - auto elapsed = - std::chrono::duration_cast(now - association_time) - .count(); - if ((elapsed < 0) || (elapsed > UINT16_MAX)) { - elapsed = UINT16_MAX; - } + for (const auto &radio : db->get_radios_list()) { + if (!radio) { + continue; + } - auto client = bss_list->create_clients_associated_list(); + for (const auto &bssid : radio->front.bssids) { + auto bss_list = tlvAssociatedClients->create_bss_list(); + bss_list->bssid() = bssid.mac; - client->mac() = client_mac; - client->time_since_last_association_sec() = elapsed; + for (const auto &associated_client_entry : radio->associated_clients) { + if (associated_client_entry.second.bssid != bssid.mac) { + continue; + } + + auto client_info = bss_list->create_clients_associated_list(); - bss_list->add_clients_associated_list(client); + auto &association_time = associated_client_entry.second.association_time; + auto elapsed = + std::chrono::duration_cast(now - association_time) + .count(); + if ((elapsed < 0) || (elapsed > UINT16_MAX)) { + elapsed = UINT16_MAX; } - tlvAssociatedClients->add_bss_list(bss_list); + client_info->mac() = associated_client_entry.first; + client_info->time_since_last_association_sec() = elapsed; + + bss_list->add_clients_associated_list(client_info); } + tlvAssociatedClients->add_bss_list(bss_list); } } } @@ -3639,8 +3607,6 @@ bool backhaul_manager::handle_1905_beacon_metrics_query(ieee1905_1::CmduMessageR const sMacAddr &requested_sta_mac = tlvBeaconMetricsQuery->associated_sta_mac(); LOG(DEBUG) << "the requested STA mac is: " << requested_sta_mac; - const auto radio = get_sta_radio(requested_sta_mac); - // build ACK message CMDU const auto mid = cmdu_rx.getMessageId(); auto cmdu_tx_header = cmdu_tx.create(mid, ieee1905_1::eMessageType::ACK_MESSAGE); @@ -3649,8 +3615,8 @@ bool backhaul_manager::handle_1905_beacon_metrics_query(ieee1905_1::CmduMessageR return false; } - auto db = AgentDB::get(); - + auto db = AgentDB::get(); + auto radio = db->get_radio_by_mac(requested_sta_mac, AgentDB::eMacType::CLIENT); if (!radio) { LOG(DEBUG) << "STA with MAC [" << requested_sta_mac << "] is not associated with any BSS operated by the agent"; @@ -3683,9 +3649,14 @@ bool backhaul_manager::handle_1905_beacon_metrics_query(ieee1905_1::CmduMessageR return send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); } - forward_to = radio->slave; + auto radio_info = get_radio(radio->front.iface_mac); + if (!radio_info) { + LOG(ERROR) << "Failed to get radio info for " << radio->front.iface_mac; + return false; + } + forward_to = radio_info->slave; - LOG(DEBUG) << "found the radio that has the sation. radio: " << radio->radio_mac + LOG(DEBUG) << "Found the radio that has the sation. radio: " << radio->front.iface_mac << "; station: " << requested_sta_mac; LOG(DEBUG) << "BEACON METRICS QUERY: sending ACK message to the originator mid: " @@ -3724,21 +3695,6 @@ bool backhaul_manager::send_slaves_enable() return true; } -void backhaul_manager::remove_client_from_all_radios(sMacAddr &client_mac) -{ - for (const auto &slave : slaves_sockets) { - auto &associated_clients_map = slave->associated_clients_map; - for (auto &clientmap : associated_clients_map) { - auto it = clientmap.second.find(client_mac); - if (it != clientmap.second.end()) { - LOG(DEBUG) << "Removing client " << client_mac << " from radio " - << slave->hostap_iface; - clientmap.second.erase(it); - } - } - } -} - bool backhaul_manager::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t event_ptr, std::string iface) { @@ -4366,11 +4322,13 @@ bool backhaul_manager::get_neighbor_links( } // Also include a link for each associated client - for (const auto &slave : slaves_sockets) { + for (const auto radio : db->get_radios_list()) { + if (!radio) { + continue; + } - for (const auto &associated_clients_entry : slave->associated_clients_map) { - auto bssid = associated_clients_entry.first; - auto associated_clients = associated_clients_entry.second; + for (const auto &associated_client : radio->associated_clients) { + auto &bssid = associated_client.second.bssid; sLinkInterface interface; if (!get_iface_name(bssid, interface.iface_name)) { @@ -4378,9 +4336,9 @@ bool backhaul_manager::get_neighbor_links( return false; } - interface.iface_mac = bssid; - interface.media_type = - beerocks::get_802_11_media_type(slave->freq_type, slave->max_bandwidth); + interface.iface_mac = bssid; + interface.media_type = beerocks::get_802_11_media_type(radio->front.freq_type, + radio->front.max_supported_bw); if (ieee1905_1::eMediaType::UNKNOWN_MEDIA == interface.media_type) { LOG(ERROR) << "Unknown media type for interface " << interface.iface_name; @@ -4390,17 +4348,15 @@ bool backhaul_manager::get_neighbor_links( LOG(TRACE) << "Getting neighbors connected to interface " << interface.iface_name << " with BSSID " << bssid; - for (const auto &associated_client : associated_clients) { - // TODO: This is not correct... We actually have to get this from the topology - // discovery message, which will give us the neighbor interface and AL MAC addresses. - sLinkNeighbor neighbor; - neighbor.iface_mac = associated_client.first; - neighbor.al_mac = neighbor.iface_mac; + // TODO: This is not correct... We actually have to get this from the topology + // discovery message, which will give us the neighbor interface and AL MAC addresses. + sLinkNeighbor neighbor; + neighbor.iface_mac = associated_client.first; + neighbor.al_mac = neighbor.iface_mac; - if ((neighbor_mac_filter == network_utils::ZERO_MAC) || - (neighbor_mac_filter == neighbor.al_mac)) { - neighbor_links_map[interface].push_back(neighbor); - } + if ((neighbor_mac_filter == network_utils::ZERO_MAC) || + (neighbor_mac_filter == neighbor.al_mac)) { + neighbor_links_map[interface].push_back(neighbor); } } } diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index b92c179e44..a62f93318c 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -175,8 +175,6 @@ class backhaul_manager : public btl::transport_socket_thread { void platform_notify_error(bpl::eErrorCode code, const std::string &error_data); bool send_slaves_enable(); - void remove_client_from_all_radios(sMacAddr &client_mac); - std::shared_ptr get_wireless_hal(std::string iface = ""); private: @@ -311,44 +309,6 @@ class backhaul_manager : public btl::transport_socket_thread { */ sApMetricsReportingInfo ap_metrics_reporting_info; - struct sClientInfo { - sMacAddr client_mac; - sMacAddr bssid; // VAP mac - std::chrono::steady_clock::time_point time_stamp; - size_t asso_len; - uint8_t assoc_req[ASSOCIATION_FRAME_SIZE]; - }; - - /** - * @brief Type definition for associated clients information. - * - * Associated client information consists of sClientInfo strucrt, which has the - * following fields: - * - The MAC address of the 802.11 client that associates to a BSS. - * - Timestamp of the 802.11 client's last association to this Multi-AP device. - * - The length of the association frame. - * - the association frame itself. - * - * Associated client information is gathered from - * ACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION events received from slave threads. - * - * Associated client information is later used to fill in the Associated Clients TLV - * in the Topology Response message and Client Capability Response message. - */ - - typedef std::unordered_map associated_clients_t; - - /** - * @brief Gets BSSID to which STA with given MAC is connected - * - * @param[in] clients_map Associated client map to seach - * @param[in] sta_mac MAC address of the STA - * @return BSSID in case of success or network_utils::ZERO_MAC otherwise - */ - static sMacAddr - get_sta_bssid(const std::unordered_map &clients_map, - const sMacAddr &sta_mac); - /** * @brief Information gathered about a radio (= slave). * @@ -382,8 +342,6 @@ class backhaul_manager : public btl::transport_socket_thread { bool he_supported = false; /**< Is HE supported flag */ std::array preferred_channels; /**< Array of supported channels in radio. */ - std::unordered_map - associated_clients_map; /**< Associated clients grouped by BSSID. */ }; /** @@ -394,14 +352,6 @@ class backhaul_manager : public btl::transport_socket_thread { */ std::shared_ptr get_radio(const sMacAddr &radio_mac) const; - /** - * @brief Gets radio info for the STA with given MAC address - * - * @param[in] sta_mac MAC address of the STA - * @return shared pointer to radio info in case of success or nullptr otherwise - */ - std::shared_ptr get_sta_radio(const sMacAddr &sta_mac); - /** * @brief Interface in this device which connects to an interface in one or more neighbors. * From 4018de62adab03d3b65d9386f22f6da4d937c894 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 8 Jul 2020 18:25:26 +0000 Subject: [PATCH 290/453] agent: Use neighbor_devices list from AgentDB Replace the use of the backhaul manager's local 1905_neighbor_devices data member to the list on the AgentDB. PPM-216 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 113 +++++++++--------- .../backhaul_manager_thread.h | 27 ----- 2 files changed, 58 insertions(+), 82 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 11c448e201..f28cfbdc82 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -524,17 +524,20 @@ void backhaul_manager::after_select(bool timeout) // 60 seconds a Topology Discovery message from it. If not, remove this neighbor from our list // and send a Topology Notification message. bool neighbors_list_changed = false; - for (auto it = m_1905_neighbor_devices.begin(); it != m_1905_neighbor_devices.end();) { - const auto &last_topology_discovery = it->second.timestamp; - if (last_topology_discovery + std::chrono::seconds(DISCOVERY_NEIGHBOUR_REMOVAL_TIMEOUT) < - std::chrono::steady_clock::now()) { - const auto &device_al_mac = it->first; - LOG(INFO) << "Removed 1905.1 device " << device_al_mac << " from neighbors list"; - it = m_1905_neighbor_devices.erase(it); - neighbors_list_changed = true; - continue; + for (auto &neighbors_on_local_iface_entry : db->neighbor_devices) { + auto &neighbors_on_local_iface = neighbors_on_local_iface_entry.second; + for (auto it = neighbors_on_local_iface.begin(); it != neighbors_on_local_iface.end();) { + auto &last_topology_discovery = it->second.timestamp; + if (now - last_topology_discovery > + std::chrono::seconds(DISCOVERY_NEIGHBOUR_REMOVAL_TIMEOUT)) { + auto &device_al_mac = it->first; + LOG(INFO) << "Removed 1905.1 device " << device_al_mac << " from neighbors list"; + it = neighbors_on_local_iface.erase(it); + neighbors_list_changed = true; + continue; + } + it++; } - it++; } if (neighbors_list_changed) { @@ -3028,27 +3031,7 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd * a map which key is the name of the local interface and the value is the list of neighbor * devices inferred from that interface. */ - std::unordered_map> neighbor_devices_by_local_iface; - for (const auto &entry : m_1905_neighbor_devices) { - const auto &neighbor_device = entry.second; - auto &neighbor_devices = neighbor_devices_by_local_iface[neighbor_device.if_name]; - - neighbor_devices.emplace_back(neighbor_device); - } - - /** - * Second, create a tlv1905NeighborDevice for every local interface on which a 1905 neighbor - * is visible, and then add the list of neighbors visible on that interface - */ - for (const auto &entry : neighbor_devices_by_local_iface) { - const auto &iface_name = entry.first; - const auto &neighbor_devices = entry.second; - - sMacAddr iface_mac; - if (!get_iface_mac(iface_name, iface_mac)) { - return false; - } - + for (auto &neighbors_on_local_iface_entry : db->neighbor_devices) { auto tlv1905NeighborDevice = cmdu_tx.addClass(); if (!tlv1905NeighborDevice) { LOG(ERROR) << "addClass ieee1905_1::tlv1905NeighborDevice failed, mid=" << std::hex @@ -3056,15 +3039,18 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd return false; } - tlv1905NeighborDevice->mac_local_iface() = iface_mac; + tlv1905NeighborDevice->mac_local_iface() = neighbors_on_local_iface_entry.first; + auto &neighbors_on_local_iface = neighbors_on_local_iface_entry.second; - if (!tlv1905NeighborDevice->alloc_mac_al_1905_device(neighbor_devices.size())) { + if (!tlv1905NeighborDevice->alloc_mac_al_1905_device(neighbors_on_local_iface.size())) { LOG(ERROR) << "alloc_mac_al_1905_device() has failed"; - return true; + return false; } size_t index = 0; - for (const auto &neighbor_device : neighbor_devices) { + for (const auto &neighbor_on_local_iface_entry : neighbors_on_local_iface) { + auto &neighbor_al_mac = neighbor_on_local_iface_entry.first; + auto mac_al_1905_device_tuple = tlv1905NeighborDevice->mac_al_1905_device(index); if (!std::get<0>(mac_al_1905_device_tuple)) { LOG(ERROR) << "getting mac_al_1905_device element has failed"; @@ -3072,7 +3058,7 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd } auto &mac_al_1905_device = std::get<1>(mac_al_1905_device_tuple); - mac_al_1905_device.mac = neighbor_device.al_mac; + mac_al_1905_device.mac = neighbor_al_mac; mac_al_1905_device.bridges_exist = ieee1905_1::tlv1905NeighborDevice::eBridgesExist::AT_LEAST_ONE_BRIDGES_EXIST; index++; @@ -3434,7 +3420,7 @@ bool backhaul_manager::handle_1905_topology_discovery(const std::string &src_mac auto mid = cmdu_rx.getMessageId(); LOG(INFO) << "Received TOPOLOGY_DISCOVERY_MESSAGE from AL MAC=" << tlvAlMac->mac() - << ", mid=" << std::hex << int(mid); + << ", mid=" << std::hex << mid; auto tlvMac = cmdu_rx.getClass(); if (!tlvMac) { @@ -3442,24 +3428,38 @@ bool backhaul_manager::handle_1905_topology_discovery(const std::string &src_mac return false; } - uint32_t if_index = message_com::get_uds_header(cmdu_rx)->if_index; - std::string if_name = network_utils::linux_get_iface_name(if_index); - if (if_name.empty()) { + uint32_t if_index = message_com::get_uds_header(cmdu_rx)->if_index; + std::string local_receiving_iface_name = network_utils::linux_get_iface_name(if_index); + if (local_receiving_iface_name.empty()) { LOG(ERROR) << "Failed getting interface name for index: " << if_index; return false; } - auto new_device = - m_1905_neighbor_devices.find(tlvAlMac->mac()) == m_1905_neighbor_devices.end(); + std::string local_receiving_iface_mac_str; + if (!network_utils::linux_iface_get_mac(local_receiving_iface_name, + local_receiving_iface_mac_str)) { + LOG(ERROR) << "Failed getting MAC address for interface: " << local_receiving_iface_name; + return false; + } + + // Check if it is a new device so if it does, we will send Topology Notification. + bool new_device = false; + for (auto &neighbors_on_local_iface_entry : db->neighbor_devices) { + auto &neighbors_on_local_iface = neighbors_on_local_iface_entry.second; + new_device = + neighbors_on_local_iface.find(tlvAlMac->mac()) == neighbors_on_local_iface.end(); + if (new_device) { + break; + } + } // Add/Update the device on our list. - sNeighborDevice neighbor_device; - neighbor_device.al_mac = tlvAlMac->mac(); - neighbor_device.mac = tlvMac->mac(); - neighbor_device.if_name = if_name; - neighbor_device.timestamp = std::chrono::steady_clock::now(); + auto &neighbor_devices_by_al_mac = + db->neighbor_devices[tlvf::mac_from_string(local_receiving_iface_mac_str)]; - m_1905_neighbor_devices[tlvAlMac->mac()] = neighbor_device; + // Update an exist neighbor. + neighbor_devices_by_al_mac[tlvAlMac->mac()].transmitting_iface_mac = tlvMac->mac(); + neighbor_devices_by_al_mac[tlvAlMac->mac()].timestamp = std::chrono::steady_clock::now(); // If it is a new device, then our 1905.1 neighbors list has changed and we are required to send // Topology Notification Message. @@ -4311,13 +4311,16 @@ bool backhaul_manager::get_neighbor_links( return false; } - for (const auto &entry : m_1905_neighbor_devices) { - sLinkNeighbor neighbor; - neighbor.al_mac = entry.first; - neighbor.iface_mac = neighbor.al_mac; - if ((neighbor_mac_filter == network_utils::ZERO_MAC) || - (neighbor_mac_filter == neighbor.al_mac)) { - neighbor_links_map[wired_interface].push_back(neighbor); + for (const auto &neighbors_on_local_iface : db->neighbor_devices) { + auto &neighbors = neighbors_on_local_iface.second; + for (const auto &neighbor_entry : neighbors) { + sLinkNeighbor neighbor; + neighbor.al_mac = neighbor_entry.first; + neighbor.iface_mac = neighbor_entry.second.transmitting_iface_mac; + if ((neighbor_mac_filter == network_utils::ZERO_MAC) || + (neighbor_mac_filter == neighbor.al_mac)) { + neighbor_links_map[wired_interface].push_back(neighbor); + } } } diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index a62f93318c..814ad53e85 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -428,33 +428,6 @@ class backhaul_manager : public btl::transport_socket_thread { get_neighbor_links(const sMacAddr &neighbor_mac_filter, std::map> &neighbor_links_map); - /** - * @brief 1905.1 Neighbor device information - * - * Information gathered from a neighbor device upon reception of a Topology Discovery message. - */ - struct sNeighborDevice { - sMacAddr al_mac = beerocks::net::network_utils:: - ZERO_MAC; /**< 1905.1 AL MAC address of the Topology Discovery message transmitting device. */ - sMacAddr mac = beerocks::net::network_utils:: - ZERO_MAC; /**< MAC address of the interface on which the Topology Discovery message is transmitted. */ - std::string - if_name; /**< Name of the network interface the Topology Discovery message was received on */ - std::chrono::steady_clock::time_point - timestamp; /**< Timestamp of the last Topology Discovery message received from this neighbor device. */ - }; - - /* - * @brief List of known 1905 neighbor devices - * - * key: 1905.1 device AL-MAC - * value: 1905.1 device information - * Devices are being added to the list when receiving a 1905.1 Topology Discovery message from - * an unknown 1905.1 device. Every 1905.1 device shall send this message every 60 seconds, and - * we update the time stamp in which the message is received. - */ - std::unordered_map m_1905_neighbor_devices; - /** * @brief Adds an AP HT Capabilities TLV to AP Capability Report message. * From afb731926065090968e165b72a416c4918c7dc87 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 8 Jul 2020 19:31:43 +0000 Subject: [PATCH 291/453] cppcheck: Add "useStlAlgorithm" to the suppression list Cppcheck complains about a style issue when using a ranged loop. The Cppcheck "prefers" to use STL functions. Since the use of STL function requires to write longer lines of code, and most of the times, to define additional helper reference variables/iterators to avoid using long lines, it is actually less readable, and less good performance-wise. Therefore suppressed. PPM-216 Signed-off-by: Moran Shoeg --- tools/docker/static-analysis/suppressions.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/docker/static-analysis/suppressions.txt b/tools/docker/static-analysis/suppressions.txt index a97a2e9e2c..c973048a7a 100644 --- a/tools/docker/static-analysis/suppressions.txt +++ b/tools/docker/static-analysis/suppressions.txt @@ -3,3 +3,6 @@ uninitMemberVar // Suppress performance: Variable 'X' is assigned in constructor body. Consider performing initialization in initialization list. useInitializationList + +// Suppress style: Consider using std::find_if algorithm instead of a raw loop. +useStlAlgorithm From 5d328649409c02746b0f15285b59a5d7f54073a1 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Mon, 20 Jul 2020 09:00:01 +0000 Subject: [PATCH 292/453] cppcheck: Update existing issues file PPM-216 Signed-off-by: Moran Shoeg --- ci/cppcheck/cppcheck_existing_issues.txt | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/ci/cppcheck/cppcheck_existing_issues.txt b/ci/cppcheck/cppcheck_existing_issues.txt index 07bba2ae39..fdd3c6aac4 100644 --- a/ci/cppcheck/cppcheck_existing_issues.txt +++ b/ci/cppcheck/cppcheck_existing_issues.txt @@ -6,33 +6,25 @@ agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp: style: The if c agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp: style: Variable 'id' is assigned a value that is never used. [unreadVariable] int id = 0; agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp: style: Variable 'iface' is assigned a value that is never used. [unreadVariable] std::string iface = radio_node->get_iface(); agent/src/beerocks/fronthaul_manager/monitor/rdkb/monitor_rdkb_hal.cpp: style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak] break; -agent/src/beerocks/slave/agent_ucc_listener.cpp: style: struct member 'sVapElement::backhaul_vap' is never used. [unusedStructMember] bool backhaul_vap; -agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Consider using std::find_if algorithm instead of a raw loop. [useStlAlgorithm] if (soc->hostap_iface == config_const_bh_slave) { -agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Consider using std::find_if algorithm instead of a raw loop. [useStlAlgorithm] if (soc_iter->slave == sd) { agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Local variable 'iface_hal' shadows outer variable [shadowVariable] auto iface_hal = get_wireless_hal(sta_iface); agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Local variable 'local_interface_name' shadows outer variable [shadowVariable] std::string local_interface_name = soc->hostap_iface; agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Local variable 'supportedServiceTuple' shadows outer variable [shadowVariable] auto supportedServiceTuple = tlvSupportedService->supported_service_list(1); agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Variable 'p_cmdu_header' is assigned a value that is never used. [unreadVariable] auto p_cmdu_header = agent/src/beerocks/slave/beerocks_slave_main.cpp: style: Parameter 'beerocks_slave_conf' can be declared with const [constParameter]static int run_son_slave(int slave_num, beerocks::config_file::sConfigSlave &beerocks_slave_conf, +agent/src/beerocks/slave/gate/unit_tests/gate_test.cpp: error: syntax error [syntaxError]TEST(gate_beacon_query_test, loading_vs_from_1905_beacon_query) agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp: warning: Comparison of a boolean expression with an integer. [compareBoolExpressionWithInt] if (bpl::dhcp_mon_stop() == false) { agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp: warning: Redundant assignment of '*(volatile char*)pass' to itself. [selfAssignment] *(volatile char *)pass = *(volatile char *)pass; agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp: warning: Redundant assignment of '*(volatile char*)pass' to itself. [selfAssignment] *(volatile char *)pass = *(volatile char *)pass; -agent/src/beerocks/slave/son_slave_thread.cpp: style: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm] if (channel_to_check == ch.channel) { agent/src/beerocks/slave/son_slave_thread.cpp: style: Local variable 'notification' shadows outer variable [shadowVariable] auto notification = message_com::create_vs_message< common/beerocks/bcl/include/bcl/beerocks_logging.h: style: Class 'logging' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] logging(const std::string &module_name, const std::string &config_path = std::string(), -common/beerocks/bcl/source/beerocks_logging.cpp: style: Consider using std::accumulate algorithm instead of a raw loop. [useStlAlgorithm] str += elt + ", "; common/beerocks/bcl/source/beerocks_logging.cpp: style: The class 'NetLogger' does not have a constructor although it has private member variables. [noConstructor]class NetLogger : public el::LogDispatchCallback { -common/beerocks/bcl/source/beerocks_ucc_listener.cpp: style: Consider using std::find_if algorithm instead of a raw loop. [useStlAlgorithm] validate_binary_notation(value) || validate_decimal_notation(value))) { -common/beerocks/bcl/source/beerocks_ucc_listener.cpp: style: Consider using std::transform algorithm instead of a raw loop. [useStlAlgorithm] mandatory_params.push_back(param_name.first); common/beerocks/bcl/source/beerocks_ucc_listener.cpp: style: Parameter 'tlv_hex_list' can be declared with const [constParameter]bool tlvPrefilledData::add_tlvs_from_list(std::list &tlv_hex_list, common/beerocks/bcl/source/beerocks_ucc_listener.cpp: style: Variable 'command_type_str' can be declared with const [constVariable] auto &command_type_str = *cmd_tokens_vec.begin(); common/beerocks/bcl/source/network/network_utils.cpp: information: Skipping configuration 'SIOCBRADDIF' since the value of 'SIOCBRADDIF' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly. [ConfigurationNotChecked] err = ioctl(br_socket_fd, SIOCBRADDIF, &ifr); common/beerocks/bcl/source/network/network_utils.cpp: information: Skipping configuration 'SIOCBRDELIF' since the value of 'SIOCBRDELIF' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly. [ConfigurationNotChecked] err = ioctl(br_socket_fd, SIOCBRDELIF, &ifr); common/beerocks/bcl/source/network/network_utils.cpp: style: Condition '!up' is always true [knownConditionTrueFalse] while (!up) { -common/beerocks/bcl/source/network/network_utils.cpp: style: Consider using std::find_if algorithm instead of a raw loop. [useStlAlgorithm] if (ip_info.iface == iface_name) { common/beerocks/bcl/source/network/network_utils.cpp: style: Local variable 'ecmd' shadows outer variable [shadowVariable] struct ethtool_cmd ecmd; common/beerocks/bcl/source/network/network_utils.cpp: style: The scope of the variable 'rtInfo_ret' can be reduced. [variableScope] int rtInfo_ret; -common/beerocks/bcl/source/network/socket.cpp: style: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm] if (soc == s) { common/beerocks/bcl/source/network/socket.cpp: style: The scope of the variable 'i' can be reduced. [variableScope] unsigned i; common/beerocks/bcl/source/network/socket.cpp: style: Unused variable: it [unusedVariable] std::vector::iterator it; common/beerocks/bcl/source/son/son_wireless_utils.cpp: style: Condition 'prev_bw<=bw' is always true [knownConditionTrueFalse] } else if (prev_bw <= bw) { @@ -44,7 +36,6 @@ common/beerocks/bwl/dummy/ap_wlan_hal_dummy.cpp: style: struct member 'DUMMY_acs common/beerocks/bwl/dummy/ap_wlan_hal_dummy.cpp: style: struct member 'DUMMY_acs_report_get::bss' is never used. [unusedStructMember] int bss; common/beerocks/bwl/dummy/mon_wlan_hal_dummy.cpp: style: The scope of the variable 'tmp_int' can be reduced. [variableScope] int64_t tmp_int; common/beerocks/bwl/dwpal/ap_wlan_hal_dwpal.cpp: information: This file is not analyzed. Cppcheck failed to extract a valid configuration. Use -v for more details. [noValidConfiguration] -common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp: style: Consider using std::count_if algorithm instead of a raw loop. [useStlAlgorithm] attached++; common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp: style: The scope of the variable 'rate_kbs' can be reduced. [variableScope] uint32_t rate_kbs; common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp: style: The scope of the variable 'rate_mbs_fp_8_1' can be reduced. [variableScope] uint8_t rate_mbs_fp_8_1; common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp: style: A pointer can not be negative so it is either pointless or an error to check if it is. [pointerLessThanZero] if (err < 0) { @@ -70,7 +61,6 @@ controller/src/beerocks/cli/beerocks_cli_bml.cpp: performance: Function paramete controller/src/beerocks/cli/beerocks_cli_bml.cpp: performance: Function parameter 'ind' should be passed by const reference. [passedByValue] const std::string &parent_bssid, const std::string ind, std::stringstream &ss) controller/src/beerocks/cli/beerocks_cli_bml.h: performance: Function parameter 'iface' should be passed by const reference. [passedByValue] int wps_onboarding(const std::string iface = std::string()); controller/src/beerocks/cli/beerocks_cli_main.cpp: performance: Function parameter 'temp_path' should be passed by const reference. [passedByValue]static void cli_tcp_proxy(std::string temp_path) -controller/src/beerocks/cli/beerocks_cli_main.cpp: style: Consider using std::accumulate algorithm instead of a raw loop. [useStlAlgorithm] cmd += token + " "; controller/src/beerocks/cli/beerocks_cli_main.cpp: style: Redundant initialization for 'cli_ptr'. The initialized value is overwritten before it is read. [redundantInitialization] beerocks::cli *cli_ptr = &cli_soc; controller/src/beerocks/cli/beerocks_cli_main.cpp: style: Variable 'cli_ptr' is assigned a value that is never used. [unreadVariable] beerocks::cli *cli_ptr = &cli_soc; controller/src/beerocks/cli/beerocks_cli_main.cpp: style: Variable 'pos' is assigned a value that is never used. [unreadVariable] } else if ((pos = token->find("!")) != std::string::npos) { @@ -87,9 +77,6 @@ controller/src/beerocks/master/db/db.cpp: performance: Function parameter 'iface controller/src/beerocks/master/db/db.cpp: performance: Function parameter 'name' should be passed by const reference. [passedByValue]bool db::set_node_name(const std::string &mac, std::string name) controller/src/beerocks/master/db/db.cpp: performance: Function parameter 'ssid' should be passed by const reference. [passedByValue]bool db::add_vap(const std::string &radio_mac, int vap_id, std::string bssid, std::string ssid, controller/src/beerocks/master/db/db.cpp: performance: Function parameter 'version' should be passed by const reference. [passedByValue]bool db::set_hostap_driver_version(const std::string &mac, std::string version) -controller/src/beerocks/master/db/db.cpp: style: Consider using std::find_if algorithm instead of a raw loop. [useStlAlgorithm] get_node_state(hostap) == beerocks::STATE_CONNECTED) { -controller/src/beerocks/master/db/db.cpp: style: Consider using std::find_if algorithm instead of a raw loop. [useStlAlgorithm] if (it.second.mac == mac) { -controller/src/beerocks/master/db/db.cpp: style: Consider using std::transform algorithm instead of a raw loop. [useStlAlgorithm] neighbors_al_macs.push_back(tlvf::mac_from_string(sibling)); controller/src/beerocks/master/db/db.cpp: style: Non-boolean value returned from function returning bool [returnNonBoolInBooleanFunction] return -1; controller/src/beerocks/master/db/db.cpp: style: Parameter 'n' can be declared with const [constParameter]int db::get_node_bw_int(std::shared_ptr &n) controller/src/beerocks/master/db/db.cpp: style: The scope of the variable 'listener_exist' can be reduced. [variableScope] bool listener_exist; @@ -107,7 +94,6 @@ controller/src/beerocks/master/db/network_map.cpp: style: Variable 'size' is ass controller/src/beerocks/master/son_actions.cpp: performance: Function parameter 'bssid' should be passed by const reference. [passedByValue] std::string sta_mac, std::string bssid) controller/src/beerocks/master/son_actions.cpp: performance: Function parameter 'hostap_mac' should be passed by const reference. [passedByValue]void son_actions::handle_dead_node(std::string mac, std::string hostap_mac, db &database, controller/src/beerocks/master/son_actions.cpp: performance: Function parameter 'sta_mac' should be passed by const reference. [passedByValue] std::string sta_mac, std::string bssid) -controller/src/beerocks/master/son_actions.cpp: style: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm] if (operating_class == operating_class_info.operating_class()) { controller/src/beerocks/master/son_actions.cpp: style: Local variable 'prev_task_id' shadows outer variable [shadowVariable] int prev_task_id = database.get_association_handling_task_id(mac); controller/src/beerocks/master/son_actions.cpp: style: The scope of the variable 'prev_task_id' can be reduced. [variableScope] int prev_task_id; controller/src/beerocks/master/son_management.cpp: style: Variable 'op_error_code' is assigned a value that is never used. [unreadVariable] op_error_code = eChannelScanOperationCode::SCAN_IN_PROGRESS; @@ -145,8 +131,6 @@ controller/src/beerocks/master/tasks/channel_selection_task.cpp: style: C-style controller/src/beerocks/master/tasks/channel_selection_task.cpp: style: C-style pointer casting [cstyleCast] auto new_event = CHANNEL_SELECTION_ALLOCATE_EVENT(sDfsCacPendinghostap_event); controller/src/beerocks/master/tasks/channel_selection_task.cpp: style: C-style pointer casting [cstyleCast] auto new_event = CHANNEL_SELECTION_ALLOCATE_EVENT(sDfsReEntrySampleSteeredClients_event); controller/src/beerocks/master/tasks/channel_selection_task.cpp: style: C-style pointer casting [cstyleCast] auto new_event = CHANNEL_SELECTION_ALLOCATE_EVENT(sDfsCacPendinghostap_event); -controller/src/beerocks/master/tasks/channel_selection_task.cpp: style: Consider using std::find_if algorithm instead of a raw loop. [useStlAlgorithm] if (database.is_hostap_backhaul_manager(sibling)) { -controller/src/beerocks/master/tasks/channel_selection_task.cpp: style: Consider using std::find_if algorithm instead of a raw loop. [useStlAlgorithm] if (database.is_node_5ghz(gw_slave)) { controller/src/beerocks/master/tasks/channel_selection_task.cpp: style: Redundant initialization for 'hostap_parent_type'. The initialized value is overwritten before it is read. [redundantInitialization] auto hostap_parent_type = database.get_node_type(hostap_parent_mac); controller/src/beerocks/master/tasks/channel_selection_task.cpp: style: The scope of the variable 'channel_80Mhz_step' can be reduced. [variableScope] auto channel_80Mhz_step = CHANNEL_80MHZ_STEP; controller/src/beerocks/master/tasks/client_locating_task.cpp: performance: Function parameter 'client_mac_' should be passed by const reference. [passedByValue] task_pool &tasks_, std::string client_mac_, @@ -201,7 +185,6 @@ framework/platform/bpl/uci/cfg/bpl_cfg_uci.cpp: style: The scope of the variable framework/platform/bpl/uci/db/bpl_db.cpp: style: Parameter 'nested_params' can be declared with const [constParameter] std::unordered_map> &nested_params) framework/platform/bpl/uci/db/bpl_db.cpp: style: Parameter 'params' can be declared with const [constParameter] std::unordered_map ¶ms) framework/platform/bpl/uci/dhcp/bpl_dhcp.cpp: style: struct member 'dhcp_event_request::data' is never used. [unusedStructMember] char data[]; -framework/tlvf/src/src/ClassList.cpp: style: Consider using std::accumulate algorithm instead of a raw loop. [useStlAlgorithm] msg_len += c->getLen(); framework/tlvf/test/tlvf_test.cpp: style: Local variable 'cmplx' shadows outer variable [shadowVariable] auto cmplx = std::get<1>(tlv4->complex_list(0)); framework/tlvf/test/tlvf_test.cpp: style: Local variable 'cmplx' shadows outer variable [shadowVariable] auto cmplx = std::get<1>(tlv4->complex_list(1)); framework/tlvf/test/tlvf_test.cpp: style: Local variable 'cmplx' shadows outer variable [shadowVariable] auto cmplx = std::get<1>(tlv4->complex_list(i)); From 0ae193fe53385afa918a6c032ecd9cb48e7ac436 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 17 Jul 2020 12:48:54 +0300 Subject: [PATCH 293/453] common: tlvf: Remove HOSTAP_CHANNEL_SWITCH_REQUEST Need to remove deprecated VS message ACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST. https://jira.prplfoundation.org/browse/PPM-287 Signed-off-by: Vladyslav Tupikin --- .../tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml | 1 - .../tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml | 4 ---- 2 files changed, 5 deletions(-) diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index be0cdeb7d3..69449dce84 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -48,7 +48,6 @@ eActionOp_CONTROL: ACTION_CONTROL_BACKHAUL_DL_RSSI_REPORT_NOTIFICATION: 31 ACTION_CONTROL_BACKHAUL_RESET: 32 - ACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST: 53 ACTION_CONTROL_HOSTAP_CSA_ERROR_NOTIFICATION: 54 ACTION_CONTROL_HOSTAP_CSA_NOTIFICATION: 55 ACTION_CONTROL_HOSTAP_ACS_ERROR_NOTIFICATION: 56 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml index 604cf41b41..145f495044 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml @@ -166,10 +166,6 @@ cACTION_CONTROL_HOSTAP_UPDATE_STOP_ON_FAILURE_ATTEMPTS_REQUEST: cACTION_CONTROL_HOSTAP_DISABLED_BY_MASTER: _type: class -cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST: - _type: class - cs_params: sApChannelSwitch - cACTION_CONTROL_HOSTAP_STATS_MEASUREMENT_REQUEST: _type: class sync: uint8_t From e956821a9a738027279e999944646926e12b9905 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 17 Jul 2020 12:56:28 +0300 Subject: [PATCH 294/453] common: tlvf: Remove code from autogenerated files https://jira.prplfoundation.org/browse/PPM-287 Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 1 - .../beerocks/tlvf/beerocks_message_control.h | 21 ------ .../tlvf/beerocks_message_control.cpp | 70 ------------------- 3 files changed, 92 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index ac72c99da9..656d00de8d 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -54,7 +54,6 @@ enum eActionOp_CONTROL: uint8_t { ACTION_CONTROL_BACKHAUL_ROAM_REQUEST = 0x1e, ACTION_CONTROL_BACKHAUL_DL_RSSI_REPORT_NOTIFICATION = 0x1f, ACTION_CONTROL_BACKHAUL_RESET = 0x20, - ACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST = 0x35, ACTION_CONTROL_HOSTAP_CSA_ERROR_NOTIFICATION = 0x36, ACTION_CONTROL_HOSTAP_CSA_NOTIFICATION = 0x37, ACTION_CONTROL_HOSTAP_ACS_ERROR_NOTIFICATION = 0x38, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h index ca3795752d..aff941ac41 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h @@ -670,27 +670,6 @@ class cACTION_CONTROL_HOSTAP_DISABLED_BY_MASTER : public BaseClass eActionOp_CONTROL* m_action_op = nullptr; }; -class cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST : public BaseClass -{ - public: - cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST(std::shared_ptr base, bool parse = false); - ~cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST(); - - static eActionOp_CONTROL get_action_op(){ - return (eActionOp_CONTROL)(ACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST); - } - sApChannelSwitch& cs_params(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CONTROL* m_action_op = nullptr; - sApChannelSwitch* m_cs_params = nullptr; -}; - class cACTION_CONTROL_HOSTAP_STATS_MEASUREMENT_REQUEST : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp index 1e18f05da5..d8216e6d91 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp @@ -2351,76 +2351,6 @@ bool cACTION_CONTROL_HOSTAP_DISABLED_BY_MASTER::init() return true; } -cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST::cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST::cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST::~cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST() { -} -sApChannelSwitch& cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST::cs_params() { - return (sApChannelSwitch&)(*m_cs_params); -} - -void cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CONTROL), reinterpret_cast(m_action_op)); - m_cs_params->struct_swap(); -} - -bool cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sApChannelSwitch); // cs_params - return class_size; -} - -bool cACTION_CONTROL_HOSTAP_CHANNEL_SWITCH_REQUEST::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_cs_params = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sApChannelSwitch))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sApChannelSwitch) << ") Failed!"; - return false; - } - if (!m_parse__) { m_cs_params->struct_init(); } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_CONTROL_HOSTAP_STATS_MEASUREMENT_REQUEST::cACTION_CONTROL_HOSTAP_STATS_MEASUREMENT_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); From 3ba4753da80ecd86ed4e44dee7fac8b69411c15b Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 14:09:55 +0300 Subject: [PATCH 295/453] agent: son_slave: Remove case from handler Need to remove cases for VS message handler for messages: ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE https://jira.prplfoundation.org/browse/PPM-290 Signed-off-by: Vladyslav Tupikin --- agent/src/beerocks/slave/son_slave_thread.cpp | 41 ------------------- 1 file changed, 41 deletions(-) diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index ce81538875..0657ae28b8 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -900,27 +900,6 @@ bool slave_thread::handle_cmdu_control_message(Socket *sd, message_com::send_cmdu(monitor_socket, cmdu_tx); break; } - case beerocks_message::ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST: { - auto request_in = - beerocks_header - ->addClass(); - if (request_in == nullptr) { - LOG(ERROR) << "addClass ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST failed"; - return false; - } - - auto request_out = message_com::create_vs_message< - beerocks_message::cACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_REQUEST>( - cmdu_tx, beerocks_header->id()); - if (request_out == nullptr) { - LOG(ERROR) << "Failed building ACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_REQUEST message!"; - return false; - } - - request_out->params() = request_in->params(); - message_com::send_cmdu(monitor_socket, cmdu_tx); - break; - } case beerocks_message::ACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST: { auto request_in = beerocks_header @@ -2757,26 +2736,6 @@ bool slave_thread::handle_cmdu_monitor_message(Socket *sd, break; } - case beerocks_message::ACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_RESPONSE: { - auto response_in = - beerocks_header - ->addClass(); - if (response_in == nullptr) { - LOG(ERROR) << "addClass ACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_RESPONSE failed"; - break; - } - auto response_out = message_com::create_vs_message< - beerocks_message::cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE>( - cmdu_tx, beerocks_header->id()); - if (response_out == nullptr) { - LOG(ERROR) - << "Failed building ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE message!"; - break; - } - response_out->params() = response_in->params(); - send_cmdu_to_controller(cmdu_tx); - break; - } case beerocks_message::ACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE: { auto response_in = beerocks_header From 1d03e2c1eee6c087efed9b2b473aabf16aeb91cb Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 14:12:10 +0300 Subject: [PATCH 296/453] controller: son_master: Remove case from handler Need to remove case for VS messages handler for message ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE. https://jira.prplfoundation.org/browse/PPM-290 Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/master/son_master_thread.cpp | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/controller/src/beerocks/master/son_master_thread.cpp b/controller/src/beerocks/master/son_master_thread.cpp index b3d11241e0..e9851f0197 100644 --- a/controller/src/beerocks/master/son_master_thread.cpp +++ b/controller/src/beerocks/master/son_master_thread.cpp @@ -3368,33 +3368,6 @@ bool master_thread::handle_cmdu_control_message(const std::string &src_mac, ); break; } - case beerocks_message::ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE: { - auto response = - beerocks_header - ->addClass(); - if (response == nullptr) { - LOG(ERROR) << "addClass ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE failed"; - return false; - } - LOG_CLI(DEBUG, "sta channel load response:" - << std::endl - << "sta_mac: " << response->params().sta_mac << std::endl - << "measurement_rep_mode: " << (int)response->params().rep_mode - << std::endl - << "op_class: " << (int)response->params().op_class << std::endl - << "channel: " << (int)response->params().channel << std::endl - << "start_time: " << (int)response->params().start_time << std::endl - << "duration: " << (int)response->params().duration << std::endl - << "channel_load: " << (int)response->params().channel_load - - << std::endl - << "new_ch_width: " << (int)response->params().new_ch_width << std::endl - << "new_ch_center_freq_seg_0: " - << (int)response->params().new_ch_center_freq_seg_0 << std::endl - << "new_ch_center_freq_seg_1: " - << (int)response->params().new_ch_center_freq_seg_1); - break; - } case beerocks_message::ACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE: { auto response = beerocks_header From f24b837e1617b5147d94bfb21397d0f67cd62a10 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 14:19:52 +0300 Subject: [PATCH 297/453] common: tlvf: Remove deprecated code Need to remove deprecated code from autodgenerated files. https://jira.prplfoundation.org/browse/PPM-290 Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 2 - .../beerocks/tlvf/beerocks_message_control.h | 42 ------ .../tlvf/beerocks_message_control.cpp | 140 ------------------ 3 files changed, 184 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index 656d00de8d..1e6c4b7ec3 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -88,8 +88,6 @@ enum eActionOp_CONTROL: uint8_t { ACTION_CONTROL_CLIENT_ARP_MONITOR_NOTIFICATION = 0x74, ACTION_CONTROL_CLIENT_BEACON_11K_REQUEST = 0x75, ACTION_CONTROL_CLIENT_BEACON_11K_RESPONSE = 0x76, - ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST = 0x77, - ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE = 0x78, ACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST = 0x79, ACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE = 0x7a, ACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST = 0x7b, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h index aff941ac41..61905a1604 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h @@ -1225,48 +1225,6 @@ class cACTION_CONTROL_CLIENT_BEACON_11K_RESPONSE : public BaseClass sBeaconResponse11k* m_params = nullptr; }; -class cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST : public BaseClass -{ - public: - cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST(std::shared_ptr base, bool parse = false); - ~cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST(); - - static eActionOp_CONTROL get_action_op(){ - return (eActionOp_CONTROL)(ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST); - } - sStaChannelLoadRequest11k& params(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CONTROL* m_action_op = nullptr; - sStaChannelLoadRequest11k* m_params = nullptr; -}; - -class cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE : public BaseClass -{ - public: - cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE(std::shared_ptr base, bool parse = false); - ~cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE(); - - static eActionOp_CONTROL get_action_op(){ - return (eActionOp_CONTROL)(ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE); - } - sStaChannelLoadResponse11k& params(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CONTROL* m_action_op = nullptr; - sStaChannelLoadResponse11k* m_params = nullptr; -}; - class cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp index d8216e6d91..bdc1df9b65 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp @@ -4303,146 +4303,6 @@ bool cACTION_CONTROL_CLIENT_BEACON_11K_RESPONSE::init() return true; } -cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST::cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST::cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST::~cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST() { -} -sStaChannelLoadRequest11k& cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST::params() { - return (sStaChannelLoadRequest11k&)(*m_params); -} - -void cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CONTROL), reinterpret_cast(m_action_op)); - m_params->struct_swap(); -} - -bool cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sStaChannelLoadRequest11k); // params - return class_size; -} - -bool cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_params = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sStaChannelLoadRequest11k))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sStaChannelLoadRequest11k) << ") Failed!"; - return false; - } - if (!m_parse__) { m_params->struct_init(); } - if (m_parse__) { class_swap(); } - return true; -} - -cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE::cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE::cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE::~cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE() { -} -sStaChannelLoadResponse11k& cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE::params() { - return (sStaChannelLoadResponse11k&)(*m_params); -} - -void cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CONTROL), reinterpret_cast(m_action_op)); - m_params->struct_swap(); -} - -bool cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sStaChannelLoadResponse11k); // params - return class_size; -} - -bool cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_params = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sStaChannelLoadResponse11k))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sStaChannelLoadResponse11k) << ") Failed!"; - return false; - } - if (!m_parse__) { m_params->struct_init(); } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST::cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); From 2aea8fed9e95a46b3c78500cc936ee5d3178964d Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 14:22:11 +0300 Subject: [PATCH 298/453] common: tlvf: Remove deprecated messages Need to remove deprecated VS messages: ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE https://jira.prplfoundation.org/browse/PPM-290 Signed-off-by: Vladyslav Tupikin --- .../tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml | 3 +-- .../tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml | 8 -------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index 69449dce84..762b7881ec 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -84,8 +84,7 @@ eActionOp_CONTROL: ACTION_CONTROL_CLIENT_ARP_MONITOR_NOTIFICATION: 116 ACTION_CONTROL_CLIENT_BEACON_11K_REQUEST: 117 ACTION_CONTROL_CLIENT_BEACON_11K_RESPONSE: 118 - ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST: 119 - ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE: 120 + ACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST: 121 ACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE: 122 ACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST: 123 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml index 145f495044..7e20d7ca59 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml @@ -289,14 +289,6 @@ cACTION_CONTROL_CLIENT_BEACON_11K_RESPONSE: _type: class params: sBeaconResponse11k -cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST: - _type: class - params: sStaChannelLoadRequest11k - -cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_RESPONSE: - _type: class - params: sStaChannelLoadResponse11k - cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST: _type: class params: sStatisticsRequest11k From 7cf810d9fb99a84570938e401c6d51ff520e743f Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 14:23:21 +0300 Subject: [PATCH 299/453] controller: son_management: Remove deprecated case Need to remove case for deprecated message ACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST from VS message handler. https://jira.prplfoundation.org/browse/PPM-290 Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/master/son_management.cpp | 51 ------------------- 1 file changed, 51 deletions(-) diff --git a/controller/src/beerocks/master/son_management.cpp b/controller/src/beerocks/master/son_management.cpp index a6aee2a626..549c748b73 100644 --- a/controller/src/beerocks/master/son_management.cpp +++ b/controller/src/beerocks/master/son_management.cpp @@ -534,57 +534,6 @@ void son_management::handle_cli_message(Socket *sd, break; } - case beerocks_message::ACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST: { - auto cli_request = - beerocks_header - ->addClass(); - if (cli_request == nullptr) { - LOG(ERROR) << "addClass ACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST failed"; - isOK = false; - break; - } - - std::string client_mac = tlvf::mac_to_string(cli_request->client_mac()); - std::string hostap_mac = tlvf::mac_to_string(cli_request->hostap_mac()); - auto agent_mac = database.get_node_parent_ire(hostap_mac); - LOG(DEBUG) << "CLI channel load request for " << client_mac << " to " << hostap_mac; - - auto request = message_com::create_vs_message< - beerocks_message::cACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST>(cmdu_tx); - if (request == nullptr) { - LOG(ERROR) << "Failed building ACTION_CONTROL_CLIENT_CHANNEL_LOAD_11K_REQUEST message!"; - isOK = false; - break; - } - - request->params().channel = cli_request->channel(); - request->params().op_class = 0; - request->params().repeats = 0; - request->params().rand_ival = 1000; - request->params().duration = 50; - request->params().sta_mac = cli_request->client_mac(); - - request->params().parallel = 0; - request->params().enable = 0; - request->params().request = 0; - request->params().report = 0; - request->params().mandatory_duration = 0; - - // Optional: - request->params().use_optional_ch_load_rep = 0; - request->params().ch_load_rep_first = 0; - request->params().ch_load_rep_second = 0; - - request->params().use_optional_wide_band_ch_switch = 0; - request->params().new_ch_width = 0; - request->params().new_ch_center_freq_seg_0 = 0; - request->params().new_ch_center_freq_seg_1 = 0; - - const auto parent_radio = database.get_node_parent_radio(hostap_mac); - son_actions::send_cmdu_to_agent(agent_mac, cmdu_tx, database, parent_radio); - - break; - } case beerocks_message::ACTION_CLI_CLIENT_STATISTICS_11K_REQUEST: { auto cli_request = beerocks_header From 02e792cd61d39abed9d3b03056ee00d51c5b84a7 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 14:31:37 +0300 Subject: [PATCH 300/453] controller: beerocks_cli: Remove deprecated cli command Need to remove deprecated cli command client_channel_load_11k_req and all connected source code. https://jira.prplfoundation.org/browse/PPM-290 Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/cli/beerocks_cli_socket.cpp | 33 ------------------- .../src/beerocks/cli/beerocks_cli_socket.h | 5 --- 2 files changed, 38 deletions(-) diff --git a/controller/src/beerocks/cli/beerocks_cli_socket.cpp b/controller/src/beerocks/cli/beerocks_cli_socket.cpp index 536cc20590..256722251f 100644 --- a/controller/src/beerocks/cli/beerocks_cli_socket.cpp +++ b/controller/src/beerocks/cli/beerocks_cli_socket.cpp @@ -158,11 +158,6 @@ void cli_socket::setFunctionsMapAndArray() "starts an IRE network optimization task", static_cast(&cli_socket::ire_network_optimization_task_caller), 0, 0, STRING_ARG, STRING_ARG); - insertCommandToMap( - "client_channel_load_11k_req", " ", - "sends to 'hostap_mac' 11k channel load request for 'client_mac' on 'channel' number", - static_cast(&cli_socket::client_channel_load_11k_req_caller), 2, 3, STRING_ARG, - STRING_ARG, INT_ARG); insertCommandToMap("client_beacon_11k_req", " <[params]>", "sends beacon request to 'sta_mac' with 'params' = (bssid, ch, ssid, " "duration, rand_ival, repeats, op_class, mode)=value", @@ -403,16 +398,6 @@ int cli_socket::ire_network_optimization_task_caller(int numOfArgs) return ire_network_optimization_task(); } -int cli_socket::client_channel_load_11k_req_caller(int numOfArgs) -{ - if (numOfArgs == 3) { - return client_channel_load_11k_req(args.stringArgs[0], args.stringArgs[1], args.intArgs[2]); - } else if (numOfArgs == 2) { - return client_channel_load_11k_req(args.stringArgs[0], args.stringArgs[1]); - } else - return -1; -} - int cli_socket::client_beacon_11k_req_caller(int numOfArgs) { @@ -765,24 +750,6 @@ int cli_socket::ire_network_optimization_task() return 0; } -int cli_socket::client_channel_load_11k_req(std::string hostap_mac, std::string client_mac, - int channel) -{ - auto request = message_com::create_vs_message< - beerocks_message::cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST>(cmdu_tx); - if (request == nullptr) { - LOG(ERROR) << "Failed building cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST message!"; - return -1; - } - request->client_mac() = tlvf::mac_from_string(client_mac); - request->hostap_mac() = tlvf::mac_from_string(hostap_mac); - request->channel() = channel; - wait_response = true; - message_com::send_cmdu(master_socket, cmdu_tx); - waitResponseReady(); - return 0; -} - int cli_socket::client_beacon_11k_req(std::string client_mac, std::string bssid, uint8_t channel, std::string ssid, uint16_t duration, uint16_t rand_ival, uint16_t repeats, int16_t op_class, std::string mode) diff --git a/controller/src/beerocks/cli/beerocks_cli_socket.h b/controller/src/beerocks/cli/beerocks_cli_socket.h index e1695ad0d0..a4a39a2dad 100644 --- a/controller/src/beerocks/cli/beerocks_cli_socket.h +++ b/controller/src/beerocks/cli/beerocks_cli_socket.h @@ -83,8 +83,6 @@ class cli_socket : public socket_thread, public cli { int client_beacon_11k_req_caller(int numOfArgs); - int client_channel_load_11k_req_caller(int numOfArgs); - int client_link_measurement_11k_req_caller(int numOfArgs); int client_statistics_11k_req_caller(int numOfArgs); @@ -136,9 +134,6 @@ class cli_socket : public socket_thread, public cli { std::string ssid, uint16_t duration, uint16_t rand_ival, uint16_t repeats, int16_t op_class, std::string mode); - int client_channel_load_11k_req(std::string hostap_mac, std::string client_mac, - int channel = 0); - int client_link_measurement_11k_req(std::string hostap_mac, std::string client_mac); int client_statistics_11k_req(std::string hostap_mac, std::string client_mac, From 1fd0ede6f7f59f20e14927ffce5757ad78af68fa Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 14:35:53 +0300 Subject: [PATCH 301/453] common: tlvf: Remove deprecated code from autogenerated files https://jira.prplfoundation.org/browse/PPM-290 Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 1 - .../beerocks/tlvf/beerocks_message_cli.h | 25 ----- .../beerocks/tlvf/beerocks_message_cli.cpp | 92 ------------------- 3 files changed, 118 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index 1e6c4b7ec3..17a3b7c128 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -292,7 +292,6 @@ enum eActionOp_CLI: uint8_t { ACTION_CLI_CLIENT_DISCONNECT_REQUEST = 0x52, ACTION_CLI_CLIENT_BSS_STEER_REQUEST = 0x53, ACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST = 0x54, - ACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST = 0x55, ACTION_CLI_CLIENT_BEACON_11K_REQUEST = 0x56, ACTION_CLI_CLIENT_STATISTICS_11K_REQUEST = 0x57, ACTION_CLI_HOSTAP_CHANNEL_SWITCH_REQUEST = 0x7a, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h index 11e76cef08..12535061e0 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h @@ -481,31 +481,6 @@ class cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST : public BaseClass sMacAddr* m_client_mac = nullptr; }; -class cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST : public BaseClass -{ - public: - cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST(std::shared_ptr base, bool parse = false); - ~cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST(); - - static eActionOp_CLI get_action_op(){ - return (eActionOp_CLI)(ACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST); - } - sMacAddr& hostap_mac(); - sMacAddr& client_mac(); - uint8_t& channel(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CLI* m_action_op = nullptr; - sMacAddr* m_hostap_mac = nullptr; - sMacAddr* m_client_mac = nullptr; - uint8_t* m_channel = nullptr; -}; - class cACTION_CLI_CLIENT_BEACON_11K_REQUEST : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp index 773822bd97..deeac6446d 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp @@ -1611,98 +1611,6 @@ bool cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST::init() return true; } -cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST::cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST::cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST::~cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST() { -} -sMacAddr& cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST::hostap_mac() { - return (sMacAddr&)(*m_hostap_mac); -} - -sMacAddr& cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST::client_mac() { - return (sMacAddr&)(*m_client_mac); -} - -uint8_t& cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST::channel() { - return (uint8_t&)(*m_channel); -} - -void cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CLI), reinterpret_cast(m_action_op)); - m_hostap_mac->struct_swap(); - m_client_mac->struct_swap(); -} - -bool cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sMacAddr); // hostap_mac - class_size += sizeof(sMacAddr); // client_mac - class_size += sizeof(uint8_t); // channel - return class_size; -} - -bool cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_hostap_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_hostap_mac->struct_init(); } - m_client_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_client_mac->struct_init(); } - m_channel = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; - return false; - } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_CLI_CLIENT_BEACON_11K_REQUEST::cACTION_CLI_CLIENT_BEACON_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); From 581edbd1385c9bd19cbb22e107078ec8b9314334 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 14:37:03 +0300 Subject: [PATCH 302/453] common: tlvf: Remove deprecated cli message Need to remove deprecated CLI message ACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST https://jira.prplfoundation.org/browse/PPM-290 Signed-off-by: Vladyslav Tupikin --- .../tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml | 2 +- .../tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index 762b7881ec..d472c7266f 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -335,7 +335,7 @@ eActionOp_CLI: ACTION_CLI_CLIENT_DISCONNECT_REQUEST: 82 ACTION_CLI_CLIENT_BSS_STEER_REQUEST: 83 ACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST: 84 - ACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST: 85 + ACTION_CLI_CLIENT_BEACON_11K_REQUEST: 86 ACTION_CLI_CLIENT_STATISTICS_11K_REQUEST: 87 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml index b27cc65e4f..a607289975 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml @@ -120,12 +120,6 @@ cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST: hostap_mac: sMacAddr client_mac: sMacAddr -cACTION_CLI_CLIENT_CHANNEL_LOAD_11K_REQUEST: - _type: class - hostap_mac: sMacAddr - client_mac: sMacAddr - channel: uint8_t - cACTION_CLI_CLIENT_BEACON_11K_REQUEST: _type: class client_mac: sMacAddr From f1848cdf1c9aa1913a1e3d4edf3c0c094f6563f3 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 17 Jul 2020 16:00:24 +0300 Subject: [PATCH 303/453] controller: cli: Remove deprecated cli command https://jira.prplfoundation.org/browse/PPM-289 Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/cli/beerocks_cli_bml.cpp | 37 ------------------- .../src/beerocks/cli/beerocks_cli_bml.h | 3 -- 2 files changed, 40 deletions(-) diff --git a/controller/src/beerocks/cli/beerocks_cli_bml.cpp b/controller/src/beerocks/cli/beerocks_cli_bml.cpp index 2ae4084a5b..7883fe482b 100644 --- a/controller/src/beerocks/cli/beerocks_cli_bml.cpp +++ b/controller/src/beerocks/cli/beerocks_cli_bml.cpp @@ -418,8 +418,6 @@ void cli_bml::setFunctionsMapAndArray() insertCommandToMap("bml_wps_onboarding", "[]", "Start WPS onboarding process on 'iface' or all ifaces in case of empty.", static_cast(&cli_bml::wps_onboarding_caller), 0, 1, STRING_ARG); - insertCommandToMap("bml_get_device_info", "", "Get device information", - static_cast(&cli_bml::get_device_info_caller), 0, 0); insertCommandToMap("bml_get_bml_version", "", "prints bml version", static_cast(&cli_bml::get_bml_version_caller), 0, 0); insertCommandToMap("bml_get_master_slave_versions", "", @@ -1014,8 +1012,6 @@ int cli_bml::wps_onboarding_caller(int numOfArgs) return wps_onboarding(args.stringArgs[0]); } -int cli_bml::get_device_info_caller(int numOfArgs) { return get_device_info(); } - int cli_bml::get_bml_version_caller(int numOfArgs) { if (numOfArgs != 0) @@ -1592,39 +1588,6 @@ int cli_bml::wps_onboarding(std::string iface) return 0; } -int cli_bml::get_device_info() -{ - BML_DEVICE_INFO device_info; - int ret = bml_get_device_info(ctx, &device_info); - - std::cout << "Manufacturer : " << device_info.manufacturer << std::endl; - std::cout << "Model Name : " << device_info.model_name << std::endl; - std::cout << "Serial Number: " << device_info.serial_number << std::endl; - - std::cout << "LAN : "; - if (device_info.lan_iface_name[0]) { - std::cout << device_info.lan_iface_name << " (" - << network_utils::ipv4_to_string(device_info.lan_ip_address) << "/" - << network_utils::ipv4_to_string(device_info.lan_network_mask) << ")"; - } else { - std::cout << "N/A"; - } - std::cout << std::endl; - - std::cout << "WAN : "; - if (device_info.wan_iface_name[0]) { - std::cout << device_info.wan_iface_name << " (" - << network_utils::ipv4_to_string(device_info.wan_ip_address) << "/" - << network_utils::ipv4_to_string(device_info.wan_network_mask) << ")"; - } else { - std::cout << "N/A"; - } - std::cout << std::endl; - - printBmlReturnVals("bml_get_device_info", ret); - return 0; -} - int cli_bml::get_bml_version() { std::string ver = bml_get_bml_version(); diff --git a/controller/src/beerocks/cli/beerocks_cli_bml.h b/controller/src/beerocks/cli/beerocks_cli_bml.h index 26d3684617..a368d1c382 100644 --- a/controller/src/beerocks/cli/beerocks_cli_bml.h +++ b/controller/src/beerocks/cli/beerocks_cli_bml.h @@ -117,8 +117,6 @@ class cli_bml : public cli { int get_onboarding_state_caller(int numOfArgs); int wps_onboarding_caller(int numOfArgs); - int get_device_info_caller(int numOfArgs); - int get_bml_version_caller(int numOfArgs); int get_master_slave_versions_caller(int numOfArgs); @@ -173,7 +171,6 @@ class cli_bml : public cli { int get_onboarding_state(); int wps_onboarding(const std::string iface = std::string()); - int get_device_info(); int get_bml_version(); int get_master_slave_versions(); From 6e7155feb3190a7c1154e3fab47f70c1c927ffa2 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 17 Jul 2020 15:59:05 +0300 Subject: [PATCH 304/453] controller: bml: Remove deprecat4ed methods Need to remove deprecated methods: bml_get_device_info bml_get_serial_number https://jira.prplfoundation.org/browse/PPM-289 Signed-off-by: Vladyslav Tupikin --- controller/src/beerocks/bml/bml.cpp | 31 ----------------------------- controller/src/beerocks/bml/bml.h | 22 -------------------- 2 files changed, 53 deletions(-) diff --git a/controller/src/beerocks/bml/bml.cpp b/controller/src/beerocks/bml/bml.cpp index d0094e8859..9f5ddb4a49 100644 --- a/controller/src/beerocks/bml/bml.cpp +++ b/controller/src/beerocks/bml/bml.cpp @@ -304,37 +304,6 @@ int bml_get_administrator_credentials(BML_CTX ctx, char *user_password) return (pBML->get_administrator_credentials(user_password)); } -int bml_get_serial_number(BML_CTX ctx, char *serial_number) -{ - // Validate input parameters - if (!ctx || !serial_number) - return (-BML_RET_INVALID_ARGS); - - bml_internal *pBML = (bml_internal *)ctx; - - BML_DEVICE_INFO device_info; - auto ret = pBML->get_device_info(device_info); - if (ret != 0) { - return ret; - } - - // Copy only the serial number - beerocks::string_utils::copy_string(serial_number, device_info.serial_number, BML_DEV_INFO_LEN); - - return 0; -} - -int bml_get_device_info(BML_CTX ctx, BML_DEVICE_INFO *device_info) -{ - // Validate input parameters - if (!ctx || !device_info) - return (-BML_RET_INVALID_ARGS); - - bml_internal *pBML = (bml_internal *)ctx; - - return (pBML->get_device_info(*device_info)); -} - int bml_set_client_roaming(BML_CTX ctx, int enable) { // Validate input parameters diff --git a/controller/src/beerocks/bml/bml.h b/controller/src/beerocks/bml/bml.h index fa62ad23be..c17056b790 100644 --- a/controller/src/beerocks/bml/bml.h +++ b/controller/src/beerocks/bml/bml.h @@ -228,28 +228,6 @@ int bml_wps_onboarding(BML_CTX ctx, const char *iface); int bml_get_administrator_credentials(BML_CTX ctx, char *user_password); -/** - * Get serial number of the device - * NOTE: DEPRECATED - Use bml_get_device_info() instead. - * - * @param [in] ctx BML Context. - * @param [out] serial_number[BML_NODE_SERIAL_NUMBER_LEN] The serial number of the device - * - * @return BML_RET_OK on success. - */ -int __attribute__((deprecated)) bml_get_serial_number(BML_CTX ctx, char *serial_number); - -/** - * Get generic device information. - * - * @param [in] ctx BML Context. - * @param [out] device_info Device information structure. - * - * @return BML_RET_OK on success. - */ - -int bml_get_device_info(BML_CTX ctx, struct BML_DEVICE_INFO *device_info); - /** * Enables or disables beerocks roaming. * From b1e8228fba0eca248a66c3e29ab177b730cd2584 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 17 Jul 2020 15:52:26 +0300 Subject: [PATCH 305/453] controller: bml_internal: Remove get_device_info() Need to remove get_device_info() method because it is deprecated and no longer needed. https://jira.prplfoundation.org/browse/PPM-289 Signed-off-by: Vladyslav Tupikin --- .../beerocks/bml/internal/bml_internal.cpp | 68 ------------------- .../src/beerocks/bml/internal/bml_internal.h | 3 - 2 files changed, 71 deletions(-) diff --git a/controller/src/beerocks/bml/internal/bml_internal.cpp b/controller/src/beerocks/bml/internal/bml_internal.cpp index bcb2e3c052..0f515ced3d 100644 --- a/controller/src/beerocks/bml/internal/bml_internal.cpp +++ b/controller/src/beerocks/bml/internal/bml_internal.cpp @@ -2807,74 +2807,6 @@ int bml_internal::get_administrator_credentials(char *user_password) return (iRet); } -int bml_internal::get_device_info(BML_DEVICE_INFO &device_info) -{ - // If the socket is not valid, attempt to re-establish the connection - if (m_sockPlatform == nullptr && !connect_to_platform()) { - return (-BML_RET_CONNECT_FAIL); - } - - // Initialize the promise for receiving the response - beerocks::promise prmDeviceInfoGet; - m_prmDeviceInfoGet = &prmDeviceInfoGet; - int iOpTimeout = RESPONSE_TIMEOUT; // Default timeout - - beerocks_message::sDeviceInfo DeviceInfo; - m_device_info = &DeviceInfo; - - //CMDU message - auto request = - message_com::create_vs_message( - cmdu_tx); - - if (request == nullptr) { - LOG(ERROR) << "Failed building ACTION_PLATFORM_DEVICE_INFO_GET_REQUEST message!"; - return (-BML_RET_OP_FAILED); - } - - if (!message_com::send_cmdu(m_sockPlatform, cmdu_tx)) { - LOG(ERROR) << "Failed sending ACTION_PLATFORM_DEVICE_INFO_GET_REQUEST message!"; - return (-BML_RET_OP_FAILED); - } - - int iRet = BML_RET_OK; - - if (!prmDeviceInfoGet.wait_for(iOpTimeout)) { - LOG(WARNING) << "Timeout while waiting for device info get response..."; - iRet = -BML_RET_TIMEOUT; - } - - // Clear the credentials member - m_device_info = nullptr; - - // Clear the promise holder - m_prmDeviceInfoGet = nullptr; - - string_utils::copy_string(device_info.manufacturer, DeviceInfo.manufacturer, BML_DEV_INFO_LEN); - string_utils::copy_string(device_info.model_name, DeviceInfo.model_name, BML_DEV_INFO_LEN); - string_utils::copy_string(device_info.serial_number, DeviceInfo.serial_number, - BML_DEV_INFO_LEN); - - // LAN - string_utils::copy_string(device_info.lan_iface_name, DeviceInfo.lan_iface_name, - BML_IFACE_NAME_LEN); - device_info.lan_ip_address = DeviceInfo.lan_ip_address; - device_info.lan_network_mask = DeviceInfo.lan_network_mask; - - // WAN - string_utils::copy_string(device_info.wan_iface_name, DeviceInfo.wan_iface_name, - BML_IFACE_NAME_LEN); - device_info.wan_ip_address = DeviceInfo.wan_ip_address; - device_info.wan_network_mask = DeviceInfo.wan_network_mask; - - if (iRet != BML_RET_OK) { - LOG(ERROR) << "Device information get failed!"; - return (iRet); - } - - return (iRet); -} - int bml_internal::set_client_roaming(bool enable) { //CMDU message diff --git a/controller/src/beerocks/bml/internal/bml_internal.h b/controller/src/beerocks/bml/internal/bml_internal.h index 06124416c9..4425072216 100644 --- a/controller/src/beerocks/bml/internal/bml_internal.h +++ b/controller/src/beerocks/bml/internal/bml_internal.h @@ -106,9 +106,6 @@ class bml_internal : public beerocks::socket_thread { // Get administrator user credentials int get_administrator_credentials(char *user_password); - // Get device information - int get_device_info(BML_DEVICE_INFO &device_info); - // Enable/Disable client roaming int set_client_roaming(bool enable); From b9c3e7538732c3ea5577d33b0279ab4c4e6e0a72 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 17 Jul 2020 13:28:34 +0300 Subject: [PATCH 306/453] controller: bml: Remove case from process_cmdu_header() Need to remove case for rocessing deprecated vendor-specific message ACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE from bml_internal::process_cmdu_header() method. https://jira.prplfoundation.org/browse/PPM-289 Signed-off-by: Vladyslav Tupikin --- .../beerocks/bml/internal/bml_internal.cpp | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/controller/src/beerocks/bml/internal/bml_internal.cpp b/controller/src/beerocks/bml/internal/bml_internal.cpp index 0f515ced3d..346e872a20 100644 --- a/controller/src/beerocks/bml/internal/bml_internal.cpp +++ b/controller/src/beerocks/bml/internal/bml_internal.cpp @@ -1297,29 +1297,6 @@ int bml_internal::process_cmdu_header(std::shared_ptr beerocks_ << "Received ADMIN_CREDENTIALS_GET_RESPONSE response, but no one is waiting..."; } } break; - case beerocks_message::ACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE: { - auto response = - beerocks_header - ->addClass(); - if (response == nullptr) { - LOG(ERROR) << "addClass cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE failed"; - return BML_RET_OP_FAILED; - } - // Signal any waiting threads - if (m_prmDeviceInfoGet) { - if (m_device_info != nullptr) { - *m_device_info = response->params(); - m_prmDeviceInfoGet->set_value(response->result() == 0); - } else { - m_prmDeviceInfoGet->set_value(0); - } - m_prmDeviceInfoGet = nullptr; - } else { - LOG(WARNING) - << "Received SERIAL_NUMBER_GET_RESPONSE response, but no one is waiting..."; - } - return BML_RET_OP_FAILED; - } break; case beerocks_message::ACTION_PLATFORM_GET_MASTER_SLAVE_VERSIONS_RESPONSE: { auto response = beerocks_header->addClass< beerocks_message::cACTION_PLATFORM_GET_MASTER_SLAVE_VERSIONS_RESPONSE>(); From 014a47d8f7b011099d606e9fec299c038e76bc3a Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 17 Jul 2020 13:20:07 +0300 Subject: [PATCH 307/453] agent: platform_manager: Remove case from handle_cmdu() Need to remove case for deprecated vendor-specific message ACTION_PLATFORM_DEVICE_INFO_GET_REQUEST from ain_thread::handle_cmdu() method. https://jira.prplfoundation.org/browse/PPM-289 Signed-off-by: Vladyslav Tupikin --- .../platform_manager_thread.cpp | 48 ------------------- 1 file changed, 48 deletions(-) diff --git a/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp b/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp index e160d8f148..135dc43968 100644 --- a/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp +++ b/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp @@ -1002,54 +1002,6 @@ bool main_thread::handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_rx) iface); } break; - case beerocks_message::ACTION_PLATFORM_DEVICE_INFO_GET_REQUEST: { - // Request message - LOG(TRACE) << "ACTION_PLATFORM_DEVICE_INFO_GET_REQUEST"; - - auto response = message_com::create_vs_message< - beerocks_message::cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE>(cmdu_tx); - - if (response == nullptr) { - LOG(ERROR) << "Failed building message!"; - break; - } - - auto ¶ms = response->params(); - memset(¶ms, 0, sizeof(params)); - - bpl::BPL_DEVICE_INFO bpl_device_info; - - if (bpl::cfg_get_device_info(&bpl_device_info) < 0) { - LOG(ERROR) << "Failed reading device information!"; - response->result() = 0; - } else { - response->result() = 1; - } - - string_utils::copy_string(params.manufacturer, bpl_device_info.manufacturer, - message::DEV_INFO_STR_MAX_LEN); - string_utils::copy_string(params.model_name, bpl_device_info.model_name, - message::DEV_INFO_STR_MAX_LEN); - string_utils::copy_string(params.serial_number, bpl_device_info.serial_number, - message::DEV_INFO_STR_MAX_LEN); - - // LAN - string_utils::copy_string(params.lan_iface_name, bpl_device_info.lan_iface_name, - message::IFACE_NAME_LENGTH); - params.lan_ip_address = bpl_device_info.lan_ip_address; - params.lan_network_mask = bpl_device_info.lan_network_mask; - - // WAN - string_utils::copy_string(params.wan_iface_name, bpl_device_info.wan_iface_name, - message::IFACE_NAME_LENGTH); - params.wan_ip_address = bpl_device_info.wan_ip_address; - params.wan_network_mask = bpl_device_info.wan_network_mask; - - // Sent with unsafe because BML is reachable only on platform thread - message_com::send_cmdu(sd, cmdu_tx); - - } break; - case beerocks_message::ACTION_PLATFORM_ERROR_NOTIFICATION: { auto error = beerocks_header->addClass(); From da03ca79381b3742824762c5c322737896643294 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 17 Jul 2020 13:17:20 +0300 Subject: [PATCH 308/453] commont: tlvf: Remove useless code from autogenerated files https://jira.prplfoundation.org/browse/PPM-289 Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 2 - .../beerocks/tlvf/beerocks_message_platform.h | 42 ------ .../tlvf/beerocks_message_platform.cpp | 139 ------------------ 3 files changed, 183 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index 17a3b7c128..228c5512fa 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -155,8 +155,6 @@ enum eActionOp_PLATFORM: uint8_t { ACTION_PLATFORM_WIFI_CREDENTIALS_GET_RESPONSE = 0xf, ACTION_PLATFORM_ADMIN_CREDENTIALS_GET_REQUEST = 0x10, ACTION_PLATFORM_ADMIN_CREDENTIALS_GET_RESPONSE = 0x11, - ACTION_PLATFORM_DEVICE_INFO_GET_REQUEST = 0x12, - ACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE = 0x13, ACTION_PLATFORM_LOCAL_MASTER_GET_REQUEST = 0x14, ACTION_PLATFORM_LOCAL_MASTER_GET_RESPONSE = 0x15, ACTION_PLATFORM_WLAN_PARAMS_CHANGED_NOTIFICATION = 0x1a, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_platform.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_platform.h index 91eb7c0e8c..7af51a48f4 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_platform.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_platform.h @@ -412,48 +412,6 @@ class cACTION_PLATFORM_ADMIN_CREDENTIALS_GET_RESPONSE : public BaseClass uint32_t* m_result = nullptr; }; -class cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST : public BaseClass -{ - public: - cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST(std::shared_ptr base, bool parse = false); - ~cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST(); - - static eActionOp_PLATFORM get_action_op(){ - return (eActionOp_PLATFORM)(ACTION_PLATFORM_DEVICE_INFO_GET_REQUEST); - } - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_PLATFORM* m_action_op = nullptr; -}; - -class cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE : public BaseClass -{ - public: - cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE(std::shared_ptr base, bool parse = false); - ~cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE(); - - static eActionOp_PLATFORM get_action_op(){ - return (eActionOp_PLATFORM)(ACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE); - } - sDeviceInfo& params(); - uint32_t& result(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_PLATFORM* m_action_op = nullptr; - sDeviceInfo* m_params = nullptr; - uint32_t* m_result = nullptr; -}; - class cACTION_PLATFORM_LOCAL_MASTER_GET_REQUEST : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_platform.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_platform.cpp index eaa7a0e2f7..ab4a1dcc10 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_platform.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_platform.cpp @@ -1346,145 +1346,6 @@ bool cACTION_PLATFORM_ADMIN_CREDENTIALS_GET_RESPONSE::init() return true; } -cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST::cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST::cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST::~cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST() { -} -void cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_PLATFORM), reinterpret_cast(m_action_op)); -} - -bool cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST::get_initial_size() -{ - size_t class_size = 0; - return class_size; -} - -bool cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - if (m_parse__) { class_swap(); } - return true; -} - -cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE::cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE::cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE::~cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE() { -} -sDeviceInfo& cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE::params() { - return (sDeviceInfo&)(*m_params); -} - -uint32_t& cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE::result() { - return (uint32_t&)(*m_result); -} - -void cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_PLATFORM), reinterpret_cast(m_action_op)); - m_params->struct_swap(); - tlvf_swap(32, reinterpret_cast(m_result)); -} - -bool cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sDeviceInfo); // params - class_size += sizeof(uint32_t); // result - return class_size; -} - -bool cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_params = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sDeviceInfo))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sDeviceInfo) << ") Failed!"; - return false; - } - if (!m_parse__) { m_params->struct_init(); } - m_result = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint32_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint32_t) << ") Failed!"; - return false; - } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_PLATFORM_LOCAL_MASTER_GET_REQUEST::cACTION_PLATFORM_LOCAL_MASTER_GET_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); From 9393223d5c1c20091b29232eb09db2a9b6c396b2 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 17 Jul 2020 13:12:14 +0300 Subject: [PATCH 309/453] common: tlvf: Remove ACTION_PLATFORM_DEVICE_INFO_ Need to remove next deprecated vendor-specific messages: ACTION_PLATFORM_DEVICE_INFO_GET_REQUEST ACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE https://jira.prplfoundation.org/browse/PPM-289 Signed-off-by: Vladyslav Tupikin --- .../yaml/beerocks/tlvf/beerocks_message_action.yaml | 3 --- .../yaml/beerocks/tlvf/beerocks_message_platform.yaml | 11 ----------- 2 files changed, 14 deletions(-) diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index d472c7266f..d0e5882bba 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -170,9 +170,6 @@ eActionOp_PLATFORM: ACTION_PLATFORM_ADMIN_CREDENTIALS_GET_REQUEST: 16 ACTION_PLATFORM_ADMIN_CREDENTIALS_GET_RESPONSE: 17 - ACTION_PLATFORM_DEVICE_INFO_GET_REQUEST: 18 - ACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE: 19 - ACTION_PLATFORM_LOCAL_MASTER_GET_REQUEST: 20 ACTION_PLATFORM_LOCAL_MASTER_GET_RESPONSE: 21 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_platform.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_platform.yaml index b45ffa1bc3..5764402e77 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_platform.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_platform.yaml @@ -99,16 +99,6 @@ cACTION_PLATFORM_ADMIN_CREDENTIALS_GET_RESPONSE: _type: uint32_t _comment: # 0 - Failure, 1 - Success -cACTION_PLATFORM_DEVICE_INFO_GET_REQUEST: - _type: class - -cACTION_PLATFORM_DEVICE_INFO_GET_RESPONSE: - _type: class - params: sDeviceInfo - result: - _type: uint32_t - _comment: # 0 - Failure, 1 - Success - cACTION_PLATFORM_LOCAL_MASTER_GET_REQUEST: _type: class @@ -141,4 +131,3 @@ cACTION_PLATFORM_ERROR_NOTIFICATION: _type: char _length: [256] _comment: # Must match BPL_ERROR_STRING_LEN - From 76598074e75711da8ba9175f47dd2bd4571c8360 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 11:58:24 +0300 Subject: [PATCH 310/453] framework: bpl: Remove deprecated method Need to remove implementation for deprecated method in uci cfg_get_device_info(). https://jira.prplfoundation.org/browse/PPM-289 Signed-off-by: Vladyslav Tupikin --- framework/platform/bpl/uci/cfg/bpl_cfg.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp index 3a5ba6066f..6edb58462f 100644 --- a/framework/platform/bpl/uci/cfg/bpl_cfg.cpp +++ b/framework/platform/bpl/uci/cfg/bpl_cfg.cpp @@ -235,8 +235,6 @@ int cfg_get_client_roaming() return retVal; } -int cfg_get_device_info(BPL_DEVICE_INFO *device_info) { return 0; } - int cfg_get_wifi_params(const char iface[BPL_IFNAME_LEN], struct BPL_WLAN_PARAMS *wlan_params) { if (!iface || !wlan_params) { From b9270476638ffb2b49fc6745a36bfa82a597a3ee Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 12:00:17 +0300 Subject: [PATCH 311/453] framework: bpl: Remove deprecated method Need to remove deprecated method implementation for linux: cfg_get_device_info(). https://jira.prplfoundation.org/browse/PPM-289 Signed-off-by: Vladyslav Tupikin --- framework/platform/bpl/linux/bpl_cfg.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/framework/platform/bpl/linux/bpl_cfg.cpp b/framework/platform/bpl/linux/bpl_cfg.cpp index 93975c385a..35967e7792 100644 --- a/framework/platform/bpl/linux/bpl_cfg.cpp +++ b/framework/platform/bpl/linux/bpl_cfg.cpp @@ -221,8 +221,6 @@ int cfg_get_dfs_reentry() { return 0; } int cfg_get_client_roaming() { return 1; } -int cfg_get_device_info(BPL_DEVICE_INFO *device_info) { return RETURN_ERR; } - int cfg_get_wifi_params(const char *iface, struct BPL_WLAN_PARAMS *wlan_params) { if (!iface || !wlan_params) { From 719dda8f0c26fe0f0e38a7d9b119cde66fa66b38 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 12:01:24 +0300 Subject: [PATCH 312/453] framework: bpl: Remove deprecated structure Need to remove deprecated structure BPL_DEVICE_INFO and prototype for deprecated method cfg_get_device_info(). https://jira.prplfoundation.org/browse/PPM-289 Signed-off-by: Vladyslav Tupikin --- framework/platform/bpl/include/bpl/bpl_cfg.h | 41 -------------------- 1 file changed, 41 deletions(-) diff --git a/framework/platform/bpl/include/bpl/bpl_cfg.h b/framework/platform/bpl/include/bpl/bpl_cfg.h index e1ab131aba..3e3446a08d 100644 --- a/framework/platform/bpl/include/bpl/bpl_cfg.h +++ b/framework/platform/bpl/include/bpl/bpl_cfg.h @@ -121,37 +121,6 @@ struct BPL_ERROR { char data[BPL_ERROR_STRING_LEN]; }; -/* Generic device information */ -struct BPL_DEVICE_INFO { - - /* Device manufacturer name (e.g. Intel Corporation) */ - char manufacturer[BPL_DEV_INFO_LEN]; - - /* Device model name */ - char model_name[BPL_DEV_INFO_LEN]; - - /* Device serial number */ - char serial_number[BPL_DEV_INFO_LEN]; - - /* LAN interface name */ - char lan_iface_name[BPL_IFNAME_LEN]; - - /* LAN interface IP address */ - uint32_t lan_ip_address; - - /* LAN interface network mask */ - uint32_t lan_network_mask; - - /* WAN interface name */ - char wan_iface_name[BPL_IFNAME_LEN]; - - /* WAN interface IP address */ - uint32_t wan_ip_address; - - /* WAN interface network mask */ - uint32_t wan_network_mask; -}; - /* Wi-Fi Credentials */ struct BPL_WIFI_CREDENTIALS { @@ -348,16 +317,6 @@ int cfg_get_dfs_reentry(); */ int cfg_get_client_roaming(); -/** - * Returns generic device information. - * - * @param [out] Device information structure. - * - * @return 0 Success. - * @return -1 Error. - */ -int cfg_get_device_info(struct BPL_DEVICE_INFO *device_info); - /** * Returns miscellaneous Wi-Fi parameters. * From f1fe72fbbf8dd7bcf2d5cf25ac68e2887dd9d045 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 12:26:00 +0300 Subject: [PATCH 313/453] controller: bml: Remove deprecated structure Need to remove deprecated structure BML_DEVICE_INFO and deprecated variables: m_prmDeviceInfoGet m_device_info https://jira.prplfoundation.org/browse/PPM-289 Signed-off-by: Vladyslav Tupikin --- controller/src/beerocks/bml/bml_defs.h | 34 ------------------- .../src/beerocks/bml/internal/bml_internal.h | 2 -- 2 files changed, 36 deletions(-) diff --git a/controller/src/beerocks/bml/bml_defs.h b/controller/src/beerocks/bml/bml_defs.h index d005b82cbb..9e080d44ff 100644 --- a/controller/src/beerocks/bml/bml_defs.h +++ b/controller/src/beerocks/bml/bml_defs.h @@ -38,7 +38,6 @@ extern "C" { #define BML_IP_ADDR_LEN 4 /* IP Address Length */ #define BML_VERSION_LEN 16 /* Version Length */ #define BML_IFACE_NAME_LEN (32 + 4) /* Maximal interface name length (32) + null termination */ -#define BML_DEV_INFO_LEN 32 /* Device information string length */ /* BML Node Types */ #define BML_NODE_TYPE_GW 1 /* GW Node */ @@ -175,39 +174,6 @@ struct BML_VAP_INFO { char key[BML_PASS_MAX_LENGTH]; }; -/** - * Device information. - */ -struct BML_DEVICE_INFO { - - /* Device manufacturer name (e.g. Intel Corporation) */ - char manufacturer[BML_DEV_INFO_LEN]; - - /* Device model name */ - char model_name[BML_DEV_INFO_LEN]; - - /* Device serial number */ - char serial_number[BML_DEV_INFO_LEN]; - - /* LAN interface name */ - char lan_iface_name[BML_IFACE_NAME_LEN]; - - /* LAN interface IP address */ - uint32_t lan_ip_address; - - /* LAN interface network mask */ - uint32_t lan_network_mask; - - /* WAN interface name */ - char wan_iface_name[BML_IFACE_NAME_LEN]; - - /* WAN interface IP address */ - uint32_t wan_ip_address; - - /* WAN interface network mask */ - uint32_t wan_network_mask; -}; - /** * A structure representing a node in the network map. */ diff --git a/controller/src/beerocks/bml/internal/bml_internal.h b/controller/src/beerocks/bml/internal/bml_internal.h index 4425072216..ab0964881d 100644 --- a/controller/src/beerocks/bml/internal/bml_internal.h +++ b/controller/src/beerocks/bml/internal/bml_internal.h @@ -349,7 +349,6 @@ class bml_internal : public beerocks::socket_thread { beerocks::promise *m_prmWiFiCredentialsClear = nullptr; beerocks::promise *m_prmWiFiCredentialsGet = nullptr; beerocks::promise *m_prmAdminCredentialsGet = nullptr; - beerocks::promise *m_prmDeviceInfoGet = nullptr; beerocks::promise *m_prmDeviceDataGet = nullptr; beerocks::promise *m_prmMasterSlaveVersions = nullptr; beerocks::promise *m_prmLocalMasterGet = nullptr; @@ -370,7 +369,6 @@ class bml_internal : public beerocks::socket_thread { BML_STATS_UPDATE_CB m_cbStatsUpdate = nullptr; BML_EVENT_CB m_cbEvent = nullptr; - beerocks_message::sDeviceInfo *m_device_info = nullptr; beerocks_message::sDeviceData *m_device_data = nullptr; beerocks_message::sWifiCredentials *m_wifi_credentials = nullptr; beerocks_message::sAdminCredentials *m_admin_credentials = nullptr; From 24ea670a927391191b22a05266648b6692442d31 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 12:29:49 +0300 Subject: [PATCH 314/453] common: tlvf: Modify autogenerated file https://jira.prplfoundation.org/browse/PPM-289 Signed-off-by: Vladyslav Tupikin --- .../include/beerocks/tlvf/beerocks_message_common.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h index 3e4fea8e48..f5df12a63f 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h @@ -858,16 +858,6 @@ typedef struct sOnboarding { typedef struct sAdminCredentials { char user_password[beerocks::message::USER_PASS_LEN]; - void struct_swap(){ - } - void struct_init(){ - } -} __attribute__((packed)) sAdminCredentials; - -typedef struct sDeviceInfo { - char manufacturer[beerocks::message::DEV_INFO_STR_MAX_LEN]; - char model_name[beerocks::message::DEV_INFO_STR_MAX_LEN]; - char serial_number[beerocks::message::DEV_INFO_STR_MAX_LEN]; char lan_iface_name[beerocks::message::IFACE_NAME_LENGTH]; uint32_t lan_ip_address; uint32_t lan_network_mask; @@ -882,7 +872,7 @@ typedef struct sDeviceInfo { } void struct_init(){ } -} __attribute__((packed)) sDeviceInfo; +} __attribute__((packed)) sAdminCredentials; typedef struct sIfaceInfo { char iface_name[beerocks::message::IFACE_NAME_LENGTH]; From 16219d224f71965ac0584ad2caec62350b91246f Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 12:30:44 +0300 Subject: [PATCH 315/453] common: tlvf: Remove deprecated structure sDeviceInfo https://jira.prplfoundation.org/browse/PPM-289 Signed-off-by: Vladyslav Tupikin --- .../yaml/beerocks/tlvf/beerocks_message_common.yaml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml index f93e34a4b4..31435860fe 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml @@ -631,18 +631,6 @@ sAdminCredentials: _type: char _length: ["beerocks::message::USER_PASS_LEN"] -sDeviceInfo: - _type: struct - manufacturer: - _type: char - _length: ["beerocks::message::DEV_INFO_STR_MAX_LEN"] - model_name: - _type: char - _length: ["beerocks::message::DEV_INFO_STR_MAX_LEN"] - serial_number: - _type: char - _length: ["beerocks::message::DEV_INFO_STR_MAX_LEN"] - lan_iface_name: _type: char _length: ["beerocks::message::IFACE_NAME_LENGTH"] From 9258329cbb6655b482fdab24da1a11e859ed0c6c Mon Sep 17 00:00:00 2001 From: Alex Kanter Date: Mon, 20 Jul 2020 16:21:02 +0000 Subject: [PATCH 316/453] prplwrt: feed_wlan_6x: bump tag Starting hostapd with start_disabled flag enabled on main vap could result in unexpected behavior after CAC is performed. New feed_wlan_6x tag points to swpal fork repo that includes the fix in which netifd wireless script updated not to set start_disabled flag for main vaps in repeater (station) mode. https://intel.prpl.dev/prplmesh/swpal ugw-8.4.1 main branch is this fork is going to be used from now on for all required swpal changes for prplwrt platforms. Signed-off-by: Alex Kanter --- tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml b/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml index b228190ec1..aefeee532e 100644 --- a/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml +++ b/tools/docker/builder/openwrt/profiles_feeds/netgear-rax40.yml @@ -15,7 +15,7 @@ hash: af078af5408654ca2e759ea7afcf92163282e86e - name: feed_wlan_6x uri: https://intel.prpl.dev/prplmesh/feed_wlan_6x.git - hash: dddeadc60130cf90b620b36719b8cfe267555bee + hash: f68c49704bd518b8808167cdfea012c5d400f6d3 - name: feed_prpl uri: https://git.prpl.dev/prplmesh/feed-prpl.git hash: 89e6602655713f8487c72d8d636daa610d76a468 From 6c9becfb2d35ca8356f1178b80996841c2c27357 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Tue, 21 Jul 2020 07:19:56 +0000 Subject: [PATCH 317/453] agent: Remove internal agent son_slave_watchdog The Agent has an internal watchdog that is responsible for monitoring the son_slaves processes and brings them up in case they are down. Since a son_slave for each front radio interface will not be anymore, the watchdog mechanism on the agent process is removed. PPM-304 Signed-off-by: Moran Shoeg --- .../beerocks/slave/beerocks_slave_main.cpp | 50 ------------------- 1 file changed, 50 deletions(-) diff --git a/agent/src/beerocks/slave/beerocks_slave_main.cpp b/agent/src/beerocks/slave/beerocks_slave_main.cpp index 5b18a4f9b6..05f59f051c 100644 --- a/agent/src/beerocks/slave/beerocks_slave_main.cpp +++ b/agent/src/beerocks/slave/beerocks_slave_main.cpp @@ -173,38 +173,6 @@ static void fill_son_slave_config(const beerocks::config_file::sConfigSlave &bee son_slave_conf.stop_on_failure_attempts = 0; } -static void son_slave_watchdog(const std::string &beerocks_slave_temp_path, - const std::unordered_map &interfaces_map) -{ - for (int slave_num = 0; slave_num < beerocks::IRE_MAX_SLAVES; slave_num++) { - auto hostap_iface_elm = interfaces_map.find(slave_num); - // if slave_num not mapped - if (hostap_iface_elm == interfaces_map.end()) { - continue; - } - - std::string hostap_iface = hostap_iface_elm->second; - // if slave has no interface configured - if (hostap_iface.empty()) { - continue; - } - // check if slave is still running - std::string base_name = std::string(BEEROCKS_AGENT) + "_" + hostap_iface; - std::string temp_path(beerocks_slave_temp_path); - if (!beerocks::os_utils::is_pid_running(temp_path, base_name)) { - //start new slave process - std::string file_name = "./" + std::string(BEEROCKS_AGENT); - if (access(file_name.c_str(), F_OK) == -1) { //file does not exist in current location - file_name = BEEROCKS_BIN_PATH + std::string(BEEROCKS_AGENT); - } - std::string cmd = file_name + " -i " + hostap_iface; - LOG(DEBUG) << "son_slave_watchdog(): sending SYSTEM_CALL with cmd = " << cmd - << std::endl; - beerocks::SYSTEM_CALL(cmd, 2, true); - } - } -} - static int system_hang_test(const beerocks::config_file::sConfigSlave &beerocks_slave_conf, int argc, char *argv[]) { @@ -329,10 +297,6 @@ static int run_beerocks_slave(beerocks::config_file::sConfigSlave &beerocks_slav if (!backhaul_mgr.start()) { LOG(ERROR) << "backhaul_mgr.start()"; } else { - //initialize watchdog timers - int son_slave_watchdog_time_elapsed_ms = 0; - std::chrono::steady_clock::time_point son_slave_watchdog_time = - std::chrono::steady_clock::now(); auto touch_time_stamp_timeout = std::chrono::steady_clock::now(); while (g_running) { @@ -350,20 +314,6 @@ static int run_beerocks_slave(beerocks::config_file::sConfigSlave &beerocks_slav std::chrono::seconds(beerocks::TOUCH_PID_TIMEOUT_SECONDS); } - if (stop_on_failure_attempts > 0 && - beerocks_slave_conf.enable_son_slaves_watchdog == "1") { - //son_slave_watchdog periodic check son_slave pids are running - son_slave_watchdog_time_elapsed_ms = - std::chrono::duration_cast( - std::chrono::steady_clock::now() - son_slave_watchdog_time) - .count(); - if (son_slave_watchdog_time_elapsed_ms >= - beerocks::SON_SLAVE_WATCHDOG_INTERVAL_MSC) { - son_slave_watchdog(beerocks_slave_conf.temp_path, interfaces_map); - son_slave_watchdog_time = std::chrono::steady_clock::now(); - } - } - // Check if backhaul manager still running and break on error if (!backhaul_mgr.is_running()) { break; From 213140d9b5670677e8fcc1fc9d323d0e810144dc Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Tue, 21 Jul 2020 07:26:48 +0000 Subject: [PATCH 318/453] agent: Remove son_slave watchdog configuration The previous commit removed son_slave watchdog. Remove the son_slave watchdog from the Agent configuration file since it is no longer needed. PPM-304 Signed-off-by: Moran Shoeg --- agent/config/beerocks_agent.conf.in | 1 - common/beerocks/bcl/include/bcl/beerocks_config_file.h | 1 - common/beerocks/bcl/source/beerocks_config_file.cpp | 1 - 3 files changed, 3 deletions(-) diff --git a/agent/config/beerocks_agent.conf.in b/agent/config/beerocks_agent.conf.in index 0b6ddae91d..ff8689f93d 100644 --- a/agent/config/beerocks_agent.conf.in +++ b/agent/config/beerocks_agent.conf.in @@ -16,7 +16,6 @@ enable_arp_monitor=0 enable_keep_alive=1 bridge_iface=@BEEROCKS_BRIDGE_IFACE@ enable_system_hang_test=0 # 0 - disabled -enable_son_slaves_watchdog=0 # 0 - disabled [backhaul] backhaul_preferred_bssid= diff --git a/common/beerocks/bcl/include/bcl/beerocks_config_file.h b/common/beerocks/bcl/include/bcl/beerocks_config_file.h index a5920029a9..0a008900fe 100644 --- a/common/beerocks/bcl/include/bcl/beerocks_config_file.h +++ b/common/beerocks/bcl/include/bcl/beerocks_config_file.h @@ -100,7 +100,6 @@ class config_file { std::string backhaul_wire_iface; std::string backhaul_wire_iface_type; std::string enable_system_hang_test; - std::string enable_son_slaves_watchdog; std::string const_backhaul_slave; //[slaveX] std::string radio_identifier[IRE_MAX_SLAVES]; // mAP RUID diff --git a/common/beerocks/bcl/source/beerocks_config_file.cpp b/common/beerocks/bcl/source/beerocks_config_file.cpp index 4c82b4caed..8b43757f11 100644 --- a/common/beerocks/bcl/source/beerocks_config_file.cpp +++ b/common/beerocks/bcl/source/beerocks_config_file.cpp @@ -154,7 +154,6 @@ bool config_file::read_slave_config_file(const std::string &config_file_path, sC std::make_tuple("enable_keep_alive=", &conf.enable_keep_alive, mandatory_slave), std::make_tuple("bridge_iface=", &conf.bridge_iface, 0), std::make_tuple("enable_system_hang_test=", &conf.enable_system_hang_test, 0), - std::make_tuple("enable_son_slaves_watchdog=", &conf.enable_son_slaves_watchdog, 0), std::make_tuple("const_backhaul_slave=", &conf.const_backhaul_slave, 0), }; std::string config_type = "global"; From 8929c4f5e33c5bd88626e0cc21129368a8157e33 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Tue, 21 Jul 2020 09:23:11 +0000 Subject: [PATCH 319/453] agent: Remove code that creates son_slaves processes Remove the code that creates processes of son_slave to each front radio interface. This commit breaks the operationality of the code, to make the PR easier for review. PPM-304 Signed-off-by: Moran Shoeg --- .../beerocks/slave/beerocks_slave_main.cpp | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/agent/src/beerocks/slave/beerocks_slave_main.cpp b/agent/src/beerocks/slave/beerocks_slave_main.cpp index 05f59f051c..eaad97278d 100644 --- a/agent/src/beerocks/slave/beerocks_slave_main.cpp +++ b/agent/src/beerocks/slave/beerocks_slave_main.cpp @@ -492,34 +492,6 @@ int main(int argc, char *argv[]) // killall running slave beerocks::os_utils::kill_pid(beerocks_slave_conf.temp_path, std::string(BEEROCKS_AGENT)); - // start all slave's - for (slave_num = 0; slave_num < beerocks::IRE_MAX_SLAVES; slave_num++) { - auto hostap_iface_elm = interfaces_map.find(slave_num); - // if slave_num not mapped - if (hostap_iface_elm == interfaces_map.end()) { - continue; - } - - std::string hostap_iface = hostap_iface_elm->second; - // if slave has no interface configured - if (hostap_iface.empty()) { - continue; - } - // killall running son slave's - std::string base_name = std::string(BEEROCKS_AGENT) + "_" + hostap_iface; - beerocks::os_utils::kill_pid(beerocks_slave_conf.temp_path, base_name); - - //start new slave process - LOG(INFO) << "Starting slave for iface '" << hostap_iface << "'"; - - std::string file_name = "./" + std::string(BEEROCKS_AGENT); - if (access(file_name.c_str(), F_OK) == -1) { //file does not exist in current location - file_name = BEEROCKS_BIN_PATH + std::string(BEEROCKS_AGENT); - } - std::string cmd = file_name + " -i " + hostap_iface; - beerocks::SYSTEM_CALL(cmd, 0, true); - } - // backhaul/platform manager slave return run_beerocks_slave(beerocks_slave_conf, interfaces_map, argc, argv); } From c021ff6258e17a695bf836b68ad3b93003019bf1 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Tue, 21 Jul 2020 14:04:02 +0000 Subject: [PATCH 320/453] agent: Initialize loggers Running two son_slaves on the main agent process requires some logging changes so the thread could continue to write to two different files. This is a temporary change until both son_slaves will be unified under the unified Agent thread. Copy init_logger() from the fronthaul manager's main file and use it on the Agent's main file. Add to the son_slaves new logger id so they will write to a different log file, and set it on the son_slave work() function. PPM-304 Signed-off-by: Moran Shoeg --- .../fronthaul_manager_main.cpp | 13 +- .../beerocks/slave/beerocks_slave_main.cpp | 144 ++++++++---------- agent/src/beerocks/slave/son_slave_thread.cpp | 6 + agent/src/beerocks/slave/son_slave_thread.h | 1 + 4 files changed, 83 insertions(+), 81 deletions(-) diff --git a/agent/src/beerocks/fronthaul_manager/fronthaul_manager_main.cpp b/agent/src/beerocks/fronthaul_manager/fronthaul_manager_main.cpp index d78ad9c3f9..e4d71f5399 100644 --- a/agent/src/beerocks/fronthaul_manager/fronthaul_manager_main.cpp +++ b/agent/src/beerocks/fronthaul_manager/fronthaul_manager_main.cpp @@ -113,6 +113,17 @@ static bool parse_arguments(int argc, char *argv[]) return true; } +/** + * @brief Create and initialize logging object and print the version. + * + * @param file_name File name of the log file. + * @param log_config Log file configuration. + * @param argc Argument counter of the process. + * @param argv Arguments values of the process. + * @param logger_id The id of the logger (optional). + * @return std::shared_ptr shared_ptr to logging object on success, otherwise + * nullptr. + */ static std::shared_ptr init_logger(const std::string &file_name, const beerocks::config_file::SConfigLog &log_config, int argc, char **argv, const std::string &logger_id = std::string()) @@ -120,7 +131,7 @@ init_logger(const std::string &file_name, const beerocks::config_file::SConfigLo auto logger = std::make_shared(file_name, log_config, logger_id); if (!logger) { std::cout << "Failed to allocated logger to " << file_name; - return std::shared_ptr(); + return nullptr; } logger->apply_settings(); CLOG(INFO, logger->get_logger_id()) diff --git a/agent/src/beerocks/slave/beerocks_slave_main.cpp b/agent/src/beerocks/slave/beerocks_slave_main.cpp index eaad97278d..4c6752da0f 100644 --- a/agent/src/beerocks/slave/beerocks_slave_main.cpp +++ b/agent/src/beerocks/slave/beerocks_slave_main.cpp @@ -26,7 +26,7 @@ static int s_signal = 0; static std::string g_son_slave_iface; // Pointer to logger instance -static beerocks::logging *s_pLogger = nullptr; +static std::vector> g_loggers; static void handle_signal() { @@ -44,14 +44,12 @@ static void handle_signal() // Roll log file case SIGUSR1: { - LOG(INFO) << "LOG Roll Signal!"; - if (!s_pLogger) { - LOG(ERROR) << "Invalid logger pointer!"; - return; - } - s_pLogger->apply_settings(); - LOG(INFO) << "--- Start of file after roll ---"; + for (auto &logger : g_loggers) { + CLOG(INFO, logger->get_logger_id()) << "LOG Roll Signal!"; + logger->apply_settings(); + CLOG(INFO, logger->get_logger_id()) << "--- Start of file after roll ---"; + } break; } @@ -173,32 +171,47 @@ static void fill_son_slave_config(const beerocks::config_file::sConfigSlave &bee son_slave_conf.stop_on_failure_attempts = 0; } +static std::shared_ptr +init_logger(const std::string &file_name, const beerocks::config_file::SConfigLog &log_config, + int argc, char **argv, const std::string &logger_id = std::string()) +{ + auto logger = std::make_shared(file_name, log_config, logger_id); + if (!logger) { + std::cout << "Failed to allocated logger to " << file_name; + return std::shared_ptr(); + } + logger->apply_settings(); + CLOG(INFO, logger->get_logger_id()) + << std::endl + << "Running " << file_name << " Version " << BEEROCKS_VERSION << " Build date " + << BEEROCKS_BUILD_DATE << std::endl + << std::endl; + beerocks::version::log_version(argc, argv, logger->get_logger_id()); + + // Redirect stdout / stderr to file + if (logger->get_log_files_enabled()) { + beerocks::os_utils::redirect_console_std(log_config.files_path + file_name + "_std.log"); + } + + return logger; +} + static int system_hang_test(const beerocks::config_file::sConfigSlave &beerocks_slave_conf, int argc, char *argv[]) { std::string name = std::string("system_hang_test"); - //init logger - beerocks::logging logger(name, beerocks_slave_conf.sLog); - s_pLogger = &logger; - logger.apply_settings(); - LOG(INFO) << std::endl - << "Running " << name << " Version " << BEEROCKS_VERSION << " Build date " - << BEEROCKS_BUILD_DATE << std::endl - << std::endl; - beerocks::version::log_version(argc, argv); - - // Redirect stdout / stderr to file - if (logger.get_log_files_enabled()) { - beerocks::os_utils::redirect_console_std(beerocks_slave_conf.sLog.files_path + name + - "_std.log"); + // Init logger + auto logger = init_logger(name, beerocks_slave_conf.sLog, argc, argv); + if (!logger) { + return 1; } - //write pid file + // Write pid file beerocks::os_utils::write_pid_file(beerocks_slave_conf.temp_path, name); std::string pid_file_path = beerocks_slave_conf.temp_path + "pid/" + name; // for file touching - //initialize timers + // Initialize timers auto touch_time_stamp_timeout = std::chrono::steady_clock::now(); auto error_time_stamp_timeout = std::chrono::steady_clock::now(); @@ -229,8 +242,6 @@ static int system_hang_test(const beerocks::config_file::sConfigSlave &beerocks_ UTILS_SLEEP_MSEC(100); } - s_pLogger = nullptr; - return 0; } @@ -238,34 +249,19 @@ static int run_beerocks_slave(beerocks::config_file::sConfigSlave &beerocks_slav const std::unordered_map &interfaces_map, int argc, char *argv[]) { - std::string base_slave_name = std::string(BEEROCKS_AGENT); - std::ofstream versionfile; - - //init logger - beerocks::logging slave_logger(base_slave_name, beerocks_slave_conf.sLog); - s_pLogger = &slave_logger; - slave_logger.apply_settings(); - LOG(INFO) << std::endl - << "Running " << base_slave_name << " Version " << BEEROCKS_VERSION << " Build date " - << BEEROCKS_BUILD_DATE << std::endl - << std::endl; - beerocks::version::log_version(argc, argv); - - versionfile.open(beerocks_slave_conf.temp_path + "beerocks_slave_version"); - versionfile << BEEROCKS_VERSION << std::endl << BEEROCKS_REVISION; - versionfile.close(); - - //redirect stdout / stderr to file - // int fd_log_file_std = beerocks::os_utils::redirect_console_std("/dev/null"); - if (slave_logger.get_log_files_enabled()) { - beerocks::os_utils::redirect_console_std(beerocks_slave_conf.sLog.files_path + - base_slave_name + "_std.log"); + std::string base_agent_name = std::string(BEEROCKS_AGENT); + + // Init logger + auto agent_logger = init_logger(base_agent_name, beerocks_slave_conf.sLog, argc, argv); + if (!agent_logger) { + return 1; } + g_loggers.push_back(agent_logger); - //write pid file - beerocks::os_utils::write_pid_file(beerocks_slave_conf.temp_path, base_slave_name); + // Write pid file + beerocks::os_utils::write_pid_file(beerocks_slave_conf.temp_path, base_agent_name); std::string pid_file_path = - beerocks_slave_conf.temp_path + "pid/" + base_slave_name; // for file touching + beerocks_slave_conf.temp_path + "pid/" + base_agent_name; // for file touching std::set slave_ap_ifaces; for (auto &elm : interfaces_map) { @@ -275,11 +271,11 @@ static int run_beerocks_slave(beerocks::config_file::sConfigSlave &beerocks_slav } beerocks::platform_manager::main_thread platform_mgr(beerocks_slave_conf, interfaces_map, - slave_logger); + *agent_logger); - //start platform_manager + // Start platform_manager if (platform_mgr.init()) { - // read the number of failures allowed before stopping agent from platform configuration + // Read the number of failures allowed before stopping agent from platform configuration int stop_on_failure_attempts = beerocks::bpl::cfg_get_stop_on_failure_attempts(); // The platform manager updates the beerocks_slave_conf.sta_iface in the init stage @@ -334,47 +330,37 @@ static int run_beerocks_slave(beerocks::config_file::sConfigSlave &beerocks_slav } LOG(DEBUG) << "Bye Bye!"; - s_pLogger = nullptr; return 0; } static int run_son_slave(int slave_num, beerocks::config_file::sConfigSlave &beerocks_slave_conf, - const std::string &hostap_iface, int argc, char *argv[]) + const std::string &fronthaul_iface, int argc, char *argv[]) { - std::string base_slave_name = std::string(BEEROCKS_AGENT) + "_" + hostap_iface; - - //init logger - beerocks::logging slave_logger(base_slave_name, beerocks_slave_conf.sLog); - s_pLogger = &slave_logger; - slave_logger.apply_settings(); - LOG(INFO) << std::endl - << "Running SON " << base_slave_name << " Version " << BEEROCKS_VERSION - << " Build date " << BEEROCKS_BUILD_DATE << std::endl - << std::endl; - beerocks::version::log_version(argc, argv); - - //redirect stdout / stderr to file - //int fd_log_file_std = beerocks::os_utils::redirect_console_std("/dev/null"); - if (slave_logger.get_log_files_enabled()) { - beerocks::os_utils::redirect_console_std(beerocks_slave_conf.sLog.files_path + - base_slave_name + "_std.log"); + std::string base_slave_name = std::string(BEEROCKS_AGENT) + "_" + fronthaul_iface; + + // Init logger + auto logger = + init_logger(base_slave_name, beerocks_slave_conf.sLog, argc, argv, base_slave_name); + if (!logger) { + return 1; } + g_loggers.push_back(logger); - //write pid file + // Write pid file beerocks::os_utils::write_pid_file(beerocks_slave_conf.temp_path, base_slave_name); std::string pid_file_path = beerocks_slave_conf.temp_path + "pid/" + base_slave_name; // for file touching - // fill configuration + // Fill configuration son::slave_thread::sSlaveConfig son_slave_conf; - fill_son_slave_config(beerocks_slave_conf, son_slave_conf, hostap_iface, slave_num); + fill_son_slave_config(beerocks_slave_conf, son_slave_conf, fronthaul_iface, slave_num); - // disable stopping on failure initially. Later on, it will be read from BPL as part of + // Disable stopping on failure initially. Later on, it will be read from BPL as part of // cACTION_PLATFORM_SON_SLAVE_REGISTER_RESPONSE son_slave_conf.stop_on_failure_attempts = 0; - son::slave_thread son_slave(son_slave_conf, slave_logger); + son::slave_thread son_slave(son_slave_conf, *logger); if (son_slave.init()) { auto touch_time_stamp_timeout = std::chrono::steady_clock::now(); while (g_running) { @@ -401,8 +387,6 @@ static int run_son_slave(int slave_num, beerocks::config_file::sConfigSlave &bee LOG(ERROR) << "son_slave.init(), slave_num=" << slave_num; } - s_pLogger = nullptr; - return 0; } diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 0657ae28b8..5992607499 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -242,6 +242,12 @@ std::string slave_thread::print_cmdu_types(const message::sUdsHeader *cmdu_heade bool slave_thread::work() { + if (!m_logger_configured) { + logger.set_thread_name(logger.get_module_name()); + logger.attach_current_thread_to_logger_id(); + m_logger_configured = true; + } + bool call_slave_select = true; if (!monitor_heartbeat_check() || !ap_manager_heartbeat_check()) { diff --git a/agent/src/beerocks/slave/son_slave_thread.h b/agent/src/beerocks/slave/son_slave_thread.h index a6ce66db4b..b9ae31a888 100644 --- a/agent/src/beerocks/slave/son_slave_thread.h +++ b/agent/src/beerocks/slave/son_slave_thread.h @@ -175,6 +175,7 @@ class slave_thread : public beerocks::socket_thread { bool is_backhual_reconf = false; bool detach_on_conf_change = false; bool configuration_in_progress = false; + bool m_logger_configured = false; bool is_backhaul_manager = false; From b01a3d36c16345c93427f017e1a81a1c10ee9a84 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 22 Jul 2020 07:17:32 +0000 Subject: [PATCH 321/453] agent: Move run_son_slave location On the next commit 'run_son_slave()' will be used from 'run_beerocks_slave()'. To do that it should be defined before 'run_beerocks_slave()'. Since 'run_son_slave()' will be changed completely, and also its name will be changed. This commit purpose it to make the code review easier. PPM-304 Signed-off-by: Moran Shoeg --- .../beerocks/slave/beerocks_slave_main.cpp | 112 +++++++++--------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/agent/src/beerocks/slave/beerocks_slave_main.cpp b/agent/src/beerocks/slave/beerocks_slave_main.cpp index 4c6752da0f..74469fa477 100644 --- a/agent/src/beerocks/slave/beerocks_slave_main.cpp +++ b/agent/src/beerocks/slave/beerocks_slave_main.cpp @@ -245,6 +245,62 @@ static int system_hang_test(const beerocks::config_file::sConfigSlave &beerocks_ return 0; } +static int run_son_slave(int slave_num, beerocks::config_file::sConfigSlave &beerocks_slave_conf, + const std::string &fronthaul_iface, int argc, char *argv[]) +{ + std::string base_slave_name = std::string(BEEROCKS_AGENT) + "_" + fronthaul_iface; + + // Init logger + auto logger = + init_logger(base_slave_name, beerocks_slave_conf.sLog, argc, argv, base_slave_name); + if (!logger) { + return 1; + } + g_loggers.push_back(logger); + + // Write pid file + beerocks::os_utils::write_pid_file(beerocks_slave_conf.temp_path, base_slave_name); + std::string pid_file_path = + beerocks_slave_conf.temp_path + "pid/" + base_slave_name; // for file touching + + // Fill configuration + son::slave_thread::sSlaveConfig son_slave_conf; + fill_son_slave_config(beerocks_slave_conf, son_slave_conf, fronthaul_iface, slave_num); + + // Disable stopping on failure initially. Later on, it will be read from BPL as part of + // cACTION_PLATFORM_SON_SLAVE_REGISTER_RESPONSE + son_slave_conf.stop_on_failure_attempts = 0; + + son::slave_thread son_slave(son_slave_conf, *logger); + if (son_slave.init()) { + auto touch_time_stamp_timeout = std::chrono::steady_clock::now(); + while (g_running) { + + // Handle signals + if (s_signal) { + handle_signal(); + continue; + } + + if (std::chrono::steady_clock::now() > touch_time_stamp_timeout) { + beerocks::os_utils::touch_pid_file(pid_file_path); + touch_time_stamp_timeout = + std::chrono::steady_clock::now() + + std::chrono::seconds(beerocks::TOUCH_PID_TIMEOUT_SECONDS); + } + + if (!son_slave.work()) { + break; + } + } + son_slave.stop(); + } else { + LOG(ERROR) << "son_slave.init(), slave_num=" << slave_num; + } + + return 0; +} + static int run_beerocks_slave(beerocks::config_file::sConfigSlave &beerocks_slave_conf, const std::unordered_map &interfaces_map, int argc, char *argv[]) @@ -334,62 +390,6 @@ static int run_beerocks_slave(beerocks::config_file::sConfigSlave &beerocks_slav return 0; } -static int run_son_slave(int slave_num, beerocks::config_file::sConfigSlave &beerocks_slave_conf, - const std::string &fronthaul_iface, int argc, char *argv[]) -{ - std::string base_slave_name = std::string(BEEROCKS_AGENT) + "_" + fronthaul_iface; - - // Init logger - auto logger = - init_logger(base_slave_name, beerocks_slave_conf.sLog, argc, argv, base_slave_name); - if (!logger) { - return 1; - } - g_loggers.push_back(logger); - - // Write pid file - beerocks::os_utils::write_pid_file(beerocks_slave_conf.temp_path, base_slave_name); - std::string pid_file_path = - beerocks_slave_conf.temp_path + "pid/" + base_slave_name; // for file touching - - // Fill configuration - son::slave_thread::sSlaveConfig son_slave_conf; - fill_son_slave_config(beerocks_slave_conf, son_slave_conf, fronthaul_iface, slave_num); - - // Disable stopping on failure initially. Later on, it will be read from BPL as part of - // cACTION_PLATFORM_SON_SLAVE_REGISTER_RESPONSE - son_slave_conf.stop_on_failure_attempts = 0; - - son::slave_thread son_slave(son_slave_conf, *logger); - if (son_slave.init()) { - auto touch_time_stamp_timeout = std::chrono::steady_clock::now(); - while (g_running) { - - // Handle signals - if (s_signal) { - handle_signal(); - continue; - } - - if (std::chrono::steady_clock::now() > touch_time_stamp_timeout) { - beerocks::os_utils::touch_pid_file(pid_file_path); - touch_time_stamp_timeout = - std::chrono::steady_clock::now() + - std::chrono::seconds(beerocks::TOUCH_PID_TIMEOUT_SECONDS); - } - - if (!son_slave.work()) { - break; - } - } - son_slave.stop(); - } else { - LOG(ERROR) << "son_slave.init(), slave_num=" << slave_num; - } - - return 0; -} - int main(int argc, char *argv[]) { int slave_num; From 91e5260d72fd9e232ff7ef192facb122ef473bac Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 22 Jul 2020 08:59:00 +0000 Subject: [PATCH 322/453] agent: Run son_slaves threads on main Agent context Run son_slaves threads on the main Agent context. Removed PID touch of son_slaves since it is no longer needed. PPM-304 Signed-off-by: Moran Shoeg --- .../beerocks/slave/beerocks_slave_main.cpp | 174 ++++++++++-------- 1 file changed, 94 insertions(+), 80 deletions(-) diff --git a/agent/src/beerocks/slave/beerocks_slave_main.cpp b/agent/src/beerocks/slave/beerocks_slave_main.cpp index 74469fa477..9f4086b802 100644 --- a/agent/src/beerocks/slave/beerocks_slave_main.cpp +++ b/agent/src/beerocks/slave/beerocks_slave_main.cpp @@ -245,8 +245,9 @@ static int system_hang_test(const beerocks::config_file::sConfigSlave &beerocks_ return 0; } -static int run_son_slave(int slave_num, beerocks::config_file::sConfigSlave &beerocks_slave_conf, - const std::string &fronthaul_iface, int argc, char *argv[]) +static std::shared_ptr +start_son_slave_thread(int slave_num, beerocks::config_file::sConfigSlave &beerocks_slave_conf, + const std::string &fronthaul_iface, int argc, char *argv[]) { std::string base_slave_name = std::string(BEEROCKS_AGENT) + "_" + fronthaul_iface; @@ -254,15 +255,10 @@ static int run_son_slave(int slave_num, beerocks::config_file::sConfigSlave &bee auto logger = init_logger(base_slave_name, beerocks_slave_conf.sLog, argc, argv, base_slave_name); if (!logger) { - return 1; + return nullptr; } g_loggers.push_back(logger); - // Write pid file - beerocks::os_utils::write_pid_file(beerocks_slave_conf.temp_path, base_slave_name); - std::string pid_file_path = - beerocks_slave_conf.temp_path + "pid/" + base_slave_name; // for file touching - // Fill configuration son::slave_thread::sSlaveConfig son_slave_conf; fill_son_slave_config(beerocks_slave_conf, son_slave_conf, fronthaul_iface, slave_num); @@ -271,34 +267,18 @@ static int run_son_slave(int slave_num, beerocks::config_file::sConfigSlave &bee // cACTION_PLATFORM_SON_SLAVE_REGISTER_RESPONSE son_slave_conf.stop_on_failure_attempts = 0; - son::slave_thread son_slave(son_slave_conf, *logger); - if (son_slave.init()) { - auto touch_time_stamp_timeout = std::chrono::steady_clock::now(); - while (g_running) { - - // Handle signals - if (s_signal) { - handle_signal(); - continue; - } - - if (std::chrono::steady_clock::now() > touch_time_stamp_timeout) { - beerocks::os_utils::touch_pid_file(pid_file_path); - touch_time_stamp_timeout = - std::chrono::steady_clock::now() + - std::chrono::seconds(beerocks::TOUCH_PID_TIMEOUT_SECONDS); - } + auto son_slave = std::make_shared(son_slave_conf, *logger); + if (!son_slave) { + CLOG(ERROR, logger->get_logger_id()) << "son::slave_thread allocating has failed!"; + return nullptr; + } - if (!son_slave.work()) { - break; - } - } - son_slave.stop(); - } else { - LOG(ERROR) << "son_slave.init(), slave_num=" << slave_num; + if (!son_slave->start()) { + CLOG(ERROR, logger->get_logger_id()) << "son_slave.start() has failed"; + return nullptr; } - return 0; + return son_slave; } static int run_beerocks_slave(beerocks::config_file::sConfigSlave &beerocks_slave_conf, @@ -330,61 +310,93 @@ static int run_beerocks_slave(beerocks::config_file::sConfigSlave &beerocks_slav *agent_logger); // Start platform_manager - if (platform_mgr.init()) { - // Read the number of failures allowed before stopping agent from platform configuration - int stop_on_failure_attempts = beerocks::bpl::cfg_get_stop_on_failure_attempts(); - - // The platform manager updates the beerocks_slave_conf.sta_iface in the init stage - std::set slave_sta_ifaces; - for (int slave_num = 0; slave_num < beerocks::IRE_MAX_SLAVES; slave_num++) { - if (!beerocks_slave_conf.sta_iface[slave_num].empty()) { - slave_sta_ifaces.insert(beerocks_slave_conf.sta_iface[slave_num]); - } + if (!platform_mgr.init()) { + LOG(ERROR) << "platform_mgr init() has failed!"; + return 1; + } + + // Read the number of failures allowed before stopping agent from platform configuration + int stop_on_failure_attempts = beerocks::bpl::cfg_get_stop_on_failure_attempts(); + + // The platform manager updates the beerocks_slave_conf.sta_iface in the init stage + std::set slave_sta_ifaces; + for (int slave_num = 0; slave_num < beerocks::IRE_MAX_SLAVES; slave_num++) { + if (!beerocks_slave_conf.sta_iface[slave_num].empty()) { + slave_sta_ifaces.insert(beerocks_slave_conf.sta_iface[slave_num]); } + } - beerocks::backhaul_manager backhaul_mgr(beerocks_slave_conf, slave_ap_ifaces, - slave_sta_ifaces, stop_on_failure_attempts); + beerocks::backhaul_manager backhaul_mgr(beerocks_slave_conf, slave_ap_ifaces, slave_sta_ifaces, + stop_on_failure_attempts); - // Start backhaul manager - if (!backhaul_mgr.start()) { - LOG(ERROR) << "backhaul_mgr.start()"; - } else { + // Start backhaul manager + if (!backhaul_mgr.start()) { + LOG(ERROR) << "backhaul_mgr init() has failed!"; + return 1; + } - auto touch_time_stamp_timeout = std::chrono::steady_clock::now(); - while (g_running) { - - // Handle signals - if (s_signal) { - handle_signal(); - continue; - } - - if (std::chrono::steady_clock::now() > touch_time_stamp_timeout) { - beerocks::os_utils::touch_pid_file(pid_file_path); - touch_time_stamp_timeout = - std::chrono::steady_clock::now() + - std::chrono::seconds(beerocks::TOUCH_PID_TIMEOUT_SECONDS); - } - - // Check if backhaul manager still running and break on error - if (!backhaul_mgr.is_running()) { - break; - } - - //call platform manager work task and break on error - if (!platform_mgr.work()) { - break; - } + std::vector> son_slaves; + for (const auto &iface_element : interfaces_map) { + auto son_slave_num = iface_element.first; + auto &fronthaul_iface = iface_element.second; + LOG(DEBUG) << "Running son_slave_" << fronthaul_iface; + auto son_slave = + start_son_slave_thread(son_slave_num, beerocks_slave_conf, fronthaul_iface, argc, argv); + if (!son_slave) { + LOG(ERROR) << "Failed to start son_slave_" << fronthaul_iface; + return 1; + } + son_slaves.push_back(son_slave); + } + + auto touch_time_stamp_timeout = std::chrono::steady_clock::now(); + while (g_running) { + + // Handle signals + if (s_signal) { + handle_signal(); + continue; + } + + if (std::chrono::steady_clock::now() > touch_time_stamp_timeout) { + beerocks::os_utils::touch_pid_file(pid_file_path); + touch_time_stamp_timeout = std::chrono::steady_clock::now() + + std::chrono::seconds(beerocks::TOUCH_PID_TIMEOUT_SECONDS); + } + + // Check if backhaul manager still running and break on error. + if (!backhaul_mgr.is_running()) { + break; + } + + // Check if all son_slave are still running and break on error. + auto should_break = false; + for (const auto &son_slave : son_slaves) { + should_break = !son_slave->is_running(); + if (should_break) { + break; } } + if (should_break) { + break; + } - LOG(DEBUG) << "backhaul_mgr.stop()"; - backhaul_mgr.stop(); + // Call platform manager work task and break on error. + if (!platform_mgr.work()) { + break; + } + } - LOG(DEBUG) << "platform_mgr.stop()"; - platform_mgr.stop(); + for (const auto &son_slave : son_slaves) { + son_slave->stop(); } + LOG(DEBUG) << "backhaul_mgr.stop()"; + backhaul_mgr.stop(); + + LOG(DEBUG) << "platform_mgr.stop()"; + platform_mgr.stop(); + LOG(DEBUG) << "Bye Bye!"; return 0; @@ -465,8 +477,10 @@ int main(int argc, char *argv[]) auto hostap_iface_elm = interfaces_map.find(slave_num); if ((hostap_iface_elm != interfaces_map.end()) && (g_son_slave_iface == hostap_iface_elm->second)) { - return run_son_slave(slave_num, beerocks_slave_conf, hostap_iface_elm->second, argc, - argv); + // This line has been only changed so compilation would pass. It is not actually + // used, and on the nex commit will be removed. + start_son_slave_thread(slave_num, beerocks_slave_conf, hostap_iface_elm->second, + argc, argv); } } LOG(ERROR) << "did not find g_son_slave_iface in hostap_iface array" << std::endl; From a68652d95551c3fb2480ce1feed2d41e89922013 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 22 Jul 2020 09:06:12 +0000 Subject: [PATCH 323/453] agent: Remove the option to run son_slave with "-i " option This option is no longer needed since now the son_slaves thread runs on the main Agent process context. PPM 304 Signed-off-by: Moran Shoeg --- .../beerocks/slave/beerocks_slave_main.cpp | 32 +++---------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/agent/src/beerocks/slave/beerocks_slave_main.cpp b/agent/src/beerocks/slave/beerocks_slave_main.cpp index 9f4086b802..24542409c7 100644 --- a/agent/src/beerocks/slave/beerocks_slave_main.cpp +++ b/agent/src/beerocks/slave/beerocks_slave_main.cpp @@ -23,7 +23,6 @@ BEEROCKS_INIT_BEEROCKS_VERSION static bool g_running = true; static int s_signal = 0; -static std::string g_son_slave_iface; // Pointer to logger instance static std::vector> g_loggers; @@ -88,13 +87,9 @@ static void init_signals() static bool parse_arguments(int argc, char *argv[]) { int opt; - while ((opt = getopt(argc, argv, "i:q:")) != -1) { + while ((opt = getopt(argc, argv, "q:")) != -1) { switch (opt) { - case 'i': { - g_son_slave_iface.assign(optarg); - break; - } - case 'q': // quary platfrom: is_master, is_gateway, is_onboarding + case 'q': // query platfrom: is_master, is_gateway, is_onboarding { std::string request; request.assign(optarg); @@ -404,8 +399,6 @@ static int run_beerocks_slave(beerocks::config_file::sConfigSlave &beerocks_slav int main(int argc, char *argv[]) { - int slave_num; - init_signals(); // Check for version query first, handle and exit if requested. @@ -436,7 +429,7 @@ int main(int argc, char *argv[]) } // beerocks system hang tester - if (g_son_slave_iface.empty() && beerocks_slave_conf.enable_system_hang_test == "1") { + if (beerocks_slave_conf.enable_system_hang_test == "1") { pid_t pid = fork(); if (pid == 0) { @@ -466,24 +459,7 @@ int main(int argc, char *argv[]) } if (interfaces_map.empty()) { - LOG(INFO) << "no hostap interface is available"; - return 0; - } - - //Handle -i option (start given son slave) - if (!g_son_slave_iface.empty()) { - //start given slave - for (slave_num = 0; slave_num < beerocks::IRE_MAX_SLAVES; slave_num++) { - auto hostap_iface_elm = interfaces_map.find(slave_num); - if ((hostap_iface_elm != interfaces_map.end()) && - (g_son_slave_iface == hostap_iface_elm->second)) { - // This line has been only changed so compilation would pass. It is not actually - // used, and on the nex commit will be removed. - start_son_slave_thread(slave_num, beerocks_slave_conf, hostap_iface_elm->second, - argc, argv); - } - } - LOG(ERROR) << "did not find g_son_slave_iface in hostap_iface array" << std::endl; + LOG(INFO) << "No radio interfaces are available"; return 0; } From 871b3a3dfcf3e236a1b2b950fd807d8c999ed1b0 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 22 Jul 2020 14:41:46 +0000 Subject: [PATCH 324/453] tools: Remove "pgrep" on son_slave processes Since son_slaves processes are no longer exist, the check if its processes are running during an operational check must be removed. PPM-304 Signed-off-by: Moran Shoeg --- common/beerocks/scripts/prplmesh_utils.sh.in | 1 - 1 file changed, 1 deletion(-) diff --git a/common/beerocks/scripts/prplmesh_utils.sh.in b/common/beerocks/scripts/prplmesh_utils.sh.in index d4bbd290f2..bb65d8a566 100755 --- a/common/beerocks/scripts/prplmesh_utils.sh.in +++ b/common/beerocks/scripts/prplmesh_utils.sh.in @@ -277,7 +277,6 @@ main_agent_operational() { } radio_agent_operational() { - pgrep -fx "@INSTALL_PATH@/bin/beerocks_agent -i $2($|[[:blank:]])" > /dev/null 2>&1 || return 1 grep -q 'goto STATE_OPERATIONAL' "$1/beerocks_agent_$2@BEEROCKS_LOG_FILES_SUFFIX@" } From 881dad3e368c1155e87639496d24fdf9b3f301e5 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 22 Jul 2020 14:50:43 +0000 Subject: [PATCH 325/453] tools: Change testflows repeater operational check to use BML Currently checking of the operational status of prprlMesh on testflows uses the BML check if the platform is the gateway, and do a grep on the log files if the platform is a repeater. Change it to always use the BML. PPM-304 Signed-off-by: Moran Shoeg --- common/beerocks/scripts/prplmesh_utils.sh.in | 16 ++++++++++++--- tests/test_gw_repeater.sh | 10 +++++++++- tools/docker/test.sh | 21 ++++++++++++++------ 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/common/beerocks/scripts/prplmesh_utils.sh.in b/common/beerocks/scripts/prplmesh_utils.sh.in index bb65d8a566..4ed961abef 100755 --- a/common/beerocks/scripts/prplmesh_utils.sh.in +++ b/common/beerocks/scripts/prplmesh_utils.sh.in @@ -296,10 +296,19 @@ status_function() { pgrep -l beerocks pgrep -l ieee1905_transport - bridge_mac="$(ip link show dev @BEEROCKS_BRIDGE_IFACE@ | awk '/^ *link\/ether / {print $2}')" - bml_cmd="bml_get_device_operational_radios $bridge_mac" + # Use the given argument as birdge mac if it filled with something, otherwise get the bridge mac + # of the local platform. + ARGUMENT_LEN=${#1} + if [ "$ARGUMENT_LEN" -ne "0" ]; then + BRIDGE_MAC=$1 + else + BRIDGE_MAC="$(ip link show dev @BEEROCKS_BRIDGE_IFACE@ | awk '/^ *link\/ether / {print $2}')" + fi + + bml_cmd="bml_get_device_operational_radios $BRIDGE_MAC" if pgrep -l beerocks_cont ; then + echo "executing operational test using bml" if execute_beerocks_command "$bml_cmd" ; then # Expecting # > OK Main radio agent operational @@ -319,6 +328,7 @@ status_function() { exit 1 fi else + echo "executing operational test using grep on log files" # check for operational status LOGS_PATH=@BEEROCKS_LOG_FILES_PATH@ @@ -387,7 +397,7 @@ main() { start_function ;; "status") - status_function + status_function "$2" ;; "roll_logs") roll_logs_function diff --git a/tests/test_gw_repeater.sh b/tests/test_gw_repeater.sh index 4c1db15ab1..065768819e 100755 --- a/tests/test_gw_repeater.sh +++ b/tests/test_gw_repeater.sh @@ -55,6 +55,13 @@ check_wsl() { RP_EXTRA_OPT=(--expose "${RP_UCC_PORT}" --publish "127.0.0.1::${RP_UCC_PORT}") } +get_repater_bridge_mac() { + if [ "$#" -eq 1 ]; then + REPEATER_BRIDGE_MAC=$(run docker container exec "$1" ifconfig br-lan | grep ether | tr -s ' ' | cut --delimiter=' ' -f 3) + echo "$REPEATER_BRIDGE_MAC" + fi +} + main() { if ! OPTS=$(getopt -o 'hvd:fg:r:t:u:' --long help,verbose,rm,gateway-only,repeater-only,delay:,force,gateway:,repeater:,tag:,unique-id: -n 'parse-options' -- "$@"); then err "Failed parsing options." >&2 ; usage; exit 1 ; @@ -128,8 +135,9 @@ main() { [ "$START_REPEATER" = "true" ] && { for repeater in $REPEATER_NAMES do + REPEATER_BRIDGE_MAC=$(get_repater_bridge_mac "${repeater}") report "Repeater $repeater operational" \ - "${rootdir}"/tools/docker/test.sh ${VERBOSE_OPT} -n "${repeater}" + "${rootdir}"/tools/docker/test.sh ${VERBOSE_OPT} -n "${GW_NAME}" -b "${REPEATER_BRIDGE_MAC}" done } diff --git a/tools/docker/test.sh b/tools/docker/test.sh index 0cfcd952e0..7fe4049a31 100755 --- a/tools/docker/test.sh +++ b/tools/docker/test.sh @@ -13,15 +13,16 @@ rootdir="${scriptdir%/*/*}" . "${rootdir}/tools/functions.sh" usage() { - echo "usage: $(basename "$0") [-hv] [-n name]" + echo "usage: $(basename "$0") [-hv] [-n name [-b bridge_mac]]" echo " options:" echo " -h|--help - show this help menu" echo " -v|--verbose - verbosity on" echo " -n|--name - container name for which to attach" + echo " -b|--bridge_mac - bridge mac to get operational status on" } main() { - if ! OPTS=$(getopt -o 'hvn:' --long verbose,help,name -n 'parse-options' -- "$@"); then + if ! OPTS=$(getopt -o 'hvn:b:' --long verbose,help,name,bridge_mac -n 'parse-options' -- "$@"); then err "Failed parsing options." >&2 usage exit 1 @@ -31,18 +32,26 @@ main() { while true; do case "$1" in - -v | --verbose) VERBOSE=true; OPT="-v"; shift ;; - -h | --help) usage; exit 0; shift ;; - -n | --name) NAME="$2"; shift; shift ;; + -v | --verbose) VERBOSE=true; OPT="-v"; shift ;; + -h | --help) usage; exit 0; shift ;; + -n | --name) NAME="$2"; shift; shift ;; + -b | --bridge_mac) BRIDGE_MAC="$2"; shift; shift ;; -- ) shift; break ;; * ) err "unsupported argument $1"; usage; exit 1 ;; esac done - run docker container exec "${NAME}" "${rootdir}/build/install/scripts/prplmesh_utils.sh" status $OPT + if [ -z "$BRIDGE_MAC" ]; then + run docker container exec "${NAME}" "${rootdir}/build/install/scripts/prplmesh_utils.sh" status $OPT + else + run docker container exec "${NAME}" "${rootdir}/build/install/scripts/prplmesh_utils.sh" status "$BRIDGE_MAC" $OPT + fi + + } VERBOSE=false NAME=prplMesh +declare BRIDGE_MAC main "$@" From 31321c51049222b61132f322113b9deca0bcde36 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 22 Jul 2020 15:19:46 +0000 Subject: [PATCH 326/453] cppcheck: Update existing issues file PPM-304 Signed-off-by: Moran Shoeg --- ci/cppcheck/cppcheck_existing_issues.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/cppcheck/cppcheck_existing_issues.txt b/ci/cppcheck/cppcheck_existing_issues.txt index fdd3c6aac4..1bfdf24dca 100644 --- a/ci/cppcheck/cppcheck_existing_issues.txt +++ b/ci/cppcheck/cppcheck_existing_issues.txt @@ -10,7 +10,7 @@ agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Lo agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Local variable 'local_interface_name' shadows outer variable [shadowVariable] std::string local_interface_name = soc->hostap_iface; agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Local variable 'supportedServiceTuple' shadows outer variable [shadowVariable] auto supportedServiceTuple = tlvSupportedService->supported_service_list(1); agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Variable 'p_cmdu_header' is assigned a value that is never used. [unreadVariable] auto p_cmdu_header = -agent/src/beerocks/slave/beerocks_slave_main.cpp: style: Parameter 'beerocks_slave_conf' can be declared with const [constParameter]static int run_son_slave(int slave_num, beerocks::config_file::sConfigSlave &beerocks_slave_conf, +agent/src/beerocks/slave/beerocks_slave_main.cpp: style: Parameter 'beerocks_slave_conf' can be declared with const [constParameter]start_son_slave_thread(int slave_num, beerocks::config_file::sConfigSlave &beerocks_slave_conf, agent/src/beerocks/slave/gate/unit_tests/gate_test.cpp: error: syntax error [syntaxError]TEST(gate_beacon_query_test, loading_vs_from_1905_beacon_query) agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp: warning: Comparison of a boolean expression with an integer. [compareBoolExpressionWithInt] if (bpl::dhcp_mon_stop() == false) { agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp: warning: Redundant assignment of '*(volatile char*)pass' to itself. [selfAssignment] *(volatile char *)pass = *(volatile char *)pass; From 5975ae8521e88e7d6c615aacd43f057327854143 Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Wed, 22 Jul 2020 17:45:06 +0200 Subject: [PATCH 327/453] framework: encryption: wps_calculate_keys: use correct kdf length Commit 55cf4335a7a fixed some cppcheck errors in this code by removing the unused emsk member from the keys structure. However, this changes the size of the keys structure, and therefore results in an incorrect Diffie-Hellman key derivation. This wasn't found in tests because we do the same on both sides, so the derived key will still be the same on both sides. However, it causes certification tests to fail. Fix this by reverting to the original situation, but adding a cppcheck exception. Fixes MAP-4.2.1:netgear-rax40 While we're at it, also fix an end-of-line whitespace in a comment. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- framework/common/encryption.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/common/encryption.cpp b/framework/common/encryption.cpp index 875974ef97..24c770e62f 100644 --- a/framework/common/encryption.cpp +++ b/framework/common/encryption.cpp @@ -291,7 +291,7 @@ bool aes_encrypt(const uint8_t *key, const uint8_t *iv, uint8_t *plaintext, int /* Verify that the ciphertext buffer has enough storage room * for block size alignment padding which will be added * during encryption, which is up to plen + cipher_block_size -1 - * for the update, and another cipher_block_size for the final one. + * for the update, and another cipher_block_size for the final one. */ int padlen = 16 - (plen % 16); if (clen < plen + padlen) { @@ -429,8 +429,8 @@ void wps_calculate_keys(const diffie_hellman &dh, const uint8_t *remote_pubkey, struct { uint8_t authkey[32]; uint8_t keywrapkey[16]; - // Currently unused, commented out to prevent cppcheck warnings - // uint8_t emsk[32]; + // cppcheck-suppress unusedStructMember + uint8_t emsk[32]; } keys; uint8_t buf[3][32]; } keys; From 745d77ae2d0bffeffd427cefe8255c499589a07a Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Thu, 23 Jul 2020 12:29:54 +0000 Subject: [PATCH 328/453] tlvf: "get client list" response returns a list of sMacAddr Preparative commit. The current implementation returns an `std::string` which tightly couples the way the son_management returns the information to the BML and the interface the BML provides to external users. From a messaging perspective as well as generic and extendable design the response should contain a list of MAC addresses and not a string. Changed the cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE to return a list of sMacAddr instead of a string. Added a missing `result` parameter to the response message to indicate an error when needed (since there are successful cases of an empty list). Please note that this commit breaks compilation but the split is done for readability and reviewability. PPM-5. Signed-off-by: Adam Dov --- .../beerocks/tlvf/beerocks_message_bml.h | 9 ++-- .../beerocks/tlvf/beerocks_message_bml.cpp | 51 ++++++++++--------- .../beerocks/tlvf/beerocks_message_bml.yaml | 5 +- 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_bml.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_bml.h index 03b1658add..588fb4b6fb 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_bml.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_bml.h @@ -2248,11 +2248,9 @@ class cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE : public BaseClass static eActionOp_BML get_action_op(){ return (eActionOp_BML)(ACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE); } + uint8_t& result(); uint32_t& client_list_size(); - std::string client_list_str(); - char* client_list(size_t length = 0); - bool set_client_list(const std::string& str); - bool set_client_list(const char buffer[], size_t size); + std::tuple client_list(size_t idx); bool alloc_client_list(size_t count = 1); void class_swap() override; bool finalize() override; @@ -2261,8 +2259,9 @@ class cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE : public BaseClass private: bool init(); eActionOp_BML* m_action_op = nullptr; + uint8_t* m_result = nullptr; uint32_t* m_client_list_size = nullptr; - char* m_client_list = nullptr; + sMacAddr* m_client_list = nullptr; size_t m_client_list_idx__ = 0; int m_lock_order_counter__ = 0; }; diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_bml.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_bml.cpp index 83c640541c..9f8d17c275 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_bml.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_bml.cpp @@ -7602,40 +7602,29 @@ BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ } cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::~cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE() { } -uint32_t& cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::client_list_size() { - return (uint32_t&)(*m_client_list_size); +uint8_t& cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::result() { + return (uint8_t&)(*m_result); } -std::string cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::client_list_str() { - char *client_list_ = client_list(); - if (!client_list_) { return std::string(); } - return std::string(client_list_, m_client_list_idx__); +uint32_t& cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::client_list_size() { + return (uint32_t&)(*m_client_list_size); } -char* cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::client_list(size_t length) { - if( (m_client_list_idx__ == 0) || (m_client_list_idx__ < length) ) { - TLVF_LOG(ERROR) << "client_list length is smaller than requested length"; - return nullptr; +std::tuple cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::client_list(size_t idx) { + bool ret_success = ( (m_client_list_idx__ > 0) && (m_client_list_idx__ > idx) ); + size_t ret_idx = ret_success ? idx : 0; + if (!ret_success) { + TLVF_LOG(ERROR) << "Requested index is greater than the number of available entries"; } - return ((char*)m_client_list); + return std::forward_as_tuple(ret_success, m_client_list[ret_idx]); } -bool cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::set_client_list(const std::string& str) { return set_client_list(str.c_str(), str.size()); } -bool cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::set_client_list(const char str[], size_t size) { - if (str == nullptr) { - TLVF_LOG(WARNING) << "set_client_list received a null pointer."; - return false; - } - if (!alloc_client_list(size)) { return false; } - std::copy(str, str + size, m_client_list); - return true; -} bool cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::alloc_client_list(size_t count) { if (m_lock_order_counter__ > 0) {; TLVF_LOG(ERROR) << "Out of order allocation for variable length list client_list, abort!"; return false; } - size_t len = sizeof(char) * count; + size_t len = sizeof(sMacAddr) * count; if(getBuffRemainingBytes() < len ) { TLVF_LOG(ERROR) << "Not enough available space on buffer - can't allocate"; return false; @@ -7653,6 +7642,9 @@ bool cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::alloc_client_list(size_t count LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << len << ") Failed!"; return false; } + if (!m_parse__) { + for (size_t i = m_client_list_idx__ - count; i < m_client_list_idx__; i++) { m_client_list[i].struct_init(); } + } return true; } @@ -7660,6 +7652,9 @@ void cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::class_swap() { tlvf_swap(8*sizeof(eActionOp_BML), reinterpret_cast(m_action_op)); tlvf_swap(32, reinterpret_cast(m_client_list_size)); + for (size_t i = 0; i < m_client_list_idx__; i++){ + m_client_list[i].struct_swap(); + } } bool cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::finalize() @@ -7692,6 +7687,7 @@ bool cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::finalize() size_t cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::get_initial_size() { size_t class_size = 0; + class_size += sizeof(uint8_t); // result class_size += sizeof(uint32_t); // client_list_size return class_size; } @@ -7702,18 +7698,23 @@ bool cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE::init() TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; return false; } + m_result = reinterpret_cast(m_buff_ptr__); + if (!buffPtrIncrementSafe(sizeof(uint8_t))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; + return false; + } m_client_list_size = reinterpret_cast(m_buff_ptr__); if (!m_parse__) *m_client_list_size = 0; if (!buffPtrIncrementSafe(sizeof(uint32_t))) { LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint32_t) << ") Failed!"; return false; } - m_client_list = (char*)m_buff_ptr__; + m_client_list = (sMacAddr*)m_buff_ptr__; uint32_t client_list_size = *m_client_list_size; if (m_parse__) { tlvf_swap(32, reinterpret_cast(&client_list_size)); } m_client_list_idx__ = client_list_size; - if (!buffPtrIncrementSafe(sizeof(char) * (client_list_size))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(char) * (client_list_size) << ") Failed!"; + if (!buffPtrIncrementSafe(sizeof(sMacAddr) * (client_list_size))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) * (client_list_size) << ") Failed!"; return false; } if (m_parse__) { class_swap(); } diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_bml.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_bml.yaml index fe395e82c9..85b6c05152 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_bml.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_bml.yaml @@ -498,11 +498,14 @@ cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST: cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE: _type: class + result: + _type: uint8_t + _comment: # 0 - Failure, 1 - Success client_list_size: _type: uint32_t _length_var: True client_list: - _type: char + _type: sMacAddr _length: [client_list_size] cACTION_BML_CLIENT_SET_CLIENT_REQUEST: From 076a5773f5731e697414b7a857e9fca27e337e63 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Thu, 23 Jul 2020 12:54:34 +0000 Subject: [PATCH 329/453] controller: "get client list" response returns a list of MACs Align with the cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE new structure and fill the response with a list of client's mac addresses. Please note that this commit breaks compilation, but the split is for readability and reviewability. PPM-5. Signed-off-by: Adam Dov --- ci/cppcheck/cppcheck_existing_issues.txt | 1 + .../src/beerocks/master/son_management.cpp | 46 +++++++++++++++---- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/ci/cppcheck/cppcheck_existing_issues.txt b/ci/cppcheck/cppcheck_existing_issues.txt index 1bfdf24dca..c4e34e2a6f 100644 --- a/ci/cppcheck/cppcheck_existing_issues.txt +++ b/ci/cppcheck/cppcheck_existing_issues.txt @@ -96,6 +96,7 @@ controller/src/beerocks/master/son_actions.cpp: performance: Function parameter controller/src/beerocks/master/son_actions.cpp: performance: Function parameter 'sta_mac' should be passed by const reference. [passedByValue] std::string sta_mac, std::string bssid) controller/src/beerocks/master/son_actions.cpp: style: Local variable 'prev_task_id' shadows outer variable [shadowVariable] int prev_task_id = database.get_association_handling_task_id(mac); controller/src/beerocks/master/son_actions.cpp: style: The scope of the variable 'prev_task_id' can be reduced. [variableScope] int prev_task_id; +controller/src/beerocks/master/son_management.cpp: style: Condition '!client_list.size()' is always true [knownConditionTrueFalse] if (!client_list.size()) { controller/src/beerocks/master/son_management.cpp: style: Variable 'op_error_code' is assigned a value that is never used. [unreadVariable] op_error_code = eChannelScanOperationCode::SCAN_IN_PROGRESS; controller/src/beerocks/master/son_management.cpp: style: Variable 'op_error_code' is assigned a value that is never used. [unreadVariable] auto op_error_code = eChannelScanOperationCode::SUCCESS; controller/src/beerocks/master/son_management.cpp: style: Variable 'result_status' is assigned a value that is never used. [unreadVariable] result_status = last_scan_success; diff --git a/controller/src/beerocks/master/son_management.cpp b/controller/src/beerocks/master/son_management.cpp index 549c748b73..25a724db58 100644 --- a/controller/src/beerocks/master/son_management.cpp +++ b/controller/src/beerocks/master/son_management.cpp @@ -1710,7 +1710,7 @@ void son_management::handle_bml_message(Socket *sd, response->result() = result; if (!message_com::send_cmdu(sd, cmdu_tx)) { - LOG(ERROR) << "Error sending get vaps list responce message"; + LOG(ERROR) << "Error sending get vaps list response message"; } break; } @@ -2130,7 +2130,7 @@ void son_management::handle_bml_message(Socket *sd, break; } - //Results avaliablity check + //Results availability check if (scan_results_size == 0) { LOG(DEBUG) << "no scan results are available"; auto response = gen_new_results_response(); @@ -2276,15 +2276,45 @@ void son_management::handle_bml_message(Socket *sd, break; } - std::string client_list = ""; - // TODO: replace empty string with a list of configured clients read from controller-db - if (!response->alloc_client_list(client_list.size())) { - LOG(ERROR) << "Failed client_list allocation to size=" << client_list.size(); + auto send_response = [&](bool result) { + //TODO: replace all BML_CLIENT requests to use boolean: (0=failure, 1-=success) + response->result() = (result) ? 0 : 1; + if (!message_com::send_cmdu(sd, cmdu_tx)) { + LOG(ERROR) << "Error sending get client list response message"; + } + }; + + // TODO: replace with a list of configured clients read from controller-db + std::vector client_list; + if (!client_list.size()) { + LOG(DEBUG) << "client list is empty!"; + // Send a valid response with an empty list + send_response(true); break; } - response->set_client_list(client_list); - message_com::send_cmdu(sd, cmdu_tx); + auto client_list_size = client_list.size(); + LOG(INFO) << "Returning " << client_list_size << " clients to BML caller"; + + if (!response->alloc_client_list(client_list_size)) { + LOG(ERROR) << "Failed buffer allocation to size = " << int(client_list_size); + send_response(false); + break; + } + + auto client_list_tuple = response->client_list(0); + if (!std::get<0>(client_list_tuple)) { + LOG(ERROR) << "client list access fail!"; + send_response(false); + break; + } + + auto clients = &std::get<1>(client_list_tuple); + for (size_t i = 0; i < client_list.size(); i++) { + clients[i] = client_list[i]; + } + + send_response(true); break; } case beerocks_message::ACTION_BML_CLIENT_SET_CLIENT_REQUEST: { From 15c69601d1a432de6a4e0c73aa51a03ef1d16e22 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Thu, 23 Jul 2020 12:58:23 +0000 Subject: [PATCH 330/453] bml: move translation to bml structure to bml_internal Preparative Commit. The current implementation expects the bml_internal to provide a list of mac addresses as an `std::string` - instead of propagating the BML structure and let the bml_internal to handle it. Changed the `bml_internal::client_get_client_list()` signature to match the BML API and removed any translation performed in the bml.cpp calling function. Please note that this commit breaks compilation, but the split is for readability and reviewability. PPM-5. Signed-off-by: Adam Dov --- controller/src/beerocks/bml/bml.cpp | 9 +-------- controller/src/beerocks/bml/internal/bml_internal.cpp | 10 +++++----- controller/src/beerocks/bml/internal/bml_internal.h | 2 +- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/controller/src/beerocks/bml/bml.cpp b/controller/src/beerocks/bml/bml.cpp index 9f5ddb4a49..59b5755df8 100644 --- a/controller/src/beerocks/bml/bml.cpp +++ b/controller/src/beerocks/bml/bml.cpp @@ -691,14 +691,7 @@ int bml_client_get_client_list(BML_CTX ctx, char *client_list, unsigned int *cli } auto pBML = static_cast(ctx); - std::string temp_client_list; - int ret = pBML->client_get_client_list(temp_client_list, client_list_size); - if (ret == BML_RET_OK) { - beerocks::string_utils::copy_string(client_list, temp_client_list.c_str(), - *client_list_size); - } - - return ret; + return pBML->client_get_client_list(client_list, client_list_size); } int bml_client_set_client(BML_CTX ctx, const char *sta_mac, diff --git a/controller/src/beerocks/bml/internal/bml_internal.cpp b/controller/src/beerocks/bml/internal/bml_internal.cpp index 346e872a20..9ec76a44a8 100644 --- a/controller/src/beerocks/bml/internal/bml_internal.cpp +++ b/controller/src/beerocks/bml/internal/bml_internal.cpp @@ -1817,12 +1817,12 @@ int bml_internal::start_dcs_single_scan(const sMacAddr &mac, int dwell_time_ms, return BML_RET_OK; } -int bml_internal::client_get_client_list(std::string &client_list, unsigned int *client_list_size) +int bml_internal::client_get_client_list(char *client_list, unsigned int *client_list_size) { LOG(DEBUG) << "client_get_client_list"; - if (!client_list_size) { - LOG(ERROR) << "Size param must be initialized"; + if (!client_list || !client_list_size) { + LOG(ERROR) << "Invalid input: null pointers"; return (-BML_RET_INVALID_DATA); } @@ -2304,8 +2304,8 @@ int bml_internal::register_event_cb(BML_EVENT_CB pCB) } if (!message_com::send_cmdu(m_sockMaster, cmdu_tx)) { - LOG(ERROR) - << "Failed sending ACTION_BML_REGISTER/UNREGISTER_TO_EVENTS_UPDATES_REQUEST message!"; + LOG(ERROR) << "Failed sending ACTION_BML_REGISTER/UNREGISTER_TO_EVENTS_UPDATES_REQUEST " + "message!"; return (-BML_RET_OP_FAILED); } diff --git a/controller/src/beerocks/bml/internal/bml_internal.h b/controller/src/beerocks/bml/internal/bml_internal.h index ab0964881d..9c085e2694 100644 --- a/controller/src/beerocks/bml/internal/bml_internal.h +++ b/controller/src/beerocks/bml/internal/bml_internal.h @@ -268,7 +268,7 @@ class bml_internal : public beerocks::socket_thread { * @param [in,out] client_list_size Size of client list. * @return BML_RET_OK on success. */ - int client_get_client_list(std::string &client_list, unsigned int *client_list_size); + int client_get_client_list(char *client_list, unsigned int *client_list_size); /** * Set client configuration. From 2092c3da83b8daf18a646688b070457aa7b38a31 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Thu, 23 Jul 2020 13:06:21 +0000 Subject: [PATCH 331/453] bml: implement translation to bml structure to bml_internal The current implementation expects the bml_internal to provide a list of mac addresses as an `std::string` - instead of propagating the BML structure and let the bml_internal to handle it. Changed the `bml_internal::client_get_client_list()` to read the list of clients from the response message. Changed the ACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE handling to translate the above-mentioned list into a char-array string containing a comma-separated list of mac addresses, according to the size limitation provided. PPM-5. Signed-off-by: Adam Dov --- .../beerocks/bml/internal/bml_internal.cpp | 108 +++++++++++++++--- .../src/beerocks/bml/internal/bml_internal.h | 14 +-- 2 files changed, 96 insertions(+), 26 deletions(-) diff --git a/controller/src/beerocks/bml/internal/bml_internal.cpp b/controller/src/beerocks/bml/internal/bml_internal.cpp index 9ec76a44a8..43f5e6e84f 100644 --- a/controller/src/beerocks/bml/internal/bml_internal.cpp +++ b/controller/src/beerocks/bml/internal/bml_internal.cpp @@ -1130,6 +1130,12 @@ int bml_internal::process_cmdu_header(std::shared_ptr beerocks_ } break; case beerocks_message::ACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE: { LOG(DEBUG) << "ACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE received"; + + if (!m_prmClientListGet) { + LOG(WARNING) << "Received GET_CLIENT_LIST response, but no one is waiting..."; + break; + } + auto response = beerocks_header ->addClass(); @@ -1138,21 +1144,49 @@ int bml_internal::process_cmdu_header(std::shared_ptr beerocks_ return BML_RET_OP_FAILED; } - //Signal any waiting threads - if (m_prmClientListGet) { - bool promise_result = false; - if (m_client_list && m_client_list_size) { - *m_client_list_size = *m_client_list_size <= response->client_list_size() - ? response->client_list_size() - : *m_client_list_size; - *m_client_list = response->client_list_str(); - promise_result = true; + if (!m_client_list || !m_client_list_size) { + LOG(ERROR) << "The pointer to the user data buffer is null!"; + m_prmClientListGet->set_value(false); + break; + } + + if (response->result() != 0) { + LOG(ERROR) << "GET_CLIENT_LIST_REQUEST failed with error: " << response->result(); + m_prmClientListGet->set_value(false); + break; + } + + auto client_list_size = response->client_list_size(); + LOG(INFO) << "Received " << client_list_size << " clients from the controller"; + // Store the received data. + if (client_list_size == 0) { + LOG(DEBUG) << "Received an empty client list!"; + m_prmClientListGet->set_value(true); + break; + } + + LOG_IF((client_list_size > *m_client_list_size), WARNING) + << "Not enough space in input buffer, writing " << *m_client_list_size << "/" + << client_list_size << " clients"; + + uint8_t max_clients_size = std::min(client_list_size, *m_client_list_size); + + bool failed_to_copy = false; + for (uint8_t index = 0; index < max_clients_size; ++index) { + auto client_list_tuple = response->client_list(index); + if (!std::get<0>(client_list_tuple)) { + LOG(ERROR) << "client list access fail!"; + m_prmClientListGet->set_value(false); + failed_to_copy = true; + break; } - m_prmClientListGet->set_value(promise_result); - } else { - LOG(WARNING) << "Received ACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE response, " - << "but no one is waiting..."; + + auto &client_element = std::get<1>(client_list_tuple); + m_client_list->push_back(client_element); } + + *m_client_list_size = m_client_list->size(); + m_prmClientListGet->set_value(!failed_to_copy); } break; case beerocks_message::ACTION_BML_CLIENT_SET_CLIENT_RESPONSE: { LOG(DEBUG) << "ACTION_BML_CLIENT_SET_CLIENT_RESPONSE received"; @@ -1821,11 +1855,19 @@ int bml_internal::client_get_client_list(char *client_list, unsigned int *client { LOG(DEBUG) << "client_get_client_list"; + // Invalid input if (!client_list || !client_list_size) { LOG(ERROR) << "Invalid input: null pointers"; return (-BML_RET_INVALID_DATA); } + // Not enough space for even one result + if (*client_list_size < (network_utils::ZERO_MAC_STRING.size() + 1)) { + LOG(ERROR) << "Invalid input: insufficient minimal space for results, client-list-max-size=" + << *client_list_size; + return (-BML_RET_INVALID_DATA); + } + // If the socket is not valid, attempt to re-establish the connection if (!m_sockMaster) { int iRet = connect_to_master(); @@ -1837,10 +1879,16 @@ int bml_internal::client_get_client_list(char *client_list, unsigned int *client // Initialize the promise for receiving the response beerocks::promise prmClientListGet; - m_prmClientListGet = &prmClientListGet; - int iOpTimeout = RESPONSE_TIMEOUT; // Default timeout - m_client_list = &client_list; - m_client_list_size = client_list_size; + m_prmClientListGet = &prmClientListGet; + int iOpTimeout = RESPONSE_TIMEOUT; // Default timeout + auto client_mac_list = std::list(); + m_client_list = &client_mac_list; + uint32_t client_mac_list_max_count = + *client_list_size / (network_utils::ZERO_MAC_STRING.size() + 1); // The 1 is for delimiters + m_client_list_size = &client_mac_list_max_count; + + // Save client list max size to be used as copy-to-buffer max size when results are received + auto client_list_max_size = *client_list_size; auto request = message_com::create_vs_message< beerocks_message::cACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST>(cmdu_tx); @@ -1874,8 +1922,30 @@ int bml_internal::client_get_client_list(char *client_list, unsigned int *client // Clear the promise holder m_prmClientListGet = nullptr; - LOG_IF(iRet != BML_RET_OK, ERROR) - << "Get client list request returned with error code:" << iRet; + if (iRet != BML_RET_OK) { + LOG(ERROR) << "Get client list request returned with error code:" << iRet; + return (iRet); + } + + bool result = prmClientListGet.get_value(); + LOG(DEBUG) << "Promise resolved, received " << client_mac_list.size() << " clients"; + if (!result) { + LOG(ERROR) << "Get client list request failed"; + return -BML_RET_OP_FAILED; + } + + // Translate sMacAddr list to string + std::string client_list_str; + for (const auto &client : client_mac_list) { + auto mac_str = tlvf::mac_to_string(client); + client_list_str.append(mac_str); + client_list_str.append(","); + } + + // Return results + *client_list_size = client_list_str.size(); + client_list_str.back() = '\0'; + beerocks::string_utils::copy_string(client_list, client_list_str.c_str(), client_list_max_size); return BML_RET_OK; } diff --git a/controller/src/beerocks/bml/internal/bml_internal.h b/controller/src/beerocks/bml/internal/bml_internal.h index 9c085e2694..16945c81c4 100644 --- a/controller/src/beerocks/bml/internal/bml_internal.h +++ b/controller/src/beerocks/bml/internal/bml_internal.h @@ -381,13 +381,13 @@ class bml_internal : public beerocks::socket_thread { //m_scan_results_status is used to store the results' latest status uint8_t *m_scan_results_status = nullptr; //m_scan_results_maxsize is used to indicate the maximum capacity of the requested results - uint32_t *m_scan_results_maxsize = nullptr; - std::string *m_client_list = nullptr; - uint32_t *m_client_list_size = nullptr; - BML_CLIENT *m_client = nullptr; - BML_VAP_INFO *m_vaps = nullptr; - uint8_t *m_pvaps_list_size = nullptr; - uint16_t id = 0; + uint32_t *m_scan_results_maxsize = nullptr; + std::list *m_client_list = nullptr; + uint32_t *m_client_list_size = nullptr; + BML_CLIENT *m_client = nullptr; + BML_VAP_INFO *m_vaps = nullptr; + uint8_t *m_pvaps_list_size = nullptr; + uint16_t id = 0; static bool s_fExtLogContext; }; From 48a56c6084d12cbedb3fd13ee38a212da4436501 Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Fri, 24 Jul 2020 18:59:36 +0200 Subject: [PATCH 332/453] .gitlab-ci.yml: boardfarm-tests: add missing dependency on image We need an explicit dependency on image-build-boardfarm-ci, since it's not implied by build-in-docker. In most cases, image-build-boardfarm-ci will be finished before build-in-docker is even started, but there's no guarantee (as observed at least once). Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5659353779..090b7315eb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -241,6 +241,7 @@ boardfarm-tests: - results needs: - job: build-in-docker + - job: image-build-boardfarm-ci tags: - boardfarm From c7154609618d615cf358d503740ab14b5f83fa8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Mon, 13 Jul 2020 09:23:45 +0200 Subject: [PATCH 333/453] ci: easymesh_cert: collect hostapd logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When debugging issues with hostapd, having its debug logs is precious. Before starting hostapd, set hostapd's log level to '1' (debug) for the syslog logger. At the end of the test, run "logread" to get the logs and save them under 'syslog.log'. While we're at it, also fix the capture of multiple hostapd commands for devices using another phy than phy1 and phy2. Also include a call to synchronize the DUT clock with the UCC clock before running the test. Signed-off-by: Raphaël Mélotte --- ci/easymesh_cert_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/easymesh_cert_version b/ci/easymesh_cert_version index ba7f7e89f1..a90fa08b78 100644 --- a/ci/easymesh_cert_version +++ b/ci/easymesh_cert_version @@ -1 +1 @@ -efaa40ec857e3724954b297cc812ff871569322a +399a33ca960cece195c3605d08951b8766e6c90d From 31af9618d555c37197da34c0a738718e0118b2fb Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Tue, 28 Jul 2020 10:34:23 +0300 Subject: [PATCH 334/453] bwl: dwpal: add scan dump in progress flag Currently the NL messages are received for both interfaces regardless of which started the scan. This becomes an issue with the Channel_Scan_Finished message, since it's only identifier is the message's sequence number (nlh->nlmsg_seq). So to solve this issue we store the sequence number present in the Channel_Scan_Dump_Result message, and validate it against the one received in the Channel_Scan_Finished message. But when the scan returns with no neighboring APs the scan dump sequence only contains the Channel_Scan_Finished, so we don't have an initial sequence number to store, and later on validate against. Added a scan dump in progress flag and validate against it, since the DCS task does not allow for two scans in progress. PPM-319 Signed-off-by: Itay Elenzweig --- .../beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp | 76 +++++++++++++------ .../beerocks/bwl/dwpal/mon_wlan_hal_dwpal.h | 3 + 2 files changed, 55 insertions(+), 24 deletions(-) diff --git a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp index 6ee6857f83..ba07244c18 100644 --- a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp @@ -1346,38 +1346,59 @@ bool mon_wlan_hal_dwpal::process_dwpal_nl_event(struct nl_msg *msg) return true; } - // We need to distinguish 1st and rest of dump events (NL80211_CMD_NEW_SCAN_RESULTS) - // 1st event is an empty dump result that we should reply with scan dump request. - // nlh->nlmsg_seq = 0 only with the 1st dump result. - // rest of events are the actual scan dump results that need to be parsed. - // unique sequence number is chosen by the nl (nlh->nlmsg_seq != 0) for the rest of events. + /* + As part of the scan results dump sequence, we always receive at least two messages. + NL80211_CMD_NEW_SCAN_RESULTS (Channel_Scan_Dump_Result) & SCAN_FINISH_CB + (Channel_Scan_Finished). + + We receive the Channel_Scan_Dump_Result once to alert us that we have pending results + waiting, so on the first occurrence of the message, we request the rest of the dump results. + + On the 2nd->Nth Channel_Scan_Dump_Result we receive a sequence number which we can use + to indicate the current message is part of the active dump sequence. + + The last message received as part of the dump sequence is Channel_Scan_Finished, which + indicates that there are no more pending scan dumps. + + In case we have no neighboring beacons for a particular scan we would only receive + the initial Channel_Scan_Dump_Result followed right after by a Channel_Scan_Finished. + This can cause an issue since we would not have an initial sequence number to later + validate against. + + To solve this issue we add a "scan dump in progress flag" to verify against later on. + */ if (m_nl_seq == 0) { if (nlh->nlmsg_seq == 0) { + // First "empty" Channel_Scan_Dump_Result message LOG(DEBUG) << "Results dump are ready"; event_queue_push(Event::Channel_Scan_New_Results_Ready); + m_scan_dump_in_progress = true; channel_scan_dump_results(); return true; } else { + //2nd -> Nth Channel_Scan_Dump_Result LOG(DEBUG) << "Results dump new sequence:" << int(nlh->nlmsg_seq); m_nl_seq = nlh->nlmsg_seq; } } - if (m_nl_seq == nlh->nlmsg_seq) { - LOG(DEBUG) << "DWPAL NL event channel scan results dump, seq = " << int(nlh->nlmsg_seq); + // Check if current Channel_Scan_Dump_Result is part of the dump sequence. + if (m_nl_seq != nlh->nlmsg_seq) { + LOG(ERROR) << "channel scan results dump received with unexpected seq number"; + return false; + } - auto results = std::make_shared(); + LOG(DEBUG) << "DWPAL NL event channel scan results dump, seq = " << int(nlh->nlmsg_seq); - if (!get_scan_results_from_nl_msg(results->channel_scan_results, msg)) { - LOG(ERROR) << "read NL msg to monitor msg failed!"; - return false; - } - LOG(DEBUG) << "Processing results for BSSID:" << results->channel_scan_results.bssid; - event_queue_push(event, results); - } else { - LOG(ERROR) << "channel scan results dump received with unexpected seq number"; + auto results = std::make_shared(); + + if (!get_scan_results_from_nl_msg(results->channel_scan_results, msg)) { + LOG(ERROR) << "read NL msg to monitor msg failed!"; return false; } + + LOG(DEBUG) << "Processing results for BSSID:" << results->channel_scan_results.bssid; + event_queue_push(event, results); break; } case Event::Channel_Scan_Abort: { @@ -1389,15 +1410,22 @@ bool mon_wlan_hal_dwpal::process_dwpal_nl_event(struct nl_msg *msg) } LOG(DEBUG) << "DWPAL NL event channel scan aborted"; - //zero sequence number for next scan - m_nl_seq = 0; - + //reset scan indicators for next scan + m_nl_seq = 0; + m_scan_dump_in_progress = false; event_queue_push(event); break; } case Event::Channel_Scan_Finished: { - // ifname is corrupted for Channel_Scan_Finished event using nlh->nlmsg_seq instead. - if (nlh->nlmsg_seq != m_nl_seq) { + + // We are not in a dump sequence, ignoring the message + if (!m_scan_dump_in_progress) { + return true; + } + + // ifname is invalid for Channel_Scan_Finished event using nlh->nlmsg_seq instead. + // In case there are no results first check if current sequence number was set. + if (m_nl_seq != 0 && nlh->nlmsg_seq != m_nl_seq) { // Current event has a sequence number not matching the current sequence number // meaning the event was recevied for a diffrent channel return true; @@ -1406,9 +1434,9 @@ bool mon_wlan_hal_dwpal::process_dwpal_nl_event(struct nl_msg *msg) LOG(DEBUG) << "DWPAL NL event channel scan results finished for sequence: " << (int)nlh->nlmsg_seq; - //zero sequence number for next scan - m_nl_seq = 0; - + //reset scan indicators for next scan + m_nl_seq = 0; + m_scan_dump_in_progress = false; event_queue_push(event); break; } diff --git a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.h b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.h index 811ac330e9..d1838e9535 100644 --- a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.h +++ b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.h @@ -113,7 +113,10 @@ class mon_wlan_hal_dwpal : public base_wlan_hal_dwpal, public mon_wlan_hal { } std::shared_ptr m_temp_dwpal_value; + // Unique sequence number for the scan result dump sequence uint32_t m_nl_seq = 0; + // Flag indicating if we are currently in a dump sequence + bool m_scan_dump_in_progress = false; }; } // namespace dwpal From 99d02bf47ec658e4903f259f8827cba987697d39 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Mon, 27 Jul 2020 14:52:48 +0000 Subject: [PATCH 335/453] framework: CMake: Change installation path of framework logging.conf On the RDKB recipe, we remove the "share" folder so we don't have the logging.conf file anywhere, and this causing the transport to use default configuration which is - printing everything to the console. Change the framework logging configuration file installation path to the folder "config" because it makes more sense to place it there. Signed-off-by: Moran Shoeg --- framework/common/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/common/CMakeLists.txt b/framework/common/CMakeLists.txt index c892eac6d9..99e343d5d0 100644 --- a/framework/common/CMakeLists.txt +++ b/framework/common/CMakeLists.txt @@ -3,8 +3,8 @@ configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/logging.conf.in" "${CMAKE_CURRENT_BINARY_DIR}/logging.conf" ) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/logging.conf" DESTINATION share) -file(COPY "${CMAKE_CURRENT_BINARY_DIR}/logging.conf" DESTINATION "${CMAKE_MULTIAP_OUTPUT_DIRECTORY}/share/") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/logging.conf" DESTINATION config) +file(COPY "${CMAKE_CURRENT_BINARY_DIR}/logging.conf" DESTINATION "${CMAKE_MULTIAP_OUTPUT_DIRECTORY}/config/") # mapfcommon sources set(sources logger.cpp encryption.cpp utils.cpp) From e5cc333e486102556c09a9b8fe5d3ba75a13056a Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Mon, 27 Jul 2020 14:54:13 +0000 Subject: [PATCH 336/453] framework: Rename framework logging.conf Rename it to framework_logging.conf to make it more clear and not confuse it with beerocks logging. Signed-off-by: Moran Shoeg --- framework/common/CMakeLists.txt | 8 ++++---- .../common/{logging.conf.in => framework_logging.conf.in} | 0 2 files changed, 4 insertions(+), 4 deletions(-) rename framework/common/{logging.conf.in => framework_logging.conf.in} (100%) diff --git a/framework/common/CMakeLists.txt b/framework/common/CMakeLists.txt index 99e343d5d0..028a9388f1 100644 --- a/framework/common/CMakeLists.txt +++ b/framework/common/CMakeLists.txt @@ -1,10 +1,10 @@ # Logging configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/logging.conf.in" - "${CMAKE_CURRENT_BINARY_DIR}/logging.conf" + "${CMAKE_CURRENT_SOURCE_DIR}/framework_logging.conf.in" + "${CMAKE_CURRENT_BINARY_DIR}/framework_logging.conf" ) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/logging.conf" DESTINATION config) -file(COPY "${CMAKE_CURRENT_BINARY_DIR}/logging.conf" DESTINATION "${CMAKE_MULTIAP_OUTPUT_DIRECTORY}/config/") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/framework_logging.conf" DESTINATION config) +file(COPY "${CMAKE_CURRENT_BINARY_DIR}/framework_logging.conf" DESTINATION "${CMAKE_MULTIAP_OUTPUT_DIRECTORY}/config/") # mapfcommon sources set(sources logger.cpp encryption.cpp utils.cpp) diff --git a/framework/common/logging.conf.in b/framework/common/framework_logging.conf.in similarity index 100% rename from framework/common/logging.conf.in rename to framework/common/framework_logging.conf.in From 91d5b6948ba93a29e5c8f342f3909848575810bd Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Mon, 27 Jul 2020 14:56:24 +0000 Subject: [PATCH 337/453] framework: Update reading path of the logging configuration file Update the path of the logging configuration file to the new path. Signed-off-by: Moran Shoeg --- framework/common/include/mapf/common/logger.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/common/include/mapf/common/logger.h b/framework/common/include/mapf/common/logger.h index c148374aee..629af76463 100644 --- a/framework/common/include/mapf/common/logger.h +++ b/framework/common/include/mapf/common/logger.h @@ -27,8 +27,8 @@ #define MAPF_DBG_IF(cond, msg) \ LOG_IF(cond, DEBUG) << msg << resetiosflags((std::ios_base::fmtflags)0xFFFF) -#define CONF_FILE_PATH std::string(MAPF_ROOT) + "/share/logging.conf" -#define CONF_FILE_TMP_PATH std::string("/tmp/share/logging.conf") +#define CONF_FILE_PATH std::string(MAPF_ROOT) + "/config/framework_logging.conf" +#define CONF_FILE_TMP_PATH std::string("/tmp/share/framework_logging.conf") extern char *__progname; struct json_object; From fa287c4081a4b16500a69d0ca7c970d8942a302d Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Fri, 24 Jul 2020 14:17:20 +0200 Subject: [PATCH 338/453] bwl: dwpal: fix sta_wlan_hal_dwpal::roam return code Return code of method sta_wlan_hal_dwpal::roam() must be true on success. Signed-off-by: Mario Maz --- common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp index 000ae0aa76..22fa6b9a12 100644 --- a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp @@ -330,7 +330,7 @@ bool sta_wlan_hal_dwpal::roam(const sMacAddr &bssid, uint8_t channel) m_active_bssid.assign(bssid_str); m_active_channel = channel; - return false; + return true; } bool sta_wlan_hal_dwpal::get_4addr_mode() From 02f8b298ad5db53731766ca9ab5e1276aa685d2e Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Tue, 21 Jul 2020 18:04:06 +0200 Subject: [PATCH 339/453] bwl: nl80211: complete sta_wlan_hal https://jira.prplfoundation.org/browse/PPM-2 The sta_wlan_hal for nl80211 is only partially implemented. Complete it with methods connect, disconnect, roam, is_connected and update_status. A large part of the code can be taken from dwpal. The rest seems unused or unnecessary in easymesh flows. Signed-off-by: Mario Maz --- .../bwl/nl80211/sta_wlan_hal_nl80211.cpp | 321 +++++++++++++++++- .../bwl/nl80211/sta_wlan_hal_nl80211.h | 159 +++++++++ 2 files changed, 476 insertions(+), 4 deletions(-) diff --git a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp index 15838ccb07..539c0b6896 100644 --- a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp +++ b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.cpp @@ -16,6 +16,28 @@ namespace bwl { namespace nl80211 { +// Convert BWL to NL80211 security string +static std::string nl80211_security_val(WiFiSec sec) +{ + switch (sec) { + case WiFiSec::None: + return "NONE"; + case WiFiSec::WEP_64: + return "WEP-64"; + case WiFiSec::WEP_128: + return "WEP-128"; + case WiFiSec::WPA_PSK: + return "WPA-PSK"; + case WiFiSec::WPA2_PSK: + return "WPA-PSK"; + case WiFiSec::WPA_WPA2_PSK: + return "WPA-PSK"; + + default: + return "INVALID"; + } +} + sta_wlan_hal_nl80211::sta_wlan_hal_nl80211(const std::string &iface_name, hal_event_cb_t callback, const bwl::hal_conf_t &hal_conf) : base_wlan_hal(bwl::HALType::Station, iface_name, IfaceType::Intel, callback, hal_conf), @@ -41,12 +63,136 @@ bool sta_wlan_hal_nl80211::connect(const std::string &ssid, const std::string &p bool mem_only_psk, const std::string &bssid, uint8_t channel, bool hidden_ssid) { + LOG(DEBUG) << "Connect interface " << get_iface_name() << " to SSID = " << ssid + << ", BSSID = " << bssid << ", Channel = " << int(channel) + << ", Sec = " << nl80211_security_val(sec) << ", mem_only_psk=" << int(mem_only_psk); + + if (ssid.empty() || bssid.empty() || sec == WiFiSec::Invalid) { + LOG(ERROR) << "Invalid params!"; + return false; + } + + // First disconnect (or do nothing if not connected) + if (!disconnect()) { + LOG(WARNING) << "Failed disconnecting before connecting to the new BSSID"; + return false; + } + + // Add a new network + auto network_id = add_network(); + if (network_id < 0) { + LOG(ERROR) << "Failed (" << network_id + << ") adding new network to interface: " << get_iface_name(); + return false; + } + + auto freq = son::wireless_utils::channel_to_freq(int(channel)); + + // Update network parameters + if (!set_network_params(network_id, ssid, bssid, sec, mem_only_psk, pass, hidden_ssid, freq)) { + LOG(ERROR) << "Failed setting network id = " << network_id + << " on interface: " << get_iface_name(); + return false; + } + + // Enable the network + if (!enable_network(network_id)) { + LOG(ERROR) << "Failed enabling network id = " << network_id + << " on interface: " << get_iface_name(); + return false; + } + + LOG(DEBUG) << "Network with id " << network_id << " has been added and enabled on interface " + << get_iface_name(); + + // Update active network parameters + m_active_ssid.assign(ssid); + m_active_bssid.assign(bssid); + m_active_pass.assign(pass); + m_active_channel = channel; + m_active_network_id = network_id; + return true; } -bool sta_wlan_hal_nl80211::disconnect() { return true; } +bool sta_wlan_hal_nl80211::disconnect() +{ + LOG(TRACE) << "Disconnect network id " << m_active_network_id + << " on interface: " << get_iface_name(); + + ConnectionStatus connection_status; + if (!read_status(connection_status)) { + LOG(ERROR) << "Failed reading status for " << get_iface_name() << "! can't disconnect"; + return false; + } -bool sta_wlan_hal_nl80211::roam(const sMacAddr &bssid, uint8_t channel) { return true; } + // Return gracefully if network state is not connected + if (!is_connected(connection_status.wpa_state)) { + LOG(DEBUG) << "Active network is not connected"; + return true; + } + + // Return gracefully if no network is connected + if (m_active_network_id < 0) { + LOG(DEBUG) << "Active network does not exist"; + return true; + } + + // Connection status id must be the same as the active network id + if (m_active_network_id != connection_status.id) { + LOG(ERROR) << "Network id mismatch: m_active_network_id(" << m_active_network_id << ") != " + << "connection_status.id(" << connection_status.id << ")"; + return false; + } + + const std::string cmd = "REMOVE_NETWORK " + std::to_string(m_active_network_id); + if (!wpa_ctrl_send_msg(cmd)) { + LOG(ERROR) << "WPA command '" << cmd << "' failed"; + } + + // Clear state + m_active_ssid = ""; + m_active_bssid = ""; + m_active_pass = ""; + m_active_channel = 0; + m_active_network_id = -1; + + return true; +} + +bool sta_wlan_hal_nl80211::roam(const sMacAddr &bssid, uint8_t channel) +{ + if (m_active_network_id == -1) { + LOG(ERROR) << "Incorrect active network " << m_active_network_id; + return false; + } + + if (!is_connected()) { + LOG(ERROR) << get_iface_name() << " Not connected, can't roam"; + return false; + } + + auto freq = son::wireless_utils::channel_to_freq(int(channel)); + if (!set_network(m_active_network_id, "freq_list", std::to_string(freq))) { + LOG(ERROR) << "Failed setting frequency on interface " << get_iface_name(); + return false; + } + + auto bssid_str = tlvf::mac_to_string(bssid); + + const std::string cmd = "ROAM " + bssid_str; + if (!wpa_ctrl_send_msg(cmd)) { + LOG(ERROR) << "WPA command '" << cmd << "' failed"; + ; + return false; + } + + // Update the active channel and bssid + m_active_bssid.assign(bssid_str); + m_active_channel = channel; + + return true; +} bool sta_wlan_hal_nl80211::get_4addr_mode() { return true; } @@ -59,7 +205,18 @@ bool sta_wlan_hal_nl80211::unassoc_rssi_measurement(const std::string &mac, int return true; } -bool sta_wlan_hal_nl80211::is_connected() { return true; } +bool sta_wlan_hal_nl80211::is_connected() +{ + ConnectionStatus connection_status; + constexpr int max_retries = 10; + int retry = 0; + while ((!read_status(connection_status)) && (retry++ < max_retries)) { + LOG(ERROR) << "Failed to read connection status, retry: " << retry; + usleep(1000); + } + + return is_connected(connection_status.wpa_state); +} int sta_wlan_hal_nl80211::get_channel() { return m_active_channel; } @@ -69,7 +226,163 @@ std::string sta_wlan_hal_nl80211::get_bssid() { return m_active_bssid; } bool sta_wlan_hal_nl80211::process_nl80211_event(parsed_obj_map_t &parsed_obj) { return true; } -bool sta_wlan_hal_nl80211::update_status() { return false; } +bool sta_wlan_hal_nl80211::update_status() +{ + ConnectionStatus connection_status; + if (!read_status(connection_status)) { + LOG(ERROR) << "Failed reading connection status for iface: " << get_iface_name(); + return false; + } + update_status(connection_status); + + return true; +} + +int sta_wlan_hal_nl80211::add_network() +{ + char *reply = nullptr; + + std::string cmd = "ADD_NETWORK"; + if (!wpa_ctrl_send_msg(cmd, &reply)) { + LOG(ERROR) << "WPA command '" << cmd << "' failed"; + ; + return -1; + } + + // Return the newly added network ID + return beerocks::string_utils::stoi(reply); +} + +bool sta_wlan_hal_nl80211::set_network(int network_id, const std::string ¶m, + const std::string &value) +{ + const std::string cmd = "SET_NETWORK " + std::to_string(network_id) + " " + param + " " + value; + if (!wpa_ctrl_send_msg(cmd)) { + LOG(ERROR) << "WPA command '" << cmd << "' failed"; + ; + return false; + } + return true; +} + +bool sta_wlan_hal_nl80211::set_network_params(int network_id, const std::string &ssid, + const std::string &bssid, WiFiSec sec, + bool mem_only_psk, const std::string &pass, + bool hidden_ssid, int freq) +{ + // Set SSID + if (!set_network(network_id, "ssid", "\"" + ssid + "\"")) { + LOG(ERROR) << "Failed setting ssid on interface " << get_iface_name(); + return false; + } + + // Set BSSID + if (!set_network(network_id, "bssid", bssid)) { + LOG(ERROR) << "Failed setting bssid on interface " << get_iface_name(); + return false; + } + + // Optional: set frequency + if ((freq > 0) && (!set_network(network_id, "freq_list", std::to_string(freq)))) { + LOG(ERROR) << "Failed setting frequency on interface " << get_iface_name(); + return false; + } + + // Security and Password + if (!set_network(network_id, "key_mgmt", nl80211_security_val(sec))) { + LOG(ERROR) << "Failed setting key_mgmt on interface " << get_iface_name(); + return false; + } + + // Optional: set hidden-ssid + if (hidden_ssid && (!set_network(network_id, "scan_ssid", "1"))) { + LOG(ERROR) << "Failed setting scan_ssid on interface " << get_iface_name(); + return false; + } + + // mem_only_psk flag tells whether to keep PSK/passphrase only in memory. + // Possible values are: + // 0 = allow PSK/passphrase to be stored to the configuration file + // 1 = do not store PSK/passphrase to the configuration file + // If false, then set the WPA ASCII passphrase. The PSK is computed from the quoted + // "passphrase" string (PSK could be used instead but passing it without quotes). + if (mem_only_psk) { + if (!set_network(network_id, "mem_only_psk", "1")) { + LOG(ERROR) << "Failed setting mem_only_psk on interface " << get_iface_name(); + return false; + } + } else if ((!pass.empty()) && (!set_network(network_id, "psk", "\"" + pass + "\""))) { + LOG(ERROR) << "Failed setting psk on interface " << get_iface_name(); + return false; + } + + return true; +} + +bool sta_wlan_hal_nl80211::enable_network(int network_id) +{ + const std::string cmd = "ENABLE_NETWORK " + std::to_string(network_id); + if (!wpa_ctrl_send_msg(cmd)) { + LOG(ERROR) << "WPA command '" << cmd << "' failed"; + ; + return false; + } + + return true; +} + +bool sta_wlan_hal_nl80211::is_connected(const std::string &wpa_state) +{ + return (wpa_state.compare("COMPLETED") == 0); +} + +bool sta_wlan_hal_nl80211::read_status(ConnectionStatus &connection_status) +{ + const char *cmd = "STATUS"; + parsed_obj_map_t reply; + if (!wpa_ctrl_send_msg(cmd, reply)) { + LOG(ERROR) << "WPA command '" << cmd << "' failed"; + ; + return false; + } + + connection_status.bssid = reply["bssid"]; + connection_status.freq = std::strtoul(reply["freq"].c_str(), nullptr, 10); + connection_status.ssid = reply["ssid"]; + connection_status.id = std::strtoul(reply["id"].c_str(), nullptr, 10); + connection_status.mode = reply["mode"]; + connection_status.pairwise_cipher = reply["pairwise_cipher"]; + connection_status.group_cipher = reply["group_cipher"]; + connection_status.key_mgmt = reply["key_mgmt"]; + connection_status.wpa_state = reply["wpa_state"]; + connection_status.address = reply["address"]; + connection_status.uuid = reply["uuid"]; + + std::string reply_str; + for (const auto &entry : reply) { + if (!reply_str.empty()) { + reply_str += "\n"; + } + reply_str += entry.first + "=" + entry.second; + } + LOG(TRACE) << "STATUS reply= \n" << reply_str; + + LOG(DEBUG) << "active network " << m_active_network_id; + + return true; +} + +void sta_wlan_hal_nl80211::update_status(const ConnectionStatus &connection_status) +{ + m_active_network_id = connection_status.id; + m_active_bssid = connection_status.bssid; + m_active_channel = son::wireless_utils::freq_to_channel(connection_status.freq); + m_active_ssid = connection_status.ssid; + + LOG(DEBUG) << "active_network_id= " << m_active_network_id + << ", active_bssid= " << m_active_bssid << ", active_channel= " << m_active_channel + << ", active_ssid= " << m_active_ssid; +} } // namespace nl80211 diff --git a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h index edffd40cff..013cc2bea0 100644 --- a/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h +++ b/common/beerocks/bwl/nl80211/sta_wlan_hal_nl80211.h @@ -73,6 +73,165 @@ class sta_wlan_hal_nl80211 : public base_wlan_hal_nl80211, public sta_wlan_hal { } private: + /** + * @brief Connection status information. + * + * Current WPA/EAPOL/EAP status information obtained with the STATUS wpa_supplicant command. + */ + struct ConnectionStatus { + /** + * Basic Service Set Identifier. + */ + std::string bssid; + + /** + * Channel frequency in MHz for IBSS. + */ + int freq; + + /** + * Service Set Identifier (network name). + */ + std::string ssid; + + /** + * Network ID + */ + int id; + + /** + * IEEE 802.11 operation mode + */ + std::string mode; + + /** + * Allowed pairwise ciphers (WPA_CIPHER_*) + */ + std::string pairwise_cipher; + + /** + * Allowed group ciphers (WPA_CIPHER_*) + */ + std::string group_cipher; + + /** + * Allowed key management protocols (WPA_KEY_MGMT_*) + */ + std::string key_mgmt; + + /** + * Current wpa_supplicant state + */ + std::string wpa_state; + + /** + * MAC address of the network interface + */ + std::string address; + + /** + * Universally Unique Identifier of the device + */ + std::string uuid; + }; + + /** + * @brief Adds a new network. + * + * Executes wpa_supplicant command ADD_NETWORK to create new network with empty configuration. + * The new network is disabled and once it has been configured it can be enabled with + * ENABLE_NETWORK command. + * + * @return Network ID of the new network or -1 on failure. + */ + int add_network(); + + /** + * @brief Sets a network variable. + * + * Executes wpa_supplicant command SET_NETWORK to set a network variable value. + * + * This command uses the same variables and data formats as the wpa_supplicant configuration + * file. Examples: + * - ssid (network name, SSID) + * - psk (WPA passphrase or pre-shared key) + * - key_mgmt (key management protocol) + * - identity (EAP identity) + * - password (EAP password) + * - ... + * + * @param network_id Network ID of the network whose variable to set. + * @param param Name of the variable. + * @param value Value to set. + * @return True on success and false otherwise. + */ + bool set_network(int network_id, const std::string ¶m, const std::string &value); + + /** + * @brief Configures a network. + * + * Configures a newly added network before it can be enabled. + * + * @param network_id Network ID of the network to be configured. + * @param ssid Service Set Identifier (network name). + * @param bssid Basic Service Set Identifier. + * @param sec WLAN Security Type (converted to a key management protocol). + * @param mem_only_psk Keep PSK/passphrase only in memory. + * @param pass WPA ASCII passphrase. If this is set, PSK will be generated using the SSID and + * passphrase configured for the network. ASCII passphrase must be between 8 and 63 characters + * (inclusive). + * @param hidden_ssid Scan this SSID with Probe Requests (scan_ssid can be used to scan for + * APs using hidden SSIDs). + * @param freq Frequency in MHz to allow for selecting the BSS. If 0, all frequencies are + * considered when selecting a BSS. + * @return True on success and false otherwise. + */ + bool set_network_params(int network_id, const std::string &ssid, const std::string &bssid, + WiFiSec sec, bool mem_only_psk, const std::string &pass, + bool hidden_ssid, int freq = 0); + + /** + * @brief Reads connection status information. + * + * Executes wpa_supplicant command STATUS to read current WPA/EAPOL/EAP status information and + * fills in given structure. + * + * @param[in,out] connection_status Connection status structure to fill in. + * @return True on success and false otherwise. + */ + bool read_status(ConnectionStatus &connection_status); + + /** + * @brief Updates connection status information. + * + * Sets class members containing active connection information with given connection status + * information (i.e.: network ID, BSSID, channel and SSID). + * + * @param connection_status Connection status information. + */ + void update_status(const ConnectionStatus &connection_status); + + /** + * @brief Enables a network. + * + * Executes wpa_supplicant command ENABLE_NETWORK to enable a network. + * + * @param network_id Network ID of the network to be enabled. + * @return True on success and false otherwise. + */ + bool enable_network(int network_id); + + /** + * @brief Checks if all authentication completed. + * + * Checks if wpa_supplicant has completed its processing for the association phase and that + * data connection is fully configured. + * + * @param wpa_state wpa_supplicant state (obtained with STATUS wpa_supplicant command). + * @return True if given wpa_supplicant state is "COMPLETED" and false otherwise. + */ + bool is_connected(const std::string &wpa_state); + // Active network parameters std::string m_active_ssid; std::string m_active_bssid; From 5cbb8c5ca3c49b32f628cc9a787f2639b873c6db Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Fri, 24 Jul 2020 14:21:13 +0200 Subject: [PATCH 340/453] bwl: dwpal: fix sta_wlan_hal_dwpal::add_network return code Return code of method sta_wlan_hal_dwpal::add_network() must be -1 on error. Signed-off-by: Mario Maz --- common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp | 7 +++---- common/beerocks/bwl/include/bwl/sta_wlan_hal_types.h | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp index 22fa6b9a12..60b6ac2902 100644 --- a/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/sta_wlan_hal_dwpal.cpp @@ -219,9 +219,8 @@ bool sta_wlan_hal_dwpal::connect(const std::string &ssid, const std::string &pas // Add a new network auto network_id = add_network(); - if (network_id < 0) { - LOG(ERROR) << "Failed (" << network_id - << ") adding new network to interface: " << get_iface_name(); + if (invalid_network_id == network_id) { + LOG(ERROR) << "Failed adding new network to interface: " << get_iface_name(); return false; } @@ -558,7 +557,7 @@ int sta_wlan_hal_dwpal::add_network() // Send command if (!dwpal_send_cmd(cmd, &reply)) { LOG(ERROR) << "ADD_NETWORK failed!"; - return false; + return invalid_network_id; } // Return the newly added network ID diff --git a/common/beerocks/bwl/include/bwl/sta_wlan_hal_types.h b/common/beerocks/bwl/include/bwl/sta_wlan_hal_types.h index 337829c4ec..a8d5c2765c 100644 --- a/common/beerocks/bwl/include/bwl/sta_wlan_hal_types.h +++ b/common/beerocks/bwl/include/bwl/sta_wlan_hal_types.h @@ -24,6 +24,8 @@ struct SScanResult { int8_t rssi; }; +constexpr int invalid_network_id = -1; + } // namespace bwl #endif // _BWL_STA_WLAN_HAL_TYPES_H_ From 0aa9eda4b4735551202809716db9563e04cc01f4 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 16 Jul 2020 15:48:18 +0300 Subject: [PATCH 341/453] controller: son_master: Remove case for VS message Need to renmove case for ACTION_CONTROL_AGENT_PING_REQUEST message from handler. https://jira.prplfoundation.org/browse/PPM-286 Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/master/son_master_thread.cpp | 37 ------------------- 1 file changed, 37 deletions(-) diff --git a/controller/src/beerocks/master/son_master_thread.cpp b/controller/src/beerocks/master/son_master_thread.cpp index e9851f0197..a71f5fb9ab 100644 --- a/controller/src/beerocks/master/son_master_thread.cpp +++ b/controller/src/beerocks/master/son_master_thread.cpp @@ -2964,43 +2964,6 @@ bool master_thread::handle_cmdu_control_message(const std::string &src_mac, } break; } - case beerocks_message::ACTION_CONTROL_AGENT_PING_REQUEST: { - if (hostap_mac.empty()) { - LOG(WARNING) << "PING_MSG_REQUEST unknown peer mac!"; - } else if (!database.update_node_last_seen(hostap_mac)) { - LOG(DEBUG) << "PING_MSG_REQUEST received from ire " << hostap_mac - << " , can't update last seen time for "; - } - - auto request = - beerocks_header->addClass(); - if (request == nullptr) { - LOG(ERROR) << "addClass cACTION_CONTROL_AGENT_PING_REQUEST failed"; - return false; - } - - auto response = - message_com::create_vs_message( - cmdu_tx); - if (request == nullptr) { - LOG(ERROR) << "Failed building message!"; - return false; - } - response->total() = request->total(); - response->seq() = request->seq(); - response->size() = request->size(); - - if (response->size()) { - if (!request->alloc_data(response->size())) { - LOG(ERROR) << "Failed buffer allocation to size=" << int(response->size()); - break; - } - memset(request->data(), 0, request->data_length()); - } - - son_actions::send_cmdu_to_agent(src_mac, cmdu_tx, database, hostap_mac); - break; - } case beerocks_message::ACTION_CONTROL_CONTROLLER_PING_RESPONSE: { if (hostap_mac.empty()) { LOG(ERROR) << "PING_MSG_RESPONSE unknown peer mac!"; From ab28d8ad4fe171e053b5594e72db92e5db8c8818 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 16 Jul 2020 15:40:14 +0300 Subject: [PATCH 342/453] agent: son_slave: Remove case from VS message handler Need to remove case for handling ACTION_CONTROL_AGENT_PING_RESPONSE message. https://jira.prplfoundation.org/browse/PPM-286 Signed-off-by: Vladyslav Tupikin --- agent/src/beerocks/slave/son_slave_thread.cpp | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 5992607499..7e0741d99a 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -708,36 +708,6 @@ bool slave_thread::handle_cmdu_control_message(Socket *sd, send_cmdu_to_controller(cmdu_tx); break; } - case beerocks_message::ACTION_CONTROL_AGENT_PING_RESPONSE: { - LOG(DEBUG) << "received ACTION_CONTROL_AGENT_PING_RESPONSE"; - auto response = - beerocks_header->addClass(); - if (response == nullptr) { - LOG(ERROR) << "addClass cACTION_CONTROL_AGENT_PING_RESPONSE failed"; - return false; - } - if (response->seq() < (response->total() - 1)) { //send next ping request - auto request = message_com::create_vs_message< - beerocks_message::cACTION_CONTROL_AGENT_PING_REQUEST>(cmdu_tx); - if (request == nullptr) { - LOG(ERROR) << "Failed building message!"; - return false; - } - - request->total() = response->total(); - request->seq() = response->seq() + 1; - request->size() = response->size(); - if (request->size()) { - if (!request->alloc_data(request->size())) { - LOG(ERROR) << "Failed buffer allocation to size=" << int(request->size()); - break; - } - memset(request->data(), 0, request->data_length()); - } - send_cmdu_to_controller(cmdu_tx); - } - break; - } case beerocks_message::ACTION_CONTROL_CHANGE_MODULE_LOGGING_LEVEL: { auto request_in = beerocks_header From 4f64d30fd37758c8cbb3ecbef2cc5e164e779d2e Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 16 Jul 2020 15:38:23 +0300 Subject: [PATCH 343/453] agent: son_slave: Remove process_keep_alive method Remove process_keep_alive method and all related variables. https://jira.prplfoundation.org/browse/PPM-286 Signed-off-by: Vladyslav Tupikin --- agent/src/beerocks/slave/son_slave_thread.cpp | 48 ------------------- agent/src/beerocks/slave/son_slave_thread.h | 1 - .../bcl/include/bcl/beerocks_defines.h | 1 - 3 files changed, 50 deletions(-) diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 7e0741d99a..c694a23491 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -266,53 +266,6 @@ bool slave_thread::work() return true; } -void slave_thread::process_keep_alive() -{ - if (!config.enable_keep_alive || !son_config.slave_keep_alive_retries || - !backhaul_params.is_prplmesh_controller) { - return; - } - - if (master_socket == nullptr) { - LOG(ERROR) << "process_keep_alive(): master_socket is nullptr!"; - return; - } - - auto now = std::chrono::steady_clock::now(); - int keep_alive_time_elapsed_ms = - std::chrono::duration_cast(now - master_last_seen).count(); - if (keep_alive_time_elapsed_ms >= beerocks::KEEP_ALIVE_INTERVAL_MSC) { - if (keep_alive_retries >= son_config.slave_keep_alive_retries) { - LOG(DEBUG) << "exceeded keep_alive_retries " << keep_alive_retries - << " - slave_reset()"; - - platform_notify_error(bpl::eErrorCode::SLAVE_MASTER_KEEP_ALIVE_TIMEOUT, - "Reached master keep-alive retries limit: " + - std::to_string(keep_alive_retries)); - - stop_on_failure_attempts--; - slave_reset(); - } else { - LOG(DEBUG) << "time elapsed since last master message: " << keep_alive_time_elapsed_ms - << "ms, sending PING_MSG_REQUEST, tries=" << keep_alive_retries; - auto request = message_com::create_vs_message< - beerocks_message::cACTION_CONTROL_AGENT_PING_REQUEST>(cmdu_tx); - if (request == nullptr) { - LOG(ERROR) << "Failed building message!"; - return; - } - - request->total() = 1; - request->seq() = 0; - request->size() = 0; - - send_cmdu_to_controller(cmdu_tx); - keep_alive_retries++; - master_last_seen = now; - } - } -} - bool slave_thread::handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_rx) { if (cmdu_rx.getMessageType() == ieee1905_1::eMessageType::VENDOR_SPECIFIC_MESSAGE) { @@ -3634,7 +3587,6 @@ bool slave_thread::slave_fsm(bool &call_slave_select) } case STATE_OPERATIONAL: { stop_on_failure_attempts = configuration_stop_on_failure_attempts; - process_keep_alive(); break; } case STATE_ONBOARDING: { diff --git a/agent/src/beerocks/slave/son_slave_thread.h b/agent/src/beerocks/slave/son_slave_thread.h index b9ae31a888..351621e356 100644 --- a/agent/src/beerocks/slave/son_slave_thread.h +++ b/agent/src/beerocks/slave/son_slave_thread.h @@ -125,7 +125,6 @@ class slave_thread : public beerocks::socket_thread { std::shared_ptr beerocks_header); bool handle_cmdu_control_ieee1905_1_message(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_rx); bool handle_cmdu_monitor_ieee1905_1_message(Socket &sd, ieee1905_1::CmduMessageRx &cmdu_rx); - void process_keep_alive(); bool slave_fsm(bool &call_slave_select); void slave_reset(); diff --git a/common/beerocks/bcl/include/bcl/beerocks_defines.h b/common/beerocks/bcl/include/bcl/beerocks_defines.h index ff453597a3..9151dba6b9 100644 --- a/common/beerocks/bcl/include/bcl/beerocks_defines.h +++ b/common/beerocks/bcl/include/bcl/beerocks_defines.h @@ -83,7 +83,6 @@ enum eMessageConsts { enum eGlobals { HIERARCHY_MAX = 14, IRE_MAX_SLAVES = 3, - KEEP_ALIVE_INTERVAL_MSC = 20000, RSSI_MAX = 20, RSSI_MIN = -100, RSSI_INVALID = -127, From 6acb909df75f9a65065e3804f9c6e95def1c8e19 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 16 Jul 2020 15:34:14 +0300 Subject: [PATCH 344/453] common: bcl: Remove deprecated error code Removed deprecated error code, fixed numeration for the rest of error codes. https://jira.prplfoundation.org/browse/PPM-286 Signed-off-by: Vladyslav Tupikin --- framework/platform/bpl/include/bpl/bpl_err.h | 51 ++++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/framework/platform/bpl/include/bpl/bpl_err.h b/framework/platform/bpl/include/bpl/bpl_err.h index d6842dfd93..d34d319bf7 100644 --- a/framework/platform/bpl/include/bpl/bpl_err.h +++ b/framework/platform/bpl/include/bpl/bpl_err.h @@ -45,32 +45,31 @@ namespace bpl { /* 14 */ ERROR_CODE(BH_SLAVE_SOCKET_DISCONNECTED) \ /* 15 */ ERROR_CODE(BH_STOPPED) \ /* 16 */ ERROR_CODE(SLAVE_CONNECTING_TO_BACKHAUL_MANAGER) \ -/* 17 */ ERROR_CODE(SLAVE_MASTER_KEEP_ALIVE_TIMEOUT) \ -/* 18 */ ERROR_CODE(SLAVE_INVALID_MASTER_SOCKET) \ -/* 19 */ ERROR_CODE(SLAVE_FAILED_CONNECT_TO_PLATFORM_MANAGER) \ -/* 20 */ ERROR_CODE(SLAVE_PLATFORM_MANAGER_REGISTER_TIMEOUT) \ -/* 21 */ ERROR_CODE(SLAVE_SLAVE_BACKHAUL_MANAGER_DISCONNECTED) \ -/* 22 */ ERROR_CODE(SLAVE_STOPPED) \ -/* 23 */ ERROR_CODE(AP_MANAGER_START) \ -/* 24 */ ERROR_CODE(AP_MANAGER_DISCONNECTED) \ -/* 25 */ ERROR_CODE(AP_MANAGER_HOSTAP_DISABLED) \ -/* 26 */ ERROR_CODE(AP_MANAGER_ATTACH_FAIL) \ -/* 27 */ ERROR_CODE(AP_MANAGER_SUDDEN_DETACH) \ -/* 28 */ ERROR_CODE(AP_MANAGER_HAL_DISCONNECTED) \ -/* 29 */ ERROR_CODE(AP_MANAGER_CAC_TIMEOUT) \ -/* 30 */ ERROR_CODE(MONITOR_DISCONNECTED) \ -/* 31 */ ERROR_CODE(MONITOR_HOSTAP_DISABLED) \ -/* 32 */ ERROR_CODE(MONITOR_ATTACH_FAIL) \ -/* 33 */ ERROR_CODE(MONITOR_SUDDEN_DETACH) \ -/* 34 */ ERROR_CODE(MONITOR_HAL_DISCONNECTED) \ -/* 35 */ ERROR_CODE(MONITOR_REPORT_PROCESS_FAIL) \ -/* 36 */ ERROR_CODE(CONFIG_PLATFORM_REPORTED_INVALID_CONFIGURATION) \ -/* 37 */ ERROR_CODE(CONFIG_BACKHAUL_WIRED_INTERFACE_IS_UNSUPPORTED) \ -/* 38 */ ERROR_CODE(CONFIG_BACKHAUL_WIRELESS_INTERFACE_IS_UNSUPPORTED) \ -/* 39 */ ERROR_CODE(CONFIG_NO_VALID_BACKHAUL_INTERFACE) \ -/* 40 */ ERROR_CODE(WATCHDOG_PROCESS_STUCK) \ -/* 41 */ ERROR_CODE(WATCHDOG_PROCESS_ZOMBIE) \ -/* 42 */ ERROR_CODE(LAST) +/* 17 */ ERROR_CODE(SLAVE_INVALID_MASTER_SOCKET) \ +/* 18 */ ERROR_CODE(SLAVE_FAILED_CONNECT_TO_PLATFORM_MANAGER) \ +/* 19 */ ERROR_CODE(SLAVE_PLATFORM_MANAGER_REGISTER_TIMEOUT) \ +/* 20 */ ERROR_CODE(SLAVE_SLAVE_BACKHAUL_MANAGER_DISCONNECTED) \ +/* 21 */ ERROR_CODE(SLAVE_STOPPED) \ +/* 22 */ ERROR_CODE(AP_MANAGER_START) \ +/* 23 */ ERROR_CODE(AP_MANAGER_DISCONNECTED) \ +/* 24 */ ERROR_CODE(AP_MANAGER_HOSTAP_DISABLED) \ +/* 25 */ ERROR_CODE(AP_MANAGER_ATTACH_FAIL) \ +/* 26 */ ERROR_CODE(AP_MANAGER_SUDDEN_DETACH) \ +/* 27 */ ERROR_CODE(AP_MANAGER_HAL_DISCONNECTED) \ +/* 28 */ ERROR_CODE(AP_MANAGER_CAC_TIMEOUT) \ +/* 29 */ ERROR_CODE(MONITOR_DISCONNECTED) \ +/* 30 */ ERROR_CODE(MONITOR_HOSTAP_DISABLED) \ +/* 31 */ ERROR_CODE(MONITOR_ATTACH_FAIL) \ +/* 32 */ ERROR_CODE(MONITOR_SUDDEN_DETACH) \ +/* 33 */ ERROR_CODE(MONITOR_HAL_DISCONNECTED) \ +/* 34 */ ERROR_CODE(MONITOR_REPORT_PROCESS_FAIL) \ +/* 35 */ ERROR_CODE(CONFIG_PLATFORM_REPORTED_INVALID_CONFIGURATION) \ +/* 36 */ ERROR_CODE(CONFIG_BACKHAUL_WIRED_INTERFACE_IS_UNSUPPORTED) \ +/* 37 */ ERROR_CODE(CONFIG_BACKHAUL_WIRELESS_INTERFACE_IS_UNSUPPORTED) \ +/* 38 */ ERROR_CODE(CONFIG_NO_VALID_BACKHAUL_INTERFACE) \ +/* 39 */ ERROR_CODE(WATCHDOG_PROCESS_STUCK) \ +/* 40 */ ERROR_CODE(WATCHDOG_PROCESS_ZOMBIE) \ +/* 41 */ ERROR_CODE(LAST) // clang-format on From 9d06d4bae6fe2fd3af3b7b6a5acc6e12bef19569 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 15 Jul 2020 18:59:30 +0300 Subject: [PATCH 345/453] common: tlvf: Remove AGENT_PING_ message Need to remove next messages and all related code because those vendor-specific message no needed anymore. ACTION_CONTROL_AGENT_PING_REQUEST ACTION_CONTROL_AGENT_PING_RESPONSE Also remove all deprecated code from autogenerated files. https://jira.prplfoundation.org/browse/PPM-286 Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 2 - .../beerocks/tlvf/beerocks_message_control.h | 64 ----- .../tlvf/beerocks_message_control.cpp | 270 ------------------ .../tlvf/beerocks_message_action.yaml | 2 - .../tlvf/beerocks_message_control.yaml | 18 -- 5 files changed, 356 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index 228c5512fa..34ffefe0df 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -45,8 +45,6 @@ enum eActionOp_CONTROL: uint8_t { ACTION_CONTROL_SON_CONFIG_UPDATE = 0x5, ACTION_CONTROL_CONTROLLER_PING_REQUEST = 0x6, ACTION_CONTROL_CONTROLLER_PING_RESPONSE = 0x7, - ACTION_CONTROL_AGENT_PING_REQUEST = 0x8, - ACTION_CONTROL_AGENT_PING_RESPONSE = 0x9, ACTION_CONTROL_CHANGE_MODULE_LOGGING_LEVEL = 0xb, ACTION_CONTROL_ARP_QUERY_REQUEST = 0xc, ACTION_CONTROL_ARP_QUERY_RESPONSE = 0xd, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h index 61905a1604..10d3a4bc99 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h @@ -223,70 +223,6 @@ class cACTION_CONTROL_CONTROLLER_PING_RESPONSE : public BaseClass int m_lock_order_counter__ = 0; }; -class cACTION_CONTROL_AGENT_PING_REQUEST : public BaseClass -{ - public: - cACTION_CONTROL_AGENT_PING_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CONTROL_AGENT_PING_REQUEST(std::shared_ptr base, bool parse = false); - ~cACTION_CONTROL_AGENT_PING_REQUEST(); - - static eActionOp_CONTROL get_action_op(){ - return (eActionOp_CONTROL)(ACTION_CONTROL_AGENT_PING_REQUEST); - } - uint16_t& total(); - uint16_t& seq(); - uint16_t& size(); - size_t data_length() { return m_data_idx__ * sizeof(uint8_t); } - uint8_t* data(size_t idx = 0); - bool set_data(const void* buffer, size_t size); - bool alloc_data(size_t count = 1); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CONTROL* m_action_op = nullptr; - uint16_t* m_total = nullptr; - uint16_t* m_seq = nullptr; - uint16_t* m_size = nullptr; - uint8_t* m_data = nullptr; - size_t m_data_idx__ = 0; - int m_lock_order_counter__ = 0; -}; - -class cACTION_CONTROL_AGENT_PING_RESPONSE : public BaseClass -{ - public: - cACTION_CONTROL_AGENT_PING_RESPONSE(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CONTROL_AGENT_PING_RESPONSE(std::shared_ptr base, bool parse = false); - ~cACTION_CONTROL_AGENT_PING_RESPONSE(); - - static eActionOp_CONTROL get_action_op(){ - return (eActionOp_CONTROL)(ACTION_CONTROL_AGENT_PING_RESPONSE); - } - uint16_t& total(); - uint16_t& seq(); - uint16_t& size(); - size_t data_length() { return m_data_idx__ * sizeof(uint8_t); } - uint8_t* data(size_t idx = 0); - bool set_data(const void* buffer, size_t size); - bool alloc_data(size_t count = 1); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CONTROL* m_action_op = nullptr; - uint16_t* m_total = nullptr; - uint16_t* m_seq = nullptr; - uint16_t* m_size = nullptr; - uint8_t* m_data = nullptr; - size_t m_data_idx__ = 0; - int m_lock_order_counter__ = 0; -}; - class cACTION_CONTROL_ARP_QUERY_REQUEST : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp index bdc1df9b65..b0621d267d 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp @@ -779,276 +779,6 @@ bool cACTION_CONTROL_CONTROLLER_PING_RESPONSE::init() return true; } -cACTION_CONTROL_AGENT_PING_REQUEST::cACTION_CONTROL_AGENT_PING_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CONTROL_AGENT_PING_REQUEST::cACTION_CONTROL_AGENT_PING_REQUEST(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CONTROL_AGENT_PING_REQUEST::~cACTION_CONTROL_AGENT_PING_REQUEST() { -} -uint16_t& cACTION_CONTROL_AGENT_PING_REQUEST::total() { - return (uint16_t&)(*m_total); -} - -uint16_t& cACTION_CONTROL_AGENT_PING_REQUEST::seq() { - return (uint16_t&)(*m_seq); -} - -uint16_t& cACTION_CONTROL_AGENT_PING_REQUEST::size() { - return (uint16_t&)(*m_size); -} - -uint8_t* cACTION_CONTROL_AGENT_PING_REQUEST::data(size_t idx) { - if ( (m_data_idx__ == 0) || (m_data_idx__ <= idx) ) { - TLVF_LOG(ERROR) << "Requested index is greater than the number of available entries"; - return nullptr; - } - return &(m_data[idx]); -} - -bool cACTION_CONTROL_AGENT_PING_REQUEST::set_data(const void* buffer, size_t size) { - if (buffer == nullptr) { - TLVF_LOG(WARNING) << "set_data received a null pointer."; - return false; - } - if (!alloc_data(size)) { return false; } - std::copy_n(reinterpret_cast(buffer), size, m_data); - return true; -} -bool cACTION_CONTROL_AGENT_PING_REQUEST::alloc_data(size_t count) { - if (m_lock_order_counter__ > 0) {; - TLVF_LOG(ERROR) << "Out of order allocation for variable length list data, abort!"; - return false; - } - size_t len = sizeof(uint8_t) * count; - if(getBuffRemainingBytes() < len ) { - TLVF_LOG(ERROR) << "Not enough available space on buffer - can't allocate"; - return false; - } - m_lock_order_counter__ = 0; - uint8_t *src = (uint8_t *)m_data; - uint8_t *dst = src + len; - if (!m_parse__) { - size_t move_length = getBuffRemainingBytes(src) - len; - std::copy_n(src, move_length, dst); - } - m_data_idx__ += count; - if (!buffPtrIncrementSafe(len)) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << len << ") Failed!"; - return false; - } - return true; -} - -void cACTION_CONTROL_AGENT_PING_REQUEST::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CONTROL), reinterpret_cast(m_action_op)); - tlvf_swap(16, reinterpret_cast(m_total)); - tlvf_swap(16, reinterpret_cast(m_seq)); - tlvf_swap(16, reinterpret_cast(m_size)); -} - -bool cACTION_CONTROL_AGENT_PING_REQUEST::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CONTROL_AGENT_PING_REQUEST::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(uint16_t); // total - class_size += sizeof(uint16_t); // seq - class_size += sizeof(uint16_t); // size - return class_size; -} - -bool cACTION_CONTROL_AGENT_PING_REQUEST::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_total = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_seq = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_size = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_data = (uint8_t*)m_buff_ptr__; - m_data_idx__ = getBuffRemainingBytes(); - if (m_parse__) { class_swap(); } - return true; -} - -cACTION_CONTROL_AGENT_PING_RESPONSE::cACTION_CONTROL_AGENT_PING_RESPONSE(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CONTROL_AGENT_PING_RESPONSE::cACTION_CONTROL_AGENT_PING_RESPONSE(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CONTROL_AGENT_PING_RESPONSE::~cACTION_CONTROL_AGENT_PING_RESPONSE() { -} -uint16_t& cACTION_CONTROL_AGENT_PING_RESPONSE::total() { - return (uint16_t&)(*m_total); -} - -uint16_t& cACTION_CONTROL_AGENT_PING_RESPONSE::seq() { - return (uint16_t&)(*m_seq); -} - -uint16_t& cACTION_CONTROL_AGENT_PING_RESPONSE::size() { - return (uint16_t&)(*m_size); -} - -uint8_t* cACTION_CONTROL_AGENT_PING_RESPONSE::data(size_t idx) { - if ( (m_data_idx__ == 0) || (m_data_idx__ <= idx) ) { - TLVF_LOG(ERROR) << "Requested index is greater than the number of available entries"; - return nullptr; - } - return &(m_data[idx]); -} - -bool cACTION_CONTROL_AGENT_PING_RESPONSE::set_data(const void* buffer, size_t size) { - if (buffer == nullptr) { - TLVF_LOG(WARNING) << "set_data received a null pointer."; - return false; - } - if (!alloc_data(size)) { return false; } - std::copy_n(reinterpret_cast(buffer), size, m_data); - return true; -} -bool cACTION_CONTROL_AGENT_PING_RESPONSE::alloc_data(size_t count) { - if (m_lock_order_counter__ > 0) {; - TLVF_LOG(ERROR) << "Out of order allocation for variable length list data, abort!"; - return false; - } - size_t len = sizeof(uint8_t) * count; - if(getBuffRemainingBytes() < len ) { - TLVF_LOG(ERROR) << "Not enough available space on buffer - can't allocate"; - return false; - } - m_lock_order_counter__ = 0; - uint8_t *src = (uint8_t *)m_data; - uint8_t *dst = src + len; - if (!m_parse__) { - size_t move_length = getBuffRemainingBytes(src) - len; - std::copy_n(src, move_length, dst); - } - m_data_idx__ += count; - if (!buffPtrIncrementSafe(len)) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << len << ") Failed!"; - return false; - } - return true; -} - -void cACTION_CONTROL_AGENT_PING_RESPONSE::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CONTROL), reinterpret_cast(m_action_op)); - tlvf_swap(16, reinterpret_cast(m_total)); - tlvf_swap(16, reinterpret_cast(m_seq)); - tlvf_swap(16, reinterpret_cast(m_size)); -} - -bool cACTION_CONTROL_AGENT_PING_RESPONSE::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CONTROL_AGENT_PING_RESPONSE::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(uint16_t); // total - class_size += sizeof(uint16_t); // seq - class_size += sizeof(uint16_t); // size - return class_size; -} - -bool cACTION_CONTROL_AGENT_PING_RESPONSE::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_total = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_seq = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_size = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_data = (uint8_t*)m_buff_ptr__; - m_data_idx__ = getBuffRemainingBytes(); - if (m_parse__) { class_swap(); } - return true; -} - cACTION_CONTROL_ARP_QUERY_REQUEST::cACTION_CONTROL_ARP_QUERY_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index d0e5882bba..6bdf260c79 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -37,8 +37,6 @@ eActionOp_CONTROL: ACTION_CONTROL_SON_CONFIG_UPDATE: 5 ACTION_CONTROL_CONTROLLER_PING_REQUEST: 6 ACTION_CONTROL_CONTROLLER_PING_RESPONSE: 7 - ACTION_CONTROL_AGENT_PING_REQUEST: 8 - ACTION_CONTROL_AGENT_PING_RESPONSE: 9 ACTION_CONTROL_CHANGE_MODULE_LOGGING_LEVEL: 11 ACTION_CONTROL_ARP_QUERY_REQUEST: 12 ACTION_CONTROL_ARP_QUERY_RESPONSE: 13 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml index 7e20d7ca59..027718a212 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml @@ -67,24 +67,6 @@ cACTION_CONTROL_CONTROLLER_PING_RESPONSE: _type: uint8_t _length: [] -cACTION_CONTROL_AGENT_PING_REQUEST: - _type: class - total: uint16_t - seq: uint16_t - size: uint16_t - data: - _type: uint8_t - _length: [] - -cACTION_CONTROL_AGENT_PING_RESPONSE: - _type: class - total: uint16_t - seq: uint16_t - size: uint16_t - data: - _type: uint8_t - _length: [] - cACTION_CONTROL_ARP_QUERY_REQUEST: _type: class params: sArpQuery From b58a27b66e5ea18c39309100bacd5521f6ce4e0f Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 00:20:03 +0300 Subject: [PATCH 346/453] agent: son_slave: Remove deprecated variable Need to remove usage of deprecated variable slave_keep_alive_retries. Also remove the corresponding variables from bcl and controller. https://jira.prplfoundation.org/browse/PPM-286 Signed-off-by: Vladyslav Tupikin --- agent/src/beerocks/slave/son_slave_thread.cpp | 3 +-- common/beerocks/bcl/include/bcl/beerocks_config_file.h | 1 - common/beerocks/bcl/source/beerocks_config_file.cpp | 1 - controller/config/beerocks_controller.conf.in | 1 - controller/src/beerocks/master/beerocks_master_main.cpp | 3 --- controller/src/beerocks/master/son_master_thread.cpp | 1 - 6 files changed, 1 insertion(+), 9 deletions(-) diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index c694a23491..adfec65639 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -3704,8 +3704,7 @@ void slave_thread::log_son_config() << "monitor_ap_idle_stable_time_sec=" << int(son_config.monitor_ap_idle_stable_time_sec) << std::endl << "monitor_disable_initiative_arp=" - << int(son_config.monitor_disable_initiative_arp) << std::endl - << "slave_keep_alive_retries=" << int(son_config.slave_keep_alive_retries); + << int(son_config.monitor_disable_initiative_arp) << std::endl; } bool slave_thread::monitor_heartbeat_check() diff --git a/common/beerocks/bcl/include/bcl/beerocks_config_file.h b/common/beerocks/bcl/include/bcl/beerocks_config_file.h index 0a008900fe..2e3edd604f 100644 --- a/common/beerocks/bcl/include/bcl/beerocks_config_file.h +++ b/common/beerocks/bcl/include/bcl/beerocks_config_file.h @@ -74,7 +74,6 @@ class config_file { std::string monitor_ap_active_threshold_B; std::string monitor_ap_idle_stable_time_sec; std::string monitor_disable_initiative_arp; - std::string slave_keep_alive_retries; std::string channel_selection_random_delay; std::string fail_safe_5G_frequency; std::string fail_safe_5G_bw; diff --git a/common/beerocks/bcl/source/beerocks_config_file.cpp b/common/beerocks/bcl/source/beerocks_config_file.cpp index 8b43757f11..50ad56e156 100644 --- a/common/beerocks/bcl/source/beerocks_config_file.cpp +++ b/common/beerocks/bcl/source/beerocks_config_file.cpp @@ -117,7 +117,6 @@ bool config_file::read_master_config_file(const std::string &config_file_path, s std::make_tuple("monitor_rx_rssi_notification_delta_db=", &conf.monitor_rx_rssi_notification_delta_db, mandatory_master), std::make_tuple("monitor_disable_initiative_arp=", &conf.monitor_disable_initiative_arp, 0), - std::make_tuple("slave_keep_alive_retries=", &conf.slave_keep_alive_retries, 0), std::make_tuple("channel_selection_random_delay=", &conf.channel_selection_random_delay, mandatory_master), std::make_tuple("fail_safe_5G_frequency=", &conf.fail_safe_5G_frequency, mandatory_master), diff --git a/controller/config/beerocks_controller.conf.in b/controller/config/beerocks_controller.conf.in index bb95a441f6..0b40308ddd 100644 --- a/controller/config/beerocks_controller.conf.in +++ b/controller/config/beerocks_controller.conf.in @@ -68,7 +68,6 @@ monitor_ap_idle_threshold_B=10000 monitor_ap_active_threshold_B=20000 monitor_ap_idle_stable_time_sec=70 monitor_disable_initiative_arp=0 -slave_keep_alive_retries=10 channel_selection_random_delay=30000 channel_selection_long_delay=43200000 credentials_change_timeout_sec=300 diff --git a/controller/src/beerocks/master/beerocks_master_main.cpp b/controller/src/beerocks/master/beerocks_master_main.cpp index 7466130c5b..83034c718d 100644 --- a/controller/src/beerocks/master/beerocks_master_main.cpp +++ b/controller/src/beerocks/master/beerocks_master_main.cpp @@ -179,8 +179,6 @@ static void fill_master_config(son::db::sDbMasterConfig &master_conf, beerocks::string_utils::stoi(main_master_conf.monitor_rx_rssi_notification_delta_db); master_conf.monitor_disable_initiative_arp = beerocks::string_utils::stoi(main_master_conf.monitor_disable_initiative_arp); - master_conf.slave_keep_alive_retries = - beerocks::string_utils::stoi(main_master_conf.slave_keep_alive_retries); master_conf.channel_selection_random_delay = beerocks::string_utils::stoi(main_master_conf.channel_selection_random_delay); master_conf.fail_safe_5G_frequency = @@ -342,7 +340,6 @@ int main(int argc, char *argv[]) } son::db master_db(master_conf, logger, bridge_info.mac); - LOG(DEBUG) << "slave_keep_alive_retries=" << master_db.config.slave_keep_alive_retries; // diagnostics_thread diagnostics(master_db); son::master_thread son_master(master_uds, master_db); diff --git a/controller/src/beerocks/master/son_master_thread.cpp b/controller/src/beerocks/master/son_master_thread.cpp index a71f5fb9ab..0bfc6a6e94 100644 --- a/controller/src/beerocks/master/son_master_thread.cpp +++ b/controller/src/beerocks/master/son_master_thread.cpp @@ -2247,7 +2247,6 @@ bool master_thread::handle_intel_slave_join( database.config.monitor_ap_idle_stable_time_sec; join_response->config().monitor_disable_initiative_arp = database.config.monitor_disable_initiative_arp; - join_response->config().slave_keep_alive_retries = database.config.slave_keep_alive_retries; join_response->config().ire_rssi_report_rate_sec = database.config.ire_rssi_report_rate_sec; LOG(DEBUG) << "send SLAVE_JOINED_RESPONSE"; From a81b957b9096f476d252c76d3942568f346bc319 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 00:15:41 +0300 Subject: [PATCH 347/453] controller: database: Remove deprecated variable Need to remove deprecated variable from database ehader file slave_keep_alive_retries. https://jira.prplfoundation.org/browse/PPM-286 Signed-off-by: Vladyslav Tupikin --- controller/src/beerocks/master/db/db.h | 1 - 1 file changed, 1 deletion(-) diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index 9166d6dfab..16a35b0733 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -108,7 +108,6 @@ class db { int monitor_ap_active_threshold_B; int monitor_ap_idle_stable_time_sec; int monitor_disable_initiative_arp; - int slave_keep_alive_retries; int idle_steer_activity_check_timeout; int channel_selection_random_delay; From 2d301303b7a1da9d59668e95ad17731184b37556 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 00:14:33 +0300 Subject: [PATCH 348/453] common: tlvf: Remove slave_keep_alive_retries Need to remove depricated variable slave_keep_alive_retries. Also remove deprecated code from autogenerated files. https://jira.prplfoundation.org/browse/PPM-286 Signed-off-by: Vladyslav Tupikin --- .../include/beerocks/tlvf/beerocks_message_common.h | 1 - .../tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h index f5df12a63f..54c6bd07f9 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h @@ -61,7 +61,6 @@ typedef struct sSonConfig { uint32_t monitor_ap_active_threshold_B; uint16_t monitor_ap_idle_stable_time_sec; uint8_t monitor_disable_initiative_arp; - uint8_t slave_keep_alive_retries; uint8_t ire_rssi_report_rate_sec; void struct_swap(){ tlvf_swap(32, reinterpret_cast(&monitor_ap_idle_threshold_B)); diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml index 31435860fe..60a827dd27 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml @@ -46,7 +46,6 @@ sSonConfig: monitor_ap_idle_stable_time_sec: uint16_t monitor_disable_initiative_arp: uint8_t - slave_keep_alive_retries: uint8_t ire_rssi_report_rate_sec: uint8_t sPlatformSettings: From e327b035c402bf322e18c2fff1dafc454dbb0049 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 10:57:13 +0300 Subject: [PATCH 349/453] cpmmon: bcl: Remove unused variable Need to remove deprecated variable enable_keep_alive. Also remove that variable from agent source code. https://jira.prplfoundation.org/browse/PPM-286 Signed-off-by: Vladyslav Tupikin --- agent/config/beerocks_agent.conf.in | 1 - agent/src/beerocks/slave/beerocks_slave_main.cpp | 1 - agent/src/beerocks/slave/son_slave_thread.cpp | 6 ++---- agent/src/beerocks/slave/son_slave_thread.h | 2 -- common/beerocks/bcl/include/bcl/beerocks_config_file.h | 1 - common/beerocks/bcl/source/beerocks_config_file.cpp | 1 - 6 files changed, 2 insertions(+), 10 deletions(-) diff --git a/agent/config/beerocks_agent.conf.in b/agent/config/beerocks_agent.conf.in index ff8689f93d..b08f6e321e 100644 --- a/agent/config/beerocks_agent.conf.in +++ b/agent/config/beerocks_agent.conf.in @@ -13,7 +13,6 @@ vendor=Intel model=prplMesh ucc_listener_port=8002 # 0 - disabled enable_arp_monitor=0 -enable_keep_alive=1 bridge_iface=@BEEROCKS_BRIDGE_IFACE@ enable_system_hang_test=0 # 0 - disabled diff --git a/agent/src/beerocks/slave/beerocks_slave_main.cpp b/agent/src/beerocks/slave/beerocks_slave_main.cpp index 24542409c7..1948cadbd6 100644 --- a/agent/src/beerocks/slave/beerocks_slave_main.cpp +++ b/agent/src/beerocks/slave/beerocks_slave_main.cpp @@ -141,7 +141,6 @@ static void fill_son_slave_config(const beerocks::config_file::sConfigSlave &bee son_slave_conf.model = beerocks_slave_conf.model; son_slave_conf.ucc_listener_port = beerocks::string_utils::stoi(beerocks_slave_conf.ucc_listener_port); - son_slave_conf.enable_keep_alive = beerocks_slave_conf.enable_keep_alive == "1"; son_slave_conf.bridge_iface = beerocks_slave_conf.bridge_iface; son_slave_conf.backhaul_preferred_bssid = beerocks_slave_conf.backhaul_preferred_bssid; son_slave_conf.backhaul_wire_iface = beerocks_slave_conf.backhaul_wire_iface; diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index adfec65639..e82138bea4 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -326,8 +326,7 @@ bool slave_thread::handle_cmdu_control_ieee1905_1_message(Socket *sd, return true; } - master_last_seen = std::chrono::steady_clock::now(); - keep_alive_retries = 0; + master_last_seen = std::chrono::steady_clock::now(); switch (cmdu_message_type) { case ieee1905_1::eMessageType::ACK_MESSAGE: @@ -407,8 +406,7 @@ bool slave_thread::handle_cmdu_control_message(Socket *sd, return true; } - master_last_seen = std::chrono::steady_clock::now(); - keep_alive_retries = 0; + master_last_seen = std::chrono::steady_clock::now(); switch (beerocks_header->action_op()) { case beerocks_message::ACTION_CONTROL_ARP_QUERY_REQUEST: { diff --git a/agent/src/beerocks/slave/son_slave_thread.h b/agent/src/beerocks/slave/son_slave_thread.h index 351621e356..1cff949f1b 100644 --- a/agent/src/beerocks/slave/son_slave_thread.h +++ b/agent/src/beerocks/slave/son_slave_thread.h @@ -40,7 +40,6 @@ class slave_thread : public beerocks::socket_thread { uint16_t ucc_listener_port; std::string bridge_iface; int stop_on_failure_attempts; - bool enable_keep_alive; bool enable_repeater_mode; std::string backhaul_wire_iface; beerocks::eIfaceType backhaul_wire_iface_type; @@ -181,7 +180,6 @@ class slave_thread : public beerocks::socket_thread { //slave FSM // eSlaveState slave_state; std::chrono::steady_clock::time_point slave_state_timer; - int keep_alive_retries = 0; bool hostap_params_available; int slave_resets_counter = 0; diff --git a/common/beerocks/bcl/include/bcl/beerocks_config_file.h b/common/beerocks/bcl/include/bcl/beerocks_config_file.h index 2e3edd604f..9f2c0ce99e 100644 --- a/common/beerocks/bcl/include/bcl/beerocks_config_file.h +++ b/common/beerocks/bcl/include/bcl/beerocks_config_file.h @@ -93,7 +93,6 @@ class config_file { std::string model; std::string ucc_listener_port; std::string enable_arp_monitor; - std::string enable_keep_alive; std::string bridge_iface; std::string backhaul_preferred_bssid; std::string backhaul_wire_iface; diff --git a/common/beerocks/bcl/source/beerocks_config_file.cpp b/common/beerocks/bcl/source/beerocks_config_file.cpp index 50ad56e156..00c10857a1 100644 --- a/common/beerocks/bcl/source/beerocks_config_file.cpp +++ b/common/beerocks/bcl/source/beerocks_config_file.cpp @@ -150,7 +150,6 @@ bool config_file::read_slave_config_file(const std::string &config_file_path, sC std::make_tuple("model=", &conf.model, mandatory_slave), std::make_tuple("ucc_listener_port=", &conf.ucc_listener_port, mandatory_slave), std::make_tuple("enable_arp_monitor=", &conf.enable_arp_monitor, mandatory_slave), - std::make_tuple("enable_keep_alive=", &conf.enable_keep_alive, mandatory_slave), std::make_tuple("bridge_iface=", &conf.bridge_iface, 0), std::make_tuple("enable_system_hang_test=", &conf.enable_system_hang_test, 0), std::make_tuple("const_backhaul_slave=", &conf.const_backhaul_slave, 0), From 527cda7755e1a0c495ef4340d3be6a01c1952c4d Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 11:37:00 +0300 Subject: [PATCH 350/453] agent: son_slave: Remove deprecated variable Need to remove deprecated variable master_last_seen. https://jira.prplfoundation.org/browse/PPM-286 Signed-off-by: Vladyslav Tupikin --- agent/src/beerocks/slave/son_slave_thread.cpp | 4 ---- agent/src/beerocks/slave/son_slave_thread.h | 1 - 2 files changed, 5 deletions(-) diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index e82138bea4..882e85ee05 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -326,8 +326,6 @@ bool slave_thread::handle_cmdu_control_ieee1905_1_message(Socket *sd, return true; } - master_last_seen = std::chrono::steady_clock::now(); - switch (cmdu_message_type) { case ieee1905_1::eMessageType::ACK_MESSAGE: return handle_ack_message(sd, cmdu_rx); @@ -406,8 +404,6 @@ bool slave_thread::handle_cmdu_control_message(Socket *sd, return true; } - master_last_seen = std::chrono::steady_clock::now(); - switch (beerocks_header->action_op()) { case beerocks_message::ACTION_CONTROL_ARP_QUERY_REQUEST: { LOG(TRACE) << "ACTION_CONTROL_ARP_QUERY_REQUEST"; diff --git a/agent/src/beerocks/slave/son_slave_thread.h b/agent/src/beerocks/slave/son_slave_thread.h index 1cff949f1b..97ca9e0374 100644 --- a/agent/src/beerocks/slave/son_slave_thread.h +++ b/agent/src/beerocks/slave/son_slave_thread.h @@ -198,7 +198,6 @@ class slave_thread : public beerocks::socket_thread { Socket *ap_manager_socket = nullptr; std::string m_fronthaul_iface; - std::chrono::steady_clock::time_point master_last_seen; std::chrono::steady_clock::time_point monitor_last_seen; std::chrono::steady_clock::time_point ap_manager_last_seen; int monitor_retries_counter = 0; From 0d10404cf92d10f1da05b8c162912ecaf1e78f76 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 23 Jul 2020 18:07:37 +0300 Subject: [PATCH 351/453] controller: son_master: Remove case for deprecated message Need to remove case from handler for deprecated VS message ACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE https://jira.prplfoundation.org/browse/PPM-292 Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/master/son_master_thread.cpp | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/controller/src/beerocks/master/son_master_thread.cpp b/controller/src/beerocks/master/son_master_thread.cpp index 0bfc6a6e94..2d5f3d4933 100644 --- a/controller/src/beerocks/master/son_master_thread.cpp +++ b/controller/src/beerocks/master/son_master_thread.cpp @@ -3360,41 +3360,6 @@ bool master_thread::handle_cmdu_control_message(const std::string &src_mac, << "delay_trigger: " << (int)response->params().delay_trigger); break; } - case beerocks_message::ACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE: { - auto response = beerocks_header->addClass< - beerocks_message::cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE>(); - if (response == nullptr) { - LOG(ERROR) << "addClass ACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE failed"; - return false; - } - LOG_CLI(DEBUG, - "link measurements response: " - << std::endl - << "sta_mac: " << response->params().sta_mac << std::endl - << "transmit_power: " << (int)response->params().transmit_power << std::endl - << "link_margin: " << (int)response->params().link_margin << std::endl - << "rx_ant_id: " << (int)response->params().rx_ant_id << std::endl - << "tx_ant_id: " << (int)response->params().tx_ant_id << std::endl - << "rcpi: " << (int)response->params().rcpi << std::endl - << "rsni: " << (int)response->params().rsni - - << std::endl - << "dmg_link_margin_activity: " - << (int)response->params().dmg_link_margin_activity << std::endl - << "dmg_link_margin_mcs: " << (int)response->params().dmg_link_margin_mcs - << std::endl - << "dmg_link_margin_link_margin: " - << (int)response->params().dmg_link_margin_link_margin << std::endl - << "dmg_link_margin_snr: " << (int)response->params().dmg_link_margin_snr - << std::endl - << "dmg_link_margin_reference_timestamp: " - << (int)response->params().dmg_link_margin_reference_timestamp << std::endl - << "dmg_link_adapt_ack_activity: " - << (int)response->params().dmg_link_adapt_ack_activity << std::endl - << "dmg_link_adapt_ack_reference_timestamp: " - << (int)response->params().dmg_link_adapt_ack_reference_timestamp); - break; - } case beerocks_message::ACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE: { auto response = beerocks_header->addClass< beerocks_message::cACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE>(); From 749cddb2531814c9945e80f9403441e233e87e84 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 23 Jul 2020 17:36:15 +0300 Subject: [PATCH 352/453] agent: monitor_thread: Remove depredcated case from handler Need to remove deprecated case for VS message ACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST from CS message handler. https://jira.prplfoundation.org/browse/PPM-292 Signed-off-by: Vladyslav Tupikin --- .../fronthaul_manager/monitor/monitor_thread.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp index d87b4a3d4d..66a5ce8111 100644 --- a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp +++ b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp @@ -1382,22 +1382,6 @@ bool monitor_thread::handle_cmdu_vs_message(Socket &sd, ieee1905_1::CmduMessageR mon_wlan_hal->sta_statistics_11k_request(bwl_request); break; } - case beerocks_message::ACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST: { - auto request = - beerocks_header - ->addClass(); - if (request == nullptr) { - LOG(ERROR) << "addClass cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST failed"; - return false; - } - std::string mac_str = tlvf::mac_to_string(request->mac()); - - LOG(DEBUG) << "ACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST:" << std::endl - << "mac=" << mac_str; - - mon_wlan_hal->sta_link_measurements_11k_request(mac_str); - break; - } case beerocks_message::ACTION_MONITOR_CHANNEL_SCAN_TRIGGER_SCAN_REQUEST: { auto request = beerocks_header From 2dfd30c27625d581e822830a88322abeb4964fe3 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 23 Jul 2020 17:23:47 +0300 Subject: [PATCH 353/453] agent: monitor_thread: Remove deprecated event Need to remove case for procesing deprecated event RRM_Link_Measurement_Response. https://jira.prplfoundation.org/browse/PPM-292 Signed-off-by: Vladyslav Tupikin --- .../monitor/monitor_thread.cpp | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp index 66a5ce8111..ca281bbc1a 100644 --- a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp +++ b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp @@ -1760,46 +1760,6 @@ bool monitor_thread::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t event } break; - case Event::RRM_Link_Measurement_Response: { - - auto hal_data = static_cast(data); - auto response = message_com::create_vs_message< - beerocks_message::cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE>(cmdu_tx); - if (response == nullptr) { - LOG(ERROR) - << "Failed building cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE message!"; - break; - } - - response->params().dialog_token = hal_data->dialog_token; - response->params().rep_mode = hal_data->rep_mode; - response->params().rx_ant_id = hal_data->rx_ant_id; - response->params().tx_ant_id = hal_data->tx_ant_id; - response->params().rcpi = hal_data->rcpi; - response->params().rsni = hal_data->rsni; - response->params().transmit_power = hal_data->transmit_power; - response->params().link_margin = hal_data->link_margin; - response->params().use_optional_dmg_link_margin = hal_data->use_optional_dmg_link_margin; - response->params().dmg_link_margin_activity = hal_data->dmg_link_margin_activity; - response->params().dmg_link_margin_mcs = hal_data->dmg_link_margin_mcs; - response->params().dmg_link_margin_link_margin = hal_data->dmg_link_margin_link_margin; - response->params().dmg_link_margin_snr = hal_data->dmg_link_margin_snr; - response->params().use_optional_dmg_link_adapt_ack = - hal_data->use_optional_dmg_link_adapt_ack; - response->params().dmg_link_adapt_ack_activity = hal_data->dmg_link_adapt_ack_activity; - response->params().dmg_link_margin_reference_timestamp = - hal_data->dmg_link_margin_reference_timestamp; - response->params().dmg_link_adapt_ack_reference_timestamp = - hal_data->dmg_link_adapt_ack_reference_timestamp; - std::copy_n(hal_data->sta_mac.oct, sizeof(response->params().sta_mac.oct), - response->params().sta_mac.oct); - - // debug_link_measurements_11k_response(msg); - - message_com::send_cmdu(slave_socket, cmdu_tx); - - } break; - case Event::AP_Enabled: { if (!data) { LOG(ERROR) << "AP_Enabled without data"; From a0170dfcc7d2b58dfc7e3652b68656eb89f14cec Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 23 Jul 2020 13:51:20 +0300 Subject: [PATCH 354/453] common: bwl: Remove deprecated event from nl80211 Need to remove deprecated event RRM_Link_Measurement_Response from nl80211. https://jira.prplfoundation.org/browse/PPM-292 Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp index 13fb9e5627..1591a8af39 100644 --- a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp +++ b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp @@ -61,8 +61,6 @@ static mon_wlan_hal::Event wav_to_bwl_event(const std::string &opcode) // } else if (opcode == "RRM-STA-STATISTICS-RECEIVED") { // return mon_wlan_hal::Event::RRM_STA_Statistics_Response; // } else if (opcode == "RRM-LINK-MEASUREMENT-RECEIVED") { - // return mon_wlan_hal::Event::RRM_Link_Measurement_Response; - // } return mon_wlan_hal::Event::Invalid; } From c6de5184a584e0c5e25e94ca52807d22abca4270 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 23 Jul 2020 13:50:21 +0300 Subject: [PATCH 355/453] common: bwl: Remove deprecated event from dwpal Need to remove deprecated event RRM_Link_Measurement_Response from dwpal. https://jira.prplfoundation.org/browse/PPM-292 Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp index ba07244c18..32954a09b6 100644 --- a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp @@ -69,8 +69,6 @@ static mon_wlan_hal::Event dwpal_to_bwl_event(const std::string &opcode) return mon_wlan_hal::Event::RRM_Beacon_Response; } else if (opcode == "RRM-STA-STATISTICS-RECEIVED") { return mon_wlan_hal::Event::RRM_STA_Statistics_Response; - } else if (opcode == "RRM-LINK-MEASUREMENT-RECEIVED") { - return mon_wlan_hal::Event::RRM_Link_Measurement_Response; } else if (opcode == "AP-ENABLED") { return mon_wlan_hal::Event::AP_Enabled; } else if (opcode == "AP-DISABLED") { @@ -1295,7 +1293,6 @@ bool mon_wlan_hal_dwpal::process_dwpal_event(char *buffer, int bufLen, const std } case Event::RRM_STA_Statistics_Response: - case Event::RRM_Link_Measurement_Response: case Event::RRM_Channel_Load_Response: break; // Gracefully ignore unhandled events From eec7941b55ba050571a7c66704d755b637854c2f Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 23 Jul 2020 13:48:14 +0300 Subject: [PATCH 356/453] common: bwl: Remove deprecated event Need to remove deprecated event RRM_Link_Measurement_Response. https://jira.prplfoundation.org/browse/PPM-292 Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/include/bwl/mon_wlan_hal.h | 1 - 1 file changed, 1 deletion(-) diff --git a/common/beerocks/bwl/include/bwl/mon_wlan_hal.h b/common/beerocks/bwl/include/bwl/mon_wlan_hal.h index d9a9cb09d1..b872ef4274 100644 --- a/common/beerocks/bwl/include/bwl/mon_wlan_hal.h +++ b/common/beerocks/bwl/include/bwl/mon_wlan_hal.h @@ -35,7 +35,6 @@ class mon_wlan_hal : public virtual base_wlan_hal { RRM_Beacon_Request_Status, RRM_Beacon_Response, RRM_STA_Statistics_Response, - RRM_Link_Measurement_Response, //CHANNEL_SCAN events Channel_Scan_Triggered, Channel_Scan_New_Results_Ready, From 7acd4f284ecf2b0bc7e613b9579d25d0f199c295 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 23 Jul 2020 13:41:33 +0300 Subject: [PATCH 357/453] agent: fronthaul_manager: Remove deprecated method Need to remove deprecated method debug_link_measurements_11k_response(). https://jira.prplfoundation.org/browse/PPM-292 Signed-off-by: Vladyslav Tupikin --- .../monitor/monitor_thread.cpp | 21 ------------------- .../monitor/monitor_thread.h | 2 -- 2 files changed, 23 deletions(-) diff --git a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp index ca281bbc1a..97ce4a85b4 100644 --- a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp +++ b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp @@ -2128,27 +2128,6 @@ bool monitor_thread::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t event // ; // } -// void monitor_thread::debug_link_measurements_11k_response(message::sACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE* event) -// { -// LOG(DEBUG) << "DATA TEST:" -// << std::endl << "sta_mac: " << event->params.sta_mac -// << std::endl << "transmit_power: " << (int)event->params.transmit_power -// << std::endl << "link_margin: " << (int)event->params.link_margin -// << std::endl << "rx_ant_id: " << (int)event->params.rx_ant_id -// << std::endl << "tx_ant_id: " << (int)event->params.tx_ant_id -// << std::endl << "rcpi: " << (int)event->params.rcpi -// << std::endl << "rsni: " << (int)event->params.rsni - -// << std::endl << "dmg_link_margin_activity: " << (int)event->params.dmg_link_margin_activity -// << std::endl << "dmg_link_margin_mcs: " << (int)event->params.dmg_link_margin_mcs -// << std::endl << "dmg_link_margin_link_margin: " << (int)event->params.dmg_link_margin_link_margin -// << std::endl << "dmg_link_margin_snr: " << (int)event->params.dmg_link_margin_snr -// << std::endl << "dmg_link_margin_reference_timestamp: " << (int)event->params.dmg_link_margin_reference_timestamp -// << std::endl << "dmg_link_adapt_ack_activity: " << (int)event->params.dmg_link_adapt_ack_activity -// << std::endl << "dmg_link_adapt_ack_reference_timestamp: " << (int)event->params.dmg_link_adapt_ack_reference_timestamp -// ; -// } - void monitor_thread::send_heartbeat() { if (slave_socket == nullptr) { diff --git a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.h b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.h index 767f3b7287..4dd1734e31 100644 --- a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.h +++ b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.h @@ -91,8 +91,6 @@ class monitor_thread : public beerocks::socket_thread { void debug_beacon_11k_response(beerocks_message::sBeaconResponse11k &event); void debug_statistics_11k_request(beerocks_message::sStatisticsRequest11k &request); void debug_statistics_11k_response(beerocks_message::sStatisticsResponse11k &event); - void - debug_link_measurements_11k_response(beerocks_message::sLinkMeasurementsResponse11k &event); void send_heartbeat(); void update_vaps_in_db(); From a717e68d22edc988f94792440ef6fa2d5b5451e6 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 23 Jul 2020 13:36:40 +0300 Subject: [PATCH 358/453] agnet: son_slave: Remove deprecated message Need to remove deprecated case for ACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE from VS message handler. https://jira.prplfoundation.org/browse/PPM-292 Signed-off-by: Vladyslav Tupikin --- agent/src/beerocks/slave/son_slave_thread.cpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 882e85ee05..08efa3b796 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -2678,25 +2678,6 @@ bool slave_thread::handle_cmdu_monitor_message(Socket *sd, send_cmdu_to_controller(cmdu_tx); break; } - case beerocks_message::ACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE: { - auto response_in = beerocks_header->addClass< - beerocks_message::cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE>(); - if (response_in == nullptr) { - LOG(ERROR) << "addClass ACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE failed"; - break; - } - auto response_out = message_com::create_vs_message< - beerocks_message::cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE>( - cmdu_tx, beerocks_header->id()); - if (response_out == nullptr) { - LOG(ERROR) - << "Failed building ACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE message!"; - break; - } - response_out->params() = response_in->params(); - send_cmdu_to_controller(cmdu_tx); - break; - } case beerocks_message::ACTION_MONITOR_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE: { LOG(INFO) << "ACTION_MONITOR_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE: action_op: " << int(beerocks_header->action_op()); From 5d61404c9391707d04561bab61bd326f566bd321 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 23 Jul 2020 13:07:37 +0300 Subject: [PATCH 359/453] common: tlvf: Remove deprecated VS message Need to remove deprecated vendor-specific messages: ACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_REQUEST ACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE Also need to remove all related code from autogenerated files. https://jira.prplfoundation.org/browse/PPM-292 Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 2 - .../beerocks/tlvf/beerocks_message_monitor.h | 42 ------ .../tlvf/beerocks_message_monitor.cpp | 140 ------------------ .../tlvf/beerocks_message_action.yaml | 2 - .../tlvf/beerocks_message_monitor.yaml | 8 - 5 files changed, 194 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index 34ffefe0df..89ab003e12 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -237,8 +237,6 @@ enum eActionOp_MONITOR: uint8_t { ACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_RESPONSE = 0x20, ACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST = 0x21, ACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE = 0x22, - ACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST = 0x23, - ACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE = 0x24, ACTION_MONITOR_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE = 0x25, ACTION_MONITOR_CLIENT_NO_ACTIVITY_NOTIFICATION = 0x26, ACTION_MONITOR_CLIENT_NEW_IP_ADDRESS_NOTIFICATION = 0x27, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_monitor.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_monitor.h index 2fbb5371b1..ffb5bba71d 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_monitor.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_monitor.h @@ -678,48 +678,6 @@ class cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE : public BaseClass sStatisticsResponse11k* m_params = nullptr; }; -class cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST : public BaseClass -{ - public: - cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST(std::shared_ptr base, bool parse = false); - ~cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST(); - - static eActionOp_MONITOR get_action_op(){ - return (eActionOp_MONITOR)(ACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST); - } - sMacAddr& mac(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_MONITOR* m_action_op = nullptr; - sMacAddr* m_mac = nullptr; -}; - -class cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE : public BaseClass -{ - public: - cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE(std::shared_ptr base, bool parse = false); - ~cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE(); - - static eActionOp_MONITOR get_action_op(){ - return (eActionOp_MONITOR)(ACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE); - } - sLinkMeasurementsResponse11k& params(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_MONITOR* m_action_op = nullptr; - sLinkMeasurementsResponse11k* m_params = nullptr; -}; - class cACTION_MONITOR_CLIENT_NEW_IP_ADDRESS_NOTIFICATION : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_monitor.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_monitor.cpp index 78ebfa8780..c6a912e351 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_monitor.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_monitor.cpp @@ -2295,146 +2295,6 @@ bool cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE::init() return true; } -cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST::cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST::cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST::~cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST() { -} -sMacAddr& cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST::mac() { - return (sMacAddr&)(*m_mac); -} - -void cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_MONITOR), reinterpret_cast(m_action_op)); - m_mac->struct_swap(); -} - -bool cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sMacAddr); // mac - return class_size; -} - -bool cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_mac->struct_init(); } - if (m_parse__) { class_swap(); } - return true; -} - -cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::~cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE() { -} -sLinkMeasurementsResponse11k& cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::params() { - return (sLinkMeasurementsResponse11k&)(*m_params); -} - -void cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_MONITOR), reinterpret_cast(m_action_op)); - m_params->struct_swap(); -} - -bool cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sLinkMeasurementsResponse11k); // params - return class_size; -} - -bool cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_params = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sLinkMeasurementsResponse11k))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sLinkMeasurementsResponse11k) << ") Failed!"; - return false; - } - if (!m_parse__) { m_params->struct_init(); } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_MONITOR_CLIENT_NEW_IP_ADDRESS_NOTIFICATION::cACTION_MONITOR_CLIENT_NEW_IP_ADDRESS_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index 6bdf260c79..59ff78cdec 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -269,8 +269,6 @@ eActionOp_MONITOR: ACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_RESPONSE: 32 ACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST: 33 ACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE: 34 - ACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST: 35 - ACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE: 36 ACTION_MONITOR_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE: 37 ACTION_MONITOR_CLIENT_NO_ACTIVITY_NOTIFICATION: 38 ACTION_MONITOR_CLIENT_NEW_IP_ADDRESS_NOTIFICATION: 39 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml index 55c1ce0db5..8161ba8a33 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml @@ -159,14 +159,6 @@ cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE: _type: class params: sStatisticsResponse11k -cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST: - _type: class - mac: sMacAddr - -cACTION_MONITOR_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE: - _type: class - params: sLinkMeasurementsResponse11k - cACTION_MONITOR_CLIENT_NEW_IP_ADDRESS_NOTIFICATION: _type: class mac: sMacAddr From e316656763281047ec161b7b002c7e5b7f8f6de9 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 23 Jul 2020 12:59:42 +0300 Subject: [PATCH 360/453] controller: beerocks_cli: Remove deprecated CLI command Need to remove deprecated CLI command client_link_measurement_11k_req and all releated code. https://jira.prplfoundation.org/browse/PPM-292 Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/cli/beerocks_cli_socket.cpp | 28 ------------------- .../src/beerocks/cli/beerocks_cli_socket.h | 4 --- 2 files changed, 32 deletions(-) diff --git a/controller/src/beerocks/cli/beerocks_cli_socket.cpp b/controller/src/beerocks/cli/beerocks_cli_socket.cpp index 256722251f..6d1af6c847 100644 --- a/controller/src/beerocks/cli/beerocks_cli_socket.cpp +++ b/controller/src/beerocks/cli/beerocks_cli_socket.cpp @@ -169,10 +169,6 @@ void cli_socket::setFunctionsMapAndArray() "sends statistics 11k request to 'client_mac', with 'group_identity', about 'peer_mac'", static_cast(&cli_socket::client_statistics_11k_req_caller), 3, 4, STRING_ARG, STRING_ARG, INT_ARG, STRING_ARG); - insertCommandToMap("client_link_measurement_11k_req", " ", - "sends link measurement 11k request for 'client_mac'", - static_cast(&cli_socket::client_link_measurement_11k_req_caller), - 2, 2, STRING_ARG, STRING_ARG); insertCommandToMap( "ap_neighbor_11k_set", " ", "add 'bssid' with 'channel' to 11k neighbor list of 'hostap_mac' with 'vap_id'", @@ -449,13 +445,6 @@ int cli_socket::client_statistics_11k_req_caller(int numOfArgs) return -1; } -int cli_socket::client_link_measurement_11k_req_caller(int numOfArgs) -{ - if (numOfArgs != 2) - return -1; - return client_link_measurement_11k_req(args.stringArgs[0], args.stringArgs[1]); -} - int cli_socket::set_neighbor_11k_caller(int numOfArgs) { if (numOfArgs == 4) { @@ -806,23 +795,6 @@ int cli_socket::client_statistics_11k_req(std::string hostap_mac, std::string cl return 0; } -int cli_socket::client_link_measurement_11k_req(std::string hostap_mac, std::string client_mac) -{ - auto request = message_com::create_vs_message< - beerocks_message::cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST>(cmdu_tx); - if (request == nullptr) { - LOG(ERROR) << "Failed building cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST message!"; - return -1; - } - request->client_mac() = tlvf::mac_from_string(client_mac); - request->hostap_mac() = tlvf::mac_from_string(hostap_mac); - - wait_response = true; - message_com::send_cmdu(master_socket, cmdu_tx); - waitResponseReady(); - return 0; -} - int cli_socket::set_neighbor_11k(std::string ap_mac, std::string bssid, uint8_t channel, int8_t vap_id) { diff --git a/controller/src/beerocks/cli/beerocks_cli_socket.h b/controller/src/beerocks/cli/beerocks_cli_socket.h index a4a39a2dad..edd24b09e4 100644 --- a/controller/src/beerocks/cli/beerocks_cli_socket.h +++ b/controller/src/beerocks/cli/beerocks_cli_socket.h @@ -83,8 +83,6 @@ class cli_socket : public socket_thread, public cli { int client_beacon_11k_req_caller(int numOfArgs); - int client_link_measurement_11k_req_caller(int numOfArgs); - int client_statistics_11k_req_caller(int numOfArgs); // Functions @@ -134,8 +132,6 @@ class cli_socket : public socket_thread, public cli { std::string ssid, uint16_t duration, uint16_t rand_ival, uint16_t repeats, int16_t op_class, std::string mode); - int client_link_measurement_11k_req(std::string hostap_mac, std::string client_mac); - int client_statistics_11k_req(std::string hostap_mac, std::string client_mac, uint8_t group_identity, std::string peer_mac = net::network_utils::WILD_MAC_STRING); From 007b144a73da0fba36595f37f4e7c37654fae88c Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 22 Jul 2020 20:58:51 +0300 Subject: [PATCH 361/453] controller: son_management: Remove case from handler Need to remove case for depricated CLI message ACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST https://jira.prplfoundation.org/browse/PPM-292 Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/master/son_management.cpp | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/controller/src/beerocks/master/son_management.cpp b/controller/src/beerocks/master/son_management.cpp index 25a724db58..6bc32ec1e8 100644 --- a/controller/src/beerocks/master/son_management.cpp +++ b/controller/src/beerocks/master/son_management.cpp @@ -623,36 +623,6 @@ void son_management::handle_cli_message(Socket *sd, break; } - case beerocks_message::ACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST: { - auto cli_request = - beerocks_header - ->addClass(); - if (cli_request == nullptr) { - LOG(ERROR) << "addClass ACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST failed"; - isOK = false; - break; - } - - std::string client_mac = tlvf::mac_to_string(cli_request->client_mac()); - std::string hostap_mac = tlvf::mac_to_string(cli_request->hostap_mac()); - auto agent_mac = database.get_node_parent_ire(hostap_mac); - LOG(DEBUG) << "CLI link measurement request for " << client_mac << " to " << hostap_mac; - - auto request = message_com::create_vs_message< - beerocks_message::cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST>(cmdu_tx); - if (request == nullptr) { - LOG(ERROR) - << "Failed building ACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST message!"; - isOK = false; - break; - } - - request->mac() = cli_request->client_mac(); - - const auto parent_radio = database.get_node_parent_radio(hostap_mac); - son_actions::send_cmdu_to_agent(agent_mac, cmdu_tx, database, parent_radio); - break; - } case beerocks_message::ACTION_CLI_HOSTAP_CHANNEL_SWITCH_REQUEST: { auto cli_request = beerocks_header From b5a49037dbc4e4c834d9350421877c5c021cf37b Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 24 Jul 2020 11:10:10 +0300 Subject: [PATCH 362/453] common: tlvf: Remove deprecated message Need to merove deprecated message ACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST and all related code from autogenerated files. https://jira.prplfoundation.org/browse/PPM-292 Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 1 - .../beerocks/tlvf/beerocks_message_cli.h | 23 ------ .../beerocks/tlvf/beerocks_message_cli.cpp | 82 ------------------- .../tlvf/beerocks_message_action.yaml | 1 - .../beerocks/tlvf/beerocks_message_cli.yaml | 5 -- 5 files changed, 112 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index 89ab003e12..550e949bf7 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -285,7 +285,6 @@ enum eActionOp_CLI: uint8_t { ACTION_CLI_CLIENT_DISALLOW_REQUEST = 0x51, ACTION_CLI_CLIENT_DISCONNECT_REQUEST = 0x52, ACTION_CLI_CLIENT_BSS_STEER_REQUEST = 0x53, - ACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST = 0x54, ACTION_CLI_CLIENT_BEACON_11K_REQUEST = 0x56, ACTION_CLI_CLIENT_STATISTICS_11K_REQUEST = 0x57, ACTION_CLI_HOSTAP_CHANNEL_SWITCH_REQUEST = 0x7a, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h index 12535061e0..377c8ec4a3 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h @@ -458,29 +458,6 @@ class cACTION_CLI_CLIENT_BSS_STEER_REQUEST : public BaseClass uint32_t* m_disassoc_timer_ms = nullptr; }; -class cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST : public BaseClass -{ - public: - cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST(std::shared_ptr base, bool parse = false); - ~cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST(); - - static eActionOp_CLI get_action_op(){ - return (eActionOp_CLI)(ACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST); - } - sMacAddr& hostap_mac(); - sMacAddr& client_mac(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CLI* m_action_op = nullptr; - sMacAddr* m_hostap_mac = nullptr; - sMacAddr* m_client_mac = nullptr; -}; - class cACTION_CLI_CLIENT_BEACON_11K_REQUEST : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp index deeac6446d..aae9565908 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp @@ -1529,88 +1529,6 @@ bool cACTION_CLI_CLIENT_BSS_STEER_REQUEST::init() return true; } -cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST::cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST::cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST::~cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST() { -} -sMacAddr& cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST::hostap_mac() { - return (sMacAddr&)(*m_hostap_mac); -} - -sMacAddr& cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST::client_mac() { - return (sMacAddr&)(*m_client_mac); -} - -void cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CLI), reinterpret_cast(m_action_op)); - m_hostap_mac->struct_swap(); - m_client_mac->struct_swap(); -} - -bool cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sMacAddr); // hostap_mac - class_size += sizeof(sMacAddr); // client_mac - return class_size; -} - -bool cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_hostap_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_hostap_mac->struct_init(); } - m_client_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_client_mac->struct_init(); } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_CLI_CLIENT_BEACON_11K_REQUEST::cACTION_CLI_CLIENT_BEACON_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index 59ff78cdec..e48f57f086 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -327,7 +327,6 @@ eActionOp_CLI: ACTION_CLI_CLIENT_DISALLOW_REQUEST: 81 ACTION_CLI_CLIENT_DISCONNECT_REQUEST: 82 ACTION_CLI_CLIENT_BSS_STEER_REQUEST: 83 - ACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST: 84 ACTION_CLI_CLIENT_BEACON_11K_REQUEST: 86 ACTION_CLI_CLIENT_STATISTICS_11K_REQUEST: 87 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml index a607289975..60f7922de4 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml @@ -115,11 +115,6 @@ cACTION_CLI_CLIENT_BSS_STEER_REQUEST: bssid: sMacAddr disassoc_timer_ms: uint32_t -cACTION_CLI_CLIENT_LINK_MEASUREMENT_11K_REQUEST: - _type: class - hostap_mac: sMacAddr - client_mac: sMacAddr - cACTION_CLI_CLIENT_BEACON_11K_REQUEST: _type: class client_mac: sMacAddr From c1c2485ff39ee4e0423e537551b3a100b1d228f5 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 22 Jul 2020 20:43:13 +0300 Subject: [PATCH 363/453] agent: son_slave: Remove case from VS message handler Need to remove case for processing deprecated vendor-specific message ACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST from vs hanler. https://jira.prplfoundation.org/browse/PPM-292 Signed-off-by: Vladyslav Tupikin --- agent/src/beerocks/slave/son_slave_thread.cpp | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 08efa3b796..dd056123ee 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -844,29 +844,6 @@ bool slave_thread::handle_cmdu_control_message(Socket *sd, message_com::send_cmdu(monitor_socket, cmdu_tx); break; } - case beerocks_message::ACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST: { - auto request_in = - beerocks_header - ->addClass(); - if (request_in == nullptr) { - LOG(ERROR) << "addClass ACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST failed"; - return false; - } - - auto request_out = message_com::create_vs_message< - beerocks_message::cACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST>( - cmdu_tx, beerocks_header->id()); - if (request_out == nullptr) { - LOG(ERROR) - << "Failed building ACTION_MONITOR_CLIENT_LINK_MEASUREMENT_11K_REQUEST message!"; - return false; - } - - request_out->mac() = request_in->mac(); - message_com::send_cmdu(monitor_socket, cmdu_tx); - break; - } - case beerocks_message::ACTION_CONTROL_HOSTAP_UPDATE_STOP_ON_FAILURE_ATTEMPTS_REQUEST: { auto request_in = beerocks_header->addClass< beerocks_message::cACTION_CONTROL_HOSTAP_UPDATE_STOP_ON_FAILURE_ATTEMPTS_REQUEST>(); From 257f178bd0087d46f250fa6597e82bb846b30cdd Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 22 Jul 2020 17:21:20 +0300 Subject: [PATCH 364/453] common: tlvf: Remove deprecated VS messages Need to remove deprecated vendor-specific messages: ACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST ACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_RESPONSE Also need to remove deprecated code from autogenerated file. https://jira.prplfoundation.org/browse/PPM-292 Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 2 - .../beerocks/tlvf/beerocks_message_control.h | 42 ------ .../tlvf/beerocks_message_control.cpp | 140 ------------------ .../tlvf/beerocks_message_action.yaml | 2 - .../tlvf/beerocks_message_control.yaml | 8 - 5 files changed, 194 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index 550e949bf7..0b3ce67f31 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -88,8 +88,6 @@ enum eActionOp_CONTROL: uint8_t { ACTION_CONTROL_CLIENT_BEACON_11K_RESPONSE = 0x76, ACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST = 0x79, ACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE = 0x7a, - ACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST = 0x7b, - ACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE = 0x7c, ACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE = 0x7d, ACTION_CONTROL_CLIENT_NO_ACTIVITY_NOTIFICATION = 0x7e, ACTION_CONTROL_STEERING_CLIENT_SET_GROUP_REQUEST = 0x7f, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h index 10d3a4bc99..e3458039c1 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h @@ -1203,48 +1203,6 @@ class cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE : public BaseClass sStatisticsResponse11k* m_params = nullptr; }; -class cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST : public BaseClass -{ - public: - cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST(std::shared_ptr base, bool parse = false); - ~cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST(); - - static eActionOp_CONTROL get_action_op(){ - return (eActionOp_CONTROL)(ACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST); - } - sMacAddr& mac(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CONTROL* m_action_op = nullptr; - sMacAddr* m_mac = nullptr; -}; - -class cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE : public BaseClass -{ - public: - cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE(std::shared_ptr base, bool parse = false); - ~cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE(); - - static eActionOp_CONTROL get_action_op(){ - return (eActionOp_CONTROL)(ACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE); - } - sLinkMeasurementsResponse11k& params(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CONTROL* m_action_op = nullptr; - sLinkMeasurementsResponse11k* m_params = nullptr; -}; - class cACTION_CONTROL_STEERING_CLIENT_SET_GROUP_REQUEST : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp index b0621d267d..47fd726f6e 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp @@ -4173,146 +4173,6 @@ bool cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE::init() return true; } -cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST::cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST::cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST::~cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST() { -} -sMacAddr& cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST::mac() { - return (sMacAddr&)(*m_mac); -} - -void cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CONTROL), reinterpret_cast(m_action_op)); - m_mac->struct_swap(); -} - -bool cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sMacAddr); // mac - return class_size; -} - -bool cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_mac->struct_init(); } - if (m_parse__) { class_swap(); } - return true; -} - -cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::~cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE() { -} -sLinkMeasurementsResponse11k& cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::params() { - return (sLinkMeasurementsResponse11k&)(*m_params); -} - -void cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CONTROL), reinterpret_cast(m_action_op)); - m_params->struct_swap(); -} - -bool cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sLinkMeasurementsResponse11k); // params - return class_size; -} - -bool cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_params = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sLinkMeasurementsResponse11k))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sLinkMeasurementsResponse11k) << ") Failed!"; - return false; - } - if (!m_parse__) { m_params->struct_init(); } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_CONTROL_STEERING_CLIENT_SET_GROUP_REQUEST::cACTION_CONTROL_STEERING_CLIENT_SET_GROUP_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index e48f57f086..72f27007a7 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -85,8 +85,6 @@ eActionOp_CONTROL: ACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST: 121 ACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE: 122 - ACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST: 123 - ACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE: 124 ACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE: 125 ACTION_CONTROL_CLIENT_NO_ACTIVITY_NOTIFICATION: 126 ACTION_CONTROL_STEERING_CLIENT_SET_GROUP_REQUEST: 127 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml index 027718a212..d28ed2ec24 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml @@ -279,14 +279,6 @@ cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE: _type: class params: sStatisticsResponse11k -cACTION_CONTROL_CLIENT_LINK_MEASUREMENT_11K_REQUEST: - _type: class - mac: sMacAddr - -cACTION_CONTROL_CLIENT_LINK_MEASUREMENTS_11K_RESPONSE: - _type: class - params: sLinkMeasurementsResponse11k - ################################################# # MONITOR RDKB CONFIGURATIONS ################################################# From 3786c8d98ff6d99284cdceb6f1c4d575044d80e5 Mon Sep 17 00:00:00 2001 From: Sinan Akpolat Date: Mon, 20 Jul 2020 01:20:23 +0300 Subject: [PATCH 365/453] tests: boardfarm: Duplicate CMDU & TLV methods in boardfarm test base class Normally duplicating code in this way must be avoided but we need to do this temporarily (until test_flows.py is removed from the project) Note that the tests in boardfarm throws exceptions to mark test as failed so self.fail() calls are removed. https://jira.prplfoundation.org/browse/PPM-303 Signed-off-by: Sinan Akpolat --- .../tests/prplmesh_base_test.py | 145 +++++++++++++++++- tests/test_flows.py | 1 + 2 files changed, 145 insertions(+), 1 deletion(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/prplmesh_base_test.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/prplmesh_base_test.py index 5e03247c77..556356e7f3 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/prplmesh_base_test.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/prplmesh_base_test.py @@ -3,10 +3,12 @@ # This code is subject to the terms of the BSD+Patent license. # See LICENSE file for more details. -from typing import Union +from typing import Union, Callable, NoReturn from boardfarm.tests import bft_base_test +from opts import debug import environment as env +import sniffer class PrplMeshBaseTest(bft_base_test.BftBaseTest): @@ -30,3 +32,144 @@ def prplmesh_status_check(self, entity_or_radio: Union[env.ALEntity, env.Radio]) if not result: raise Exception return result + + def check_cmdu( + self, msg: str, match_function: Callable[[sniffer.Packet], bool] + ) -> [sniffer.Packet]: + """Verify that the wired_sniffer has captured a CMDU that satisfies match_function. + + Mark failure if no satisfying packet is found. + + Parameters + ---------- + msg: str + Message to show in case of failure. It is formatted in a context like + "No CMDU found". + + match_function: Callable[[sniffer.Packet], bool] + A function that returns True if it is the expected packet. It is called on every packet + returned by get_packet_capture. + + Returns + ------- + [sniffer.Packet] + The matching packets. + """ + debug("Checking for CMDU {}".format(msg)) + result = self.dev.DUT.wired_sniffer.get_cmdu_capture(match_function) + assert result, "No CMDU {} found".format(msg) + return result + + def check_cmdu_type( + self, msg: str, msg_type: int, eth_src: str, eth_dst: str = None, mid: int = None + ) -> [sniffer.Packet]: + """Verify that the wired sniffer has captured a CMDU. + + Mark failure if the CMDU is not found. + + Parameters + ---------- + msg: str + Message to show in case of failure. It is formatted in a context like + "No CMDU found". + + msg_type: int + CMDU message type that is expected. + + eth_src: str + MAC address of the sender that is expected. + + eth_dst: str + MAC address of the destination that is expected. If omitted, the IEEE1905.1 multicast + MAC address is used. + + mid: int + Message Identifier that is expected. If omitted, the MID is not checked. + + Returns + ------- + [sniffer.Packet] + The matching packets. + """ + debug("Checking for CMDU {} (0x{:04x}) from {}".format(msg, msg_type, eth_src)) + result = self.dev.DUT.wired_sniffer.get_cmdu_capture_type(msg_type, eth_src, eth_dst, mid) + assert result, "No CMDU {} found".format(msg) + return result + + def check_cmdu_type_single( + self, msg: str, msg_type: int, eth_src: str, eth_dst: str = None, mid: int = None + ) -> sniffer.Packet: + '''Like check_cmdu_type, but also check that only a single CMDU is found.''' + debug("Checking for single CMDU {} (0x{:04x}) from {}".format(msg, msg_type, eth_src)) + cmdus = self.check_cmdu_type(msg, msg_type, eth_src, eth_dst, mid) + assert len(cmdus) == 1, "Multiple CMDUs {} found".format(msg) + return cmdus[0] + + def check_no_cmdu_type( + self, msg: str, msg_type: int, eth_src: str, eth_dst: str = None + ) -> NoReturn: + '''Like check_cmdu_type, but check that *no* machting CMDU is found.''' + debug("Checking for no CMDU {} (0x{:04x}) from {}".format(msg, msg_type, eth_src)) + result = self.dev.DUT.wired_sniffer.get_cmdu_capture_type(msg_type, eth_src, eth_dst) + if result: + for packet in result: + debug(" {}".format(packet)) + assert False, "Unexpected CMDU {}".format(msg) + + def check_cmdu_has_tlvs( + self, packet: sniffer.Packet, tlv_type: int + ) -> [sniffer.Tlv]: + '''Check that the packet has at least one TLV of the given type. + + Mark failure if no TLV of that type is found. + + Parameters + ---------- + packet: Union[sniffer.Packet] + The packet to verify. If it is empty or it is not an IEEE1905 + packet, an AssertionError is raised. + + tlv_type: int + The type of TLV to look for. + + Returns + ------- + [sniffer.Tlv] + List of TLVs of the requested type. An AssertionError is raised if + no TLV is found. + ''' + assert packet, "No packet found" + assert packet.ieee1905, "Packet is not IEEE1905: {}".format(packet) + tlvs = [tlv for tlv in packet.ieee1905_tlvs if tlv.tlv_type == tlv_type] + if not tlvs: + debug(" {}".format(packet)) + assert False, "No TLV of type 0x{:02x} found in packet".format(tlv_type) + return tlvs + + def check_cmdu_has_tlv_single( + self, packet: Union[sniffer.Packet, None], tlv_type: int + ) -> sniffer.Tlv: + '''Like check_cmdu_has_tlvs, but also check that only one TLV of that type is found.''' + tlvs = self.check_cmdu_has_tlvs(packet, tlv_type) + if len(tlvs) > 1: + debug(" {}".format(packet)) + assert False, "More than one ({}) TLVs of type 0x{:02x} found".format( + len(tlvs), tlv_type) + return tlvs[0] + + def check_cmdu_has_tlvs_exact( + self, packet: Union[sniffer.Packet, None], tlvs: [sniffer.Tlv] + ) -> NoReturn: + '''Check that the CMDU has exactly the TLVs given.''' + assert packet, "Packet not found" + assert packet.ieee1905, "Packet is not IEEE1905: {}".format(packet) + + packet_tlvs = list(packet.ieee1905_tlvs) + for t in tlvs: + if t in packet_tlvs: + packet_tlvs.remove(t) + else: + assert False, "Packet misses tlv:\n {}".format(str(t)) + + assert not packet_tlvs, "Packet has unexpected tlvs:\n {}".format( + "\n ".join(map(str, packet_tlvs))) diff --git a/tests/test_flows.py b/tests/test_flows.py index 35ad3c01cb..04ad153a05 100755 --- a/tests/test_flows.py +++ b/tests/test_flows.py @@ -122,6 +122,7 @@ def check_cmdu_type_single( self, msg: str, msg_type: int, eth_src: str, eth_dst: str = None, mid: int = None ) -> sniffer.Packet: '''Like check_cmdu_type, but also check that only a single CMDU is found.''' + debug("Checking for single CMDU {} (0x{:04x}) from {}".format(msg, msg_type, eth_src)) cmdus = self.check_cmdu_type(msg, msg_type, eth_src, eth_dst, mid) if not cmdus: assert False # Failure already reported by check_cmdu From 99eb2ee7593ea44a75bbe9a5963cb38cb72541e3 Mon Sep 17 00:00:00 2001 From: Sinan Akpolat Date: Mon, 20 Jul 2020 13:27:21 +0300 Subject: [PATCH 366/453] tests: boardfarm: Change device names with more suitable ones We can only choose from names provided by boardfarm in boardfarm/lib/DeviceManager.py. All the devices are in lan side of the gateway so I changed component names to 'lan' and 'lan2'. Previously we have chosen to use one of the APs as DUT but calling it 'controller' is confusing so that name is changed to 'agent'. https://jira.prplfoundation.org/browse/PPM-303 Signed-off-by: Sinan Akpolat --- .../boardfarm_prplmesh/prplmesh_config.json | 6 +++--- .../boardfarm_prplmesh/tests/ap_config_renew.py | 2 +- .../tests/client_association_link_metrics.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json index 2494116933..1613b432ac 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json @@ -1,12 +1,12 @@ { "prplmesh_docker": { - "name": "controller", + "name": "agent", "board_type": "prplmesh_docker", "role": "agent", "conn_cmd": "", "devices": [ { - "name": "wan", + "name": "lan", "type": "prplmesh_docker", "role": "controller", "conn_cmd": "" @@ -27,7 +27,7 @@ "conn_cmd": "cu -s 115200 -l /dev/ttyUSB0", "devices": [ { - "name": "wan", + "name": "lan", "type": "prplmesh_docker", "role": "controller", "docker_network": "prplMesh-net-rax40-1", diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/ap_config_renew.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/ap_config_renew.py index 5ce4d52ac6..e6d137701e 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/ap_config_renew.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/ap_config_renew.py @@ -16,7 +16,7 @@ class ApConfigRenew(PrplMeshBaseTest): def runTest(self): # Locate test participants agent = self.dev.DUT.agent_entity - controller = self.dev.wan.controller_entity + controller = self.dev.lan.controller_entity self.dev.DUT.wired_sniffer.start(self.__class__.__name__ + "-" + self.dev.DUT.name) # Regression test: MAC address should be case insensitive diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py index 78649ed9dd..cc29810f7b 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/client_association_link_metrics.py @@ -20,7 +20,7 @@ class ClientAssociationLinkMetrics(PrplMeshBaseTest): def runTest(self): # Locate test participants agent = self.dev.DUT.agent_entity - controller = self.dev.wan.controller_entity + controller = self.dev.lan.controller_entity sta = self.dev.wifi # Regression check From 9002889c9b36c9b53a965b0e599413848088094f Mon Sep 17 00:00:00 2001 From: Sinan Akpolat Date: Mon, 20 Jul 2020 04:18:40 +0300 Subject: [PATCH 367/453] tests: boardfarm: Make adjustments and move link metric query test I had to modify the test since boardfarm tests end when they fail. (As oppesed to test flows tests which can continue executing and aggregate mulitple failure reasons.) This test is skipped in RAX 40 setup since there is only one agent there. https://jira.prplfoundation.org/browse/PPM-303 Signed-off-by: Sinan Akpolat --- .../boardfarm_prplmesh/prplmesh_config.json | 6 ++ .../tests/link_metric_query.py | 102 ++++++++++++++++++ .../boardfarm_prplmesh/testsuites.cfg | 1 + 3 files changed, 109 insertions(+) create mode 100644 tests/boardfarm_plugins/boardfarm_prplmesh/tests/link_metric_query.py diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json index 1613b432ac..3d9d46f617 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config.json @@ -11,6 +11,12 @@ "role": "controller", "conn_cmd": "" }, + { + "name": "lan2", + "type": "prplmesh_docker", + "role": "agent", + "conn_cmd": "" + }, { "name": "wifi", "type": "STA_dummy", diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/tests/link_metric_query.py b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/link_metric_query.py new file mode 100644 index 0000000000..8dfd6730ff --- /dev/null +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/tests/link_metric_query.py @@ -0,0 +1,102 @@ +import time +from collections import Counter +from boardfarm.exceptions import SkipTest +from .prplmesh_base_test import PrplMeshBaseTest +from capi import tlv +from opts import debug + + +class LinkMetricQuery(PrplMeshBaseTest): + """Check if an agent can report the links it formed with other devices properly + + Devices used in test setup: + AP1 - Agent1 [DUT] + AP2 - Agent2 + GW - Controller + + Given: + Bi-directional link is formed between AP1 and GW + Bi-directional link is formed between AP2 and AP1 + When: + GW controller is instructed; "Link metric query" (0x0005) is sent for "All neighbors" (0) and + for "Both Tx and Rx link metrics" (2) from GW controller to AP1 agent + Then: + Agent must return a "Link metric response" (0x0006) which contains: + - A "1905 transmitter link metric" TLV with AP1's local interface MAC address + and GW's interface MAC address + - A "1905 receiver link metric" TLV with AP1's local interface MAC address + and GW's interface MAC address + - A "1905 transmitter link metric" TLV with AP1's local interface MAC address + and AP2's interface MAC address + - A "1905 receiver link metric" TLV with AP1's local interface MAC address + and AP2's interface MAC address + + Link's media type (ethernet, wifi), packet stats, RSSI (for wireless rx links) and phy rate + (for wireless tx links) are not checked in this test. + """ + def runTest(self): + # skip this test if one of the components does not exist in setup + try: + agent1 = self.dev.DUT.agent_entity + agent2 = self.dev.lan2.agent_entity + controller = self.dev.lan.controller_entity + except AttributeError as ae: + raise SkipTest(ae) + + sniffer = self.dev.DUT.wired_sniffer + sniffer.start(self.__class__.__name__ + "-" + self.dev.DUT.name) + + mid = controller.ucc_socket.dev_send_1905(agent1.mac, 0x0005, + tlv(0x08, 0x0002, "0x00 0x02")) + time.sleep(1) + + query = self.check_cmdu_type_single("link metric query", 0x0005, + controller.mac, agent1.mac, + mid) + query_tlv = self.check_cmdu_has_tlv_single(query, 0x08) + + debug("Checking query type and queried metrics are correct") + assert int(query_tlv.link_metric_query_type) == 0x00, "Query type is not 'All neighbors'" + assert int(query_tlv.link_metrics_requested) == 0x02, \ + "Metrics for both Tx and Rx is not requested" + + resp = self.check_cmdu_type_single("link metric response", 0x0006, + agent1.mac, controller.mac, + mid) + + debug("Checking response contains expected links to/from agent and nothing else") + # neighbor macs are based on the setup in "launch_environment_docker" method + expected_tx_link_neighbors = [controller.mac, agent2.mac] + expected_rx_link_neighbors = [controller.mac, agent2.mac] + actual_tx_links = self.check_cmdu_has_tlvs(resp, 0x09) + actual_rx_links = self.check_cmdu_has_tlvs(resp, 0x0a) + + def verify_links(links, expected_neighbors, link_type): + verified_neighbors = [] + unexpected_neighbors = [] + for link in links: + assert link.responder_mac_addr == agent1.mac, "Responder MAC address is wrong" + # a tshark (v3.2.4) bug causes "neighbor_mac_addr" field to + # show up as "responder_mac_addr_2" + if link.responder_mac_addr_2 in expected_neighbors: + verified_neighbors += [link.responder_mac_addr_2] + else: + unexpected_neighbors += [link.responder_mac_addr_2] + + # we expect each neighbor to appear only once + dup_links = [] + for neighbor, count in Counter(verified_neighbors).items(): + if count != 1: + dup_links.append((neighbor, count)) + assert not dup_links, \ + "Following {} links were expected to appear only once:\n".format(link_type)\ + + "\n".join(dup_links) + + # report any extra neighbors that show up + assert not unexpected_neighbors, \ + "{} links to following neighbors were not expected:\n".format(link_type)\ + + "\n".join(unexpected_neighbors) + + # check responder mac is our own mac, neighbor is one of the expected macs for each link + verify_links(actual_tx_links, expected_tx_link_neighbors, "tx") + verify_links(actual_rx_links, expected_rx_link_neighbors, "rx") diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/testsuites.cfg b/tests/boardfarm_plugins/boardfarm_prplmesh/testsuites.cfg index d441fb2640..68acac81ec 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/testsuites.cfg +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/testsuites.cfg @@ -7,3 +7,4 @@ InitialApConfig ApConfigRenew ClientAssociationLinkMetrics +LinkMetricQuery \ No newline at end of file From c10d4b798dce234b88b8da50595bb3a9d042061f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= Date: Mon, 27 Jul 2020 17:33:59 +0200 Subject: [PATCH 368/453] agent: ucc_listener: take the ssid into account when looking for "macaddr" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 96e22fbb6b698b2e80f72274510260a5e3a89a54 split the handling of "macaddr" and "bssid". In the "macaddr" case, the ruid (which correspond to the radio MAC) was returned unconditionally. However, there are some cases where the UCC asks for a "macaddr" by also specifying an "ssid". In those cases, we have to lookup the MAC address of the VAP with the matching ssid and return it (like we do in the "bssid" case). Move the code that gets the MAC/bssid to the get_mac_by_ssid() function and use it in the "bssid" case. In the "macaddr" case: if an "ssid" was given, use get_mac_by_ssid() to find and return the MAC of the VAP instead of returning the MAC of the radio. Fixes https://jira.prplfoundation.org/browse/PPM-317 MAP-4.2.1:netgear-rax40 Signed-off-by: Raphaël Mélotte --- agent/src/beerocks/slave/agent_db.cpp | 18 +++++++ agent/src/beerocks/slave/agent_db.h | 10 ++++ .../src/beerocks/slave/agent_ucc_listener.cpp | 51 +++++++++++-------- 3 files changed, 59 insertions(+), 20 deletions(-) diff --git a/agent/src/beerocks/slave/agent_db.cpp b/agent/src/beerocks/slave/agent_db.cpp index c675f44562..c8341c9b2a 100644 --- a/agent/src/beerocks/slave/agent_db.cpp +++ b/agent/src/beerocks/slave/agent_db.cpp @@ -96,4 +96,22 @@ void AgentDB::erase_client(const sMacAddr &client_mac, sMacAddr bssid) } } +bool AgentDB::get_mac_by_ssid(const sMacAddr &ruid, const std::string &ssid, sMacAddr &value) +{ + value = net::network_utils::ZERO_MAC; + auto radio = get_radio_by_mac(ruid, AgentDB::eMacType::RADIO); + if (!radio) { + LOG(ERROR) << "No radio with ruid '" << ruid << "' found!"; + return false; + } + + for (const auto &bssid : radio->front.bssids) { + if (bssid.ssid == ssid) { + value = bssid.mac; + return true; + } + } + return false; +} + } // namespace beerocks diff --git a/agent/src/beerocks/slave/agent_db.h b/agent/src/beerocks/slave/agent_db.h index b9a89d3baf..2544d13531 100644 --- a/agent/src/beerocks/slave/agent_db.h +++ b/agent/src/beerocks/slave/agent_db.h @@ -209,6 +209,16 @@ class AgentDB { */ void erase_client(const sMacAddr &client_mac, sMacAddr bssid = net::network_utils::ZERO_MAC); + /** + * @brief Get the MAC address (or bssid) of an AP based on the ruid and ssid. + * + * @param[in] ruid The Radio UID. + * @param[in] ssid The ssid of the AP. + * @param[out] value The mac address/bssid if found, else an invalid MAC (zero). + * @return true if the mac/bssid was found, false otherwise. + */ + bool get_mac_by_ssid(const sMacAddr &ruid, const std::string &ssid, sMacAddr &value); + /** * @brief 1905.1 Neighbor device information * Information gathered from a neighbor device upon reception of a Topology Discovery message. diff --git a/agent/src/beerocks/slave/agent_ucc_listener.cpp b/agent/src/beerocks/slave/agent_ucc_listener.cpp index bda7b31f21..6dbc52a352 100644 --- a/agent/src/beerocks/slave/agent_ucc_listener.cpp +++ b/agent/src/beerocks/slave/agent_ucc_listener.cpp @@ -93,7 +93,10 @@ void agent_ucc_listener::clear_configuration() bool agent_ucc_listener::handle_dev_get_param(std::unordered_map ¶ms, std::string &value) { - auto parameter = params["parameter"]; + auto parameter = params["parameter"]; + auto db = AgentDB::get(); + sMacAddr mac_value = net::network_utils::ZERO_MAC; + std::transform(parameter.begin(), parameter.end(), parameter.begin(), ::tolower); if (parameter == "alid") { value = m_bridge_mac; @@ -103,9 +106,23 @@ bool agent_ucc_listener::handle_dev_get_param(std::unordered_mapget_mac_by_ssid(ruid, ssid, mac_value)) { + LOG(ERROR) << " failed to find the MAC address for ruid '" << ruid_str << "'" + << " ssid '" << ssid << "'"; + value = "macaddr/bssid not found for ruid " + ruid_str + " ssid " + ssid; + return false; + } + value = tlvf::mac_to_string(mac_value); return true; } else if (parameter == "bssid") { if (params.find("ruid") == params.end()) { @@ -116,24 +133,18 @@ bool agent_ucc_listener::handle_dev_get_param(std::unordered_mapget_radio_by_mac(tlvf::mac_from_string(ruid), AgentDB::eMacType::RADIO); - if (!radio) { - value = "ruid " + ruid + " not found"; + auto ruid_str = tlvf::mac_to_string(std::strtoull(params["ruid"].c_str(), nullptr, 16)); + auto ruid = tlvf::mac_from_string(ruid_str); + auto ssid = params["ssid"]; + + if (!db->get_mac_by_ssid(ruid, ssid, mac_value)) { + LOG(ERROR) << " failed to find the BSSID for ruid '" << ruid_str << "'" + << " ssid '" << ssid << "'"; + value = "macaddr/bssid not found for ruid " + ruid_str + " ssid " + ssid; return false; } - - for (const auto &bssid : radio->front.bssids) { - if (bssid.ssid == ssid) { - value = tlvf::mac_to_string(bssid.mac); - return true; - } - } - value = "bssid not found for ruid " + ruid + " ssid " + ssid; - return false; + value = tlvf::mac_to_string(mac_value); + return true; } value = "parameter " + parameter + " not supported"; return false; From b80d3c7af47ff10992dfba67581685d9aaad11d5 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 23 Jul 2020 23:44:50 +0300 Subject: [PATCH 369/453] common: tlvf: Remove deprecated message Need to remove deprecated message ACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION https://jira.prplfoundation.org/browse/PPM-293 Signed-off-by: Vladyslav Tupikin --- .../tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml | 1 - .../tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml | 5 ----- 2 files changed, 6 deletions(-) diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index 72f27007a7..caefd1542e 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -40,7 +40,6 @@ eActionOp_CONTROL: ACTION_CONTROL_CHANGE_MODULE_LOGGING_LEVEL: 11 ACTION_CONTROL_ARP_QUERY_REQUEST: 12 ACTION_CONTROL_ARP_QUERY_RESPONSE: 13 - ACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION: 14 ACTION_CONTROL_BACKHAUL_ROAM_REQUEST: 30 ACTION_CONTROL_BACKHAUL_DL_RSSI_REPORT_NOTIFICATION: 31 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml index d28ed2ec24..b9f0779dc9 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml @@ -75,11 +75,6 @@ cACTION_CONTROL_ARP_QUERY_RESPONSE: _type: class params: sArpMonitorData -cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION: - _type: class - bridge_mac: sMacAddr - operational: uint8_t - cACTION_CONTROL_BACKHAUL_DL_RSSI_REPORT_NOTIFICATION: _type: class params: sBackhaulRssi From cae7bbf8ecfdfe4a074b55f86e0ff7400031dc5f Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 23 Jul 2020 23:57:32 +0300 Subject: [PATCH 370/453] common: tlvf: Remove deprecated autogenerated code https://jira.prplfoundation.org/browse/PPM-293 Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 1 - .../beerocks/tlvf/beerocks_message_control.h | 23 ------ .../tlvf/beerocks_message_control.cpp | 80 ------------------- 3 files changed, 104 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index 0b3ce67f31..c3cb2aa3c5 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -48,7 +48,6 @@ enum eActionOp_CONTROL: uint8_t { ACTION_CONTROL_CHANGE_MODULE_LOGGING_LEVEL = 0xb, ACTION_CONTROL_ARP_QUERY_REQUEST = 0xc, ACTION_CONTROL_ARP_QUERY_RESPONSE = 0xd, - ACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION = 0xe, ACTION_CONTROL_BACKHAUL_ROAM_REQUEST = 0x1e, ACTION_CONTROL_BACKHAUL_DL_RSSI_REPORT_NOTIFICATION = 0x1f, ACTION_CONTROL_BACKHAUL_RESET = 0x20, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h index e3458039c1..552891928b 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h @@ -265,29 +265,6 @@ class cACTION_CONTROL_ARP_QUERY_RESPONSE : public BaseClass sArpMonitorData* m_params = nullptr; }; -class cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION : public BaseClass -{ - public: - cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION(std::shared_ptr base, bool parse = false); - ~cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION(); - - static eActionOp_CONTROL get_action_op(){ - return (eActionOp_CONTROL)(ACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION); - } - sMacAddr& bridge_mac(); - uint8_t& operational(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CONTROL* m_action_op = nullptr; - sMacAddr* m_bridge_mac = nullptr; - uint8_t* m_operational = nullptr; -}; - class cACTION_CONTROL_BACKHAUL_DL_RSSI_REPORT_NOTIFICATION : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp index 47fd726f6e..032b9f8c11 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp @@ -919,86 +919,6 @@ bool cACTION_CONTROL_ARP_QUERY_RESPONSE::init() return true; } -cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION::cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION::cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION::~cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION() { -} -sMacAddr& cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION::bridge_mac() { - return (sMacAddr&)(*m_bridge_mac); -} - -uint8_t& cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION::operational() { - return (uint8_t&)(*m_operational); -} - -void cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CONTROL), reinterpret_cast(m_action_op)); - m_bridge_mac->struct_swap(); -} - -bool cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sMacAddr); // bridge_mac - class_size += sizeof(uint8_t); // operational - return class_size; -} - -bool cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_bridge_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_bridge_mac->struct_init(); } - m_operational = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; - return false; - } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_CONTROL_BACKHAUL_DL_RSSI_REPORT_NOTIFICATION::cACTION_CONTROL_BACKHAUL_DL_RSSI_REPORT_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); From 556824901974c8f9a8db3efd230865f90b464b3c Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 24 Jul 2020 00:02:31 +0300 Subject: [PATCH 371/453] agent: son_slave: Remove case for deprecated message Need to remove case for deprecated VS message ACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION from VS message handler. https://jira.prplfoundation.org/browse/PPM-293 Signed-off-by: Vladyslav Tupikin --- agent/src/beerocks/slave/son_slave_thread.cpp | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index dd056123ee..5ff8b3a21d 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -2345,46 +2345,6 @@ bool slave_thread::handle_cmdu_monitor_message(Socket *sd, } break; } - case beerocks_message::ACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION: { - auto notification_in = - beerocks_header - ->addClass(); - if (notification_in == nullptr) { - LOG(ERROR) << "addClass cACTION_APMANAGER_HOSTAP_STATUS_CHANGED_NOTIFICATION failed"; - return false; - } - std::stringstream print_str; - if (notification_in->new_tx_state() != -1) { - print_str << " new tx state: " - << std::string(notification_in->new_tx_state() ? "on" : "off"); - } - if (notification_in->new_hostap_enabled_state() != -1) { - print_str << " | new hostap_enabled state: " - << std::string(notification_in->new_hostap_enabled_state() ? "on" : "off"); - } - LOG(INFO) << "ACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION" << print_str.str(); - - bool agent_operational = false; - if (slave_state == STATE_OPERATIONAL && notification_in->new_tx_state() == 1 && - notification_in->new_hostap_enabled_state() == 1) { - slave_resets_counter = 0; - agent_operational = true; - } - - auto notification_out = message_com::create_vs_message< - beerocks_message::cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION>(cmdu_tx); - if (notification_out == nullptr) { - LOG(ERROR) << "Failed building message!"; - return false; - } - auto db = AgentDB::get(); - - notification_out->operational() = agent_operational; - notification_out->bridge_mac() = db->bridge.mac; - send_cmdu_to_controller(cmdu_tx); - - break; - } case beerocks_message::ACTION_MONITOR_CLIENT_START_MONITORING_RESPONSE: { auto response_in = beerocks_header From fe5aaed491bc489b9ec2c4ab73efe7df32fb5f2d Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 24 Jul 2020 00:03:32 +0300 Subject: [PATCH 372/453] controller: son_master: Remove deprecated case from handler Need to remove case for deprecated message ACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION from handler https://jira.prplfoundation.org/browse/PPM-293 Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/master/son_master_thread.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/controller/src/beerocks/master/son_master_thread.cpp b/controller/src/beerocks/master/son_master_thread.cpp index 2d5f3d4933..78497fe9f4 100644 --- a/controller/src/beerocks/master/son_master_thread.cpp +++ b/controller/src/beerocks/master/son_master_thread.cpp @@ -2830,21 +2830,6 @@ bool master_thread::handle_cmdu_control_message(const std::string &src_mac, break; } - case beerocks_message::ACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION: { - auto notification = - beerocks_header - ->addClass(); - if (notification == nullptr) { - LOG(ERROR) << "addClass cACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION failed"; - return false; - } - auto bridge_mac = tlvf::mac_to_string(notification->bridge_mac()); - - LOG(TRACE) << "ACTION_CONTROL_PLATFORM_OPERATIONAL_NOTIFICATION: " << bridge_mac - << ", new_operational_state=" << int(notification->operational()); - database.set_node_operational_state(bridge_mac, notification->operational()); - break; - } case beerocks_message::ACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_START_NOTIFICATION: { auto notification = beerocks_header->addClass< beerocks_message::cACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_START_NOTIFICATION>(); From 798e071f3e6aa7a1be9b4a0cc050715f2b3e4540 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 24 Jul 2020 10:25:44 +0300 Subject: [PATCH 373/453] common: tlvf: Remove deprecated message Need to remove deprecated message ACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION Also need to remove all autogenerated code. https://jira.prplfoundation.org/browse/PPM-293 Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 1 - .../beerocks/tlvf/beerocks_message_monitor.h | 23 ------ .../tlvf/beerocks_message_monitor.cpp | 78 ------------------- .../tlvf/beerocks_message_action.yaml | 1 - .../tlvf/beerocks_message_monitor.yaml | 5 -- 5 files changed, 108 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index c3cb2aa3c5..5e4ac104d9 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -243,7 +243,6 @@ enum eActionOp_MONITOR: uint8_t { ACTION_MONITOR_HOSTAP_STATS_MEASUREMENT_RESPONSE = 0x33, ACTION_MONITOR_HOSTAP_LOAD_MEASUREMENT_NOTIFICATION = 0x34, ACTION_MONITOR_HOSTAP_ACTIVITY_NOTIFICATION = 0x35, - ACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION = 0x36, ACTION_MONITOR_CHANNEL_SCAN_TRIGGER_SCAN_REQUEST = 0x3c, ACTION_MONITOR_CHANNEL_SCAN_TRIGGER_SCAN_RESPONSE = 0x3d, ACTION_MONITOR_CHANNEL_SCAN_TRIGGERED_NOTIFICATION = 0x3e, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_monitor.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_monitor.h index ffb5bba71d..b2af821018 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_monitor.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_monitor.h @@ -476,29 +476,6 @@ class cACTION_MONITOR_HOSTAP_STATS_MEASUREMENT_REQUEST : public BaseClass uint8_t* m_sync = nullptr; }; -class cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION : public BaseClass -{ - public: - cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION(std::shared_ptr base, bool parse = false); - ~cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION(); - - static eActionOp_MONITOR get_action_op(){ - return (eActionOp_MONITOR)(ACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION); - } - int8_t& new_tx_state(); - int8_t& new_hostap_enabled_state(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_MONITOR* m_action_op = nullptr; - int8_t* m_new_tx_state = nullptr; - int8_t* m_new_hostap_enabled_state = nullptr; -}; - class cACTION_MONITOR_HOSTAP_STATS_MEASUREMENT_RESPONSE : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_monitor.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_monitor.cpp index c6a912e351..20700c608a 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_monitor.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_monitor.cpp @@ -1549,84 +1549,6 @@ bool cACTION_MONITOR_HOSTAP_STATS_MEASUREMENT_REQUEST::init() return true; } -cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION::cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION::cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION::~cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION() { -} -int8_t& cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION::new_tx_state() { - return (int8_t&)(*m_new_tx_state); -} - -int8_t& cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION::new_hostap_enabled_state() { - return (int8_t&)(*m_new_hostap_enabled_state); -} - -void cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_MONITOR), reinterpret_cast(m_action_op)); -} - -bool cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(int8_t); // new_tx_state - class_size += sizeof(int8_t); // new_hostap_enabled_state - return class_size; -} - -bool cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_new_tx_state = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(int8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(int8_t) << ") Failed!"; - return false; - } - m_new_hostap_enabled_state = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(int8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(int8_t) << ") Failed!"; - return false; - } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_MONITOR_HOSTAP_STATS_MEASUREMENT_RESPONSE::cACTION_MONITOR_HOSTAP_STATS_MEASUREMENT_RESPONSE(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index caefd1542e..52b5f58893 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -276,7 +276,6 @@ eActionOp_MONITOR: ACTION_MONITOR_HOSTAP_STATS_MEASUREMENT_RESPONSE: 51 ACTION_MONITOR_HOSTAP_LOAD_MEASUREMENT_NOTIFICATION: 52 ACTION_MONITOR_HOSTAP_ACTIVITY_NOTIFICATION: 53 - ACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION: 54 ACTION_MONITOR_CHANNEL_SCAN_TRIGGER_SCAN_REQUEST: 60 ACTION_MONITOR_CHANNEL_SCAN_TRIGGER_SCAN_RESPONSE: 61 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml index 8161ba8a33..51d4646b6f 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml @@ -111,11 +111,6 @@ cACTION_MONITOR_HOSTAP_STATS_MEASUREMENT_REQUEST: _type: class sync: uint8_t -cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION: - _type: class - new_tx_state: int8_t - new_hostap_enabled_state: int8_t - cACTION_MONITOR_HOSTAP_STATS_MEASUREMENT_RESPONSE: _type: class ap_stats_size: From 26ae9da1e66314ff3cbf315655061738ab7a8061 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 24 Jul 2020 15:27:39 +0300 Subject: [PATCH 374/453] agent: monitor_thread: Remove deprecated code Need to remove deprecated code for creation vendor-specific message ACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION Also need to remove unused variables. https://jira.prplfoundation.org/browse/PPM-293 Signed-off-by: Vladyslav Tupikin --- .../monitor/monitor_thread.cpp | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp index 97ce4a85b4..a060e88f1d 100644 --- a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp +++ b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp @@ -487,14 +487,11 @@ void monitor_thread::after_select(bool timeout) } } - int8_t new_tx_state = mon_wlan_hal->get_radio_info().tx_enabled; - int8_t new_hostap_enabled_state = mon_wlan_hal->get_radio_info().wifi_ctrl_enabled; - bool tx_state_changed = false; - bool hostap_enabled_state_changed = false; + int8_t new_tx_state = mon_wlan_hal->get_radio_info().tx_enabled; + int8_t new_hostap_enabled_state = mon_wlan_hal->get_radio_info().wifi_ctrl_enabled; if (mon_db.get_ap_tx_enabled() != new_tx_state) { // tx was changed mon_db.set_ap_tx_enabled(new_tx_state); - tx_state_changed = true; } if (mon_db.get_hostapd_enabled() != @@ -503,21 +500,6 @@ void monitor_thread::after_select(bool timeout) LOG(DEBUG) << "wifi_ctrl_enabled=2 on already attached to Hostapd"; } mon_db.set_hostapd_enabled(new_hostap_enabled_state); - hostap_enabled_state_changed = true; - } - - if (tx_state_changed || hostap_enabled_state_changed) { - // LOG(DEBUG) << "wifi_ctrl_enabled=" << int(new_hostap_enabled_state) << ", tx_enabled=" << int(new_tx_state); - - auto notification = message_com::create_vs_message< - beerocks_message::cACTION_MONITOR_HOSTAP_STATUS_CHANGED_NOTIFICATION>(cmdu_tx); - if (notification == nullptr) { - LOG(ERROR) << "Failed building message!"; - return; - } - notification->new_tx_state() = new_tx_state; - notification->new_hostap_enabled_state() = new_hostap_enabled_state; - message_com::send_cmdu(slave_socket, cmdu_tx); } } From 3c0ce8b1250563fcca6754fb7af132627c58813f Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 15 Jul 2020 15:25:15 +0300 Subject: [PATCH 375/453] controller: cli: Remove unused cli commands Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/cli/beerocks_cli_socket.cpp | 66 ------------------- .../src/beerocks/cli/beerocks_cli_socket.h | 8 --- 2 files changed, 74 deletions(-) diff --git a/controller/src/beerocks/cli/beerocks_cli_socket.cpp b/controller/src/beerocks/cli/beerocks_cli_socket.cpp index 6d1af6c847..298cd0ac99 100644 --- a/controller/src/beerocks/cli/beerocks_cli_socket.cpp +++ b/controller/src/beerocks/cli/beerocks_cli_socket.cpp @@ -178,16 +178,6 @@ void cli_socket::setFunctionsMapAndArray() "remove 'bssid' from 11k neighbor list of 'hostap_mac' 'vap_id'", static_cast(&cli_socket::rm_neighbor_11k_caller), 3, 3, STRING_ARG, STRING_ARG); - insertCommandToMap("ping_slave", " [] []", - "send ping request to slave mac, num_of_req times (1 time by default), with " - "size = 'packet_size' (0 by default) ", - static_cast(&cli_socket::ping_slave_caller), 1, 3, STRING_ARG, - INT_ARG, INT_ARG); - insertCommandToMap("ping_all_slaves", "[] []", - "send ping request to all slaves, num_of_req times each (1 time by " - "default), with size = 'packet_size' (0 by default) ", - static_cast(&cli_socket::ping_all_slaves_caller), 0, 2, INT_ARG, - INT_ARG); } bool cli_socket::waitResponseReady() @@ -462,28 +452,6 @@ int cli_socket::rm_neighbor_11k_caller(int numOfArgs) return -1; } -int cli_socket::ping_slave_caller(int numOfArgs) -{ - if (numOfArgs < 0) - return -1; - else if (numOfArgs == 3) - return ping_slave(args.stringArgs[0], args.intArgs[1], args.intArgs[2]); - else if (numOfArgs == 2) - return ping_slave(args.stringArgs[0], args.intArgs[1]); - return ping_slave(args.stringArgs[0]); -} - -int cli_socket::ping_all_slaves_caller(int numOfArgs) -{ - if (numOfArgs < 0) - return -1; - else if (numOfArgs == 2) - return ping_all_slaves(args.intArgs[0], args.intArgs[1]); - else if (numOfArgs == 1) - return ping_all_slaves(args.intArgs[0]); - return ping_all_slaves(); -} - // // Functions // @@ -831,38 +799,4 @@ int cli_socket::rm_neighbor_11k(std::string ap_mac, std::string bssid, int8_t va return 0; } -int cli_socket::ping_slave(std::string ire_mac, int num_of_req, int ping_size) -{ - auto request = - message_com::create_vs_message(cmdu_tx); - if (request == nullptr) { - LOG(ERROR) << "Failed building cACTION_CLI_PING_SLAVE_REQUEST message!"; - return -1; - } - request->mac() = tlvf::mac_from_string(ire_mac); - request->num_of_req() = (uint16_t)num_of_req; - request->size() = (uint16_t)ping_size; - - message_com::send_cmdu(master_socket, cmdu_tx); - - return 0; -} - -int cli_socket::ping_all_slaves(int num_of_req, int ping_size) -{ - auto request = - message_com::create_vs_message( - cmdu_tx); - if (request == nullptr) { - LOG(ERROR) << "Failed building cACTION_CLI_PING_ALL_SLAVES_REQUEST message!"; - return -1; - } - request->num_of_req() = (uint16_t)num_of_req; - request->size() = (uint16_t)ping_size; - - message_com::send_cmdu(master_socket, cmdu_tx); - - return 0; -} - } // namespace beerocks diff --git a/controller/src/beerocks/cli/beerocks_cli_socket.h b/controller/src/beerocks/cli/beerocks_cli_socket.h index edd24b09e4..239205d6b7 100644 --- a/controller/src/beerocks/cli/beerocks_cli_socket.h +++ b/controller/src/beerocks/cli/beerocks_cli_socket.h @@ -73,10 +73,6 @@ class cli_socket : public socket_thread, public cli { int ire_network_optimization_task_caller(int numOfArgs); - int ping_slave_caller(int numOfArgs); - - int ping_all_slaves_caller(int numOfArgs); - int rm_neighbor_11k_caller(int numOfArgs); int set_neighbor_11k_caller(int numOfArgs); @@ -120,10 +116,6 @@ class cli_socket : public socket_thread, public cli { int ire_network_optimization_task(); - int ping_slave(std::string ire_mac, int num_of_req = 1, int ping_size = 0); - - int ping_all_slaves(int num_of_req = 1, int ping_size = 0); - int rm_neighbor_11k(std::string ap_mac, std::string bssid, int8_t vap_id); int set_neighbor_11k(std::string ap_mac, std::string bssid, uint8_t channel, int8_t vap_id); From bd422c901c2548852b302b1d8baee39a8d126543 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 30 Jul 2020 01:08:34 +0300 Subject: [PATCH 376/453] common: tlvf: Remove useless messages Need to remove unused messages: ACTION_CLI_PING_SLAVE_REQUEST ACTION_CLI_PING_ALL_SLAVES_REQUEST Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 2 - .../beerocks/tlvf/beerocks_message_cli.h | 48 ----- .../beerocks/tlvf/beerocks_message_cli.cpp | 172 ------------------ .../tlvf/beerocks_message_action.yaml | 2 - .../beerocks/tlvf/beerocks_message_cli.yaml | 11 -- 5 files changed, 235 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index 5e4ac104d9..bc8172cd43 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -275,8 +275,6 @@ enum eActionOp_CLI: uint8_t { ACTION_CLI_IRE_NETWORK_OPTIMIZATION_TASK = 0x23, ACTION_CLI_BACKHAUL_SCAN_RESULTS = 0x24, ACTION_CLI_BACKHAUL_ROAM_REQUEST = 0x25, - ACTION_CLI_PING_SLAVE_REQUEST = 0x26, - ACTION_CLI_PING_ALL_SLAVES_REQUEST = 0x27, ACTION_CLI_CLIENT_ALLOW_REQUEST = 0x50, ACTION_CLI_CLIENT_DISALLOW_REQUEST = 0x51, ACTION_CLI_CLIENT_DISCONNECT_REQUEST = 0x52, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h index 377c8ec4a3..96b30978de 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h @@ -270,54 +270,6 @@ class cACTION_CLI_DUMP_NODE_INFO : public BaseClass sMacAddr* m_mac = nullptr; }; -class cACTION_CLI_PING_SLAVE_REQUEST : public BaseClass -{ - public: - cACTION_CLI_PING_SLAVE_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CLI_PING_SLAVE_REQUEST(std::shared_ptr base, bool parse = false); - ~cACTION_CLI_PING_SLAVE_REQUEST(); - - static eActionOp_CLI get_action_op(){ - return (eActionOp_CLI)(ACTION_CLI_PING_SLAVE_REQUEST); - } - sMacAddr& mac(); - uint16_t& num_of_req(); - uint16_t& size(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CLI* m_action_op = nullptr; - sMacAddr* m_mac = nullptr; - uint16_t* m_num_of_req = nullptr; - uint16_t* m_size = nullptr; -}; - -class cACTION_CLI_PING_ALL_SLAVES_REQUEST : public BaseClass -{ - public: - cACTION_CLI_PING_ALL_SLAVES_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CLI_PING_ALL_SLAVES_REQUEST(std::shared_ptr base, bool parse = false); - ~cACTION_CLI_PING_ALL_SLAVES_REQUEST(); - - static eActionOp_CLI get_action_op(){ - return (eActionOp_CLI)(ACTION_CLI_PING_ALL_SLAVES_REQUEST); - } - uint16_t& num_of_req(); - uint16_t& size(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CLI* m_action_op = nullptr; - uint16_t* m_num_of_req = nullptr; - uint16_t* m_size = nullptr; -}; - class cACTION_CLI_BACKHAUL_SCAN_RESULTS : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp index aae9565908..3a5da025a1 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp @@ -856,178 +856,6 @@ bool cACTION_CLI_DUMP_NODE_INFO::init() return true; } -cACTION_CLI_PING_SLAVE_REQUEST::cACTION_CLI_PING_SLAVE_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CLI_PING_SLAVE_REQUEST::cACTION_CLI_PING_SLAVE_REQUEST(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CLI_PING_SLAVE_REQUEST::~cACTION_CLI_PING_SLAVE_REQUEST() { -} -sMacAddr& cACTION_CLI_PING_SLAVE_REQUEST::mac() { - return (sMacAddr&)(*m_mac); -} - -uint16_t& cACTION_CLI_PING_SLAVE_REQUEST::num_of_req() { - return (uint16_t&)(*m_num_of_req); -} - -uint16_t& cACTION_CLI_PING_SLAVE_REQUEST::size() { - return (uint16_t&)(*m_size); -} - -void cACTION_CLI_PING_SLAVE_REQUEST::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CLI), reinterpret_cast(m_action_op)); - m_mac->struct_swap(); - tlvf_swap(16, reinterpret_cast(m_num_of_req)); - tlvf_swap(16, reinterpret_cast(m_size)); -} - -bool cACTION_CLI_PING_SLAVE_REQUEST::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CLI_PING_SLAVE_REQUEST::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sMacAddr); // mac - class_size += sizeof(uint16_t); // num_of_req - class_size += sizeof(uint16_t); // size - return class_size; -} - -bool cACTION_CLI_PING_SLAVE_REQUEST::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_mac->struct_init(); } - m_num_of_req = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_size = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - if (m_parse__) { class_swap(); } - return true; -} - -cACTION_CLI_PING_ALL_SLAVES_REQUEST::cACTION_CLI_PING_ALL_SLAVES_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CLI_PING_ALL_SLAVES_REQUEST::cACTION_CLI_PING_ALL_SLAVES_REQUEST(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CLI_PING_ALL_SLAVES_REQUEST::~cACTION_CLI_PING_ALL_SLAVES_REQUEST() { -} -uint16_t& cACTION_CLI_PING_ALL_SLAVES_REQUEST::num_of_req() { - return (uint16_t&)(*m_num_of_req); -} - -uint16_t& cACTION_CLI_PING_ALL_SLAVES_REQUEST::size() { - return (uint16_t&)(*m_size); -} - -void cACTION_CLI_PING_ALL_SLAVES_REQUEST::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CLI), reinterpret_cast(m_action_op)); - tlvf_swap(16, reinterpret_cast(m_num_of_req)); - tlvf_swap(16, reinterpret_cast(m_size)); -} - -bool cACTION_CLI_PING_ALL_SLAVES_REQUEST::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CLI_PING_ALL_SLAVES_REQUEST::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(uint16_t); // num_of_req - class_size += sizeof(uint16_t); // size - return class_size; -} - -bool cACTION_CLI_PING_ALL_SLAVES_REQUEST::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_num_of_req = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_size = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_CLI_BACKHAUL_SCAN_RESULTS::cACTION_CLI_BACKHAUL_SCAN_RESULTS(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index 52b5f58893..ad46204e87 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -316,8 +316,6 @@ eActionOp_CLI: ACTION_CLI_IRE_NETWORK_OPTIMIZATION_TASK: 35 ACTION_CLI_BACKHAUL_SCAN_RESULTS: 36 ACTION_CLI_BACKHAUL_ROAM_REQUEST: 37 - ACTION_CLI_PING_SLAVE_REQUEST: 38 - ACTION_CLI_PING_ALL_SLAVES_REQUEST: 39 ACTION_CLI_CLIENT_ALLOW_REQUEST: 80 ACTION_CLI_CLIENT_DISALLOW_REQUEST: 81 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml index 60f7922de4..4fa054b1ca 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml @@ -69,17 +69,6 @@ cACTION_CLI_DUMP_NODE_INFO: _type: class mac: sMacAddr -cACTION_CLI_PING_SLAVE_REQUEST: - _type: class - mac: sMacAddr - num_of_req: uint16_t - size: uint16_t - -cACTION_CLI_PING_ALL_SLAVES_REQUEST: - _type: class - num_of_req: uint16_t - size: uint16_t - cACTION_CLI_BACKHAUL_SCAN_RESULTS: _type: class mac: sMacAddr From e21f21c46cc56eaa024f2766030c1da9f8a5d78c Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 15 Jul 2020 14:45:50 +0300 Subject: [PATCH 377/453] controller: son_master: Remove unused code Need to remove all related code for messages: ACTION_CONTROL_CONTROLLER_PING_REQUEST ACTION_CONTROL_CONTROLLER_PING_RESPONSE Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/master/son_master_thread.cpp | 63 ------------------- 1 file changed, 63 deletions(-) diff --git a/controller/src/beerocks/master/son_master_thread.cpp b/controller/src/beerocks/master/son_master_thread.cpp index 78497fe9f4..69a477d5f3 100644 --- a/controller/src/beerocks/master/son_master_thread.cpp +++ b/controller/src/beerocks/master/son_master_thread.cpp @@ -2948,69 +2948,6 @@ bool master_thread::handle_cmdu_control_message(const std::string &src_mac, } break; } - case beerocks_message::ACTION_CONTROL_CONTROLLER_PING_RESPONSE: { - if (hostap_mac.empty()) { - LOG(ERROR) << "PING_MSG_RESPONSE unknown peer mac!"; - } else { - auto response = - beerocks_header - ->addClass(); - if (response == nullptr) { - LOG(ERROR) << "addClass cACTION_CONTROL_CONTROLLER_PING_RESPONSE failed"; - return false; - } - if (!database.update_node_last_ping_received(hostap_mac, response->seq())) { - LOG(DEBUG) << "PING_MSG_RESPONSE received from slave " << hostap_mac - << " , can't update last seen time for "; - } else { - LOG_CLI(DEBUG, - "PING_MSG_RESPONSE received from slave = " - << hostap_mac << " , seq = " << (int)response->seq() - << " , size = " << (int)response->size() << " , RTT = " - << float((std::chrono::duration_cast>( - database.get_node_last_ping_received(hostap_mac) - - database.get_node_last_ping_sent(hostap_mac))) - .count()) - << "[sec]" << std::endl); - } - if (response->seq() < (response->total() - 1)) { //send next ping request - auto request = message_com::create_vs_message< - beerocks_message::cACTION_CONTROL_CONTROLLER_PING_REQUEST>(cmdu_tx); - if (request == nullptr) { - LOG(ERROR) << "Failed building message!"; - return false; - } - request->total() = response->total(); - request->seq() = response->seq() + 1; - request->size() = response->size(); - if (!request->alloc_data(response->size())) { - LOG(ERROR) << "Failed buffer allocation to size=" << int(response->size()); - break; - } - memset(request->data(), 0, request->data_length()); - if (!database.update_node_last_ping_sent(hostap_mac)) { - LOG(DEBUG) << "sending PING_MSG_REQUEST for slave " << hostap_mac - << " , can't update last ping sent time for "; - } - son_actions::send_cmdu_to_agent(src_mac, cmdu_tx, database, hostap_mac); - } else if (response->seq() == (response->total() - 1)) { - if (!database.update_node_last_ping_received_avg(hostap_mac, response->total())) { - LOG(DEBUG) << "last PING_MSG_RESPONSE received from slave " << hostap_mac - << " , can't update last ping received avg "; - } else { - LOG_CLI(DEBUG, "last PING_MSG_RESPONSE received from slave = " - << hostap_mac << " RTT summary: " << std::endl - << "min = " << database.get_node_last_ping_min_ms(hostap_mac) - << " [ms], " - << "max = " << database.get_node_last_ping_max_ms(hostap_mac) - << " [ms], " - << "avg = " << database.get_node_last_ping_avg_ms(hostap_mac) - << " [ms]" << std::endl); - } - } - } - break; - } case beerocks_message::ACTION_CONTROL_CLIENT_NO_RESPONSE_NOTIFICATION: { auto notification = beerocks_header From 9eb70bc8b032dbc66adbf4c878df8db0404cd35e Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Fri, 17 Jul 2020 17:52:00 +0300 Subject: [PATCH 378/453] controller: db: Remove deprecated update_node_last_ping_sent() Need to remove deprecated method update_node_last_ping_sent() from db source code. Signed-off-by: Vladyslav Tupikin --- controller/src/beerocks/master/db/db.cpp | 112 ----------------------- controller/src/beerocks/master/db/db.h | 10 -- controller/src/beerocks/master/db/node.h | 8 -- 3 files changed, 130 deletions(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index e9ac8bc703..39fab4c7d4 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -581,17 +581,6 @@ bool db::update_node_last_seen(const std::string &mac) return true; } -bool db::update_node_last_ping_sent(const std::string &mac) -{ - auto n = get_node(mac); - if (!n) { - LOG(WARNING) << __FUNCTION__ << " - node " << mac << " does not exist!"; - return false; - } - n->last_ping_sent = std::chrono::steady_clock::now(); - return true; -} - std::chrono::steady_clock::time_point db::get_node_last_seen(const std::string &mac) { auto n = get_node(mac); @@ -603,107 +592,6 @@ std::chrono::steady_clock::time_point db::get_node_last_seen(const std::string & return n->last_seen; } -std::chrono::steady_clock::time_point db::get_node_last_ping_sent(const std::string &mac) -{ - auto n = get_node(mac); - if (!n) { - LOG(WARNING) << __FUNCTION__ << " - node " << mac << " does not exist!"; - return std::chrono::steady_clock::now(); - } - return n->last_ping_sent; -} - -bool db::update_node_last_ping_received(const std::string &mac, int seq) -{ - auto n = get_node(mac); - if (!n) { - LOG(WARNING) << __FUNCTION__ << " - node " << mac << " does not exist!"; - return false; - } - n->last_ping_received = std::chrono::steady_clock::now(); - n->last_seen = n->last_ping_received; - - n->last_ping_delta_ms = - (double)((std::chrono::duration_cast>( - get_node_last_ping_received(mac) - get_node_last_ping_sent(mac))) - .count()) * - 1000; - if (n->last_ping_delta_ms < n->last_ping_min_ms || (seq == 0)) { - n->last_ping_min_ms = n->last_ping_delta_ms; - } - if (n->last_ping_delta_ms > n->last_ping_max_ms || (seq == 0)) { - n->last_ping_max_ms = n->last_ping_delta_ms; - } - if (seq == 0) { - n->last_ping_avg_ms_acc = n->last_ping_delta_ms; - } else { - n->last_ping_avg_ms_acc += n->last_ping_delta_ms; - } - - return true; -} - -bool db::update_node_last_ping_received_avg(const std::string &mac, int total_seq) -{ - auto n = get_node(mac); - if (!n) { - LOG(WARNING) << __FUNCTION__ << " - node " << mac << " does not exist!"; - return false; - } - n->last_ping_avg_ms = n->last_ping_avg_ms_acc / total_seq; - return true; -} - -std::chrono::steady_clock::time_point db::get_node_last_ping_received(const std::string &mac) -{ - auto n = get_node(mac); - if (!n) { - LOG(WARNING) << __FUNCTION__ << " - node " << mac << " does not exist!"; - return std::chrono::steady_clock::now(); - } - return n->last_ping_received; -} - -int db::get_node_last_ping_delta_ms(const std::string &mac) -{ - auto n = get_node(mac); - if (!n) { - LOG(WARNING) << __FUNCTION__ << " - node " << mac << " does not exist!"; - return -1; - } - return n->last_ping_delta_ms; -} - -int db::get_node_last_ping_min_ms(const std::string &mac) -{ - auto n = get_node(mac); - if (!n) { - LOG(WARNING) << __FUNCTION__ << " - node " << mac << " does not exist!"; - return -1; - } - return n->last_ping_min_ms; -} - -int db::get_node_last_ping_max_ms(const std::string &mac) -{ - auto n = get_node(mac); - if (!n) { - LOG(WARNING) << __FUNCTION__ << " - node " << mac << " does not exist!"; - return -1; - } - return n->last_ping_max_ms; -} - -int db::get_node_last_ping_avg_ms(const std::string &mac) -{ - auto n = get_node(mac); - if (!n) { - LOG(WARNING) << __FUNCTION__ << " - node " << mac << " does not exist!"; - return -1; - } - return n->last_ping_avg_ms; -} - std::unordered_map> & db::get_link_metric_data_map() { diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index 16a35b0733..35b212a91d 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -272,17 +272,7 @@ class db { bool update_node_last_seen(const std::string &mac); - bool update_node_last_ping_sent(const std::string &mac); std::chrono::steady_clock::time_point get_node_last_seen(const std::string &mac); - std::chrono::steady_clock::time_point get_node_last_ping_sent(const std::string &mac); - - bool update_node_last_ping_received(const std::string &mac, int seq); - bool update_node_last_ping_received_avg(const std::string &mac, int total_seq); - std::chrono::steady_clock::time_point get_node_last_ping_received(const std::string &mac); - int get_node_last_ping_delta_ms(const std::string &mac); - int get_node_last_ping_min_ms(const std::string &mac); - int get_node_last_ping_max_ms(const std::string &mac); - int get_node_last_ping_avg_ms(const std::string &mac); bool set_hostap_active(const std::string &mac, bool active); bool is_hostap_active(const std::string &mac); diff --git a/controller/src/beerocks/master/db/node.h b/controller/src/beerocks/master/db/node.h index 99838dce25..89043fd78d 100644 --- a/controller/src/beerocks/master/db/node.h +++ b/controller/src/beerocks/master/db/node.h @@ -263,14 +263,6 @@ class node { beerocks::eBandType band_type = beerocks::eBandType::INVALID_BAND; beerocks::eIfaceType iface_type = beerocks::IFACE_TYPE_ETHERNET; std::chrono::steady_clock::time_point last_seen; - std::chrono::steady_clock::time_point last_ping_sent; - std::chrono::steady_clock::time_point last_ping_received; - - int last_ping_delta_ms = 0; - int last_ping_min_ms = 0; - int last_ping_max_ms = 0; - int last_ping_avg_ms_acc = 0; - int last_ping_avg_ms = 0; friend std::ostream &operator<<(std::ostream &os, const node &node); friend std::ostream &operator<<(std::ostream &os, const node *node); From f4ed1fa29d84b93acc8eb942e92c3e74b68a4361 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 15 Jul 2020 14:44:10 +0300 Subject: [PATCH 379/453] controller: son_management: Remove unused code Need to remove all related code for messages: ACTION_CONTROL_CONTROLLER_PING_REQUEST ACTION_CONTROL_CONTROLLER_PING_RESPONSE Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/master/son_management.cpp | 105 ------------------ 1 file changed, 105 deletions(-) diff --git a/controller/src/beerocks/master/son_management.cpp b/controller/src/beerocks/master/son_management.cpp index 6bc32ec1e8..9372c9cc5c 100644 --- a/controller/src/beerocks/master/son_management.cpp +++ b/controller/src/beerocks/master/son_management.cpp @@ -83,111 +83,6 @@ void son_management::handle_cli_message(Socket *sd, //LOG(DEBUG) << "NEW CLI action=" << int(header->action()) << " action_op=" << int(header->action_op()); switch (beerocks_header->action_op()) { - - case beerocks_message::ACTION_CLI_PING_SLAVE_REQUEST: { - LOG(DEBUG) << "PING_SLAVE_REQUEST from CLI"; - auto cli_request = - beerocks_header->addClass(); - if (cli_request == nullptr) { - LOG(ERROR) << "addClass cACTION_CLI_PING_SLAVE_REQUEST failed"; - isOK = false; - break; - } - std::string slave = tlvf::mac_to_string(cli_request->mac()); - if (database.is_hostap_active(slave)) { - auto agent_mac = database.get_node_parent_ire(slave); - - auto request = message_com::create_vs_message< - beerocks_message::cACTION_CONTROL_CONTROLLER_PING_REQUEST>(cmdu_tx); - if (request == nullptr) { - LOG(ERROR) << "Failed building message!"; - isOK = false; - break; - } - - request->total() = cli_request->num_of_req(); - request->seq() = 0; - - auto size_left = - MTU_SIZE - message_com::get_vs_cmdu_size_on_buffer< - beerocks_message::cACTION_CONTROL_CONTROLLER_PING_REQUEST>(); - if (size_left > cli_request->size()) { - request->size() = cli_request->size(); - } else { - LOG(DEBUG) << "PING_MSG_REQUEST size > tx_buffer size left setting size to " - << (int)size_left << " bytes"; - request->size() = size_left; - } - - if (!request->alloc_data(size_left)) { - LOG(ERROR) << "Failed buffer allocation to size=" << int(size_left); - isOK = false; - break; - } - memset(request->data(), 0, request->data_length()); - if (!database.update_node_last_ping_sent(slave)) { - LOG(DEBUG) << "PING_MSG_REQUEST received for slave " << slave - << " , can't update last ping sent time for "; - } - - const auto parent_radio = database.get_node_parent_radio(slave); - son_actions::send_cmdu_to_agent(agent_mac, cmdu_tx, database, parent_radio); - } - break; - } - case beerocks_message::ACTION_CLI_PING_ALL_SLAVES_REQUEST: { - LOG(DEBUG) << "PING_ALL_SLAVES_REQUEST from CLI"; - auto cli_request = - beerocks_header->addClass(); - if (cli_request == nullptr) { - LOG(ERROR) << "addClass cACTION_CLI_PING_SLAVE_REQUEST failed"; - isOK = false; - break; - } - - auto request = message_com::create_vs_message< - beerocks_message::cACTION_CONTROL_CONTROLLER_PING_REQUEST>(cmdu_tx); - if (request == nullptr) { - LOG(ERROR) << "Failed building message!"; - isOK = false; - break; - } - request->total() = cli_request->num_of_req(); - request->seq() = 0; - auto size_left = - MTU_SIZE - message_com::get_vs_cmdu_size_on_buffer< - beerocks_message::cACTION_CONTROL_CONTROLLER_PING_REQUEST>(); - if (size_left > cli_request->size()) { - request->size() = cli_request->size(); - } else { - LOG(DEBUG) << "PING_MSG_REQUEST size > tx_buffer size left setting size to " - << (int)size_left << " bytes"; - request->size() = size_left; - } - - if (!request->alloc_data(size_left)) { - LOG(ERROR) << "Failed buffer allocation to size=" << int(size_left); - isOK = false; - break; - } - - memset(request->data(), 0, request->data_length()); - - auto slaves = database.get_active_hostaps(); - for (const auto &slave : slaves) { - LOG(DEBUG) << "tending to send PING_MSG_REQUEST to " << slave; - if (database.is_hostap_active(slave)) { - auto agent_mac = database.get_node_parent_ire(slave); - if (!database.update_node_last_ping_sent(slave)) { - LOG(DEBUG) << "PING_MSG_REQUEST received for slave " << slave - << " , can't update last ping sent time for "; - } - LOG(DEBUG) << "send PING_MSG_REQUEST to " << slave; - son_actions::send_cmdu_to_agent(agent_mac, cmdu_tx, database, slave); - } - } - break; - } case beerocks_message::ACTION_CLI_HOSTAP_STATS_MEASUREMENT: { auto request_in = beerocks_header->addClass(); From 2ab69eedb4b76208e268851a277f36dcbc50b6a8 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 15 Jul 2020 14:38:51 +0300 Subject: [PATCH 380/453] agent: son_slave: Remove useless code Need to remove all related code for messages: ACTION_CONTROL_CONTROLLER_PING_REQUEST ACTION_CONTROL_CONTROLLER_PING_RESPONSE Signed-off-by: Vladyslav Tupikin --- agent/src/beerocks/slave/son_slave_thread.cpp | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 5ff8b3a21d..475f08f787 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -626,35 +626,6 @@ bool slave_thread::handle_cmdu_control_message(Socket *sd, message_com::send_cmdu(monitor_socket, cmdu_tx); break; } - case beerocks_message::ACTION_CONTROL_CONTROLLER_PING_REQUEST: { - LOG(DEBUG) << "received ACTION_CONTROL_CONTROLLER_PING_REQUEST"; - auto request = - beerocks_header->addClass(); - if (request == nullptr) { - LOG(ERROR) << "addClass cACTION_CONTROL_CONTROLLER_PING_REQUEST failed"; - return false; - } - - auto response = message_com::create_vs_message< - beerocks_message::cACTION_CONTROL_CONTROLLER_PING_RESPONSE>(cmdu_tx); - if (response == nullptr) { - LOG(ERROR) << "Failed building message!"; - return false; - } - response->total() = request->total(); - response->seq() = request->seq(); - response->size() = request->size(); - - if (response->size()) { - if (!response->alloc_data(request->size())) { - LOG(ERROR) << "Failed buffer allocation to size=" << int(request->size()); - break; - } - memset(request->data(), 0, request->data_length()); - } - send_cmdu_to_controller(cmdu_tx); - break; - } case beerocks_message::ACTION_CONTROL_CHANGE_MODULE_LOGGING_LEVEL: { auto request_in = beerocks_header From 99955ba6f07dea4b8b057ff95080fc503baff202 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 15 Jul 2020 14:35:21 +0300 Subject: [PATCH 381/453] common: tlvf: Remove ACTION_CONTROL_CONTROLLER_PING_REQUEST/RESPONSE Need to remove next messages: ACTION_CONTROL_CONTROLLER_PING_REQUEST ACTION_CONTROL_CONTROLLER_PING_RESPONSE https://jira.prplfoundation.org/browse/PPM-285 Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 2 - .../beerocks/tlvf/beerocks_message_control.h | 64 ----- .../tlvf/beerocks_message_control.cpp | 270 ------------------ .../tlvf/beerocks_message_action.yaml | 2 - .../tlvf/beerocks_message_control.yaml | 18 -- 5 files changed, 356 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index bc8172cd43..569c6b69e8 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -43,8 +43,6 @@ enum eActionOp_CONTROL: uint8_t { ACTION_CONTROL_SLAVE_JOINED_NOTIFICATION = 0x3, ACTION_CONTROL_SLAVE_JOINED_RESPONSE = 0x4, ACTION_CONTROL_SON_CONFIG_UPDATE = 0x5, - ACTION_CONTROL_CONTROLLER_PING_REQUEST = 0x6, - ACTION_CONTROL_CONTROLLER_PING_RESPONSE = 0x7, ACTION_CONTROL_CHANGE_MODULE_LOGGING_LEVEL = 0xb, ACTION_CONTROL_ARP_QUERY_REQUEST = 0xc, ACTION_CONTROL_ARP_QUERY_RESPONSE = 0xd, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h index 552891928b..eb3bf2e899 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h @@ -159,70 +159,6 @@ class cACTION_CONTROL_SON_CONFIG_UPDATE : public BaseClass sSonConfig* m_config = nullptr; }; -class cACTION_CONTROL_CONTROLLER_PING_REQUEST : public BaseClass -{ - public: - cACTION_CONTROL_CONTROLLER_PING_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CONTROL_CONTROLLER_PING_REQUEST(std::shared_ptr base, bool parse = false); - ~cACTION_CONTROL_CONTROLLER_PING_REQUEST(); - - static eActionOp_CONTROL get_action_op(){ - return (eActionOp_CONTROL)(ACTION_CONTROL_CONTROLLER_PING_REQUEST); - } - uint16_t& total(); - uint16_t& seq(); - uint16_t& size(); - size_t data_length() { return m_data_idx__ * sizeof(uint8_t); } - uint8_t* data(size_t idx = 0); - bool set_data(const void* buffer, size_t size); - bool alloc_data(size_t count = 1); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CONTROL* m_action_op = nullptr; - uint16_t* m_total = nullptr; - uint16_t* m_seq = nullptr; - uint16_t* m_size = nullptr; - uint8_t* m_data = nullptr; - size_t m_data_idx__ = 0; - int m_lock_order_counter__ = 0; -}; - -class cACTION_CONTROL_CONTROLLER_PING_RESPONSE : public BaseClass -{ - public: - cACTION_CONTROL_CONTROLLER_PING_RESPONSE(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CONTROL_CONTROLLER_PING_RESPONSE(std::shared_ptr base, bool parse = false); - ~cACTION_CONTROL_CONTROLLER_PING_RESPONSE(); - - static eActionOp_CONTROL get_action_op(){ - return (eActionOp_CONTROL)(ACTION_CONTROL_CONTROLLER_PING_RESPONSE); - } - uint16_t& total(); - uint16_t& seq(); - uint16_t& size(); - size_t data_length() { return m_data_idx__ * sizeof(uint8_t); } - uint8_t* data(size_t idx = 0); - bool set_data(const void* buffer, size_t size); - bool alloc_data(size_t count = 1); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CONTROL* m_action_op = nullptr; - uint16_t* m_total = nullptr; - uint16_t* m_seq = nullptr; - uint16_t* m_size = nullptr; - uint8_t* m_data = nullptr; - size_t m_data_idx__ = 0; - int m_lock_order_counter__ = 0; -}; - class cACTION_CONTROL_ARP_QUERY_REQUEST : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp index 032b9f8c11..f9b5175362 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp @@ -509,276 +509,6 @@ bool cACTION_CONTROL_SON_CONFIG_UPDATE::init() return true; } -cACTION_CONTROL_CONTROLLER_PING_REQUEST::cACTION_CONTROL_CONTROLLER_PING_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CONTROL_CONTROLLER_PING_REQUEST::cACTION_CONTROL_CONTROLLER_PING_REQUEST(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CONTROL_CONTROLLER_PING_REQUEST::~cACTION_CONTROL_CONTROLLER_PING_REQUEST() { -} -uint16_t& cACTION_CONTROL_CONTROLLER_PING_REQUEST::total() { - return (uint16_t&)(*m_total); -} - -uint16_t& cACTION_CONTROL_CONTROLLER_PING_REQUEST::seq() { - return (uint16_t&)(*m_seq); -} - -uint16_t& cACTION_CONTROL_CONTROLLER_PING_REQUEST::size() { - return (uint16_t&)(*m_size); -} - -uint8_t* cACTION_CONTROL_CONTROLLER_PING_REQUEST::data(size_t idx) { - if ( (m_data_idx__ == 0) || (m_data_idx__ <= idx) ) { - TLVF_LOG(ERROR) << "Requested index is greater than the number of available entries"; - return nullptr; - } - return &(m_data[idx]); -} - -bool cACTION_CONTROL_CONTROLLER_PING_REQUEST::set_data(const void* buffer, size_t size) { - if (buffer == nullptr) { - TLVF_LOG(WARNING) << "set_data received a null pointer."; - return false; - } - if (!alloc_data(size)) { return false; } - std::copy_n(reinterpret_cast(buffer), size, m_data); - return true; -} -bool cACTION_CONTROL_CONTROLLER_PING_REQUEST::alloc_data(size_t count) { - if (m_lock_order_counter__ > 0) {; - TLVF_LOG(ERROR) << "Out of order allocation for variable length list data, abort!"; - return false; - } - size_t len = sizeof(uint8_t) * count; - if(getBuffRemainingBytes() < len ) { - TLVF_LOG(ERROR) << "Not enough available space on buffer - can't allocate"; - return false; - } - m_lock_order_counter__ = 0; - uint8_t *src = (uint8_t *)m_data; - uint8_t *dst = src + len; - if (!m_parse__) { - size_t move_length = getBuffRemainingBytes(src) - len; - std::copy_n(src, move_length, dst); - } - m_data_idx__ += count; - if (!buffPtrIncrementSafe(len)) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << len << ") Failed!"; - return false; - } - return true; -} - -void cACTION_CONTROL_CONTROLLER_PING_REQUEST::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CONTROL), reinterpret_cast(m_action_op)); - tlvf_swap(16, reinterpret_cast(m_total)); - tlvf_swap(16, reinterpret_cast(m_seq)); - tlvf_swap(16, reinterpret_cast(m_size)); -} - -bool cACTION_CONTROL_CONTROLLER_PING_REQUEST::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CONTROL_CONTROLLER_PING_REQUEST::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(uint16_t); // total - class_size += sizeof(uint16_t); // seq - class_size += sizeof(uint16_t); // size - return class_size; -} - -bool cACTION_CONTROL_CONTROLLER_PING_REQUEST::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_total = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_seq = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_size = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_data = (uint8_t*)m_buff_ptr__; - m_data_idx__ = getBuffRemainingBytes(); - if (m_parse__) { class_swap(); } - return true; -} - -cACTION_CONTROL_CONTROLLER_PING_RESPONSE::cACTION_CONTROL_CONTROLLER_PING_RESPONSE(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CONTROL_CONTROLLER_PING_RESPONSE::cACTION_CONTROL_CONTROLLER_PING_RESPONSE(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CONTROL_CONTROLLER_PING_RESPONSE::~cACTION_CONTROL_CONTROLLER_PING_RESPONSE() { -} -uint16_t& cACTION_CONTROL_CONTROLLER_PING_RESPONSE::total() { - return (uint16_t&)(*m_total); -} - -uint16_t& cACTION_CONTROL_CONTROLLER_PING_RESPONSE::seq() { - return (uint16_t&)(*m_seq); -} - -uint16_t& cACTION_CONTROL_CONTROLLER_PING_RESPONSE::size() { - return (uint16_t&)(*m_size); -} - -uint8_t* cACTION_CONTROL_CONTROLLER_PING_RESPONSE::data(size_t idx) { - if ( (m_data_idx__ == 0) || (m_data_idx__ <= idx) ) { - TLVF_LOG(ERROR) << "Requested index is greater than the number of available entries"; - return nullptr; - } - return &(m_data[idx]); -} - -bool cACTION_CONTROL_CONTROLLER_PING_RESPONSE::set_data(const void* buffer, size_t size) { - if (buffer == nullptr) { - TLVF_LOG(WARNING) << "set_data received a null pointer."; - return false; - } - if (!alloc_data(size)) { return false; } - std::copy_n(reinterpret_cast(buffer), size, m_data); - return true; -} -bool cACTION_CONTROL_CONTROLLER_PING_RESPONSE::alloc_data(size_t count) { - if (m_lock_order_counter__ > 0) {; - TLVF_LOG(ERROR) << "Out of order allocation for variable length list data, abort!"; - return false; - } - size_t len = sizeof(uint8_t) * count; - if(getBuffRemainingBytes() < len ) { - TLVF_LOG(ERROR) << "Not enough available space on buffer - can't allocate"; - return false; - } - m_lock_order_counter__ = 0; - uint8_t *src = (uint8_t *)m_data; - uint8_t *dst = src + len; - if (!m_parse__) { - size_t move_length = getBuffRemainingBytes(src) - len; - std::copy_n(src, move_length, dst); - } - m_data_idx__ += count; - if (!buffPtrIncrementSafe(len)) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << len << ") Failed!"; - return false; - } - return true; -} - -void cACTION_CONTROL_CONTROLLER_PING_RESPONSE::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CONTROL), reinterpret_cast(m_action_op)); - tlvf_swap(16, reinterpret_cast(m_total)); - tlvf_swap(16, reinterpret_cast(m_seq)); - tlvf_swap(16, reinterpret_cast(m_size)); -} - -bool cACTION_CONTROL_CONTROLLER_PING_RESPONSE::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CONTROL_CONTROLLER_PING_RESPONSE::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(uint16_t); // total - class_size += sizeof(uint16_t); // seq - class_size += sizeof(uint16_t); // size - return class_size; -} - -bool cACTION_CONTROL_CONTROLLER_PING_RESPONSE::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_total = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_seq = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_size = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint16_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint16_t) << ") Failed!"; - return false; - } - m_data = (uint8_t*)m_buff_ptr__; - m_data_idx__ = getBuffRemainingBytes(); - if (m_parse__) { class_swap(); } - return true; -} - cACTION_CONTROL_ARP_QUERY_REQUEST::cACTION_CONTROL_ARP_QUERY_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index ad46204e87..aaff2e05f9 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -35,8 +35,6 @@ eActionOp_CONTROL: ACTION_CONTROL_SLAVE_JOINED_NOTIFICATION: 3 ACTION_CONTROL_SLAVE_JOINED_RESPONSE: 4 ACTION_CONTROL_SON_CONFIG_UPDATE: 5 - ACTION_CONTROL_CONTROLLER_PING_REQUEST: 6 - ACTION_CONTROL_CONTROLLER_PING_RESPONSE: 7 ACTION_CONTROL_CHANGE_MODULE_LOGGING_LEVEL: 11 ACTION_CONTROL_ARP_QUERY_REQUEST: 12 ACTION_CONTROL_ARP_QUERY_RESPONSE: 13 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml index b9f0779dc9..a400f14d68 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml @@ -49,24 +49,6 @@ cACTION_CONTROL_SON_CONFIG_UPDATE: _type: class config: sSonConfig -cACTION_CONTROL_CONTROLLER_PING_REQUEST: - _type: class - total: uint16_t - seq: uint16_t - size: uint16_t - data: - _type: uint8_t - _length: [] - -cACTION_CONTROL_CONTROLLER_PING_RESPONSE: - _type: class - total: uint16_t - seq: uint16_t - size: uint16_t - data: - _type: uint8_t - _length: [] - cACTION_CONTROL_ARP_QUERY_REQUEST: _type: class params: sArpQuery From fc4b2dcbf5e318c8a2498b29e25226326f6b4c41 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 22 Jul 2020 14:39:28 +0300 Subject: [PATCH 382/453] agent: monitor_thread: Remove deprecated methods Need to remove deprecated methods debug_statistics_11k_request() debug_statistics_11k_response() https://jira.prplfoundation.org/browse/PPM-291 Signed-off-by: Vladyslav Tupikin --- .../monitor/monitor_thread.cpp | 73 ------------------- .../monitor/monitor_thread.h | 2 - 2 files changed, 75 deletions(-) diff --git a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp index a060e88f1d..886fdaf0f5 100644 --- a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp +++ b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp @@ -1997,58 +1997,6 @@ bool monitor_thread::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t event // ; // } -// void monitor_thread::debug_statistics_11k_request(message::sACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST* request) -// { -// LOG(DEBUG) << "ACTION_MONITOR_CLIENT_STATISTICS_REQUEST:" << std::endl -// << std::endl << "group_identity: " << (int)request->params.group_identity -// << std::endl << "repeats: " << (int)request->params.repeats -// << std::endl << "rand_ival: " << (int)request->params.rand_ival -// << std::endl << "duration: " << (int)request->params.duration -// << std::endl << "sta_mac: " << request->params.sta_mac -// << std::endl << "peer_mac_addr: " << request->params.peer_mac_addr -// << std::endl << "parallel: " << (int)request->params.parallel -// << std::endl << "enable: " << (int)request->params.enable -// << std::endl << "request: " << (int)request->params.request -// << std::endl << "report: " << (int)request->params.report -// << std::endl << "mandatory_duration: " << (int)request->params.mandatory_duration; -// //Optional: -// // << std::endl << "use_optional_trig_rep_sta_counters: " << (int)request->params.use_optional_trig_rep_sta_counters -// // << std::endl << "measurement_count_1: " << (int)request->params.measurement_count_1 -// // << std::endl << "trigger_timeout_1: " << (int)request->params.trigger_timeout_1 -// // << std::endl << "sta_counter_trigger_condition: " << (int)request->params.sta_counter_trigger_condition -// // << std::endl << "dot11FailedCountThreshold: " << (int)request->params.dot11FailedCountThreshold -// // << std::endl << "dot11FCSErrorCountThreshold: " << (int)request->params.dot11FCSErrorCountThreshold -// // << std::endl << "dot11MultipleRetryCountThreshold: " << (int)request->params.dot11MultipleRetryCountThreshold -// // << std::endl << "dot11FrameDuplicateCountThreshold: " << (int)request->params.dot11FrameDuplicateCountThreshold -// // << std::endl << "dot11RTSFailureCountThreshold: " << (int)request->params.dot11RTSFailureCountThreshold -// // << std::endl << "dot11AckFailureCountThreshold: " << (int)request->params.dot11AckFailureCountThreshold -// // << std::endl << "dot11RetryCountThreshold: " << (int)request->params.dot11RetryCountThreshold -// // << std::endl << "use_optional_trig_rep_qos_sta_counters: " << (int)request->params.use_optional_trig_rep_qos_sta_counters -// // << std::endl << "measurement_count_2: " << (int)request->params.measurement_count_2 -// // << std::endl << "trigger_timeout_2: " << (int)request->params.trigger_timeout_2 -// // << std::endl << "qos_sta_counter_trigger_condition: " << (int)request->params.qos_sta_counter_trigger_condition -// // << std::endl << "dot11QoSFailedCountThreshold: " << (int)request->params.dot11QoSFailedCountThreshold -// // << std::endl << "dot11QoSRetryCountThreshold: " << (int)request->params.dot11QoSRetryCountThreshold -// // << std::endl << "dot11QoSMultipleRetryCountThreshold: " << (int)request->params.dot11QoSMultipleRetryCountThreshold -// // << std::endl << "dot11QoSFrameDuplicateCountThreshold: " << (int)request->params.dot11QoSFrameDuplicateCountThreshold -// // << std::endl << "dot11QoSRTSCountFailureThreshold: " << (int)request->params.dot11QoSRTSCountFailureThreshold -// // << std::endl << "dot11QoSAckFailureCountThreshold: " << (int)request->params.dot11QoSAckFailureCountThreshold -// // << std::endl << "dot11QoSDiscardedCountThreshold: " << (int)request->params.dot11QoSDiscardedCountThreshold -// // << std::endl << "use_optional_trig_rep_rsna_counters: " << (int)request->params.use_optional_trig_rep_rsna_counters -// // << std::endl << "measurement_count_3: " << (int)request->params.measurement_count_3 -// // << std::endl << "trigger_timeout_3: " << (int)request->params.trigger_timeout_3 -// // << std::endl << "rsna_counter_trigger_condition: " << (int)request->params.rsna_counter_trigger_condition -// // << std::endl << "dot11RSNAStatsCMACICVErrorsThreshold: " << (int)request->params.dot11RSNAStatsCMACICVErrorsThreshold -// // << std::endl << "dot11RSNAStatsCMACReplaysThreshold: " << (int)request->params.dot11RSNAStatsCMACReplaysThreshold -// // << std::endl << "dot11RSNAStatsRobustMgmtCCMPReplaysThreshold: " << (int)request->params.dot11RSNAStatsRobustMgmtCCMPReplaysThreshold -// // << std::endl << "dot11RSNAStatsTKIPICVErrorsThreshold: " << (int)request->params.dot11RSNAStatsTKIPICVErrorsThreshold -// // << std::endl << "dot11RSNAStatsTKIPReplaysThreshold: " << (int)request->params.dot11RSNAStatsTKIPReplaysThreshold -// // << std::endl << "dot11RSNAStatsCCMPDecryptErrorsThreshold: " << (int)request->params.dot11RSNAStatsCCMPDecryptErrorsThreshold -// // << std::endl << "dot11RSNAStatsCCMPReplaysThreshold: " << (int)request->params.dot11RSNAStatsCCMPReplaysThreshold -// // ; - -// } - // void monitor_thread::debug_channel_load_11k_response(message::sACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_RESPONSE* event) // { // LOG(DEBUG) << "DATA TEST:" @@ -2089,27 +2037,6 @@ bool monitor_thread::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t event // ; // } -// void monitor_thread::debug_statistics_11k_response(message::sACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE* event) -// { -// std::string statistics_group_data; -// for(uint8_t i=0;iparams.statistics_group_data_size;i++){ -// statistics_group_data += string_utils::to_string(event->params.statistics_group_data[i]) + ","; -// } -// statistics_group_data.pop_back(); // deletes last comma - -// LOG(DEBUG) << "DATA TEST:" -// << std::endl << "sta_mac: " << event->params.sta_mac -// << std::endl << "measurement_rep_mode: " << (int)event->params.rep_mode -// << std::endl << "duration: " << (int)event->params.duration -// << std::endl << "group_identity: " << (int)event->params.group_identity -// << std::endl << "statistics_group_data: "<< statistics_group_data - -// << std::endl << "average_trigger: " << (int)event->params.average_trigger -// << std::endl << "consecutive_trigger: " << (int)event->params.consecutive_trigger -// << std::endl << "delay_trigger: " << (int)event->params.delay_trigger -// ; -// } - void monitor_thread::send_heartbeat() { if (slave_socket == nullptr) { diff --git a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.h b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.h index 4dd1734e31..c82a43f736 100644 --- a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.h +++ b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.h @@ -89,8 +89,6 @@ class monitor_thread : public beerocks::socket_thread { void debug_channel_load_11k_response(beerocks_message::sStaChannelLoadResponse11k &event); void debug_beacon_11k_request(beerocks_message::sBeaconRequest11k &request); void debug_beacon_11k_response(beerocks_message::sBeaconResponse11k &event); - void debug_statistics_11k_request(beerocks_message::sStatisticsRequest11k &request); - void debug_statistics_11k_response(beerocks_message::sStatisticsResponse11k &event); void send_heartbeat(); void update_vaps_in_db(); From ee0f45bd5179517e4147234467aff88f3537878e Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 22 Jul 2020 14:38:15 +0300 Subject: [PATCH 383/453] common: bwl: Remove deprecated method Need to remove deprecated method sta_statistics_11k_request(). https://jira.prplfoundation.org/browse/PPM-291 Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/dummy/mon_wlan_hal_dummy.cpp | 6 ------ common/beerocks/bwl/dummy/mon_wlan_hal_dummy.h | 2 +- common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp | 6 ------ common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.h | 1 - common/beerocks/bwl/include/bwl/mon_wlan_hal.h | 1 - common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp | 6 ------ common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.h | 1 - 7 files changed, 1 insertion(+), 22 deletions(-) diff --git a/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.cpp b/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.cpp index 7f104ccd18..ec1e0c7904 100644 --- a/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.cpp +++ b/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.cpp @@ -143,12 +143,6 @@ bool mon_wlan_hal_dummy::sta_beacon_11k_request(const SBeaconRequest11k &req, in return true; } -bool mon_wlan_hal_dummy::sta_statistics_11k_request(const SStatisticsRequest11k &req) -{ - LOG(TRACE) << __func__; - return true; -} - bool mon_wlan_hal_dummy::sta_link_measurements_11k_request(const std::string &sta_mac) { LOG(TRACE) << __func__; diff --git a/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.h b/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.h index f07281037f..d06f063dfa 100644 --- a/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.h +++ b/common/beerocks/bwl/dummy/mon_wlan_hal_dummy.h @@ -42,7 +42,7 @@ class mon_wlan_hal_dummy : public base_wlan_hal_dummy, public mon_wlan_hal { const std::string &sta_mac, SStaStats &sta_stats) override; virtual bool sta_channel_load_11k_request(const SStaChannelLoadRequest11k &req) override; virtual bool sta_beacon_11k_request(const SBeaconRequest11k &req, int &dialog_token) override; - virtual bool sta_statistics_11k_request(const SStatisticsRequest11k &req) override; + virtual bool sta_link_measurements_11k_request(const std::string &sta_mac) override; virtual bool channel_scan_trigger(int dwell_time_msec, const std::vector &channel_pool) override; diff --git a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp index 32954a09b6..dea5b51bb7 100644 --- a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp @@ -873,12 +873,6 @@ bool mon_wlan_hal_dwpal::sta_beacon_11k_request(const SBeaconRequest11k &req, in return true; } -bool mon_wlan_hal_dwpal::sta_statistics_11k_request(const SStatisticsRequest11k &req) -{ - LOG(TRACE) << __func__; - return true; -} - bool mon_wlan_hal_dwpal::sta_link_measurements_11k_request(const std::string &sta_mac) { LOG(TRACE) << __func__; diff --git a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.h b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.h index d1838e9535..abaa49e893 100644 --- a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.h +++ b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.h @@ -39,7 +39,6 @@ class mon_wlan_hal_dwpal : public base_wlan_hal_dwpal, public mon_wlan_hal { const std::string &sta_mac, SStaStats &sta_stats) override; virtual bool sta_channel_load_11k_request(const SStaChannelLoadRequest11k &req) override; virtual bool sta_beacon_11k_request(const SBeaconRequest11k &req, int &dialog_token) override; - virtual bool sta_statistics_11k_request(const SStatisticsRequest11k &req) override; virtual bool sta_link_measurements_11k_request(const std::string &sta_mac) override; virtual bool channel_scan_trigger(int dwell_time_msec, const std::vector &channel_pool) override; diff --git a/common/beerocks/bwl/include/bwl/mon_wlan_hal.h b/common/beerocks/bwl/include/bwl/mon_wlan_hal.h index b872ef4274..c405e0ed09 100644 --- a/common/beerocks/bwl/include/bwl/mon_wlan_hal.h +++ b/common/beerocks/bwl/include/bwl/mon_wlan_hal.h @@ -54,7 +54,6 @@ class mon_wlan_hal : public virtual base_wlan_hal { virtual bool sta_channel_load_11k_request(const SStaChannelLoadRequest11k &req) = 0; virtual bool sta_beacon_11k_request(const SBeaconRequest11k &req, int &dialog_token) = 0; - virtual bool sta_statistics_11k_request(const SStatisticsRequest11k &req) = 0; virtual bool sta_link_measurements_11k_request(const std::string &sta_mac) = 0; virtual bool channel_scan_trigger(int dwell_time_msec, const std::vector &channel_pool) = 0; diff --git a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp index 1591a8af39..f5e5fe2f63 100644 --- a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp +++ b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp @@ -367,12 +367,6 @@ bool mon_wlan_hal_nl80211::sta_beacon_11k_request(const SBeaconRequest11k &req, return true; } -bool mon_wlan_hal_nl80211::sta_statistics_11k_request(const SStatisticsRequest11k &req) -{ - LOG(TRACE) << __func__ << " - NOT IMPLEMENTED!"; - return true; -} - bool mon_wlan_hal_nl80211::sta_link_measurements_11k_request(const std::string &sta_mac) { LOG(TRACE) << __func__ << " - NOT IMPLEMENTED!"; diff --git a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.h b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.h index f2448e1237..63b76e5012 100644 --- a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.h +++ b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.h @@ -39,7 +39,6 @@ class mon_wlan_hal_nl80211 : public base_wlan_hal_nl80211, public mon_wlan_hal { virtual bool sta_channel_load_11k_request(const SStaChannelLoadRequest11k &req) override; virtual bool sta_beacon_11k_request(const SBeaconRequest11k &req, int &dialog_token) override; - virtual bool sta_statistics_11k_request(const SStatisticsRequest11k &req) override; virtual bool sta_link_measurements_11k_request(const std::string &sta_mac) override; virtual bool channel_scan_trigger(int dwell_time_msec, const std::vector &channel_pool) override; From 4964f83dc5626331346923b945b645dcbeedb587 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 22 Jul 2020 13:31:59 +0300 Subject: [PATCH 384/453] common: bwl: Remove RRM_STA_Statistics_Response https://jira.prplfoundation.org/browse/PPM-291 Signed-off-by: Vladyslav Tupikin --- common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp | 4 ---- common/beerocks/bwl/include/bwl/mon_wlan_hal.h | 1 - common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp | 2 -- 3 files changed, 7 deletions(-) diff --git a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp index dea5b51bb7..abacc4d343 100644 --- a/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/mon_wlan_hal_dwpal.cpp @@ -67,8 +67,6 @@ static mon_wlan_hal::Event dwpal_to_bwl_event(const std::string &opcode) return mon_wlan_hal::Event::RRM_Channel_Load_Response; } else if (opcode == "RRM-BEACON-REP-RECEIVED") { return mon_wlan_hal::Event::RRM_Beacon_Response; - } else if (opcode == "RRM-STA-STATISTICS-RECEIVED") { - return mon_wlan_hal::Event::RRM_STA_Statistics_Response; } else if (opcode == "AP-ENABLED") { return mon_wlan_hal::Event::AP_Enabled; } else if (opcode == "AP-DISABLED") { @@ -1285,8 +1283,6 @@ bool mon_wlan_hal_dwpal::process_dwpal_event(char *buffer, int bufLen, const std event_queue_push(Event::STA_Disconnected, msg_buff); // send message to the AP manager break; } - - case Event::RRM_STA_Statistics_Response: case Event::RRM_Channel_Load_Response: break; // Gracefully ignore unhandled events diff --git a/common/beerocks/bwl/include/bwl/mon_wlan_hal.h b/common/beerocks/bwl/include/bwl/mon_wlan_hal.h index c405e0ed09..1215ba4ba0 100644 --- a/common/beerocks/bwl/include/bwl/mon_wlan_hal.h +++ b/common/beerocks/bwl/include/bwl/mon_wlan_hal.h @@ -34,7 +34,6 @@ class mon_wlan_hal : public virtual base_wlan_hal { RRM_Channel_Load_Response, RRM_Beacon_Request_Status, RRM_Beacon_Response, - RRM_STA_Statistics_Response, //CHANNEL_SCAN events Channel_Scan_Triggered, Channel_Scan_New_Results_Ready, diff --git a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp index f5e5fe2f63..2b2f4e199b 100644 --- a/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp +++ b/common/beerocks/bwl/nl80211/mon_wlan_hal_nl80211.cpp @@ -58,8 +58,6 @@ static mon_wlan_hal::Event wav_to_bwl_event(const std::string &opcode) } else if (opcode == "BEACON-RESP-RX") { return mon_wlan_hal::Event::RRM_Beacon_Response; } - // } else if (opcode == "RRM-STA-STATISTICS-RECEIVED") { - // return mon_wlan_hal::Event::RRM_STA_Statistics_Response; // } else if (opcode == "RRM-LINK-MEASUREMENT-RECEIVED") { return mon_wlan_hal::Event::Invalid; From df6189ec31450edb85f1561e8d443d2698b7913b Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Wed, 22 Jul 2020 13:22:53 +0300 Subject: [PATCH 385/453] agent: fronthaul_manager: Remove deprecated VS message Need to remove code which uses VS message: ACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST ACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE https://jira.prplfoundation.org/browse/PPM-291 Signed-off-by: Vladyslav Tupikin --- .../monitor/monitor_thread.cpp | 116 ------------------ 1 file changed, 116 deletions(-) diff --git a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp index 886fdaf0f5..99a5a1e560 100644 --- a/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp +++ b/agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp @@ -1281,89 +1281,6 @@ bool monitor_thread::handle_cmdu_vs_message(Socket &sd, ieee1905_1::CmduMessageR mon_wlan_hal->sta_channel_load_11k_request(bwl_request); break; } - case beerocks_message::ACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST: { - auto request = - beerocks_header - ->addClass(); - if (request == nullptr) { - LOG(ERROR) << "addClass cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST failed"; - return false; - } - - // debug_statistics_11k_request(request); - - // TODO: TEMPORARY CONVERSION! - bwl::SStatisticsRequest11k bwl_request; - - bwl_request.group_identity = request->params().group_identity; - bwl_request.parallel = request->params().parallel; - bwl_request.enable = request->params().enable; - bwl_request.request = request->params().request; - bwl_request.report = request->params().report; - bwl_request.mandatory_duration = request->params().mandatory_duration; - bwl_request.repeats = request->params().repeats; - bwl_request.rand_ival = request->params().rand_ival; - bwl_request.duration = request->params().duration; - bwl_request.use_optional_trig_rep_sta_counters = - request->params().use_optional_trig_rep_sta_counters; - bwl_request.measurement_count_1 = request->params().measurement_count_1; - bwl_request.trigger_timeout_1 = request->params().trigger_timeout_1; - bwl_request.sta_counter_trigger_condition = request->params().sta_counter_trigger_condition; - bwl_request.dot11FailedCountThreshold = request->params().dot11FailedCountThreshold; - bwl_request.dot11FCSErrorCountThreshold = request->params().dot11FCSErrorCountThreshold; - bwl_request.dot11MultipleRetryCountThreshold = - request->params().dot11MultipleRetryCountThreshold; - bwl_request.dot11FrameDuplicateCountThreshold = - request->params().dot11FrameDuplicateCountThreshold; - bwl_request.dot11RTSFailureCountThreshold = request->params().dot11RTSFailureCountThreshold; - bwl_request.dot11AckFailureCountThreshold = request->params().dot11AckFailureCountThreshold; - bwl_request.dot11RetryCountThreshold = request->params().dot11RetryCountThreshold; - bwl_request.use_optional_trig_rep_qos_sta_counters = - request->params().use_optional_trig_rep_qos_sta_counters; - bwl_request.measurement_count_2 = request->params().measurement_count_2; - bwl_request.trigger_timeout_2 = request->params().trigger_timeout_2; - bwl_request.qos_sta_counter_trigger_condition = - request->params().qos_sta_counter_trigger_condition; - bwl_request.dot11QoSFailedCountThreshold = request->params().dot11QoSFailedCountThreshold; - bwl_request.dot11QoSRetryCountThreshold = request->params().dot11QoSRetryCountThreshold; - bwl_request.dot11QoSMultipleRetryCountThreshold = - request->params().dot11QoSMultipleRetryCountThreshold; - bwl_request.dot11QoSFrameDuplicateCountThreshold = - request->params().dot11QoSFrameDuplicateCountThreshold; - bwl_request.dot11QoSRTSCountFailureThreshold = - request->params().dot11QoSRTSCountFailureThreshold; - bwl_request.dot11QoSAckFailureCountThreshold = - request->params().dot11QoSAckFailureCountThreshold; - bwl_request.dot11QoSDiscardedCountThreshold = - request->params().dot11QoSDiscardedCountThreshold; - bwl_request.use_optional_trig_rep_rsna_counters = - request->params().use_optional_trig_rep_rsna_counters; - bwl_request.measurement_count_3 = request->params().measurement_count_3; - bwl_request.trigger_timeout_3 = request->params().trigger_timeout_3; - bwl_request.rsna_counter_trigger_condition = - request->params().rsna_counter_trigger_condition; - bwl_request.dot11RSNAStatsCMACICVErrorsThreshold = - request->params().dot11RSNAStatsCMACICVErrorsThreshold; - bwl_request.dot11RSNAStatsCMACReplaysThreshold = - request->params().dot11RSNAStatsCMACReplaysThreshold; - bwl_request.dot11RSNAStatsRobustMgmtCCMPReplaysThreshold = - request->params().dot11RSNAStatsRobustMgmtCCMPReplaysThreshold; - bwl_request.dot11RSNAStatsTKIPICVErrorsThreshold = - request->params().dot11RSNAStatsTKIPICVErrorsThreshold; - bwl_request.dot11RSNAStatsTKIPReplaysThreshold = - request->params().dot11RSNAStatsTKIPReplaysThreshold; - bwl_request.dot11RSNAStatsCCMPDecryptErrorsThreshold = - request->params().dot11RSNAStatsCCMPDecryptErrorsThreshold; - bwl_request.dot11RSNAStatsCCMPReplaysThreshold = - request->params().dot11RSNAStatsCCMPReplaysThreshold; - std::copy_n(request->params().sta_mac.oct, sizeof(bwl_request.sta_mac.oct), - bwl_request.sta_mac.oct); - std::copy_n(request->params().peer_mac_addr.oct, sizeof(bwl_request.peer_mac_addr.oct), - bwl_request.peer_mac_addr.oct); - - mon_wlan_hal->sta_statistics_11k_request(bwl_request); - break; - } case beerocks_message::ACTION_MONITOR_CHANNEL_SCAN_TRIGGER_SCAN_REQUEST: { auto request = beerocks_header @@ -1709,39 +1626,6 @@ bool monitor_thread::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t event } break; - case Event::RRM_STA_Statistics_Response: { - - auto hal_data = static_cast(data); - - auto response = message_com::create_vs_message< - beerocks_message::cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE>(cmdu_tx); - if (response == nullptr) { - LOG(ERROR) << "Failed building cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE message!"; - break; - } - - response->params().dialog_token = hal_data->dialog_token; - response->params().measurement_token = hal_data->measurement_token; - response->params().rep_mode = hal_data->rep_mode; - response->params().group_identity = hal_data->group_identity; - response->params().statistics_group_data_size = hal_data->statistics_group_data_size; - response->params().duration = hal_data->duration; - response->params().use_optional_rep_reason = hal_data->use_optional_rep_reason; - response->params().average_trigger = hal_data->average_trigger; - response->params().consecutive_trigger = hal_data->consecutive_trigger; - response->params().delay_trigger = hal_data->delay_trigger; - std::copy_n(hal_data->statistics_group_data, - sizeof(response->params().statistics_group_data), - response->params().statistics_group_data); - std::copy_n(hal_data->sta_mac.oct, sizeof(response->params().sta_mac.oct), - response->params().sta_mac.oct); - - // debug_statistics_11k_response(msg); - - message_com::send_cmdu(slave_socket, cmdu_tx); - - } break; - case Event::AP_Enabled: { if (!data) { LOG(ERROR) << "AP_Enabled without data"; From 66124ed6e06b5150b9388e82b0250f1087cd2dac Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 16:28:41 +0300 Subject: [PATCH 386/453] controller: son_master: Remove case from VS message handler Need to remove case for processing ACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE message from VS message handler. https://jira.prplfoundation.org/browse/PPM-291 Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/master/son_master_thread.cpp | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/controller/src/beerocks/master/son_master_thread.cpp b/controller/src/beerocks/master/son_master_thread.cpp index 69a477d5f3..9ea4cc6dbe 100644 --- a/controller/src/beerocks/master/son_master_thread.cpp +++ b/controller/src/beerocks/master/son_master_thread.cpp @@ -3252,36 +3252,6 @@ bool master_thread::handle_cmdu_control_message(const std::string &src_mac, ); break; } - case beerocks_message::ACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE: { - auto response = - beerocks_header - ->addClass(); - if (response == nullptr) { - LOG(ERROR) << "addClass ACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE failed"; - return false; - } - std::string statistics_group_data; - for (uint8_t i = 0; i < response->params().statistics_group_data_size; i++) { - statistics_group_data += - std::to_string(response->params().statistics_group_data[i]) + ","; - } - statistics_group_data.pop_back(); // deletes last comma - LOG_CLI(DEBUG, - "statistics response: " - << std::endl - << "sta_mac: " << response->params().sta_mac << std::endl - << "measurement_rep_mode: " << (int)response->params().rep_mode << std::endl - << "duration: " << (int)response->params().duration << std::endl - << "group_identity: " << (int)response->params().group_identity << std::endl - << "statistics_group_data: " << statistics_group_data - - << std::endl - << "average_trigger: " << (int)response->params().average_trigger << std::endl - << "consecutive_trigger: " << (int)response->params().consecutive_trigger - << std::endl - << "delay_trigger: " << (int)response->params().delay_trigger); - break; - } case beerocks_message::ACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE: { auto response = beerocks_header->addClass< beerocks_message::cACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE>(); From fe02619ea26df8691492e47507d51cbe1f97fb3c Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 18:34:53 +0300 Subject: [PATCH 387/453] common: tlvf: Remove deprecated VS message Need to remove deprecated VS message ACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE. https://jira.prplfoundation.org/browse/PPM-291 Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 2 - .../beerocks/tlvf/beerocks_message_monitor.h | 42 ------ .../tlvf/beerocks_message_monitor.cpp | 140 ------------------ .../tlvf/beerocks_message_action.yaml | 2 - .../tlvf/beerocks_message_monitor.yaml | 8 - 5 files changed, 194 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index 569c6b69e8..b583f299e5 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -230,8 +230,6 @@ enum eActionOp_MONITOR: uint8_t { ACTION_MONITOR_CLIENT_BEACON_11K_RESPONSE = 0x1e, ACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_REQUEST = 0x1f, ACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_RESPONSE = 0x20, - ACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST = 0x21, - ACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE = 0x22, ACTION_MONITOR_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE = 0x25, ACTION_MONITOR_CLIENT_NO_ACTIVITY_NOTIFICATION = 0x26, ACTION_MONITOR_CLIENT_NEW_IP_ADDRESS_NOTIFICATION = 0x27, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_monitor.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_monitor.h index b2af821018..d7c34d699d 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_monitor.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_monitor.h @@ -613,48 +613,6 @@ class cACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_RESPONSE : public BaseClass sStaChannelLoadResponse11k* m_params = nullptr; }; -class cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST : public BaseClass -{ - public: - cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST(std::shared_ptr base, bool parse = false); - ~cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST(); - - static eActionOp_MONITOR get_action_op(){ - return (eActionOp_MONITOR)(ACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST); - } - sStatisticsRequest11k& params(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_MONITOR* m_action_op = nullptr; - sStatisticsRequest11k* m_params = nullptr; -}; - -class cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE : public BaseClass -{ - public: - cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE(std::shared_ptr base, bool parse = false); - ~cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE(); - - static eActionOp_MONITOR get_action_op(){ - return (eActionOp_MONITOR)(ACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE); - } - sStatisticsResponse11k& params(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_MONITOR* m_action_op = nullptr; - sStatisticsResponse11k* m_params = nullptr; -}; - class cACTION_MONITOR_CLIENT_NEW_IP_ADDRESS_NOTIFICATION : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_monitor.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_monitor.cpp index 20700c608a..3d366d9d06 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_monitor.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_monitor.cpp @@ -2077,146 +2077,6 @@ bool cACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_RESPONSE::init() return true; } -cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST::cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST::cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST::~cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST() { -} -sStatisticsRequest11k& cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST::params() { - return (sStatisticsRequest11k&)(*m_params); -} - -void cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_MONITOR), reinterpret_cast(m_action_op)); - m_params->struct_swap(); -} - -bool cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sStatisticsRequest11k); // params - return class_size; -} - -bool cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_params = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sStatisticsRequest11k))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sStatisticsRequest11k) << ") Failed!"; - return false; - } - if (!m_parse__) { m_params->struct_init(); } - if (m_parse__) { class_swap(); } - return true; -} - -cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE::cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE::cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE::~cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE() { -} -sStatisticsResponse11k& cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE::params() { - return (sStatisticsResponse11k&)(*m_params); -} - -void cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_MONITOR), reinterpret_cast(m_action_op)); - m_params->struct_swap(); -} - -bool cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sStatisticsResponse11k); // params - return class_size; -} - -bool cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_params = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sStatisticsResponse11k))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sStatisticsResponse11k) << ") Failed!"; - return false; - } - if (!m_parse__) { m_params->struct_init(); } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_MONITOR_CLIENT_NEW_IP_ADDRESS_NOTIFICATION::cACTION_MONITOR_CLIENT_NEW_IP_ADDRESS_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index aaff2e05f9..b94106a261 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -262,8 +262,6 @@ eActionOp_MONITOR: ACTION_MONITOR_CLIENT_BEACON_11K_RESPONSE: 30 ACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_REQUEST: 31 ACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_RESPONSE: 32 - ACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST: 33 - ACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE: 34 ACTION_MONITOR_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE: 37 ACTION_MONITOR_CLIENT_NO_ACTIVITY_NOTIFICATION: 38 ACTION_MONITOR_CLIENT_NEW_IP_ADDRESS_NOTIFICATION: 39 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml index 51d4646b6f..20830b5a92 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_monitor.yaml @@ -146,14 +146,6 @@ cACTION_MONITOR_CLIENT_CHANNEL_LOAD_11K_RESPONSE: _type: class params: sStaChannelLoadResponse11k -cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST: - _type: class - params: sStatisticsRequest11k - -cACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE: - _type: class - params: sStatisticsResponse11k - cACTION_MONITOR_CLIENT_NEW_IP_ADDRESS_NOTIFICATION: _type: class mac: sMacAddr From e7b37074f468f1be87f7f84607181cbbaf148f05 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 18:19:22 +0300 Subject: [PATCH 388/453] agent: son_slave: Remove case for deprecated message Need to remove deprecated case from handler for vendor specific message ACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE https://jira.prplfoundation.org/browse/PPM-291 Signed-off-by: Vladyslav Tupikin --- agent/src/beerocks/slave/son_slave_thread.cpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 475f08f787..bdebcb27f1 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -2567,25 +2567,6 @@ bool slave_thread::handle_cmdu_monitor_message(Socket *sd, break; } - case beerocks_message::ACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE: { - auto response_in = - beerocks_header - ->addClass(); - if (response_in == nullptr) { - LOG(ERROR) << "addClass ACTION_MONITOR_CLIENT_STATISTICS_11K_RESPONSE failed"; - break; - } - auto response_out = message_com::create_vs_message< - beerocks_message::cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE>( - cmdu_tx, beerocks_header->id()); - if (response_out == nullptr) { - LOG(ERROR) << "Failed building ACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE message!"; - break; - } - response_out->params() = response_in->params(); - send_cmdu_to_controller(cmdu_tx); - break; - } case beerocks_message::ACTION_MONITOR_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE: { LOG(INFO) << "ACTION_MONITOR_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE: action_op: " << int(beerocks_header->action_op()); From dc4445a43dd8827e56bd63a747c880caae1da530 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 16:38:26 +0300 Subject: [PATCH 389/453] controller: beerocks_cli: Remove deprecated CLI command Need to remove deprecated CLI command client_statistics_11k_req and all related code. https://jira.prplfoundation.org/browse/PPM-291 Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/cli/beerocks_cli_socket.cpp | 36 ------------------- .../src/beerocks/cli/beerocks_cli_socket.h | 6 ---- 2 files changed, 42 deletions(-) diff --git a/controller/src/beerocks/cli/beerocks_cli_socket.cpp b/controller/src/beerocks/cli/beerocks_cli_socket.cpp index 298cd0ac99..49f80815db 100644 --- a/controller/src/beerocks/cli/beerocks_cli_socket.cpp +++ b/controller/src/beerocks/cli/beerocks_cli_socket.cpp @@ -164,11 +164,6 @@ void cli_socket::setFunctionsMapAndArray() static_cast(&cli_socket::client_beacon_11k_req_caller), 1, 9, STRING_ARG, STRING_ARG, STRING_ARG, STRING_ARG, STRING_ARG, STRING_ARG, STRING_ARG, STRING_ARG, STRING_ARG); - insertCommandToMap( - "client_statistics_11k_req", " ", - "sends statistics 11k request to 'client_mac', with 'group_identity', about 'peer_mac'", - static_cast(&cli_socket::client_statistics_11k_req_caller), 3, 4, STRING_ARG, - STRING_ARG, INT_ARG, STRING_ARG); insertCommandToMap( "ap_neighbor_11k_set", " ", "add 'bssid' with 'channel' to 11k neighbor list of 'hostap_mac' with 'vap_id'", @@ -424,17 +419,6 @@ int cli_socket::client_beacon_11k_req_caller(int numOfArgs) return -1; } -int cli_socket::client_statistics_11k_req_caller(int numOfArgs) -{ - if (numOfArgs == 4) { - return client_statistics_11k_req(args.stringArgs[0], args.stringArgs[1], args.intArgs[2], - args.stringArgs[3]); - } else if (numOfArgs == 3) { - return client_statistics_11k_req(args.stringArgs[0], args.stringArgs[1], args.intArgs[2]); - } else - return -1; -} - int cli_socket::set_neighbor_11k_caller(int numOfArgs) { if (numOfArgs == 4) { @@ -743,26 +727,6 @@ int cli_socket::client_beacon_11k_req(std::string client_mac, std::string bssid, return 0; } -int cli_socket::client_statistics_11k_req(std::string hostap_mac, std::string client_mac, - uint8_t group_identity, std::string peer_mac) -{ - auto request = - message_com::create_vs_message( - cmdu_tx); - if (request == nullptr) { - LOG(ERROR) << "Failed building cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST message!"; - return -1; - } - request->client_mac() = tlvf::mac_from_string(client_mac); - request->hostap_mac() = tlvf::mac_from_string(hostap_mac); - request->peer_mac() = tlvf::mac_from_string(peer_mac); - request->group_identity() = group_identity; - wait_response = true; - message_com::send_cmdu(master_socket, cmdu_tx); - waitResponseReady(); - return 0; -} - int cli_socket::set_neighbor_11k(std::string ap_mac, std::string bssid, uint8_t channel, int8_t vap_id) { diff --git a/controller/src/beerocks/cli/beerocks_cli_socket.h b/controller/src/beerocks/cli/beerocks_cli_socket.h index 239205d6b7..1f50d9a729 100644 --- a/controller/src/beerocks/cli/beerocks_cli_socket.h +++ b/controller/src/beerocks/cli/beerocks_cli_socket.h @@ -79,8 +79,6 @@ class cli_socket : public socket_thread, public cli { int client_beacon_11k_req_caller(int numOfArgs); - int client_statistics_11k_req_caller(int numOfArgs); - // Functions int enable_debug(int8_t isEnable = -1); @@ -124,10 +122,6 @@ class cli_socket : public socket_thread, public cli { std::string ssid, uint16_t duration, uint16_t rand_ival, uint16_t repeats, int16_t op_class, std::string mode); - int client_statistics_11k_req(std::string hostap_mac, std::string client_mac, - uint8_t group_identity, - std::string peer_mac = net::network_utils::WILD_MAC_STRING); - // Variables std::string temp_path; SocketClient *master_socket = nullptr; From 1d595a41adaf70874e800c7066dfbb4fce63fc00 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 16:36:36 +0300 Subject: [PATCH 390/453] controller: son_management: Remove deprecated case from handler Need to remove deprecated case for processing message from handler: ACTION_CLI_CLIENT_STATISTICS_11K_REQUEST https://jira.prplfoundation.org/browse/PPM-291 Signed-off-by: Vladyslav Tupikin --- .../src/beerocks/master/son_management.cpp | 89 ------------------- 1 file changed, 89 deletions(-) diff --git a/controller/src/beerocks/master/son_management.cpp b/controller/src/beerocks/master/son_management.cpp index 9372c9cc5c..b7cd6de536 100644 --- a/controller/src/beerocks/master/son_management.cpp +++ b/controller/src/beerocks/master/son_management.cpp @@ -429,95 +429,6 @@ void son_management::handle_cli_message(Socket *sd, break; } - case beerocks_message::ACTION_CLI_CLIENT_STATISTICS_11K_REQUEST: { - auto cli_request = - beerocks_header - ->addClass(); - if (cli_request == nullptr) { - LOG(ERROR) << "addClass ACTION_CLI_CLIENT_STATISTICS_11K_REQUEST failed"; - isOK = false; - break; - } - - std::string client_mac = tlvf::mac_to_string(cli_request->client_mac()); - std::string hostap_mac = tlvf::mac_to_string(cli_request->hostap_mac()); - auto agent_mac = database.get_node_parent_ire(hostap_mac); - LOG(DEBUG) << "CLI statistics request for " << client_mac << " to " << hostap_mac; - - auto request = message_com::create_vs_message< - beerocks_message::cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST>(cmdu_tx); - if (request == nullptr) { - LOG(ERROR) << "Failed building ACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST message!"; - isOK = false; - break; - } - - //TODO: set params values - request->params().group_identity = cli_request->group_identity(); - request->params().repeats = - 0; // '0' = once, '65535' = repeats until cancel request, other (1-65534) = specific num of repeats - request->params().rand_ival = - 1000; // random interval - specifies the upper bound of the random delay to be used prior to making the measurement, expressed in units of TUs [=1024usec] - request->params().duration = - 10; // measurement duration, expressed in units of TUs [=1024usec] - request->params().sta_mac = cli_request->client_mac(); - request->params().peer_mac_addr = - cli_request - ->peer_mac(); // the bssid which will be reported. for all bssid, use wildcard "ff:ff:ff:ff:ff:ff" - - // Measurement request mode booleans: - request->params().parallel = - 0; // (for multiple requests)'0' - measurements are to be performed in sequence, - // '1' - request that the measurement is to start at the same time as the measurement described - // by the next Measurement Request element in the same Measurement Request frame - request->params().enable = 0; - request->params().request = 0; - request->params().report = 0; - request->params().mandatory_duration = - 0; // '0' - the duration can be lower than in the duration field, '1' - duration is mandantory - - // Optional: - request->params().use_optional_trig_rep_sta_counters = 0; // bool - // request.params.measurement_count_1; - // request.params.trigger_timeout_1; - // request.params.sta_counter_trigger_condition; - // request.params.dot11FailedCountThreshold; - // request.params.dot11FCSErrorCountThreshold; - // request.params.dot11MultipleRetryCountThreshold; - // request.params.dot11FrameDuplicateCountThreshold; - // request.params.dot11RTSFailureCountThreshold; - // request.params.dot11AckFailureCountThreshold; - // request.params.dot11RetryCountThreshold; - - request->params().use_optional_trig_rep_qos_sta_counters = 0; // bool - // request.params.measurement_count_2; - // request.params.trigger_timeout_2; - // request.params.qos_sta_counter_trigger_condition; - // request.params.dot11QoSFailedCountThreshold; - // request.params.dot11QoSRetryCountThreshold; - // request.params.dot11QoSMultipleRetryCountThreshold; - // request.params.dot11QoSFrameDuplicateCountThreshold; - // request.params.dot11QoSRTSCountFailureThreshold; - // request.params.dot11QoSAckFailureCountThreshold; - // request.params.dot11QoSDiscardedCountThreshold; - - request->params().use_optional_trig_rep_rsna_counters = 0; // bool - // request.params.measurement_count_3; - // request.params.trigger_timeout_3; - // request.params.rsna_counter_trigger_condition; - // request.params.dot11RSNAStatsCMACICVErrorsThreshold; - // request.params.dot11RSNAStatsCMACReplaysThreshold; - // request.params.dot11RSNAStatsRobustMgmtCCMPReplaysThreshold; - // request.params.dot11RSNAStatsTKIPICVErrorsThreshold; - // request.params.dot11RSNAStatsTKIPReplaysThreshold; - // request.params.dot11RSNAStatsCCMPDecryptErrorsThreshold; - // request.params.dot11RSNAStatsCCMPReplaysThreshold; - - const auto parent_radio = database.get_node_parent_radio(hostap_mac); - son_actions::send_cmdu_to_agent(agent_mac, cmdu_tx, database, parent_radio); - - break; - } case beerocks_message::ACTION_CLI_HOSTAP_CHANNEL_SWITCH_REQUEST: { auto cli_request = beerocks_header From 6b2c370df153773274618bf6f87d851387e8f8f6 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 16:26:49 +0300 Subject: [PATCH 391/453] agent: son_slave: Remove case from VS message handler Need to remove case from VS message handler for processing message: ACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST https://jira.prplfoundation.org/browse/PPM-291 Signed-off-by: Vladyslav Tupikin --- agent/src/beerocks/slave/son_slave_thread.cpp | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index bdebcb27f1..430f96a638 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -794,27 +794,6 @@ bool slave_thread::handle_cmdu_control_message(Socket *sd, message_com::send_cmdu(monitor_socket, cmdu_tx); break; } - case beerocks_message::ACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST: { - auto request_in = - beerocks_header - ->addClass(); - if (request_in == nullptr) { - LOG(ERROR) << "addClass ACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST failed"; - return false; - } - - auto request_out = message_com::create_vs_message< - beerocks_message::cACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST>(cmdu_tx, - beerocks_header->id()); - if (request_out == nullptr) { - LOG(ERROR) << "Failed building ACTION_MONITOR_CLIENT_STATISTICS_11K_REQUEST message!"; - return false; - } - - request_out->params() = request_in->params(); - message_com::send_cmdu(monitor_socket, cmdu_tx); - break; - } case beerocks_message::ACTION_CONTROL_HOSTAP_UPDATE_STOP_ON_FAILURE_ATTEMPTS_REQUEST: { auto request_in = beerocks_header->addClass< beerocks_message::cACTION_CONTROL_HOSTAP_UPDATE_STOP_ON_FAILURE_ATTEMPTS_REQUEST>(); From 125b2111be1d2faadc278c8b36aabfd41c8d77f0 Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Thu, 30 Jul 2020 02:04:35 +0300 Subject: [PATCH 392/453] common: tlvf: Remove deprecated CLI message Need to remove deprecated CLI message ACTION_CLI_CLIENT_STATISTICS_11K_REQUEST. https://jira.prplfoundation.org/browse/PPM-291 Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 1 - .../beerocks/tlvf/beerocks_message_cli.h | 27 ----- .../beerocks/tlvf/beerocks_message_cli.cpp | 104 ------------------ .../tlvf/beerocks_message_action.yaml | 1 - .../beerocks/tlvf/beerocks_message_cli.yaml | 7 -- 5 files changed, 140 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index b583f299e5..733773b394 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -276,7 +276,6 @@ enum eActionOp_CLI: uint8_t { ACTION_CLI_CLIENT_DISCONNECT_REQUEST = 0x52, ACTION_CLI_CLIENT_BSS_STEER_REQUEST = 0x53, ACTION_CLI_CLIENT_BEACON_11K_REQUEST = 0x56, - ACTION_CLI_CLIENT_STATISTICS_11K_REQUEST = 0x57, ACTION_CLI_HOSTAP_CHANNEL_SWITCH_REQUEST = 0x7a, ACTION_CLI_HOSTAP_SET_NEIGHBOR_11K_REQUEST = 0x7b, ACTION_CLI_HOSTAP_REMOVE_NEIGHBOR_11K_REQUEST = 0x7c, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h index 96b30978de..eaaa9a8890 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_cli.h @@ -452,33 +452,6 @@ class cACTION_CLI_CLIENT_BEACON_11K_REQUEST : public BaseClass int16_t* m_op_class = nullptr; }; -class cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST : public BaseClass -{ - public: - cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST(std::shared_ptr base, bool parse = false); - ~cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST(); - - static eActionOp_CLI get_action_op(){ - return (eActionOp_CLI)(ACTION_CLI_CLIENT_STATISTICS_11K_REQUEST); - } - sMacAddr& hostap_mac(); - sMacAddr& client_mac(); - sMacAddr& peer_mac(); - uint8_t& group_identity(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CLI* m_action_op = nullptr; - sMacAddr* m_hostap_mac = nullptr; - sMacAddr* m_client_mac = nullptr; - sMacAddr* m_peer_mac = nullptr; - uint8_t* m_group_identity = nullptr; -}; - class cACTION_CLI_HOSTAP_CHANNEL_SWITCH_REQUEST : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp index 3a5da025a1..bb432a0f03 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_cli.cpp @@ -1540,110 +1540,6 @@ bool cACTION_CLI_CLIENT_BEACON_11K_REQUEST::init() return true; } -cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST::cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST::cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST::~cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST() { -} -sMacAddr& cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST::hostap_mac() { - return (sMacAddr&)(*m_hostap_mac); -} - -sMacAddr& cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST::client_mac() { - return (sMacAddr&)(*m_client_mac); -} - -sMacAddr& cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST::peer_mac() { - return (sMacAddr&)(*m_peer_mac); -} - -uint8_t& cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST::group_identity() { - return (uint8_t&)(*m_group_identity); -} - -void cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CLI), reinterpret_cast(m_action_op)); - m_hostap_mac->struct_swap(); - m_client_mac->struct_swap(); - m_peer_mac->struct_swap(); -} - -bool cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sMacAddr); // hostap_mac - class_size += sizeof(sMacAddr); // client_mac - class_size += sizeof(sMacAddr); // peer_mac - class_size += sizeof(uint8_t); // group_identity - return class_size; -} - -bool cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_hostap_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_hostap_mac->struct_init(); } - m_client_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_client_mac->struct_init(); } - m_peer_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_peer_mac->struct_init(); } - m_group_identity = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(uint8_t))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; - return false; - } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_CLI_HOSTAP_CHANNEL_SWITCH_REQUEST::cACTION_CLI_HOSTAP_CHANNEL_SWITCH_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index b94106a261..ff56c71040 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -319,7 +319,6 @@ eActionOp_CLI: ACTION_CLI_CLIENT_BSS_STEER_REQUEST: 83 ACTION_CLI_CLIENT_BEACON_11K_REQUEST: 86 - ACTION_CLI_CLIENT_STATISTICS_11K_REQUEST: 87 ACTION_CLI_HOSTAP_CHANNEL_SWITCH_REQUEST: 122 ACTION_CLI_HOSTAP_SET_NEIGHBOR_11K_REQUEST: 123 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml index 4fa054b1ca..b5cffb91fe 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_cli.yaml @@ -119,13 +119,6 @@ cACTION_CLI_CLIENT_BEACON_11K_REQUEST: repeats: uint16_t op_class: int16_t -cACTION_CLI_CLIENT_STATISTICS_11K_REQUEST: - _type: class - hostap_mac: sMacAddr - client_mac: sMacAddr - peer_mac: sMacAddr - group_identity: uint8_t - ################################################# # HOSTAP ################################################# From 5c6f5c00d3ee6039671e6a32a20d1c36006ebc7d Mon Sep 17 00:00:00 2001 From: Vladyslav Tupikin Date: Tue, 21 Jul 2020 16:19:18 +0300 Subject: [PATCH 393/453] common: tlvf: Remove deprecated messages Need to remove deprecated messages: ACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST ACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE https://jira.prplfoundation.org/browse/PPM-291 Signed-off-by: Vladyslav Tupikin --- .../beerocks/tlvf/beerocks_message_action.h | 2 - .../beerocks/tlvf/beerocks_message_control.h | 42 ------ .../tlvf/beerocks_message_control.cpp | 140 ------------------ .../tlvf/beerocks_message_action.yaml | 3 - .../tlvf/beerocks_message_control.yaml | 8 - 5 files changed, 195 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h index 733773b394..a940d478a6 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_action.h @@ -83,8 +83,6 @@ enum eActionOp_CONTROL: uint8_t { ACTION_CONTROL_CLIENT_ARP_MONITOR_NOTIFICATION = 0x74, ACTION_CONTROL_CLIENT_BEACON_11K_REQUEST = 0x75, ACTION_CONTROL_CLIENT_BEACON_11K_RESPONSE = 0x76, - ACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST = 0x79, - ACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE = 0x7a, ACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE = 0x7d, ACTION_CONTROL_CLIENT_NO_ACTIVITY_NOTIFICATION = 0x7e, ACTION_CONTROL_STEERING_CLIENT_SET_GROUP_REQUEST = 0x7f, diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h index eb3bf2e899..35164fb15f 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_control.h @@ -1074,48 +1074,6 @@ class cACTION_CONTROL_CLIENT_BEACON_11K_RESPONSE : public BaseClass sBeaconResponse11k* m_params = nullptr; }; -class cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST : public BaseClass -{ - public: - cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST(std::shared_ptr base, bool parse = false); - ~cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST(); - - static eActionOp_CONTROL get_action_op(){ - return (eActionOp_CONTROL)(ACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST); - } - sStatisticsRequest11k& params(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CONTROL* m_action_op = nullptr; - sStatisticsRequest11k* m_params = nullptr; -}; - -class cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE : public BaseClass -{ - public: - cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE(std::shared_ptr base, bool parse = false); - ~cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE(); - - static eActionOp_CONTROL get_action_op(){ - return (eActionOp_CONTROL)(ACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE); - } - sStatisticsResponse11k& params(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_CONTROL* m_action_op = nullptr; - sStatisticsResponse11k* m_params = nullptr; -}; - class cACTION_CONTROL_STEERING_CLIENT_SET_GROUP_REQUEST : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp index f9b5175362..22f022f321 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_control.cpp @@ -3683,146 +3683,6 @@ bool cACTION_CONTROL_CLIENT_BEACON_11K_RESPONSE::init() return true; } -cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST::cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST::cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST::~cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST() { -} -sStatisticsRequest11k& cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST::params() { - return (sStatisticsRequest11k&)(*m_params); -} - -void cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CONTROL), reinterpret_cast(m_action_op)); - m_params->struct_swap(); -} - -bool cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sStatisticsRequest11k); // params - return class_size; -} - -bool cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_params = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sStatisticsRequest11k))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sStatisticsRequest11k) << ") Failed!"; - return false; - } - if (!m_parse__) { m_params->struct_init(); } - if (m_parse__) { class_swap(); } - return true; -} - -cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE::cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE::cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE::~cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE() { -} -sStatisticsResponse11k& cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE::params() { - return (sStatisticsResponse11k&)(*m_params); -} - -void cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_CONTROL), reinterpret_cast(m_action_op)); - m_params->struct_swap(); -} - -bool cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sStatisticsResponse11k); // params - return class_size; -} - -bool cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_params = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sStatisticsResponse11k))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sStatisticsResponse11k) << ") Failed!"; - return false; - } - if (!m_parse__) { m_params->struct_init(); } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_CONTROL_STEERING_CLIENT_SET_GROUP_REQUEST::cACTION_CONTROL_STEERING_CLIENT_SET_GROUP_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml index ff56c71040..32be33f1f6 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_action.yaml @@ -79,9 +79,6 @@ eActionOp_CONTROL: ACTION_CONTROL_CLIENT_ARP_MONITOR_NOTIFICATION: 116 ACTION_CONTROL_CLIENT_BEACON_11K_REQUEST: 117 ACTION_CONTROL_CLIENT_BEACON_11K_RESPONSE: 118 - - ACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST: 121 - ACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE: 122 ACTION_CONTROL_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE: 125 ACTION_CONTROL_CLIENT_NO_ACTIVITY_NOTIFICATION: 126 ACTION_CONTROL_STEERING_CLIENT_SET_GROUP_REQUEST: 127 diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml index a400f14d68..346454c4c0 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_control.yaml @@ -248,14 +248,6 @@ cACTION_CONTROL_CLIENT_BEACON_11K_RESPONSE: _type: class params: sBeaconResponse11k -cACTION_CONTROL_CLIENT_STATISTICS_11K_REQUEST: - _type: class - params: sStatisticsRequest11k - -cACTION_CONTROL_CLIENT_STATISTICS_11K_RESPONSE: - _type: class - params: sStatisticsResponse11k - ################################################# # MONITOR RDKB CONFIGURATIONS ################################################# From fed9a3ce6a45694a392588b04c5c933ab7a3742d Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Thu, 23 Jul 2020 11:18:09 +0000 Subject: [PATCH 394/453] framework: bpl: uci: add new UCI DB interface preparatory commit. To support the persistent DB feature, we use the UCI library APIs, and with it provide a simpler, more straightforward interface. Added BPL UCI stubs to be used by the BPL DB to read/write/modify the UCI DB files. Relates to JIRA PPM-5. Signed-off-by: Itay Elenzweig --- framework/platform/bpl/uci/db/bpl_db_uci.cpp | 91 +++++++++++++ framework/platform/bpl/uci/db/bpl_db_uci.h | 134 +++++++++++++++++++ 2 files changed, 225 insertions(+) create mode 100644 framework/platform/bpl/uci/db/bpl_db_uci.cpp create mode 100644 framework/platform/bpl/uci/db/bpl_db_uci.h diff --git a/framework/platform/bpl/uci/db/bpl_db_uci.cpp b/framework/platform/bpl/uci/db/bpl_db_uci.cpp new file mode 100644 index 0000000000..0aa3231944 --- /dev/null +++ b/framework/platform/bpl/uci/db/bpl_db_uci.cpp @@ -0,0 +1,91 @@ +#include "bpl_db_uci.h" + +#include +#include + +namespace beerocks { +namespace bpl { +namespace db { + +bool uci_section_exists(const std::string &package_name, const std::string §ion_type, + const std::string §ion_name) +{ + //package_name.(section_type)section_name + LOG(TRACE) << "uci_section_exists() " << package_name << ".(" << section_type << ")" + << section_name; + + return true; +} + +bool uci_add_section(const std::string &package_name, const std::string §ion_type, + const std::string §ion_name) +{ + //package_name.(section_type)section_name + LOG(TRACE) << "uci_add_section() " << package_name << ".(" << section_type << ")" + << section_name; + + return true; +} + +bool uci_set_section(const std::string &package_name, const std::string §ion_type, + const std::string §ion_name, const OptionsUnorderedMap &options) +{ + //package_name.(section_type)section_name + LOG(TRACE) << "uci_set_section() " << package_name << ".(" << section_type << ")" + << section_name; + + return true; +} + +bool uci_get_section(const std::string &package_name, const std::string §ion_type, + const std::string §ion_name, OptionsUnorderedMap &options) +{ + //package_name.(section_type)section_name + LOG(TRACE) << "uci_get_section() " << package_name << ".(" << section_type << ")" + << section_name; + + return true; +} + +bool uci_get_section_type(const std::string &package_name, const std::string §ion_name, + std::string §ion_type) +{ + //package_name.section_name + LOG(TRACE) << "uci_get_section_type() " << package_name << "." << section_name; + + return true; +} + +bool uci_get_option(const std::string &package_name, const std::string §ion_type, + const std::string §ion_name, const std::string &option_name, + std::string &option_value) +{ + //package_name.(section_type)section_name.option_name + LOG(TRACE) << "uci_get_param() " << package_name << ".(" << section_type << ")" << section_name + << "." << option_name; + + return true; +} + +bool uci_delete_section(const std::string &package_name, const std::string §ion_type, + const std::string §ion_name) +{ + //package_name.(section_type)section_name + LOG(TRACE) << "uci_delete_section() " << package_name << ".(" << section_type << ")" + << section_name; + + return true; +} + +bool uci_get_all_sections(const std::string &package_name, const std::string §ion_type, + std::vector §ions) +{ + //package_name.(section_type) + LOG(TRACE) << "uci_get_all_sections() " << package_name << ".(" << section_type << ")"; + + return true; +} + +} // namespace db +} // namespace bpl +} // namespace beerocks diff --git a/framework/platform/bpl/uci/db/bpl_db_uci.h b/framework/platform/bpl/uci/db/bpl_db_uci.h new file mode 100644 index 0000000000..b4a7470e84 --- /dev/null +++ b/framework/platform/bpl/uci/db/bpl_db_uci.h @@ -0,0 +1,134 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#ifndef _BPL_DB_UCI_H_ +#define _BPL_DB_UCI_H_ + +#include +#include +#include + +namespace beerocks { +namespace bpl { +namespace db { + +using OptionsUnorderedMap = std::unordered_map; +/****************************************************************************/ +/******************************* Definitions ********************************/ +/****************************************************************************/ + +/****************************************************************************/ +/******************************* Structures *********************************/ +/****************************************************************************/ + +/****************************************************************************/ +/******************************** Functions *********************************/ +/****************************************************************************/ + +/** + * @brief Find if section exists. + * + * @param[in] package_name name of the requested configuration file. + * @param[in] section_type type of the requested section. + * @param[in] section_name name of the requested section. + * @return true if section exists in db, false otherwise + */ +bool uci_section_exists(const std::string &package_name, const std::string §ion_type, + const std::string §ion_name); + +/** + * @brief Add new named section. + * + * @param[in] package_name name of the requested configuration file. + * @param[in] section_type type of the requested section. + * @param[in] section_name name of the requested section. + * @return true if section exists in db, false otherwise + */ +bool uci_add_section(const std::string &package_name, const std::string §ion_type, + const std::string §ion_name); + +/** + * @brief Set values in section, updating as needed. + * An option set to an empty string will be removed from the section. + * An option that does not exist will be added to the section. + * An option that already exists will be overridden with the new value + * Options that exist and are not mentioned in @a options will remain unchanged. + * + * @param[in] package_name name of the requested configuration file. + * @param[in] section_type type of the requested section. + * @param[in] section_name name of the requested section. + * @param[in] options unordered map containing a key/value pair of parameters to be set. + * @return true on success, false otherwise. + */ +bool uci_set_section(const std::string &package_name, const std::string §ion_type, + const std::string §ion_name, const OptionsUnorderedMap &options); + +/** + * @brief Get values in section. + * + * @param[in] package_name name of the requested configuration file. + * @param[in] section_type type of the requested section. + * @param[in] section_name name of the requested section. + * @param[out] options empty unordered map, will be filled with configured parameters. + * @return true on success, false otherwise. + */ +bool uci_get_section(const std::string &package_name, const std::string §ion_type, + const std::string §ion_name, OptionsUnorderedMap &options); + +/** + * @brief Get type of section by name. + * + * @param[in] package_name name of the requested configuration file. + * @param[in] section_name name of the requested section. + * @param[out] section_type will contain type of found section. + * @return true on success, false otherwise. + */ +bool uci_get_section_type(const std::string &package_name, const std::string §ion_name, + std::string §ion_type); + +/** + * @brief Get specific value from section. + * + * @param[in] package_name name of the requested configuration file. + * @param[in] section_type type of the requested section. + * @param[in] section_name name of the requested section. + * @param[in] option_name name of the requested option. + * @param[out] option_value will contain value of found option. + * @return true on success, false otherwise. + */ +bool uci_get_option(const std::string &package_name, const std::string §ion_type, + const std::string §ion_name, const std::string &option_name, + std::string &option_value); + +/** + * @brief Delete existing section. + * + * @param[in] package_name name of the requested configuration file. + * @param[in] section_type type of the requested section. + * @param[in] section_name name of the requested section. + * @return true if section exists in db, false otherwise + */ +bool uci_delete_section(const std::string &package_name, const std::string §ion_type, + const std::string §ion_name); + +/** + * @brief Get all entries with the same type. + * + * @param[in] package_name name of the requested configuration file. + * @param[in] section_type type of the requested section. (If empty get sections of all types) + * @param[out] sections empty vector, will be filled with all matching sections. + * @return true if section exists in db, false otherwise + */ +bool uci_get_all_sections(const std::string &package_name, const std::string §ion_type, + std::vector §ions); + +} // namespace db +} // namespace bpl +} // namespace beerocks + +#endif /* _BPL_DB_UCI_H_ */ From aa7c93770034cb4ffc656ce1b7a5ecc479b3a878 Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Thu, 23 Jul 2020 11:18:49 +0000 Subject: [PATCH 395/453] framework: bpl: uci: add UCI helper functions. preparatory commit. Added BPL UCI helper functions, - alloc_context which allocated a uci_context "smart" pointer. - uci_get_error which returns the output error from the UCI. Relates to JIRA PPM-5. Signed-off-by: Itay Elenzweig --- framework/platform/bpl/uci/db/bpl_db_uci.cpp | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/framework/platform/bpl/uci/db/bpl_db_uci.cpp b/framework/platform/bpl/uci/db/bpl_db_uci.cpp index 0aa3231944..cfad90b0cf 100644 --- a/framework/platform/bpl/uci/db/bpl_db_uci.cpp +++ b/framework/platform/bpl/uci/db/bpl_db_uci.cpp @@ -3,10 +3,40 @@ #include #include +extern "C" { +#include +} + namespace beerocks { namespace bpl { namespace db { +constexpr ssize_t MAX_UCI_BUF_LEN = 64; +constexpr char package_path[] = "%s"; +constexpr char section_path[] = "%s.%s"; +constexpr char section_type_path[] = "%s.%s=%s"; +constexpr char option_path[] = "%s.%s.%s"; +constexpr char option_value_path[] = "%s.%s.%s=%s"; + +std::string uci_get_error(uci_context *ctx) +{ + char *err_buf = nullptr; + uci_get_errorstr(ctx, &err_buf, ""); + return std::string(err_buf == nullptr ? "" : err_buf); +} + +std::shared_ptr alloc_context() +{ + auto ctx = std::shared_ptr(uci_alloc_context(), [](uci_context *ctx) { + if (ctx) { + uci_free_context(ctx); + } + }); + + LOG_IF(!ctx, ERROR) << "Failed allocating UCI context!"; + return ctx; +} + bool uci_section_exists(const std::string &package_name, const std::string §ion_type, const std::string §ion_name) { From 221e96e51108eb55fda1914be4a0b28ed5fa4622 Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Thu, 23 Jul 2020 11:19:16 +0000 Subject: [PATCH 396/453] framework: bpl: uci: Implement section_exists function. The implementation of bpl_db_uci function utilizes the `libuci` functions that provides persistency of the configured data over UCI. Implemented the section_exists API, the functions checks whether a section exists in the given configuration. Existence is determined by matching section name & type (if provided). Relates to JIRA PPM-5. Signed-off-by: Itay Elenzweig --- framework/platform/bpl/uci/db/bpl_db_uci.cpp | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/framework/platform/bpl/uci/db/bpl_db_uci.cpp b/framework/platform/bpl/uci/db/bpl_db_uci.cpp index cfad90b0cf..fcbf511fbb 100644 --- a/framework/platform/bpl/uci/db/bpl_db_uci.cpp +++ b/framework/platform/bpl/uci/db/bpl_db_uci.cpp @@ -44,6 +44,55 @@ bool uci_section_exists(const std::string &package_name, const std::string § LOG(TRACE) << "uci_section_exists() " << package_name << ".(" << section_type << ")" << section_name; + auto ctx = alloc_context(); + if (!ctx) { + return false; + } + + char path[MAX_UCI_BUF_LEN] = {0}; + // Generate a uci path to the package we wish to lookup + if (snprintf(path, MAX_UCI_BUF_LEN, package_path, package_name.c_str()) <= 0) { + LOG(ERROR) << "Failed to compose path"; + return false; + } + + uci_package *pkg = uci_lookup_package(ctx.get(), path); + if (!pkg) { + // Try and load the package file, in case it wasn't loaded before + uci_load(ctx.get(), path, &pkg); + if (!pkg) { + LOG(ERROR) << "uci lookup package failed!" << std::endl << uci_get_error(ctx.get()); + return false; + } + } + + bool section_found = false; + // Loop through all sections + uci_section *sec = nullptr; + uci_element *elm = nullptr; + uci_foreach_element(&pkg->sections, elm) + { + sec = uci_to_section(elm); + // uci enforces sections must have unique name + if (section_name.compare(sec->e.name) == 0) { + LOG(TRACE) << "Found section: " << sec->type << "(" << sec->e.name << ")"; + section_found = true; + break; + } + } + + if (!section_found) { + LOG(DEBUG) << "No matching section found for " << section_name; + return false; + } + + // If the section_type is empty all matching sections are a valid match + if (!section_type.empty() && section_type.compare(sec->type) != 0) { + LOG(DEBUG) << "Section with matching name found, but types don't match" << std::endl + << "Searched type: " << section_type << ", Found type: " << sec->type; + return false; + } + return true; } From 5476f35d34f9ddb30c4ea6cf1f9382aabb638980 Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Thu, 23 Jul 2020 11:19:30 +0000 Subject: [PATCH 397/453] framework: bpl: uci: Implement add_section function. The implementation of bpl_db_uci function utilizes the `libuci` functions that provides persistency of the configured data over UCI. Implemented the add_section API, the functions creates a new named section with the provided type in the given configuration. Relates to JIRA PPM-5. Signed-off-by: Itay Elenzweig --- framework/platform/bpl/uci/db/bpl_db_uci.cpp | 45 ++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/framework/platform/bpl/uci/db/bpl_db_uci.cpp b/framework/platform/bpl/uci/db/bpl_db_uci.cpp index fcbf511fbb..5b1d1bf5d8 100644 --- a/framework/platform/bpl/uci/db/bpl_db_uci.cpp +++ b/framework/platform/bpl/uci/db/bpl_db_uci.cpp @@ -103,6 +103,51 @@ bool uci_add_section(const std::string &package_name, const std::string §ion LOG(TRACE) << "uci_add_section() " << package_name << ".(" << section_type << ")" << section_name; + auto ctx = alloc_context(); + if (!ctx) { + return false; + } + + char sec_path[MAX_UCI_BUF_LEN] = {0}; + // Generate a uci path to the section we wish to lookup + if (snprintf(sec_path, MAX_UCI_BUF_LEN, section_type_path, package_name.c_str(), + section_name.c_str(), section_type.c_str()) <= 0) { + LOG(ERROR) << "Failed to compose path"; + return false; + } + + uci_ptr sec_ptr; + // Initialize section pointer from path. + if (uci_lookup_ptr(ctx.get(), &sec_ptr, sec_path, true) != UCI_OK) { + LOG(ERROR) << "UCI failed to lookup ptr for path: " << sec_path << std::endl + << uci_get_error(ctx.get()); + return false; + } + + // Check if section already exists + if (sec_ptr.s) { + LOG(ERROR) << "Section already exists!"; + return false; + } + + // Add a new named section. + if (uci_set(ctx.get(), &sec_ptr) != UCI_OK) { + LOG(ERROR) << "Failed to add new section"; + return false; + } + + // Create delta from changes, this does not change the persistent file. + if (uci_save(ctx.get(), sec_ptr.p) != UCI_OK) { + LOG(ERROR) << "Failed to save changes!" << std::endl << uci_get_error(ctx.get()); + return false; + } + + // Commit changes to file + if (uci_commit(ctx.get(), &sec_ptr.p, false) != UCI_OK) { + LOG(ERROR) << "Failed to commit changes!" << std::endl << uci_get_error(ctx.get()); + return false; + } + return true; } From 56fe731e22d074471d9776c635afe486b19b8a56 Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Thu, 23 Jul 2020 11:19:44 +0000 Subject: [PATCH 398/453] framework: bpl: uci: Implement set_section function. The implementation of bpl_db_uci function utilizes the `libuci` functions that provides persistency of the configured data over UCI. Implemented the set_section API, the function sets the provided options as described below: - if the option is provided without a value it is removed from the section. - if the option is provided with value: -- if it doesn't exist in the section it will be added with its value -- if it already exist - its value is overwritten Existing options in the section, that are not provided as part of the options map will not be changed. Relates to JIRA PPM-5. Signed-off-by: Itay Elenzweig --- framework/platform/bpl/uci/db/bpl_db_uci.cpp | 76 ++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/framework/platform/bpl/uci/db/bpl_db_uci.cpp b/framework/platform/bpl/uci/db/bpl_db_uci.cpp index 5b1d1bf5d8..9861b114fe 100644 --- a/framework/platform/bpl/uci/db/bpl_db_uci.cpp +++ b/framework/platform/bpl/uci/db/bpl_db_uci.cpp @@ -158,6 +158,82 @@ bool uci_set_section(const std::string &package_name, const std::string §ion LOG(TRACE) << "uci_set_section() " << package_name << ".(" << section_type << ")" << section_name; + if (!uci_section_exists(package_name, section_type, section_name)) { + LOG(ERROR) << "section " << section_name << " of type " << section_type + << " was not found!"; + return false; + } + + auto ctx = alloc_context(); + if (!ctx) { + return false; + } + + for (auto &option : options) { + char opt_path[MAX_UCI_BUF_LEN] = {0}; + // Generate a uci path to the option we wish to set + if (snprintf(opt_path, MAX_UCI_BUF_LEN, option_path, package_name.c_str(), + section_name.c_str(), option.first.c_str()) <= 0) { + LOG(ERROR) << "Failed to compose path"; + return false; + } + + uci_ptr opt_ptr; + // Initialize option pointer from path. + if (uci_lookup_ptr(ctx.get(), &opt_ptr, opt_path, true) != UCI_OK) { + LOG(ERROR) << "UCI failed to lookup ptr for path: " << opt_path << std::endl + << uci_get_error(ctx.get()); + return false; + } + // Set the value of option in uci_ptr + // when using uci_set, it will store the change in the context + auto value_ptr = strdup(option.second.c_str()); + if (!value_ptr) { + LOG(ERROR) << "Failed to duplicate value buffer"; + return false; + } + opt_ptr.value = value_ptr; + + /* + If the value is set to empty the option will be removed + If the option does not exist it will be created + If the option does exist the value will be overridden + */ + if (uci_set(ctx.get(), &opt_ptr) != UCI_OK) { + LOG(ERROR) << "Failed to set option " << option.first << std::endl + << uci_get_error(ctx.get()); + return false; + } + + // Create delta from changes in the coxtext, this does not change the persistent file. + if (uci_save(ctx.get(), opt_ptr.p) != UCI_OK) { + LOG(ERROR) << "Failed to save changes!" << std::endl << uci_get_error(ctx.get()); + return false; + } + } + + // To save the changes made we need to call "uci_commit" with the package + // Loading a uci_ptr will also load the changes saved in the context's delta + char pkg_path[MAX_UCI_BUF_LEN] = {0}; + // Generate a uci path to the package we wish to lookup + if (snprintf(pkg_path, MAX_UCI_BUF_LEN, package_path, package_name.c_str()) <= 0) { + LOG(ERROR) << "Failed to compose path"; + return false; + } + + uci_ptr pkg_ptr; + // Initialize package pointer from path & validate package existace. + if (uci_lookup_ptr(ctx.get(), &pkg_ptr, pkg_path, true) != UCI_OK || !pkg_ptr.p) { + LOG(ERROR) << "UCI failed to lookup ptr for path: " << pkg_path << std::endl + << uci_get_error(ctx.get()); + return false; + } + + // Commit changes to file + if (uci_commit(ctx.get(), &pkg_ptr.p, false) != UCI_OK) { + LOG(ERROR) << "Failed to commit changes!" << std::endl << uci_get_error(ctx.get()); + return false; + } return true; } From 2e934544ca2c2c6aa83ad74d17ab8632599449d7 Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Thu, 23 Jul 2020 11:20:01 +0000 Subject: [PATCH 399/453] framework: bpl: uci: Implement get_section function. The implementation of bpl_db_uci function utilizes the `libuci` functions that provides persistency of the configured data over UCI. Implemented the get_section API, the functions retrieves all available (configured) options of the found section. Relates to JIRA PPM-5. Signed-off-by: Itay Elenzweig --- framework/platform/bpl/uci/db/bpl_db_uci.cpp | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/framework/platform/bpl/uci/db/bpl_db_uci.cpp b/framework/platform/bpl/uci/db/bpl_db_uci.cpp index 9861b114fe..248344c67e 100644 --- a/framework/platform/bpl/uci/db/bpl_db_uci.cpp +++ b/framework/platform/bpl/uci/db/bpl_db_uci.cpp @@ -244,6 +244,38 @@ bool uci_get_section(const std::string &package_name, const std::string §ion LOG(TRACE) << "uci_get_section() " << package_name << ".(" << section_type << ")" << section_name; + auto ctx = alloc_context(); + if (!ctx) { + return false; + } + + char sec_path[MAX_UCI_BUF_LEN] = {0}; + // Generate a uci path to the section we wish to lookup + if (snprintf(sec_path, MAX_UCI_BUF_LEN, section_path, package_name.c_str(), + section_name.c_str()) <= 0) { + LOG(ERROR) << "Failed to compose path"; + return false; + } + + uci_ptr sec_ptr; + // Initialize section pointer from path & validate section existace + if (uci_lookup_ptr(ctx.get(), &sec_ptr, sec_path, true) != UCI_OK || !sec_ptr.s) { + LOG(ERROR) << "UCI failed to lookup ptr for path: " << sec_path << std::endl + << uci_get_error(ctx.get()); + return false; + } + + // Loop through the option within the found section + uci_element *elm = nullptr; + uci_foreach_element(&sec_ptr.s->options, elm) + { + uci_option *opt = uci_to_option(elm); + // Only type UCI_TYPE_STRING is supported + if (opt->type == UCI_TYPE_STRING) { + options[std::string(opt->e.name)] = opt->v.string; + } + } + return true; } From 0053c4e05037d099c455b6cf2769b30b2ac4c1bb Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Thu, 23 Jul 2020 11:20:11 +0000 Subject: [PATCH 400/453] framework: bpl: uci: Implement get_section_type function. The implementation of bpl_db_uci function utilizes the `libuci` functions that provides persistency of the configured data over UCI. Implemented the get_section_type API, the function retrieves the type of the found section. Relates to JIRA PPM-5. Signed-off-by: Itay Elenzweig --- framework/platform/bpl/uci/db/bpl_db_uci.cpp | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/framework/platform/bpl/uci/db/bpl_db_uci.cpp b/framework/platform/bpl/uci/db/bpl_db_uci.cpp index 248344c67e..d386ac4d07 100644 --- a/framework/platform/bpl/uci/db/bpl_db_uci.cpp +++ b/framework/platform/bpl/uci/db/bpl_db_uci.cpp @@ -285,6 +285,28 @@ bool uci_get_section_type(const std::string &package_name, const std::string &se //package_name.section_name LOG(TRACE) << "uci_get_section_type() " << package_name << "." << section_name; + auto ctx = alloc_context(); + if (!ctx) { + return false; + } + + char sec_path[MAX_UCI_BUF_LEN] = {0}; + // Generate a uci path to the section we wish to lookup + if (snprintf(sec_path, MAX_UCI_BUF_LEN, section_path, package_name.c_str(), + section_name.c_str()) <= 0) { + LOG(ERROR) << "Failed to compose path"; + return false; + } + + uci_ptr sec_ptr; + // Initialize section pointer from path & validate section existace + if (uci_lookup_ptr(ctx.get(), &sec_ptr, sec_path, true) != UCI_OK || !sec_ptr.s) { + LOG(ERROR) << "UCI failed to lookup ptr for path: " << sec_path << std::endl + << uci_get_error(ctx.get()); + return false; + } + + section_type = sec_ptr.s->type; return true; } From 4a9a28d8278a7f2937f6a3bfa3e36fc3e23fc95d Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Thu, 23 Jul 2020 11:20:20 +0000 Subject: [PATCH 401/453] framework: bpl: uci: Implement get_option function. The implementation of bpl_db_uci function utilizes the `libuci` functions that provides persistency of the configured data over UCI. Implemented the get_option API, the function retrieves the value of the requested option. Relates to JIRA PPM-5. Signed-off-by: Itay Elenzweig --- framework/platform/bpl/uci/db/bpl_db_uci.cpp | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/framework/platform/bpl/uci/db/bpl_db_uci.cpp b/framework/platform/bpl/uci/db/bpl_db_uci.cpp index d386ac4d07..c4892db353 100644 --- a/framework/platform/bpl/uci/db/bpl_db_uci.cpp +++ b/framework/platform/bpl/uci/db/bpl_db_uci.cpp @@ -318,6 +318,34 @@ bool uci_get_option(const std::string &package_name, const std::string §ion_ LOG(TRACE) << "uci_get_param() " << package_name << ".(" << section_type << ")" << section_name << "." << option_name; + if (!uci_section_exists(package_name, section_type, section_name)) { + LOG(ERROR) << "section " << section_name << " of type " << section_type + << " was not found!"; + return false; + } + + auto ctx = alloc_context(); + if (!ctx) { + return false; + } + + char opt_path[MAX_UCI_BUF_LEN] = {0}; + // Generate a uci path to the option we wish to lookup + if (snprintf(opt_path, MAX_UCI_BUF_LEN, option_path, package_name.c_str(), section_name.c_str(), + option_name.c_str()) <= 0) { + LOG(ERROR) << "Failed to compose path"; + return false; + } + + uci_ptr opt_ptr; + // Initialize option pointer from path & validate option existace + if (uci_lookup_ptr(ctx.get(), &opt_ptr, opt_path, true) != UCI_OK || !opt_ptr.o) { + LOG(ERROR) << "UCI failed to lookup ptr for path: " << opt_path << std::endl + << uci_get_error(ctx.get()); + return false; + } + + option_value = opt_ptr.o->v.string; return true; } From b1a551cb6129683b96780534edbf5cc459665ed4 Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Thu, 23 Jul 2020 11:20:32 +0000 Subject: [PATCH 402/453] framework: bpl: uci: Implement delete_section function. The implementation of bpl_db_uci function utilizes the `libuci` functions that provides persistency of the configured data over UCI. Implemented the delete_section API, the function searches and removes the found section. Relates to JIRA PPM-5. Signed-off-by: Itay Elenzweig --- framework/platform/bpl/uci/db/bpl_db_uci.cpp | 61 ++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/framework/platform/bpl/uci/db/bpl_db_uci.cpp b/framework/platform/bpl/uci/db/bpl_db_uci.cpp index c4892db353..d36366444f 100644 --- a/framework/platform/bpl/uci/db/bpl_db_uci.cpp +++ b/framework/platform/bpl/uci/db/bpl_db_uci.cpp @@ -356,6 +356,67 @@ bool uci_delete_section(const std::string &package_name, const std::string § LOG(TRACE) << "uci_delete_section() " << package_name << ".(" << section_type << ")" << section_name; + // Verify requested section exists + if (!uci_section_exists(package_name, section_type, section_name)) { + LOG(ERROR) << "section " << section_name << " of type " << section_type + << " was not found!"; + return false; + } + + auto ctx = alloc_context(); + if (!ctx) { + return false; + } + + char sec_path[MAX_UCI_BUF_LEN] = {0}; + // Generate a uci path to the section we wish to lookup + if (snprintf(sec_path, MAX_UCI_BUF_LEN, section_path, package_name.c_str(), + section_name.c_str()) <= 0) { + LOG(ERROR) << "Failed to compose path"; + return false; + } + + uci_ptr sec_ptr; + // Initialize section pointer from path & validate section existace + if (uci_lookup_ptr(ctx.get(), &sec_ptr, sec_path, true) != UCI_OK || !sec_ptr.s) { + LOG(ERROR) << "UCI failed to lookup ptr for path: " << sec_path << std::endl + << uci_get_error(ctx.get()); + return false; + } + + if (uci_delete(ctx.get(), &sec_ptr) != UCI_OK) { + LOG(ERROR) << "UCI failed to delete ptr: " << sec_path << std::endl + << uci_get_error(ctx.get()); + return false; + } + + char pkg_path[MAX_UCI_BUF_LEN] = {0}; + // Generate a uci path to the package we wish to lookup + if (snprintf(pkg_path, MAX_UCI_BUF_LEN, package_path, package_name.c_str()) <= 0) { + LOG(ERROR) << "Failed to compose path"; + return false; + } + + uci_ptr pkg_ptr; + // Initialize package pointer from path & validate package existace + if (uci_lookup_ptr(ctx.get(), &pkg_ptr, pkg_path, true) != UCI_OK || !pkg_ptr.p) { + LOG(ERROR) << "UCI failed to lookup ptr for path: " << pkg_path << std::endl + << uci_get_error(ctx.get()); + return false; + } + + // Create delta of changes, this does not change the persistent file. + if (uci_save(ctx.get(), pkg_ptr.p) != UCI_OK) { + LOG(ERROR) << "Failed to save changes!" << std::endl << uci_get_error(ctx.get()); + return false; + } + + // Commit changes to file + if (uci_commit(ctx.get(), &pkg_ptr.p, false) != UCI_OK) { + LOG(ERROR) << "Failed to commit changes!" << std::endl << uci_get_error(ctx.get()); + return false; + } + return true; } From bfb3852e5ebe939d0f0280be6a152cd2f379fda6 Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Thu, 23 Jul 2020 11:20:43 +0000 Subject: [PATCH 403/453] framework: bpl: uci: Implement get_all_sections function. The implementation of bpl_db_uci function utilizes the `libuci` functions that provides persistency of the configured data over UCI. Implemented the get_all_sections API, the function returns all the available sections names, if the type is specifiers only the sections with matching types are returned. Relates to JIRA PPM-5. Signed-off-by: Itay Elenzweig --- framework/platform/bpl/uci/db/bpl_db_uci.cpp | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/framework/platform/bpl/uci/db/bpl_db_uci.cpp b/framework/platform/bpl/uci/db/bpl_db_uci.cpp index d36366444f..9b238cc881 100644 --- a/framework/platform/bpl/uci/db/bpl_db_uci.cpp +++ b/framework/platform/bpl/uci/db/bpl_db_uci.cpp @@ -426,6 +426,36 @@ bool uci_get_all_sections(const std::string &package_name, const std::string &se //package_name.(section_type) LOG(TRACE) << "uci_get_all_sections() " << package_name << ".(" << section_type << ")"; + auto ctx = alloc_context(); + if (!ctx) { + return false; + } + + char pkg_path[MAX_UCI_BUF_LEN] = {0}; + // Generate a uci path to the package we wish to lookup + if (snprintf(pkg_path, MAX_UCI_BUF_LEN, package_path, package_name.c_str()) <= 0) { + LOG(ERROR) << "Failed to compose path"; + return false; + } + + uci_ptr pkg_ptr; + // Initialize package pointer from path & validate package existace + if (uci_lookup_ptr(ctx.get(), &pkg_ptr, pkg_path, true) != UCI_OK || !pkg_ptr.p) { + LOG(ERROR) << "UCI lookup failed for path: " << pkg_path << std::endl + << uci_get_error(ctx.get()); + return false; + } + + // Loop through all sections + uci_element *elm = nullptr; + uci_foreach_element(&pkg_ptr.p->sections, elm) + { + uci_section *sec = uci_to_section(elm); + // If section type matches add to result + if (section_type.empty() || section_type.compare(sec->type) == 0) { + sections.emplace_back(sec->e.name); + } + } return true; } From d2a410726677baeb0708bbc8c55b5e2e4e820745 Mon Sep 17 00:00:00 2001 From: Itay Elenzweig Date: Thu, 23 Jul 2020 11:21:14 +0000 Subject: [PATCH 404/453] framework: bpl: use the UCI APIs in the BPL DB. Utilize the newly implemented bpl_db_uci APIs in the bpl_db. The following functionality in the bpl_db is implemented: - db_has_entry - Check whether an entry exists in the DB. - db_add_entry - Adds a new entry to the DB & fills it with the provided parameters, if entry exists (even under different type) the function will fail. - db_set_entry - Set provided parameters for a given entry. If entry type is provided the entry must be of the same type. - db_get_entry - retrieve the matching entry's parameters from the DB. - db_get_entries_by_type - retrieve all entries with their values for a given entry type from the DB. If the type is not provided, retrieve all available entries. - db_remove_entry - remove an entry from the DB. Note that if an entry-type is provided, and entry type doesn't match the provided entry type, it will not be removed. Removed the unneeded cppcheck issues that were added before the implementation. Relates to JIRA PPM-5. Signed-off-by: Itay Elenzweig --- ci/cppcheck/cppcheck_existing_issues.txt | 2 - framework/platform/bpl/uci/db/bpl_db.cpp | 107 ++++++++++++++++++++--- 2 files changed, 96 insertions(+), 13 deletions(-) diff --git a/ci/cppcheck/cppcheck_existing_issues.txt b/ci/cppcheck/cppcheck_existing_issues.txt index c4e34e2a6f..499e1a4341 100644 --- a/ci/cppcheck/cppcheck_existing_issues.txt +++ b/ci/cppcheck/cppcheck_existing_issues.txt @@ -183,8 +183,6 @@ framework/platform/bpl/uci/arp/monitor/arp_monitor.cpp: style: Unused variable: framework/platform/bpl/uci/cfg/bpl_cfg.cpp: style: The scope of the variable 'retVal' can be reduced. [variableScope] int retVal = 0; framework/platform/bpl/uci/cfg/bpl_cfg.cpp: style: Variable 'retVal' is assigned a value that is never used. [unreadVariable] int retVal = 0; framework/platform/bpl/uci/cfg/bpl_cfg_uci.cpp: style: The scope of the variable 'scanf_res' can be reduced. [variableScope] int scanf_res; -framework/platform/bpl/uci/db/bpl_db.cpp: style: Parameter 'nested_params' can be declared with const [constParameter] std::unordered_map> &nested_params) -framework/platform/bpl/uci/db/bpl_db.cpp: style: Parameter 'params' can be declared with const [constParameter] std::unordered_map ¶ms) framework/platform/bpl/uci/dhcp/bpl_dhcp.cpp: style: struct member 'dhcp_event_request::data' is never used. [unusedStructMember] char data[]; framework/tlvf/test/tlvf_test.cpp: style: Local variable 'cmplx' shadows outer variable [shadowVariable] auto cmplx = std::get<1>(tlv4->complex_list(0)); framework/tlvf/test/tlvf_test.cpp: style: Local variable 'cmplx' shadows outer variable [shadowVariable] auto cmplx = std::get<1>(tlv4->complex_list(1)); diff --git a/framework/platform/bpl/uci/db/bpl_db.cpp b/framework/platform/bpl/uci/db/bpl_db.cpp index 1eeb912a5e..7b82b3e81c 100644 --- a/framework/platform/bpl/uci/db/bpl_db.cpp +++ b/framework/platform/bpl/uci/db/bpl_db.cpp @@ -6,7 +6,9 @@ * See LICENSE file for more details. */ -#include "bpl/bpl_db.h" +#include + +#include "bpl_db_uci.h" #include @@ -17,30 +19,82 @@ namespace beerocks { namespace bpl { +constexpr char DB_FILE[] = "prplmesh_db"; + bool db_has_entry(const std::string &entry_type, const std::string &entry_name) { - LOG(TRACE) << " - NOT IMPLEMENTED!"; - return false; + LOG(TRACE) << entry_type << ":" << entry_name; + + if (entry_name.empty()) { + LOG(ERROR) << "Entry name must be provided"; + return false; + } + return db::uci_section_exists(DB_FILE, entry_type, entry_name); } bool db_add_entry(const std::string &entry_type, const std::string &entry_name, const std::unordered_map ¶ms) { - LOG(TRACE) << " - NOT IMPLEMENTED!"; - return true; + LOG(TRACE) << entry_type << ":" << entry_name; + + if (entry_name.empty() || entry_type.empty()) { + LOG(ERROR) << "Entry name & type must be set"; + return false; + } + // Check if entry of the same name exists. + if (db::uci_section_exists(DB_FILE, "", entry_name)) { + LOG(ERROR) << "Entry " << entry_name << " already exists"; + return false; + } + if (!db::uci_add_section(DB_FILE, entry_type, entry_name)) { + LOG(ERROR) << "Failed to create entry " << entry_name << "!"; + return false; + } + LOG(DEBUG) << "Update entry " << entry_name << " with new values."; + return db::uci_set_section(DB_FILE, entry_type, entry_name, params); } bool db_set_entry(const std::string &entry_type, const std::string &entry_name, const std::unordered_map ¶ms) { - LOG(TRACE) << " - NOT IMPLEMENTED!"; - return true; + LOG(TRACE) << entry_type << ":" << entry_name; + + if (entry_name.empty()) { + LOG(ERROR) << "Entry name must be provided"; + return false; + } + if (!db::uci_section_exists(DB_FILE, entry_type, entry_name)) { + LOG(DEBUG) << "Entry " << entry_name + << (!entry_type.empty() ? std::string(" of type ") + entry_type : "") + << " not found!"; + return false; + } + // Update the new/existing entry + LOG(DEBUG) << "Update entry " << entry_name << " with new values."; + return db::uci_set_section(DB_FILE, entry_type, entry_name, params); } bool db_get_entry(const std::string &entry_type, const std::string &entry_name, std::unordered_map ¶ms) { - LOG(TRACE) << " - NOT IMPLEMENTED!"; + LOG(TRACE) << entry_type << ":" << entry_name; + + if (entry_name.empty()) { + LOG(ERROR) << "Entry name must be provided"; + return false; + } + if (params.size() == 0) { + // params map is empty, getting all parameters + return db::uci_get_section(DB_FILE, entry_type, entry_name, params); + } + for (auto ¶m : params) { + // params map is not empty, getting selected parameters + if (!db::uci_get_option(DB_FILE, entry_type, entry_name, param.first, param.second)) { + LOG(ERROR) << "Failed to get " << param.first; + // TODO: + return false; + } + } return true; } @@ -48,14 +102,45 @@ bool db_get_entries_by_type( const std::string &entry_type, std::unordered_map> &nested_params) { - LOG(TRACE) << " - NOT IMPLEMENTED!"; + LOG(TRACE) << entry_type; + + std::vector entries; + + if (!db::uci_get_all_sections(DB_FILE, entry_type, entries)) { + LOG(ERROR) << "Failed to get all entries"; + return false; + } + for (auto &entry_name : entries) { + std::unordered_map params; + if (!db::uci_get_section(DB_FILE, entry_type, entry_name, params)) { + LOG(ERROR) << "Failed to get entry " << entry_name; + return false; + } + // If the returning parameters are empty, there is not need to set. + if (!params.empty()) { + nested_params[entry_name] = std::move(params); + } + } + + LOG(DEBUG) << "Found " << nested_params.size() << " entries!"; return true; } bool db_remove_entry(const std::string &entry_type, const std::string &entry_name) { - LOG(TRACE) << " - NOT IMPLEMENTED!"; - return true; + LOG(TRACE) << entry_type << ":" << entry_name; + + if (entry_name.empty()) { + LOG(ERROR) << "Entry name must be provided"; + return false; + } + if (!db::uci_section_exists(DB_FILE, entry_type, entry_name)) { + LOG(DEBUG) << "Entry " << entry_name + << (!entry_type.empty() ? std::string(" of type ") + entry_type : "") + << " not found!"; + return true; + } + return db::uci_delete_section(DB_FILE, entry_type, entry_name); } } // namespace bpl From f71f7625a6653194e36b8f8d08911dcb6210c9a9 Mon Sep 17 00:00:00 2001 From: Ivan Efimov Date: Tue, 28 Jul 2020 20:18:34 +0500 Subject: [PATCH 405/453] bml: rdkb hal: enum elements names conflict with RDKB WiFi HAL ones There are two enums in bml_rdkb_defs.h: * BML_DISCONNECT_SOURCE * BML_DISCONNECT_TYPE which elements has the same names as next RDKB WiFi HAL enums * wifi_disconnectSource_t * wifi_disconnectType_t and conflict with them as a result See on GitHub: https://github.com/rdkcmf/rdkb-halinterface/blob/2fbb252ca52b81fa59edbe9b6461ab7d2eb33b23/wifi_hal.h#L7200 Add BML_ prefix for enum elements names There are no places in prplMesh where mentioned enums are used explicitly. So this commit changes are enough Signed-off-by: Ivan Efimov --- controller/src/beerocks/bml/rdkb/bml_rdkb_defs.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/controller/src/beerocks/bml/rdkb/bml_rdkb_defs.h b/controller/src/beerocks/bml/rdkb/bml_rdkb_defs.h index 47cd2a3cd1..972d3bcf93 100644 --- a/controller/src/beerocks/bml/rdkb/bml_rdkb_defs.h +++ b/controller/src/beerocks/bml/rdkb/bml_rdkb_defs.h @@ -92,15 +92,15 @@ struct BML_STEERING_RRM_CAPS { }; typedef enum { - DISCONNECT_SOURCE_UNKNOWN = 0, /**< Unknown source */ - DISCONNECT_SOURCE_LOCAL, /**< Initiated locally */ - DISCONNECT_SOURCE_REMOTE /**< Initiated remotely */ + BML_DISCONNECT_SOURCE_UNKNOWN = 0, /**< Unknown source */ + BML_DISCONNECT_SOURCE_LOCAL, /**< Initiated locally */ + BML_DISCONNECT_SOURCE_REMOTE /**< Initiated remotely */ } BML_DISCONNECT_SOURCE; typedef enum { - DISCONNECT_TYPE_UNKNOWN = 0, /**< Unknown type */ - DISCONNECT_TYPE_DISASSOC, /**< Disassociation */ - DISCONNECT_TYPE_DEAUTH /**< Deauthentication */ + BML_DISCONNECT_TYPE_UNKNOWN = 0, /**< Unknown type */ + BML_DISCONNECT_TYPE_DISASSOC, /**< Disassociation */ + BML_DISCONNECT_TYPE_DEAUTH /**< Deauthentication */ } BML_DISCONNECT_TYPE; /** From 666d3383801c993130d5d5957b618cac224c8500 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Tue, 28 Jul 2020 11:57:22 +0000 Subject: [PATCH 406/453] bml: BML_CLIENT: change sta_mac type from char to uint8_t The type of the mac address parameter is incorrect. Changed sta_mac from char[6] to uint8_t[6]. PPM-5. Signed-off-by: Itay Elenzweig Signed-off-by: Adam Dov --- controller/src/beerocks/bml/bml_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/src/beerocks/bml/bml_defs.h b/controller/src/beerocks/bml/bml_defs.h index 9e080d44ff..57ec4e71af 100644 --- a/controller/src/beerocks/bml/bml_defs.h +++ b/controller/src/beerocks/bml/bml_defs.h @@ -599,7 +599,7 @@ struct BML_CLIENT_CONFIG { struct BML_CLIENT { // Client MAC. - char sta_mac[BML_MAC_ADDR_LEN]; + uint8_t sta_mac[BML_MAC_ADDR_LEN]; // Time of last client configuration edit (in Seconds) uint32_t timestamp_sec; From 73004040d2f3446ef8938f610c67290293185dcc Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Tue, 28 Jul 2020 12:12:55 +0000 Subject: [PATCH 407/453] beerocks_cli_bml: Fix client APIs - In client_set_client changed incoming type from INT_ARG to STRING_ARG. To use parameters as optional parameters, we need to retrieve them from the CLI as strings and convert them to integers. - Added int conversion in the client_set_client LOG print. To print the incoming values in client_set_client, need to convert them to type int, otherwise, they will be printed as Char. - Added tlvf::mac_to_string in the client_get_client LOG print. The received mac address needs to be converted to a readable format to be printed. PPM-5. Signed-off-by: Itay Elenzweig --- controller/src/beerocks/cli/beerocks_cli_bml.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/controller/src/beerocks/cli/beerocks_cli_bml.cpp b/controller/src/beerocks/cli/beerocks_cli_bml.cpp index 7883fe482b..42d7afe154 100644 --- a/controller/src/beerocks/cli/beerocks_cli_bml.cpp +++ b/controller/src/beerocks/cli/beerocks_cli_bml.cpp @@ -563,8 +563,8 @@ void cli_bml::setFunctionsMapAndArray() " selected_bands - Bitwise parameter, 1 for 2.4G, 2 for 5G, 3 for both, 0 for Disabled" " stay_on_initial_radio - 1 for true, 0 for false or (default) -1 for not configured," " stay_on_selected_device - 1 for true, 0 for false or (default) -1 for not configured", - static_cast(&cli_bml::client_set_client_caller), 2, 4, STRING_ARG, INT_ARG, - INT_ARG, INT_ARG); + static_cast(&cli_bml::client_set_client_caller), 2, 4, STRING_ARG, STRING_ARG, + STRING_ARG, STRING_ARG); insertCommandToMap("bml_client_get_client", "", "Get client with the given STA MAC.", static_cast(&cli_bml::client_get_client_caller), 1, 1, STRING_ARG); @@ -2230,9 +2230,9 @@ int cli_bml::client_set_client(const std::string &sta_mac, int8_t selected_bands { std::cout << "client_set_client: " << std::endl << " sta_mac: " << sta_mac << std::endl - << " selected_bands: " << selected_bands << std::endl - << " stay_on_initial_radio: " << stay_on_initial_radio << std::endl - << " stay_on_selected_device: " << stay_on_selected_device << std::endl; + << " selected_bands: " << int(selected_bands) << std::endl + << " stay_on_initial_radio: " << int(stay_on_initial_radio) << std::endl + << " stay_on_selected_device: " << int(stay_on_selected_device) << std::endl; BML_CLIENT_CONFIG cfg{ .stay_on_initial_radio = stay_on_initial_radio, @@ -2285,7 +2285,7 @@ int cli_bml::client_get_client(const std::string &sta_mac) return ret; }; - std::cout << "client: " << client.sta_mac << std::endl + std::cout << "client: " << tlvf::mac_to_string(client.sta_mac) << std::endl << " timestamp_sec: " << client.timestamp_sec << std::endl << " stay_on_initial_radio: " << client_bool_print(client.stay_on_initial_radio) << std::endl From 29f92ed4fa3b1939cfed1dcc83382f648ddabcd3 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Tue, 28 Jul 2020 12:29:25 +0000 Subject: [PATCH 408/453] controller: bml: fix return values Changed returning error values in the code to a negative values as expected by the BML. PPM-5. Signed-off-by: Itay Elenzweig Signed-off-by: Adam Dov --- controller/src/beerocks/bml/internal/bml_internal.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/controller/src/beerocks/bml/internal/bml_internal.cpp b/controller/src/beerocks/bml/internal/bml_internal.cpp index 43f5e6e84f..45f8293af0 100644 --- a/controller/src/beerocks/bml/internal/bml_internal.cpp +++ b/controller/src/beerocks/bml/internal/bml_internal.cpp @@ -1141,13 +1141,13 @@ int bml_internal::process_cmdu_header(std::shared_ptr beerocks_ ->addClass(); if (!response) { LOG(ERROR) << "addClass cACTION_BML_CLIENT_GET_CLIENT_LIST_RESPONSE failed"; - return BML_RET_OP_FAILED; + return (-BML_RET_OP_FAILED); } if (!m_client_list || !m_client_list_size) { LOG(ERROR) << "The pointer to the user data buffer is null!"; m_prmClientListGet->set_value(false); - break; + return (-BML_RET_INVALID_ARGS); } if (response->result() != 0) { @@ -1195,7 +1195,7 @@ int bml_internal::process_cmdu_header(std::shared_ptr beerocks_ ->addClass(); if (!response) { LOG(ERROR) << "addClass cACTION_BML_CLIENT_SET_CLIENT_RESPONSE failed"; - return BML_RET_OP_FAILED; + return (-BML_RET_OP_FAILED); } ///Signal any waiting threads @@ -1212,7 +1212,7 @@ int bml_internal::process_cmdu_header(std::shared_ptr beerocks_ ->addClass(); if (!response) { LOG(ERROR) << "addClass cACTION_BML_CLIENT_GET_CLIENT_RESPONSE failed"; - return BML_RET_OP_FAILED; + return (-BML_RET_OP_FAILED); } //Signal any waiting threads @@ -1931,7 +1931,7 @@ int bml_internal::client_get_client_list(char *client_list, unsigned int *client LOG(DEBUG) << "Promise resolved, received " << client_mac_list.size() << " clients"; if (!result) { LOG(ERROR) << "Get client list request failed"; - return -BML_RET_OP_FAILED; + return (-BML_RET_OP_FAILED); } // Translate sMacAddr list to string From 57ec6b0cded912e32cf3320979dd0296c1f21909 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Wed, 29 Jul 2020 15:01:59 +0000 Subject: [PATCH 409/453] bml: cli: fix selected_bands debug prints Removed excess spaces from selected-bands debug print. PPM-5. Signed-off-by: Adam Dov --- controller/src/beerocks/cli/beerocks_cli_bml.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/controller/src/beerocks/cli/beerocks_cli_bml.cpp b/controller/src/beerocks/cli/beerocks_cli_bml.cpp index 42d7afe154..885d72720d 100644 --- a/controller/src/beerocks/cli/beerocks_cli_bml.cpp +++ b/controller/src/beerocks/cli/beerocks_cli_bml.cpp @@ -2270,13 +2270,13 @@ int cli_bml::client_get_client(const std::string &sta_mac) if (val == BML_CLIENT_SELECTED_BANDS_DISABLED) return "Disabled"; if (val & BML_CLIENT_SELECTED_BANDS_24G) - ret += "2.4 Ghz,"; + ret += "2.4GHz,"; if (val & BML_CLIENT_SELECTED_BANDS_5G) - ret += "5 Ghz,"; + ret += "5GHz,"; if (val & BML_CLIENT_SELECTED_BANDS_6G) - ret += "6 Ghz,"; + ret += "6GHz,"; if (val & BML_CLIENT_SELECTED_BANDS_60G) - ret += "60 Ghz,"; + ret += "60GHz,"; // remove ending comma if (!ret.empty() && (ret.back() == ',')) { From e5dae02aae092a826a187f7bb3de278250a2ed03 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Wed, 29 Jul 2020 14:23:13 +0000 Subject: [PATCH 410/453] bml: remove the unsupported stay_on_selected_device The introduction of the stay_on_selected_device configuration, its DB support, and utilization delayed to the next phase of the smart-steering feature. Removed the stay_on_selected_device from the BML interface - from set_client and get_client APIs related structs. Removed the stay_on_selected_device from the BML CLI interface - both from set_client and get_client CLI functions. Note that the stay_on_selected_device infrastructure in the BML message to/from the controller is not removed, but not used. PPM-5. Signed-off-by: Adam Dov --- controller/src/beerocks/bml/bml_defs.h | 6 ---- .../beerocks/bml/internal/bml_internal.cpp | 19 ++++++----- .../src/beerocks/cli/beerocks_cli_bml.cpp | 33 ++++++------------- .../src/beerocks/cli/beerocks_cli_bml.h | 2 +- 4 files changed, 22 insertions(+), 38 deletions(-) diff --git a/controller/src/beerocks/bml/bml_defs.h b/controller/src/beerocks/bml/bml_defs.h index 57ec4e71af..480d377c44 100644 --- a/controller/src/beerocks/bml/bml_defs.h +++ b/controller/src/beerocks/bml/bml_defs.h @@ -589,9 +589,6 @@ struct BML_CLIENT_CONFIG { // 1 for true, 0 for false, -1 for "not configured". int8_t stay_on_initial_radio; - // 1 for true, 0 for false, -1 for "not configured". - int8_t stay_on_selected_device; - // Bitwise value of selected bands for the client. // Correlates to BML_CLIENT_SELECTED_BANDS int8_t selected_bands; @@ -610,9 +607,6 @@ struct BML_CLIENT { // 1 for true, 0 for false, -1 for "not configured". int8_t stay_on_initial_radio; - // 1 for true, 0 for false, -1 for "not configured". - int8_t stay_on_selected_device; - // Bitwise value of selected bands for the client. // Correlates to BML_CLIENT_SELECTED_BANDS int8_t selected_bands; diff --git a/controller/src/beerocks/bml/internal/bml_internal.cpp b/controller/src/beerocks/bml/internal/bml_internal.cpp index 45f8293af0..ff6660473f 100644 --- a/controller/src/beerocks/bml/internal/bml_internal.cpp +++ b/controller/src/beerocks/bml/internal/bml_internal.cpp @@ -1221,11 +1221,12 @@ int bml_internal::process_cmdu_header(std::shared_ptr beerocks_ if (m_client) { std::copy_n(response->client().sta_mac.oct, BML_MAC_ADDR_LEN, m_client->sta_mac); - m_client->timestamp_sec = response->client().timestamp_sec; - m_client->stay_on_initial_radio = response->client().stay_on_initial_radio; - m_client->stay_on_selected_device = response->client().stay_on_selected_device; - m_client->selected_bands = response->client().selected_bands; - m_client->time_life_delay_days = response->client().time_life_delay_days; + m_client->timestamp_sec = response->client().timestamp_sec; + m_client->stay_on_initial_radio = response->client().stay_on_initial_radio; + // TODO: add stay_on_selected_device to BML_CLIENT when support is added + //m_client->stay_on_selected_device = response->client().stay_on_selected_device; + m_client->selected_bands = response->client().selected_bands; + m_client->time_life_delay_days = response->client().time_life_delay_days; //Resolve promise to "true" promise_result = true; } @@ -1963,9 +1964,11 @@ int bml_internal::client_set_client(const sMacAddr &sta_mac, const BML_CLIENT_CO return (-BML_RET_OP_FAILED); } - request->sta_mac() = sta_mac; - request->client_config().stay_on_initial_radio = client_config.stay_on_initial_radio; - request->client_config().stay_on_selected_device = client_config.stay_on_selected_device; + request->sta_mac() = sta_mac; + request->client_config().stay_on_initial_radio = client_config.stay_on_initial_radio; + // TODO: add stay_on_selected_device to BML_CLIENT when support is added + // currently, it is only available as infrastructure in the request/response message + request->client_config().stay_on_selected_device = PARAMETER_NOT_CONFIGURED; request->client_config().selected_bands = client_config.selected_bands; int result = 0; diff --git a/controller/src/beerocks/cli/beerocks_cli_bml.cpp b/controller/src/beerocks/cli/beerocks_cli_bml.cpp index 885d72720d..d8f16c6b6a 100644 --- a/controller/src/beerocks/cli/beerocks_cli_bml.cpp +++ b/controller/src/beerocks/cli/beerocks_cli_bml.cpp @@ -561,10 +561,9 @@ void cli_bml::setFunctionsMapAndArray() "bml_client_set_client", " []", "Set client with the given STA MAC:" " selected_bands - Bitwise parameter, 1 for 2.4G, 2 for 5G, 3 for both, 0 for Disabled" - " stay_on_initial_radio - 1 for true, 0 for false or (default) -1 for not configured," - " stay_on_selected_device - 1 for true, 0 for false or (default) -1 for not configured", - static_cast(&cli_bml::client_set_client_caller), 2, 4, STRING_ARG, STRING_ARG, - STRING_ARG, STRING_ARG); + " stay_on_initial_radio - 1 for true, 0 for false or (default) -1 for not configured,", + static_cast(&cli_bml::client_set_client_caller), 2, 3, STRING_ARG, STRING_ARG, + STRING_ARG); insertCommandToMap("bml_client_get_client", "", "Get client with the given STA MAC.", static_cast(&cli_bml::client_get_client_caller), 1, 1, STRING_ARG); @@ -1345,13 +1344,11 @@ int cli_bml::client_set_client_caller(int numOfArgs) * Optional: * selected_bands= * stay_on_initial_radio= - * stay_on_selected_device= ]*/ std::string::size_type pos; std::string sta_mac(network_utils::WILD_MAC_STRING); - int8_t selected_bands = BML_PARAMETER_NOT_CONFIGURED; - int8_t stay_on_initial_radio = BML_PARAMETER_NOT_CONFIGURED; - int8_t stay_on_selected_device = BML_PARAMETER_NOT_CONFIGURED; + int8_t selected_bands = BML_PARAMETER_NOT_CONFIGURED; + int8_t stay_on_initial_radio = BML_PARAMETER_NOT_CONFIGURED; if (numOfArgs > 1) { sta_mac = args.stringArgs[0]; for (int i = 1; i < numOfArgs; i++) { //first optional arg @@ -1362,14 +1359,9 @@ int cli_bml::client_set_client_caller(int numOfArgs) std::string::npos) { stay_on_initial_radio = string_utils::stoi( args.stringArgs[i].substr(pos + sizeof("stay_on_initial_radio"))); - } else if ((pos = args.stringArgs[i].find("stay_on_selected_device=")) != - std::string::npos) { - stay_on_selected_device = string_utils::stoi( - args.stringArgs[i].substr(pos + sizeof("stay_on_selected_device"))); } } - return client_set_client(sta_mac, selected_bands, stay_on_initial_radio, - stay_on_selected_device); + return client_set_client(sta_mac, selected_bands, stay_on_initial_radio); } return -1; } @@ -2222,22 +2214,19 @@ int cli_bml::client_get_client_list() * @param [in] sta_mac MAC address of requested client. * @param [in] selected_bands comma-seperated selected bands. * @param [in] stay_on_initial_radio Whather to stay on initial radio or not. - * @param [in] stay_on_selected_device Whather to stay on selected device or not. * @return 0 on success. */ int cli_bml::client_set_client(const std::string &sta_mac, int8_t selected_bands, - int8_t stay_on_initial_radio, int8_t stay_on_selected_device) + int8_t stay_on_initial_radio) { std::cout << "client_set_client: " << std::endl << " sta_mac: " << sta_mac << std::endl << " selected_bands: " << int(selected_bands) << std::endl - << " stay_on_initial_radio: " << int(stay_on_initial_radio) << std::endl - << " stay_on_selected_device: " << int(stay_on_selected_device) << std::endl; + << " stay_on_initial_radio: " << int(stay_on_initial_radio) << std::endl; BML_CLIENT_CONFIG cfg{ - .stay_on_initial_radio = stay_on_initial_radio, - .stay_on_selected_device = stay_on_selected_device, - .selected_bands = selected_bands, + .stay_on_initial_radio = stay_on_initial_radio, + .selected_bands = selected_bands, }; int ret = bml_client_set_client(ctx, sta_mac.c_str(), &cfg); @@ -2289,8 +2278,6 @@ int cli_bml::client_get_client(const std::string &sta_mac) << " timestamp_sec: " << client.timestamp_sec << std::endl << " stay_on_initial_radio: " << client_bool_print(client.stay_on_initial_radio) << std::endl - << " stay_on_selected_device: " - << client_bool_print(client.stay_on_selected_device) << std::endl << " selected_bands: " << client_selected_bands_print(client.selected_bands) << std::endl << " single_band: " << client_bool_print(client.single_band) << std::endl diff --git a/controller/src/beerocks/cli/beerocks_cli_bml.h b/controller/src/beerocks/cli/beerocks_cli_bml.h index a368d1c382..a3055e77db 100644 --- a/controller/src/beerocks/cli/beerocks_cli_bml.h +++ b/controller/src/beerocks/cli/beerocks_cli_bml.h @@ -216,7 +216,7 @@ class cli_bml : public cli { bool is_single_scan = false); int client_get_client_list(); int client_set_client(const std::string &sta_mac, int8_t selected_bands, - int8_t stay_on_initial_radio, int8_t stay_on_selected_device); + int8_t stay_on_initial_radio); int client_get_client(const std::string &sta_mac); template const std::string string_from_int_array(T *arr, size_t arr_max_size); // Variable From eb2b7923fa937369a34e8fcec30714984340142c Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Tue, 28 Jul 2020 12:53:10 +0000 Subject: [PATCH 411/453] controller: bml: refactor client_get_client Added verification of "is someone waiting for the promise" before handling the response. Implement the function with error-handling first according to the agreed coding guidelines. Fixed broken return-on-error in the "get_client" implementation. PPM-5. Signed-off-by: Itay Elenzweig Signed-off-by: Adam Dov --- .../beerocks/bml/internal/bml_internal.cpp | 58 ++++++++++++------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/controller/src/beerocks/bml/internal/bml_internal.cpp b/controller/src/beerocks/bml/internal/bml_internal.cpp index ff6660473f..8c138e567f 100644 --- a/controller/src/beerocks/bml/internal/bml_internal.cpp +++ b/controller/src/beerocks/bml/internal/bml_internal.cpp @@ -1207,6 +1207,13 @@ int bml_internal::process_cmdu_header(std::shared_ptr beerocks_ } break; case beerocks_message::ACTION_BML_CLIENT_GET_CLIENT_RESPONSE: { LOG(DEBUG) << "ACTION_BML_CLIENT_GET_CLIENT_RESPONSE received"; + + if (!m_prmClientGet) { + LOG(WARNING) << "Received ACTION_BML_CLIENT_GET_CLIENT_RESPONSE response, " + << "but no one is waiting..."; + break; + } + auto response = beerocks_header ->addClass(); @@ -1215,26 +1222,29 @@ int bml_internal::process_cmdu_header(std::shared_ptr beerocks_ return (-BML_RET_OP_FAILED); } - //Signal any waiting threads - if (m_prmClientGet) { - bool promise_result = false; - if (m_client) { - std::copy_n(response->client().sta_mac.oct, BML_MAC_ADDR_LEN, - m_client->sta_mac); - m_client->timestamp_sec = response->client().timestamp_sec; - m_client->stay_on_initial_radio = response->client().stay_on_initial_radio; - // TODO: add stay_on_selected_device to BML_CLIENT when support is added - //m_client->stay_on_selected_device = response->client().stay_on_selected_device; - m_client->selected_bands = response->client().selected_bands; - m_client->time_life_delay_days = response->client().time_life_delay_days; - //Resolve promise to "true" - promise_result = true; - } - m_prmClientGet->set_value(promise_result); - } else { - LOG(WARNING) << "Received ACTION_BML_CLIENT_GET_CLIENT_RESPONSE response, " - << "but no one is waiting..."; + if (response->result() != 0) { + LOG(ERROR) << "CLIENT_GET_CLIENT_REQUEST failed with error: " << response->result(); + m_prmClientGet->set_value(false); + break; + } + + if (!m_client) { + LOG(ERROR) << "The pointer to the user client data is null!"; + m_prmClientGet->set_value(false); + break; } + + std::copy_n(response->client().sta_mac.oct, BML_MAC_ADDR_LEN, m_client->sta_mac); + m_client->timestamp_sec = response->client().timestamp_sec; + m_client->stay_on_initial_radio = response->client().stay_on_initial_radio; + // TODO: add stay_on_selected_device to BML_CLIENT when support is added + //m_client->stay_on_selected_device = response->client().stay_on_selected_device; + m_client->selected_bands = response->client().selected_bands; + m_client->single_band = response->client().single_band; + m_client->time_life_delay_days = response->client().time_life_delay_days; + + //Resolve promise to "true" + m_prmClientGet->set_value(true); } break; default: { LOG(WARNING) << "unhandled header BML action type 0x" << std::hex @@ -2036,7 +2046,15 @@ int bml_internal::client_get_client(const sMacAddr &sta_mac, BML_CLIENT *client) // Clear the promise holder m_prmClientGet = nullptr; - LOG_IF(iRet != BML_RET_OK, ERROR) << "Get client request returned with error code:" << iRet; + if (iRet != BML_RET_OK) { + LOG(ERROR) << "Get client request returned with error code:" << iRet; + return (iRet); + } + + if (!prmClientGet.get_value()) { + LOG(ERROR) << "Get client request failed"; + return (-BML_RET_OP_FAILED); + } return BML_RET_OK; } From 84d7f0e19171538f97087ea9157072556eedf1ad Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Tue, 28 Jul 2020 13:19:39 +0000 Subject: [PATCH 412/453] controller: bml: validate set_client input parameters The BML APIs provide an optional-parameters interface, meaning the user can use the API with some of the parameters set to "NOT_CONFIGURED" value, and these parameters not configured in the DB. However, using the API with all the parameters set to "NOT_CONFIGURED" value is not a valid case and should be handled as an error. Added verification that at least one of the given parameters not set to "NOT_CONFIGURED" value. PPM-5. Signed-off-by: Itay Elenzweig Signed-off-by: Adam Dov --- controller/src/beerocks/bml/internal/bml_internal.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/controller/src/beerocks/bml/internal/bml_internal.cpp b/controller/src/beerocks/bml/internal/bml_internal.cpp index 8c138e567f..4756d8b0aa 100644 --- a/controller/src/beerocks/bml/internal/bml_internal.cpp +++ b/controller/src/beerocks/bml/internal/bml_internal.cpp @@ -1965,6 +1965,12 @@ int bml_internal::client_set_client(const sMacAddr &sta_mac, const BML_CLIENT_CO { LOG(DEBUG) << "client_set_client"; + if ((client_config.stay_on_initial_radio == BML_PARAMETER_NOT_CONFIGURED) && + (client_config.selected_bands == BML_PARAMETER_NOT_CONFIGURED)) { + LOG(WARNING) << "No parameter is requested to be configured, returning"; + return (-BML_RET_INVALID_ARGS); + } + auto request = message_com::create_vs_message( cmdu_tx); From da8a4853f067df0c1cb7a91a1a744da770a6d7a5 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Wed, 22 Jul 2020 05:37:57 +0000 Subject: [PATCH 413/453] controller: db: change aging check to use the remaining time The current condition of comparing the client's passed-timelife-delay against max-timelife-delay is correct but doesn't reflect the actual logic behind it which is "is remaining timelife over". This change enables a more coherent comparison of current-client-remaining-timelife-delay against a candidate-client-for-removal-timelife-delay (if the DB is full). Changed the aging condition to "client-remaining-time < 0". PPM-5. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index 39fab4c7d4..abaffaecd9 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -2889,7 +2889,8 @@ bool db::load_persistent_db_clients() * 2.b. Is "unfriendly" something we know at boot? */ static const int max_timelife_delay_sec = config.max_timelife_delay_days * 24 * 3600; - if (client_timelife_passed_sec > max_timelife_delay_sec) { + auto client_remaining_timelife_sec = max_timelife_delay_sec - client_timelife_passed_sec; + if (client_remaining_timelife_sec <= 0) { LOG(ERROR) << "Invalid entry - configured data has aged for client entry " << client_entry; // Calling BPL API directly as there's no need to increment/decrement counter at this point From 227e127f529a028ff0be9d557a0015866fa6a23e Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Wed, 22 Jul 2020 07:17:33 +0000 Subject: [PATCH 414/453] controller: db: change client_db_entry_to_mac to get a copy The current client_db_entry_to_mac receives a const& to the mac address and internally makes a copy to perform an in-place replacement of characters. Changed the function to receive a copy instead of a const& and changed the implementation accordingly. PPM-5. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 10 ++++------ controller/src/beerocks/master/db/db.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index abaffaecd9..ab29d8a11e 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -59,17 +59,15 @@ std::string db::client_db_entry_from_mac(const sMacAddr &mac) return db_entry; } -sMacAddr db::client_db_entry_to_mac(const std::string &db_entry) +sMacAddr db::client_db_entry_to_mac(std::string db_entry) { - std::string entry = db_entry; + std::replace(db_entry.begin(), db_entry.end(), '_', ':'); - std::replace(entry.begin(), entry.end(), '_', ':'); - - if (!network_utils::is_valid_mac(entry)) { + if (!network_utils::is_valid_mac(db_entry)) { return network_utils::ZERO_MAC; } - return tlvf::mac_from_string(entry); + return tlvf::mac_from_string(db_entry); } std::string db::timestamp_to_string_seconds(const std::chrono::steady_clock::time_point timestamp) diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index 35b212a91d..c1ea1f56f2 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -196,7 +196,7 @@ class db { * @param db_entry Client entry name in persistent db. * @return sMacAddr MAC address of the client the db_entry is representing. On failure ZERO_MAC is returned. */ - static sMacAddr client_db_entry_to_mac(const std::string &db_entry); + static sMacAddr client_db_entry_to_mac(std::string db_entry); /** * @brief Get string representation of number of seconds in timestamp. From e8f6ea60ed5888e0f05e1996b2a6e376e3cb0902 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Wed, 22 Jul 2020 08:34:39 +0000 Subject: [PATCH 415/453] controller: db: add `using ValuesMap` for cleaner code Added `using ValuesMap = std::unordered_map` and replaced DB APIs and private function to use the new `ValuesMap` instead of `std::unordered_map`. The above change is a fix to comment raised in a previous PR, and it results in much cleaner code. PPM-5. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 30 ++++++++++-------------- controller/src/beerocks/master/db/db.h | 22 ++++++++--------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index ab29d8a11e..3e38d2868e 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -2380,8 +2380,7 @@ bool db::is_client_in_persistent_db(const sMacAddr &mac) return bpl::db_has_entry(type_to_string(beerocks::eType::TYPE_CLIENT), client_db_entry); } -bool db::add_client_to_persistent_db(const sMacAddr &mac, - const std::unordered_map ¶ms) +bool db::add_client_to_persistent_db(const sMacAddr &mac, const ValuesMap ¶ms) { // if persistent db is disabled if (!config.persistent_db) { @@ -2459,7 +2458,7 @@ bool db::set_client_time_life_delay(const sMacAddr &mac, } else { LOG(DEBUG) << "configuring persistent-db, timelife = " << time_life_delay_sec.count(); - std::unordered_map values_map; + ValuesMap values_map; values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); values_map[TIMELIFE_DELAY_STR] = std::to_string(time_life_delay_sec.count()); @@ -2508,7 +2507,7 @@ bool db::set_client_stay_on_initial_radio(const sMacAddr &mac, bool stay_on_init LOG(DEBUG) << "configuring persistent-db, initial_radio_enable = " << stay_on_initial_radio; - std::unordered_map values_map; + ValuesMap values_map; values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); values_map[INITIAL_RADIO_ENABLE_STR] = std::to_string(stay_on_initial_radio); @@ -2557,7 +2556,7 @@ bool db::set_client_initial_radio(const sMacAddr &mac, const sMacAddr &initial_r } else { LOG(DEBUG) << "configuring persistent-db, initial_radio = " << initial_radio_mac; - std::unordered_map values_map; + ValuesMap values_map; values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); values_map[INITIAL_RADIO_STR] = tlvf::mac_to_string(initial_radio_mac); @@ -2606,7 +2605,7 @@ bool db::set_client_stay_on_selected_band(const sMacAddr &mac, bool stay_on_sele LOG(DEBUG) << "configuring persistent-db, selected_band_enable = " << stay_on_selected_band; - std::unordered_map values_map; + ValuesMap values_map; values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); values_map[SELECTED_BAND_ENABLE_STR] = std::to_string(stay_on_selected_band); @@ -2655,7 +2654,7 @@ bool db::set_client_selected_bands(const sMacAddr &mac, beerocks::eFreqType sele } else { LOG(DEBUG) << ", configuring persistent-db, selected_bands = " << int(selected_bands); - std::unordered_map values_map; + ValuesMap values_map; values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); values_map[SELECTED_BANDS_STR] = std::to_string(selected_bands); @@ -2741,7 +2740,7 @@ bool db::update_client_persistent_db(const sMacAddr &mac) return true; } - std::unordered_map values_map; + ValuesMap values_map; //fill values map of client persistent params values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(node->client_parameters_last_edit); @@ -2797,7 +2796,7 @@ bool db::load_persistent_db_clients() return false; } - std::unordered_map> clients; + std::unordered_map clients; if (!bpl::db_get_entries_by_type(type_to_string(beerocks::eType::TYPE_CLIENT), clients)) { LOG(ERROR) << "Failed to get all clients from persistent DB"; return false; @@ -2820,8 +2819,7 @@ bool db::load_persistent_db_clients() // Add node for client and fill with persistent data. auto add_new_client_with_persistent_data_to_nodes_list = - [&](const sMacAddr &client_mac, - const std::unordered_map values_map) -> bool { + [&](const sMacAddr &client_mac, const ValuesMap values_map) -> bool { // Add client node with defaults and in default location if (!add_node(client_mac)) { LOG(ERROR) << "Failed to add client node for client_entry " << client_entry; @@ -4221,8 +4219,7 @@ void db::set_prplmesh(const sMacAddr &mac) get_node(mac)->is_prplmesh = true; } -bool db::update_client_entry_in_persistent_db( - const sMacAddr &mac, const std::unordered_map &values_map) +bool db::update_client_entry_in_persistent_db(const sMacAddr &mac, const ValuesMap &values_map) { auto db_entry = client_db_entry_from_mac(mac); auto type_client_str = type_to_string(beerocks::eType::TYPE_CLIENT); @@ -4240,8 +4237,7 @@ bool db::update_client_entry_in_persistent_db( return true; } -bool db::set_node_params_from_map(const sMacAddr &mac, - const std::unordered_map &values_map) +bool db::set_node_params_from_map(const sMacAddr &mac, const ValuesMap &values_map) { auto node = get_node(mac); if (!node) { @@ -4288,8 +4284,8 @@ bool db::set_node_params_from_map(const sMacAddr &mac, return true; } -bool db::add_client_entry_and_update_counter( - const std::string &entry_name, const std::unordered_map &values_map) +bool db::add_client_entry_and_update_counter(const std::string &entry_name, + const ValuesMap &values_map) { if (!bpl::db_add_entry(type_to_string(beerocks::eType::TYPE_CLIENT), entry_name, values_map)) { LOG(ERROR) << "failed to add client entry " << entry_name << " to persistent db"; diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index c1ea1f56f2..ad00bc6897 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -45,6 +45,11 @@ class db { } sBmlListener; public: + /** + * @brief An unordered map of parameters and their values. + */ + using ValuesMap = std::unordered_map; + /** * @brief Client parameter names. * The parameter names can be used to set/get multiple parameters in one-shot. @@ -652,12 +657,10 @@ class db { * @brief Adds a client to the persistent db, if already exists, remove old entry and add a new one. * * @param mac MAC address of a client. - * @param params An unordered map of key-value of client parameters. + * @param params An unordered map of key-value of client parameters and their values. * @return true on success, otherwise false. */ - bool add_client_to_persistent_db(const sMacAddr &mac, - const std::unordered_map ¶ms = - std::unordered_map()); + bool add_client_to_persistent_db(const sMacAddr &mac, const ValuesMap ¶ms = {}); /** * @brief Get the client's parameters last edit time. @@ -1091,8 +1094,7 @@ class db { * @param values_map A map of client params and their values. * @return true on success, otherwise false. */ - bool update_client_entry_in_persistent_db( - const sMacAddr &mac, const std::unordered_map &values_map); + bool update_client_entry_in_persistent_db(const sMacAddr &mac, const ValuesMap &values_map); /** * @brief Sets the node params (runtime db) from a param-value map. @@ -1101,8 +1103,7 @@ class db { * @param values_map A map of client params and their values. * @return true on success, otherwise false. */ - bool set_node_params_from_map(const sMacAddr &mac, - const std::unordered_map &values_map); + bool set_node_params_from_map(const sMacAddr &mac, const ValuesMap &values_map); /** * @brief Adds a client entry to persistent_db with configured parameters and increments clients counter. @@ -1111,9 +1112,8 @@ class db { * @param values_map A map of client params and their values. * @return true on success, otherwise false. */ - bool add_client_entry_and_update_counter( - const std::string &entry_name, - const std::unordered_map &values_map); + bool add_client_entry_and_update_counter(const std::string &entry_name, + const ValuesMap &values_map); /** * @brief Removes a client entry from persistent_db and decrements clients counter. From 83a15ae7aae3b64b2851fd6282a9c8e5187ce658 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Thu, 23 Jul 2020 23:02:32 +0000 Subject: [PATCH 416/453] controller: db: change selected_bands type The current implementation of selected bands mistakenly used the existing beerocks::eFreqType as the storage type. This is not extensible and doesn't define the full possible configurations. Moreover, by using the newly introduced eClientSelectedBands instead, which is used in the BML<->controller messaging, we can simplify the set and get operations and any future extension of supported values. Changed in node class the storage type of the selected bands and its description. Changed the DB APIs to use the int8_t instead of beerocks::eFreqType. Changed the selected bands` default value from beerocks::eFreqType::FREQ_UNKNOWN to beerocks::PARAMETER_NOT_CONFIGURED. PPM-5. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 14 +++++++------- controller/src/beerocks/master/db/db.h | 8 ++++---- controller/src/beerocks/master/db/node.h | 5 +++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index 3e38d2868e..15f5cffdcd 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -2635,7 +2635,7 @@ eTriStateBool db::get_client_stay_on_selected_band(const sMacAddr &mac) return node->client_stay_on_selected_band; } -bool db::set_client_selected_bands(const sMacAddr &mac, beerocks::eFreqType selected_bands, +bool db::set_client_selected_bands(const sMacAddr &mac, int8_t selected_bands, bool save_to_persistent_db) { auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); @@ -2652,7 +2652,7 @@ bool db::set_client_selected_bands(const sMacAddr &mac, beerocks::eFreqType sele if (!config.persistent_db) { LOG(DEBUG) << "persistent db is disabled"; } else { - LOG(DEBUG) << ", configuring persistent-db, selected_bands = " << int(selected_bands); + LOG(DEBUG) << ", configuring persistent-db, selected_bands = " << selected_bands; ValuesMap values_map; values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); @@ -2672,12 +2672,12 @@ bool db::set_client_selected_bands(const sMacAddr &mac, beerocks::eFreqType sele return true; } -beerocks::eFreqType db::get_client_selected_bands(const sMacAddr &mac) +int8_t db::get_client_selected_bands(const sMacAddr &mac) { auto node = get_node_verify_type(mac, beerocks::TYPE_CLIENT); if (!node) { LOG(ERROR) << "client node not found for mac " << mac; - return beerocks::eFreqType::FREQ_UNKNOWN; + return PARAMETER_NOT_CONFIGURED; } return node->client_selected_bands; @@ -2698,7 +2698,7 @@ bool db::clear_client_persistent_db(const sMacAddr &mac) node->client_stay_on_initial_radio = eTriStateBool::NOT_CONFIGURED; node->client_initial_radio = network_utils::ZERO_MAC; node->client_stay_on_selected_band = eTriStateBool::NOT_CONFIGURED; - node->client_selected_bands = beerocks::eFreqType::FREQ_UNKNOWN; + node->client_selected_bands = PARAMETER_NOT_CONFIGURED; // if persistent db is enabled if (config.persistent_db) { @@ -2771,7 +2771,7 @@ bool db::update_client_persistent_db(const sMacAddr &mac) values_map[SELECTED_BAND_ENABLE_STR] = std::to_string(enable); } - if (node->client_selected_bands != beerocks::eFreqType::FREQ_UNKNOWN) { + if (node->client_selected_bands != PARAMETER_NOT_CONFIGURED) { LOG(DEBUG) << "setting client selected-bands in persistent-db to for " << mac << " to " << node->client_selected_bands; values_map[SELECTED_BANDS_STR] = std::to_string(node->client_selected_bands); @@ -4275,7 +4275,7 @@ bool db::set_node_params_from_map(const sMacAddr &mac, const ValuesMap &values_m } else if (param.first == SELECTED_BANDS_STR) { LOG(DEBUG) << "setting node client_selected_bands to " << param.second << " for " << mac; - node->client_selected_bands = beerocks::eFreqType(string_utils::stoi(param.second)); + node->client_selected_bands = string_utils::stoi(param.second); } else { LOG(WARNING) << "Unknown parameter, skipping: " << param.first << " for " << mac; } diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index ad00bc6897..306e0cd793 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -751,20 +751,20 @@ class db { * @brief Set the client's selected-bands. * * @param mac MAC address of a client. - * @param selected_bands Client selected band/bands. FREQ_UNKNOWN is considered as "not-configured". + * @param selected_bands Client selected band/bands. Possible values are bitwise options of eClientSelectedBands. * @param save_to_persistent_db If set to true, update the persistent-db (write-through), default is true. * @return true on success, otherwise false. */ - bool set_client_selected_bands(const sMacAddr &mac, beerocks::eFreqType selected_bands, + bool set_client_selected_bands(const sMacAddr &mac, int8_t selected_bands, bool save_to_persistent_db = true); /** * @brief Get the client's selected-bands. * * @param mac MAC address of a client. - * @return Selected band/bands. + * @return Selected band/bands. Possible values are bitwise options of eClientSelectedBands. */ - beerocks::eFreqType get_client_selected_bands(const sMacAddr &mac); + int8_t get_client_selected_bands(const sMacAddr &mac); /** * @brief Clear client's persistent information. diff --git a/controller/src/beerocks/master/db/node.h b/controller/src/beerocks/master/db/node.h index 89043fd78d..67a7facd4a 100644 --- a/controller/src/beerocks/master/db/node.h +++ b/controller/src/beerocks/master/db/node.h @@ -292,8 +292,9 @@ class node { eTriStateBool client_stay_on_selected_band = eTriStateBool::NOT_CONFIGURED; // The selected bands the client should be steered to if the client_stay_on_selected_band is set. - // Default value is FREQ_UNKNOWN (also indicates value is not configured) - beerocks::eFreqType client_selected_bands = beerocks::eFreqType::FREQ_UNKNOWN; + // Default value is PARAMETER_NOT_CONFIGURED. + // Possible values are bitwise options of eClientSelectedBands. + int8_t client_selected_bands = beerocks::PARAMETER_NOT_CONFIGURED; /* * Persistent configurations - end From 01baa0cc31b5b7dbe8624c9f71cc4b27c5ff9c68 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Wed, 22 Jul 2020 09:43:20 +0000 Subject: [PATCH 417/453] controller: db: load_persistent_db_clients: handle db is full As part of the load_persistent_db_clients() a corner-case where the user added to the persistent DB more than the allowed max-clients-db-size must be handled. Added a check of the number-of-added-clients against the max-clients-db-size - if the condition is met - the clients' DB is full. If clients DB is full, find a candidate client for removal and compare it against the client read from persistent DB and we are trying to add. If the new client's remaining timelife is greater than the timelife of the candidate_for_removal, then the candidate is removed from the runtime DB and the persistent DB and the new client is added instead to the runtime DB. If the new client's remaining timelife is smaller or equal to the timelife of the candidate_for_removal, then the new client is removed from the persistent DB and we continue to the next client. PPM-5. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 79 +++++++++++++++++++++--- 1 file changed, 71 insertions(+), 8 deletions(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index 15f5cffdcd..1625c35814 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -2808,9 +2808,10 @@ bool db::load_persistent_db_clients() } // Counters for client nodes-add success/fail (filtered-out client entries are not counted) - int add_node_error_count = 0; - int set_node_error_count = 0; - int clients_added_no_error = 0; + uint16_t add_node_error_count = 0; + uint16_t set_node_error_count = 0; + uint16_t clients_added_no_error = 0; + uint16_t clients_not_added_or_removed_due_to_full_db = 0; // Add clients to runtime db - invalid client (no timestamp or aged entries) are filtered out for (const auto &client : clients) { @@ -2872,12 +2873,15 @@ bool db::load_persistent_db_clients() continue; } + // Save current time as a separate variable for fair comparison of current client + // remaining-timelife-delay against a candidate for removal in case the DB is full. + auto now = std::chrono::steady_clock::now(); + // Aged clients are removed from persistent db and not added to runtime db - auto timestamp_sec = beerocks::string_utils::stoi(timestamp_it->second); - auto timestamp = db::timestamp_from_seconds(timestamp_sec); - auto client_timelife_passed_sec = std::chrono::duration_cast( - std::chrono::steady_clock::now() - timestamp) - .count(); + auto timestamp_sec = beerocks::string_utils::stoi(timestamp_it->second); + auto timestamp = db::timestamp_from_seconds(timestamp_sec); + auto client_timelife_passed_sec = + std::chrono::duration_cast(now - timestamp).count(); /* TODO: aging validation against specific client configuration and unfriendly-device-max-timelife-delay: * 1. If client has timelife_delay_str param configured, it should be checked against it instead of global max-timelife-delay param. @@ -2897,6 +2901,61 @@ bool db::load_persistent_db_clients() continue; } + // If clients DB is full - find candidate for removal and compare against the current client. + // Note that this is a corner case and at the init stage where this functionality is performed we do + // not expect for this condition to be met. + // This is only for robustness against user misuse (adding manually more clients than clients_persistent_db_max_size). + if (clients_added_no_error >= config.clients_persistent_db_max_size) { + ++clients_not_added_or_removed_due_to_full_db; + // Find candidate client for removal + auto candidate_for_removal_mac = get_candidate_client_for_removal(); + if (candidate_for_removal_mac == network_utils::ZERO_MAC) { + LOG(WARNING) << "Failed to find candidate client for removal, unable to check if " + "possible to add " + << client_mac; + continue; + } + + // Get candidate node + auto candidate_node = + get_node_verify_type(candidate_for_removal_mac, eType::TYPE_CLIENT); + if (!candidate_node) { + LOG(WARNING) << "Failed to get node for client " << candidate_for_removal_mac; + continue; + } + + // Calculate candidate client remaining timelife delay. + auto candidate_remaining_time_sec = + std::chrono::duration_cast( + now - candidate_node->client_parameters_last_edit) + .count(); + + // If current client is has less remaining time, just remove it from persistent DB + if (client_remaining_timelife_sec <= candidate_remaining_time_sec) { + LOG(DEBUG) << "Clients DB is full, client has the least remaining timelife, it is " + "not added to the runtime DB and removed from persistent DB: " + << client_mac; + if (!bpl::db_remove_entry(type_client_str, client_entry)) { + LOG(ERROR) << "Failed to remove entry " << client_entry + << " from persistent db"; + } + continue; + } + + // Free-up space in the DB + // clear candidate client's persistent data in runtime db and remove from persistent db + if (!clear_client_persistent_db(candidate_for_removal_mac)) { + LOG(ERROR) << "failed to clear client persistent data and remove it from " + "persistent db for client " + << candidate_for_removal_mac << ", unable to add client " << client_mac; + continue; + } + + // The candidate client which is removed was previously counted as added-no-error. + // Decrease the related counter (which will be increased back as part of the new client add). + --clients_added_no_error; + } + // Add client node if (!add_new_client_with_persistent_data_to_nodes_list(client_mac, client_data_map)) { LOG(ERROR) << "Failed to add client node with persistent data for client " << client_mac @@ -2909,6 +2968,10 @@ bool db::load_persistent_db_clients() << "Failed to add nodes for " << add_node_error_count << " clients"; LOG_IF(set_node_error_count, ERROR) << "Failed to set nodes with values from persistent db for " << set_node_error_count << " clients"; + LOG_IF(clients_not_added_or_removed_due_to_full_db, DEBUG) + << "Filtered clients due to max DB capacity reached: " + << clients_not_added_or_removed_due_to_full_db + << ", max-capacity: " << config.clients_persistent_db_max_size; LOG(DEBUG) << "Added " << clients_added_no_error << " clients successfully"; // Set clients count to number of clients added successfully to runtime db From 96bd1fd9a95a8238d7d5f4e5509b556a580b00df Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Wed, 22 Jul 2020 12:43:26 +0000 Subject: [PATCH 418/453] controller: db: add API to get all configured clients Preparative commit. Added API to get all the clients in the runtime DB that have persistent information configured. The assumption is that a client with persistent data configured must have a timestamp configured (which differs from the default value that the not-configured clients have). The API returns a dqueu of the MAC addresses of the above-mentioned clients. PPM-5. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 18 ++++++++++++++++++ controller/src/beerocks/master/db/db.h | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index 1625c35814..5b6ca649c1 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -2980,6 +2980,24 @@ bool db::load_persistent_db_clients() return true; } +std::deque db::get_clients_with_persistent_data_configured() +{ + std::deque configured_clients; + for (auto node_map : nodes) { + for (auto kv : node_map) { + if ((kv.second->get_type() == eType::TYPE_CLIENT) && (kv.second->mac == kv.first) && + (kv.second->client_parameters_last_edit != + std::chrono::steady_clock::time_point::min())) { + configured_clients.push_back(tlvf::mac_from_string(kv.first)); + } + } + } + + LOG_IF(configured_clients.empty(), DEBUG) << "No clients are found"; + + return configured_clients; +} + // // CLI // diff --git a/controller/src/beerocks/master/db/db.h b/controller/src/beerocks/master/db/db.h index 306e0cd793..6c76ae5087 100644 --- a/controller/src/beerocks/master/db/db.h +++ b/controller/src/beerocks/master/db/db.h @@ -791,6 +791,13 @@ class db { */ bool load_persistent_db_clients(); + /** + * @brief Get the clients with persistent data configured object + * + * @return std::deque containing mac addresses of clients with configured persistent data + */ + std::deque get_clients_with_persistent_data_configured(); + // // CLI // From bad377bbe494a284fc2991f8b607368c8ee92723 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Sun, 26 Jul 2020 07:30:28 +0000 Subject: [PATCH 419/453] controller: read list of clients from DB Changed the ACTION_BML_CLIENT_GET_CLIENT_LIST_REQUEST handling to read the clients from persistent DB using the get_clients_with_persistent_data_configured() DB API. Removed the related cpp-check issue from cppcheck_existing_issues.txt. PPM-5. Signed-off-by: Adam Dov --- ci/cppcheck/cppcheck_existing_issues.txt | 1 - controller/src/beerocks/master/son_management.cpp | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ci/cppcheck/cppcheck_existing_issues.txt b/ci/cppcheck/cppcheck_existing_issues.txt index 499e1a4341..9546116589 100644 --- a/ci/cppcheck/cppcheck_existing_issues.txt +++ b/ci/cppcheck/cppcheck_existing_issues.txt @@ -96,7 +96,6 @@ controller/src/beerocks/master/son_actions.cpp: performance: Function parameter controller/src/beerocks/master/son_actions.cpp: performance: Function parameter 'sta_mac' should be passed by const reference. [passedByValue] std::string sta_mac, std::string bssid) controller/src/beerocks/master/son_actions.cpp: style: Local variable 'prev_task_id' shadows outer variable [shadowVariable] int prev_task_id = database.get_association_handling_task_id(mac); controller/src/beerocks/master/son_actions.cpp: style: The scope of the variable 'prev_task_id' can be reduced. [variableScope] int prev_task_id; -controller/src/beerocks/master/son_management.cpp: style: Condition '!client_list.size()' is always true [knownConditionTrueFalse] if (!client_list.size()) { controller/src/beerocks/master/son_management.cpp: style: Variable 'op_error_code' is assigned a value that is never used. [unreadVariable] op_error_code = eChannelScanOperationCode::SCAN_IN_PROGRESS; controller/src/beerocks/master/son_management.cpp: style: Variable 'op_error_code' is assigned a value that is never used. [unreadVariable] auto op_error_code = eChannelScanOperationCode::SUCCESS; controller/src/beerocks/master/son_management.cpp: style: Variable 'result_status' is assigned a value that is never used. [unreadVariable] result_status = last_scan_success; diff --git a/controller/src/beerocks/master/son_management.cpp b/controller/src/beerocks/master/son_management.cpp index b7cd6de536..98a550649e 100644 --- a/controller/src/beerocks/master/son_management.cpp +++ b/controller/src/beerocks/master/son_management.cpp @@ -2060,9 +2060,8 @@ void son_management::handle_bml_message(Socket *sd, } }; - // TODO: replace with a list of configured clients read from controller-db - std::vector client_list; - if (!client_list.size()) { + auto client_list = database.get_clients_with_persistent_data_configured(); + if (client_list.empty()) { LOG(DEBUG) << "client list is empty!"; // Send a valid response with an empty list send_response(true); From ed7161ae6458dfc4e06ce89a30a3f84250e0c6e4 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Sun, 26 Jul 2020 12:50:23 +0000 Subject: [PATCH 420/453] controller: read client information from DB Change the ACTION_BML_CLIENT_GET_CLIENT_REQUEST handling to read the client information from the DB using the DB APIs. The handling also takes care of the following scenarios: "client does not exist in DB" - handled as an error. "client timestamp not exist" - handled as an error. PPM-5. Signed-off-by: Adam Dov --- .../src/beerocks/master/son_management.cpp | 52 ++++++++++++++++--- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/controller/src/beerocks/master/son_management.cpp b/controller/src/beerocks/master/son_management.cpp index 98a550649e..56ec8f6a80 100644 --- a/controller/src/beerocks/master/son_management.cpp +++ b/controller/src/beerocks/master/son_management.cpp @@ -2134,16 +2134,52 @@ void son_management::handle_bml_message(Socket *sd, break; } - //TODO: fill client information from controller DB - response->client().sta_mac = request->sta_mac(); - response->client().timestamp_sec = 0; - response->client().stay_on_initial_radio = PARAMETER_NOT_CONFIGURED; + auto client_mac = request->sta_mac(); + if (!database.has_node(client_mac)) { + LOG(DEBUG) << "Requested client " << client_mac << " is not listed in the DB"; + response->result() = 1; //Fail. + message_com::send_cmdu(sd, cmdu_tx); + break; + } + + // A configured client must have a valid timestamp configured + auto client_timestamp = database.get_client_parameters_last_edit(client_mac); + if (client_timestamp == std::chrono::steady_clock::time_point::min()) { + LOG(DEBUG) << "Requested client " << client_mac + << " doesn't have a valid timestamp listed in the DB"; + response->result() = 1; //Fail. + message_com::send_cmdu(sd, cmdu_tx); + break; + } + + // Client mac + response->client().sta_mac = client_mac; + // Timestamp + response->client().timestamp_sec = client_timestamp.time_since_epoch().count(); + // Stay on initial radio + response->client().stay_on_initial_radio = + int(database.get_client_stay_on_initial_radio(client_mac)); + // Selected bands + auto selected_band_enable = database.get_client_stay_on_selected_band(client_mac); + if (selected_band_enable == eTriStateBool::NOT_CONFIGURED) { + response->client().selected_bands = PARAMETER_NOT_CONFIGURED; + } else { + response->client().selected_bands = database.get_client_selected_bands(client_mac); + } + // Timelife Delay - scaled from seconds to days + auto timelife_delay_sec = database.get_client_time_life_delay(client_mac); + response->client().time_life_delay_days = + (timelife_delay_sec == std::chrono::seconds::zero()) + ? PARAMETER_NOT_CONFIGURED + : std::chrono::duration_cast(timelife_delay_sec).count() / 24; + + // Currently not supported in DB + // Stay on selected device response->client().stay_on_selected_device = PARAMETER_NOT_CONFIGURED; - response->client().selected_bands = eClientSelectedBands::eSelectedBands_Disabled; - response->client().single_band = PARAMETER_NOT_CONFIGURED; - response->client().time_life_delay_days = PARAMETER_NOT_CONFIGURED; - response->result() = 0; //Success. + // Does client support only single band + response->client().single_band = PARAMETER_NOT_CONFIGURED; + response->result() = 0; //Success. message_com::send_cmdu(sd, cmdu_tx); break; } From ac52db566a49c86bcb0fc8ff56bcb04c92122614 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Tue, 28 Jul 2020 07:49:28 +0000 Subject: [PATCH 421/453] controller: set client information to DB Change the ACTION_BML_CLIENT_SET_CLIENT_REQUEST handling to configure the client information to the runtime DB using the DB APIs. If persistent DB is enabled - the update_client_persistent_db() API called to update the persistent DB with the client information (to prevent multiple persistent DB access overhead). Note that if the client is not yet part of the runtime DB, a node for it added before-hand. Moreover, managing the persistent DB max size limit is handled internally and is transparent to the user. PPM-5. Signed-off-by: Adam Dov --- .../src/beerocks/master/son_management.cpp | 96 ++++++++++++++++++- 1 file changed, 93 insertions(+), 3 deletions(-) diff --git a/controller/src/beerocks/master/son_management.cpp b/controller/src/beerocks/master/son_management.cpp index 56ec8f6a80..360471ca8f 100644 --- a/controller/src/beerocks/master/son_management.cpp +++ b/controller/src/beerocks/master/son_management.cpp @@ -2110,10 +2110,100 @@ void son_management::handle_bml_message(Socket *sd, break; } - //TODO: add client to persistent DB if required and set client parameters - response->result() = 0; //Success. + auto send_response = [&](bool result) -> bool { + response->result() = (result) ? 0 : 1; + return message_com::send_cmdu(sd, cmdu_tx); + }; - message_com::send_cmdu(sd, cmdu_tx); + // If none of the parameters is configured - return error. + // This flow should be blocked by the BML interface and should not be reached. + if ((request->client_config().stay_on_initial_radio == PARAMETER_NOT_CONFIGURED) && + (request->client_config().stay_on_selected_device == PARAMETER_NOT_CONFIGURED) && + (request->client_config().selected_bands == PARAMETER_NOT_CONFIGURED)) { + LOG(ERROR) + << "Received ACTION_BML_CLIENT_SET_CLIENT request without parameters to configure"; + send_response(false); + break; + } + + // Get client mac. + auto client_mac = request->sta_mac(); + + // If client doesn't have node in runtime DB - add node to runtime DB. + if (!database.has_node(client_mac)) { + LOG(DEBUG) << "Setting a client which doesn't exist in DB, adding client to DB"; + if (!database.add_node(client_mac)) { + LOG(ERROR) << "Failed to add client node for client " << client_mac; + send_response(false); + break; + } + } + + // Set stay_on_initial_radio if requested. + if (request->client_config().stay_on_initial_radio != PARAMETER_NOT_CONFIGURED) { + auto stay_on_initial_radio = + (eTriStateBool(request->client_config().stay_on_initial_radio) == + eTriStateBool::ENABLE); + if (!database.set_client_stay_on_initial_radio(client_mac, stay_on_initial_radio, + false)) { + LOG(ERROR) << " Failed to set stay-on-initial-radio to " << stay_on_initial_radio + << " for client " << client_mac; + send_response(false); + break; + } + } + + // Set stay_on_selected_device if requested. + if (request->client_config().stay_on_selected_device != PARAMETER_NOT_CONFIGURED) { + LOG(DEBUG) + << "The stay-on-selected-device configuration is not yet supported in the DB"; + + // TODO: add stay_on_selected_device support in the persistent DB. + // auto stay_on_selected_device = + // (eTriStateBool(request->client_config().stay_on_selected_device) == + // eTriStateBool::ENABLE); + // if (!database.set_client_stay_on_selected_device(client_mac, stay_on_selected_device, + // false)) { + // LOG(ERROR) << " Failed to set stay-on-selected-device to " + // << stay_on_selected_device << " for client " << client_mac; + // send_response(false); + // break; + // } + } + + // Set stay_on_selected_bands and selected_bands if requested. + if (request->client_config().selected_bands != PARAMETER_NOT_CONFIGURED) { + auto selected_bands = eClientSelectedBands(request->client_config().selected_bands); + auto stay_on_selected_band = + (selected_bands != eClientSelectedBands::eSelectedBands_Disabled); + // Set stay_on_selected_bands. + if (!database.set_client_stay_on_selected_band(client_mac, stay_on_selected_band, + false)) { + LOG(ERROR) << " Failed to stay_on_selected_band to " << stay_on_selected_band + << " for client " << client_mac; + send_response(false); + break; + } + // Set selected_bands. + if (!database.set_client_selected_bands(client_mac, selected_bands, false)) { + LOG(ERROR) << " Failed to set selected-bands to " << selected_bands + << " for client " << client_mac; + send_response(false); + break; + } + } + + //if persistent_db is enabled, call the "update_client_persistent_db" + if (database.config.persistent_db) { + if (!database.update_client_persistent_db(client_mac)) { + LOG(ERROR) + << "Information is saved to runtime-DB but failed to set to persistent DB"; + send_response(false); + break; + } + } + + send_response(true); break; } case beerocks_message::ACTION_BML_CLIENT_GET_CLIENT_REQUEST: { From 1ceb8d24de931aaf3e6802a20954cde501347893 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Tue, 28 Jul 2020 15:48:45 +0000 Subject: [PATCH 422/453] db: set the initial-radio when stay-on-initial-radio is set When configuring the stay_on_initial_radio the initial_radio needs to be set as well. If stay_on_initial_radio is disabled - clear the initial_radio configuration. If stay_on_initial_radio is enabled and the client is connected - set the initial_radio to the parent radio (not bssid) mac. PPM-5. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 31 +++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index 5b6ca649c1..d17d3fbcf0 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -2498,6 +2498,8 @@ bool db::set_client_stay_on_initial_radio(const sMacAddr &mac, bool stay_on_init LOG(DEBUG) << "stay_on_initial_radio = " << stay_on_initial_radio; + auto is_client_connected = (node->state == STATE_CONNECTED); + auto timestamp = std::chrono::steady_clock::now(); if (save_to_persistent_db) { // if persistent db is disabled @@ -2510,6 +2512,14 @@ bool db::set_client_stay_on_initial_radio(const sMacAddr &mac, bool stay_on_init ValuesMap values_map; values_map[TIMESTAMP_STR] = timestamp_to_string_seconds(timestamp); values_map[INITIAL_RADIO_ENABLE_STR] = std::to_string(stay_on_initial_radio); + // clear initial-radio data on disabling of stay_on_initial_radio + if (!stay_on_initial_radio) { + values_map[INITIAL_RADIO_STR] = std::string(); + } else if (is_client_connected) { + // if enabling stay-on-initial-radio and client is already connected, update the initial_radio as well + auto bssid = node->parent_mac; + values_map[INITIAL_RADIO_STR] = get_node_parent_radio(bssid); + } // update the persistent db if (!update_client_entry_in_persistent_db(mac, values_map)) { @@ -2521,6 +2531,15 @@ bool db::set_client_stay_on_initial_radio(const sMacAddr &mac, bool stay_on_init node->client_stay_on_initial_radio = (stay_on_initial_radio) ? eTriStateBool::ENABLE : eTriStateBool::DISABLE; + // clear initial-radio data on disabling of stay_on_initial_radio + if (!stay_on_initial_radio) { + node->client_initial_radio = network_utils::ZERO_MAC; + // if enabling stay-on-initial-radio and client is already connected, update the initial_radio as well + } else if (is_client_connected) { + auto bssid = node->parent_mac; + auto parent_radio_mac = get_node_parent_radio(bssid); + node->client_initial_radio = tlvf::mac_from_string(parent_radio_mac); + } node->client_parameters_last_edit = timestamp; return true; @@ -4340,9 +4359,19 @@ bool db::set_node_params_from_map(const sMacAddr &mac, const ValuesMap &values_m } else if (param.first == INITIAL_RADIO_ENABLE_STR) { LOG(DEBUG) << "setting node client_stay_on_initial_radio to " << param.second << " for " << mac; - + auto stay_on_initial_radio = (param.second == "1"); node->client_stay_on_initial_radio = (param.second == "1") ? eTriStateBool::ENABLE : eTriStateBool::DISABLE; + + // clear initial-radio data on disabling of stay_on_initial_radio + if (!stay_on_initial_radio) { + node->client_initial_radio = network_utils::ZERO_MAC; + // if enabling stay-on-initial-radio and client is already connected, update the initial_radio as well + } else if (node->state == STATE_CONNECTED) { + auto bssid = node->parent_mac; + auto parent_radio_mac = get_node_parent_radio(bssid); + node->client_initial_radio = tlvf::mac_from_string(parent_radio_mac); + } } else if (param.first == INITIAL_RADIO_STR) { LOG(DEBUG) << "setting node client_initial_radio to " << param.second << " for " << mac; From ac1183137c3ddd6afff95b71a532820c340cff87 Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Wed, 29 Jul 2020 07:19:42 +0000 Subject: [PATCH 423/453] controller: db: set the initial-radio on client connection The stay-on-initial-radio can be configured for disconnected clients as well as clients which never connected yet. This means, that when the client connects, we need to check if the stay-on-initial-radio is enabled and if so set the initial-radio. Note that the initial-radio is set only if it wasn't set before - to prevent overriding previous configuration. The value set to the initial-radio is the parent radio (not bssid) mac. Added the above-described functionality to the association_handling_task::finalize_new_connection() which is called on client connection. PPM-5. Signed-off-by: Adam Dov --- .../master/tasks/association_handling_task.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/controller/src/beerocks/master/tasks/association_handling_task.cpp b/controller/src/beerocks/master/tasks/association_handling_task.cpp index cfab15d3b8..d8b6377323 100644 --- a/controller/src/beerocks/master/tasks/association_handling_task.cpp +++ b/controller/src/beerocks/master/tasks/association_handling_task.cpp @@ -372,6 +372,24 @@ void association_handling_task::finalize_new_connection() */ if (!database.get_node_handoff_flag(sta_mac)) { if (database.get_node_type(sta_mac) == beerocks::TYPE_CLIENT) { + // The client's stay-on-initial-radio can be enabled prior to the client connection. + // If this is the case, when the client connects the initial-radio should be configured (if not already configured) + // to allow the functionality of stay-on-initial-radio. + // Note: The initial-radio is persistent configuration and if is already set, the client-connection flow should + // not override the existing configuration. + auto client_mac = tlvf::mac_from_string(sta_mac); + if ((database.get_client_stay_on_initial_radio(client_mac) == eTriStateBool::ENABLE) && + (database.get_client_initial_radio(client_mac) == network_utils::ZERO_MAC)) { + auto bssid = database.get_node_parent(sta_mac); + auto parent_radio_mac = database.get_node_parent_radio(bssid); + // If stay_on_initial_radio is enabled and initial_radio is not set yet, set to parent radio mac (not bssid) + if (!database.set_client_initial_radio(client_mac, + tlvf::mac_from_string(parent_radio_mac), + database.config.persistent_db)) { + LOG(WARNING) << "Failed to set client " << client_mac << " initial radio to " + << parent_radio_mac; + } + } auto new_task = std::make_shared( database, cmdu_tx, tasks, sta_mac, 6000, "handle_completed_connection"); tasks.add_task(new_task); From 5aad03c1ae744c4f7e0382a7ccf505825ed603ba Mon Sep 17 00:00:00 2001 From: Adam Dov Date: Sun, 2 Aug 2020 08:31:44 +0000 Subject: [PATCH 424/453] controller: db: fix function return value on success to true As part of testing the full flows of the persistent Db we encountered an issue where a successful removal of a client entry from the persistent DB resulted in a false-positive error. The cause of this error is that remove_client_entry_and_update_counter() in the db class returned false both for success and for failure. Changed the successful return value of the above-mentioned function from false to true. Signed-off-by: Adam Dov --- controller/src/beerocks/master/db/db.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/src/beerocks/master/db/db.cpp b/controller/src/beerocks/master/db/db.cpp index d17d3fbcf0..fc7ba91b44 100644 --- a/controller/src/beerocks/master/db/db.cpp +++ b/controller/src/beerocks/master/db/db.cpp @@ -4415,7 +4415,7 @@ bool db::remove_client_entry_and_update_counter(const std::string &entry_name) } --m_persistent_db_clients_count; - return false; + return true; } bool db::remove_candidate_client() From f5a3a1b4096a48c8f2d0c97bc8faae4db9c32bab Mon Sep 17 00:00:00 2001 From: Oren Vormaser Date: Sun, 26 Jul 2020 15:46:47 +0000 Subject: [PATCH 425/453] common: prplmesh_utils.sh: change prplmesh_utils.sh status output Currently prplmesh_utils.sh status output follows the follwing format: operational test failed! bml_connect: return value is: BML_RET_OK, Success status OK Main radio agent operational bml_device_oper_radios_query: return value is: BML_RET_OK, Success status bml_disconnect: return value is: BML_RET_OK, Success status The command output has been changed to match original FAIL/OK wlan0 report: operational test failed! OK Main agent operational FAIL wlan0 radio agent operational FAIL wlan2 radio agent operational https://jira.prplfoundation.org/browse/PPM-314 Signed-off-by: Oren Vormaser --- common/beerocks/scripts/prplmesh_utils.sh.in | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/common/beerocks/scripts/prplmesh_utils.sh.in b/common/beerocks/scripts/prplmesh_utils.sh.in index 4ed961abef..74efb9eeaf 100755 --- a/common/beerocks/scripts/prplmesh_utils.sh.in +++ b/common/beerocks/scripts/prplmesh_utils.sh.in @@ -310,17 +310,27 @@ status_function() { if pgrep -l beerocks_cont ; then echo "executing operational test using bml" if execute_beerocks_command "$bml_cmd" ; then + OUTPUT=$output # Expecting # > OK Main radio agent operational # > OK wlan0 radio agent operational # > OK wlan2 radio agent operational - OK_Count=$(echo "$output" | grep -c -e "OK.*operational") + OK_Count=$(echo "$OUTPUT" | grep -c -e "OK.*operational") if [ "$OK_Count" -eq 3 ]; then success "operational test success!" + OUTPUT=$(echo "$OUTPUT" | grep -E '(FAIL|OK).*?operational') + success "$OUTPUT" exit 0 else err "operational test failed!" - err "$output" + OUTPUT=$(echo "$OUTPUT" | grep -E '(FAIL| OK).*?operational' | sed -e "s/ OK/OK/") + echo "$OUTPUT" + if [ "$(echo "$OUTPUT" | grep -c -e " @BEEROCKS_WLAN1_IFACE@ .*operational")" -eq 0 ]; then + err "FAIL @BEEROCKS_WLAN1_IFACE@ radio agent operational" + fi + if [ "$(echo "$OUTPUT" | grep -c -e " @BEEROCKS_WLAN2_IFACE@ .*operational")" -eq 0 ]; then + err "FAIL @BEEROCKS_WLAN2_IFACE@ radio agent operational" + fi exit 1 fi else From e5ccae04f1fc95cc6a177ee77b5de8543601b1bd Mon Sep 17 00:00:00 2001 From: Anton Bilohai Date: Fri, 17 Jul 2020 10:45:46 +0300 Subject: [PATCH 426/453] tools: install AMBIORIX to the Ubuntu Docker builder Add AMBIORIX libraries, applications and dependencies to the dummy device Docker image builder. Jira link: https://jira.prplfoundation.org/browse/PPM-266 Signed-off-by: Anton Bilohai --- tools/docker/builder/ubuntu/bionic/Dockerfile | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/tools/docker/builder/ubuntu/bionic/Dockerfile b/tools/docker/builder/ubuntu/bionic/Dockerfile index e48926361b..b8858d4dd2 100644 --- a/tools/docker/builder/ubuntu/bionic/Dockerfile +++ b/tools/docker/builder/ubuntu/bionic/Dockerfile @@ -26,5 +26,35 @@ RUN apt-get update && apt-get install -y \ python3-yaml \ uuid-runtime \ valgrind \ - vim \ - && rm -rf /var/lib/apt/lists/* + vim +# AMBRIORIX dependencies +# We need liburiparser-dev > v. 9.0 which isn't avalaible in default +# 18.04 Ubuntu repos. So add Ubuntu 19.10 repo which has v. 0.9.3-2 +RUN \ + apt-get install -y \ + bison \ + flex \ + libevent-dev \ + libyajl-dev \ + repo && \ + echo "deb http://cz.archive.ubuntu.com/ubuntu eoan main universe" | tee -a /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y \ + liburiparser-dev && \ + rm -rf /var/lib/apt/lists/* +WORKDIR ambiorix +# Fetch and intall Bus Agnostic API libs, applications. +# As they have some internal dependencies - we should build & install +# them in specific order. +RUN \ + repo init -u https://gitlab.com/soft.at.home/ambiorix/ambiorix.git && \ + repo sync && \ + make install -C libraries/libamxc && \ + make install -C libraries/libamxp && \ + make install -C libraries/libamxd && \ + make install -C libraries/libamxj && \ + make install -C libraries/libamxo && \ + make install -C libraries/libamxb && \ + make install -C applications/amxb-inspect && \ + make install -C applications/amxo-cg && \ + make install -C applications/amxrt From e5d8170da38443b1e895d394ec7416fa82403755 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Tue, 28 Jul 2020 13:43:40 +0000 Subject: [PATCH 427/453] agent: Cleanup irrelevant code Cleanup preparative commit. PR #1504 has added all the members are required for the Topology Task to the AgentDB. Since at that time the AgentDB was not really shared since the son_slaves were on a different process than the backhaul manager, we had to create a local copy of everything which is passed on on messages between the son_slaves and the backhaul manager. Now that PR #1584 is merged and the database is shared, we can delete all of these local copies: 1. Remove passing local_gw and local_controller flags. 2. Remove passing bridge_mac on backhaul connected notification, and setting a local copy of it on the backhaul constructor. 3. Removed passing of vap list update to the backhaul manager. 4. Remove passing client associated and disconnected messages to the backhaul manager. 5. Remove dependency on backhaul manager member "slaves_sockets" for "freq_type" and remove it from the backhaul manager. 6. Remove adding the radio nodes again on the backhaul manager (it is added on the son_slave already). 7. Remove the local copy of a bunch of parameters on the "BACKHAUL_ENABLE" handler, that we now have access to through the DB. PPM-320 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 116 ++++-------------- .../backhaul_manager_thread.h | 7 +- .../platform_manager_thread.cpp | 2 - agent/src/beerocks/slave/son_slave_thread.cpp | 86 +++---------- 4 files changed, 43 insertions(+), 168 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index f28cfbdc82..968cf88769 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -245,10 +245,6 @@ backhaul_manager::backhaul_manager(const config_file::sConfigSlave &config, m_sConfig.vendor = config.vendor; m_sConfig.model = config.model; - // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 - auto db = AgentDB::get(); - db->bridge.iface_name = config.bridge_iface; - m_eFSMState = EState::INIT; set_select_timeout(SELECT_TIMEOUT_MSC); } @@ -590,7 +586,6 @@ bool backhaul_manager::finalize_slaves_connect_state(bool fConnected, notification->params().gw_ipv4 = network_utils::ipv4_from_string(bridge_info.ip_gw); notification->params().gw_bridge_mac = tlvf::mac_from_string(bssid_bridge_mac); - notification->params().bridge_mac = db->bridge.mac; notification->params().bridge_ipv4 = network_utils::ipv4_from_string(bridge_info.ip); notification->params().backhaul_mac = tlvf::mac_from_string(iface_info.mac); notification->params().backhaul_ipv4 = network_utils::ipv4_from_string(iface_info.ip); @@ -1504,6 +1499,7 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) FSM_MOVE_STATE(RESTART); break; } + auto db = AgentDB::get(); bool preferred_band_is_available = false; @@ -1518,7 +1514,11 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) LOG(WARNING) << "Sta_hal of " << soc->sta_iface << " is null"; continue; } - if (m_sConfig.backhaul_preferred_radio_band == soc->freq_type) { + auto radio = db->radio(soc->hostap_iface); + if (!radio) { + continue; + } + if (m_sConfig.backhaul_preferred_radio_band == radio->front.freq_type) { preferred_band_is_available = true; } } @@ -1538,9 +1538,14 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) continue; } + auto radio = db->radio(soc->hostap_iface); + if (!radio) { + continue; + } + if (preferred_band_is_available && m_sConfig.backhaul_preferred_radio_band != beerocks::eFreqType::FREQ_AUTO && - m_sConfig.backhaul_preferred_radio_band != soc->freq_type) { + m_sConfig.backhaul_preferred_radio_band != radio->front.freq_type) { LOG(DEBUG) << "slave iface=" << soc->sta_iface << " is not of the preferred backhaul band"; continue; @@ -1883,8 +1888,6 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr soc->sta_iface.assign(request->sta_iface(message::IFACE_NAME_LENGTH)); soc->hostap_iface.assign(request->hostap_iface(message::IFACE_NAME_LENGTH)); - // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 - db->add_radio(request->hostap_iface(), request->sta_iface()); soc->sta_iface_filter_low = request->sta_iface_filter_low(); onboarding = request->onboarding(); @@ -1943,20 +1946,10 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr std::copy_n(channels, request->preferred_channels_size(), soc->preferred_channels.begin()); - soc->radio_mac = request->iface_mac(); - // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 - radio->front.iface_mac = soc->radio_mac; - - soc->freq_type = request->frequency_band(); - // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 - radio->front.freq_type = request->frequency_band(); + soc->radio_mac = request->iface_mac(); soc->controller_discovered = false; - soc->max_bandwidth = request->max_bandwidth(); - // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 - radio->front.max_supported_bw = request->max_bandwidth(); - - soc->ht_supported = request->ht_supported(); - soc->ht_capability = request->ht_capability(); + soc->ht_supported = request->ht_supported(); + soc->ht_capability = request->ht_capability(); std::copy_n(request->ht_mcs_set(), soc->ht_mcs_set.size(), soc->ht_mcs_set.begin()); soc->vht_supported = request->vht_supported(); soc->vht_capability = request->vht_capability(); @@ -2023,7 +2016,6 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr if (m_sConfig.security_type == bwl::WiFiSec::WPA_WPA2_PSK) { m_sConfig.security_type = bwl::WiFiSec::WPA2_PSK; } - db->ethernet.iface_name.assign(request->wire_iface(message::IFACE_NAME_LENGTH)); m_sConfig.wire_iface_type = (beerocks::eIfaceType)request->wire_iface_type(); LOG(DEBUG) << "All slaves ready, proceeding" << std::endl @@ -2145,76 +2137,6 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr } break; } - case beerocks_message::ACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION: { - LOG(DEBUG) << "ACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION received from iface " - << soc->hostap_iface; - auto msg = beerocks_header->addClass< - beerocks_message::cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION>(); - if (!msg) { - LOG(ERROR) << "Failed parsing BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION message!"; - return false; - } - - // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 - auto db = AgentDB::get(); - auto radio = db->radio(soc->hostap_iface); - if (!radio) { - LOG(DEBUG) << "Radio of iface " << soc->hostap_iface << " does not exist on the db"; - return false; - } - for (uint8_t vap_idx = 0; vap_idx < eBeeRocksIfaceIds::IFACE_TOTAL_VAPS; vap_idx++) { - radio->front.bssids[vap_idx].mac = msg->params().vaps[vap_idx].mac; - radio->front.bssids[vap_idx].ssid = msg->params().vaps[vap_idx].ssid; - radio->front.bssids[vap_idx].type = msg->params().vaps[vap_idx].backhaul_vap - ? AgentDB::sRadio::sFront::sBssid::eType::bAP - : AgentDB::sRadio::sFront::sBssid::eType::fAP; - } - break; - } - case beerocks_message::ACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION: { - LOG(DEBUG) << "ACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION"; - auto msg = - beerocks_header - ->addClass(); - if (!msg) { - LOG(ERROR) << "Failed building ACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION message!"; - break; - } - - // Remove this client from other radios. - auto db = AgentDB::get(); - db->erase_client(msg->client_mac()); - - // Set client association information for associated client - auto radio = db->get_radio_by_mac(msg->bssid(), AgentDB::eMacType::BSSID); - if (!radio) { - LOG(DEBUG) << "Radio containing bssid " << msg->bssid() << " not found"; - break; - } - - radio->associated_clients.emplace(msg->client_mac(), - AgentDB::sRadio::sClient{msg->bssid(), - msg->association_frame_length(), - msg->association_frame()}); - - break; - } - case beerocks_message::ACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION: { - LOG(DEBUG) << "ACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION"; - auto msg = - beerocks_header - ->addClass(); - if (!msg) { - LOG(ERROR) - << "Failed building ACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION message!"; - return false; - } - - // If exists, remove client association information for disconnected client. - auto db = AgentDB::get(); - db->erase_client(msg->client_mac(), msg->bssid()); - break; - } case beerocks_message::ACTION_BACKHAUL_ASSOCIATED_STA_LINK_METRICS_RESPONSE: { auto response_in = beerocks_header->addClass< beerocks_message::cACTION_BACKHAUL_ASSOCIATED_STA_LINK_METRICS_RESPONSE>(); @@ -3481,7 +3403,7 @@ bool backhaul_manager::handle_1905_autoconfiguration_response(ieee1905_1::CmduMe const std::string &src_mac) { LOG(DEBUG) << "received autoconfiguration response message"; - + auto db = AgentDB::get(); if (!controller_bridge_mac.empty() && src_mac != controller_bridge_mac) { LOG(INFO) << "current controller_bridge_mac=" << controller_bridge_mac << " but response came from src_mac=" << src_mac << ", ignoring"; @@ -3539,7 +3461,11 @@ bool backhaul_manager::handle_1905_autoconfiguration_response(ieee1905_1::CmduMe } LOG(DEBUG) << "received autoconfiguration response for " << band_name << " band"; for (auto soc : slaves_sockets) { - if (soc->freq_type == freq_type) { + auto radio = db->radio(soc->hostap_iface); + if (!radio) { + continue; + } + if (radio->front.freq_type == freq_type) { LOG(DEBUG) << band_name << " band socket found, iface=" << soc->hostap_iface; if (!soc->controller_discovered) { LOG(DEBUG) << "set controller_discovered to true for " << band_name diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 814ad53e85..faef31007b 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -320,7 +320,6 @@ class backhaul_manager : public btl::transport_socket_thread { sMacAddr radio_mac; /**< Radio ID (= radio MAC address) */ std::string hostap_iface; /**< Name of the radio interface */ std::string sta_iface; /**< Name of the bSTA interface on the radio (if any) */ - eFreqType freq_type = eFreqType::FREQ_UNKNOWN; bool sta_iface_filter_low = false; bool slave_is_backhaul_manager = false; bool controller_discovered = false; @@ -329,10 +328,8 @@ class backhaul_manager : public btl::transport_socket_thread { Socket *sta_hal_ext_events = nullptr; Socket *sta_hal_int_events = nullptr; - eWiFiBandwidth max_bandwidth = - eWiFiBandwidth::BANDWIDTH_UNKNOWN; /**< Maximum supported bandwidth */ - bool ht_supported = false; /**< Is HT supported flag */ - uint16_t ht_capability = 0; /**< HT capabilities */ + bool ht_supported = false; /**< Is HT supported flag */ + uint16_t ht_capability = 0; /**< HT capabilities */ std::array ht_mcs_set; /**< 16-byte attribute containing the MCS set as defined in 802.11n */ bool vht_supported = false; /**< Is VHT supported flag */ diff --git a/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp b/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp index 135dc43968..a0dd39f840 100644 --- a/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp +++ b/agent/src/beerocks/slave/platform_manager/platform_manager_thread.cpp @@ -203,13 +203,11 @@ static bool fill_platform_settings( 0; // TODO add platform DB flag msg->platform_settings().client_11k_roaming_enabled = uint8_t(platform_common_conf.client_roaming || platform_common_conf.band_steering); - msg->platform_settings().local_gw = uint8_t(db->device_conf.local_gw); msg->platform_settings().operating_mode = uint8_t(platform_common_conf.operating_mode); msg->platform_settings().management_mode = uint8_t(platform_common_conf.management_mode); msg->platform_settings().certification_mode = uint8_t(platform_common_conf.certification_mode); msg->platform_settings().stop_on_failure_attempts = uint8_t(platform_common_conf.stop_on_failure_attempts); - msg->platform_settings().local_master = uint8_t(db->device_conf.local_controller); msg->platform_settings().backhaul_max_vaps = uint8_t(platform_common_conf.backhaul_max_vaps); msg->platform_settings().backhaul_network_enabled = uint8_t(platform_common_conf.backhaul_network_enabled); diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 430f96a638..85805bc77d 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -1059,9 +1059,6 @@ bool slave_thread::handle_cmdu_backhaul_manager_message( auto db = AgentDB::get(); - // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 - db->bridge.mac = notification->params().bridge_mac; - backhaul_params.gw_ipv4 = network_utils::ipv4_to_string(notification->params().gw_ipv4); backhaul_params.gw_bridge_mac = tlvf::mac_to_string(notification->params().gw_bridge_mac); @@ -1312,10 +1309,6 @@ bool slave_thread::handle_cmdu_platform_manager_message( auto db = AgentDB::get(); - // Local copy on cuurent process database instance, to be removed on PPM-83 phase 5 - db->device_conf.local_gw = response->platform_settings().local_gw; - db->device_conf.local_controller = response->platform_settings().local_master; - configuration_stop_on_failure_attempts = response->platform_settings().stop_on_failure_attempts; stop_on_failure_attempts = configuration_stop_on_failure_attempts; @@ -1668,18 +1661,6 @@ bool slave_thread::handle_cmdu_ap_manager_message(Socket *sd, notification_out->params() = notification_in->params(); LOG(TRACE) << "send ACTION_CONTROL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION"; send_cmdu_to_controller(cmdu_tx); - - auto notification_out2 = message_com::create_vs_message< - beerocks_message::cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION>(cmdu_tx); - if (notification_out2 == nullptr) { - LOG(ERROR) << "Failed building message!"; - return false; - } - - notification_out2->params() = notification_in->params(); - LOG(TRACE) << "send ACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION"; - message_com::send_cmdu(backhaul_manager_socket, cmdu_tx); - break; } case beerocks_message::ACTION_APMANAGER_HOSTAP_ACS_NOTIFICATION: { @@ -1799,8 +1780,9 @@ bool slave_thread::handle_cmdu_ap_manager_message(Socket *sd, return false; } - std::string client_mac = tlvf::mac_to_string(notification_in->params().mac); - LOG(INFO) << "client disconnected sta_mac=" << client_mac; + auto &client_mac = notification_in->params().mac; + auto &bssid = notification_in->params().bssid; + LOG(INFO) << "client disconnected sta_mac=" << client_mac << " from bssid=" << bssid; //notify master if (!master_socket) { @@ -1808,24 +1790,9 @@ bool slave_thread::handle_cmdu_ap_manager_message(Socket *sd, return true; } - // Build VS CMDU message to send to backhaul manager - auto notification_out = message_com::create_vs_message< - beerocks_message::cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION>(cmdu_tx); - if (!notification_out) { - LOG(ERROR) - << "Failed building ACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION message!"; - break; - } - - notification_out->client_mac() = notification_in->params().mac; - notification_out->bssid() = notification_in->params().bssid; - - // Send the message - LOG(DEBUG) << "send ACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION for client " - << notification_out->client_mac(); - if (!message_com::send_cmdu(backhaul_manager_socket, cmdu_tx)) { - slave_reset(); - } + // If exists, remove client association information for disconnected client. + auto db = AgentDB::get(); + db->erase_client(client_mac, bssid); // build 1905.1 message CMDU to send to the controller if (!cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_NOTIFICATION_MESSAGE)) { @@ -1986,37 +1953,29 @@ bool slave_thread::handle_cmdu_ap_manager_message(Socket *sd, return false; } LOG(TRACE) << "received ACTION_APMANAGER_CLIENT_ASSOCIATED_NOTIFICATION"; - std::string client_mac = tlvf::mac_to_string(notification_in->mac()); - LOG(INFO) << "client associated sta_mac=" << client_mac; + auto &client_mac = notification_in->mac(); + auto &bssid = notification_in->bssid(); + LOG(INFO) << "Client associated sta_mac=" << client_mac << " to bssid=" << bssid; if (!master_socket) { LOG(DEBUG) << "Controller is not connected"; return true; } - // Build VS CMDU message to send to backhaul manager - auto notification_out = message_com::create_vs_message< - beerocks_message::cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION>(cmdu_tx); - if (!notification_out) { - LOG(ERROR) << "Failed building ACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION message!"; - break; - } + // Save information AgentDB + auto db = AgentDB::get(); + db->erase_client(client_mac); - notification_out->client_mac() = notification_in->mac(); - notification_out->bssid() = notification_in->bssid(); - if (!notification_in->association_frame_length()) { - LOG(DEBUG) << "no association frame"; - } else { - notification_out->set_association_frame(notification_in->association_frame(), - notification_in->association_frame_length()); + // Set client association information for associated client + auto radio = db->get_radio_by_mac(bssid, AgentDB::eMacType::BSSID); + if (!radio) { + LOG(DEBUG) << "Radio containing bssid " << bssid << " not found"; + break; } - // Send the message - LOG(DEBUG) << "send ACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION for client " - << notification_out->client_mac(); - if (!message_com::send_cmdu(backhaul_manager_socket, cmdu_tx)) { - slave_reset(); - } + radio->associated_clients.emplace( + client_mac, AgentDB::sRadio::sClient{bssid, notification_in->association_frame_length(), + notification_in->association_frame()}); // build 1905.1 message CMDU to send to the controller if (!cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_NOTIFICATION_MESSAGE)) { @@ -3135,9 +3094,7 @@ bool slave_thread::slave_fsm(bool &call_slave_select) config.backhaul_wireless_iface.c_str(), message::IFACE_NAME_LENGTH); - bh_enable->frequency_band() = hostap_params.frequency_band; radio->front.freq_type = hostap_params.frequency_band; - bh_enable->max_bandwidth() = hostap_params.max_bandwidth; radio->front.max_supported_bw = hostap_params.max_bandwidth; bh_enable->ht_supported() = hostap_params.ht_supported; @@ -3201,9 +3158,6 @@ bool slave_thread::slave_fsm(bool &call_slave_select) network_utils::iface_info bridge_info; network_utils::get_iface_info(bridge_info, db->bridge.iface_name); - // Create a local copy on this process database instance. Will be removed on PPM-83 phase 5 - db->bridge.mac = tlvf::mac_from_string(bridge_info.mac); - backhaul_params.gw_ipv4 = bridge_info.ip; backhaul_params.gw_bridge_mac = bridge_info.mac; backhaul_params.bridge_ipv4 = bridge_info.ip; From 95765c01521e439da08118a0cfcd4ec7c0a4dd2b Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Tue, 28 Jul 2020 13:47:02 +0000 Subject: [PATCH 428/453] tlvf: Cleanup unused messages Remove these messages since they are no longer being used: ACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION ACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION ACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION PPM-320 Signed-off-by: Moran Shoeg --- .../beerocks/tlvf/beerocks_message_backhaul.h | 74 ----- .../tlvf/beerocks_message_backhaul.cpp | 278 ------------------ .../tlvf/beerocks_message_backhaul.yaml | 17 -- 3 files changed, 369 deletions(-) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h index ba3c15aebb..b49005bc45 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h @@ -446,80 +446,6 @@ class cACTION_BACKHAUL_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE : public BaseClas sMacAddr* m_mac = nullptr; }; -class cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION : public BaseClass -{ - public: - cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION(std::shared_ptr base, bool parse = false); - ~cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION(); - - static eActionOp_BACKHAUL get_action_op(){ - return (eActionOp_BACKHAUL)(ACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION); - } - sVapsList& params(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_BACKHAUL* m_action_op = nullptr; - sVapsList* m_params = nullptr; -}; - -class cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION : public BaseClass -{ - public: - cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION(std::shared_ptr base, bool parse = false); - ~cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION(); - - static eActionOp_BACKHAUL get_action_op(){ - return (eActionOp_BACKHAUL)(ACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION); - } - sMacAddr& client_mac(); - sMacAddr& bssid(); - size_t association_frame_length() { return m_association_frame_idx__ * sizeof(uint8_t); } - uint8_t* association_frame(size_t idx = 0); - bool set_association_frame(const void* buffer, size_t size); - bool alloc_association_frame(size_t count = 1); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_BACKHAUL* m_action_op = nullptr; - sMacAddr* m_client_mac = nullptr; - sMacAddr* m_bssid = nullptr; - uint8_t* m_association_frame = nullptr; - size_t m_association_frame_idx__ = 0; - int m_lock_order_counter__ = 0; -}; - -class cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION : public BaseClass -{ - public: - cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse = false); - explicit cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION(std::shared_ptr base, bool parse = false); - ~cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION(); - - static eActionOp_BACKHAUL get_action_op(){ - return (eActionOp_BACKHAUL)(ACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION); - } - sMacAddr& client_mac(); - sMacAddr& bssid(); - void class_swap() override; - bool finalize() override; - static size_t get_initial_size(); - - private: - bool init(); - eActionOp_BACKHAUL* m_action_op = nullptr; - sMacAddr* m_client_mac = nullptr; - sMacAddr* m_bssid = nullptr; -}; - class cACTION_BACKHAUL_ASSOCIATED_STA_LINK_METRICS_REQUEST : public BaseClass { public: diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp index 8b72637c1f..c014497d4d 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp @@ -1605,284 +1605,6 @@ bool cACTION_BACKHAUL_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE::init() return true; } -cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION::cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION::cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION::~cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION() { -} -sVapsList& cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION::params() { - return (sVapsList&)(*m_params); -} - -void cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_BACKHAUL), reinterpret_cast(m_action_op)); - m_params->struct_swap(); -} - -bool cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sVapsList); // params - return class_size; -} - -bool cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_params = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sVapsList))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sVapsList) << ") Failed!"; - return false; - } - if (!m_parse__) { m_params->struct_init(); } - if (m_parse__) { class_swap(); } - return true; -} - -cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION::cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION::cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION::~cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION() { -} -sMacAddr& cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION::client_mac() { - return (sMacAddr&)(*m_client_mac); -} - -sMacAddr& cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION::bssid() { - return (sMacAddr&)(*m_bssid); -} - -uint8_t* cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION::association_frame(size_t idx) { - if ( (m_association_frame_idx__ == 0) || (m_association_frame_idx__ <= idx) ) { - TLVF_LOG(ERROR) << "Requested index is greater than the number of available entries"; - return nullptr; - } - return &(m_association_frame[idx]); -} - -bool cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION::set_association_frame(const void* buffer, size_t size) { - if (buffer == nullptr) { - TLVF_LOG(WARNING) << "set_association_frame received a null pointer."; - return false; - } - if (!alloc_association_frame(size)) { return false; } - std::copy_n(reinterpret_cast(buffer), size, m_association_frame); - return true; -} -bool cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION::alloc_association_frame(size_t count) { - if (m_lock_order_counter__ > 0) {; - TLVF_LOG(ERROR) << "Out of order allocation for variable length list association_frame, abort!"; - return false; - } - size_t len = sizeof(uint8_t) * count; - if(getBuffRemainingBytes() < len ) { - TLVF_LOG(ERROR) << "Not enough available space on buffer - can't allocate"; - return false; - } - m_lock_order_counter__ = 0; - uint8_t *src = (uint8_t *)m_association_frame; - uint8_t *dst = src + len; - if (!m_parse__) { - size_t move_length = getBuffRemainingBytes(src) - len; - std::copy_n(src, move_length, dst); - } - m_association_frame_idx__ += count; - if (!buffPtrIncrementSafe(len)) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << len << ") Failed!"; - return false; - } - return true; -} - -void cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_BACKHAUL), reinterpret_cast(m_action_op)); - m_client_mac->struct_swap(); - m_bssid->struct_swap(); -} - -bool cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sMacAddr); // client_mac - class_size += sizeof(sMacAddr); // bssid - return class_size; -} - -bool cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_client_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_client_mac->struct_init(); } - m_bssid = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_bssid->struct_init(); } - m_association_frame = (uint8_t*)m_buff_ptr__; - m_association_frame_idx__ = getBuffRemainingBytes(); - if (m_parse__) { class_swap(); } - return true; -} - -cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION::cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION(uint8_t* buff, size_t buff_len, bool parse) : - BaseClass(buff, buff_len, parse) { - m_init_succeeded = init(); -} -cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION::cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION(std::shared_ptr base, bool parse) : -BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){ - m_init_succeeded = init(); -} -cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION::~cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION() { -} -sMacAddr& cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION::client_mac() { - return (sMacAddr&)(*m_client_mac); -} - -sMacAddr& cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION::bssid() { - return (sMacAddr&)(*m_bssid); -} - -void cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION::class_swap() -{ - tlvf_swap(8*sizeof(eActionOp_BACKHAUL), reinterpret_cast(m_action_op)); - m_client_mac->struct_swap(); - m_bssid->struct_swap(); -} - -bool cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION::finalize() -{ - if (m_parse__) { - TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set"; - return true; - } - if (m_finalized__) { - TLVF_LOG(DEBUG) << "finalize() called for already finalized class"; - return true; - } - if (!isPostInitSucceeded()) { - TLVF_LOG(ERROR) << "post init check failed"; - return false; - } - if (m_inner__) { - if (!m_inner__->finalize()) { - TLVF_LOG(ERROR) << "m_inner__->finalize() failed"; - return false; - } - auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength(); - m_buff_ptr__ -= tailroom; - } - class_swap(); - m_finalized__ = true; - return true; -} - -size_t cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION::get_initial_size() -{ - size_t class_size = 0; - class_size += sizeof(sMacAddr); // client_mac - class_size += sizeof(sMacAddr); // bssid - return class_size; -} - -bool cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION::init() -{ - if (getBuffRemainingBytes() < get_initial_size()) { - TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed"; - return false; - } - m_client_mac = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_client_mac->struct_init(); } - m_bssid = reinterpret_cast(m_buff_ptr__); - if (!buffPtrIncrementSafe(sizeof(sMacAddr))) { - LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(sMacAddr) << ") Failed!"; - return false; - } - if (!m_parse__) { m_bssid->struct_init(); } - if (m_parse__) { class_swap(); } - return true; -} - cACTION_BACKHAUL_ASSOCIATED_STA_LINK_METRICS_REQUEST::cACTION_BACKHAUL_ASSOCIATED_STA_LINK_METRICS_REQUEST(uint8_t* buff, size_t buff_len, bool parse) : BaseClass(buff, buff_len, parse) { m_init_succeeded = init(); diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml index 2470990648..2e9dbd47aa 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml @@ -122,23 +122,6 @@ cACTION_BACKHAUL_CLIENT_RX_RSSI_MEASUREMENT_CMD_RESPONSE: _type: class mac: sMacAddr -cACTION_BACKHAUL_HOSTAP_VAPS_LIST_UPDATE_NOTIFICATION: - _type: class - params: sVapsList - -cACTION_BACKHAUL_CLIENT_ASSOCIATED_NOTIFICATION: - _type: class - client_mac: sMacAddr - bssid: sMacAddr - association_frame: - _type: uint8_t - _length: [] - -cACTION_BACKHAUL_CLIENT_DISCONNECTED_NOTIFICATION: - _type: class - client_mac: sMacAddr - bssid: sMacAddr - cACTION_BACKHAUL_ASSOCIATED_STA_LINK_METRICS_REQUEST: _type: class sync: uint8_t From cb2fb89ca50d0b95d8fcb3add3d3c77847f21ca4 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Tue, 28 Jul 2020 13:57:10 +0000 Subject: [PATCH 429/453] agnet: Clear ethernet backhaul information on local gw On GW platform the ethernet interface which is used for backhaul connection must be empty since the GW doesn't need wired backhaul connection. Since it is being set on the constructor from the agent configuration file, clear it here when we know if the agent runs on a GW. Since now on GW platform the ethernet interface is empty, add a precondition for not being a GW before doing backhaul interfaces validation on STATE_BACKHAUL_ENABLE. PPM-320 Signed-off-by: Moran Shoeg --- agent/src/beerocks/slave/son_slave_thread.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 85805bc77d..914bd36c94 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -1309,6 +1309,17 @@ bool slave_thread::handle_cmdu_platform_manager_message( auto db = AgentDB::get(); + /** + * On GW platform the ethernet interface which is used for backhaul connection must be + * empty since the GW doesn't need wired backhaul connection. Since it is being set on + * the constructor from the agent configuration file, clear it here when we know if the + * agent runs on a GW. + */ + if (db->device_conf.local_gw) { + db->ethernet.iface_name.clear(); + db->ethernet.mac = network_utils::ZERO_MAC; + } + configuration_stop_on_failure_attempts = response->platform_settings().stop_on_failure_attempts; stop_on_failure_attempts = configuration_stop_on_failure_attempts; @@ -3014,6 +3025,13 @@ bool slave_thread::slave_fsm(bool &call_slave_select) case STATE_BACKHAUL_ENABLE: { bool error = false; auto db = AgentDB::get(); + + if (db->device_conf.local_gw) { + LOG(TRACE) << "goto STATE_SEND_BACKHAUL_MANAGER_ENABLE"; + slave_state = STATE_SEND_BACKHAUL_MANAGER_ENABLE; + break; + } + if (!db->ethernet.iface_name.empty()) { if (config.backhaul_wire_iface_type == beerocks::IFACE_TYPE_UNSUPPORTED) { LOG(DEBUG) << "backhaul_wire_iface_type is UNSUPPORTED"; From 8684958ffc107632b2116da4aab45b673e4ae9ac Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 29 Jul 2020 16:54:24 +0000 Subject: [PATCH 430/453] agent: Set and clear interface mac Until now, only the front interface mac has been set to a value after the fronthaul has joined. Add code that set the back radio interface mac as well after successful attach, and clear both front and back radio on a restart phase. PPM-320 Signed-off-by: Moran Shoeg --- agent/src/beerocks/slave/agent_db.h | 8 ++++++-- .../backhaul_manager_thread.cpp | 17 +++++++++++++++++ agent/src/beerocks/slave/son_slave_thread.cpp | 10 ++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/agent/src/beerocks/slave/agent_db.h b/agent/src/beerocks/slave/agent_db.h index 2544d13531..30893c248d 100644 --- a/agent/src/beerocks/slave/agent_db.h +++ b/agent/src/beerocks/slave/agent_db.h @@ -118,7 +118,8 @@ class AgentDB { struct sFront { explicit sFront(const std::string &iface_name_) - : iface_name(iface_name_), max_supported_bw(eWiFiBandwidth::BANDWIDTH_UNKNOWN), + : iface_name(iface_name_), iface_mac(net::network_utils::ZERO_MAC), + max_supported_bw(eWiFiBandwidth::BANDWIDTH_UNKNOWN), freq_type(eFreqType::FREQ_UNKNOWN) { } @@ -136,7 +137,10 @@ class AgentDB { } front; struct sBack { - explicit sBack(const std::string &iface_name_) : iface_name(iface_name_) {} + explicit sBack(const std::string &iface_name_) + : iface_name(iface_name_), iface_mac(net::network_utils::ZERO_MAC) + { + } std::string iface_name; sMacAddr iface_mac; } back; diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 968cf88769..79659101b0 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -1082,6 +1082,14 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) for (auto soc : slaves_sockets) { std::string iface = soc->sta_iface; + auto radio = db->radio(soc->sta_iface); + if (!radio) { + LOG(DEBUG) << "Radio of iface " << soc->sta_iface << " does not exist on the db"; + continue; + } + // Clear the backhaul interface mac. + radio->back.iface_mac = network_utils::ZERO_MAC; + if (soc->sta_wlan_hal) { soc->sta_wlan_hal.reset(); } @@ -1436,6 +1444,15 @@ bool backhaul_manager::backhaul_fsm_wireless(bool &skip_select) // break; // } + auto radio = db->radio(soc->sta_iface); + if (!radio) { + LOG(DEBUG) << "Radio of iface " << soc->sta_iface + << " does not exist on the db"; + continue; + } + // Update the backhaul interface mac. + radio->back.iface_mac = tlvf::mac_from_string(soc->sta_wlan_hal->get_radio_mac()); + } else if (attach_state == bwl::HALState::Failed) { // Delete the HAL instance soc->sta_wlan_hal.reset(); diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index 914bd36c94..5afbccff0e 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -154,6 +154,16 @@ void slave_thread::slave_reset() is_backhaul_manager = false; detach_on_conf_change = false; + auto db = AgentDB::get(); + + auto radio = db->radio(m_fronthaul_iface); + if (!radio) { + LOG(ERROR) << "Radio of iface " << m_fronthaul_iface << " does not exist on the db"; + return; + } + // Clear the front interface mac. + radio->front.iface_mac = network_utils::ZERO_MAC; + if (configuration_stop_on_failure_attempts && !stop_on_failure_attempts) { LOG(ERROR) << "Reached to max stop on failure attempts!"; stopped = true; From 1908e74de2e444c72507a2fcfbd38c536e835cd1 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Tue, 28 Jul 2020 15:43:38 +0000 Subject: [PATCH 431/453] agent: Move media_type function to different file Media type functionality is needed by few Multi-AP flows. One of the Unified Agent goals is to keep the backhaul manager slim as possible and moving all code that is unrelated to backhaul link establishment out of the thread. Therefore, move media_type functionality out to an external file. PPM-320 Signed-off-by: Moran Shoeg --- agent/src/beerocks/slave/CMakeLists.txt | 1 + .../backhaul_manager_thread.cpp | 122 ++---------------- .../backhaul_manager_thread.h | 16 --- .../src/beerocks/slave/helpers/media_type.cpp | 106 +++++++++++++++ agent/src/beerocks/slave/helpers/media_type.h | 42 ++++++ 5 files changed, 158 insertions(+), 129 deletions(-) create mode 100644 agent/src/beerocks/slave/helpers/media_type.cpp create mode 100644 agent/src/beerocks/slave/helpers/media_type.h diff --git a/agent/src/beerocks/slave/CMakeLists.txt b/agent/src/beerocks/slave/CMakeLists.txt index dec96a8420..c89917c0f8 100644 --- a/agent/src/beerocks/slave/CMakeLists.txt +++ b/agent/src/beerocks/slave/CMakeLists.txt @@ -10,6 +10,7 @@ file(GLOB beerocks_agent_sources # [TASK] Move link metric related classes to BPL #910 ${MODULE_PATH}/link_metrics/*.c* ${MODULE_PATH}/platform_manager/*.c* + ${MODULE_PATH}/helpers/*.c* ${MODULE_PATH}/tasks/*.c* ${MODULE_PATH}/gate/*.c* ${MODULE_PATH}/*.c* diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 79659101b0..5e855506d2 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -31,6 +31,7 @@ #include "backhaul_manager_thread.h" #include "../agent_db.h" +#include "../helpers/media_type.h" #include "../link_metrics/ieee802_11_link_metrics_collector.h" #include "../link_metrics/ieee802_3_link_metrics_collector.h" #include "../tlvf_utils.h" @@ -120,68 +121,6 @@ namespace beerocks { const char *backhaul_manager::s_arrStates[] = {FOREACH_STATE(GENERATE_STRING)}; -/** - * IEEE Std 1905.1, Table 6-12—Media type (intfType) for IEEE 802.11 interfaces - * - * Value and Description Frequency MaxBandwith Comments - * 0 IEEE 802.11b (2.4 GHz) 2.4 GHz 22 MHz Not supported - * 1 IEEE 802.11g (2.4 GHz) 2.4 GHz 20 MHz - * 2 IEEE 802.11a (5 GHz) 5 GHz 20 MHz - * 3 IEEE 802.11n (2.4 GHz) 2.4 GHz 40 MHz - * 4 IEEE 802.11n (5 GHz) 5 GHz 40 MHz - * 5 IEEE 802.11ac (5 GHz) 5 GHz 80 MHz - * 6 IEEE 802.11ad (60 GHz) 60 GHz 160 MHz Not supported - * 7 IEEE 802.11af (whitespace) Not supported - * 8 IEEE 802.11ax (2.4 GHz) 2.4 GHz 160 MHz Not included in Table 6-12—Media type (intfType), WiFi6 is specified to use 0x0108 in R2 - * 8 IEEE 802.11ax (5 GHz) 5 GHz 160 MHz Not included in Table 6-12—Media type (intfType), WiFi6 is specified to use 0x0108 in R2 - */ -static const std::vector> - table_6_12_media_type_802_11{ - std::make_tuple(eFreqType::FREQ_24G, eWiFiBandwidth::BANDWIDTH_20, - ieee1905_1::eMediaType::IEEE_802_11G_2_4_GHZ), - - std::make_tuple(eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_20, - ieee1905_1::eMediaType::IEEE_802_11A_5_GHZ), - - std::make_tuple(eFreqType::FREQ_24G, eWiFiBandwidth::BANDWIDTH_40, - ieee1905_1::eMediaType::IEEE_802_11N_2_4_GHZ), - - std::make_tuple(eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_40, - ieee1905_1::eMediaType::IEEE_802_11N_5_GHZ), - - std::make_tuple(eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_80, - ieee1905_1::eMediaType::IEEE_802_11AC_5_GHZ), - - std::make_tuple(eFreqType::FREQ_24G, eWiFiBandwidth::BANDWIDTH_160, - ieee1905_1::eMediaType::IEEE_802_11AX), - - std::make_tuple(eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_160, - ieee1905_1::eMediaType::IEEE_802_11AX), - - }; - -/** - * @brief Gets media type from given frequency band and max bandwidth values. - * - * Media type value is obtained by looking up into table_6_12_media_type_802_11 table. - * Returns UNKNOWN_MEDIA if frequency band and max bandwidth are not found in table. - * - * @param frequency_band Frequency band - * @param max_bandwidth Maximum bandwidth - * @return Media type value as per table_6_12_media_type_802_11 table. - */ -static ieee1905_1::eMediaType get_802_11_media_type(eFreqType frequency_band, - eWiFiBandwidth max_bandwidth) -{ - for (const auto &tuple : table_6_12_media_type_802_11) { - if ((std::get<0>(tuple) == frequency_band) && (std::get<1>(tuple) == max_bandwidth)) { - return std::get<2>(tuple); - } - } - - return ieee1905_1::eMediaType::UNKNOWN_MEDIA; -} - /** * @brief Gets the MAC address of given interface. * @@ -2852,8 +2791,8 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd if (!local_interface_name.empty() && network_utils::linux_iface_is_up_and_running(local_interface_name)) { ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; - if (!get_media_type(local_interface_name, ieee1905_1::eMediaTypeGroup::IEEE_802_3, - media_type)) { + if (!MediaType::get_media_type(local_interface_name, + ieee1905_1::eMediaTypeGroup::IEEE_802_3, media_type)) { LOG(ERROR) << "Unable to compute media type for interface " << local_interface_name; return false; } @@ -2943,7 +2882,7 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd ieee1905_1::eMediaTypeGroup media_type_group = ieee1905_1::eMediaTypeGroup::IEEE_802_11; ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; - if (!get_media_type(local_interface_name, media_type_group, media_type)) { + if (!MediaType::get_media_type(local_interface_name, media_type_group, media_type)) { LOG(ERROR) << "Unable to compute media type for interface " << local_interface_name; return false; } @@ -4163,50 +4102,6 @@ std::shared_ptr backhaul_manager::get_wireless_hal(std::strin return slave_sk->second->sta_wlan_hal; } -bool backhaul_manager::get_media_type(const std::string &interface_name, - ieee1905_1::eMediaTypeGroup media_type_group, - ieee1905_1::eMediaType &media_type) -{ - bool result = false; - - if (ieee1905_1::eMediaTypeGroup::IEEE_802_3 == media_type_group) { - uint32_t speed; - if (network_utils::linux_iface_get_speed(interface_name, speed)) { - if (SPEED_100 == speed) { - media_type = ieee1905_1::eMediaType::IEEE_802_3U_FAST_ETHERNET; - } else if (SPEED_1000 <= speed) { - media_type = ieee1905_1::eMediaType::IEEE_802_3AB_GIGABIT_ETHERNET; - } else { - media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; - } - - result = true; - } - } else if (ieee1905_1::eMediaTypeGroup::IEEE_802_11 == media_type_group) { - - auto db = AgentDB::get(); - - auto radio = db->radio(interface_name); - if (radio) { - media_type = - get_802_11_media_type(radio->front.freq_type, radio->front.max_supported_bw); - result = true; - } - - } else if (ieee1905_1::eMediaTypeGroup::IEEE_1901 == media_type_group) { - // TODO: Not supported yet - LOG(ERROR) << "IEEE_1901 media is not supported yet"; - } else if (ieee1905_1::eMediaTypeGroup::MoCA == media_type_group) { - // TODO: Not supported yet - LOG(ERROR) << "MoCA media is not supported yet"; - } else { - media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; - result = true; - } - - return result; -} - std::unique_ptr backhaul_manager::create_link_metrics_collector(const sLinkInterface &link_interface) const { @@ -4244,8 +4139,9 @@ bool backhaul_manager::get_neighbor_links( wired_interface.iface_name = db->ethernet.iface_name; - if (!get_media_type(wired_interface.iface_name, ieee1905_1::eMediaTypeGroup::IEEE_802_3, - wired_interface.media_type)) { + if (!MediaType::get_media_type(wired_interface.iface_name, + ieee1905_1::eMediaTypeGroup::IEEE_802_3, + wired_interface.media_type)) { LOG(ERROR) << "Unable to compute media type for interface " << wired_interface.iface_name; return false; } @@ -4283,8 +4179,8 @@ bool backhaul_manager::get_neighbor_links( } interface.iface_mac = bssid; - interface.media_type = beerocks::get_802_11_media_type(radio->front.freq_type, - radio->front.max_supported_bw); + interface.media_type = MediaType::get_802_11_media_type(radio->front.freq_type, + radio->front.max_supported_bw); if (ieee1905_1::eMediaType::UNKNOWN_MEDIA == interface.media_type) { LOG(ERROR) << "Unknown media type for interface " << interface.iface_name; diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index faef31007b..a676772bed 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -377,22 +377,6 @@ class backhaul_manager : public btl::transport_socket_thread { beerocks::net::network_utils::ZERO_MAC; /**< The MAC address of the interface. */ }; - /** - * @brief Gets media type for given interface. - * - * The mechanism to use to obtain media type depends on the media type group: - * Ethernet, WiFi, MoCA, etc. - * - * @param[in] interface_name Name of the local interface. - * @param[in] media_type_group The media type group of the connecting interface. - * @param[in, out] media_type The underlying network technology of the connecting interface. - * - * @return True on success and false otherwise. - */ - bool get_media_type(const std::string &interface_name, - ieee1905_1::eMediaTypeGroup media_type_group, - ieee1905_1::eMediaType &media_type); - /** * @brief Creates a new link metrics collector for given media type. * diff --git a/agent/src/beerocks/slave/helpers/media_type.cpp b/agent/src/beerocks/slave/helpers/media_type.cpp new file mode 100644 index 0000000000..2b5e4dc4f9 --- /dev/null +++ b/agent/src/beerocks/slave/helpers/media_type.cpp @@ -0,0 +1,106 @@ +#include "media_type.h" + +#include + +#include "../agent_db.h" + +// SPEED values +#include + +namespace beerocks { +/** + * IEEE Std 1905.1, Table 6-12—Media type (intfType) for IEEE 802.11 interfaces + * + * Value and Description Frequency MaxBandwith Comments + * 0 IEEE 802.11b (2.4 GHz) 2.4 GHz 22 MHz Not supported + * 1 IEEE 802.11g (2.4 GHz) 2.4 GHz 20 MHz + * 2 IEEE 802.11a (5 GHz) 5 GHz 20 MHz + * 3 IEEE 802.11n (2.4 GHz) 2.4 GHz 40 MHz + * 4 IEEE 802.11n (5 GHz) 5 GHz 40 MHz + * 5 IEEE 802.11ac (5 GHz) 5 GHz 80 MHz + * 6 IEEE 802.11ad (60 GHz) 60 GHz 160 MHz Not supported + * 7 IEEE 802.11af (whitespace) Not supported + * 8 IEEE 802.11ax (2.4 GHz) 2.4 GHz 160 MHz Not included in Table 6-12—Media type (intfType), WiFi6 is specified to use 0x0108 in R2 + * 8 IEEE 802.11ax (5 GHz) 5 GHz 160 MHz Not included in Table 6-12—Media type (intfType), WiFi6 is specified to use 0x0108 in R2 + */ +static const std::vector> + table_6_12_media_type_802_11{ + std::make_tuple(eFreqType::FREQ_24G, eWiFiBandwidth::BANDWIDTH_20, + ieee1905_1::eMediaType::IEEE_802_11G_2_4_GHZ), + + std::make_tuple(eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_20, + ieee1905_1::eMediaType::IEEE_802_11A_5_GHZ), + + std::make_tuple(eFreqType::FREQ_24G, eWiFiBandwidth::BANDWIDTH_40, + ieee1905_1::eMediaType::IEEE_802_11N_2_4_GHZ), + + std::make_tuple(eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_40, + ieee1905_1::eMediaType::IEEE_802_11N_5_GHZ), + + std::make_tuple(eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_80, + ieee1905_1::eMediaType::IEEE_802_11AC_5_GHZ), + + std::make_tuple(eFreqType::FREQ_24G, eWiFiBandwidth::BANDWIDTH_160, + ieee1905_1::eMediaType::IEEE_802_11AX), + + std::make_tuple(eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_160, + ieee1905_1::eMediaType::IEEE_802_11AX), + + }; + +ieee1905_1::eMediaType MediaType::get_802_11_media_type(eFreqType frequency_band, + eWiFiBandwidth max_bandwidth) +{ + for (const auto &tuple : table_6_12_media_type_802_11) { + if ((std::get<0>(tuple) == frequency_band) && (std::get<1>(tuple) == max_bandwidth)) { + return std::get<2>(tuple); + } + } + + return ieee1905_1::eMediaType::UNKNOWN_MEDIA; +} + +bool MediaType::get_media_type(const std::string &interface_name, + ieee1905_1::eMediaTypeGroup media_type_group, + ieee1905_1::eMediaType &media_type) +{ + bool result = false; + + if (ieee1905_1::eMediaTypeGroup::IEEE_802_3 == media_type_group) { + uint32_t speed; + if (net::network_utils::linux_iface_get_speed(interface_name, speed)) { + if (SPEED_100 == speed) { + media_type = ieee1905_1::eMediaType::IEEE_802_3U_FAST_ETHERNET; + } else if (SPEED_1000 <= speed) { + media_type = ieee1905_1::eMediaType::IEEE_802_3AB_GIGABIT_ETHERNET; + } else { + media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; + } + + result = true; + } + } else if (ieee1905_1::eMediaTypeGroup::IEEE_802_11 == media_type_group) { + + auto db = AgentDB::get(); + + auto radio = db->radio(interface_name); + if (radio) { + media_type = + get_802_11_media_type(radio->front.freq_type, radio->front.max_supported_bw); + result = true; + } + + } else if (ieee1905_1::eMediaTypeGroup::IEEE_1901 == media_type_group) { + // TODO: Not supported yet + LOG(ERROR) << "IEEE_1901 media is not supported yet"; + } else if (ieee1905_1::eMediaTypeGroup::MoCA == media_type_group) { + // TODO: Not supported yet + LOG(ERROR) << "MoCA media is not supported yet"; + } else { + media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; + result = true; + } + + return result; +} +} // namespace beerocks diff --git a/agent/src/beerocks/slave/helpers/media_type.h b/agent/src/beerocks/slave/helpers/media_type.h new file mode 100644 index 0000000000..f09f90219a --- /dev/null +++ b/agent/src/beerocks/slave/helpers/media_type.h @@ -0,0 +1,42 @@ + +#include + +#include + +#include + +namespace beerocks { + +class MediaType { + +public: + /** + * @brief Gets media type from given frequency band and max bandwidth values. + * + * Media type value is obtained by looking up into table_6_12_media_type_802_11 table. + * Returns UNKNOWN_MEDIA if frequency band and max bandwidth are not found in table. + * + * @param frequency_band Frequency band. + * @param max_bandwidth Maximum bandwidth. + * @return Media type value as per table_6_12_media_type_802_11 table. + */ + static ieee1905_1::eMediaType get_802_11_media_type(eFreqType frequency_band, + eWiFiBandwidth max_bandwidth); + /** + * @brief Gets media type for given interface. + * + * The mechanism to use to obtain media type depends on the media type group: + * Ethernet, WiFi, MoCA, etc. + * + * @param[in] interface_name Name of the local interface. + * @param[in] media_type_group The media type group of the connecting interface. + * @param[in, out] media_type The underlying network technology of the connecting interface. + * + * @return True on success and false otherwise. + */ + static bool get_media_type(const std::string &interface_name, + ieee1905_1::eMediaTypeGroup media_type_group, + ieee1905_1::eMediaType &media_type); +}; + +} // namespace beerocks From 5b21b6f976d7d10db5a4ad0e0ffc32524b00af32 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 29 Jul 2020 13:53:23 +0000 Subject: [PATCH 432/453] agent: Add a skeleton for the Topology task Add a skeleton for the Topology task, without any real content except a constructor. Add the task to the task pool on the backhaul manager. On the follow-ups commits I will move pieces by pieces of code from the backhaul manager to the Topology Task, to make the review easier. PPM-320 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 7 ++++ .../beerocks/slave/tasks/topology_task.cpp | 37 +++++++++++++++++++ .../src/beerocks/slave/tasks/topology_task.h | 33 +++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 agent/src/beerocks/slave/tasks/topology_task.cpp create mode 100644 agent/src/beerocks/slave/tasks/topology_task.h diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 5e855506d2..06196ec7d1 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -34,6 +34,7 @@ #include "../helpers/media_type.h" #include "../link_metrics/ieee802_11_link_metrics_collector.h" #include "../link_metrics/ieee802_3_link_metrics_collector.h" +#include "../tasks/topology_task.h" #include "../tlvf_utils.h" #include @@ -186,6 +187,12 @@ backhaul_manager::backhaul_manager(const config_file::sConfigSlave &config, m_eFSMState = EState::INIT; set_select_timeout(SELECT_TIMEOUT_MSC); + + auto topology_task = std::make_shared(*this, cmdu_tx); + if (!topology_task) { + LOG(ERROR) << "failed to allocate Topology Task!"; + } + m_task_pool.add_task(topology_task); } backhaul_manager::~backhaul_manager() { backhaul_manager::on_thread_stop(); } diff --git a/agent/src/beerocks/slave/tasks/topology_task.cpp b/agent/src/beerocks/slave/tasks/topology_task.cpp new file mode 100644 index 0000000000..a52c37f8b8 --- /dev/null +++ b/agent/src/beerocks/slave/tasks/topology_task.cpp @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#include "topology_task.h" +#include "../agent_db.h" +#include "../backhaul_manager/backhaul_manager_thread.h" +#include "../helpers/media_type.h" + +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +using namespace beerocks; +using namespace net; +using namespace son; + +TopologyTask::TopologyTask(backhaul_manager &btl_ctx, ieee1905_1::CmduMessageTx &cmdu_tx) + : Task(eTaskType::TOPOLOGY), m_btl_ctx(btl_ctx), m_cmdu_tx(cmdu_tx) +{ +} diff --git a/agent/src/beerocks/slave/tasks/topology_task.h b/agent/src/beerocks/slave/tasks/topology_task.h new file mode 100644 index 0000000000..b46e5051a1 --- /dev/null +++ b/agent/src/beerocks/slave/tasks/topology_task.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent + * + * SPDX-FileCopyrightText: 2016-2020 the prplMesh contributors (see AUTHORS.md) + * + * This code is subject to the terms of the BSD+Patent license. + * See LICENSE file for more details. + */ + +#ifndef _TOPOLOGY_TASK_H_ +#define _TOPOLOGY_TASK_H_ + +#include "task.h" + +#include + +namespace beerocks { + +// Forward decleration for backhaul_manager context saving +class backhaul_manager; + +class TopologyTask : public Task { +public: + TopologyTask(backhaul_manager &btl_ctx, ieee1905_1::CmduMessageTx &cmdu_tx); + ~TopologyTask() {} + +private: + backhaul_manager &m_btl_ctx; + ieee1905_1::CmduMessageTx &m_cmdu_tx; +}; + +} // namespace beerocks + +#endif // _TOPOLOGY_TASK_H_ From c0f96be5675d486f0a7f1a69e5299c9c11116e8f Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 29 Jul 2020 17:33:04 +0000 Subject: [PATCH 433/453] agent: Add send_topology_notification function Preparative commit. Add send_topology_notification function to topology task. This function is not replacing any function on the backhaul manager since it does not exist. Currently, the backhaul manager builds this message on each place it needs to send it. This function will be used on the next commits. PPM-320 Signed-off-by: Moran Shoeg --- agent/src/beerocks/slave/tasks/topology_task.cpp | 12 ++++++++++++ agent/src/beerocks/slave/tasks/topology_task.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/agent/src/beerocks/slave/tasks/topology_task.cpp b/agent/src/beerocks/slave/tasks/topology_task.cpp index a52c37f8b8..6788a85a0b 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.cpp +++ b/agent/src/beerocks/slave/tasks/topology_task.cpp @@ -35,3 +35,15 @@ TopologyTask::TopologyTask(backhaul_manager &btl_ctx, ieee1905_1::CmduMessageTx : Task(eTaskType::TOPOLOGY), m_btl_ctx(btl_ctx), m_cmdu_tx(cmdu_tx) { } + +void TopologyTask::send_topology_notification() +{ + auto cmdu_header = m_cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_NOTIFICATION_MESSAGE); + if (!cmdu_header) { + LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; + return; + } + auto db = AgentDB::get(); + m_btl_ctx.send_cmdu_to_broker(m_cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, + tlvf::mac_to_string(db->bridge.mac)); +} diff --git a/agent/src/beerocks/slave/tasks/topology_task.h b/agent/src/beerocks/slave/tasks/topology_task.h index b46e5051a1..356e4cb753 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.h +++ b/agent/src/beerocks/slave/tasks/topology_task.h @@ -24,6 +24,9 @@ class TopologyTask : public Task { ~TopologyTask() {} private: + /* Helper functions */ + void send_topology_notification(); + backhaul_manager &m_btl_ctx; ieee1905_1::CmduMessageTx &m_cmdu_tx; }; From c1ed13c2dd99397125f9a45b0faf94ca90f48235 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 29 Jul 2020 17:44:27 +0000 Subject: [PATCH 434/453] agent: Add send_topology_discovery function Preparative commit. Add send_topology_discovery function to the topology task. Remove the same function from the backhaul manager. Note that this commit breaks the compilation since the call for the removed function remained on the backhaul manager. This is done for code reviewability and will be fixed on the next commit. PPM-320 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 60 ------------------- .../backhaul_manager_thread.h | 9 --- .../beerocks/slave/tasks/topology_task.cpp | 56 +++++++++++++++++ .../src/beerocks/slave/tasks/topology_task.h | 1 + 4 files changed, 57 insertions(+), 69 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 06196ec7d1..107c45bd1e 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -1091,66 +1091,6 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) return (true); } // namespace beerocks -bool backhaul_manager::send_1905_topology_discovery_message() -{ - // TODO: get the list of interfaces that are up_and_running using the event-driven mechanism - // to be implemented in #866 - - /** - * Transmission type of Topology Discovery message is 'neighbor multicast'. - * That is, the CMDU must be transmitted once on each and every of its 1905.1 interfaces. - * Also, according to IEEE1905.1, the message should include a MAC Address TLV which contains - * the address of the interface on which the message is sent. Thus, a different message should - * be sent on each interface. - */ - auto db = AgentDB::get(); - auto ifaces = network_utils::linux_get_iface_list_from_bridge(db->bridge.iface_name); - for (const auto &iface_name : ifaces) { - if (!network_utils::linux_iface_is_up_and_running(iface_name)) { - continue; - } - - send_1905_topology_discovery_message(iface_name); - } - - return true; -} - -bool backhaul_manager::send_1905_topology_discovery_message(const std::string &iface_name) -{ - sMacAddr iface_mac; - if (!get_iface_mac(iface_name, iface_mac)) { - return false; - } - - auto cmdu_hdr = cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_DISCOVERY_MESSAGE); - if (!cmdu_hdr) { - LOG(ERROR) << "Failed to create TOPOLOGY_DISCOVERY_MESSAGE cmdu"; - return false; - } - - auto db = AgentDB::get(); - - auto tlvAlMacAddress = cmdu_tx.addClass(); - if (!tlvAlMacAddress) { - LOG(ERROR) << "Failed to create tlvAlMacAddress tlv"; - return false; - } - tlvAlMacAddress->mac() = db->bridge.mac; - - auto tlvMacAddress = cmdu_tx.addClass(); - if (!tlvMacAddress) { - LOG(ERROR) << "Failed to create tlvMacAddress tlv"; - return false; - } - tlvMacAddress->mac() = iface_mac; - - LOG(DEBUG) << "send_1905_topology_discovery_message, bridge_mac=" << db->bridge.mac - << ", iface=" << iface_name; - return send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, - tlvf::mac_to_string(db->bridge.mac), iface_name); -} - bool backhaul_manager::send_autoconfig_search_message(const std::string &front_radio_iface_name) { auto db = AgentDB::get(); diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index a676772bed..69f62f9e94 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -95,15 +95,6 @@ class backhaul_manager : public btl::transport_socket_thread { std::shared_ptr pSocket = nullptr); // cmdu_duplicate bool send_autoconfig_search_message(const std::string &front_radio_iface_name); - bool send_1905_topology_discovery_message(); - - /** - * @brief Sends Topology Discovery message on given interface. - * - * @param iface_name Name of the network interface on which the message is transmitted. - * @return True on success and false otherwise - */ - bool send_1905_topology_discovery_message(const std::string &iface_name); /** * @brief Sends an AP Metrics Query message for each bssid on 'bssid_list' to the son_slaves. diff --git a/agent/src/beerocks/slave/tasks/topology_task.cpp b/agent/src/beerocks/slave/tasks/topology_task.cpp index 6788a85a0b..8702fd4815 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.cpp +++ b/agent/src/beerocks/slave/tasks/topology_task.cpp @@ -36,6 +36,62 @@ TopologyTask::TopologyTask(backhaul_manager &btl_ctx, ieee1905_1::CmduMessageTx { } +void TopologyTask::send_topology_discovery() +{ + // TODO: get the list of interfaces that are up_and_running using the event-driven mechanism + // to be implemented in #866 + + /** + * Transmission type of Topology Discovery message is 'neighbor multicast'. + * That is, the CMDU must be transmitted once on each and every of its 1905.1 interfaces. + * Also, according to IEEE1905.1, the message should include a MAC Address TLV which contains + * the address of the interface on which the message is sent. Thus, a different message should + * be sent on each interface. + */ + auto db = AgentDB::get(); + + // Make list of ifaces Macs to send on the message. + auto ifaces = network_utils::linux_get_iface_list_from_bridge(db->bridge.iface_name); + for (const auto &iface_name : ifaces) { + if (!network_utils::linux_iface_is_up_and_running(iface_name)) { + continue; + } + + std::string iface_mac_str; + if (!network_utils::linux_iface_get_mac(iface_name, iface_mac_str)) { + LOG(ERROR) << "Failed getting MAC address for interface: " << iface_name; + return; + } + + auto iface_mac = tlvf::mac_from_string(iface_mac_str); + + auto cmdu_header = + m_cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_DISCOVERY_MESSAGE); + if (!cmdu_header) { + LOG(ERROR) << "Failed to create TOPOLOGY_DISCOVERY_MESSAGE cmdu"; + return; + } + auto tlvAlMacAddress = m_cmdu_tx.addClass(); + if (!tlvAlMacAddress) { + LOG(ERROR) << "Failed to create tlvAlMacAddress tlv"; + return; + } + tlvAlMacAddress->mac() = db->bridge.mac; + + auto tlvMacAddress = m_cmdu_tx.addClass(); + if (!tlvMacAddress) { + LOG(ERROR) << "Failed to create tlvMacAddress tlv"; + return; + } + tlvMacAddress->mac() = iface_mac; + + LOG(DEBUG) << "send_1905_topology_discovery_message, bridge_mac=" << db->bridge.mac + << ", iface=" << iface_name; + m_btl_ctx.send_cmdu_to_broker(m_cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, + tlvf::mac_to_string(db->bridge.mac), iface_name); + } +} + void TopologyTask::send_topology_notification() { auto cmdu_header = m_cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_NOTIFICATION_MESSAGE); diff --git a/agent/src/beerocks/slave/tasks/topology_task.h b/agent/src/beerocks/slave/tasks/topology_task.h index 356e4cb753..da87e59083 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.h +++ b/agent/src/beerocks/slave/tasks/topology_task.h @@ -25,6 +25,7 @@ class TopologyTask : public Task { private: /* Helper functions */ + void send_topology_discovery(); void send_topology_notification(); backhaul_manager &m_btl_ctx; From f7bc0e0bc2a085d1f381ea46a0a636b660df4e03 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 29 Jul 2020 17:50:48 +0000 Subject: [PATCH 435/453] agent: Add to the topology task a work function Add to the topology task a work function. Move the topology related code from backhaul manager "after_select" function new topology task work function. PPM-320 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 47 ------------------- .../beerocks/slave/tasks/topology_task.cpp | 47 +++++++++++++++++++ .../src/beerocks/slave/tasks/topology_task.h | 2 + 3 files changed, 49 insertions(+), 47 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 107c45bd1e..b4ec09eaf5 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -447,53 +447,6 @@ void backhaul_manager::after_select(bool timeout) } } - auto db = AgentDB::get(); - - // Send topology discovery every 60 seconds according to IEEE_Std_1905.1-2013 specification - static std::chrono::steady_clock::time_point discovery_timestamp = - std::chrono::steady_clock::now(); - auto now = std::chrono::steady_clock::now(); - auto elapsed = std::chrono::duration_cast(now - discovery_timestamp); - if ((m_eFSMState == EState::CONNECTED) || - (m_eFSMState == EState::OPERATIONAL && elapsed.count() == 60)) { - discovery_timestamp = now; - send_1905_topology_discovery_message(); - } - - // Each platform must send Topology Discovery message every 60 seconds to its first circle - // 1905.1 neighbors. - // Iterate on each of known 1905.1 neighbors and check if we have received in the last - // 60 seconds a Topology Discovery message from it. If not, remove this neighbor from our list - // and send a Topology Notification message. - bool neighbors_list_changed = false; - for (auto &neighbors_on_local_iface_entry : db->neighbor_devices) { - auto &neighbors_on_local_iface = neighbors_on_local_iface_entry.second; - for (auto it = neighbors_on_local_iface.begin(); it != neighbors_on_local_iface.end();) { - auto &last_topology_discovery = it->second.timestamp; - if (now - last_topology_discovery > - std::chrono::seconds(DISCOVERY_NEIGHBOUR_REMOVAL_TIMEOUT)) { - auto &device_al_mac = it->first; - LOG(INFO) << "Removed 1905.1 device " << device_al_mac << " from neighbors list"; - it = neighbors_on_local_iface.erase(it); - neighbors_list_changed = true; - continue; - } - it++; - } - } - - if (neighbors_list_changed) { - LOG(INFO) << "Sending topology notification on removeing of 1905.1 neighbors"; - auto cmdu_header = - cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_NOTIFICATION_MESSAGE); - if (!cmdu_header) { - LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; - return; - } - send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, - tlvf::mac_to_string(db->bridge.mac)); - } - // Run Tasks m_task_pool.run_tasks(); } diff --git a/agent/src/beerocks/slave/tasks/topology_task.cpp b/agent/src/beerocks/slave/tasks/topology_task.cpp index 8702fd4815..2d1f1ed86d 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.cpp +++ b/agent/src/beerocks/slave/tasks/topology_task.cpp @@ -36,6 +36,53 @@ TopologyTask::TopologyTask(backhaul_manager &btl_ctx, ieee1905_1::CmduMessageTx { } +void TopologyTask::work() +{ + auto now = std::chrono::steady_clock::now(); + + // Send topology discovery every 60 seconds according to IEEE_Std_1905.1-2013 specification + constexpr uint8_t TOPOLOGY_DISCOVERY_TX_CYCLE_SEC = 60; + static std::chrono::steady_clock::time_point discovery_timestamp = + std::chrono::steady_clock::now(); + + if (now - discovery_timestamp > std::chrono::seconds(TOPOLOGY_DISCOVERY_TX_CYCLE_SEC)) { + discovery_timestamp = now; + send_topology_discovery(); + } + + // Each platform must send Topology Discovery message every 60 seconds to its first circle + // 1905.1 neighbors. + // Iterate on each of known 1905.1 neighbors and check if we have received in the last + // 60 seconds a Topology Discovery message from it. If not, remove this neighbor from our list + // and send a Topology Notification message. + static constexpr uint8_t DISCOVERY_NEIGHBOUR_REMOVAL_TIMEOUT_SEC = + ieee1905_1_consts::DISCOVERY_NOTIFICATION_TIMEOUT_SEC + 3; // 3 seconds grace period. + + auto db = AgentDB::get(); + + bool neighbors_list_changed = false; + for (auto &neighbors_on_local_iface_entry : db->neighbor_devices) { + auto &neighbors_on_local_iface = neighbors_on_local_iface_entry.second; + for (auto it = neighbors_on_local_iface.begin(); it != neighbors_on_local_iface.end();) { + auto &last_topology_discovery = it->second.timestamp; + if (now - last_topology_discovery > + std::chrono::seconds(DISCOVERY_NEIGHBOUR_REMOVAL_TIMEOUT_SEC)) { + auto &device_al_mac = it->first; + LOG(INFO) << "Removed 1905.1 device " << device_al_mac << " from neighbors list"; + it = neighbors_on_local_iface.erase(it); + neighbors_list_changed = true; + continue; + } + it++; + } + } + + if (neighbors_list_changed) { + LOG(INFO) << "Sending topology notification on removeing of 1905.1 neighbors"; + send_topology_notification(); + } +} + void TopologyTask::send_topology_discovery() { // TODO: get the list of interfaces that are up_and_running using the event-driven mechanism diff --git a/agent/src/beerocks/slave/tasks/topology_task.h b/agent/src/beerocks/slave/tasks/topology_task.h index da87e59083..a740d2cc7c 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.h +++ b/agent/src/beerocks/slave/tasks/topology_task.h @@ -23,6 +23,8 @@ class TopologyTask : public Task { TopologyTask(backhaul_manager &btl_ctx, ieee1905_1::CmduMessageTx &cmdu_tx); ~TopologyTask() {} + void work() override; + private: /* Helper functions */ void send_topology_discovery(); From 0c791ec13ac1a13c0917749084bf17fee781ecab Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 29 Jul 2020 18:16:47 +0000 Subject: [PATCH 436/453] agent: Move the topology discovery handler to the Topology Task Move the topology discovery handler from the backhaul manager to the Topology Task. As part of this commit add the cmdu handler to the topology task as well. PPM-320 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 77 --------------- .../backhaul_manager_thread.h | 2 - .../beerocks/slave/tasks/topology_task.cpp | 95 +++++++++++++++++++ .../src/beerocks/slave/tasks/topology_task.h | 13 +++ 4 files changed, 108 insertions(+), 79 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index b4ec09eaf5..dce9e180ac 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -2076,8 +2076,6 @@ bool backhaul_manager::handle_1905_1_message(ieee1905_1::CmduMessageRx &cmdu_rx, * false if the message needs to be forwarded by the calling function */ switch (cmdu_rx.getMessageType()) { - case ieee1905_1::eMessageType::TOPOLOGY_DISCOVERY_MESSAGE: - return handle_1905_topology_discovery(src_mac, cmdu_rx); case ieee1905_1::eMessageType::AP_AUTOCONFIGURATION_RESPONSE_MESSAGE: { return handle_1905_autoconfiguration_response(cmdu_rx, src_mac); } @@ -3180,81 +3178,6 @@ bool backhaul_manager::handle_1905_combined_infrastructure_metrics( return send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); } -bool backhaul_manager::handle_1905_topology_discovery(const std::string &src_mac, - ieee1905_1::CmduMessageRx &cmdu_rx) -{ - auto tlvAlMac = cmdu_rx.getClass(); - if (!tlvAlMac) { - LOG(ERROR) << "getClass tlvAlMacAddress failed"; - return false; - } - - auto db = AgentDB::get(); - - // Filter out the messages we have sent. - if (tlvAlMac->mac() == db->bridge.mac) { - return true; - } - - auto mid = cmdu_rx.getMessageId(); - LOG(INFO) << "Received TOPOLOGY_DISCOVERY_MESSAGE from AL MAC=" << tlvAlMac->mac() - << ", mid=" << std::hex << mid; - - auto tlvMac = cmdu_rx.getClass(); - if (!tlvMac) { - LOG(ERROR) << "getClass tlvMacAddress failed"; - return false; - } - - uint32_t if_index = message_com::get_uds_header(cmdu_rx)->if_index; - std::string local_receiving_iface_name = network_utils::linux_get_iface_name(if_index); - if (local_receiving_iface_name.empty()) { - LOG(ERROR) << "Failed getting interface name for index: " << if_index; - return false; - } - - std::string local_receiving_iface_mac_str; - if (!network_utils::linux_iface_get_mac(local_receiving_iface_name, - local_receiving_iface_mac_str)) { - LOG(ERROR) << "Failed getting MAC address for interface: " << local_receiving_iface_name; - return false; - } - - // Check if it is a new device so if it does, we will send Topology Notification. - bool new_device = false; - for (auto &neighbors_on_local_iface_entry : db->neighbor_devices) { - auto &neighbors_on_local_iface = neighbors_on_local_iface_entry.second; - new_device = - neighbors_on_local_iface.find(tlvAlMac->mac()) == neighbors_on_local_iface.end(); - if (new_device) { - break; - } - } - - // Add/Update the device on our list. - auto &neighbor_devices_by_al_mac = - db->neighbor_devices[tlvf::mac_from_string(local_receiving_iface_mac_str)]; - - // Update an exist neighbor. - neighbor_devices_by_al_mac[tlvAlMac->mac()].transmitting_iface_mac = tlvMac->mac(); - neighbor_devices_by_al_mac[tlvAlMac->mac()].timestamp = std::chrono::steady_clock::now(); - - // If it is a new device, then our 1905.1 neighbors list has changed and we are required to send - // Topology Notification Message. - if (new_device) { - LOG(INFO) << "Sending Topology Notification on newly discovered 1905.1 device"; - auto cmdu_header = - cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_NOTIFICATION_MESSAGE); - if (!cmdu_header) { - LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; - return false; - } - send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, - tlvf::mac_to_string(db->bridge.mac)); - } - return true; -} - bool backhaul_manager::handle_1905_autoconfiguration_response(ieee1905_1::CmduMessageRx &cmdu_rx, const std::string &src_mac) { diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 69f62f9e94..7a139f991e 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -127,8 +127,6 @@ class backhaul_manager : public btl::transport_socket_thread { bool handle_1905_1_message(ieee1905_1::CmduMessageRx &cmdu_rx, const std::string &src_mac, Socket *&forward_to); // 1905 messages handlers - bool handle_1905_topology_discovery(const std::string &src_mac, - ieee1905_1::CmduMessageRx &cmdu_rx); bool handle_1905_autoconfiguration_response(ieee1905_1::CmduMessageRx &cmdu_rx, const std::string &src_mac); bool handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, const std::string &src_mac); diff --git a/agent/src/beerocks/slave/tasks/topology_task.cpp b/agent/src/beerocks/slave/tasks/topology_task.cpp index 2d1f1ed86d..cf5820011d 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.cpp +++ b/agent/src/beerocks/slave/tasks/topology_task.cpp @@ -83,6 +83,101 @@ void TopologyTask::work() } } +bool TopologyTask::handle_cmdu(ieee1905_1::CmduMessageRx &cmdu_rx, const sMacAddr &src_mac, + std::shared_ptr beerocks_header) +{ + switch (cmdu_rx.getMessageType()) { + case ieee1905_1::eMessageType::TOPOLOGY_DISCOVERY_MESSAGE: { + handle_topology_discovery(cmdu_rx, src_mac); + break; + } + default: { + // Message was not handled, therefore return false. + return false; + } + } + return true; +} + +void TopologyTask::handle_topology_discovery(ieee1905_1::CmduMessageRx &cmdu_rx, + const sMacAddr &src_mac) +{ + auto tlvAlMac = cmdu_rx.getClass(); + if (!tlvAlMac) { + LOG(ERROR) << "getClass tlvAlMacAddress failed"; + return; + } + + auto db = AgentDB::get(); + + // Filter out the messages we have sent. + if (tlvAlMac->mac() == db->bridge.mac) { + return; + } + + auto mid = cmdu_rx.getMessageId(); + LOG(INFO) << "Received TOPOLOGY_DISCOVERY_MESSAGE from AL MAC=" << tlvAlMac->mac() + << ", mid=" << std::hex << mid; + + auto tlvMac = cmdu_rx.getClass(); + if (!tlvMac) { + LOG(ERROR) << "getClass tlvMacAddress failed"; + return; + } + + uint32_t if_index = message_com::get_uds_header(cmdu_rx)->if_index; + std::string local_receiving_iface_name = network_utils::linux_get_iface_name(if_index); + if (local_receiving_iface_name.empty()) { + LOG(ERROR) << "Failed getting interface name for index: " << if_index; + return; + } + + std::string local_receiving_iface_mac_str; + if (!network_utils::linux_iface_get_mac(local_receiving_iface_name, + local_receiving_iface_mac_str)) { + LOG(ERROR) << "Failed getting MAC address for interface: " << local_receiving_iface_name; + return; + } + + LOG(DEBUG) << "sender iface_mac=" << tlvMac->mac() + << ", local_receiving_iface=" << local_receiving_iface_name + << ", local_receiving_iface_mac=" << local_receiving_iface_mac_str; + + // Check if it is a new device so if it does, we will send a Topology Notification. + bool new_device = false; + for (auto &neighbors_on_local_iface_entry : db->neighbor_devices) { + auto &neighbors_on_local_iface = neighbors_on_local_iface_entry.second; + new_device = + neighbors_on_local_iface.find(tlvAlMac->mac()) == neighbors_on_local_iface.end(); + if (new_device) { + break; + } + } + + // Add/Update the device on our list. + AgentDB::sNeighborDevice neighbor_device; + neighbor_device.transmitting_iface_mac = tlvMac->mac(); + neighbor_device.timestamp = std::chrono::steady_clock::now(); + + auto &neighbor_devices_by_al_mac = + db->neighbor_devices[tlvf::mac_from_string(local_receiving_iface_mac_str)]; + neighbor_devices_by_al_mac[tlvAlMac->mac()] = neighbor_device; + + // If it is a new device, then our 1905.1 neighbors list has changed and we are required to send + // Topology Notification Message. + if (new_device) { + LOG(INFO) << "Sending Topology Notification on newly discovered 1905.1 device"; + auto cmdu_header = + m_cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_NOTIFICATION_MESSAGE); + if (!cmdu_header) { + LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; + return; + } + m_btl_ctx.send_cmdu_to_broker(m_cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, + tlvf::mac_to_string(db->bridge.mac)); + } +} + void TopologyTask::send_topology_discovery() { // TODO: get the list of interfaces that are up_and_running using the event-driven mechanism diff --git a/agent/src/beerocks/slave/tasks/topology_task.h b/agent/src/beerocks/slave/tasks/topology_task.h index a740d2cc7c..cb09aad8c5 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.h +++ b/agent/src/beerocks/slave/tasks/topology_task.h @@ -25,7 +25,20 @@ class TopologyTask : public Task { void work() override; + bool handle_cmdu(ieee1905_1::CmduMessageRx &cmdu_rx, const sMacAddr &src_mac, + std::shared_ptr beerocks_header) override; + private: + /* 1905.1 message handlers: */ + + /** + * @brief Handles 1905 Topology Discovery message. + * + * @param[in] cmdu_rx Received CMDU. + * @param[in] src_mac MAC address of the message sender. + */ + void handle_topology_discovery(ieee1905_1::CmduMessageRx &cmdu_rx, const sMacAddr &src_mac); + /* Helper functions */ void send_topology_discovery(); void send_topology_notification(); From ced919959a182f9f122bd2ae4a2233c410486d25 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 29 Jul 2020 18:20:20 +0000 Subject: [PATCH 437/453] agent: Move the topology query handler to the Topology Task Move the topology query handler from the backhaul manager to the Topology Task. As part of this commit I changed the representation of MID print from decimal to hex since it makes more sense to print it in hex, but this change has broken the topology test on test_flows script which expected to a decimal value. Change the format on test_flows.py so the topology task will not fail. PPM-320 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 327 ------------------ .../backhaul_manager_thread.h | 1 - .../beerocks/slave/tasks/topology_task.cpp | 323 +++++++++++++++++ .../src/beerocks/slave/tasks/topology_task.h | 8 + tests/test_flows.py | 2 +- 5 files changed, 332 insertions(+), 329 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index dce9e180ac..49b01d8b95 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -2091,9 +2091,6 @@ bool backhaul_manager::handle_1905_1_message(ieee1905_1::CmduMessageRx &cmdu_rx, // returning false. return false; } - case ieee1905_1::eMessageType::TOPOLOGY_QUERY_MESSAGE: { - return handle_1905_topology_query(cmdu_rx, src_mac); - } case ieee1905_1::eMessageType::AP_CAPABILITY_QUERY_MESSAGE: { return handle_ap_capability_query(cmdu_rx, src_mac); } @@ -2645,330 +2642,6 @@ bool backhaul_manager::handle_slave_ap_metrics_response(ieee1905_1::CmduMessageR return send_cmdu_to_broker(cmdu_tx, controller_bridge_mac, tlvf::mac_to_string(db->bridge.mac)); } -/** - * @brief Handles 1905 Topology Query message - * @param cmdu_rx Received CMDU (containing Topology Query) - * @param src_mac MAC address of the message sender - * @return true on success - * @return false on failure - */ -bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, - const std::string &src_mac) -{ - const auto mid = cmdu_rx.getMessageId(); - LOG(DEBUG) << "Received TOPOLOGY_QUERY_MESSAGE , mid=" << std::dec << int(mid); - auto cmdu_tx_header = cmdu_tx.create(mid, ieee1905_1::eMessageType::TOPOLOGY_RESPONSE_MESSAGE); - if (!cmdu_tx_header) { - LOG(ERROR) << "Failed creating topology response header! mid=" << std::hex << (int)mid; - return false; - } - - auto db = AgentDB::get(); - - auto tlvDeviceInformation = cmdu_tx.addClass(); - if (!tlvDeviceInformation) { - LOG(ERROR) << "addClass ieee1905_1::tlvDeviceInformation failed, mid=" << std::hex - << (int)mid; - return false; - } - - /** - * 1905.1 AL MAC address of the device. - */ - tlvDeviceInformation->mac() = db->bridge.mac; - - /** - * Set the number of local interfaces and fill info of each of the local interfaces, according - * to IEEE_1905 section 6.4.5 - */ - - /** - * Add a LocalInterfaceInfo field for the wired interface, if any. - */ - std::string local_interface_name = db->ethernet.iface_name; - if (!local_interface_name.empty() && - network_utils::linux_iface_is_up_and_running(local_interface_name)) { - ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; - if (!MediaType::get_media_type(local_interface_name, - ieee1905_1::eMediaTypeGroup::IEEE_802_3, media_type)) { - LOG(ERROR) << "Unable to compute media type for interface " << local_interface_name; - return false; - } - - std::shared_ptr localInterfaceInfo = - tlvDeviceInformation->create_local_interface_list(); - - // default to zero mac if get_mac fails. - std::string wire_iface_mac = network_utils::ZERO_MAC_STRING; - network_utils::linux_iface_get_mac(local_interface_name, wire_iface_mac); - localInterfaceInfo->mac() = tlvf::mac_from_string(wire_iface_mac); - localInterfaceInfo->media_type() = media_type; - localInterfaceInfo->media_info_length() = 0; - - tlvDeviceInformation->add_local_interface_list(localInterfaceInfo); - } - - /** - * Add a LocalInterfaceInfo field for each wireless interface. - */ - for (const auto &soc : slaves_sockets) { - // Iterate on front radio iface and then switch to back radio iface - auto fill_radio_iface_info = [&](ieee1905_1::eMediaType media_type, bool front_iface) { - LOG(DEBUG) << "filling interface information on radio=" - << (front_iface ? soc->hostap_iface : soc->sta_iface); - - // Skip Backhaul iteration iface when STA BWL is not allocated (Eth connection or GW). - if (!front_iface && !soc->sta_wlan_hal) { - LOG(TRACE) << "Skip radio interface with no active STA BWL, front_radio=" - << soc->hostap_iface; - return true; - } - - auto localInterfaceInfo = tlvDeviceInformation->create_local_interface_list(); - - localInterfaceInfo->mac() = - front_iface ? soc->radio_mac - : tlvf::mac_from_string(soc->sta_wlan_hal->get_radio_mac()); - - LOG(DEBUG) << "Added radio interface to tlvDeviceInformation: " - << localInterfaceInfo->mac(); - - localInterfaceInfo->media_type() = media_type; - - ieee1905_1::s802_11SpecificInformation media_info = {}; - localInterfaceInfo->alloc_media_info(sizeof(media_info)); - - // BSSID field is not defined well for interface. The common definition is in simple - // words "the AP/ETH mac that we are connected to". - // For fronthaul radio interface or unused backhaul interface put zero mac. - if (db->device_conf.local_gw || - db->backhaul.connection_type == AgentDB::sBackhaul::eConnectionType::Wired || - front_iface || - (db->backhaul.connection_type == AgentDB::sBackhaul::eConnectionType::Wireless && - soc->sta_iface != db->backhaul.selected_iface_name)) { - media_info.network_membership = network_utils::ZERO_MAC; - } else { - media_info.network_membership = - tlvf::mac_from_string(soc->sta_wlan_hal->get_bssid()); - } - - media_info.role = - front_iface ? ieee1905_1::eRole::AP : ieee1905_1::eRole::NON_AP_NON_PCP_STA; - - // TODO: The Backhaul manager does not hold the information on the front radios. - // For now, put zeros and when the Agent management will be move to unified Agent thread - // this field will be filled. #435 - media_info.ap_channel_bandwidth = 0; - media_info.ap_channel_center_frequency_index1 = 0; - media_info.ap_channel_center_frequency_index2 = 0; - - auto *media_info_ptr = localInterfaceInfo->media_info(0); - if (media_info_ptr == nullptr) { - LOG(ERROR) << "media_info is nullptr"; - return false; - } - - std::copy_n(reinterpret_cast(&media_info), sizeof(media_info), - media_info_ptr); - - tlvDeviceInformation->add_local_interface_list(localInterfaceInfo); - - return true; - }; - - std::string local_interface_name = soc->hostap_iface; - - ieee1905_1::eMediaTypeGroup media_type_group = ieee1905_1::eMediaTypeGroup::IEEE_802_11; - ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; - if (!MediaType::get_media_type(local_interface_name, media_type_group, media_type)) { - LOG(ERROR) << "Unable to compute media type for interface " << local_interface_name; - return false; - } - - if (!fill_radio_iface_info(media_type, true)) { - LOG(DEBUG) << "filling interface information on radio=" << soc->hostap_iface - << " has failed!"; - return true; - } - - if (!fill_radio_iface_info(media_type, false)) { - LOG(DEBUG) << "filling interface information on radio=" << soc->hostap_iface - << " backhaul has failed!"; - return true; - } - } - - /** - * Add a 1905.1 neighbor device TLV for each local interface for which this management entity - * has inferred the presence of a 1905.1 neighbor device. Include each discovered neighbor - * device in its corresponding 1905.1 neighbor device TLV. - * - * First, group known 1905 neighbor devices by the local interface that links to them. Create - * a map which key is the name of the local interface and the value is the list of neighbor - * devices inferred from that interface. - */ - for (auto &neighbors_on_local_iface_entry : db->neighbor_devices) { - auto tlv1905NeighborDevice = cmdu_tx.addClass(); - if (!tlv1905NeighborDevice) { - LOG(ERROR) << "addClass ieee1905_1::tlv1905NeighborDevice failed, mid=" << std::hex - << mid; - return false; - } - - tlv1905NeighborDevice->mac_local_iface() = neighbors_on_local_iface_entry.first; - auto &neighbors_on_local_iface = neighbors_on_local_iface_entry.second; - - if (!tlv1905NeighborDevice->alloc_mac_al_1905_device(neighbors_on_local_iface.size())) { - LOG(ERROR) << "alloc_mac_al_1905_device() has failed"; - return false; - } - - size_t index = 0; - for (const auto &neighbor_on_local_iface_entry : neighbors_on_local_iface) { - auto &neighbor_al_mac = neighbor_on_local_iface_entry.first; - - auto mac_al_1905_device_tuple = tlv1905NeighborDevice->mac_al_1905_device(index); - if (!std::get<0>(mac_al_1905_device_tuple)) { - LOG(ERROR) << "getting mac_al_1905_device element has failed"; - return true; - } - - auto &mac_al_1905_device = std::get<1>(mac_al_1905_device_tuple); - mac_al_1905_device.mac = neighbor_al_mac; - mac_al_1905_device.bridges_exist = - ieee1905_1::tlv1905NeighborDevice::eBridgesExist::AT_LEAST_ONE_BRIDGES_EXIST; - index++; - } - } - - auto tlvSupportedService = cmdu_tx.addClass(); - if (!tlvSupportedService) { - LOG(ERROR) << "addClass wfa_map::tlvSupportedService failed, mid=" << std::hex << (int)mid; - return false; - } - - size_t number_of_supported_services = 1; - if (db->device_conf.local_controller) { - number_of_supported_services++; - } - - if (!tlvSupportedService->alloc_supported_service_list(number_of_supported_services)) { - LOG(ERROR) << "alloc_supported_service_list failed"; - return false; - } - - auto supportedServiceTuple = tlvSupportedService->supported_service_list(0); - if (!std::get<0>(supportedServiceTuple)) { - LOG(ERROR) << "Failed accessing supported_service_list(0)"; - return false; - } - - std::get<1>(supportedServiceTuple) = - wfa_map::tlvSupportedService::eSupportedService::MULTI_AP_AGENT; - - if (db->device_conf.local_controller) { - auto supportedServiceTuple = tlvSupportedService->supported_service_list(1); - if (!std::get<0>(supportedServiceTuple)) { - LOG(ERROR) << "Failed accessing supported_service_list(1)"; - return false; - } - - std::get<1>(supportedServiceTuple) = - wfa_map::tlvSupportedService::eSupportedService::MULTI_AP_CONTROLLER; - } - - auto tlvApOperationalBSS = cmdu_tx.addClass(); - if (!tlvApOperationalBSS) { - LOG(ERROR) << "addClass wfa_map::tlvApOperationalBSS failed, mid=" << std::hex << (int)mid; - return false; - } - - for (const auto &radio : db->get_radios_list()) { - if (!radio) { - continue; - } - - auto radio_list = tlvApOperationalBSS->create_radio_list(); - radio_list->radio_uid() = radio->front.iface_mac; - for (const auto &bssid : radio->front.bssids) { - if (bssid.mac == network_utils::ZERO_MAC) { - continue; - } - if (bssid.ssid.empty()) { - continue; - } - auto radio_bss_list = radio_list->create_radio_bss_list(); - radio_bss_list->radio_bssid() = bssid.mac; - radio_bss_list->set_ssid(bssid.ssid); - - radio_list->add_radio_bss_list(radio_bss_list); - } - tlvApOperationalBSS->add_radio_list(radio_list); - } - - // The Multi-AP Agent shall include an Associated Clients TLV in the message if there is at - // least one 802.11 client directly associated with any of the BSS(s) that is operated by the - // Multi-AP Agent - bool include_associated_clients_tlv = false; - for (const auto &radio : db->get_radios_list()) { - if (!radio) { - continue; - } - if (radio->associated_clients.size() > 0) { - include_associated_clients_tlv = true; - break; - } - } - - if (include_associated_clients_tlv) { - auto tlvAssociatedClients = cmdu_tx.addClass(); - if (!tlvAssociatedClients) { - LOG(ERROR) << "addClass wfa_map::tlvAssociatedClients failed, mid=" << std::hex << mid; - return false; - } - - // Get current time to compute elapsed time since last client association - auto now = std::chrono::steady_clock::now(); - - // Fill in Associated Clients TLV - for (const auto &radio : db->get_radios_list()) { - if (!radio) { - continue; - } - - for (const auto &bssid : radio->front.bssids) { - auto bss_list = tlvAssociatedClients->create_bss_list(); - bss_list->bssid() = bssid.mac; - - for (const auto &associated_client_entry : radio->associated_clients) { - if (associated_client_entry.second.bssid != bssid.mac) { - continue; - } - - auto client_info = bss_list->create_clients_associated_list(); - - auto &association_time = associated_client_entry.second.association_time; - auto elapsed = - std::chrono::duration_cast(now - association_time) - .count(); - if ((elapsed < 0) || (elapsed > UINT16_MAX)) { - elapsed = UINT16_MAX; - } - - client_info->mac() = associated_client_entry.first; - client_info->time_since_last_association_sec() = elapsed; - - bss_list->add_clients_associated_list(client_info); - } - tlvAssociatedClients->add_bss_list(bss_list); - } - } - } - - LOG(DEBUG) << "Sending topology response message, mid: " << std::hex << (int)mid; - return send_cmdu_to_broker(cmdu_tx, src_mac, tlvf::mac_to_string(db->bridge.mac)); -} - bool backhaul_manager::handle_1905_higher_layer_data_message(ieee1905_1::CmduMessageRx &cmdu_rx, const std::string &src_mac) { diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 7a139f991e..c9439e2c03 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -129,7 +129,6 @@ class backhaul_manager : public btl::transport_socket_thread { // 1905 messages handlers bool handle_1905_autoconfiguration_response(ieee1905_1::CmduMessageRx &cmdu_rx, const std::string &src_mac); - bool handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, const std::string &src_mac); bool handle_1905_higher_layer_data_message(ieee1905_1::CmduMessageRx &cmdu_rx, const std::string &src_mac); bool handle_1905_link_metric_query(ieee1905_1::CmduMessageRx &cmdu_rx, diff --git a/agent/src/beerocks/slave/tasks/topology_task.cpp b/agent/src/beerocks/slave/tasks/topology_task.cpp index cf5820011d..dd3e358eaa 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.cpp +++ b/agent/src/beerocks/slave/tasks/topology_task.cpp @@ -91,6 +91,10 @@ bool TopologyTask::handle_cmdu(ieee1905_1::CmduMessageRx &cmdu_rx, const sMacAdd handle_topology_discovery(cmdu_rx, src_mac); break; } + case ieee1905_1::eMessageType::TOPOLOGY_QUERY_MESSAGE: { + handle_topology_query(cmdu_rx, src_mac); + break; + } default: { // Message was not handled, therefore return false. return false; @@ -178,6 +182,325 @@ void TopologyTask::handle_topology_discovery(ieee1905_1::CmduMessageRx &cmdu_rx, } } +void TopologyTask::handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, + const sMacAddr &src_mac) +{ + const auto mid = cmdu_rx.getMessageId(); + LOG(DEBUG) << "Received TOPOLOGY_QUERY_MESSAGE, mid=" << std::hex << mid; + auto cmdu_tx_header = + m_cmdu_tx.create(mid, ieee1905_1::eMessageType::TOPOLOGY_RESPONSE_MESSAGE); + if (!cmdu_tx_header) { + LOG(ERROR) << "Failed creating topology response header"; + return; + } + + auto db = AgentDB::get(); + + auto tlvDeviceInformation = m_cmdu_tx.addClass(); + if (!tlvDeviceInformation) { + LOG(ERROR) << "addClass ieee1905_1::tlvDeviceInformation failed"; + return; + } + + /** + * 1905.1 AL MAC address of the device. + */ + tlvDeviceInformation->mac() = db->bridge.mac; + + /** + * Set the number of local interfaces and fill info of each of the local interfaces, according + * to IEEE_1905 section 6.4.5 + */ + + /** + * Add a LocalInterfaceInfo field for the wired interface, if any. + */ + std::string &local_interface_name = db->ethernet.iface_name; + if (!local_interface_name.empty() && + network_utils::linux_iface_is_up_and_running(local_interface_name)) { + ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; + if (!MediaType::get_media_type(local_interface_name, + ieee1905_1::eMediaTypeGroup::IEEE_802_3, media_type)) { + LOG(ERROR) << "Unable to compute media type for interface " << local_interface_name; + return; + } + + std::shared_ptr localInterfaceInfo = + tlvDeviceInformation->create_local_interface_list(); + + // default to zero mac if get_mac fails. + std::string wire_iface_mac = network_utils::ZERO_MAC_STRING; + network_utils::linux_iface_get_mac(local_interface_name, wire_iface_mac); + localInterfaceInfo->mac() = tlvf::mac_from_string(wire_iface_mac); + localInterfaceInfo->media_type() = media_type; + localInterfaceInfo->media_info_length() = 0; + + tlvDeviceInformation->add_local_interface_list(localInterfaceInfo); + } + + /** + * Add a LocalInterfaceInfo field for each wireless interface. + */ + for (const auto radio : db->get_radios_list()) { + if (radio == nullptr) { + continue; + } + + // Iterate on front radio iface and then switch to back radio iface + auto fill_radio_iface_info = [&](ieee1905_1::eMediaType media_type, bool front_iface) { + LOG(DEBUG) << "filling interface information on radio=" + << (front_iface ? radio->front.iface_name : radio->back.iface_name); + + // Skip Backhaul iteration iface when STA BWL is not allocated (Eth connection or GW). + if (!front_iface && radio->back.iface_name != db->backhaul.selected_iface_name) { + LOG(TRACE) << "Skip radio interface with no active STA BWL, front_radio=" + << radio->front.iface_name << ", back_radio=" << radio->back.iface_name; + return true; + } + + auto localInterfaceInfo = tlvDeviceInformation->create_local_interface_list(); + + localInterfaceInfo->mac() = + front_iface ? radio->front.iface_mac : radio->back.iface_mac; + + LOG(DEBUG) << "Added radio interface to tlvDeviceInformation: " + << localInterfaceInfo->mac(); + + localInterfaceInfo->media_type() = media_type; + + ieee1905_1::s802_11SpecificInformation media_info = {}; + localInterfaceInfo->alloc_media_info(sizeof(media_info)); + + // BSSID field is not defined well for interface. The common definition is in simple + // words "the AP/ETH mac that we are connected to". + // For fronthaul radio interface or unused backhaul interface put zero mac. + if (db->device_conf.local_gw || + db->backhaul.connection_type == AgentDB::sBackhaul::eConnectionType::Wired || + front_iface || + (db->backhaul.connection_type == AgentDB::sBackhaul::eConnectionType::Wireless && + radio->back.iface_name != db->backhaul.selected_iface_name)) { + media_info.network_membership = network_utils::ZERO_MAC; + } else { + media_info.network_membership = radio->back.iface_mac; + } + + media_info.role = + front_iface ? ieee1905_1::eRole::AP : ieee1905_1::eRole::NON_AP_NON_PCP_STA; + + // TODO: The Backhaul manager does not hold the information on the front radios. + // For now, put zeros and when the Agent management will be move to unified Agent thread + // this field will be filled. #435 + media_info.ap_channel_bandwidth = 0; + media_info.ap_channel_center_frequency_index1 = 0; + media_info.ap_channel_center_frequency_index2 = 0; + + auto *media_info_ptr = localInterfaceInfo->media_info(0); + if (media_info_ptr == nullptr) { + LOG(ERROR) << "media_info is nullptr"; + return false; + } + + std::copy_n(reinterpret_cast(&media_info), sizeof(media_info), + media_info_ptr); + + tlvDeviceInformation->add_local_interface_list(localInterfaceInfo); + + return true; + }; + + std::string &local_interface_name = radio->front.iface_name; + + ieee1905_1::eMediaTypeGroup media_type_group = ieee1905_1::eMediaTypeGroup::IEEE_802_11; + ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; + if (!MediaType::get_media_type(local_interface_name, media_type_group, media_type)) { + LOG(ERROR) << "Unable to compute media type for interface " << local_interface_name; + return; + } + + if (!fill_radio_iface_info(media_type, true)) { + LOG(DEBUG) << "filling interface information on radio=" << radio->front.iface_name + << " has failed!"; + return; + } + + if (!fill_radio_iface_info(media_type, false)) { + LOG(DEBUG) << "filling interface information on radio=" << radio->back.iface_name + << " backhaul has failed!"; + return; + } + } + + /** + * Add a 1905.1 neighbor device TLV for each local interface for which this management entity + * has inferred the presence of a 1905.1 neighbor device. Include each discovered neighbor + * device in its corresponding 1905.1 neighbor device TLV. + * + * First, group known 1905 neighbor devices by the local interface that links to them. Create + * a map which key is the name of the local interface and the value is the list of neighbor + * devices inferred from that interface. + */ + for (auto &neighbors_on_local_iface_entry : db->neighbor_devices) { + auto tlv1905NeighborDevice = m_cmdu_tx.addClass(); + if (!tlv1905NeighborDevice) { + LOG(ERROR) << "addClass ieee1905_1::tlv1905NeighborDevice failed"; + return; + } + + tlv1905NeighborDevice->mac_local_iface() = neighbors_on_local_iface_entry.first; + auto &neighbors_on_local_iface = neighbors_on_local_iface_entry.second; + + if (!tlv1905NeighborDevice->alloc_mac_al_1905_device(neighbors_on_local_iface.size())) { + LOG(ERROR) << "alloc_mac_al_1905_device() has failed"; + return; + } + + size_t index = 0; + for (const auto &neighbor_on_local_iface_entry : neighbors_on_local_iface) { + auto &neighbor_al_mac = neighbor_on_local_iface_entry.first; + + auto mac_al_1905_device_tuple = tlv1905NeighborDevice->mac_al_1905_device(index); + if (!std::get<0>(mac_al_1905_device_tuple)) { + LOG(ERROR) << "getting mac_al_1905_device element has failed"; + return; + } + + auto &mac_al_1905_device = std::get<1>(mac_al_1905_device_tuple); + mac_al_1905_device.mac = neighbor_al_mac; + mac_al_1905_device.bridges_exist = + ieee1905_1::tlv1905NeighborDevice::eBridgesExist::AT_LEAST_ONE_BRIDGES_EXIST; + index++; + } + } + + auto tlvSupportedService = m_cmdu_tx.addClass(); + if (!tlvSupportedService) { + LOG(ERROR) << "addClass wfa_map::tlvSupportedService failed"; + return; + } + + size_t number_of_supported_services = 1; + if (db->device_conf.local_controller) { + number_of_supported_services++; + } + + if (!tlvSupportedService->alloc_supported_service_list(number_of_supported_services)) { + LOG(ERROR) << "alloc_supported_service_list failed"; + return; + } + + auto supportedServiceTuple = tlvSupportedService->supported_service_list(0); + if (!std::get<0>(supportedServiceTuple)) { + LOG(ERROR) << "Failed accessing supported_service_list(0)"; + return; + } + + std::get<1>(supportedServiceTuple) = + wfa_map::tlvSupportedService::eSupportedService::MULTI_AP_AGENT; + + if (db->device_conf.local_controller) { + auto supportedServiceTuple = tlvSupportedService->supported_service_list(1); + if (!std::get<0>(supportedServiceTuple)) { + LOG(ERROR) << "Failed accessing supported_service_list(1)"; + return; + } + + std::get<1>(supportedServiceTuple) = + wfa_map::tlvSupportedService::eSupportedService::MULTI_AP_CONTROLLER; + } + + auto tlvApOperationalBSS = m_cmdu_tx.addClass(); + if (!tlvApOperationalBSS) { + LOG(ERROR) << "addClass wfa_map::tlvApOperationalBSS failed"; + return; + } + + for (const auto &radio : db->get_radios_list()) { + if (!radio) { + continue; + } + + auto radio_list = tlvApOperationalBSS->create_radio_list(); + radio_list->radio_uid() = radio->front.iface_mac; + for (const auto &bssid : radio->front.bssids) { + if (bssid.mac == network_utils::ZERO_MAC) { + continue; + } + if (bssid.ssid.empty()) { + continue; + } + auto radio_bss_list = radio_list->create_radio_bss_list(); + radio_bss_list->radio_bssid() = bssid.mac; + radio_bss_list->set_ssid(bssid.ssid); + + radio_list->add_radio_bss_list(radio_bss_list); + } + tlvApOperationalBSS->add_radio_list(radio_list); + } + + // The Multi-AP Agent shall include an Associated Clients TLV in the message if there is at + // least one 802.11 client directly associated with any of the BSS(s) that is operated by the + // Multi-AP Agent + bool include_associated_clients_tlv = false; + for (const auto &radio : db->get_radios_list()) { + if (!radio) { + continue; + } + if (radio->associated_clients.size() > 0) { + include_associated_clients_tlv = true; + break; + } + } + + if (include_associated_clients_tlv) { + auto tlvAssociatedClients = m_cmdu_tx.addClass(); + if (!tlvAssociatedClients) { + LOG(ERROR) << "addClass wfa_map::tlvAssociatedClients failed, mid=" << std::hex << mid; + return; + } + + // Get current time to compute elapsed time since last client association + auto now = std::chrono::steady_clock::now(); + + // Fill in Associated Clients TLV + for (const auto &radio : db->get_radios_list()) { + if (!radio) { + continue; + } + + for (const auto &bssid : radio->front.bssids) { + auto bss_list = tlvAssociatedClients->create_bss_list(); + bss_list->bssid() = bssid.mac; + + for (const auto &associated_client_entry : radio->associated_clients) { + if (associated_client_entry.second.bssid != bssid.mac) { + continue; + } + + auto client_info = bss_list->create_clients_associated_list(); + + auto &association_time = associated_client_entry.second.association_time; + auto elapsed = + std::chrono::duration_cast(now - association_time) + .count(); + if ((elapsed < 0) || (elapsed > UINT16_MAX)) { + elapsed = UINT16_MAX; + } + + client_info->mac() = associated_client_entry.first; + client_info->time_since_last_association_sec() = elapsed; + + bss_list->add_clients_associated_list(client_info); + } + tlvAssociatedClients->add_bss_list(bss_list); + } + } + } + + LOG(DEBUG) << "Sending topology response message, mid=" << std::hex << mid; + m_btl_ctx.send_cmdu_to_broker(m_cmdu_tx, tlvf::mac_to_string(src_mac), + tlvf::mac_to_string(db->bridge.mac)); +} + void TopologyTask::send_topology_discovery() { // TODO: get the list of interfaces that are up_and_running using the event-driven mechanism diff --git a/agent/src/beerocks/slave/tasks/topology_task.h b/agent/src/beerocks/slave/tasks/topology_task.h index cb09aad8c5..3de88185d4 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.h +++ b/agent/src/beerocks/slave/tasks/topology_task.h @@ -39,6 +39,14 @@ class TopologyTask : public Task { */ void handle_topology_discovery(ieee1905_1::CmduMessageRx &cmdu_rx, const sMacAddr &src_mac); + /** + * @brief Handles 1905 Topology Query message. + * + * @param[in] cmdu_rx Received CMDU. + * @param[in] src_mac MAC address of the message sender. + */ + void handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, const sMacAddr &src_mac); + /* Helper functions */ void send_topology_discovery(); void send_topology_notification(); diff --git a/tests/test_flows.py b/tests/test_flows.py index 04ad153a05..4d888bc8d6 100755 --- a/tests/test_flows.py +++ b/tests/test_flows.py @@ -1261,7 +1261,7 @@ def test_higher_layer_data_payload_trigger(self): def test_topology(self): mid = env.controller.dev_send_1905(env.agents[0].mac, 0x0002) debug("Confirming topology query was received") - self.check_log(env.agents[0], r"TOPOLOGY_QUERY_MESSAGE.*mid={:d}".format(mid)) + self.check_log(env.agents[0], r"TOPOLOGY_QUERY_MESSAGE.*mid=0x{:x}".format(mid)) def test_beacon_report_query(self): # associated STA From d831fb095ca44a0b8f90598ba8647f2984469ea2 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 29 Jul 2020 18:27:27 +0000 Subject: [PATCH 438/453] agent: Add an event handler to the Topology Task Add event handler function to the Topology Task with a handler to event type "AGENT_RADIO_STATE_CHANGED". Send the above event to the task from all the relevant places on the backhaul manager. PPM-320 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 29 +++++++++---------- .../beerocks/slave/tasks/topology_task.cpp | 18 ++++++++++++ .../src/beerocks/slave/tasks/topology_task.h | 7 +++++ 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 49b01d8b95..19c1ebe986 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -366,14 +366,8 @@ bool backhaul_manager::socket_disconnected(Socket *sd) if (m_eFSMState >= EState::CONNECT_TO_MASTER) { LOG(INFO) << "Sending topology notification on son_slave disconnect"; - auto cmdu_header = - cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_NOTIFICATION_MESSAGE); - if (!cmdu_header) { - LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; - return false; - } - send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, - tlvf::mac_to_string(db->bridge.mac)); + m_task_pool.send_event(eTaskType::TOPOLOGY, + TopologyTask::eEvent::AGENT_RADIO_STATE_CHANGED); } return false; } else { @@ -880,6 +874,15 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) // Successfully connected to the master case EState::CONNECTED: { + /** + * According to the 1905.1 specification section 8.2.1.1 - A 1905.1 management entity shall + * transmit a topology discovery message every 60 seconds or if an "implementation-specific" + * event occurs (e.g., device initialized or an interface is connected). + * Sending "AGENT_DEVICE_INITIALIZED" event will trigger sending of topology discovery + * message. + */ + m_task_pool.send_event(eTaskType::TOPOLOGY, TopologyTask::eEvent::AGENT_DEVICE_INITIALIZED); + stop_on_failure_attempts = configuration_stop_on_failure_attempts; LOG(DEBUG) << "clearing blacklist"; @@ -1816,14 +1819,8 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr if (m_eFSMState >= EState::CONNECT_TO_MASTER) { LOG(INFO) << "Sending topology notification on reconnected son_slave"; - auto cmdu_header = - cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_NOTIFICATION_MESSAGE); - if (!cmdu_header) { - LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; - return false; - } - send_cmdu_to_broker(cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, - tlvf::mac_to_string(db->bridge.mac)); + m_task_pool.send_event(eTaskType::TOPOLOGY, + TopologyTask::eEvent::AGENT_RADIO_STATE_CHANGED); } // If we're already connected, send a notification to the slave diff --git a/agent/src/beerocks/slave/tasks/topology_task.cpp b/agent/src/beerocks/slave/tasks/topology_task.cpp index dd3e358eaa..17bd2f12ff 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.cpp +++ b/agent/src/beerocks/slave/tasks/topology_task.cpp @@ -83,6 +83,24 @@ void TopologyTask::work() } } +void TopologyTask::handle_event(uint8_t event_enum_value) +{ + switch (eEvent(event_enum_value)) { + case AGENT_RADIO_STATE_CHANGED: { + send_topology_notification(); + break; + } + case AGENT_DEVICE_INITIALIZED: { + send_topology_discovery(); + break; + } + default: { + LOG(DEBUG) << "Message handler doesn't exists for event type " << event_enum_value; + break; + } + } +} + bool TopologyTask::handle_cmdu(ieee1905_1::CmduMessageRx &cmdu_rx, const sMacAddr &src_mac, std::shared_ptr beerocks_header) { diff --git a/agent/src/beerocks/slave/tasks/topology_task.h b/agent/src/beerocks/slave/tasks/topology_task.h index 3de88185d4..6159a7040a 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.h +++ b/agent/src/beerocks/slave/tasks/topology_task.h @@ -25,6 +25,13 @@ class TopologyTask : public Task { void work() override; + enum eEvent : uint8_t { + AGENT_RADIO_STATE_CHANGED, + AGENT_DEVICE_INITIALIZED, + }; + + void handle_event(uint8_t event_enum_value) override; + bool handle_cmdu(ieee1905_1::CmduMessageRx &cmdu_rx, const sMacAddr &src_mac, std::shared_ptr beerocks_header) override; From e0b4ddf3a34fb427d6f6296a8e0afc5c73a74ddd Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 29 Jul 2020 18:30:10 +0000 Subject: [PATCH 439/453] agent: Add VS message handler to the Topology Task This is a preparative commit for a future PR, preparing the handlers of client connect/disconnect event which will have to move from the unified Agent to this task. PPM-320 Signed-off-by: Moran Shoeg --- .../backhaul_manager_thread.cpp | 7 ++- .../beerocks/slave/tasks/topology_task.cpp | 45 +++++++++++++++++++ .../src/beerocks/slave/tasks/topology_task.h | 31 +++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 19c1ebe986..6fb665e990 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -794,7 +794,7 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select) } case EState::MASTER_DISCOVERY: { - auto db = AgentDB ::get(); + auto db = AgentDB::get(); if (network_utils::get_iface_info(bridge_info, db->bridge.iface_name) != 0) { LOG(ERROR) << "Failed reading addresses from the bridge!"; platform_notify_error(bpl::eErrorCode::BH_READING_DATA_FROM_THE_BRIDGE, ""); @@ -2121,6 +2121,11 @@ bool backhaul_manager::handle_1905_1_message(ieee1905_1::CmduMessageRx &cmdu_rx, case ieee1905_1::eMessageType::BACKHAUL_STEERING_REQUEST_MESSAGE: { return handle_backhaul_steering_request(cmdu_rx, src_mac); } + case ieee1905_1::eMessageType::VENDOR_SPECIFIC_MESSAGE: { + // We should not handle vendor specific messages here, return false so the message will + // be forwarded and will not be passed to the task_pool. + return false; + } default: { // TODO add a warning once all vendor specific flows are replaced with EasyMesh // flows, since we won't expect a 1905 message not handled in this function diff --git a/agent/src/beerocks/slave/tasks/topology_task.cpp b/agent/src/beerocks/slave/tasks/topology_task.cpp index 17bd2f12ff..ce24286ed7 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.cpp +++ b/agent/src/beerocks/slave/tasks/topology_task.cpp @@ -113,6 +113,9 @@ bool TopologyTask::handle_cmdu(ieee1905_1::CmduMessageRx &cmdu_rx, const sMacAdd handle_topology_query(cmdu_rx, src_mac); break; } + case ieee1905_1::eMessageType::VENDOR_SPECIFIC_MESSAGE: { + return handle_vendor_specific(cmdu_rx, src_mac, beerocks_header); + } default: { // Message was not handled, therefore return false. return false; @@ -519,6 +522,48 @@ void TopologyTask::handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, tlvf::mac_to_string(db->bridge.mac)); } +bool TopologyTask::handle_vendor_specific(ieee1905_1::CmduMessageRx &cmdu_rx, + const sMacAddr &src_mac, + std::shared_ptr beerocks_header) +{ + if (!beerocks_header) { + LOG(ERROR) << "beerocks_header is nullptr"; + return false; + } + + // Since currently we handle only action_ops of action type "ACTION_BACKHAUL", use a single + // switch-case on "ACTION_BACKHAUL" only. + switch (beerocks_header->action_op()) { + case beerocks_message::ACTION_APMANAGER_CLIENT_ASSOCIATED_NOTIFICATION: { + handle_vs_client_associated(cmdu_rx, beerocks_header); + break; + } + case beerocks_message::ACTION_APMANAGER_CLIENT_DISCONNECTED_NOTIFICATION: { + handle_vs_client_disassociated(cmdu_rx, beerocks_header); + break; + } + default: { + // Message was not handled, therefore return false. + return false; + } + } + return true; +} + +void TopologyTask::handle_vs_client_associated(ieee1905_1::CmduMessageRx &cmdu_rx, + std::shared_ptr beerocks_header) +{ + // TODO: Move handling of "ACTION_APMANAGER_CLIENT_ASSOCIATED_NOTIFICATION" to here when + // moving this task to unified agent context. +} + +void TopologyTask::handle_vs_client_disassociated(ieee1905_1::CmduMessageRx &cmdu_rx, + std::shared_ptr beerocks_header) +{ + // TODO: Move handling of "ACTION_APMANAGER_CLIENT_DISCONNECTED_NOTIFICATION" to here when + // moving this task to unified agent context. +} + void TopologyTask::send_topology_discovery() { // TODO: get the list of interfaces that are up_and_running using the event-driven mechanism diff --git a/agent/src/beerocks/slave/tasks/topology_task.h b/agent/src/beerocks/slave/tasks/topology_task.h index 6159a7040a..b8bca24e35 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.h +++ b/agent/src/beerocks/slave/tasks/topology_task.h @@ -54,6 +54,37 @@ class TopologyTask : public Task { */ void handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, const sMacAddr &src_mac); + /** + * @brief Handles Vendor Specific messages. + * + * @param[in] cmdu_rx Received CMDU. + * @param[in] src_mac MAC address of the message sender. + * @param[in] beerocks_header Shared pointer to beerocks header. + * @return true, if the message has been handled, otherwise false. + */ + bool handle_vendor_specific(ieee1905_1::CmduMessageRx &cmdu_rx, const sMacAddr &src_mac, + std::shared_ptr beerocks_header); + + /* Vendor specific message handlers: */ + + /** + * @brief Handles Vendor Specific Client Associated message. + * + * @param[in] cmdu_rx Received CMDU. + * @param[in] beerocks_header Shared pointer to beerocks header. + */ + void handle_vs_client_associated(ieee1905_1::CmduMessageRx &cmdu_rx, + std::shared_ptr beerocks_header); + + /** + * @brief Handles Vendor Specific Client Disassociated message. + * + * @param[in] cmdu_rx Received CMDU. + * @param[in] beerocks_header Shared pointer to beerocks header. + */ + void handle_vs_client_disassociated(ieee1905_1::CmduMessageRx &cmdu_rx, + std::shared_ptr beerocks_header); + /* Helper functions */ void send_topology_discovery(); void send_topology_notification(); From 7507f84642432248b7c1753cc417f36bd86cc693 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 29 Jul 2020 19:37:09 +0000 Subject: [PATCH 440/453] agent: Split topology query handler to functions This commit is only cosmetic and does not change any logic. The topology query handler currently adds five tlvs to the response message. Some of them are pretty huge and it makes the function very long and unreadable. Create a function that adds and fill each tlv to the response message, and call them from the handler. PPM-320 Signed-off-by: Moran Shoeg --- .../beerocks/slave/tasks/topology_task.cpp | 338 ++++++++++-------- .../src/beerocks/slave/tasks/topology_task.h | 35 ++ 2 files changed, 230 insertions(+), 143 deletions(-) diff --git a/agent/src/beerocks/slave/tasks/topology_task.cpp b/agent/src/beerocks/slave/tasks/topology_task.cpp index ce24286ed7..dbdbcf9de9 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.cpp +++ b/agent/src/beerocks/slave/tasks/topology_task.cpp @@ -215,14 +215,153 @@ void TopologyTask::handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, return; } + if (!add_device_information_tlv()) { + return; + } + + if (!add_1905_neighbor_device_tlv()) { + return; + } + + if (!add_supported_service_tlv()) { + return; + } + + if (!add_ap_operational_bss_tlv()) { + return; + } + + if (!add_associated_clients_tlv()) { + return; + } + auto db = AgentDB::get(); + LOG(DEBUG) << "Sending topology response message, mid=" << std::hex << mid; + m_btl_ctx.send_cmdu_to_broker(m_cmdu_tx, tlvf::mac_to_string(src_mac), + tlvf::mac_to_string(db->bridge.mac)); +} + +bool TopologyTask::handle_vendor_specific(ieee1905_1::CmduMessageRx &cmdu_rx, + const sMacAddr &src_mac, + std::shared_ptr beerocks_header) +{ + if (!beerocks_header) { + LOG(ERROR) << "beerocks_header is nullptr"; + return false; + } + + // Since currently we handle only action_ops of action type "ACTION_BACKHAUL", use a single + // switch-case on "ACTION_BACKHAUL" only. + switch (beerocks_header->action_op()) { + case beerocks_message::ACTION_APMANAGER_CLIENT_ASSOCIATED_NOTIFICATION: { + handle_vs_client_associated(cmdu_rx, beerocks_header); + break; + } + case beerocks_message::ACTION_APMANAGER_CLIENT_DISCONNECTED_NOTIFICATION: { + handle_vs_client_disassociated(cmdu_rx, beerocks_header); + break; + } + default: { + // Message was not handled, therfore return false. + return false; + } + } + return true; +} + +void TopologyTask::handle_vs_client_associated(ieee1905_1::CmduMessageRx &cmdu_rx, + std::shared_ptr beerocks_header) +{ + // TODO: Move handling of "ACTION_APMANAGER_CLIENT_ASSOCIATED_NOTIFICATION" to here when + // moving this task to unified agent context. +} + +void TopologyTask::handle_vs_client_disassociated(ieee1905_1::CmduMessageRx &cmdu_rx, + std::shared_ptr beerocks_header) +{ + // TODO: Move handling of "ACTION_APMANAGER_CLIENT_DISCONNECTED_NOTIFICATION" to here when + // moving this task to unified agent context. +} + +void TopologyTask::send_topology_discovery() +{ + // TODO: get the list of interfaces that are up_and_running using the event-driven mechanism + // to be implemented in #866 + + /** + * Transmission type of Topology Discovery message is 'neighbor multicast'. + * That is, the CMDU must be transmitted once on each and every of its 1905.1 interfaces. + * Also, according to IEEE1905.1, the message should include a MAC Address TLV which contains + * the address of the interface on which the message is sent. Thus, a different message should + * be sent on each interface. + */ + auto db = AgentDB::get(); + + // Make list of ifaces Macs to send on the message. + auto ifaces = network_utils::linux_get_iface_list_from_bridge(db->bridge.iface_name); + for (const auto &iface_name : ifaces) { + if (!network_utils::linux_iface_is_up_and_running(iface_name)) { + continue; + } + + std::string iface_mac_str; + if (!network_utils::linux_iface_get_mac(iface_name, iface_mac_str)) { + LOG(ERROR) << "Failed getting MAC address for interface: " << iface_name; + return; + } + + auto iface_mac = tlvf::mac_from_string(iface_mac_str); + + auto cmdu_header = + m_cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_DISCOVERY_MESSAGE); + if (!cmdu_header) { + LOG(ERROR) << "Failed to create TOPOLOGY_DISCOVERY_MESSAGE cmdu"; + return; + } + auto tlvAlMacAddress = m_cmdu_tx.addClass(); + if (!tlvAlMacAddress) { + LOG(ERROR) << "Failed to create tlvAlMacAddress tlv"; + return; + } + tlvAlMacAddress->mac() = db->bridge.mac; + + auto tlvMacAddress = m_cmdu_tx.addClass(); + if (!tlvMacAddress) { + LOG(ERROR) << "Failed to create tlvMacAddress tlv"; + return; + } + tlvMacAddress->mac() = iface_mac; + + LOG(DEBUG) << "send_1905_topology_discovery_message, bridge_mac=" << db->bridge.mac + << ", iface=" << iface_name; + m_btl_ctx.send_cmdu_to_broker(m_cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, + tlvf::mac_to_string(db->bridge.mac), iface_name); + } +} + +void TopologyTask::send_topology_notification() +{ + auto cmdu_header = m_cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_NOTIFICATION_MESSAGE); + if (!cmdu_header) { + LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; + return; + } + auto db = AgentDB::get(); + m_btl_ctx.send_cmdu_to_broker(m_cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, + tlvf::mac_to_string(db->bridge.mac)); +} + +bool TopologyTask::add_device_information_tlv() +{ auto tlvDeviceInformation = m_cmdu_tx.addClass(); if (!tlvDeviceInformation) { LOG(ERROR) << "addClass ieee1905_1::tlvDeviceInformation failed"; - return; + return false; } + auto db = AgentDB::get(); + /** * 1905.1 AL MAC address of the device. */ @@ -236,23 +375,23 @@ void TopologyTask::handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, /** * Add a LocalInterfaceInfo field for the wired interface, if any. */ - std::string &local_interface_name = db->ethernet.iface_name; - if (!local_interface_name.empty() && - network_utils::linux_iface_is_up_and_running(local_interface_name)) { + std::string &local_eth_iface_name = db->ethernet.iface_name; + if (!local_eth_iface_name.empty() && + network_utils::linux_iface_is_up_and_running(local_eth_iface_name)) { ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; - if (!MediaType::get_media_type(local_interface_name, + if (!MediaType::get_media_type(local_eth_iface_name, ieee1905_1::eMediaTypeGroup::IEEE_802_3, media_type)) { - LOG(ERROR) << "Unable to compute media type for interface " << local_interface_name; - return; + LOG(ERROR) << "Unable to compute media type for interface " << local_eth_iface_name; + return false; } std::shared_ptr localInterfaceInfo = tlvDeviceInformation->create_local_interface_list(); // default to zero mac if get_mac fails. - std::string wire_iface_mac = network_utils::ZERO_MAC_STRING; - network_utils::linux_iface_get_mac(local_interface_name, wire_iface_mac); - localInterfaceInfo->mac() = tlvf::mac_from_string(wire_iface_mac); + std::string eth_iface_mac = network_utils::ZERO_MAC_STRING; + network_utils::linux_iface_get_mac(local_eth_iface_name, eth_iface_mac); + localInterfaceInfo->mac() = tlvf::mac_from_string(eth_iface_mac); localInterfaceInfo->media_type() = media_type; localInterfaceInfo->media_info_length() = 0; @@ -263,7 +402,7 @@ void TopologyTask::handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, * Add a LocalInterfaceInfo field for each wireless interface. */ for (const auto radio : db->get_radios_list()) { - if (radio == nullptr) { + if (!radio) { continue; } @@ -273,7 +412,8 @@ void TopologyTask::handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, << (front_iface ? radio->front.iface_name : radio->back.iface_name); // Skip Backhaul iteration iface when STA BWL is not allocated (Eth connection or GW). - if (!front_iface && radio->back.iface_name != db->backhaul.selected_iface_name) { + if (!front_iface && (db->device_conf.local_gw || + radio->back.iface_name != db->backhaul.selected_iface_name)) { LOG(TRACE) << "Skip radio interface with no active STA BWL, front_radio=" << radio->front.iface_name << ", back_radio=" << radio->back.iface_name; return true; @@ -329,27 +469,33 @@ void TopologyTask::handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, return true; }; - std::string &local_interface_name = radio->front.iface_name; + std::string &local_radio_iface_name = radio->front.iface_name; ieee1905_1::eMediaTypeGroup media_type_group = ieee1905_1::eMediaTypeGroup::IEEE_802_11; ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType::UNKNOWN_MEDIA; - if (!MediaType::get_media_type(local_interface_name, media_type_group, media_type)) { - LOG(ERROR) << "Unable to compute media type for interface " << local_interface_name; - return; + if (!MediaType::get_media_type(local_radio_iface_name, media_type_group, media_type)) { + LOG(ERROR) << "Unable to compute media type for interface " << local_radio_iface_name; + return false; } if (!fill_radio_iface_info(media_type, true)) { LOG(DEBUG) << "filling interface information on radio=" << radio->front.iface_name << " has failed!"; - return; + return false; } if (!fill_radio_iface_info(media_type, false)) { LOG(DEBUG) << "filling interface information on radio=" << radio->back.iface_name << " backhaul has failed!"; - return; + return false; } } + return true; +} + +bool TopologyTask::add_1905_neighbor_device_tlv() +{ + auto db = AgentDB::get(); /** * Add a 1905.1 neighbor device TLV for each local interface for which this management entity @@ -364,7 +510,7 @@ void TopologyTask::handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, auto tlv1905NeighborDevice = m_cmdu_tx.addClass(); if (!tlv1905NeighborDevice) { LOG(ERROR) << "addClass ieee1905_1::tlv1905NeighborDevice failed"; - return; + return false; } tlv1905NeighborDevice->mac_local_iface() = neighbors_on_local_iface_entry.first; @@ -372,7 +518,7 @@ void TopologyTask::handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, if (!tlv1905NeighborDevice->alloc_mac_al_1905_device(neighbors_on_local_iface.size())) { LOG(ERROR) << "alloc_mac_al_1905_device() has failed"; - return; + return false; } size_t index = 0; @@ -382,7 +528,7 @@ void TopologyTask::handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, auto mac_al_1905_device_tuple = tlv1905NeighborDevice->mac_al_1905_device(index); if (!std::get<0>(mac_al_1905_device_tuple)) { LOG(ERROR) << "getting mac_al_1905_device element has failed"; - return; + return false; } auto &mac_al_1905_device = std::get<1>(mac_al_1905_device_tuple); @@ -392,13 +538,19 @@ void TopologyTask::handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, index++; } } + return true; +} +bool TopologyTask::add_supported_service_tlv() +{ auto tlvSupportedService = m_cmdu_tx.addClass(); if (!tlvSupportedService) { LOG(ERROR) << "addClass wfa_map::tlvSupportedService failed"; - return; + return false; } + auto db = AgentDB::get(); + size_t number_of_supported_services = 1; if (db->device_conf.local_controller) { number_of_supported_services++; @@ -406,35 +558,41 @@ void TopologyTask::handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, if (!tlvSupportedService->alloc_supported_service_list(number_of_supported_services)) { LOG(ERROR) << "alloc_supported_service_list failed"; - return; + return false; } auto supportedServiceTuple = tlvSupportedService->supported_service_list(0); if (!std::get<0>(supportedServiceTuple)) { LOG(ERROR) << "Failed accessing supported_service_list(0)"; - return; + return false; } std::get<1>(supportedServiceTuple) = wfa_map::tlvSupportedService::eSupportedService::MULTI_AP_AGENT; if (db->device_conf.local_controller) { - auto supportedServiceTuple = tlvSupportedService->supported_service_list(1); + supportedServiceTuple = tlvSupportedService->supported_service_list(1); if (!std::get<0>(supportedServiceTuple)) { LOG(ERROR) << "Failed accessing supported_service_list(1)"; - return; + return false; } std::get<1>(supportedServiceTuple) = wfa_map::tlvSupportedService::eSupportedService::MULTI_AP_CONTROLLER; } + return true; +} +bool TopologyTask::add_ap_operational_bss_tlv() +{ auto tlvApOperationalBSS = m_cmdu_tx.addClass(); if (!tlvApOperationalBSS) { LOG(ERROR) << "addClass wfa_map::tlvApOperationalBSS failed"; - return; + return false; } + auto db = AgentDB::get(); + for (const auto &radio : db->get_radios_list()) { if (!radio) { continue; @@ -458,9 +616,16 @@ void TopologyTask::handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, tlvApOperationalBSS->add_radio_list(radio_list); } + return true; +} + +bool TopologyTask::add_associated_clients_tlv() +{ + auto db = AgentDB::get(); + // The Multi-AP Agent shall include an Associated Clients TLV in the message if there is at // least one 802.11 client directly associated with any of the BSS(s) that is operated by the - // Multi-AP Agent + // Multi-AP Agent. bool include_associated_clients_tlv = false; for (const auto &radio : db->get_radios_list()) { if (!radio) { @@ -475,8 +640,8 @@ void TopologyTask::handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, if (include_associated_clients_tlv) { auto tlvAssociatedClients = m_cmdu_tx.addClass(); if (!tlvAssociatedClients) { - LOG(ERROR) << "addClass wfa_map::tlvAssociatedClients failed, mid=" << std::hex << mid; - return; + LOG(ERROR) << "addClass wfa_map::tlvAssociatedClients failed"; + return false; } // Get current time to compute elapsed time since last client association @@ -516,118 +681,5 @@ void TopologyTask::handle_topology_query(ieee1905_1::CmduMessageRx &cmdu_rx, } } } - - LOG(DEBUG) << "Sending topology response message, mid=" << std::hex << mid; - m_btl_ctx.send_cmdu_to_broker(m_cmdu_tx, tlvf::mac_to_string(src_mac), - tlvf::mac_to_string(db->bridge.mac)); -} - -bool TopologyTask::handle_vendor_specific(ieee1905_1::CmduMessageRx &cmdu_rx, - const sMacAddr &src_mac, - std::shared_ptr beerocks_header) -{ - if (!beerocks_header) { - LOG(ERROR) << "beerocks_header is nullptr"; - return false; - } - - // Since currently we handle only action_ops of action type "ACTION_BACKHAUL", use a single - // switch-case on "ACTION_BACKHAUL" only. - switch (beerocks_header->action_op()) { - case beerocks_message::ACTION_APMANAGER_CLIENT_ASSOCIATED_NOTIFICATION: { - handle_vs_client_associated(cmdu_rx, beerocks_header); - break; - } - case beerocks_message::ACTION_APMANAGER_CLIENT_DISCONNECTED_NOTIFICATION: { - handle_vs_client_disassociated(cmdu_rx, beerocks_header); - break; - } - default: { - // Message was not handled, therefore return false. - return false; - } - } return true; } - -void TopologyTask::handle_vs_client_associated(ieee1905_1::CmduMessageRx &cmdu_rx, - std::shared_ptr beerocks_header) -{ - // TODO: Move handling of "ACTION_APMANAGER_CLIENT_ASSOCIATED_NOTIFICATION" to here when - // moving this task to unified agent context. -} - -void TopologyTask::handle_vs_client_disassociated(ieee1905_1::CmduMessageRx &cmdu_rx, - std::shared_ptr beerocks_header) -{ - // TODO: Move handling of "ACTION_APMANAGER_CLIENT_DISCONNECTED_NOTIFICATION" to here when - // moving this task to unified agent context. -} - -void TopologyTask::send_topology_discovery() -{ - // TODO: get the list of interfaces that are up_and_running using the event-driven mechanism - // to be implemented in #866 - - /** - * Transmission type of Topology Discovery message is 'neighbor multicast'. - * That is, the CMDU must be transmitted once on each and every of its 1905.1 interfaces. - * Also, according to IEEE1905.1, the message should include a MAC Address TLV which contains - * the address of the interface on which the message is sent. Thus, a different message should - * be sent on each interface. - */ - auto db = AgentDB::get(); - - // Make list of ifaces Macs to send on the message. - auto ifaces = network_utils::linux_get_iface_list_from_bridge(db->bridge.iface_name); - for (const auto &iface_name : ifaces) { - if (!network_utils::linux_iface_is_up_and_running(iface_name)) { - continue; - } - - std::string iface_mac_str; - if (!network_utils::linux_iface_get_mac(iface_name, iface_mac_str)) { - LOG(ERROR) << "Failed getting MAC address for interface: " << iface_name; - return; - } - - auto iface_mac = tlvf::mac_from_string(iface_mac_str); - - auto cmdu_header = - m_cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_DISCOVERY_MESSAGE); - if (!cmdu_header) { - LOG(ERROR) << "Failed to create TOPOLOGY_DISCOVERY_MESSAGE cmdu"; - return; - } - auto tlvAlMacAddress = m_cmdu_tx.addClass(); - if (!tlvAlMacAddress) { - LOG(ERROR) << "Failed to create tlvAlMacAddress tlv"; - return; - } - tlvAlMacAddress->mac() = db->bridge.mac; - - auto tlvMacAddress = m_cmdu_tx.addClass(); - if (!tlvMacAddress) { - LOG(ERROR) << "Failed to create tlvMacAddress tlv"; - return; - } - tlvMacAddress->mac() = iface_mac; - - LOG(DEBUG) << "send_1905_topology_discovery_message, bridge_mac=" << db->bridge.mac - << ", iface=" << iface_name; - m_btl_ctx.send_cmdu_to_broker(m_cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, - tlvf::mac_to_string(db->bridge.mac), iface_name); - } -} - -void TopologyTask::send_topology_notification() -{ - auto cmdu_header = m_cmdu_tx.create(0, ieee1905_1::eMessageType::TOPOLOGY_NOTIFICATION_MESSAGE); - if (!cmdu_header) { - LOG(ERROR) << "cmdu creation of type TOPOLOGY_NOTIFICATION_MESSAGE, has failed"; - return; - } - auto db = AgentDB::get(); - m_btl_ctx.send_cmdu_to_broker(m_cmdu_tx, network_utils::MULTICAST_1905_MAC_ADDR, - tlvf::mac_to_string(db->bridge.mac)); -} diff --git a/agent/src/beerocks/slave/tasks/topology_task.h b/agent/src/beerocks/slave/tasks/topology_task.h index b8bca24e35..4875e3e76b 100644 --- a/agent/src/beerocks/slave/tasks/topology_task.h +++ b/agent/src/beerocks/slave/tasks/topology_task.h @@ -89,6 +89,41 @@ class TopologyTask : public Task { void send_topology_discovery(); void send_topology_notification(); + /** + * @brief Add and fill device information tlv. + * + * @return true on success, otherwise false. + */ + bool add_device_information_tlv(); + + /** + * @brief Add and fill 1905_neighbor_device tlv for each know neighbor. + * + * @return true on success, otherwise false. + */ + bool add_1905_neighbor_device_tlv(); + + /** + * @brief Add and fill supported service tlv. + * + * @return true on success, otherwise false. + */ + bool add_supported_service_tlv(); + + /** + * @brief Add and fill AP operational BSS tlv. + * + * @return true on success, otherwise false. + */ + bool add_ap_operational_bss_tlv(); + + /** + * @brief Add and fill associated_clients tlv. + * + * @return true on success, otherwise false. + */ + bool add_associated_clients_tlv(); + backhaul_manager &m_btl_ctx; ieee1905_1::CmduMessageTx &m_cmdu_tx; }; From 76b124885aa558022720283f030ea7824076d1d4 Mon Sep 17 00:00:00 2001 From: Moran Shoeg Date: Wed, 29 Jul 2020 19:53:10 +0000 Subject: [PATCH 441/453] cppcheck: Update existing issues file PPM-320 Signed-off-by: Moran Shoeg --- ci/cppcheck/cppcheck_existing_issues.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/ci/cppcheck/cppcheck_existing_issues.txt b/ci/cppcheck/cppcheck_existing_issues.txt index 9546116589..9e1bda6d43 100644 --- a/ci/cppcheck/cppcheck_existing_issues.txt +++ b/ci/cppcheck/cppcheck_existing_issues.txt @@ -7,8 +7,6 @@ agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp: style: Variable agent/src/beerocks/fronthaul_manager/monitor/monitor_thread.cpp: style: Variable 'iface' is assigned a value that is never used. [unreadVariable] std::string iface = radio_node->get_iface(); agent/src/beerocks/fronthaul_manager/monitor/rdkb/monitor_rdkb_hal.cpp: style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak] break; agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Local variable 'iface_hal' shadows outer variable [shadowVariable] auto iface_hal = get_wireless_hal(sta_iface); -agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Local variable 'local_interface_name' shadows outer variable [shadowVariable] std::string local_interface_name = soc->hostap_iface; -agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Local variable 'supportedServiceTuple' shadows outer variable [shadowVariable] auto supportedServiceTuple = tlvSupportedService->supported_service_list(1); agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp: style: Variable 'p_cmdu_header' is assigned a value that is never used. [unreadVariable] auto p_cmdu_header = agent/src/beerocks/slave/beerocks_slave_main.cpp: style: Parameter 'beerocks_slave_conf' can be declared with const [constParameter]start_son_slave_thread(int slave_num, beerocks::config_file::sConfigSlave &beerocks_slave_conf, agent/src/beerocks/slave/gate/unit_tests/gate_test.cpp: error: syntax error [syntaxError]TEST(gate_beacon_query_test, loading_vs_from_1905_beacon_query) From ee6d7735e45e92dc6c11637c0ba2f294b771af2c Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 15:00:21 +0200 Subject: [PATCH 442/453] PPM-30: Changes to bf plugins for docker-compose Signed-off-by: pablo --- .../devices/prplmesh_base.py | 130 +++++++++++++----- 1 file changed, 92 insertions(+), 38 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py index 700c5c2863..79eea79ea7 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py @@ -3,30 +3,95 @@ # This code is subject to the terms of the BSD+Patent license. # See LICENSE file for more details. -import pexpect - -from boardfarm.devices import linux - - -class CommandError(Exception): - """Raised on failed execution""" - pass - - -class PrplMeshBase(linux.LinuxDevice): - """PrplMesh abstract device.""" - - def _run_shell_cmd(self, cmd: str = "", args: list = None, timeout: int = 30): - """Wrapper that executes command with specified args on host machine and logs output.""" - - res, exitstatus = pexpect.run(cmd, args=args, timeout=timeout, encoding="utf-8", - withexitstatus=1) - entry = " ".join((cmd, " ".join(args))) - if exitstatus != 0: - raise CommandError("Error executing {}:\n{}".format(entry, res)) - - self.log_calls += entry - self.log += "$ " + entry + "\r\n" + res +import os +import time + +import boardfarm +from environment import ALEntityDocker, _get_bridge_interface +from .prplmesh_base import PrplMeshBase +from sniffer import Sniffer + +rootdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..')) + + +class PrplMeshCompose(PrplMeshBase): + """Dockerized prplMesh device.""" + + model = ("prplmesh_compose") + agent_entity = None + controller_entity = None + + def __init__(self, *args, **kwargs): + self.args = args + self.kwargs = kwargs + + config = kwargs.get("config", kwargs) + + # List of device's consoles test can interact with + self.consoles = [self] + + # Getting unic ID to distinguish devices and network they belong to + self.unique_id = os.getenv("RUN_ID") + self.user_id = os.getenv("SUDO_USER", os.getenv("USER", "")) + + self.name = "-".join((config.get("name", "prplmesh_compose"), self.unique_id)) + print('config.get("name") {}'.format(config.get("name"))) + # self.name = config.get("name") + self.role = config.get("role", "agent") + self.cleanup_cmd = config.get("cleanup_cmd", None) + self.conn_cmd = config.get("conn_cmd", None) + self.delay = config.get("delay", 7) + self.docker_network = "boardfarm-ci_default" + + if self.role == "controller": + self._docker_compose(["-d", "--name", self.name, "controller"], + "run", "start-controller") + time.sleep(self.delay) + self.controller_entity = \ + ALEntityDocker(self.name, is_controller=True, compose=True) + else: + self._docker_compose(["-d", "--name", self.name, "agent"], + "run", "start-agent") + time.sleep(self.delay) + self.agent_entity = ALEntityDocker(self.name, is_controller=False, compose=True) + + self.wired_sniffer = Sniffer(_get_bridge_interface(self.docker_network), + boardfarm.config.output_dir) + self.check_status() + + def _docker_compose(self, args, parameter=None, start=None): + print('_docker_compose: args {}'.format(args)) + yml_path = "tools/docker/boardfarm-ci/docker-compose.yml" + full_args = ["-f", os.path.join(rootdir, yml_path)] + if parameter == "run": + log_path = os.path.join(rootdir, "logs/{}".format(self.name)) + if not os.path.exists(log_path): + os.mkdir(log_path) + + pipeline_id = os.getenv('CI_PIPELINE_ID') + if pipeline_id is None or pipeline_id == 'latest': + vol = '{}:/tmp/{}/beerocks/logs'.format(log_path, self.user_id) + else: + vol = '{}:/tmp/beerocks/logs'.format(log_path) + + full_args += ["run", "--rm", "-v", vol] + # full_args += ["--entrypoint", entrypoint + ' ' + start] + full_args += args + + print('_docker_compose: {}'.format(' '.join(full_args))) + # os.environ['CURRENT_UID'] = '1000:998' + if os.getenv('CI_PIPELINE_ID') is None: + print('Setting CI_PIPELINE_ID "latest"') + os.environ['CI_PIPELINE_ID'] = 'latest' + self._run_shell_cmd("/usr/local/bin/docker-compose", + full_args, env=os.environ) + else: + self._run_shell_cmd("/usr/local/bin/docker-compose", full_args) + + def __del__(self): + # self._docker_compose(["stop", self.name]) + self._run_shell_cmd("docker", ["stop", self.name]) + self._run_shell_cmd("docker", ["container", "rm", "-f", self.name]) def check_status(self): """Method required by boardfarm. @@ -34,25 +99,14 @@ def check_status(self): It is used by boardfarm to indicate that spawned device instance is ready for test and also after test - to insure that device still operational. """ - pass - - def close(self): - """Method required by boardfarm. - - Purpose is to close connection to device's consoles. - """ + # self._run_shell_cmd(os.path.join(rootdir, "tools", "docker", "test.sh"), + # ["-v", "-n", "controller"]) pass def isalive(self): """Method required by boardfarm. States that device is operational and its consoles are accessible. - """ - pass - - def touch(self): - """Method required by boardfarm. - Purpose is to keep consoles active, so they don't disconnect for long running activities. """ - pass + return True From c0bcdaa88684dc66aa19a157b75290ad606f7345 Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 15:04:25 +0200 Subject: [PATCH 443/453] PPM-30: Changes on class ALEntityDocker for compose Use directly the hostname instead of querying for the ip Signed-off-by: pablo --- tests/environment.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/environment.py b/tests/environment.py index 7da67bb6b0..888ff0fe71 100644 --- a/tests/environment.py +++ b/tests/environment.py @@ -191,6 +191,9 @@ def _docker_wait_for_log(container: str, programs: [str], regex: str, start_line timeout: float) -> bool: def logfilename(program): logfilename = os.path.join(rootdir, 'logs', container, 'beerocks_{}.log'.format(program)) + + print(' --- logfilename: {}'.format(logfilename)) + # WSL doesn't support symlinks on NTFS, so resolve the symlink manually if on_wsl: logfilename = os.path.join( @@ -249,9 +252,9 @@ class ALEntityDocker(ALEntity): The entity is defined from the name of the container, the rest is derived from that. ''' - # NOTE: name arg can be also extracted from the device class itself, but test_flows.py - # don't have it. We can remove this arg as soon, as we drop test_flows.py - def __init__(self, name: str, device: None = None, is_controller: bool = False): + def __init__(self, name: str, device: None = None, is_controller: bool = False, + compose: bool = False): + self.name = name self.bridge_name = 'br-lan' if device: @@ -268,16 +271,19 @@ def __init__(self, name: str, device: None = None, is_controller: bool = False): config_file.read()).group('port') # On WSL, connect to the locally exposed container port - if on_wsl: - published_port_output = subprocess.check_output( - ["docker", "port", name, ucc_port]).decode('utf-8').split(":") - device_ip = published_port_output[0] - ucc_port = int(published_port_output[1]) + if not compose: + if on_wsl: + published_port_output = subprocess.check_output( + ["docker", "port", name, ucc_port]).decode('utf-8').split(":") + device_ip = published_port_output[0] + ucc_port = int(published_port_output[1]) + else: + device_ip_output = self.command( + 'ip', '-f', 'inet', 'addr', 'show', self.bridge_name) + device_ip = re.search( + r'inet (?P[0-9.]+)', device_ip_output.decode('utf-8')).group('ip') else: - device_ip_output = self.command( - 'ip', '-f', 'inet', 'addr', 'show', self.bridge_name) - device_ip = re.search(r'inet (?P[0-9.]+)', - device_ip_output.decode('utf-8')).group('ip') + device_ip = name ucc_socket = UCCSocket(device_ip, ucc_port) mac = ucc_socket.dev_get_parameter('ALid') From 8ea7ebf4c23bb3a21fecfeb2b072486ccb6f985c Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 15:06:16 +0200 Subject: [PATCH 444/453] PPM-30: Define test entrypoint and json config Entrypoint calls the json for "in compose" tests Signed-off-by: pablo --- .../prplmesh_config_compose.json | 15 +++++++++++++++ tests/run_bf_compose.sh | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config_compose.json create mode 100755 tests/run_bf_compose.sh diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config_compose.json b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config_compose.json new file mode 100644 index 0000000000..dbd3897cb8 --- /dev/null +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/prplmesh_config_compose.json @@ -0,0 +1,15 @@ +{ + "prplmesh_docker": { + "name": "dockerized_device", + "board_type": "prplmesh_compose", + "role": "controller", + "conn_cmd": "", + "devices": [ + { + "name": "repeater1", + "type": "prplmesh_compose", + "conn_cmd": "" + } + ] + } +} diff --git a/tests/run_bf_compose.sh b/tests/run_bf_compose.sh new file mode 100755 index 0000000000..365e3a7671 --- /dev/null +++ b/tests/run_bf_compose.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# SPDX-License-Identifier: BSD-2-Clause-Patent +# SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) +# This code is subject to the terms of the BSD+Patent license. +# See LICENSE file for more details. + +scriptdir=$(dirname "$(readlink -f "${0}")") +bf_plugins_dir=${scriptdir}/boardfarm_plugins + +if [ -n "${PYTHONPATH}" ]; then + PYTHONPATH="${bf_plugins_dir}:${scriptdir}:${PYTHONPATH}" +else + PYTHONPATH="${bf_plugins_dir}:${scriptdir}" +fi +echo "$PYTHONPATH" +export PYTHONPATH + +exec bft -c "${bf_plugins_dir}"/boardfarm_prplmesh/prplmesh_config_compose.json -n prplmesh_docker -x test_flows From 42420805fa4f4a2726f25c779f7df8763bce8818 Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 15:10:11 +0200 Subject: [PATCH 445/453] PPM-30: Dockerfile and docker-compose.yml Dockerfile to create boardfarm docker image and docker-compose.yml with the configuration for boardfarm, controller and extender Signed-off-by: pablo --- tools/docker/boardfarm-ci/Dockerfile | 30 +++------- tools/docker/boardfarm-ci/docker-compose.yml | 60 ++++++++++++++++++++ 2 files changed, 69 insertions(+), 21 deletions(-) create mode 100644 tools/docker/boardfarm-ci/docker-compose.yml diff --git a/tools/docker/boardfarm-ci/Dockerfile b/tools/docker/boardfarm-ci/Dockerfile index 67fd3ed294..a5d2979de6 100644 --- a/tools/docker/boardfarm-ci/Dockerfile +++ b/tools/docker/boardfarm-ci/Dockerfile @@ -1,41 +1,29 @@ FROM python:3.8-slim-buster +# FROM tiangolo/docker-with-compose RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - apt-transport-https \ - ca-certificates curl \ - curl \ - gcc \ - git \ - gnupg \ - gnupg-agent \ - libsnmp-dev \ - netcat \ - software-properties-common \ - wireshark-common \ - && rm -rf /var/lib/apt/lists/* +&& apt-get install gcc libsnmp-dev -y \ +&& apt-get clean COPY requirements.txt /app/requirements.txt WORKDIR app RUN pip3 install -r requirements.txt -# TODO: what needs this? -#RUN pip3 install jsonschema distro +RUN apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y +RUN apt-get install curl -y RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - docker-ce \ - docker-ce-cli \ - containerd.io \ - && rm -rf /var/lib/apt/lists/* - +&& apt-get install docker-ce docker-ce-cli containerd.io -y RUN curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose RUN chmod 755 /usr/local/bin/docker-compose +RUN DEBIAN_FRONTEND=noninteractive apt-get install wireshark-common -y +# VOLUME "/home/pablo/assia/prpl/git" +# ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] RUN git clone https://github.com/mattsm/boardfarm.git \ && cd boardfarm \ && git checkout 100521fde1fb67536682cafecc2f91a6e2e8a6f8 \ diff --git a/tools/docker/boardfarm-ci/docker-compose.yml b/tools/docker/boardfarm-ci/docker-compose.yml new file mode 100644 index 0000000000..1f50b9cc75 --- /dev/null +++ b/tools/docker/boardfarm-ci/docker-compose.yml @@ -0,0 +1,60 @@ +version: '3' +services: + # Controller and agent are run from inside the boardfarm container + controller: + image: registry.gitlab.com/prpl-foundation/prplmesh/prplmesh-runner:${CI_PIPELINE_ID} + privileged: true # For the creation of the bridge to work + container_name: controller + environment: + - USER + - INSTALL_DIR=${FINAL_ROOT_DIR}/build/install + - ROOT_DIR=${FINAL_ROOT_DIR} + - CURRENT_ID + - CI_PIPELINE_ID + expose: + - "5000" + - "8002" + volumes: + - "$ROOT_DIR:${FINAL_ROOT_DIR}" + entrypoint: ["/root/entrypoint.sh", "/usr/bin/start-controller-agent"] + + agent: + image: registry.gitlab.com/prpl-foundation/prplmesh/prplmesh-runner:${CI_PIPELINE_ID} + privileged: true + container_name: agent + environment: + - USER + - INSTALL_DIR=${FINAL_ROOT_DIR}/build/install + - ROOT_DIR=${FINAL_ROOT_DIR} + # /builds/prpl-foundation/prplMesh + - CURRENT_ID + - CI_PIPELINE_ID + expose: + - "5000" + - "8002" + volumes: + - "$ROOT_DIR:${FINAL_ROOT_DIR}" + entrypoint: ["/root/entrypoint.sh", "/usr/bin/start-agent"] + + # Boardfarm image is launched from dctest.py, TARGET_DIR refers to the + # path inside the controller, will be referred as $ROOT_DIR inside + boardfarm: + build: . + privileged: true + container_name: boardfarm + environment: + - USER + - ROOT_DIR + - CURRENT_ID + - RUN_ID + - CI_PIPELINE_ID + - FINAL_ROOT_DIR + ports: + - "5000:5000" + volumes: + - "$ROOT_DIR:$ROOT_DIR" + - "/var/run/docker:/var/run/docker" + - "/var/run/docker.sock:/var/run/docker.sock" + user: ${CURRENT_UID} + working_dir: $ROOT_DIR/tests + entrypoint: ["bash", "run_bf_compose.sh"] From 34a067e1b73f32b1f83e1aa57f8929fd51d1d866 Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 15:11:33 +0200 Subject: [PATCH 446/453] PPM-30: dctest.py script to wrap docker-compose It wraps docker-compose tests - Verifies versions of docker and docker-compose - Creates and launches boardfarm image with the correct environment variables - Cleans images after building - Returns value from boardfarm process inside the image Signed-off-by: pablo --- dctest.py | 255 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100755 dctest.py diff --git a/dctest.py b/dctest.py new file mode 100755 index 0000000000..3855209703 --- /dev/null +++ b/dctest.py @@ -0,0 +1,255 @@ +#!/usr/bin/env python3 +# +# Launch the test suite using docker and docker-compose. This script wraps +# the creation of the bridge(s) to be able to connect external devices with +# the docker network, launching the service for boardfarm. +# +# As this script is run outside containers, it does not use anything apart +# from Python 3.5 (will work on later versions but only uses 3.5 features) +# +# The best way to make sure no Python 3.5+ features are used is running the +# script with a Python 3.5.0 interpreter. Compile it from: +# +# https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz +# +# Also, when calling a function look for 'New in version 3.X' where X > 5 +# +from __future__ import print_function # To check for python2 or < 3.5 execution +import argparse +import fcntl +import os +import grp +import shutil +import getpass +import sys +from subprocess import Popen, PIPE + + +if not (sys.version_info.major == 3 and sys.version_info.minor >= 5): + print("This script requires Python 3.5 or higher!") + print("You are using Python {}.{}.".format(sys.version_info.major, sys.version_info.minor)) + sys.exit(1) + + +def check_docker_versions(): + DOCKER_MAJOR = 19 + DC_MAJOR = 1 + DC_MINOR = 25 + docker_version = os.popen('docker --version').read().split(' ')[2] + docker_major = int(docker_version.split('.')[0]) + if docker_major < DOCKER_MAJOR: + fmt = "This script requires docker {}.0 or higher" + print(fmt.format(DOCKER_MAJOR)) + print("You are usng version {}".format(docker_version)) + sys.exit(1) + dc_version = os.popen('docker-compose --version').read().split(' ')[2] + dc_major = int(dc_version.split('.')[0]) + dc_minor = int(dc_version.split('.')[1]) + if dc_major < DC_MAJOR: + fmt = "This script requires docker-compose {}.{} or higher" + print(fmt.format(DC_MAJOR, DC_MINOR)) + print("You are usng version {}".format(dc_version)) + sys.exit(1) + if dc_minor < DC_MINOR: + fmt = "This script requires docker-compose {}.{} or higher" + print(fmt.format(DC_MAJOR, DC_MINOR)) + print("You are usng version {}".format(dc_version)) + sys.exit(1) + + +class Services: + def __init__(self, bid=None): + self.scriptdir = os.path.dirname(os.path.realpath(__file__)) + os.chdir(self.scriptdir) + self.rootdir = self.scriptdir + + if bid is not None: + self.build_id = bid + print('Using ID {}'.format(self.build_id)) + # return + else: + self.build_id = self.get_build_id() + + self.logdir = os.path.join(self.scriptdir, 'logs') + device_name = 'dockerized_device-{}'.format(self.build_id) + self.devicedir = os.path.join(self.logdir, device_name) + repeater_name = 'repeater1-{}'.format(self.build_id) + self.repeaterdir = os.path.join(self.logdir, repeater_name) + if not os.path.exists(self.logdir): + os.makedirs(self.logdir) + if not os.path.exists(self.devicedir): + print('Making {}'.format(self.devicedir)) + os.makedirs(self.devicedir) + if not os.path.exists(self.repeaterdir): + print('Making {}'.format(self.repeaterdir)) + os.makedirs(self.repeaterdir) + + def cleanlogs(self): + shutil.rmtree(os.path.join(self.scriptdir, 'logs')) + + def _setNonBlocking(fd): + """ + Set the file description of the given file descriptor to non-blocking. + """ + flags = fcntl.fcntl(fd, fcntl.F_GETFL) + flags = flags | os.O_NONBLOCK + fcntl.fcntl(fd, fcntl.F_SETFL, flags) + + def get_build_id(self): + ci_pipeline_id = os.getenv('CI_PIPELINE_ID') + if ci_pipeline_id is not None: + return ci_pipeline_id + + # Otherwise we are running on the local machine, just find last id + # created and add one + last_id = 0 + if not os.path.exists('logs'): + return str(1) + for d in os.listdir('logs'): + if d.startswith('dockerized_device-'): + suffix = d[len('dockerized_device-'):] + isuffix = int(suffix) + if isuffix > last_id: + last_id = isuffix + if last_id == 0: + new_id = 1 + else: + new_id = last_id + 1 + return str(new_id) + + def copy_build_dir(self): + new_id = self.build_id + self.build_dir = 'build-{}'.format(new_id) + shutil.copytree('build', 'build-{}'.format(self.build_dir)) + print('Copied build/ into {}'.format(self.build_dir)) + + def dc(self, args, interactive=False): + params = ['docker-compose', '-f', + 'tools/docker/boardfarm-ci/docker-compose.yml'] + # params += ['-p', 'boardfarm-ci-{}'.format(self.build_id)] + params += args + local_env = os.environ + local_env['ROOT_DIR'] = self.rootdir + docker_gid = grp.getgrnam('docker')[2] + local_env['CURRENT_UID'] = str(os.getuid()) + ':' + str(docker_gid) + local_env['CURRENT_ID'] = str(os.getuid()) + local_env['RUN_ID'] = self.build_id + + if os.getenv('CI_PIPELINE_ID') is None: + # Running locally + local_env['CI_PIPELINE_ID'] = 'latest' + local_env['FINAL_ROOT_DIR'] = self.rootdir + else: + # Running inside gitlab-ci + local_env['FINAL_ROOT_DIR'] = '/builds/prpl-foundation/prplMesh' + + # local_env['CURRENT_UID']= str(os.getuid()) + ':' + str(os.getgid()) + if not interactive: + proc = Popen(params, stdout=PIPE, stderr=PIPE) + for line in proc.stdout: + print(line.decode(), end='') + proc.stdout.close() + else: + proc = Popen(params) + return_code = proc.wait() + return return_code + + +def vararg_callback(option, opt_str, value, parser): + assert value is None + value = [] + + def floatable(str): + try: + float(str) + return True + except ValueError: + return False + + for arg in parser.rargs: + # stop on --foo like options + if arg[:2] == "--" and len(arg) > 2: + break + # stop on -a, but not on -3 or -3.0 + if arg[:1] == "-" and len(arg) > 1 and not floatable(arg): + break + value.append(arg) + + del parser.rargs[:len(value)] + setattr(parser.values, option.dest, value) + + +def cleanup(rc): + if rc != 0: + print('Return code !=0 -> {}'.format(rc)) + if getpass.getuser() == 'gitlab-runner': + os.system('chown -R gitlab-runner:gitlab-runner .') + sys.exit(rc) + + +if __name__ == '__main__': + check_docker_versions() + parser = argparse.ArgumentParser(description='Dockerized test launcher') + parser.add_argument('--test', dest='test', type=str, help='Test to be run') + parser.add_argument('--clean', dest='clean', action='store_true', + help='Clean containers images and networks') + parser.add_argument('--build', dest='build', action='store_true', + help='Rebuild containers') + parser.add_argument('--shell', dest='shell', action='store_true', + help='Run a shell on the bf container') + parser.add_argument('--comp', dest='comp', action='store_true', + help='Pass the rest of arguments to docker-compose') + parser.add_argument('--id', dest='bid', type=str, + help='Specify the id to use for build/shell/comp/clean') + args, rest = parser.parse_known_args() + + if os.getenv('CI_PIPELINE_ID') is not None: + args.bid == os.getenv('CI_PIPELINE_ID') + + if args.comp: + if args.bid is None: + print('Specify --id for the --comp parameter') + sys.exit(0) + services = Services(bid=args.bid) + if len(rest) == 0: + print('Usage: dctest --id --comp ') + sys.exit(1) + sys.exit(services.dc(rest, interactive=True)) + else: + if len(rest) > 0: + print('Unknown parameters: {}'.format(rest)) + sys.exit(1) + + if args.clean: + if args.bid is None: + print('Specify --id for the --clean parameter') + sys.exit(0) + services = Services(bid=args.bid) + rc = services.dc(['down', '--remove-orphans', '--rmi', 'all']) + cleanup(rc) + elif args.shell: + if not args.bid: + print('Specify --id for the shell parameter') + sys.exit(0) + services = Services(bid=args.bid) + rc = services.dc(['run', '--rm', '--service-ports', '--entrypoint', + '/bin/bash', 'boardfarm'], interactive=True) + cleanup(rc) + elif args.build: + if not args.bid: + print('Specify --id for the build parameter') + sys.exit(0) + services = Services(bid=args.bid) + rc = services.dc(['build'], interactive=True) + cleanup(rc) + else: + if args.bid: + services = Services(bid=args.bid) # With new build id + else: + services = Services() # With new build id + # rc = services.dc(['up', 'boardfarm']) + # rc = services.dc(['run', '--service-ports', '--entrypoint', + # '/bin/bash', 'boardfarm'], interactive=True) + rc = services.dc(['run', '--rm', '--service-ports', '--use-aliases', + 'boardfarm'], interactive=True) + cleanup(rc) From a7c0852bad46f8a13a0fb8ba52fafe335f8eee20 Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 16:48:34 +0200 Subject: [PATCH 447/453] PPM-30: Add test to boardfarm-ci Signed-off-by: pablo --- .gitlab-ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 090b7315eb..7d5cda44ef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -180,6 +180,7 @@ upload-artifacts: - build-for-glinet-b1300 - build-for-turris-omnia + .run-test-in-docker: stage: test extends: .in-prplmesh-builder @@ -198,6 +199,15 @@ bwl_dummy_unit_tests: bcl_unit_tests: extends: .run-test-in-docker +dctest_one_test: + stage: test + script: + - ./dctest.py + tags: + - boardfarm-compose + needs: + - job: build-in-docker + mapf_common_encryption_tests: extends: .run-test-in-docker From c1e5262a756c3a7043e8bb5639409c654c9a34eb Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 17:52:38 +0200 Subject: [PATCH 448/453] PPM-30: Check return error on _run_shell Signed-off-by: pablo --- .../devices/prplmesh_base.py | 104 ++++-------------- 1 file changed, 22 insertions(+), 82 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py index 79eea79ea7..b8cd850d72 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_base.py @@ -3,95 +3,35 @@ # This code is subject to the terms of the BSD+Patent license. # See LICENSE file for more details. -import os -import time +import pexpect +from typing import Dict -import boardfarm -from environment import ALEntityDocker, _get_bridge_interface -from .prplmesh_base import PrplMeshBase -from sniffer import Sniffer +from boardfarm.devices import linux -rootdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..')) +class CommandError(Exception): + """Raised on failed execution""" + pass -class PrplMeshCompose(PrplMeshBase): - """Dockerized prplMesh device.""" - model = ("prplmesh_compose") - agent_entity = None - controller_entity = None +class PrplMeshBase(linux.LinuxDevice): + """PrplMesh abstract device.""" - def __init__(self, *args, **kwargs): - self.args = args - self.kwargs = kwargs - - config = kwargs.get("config", kwargs) - - # List of device's consoles test can interact with - self.consoles = [self] - - # Getting unic ID to distinguish devices and network they belong to - self.unique_id = os.getenv("RUN_ID") - self.user_id = os.getenv("SUDO_USER", os.getenv("USER", "")) - - self.name = "-".join((config.get("name", "prplmesh_compose"), self.unique_id)) - print('config.get("name") {}'.format(config.get("name"))) - # self.name = config.get("name") - self.role = config.get("role", "agent") - self.cleanup_cmd = config.get("cleanup_cmd", None) - self.conn_cmd = config.get("conn_cmd", None) - self.delay = config.get("delay", 7) - self.docker_network = "boardfarm-ci_default" - - if self.role == "controller": - self._docker_compose(["-d", "--name", self.name, "controller"], - "run", "start-controller") - time.sleep(self.delay) - self.controller_entity = \ - ALEntityDocker(self.name, is_controller=True, compose=True) - else: - self._docker_compose(["-d", "--name", self.name, "agent"], - "run", "start-agent") - time.sleep(self.delay) - self.agent_entity = ALEntityDocker(self.name, is_controller=False, compose=True) - - self.wired_sniffer = Sniffer(_get_bridge_interface(self.docker_network), - boardfarm.config.output_dir) - self.check_status() - - def _docker_compose(self, args, parameter=None, start=None): - print('_docker_compose: args {}'.format(args)) - yml_path = "tools/docker/boardfarm-ci/docker-compose.yml" - full_args = ["-f", os.path.join(rootdir, yml_path)] - if parameter == "run": - log_path = os.path.join(rootdir, "logs/{}".format(self.name)) - if not os.path.exists(log_path): - os.mkdir(log_path) - - pipeline_id = os.getenv('CI_PIPELINE_ID') - if pipeline_id is None or pipeline_id == 'latest': - vol = '{}:/tmp/{}/beerocks/logs'.format(log_path, self.user_id) - else: - vol = '{}:/tmp/beerocks/logs'.format(log_path) - - full_args += ["run", "--rm", "-v", vol] - # full_args += ["--entrypoint", entrypoint + ' ' + start] - full_args += args - - print('_docker_compose: {}'.format(' '.join(full_args))) - # os.environ['CURRENT_UID'] = '1000:998' - if os.getenv('CI_PIPELINE_ID') is None: - print('Setting CI_PIPELINE_ID "latest"') - os.environ['CI_PIPELINE_ID'] = 'latest' - self._run_shell_cmd("/usr/local/bin/docker-compose", - full_args, env=os.environ) + def _run_shell_cmd(self, cmd: str = "", args: list = None, timeout: int = 30, + env: Dict[str, str] = None): + """Wrapper that executes command with specified args on host machine and logs output.""" + if env is not None: + res, exitstatus = pexpect.run(cmd, args=args, timeout=timeout, encoding="utf-8", + withexitstatus=1, env=env) else: - self._run_shell_cmd("/usr/local/bin/docker-compose", full_args) - - def __del__(self): - # self._docker_compose(["stop", self.name]) - self._run_shell_cmd("docker", ["stop", self.name]) - self._run_shell_cmd("docker", ["container", "rm", "-f", self.name]) + res, exitstatus = pexpect.run(cmd, args=args, timeout=timeout, encoding="utf-8", + withexitstatus=1) + entry = " ".join((cmd, " ".join(args))) + if exitstatus != 0: + raise CommandError("Error executing {}".format(entry)) + + self.log_calls += entry + self.log += "$ " + entry + "\r\n" + res def check_status(self): """Method required by boardfarm. From 38b78363f882151b55d614458cd96b91bc97ae28 Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 4 Aug 2020 18:13:21 +0200 Subject: [PATCH 449/453] Added device prplmesh_compose.py Signed-off-by: pablo --- .../devices/prplmesh_compose.py | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py new file mode 100644 index 0000000000..79eea79ea7 --- /dev/null +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py @@ -0,0 +1,112 @@ +# SPDX-License-Identifier: BSD-2-Clause-Patent +# SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md) +# This code is subject to the terms of the BSD+Patent license. +# See LICENSE file for more details. + +import os +import time + +import boardfarm +from environment import ALEntityDocker, _get_bridge_interface +from .prplmesh_base import PrplMeshBase +from sniffer import Sniffer + +rootdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..')) + + +class PrplMeshCompose(PrplMeshBase): + """Dockerized prplMesh device.""" + + model = ("prplmesh_compose") + agent_entity = None + controller_entity = None + + def __init__(self, *args, **kwargs): + self.args = args + self.kwargs = kwargs + + config = kwargs.get("config", kwargs) + + # List of device's consoles test can interact with + self.consoles = [self] + + # Getting unic ID to distinguish devices and network they belong to + self.unique_id = os.getenv("RUN_ID") + self.user_id = os.getenv("SUDO_USER", os.getenv("USER", "")) + + self.name = "-".join((config.get("name", "prplmesh_compose"), self.unique_id)) + print('config.get("name") {}'.format(config.get("name"))) + # self.name = config.get("name") + self.role = config.get("role", "agent") + self.cleanup_cmd = config.get("cleanup_cmd", None) + self.conn_cmd = config.get("conn_cmd", None) + self.delay = config.get("delay", 7) + self.docker_network = "boardfarm-ci_default" + + if self.role == "controller": + self._docker_compose(["-d", "--name", self.name, "controller"], + "run", "start-controller") + time.sleep(self.delay) + self.controller_entity = \ + ALEntityDocker(self.name, is_controller=True, compose=True) + else: + self._docker_compose(["-d", "--name", self.name, "agent"], + "run", "start-agent") + time.sleep(self.delay) + self.agent_entity = ALEntityDocker(self.name, is_controller=False, compose=True) + + self.wired_sniffer = Sniffer(_get_bridge_interface(self.docker_network), + boardfarm.config.output_dir) + self.check_status() + + def _docker_compose(self, args, parameter=None, start=None): + print('_docker_compose: args {}'.format(args)) + yml_path = "tools/docker/boardfarm-ci/docker-compose.yml" + full_args = ["-f", os.path.join(rootdir, yml_path)] + if parameter == "run": + log_path = os.path.join(rootdir, "logs/{}".format(self.name)) + if not os.path.exists(log_path): + os.mkdir(log_path) + + pipeline_id = os.getenv('CI_PIPELINE_ID') + if pipeline_id is None or pipeline_id == 'latest': + vol = '{}:/tmp/{}/beerocks/logs'.format(log_path, self.user_id) + else: + vol = '{}:/tmp/beerocks/logs'.format(log_path) + + full_args += ["run", "--rm", "-v", vol] + # full_args += ["--entrypoint", entrypoint + ' ' + start] + full_args += args + + print('_docker_compose: {}'.format(' '.join(full_args))) + # os.environ['CURRENT_UID'] = '1000:998' + if os.getenv('CI_PIPELINE_ID') is None: + print('Setting CI_PIPELINE_ID "latest"') + os.environ['CI_PIPELINE_ID'] = 'latest' + self._run_shell_cmd("/usr/local/bin/docker-compose", + full_args, env=os.environ) + else: + self._run_shell_cmd("/usr/local/bin/docker-compose", full_args) + + def __del__(self): + # self._docker_compose(["stop", self.name]) + self._run_shell_cmd("docker", ["stop", self.name]) + self._run_shell_cmd("docker", ["container", "rm", "-f", self.name]) + + def check_status(self): + """Method required by boardfarm. + + It is used by boardfarm to indicate that spawned device instance is ready for test + and also after test - to insure that device still operational. + """ + # self._run_shell_cmd(os.path.join(rootdir, "tools", "docker", "test.sh"), + # ["-v", "-n", "controller"]) + pass + + def isalive(self): + """Method required by boardfarm. + + States that device is operational and its consoles are accessible. + + """ + return True From 7e90bb234731d4574dc5ad69c3756b776e9bfdbd Mon Sep 17 00:00:00 2001 From: odkq Date: Wed, 5 Aug 2020 16:46:33 +0200 Subject: [PATCH 450/453] boardfarm-ci: Set device on prplmesh_compose.py Signed-off-by: odkq --- .../boardfarm_prplmesh/devices/prplmesh_compose.py | 4 ++-- tests/run_bf_compose.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py index 79eea79ea7..e94328fda3 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py @@ -48,12 +48,12 @@ def __init__(self, *args, **kwargs): "run", "start-controller") time.sleep(self.delay) self.controller_entity = \ - ALEntityDocker(self.name, is_controller=True, compose=True) + ALEntityDocker(self.name, device=self, is_controller=True, compose=True) else: self._docker_compose(["-d", "--name", self.name, "agent"], "run", "start-agent") time.sleep(self.delay) - self.agent_entity = ALEntityDocker(self.name, is_controller=False, compose=True) + self.agent_entity = ALEntityDocker(self.name, device=self, is_controller=False, compose=True) self.wired_sniffer = Sniffer(_get_bridge_interface(self.docker_network), boardfarm.config.output_dir) diff --git a/tests/run_bf_compose.sh b/tests/run_bf_compose.sh index 365e3a7671..df9b144dcc 100755 --- a/tests/run_bf_compose.sh +++ b/tests/run_bf_compose.sh @@ -14,5 +14,5 @@ else fi echo "$PYTHONPATH" export PYTHONPATH - +export BFT_DEBUG=y exec bft -c "${bf_plugins_dir}"/boardfarm_prplmesh/prplmesh_config_compose.json -n prplmesh_docker -x test_flows From 5b6846d49d46a6ef48067d3faf4b66609cf9a197 Mon Sep 17 00:00:00 2001 From: odkq Date: Wed, 5 Aug 2020 17:31:03 +0200 Subject: [PATCH 451/453] boardfarm-ci: Add mockup of prplmesh_status_check Signed-off-by: odkq --- .../boardfarm_prplmesh/devices/prplmesh_compose.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py index e94328fda3..9db700ecc8 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py @@ -45,7 +45,7 @@ def __init__(self, *args, **kwargs): if self.role == "controller": self._docker_compose(["-d", "--name", self.name, "controller"], - "run", "start-controller") + "run", "start-controller-agent") time.sleep(self.delay) self.controller_entity = \ ALEntityDocker(self.name, device=self, is_controller=True, compose=True) @@ -110,3 +110,7 @@ def isalive(self): """ return True + + def prprlmesh_status_check(self): + return True + From fa9af45d5688d254f6e0f69620820caffbfa8af6 Mon Sep 17 00:00:00 2001 From: odkq Date: Thu, 6 Aug 2020 12:44:55 +0200 Subject: [PATCH 452/453] Use original name and docker-name for hostname in environment.py Signed-off-by: odkq --- .../boardfarm_prplmesh/devices/prplmesh_compose.py | 3 ++- tests/environment.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py index 9db700ecc8..62f83d9ff9 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py @@ -34,7 +34,8 @@ def __init__(self, *args, **kwargs): self.unique_id = os.getenv("RUN_ID") self.user_id = os.getenv("SUDO_USER", os.getenv("USER", "")) - self.name = "-".join((config.get("name", "prplmesh_compose"), self.unique_id)) + self.docker_name = "-".join((config.get("name", "prplmesh_compose"), self.unique_id)) + self.name = config.get("name", "prplmesh_compose") print('config.get("name") {}'.format(config.get("name"))) # self.name = config.get("name") self.role = config.get("role", "agent") diff --git a/tests/environment.py b/tests/environment.py index 888ff0fe71..4f80f73513 100644 --- a/tests/environment.py +++ b/tests/environment.py @@ -283,7 +283,7 @@ def __init__(self, name: str, device: None = None, is_controller: bool = False, device_ip = re.search( r'inet (?P[0-9.]+)', device_ip_output.decode('utf-8')).group('ip') else: - device_ip = name + device_ip = self.device.name ucc_socket = UCCSocket(device_ip, ucc_port) mac = ucc_socket.dev_get_parameter('ALid') From bfa9bd720280293e5cd491ef98e791182cf6136e Mon Sep 17 00:00:00 2001 From: odkq Date: Thu, 6 Aug 2020 15:16:19 +0200 Subject: [PATCH 453/453] boardfarm-ci: Use docker_name Signed-off-by: odkq --- .../boardfarm_prplmesh/devices/prplmesh_compose.py | 12 ++++++------ tests/environment.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py index 62f83d9ff9..b8e3ff821a 100644 --- a/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py +++ b/tests/boardfarm_plugins/boardfarm_prplmesh/devices/prplmesh_compose.py @@ -45,13 +45,13 @@ def __init__(self, *args, **kwargs): self.docker_network = "boardfarm-ci_default" if self.role == "controller": - self._docker_compose(["-d", "--name", self.name, "controller"], + self._docker_compose(["-d", "--name", self.docker_name, "controller"], "run", "start-controller-agent") time.sleep(self.delay) self.controller_entity = \ ALEntityDocker(self.name, device=self, is_controller=True, compose=True) else: - self._docker_compose(["-d", "--name", self.name, "agent"], + self._docker_compose(["-d", "--name", self.docker_name, "agent"], "run", "start-agent") time.sleep(self.delay) self.agent_entity = ALEntityDocker(self.name, device=self, is_controller=False, compose=True) @@ -65,7 +65,7 @@ def _docker_compose(self, args, parameter=None, start=None): yml_path = "tools/docker/boardfarm-ci/docker-compose.yml" full_args = ["-f", os.path.join(rootdir, yml_path)] if parameter == "run": - log_path = os.path.join(rootdir, "logs/{}".format(self.name)) + log_path = os.path.join(rootdir, "logs/{}".format(self.docker_name)) if not os.path.exists(log_path): os.mkdir(log_path) @@ -90,9 +90,9 @@ def _docker_compose(self, args, parameter=None, start=None): self._run_shell_cmd("/usr/local/bin/docker-compose", full_args) def __del__(self): - # self._docker_compose(["stop", self.name]) - self._run_shell_cmd("docker", ["stop", self.name]) - self._run_shell_cmd("docker", ["container", "rm", "-f", self.name]) + # self._docker_compose(["stop", self.name + self._run_shell_cmd("docker", ["stop", self.docker_name]) + self._run_shell_cmd("docker", ["container", "rm", "-f", self.docker_name]) def check_status(self): """Method required by boardfarm. diff --git a/tests/environment.py b/tests/environment.py index 4f80f73513..715c6cd5ff 100644 --- a/tests/environment.py +++ b/tests/environment.py @@ -283,7 +283,7 @@ def __init__(self, name: str, device: None = None, is_controller: bool = False, device_ip = re.search( r'inet (?P[0-9.]+)', device_ip_output.decode('utf-8')).group('ip') else: - device_ip = self.device.name + device_ip = self.device.docker_name ucc_socket = UCCSocket(device_ip, ucc_port) mac = ucc_socket.dev_get_parameter('ALid')