From 5030808e05b2a06e9e53a74be51ae82afcac2452 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Mon, 26 Jul 2021 21:47:11 -0700 Subject: [PATCH] [simulation] add empty `otPlatInfraIf` platform APIs in simul/test (#6852) This commit adds empty implementations of `otPlatInfraIf` platform APIs under simulation. It also adds `otPlatInfraIfHasAddress()` in `test_platform`. This allows the unit tests and simulation platform builds to succeed when `OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE` is enabled. --- examples/platforms/simulation/CMakeLists.txt | 1 + examples/platforms/simulation/Makefile.am | 1 + examples/platforms/simulation/infra_if.c | 54 ++++++++++++++++++++ tests/unit/test_platform.cpp | 8 +++ 4 files changed, 64 insertions(+) create mode 100644 examples/platforms/simulation/infra_if.c diff --git a/examples/platforms/simulation/CMakeLists.txt b/examples/platforms/simulation/CMakeLists.txt index 76be2738b..74c13d0df 100644 --- a/examples/platforms/simulation/CMakeLists.txt +++ b/examples/platforms/simulation/CMakeLists.txt @@ -62,6 +62,7 @@ add_library(openthread-simulation diag.c entropy.c flash.c + infra_if.c logging.c misc.c radio.c diff --git a/examples/platforms/simulation/Makefile.am b/examples/platforms/simulation/Makefile.am index a36329b52..6a7724630 100644 --- a/examples/platforms/simulation/Makefile.am +++ b/examples/platforms/simulation/Makefile.am @@ -44,6 +44,7 @@ PLATFORM_SOURCES = \ diag.c \ entropy.c \ flash.c \ + infra_if.c \ logging.c \ misc.c \ openthread-core-simulation-config.h \ diff --git a/examples/platforms/simulation/infra_if.c b/examples/platforms/simulation/infra_if.c new file mode 100644 index 000000000..b62041b8d --- /dev/null +++ b/examples/platforms/simulation/infra_if.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2021, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "platform-simulation.h" + +#include + +#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE +bool otPlatInfraIfHasAddress(uint32_t aInfraIfIndex, const otIp6Address *aAddress) +{ + OT_UNUSED_VARIABLE(aInfraIfIndex); + OT_UNUSED_VARIABLE(aAddress); + + return false; +} + +otError otPlatInfraIfSendIcmp6Nd(uint32_t aInfraIfIndex, + const otIp6Address *aDestAddress, + const uint8_t * aBuffer, + uint16_t aBufferLength) +{ + OT_UNUSED_VARIABLE(aInfraIfIndex); + OT_UNUSED_VARIABLE(aDestAddress); + OT_UNUSED_VARIABLE(aBuffer); + OT_UNUSED_VARIABLE(aBufferLength); + + return OT_ERROR_FAILED; +} +#endif diff --git a/tests/unit/test_platform.cpp b/tests/unit/test_platform.cpp index 4e4ac209a..fb752e993 100644 --- a/tests/unit/test_platform.cpp +++ b/tests/unit/test_platform.cpp @@ -712,6 +712,14 @@ otLinkMetrics otPlatRadioGetEnhAckProbingMetrics(otInstance *aInstance, const ot #endif #if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE +bool otPlatInfraIfHasAddress(uint32_t aInfraIfIndex, const otIp6Address *aAddress) +{ + OT_UNUSED_VARIABLE(aInfraIfIndex); + OT_UNUSED_VARIABLE(aAddress); + + return false; +} + otError otPlatInfraIfSendIcmp6Nd(uint32_t aInfraIfIndex, const otIp6Address *aDestAddress, const uint8_t * aBuffer,