Imported more library files
Not compiling currently
This commit is contained in:
381
Libs/util/third_party/openthread/examples/apps/cli/cli_uart.cpp
vendored
Normal file
381
Libs/util/third_party/openthread/examples/apps/cli/cli_uart.cpp
vendored
Normal file
@@ -0,0 +1,381 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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 "openthread-core-config.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openthread-system.h>
|
||||
#include <openthread/cli.h>
|
||||
#include <openthread/logging.h>
|
||||
|
||||
#include "cli/cli_config.h"
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/debug.hpp"
|
||||
#include "utils/uart.h"
|
||||
|
||||
#if OPENTHREAD_POSIX
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE
|
||||
*
|
||||
* The size of CLI UART RX buffer in bytes.
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
#define OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE 640
|
||||
#else
|
||||
#define OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE 512
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_CLI_TX_BUFFER_SIZE
|
||||
*
|
||||
* The size of CLI message buffer in bytes.
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE
|
||||
#define OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE 1024
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_DIAG_ENABLE
|
||||
#if OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE > OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE
|
||||
#error "diag output buffer should be smaller than CLI UART tx buffer"
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE > OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE
|
||||
#error "diag command line should be smaller than CLI UART rx buffer"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH > OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE
|
||||
#error "command line should be should be smaller than CLI rx buffer"
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
kRxBufferSize = OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE,
|
||||
kTxBufferSize = OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE,
|
||||
};
|
||||
|
||||
char sRxBuffer[kRxBufferSize];
|
||||
uint16_t sRxLength;
|
||||
|
||||
char sTxBuffer[kTxBufferSize];
|
||||
uint16_t sTxHead;
|
||||
uint16_t sTxLength;
|
||||
|
||||
uint16_t sSendLength;
|
||||
|
||||
#ifdef OT_CLI_UART_LOCK_HDR_FILE
|
||||
|
||||
#include OT_CLI_UART_LOCK_HDR_FILE
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Macro to acquire an exclusive lock of uart cli output
|
||||
* Default implementation does nothing
|
||||
*/
|
||||
#ifndef OT_CLI_UART_OUTPUT_LOCK
|
||||
#define OT_CLI_UART_OUTPUT_LOCK() \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Macro to release the exclusive lock of uart cli output
|
||||
* Default implementation does nothing
|
||||
*/
|
||||
#ifndef OT_CLI_UART_OUTPUT_UNLOCK
|
||||
#define OT_CLI_UART_OUTPUT_UNLOCK() \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif // OT_CLI_UART_LOCK_HDR_FILE
|
||||
|
||||
static int Output(const char *aBuf, uint16_t aBufLength);
|
||||
static otError ProcessCommand(void);
|
||||
|
||||
static void ReceiveTask(const uint8_t *aBuf, uint16_t aBufLength)
|
||||
{
|
||||
static const char sEraseString[] = {'\b', ' ', '\b'};
|
||||
static const char CRNL[] = {'\r', '\n'};
|
||||
static uint8_t sLastChar = '\0';
|
||||
const uint8_t *end;
|
||||
|
||||
end = aBuf + aBufLength;
|
||||
|
||||
for (; aBuf < end; aBuf++)
|
||||
{
|
||||
switch (*aBuf)
|
||||
{
|
||||
case '\n':
|
||||
if (sLastChar == '\r')
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
OT_FALL_THROUGH;
|
||||
|
||||
case '\r':
|
||||
Output(CRNL, sizeof(CRNL));
|
||||
sRxBuffer[sRxLength] = '\0';
|
||||
IgnoreError(ProcessCommand());
|
||||
break;
|
||||
|
||||
#if OPENTHREAD_POSIX && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
|
||||
case 0x03: // ASCII for Ctrl-C
|
||||
kill(0, SIGINT);
|
||||
break;
|
||||
|
||||
case 0x04: // ASCII for Ctrl-D
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case '\b':
|
||||
case 127:
|
||||
if (sRxLength > 0)
|
||||
{
|
||||
Output(sEraseString, sizeof(sEraseString));
|
||||
sRxBuffer[--sRxLength] = '\0';
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if (sRxLength < kRxBufferSize - 1)
|
||||
{
|
||||
Output(reinterpret_cast<const char *>(aBuf), 1);
|
||||
sRxBuffer[sRxLength++] = static_cast<char>(*aBuf);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
sLastChar = *aBuf;
|
||||
}
|
||||
}
|
||||
|
||||
static otError ProcessCommand(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
while (sRxLength > 0 && (sRxBuffer[sRxLength - 1] == '\n' || sRxBuffer[sRxLength - 1] == '\r'))
|
||||
{
|
||||
sRxBuffer[--sRxLength] = '\0';
|
||||
}
|
||||
|
||||
otCliInputLine(sRxBuffer);
|
||||
sRxLength = 0;
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static void Send(void)
|
||||
{
|
||||
VerifyOrExit(sSendLength == 0);
|
||||
|
||||
if (sTxLength > kTxBufferSize - sTxHead)
|
||||
{
|
||||
sSendLength = kTxBufferSize - sTxHead;
|
||||
}
|
||||
else
|
||||
{
|
||||
sSendLength = sTxLength;
|
||||
}
|
||||
|
||||
if (sSendLength > 0)
|
||||
{
|
||||
#if OPENTHREAD_CONFIG_ENABLE_DEBUG_UART
|
||||
/* duplicate the output to the debug uart */
|
||||
otSysDebugUart_write_bytes(reinterpret_cast<uint8_t *>(sTxBuffer + sTxHead), sSendLength);
|
||||
#endif
|
||||
IgnoreError(otPlatUartSend(reinterpret_cast<uint8_t *>(sTxBuffer + sTxHead), sSendLength));
|
||||
}
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
static void SendDoneTask(void)
|
||||
{
|
||||
sTxHead = (sTxHead + sSendLength) % kTxBufferSize;
|
||||
sTxLength -= sSendLength;
|
||||
sSendLength = 0;
|
||||
|
||||
Send();
|
||||
}
|
||||
|
||||
static int Output(const char *aBuf, uint16_t aBufLength)
|
||||
{
|
||||
OT_CLI_UART_OUTPUT_LOCK();
|
||||
uint16_t sent = 0;
|
||||
|
||||
while (aBufLength > 0)
|
||||
{
|
||||
uint16_t remaining = kTxBufferSize - sTxLength;
|
||||
uint16_t tail;
|
||||
uint16_t sendLength = aBufLength;
|
||||
|
||||
if (sendLength > remaining)
|
||||
{
|
||||
sendLength = remaining;
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < sendLength; i++)
|
||||
{
|
||||
tail = (sTxHead + sTxLength) % kTxBufferSize;
|
||||
sTxBuffer[tail] = *aBuf++;
|
||||
aBufLength--;
|
||||
sTxLength++;
|
||||
}
|
||||
|
||||
Send();
|
||||
|
||||
sent += sendLength;
|
||||
|
||||
if (aBufLength > 0)
|
||||
{
|
||||
// More to send, so flush what's waiting now
|
||||
otError err = otPlatUartFlush();
|
||||
|
||||
if (err == OT_ERROR_NONE)
|
||||
{
|
||||
// Flush successful, reset the pointers
|
||||
SendDoneTask();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Flush did not succeed, so abort here.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OT_CLI_UART_OUTPUT_UNLOCK();
|
||||
|
||||
return sent;
|
||||
}
|
||||
|
||||
static int CliUartOutput(void *aContext, const char *aFormat, va_list aArguments)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aContext);
|
||||
|
||||
int rval;
|
||||
|
||||
if (sTxLength == 0)
|
||||
{
|
||||
rval = vsnprintf(sTxBuffer, kTxBufferSize, aFormat, aArguments);
|
||||
VerifyOrExit(rval >= 0 && rval < kTxBufferSize, otLogWarnPlat("Failed to format CLI output `%s`", aFormat));
|
||||
sTxHead = 0;
|
||||
sTxLength = static_cast<uint16_t>(rval);
|
||||
sSendLength = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
va_list retryArguments;
|
||||
uint16_t tail = (sTxHead + sTxLength) % kTxBufferSize;
|
||||
uint16_t remaining = (sTxHead > tail ? (sTxHead - tail) : (kTxBufferSize - tail));
|
||||
|
||||
va_copy(retryArguments, aArguments);
|
||||
|
||||
rval = vsnprintf(&sTxBuffer[tail], remaining, aFormat, aArguments);
|
||||
|
||||
if (rval < 0)
|
||||
{
|
||||
otLogWarnPlat("Failed to format CLI output `%s`", aFormat);
|
||||
}
|
||||
else if (rval < remaining)
|
||||
{
|
||||
sTxLength += rval;
|
||||
}
|
||||
else if (rval < kTxBufferSize)
|
||||
{
|
||||
while (sTxLength != 0)
|
||||
{
|
||||
otError error;
|
||||
|
||||
Send();
|
||||
|
||||
error = otPlatUartFlush();
|
||||
|
||||
if (error == OT_ERROR_NONE)
|
||||
{
|
||||
// Flush successful, reset the pointers
|
||||
SendDoneTask();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Flush did not succeed, so abandon buffered output.
|
||||
otLogWarnPlat("Failed to output CLI: %s", otThreadErrorToString(error));
|
||||
break;
|
||||
}
|
||||
}
|
||||
rval = vsnprintf(sTxBuffer, kTxBufferSize, aFormat, retryArguments);
|
||||
OT_ASSERT(rval > 0);
|
||||
sTxLength = static_cast<uint16_t>(rval);
|
||||
sTxHead = 0;
|
||||
sSendLength = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
otLogWarnPlat("CLI output `%s` truncated", aFormat);
|
||||
}
|
||||
|
||||
va_end(retryArguments);
|
||||
}
|
||||
|
||||
Send();
|
||||
|
||||
exit:
|
||||
return rval;
|
||||
}
|
||||
|
||||
void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength) { ReceiveTask(aBuf, aBufLength); }
|
||||
|
||||
void otPlatUartSendDone(void) { SendDoneTask(); }
|
||||
|
||||
extern "C" void otAppCliInit(otInstance *aInstance)
|
||||
{
|
||||
sRxLength = 0;
|
||||
sTxHead = 0;
|
||||
sTxLength = 0;
|
||||
sSendLength = 0;
|
||||
|
||||
IgnoreError(otPlatUartEnable());
|
||||
|
||||
otCliInit(aInstance, CliUartOutput, aInstance);
|
||||
}
|
||||
95
Libs/util/third_party/openthread/examples/platforms/openthread-system.h
vendored
Normal file
95
Libs/util/third_party/openthread/examples/platforms/openthread-system.h
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the platform-specific functions needed by OpenThread's example applications.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_SYSTEM_H_
|
||||
#define OPENTHREAD_SYSTEM_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Performs all platform-specific initialization of OpenThread's drivers.
|
||||
*
|
||||
* @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function
|
||||
* when initialization of OpenThread's drivers is most appropriate.
|
||||
*
|
||||
* @param[in] argc Number of arguments in @p argv.
|
||||
* @param[in] argv Argument vector.
|
||||
*/
|
||||
void otSysInit(int argc, char *argv[]);
|
||||
|
||||
/**
|
||||
* Performs all platform-specific deinitialization for OpenThread's drivers.
|
||||
*
|
||||
* @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function
|
||||
* when deinitialization of OpenThread's drivers is most appropriate.
|
||||
*/
|
||||
void otSysDeinit(void);
|
||||
|
||||
/**
|
||||
* Returns true if a pseudo-reset was requested.
|
||||
*
|
||||
* In such a case, the main loop should shut down and re-initialize the OpenThread instance.
|
||||
*
|
||||
* @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function
|
||||
* in the main loop to determine when to shut down and re-initialize the OpenThread instance.
|
||||
*/
|
||||
bool otSysPseudoResetWasRequested(void);
|
||||
|
||||
/**
|
||||
* Performs all platform-specific processing for OpenThread's example applications.
|
||||
*
|
||||
* @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function
|
||||
* in the main loop when processing OpenThread's drivers is most appropriate.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
void otSysProcessDrivers(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Is called whenever platform drivers needs processing.
|
||||
*
|
||||
* @note This function is not handled by the OpenThread library. Instead, the system/RTOS should handle this function
|
||||
* and schedule a call to `otSysProcessDrivers()`.
|
||||
*/
|
||||
extern void otSysEventSignalPending(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_SYSTEM_H_
|
||||
81
Libs/util/third_party/openthread/examples/platforms/utils/code_utils.h
vendored
Normal file
81
Libs/util/third_party/openthread/examples/platforms/utils/code_utils.h
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file includes macros for validating runtime conditions.
|
||||
*/
|
||||
|
||||
#ifndef CODE_UTILS_H
|
||||
#define CODE_UTILS_H
|
||||
|
||||
/**
|
||||
* This checks for the specified condition, which is expected to
|
||||
* commonly be true, and branches to the local label 'exit' if the
|
||||
* condition is false.
|
||||
*
|
||||
* @param[in] aCondition A Boolean expression to be evaluated.
|
||||
*/
|
||||
#define otEXPECT(aCondition) \
|
||||
do \
|
||||
{ \
|
||||
if (!(aCondition)) \
|
||||
{ \
|
||||
goto exit; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* This checks for the specified condition, which is expected to
|
||||
* commonly be true, and both executes @p anAction and branches to
|
||||
* the local label 'exit' if the condition is false.
|
||||
*
|
||||
* @param[in] aCondition A Boolean expression to be evaluated.
|
||||
* @param[in] aAction An expression or block to execute when the
|
||||
* assertion fails.
|
||||
*/
|
||||
#define otEXPECT_ACTION(aCondition, aAction) \
|
||||
do \
|
||||
{ \
|
||||
if (!(aCondition)) \
|
||||
{ \
|
||||
aAction; \
|
||||
goto exit; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Calculates the number of elements in an array.
|
||||
*
|
||||
* @param[in] aArray Name of the array variable.
|
||||
*
|
||||
* @returns Number of elements in the array.
|
||||
*/
|
||||
#define otARRAY_LENGTH(aArray) (sizeof(aArray) / sizeof(aArray[0]))
|
||||
|
||||
#endif // CODE_UTILS_H
|
||||
140
Libs/util/third_party/openthread/examples/platforms/utils/debug_uart.c
vendored
Normal file
140
Libs/util/third_party/openthread/examples/platforms/utils/debug_uart.c
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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 <openthread-core-config.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/debug_uart.h>
|
||||
#include <openthread/platform/toolchain.h>
|
||||
|
||||
/*
|
||||
* Implementation note:
|
||||
* These are all "weak" so that a platform may if it chooses override the instance.
|
||||
*/
|
||||
|
||||
OT_TOOL_WEAK
|
||||
void otPlatDebugUart_printf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
otPlatDebugUart_vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK
|
||||
void otPlatDebugUart_vprintf(const char *fmt, va_list ap)
|
||||
{
|
||||
char buf[128];
|
||||
/* by standard ...
|
||||
* vsnprintf() always null terminates
|
||||
*/
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
/* however ... some platforms have bugs */
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
otPlatDebugUart_puts_no_nl(buf);
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK
|
||||
void otPlatDebugUart_write_bytes(const uint8_t *pBytes, int nBytes)
|
||||
{
|
||||
while (nBytes > 0)
|
||||
{
|
||||
otPlatDebugUart_putchar((int)(*pBytes));
|
||||
pBytes++;
|
||||
nBytes--;
|
||||
}
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK
|
||||
void otPlatDebugUart_puts_no_nl(const char *s)
|
||||
{
|
||||
while (*s)
|
||||
{
|
||||
otPlatDebugUart_putchar(*s);
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK
|
||||
void otPlatDebugUart_puts(const char *s)
|
||||
{
|
||||
otPlatDebugUart_puts_no_nl(s);
|
||||
otPlatDebugUart_putchar('\n');
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK
|
||||
void otPlatDebugUart_putchar(int c)
|
||||
{
|
||||
/* map lf to crlf as needed */
|
||||
if (c == '\n')
|
||||
{
|
||||
otPlatDebugUart_putchar_raw('\r');
|
||||
}
|
||||
|
||||
otPlatDebugUart_putchar_raw(c);
|
||||
}
|
||||
|
||||
/* provide WEAK stubs for platforms that do not implement all functions */
|
||||
OT_TOOL_WEAK
|
||||
void otPlatDebugUart_putchar_raw(int c) { OT_UNUSED_VARIABLE(c); }
|
||||
|
||||
OT_TOOL_WEAK
|
||||
int otPlatDebugUart_kbhit(void) { return 0; /* nothing */ }
|
||||
|
||||
OT_TOOL_WEAK
|
||||
int otPlatDebugUart_getc(void) { return -1; /* nothing */ }
|
||||
|
||||
OT_TOOL_WEAK
|
||||
otError otPlatDebugUart_logfile(const char *filename)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(filename);
|
||||
|
||||
return OT_ERROR_FAILED;
|
||||
}
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART)
|
||||
/* this should not be a WEAK function */
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aLogLevel);
|
||||
OT_UNUSED_VARIABLE(aLogRegion);
|
||||
|
||||
va_list ap;
|
||||
uint32_t now;
|
||||
|
||||
now = otPlatAlarmMilliGetNow();
|
||||
otPlatDebugUart_printf("%3d.%03d | ", (int)(now / 1000), (int)(now % 1000));
|
||||
va_start(ap, aFormat);
|
||||
otPlatDebugUart_vprintf(aFormat, ap);
|
||||
va_end(ap);
|
||||
|
||||
otPlatDebugUart_putchar('\n');
|
||||
}
|
||||
#endif
|
||||
265
Libs/util/third_party/openthread/examples/platforms/utils/link_metrics.cpp
vendored
Normal file
265
Libs/util/third_party/openthread/examples/platforms/utils/link_metrics.cpp
vendored
Normal file
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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 "link_metrics.h"
|
||||
|
||||
#include <openthread/link_metrics.h>
|
||||
|
||||
#include "common/clearable.hpp"
|
||||
#include "common/linked_list.hpp"
|
||||
#include "common/pool.hpp"
|
||||
#include "thread/link_quality.hpp"
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE || OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
|
||||
|
||||
using namespace ot;
|
||||
|
||||
static int8_t sNoiseFloor; ///< The noise floor used by Link Metrics. It should be set to the platform's
|
||||
///< noise floor (measured noise floor, receiver sensitivity or a constant).
|
||||
|
||||
class LinkMetricsDataInfo : public LinkedListEntry<LinkMetricsDataInfo>, public Clearable<LinkMetricsDataInfo>
|
||||
{
|
||||
friend class LinkedList<LinkMetricsDataInfo>;
|
||||
friend class LinkedListEntry<LinkMetricsDataInfo>;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
LinkMetricsDataInfo(void) { Clear(); };
|
||||
|
||||
/**
|
||||
* Set the information for this object.
|
||||
*
|
||||
* @param[in] aLinkMetrics Flags specifying what metrics to query.
|
||||
* @param[in] aShortAddress Short Address of the Probing Initiator tracked by this object.
|
||||
* @param[in] aExtAddress A reference to the Extended Address of the Probing Initiator tracked by this
|
||||
* object.
|
||||
*/
|
||||
void Set(otLinkMetrics aLinkMetrics, otShortAddress aShortAddress, const otExtAddress &aExtAddress)
|
||||
{
|
||||
mLinkMetrics = aLinkMetrics;
|
||||
mShortAddress = aShortAddress;
|
||||
memcpy(mExtAddress.m8, aExtAddress.m8, sizeof(aExtAddress));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Link Metrics data stored in this object.
|
||||
*
|
||||
* TODO: Currently the order of Link Metircs data is fixed. Will update it to follow the order specified in TLV.
|
||||
*
|
||||
* @param[in] aLqi LQI value of the acknowledeged frame.
|
||||
* @param[in] aRssi RSSI value of the acknowledged frame.
|
||||
* @param[out] aData A pointer to the output buffer. @p aData MUST NOT be `nullptr`. The buffer must have
|
||||
* at least 2 bytes (per spec 4.11.3.4.4.6). Otherwise the behavior would be undefined.
|
||||
*
|
||||
* @returns The number of bytes written. `0` on failure.
|
||||
*/
|
||||
uint8_t GetEnhAckData(uint8_t aLqi, int8_t aRssi, uint8_t *aData) const
|
||||
{
|
||||
enum
|
||||
{
|
||||
kEnhAckProbingDataMaxLen = 2,
|
||||
};
|
||||
|
||||
uint8_t bytes = 0;
|
||||
|
||||
VerifyOrExit(aData != nullptr);
|
||||
|
||||
if (mLinkMetrics.mLqi)
|
||||
{
|
||||
aData[bytes++] = aLqi;
|
||||
}
|
||||
if (mLinkMetrics.mLinkMargin)
|
||||
{
|
||||
aData[bytes++] = static_cast<uint8_t>(GetLinkMargin(aRssi) * 255 /
|
||||
130); // Linear scale Link Margin from [0, 130] to [0, 255]
|
||||
}
|
||||
if (bytes < kEnhAckProbingDataMaxLen && mLinkMetrics.mRssi)
|
||||
{
|
||||
aData[bytes++] =
|
||||
static_cast<uint8_t>((aRssi + 130) * 255 / 130); // Linear scale RSSI from [-130, 0] to [0, 255]
|
||||
}
|
||||
|
||||
exit:
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the length of Link Metrics Data.
|
||||
*
|
||||
* @returns The number of bytes for the data.
|
||||
*/
|
||||
uint8_t GetEnhAckDataLen() const
|
||||
{
|
||||
return static_cast<uint8_t>(mLinkMetrics.mLqi) + static_cast<uint8_t>(mLinkMetrics.mLinkMargin) +
|
||||
static_cast<uint8_t>(mLinkMetrics.mRssi);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the metrics configured for the Enhanced-ACK Based Probing.
|
||||
*
|
||||
* @returns The metrics configured.
|
||||
*/
|
||||
otLinkMetrics GetLinkMetrics(void) const { return mLinkMetrics; }
|
||||
|
||||
private:
|
||||
uint8_t GetLinkMargin(int8_t aRssi) const { return ComputeLinkMargin(sNoiseFloor, aRssi); }
|
||||
|
||||
bool Matches(const otShortAddress &aShortAddress) const { return mShortAddress == aShortAddress; };
|
||||
|
||||
bool Matches(const otExtAddress &aExtAddress) const
|
||||
{
|
||||
return memcmp(&mExtAddress, &aExtAddress, sizeof(otExtAddress)) == 0;
|
||||
};
|
||||
|
||||
LinkMetricsDataInfo *mNext;
|
||||
|
||||
otLinkMetrics mLinkMetrics;
|
||||
|
||||
otShortAddress mShortAddress;
|
||||
otExtAddress mExtAddress;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
kMaxEnhAckProbingInitiator = OPENTHREAD_CONFIG_MLE_LINK_METRICS_MAX_SERIES_SUPPORTED,
|
||||
};
|
||||
|
||||
typedef Pool<LinkMetricsDataInfo, kMaxEnhAckProbingInitiator> LinkMetricsDataInfoPool;
|
||||
|
||||
typedef LinkedList<LinkMetricsDataInfo> LinkMetricsDataInfoList;
|
||||
|
||||
static LinkMetricsDataInfoPool &GetLinkMetricsDataInfoPool(void)
|
||||
{
|
||||
static LinkMetricsDataInfoPool sDataInfoPool;
|
||||
return sDataInfoPool;
|
||||
}
|
||||
|
||||
static LinkMetricsDataInfoList &GetLinkMetricsDataInfoActiveList(void)
|
||||
{
|
||||
static LinkMetricsDataInfoList sDataInfoActiveList;
|
||||
return sDataInfoActiveList;
|
||||
}
|
||||
|
||||
static inline bool IsLinkMetricsClear(otLinkMetrics aLinkMetrics)
|
||||
{
|
||||
return !aLinkMetrics.mPduCount && !aLinkMetrics.mLqi && !aLinkMetrics.mLinkMargin && !aLinkMetrics.mRssi;
|
||||
}
|
||||
|
||||
void otLinkMetricsInit(int8_t aNoiseFloor)
|
||||
{
|
||||
sNoiseFloor = aNoiseFloor;
|
||||
otLinkMetricsResetEnhAckProbing();
|
||||
}
|
||||
|
||||
otError otLinkMetricsConfigureEnhAckProbing(otShortAddress aShortAddress,
|
||||
const otExtAddress *aExtAddress,
|
||||
otLinkMetrics aLinkMetrics)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
LinkMetricsDataInfo *dataInfo = nullptr;
|
||||
|
||||
VerifyOrExit(aExtAddress != nullptr, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
if (IsLinkMetricsClear(aLinkMetrics)) ///< Remove the entry
|
||||
{
|
||||
dataInfo = GetLinkMetricsDataInfoActiveList().RemoveMatching(aShortAddress);
|
||||
VerifyOrExit(dataInfo != nullptr, error = OT_ERROR_NOT_FOUND);
|
||||
GetLinkMetricsDataInfoPool().Free(*dataInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
dataInfo = GetLinkMetricsDataInfoActiveList().FindMatching(aShortAddress);
|
||||
|
||||
if (dataInfo == nullptr)
|
||||
{
|
||||
dataInfo = GetLinkMetricsDataInfoPool().Allocate();
|
||||
VerifyOrExit(dataInfo != nullptr, error = OT_ERROR_NO_BUFS);
|
||||
dataInfo->Clear();
|
||||
GetLinkMetricsDataInfoActiveList().Push(*dataInfo);
|
||||
}
|
||||
|
||||
// Overwrite the previous configuration if it already existed.
|
||||
dataInfo->Set(aLinkMetrics, aShortAddress, *aExtAddress);
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
LinkMetricsDataInfo *GetLinkMetricsInfoByMacAddress(const otMacAddress *aMacAddress)
|
||||
{
|
||||
LinkMetricsDataInfo *dataInfo = nullptr;
|
||||
|
||||
VerifyOrExit(aMacAddress != nullptr);
|
||||
|
||||
if (aMacAddress->mType == OT_MAC_ADDRESS_TYPE_SHORT)
|
||||
{
|
||||
dataInfo = GetLinkMetricsDataInfoActiveList().FindMatching(aMacAddress->mAddress.mShortAddress);
|
||||
}
|
||||
else if (aMacAddress->mType == OT_MAC_ADDRESS_TYPE_EXTENDED)
|
||||
{
|
||||
dataInfo = GetLinkMetricsDataInfoActiveList().FindMatching(aMacAddress->mAddress.mExtAddress);
|
||||
}
|
||||
|
||||
exit:
|
||||
return dataInfo;
|
||||
}
|
||||
|
||||
uint8_t otLinkMetricsEnhAckGenData(const otMacAddress *aMacAddress, uint8_t aLqi, int8_t aRssi, uint8_t *aData)
|
||||
{
|
||||
uint8_t bytes = 0;
|
||||
LinkMetricsDataInfo *dataInfo = GetLinkMetricsInfoByMacAddress(aMacAddress);
|
||||
|
||||
VerifyOrExit(dataInfo != nullptr);
|
||||
|
||||
bytes = dataInfo->GetEnhAckData(aLqi, aRssi, aData);
|
||||
|
||||
exit:
|
||||
return bytes;
|
||||
}
|
||||
|
||||
uint8_t otLinkMetricsEnhAckGetDataLen(const otMacAddress *aMacAddress)
|
||||
{
|
||||
uint8_t len = 0;
|
||||
LinkMetricsDataInfo *dataInfo = GetLinkMetricsInfoByMacAddress(aMacAddress);
|
||||
|
||||
VerifyOrExit(dataInfo != nullptr);
|
||||
len = dataInfo->GetEnhAckDataLen();
|
||||
|
||||
exit:
|
||||
return len;
|
||||
}
|
||||
|
||||
void otLinkMetricsResetEnhAckProbing(void)
|
||||
{
|
||||
GetLinkMetricsDataInfoActiveList().Clear();
|
||||
GetLinkMetricsDataInfoPool().FreeAll();
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE || OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
|
||||
114
Libs/util/third_party/openthread/examples/platforms/utils/link_metrics.h
vendored
Normal file
114
Libs/util/third_party/openthread/examples/platforms/utils/link_metrics.h
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the link metrics interface for OpenThread platform radio drivers.
|
||||
*
|
||||
* APIs defined in this module could be used by a platform to implement Enhanced-ACK Based Probing feature
|
||||
* (Probing Subject side) in its radio driver.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_UTILS_LINK_METRICS_H
|
||||
#define OPENTHREAD_UTILS_LINK_METRICS_H
|
||||
|
||||
#include <openthread/link_metrics.h>
|
||||
|
||||
#include "mac_frame.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initializes the Link Metrics util module.
|
||||
*
|
||||
* @param[in] aNoiseFloor The noise floor used by Link Metrics. It should be set to the platform's
|
||||
* noise floor (measured noise floor, receiver sensitivity or a constant).
|
||||
*/
|
||||
void otLinkMetricsInit(int8_t aNoiseFloor);
|
||||
|
||||
/**
|
||||
* Sets/clears Enhanced-ACK Based Probing for a specific Initiator.
|
||||
*
|
||||
* Can start/stop Enhanced-ACK Based Probing for a neighbor that has the address @p aShortAddress and
|
||||
* @p aExtAddress. Once the Probing is started, the device would record the Link Metrics data of link layer frames
|
||||
* sent from that neighbor and include the data into header IE in Enhanced-ACK sent to that neighbor.
|
||||
*
|
||||
* @param[in] aShortAddress The short address of the Initiator.
|
||||
* @param[in] aExtAddress A pointer to the extended address of the Initiator.
|
||||
* @param[in] aLinkMetrics Flags specifying what metrics to query (Pdu Count would be omitted). When
|
||||
* @p aLinkMetrics is equal to `0`, this method clears the Initiator.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully configured the Enhanced-ACK Based Probing.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aExtAddress is `nullptr`.
|
||||
* @retval OT_ERROR_NOT_FOUND The Initiator indicated by @p aShortAddress is not found when trying to clear.
|
||||
* @retval OT_ERROR_NO_BUFS No more Initiator can be supported.
|
||||
*/
|
||||
otError otLinkMetricsConfigureEnhAckProbing(otShortAddress aShortAddress,
|
||||
const otExtAddress *aExtAddress,
|
||||
otLinkMetrics aLinkMetrics);
|
||||
|
||||
/**
|
||||
* Generates the Link Metrics data (assessed for the acknowledged frame) bytes that would be included in
|
||||
* Vendor-Specific IE.
|
||||
*
|
||||
* First checks what Link Metrics are specified by the Initiator indicated by @p aMacAddress. And then
|
||||
* write the values to @p aData.
|
||||
*
|
||||
* @param[in] aMacAddress The Mac address of the Initiator.
|
||||
* @param[in] aLqi LQI value of the acknowledged frame.
|
||||
* @param[in] aRssi RSSI value of the acknowledged frame.
|
||||
* @param[out] aData A pointer to the buffer where the data would be written to. The caller should make
|
||||
* sure that the size of the buffer is not less than the size of Link Metrics data
|
||||
* configured before.
|
||||
*
|
||||
* @returns The size of data read. Would be `0` if the Initiator is not found or @p aData is invalid.
|
||||
*/
|
||||
uint8_t otLinkMetricsEnhAckGenData(const otMacAddress *aMacAddress, uint8_t aLqi, int8_t aRssi, uint8_t *aData);
|
||||
|
||||
/**
|
||||
* Returns the data length of Enhanced-ACK Based Probing for a specific Initiator.
|
||||
*
|
||||
* @param[in] aMacAddress The Mac address of the Initiator.
|
||||
*
|
||||
* @returns The size of data. `0` if it's not configured for the Initiator.
|
||||
*/
|
||||
uint8_t otLinkMetricsEnhAckGetDataLen(const otMacAddress *aMacAddress);
|
||||
|
||||
/**
|
||||
* This method resets Enhanced-ACK Based Probing data.
|
||||
*/
|
||||
void otLinkMetricsResetEnhAckProbing(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_UTILS_LINK_METRICS_H
|
||||
133
Libs/util/third_party/openthread/examples/platforms/utils/logging_rtt.h
vendored
Normal file
133
Libs/util/third_party/openthread/examples/platforms/utils/logging_rtt.h
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the logging rtt interfaces and default constants used by logging_rtt.c.
|
||||
*/
|
||||
|
||||
#ifndef UTILS_LOGGING_RTT_H
|
||||
#define UTILS_LOGGING_RTT_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def LOG_RTT_BUFFER_INDEX
|
||||
*
|
||||
* RTT's buffer index.
|
||||
*/
|
||||
#ifndef LOG_RTT_BUFFER_INDEX
|
||||
#define LOG_RTT_BUFFER_INDEX 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def LOG_RTT_BUFFER_NAME
|
||||
*
|
||||
* RTT's name. Only used if LOG_RTT_BUFFER_INDEX is not 0. Otherwise,
|
||||
* the buffer name is fixed to "Terminal".
|
||||
*/
|
||||
#ifndef LOG_RTT_BUFFER_NAME
|
||||
#define LOG_RTT_BUFFER_NAME "Terminal"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def LOG_RTT_BUFFER_SIZE
|
||||
*
|
||||
* LOG RTT's buffer size. Only used if LOG_RTT_BUFFER_INDEX is not 0. To
|
||||
* configure buffer #0 size, check the BUFFER_SIZE_UP definition in
|
||||
* SEGGER_RTT_Conf.h
|
||||
*/
|
||||
#ifndef LOG_RTT_BUFFER_SIZE
|
||||
#define LOG_RTT_BUFFER_SIZE 256
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def LOG_RTT_COLOR_ENABLE
|
||||
*
|
||||
* Enable colors on RTT Viewer.
|
||||
*/
|
||||
#ifndef LOG_RTT_COLOR_ENABLE
|
||||
#define LOG_RTT_COLOR_ENABLE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def LOG_PARSE_BUFFER_SIZE
|
||||
*
|
||||
* LOG buffer used to parse print format. It will be locally allocated on the
|
||||
* stack.
|
||||
*/
|
||||
#ifndef LOG_PARSE_BUFFER_SIZE
|
||||
#define LOG_PARSE_BUFFER_SIZE \
|
||||
(19 /* Timestamp */ + 8 /* RTT color code */ + OPENTHREAD_CONFIG_LOG_MAX_SIZE + 1 /* \n */)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def LOG_TIMESTAMP_ENABLE
|
||||
*
|
||||
* Enable timestamp in the logs.
|
||||
*/
|
||||
#ifndef LOG_TIMESTAMP_ENABLE
|
||||
#define LOG_TIMESTAMP_ENABLE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initialization of Logger driver.
|
||||
*/
|
||||
void utilsLogRttInit(void);
|
||||
|
||||
/**
|
||||
* Deinitialization of Logger driver.
|
||||
*/
|
||||
void utilsLogRttDeinit(void);
|
||||
|
||||
/**
|
||||
* Outputs logs to SEGGER RTT.
|
||||
*
|
||||
* @param[in] aLogLevel The log level.
|
||||
* @param[in] aLogRegion The log region.
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ap va_list matching information for aFormat
|
||||
*/
|
||||
void utilsLogRttOutput(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list ap);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // UTILS_LOGGING_RTT_H
|
||||
397
Libs/util/third_party/openthread/examples/platforms/utils/mac_frame.cpp
vendored
Normal file
397
Libs/util/third_party/openthread/examples/platforms/utils/mac_frame.cpp
vendored
Normal file
@@ -0,0 +1,397 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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 "mac_frame.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#include "common/code_utils.hpp"
|
||||
#include "mac/mac_frame.hpp"
|
||||
|
||||
using namespace ot;
|
||||
|
||||
bool otMacFrameDoesAddrMatch(const otRadioFrame *aFrame,
|
||||
otPanId aPanId,
|
||||
otShortAddress aShortAddress,
|
||||
const otExtAddress *aExtAddress)
|
||||
{
|
||||
return otMacFrameDoesAddrMatchAny(aFrame, aPanId, aShortAddress, Mac::kShortAddrInvalid, aExtAddress);
|
||||
}
|
||||
|
||||
bool otMacFrameDoesAddrMatchAny(const otRadioFrame *aFrame,
|
||||
otPanId aPanId,
|
||||
otShortAddress aShortAddress,
|
||||
otShortAddress aAltShortAddress,
|
||||
const otExtAddress *aExtAddress)
|
||||
{
|
||||
const Mac::Frame &frame = *static_cast<const Mac::Frame *>(aFrame);
|
||||
bool rval = true;
|
||||
Mac::Address dst;
|
||||
Mac::PanId panid;
|
||||
|
||||
VerifyOrExit(frame.GetDstAddr(dst) == kErrorNone, rval = false);
|
||||
|
||||
switch (dst.GetType())
|
||||
{
|
||||
case Mac::Address::kTypeShort:
|
||||
VerifyOrExit(dst.GetShort() == Mac::kShortAddrBroadcast || dst.GetShort() == aShortAddress ||
|
||||
(aAltShortAddress != Mac::kShortAddrInvalid && dst.GetShort() == aAltShortAddress),
|
||||
rval = false);
|
||||
break;
|
||||
|
||||
case Mac::Address::kTypeExtended:
|
||||
VerifyOrExit(dst.GetExtended() == *static_cast<const Mac::ExtAddress *>(aExtAddress), rval = false);
|
||||
break;
|
||||
|
||||
case Mac::Address::kTypeNone:
|
||||
break;
|
||||
}
|
||||
|
||||
SuccessOrExit(frame.GetDstPanId(panid));
|
||||
VerifyOrExit(panid == Mac::kPanIdBroadcast || panid == aPanId, rval = false);
|
||||
|
||||
exit:
|
||||
return rval;
|
||||
}
|
||||
|
||||
bool otMacFrameIsAck(const otRadioFrame *aFrame)
|
||||
{
|
||||
return static_cast<const Mac::Frame *>(aFrame)->GetType() == Mac::Frame::kTypeAck;
|
||||
}
|
||||
|
||||
bool otMacFrameIsData(const otRadioFrame *aFrame)
|
||||
{
|
||||
return static_cast<const Mac::Frame *>(aFrame)->GetType() == Mac::Frame::kTypeData;
|
||||
}
|
||||
|
||||
bool otMacFrameIsCommand(const otRadioFrame *aFrame)
|
||||
{
|
||||
return static_cast<const Mac::Frame *>(aFrame)->GetType() == Mac::Frame::kTypeMacCmd;
|
||||
}
|
||||
|
||||
bool otMacFrameIsDataRequest(const otRadioFrame *aFrame)
|
||||
{
|
||||
return static_cast<const Mac::Frame *>(aFrame)->IsDataRequestCommand();
|
||||
}
|
||||
|
||||
bool otMacFrameIsAckRequested(const otRadioFrame *aFrame)
|
||||
{
|
||||
return static_cast<const Mac::Frame *>(aFrame)->GetAckRequest();
|
||||
}
|
||||
|
||||
static void GetOtMacAddress(const Mac::Address &aInAddress, otMacAddress *aOutAddress)
|
||||
{
|
||||
switch (aInAddress.GetType())
|
||||
{
|
||||
case Mac::Address::kTypeNone:
|
||||
aOutAddress->mType = OT_MAC_ADDRESS_TYPE_NONE;
|
||||
break;
|
||||
|
||||
case Mac::Address::kTypeShort:
|
||||
aOutAddress->mType = OT_MAC_ADDRESS_TYPE_SHORT;
|
||||
aOutAddress->mAddress.mShortAddress = aInAddress.GetShort();
|
||||
break;
|
||||
|
||||
case Mac::Address::kTypeExtended:
|
||||
aOutAddress->mType = OT_MAC_ADDRESS_TYPE_EXTENDED;
|
||||
aOutAddress->mAddress.mExtAddress = aInAddress.GetExtended();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
otError otMacFrameGetSrcAddr(const otRadioFrame *aFrame, otMacAddress *aMacAddress)
|
||||
{
|
||||
otError error;
|
||||
Mac::Address address;
|
||||
|
||||
error = static_cast<const Mac::Frame *>(aFrame)->GetSrcAddr(address);
|
||||
SuccessOrExit(error);
|
||||
|
||||
GetOtMacAddress(address, aMacAddress);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otMacFrameGetDstAddr(const otRadioFrame *aFrame, otMacAddress *aMacAddress)
|
||||
{
|
||||
otError error;
|
||||
Mac::Address address;
|
||||
|
||||
error = static_cast<const Mac::Frame *>(aFrame)->GetDstAddr(address);
|
||||
SuccessOrExit(error);
|
||||
|
||||
GetOtMacAddress(address, aMacAddress);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otMacFrameGetSequence(const otRadioFrame *aFrame, uint8_t *aSequence)
|
||||
{
|
||||
otError error;
|
||||
|
||||
if (static_cast<const Mac::Frame *>(aFrame)->IsSequencePresent())
|
||||
{
|
||||
*aSequence = static_cast<const Mac::Frame *>(aFrame)->GetSequence();
|
||||
error = kErrorNone;
|
||||
}
|
||||
else
|
||||
{
|
||||
error = kErrorParse;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
void otMacFrameProcessTransmitAesCcm(otRadioFrame *aFrame, const otExtAddress *aExtAddress)
|
||||
{
|
||||
static_cast<Mac::TxFrame *>(aFrame)->ProcessTransmitAesCcm(*static_cast<const Mac::ExtAddress *>(aExtAddress));
|
||||
}
|
||||
|
||||
bool otMacFrameIsVersion2015(const otRadioFrame *aFrame)
|
||||
{
|
||||
return static_cast<const Mac::Frame *>(aFrame)->IsVersion2015();
|
||||
}
|
||||
|
||||
void otMacFrameGenerateImmAck(const otRadioFrame *aFrame, bool aIsFramePending, otRadioFrame *aAckFrame)
|
||||
{
|
||||
assert(aFrame != nullptr && aAckFrame != nullptr);
|
||||
|
||||
static_cast<Mac::TxFrame *>(aAckFrame)->GenerateImmAck(*static_cast<const Mac::RxFrame *>(aFrame), aIsFramePending);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2
|
||||
otError otMacFrameGenerateEnhAck(const otRadioFrame *aFrame,
|
||||
bool aIsFramePending,
|
||||
const uint8_t *aIeData,
|
||||
uint8_t aIeLength,
|
||||
otRadioFrame *aAckFrame)
|
||||
{
|
||||
assert(aFrame != nullptr && aAckFrame != nullptr);
|
||||
|
||||
return static_cast<Mac::TxFrame *>(aAckFrame)->GenerateEnhAck(*static_cast<const Mac::RxFrame *>(aFrame),
|
||||
aIsFramePending, aIeData, aIeLength);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||
void otMacFrameSetCslIe(otRadioFrame *aFrame, uint16_t aCslPeriod, uint16_t aCslPhase)
|
||||
{
|
||||
static_cast<Mac::Frame *>(aFrame)->SetCslIe(aCslPeriod, aCslPhase);
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||
|
||||
bool otMacFrameIsSecurityEnabled(otRadioFrame *aFrame)
|
||||
{
|
||||
return static_cast<const Mac::Frame *>(aFrame)->GetSecurityEnabled();
|
||||
}
|
||||
|
||||
bool otMacFrameIsKeyIdMode1(otRadioFrame *aFrame)
|
||||
{
|
||||
uint8_t keyIdMode;
|
||||
otError error;
|
||||
|
||||
error = static_cast<const Mac::Frame *>(aFrame)->GetKeyIdMode(keyIdMode);
|
||||
|
||||
return (error == OT_ERROR_NONE) ? (keyIdMode == Mac::Frame::kKeyIdMode1) : false;
|
||||
}
|
||||
|
||||
uint8_t otMacFrameGetKeyId(otRadioFrame *aFrame)
|
||||
{
|
||||
uint8_t keyId = 0;
|
||||
|
||||
IgnoreError(static_cast<const Mac::Frame *>(aFrame)->GetKeyId(keyId));
|
||||
|
||||
return keyId;
|
||||
}
|
||||
|
||||
void otMacFrameSetKeyId(otRadioFrame *aFrame, uint8_t aKeyId) { static_cast<Mac::Frame *>(aFrame)->SetKeyId(aKeyId); }
|
||||
|
||||
uint32_t otMacFrameGetFrameCounter(otRadioFrame *aFrame)
|
||||
{
|
||||
uint32_t frameCounter = UINT32_MAX;
|
||||
|
||||
IgnoreError(static_cast<Mac::Frame *>(aFrame)->GetFrameCounter(frameCounter));
|
||||
|
||||
return frameCounter;
|
||||
}
|
||||
|
||||
void otMacFrameSetFrameCounter(otRadioFrame *aFrame, uint32_t aFrameCounter)
|
||||
{
|
||||
static_cast<Mac::Frame *>(aFrame)->SetFrameCounter(aFrameCounter);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||
uint8_t otMacFrameGenerateCslIeTemplate(uint8_t *aDest)
|
||||
{
|
||||
assert(aDest != nullptr);
|
||||
|
||||
reinterpret_cast<Mac::HeaderIe *>(aDest)->SetId(Mac::CslIe::kHeaderIeId);
|
||||
reinterpret_cast<Mac::HeaderIe *>(aDest)->SetLength(sizeof(Mac::CslIe));
|
||||
|
||||
return sizeof(Mac::HeaderIe) + sizeof(Mac::CslIe);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
|
||||
uint8_t otMacFrameGenerateEnhAckProbingIe(uint8_t *aDest, const uint8_t *aIeData, uint8_t aIeDataLength)
|
||||
{
|
||||
uint8_t len = sizeof(Mac::VendorIeHeader) + aIeDataLength;
|
||||
|
||||
assert(aDest != nullptr);
|
||||
|
||||
reinterpret_cast<Mac::HeaderIe *>(aDest)->SetId(Mac::ThreadIe::kHeaderIeId);
|
||||
reinterpret_cast<Mac::HeaderIe *>(aDest)->SetLength(len);
|
||||
|
||||
aDest += sizeof(Mac::HeaderIe);
|
||||
|
||||
reinterpret_cast<Mac::VendorIeHeader *>(aDest)->SetVendorOui(Mac::ThreadIe::kVendorOuiThreadCompanyId);
|
||||
reinterpret_cast<Mac::VendorIeHeader *>(aDest)->SetSubType(Mac::ThreadIe::kEnhAckProbingIe);
|
||||
|
||||
if (aIeData != nullptr)
|
||||
{
|
||||
aDest += sizeof(Mac::VendorIeHeader);
|
||||
memcpy(aDest, aIeData, aIeDataLength);
|
||||
}
|
||||
|
||||
return sizeof(Mac::HeaderIe) + len;
|
||||
}
|
||||
|
||||
void otMacFrameSetEnhAckProbingIe(otRadioFrame *aFrame, const uint8_t *aData, uint8_t aDataLen)
|
||||
{
|
||||
assert(aFrame != nullptr && aData != nullptr);
|
||||
|
||||
reinterpret_cast<Mac::Frame *>(aFrame)->SetEnhAckProbingIe(aData, aDataLen);
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
|
||||
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||
static uint16_t ComputeCslPhase(uint32_t aRadioTime, otRadioContext *aRadioContext)
|
||||
{
|
||||
return (aRadioContext->mCslSampleTime - aRadioTime) % (aRadioContext->mCslPeriod * OT_US_PER_TEN_SYMBOLS) /
|
||||
OT_US_PER_TEN_SYMBOLS;
|
||||
}
|
||||
#endif
|
||||
otError otMacFrameProcessTransmitSecurity(otRadioFrame *aFrame, otRadioContext *aRadioContext)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
#if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2
|
||||
otMacKeyMaterial *key = nullptr;
|
||||
uint8_t keyId;
|
||||
uint32_t frameCounter;
|
||||
|
||||
VerifyOrExit(otMacFrameIsSecurityEnabled(aFrame) && otMacFrameIsKeyIdMode1(aFrame) &&
|
||||
!aFrame->mInfo.mTxInfo.mIsSecurityProcessed);
|
||||
|
||||
if (otMacFrameIsAck(aFrame))
|
||||
{
|
||||
keyId = otMacFrameGetKeyId(aFrame);
|
||||
|
||||
VerifyOrExit(keyId != 0, error = OT_ERROR_FAILED);
|
||||
|
||||
if (keyId == aRadioContext->mKeyId)
|
||||
{
|
||||
key = &aRadioContext->mCurrKey;
|
||||
frameCounter = aRadioContext->mMacFrameCounter++;
|
||||
}
|
||||
else if (keyId == aRadioContext->mKeyId - 1)
|
||||
{
|
||||
key = &aRadioContext->mPrevKey;
|
||||
frameCounter = aRadioContext->mPrevMacFrameCounter++;
|
||||
}
|
||||
else if (keyId == aRadioContext->mKeyId + 1)
|
||||
{
|
||||
key = &aRadioContext->mNextKey;
|
||||
frameCounter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ExitNow(error = OT_ERROR_SECURITY);
|
||||
}
|
||||
}
|
||||
else if (!aFrame->mInfo.mTxInfo.mIsHeaderUpdated)
|
||||
{
|
||||
key = &aRadioContext->mCurrKey;
|
||||
keyId = aRadioContext->mKeyId;
|
||||
frameCounter = aRadioContext->mMacFrameCounter++;
|
||||
}
|
||||
|
||||
if (key != nullptr)
|
||||
{
|
||||
aFrame->mInfo.mTxInfo.mAesKey = key;
|
||||
|
||||
otMacFrameSetKeyId(aFrame, keyId);
|
||||
otMacFrameSetFrameCounter(aFrame, frameCounter);
|
||||
aFrame->mInfo.mTxInfo.mIsHeaderUpdated = true;
|
||||
}
|
||||
#else
|
||||
VerifyOrExit(!aFrame->mInfo.mTxInfo.mIsSecurityProcessed);
|
||||
#endif // OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2
|
||||
|
||||
otMacFrameProcessTransmitAesCcm(aFrame, &aRadioContext->mExtAddress);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
void otMacFrameUpdateTimeIe(otRadioFrame *aFrame, uint64_t aRadioTime, otRadioContext *aRadioContext)
|
||||
{
|
||||
if (aFrame->mInfo.mTxInfo.mIeInfo->mTimeIeOffset != 0)
|
||||
{
|
||||
uint8_t *timeIe = aFrame->mPsdu + aFrame->mInfo.mTxInfo.mIeInfo->mTimeIeOffset;
|
||||
uint64_t time = aRadioTime + aFrame->mInfo.mTxInfo.mIeInfo->mNetworkTimeOffset;
|
||||
|
||||
*timeIe = aFrame->mInfo.mTxInfo.mIeInfo->mTimeSyncSeq;
|
||||
|
||||
*(++timeIe) = static_cast<uint8_t>(time & 0xff);
|
||||
for (uint8_t i = 1; i < sizeof(uint64_t); i++)
|
||||
{
|
||||
time = time >> 8;
|
||||
*(++timeIe) = static_cast<uint8_t>(time & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
|
||||
otError otMacFrameProcessTxSfd(otRadioFrame *aFrame, uint64_t aRadioTime, otRadioContext *aRadioContext)
|
||||
{
|
||||
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||
if (aRadioContext->mCslPeriod > 0) // CSL IE should be filled for every transmit attempt
|
||||
{
|
||||
otMacFrameSetCslIe(aFrame, aRadioContext->mCslPeriod, ComputeCslPhase(aRadioTime, aRadioContext));
|
||||
}
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
otMacFrameUpdateTimeIe(aFrame, aRadioTime, aRadioContext);
|
||||
#endif
|
||||
aFrame->mInfo.mTxInfo.mTimestamp = aRadioTime;
|
||||
return otMacFrameProcessTransmitSecurity(aFrame, aRadioContext);
|
||||
}
|
||||
383
Libs/util/third_party/openthread/examples/platforms/utils/mac_frame.h
vendored
Normal file
383
Libs/util/third_party/openthread/examples/platforms/utils/mac_frame.h
vendored
Normal file
@@ -0,0 +1,383 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the mac frame interface for OpenThread platform radio drivers.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_UTILS_MAC_FRAME_H
|
||||
#define OPENTHREAD_UTILS_MAC_FRAME_H
|
||||
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Specifies the IEEE 802.15.4 Address type.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_MAC_ADDRESS_TYPE_NONE, ///< No address.
|
||||
OT_MAC_ADDRESS_TYPE_SHORT, ///< IEEE 802.15.4 Short Address.
|
||||
OT_MAC_ADDRESS_TYPE_EXTENDED, ///< IEEE 802.15.4 Extended Address.
|
||||
} otMacAddressType;
|
||||
|
||||
/**
|
||||
* Represents an IEEE 802.15.4 short or extended Address.
|
||||
*/
|
||||
typedef struct otMacAddress
|
||||
{
|
||||
union
|
||||
{
|
||||
otShortAddress mShortAddress; ///< The IEEE 802.15.4 Short Address.
|
||||
otExtAddress mExtAddress; ///< The IEEE 802.15.4 Extended Address.
|
||||
} mAddress;
|
||||
|
||||
otMacAddressType mType; ///< The address type (short, extended, or none).
|
||||
} otMacAddress;
|
||||
|
||||
/**
|
||||
* Check if @p aFrame is an Ack frame.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
*
|
||||
* @retval true It is an ACK frame.
|
||||
* @retval false It is not an ACK frame.
|
||||
*/
|
||||
bool otMacFrameIsAck(const otRadioFrame *aFrame);
|
||||
|
||||
/**
|
||||
* Check if @p aFrame is a Data frame.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
*
|
||||
* @retval true It is a Data frame.
|
||||
* @retval false It is not a Data frame.
|
||||
*/
|
||||
bool otMacFrameIsData(const otRadioFrame *aFrame);
|
||||
|
||||
/**
|
||||
* Check if @p aFrame is a Command frame.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
*
|
||||
* @retval true It is a Command frame.
|
||||
* @retval false It is not a Command frame.
|
||||
*/
|
||||
bool otMacFrameIsCommand(const otRadioFrame *aFrame);
|
||||
|
||||
/**
|
||||
* Check if @p aFrame is a Data Request Command.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame. For 802.15.4-2015 and above frame,
|
||||
* the frame should be already decrypted.
|
||||
*
|
||||
* @retval true It is a Data Request Command frame.
|
||||
* @retval false It is not a Data Request Command frame.
|
||||
*/
|
||||
bool otMacFrameIsDataRequest(const otRadioFrame *aFrame);
|
||||
|
||||
/**
|
||||
* Check if @p aFrame requests ACK.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
*
|
||||
* @retval true It requests ACK.
|
||||
* @retval false It does not request ACK.
|
||||
*/
|
||||
bool otMacFrameIsAckRequested(const otRadioFrame *aFrame);
|
||||
|
||||
/**
|
||||
* Check if @p aFrame matches the @p aPandId and @p aShortAddress or @p aExtAddress.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
* @param[in] aPanId The PAN id to match with.
|
||||
* @param[in] aShortAddress The short address to match with.
|
||||
* @param[in] aExtAddress The extended address to match with.
|
||||
*
|
||||
* @retval true It is a broadcast or matches with the PAN id and one of the addresses.
|
||||
* @retval false It doesn't match.
|
||||
*/
|
||||
bool otMacFrameDoesAddrMatch(const otRadioFrame *aFrame,
|
||||
otPanId aPanId,
|
||||
otShortAddress aShortAddress,
|
||||
const otExtAddress *aExtAddress);
|
||||
|
||||
/**
|
||||
* Check if @p aFrame matches the @p aPandId and @p aShortAddress, or @p aAltShortAddress or @p aExtAddress.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
* @param[in] aPanId The PAN id to match with.
|
||||
* @param[in] aShortAddress The short address to match with.
|
||||
* @param[in] aAltShortAddress The alternate short address to match with. Can be `OT_RADIO_INVALID_SHORT_ADDR` if
|
||||
* there is no alternate address.
|
||||
* @param[in] aExtAddress The extended address to match with.
|
||||
*
|
||||
* @retval true It is a broadcast or matches with the PAN id and one of the addresses.
|
||||
* @retval false It doesn't match.
|
||||
*/
|
||||
bool otMacFrameDoesAddrMatchAny(const otRadioFrame *aFrame,
|
||||
otPanId aPanId,
|
||||
otShortAddress aShortAddress,
|
||||
otShortAddress aAltShortAddress,
|
||||
const otExtAddress *aExtAddress);
|
||||
|
||||
/**
|
||||
* Get source MAC address.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
* @param[out] aMacAddress A pointer to MAC address.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully got the source MAC address.
|
||||
* @retval OT_ERROR_PARSE Failed to parse the source MAC address.
|
||||
*/
|
||||
otError otMacFrameGetSrcAddr(const otRadioFrame *aFrame, otMacAddress *aMacAddress);
|
||||
|
||||
/**
|
||||
* Get destination MAC address.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
* @param[out] aMacAddress A pointer to MAC address.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully got the destination MAC address.
|
||||
* @retval OT_ERROR_PARSE Failed to parse the destination MAC address.
|
||||
*/
|
||||
otError otMacFrameGetDstAddr(const otRadioFrame *aFrame, otMacAddress *aMacAddress);
|
||||
|
||||
/**
|
||||
* Get the sequence of @p aFrame.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
* @param[out] aSequence A pointer to the sequence.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully got the sequence.
|
||||
* @retval OT_ERROR_PARSE Failed to parse the sequence.
|
||||
*/
|
||||
otError otMacFrameGetSequence(const otRadioFrame *aFrame, uint8_t *aSequence);
|
||||
|
||||
/**
|
||||
* Performs AES CCM on the frame which is going to be sent.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the MAC frame buffer that is going to be sent.
|
||||
* @param[in] aExtAddress A pointer to the extended address, which will be used to generate nonce
|
||||
* for AES CCM computation.
|
||||
*/
|
||||
void otMacFrameProcessTransmitAesCcm(otRadioFrame *aFrame, const otExtAddress *aExtAddress);
|
||||
|
||||
/**
|
||||
* Tell if the version of @p aFrame is 2015.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
*
|
||||
* @retval true It is a version 2015 frame.
|
||||
* @retval false It is not a version 2015 frame.
|
||||
*/
|
||||
bool otMacFrameIsVersion2015(const otRadioFrame *aFrame);
|
||||
|
||||
/**
|
||||
* Generate Imm-Ack for @p aFrame.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
* @param[in] aIsFramePending Value of the ACK's frame pending bit.
|
||||
* @param[out] aAckFrame A pointer to the ack frame to be generated.
|
||||
*/
|
||||
void otMacFrameGenerateImmAck(const otRadioFrame *aFrame, bool aIsFramePending, otRadioFrame *aAckFrame);
|
||||
|
||||
/**
|
||||
* Generate Enh-Ack for @p aFrame.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
* @param[in] aIsFramePending Value of the ACK's frame pending bit.
|
||||
* @param[in] aIeData A pointer to the IE data portion of the ACK to be sent.
|
||||
* @param[in] aIeLength The length of IE data portion of the ACK to be sent.
|
||||
* @param[out] aAckFrame A pointer to the ack frame to be generated.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully generated Enh Ack in @p aAckFrame.
|
||||
* @retval OT_ERROR_PARSE @p aFrame has incorrect format.
|
||||
*/
|
||||
otError otMacFrameGenerateEnhAck(const otRadioFrame *aFrame,
|
||||
bool aIsFramePending,
|
||||
const uint8_t *aIeData,
|
||||
uint8_t aIeLength,
|
||||
otRadioFrame *aAckFrame);
|
||||
|
||||
/**
|
||||
* Set CSL IE content into the frame.
|
||||
*
|
||||
* @param[in,out] aFrame A pointer to the frame to be modified.
|
||||
* @param[in] aCslPeriod CSL Period in CSL IE.
|
||||
* @param[in] aCslPhase CSL Phase in CSL IE.
|
||||
*/
|
||||
void otMacFrameSetCslIe(otRadioFrame *aFrame, uint16_t aCslPeriod, uint16_t aCslPhase);
|
||||
|
||||
/**
|
||||
* Tell if the security of @p aFrame is enabled.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
*
|
||||
* @retval true The frame has security enabled.
|
||||
* @retval false The frame does not have security enabled.
|
||||
*/
|
||||
bool otMacFrameIsSecurityEnabled(otRadioFrame *aFrame);
|
||||
|
||||
/**
|
||||
* Tell if the key ID mode of @p aFrame is 1.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
*
|
||||
* @retval true The frame key ID mode is 1.
|
||||
* @retval false The frame security is not enabled or key ID mode is not 1.
|
||||
*/
|
||||
bool otMacFrameIsKeyIdMode1(otRadioFrame *aFrame);
|
||||
|
||||
/**
|
||||
* Get the key ID of @p aFrame.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
*
|
||||
* @returns The key ID of the frame with key ID mode 1. Returns 0 if failed.
|
||||
*/
|
||||
uint8_t otMacFrameGetKeyId(otRadioFrame *aFrame);
|
||||
|
||||
/**
|
||||
* Set key ID to @p aFrame with key ID mode 1.
|
||||
*
|
||||
* @param[in,out] aFrame A pointer to the frame to be modified.
|
||||
* @param[in] aKeyId Key ID to be set to the frame.
|
||||
*/
|
||||
void otMacFrameSetKeyId(otRadioFrame *aFrame, uint8_t aKeyId);
|
||||
|
||||
/**
|
||||
* Get the frame counter of @p aFrame.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
*
|
||||
* @returns The frame counter of the frame. Returns UINT32_MAX if failed.
|
||||
*/
|
||||
uint32_t otMacFrameGetFrameCounter(otRadioFrame *aFrame);
|
||||
|
||||
/**
|
||||
* Set frame counter to @p aFrame.
|
||||
*
|
||||
* @param[in,out] aFrame A pointer to the frame to be modified.
|
||||
* @param[in] aFrameCounter Frame counter to be set to the frame.
|
||||
*/
|
||||
void otMacFrameSetFrameCounter(otRadioFrame *aFrame, uint32_t aFrameCounter);
|
||||
|
||||
/**
|
||||
* Write CSL IE to a buffer (without setting IE value).
|
||||
*
|
||||
* @param[out] aDest A pointer to the output buffer.
|
||||
*
|
||||
* @returns The total count of bytes (total length of CSL IE) written to the buffer.
|
||||
*/
|
||||
uint8_t otMacFrameGenerateCslIeTemplate(uint8_t *aDest);
|
||||
|
||||
/**
|
||||
* Write Enh-ACK Probing IE (Vendor IE with THREAD OUI) to a buffer.
|
||||
*
|
||||
* @p aIeData could be `NULL`. If @p aIeData is `NULL`, this method generates the IE with the data unset. This allows
|
||||
* users to generate the pattern first and update value later. (For example, using `otMacFrameSetEnhAckProbingIe`)
|
||||
*
|
||||
* @param[out] aDest A pointer to the output buffer.
|
||||
* @param[in] aIeData A pointer to the Link Metrics data.
|
||||
* @param[in] aIeDataLength The length of Link Metrics data value. Should be `1` or `2`. (Per spec 4.11.3.4.4.6)
|
||||
*
|
||||
* @returns The total count of bytes (total length of the Vendor IE) written to the buffer.
|
||||
*/
|
||||
uint8_t otMacFrameGenerateEnhAckProbingIe(uint8_t *aDest, const uint8_t *aIeData, uint8_t aIeDataLength);
|
||||
|
||||
/**
|
||||
* Sets the data value of Enh-ACK Probing IE (Vendor IE with THREAD OUI) in a frame.
|
||||
*
|
||||
* If no Enh-ACK Probing IE is found in @p aFrame, nothing would be done.
|
||||
*
|
||||
* @param[in] aFrame The target frame that contains the IE. MUST NOT be `NULL`.
|
||||
* @param[in] aData A pointer to the data value. MUST NOT be `NULL`.
|
||||
* @param[in] aDataLen The length of @p aData.
|
||||
*/
|
||||
void otMacFrameSetEnhAckProbingIe(otRadioFrame *aFrame, const uint8_t *aData, uint8_t aDataLen);
|
||||
|
||||
/**
|
||||
* Represents the context for radio layer.
|
||||
*/
|
||||
typedef struct otRadioContext
|
||||
{
|
||||
otExtAddress mExtAddress; ///< In little-endian byte order.
|
||||
uint32_t mMacFrameCounter;
|
||||
uint32_t mPrevMacFrameCounter;
|
||||
uint32_t mCslSampleTime; ///< The sample time based on the microsecond timer.
|
||||
uint16_t mCslPeriod; ///< In unit of 10 symbols.
|
||||
otShortAddress mShortAddress;
|
||||
otShortAddress mAlternateShortAddress;
|
||||
otRadioKeyType mKeyType;
|
||||
uint8_t mKeyId;
|
||||
otMacKeyMaterial mPrevKey;
|
||||
otMacKeyMaterial mCurrKey;
|
||||
otMacKeyMaterial mNextKey;
|
||||
} otRadioContext;
|
||||
|
||||
/**
|
||||
* Perform processing of SFD callback from ISR.
|
||||
*
|
||||
* This function may do multiple tasks as follows.
|
||||
*
|
||||
* - CSL IE will be populated (if present)
|
||||
* - Time IE will be populated (if present)
|
||||
* - Tx timestamp will be populated
|
||||
* - Tx security will be performed (including assignment of security frame counter and key id if not assigned)
|
||||
*
|
||||
* @param[in,out] aFrame The target frame. MUST NOT be `NULL`.
|
||||
* @param[in] aRadioTime The radio time when the SFD was at the antenna.
|
||||
* @param[in,out] aRadioContext The radio context accessible in ISR.
|
||||
*
|
||||
* @returns the error processing the callback. The caller should abort transmission on failures.
|
||||
*/
|
||||
otError otMacFrameProcessTxSfd(otRadioFrame *aFrame, uint64_t aRadioTime, otRadioContext *aRadioContext);
|
||||
|
||||
/**
|
||||
* Process frame tx security.
|
||||
*
|
||||
* @param[in,out] aFrame The target frame. MUST NOT be `NULL`.
|
||||
* @param[in,out] aRadioContext The radio context accessible in ISR.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully processed security.
|
||||
* @retval OT_ERROR_FAILED Failed to processed security.
|
||||
* @retval OT_ERROR_SECURITY Failed to processed security for missing key.
|
||||
*/
|
||||
otError otMacFrameProcessTransmitSecurity(otRadioFrame *aFrame, otRadioContext *aRadioContext);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_UTILS_MAC_FRAME_H
|
||||
48
Libs/util/third_party/openthread/examples/platforms/utils/settings.h
vendored
Normal file
48
Libs/util/third_party/openthread/examples/platforms/utils/settings.h
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2020, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file defines the configuration options for platform abstraction of non-volatile storage of settings.
|
||||
*/
|
||||
|
||||
#ifndef UTILS_SETTINGS_H_
|
||||
#define UTILS_SETTINGS_H_
|
||||
|
||||
#include <openthread-core-config.h>
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_SETTINGS_RAM
|
||||
*
|
||||
* Define as 1 to enable saving the settings in RAM instead of flash.
|
||||
*/
|
||||
#ifndef OPENTHREAD_SETTINGS_RAM
|
||||
#define OPENTHREAD_SETTINGS_RAM 0
|
||||
#endif
|
||||
|
||||
#endif // UTILS_SETTINGS_H_
|
||||
230
Libs/util/third_party/openthread/examples/platforms/utils/settings_ram.c
vendored
Normal file
230
Libs/util/third_party/openthread/examples/platforms/utils/settings_ram.c
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file implements OpenThread platform abstraction for storage of settings in RAM.
|
||||
*/
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/platform/settings.h>
|
||||
|
||||
#define SETTINGS_BUFFER_SIZE 1024
|
||||
|
||||
#if OPENTHREAD_SETTINGS_RAM
|
||||
|
||||
static uint8_t sSettingsBuf[SETTINGS_BUFFER_SIZE];
|
||||
static uint16_t sSettingsBufLength;
|
||||
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct settingsBlock
|
||||
{
|
||||
uint16_t key;
|
||||
uint16_t length;
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
// settings API
|
||||
void otPlatSettingsInit(otInstance *aInstance, const uint16_t *aSensitiveKeys, uint16_t aSensitiveKeysLength)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aSensitiveKeys);
|
||||
OT_UNUSED_VARIABLE(aSensitiveKeysLength);
|
||||
|
||||
sSettingsBufLength = 0;
|
||||
}
|
||||
|
||||
void otPlatSettingsDeinit(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); }
|
||||
|
||||
otError otPlatSettingsGet(otInstance *aInstance, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
uint16_t i = 0;
|
||||
uint16_t valueLength = 0;
|
||||
uint16_t readLength;
|
||||
int currentIndex = 0;
|
||||
const struct settingsBlock *currentBlock;
|
||||
otError error = OT_ERROR_NOT_FOUND;
|
||||
|
||||
while (i < sSettingsBufLength)
|
||||
{
|
||||
currentBlock = (struct settingsBlock *)&sSettingsBuf[i];
|
||||
|
||||
if (aKey == currentBlock->key)
|
||||
{
|
||||
if (currentIndex == aIndex)
|
||||
{
|
||||
readLength = currentBlock->length;
|
||||
|
||||
// Perform read only if an input buffer was passed in
|
||||
if (aValue != NULL && aValueLength != NULL)
|
||||
{
|
||||
// Adjust read length if input buffer size is smaller
|
||||
if (readLength > *aValueLength)
|
||||
{
|
||||
readLength = *aValueLength;
|
||||
}
|
||||
|
||||
memcpy(aValue, &sSettingsBuf[i + sizeof(struct settingsBlock)], readLength);
|
||||
}
|
||||
|
||||
valueLength = currentBlock->length;
|
||||
error = OT_ERROR_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
currentIndex++;
|
||||
}
|
||||
|
||||
i += sizeof(struct settingsBlock) + currentBlock->length;
|
||||
}
|
||||
|
||||
if (aValueLength != NULL)
|
||||
{
|
||||
*aValueLength = valueLength;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatSettingsSet(otInstance *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
|
||||
{
|
||||
uint16_t i = 0;
|
||||
uint16_t currentBlockLength;
|
||||
uint16_t nextBlockStart;
|
||||
const struct settingsBlock *currentBlock;
|
||||
|
||||
// Delete all entries of aKey
|
||||
while (i < sSettingsBufLength)
|
||||
{
|
||||
currentBlock = (struct settingsBlock *)&sSettingsBuf[i];
|
||||
currentBlockLength = sizeof(struct settingsBlock) + currentBlock->length;
|
||||
|
||||
if (aKey == currentBlock->key)
|
||||
{
|
||||
nextBlockStart = i + currentBlockLength;
|
||||
|
||||
if (nextBlockStart < sSettingsBufLength)
|
||||
{
|
||||
memmove(&sSettingsBuf[i], &sSettingsBuf[nextBlockStart], sSettingsBufLength - nextBlockStart);
|
||||
}
|
||||
|
||||
assert(sSettingsBufLength >= currentBlockLength);
|
||||
sSettingsBufLength -= currentBlockLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
i += currentBlockLength;
|
||||
}
|
||||
}
|
||||
|
||||
return otPlatSettingsAdd(aInstance, aKey, aValue, aValueLength);
|
||||
}
|
||||
|
||||
otError otPlatSettingsAdd(otInstance *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otError error;
|
||||
struct settingsBlock *currentBlock;
|
||||
const uint16_t newBlockLength = sizeof(struct settingsBlock) + aValueLength;
|
||||
|
||||
if (sSettingsBufLength + newBlockLength <= sizeof(sSettingsBuf))
|
||||
{
|
||||
currentBlock = (struct settingsBlock *)&sSettingsBuf[sSettingsBufLength];
|
||||
currentBlock->key = aKey;
|
||||
currentBlock->length = aValueLength;
|
||||
|
||||
memcpy(&sSettingsBuf[sSettingsBufLength + sizeof(struct settingsBlock)], aValue, aValueLength);
|
||||
sSettingsBufLength += newBlockLength;
|
||||
|
||||
error = OT_ERROR_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
error = OT_ERROR_NO_BUFS;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatSettingsDelete(otInstance *aInstance, uint16_t aKey, int aIndex)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
uint16_t i = 0;
|
||||
int currentIndex = 0;
|
||||
uint16_t nextBlockStart;
|
||||
uint16_t currentBlockLength;
|
||||
const struct settingsBlock *currentBlock;
|
||||
otError error = OT_ERROR_NOT_FOUND;
|
||||
|
||||
while (i < sSettingsBufLength)
|
||||
{
|
||||
currentBlock = (struct settingsBlock *)&sSettingsBuf[i];
|
||||
currentBlockLength = sizeof(struct settingsBlock) + currentBlock->length;
|
||||
|
||||
if (aKey == currentBlock->key)
|
||||
{
|
||||
if (currentIndex == aIndex)
|
||||
{
|
||||
nextBlockStart = i + currentBlockLength;
|
||||
|
||||
if (nextBlockStart < sSettingsBufLength)
|
||||
{
|
||||
memmove(&sSettingsBuf[i], &sSettingsBuf[nextBlockStart], sSettingsBufLength - nextBlockStart);
|
||||
}
|
||||
|
||||
assert(sSettingsBufLength >= currentBlockLength);
|
||||
sSettingsBufLength -= currentBlockLength;
|
||||
|
||||
error = OT_ERROR_NONE;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
i += currentBlockLength;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
void otPlatSettingsWipe(otInstance *aInstance) { otPlatSettingsInit(aInstance, NULL, 0); }
|
||||
|
||||
#endif // OPENTHREAD_SETTINGS_RAM
|
||||
116
Libs/util/third_party/openthread/examples/platforms/utils/uart.h
vendored
Normal file
116
Libs/util/third_party/openthread/examples/platforms/utils/uart.h
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform abstraction for UART communication.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_UART_H_
|
||||
#define OPENTHREAD_PLATFORM_UART_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-uart
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for UART communication.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable the UART.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully enabled the UART.
|
||||
* @retval OT_ERROR_FAILED Failed to enabled the UART.
|
||||
*/
|
||||
otError otPlatUartEnable(void);
|
||||
|
||||
/**
|
||||
* Disable the UART.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully disabled the UART.
|
||||
* @retval OT_ERROR_FAILED Failed to disable the UART.
|
||||
*/
|
||||
otError otPlatUartDisable(void);
|
||||
|
||||
/**
|
||||
* Send bytes over the UART.
|
||||
*
|
||||
* @param[in] aBuf A pointer to the data buffer.
|
||||
* @param[in] aBufLength Number of bytes to transmit.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started transmission.
|
||||
* @retval OT_ERROR_FAILED Failed to start the transmission.
|
||||
*/
|
||||
otError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength);
|
||||
|
||||
/**
|
||||
* Flush the outgoing transmit buffer and wait for the data to be sent.
|
||||
* This is called when the CLI UART interface has a full buffer but still
|
||||
* wishes to send more data.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Flush succeeded, we can proceed to write more
|
||||
* data to the buffer.
|
||||
*
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED Driver does not support synchronous flush.
|
||||
* @retval OT_ERROR_INVALID_STATE Driver has no data to flush.
|
||||
*/
|
||||
otError otPlatUartFlush(void);
|
||||
|
||||
/**
|
||||
* The UART driver calls this method to notify OpenThread that the requested bytes have been sent.
|
||||
*/
|
||||
extern void otPlatUartSendDone(void);
|
||||
|
||||
/**
|
||||
* The UART driver calls this method to notify OpenThread that bytes have been received.
|
||||
*
|
||||
* @param[in] aBuf A pointer to the received bytes.
|
||||
* @param[in] aBufLength The number of bytes received.
|
||||
*/
|
||||
extern void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_UART_H_
|
||||
135
Libs/util/third_party/openthread/examples/platforms/utils/uart_rtt.c
vendored
Normal file
135
Libs/util/third_party/openthread/examples/platforms/utils/uart_rtt.c
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file implements the RTT implementation of the uart API.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <utils/code_utils.h>
|
||||
#include <openthread/error.h>
|
||||
|
||||
#if OPENTHREAD_UART_RTT_ENABLE
|
||||
|
||||
#include "SEGGER_RTT.h"
|
||||
#include "uart.h"
|
||||
#include "uart_rtt.h"
|
||||
|
||||
static bool sUartInitialized = false;
|
||||
static bool sUartPendingUp = false;
|
||||
|
||||
#if UART_RTT_BUFFER_INDEX != 0
|
||||
static uint8_t sUartUpBuffer[UART_RTT_UP_BUFFER_SIZE];
|
||||
static uint8_t sUartDownBuffer[UART_RTT_DOWN_BUFFER_SIZE];
|
||||
#endif
|
||||
|
||||
otError otPlatUartEnable(void)
|
||||
{
|
||||
otError error = OT_ERROR_FAILED;
|
||||
|
||||
#if UART_RTT_BUFFER_INDEX != 0
|
||||
int resUp = SEGGER_RTT_ConfigUpBuffer(UART_RTT_BUFFER_INDEX, UART_RTT_BUFFER_NAME, sUartUpBuffer,
|
||||
UART_RTT_UP_BUFFER_SIZE, SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL);
|
||||
int resDown = SEGGER_RTT_ConfigDownBuffer(UART_RTT_BUFFER_INDEX, UART_RTT_BUFFER_NAME, sUartDownBuffer,
|
||||
UART_RTT_DOWN_BUFFER_SIZE, SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL);
|
||||
#else
|
||||
int resUp = SEGGER_RTT_SetFlagsUpBuffer(UART_RTT_BUFFER_INDEX, SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL);
|
||||
int resDown = SEGGER_RTT_SetFlagsDownBuffer(UART_RTT_BUFFER_INDEX, SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL);
|
||||
#endif
|
||||
|
||||
otEXPECT(resUp >= 0 && resDown >= 0);
|
||||
|
||||
sUartInitialized = true;
|
||||
sUartPendingUp = false;
|
||||
error = OT_ERROR_NONE;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatUartDisable(void)
|
||||
{
|
||||
sUartInitialized = false;
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
otEXPECT_ACTION(SEGGER_RTT_Write(UART_RTT_BUFFER_INDEX, aBuf, aBufLength) != 0, error = OT_ERROR_FAILED);
|
||||
sUartPendingUp = true;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatUartFlush(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
otEXPECT_ACTION(sUartPendingUp, error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
while (SEGGER_RTT_HasDataUp(UART_RTT_BUFFER_INDEX) != 0)
|
||||
{
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void utilsUartRttProcess(void)
|
||||
{
|
||||
uint8_t buf[UART_RTT_READ_BUFFER_SIZE];
|
||||
unsigned count;
|
||||
|
||||
otEXPECT(sUartInitialized);
|
||||
|
||||
if (sUartPendingUp && SEGGER_RTT_HasDataUp(UART_RTT_BUFFER_INDEX) == 0)
|
||||
{
|
||||
sUartPendingUp = false;
|
||||
otPlatUartSendDone();
|
||||
}
|
||||
|
||||
count = SEGGER_RTT_Read(UART_RTT_BUFFER_INDEX, &buf, sizeof(buf));
|
||||
if (count > 0)
|
||||
{
|
||||
otPlatUartReceived((const uint8_t *)&buf, count);
|
||||
}
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_UART_RTT_ENABLE
|
||||
111
Libs/util/third_party/openthread/examples/platforms/utils/uart_rtt.h
vendored
Normal file
111
Libs/util/third_party/openthread/examples/platforms/utils/uart_rtt.h
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file defines the RTT implementation of the uart API and default constants used by uart_rtt.c.
|
||||
*/
|
||||
|
||||
#ifndef UTILS_UART_RTT_H
|
||||
#define UTILS_UART_RTT_H
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include "logging_rtt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def UART_RTT_BUFFER_INDEX
|
||||
*
|
||||
* RTT buffer index used for the uart.
|
||||
*/
|
||||
#ifndef UART_RTT_BUFFER_INDEX
|
||||
#define UART_RTT_BUFFER_INDEX 1
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_UART_RTT_ENABLE && (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED) && \
|
||||
(LOG_RTT_BUFFER_INDEX == UART_RTT_BUFFER_INDEX)
|
||||
#error "Log buffer index matches uart buffer index"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def UART_RTT_BUFFER_NAME
|
||||
*
|
||||
* RTT name used for the uart. Only used if UART_RTT_BUFFER_INDEX is not 0.
|
||||
* Otherwise, the buffer name is fixed to "Terminal".
|
||||
*/
|
||||
#ifndef UART_RTT_BUFFER_NAME
|
||||
#define UART_RTT_BUFFER_NAME "Terminal"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def UART_RTT_UP_BUFFER_SIZE
|
||||
*
|
||||
* RTT up buffer size used for the uart. Only used if UART_RTT_BUFFER_INDEX
|
||||
* is not 0. To configure buffer #0 size, check the BUFFER_SIZE_UP definition
|
||||
* in SEGGER_RTT_Conf.h
|
||||
*/
|
||||
#ifndef UART_RTT_UP_BUFFER_SIZE
|
||||
#define UART_RTT_UP_BUFFER_SIZE 256
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def UART_RTT_DOWN_BUFFER_SIZE
|
||||
*
|
||||
* RTT down buffer size used for the uart. Only used if UART_RTT_BUFFER_INDEX
|
||||
* is not 0. To configure buffer #0 size, check the BUFFER_SIZE_DOWN definition
|
||||
* in SEGGER_RTT_Conf.h
|
||||
*/
|
||||
#ifndef UART_RTT_DOWN_BUFFER_SIZE
|
||||
#define UART_RTT_DOWN_BUFFER_SIZE 16
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def UART_RTT_READ_BUFFER_SIZE
|
||||
*
|
||||
* Size of the temporary buffer used when reading from the RTT channel. It will be
|
||||
* locally allocated on the stack.
|
||||
*/
|
||||
#ifndef UART_RTT_READ_BUFFER_SIZE
|
||||
#define UART_RTT_READ_BUFFER_SIZE 16
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Updates the rtt uart. Must be called frequently to process receive and send done.
|
||||
*/
|
||||
void utilsUartRttProcess(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // UTILS_UART_RTT_H
|
||||
83
Libs/util/third_party/openthread/include/openthread/backbone_router.h
vendored
Normal file
83
Libs/util/third_party/openthread/include/openthread/backbone_router.h
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Backbone Router API (Thread 1.2)
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_BACKBONE_ROUTER_H_
|
||||
#define OPENTHREAD_BACKBONE_ROUTER_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-backbone-router
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions for the OpenThread Backbone Router Service.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents Backbone Router configuration.
|
||||
*/
|
||||
typedef struct otBackboneRouterConfig
|
||||
{
|
||||
uint16_t mServer16; ///< Only used when get Primary Backbone Router information in the Thread Network
|
||||
uint16_t mReregistrationDelay; ///< Reregistration Delay (in seconds)
|
||||
uint32_t mMlrTimeout; ///< Multicast Listener Registration Timeout (in seconds)
|
||||
uint8_t mSequenceNumber; ///< Sequence Number
|
||||
} otBackboneRouterConfig;
|
||||
|
||||
/**
|
||||
* Gets the Primary Backbone Router information in the Thread Network.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aConfig A pointer to where to put Primary Backbone Router information.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully got Primary Backbone Router information.
|
||||
* @retval OT_ERROR_NOT_FOUND No Primary Backbone Router exists.
|
||||
*/
|
||||
otError otBackboneRouterGetPrimary(otInstance *aInstance, otBackboneRouterConfig *aConfig);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_BACKBONE_ROUTER_H_
|
||||
412
Libs/util/third_party/openthread/include/openthread/backbone_router_ftd.h
vendored
Normal file
412
Libs/util/third_party/openthread/include/openthread/backbone_router_ftd.h
vendored
Normal file
@@ -0,0 +1,412 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Backbone Router API (for Thread 1.2 FTD with
|
||||
* `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE`).
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_BACKBONE_ROUTER_FTD_H_
|
||||
#define OPENTHREAD_BACKBONE_ROUTER_FTD_H_
|
||||
|
||||
#include <openthread/backbone_router.h>
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/netdata.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-backbone-router
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents the Backbone Router Status.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_BACKBONE_ROUTER_STATE_DISABLED = 0, ///< Backbone function is disabled.
|
||||
OT_BACKBONE_ROUTER_STATE_SECONDARY = 1, ///< Secondary Backbone Router.
|
||||
OT_BACKBONE_ROUTER_STATE_PRIMARY = 2, ///< The Primary Backbone Router.
|
||||
} otBackboneRouterState;
|
||||
|
||||
/**
|
||||
* Enables or disables Backbone functionality.
|
||||
*
|
||||
* If enabled, a Server Data Request message `SRV_DATA.ntf` is triggered for the attached
|
||||
* device if there is no Backbone Router Service in the Thread Network Data.
|
||||
*
|
||||
* If disabled, `SRV_DATA.ntf` is triggered if the Backbone Router is in the Primary state.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnable TRUE to enable Backbone functionality, FALSE otherwise.
|
||||
*
|
||||
* @sa otBackboneRouterGetState
|
||||
* @sa otBackboneRouterGetConfig
|
||||
* @sa otBackboneRouterSetConfig
|
||||
* @sa otBackboneRouterRegister
|
||||
*/
|
||||
void otBackboneRouterSetEnabled(otInstance *aInstance, bool aEnable);
|
||||
|
||||
/**
|
||||
* Gets the Backbone Router #otBackboneRouterState.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_BACKBONE_ROUTER_STATE_DISABLED Backbone functionality is disabled.
|
||||
* @retval OT_BACKBONE_ROUTER_STATE_SECONDARY Secondary Backbone Router.
|
||||
* @retval OT_BACKBONE_ROUTER_STATE_PRIMARY The Primary Backbone Router.
|
||||
*
|
||||
* @sa otBackboneRouterSetEnabled
|
||||
* @sa otBackboneRouterGetConfig
|
||||
* @sa otBackboneRouterSetConfig
|
||||
* @sa otBackboneRouterRegister
|
||||
*/
|
||||
otBackboneRouterState otBackboneRouterGetState(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the local Backbone Router configuration.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aConfig A pointer where to put local Backbone Router configuration.
|
||||
*
|
||||
*
|
||||
* @sa otBackboneRouterSetEnabled
|
||||
* @sa otBackboneRouterGetState
|
||||
* @sa otBackboneRouterSetConfig
|
||||
* @sa otBackboneRouterRegister
|
||||
*/
|
||||
void otBackboneRouterGetConfig(otInstance *aInstance, otBackboneRouterConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Sets the local Backbone Router configuration #otBackboneRouterConfig.
|
||||
*
|
||||
* A Server Data Request message `SRV_DATA.ntf` is initiated automatically if BBR Dataset changes for Primary
|
||||
* Backbone Router.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aConfig A pointer to the Backbone Router configuration to take effect.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully updated configuration.
|
||||
* @retval OT_ERROR_INVALID_ARGS The configuration in @p aConfig is invalid.
|
||||
*
|
||||
* @sa otBackboneRouterSetEnabled
|
||||
* @sa otBackboneRouterGetState
|
||||
* @sa otBackboneRouterGetConfig
|
||||
* @sa otBackboneRouterRegister
|
||||
*/
|
||||
otError otBackboneRouterSetConfig(otInstance *aInstance, const otBackboneRouterConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Explicitly registers local Backbone Router configuration.
|
||||
*
|
||||
* A Server Data Request message `SRV_DATA.ntf` is triggered for the attached device.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient space to add the Backbone Router service.
|
||||
* @retval OT_ERROR_NONE Successfully queued a Server Data Request message for delivery.
|
||||
*
|
||||
* @sa otBackboneRouterSetEnabled
|
||||
* @sa otBackboneRouterGetState
|
||||
* @sa otBackboneRouterGetConfig
|
||||
* @sa otBackboneRouterSetConfig
|
||||
*/
|
||||
otError otBackboneRouterRegister(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Returns the Backbone Router registration jitter value.
|
||||
*
|
||||
* @returns The Backbone Router registration jitter value.
|
||||
*
|
||||
* @sa otBackboneRouterSetRegistrationJitter
|
||||
*/
|
||||
uint8_t otBackboneRouterGetRegistrationJitter(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the Backbone Router registration jitter value.
|
||||
*
|
||||
* @param[in] aJitter the Backbone Router registration jitter value to set.
|
||||
*
|
||||
* @sa otBackboneRouterGetRegistrationJitter
|
||||
*/
|
||||
void otBackboneRouterSetRegistrationJitter(otInstance *aInstance, uint8_t aJitter);
|
||||
|
||||
/**
|
||||
* Gets the local Domain Prefix configuration.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aConfig A pointer to the Domain Prefix configuration.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully got the Domain Prefix configuration.
|
||||
* @retval OT_ERROR_NOT_FOUND No Domain Prefix was configured.
|
||||
*/
|
||||
otError otBackboneRouterGetDomainPrefix(otInstance *aInstance, otBorderRouterConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Configures response status for next DUA registration.
|
||||
*
|
||||
* Note: available only when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled.
|
||||
* Only used for test and certification.
|
||||
*
|
||||
* TODO: (DUA) support coap error code and corresponding process for certification purpose.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMlIid A pointer to the Mesh Local IID. If NULL, respond with @p aStatus for any
|
||||
* coming DUA.req, otherwise only respond the one with matching @p aMlIid.
|
||||
* @param[in] aStatus The status to respond.
|
||||
*/
|
||||
void otBackboneRouterConfigNextDuaRegistrationResponse(otInstance *aInstance,
|
||||
const otIp6InterfaceIdentifier *aMlIid,
|
||||
uint8_t aStatus);
|
||||
|
||||
/**
|
||||
* Configures the response status for the next Multicast Listener Registration.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE`,
|
||||
* `OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE`, and
|
||||
* `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` are enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aStatus The status to respond.
|
||||
*/
|
||||
void otBackboneRouterConfigNextMulticastListenerRegistrationResponse(otInstance *aInstance, uint8_t aStatus);
|
||||
|
||||
/**
|
||||
* Represents the Multicast Listener events.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_BACKBONE_ROUTER_MULTICAST_LISTENER_ADDED = 0, ///< Multicast Listener was added.
|
||||
OT_BACKBONE_ROUTER_MULTICAST_LISTENER_REMOVED = 1, ///< Multicast Listener was removed or expired.
|
||||
} otBackboneRouterMulticastListenerEvent;
|
||||
|
||||
/**
|
||||
* Pointer is called whenever the Multicast Listeners change.
|
||||
*
|
||||
* @param[in] aContext The user context pointer.
|
||||
* @param[in] aEvent The Multicast Listener event.
|
||||
* @param[in] aAddress The IPv6 multicast address of the Multicast Listener.
|
||||
*/
|
||||
typedef void (*otBackboneRouterMulticastListenerCallback)(void *aContext,
|
||||
otBackboneRouterMulticastListenerEvent aEvent,
|
||||
const otIp6Address *aAddress);
|
||||
|
||||
/**
|
||||
* Sets the Backbone Router Multicast Listener callback.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback A pointer to the Multicast Listener callback.
|
||||
* @param[in] aContext A user context pointer.
|
||||
*/
|
||||
void otBackboneRouterSetMulticastListenerCallback(otInstance *aInstance,
|
||||
otBackboneRouterMulticastListenerCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Clears the Multicast Listeners.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE`,
|
||||
* `OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE`, and
|
||||
* `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` are enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @sa otBackboneRouterMulticastListenerAdd
|
||||
* @sa otBackboneRouterMulticastListenerGetNext
|
||||
*/
|
||||
void otBackboneRouterMulticastListenerClear(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Adds a Multicast Listener with a timeout value, in seconds.
|
||||
*
|
||||
* Pass `0` to use the default MLR timeout.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE`,
|
||||
* `OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE`, and
|
||||
* `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` are enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aAddress The Multicast Listener address.
|
||||
* @param[in] aTimeout The timeout (in seconds) of the Multicast Listener, or 0 to use the default MLR timeout.
|
||||
*
|
||||
* @retval OT_ERROR_NONE If the Multicast Listener was successfully added.
|
||||
* @retval OT_ERROR_INVALID_ARGS If the Multicast Listener address was invalid.
|
||||
* @retval OT_ERROR_NO_BUFS No space available to save the Multicast Listener.
|
||||
*
|
||||
* @sa otBackboneRouterMulticastListenerClear
|
||||
* @sa otBackboneRouterMulticastListenerGetNext
|
||||
*/
|
||||
otError otBackboneRouterMulticastListenerAdd(otInstance *aInstance, const otIp6Address *aAddress, uint32_t aTimeout);
|
||||
|
||||
#define OT_BACKBONE_ROUTER_MULTICAST_LISTENER_ITERATOR_INIT \
|
||||
0 ///< Initializer for otBackboneRouterMulticastListenerIterator
|
||||
|
||||
typedef uint16_t otBackboneRouterMulticastListenerIterator; ///< Used to iterate through Multicast Listeners.
|
||||
|
||||
/**
|
||||
* Represents a Backbone Router Multicast Listener info.
|
||||
*/
|
||||
typedef struct otBackboneRouterMulticastListenerInfo
|
||||
{
|
||||
otIp6Address mAddress; // Multicast Listener address.
|
||||
uint32_t mTimeout; // Timeout (in seconds).
|
||||
} otBackboneRouterMulticastListenerInfo;
|
||||
|
||||
/**
|
||||
* Gets the next Multicast Listener info (using an iterator).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to the iterator. On success the iterator will be updated to point to next
|
||||
* Multicast Listener. To get the first entry the iterator should be set to
|
||||
* OT_BACKBONE_ROUTER_MULTICAST_LISTENER_ITERATOR_INIT.
|
||||
* @param[out] aListenerInfo A pointer to an `otBackboneRouterMulticastListenerInfo` where information of next
|
||||
* Multicast Listener is placed (on success).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully found the next Multicast Listener info (@p aListenerInfo was successfully
|
||||
* updated).
|
||||
* @retval OT_ERROR_NOT_FOUND No subsequent Multicast Listener info was found.
|
||||
*
|
||||
* @sa otBackboneRouterMulticastListenerClear
|
||||
* @sa otBackboneRouterMulticastListenerAdd
|
||||
*/
|
||||
otError otBackboneRouterMulticastListenerGetNext(otInstance *aInstance,
|
||||
otBackboneRouterMulticastListenerIterator *aIterator,
|
||||
otBackboneRouterMulticastListenerInfo *aListenerInfo);
|
||||
|
||||
/**
|
||||
* Represents the ND Proxy events.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_BACKBONE_ROUTER_NDPROXY_ADDED = 0, ///< ND Proxy was added.
|
||||
OT_BACKBONE_ROUTER_NDPROXY_REMOVED = 1, ///< ND Proxy was removed.
|
||||
OT_BACKBONE_ROUTER_NDPROXY_RENEWED = 2, ///< ND Proxy was renewed.
|
||||
OT_BACKBONE_ROUTER_NDPROXY_CLEARED = 3, ///< All ND Proxies were cleared.
|
||||
} otBackboneRouterNdProxyEvent;
|
||||
|
||||
/**
|
||||
* Pointer is called whenever the Nd Proxy changed.
|
||||
*
|
||||
* @param[in] aContext The user context pointer.
|
||||
* @param[in] aEvent The ND Proxy event.
|
||||
* @param[in] aDua The Domain Unicast Address of the ND Proxy, or `nullptr` if @p aEvent is
|
||||
* `OT_BACKBONE_ROUTER_NDPROXY_CLEARED`.
|
||||
*/
|
||||
typedef void (*otBackboneRouterNdProxyCallback)(void *aContext,
|
||||
otBackboneRouterNdProxyEvent aEvent,
|
||||
const otIp6Address *aDua);
|
||||
|
||||
/**
|
||||
* Sets the Backbone Router ND Proxy callback.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback A pointer to the ND Proxy callback.
|
||||
* @param[in] aContext A user context pointer.
|
||||
*/
|
||||
void otBackboneRouterSetNdProxyCallback(otInstance *aInstance,
|
||||
otBackboneRouterNdProxyCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Represents the Backbone Router ND Proxy info.
|
||||
*/
|
||||
typedef struct otBackboneRouterNdProxyInfo
|
||||
{
|
||||
otIp6InterfaceIdentifier *mMeshLocalIid; ///< Mesh-local IID
|
||||
uint32_t mTimeSinceLastTransaction; ///< Time since last transaction (Seconds)
|
||||
uint16_t mRloc16; ///< RLOC16
|
||||
} otBackboneRouterNdProxyInfo;
|
||||
|
||||
/**
|
||||
* Gets the Backbone Router ND Proxy info.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDua The Domain Unicast Address.
|
||||
* @param[out] aNdProxyInfo A pointer to the ND Proxy info.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully got the ND Proxy info.
|
||||
* @retval OT_ERROR_NOT_FOUND Failed to find the Domain Unicast Address in the ND Proxy table.
|
||||
*/
|
||||
otError otBackboneRouterGetNdProxyInfo(otInstance *aInstance,
|
||||
const otIp6Address *aDua,
|
||||
otBackboneRouterNdProxyInfo *aNdProxyInfo);
|
||||
|
||||
/**
|
||||
* Represents the Domain Prefix events.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_BACKBONE_ROUTER_DOMAIN_PREFIX_ADDED = 0, ///< Domain Prefix was added.
|
||||
OT_BACKBONE_ROUTER_DOMAIN_PREFIX_REMOVED = 1, ///< Domain Prefix was removed.
|
||||
OT_BACKBONE_ROUTER_DOMAIN_PREFIX_CHANGED = 2, ///< Domain Prefix was changed.
|
||||
} otBackboneRouterDomainPrefixEvent;
|
||||
|
||||
/**
|
||||
* Pointer is called whenever the Domain Prefix changed.
|
||||
*
|
||||
* @param[in] aContext The user context pointer.
|
||||
* @param[in] aEvent The Domain Prefix event.
|
||||
* @param[in] aDomainPrefix The new Domain Prefix if added or changed, nullptr otherwise.
|
||||
*/
|
||||
typedef void (*otBackboneRouterDomainPrefixCallback)(void *aContext,
|
||||
otBackboneRouterDomainPrefixEvent aEvent,
|
||||
const otIp6Prefix *aDomainPrefix);
|
||||
/**
|
||||
* Sets the Backbone Router Domain Prefix callback.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback A pointer to the Domain Prefix callback.
|
||||
* @param[in] aContext A user context pointer.
|
||||
*/
|
||||
void otBackboneRouterSetDomainPrefixCallback(otInstance *aInstance,
|
||||
otBackboneRouterDomainPrefixCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_BACKBONE_ROUTER_FTD_H_
|
||||
428
Libs/util/third_party/openthread/include/openthread/ble_secure.h
vendored
Normal file
428
Libs/util/third_party/openthread/include/openthread/ble_secure.h
vendored
Normal file
@@ -0,0 +1,428 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the top-level functions for the OpenThread BLE Secure implementation.
|
||||
*
|
||||
* @note
|
||||
* The functions in this module require the build-time feature `OPENTHREAD_CONFIG_BLE_TCAT_ENABLE=1`.
|
||||
*
|
||||
* @note
|
||||
* To enable cipher suite DTLS_PSK_WITH_AES_128_CCM_8, MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
|
||||
* must be enabled in mbedtls-config.h
|
||||
* To enable cipher suite DTLS_ECDHE_ECDSA_WITH_AES_128_CCM_8,
|
||||
* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED must be enabled in mbedtls-config.h.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_BLE_SECURE_H_
|
||||
#define OPENTHREAD_BLE_SECURE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <openthread/message.h>
|
||||
#include <openthread/tcat.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-ble-secure
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control BLE Secure (TLS over BLE) communication.
|
||||
*
|
||||
* The functions in this module are available when BLE Secure API feature
|
||||
* (`OPENTHREAD_CONFIG_BLE_TCAT_ENABLE`) is enabled.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pointer to call when ble secure connection state changes.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aConnected TRUE, if a secure connection was established, FALSE otherwise.
|
||||
* @param[in] aBleConnectionOpen TRUE if a BLE connection was established to carry a TLS data stream, FALSE
|
||||
* otherwise.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*/
|
||||
typedef void (*otHandleBleSecureConnect)(otInstance *aInstance,
|
||||
bool aConnected,
|
||||
bool aBleConnectionOpen,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Pointer to call when data was received over a BLE Secure TLS connection.
|
||||
*/
|
||||
typedef otHandleTcatApplicationDataReceive otHandleBleSecureReceive;
|
||||
|
||||
/**
|
||||
* Starts the BLE Secure service.
|
||||
* When TLV mode is active, the function @p aReceiveHandler will be called once a complete TLV was received and the
|
||||
* message offset points to the TLV value.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aConnectHandler A pointer to a function that will be called when the connection
|
||||
* state changes.
|
||||
* @param[in] aReceiveHandler A pointer to a function that will be called once data has been received
|
||||
* over the TLS connection.
|
||||
* @param[in] aTlvMode A boolean value indicating if line mode shall be activated.
|
||||
* @param[in] aContext A pointer to arbitrary context information. May be NULL if not used.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the BLE Secure server.
|
||||
* @retval OT_ERROR_ALREADY The service was stated already.
|
||||
*/
|
||||
otError otBleSecureStart(otInstance *aInstance,
|
||||
otHandleBleSecureConnect aConnectHandler,
|
||||
otHandleBleSecureReceive aReceiveHandler,
|
||||
bool aTlvMode,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Sets TCAT vendor info
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aVendorInfo A pointer to the Vendor Information (must remain valid after the method call.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set value.
|
||||
* @retval OT_ERROR_INVALID_ARGS Value not set.
|
||||
*/
|
||||
otError otBleSecureSetTcatVendorInfo(otInstance *aInstance, const otTcatVendorInfo *aVendorInfo);
|
||||
|
||||
/**
|
||||
* Enables the TCAT protocol over BLE Secure.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aHandler A pointer to a function that is called when the join operation completes.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the BLE Secure Joiner role.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aElevationPsk or @p aVendorInfo is invalid.
|
||||
* @retval OT_ERROR_INVALID_STATE The BLE function has not been started or line mode is not selected.
|
||||
*/
|
||||
otError otBleSecureTcatStart(otInstance *aInstance, otHandleTcatJoin aHandler);
|
||||
|
||||
/**
|
||||
* Stops the BLE Secure server.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otBleSecureStop(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the Pre-Shared Key (PSK) and cipher suite
|
||||
* TLS_PSK_WITH_AES_128_CCM_8.
|
||||
*
|
||||
* @note Requires the build-time feature `MBEDTLS_KEY_EXCHANGE_PSK_ENABLED` to be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPsk A pointer to the PSK.
|
||||
* @param[in] aPskLength The PSK length.
|
||||
* @param[in] aPskIdentity The Identity Name for the PSK.
|
||||
* @param[in] aPskIdLength The PSK Identity Length.
|
||||
*/
|
||||
void otBleSecureSetPsk(otInstance *aInstance,
|
||||
const uint8_t *aPsk,
|
||||
uint16_t aPskLength,
|
||||
const uint8_t *aPskIdentity,
|
||||
uint16_t aPskIdLength);
|
||||
|
||||
/**
|
||||
* Returns the peer x509 certificate base64 encoded.
|
||||
*
|
||||
* @note Requires the build-time features `MBEDTLS_BASE64_C` and
|
||||
* `MBEDTLS_SSL_KEEP_PEER_CERTIFICATE` to be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aPeerCert A pointer to the base64 encoded certificate buffer.
|
||||
* @param[in,out] aCertLength On input, the size the max size of @p aPeerCert.
|
||||
* On output, the length of the base64 encoded peer certificate.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully get the peer certificate.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aInstance or @p aCertLength is invalid.
|
||||
* @retval OT_ERROR_INVALID_STATE Not connected yet.
|
||||
* @retval OT_ERROR_NO_BUFS Can't allocate memory for certificate.
|
||||
*/
|
||||
otError otBleSecureGetPeerCertificateBase64(otInstance *aInstance, unsigned char *aPeerCert, size_t *aCertLength);
|
||||
|
||||
/**
|
||||
* Returns an attribute value identified by its OID from the subject
|
||||
* of the peer x509 certificate. The peer OID is provided in binary format.
|
||||
* The attribute length is set if the attribute was successfully read or zero
|
||||
* if unsuccessful. The ASN.1 type as is set as defineded in the ITU-T X.690 standard
|
||||
* if the attribute was successfully read.
|
||||
*
|
||||
* @note Requires the build-time feature
|
||||
* `MBEDTLS_SSL_KEEP_PEER_CERTIFICATE` to be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aOid A pointer to the OID to be found.
|
||||
* @param[in] aOidLength The length of the OID.
|
||||
* @param[out] aAttributeBuffer A pointer to the attribute buffer.
|
||||
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
|
||||
* On output, the length of the attribute written to the buffer.
|
||||
* @param[out] aAsn1Type A pointer to the ASN.1 type of the attribute written to the buffer.
|
||||
*
|
||||
* @retval OT_ERROR_INVALID_STATE Not connected yet.
|
||||
* @retval OT_ERROR_INVALID_ARGS Invalid attribute length.
|
||||
* @retval OT_ERROR_NONE Successfully read attribute.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient memory for storing the attribute value.
|
||||
*/
|
||||
otError otBleSecureGetPeerSubjectAttributeByOid(otInstance *aInstance,
|
||||
const char *aOid,
|
||||
size_t aOidLength,
|
||||
uint8_t *aAttributeBuffer,
|
||||
size_t *aAttributeLength,
|
||||
int *aAsn1Type);
|
||||
|
||||
/**
|
||||
* Returns an attribute value for the OID 1.3.6.1.4.1.44970.x from the v3 extensions of
|
||||
* the peer x509 certificate, where the last digit x is set to aThreadOidDescriptor.
|
||||
* The attribute length is set if the attribute was successfully read or zero if unsuccessful.
|
||||
* Requires a connection to be active.
|
||||
*
|
||||
* @note Requires the build-time feature
|
||||
* `MBEDTLS_SSL_KEEP_PEER_CERTIFICATE` to be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aThreadOidDescriptor The last digit of the Thread attribute OID.
|
||||
* @param[out] aAttributeBuffer A pointer to the attribute buffer.
|
||||
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
|
||||
* On output, the length of the attribute written to the buffer.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully read attribute.
|
||||
* @retval OT_ERROR_INVALID_ARGS Invalid attribute length.
|
||||
* @retval OT_NOT_FOUND The requested attribute was not found.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient memory for storing the attribute value.
|
||||
* @retval OT_ERROR_INVALID_STATE Not connected yet.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED The value of aThreadOidDescriptor is >127.
|
||||
* @retval OT_ERROR_PARSE The certificate extensions could not be parsed.
|
||||
*/
|
||||
otError otBleSecureGetThreadAttributeFromPeerCertificate(otInstance *aInstance,
|
||||
int aThreadOidDescriptor,
|
||||
uint8_t *aAttributeBuffer,
|
||||
size_t *aAttributeLength);
|
||||
|
||||
/**
|
||||
* Returns an attribute value for the OID 1.3.6.1.4.1.44970.x from the v3 extensions of
|
||||
* the own x509 certificate, where the last digit x is set to aThreadOidDescriptor.
|
||||
* The attribute length is set if the attribute was successfully read or zero if unsuccessful.
|
||||
* Requires a connection to be active.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aThreadOidDescriptor The last digit of the Thread attribute OID.
|
||||
* @param[out] aAttributeBuffer A pointer to the attribute buffer.
|
||||
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
|
||||
* On output, the length of the attribute written to the buffer.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully read attribute.
|
||||
* @retval OT_ERROR_INVALID_ARGS Invalid attribute length.
|
||||
* @retval OT_NOT_FOUND The requested attribute was not found.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient memory for storing the attribute value.
|
||||
* @retval OT_ERROR_INVALID_STATE Not connected yet.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED The value of aThreadOidDescriptor is >127.
|
||||
* @retval OT_ERROR_PARSE The certificate extensions could not be parsed.
|
||||
*/
|
||||
otError otBleSecureGetThreadAttributeFromOwnCertificate(otInstance *aInstance,
|
||||
int aThreadOidDescriptor,
|
||||
uint8_t *aAttributeBuffer,
|
||||
size_t *aAttributeLength);
|
||||
|
||||
/**
|
||||
* Sets the authentication mode for the BLE secure connection.
|
||||
*
|
||||
* Disable or enable the verification of peer certificate.
|
||||
* Must be called before start.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aVerifyPeerCertificate true, to verify the peer certificate.
|
||||
*/
|
||||
void otBleSecureSetSslAuthMode(otInstance *aInstance, bool aVerifyPeerCertificate);
|
||||
|
||||
/**
|
||||
* Sets the local device's X509 certificate with corresponding private key for
|
||||
* TLS session with TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8.
|
||||
*
|
||||
* @note Requires `MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=1`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aX509Cert A pointer to the PEM formatted X509 certificate.
|
||||
* @param[in] aX509Length The length of certificate.
|
||||
* @param[in] aPrivateKey A pointer to the PEM formatted private key.
|
||||
* @param[in] aPrivateKeyLength The length of the private key.
|
||||
*/
|
||||
void otBleSecureSetCertificate(otInstance *aInstance,
|
||||
const uint8_t *aX509Cert,
|
||||
uint32_t aX509Length,
|
||||
const uint8_t *aPrivateKey,
|
||||
uint32_t aPrivateKeyLength);
|
||||
|
||||
/**
|
||||
* Sets the trusted top level CAs. It is needed for validating the
|
||||
* certificate of the peer.
|
||||
*
|
||||
* TLS mode "ECDHE ECDSA with AES 128 CCM 8" for secure BLE.
|
||||
*
|
||||
* @note Requires `MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=1`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aX509CaCertificateChain A pointer to the PEM formatted X509 CA chain.
|
||||
* @param[in] aX509CaCertChainLength The length of chain.
|
||||
*/
|
||||
void otBleSecureSetCaCertificateChain(otInstance *aInstance,
|
||||
const uint8_t *aX509CaCertificateChain,
|
||||
uint32_t aX509CaCertChainLength);
|
||||
|
||||
/**
|
||||
* Initializes TLS session with a peer using an already open BLE connection.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started TLS connection.
|
||||
*/
|
||||
otError otBleSecureConnect(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Stops the BLE and TLS connection.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otBleSecureDisconnect(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the TLS session is active (connected or connecting).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval TRUE If TLS session is active.
|
||||
* @retval FALSE If TLS session is not active.
|
||||
*/
|
||||
bool otBleSecureIsConnectionActive(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the TLS session is connected.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval TRUE The TLS session is connected.
|
||||
* @retval FALSE The TLS session is not connected.
|
||||
*/
|
||||
bool otBleSecureIsConnected(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the TCAT agent is enabled.
|
||||
*
|
||||
* @retval TRUE The TCAT agent is enabled.
|
||||
* @retval FALSE The TCAT agent is not enabled.
|
||||
*/
|
||||
bool otBleSecureIsTcatEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Indicates whether or not a TCAT command class is authorized.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCommandClass A command class to check.
|
||||
*
|
||||
* @retval TRUE The command class is authorized.
|
||||
* @retval FALSE The command class is not authorized.
|
||||
*/
|
||||
bool otBleSecureIsCommandClassAuthorized(otInstance *aInstance, otTcatCommandClass aCommandClass);
|
||||
|
||||
/**
|
||||
* Sends a secure BLE message.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMessage A pointer to the message to send.
|
||||
*
|
||||
* If the return value is OT_ERROR_NONE, OpenThread takes ownership of @p aMessage, and the caller should no longer
|
||||
* reference @p aMessage. If the return value is not OT_ERROR_NONE, the caller retains ownership of @p aMessage,
|
||||
* including freeing @p aMessage if the message buffer is no longer needed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully sent message.
|
||||
* @retval OT_ERROR_NO_BUFS Failed to allocate buffer memory.
|
||||
* @retval OT_ERROR_INVALID_STATE TLS connection was not initialized.
|
||||
*/
|
||||
otError otBleSecureSendMessage(otInstance *aInstance, otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Sends a secure BLE data packet.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aBuf A pointer to the data to send as the Value of the TCAT Send Application Data TLV.
|
||||
* @param[in] aLength A number indicating the length of the data buffer.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully sent data.
|
||||
* @retval OT_ERROR_NO_BUFS Failed to allocate buffer memory.
|
||||
* @retval OT_ERROR_INVALID_STATE TLS connection was not initialized.
|
||||
*/
|
||||
otError otBleSecureSend(otInstance *aInstance, uint8_t *aBuf, uint16_t aLength);
|
||||
|
||||
/**
|
||||
* Sends a secure BLE data packet containing a TCAT Send Application Data TLV.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aBuf A pointer to the data to send as the Value of the TCAT Send Application Data TLV.
|
||||
* @param[in] aLength A number indicating the length of the data buffer.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully sent data.
|
||||
* @retval OT_ERROR_NO_BUFS Failed to allocate buffer memory.
|
||||
* @retval OT_ERROR_INVALID_STATE TLS connection was not initialized.
|
||||
*/
|
||||
otError otBleSecureSendApplicationTlv(otInstance *aInstance, uint8_t *aBuf, uint16_t aLength);
|
||||
|
||||
/**
|
||||
* Flushes the send buffer.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully flushed output buffer.
|
||||
* @retval OT_ERROR_NO_BUFS Failed to allocate buffer memory.
|
||||
* @retval OT_ERROR_INVALID_STATE TLS connection was not initialized.
|
||||
*/
|
||||
otError otBleSecureFlush(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the Install Code Verify Status during the current session.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval TRUE The install code was correctly verified.
|
||||
* @retval FALSE The install code was not verified.
|
||||
*/
|
||||
bool otBleSecureGetInstallCodeVerifyStatus(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif /* OPENTHREAD_BLE_SECURE_H_ */
|
||||
311
Libs/util/third_party/openthread/include/openthread/border_agent.h
vendored
Normal file
311
Libs/util/third_party/openthread/include/openthread/border_agent.h
vendored
Normal file
@@ -0,0 +1,311 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes functions for the Thread Border Agent role.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_BORDER_AGENT_H_
|
||||
#define OPENTHREAD_BORDER_AGENT_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-border-agent
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions for the Thread Border Agent role.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The length of Border Agent/Router ID in bytes.
|
||||
*/
|
||||
#define OT_BORDER_AGENT_ID_LENGTH (16)
|
||||
|
||||
/**
|
||||
* Minimum length of the ephemeral key string.
|
||||
*/
|
||||
#define OT_BORDER_AGENT_MIN_EPHEMERAL_KEY_LENGTH (6)
|
||||
|
||||
/**
|
||||
* Maximum length of the ephemeral key string.
|
||||
*/
|
||||
#define OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_LENGTH (32)
|
||||
|
||||
/**
|
||||
* Default ephemeral key timeout interval in milliseconds.
|
||||
*/
|
||||
#define OT_BORDER_AGENT_DEFAULT_EPHEMERAL_KEY_TIMEOUT (2 * 60 * 1000u)
|
||||
|
||||
/**
|
||||
* Maximum ephemeral key timeout interval in milliseconds.
|
||||
*/
|
||||
#define OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_TIMEOUT (10 * 60 * 1000u)
|
||||
|
||||
/**
|
||||
* Represents a Border Agent Identifier.
|
||||
*/
|
||||
typedef struct otBorderAgentId
|
||||
{
|
||||
uint8_t mId[OT_BORDER_AGENT_ID_LENGTH]; ///< Border Agent ID bytes.
|
||||
} otBorderAgentId;
|
||||
|
||||
/**
|
||||
* Defines the Border Agent state.
|
||||
*/
|
||||
typedef enum otBorderAgentState
|
||||
{
|
||||
OT_BORDER_AGENT_STATE_STOPPED = 0, ///< Border agent role is disabled.
|
||||
OT_BORDER_AGENT_STATE_STARTED = 1, ///< Border agent is started.
|
||||
OT_BORDER_AGENT_STATE_ACTIVE = 2, ///< Border agent is connected with external commissioner.
|
||||
} otBorderAgentState;
|
||||
|
||||
typedef struct otBorderAgentCounters
|
||||
{
|
||||
uint32_t mEpskcActivations; ///< The number of ePSKc activations
|
||||
uint32_t mEpskcDeactivationClears; ///< The number of ePSKc deactivations via API
|
||||
uint32_t mEpskcDeactivationTimeouts; ///< The number of ePSKc deactivations due to timeout
|
||||
uint32_t mEpskcDeactivationMaxAttempts; ///< The number of ePSKc deactivations due to reached max attempts
|
||||
uint32_t mEpskcDeactivationDisconnects; ///< The number of ePSKc deactivations due to commissioner disconnected
|
||||
uint32_t mEpskcInvalidBaStateErrors; ///< The number of invalid border agent state errors at ePSKc activation
|
||||
uint32_t mEpskcInvalidArgsErrors; ///< The number of invalid args errors at ePSKc activation
|
||||
uint32_t mEpskcStartSecureSessionErrors; ///< The number of start secure session errors at ePSKc activation
|
||||
uint32_t mEpskcSecureSessionSuccesses; ///< The number of established secure sessions with ePSKc
|
||||
uint32_t mEpskcSecureSessionFailures; ///< The number of failed secure sessions with ePSKc
|
||||
uint32_t mEpskcCommissionerPetitions; ///< The number of successful commissioner petitions with ePSKc
|
||||
|
||||
uint32_t mPskcSecureSessionSuccesses; ///< The number of established secure sessions with PSKc
|
||||
uint32_t mPskcSecureSessionFailures; ///< The number of failed secure sessions with PSKc
|
||||
uint32_t mPskcCommissionerPetitions; ///< The number of successful commissioner petitions with PSKc
|
||||
|
||||
uint32_t mMgmtActiveGets; ///< The number of MGMT_ACTIVE_GET.req sent over secure sessions
|
||||
uint32_t mMgmtPendingGets; ///< The number of MGMT_PENDING_GET.req sent over secure sessions
|
||||
} otBorderAgentCounters;
|
||||
|
||||
/**
|
||||
* Gets the counters of the Thread Border Agent.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the Border Agent counters.
|
||||
*/
|
||||
const otBorderAgentCounters *otBorderAgentGetCounters(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the #otBorderAgentState of the Thread Border Agent role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The current #otBorderAgentState of the Border Agent.
|
||||
*/
|
||||
otBorderAgentState otBorderAgentGetState(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the UDP port of the Thread Border Agent service.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns UDP port of the Border Agent.
|
||||
*/
|
||||
uint16_t otBorderAgentGetUdpPort(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the randomly generated Border Agent ID.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE`.
|
||||
*
|
||||
* The ID is saved in persistent storage and survives reboots. The typical use case of the ID is to
|
||||
* be published in the MeshCoP mDNS service as the `id` TXT value for the client to identify this
|
||||
* Border Router/Agent device.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aId A pointer to buffer to receive the ID.
|
||||
*
|
||||
* @retval OT_ERROR_NONE If successfully retrieved the Border Agent ID.
|
||||
* @retval ... If failed to retrieve the Border Agent ID.
|
||||
*
|
||||
* @sa otBorderAgentSetId
|
||||
*/
|
||||
otError otBorderAgentGetId(otInstance *aInstance, otBorderAgentId *aId);
|
||||
|
||||
/**
|
||||
* Sets the Border Agent ID.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE`.
|
||||
*
|
||||
* The Border Agent ID will be saved in persistent storage and survive reboots. It's required to
|
||||
* set the ID only once after factory reset. If the ID has never been set by calling this function,
|
||||
* a random ID will be generated and returned when `otBorderAgentGetId` is called.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aId A pointer to the Border Agent ID.
|
||||
*
|
||||
* @retval OT_ERROR_NONE If successfully set the Border Agent ID.
|
||||
* @retval ... If failed to set the Border Agent ID.
|
||||
*
|
||||
* @sa otBorderAgentGetId
|
||||
*/
|
||||
otError otBorderAgentSetId(otInstance *aInstance, const otBorderAgentId *aId);
|
||||
|
||||
/**
|
||||
* Sets the ephemeral key for a given timeout duration.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE`.
|
||||
*
|
||||
* The ephemeral key can be set when the Border Agent is already running and is not currently connected to any external
|
||||
* commissioner (i.e., it is in `OT_BORDER_AGENT_STATE_STARTED` state). Otherwise `OT_ERROR_INVALID_STATE` is returned.
|
||||
* To terminate active commissioner sessions, use the `otBorderAgentDisconnect()` API.
|
||||
*
|
||||
* The given @p aKeyString is directly used as the ephemeral PSK (excluding the trailing null `\0` character ).
|
||||
* The @p aKeyString length must be between `OT_BORDER_AGENT_MIN_EPHEMERAL_KEY_LENGTH` and
|
||||
* `OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_LENGTH`, inclusive.
|
||||
*
|
||||
* Setting the ephemeral key again before a previously set key has timed out will replace the previously set key and
|
||||
* reset the timeout.
|
||||
*
|
||||
* During the timeout interval, the ephemeral key can be used only once by an external commissioner to establish a
|
||||
* connection. After the commissioner disconnects, the ephemeral key is cleared, and the Border Agent reverts to
|
||||
* using PSKc. If the timeout expires while a commissioner is still connected, the session will be terminated, and the
|
||||
* Border Agent will cease using the ephemeral key and revert to PSKc.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aKeyString The ephemeral key string (used as PSK excluding the trailing null `\0` character).
|
||||
* @param[in] aTimeout The timeout duration in milliseconds to use the ephemeral key.
|
||||
* If zero, the default `OT_BORDER_AGENT_DEFAULT_EPHEMERAL_KEY_TIMEOUT` value will be used.
|
||||
* If the given timeout value is larger than `OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_TIMEOUT`, the
|
||||
* max value `OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_TIMEOUT` will be used instead.
|
||||
* @param[in] aUdpPort The UDP port to use with ephemeral key. If zero, an ephemeral port will be used.
|
||||
* `otBorderAgentGetUdpPort()` will return the current UDP port being used.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the ephemeral key.
|
||||
* @retval OT_ERROR_INVALID_STATE Border Agent is not running or it is connected to an external commissioner.
|
||||
* @retval OT_ERROR_INVALID_ARGS The given @p aKeyString is not valid (too short or too long).
|
||||
* @retval OT_ERROR_FAILED Failed to set the key (e.g., could not bind to UDP port).
|
||||
|
||||
*/
|
||||
otError otBorderAgentSetEphemeralKey(otInstance *aInstance,
|
||||
const char *aKeyString,
|
||||
uint32_t aTimeout,
|
||||
uint16_t aUdpPort);
|
||||
|
||||
/**
|
||||
* Cancels the ephemeral key that is in use.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE`.
|
||||
*
|
||||
* Can be used to cancel a previously set ephemeral key before it times out. If the Border Agent is not running or
|
||||
* there is no ephemeral key in use, calling this function has no effect.
|
||||
*
|
||||
* If a commissioner is connected using the ephemeral key and is currently active, calling this function does not
|
||||
* change its state. In this case the `otBorderAgentIsEphemeralKeyActive()` will continue to return `TRUE` until the
|
||||
* commissioner disconnects, or the ephemeral key timeout expires. To terminate active commissioner sessions, use the
|
||||
* `otBorderAgentDisconnect()` API.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
*/
|
||||
void otBorderAgentClearEphemeralKey(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Indicates whether or not an ephemeral key is currently active.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE`.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
*
|
||||
* @retval TRUE An ephemeral key is active.
|
||||
* @retval FALSE No ephemeral key is active.
|
||||
*/
|
||||
bool otBorderAgentIsEphemeralKeyActive(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Callback function pointer to signal changes related to the Border Agent's ephemeral key.
|
||||
*
|
||||
* This callback is invoked whenever:
|
||||
*
|
||||
* - The Border Agent starts using an ephemeral key.
|
||||
* - Any parameter related to the ephemeral key, such as the port number, changes.
|
||||
* - A commissioner candidate successfully establishes a secure session with the Border Agent using the ephemeral key.
|
||||
* This situation can be identified by `otBorderAgentGetState()` being `OT_BORDER_AGENT_STATE_ACTIVE` (this event
|
||||
* can be used to stop advertising the mDNS service "_meshcop-e._udp").
|
||||
* - The Border Agent stops using the ephemeral key due to:
|
||||
* - A direct call to `otBorderAgentClearEphemeralKey()`.
|
||||
* - The ephemeral key timing out.
|
||||
* - An external commissioner successfully using the key to connect and then disconnecting.
|
||||
* - Reaching the maximum number of allowed failed connection attempts.
|
||||
*
|
||||
* Any OpenThread API, including `otBorderAgent` APIs, can be safely called from this callback.
|
||||
*
|
||||
* @param[in] aContext A pointer to an arbitrary context (provided when callback is set).
|
||||
*/
|
||||
typedef void (*otBorderAgentEphemeralKeyCallback)(void *aContext);
|
||||
|
||||
/**
|
||||
* Sets the callback function used by the Border Agent to notify any changes related to use of ephemeral key.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE`.
|
||||
*
|
||||
* A subsequent call to this function will replace any previously set callback.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aCallback The callback function pointer.
|
||||
* @param[in] aContext The arbitrary context to use with callback.
|
||||
*/
|
||||
void otBorderAgentSetEphemeralKeyCallback(otInstance *aInstance,
|
||||
otBorderAgentEphemeralKeyCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Disconnects the Border Agent from any active secure sessions.
|
||||
*
|
||||
* If Border Agent is connected to a commissioner candidate with ephemeral key, calling this API
|
||||
* will cause the ephemeral key to be cleared after the session is disconnected.
|
||||
*
|
||||
* The Border Agent state may not change immediately upon calling this method. The state will be
|
||||
* updated when the connection update is notified with a delay.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
*/
|
||||
void otBorderAgentDisconnect(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_BORDER_AGENT_H_
|
||||
203
Libs/util/third_party/openthread/include/openthread/border_router.h
vendored
Normal file
203
Libs/util/third_party/openthread/include/openthread/border_router.h
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Border Router API.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_BORDER_ROUTER_H_
|
||||
#define OPENTHREAD_BORDER_ROUTER_H_
|
||||
|
||||
#include <openthread/border_routing.h>
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/netdata.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-border-router
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions to manage local network data with the OpenThread Border Router.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides a full or stable copy of the local Thread Network Data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aStable TRUE when copying the stable version, FALSE when copying the full version.
|
||||
* @param[out] aData A pointer to the data buffer.
|
||||
* @param[in,out] aDataLength On entry, size of the data buffer pointed to by @p aData.
|
||||
* On exit, number of copied bytes.
|
||||
*/
|
||||
otError otBorderRouterGetNetData(otInstance *aInstance, bool aStable, uint8_t *aData, uint8_t *aDataLength);
|
||||
|
||||
/**
|
||||
* Add a border router configuration to the local network data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aConfig A pointer to the border router configuration.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added the configuration to the local network data.
|
||||
* @retval OT_ERROR_INVALID_ARGS One or more configuration parameters were invalid.
|
||||
* @retval OT_ERROR_NO_BUFS Not enough room is available to add the configuration to the local network data.
|
||||
*
|
||||
* @sa otBorderRouterRemoveOnMeshPrefix
|
||||
* @sa otBorderRouterRegister
|
||||
*/
|
||||
otError otBorderRouterAddOnMeshPrefix(otInstance *aInstance, const otBorderRouterConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Remove a border router configuration from the local network data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPrefix A pointer to an IPv6 prefix.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully removed the configuration from the local network data.
|
||||
* @retval OT_ERROR_NOT_FOUND Could not find the Border Router entry.
|
||||
*
|
||||
* @sa otBorderRouterAddOnMeshPrefix
|
||||
* @sa otBorderRouterRegister
|
||||
*/
|
||||
otError otBorderRouterRemoveOnMeshPrefix(otInstance *aInstance, const otIp6Prefix *aPrefix);
|
||||
|
||||
/**
|
||||
* Gets the next On Mesh Prefix in the local Network Data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to the Network Data iterator context. To get the first on-mesh entry
|
||||
it should be set to OT_NETWORK_DATA_ITERATOR_INIT.
|
||||
* @param[out] aConfig A pointer to the On Mesh Prefix information.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully found the next On Mesh prefix.
|
||||
* @retval OT_ERROR_NOT_FOUND No subsequent On Mesh prefix exists in the Thread Network Data.
|
||||
*/
|
||||
otError otBorderRouterGetNextOnMeshPrefix(otInstance *aInstance,
|
||||
otNetworkDataIterator *aIterator,
|
||||
otBorderRouterConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Add an external route configuration to the local network data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aConfig A pointer to the external route configuration.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added the configuration to the local network data.
|
||||
* @retval OT_ERROR_INVALID_ARGS One or more configuration parameters were invalid.
|
||||
* @retval OT_ERROR_NO_BUFS Not enough room is available to add the configuration to the local network data.
|
||||
*
|
||||
* @sa otBorderRouterRemoveRoute
|
||||
* @sa otBorderRouterRegister
|
||||
*/
|
||||
otError otBorderRouterAddRoute(otInstance *aInstance, const otExternalRouteConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Remove an external route configuration from the local network data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPrefix A pointer to an IPv6 prefix.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully removed the configuration from the local network data.
|
||||
* @retval OT_ERROR_NOT_FOUND Could not find the Border Router entry.
|
||||
*
|
||||
* @sa otBorderRouterAddRoute
|
||||
* @sa otBorderRouterRegister
|
||||
*/
|
||||
otError otBorderRouterRemoveRoute(otInstance *aInstance, const otIp6Prefix *aPrefix);
|
||||
|
||||
/**
|
||||
* Gets the next external route in the local Network Data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to the Network Data iterator context. To get the first external route entry
|
||||
it should be set to OT_NETWORK_DATA_ITERATOR_INIT.
|
||||
* @param[out] aConfig A pointer to the External Route information.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully found the next External Route.
|
||||
* @retval OT_ERROR_NOT_FOUND No subsequent external route entry exists in the Thread Network Data.
|
||||
*/
|
||||
otError otBorderRouterGetNextRoute(otInstance *aInstance,
|
||||
otNetworkDataIterator *aIterator,
|
||||
otExternalRouteConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Immediately register the local network data with the Leader.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully queued a Server Data Request message for delivery.
|
||||
*
|
||||
* @sa otBorderRouterAddOnMeshPrefix
|
||||
* @sa otBorderRouterRemoveOnMeshPrefix
|
||||
* @sa otBorderRouterAddRoute
|
||||
* @sa otBorderRouterRemoveRoute
|
||||
*/
|
||||
otError otBorderRouterRegister(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Function pointer callback which is invoked when Network Data (local or leader) gets full.
|
||||
*
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*/
|
||||
typedef void (*otBorderRouterNetDataFullCallback)(void *aContext);
|
||||
|
||||
/**
|
||||
* Sets the callback to indicate when Network Data gets full.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL`.
|
||||
*
|
||||
* The callback is invoked whenever:
|
||||
* - The device is acting as a leader and receives a Network Data registration from a Border Router (BR) that it cannot
|
||||
* add to Network Data (running out of space).
|
||||
* - The device is acting as a BR and new entries cannot be added to its local Network Data.
|
||||
* - The device is acting as a BR and tries to register its local Network Data entries with the leader, but determines
|
||||
* that its local entries will not fit.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback The callback.
|
||||
* @param[in] aContext A pointer to arbitrary context information used with @p aCallback.
|
||||
*/
|
||||
void otBorderRouterSetNetDataFullCallback(otInstance *aInstance,
|
||||
otBorderRouterNetDataFullCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_BORDER_ROUTER_H_
|
||||
585
Libs/util/third_party/openthread/include/openthread/border_routing.h
vendored
Normal file
585
Libs/util/third_party/openthread/include/openthread/border_routing.h
vendored
Normal file
@@ -0,0 +1,585 @@
|
||||
/*
|
||||
* Copyright (c) 2021-22, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Border Routing Manager API.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_BORDER_ROUTING_H_
|
||||
#define OPENTHREAD_BORDER_ROUTING_H_
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/netdata.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-border-routing
|
||||
*
|
||||
* @brief
|
||||
* This module includes definitions related to Border Routing Manager.
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* All the functions in this module require `OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE` to be enabled.
|
||||
*
|
||||
* Border Routing Manager handles bi-directional routing between Thread network and adjacent infrastructure link (AIL).
|
||||
*
|
||||
* It emits ICMRv6 ND Router Advertisement (RA) messages on AIL to advertise on-link and route prefixes. It also
|
||||
* processes received RA messages from infrastructure and mirrors the discovered prefixes on the Thread Network Data to
|
||||
* ensure devices on Thread mesh can reach AIL through the Border Router.
|
||||
*
|
||||
* Routing Manager manages the Off-Mesh Routable (OMR) prefix on the Thread Network data which configures Thread
|
||||
* devices with a suitable Off-Mesh Routable IPv6 address. It announces the reachability of this prefix on AIL by
|
||||
* including it in the emitted RA messages as an IPv6 Route Information Option (RIO).
|
||||
*
|
||||
* Routing Manager also monitors and adds on-link prefix on the infrastructure network. If a router on AIL is already
|
||||
* providing RA messages containing an IPv6 Prefix Information Option (PIO) that enables IPv6 devices on the link to
|
||||
* self-configure their own routable unicast IPv6 address, this address can be used by Thread devices to reach AIL. If
|
||||
* Border Router finds no such RA message on AIL, it generates a ULA on-link prefix which it then advertises on AIL in
|
||||
* the emitted RA messages.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents an iterator to iterate through the Border Router's discovered prefix table.
|
||||
*
|
||||
* The fields in this type are opaque (intended for use by OpenThread core only) and therefore should not be
|
||||
* accessed or used by caller.
|
||||
*
|
||||
* Before using an iterator, it MUST be initialized using `otBorderRoutingPrefixTableInitIterator()`.
|
||||
*/
|
||||
typedef struct otBorderRoutingPrefixTableIterator
|
||||
{
|
||||
const void *mPtr1;
|
||||
const void *mPtr2;
|
||||
uint32_t mData0;
|
||||
uint32_t mData1;
|
||||
uint8_t mData2;
|
||||
uint8_t mData3;
|
||||
} otBorderRoutingPrefixTableIterator;
|
||||
|
||||
/**
|
||||
* Represents a discovered router on the infrastructure link.
|
||||
*
|
||||
* The `mIsPeerBr` field requires `OPENTHREAD_CONFIG_BORDER_ROUTING_TRACK_PEER_BR_INFO_ENABLE`. Routing Manager
|
||||
* determines whether the router is a peer BR (connected to the same Thread mesh network) by comparing its advertised
|
||||
* PIO/RIO prefixes with the entries in the Thread Network Data. While this method is generally effective, it may not
|
||||
* be 100% accurate in all scenarios, so the `mIsPeerBr` flag should be used with caution.
|
||||
*/
|
||||
typedef struct otBorderRoutingRouterEntry
|
||||
{
|
||||
otIp6Address mAddress; ///< IPv6 address of the router.
|
||||
uint32_t mMsecSinceLastUpdate; ///< Milliseconds since last update (any message rx) from this router.
|
||||
uint32_t mAge; ///< The router's age in seconds (duration since its first discovery).
|
||||
bool mManagedAddressConfigFlag : 1; ///< The router's Managed Address Config flag (`M` flag).
|
||||
bool mOtherConfigFlag : 1; ///< The router's Other Config flag (`O` flag).
|
||||
bool mSnacRouterFlag : 1; ///< The router's SNAC Router flag (`S` flag).
|
||||
bool mIsLocalDevice : 1; ///< This router is the local device (this BR).
|
||||
bool mIsReachable : 1; ///< This router is reachable.
|
||||
bool mIsPeerBr : 1; ///< This router is (likely) a peer BR.
|
||||
} otBorderRoutingRouterEntry;
|
||||
|
||||
/**
|
||||
* Represents an entry from the discovered prefix table.
|
||||
*
|
||||
* The entries in the discovered table track the Prefix/Route Info Options in the received Router Advertisement messages
|
||||
* from other routers on the infrastructure link.
|
||||
*/
|
||||
typedef struct otBorderRoutingPrefixTableEntry
|
||||
{
|
||||
otBorderRoutingRouterEntry mRouter; ///< Information about the router advertising this prefix.
|
||||
otIp6Prefix mPrefix; ///< The discovered IPv6 prefix.
|
||||
bool mIsOnLink; ///< Indicates whether the prefix is on-link or route prefix.
|
||||
uint32_t mMsecSinceLastUpdate; ///< Milliseconds since last update of this prefix.
|
||||
uint32_t mValidLifetime; ///< Valid lifetime of the prefix (in seconds).
|
||||
otRoutePreference mRoutePreference; ///< Route preference when `mIsOnlink` is false.
|
||||
uint32_t mPreferredLifetime; ///< Preferred lifetime of the on-link prefix when `mIsOnLink`.
|
||||
} otBorderRoutingPrefixTableEntry;
|
||||
|
||||
/**
|
||||
* Represents information about a peer Border Router found in the Network Data.
|
||||
*/
|
||||
typedef struct otBorderRoutingPeerBorderRouterEntry
|
||||
{
|
||||
uint16_t mRloc16; ///< The RLOC16 of BR.
|
||||
uint32_t mAge; ///< Seconds since the BR appeared in the Network Data.
|
||||
} otBorderRoutingPeerBorderRouterEntry;
|
||||
|
||||
/**
|
||||
* Represents a group of data of platform-generated RA messages processed.
|
||||
*/
|
||||
typedef struct otPdProcessedRaInfo
|
||||
{
|
||||
uint32_t mNumPlatformRaReceived; ///< The number of platform generated RA handled by ProcessPlatformGeneratedRa.
|
||||
uint32_t mNumPlatformPioProcessed; ///< The number of PIO processed for adding OMR prefixes.
|
||||
uint32_t mLastPlatformRaMsec; ///< The timestamp of last processed RA message.
|
||||
} otPdProcessedRaInfo;
|
||||
|
||||
/**
|
||||
* Represents the state of Border Routing Manager.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_BORDER_ROUTING_STATE_UNINITIALIZED, ///< Routing Manager is uninitialized.
|
||||
OT_BORDER_ROUTING_STATE_DISABLED, ///< Routing Manager is initialized but disabled.
|
||||
OT_BORDER_ROUTING_STATE_STOPPED, ///< Routing Manager in initialized and enabled but currently stopped.
|
||||
OT_BORDER_ROUTING_STATE_RUNNING, ///< Routing Manager is initialized, enabled, and running.
|
||||
} otBorderRoutingState;
|
||||
|
||||
/**
|
||||
* This enumeration represents the state of DHCPv6 Prefix Delegation State.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_BORDER_ROUTING_DHCP6_PD_STATE_DISABLED, ///< DHCPv6 PD is disabled on the border router.
|
||||
OT_BORDER_ROUTING_DHCP6_PD_STATE_STOPPED, ///< DHCPv6 PD in enabled but won't try to request and publish a prefix.
|
||||
OT_BORDER_ROUTING_DHCP6_PD_STATE_RUNNING, ///< DHCPv6 PD is enabled and will try to request and publish a prefix.
|
||||
OT_BORDER_ROUTING_DHCP6_PD_STATE_IDLE, ///< DHCPv6 PD is idle; Higher-prf prefix published by other BRs.
|
||||
} otBorderRoutingDhcp6PdState;
|
||||
|
||||
/**
|
||||
* Initializes the Border Routing Manager on given infrastructure interface.
|
||||
*
|
||||
* @note This method MUST be called before any other otBorderRouting* APIs.
|
||||
* @note This method can be re-called to change the infrastructure interface, but the Border Routing Manager should be
|
||||
* disabled first, and re-enabled after.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aInfraIfIndex The infrastructure interface index.
|
||||
* @param[in] aInfraIfIsRunning A boolean that indicates whether the infrastructure
|
||||
* interface is running.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the Border Routing Manager on given infrastructure.
|
||||
* @retval OT_ERROR_INVALID_STATE The Border Routing Manager is in a state other than disabled or uninitialized.
|
||||
* @retval OT_ERROR_INVALID_ARGS The index of the infrastructure interface is not valid.
|
||||
* @retval OT_ERROR_FAILED Internal failure. Usually due to failure in generating random prefixes.
|
||||
*
|
||||
* @sa otPlatInfraIfStateChanged.
|
||||
* @sa otBorderRoutingSetEnabled.
|
||||
*/
|
||||
otError otBorderRoutingInit(otInstance *aInstance, uint32_t aInfraIfIndex, bool aInfraIfIsRunning);
|
||||
|
||||
/**
|
||||
* Enables or disables the Border Routing Manager.
|
||||
*
|
||||
* @note The Border Routing Manager is disabled by default.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnabled A boolean to enable/disable the routing manager.
|
||||
*
|
||||
* @retval OT_ERROR_INVALID_STATE The Border Routing Manager is not initialized yet.
|
||||
* @retval OT_ERROR_NONE Successfully enabled/disabled the Border Routing Manager.
|
||||
*/
|
||||
otError otBorderRoutingSetEnabled(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Gets the current state of Border Routing Manager.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The current state of Border Routing Manager.
|
||||
*/
|
||||
otBorderRoutingState otBorderRoutingGetState(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the current preference used when advertising Route Info Options (RIO) in Router Advertisement
|
||||
* messages sent over the infrastructure link.
|
||||
*
|
||||
* The RIO preference is determined as follows:
|
||||
*
|
||||
* - If explicitly set by user by calling `otBorderRoutingSetRouteInfoOptionPreference()`, the given preference is
|
||||
* used.
|
||||
* - Otherwise, it is determined based on device's current role: Medium preference when in router/leader role and
|
||||
* low preference when in child role.
|
||||
*
|
||||
* @returns The current Route Info Option preference.
|
||||
*/
|
||||
otRoutePreference otBorderRoutingGetRouteInfoOptionPreference(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Explicitly sets the preference to use when advertising Route Info Options (RIO) in Router
|
||||
* Advertisement messages sent over the infrastructure link.
|
||||
*
|
||||
* After a call to this function, BR will use the given preference for all its advertised RIOs. The preference can be
|
||||
* cleared by calling `otBorderRoutingClearRouteInfoOptionPreference()`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPreference The route preference to use.
|
||||
*/
|
||||
void otBorderRoutingSetRouteInfoOptionPreference(otInstance *aInstance, otRoutePreference aPreference);
|
||||
|
||||
/**
|
||||
* Clears a previously set preference value for advertised Route Info Options.
|
||||
*
|
||||
* After a call to this function, BR will use device's role to determine the RIO preference: Medium preference when
|
||||
* in router/leader role and low preference when in child role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otBorderRoutingClearRouteInfoOptionPreference(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets additional options to append at the end of emitted Router Advertisement (RA) messages.
|
||||
*
|
||||
* The content of @p aOptions is copied internally, so it can be a temporary buffer (e.g., a stack allocated array).
|
||||
*
|
||||
* Subsequent calls to this function overwrite the previously set value.
|
||||
*
|
||||
* @param[in] aOptions A pointer to the encoded options. Can be `NULL` to clear.
|
||||
* @param[in] aLength Number of bytes in @p aOptions.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the extra option bytes.
|
||||
* @retval OT_ERROR_NO_BUFS Could not allocate buffer to save the buffer.
|
||||
*/
|
||||
otError otBorderRoutingSetExtraRouterAdvertOptions(otInstance *aInstance, const uint8_t *aOptions, uint16_t aLength);
|
||||
|
||||
/**
|
||||
* Gets the current preference used for published routes in Network Data.
|
||||
*
|
||||
* The preference is determined as follows:
|
||||
*
|
||||
* - If explicitly set by user by calling `otBorderRoutingSetRoutePreference()`, the given preference is used.
|
||||
* - Otherwise, it is determined automatically by `RoutingManager` based on the device's role and link quality.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The current published route preference.
|
||||
*/
|
||||
otRoutePreference otBorderRoutingGetRoutePreference(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Explicitly sets the preference of published routes in Network Data.
|
||||
*
|
||||
* After a call to this function, BR will use the given preference. The preference can be cleared by calling
|
||||
* `otBorderRoutingClearRoutePreference()`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPreference The route preference to use.
|
||||
*/
|
||||
void otBorderRoutingSetRoutePreference(otInstance *aInstance, otRoutePreference aPreference);
|
||||
|
||||
/**
|
||||
* Clears a previously set preference value for published routes in Network Data.
|
||||
*
|
||||
* After a call to this function, BR will determine the preference automatically based on the device's role and
|
||||
* link quality (to the parent when acting as end-device).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otBorderRoutingClearRoutePreference(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the local Off-Mesh-Routable (OMR) Prefix, for example `fdfc:1ff5:1512:5622::/64`.
|
||||
*
|
||||
* An OMR Prefix is a randomly generated 64-bit prefix that's published in the
|
||||
* Thread network if there isn't already an OMR prefix. This prefix can be reached
|
||||
* from the local Wi-Fi or Ethernet network.
|
||||
*
|
||||
* Note: When DHCPv6 PD is enabled, the border router may publish the prefix from
|
||||
* DHCPv6 PD.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aPrefix A pointer to where the prefix will be output to.
|
||||
*
|
||||
* @retval OT_ERROR_INVALID_STATE The Border Routing Manager is not initialized yet.
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the OMR prefix.
|
||||
*
|
||||
* @sa otBorderRoutingGetPdOmrPrefix
|
||||
*/
|
||||
otError otBorderRoutingGetOmrPrefix(otInstance *aInstance, otIp6Prefix *aPrefix);
|
||||
|
||||
/**
|
||||
* Gets the DHCPv6 Prefix Delegation (PD) provided off-mesh-routable (OMR) prefix.
|
||||
*
|
||||
* Only mPrefix, mValidLifetime and mPreferredLifetime fields are used in the returned prefix info.
|
||||
*
|
||||
* `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE` must be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aPrefixInfo A pointer to where the prefix info will be output to.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the OMR prefix.
|
||||
* @retval OT_ERROR_INVALID_STATE The Border Routing Manager is not initialized yet.
|
||||
* @retval OT_ERROR_NOT_FOUND There are no valid PD prefix on this BR.
|
||||
*
|
||||
* @sa otBorderRoutingGetOmrPrefix
|
||||
* @sa otPlatBorderRoutingProcessIcmp6Ra
|
||||
*/
|
||||
otError otBorderRoutingGetPdOmrPrefix(otInstance *aInstance, otBorderRoutingPrefixTableEntry *aPrefixInfo);
|
||||
|
||||
/**
|
||||
* Gets the data of platform generated RA message processed..
|
||||
*
|
||||
* `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE` must be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aPrefixInfo A pointer to where the prefix info will be output to.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the Info.
|
||||
* @retval OT_ERROR_INVALID_STATE The Border Routing Manager is not initialized yet.
|
||||
* @retval OT_ERROR_NOT_FOUND There are no valid Info on this BR.
|
||||
*/
|
||||
otError otBorderRoutingGetPdProcessedRaInfo(otInstance *aInstance, otPdProcessedRaInfo *aPdProcessedRaInfo);
|
||||
|
||||
/**
|
||||
* Gets the currently favored Off-Mesh-Routable (OMR) Prefix.
|
||||
*
|
||||
* The favored OMR prefix can be discovered from Network Data or can be this device's local OMR prefix.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aPrefix A pointer to output the favored OMR prefix.
|
||||
* @param[out] aPreference A pointer to output the preference associated the favored prefix.
|
||||
*
|
||||
* @retval OT_ERROR_INVALID_STATE The Border Routing Manager is not running yet.
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the favored OMR prefix.
|
||||
*/
|
||||
otError otBorderRoutingGetFavoredOmrPrefix(otInstance *aInstance, otIp6Prefix *aPrefix, otRoutePreference *aPreference);
|
||||
|
||||
/**
|
||||
* Gets the local On-Link Prefix for the adjacent infrastructure link.
|
||||
*
|
||||
* The local On-Link Prefix is a 64-bit prefix that's advertised on the infrastructure link if there isn't already a
|
||||
* usable on-link prefix being advertised on the link.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aPrefix A pointer to where the prefix will be output to.
|
||||
*
|
||||
* @retval OT_ERROR_INVALID_STATE The Border Routing Manager is not initialized yet.
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the local on-link prefix.
|
||||
*/
|
||||
otError otBorderRoutingGetOnLinkPrefix(otInstance *aInstance, otIp6Prefix *aPrefix);
|
||||
|
||||
/**
|
||||
* Gets the currently favored On-Link Prefix.
|
||||
*
|
||||
* The favored prefix is either a discovered on-link prefix on the infrastructure link or the local on-link prefix.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aPrefix A pointer to where the prefix will be output to.
|
||||
*
|
||||
* @retval OT_ERROR_INVALID_STATE The Border Routing Manager is not initialized yet.
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the favored on-link prefix.
|
||||
*/
|
||||
otError otBorderRoutingGetFavoredOnLinkPrefix(otInstance *aInstance, otIp6Prefix *aPrefix);
|
||||
|
||||
/**
|
||||
* Gets the local NAT64 Prefix of the Border Router.
|
||||
*
|
||||
* NAT64 Prefix might not be advertised in the Thread network.
|
||||
*
|
||||
* `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` must be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aPrefix A pointer to where the prefix will be output to.
|
||||
*
|
||||
* @retval OT_ERROR_INVALID_STATE The Border Routing Manager is not initialized yet.
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the NAT64 prefix.
|
||||
*/
|
||||
otError otBorderRoutingGetNat64Prefix(otInstance *aInstance, otIp6Prefix *aPrefix);
|
||||
|
||||
/**
|
||||
* Gets the currently favored NAT64 prefix.
|
||||
*
|
||||
* The favored NAT64 prefix can be discovered from infrastructure link or can be this device's local NAT64 prefix.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aPrefix A pointer to output the favored NAT64 prefix.
|
||||
* @param[out] aPreference A pointer to output the preference associated the favored prefix.
|
||||
*
|
||||
* @retval OT_ERROR_INVALID_STATE The Border Routing Manager is not initialized yet.
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the favored NAT64 prefix.
|
||||
*/
|
||||
otError otBorderRoutingGetFavoredNat64Prefix(otInstance *aInstance,
|
||||
otIp6Prefix *aPrefix,
|
||||
otRoutePreference *aPreference);
|
||||
|
||||
/**
|
||||
* Initializes an `otBorderRoutingPrefixTableIterator`.
|
||||
*
|
||||
* An iterator MUST be initialized before it is used.
|
||||
*
|
||||
* An iterator can be initialized again to restart from the beginning of the table.
|
||||
*
|
||||
* When iterating over entries in the table, to ensure the update times `mMsecSinceLastUpdate` of entries are
|
||||
* consistent, they are given relative to the time the iterator was initialized.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[out] aIterator A pointer to the iterator to initialize.
|
||||
*/
|
||||
void otBorderRoutingPrefixTableInitIterator(otInstance *aInstance, otBorderRoutingPrefixTableIterator *aIterator);
|
||||
|
||||
/**
|
||||
* Iterates over the entries in the Border Router's discovered prefix table.
|
||||
*
|
||||
* Prefix entries associated with the same discovered router on an infrastructure link are guaranteed to be grouped
|
||||
* together (retrieved back-to-back).
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to the iterator.
|
||||
* @param[out] aEntry A pointer to the entry to populate.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Iterated to the next entry, @p aEntry and @p aIterator are updated.
|
||||
* @retval OT_ERROR_NOT_FOUND No more entries in the table.
|
||||
*/
|
||||
otError otBorderRoutingGetNextPrefixTableEntry(otInstance *aInstance,
|
||||
otBorderRoutingPrefixTableIterator *aIterator,
|
||||
otBorderRoutingPrefixTableEntry *aEntry);
|
||||
|
||||
/**
|
||||
* Iterates over the discovered router entries on the infrastructure link.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to the iterator.
|
||||
* @param[out] aEntry A pointer to the entry to populate.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Iterated to the next router, @p aEntry and @p aIterator are updated.
|
||||
* @retval OT_ERROR_NOT_FOUND No more router entries.
|
||||
*/
|
||||
otError otBorderRoutingGetNextRouterEntry(otInstance *aInstance,
|
||||
otBorderRoutingPrefixTableIterator *aIterator,
|
||||
otBorderRoutingRouterEntry *aEntry);
|
||||
|
||||
/**
|
||||
* Iterates over the peer BRs found in the Network Data.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_BORDER_ROUTING_TRACK_PEER_BR_INFO_ENABLE`.
|
||||
*
|
||||
* Peer BRs are other devices within the Thread mesh that provide external IP connectivity. A device is considered
|
||||
* to provide external IP connectivity if at least one of the following conditions is met regarding its Network Data
|
||||
* entries:
|
||||
*
|
||||
* - It has added at least one external route entry.
|
||||
* - It has added at least one prefix entry with both the default-route and on-mesh flags set.
|
||||
* - It has added at least one domain prefix (with both the domain and on-mesh flags set).
|
||||
*
|
||||
* The list of peer BRs specifically excludes the current device, even if it is itself acting as a BR.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to the iterator.
|
||||
* @param[out] aEntry A pointer to the entry to populate.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Iterated to the next entry, @p aEntry and @p aIterator are updated.
|
||||
* @retval OT_ERROR_NOT_FOUND No more entries.
|
||||
*/
|
||||
otError otBorderRoutingGetNextPeerBrEntry(otInstance *aInstance,
|
||||
otBorderRoutingPrefixTableIterator *aIterator,
|
||||
otBorderRoutingPeerBorderRouterEntry *aEntry);
|
||||
|
||||
/**
|
||||
* Returns the number of peer BRs found in the Network Data.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_BORDER_ROUTING_TRACK_PEER_BR_INFO_ENABLE`.
|
||||
*
|
||||
* Peer BRs are other devices within the Thread mesh that provide external IP connectivity. A device is considered
|
||||
* to provide external IP connectivity if at least one of the following conditions is met regarding its Network Data
|
||||
* entries:
|
||||
*
|
||||
* - It has added at least one external route entry.
|
||||
* - It has added at least one prefix entry with both the default-route and on-mesh flags set.
|
||||
* - It has added at least one domain prefix (with both the domain and on-mesh flags set).
|
||||
*
|
||||
* The list of peer BRs specifically excludes the current device, even if it is itself acting as a BR.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[out] aMinAge Pointer to an `uint32_t` to return the minimum age among all peer BRs.
|
||||
* Can be NULL if the caller does not need this information.
|
||||
* Age is represented as seconds since appearance of the BR entry in the Network Data.
|
||||
*
|
||||
* @returns The number of peer BRs.
|
||||
*/
|
||||
uint16_t otBorderRoutingCountPeerBrs(otInstance *aInstance, uint32_t *aMinAge);
|
||||
|
||||
/**
|
||||
* Enables / Disables DHCPv6 Prefix Delegation.
|
||||
*
|
||||
* `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE` must be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnabled Whether to accept platform generated RA messages.
|
||||
*/
|
||||
void otBorderRoutingDhcp6PdSetEnabled(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Gets the current state of DHCPv6 Prefix Delegation.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE` to be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The current state of DHCPv6 Prefix Delegation.
|
||||
*/
|
||||
otBorderRoutingDhcp6PdState otBorderRoutingDhcp6PdGetState(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* When the state of a DHCPv6 Prefix Delegation (PD) on the Thread interface changes, this callback notifies processes
|
||||
* in the OS of this changed state.
|
||||
*
|
||||
* @param[in] aState The state of DHCPv6 Prefix Delegation State.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*/
|
||||
typedef void (*otBorderRoutingRequestDhcp6PdCallback)(otBorderRoutingDhcp6PdState aState, void *aContext);
|
||||
|
||||
/**
|
||||
* Sets the callback whenever the DHCPv6 PD state changes on the Thread interface.
|
||||
*
|
||||
* Subsequent calls to this function replace the previously set callback.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback A pointer to a function that is called whenever the DHCPv6 PD state changes.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*/
|
||||
void otBorderRoutingDhcp6PdSetRequestCallback(otInstance *aInstance,
|
||||
otBorderRoutingRequestDhcp6PdCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Sets the local on-link prefix.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_BORDER_ROUTING_TESTING_API_ENABLE`.
|
||||
*
|
||||
* This is intended for testing only and using it will make the BR non-compliant with the Thread Specification.
|
||||
*
|
||||
* @param[in] aPrefix The on-link prefix to use.
|
||||
*/
|
||||
void otBorderRoutingSetOnLinkPrefix(otInstance *aInstance, const otIp6Prefix *aPrefix);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_BORDER_ROUTING_H_
|
||||
290
Libs/util/third_party/openthread/include/openthread/channel_manager.h
vendored
Normal file
290
Libs/util/third_party/openthread/include/openthread/channel_manager.h
vendored
Normal file
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the OpenThread API for Channel Manager module.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_CHANNEL_MANAGER_H_
|
||||
#define OPENTHREAD_CHANNEL_MANAGER_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-channel-manager
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions for Channel Manager.
|
||||
*
|
||||
* The functions in this module are available when Channel Manager features
|
||||
* `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` or `OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE &&
|
||||
* OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE` are enabled. Channel Manager behavior depends on the
|
||||
* device role. It manages the network-wide PAN channel on a Full Thread Device in rx-on-when-idle mode, or with
|
||||
* `OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE && OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE` set,
|
||||
* selects CSL channel in synchronized rx-off-when-idle mode. On a Minimal Thread Device
|
||||
* `OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE && OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE` selects
|
||||
* the CSL channel.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Requests a Thread network channel change.
|
||||
*
|
||||
* The network switches to the given channel after a specified delay (see #otChannelManagerSetDelay()). The channel
|
||||
* change is performed by updating the Pending Operational Dataset.
|
||||
*
|
||||
* A subsequent call will cancel an ongoing previously requested channel change.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aChannel The new channel for the Thread network.
|
||||
*/
|
||||
void otChannelManagerRequestChannelChange(otInstance *aInstance, uint8_t aChannel);
|
||||
|
||||
/**
|
||||
* Gets the channel from the last successful call to `otChannelManagerRequestChannelChange()`
|
||||
*
|
||||
* @returns The last requested channel or zero if there has been no channel change request yet.
|
||||
*/
|
||||
uint8_t otChannelManagerGetRequestedChannel(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the delay (in seconds) used by Channel Manager for a network channel change.
|
||||
*
|
||||
* Only available on FTDs.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The delay (in seconds) for channel change.
|
||||
*/
|
||||
uint16_t otChannelManagerGetDelay(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the delay (in seconds) used for a network channel change.
|
||||
*
|
||||
* Only available on FTDs. The delay should preferably be longer than the maximum data poll interval used by all
|
||||
* Sleepy End Devices within the Thread network.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDelay Delay in seconds.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Delay was updated successfully.
|
||||
* @retval OT_ERROR_INVALID_ARGS The given delay @p aDelay is too short.
|
||||
*/
|
||||
otError otChannelManagerSetDelay(otInstance *aInstance, uint16_t aDelay);
|
||||
|
||||
/**
|
||||
* Requests that `ChannelManager` checks and selects a new channel and starts a channel change.
|
||||
*
|
||||
* Unlike the `otChannelManagerRequestChannelChange()` where the channel must be given as a parameter, this function
|
||||
* asks the `ChannelManager` to select a channel by itself (based on collected channel quality info).
|
||||
*
|
||||
* Once called, the Channel Manager will perform the following 3 steps:
|
||||
*
|
||||
* 1) `ChannelManager` decides if the channel change would be helpful. This check can be skipped if
|
||||
* `aSkipQualityCheck` is set to true (forcing a channel selection to happen and skipping the quality check).
|
||||
* This step uses the collected link quality metrics on the device (such as CCA failure rate, frame and message
|
||||
* error rates per neighbor, etc.) to determine if the current channel quality is at the level that justifies
|
||||
* a channel change.
|
||||
*
|
||||
* 2) If the first step passes, then `ChannelManager` selects a potentially better channel. It uses the collected
|
||||
* channel quality data by `ChannelMonitor` module. The supported and favored channels are used at this step.
|
||||
* (see `otChannelManagerSetSupportedChannels()` and `otChannelManagerSetFavoredChannels()`).
|
||||
*
|
||||
* 3) If the newly selected channel is different from the current channel, `ChannelManager` requests/starts the
|
||||
* channel change process (internally invoking a `RequestChannelChange()`).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aSkipQualityCheck Indicates whether the quality check (step 1) should be skipped.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Channel selection finished successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND Supported channel mask is empty, therefore could not select a channel.
|
||||
*/
|
||||
otError otChannelManagerRequestChannelSelect(otInstance *aInstance, bool aSkipQualityCheck);
|
||||
|
||||
/**
|
||||
* Requests that `ChannelManager` checks and selects a new CSL channel and starts a CSL channel change.
|
||||
*
|
||||
* Only available with `OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE &&
|
||||
* OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE`. This function asks the `ChannelManager` to select a
|
||||
* channel by itself (based on collected channel quality info).
|
||||
*
|
||||
* Once called, the Channel Manager will perform the following 3 steps:
|
||||
*
|
||||
* 1) `ChannelManager` decides if the CSL channel change would be helpful. This check can be skipped if
|
||||
* `aSkipQualityCheck` is set to true (forcing a CSL channel selection to happen and skipping the quality check).
|
||||
* This step uses the collected link quality metrics on the device (such as CCA failure rate, frame and message
|
||||
* error rates per neighbor, etc.) to determine if the current channel quality is at the level that justifies
|
||||
* a CSL channel change.
|
||||
*
|
||||
* 2) If the first step passes, then `ChannelManager` selects a potentially better CSL channel. It uses the collected
|
||||
* channel quality data by `ChannelMonitor` module. The supported and favored channels are used at this step.
|
||||
* (see `otChannelManagerSetSupportedChannels()` and `otChannelManagerSetFavoredChannels()`).
|
||||
*
|
||||
* 3) If the newly selected CSL channel is different from the current CSL channel, `ChannelManager` starts the
|
||||
* CSL channel change process.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aSkipQualityCheck Indicates whether the quality check (step 1) should be skipped.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Channel selection finished successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND Supported channel mask is empty, therefore could not select a channel.
|
||||
*/
|
||||
otError otChannelManagerRequestCslChannelSelect(otInstance *aInstance, bool aSkipQualityCheck);
|
||||
|
||||
/**
|
||||
* Enables or disables the auto-channel-selection functionality for network channel.
|
||||
*
|
||||
* When enabled, `ChannelManager` will periodically invoke a `RequestChannelSelect(false)`. The period interval
|
||||
* can be set by `otChannelManagerSetAutoChannelSelectionInterval()`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnabled Indicates whether to enable or disable this functionality.
|
||||
*/
|
||||
void otChannelManagerSetAutoChannelSelectionEnabled(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Indicates whether the auto-channel-selection functionality for a network channel is enabled or not.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns TRUE if enabled, FALSE if disabled.
|
||||
*/
|
||||
bool otChannelManagerGetAutoChannelSelectionEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Enables or disables the auto-channel-selection functionality for a CSL channel.
|
||||
*
|
||||
* Only available with `OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE &&
|
||||
* OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE`. When enabled, `ChannelManager` will periodically invoke
|
||||
* a `otChannelManagerRequestCslChannelSelect()`. The period interval can be set by
|
||||
* `otChannelManagerSetAutoChannelSelectionInterval()`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnabled Indicates whether to enable or disable this functionality.
|
||||
*/
|
||||
void otChannelManagerSetAutoCslChannelSelectionEnabled(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Indicates whether the auto-csl-channel-selection functionality is enabled or not.
|
||||
*
|
||||
* Only available with `OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE &&
|
||||
* OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns TRUE if enabled, FALSE if disabled.
|
||||
*/
|
||||
bool otChannelManagerGetAutoCslChannelSelectionEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the period interval (in seconds) used by auto-channel-selection functionality.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aInterval The interval in seconds.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The interval was set successfully.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aInterval is not valid (zero).
|
||||
*/
|
||||
otError otChannelManagerSetAutoChannelSelectionInterval(otInstance *aInstance, uint32_t aInterval);
|
||||
|
||||
/**
|
||||
* Gets the period interval (in seconds) used by auto-channel-selection functionality.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The interval in seconds.
|
||||
*/
|
||||
uint32_t otChannelManagerGetAutoChannelSelectionInterval(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the supported channel mask.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The supported channels as a bit-mask.
|
||||
*/
|
||||
uint32_t otChannelManagerGetSupportedChannels(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the supported channel mask.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aChannelMask A channel mask.
|
||||
*/
|
||||
void otChannelManagerSetSupportedChannels(otInstance *aInstance, uint32_t aChannelMask);
|
||||
|
||||
/**
|
||||
* Gets the favored channel mask.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The favored channels as a bit-mask.
|
||||
*/
|
||||
uint32_t otChannelManagerGetFavoredChannels(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the favored channel mask.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aChannelMask A channel mask.
|
||||
*/
|
||||
void otChannelManagerSetFavoredChannels(otInstance *aInstance, uint32_t aChannelMask);
|
||||
|
||||
/**
|
||||
* Gets the CCA failure rate threshold.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The CCA failure rate threshold. Value 0 maps to 0% and 0xffff maps to 100%.
|
||||
*/
|
||||
uint16_t otChannelManagerGetCcaFailureRateThreshold(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the CCA failure rate threshold.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aThreshold A CCA failure rate threshold. Value 0 maps to 0% and 0xffff maps to 100%.
|
||||
*/
|
||||
void otChannelManagerSetCcaFailureRateThreshold(otInstance *aInstance, uint16_t aThreshold);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_CHANNEL_MANAGER_H_
|
||||
158
Libs/util/third_party/openthread/include/openthread/channel_monitor.h
vendored
Normal file
158
Libs/util/third_party/openthread/include/openthread/channel_monitor.h
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the OpenThread API for channel monitoring feature
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_CHANNEL_MONITOR_H_
|
||||
#define OPENTHREAD_CHANNEL_MONITOR_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-channel-monitor
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions for channel monitoring feature.
|
||||
*
|
||||
* The functions in this module are available when channel monitor feature
|
||||
* (`OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE`) is enabled.
|
||||
*
|
||||
* Channel monitoring will periodically monitor all channels to help determine the cleaner channels (channels
|
||||
* with less interference).
|
||||
*
|
||||
* When channel monitoring is active, a zero-duration Energy Scan is performed, collecting a single RSSI sample on
|
||||
* every channel per sample interval. The RSSI samples are compared with a pre-specified RSSI threshold. As an
|
||||
* indicator of channel quality, the channel monitoring module maintains and provides the average rate/percentage of
|
||||
* RSSI samples that are above the threshold within (approximately) a specified sample window (referred to as channel
|
||||
* occupancy).
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enables or disables the Channel Monitoring operation.
|
||||
*
|
||||
* Once operation starts, any previously collected data is cleared. However, after operation is disabled, the previous
|
||||
* collected data is still valid and can be read.
|
||||
*
|
||||
* @note OpenThread core internally enables or disables the Channel Monitoring operation when the IPv6 interface is
|
||||
* brought up or down, for example in a call to `otIp6SetEnabled()`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnabled TRUE to enable/start Channel Monitoring operation, FALSE to disable/stop it.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Channel Monitoring state changed successfully
|
||||
* @retval OT_ERROR_ALREADY Channel Monitoring is already in the same state.
|
||||
*/
|
||||
otError otChannelMonitorSetEnabled(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Indicates whether the Channel Monitoring operation is enabled and running.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns TRUE if the Channel Monitoring operation is enabled, FALSE otherwise.
|
||||
*/
|
||||
bool otChannelMonitorIsEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get channel monitoring sample interval in milliseconds.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The channel monitor sample interval in milliseconds.
|
||||
*/
|
||||
uint32_t otChannelMonitorGetSampleInterval(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get channel monitoring RSSI threshold in dBm.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The RSSI threshold in dBm.
|
||||
*/
|
||||
int8_t otChannelMonitorGetRssiThreshold(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get channel monitoring averaging sample window length (number of samples).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The averaging sample window.
|
||||
*/
|
||||
uint32_t otChannelMonitorGetSampleWindow(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get channel monitoring total number of RSSI samples (per channel).
|
||||
*
|
||||
* The count indicates total number samples per channel by channel monitoring module since its start (since Thread
|
||||
* network interface was enabled).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns Total number of RSSI samples (per channel) taken so far.
|
||||
*/
|
||||
uint32_t otChannelMonitorGetSampleCount(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the current channel occupancy for a given channel.
|
||||
*
|
||||
* The channel occupancy value represents the average rate/percentage of RSSI samples that were above RSSI threshold
|
||||
* ("bad" RSSI samples).
|
||||
*
|
||||
* For the first "sample window" samples, the average is maintained as the actual percentage (i.e., ratio of number
|
||||
* of "bad" samples by total number of samples). After "window" samples, the averager uses an exponentially
|
||||
* weighted moving average. Practically, this means the average is representative of up to `3 * window` last samples
|
||||
* with highest weight given to the latest `kSampleWindow` samples.
|
||||
*
|
||||
* Max value of `0xffff` indicates all RSSI samples were above RSSI threshold (i.e. 100% of samples were "bad").
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aChannel The channel for which to get the link occupancy.
|
||||
*
|
||||
* @returns The current channel occupancy for the given channel.
|
||||
*/
|
||||
uint16_t otChannelMonitorGetChannelOccupancy(otInstance *aInstance, uint8_t aChannel);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_CHANNEL_MONITOR_H_
|
||||
115
Libs/util/third_party/openthread/include/openthread/child_supervision.h
vendored
Normal file
115
Libs/util/third_party/openthread/include/openthread/child_supervision.h
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the OpenThread API for child supervision feature.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_CHILD_SUPERVISION_H_
|
||||
#define OPENTHREAD_CHILD_SUPERVISION_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-child-supervision
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions for Child Supervision feature.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets the Child Supervision interval (in seconds) on a child.
|
||||
*
|
||||
* Child Supervision feature provides a mechanism for parent to ensure that a message is sent to each sleepy child
|
||||
* within the supervision interval. If there is no transmission to the child within the supervision interval, OpenThread
|
||||
* enqueues and sends a Child Supervision Message to the child.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The child supervision interval. Zero indicates that supervision is disabled.
|
||||
*/
|
||||
uint16_t otChildSupervisionGetInterval(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the child supervision interval (in seconds) on the child.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aInterval The supervision interval (in seconds). Zero to disable supervision.
|
||||
*/
|
||||
void otChildSupervisionSetInterval(otInstance *aInstance, uint16_t aInterval);
|
||||
|
||||
/**
|
||||
* Gets the supervision check timeout interval (in seconds) on the child.
|
||||
*
|
||||
* If the device is a sleepy child and it does not hear from its parent within the specified check timeout, it initiates
|
||||
* the re-attach process (MLE Child Update Request/Response exchange with its parent).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The supervision check timeout. Zero indicates that supervision check on the child is disabled.
|
||||
*/
|
||||
uint16_t otChildSupervisionGetCheckTimeout(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the supervision check timeout interval (in seconds) on the child.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aTimeout The check timeout (in seconds). Zero to disable supervision check on the child.
|
||||
*/
|
||||
void otChildSupervisionSetCheckTimeout(otInstance *aInstance, uint16_t aTimeout);
|
||||
|
||||
/**
|
||||
* Get the value of supervision check timeout failure counter.
|
||||
*
|
||||
* The counter tracks the number of supervision check failures on the child. It is incremented when the child does
|
||||
* not hear from its parent within the specified check timeout interval.
|
||||
*/
|
||||
uint16_t otChildSupervisionGetCheckFailureCounter(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Reset the supervision check timeout failure counter to zero.
|
||||
*/
|
||||
void otChildSupervisionResetCheckFailureCounter(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_CHILD_SUPERVISION_H_
|
||||
158
Libs/util/third_party/openthread/include/openthread/cli.h
vendored
Normal file
158
Libs/util/third_party/openthread/include/openthread/cli.h
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the top-level functions for the OpenThread CLI server.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_CLI_H_
|
||||
#define OPENTHREAD_CLI_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Represents a CLI command.
|
||||
*/
|
||||
typedef struct otCliCommand
|
||||
{
|
||||
const char *mName; ///< A pointer to the command string.
|
||||
otError (*mCommand)(void *aContext,
|
||||
uint8_t aArgsLength,
|
||||
char *aArgs[]); ///< A function pointer to process the command.
|
||||
} otCliCommand;
|
||||
|
||||
/**
|
||||
* @addtogroup api-cli
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control the Thread stack's execution.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pointer is called to notify about Console output.
|
||||
*
|
||||
* @param[out] aContext A user context pointer.
|
||||
* @param[in] aFormat The format string.
|
||||
* @param[in] aArguments The format string arguments.
|
||||
*
|
||||
* @returns Number of bytes written by the callback.
|
||||
*/
|
||||
typedef int (*otCliOutputCallback)(void *aContext, const char *aFormat, va_list aArguments);
|
||||
|
||||
/**
|
||||
* Initialize the CLI module.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aCallback A callback method called to process CLI output.
|
||||
* @param[in] aContext A user context pointer.
|
||||
*/
|
||||
void otCliInit(otInstance *aInstance, otCliOutputCallback aCallback, void *aContext);
|
||||
|
||||
/**
|
||||
* Is called to feed in a console input line.
|
||||
*
|
||||
* @param[in] aBuf A pointer to a null-terminated string.
|
||||
*/
|
||||
void otCliInputLine(char *aBuf);
|
||||
|
||||
/**
|
||||
* Set a user command table.
|
||||
*
|
||||
* @param[in] aUserCommands A pointer to an array with user commands.
|
||||
* @param[in] aLength @p aUserCommands length.
|
||||
* @param[in] aContext @p The context passed to the handler.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully updated command table with commands from @p aUserCommands.
|
||||
* @retval OT_ERROR_FAILED Maximum number of command entries have already been set.
|
||||
*/
|
||||
otError otCliSetUserCommands(const otCliCommand *aUserCommands, uint8_t aLength, void *aContext);
|
||||
|
||||
/**
|
||||
* Write a number of bytes to the CLI console as a hex string.
|
||||
*
|
||||
* @param[in] aBytes A pointer to data which should be printed.
|
||||
* @param[in] aLength @p aBytes length.
|
||||
*/
|
||||
void otCliOutputBytes(const uint8_t *aBytes, uint8_t aLength);
|
||||
|
||||
/**
|
||||
* Write formatted string to the CLI console
|
||||
*
|
||||
* @param[in] aFmt A pointer to the format string.
|
||||
* @param[in] ... A matching list of arguments.
|
||||
*/
|
||||
void otCliOutputFormat(const char *aFmt, ...);
|
||||
|
||||
/**
|
||||
* Write error code to the CLI console
|
||||
*
|
||||
* If the @p aError is `OT_ERROR_PENDING` nothing will be outputted.
|
||||
*
|
||||
* @param[in] aError Error code value.
|
||||
*/
|
||||
void otCliAppendResult(otError aError);
|
||||
|
||||
/**
|
||||
* Callback to write the OpenThread Log to the CLI console
|
||||
*
|
||||
* @param[in] aLogLevel The log level.
|
||||
* @param[in] aLogRegion The log region.
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] aArgs va_list matching aFormat.
|
||||
*/
|
||||
void otCliPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs);
|
||||
|
||||
/**
|
||||
* Callback to allow vendor specific commands to be added to the user command table.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_CLI_VENDOR_COMMANDS_ENABLE` is enabled and
|
||||
* `OPENTHREAD_CONFIG_CLI_MAX_USER_CMD_ENTRIES` is greater than 1.
|
||||
*/
|
||||
extern void otCliVendorSetUserCommands(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_CLI_H_
|
||||
1101
Libs/util/third_party/openthread/include/openthread/coap.h
vendored
Normal file
1101
Libs/util/third_party/openthread/include/openthread/coap.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
412
Libs/util/third_party/openthread/include/openthread/coap_secure.h
vendored
Normal file
412
Libs/util/third_party/openthread/include/openthread/coap_secure.h
vendored
Normal file
@@ -0,0 +1,412 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the top-level functions for the OpenThread CoAP Secure implementation.
|
||||
*
|
||||
* @note
|
||||
* The functions in this module require the build-time feature `OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1`.
|
||||
*
|
||||
* @note
|
||||
* To enable cipher suite DTLS_PSK_WITH_AES_128_CCM_8, MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
|
||||
* must be enabled in mbedtls-config.h
|
||||
* To enable cipher suite DTLS_ECDHE_ECDSA_WITH_AES_128_CCM_8,
|
||||
* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED must be enabled in mbedtls-config.h.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_COAP_SECURE_H_
|
||||
#define OPENTHREAD_COAP_SECURE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/coap.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-coap-secure
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control CoAP Secure (CoAP over DTLS) communication.
|
||||
*
|
||||
* The functions in this module are available when CoAP Secure API feature
|
||||
* (`OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE`) is enabled.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define OT_DEFAULT_COAP_SECURE_PORT 5684 ///< Default CoAP Secure port, as specified in RFC 7252
|
||||
|
||||
/**
|
||||
* CoAP secure connection event types.
|
||||
*/
|
||||
typedef enum otCoapSecureConnectEvent
|
||||
{
|
||||
OT_COAP_SECURE_CONNECTED = 0, ///< Connection established
|
||||
OT_COAP_SECURE_DISCONNECTED_PEER_CLOSED, ///< Disconnected by peer
|
||||
OT_COAP_SECURE_DISCONNECTED_LOCAL_CLOSED, ///< Disconnected locally
|
||||
OT_COAP_SECURE_DISCONNECTED_MAX_ATTEMPTS, ///< Disconnected due to reaching the max connection attempts
|
||||
OT_COAP_SECURE_DISCONNECTED_ERROR, ///< Disconnected due to an error
|
||||
} otCoapSecureConnectEvent;
|
||||
|
||||
/**
|
||||
* Pointer is called when the DTLS connection state changes.
|
||||
*
|
||||
* @param[in] aEvent The connection event.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*/
|
||||
typedef void (*otHandleCoapSecureClientConnect)(otCoapSecureConnectEvent aEvent, void *aContext);
|
||||
|
||||
/**
|
||||
* Callback function pointer to notify when the CoAP secure agent is automatically stopped due to reaching the maximum
|
||||
* number of connection attempts.
|
||||
*
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*/
|
||||
typedef void (*otCoapSecureAutoStopCallback)(void *aContext);
|
||||
|
||||
/**
|
||||
* Starts the CoAP Secure service.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPort The local UDP port to bind to.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the CoAP Secure server.
|
||||
*/
|
||||
otError otCoapSecureStart(otInstance *aInstance, uint16_t aPort);
|
||||
|
||||
/**
|
||||
* Starts the CoAP secure service and sets the maximum number of allowed connection attempts before stopping the
|
||||
* agent automatically.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPort The local UDP port to bind to.
|
||||
* @param[in] aMaxAttempts Maximum number of allowed connection request attempts. Zero indicates no limit.
|
||||
* @param[in] aCallback Callback to notify if max number of attempts has reached and agent is stopped.
|
||||
* @param[in] aContext A pointer to arbitrary context to use with @p aCallback.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the CoAP agent.
|
||||
* @retval OT_ERROR_ALREADY Already started.
|
||||
*/
|
||||
otError otCoapSecureStartWithMaxConnAttempts(otInstance *aInstance,
|
||||
uint16_t aPort,
|
||||
uint16_t aMaxAttempts,
|
||||
otCoapSecureAutoStopCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Stops the CoAP Secure server.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otCoapSecureStop(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the Pre-Shared Key (PSK) and cipher suite
|
||||
* DTLS_PSK_WITH_AES_128_CCM_8.
|
||||
*
|
||||
* @note This function requires the build-time feature `MBEDTLS_KEY_EXCHANGE_PSK_ENABLED` to be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPsk A pointer to the PSK.
|
||||
* @param[in] aPskLength The PSK length.
|
||||
* @param[in] aPskIdentity The Identity Name for the PSK.
|
||||
* @param[in] aPskIdLength The PSK Identity Length.
|
||||
*/
|
||||
void otCoapSecureSetPsk(otInstance *aInstance,
|
||||
const uint8_t *aPsk,
|
||||
uint16_t aPskLength,
|
||||
const uint8_t *aPskIdentity,
|
||||
uint16_t aPskIdLength);
|
||||
|
||||
/**
|
||||
* Returns the peer x509 certificate base64 encoded.
|
||||
*
|
||||
* @note This function requires the build-time features `MBEDTLS_BASE64_C` and
|
||||
* `MBEDTLS_SSL_KEEP_PEER_CERTIFICATE` to be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aPeerCert A pointer to the base64 encoded certificate buffer.
|
||||
* @param[out] aCertLength The length of the base64 encoded peer certificate.
|
||||
* @param[in] aCertBufferSize The buffer size of aPeerCert.
|
||||
*
|
||||
* @retval OT_ERROR_INVALID_STATE Not connected yet.
|
||||
* @retval OT_ERROR_NONE Successfully get the peer certificate.
|
||||
* @retval OT_ERROR_NO_BUFS Can't allocate memory for certificate.
|
||||
*/
|
||||
otError otCoapSecureGetPeerCertificateBase64(otInstance *aInstance,
|
||||
unsigned char *aPeerCert,
|
||||
size_t *aCertLength,
|
||||
size_t aCertBufferSize);
|
||||
|
||||
/**
|
||||
* Sets the authentication mode for the coap secure connection.
|
||||
*
|
||||
* Disable or enable the verification of peer certificate.
|
||||
* Must be called before start.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aVerifyPeerCertificate true, to verify the peer certificate.
|
||||
*/
|
||||
void otCoapSecureSetSslAuthMode(otInstance *aInstance, bool aVerifyPeerCertificate);
|
||||
|
||||
/**
|
||||
* Sets the local device's X509 certificate with corresponding private key for
|
||||
* DTLS session with DTLS_ECDHE_ECDSA_WITH_AES_128_CCM_8.
|
||||
*
|
||||
* @note This function requires `MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=1`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aX509Cert A pointer to the PEM formatted X509 certificate.
|
||||
* @param[in] aX509Length The length of certificate.
|
||||
* @param[in] aPrivateKey A pointer to the PEM formatted private key.
|
||||
* @param[in] aPrivateKeyLength The length of the private key.
|
||||
*/
|
||||
void otCoapSecureSetCertificate(otInstance *aInstance,
|
||||
const uint8_t *aX509Cert,
|
||||
uint32_t aX509Length,
|
||||
const uint8_t *aPrivateKey,
|
||||
uint32_t aPrivateKeyLength);
|
||||
|
||||
/**
|
||||
* Sets the trusted top level CAs. It is needed for validating the
|
||||
* certificate of the peer.
|
||||
*
|
||||
* DTLS mode "ECDHE ECDSA with AES 128 CCM 8" for Application CoAPS.
|
||||
*
|
||||
* @note This function requires `MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=1`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aX509CaCertificateChain A pointer to the PEM formatted X509 CA chain.
|
||||
* @param[in] aX509CaCertChainLength The length of chain.
|
||||
*/
|
||||
void otCoapSecureSetCaCertificateChain(otInstance *aInstance,
|
||||
const uint8_t *aX509CaCertificateChain,
|
||||
uint32_t aX509CaCertChainLength);
|
||||
|
||||
/**
|
||||
* Initializes DTLS session with a peer.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aSockAddr A pointer to the remote socket address.
|
||||
* @param[in] aHandler A pointer to a function that will be called when the DTLS connection
|
||||
* state changes.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started DTLS connection.
|
||||
*/
|
||||
otError otCoapSecureConnect(otInstance *aInstance,
|
||||
const otSockAddr *aSockAddr,
|
||||
otHandleCoapSecureClientConnect aHandler,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Stops the DTLS connection.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otCoapSecureDisconnect(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the DTLS session is connected.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval TRUE The DTLS session is connected.
|
||||
* @retval FALSE The DTLS session is not connected.
|
||||
*/
|
||||
bool otCoapSecureIsConnected(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the DTLS session is active.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval TRUE If DTLS session is active.
|
||||
* @retval FALSE If DTLS session is not active.
|
||||
*/
|
||||
bool otCoapSecureIsConnectionActive(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the DTLS session is closed.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval TRUE The DTLS session is closed.
|
||||
* @retval FALSE The DTLS session is not closed.
|
||||
*/
|
||||
bool otCoapSecureIsClosed(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sends a CoAP request block-wise over secure DTLS connection.
|
||||
*
|
||||
* Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration
|
||||
* is enabled.
|
||||
*
|
||||
* If a response for a request is expected, respective function and context information should be provided.
|
||||
* If no response is expected, these arguments should be NULL pointers.
|
||||
* If Message Id was not set in the header (equal to 0), this function will assign unique Message Id to the message.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMessage A reference to the message to send.
|
||||
* @param[in] aHandler A function pointer that shall be called on response reception or time-out.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
* @param[in] aTransmitHook A function pointer that is called on Block1 response reception.
|
||||
* @param[in] aReceiveHook A function pointer that is called on Block2 response reception.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully sent CoAP message.
|
||||
* @retval OT_ERROR_NO_BUFS Failed to allocate retransmission data.
|
||||
* @retval OT_ERROR_INVALID_STATE DTLS connection was not initialized.
|
||||
*/
|
||||
otError otCoapSecureSendRequestBlockWise(otInstance *aInstance,
|
||||
otMessage *aMessage,
|
||||
otCoapResponseHandler aHandler,
|
||||
void *aContext,
|
||||
otCoapBlockwiseTransmitHook aTransmitHook,
|
||||
otCoapBlockwiseReceiveHook aReceiveHook);
|
||||
|
||||
/**
|
||||
* Sends a CoAP request over secure DTLS connection.
|
||||
*
|
||||
* If a response for a request is expected, respective function and context information should be provided.
|
||||
* If no response is expected, these arguments should be NULL pointers.
|
||||
* If Message Id was not set in the header (equal to 0), this function will assign unique Message Id to the message.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMessage A reference to the message to send.
|
||||
* @param[in] aHandler A function pointer that shall be called on response reception or time-out.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully sent CoAP message.
|
||||
* @retval OT_ERROR_NO_BUFS Failed to allocate retransmission data.
|
||||
* @retval OT_ERROR_INVALID_STATE DTLS connection was not initialized.
|
||||
*/
|
||||
otError otCoapSecureSendRequest(otInstance *aInstance,
|
||||
otMessage *aMessage,
|
||||
otCoapResponseHandler aHandler,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Adds a resource to the CoAP Secure server.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aResource A pointer to the resource.
|
||||
*/
|
||||
void otCoapSecureAddResource(otInstance *aInstance, otCoapResource *aResource);
|
||||
|
||||
/**
|
||||
* Removes a resource from the CoAP Secure server.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aResource A pointer to the resource.
|
||||
*/
|
||||
void otCoapSecureRemoveResource(otInstance *aInstance, otCoapResource *aResource);
|
||||
|
||||
/**
|
||||
* Adds a block-wise resource to the CoAP Secure server.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aResource A pointer to the resource.
|
||||
*/
|
||||
void otCoapSecureAddBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResource *aResource);
|
||||
|
||||
/**
|
||||
* Removes a block-wise resource from the CoAP Secure server.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aResource A pointer to the resource.
|
||||
*/
|
||||
void otCoapSecureRemoveBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResource *aResource);
|
||||
|
||||
/**
|
||||
* Sets the default handler for unhandled CoAP Secure requests.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aHandler A function pointer that shall be called when an unhandled request arrives.
|
||||
* @param[in] aContext A pointer to arbitrary context information. May be NULL if not used.
|
||||
*/
|
||||
void otCoapSecureSetDefaultHandler(otInstance *aInstance, otCoapRequestHandler aHandler, void *aContext);
|
||||
|
||||
/**
|
||||
* Sets the connect event callback to indicate when
|
||||
* a Client connection to the CoAP Secure server has changed.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aHandler A pointer to a function that will be called once DTLS connection has changed.
|
||||
* @param[in] aContext A pointer to arbitrary context information. May be NULL if not used.
|
||||
*/
|
||||
void otCoapSecureSetClientConnectEventCallback(otInstance *aInstance,
|
||||
otHandleCoapSecureClientConnect aHandler,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Sends a CoAP response block-wise from the CoAP Secure server.
|
||||
*
|
||||
* Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration
|
||||
* is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMessage A pointer to the CoAP response to send.
|
||||
* @param[in] aMessageInfo A pointer to the message info associated with @p aMessage.
|
||||
* @param[in] aContext A pointer to arbitrary context information. May be NULL if not used.
|
||||
* @param[in] aTransmitHook A function pointer that is called on Block1 request reception.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully enqueued the CoAP response message.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffers available to send the CoAP response.
|
||||
*/
|
||||
otError otCoapSecureSendResponseBlockWise(otInstance *aInstance,
|
||||
otMessage *aMessage,
|
||||
const otMessageInfo *aMessageInfo,
|
||||
void *aContext,
|
||||
otCoapBlockwiseTransmitHook aTransmitHook);
|
||||
|
||||
/**
|
||||
* Sends a CoAP response from the CoAP Secure server.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMessage A pointer to the CoAP response to send.
|
||||
* @param[in] aMessageInfo A pointer to the message info associated with @p aMessage.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully enqueued the CoAP response message.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffers available to send the CoAP response.
|
||||
*/
|
||||
otError otCoapSecureSendResponse(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif /* OPENTHREAD_COAP_SECURE_H_ */
|
||||
469
Libs/util/third_party/openthread/include/openthread/commissioner.h
vendored
Normal file
469
Libs/util/third_party/openthread/include/openthread/commissioner.h
vendored
Normal file
@@ -0,0 +1,469 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes functions for the Thread Commissioner role.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_COMMISSIONER_H_
|
||||
#define OPENTHREAD_COMMISSIONER_H_
|
||||
|
||||
#include <openthread/dataset.h>
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/joiner.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
#include <openthread/platform/toolchain.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-commissioner
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions for the Thread Commissioner role.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Defines the Commissioner State.
|
||||
*/
|
||||
typedef enum otCommissionerState
|
||||
{
|
||||
OT_COMMISSIONER_STATE_DISABLED = 0, ///< Commissioner role is disabled.
|
||||
OT_COMMISSIONER_STATE_PETITION = 1, ///< Currently petitioning to become a Commissioner.
|
||||
OT_COMMISSIONER_STATE_ACTIVE = 2, ///< Commissioner role is active.
|
||||
} otCommissionerState;
|
||||
|
||||
/**
|
||||
* Defines a Joiner Event on the Commissioner.
|
||||
*/
|
||||
typedef enum otCommissionerJoinerEvent
|
||||
{
|
||||
OT_COMMISSIONER_JOINER_START = 0,
|
||||
OT_COMMISSIONER_JOINER_CONNECTED = 1,
|
||||
OT_COMMISSIONER_JOINER_FINALIZE = 2,
|
||||
OT_COMMISSIONER_JOINER_END = 3,
|
||||
OT_COMMISSIONER_JOINER_REMOVED = 4,
|
||||
} otCommissionerJoinerEvent;
|
||||
|
||||
#define OT_COMMISSIONING_PASSPHRASE_MIN_SIZE 6 ///< Minimum size of the Commissioning Passphrase
|
||||
#define OT_COMMISSIONING_PASSPHRASE_MAX_SIZE 255 ///< Maximum size of the Commissioning Passphrase
|
||||
|
||||
#define OT_PROVISIONING_URL_MAX_SIZE 64 ///< Max size (number of chars) in Provisioning URL string (excludes null char).
|
||||
|
||||
#define OT_STEERING_DATA_MAX_LENGTH 16 ///< Max steering data length (bytes)
|
||||
|
||||
/**
|
||||
* Represents the steering data.
|
||||
*/
|
||||
typedef struct otSteeringData
|
||||
{
|
||||
uint8_t mLength; ///< Length of steering data (bytes)
|
||||
uint8_t m8[OT_STEERING_DATA_MAX_LENGTH]; ///< Byte values
|
||||
} otSteeringData;
|
||||
|
||||
/**
|
||||
* Represents a Commissioning Dataset.
|
||||
*/
|
||||
typedef struct otCommissioningDataset
|
||||
{
|
||||
uint16_t mLocator; ///< Border Router RLOC16
|
||||
uint16_t mSessionId; ///< Commissioner Session Id
|
||||
otSteeringData mSteeringData; ///< Steering Data
|
||||
uint16_t mJoinerUdpPort; ///< Joiner UDP Port
|
||||
|
||||
bool mIsLocatorSet : 1; ///< TRUE if Border Router RLOC16 is set, FALSE otherwise.
|
||||
bool mIsSessionIdSet : 1; ///< TRUE if Commissioner Session Id is set, FALSE otherwise.
|
||||
bool mIsSteeringDataSet : 1; ///< TRUE if Steering Data is set, FALSE otherwise.
|
||||
bool mIsJoinerUdpPortSet : 1; ///< TRUE if Joiner UDP Port is set, FALSE otherwise.
|
||||
bool mHasExtraTlv : 1; ///< TRUE if the Dataset contains any extra unknown sub-TLV, FALSE otherwise.
|
||||
} otCommissioningDataset;
|
||||
|
||||
#define OT_JOINER_MAX_PSKD_LENGTH 32 ///< Maximum string length of a Joiner PSKd (does not include null char).
|
||||
|
||||
/**
|
||||
* Represents a Joiner PSKd.
|
||||
*/
|
||||
typedef struct otJoinerPskd
|
||||
{
|
||||
char m8[OT_JOINER_MAX_PSKD_LENGTH + 1]; ///< Char string array (must be null terminated - +1 is for null char).
|
||||
} otJoinerPskd;
|
||||
|
||||
/**
|
||||
* Defines a Joiner Info Type.
|
||||
*/
|
||||
typedef enum otJoinerInfoType
|
||||
{
|
||||
OT_JOINER_INFO_TYPE_ANY = 0, ///< Accept any Joiner (no EUI64 or Discerner is specified).
|
||||
OT_JOINER_INFO_TYPE_EUI64 = 1, ///< Joiner EUI-64 is specified (`mSharedId.mEui64` in `otJoinerInfo`).
|
||||
OT_JOINER_INFO_TYPE_DISCERNER = 2, ///< Joiner Discerner is specified (`mSharedId.mDiscerner` in `otJoinerInfo`).
|
||||
} otJoinerInfoType;
|
||||
|
||||
/**
|
||||
* Represents a Joiner Info.
|
||||
*/
|
||||
typedef struct otJoinerInfo
|
||||
{
|
||||
otJoinerInfoType mType; ///< Joiner type.
|
||||
union
|
||||
{
|
||||
otExtAddress mEui64; ///< Joiner EUI64 (when `mType` is `OT_JOINER_INFO_TYPE_EUI64`)
|
||||
otJoinerDiscerner mDiscerner; ///< Joiner Discerner (when `mType` is `OT_JOINER_INFO_TYPE_DISCERNER`)
|
||||
} mSharedId; ///< Shared fields
|
||||
otJoinerPskd mPskd; ///< Joiner PSKd
|
||||
uint32_t mExpirationTime; ///< Joiner expiration time in msec
|
||||
} otJoinerInfo;
|
||||
|
||||
/**
|
||||
* Pointer is called whenever the commissioner state changes.
|
||||
*
|
||||
* @param[in] aState The Commissioner state.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otCommissionerStateCallback)(otCommissionerState aState, void *aContext);
|
||||
|
||||
/**
|
||||
* Pointer is called whenever the joiner state changes.
|
||||
*
|
||||
* @param[in] aEvent The joiner event type.
|
||||
* @param[in] aJoinerInfo A pointer to the Joiner Info.
|
||||
* @param[in] aJoinerId A pointer to the Joiner ID (if not known, it will be NULL).
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otCommissionerJoinerCallback)(otCommissionerJoinerEvent aEvent,
|
||||
const otJoinerInfo *aJoinerInfo,
|
||||
const otExtAddress *aJoinerId,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Enables the Thread Commissioner role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aStateCallback A pointer to a function that is called when the commissioner state changes.
|
||||
* @param[in] aJoinerCallback A pointer to a function that is called with a joiner event occurs.
|
||||
* @param[in] aCallbackContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the Commissioner service.
|
||||
* @retval OT_ERROR_ALREADY Commissioner is already started.
|
||||
* @retval OT_ERROR_INVALID_STATE Device is not currently attached to a network.
|
||||
*/
|
||||
otError otCommissionerStart(otInstance *aInstance,
|
||||
otCommissionerStateCallback aStateCallback,
|
||||
otCommissionerJoinerCallback aJoinerCallback,
|
||||
void *aCallbackContext);
|
||||
|
||||
/**
|
||||
* Disables the Thread Commissioner role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully stopped the Commissioner service.
|
||||
* @retval OT_ERROR_ALREADY Commissioner is already stopped.
|
||||
*/
|
||||
otError otCommissionerStop(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Returns the Commissioner Id.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The Commissioner Id.
|
||||
*/
|
||||
const char *otCommissionerGetId(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the Commissioner Id.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aId A pointer to a string character array. Must be null terminated.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the Commissioner Id.
|
||||
* @retval OT_ERROR_INVALID_ARGS Given name is too long.
|
||||
* @retval OT_ERROR_INVALID_STATE The commissioner is active and id cannot be changed.
|
||||
*/
|
||||
otError otCommissionerSetId(otInstance *aInstance, const char *aId);
|
||||
|
||||
/**
|
||||
* Adds a Joiner entry.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEui64 A pointer to the Joiner's IEEE EUI-64 or NULL for any Joiner.
|
||||
* @param[in] aPskd A pointer to the PSKd.
|
||||
* @param[in] aTimeout A time after which a Joiner is automatically removed, in seconds.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added the Joiner.
|
||||
* @retval OT_ERROR_NO_BUFS No buffers available to add the Joiner.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aEui64 or @p aPskd is invalid.
|
||||
* @retval OT_ERROR_INVALID_STATE The commissioner is not active.
|
||||
*
|
||||
* @note Only use this after successfully starting the Commissioner role with otCommissionerStart().
|
||||
*/
|
||||
otError otCommissionerAddJoiner(otInstance *aInstance,
|
||||
const otExtAddress *aEui64,
|
||||
const char *aPskd,
|
||||
uint32_t aTimeout);
|
||||
|
||||
/**
|
||||
* Adds a Joiner entry with a given Joiner Discerner value.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDiscerner A pointer to the Joiner Discerner.
|
||||
* @param[in] aPskd A pointer to the PSKd.
|
||||
* @param[in] aTimeout A time after which a Joiner is automatically removed, in seconds.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added the Joiner.
|
||||
* @retval OT_ERROR_NO_BUFS No buffers available to add the Joiner.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aDiscerner or @p aPskd is invalid.
|
||||
* @retval OT_ERROR_INVALID_STATE The commissioner is not active.
|
||||
*
|
||||
* @note Only use this after successfully starting the Commissioner role with otCommissionerStart().
|
||||
*/
|
||||
otError otCommissionerAddJoinerWithDiscerner(otInstance *aInstance,
|
||||
const otJoinerDiscerner *aDiscerner,
|
||||
const char *aPskd,
|
||||
uint32_t aTimeout);
|
||||
|
||||
/**
|
||||
* Get joiner info at aIterator position.
|
||||
*
|
||||
* @param[in] aInstance A pointer to instance.
|
||||
* @param[in,out] aIterator A pointer to the Joiner Info iterator context.
|
||||
* @param[out] aJoiner A reference to Joiner info.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully get the Joiner info.
|
||||
* @retval OT_ERROR_NOT_FOUND Not found next Joiner.
|
||||
*/
|
||||
otError otCommissionerGetNextJoinerInfo(otInstance *aInstance, uint16_t *aIterator, otJoinerInfo *aJoiner);
|
||||
|
||||
/**
|
||||
* Removes a Joiner entry.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEui64 A pointer to the Joiner's IEEE EUI-64 or NULL for any Joiner.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully removed the Joiner.
|
||||
* @retval OT_ERROR_NOT_FOUND The Joiner specified by @p aEui64 was not found.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aEui64 is invalid.
|
||||
* @retval OT_ERROR_INVALID_STATE The commissioner is not active.
|
||||
*
|
||||
* @note Only use this after successfully starting the Commissioner role with otCommissionerStart().
|
||||
*/
|
||||
otError otCommissionerRemoveJoiner(otInstance *aInstance, const otExtAddress *aEui64);
|
||||
|
||||
/**
|
||||
* Removes a Joiner entry.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDiscerner A pointer to the Joiner Discerner.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully removed the Joiner.
|
||||
* @retval OT_ERROR_NOT_FOUND The Joiner specified by @p aEui64 was not found.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aDiscerner is invalid.
|
||||
* @retval OT_ERROR_INVALID_STATE The commissioner is not active.
|
||||
*
|
||||
* @note Only use this after successfully starting the Commissioner role with otCommissionerStart().
|
||||
*/
|
||||
otError otCommissionerRemoveJoinerWithDiscerner(otInstance *aInstance, const otJoinerDiscerner *aDiscerner);
|
||||
|
||||
/**
|
||||
* Gets the Provisioning URL.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the URL string.
|
||||
*/
|
||||
const char *otCommissionerGetProvisioningUrl(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the Provisioning URL.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aProvisioningUrl A pointer to the Provisioning URL (may be NULL to set as empty string).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the Provisioning URL.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aProvisioningUrl is invalid (too long).
|
||||
*/
|
||||
otError otCommissionerSetProvisioningUrl(otInstance *aInstance, const char *aProvisioningUrl);
|
||||
|
||||
/**
|
||||
* Sends an Announce Begin message.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aChannelMask The channel mask value.
|
||||
* @param[in] aCount The number of Announcement messages per channel.
|
||||
* @param[in] aPeriod The time between two successive MLE Announce transmissions (in milliseconds).
|
||||
* @param[in] aAddress A pointer to the IPv6 destination.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully enqueued the Announce Begin message.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffers to generate an Announce Begin message.
|
||||
* @retval OT_ERROR_INVALID_STATE The commissioner is not active.
|
||||
*
|
||||
* @note Only use this after successfully starting the Commissioner role with otCommissionerStart().
|
||||
*/
|
||||
otError otCommissionerAnnounceBegin(otInstance *aInstance,
|
||||
uint32_t aChannelMask,
|
||||
uint8_t aCount,
|
||||
uint16_t aPeriod,
|
||||
const otIp6Address *aAddress);
|
||||
|
||||
/**
|
||||
* Pointer is called when the Commissioner receives an Energy Report.
|
||||
*
|
||||
* @param[in] aChannelMask The channel mask value.
|
||||
* @param[in] aEnergyList A pointer to the energy measurement list.
|
||||
* @param[in] aEnergyListLength Number of entries in @p aEnergyListLength.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otCommissionerEnergyReportCallback)(uint32_t aChannelMask,
|
||||
const uint8_t *aEnergyList,
|
||||
uint8_t aEnergyListLength,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Sends an Energy Scan Query message.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aChannelMask The channel mask value.
|
||||
* @param[in] aCount The number of energy measurements per channel.
|
||||
* @param[in] aPeriod The time between energy measurements (milliseconds).
|
||||
* @param[in] aScanDuration The scan duration for each energy measurement (milliseconds).
|
||||
* @param[in] aAddress A pointer to the IPv6 destination.
|
||||
* @param[in] aCallback A pointer to a function called on receiving an Energy Report message.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully enqueued the Energy Scan Query message.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffers to generate an Energy Scan Query message.
|
||||
* @retval OT_ERROR_INVALID_STATE The commissioner is not active.
|
||||
*
|
||||
* @note Only use this after successfully starting the Commissioner role with otCommissionerStart().
|
||||
*/
|
||||
otError otCommissionerEnergyScan(otInstance *aInstance,
|
||||
uint32_t aChannelMask,
|
||||
uint8_t aCount,
|
||||
uint16_t aPeriod,
|
||||
uint16_t aScanDuration,
|
||||
const otIp6Address *aAddress,
|
||||
otCommissionerEnergyReportCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Pointer is called when the Commissioner receives a PAN ID Conflict message.
|
||||
*
|
||||
* @param[in] aPanId The PAN ID value.
|
||||
* @param[in] aChannelMask The channel mask value.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otCommissionerPanIdConflictCallback)(uint16_t aPanId, uint32_t aChannelMask, void *aContext);
|
||||
|
||||
/**
|
||||
* Sends a PAN ID Query message.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPanId The PAN ID to query.
|
||||
* @param[in] aChannelMask The channel mask value.
|
||||
* @param[in] aAddress A pointer to the IPv6 destination.
|
||||
* @param[in] aCallback A pointer to a function called on receiving a PAN ID Conflict message.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully enqueued the PAN ID Query message.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffers to generate a PAN ID Query message.
|
||||
* @retval OT_ERROR_INVALID_STATE The commissioner is not active.
|
||||
*
|
||||
* @note Only use this after successfully starting the Commissioner role with otCommissionerStart().
|
||||
*/
|
||||
otError otCommissionerPanIdQuery(otInstance *aInstance,
|
||||
uint16_t aPanId,
|
||||
uint32_t aChannelMask,
|
||||
const otIp6Address *aAddress,
|
||||
otCommissionerPanIdConflictCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Sends MGMT_COMMISSIONER_GET.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aTlvs A pointer to TLVs.
|
||||
* @param[in] aLength The length of TLVs.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
* @retval OT_ERROR_INVALID_STATE The commissioner is not active.
|
||||
*/
|
||||
otError otCommissionerSendMgmtGet(otInstance *aInstance, const uint8_t *aTlvs, uint8_t aLength);
|
||||
|
||||
/**
|
||||
* Sends MGMT_COMMISSIONER_SET.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDataset A pointer to commissioning dataset.
|
||||
* @param[in] aTlvs A pointer to TLVs.
|
||||
* @param[in] aLength The length of TLVs.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
* @retval OT_ERROR_INVALID_STATE The commissioner is not active.
|
||||
*/
|
||||
otError otCommissionerSendMgmtSet(otInstance *aInstance,
|
||||
const otCommissioningDataset *aDataset,
|
||||
const uint8_t *aTlvs,
|
||||
uint8_t aLength);
|
||||
|
||||
/**
|
||||
* Returns the Commissioner Session ID.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The current commissioner session id.
|
||||
*/
|
||||
uint16_t otCommissionerGetSessionId(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Returns the Commissioner State.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_COMMISSIONER_STATE_DISABLED Commissioner disabled.
|
||||
* @retval OT_COMMISSIONER_STATE_PETITION Becoming the commissioner.
|
||||
* @retval OT_COMMISSIONER_STATE_ACTIVE Commissioner enabled.
|
||||
*/
|
||||
otCommissionerState otCommissionerGetState(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_COMMISSIONER_H_
|
||||
47
Libs/util/third_party/openthread/include/openthread/config.h
vendored
Normal file
47
Libs/util/third_party/openthread/include/openthread/config.h
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes required defines config header.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_CONFIG_H_
|
||||
#define OPENTHREAD_CONFIG_H_
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_FILE
|
||||
*
|
||||
* The OpenThread feature configuration file.
|
||||
*/
|
||||
#if defined(OPENTHREAD_CONFIG_FILE)
|
||||
#include OPENTHREAD_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_H_
|
||||
110
Libs/util/third_party/openthread/include/openthread/crypto.h
vendored
Normal file
110
Libs/util/third_party/openthread/include/openthread/crypto.h
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread crypto C APIs.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_CRYPTO_H_
|
||||
#define OPENTHREAD_CRYPTO_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/platform/crypto.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-crypto
|
||||
*
|
||||
* @brief
|
||||
* This module includes cryptographic functions.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a SHA-256 hash.
|
||||
*/
|
||||
typedef otPlatCryptoSha256Hash otCryptoSha256Hash;
|
||||
|
||||
/**
|
||||
* Performs HMAC computation.
|
||||
*
|
||||
* @param[in] aKey A pointer to the key.
|
||||
* @param[in] aBuf A pointer to the input buffer.
|
||||
* @param[in] aBufLength The length of @p aBuf in bytes.
|
||||
* @param[out] aHash A pointer to a `otCryptoSha256Hash` structure to output the hash value.
|
||||
*/
|
||||
void otCryptoHmacSha256(const otCryptoKey *aKey, const uint8_t *aBuf, uint16_t aBufLength, otCryptoSha256Hash *aHash);
|
||||
|
||||
/**
|
||||
* Performs AES CCM computation.
|
||||
*
|
||||
* @param[in] aKey A pointer to the key.
|
||||
* @param[in] aTagLength Length of tag in bytes.
|
||||
* @param[in] aNonce A pointer to the nonce.
|
||||
* @param[in] aNonceLength Length of nonce in bytes.
|
||||
*
|
||||
* @param[in] aHeader A pointer to the header.
|
||||
* @param[in] aHeaderLength Length of header in bytes.
|
||||
*
|
||||
* @param[in,out] aPlainText A pointer to the plaintext.
|
||||
* @param[in,out] aCipherText A pointer to the ciphertext.
|
||||
* @param[in] aLength Plaintext length in bytes.
|
||||
* @param[in] aEncrypt `true` on encrypt and `false` on decrypt.
|
||||
*
|
||||
* @param[out] aTag A pointer to the tag.
|
||||
*/
|
||||
void otCryptoAesCcm(const otCryptoKey *aKey,
|
||||
uint8_t aTagLength,
|
||||
const void *aNonce,
|
||||
uint8_t aNonceLength,
|
||||
const void *aHeader,
|
||||
uint32_t aHeaderLength,
|
||||
void *aPlainText,
|
||||
void *aCipherText,
|
||||
uint32_t aLength,
|
||||
bool aEncrypt,
|
||||
void *aTag);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_CRYPTO_H_
|
||||
600
Libs/util/third_party/openthread/include/openthread/dataset.h
vendored
Normal file
600
Libs/util/third_party/openthread/include/openthread/dataset.h
vendored
Normal file
@@ -0,0 +1,600 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Operational Dataset API (for both FTD and MTD).
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_DATASET_H_
|
||||
#define OPENTHREAD_DATASET_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/platform/crypto.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-operational-dataset
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* For FTD and MTD builds, the Operational Dataset API includes functions to manage Active and Pending datasets
|
||||
* and dataset TLVs.
|
||||
*/
|
||||
|
||||
#define OT_NETWORK_KEY_SIZE 16 ///< Size of the Thread Network Key (bytes)
|
||||
|
||||
/**
|
||||
* @struct otNetworkKey
|
||||
*
|
||||
* Represents a Thread Network Key.
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otNetworkKey
|
||||
{
|
||||
uint8_t m8[OT_NETWORK_KEY_SIZE]; ///< Byte values
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* Represents a Thread Network Key.
|
||||
*/
|
||||
typedef struct otNetworkKey otNetworkKey;
|
||||
|
||||
/**
|
||||
* This datatype represents KeyRef to NetworkKey.
|
||||
*/
|
||||
typedef otCryptoKeyRef otNetworkKeyRef; ///< Reference to Key
|
||||
|
||||
#define OT_NETWORK_NAME_MAX_SIZE 16 ///< Maximum size of the Thread Network Name field (bytes)
|
||||
|
||||
/**
|
||||
* Represents a Network Name.
|
||||
*
|
||||
* The `otNetworkName` is a null terminated C string (i.e., `m8` char array MUST end with null char `\0`).
|
||||
*/
|
||||
typedef struct otNetworkName
|
||||
{
|
||||
char m8[OT_NETWORK_NAME_MAX_SIZE + 1]; ///< Byte values. The `+ 1` is for null char.
|
||||
} otNetworkName;
|
||||
|
||||
#define OT_EXT_PAN_ID_SIZE 8 ///< Size of a Thread PAN ID (bytes)
|
||||
|
||||
/**
|
||||
* Represents an Extended PAN ID.
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otExtendedPanId
|
||||
{
|
||||
uint8_t m8[OT_EXT_PAN_ID_SIZE]; ///< Byte values
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* Represents an Extended PAN ID.
|
||||
*/
|
||||
typedef struct otExtendedPanId otExtendedPanId;
|
||||
|
||||
#define OT_MESH_LOCAL_PREFIX_SIZE OT_IP6_PREFIX_SIZE ///< Size of the Mesh Local Prefix (bytes)
|
||||
|
||||
/**
|
||||
* Represents a Mesh Local Prefix.
|
||||
*/
|
||||
typedef otIp6NetworkPrefix otMeshLocalPrefix;
|
||||
|
||||
#define OT_PSKC_MAX_SIZE 16 ///< Maximum size of the PSKc (bytes)
|
||||
|
||||
/**
|
||||
* Represents PSKc.
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otPskc
|
||||
{
|
||||
uint8_t m8[OT_PSKC_MAX_SIZE]; ///< Byte values
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* Represents a PSKc.
|
||||
*/
|
||||
typedef struct otPskc otPskc;
|
||||
|
||||
/**
|
||||
* This datatype represents KeyRef to PSKc.
|
||||
*/
|
||||
typedef otCryptoKeyRef otPskcRef; ///< Reference to Key
|
||||
|
||||
/**
|
||||
* Represent Security Policy.
|
||||
*/
|
||||
typedef struct otSecurityPolicy
|
||||
{
|
||||
uint16_t mRotationTime; ///< The value for thrKeyRotation in units of hours.
|
||||
|
||||
bool mObtainNetworkKeyEnabled : 1; ///< Obtaining the Network Key for out-of-band commissioning is enabled
|
||||
bool mNativeCommissioningEnabled : 1; ///< Native Commissioning using PSKc is allowed
|
||||
bool mRoutersEnabled : 1; ///< Thread 1.0/1.1.x Routers are enabled
|
||||
bool mExternalCommissioningEnabled : 1; ///< External Commissioner authentication is allowed
|
||||
bool mCommercialCommissioningEnabled : 1; ///< Commercial Commissioning is enabled
|
||||
bool mAutonomousEnrollmentEnabled : 1; ///< Autonomous Enrollment is enabled
|
||||
bool mNetworkKeyProvisioningEnabled : 1; ///< Network Key Provisioning is enabled
|
||||
bool mTobleLinkEnabled : 1; ///< ToBLE link is enabled
|
||||
bool mNonCcmRoutersEnabled : 1; ///< Non-CCM Routers enabled
|
||||
uint8_t mVersionThresholdForRouting : 3; ///< Version-threshold for Routing
|
||||
} otSecurityPolicy;
|
||||
|
||||
/**
|
||||
* Represents Channel Mask.
|
||||
*/
|
||||
typedef uint32_t otChannelMask;
|
||||
|
||||
#define OT_CHANNEL_1_MASK (1 << 1) ///< Channel 1
|
||||
#define OT_CHANNEL_2_MASK (1 << 2) ///< Channel 2
|
||||
#define OT_CHANNEL_3_MASK (1 << 3) ///< Channel 3
|
||||
#define OT_CHANNEL_4_MASK (1 << 4) ///< Channel 4
|
||||
#define OT_CHANNEL_5_MASK (1 << 5) ///< Channel 5
|
||||
#define OT_CHANNEL_6_MASK (1 << 6) ///< Channel 6
|
||||
#define OT_CHANNEL_7_MASK (1 << 7) ///< Channel 7
|
||||
#define OT_CHANNEL_8_MASK (1 << 8) ///< Channel 8
|
||||
#define OT_CHANNEL_9_MASK (1 << 9) ///< Channel 9
|
||||
#define OT_CHANNEL_10_MASK (1 << 10) ///< Channel 10
|
||||
#define OT_CHANNEL_11_MASK (1 << 11) ///< Channel 11
|
||||
#define OT_CHANNEL_12_MASK (1 << 12) ///< Channel 12
|
||||
#define OT_CHANNEL_13_MASK (1 << 13) ///< Channel 13
|
||||
#define OT_CHANNEL_14_MASK (1 << 14) ///< Channel 14
|
||||
#define OT_CHANNEL_15_MASK (1 << 15) ///< Channel 15
|
||||
#define OT_CHANNEL_16_MASK (1 << 16) ///< Channel 16
|
||||
#define OT_CHANNEL_17_MASK (1 << 17) ///< Channel 17
|
||||
#define OT_CHANNEL_18_MASK (1 << 18) ///< Channel 18
|
||||
#define OT_CHANNEL_19_MASK (1 << 19) ///< Channel 19
|
||||
#define OT_CHANNEL_20_MASK (1 << 20) ///< Channel 20
|
||||
#define OT_CHANNEL_21_MASK (1 << 21) ///< Channel 21
|
||||
#define OT_CHANNEL_22_MASK (1 << 22) ///< Channel 22
|
||||
#define OT_CHANNEL_23_MASK (1 << 23) ///< Channel 23
|
||||
#define OT_CHANNEL_24_MASK (1 << 24) ///< Channel 24
|
||||
#define OT_CHANNEL_25_MASK (1 << 25) ///< Channel 25
|
||||
#define OT_CHANNEL_26_MASK (1 << 26) ///< Channel 26
|
||||
|
||||
/**
|
||||
* Represents presence of different components in Active or Pending Operational Dataset.
|
||||
*/
|
||||
typedef struct otOperationalDatasetComponents
|
||||
{
|
||||
bool mIsActiveTimestampPresent; ///< TRUE if Active Timestamp is present, FALSE otherwise.
|
||||
bool mIsPendingTimestampPresent; ///< TRUE if Pending Timestamp is present, FALSE otherwise.
|
||||
bool mIsNetworkKeyPresent; ///< TRUE if Network Key is present, FALSE otherwise.
|
||||
bool mIsNetworkNamePresent; ///< TRUE if Network Name is present, FALSE otherwise.
|
||||
bool mIsExtendedPanIdPresent; ///< TRUE if Extended PAN ID is present, FALSE otherwise.
|
||||
bool mIsMeshLocalPrefixPresent; ///< TRUE if Mesh Local Prefix is present, FALSE otherwise.
|
||||
bool mIsDelayPresent; ///< TRUE if Delay Timer is present, FALSE otherwise.
|
||||
bool mIsPanIdPresent; ///< TRUE if PAN ID is present, FALSE otherwise.
|
||||
bool mIsChannelPresent; ///< TRUE if Channel is present, FALSE otherwise.
|
||||
bool mIsPskcPresent; ///< TRUE if PSKc is present, FALSE otherwise.
|
||||
bool mIsSecurityPolicyPresent; ///< TRUE if Security Policy is present, FALSE otherwise.
|
||||
bool mIsChannelMaskPresent; ///< TRUE if Channel Mask is present, FALSE otherwise.
|
||||
bool mIsWakeupChannelPresent; ///< TRUE if Wake-up Channel is present, FALSE otherwise.
|
||||
} otOperationalDatasetComponents;
|
||||
|
||||
/**
|
||||
* Represents a Thread Dataset timestamp component.
|
||||
*/
|
||||
typedef struct otTimestamp
|
||||
{
|
||||
uint64_t mSeconds;
|
||||
uint16_t mTicks;
|
||||
bool mAuthoritative;
|
||||
} otTimestamp;
|
||||
|
||||
/**
|
||||
* Represents an Active or Pending Operational Dataset.
|
||||
*
|
||||
* Components in Dataset are optional. `mComponents` structure specifies which components are present in the Dataset.
|
||||
*/
|
||||
typedef struct otOperationalDataset
|
||||
{
|
||||
otTimestamp mActiveTimestamp; ///< Active Timestamp
|
||||
otTimestamp mPendingTimestamp; ///< Pending Timestamp
|
||||
otNetworkKey mNetworkKey; ///< Network Key
|
||||
otNetworkName mNetworkName; ///< Network Name
|
||||
otExtendedPanId mExtendedPanId; ///< Extended PAN ID
|
||||
otMeshLocalPrefix mMeshLocalPrefix; ///< Mesh Local Prefix
|
||||
uint32_t mDelay; ///< Delay Timer
|
||||
otPanId mPanId; ///< PAN ID
|
||||
uint16_t mChannel; ///< Channel
|
||||
uint16_t mWakeupChannel; ///< Wake-up Channel
|
||||
otPskc mPskc; ///< PSKc
|
||||
otSecurityPolicy mSecurityPolicy; ///< Security Policy
|
||||
otChannelMask mChannelMask; ///< Channel Mask
|
||||
otOperationalDatasetComponents mComponents; ///< Specifies which components are set in the Dataset.
|
||||
} otOperationalDataset;
|
||||
|
||||
/**
|
||||
* Maximum length of Operational Dataset in bytes.
|
||||
*/
|
||||
#define OT_OPERATIONAL_DATASET_MAX_LENGTH 254
|
||||
|
||||
/**
|
||||
* Represents an Active or Pending Operational Dataset.
|
||||
*
|
||||
* The Operational Dataset is TLV encoded as specified by Thread.
|
||||
*/
|
||||
typedef struct otOperationalDatasetTlvs
|
||||
{
|
||||
uint8_t mTlvs[OT_OPERATIONAL_DATASET_MAX_LENGTH]; ///< Operational Dataset TLVs.
|
||||
uint8_t mLength; ///< Size of Operational Dataset in bytes.
|
||||
} otOperationalDatasetTlvs;
|
||||
|
||||
/**
|
||||
* Represents meshcop TLV types.
|
||||
*/
|
||||
typedef enum otMeshcopTlvType
|
||||
{
|
||||
OT_MESHCOP_TLV_CHANNEL = 0, ///< meshcop Channel TLV
|
||||
OT_MESHCOP_TLV_PANID = 1, ///< meshcop Pan Id TLV
|
||||
OT_MESHCOP_TLV_EXTPANID = 2, ///< meshcop Extended Pan Id TLV
|
||||
OT_MESHCOP_TLV_NETWORKNAME = 3, ///< meshcop Network Name TLV
|
||||
OT_MESHCOP_TLV_PSKC = 4, ///< meshcop PSKc TLV
|
||||
OT_MESHCOP_TLV_NETWORKKEY = 5, ///< meshcop Network Key TLV
|
||||
OT_MESHCOP_TLV_NETWORK_KEY_SEQUENCE = 6, ///< meshcop Network Key Sequence TLV
|
||||
OT_MESHCOP_TLV_MESHLOCALPREFIX = 7, ///< meshcop Mesh Local Prefix TLV
|
||||
OT_MESHCOP_TLV_STEERING_DATA = 8, ///< meshcop Steering Data TLV
|
||||
OT_MESHCOP_TLV_BORDER_AGENT_RLOC = 9, ///< meshcop Border Agent Locator TLV
|
||||
OT_MESHCOP_TLV_COMMISSIONER_ID = 10, ///< meshcop Commissioner ID TLV
|
||||
OT_MESHCOP_TLV_COMM_SESSION_ID = 11, ///< meshcop Commissioner Session ID TLV
|
||||
OT_MESHCOP_TLV_SECURITYPOLICY = 12, ///< meshcop Security Policy TLV
|
||||
OT_MESHCOP_TLV_GET = 13, ///< meshcop Get TLV
|
||||
OT_MESHCOP_TLV_ACTIVETIMESTAMP = 14, ///< meshcop Active Timestamp TLV
|
||||
OT_MESHCOP_TLV_COMMISSIONER_UDP_PORT = 15, ///< meshcop Commissioner UDP Port TLV
|
||||
OT_MESHCOP_TLV_STATE = 16, ///< meshcop State TLV
|
||||
OT_MESHCOP_TLV_JOINER_DTLS = 17, ///< meshcop Joiner DTLS Encapsulation TLV
|
||||
OT_MESHCOP_TLV_JOINER_UDP_PORT = 18, ///< meshcop Joiner UDP Port TLV
|
||||
OT_MESHCOP_TLV_JOINER_IID = 19, ///< meshcop Joiner IID TLV
|
||||
OT_MESHCOP_TLV_JOINER_RLOC = 20, ///< meshcop Joiner Router Locator TLV
|
||||
OT_MESHCOP_TLV_JOINER_ROUTER_KEK = 21, ///< meshcop Joiner Router KEK TLV
|
||||
OT_MESHCOP_TLV_PROVISIONING_URL = 32, ///< meshcop Provisioning URL TLV
|
||||
OT_MESHCOP_TLV_VENDOR_NAME_TLV = 33, ///< meshcop Vendor Name TLV
|
||||
OT_MESHCOP_TLV_VENDOR_MODEL_TLV = 34, ///< meshcop Vendor Model TLV
|
||||
OT_MESHCOP_TLV_VENDOR_SW_VERSION_TLV = 35, ///< meshcop Vendor SW Version TLV
|
||||
OT_MESHCOP_TLV_VENDOR_DATA_TLV = 36, ///< meshcop Vendor Data TLV
|
||||
OT_MESHCOP_TLV_VENDOR_STACK_VERSION_TLV = 37, ///< meshcop Vendor Stack Version TLV
|
||||
OT_MESHCOP_TLV_UDP_ENCAPSULATION_TLV = 48, ///< meshcop UDP encapsulation TLV
|
||||
OT_MESHCOP_TLV_IPV6_ADDRESS_TLV = 49, ///< meshcop IPv6 address TLV
|
||||
OT_MESHCOP_TLV_PENDINGTIMESTAMP = 51, ///< meshcop Pending Timestamp TLV
|
||||
OT_MESHCOP_TLV_DELAYTIMER = 52, ///< meshcop Delay Timer TLV
|
||||
OT_MESHCOP_TLV_CHANNELMASK = 53, ///< meshcop Channel Mask TLV
|
||||
OT_MESHCOP_TLV_COUNT = 54, ///< meshcop Count TLV
|
||||
OT_MESHCOP_TLV_PERIOD = 55, ///< meshcop Period TLV
|
||||
OT_MESHCOP_TLV_SCAN_DURATION = 56, ///< meshcop Scan Duration TLV
|
||||
OT_MESHCOP_TLV_ENERGY_LIST = 57, ///< meshcop Energy List TLV
|
||||
OT_MESHCOP_TLV_THREAD_DOMAIN_NAME = 59, ///< meshcop Thread Domain Name TLV
|
||||
OT_MESHCOP_TLV_WAKEUP_CHANNEL = 74, ///< meshcop Wake-up Channel TLV
|
||||
OT_MESHCOP_TLV_DISCOVERYREQUEST = 128, ///< meshcop Discovery Request TLV
|
||||
OT_MESHCOP_TLV_DISCOVERYRESPONSE = 129, ///< meshcop Discovery Response TLV
|
||||
OT_MESHCOP_TLV_JOINERADVERTISEMENT = 241, ///< meshcop Joiner Advertisement TLV
|
||||
} otMeshcopTlvType;
|
||||
|
||||
/**
|
||||
* Pointer is called when a response to a MGMT_SET request is received or times out.
|
||||
*
|
||||
* @param[in] aResult A result of the operation.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The request was accepted by the leader.
|
||||
* @retval OT_ERROR_REJECTED The request was rejected by the leader.
|
||||
* @retval OT_ERROR_PARSE An error occurred during parsing the response.
|
||||
* @retval OT_ERROR_ABORT The request was reset by peer.
|
||||
* @retval OT_ERROR_RESPONSE_TIMEOUT No response or acknowledgment received during timeout period.
|
||||
*/
|
||||
typedef void (*otDatasetMgmtSetCallback)(otError aResult, void *aContext);
|
||||
|
||||
/**
|
||||
* Indicates whether a valid network is present in the Active Operational Dataset or not.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns TRUE if a valid network is present in the Active Operational Dataset, FALSE otherwise.
|
||||
*/
|
||||
bool otDatasetIsCommissioned(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the Active Operational Dataset.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aDataset A pointer to where the Active Operational Dataset will be placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the Active Operational Dataset.
|
||||
* @retval OT_ERROR_NOT_FOUND No corresponding value in the setting store.
|
||||
*/
|
||||
otError otDatasetGetActive(otInstance *aInstance, otOperationalDataset *aDataset);
|
||||
|
||||
/**
|
||||
* Gets the Active Operational Dataset.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aDataset A pointer to where the Active Operational Dataset will be placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the Active Operational Dataset.
|
||||
* @retval OT_ERROR_NOT_FOUND No corresponding value in the setting store.
|
||||
*/
|
||||
otError otDatasetGetActiveTlvs(otInstance *aInstance, otOperationalDatasetTlvs *aDataset);
|
||||
|
||||
/**
|
||||
* Sets the Active Operational Dataset.
|
||||
*
|
||||
* If the dataset does not include an Active Timestamp, the dataset is only partially complete.
|
||||
*
|
||||
* If Thread is enabled on a device that has a partially complete Active Dataset, the device will attempt to attach to
|
||||
* an existing Thread network using any existing information in the dataset. Only the Thread Network Key is needed to
|
||||
* attach to a network.
|
||||
*
|
||||
* If channel is not included in the dataset, the device will send MLE Announce messages across different channels to
|
||||
* find neighbors on other channels.
|
||||
*
|
||||
* If the device successfully attaches to a Thread network, the device will then retrieve the full Active Dataset from
|
||||
* its Parent. Note that a router-capable device will not transition to the Router or Leader roles until it has a
|
||||
* complete Active Dataset.
|
||||
*
|
||||
* This function consistently returns `OT_ERROR_NONE` and can effectively be treated as having a `void` return type.
|
||||
* Previously, other errors (e.g., `OT_ERROR_NOT_IMPLEMENTED`) were allowed for legacy reasons. However, as
|
||||
* non-volatile storage is now mandatory for Thread operation, any failure to save the dataset will trigger an
|
||||
* assertion. The `otError` return type is retained for backward compatibility.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDataset A pointer to the Active Operational Dataset.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the Active Operational Dataset.
|
||||
*/
|
||||
otError otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aDataset);
|
||||
|
||||
/**
|
||||
* Sets the Active Operational Dataset.
|
||||
*
|
||||
* If the dataset does not include an Active Timestamp, the dataset is only partially complete.
|
||||
*
|
||||
* If Thread is enabled on a device that has a partially complete Active Dataset, the device will attempt to attach to
|
||||
* an existing Thread network using any existing information in the dataset. Only the Thread Network Key is needed to
|
||||
* attach to a network.
|
||||
*
|
||||
* If channel is not included in the dataset, the device will send MLE Announce messages across different channels to
|
||||
* find neighbors on other channels.
|
||||
*
|
||||
* If the device successfully attaches to a Thread network, the device will then retrieve the full Active Dataset from
|
||||
* its Parent. Note that a router-capable device will not transition to the Router or Leader roles until it has a
|
||||
* complete Active Dataset.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDataset A pointer to the Active Operational Dataset.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the Active Operational Dataset.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aDataset is invalid. It is too long or contains incorrect TLV formatting.
|
||||
*/
|
||||
otError otDatasetSetActiveTlvs(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset);
|
||||
|
||||
/**
|
||||
* Gets the Pending Operational Dataset.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aDataset A pointer to where the Pending Operational Dataset will be placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the Pending Operational Dataset.
|
||||
* @retval OT_ERROR_NOT_FOUND No corresponding value in the setting store.
|
||||
*/
|
||||
otError otDatasetGetPending(otInstance *aInstance, otOperationalDataset *aDataset);
|
||||
|
||||
/**
|
||||
* Gets the Pending Operational Dataset.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aDataset A pointer to where the Pending Operational Dataset will be placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the Pending Operational Dataset.
|
||||
* @retval OT_ERROR_NOT_FOUND No corresponding value in the setting store.
|
||||
*/
|
||||
otError otDatasetGetPendingTlvs(otInstance *aInstance, otOperationalDatasetTlvs *aDataset);
|
||||
|
||||
/**
|
||||
* Sets the Pending Operational Dataset.
|
||||
*
|
||||
* This function consistently returns `OT_ERROR_NONE` and can effectively be treated as having a `void` return type.
|
||||
* Previously, other errors (e.g., `OT_ERROR_NOT_IMPLEMENTED`) were allowed for legacy reasons. However, as
|
||||
* non-volatile storage is now mandatory for Thread operation, any failure to save the dataset will trigger an
|
||||
* assertion. The `otError` return type is retained for backward compatibility.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDataset A pointer to the Pending Operational Dataset.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the Pending Operational Dataset.
|
||||
*/
|
||||
otError otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *aDataset);
|
||||
|
||||
/**
|
||||
* Sets the Pending Operational Dataset.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDataset A pointer to the Pending Operational Dataset.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the Pending Operational Dataset.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aDataset is invalid. It is too long or contains incorrect TLV formatting.
|
||||
*/
|
||||
otError otDatasetSetPendingTlvs(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset);
|
||||
|
||||
/**
|
||||
* Sends MGMT_ACTIVE_GET.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDatasetComponents A pointer to a Dataset Components structure specifying which components to request.
|
||||
* @param[in] aTlvTypes A pointer to array containing additional raw TLV types to be requested.
|
||||
* @param[in] aLength The length of @p aTlvTypes.
|
||||
* @param[in] aAddress A pointer to the IPv6 destination, if it is NULL, will use Leader ALOC as default.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
*/
|
||||
otError otDatasetSendMgmtActiveGet(otInstance *aInstance,
|
||||
const otOperationalDatasetComponents *aDatasetComponents,
|
||||
const uint8_t *aTlvTypes,
|
||||
uint8_t aLength,
|
||||
const otIp6Address *aAddress);
|
||||
|
||||
/**
|
||||
* Sends MGMT_ACTIVE_SET.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDataset A pointer to operational dataset.
|
||||
* @param[in] aTlvs A pointer to TLVs.
|
||||
* @param[in] aLength The length of TLVs.
|
||||
* @param[in] aCallback A pointer to a function that is called on response reception or timeout.
|
||||
* @param[in] aContext A pointer to application-specific context for @p aCallback.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
* @retval OT_ERROR_BUSY A previous request is ongoing.
|
||||
*/
|
||||
otError otDatasetSendMgmtActiveSet(otInstance *aInstance,
|
||||
const otOperationalDataset *aDataset,
|
||||
const uint8_t *aTlvs,
|
||||
uint8_t aLength,
|
||||
otDatasetMgmtSetCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Sends MGMT_PENDING_GET.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDatasetComponents A pointer to a Dataset Components structure specifying which components to request.
|
||||
* @param[in] aTlvTypes A pointer to array containing additional raw TLV types to be requested.
|
||||
* @param[in] aLength The length of @p aTlvTypes.
|
||||
* @param[in] aAddress A pointer to the IPv6 destination, if it is NULL, will use Leader ALOC as default.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
*/
|
||||
otError otDatasetSendMgmtPendingGet(otInstance *aInstance,
|
||||
const otOperationalDatasetComponents *aDatasetComponents,
|
||||
const uint8_t *aTlvTypes,
|
||||
uint8_t aLength,
|
||||
const otIp6Address *aAddress);
|
||||
|
||||
/**
|
||||
* Sends MGMT_PENDING_SET.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDataset A pointer to operational dataset.
|
||||
* @param[in] aTlvs A pointer to TLVs.
|
||||
* @param[in] aLength The length of TLVs.
|
||||
* @param[in] aCallback A pointer to a function that is called on response reception or timeout.
|
||||
* @param[in] aContext A pointer to application-specific context for @p aCallback.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
* @retval OT_ERROR_BUSY A previous request is ongoing.
|
||||
*/
|
||||
otError otDatasetSendMgmtPendingSet(otInstance *aInstance,
|
||||
const otOperationalDataset *aDataset,
|
||||
const uint8_t *aTlvs,
|
||||
uint8_t aLength,
|
||||
otDatasetMgmtSetCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Generates PSKc from a given pass-phrase, network name, and extended PAN ID.
|
||||
*
|
||||
* PSKc is used to establish the Commissioner Session.
|
||||
*
|
||||
* @param[in] aPassPhrase The commissioning pass-phrase.
|
||||
* @param[in] aNetworkName The network name for PSKc computation.
|
||||
* @param[in] aExtPanId The extended PAN ID for PSKc computation.
|
||||
* @param[out] aPskc A pointer to variable to output the generated PSKc.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully generate PSKc.
|
||||
* @retval OT_ERROR_INVALID_ARGS If any of the input arguments is invalid.
|
||||
*/
|
||||
otError otDatasetGeneratePskc(const char *aPassPhrase,
|
||||
const otNetworkName *aNetworkName,
|
||||
const otExtendedPanId *aExtPanId,
|
||||
otPskc *aPskc);
|
||||
|
||||
/**
|
||||
* Sets an `otNetworkName` instance from a given null terminated C string.
|
||||
*
|
||||
* @p aNameString must follow UTF-8 encoding and the Network Name length must not be longer than
|
||||
* `OT_NETWORK_NAME_MAX_SIZE`.
|
||||
*
|
||||
* @param[out] aNetworkName A pointer to the `otNetworkName` to set.
|
||||
* @param[in] aNameString A name C string.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set @p aNetworkName from @p aNameString.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aNameStrng is invalid (too long or does not follow UTF-8 encoding).
|
||||
*/
|
||||
otError otNetworkNameFromString(otNetworkName *aNetworkName, const char *aNameString);
|
||||
|
||||
/**
|
||||
* Parses an Operational Dataset from a given `otOperationalDatasetTlvs`.
|
||||
*
|
||||
* @param[in] aDatasetTlvs A pointer to dataset TLVs.
|
||||
* @param[out] aDataset A pointer to where the dataset will be placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set @p aDataset from @p aDatasetTlvs.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aDatasetTlvs's length is longer than `OT_OPERATIONAL_DATASET_MAX_LENGTH`.
|
||||
*/
|
||||
otError otDatasetParseTlvs(const otOperationalDatasetTlvs *aDatasetTlvs, otOperationalDataset *aDataset);
|
||||
|
||||
/**
|
||||
* Converts a given Operational Dataset to `otOperationalDatasetTlvs`.
|
||||
*
|
||||
* @param[in] aDataset An Operational dataset to convert to TLVs.
|
||||
* @param[out] aDatasetTlvs A pointer to dataset TLVs to return the result.
|
||||
*/
|
||||
void otDatasetConvertToTlvs(const otOperationalDataset *aDataset, otOperationalDatasetTlvs *aDatasetTlvs);
|
||||
|
||||
/**
|
||||
* Updates a given Operational Dataset.
|
||||
*
|
||||
* @p aDataset contains the fields to be updated and their new value.
|
||||
*
|
||||
* @param[in] aDataset Specifies the set of types and values to update.
|
||||
* @param[in,out] aDatasetTlvs A pointer to dataset TLVs to update.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully updated @p aDatasetTlvs.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aDataset contains invalid values.
|
||||
* @retval OT_ERROR_NO_BUFS Not enough space space in @p aDatasetTlvs to apply the update.
|
||||
*/
|
||||
otError otDatasetUpdateTlvs(const otOperationalDataset *aDataset, otOperationalDatasetTlvs *aDatasetTlvs);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_DATASET_H_
|
||||
93
Libs/util/third_party/openthread/include/openthread/dataset_ftd.h
vendored
Normal file
93
Libs/util/third_party/openthread/include/openthread/dataset_ftd.h
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Operational Dataset API (FTD only).
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_DATASET_FTD_H_
|
||||
#define OPENTHREAD_DATASET_FTD_H_
|
||||
|
||||
#include <openthread/dataset.h>
|
||||
#include <openthread/ip6.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-operational-dataset
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* For FTD only, creates a new Operational Dataset to use when forming a new network.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aDataset The Operational Dataset.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully created a new Operational Dataset.
|
||||
* @retval OT_ERROR_FAILED Failed to generate random values for new parameters.
|
||||
*/
|
||||
otError otDatasetCreateNewNetwork(otInstance *aInstance, otOperationalDataset *aDataset);
|
||||
|
||||
/**
|
||||
* For FTD only, gets a minimal delay timer.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval the value of minimal delay timer (in ms).
|
||||
*/
|
||||
uint32_t otDatasetGetDelayTimerMinimal(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* For FTD only, sets a minimal delay timer.
|
||||
*
|
||||
* @note This API is reserved for testing and demo purposes only. Changing settings with
|
||||
* this API will render a production application non-compliant with the Thread Specification.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDelayTimerMinimal The value of minimal delay timer (in ms).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set minimal delay timer.
|
||||
* @retval OT_ERROR_INVALID_ARGS If @p aDelayTimerMinimal is not valid.
|
||||
*/
|
||||
otError otDatasetSetDelayTimerMinimal(otInstance *aInstance, uint32_t aDelayTimerMinimal);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_DATASET_FTD_H_
|
||||
123
Libs/util/third_party/openthread/include/openthread/dataset_updater.h
vendored
Normal file
123
Libs/util/third_party/openthread/include/openthread/dataset_updater.h
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the OpenThread API for Dataset Updater module.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_DATASET_UPDATER_H_
|
||||
#define OPENTHREAD_DATASET_UPDATER_H_
|
||||
|
||||
#include <openthread/dataset.h>
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-operational-dataset
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* For FTD builds only, Dataset Updater includes functions to manage dataset updates.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This callback function pointer is called when a Dataset update request finishes, reporting success or failure status
|
||||
* of the Dataset update request.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aError The error status.
|
||||
* OT_ERROR_NONE indicates successful Dataset update.
|
||||
* OT_ERROR_INVALID_STATE indicates failure due invalid state (MLE being disabled).
|
||||
* OT_ERROR_ALREADY indicates failure due to another device within network requesting
|
||||
* a conflicting Dataset update.
|
||||
*
|
||||
* @param[in] aContext A pointer to the arbitrary context (provided by user in `otDatasetUpdaterRequestUpdate()`).
|
||||
*/
|
||||
typedef void (*otDatasetUpdaterCallback)(otError aError, void *aContext);
|
||||
|
||||
/**
|
||||
* Requests an update to Operational Dataset.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE` is enabled.
|
||||
*
|
||||
* @p aDataset should contain the fields to be updated and their new value. It must not contain Active or Pending
|
||||
* Timestamp fields. The Delay field is optional, if not provided a default value (1000 ms) would be used.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDataset A pointer to the Dataset containing the fields to change.
|
||||
* @param[in] aCallback A callback to indicate when Dataset update request finishes.
|
||||
* @param[in] aContext An arbitrary context passed to callback.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Dataset update started successfully (@p aCallback will be invoked on completion).
|
||||
* @retval OT_ERROR_INVALID_STATE Device is disabled or not fully configured (missing or incomplete Active Dataset).
|
||||
* @retval OT_ERROR_ALREADY The @p aDataset fields already match the existing Active Dataset.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aDataset is not valid (contains Active or Pending Timestamp).
|
||||
* @retval OT_ERROR_BUSY Cannot start update, a previous one is ongoing.
|
||||
* @retval OT_ERROR_NO_BUFS Could not allocated buffer to save Dataset.
|
||||
*/
|
||||
otError otDatasetUpdaterRequestUpdate(otInstance *aInstance,
|
||||
const otOperationalDataset *aDataset,
|
||||
otDatasetUpdaterCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Cancels an ongoing (if any) Operational Dataset update request.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otDatasetUpdaterCancelUpdate(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Indicates whether there is an ongoing Operation Dataset update request.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval TRUE There is an ongoing update.
|
||||
* @retval FALSE There is no ongoing update.
|
||||
*/
|
||||
bool otDatasetUpdaterIsUpdateOngoing(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_DATASET_UPDATER_H_
|
||||
110
Libs/util/third_party/openthread/include/openthread/diag.h
vendored
Normal file
110
Libs/util/third_party/openthread/include/openthread/diag.h
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the OpenThread API for Factory Diagnostics.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_DIAG_H_
|
||||
#define OPENTHREAD_DIAG_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-factory-diagnostics
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control the Thread stack's execution.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Represents the pointer to callback to output diag messages. */
|
||||
typedef otPlatDiagOutputCallback otDiagOutputCallback;
|
||||
|
||||
/**
|
||||
* Sets the diag output callback.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aCallback A pointer to a function that is called on outputting diag messages.
|
||||
* @param[in] aContext A pointer to the user context.
|
||||
*/
|
||||
void otDiagSetOutputCallback(otInstance *aInstance, otDiagOutputCallback aCallback, void *aContext);
|
||||
|
||||
/**
|
||||
* Processes a factory diagnostics command line.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aArgsLength The number of elements in @p aArgs.
|
||||
* @param[in] aArgs An array of arguments.
|
||||
*
|
||||
* @retval OT_ERROR_INVALID_ARGS The command is supported but invalid arguments provided.
|
||||
* @retval OT_ERROR_NONE The command is successfully process.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED The command is not supported.
|
||||
*/
|
||||
otError otDiagProcessCmd(otInstance *aInstance, uint8_t aArgsLength, char *aArgs[]);
|
||||
|
||||
/**
|
||||
* Processes a factory diagnostics command line.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aString A NULL-terminated input string.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The command is successfully process.
|
||||
* @retval OT_ERROR_INVALID_ARGS The command is supported but invalid arguments provided.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED The command is not supported.
|
||||
* @retval OT_ERROR_NO_BUFS The command string is too long.
|
||||
*/
|
||||
otError otDiagProcessCmdLine(otInstance *aInstance, const char *aString);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the factory diagnostics mode is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval TRUE if factory diagnostics mode is enabled
|
||||
* @retval FALSE if factory diagnostics mode is disabled.
|
||||
*/
|
||||
bool otDiagIsEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_DIAG_H_
|
||||
189
Libs/util/third_party/openthread/include/openthread/dns.h
vendored
Normal file
189
Libs/util/third_party/openthread/include/openthread/dns.h
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the top-level DNS functions for the OpenThread library.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_DNS_H_
|
||||
#define OPENTHREAD_DNS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-dns
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control DNS communication.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define OT_DNS_MAX_NAME_SIZE 255 ///< Maximum name string size (includes null char at the end of string).
|
||||
|
||||
#define OT_DNS_MAX_LABEL_SIZE 64 ///< Maximum label string size (include null char at the end of string).
|
||||
|
||||
#define OT_DNS_TXT_KEY_MIN_LENGTH 1 ///< Minimum length of TXT record key string (RFC 6763 - section 6.4).
|
||||
|
||||
#define OT_DNS_TXT_KEY_MAX_LENGTH 9 ///< Recommended maximum length of TXT record key string (RFC 6763 - section 6.4).
|
||||
|
||||
#define OT_DNS_TXT_KEY_ITER_MAX_LENGTH 64 ///< Maximum length of TXT key string supported by `otDnsTxtEntryIterator`.
|
||||
|
||||
/**
|
||||
* Represents a TXT record entry representing a key/value pair (RFC 6763 - section 6.3).
|
||||
*
|
||||
* The string buffers pointed to by `mKey` and `mValue` MUST persist and remain unchanged after an instance of such
|
||||
* structure is passed to OpenThread (as part of `otSrpClientService` instance).
|
||||
*
|
||||
* An array of `otDnsTxtEntry` entries are used in `otSrpClientService` to specify the full TXT record (a list of
|
||||
* entries).
|
||||
*/
|
||||
typedef struct otDnsTxtEntry
|
||||
{
|
||||
/**
|
||||
* The TXT record key string.
|
||||
*
|
||||
* If `mKey` is not NULL, then it MUST be a null-terminated C string. The entry is treated as key/value pair with
|
||||
* `mValue` buffer providing the value.
|
||||
* - The entry is encoded as follows:
|
||||
* - A single string length byte followed by "key=value" format (without the quotation marks).
|
||||
- In this case, the overall encoded length must be 255 bytes or less.
|
||||
* - If `mValue` is NULL, then key is treated as a boolean attribute and encoded as "key" (with no `=`).
|
||||
* - If `mValue` is not NULL but `mValueLength` is zero, then it is treated as empty value and encoded as "key=".
|
||||
*
|
||||
* If `mKey` is NULL, then `mValue` buffer is treated as an already encoded TXT-DATA and is appended as is in the
|
||||
* DNS message.
|
||||
*/
|
||||
const char *mKey;
|
||||
const uint8_t *mValue; ///< The TXT record value or already encoded TXT-DATA (depending on `mKey`).
|
||||
uint16_t mValueLength; ///< Number of bytes in `mValue` buffer.
|
||||
} otDnsTxtEntry;
|
||||
|
||||
/**
|
||||
* Represents an iterator for TXT record entries (key/value pairs).
|
||||
*
|
||||
* The data fields in this structure are intended for use by OpenThread core and caller should not read or change them.
|
||||
*/
|
||||
typedef struct otDnsTxtEntryIterator
|
||||
{
|
||||
const void *mPtr;
|
||||
uint16_t mData[2];
|
||||
char mChar[OT_DNS_TXT_KEY_ITER_MAX_LENGTH + 1];
|
||||
} otDnsTxtEntryIterator;
|
||||
|
||||
/**
|
||||
* Initializes a TXT record iterator.
|
||||
*
|
||||
* The buffer pointer @p aTxtData and its content MUST persist and remain unchanged while @p aIterator object
|
||||
* is being used.
|
||||
*
|
||||
* @param[in] aIterator A pointer to the iterator to initialize (MUST NOT be NULL).
|
||||
* @param[in] aTxtData A pointer to buffer containing the encoded TXT data.
|
||||
* @param[in] aTxtDataLength The length (number of bytes) of @p aTxtData.
|
||||
*/
|
||||
void otDnsInitTxtEntryIterator(otDnsTxtEntryIterator *aIterator, const uint8_t *aTxtData, uint16_t aTxtDataLength);
|
||||
|
||||
/**
|
||||
* Parses the TXT data from an iterator and gets the next TXT record entry (key/value pair).
|
||||
*
|
||||
* The @p aIterator MUST be initialized using `otDnsInitTxtEntryIterator()` before calling this function and the TXT
|
||||
* data buffer used to initialize the iterator MUST persist and remain unchanged. Otherwise the behavior of this
|
||||
* function is undefined.
|
||||
*
|
||||
* If the parsed key string length is smaller than or equal to `OT_DNS_TXT_KEY_ITER_MAX_LENGTH` the key string is
|
||||
* returned in `mKey` in @p aEntry. But if the key is longer, then `mKey` is set to NULL and the entire encoded TXT
|
||||
* entry string is returned in `mValue` and `mValueLength`.
|
||||
*
|
||||
* @param[in] aIterator A pointer to the iterator (MUST NOT be NULL).
|
||||
* @param[out] aEntry A pointer to a `otDnsTxtEntry` structure to output the parsed/read entry (MUST NOT be NULL).
|
||||
*
|
||||
* @retval OT_ERROR_NONE The next entry was parsed successfully. @p aEntry is updated.
|
||||
* @retval OT_ERROR_NOT_FOUND No more entries in the TXT data.
|
||||
* @retval OT_ERROR_PARSE The TXT data from @p aIterator is not well-formed.
|
||||
*/
|
||||
otError otDnsGetNextTxtEntry(otDnsTxtEntryIterator *aIterator, otDnsTxtEntry *aEntry);
|
||||
|
||||
/**
|
||||
* Encodes a given list of TXT record entries (key/value pairs) into TXT data (following format specified by RFC 6763).
|
||||
*
|
||||
* @param[in] aTxtEntries Pointer to an array of `otDnsTxtEntry`.
|
||||
* @param[in] aNumTxtEntries Number of entries in @p aTxtEntries array.
|
||||
* @param[out] aTxtData A pointer to a buffer to output the encoded TXT data.
|
||||
* @param[in,out] aTxtDataLength On input, size of buffer @p aTxtData. On output, length of the encoded TXT data.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Encoded TXT data successfully, @p aTxtData and @p aTxtDataLength are updated.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aTxtEntries is not valid.
|
||||
* @retval OT_ERROR_NO_BUS Could not fit the encoded data in @p aTxtData buffer with its @p aTxtDataLength.
|
||||
*/
|
||||
otError otDnsEncodeTxtData(const otDnsTxtEntry *aTxtEntries,
|
||||
uint16_t aNumTxtEntries,
|
||||
uint8_t *aTxtData,
|
||||
uint16_t *aTxtDataLength);
|
||||
|
||||
/**
|
||||
* Enables/disables the "DNS name compression" mode.
|
||||
*
|
||||
* By default DNS name compression is enabled. When disabled, DNS names are appended as full and never compressed. This
|
||||
* is applicable to OpenThread's DNS and SRP client/server modules.
|
||||
*
|
||||
* This is intended for testing only and available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` config is enabled.
|
||||
*
|
||||
* Note that in the case `OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE` is used, this mode applies to all OpenThread
|
||||
* instances (i.e., calling this function enables/disables the compression mode on all OpenThread instances).
|
||||
*
|
||||
* @param[in] aEnabled TRUE to enable the "DNS name compression" mode, FALSE to disable.
|
||||
*/
|
||||
void otDnsSetNameCompressionEnabled(bool aEnabled);
|
||||
|
||||
/**
|
||||
* Indicates whether the "DNS name compression" mode is enabled or not.
|
||||
*
|
||||
* This is intended for testing only and available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` config is enabled.
|
||||
*
|
||||
* @returns TRUE if the "DNS name compression" mode is enabled, FALSE otherwise.
|
||||
*/
|
||||
bool otDnsIsNameCompressionEnabled(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_DNS_H_
|
||||
657
Libs/util/third_party/openthread/include/openthread/dns_client.h
vendored
Normal file
657
Libs/util/third_party/openthread/include/openthread/dns_client.h
vendored
Normal file
@@ -0,0 +1,657 @@
|
||||
/*
|
||||
* Copyright (c) 2017-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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the top-level DNS functions for the OpenThread library.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_DNS_CLIENT_H_
|
||||
#define OPENTHREAD_DNS_CLIENT_H_
|
||||
|
||||
#include <openthread/dns.h>
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/ip6.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-dns
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control DNS communication.
|
||||
*
|
||||
* The functions in this module are available only if feature `OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE` is enabled.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Type represents the "Recursion Desired" (RD) flag in an `otDnsQueryConfig`.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_DNS_FLAG_UNSPECIFIED = 0, ///< Indicates the flag is not specified.
|
||||
OT_DNS_FLAG_RECURSION_DESIRED = 1, ///< Indicates DNS name server can resolve the query recursively.
|
||||
OT_DNS_FLAG_NO_RECURSION = 2, ///< Indicates DNS name server can not resolve the query recursively.
|
||||
} otDnsRecursionFlag;
|
||||
|
||||
/**
|
||||
* Type represents the NAT64 mode in an `otDnsQueryConfig`.
|
||||
*
|
||||
* The NAT64 mode indicates whether to allow or disallow NAT64 address translation during DNS client address resolution.
|
||||
* This mode is only used when `OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE` is enabled.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_DNS_NAT64_UNSPECIFIED = 0, ///< NAT64 mode is not specified. Use default NAT64 mode.
|
||||
OT_DNS_NAT64_ALLOW = 1, ///< Allow NAT64 address translation during DNS client address resolution.
|
||||
OT_DNS_NAT64_DISALLOW = 2, ///< Do not allow NAT64 address translation during DNS client address resolution.
|
||||
} otDnsNat64Mode;
|
||||
|
||||
/**
|
||||
* Type represents the service resolution mode in an `otDnsQueryConfig`.
|
||||
*
|
||||
* This is only used during DNS client service resolution `otDnsClientResolveService()`. It determines which
|
||||
* record types to query.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_DNS_SERVICE_MODE_UNSPECIFIED = 0, ///< Mode is not specified. Use default service mode.
|
||||
OT_DNS_SERVICE_MODE_SRV = 1, ///< Query for SRV record only.
|
||||
OT_DNS_SERVICE_MODE_TXT = 2, ///< Query for TXT record only.
|
||||
OT_DNS_SERVICE_MODE_SRV_TXT = 3, ///< Query for both SRV and TXT records in same message.
|
||||
OT_DNS_SERVICE_MODE_SRV_TXT_SEPARATE = 4, ///< Query in parallel for SRV and TXT using separate messages.
|
||||
OT_DNS_SERVICE_MODE_SRV_TXT_OPTIMIZE = 5, ///< Query for TXT/SRV together first, if fails then query separately.
|
||||
} otDnsServiceMode;
|
||||
|
||||
/**
|
||||
* Type represents the DNS transport protocol in an `otDnsQueryConfig`.
|
||||
*
|
||||
* This `OT_DNS_TRANSPORT_TCP` is only supported when `OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE` is enabled.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_DNS_TRANSPORT_UNSPECIFIED = 0, /// DNS transport is unspecified.
|
||||
OT_DNS_TRANSPORT_UDP = 1, /// DNS query should be sent via UDP.
|
||||
OT_DNS_TRANSPORT_TCP = 2, /// DNS query should be sent via TCP.
|
||||
} otDnsTransportProto;
|
||||
|
||||
/**
|
||||
* Represents a DNS query configuration.
|
||||
*
|
||||
* Any of the fields in this structure can be set to zero to indicate that it is not specified. How the unspecified
|
||||
* fields are treated is determined by the function which uses the instance of `otDnsQueryConfig`.
|
||||
*/
|
||||
typedef struct otDnsQueryConfig
|
||||
{
|
||||
otSockAddr mServerSockAddr; ///< Server address (IPv6 addr/port). All zero or zero port for unspecified.
|
||||
uint32_t mResponseTimeout; ///< Wait time (in msec) to rx response. Zero indicates unspecified value.
|
||||
uint8_t mMaxTxAttempts; ///< Maximum tx attempts before reporting failure. Zero for unspecified value.
|
||||
otDnsRecursionFlag mRecursionFlag; ///< Indicates whether the server can resolve the query recursively or not.
|
||||
otDnsNat64Mode mNat64Mode; ///< Allow/Disallow NAT64 address translation during address resolution.
|
||||
otDnsServiceMode mServiceMode; ///< Determines which records to query during service resolution.
|
||||
otDnsTransportProto mTransportProto; ///< Select default transport protocol.
|
||||
} otDnsQueryConfig;
|
||||
|
||||
/**
|
||||
* Gets the current default query config used by DNS client.
|
||||
*
|
||||
* When OpenThread stack starts, the default DNS query config is determined from a set of OT config options such as
|
||||
* `OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_IP6_ADDRESS`, `_DEFAULT_SERVER_PORT`, `_DEFAULT_RESPONSE_TIMEOUT`, etc.
|
||||
* (see `config/dns_client.h` for all related config options).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the current default config being used by DNS client.
|
||||
*/
|
||||
const otDnsQueryConfig *otDnsClientGetDefaultConfig(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the default query config on DNS client.
|
||||
*
|
||||
* @note Any ongoing query will continue to use the config from when it was started. The new default config will be
|
||||
* used for any future DNS queries.
|
||||
*
|
||||
* The @p aConfig can be NULL. In this case the default config will be set to the defaults from OT config options
|
||||
* `OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_{}`. This resets the default query config back to to the config when the
|
||||
* OpenThread stack starts.
|
||||
*
|
||||
* In a non-NULL @p aConfig, caller can choose to leave some of the fields in `otDnsQueryConfig` instance unspecified
|
||||
* (value zero). The unspecified fields are replaced by the corresponding OT config option definitions
|
||||
* `OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_{}` to form the default query config.
|
||||
*
|
||||
* When `OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_ADDRESS_AUTO_SET_ENABLE` is enabled, the server's IPv6 address in
|
||||
* the default config is automatically set and updated by DNS client. This is done only when user does not explicitly
|
||||
* set or specify it. This behavior requires SRP client and its auto-start feature to be enabled. SRP client will then
|
||||
* monitor the Thread Network Data for DNS/SRP Service entries to select an SRP server. The selected SRP server address
|
||||
* is also set as the DNS server address in the default config.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aConfig A pointer to the new query config to use as default.
|
||||
*/
|
||||
void otDnsClientSetDefaultConfig(otInstance *aInstance, const otDnsQueryConfig *aConfig);
|
||||
|
||||
/**
|
||||
* An opaque representation of a response to an address resolution DNS query.
|
||||
*
|
||||
* Pointers to instance of this type are provided from callback `otDnsAddressCallback`.
|
||||
*/
|
||||
typedef struct otDnsAddressResponse otDnsAddressResponse;
|
||||
|
||||
/**
|
||||
* Pointer is called when a DNS response is received for an address resolution query.
|
||||
*
|
||||
* Within this callback the user can use `otDnsAddressResponseGet{Item}()` functions along with the @p aResponse
|
||||
* pointer to get more info about the response.
|
||||
*
|
||||
* The @p aResponse pointer can only be used within this callback and after returning from this function it will not
|
||||
* stay valid, so the user MUST NOT retain the @p aResponse pointer for later use.
|
||||
*
|
||||
* @param[in] aError The result of the DNS transaction.
|
||||
* @param[in] aResponse A pointer to the response (it is always non-NULL).
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*
|
||||
* The @p aError can have the following:
|
||||
*
|
||||
* - OT_ERROR_NONE A response was received successfully.
|
||||
* - OT_ERROR_ABORT A DNS transaction was aborted by stack.
|
||||
* - OT_ERROR_RESPONSE_TIMEOUT No DNS response has been received within timeout.
|
||||
*
|
||||
* If the server rejects the address resolution request the error code from server is mapped as follow:
|
||||
*
|
||||
* - (0) NOERROR Success (no error condition) -> OT_ERROR_NONE
|
||||
* - (1) FORMERR Server unable to interpret due to format error -> OT_ERROR_PARSE
|
||||
* - (2) SERVFAIL Server encountered an internal failure -> OT_ERROR_FAILED
|
||||
* - (3) NXDOMAIN Name that ought to exist, does not exist -> OT_ERROR_NOT_FOUND
|
||||
* - (4) NOTIMP Server does not support the query type (OpCode) -> OT_ERROR_NOT_IMPLEMENTED
|
||||
* - (5) REFUSED Server refused for policy/security reasons -> OT_ERROR_SECURITY
|
||||
* - (6) YXDOMAIN Some name that ought not to exist, does exist -> OT_ERROR_DUPLICATED
|
||||
* - (7) YXRRSET Some RRset that ought not to exist, does exist -> OT_ERROR_DUPLICATED
|
||||
* - (8) NXRRSET Some RRset that ought to exist, does not exist -> OT_ERROR_NOT_FOUND
|
||||
* - (9) NOTAUTH Service is not authoritative for zone -> OT_ERROR_SECURITY
|
||||
* - (10) NOTZONE A name is not in the zone -> OT_ERROR_PARSE
|
||||
* - (20) BADNAME Bad name -> OT_ERROR_PARSE
|
||||
* - (21) BADALG Bad algorithm -> OT_ERROR_SECURITY
|
||||
* - (22) BADTRUN Bad truncation -> OT_ERROR_PARSE
|
||||
* - Other response codes -> OT_ERROR_FAILED
|
||||
*/
|
||||
typedef void (*otDnsAddressCallback)(otError aError, const otDnsAddressResponse *aResponse, void *aContext);
|
||||
|
||||
/**
|
||||
* Sends an address resolution DNS query for AAAA (IPv6) record(s) for a given host name.
|
||||
*
|
||||
* The @p aConfig can be NULL. In this case the default config (from `otDnsClientGetDefaultConfig()`) will be used as
|
||||
* the config for this query. In a non-NULL @p aConfig, some of the fields can be left unspecified (value zero). The
|
||||
* unspecified fields are then replaced by the values from the default config.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aHostName The host name for which to query the address (MUST NOT be NULL).
|
||||
* @param[in] aCallback A function pointer that shall be called on response reception or time-out.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
* @param[in] aConfig A pointer to the config to use for this query.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Query sent successfully. @p aCallback will be invoked to report the status.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer to prepare and send query.
|
||||
* @retval OT_ERROR_INVALID_ARGS The host name is not valid format.
|
||||
* @retval OT_ERROR_INVALID_STATE Cannot send query since Thread interface is not up.
|
||||
*/
|
||||
otError otDnsClientResolveAddress(otInstance *aInstance,
|
||||
const char *aHostName,
|
||||
otDnsAddressCallback aCallback,
|
||||
void *aContext,
|
||||
const otDnsQueryConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Sends an address resolution DNS query for A (IPv4) record(s) for a given host name.
|
||||
*
|
||||
* Requires and is available when `OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE` is enabled.
|
||||
*
|
||||
* When a successful response is received, the addresses are returned from @p aCallback as NAT64 IPv6 translated
|
||||
* versions of the IPv4 addresses from the query response.
|
||||
*
|
||||
* The @p aConfig can be NULL. In this case the default config (from `otDnsClientGetDefaultConfig()`) will be used as
|
||||
* the config for this query. In a non-NULL @p aConfig, some of the fields can be left unspecified (value zero). The
|
||||
* unspecified fields are then replaced by the values from the default config.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aHostName The host name for which to query the address (MUST NOT be NULL).
|
||||
* @param[in] aCallback A function pointer that shall be called on response reception or time-out.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
* @param[in] aConfig A pointer to the config to use for this query.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Query sent successfully. @p aCallback will be invoked to report the status.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer to prepare and send query.
|
||||
* @retval OT_ERROR_INVALID_ARGS The host name is not valid format or NAT64 is not enabled in config.
|
||||
* @retval OT_ERROR_INVALID_STATE Cannot send query since Thread interface is not up.
|
||||
*/
|
||||
otError otDnsClientResolveIp4Address(otInstance *aInstance,
|
||||
const char *aHostName,
|
||||
otDnsAddressCallback aCallback,
|
||||
void *aContext,
|
||||
const otDnsQueryConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Gets the full host name associated with an address resolution DNS response.
|
||||
*
|
||||
* MUST only be used from `otDnsAddressCallback`.
|
||||
*
|
||||
* @param[in] aResponse A pointer to the response.
|
||||
* @param[out] aNameBuffer A buffer to char array to output the full host name (MUST NOT be NULL).
|
||||
* @param[in] aNameBufferSize The size of @p aNameBuffer.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The full host name was read successfully.
|
||||
* @retval OT_ERROR_NO_BUFS The name does not fit in @p aNameBuffer.
|
||||
*/
|
||||
otError otDnsAddressResponseGetHostName(const otDnsAddressResponse *aResponse,
|
||||
char *aNameBuffer,
|
||||
uint16_t aNameBufferSize);
|
||||
|
||||
/**
|
||||
* Gets an IPv6 address associated with an address resolution DNS response.
|
||||
*
|
||||
* MUST only be used from `otDnsAddressCallback`.
|
||||
*
|
||||
* The response may include multiple IPv6 address records. @p aIndex can be used to iterate through the list of
|
||||
* addresses. Index zero gets the first address and so on. When we reach end of the list, `OT_ERROR_NOT_FOUND` is
|
||||
* returned.
|
||||
*
|
||||
* @param[in] aResponse A pointer to the response.
|
||||
* @param[in] aIndex The address record index to retrieve.
|
||||
* @param[out] aAddress A pointer to a IPv6 address to output the address (MUST NOT be NULL).
|
||||
* @param[out] aTtl A pointer to an `uint32_t` to output TTL for the address. It can be NULL if caller does not
|
||||
* want to get the TTL.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The address was read successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND No address record in @p aResponse at @p aIndex.
|
||||
* @retval OT_ERROR_PARSE Could not parse the records in the @p aResponse.
|
||||
* @retval OT_ERROR_INVALID_STATE No NAT64 prefix (applicable only when NAT64 is allowed).
|
||||
*/
|
||||
otError otDnsAddressResponseGetAddress(const otDnsAddressResponse *aResponse,
|
||||
uint16_t aIndex,
|
||||
otIp6Address *aAddress,
|
||||
uint32_t *aTtl);
|
||||
|
||||
/**
|
||||
* An opaque representation of a response to a browse (service instance enumeration) DNS query.
|
||||
*
|
||||
* Pointers to instance of this type are provided from callback `otDnsBrowseCallback`.
|
||||
*/
|
||||
typedef struct otDnsBrowseResponse otDnsBrowseResponse;
|
||||
|
||||
/**
|
||||
* Pointer is called when a DNS response is received for a browse (service instance enumeration) query.
|
||||
*
|
||||
* Within this callback the user can use `otDnsBrowseResponseGet{Item}()` functions along with the @p aResponse
|
||||
* pointer to get more info about the response.
|
||||
*
|
||||
* The @p aResponse pointer can only be used within this callback and after returning from this function it will not
|
||||
* stay valid, so the user MUST NOT retain the @p aResponse pointer for later use.
|
||||
*
|
||||
* @param[in] aError The result of the DNS transaction.
|
||||
* @param[in] aResponse A pointer to the response (it is always non-NULL).
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*
|
||||
* For the full list of possible values for @p aError, please see `otDnsAddressCallback()`.
|
||||
*/
|
||||
typedef void (*otDnsBrowseCallback)(otError aError, const otDnsBrowseResponse *aResponse, void *aContext);
|
||||
|
||||
/**
|
||||
* Provides info for a DNS service instance.
|
||||
*/
|
||||
typedef struct otDnsServiceInfo
|
||||
{
|
||||
uint32_t mTtl; ///< Service record TTL (in seconds).
|
||||
uint16_t mPort; ///< Service port number.
|
||||
uint16_t mPriority; ///< Service priority.
|
||||
uint16_t mWeight; ///< Service weight.
|
||||
char *mHostNameBuffer; ///< Buffer to output the service host name (can be NULL if not needed).
|
||||
uint16_t mHostNameBufferSize; ///< Size of `mHostNameBuffer`.
|
||||
otIp6Address mHostAddress; ///< The host IPv6 address. Set to all zero if not available.
|
||||
uint32_t mHostAddressTtl; ///< The host address TTL.
|
||||
uint8_t *mTxtData; ///< Buffer to output TXT data (can be NULL if not needed).
|
||||
uint16_t mTxtDataSize; ///< On input, size of `mTxtData` buffer. On output number bytes written.
|
||||
bool mTxtDataTruncated; ///< Indicates if TXT data could not fit in `mTxtDataSize` and was truncated.
|
||||
uint32_t mTxtDataTtl; ///< The TXT data TTL.
|
||||
} otDnsServiceInfo;
|
||||
|
||||
/**
|
||||
* Sends a DNS browse (service instance enumeration) query for a given service name.
|
||||
*
|
||||
* Is available when `OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE` is enabled.
|
||||
*
|
||||
* The @p aConfig can be NULL. In this case the default config (from `otDnsClientGetDefaultConfig()`) will be used as
|
||||
* the config for this query. In a non-NULL @p aConfig, some of the fields can be left unspecified (value zero). The
|
||||
* unspecified fields are then replaced by the values from the default config.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aServiceName The service name to query for (MUST NOT be NULL).
|
||||
* @param[in] aCallback A function pointer that shall be called on response reception or time-out.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
* @param[in] aConfig A pointer to the config to use for this query.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Query sent successfully. @p aCallback will be invoked to report the status.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer to prepare and send query.
|
||||
*/
|
||||
otError otDnsClientBrowse(otInstance *aInstance,
|
||||
const char *aServiceName,
|
||||
otDnsBrowseCallback aCallback,
|
||||
void *aContext,
|
||||
const otDnsQueryConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Gets the service name associated with a DNS browse (service instance enumeration) response.
|
||||
*
|
||||
* MUST only be used from `otDnsBrowseCallback`.
|
||||
*
|
||||
* @param[in] aResponse A pointer to the response.
|
||||
* @param[out] aNameBuffer A buffer to char array to output the service name (MUST NOT be NULL).
|
||||
* @param[in] aNameBufferSize The size of @p aNameBuffer.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The service name was read successfully.
|
||||
* @retval OT_ERROR_NO_BUFS The name does not fit in @p aNameBuffer.
|
||||
*/
|
||||
otError otDnsBrowseResponseGetServiceName(const otDnsBrowseResponse *aResponse,
|
||||
char *aNameBuffer,
|
||||
uint16_t aNameBufferSize);
|
||||
|
||||
/**
|
||||
* Gets a service instance associated with a DNS browse (service instance enumeration) response.
|
||||
*
|
||||
* MUST only be used from `otDnsBrowseCallback`.
|
||||
*
|
||||
* The response may include multiple service instance records. @p aIndex can be used to iterate through the list. Index
|
||||
* zero gives the first record. When we reach end of the list, `OT_ERROR_NOT_FOUND` is returned.
|
||||
*
|
||||
* Note that this function gets the service instance label and not the full service instance name which is of the form
|
||||
* `<Instance>.<Service>.<Domain>`.
|
||||
*
|
||||
* @param[in] aResponse A pointer to the response.
|
||||
* @param[in] aIndex The service instance record index to retrieve.
|
||||
* @param[out] aLabelBuffer A buffer to char array to output the service instance label (MUST NOT be NULL).
|
||||
* @param[in] aLabelBufferSize The size of @p aLabelBuffer.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The service instance was read successfully.
|
||||
* @retval OT_ERROR_NO_BUFS The name does not fit in @p aNameBuffer.
|
||||
* @retval OT_ERROR_NOT_FOUND No service instance record in @p aResponse at @p aIndex.
|
||||
* @retval OT_ERROR_PARSE Could not parse the records in the @p aResponse.
|
||||
*/
|
||||
otError otDnsBrowseResponseGetServiceInstance(const otDnsBrowseResponse *aResponse,
|
||||
uint16_t aIndex,
|
||||
char *aLabelBuffer,
|
||||
uint8_t aLabelBufferSize);
|
||||
|
||||
/**
|
||||
* Gets info for a service instance from a DNS browse (service instance enumeration) response.
|
||||
*
|
||||
* MUST only be used from `otDnsBrowseCallback`.
|
||||
*
|
||||
* A browse DNS response can include SRV, TXT, and AAAA records for the service instances that are enumerated. This is
|
||||
* a SHOULD and not a MUST requirement, and servers/resolvers are not required to provide this. This function attempts
|
||||
* to retrieve this info for a given service instance when available.
|
||||
*
|
||||
* - If no matching SRV record is found in @p aResponse, `OT_ERROR_NOT_FOUND` is returned. In this case, no additional
|
||||
* records (no TXT and/or AAAA) are read.
|
||||
* - If a matching SRV record is found in @p aResponse, @p aServiceInfo is updated and `OT_ERROR_NONE` is returned.
|
||||
* - If no matching TXT record is found in @p aResponse, `mTxtDataSize` in @p aServiceInfo is set to zero.
|
||||
* - If TXT data length is greater than `mTxtDataSize`, it is read partially and `mTxtDataTruncated` is set to true.
|
||||
* - If no matching AAAA record is found in @p aResponse, `mHostAddress is set to all zero or unspecified address.
|
||||
* - If there are multiple AAAA records for the host name in @p aResponse, `mHostAddress` is set to the first one. The
|
||||
* other addresses can be retrieved using `otDnsBrowseResponseGetHostAddress()`.
|
||||
*
|
||||
* @param[in] aResponse A pointer to the response.
|
||||
* @param[in] aInstanceLabel The service instance label (MUST NOT be NULL).
|
||||
* @param[out] aServiceInfo A `ServiceInfo` to output the service instance information (MUST NOT be NULL).
|
||||
*
|
||||
* @retval OT_ERROR_NONE The service instance info was read. @p aServiceInfo is updated.
|
||||
* @retval OT_ERROR_NOT_FOUND Could not find a matching SRV record for @p aInstanceLabel.
|
||||
* @retval OT_ERROR_NO_BUFS The host name and/or TXT data could not fit in the given buffers.
|
||||
* @retval OT_ERROR_PARSE Could not parse the records in the @p aResponse.
|
||||
*/
|
||||
otError otDnsBrowseResponseGetServiceInfo(const otDnsBrowseResponse *aResponse,
|
||||
const char *aInstanceLabel,
|
||||
otDnsServiceInfo *aServiceInfo);
|
||||
|
||||
/**
|
||||
* Gets the host IPv6 address from a DNS browse (service instance enumeration) response.
|
||||
*
|
||||
* MUST only be used from `otDnsBrowseCallback`.
|
||||
*
|
||||
* The response can include zero or more IPv6 address records. @p aIndex can be used to iterate through the list of
|
||||
* addresses. Index zero gets the first address and so on. When we reach end of the list, `OT_ERROR_NOT_FOUND` is
|
||||
* returned.
|
||||
*
|
||||
* @param[in] aResponse A pointer to the response.
|
||||
* @param[in] aHostName The host name to get the address (MUST NOT be NULL).
|
||||
* @param[in] aIndex The address record index to retrieve.
|
||||
* @param[out] aAddress A pointer to a IPv6 address to output the address (MUST NOT be NULL).
|
||||
* @param[out] aTtl A pointer to an `uint32_t` to output TTL for the address. It can be NULL if caller does
|
||||
* not want to get the TTL.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The address was read successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND No address record for @p aHostname in @p aResponse at @p aIndex.
|
||||
* @retval OT_ERROR_PARSE Could not parse the records in the @p aResponse.
|
||||
*/
|
||||
otError otDnsBrowseResponseGetHostAddress(const otDnsBrowseResponse *aResponse,
|
||||
const char *aHostName,
|
||||
uint16_t aIndex,
|
||||
otIp6Address *aAddress,
|
||||
uint32_t *aTtl);
|
||||
|
||||
/**
|
||||
* An opaque representation of a response to a service instance resolution DNS query.
|
||||
*
|
||||
* Pointers to instance of this type are provided from callback `otDnsAddressCallback`.
|
||||
*/
|
||||
typedef struct otDnsServiceResponse otDnsServiceResponse;
|
||||
|
||||
/**
|
||||
* Pointer is called when a DNS response is received for a service instance resolution query.
|
||||
*
|
||||
* Within this callback the user can use `otDnsServiceResponseGet{Item}()` functions along with the @p aResponse
|
||||
* pointer to get more info about the response.
|
||||
*
|
||||
* The @p aResponse pointer can only be used within this callback and after returning from this function it will not
|
||||
* stay valid, so the user MUST NOT retain the @p aResponse pointer for later use.
|
||||
*
|
||||
* @param[in] aError The result of the DNS transaction.
|
||||
* @param[in] aResponse A pointer to the response (it is always non-NULL).
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*
|
||||
* For the full list of possible values for @p aError, please see `otDnsAddressCallback()`.
|
||||
*/
|
||||
typedef void (*otDnsServiceCallback)(otError aError, const otDnsServiceResponse *aResponse, void *aContext);
|
||||
|
||||
/**
|
||||
* Starts a DNS service instance resolution for a given service instance.
|
||||
*
|
||||
* Is available when `OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE` is enabled.
|
||||
*
|
||||
* The @p aConfig can be NULL. In this case the default config (from `otDnsClientGetDefaultConfig()`) will be used as
|
||||
* the config for this query. In a non-NULL @p aConfig, some of the fields can be left unspecified (value zero). The
|
||||
* unspecified fields are then replaced by the values from the default config.
|
||||
*
|
||||
* The function sends queries for SRV and/or TXT records for the given service instance. The `mServiceMode` field in
|
||||
* `otDnsQueryConfig` determines which records to query (SRV only, TXT only, or both SRV and TXT) and how to perform
|
||||
* the query (together in the same message, separately in parallel, or in optimized mode where client will try in the
|
||||
* same message first and then separately if it fails to get a response).
|
||||
*
|
||||
* The SRV record provides information about service port, priority, and weight along with the host name associated
|
||||
* with the service instance. This function DOES NOT perform address resolution for the host name discovered from SRV
|
||||
* record. The server/resolver may provide AAAA/A record(s) for the host name in the Additional Data section of the
|
||||
* response to SRV/TXT query and this information can be retrieved using `otDnsServiceResponseGetServiceInfo()` in
|
||||
* `otDnsServiceCallback`. Users of this API MUST NOT assume that host address will always be available from
|
||||
* `otDnsServiceResponseGetServiceInfo()`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aInstanceLabel The service instance label.
|
||||
* @param[in] aServiceName The service name (together with @p aInstanceLabel form full instance name).
|
||||
* @param[in] aCallback A function pointer that shall be called on response reception or time-out.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
* @param[in] aConfig A pointer to the config to use for this query.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Query sent successfully. @p aCallback will be invoked to report the status.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer to prepare and send query.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aInstanceLabel is NULL.
|
||||
*/
|
||||
otError otDnsClientResolveService(otInstance *aInstance,
|
||||
const char *aInstanceLabel,
|
||||
const char *aServiceName,
|
||||
otDnsServiceCallback aCallback,
|
||||
void *aContext,
|
||||
const otDnsQueryConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Starts a DNS service instance resolution for a given service instance, with a potential follow-up
|
||||
* address resolution for the host name discovered for the service instance.
|
||||
*
|
||||
* Is available when `OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE` is enabled.
|
||||
*
|
||||
* The @p aConfig can be NULL. In this case the default config (from `otDnsClientGetDefaultConfig()`) will be used as
|
||||
* the config for this query. In a non-NULL @p aConfig, some of the fields can be left unspecified (value zero). The
|
||||
* unspecified fields are then replaced by the values from the default config. This function cannot be used with
|
||||
* `mServiceMode` in DNS config set to `OT_DNS_SERVICE_MODE_TXT` (i.e., querying for TXT record only) and will return
|
||||
* `OT_ERROR_INVALID_ARGS`.
|
||||
*
|
||||
* Behaves similarly to `otDnsClientResolveService()` sending queries for SRV and TXT records. However,
|
||||
* if the server/resolver does not provide AAAA/A records for the host name in the response to SRV query (in the
|
||||
* Additional Data section), it will perform host name resolution (sending an AAAA query) for the discovered host name
|
||||
* from the SRV record. The callback @p aCallback is invoked when responses for all queries are received (i.e., both
|
||||
* service and host address resolutions are finished).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aInstanceLabel The service instance label.
|
||||
* @param[in] aServiceName The service name (together with @p aInstanceLabel form full instance name).
|
||||
* @param[in] aCallback A function pointer that shall be called on response reception or time-out.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
* @param[in] aConfig A pointer to the config to use for this query.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Query sent successfully. @p aCallback will be invoked to report the status.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer to prepare and send query.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aInstanceLabel is NULL, or @p aConfig is invalid.
|
||||
*/
|
||||
otError otDnsClientResolveServiceAndHostAddress(otInstance *aInstance,
|
||||
const char *aInstanceLabel,
|
||||
const char *aServiceName,
|
||||
otDnsServiceCallback aCallback,
|
||||
void *aContext,
|
||||
const otDnsQueryConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Gets the service instance name associated with a DNS service instance resolution response.
|
||||
*
|
||||
* MUST only be used from `otDnsServiceCallback`.
|
||||
*
|
||||
* @param[in] aResponse A pointer to the response.
|
||||
* @param[out] aLabelBuffer A buffer to char array to output the service instance label (MUST NOT be NULL).
|
||||
* @param[in] aLabelBufferSize The size of @p aLabelBuffer.
|
||||
* @param[out] aNameBuffer A buffer to char array to output the rest of service name (can be NULL if user is
|
||||
* not interested in getting the name.
|
||||
* @param[in] aNameBufferSize The size of @p aNameBuffer.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The service name was read successfully.
|
||||
* @retval OT_ERROR_NO_BUFS Either the label or name does not fit in the given buffers.
|
||||
*/
|
||||
otError otDnsServiceResponseGetServiceName(const otDnsServiceResponse *aResponse,
|
||||
char *aLabelBuffer,
|
||||
uint8_t aLabelBufferSize,
|
||||
char *aNameBuffer,
|
||||
uint16_t aNameBufferSize);
|
||||
|
||||
/**
|
||||
* Gets info for a service instance from a DNS service instance resolution response.
|
||||
*
|
||||
* MUST only be used from a `otDnsServiceCallback` triggered from `otDnsClientResolveService()` or
|
||||
* `otDnsClientResolveServiceAndHostAddress()`.
|
||||
*
|
||||
* When this is is used from a `otDnsClientResolveService()` callback, the DNS response from server/resolver may
|
||||
* include AAAA records in its Additional Data section for the host name associated with the service instance that is
|
||||
* resolved. This is a SHOULD and not a MUST requirement so servers/resolvers are not required to provide this. This
|
||||
* function attempts to parse AAAA record(s) if included in the response. If it is not included `mHostAddress` is set
|
||||
* to all zeros (unspecified address). To also resolve the host address, user can use the DNS client API function
|
||||
* `otDnsClientResolveServiceAndHostAddress()` which will perform service resolution followed up by a host name
|
||||
* address resolution query (when AAAA records are not provided by server/resolver in the SRV query response).
|
||||
*
|
||||
* - If a matching SRV record is found in @p aResponse, @p aServiceInfo is updated.
|
||||
* - If no matching SRV record is found, `OT_ERROR_NOT_FOUND` is returned unless the query config for this query
|
||||
* used `OT_DNS_SERVICE_MODE_TXT` for `mServiceMode` (meaning the request was only for TXT record). In this case, we
|
||||
* still try to parse the SRV record from Additional Data Section of response (in case server provided the info).
|
||||
* - If no matching TXT record is found in @p aResponse, `mTxtDataSize` in @p aServiceInfo is set to zero.
|
||||
* - If TXT data length is greater than `mTxtDataSize`, it is read partially and `mTxtDataTruncated` is set to true.
|
||||
* - If no matching AAAA record is found in @p aResponse, `mHostAddress is set to all zero or unspecified address.
|
||||
* - If there are multiple AAAA records for the host name in @p aResponse, `mHostAddress` is set to the first one. The
|
||||
* other addresses can be retrieved using `otDnsServiceResponseGetHostAddress()`.
|
||||
*
|
||||
* @param[in] aResponse A pointer to the response.
|
||||
* @param[out] aServiceInfo A `ServiceInfo` to output the service instance information (MUST NOT be NULL).
|
||||
*
|
||||
* @retval OT_ERROR_NONE The service instance info was read. @p aServiceInfo is updated.
|
||||
* @retval OT_ERROR_NOT_FOUND Could not find a required record in @p aResponse.
|
||||
* @retval OT_ERROR_NO_BUFS The host name and/or TXT data could not fit in the given buffers.
|
||||
* @retval OT_ERROR_PARSE Could not parse the records in the @p aResponse.
|
||||
*/
|
||||
otError otDnsServiceResponseGetServiceInfo(const otDnsServiceResponse *aResponse, otDnsServiceInfo *aServiceInfo);
|
||||
|
||||
/**
|
||||
* Gets the host IPv6 address from a DNS service instance resolution response.
|
||||
*
|
||||
* MUST only be used from `otDnsServiceCallback`.
|
||||
*
|
||||
* The response can include zero or more IPv6 address records. @p aIndex can be used to iterate through the list of
|
||||
* addresses. Index zero gets the first address and so on. When we reach end of the list, `OT_ERROR_NOT_FOUND` is
|
||||
* returned.
|
||||
*
|
||||
* @param[in] aResponse A pointer to the response.
|
||||
* @param[in] aHostName The host name to get the address (MUST NOT be NULL).
|
||||
* @param[in] aIndex The address record index to retrieve.
|
||||
* @param[out] aAddress A pointer to a IPv6 address to output the address (MUST NOT be NULL).
|
||||
* @param[out] aTtl A pointer to an `uint32_t` to output TTL for the address. It can be NULL if caller does
|
||||
* not want to get the TTL.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The address was read successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND No address record for @p aHostname in @p aResponse at @p aIndex.
|
||||
* @retval OT_ERROR_PARSE Could not parse the records in the @p aResponse.
|
||||
*/
|
||||
otError otDnsServiceResponseGetHostAddress(const otDnsServiceResponse *aResponse,
|
||||
const char *aHostName,
|
||||
uint16_t aIndex,
|
||||
otIp6Address *aAddress,
|
||||
uint32_t *aTtl);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_DNS_CLIENT_H_
|
||||
282
Libs/util/third_party/openthread/include/openthread/dnssd_server.h
vendored
Normal file
282
Libs/util/third_party/openthread/include/openthread/dnssd_server.h
vendored
Normal file
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the DNS-SD server APIs.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_DNSSD_SERVER_H_
|
||||
#define OPENTHREAD_DNSSD_SERVER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/dns.h>
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/ip6.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-dnssd-server
|
||||
*
|
||||
* @brief
|
||||
* This module includes APIs for DNS-SD server.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Is called when a DNS-SD query subscribes one of:
|
||||
* 1. a service name.
|
||||
* 2. a service instance name.
|
||||
* 3. a host name.
|
||||
*
|
||||
* The DNS-SD query implementation is responsible for identifying what @p aFullName is.
|
||||
* If @p aFullName is a service name or service instance name, the DNS-SD query implementation should discover
|
||||
* corresponding service instance information and notify the DNS-SD server using
|
||||
* `otDnssdQueryHandleDiscoveredServiceInstance`.
|
||||
* If @p aFullName is a host name, the DNS-SD query implementation should
|
||||
* discover the host information and notify the DNS-SD server using `otDnssdQueryHandleDiscoveredHost`.
|
||||
*
|
||||
* @note There can be multiple subscription to the same name. DNS-SD query implementation should record the number of
|
||||
* active subscriptions and stop notifying when there is no active subscription for @p aFullName.
|
||||
*
|
||||
* @param[in] aContext A pointer to the application-specific context.
|
||||
* @param[in] aFullName The null-terminated full service name (e.g. "_ipps._tcp.default.service.arpa."),
|
||||
* or full service instance name (e.g. "OpenThread._ipps._tcp.default.service.arpa."),
|
||||
* or full host name (e.g. "ot-host.default.service.arpa.").
|
||||
*
|
||||
* @sa otDnssdQueryHandleDiscoveredServiceInstance
|
||||
* @sa otDnssdQueryHandleDiscoveredHost
|
||||
*/
|
||||
typedef void (*otDnssdQuerySubscribeCallback)(void *aContext, const char *aFullName);
|
||||
|
||||
/**
|
||||
* Is called when a DNS-SD query unsubscribes one of:
|
||||
* 1. a service name.
|
||||
* 2. a service instance name.
|
||||
* 3. a host name.
|
||||
*
|
||||
* The DNS-SD query implementation is responsible for identifying what @p aFullName is.
|
||||
*
|
||||
* @note There can be multiple subscription to the same name. DNS-SD query implementation should record the number of
|
||||
* active subscriptions and stop notifying when there is no active subscription for @p aFullName.
|
||||
*
|
||||
* @param[in] aContext A pointer to the application-specific context.
|
||||
* @param[in] aFullName The null-terminated full service name (e.g. "_ipps._tcp.default.service.arpa."), or
|
||||
* full service instance name (e.g. "OpenThread._ipps._tcp.default.service.arpa.").
|
||||
*/
|
||||
typedef void (*otDnssdQueryUnsubscribeCallback)(void *aContext, const char *aFullName);
|
||||
|
||||
/**
|
||||
* This opaque type represents a DNS-SD query.
|
||||
*/
|
||||
typedef void otDnssdQuery;
|
||||
|
||||
/**
|
||||
* Represents information of a discovered service instance for a DNS-SD query.
|
||||
*/
|
||||
typedef struct otDnssdServiceInstanceInfo
|
||||
{
|
||||
const char *mFullName; ///< Full instance name (e.g. "OpenThread._ipps._tcp.default.service.arpa.").
|
||||
const char *mHostName; ///< Host name (e.g. "ot-host.default.service.arpa.").
|
||||
uint8_t mAddressNum; ///< Number of host IPv6 addresses.
|
||||
const otIp6Address *mAddresses; ///< Host IPv6 addresses.
|
||||
uint16_t mPort; ///< Service port.
|
||||
uint16_t mPriority; ///< Service priority.
|
||||
uint16_t mWeight; ///< Service weight.
|
||||
uint16_t mTxtLength; ///< Service TXT RDATA length.
|
||||
const uint8_t *mTxtData; ///< Service TXT RDATA.
|
||||
uint32_t mTtl; ///< Service TTL (in seconds).
|
||||
} otDnssdServiceInstanceInfo;
|
||||
|
||||
/**
|
||||
* Represents information of a discovered host for a DNS-SD query.
|
||||
*/
|
||||
typedef struct otDnssdHostInfo
|
||||
{
|
||||
uint8_t mAddressNum; ///< Number of host IPv6 addresses.
|
||||
const otIp6Address *mAddresses; ///< Host IPv6 addresses.
|
||||
uint32_t mTtl; ///< Service TTL (in seconds).
|
||||
} otDnssdHostInfo;
|
||||
|
||||
/**
|
||||
* Specifies a DNS-SD query type.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_DNSSD_QUERY_TYPE_NONE = 0, ///< Service type unspecified.
|
||||
OT_DNSSD_QUERY_TYPE_BROWSE = 1, ///< Service type browse service.
|
||||
OT_DNSSD_QUERY_TYPE_RESOLVE = 2, ///< Service type resolve service instance.
|
||||
OT_DNSSD_QUERY_TYPE_RESOLVE_HOST = 3, ///< Service type resolve hostname.
|
||||
} otDnssdQueryType;
|
||||
|
||||
/**
|
||||
* Represents the count of queries, responses, failures handled by upstream DNS server.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE`.
|
||||
*/
|
||||
typedef struct otUpstreamDnsCounters
|
||||
{
|
||||
uint32_t mQueries; ///< The number of queries forwarded.
|
||||
uint32_t mResponses; ///< The number of responses forwarded.
|
||||
uint32_t mFailures; ///< The number of upstream DNS failures.
|
||||
} otUpstreamDnsCounters;
|
||||
|
||||
/**
|
||||
* Contains the counters of DNS-SD server.
|
||||
*/
|
||||
typedef struct otDnssdCounters
|
||||
{
|
||||
uint32_t mSuccessResponse; ///< The number of successful responses.
|
||||
uint32_t mServerFailureResponse; ///< The number of server failure responses.
|
||||
uint32_t mFormatErrorResponse; ///< The number of format error responses.
|
||||
uint32_t mNameErrorResponse; ///< The number of name error responses.
|
||||
uint32_t mNotImplementedResponse; ///< The number of 'not implemented' responses.
|
||||
uint32_t mOtherResponse; ///< The number of other responses.
|
||||
uint32_t mResolvedBySrp; ///< The number of queries resolved by the local SRP server.
|
||||
otUpstreamDnsCounters mUpstreamDnsCounters; ///< The number of queries, responses,
|
||||
///< failures handled by upstream DNS server.
|
||||
} otDnssdCounters;
|
||||
|
||||
/**
|
||||
* Sets DNS-SD server query callbacks.
|
||||
*
|
||||
* The DNS-SD server calls @p aSubscribe to subscribe to a service or service instance to resolve a DNS-SD query and @p
|
||||
* aUnsubscribe to unsubscribe when the query is resolved or timeout.
|
||||
*
|
||||
* @note @p aSubscribe and @p aUnsubscribe must be both set or unset.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aSubscribe A pointer to the callback function to subscribe a service or service instance.
|
||||
* @param[in] aUnsubscribe A pointer to the callback function to unsubscribe a service or service instance.
|
||||
* @param[in] aContext A pointer to the application-specific context.
|
||||
*/
|
||||
void otDnssdQuerySetCallbacks(otInstance *aInstance,
|
||||
otDnssdQuerySubscribeCallback aSubscribe,
|
||||
otDnssdQueryUnsubscribeCallback aUnsubscribe,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Notifies a discovered service instance.
|
||||
*
|
||||
* The external query resolver (e.g. Discovery Proxy) should call this function to notify OpenThread core of the
|
||||
* subscribed services or service instances.
|
||||
*
|
||||
* @note @p aInstanceInfo must not contain unspecified or link-local or loop-back or multicast IP addresses.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aServiceFullName The null-terminated full service name.
|
||||
* @param[in] aInstanceInfo A pointer to the discovered service instance information.
|
||||
*/
|
||||
void otDnssdQueryHandleDiscoveredServiceInstance(otInstance *aInstance,
|
||||
const char *aServiceFullName,
|
||||
otDnssdServiceInstanceInfo *aInstanceInfo);
|
||||
/**
|
||||
* Notifies a discovered host.
|
||||
*
|
||||
* The external query resolver (e.g. Discovery Proxy) should call this function to notify OpenThread core of the
|
||||
* subscribed hosts.
|
||||
*
|
||||
* @note @p aHostInfo must not contain unspecified or link-local or loop-back or multicast IP addresses.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aHostFullName The null-terminated full host name.
|
||||
* @param[in] aHostInfo A pointer to the discovered service instance information.
|
||||
*/
|
||||
void otDnssdQueryHandleDiscoveredHost(otInstance *aInstance, const char *aHostFullName, otDnssdHostInfo *aHostInfo);
|
||||
|
||||
/**
|
||||
* Acquires the next query in the DNS-SD server.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aQuery The query pointer. Pass NULL to get the first query.
|
||||
*
|
||||
* @returns A pointer to the query or NULL if no more queries.
|
||||
*/
|
||||
const otDnssdQuery *otDnssdGetNextQuery(otInstance *aInstance, const otDnssdQuery *aQuery);
|
||||
|
||||
/**
|
||||
* Acquires the DNS-SD query type and name for a specific query.
|
||||
*
|
||||
* @param[in] aQuery The query pointer acquired from `otDnssdGetNextQuery`.
|
||||
* @param[out] aNameOutput The name output buffer, which should be `OT_DNS_MAX_NAME_SIZE` bytes long.
|
||||
*
|
||||
* @returns The DNS-SD query type.
|
||||
*/
|
||||
otDnssdQueryType otDnssdGetQueryTypeAndName(const otDnssdQuery *aQuery, char (*aNameOutput)[OT_DNS_MAX_NAME_SIZE]);
|
||||
|
||||
/**
|
||||
* Returns the counters of the DNS-SD server.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @returns A pointer to the counters of the DNS-SD server.
|
||||
*/
|
||||
const otDnssdCounters *otDnssdGetCounters(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Enable or disable forwarding DNS queries to platform DNS upstream API.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnabled A boolean to enable/disable forwarding DNS queries to upstream.
|
||||
*
|
||||
* @sa otPlatDnsStartUpstreamQuery
|
||||
* @sa otPlatDnsCancelUpstreamQuery
|
||||
* @sa otPlatDnsUpstreamQueryDone
|
||||
*/
|
||||
void otDnssdUpstreamQuerySetEnabled(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Returns whether the DNSSD server will forward DNS queries to the platform DNS upstream API.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @retval TRUE If the DNSSD server will forward DNS queries.
|
||||
* @retval FALSE If the DNSSD server will not forward DNS queries.
|
||||
*
|
||||
* @sa otDnssdUpstreamQuerySetEnabled
|
||||
*/
|
||||
bool otDnssdUpstreamQueryIsEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_DNSSD_SERVER_H_
|
||||
267
Libs/util/third_party/openthread/include/openthread/error.h
vendored
Normal file
267
Libs/util/third_party/openthread/include/openthread/error.h
vendored
Normal file
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the errors used in the OpenThread.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_ERROR_H_
|
||||
#define OPENTHREAD_ERROR_H_
|
||||
|
||||
#include <openthread/platform/toolchain.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-error
|
||||
*
|
||||
* @brief
|
||||
* This module includes error definitions used in OpenThread.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents error codes used throughout OpenThread.
|
||||
*/
|
||||
typedef enum OT_MUST_USE_RESULT otError
|
||||
{
|
||||
/**
|
||||
* No error.
|
||||
*/
|
||||
OT_ERROR_NONE = 0,
|
||||
|
||||
/**
|
||||
* Operational failed.
|
||||
*/
|
||||
OT_ERROR_FAILED = 1,
|
||||
|
||||
/**
|
||||
* Message was dropped.
|
||||
*/
|
||||
OT_ERROR_DROP = 2,
|
||||
|
||||
/**
|
||||
* Insufficient buffers.
|
||||
*/
|
||||
OT_ERROR_NO_BUFS = 3,
|
||||
|
||||
/**
|
||||
* No route available.
|
||||
*/
|
||||
OT_ERROR_NO_ROUTE = 4,
|
||||
|
||||
/**
|
||||
* Service is busy and could not service the operation.
|
||||
*/
|
||||
OT_ERROR_BUSY = 5,
|
||||
|
||||
/**
|
||||
* Failed to parse message.
|
||||
*/
|
||||
OT_ERROR_PARSE = 6,
|
||||
|
||||
/**
|
||||
* Input arguments are invalid.
|
||||
*/
|
||||
OT_ERROR_INVALID_ARGS = 7,
|
||||
|
||||
/**
|
||||
* Security checks failed.
|
||||
*/
|
||||
OT_ERROR_SECURITY = 8,
|
||||
|
||||
/**
|
||||
* Address resolution requires an address query operation.
|
||||
*/
|
||||
OT_ERROR_ADDRESS_QUERY = 9,
|
||||
|
||||
/**
|
||||
* Address is not in the source match table.
|
||||
*/
|
||||
OT_ERROR_NO_ADDRESS = 10,
|
||||
|
||||
/**
|
||||
* Operation was aborted.
|
||||
*/
|
||||
OT_ERROR_ABORT = 11,
|
||||
|
||||
/**
|
||||
* Function or method is not implemented.
|
||||
*/
|
||||
OT_ERROR_NOT_IMPLEMENTED = 12,
|
||||
|
||||
/**
|
||||
* Cannot complete due to invalid state.
|
||||
*/
|
||||
OT_ERROR_INVALID_STATE = 13,
|
||||
|
||||
/**
|
||||
* No acknowledgment was received after macMaxFrameRetries (IEEE 802.15.4-2006).
|
||||
*/
|
||||
OT_ERROR_NO_ACK = 14,
|
||||
|
||||
/**
|
||||
* A transmission could not take place due to activity on the channel, i.e., the CSMA-CA mechanism has failed
|
||||
* (IEEE 802.15.4-2006).
|
||||
*/
|
||||
OT_ERROR_CHANNEL_ACCESS_FAILURE = 15,
|
||||
|
||||
/**
|
||||
* Not currently attached to a Thread Partition.
|
||||
*/
|
||||
OT_ERROR_DETACHED = 16,
|
||||
|
||||
/**
|
||||
* FCS check failure while receiving.
|
||||
*/
|
||||
OT_ERROR_FCS = 17,
|
||||
|
||||
/**
|
||||
* No frame received.
|
||||
*/
|
||||
OT_ERROR_NO_FRAME_RECEIVED = 18,
|
||||
|
||||
/**
|
||||
* Received a frame from an unknown neighbor.
|
||||
*/
|
||||
OT_ERROR_UNKNOWN_NEIGHBOR = 19,
|
||||
|
||||
/**
|
||||
* Received a frame from an invalid source address.
|
||||
*/
|
||||
OT_ERROR_INVALID_SOURCE_ADDRESS = 20,
|
||||
|
||||
/**
|
||||
* Received a frame filtered by the address filter (allowlisted or denylisted).
|
||||
*/
|
||||
OT_ERROR_ADDRESS_FILTERED = 21,
|
||||
|
||||
/**
|
||||
* Received a frame filtered by the destination address check.
|
||||
*/
|
||||
OT_ERROR_DESTINATION_ADDRESS_FILTERED = 22,
|
||||
|
||||
/**
|
||||
* The requested item could not be found.
|
||||
*/
|
||||
OT_ERROR_NOT_FOUND = 23,
|
||||
|
||||
/**
|
||||
* The operation is already in progress.
|
||||
*/
|
||||
OT_ERROR_ALREADY = 24,
|
||||
|
||||
/**
|
||||
* The creation of IPv6 address failed.
|
||||
*/
|
||||
OT_ERROR_IP6_ADDRESS_CREATION_FAILURE = 26,
|
||||
|
||||
/**
|
||||
* Operation prevented by mode flags
|
||||
*/
|
||||
OT_ERROR_NOT_CAPABLE = 27,
|
||||
|
||||
/**
|
||||
* Coap response or acknowledgment or DNS, SNTP response not received.
|
||||
*/
|
||||
OT_ERROR_RESPONSE_TIMEOUT = 28,
|
||||
|
||||
/**
|
||||
* Received a duplicated frame.
|
||||
*/
|
||||
OT_ERROR_DUPLICATED = 29,
|
||||
|
||||
/**
|
||||
* Message is being dropped from reassembly list due to timeout.
|
||||
*/
|
||||
OT_ERROR_REASSEMBLY_TIMEOUT = 30,
|
||||
|
||||
/**
|
||||
* Message is not a TMF Message.
|
||||
*/
|
||||
OT_ERROR_NOT_TMF = 31,
|
||||
|
||||
/**
|
||||
* Received a non-lowpan data frame.
|
||||
*/
|
||||
OT_ERROR_NOT_LOWPAN_DATA_FRAME = 32,
|
||||
|
||||
/**
|
||||
* The link margin was too low.
|
||||
*/
|
||||
OT_ERROR_LINK_MARGIN_LOW = 34,
|
||||
|
||||
/**
|
||||
* Input (CLI) command is invalid.
|
||||
*/
|
||||
OT_ERROR_INVALID_COMMAND = 35,
|
||||
|
||||
/**
|
||||
* Special error code used to indicate success/error status is pending and not yet known.
|
||||
*/
|
||||
OT_ERROR_PENDING = 36,
|
||||
|
||||
/**
|
||||
* Request rejected.
|
||||
*/
|
||||
OT_ERROR_REJECTED = 37,
|
||||
|
||||
/**
|
||||
* The number of defined errors.
|
||||
*/
|
||||
OT_NUM_ERRORS,
|
||||
|
||||
/**
|
||||
* Generic error (should not use).
|
||||
*/
|
||||
OT_ERROR_GENERIC = 255,
|
||||
} otError;
|
||||
|
||||
/**
|
||||
* Converts an otError enum into a string.
|
||||
*
|
||||
* @param[in] aError An otError enum.
|
||||
*
|
||||
* @returns A string representation of an otError.
|
||||
*/
|
||||
const char *otThreadErrorToString(otError aError);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_ERROR_H_
|
||||
75
Libs/util/third_party/openthread/include/openthread/heap.h
vendored
Normal file
75
Libs/util/third_party/openthread/include/openthread/heap.h
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the API for setting external heap in OpenThread.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_HEAP_H_
|
||||
#define OPENTHREAD_HEAP_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-heap
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that set the external OpenThread heap.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
// This is a temporary API and would be removed after moving heap to platform.
|
||||
// TODO: Remove after moving heap to platform.
|
||||
/**
|
||||
* @note This API is deprecated and use of it is discouraged.
|
||||
*/
|
||||
void *otHeapCAlloc(size_t aCount, size_t aSize);
|
||||
|
||||
// This is a temporary API and would be removed after moving heap to platform.
|
||||
// TODO: Remove after moving heap to platform.
|
||||
/**
|
||||
* @note This API is deprecated and use of it is discouraged.
|
||||
*/
|
||||
void otHeapFree(void *aPointer);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_HEAP_H_
|
||||
423
Libs/util/third_party/openthread/include/openthread/history_tracker.h
vendored
Normal file
423
Libs/util/third_party/openthread/include/openthread/history_tracker.h
vendored
Normal file
@@ -0,0 +1,423 @@
|
||||
/*
|
||||
* 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)
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_HISTORY_TRACKER_H_
|
||||
#define OPENTHREAD_HISTORY_TRACKER_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/netdata.h>
|
||||
#include <openthread/thread.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-history-tracker
|
||||
*
|
||||
* @brief
|
||||
* Records the history of different events, for example RX and TX messages or network info changes. All tracked
|
||||
* entries are timestamped.
|
||||
*
|
||||
* The functions in this module are available when `OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE` is enabled.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* This constant specifies the maximum age of entries which is 49 days (in msec).
|
||||
*
|
||||
* Entries older than the max age will give this value as their age.
|
||||
*/
|
||||
#define OT_HISTORY_TRACKER_MAX_AGE (49 * 24 * 60 * 60 * 1000u)
|
||||
|
||||
#define OT_HISTORY_TRACKER_ENTRY_AGE_STRING_SIZE 21 ///< Recommended size for string representation of an entry age.
|
||||
|
||||
/**
|
||||
* Represents an iterator to iterate through a history list.
|
||||
*
|
||||
* The fields in this type are opaque (intended for use by OpenThread core) and therefore should not be accessed/used
|
||||
* by caller.
|
||||
*
|
||||
* Before using an iterator, it MUST be initialized using `otHistoryTrackerInitIterator()`,
|
||||
*/
|
||||
typedef struct otHistoryTrackerIterator
|
||||
{
|
||||
uint32_t mData32;
|
||||
uint16_t mData16;
|
||||
} otHistoryTrackerIterator;
|
||||
|
||||
/**
|
||||
* Represents Thread network info.
|
||||
*/
|
||||
typedef struct otHistoryTrackerNetworkInfo
|
||||
{
|
||||
otDeviceRole mRole; ///< Device Role.
|
||||
otLinkModeConfig mMode; ///< Device Mode.
|
||||
uint16_t mRloc16; ///< Device RLOC16.
|
||||
uint32_t mPartitionId; ///< Partition ID (valid when attached).
|
||||
} otHistoryTrackerNetworkInfo;
|
||||
|
||||
/**
|
||||
* Defines the events for an IPv6 (unicast or multicast) address info (i.e., whether address is added
|
||||
* or removed).
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_HISTORY_TRACKER_ADDRESS_EVENT_ADDED = 0, ///< Address is added.
|
||||
OT_HISTORY_TRACKER_ADDRESS_EVENT_REMOVED = 1, ///< Address is removed.
|
||||
} otHistoryTrackerAddressEvent;
|
||||
|
||||
/**
|
||||
* Represent a unicast IPv6 address info.
|
||||
*/
|
||||
typedef struct otHistoryTrackerUnicastAddressInfo
|
||||
{
|
||||
otIp6Address mAddress; ///< The unicast IPv6 address.
|
||||
uint8_t mPrefixLength; ///< The Prefix length (in bits).
|
||||
uint8_t mAddressOrigin; ///< The address origin (`OT_ADDRESS_ORIGIN_*` constants).
|
||||
otHistoryTrackerAddressEvent mEvent; ///< Indicates the event (address is added/removed).
|
||||
uint8_t mScope : 4; ///< The IPv6 scope.
|
||||
bool mPreferred : 1; ///< If the address is preferred.
|
||||
bool mValid : 1; ///< If the address is valid.
|
||||
bool mRloc : 1; ///< If the address is an RLOC.
|
||||
} otHistoryTrackerUnicastAddressInfo;
|
||||
|
||||
/**
|
||||
* Represent an IPv6 multicast address info.
|
||||
*/
|
||||
typedef struct otHistoryTrackerMulticastAddressInfo
|
||||
{
|
||||
otIp6Address mAddress; ///< The IPv6 multicast address.
|
||||
uint8_t mAddressOrigin; ///< The address origin (`OT_ADDRESS_ORIGIN_*` constants).
|
||||
otHistoryTrackerAddressEvent mEvent; ///< Indicates the event (address is added/removed).
|
||||
} otHistoryTrackerMulticastAddressInfo;
|
||||
|
||||
/**
|
||||
* Constants representing message priority used in `otHistoryTrackerMessageInfo` struct.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
OT_HISTORY_TRACKER_MSG_PRIORITY_LOW = OT_MESSAGE_PRIORITY_LOW, ///< Low priority level.
|
||||
OT_HISTORY_TRACKER_MSG_PRIORITY_NORMAL = OT_MESSAGE_PRIORITY_NORMAL, ///< Normal priority level.
|
||||
OT_HISTORY_TRACKER_MSG_PRIORITY_HIGH = OT_MESSAGE_PRIORITY_HIGH, ///< High priority level.
|
||||
OT_HISTORY_TRACKER_MSG_PRIORITY_NET = OT_MESSAGE_PRIORITY_HIGH + 1, ///< Network Control priority level.
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a RX/TX IPv6 message info.
|
||||
*
|
||||
* Some of the fields in this struct are applicable to a RX message or a TX message only, e.g., `mAveRxRss` is the
|
||||
* average RSS of all fragment frames that form a received message and is only applicable for a RX message.
|
||||
*/
|
||||
typedef struct otHistoryTrackerMessageInfo
|
||||
{
|
||||
uint16_t mPayloadLength; ///< IPv6 payload length (exclude IP6 header itself).
|
||||
uint16_t mNeighborRloc16; ///< RLOC16 of neighbor which sent/received the msg (`0xfffe` if no RLOC16).
|
||||
otSockAddr mSource; ///< Source IPv6 address and port (if UDP/TCP)
|
||||
otSockAddr mDestination; ///< Destination IPv6 address and port (if UDP/TCP).
|
||||
uint16_t mChecksum; ///< Message checksum (valid only for UDP/TCP/ICMP6).
|
||||
uint8_t mIpProto; ///< IP Protocol number (`OT_IP6_PROTO_*` enumeration).
|
||||
uint8_t mIcmp6Type; ///< ICMP6 type if msg is ICMP6, zero otherwise (`OT_ICMP6_TYPE_*` enumeration).
|
||||
int8_t mAveRxRss; ///< RSS of received message or OT_RADIO_INVALID_RSSI if not known.
|
||||
bool mLinkSecurity : 1; ///< Indicates whether msg used link security.
|
||||
bool mTxSuccess : 1; ///< Indicates TX success (e.g., ack received). Applicable for TX msg only.
|
||||
uint8_t mPriority : 2; ///< Message priority (`OT_HISTORY_TRACKER_MSG_PRIORITY_*` enumeration).
|
||||
bool mRadioIeee802154 : 1; ///< Indicates whether msg was sent/received over a 15.4 radio link.
|
||||
bool mRadioTrelUdp6 : 1; ///< Indicates whether msg was sent/received over a TREL radio link.
|
||||
} otHistoryTrackerMessageInfo;
|
||||
|
||||
/**
|
||||
* Defines the events in a neighbor info (i.e. whether neighbor is added, removed, or changed).
|
||||
*
|
||||
* Event `OT_HISTORY_TRACKER_NEIGHBOR_EVENT_RESTORING` is applicable to child neighbors only. It is triggered after
|
||||
* the device (re)starts and when the previous children list is retrieved from non-volatile settings and the device
|
||||
* tries to restore connection to them.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_HISTORY_TRACKER_NEIGHBOR_EVENT_ADDED = 0, ///< Neighbor is added.
|
||||
OT_HISTORY_TRACKER_NEIGHBOR_EVENT_REMOVED = 1, ///< Neighbor is removed.
|
||||
OT_HISTORY_TRACKER_NEIGHBOR_EVENT_CHANGED = 2, ///< Neighbor changed (e.g., device mode flags changed).
|
||||
OT_HISTORY_TRACKER_NEIGHBOR_EVENT_RESTORING = 3, ///< Neighbor is being restored (applicable to child only).
|
||||
} otHistoryTrackerNeighborEvent;
|
||||
|
||||
/**
|
||||
* Represents a neighbor info.
|
||||
*/
|
||||
typedef struct otHistoryTrackerNeighborInfo
|
||||
{
|
||||
otExtAddress mExtAddress; ///< Neighbor's Extended Address.
|
||||
uint16_t mRloc16; ///< Neighbor's RLOC16.
|
||||
int8_t mAverageRssi; ///< Average RSSI of rx frames from neighbor at the time of recording entry.
|
||||
uint8_t mEvent : 2; ///< Indicates the event (`OT_HISTORY_TRACKER_NEIGHBOR_EVENT_*` enumeration).
|
||||
bool mRxOnWhenIdle : 1; ///< Rx-on-when-idle.
|
||||
bool mFullThreadDevice : 1; ///< Full Thread Device.
|
||||
bool mFullNetworkData : 1; ///< Full Network Data.
|
||||
bool mIsChild : 1; ///< Indicates whether or not the neighbor is a child.
|
||||
} otHistoryTrackerNeighborInfo;
|
||||
|
||||
/**
|
||||
* Defines the events in a router info (i.e. whether router is added, removed, or changed).
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_HISTORY_TRACKER_ROUTER_EVENT_ADDED = 0, ///< Router is added (router ID allocated).
|
||||
OT_HISTORY_TRACKER_ROUTER_EVENT_REMOVED = 1, ///< Router entry is removed (router ID released).
|
||||
OT_HISTORY_TRACKER_ROUTER_EVENT_NEXT_HOP_CHANGED = 2, ///< Router entry next hop and cost changed.
|
||||
OT_HISTORY_TRACKER_ROUTER_EVENT_COST_CHANGED = 3, ///< Router entry path cost changed (next hop as before).
|
||||
} otHistoryTrackerRouterEvent;
|
||||
|
||||
#define OT_HISTORY_TRACKER_NO_NEXT_HOP 63 ///< No next hop - For `mNextHop` in `otHistoryTrackerRouterInfo`.
|
||||
|
||||
#define OT_HISTORY_TRACKER_INFINITE_PATH_COST 0 ///< Infinite path cost - used in `otHistoryTrackerRouterInfo`.
|
||||
|
||||
/**
|
||||
* Represents a router table entry event.
|
||||
*/
|
||||
typedef struct otHistoryTrackerRouterInfo
|
||||
{
|
||||
uint8_t mEvent : 2; ///< Router entry event (`OT_HISTORY_TRACKER_ROUTER_EVENT_*` enumeration).
|
||||
uint8_t mRouterId : 6; ///< Router ID.
|
||||
uint8_t mNextHop; ///< Next Hop Router ID - `OT_HISTORY_TRACKER_NO_NEXT_HOP` if no next hop.
|
||||
uint8_t mOldPathCost : 4; ///< Old path cost - `OT_HISTORY_TRACKER_INFINITE_PATH_COST` if infinite or unknown.
|
||||
uint8_t mPathCost : 4; ///< New path cost - `OT_HISTORY_TRACKER_INFINITE_PATH_COST` if infinite or unknown.
|
||||
} otHistoryTrackerRouterInfo;
|
||||
|
||||
/**
|
||||
* Defines the events for a Network Data entry (i.e., whether an entry is added or removed).
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_HISTORY_TRACKER_NET_DATA_ENTRY_ADDED = 0, ///< Network data entry is added.
|
||||
OT_HISTORY_TRACKER_NET_DATA_ENTRY_REMOVED = 1, ///< Network data entry is removed.
|
||||
} otHistoryTrackerNetDataEvent;
|
||||
|
||||
/**
|
||||
* Represent a Network Data on mesh prefix info.
|
||||
*/
|
||||
typedef struct otHistoryTrackerOnMeshPrefixInfo
|
||||
{
|
||||
otBorderRouterConfig mPrefix; ///< The on mesh prefix entry.
|
||||
otHistoryTrackerNetDataEvent mEvent; ///< Indicates the event (added/removed).
|
||||
} otHistoryTrackerOnMeshPrefixInfo;
|
||||
|
||||
/**
|
||||
* Represent a Network Data extern route info.
|
||||
*/
|
||||
typedef struct otHistoryTrackerExternalRouteInfo
|
||||
{
|
||||
otExternalRouteConfig mRoute; ///< The external route entry.
|
||||
otHistoryTrackerNetDataEvent mEvent; ///< Indicates the event (added/removed).
|
||||
} otHistoryTrackerExternalRouteInfo;
|
||||
|
||||
/**
|
||||
* Initializes an `otHistoryTrackerIterator`.
|
||||
*
|
||||
* An iterator MUST be initialized before it is used.
|
||||
*
|
||||
* An iterator can be initialized again to start from the beginning of the list.
|
||||
*
|
||||
* When iterating over entries in a list, to ensure the entry ages are consistent, the age is given relative to the
|
||||
* time the iterator was initialized, i.e., the entry age is provided as the duration (in milliseconds) from the event
|
||||
* (when entry was recorded) to the iterator initialization time.
|
||||
*
|
||||
* @param[in] aIterator A pointer to the iterator to initialize (MUST NOT be NULL).
|
||||
*/
|
||||
void otHistoryTrackerInitIterator(otHistoryTrackerIterator *aIterator);
|
||||
|
||||
/**
|
||||
* Iterates over the entries in the network info history list.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to an iterator. MUST be initialized or the behavior is undefined.
|
||||
* @param[out] aEntryAge A pointer to a variable to output the entry's age. MUST NOT be NULL.
|
||||
* Age is provided as the duration (in milliseconds) from when entry was recorded to
|
||||
* @p aIterator initialization time. It is set to `OT_HISTORY_TRACKER_MAX_AGE` for entries
|
||||
* older than max age.
|
||||
*
|
||||
* @returns A pointer to `otHistoryTrackerNetworkInfo` entry or `NULL` if no more entries in the list.
|
||||
*/
|
||||
const otHistoryTrackerNetworkInfo *otHistoryTrackerIterateNetInfoHistory(otInstance *aInstance,
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t *aEntryAge);
|
||||
|
||||
/**
|
||||
* Iterates over the entries in the unicast address history list.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to an iterator. MUST be initialized or the behavior is undefined.
|
||||
* @param[out] aEntryAge A pointer to a variable to output the entry's age. MUST NOT be NULL.
|
||||
* Age is provided as the duration (in milliseconds) from when entry was recorded to
|
||||
* @p aIterator initialization time. It is set to `OT_HISTORY_TRACKER_MAX_AGE` for entries
|
||||
* older than max age.
|
||||
*
|
||||
* @returns A pointer to `otHistoryTrackerUnicastAddressInfo` entry or `NULL` if no more entries in the list.
|
||||
*/
|
||||
const otHistoryTrackerUnicastAddressInfo *otHistoryTrackerIterateUnicastAddressHistory(
|
||||
otInstance *aInstance,
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t *aEntryAge);
|
||||
|
||||
/**
|
||||
* Iterates over the entries in the multicast address history list.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to an iterator. MUST be initialized or the behavior is undefined.
|
||||
* @param[out] aEntryAge A pointer to a variable to output the entry's age. MUST NOT be NULL.
|
||||
* Age is provided as the duration (in milliseconds) from when entry was recorded to
|
||||
* @p aIterator initialization time. It is set to `OT_HISTORY_TRACKER_MAX_AGE` for entries
|
||||
* older than max age.
|
||||
*
|
||||
* @returns A pointer to `otHistoryTrackerMulticastAddressInfo` entry or `NULL` if no more entries in the list.
|
||||
*/
|
||||
const otHistoryTrackerMulticastAddressInfo *otHistoryTrackerIterateMulticastAddressHistory(
|
||||
otInstance *aInstance,
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t *aEntryAge);
|
||||
|
||||
/**
|
||||
* Iterates over the entries in the RX message history list.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to an iterator. MUST be initialized or the behavior is undefined.
|
||||
* @param[out] aEntryAge A pointer to a variable to output the entry's age. MUST NOT be NULL.
|
||||
* Age is provided as the duration (in milliseconds) from when entry was recorded to
|
||||
* @p aIterator initialization time. It is set to `OT_HISTORY_TRACKER_MAX_AGE` for entries
|
||||
* older than max age.
|
||||
*
|
||||
* @returns The `otHistoryTrackerMessageInfo` entry or `NULL` if no more entries in the list.
|
||||
*/
|
||||
const otHistoryTrackerMessageInfo *otHistoryTrackerIterateRxHistory(otInstance *aInstance,
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t *aEntryAge);
|
||||
|
||||
/**
|
||||
* Iterates over the entries in the TX message history list.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to an iterator. MUST be initialized or the behavior is undefined.
|
||||
* @param[out] aEntryAge A pointer to a variable to output the entry's age. MUST NOT be NULL.
|
||||
* Age is provided as the duration (in milliseconds) from when entry was recorded to
|
||||
* @p aIterator initialization time. It is set to `OT_HISTORY_TRACKER_MAX_AGE` for entries
|
||||
* older than max age.
|
||||
*
|
||||
* @returns The `otHistoryTrackerMessageInfo` entry or `NULL` if no more entries in the list.
|
||||
*/
|
||||
const otHistoryTrackerMessageInfo *otHistoryTrackerIterateTxHistory(otInstance *aInstance,
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t *aEntryAge);
|
||||
|
||||
/**
|
||||
* Iterates over the entries in the neighbor history list.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to an iterator. MUST be initialized or the behavior is undefined.
|
||||
* @param[out] aEntryAge A pointer to a variable to output the entry's age. MUST NOT be NULL.
|
||||
* Age is provided as the duration (in milliseconds) from when entry was recorded to
|
||||
* @p aIterator initialization time. It is set to `OT_HISTORY_TRACKER_MAX_AGE` for entries
|
||||
* older than max age.
|
||||
*
|
||||
* @returns The `otHistoryTrackerNeighborInfo` entry or `NULL` if no more entries in the list.
|
||||
*/
|
||||
const otHistoryTrackerNeighborInfo *otHistoryTrackerIterateNeighborHistory(otInstance *aInstance,
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t *aEntryAge);
|
||||
|
||||
/**
|
||||
* Iterates over the entries in the router history list.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to an iterator. MUST be initialized or the behavior is undefined.
|
||||
* @param[out] aEntryAge A pointer to a variable to output the entry's age. MUST NOT be NULL.
|
||||
* Age is provided as the duration (in milliseconds) from when entry was recorded to
|
||||
* @p aIterator initialization time. It is set to `OT_HISTORY_TRACKER_MAX_AGE` for entries
|
||||
* older than max age.
|
||||
*
|
||||
* @returns The `otHistoryTrackerRouterInfo` entry or `NULL` if no more entries in the list.
|
||||
*/
|
||||
const otHistoryTrackerRouterInfo *otHistoryTrackerIterateRouterHistory(otInstance *aInstance,
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t *aEntryAge);
|
||||
|
||||
/**
|
||||
* Iterates over the entries in the Network Data on mesh prefix entry history list.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to an iterator. MUST be initialized or the behavior is undefined.
|
||||
* @param[out] aEntryAge A pointer to a variable to output the entry's age. MUST NOT be NULL.
|
||||
* Age is provided as the duration (in milliseconds) from when entry was recorded to
|
||||
* @p aIterator initialization time. It is set to `OT_HISTORY_TRACKER_MAX_AGE` for entries
|
||||
* older than max age.
|
||||
*
|
||||
* @returns The `otHistoryTrackerOnMeshPrefixInfo` entry or `NULL` if no more entries in the list.
|
||||
*/
|
||||
const otHistoryTrackerOnMeshPrefixInfo *otHistoryTrackerIterateOnMeshPrefixHistory(otInstance *aInstance,
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t *aEntryAge);
|
||||
|
||||
/**
|
||||
* Iterates over the entries in the Network Data external route entry history list.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to an iterator. MUST be initialized or the behavior is undefined.
|
||||
* @param[out] aEntryAge A pointer to a variable to output the entry's age. MUST NOT be NULL.
|
||||
* Age is provided as the duration (in milliseconds) from when entry was recorded to
|
||||
* @p aIterator initialization time. It is set to `OT_HISTORY_TRACKER_MAX_AGE` for entries
|
||||
* older than max age.
|
||||
*
|
||||
* @returns The `otHistoryTrackerExternalRouteInfo` entry or `NULL` if no more entries in the list.
|
||||
*/
|
||||
const otHistoryTrackerExternalRouteInfo *otHistoryTrackerIterateExternalRouteHistory(
|
||||
otInstance *aInstance,
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t *aEntryAge);
|
||||
|
||||
/**
|
||||
* Converts a given entry age to a human-readable string.
|
||||
*
|
||||
* The entry age string follows the format `hours:minutes:seconds:milliseconds` (if
|
||||
* shorter than one day) or `days:hours:minutes:seconds`(if longer than one day).
|
||||
*
|
||||
* If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated
|
||||
* but the outputted string is always null-terminated.
|
||||
*
|
||||
* @param[in] aEntryAge The entry age (duration in msec).
|
||||
* @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be NULL).
|
||||
* @param[in] aSize The size of @p aBuffer. Recommended to use `OT_HISTORY_TRACKER_ENTRY_AGE_STRING_SIZE`.
|
||||
*/
|
||||
void otHistoryTrackerEntryAgeToString(uint32_t aEntryAge, char *aBuffer, uint16_t aSize);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_HISTORY_TRACKER_H_
|
||||
197
Libs/util/third_party/openthread/include/openthread/icmp6.h
vendored
Normal file
197
Libs/util/third_party/openthread/include/openthread/icmp6.h
vendored
Normal file
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the top-level ICMPv6 functions for the OpenThread library.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_ICMP6_H_
|
||||
#define OPENTHREAD_ICMP6_H_
|
||||
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/message.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-icmp6
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control ICMPv6 communication.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* ICMPv6 Message Types
|
||||
*/
|
||||
typedef enum otIcmp6Type
|
||||
{
|
||||
OT_ICMP6_TYPE_DST_UNREACH = 1, ///< Destination Unreachable
|
||||
OT_ICMP6_TYPE_PACKET_TO_BIG = 2, ///< Packet To Big
|
||||
OT_ICMP6_TYPE_TIME_EXCEEDED = 3, ///< Time Exceeded
|
||||
OT_ICMP6_TYPE_PARAMETER_PROBLEM = 4, ///< Parameter Problem
|
||||
OT_ICMP6_TYPE_ECHO_REQUEST = 128, ///< Echo Request
|
||||
OT_ICMP6_TYPE_ECHO_REPLY = 129, ///< Echo Reply
|
||||
OT_ICMP6_TYPE_ROUTER_SOLICIT = 133, ///< Router Solicitation
|
||||
OT_ICMP6_TYPE_ROUTER_ADVERT = 134, ///< Router Advertisement
|
||||
OT_ICMP6_TYPE_NEIGHBOR_SOLICIT = 135, ///< Neighbor Solicitation
|
||||
OT_ICMP6_TYPE_NEIGHBOR_ADVERT = 136, ///< Neighbor Advertisement
|
||||
} otIcmp6Type;
|
||||
|
||||
/**
|
||||
* ICMPv6 Message Codes
|
||||
*/
|
||||
typedef enum otIcmp6Code
|
||||
{
|
||||
OT_ICMP6_CODE_DST_UNREACH_NO_ROUTE = 0, ///< Destination Unreachable (Type 1) - No Route
|
||||
OT_ICMP6_CODE_DST_UNREACH_PROHIBITED = 1, ///< Destination Unreachable (Type 1) - Administratively Prohibited
|
||||
OT_ICMP6_CODE_FRAGM_REAS_TIME_EX = 1, ///< Time Exceeded (Type 3) - Fragment Reassembly
|
||||
} otIcmp6Code;
|
||||
|
||||
#define OT_ICMP6_HEADER_DATA_SIZE 4 ///< Size of ICMPv6 Header.
|
||||
#define OT_ICMP6_ROUTER_ADVERT_MIN_SIZE 16 ///< Size of a Router Advertisement message without any options.
|
||||
|
||||
/**
|
||||
* @struct otIcmp6Header
|
||||
*
|
||||
* Represents an ICMPv6 header.
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otIcmp6Header
|
||||
{
|
||||
uint8_t mType; ///< Type
|
||||
uint8_t mCode; ///< Code
|
||||
uint16_t mChecksum; ///< Checksum
|
||||
union OT_TOOL_PACKED_FIELD
|
||||
{
|
||||
uint8_t m8[OT_ICMP6_HEADER_DATA_SIZE / sizeof(uint8_t)];
|
||||
uint16_t m16[OT_ICMP6_HEADER_DATA_SIZE / sizeof(uint16_t)];
|
||||
uint32_t m32[OT_ICMP6_HEADER_DATA_SIZE / sizeof(uint32_t)];
|
||||
} mData; ///< Message-specific data
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* Represents an ICMPv6 header.
|
||||
*/
|
||||
typedef struct otIcmp6Header otIcmp6Header;
|
||||
|
||||
/**
|
||||
* This callback allows OpenThread to inform the application of a received ICMPv6 message.
|
||||
*
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
* @param[in] aMessage A pointer to the received message.
|
||||
* @param[in] aMessageInfo A pointer to message information associated with @p aMessage.
|
||||
* @param[in] aIcmpHeader A pointer to the received ICMPv6 header.
|
||||
*/
|
||||
typedef void (*otIcmp6ReceiveCallback)(void *aContext,
|
||||
otMessage *aMessage,
|
||||
const otMessageInfo *aMessageInfo,
|
||||
const otIcmp6Header *aIcmpHeader);
|
||||
|
||||
/**
|
||||
* Implements ICMPv6 message handler.
|
||||
*/
|
||||
typedef struct otIcmp6Handler
|
||||
{
|
||||
otIcmp6ReceiveCallback mReceiveCallback; ///< The ICMPv6 received callback
|
||||
void *mContext; ///< A pointer to arbitrary context information.
|
||||
struct otIcmp6Handler *mNext; ///< A pointer to the next handler in the list.
|
||||
} otIcmp6Handler;
|
||||
|
||||
/**
|
||||
* ICMPv6 Echo Reply Modes
|
||||
*/
|
||||
typedef enum otIcmp6EchoMode
|
||||
{
|
||||
OT_ICMP6_ECHO_HANDLER_DISABLED = 0, ///< ICMPv6 Echo processing disabled
|
||||
OT_ICMP6_ECHO_HANDLER_UNICAST_ONLY = 1, ///< ICMPv6 Echo processing enabled only for unicast requests only
|
||||
OT_ICMP6_ECHO_HANDLER_MULTICAST_ONLY = 2, ///< ICMPv6 Echo processing enabled only for multicast requests only
|
||||
OT_ICMP6_ECHO_HANDLER_ALL = 3, ///< ICMPv6 Echo processing enabled for unicast and multicast requests
|
||||
OT_ICMP6_ECHO_HANDLER_RLOC_ALOC_ONLY = 4, ///< ICMPv6 Echo processing enabled for RLOC/ALOC destinations only
|
||||
} otIcmp6EchoMode;
|
||||
|
||||
/**
|
||||
* Indicates whether or not ICMPv6 Echo processing is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ICMP6_ECHO_HANDLER_DISABLED ICMPv6 Echo processing is disabled.
|
||||
* @retval OT_ICMP6_ECHO_HANDLER_UNICAST_ONLY ICMPv6 Echo processing enabled for unicast requests only
|
||||
* @retval OT_ICMP6_ECHO_HANDLER_MULTICAST_ONLY ICMPv6 Echo processing enabled for multicast requests only
|
||||
* @retval OT_ICMP6_ECHO_HANDLER_ALL ICMPv6 Echo processing enabled for unicast and multicast requests
|
||||
*/
|
||||
otIcmp6EchoMode otIcmp6GetEchoMode(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets whether or not ICMPv6 Echo processing is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMode The ICMPv6 Echo processing mode.
|
||||
*/
|
||||
void otIcmp6SetEchoMode(otInstance *aInstance, otIcmp6EchoMode aMode);
|
||||
|
||||
/**
|
||||
* Registers a handler to provide received ICMPv6 messages.
|
||||
*
|
||||
* @note A handler structure @p aHandler has to be stored in persistent (static) memory.
|
||||
* OpenThread does not make a copy of handler structure.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aHandler A pointer to a handler containing callback that is called when
|
||||
* an ICMPv6 message is received.
|
||||
*/
|
||||
otError otIcmp6RegisterHandler(otInstance *aInstance, otIcmp6Handler *aHandler);
|
||||
|
||||
/**
|
||||
* Sends an ICMPv6 Echo Request via the Thread interface.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMessage A pointer to the message buffer containing the ICMPv6 payload.
|
||||
* @param[in] aMessageInfo A reference to message information associated with @p aMessage.
|
||||
* @param[in] aIdentifier An identifier to aid in matching Echo Replies to this Echo Request.
|
||||
* May be zero.
|
||||
*/
|
||||
otError otIcmp6SendEchoRequest(otInstance *aInstance,
|
||||
otMessage *aMessage,
|
||||
const otMessageInfo *aMessageInfo,
|
||||
uint16_t aIdentifier);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_ICMP6_H_
|
||||
326
Libs/util/third_party/openthread/include/openthread/instance.h
vendored
Normal file
326
Libs/util/third_party/openthread/include/openthread/instance.h
vendored
Normal file
@@ -0,0 +1,326 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Instance API.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_INSTANCE_H_
|
||||
#define OPENTHREAD_INSTANCE_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
#include <openthread/platform/toolchain.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The OpenThread API monotonic version number.
|
||||
*
|
||||
* This number MUST increase by one each time the contents of public OpenThread API include headers change.
|
||||
*
|
||||
* @note This number versions both OpenThread platform and user APIs.
|
||||
*/
|
||||
#define OPENTHREAD_API_VERSION (464)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control the OpenThread Instance.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents the OpenThread instance structure.
|
||||
*/
|
||||
typedef struct otInstance otInstance;
|
||||
|
||||
/**
|
||||
* Initializes the OpenThread library.
|
||||
*
|
||||
* Initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be
|
||||
* called before any other calls to OpenThread.
|
||||
*
|
||||
* Is available and can only be used when support for multiple OpenThread instances is enabled.
|
||||
*
|
||||
* @param[in] aInstanceBuffer The buffer for OpenThread to use for allocating the otInstance structure.
|
||||
* @param[in,out] aInstanceBufferSize On input, the size of aInstanceBuffer. On output, if not enough space for
|
||||
* otInstance, the number of bytes required for otInstance.
|
||||
*
|
||||
* @returns A pointer to the new OpenThread instance.
|
||||
*
|
||||
* @sa otInstanceFinalize
|
||||
*/
|
||||
otInstance *otInstanceInit(void *aInstanceBuffer, size_t *aInstanceBufferSize);
|
||||
|
||||
/**
|
||||
* Initializes the static single instance of the OpenThread library.
|
||||
*
|
||||
* Initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be
|
||||
* called before any other calls to OpenThread.
|
||||
*
|
||||
* Is available and can only be used when support for multiple OpenThread instances is disabled.
|
||||
*
|
||||
* @returns A pointer to the single OpenThread instance.
|
||||
*/
|
||||
otInstance *otInstanceInitSingle(void);
|
||||
|
||||
/**
|
||||
* Initializes the OpenThread instance.
|
||||
*
|
||||
* This function initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be
|
||||
* called before any other calls to OpenThread. This method utilizes static buffer to initialize the OpenThread
|
||||
* instance.
|
||||
*
|
||||
* This function is available and can only be used when support for multiple OpenThread static instances is
|
||||
* enabled (`OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE`)
|
||||
*
|
||||
* @param[in] aIdx The index of the OpenThread instance to initialize.
|
||||
*
|
||||
* @returns A pointer to the new OpenThread instance.
|
||||
*/
|
||||
otInstance *otInstanceInitMultiple(uint8_t aIdx);
|
||||
|
||||
/**
|
||||
* Gets the instance identifier.
|
||||
*
|
||||
* The instance identifier is set to a random value when the instance is constructed, and then its value will not
|
||||
* change after initialization.
|
||||
*
|
||||
* @returns The instance identifier.
|
||||
*/
|
||||
uint32_t otInstanceGetId(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the instance is valid/initialized.
|
||||
*
|
||||
* The instance is considered valid if it is acquired and initialized using either `otInstanceInitSingle()` (in single
|
||||
* instance case) or `otInstanceInit()` (in multi instance case). A subsequent call to `otInstanceFinalize()` causes
|
||||
* the instance to be considered as uninitialized.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns TRUE if the given instance is valid/initialized, FALSE otherwise.
|
||||
*/
|
||||
bool otInstanceIsInitialized(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Disables the OpenThread library.
|
||||
*
|
||||
* Call this function when OpenThread is no longer in use.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otInstanceFinalize(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Returns the current instance uptime (in msec).
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled.
|
||||
*
|
||||
* The uptime is given as number of milliseconds since OpenThread instance was initialized.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The uptime (number of milliseconds).
|
||||
*/
|
||||
uint64_t otInstanceGetUptime(otInstance *aInstance);
|
||||
|
||||
#define OT_UPTIME_STRING_SIZE 24 ///< Recommended size for string representation of uptime.
|
||||
|
||||
/**
|
||||
* Returns the current instance uptime as a human-readable string.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled.
|
||||
*
|
||||
* The string follows the format "<hh>:<mm>:<ss>.<mmmm>" for hours, minutes, seconds and millisecond (if uptime is
|
||||
* shorter than one day) or "<dd>d.<hh>:<mm>:<ss>.<mmmm>" (if longer than a day).
|
||||
*
|
||||
* If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated
|
||||
* but the outputted string is always null-terminated.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aBuffer A pointer to a char array to output the string.
|
||||
* @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_UPTIME_STRING_SIZE`.
|
||||
*/
|
||||
void otInstanceGetUptimeAsString(otInstance *aInstance, char *aBuffer, uint16_t aSize);
|
||||
|
||||
#define OT_CHANGED_IP6_ADDRESS_ADDED (1U << 0) ///< IPv6 address was added
|
||||
#define OT_CHANGED_IP6_ADDRESS_REMOVED (1U << 1) ///< IPv6 address was removed
|
||||
#define OT_CHANGED_THREAD_ROLE (1U << 2) ///< Role (disabled, detached, child, router, leader) changed
|
||||
#define OT_CHANGED_THREAD_LL_ADDR (1U << 3) ///< The link-local address changed
|
||||
#define OT_CHANGED_THREAD_ML_ADDR (1U << 4) ///< The mesh-local address changed
|
||||
#define OT_CHANGED_THREAD_RLOC_ADDED (1U << 5) ///< RLOC was added
|
||||
#define OT_CHANGED_THREAD_RLOC_REMOVED (1U << 6) ///< RLOC was removed
|
||||
#define OT_CHANGED_THREAD_PARTITION_ID (1U << 7) ///< Partition ID changed
|
||||
#define OT_CHANGED_THREAD_KEY_SEQUENCE_COUNTER (1U << 8) ///< Thread Key Sequence changed
|
||||
#define OT_CHANGED_THREAD_NETDATA (1U << 9) ///< Thread Network Data changed
|
||||
#define OT_CHANGED_THREAD_CHILD_ADDED (1U << 10) ///< Child was added
|
||||
#define OT_CHANGED_THREAD_CHILD_REMOVED (1U << 11) ///< Child was removed
|
||||
#define OT_CHANGED_IP6_MULTICAST_SUBSCRIBED (1U << 12) ///< Subscribed to a IPv6 multicast address
|
||||
#define OT_CHANGED_IP6_MULTICAST_UNSUBSCRIBED (1U << 13) ///< Unsubscribed from a IPv6 multicast address
|
||||
#define OT_CHANGED_THREAD_CHANNEL (1U << 14) ///< Thread network channel changed
|
||||
#define OT_CHANGED_THREAD_PANID (1U << 15) ///< Thread network PAN Id changed
|
||||
#define OT_CHANGED_THREAD_NETWORK_NAME (1U << 16) ///< Thread network name changed
|
||||
#define OT_CHANGED_THREAD_EXT_PANID (1U << 17) ///< Thread network extended PAN ID changed
|
||||
#define OT_CHANGED_NETWORK_KEY (1U << 18) ///< Network key changed
|
||||
#define OT_CHANGED_PSKC (1U << 19) ///< PSKc changed
|
||||
#define OT_CHANGED_SECURITY_POLICY (1U << 20) ///< Security Policy changed
|
||||
#define OT_CHANGED_CHANNEL_MANAGER_NEW_CHANNEL (1U << 21) ///< Channel Manager new pending Thread channel changed
|
||||
#define OT_CHANGED_SUPPORTED_CHANNEL_MASK (1U << 22) ///< Supported channel mask changed
|
||||
#define OT_CHANGED_COMMISSIONER_STATE (1U << 23) ///< Commissioner state changed
|
||||
#define OT_CHANGED_THREAD_NETIF_STATE (1U << 24) ///< Thread network interface state changed
|
||||
#define OT_CHANGED_THREAD_BACKBONE_ROUTER_STATE (1U << 25) ///< Backbone Router state changed
|
||||
#define OT_CHANGED_THREAD_BACKBONE_ROUTER_LOCAL (1U << 26) ///< Local Backbone Router configuration changed
|
||||
#define OT_CHANGED_JOINER_STATE (1U << 27) ///< Joiner state changed
|
||||
#define OT_CHANGED_ACTIVE_DATASET (1U << 28) ///< Active Operational Dataset changed
|
||||
#define OT_CHANGED_PENDING_DATASET (1U << 29) ///< Pending Operational Dataset changed
|
||||
#define OT_CHANGED_NAT64_TRANSLATOR_STATE (1U << 30) ///< The state of NAT64 translator changed
|
||||
#define OT_CHANGED_PARENT_LINK_QUALITY (1U << 31) ///< Parent link quality changed
|
||||
|
||||
/**
|
||||
* Represents a bit-field indicating specific state/configuration that has changed. See `OT_CHANGED_*`
|
||||
* definitions.
|
||||
*/
|
||||
typedef uint32_t otChangedFlags;
|
||||
|
||||
/**
|
||||
* Pointer is called to notify certain configuration or state changes within OpenThread.
|
||||
*
|
||||
* @param[in] aFlags A bit-field indicating specific state that has changed. See `OT_CHANGED_*` definitions.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otStateChangedCallback)(otChangedFlags aFlags, void *aContext);
|
||||
|
||||
/**
|
||||
* Registers a callback to indicate when certain configuration or state changes within OpenThread.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback A pointer to a function that is called with certain configuration or state changes.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Added the callback to the list of callbacks.
|
||||
* @retval OT_ERROR_ALREADY The callback was already registered.
|
||||
* @retval OT_ERROR_NO_BUFS Could not add the callback due to resource constraints.
|
||||
*/
|
||||
otError otSetStateChangedCallback(otInstance *aInstance, otStateChangedCallback aCallback, void *aContext);
|
||||
|
||||
/**
|
||||
* Removes a callback to indicate when certain configuration or state changes within OpenThread.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback A pointer to a function that is called with certain configuration or state changes.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
void otRemoveStateChangeCallback(otInstance *aInstance, otStateChangedCallback aCallback, void *aContext);
|
||||
|
||||
/**
|
||||
* Triggers a platform reset.
|
||||
*
|
||||
* The reset process ensures that all the OpenThread state/info (stored in volatile memory) is erased. Note that the
|
||||
* `otPlatformReset` does not erase any persistent state/info saved in non-volatile memory.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otInstanceReset(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Triggers a platform reset to bootloader mode, if supported.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Reset to bootloader successfully.
|
||||
* @retval OT_ERROR_BUSY Failed due to another operation is ongoing.
|
||||
* @retval OT_ERROR_NOT_CAPABLE Not capable of resetting to bootloader.
|
||||
*/
|
||||
otError otInstanceResetToBootloader(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Deletes all the settings stored on non-volatile memory, and then triggers a platform reset.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otInstanceFactoryReset(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Resets the internal states of the OpenThread radio stack.
|
||||
*
|
||||
* Callbacks and configurations are preserved.
|
||||
*
|
||||
* This API is only available under radio builds (`OPENTHREAD_RADIO = 1`).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otInstanceResetRadioStack(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Erases all the OpenThread persistent info (network settings) stored on non-volatile memory.
|
||||
* Erase is successful only if the device is in `disabled` state/role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE All persistent info/state was erased successfully.
|
||||
* @retval OT_ERROR_INVALID_STATE Device is not in `disabled` state/role.
|
||||
*/
|
||||
otError otInstanceErasePersistentInfo(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the OpenThread version string.
|
||||
*
|
||||
* @returns A pointer to the OpenThread version.
|
||||
*/
|
||||
const char *otGetVersionString(void);
|
||||
|
||||
/**
|
||||
* Gets the OpenThread radio version string.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the OpenThread radio version.
|
||||
*/
|
||||
const char *otGetRadioVersionString(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_INSTANCE_H_
|
||||
864
Libs/util/third_party/openthread/include/openthread/ip6.h
vendored
Normal file
864
Libs/util/third_party/openthread/include/openthread/ip6.h
vendored
Normal file
@@ -0,0 +1,864 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread IPv6 API.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_IP6_H_
|
||||
#define OPENTHREAD_IP6_H_
|
||||
|
||||
#include <openthread/message.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-ip6
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control IPv6 communication.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define OT_IP6_PREFIX_SIZE 8 ///< Size of an IPv6 prefix (bytes)
|
||||
#define OT_IP6_PREFIX_BITSIZE (OT_IP6_PREFIX_SIZE * 8) ///< Size of an IPv6 prefix (bits)
|
||||
#define OT_IP6_IID_SIZE 8 ///< Size of an IPv6 Interface Identifier (bytes)
|
||||
#define OT_IP6_ADDRESS_SIZE 16 ///< Size of an IPv6 address (bytes)
|
||||
#define OT_IP6_ADDRESS_BITSIZE (OT_IP6_ADDRESS_SIZE * 8) ///< Size of an IPv6 address (bits)
|
||||
#define OT_IP6_HEADER_SIZE 40 ///< Size of an IPv6 header (bytes)
|
||||
#define OT_IP6_HEADER_PROTO_OFFSET 6 ///< Offset of the proto field in the IPv6 header (bytes)
|
||||
|
||||
/**
|
||||
* @struct otIp6InterfaceIdentifier
|
||||
*
|
||||
* Represents the Interface Identifier of an IPv6 address.
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otIp6InterfaceIdentifier
|
||||
{
|
||||
union OT_TOOL_PACKED_FIELD
|
||||
{
|
||||
uint8_t m8[OT_IP6_IID_SIZE]; ///< 8-bit fields
|
||||
uint16_t m16[OT_IP6_IID_SIZE / sizeof(uint16_t)]; ///< 16-bit fields
|
||||
uint32_t m32[OT_IP6_IID_SIZE / sizeof(uint32_t)]; ///< 32-bit fields
|
||||
} mFields; ///< The Interface Identifier accessor fields
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* Represents the Interface Identifier of an IPv6 address.
|
||||
*/
|
||||
typedef struct otIp6InterfaceIdentifier otIp6InterfaceIdentifier;
|
||||
|
||||
/**
|
||||
* @struct otIp6NetworkPrefix
|
||||
*
|
||||
* Represents the Network Prefix of an IPv6 address (most significant 64 bits of the address).
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otIp6NetworkPrefix
|
||||
{
|
||||
uint8_t m8[OT_IP6_PREFIX_SIZE]; ///< The Network Prefix.
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* Represents the Network Prefix of an IPv6 address (most significant 64 bits of the address).
|
||||
*/
|
||||
typedef struct otIp6NetworkPrefix otIp6NetworkPrefix;
|
||||
|
||||
/**
|
||||
* @struct otIp6AddressComponents
|
||||
*
|
||||
* Represents the components of an IPv6 address.
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otIp6AddressComponents
|
||||
{
|
||||
otIp6NetworkPrefix mNetworkPrefix; ///< The Network Prefix (most significant 64 bits of the address)
|
||||
otIp6InterfaceIdentifier mIid; ///< The Interface Identifier (least significant 64 bits of the address)
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* Represents the components of an IPv6 address.
|
||||
*/
|
||||
typedef struct otIp6AddressComponents otIp6AddressComponents;
|
||||
|
||||
/**
|
||||
* @struct otIp6Address
|
||||
*
|
||||
* Represents an IPv6 address.
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otIp6Address
|
||||
{
|
||||
union OT_TOOL_PACKED_FIELD
|
||||
{
|
||||
uint8_t m8[OT_IP6_ADDRESS_SIZE]; ///< 8-bit fields
|
||||
uint16_t m16[OT_IP6_ADDRESS_SIZE / sizeof(uint16_t)]; ///< 16-bit fields
|
||||
uint32_t m32[OT_IP6_ADDRESS_SIZE / sizeof(uint32_t)]; ///< 32-bit fields
|
||||
otIp6AddressComponents mComponents; ///< IPv6 address components
|
||||
} mFields; ///< IPv6 accessor fields
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* Represents an IPv6 address.
|
||||
*/
|
||||
typedef struct otIp6Address otIp6Address;
|
||||
|
||||
/**
|
||||
* @struct otIp6Prefix
|
||||
*
|
||||
* Represents an IPv6 prefix.
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otIp6Prefix
|
||||
{
|
||||
otIp6Address mPrefix; ///< The IPv6 prefix.
|
||||
uint8_t mLength; ///< The IPv6 prefix length (in bits).
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* Represents an IPv6 prefix.
|
||||
*/
|
||||
typedef struct otIp6Prefix otIp6Prefix;
|
||||
|
||||
/**
|
||||
* IPv6 Address origins
|
||||
*/
|
||||
enum
|
||||
{
|
||||
OT_ADDRESS_ORIGIN_THREAD = 0, ///< Thread assigned address (ALOC, RLOC, MLEID, etc)
|
||||
OT_ADDRESS_ORIGIN_SLAAC = 1, ///< SLAAC assigned address
|
||||
OT_ADDRESS_ORIGIN_DHCPV6 = 2, ///< DHCPv6 assigned address
|
||||
OT_ADDRESS_ORIGIN_MANUAL = 3, ///< Manually assigned address
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents an IPv6 network interface unicast address.
|
||||
*/
|
||||
typedef struct otNetifAddress
|
||||
{
|
||||
otIp6Address mAddress; ///< The IPv6 unicast address.
|
||||
uint8_t mPrefixLength; ///< The Prefix length (in bits).
|
||||
uint8_t mAddressOrigin; ///< The IPv6 address origin.
|
||||
bool mPreferred : 1; ///< TRUE if the address is preferred, FALSE otherwise.
|
||||
bool mValid : 1; ///< TRUE if the address is valid, FALSE otherwise.
|
||||
bool mScopeOverrideValid : 1; ///< TRUE if the mScopeOverride value is valid, FALSE otherwise.
|
||||
unsigned int mScopeOverride : 4; ///< The IPv6 scope of this address.
|
||||
bool mRloc : 1; ///< TRUE if the address is an RLOC, FALSE otherwise.
|
||||
bool mMeshLocal : 1; ///< TRUE if the address is mesh-local, FALSE otherwise.
|
||||
bool mSrpRegistered : 1; ///< Used by OT core only (indicates whether registered by SRP Client).
|
||||
const struct otNetifAddress *mNext; ///< A pointer to the next network interface address.
|
||||
} otNetifAddress;
|
||||
|
||||
/**
|
||||
* Represents an IPv6 network interface multicast address.
|
||||
*/
|
||||
typedef struct otNetifMulticastAddress
|
||||
{
|
||||
otIp6Address mAddress; ///< The IPv6 multicast address.
|
||||
const struct otNetifMulticastAddress *mNext; ///< A pointer to the next network interface multicast address.
|
||||
} otNetifMulticastAddress;
|
||||
|
||||
/**
|
||||
* Represents an IPv6 socket address.
|
||||
*/
|
||||
typedef struct otSockAddr
|
||||
{
|
||||
otIp6Address mAddress; ///< An IPv6 address.
|
||||
uint16_t mPort; ///< A transport-layer port.
|
||||
} otSockAddr;
|
||||
|
||||
/**
|
||||
* ECN statuses, represented as in the IP header.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
OT_ECN_NOT_CAPABLE = 0x0, ///< Non-ECT
|
||||
OT_ECN_CAPABLE_0 = 0x2, ///< ECT(0)
|
||||
OT_ECN_CAPABLE_1 = 0x1, ///< ECT(1)
|
||||
OT_ECN_MARKED = 0x3, ///< Congestion encountered (CE)
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents the local and peer IPv6 socket addresses.
|
||||
*/
|
||||
typedef struct otMessageInfo
|
||||
{
|
||||
otIp6Address mSockAddr; ///< The local IPv6 address.
|
||||
otIp6Address mPeerAddr; ///< The peer IPv6 address.
|
||||
uint16_t mSockPort; ///< The local transport-layer port.
|
||||
uint16_t mPeerPort; ///< The peer transport-layer port.
|
||||
uint8_t mHopLimit; ///< The IPv6 Hop Limit value. Only applies if `mAllowZeroHopLimit` is FALSE.
|
||||
///< If `0`, IPv6 Hop Limit is default value `OPENTHREAD_CONFIG_IP6_HOP_LIMIT_DEFAULT`.
|
||||
///< Otherwise, specifies the IPv6 Hop Limit.
|
||||
uint8_t mEcn : 2; ///< The ECN status of the packet, represented as in the IPv6 header.
|
||||
bool mIsHostInterface : 1; ///< TRUE if packets sent/received via host interface, FALSE otherwise.
|
||||
bool mAllowZeroHopLimit : 1; ///< TRUE to allow IPv6 Hop Limit 0 in `mHopLimit`, FALSE otherwise.
|
||||
bool mMulticastLoop : 1; ///< TRUE to allow looping back multicast, FALSE otherwise.
|
||||
} otMessageInfo;
|
||||
|
||||
/**
|
||||
* Internet Protocol Numbers.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
OT_IP6_PROTO_HOP_OPTS = 0, ///< IPv6 Hop-by-Hop Option
|
||||
OT_IP6_PROTO_TCP = 6, ///< Transmission Control Protocol
|
||||
OT_IP6_PROTO_UDP = 17, ///< User Datagram
|
||||
OT_IP6_PROTO_IP6 = 41, ///< IPv6 encapsulation
|
||||
OT_IP6_PROTO_ROUTING = 43, ///< Routing Header for IPv6
|
||||
OT_IP6_PROTO_FRAGMENT = 44, ///< Fragment Header for IPv6
|
||||
OT_IP6_PROTO_ICMP6 = 58, ///< ICMP for IPv6
|
||||
OT_IP6_PROTO_NONE = 59, ///< No Next Header for IPv6
|
||||
OT_IP6_PROTO_DST_OPTS = 60, ///< Destination Options for IPv6
|
||||
};
|
||||
|
||||
/**
|
||||
* Brings the IPv6 interface up or down.
|
||||
*
|
||||
* Call this to enable or disable IPv6 communication.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnabled TRUE to enable IPv6, FALSE otherwise.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully brought the IPv6 interface up/down.
|
||||
* @retval OT_ERROR_INVALID_STATE IPv6 interface is not available since device is operating in raw-link mode
|
||||
* (applicable only when `OPENTHREAD_CONFIG_LINK_RAW_ENABLE` feature is enabled).
|
||||
*/
|
||||
otError otIp6SetEnabled(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the IPv6 interface is up.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval TRUE The IPv6 interface is enabled.
|
||||
* @retval FALSE The IPv6 interface is disabled.
|
||||
*/
|
||||
bool otIp6IsEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Adds a Network Interface Address to the Thread interface.
|
||||
*
|
||||
* The passed-in instance @p aAddress is copied by the Thread interface. The Thread interface only
|
||||
* supports a fixed number of externally added unicast addresses. See `OPENTHREAD_CONFIG_IP6_MAX_EXT_UCAST_ADDRS`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aAddress A pointer to a Network Interface Address.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added (or updated) the Network Interface Address.
|
||||
* @retval OT_ERROR_INVALID_ARGS The IP Address indicated by @p aAddress is an internal address.
|
||||
* @retval OT_ERROR_NO_BUFS The Network Interface is already storing the maximum allowed external addresses.
|
||||
*/
|
||||
otError otIp6AddUnicastAddress(otInstance *aInstance, const otNetifAddress *aAddress);
|
||||
|
||||
/**
|
||||
* Removes a Network Interface Address from the Thread interface.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aAddress A pointer to an IP Address.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully removed the Network Interface Address.
|
||||
* @retval OT_ERROR_INVALID_ARGS The IP Address indicated by @p aAddress is an internal address.
|
||||
* @retval OT_ERROR_NOT_FOUND The IP Address indicated by @p aAddress was not found.
|
||||
*/
|
||||
otError otIp6RemoveUnicastAddress(otInstance *aInstance, const otIp6Address *aAddress);
|
||||
|
||||
/**
|
||||
* Gets the list of IPv6 addresses assigned to the Thread interface.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the first Network Interface Address.
|
||||
*/
|
||||
const otNetifAddress *otIp6GetUnicastAddresses(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Indicates whether or not a unicast IPv6 address is assigned to the Thread interface.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aAddress A pointer to the unicast address.
|
||||
*
|
||||
* @retval TRUE If @p aAddress is assigned to the Thread interface.
|
||||
* @retval FALSE If @p aAddress is not assigned to the Thread interface.
|
||||
*/
|
||||
bool otIp6HasUnicastAddress(otInstance *aInstance, const otIp6Address *aAddress);
|
||||
|
||||
/**
|
||||
* Subscribes the Thread interface to a Network Interface Multicast Address.
|
||||
*
|
||||
* The passed in instance @p aAddress will be copied by the Thread interface. The Thread interface only
|
||||
* supports a fixed number of externally added multicast addresses. See `OPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aAddress A pointer to an IP Address.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully subscribed to the Network Interface Multicast Address.
|
||||
* @retval OT_ERROR_ALREADY The multicast address is already subscribed.
|
||||
* @retval OT_ERROR_INVALID_ARGS The IP Address indicated by @p aAddress is an invalid multicast address.
|
||||
* @retval OT_ERROR_REJECTED The IP Address indicated by @p aAddress is an internal multicast address.
|
||||
* @retval OT_ERROR_NO_BUFS The Network Interface is already storing the maximum allowed external multicast
|
||||
* addresses.
|
||||
*/
|
||||
otError otIp6SubscribeMulticastAddress(otInstance *aInstance, const otIp6Address *aAddress);
|
||||
|
||||
/**
|
||||
* Unsubscribes the Thread interface to a Network Interface Multicast Address.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aAddress A pointer to an IP Address.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully unsubscribed to the Network Interface Multicast Address.
|
||||
* @retval OT_ERROR_REJECTED The IP Address indicated by @p aAddress is an internal address.
|
||||
* @retval OT_ERROR_NOT_FOUND The IP Address indicated by @p aAddress was not found.
|
||||
*/
|
||||
otError otIp6UnsubscribeMulticastAddress(otInstance *aInstance, const otIp6Address *aAddress);
|
||||
|
||||
/**
|
||||
* Gets the list of IPv6 multicast addresses subscribed to the Thread interface.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the first Network Interface Multicast Address.
|
||||
*/
|
||||
const otNetifMulticastAddress *otIp6GetMulticastAddresses(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Allocate a new message buffer for sending an IPv6 message.
|
||||
*
|
||||
* @note If @p aSettings is 'NULL', the link layer security is enabled and the message priority is set to
|
||||
* OT_MESSAGE_PRIORITY_NORMAL by default.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aSettings A pointer to the message settings or NULL to set default settings.
|
||||
*
|
||||
* @returns A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid.
|
||||
*
|
||||
* @sa otMessageFree
|
||||
*/
|
||||
otMessage *otIp6NewMessage(otInstance *aInstance, const otMessageSettings *aSettings);
|
||||
|
||||
/**
|
||||
* Allocate a new message buffer and write the IPv6 datagram to the message buffer for sending an IPv6 message.
|
||||
*
|
||||
* @note If @p aSettings is NULL, the link layer security is enabled and the message priority is obtained from IPv6
|
||||
* message itself.
|
||||
* If @p aSettings is not NULL, the @p aSetting->mPriority is ignored and obtained from IPv6 message itself.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aData A pointer to the IPv6 datagram buffer.
|
||||
* @param[in] aDataLength The size of the IPv6 datagram buffer pointed by @p aData.
|
||||
* @param[in] aSettings A pointer to the message settings or NULL to set default settings.
|
||||
*
|
||||
* @returns A pointer to the message or NULL if malformed IPv6 header or insufficient message buffers are available.
|
||||
*
|
||||
* @sa otMessageFree
|
||||
*/
|
||||
otMessage *otIp6NewMessageFromBuffer(otInstance *aInstance,
|
||||
const uint8_t *aData,
|
||||
uint16_t aDataLength,
|
||||
const otMessageSettings *aSettings);
|
||||
|
||||
/**
|
||||
* Pointer is called when an IPv6 datagram is received.
|
||||
*
|
||||
* @param[in] aMessage A pointer to the message buffer containing the received IPv6 datagram. This function transfers
|
||||
* the ownership of the @p aMessage to the receiver of the callback. The message should be
|
||||
* freed by the receiver of the callback after it is processed (see otMessageFree()).
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otIp6ReceiveCallback)(otMessage *aMessage, void *aContext);
|
||||
|
||||
/**
|
||||
* Registers a callback to provide received IPv6 datagrams.
|
||||
*
|
||||
* By default, this callback does not pass Thread control traffic. See otIp6SetReceiveFilterEnabled() to
|
||||
* change the Thread control traffic filter setting.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback A pointer to a function that is called when an IPv6 datagram is received or
|
||||
* NULL to disable the callback.
|
||||
* @param[in] aCallbackContext A pointer to application-specific context.
|
||||
*
|
||||
* @sa otIp6IsReceiveFilterEnabled
|
||||
* @sa otIp6SetReceiveFilterEnabled
|
||||
*/
|
||||
void otIp6SetReceiveCallback(otInstance *aInstance, otIp6ReceiveCallback aCallback, void *aCallbackContext);
|
||||
|
||||
/**
|
||||
* Represents IPv6 address information.
|
||||
*/
|
||||
typedef struct otIp6AddressInfo
|
||||
{
|
||||
const otIp6Address *mAddress; ///< A pointer to the IPv6 address.
|
||||
uint8_t mPrefixLength; ///< The prefix length of mAddress if it is a unicast address.
|
||||
uint8_t mScope : 4; ///< The scope of this address.
|
||||
bool mPreferred : 1; ///< Whether this is a preferred address.
|
||||
bool mMeshLocal : 1; ///< Whether this is a mesh-local unicast/anycast address.
|
||||
} otIp6AddressInfo;
|
||||
|
||||
/**
|
||||
* Pointer is called when an internal IPv6 address is added or removed.
|
||||
*
|
||||
* @param[in] aAddressInfo A pointer to the IPv6 address information.
|
||||
* @param[in] aIsAdded TRUE if the @p aAddress was added, FALSE if @p aAddress was removed.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otIp6AddressCallback)(const otIp6AddressInfo *aAddressInfo, bool aIsAdded, void *aContext);
|
||||
|
||||
/**
|
||||
* Registers a callback to notify internal IPv6 address changes.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback A pointer to a function that is called when an internal IPv6 address is added or
|
||||
* removed. NULL to disable the callback.
|
||||
* @param[in] aCallbackContext A pointer to application-specific context.
|
||||
*/
|
||||
void otIp6SetAddressCallback(otInstance *aInstance, otIp6AddressCallback aCallback, void *aCallbackContext);
|
||||
|
||||
/**
|
||||
* Indicates whether or not Thread control traffic is filtered out when delivering IPv6 datagrams
|
||||
* via the callback specified in otIp6SetReceiveCallback().
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns TRUE if Thread control traffic is filtered out, FALSE otherwise.
|
||||
*
|
||||
* @sa otIp6SetReceiveCallback
|
||||
* @sa otIp6SetReceiveFilterEnabled
|
||||
*/
|
||||
bool otIp6IsReceiveFilterEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets whether or not Thread control traffic is filtered out when delivering IPv6 datagrams
|
||||
* via the callback specified in otIp6SetReceiveCallback().
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnabled TRUE if Thread control traffic is filtered out, FALSE otherwise.
|
||||
*
|
||||
* @sa otIp6SetReceiveCallback
|
||||
* @sa otIsReceiveIp6FilterEnabled
|
||||
*/
|
||||
void otIp6SetReceiveFilterEnabled(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Sends an IPv6 datagram via the Thread interface.
|
||||
*
|
||||
* The caller transfers ownership of @p aMessage when making this call. OpenThread will free @p aMessage when
|
||||
* processing is complete, including when a value other than `OT_ERROR_NONE` is returned.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMessage A pointer to the message buffer containing the IPv6 datagram.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully processed the message.
|
||||
* @retval OT_ERROR_DROP Message was well-formed but not fully processed due to packet processing
|
||||
* rules.
|
||||
* @retval OT_ERROR_NO_BUFS Could not allocate necessary message buffers when processing the datagram.
|
||||
* @retval OT_ERROR_NO_ROUTE No route to host.
|
||||
* @retval OT_ERROR_INVALID_SOURCE_ADDRESS Source address is invalid, e.g. an anycast address or a multicast address.
|
||||
* @retval OT_ERROR_PARSE Encountered a malformed header when processing the message.
|
||||
* @retval OT_ERROR_INVALID_ARGS The message's metadata is invalid, e.g. the message uses
|
||||
* `OT_MESSAGE_ORIGIN_THREAD_NETIF` as the origin.
|
||||
*/
|
||||
otError otIp6Send(otInstance *aInstance, otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Adds a port to the allowed unsecured port list.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPort The port value.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The port was successfully added to the allowed unsecure port list.
|
||||
* @retval OT_ERROR_INVALID_ARGS The port is invalid (value 0 is reserved for internal use).
|
||||
* @retval OT_ERROR_NO_BUFS The unsecure port list is full.
|
||||
*/
|
||||
otError otIp6AddUnsecurePort(otInstance *aInstance, uint16_t aPort);
|
||||
|
||||
/**
|
||||
* Removes a port from the allowed unsecure port list.
|
||||
*
|
||||
* @note This function removes @p aPort by overwriting @p aPort with the element after @p aPort in the internal port
|
||||
* list. Be careful when calling otIp6GetUnsecurePorts() followed by otIp6RemoveUnsecurePort() to remove unsecure
|
||||
* ports.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPort The port value.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The port was successfully removed from the allowed unsecure port list.
|
||||
* @retval OT_ERROR_INVALID_ARGS The port is invalid (value 0 is reserved for internal use).
|
||||
* @retval OT_ERROR_NOT_FOUND The port was not found in the unsecure port list.
|
||||
*/
|
||||
otError otIp6RemoveUnsecurePort(otInstance *aInstance, uint16_t aPort);
|
||||
|
||||
/**
|
||||
* Removes all ports from the allowed unsecure port list.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otIp6RemoveAllUnsecurePorts(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Returns a pointer to the unsecure port list.
|
||||
*
|
||||
* @note Port value 0 is used to indicate an invalid entry.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aNumEntries The number of entries in the list.
|
||||
*
|
||||
* @returns A pointer to the unsecure port list.
|
||||
*/
|
||||
const uint16_t *otIp6GetUnsecurePorts(otInstance *aInstance, uint8_t *aNumEntries);
|
||||
|
||||
/**
|
||||
* Test if two IPv6 addresses are the same.
|
||||
*
|
||||
* @param[in] aFirst A pointer to the first IPv6 address to compare.
|
||||
* @param[in] aSecond A pointer to the second IPv6 address to compare.
|
||||
*
|
||||
* @retval TRUE The two IPv6 addresses are the same.
|
||||
* @retval FALSE The two IPv6 addresses are not the same.
|
||||
*/
|
||||
bool otIp6IsAddressEqual(const otIp6Address *aFirst, const otIp6Address *aSecond);
|
||||
|
||||
/**
|
||||
* Test if two IPv6 prefixes are the same.
|
||||
*
|
||||
* @param[in] aFirst A pointer to the first IPv6 prefix to compare.
|
||||
* @param[in] aSecond A pointer to the second IPv6 prefix to compare.
|
||||
*
|
||||
* @retval TRUE The two IPv6 prefixes are the same.
|
||||
* @retval FALSE The two IPv6 prefixes are not the same.
|
||||
*/
|
||||
bool otIp6ArePrefixesEqual(const otIp6Prefix *aFirst, const otIp6Prefix *aSecond);
|
||||
|
||||
/**
|
||||
* Converts a human-readable IPv6 address string into a binary representation.
|
||||
*
|
||||
* @param[in] aString A pointer to a NULL-terminated string.
|
||||
* @param[out] aAddress A pointer to an IPv6 address.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully parsed @p aString and updated @p aAddress.
|
||||
* @retval OT_ERROR_PARSE Failed to parse @p aString as an IPv6 address.
|
||||
*/
|
||||
otError otIp6AddressFromString(const char *aString, otIp6Address *aAddress);
|
||||
|
||||
/**
|
||||
* Converts a human-readable IPv6 prefix string into a binary representation.
|
||||
*
|
||||
* The @p aString parameter should be a string in the format "<address>/<plen>", where `<address>` is an IPv6
|
||||
* address and `<plen>` is a prefix length.
|
||||
*
|
||||
* @param[in] aString A pointer to a NULL-terminated string.
|
||||
* @param[out] aPrefix A pointer to an IPv6 prefix.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully parsed the string as an IPv6 prefix and updated @p aPrefix.
|
||||
* @retval OT_ERROR_PARSE Failed to parse @p aString as an IPv6 prefix.
|
||||
*/
|
||||
otError otIp6PrefixFromString(const char *aString, otIp6Prefix *aPrefix);
|
||||
|
||||
#define OT_IP6_ADDRESS_STRING_SIZE 40 ///< Recommended size for string representation of an IPv6 address.
|
||||
|
||||
/**
|
||||
* Converts a given IPv6 address to a human-readable string.
|
||||
*
|
||||
* The IPv6 address string is formatted as 16 hex values separated by ':' (i.e., "%x:%x:%x:...:%x").
|
||||
*
|
||||
* If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated
|
||||
* but the outputted string is always null-terminated.
|
||||
*
|
||||
* @param[in] aAddress A pointer to an IPv6 address (MUST NOT be NULL).
|
||||
* @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be NULL).
|
||||
* @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_IP6_ADDRESS_STRING_SIZE`.
|
||||
*/
|
||||
void otIp6AddressToString(const otIp6Address *aAddress, char *aBuffer, uint16_t aSize);
|
||||
|
||||
#define OT_IP6_SOCK_ADDR_STRING_SIZE 48 ///< Recommended size for string representation of an IPv6 socket address.
|
||||
|
||||
/**
|
||||
* Converts a given IPv6 socket address to a human-readable string.
|
||||
*
|
||||
* The IPv6 socket address string is formatted as [`address`]:`port` where `address` is shown
|
||||
* as 16 hex values separated by `:` and `port` is the port number in decimal format,
|
||||
* for example "[%x:%x:...:%x]:%u".
|
||||
*
|
||||
* If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated
|
||||
* but the outputted string is always null-terminated.
|
||||
*
|
||||
* @param[in] aSockAddr A pointer to an IPv6 socket address (MUST NOT be NULL).
|
||||
* @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be NULL).
|
||||
* @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_IP6_SOCK_ADDR_STRING_SIZE`.
|
||||
*/
|
||||
void otIp6SockAddrToString(const otSockAddr *aSockAddr, char *aBuffer, uint16_t aSize);
|
||||
|
||||
#define OT_IP6_PREFIX_STRING_SIZE 45 ///< Recommended size for string representation of an IPv6 prefix.
|
||||
|
||||
/**
|
||||
* Converts a given IPv6 prefix to a human-readable string.
|
||||
*
|
||||
* The IPv6 address string is formatted as "%x:%x:%x:...[::]/plen".
|
||||
*
|
||||
* If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated
|
||||
* but the outputted string is always null-terminated.
|
||||
*
|
||||
* @param[in] aPrefix A pointer to an IPv6 prefix (MUST NOT be NULL).
|
||||
* @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be NULL).
|
||||
* @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_IP6_PREFIX_STRING_SIZE`.
|
||||
*/
|
||||
void otIp6PrefixToString(const otIp6Prefix *aPrefix, char *aBuffer, uint16_t aSize);
|
||||
|
||||
/**
|
||||
* Returns the prefix match length (bits) for two IPv6 addresses.
|
||||
*
|
||||
* @param[in] aFirst A pointer to the first IPv6 address.
|
||||
* @param[in] aSecond A pointer to the second IPv6 address.
|
||||
*
|
||||
* @returns The prefix match length in bits.
|
||||
*/
|
||||
uint8_t otIp6PrefixMatch(const otIp6Address *aFirst, const otIp6Address *aSecond);
|
||||
|
||||
/**
|
||||
* Gets a prefix with @p aLength from @p aAddress.
|
||||
*
|
||||
* @param[in] aAddress A pointer to an IPv6 address.
|
||||
* @param[in] aLength The length of prefix in bits.
|
||||
* @param[out] aPrefix A pointer to output the IPv6 prefix.
|
||||
*/
|
||||
void otIp6GetPrefix(const otIp6Address *aAddress, uint8_t aLength, otIp6Prefix *aPrefix);
|
||||
|
||||
/**
|
||||
* Indicates whether or not a given IPv6 address is the Unspecified Address.
|
||||
*
|
||||
* @param[in] aAddress A pointer to an IPv6 address.
|
||||
*
|
||||
* @retval TRUE If the IPv6 address is the Unspecified Address.
|
||||
* @retval FALSE If the IPv6 address is not the Unspecified Address.
|
||||
*/
|
||||
bool otIp6IsAddressUnspecified(const otIp6Address *aAddress);
|
||||
|
||||
/**
|
||||
* Perform OpenThread source address selection.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in,out] aMessageInfo A pointer to the message information.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Found a source address and is filled into mSockAddr of @p aMessageInfo.
|
||||
* @retval OT_ERROR_NOT_FOUND No source address was found and @p aMessageInfo is unchanged.
|
||||
*/
|
||||
otError otIp6SelectSourceAddress(otInstance *aInstance, otMessageInfo *aMessageInfo);
|
||||
|
||||
/**
|
||||
* Indicates whether the SLAAC module is enabled or not.
|
||||
*
|
||||
* `OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE` build-time feature must be enabled.
|
||||
*
|
||||
* @retval TRUE SLAAC module is enabled.
|
||||
* @retval FALSE SLAAC module is disabled.
|
||||
*/
|
||||
bool otIp6IsSlaacEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Enables/disables the SLAAC module.
|
||||
*
|
||||
* `OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE` build-time feature must be enabled.
|
||||
*
|
||||
* When SLAAC module is enabled, SLAAC addresses (based on on-mesh prefixes in Network Data) are added to the interface.
|
||||
* When SLAAC module is disabled any previously added SLAAC address is removed.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnabled TRUE to enable, FALSE to disable.
|
||||
*/
|
||||
void otIp6SetSlaacEnabled(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Pointer allows user to filter prefixes and not allow an SLAAC address based on a prefix to be added.
|
||||
*
|
||||
* `otIp6SetSlaacPrefixFilter()` can be used to set the filter handler. The filter handler is invoked by SLAAC module
|
||||
* when it is about to add a SLAAC address based on a prefix. Its boolean return value determines whether the address
|
||||
* is filtered (not added) or not.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPrefix A pointer to prefix for which SLAAC address is about to be added.
|
||||
*
|
||||
* @retval TRUE Indicates that the SLAAC address based on the prefix should be filtered and NOT added.
|
||||
* @retval FALSE Indicates that the SLAAC address based on the prefix should be added.
|
||||
*/
|
||||
typedef bool (*otIp6SlaacPrefixFilter)(otInstance *aInstance, const otIp6Prefix *aPrefix);
|
||||
|
||||
/**
|
||||
* Sets the SLAAC module filter handler.
|
||||
*
|
||||
* `OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE` build-time feature must be enabled.
|
||||
*
|
||||
* The filter handler is called by SLAAC module when it is about to add a SLAAC address based on a prefix to decide
|
||||
* whether the address should be added or not.
|
||||
*
|
||||
* A NULL filter handler disables filtering and allows all SLAAC addresses to be added.
|
||||
*
|
||||
* If this function is not called, the default filter used by SLAAC module will be NULL (filtering is disabled).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aFilter A pointer to SLAAC prefix filter handler, or NULL to disable filtering.
|
||||
*/
|
||||
void otIp6SetSlaacPrefixFilter(otInstance *aInstance, otIp6SlaacPrefixFilter aFilter);
|
||||
|
||||
/**
|
||||
* Pointer is called with results of `otIp6RegisterMulticastListeners`.
|
||||
*
|
||||
* @param[in] aContext A pointer to the user context.
|
||||
* @param[in] aError OT_ERROR_NONE when successfully sent MLR.req and received MLR.rsp,
|
||||
* OT_ERROR_RESPONSE_TIMEOUT when failed to receive MLR.rsp,
|
||||
* OT_ERROR_PARSE when failed to parse MLR.rsp.
|
||||
* @param[in] aMlrStatus The Multicast Listener Registration status when @p aError is OT_ERROR_NONE.
|
||||
* @param[in] aFailedAddresses A pointer to the failed IPv6 addresses when @p aError is OT_ERROR_NONE.
|
||||
* @param[in] aFailedAddressNum The number of failed IPv6 addresses when @p aError is OT_ERROR_NONE.
|
||||
*
|
||||
* @sa otIp6RegisterMulticastListeners
|
||||
*/
|
||||
typedef void (*otIp6RegisterMulticastListenersCallback)(void *aContext,
|
||||
otError aError,
|
||||
uint8_t aMlrStatus,
|
||||
const otIp6Address *aFailedAddresses,
|
||||
uint8_t aFailedAddressNum);
|
||||
|
||||
#define OT_IP6_MAX_MLR_ADDRESSES 15 ///< Max number of IPv6 addresses supported by Multicast Listener Registration.
|
||||
|
||||
/**
|
||||
* Registers Multicast Listeners to Primary Backbone Router.
|
||||
*
|
||||
* `OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE` and `OPENTHREAD_CONFIG_COMMISSIONER_ENABLE`
|
||||
* must be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aAddresses A Multicast Address Array to register.
|
||||
* @param[in] aAddressNum The number of Multicast Address to register (0 if @p aAddresses is NULL).
|
||||
* @param[in] aTimeout A pointer to the timeout value (in seconds) to be included in MLR.req. A timeout value of 0
|
||||
* removes the corresponding Multicast Listener. If NULL, MLR.req would have no Timeout Tlv by
|
||||
* default.
|
||||
* @param[in] aCallback A pointer to the callback function.
|
||||
* @param[in] aContext A pointer to the user context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully sent MLR.req. The @p aCallback will be called iff this method
|
||||
* returns OT_ERROR_NONE.
|
||||
* @retval OT_ERROR_BUSY If a previous registration was ongoing.
|
||||
* @retval OT_ERROR_INVALID_ARGS If one or more arguments are invalid.
|
||||
* @retval OT_ERROR_INVALID_STATE If the device was not in a valid state to send MLR.req (e.g. Commissioner not
|
||||
* started, Primary Backbone Router not found).
|
||||
* @retval OT_ERROR_NO_BUFS If insufficient message buffers available.
|
||||
*
|
||||
* @sa otIp6RegisterMulticastListenersCallback
|
||||
*/
|
||||
otError otIp6RegisterMulticastListeners(otInstance *aInstance,
|
||||
const otIp6Address *aAddresses,
|
||||
uint8_t aAddressNum,
|
||||
const uint32_t *aTimeout,
|
||||
otIp6RegisterMulticastListenersCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Sets the Mesh Local IID (for test purpose).
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aIid A pointer to the Mesh Local IID to set.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the Mesh Local IID.
|
||||
* @retval OT_ERROR_INVALID_STATE Thread protocols are enabled.
|
||||
*/
|
||||
otError otIp6SetMeshLocalIid(otInstance *aInstance, const otIp6InterfaceIdentifier *aIid);
|
||||
|
||||
/**
|
||||
* Converts a given IP protocol number to a human-readable string.
|
||||
*
|
||||
* @param[in] aIpProto An IP protocol number (`OT_IP6_PROTO_*` enumeration).
|
||||
*
|
||||
* @returns A string representing @p aIpProto.
|
||||
*/
|
||||
const char *otIp6ProtoToString(uint8_t aIpProto);
|
||||
|
||||
/**
|
||||
* Represents the counters for packets and bytes.
|
||||
*/
|
||||
typedef struct otPacketsAndBytes
|
||||
{
|
||||
uint64_t mPackets; ///< The number of packets.
|
||||
uint64_t mBytes; ///< The number of bytes.
|
||||
} otPacketsAndBytes;
|
||||
|
||||
/**
|
||||
* Represents the counters of packets forwarded via Border Routing.
|
||||
*/
|
||||
typedef struct otBorderRoutingCounters
|
||||
{
|
||||
otPacketsAndBytes mInboundUnicast; ///< The counters for inbound unicast.
|
||||
otPacketsAndBytes mInboundMulticast; ///< The counters for inbound multicast.
|
||||
otPacketsAndBytes mOutboundUnicast; ///< The counters for outbound unicast.
|
||||
otPacketsAndBytes mOutboundMulticast; ///< The counters for outbound multicast.
|
||||
otPacketsAndBytes mInboundInternet; ///< The counters for inbound Internet when DHCPv6 PD enabled.
|
||||
otPacketsAndBytes mOutboundInternet; ///< The counters for outbound Internet when DHCPv6 PD enabled.
|
||||
uint32_t mRaRx; ///< The number of received RA packets.
|
||||
uint32_t mRaTxSuccess; ///< The number of RA packets successfully transmitted.
|
||||
uint32_t mRaTxFailure; ///< The number of RA packets failed to transmit.
|
||||
uint32_t mRsRx; ///< The number of received RS packets.
|
||||
uint32_t mRsTxSuccess; ///< The number of RS packets successfully transmitted.
|
||||
uint32_t mRsTxFailure; ///< The number of RS packets failed to transmit.
|
||||
} otBorderRoutingCounters;
|
||||
|
||||
/**
|
||||
* Gets the Border Routing counters.
|
||||
*
|
||||
* `OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE` build-time feature must be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the Border Routing counters.
|
||||
*/
|
||||
const otBorderRoutingCounters *otIp6GetBorderRoutingCounters(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Resets the Border Routing counters.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otIp6ResetBorderRoutingCounters(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_IP6_H_
|
||||
191
Libs/util/third_party/openthread/include/openthread/jam_detection.h
vendored
Normal file
191
Libs/util/third_party/openthread/include/openthread/jam_detection.h
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the OpenThread API for jam detection feature.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_JAM_DETECTION_H_
|
||||
#define OPENTHREAD_JAM_DETECTION_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-jam-detection
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions for signal jamming detection feature.
|
||||
*
|
||||
* The functions in this module are available when jam-detection feature (`OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE`)
|
||||
* is enabled.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pointer is called if signal jam detection is enabled and a jam is detected.
|
||||
*
|
||||
* @param[in] aJamState Current jam state (`true` if jam is detected, `false` otherwise).
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otJamDetectionCallback)(bool aJamState, void *aContext);
|
||||
|
||||
/**
|
||||
* Set the Jam Detection RSSI Threshold (in dBm).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aRssiThreshold The RSSI threshold.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the threshold.
|
||||
*/
|
||||
otError otJamDetectionSetRssiThreshold(otInstance *aInstance, int8_t aRssiThreshold);
|
||||
|
||||
/**
|
||||
* Get the Jam Detection RSSI Threshold (in dBm).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The Jam Detection RSSI Threshold.
|
||||
*/
|
||||
int8_t otJamDetectionGetRssiThreshold(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the Jam Detection Detection Window (in seconds).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aWindow The Jam Detection window (valid range is 1 to 63)
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the window.
|
||||
* @retval OT_ERROR_INVALID_ARGS The given input parameter not within valid range (1-63)
|
||||
*/
|
||||
otError otJamDetectionSetWindow(otInstance *aInstance, uint8_t aWindow);
|
||||
|
||||
/**
|
||||
* Get the Jam Detection Detection Window (in seconds).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The Jam Detection Window.
|
||||
*/
|
||||
uint8_t otJamDetectionGetWindow(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the Jam Detection Busy Period (in seconds).
|
||||
*
|
||||
* The number of aggregate seconds within the detection window where the RSSI must be above
|
||||
* threshold to trigger detection.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aBusyPeriod The Jam Detection busy period (should be non-zero and
|
||||
less than or equal to Jam Detection Window)
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the window.
|
||||
* @retval OT_ERROR_INVALID_ARGS The given input is not within the valid range.
|
||||
*/
|
||||
otError otJamDetectionSetBusyPeriod(otInstance *aInstance, uint8_t aBusyPeriod);
|
||||
|
||||
/**
|
||||
* Get the Jam Detection Busy Period (in seconds)
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The Jam Detection Busy Period.
|
||||
*/
|
||||
uint8_t otJamDetectionGetBusyPeriod(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Start the jamming detection.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback A pointer to a function called to notify of jamming state change.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the jamming detection.
|
||||
* @retval OT_ERROR_ALREADY Jam detection has been started before.
|
||||
*/
|
||||
otError otJamDetectionStart(otInstance *aInstance, otJamDetectionCallback aCallback, void *aContext);
|
||||
|
||||
/**
|
||||
* Stop the jamming detection.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully stopped the jamming detection.
|
||||
* @retval OT_ERROR_ALREADY Jam detection is already stopped.
|
||||
*/
|
||||
otError otJamDetectionStop(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the Jam Detection Status (enabled/disabled)
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The Jam Detection status (true if enabled, false otherwise).
|
||||
*/
|
||||
bool otJamDetectionIsEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the Jam Detection State
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The Jam Detection state (`true` jam is detected, `false' otherwise).
|
||||
*/
|
||||
bool otJamDetectionGetState(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the current history bitmap.
|
||||
*
|
||||
* This value provides information about current state of jamming detection
|
||||
* module for monitoring/debugging purpose. It returns a 64-bit value where
|
||||
* each bit corresponds to one second interval starting with bit 0 for the
|
||||
* most recent interval and bit 63 for the oldest intervals (63 sec earlier).
|
||||
* The bit is set to 1 if the jamming detection module observed/detected
|
||||
* high signal level during the corresponding one second interval.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The current history bitmap.
|
||||
*/
|
||||
uint64_t otJamDetectionGetHistoryBitmap(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_JAM_DETECTION_H_
|
||||
192
Libs/util/third_party/openthread/include/openthread/joiner.h
vendored
Normal file
192
Libs/util/third_party/openthread/include/openthread/joiner.h
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes functions for the Thread Joiner role.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_JOINER_H_
|
||||
#define OPENTHREAD_JOINER_H_
|
||||
|
||||
#include <openthread/platform/radio.h>
|
||||
#include <openthread/platform/toolchain.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-joiner
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions for the Thread Joiner role.
|
||||
*
|
||||
* @note
|
||||
* The functions in this module require `OPENTHREAD_CONFIG_JOINER_ENABLE=1`.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Defines the Joiner State.
|
||||
*/
|
||||
typedef enum otJoinerState
|
||||
{
|
||||
OT_JOINER_STATE_IDLE = 0,
|
||||
OT_JOINER_STATE_DISCOVER = 1,
|
||||
OT_JOINER_STATE_CONNECT = 2,
|
||||
OT_JOINER_STATE_CONNECTED = 3,
|
||||
OT_JOINER_STATE_ENTRUST = 4,
|
||||
OT_JOINER_STATE_JOINED = 5,
|
||||
} otJoinerState;
|
||||
|
||||
#define OT_JOINER_MAX_DISCERNER_LENGTH 64 ///< Maximum length of a Joiner Discerner in bits.
|
||||
|
||||
/**
|
||||
* Represents a Joiner Discerner.
|
||||
*/
|
||||
typedef struct otJoinerDiscerner
|
||||
{
|
||||
uint64_t mValue; ///< Discerner value (the lowest `mLength` bits specify the discerner).
|
||||
uint8_t mLength; ///< Length (number of bits) - must be non-zero and at most `OT_JOINER_MAX_DISCERNER_LENGTH`.
|
||||
} otJoinerDiscerner;
|
||||
|
||||
/**
|
||||
* Pointer is called to notify the completion of a join operation.
|
||||
*
|
||||
* @param[in] aError OT_ERROR_NONE if the join process succeeded.
|
||||
* OT_ERROR_SECURITY if the join process failed due to security credentials.
|
||||
* OT_ERROR_NOT_FOUND if no joinable network was discovered.
|
||||
* OT_ERROR_RESPONSE_TIMEOUT if a response timed out.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otJoinerCallback)(otError aError, void *aContext);
|
||||
|
||||
/**
|
||||
* Enables the Thread Joiner role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPskd A pointer to the PSKd.
|
||||
* @param[in] aProvisioningUrl A pointer to the Provisioning URL (may be NULL).
|
||||
* @param[in] aVendorName A pointer to the Vendor Name (may be NULL).
|
||||
* @param[in] aVendorModel A pointer to the Vendor Model (may be NULL).
|
||||
* @param[in] aVendorSwVersion A pointer to the Vendor SW Version (may be NULL).
|
||||
* @param[in] aVendorData A pointer to the Vendor Data (may be NULL).
|
||||
* @param[in] aCallback A pointer to a function that is called when the join operation completes.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the Joiner role.
|
||||
* @retval OT_ERROR_BUSY The previous attempt is still on-going.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aPskd or @p aProvisioningUrl is invalid.
|
||||
* @retval OT_ERROR_INVALID_STATE The IPv6 stack is not enabled or Thread stack is fully enabled.
|
||||
*/
|
||||
otError otJoinerStart(otInstance *aInstance,
|
||||
const char *aPskd,
|
||||
const char *aProvisioningUrl,
|
||||
const char *aVendorName,
|
||||
const char *aVendorModel,
|
||||
const char *aVendorSwVersion,
|
||||
const char *aVendorData,
|
||||
otJoinerCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Disables the Thread Joiner role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otJoinerStop(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the Joiner State.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The joiner state.
|
||||
*/
|
||||
otJoinerState otJoinerGetState(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the Joiner ID.
|
||||
*
|
||||
* If a Joiner Discerner is not set, Joiner ID is the first 64 bits of the result of computing SHA-256 over
|
||||
* factory-assigned IEEE EUI-64. Otherwise the Joiner ID is calculated from the Joiner Discerner value.
|
||||
*
|
||||
* The Joiner ID is also used as the device's IEEE 802.15.4 Extended Address during the commissioning process.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the Joiner ID.
|
||||
*/
|
||||
const otExtAddress *otJoinerGetId(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the Joiner Discerner.
|
||||
*
|
||||
* The Joiner Discerner is used to calculate the Joiner ID during the Thread Commissioning process. For more
|
||||
* information, refer to #otJoinerGetId.
|
||||
* @note The Joiner Discerner takes the place of the Joiner EUI-64 during the joiner session of Thread Commissioning.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aDiscerner A pointer to a Joiner Discerner. If NULL clears any previously set discerner.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The Joiner Discerner updated successfully.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aDiscerner is not valid (specified length is not within valid range).
|
||||
* @retval OT_ERROR_INVALID_STATE There is an ongoing Joining process so Joiner Discerner could not be changed.
|
||||
*/
|
||||
otError otJoinerSetDiscerner(otInstance *aInstance, otJoinerDiscerner *aDiscerner);
|
||||
|
||||
/**
|
||||
* Gets the Joiner Discerner. For more information, refer to #otJoinerSetDiscerner.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to Joiner Discerner or NULL if none is set.
|
||||
*/
|
||||
const otJoinerDiscerner *otJoinerGetDiscerner(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Converts a given joiner state enumeration value to a human-readable string.
|
||||
*
|
||||
* @param[in] aState The joiner state.
|
||||
*
|
||||
* @returns A human-readable string representation of @p aState.
|
||||
*/
|
||||
const char *otJoinerStateToString(otJoinerState aState);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_JOINER_H_
|
||||
1211
Libs/util/third_party/openthread/include/openthread/link.h
vendored
Normal file
1211
Libs/util/third_party/openthread/include/openthread/link.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
279
Libs/util/third_party/openthread/include/openthread/link_metrics.h
vendored
Normal file
279
Libs/util/third_party/openthread/include/openthread/link_metrics.h
vendored
Normal file
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Link Metrics API.
|
||||
*/
|
||||
|
||||
#ifndef LINK_METRICS_H_
|
||||
#define LINK_METRICS_H_
|
||||
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/message.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-link-metrics
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control the Link Metrics protocol.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents the result (value) for a Link Metrics query.
|
||||
*/
|
||||
typedef struct otLinkMetricsValues
|
||||
{
|
||||
otLinkMetrics mMetrics; ///< Specifies which metrics values are present/included.
|
||||
|
||||
uint32_t mPduCountValue; ///< The value of Pdu Count.
|
||||
uint8_t mLqiValue; ///< The value LQI.
|
||||
uint8_t mLinkMarginValue; ///< The value of Link Margin.
|
||||
int8_t mRssiValue; ///< The value of Rssi.
|
||||
} otLinkMetricsValues;
|
||||
|
||||
/**
|
||||
* Represents which frames are accounted in a Forward Tracking Series.
|
||||
*/
|
||||
typedef struct otLinkMetricsSeriesFlags
|
||||
{
|
||||
bool mLinkProbe : 1; ///< MLE Link Probe.
|
||||
bool mMacData : 1; ///< MAC Data frame.
|
||||
bool mMacDataRequest : 1; ///< MAC Data Request.
|
||||
bool mMacAck : 1; ///< MAC Ack.
|
||||
} otLinkMetricsSeriesFlags;
|
||||
|
||||
/**
|
||||
* Enhanced-ACK Flags.
|
||||
*
|
||||
* These are used in Enhanced-ACK Based Probing to indicate whether to register or clear the probing.
|
||||
*/
|
||||
typedef enum otLinkMetricsEnhAckFlags
|
||||
{
|
||||
OT_LINK_METRICS_ENH_ACK_CLEAR = 0, ///< Clear.
|
||||
OT_LINK_METRICS_ENH_ACK_REGISTER = 1, ///< Register.
|
||||
} otLinkMetricsEnhAckFlags;
|
||||
|
||||
/**
|
||||
* Link Metrics Status values.
|
||||
*/
|
||||
typedef enum otLinkMetricsStatus
|
||||
{
|
||||
OT_LINK_METRICS_STATUS_SUCCESS = 0,
|
||||
OT_LINK_METRICS_STATUS_CANNOT_SUPPORT_NEW_SERIES = 1,
|
||||
OT_LINK_METRICS_STATUS_SERIESID_ALREADY_REGISTERED = 2,
|
||||
OT_LINK_METRICS_STATUS_SERIESID_NOT_RECOGNIZED = 3,
|
||||
OT_LINK_METRICS_STATUS_NO_MATCHING_FRAMES_RECEIVED = 4,
|
||||
OT_LINK_METRICS_STATUS_OTHER_ERROR = 254,
|
||||
} otLinkMetricsStatus;
|
||||
|
||||
/**
|
||||
* Pointer is called when a Link Metrics report is received.
|
||||
*
|
||||
* @param[in] aSource A pointer to the source address.
|
||||
* @param[in] aMetricsValues A pointer to the Link Metrics values (the query result).
|
||||
* @param[in] aStatus The status code in the report (only useful when @p aMetricsValues is NULL).
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otLinkMetricsReportCallback)(const otIp6Address *aSource,
|
||||
const otLinkMetricsValues *aMetricsValues,
|
||||
otLinkMetricsStatus aStatus,
|
||||
void *aContext);
|
||||
/**
|
||||
* Pointer is called when a Link Metrics Management Response is received.
|
||||
*
|
||||
* @param[in] aSource A pointer to the source address.
|
||||
* @param[in] aStatus The status code in the response.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otLinkMetricsMgmtResponseCallback)(const otIp6Address *aSource,
|
||||
otLinkMetricsStatus aStatus,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Pointer is called when Enh-ACK Probing IE is received.
|
||||
*
|
||||
* @param[in] aShortAddress The Mac short address of the Probing Subject.
|
||||
* @param[in] aExtAddress A pointer to the Mac extended address of the Probing Subject.
|
||||
* @param[in] aMetricsValues A pointer to the Link Metrics values obtained from the IE.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otLinkMetricsEnhAckProbingIeReportCallback)(otShortAddress aShortAddress,
|
||||
const otExtAddress *aExtAddress,
|
||||
const otLinkMetricsValues *aMetricsValues,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Sends an MLE Data Request to query Link Metrics.
|
||||
*
|
||||
* It could be either Single Probe or Forward Tracking Series.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDestination A pointer to the destination address.
|
||||
* @param[in] aSeriesId The Series ID to query about, 0 for Single Probe.
|
||||
* @param[in] aLinkMetricsFlags A pointer to flags specifying what metrics to query.
|
||||
* @param[in] aCallback A pointer to a function that is called when Link Metrics report is received.
|
||||
* @param[in] aCallbackContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully sent a Link Metrics query message.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffers to generate the MLE Data Request message.
|
||||
* @retval OT_ERROR_UNKNOWN_NEIGHBOR @p aDestination is not link-local or the neighbor is not found.
|
||||
* @retval OT_ERROR_NOT_CAPABLE The neighbor is not a Thread 1.2 device and does not support Link Metrics.
|
||||
*/
|
||||
otError otLinkMetricsQuery(otInstance *aInstance,
|
||||
const otIp6Address *aDestination,
|
||||
uint8_t aSeriesId,
|
||||
const otLinkMetrics *aLinkMetricsFlags,
|
||||
otLinkMetricsReportCallback aCallback,
|
||||
void *aCallbackContext);
|
||||
|
||||
/**
|
||||
* Sends an MLE Link Metrics Management Request to configure or clear a Forward Tracking Series.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDestination A pointer to the destination address.
|
||||
* @param[in] aSeriesId The Series ID to operate with.
|
||||
* @param[in] aSeriesFlags The Series Flags that specifies which frames are to be accounted.
|
||||
* @param[in] aLinkMetricsFlags A pointer to flags specifying what metrics to query. Should be `NULL` when
|
||||
* `aSeriesFlags` is `0`.
|
||||
* @param[in] aCallback A pointer to a function that is called when Link Metrics Management Response is
|
||||
* received.
|
||||
* @param[in] aCallbackContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully sent a Link Metrics Management Request message.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffers to generate the MLE Link Metrics Management Request message.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aSeriesId is not within the valid range.
|
||||
* @retval OT_ERROR_UNKNOWN_NEIGHBOR @p aDestination is not link-local or the neighbor is not found.
|
||||
* @retval OT_ERROR_NOT_CAPABLE The neighbor is not a Thread 1.2 device and does not support Link Metrics.
|
||||
*/
|
||||
otError otLinkMetricsConfigForwardTrackingSeries(otInstance *aInstance,
|
||||
const otIp6Address *aDestination,
|
||||
uint8_t aSeriesId,
|
||||
otLinkMetricsSeriesFlags aSeriesFlags,
|
||||
const otLinkMetrics *aLinkMetricsFlags,
|
||||
otLinkMetricsMgmtResponseCallback aCallback,
|
||||
void *aCallbackContext);
|
||||
|
||||
/**
|
||||
* Sends an MLE Link Metrics Management Request to configure/clear an Enhanced-ACK Based Probing.
|
||||
* This functionality requires OT_LINK_METRICS_INITIATOR feature enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDestination A pointer to the destination address.
|
||||
* @param[in] aEnhAckFlags Enh-ACK Flags to indicate whether to register or clear the probing. `0` to clear and
|
||||
* `1` to register. Other values are reserved.
|
||||
* @param[in] aLinkMetricsFlags A pointer to flags specifying what metrics to query. Should be `NULL` when
|
||||
* `aEnhAckFlags` is `0`.
|
||||
* @param[in] aCallback A pointer to a function that is called when an Enhanced Ack with Link Metrics is
|
||||
* received.
|
||||
* @param[in] aCallbackContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully sent a Link Metrics Management Request message.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffers to generate the MLE Link Metrics Management Request message.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aEnhAckFlags is not a valid value or @p aLinkMetricsFlags isn't correct.
|
||||
* @retval OT_ERROR_UNKNOWN_NEIGHBOR @p aDestination is not link-local or the neighbor is not found.
|
||||
* @retval OT_ERROR_NOT_CAPABLE The neighbor is not a Thread 1.2 device and does not support Link Metrics.
|
||||
*/
|
||||
otError otLinkMetricsConfigEnhAckProbing(otInstance *aInstance,
|
||||
const otIp6Address *aDestination,
|
||||
otLinkMetricsEnhAckFlags aEnhAckFlags,
|
||||
const otLinkMetrics *aLinkMetricsFlags,
|
||||
otLinkMetricsMgmtResponseCallback aCallback,
|
||||
void *aCallbackContext,
|
||||
otLinkMetricsEnhAckProbingIeReportCallback aEnhAckCallback,
|
||||
void *aEnhAckCallbackContext);
|
||||
|
||||
/**
|
||||
* Sends an MLE Link Probe message.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDestination A pointer to the destination address.
|
||||
* @param[in] aSeriesId The Series ID [1, 254] which the Probe message aims at.
|
||||
* @param[in] aLength The length of the data payload in Link Probe TLV, [0, 64] (per Thread 1.2 spec, 4.4.37).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully sent a Link Probe message.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffers to generate the MLE Link Probe message.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aSeriesId or @p aLength is not within the valid range.
|
||||
* @retval OT_ERROR_UNKNOWN_NEIGHBOR @p aDestination is not link-local or the neighbor is not found.
|
||||
* @retval OT_ERROR_NOT_CAPABLE The neighbor is not a Thread 1.2 device and does not support Link Metrics.
|
||||
*/
|
||||
otError otLinkMetricsSendLinkProbe(otInstance *aInstance,
|
||||
const otIp6Address *aDestination,
|
||||
uint8_t aSeriesId,
|
||||
uint8_t aLength);
|
||||
|
||||
/**
|
||||
* If Link Metrics Manager is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval TRUE Link Metrics Manager is enabled.
|
||||
* @retval FALSE Link Metrics Manager is not enabled.
|
||||
*/
|
||||
bool otLinkMetricsManagerIsEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Enable or disable Link Metrics Manager.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnable A boolean indicating to enable or disable.
|
||||
*/
|
||||
void otLinkMetricsManagerSetEnabled(otInstance *aInstance, bool aEnable);
|
||||
|
||||
/**
|
||||
* Get Link Metrics data of a neighbor by its extended address.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aExtAddress A pointer to the Mac extended address of the Probing Subject.
|
||||
* @param[out] aLinkMetricsValues A pointer to the Link Metrics values of the subject.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully got the Link Metrics data.
|
||||
* @retval OT_ERROR_INVALID_ARGS The arguments are invalid.
|
||||
* @retval OT_ERROR_NOT_FOUND No neighbor with the given extended address is found.
|
||||
*/
|
||||
otError otLinkMetricsManagerGetMetricsValueByExtAddr(otInstance *aInstance,
|
||||
const otExtAddress *aExtAddress,
|
||||
otLinkMetricsValues *aLinkMetricsValues);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // LINK_METRICS_H_
|
||||
394
Libs/util/third_party/openthread/include/openthread/link_raw.h
vendored
Normal file
394
Libs/util/third_party/openthread/include/openthread/link_raw.h
vendored
Normal file
@@ -0,0 +1,394 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the raw OpenThread IEEE 802.15.4 Link Layer API.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_LINK_RAW_H_
|
||||
#define OPENTHREAD_LINK_RAW_H_
|
||||
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-link-raw
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control the raw link-layer configuration.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pointer on receipt of a IEEE 802.15.4 frame.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aFrame A pointer to the received frame or NULL if the receive operation was aborted.
|
||||
* @param[in] aError OT_ERROR_NONE when successfully received a frame.
|
||||
* OT_ERROR_ABORT when reception was aborted and a frame was not received.
|
||||
*/
|
||||
typedef void (*otLinkRawReceiveDone)(otInstance *aInstance, otRadioFrame *aFrame, otError aError);
|
||||
|
||||
/**
|
||||
* Enables/disables the raw link-layer.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback A pointer to a function called on receipt of a IEEE 802.15.4 frame. NULL to disable the
|
||||
* raw-link layer.
|
||||
*
|
||||
* @retval OT_ERROR_FAILED The radio could not be enabled/disabled.
|
||||
* @retval OT_ERROR_INVALID_STATE If the OpenThread IPv6 interface is already enabled.
|
||||
* @retval OT_ERROR_NONE If the enable state was successfully set.
|
||||
*/
|
||||
otError otLinkRawSetReceiveDone(otInstance *aInstance, otLinkRawReceiveDone aCallback);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the raw link-layer is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval true The raw link-layer is enabled.
|
||||
* @retval false The raw link-layer is disabled.
|
||||
*/
|
||||
bool otLinkRawIsEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the status of promiscuous mode.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval true Promiscuous mode is enabled.
|
||||
* @retval false Promiscuous mode is disabled.
|
||||
*/
|
||||
bool otLinkRawGetPromiscuous(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Enables or disables promiscuous mode.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnable A value to enable or disable promiscuous mode.
|
||||
*
|
||||
* @retval OT_ERROR_NONE If successful.
|
||||
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
|
||||
*/
|
||||
otError otLinkRawSetPromiscuous(otInstance *aInstance, bool aEnable);
|
||||
|
||||
/**
|
||||
* Set the Short Address for address filtering.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aShortAddress The IEEE 802.15.4 Short Address.
|
||||
*
|
||||
* @retval OT_ERROR_NONE If successful.
|
||||
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
|
||||
*/
|
||||
otError otLinkRawSetShortAddress(otInstance *aInstance, uint16_t aShortAddress);
|
||||
|
||||
/**
|
||||
* Set the alternate short address.
|
||||
*
|
||||
* This is an optional API. Support for this is indicated by including the capability `OT_RADIO_CAPS_ALT_SHORT_ADDR` in
|
||||
* `otLinkRawGetCaps()`.
|
||||
*
|
||||
* When supported, the radio will accept received frames destined to the specified alternate short address in addition
|
||||
* to the short address provided in `otLinkRawSetShortAddress()`.
|
||||
*
|
||||
* The @p aShortAddress can be set to `OT_RADIO_INVALID_SHORT_ADDR` (0xfffe) to clear any previously set alternate
|
||||
* short address.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aShortAddress The alternate short address. `OT_RADIO_INVALID_SHORT_ADDR` to clear.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the alternate short address.
|
||||
* @retval OT_ERROR_INVALID_STATE The raw link-layer is not enabled.
|
||||
*/
|
||||
otError otLinkRawSetAlternateShortAddress(otInstance *aInstance, otShortAddress aShortAddress);
|
||||
|
||||
/**
|
||||
* Transition the radio from Receive to Sleep.
|
||||
* Turn off the radio.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully transitioned to Sleep.
|
||||
* @retval OT_ERROR_BUSY The radio was transmitting
|
||||
* @retval OT_ERROR_INVALID_STATE The radio was disabled
|
||||
*/
|
||||
otError otLinkRawSleep(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Transitioning the radio from Sleep to Receive.
|
||||
* Turn on the radio.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully transitioned to Receive.
|
||||
* @retval OT_ERROR_INVALID_STATE The radio was disabled or transmitting.
|
||||
*/
|
||||
otError otLinkRawReceive(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* The radio transitions from Transmit to Receive.
|
||||
* Returns a pointer to the transmit buffer.
|
||||
*
|
||||
* The caller forms the IEEE 802.15.4 frame in this buffer then calls otLinkRawTransmit()
|
||||
* to request transmission.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the transmit buffer or NULL if the raw link-layer isn't enabled.
|
||||
*/
|
||||
otRadioFrame *otLinkRawGetTransmitBuffer(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Pointer on receipt of a IEEE 802.15.4 frame.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aFrame A pointer to the frame that was transmitted.
|
||||
* @param[in] aAckFrame A pointer to the ACK frame.
|
||||
* @param[in] aError OT_ERROR_NONE when the frame was transmitted.
|
||||
* OT_ERROR_NO_ACK when the frame was transmitted but no ACK was received
|
||||
* OT_ERROR_CHANNEL_ACCESS_FAILURE when the transmission could not take place
|
||||
due to activity on the channel.
|
||||
* OT_ERROR_ABORT when transmission was aborted for other reasons.
|
||||
*/
|
||||
typedef void (*otLinkRawTransmitDone)(otInstance *aInstance,
|
||||
otRadioFrame *aFrame,
|
||||
otRadioFrame *aAckFrame,
|
||||
otError aError);
|
||||
|
||||
/**
|
||||
* Begins the transmit sequence on the radio.
|
||||
*
|
||||
* The caller must form the IEEE 802.15.4 frame in the buffer provided by otLinkRawGetTransmitBuffer() before
|
||||
* requesting transmission. The channel and transmit power are also included in the otRadioFrame structure.
|
||||
*
|
||||
* The transmit sequence consists of:
|
||||
* 1. Transitioning the radio to Transmit from Receive.
|
||||
* 2. Transmits the PSDU on the given channel and at the given transmit power.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback A pointer to a function called on completion of the transmission.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully transitioned to Transmit.
|
||||
* @retval OT_ERROR_INVALID_STATE The radio was not in the Receive state.
|
||||
*/
|
||||
otError otLinkRawTransmit(otInstance *aInstance, otLinkRawTransmitDone aCallback);
|
||||
|
||||
/**
|
||||
* Get the most recent RSSI measurement.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The RSSI in dBm when it is valid. 127 when RSSI is invalid.
|
||||
*/
|
||||
int8_t otLinkRawGetRssi(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the radio capabilities.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The radio capability bit vector. The stack enables or disables some functions based on this value.
|
||||
*/
|
||||
otRadioCaps otLinkRawGetCaps(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Pointer on receipt of a IEEE 802.15.4 frame.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnergyScanMaxRssi The maximum RSSI encountered on the scanned channel.
|
||||
*/
|
||||
typedef void (*otLinkRawEnergyScanDone)(otInstance *aInstance, int8_t aEnergyScanMaxRssi);
|
||||
|
||||
/**
|
||||
* Begins the energy scan sequence on the radio.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aScanChannel The channel to perform the energy scan on.
|
||||
* @param[in] aScanDuration The duration, in milliseconds, for the channel to be scanned.
|
||||
* @param[in] aCallback A pointer to a function called on completion of a scanned channel.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started scanning the channel.
|
||||
* @retval OT_ERROR_BUSY The radio is performing energy scanning.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED The radio doesn't support energy scanning.
|
||||
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
|
||||
*/
|
||||
otError otLinkRawEnergyScan(otInstance *aInstance,
|
||||
uint8_t aScanChannel,
|
||||
uint16_t aScanDuration,
|
||||
otLinkRawEnergyScanDone aCallback);
|
||||
|
||||
/**
|
||||
* Enable/Disable source match for frame pending.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnable Enable/disable source match for frame pending.
|
||||
*
|
||||
* @retval OT_ERROR_NONE If successful.
|
||||
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
|
||||
*/
|
||||
otError otLinkRawSrcMatchEnable(otInstance *aInstance, bool aEnable);
|
||||
|
||||
/**
|
||||
* Adding short address to the source match table.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aShortAddress The short address to be added.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added short address to the source match table.
|
||||
* @retval OT_ERROR_NO_BUFS No available entry in the source match table.
|
||||
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
|
||||
*/
|
||||
otError otLinkRawSrcMatchAddShortEntry(otInstance *aInstance, uint16_t aShortAddress);
|
||||
|
||||
/**
|
||||
* Adding extended address to the source match table.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aExtAddress The extended address to be added.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added extended address to the source match table.
|
||||
* @retval OT_ERROR_NO_BUFS No available entry in the source match table.
|
||||
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
|
||||
*/
|
||||
otError otLinkRawSrcMatchAddExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress);
|
||||
|
||||
/**
|
||||
* Removing short address to the source match table.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aShortAddress The short address to be removed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully removed short address from the source match table.
|
||||
* @retval OT_ERROR_NO_ADDRESS The short address is not in source match table.
|
||||
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
|
||||
*/
|
||||
otError otLinkRawSrcMatchClearShortEntry(otInstance *aInstance, uint16_t aShortAddress);
|
||||
|
||||
/**
|
||||
* Removing extended address to the source match table of the radio.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aExtAddress The extended address to be removed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully removed the extended address from the source match table.
|
||||
* @retval OT_ERROR_NO_ADDRESS The extended address is not in source match table.
|
||||
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
|
||||
*/
|
||||
otError otLinkRawSrcMatchClearExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress);
|
||||
|
||||
/**
|
||||
* Removing all the short addresses from the source match table.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE If successful.
|
||||
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
|
||||
*/
|
||||
otError otLinkRawSrcMatchClearShortEntries(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Removing all the extended addresses from the source match table.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE If successful.
|
||||
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
|
||||
*/
|
||||
otError otLinkRawSrcMatchClearExtEntries(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Update MAC keys and key index.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aKeyIdMode The key ID mode.
|
||||
* @param[in] aKeyId The key index.
|
||||
* @param[in] aPrevKey The previous MAC key.
|
||||
* @param[in] aCurrKey The current MAC key.
|
||||
* @param[in] aNextKey The next MAC key.
|
||||
*
|
||||
* @retval OT_ERROR_NONE If successful.
|
||||
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
|
||||
*/
|
||||
otError otLinkRawSetMacKey(otInstance *aInstance,
|
||||
uint8_t aKeyIdMode,
|
||||
uint8_t aKeyId,
|
||||
const otMacKey *aPrevKey,
|
||||
const otMacKey *aCurrKey,
|
||||
const otMacKey *aNextKey);
|
||||
|
||||
/**
|
||||
* Sets the current MAC frame counter value.
|
||||
*
|
||||
* Always sets the MAC counter to the new given value @p aMacFrameCounter independent of the current
|
||||
* value.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMacFrameCounter The MAC frame counter value.
|
||||
*
|
||||
* @retval OT_ERROR_NONE If successful.
|
||||
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
|
||||
*/
|
||||
otError otLinkRawSetMacFrameCounter(otInstance *aInstance, uint32_t aMacFrameCounter);
|
||||
|
||||
/**
|
||||
* Sets the current MAC frame counter value only if the new value is larger than the current one.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMacFrameCounter The MAC frame counter value.
|
||||
*
|
||||
* @retval OT_ERROR_NONE If successful.
|
||||
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
|
||||
*/
|
||||
otError otLinkRawSetMacFrameCounterIfLarger(otInstance *aInstance, uint32_t aMacFrameCounter);
|
||||
|
||||
/**
|
||||
* Get current platform time (64bits width) of the radio chip.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The current radio time in microseconds.
|
||||
*/
|
||||
uint64_t otLinkRawGetRadioTime(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_LINK_RAW_H_
|
||||
285
Libs/util/third_party/openthread/include/openthread/logging.h
vendored
Normal file
285
Libs/util/third_party/openthread/include/openthread/logging.h
vendored
Normal file
@@ -0,0 +1,285 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2018, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes OpenThread logging related definitions.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_LOGGING_H_
|
||||
#define OPENTHREAD_LOGGING_H_
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-logging
|
||||
*
|
||||
* @brief
|
||||
* This module includes OpenThread logging related definitions.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the current log level.
|
||||
*
|
||||
* If dynamic log level feature `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE` is enabled, this function returns the
|
||||
* currently set dynamic log level. Otherwise, this function returns the build-time configured log level.
|
||||
*
|
||||
* @returns The log level.
|
||||
*/
|
||||
otLogLevel otLoggingGetLevel(void);
|
||||
|
||||
/**
|
||||
* Sets the log level.
|
||||
*
|
||||
* @note This function requires `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1`.
|
||||
*
|
||||
* @param[in] aLogLevel The log level.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully updated log level.
|
||||
* @retval OT_ERROR_INVALID_ARGS Log level value is invalid.
|
||||
*/
|
||||
otError otLoggingSetLevel(otLogLevel aLogLevel);
|
||||
|
||||
/**
|
||||
* Emits a log message at critical log level.
|
||||
*
|
||||
* Is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
|
||||
* level is below critical, this function does not emit any log message.
|
||||
*
|
||||
* @param[in] aFormat The format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*/
|
||||
void otLogCritPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
|
||||
/**
|
||||
* Emits a log message at warning log level.
|
||||
*
|
||||
* Is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
|
||||
* level is below warning, this function does not emit any log message.
|
||||
*
|
||||
* @param[in] aFormat The format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*/
|
||||
void otLogWarnPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
|
||||
/**
|
||||
* Emits a log message at note log level.
|
||||
*
|
||||
* Is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
|
||||
* level is below note, this function does not emit any log message.
|
||||
*
|
||||
* @param[in] aFormat The format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*/
|
||||
void otLogNotePlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
|
||||
/**
|
||||
* Emits a log message at info log level.
|
||||
*
|
||||
* Is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
|
||||
* level is below info, this function does not emit any log message.
|
||||
*
|
||||
* @param[in] aFormat The format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*/
|
||||
void otLogInfoPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
|
||||
/**
|
||||
* Emits a log message at debug log level.
|
||||
*
|
||||
* Is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
|
||||
* level is below debug, this function does not emit any log message.
|
||||
*
|
||||
* @param[in] aFormat The format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*/
|
||||
void otLogDebgPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
|
||||
/**
|
||||
* Generates a memory dump at critical log level.
|
||||
*
|
||||
* If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below
|
||||
* critical this function does not emit any log message.
|
||||
*
|
||||
* @param[in] aText A string that is printed before the bytes.
|
||||
* @param[in] aData A pointer to the data buffer.
|
||||
* @param[in] aDataLength Number of bytes in @p aData.
|
||||
*/
|
||||
void otDumpCritPlat(const char *aText, const void *aData, uint16_t aDataLength);
|
||||
|
||||
/**
|
||||
* Generates a memory dump at warning log level.
|
||||
*
|
||||
* If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below
|
||||
* warning this function does not emit any log message.
|
||||
*
|
||||
* @param[in] aText A string that is printed before the bytes.
|
||||
* @param[in] aData A pointer to the data buffer.
|
||||
* @param[in] aDataLength Number of bytes in @p aData.
|
||||
*/
|
||||
void otDumpWarnPlat(const char *aText, const void *aData, uint16_t aDataLength);
|
||||
|
||||
/**
|
||||
* Generates a memory dump at note log level.
|
||||
*
|
||||
* If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below
|
||||
* note this function does not emit any log message.
|
||||
*
|
||||
* @param[in] aText A string that is printed before the bytes.
|
||||
* @param[in] aData A pointer to the data buffer.
|
||||
* @param[in] aDataLength Number of bytes in @p aData.
|
||||
*/
|
||||
void otDumpNotePlat(const char *aText, const void *aData, uint16_t aDataLength);
|
||||
|
||||
/**
|
||||
* Generates a memory dump at info log level.
|
||||
*
|
||||
* If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below
|
||||
* info this function does not emit any log message.
|
||||
*
|
||||
* @param[in] aText A string that is printed before the bytes.
|
||||
* @param[in] aData A pointer to the data buffer.
|
||||
* @param[in] aDataLength Number of bytes in @p aData.
|
||||
*/
|
||||
void otDumpInfoPlat(const char *aText, const void *aData, uint16_t aDataLength);
|
||||
|
||||
/**
|
||||
* Generates a memory dump at debug log level.
|
||||
*
|
||||
* If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below
|
||||
* debug this function does not emit any log message.
|
||||
*
|
||||
* @param[in] aText A string that is printed before the bytes.
|
||||
* @param[in] aData A pointer to the data buffer.
|
||||
* @param[in] aDataLength Number of bytes in @p aData.
|
||||
*/
|
||||
void otDumpDebgPlat(const char *aText, const void *aData, uint16_t aDataLength);
|
||||
|
||||
/**
|
||||
* Emits a log message at given log level using a platform module name.
|
||||
*
|
||||
* This is is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
|
||||
* level is below @p aLogLevel , this function does not emit any log message.
|
||||
*
|
||||
* The @p aPlatModuleName name is used to determine the log module name in the emitted log message, following the
|
||||
* `P-{PlatModuleName}---` format. This means that the prefix string "P-" is added to indicate that this is a platform
|
||||
* sub-module, followed by the next 12 characters of the @p PlatModuleName string, with padded hyphens `-` at the end
|
||||
* to ensure that the region name is 14 characters long.
|
||||
|
||||
* @param[in] aLogLevel The log level.
|
||||
* @param[in] aPlatModuleName The platform sub-module name.
|
||||
* @param[in] aFormat The format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*/
|
||||
void otLogPlat(otLogLevel aLogLevel, const char *aPlatModuleName, const char *aFormat, ...)
|
||||
OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(3, 4);
|
||||
|
||||
/**
|
||||
* Emits a log message at given log level using a platform module name.
|
||||
*
|
||||
* This is is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
|
||||
* level is below @p aLogLevel , this function does not emit any log message.
|
||||
*
|
||||
* The @p aPlatModuleName name is used to determine the log module name in the emitted log message, following the
|
||||
* `P-{PlatModuleName}---` format. This means that the prefix string "P-" is added to indicate that this is a platform
|
||||
* sub-module, followed by the next 12 characters of the @p PlatModuleName string, with padded hyphens `-` at the end
|
||||
* to ensure that the region name is 14 characters long.
|
||||
*
|
||||
* @param[in] aLogLevel The log level.
|
||||
* @param[in] aPlatModuleName The platform sub-module name.
|
||||
* @param[in] aFormat The format string.
|
||||
* @param[in] aArgs Arguments for the format specification.
|
||||
*/
|
||||
void otLogPlatArgs(otLogLevel aLogLevel, const char *aPlatModuleName, const char *aFormat, va_list aArgs);
|
||||
|
||||
/**
|
||||
* Emits a log message at a given log level.
|
||||
*
|
||||
* Is intended for use by CLI only. If `OPENTHREAD_CONFIG_LOG_CLI` is not set or the current log
|
||||
* level is below the given log level, this function does not emit any log message.
|
||||
*
|
||||
* @param[in] aLogLevel The log level.
|
||||
* @param[in] aFormat The format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*/
|
||||
void otLogCli(otLogLevel aLogLevel, const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 3);
|
||||
|
||||
#define OT_LOG_HEX_DUMP_LINE_SIZE 73 ///< Hex dump line string size.
|
||||
|
||||
/**
|
||||
* Represents information used for generating hex dump output.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const uint8_t *mDataBytes; ///< The data byes.
|
||||
uint16_t mDataLength; ///< The data length (number of bytes in @p mDataBytes)
|
||||
const char *mTitle; ///< Title string to add table header (MUST NOT be `NULL`).
|
||||
char mLine[OT_LOG_HEX_DUMP_LINE_SIZE]; ///< Buffer to output one line of generated hex dump.
|
||||
uint16_t mIterator; ///< Iterator used by OT stack. MUST be initialized to zero.
|
||||
} otLogHexDumpInfo;
|
||||
|
||||
/**
|
||||
* Generates the next hex dump line.
|
||||
*
|
||||
* Can call this method back-to-back to generate the hex dump output line by line. On the first call the `mIterator`
|
||||
* field in @p aInfo MUST be set to zero.
|
||||
*
|
||||
* Here is an example of the generated hex dump output:
|
||||
*
|
||||
* "==========================[{mTitle} len=070]============================"
|
||||
* "| 41 D8 87 34 12 FF FF 25 | 4C 57 DA F2 FB 2F 62 7F | A..4...%LW.../b. |"
|
||||
* "| 3B 01 F0 4D 4C 4D 4C 54 | 4F 00 15 15 00 00 00 00 | ;..MLMLTO....... |"
|
||||
* "| 00 00 00 01 80 DB 60 82 | 7E 33 72 3B CC B3 A1 84 | ......`.~3r;.... |"
|
||||
* "| 3B E6 AD B2 0B 45 E7 45 | C5 B9 00 1A CB 2D 6D 1C | ;....E.E.....-m. |"
|
||||
* "| 10 3E 3C F5 D3 70 | | .><..p |"
|
||||
* "------------------------------------------------------------------------"
|
||||
*
|
||||
* @param[in,out] aInfo A pointer to `otLogHexDumpInfo` to use to generate hex dump.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully generated the next line, `mLine` field in @p aInfo is updated.
|
||||
* @retval OT_ERROR_NOT_FOUND Reached the end and no more line to generate.
|
||||
*/
|
||||
otError otLogGenerateNextHexDumpLine(otLogHexDumpInfo *aInfo);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_LOGGING_H_
|
||||
873
Libs/util/third_party/openthread/include/openthread/mdns.h
vendored
Normal file
873
Libs/util/third_party/openthread/include/openthread/mdns.h
vendored
Normal file
@@ -0,0 +1,873 @@
|
||||
/*
|
||||
* Copyright (c) 2024, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the mDNS related APIs.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_MULTICAST_DNS_H_
|
||||
#define OPENTHREAD_MULTICAST_DNS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/platform/dnssd.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-mdns
|
||||
*
|
||||
* @brief
|
||||
* This module includes APIs for Multicast DNS (mDNS).
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* The mDNS APIs are available when the mDNS support `OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE` is enabled and the
|
||||
* `OPENTHREAD_CONFIG_MULTICAST_DNS_PUBLIC_API_ENABLE` is also enabled.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a request ID (`uint32_t` value) for registering a host, a service, or a key service.
|
||||
*/
|
||||
typedef otPlatDnssdRequestId otMdnsRequestId;
|
||||
|
||||
/**
|
||||
* Represents the callback function to report the outcome of a host, service, or key registration request.
|
||||
*
|
||||
* The outcome of a registration request is reported back by invoking this callback with one of the following `aError`
|
||||
* inputs:
|
||||
*
|
||||
* - `OT_ERROR_NONE` indicates registration was successful.
|
||||
* - `OT_ERROR_DUPLICATED` indicates a name conflict while probing, i.e., name is claimed by another mDNS responder.
|
||||
*
|
||||
* See `otMdnsRegisterHost()`, `otMdnsRegisterService()`, and `otMdnsRegisterKey()` for more details about when
|
||||
* the callback will be invoked.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aRequestId The request ID.
|
||||
* @param[in] aError Error indicating the outcome of request.
|
||||
*/
|
||||
typedef otPlatDnssdRegisterCallback otMdnsRegisterCallback;
|
||||
|
||||
/**
|
||||
* Represents the callback function to report a detected name conflict after successful registration of an entry.
|
||||
*
|
||||
* If a conflict is detected while registering an entry, it is reported through the provided `otMdnsRegisterCallback`.
|
||||
* The `otMdnsConflictCallback` is used only when a name conflict is detected after an entry has been successfully
|
||||
* registered.
|
||||
*
|
||||
* A non-NULL @p aServiceType indicates that conflict is for a service entry. In this case @p aName specifies the
|
||||
* service instance label (treated as as a single DNS label and can potentially include dot `.` character).
|
||||
*
|
||||
* A NULL @p aServiceType indicates that conflict is for a host entry. In this case @p Name specifies the host name. It
|
||||
* does not include the domain name.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aName The host name or the service instance label.
|
||||
* @param[in] aServiceType The service type (e.g., `_tst._udp`).
|
||||
*/
|
||||
typedef void (*otMdnsConflictCallback)(otInstance *aInstance, const char *aName, const char *aServiceType);
|
||||
|
||||
/**
|
||||
* Represents an mDNS host.
|
||||
*
|
||||
* This type is used to register or unregister a host (`otMdnsRegisterHost()` and `otMdnsUnregisterHost()`).
|
||||
*
|
||||
* See the description of each function for more details on how different fields are used in each case.
|
||||
*/
|
||||
typedef otPlatDnssdHost otMdnsHost;
|
||||
|
||||
/**
|
||||
* Represents an mDNS service.
|
||||
*
|
||||
* This type is used to register or unregister a service (`otMdnsRegisterService()` and `otMdnsUnregisterService()`).
|
||||
*
|
||||
* See the description of each function for more details on how different fields are used in each case.
|
||||
*/
|
||||
typedef otPlatDnssdService otMdnsService;
|
||||
|
||||
/**
|
||||
* Represents an mDNS key record.
|
||||
*
|
||||
* See `otMdnsRegisterKey()`, `otMdnsUnregisterKey()` for more details about fields in each case.
|
||||
*/
|
||||
typedef otPlatDnssdKey otMdnsKey;
|
||||
|
||||
/**
|
||||
* Represents an mDNS entry iterator.
|
||||
*/
|
||||
typedef struct otMdnsIterator otMdnsIterator;
|
||||
|
||||
/**
|
||||
* Represents a host/service/key entry state.
|
||||
*/
|
||||
typedef enum otMdnsEntryState
|
||||
{
|
||||
OT_MDNS_ENTRY_STATE_PROBING, ///< Probing to claim the name.
|
||||
OT_MDNS_ENTRY_STATE_REGISTERED, ///< Entry is successfully registered.
|
||||
OT_MDNS_ENTRY_STATE_CONFLICT, ///< Name conflict was detected.
|
||||
OT_MDNS_ENTRY_STATE_REMOVING, ///< Entry is being removed (sending "goodbye" announcements).
|
||||
} otMdnsEntryState;
|
||||
|
||||
/**
|
||||
* Enables or disables the mDNS module.
|
||||
*
|
||||
* The mDNS module should be enabled before registration any host, service, or key entries. Disabling mDNS will
|
||||
* immediately stop all operations and any communication (multicast or unicast tx) and remove any previously registered
|
||||
* entries without sending any "goodbye" announcements or invoking their callback. Once disabled, all currently active
|
||||
* browsers and resolvers are stopped.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aEnable Boolean to indicate whether to enable (on `TRUE`) or disable (on `FALSE`).
|
||||
* @param[in] aInfraIfIndex The network interface index for mDNS operation. Value is ignored when disabling
|
||||
*
|
||||
* @retval OT_ERROR_NONE Enabled or disabled the mDNS module successfully.
|
||||
* @retval OT_ERROR_ALREADY mDNS is already enabled on an enable request or is already disabled on a disable request.
|
||||
*/
|
||||
otError otMdnsSetEnabled(otInstance *aInstance, bool aEnable, uint32_t aInfraIfIndex);
|
||||
|
||||
/**
|
||||
* Indicates whether the mDNS module is enabled.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
*
|
||||
* @retval TRUE The mDNS module is enabled
|
||||
* @retval FALSE The mDNS module is disabled.
|
||||
*/
|
||||
bool otMdnsIsEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets whether the mDNS module is allowed to send questions requesting unicast responses referred to as "QU" questions.
|
||||
*
|
||||
* The "QU" questions request unicast responses, in contrast to "QM" questions which request multicast responses.
|
||||
*
|
||||
* When allowed, the first probe will be sent as a "QU" question. This API can be used to address platform limitation
|
||||
* where platform socket cannot accept unicast response received on mDNS port (due to it being already bound).
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aAllow Indicates whether or not to allow "QU" questions.
|
||||
*/
|
||||
void otMdnsSetQuestionUnicastAllowed(otInstance *aInstance, bool aAllow);
|
||||
|
||||
/**
|
||||
* Indicates whether mDNS module is allowed to send "QU" questions requesting unicast response.
|
||||
*
|
||||
* @retval TRUE The mDNS module is allowed to send "QU" questions.
|
||||
* @retval FALSE The mDNS module is not allowed to send "QU" questions.
|
||||
*/
|
||||
bool otMdnsIsQuestionUnicastAllowed(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the post-registration conflict callback.
|
||||
*
|
||||
* If a conflict is detected while registering an entry, it is reported through the provided `otMdnsRegisterCallback`.
|
||||
* The `otMdnsConflictCallback` is used only when a name conflict is detected after an entry has been successfully
|
||||
* registered.
|
||||
*
|
||||
* @p aCallback can be set to `NULL` if not needed. Subsequent calls will replace any previously set callback.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aCallback The conflict callback.
|
||||
*/
|
||||
void otMdnsSetConflictCallback(otInstance *aInstance, otMdnsConflictCallback aCallback);
|
||||
|
||||
/**
|
||||
* Registers or updates a host on mDNS.
|
||||
*
|
||||
* The fields in @p aHost follow these rules:
|
||||
*
|
||||
* - The `mHostName` field specifies the host name to register (e.g., "myhost"). MUST NOT contain the domain name.
|
||||
* - The `mAddresses` is array of IPv6 addresses to register with the host. `mAddressesLength` provides the number of
|
||||
* entries in `mAddresses` array.
|
||||
* - The `mAddresses` array can be empty with zero `mAddressesLength`. In this case, mDNS will treat it as if host is
|
||||
* unregistered and stops advertising any addresses for this the host name.
|
||||
* - The `mTtl` specifies the TTL if non-zero. If zero, the mDNS core will choose the default TTL of 120 seconds.
|
||||
* - Other fields in @p aHost structure are ignored in an `otMdnsRegisterHost()` call.
|
||||
*
|
||||
* This function can be called again for the same `mHostName` to update a previously registered host entry, for example,
|
||||
* to change the list of addresses of the host. In this case, the mDNS module will send "goodbye" announcements for any
|
||||
* previously registered and now removed addresses and announce any newly added addresses.
|
||||
*
|
||||
* The outcome of the registration request is reported back by invoking the provided @p aCallback with @p aRequestId
|
||||
* as its input and one of the following `aError` inputs:
|
||||
*
|
||||
* - `OT_ERROR_NONE` indicates registration was successful.
|
||||
* - `OT_ERROR_DULICATED` indicates a name conflict while probing, i.e., name is claimed by another mDNS responder.
|
||||
*
|
||||
* For caller convenience, the OpenThread mDNS module guarantees that the callback will be invoked after this function
|
||||
* returns, even in cases of immediate registration success. The @p aCallback can be `NULL` if caller does not want to
|
||||
* be notified of the outcome.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aHost Information about the host to register.
|
||||
* @param[in] aRequestId The ID associated with this request.
|
||||
* @param[in] aCallback The callback function pointer to report the outcome (can be NULL if not needed).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started registration. @p aCallback will report the outcome.
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
*/
|
||||
otError otMdnsRegisterHost(otInstance *aInstance,
|
||||
const otMdnsHost *aHost,
|
||||
otMdnsRequestId aRequestId,
|
||||
otMdnsRegisterCallback aCallback);
|
||||
|
||||
/**
|
||||
* Unregisters a host on mDNS.
|
||||
*
|
||||
* The fields in @p aHost follow these rules:
|
||||
*
|
||||
* - The `mHostName` field specifies the host name to unregister (e.g., "myhost"). MUST NOT contain the domain name.
|
||||
* - Other fields in @p aHost structure are ignored in an `otMdnsUnregisterHost()` call.
|
||||
*
|
||||
* If there is no previously registered host with the same name, no action is performed.
|
||||
*
|
||||
* If there is a previously registered host with the same name, the mDNS module will send "goodbye" announcement for
|
||||
* all previously advertised address records.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aHost Information about the host to unregister.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully unregistered host.
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
*/
|
||||
otError otMdnsUnregisterHost(otInstance *aInstance, const otMdnsHost *aHost);
|
||||
|
||||
/**
|
||||
* Registers or updates a service on mDNS.
|
||||
*
|
||||
* The fields in @p aService follow these rules:
|
||||
*
|
||||
* - The `mServiceInstance` specifies the service instance label. It is treated as a single DNS name label. It may
|
||||
* contain dot `.` character which is allowed in a service instance label.
|
||||
* - The `mServiceType` specifies the service type (e.g., "_tst._udp"). It is treated as multiple dot `.` separated
|
||||
* labels. It MUST NOT contain the domain name.
|
||||
* - The `mHostName` field specifies the host name of the service. MUST NOT contain the domain name.
|
||||
* - The `mSubTypeLabels` is an array of strings representing sub-types associated with the service. Each array entry
|
||||
* is a sub-type label. The `mSubTypeLabels can be NULL if there is no sub-type. Otherwise, the array length is
|
||||
* specified by `mSubTypeLabelsLength`.
|
||||
* - The `mTxtData` and `mTxtDataLength` specify the encoded TXT data. The `mTxtData` can be NULL or `mTxtDataLength`
|
||||
* can be zero to specify an empty TXT data. In this case mDNS module will use a single zero byte `[ 0 ]` as the
|
||||
* TXT data.
|
||||
* - The `mPort`, `mWeight`, and `mPriority` specify the service's parameters as specified in DNS SRV record.
|
||||
* - The `mTtl` specifies the TTL if non-zero. If zero, the mDNS module will use the default TTL of 120 seconds.
|
||||
* - Other fields in @p aService structure are ignored in an `otMdnsRegisterService()` call.
|
||||
*
|
||||
* This function can be called again for the same `mServiceInstance` and `mServiceType` to update a previously
|
||||
* registered service entry, for example, to change the sub-types list, or update any parameter such as port, weight,
|
||||
* priority, TTL, or host name. The mDNS module will send announcements for any changed info, e.g., will send "goodbye"
|
||||
* announcements for any removed sub-types and announce any newly added sub-types.
|
||||
*
|
||||
* Regarding the invocation of the @p aCallback, this function behaves in the same way as described in
|
||||
* `otMdnsRegisterHost()`.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aService Information about the service to register.
|
||||
* @param[in] aRequestId The ID associated with this request.
|
||||
* @param[in] aCallback The callback function pointer to report the outcome (can be NULL if not needed).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started registration. @p aCallback will report the outcome.
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
*/
|
||||
otError otMdnsRegisterService(otInstance *aInstance,
|
||||
const otMdnsService *aService,
|
||||
otMdnsRequestId aRequestId,
|
||||
otMdnsRegisterCallback aCallback);
|
||||
|
||||
/**
|
||||
* Unregisters a service on mDNS module.
|
||||
*
|
||||
* The fields in @p aService follow these rules:
|
||||
|
||||
* - The `mServiceInstance` specifies the service instance label. It is treated as a single DNS name label. It may
|
||||
* contain dot `.` character which is allowed in a service instance label.
|
||||
* - The `mServiceType` specifies the service type (e.g., "_tst._udp"). It is treated as multiple dot `.` separated
|
||||
* labels. It MUST NOT contain the domain name.
|
||||
* - Other fields in @p aService structure are ignored in an `otMdnsUnregisterService()` call.
|
||||
*
|
||||
* If there is no previously registered service with the same name, no action is performed.
|
||||
*
|
||||
* If there is a previously registered service with the same name, the mDNS module will send "goodbye" announcements
|
||||
* for all related records.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aService Information about the service to unregister.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully unregistered service.
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
*/
|
||||
otError otMdnsUnregisterService(otInstance *aInstance, const otMdnsService *aService);
|
||||
|
||||
/**
|
||||
* Registers or updates a key record on mDNS module.
|
||||
*
|
||||
* The fields in @p aKey follow these rules:
|
||||
*
|
||||
* - If the key is associated with a host entry, the `mName` field specifies the host name and the `mServiceType` MUST
|
||||
* be NULL.
|
||||
* - If the key is associated with a service entry, the `mName` filed specifies the service instance label (always
|
||||
* treated as a single label) and the `mServiceType` filed specifies the service type (e.g., "_tst._udp"). In this
|
||||
* case the DNS name for key record is `<mName>.<mServiceTye>`.
|
||||
* - The `mKeyData` field contains the key record's data with `mKeyDataLength` as its length in byes.
|
||||
* - The `mTtl` specifies the TTL if non-zero. If zero, the mDNS module will use the default TTL of 120 seconds.
|
||||
* - Other fields in @p aKey structure are ignored in an `otMdnsRegisterKey()` call.
|
||||
*
|
||||
* This function can be called again for the same name to updated a previously registered key entry, for example, to
|
||||
* change the key data or TTL.
|
||||
*
|
||||
* Regarding the invocation of the @p aCallback, this function behaves in the same way as described in
|
||||
* `otMdnsRegisterHost()`.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aKey Information about the key record to register.
|
||||
* @param[in] aRequestId The ID associated with this request.
|
||||
* @param[in] aCallback The callback function pointer to report the outcome (can be NULL if not needed).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started registration. @p aCallback will report the outcome.
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
*/
|
||||
otError otMdnsRegisterKey(otInstance *aInstance,
|
||||
const otMdnsKey *aKey,
|
||||
otMdnsRequestId aRequestId,
|
||||
otMdnsRegisterCallback aCallback);
|
||||
|
||||
/**
|
||||
* Unregisters a key record on mDNS.
|
||||
*
|
||||
* The fields in @p aKey follow these rules:
|
||||
*
|
||||
* - If the key is associated with a host entry, the `mName` field specifies the host name and the `mServiceType` MUST
|
||||
* be NULL.
|
||||
* - If the key is associated with a service entry, the `mName` filed specifies the service instance label (always
|
||||
* treated as a single label) and the `mServiceType` filed specifies the service type (e.g., "_tst._udp"). In this
|
||||
* case the DNS name for key record is `<mName>.<mServiceTye>`.
|
||||
* - Other fields in @p aKey structure are ignored in an `otMdnsUnregisterKey()` call.
|
||||
*
|
||||
* If there is no previously registered key with the same name, no action is performed.
|
||||
*
|
||||
* If there is a previously registered key with the same name, the mDNS module will send "goodbye" announcements for
|
||||
* the key record.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aKey Information about the key to unregister.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully unregistered key
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
*/
|
||||
otError otMdnsUnregisterKey(otInstance *aInstance, const otMdnsKey *aKey);
|
||||
|
||||
/**
|
||||
* Allocates a new iterator.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_MULTICAST_DNS_ENTRY_ITERATION_API_ENABLE`.
|
||||
*
|
||||
* An allocated iterator must be freed by the caller using `otMdnsFreeIterator()`.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the allocated iterator, or `NULL` if it fails to allocate.
|
||||
*/
|
||||
otMdnsIterator *otMdnsAllocateIterator(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Frees a previously allocated iterator.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_MULTICAST_DNS_ENTRY_ITERATION_API_ENABLE`.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aIterator The iterator to free.
|
||||
*/
|
||||
void otMdnsFreeIterator(otInstance *aInstance, otMdnsIterator *aIterator);
|
||||
|
||||
/**
|
||||
* Iterates over registered host entries.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_MULTICAST_DNS_ENTRY_ITERATION_API_ENABLE`.
|
||||
*
|
||||
* On success, @p aHost is populated with information about the next host. Pointers within the `otMdnsHost` structure
|
||||
* (like `mName`) remain valid until the next call to any OpenThread stack's public or platform API/callback.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aIterator Pointer to the iterator.
|
||||
* @param[out] aHost Pointer to an `otMdnsHost` to return the information about the next host entry.
|
||||
* @param[out] aState Pointer to an `otMdnsEntryState` to return the entry state.
|
||||
*
|
||||
* @retval OT_ERROR_NONE @p aHost, @p aState, & @p aIterator are updated successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND Reached the end of the list.
|
||||
* @retval OT_ERROR_INVALID_ARG @p aIterator is not valid.
|
||||
*/
|
||||
otError otMdnsGetNextHost(otInstance *aInstance,
|
||||
otMdnsIterator *aIterator,
|
||||
otMdnsHost *aHost,
|
||||
otMdnsEntryState *aState);
|
||||
|
||||
/**
|
||||
* Iterates over registered service entries.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_MULTICAST_DNS_ENTRY_ITERATION_API_ENABLE`.
|
||||
*
|
||||
* On success, @p aService is populated with information about the next service . Pointers within the `otMdnsService`
|
||||
* structure (like `mServiceType`, `mSubTypeLabels`) remain valid until the next call to any OpenThread stack's public
|
||||
* or platform API/callback.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aIterator Pointer to the iterator to use.
|
||||
* @param[out] aService Pointer to an `otMdnsService` to return the information about the next service entry.
|
||||
* @param[out] aState Pointer to an `otMdnsEntryState` to return the entry state.
|
||||
*
|
||||
* @retval OT_ERROR_NONE @p aService, @p aState, & @p aIterator are updated successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND Reached the end of the list.
|
||||
* @retval OT_ERROR_INVALID_ARG @p aIterator is not valid.
|
||||
*/
|
||||
otError otMdnsGetNextService(otInstance *aInstance,
|
||||
otMdnsIterator *aIterator,
|
||||
otMdnsService *aService,
|
||||
otMdnsEntryState *aState);
|
||||
|
||||
/**
|
||||
* Iterates over registered key entries.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_MULTICAST_DNS_ENTRY_ITERATION_API_ENABLE`.
|
||||
*
|
||||
* On success, @p aKey is populated with information about the next key. Pointers within the `otMdnsKey` structure
|
||||
* (like `mName`) remain valid until the next call to any OpenThread stack's public or platform API/callback.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aIterator Pointer to the iterator to use.
|
||||
* @param[out] aKey Pointer to an `otMdnsKey` to return the information about the next key entry.
|
||||
* @param[out] aState Pointer to an `otMdnsEntryState` to return the entry state.
|
||||
*
|
||||
* @retval OT_ERROR_NONE @p aKey, @p aState, & @p aIterator are updated successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND Reached the end of the list.
|
||||
* @retval OT_ERROR_INVALID_ARG Iterator is not valid.
|
||||
*/
|
||||
otError otMdnsGetNextKey(otInstance *aInstance, otMdnsIterator *aIterator, otMdnsKey *aKey, otMdnsEntryState *aState);
|
||||
|
||||
/**
|
||||
* Represents a service browser.
|
||||
*
|
||||
* Refer to `otPlatDnssdBrowser` for documentation of member fields and `otMdnsStartBrowser()` for how they are used.
|
||||
*/
|
||||
typedef otPlatDnssdBrowser otMdnsBrowser;
|
||||
|
||||
/**
|
||||
* Represents the callback function pointer type used to report a browse result.
|
||||
*/
|
||||
typedef otPlatDnssdBrowseCallback otMdnsBrowseCallback;
|
||||
|
||||
/**
|
||||
* Represents a browse result.
|
||||
*/
|
||||
typedef otPlatDnssdBrowseResult otMdnsBrowseResult;
|
||||
|
||||
/**
|
||||
* Represents an SRV service resolver.
|
||||
*
|
||||
* Refer to `otPlatDnssdSrvResolver` for documentation of member fields and `otMdnsStartSrvResolver()` for how they are
|
||||
* used.
|
||||
*/
|
||||
typedef otPlatDnssdSrvResolver otMdnsSrvResolver;
|
||||
|
||||
/**
|
||||
* Represents the callback function pointer type used to report an SRV resolve result.
|
||||
*/
|
||||
typedef otPlatDnssdSrvCallback otMdnsSrvCallback;
|
||||
|
||||
/**
|
||||
* Represents an SRV resolver result.
|
||||
*/
|
||||
typedef otPlatDnssdSrvResult otMdnsSrvResult;
|
||||
|
||||
/**
|
||||
* Represents a TXT service resolver.
|
||||
*
|
||||
* Refer to `otPlatDnssdTxtResolver` for documentation of member fields and `otMdnsStartTxtResolver()` for how they are
|
||||
* used.
|
||||
*/
|
||||
typedef otPlatDnssdTxtResolver otMdnsTxtResolver;
|
||||
|
||||
/**
|
||||
* Represents the callback function pointer type used to report a TXT resolve result.
|
||||
*/
|
||||
typedef otPlatDnssdTxtCallback otMdnsTxtCallback;
|
||||
|
||||
/**
|
||||
* Represents a TXT resolver result.
|
||||
*/
|
||||
typedef otPlatDnssdTxtResult otMdnsTxtResult;
|
||||
|
||||
/**
|
||||
* Represents an address resolver.
|
||||
*
|
||||
* Refer to `otPlatDnssdAddressResolver` for documentation of member fields and `otMdnsStartIp6AddressResolver()` or
|
||||
* `otMdnsStartIp4AddressResolver()` for how they are used.
|
||||
*/
|
||||
typedef otPlatDnssdAddressResolver otMdnsAddressResolver;
|
||||
|
||||
/**
|
||||
* Represents the callback function pointer type use to report an IPv6/IPv4 address resolve result.
|
||||
*/
|
||||
typedef otPlatDnssdAddressCallback otMdnsAddressCallback;
|
||||
|
||||
/**
|
||||
* Represents a discovered host address and its TTL.
|
||||
*/
|
||||
typedef otPlatDnssdAddressAndTtl otMdnsAddressAndTtl;
|
||||
|
||||
/**
|
||||
* Represents address resolver result.
|
||||
*/
|
||||
typedef otPlatDnssdAddressResult otMdnsAddressResult;
|
||||
|
||||
/**
|
||||
* Starts a service browser.
|
||||
*
|
||||
* Initiates a continuous search for the specified `mServiceType` in @p aBrowser. For sub-type services, use
|
||||
* `mSubTypeLabel` to define the sub-type, for base services, set `mSubTypeLabel` to NULL.
|
||||
*
|
||||
* Discovered services are reported through the `mCallback` function in @p aBrowser. Services that have been removed
|
||||
* are reported with a TTL value of zero. The callback may be invoked immediately with cached information (if available)
|
||||
* and potentially before this function returns. When cached results are used, the reported TTL value will reflect
|
||||
* the original TTL from the last received response.
|
||||
*
|
||||
* Multiple browsers can be started for the same service, provided they use different callback functions.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aBrowser The browser to be started.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Browser started successfully.
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
* @retval OT_ERROR_ALREADY An identical browser (same service and callback) is already active.
|
||||
*/
|
||||
otError otMdnsStartBrowser(otInstance *aInstance, const otMdnsBrowser *aBrowser);
|
||||
|
||||
/**
|
||||
* Stops a service browser.
|
||||
*
|
||||
* No action is performed if no matching browser with the same service and callback is currently active.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aBrowser The browser to stop.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Browser stopped successfully.
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
*/
|
||||
otError otMdnsStopBrowser(otInstance *aInstance, const otMdnsBrowser *aBroswer);
|
||||
|
||||
/**
|
||||
* Starts an SRV record resolver.
|
||||
*
|
||||
* Initiates a continuous SRV record resolver for the specified service in @p aResolver.
|
||||
*
|
||||
* Discovered information is reported through the `mCallback` function in @p aResolver. When the service is removed
|
||||
* it is reported with a TTL value of zero. In this case, `mHostName` may be NULL and other result fields (such as
|
||||
* `mPort`) should be ignored.
|
||||
*
|
||||
* The callback may be invoked immediately with cached information (if available) and potentially before this function
|
||||
* returns. When cached result is used, the reported TTL value will reflect the original TTL from the last received
|
||||
* response.
|
||||
*
|
||||
* Multiple resolvers can be started for the same service, provided they use different callback functions.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to be started.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Resolver started successfully.
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
* @retval OT_ERROR_ALREADY An identical resolver (same service and callback) is already active.
|
||||
*/
|
||||
otError otMdnsStartSrvResolver(otInstance *aInstance, const otMdnsSrvResolver *aResolver);
|
||||
|
||||
/**
|
||||
* Stops an SRV record resolver.
|
||||
*
|
||||
* No action is performed if no matching resolver with the same service and callback is currently active.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to stop.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Resolver stopped successfully.
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
*/
|
||||
otError otMdnsStopSrvResolver(otInstance *aInstance, const otMdnsSrvResolver *aResolver);
|
||||
|
||||
/**
|
||||
* Starts a TXT record resolver.
|
||||
*
|
||||
* Initiates a continuous TXT record resolver for the specified service in @p aResolver.
|
||||
*
|
||||
* Discovered information is reported through the `mCallback` function in @p aResolver. When the TXT record is removed
|
||||
* it is reported with a TTL value of zero. In this case, `mTxtData` may be NULL, and other result fields (such as
|
||||
* `mTxtDataLength`) should be ignored.
|
||||
*
|
||||
* The callback may be invoked immediately with cached information (if available) and potentially before this function
|
||||
* returns. When cached result is used, the reported TTL value will reflect the original TTL from the last received
|
||||
* response.
|
||||
*
|
||||
* Multiple resolvers can be started for the same service, provided they use different callback functions.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to be started.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Resolver started successfully.
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
* @retval OT_ERROR_ALREADY An identical resolver (same service and callback) is already active.
|
||||
*/
|
||||
otError otMdnsStartTxtResolver(otInstance *aInstance, const otMdnsTxtResolver *aResolver);
|
||||
|
||||
/**
|
||||
* Stops a TXT record resolver.
|
||||
*
|
||||
* No action is performed if no matching resolver with the same service and callback is currently active.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to stop.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Resolver stopped successfully.
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
*/
|
||||
otError otMdnsStopTxtResolver(otInstance *aInstance, const otMdnsTxtResolver *aResolver);
|
||||
|
||||
/**
|
||||
* Starts an IPv6 address resolver.
|
||||
*
|
||||
* Initiates a continuous IPv6 address resolver for the specified host name in @p aResolver.
|
||||
*
|
||||
* Discovered addresses are reported through the `mCallback` function in @p aResolver. The callback is invoked
|
||||
* whenever addresses are added or removed, providing an updated list. If all addresses are removed, the callback is
|
||||
* invoked with an empty list (`mAddresses` will be NULL, and `mAddressesLength` will be zero).
|
||||
*
|
||||
* The callback may be invoked immediately with cached information (if available) and potentially before this function
|
||||
* returns. When cached result is used, the reported TTL values will reflect the original TTL from the last received
|
||||
* response.
|
||||
*
|
||||
* Multiple resolvers can be started for the same host name, provided they use different callback functions.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to be started.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Resolver started successfully.
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
* @retval OT_ERROR_ALREADY An identical resolver (same host and callback) is already active.
|
||||
*/
|
||||
otError otMdnsStartIp6AddressResolver(otInstance *aInstance, const otMdnsAddressResolver *aResolver);
|
||||
|
||||
/**
|
||||
* Stops an IPv6 address resolver.
|
||||
*
|
||||
* No action is performed if no matching resolver with the same host name and callback is currently active.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to stop.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Resolver stopped successfully.
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
*/
|
||||
otError otMdnsStopIp6AddressResolver(otInstance *aInstance, const otMdnsAddressResolver *aResolver);
|
||||
|
||||
/**
|
||||
* Starts an IPv4 address resolver.
|
||||
*
|
||||
* Initiates a continuous IPv4 address resolver for the specified host name in @p aResolver.
|
||||
*
|
||||
* Discovered addresses are reported through the `mCallback` function in @p aResolver. The IPv4 addresses are
|
||||
* represented using the IPv4-mapped IPv6 address format in `mAddresses` array. The callback is invoked whenever
|
||||
* addresses are added or removed, providing an updated list. If all addresses are removed, the callback is invoked
|
||||
* with an empty list (`mAddresses` will be NULL, and `mAddressesLength` will be zero).
|
||||
*
|
||||
* The callback may be invoked immediately with cached information (if available) and potentially before this function
|
||||
* returns. When cached result is used, the reported TTL values will reflect the original TTL from the last received
|
||||
* response.
|
||||
*
|
||||
* Multiple resolvers can be started for the same host name, provided they use different callback functions.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to be started.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Resolver started successfully.
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
* @retval OT_ERROR_ALREADY An identical resolver (same host and callback) is already active.
|
||||
*/
|
||||
otError otMdnsStartIp4AddressResolver(otInstance *aInstance, const otMdnsAddressResolver *aResolver);
|
||||
|
||||
/**
|
||||
* Stops an IPv4 address resolver.
|
||||
*
|
||||
* No action is performed if no matching resolver with the same host name and callback is currently active.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to stop.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Resolver stopped successfully.
|
||||
* @retval OT_ERROR_INVALID_STATE mDNS module is not enabled.
|
||||
*/
|
||||
otError otMdnsStopIp4AddressResolver(otInstance *aInstance, const otMdnsAddressResolver *aResolver);
|
||||
|
||||
/**
|
||||
* Represents additional information about a browser/resolver and its cached results.
|
||||
*/
|
||||
typedef struct otMdnsCacheInfo
|
||||
{
|
||||
bool mIsActive; ///< Whether this is an active browser/resolver vs an opportunistic cached one.
|
||||
bool mHasCachedResults; ///< Whether there is any cached results.
|
||||
} otMdnsCacheInfo;
|
||||
|
||||
/**
|
||||
* Iterates over browsers.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_MULTICAST_DNS_ENTRY_ITERATION_API_ENABLE`.
|
||||
*
|
||||
* On success, @p aBrowser is populated with information about the next browser. The `mCallback` field is always
|
||||
* set to `NULL` as there may be multiple active browsers with different callbacks. Other pointers within the
|
||||
* `otMdnsBrowser` structure remain valid until the next call to any OpenThread stack's public or platform API/callback.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aIterator Pointer to the iterator.
|
||||
* @param[out] aBrowser Pointer to an `otMdnsBrowser` to return the information about the next browser.
|
||||
* @param[out] aInfo Pointer to an `otMdnsCacheInfo` to return additional information.
|
||||
*
|
||||
* @retval OT_ERROR_NONE @p aBrowser, @p aInfo, & @p aIterator are updated successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND Reached the end of the list.
|
||||
* @retval OT_ERROR_INVALID_ARG @p aIterator is not valid.
|
||||
*/
|
||||
otError otMdnsGetNextBrowser(otInstance *aInstance,
|
||||
otMdnsIterator *aIterator,
|
||||
otMdnsBrowser *aBrowser,
|
||||
otMdnsCacheInfo *aInfo);
|
||||
|
||||
/**
|
||||
* Iterates over SRV resolvers.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_MULTICAST_DNS_ENTRY_ITERATION_API_ENABLE`.
|
||||
*
|
||||
* On success, @p aResolver is populated with information about the next resolver. The `mCallback` field is always
|
||||
* set to `NULL` as there may be multiple active resolvers with different callbacks. Other pointers within the
|
||||
* `otMdnsSrvResolver` structure remain valid until the next call to any OpenThread stack's public or platform
|
||||
* API/callback.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aIterator Pointer to the iterator.
|
||||
* @param[out] aResolver Pointer to an `otMdnsSrvResolver` to return the information about the next resolver.
|
||||
* @param[out] aInfo Pointer to an `otMdnsCacheInfo` to return additional information.
|
||||
*
|
||||
* @retval OT_ERROR_NONE @p aResolver, @p aInfo, & @p aIterator are updated successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND Reached the end of the list.
|
||||
* @retval OT_ERROR_INVALID_ARG @p aIterator is not valid.
|
||||
*/
|
||||
otError otMdnsGetNextSrvResolver(otInstance *aInstance,
|
||||
otMdnsIterator *aIterator,
|
||||
otMdnsSrvResolver *aResolver,
|
||||
otMdnsCacheInfo *aInfo);
|
||||
|
||||
/**
|
||||
* Iterates over TXT resolvers.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_MULTICAST_DNS_ENTRY_ITERATION_API_ENABLE`.
|
||||
*
|
||||
* On success, @p aResolver is populated with information about the next resolver. The `mCallback` field is always
|
||||
* set to `NULL` as there may be multiple active resolvers with different callbacks. Other pointers within the
|
||||
* `otMdnsTxtResolver` structure remain valid until the next call to any OpenThread stack's public or platform
|
||||
* API/callback.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aIterator Pointer to the iterator.
|
||||
* @param[out] aResolver Pointer to an `otMdnsTxtResolver` to return the information about the next resolver.
|
||||
* @param[out] aInfo Pointer to an `otMdnsCacheInfo` to return additional information.
|
||||
*
|
||||
* @retval OT_ERROR_NONE @p aResolver, @p aInfo, & @p aIterator are updated successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND Reached the end of the list.
|
||||
* @retval OT_ERROR_INVALID_ARG @p aIterator is not valid.
|
||||
*/
|
||||
otError otMdnsGetNextTxtResolver(otInstance *aInstance,
|
||||
otMdnsIterator *aIterator,
|
||||
otMdnsTxtResolver *aResolver,
|
||||
otMdnsCacheInfo *aInfo);
|
||||
|
||||
/**
|
||||
* Iterates over IPv6 address resolvers.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_MULTICAST_DNS_ENTRY_ITERATION_API_ENABLE`.
|
||||
*
|
||||
* On success, @p aResolver is populated with information about the next resolver. The `mCallback` field is always
|
||||
* set to `NULL` as there may be multiple active resolvers with different callbacks. Other pointers within the
|
||||
* `otMdnsAddressResolver` structure remain valid until the next call to any OpenThread stack's public or platform
|
||||
* API/callback.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aIterator Pointer to the iterator.
|
||||
* @param[out] aResolver Pointer to an `otMdnsAddressResolver` to return the information about the next resolver.
|
||||
* @param[out] aInfo Pointer to an `otMdnsCacheInfo` to return additional information.
|
||||
*
|
||||
* @retval OT_ERROR_NONE @p aResolver, @p aInfo, & @p aIterator are updated successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND Reached the end of the list.
|
||||
* @retval OT_ERROR_INVALID_ARG @p aIterator is not valid.
|
||||
*/
|
||||
otError otMdnsGetNextIp6AddressResolver(otInstance *aInstance,
|
||||
otMdnsIterator *aIterator,
|
||||
otMdnsAddressResolver *aResolver,
|
||||
otMdnsCacheInfo *aInfo);
|
||||
|
||||
/**
|
||||
* Iterates over IPv4 address resolvers.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_MULTICAST_DNS_ENTRY_ITERATION_API_ENABLE`.
|
||||
*
|
||||
* On success, @p aResolver is populated with information about the next resolver. The `mCallback` field is always
|
||||
* set to `NULL` as there may be multiple active resolvers with different callbacks. Other pointers within the
|
||||
* `otMdnsAddressResolver` structure remain valid until the next call to any OpenThread stack's public or platform
|
||||
* API/callback.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aIterator Pointer to the iterator.
|
||||
* @param[out] aResolver Pointer to an `otMdnsAddressResolver` to return the information about the next resolver.
|
||||
* @param[out] aInfo Pointer to an `otMdnsCacheInfo` to return additional information.
|
||||
*
|
||||
* @retval OT_ERROR_NONE @p aResolver, @p aInfo, & @p aIterator are updated successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND Reached the end of the list.
|
||||
* @retval OT_ERROR_INVALID_ARG @p aIterator is not valid.
|
||||
*/
|
||||
otError otMdnsGetNextIp4AddressResolver(otInstance *aInstance,
|
||||
otMdnsIterator *aIterator,
|
||||
otMdnsAddressResolver *aResolver,
|
||||
otMdnsCacheInfo *aInfo);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_MULTICAST_DNS_H_
|
||||
392
Libs/util/third_party/openthread/include/openthread/mesh_diag.h
vendored
Normal file
392
Libs/util/third_party/openthread/include/openthread/mesh_diag.h
vendored
Normal file
@@ -0,0 +1,392 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Mesh Diagnostic APIs.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_MESH_DIAG_H_
|
||||
#define OPENTHREAD_MESH_DIAG_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/thread.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-mesh-diag
|
||||
*
|
||||
* @brief
|
||||
* This module includes definitions and functions for Mesh Diagnostics.
|
||||
*
|
||||
* The Mesh Diagnostics APIs require `OPENTHREAD_CONFIG_MESH_DIAG_ENABLE` and `OPENTHREAD_FTD`.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents the set of configurations used when discovering mesh topology indicating which items to
|
||||
* discover.
|
||||
*/
|
||||
typedef struct otMeshDiagDiscoverConfig
|
||||
{
|
||||
bool mDiscoverIp6Addresses : 1; ///< Whether or not to discover IPv6 addresses of every router.
|
||||
bool mDiscoverChildTable : 1; ///< Whether or not to discover children of every router.
|
||||
} otMeshDiagDiscoverConfig;
|
||||
|
||||
/**
|
||||
* An opaque iterator to iterate over list of IPv6 addresses of a router.
|
||||
*
|
||||
* Pointers to instance of this type are provided in `otMeshDiagRouterInfo`.
|
||||
*/
|
||||
typedef struct otMeshDiagIp6AddrIterator otMeshDiagIp6AddrIterator;
|
||||
|
||||
/**
|
||||
* An opaque iterator to iterate over list of children of a router.
|
||||
*
|
||||
* Pointers to instance of this type are provided in `otMeshDiagRouterInfo`.
|
||||
*/
|
||||
typedef struct otMeshDiagChildIterator otMeshDiagChildIterator;
|
||||
|
||||
/**
|
||||
* Specifies that Thread Version is unknown.
|
||||
*
|
||||
* This is used in `otMeshDiagRouterInfo` for `mVersion` property when device does not provide its version. This
|
||||
* indicates that device is likely running 1.3.0 (version value 4) or earlier.
|
||||
*/
|
||||
#define OT_MESH_DIAG_VERSION_UNKNOWN 0xffff
|
||||
|
||||
/**
|
||||
* Represents information about a router in Thread mesh discovered using `otMeshDiagDiscoverTopology()`.
|
||||
*/
|
||||
typedef struct otMeshDiagRouterInfo
|
||||
{
|
||||
otExtAddress mExtAddress; ///< Extended MAC address.
|
||||
uint16_t mRloc16; ///< RLOC16.
|
||||
uint8_t mRouterId; ///< Router ID.
|
||||
uint16_t mVersion; ///< Thread Version. `OT_MESH_DIAG_VERSION_UNKNOWN` if unknown.
|
||||
bool mIsThisDevice : 1; ///< Whether router is this device itself.
|
||||
bool mIsThisDeviceParent : 1; ///< Whether router is parent of this device (when device is a child).
|
||||
bool mIsLeader : 1; ///< Whether router is leader.
|
||||
bool mIsBorderRouter : 1; ///< Whether router acts as a border router providing ext connectivity.
|
||||
|
||||
/**
|
||||
* Provides the link quality from this router to other routers, also indicating whether a link is established
|
||||
* between the routers.
|
||||
*
|
||||
* The array is indexed based on Router ID. `mLinkQualities[routerId]` indicates the incoming link quality, the
|
||||
* router sees to the router with `routerId`. Link quality is a value in [0, 3]. Value zero indicates no link.
|
||||
* Larger value indicate better link quality (as defined by Thread specification).
|
||||
*/
|
||||
uint8_t mLinkQualities[OT_NETWORK_MAX_ROUTER_ID + 1];
|
||||
|
||||
/**
|
||||
* A pointer to an iterator to go through the list of IPv6 addresses of the router.
|
||||
*
|
||||
* The pointer is valid only while `otMeshDiagRouterInfo` is valid. It can be used in `otMeshDiagGetNextIp6Address`
|
||||
* to iterate through the IPv6 addresses.
|
||||
*
|
||||
* The pointer can be NULL when there was no request to discover IPv6 addresses (in `otMeshDiagDiscoverConfig`) or
|
||||
* if the router did not provide the list.
|
||||
*/
|
||||
otMeshDiagIp6AddrIterator *mIp6AddrIterator;
|
||||
|
||||
/**
|
||||
* A pointer to an iterator to go through the list of children of the router.
|
||||
*
|
||||
* The pointer is valid only while `otMeshDiagRouterInfo` is valid. It can be used in `otMeshDiagGetNextChildInfo`
|
||||
* to iterate through the children of the router.
|
||||
*
|
||||
* The pointer can be NULL when there was no request to discover children (in `otMeshDiagDiscoverConfig`) or
|
||||
* if the router did not provide the list.
|
||||
*/
|
||||
otMeshDiagChildIterator *mChildIterator;
|
||||
} otMeshDiagRouterInfo;
|
||||
|
||||
/**
|
||||
* Represents information about a discovered child in Thread mesh using `otMeshDiagDiscoverTopology()`.
|
||||
*/
|
||||
typedef struct otMeshDiagChildInfo
|
||||
{
|
||||
uint16_t mRloc16; ///< RLOC16.
|
||||
otLinkModeConfig mMode; ///< Device mode.
|
||||
uint8_t mLinkQuality; ///< Incoming link quality to child from parent.
|
||||
bool mIsThisDevice : 1; ///< Whether child is this device itself.
|
||||
bool mIsBorderRouter : 1; ///< Whether child acts as a border router providing ext connectivity.
|
||||
} otMeshDiagChildInfo;
|
||||
|
||||
/**
|
||||
* Pointer type represents the callback used by `otMeshDiagDiscoverTopology()` to provide information
|
||||
* about a discovered router.
|
||||
*
|
||||
* When @p aError is `OT_ERROR_PENDING`, it indicates that the discovery is not yet finished and there will be more
|
||||
* routers to discover and the callback will be invoked again.
|
||||
*
|
||||
* @param[in] aError OT_ERROR_PENDING Indicates there are more routers to be discovered.
|
||||
* OT_ERROR_NONE Indicates this is the last router and mesh discovery is done.
|
||||
* OT_ERROR_RESPONSE_TIMEOUT Timed out waiting for response from one or more routers.
|
||||
* @param[in] aRouterInfo The discovered router info (can be null if `aError` is OT_ERROR_RESPONSE_TIMEOUT).
|
||||
* @param[in] aContext Application-specific context.
|
||||
*/
|
||||
typedef void (*otMeshDiagDiscoverCallback)(otError aError, otMeshDiagRouterInfo *aRouterInfo, void *aContext);
|
||||
|
||||
/**
|
||||
* Starts network topology discovery.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aConfig The configuration to use for discovery (e.g., which items to discover).
|
||||
* @param[in] aCallback The callback to report the discovered routers.
|
||||
* @param[in] aContext A context to pass in @p aCallback.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The network topology discovery started successfully.
|
||||
* @retval OT_ERROR_BUSY A previous discovery request is still ongoing.
|
||||
* @retval OT_ERROR_INVALID_STATE Device is not attached.
|
||||
* @retval OT_ERROR_NO_BUFS Could not allocate buffer to send discovery messages.
|
||||
*/
|
||||
otError otMeshDiagDiscoverTopology(otInstance *aInstance,
|
||||
const otMeshDiagDiscoverConfig *aConfig,
|
||||
otMeshDiagDiscoverCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Cancels an ongoing topology discovery if there is one, otherwise no action.
|
||||
*
|
||||
* When ongoing discovery is cancelled, the callback from `otMeshDiagDiscoverTopology()` will not be called anymore.
|
||||
*/
|
||||
void otMeshDiagCancel(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Iterates through the discovered IPv6 addresses of a router or an MTD child.
|
||||
*
|
||||
* MUST be used
|
||||
* - from the callback `otMeshDiagDiscoverCallback()` and use the `mIp6AddrIterator` from the `aRouterInfo` struct that
|
||||
* is provided as input to the callback, or
|
||||
* - from the callback `otMeshDiagChildIp6AddrsCallback()` along with provided `aIp6AddrIterator`.
|
||||
*
|
||||
* @param[in,out] aIterator The address iterator to use.
|
||||
* @param[out] aIp6Address A pointer to return the next IPv6 address (if any).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the next address. @p aIp6Address and @p aIterator are updated.
|
||||
* @retval OT_ERROR_NOT_FOUND No more address. Reached the end of the list.
|
||||
*/
|
||||
otError otMeshDiagGetNextIp6Address(otMeshDiagIp6AddrIterator *aIterator, otIp6Address *aIp6Address);
|
||||
|
||||
/**
|
||||
* Iterates through the discovered children of a router.
|
||||
*
|
||||
* This function MUST be used from the callback `otMeshDiagDiscoverCallback()` and use the `mChildIterator` from the
|
||||
* `aRouterInfo` struct that is provided as input to the callback.
|
||||
*
|
||||
* @param[in,out] aIterator The address iterator to use.
|
||||
* @param[out] aChildInfo A pointer to return the child info (if any).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the next child. @p aChildInfo and @p aIterator are updated.
|
||||
* @retval OT_ERROR_NOT_FOUND No more child. Reached the end of the list.
|
||||
*/
|
||||
otError otMeshDiagGetNextChildInfo(otMeshDiagChildIterator *aIterator, otMeshDiagChildInfo *aChildInfo);
|
||||
|
||||
/**
|
||||
* Represents information about a child entry from `otMeshDiagQueryChildTable()`.
|
||||
*
|
||||
* `mSupportsErrRate` indicates whether or not the error tracking feature is supported and `mFrameErrorRate` and
|
||||
* `mMessageErrorRate` values are valid. The frame error rate tracks frame tx errors (towards the child) at MAC
|
||||
* layer, while `mMessageErrorRate` tracks the IPv6 message error rate (above MAC layer and after MAC retries) when
|
||||
* an IPv6 message is dropped. For example, if the message is large and requires 6LoWPAN fragmentation, message tx is
|
||||
* considered as failed if one of its fragment frame tx fails (for example, never acked).
|
||||
*/
|
||||
typedef struct otMeshDiagChildEntry
|
||||
{
|
||||
bool mRxOnWhenIdle : 1; ///< Is rx-on when idle (vs sleepy).
|
||||
bool mDeviceTypeFtd : 1; ///< Is device FTD (vs MTD).
|
||||
bool mFullNetData : 1; ///< Whether device gets full Network Data (vs stable sub-set).
|
||||
bool mCslSynchronized : 1; ///< Is CSL capable and CSL synchronized.
|
||||
bool mSupportsErrRate : 1; ///< `mFrameErrorRate` and `mMessageErrorRate` values are valid.
|
||||
uint16_t mRloc16; ///< RLOC16.
|
||||
otExtAddress mExtAddress; ///< Extended Address.
|
||||
uint16_t mVersion; ///< Version.
|
||||
uint32_t mTimeout; ///< Timeout in seconds.
|
||||
uint32_t mAge; ///< Seconds since last heard from the child.
|
||||
uint32_t mConnectionTime; ///< Seconds since child attach.
|
||||
uint16_t mSupervisionInterval; ///< Supervision interval in seconds. Zero to indicate not used.
|
||||
uint8_t mLinkMargin; ///< Link Margin in dB.
|
||||
int8_t mAverageRssi; ///< Average RSSI.
|
||||
int8_t mLastRssi; ///< RSSI of last received frame.
|
||||
uint16_t mFrameErrorRate; ///< Frame error rate (0x0000->0%, 0xffff->100%).
|
||||
uint16_t mMessageErrorRate; ///< (IPv6) msg error rate (0x0000->0%, 0xffff->100%).
|
||||
uint16_t mQueuedMessageCount; ///< Number of queued messages for indirect tx to child.
|
||||
uint16_t mCslPeriod; ///< CSL Period in unit of 10-symbols-time. Zero indicates CSL is disabled.
|
||||
uint32_t mCslTimeout; ///< CSL Timeout in seconds.
|
||||
uint8_t mCslChannel; ///< CSL channel.
|
||||
} otMeshDiagChildEntry;
|
||||
|
||||
/**
|
||||
* Represents the callback used by `otMeshDiagQueryChildTable()` to provide information about child table entries.
|
||||
*
|
||||
* When @p aError is `OT_ERROR_PENDING`, it indicates that the table still has more entries and the callback will be
|
||||
* invoked again.
|
||||
*
|
||||
* @param[in] aError OT_ERROR_PENDING Indicates there are more entries in the table.
|
||||
* OT_ERROR_NONE Indicates the table is finished.
|
||||
* OT_ERROR_RESPONSE_TIMEOUT Timed out waiting for response.
|
||||
* @param[in] aChildEntry The child entry (can be null if `aError` is OT_ERROR_RESPONSE_TIMEOUT or OT_ERROR_NONE).
|
||||
* @param[in] aContext Application-specific context.
|
||||
*/
|
||||
typedef void (*otMeshDiagQueryChildTableCallback)(otError aError,
|
||||
const otMeshDiagChildEntry *aChildEntry,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Starts query for child table for a given router.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aRloc16 The RLOC16 of router to query.
|
||||
* @param[in] aCallback The callback to report the queried child table.
|
||||
* @param[in] aContext A context to pass in @p aCallback.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The query started successfully.
|
||||
* @retval OT_ERROR_BUSY A previous discovery or query request is still ongoing.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aRloc16 is not a valid router RLOC16.
|
||||
* @retval OT_ERROR_INVALID_STATE Device is not attached.
|
||||
* @retval OT_ERROR_NO_BUFS Could not allocate buffer to send query messages.
|
||||
*/
|
||||
otError otMeshDiagQueryChildTable(otInstance *aInstance,
|
||||
uint16_t aRloc16,
|
||||
otMeshDiagQueryChildTableCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Represents the callback used by `otMeshDiagQueryChildrenIp6Addrs()` to provide information about an MTD child and
|
||||
* its list of IPv6 addresses.
|
||||
*
|
||||
* When @p aError is `OT_ERROR_PENDING`, it indicates that there are more children and the callback will be invoked
|
||||
* again.
|
||||
*
|
||||
* @param[in] aError OT_ERROR_PENDING Indicates there are more children in the table.
|
||||
* OT_ERROR_NONE Indicates the table is finished.
|
||||
* OT_ERROR_RESPONSE_TIMEOUT Timed out waiting for response.
|
||||
* @param[in] aChildRloc16 The RLOC16 of the child. `0xfffe` is used on `OT_ERROR_RESPONSE_TIMEOUT`.
|
||||
* @param[in] aIp6AddrIterator An iterator to go through the IPv6 addresses of the child with @p aRloc using
|
||||
* `otMeshDiagGetNextIp6Address()`. Set to NULL on `OT_ERROR_RESPONSE_TIMEOUT`.
|
||||
* @param[in] aContext Application-specific context.
|
||||
*/
|
||||
typedef void (*otMeshDiagChildIp6AddrsCallback)(otError aError,
|
||||
uint16_t aChildRloc16,
|
||||
otMeshDiagIp6AddrIterator *aIp6AddrIterator,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Sends a query to a parent to retrieve the IPv6 addresses of all its MTD children.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aRloc16 The RLOC16 of parent to query.
|
||||
* @param[in] aCallback The callback to report the queried child IPv6 address list.
|
||||
* @param[in] aContext A context to pass in @p aCallback.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The query started successfully.
|
||||
* @retval OT_ERROR_BUSY A previous discovery or query request is still ongoing.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aRloc16 is not a valid RLOC16.
|
||||
* @retval OT_ERROR_INVALID_STATE Device is not attached.
|
||||
* @retval OT_ERROR_NO_BUFS Could not allocate buffer to send query messages.
|
||||
*/
|
||||
otError otMeshDiagQueryChildrenIp6Addrs(otInstance *aInstance,
|
||||
uint16_t aRloc16,
|
||||
otMeshDiagChildIp6AddrsCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Represents information about a router neighbor entry from `otMeshDiagQueryRouterNeighborTable()`.
|
||||
*
|
||||
* `mSupportsErrRate` indicates whether or not the error tracking feature is supported and `mFrameErrorRate` and
|
||||
* `mMessageErrorRate` values are valid. The frame error rate tracks frame tx errors (towards the child) at MAC
|
||||
* layer, while `mMessageErrorRate` tracks the IPv6 message error rate (above MAC layer and after MAC retries) when
|
||||
* an IPv6 message is dropped. For example, if the message is large and requires 6LoWPAN fragmentation, message tx is
|
||||
* considered as failed if one of its fragment frame tx fails (for example, never acked).
|
||||
*/
|
||||
typedef struct otMeshDiagRouterNeighborEntry
|
||||
{
|
||||
bool mSupportsErrRate : 1; ///< `mFrameErrorRate` and `mMessageErrorRate` values are valid.
|
||||
uint16_t mRloc16; ///< RLOC16.
|
||||
otExtAddress mExtAddress; ///< Extended Address.
|
||||
uint16_t mVersion; ///< Version.
|
||||
uint32_t mConnectionTime; ///< Seconds since link establishment.
|
||||
uint8_t mLinkMargin; ///< Link Margin in dB.
|
||||
int8_t mAverageRssi; ///< Average RSSI.
|
||||
int8_t mLastRssi; ///< RSSI of last received frame.
|
||||
uint16_t mFrameErrorRate; ///< Frame error rate (0x0000->0%, 0xffff->100%).
|
||||
uint16_t mMessageErrorRate; ///< (IPv6) msg error rate (0x0000->0%, 0xffff->100%).
|
||||
} otMeshDiagRouterNeighborEntry;
|
||||
|
||||
/**
|
||||
* Represents the callback used by `otMeshDiagQueryRouterNeighborTable()` to provide information about neighbor router
|
||||
* table entries.
|
||||
*
|
||||
* When @p aError is `OT_ERROR_PENDING`, it indicates that the table still has more entries and the callback will be
|
||||
* invoked again.
|
||||
*
|
||||
* @param[in] aError OT_ERROR_PENDING Indicates there are more entries in the table.
|
||||
* OT_ERROR_NONE Indicates the table is finished.
|
||||
* OT_ERROR_RESPONSE_TIMEOUT Timed out waiting for response.
|
||||
* @param[in] aNeighborEntry The neighbor entry (can be null if `aError` is RESPONSE_TIMEOUT or NONE).
|
||||
* @param[in] aContext Application-specific context.
|
||||
*/
|
||||
typedef void (*otMeshDiagQueryRouterNeighborTableCallback)(otError aError,
|
||||
const otMeshDiagRouterNeighborEntry *aNeighborEntry,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Starts query for router neighbor table for a given router.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aRloc16 The RLOC16 of router to query.
|
||||
* @param[in] aCallback The callback to report the queried table.
|
||||
* @param[in] aContext A context to pass in @p aCallback.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The query started successfully.
|
||||
* @retval OT_ERROR_BUSY A previous discovery or query request is still ongoing.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aRloc16 is not a valid router RLOC16.
|
||||
* @retval OT_ERROR_INVALID_STATE Device is not attached.
|
||||
* @retval OT_ERROR_NO_BUFS Could not allocate buffer to send query messages.
|
||||
*/
|
||||
otError otMeshDiagQueryRouterNeighborTable(otInstance *aInstance,
|
||||
uint16_t aRloc16,
|
||||
otMeshDiagQueryRouterNeighborTableCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_MESH_DIAG_H_
|
||||
470
Libs/util/third_party/openthread/include/openthread/message.h
vendored
Normal file
470
Libs/util/third_party/openthread/include/openthread/message.h
vendored
Normal file
@@ -0,0 +1,470 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the top-level OpenThread APIs related to message buffer and queues.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_MESSAGE_H_
|
||||
#define OPENTHREAD_MESSAGE_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/platform/toolchain.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-message
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that manipulate OpenThread message buffers.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* An opaque representation of an OpenThread message buffer.
|
||||
*/
|
||||
typedef struct otMessage otMessage;
|
||||
|
||||
/**
|
||||
* Defines the OpenThread message priority levels.
|
||||
*/
|
||||
typedef enum otMessagePriority
|
||||
{
|
||||
OT_MESSAGE_PRIORITY_LOW = 0, ///< Low priority level.
|
||||
OT_MESSAGE_PRIORITY_NORMAL = 1, ///< Normal priority level.
|
||||
OT_MESSAGE_PRIORITY_HIGH = 2, ///< High priority level.
|
||||
} otMessagePriority;
|
||||
|
||||
/**
|
||||
* Defines the OpenThread message origins.
|
||||
*/
|
||||
typedef enum otMessageOrigin
|
||||
{
|
||||
OT_MESSAGE_ORIGIN_THREAD_NETIF = 0, ///< Message from Thread Netif.
|
||||
OT_MESSAGE_ORIGIN_HOST_TRUSTED = 1, ///< Message from a trusted source on host.
|
||||
OT_MESSAGE_ORIGIN_HOST_UNTRUSTED = 2, ///< Message from an untrusted source on host.
|
||||
} otMessageOrigin;
|
||||
|
||||
/**
|
||||
* Represents a message settings.
|
||||
*/
|
||||
typedef struct otMessageSettings
|
||||
{
|
||||
bool mLinkSecurityEnabled; ///< TRUE if the message should be secured at Layer 2.
|
||||
uint8_t mPriority; ///< Priority level (MUST be a `OT_MESSAGE_PRIORITY_*` from `otMessagePriority`).
|
||||
} otMessageSettings;
|
||||
|
||||
/**
|
||||
* Represents link-specific information for messages received from the Thread radio.
|
||||
*/
|
||||
typedef struct otThreadLinkInfo
|
||||
{
|
||||
uint16_t mPanId; ///< Source PAN ID
|
||||
uint8_t mChannel; ///< 802.15.4 Channel
|
||||
int8_t mRss; ///< Received Signal Strength in dBm (averaged over fragments)
|
||||
uint8_t mLqi; ///< Average Link Quality Indicator (averaged over fragments)
|
||||
bool mLinkSecurity : 1; ///< Indicates whether or not link security is enabled.
|
||||
bool mIsDstPanIdBroadcast : 1; ///< Indicates whether or not destination PAN ID is broadcast.
|
||||
|
||||
// Applicable/Required only when time sync feature (`OPENTHREAD_CONFIG_TIME_SYNC_ENABLE`) is enabled.
|
||||
uint8_t mTimeSyncSeq; ///< The time sync sequence.
|
||||
int64_t mNetworkTimeOffset; ///< The time offset to the Thread network time, in microseconds.
|
||||
|
||||
// Applicable only when OPENTHREAD_CONFIG_MULTI_RADIO feature is enabled.
|
||||
uint8_t mRadioType; ///< Radio link type.
|
||||
} otThreadLinkInfo;
|
||||
|
||||
/**
|
||||
* Free an allocated message buffer.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message buffer.
|
||||
*
|
||||
* @sa otMessageAppend
|
||||
* @sa otMessageGetLength
|
||||
* @sa otMessageSetLength
|
||||
* @sa otMessageGetOffset
|
||||
* @sa otMessageSetOffset
|
||||
* @sa otMessageRead
|
||||
* @sa otMessageWrite
|
||||
*/
|
||||
void otMessageFree(otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Get the message length in bytes.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message buffer.
|
||||
*
|
||||
* @returns The message length in bytes.
|
||||
*
|
||||
* @sa otMessageFree
|
||||
* @sa otMessageAppend
|
||||
* @sa otMessageSetLength
|
||||
* @sa otMessageGetOffset
|
||||
* @sa otMessageSetOffset
|
||||
* @sa otMessageRead
|
||||
* @sa otMessageWrite
|
||||
* @sa otMessageSetLength
|
||||
*/
|
||||
uint16_t otMessageGetLength(const otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Set the message length in bytes.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message buffer.
|
||||
* @param[in] aLength A length in bytes.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the message length.
|
||||
* @retval OT_ERROR_NO_BUFS No available buffers to grow the message.
|
||||
*
|
||||
* @sa otMessageFree
|
||||
* @sa otMessageAppend
|
||||
* @sa otMessageGetLength
|
||||
* @sa otMessageGetOffset
|
||||
* @sa otMessageSetOffset
|
||||
* @sa otMessageRead
|
||||
* @sa otMessageWrite
|
||||
*/
|
||||
otError otMessageSetLength(otMessage *aMessage, uint16_t aLength);
|
||||
|
||||
/**
|
||||
* Get the message offset in bytes.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message buffer.
|
||||
*
|
||||
* @returns The message offset value.
|
||||
*
|
||||
* @sa otMessageFree
|
||||
* @sa otMessageAppend
|
||||
* @sa otMessageGetLength
|
||||
* @sa otMessageSetLength
|
||||
* @sa otMessageSetOffset
|
||||
* @sa otMessageRead
|
||||
* @sa otMessageWrite
|
||||
*/
|
||||
uint16_t otMessageGetOffset(const otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Set the message offset in bytes.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message buffer.
|
||||
* @param[in] aOffset An offset in bytes.
|
||||
*
|
||||
* @sa otMessageFree
|
||||
* @sa otMessageAppend
|
||||
* @sa otMessageGetLength
|
||||
* @sa otMessageSetLength
|
||||
* @sa otMessageGetOffset
|
||||
* @sa otMessageRead
|
||||
* @sa otMessageWrite
|
||||
*/
|
||||
void otMessageSetOffset(otMessage *aMessage, uint16_t aOffset);
|
||||
|
||||
/**
|
||||
* Indicates whether or not link security is enabled for the message.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message buffer.
|
||||
*
|
||||
* @retval TRUE If link security is enabled.
|
||||
* @retval FALSE If link security is not enabled.
|
||||
*/
|
||||
bool otMessageIsLinkSecurityEnabled(const otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the message is allowed to be looped back to host.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message buffer.
|
||||
*
|
||||
* @retval TRUE If the message is allowed to be looped back to host.
|
||||
* @retval FALSE If the message is not allowed to be looped back to host.
|
||||
*/
|
||||
bool otMessageIsLoopbackToHostAllowed(const otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Sets whether or not the message is allowed to be looped back to host.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message buffer.
|
||||
* @param[in] aAllowLoopbackToHost Whether to allow the message to be looped back to host.
|
||||
*/
|
||||
void otMessageSetLoopbackToHostAllowed(otMessage *aMessage, bool aAllowLoopbackToHost);
|
||||
|
||||
/**
|
||||
* Indicates whether the given message may be looped back in a case of a multicast destination address.
|
||||
*
|
||||
* If @p aMessage is used along with an `otMessageInfo`, the `mMulticastLoop` field from `otMessageInfo` structure
|
||||
* takes precedence and will be used instead of the the value set on @p aMessage.
|
||||
*
|
||||
* This API is mainly intended for use along with `otIp6Send()` which expects an already prepared IPv6 message.
|
||||
*
|
||||
* @param[in] aMessage A pointer to the message.
|
||||
*/
|
||||
bool otMessageIsMulticastLoopEnabled(otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Controls whether the given message may be looped back in a case of a multicast destination address.
|
||||
*
|
||||
* @param[in] aMessage A pointer to the message.
|
||||
* @param[in] aEnabled The configuration value.
|
||||
*/
|
||||
void otMessageSetMulticastLoopEnabled(otMessage *aMessage, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Gets the message origin.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message buffer.
|
||||
*
|
||||
* @returns The message origin.
|
||||
*/
|
||||
otMessageOrigin otMessageGetOrigin(const otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Sets the message origin.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message buffer.
|
||||
* @param[in] aOrigin The message origin.
|
||||
*/
|
||||
void otMessageSetOrigin(otMessage *aMessage, otMessageOrigin aOrigin);
|
||||
|
||||
/**
|
||||
* Sets/forces the message to be forwarded using direct transmission.
|
||||
* Default setting for a new message is `false`.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message buffer.
|
||||
* @param[in] aEnabled If `true`, the message is forced to use direct transmission. If `false`, the message follows
|
||||
* the normal procedure.
|
||||
*/
|
||||
void otMessageSetDirectTransmission(otMessage *aMessage, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Returns the average RSS (received signal strength) associated with the message.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message buffer.
|
||||
*
|
||||
* @returns The average RSS value (in dBm) or OT_RADIO_RSSI_INVALID if no average RSS is available.
|
||||
*/
|
||||
int8_t otMessageGetRss(const otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Retrieves the link-specific information for a message received over Thread radio.
|
||||
*
|
||||
* @param[in] aMessage The message from which to retrieve `otThreadLinkInfo`.
|
||||
* @pram[out] aLinkInfo A pointer to an `otThreadLinkInfo` to populate.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the link info, @p `aLinkInfo` is updated.
|
||||
* @retval OT_ERROR_NOT_FOUND Message origin is not `OT_MESSAGE_ORIGIN_THREAD_NETIF`.
|
||||
*/
|
||||
otError otMessageGetThreadLinkInfo(const otMessage *aMessage, otThreadLinkInfo *aLinkInfo);
|
||||
|
||||
/**
|
||||
* Append bytes to a message.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message buffer.
|
||||
* @param[in] aBuf A pointer to the data to append.
|
||||
* @param[in] aLength Number of bytes to append.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully appended to the message
|
||||
* @retval OT_ERROR_NO_BUFS No available buffers to grow the message.
|
||||
*
|
||||
* @sa otMessageFree
|
||||
* @sa otMessageGetLength
|
||||
* @sa otMessageSetLength
|
||||
* @sa otMessageGetOffset
|
||||
* @sa otMessageSetOffset
|
||||
* @sa otMessageRead
|
||||
* @sa otMessageWrite
|
||||
*/
|
||||
otError otMessageAppend(otMessage *aMessage, const void *aBuf, uint16_t aLength);
|
||||
|
||||
/**
|
||||
* Read bytes from a message.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message buffer.
|
||||
* @param[in] aOffset An offset in bytes.
|
||||
* @param[in] aBuf A pointer to a buffer that message bytes are read to.
|
||||
* @param[in] aLength Number of bytes to read.
|
||||
*
|
||||
* @returns The number of bytes read.
|
||||
*
|
||||
* @sa otMessageFree
|
||||
* @sa otMessageAppend
|
||||
* @sa otMessageGetLength
|
||||
* @sa otMessageSetLength
|
||||
* @sa otMessageGetOffset
|
||||
* @sa otMessageSetOffset
|
||||
* @sa otMessageWrite
|
||||
*/
|
||||
uint16_t otMessageRead(const otMessage *aMessage, uint16_t aOffset, void *aBuf, uint16_t aLength);
|
||||
|
||||
/**
|
||||
* Write bytes to a message.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message buffer.
|
||||
* @param[in] aOffset An offset in bytes.
|
||||
* @param[in] aBuf A pointer to a buffer that message bytes are written from.
|
||||
* @param[in] aLength Number of bytes to write.
|
||||
*
|
||||
* @returns The number of bytes written.
|
||||
*
|
||||
* @sa otMessageFree
|
||||
* @sa otMessageAppend
|
||||
* @sa otMessageGetLength
|
||||
* @sa otMessageSetLength
|
||||
* @sa otMessageGetOffset
|
||||
* @sa otMessageSetOffset
|
||||
* @sa otMessageRead
|
||||
*/
|
||||
int otMessageWrite(otMessage *aMessage, uint16_t aOffset, const void *aBuf, uint16_t aLength);
|
||||
|
||||
/**
|
||||
* Represents an OpenThread message queue.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
void *mData; ///< Opaque data used by the implementation.
|
||||
} otMessageQueue;
|
||||
|
||||
/**
|
||||
* Represents information about a message queue.
|
||||
*/
|
||||
typedef struct otMessageQueueInfo
|
||||
{
|
||||
uint16_t mNumMessages; ///< Number of messages in the queue.
|
||||
uint16_t mNumBuffers; ///< Number of data buffers used by messages in the queue.
|
||||
uint32_t mTotalBytes; ///< Total number of bytes used by all messages in the queue.
|
||||
} otMessageQueueInfo;
|
||||
|
||||
/**
|
||||
* Represents the message buffer information for different queues used by OpenThread stack.
|
||||
*/
|
||||
typedef struct otBufferInfo
|
||||
{
|
||||
uint16_t mTotalBuffers; ///< The total number of buffers in the messages pool (0xffff if unknown).
|
||||
uint16_t mFreeBuffers; ///< The number of free buffers (0xffff if unknown).
|
||||
|
||||
/**
|
||||
* The maximum number of used buffers at the same time since OT stack initialization or last call to
|
||||
* `otMessageResetBufferInfo()`.
|
||||
*/
|
||||
uint16_t mMaxUsedBuffers;
|
||||
|
||||
otMessageQueueInfo m6loSendQueue; ///< Info about 6LoWPAN send queue.
|
||||
otMessageQueueInfo m6loReassemblyQueue; ///< Info about 6LoWPAN reassembly queue.
|
||||
otMessageQueueInfo mIp6Queue; ///< Info about IPv6 send queue.
|
||||
otMessageQueueInfo mMplQueue; ///< Info about MPL send queue.
|
||||
otMessageQueueInfo mMleQueue; ///< Info about MLE delayed message queue.
|
||||
otMessageQueueInfo mCoapQueue; ///< Info about CoAP/TMF send queue.
|
||||
otMessageQueueInfo mCoapSecureQueue; ///< Info about CoAP secure send queue.
|
||||
otMessageQueueInfo mApplicationCoapQueue; ///< Info about application CoAP send queue.
|
||||
} otBufferInfo;
|
||||
|
||||
/**
|
||||
* Initialize the message queue.
|
||||
*
|
||||
* MUST be called once and only once for a `otMessageQueue` instance before any other `otMessageQueue`
|
||||
* functions. The behavior is undefined if other queue APIs are used with an `otMessageQueue` before it being
|
||||
* initialized or if it is initialized more than once.
|
||||
*
|
||||
* @param[in] aQueue A pointer to a message queue.
|
||||
*/
|
||||
void otMessageQueueInit(otMessageQueue *aQueue);
|
||||
|
||||
/**
|
||||
* Adds a message to the end of the given message queue.
|
||||
*
|
||||
* @param[in] aQueue A pointer to the message queue.
|
||||
* @param[in] aMessage The message to add.
|
||||
*/
|
||||
void otMessageQueueEnqueue(otMessageQueue *aQueue, otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Adds a message at the head/front of the given message queue.
|
||||
*
|
||||
* @param[in] aQueue A pointer to the message queue.
|
||||
* @param[in] aMessage The message to add.
|
||||
*/
|
||||
void otMessageQueueEnqueueAtHead(otMessageQueue *aQueue, otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Removes a message from the given message queue.
|
||||
*
|
||||
* @param[in] aQueue A pointer to the message queue.
|
||||
* @param[in] aMessage The message to remove.
|
||||
*/
|
||||
void otMessageQueueDequeue(otMessageQueue *aQueue, otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Returns a pointer to the message at the head of the queue.
|
||||
*
|
||||
* @param[in] aQueue A pointer to a message queue.
|
||||
*
|
||||
* @returns A pointer to the message at the head of queue or NULL if queue is empty.
|
||||
*/
|
||||
otMessage *otMessageQueueGetHead(otMessageQueue *aQueue);
|
||||
|
||||
/**
|
||||
* Returns a pointer to the next message in the queue by iterating forward (from head to tail).
|
||||
*
|
||||
* @param[in] aQueue A pointer to a message queue.
|
||||
* @param[in] aMessage A pointer to current message buffer.
|
||||
*
|
||||
* @returns A pointer to the next message in the queue after `aMessage` or NULL if `aMessage is the tail of queue.
|
||||
* NULL is returned if `aMessage` is not in the queue `aQueue`.
|
||||
*/
|
||||
otMessage *otMessageQueueGetNext(otMessageQueue *aQueue, const otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Get the Message Buffer information.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[out] aBufferInfo A pointer where the message buffer information is written.
|
||||
*/
|
||||
void otMessageGetBufferInfo(otInstance *aInstance, otBufferInfo *aBufferInfo);
|
||||
|
||||
/**
|
||||
* Reset the Message Buffer information counter tracking the maximum number buffers in use at the same time.
|
||||
*
|
||||
* This resets `mMaxUsedBuffers` in `otBufferInfo`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*/
|
||||
void otMessageResetBufferInfo(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_MESSAGE_H_
|
||||
96
Libs/util/third_party/openthread/include/openthread/multi_radio.h
vendored
Normal file
96
Libs/util/third_party/openthread/include/openthread/multi_radio.h
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Multi Radio Link APIs.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_MULTI_RADIO_H_
|
||||
#define OPENTHREAD_MULTI_RADIO_H_
|
||||
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-multi-radio
|
||||
*
|
||||
* @brief
|
||||
* This module includes definitions and functions for multi radio link.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents information associated with a radio link.
|
||||
*/
|
||||
typedef struct otRadioLinkInfo
|
||||
{
|
||||
uint8_t mPreference; ///< Preference level of radio link
|
||||
} otRadioLinkInfo;
|
||||
|
||||
/**
|
||||
* Represents multi radio link information associated with a neighbor.
|
||||
*/
|
||||
typedef struct otMultiRadioNeighborInfo
|
||||
{
|
||||
bool mSupportsIeee802154 : 1; ///< Neighbor supports IEEE 802.15.4 radio link
|
||||
bool mSupportsTrelUdp6 : 1; ///< Neighbor supports Thread Radio Encapsulation Link (TREL) radio link.
|
||||
otRadioLinkInfo mIeee802154Info; ///< Additional info for 15.4 radio link (applicable when supported).
|
||||
otRadioLinkInfo mTrelUdp6Info; ///< Additional info for TREL radio link (applicable when supported).
|
||||
} otMultiRadioNeighborInfo;
|
||||
|
||||
/**
|
||||
* Gets the multi radio link information associated with a neighbor with a given Extended Address.
|
||||
*
|
||||
* `OPENTHREAD_CONFIG_MULTI_RADIO` must be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aExtAddress The Extended Address of neighbor.
|
||||
* @param[out] aNeighborInfo A pointer to `otMultiRadioNeighborInfo` to output the neighbor info (on success).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Neighbor was found and @p aNeighborInfo was updated successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND Could not find a neighbor with @p aExtAddress.
|
||||
*/
|
||||
otError otMultiRadioGetNeighborInfo(otInstance *aInstance,
|
||||
const otExtAddress *aExtAddress,
|
||||
otMultiRadioNeighborInfo *aNeighborInfo);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_MULTI_RADIO_H_
|
||||
505
Libs/util/third_party/openthread/include/openthread/nat64.h
vendored
Normal file
505
Libs/util/third_party/openthread/include/openthread/nat64.h
vendored
Normal file
@@ -0,0 +1,505 @@
|
||||
/*
|
||||
* Copyright (c) 2022, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread API for NAT64 on a border router.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_NAT64_H_
|
||||
#define OPENTHREAD_NAT64_H_
|
||||
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/message.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-nat64
|
||||
*
|
||||
* @brief This module includes functions and structs for the NAT64 function on the border router. These functions are
|
||||
* only available when `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` is enabled.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define OT_IP4_ADDRESS_SIZE 4 ///< Size of an IPv4 address (bytes)
|
||||
|
||||
/**
|
||||
* @struct otIp4Address
|
||||
*
|
||||
* Represents an IPv4 address.
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otIp4Address
|
||||
{
|
||||
union OT_TOOL_PACKED_FIELD
|
||||
{
|
||||
uint8_t m8[OT_IP4_ADDRESS_SIZE]; ///< 8-bit fields
|
||||
uint32_t m32; ///< 32-bit representation
|
||||
} mFields;
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* Represents an IPv4 address.
|
||||
*/
|
||||
typedef struct otIp4Address otIp4Address;
|
||||
|
||||
/**
|
||||
* @struct otIp4Cidr
|
||||
*
|
||||
* Represents an IPv4 CIDR block.
|
||||
*/
|
||||
typedef struct otIp4Cidr
|
||||
{
|
||||
otIp4Address mAddress;
|
||||
uint8_t mLength;
|
||||
} otIp4Cidr;
|
||||
|
||||
/**
|
||||
* Represents the counters for NAT64.
|
||||
*/
|
||||
typedef struct otNat64Counters
|
||||
{
|
||||
uint64_t m4To6Packets; ///< Number of packets translated from IPv4 to IPv6.
|
||||
uint64_t m4To6Bytes; ///< Sum of size of packets translated from IPv4 to IPv6.
|
||||
uint64_t m6To4Packets; ///< Number of packets translated from IPv6 to IPv4.
|
||||
uint64_t m6To4Bytes; ///< Sum of size of packets translated from IPv6 to IPv4.
|
||||
} otNat64Counters;
|
||||
|
||||
/**
|
||||
* Represents the counters for the protocols supported by NAT64.
|
||||
*/
|
||||
typedef struct otNat64ProtocolCounters
|
||||
{
|
||||
otNat64Counters mTotal; ///< Counters for sum of all protocols.
|
||||
otNat64Counters mIcmp; ///< Counters for ICMP and ICMPv6.
|
||||
otNat64Counters mUdp; ///< Counters for UDP.
|
||||
otNat64Counters mTcp; ///< Counters for TCP.
|
||||
} otNat64ProtocolCounters;
|
||||
|
||||
/**
|
||||
* Packet drop reasons.
|
||||
*/
|
||||
typedef enum otNat64DropReason
|
||||
{
|
||||
OT_NAT64_DROP_REASON_UNKNOWN = 0, ///< Packet drop for unknown reasons.
|
||||
OT_NAT64_DROP_REASON_ILLEGAL_PACKET, ///< Packet drop due to failed to parse the datagram.
|
||||
OT_NAT64_DROP_REASON_UNSUPPORTED_PROTO, ///< Packet drop due to unsupported IP protocol.
|
||||
OT_NAT64_DROP_REASON_NO_MAPPING, ///< Packet drop due to no mappings found or mapping pool exhausted.
|
||||
//---
|
||||
OT_NAT64_DROP_REASON_COUNT,
|
||||
} otNat64DropReason;
|
||||
|
||||
/**
|
||||
* Represents the counters of dropped packets due to errors when handling NAT64 packets.
|
||||
*/
|
||||
typedef struct otNat64ErrorCounters
|
||||
{
|
||||
uint64_t mCount4To6[OT_NAT64_DROP_REASON_COUNT]; ///< Errors translating IPv4 packets.
|
||||
uint64_t mCount6To4[OT_NAT64_DROP_REASON_COUNT]; ///< Errors translating IPv6 packets.
|
||||
} otNat64ErrorCounters;
|
||||
|
||||
/**
|
||||
* Gets NAT64 translator counters.
|
||||
*
|
||||
* The counter is counted since the instance initialized.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aCounters A pointer to an `otNat64Counters` where the counters of NAT64 translator will be placed.
|
||||
*/
|
||||
void otNat64GetCounters(otInstance *aInstance, otNat64ProtocolCounters *aCounters);
|
||||
|
||||
/**
|
||||
* Gets the NAT64 translator error counters.
|
||||
*
|
||||
* The counters are initialized to zero when the OpenThread instance is initialized.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aCounters A pointer to an `otNat64Counters` where the counters of NAT64 translator will be placed.
|
||||
*/
|
||||
void otNat64GetErrorCounters(otInstance *aInstance, otNat64ErrorCounters *aCounters);
|
||||
|
||||
/**
|
||||
* Represents an address mapping record for NAT64.
|
||||
*
|
||||
* @note The counters will be reset for each mapping session even for the same address pair. Applications can use `mId`
|
||||
* to identify different sessions to calculate the packets correctly.
|
||||
*/
|
||||
typedef struct otNat64AddressMapping
|
||||
{
|
||||
uint64_t mId; ///< The unique id for a mapping session.
|
||||
|
||||
otIp4Address mIp4; ///< The IPv4 address of the mapping.
|
||||
otIp6Address mIp6; ///< The IPv6 address of the mapping.
|
||||
uint32_t mRemainingTimeMs; ///< Remaining time before expiry in milliseconds.
|
||||
|
||||
otNat64ProtocolCounters mCounters;
|
||||
} otNat64AddressMapping;
|
||||
|
||||
/**
|
||||
* Used to iterate through NAT64 address mappings.
|
||||
*
|
||||
* The fields in this type are opaque (intended for use by OpenThread core only) and therefore should not be
|
||||
* accessed or used by caller.
|
||||
*
|
||||
* Before using an iterator, it MUST be initialized using `otNat64AddressMappingIteratorInit()`.
|
||||
*/
|
||||
typedef struct otNat64AddressMappingIterator
|
||||
{
|
||||
void *mPtr;
|
||||
} otNat64AddressMappingIterator;
|
||||
|
||||
/**
|
||||
* Initializes an `otNat64AddressMappingIterator`.
|
||||
*
|
||||
* An iterator MUST be initialized before it is used.
|
||||
*
|
||||
* An iterator can be initialized again to restart from the beginning of the mapping info.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[out] aIterator A pointer to the iterator to initialize.
|
||||
*/
|
||||
void otNat64InitAddressMappingIterator(otInstance *aInstance, otNat64AddressMappingIterator *aIterator);
|
||||
|
||||
/**
|
||||
* Gets the next AddressMapping info (using an iterator).
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to the iterator. On success the iterator will be updated to point to next
|
||||
* NAT64 address mapping record. To get the first entry the iterator should be set to
|
||||
* OT_NAT64_ADDRESS_MAPPING_ITERATOR_INIT.
|
||||
* @param[out] aMapping A pointer to an `otNat64AddressMapping` where information of next NAT64 address
|
||||
* mapping record is placed (on success).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully found the next NAT64 address mapping info (@p aMapping was successfully
|
||||
* updated).
|
||||
* @retval OT_ERROR_NOT_FOUND No subsequent NAT64 address mapping info was found.
|
||||
*/
|
||||
otError otNat64GetNextAddressMapping(otInstance *aInstance,
|
||||
otNat64AddressMappingIterator *aIterator,
|
||||
otNat64AddressMapping *aMapping);
|
||||
|
||||
/**
|
||||
* States of NAT64.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_NAT64_STATE_DISABLED = 0, ///< NAT64 is disabled.
|
||||
OT_NAT64_STATE_NOT_RUNNING, ///< NAT64 is enabled, but one or more dependencies of NAT64 are not running.
|
||||
OT_NAT64_STATE_IDLE, ///< NAT64 is enabled, but this BR is not an active NAT64 BR.
|
||||
OT_NAT64_STATE_ACTIVE, ///< The BR is publishing a NAT64 prefix and/or translating packets.
|
||||
} otNat64State;
|
||||
|
||||
/**
|
||||
* Gets the state of NAT64 translator.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_NAT64_STATE_DISABLED NAT64 translator is disabled.
|
||||
* @retval OT_NAT64_STATE_NOT_RUNNING NAT64 translator is enabled, but the translator is not configured with a valid
|
||||
* NAT64 prefix and a CIDR.
|
||||
* @retval OT_NAT64_STATE_ACTIVE NAT64 translator is enabled, and is translating packets.
|
||||
*/
|
||||
otNat64State otNat64GetTranslatorState(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the state of NAT64 prefix manager.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_NAT64_STATE_DISABLED NAT64 prefix manager is disabled.
|
||||
* @retval OT_NAT64_STATE_NOT_RUNNING NAT64 prefix manager is enabled, but is not running (because the routing manager
|
||||
* is not running).
|
||||
* @retval OT_NAT64_STATE_IDLE NAT64 prefix manager is enabled, but is not publishing a NAT64 prefix. Usually
|
||||
* when there is another border router publishing a NAT64 prefix with higher
|
||||
* priority.
|
||||
* @retval OT_NAT64_STATE_ACTIVE NAT64 prefix manager is enabled, and is publishing NAT64 prefix to the Thread
|
||||
* network.
|
||||
*/
|
||||
otNat64State otNat64GetPrefixManagerState(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Enable or disable NAT64 functions.
|
||||
*
|
||||
* Note: This includes the NAT64 Translator (when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled) and the NAT64
|
||||
* Prefix Manager (when `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` is enabled).
|
||||
*
|
||||
* When `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled, setting disabled to true resets the
|
||||
* mapping table in the translator.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` or `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` is
|
||||
* enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnabled A boolean to enable/disable the NAT64 functions
|
||||
*
|
||||
* @sa otNat64GetTranslatorState
|
||||
* @sa otNat64GetPrefixManagerState
|
||||
*/
|
||||
void otNat64SetEnabled(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Allocate a new message buffer for sending an IPv4 message to the NAT64 translator.
|
||||
*
|
||||
* Message buffers allocated by this function will have 20 bytes (difference between the size of IPv6 headers
|
||||
* and IPv4 header sizes) reserved.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled.
|
||||
*
|
||||
* @note If @p aSettings is `NULL`, the link layer security is enabled and the message priority is set to
|
||||
* OT_MESSAGE_PRIORITY_NORMAL by default.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aSettings A pointer to the message settings or NULL to set default settings.
|
||||
*
|
||||
* @returns A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid.
|
||||
*
|
||||
* @sa otNat64Send
|
||||
*/
|
||||
otMessage *otIp4NewMessage(otInstance *aInstance, const otMessageSettings *aSettings);
|
||||
|
||||
/**
|
||||
* Sets the CIDR used when setting the source address of the outgoing translated IPv4 packets.
|
||||
*
|
||||
* Is available only when OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE is enabled.
|
||||
*
|
||||
* @note A valid CIDR must have a non-zero prefix length. The actual addresses pool is limited by the size of the
|
||||
* mapping pool and the number of addresses available in the CIDR block.
|
||||
*
|
||||
* @note This function can be called at any time, but the NAT64 translator will be reset and all existing sessions will
|
||||
* be expired when updating the configured CIDR.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCidr A pointer to an otIp4Cidr for the IPv4 CIDR block for NAT64.
|
||||
*
|
||||
* @retval OT_ERROR_INVALID_ARGS The given CIDR is not a valid IPv4 CIDR for NAT64.
|
||||
* @retval OT_ERROR_NONE Successfully set the CIDR for NAT64.
|
||||
*
|
||||
* @sa otNat64Send
|
||||
* @sa otNat64SetReceiveIp4Callback
|
||||
*/
|
||||
otError otNat64SetIp4Cidr(otInstance *aInstance, const otIp4Cidr *aCidr);
|
||||
|
||||
/**
|
||||
* Clears the CIDR used when setting the source address of the outgoing translated IPv4 packets.
|
||||
*
|
||||
* Is available only when OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE is enabled.
|
||||
*
|
||||
* @note This function can be called at any time, but the NAT64 translator will be reset and all existing sessions
|
||||
* will be expired when clearing the configured CIDR.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @sa otNat64SetIp4Cidr
|
||||
*/
|
||||
void otNat64ClearIp4Cidr(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Translates an IPv4 datagram to an IPv6 datagram and sends via the Thread interface.
|
||||
*
|
||||
* The caller transfers ownership of @p aMessage when making this call. OpenThread will free @p aMessage when
|
||||
* processing is complete, including when a value other than `OT_ERROR_NONE` is returned.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMessage A pointer to the message buffer containing the IPv4 datagram.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully processed the message.
|
||||
* @retval OT_ERROR_DROP Message was well-formed but not fully processed due to packet processing
|
||||
* rules.
|
||||
* @retval OT_ERROR_NO_BUFS Could not allocate necessary message buffers when processing the datagram.
|
||||
* @retval OT_ERROR_NO_ROUTE No route to host.
|
||||
* @retval OT_ERROR_INVALID_SOURCE_ADDRESS Source address is invalid, e.g. an anycast address or a multicast address.
|
||||
* @retval OT_ERROR_PARSE Encountered a malformed header when processing the message.
|
||||
*/
|
||||
otError otNat64Send(otInstance *aInstance, otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Pointer is called when an IPv4 datagram (translated by NAT64 translator) is received.
|
||||
*
|
||||
* @param[in] aMessage A pointer to the message buffer containing the received IPv6 datagram. This function transfers
|
||||
* the ownership of the @p aMessage to the receiver of the callback. The message should be
|
||||
* freed by the receiver of the callback after it is processed.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otNat64ReceiveIp4Callback)(otMessage *aMessage, void *aContext);
|
||||
|
||||
/**
|
||||
* Registers a callback to provide received IPv4 datagrams.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback A pointer to a function that is called when an IPv4 datagram is received or
|
||||
* NULL to disable the callback.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
void otNat64SetReceiveIp4Callback(otInstance *aInstance, otNat64ReceiveIp4Callback aCallback, void *aContext);
|
||||
|
||||
/**
|
||||
* Gets the IPv4 CIDR configured in the NAT64 translator.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aCidr A pointer to an otIp4Cidr. Where the CIDR will be filled.
|
||||
*/
|
||||
otError otNat64GetCidr(otInstance *aInstance, otIp4Cidr *aCidr);
|
||||
|
||||
/**
|
||||
* Test if two IPv4 addresses are the same.
|
||||
*
|
||||
* @param[in] aFirst A pointer to the first IPv4 address to compare.
|
||||
* @param[in] aSecond A pointer to the second IPv4 address to compare.
|
||||
*
|
||||
* @retval TRUE The two IPv4 addresses are the same.
|
||||
* @retval FALSE The two IPv4 addresses are not the same.
|
||||
*/
|
||||
bool otIp4IsAddressEqual(const otIp4Address *aFirst, const otIp4Address *aSecond);
|
||||
|
||||
/**
|
||||
* Set @p aIp4Address by performing NAT64 address translation from @p aIp6Address as specified
|
||||
* in RFC 6052.
|
||||
*
|
||||
* The NAT64 @p aPrefixLength MUST be one of the following values: 32, 40, 48, 56, 64, or 96, otherwise the behavior
|
||||
* of this method is undefined.
|
||||
*
|
||||
* @param[in] aPrefixLength The prefix length to use for IPv4/IPv6 translation.
|
||||
* @param[in] aIp6Address A pointer to an IPv6 address.
|
||||
* @param[out] aIp4Address A pointer to output the IPv4 address.
|
||||
*/
|
||||
void otIp4ExtractFromIp6Address(uint8_t aPrefixLength, const otIp6Address *aIp6Address, otIp4Address *aIp4Address);
|
||||
|
||||
/**
|
||||
* Extracts the IPv4 address from a given IPv4-mapped IPv6 address.
|
||||
*
|
||||
* An IPv4-mapped IPv6 address consists of an 80-bit prefix of zeros, the next 16 bits set to ones, and the remaining,
|
||||
* least-significant 32 bits contain the IPv4 address, e.g., `::ffff:192.0.2.128` representing `192.0.2.128`.
|
||||
*
|
||||
* @param[in] aIp6Address An IPv6 address to extract IPv4 from.
|
||||
* @param[out] aIp4Address An IPv4 address to output the extracted address.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Extracted the IPv4 address successfully. @p aIp4Address is updated.
|
||||
* @retval OT_ERROR_PARSE The @p aIp6Address does not follow the IPv4-mapped IPv6 address format.
|
||||
*/
|
||||
otError otIp4FromIp4MappedIp6Address(const otIp6Address *aIp6Address, otIp4Address *aIp4Address);
|
||||
|
||||
/**
|
||||
* Converts a given IP4 address to an IPv6 address following the IPv4-mapped IPv6 address format.
|
||||
*
|
||||
* @param[in] aIp4Address An IPv4 address to convert.
|
||||
* @param[out] aIp6Address An IPv6 address to set.
|
||||
*/
|
||||
void otIp4ToIp4MappedIp6Address(const otIp4Address *aIp4Address, otIp6Address *aIp6Address);
|
||||
|
||||
#define OT_IP4_ADDRESS_STRING_SIZE 17 ///< Length of 000.000.000.000 plus a suffix NUL
|
||||
|
||||
/**
|
||||
* Converts the address to a string.
|
||||
*
|
||||
* The string format uses quad-dotted notation of four bytes in the address (e.g., "127.0.0.1").
|
||||
*
|
||||
* If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be
|
||||
* truncated but the outputted string is always null-terminated.
|
||||
*
|
||||
* @param[in] aAddress A pointer to an IPv4 address (MUST NOT be NULL).
|
||||
* @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be `nullptr`).
|
||||
* @param[in] aSize The size of @p aBuffer (in bytes).
|
||||
*/
|
||||
void otIp4AddressToString(const otIp4Address *aAddress, char *aBuffer, uint16_t aSize);
|
||||
|
||||
#define OT_IP4_CIDR_STRING_SIZE 20 ///< Length of 000.000.000.000/00 plus a suffix NUL
|
||||
|
||||
/**
|
||||
* Converts a human-readable IPv4 CIDR string into a binary representation.
|
||||
*
|
||||
* @param[in] aString A pointer to a NULL-terminated string.
|
||||
* @param[out] aCidr A pointer to an IPv4 CIDR.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully parsed the string.
|
||||
* @retval OT_ERROR_INVALID_ARGS Failed to parse the string.
|
||||
*/
|
||||
otError otIp4CidrFromString(const char *aString, otIp4Cidr *aCidr);
|
||||
|
||||
/**
|
||||
* Converts the IPv4 CIDR to a string.
|
||||
*
|
||||
* The string format uses quad-dotted notation of four bytes in the address with the length of prefix (e.g.,
|
||||
* "127.0.0.1/32").
|
||||
*
|
||||
* If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be
|
||||
* truncated but the outputted string is always null-terminated.
|
||||
*
|
||||
* @param[in] aCidr A pointer to an IPv4 CIDR (MUST NOT be NULL).
|
||||
* @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be `nullptr`).
|
||||
* @param[in] aSize The size of @p aBuffer (in bytes).
|
||||
*/
|
||||
void otIp4CidrToString(const otIp4Cidr *aCidr, char *aBuffer, uint16_t aSize);
|
||||
|
||||
/**
|
||||
* Converts a human-readable IPv4 address string into a binary representation.
|
||||
*
|
||||
* @param[in] aString A pointer to a NULL-terminated string.
|
||||
* @param[out] aAddress A pointer to an IPv4 address.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully parsed the string.
|
||||
* @retval OT_ERROR_INVALID_ARGS Failed to parse the string.
|
||||
*/
|
||||
otError otIp4AddressFromString(const char *aString, otIp4Address *aAddress);
|
||||
|
||||
/**
|
||||
* Sets the IPv6 address by performing NAT64 address translation from the preferred NAT64 prefix and the given IPv4
|
||||
* address as specified in RFC 6052.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aIp4Address A pointer to the IPv4 address to translate to IPv6.
|
||||
* @param[out] aIp6Address A pointer to the synthesized IPv6 address.
|
||||
*
|
||||
* @returns OT_ERROR_NONE Successfully synthesized the IPv6 address from NAT64 prefix and IPv4 address.
|
||||
* @returns OT_ERROR_INVALID_STATE No valid NAT64 prefix in the network data.
|
||||
*/
|
||||
otError otNat64SynthesizeIp6Address(otInstance *aInstance, const otIp4Address *aIp4Address, otIp6Address *aIp6Address);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_NAT64_H_
|
||||
173
Libs/util/third_party/openthread/include/openthread/ncp.h
vendored
Normal file
173
Libs/util/third_party/openthread/include/openthread/ncp.h
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the top-level functions for the OpenThread NCP module.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_NCP_H_
|
||||
#define OPENTHREAD_NCP_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <openthread/platform/logging.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-ncp
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control the Thread stack's execution.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pointer is called to send HDLC encoded NCP data.
|
||||
*
|
||||
* @param[in] aBuf A pointer to a buffer with an output.
|
||||
* @param[in] aBufLength A length of the output data stored in the buffer.
|
||||
*
|
||||
* @returns Number of bytes processed by the callback.
|
||||
*/
|
||||
typedef int (*otNcpHdlcSendCallback)(const uint8_t *aBuf, uint16_t aBufLength);
|
||||
|
||||
/**
|
||||
* Is called after NCP send finished.
|
||||
*/
|
||||
void otNcpHdlcSendDone(void);
|
||||
|
||||
/**
|
||||
* Is called after HDLC encoded NCP data received.
|
||||
*
|
||||
* @param[in] aBuf A pointer to a buffer.
|
||||
* @param[in] aBufLength The length of the data stored in the buffer.
|
||||
*/
|
||||
void otNcpHdlcReceive(const uint8_t *aBuf, uint16_t aBufLength);
|
||||
|
||||
/**
|
||||
* Initialize the NCP based on HDLC framing.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aSendCallback The function pointer used to send NCP data.
|
||||
*/
|
||||
void otNcpHdlcInit(otInstance *aInstance, otNcpHdlcSendCallback aSendCallback);
|
||||
|
||||
/**
|
||||
* Initialize the NCP based on HDLC framing.
|
||||
*
|
||||
* @param[in] aInstances The OpenThread instance pointers array.
|
||||
* @param[in] aCount Number of elements in the array.
|
||||
* @param[in] aSendCallback The function pointer used to send NCP data.
|
||||
*/
|
||||
void otNcpHdlcInitMulti(otInstance **aInstance, uint8_t aCount, otNcpHdlcSendCallback aSendCallback);
|
||||
|
||||
/**
|
||||
* Initialize the NCP based on SPI framing.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
void otNcpSpiInit(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @brief Send data to the host via a specific stream.
|
||||
*
|
||||
* Attempts to send the given data to the host
|
||||
* using the given aStreamId. This is useful for reporting
|
||||
* error messages, implementing debug/diagnostic consoles,
|
||||
* and potentially other types of datastreams.
|
||||
*
|
||||
* The write either is accepted in its entirety or rejected.
|
||||
* Partial writes are not attempted.
|
||||
*
|
||||
* @param[in] aStreamId A numeric identifier for the stream to write to.
|
||||
* If set to '0', will default to the debug stream.
|
||||
* @param[in] aDataPtr A pointer to the data to send on the stream.
|
||||
* If aDataLen is non-zero, this param MUST NOT be NULL.
|
||||
* @param[in] aDataLen The number of bytes of data from aDataPtr to send.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The data was queued for delivery to the host.
|
||||
* @retval OT_ERROR_BUSY There are not enough resources to complete this
|
||||
* request. This is usually a temporary condition.
|
||||
* @retval OT_ERROR_INVALID_ARGS The given aStreamId was invalid.
|
||||
*/
|
||||
otError otNcpStreamWrite(int aStreamId, const uint8_t *aDataPtr, int aDataLen);
|
||||
|
||||
/**
|
||||
* Writes OpenThread Log using `otNcpStreamWrite`.
|
||||
*
|
||||
* @param[in] aLogLevel The log level.
|
||||
* @param[in] aLogRegion The log region.
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] aArgs va_list matching aFormat.
|
||||
*/
|
||||
void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs);
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// Peek/Poke memory access control delegates
|
||||
|
||||
/**
|
||||
* Defines delegate (function pointer) type to control behavior of peek/poke operation.
|
||||
*
|
||||
* This delegate function is called to decide whether to allow peek or poke of a specific memory region. It is used
|
||||
* if NCP support for peek/poke commands is enabled.
|
||||
*
|
||||
* @param[in] aAddress Start address of memory region.
|
||||
* @param[in] aCount Number of bytes to peek or poke.
|
||||
*
|
||||
* @returns TRUE to allow peek/poke of the given memory region, FALSE otherwise.
|
||||
*/
|
||||
typedef bool (*otNcpDelegateAllowPeekPoke)(uint32_t aAddress, uint16_t aCount);
|
||||
|
||||
/**
|
||||
* Registers peek/poke delegate functions with NCP module.
|
||||
*
|
||||
* The delegate functions are called by NCP module to decide whether to allow peek or poke of a specific memory region.
|
||||
* If the delegate pointer is set to NULL, it allows peek/poke operation for any address.
|
||||
*
|
||||
* @param[in] aAllowPeekDelegate Delegate function pointer for peek operation.
|
||||
* @param[in] aAllowPokeDelegate Delegate function pointer for poke operation.
|
||||
*/
|
||||
void otNcpRegisterPeekPokeDelegates(otNcpDelegateAllowPeekPoke aAllowPeekDelegate,
|
||||
otNcpDelegateAllowPeekPoke aAllowPokeDelegate);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_NCP_H_
|
||||
306
Libs/util/third_party/openthread/include/openthread/netdata.h
vendored
Normal file
306
Libs/util/third_party/openthread/include/openthread/netdata.h
vendored
Normal file
@@ -0,0 +1,306 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Network Data API.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_NETDATA_H_
|
||||
#define OPENTHREAD_NETDATA_H_
|
||||
|
||||
#include <openthread/commissioner.h>
|
||||
#include <openthread/ip6.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-thread-general
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define OT_NETWORK_DATA_ITERATOR_INIT 0 ///< Value to initialize `otNetworkDataIterator`.
|
||||
|
||||
typedef uint32_t otNetworkDataIterator; ///< Used to iterate through Network Data information.
|
||||
|
||||
/**
|
||||
* Represents a Border Router configuration.
|
||||
*/
|
||||
typedef struct otBorderRouterConfig
|
||||
{
|
||||
otIp6Prefix mPrefix; ///< The IPv6 prefix.
|
||||
signed int mPreference : 2; ///< A 2-bit signed int preference (`OT_ROUTE_PREFERENCE_*` values).
|
||||
bool mPreferred : 1; ///< Whether prefix is preferred.
|
||||
bool mSlaac : 1; ///< Whether prefix can be used for address auto-configuration (SLAAC).
|
||||
bool mDhcp : 1; ///< Whether border router is DHCPv6 Agent.
|
||||
bool mConfigure : 1; ///< Whether DHCPv6 Agent supplying other config data.
|
||||
bool mDefaultRoute : 1; ///< Whether border router is a default router for prefix.
|
||||
bool mOnMesh : 1; ///< Whether this prefix is considered on-mesh.
|
||||
bool mStable : 1; ///< Whether this configuration is considered Stable Network Data.
|
||||
bool mNdDns : 1; ///< Whether this border router can supply DNS information via ND.
|
||||
bool mDp : 1; ///< Whether prefix is a Thread Domain Prefix (added since Thread 1.2).
|
||||
uint16_t mRloc16; ///< The border router's RLOC16 (value ignored on config add).
|
||||
} otBorderRouterConfig;
|
||||
|
||||
/**
|
||||
* Represents 6LoWPAN Context ID information associated with a prefix in Network Data.
|
||||
*/
|
||||
typedef struct otLowpanContextInfo
|
||||
{
|
||||
uint8_t mContextId; ///< The 6LoWPAN Context ID.
|
||||
bool mCompressFlag; ///< The compress flag.
|
||||
otIp6Prefix mPrefix; ///< The associated IPv6 prefix.
|
||||
} otLowpanContextInfo;
|
||||
|
||||
/**
|
||||
* Represents an External Route configuration.
|
||||
*/
|
||||
typedef struct otExternalRouteConfig
|
||||
{
|
||||
otIp6Prefix mPrefix; ///< The IPv6 prefix.
|
||||
uint16_t mRloc16; ///< The border router's RLOC16 (value ignored on config add).
|
||||
signed int mPreference : 2; ///< A 2-bit signed int preference (`OT_ROUTE_PREFERENCE_*` values).
|
||||
bool mNat64 : 1; ///< Whether this is a NAT64 prefix.
|
||||
bool mStable : 1; ///< Whether this configuration is considered Stable Network Data.
|
||||
bool mNextHopIsThisDevice : 1; ///< Whether the next hop is this device (value ignored on config add).
|
||||
bool mAdvPio : 1; ///< Whether or not BR is advertising a ULA prefix in PIO (AP flag).
|
||||
} otExternalRouteConfig;
|
||||
|
||||
/**
|
||||
* Defines valid values for `mPreference` in `otExternalRouteConfig` and `otBorderRouterConfig`.
|
||||
*/
|
||||
typedef enum otRoutePreference
|
||||
{
|
||||
OT_ROUTE_PREFERENCE_LOW = -1, ///< Low route preference.
|
||||
OT_ROUTE_PREFERENCE_MED = 0, ///< Medium route preference.
|
||||
OT_ROUTE_PREFERENCE_HIGH = 1, ///< High route preference.
|
||||
} otRoutePreference;
|
||||
|
||||
#define OT_SERVICE_DATA_MAX_SIZE 252 ///< Max size of Service Data in bytes.
|
||||
#define OT_SERVER_DATA_MAX_SIZE 248 ///< Max size of Server Data in bytes. Theoretical limit, practically much lower.
|
||||
|
||||
/**
|
||||
* Represents a Server configuration.
|
||||
*/
|
||||
typedef struct otServerConfig
|
||||
{
|
||||
bool mStable : 1; ///< Whether this config is considered Stable Network Data.
|
||||
uint8_t mServerDataLength; ///< Length of server data.
|
||||
uint8_t mServerData[OT_SERVER_DATA_MAX_SIZE]; ///< Server data bytes.
|
||||
uint16_t mRloc16; ///< The Server RLOC16.
|
||||
} otServerConfig;
|
||||
|
||||
/**
|
||||
* Represents a Service configuration.
|
||||
*/
|
||||
typedef struct otServiceConfig
|
||||
{
|
||||
uint8_t mServiceId; ///< Service ID (when iterating over the Network Data).
|
||||
uint32_t mEnterpriseNumber; ///< IANA Enterprise Number.
|
||||
uint8_t mServiceDataLength; ///< Length of service data.
|
||||
uint8_t mServiceData[OT_SERVICE_DATA_MAX_SIZE]; ///< Service data bytes.
|
||||
otServerConfig mServerConfig; ///< The Server configuration.
|
||||
} otServiceConfig;
|
||||
|
||||
/**
|
||||
* Provide full or stable copy of the Partition's Thread Network Data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aStable TRUE when copying the stable version, FALSE when copying the full version.
|
||||
* @param[out] aData A pointer to the data buffer.
|
||||
* @param[in,out] aDataLength On entry, size of the data buffer pointed to by @p aData.
|
||||
* On exit, number of copied bytes.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully copied the Thread Network Data into @p aData and updated @p aDataLength.
|
||||
* @retval OT_ERROR_NO_BUFS Not enough space in @p aData to fully copy the Thread Network Data.
|
||||
*/
|
||||
otError otNetDataGet(otInstance *aInstance, bool aStable, uint8_t *aData, uint8_t *aDataLength);
|
||||
|
||||
/**
|
||||
* Get the current length (number of bytes) of Partition's Thread Network Data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @return The length of the Network Data.
|
||||
*/
|
||||
uint8_t otNetDataGetLength(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the maximum observed length of the Thread Network Data since OT stack initialization or since the last call to
|
||||
* `otNetDataResetMaxLength()`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @return The maximum length of the Network Data (high water mark for Network Data length).
|
||||
*/
|
||||
uint8_t otNetDataGetMaxLength(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Reset the tracked maximum length of the Thread Network Data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @sa otNetDataGetMaxLength
|
||||
*/
|
||||
void otNetDataResetMaxLength(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the next On Mesh Prefix in the partition's Network Data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to the Network Data iterator context. To get the first on-mesh entry
|
||||
it should be set to OT_NETWORK_DATA_ITERATOR_INIT.
|
||||
* @param[out] aConfig A pointer to where the On Mesh Prefix information will be placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully found the next On Mesh prefix.
|
||||
* @retval OT_ERROR_NOT_FOUND No subsequent On Mesh prefix exists in the Thread Network Data.
|
||||
*/
|
||||
otError otNetDataGetNextOnMeshPrefix(otInstance *aInstance,
|
||||
otNetworkDataIterator *aIterator,
|
||||
otBorderRouterConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Get the next external route in the partition's Network Data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to the Network Data iterator context. To get the first external route entry
|
||||
it should be set to OT_NETWORK_DATA_ITERATOR_INIT.
|
||||
* @param[out] aConfig A pointer to where the External Route information will be placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully found the next External Route.
|
||||
* @retval OT_ERROR_NOT_FOUND No subsequent external route entry exists in the Thread Network Data.
|
||||
*/
|
||||
otError otNetDataGetNextRoute(otInstance *aInstance, otNetworkDataIterator *aIterator, otExternalRouteConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Get the next service in the partition's Network Data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to the Network Data iterator context. To get the first service entry
|
||||
it should be set to OT_NETWORK_DATA_ITERATOR_INIT.
|
||||
* @param[out] aConfig A pointer to where the service information will be placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully found the next service.
|
||||
* @retval OT_ERROR_NOT_FOUND No subsequent service exists in the partition's Network Data.
|
||||
*/
|
||||
otError otNetDataGetNextService(otInstance *aInstance, otNetworkDataIterator *aIterator, otServiceConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Get the next 6LoWPAN Context ID info in the partition's Network Data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to the Network Data iterator. To get the first service entry
|
||||
it should be set to OT_NETWORK_DATA_ITERATOR_INIT.
|
||||
* @param[out] aContextInfo A pointer to where the retrieved 6LoWPAN Context ID information will be placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully found the next 6LoWPAN Context ID info.
|
||||
* @retval OT_ERROR_NOT_FOUND No subsequent 6LoWPAN Context info exists in the partition's Network Data.
|
||||
*/
|
||||
otError otNetDataGetNextLowpanContextInfo(otInstance *aInstance,
|
||||
otNetworkDataIterator *aIterator,
|
||||
otLowpanContextInfo *aContextInfo);
|
||||
|
||||
/**
|
||||
* Gets the Commissioning Dataset from the partition's Network Data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[out] aDataset A pointer to a `otCommissioningDataset` to populate.
|
||||
*/
|
||||
void otNetDataGetCommissioningDataset(otInstance *aInstance, otCommissioningDataset *aDataset);
|
||||
|
||||
/**
|
||||
* Get the Network Data Version.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The Network Data Version.
|
||||
*/
|
||||
uint8_t otNetDataGetVersion(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the Stable Network Data Version.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The Stable Network Data Version.
|
||||
*/
|
||||
uint8_t otNetDataGetStableVersion(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Check if the steering data includes a Joiner.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEui64 A pointer to the Joiner's IEEE EUI-64.
|
||||
*
|
||||
* @retval OT_ERROR_NONE @p aEui64 is included in the steering data.
|
||||
* @retval OT_ERROR_INVALID_STATE No steering data present.
|
||||
* @retval OT_ERROR_NOT_FOUND @p aEui64 is not included in the steering data.
|
||||
*/
|
||||
otError otNetDataSteeringDataCheckJoiner(otInstance *aInstance, const otExtAddress *aEui64);
|
||||
|
||||
// Forward declaration
|
||||
struct otJoinerDiscerner;
|
||||
|
||||
/**
|
||||
* Check if the steering data includes a Joiner with a given discerner value.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDiscerner A pointer to the Joiner Discerner.
|
||||
*
|
||||
* @retval OT_ERROR_NONE @p aDiscerner is included in the steering data.
|
||||
* @retval OT_ERROR_INVALID_STATE No steering data present.
|
||||
* @retval OT_ERROR_NOT_FOUND @p aDiscerner is not included in the steering data.
|
||||
*/
|
||||
otError otNetDataSteeringDataCheckJoinerWithDiscerner(otInstance *aInstance,
|
||||
const struct otJoinerDiscerner *aDiscerner);
|
||||
|
||||
/**
|
||||
* Check whether a given Prefix can act as a valid OMR prefix and also the Leader's Network Data contains this prefix.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPrefix A pointer to the IPv6 prefix.
|
||||
*
|
||||
* @returns Whether @p aPrefix is a valid OMR prefix and Leader's Network Data contains the OMR prefix @p aPrefix.
|
||||
*
|
||||
* @note This API is only available when `OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE` is used.
|
||||
*/
|
||||
bool otNetDataContainsOmrPrefix(otInstance *aInstance, const otIp6Prefix *aPrefix);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_NETDATA_H_
|
||||
314
Libs/util/third_party/openthread/include/openthread/netdata_publisher.h
vendored
Normal file
314
Libs/util/third_party/openthread/include/openthread/netdata_publisher.h
vendored
Normal file
@@ -0,0 +1,314 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Network Data Publisher API.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_NETDATA_PUBLISHER_H_
|
||||
#define OPENTHREAD_NETDATA_PUBLISHER_H_
|
||||
|
||||
#include <openthread/netdata.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-thread-general
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* The Network Data Publisher provides mechanisms to limit the number of similar Service and/or Prefix (on-mesh prefix
|
||||
* or external route) entries in the Thread Network Data by monitoring the Network Data and managing if or when to add
|
||||
* or remove entries.
|
||||
*
|
||||
* All the functions in this module require `OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE` to be enabled.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents the events reported from the Publisher callbacks.
|
||||
*/
|
||||
typedef enum otNetDataPublisherEvent
|
||||
{
|
||||
OT_NETDATA_PUBLISHER_EVENT_ENTRY_ADDED = 0, ///< Published entry is added to the Thread Network Data.
|
||||
OT_NETDATA_PUBLISHER_EVENT_ENTRY_REMOVED = 1, ///< Published entry is removed from the Thread Network Data.
|
||||
} otNetDataPublisherEvent;
|
||||
|
||||
/**
|
||||
* Pointer type defines the callback used to notify when a "DNS/SRP Service" entry is added to or removed
|
||||
* from the Thread Network Data.
|
||||
*
|
||||
* On remove the callback is invoked independent of whether the entry is removed by `Publisher` (e.g., when there are
|
||||
* too many similar entries already present in the Network Data) or through an explicit call to unpublish the entry
|
||||
* (i.e., a call to `otNetDataUnpublishDnsSrpService()`).
|
||||
*
|
||||
* @param[in] aEvent Indicates the event (whether the entry was added or removed).
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otNetDataDnsSrpServicePublisherCallback)(otNetDataPublisherEvent aEvent, void *aContext);
|
||||
|
||||
/**
|
||||
* Pointer type defines the callback used to notify when a prefix (on-mesh or external route) entry is
|
||||
* added to or removed from the Thread Network Data.
|
||||
*
|
||||
* On remove the callback is invoked independent of whether the entry is removed by `Publisher` (e.g., when there are
|
||||
* too many similar entries already present in the Network Data) or through an explicit call to unpublish the entry.
|
||||
*
|
||||
* @param[in] aEvent Indicates the event (whether the entry was added or removed).
|
||||
* @param[in] aPrefix A pointer to the prefix entry.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otNetDataPrefixPublisherCallback)(otNetDataPublisherEvent aEvent,
|
||||
const otIp6Prefix *aPrefix,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Requests "DNS/SRP Service Anycast Address" to be published in the Thread Network Data.
|
||||
*
|
||||
* Requires the feature `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` to be enabled.
|
||||
*
|
||||
* A call to this function will remove and replace any previous "DNS/SRP Service" entry that was being published (from
|
||||
* earlier call to any of `otNetDataPublishDnsSrpService{Type}()` functions).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aSequenceNUmber The sequence number of DNS/SRP Anycast Service.
|
||||
*/
|
||||
void otNetDataPublishDnsSrpServiceAnycast(otInstance *aInstance, uint8_t aSequenceNUmber);
|
||||
|
||||
/**
|
||||
* Requests "DNS/SRP Service Unicast Address" to be published in the Thread Network Data.
|
||||
*
|
||||
* Requires the feature `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` to be enabled.
|
||||
*
|
||||
* A call to this function will remove and replace any previous "DNS/SRP Service" entry that was being published (from
|
||||
* earlier call to any of `otNetDataPublishDnsSrpService{Type}()` functions).
|
||||
*
|
||||
* Publishes the "DNS/SRP Service Unicast Address" by including the address and port info in the Service
|
||||
* TLV data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aAddress The DNS/SRP server address to publish (MUST NOT be NULL).
|
||||
* @param[in] aPort The SRP server port number to publish.
|
||||
*/
|
||||
void otNetDataPublishDnsSrpServiceUnicast(otInstance *aInstance, const otIp6Address *aAddress, uint16_t aPort);
|
||||
|
||||
/**
|
||||
* Requests "DNS/SRP Service Unicast Address" to be published in the Thread Network Data.
|
||||
*
|
||||
* Requires the feature `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` to be enabled.
|
||||
*
|
||||
* A call to this function will remove and replace any previous "DNS/SRP Service" entry that was being published (from
|
||||
* earlier call to any of `otNetDataPublishDnsSrpService{Type}()` functions).
|
||||
*
|
||||
* Unlike `otNetDataPublishDnsSrpServiceUnicast()` which requires the published address to be given and includes the
|
||||
* info in the Service TLV data, this function uses the device's mesh-local EID and includes the info in the Server TLV
|
||||
* data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPort The SRP server port number to publish.
|
||||
*/
|
||||
void otNetDataPublishDnsSrpServiceUnicastMeshLocalEid(otInstance *aInstance, uint16_t aPort);
|
||||
|
||||
/**
|
||||
* Indicates whether or not currently the "DNS/SRP Service" entry is added to the Thread Network Data.
|
||||
*
|
||||
* Requires the feature `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` to be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval TRUE The published DNS/SRP Service entry is added to the Thread Network Data.
|
||||
* @retval FALSE The entry is not added to Thread Network Data or there is no entry to publish.
|
||||
*/
|
||||
bool otNetDataIsDnsSrpServiceAdded(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets a callback for notifying when a published "DNS/SRP Service" is actually added to or removed from
|
||||
* the Thread Network Data.
|
||||
*
|
||||
* A subsequent call to this function replaces any previously set callback function.
|
||||
*
|
||||
* Requires the feature `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` to be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback The callback function pointer (can be NULL if not needed).
|
||||
* @param[in] aContext A pointer to application-specific context (used when @p aCallback is invoked).
|
||||
*/
|
||||
void otNetDataSetDnsSrpServicePublisherCallback(otInstance *aInstance,
|
||||
otNetDataDnsSrpServicePublisherCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Unpublishes any previously added DNS/SRP (Anycast or Unicast) Service entry from the Thread Network
|
||||
* Data.
|
||||
*
|
||||
* `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` must be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otNetDataUnpublishDnsSrpService(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Requests an on-mesh prefix to be published in the Thread Network Data.
|
||||
*
|
||||
* Requires the feature `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` to be enabled.
|
||||
*
|
||||
* Only stable entries can be published (i.e.,`aConfig.mStable` MUST be TRUE).
|
||||
*
|
||||
* A subsequent call to this method will replace a previous request for the same prefix. In particular, if the new call
|
||||
* only changes the flags (e.g., preference level) and the prefix is already added in the Network Data, the change to
|
||||
* flags is immediately reflected in the Network Data. This ensures that existing entries in the Network Data are not
|
||||
* abruptly removed. Note that a change in the preference level can potentially later cause the entry to be removed
|
||||
* from the Network Data after determining there are other nodes that are publishing the same prefix with the same or
|
||||
* higher preference.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aConfig The on-mesh prefix config to publish (MUST NOT be NULL).
|
||||
*
|
||||
* @retval OT_ERROR_NONE The on-mesh prefix is published successfully.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aConfig is not valid (bad prefix, invalid flag combinations, or not stable).
|
||||
* @retval OT_ERROR_NO_BUFS Could not allocate an entry for the new request. Publisher supports a limited number
|
||||
* of entries (shared between on-mesh prefix and external route) determined by config
|
||||
* `OPENTHREAD_CONFIG_NETDATA_PUBLISHER_MAX_PREFIX_ENTRIES`.
|
||||
*/
|
||||
otError otNetDataPublishOnMeshPrefix(otInstance *aInstance, const otBorderRouterConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Requests an external route prefix to be published in the Thread Network Data.
|
||||
*
|
||||
* Requires the feature `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` to be enabled.
|
||||
*
|
||||
* Only stable entries can be published (i.e.,`aConfig.mStable` MUST be TRUE).
|
||||
*
|
||||
* A subsequent call to this method will replace a previous request for the same prefix. In particular, if the new call
|
||||
* only changes the flags (e.g., preference level) and the prefix is already added in the Network Data, the change to
|
||||
* flags is immediately reflected in the Network Data. This ensures that existing entries in the Network Data are not
|
||||
* abruptly removed. Note that a change in the preference level can potentially later cause the entry to be removed
|
||||
* from the Network Data after determining there are other nodes that are publishing the same prefix with the same or
|
||||
* higher preference.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aConfig The external route config to publish (MUST NOT be NULL).
|
||||
*
|
||||
* @retval OT_ERROR_NONE The external route is published successfully.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aConfig is not valid (bad prefix, invalid flag combinations, or not stable).
|
||||
* @retval OT_ERROR_NO_BUFS Could not allocate an entry for the new request. Publisher supports a limited number
|
||||
* of entries (shared between on-mesh prefix and external route) determined by config
|
||||
* `OPENTHREAD_CONFIG_NETDATA_PUBLISHER_MAX_PREFIX_ENTRIES`.
|
||||
*/
|
||||
otError otNetDataPublishExternalRoute(otInstance *aInstance, const otExternalRouteConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Replaces a previously published external route in the Thread Network Data.
|
||||
*
|
||||
* Requires the feature `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` to be enabled.
|
||||
*
|
||||
* If there is no previously published external route matching @p aPrefix, this function behaves similarly to
|
||||
* `otNetDataPublishExternalRoute()`, i.e., it will start the process of publishing @a aConfig as an external route in
|
||||
* the Thread Network Data.
|
||||
*
|
||||
* If there is a previously published route entry matching @p aPrefix, it will be replaced with the new prefix from
|
||||
* @p aConfig.
|
||||
*
|
||||
* - If the @p aPrefix was already added in the Network Data, the change to the new prefix in @p aConfig is immediately
|
||||
* reflected in the Network Data. This ensures that route entries in the Network Data are not abruptly removed and
|
||||
* the transition from aPrefix to the new prefix is smooth.
|
||||
*
|
||||
* - If the old published @p aPrefix was not added in the Network Data, it will be replaced with the new @p aConfig
|
||||
* prefix but it will not be immediately added. Instead, it will start the process of publishing it in the Network
|
||||
* Data (monitoring the Network Data to determine when/if to add the prefix, depending on the number of similar
|
||||
* prefixes present in the Network Data).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPrefix The previously published external route prefix to replace.
|
||||
* @param[in] aConfig The external route config to publish.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The external route is published successfully.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aConfig is not valid (bad prefix, invalid flag combinations, or not stable).
|
||||
* @retval OT_ERROR_NO_BUFS Could not allocate an entry for the new request. Publisher supports a limited number
|
||||
* of entries (shared between on-mesh prefix and external route) determined by config
|
||||
* `OPENTHREAD_CONFIG_NETDATA_PUBLISHER_MAX_PREFIX_ENTRIES`.
|
||||
*/
|
||||
otError otNetDataReplacePublishedExternalRoute(otInstance *aInstance,
|
||||
const otIp6Prefix *aPrefix,
|
||||
const otExternalRouteConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Indicates whether or not currently a published prefix entry (on-mesh or external route) is added to
|
||||
* the Thread Network Data.
|
||||
*
|
||||
* Requires the feature `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` to be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPrefix A pointer to the prefix (MUST NOT be NULL).
|
||||
*
|
||||
* @retval TRUE The published prefix entry is added to the Thread Network Data.
|
||||
* @retval FALSE The entry is not added to Thread Network Data or there is no entry to publish.
|
||||
*/
|
||||
bool otNetDataIsPrefixAdded(otInstance *aInstance, const otIp6Prefix *aPrefix);
|
||||
|
||||
/**
|
||||
* Sets a callback for notifying when a published prefix entry is actually added to or removed from
|
||||
* the Thread Network Data.
|
||||
*
|
||||
* A subsequent call to this function replaces any previously set callback function.
|
||||
*
|
||||
* Requires the feature `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` to be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback The callback function pointer (can be NULL if not needed).
|
||||
* @param[in] aContext A pointer to application-specific context (used when @p aCallback is invoked).
|
||||
*/
|
||||
void otNetDataSetPrefixPublisherCallback(otInstance *aInstance,
|
||||
otNetDataPrefixPublisherCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Unpublishes a previously published On-Mesh or External Route Prefix.
|
||||
*
|
||||
* `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` must be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPrefix The prefix to unpublish (MUST NOT be NULL).
|
||||
*
|
||||
* @retval OT_ERROR_NONE The prefix was unpublished successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND Could not find the prefix in the published list.
|
||||
*/
|
||||
otError otNetDataUnpublishPrefix(otInstance *aInstance, const otIp6Prefix *aPrefix);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_NETDATA_PUBLISHER_H_
|
||||
417
Libs/util/third_party/openthread/include/openthread/netdiag.h
vendored
Normal file
417
Libs/util/third_party/openthread/include/openthread/netdiag.h
vendored
Normal file
@@ -0,0 +1,417 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Network Diagnostic API.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_NETDIAG_H_
|
||||
#define OPENTHREAD_NETDIAG_H_
|
||||
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/thread.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-thread-general
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_EXT_ADDRESS 0 ///< MAC Extended Address TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_SHORT_ADDRESS 1 ///< Address16 TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_MODE 2 ///< Mode TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_TIMEOUT 3 ///< Timeout TLV (max polling time period for SEDs)
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_CONNECTIVITY 4 ///< Connectivity TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_ROUTE 5 ///< Route64 TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_LEADER_DATA 6 ///< Leader Data TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_NETWORK_DATA 7 ///< Network Data TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_IP6_ADDR_LIST 8 ///< IPv6 Address List TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_MAC_COUNTERS 9 ///< MAC Counters TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_BATTERY_LEVEL 14 ///< Battery Level TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_SUPPLY_VOLTAGE 15 ///< Supply Voltage TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_CHILD_TABLE 16 ///< Child Table TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_CHANNEL_PAGES 17 ///< Channel Pages TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_TYPE_LIST 18 ///< Type List TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_MAX_CHILD_TIMEOUT 19 ///< Max Child Timeout TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_EUI64 23 ///< EUI64 TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_VERSION 24 ///< Thread Version TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_VENDOR_NAME 25 ///< Vendor Name TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_VENDOR_MODEL 26 ///< Vendor Model TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_VENDOR_SW_VERSION 27 ///< Vendor SW Version TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_THREAD_STACK_VERSION 28 ///< Thread Stack Version TLV (codebase/commit version)
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_CHILD 29 ///< Child TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_CHILD_IP6_ADDR_LIST 30 ///< Child IPv6 Address List TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_ROUTER_NEIGHBOR 31 ///< Router Neighbor TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_ANSWER 32 ///< Answer TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_QUERY_ID 33 ///< Query ID TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_MLE_COUNTERS 34 ///< MLE Counters TLV
|
||||
#define OT_NETWORK_DIAGNOSTIC_TLV_VENDOR_APP_URL 35 ///< Vendor App URL TLV
|
||||
|
||||
#define OT_NETWORK_DIAGNOSTIC_MAX_VENDOR_NAME_TLV_LENGTH 32 ///< Max length of Vendor Name TLV.
|
||||
#define OT_NETWORK_DIAGNOSTIC_MAX_VENDOR_MODEL_TLV_LENGTH 32 ///< Max length of Vendor Model TLV.
|
||||
#define OT_NETWORK_DIAGNOSTIC_MAX_VENDOR_SW_VERSION_TLV_LENGTH 16 ///< Max length of Vendor SW Version TLV.
|
||||
#define OT_NETWORK_DIAGNOSTIC_MAX_THREAD_STACK_VERSION_TLV_LENGTH 64 ///< Max length of Thread Stack Version TLV.
|
||||
#define OT_NETWORK_DIAGNOSTIC_MAX_VENDOR_APP_URL_TLV_LENGTH 96 ///< Max length of Vendor App URL TLV.
|
||||
|
||||
#define OT_NETWORK_DIAGNOSTIC_ITERATOR_INIT 0 ///< Initializer for `otNetworkDiagIterator`.
|
||||
|
||||
typedef uint16_t otNetworkDiagIterator; ///< Used to iterate through Network Diagnostic TLV.
|
||||
|
||||
/**
|
||||
* Represents a Network Diagnostic Connectivity value.
|
||||
*/
|
||||
typedef struct otNetworkDiagConnectivity
|
||||
{
|
||||
int8_t mParentPriority; ///< The priority of the sender as a parent.
|
||||
uint8_t mLinkQuality3; ///< Number of neighbors with link of quality 3.
|
||||
uint8_t mLinkQuality2; ///< Number of neighbors with link of quality 2.
|
||||
uint8_t mLinkQuality1; ///< Number of neighbors with link of quality 1.
|
||||
uint8_t mLeaderCost; ///< Cost to the Leader.
|
||||
uint8_t mIdSequence; ///< Most recent received ID seq number.
|
||||
uint8_t mActiveRouters; ///< Number of active routers.
|
||||
uint16_t mSedBufferSize; ///< Buffer capacity in bytes for SEDs. Optional.
|
||||
uint8_t mSedDatagramCount; ///< Queue capacity (number of IPv6 datagrams) per SED. Optional.
|
||||
} otNetworkDiagConnectivity;
|
||||
|
||||
/**
|
||||
* Represents a Network Diagnostic Route data.
|
||||
*/
|
||||
typedef struct otNetworkDiagRouteData
|
||||
{
|
||||
uint8_t mRouterId; ///< The Assigned Router ID.
|
||||
uint8_t mLinkQualityOut : 2; ///< Link Quality Out.
|
||||
uint8_t mLinkQualityIn : 2; ///< Link Quality In.
|
||||
uint8_t mRouteCost : 4; ///< Routing Cost. Infinite routing cost is represented by value 0.
|
||||
} otNetworkDiagRouteData;
|
||||
|
||||
/**
|
||||
* Represents a Network Diagnostic Route64 TLV value.
|
||||
*/
|
||||
typedef struct otNetworkDiagRoute
|
||||
{
|
||||
/**
|
||||
* The sequence number associated with the set of Router ID assignments in #mRouteData.
|
||||
*/
|
||||
uint8_t mIdSequence; ///< Sequence number for Router ID assignments.
|
||||
uint8_t mRouteCount; ///< Number of routes.
|
||||
otNetworkDiagRouteData mRouteData[OT_NETWORK_MAX_ROUTER_ID + 1]; ///< Link Quality and Routing Cost data.
|
||||
} otNetworkDiagRoute;
|
||||
|
||||
/**
|
||||
* Represents a Network Diagnostic Mac Counters value.
|
||||
*
|
||||
* See <a href="https://www.ietf.org/rfc/rfc2863">RFC 2863</a> for definitions of member fields.
|
||||
*/
|
||||
typedef struct otNetworkDiagMacCounters
|
||||
{
|
||||
uint32_t mIfInUnknownProtos;
|
||||
uint32_t mIfInErrors;
|
||||
uint32_t mIfOutErrors;
|
||||
uint32_t mIfInUcastPkts;
|
||||
uint32_t mIfInBroadcastPkts;
|
||||
uint32_t mIfInDiscards;
|
||||
uint32_t mIfOutUcastPkts;
|
||||
uint32_t mIfOutBroadcastPkts;
|
||||
uint32_t mIfOutDiscards;
|
||||
} otNetworkDiagMacCounters;
|
||||
|
||||
/**
|
||||
* Represents a Network Diagnostics MLE Counters value.
|
||||
*/
|
||||
typedef struct otNetworkDiagMleCounters
|
||||
{
|
||||
uint16_t mDisabledRole; ///< Number of times device entered disabled role.
|
||||
uint16_t mDetachedRole; ///< Number of times device entered detached role.
|
||||
uint16_t mChildRole; ///< Number of times device entered child role.
|
||||
uint16_t mRouterRole; ///< Number of times device entered router role.
|
||||
uint16_t mLeaderRole; ///< Number of times device entered leader role.
|
||||
uint16_t mAttachAttempts; ///< Number of attach attempts while device was detached.
|
||||
uint16_t mPartitionIdChanges; ///< Number of changes to partition ID.
|
||||
uint16_t mBetterPartitionAttachAttempts; ///< Number of attempts to attach to a better partition.
|
||||
uint16_t mParentChanges; ///< Number of time device changed its parent.
|
||||
uint64_t mTrackedTime; ///< Milliseconds tracked by next counters (zero if not supported).
|
||||
uint64_t mDisabledTime; ///< Milliseconds device has been in disabled role.
|
||||
uint64_t mDetachedTime; ///< Milliseconds device has been in detached role.
|
||||
uint64_t mChildTime; ///< Milliseconds device has been in child role.
|
||||
uint64_t mRouterTime; ///< Milliseconds device has been in router role.
|
||||
uint64_t mLeaderTime; ///< Milliseconds device has been in leader role.
|
||||
} otNetworkDiagMleCounters;
|
||||
|
||||
/**
|
||||
* Represents a Network Diagnostic Child Table Entry.
|
||||
*/
|
||||
typedef struct otNetworkDiagChildEntry
|
||||
{
|
||||
uint16_t mTimeout : 5; ///< Expected poll timeout expressed as 2^(Timeout-4) seconds.
|
||||
uint8_t mLinkQuality : 2; ///< Link Quality In value [0,3]. Zero indicate sender cannot provide link quality info.
|
||||
uint16_t mChildId : 9; ///< Child ID (derived from child RLOC)
|
||||
otLinkModeConfig mMode; ///< Link mode.
|
||||
} otNetworkDiagChildEntry;
|
||||
|
||||
/**
|
||||
* Represents a Network Diagnostic TLV.
|
||||
*/
|
||||
typedef struct otNetworkDiagTlv
|
||||
{
|
||||
uint8_t mType; ///< The Network Diagnostic TLV type.
|
||||
|
||||
union
|
||||
{
|
||||
otExtAddress mExtAddress;
|
||||
otExtAddress mEui64;
|
||||
uint16_t mAddr16;
|
||||
otLinkModeConfig mMode;
|
||||
uint32_t mTimeout;
|
||||
otNetworkDiagConnectivity mConnectivity;
|
||||
otNetworkDiagRoute mRoute;
|
||||
otLeaderData mLeaderData;
|
||||
otNetworkDiagMacCounters mMacCounters;
|
||||
otNetworkDiagMleCounters mMleCounters;
|
||||
uint8_t mBatteryLevel;
|
||||
uint16_t mSupplyVoltage;
|
||||
uint32_t mMaxChildTimeout;
|
||||
uint16_t mVersion;
|
||||
char mVendorName[OT_NETWORK_DIAGNOSTIC_MAX_VENDOR_NAME_TLV_LENGTH + 1];
|
||||
char mVendorModel[OT_NETWORK_DIAGNOSTIC_MAX_VENDOR_MODEL_TLV_LENGTH + 1];
|
||||
char mVendorSwVersion[OT_NETWORK_DIAGNOSTIC_MAX_VENDOR_SW_VERSION_TLV_LENGTH + 1];
|
||||
char mThreadStackVersion[OT_NETWORK_DIAGNOSTIC_MAX_THREAD_STACK_VERSION_TLV_LENGTH + 1];
|
||||
char mVendorAppUrl[OT_NETWORK_DIAGNOSTIC_MAX_VENDOR_APP_URL_TLV_LENGTH + 1];
|
||||
struct
|
||||
{
|
||||
uint8_t mCount;
|
||||
uint8_t m8[OT_NETWORK_BASE_TLV_MAX_LENGTH];
|
||||
} mNetworkData;
|
||||
struct
|
||||
{
|
||||
uint8_t mCount;
|
||||
otIp6Address mList[OT_NETWORK_BASE_TLV_MAX_LENGTH / sizeof(otIp6Address)];
|
||||
} mIp6AddrList;
|
||||
struct
|
||||
{
|
||||
uint8_t mCount;
|
||||
otNetworkDiagChildEntry mTable[OT_NETWORK_BASE_TLV_MAX_LENGTH / sizeof(otNetworkDiagChildEntry)];
|
||||
} mChildTable;
|
||||
struct
|
||||
{
|
||||
uint8_t mCount;
|
||||
uint8_t m8[OT_NETWORK_BASE_TLV_MAX_LENGTH];
|
||||
} mChannelPages;
|
||||
} mData;
|
||||
} otNetworkDiagTlv;
|
||||
|
||||
/**
|
||||
* Gets the next Network Diagnostic TLV in the message.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE`.
|
||||
*
|
||||
* @param[in] aMessage A pointer to a message.
|
||||
* @param[in,out] aIterator A pointer to the Network Diagnostic iterator context. To get the first
|
||||
* Network Diagnostic TLV it should be set to OT_NETWORK_DIAGNOSTIC_ITERATOR_INIT.
|
||||
* @param[out] aNetworkDiagTlv A pointer to where the Network Diagnostic TLV information will be placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully found the next Network Diagnostic TLV.
|
||||
* @retval OT_ERROR_NOT_FOUND No subsequent Network Diagnostic TLV exists in the message.
|
||||
* @retval OT_ERROR_PARSE Parsing the next Network Diagnostic failed.
|
||||
*
|
||||
* @Note A subsequent call to this function is allowed only when current return value is OT_ERROR_NONE.
|
||||
*/
|
||||
otError otThreadGetNextDiagnosticTlv(const otMessage *aMessage,
|
||||
otNetworkDiagIterator *aIterator,
|
||||
otNetworkDiagTlv *aNetworkDiagTlv);
|
||||
|
||||
/**
|
||||
* Pointer is called when Network Diagnostic Get response is received.
|
||||
*
|
||||
* @param[in] aError The error when failed to get the response.
|
||||
* @param[in] aMessage A pointer to the message buffer containing the received Network Diagnostic
|
||||
* Get response payload. Available only when @p aError is `OT_ERROR_NONE`.
|
||||
* @param[in] aMessageInfo A pointer to the message info for @p aMessage. Available only when
|
||||
* @p aError is `OT_ERROR_NONE`.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otReceiveDiagnosticGetCallback)(otError aError,
|
||||
otMessage *aMessage,
|
||||
const otMessageInfo *aMessageInfo,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Send a Network Diagnostic Get request.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDestination A pointer to destination address.
|
||||
* @param[in] aTlvTypes An array of Network Diagnostic TLV types.
|
||||
* @param[in] aCount Number of types in aTlvTypes.
|
||||
* @param[in] aCallback A pointer to a function that is called when Network Diagnostic Get response
|
||||
* is received or NULL to disable the callback.
|
||||
* @param[in] aCallbackContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully queued the DIAG_GET.req.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient message buffers available to send DIAG_GET.req.
|
||||
*/
|
||||
otError otThreadSendDiagnosticGet(otInstance *aInstance,
|
||||
const otIp6Address *aDestination,
|
||||
const uint8_t aTlvTypes[],
|
||||
uint8_t aCount,
|
||||
otReceiveDiagnosticGetCallback aCallback,
|
||||
void *aCallbackContext);
|
||||
|
||||
/**
|
||||
* Send a Network Diagnostic Reset request.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDestination A pointer to destination address.
|
||||
* @param[in] aTlvTypes An array of Network Diagnostic TLV types. Currently only Type 9 is allowed.
|
||||
* @param[in] aCount Number of types in aTlvTypes
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully queued the DIAG_RST.ntf.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient message buffers available to send DIAG_RST.ntf.
|
||||
*/
|
||||
otError otThreadSendDiagnosticReset(otInstance *aInstance,
|
||||
const otIp6Address *aDestination,
|
||||
const uint8_t aTlvTypes[],
|
||||
uint8_t aCount);
|
||||
|
||||
/**
|
||||
* Get the vendor name string.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The vendor name string.
|
||||
*/
|
||||
const char *otThreadGetVendorName(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the vendor model string.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The vendor model string.
|
||||
*/
|
||||
const char *otThreadGetVendorModel(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the vendor software version string.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The vendor software version string.
|
||||
*/
|
||||
const char *otThreadGetVendorSwVersion(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the vendor app URL string.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The vendor app URL string.
|
||||
*/
|
||||
const char *otThreadGetVendorAppUrl(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the vendor name string.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_NET_DIAG_VENDOR_INFO_SET_API_ENABLE`.
|
||||
*
|
||||
* @p aVendorName should be UTF8 with max length of 32 chars (`MAX_VENDOR_NAME_TLV_LENGTH`). Maximum length does not
|
||||
* include the null `\0` character.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aVendorName The vendor name string.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the vendor name.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aVendorName is not valid (too long or not UTF8).
|
||||
*/
|
||||
otError otThreadSetVendorName(otInstance *aInstance, const char *aVendorName);
|
||||
|
||||
/**
|
||||
* Set the vendor model string.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_NET_DIAG_VENDOR_INFO_SET_API_ENABLE`.
|
||||
*
|
||||
* @p aVendorModel should be UTF8 with max length of 32 chars (`MAX_VENDOR_MODEL_TLV_LENGTH`). Maximum length does not
|
||||
* include the null `\0` character.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aVendorModel The vendor model string.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the vendor model.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aVendorModel is not valid (too long or not UTF8).
|
||||
*/
|
||||
otError otThreadSetVendorModel(otInstance *aInstance, const char *aVendorModel);
|
||||
|
||||
/**
|
||||
* Set the vendor software version string.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_NET_DIAG_VENDOR_INFO_SET_API_ENABLE`.
|
||||
*
|
||||
* @p aVendorSwVersion should be UTF8 with max length of 16 chars(`MAX_VENDOR_SW_VERSION_TLV_LENGTH`). Maximum length
|
||||
* does not include the null `\0` character.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aVendorSwVersion The vendor software version string.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the vendor software version.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aVendorSwVersion is not valid (too long or not UTF8).
|
||||
*/
|
||||
otError otThreadSetVendorSwVersion(otInstance *aInstance, const char *aVendorSwVersion);
|
||||
|
||||
/**
|
||||
* Set the vendor app URL string.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_NET_DIAG_VENDOR_INFO_SET_API_ENABLE`.
|
||||
*
|
||||
* @p aVendorAppUrl should be UTF8 with max length of 64 chars (`MAX_VENDOR_APPL_URL_TLV_LENGTH`). Maximum length
|
||||
* does not include the null `\0` character.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aVendorAppUrl The vendor app URL string.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the vendor app URL string.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aVendorAppUrl is not valid (too long or not UTF8).
|
||||
*/
|
||||
otError otThreadSetVendorAppUrl(otInstance *aInstance, const char *aVendorAppUrl);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_NETDIAG_H_
|
||||
150
Libs/util/third_party/openthread/include/openthread/network_time.h
vendored
Normal file
150
Libs/util/third_party/openthread/include/openthread/network_time.h
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Network Time Synchronization Service API.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_NETWORK_TIME_H_
|
||||
#define OPENTHREAD_NETWORK_TIME_H_
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-network-time
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control network time synchronization service.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents OpenThread time synchronization status.
|
||||
*/
|
||||
typedef enum otNetworkTimeStatus
|
||||
{
|
||||
OT_NETWORK_TIME_UNSYNCHRONIZED = -1, ///< The device hasn't attached to a network.
|
||||
OT_NETWORK_TIME_RESYNC_NEEDED = 0, ///< The device hasn’t received time sync for more than two periods time.
|
||||
OT_NETWORK_TIME_SYNCHRONIZED = 1, ///< The device network time is synchronized.
|
||||
} otNetworkTimeStatus;
|
||||
|
||||
/**
|
||||
* Pointer is called when a network time sync or status change occurs.
|
||||
*/
|
||||
typedef void (*otNetworkTimeSyncCallbackFn)(void *aCallbackContext);
|
||||
|
||||
/**
|
||||
* zero is considered as invalid time synchronization sequence.
|
||||
*/
|
||||
#define OT_TIME_SYNC_INVALID_SEQ 0
|
||||
|
||||
/**
|
||||
* Get the Thread network time.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in,out] aNetworkTime The Thread network time in microseconds.
|
||||
*
|
||||
* @returns The time synchronization status.
|
||||
*/
|
||||
otNetworkTimeStatus otNetworkTimeGet(otInstance *aInstance, uint64_t *aNetworkTime);
|
||||
|
||||
/**
|
||||
* Set the time synchronization period.
|
||||
*
|
||||
* Can only be called while Thread protocols are disabled.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aTimeSyncPeriod The time synchronization period, in seconds.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the time sync period.
|
||||
* @retval OT_ERROR_INVALID_STATE Thread protocols are enabled.
|
||||
*/
|
||||
otError otNetworkTimeSetSyncPeriod(otInstance *aInstance, uint16_t aTimeSyncPeriod);
|
||||
|
||||
/**
|
||||
* Get the time synchronization period.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @returns The time synchronization period.
|
||||
*/
|
||||
uint16_t otNetworkTimeGetSyncPeriod(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the time synchronization XTAL accuracy threshold for Router-Capable device.
|
||||
*
|
||||
* Can only be called while Thread protocols are disabled.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aXTALThreshold The XTAL accuracy threshold for Router, in PPM.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the time sync period.
|
||||
* @retval OT_ERROR_INVALID_STATE Thread protocols are enabled.
|
||||
*/
|
||||
otError otNetworkTimeSetXtalThreshold(otInstance *aInstance, uint16_t aXTALThreshold);
|
||||
|
||||
/**
|
||||
* Get the time synchronization XTAL accuracy threshold for Router.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @returns The XTAL accuracy threshold for Router, in PPM.
|
||||
*/
|
||||
uint16_t otNetworkTimeGetXtalThreshold(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set a callback to be called when a network time sync or status change occurs
|
||||
*
|
||||
* This callback shall be called only when the network time offset jumps by
|
||||
* OPENTHREAD_CONFIG_TIME_SYNC_JUMP_NOTIF_MIN_US or when the status changes.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aCallbackFn The callback function to be called
|
||||
* @param[in] aCallbackContext The context to be passed to the callback function upon invocation
|
||||
*/
|
||||
void otNetworkTimeSyncSetCallback(otInstance *aInstance,
|
||||
otNetworkTimeSyncCallbackFn aCallbackFn,
|
||||
void *aCallbackContext);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_NETWORK_TIME_H_
|
||||
148
Libs/util/third_party/openthread/include/openthread/ping_sender.h
vendored
Normal file
148
Libs/util/third_party/openthread/include/openthread/ping_sender.h
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the OpenThread API for ping sender module.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PING_SENDER_H_
|
||||
#define OPENTHREAD_PING_SENDER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/ip6.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-ping-sender
|
||||
*
|
||||
* @brief
|
||||
* This file includes the OpenThread API for the ping sender module.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a ping reply.
|
||||
*/
|
||||
typedef struct otPingSenderReply
|
||||
{
|
||||
otIp6Address mSenderAddress; ///< Sender IPv6 address (address from which ping reply was received).
|
||||
uint16_t mRoundTripTime; ///< Round trip time in msec.
|
||||
uint16_t mSize; ///< Data size (number of bytes) in reply (excluding IPv6 and ICMP6 headers).
|
||||
uint16_t mSequenceNumber; ///< Sequence number.
|
||||
uint8_t mHopLimit; ///< Hop limit.
|
||||
} otPingSenderReply;
|
||||
|
||||
/**
|
||||
* Represents statistics of a ping request.
|
||||
*/
|
||||
typedef struct otPingSenderStatistics
|
||||
{
|
||||
uint16_t mSentCount; ///< The number of ping requests already sent.
|
||||
uint16_t mReceivedCount; ///< The number of ping replies received.
|
||||
uint32_t mTotalRoundTripTime; ///< The total round trip time of ping requests.
|
||||
uint16_t mMinRoundTripTime; ///< The min round trip time among ping requests.
|
||||
uint16_t mMaxRoundTripTime; ///< The max round trip time among ping requests.
|
||||
bool mIsMulticast; ///< Whether this is a multicast ping request.
|
||||
} otPingSenderStatistics;
|
||||
|
||||
/**
|
||||
* Pointer type specifies the callback to notify receipt of a ping reply.
|
||||
*
|
||||
* @param[in] aReply A pointer to a `otPingSenderReply` containing info about the received ping reply.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otPingSenderReplyCallback)(const otPingSenderReply *aReply, void *aContext);
|
||||
|
||||
/**
|
||||
* Pointer type specifies the callback to report the ping statistics.
|
||||
*
|
||||
* @param[in] aStatistics A pointer to a `otPingSenderStatistics` containing info about the received ping
|
||||
* statistics.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
typedef void (*otPingSenderStatisticsCallback)(const otPingSenderStatistics *aStatistics, void *aContext);
|
||||
|
||||
/**
|
||||
* Represents a ping request configuration.
|
||||
*/
|
||||
typedef struct otPingSenderConfig
|
||||
{
|
||||
otIp6Address mSource; ///< Source address of the ping.
|
||||
otIp6Address mDestination; ///< Destination address to ping.
|
||||
otPingSenderReplyCallback mReplyCallback; ///< Callback function to report replies (can be NULL if not needed).
|
||||
otPingSenderStatisticsCallback
|
||||
mStatisticsCallback; ///< Callback function to report statistics (can be NULL if not needed).
|
||||
void *mCallbackContext; ///< A pointer to the callback application-specific context.
|
||||
uint16_t mSize; ///< Data size (# of bytes) excludes IPv6/ICMPv6 header. Zero for default.
|
||||
uint16_t mCount; ///< Number of ping messages to send. Zero to use default.
|
||||
uint32_t mInterval; ///< Ping tx interval in milliseconds. Zero to use default.
|
||||
uint16_t mTimeout; ///< Time in milliseconds to wait for final reply after sending final request.
|
||||
///< Zero to use default.
|
||||
uint8_t mHopLimit; ///< Hop limit (used if `mAllowZeroHopLimit` is false). Zero for default.
|
||||
bool mAllowZeroHopLimit; ///< Indicates whether hop limit is zero.
|
||||
bool mMulticastLoop; ///< Allow looping back pings to multicast address that device is subscribed to.
|
||||
} otPingSenderConfig;
|
||||
|
||||
/**
|
||||
* Starts a ping.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aConfig The ping config to use.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The ping started successfully.
|
||||
* @retval OT_ERROR_BUSY Could not start since busy with a previous ongoing ping request.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aConfig contains invalid parameters (e.g., ping interval is too long).
|
||||
|
||||
*/
|
||||
otError otPingSenderPing(otInstance *aInstance, const otPingSenderConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Stops an ongoing ping.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otPingSenderStop(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PING_SENDER_H_
|
||||
96
Libs/util/third_party/openthread/include/openthread/platform/alarm-micro.h
vendored
Normal file
96
Libs/util/third_party/openthread/include/openthread/platform/alarm-micro.h
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform abstraction for the microsecond alarm service.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_ALARM_MICRO_H_
|
||||
#define OPENTHREAD_PLATFORM_ALARM_MICRO_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-alarm
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set the alarm to fire at @p aDt microseconds after @p aT0.
|
||||
*
|
||||
* For @p aT0, the platform MUST support all values in [0, 2^32-1].
|
||||
* For @p aDt, the platform MUST support all values in [0, 2^31-1].
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aT0 The reference time.
|
||||
* @param[in] aDt The time delay in microseconds from @p aT0.
|
||||
*/
|
||||
void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt);
|
||||
|
||||
/**
|
||||
* Stop the alarm.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
void otPlatAlarmMicroStop(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the current time.
|
||||
*
|
||||
* The current time MUST represent a free-running timer. When maintaining current time, the time value MUST utilize the
|
||||
* entire range [0, 2^32-1] and MUST NOT wrap before 2^32.
|
||||
*
|
||||
* @returns The current time in microseconds.
|
||||
*/
|
||||
uint32_t otPlatAlarmMicroGetNow(void);
|
||||
|
||||
/**
|
||||
* Signal that the alarm has fired.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
extern void otPlatAlarmMicroFired(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_ALARM_MICRO_H_
|
||||
106
Libs/util/third_party/openthread/include/openthread/platform/alarm-milli.h
vendored
Normal file
106
Libs/util/third_party/openthread/include/openthread/platform/alarm-milli.h
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform abstraction for the millisecond alarm service.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_ALARM_MILLI_H_
|
||||
#define OPENTHREAD_PLATFORM_ALARM_MILLI_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-alarm
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for the alarm service.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set the alarm to fire at @p aDt milliseconds after @p aT0.
|
||||
*
|
||||
* For @p aT0 the platform MUST support all values in [0, 2^32-1].
|
||||
* For @p aDt, the platform MUST support all values in [0, 2^31-1].
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aT0 The reference time.
|
||||
* @param[in] aDt The time delay in milliseconds from @p aT0.
|
||||
*/
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt);
|
||||
|
||||
/**
|
||||
* Stop the alarm.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
void otPlatAlarmMilliStop(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the current time.
|
||||
*
|
||||
* The current time MUST represent a free-running timer. When maintaining current time, the time value MUST utilize the
|
||||
* entire range [0, 2^32-1] and MUST NOT wrap before 2^32.
|
||||
*
|
||||
* @returns The current time in milliseconds.
|
||||
*/
|
||||
uint32_t otPlatAlarmMilliGetNow(void);
|
||||
|
||||
/**
|
||||
* Signal that the alarm has fired.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
extern void otPlatAlarmMilliFired(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Signal diagnostics module that the alarm has fired.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
extern void otPlatDiagAlarmFired(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_ALARM_MILLI_H_
|
||||
333
Libs/util/third_party/openthread/include/openthread/platform/ble.h
vendored
Normal file
333
Libs/util/third_party/openthread/include/openthread/platform/ble.h
vendored
Normal file
@@ -0,0 +1,333 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines a OpenThread BLE GATT peripheral interface driver.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_BLE_H_
|
||||
#define OPENTHREAD_PLATFORM_BLE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/instance.h>
|
||||
|
||||
/**
|
||||
* @addtogroup plat-ble
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for BLE Host communication.
|
||||
* The platform needs to implement Bluetooth LE 4.2 or higher.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time slot duration on PHY layer in microseconds (0.625ms).
|
||||
*/
|
||||
|
||||
#define OT_BLE_TIMESLOT_UNIT 625
|
||||
|
||||
/**
|
||||
* Minimum allowed interval for advertising packet in OT_BLE_ADV_INTERVAL_UNIT units (20ms).
|
||||
*/
|
||||
|
||||
#define OT_BLE_ADV_INTERVAL_MIN 0x0020
|
||||
|
||||
/**
|
||||
* Maximum allowed interval for advertising packet in OT_BLE_ADV_INTERVAL_UNIT units (10.24s).
|
||||
*/
|
||||
|
||||
#define OT_BLE_ADV_INTERVAL_MAX 0x4000
|
||||
|
||||
/**
|
||||
* Default interval for advertising packet (ms).
|
||||
*/
|
||||
|
||||
#define OT_BLE_ADV_INTERVAL_DEFAULT 100
|
||||
|
||||
/**
|
||||
* Unit used to calculate interval duration (0.625ms).
|
||||
*/
|
||||
|
||||
#define OT_BLE_ADV_INTERVAL_UNIT OT_BLE_TIMESLOT_UNIT
|
||||
|
||||
/**
|
||||
* Maximum allowed ATT MTU size (must be >= 23).
|
||||
*/
|
||||
|
||||
#define OT_BLE_ATT_MTU_MAX 67
|
||||
|
||||
/**
|
||||
* Default power value for BLE.
|
||||
*/
|
||||
|
||||
#define OT_BLE_DEFAULT_POWER 0
|
||||
|
||||
/**
|
||||
* TOBLE service UUID
|
||||
*/
|
||||
|
||||
#define OT_TOBLE_SERVICE_UUID 0xfffb
|
||||
|
||||
/**
|
||||
* Represent BLE link capabilities
|
||||
*/
|
||||
typedef struct otBleLinkCapabilities
|
||||
{
|
||||
uint8_t mRsv : 6;
|
||||
bool mL2CapDirect : 1;
|
||||
bool mGattNotifications : 1;
|
||||
} otBleLinkCapabilities;
|
||||
|
||||
/**
|
||||
* Represents a BLE packet.
|
||||
*/
|
||||
typedef struct otBleRadioPacket
|
||||
{
|
||||
uint8_t *mValue; ///< The value of an attribute
|
||||
uint16_t mLength; ///< Length of the @p mValue.
|
||||
int8_t mPower; ///< Transmit/receive power in dBm.
|
||||
} otBleRadioPacket;
|
||||
|
||||
/*******************************************************************************
|
||||
* @section Bluetooth Low Energy management.
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Enable the Bluetooth Low Energy radio.
|
||||
*
|
||||
* @note BLE Device should use the highest ATT_MTU supported that does not
|
||||
* exceed OT_BLE_ATT_MTU_MAX octets.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully enabled.
|
||||
* @retval OT_ERROR_FAILED The BLE radio could not be enabled.
|
||||
*/
|
||||
otError otPlatBleEnable(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Disable the Bluetooth Low Energy radio.
|
||||
*
|
||||
* When disabled, the BLE stack will flush event queues and not generate new
|
||||
* events. The BLE peripheral is turned off or put into a low power sleep
|
||||
* state. Any dynamic memory used by the stack should be released,
|
||||
* but static memory may remain reserved.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully transitioned to disabled.
|
||||
* @retval OT_ERROR_FAILED The BLE radio could not be disabled.
|
||||
*/
|
||||
otError otPlatBleDisable(otInstance *aInstance);
|
||||
|
||||
/****************************************************************************
|
||||
* @section Bluetooth Low Energy GAP.
|
||||
***************************************************************************/
|
||||
/**
|
||||
* Gets BLE Advertising buffer.
|
||||
*
|
||||
* @note This function shall be used only for BLE Peripheral role.
|
||||
* Returned buffer should have enough space to fit max advertisement
|
||||
* defined by specification.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aAdvertisementData The formatted TCAT advertisement frame.
|
||||
* @param[in] aAdvertisementLen The TCAT advertisement frame length.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Advertising procedure has been started.
|
||||
* @retval OT_ERROR_NO_BUFS No bufferspace available.
|
||||
*/
|
||||
otError otPlatBleGetAdvertisementBuffer(otInstance *aInstance, uint8_t **aAdvertisementBuffer);
|
||||
|
||||
/**
|
||||
* Sets BLE Advertising data.
|
||||
*
|
||||
* @note This function shall be used only for BLE Peripheral role.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aAdvertisementData The formatted TCAT advertisement frame.
|
||||
* @param[in] aAdvertisementLen The TCAT advertisement frame length.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Advertising procedure has been started.
|
||||
* @retval OT_ERROR_INVALID_STATE BLE Device is in invalid state.
|
||||
* @retval OT_ERROR_INVALID_ARGS Invalid value has been supplied.
|
||||
*/
|
||||
otError otPlatBleGapAdvSetData(otInstance *aInstance, uint8_t *aAdvertisementData, uint16_t aAdvertisementLen);
|
||||
|
||||
/**
|
||||
* Starts BLE Advertising procedure.
|
||||
*
|
||||
* The BLE device shall use undirected advertising with no filter applied.
|
||||
* A single BLE Advertising packet must be sent on all advertising
|
||||
* channels (37, 38 and 39).
|
||||
*
|
||||
* @note This function shall be used only for BLE Peripheral role.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aInterval The interval between subsequent advertising packets
|
||||
* in OT_BLE_ADV_INTERVAL_UNIT units.
|
||||
* Shall be within OT_BLE_ADV_INTERVAL_MIN and
|
||||
* OT_BLE_ADV_INTERVAL_MAX range or OT_BLE_ADV_INTERVAL_DEFAULT
|
||||
* for a default value set at compile time.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Advertising procedure has been started.
|
||||
* @retval OT_ERROR_INVALID_STATE BLE Device is in invalid state.
|
||||
* @retval OT_ERROR_INVALID_ARGS Invalid interval value has been supplied.
|
||||
*/
|
||||
otError otPlatBleGapAdvStart(otInstance *aInstance, uint16_t aInterval);
|
||||
|
||||
/**
|
||||
* Stops BLE Advertising procedure.
|
||||
*
|
||||
* @note This function shall be used only for BLE Peripheral role.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Advertising procedure has been stopped.
|
||||
* @retval OT_ERROR_INVALID_STATE BLE Device is in invalid state.
|
||||
*/
|
||||
otError otPlatBleGapAdvStop(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* The BLE driver calls this method to notify OpenThread that a BLE Central Device has
|
||||
* been connected.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aConnectionId The identifier of the open connection.
|
||||
*/
|
||||
extern void otPlatBleGapOnConnected(otInstance *aInstance, uint16_t aConnectionId);
|
||||
|
||||
/**
|
||||
* The BLE driver calls this method to notify OpenThread that the BLE Central Device
|
||||
* has been disconnected.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aConnectionId The identifier of the closed connection.
|
||||
*/
|
||||
extern void otPlatBleGapOnDisconnected(otInstance *aInstance, uint16_t aConnectionId);
|
||||
|
||||
/**
|
||||
* Disconnects BLE connection.
|
||||
*
|
||||
* The BLE device shall use the Remote User Terminated Connection (0x13) reason
|
||||
* code when disconnecting from the peer BLE device..
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Disconnection procedure has been started.
|
||||
* @retval OT_ERROR_INVALID_STATE BLE Device is in invalid state.
|
||||
*/
|
||||
otError otPlatBleGapDisconnect(otInstance *aInstance);
|
||||
|
||||
/*******************************************************************************
|
||||
* @section Bluetooth Low Energy GATT Common.
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* Reads currently use value of ATT_MTU.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[out] aMtu A pointer to output the current ATT_MTU value.
|
||||
*
|
||||
* @retval OT_ERROR_NONE ATT_MTU value has been placed in @p aMtu.
|
||||
* @retval OT_ERROR_FAILED BLE Device cannot determine its ATT_MTU.
|
||||
*/
|
||||
otError otPlatBleGattMtuGet(otInstance *aInstance, uint16_t *aMtu);
|
||||
|
||||
/**
|
||||
* The BLE driver calls this method to notify OpenThread that ATT_MTU has been updated.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aMtu The updated ATT_MTU value.
|
||||
*/
|
||||
extern void otPlatBleGattOnMtuUpdate(otInstance *aInstance, uint16_t aMtu);
|
||||
|
||||
/*******************************************************************************
|
||||
* @section Bluetooth Low Energy GATT Server.
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Sends ATT Handle Value Indication.
|
||||
*
|
||||
* @note This function shall be used only for GATT Server.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aHandle The handle of the attribute to be indicated.
|
||||
* @param[in] aPacket A pointer to the packet contains value to be indicated.
|
||||
*
|
||||
* @retval OT_ERROR_NONE ATT Handle Value Indication has been sent.
|
||||
* @retval OT_ERROR_INVALID_STATE BLE Device is in invalid state.
|
||||
* @retval OT_ERROR_INVALID_ARGS Invalid handle value, data or data length has been supplied.
|
||||
* @retval OT_ERROR_NO_BUFS No available internal buffer found.
|
||||
*/
|
||||
otError otPlatBleGattServerIndicate(otInstance *aInstance, uint16_t aHandle, const otBleRadioPacket *aPacket);
|
||||
|
||||
/**
|
||||
* The BLE driver calls this method to notify OpenThread that an ATT Write Request
|
||||
* packet has been received.
|
||||
*
|
||||
* @note This function shall be used only for GATT Server.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aHandle The handle of the attribute to be written.
|
||||
* @param[in] aPacket A pointer to the packet contains value to be written to the attribute.
|
||||
*/
|
||||
extern void otPlatBleGattServerOnWriteRequest(otInstance *aInstance, uint16_t aHandle, const otBleRadioPacket *aPacket);
|
||||
|
||||
/**
|
||||
* Function to retrieve from platform BLE link capabilities.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[out] aBleLinkCapabilities The pointer to retrieve the BLE ling capabilities.
|
||||
*/
|
||||
void otPlatBleGetLinkCapabilities(otInstance *aInstance, otBleLinkCapabilities *aBleLinkCapabilities);
|
||||
|
||||
/**
|
||||
* Function to retrieve from platform multiradio support of BLE and IEEE.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
bool otPlatBleSupportsMultiRadio(otInstance *aInstance);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_BLE_H_
|
||||
89
Libs/util/third_party/openthread/include/openthread/platform/border_routing.h
vendored
Normal file
89
Libs/util/third_party/openthread/include/openthread/platform/border_routing.h
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform abstraction for border routing manager.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_BORDER_ROUTER_H_
|
||||
#define OPENTHREAD_PLATFORM_BORDER_ROUTER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handles ICMP6 RA messages received on the Thread interface on the platform.
|
||||
*
|
||||
* The `aMessage` should point to a buffer of a valid ICMPv6 message (without IP headers) with router advertisement as
|
||||
* the value of type field of the message.
|
||||
*
|
||||
* When DHCPv6 PD is disabled, the message will be dropped silently.
|
||||
*
|
||||
* Note: RA messages will not be forwarded into Thread networks, while for many platforms, RA messages is the way of
|
||||
* distributing a prefix and other infomations to the downstream network. The typical usecase of this function is to
|
||||
* handle the router advertisement messages sent by the platform as a result of DHCPv6 Prefix Delegation.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMessage A pointer to an ICMPv6 RouterAdvertisement message.
|
||||
* @param[in] aLength The length of ICMPv6 RouterAdvertisement message.
|
||||
*/
|
||||
extern void otPlatBorderRoutingProcessIcmp6Ra(otInstance *aInstance, const uint8_t *aMessage, uint16_t aLength);
|
||||
|
||||
/**
|
||||
* Process a prefix received from the DHCPv6 PD Server. The prefix is received on
|
||||
* the DHCPv6 PD client callback and provided to the Routing Manager via this
|
||||
* API.
|
||||
*
|
||||
* The prefix lifetime can be updated by calling the function again with updated time values.
|
||||
* If the preferred lifetime of the prefix is set to 0, the prefix becomes deprecated.
|
||||
* When this function is called multiple times, the smallest prefix is preferred as this rule allows
|
||||
* choosing a GUA instead of a ULA.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPrefixInfo A pointer to the prefix information structure
|
||||
*/
|
||||
extern void otPlatBorderRoutingProcessDhcp6PdPrefix(otInstance *aInstance,
|
||||
const otBorderRoutingPrefixTableEntry *aPrefixInfo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_BORDER_ROUTER_H_
|
||||
715
Libs/util/third_party/openthread/include/openthread/platform/crypto.h
vendored
Normal file
715
Libs/util/third_party/openthread/include/openthread/platform/crypto.h
vendored
Normal file
@@ -0,0 +1,715 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform abstraction for Crypto operations.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_CRYPTO_H_
|
||||
#define OPENTHREAD_PLATFORM_CRYPTO_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-crypto
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for Crypto.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Defines the key types.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_CRYPTO_KEY_TYPE_RAW, ///< Key Type: Raw Data.
|
||||
OT_CRYPTO_KEY_TYPE_AES, ///< Key Type: AES.
|
||||
OT_CRYPTO_KEY_TYPE_HMAC, ///< Key Type: HMAC.
|
||||
OT_CRYPTO_KEY_TYPE_ECDSA, ///< Key Type: ECDSA.
|
||||
} otCryptoKeyType;
|
||||
|
||||
/**
|
||||
* Defines the key algorithms.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_CRYPTO_KEY_ALG_VENDOR, ///< Key Algorithm: Vendor Defined.
|
||||
OT_CRYPTO_KEY_ALG_AES_ECB, ///< Key Algorithm: AES ECB.
|
||||
OT_CRYPTO_KEY_ALG_HMAC_SHA_256, ///< Key Algorithm: HMAC SHA-256.
|
||||
OT_CRYPTO_KEY_ALG_ECDSA, ///< Key Algorithm: ECDSA.
|
||||
} otCryptoKeyAlgorithm;
|
||||
|
||||
/**
|
||||
* Defines the key usage flags.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
OT_CRYPTO_KEY_USAGE_NONE = 0, ///< Key Usage: Key Usage is empty.
|
||||
OT_CRYPTO_KEY_USAGE_EXPORT = 1 << 0, ///< Key Usage: Key can be exported.
|
||||
OT_CRYPTO_KEY_USAGE_ENCRYPT = 1 << 1, ///< Key Usage: Encryption (vendor defined).
|
||||
OT_CRYPTO_KEY_USAGE_DECRYPT = 1 << 2, ///< Key Usage: AES ECB.
|
||||
OT_CRYPTO_KEY_USAGE_SIGN_HASH = 1 << 3, ///< Key Usage: Sign Hash.
|
||||
OT_CRYPTO_KEY_USAGE_VERIFY_HASH = 1 << 4, ///< Key Usage: Verify Hash.
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines the key storage types.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_CRYPTO_KEY_STORAGE_VOLATILE, ///< Key Persistence: Key is volatile.
|
||||
OT_CRYPTO_KEY_STORAGE_PERSISTENT, ///< Key Persistence: Key is persistent.
|
||||
} otCryptoKeyStorage;
|
||||
|
||||
/**
|
||||
* This datatype represents the key reference.
|
||||
*/
|
||||
typedef uint32_t otCryptoKeyRef;
|
||||
|
||||
/**
|
||||
* @struct otCryptoKey
|
||||
*
|
||||
* Represents the Key Material required for Crypto operations.
|
||||
*/
|
||||
typedef struct otCryptoKey
|
||||
{
|
||||
const uint8_t *mKey; ///< Pointer to the buffer containing key. NULL indicates to use `mKeyRef`.
|
||||
uint16_t mKeyLength; ///< The key length in bytes (applicable when `mKey` is not NULL).
|
||||
uint32_t mKeyRef; ///< The PSA key ref (requires `mKey` to be NULL).
|
||||
} otCryptoKey;
|
||||
|
||||
/**
|
||||
* @struct otCryptoContext
|
||||
*
|
||||
* Stores the context object for platform APIs.
|
||||
*/
|
||||
typedef struct otCryptoContext
|
||||
{
|
||||
void *mContext; ///< Pointer to the context.
|
||||
uint16_t mContextSize; ///< The length of the context in bytes.
|
||||
} otCryptoContext;
|
||||
|
||||
/**
|
||||
* Length of SHA256 hash (in bytes).
|
||||
*/
|
||||
#define OT_CRYPTO_SHA256_HASH_SIZE 32
|
||||
|
||||
/**
|
||||
* @struct otPlatCryptoSha256Hash
|
||||
*
|
||||
* Represents a SHA-256 hash.
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otPlatCryptoSha256Hash
|
||||
{
|
||||
uint8_t m8[OT_CRYPTO_SHA256_HASH_SIZE]; ///< Hash bytes.
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* Represents a SHA-256 hash.
|
||||
*/
|
||||
typedef struct otPlatCryptoSha256Hash otPlatCryptoSha256Hash;
|
||||
|
||||
/**
|
||||
* Max buffer size (in bytes) for representing the EDCSA key-pair in DER format.
|
||||
*/
|
||||
#define OT_CRYPTO_ECDSA_MAX_DER_SIZE 125
|
||||
|
||||
/**
|
||||
* @struct otPlatCryptoEcdsaKeyPair
|
||||
*
|
||||
* Represents an ECDSA key pair (public and private keys).
|
||||
*
|
||||
* The key pair is stored using Distinguished Encoding Rules (DER) format (per RFC 5915).
|
||||
*/
|
||||
typedef struct otPlatCryptoEcdsaKeyPair
|
||||
{
|
||||
uint8_t mDerBytes[OT_CRYPTO_ECDSA_MAX_DER_SIZE];
|
||||
uint8_t mDerLength;
|
||||
} otPlatCryptoEcdsaKeyPair;
|
||||
|
||||
/**
|
||||
* Buffer size (in bytes) for representing the EDCSA public key.
|
||||
*/
|
||||
#define OT_CRYPTO_ECDSA_PUBLIC_KEY_SIZE 64
|
||||
|
||||
/**
|
||||
* @struct otPlatCryptoEcdsaPublicKey
|
||||
*
|
||||
* Represents a ECDSA public key.
|
||||
*
|
||||
* The public key is stored as a byte sequence representation of an uncompressed curve point (RFC 6605 - sec 4).
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otPlatCryptoEcdsaPublicKey
|
||||
{
|
||||
uint8_t m8[OT_CRYPTO_ECDSA_PUBLIC_KEY_SIZE];
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
typedef struct otPlatCryptoEcdsaPublicKey otPlatCryptoEcdsaPublicKey;
|
||||
|
||||
/**
|
||||
* Buffer size (in bytes) for representing the EDCSA signature.
|
||||
*/
|
||||
#define OT_CRYPTO_ECDSA_SIGNATURE_SIZE 64
|
||||
|
||||
/**
|
||||
* @struct otPlatCryptoEcdsaSignature
|
||||
*
|
||||
* Represents an ECDSA signature.
|
||||
*
|
||||
* The signature is encoded as the concatenated binary representation of two MPIs `r` and `s` which are calculated
|
||||
* during signing (RFC 6605 - section 4).
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otPlatCryptoEcdsaSignature
|
||||
{
|
||||
uint8_t m8[OT_CRYPTO_ECDSA_SIGNATURE_SIZE];
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
typedef struct otPlatCryptoEcdsaSignature otPlatCryptoEcdsaSignature;
|
||||
|
||||
/**
|
||||
* Max PBKDF2 SALT length: salt prefix (6) + extended panid (8) + network name (16)
|
||||
*/
|
||||
#define OT_CRYPTO_PBDKF2_MAX_SALT_SIZE 30
|
||||
|
||||
/**
|
||||
* Initialize the Crypto module.
|
||||
*/
|
||||
void otPlatCryptoInit(void);
|
||||
|
||||
/**
|
||||
* Import a key into PSA ITS.
|
||||
*
|
||||
* @param[in,out] aKeyRef Pointer to the key ref to be used for crypto operations.
|
||||
* @param[in] aKeyType Key Type encoding for the key.
|
||||
* @param[in] aKeyAlgorithm Key algorithm encoding for the key.
|
||||
* @param[in] aKeyUsage Key Usage encoding for the key (combinations of `OT_CRYPTO_KEY_USAGE_*`).
|
||||
* @param[in] aKeyPersistence Key Persistence for this key
|
||||
* @param[in] aKey Actual key to be imported.
|
||||
* @param[in] aKeyLen Length of the key to be imported.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully imported the key.
|
||||
* @retval OT_ERROR_FAILED Failed to import the key.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aKey was set to NULL.
|
||||
*
|
||||
* @note If OT_CRYPTO_KEY_STORAGE_PERSISTENT is passed for aKeyPersistence then @p aKeyRef is input and platform
|
||||
* should use the given aKeyRef and MUST not change it.
|
||||
*
|
||||
* If OT_CRYPTO_KEY_STORAGE_VOLATILE is passed for aKeyPersistence then @p aKeyRef is output, the initial
|
||||
* value does not matter and platform API MUST update it to return the new key ref.
|
||||
*
|
||||
* This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled.
|
||||
*/
|
||||
otError otPlatCryptoImportKey(otCryptoKeyRef *aKeyRef,
|
||||
otCryptoKeyType aKeyType,
|
||||
otCryptoKeyAlgorithm aKeyAlgorithm,
|
||||
int aKeyUsage,
|
||||
otCryptoKeyStorage aKeyPersistence,
|
||||
const uint8_t *aKey,
|
||||
size_t aKeyLen);
|
||||
|
||||
/**
|
||||
* Export a key stored in PSA ITS.
|
||||
*
|
||||
* @param[in] aKeyRef The key ref to be used for crypto operations.
|
||||
* @param[out] aBuffer Pointer to the buffer where key needs to be exported.
|
||||
* @param[in] aBufferLen Length of the buffer passed to store the exported key.
|
||||
* @param[out] aKeyLen Pointer to return the length of the exported key.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully exported @p aKeyRef.
|
||||
* @retval OT_ERROR_FAILED Failed to export @p aKeyRef.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aBuffer was NULL
|
||||
*
|
||||
* @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled.
|
||||
*/
|
||||
otError otPlatCryptoExportKey(otCryptoKeyRef aKeyRef, uint8_t *aBuffer, size_t aBufferLen, size_t *aKeyLen);
|
||||
|
||||
/**
|
||||
* Destroy a key stored in PSA ITS.
|
||||
*
|
||||
* @param[in] aKeyRef The key ref to be destroyed
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully destroyed the key.
|
||||
* @retval OT_ERROR_FAILED Failed to destroy the key.
|
||||
*
|
||||
* @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled.
|
||||
*/
|
||||
otError otPlatCryptoDestroyKey(otCryptoKeyRef aKeyRef);
|
||||
|
||||
/**
|
||||
* Check if the key ref passed has an associated key in PSA ITS.
|
||||
*
|
||||
* @param[in] aKeyRef The Key Ref to check.
|
||||
*
|
||||
* @retval TRUE There is an associated key with @p aKeyRef.
|
||||
* @retval FALSE There is no associated key with @p aKeyRef.
|
||||
*
|
||||
* @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled.
|
||||
*/
|
||||
bool otPlatCryptoHasKey(otCryptoKeyRef aKeyRef);
|
||||
|
||||
/**
|
||||
* Initialize the HMAC operation.
|
||||
*
|
||||
* @param[in] aContext Context for HMAC operation.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully initialized HMAC operation.
|
||||
* @retval OT_ERROR_FAILED Failed to initialize HMAC operation.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
|
||||
*
|
||||
* @note The platform driver shall point the context to the correct object such as psa_mac_operation_t or
|
||||
* mbedtls_md_context_t.
|
||||
*/
|
||||
otError otPlatCryptoHmacSha256Init(otCryptoContext *aContext);
|
||||
|
||||
/**
|
||||
* Uninitialize the HMAC operation.
|
||||
*
|
||||
* @param[in] aContext Context for HMAC operation.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully uninitialized HMAC operation.
|
||||
* @retval OT_ERROR_FAILED Failed to uninitialized HMAC operation.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
|
||||
*/
|
||||
otError otPlatCryptoHmacSha256Deinit(otCryptoContext *aContext);
|
||||
|
||||
/**
|
||||
* Start HMAC operation.
|
||||
*
|
||||
* @param[in] aContext Context for HMAC operation.
|
||||
* @param[in] aKey Key material to be used for HMAC operation.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started HMAC operation.
|
||||
* @retval OT_ERROR_FAILED Failed to start HMAC operation.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext or @p aKey was NULL
|
||||
*/
|
||||
otError otPlatCryptoHmacSha256Start(otCryptoContext *aContext, const otCryptoKey *aKey);
|
||||
|
||||
/**
|
||||
* Update the HMAC operation with new input.
|
||||
*
|
||||
* @param[in] aContext Context for HMAC operation.
|
||||
* @param[in] aBuf A pointer to the input buffer.
|
||||
* @param[in] aBufLength The length of @p aBuf in bytes.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully updated HMAC with new input operation.
|
||||
* @retval OT_ERROR_FAILED Failed to update HMAC operation.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext or @p aBuf was NULL
|
||||
*/
|
||||
otError otPlatCryptoHmacSha256Update(otCryptoContext *aContext, const void *aBuf, uint16_t aBufLength);
|
||||
|
||||
/**
|
||||
* Complete the HMAC operation.
|
||||
*
|
||||
* @param[in] aContext Context for HMAC operation.
|
||||
* @param[out] aBuf A pointer to the output buffer.
|
||||
* @param[in] aBufLength The length of @p aBuf in bytes.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully completed HMAC operation.
|
||||
* @retval OT_ERROR_FAILED Failed to complete HMAC operation.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext or @p aBuf was NULL
|
||||
*/
|
||||
otError otPlatCryptoHmacSha256Finish(otCryptoContext *aContext, uint8_t *aBuf, size_t aBufLength);
|
||||
|
||||
/**
|
||||
* Initialise the AES operation.
|
||||
*
|
||||
* @param[in] aContext Context for AES operation.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully Initialised AES operation.
|
||||
* @retval OT_ERROR_FAILED Failed to Initialise AES operation.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
|
||||
* @retval OT_ERROR_NO_BUFS Cannot allocate the context.
|
||||
*
|
||||
* @note The platform driver shall point the context to the correct object such as psa_key_id
|
||||
* or mbedtls_aes_context_t.
|
||||
*/
|
||||
otError otPlatCryptoAesInit(otCryptoContext *aContext);
|
||||
|
||||
/**
|
||||
* Set the key for AES operation.
|
||||
*
|
||||
* @param[in] aContext Context for AES operation.
|
||||
* @param[out] aKey Key to use for AES operation.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the key for AES operation.
|
||||
* @retval OT_ERROR_FAILED Failed to set the key for AES operation.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext or @p aKey was NULL
|
||||
*/
|
||||
otError otPlatCryptoAesSetKey(otCryptoContext *aContext, const otCryptoKey *aKey);
|
||||
|
||||
/**
|
||||
* Encrypt the given data.
|
||||
*
|
||||
* @param[in] aContext Context for AES operation.
|
||||
* @param[in] aInput Pointer to the input buffer.
|
||||
* @param[in] aOutput Pointer to the output buffer.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully encrypted @p aInput.
|
||||
* @retval OT_ERROR_FAILED Failed to encrypt @p aInput.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext or @p aKey or @p aOutput were NULL
|
||||
*/
|
||||
otError otPlatCryptoAesEncrypt(otCryptoContext *aContext, const uint8_t *aInput, uint8_t *aOutput);
|
||||
|
||||
/**
|
||||
* Free the AES context.
|
||||
*
|
||||
* @param[in] aContext Context for AES operation.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully freed AES context.
|
||||
* @retval OT_ERROR_FAILED Failed to free AES context.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
|
||||
*/
|
||||
otError otPlatCryptoAesFree(otCryptoContext *aContext);
|
||||
|
||||
/**
|
||||
* Initialise the HKDF context.
|
||||
*
|
||||
* @param[in] aContext Context for HKDF operation.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully Initialised AES operation.
|
||||
* @retval OT_ERROR_FAILED Failed to Initialise AES operation.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
|
||||
*
|
||||
* @note The platform driver shall point the context to the correct object such as psa_key_derivation_operation_t
|
||||
* or HmacSha256::Hash
|
||||
*/
|
||||
otError otPlatCryptoHkdfInit(otCryptoContext *aContext);
|
||||
|
||||
/**
|
||||
* Perform HKDF Expand step.
|
||||
*
|
||||
* @param[in] aContext Operation context for HKDF operation.
|
||||
* @param[in] aInfo Pointer to the Info sequence.
|
||||
* @param[in] aInfoLength Length of the Info sequence.
|
||||
* @param[out] aOutputKey Pointer to the output Key.
|
||||
* @param[in] aOutputKeyLength Size of the output key buffer.
|
||||
*
|
||||
* @retval OT_ERROR_NONE HKDF Expand was successful.
|
||||
* @retval OT_ERROR_FAILED HKDF Expand failed.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
|
||||
*/
|
||||
otError otPlatCryptoHkdfExpand(otCryptoContext *aContext,
|
||||
const uint8_t *aInfo,
|
||||
uint16_t aInfoLength,
|
||||
uint8_t *aOutputKey,
|
||||
uint16_t aOutputKeyLength);
|
||||
|
||||
/**
|
||||
* Perform HKDF Extract step.
|
||||
*
|
||||
* @param[in] aContext Operation context for HKDF operation.
|
||||
* @param[in] aSalt Pointer to the Salt for HKDF.
|
||||
* @param[in] aSaltLength Length of Salt.
|
||||
* @param[in] aInputKey Pointer to the input key.
|
||||
*
|
||||
* @retval OT_ERROR_NONE HKDF Extract was successful.
|
||||
* @retval OT_ERROR_FAILED HKDF Extract failed.
|
||||
*/
|
||||
otError otPlatCryptoHkdfExtract(otCryptoContext *aContext,
|
||||
const uint8_t *aSalt,
|
||||
uint16_t aSaltLength,
|
||||
const otCryptoKey *aInputKey);
|
||||
|
||||
/**
|
||||
* Uninitialize the HKDF context.
|
||||
*
|
||||
* @param[in] aContext Context for HKDF operation.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully un-initialised HKDF operation.
|
||||
* @retval OT_ERROR_FAILED Failed to un-initialised HKDF operation.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
|
||||
*/
|
||||
otError otPlatCryptoHkdfDeinit(otCryptoContext *aContext);
|
||||
|
||||
/**
|
||||
* Initialise the SHA-256 operation.
|
||||
*
|
||||
* @param[in] aContext Context for SHA-256 operation.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully initialised SHA-256 operation.
|
||||
* @retval OT_ERROR_FAILED Failed to initialise SHA-256 operation.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
|
||||
*
|
||||
*
|
||||
* @note The platform driver shall point the context to the correct object such as psa_hash_operation_t
|
||||
* or mbedtls_sha256_context.
|
||||
*/
|
||||
otError otPlatCryptoSha256Init(otCryptoContext *aContext);
|
||||
|
||||
/**
|
||||
* Uninitialize the SHA-256 operation.
|
||||
*
|
||||
* @param[in] aContext Context for SHA-256 operation.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully un-initialised SHA-256 operation.
|
||||
* @retval OT_ERROR_FAILED Failed to un-initialised SHA-256 operation.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
|
||||
*/
|
||||
otError otPlatCryptoSha256Deinit(otCryptoContext *aContext);
|
||||
|
||||
/**
|
||||
* Start SHA-256 operation.
|
||||
*
|
||||
* @param[in] aContext Context for SHA-256 operation.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started SHA-256 operation.
|
||||
* @retval OT_ERROR_FAILED Failed to start SHA-256 operation.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
|
||||
*/
|
||||
otError otPlatCryptoSha256Start(otCryptoContext *aContext);
|
||||
|
||||
/**
|
||||
* Update SHA-256 operation with new input.
|
||||
*
|
||||
* @param[in] aContext Context for SHA-256 operation.
|
||||
* @param[in] aBuf A pointer to the input buffer.
|
||||
* @param[in] aBufLength The length of @p aBuf in bytes.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully updated SHA-256 with new input operation.
|
||||
* @retval OT_ERROR_FAILED Failed to update SHA-256 operation.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext or @p aBuf was NULL
|
||||
*/
|
||||
otError otPlatCryptoSha256Update(otCryptoContext *aContext, const void *aBuf, uint16_t aBufLength);
|
||||
|
||||
/**
|
||||
* Finish SHA-256 operation.
|
||||
*
|
||||
* @param[in] aContext Context for SHA-256 operation.
|
||||
* @param[in] aHash A pointer to the output buffer, where hash needs to be stored.
|
||||
* @param[in] aHashSize The length of @p aHash in bytes.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully completed the SHA-256 operation.
|
||||
* @retval OT_ERROR_FAILED Failed to complete SHA-256 operation.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aContext or @p aHash was NULL
|
||||
*/
|
||||
otError otPlatCryptoSha256Finish(otCryptoContext *aContext, uint8_t *aHash, uint16_t aHashSize);
|
||||
|
||||
/**
|
||||
* Initialize cryptographically-secure pseudorandom number generator (CSPRNG).
|
||||
*/
|
||||
void otPlatCryptoRandomInit(void);
|
||||
|
||||
/**
|
||||
* Deinitialize cryptographically-secure pseudorandom number generator (CSPRNG).
|
||||
*/
|
||||
void otPlatCryptoRandomDeinit(void);
|
||||
|
||||
/**
|
||||
* Fills a given buffer with cryptographically secure random bytes.
|
||||
*
|
||||
* @param[out] aBuffer A pointer to a buffer to fill with the random bytes.
|
||||
* @param[in] aSize Size of buffer (number of bytes to fill).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully filled buffer with random values.
|
||||
* @retval OT_ERROR_FAILED Operation failed.
|
||||
*/
|
||||
otError otPlatCryptoRandomGet(uint8_t *aBuffer, uint16_t aSize);
|
||||
|
||||
/**
|
||||
* Generate and populate the output buffer with a new ECDSA key-pair.
|
||||
*
|
||||
* @param[out] aKeyPair A pointer to an ECDSA key-pair structure to store the generated key-pair.
|
||||
*
|
||||
* @retval OT_ERROR_NONE A new key-pair was generated successfully.
|
||||
* @retval OT_ERROR_NO_BUFS Failed to allocate buffer for key generation.
|
||||
* @retval OT_ERROR_NOT_CAPABLE Feature not supported.
|
||||
* @retval OT_ERROR_FAILED Failed to generate key-pair.
|
||||
*/
|
||||
otError otPlatCryptoEcdsaGenerateKey(otPlatCryptoEcdsaKeyPair *aKeyPair);
|
||||
|
||||
/**
|
||||
* Get the associated public key from the input context.
|
||||
*
|
||||
* @param[in] aKeyPair A pointer to an ECDSA key-pair structure where the key-pair is stored.
|
||||
* @param[out] aPublicKey A pointer to an ECDSA public key structure to store the public key.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Public key was retrieved successfully, and @p aBuffer is updated.
|
||||
* @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format).
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL.
|
||||
*/
|
||||
otError otPlatCryptoEcdsaGetPublicKey(const otPlatCryptoEcdsaKeyPair *aKeyPair, otPlatCryptoEcdsaPublicKey *aPublicKey);
|
||||
|
||||
/**
|
||||
* Calculate the ECDSA signature for a hashed message using the private key from the input context.
|
||||
*
|
||||
* Uses the deterministic digital signature generation procedure from RFC 6979.
|
||||
*
|
||||
* @param[in] aKeyPair A pointer to an ECDSA key-pair structure where the key-pair is stored.
|
||||
* @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature calculation
|
||||
* is stored.
|
||||
* @param[out] aSignature A pointer to an ECDSA signature structure to output the calculated signature.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The signature was calculated successfully, @p aSignature was updated.
|
||||
* @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format).
|
||||
* @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature calculation.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL.
|
||||
*/
|
||||
otError otPlatCryptoEcdsaSign(const otPlatCryptoEcdsaKeyPair *aKeyPair,
|
||||
const otPlatCryptoSha256Hash *aHash,
|
||||
otPlatCryptoEcdsaSignature *aSignature);
|
||||
|
||||
/**
|
||||
* Use the key from the input context to verify the ECDSA signature of a hashed message.
|
||||
*
|
||||
* @param[in] aPublicKey A pointer to an ECDSA public key structure where the public key for signature
|
||||
* verification is stored.
|
||||
* @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature verification
|
||||
* is stored.
|
||||
* @param[in] aSignature A pointer to an ECDSA signature structure where the signature value to be verified is
|
||||
* stored.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The signature was verified successfully.
|
||||
* @retval OT_ERROR_SECURITY The signature is invalid.
|
||||
* @retval OT_ERROR_INVALID_ARGS The key or hash is invalid.
|
||||
* @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature verification.
|
||||
*/
|
||||
otError otPlatCryptoEcdsaVerify(const otPlatCryptoEcdsaPublicKey *aPublicKey,
|
||||
const otPlatCryptoSha256Hash *aHash,
|
||||
const otPlatCryptoEcdsaSignature *aSignature);
|
||||
|
||||
/**
|
||||
* Calculate the ECDSA signature for a hashed message using the Key reference passed.
|
||||
*
|
||||
* Uses the deterministic digital signature generation procedure from RFC 6979.
|
||||
*
|
||||
* @param[in] aKeyRef Key Reference to the slot where the key-pair is stored.
|
||||
* @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature calculation
|
||||
* is stored.
|
||||
* @param[out] aSignature A pointer to an ECDSA signature structure to output the calculated signature.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The signature was calculated successfully, @p aSignature was updated.
|
||||
* @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format).
|
||||
* @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature calculation.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL.
|
||||
*
|
||||
* @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled.
|
||||
*/
|
||||
otError otPlatCryptoEcdsaSignUsingKeyRef(otCryptoKeyRef aKeyRef,
|
||||
const otPlatCryptoSha256Hash *aHash,
|
||||
otPlatCryptoEcdsaSignature *aSignature);
|
||||
|
||||
/**
|
||||
* Get the associated public key from the key reference passed.
|
||||
*
|
||||
* The public key is stored differently depending on the crypto backend library being used
|
||||
* (OPENTHREAD_CONFIG_CRYPTO_LIB).
|
||||
*
|
||||
* This API must make sure to return the public key as a byte sequence representation of an
|
||||
* uncompressed curve point (RFC 6605 - sec 4)
|
||||
*
|
||||
* @param[in] aKeyRef Key Reference to the slot where the key-pair is stored.
|
||||
* @param[out] aPublicKey A pointer to an ECDSA public key structure to store the public key.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Public key was retrieved successfully, and @p aBuffer is updated.
|
||||
* @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format).
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL.
|
||||
*
|
||||
* @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled.
|
||||
*/
|
||||
otError otPlatCryptoEcdsaExportPublicKey(otCryptoKeyRef aKeyRef, otPlatCryptoEcdsaPublicKey *aPublicKey);
|
||||
|
||||
/**
|
||||
* Generate and import a new ECDSA key-pair at reference passed.
|
||||
*
|
||||
* @param[in] aKeyRef Key Reference to the slot where the key-pair is stored.
|
||||
*
|
||||
* @retval OT_ERROR_NONE A new key-pair was generated successfully.
|
||||
* @retval OT_ERROR_NO_BUFS Failed to allocate buffer for key generation.
|
||||
* @retval OT_ERROR_NOT_CAPABLE Feature not supported.
|
||||
* @retval OT_ERROR_FAILED Failed to generate key-pair.
|
||||
*
|
||||
* @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled.
|
||||
*/
|
||||
otError otPlatCryptoEcdsaGenerateAndImportKey(otCryptoKeyRef aKeyRef);
|
||||
|
||||
/**
|
||||
* Use the keyref to verify the ECDSA signature of a hashed message.
|
||||
*
|
||||
* @param[in] aKeyRef Key Reference to the slot where the key-pair is stored.
|
||||
* @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature verification
|
||||
* is stored.
|
||||
* @param[in] aSignature A pointer to an ECDSA signature structure where the signature value to be verified is
|
||||
* stored.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The signature was verified successfully.
|
||||
* @retval OT_ERROR_SECURITY The signature is invalid.
|
||||
* @retval OT_ERROR_INVALID_ARGS The key or hash is invalid.
|
||||
* @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature verification.
|
||||
*
|
||||
* @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled.
|
||||
*/
|
||||
otError otPlatCryptoEcdsaVerifyUsingKeyRef(otCryptoKeyRef aKeyRef,
|
||||
const otPlatCryptoSha256Hash *aHash,
|
||||
const otPlatCryptoEcdsaSignature *aSignature);
|
||||
|
||||
/**
|
||||
* Perform PKCS#5 PBKDF2 using CMAC (AES-CMAC-PRF-128).
|
||||
*
|
||||
* @param[in] aPassword Password to use when generating key.
|
||||
* @param[in] aPasswordLen Length of password.
|
||||
* @param[in] aSalt Salt to use when generating key.
|
||||
* @param[in] aSaltLen Length of salt.
|
||||
* @param[in] aIterationCounter Iteration count.
|
||||
* @param[in] aKeyLen Length of generated key in bytes.
|
||||
* @param[out] aKey A pointer to the generated key.
|
||||
*
|
||||
* @retval OT_ERROR_NONE A new key-pair was generated successfully.
|
||||
* @retval OT_ERROR_NO_BUFS Failed to allocate buffer for key generation.
|
||||
* @retval OT_ERROR_NOT_CAPABLE Feature not supported.
|
||||
* @retval OT_ERROR_FAILED Failed to generate key.
|
||||
*/
|
||||
otError otPlatCryptoPbkdf2GenerateKey(const uint8_t *aPassword,
|
||||
uint16_t aPasswordLen,
|
||||
const uint8_t *aSalt,
|
||||
uint16_t aSaltLen,
|
||||
uint32_t aIterationCounter,
|
||||
uint16_t aKeyLen,
|
||||
uint8_t *aKey);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern "C"
|
||||
#endif
|
||||
#endif // OPENTHREAD_PLATFORM_CRYPTO_H_
|
||||
192
Libs/util/third_party/openthread/include/openthread/platform/debug_uart.h
vendored
Normal file
192
Libs/util/third_party/openthread/include/openthread/platform/debug_uart.h
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_DEBUG_UART_H_
|
||||
#define OPENTHREAD_PLATFORM_DEBUG_UART_H_
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Note: This is NOT a public thread API, and this header file is *NOT*
|
||||
* installed as part of OpenThread, this is an pseudo-internal
|
||||
* debug feature usable by developers during the course of development.
|
||||
*
|
||||
* This implements a very basic debug uart useful for logging
|
||||
* messages when the primary uart is already engaged (example the NCP)
|
||||
* and encapsulating logs is not practical.
|
||||
*
|
||||
* Implementation Notes:
|
||||
*
|
||||
* Only 3 functions are required to be implemented by the platform.
|
||||
* see/search for the word MUST in the comments below.
|
||||
*
|
||||
* The other functions (without MUST in the comment) are WEAK symbols
|
||||
* that can optionally be overridden by the platform or the application.
|
||||
*
|
||||
* Many of the other functions are simply convenience functions to
|
||||
* aid a developer during their normal course of work and are not
|
||||
* intended to be present, or used in production system.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup internal-debug-api
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Standard printf() to the debug uart with no log decoration.
|
||||
*
|
||||
* @param[in] fmt printf formatter text
|
||||
*
|
||||
* This is a debug convenience function that is not intended to be
|
||||
* used in anything other then "debug scenarios" by a developer.
|
||||
*
|
||||
* lf -> cr/lf mapping is automatically handled via otPlatDebugUart_putchar()
|
||||
*
|
||||
* @sa otPlatDebugUart_vprintf() for limitations
|
||||
*
|
||||
* This is a WEAK symbol that can easily be overridden as needed.
|
||||
*/
|
||||
void otPlatDebugUart_printf(const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* Standard vprintf() to the debug uart, with no log decoration.
|
||||
*
|
||||
* @param[in] fmt printf formatter text
|
||||
* @param[in] ap va_list value for print parameters.
|
||||
*
|
||||
* Implementation limitation: this formats the text into
|
||||
* a purposely small text buffer on the stack, thus long
|
||||
* messages may be truncated.
|
||||
*
|
||||
* This is a WEAK symbol that can easily be overridden as needed.
|
||||
*
|
||||
* For example, some platforms might override this via a non-WEAK
|
||||
* symbol because the platform provides a UART_vprintf() like
|
||||
* function that can handle an arbitrary length output.
|
||||
*/
|
||||
void otPlatDebugUart_vprintf(const char *fmt, va_list ap);
|
||||
|
||||
/**
|
||||
* Platform specific write single byte to Debug Uart
|
||||
* This should not perform CR/LF mapping.
|
||||
*
|
||||
* MUST be implemented by the platform
|
||||
*
|
||||
* @param[in] c what to transmit
|
||||
*/
|
||||
void otPlatDebugUart_putchar_raw(int c);
|
||||
|
||||
/**
|
||||
* Poll/test debug uart if a key has been pressed.
|
||||
* It would be common to a stub function that returns 0.
|
||||
*
|
||||
* MUST be implemented by the platform
|
||||
*
|
||||
* @retval zero - nothing ready
|
||||
* @retval nonzero - otPlatDebugUart_getc() will succeed.
|
||||
*/
|
||||
int otPlatDebugUart_kbhit(void);
|
||||
|
||||
/**
|
||||
* Poll/Read a byte from the debug uart
|
||||
*
|
||||
* MUST be implemented by the platform
|
||||
*
|
||||
* @retval (negative) no data available, see otPlatDebugUart_kbhit()
|
||||
* @retval (0x00..0x0ff) data byte value
|
||||
*/
|
||||
int otPlatDebugUart_getc(void);
|
||||
|
||||
/**
|
||||
* Write byte to the uart, expand cr/lf as need.
|
||||
*
|
||||
* A WEAK default implementation is provided
|
||||
* that can be overridden as needed.
|
||||
*
|
||||
* @param[in] c the byte to transmit
|
||||
*/
|
||||
void otPlatDebugUart_putchar(int c);
|
||||
|
||||
/**
|
||||
* identical to "man 3 puts" - terminates with lf
|
||||
* Which is then mapped to cr/lf as required
|
||||
*
|
||||
* A WEAK default implementation is provided
|
||||
* that can be overridden as needed.
|
||||
*
|
||||
* @param[in] s the string to print with a lf at the end
|
||||
*/
|
||||
void otPlatDebugUart_puts(const char *s);
|
||||
|
||||
/**
|
||||
* Write N bytes to the UART, mapping cr/lf
|
||||
*
|
||||
* @param[in] pBytes pointer to bytes to transmit.
|
||||
* @param[in] nBytes how many bytes to transmit.
|
||||
*/
|
||||
void otPlatDebugUart_write_bytes(const uint8_t *pBytes, int nBytes);
|
||||
|
||||
/**
|
||||
* puts() without a terminal newline.
|
||||
* see: "man 3 puts", without a adding a terminal lf
|
||||
*
|
||||
* @param[in] s the string to print without a lf at the end
|
||||
*
|
||||
* Note, the terminal "lf" mapped to cr/lf via
|
||||
* the function otPlatDebugUart_putchar()
|
||||
*/
|
||||
void otPlatDebugUart_puts_no_nl(const char *s);
|
||||
|
||||
/**
|
||||
* Some platforms (simulation) can log to a file.
|
||||
*
|
||||
* @returns OT_ERROR_NONE
|
||||
* @returns OT_ERROR_FAILED
|
||||
*
|
||||
* Platforms that desire this MUST provide an implementation.
|
||||
*/
|
||||
otError otPlatDebugUart_logfile(const char *filename);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_DEBUG_UART_H_
|
||||
298
Libs/util/third_party/openthread/include/openthread/platform/diag.h
vendored
Normal file
298
Libs/util/third_party/openthread/include/openthread/platform/diag.h
vendored
Normal file
@@ -0,0 +1,298 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the platform diag interface.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_DIAG_H_
|
||||
#define OPENTHREAD_PLATFORM_DIAG_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-factory-diagnostics
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for diagnostics features.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Defines the gpio modes.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_GPIO_MODE_INPUT = 0, ///< Input mode without pull resistor.
|
||||
OT_GPIO_MODE_OUTPUT = 1, ///< Output mode.
|
||||
} otGpioMode;
|
||||
|
||||
/**
|
||||
* Pointer to callback to output platform diag messages.
|
||||
*
|
||||
* @param[in] aFormat The format string.
|
||||
* @param[in] aArguments The format string arguments.
|
||||
* @param[out] aContext A pointer to the user context.
|
||||
*/
|
||||
typedef void (*otPlatDiagOutputCallback)(const char *aFormat, va_list aArguments, void *aContext);
|
||||
|
||||
/**
|
||||
* Sets the platform diag output callback.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aCallback A pointer to a function that is called on outputting diag messages.
|
||||
* @param[in] aContext A pointer to the user context.
|
||||
*/
|
||||
void otPlatDiagSetOutputCallback(otInstance *aInstance, otPlatDiagOutputCallback aCallback, void *aContext);
|
||||
|
||||
/**
|
||||
* Processes a factory diagnostics command line.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance for current request.
|
||||
* @param[in] aArgsLength The number of arguments in @p aArgs.
|
||||
* @param[in] aArgs The arguments of diagnostics command line.
|
||||
*
|
||||
* @retval OT_ERROR_INVALID_ARGS The command is supported but invalid arguments provided.
|
||||
* @retval OT_ERROR_NONE The command is successfully process.
|
||||
* @retval OT_ERROR_INVALID_COMMAND The command is not valid or not supported.
|
||||
*/
|
||||
otError otPlatDiagProcess(otInstance *aInstance, uint8_t aArgsLength, char *aArgs[]);
|
||||
|
||||
/**
|
||||
* Enables/disables the factory diagnostics mode.
|
||||
*
|
||||
* @param[in] aMode TRUE to enable diagnostics mode, FALSE otherwise.
|
||||
*/
|
||||
void otPlatDiagModeSet(bool aMode);
|
||||
|
||||
/**
|
||||
* Indicates whether or not factory diagnostics mode is enabled.
|
||||
*
|
||||
* @returns TRUE if factory diagnostics mode is enabled, FALSE otherwise.
|
||||
*/
|
||||
bool otPlatDiagModeGet(void);
|
||||
|
||||
/**
|
||||
* Sets the channel to use for factory diagnostics.
|
||||
*
|
||||
* @param[in] aChannel The channel value.
|
||||
*/
|
||||
void otPlatDiagChannelSet(uint8_t aChannel);
|
||||
|
||||
/**
|
||||
* Sets the transmit power to use for factory diagnostics.
|
||||
*
|
||||
* @param[in] aTxPower The transmit power value.
|
||||
*/
|
||||
void otPlatDiagTxPowerSet(int8_t aTxPower);
|
||||
|
||||
/**
|
||||
* Processes the received radio frame.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance for current request.
|
||||
* @param[in] aFrame The received radio frame.
|
||||
* @param[in] aError The received radio frame status.
|
||||
*/
|
||||
void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otError aError);
|
||||
|
||||
/**
|
||||
* Processes the alarm event.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance for current request.
|
||||
*/
|
||||
void otPlatDiagAlarmCallback(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the gpio value.
|
||||
*
|
||||
* @param[in] aGpio The gpio number.
|
||||
* @param[in] aValue true to set the gpio to high level, or false otherwise.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the gpio.
|
||||
* @retval OT_ERROR_FAILED A platform error occurred while setting the gpio.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aGpio is not supported.
|
||||
* @retval OT_ERROR_INVALID_STATE Diagnostic mode was not enabled or @p aGpio is not configured as output.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED This function is not implemented or configured on the platform.
|
||||
*/
|
||||
otError otPlatDiagGpioSet(uint32_t aGpio, bool aValue);
|
||||
|
||||
/**
|
||||
* Gets the gpio value.
|
||||
*
|
||||
* @param[in] aGpio The gpio number.
|
||||
* @param[out] aValue A pointer where to put gpio value.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully got the gpio value.
|
||||
* @retval OT_ERROR_FAILED A platform error occurred while getting the gpio value.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aGpio is not supported or @p aValue is NULL.
|
||||
* @retval OT_ERROR_INVALID_STATE Diagnostic mode was not enabled or @p aGpio is not configured as input.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED This function is not implemented or configured on the platform.
|
||||
*/
|
||||
otError otPlatDiagGpioGet(uint32_t aGpio, bool *aValue);
|
||||
|
||||
/**
|
||||
* Sets the gpio mode.
|
||||
*
|
||||
* @param[in] aGpio The gpio number.
|
||||
* @param[out] aMode The gpio mode.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the gpio mode.
|
||||
* @retval OT_ERROR_FAILED A platform error occurred while setting the gpio mode.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aGpio or @p aMode is not supported.
|
||||
* @retval OT_ERROR_INVALID_STATE Diagnostic mode was not enabled.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED This function is not implemented or configured on the platform.
|
||||
*/
|
||||
otError otPlatDiagGpioSetMode(uint32_t aGpio, otGpioMode aMode);
|
||||
|
||||
/**
|
||||
* Gets the gpio mode.
|
||||
*
|
||||
* @param[in] aGpio The gpio number.
|
||||
* @param[out] aMode A pointer where to put gpio mode.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully got the gpio mode.
|
||||
* @retval OT_ERROR_FAILED Mode returned by the platform is not implemented in OpenThread or a platform error
|
||||
* occurred while getting the gpio mode.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aGpio is not supported or @p aMode is NULL.
|
||||
* @retval OT_ERROR_INVALID_STATE Diagnostic mode was not enabled.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED This function is not implemented or configured on the platform.
|
||||
*/
|
||||
otError otPlatDiagGpioGetMode(uint32_t aGpio, otGpioMode *aMode);
|
||||
|
||||
/**
|
||||
* Set the radio raw power setting for diagnostics module.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aRawPowerSetting A pointer to the raw power setting byte array.
|
||||
* @param[in] aRawPowerSettingLength The length of the @p aRawPowerSetting.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the raw power setting.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aRawPowerSetting is NULL or the @p aRawPowerSettingLength is too long.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED This method is not implemented.
|
||||
*/
|
||||
otError otPlatDiagRadioSetRawPowerSetting(otInstance *aInstance,
|
||||
const uint8_t *aRawPowerSetting,
|
||||
uint16_t aRawPowerSettingLength);
|
||||
|
||||
/**
|
||||
* Get the radio raw power setting for diagnostics module.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[out] aRawPowerSetting A pointer to the raw power setting byte array.
|
||||
* @param[in,out] aRawPowerSettingLength On input, a pointer to the size of @p aRawPowerSetting.
|
||||
* On output, a pointer to the length of the raw power setting data.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the raw power setting.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aRawPowerSetting or @p aRawPowerSettingLength is NULL or
|
||||
* @aRawPowerSettingLength is too short.
|
||||
* @retval OT_ERROR_NOT_FOUND The raw power setting is not set.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED This method is not implemented.
|
||||
*/
|
||||
otError otPlatDiagRadioGetRawPowerSetting(otInstance *aInstance,
|
||||
uint8_t *aRawPowerSetting,
|
||||
uint16_t *aRawPowerSettingLength);
|
||||
|
||||
/**
|
||||
* Enable/disable the platform layer to use the raw power setting set by `otPlatDiagRadioSetRawPowerSetting()`.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aEnable TRUE to enable or FALSE to disable the raw power setting.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully enabled/disabled the raw power setting.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED This method is not implemented.
|
||||
*/
|
||||
otError otPlatDiagRadioRawPowerSettingEnable(otInstance *aInstance, bool aEnable);
|
||||
|
||||
/**
|
||||
* Start/stop the platform layer to transmit continuous carrier wave.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aEnable TRUE to enable or FALSE to disable the platform layer to transmit continuous carrier wave.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully enabled/disabled .
|
||||
* @retval OT_ERROR_INVALID_STATE The radio was not in the Receive state.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED This method is not implemented.
|
||||
*/
|
||||
otError otPlatDiagRadioTransmitCarrier(otInstance *aInstance, bool aEnable);
|
||||
|
||||
/**
|
||||
* Start/stop the platform layer to transmit stream of characters.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aEnable TRUE to enable or FALSE to disable the platform layer to transmit stream.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully enabled/disabled.
|
||||
* @retval OT_ERROR_INVALID_STATE The radio was not in the Receive state.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED This function is not implemented.
|
||||
*/
|
||||
otError otPlatDiagRadioTransmitStream(otInstance *aInstance, bool aEnable);
|
||||
|
||||
/**
|
||||
* Get the power settings for the given channel.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aChannel The radio channel.
|
||||
* @param[out] aTargetPower The target power in 0.01 dBm.
|
||||
* @param[out] aActualPower The actual power in 0.01 dBm.
|
||||
* @param[out] aRawPowerSetting A pointer to the raw power setting byte array.
|
||||
* @param[in,out] aRawPowerSettingLength On input, a pointer to the size of @p aRawPowerSetting.
|
||||
* On output, a pointer to the length of the raw power setting data.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully got the target power.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aChannel is invalid, @aTargetPower, @p aActualPower, @p aRawPowerSetting or
|
||||
* @p aRawPowerSettingLength is NULL or @aRawPowerSettingLength is too short.
|
||||
* @retval OT_ERROR_NOT_FOUND The power settings for the @p aChannel was not found.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED This method is not implemented.
|
||||
*/
|
||||
otError otPlatDiagRadioGetPowerSettings(otInstance *aInstance,
|
||||
uint8_t aChannel,
|
||||
int16_t *aTargetPower,
|
||||
int16_t *aActualPower,
|
||||
uint8_t *aRawPowerSetting,
|
||||
uint16_t *aRawPowerSettingLength);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_DIAG_H_
|
||||
107
Libs/util/third_party/openthread/include/openthread/platform/dns.h
vendored
Normal file
107
Libs/util/third_party/openthread/include/openthread/platform/dns.h
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the platform DNS interface.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_DNS_H_
|
||||
#define OPENTHREAD_PLATFORM_DNS_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/message.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-dns
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for sending recursive DNS query to upstream DNS servers.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* This opaque type represents an upstream DNS query transaction.
|
||||
*/
|
||||
typedef struct otPlatDnsUpstreamQuery otPlatDnsUpstreamQuery;
|
||||
|
||||
/**
|
||||
* Starts an upstream query transaction.
|
||||
*
|
||||
* - In success case (and errors represented by DNS protocol messages), the platform is expected to call
|
||||
* `otPlatDnsUpstreamQueryDone`.
|
||||
* - The OpenThread core may cancel a (possibly timeout) query transaction by calling
|
||||
* `otPlatDnsCancelUpstreamQuery`, the platform must not call `otPlatDnsUpstreamQueryDone` on a
|
||||
* cancelled transaction.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aTxn A pointer to the opaque DNS query transaction object.
|
||||
* @param[in] aQuery A message buffer of the DNS payload that should be sent to upstream DNS server.
|
||||
*/
|
||||
void otPlatDnsStartUpstreamQuery(otInstance *aInstance, otPlatDnsUpstreamQuery *aTxn, const otMessage *aQuery);
|
||||
|
||||
/**
|
||||
* Cancels a transaction of upstream query.
|
||||
*
|
||||
* The platform must call `otPlatDnsUpstreamQueryDone` to release the resources.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aTxn A pointer to the opaque DNS query transaction object.
|
||||
*/
|
||||
void otPlatDnsCancelUpstreamQuery(otInstance *aInstance, otPlatDnsUpstreamQuery *aTxn);
|
||||
|
||||
/**
|
||||
* The platform calls this function to finish DNS query.
|
||||
*
|
||||
* The transaction will be released, so the platform must not call on the same transaction twice. This function passes
|
||||
* the ownership of `aResponse` to OpenThread stack.
|
||||
*
|
||||
* Platform can pass a nullptr to close a transaction without a response.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aTxn A pointer to the opaque DNS query transaction object.
|
||||
* @param[in] aResponse A message buffer of the DNS response payload or `nullptr` to close a transaction without a
|
||||
* response.
|
||||
*/
|
||||
extern void otPlatDnsUpstreamQueryDone(otInstance *aInstance, otPlatDnsUpstreamQuery *aTxn, otMessage *aResponse);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
729
Libs/util/third_party/openthread/include/openthread/platform/dnssd.h
vendored
Normal file
729
Libs/util/third_party/openthread/include/openthread/platform/dnssd.h
vendored
Normal file
@@ -0,0 +1,729 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform abstraction for DNS-SD (e.g., mDNS) on the infrastructure network.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_DNSSD_H_
|
||||
#define OPENTHREAD_PLATFORM_DNSSD_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/dns.h>
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/ip6.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-dns-sd
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for DNS-SD (e.g., mDNS) on the infrastructure network.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* The DNS-SD platform APIs are used only when `OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE` is enabled.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents the state of the DNS-SD platform.
|
||||
*/
|
||||
typedef enum otPlatDnssdState
|
||||
{
|
||||
OT_PLAT_DNSSD_STOPPED, ///< Stopped and unable to register any service or host, or start any browser/resolver.
|
||||
OT_PLAT_DNSSD_READY, ///< Running and ready to register service or host.
|
||||
} otPlatDnssdState;
|
||||
|
||||
/**
|
||||
* Represents a request ID for registering/unregistering a service or host.
|
||||
*/
|
||||
typedef uint32_t otPlatDnssdRequestId;
|
||||
|
||||
/**
|
||||
* Represents the callback function used when registering/unregistering a host or service.
|
||||
*
|
||||
* See `otPlatDnssdRegisterService()`, `otPlatDnssdUnregisterService()`, `otPlatDnssdRegisterHost()`, and
|
||||
* `otPlatDnssdUnregisterHost()` for more details about when to invoke the callback and the `aError` values that can
|
||||
* be returned in each case.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aRequestId The request ID.
|
||||
* @param[in] aError Error indicating the outcome of request.
|
||||
*/
|
||||
typedef void (*otPlatDnssdRegisterCallback)(otInstance *aInstance, otPlatDnssdRequestId aRequestId, otError aError);
|
||||
|
||||
/**
|
||||
* Represents a DNS-SD service.
|
||||
*
|
||||
* See `otPlatDnssdRegisterService()`, `otPlatDnssdUnregisterService()` for more details about fields in each case.
|
||||
*/
|
||||
typedef struct otPlatDnssdService
|
||||
{
|
||||
const char *mHostName; ///< The host name (does not include domain name).
|
||||
const char *mServiceInstance; ///< The service instance name label (not the full name).
|
||||
const char *mServiceType; ///< The service type (e.g., "_mt._udp", does not include domain name).
|
||||
const char *const *mSubTypeLabels; ///< Array of sub-type labels (can be NULL if no label).
|
||||
uint16_t mSubTypeLabelsLength; ///< Length of array of sub-type labels.
|
||||
const uint8_t *mTxtData; ///< Encoded TXT data bytes.
|
||||
uint16_t mTxtDataLength; ///< Length of TXT data.
|
||||
uint16_t mPort; ///< The service port number.
|
||||
uint16_t mPriority; ///< The service priority.
|
||||
uint16_t mWeight; ///< The service weight.
|
||||
uint32_t mTtl; ///< The service TTL in seconds.
|
||||
uint32_t mInfraIfIndex; ///< The infrastructure network interface index.
|
||||
} otPlatDnssdService;
|
||||
|
||||
/**
|
||||
* Represents a DNS-SD host.
|
||||
*
|
||||
* See `otPlatDnssdRegisterHost()`, `otPlatDnssdUnregisterHost()` for more details about fields in each case.
|
||||
*/
|
||||
typedef struct otPlatDnssdHost
|
||||
{
|
||||
const char *mHostName; ///< The host name (does not include domain name).
|
||||
const otIp6Address *mAddresses; ///< Array of IPv6 host addresses.
|
||||
uint16_t mAddressesLength; ///< Number of entries in @p mAddresses array.
|
||||
uint32_t mTtl; ///< The host TTL in seconds.
|
||||
uint32_t mInfraIfIndex; ///< The infrastructure network interface index.
|
||||
} otPlatDnssdHost;
|
||||
|
||||
/**
|
||||
* Represents a DNS-SD key record.
|
||||
*
|
||||
* See `otPlatDnssdRegisterKey()`, `otPlatDnssdUnregisterKey()` for more details about fields in each case.
|
||||
*/
|
||||
typedef struct otPlatDnssdKey
|
||||
{
|
||||
const char *mName; ///< A host or a service instance name (does not include domain name).
|
||||
const char *mServiceType; ///< The service type if key is for a service (does not include domain name).
|
||||
const uint8_t *mKeyData; ///< Byte array containing the key record data.
|
||||
uint16_t mKeyDataLength; ///< Length of @p mKeyData in bytes.
|
||||
uint16_t mClass; ///< The resource record class.
|
||||
uint32_t mTtl; ///< The TTL in seconds.
|
||||
uint32_t mInfraIfIndex; ///< The infrastructure network interface index.
|
||||
} otPlatDnssdKey;
|
||||
|
||||
/**
|
||||
* Callback to notify state changes of the DNS-SD platform.
|
||||
*
|
||||
* The OpenThread stack will call `otPlatDnssdGetState()` (from this callback or later) to get the new state. The
|
||||
* platform MUST therefore ensure that the returned state from `otPlatDnssdGetState()` is updated before calling this.
|
||||
*
|
||||
* When the platform signals a state change to `OT_PLAT_DNSSD_STOPPED` using this callback, all active browsers and
|
||||
* resolvers are considered to be stopped, and any previously registered host, service, key entries as removed.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
extern void otPlatDnssdStateHandleStateChange(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the current state of the DNS-SD module.
|
||||
*
|
||||
* The platform MUST notify the OpenThread stack whenever its state gets changed by invoking
|
||||
* `otPlatDnssdStateHandleStateChange()`.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
*
|
||||
* @returns The current state of the DNS-SD module.
|
||||
*/
|
||||
otPlatDnssdState otPlatDnssdGetState(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Registers or updates a service on the infrastructure network's DNS-SD module.
|
||||
*
|
||||
* The @p aService and all its contained information (strings and buffers) are only valid during this call. The
|
||||
* platform MUST save a copy of the information if it wants to retain the information after returning from this
|
||||
* function.
|
||||
*
|
||||
* The fields in @p aService follow these rules:
|
||||
*
|
||||
* - The `mServiceInstance` and `mServiceType` fields specify the service instance label and service type name,
|
||||
* respectively. They are never NULL.
|
||||
* - The `mHostName` field specifies the host name of the service if it is not NULL. Otherwise, if it is NULL, it
|
||||
* indicates that this service is for the device itself and leaves the host name selection to DNS-SD platform.
|
||||
* - The `mSubTypeLabels` is an array of strings representing sub-types associated with the service. It can be NULL
|
||||
* if there are no sub-types. Otherwise, the array length is specified by `mSubTypeLabelsLength`.
|
||||
* - The `mTxtData` and `mTxtDataLength` fields specify the encoded TXT data.
|
||||
* - The `mPort`, `mWeight`, and `mPriority` fields specify the service's parameters (as specified in DNS SRV record).
|
||||
* - The `mTtl` field specifies the TTL if non-zero. If zero, the platform can choose the TTL to use.
|
||||
* - The `mInfraIfIndex` field, if non-zero, specifies the infrastructure network interface index to use for this
|
||||
* request. If zero, the platform implementation can decided the interface.
|
||||
*
|
||||
* When the `mHostName` field in @p aService is not NULL (indicating that this registration is on behalf of another
|
||||
* host), the OpenThread stack will ensure that `otPlatDnssdRegisterHost()` is also called for the same host before any
|
||||
* service registration requests for the same host.
|
||||
*
|
||||
* Once the registration request is finished, either successfully or failed, the platform reports the outcome by
|
||||
* invoking the @p aCallback and passing the same @p aRequestId in the callback. The @p aCallback function pointer can
|
||||
* be NULL, which indicates that the OpenThread stack does not need to be notified of the outcome of the request.
|
||||
* If the outcome is determined, the platform implementation may invoke the @p aCallback before returning from this
|
||||
* function. The OpenThread stack will ensure to handle such a situation.
|
||||
*
|
||||
* On success, the @p aCallback MUST be called (if non-NULL) with `OT_ERROR_NONE` as the `aError` input parameter. If
|
||||
* the registration causes a name conflict on DNS-SD domain (the service instance name is already claimed by another
|
||||
* host), the `OT_ERROR_DUPLICATED` error MUST be used. The platform implementation can use other `OT_ERROR` types for
|
||||
* other types of errors.
|
||||
*
|
||||
* The platform implementation MUST not assume that the @p aRequestId used in subsequent requests will be different.
|
||||
* OpenThread may reuse the same request ID again for a different request.
|
||||
*
|
||||
* The OpenThread stack will not register the same service (with no changes) that was registered successfully earlier.
|
||||
* Therefore, the platform implementation does not need to check for duplicate/same service and can assume that calls
|
||||
* to this function are either registering a new entry or changing some parameter in a previously registered item. As
|
||||
* a result, these changes always need to be synced on the infrastructure DNS-SD module.
|
||||
*
|
||||
* The OpenThread stack does not require the platform implementation to always invoke the @p aCallback function.
|
||||
* The OpenThread stack has its own mechanism to time out an aged request with no response. This relaxes the
|
||||
* requirement for platform implementations.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aService Information about the service to register.
|
||||
* @param[in] aRequestId The ID associated with this request.
|
||||
* @param[in] aCallback The callback function pointer to report the outcome (may be NULL if no callback needed).
|
||||
*/
|
||||
void otPlatDnssdRegisterService(otInstance *aInstance,
|
||||
const otPlatDnssdService *aService,
|
||||
otPlatDnssdRequestId aRequestId,
|
||||
otPlatDnssdRegisterCallback aCallback);
|
||||
|
||||
/**
|
||||
* Unregisters a service on the infrastructure network's DNS-SD module.
|
||||
*
|
||||
* The @p aService and all its contained information (strings and buffers) are only valid during this call. The
|
||||
* platform MUST save a copy of the information if it wants to retain the information after returning from this
|
||||
* function.
|
||||
*
|
||||
* The fields in @p aService follow these rules:
|
||||
*
|
||||
* - The `mServiceInstance` and `mServiceType` fields specify the service instance label and service type name,
|
||||
* respectively. They are never NULL.
|
||||
* - The `mHostName` field specifies the host name of the service if it is not NULL. Otherwise, if it is NULL, it
|
||||
* indicates that this service is for the device itself and leaves the host name selection to DNS-SD platform.
|
||||
* - The `mInfraIfIndex` field, if non-zero, specifies the infrastructure network interface index to use for this
|
||||
* request. If zero, the platform implementation can decided the interface.
|
||||
* - The rest of the fields in @p aService structure MUST be ignored in `otPlatDnssdUnregisterService()` call and may
|
||||
* be set to zero by the OpenThread stack.
|
||||
*
|
||||
* Regarding the invocation of the @p aCallback and the reuse of the @p aRequestId, this function follows the same
|
||||
* rules as described in `otPlatDnssdRegisterService()`.
|
||||
*
|
||||
* The OpenThread stack may request the unregistration of a service that was not previously registered, and the
|
||||
* platform implementation MUST handle this case. In such a case, the platform can use either `OT_ERROR_NOT_FOUND` to
|
||||
* indicate that there was no such registration, or `OT_ERROR_NONE` when invoking the @p aCallback function. The
|
||||
* OpenThread stack will handle either case correctly.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aService Information about the service to unregister.
|
||||
* @param[in] aRequestId The ID associated with this request.
|
||||
* @param[in] aCallback The callback function pointer to report the outcome (may be NULL if no callback needed).
|
||||
*/
|
||||
void otPlatDnssdUnregisterService(otInstance *aInstance,
|
||||
const otPlatDnssdService *aService,
|
||||
otPlatDnssdRequestId aRequestId,
|
||||
otPlatDnssdRegisterCallback aCallback);
|
||||
|
||||
/**
|
||||
* Registers or updates a host on the infrastructure network's DNS-SD module.
|
||||
*
|
||||
* The @p aHost and all its contained information (strings and arrays) are only valid during this call. The
|
||||
* platform MUST save a copy of the information if it wants to retain the information after returning from this
|
||||
* function.
|
||||
*
|
||||
* The fields in @p aHost follow these rules:
|
||||
*
|
||||
* - The `mHostName` field specifies the host name to register. It is never NULL.
|
||||
* - The `mAddresses` field is an array of IPv6 addresses to register with the host. `mAddressesLength` field provides
|
||||
* the number of entries in `mAddresses` array. The platform implementation MUST not filter or remove any of
|
||||
* addresses in the list.
|
||||
* The OpenThread stack will already ensure that the given addresses are externally reachable. For example, when
|
||||
* registering host from an SRP registration, link-local or mesh-local addresses associated with the host which are
|
||||
* intended for use within Thread mesh are not included in `mAddresses` array passed to this API. The `mAddresses`
|
||||
* array can be empty with zero `mAddressesLength`. In such a case, the platform MUST stop advertising any addresses
|
||||
* for this host name on the infrastructure DNS-SD.
|
||||
* - The `mTtl` field specifies the TTL if non-zero. If zero, the platform can choose the TTL to use.
|
||||
* - The `mInfraIfIndex` field, if non-zero, specifies the infrastructure network interface index to use for this
|
||||
* request. If zero, the platform implementation can decided the interface.
|
||||
*
|
||||
* Regarding the invocation of the @p aCallback and the reuse of the @p aRequestId, this function follows the same
|
||||
* rules as described in `otPlatDnssdRegisterService()`.
|
||||
*
|
||||
* The OpenThread stack will not register the same host (with no changes) that was registered successfully earlier.
|
||||
* Therefore, the platform implementation does not need to check for duplicate/same host and can assume that calls
|
||||
* to this function are either registering a new entry or changing some parameter in a previously registered item. As
|
||||
* a result, these changes always need to be synced on the infrastructure DNS-SD module.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aHost Information about the host to register.
|
||||
* @param[in] aRequestId The ID associated with this request.
|
||||
* @param[in] aCallback The callback function pointer to report the outcome (may be NULL if no callback needed).
|
||||
*/
|
||||
void otPlatDnssdRegisterHost(otInstance *aInstance,
|
||||
const otPlatDnssdHost *aHost,
|
||||
otPlatDnssdRequestId aRequestId,
|
||||
otPlatDnssdRegisterCallback aCallback);
|
||||
|
||||
/**
|
||||
* Unregisters a host on the infrastructure network's DNS-SD module.
|
||||
*
|
||||
* The @p aHost and all its contained information (strings and arrays) are only valid during this call. The
|
||||
* platform MUST save a copy of the information if it wants to retain the information after returning from this
|
||||
* function.
|
||||
*
|
||||
* The fields in @p aHost follow these rules:
|
||||
*
|
||||
* - The `mHostName` field specifies the host name to unregister. It is never NULL.
|
||||
* - The `mInfraIfIndex` field, if non-zero, specifies the infrastructure network interface index to use for this
|
||||
* request. If zero, the platform implementation can decided the interface.
|
||||
* - The rest of the fields in @p aHost structure MUST be ignored in `otPlatDnssdUnregisterHost()` call and may
|
||||
* be set to zero by the OpenThread stack.
|
||||
*
|
||||
* Regarding the invocation of the @p aCallback and the reuse of the @p aRequestId, this function follows the same
|
||||
* rules as described in `otPlatDnssdRegisterService()`.
|
||||
*
|
||||
* The OpenThread stack may request the unregistration of a host that was not previously registered, and the platform
|
||||
* implementation MUST handle this case. In such a case, the platform can use either `OT_ERROR_NOT_FOUND` to indicate
|
||||
* that there was no such registration, or `OT_ERROR_NONE` when invoking the @p aCallback function. OpenThread stack
|
||||
* will handle either case correctly.
|
||||
*
|
||||
* When unregistering a host, the OpenThread stack will also unregister any previously registered services
|
||||
* associated with the same host (by calling `otPlatDnssdUnregisterService()`). However, the platform implementation
|
||||
* MAY assume that unregistering a host also unregisters all its associated services.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aHost Information about the host to unregister.
|
||||
* @param[in] aRequestId The ID associated with this request.
|
||||
* @param[in] aCallback The callback function pointer to report the outcome (may be NULL if no callback needed).
|
||||
*/
|
||||
void otPlatDnssdUnregisterHost(otInstance *aInstance,
|
||||
const otPlatDnssdHost *aHost,
|
||||
otPlatDnssdRequestId aRequestId,
|
||||
otPlatDnssdRegisterCallback aCallback);
|
||||
|
||||
/**
|
||||
* Registers or updates a key record on the infrastructure network's DNS-SD module.
|
||||
*
|
||||
* The @p aKey and all its contained information (strings and arrays) are only valid during this call. The
|
||||
* platform MUST save a copy of the information if it wants to retain the information after returning from this
|
||||
* function.
|
||||
*
|
||||
* The fields in @p aKey follow these rules:
|
||||
*
|
||||
* - If the key is associated with a host, `mName` field specifies the host name and `mServiceType` will be NULL.
|
||||
* - If the key is associated with a service, `mName` field specifies the service instance label and `mServiceType`
|
||||
* field specifies the service type. In this case the DNS name for key record is `{mName}.{mServiceTye}`.
|
||||
* - The `mKeyData` field contains the key record's data with `mKeyDataLength` as its length in byes. It is never NULL.
|
||||
* - The `mClass` fields specifies the resource record class to use when registering key record.
|
||||
* - The `mTtl` field specifies the TTL if non-zero. If zero, the platform can choose the TTL to use.
|
||||
* - The `mInfraIfIndex` field, if non-zero, specifies the infrastructure network interface index to use for this
|
||||
* request. If zero, the platform implementation can decided the interface.
|
||||
*
|
||||
* Regarding the invocation of the @p aCallback and the reuse of the @p aRequestId, this function follows the same
|
||||
* rules as described in `otPlatDnssdRegisterService()`.
|
||||
*
|
||||
* The OpenThread stack will not register the same key (with no changes) that was registered successfully earlier.
|
||||
* Therefore, the platform implementation does not need to check for duplicate/same name and can assume that calls
|
||||
* to this function are either registering a new key or changing the key data in a previously registered one. As
|
||||
* a result, these changes always need to be synced on the infrastructure DNS-SD module.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aKey Information about the key record to register.
|
||||
* @param[in] aRequestId The ID associated with this request.
|
||||
* @param[in] aCallback The callback function pointer to report the outcome (may be NULL if no callback needed).
|
||||
*/
|
||||
void otPlatDnssdRegisterKey(otInstance *aInstance,
|
||||
const otPlatDnssdKey *aKey,
|
||||
otPlatDnssdRequestId aRequestId,
|
||||
otPlatDnssdRegisterCallback aCallback);
|
||||
|
||||
/**
|
||||
* Unregisters a key record on the infrastructure network's DNS-SD module.
|
||||
*
|
||||
* The @p aKey and all its contained information (strings and arrays) are only valid during this call. The
|
||||
* platform MUST save a copy of the information if it wants to retain the information after returning from this
|
||||
* function.
|
||||
*
|
||||
* The fields in @p aKey follow these rules:
|
||||
*
|
||||
* - If the key is associated with a host, `mName` field specifies the host name and `mServiceType` will be NULL.
|
||||
* - If the key is associated with a service, `mName` field specifies the service instance label and `mServiceType`
|
||||
* field specifies the service type. In this case the DNS name for key record is `{mName}.{mServiceTye}`.
|
||||
* - The `mInfraIfIndex` field, if non-zero, specifies the infrastructure network interface index to use for this
|
||||
* request. If zero, the platform implementation can decided the interface.
|
||||
* - The rest of the fields in @p aKey structure MUST be ignored in `otPlatDnssdUnregisterKey()` call and may
|
||||
* be set to zero by the OpenThread stack.
|
||||
*
|
||||
* Regarding the invocation of the @p aCallback and the reuse of the @p aRequestId, this function follows the same
|
||||
* rules as described in `otPlatDnssdRegisterService()`.
|
||||
*
|
||||
* The OpenThread stack may request the unregistration of a key that was not previously registered, and the platform
|
||||
* implementation MUST handle this case. In such a case, the platform can use either `OT_ERROR_NOT_FOUND` to indicate
|
||||
* that there was no such registration, or `OT_ERROR_NONE` when invoking the @p aCallback function. the OpenThread
|
||||
* stack will handle either case correctly.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aKey Information about the key to unregister.
|
||||
* @param[in] aRequestId The ID associated with this request.
|
||||
* @param[in] aCallback The callback function pointer to report the outcome (may be NULL if no callback needed).
|
||||
*/
|
||||
void otPlatDnssdUnregisterKey(otInstance *aInstance,
|
||||
const otPlatDnssdKey *aKey,
|
||||
otPlatDnssdRequestId aRequestId,
|
||||
otPlatDnssdRegisterCallback aCallback);
|
||||
|
||||
//======================================================================================================================
|
||||
|
||||
/**
|
||||
* Represents a browse result.
|
||||
*/
|
||||
typedef struct otPlatDnssdBrowseResult
|
||||
{
|
||||
const char *mServiceType; ///< The service type (e.g., "_mt._udp").
|
||||
const char *mSubTypeLabel; ///< The sub-type label if browsing for sub-type, NULL otherwise.
|
||||
const char *mServiceInstance; ///< Service instance label.
|
||||
uint32_t mTtl; ///< TTL in seconds. Zero TTL indicates that service is removed.
|
||||
uint32_t mInfraIfIndex; ///< The infrastructure network interface index.
|
||||
} otPlatDnssdBrowseResult;
|
||||
|
||||
/**
|
||||
* Represents the callback function used to report a browse result.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResult The browse result.
|
||||
*/
|
||||
typedef void (*otPlatDnssdBrowseCallback)(otInstance *aInstance, const otPlatDnssdBrowseResult *aResult);
|
||||
|
||||
/**
|
||||
* Represents a service browser.
|
||||
*/
|
||||
typedef struct otPlatDnssdBrowser
|
||||
{
|
||||
const char *mServiceType; ///< The service type (e.g., "_mt._udp"). MUST NOT include domain name.
|
||||
const char *mSubTypeLabel; ///< The sub-type label if browsing for sub-type, NULL otherwise.
|
||||
uint32_t mInfraIfIndex; ///< The infrastructure network interface index.
|
||||
otPlatDnssdBrowseCallback mCallback; ///< The callback to report result.
|
||||
} otPlatDnssdBrowser;
|
||||
|
||||
/**
|
||||
* Represents an SRV resolver result.
|
||||
*/
|
||||
typedef struct otPlatDnssdSrvResult
|
||||
{
|
||||
const char *mServiceInstance; ///< The service instance name label.
|
||||
const char *mServiceType; ///< The service type.
|
||||
const char *mHostName; ///< The host name (e.g., "myhost"). Can be NULL when `mTtl` is zero.
|
||||
uint16_t mPort; ///< The service port number.
|
||||
uint16_t mPriority; ///< The service priority.
|
||||
uint16_t mWeight; ///< The service weight.
|
||||
uint32_t mTtl; ///< The service TTL in seconds. Zero TTL indicates SRV record is removed.
|
||||
uint32_t mInfraIfIndex; ///< The infrastructure network interface index.
|
||||
} otPlatDnssdSrvResult;
|
||||
|
||||
/**
|
||||
* Represents the callback function used to report an SRV resolve result.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResult The SRV resolve result.
|
||||
*/
|
||||
typedef void (*otPlatDnssdSrvCallback)(otInstance *aInstance, const otPlatDnssdSrvResult *aResult);
|
||||
|
||||
/**
|
||||
* Represents an SRV service resolver.
|
||||
*/
|
||||
typedef struct otPlatDnssdSrvResolver
|
||||
{
|
||||
const char *mServiceInstance; ///< The service instance label.
|
||||
const char *mServiceType; ///< The service type.
|
||||
uint32_t mInfraIfIndex; ///< The infrastructure network interface index.
|
||||
otPlatDnssdSrvCallback mCallback; ///< The callback to report result.
|
||||
} otPlatDnssdSrvResolver;
|
||||
|
||||
/**
|
||||
* Represents a TXT resolver result.
|
||||
*/
|
||||
typedef struct otPlatDnssdTxtResult
|
||||
{
|
||||
const char *mServiceInstance; ///< The service instance name label.
|
||||
const char *mServiceType; ///< The service type.
|
||||
const uint8_t *mTxtData; ///< Encoded TXT data bytes. Can be NULL when `mTtl` is zero.
|
||||
uint16_t mTxtDataLength; ///< Length of TXT data.
|
||||
uint32_t mTtl; ///< The TXT data TTL in seconds. Zero TTL indicates record is removed.
|
||||
uint32_t mInfraIfIndex; ///< The infrastructure network interface index.
|
||||
} otPlatDnssdTxtResult;
|
||||
|
||||
/**
|
||||
* Represents the callback function used to report a TXT resolve result.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResult The TXT resolve result.
|
||||
*/
|
||||
typedef void (*otPlatDnssdTxtCallback)(otInstance *aInstance, const otPlatDnssdTxtResult *aResult);
|
||||
|
||||
/**
|
||||
* Represents a TXT service resolver.
|
||||
*/
|
||||
typedef struct otPlatDnssdTxtResolver
|
||||
{
|
||||
const char *mServiceInstance; ///< Service instance label.
|
||||
const char *mServiceType; ///< Service type.
|
||||
uint32_t mInfraIfIndex; ///< The infrastructure network interface index.
|
||||
otPlatDnssdTxtCallback mCallback;
|
||||
} otPlatDnssdTxtResolver;
|
||||
|
||||
/**
|
||||
* Represents a discovered host address and its TTL.
|
||||
*/
|
||||
typedef struct otPlatDnssdAddressAndTtl
|
||||
{
|
||||
otIp6Address mAddress; ///< The IPv6 address. For IPv4 address the IPv4-mapped IPv6 address format is used.
|
||||
uint32_t mTtl; ///< The TTL in seconds.
|
||||
} otPlatDnssdAddressAndTtl;
|
||||
|
||||
/**
|
||||
* Represents address resolver result.
|
||||
*/
|
||||
typedef struct otPlatDnssdAddressResult
|
||||
{
|
||||
const char *mHostName; ///< The host name.
|
||||
const otPlatDnssdAddressAndTtl *mAddresses; ///< Array of host addresses and their TTL. Can be NULL if empty.
|
||||
uint16_t mAddressesLength; ///< Number of entries in `mAddresses` array.
|
||||
uint32_t mInfraIfIndex; ///< The infrastructure network interface index.
|
||||
} otPlatDnssdAddressResult;
|
||||
|
||||
/**
|
||||
* Represents the callback function use to report a IPv6/IPv4 address resolve result.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResult The address resolve result.
|
||||
*/
|
||||
typedef void (*otPlatDnssdAddressCallback)(otInstance *aInstance, const otPlatDnssdAddressResult *aResult);
|
||||
|
||||
/**
|
||||
* Represents an address resolver.
|
||||
*/
|
||||
typedef struct otPlatDnssdAddressResolver
|
||||
{
|
||||
const char *mHostName; ///< The host name (e.g., "myhost"). MUST NOT contain domain name.
|
||||
uint32_t mInfraIfIndex; ///< The infrastructure network interface index.
|
||||
otPlatDnssdAddressCallback mCallback; ///< The callback to report result.
|
||||
} otPlatDnssdAddressResolver;
|
||||
|
||||
/**
|
||||
* Starts a service browser.
|
||||
*
|
||||
* Initiates a continuous search for the specified `mServiceType` in @p aBrowser. For sub-type services,
|
||||
* `mSubTypeLabel` specifies the sub-type, for base services, `mSubTypeLabel` is set to NULL.
|
||||
*
|
||||
* Discovered services should be reported through the `mCallback` function in @p aBrowser. Services that have been
|
||||
* removed are reported with a TTL value of zero. The callback may be invoked immediately with cached information
|
||||
* (if available) and potentially before this function returns. When cached results are used, the reported TTL value
|
||||
* should reflect the original TTL from the last received response.
|
||||
*
|
||||
* Multiple browsers can be started for the same service, provided they use different callback functions.
|
||||
*
|
||||
* The @p aBrowser and all its contained information (strings) are only valid during this call. The platform MUST save
|
||||
* a copy of the information if it wants to retain the information after returning from this function.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aBrowser The browser to be started.
|
||||
*/
|
||||
void otPlatDnssdStartBrowser(otInstance *aInstance, const otPlatDnssdBrowser *aBrowser);
|
||||
|
||||
/**
|
||||
* Stops a service browser.
|
||||
*
|
||||
* No action is performed if no matching browser with the same service and callback is currently active.
|
||||
*
|
||||
* The @p aBrowser and all its contained information (strings) are only valid during this call. The platform MUST save
|
||||
* a copy of the information if it wants to retain the information after returning from this function.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aBrowser The browser to stop.
|
||||
*/
|
||||
void otPlatDnssdStopBrowser(otInstance *aInstance, const otPlatDnssdBrowser *aBrowser);
|
||||
|
||||
/**
|
||||
* Starts an SRV record resolver.
|
||||
*
|
||||
* Initiates a continuous SRV record resolver for the specified service in @p aResolver.
|
||||
*
|
||||
* Discovered information should be reported through the `mCallback` function in @p aResolver. When the service is
|
||||
* removed it is reported with a TTL value of zero. In this case, `mHostName` may be NULL and other result fields (such
|
||||
* as `mPort`) will be ignored by the OpenThread stack.
|
||||
*
|
||||
* The callback may be invoked immediately with cached information (if available) and potentially before this function
|
||||
* returns. When cached result is used, the reported TTL value should reflect the original TTL from the last received
|
||||
* response.
|
||||
*
|
||||
* Multiple resolvers can be started for the same service, provided they use different callback functions.
|
||||
*
|
||||
* The @p aResolver and all its contained information (strings) are only valid during this call. The platform MUST save
|
||||
* a copy of the information if it wants to retain the information after returning from this function.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to be started.
|
||||
*/
|
||||
void otPlatDnssdStartSrvResolver(otInstance *aInstance, const otPlatDnssdSrvResolver *aResolver);
|
||||
|
||||
/**
|
||||
* Stops an SRV record resolver.
|
||||
*
|
||||
* No action is performed if no matching resolver with the same service and callback is currently active.
|
||||
*
|
||||
* The @p aResolver and all its contained information (strings) are only valid during this call. The platform MUST save
|
||||
* a copy of the information if it wants to retain the information after returning from this function.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to stop.
|
||||
*/
|
||||
void otPlatDnssdStopSrvResolver(otInstance *aInstance, const otPlatDnssdSrvResolver *aResolver);
|
||||
|
||||
/**
|
||||
* Starts a TXT record resolver.
|
||||
*
|
||||
* Initiates a continuous TXT record resolver for the specified service in @p aResolver.
|
||||
*
|
||||
* Discovered information should be reported through the `mCallback` function in @p aResolver. When the TXT record is
|
||||
* removed it is reported with a TTL value of zero. In this case, `mTxtData` may be NULL, and other result fields
|
||||
* (such as `mTxtDataLength`) will be ignored by the OpenThread stack.
|
||||
*
|
||||
* The callback may be invoked immediately with cached information (if available) and potentially before this function
|
||||
* returns. When cached result is used, the reported TTL value should reflect the original TTL from the last received
|
||||
* response.
|
||||
*
|
||||
* Multiple resolvers can be started for the same service, provided they use different callback functions.
|
||||
*
|
||||
* The @p aResolver and all its contained information (strings) are only valid during this call. The platform MUST save
|
||||
* a copy of the information if it wants to retain the information after returning from this function.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to be started.
|
||||
*/
|
||||
void otPlatDnssdStartTxtResolver(otInstance *aInstance, const otPlatDnssdTxtResolver *aResolver);
|
||||
|
||||
/**
|
||||
* Stops a TXT record resolver.
|
||||
*
|
||||
* No action is performed if no matching resolver with the same service and callback is currently active.
|
||||
*
|
||||
* The @p aResolver and all its contained information (strings) are only valid during this call. The platform MUST save
|
||||
* a copy of the information if it wants to retain the information after returning from this function.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to stop.
|
||||
*/
|
||||
void otPlatDnssdStopTxtResolver(otInstance *aInstance, const otPlatDnssdTxtResolver *aResolver);
|
||||
|
||||
/**
|
||||
* Starts an IPv6 address resolver.
|
||||
*
|
||||
* Initiates a continuous IPv6 address resolver for the specified host name in @p aResolver.
|
||||
*
|
||||
* Discovered addresses should be reported through the `mCallback` function in @p aResolver. The callback should be
|
||||
* invoked whenever addresses are added or removed, providing an updated list. If all addresses are removed, the
|
||||
* callback should be invoked with an empty list (`mAddressesLength` set to zero).
|
||||
*
|
||||
* The callback may be invoked immediately with cached information (if available) and potentially before this function
|
||||
* returns. When cached result is used, the reported TTL values should reflect the original TTL from the last received
|
||||
* response.
|
||||
*
|
||||
* Multiple resolvers can be started for the same host name, provided they use different callback functions.
|
||||
*
|
||||
* The @p aResolver and all its contained information (strings) are only valid during this call. The platform MUST save
|
||||
* a copy of the information if it wants to retain the information after returning from this function.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to be started.
|
||||
*/
|
||||
void otPlatDnssdStartIp6AddressResolver(otInstance *aInstance, const otPlatDnssdAddressResolver *aResolver);
|
||||
|
||||
/**
|
||||
* Stops an IPv6 address resolver.
|
||||
*
|
||||
* No action is performed if no matching resolver with the same host name and callback is currently active.
|
||||
*
|
||||
* The @p aResolver and all its contained information (strings) are only valid during this call. The platform MUST save
|
||||
* a copy of the information if it wants to retain the information after returning from this function.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to stop.
|
||||
*/
|
||||
void otPlatDnssdStopIp6AddressResolver(otInstance *aInstance, const otPlatDnssdAddressResolver *aResolver);
|
||||
|
||||
/**
|
||||
* Starts an IPv4 address resolver.
|
||||
*
|
||||
* Initiates a continuous IPv4 address resolver for the specified host name in @p aResolver.
|
||||
*
|
||||
* Discovered addresses should be reported through the `mCallback` function in @p aResolver. The IPv4 addresses are
|
||||
* represented using the IPv4-mapped IPv6 address format in `mAddresses` array. The callback should be invoked
|
||||
* whenever addresses are added or removed, providing an updated list. If all addresses are removed, the callback
|
||||
* should be invoked with an empty list (`mAddressesLength` set to zero).
|
||||
*
|
||||
* The callback may be invoked immediately with cached information (if available) and potentially before this function
|
||||
* returns. When cached result is used, the reported TTL values will reflect the original TTL from the last received
|
||||
* response.
|
||||
*
|
||||
* Multiple resolvers can be started for the same host name, provided they use different callback functions.
|
||||
*
|
||||
* The @p aResolver and all its contained information (strings) are only valid during this call. The platform MUST save
|
||||
* a copy of the information if it wants to retain the information after returning from this function.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to be started.
|
||||
*/
|
||||
void otPlatDnssdStartIp4AddressResolver(otInstance *aInstance, const otPlatDnssdAddressResolver *aResolver);
|
||||
|
||||
/**
|
||||
* Stops an IPv4 address resolver.
|
||||
*
|
||||
* No action is performed if no matching resolver with the same host name and callback is currently active.
|
||||
*
|
||||
* The @p aResolver and all its contained information (strings) are only valid during this call. The platform MUST save
|
||||
* a copy of the information if it wants to retain the information after returning from this function.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aResolver The resolver to stop.
|
||||
*/
|
||||
void otPlatDnssdStopIp4AddressResolver(otInstance *aInstance, const otPlatDnssdAddressResolver *aResolver);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_DNSSD_H_
|
||||
191
Libs/util/third_party/openthread/include/openthread/platform/dso_transport.h
vendored
Normal file
191
Libs/util/third_party/openthread/include/openthread/platform/dso_transport.h
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform abstraction for DNS Stateful Operations (DSO) transport.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_DSO_TRANSPORT_H_
|
||||
#define OPENTHREAD_PLATFORM_DSO_TRANSPORT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/message.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Represents a DSO connection.
|
||||
*
|
||||
* It is an opaque struct (the platform implementation only deals with pointers to this struct).
|
||||
*/
|
||||
typedef struct otPlatDsoConnection otPlatDsoConnection;
|
||||
|
||||
/**
|
||||
* Can be used by DSO platform implementation to get the the OpenThread instance associated with a
|
||||
* connection instance.
|
||||
*
|
||||
* @param[in] aConnection A pointer to the DSO connection.
|
||||
*
|
||||
* @returns A pointer to the `otInstance`.
|
||||
*/
|
||||
extern otInstance *otPlatDsoGetInstance(otPlatDsoConnection *aConnection);
|
||||
|
||||
/**
|
||||
* Starts or stops listening for incoming connection requests on transport layer.
|
||||
*
|
||||
* For DNS-over-TLS, the transport layer MUST listen on port 853 and follow RFC 7858.
|
||||
*
|
||||
* While listening is enabled, if a connection request is received, the `otPlatDsoAccept()` callback MUST be called.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aEnable TRUE to start listening, FALSE to stop listening.
|
||||
*/
|
||||
void otPlatDsoEnableListening(otInstance *aInstance, bool aEnable);
|
||||
|
||||
/**
|
||||
* Is a callback from the DSO platform to indicate an incoming connection request when listening is
|
||||
* enabled.
|
||||
*
|
||||
* Determines whether or not to accept the connection request. It returns a non-null `otPlatDsoConnection`
|
||||
* pointer if the request is to be accepted, or `NULL` if the request is to be rejected.
|
||||
*
|
||||
* If a non-null connection pointer is returned, the platform layer MUST continue establishing the connection with the
|
||||
* peer. The platform reports the outcome by invoking `otPlatDsoHandleConnected()` callback on success or
|
||||
* `otPlatDsoHandleDisconnected()` callback on failure.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aPeerSockAddr The socket address (IPv6 address and port number) of the peer requesting connection.
|
||||
*
|
||||
* @returns A pointer to the `otPlatDsoConnection` to use if to accept, or `NULL` if to reject.
|
||||
*/
|
||||
extern otPlatDsoConnection *otPlatDsoAccept(otInstance *aInstance, const otSockAddr *aPeerSockAddr);
|
||||
|
||||
/**
|
||||
* Requests the platform layer to initiate establishing a connection with a peer.
|
||||
*
|
||||
* The platform reports the outcome by invoking `otPlatDsoHandleConnected()` callback on success or
|
||||
* `otPlatDsoHandleDisconnected()` callback (on failure).
|
||||
*
|
||||
* @param[in] aConnection The connection.
|
||||
* @param[in] aPeerSockAddr The socket address (IPv6 address and port number) of the peer to connect to.
|
||||
*/
|
||||
void otPlatDsoConnect(otPlatDsoConnection *aConnection, const otSockAddr *aPeerSockAddr);
|
||||
|
||||
/**
|
||||
* Is a callback from the platform layer to indicate that a connection is successfully established.
|
||||
*
|
||||
* It MUST be called either after accepting an incoming connection (`otPlatDsoAccept`) or after a `otPlatDsoConnect()`
|
||||
* call.
|
||||
*
|
||||
* Only after this callback, the connection can be used to send and receive messages.
|
||||
*
|
||||
* @param[in] aConnection The connection.
|
||||
*/
|
||||
extern void otPlatDsoHandleConnected(otPlatDsoConnection *aConnection);
|
||||
|
||||
/**
|
||||
* Sends a DSO message to the peer on a connection.
|
||||
*
|
||||
* Is used only after the connection is successfully established (after `otPlatDsoHandleConnected()`
|
||||
* callback).
|
||||
*
|
||||
* Passes the ownership of the @p aMessage to the DSO platform layer, and the platform implementation is
|
||||
* expected to free the message once it is no longer needed.
|
||||
*
|
||||
* The @p aMessage contains the DNS message (starting with DNS header). Note that it does not contain the the length
|
||||
* field that is needed when sending over TLS/TCP transport. The platform layer MUST therefore include the length
|
||||
* field when passing the message to TLS/TCP layer.
|
||||
*
|
||||
* @param[in] aConnection The connection to send on.
|
||||
* @param[in] aMessage The message to send.
|
||||
*/
|
||||
void otPlatDsoSend(otPlatDsoConnection *aConnection, otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Is a callback from the platform layer to indicate that a DNS message was received over a connection.
|
||||
*
|
||||
* The platform MUST call this function only after the connection is successfully established (after callback
|
||||
* `otPlatDsoHandleConnected()` is invoked).
|
||||
*
|
||||
* Passes the ownership of the @p aMessage from the DSO platform layer to OpenThread. OpenThread will
|
||||
* free the message when no longer needed.
|
||||
*
|
||||
* The @p aMessage MUST contain the DNS message (starting with DNS header) and not include the length field that may
|
||||
* be included in TCP/TLS exchange.
|
||||
*
|
||||
* @param[in] aConnection The connection on which the message was received.
|
||||
* @param[in] aMessage The received message.
|
||||
*/
|
||||
extern void otPlatDsoHandleReceive(otPlatDsoConnection *aConnection, otMessage *aMessage);
|
||||
|
||||
/**
|
||||
* Defines disconnect modes.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_PLAT_DSO_DISCONNECT_MODE_GRACEFULLY_CLOSE, ///< Gracefully close the connection.
|
||||
OT_PLAT_DSO_DISCONNECT_MODE_FORCIBLY_ABORT, ///< Forcibly abort the connection.
|
||||
} otPlatDsoDisconnectMode;
|
||||
|
||||
/**
|
||||
* Requests a connection to be disconnected.
|
||||
*
|
||||
* After calling this function, the DSO platform implementation MUST NOT maintain `aConnection` pointer (platform
|
||||
* MUST NOT call any callbacks using this `Connection` pointer anymore). In particular, calling `otPlatDsoDisconnect()`
|
||||
* MUST NOT trigger the callback `otPlatDsoHandleDisconnected()`.
|
||||
*
|
||||
* @param[in] aConnection The connection to disconnect
|
||||
* @param[in] aMode The disconnect mode (close gracefully or forcibly abort).
|
||||
*/
|
||||
void otPlatDsoDisconnect(otPlatDsoConnection *aConnection, otPlatDsoDisconnectMode aMode);
|
||||
|
||||
/**
|
||||
* Is a callback from the platform layer to indicate that peer closed/aborted the connection or the
|
||||
* connection establishment failed (e.g., peer rejected a connection request).
|
||||
*
|
||||
* After calling this function, the DSO platform implementation MUST NOT maintain `aConnection` pointer (platform
|
||||
* MUST NOT call any callbacks using this `Connection` pointer anymore).
|
||||
*
|
||||
* @param[in] aConnection The connection which disconnected.
|
||||
* @param[in] aMode The disconnect mode (closed gracefully or forcibly aborted).
|
||||
*/
|
||||
extern void otPlatDsoHandleDisconnected(otPlatDsoConnection *aConnection, otPlatDsoDisconnectMode aMode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_DSO_TRANSPORT_H_
|
||||
77
Libs/util/third_party/openthread/include/openthread/platform/entropy.h
vendored
Normal file
77
Libs/util/third_party/openthread/include/openthread/platform/entropy.h
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform abstraction for entropy generation.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_ENTROPY_H_
|
||||
#define OPENTHREAD_PLATFORM_ENTROPY_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-entropy
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for entropy generation.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fill buffer with entropy.
|
||||
*
|
||||
* MUST be implemented using a true random number generator (TRNG).
|
||||
*
|
||||
* @param[out] aOutput A pointer to where the true random values are placed. Must not be NULL.
|
||||
* @param[in] aOutputLength Size of @p aBuffer.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully filled @p aBuffer with true random values.
|
||||
* @retval OT_ERROR_FAILED Failed to fill @p aBuffer with true random values.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aBuffer was set to NULL.
|
||||
*/
|
||||
otError otPlatEntropyGet(uint8_t *aOutput, uint16_t aOutputLength);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_ENTROPY_H_
|
||||
90
Libs/util/third_party/openthread/include/openthread/platform/flash.h
vendored
Normal file
90
Libs/util/third_party/openthread/include/openthread/platform/flash.h
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_FLASH_H_
|
||||
#define OPENTHREAD_PLATFORM_FLASH_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initializes the flash driver.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
void otPlatFlashInit(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the size of the swap space.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @returns The size of the swap space in bytes.
|
||||
*/
|
||||
uint32_t otPlatFlashGetSwapSize(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Erases the swap space indicated by @p aSwapIndex.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aSwapIndex A value in [0, 1] that indicates the swap space.
|
||||
*/
|
||||
void otPlatFlashErase(otInstance *aInstance, uint8_t aSwapIndex);
|
||||
|
||||
/**
|
||||
* Reads @p aSize bytes into @p aData.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aSwapIndex A value in [0, 1] that indicates the swap space.
|
||||
* @param[in] aOffset A byte offset within the swap space.
|
||||
* @param[out] aData A pointer to the data buffer for reading.
|
||||
* @param[in] aSize Number of bytes to read.
|
||||
*/
|
||||
void otPlatFlashRead(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, void *aData, uint32_t aSize);
|
||||
|
||||
/**
|
||||
* Writes @p aSize bytes from @p aData.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aSwapIndex A value in [0, 1] that indicates the swap space.
|
||||
* @param[in] aOffset A byte offset within the swap space.
|
||||
* @param[out] aData A pointer to the data to write.
|
||||
* @param[in] aSize Number of bytes to write.
|
||||
*/
|
||||
void otPlatFlashWrite(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, const void *aData, uint32_t aSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_FLASH_H_
|
||||
193
Libs/util/third_party/openthread/include/openthread/platform/infra_if.h
vendored
Normal file
193
Libs/util/third_party/openthread/include/openthread/platform/infra_if.h
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform abstraction for the infrastructure network interface.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_INFRA_IF_H_
|
||||
#define OPENTHREAD_PLATFORM_INFRA_IF_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/ip6.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OT_PLAT_INFRA_IF_MAX_LINK_LAYER_ADDR_LENGTH 16 ///< Maximum InfraIf Link-layer address length.
|
||||
|
||||
/**
|
||||
* Represents an InfraIf Link-Layer Address.
|
||||
*/
|
||||
typedef struct otPlatInfraIfLinkLayerAddress
|
||||
{
|
||||
uint8_t mAddress[OT_PLAT_INFRA_IF_MAX_LINK_LAYER_ADDR_LENGTH]; ///< The link-layer address bytes.
|
||||
uint8_t mLength; ///< The address length (number of bytes).
|
||||
} otPlatInfraIfLinkLayerAddress;
|
||||
|
||||
/**
|
||||
* @addtogroup plat-infra-if
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for the adjacent infrastructure network interface.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tells whether an infra interface has the given IPv6 address assigned.
|
||||
*
|
||||
* @param[in] aInfraIfIndex The index of the infra interface.
|
||||
* @param[in] aAddress The IPv6 address.
|
||||
*
|
||||
* @returns TRUE if the infra interface has given IPv6 address assigned, FALSE otherwise.
|
||||
*/
|
||||
bool otPlatInfraIfHasAddress(uint32_t aInfraIfIndex, const otIp6Address *aAddress);
|
||||
|
||||
/**
|
||||
* Sends an ICMPv6 Neighbor Discovery message on given infrastructure interface.
|
||||
*
|
||||
* See RFC 4861: https://tools.ietf.org/html/rfc4861.
|
||||
*
|
||||
* @param[in] aInfraIfIndex The index of the infrastructure interface this message is sent to.
|
||||
* @param[in] aDestAddress The destination address this message is sent to.
|
||||
* @param[in] aBuffer The ICMPv6 message buffer. The ICMPv6 checksum is left zero and the
|
||||
* platform should do the checksum calculate.
|
||||
* @param[in] aBufferLength The length of the message buffer.
|
||||
*
|
||||
* @note Per RFC 4861, the implementation should send the message with IPv6 link-local source address
|
||||
* of interface @p aInfraIfIndex and IP Hop Limit 255.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully sent the ICMPv6 message.
|
||||
* @retval OT_ERROR_FAILED Failed to send the ICMPv6 message.
|
||||
*/
|
||||
otError otPlatInfraIfSendIcmp6Nd(uint32_t aInfraIfIndex,
|
||||
const otIp6Address *aDestAddress,
|
||||
const uint8_t *aBuffer,
|
||||
uint16_t aBufferLength);
|
||||
|
||||
/**
|
||||
* The infra interface driver calls this method to notify OpenThread
|
||||
* that an ICMPv6 Neighbor Discovery message is received.
|
||||
*
|
||||
* See RFC 4861: https://tools.ietf.org/html/rfc4861.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aInfraIfIndex The index of the infrastructure interface on which the ICMPv6 message is received.
|
||||
* @param[in] aSrcAddress The source address this message is received from.
|
||||
* @param[in] aBuffer The ICMPv6 message buffer.
|
||||
* @param[in] aBufferLength The length of the ICMPv6 message buffer.
|
||||
*
|
||||
* @note Per RFC 4861, the caller should enforce that the source address MUST be a IPv6 link-local
|
||||
* address and the IP Hop Limit MUST be 255.
|
||||
*/
|
||||
extern void otPlatInfraIfRecvIcmp6Nd(otInstance *aInstance,
|
||||
uint32_t aInfraIfIndex,
|
||||
const otIp6Address *aSrcAddress,
|
||||
const uint8_t *aBuffer,
|
||||
uint16_t aBufferLength);
|
||||
|
||||
/**
|
||||
* The infra interface driver calls this method to notify OpenThread
|
||||
* of the interface state changes.
|
||||
*
|
||||
* It is fine for the platform to call to method even when the running state
|
||||
* of the interface hasn't changed. In this case, the Routing Manager state is
|
||||
* not affected.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aInfraIfIndex The index of the infrastructure interface.
|
||||
* @param[in] aIsRunning A boolean that indicates whether the infrastructure
|
||||
* interface is running.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully updated the infra interface status.
|
||||
* @retval OT_ERROR_INVALID_STATE The Routing Manager is not initialized.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aInfraIfIndex doesn't match the infra interface the
|
||||
* Routing Manager are initialized with.
|
||||
*/
|
||||
extern otError otPlatInfraIfStateChanged(otInstance *aInstance, uint32_t aInfraIfIndex, bool aIsRunning);
|
||||
|
||||
/**
|
||||
* Send a request to discover the NAT64 prefix on the infrastructure interface with @p aInfraIfIndex.
|
||||
*
|
||||
* OpenThread will call this method periodically to monitor the presence or change of NAT64 prefix.
|
||||
*
|
||||
* @param[in] aInfraIfIndex The index of the infrastructure interface to discover the NAT64 prefix.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully request NAT64 prefix discovery.
|
||||
* @retval OT_ERROR_FAILED Failed to request NAT64 prefix discovery.
|
||||
*/
|
||||
otError otPlatInfraIfDiscoverNat64Prefix(uint32_t aInfraIfIndex);
|
||||
|
||||
/**
|
||||
* The infra interface driver calls this method to notify OpenThread that
|
||||
* the discovery of NAT64 prefix is done.
|
||||
*
|
||||
* Is expected to be invoked after calling otPlatInfraIfDiscoverNat64Prefix.
|
||||
* If no NAT64 prefix is discovered, @p aIp6Prefix shall point to an empty prefix with zero length.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aInfraIfIndex The index of the infrastructure interface on which the NAT64 prefix is discovered.
|
||||
* @param[in] aIp6Prefix A pointer to NAT64 prefix.
|
||||
*/
|
||||
extern void otPlatInfraIfDiscoverNat64PrefixDone(otInstance *aInstance,
|
||||
uint32_t aInfraIfIndex,
|
||||
const otIp6Prefix *aIp6Prefix);
|
||||
|
||||
/**
|
||||
* Get the link-layer address of the infrastructure interface.
|
||||
*
|
||||
* OpenThread invokes this method when the address is required, for example: when generating an ND6 message
|
||||
* which includes a source link-layer address option.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aInfraIfIndex The index of the infrastructure interface.
|
||||
* @param[out] aInfraIfLinkLayerAddress A pointer to infrastructure interface link-layer address.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully get the infrastructure interface link-layer address.
|
||||
* @retval OT_ERROR_FAILED Failed to get the infrastructure interface link-layer address.
|
||||
*/
|
||||
otError otPlatGetInfraIfLinkLayerAddress(otInstance *aInstance,
|
||||
uint32_t aIfIndex,
|
||||
otPlatInfraIfLinkLayerAddress *aInfraIfLinkLayerAddress);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_INFRA_IF_H_
|
||||
174
Libs/util/third_party/openthread/include/openthread/platform/logging.h
vendored
Normal file
174
Libs/util/third_party/openthread/include/openthread/platform/logging.h
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform abstraction for the debug log service.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_LOGGING_H_
|
||||
#define OPENTHREAD_PLATFORM_LOGGING_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-logging
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for the debug log service.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Log level None.
|
||||
*
|
||||
* @note Log Levels are defines so that embedded implementations can eliminate code at compile time via
|
||||
* #if/#else/#endif.
|
||||
*/
|
||||
#define OT_LOG_LEVEL_NONE 0
|
||||
|
||||
/**
|
||||
* Log level Critical.
|
||||
*
|
||||
* @note Log Levels are defines so that embedded implementations can eliminate code at compile time via
|
||||
* #if/#else/#endif.
|
||||
*/
|
||||
#define OT_LOG_LEVEL_CRIT 1
|
||||
|
||||
/**
|
||||
* Log level Warning.
|
||||
*
|
||||
* @note Log Levels are defines so that embedded implementations can eliminate code at compile time via
|
||||
* #if/#else/#endif.
|
||||
*/
|
||||
#define OT_LOG_LEVEL_WARN 2
|
||||
|
||||
/**
|
||||
* Log level Notice.
|
||||
*
|
||||
* @note Log Levels are defines so that embedded implementations can eliminate code at compile time via
|
||||
* #if/#else/#endif.
|
||||
*/
|
||||
#define OT_LOG_LEVEL_NOTE 3
|
||||
|
||||
/**
|
||||
* Log level Informational.
|
||||
*
|
||||
* @note Log Levels are defines so that embedded implementations can eliminate code at compile time via
|
||||
* #if/#else/#endif.
|
||||
*/
|
||||
#define OT_LOG_LEVEL_INFO 4
|
||||
|
||||
/**
|
||||
* Log level Debug.
|
||||
*
|
||||
* @note Log Levels are defines so that embedded implementations can eliminate code at compile time via
|
||||
* #if/#else/#endif.
|
||||
*/
|
||||
#define OT_LOG_LEVEL_DEBG 5
|
||||
|
||||
/**
|
||||
* Represents the log level.
|
||||
*/
|
||||
typedef int otLogLevel;
|
||||
|
||||
/**
|
||||
* Represents log regions.
|
||||
*
|
||||
* The support for log region is removed and instead each core module can define its own name to appended to the logs.
|
||||
* However, the `otLogRegion` enumeration is still defined as before to help with platforms which we may be using it
|
||||
* in their `otPlatLog()` implementation. The OT core will always emit all logs with `OT_LOG_REGION_CORE`.
|
||||
*/
|
||||
typedef enum otLogRegion
|
||||
{
|
||||
OT_LOG_REGION_API = 1, ///< OpenThread API
|
||||
OT_LOG_REGION_MLE = 2, ///< MLE
|
||||
OT_LOG_REGION_ARP = 3, ///< EID-to-RLOC mapping.
|
||||
OT_LOG_REGION_NET_DATA = 4, ///< Network Data
|
||||
OT_LOG_REGION_ICMP = 5, ///< ICMPv6
|
||||
OT_LOG_REGION_IP6 = 6, ///< IPv6
|
||||
OT_LOG_REGION_TCP = 7, ///< TCP
|
||||
OT_LOG_REGION_MAC = 8, ///< IEEE 802.15.4 MAC
|
||||
OT_LOG_REGION_MEM = 9, ///< Memory
|
||||
OT_LOG_REGION_NCP = 10, ///< NCP
|
||||
OT_LOG_REGION_MESH_COP = 11, ///< Mesh Commissioning Protocol
|
||||
OT_LOG_REGION_NET_DIAG = 12, ///< Network Diagnostic
|
||||
OT_LOG_REGION_PLATFORM = 13, ///< Platform
|
||||
OT_LOG_REGION_COAP = 14, ///< CoAP
|
||||
OT_LOG_REGION_CLI = 15, ///< CLI
|
||||
OT_LOG_REGION_CORE = 16, ///< OpenThread Core
|
||||
OT_LOG_REGION_UTIL = 17, ///< Utility module
|
||||
OT_LOG_REGION_BBR = 18, ///< Backbone Router (available since Thread 1.2)
|
||||
OT_LOG_REGION_MLR = 19, ///< Multicast Listener Registration (available since Thread 1.2)
|
||||
OT_LOG_REGION_DUA = 20, ///< Domain Unicast Address (available since Thread 1.2)
|
||||
OT_LOG_REGION_BR = 21, ///< Border Router
|
||||
OT_LOG_REGION_SRP = 22, ///< Service Registration Protocol (SRP)
|
||||
OT_LOG_REGION_DNS = 23, ///< DNS
|
||||
} otLogRegion;
|
||||
|
||||
/**
|
||||
* Outputs logs.
|
||||
*
|
||||
* Note that the support for log region is removed. The OT core will always emit all logs with `OT_LOG_REGION_CORE`
|
||||
* as @p aLogRegion.
|
||||
*
|
||||
* @param[in] aLogLevel The log level.
|
||||
* @param[in] aLogRegion The log region.
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*/
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...);
|
||||
|
||||
/**
|
||||
* Handles OpenThread log level changes.
|
||||
*
|
||||
* This platform function is called whenever the OpenThread log level changes.
|
||||
* This platform function is optional since an empty weak implementation has been provided.
|
||||
*
|
||||
* @note Only applicable when `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1`.
|
||||
*
|
||||
* @param[in] aLogLevel The new OpenThread log level.
|
||||
*/
|
||||
void otPlatLogHandleLevelChanged(otLogLevel aLogLevel);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_LOGGING_H_
|
||||
165
Libs/util/third_party/openthread/include/openthread/platform/mdns_socket.h
vendored
Normal file
165
Libs/util/third_party/openthread/include/openthread/platform/mdns_socket.h
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright (c) 2024, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform abstraction for mDNS socket.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_MULTICAST_DNS_SOCKET_H_
|
||||
#define OPENTHREAD_PLATFORM_MULTICAST_DNS_SOCKET_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/message.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-mdns
|
||||
*
|
||||
* @brief
|
||||
* This module defines platform APIs for Multicast DNS (mDNS) socket.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a socket address info.
|
||||
*/
|
||||
typedef struct otPlatMdnsAddressInfo
|
||||
{
|
||||
otIp6Address mAddress; ///< IP address. IPv4-mapped IPv6 format should be used to represent IPv4 address.
|
||||
uint16_t mPort; ///< Port number.
|
||||
uint32_t mInfraIfIndex; ///< Interface index.
|
||||
} otPlatMdnsAddressInfo;
|
||||
|
||||
/**
|
||||
* Enables or disables listening for mDNS messages sent to mDNS port 5353.
|
||||
*
|
||||
* When listening is enabled, the platform MUST listen for multicast messages sent to UDP destination port 5353 at the
|
||||
* mDNS link-local multicast address `224.0.0.251` and its IPv6 equivalent `ff02::fb`.
|
||||
*
|
||||
* The platform SHOULD also listen for any unicast messages sent to UDP destination port 5353. If this is not possible,
|
||||
* then OpenThread mDNS module can be configured to not use any "QU" questions requesting unicast response.
|
||||
*
|
||||
* While enabled, all received messages MUST be reported back using `otPlatMdnsHandleReceive()` callback.
|
||||
*
|
||||
* @param[in] aInstance The OpernThread instance.
|
||||
* @param[in] aEnable Indicate whether to enable or disable.
|
||||
* @param[in] aInfraInfIndex The infrastructure network interface index.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully enabled/disabled listening for mDNS messages.
|
||||
* @retval OT_ERROR_FAILED Failed to enable/disable listening for mDNS messages.
|
||||
*/
|
||||
otError otPlatMdnsSetListeningEnabled(otInstance *aInstance, bool aEnable, uint32_t aInfraIfIndex);
|
||||
|
||||
/**
|
||||
* Sends an mDNS message as multicast.
|
||||
*
|
||||
* The platform MUST multicast the prepared mDNS message in @p aMessage as a UDP message using the mDNS well-known port
|
||||
* number 5353 for both source and destination ports. The message MUST be sent to the mDNS link-local multicast
|
||||
* address `224.0.0.251` and/or its IPv6 equivalent `ff02::fb`.
|
||||
*
|
||||
* @p aMessage contains the mDNS message starting with DNS header at offset zero. It does not include IP or UDP headers.
|
||||
* This function passes the ownership of @p aMessage to the platform layer and platform implementation MUST free
|
||||
* @p aMessage once sent and no longer needed.
|
||||
*
|
||||
* The platform MUST allow multicast loopback, i.e., the multicast message @p aMessage MUST also be received and
|
||||
* passed back to OpenThread stack using `otPlatMdnsHandleReceive()` callback. This behavior is essential for the
|
||||
* OpenThread mDNS stack to process and potentially respond to its own queries, while allowing other mDNS receivers
|
||||
* to also receive the query and its response.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aMessage The mDNS message to multicast. Ownership is transferred to the platform layer.
|
||||
* @param[in] aInfraIfIndex The infrastructure network interface index.
|
||||
*/
|
||||
void otPlatMdnsSendMulticast(otInstance *aInstance, otMessage *aMessage, uint32_t aInfraIfIndex);
|
||||
|
||||
/**
|
||||
* Sends an mDNS message as unicast.
|
||||
*
|
||||
* The platform MUST send the prepared mDNS message in @p aMessage as a UDP message using source UDP port 5353 to
|
||||
* the destination address and port number specified by @p aAddress.
|
||||
*
|
||||
* @p aMessage contains the DNS message starting with the DNS header at offset zero. It does not include IP or UDP
|
||||
* headers. This function passes the ownership of @p aMessage to the platform layer and platform implementation
|
||||
* MUST free @p aMessage once sent and no longer needed.
|
||||
*
|
||||
* The @p aAddress fields are as follows:
|
||||
*
|
||||
* - `mAddress` specifies the destination address. IPv4-mapped IPv6 format is used to represent an IPv4 destination.
|
||||
* - `mPort` specifies the destination port.
|
||||
* - `mInfraIndex` specifies the interface index.
|
||||
*
|
||||
* If the @aAddress matches this devices address, the platform MUST ensure to receive and pass the message back to
|
||||
* the OpenThread stack using `otPlatMdnsHandleReceive()` for processing.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aMessage The mDNS message to multicast. Ownership is transferred to platform layer.
|
||||
* @param[in] aAddress The destination address info.
|
||||
*/
|
||||
void otPlatMdnsSendUnicast(otInstance *aInstance, otMessage *aMessage, const otPlatMdnsAddressInfo *aAddress);
|
||||
|
||||
/**
|
||||
* Callback to notify OpenThread mDNS module of a received message on UDP port 5353.
|
||||
*
|
||||
* @p aMessage MUST contain DNS message starting with the DNS header at offset zero. This function passes the
|
||||
* ownership of @p aMessage from the platform layer to the OpenThread stack. The OpenThread stack will free the
|
||||
* message once processed.
|
||||
*
|
||||
* The @p aAddress fields are as follows:
|
||||
*
|
||||
* - `mAddress` specifies the sender's address. IPv4-mapped IPv6 format is used to represent an IPv4 destination.
|
||||
* - `mPort` specifies the sender's port.
|
||||
* - `mInfraIndex` specifies the interface index.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aMessage The received mDNS message. Ownership is transferred to the OpenThread stack.
|
||||
* @param[in] aIsUnicast Indicates whether the received message is unicast or multicast.
|
||||
* @param[in] aAddress The sender's address info.
|
||||
*/
|
||||
extern void otPlatMdnsHandleReceive(otInstance *aInstance,
|
||||
otMessage *aMessage,
|
||||
bool aIsUnicast,
|
||||
const otPlatMdnsAddressInfo *aAddress);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_MULTICAST_DNS_SOCKET_H_
|
||||
92
Libs/util/third_party/openthread/include/openthread/platform/memory.h
vendored
Normal file
92
Libs/util/third_party/openthread/include/openthread/platform/memory.h
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform abstraction for dynamic memory allocation.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_MEMORY_H_
|
||||
#define OPENTHREAD_PLATFORM_MEMORY_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-memory
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for dynamic memory allocation.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* OpenThread only requires dynamic memory allocation when supporting multiple simultaneous instances, for MbedTls.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Dynamically allocates new memory. On platforms that support it, should just redirect to calloc. For
|
||||
* those that don't support calloc, should support the same functionality:
|
||||
*
|
||||
* "The calloc() function contiguously allocates enough space for count objects that are size bytes of
|
||||
* memory each and returns a pointer to the allocated memory. The allocated memory is filled with bytes
|
||||
* of value zero."
|
||||
*
|
||||
* Is required for OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE.
|
||||
*
|
||||
* @param[in] aNum The number of blocks to allocate
|
||||
* @param[in] aSize The size of each block to allocate
|
||||
*
|
||||
* @retval void* The pointer to the front of the memory allocated
|
||||
* @retval NULL Failed to allocate the memory requested.
|
||||
*/
|
||||
void *otPlatCAlloc(size_t aNum, size_t aSize);
|
||||
|
||||
/**
|
||||
* Frees memory that was dynamically allocated.
|
||||
*
|
||||
* Is required for OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE.
|
||||
*
|
||||
* @param[in] aPtr A pointer the memory blocks to free. The pointer may be NULL.
|
||||
*/
|
||||
void otPlatFree(void *aPtr);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_MEMORY_H_
|
||||
116
Libs/util/third_party/openthread/include/openthread/platform/messagepool.h
vendored
Normal file
116
Libs/util/third_party/openthread/include/openthread/platform/messagepool.h
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform abstraction for the message pool.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_MESSAGEPOOL_H_
|
||||
#define OPENTHREAD_PLATFORM_MESSAGEPOOL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/message.h>
|
||||
|
||||
/**
|
||||
* @addtogroup plat-messagepool
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for the message pool.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Represents an OpenThread message buffer.
|
||||
*/
|
||||
typedef struct otMessageBuffer
|
||||
{
|
||||
struct otMessageBuffer *mNext; ///< Pointer to the next buffer.
|
||||
} otMessageBuffer;
|
||||
|
||||
/**
|
||||
* Initialize the platform implemented message pool.
|
||||
*
|
||||
* Is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aMinNumFreeBuffers An uint16 containing the minimum number of free buffers desired by OpenThread.
|
||||
* @param[in] aBufferSize The size in bytes of a buffer object.
|
||||
*/
|
||||
void otPlatMessagePoolInit(otInstance *aInstance, uint16_t aMinNumFreeBuffers, size_t aBufferSize);
|
||||
|
||||
/**
|
||||
* Allocate a buffer from the platform managed buffer pool.
|
||||
*
|
||||
* Is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled.
|
||||
*
|
||||
* The returned buffer instance MUST have at least `aBufferSize` bytes (as specified in `otPlatMessagePoolInit()`).
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the buffer or NULL if no buffers are available.
|
||||
*/
|
||||
otMessageBuffer *otPlatMessagePoolNew(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Is used to free a buffer back to the platform managed buffer pool.
|
||||
*
|
||||
* Is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aBuffer The buffer to free.
|
||||
*/
|
||||
void otPlatMessagePoolFree(otInstance *aInstance, otMessageBuffer *aBuffer);
|
||||
|
||||
/**
|
||||
* Get the number of free buffers.
|
||||
*
|
||||
* Is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*
|
||||
* @returns The number of buffers currently free and available to OpenThread.
|
||||
*/
|
||||
uint16_t otPlatMessagePoolNumFreeBuffers(otInstance *aInstance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_MESSAGEPOOL_H_
|
||||
215
Libs/util/third_party/openthread/include/openthread/platform/misc.h
vendored
Normal file
215
Libs/util/third_party/openthread/include/openthread/platform/misc.h
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes platform abstractions for miscellaneous behaviors.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_MISC_H_
|
||||
#define OPENTHREAD_PLATFORM_MISC_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-misc
|
||||
*
|
||||
* @brief
|
||||
* This module includes platform abstractions for miscellaneous behaviors.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Performs a software reset on the platform, if supported.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
void otPlatReset(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Performs a hardware reset on the platform to launch bootloader mode, if supported.
|
||||
*
|
||||
* Used when `OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Reset to bootloader successfully.
|
||||
* @retval OT_ERROR_BUSY Failed due to another operation is ongoing.
|
||||
* @retval OT_ERROR_NOT_CAPABLE Not capable of resetting to bootloader.
|
||||
*/
|
||||
otError otPlatResetToBootloader(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Enumeration of possible reset reason codes.
|
||||
*
|
||||
* These are in the same order as the Spinel reset reason codes.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_PLAT_RESET_REASON_POWER_ON = 0,
|
||||
OT_PLAT_RESET_REASON_EXTERNAL = 1,
|
||||
OT_PLAT_RESET_REASON_SOFTWARE = 2,
|
||||
OT_PLAT_RESET_REASON_FAULT = 3,
|
||||
OT_PLAT_RESET_REASON_CRASH = 4,
|
||||
OT_PLAT_RESET_REASON_ASSERT = 5,
|
||||
OT_PLAT_RESET_REASON_OTHER = 6,
|
||||
OT_PLAT_RESET_REASON_UNKNOWN = 7,
|
||||
OT_PLAT_RESET_REASON_WATCHDOG = 8,
|
||||
|
||||
OT_PLAT_RESET_REASON_COUNT,
|
||||
} otPlatResetReason;
|
||||
|
||||
/**
|
||||
* Returns the reason for the last platform reset.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
otPlatResetReason otPlatGetResetReason(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Provides a platform specific implementation for assert.
|
||||
*
|
||||
* @param[in] aFilename The name of the file where the assert occurred.
|
||||
* @param[in] aLineNumber The line number in the file where the assert occurred.
|
||||
*/
|
||||
void otPlatAssertFail(const char *aFilename, int aLineNumber);
|
||||
|
||||
/**
|
||||
* Performs a platform specific operation to wake the host MCU.
|
||||
* This is used only for NCP configurations.
|
||||
*/
|
||||
void otPlatWakeHost(void);
|
||||
|
||||
/**
|
||||
* Enumeration of micro-controller's power states.
|
||||
*
|
||||
* These values are used for NCP configuration when `OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL` is enabled.
|
||||
*
|
||||
* The power state specifies the desired power state of NCP's micro-controller (MCU) when the underlying platform's
|
||||
* operating system enters idle mode (i.e., all active tasks/events are processed and the MCU can potentially enter a
|
||||
* energy-saving power state).
|
||||
*
|
||||
* The power state primarily determines how the host should interact with the NCP and whether the host needs an
|
||||
* external trigger (a "poke") to NCP before it can communicate with the NCP or not.
|
||||
*
|
||||
* After a reset, the MCU power state MUST be `OT_PLAT_POWER_STATE_ON`.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/**
|
||||
* NCP's MCU stays on and active all the time.
|
||||
*
|
||||
* When the NCP's desired power state is set to `ON`, host can send messages to NCP without requiring any "poke" or
|
||||
* external triggers.
|
||||
*
|
||||
* @note The `ON` power state only determines the MCU's power mode and is not related to radio's state.
|
||||
*/
|
||||
OT_PLAT_MCU_POWER_STATE_ON = 0,
|
||||
|
||||
/**
|
||||
* NCP's MCU can enter low-power (energy-saving) state.
|
||||
*
|
||||
* When the NCP's desired power state is set to `LOW_POWER`, host is expected to "poke" the NCP (e.g., an external
|
||||
* trigger like an interrupt) before it can communicate with the NCP (send a message to the NCP). The "poke"
|
||||
* mechanism is determined by the platform code (based on NCP's interface to the host).
|
||||
*
|
||||
* While power state is set to `LOW_POWER`, NCP can still (at any time) send messages to host. Note that receiving
|
||||
* a message from the NCP does NOT indicate that the NCP's power state has changed, i.e., host is expected to
|
||||
* continue to "poke" when it wants to talk to the NCP until the power state is explicitly changed (by a successful
|
||||
* call to `otPlatSetMcuPowerState()` changing the state to `ON`).
|
||||
*
|
||||
* @note The `LOW_POWER` power state only determines the MCU's power mode and is not related to radio's state
|
||||
* (radio is managed by OpenThread core and device role, e.g., device being sleepy or not.
|
||||
*/
|
||||
OT_PLAT_MCU_POWER_STATE_LOW_POWER = 1,
|
||||
|
||||
/**
|
||||
* NCP is fully off.
|
||||
*
|
||||
* An NCP hardware reset (via a RESET pin) is required to bring the NCP back to `SPINEL_MCU_POWER_STATE_ON`.
|
||||
* RAM is not retained after reset.
|
||||
*/
|
||||
OT_PLAT_MCU_POWER_STATE_OFF = 2,
|
||||
} otPlatMcuPowerState;
|
||||
|
||||
/**
|
||||
* Sets the desired MCU power state.
|
||||
*
|
||||
* This is only applicable and used for NCP configuration when `OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL`
|
||||
* is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to OpenThread instance.
|
||||
* @param[in] aState The new MCU power state.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The power state updated successfully.
|
||||
* @retval OT_ERROR_FAILED The given MCU power state is not supported by the platform.
|
||||
*/
|
||||
otError otPlatSetMcuPowerState(otInstance *aInstance, otPlatMcuPowerState aState);
|
||||
|
||||
/**
|
||||
* Gets the current desired MCU power state.
|
||||
*
|
||||
* This is only applicable and used for NCP configuration when `OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL`
|
||||
* is enabled.
|
||||
*
|
||||
* After a reset, the power state MUST return `OT_PLAT_POWER_STATE_ON`. During operation, power state SHOULD only
|
||||
* change through an explicit successful call to `otPlatSetMcuPowerState()`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to OpenThread instance.
|
||||
*
|
||||
* @returns The current power state.
|
||||
*/
|
||||
otPlatMcuPowerState otPlatGetMcuPowerState(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Logs a crash dump using OpenThread logging APIs
|
||||
*
|
||||
* @note This API is an optional logging platform API. It's up to the platform layer to implement it.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Crash dump was logged successfully
|
||||
* @retval OT_ERROR_NOT_CAPABLE Platform is not capable of logging a crash dump
|
||||
*/
|
||||
otError otPlatLogCrashDump(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_MISC_H_
|
||||
139
Libs/util/third_party/openthread/include/openthread/platform/multipan.h
vendored
Normal file
139
Libs/util/third_party/openthread/include/openthread/platform/multipan.h
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the multipan interface for OpenThread.
|
||||
*
|
||||
* Multipan RCP is a feature that allows single RCP operate in multiple networks.
|
||||
*
|
||||
* Currently we support two types of multipan RCP:
|
||||
* - Full multipan: RCP operates in parallel on both networks (for example using more than one transceiver)
|
||||
* - Switching RCP: RCP can communicate only with one network at a time and requires network switching mechanism.
|
||||
* Switching can be automatic (for example time based, radio sleep based) or manually controlled by
|
||||
* the host.
|
||||
*
|
||||
* Full multipan RCP and Automatic Switching RCP do not require any special care from the host side.
|
||||
* Manual Switching RCP requires host to switch currently active network.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_MULTIPAN_H_
|
||||
#define OPENTHREAD_PLATFORM_MULTIPAN_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-multipan
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for multipan support.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get instance currently in control of the radio.
|
||||
*
|
||||
* If radio does not operate in parallel on all interfaces, this function returns an instance object with granted
|
||||
* radio access.
|
||||
*
|
||||
* @param[out] aInstance Pointer to the variable for storing the active instance pointer.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the property.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED Failed due to lack of the support in radio.
|
||||
* @retval OT_ERROR_INVALID_COMMAND Platform supports all interfaces simultaneously.
|
||||
*/
|
||||
otError otPlatMultipanGetActiveInstance(otInstance **aInstance);
|
||||
|
||||
/**
|
||||
* Set `aInstance` as the current active instance controlling radio.
|
||||
*
|
||||
* This function allows selecting the currently active instance on platforms that do not support parallel
|
||||
* communication on multiple interfaces. In other words, if more than one instance is in a receive state, calling
|
||||
* #otPlatMultipanSetActiveInstance guarantees that specified instance will be the one receiving. This function returns
|
||||
* if the request was received properly. After interface switching is complete, the platform should call
|
||||
* #otPlatMultipanSwitchoverDone. Switching interfaces may take longer if `aCompletePending` is set true.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aCompletePending True if ongoing radio operation should complete before interface switch (Soft switch),
|
||||
* false for force switch.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the property.
|
||||
* @retval OT_ERROR_BUSY Failed due to another operation ongoing.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED Failed due to unknown instance or more instances than interfaces available.
|
||||
* @retval OT_ERROR_INVALID_COMMAND Platform supports all interfaces simultaneously.
|
||||
* @retval OT_ERROR_ALREADY Given interface is already active.
|
||||
*/
|
||||
otError otPlatMultipanSetActiveInstance(otInstance *aInstance, bool aCompletePending);
|
||||
|
||||
/**
|
||||
* The platform completed the interface switching procedure.
|
||||
*
|
||||
* Should be invoked immediately after processing #otPlatMultipanSetActiveInstance if no delay is needed, or if
|
||||
* some longer radio operations need to complete first, after the switch in interfaces is fully complete.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aSuccess True if successfully switched the interfaces, false if switching failed.
|
||||
*/
|
||||
extern void otPlatMultipanSwitchoverDone(otInstance *aInstance, bool aSuccess);
|
||||
|
||||
/**
|
||||
* Get the instance pointer corresponding to the given IID.
|
||||
*
|
||||
* @param[in] aIid The IID of the interface.
|
||||
*
|
||||
* @retval Instance pointer if aIid is has an instance assigned, nullptr otherwise.
|
||||
*/
|
||||
otInstance *otPlatMultipanIidToInstance(uint8_t aIid);
|
||||
|
||||
/**
|
||||
* Get the IID corresponding to the given OpenThread instance pointer.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @retval IID of the given instance, broadcast IID otherwise.
|
||||
*/
|
||||
uint8_t otPlatMultipanInstanceToIid(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_MULTIPAN_H_
|
||||
80
Libs/util/third_party/openthread/include/openthread/platform/otns.h
vendored
Normal file
80
Libs/util/third_party/openthread/include/openthread/platform/otns.h
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the abstraction for the platform OTNS utilities.
|
||||
*
|
||||
* OTNS is an OpenThread Network Simulator that simulates Thread networks using OpenThread simulation instances and
|
||||
* provides visualization and management of those simulated networks.
|
||||
* Refer to https://github.com/openthread/ot-ns for more information about OTNS.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_OTNS_H_
|
||||
#define OPENTHREAD_PLATFORM_OTNS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-otns
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for OTNS.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Exports status information to OTNS.
|
||||
*
|
||||
* The status information is represented by a null-terminated string with format recognizable by OTNS.
|
||||
* Each call to `otPlatOtnsStatus` can send multiple statuses, separated by ';', e.x. "parid=577fbc37;lrid=5".
|
||||
* Each status contains key and value separated by '='.
|
||||
* Status value can be further separated into multiple fields using ',',
|
||||
* e.x. "ping_request=fdde:ad00:beef:0:459e:d7b4:b65e:5480,4,112000".
|
||||
*
|
||||
* New statuses should follow these conventions.
|
||||
*
|
||||
* Currently, OTNS only supports virtual time simulation.
|
||||
*
|
||||
* @param[in] aStatus The status string.
|
||||
*/
|
||||
void otPlatOtnsStatus(const char *aStatus);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_OTNS_H_
|
||||
1390
Libs/util/third_party/openthread/include/openthread/platform/radio.h
vendored
Normal file
1390
Libs/util/third_party/openthread/include/openthread/platform/radio.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
249
Libs/util/third_party/openthread/include/openthread/platform/settings.h
vendored
Normal file
249
Libs/util/third_party/openthread/include/openthread/platform/settings.h
vendored
Normal file
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes platform abstraction for non-volatile storage of settings.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_SETTINGS_H_
|
||||
#define OPENTHREAD_PLATFORM_SETTINGS_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-settings
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for non-volatile storage of settings.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Defines the keys of settings.
|
||||
*
|
||||
* Note: When adding a new settings key, if the settings corresponding to the key contains security sensitive
|
||||
* information, the developer MUST add the key to the array `aSensitiveKeys` which is passed in
|
||||
* `otPlatSettingsInit()`.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
OT_SETTINGS_KEY_ACTIVE_DATASET = 0x0001, ///< Active Operational Dataset.
|
||||
OT_SETTINGS_KEY_PENDING_DATASET = 0x0002, ///< Pending Operational Dataset.
|
||||
OT_SETTINGS_KEY_NETWORK_INFO = 0x0003, ///< Thread network information.
|
||||
OT_SETTINGS_KEY_PARENT_INFO = 0x0004, ///< Parent information.
|
||||
OT_SETTINGS_KEY_CHILD_INFO = 0x0005, ///< Child information.
|
||||
OT_SETTINGS_KEY_SLAAC_IID_SECRET_KEY = 0x0007, ///< SLAAC key to generate semantically opaque IID.
|
||||
OT_SETTINGS_KEY_DAD_INFO = 0x0008, ///< Duplicate Address Detection (DAD) information.
|
||||
OT_SETTINGS_KEY_SRP_ECDSA_KEY = 0x000b, ///< SRP client ECDSA public/private key pair.
|
||||
OT_SETTINGS_KEY_SRP_CLIENT_INFO = 0x000c, ///< The SRP client info (selected SRP server address).
|
||||
OT_SETTINGS_KEY_SRP_SERVER_INFO = 0x000d, ///< The SRP server info (UDP port).
|
||||
OT_SETTINGS_KEY_BR_ULA_PREFIX = 0x000f, ///< BR ULA prefix.
|
||||
OT_SETTINGS_KEY_BR_ON_LINK_PREFIXES = 0x0010, ///< BR local on-link prefixes.
|
||||
OT_SETTINGS_KEY_BORDER_AGENT_ID = 0x0011, ///< Unique Border Agent/Router ID.
|
||||
|
||||
// Deprecated and reserved key values:
|
||||
//
|
||||
// 0x0006 previously auto-start.
|
||||
// 0x0009 previously OMR prefix.
|
||||
// 0x000a previously on-link prefix.
|
||||
// 0x000e previously NAT64 prefix.
|
||||
|
||||
// Keys in range 0x8000-0xffff are reserved for vendor-specific use.
|
||||
OT_SETTINGS_KEY_VENDOR_RESERVED_MIN = 0x8000,
|
||||
OT_SETTINGS_KEY_VENDOR_RESERVED_MAX = 0xffff,
|
||||
};
|
||||
|
||||
/**
|
||||
* Performs any initialization for the settings subsystem, if necessary.
|
||||
*
|
||||
* Also sets the sensitive keys that should be stored in the secure area.
|
||||
*
|
||||
* Note that the memory pointed by @p aSensitiveKeys MUST not be released before @p aInstance is destroyed.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aSensitiveKeys A pointer to an array containing the list of sensitive keys. May be NULL only if
|
||||
* @p aSensitiveKeysLength is 0, which means that there is no sensitive keys.
|
||||
* @param[in] aSensitiveKeysLength The number of entries in the @p aSensitiveKeys array.
|
||||
*/
|
||||
void otPlatSettingsInit(otInstance *aInstance, const uint16_t *aSensitiveKeys, uint16_t aSensitiveKeysLength);
|
||||
|
||||
/**
|
||||
* Performs any de-initialization for the settings subsystem, if necessary.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
void otPlatSettingsDeinit(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Fetches the value of a setting.
|
||||
*
|
||||
* Fetches the value of the setting identified
|
||||
* by @p aKey and write it to the memory pointed to by aValue.
|
||||
* It then writes the length to the integer pointed to by
|
||||
* @p aValueLength. The initial value of @p aValueLength is the
|
||||
* maximum number of bytes to be written to @p aValue.
|
||||
*
|
||||
* Can be used to check for the existence of
|
||||
* a key without fetching the value by setting @p aValue and
|
||||
* @p aValueLength to NULL. You can also check the length of
|
||||
* the setting without fetching it by setting only aValue
|
||||
* to NULL.
|
||||
*
|
||||
* Note that the underlying storage implementation is not
|
||||
* required to maintain the order of settings with multiple
|
||||
* values. The order of such values MAY change after ANY
|
||||
* write operation to the store.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aKey The key associated with the requested setting.
|
||||
* @param[in] aIndex The index of the specific item to get.
|
||||
* @param[out] aValue A pointer to where the value of the setting should be written. May be set to NULL if
|
||||
* just testing for the presence or length of a setting.
|
||||
* @param[in,out] aValueLength A pointer to the length of the value. When called, this pointer should point to an
|
||||
* integer containing the maximum value size that can be written to @p aValue. At return,
|
||||
* the actual length of the setting is written. This may be set to NULL if performing
|
||||
* a presence check.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The given setting was found and fetched successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND The given setting was not found in the setting store.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED This function is not implemented on this platform.
|
||||
*/
|
||||
otError otPlatSettingsGet(otInstance *aInstance, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength);
|
||||
|
||||
/**
|
||||
* Sets or replaces the value of a setting.
|
||||
*
|
||||
* Sets or replaces the value of a setting
|
||||
* identified by @p aKey.
|
||||
*
|
||||
* Calling this function successfully may cause unrelated
|
||||
* settings with multiple values to be reordered.
|
||||
*
|
||||
* OpenThread stack guarantees to use `otPlatSettingsSet()`
|
||||
* method for a @p aKey that was either previously set using
|
||||
* `otPlatSettingsSet()` (i.e., contains a single value) or
|
||||
* is empty and/or fully deleted (contains no value).
|
||||
*
|
||||
* Platform layer can rely and use this fact for optimizing
|
||||
* its implementation.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aKey The key associated with the setting to change.
|
||||
* @param[in] aValue A pointer to where the new value of the setting should be read from. MUST NOT be NULL if
|
||||
* @p aValueLength is non-zero.
|
||||
* @param[in] aValueLength The length of the data pointed to by aValue. May be zero.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The given setting was changed or staged.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED This function is not implemented on this platform.
|
||||
* @retval OT_ERROR_NO_BUFS No space remaining to store the given setting.
|
||||
*/
|
||||
otError otPlatSettingsSet(otInstance *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength);
|
||||
|
||||
/**
|
||||
* Adds a value to a setting.
|
||||
*
|
||||
* Adds the value to a setting
|
||||
* identified by @p aKey, without replacing any existing
|
||||
* values.
|
||||
*
|
||||
* Note that the underlying implementation is not required
|
||||
* to maintain the order of the items associated with a
|
||||
* specific key. The added value may be added to the end,
|
||||
* the beginning, or even somewhere in the middle. The order
|
||||
* of any pre-existing values may also change.
|
||||
*
|
||||
* Calling this function successfully may cause unrelated
|
||||
* settings with multiple values to be reordered.
|
||||
*
|
||||
* OpenThread stack guarantees to use `otPlatSettingsAdd()`
|
||||
* method for a @p aKey that was either previously managed by
|
||||
* `otPlatSettingsAdd()` (i.e., contains one or more items) or
|
||||
* is empty and/or fully deleted (contains no value).
|
||||
*
|
||||
* Platform layer can rely and use this fact for optimizing
|
||||
* its implementation.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aKey The key associated with the setting to change.
|
||||
* @param[in] aValue A pointer to where the new value of the setting should be read from. MUST NOT be NULL
|
||||
* if @p aValueLength is non-zero.
|
||||
* @param[in] aValueLength The length of the data pointed to by @p aValue. May be zero.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The given setting was added or staged to be added.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED This function is not implemented on this platform.
|
||||
* @retval OT_ERROR_NO_BUFS No space remaining to store the given setting.
|
||||
*/
|
||||
otError otPlatSettingsAdd(otInstance *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength);
|
||||
|
||||
/**
|
||||
* Removes a setting from the setting store.
|
||||
*
|
||||
* Deletes a specific value from the
|
||||
* setting identified by aKey from the settings store.
|
||||
*
|
||||
* Note that the underlying implementation is not required
|
||||
* to maintain the order of the items associated with a
|
||||
* specific key.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aKey The key associated with the requested setting.
|
||||
* @param[in] aIndex The index of the value to be removed. If set to -1, all values for this @p aKey will be
|
||||
* removed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The given key and index was found and removed successfully.
|
||||
* @retval OT_ERROR_NOT_FOUND The given key or index was not found in the setting store.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED This function is not implemented on this platform.
|
||||
*/
|
||||
otError otPlatSettingsDelete(otInstance *aInstance, uint16_t aKey, int aIndex);
|
||||
|
||||
/**
|
||||
* Removes all settings from the setting store.
|
||||
*
|
||||
* Deletes all settings from the settings
|
||||
* store, resetting it to its initial factory state.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
void otPlatSettingsWipe(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_SETTINGS_H_
|
||||
176
Libs/util/third_party/openthread/include/openthread/platform/spi-slave.h
vendored
Normal file
176
Libs/util/third_party/openthread/include/openthread/platform/spi-slave.h
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file spi-slave.h
|
||||
* @brief
|
||||
* This file includes the platform abstraction for SPI slave communication.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_SPI_SLAVE_H_
|
||||
#define OPENTHREAD_PLATFORM_SPI_SLAVE_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-spi-slave
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for SPI slave communication.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Indicates that a SPI transaction has completed with the given length. The data written to the slave has been written
|
||||
* to the pointer indicated by the `aInputBuf` argument to the previous call to `otPlatSpiSlavePrepareTransaction()`.
|
||||
*
|
||||
* Once this function is called, `otPlatSpiSlavePrepareTransaction()` is invalid and must be called again for the next
|
||||
* transaction to be valid.
|
||||
*
|
||||
* Note that this function is always called at the end of a transaction, even if `otPlatSpiSlavePrepareTransaction()`
|
||||
* has not yet been called. In such cases, `aOutputBufLen` and `aInputBufLen` will be zero.
|
||||
*
|
||||
* This callback can be called from ISR context. The return value from this function indicates if any further
|
||||
* processing is required. If `TRUE` is returned the platform spi-slave driver implementation must invoke the
|
||||
* transaction process callback (`aProcessCallback` set in `otPlatSpiSlaveEnable()`) which unlike this callback must be
|
||||
* called from the same OS context that any other OpenThread API/callback is called.
|
||||
*
|
||||
* @param[in] aContext Context pointer passed into `otPlatSpiSlaveEnable()`.
|
||||
* @param[in] aOutputBuf Value of `aOutputBuf` from last call to `otPlatSpiSlavePrepareTransaction()`.
|
||||
* @param[in] aOutputBufLen Value of `aOutputBufLen` from last call to `otPlatSpiSlavePrepareTransaction()`.
|
||||
* @param[in] aInputBuf Value of aInputBuf from last call to `otPlatSpiSlavePrepareTransaction()`.
|
||||
* @param[in] aInputBufLen Value of aInputBufLen from last call to `otPlatSpiSlavePrepareTransaction()`
|
||||
* @param[in] aTransactionLength Length of the completed transaction, in bytes.
|
||||
*
|
||||
* @returns TRUE if after this call returns the platform should invoke the process callback `aProcessCallback`,
|
||||
* FALSE if there is nothing to process and no need to invoke the process callback.
|
||||
*/
|
||||
typedef bool (*otPlatSpiSlaveTransactionCompleteCallback)(void *aContext,
|
||||
uint8_t *aOutputBuf,
|
||||
uint16_t aOutputBufLen,
|
||||
uint8_t *aInputBuf,
|
||||
uint16_t aInputBufLen,
|
||||
uint16_t aTransactionLength);
|
||||
|
||||
/**
|
||||
* Invoked after a transaction complete callback is called and returns `TRUE` to do any further processing required.
|
||||
* Unlike `otPlatSpiSlaveTransactionCompleteCallback` which can be called from any OS context (e.g., ISR), this
|
||||
* callback MUST be called from the same OS context as any other OpenThread API/callback.
|
||||
*
|
||||
* @param[in] aContext Context pointer passed into `otPlatSpiSlaveEnable()`.
|
||||
*/
|
||||
typedef void (*otPlatSpiSlaveTransactionProcessCallback)(void *aContext);
|
||||
|
||||
/**
|
||||
* Initialize the SPI slave interface.
|
||||
|
||||
* Note that SPI slave is not fully ready until a transaction is prepared using `otPlatSPISlavePrepareTransaction()`.
|
||||
*
|
||||
* If `otPlatSPISlavePrepareTransaction() is not called before the master begins a transaction, the resulting SPI
|
||||
* transaction will send all `0xFF` bytes and discard all received bytes.
|
||||
*
|
||||
* @param[in] aCompleteCallback Pointer to transaction complete callback.
|
||||
* @param[in] aProcessCallback Pointer to process callback.
|
||||
* @param[in] aContext Context pointer to be passed to callbacks.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully enabled the SPI Slave interface.
|
||||
* @retval OT_ERROR_ALREADY SPI Slave interface is already enabled.
|
||||
* @retval OT_ERROR_FAILED Failed to enable the SPI Slave interface.
|
||||
*/
|
||||
otError otPlatSpiSlaveEnable(otPlatSpiSlaveTransactionCompleteCallback aCompleteCallback,
|
||||
otPlatSpiSlaveTransactionProcessCallback aProcessCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Shutdown and disable the SPI slave interface.
|
||||
*/
|
||||
void otPlatSpiSlaveDisable(void);
|
||||
|
||||
/**
|
||||
* Prepare data for the next SPI transaction. Data pointers MUST remain valid until the transaction complete callback
|
||||
* is called by the SPI slave driver, or until after the next call to `otPlatSpiSlavePrepareTransaction()`.
|
||||
*
|
||||
* May be called more than once before the SPI master initiates the transaction. Each *successful* call
|
||||
* to this function will cause the previous values from earlier calls to be discarded.
|
||||
*
|
||||
* Not calling this function after a completed transaction is the same as if this function was previously called with
|
||||
* both buffer lengths set to zero and `aRequestTransactionFlag` set to `false`.
|
||||
*
|
||||
* Once `aOutputBufLen` bytes of `aOutputBuf` has been clocked out, the MISO pin shall be set high until the master
|
||||
* finishes the SPI transaction. This is the functional equivalent of padding the end of `aOutputBuf` with `0xFF` bytes
|
||||
* out to the length of the transaction.
|
||||
*
|
||||
* Once `aInputBufLen` bytes of aInputBuf have been clocked in from MOSI, all subsequent values from the MOSI pin are
|
||||
* ignored until the SPI master finishes the transaction.
|
||||
*
|
||||
* Note that even if `aInputBufLen` or `aOutputBufLen` (or both) are exhausted before the SPI master finishes a
|
||||
* transaction, the ongoing size of the transaction must still be kept track of to be passed to the transaction
|
||||
* complete callback. For example, if `aInputBufLen` is equal to 10 and `aOutputBufLen` equal to 20 and the SPI master
|
||||
* clocks out 30 bytes, the value 30 is passed to the transaction complete callback.
|
||||
*
|
||||
* If a `NULL` pointer is passed in as `aOutputBuf` or `aInputBuf` it means that that buffer pointer should not change
|
||||
* from its previous/current value. In this case, the corresponding length argument should be ignored. For example,
|
||||
* `otPlatSpiSlavePrepareTransaction(NULL, 0, aInputBuf, aInputLen, false)` changes the input buffer pointer and its
|
||||
* length but keeps the output buffer pointer same as before.
|
||||
*
|
||||
* Any call to this function while a transaction is in progress will cause all of the arguments to be ignored and the
|
||||
* return value to be `OT_ERROR_BUSY`.
|
||||
*
|
||||
* @param[in] aOutputBuf Data to be written to MISO pin
|
||||
* @param[in] aOutputBufLen Size of the output buffer, in bytes
|
||||
* @param[in] aInputBuf Data to be read from MOSI pin
|
||||
* @param[in] aInputBufLen Size of the input buffer, in bytes
|
||||
* @param[in] aRequestTransactionFlag Set to true if host interrupt should be set
|
||||
*
|
||||
* @retval OT_ERROR_NONE Transaction was successfully prepared.
|
||||
* @retval OT_ERROR_BUSY A transaction is currently in progress.
|
||||
* @retval OT_ERROR_INVALID_STATE otPlatSpiSlaveEnable() hasn't been called.
|
||||
*/
|
||||
otError otPlatSpiSlavePrepareTransaction(uint8_t *aOutputBuf,
|
||||
uint16_t aOutputBufLen,
|
||||
uint8_t *aInputBuf,
|
||||
uint16_t aInputBufLen,
|
||||
bool aRequestTransactionFlag);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_SPI_SLAVE_H_
|
||||
102
Libs/util/third_party/openthread/include/openthread/platform/time.h
vendored
Normal file
102
Libs/util/third_party/openthread/include/openthread/platform/time.h
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform abstraction for the time service.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_TIME_H_
|
||||
#define OPENTHREAD_PLATFORM_TIME_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OT_MS_PER_S 1000 ///< Number of milliseconds per second
|
||||
#define OT_US_PER_MS 1000 ///< Number of microseconds per millisecond
|
||||
#define OT_US_PER_S 1000000 ///< Number of microseconds per second
|
||||
#define OT_NS_PER_US 1000 ///< Number of nanoseconds per microsecond
|
||||
|
||||
/**
|
||||
* @addtogroup plat-time
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for the time service.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the current platform time in microseconds referenced to a continuous
|
||||
* monotonic local clock (64 bits width).
|
||||
*
|
||||
* The clock SHALL NOT wrap during the device's uptime. Implementations SHALL
|
||||
* therefore identify and compensate for internal counter overflows. The clock
|
||||
* does not have a defined epoch and it SHALL NOT introduce any continuous or
|
||||
* discontinuous adjustments (e.g. leap seconds). Implementations SHALL
|
||||
* compensate for any sleep times of the device.
|
||||
*
|
||||
* Implementations MAY choose to discipline the platform clock and compensate
|
||||
* for sleep times by any means (e.g. by combining a high precision/low power
|
||||
* RTC with a high resolution counter) as long as the exposed combined clock
|
||||
* provides continuous monotonic microsecond resolution ticks within the
|
||||
* accuracy limits announced by @ref otPlatTimeGetXtalAccuracy.
|
||||
*
|
||||
* @returns The current time in microseconds.
|
||||
*/
|
||||
uint64_t otPlatTimeGet(void);
|
||||
|
||||
/**
|
||||
* Get the current estimated worst case accuracy (maximum ± deviation from the
|
||||
* nominal frequency) of the local platform clock in units of PPM.
|
||||
*
|
||||
* @note Implementations MAY estimate this value based on current operating
|
||||
* conditions (e.g. temperature).
|
||||
*
|
||||
* In case the implementation does not estimate the current value but returns a
|
||||
* fixed value, this value MUST be the worst-case accuracy over all possible
|
||||
* foreseen operating conditions (temperature, pressure, etc) of the
|
||||
* implementation.
|
||||
*
|
||||
* @returns The current platform clock accuracy, in PPM.
|
||||
*/
|
||||
uint16_t otPlatTimeGetXtalAccuracy(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_TIME_H_
|
||||
305
Libs/util/third_party/openthread/include/openthread/platform/toolchain.h
vendored
Normal file
305
Libs/util/third_party/openthread/include/openthread/platform/toolchain.h
vendored
Normal file
@@ -0,0 +1,305 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup plat-toolchain
|
||||
*
|
||||
* @brief
|
||||
* This module defines a toolchain abstraction layer through macros.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* @code
|
||||
*
|
||||
* typedef
|
||||
* OT_TOOL_PACKED_BEGIN
|
||||
* struct
|
||||
* {
|
||||
* char mField1;
|
||||
* union
|
||||
* {
|
||||
* char mField2;
|
||||
* long mField3;
|
||||
* } OT_TOOL_PACKED_FIELD;
|
||||
* } OT_TOOL_PACKED_END packed_struct_t;
|
||||
*
|
||||
* @endcode
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_TOOLCHAIN_H_
|
||||
#define OPENTHREAD_PLATFORM_TOOLCHAIN_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OT_MUST_USE_RESULT
|
||||
*
|
||||
* Compiler-specific indication that a class or enum must be used when it is
|
||||
* the return value of a function.
|
||||
*
|
||||
* @note This is currently only available with clang (C++17 implements it
|
||||
* as attribute [[nodiscard]]).
|
||||
* @note To suppress the 'unused-result' warning/error, please use the
|
||||
* '-Wno-unused-result' compiler option.
|
||||
*/
|
||||
#if defined(__clang__) && (__clang_major__ >= 4 || (__clang_major__ >= 3 && __clang_minor__ >= 9))
|
||||
#define OT_MUST_USE_RESULT __attribute__((warn_unused_result))
|
||||
#else
|
||||
#define OT_MUST_USE_RESULT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OT_TOOL_PACKED_BEGIN
|
||||
*
|
||||
* Compiler-specific indication that a class or struct must be byte packed.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def OT_TOOL_PACKED_FIELD
|
||||
*
|
||||
* Indicate to the compiler a nested struct or union to be packed
|
||||
* within byte packed class or struct.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def OT_TOOL_PACKED_END
|
||||
*
|
||||
* Compiler-specific indication at the end of a byte packed class or struct.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def OT_TOOL_WEAK
|
||||
*
|
||||
* Compiler-specific weak symbol modifier.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK
|
||||
*
|
||||
* Specifies that a function or method takes `printf` style arguments and should be type-checked against
|
||||
* a format string.
|
||||
*
|
||||
* Must be added after the function/method declaration. For example:
|
||||
*
|
||||
* `void MyPrintf(void *aObject, const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 3);`
|
||||
*
|
||||
* The two argument index values indicate format string and first argument to check against it. They start at index 1
|
||||
* for the first parameter in a function and at index 2 for the first parameter in a method.
|
||||
*
|
||||
* @param[in] aFmtIndex The argument index of the format string.
|
||||
* @param[in] aStartIndex The argument index of the first argument to check against the format string.
|
||||
*/
|
||||
|
||||
// =========== TOOLCHAIN SELECTION : START ===========
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM) || defined(__TI_ARM__)
|
||||
|
||||
// https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html
|
||||
// http://www.keil.com/support/man/docs/armcc/armcc_chr1359124973480.htm
|
||||
|
||||
#define OT_TOOL_PACKED_BEGIN
|
||||
#define OT_TOOL_PACKED_FIELD __attribute__((packed))
|
||||
#define OT_TOOL_PACKED_END __attribute__((packed))
|
||||
#define OT_TOOL_WEAK __attribute__((weak))
|
||||
|
||||
#define OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(aFmtIndex, aStartIndex) \
|
||||
__attribute__((format(printf, aFmtIndex, aStartIndex)))
|
||||
|
||||
#elif defined(__ICCARM__) || defined(__ICC8051__)
|
||||
|
||||
// http://supp.iar.com/FilesPublic/UPDINFO/004916/arm/doc/EWARM_DevelopmentGuide.ENU.pdf
|
||||
|
||||
#include "intrinsics.h"
|
||||
|
||||
#define OT_TOOL_PACKED_BEGIN __packed
|
||||
#define OT_TOOL_PACKED_FIELD
|
||||
#define OT_TOOL_PACKED_END
|
||||
#define OT_TOOL_WEAK __weak
|
||||
|
||||
#define OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(aFmtIndex, aStartIndex)
|
||||
|
||||
#elif defined(__SDCC)
|
||||
|
||||
// Structures are packed by default in sdcc, as it primarily targets 8-bit MCUs.
|
||||
|
||||
#define OT_TOOL_PACKED_BEGIN
|
||||
#define OT_TOOL_PACKED_FIELD
|
||||
#define OT_TOOL_PACKED_END
|
||||
#define OT_TOOL_WEAK
|
||||
|
||||
#define OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(aFmtIndex, aStartIndex)
|
||||
|
||||
#else
|
||||
|
||||
#error "Error: No valid Toolchain specified"
|
||||
|
||||
// Symbols for Doxygen
|
||||
|
||||
#define OT_TOOL_PACKED_BEGIN
|
||||
#define OT_TOOL_PACKED_FIELD
|
||||
#define OT_TOOL_PACKED_END
|
||||
#define OT_TOOL_WEAK
|
||||
|
||||
#define OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(aFmtIndex, aStartIndex)
|
||||
|
||||
#endif
|
||||
|
||||
// =========== TOOLCHAIN SELECTION : END ===========
|
||||
|
||||
/**
|
||||
* @def OT_UNUSED_VARIABLE
|
||||
*
|
||||
* Suppress unused variable warning in specific toolchains.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def OT_UNREACHABLE_CODE
|
||||
*
|
||||
* Suppress Unreachable code warning in specific toolchains.
|
||||
*/
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define OT_UNUSED_VARIABLE(VARIABLE) \
|
||||
do \
|
||||
{ \
|
||||
if (&VARIABLE == NULL) \
|
||||
{ \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define OT_UNREACHABLE_CODE(CODE) \
|
||||
_Pragma("diag_suppress=Pe111") _Pragma("diag_suppress=Pe128") CODE _Pragma("diag_default=Pe111") \
|
||||
_Pragma("diag_default=Pe128")
|
||||
|
||||
#elif defined(__CC_ARM)
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define OT_UNUSED_VARIABLE(VARIABLE) \
|
||||
do \
|
||||
{ \
|
||||
if (&VARIABLE == NULL) \
|
||||
{ \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define OT_UNREACHABLE_CODE(CODE) CODE
|
||||
|
||||
#elif defined(__TI_ARM__)
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define OT_UNUSED_VARIABLE(VARIABLE) \
|
||||
do \
|
||||
{ \
|
||||
if (&VARIABLE == NULL) \
|
||||
{ \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
/*
|
||||
* #112-D statement is unreachable
|
||||
* #129-D loop is not reachable
|
||||
*/
|
||||
#define OT_UNREACHABLE_CODE(CODE) \
|
||||
_Pragma("diag_push") _Pragma("diag_suppress 112") _Pragma("diag_suppress 129") CODE _Pragma("diag_pop")
|
||||
|
||||
#else
|
||||
|
||||
#define OT_UNUSED_VARIABLE(VARIABLE) \
|
||||
do \
|
||||
{ \
|
||||
(void)(VARIABLE); \
|
||||
} while (false)
|
||||
|
||||
#define OT_UNREACHABLE_CODE(CODE) CODE
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Keil and IAR compiler doesn't provide type limits for C++.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
#if defined(__CC_ARM) || defined(__ICCARM__)
|
||||
|
||||
#ifndef UINT8_MAX
|
||||
#define UINT8_MAX 0xff
|
||||
#endif
|
||||
|
||||
#ifndef UINT16_MAX
|
||||
#define UINT16_MAX 0xffff
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define OT_APPLE_IGNORE_GNU_FOLDING_CONSTANT(...) \
|
||||
_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wgnu-folding-constant\"") \
|
||||
__VA_ARGS__ _Pragma("GCC diagnostic pop")
|
||||
#else
|
||||
#define OT_APPLE_IGNORE_GNU_FOLDING_CONSTANT(...) __VA_ARGS__
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OT_FALL_THROUGH
|
||||
*
|
||||
* Suppress fall through warning in specific compiler.
|
||||
*/
|
||||
#if defined(__cplusplus) && (__cplusplus >= 201703L)
|
||||
#define OT_FALL_THROUGH [[fallthrough]]
|
||||
#elif defined(__clang__)
|
||||
#define OT_FALL_THROUGH [[clang::fallthrough]]
|
||||
#elif defined(__GNUC__) && (__GNUC__ >= 7)
|
||||
#define OT_FALL_THROUGH __attribute__((fallthrough))
|
||||
#else
|
||||
#define OT_FALL_THROUGH \
|
||||
do \
|
||||
{ \
|
||||
} while (false) /* fallthrough */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_TOOLCHAIN_H_
|
||||
221
Libs/util/third_party/openthread/include/openthread/platform/trel.h
vendored
Normal file
221
Libs/util/third_party/openthread/include/openthread/platform/trel.h
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform abstraction for Thread Radio Encapsulation Link (TREL) using DNS-SD and UDP/IPv6.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_TREL_H_
|
||||
#define OPENTHREAD_PLATFORM_TREL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/ip6.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup plat-trel
|
||||
*
|
||||
* @brief
|
||||
* This module includes the platform abstraction for Thread Radio Encapsulation Link (TREL) using DNS-SD and
|
||||
* UDP/IPv6.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initializes and enables TREL platform layer.
|
||||
*
|
||||
* Upon this call, the platform layer MUST perform the following:
|
||||
*
|
||||
* 1) TREL platform layer MUST open a UDP socket to listen for and receive TREL messages from peers. The socket is
|
||||
* bound to an ephemeral port number chosen by the platform layer. The port number MUST be returned in @p aUdpPort.
|
||||
* The socket is also bound to network interface(s) on which TREL is to be supported. The socket and the chosen port
|
||||
* should stay valid while TREL is enabled.
|
||||
*
|
||||
* 2) Platform layer MUST initiate an ongoing DNS-SD browse on the service name "_trel._udp" within the local browsing
|
||||
* domain to discover other devices supporting TREL. The ongoing browse will produce two different types of events:
|
||||
* "add" events and "remove" events. When the browse is started, it should produce an "add" event for every TREL peer
|
||||
* currently present on the network. Whenever a TREL peer goes offline, a "remove" event should be produced. "remove"
|
||||
* events are not guaranteed, however. When a TREL service instance is discovered, a new ongoing DNS-SD query for an
|
||||
* AAAA record should be started on the hostname indicated in the SRV record of the discovered instance. If multiple
|
||||
* host IPv6 addressees are discovered for a peer, one with highest scope among all addresses MUST be reported (if
|
||||
* there are multiple address at same scope, one must be selected randomly).
|
||||
*
|
||||
* TREL platform MUST signal back the discovered peer info using `otPlatTrelHandleDiscoveredPeerInfo()` callback. This
|
||||
* callback MUST be invoked when a new peer is discovered, when there is a change in an existing entry (e.g., new
|
||||
* TXT record or new port number or new IPv6 address), or when the peer is removed.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[out] aUdpPort A pointer to return the selected port number by platform layer.
|
||||
*/
|
||||
void otPlatTrelEnable(otInstance *aInstance, uint16_t *aUdpPort);
|
||||
|
||||
/**
|
||||
* Disables TREL platform layer.
|
||||
*
|
||||
* After this call, the platform layer MUST stop DNS-SD browse on the service name "_trel._udp", stop advertising the
|
||||
* TREL DNS-SD service (from `otPlatTrelRegisterService()`) and MUST close the UDP socket used to receive TREL messages.
|
||||
*
|
||||
* @pram[in] aInstance The OpenThread instance.
|
||||
*/
|
||||
void otPlatTrelDisable(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Represents a TREL peer info discovered using DNS-SD browse on the service name "_trel._udp".
|
||||
*/
|
||||
typedef struct otPlatTrelPeerInfo
|
||||
{
|
||||
/**
|
||||
* This boolean flag indicates whether the entry is being removed or added.
|
||||
*
|
||||
* - TRUE indicates that peer is removed.
|
||||
* - FALSE indicates that it is a new entry or an update to an existing entry.
|
||||
*/
|
||||
bool mRemoved;
|
||||
|
||||
/**
|
||||
* The TXT record data (encoded as specified by DNS-SD) from the SRV record of the discovered TREL peer service
|
||||
* instance.
|
||||
*/
|
||||
const uint8_t *mTxtData;
|
||||
|
||||
uint16_t mTxtLength; ///< Number of bytes in @p mTxtData buffer.
|
||||
|
||||
/**
|
||||
* The TREL peer socket address (IPv6 address and port number).
|
||||
*
|
||||
* The port number is determined from the SRV record of the discovered TREL peer service instance. The IPv6 address
|
||||
* is determined from the DNS-SD query for AAAA records on the hostname indicated in the SRV record of the
|
||||
* discovered service instance. If multiple host IPv6 addressees are discovered, one with highest scope is used.
|
||||
*/
|
||||
otSockAddr mSockAddr;
|
||||
} otPlatTrelPeerInfo;
|
||||
|
||||
/**
|
||||
* This is a callback function from platform layer to report a discovered TREL peer info.
|
||||
*
|
||||
* @note The @p aInfo structure and its content (e.g., the `mTxtData` buffer) does not need to persist after returning
|
||||
* from this call. OpenThread code will make a copy of all the info it needs.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aInfo A pointer to the TREL peer info.
|
||||
*/
|
||||
extern void otPlatTrelHandleDiscoveredPeerInfo(otInstance *aInstance, const otPlatTrelPeerInfo *aInfo);
|
||||
|
||||
/**
|
||||
* Registers a new service to be advertised using DNS-SD [RFC6763].
|
||||
*
|
||||
* The service name is "_trel._udp". The platform should use its own hostname, which when combined with the service
|
||||
* name and the local DNS-SD domain name will produce the full service instance name, for example
|
||||
* "example-host._trel._udp.local.".
|
||||
*
|
||||
* The domain under which the service instance name appears will be 'local' for mDNS, and will be whatever domain is
|
||||
* used for service registration in the case of a non-mDNS local DNS-SD service.
|
||||
*
|
||||
* A subsequent call to this function updates the previous service. It is used to update the TXT record data and/or the
|
||||
* port number.
|
||||
*
|
||||
* The @p aTxtData buffer is not persisted after the return from this function. The platform layer MUST NOT keep the
|
||||
* pointer and instead copy the content if needed.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* @param[in] aPort The port number to include in the SRV record of the advertised service.
|
||||
* @param[in] aTxtData A pointer to the TXT record data (encoded) to be include in the advertised service.
|
||||
* @param[in] aTxtLength The length of @p aTxtData (number of bytes).
|
||||
*/
|
||||
void otPlatTrelRegisterService(otInstance *aInstance, uint16_t aPort, const uint8_t *aTxtData, uint8_t aTxtLength);
|
||||
|
||||
/**
|
||||
* Requests a TREL UDP packet to be sent to a given destination.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aUdpPayload A pointer to UDP payload.
|
||||
* @param[in] aUdpPayloadLen The payload length (number of bytes).
|
||||
* @param[in] aDestSockAddr The destination socket address.
|
||||
*/
|
||||
void otPlatTrelSend(otInstance *aInstance,
|
||||
const uint8_t *aUdpPayload,
|
||||
uint16_t aUdpPayloadLen,
|
||||
const otSockAddr *aDestSockAddr);
|
||||
|
||||
/**
|
||||
* Is a callback from platform to notify of a received TREL UDP packet.
|
||||
*
|
||||
* @note The buffer content (up to its specified length) may get changed during processing by OpenThread core (e.g.,
|
||||
* decrypted in place), so the platform implementation should expect that after returning from this function the
|
||||
* @p aBuffer content may have been altered.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aBuffer A buffer containing the received UDP payload.
|
||||
* @param[in] aLength UDP payload length (number of bytes).
|
||||
*/
|
||||
extern void otPlatTrelHandleReceived(otInstance *aInstance, uint8_t *aBuffer, uint16_t aLength);
|
||||
|
||||
/**
|
||||
* Represents a group of TREL related counters in the platform layer.
|
||||
*/
|
||||
typedef struct otPlatTrelCounters
|
||||
{
|
||||
uint64_t mTxPackets; ///< Number of packets successfully transmitted through TREL.
|
||||
uint64_t mTxBytes; ///< Sum of size of packets successfully transmitted through TREL.
|
||||
uint64_t mTxFailure; ///< Number of packet transmission failures through TREL.
|
||||
uint64_t mRxPackets; ///< Number of packets received through TREL.
|
||||
uint64_t mRxBytes; ///< Sum of size of packets received through TREL.
|
||||
} otPlatTrelCounters;
|
||||
|
||||
/**
|
||||
* Gets the pointer to the TREL counters in the platform layer.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
const otPlatTrelCounters *otPlatTrelGetCounters(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Resets the TREL counters in the platform layer.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
void otPlatTrelResetCounters(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_TREL_H_
|
||||
145
Libs/util/third_party/openthread/include/openthread/platform/udp.h
vendored
Normal file
145
Libs/util/third_party/openthread/include/openthread/platform/udp.h
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the abstraction for the platform UDP service.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_PLATFORM_UDP_H_
|
||||
#define OPENTHREAD_PLATFORM_UDP_H_
|
||||
|
||||
#include <openthread/udp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initializes the UDP socket by platform.
|
||||
*
|
||||
* @param[in] aUdpSocket A pointer to the UDP socket.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully initialized UDP socket by platform.
|
||||
* @retval OT_ERROR_FAILED Failed to initialize UDP Socket.
|
||||
*/
|
||||
otError otPlatUdpSocket(otUdpSocket *aUdpSocket);
|
||||
|
||||
/**
|
||||
* Closes the UDP socket by platform.
|
||||
*
|
||||
* @param[in] aUdpSocket A pointer to the UDP socket.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully closed UDP socket by platform.
|
||||
* @retval OT_ERROR_FAILED Failed to close UDP Socket.
|
||||
*/
|
||||
otError otPlatUdpClose(otUdpSocket *aUdpSocket);
|
||||
|
||||
/**
|
||||
* Binds the UDP socket by platform.
|
||||
*
|
||||
* @param[in] aUdpSocket A pointer to the UDP socket.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully bound UDP socket by platform.
|
||||
* @retval OT_ERROR_FAILED Failed to bind UDP socket.
|
||||
*/
|
||||
otError otPlatUdpBind(otUdpSocket *aUdpSocket);
|
||||
|
||||
/**
|
||||
* Binds the UDP socket to a platform network interface.
|
||||
*
|
||||
* Note: only available when `OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE` is used.
|
||||
*
|
||||
* @param[in] aUdpSocket A pointer to the UDP socket.
|
||||
* @param[in] aNetifIdentifier The network interface identifier.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully bound UDP socket.
|
||||
* @retval OT_ERROR_FAILED Failed to bind UDP.
|
||||
*/
|
||||
otError otPlatUdpBindToNetif(otUdpSocket *aUdpSocket, otNetifIdentifier aNetifIdentifier);
|
||||
|
||||
/**
|
||||
* Connects UDP socket by platform.
|
||||
*
|
||||
* @param[in] aUdpSocket A pointer to the UDP socket.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully connected by platform.
|
||||
* @retval OT_ERROR_FAILED Failed to connect UDP socket.
|
||||
*/
|
||||
otError otPlatUdpConnect(otUdpSocket *aUdpSocket);
|
||||
|
||||
/**
|
||||
* Sends UDP payload by platform.
|
||||
*
|
||||
* @param[in] aUdpSocket A pointer to the UDP socket.
|
||||
* @param[in] aMessage A pointer to the message to send.
|
||||
* @param[in] aMessageInfo A pointer to the message info associated with @p aMessage.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully sent by platform, and @p aMessage is freed.
|
||||
* @retval OT_ERROR_FAILED Failed to bind UDP socket.
|
||||
*/
|
||||
otError otPlatUdpSend(otUdpSocket *aUdpSocket, otMessage *aMessage, const otMessageInfo *aMessageInfo);
|
||||
|
||||
/**
|
||||
* Configures the UDP socket to join a UDP multicast group.
|
||||
*
|
||||
* Note: only available when `OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE` is used.
|
||||
*
|
||||
* @param[in] aUdpSocket A pointer to the UDP socket.
|
||||
* @param[in] aNetifIdentifier The network interface identifier.
|
||||
* @param[in] aAddress The UDP multicast group address.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully joined the multicast group.
|
||||
* @retval OT_ERROR_FAILED Failed to join the multicast group.
|
||||
*/
|
||||
otError otPlatUdpJoinMulticastGroup(otUdpSocket *aUdpSocket,
|
||||
otNetifIdentifier aNetifIdentifier,
|
||||
const otIp6Address *aAddress);
|
||||
|
||||
/**
|
||||
* Configures the UDP socket to leave a UDP multicast group.
|
||||
*
|
||||
* Note: only available when `OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE` is used.
|
||||
*
|
||||
* @param[in] aUdpSocket A pointer to the UDP socket.
|
||||
* @param[in] aNetifIdentifier The network interface identifier.
|
||||
* @param[in] aAddress The UDP multicast group address.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully left the multicast group.
|
||||
* @retval OT_ERROR_FAILED Failed to leave the multicast group.
|
||||
*/
|
||||
otError otPlatUdpLeaveMulticastGroup(otUdpSocket *aUdpSocket,
|
||||
otNetifIdentifier aNetifIdentifier,
|
||||
const otIp6Address *aAddress);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_PLATFORM_UDP_H_
|
||||
96
Libs/util/third_party/openthread/include/openthread/radio_stats.h
vendored
Normal file
96
Libs/util/third_party/openthread/include/openthread/radio_stats.h
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the OpenThread API for radio stats module.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_RADIO_STATS_H_
|
||||
#define OPENTHREAD_RADIO_STATS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-radio
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions for radio statistics.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Contains the statistics of radio.
|
||||
*/
|
||||
typedef struct otRadioTimeStats
|
||||
{
|
||||
uint64_t mDisabledTime; ///< The total time that radio is in disabled state, in unit of microseconds.
|
||||
uint64_t mSleepTime; ///< The total time that radio is in sleep state, in unit of microseconds.
|
||||
uint64_t mTxTime; ///> The total time that radio is doing transmission, in unit of microseconds.
|
||||
uint64_t mRxTime; ///> The total time that radio is in receive state, in unit of microseconds.
|
||||
} otRadioTimeStats;
|
||||
|
||||
/**
|
||||
* Gets the radio statistics.
|
||||
*
|
||||
* The radio statistics include the time when the radio is in TX/RX/Sleep state. These times are in units of
|
||||
* microseconds. All times are calculated from the last reset of radio statistics.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns A const pointer to the otRadioTimeStats struct that contains the data.
|
||||
*/
|
||||
const otRadioTimeStats *otRadioTimeStatsGet(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Resets the radio statistics.
|
||||
*
|
||||
* All times are reset to 0.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otRadioTimeStatsReset(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_RADIO_STATS_H_
|
||||
71
Libs/util/third_party/openthread/include/openthread/random_crypto.h
vendored
Normal file
71
Libs/util/third_party/openthread/include/openthread/random_crypto.h
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread cryptographic random number generator API.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_RANDOM_CRYPTO_H_
|
||||
#define OPENTHREAD_RANDOM_CRYPTO_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-random-crypto
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that generates cryptographic random numbers.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fills a given buffer with cryptographically secure random bytes.
|
||||
*
|
||||
* @param[out] aBuffer A pointer to a buffer to fill with the random bytes.
|
||||
* @param[in] aSize Size of buffer (number of bytes to fill).
|
||||
*/
|
||||
otError otRandomCryptoFillBuffer(uint8_t *aBuffer, uint16_t aSize);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_RANDOM_CRYPTO_H_
|
||||
134
Libs/util/third_party/openthread/include/openthread/random_noncrypto.h
vendored
Normal file
134
Libs/util/third_party/openthread/include/openthread/random_noncrypto.h
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread non cryptographic random number generator API.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_RANDOM_H_
|
||||
#define OPENTHREAD_RANDOM_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-random-non-crypto
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that generates non cryptographic random numbers.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generates and returns a random `uint32_t` value.
|
||||
*
|
||||
* @returns A random `uint32_t` value.
|
||||
*/
|
||||
uint32_t otRandomNonCryptoGetUint32(void);
|
||||
|
||||
/**
|
||||
* Generates and returns a random byte.
|
||||
*
|
||||
* @returns A random `uint8_t` value.
|
||||
*/
|
||||
uint8_t otRandomNonCryptoGetUint8(void);
|
||||
|
||||
/**
|
||||
* Generates and returns a random `uint16_t` value.
|
||||
*
|
||||
* @returns A random `uint16_t` value.
|
||||
*/
|
||||
uint16_t otRandomNonCryptoGetUint16(void);
|
||||
|
||||
/**
|
||||
* Generates and returns a random `uint8_t` value within a given range `[aMin, aMax)`.
|
||||
*
|
||||
* @param[in] aMin A minimum value (this value can be included in returned random result).
|
||||
* @param[in] aMax A maximum value (this value is excluded from returned random result).
|
||||
*
|
||||
* @returns A random `uint8_t` value in the given range (i.e., aMin <= random value < aMax).
|
||||
*/
|
||||
uint8_t otRandomNonCryptoGetUint8InRange(uint8_t aMin, uint8_t aMax);
|
||||
|
||||
/**
|
||||
* Generates and returns a random `uint16_t` value within a given range `[aMin, aMax)`.
|
||||
*
|
||||
* @note The returned random value can include the @p aMin value but excludes the @p aMax.
|
||||
*
|
||||
* @param[in] aMin A minimum value (this value can be included in returned random result).
|
||||
* @param[in] aMax A maximum value (this value is excluded from returned random result).
|
||||
*
|
||||
* @returns A random `uint16_t` value in the given range (i.e., aMin <= random value < aMax).
|
||||
*/
|
||||
uint16_t otRandomNonCryptoGetUint16InRange(uint16_t aMin, uint16_t aMax);
|
||||
|
||||
/**
|
||||
* Generates and returns a random `uint32_t` value within a given range `[aMin, aMax)`.
|
||||
*
|
||||
* @note The returned random value can include the @p aMin value but excludes the @p aMax.
|
||||
*
|
||||
* @param[in] aMin A minimum value (this value can be included in returned random result).
|
||||
* @param[in] aMax A maximum value (this value is excluded from returned random result).
|
||||
*
|
||||
* @returns A random `uint32_t` value in the given range (i.e., aMin <= random value < aMax).
|
||||
*/
|
||||
uint32_t otRandomNonCryptoGetUint32InRange(uint32_t aMin, uint32_t aMax);
|
||||
|
||||
/**
|
||||
* Fills a given buffer with random bytes.
|
||||
*
|
||||
* @param[out] aBuffer A pointer to a buffer to fill with the random bytes.
|
||||
* @param[in] aSize Size of buffer (number of bytes to fill).
|
||||
*/
|
||||
void otRandomNonCryptoFillBuffer(uint8_t *aBuffer, uint16_t aSize);
|
||||
|
||||
/**
|
||||
* Adds a random jitter within a given range to a given value.
|
||||
*
|
||||
* @param[in] aValue A value to which the random jitter is added.
|
||||
* @param[in] aJitter Maximum jitter. Random jitter is selected from the range `[-aJitter, aJitter]`.
|
||||
*
|
||||
* @returns The given value with an added random jitter.
|
||||
*/
|
||||
uint32_t otRandomNonCryptoAddJitter(uint32_t aValue, uint16_t aJitter);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_RANDOM_H_
|
||||
131
Libs/util/third_party/openthread/include/openthread/server.h
vendored
Normal file
131
Libs/util/third_party/openthread/include/openthread/server.h
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Server API.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_SERVER_H_
|
||||
#define OPENTHREAD_SERVER_H_
|
||||
|
||||
#include <openthread/netdata.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-server
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions to manage local network data with the OpenThread Server.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides a full or stable copy of the local Thread Network Data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aStable TRUE when copying the stable version, FALSE when copying the full version.
|
||||
* @param[out] aData A pointer to the data buffer.
|
||||
* @param[in,out] aDataLength On entry, size of the data buffer pointed to by @p aData.
|
||||
* On exit, number of copied bytes.
|
||||
*/
|
||||
otError otServerGetNetDataLocal(otInstance *aInstance, bool aStable, uint8_t *aData, uint8_t *aDataLength);
|
||||
|
||||
/**
|
||||
* Add a service configuration to the local network data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aConfig A pointer to the service configuration.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added the configuration to the local network data.
|
||||
* @retval OT_ERROR_INVALID_ARGS One or more configuration parameters were invalid.
|
||||
* @retval OT_ERROR_NO_BUFS Not enough room is available to add the configuration to the local network data.
|
||||
*
|
||||
* @sa otServerRemoveService
|
||||
* @sa otServerRegister
|
||||
*/
|
||||
otError otServerAddService(otInstance *aInstance, const otServiceConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Remove a service configuration from the local network data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnterpriseNumber Enterprise Number of the service entry to be deleted.
|
||||
* @param[in] aServiceData A pointer to an Service Data to look for during deletion.
|
||||
* @param[in] aServiceDataLength The length of @p aServiceData in bytes.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully removed the configuration from the local network data.
|
||||
* @retval OT_ERROR_NOT_FOUND Could not find the Border Router entry.
|
||||
*
|
||||
* @sa otServerAddService
|
||||
* @sa otServerRegister
|
||||
*/
|
||||
otError otServerRemoveService(otInstance *aInstance,
|
||||
uint32_t aEnterpriseNumber,
|
||||
const uint8_t *aServiceData,
|
||||
uint8_t aServiceDataLength);
|
||||
|
||||
/**
|
||||
* Gets the next service in the local Network Data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in,out] aIterator A pointer to the Network Data iterator context. To get the first service entry
|
||||
it should be set to OT_NETWORK_DATA_ITERATOR_INIT.
|
||||
* @param[out] aConfig A pointer to where the service information will be placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully found the next service.
|
||||
* @retval OT_ERROR_NOT_FOUND No subsequent service exists in the Thread Network Data.
|
||||
*/
|
||||
otError otServerGetNextService(otInstance *aInstance, otNetworkDataIterator *aIterator, otServiceConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Immediately register the local network data with the Leader.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully queued a Server Data Request message for delivery.
|
||||
*
|
||||
* @sa otServerAddService
|
||||
* @sa otServerRemoveService
|
||||
*/
|
||||
otError otServerRegister(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_SERVER_H_
|
||||
115
Libs/util/third_party/openthread/include/openthread/sntp.h
vendored
Normal file
115
Libs/util/third_party/openthread/include/openthread/sntp.h
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the top-level sntp functions for the OpenThread library.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_SNTP_H_
|
||||
#define OPENTHREAD_SNTP_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/ip6.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-sntp
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control SNTP communication.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define OT_SNTP_DEFAULT_SERVER_IP "2001:4860:4806:8::" ///< Defines default SNTP Server address - Google NTP Server.
|
||||
#define OT_SNTP_DEFAULT_SERVER_PORT 123 ///< Defines default SNTP Server port.
|
||||
|
||||
/**
|
||||
* Implements SNTP Query parameters.
|
||||
*/
|
||||
typedef struct otSntpQuery
|
||||
{
|
||||
const otMessageInfo *mMessageInfo; ///< A reference to the message info related with SNTP Server.
|
||||
} otSntpQuery;
|
||||
|
||||
/**
|
||||
* Pointer is called when a SNTP response is received.
|
||||
*
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
* @param[in] aTime Specifies the time at the server when the response left for the client, in UNIX time.
|
||||
* @param[in] aResult A result of the SNTP transaction.
|
||||
*
|
||||
* @retval OT_ERROR_NONE A response was received successfully and time is provided
|
||||
* in @p aTime.
|
||||
* @retval OT_ERROR_ABORT A SNTP transaction was aborted by stack.
|
||||
* @retval OT_ERROR_BUSY The Kiss-o'-death packet has been received.
|
||||
* @retval OT_ERROR_RESPONSE_TIMEOUT No SNTP response has been received within timeout.
|
||||
* @retval OT_ERROR_FAILED A response was received but contains incorrect data.
|
||||
*/
|
||||
typedef void (*otSntpResponseHandler)(void *aContext, uint64_t aTime, otError aResult);
|
||||
|
||||
/**
|
||||
* Sends a SNTP query.
|
||||
*
|
||||
* Is available only if feature `OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aQuery A pointer to specify SNTP query parameters.
|
||||
* @param[in] aHandler A function pointer that shall be called on response reception or time-out.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*/
|
||||
otError otSntpClientQuery(otInstance *aInstance,
|
||||
const otSntpQuery *aQuery,
|
||||
otSntpResponseHandler aHandler,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Sets the unix era number.
|
||||
*
|
||||
* The default value of unix era is set to 0. The subsequent eras start after year 2106.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aUnixEra Unix era number.
|
||||
*/
|
||||
void otSntpClientSetUnixEra(otInstance *aInstance, uint32_t aUnixEra);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_SNTP_H_
|
||||
681
Libs/util/third_party/openthread/include/openthread/srp_client.h
vendored
Normal file
681
Libs/util/third_party/openthread/include/openthread/srp_client.h
vendored
Normal file
@@ -0,0 +1,681 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread SRP (Service Registration Protocol) client APIs.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_SRP_CLIENT_H_
|
||||
#define OPENTHREAD_SRP_CLIENT_H_
|
||||
|
||||
#include <openthread/dns.h>
|
||||
#include <openthread/ip6.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-srp
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control SRP client behavior.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Specifies an SRP client item (service or host info) state.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_SRP_CLIENT_ITEM_STATE_TO_ADD, ///< Item to be added/registered.
|
||||
OT_SRP_CLIENT_ITEM_STATE_ADDING, ///< Item is being added/registered.
|
||||
OT_SRP_CLIENT_ITEM_STATE_TO_REFRESH, ///< Item to be refreshed (re-register to renew lease).
|
||||
OT_SRP_CLIENT_ITEM_STATE_REFRESHING, ///< Item is being refreshed.
|
||||
OT_SRP_CLIENT_ITEM_STATE_TO_REMOVE, ///< Item to be removed.
|
||||
OT_SRP_CLIENT_ITEM_STATE_REMOVING, ///< Item is being removed.
|
||||
OT_SRP_CLIENT_ITEM_STATE_REGISTERED, ///< Item is registered with server.
|
||||
OT_SRP_CLIENT_ITEM_STATE_REMOVED, ///< Item is removed.
|
||||
} otSrpClientItemState;
|
||||
|
||||
/**
|
||||
* Represents an SRP client host info.
|
||||
*/
|
||||
typedef struct otSrpClientHostInfo
|
||||
{
|
||||
const char *mName; ///< Host name (label) string (NULL if not yet set).
|
||||
const otIp6Address *mAddresses; ///< Array of host IPv6 addresses (NULL if not set or auto address is enabled).
|
||||
uint8_t mNumAddresses; ///< Number of IPv6 addresses in `mAddresses` array.
|
||||
bool mAutoAddress; ///< Indicates whether auto address mode is enabled or not.
|
||||
otSrpClientItemState mState; ///< Host info state.
|
||||
} otSrpClientHostInfo;
|
||||
|
||||
/**
|
||||
* Represents an SRP client service.
|
||||
*
|
||||
* The values in this structure, including the string buffers for the names and the TXT record entries, MUST persist
|
||||
* and stay constant after an instance of this structure is passed to OpenThread from `otSrpClientAddService()` or
|
||||
* `otSrpClientRemoveService()`.
|
||||
*
|
||||
* The `mState`, `mData`, `mNext` fields are used/managed by OT core only. Their value is ignored when an instance of
|
||||
* `otSrpClientService` is passed in `otSrpClientAddService()` or `otSrpClientRemoveService()` or other functions. The
|
||||
* caller does not need to set these fields.
|
||||
*
|
||||
* The `mLease` and `mKeyLease` fields specify the desired lease and key lease intervals for this service. Zero value
|
||||
* indicates that the interval is unspecified and then the default lease or key lease intervals from
|
||||
* `otSrpClientGetLeaseInterval()` and `otSrpClientGetKeyLeaseInterval()` are used for this service. If the key lease
|
||||
* interval (whether set explicitly or determined from the default) is shorter than the lease interval for a service,
|
||||
* SRP client will re-use the lease interval value for key lease interval as well. For example, if in service `mLease`
|
||||
* is explicitly set to 2 days and `mKeyLease` is set to zero and default key lease is set to 1 day, then when
|
||||
* registering this service, the requested key lease for this service is also set to 2 days.
|
||||
*/
|
||||
typedef struct otSrpClientService
|
||||
{
|
||||
const char *mName; ///< The service labels (e.g., "_mt._udp", not the full domain name).
|
||||
const char *mInstanceName; ///< The service instance name label (not the full name).
|
||||
const char *const *mSubTypeLabels; ///< Array of sub-type labels (must end with `NULL` or can be `NULL`).
|
||||
const otDnsTxtEntry *mTxtEntries; ///< Array of TXT entries (`mNumTxtEntries` gives num of entries).
|
||||
uint16_t mPort; ///< The service port number.
|
||||
uint16_t mPriority; ///< The service priority.
|
||||
uint16_t mWeight; ///< The service weight.
|
||||
uint8_t mNumTxtEntries; ///< Number of entries in the `mTxtEntries` array.
|
||||
otSrpClientItemState mState; ///< Service state (managed by OT core).
|
||||
uint32_t mData; ///< Internal data (used by OT core).
|
||||
struct otSrpClientService *mNext; ///< Pointer to next entry in a linked-list (managed by OT core).
|
||||
uint32_t mLease; ///< Desired lease interval in sec - zero to use default.
|
||||
uint32_t mKeyLease; ///< Desired key lease interval in sec - zero to use default.
|
||||
} otSrpClientService;
|
||||
|
||||
/**
|
||||
* Pointer type defines the callback used by SRP client to notify user of changes/events/errors.
|
||||
*
|
||||
* This callback is invoked on a successful registration of an update (i.e., add/remove of host-info and/or some
|
||||
* service(s)) with the SRP server, or if there is a failure or error (e.g., server rejects a update request or client
|
||||
* times out waiting for response, etc).
|
||||
*
|
||||
* In case of a successful reregistration of an update, `aError` parameter would be `OT_ERROR_NONE` and the host info
|
||||
* and the full list of services is provided as input parameters to the callback. Note that host info and services each
|
||||
* track its own state in the corresponding `mState` member variable of the related data structure (the state
|
||||
* indicating whether the host-info/service is registered or removed or still being added/removed, etc).
|
||||
*
|
||||
* The list of removed services is passed as its own linked-list `aRemovedServices` in the callback. Note that when the
|
||||
* callback is invoked, the SRP client (OpenThread implementation) is done with the removed service instances listed in
|
||||
* `aRemovedServices` and no longer tracks/stores them (i.e., if from the callback we call `otSrpClientGetServices()`
|
||||
* the removed services will not be present in the returned list). Providing a separate list of removed services in
|
||||
* the callback helps indicate to user which items are now removed and allow user to re-claim/reuse the instances.
|
||||
*
|
||||
* If the server rejects an SRP update request, the DNS response code (RFC 2136) is mapped to the following errors:
|
||||
*
|
||||
* - (0) NOERROR Success (no error condition) -> OT_ERROR_NONE
|
||||
* - (1) FORMERR Server unable to interpret due to format error -> OT_ERROR_PARSE
|
||||
* - (2) SERVFAIL Server encountered an internal failure -> OT_ERROR_FAILED
|
||||
* - (3) NXDOMAIN Name that ought to exist, does not exist -> OT_ERROR_NOT_FOUND
|
||||
* - (4) NOTIMP Server does not support the query type (OpCode) -> OT_ERROR_NOT_IMPLEMENTED
|
||||
* - (5) REFUSED Server refused for policy/security reasons -> OT_ERROR_SECURITY
|
||||
* - (6) YXDOMAIN Some name that ought not to exist, does exist -> OT_ERROR_DUPLICATED
|
||||
* - (7) YXRRSET Some RRset that ought not to exist, does exist -> OT_ERROR_DUPLICATED
|
||||
* - (8) NXRRSET Some RRset that ought to exist, does not exist -> OT_ERROR_NOT_FOUND
|
||||
* - (9) NOTAUTH Service is not authoritative for zone -> OT_ERROR_SECURITY
|
||||
* - (10) NOTZONE A name is not in the zone -> OT_ERROR_PARSE
|
||||
* - (20) BADNAME Bad name -> OT_ERROR_PARSE
|
||||
* - (21) BADALG Bad algorithm -> OT_ERROR_SECURITY
|
||||
* - (22) BADTRUN Bad truncation -> OT_ERROR_PARSE
|
||||
* - Other response codes -> OT_ERROR_FAILED
|
||||
*
|
||||
* The following errors are also possible:
|
||||
*
|
||||
* - OT_ERROR_RESPONSE_TIMEOUT : Timed out waiting for response from server (client would continue to retry).
|
||||
* - OT_ERROR_INVALID_ARGS : The provided service structure is invalid (e.g., bad service name or `otDnsTxtEntry`).
|
||||
* - OT_ERROR_NO_BUFS : Insufficient buffer to prepare or send the update message.
|
||||
*
|
||||
* Note that in case of any failure, the client continues the operation, i.e. it prepares and (re)transmits the SRP
|
||||
* update message to the server, after some wait interval. The retry wait interval starts from the minimum value and
|
||||
* is increased by the growth factor every failure up to the max value (please see configuration parameter
|
||||
* `OPENTHREAD_CONFIG_SRP_CLIENT_MIN_RETRY_WAIT_INTERVAL` and the related ones for more details).
|
||||
*
|
||||
* @param[in] aError The error (see above).
|
||||
* @param[in] aHostInfo A pointer to host info.
|
||||
* @param[in] aServices The head of linked-list containing all services (excluding the ones removed). NULL if
|
||||
* the list is empty.
|
||||
* @param[in] aRemovedServices The head of linked-list containing all removed services. NULL if the list is empty.
|
||||
* @param[in] aContext A pointer to an arbitrary context (provided when callback was registered).
|
||||
*/
|
||||
typedef void (*otSrpClientCallback)(otError aError,
|
||||
const otSrpClientHostInfo *aHostInfo,
|
||||
const otSrpClientService *aServices,
|
||||
const otSrpClientService *aRemovedServices,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Pointer type defines the callback used by SRP client to notify user when it is auto-started or stopped.
|
||||
*
|
||||
* This is only used when auto-start feature `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE` is enabled.
|
||||
*
|
||||
* This callback is invoked when auto-start mode is enabled and the SRP client is either automatically started or
|
||||
* stopped.
|
||||
*
|
||||
* @param[in] aServerSockAddr A non-NULL pointer indicates SRP server was started and pointer will give the
|
||||
* selected server socket address. A NULL pointer indicates SRP server was stopped.
|
||||
* @param[in] aContext A pointer to an arbitrary context (provided when callback was registered).
|
||||
*/
|
||||
typedef void (*otSrpClientAutoStartCallback)(const otSockAddr *aServerSockAddr, void *aContext);
|
||||
|
||||
/**
|
||||
* Starts the SRP client operation.
|
||||
*
|
||||
* SRP client will prepare and send "SRP Update" message to the SRP server once all the following conditions are met:
|
||||
*
|
||||
* - The SRP client is started - `otSrpClientStart()` is called.
|
||||
* - Host name is set - `otSrpClientSetHostName()` is called.
|
||||
* - At least one host IPv6 address is set - `otSrpClientSetHostAddresses()` is called.
|
||||
* - At least one service is added - `otSrpClientAddService()` is called.
|
||||
*
|
||||
* It does not matter in which order these functions are called. When all conditions are met, the SRP client will
|
||||
* wait for a short delay before preparing an "SRP Update" message and sending it to server. This delay allows for user
|
||||
* to add multiple services and/or IPv6 addresses before the first SRP Update message is sent (ensuring a single SRP
|
||||
* Update is sent containing all the info). The config `OPENTHREAD_CONFIG_SRP_CLIENT_UPDATE_TX_DELAY` specifies the
|
||||
* delay interval.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aServerSockAddr The socket address (IPv6 address and port number) of the SRP server.
|
||||
*
|
||||
* @retval OT_ERROR_NONE SRP client operation started successfully or it is already running with same server
|
||||
* socket address and callback.
|
||||
* @retval OT_ERROR_BUSY SRP client is busy running with a different socket address.
|
||||
* @retval OT_ERROR_FAILED Failed to open/connect the client's UDP socket.
|
||||
*/
|
||||
otError otSrpClientStart(otInstance *aInstance, const otSockAddr *aServerSockAddr);
|
||||
|
||||
/**
|
||||
* Stops the SRP client operation.
|
||||
*
|
||||
* Stops any further interactions with the SRP server. Note that it does not remove or clear host info
|
||||
* and/or list of services. It marks all services to be added/removed again once the client is (re)started.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*/
|
||||
void otSrpClientStop(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Indicates whether the SRP client is running or not.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*
|
||||
* @returns TRUE if the SRP client is running, FALSE otherwise.
|
||||
*/
|
||||
bool otSrpClientIsRunning(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the socket address (IPv6 address and port number) of the SRP server which is being used by SRP
|
||||
* client.
|
||||
*
|
||||
* If the client is not running, the address is unspecified (all zero) with zero port number.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the SRP server's socket address (is always non-NULL).
|
||||
*/
|
||||
const otSockAddr *otSrpClientGetServerAddress(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the callback to notify caller of events/changes from SRP client.
|
||||
*
|
||||
* The SRP client allows a single callback to be registered. So consecutive calls to this function will overwrite any
|
||||
* previously set callback functions.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aCallback The callback to notify of events and changes. Can be NULL if not needed.
|
||||
* @param[in] aContext An arbitrary context used with @p aCallback.
|
||||
*/
|
||||
void otSrpClientSetCallback(otInstance *aInstance, otSrpClientCallback aCallback, void *aContext);
|
||||
|
||||
/**
|
||||
* Enables the auto-start mode.
|
||||
*
|
||||
* This is only available when auto-start feature `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE` is enabled.
|
||||
*
|
||||
* Config option `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_DEFAULT_MODE` specifies the default auto-start mode (whether
|
||||
* it is enabled or disabled at the start of OT stack).
|
||||
*
|
||||
* When auto-start is enabled, the SRP client will monitor the Thread Network Data to discover SRP servers and select
|
||||
* the preferred server and automatically start and stop the client when an SRP server is detected.
|
||||
*
|
||||
* There are three categories of Network Data entries indicating presence of SRP sever. They are preferred in the
|
||||
* following order:
|
||||
*
|
||||
* 1) Preferred unicast entries where server address is included in the service data. If there are multiple options,
|
||||
* the one with numerically lowest IPv6 address is preferred.
|
||||
*
|
||||
* 2) Anycast entries each having a seq number. A larger sequence number in the sense specified by Serial Number
|
||||
* Arithmetic logic in RFC-1982 is considered more recent and therefore preferred. The largest seq number using
|
||||
* serial number arithmetic is preferred if it is well-defined (i.e., the seq number is larger than all other
|
||||
* seq numbers). If it is not well-defined, then the numerically largest seq number is preferred.
|
||||
*
|
||||
* 3) Unicast entries where the server address info is included in server data. If there are multiple options, the
|
||||
* one with numerically lowest IPv6 address is preferred.
|
||||
*
|
||||
* When there is a change in the Network Data entries, client will check that the currently selected server is still
|
||||
* present in the Network Data and is still the preferred one. Otherwise the client will switch to the new preferred
|
||||
* server or stop if there is none.
|
||||
*
|
||||
* When the SRP client is explicitly started through a successful call to `otSrpClientStart()`, the given SRP server
|
||||
* address in `otSrpClientStart()` will continue to be used regardless of the state of auto-start mode and whether the
|
||||
* same SRP server address is discovered or not in the Thread Network Data. In this case, only an explicit
|
||||
* `otSrpClientStop()` call will stop the client.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aCallback A callback to notify when client is auto-started/stopped. Can be NULL if not needed.
|
||||
* @param[in] aContext A context to be passed when invoking @p aCallback.
|
||||
*/
|
||||
void otSrpClientEnableAutoStartMode(otInstance *aInstance, otSrpClientAutoStartCallback aCallback, void *aContext);
|
||||
|
||||
/**
|
||||
* Disables the auto-start mode.
|
||||
*
|
||||
* This is only available when auto-start feature `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE` is enabled.
|
||||
*
|
||||
* Disabling the auto-start mode will not stop the client if it is already running but the client stops monitoring
|
||||
* the Thread Network Data to verify that the selected SRP server is still present in it.
|
||||
*
|
||||
* Note that a call to `otSrpClientStop()` will also disable the auto-start mode.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*/
|
||||
void otSrpClientDisableAutoStartMode(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Indicates the current state of auto-start mode (enabled or disabled).
|
||||
*
|
||||
* This is only available when auto-start feature `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*
|
||||
* @returns TRUE if the auto-start mode is enabled, FALSE otherwise.
|
||||
*/
|
||||
bool otSrpClientIsAutoStartModeEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the TTL value in every record included in SRP update requests.
|
||||
*
|
||||
* Note that this is the TTL requested by the SRP client. The server may choose to accept a different TTL.
|
||||
*
|
||||
* By default, the TTL will equal the lease interval. Passing 0 or a value larger than the lease interval via
|
||||
* `otSrpClientSetTtl()` will also cause the TTL to equal the lease interval.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*
|
||||
* @returns The TTL (in seconds).
|
||||
*/
|
||||
uint32_t otSrpClientGetTtl(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the TTL value in every record included in SRP update requests.
|
||||
*
|
||||
* Changing the TTL does not impact the TTL of already registered services/host-info.
|
||||
* It only affects future SRP update messages (i.e., adding new services and/or refreshes of the existing services).
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aTtl The TTL (in seconds). If value is zero or greater than lease interval, the TTL is set to the
|
||||
* lease interval.
|
||||
*/
|
||||
void otSrpClientSetTtl(otInstance *aInstance, uint32_t aTtl);
|
||||
|
||||
/**
|
||||
* Gets the default lease interval used in SRP update requests.
|
||||
*
|
||||
* The default interval is used only for `otSrpClientService` instances with `mLease` set to zero.
|
||||
*
|
||||
* Note that this is the lease duration requested by the SRP client. The server may choose to accept a different lease
|
||||
* interval.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*
|
||||
* @returns The lease interval (in seconds).
|
||||
*/
|
||||
uint32_t otSrpClientGetLeaseInterval(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the default lease interval used in SRP update requests.
|
||||
*
|
||||
* The default interval is used only for `otSrpClientService` instances with `mLease` set to zero.
|
||||
*
|
||||
* Changing the lease interval does not impact the accepted lease interval of already registered services/host-info.
|
||||
* It only affects any future SRP update messages (i.e., adding new services and/or refreshes of the existing services).
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aInterval The lease interval (in seconds). If zero, the default value specified by
|
||||
* `OPENTHREAD_CONFIG_SRP_CLIENT_DEFAULT_LEASE` would be used.
|
||||
*/
|
||||
void otSrpClientSetLeaseInterval(otInstance *aInstance, uint32_t aInterval);
|
||||
|
||||
/**
|
||||
* Gets the default key lease interval used in SRP update requests.
|
||||
*
|
||||
* The default interval is used only for `otSrpClientService` instances with `mKeyLease` set to zero.
|
||||
*
|
||||
* Note that this is the lease duration requested by the SRP client. The server may choose to accept a different lease
|
||||
* interval.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*
|
||||
* @returns The key lease interval (in seconds).
|
||||
*/
|
||||
uint32_t otSrpClientGetKeyLeaseInterval(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the default key lease interval used in SRP update requests.
|
||||
*
|
||||
* The default interval is used only for `otSrpClientService` instances with `mKeyLease` set to zero.
|
||||
*
|
||||
* Changing the lease interval does not impact the accepted lease interval of already registered services/host-info.
|
||||
* It only affects any future SRP update messages (i.e., adding new services and/or refreshes of existing services).
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aInterval The key lease interval (in seconds). If zero, the default value specified by
|
||||
* `OPENTHREAD_CONFIG_SRP_CLIENT_DEFAULT_KEY_LEASE` would be used.
|
||||
*/
|
||||
void otSrpClientSetKeyLeaseInterval(otInstance *aInstance, uint32_t aInterval);
|
||||
|
||||
/**
|
||||
* Gets the host info.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to host info structure.
|
||||
*/
|
||||
const otSrpClientHostInfo *otSrpClientGetHostInfo(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the host name label.
|
||||
*
|
||||
* After a successful call to this function, `otSrpClientCallback` will be called to report the status of host info
|
||||
* registration with SRP server.
|
||||
*
|
||||
* The name string buffer pointed to by @p aName MUST persist and stay unchanged after returning from this function.
|
||||
* OpenThread will keep the pointer to the string.
|
||||
*
|
||||
* The host name can be set before client is started or after start but before host info is registered with server
|
||||
* (host info should be in either `STATE_TO_ADD` or `STATE_REMOVED`).
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aName A pointer to host name label string (MUST NOT be NULL). Pointer to the string buffer MUST
|
||||
* persist and remain valid and constant after return from this function.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The host name label was set successfully.
|
||||
* @retval OT_ERROR_INVALID_ARGS The @p aName is NULL.
|
||||
* @retval OT_ERROR_INVALID_STATE The host name is already set and registered with the server.
|
||||
*/
|
||||
otError otSrpClientSetHostName(otInstance *aInstance, const char *aName);
|
||||
|
||||
/**
|
||||
* Enables auto host address mode.
|
||||
*
|
||||
* When enabled host IPv6 addresses are automatically set by SRP client using all the preferred unicast addresses on
|
||||
* Thread netif excluding all link-local and mesh-local addresses. If there is no preferred address, then Mesh Local
|
||||
* EID address is added. The SRP client will automatically re-register when/if addresses on Thread netif are updated
|
||||
* (new addresses are added or existing addresses are removed or marked as non-preferred).
|
||||
*
|
||||
* The auto host address mode can be enabled before start or during operation of SRP client except when the host info
|
||||
* is being removed (client is busy handling a remove request from an call to `otSrpClientRemoveHostAndServices()` and
|
||||
* host info still being in either `STATE_TO_REMOVE` or `STATE_REMOVING` states).
|
||||
*
|
||||
* After auto host address mode is enabled, it can be disabled by a call to `otSrpClientSetHostAddresses()` which
|
||||
* then explicitly sets the host addresses.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully enabled auto host address mode.
|
||||
* @retval OT_ERROR_INVALID_STATE Host is being removed and therefore cannot enable auto host address mode.
|
||||
*/
|
||||
otError otSrpClientEnableAutoHostAddress(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets/updates the list of host IPv6 address.
|
||||
*
|
||||
* Host IPv6 addresses can be set/changed before start or during operation of SRP client (e.g. to add/remove or change
|
||||
* a previously registered host address), except when the host info is being removed (client is busy handling a remove
|
||||
* request from an earlier call to `otSrpClientRemoveHostAndServices()` and host info still being in either
|
||||
* `STATE_TO_REMOVE` or `STATE_REMOVING` states).
|
||||
*
|
||||
* The host IPv6 address array pointed to by @p aIp6Addresses MUST persist and remain unchanged after returning from
|
||||
* this function (with `OT_ERROR_NONE`). OpenThread will save the pointer to the array.
|
||||
*
|
||||
* After a successful call to this function, `otSrpClientCallback` will be called to report the status of the address
|
||||
* registration with SRP server.
|
||||
*
|
||||
* Calling this function disables auto host address mode if it was previously enabled from a successful call to
|
||||
* `otSrpClientEnableAutoHostAddress()`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aIp6Addresses A pointer to the an array containing the host IPv6 addresses.
|
||||
* @param[in] aNumAddresses The number of addresses in the @p aIp6Addresses array.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The host IPv6 address list change started successfully. The `otSrpClientCallback`
|
||||
* will be called to report the status of registering addresses with server.
|
||||
* @retval OT_ERROR_INVALID_ARGS The address list is invalid (e.g., must contain at least one address).
|
||||
* @retval OT_ERROR_INVALID_STATE Host is being removed and therefore cannot change host address.
|
||||
*/
|
||||
otError otSrpClientSetHostAddresses(otInstance *aInstance, const otIp6Address *aIp6Addresses, uint8_t aNumAddresses);
|
||||
|
||||
/**
|
||||
* Adds a service to be registered with server.
|
||||
*
|
||||
* After a successful call to this function, `otSrpClientCallback` will be called to report the status of the service
|
||||
* addition/registration with SRP server.
|
||||
*
|
||||
* The `otSrpClientService` instance being pointed to by @p aService MUST persist and remain unchanged after returning
|
||||
* from this function (with `OT_ERROR_NONE`). OpenThread will save the pointer to the service instance.
|
||||
*
|
||||
* The `otSrpClientService` instance is not longer tracked by OpenThread and can be reclaimed only when
|
||||
*
|
||||
* - It is removed explicitly by a call to `otSrpClientRemoveService()` or removed along with other services by a
|
||||
* call to `otSrpClientRemoveHostAndServices() and only after the `otSrpClientCallback` is called indicating the
|
||||
* service was removed. Or,
|
||||
* - A call to `otSrpClientClearHostAndServices()` which removes the host and all related services immediately.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aService A pointer to a `otSrpClientService` instance to add.
|
||||
|
||||
* @retval OT_ERROR_NONE The addition of service started successfully. The `otSrpClientCallback` will be
|
||||
* called to report the status.
|
||||
* @retval OT_ERROR_ALREADY A service with the same service and instance names is already in the list.
|
||||
* @retval OT_ERROR_INVALID_ARGS The service structure is invalid (e.g., bad service name or `otDnsTxtEntry`).
|
||||
*/
|
||||
otError otSrpClientAddService(otInstance *aInstance, otSrpClientService *aService);
|
||||
|
||||
/**
|
||||
* Requests a service to be unregistered with server.
|
||||
*
|
||||
* After a successful call to this function, `otSrpClientCallback` will be called to report the status of remove
|
||||
* request with SRP server.
|
||||
|
||||
* The `otSrpClientService` instance being pointed to by @p aService MUST persist and remain unchanged after returning
|
||||
* from this function (with `OT_ERROR_NONE`). OpenThread will keep the service instance during the remove process.
|
||||
* Only after the `otSrpClientCallback` is called indicating the service instance is removed from SRP client
|
||||
* service list and can be be freed/reused.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aService A pointer to a `otSrpClientService` instance to remove.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The removal of service started successfully. The `otSrpClientCallback` will be called to
|
||||
* report the status.
|
||||
* @retval OT_ERROR_NOT_FOUND The service could not be found in the list.
|
||||
*/
|
||||
otError otSrpClientRemoveService(otInstance *aInstance, otSrpClientService *aService);
|
||||
|
||||
/**
|
||||
* Clears a service, immediately removing it from the client service list.
|
||||
*
|
||||
* Unlike `otSrpClientRemoveService()` which sends an update message to the server to remove the service, this function
|
||||
* clears the service from the client's service list without any interaction with the server. On a successful call to
|
||||
* this function, the `otSrpClientCallback` will NOT be called and the @p aService entry can be reclaimed and re-used
|
||||
* by the caller immediately.
|
||||
*
|
||||
* Can be used along with a subsequent call to `otSrpClientAddService()` (potentially reusing the same @p
|
||||
* aService entry with the same service and instance names) to update some of the parameters in an existing service.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aService A pointer to a `otSrpClientService` instance to delete.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The @p aService is deleted successfully. It can be reclaimed and re-used immediately.
|
||||
* @retval OT_ERROR_NOT_FOUND The service could not be found in the list.
|
||||
*/
|
||||
otError otSrpClientClearService(otInstance *aInstance, otSrpClientService *aService);
|
||||
|
||||
/**
|
||||
* Gets the list of services being managed by client.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the head of linked-list of all services or NULL if the list is empty.
|
||||
*/
|
||||
const otSrpClientService *otSrpClientGetServices(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Starts the remove process of the host info and all services.
|
||||
*
|
||||
* After returning from this function, `otSrpClientCallback` will be called to report the status of remove request with
|
||||
* SRP server.
|
||||
*
|
||||
* If the host info is to be permanently removed from server, @p aRemoveKeyLease should be set to `true` which removes
|
||||
* the key lease associated with host on server. Otherwise, the key lease record is kept as before, which ensures
|
||||
* that the server holds the host name in reserve for when the client is once again able to provide and register its
|
||||
* service(s).
|
||||
*
|
||||
* The @p aSendUnregToServer determines the behavior when the host info is not yet registered with the server. If
|
||||
* @p aSendUnregToServer is set to `false` (which is the default/expected value) then the SRP client will immediately
|
||||
* remove the host info and services without sending an update message to server (no need to update the server if
|
||||
* nothing is yet registered with it). If @p aSendUnregToServer is set to `true` then the SRP client will send an
|
||||
* update message to the server. Note that if the host info is registered then the value of @p aSendUnregToServer does
|
||||
* not matter and the SRP client will always send an update message to server requesting removal of all info.
|
||||
*
|
||||
* One situation where @p aSendUnregToServer can be useful is on a device reset/reboot, caller may want to remove any
|
||||
* previously registered services with the server. In this case, caller can `otSrpClientSetHostName()` and then request
|
||||
* `otSrpClientRemoveHostAndServices()` with `aSendUnregToServer` as `true`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aRemoveKeyLease A boolean indicating whether or not the host key lease should also be removed.
|
||||
* @param[in] aSendUnregToServer A boolean indicating whether to send update to server when host info is not registered.
|
||||
*
|
||||
* @retval OT_ERROR_NONE The removal of host info and services started successfully. The `otSrpClientCallback`
|
||||
* will be called to report the status.
|
||||
* @retval OT_ERROR_ALREADY The host info is already removed.
|
||||
*/
|
||||
otError otSrpClientRemoveHostAndServices(otInstance *aInstance, bool aRemoveKeyLease, bool aSendUnregToServer);
|
||||
|
||||
/**
|
||||
* Clears all host info and all the services.
|
||||
*
|
||||
* Unlike `otSrpClientRemoveHostAndServices()` which sends an update message to the server to remove all the info, this
|
||||
* function clears all the info immediately without any interaction with the server.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*/
|
||||
void otSrpClientClearHostAndServices(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the domain name being used by SRP client.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE` to be enabled.
|
||||
*
|
||||
* If domain name is not set, "default.service.arpa" will be used.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*
|
||||
* @returns The domain name string.
|
||||
*/
|
||||
const char *otSrpClientGetDomainName(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the domain name to be used by SRP client.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE` to be enabled.
|
||||
*
|
||||
* If not set "default.service.arpa" will be used.
|
||||
*
|
||||
* The name string buffer pointed to by @p aName MUST persist and stay unchanged after returning from this function.
|
||||
* OpenThread will keep the pointer to the string.
|
||||
*
|
||||
* The domain name can be set before client is started or after start but before host info is registered with server
|
||||
* (host info should be in either `STATE_TO_ADD` or `STATE_TO_REMOVE`).
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aName A pointer to the domain name string. If NULL sets it to default "default.service.arpa".
|
||||
*
|
||||
* @retval OT_ERROR_NONE The domain name label was set successfully.
|
||||
* @retval OT_ERROR_INVALID_STATE The host info is already registered with server.
|
||||
*/
|
||||
otError otSrpClientSetDomainName(otInstance *aInstance, const char *aName);
|
||||
|
||||
/**
|
||||
* Converts a `otSrpClientItemState` to a string.
|
||||
*
|
||||
* @param[in] aItemState An item state.
|
||||
*
|
||||
* @returns A string representation of @p aItemState.
|
||||
*/
|
||||
const char *otSrpClientItemStateToString(otSrpClientItemState aItemState);
|
||||
|
||||
/**
|
||||
* Enables/disables "service key record inclusion" mode.
|
||||
*
|
||||
* When enabled, SRP client will include KEY record in Service Description Instructions in the SRP update messages
|
||||
* that it sends.
|
||||
*
|
||||
* Is available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` configuration is enabled.
|
||||
*
|
||||
* @note KEY record is optional in Service Description Instruction (it is required and always included in the Host
|
||||
* Description Instruction). The default behavior of SRP client is to not include it. This function is intended to
|
||||
* override the default behavior for testing only.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aEnabled TRUE to enable, FALSE to disable the "service key record inclusion" mode.
|
||||
*/
|
||||
void otSrpClientSetServiceKeyRecordEnabled(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Indicates whether the "service key record inclusion" mode is enabled or disabled.
|
||||
*
|
||||
* Is available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` configuration is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*
|
||||
* @returns TRUE if "service key record inclusion" mode is enabled, FALSE otherwise.
|
||||
*/
|
||||
bool otSrpClientIsServiceKeyRecordEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_SRP_CLIENT_H_
|
||||
180
Libs/util/third_party/openthread/include/openthread/srp_client_buffers.h
vendored
Normal file
180
Libs/util/third_party/openthread/include/openthread/srp_client_buffers.h
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread SRP (Service Registration Protocol) client buffers and service pool.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_SRP_CLIENT_BUFFERS_H_
|
||||
#define OPENTHREAD_SRP_CLIENT_BUFFERS_H_
|
||||
|
||||
#include <openthread/dns.h>
|
||||
#include <openthread/srp_client.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-srp
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions for SRP client buffers and service pool.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* Functions in this module are only available when feature OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE is enabled.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a SRP client service pool entry.
|
||||
*/
|
||||
typedef struct otSrpClientBuffersServiceEntry
|
||||
{
|
||||
otSrpClientService mService; ///< The SRP client service structure.
|
||||
otDnsTxtEntry mTxtEntry; ///< The SRP client TXT entry.
|
||||
} otSrpClientBuffersServiceEntry;
|
||||
|
||||
/**
|
||||
* Gets the string buffer to use for SRP client host name.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[out] aSize Pointer to a variable to return the size (number of bytes) of the string buffer (MUST NOT be
|
||||
* NULL).
|
||||
*
|
||||
* @returns A pointer to char buffer to use for SRP client host name.
|
||||
*/
|
||||
char *otSrpClientBuffersGetHostNameString(otInstance *aInstance, uint16_t *aSize);
|
||||
|
||||
/**
|
||||
* Gets the array of IPv6 address entries to use as SRP client host address list.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[out] aArrayLength Pointer to a variable to return the array length i.e., number of IPv6 address entries in
|
||||
* the array (MUST NOT be NULL).
|
||||
*
|
||||
* @returns A pointer to an array of `otIp6Address` entries (number of entries is returned in @p aArrayLength).
|
||||
*/
|
||||
otIp6Address *otSrpClientBuffersGetHostAddressesArray(otInstance *aInstance, uint8_t *aArrayLength);
|
||||
|
||||
/**
|
||||
* Allocates a new service entry from the pool.
|
||||
*
|
||||
* The returned service entry instance will be initialized as follows:
|
||||
*
|
||||
* - `mService.mName` will point to an allocated string buffer which can be retrieved using the function
|
||||
* `otSrpClientBuffersGetServiceEntryServiceNameString()`.
|
||||
* - `mService.mInstanceName` will point to an allocated string buffer which can be retrieved using the function
|
||||
* `otSrpClientBuffersGetServiceEntryInstanceNameString()`.
|
||||
* - `mService.mSubTypeLabels` points to an array that is returned from `otSrpClientBuffersGetSubTypeLabelsArray()`.
|
||||
* - `mService.mTxtEntries` will point to `mTxtEntry`.
|
||||
* - `mService.mNumTxtEntries` will be set to one.
|
||||
* - Other `mService` fields (port, priority, weight) are set to zero.
|
||||
* - `mTxtEntry.mKey` is set to NULL (value is treated as already encoded).
|
||||
* - `mTxtEntry.mValue` will point to an allocated buffer which can be retrieved using the function
|
||||
* `otSrpClientBuffersGetServiceEntryTxtBuffer()`.
|
||||
* - `mTxtEntry.mValueLength` is set to zero.
|
||||
* - All related data/string buffers and arrays are cleared to all zero.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the newly allocated service entry or NULL if not more entry available in the pool.
|
||||
*/
|
||||
otSrpClientBuffersServiceEntry *otSrpClientBuffersAllocateService(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Frees a previously allocated service entry.
|
||||
*
|
||||
* The @p aService MUST be previously allocated using `otSrpClientBuffersAllocateService()` and not yet freed. Otherwise
|
||||
* the behavior of this function is undefined.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[in] aService A pointer to the service entry to free (MUST NOT be NULL).
|
||||
*/
|
||||
void otSrpClientBuffersFreeService(otInstance *aInstance, otSrpClientBuffersServiceEntry *aService);
|
||||
|
||||
/**
|
||||
* Frees all previously allocated service entries.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
*/
|
||||
void otSrpClientBuffersFreeAllServices(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the string buffer for service name from a service entry.
|
||||
*
|
||||
* @param[in] aEntry A pointer to a previously allocated service entry (MUST NOT be NULL).
|
||||
* @param[out] aSize A pointer to a variable to return the size (number of bytes) of the string buffer (MUST NOT be
|
||||
* NULL).
|
||||
*
|
||||
* @returns A pointer to the string buffer.
|
||||
*/
|
||||
char *otSrpClientBuffersGetServiceEntryServiceNameString(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize);
|
||||
|
||||
/**
|
||||
* Gets the string buffer for service instance name from a service entry.
|
||||
*
|
||||
* @param[in] aEntry A pointer to a previously allocated service entry (MUST NOT be NULL).
|
||||
* @param[out] aSize A pointer to a variable to return the size (number of bytes) of the string buffer (MUST NOT be
|
||||
* NULL).
|
||||
*
|
||||
* @returns A pointer to the string buffer.
|
||||
*/
|
||||
char *otSrpClientBuffersGetServiceEntryInstanceNameString(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize);
|
||||
|
||||
/**
|
||||
* Gets the buffer for TXT record from a service entry.
|
||||
*
|
||||
* @param[in] aEntry A pointer to a previously allocated service entry (MUST NOT be NULL).
|
||||
* @param[out] aSize A pointer to a variable to return the size (number of bytes) of the buffer (MUST NOT be NULL).
|
||||
*
|
||||
* @returns A pointer to the buffer.
|
||||
*/
|
||||
uint8_t *otSrpClientBuffersGetServiceEntryTxtBuffer(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize);
|
||||
|
||||
/**
|
||||
* Gets the array for service subtype labels from the service entry.
|
||||
*
|
||||
* @param[in] aEntry A pointer to a previously allocated service entry (MUST NOT be NULL).
|
||||
* @param[out] aArrayLength A pointer to a variable to return the array length (MUST NOT be NULL).
|
||||
*
|
||||
* @returns A pointer to the array.
|
||||
*/
|
||||
const char **otSrpClientBuffersGetSubTypeLabelsArray(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aArrayLength);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_SRP_CLIENT_BUFFERS_H_
|
||||
650
Libs/util/third_party/openthread/include/openthread/srp_server.h
vendored
Normal file
650
Libs/util/third_party/openthread/include/openthread/srp_server.h
vendored
Normal file
@@ -0,0 +1,650 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the API for server of the Service Registration Protocol (SRP).
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_SRP_SERVER_H_
|
||||
#define OPENTHREAD_SRP_SERVER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/dns.h>
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/ip6.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-srp
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions of the Service Registration Protocol.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* This opaque type represents a SRP service host.
|
||||
*/
|
||||
typedef struct otSrpServerHost otSrpServerHost;
|
||||
|
||||
/**
|
||||
* This opaque type represents a SRP service.
|
||||
*/
|
||||
typedef struct otSrpServerService otSrpServerService;
|
||||
|
||||
/**
|
||||
* The ID of a SRP service update transaction on the SRP Server.
|
||||
*/
|
||||
typedef uint32_t otSrpServerServiceUpdateId;
|
||||
|
||||
/**
|
||||
* Represents the state of the SRP server.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_SRP_SERVER_STATE_DISABLED = 0, ///< The SRP server is disabled.
|
||||
OT_SRP_SERVER_STATE_RUNNING = 1, ///< The SRP server is enabled and running.
|
||||
OT_SRP_SERVER_STATE_STOPPED = 2, ///< The SRP server is enabled but stopped.
|
||||
} otSrpServerState;
|
||||
|
||||
/**
|
||||
* Represents the address mode used by the SRP server.
|
||||
*
|
||||
* Address mode specifies how the address and port number are determined by the SRP server and how this info is
|
||||
* published in the Thread Network Data.
|
||||
*/
|
||||
typedef enum otSrpServerAddressMode
|
||||
{
|
||||
OT_SRP_SERVER_ADDRESS_MODE_UNICAST = 0, ///< Unicast address mode.
|
||||
OT_SRP_SERVER_ADDRESS_MODE_ANYCAST = 1, ///< Anycast address mode.
|
||||
} otSrpServerAddressMode;
|
||||
|
||||
/**
|
||||
* Includes SRP server TTL configurations.
|
||||
*/
|
||||
typedef struct otSrpServerTtlConfig
|
||||
{
|
||||
uint32_t mMinTtl; ///< The minimum TTL in seconds.
|
||||
uint32_t mMaxTtl; ///< The maximum TTL in seconds.
|
||||
} otSrpServerTtlConfig;
|
||||
|
||||
/**
|
||||
* Includes SRP server LEASE and KEY-LEASE configurations.
|
||||
*/
|
||||
typedef struct otSrpServerLeaseConfig
|
||||
{
|
||||
uint32_t mMinLease; ///< The minimum LEASE interval in seconds.
|
||||
uint32_t mMaxLease; ///< The maximum LEASE interval in seconds.
|
||||
uint32_t mMinKeyLease; ///< The minimum KEY-LEASE interval in seconds.
|
||||
uint32_t mMaxKeyLease; ///< The maximum KEY-LEASE interval in seconds.
|
||||
} otSrpServerLeaseConfig;
|
||||
|
||||
/**
|
||||
* Includes SRP server lease information of a host/service.
|
||||
*/
|
||||
typedef struct otSrpServerLeaseInfo
|
||||
{
|
||||
uint32_t mLease; ///< The lease time of a host/service in milliseconds.
|
||||
uint32_t mKeyLease; ///< The key lease time of a host/service in milliseconds.
|
||||
uint32_t mRemainingLease; ///< The remaining lease time of the host/service in milliseconds.
|
||||
uint32_t mRemainingKeyLease; ///< The remaining key lease time of a host/service in milliseconds.
|
||||
} otSrpServerLeaseInfo;
|
||||
|
||||
/**
|
||||
* Includes the statistics of SRP server responses.
|
||||
*/
|
||||
typedef struct otSrpServerResponseCounters
|
||||
{
|
||||
uint32_t mSuccess; ///< The number of successful responses.
|
||||
uint32_t mServerFailure; ///< The number of server failure responses.
|
||||
uint32_t mFormatError; ///< The number of format error responses.
|
||||
uint32_t mNameExists; ///< The number of 'name exists' responses.
|
||||
uint32_t mRefused; ///< The number of refused responses.
|
||||
uint32_t mOther; ///< The number of other responses.
|
||||
} otSrpServerResponseCounters;
|
||||
|
||||
/**
|
||||
* Returns the domain authorized to the SRP server.
|
||||
*
|
||||
* If the domain if not set by SetDomain, "default.service.arpa." will be returned.
|
||||
* A trailing dot is always appended even if the domain is set without it.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the dot-joined domain string.
|
||||
*/
|
||||
const char *otSrpServerGetDomain(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the domain on the SRP server.
|
||||
*
|
||||
* A trailing dot will be appended to @p aDomain if it is not already there.
|
||||
* Should only be called before the SRP server is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDomain The domain to be set. MUST NOT be NULL.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the domain to @p aDomain.
|
||||
* @retval OT_ERROR_INVALID_STATE The SRP server is already enabled and the Domain cannot be changed.
|
||||
* @retval OT_ERROR_INVALID_ARGS The argument @p aDomain is not a valid DNS domain name.
|
||||
* @retval OT_ERROR_NO_BUFS There is no memory to store content of @p aDomain.
|
||||
*/
|
||||
otError otSrpServerSetDomain(otInstance *aInstance, const char *aDomain);
|
||||
|
||||
/**
|
||||
* Returns the state of the SRP server.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The current state of the SRP server.
|
||||
*/
|
||||
otSrpServerState otSrpServerGetState(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Returns the port the SRP server is listening to.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The port of the SRP server. It returns 0 if the server is not running.
|
||||
*/
|
||||
uint16_t otSrpServerGetPort(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Returns the address mode being used by the SRP server.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The SRP server's address mode.
|
||||
*/
|
||||
otSrpServerAddressMode otSrpServerGetAddressMode(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the address mode to be used by the SRP server.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMode The address mode to use.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the address mode.
|
||||
* @retval OT_ERROR_INVALID_STATE The SRP server is enabled and the address mode cannot be changed.
|
||||
*/
|
||||
otError otSrpServerSetAddressMode(otInstance *aInstance, otSrpServerAddressMode aMode);
|
||||
|
||||
/**
|
||||
* Returns the sequence number used with anycast address mode.
|
||||
*
|
||||
* The sequence number is included in "DNS/SRP Service Anycast Address" entry published in the Network Data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The anycast sequence number.
|
||||
*/
|
||||
uint8_t otSrpServerGetAnycastModeSequenceNumber(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the sequence number used with anycast address mode.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aSequenceNumber The sequence number to use.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the address mode.
|
||||
* @retval OT_ERROR_INVALID_STATE The SRP server is enabled and the sequence number cannot be changed.
|
||||
*/
|
||||
otError otSrpServerSetAnycastModeSequenceNumber(otInstance *aInstance, uint8_t aSequenceNumber);
|
||||
|
||||
/**
|
||||
* Enables/disables the SRP server.
|
||||
*
|
||||
* On a Border Router, it is recommended to use `otSrpServerSetAutoEnableMode()` instead.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnabled A boolean to enable/disable the SRP server.
|
||||
*/
|
||||
void otSrpServerSetEnabled(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Enables/disables the auto-enable mode on SRP server.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE` feature.
|
||||
*
|
||||
* When this mode is enabled, the Border Routing Manager controls if/when to enable or disable the SRP server.
|
||||
* SRP sever is auto-enabled if/when Border Routing is started and it is done with the initial prefix and route
|
||||
* configurations (when the OMR and on-link prefixes are determined, advertised in emitted Router Advertisement message
|
||||
* on infrastructure side and published in the Thread Network Data). The SRP server is auto-disabled if/when BR is
|
||||
* stopped (e.g., if the infrastructure network interface is brought down or if BR gets detached).
|
||||
*
|
||||
* This mode can be disabled by a `otSrpServerSetAutoEnableMode()` call with @p aEnabled set to `false` or if the SRP
|
||||
* server is explicitly enabled or disabled by a call to `otSrpServerSetEnabled()` function. Disabling auto-enable mode
|
||||
* using `otSrpServerSetAutoEnableMode(false)` will not change the current state of SRP sever (e.g., if it is enabled
|
||||
* it stays enabled).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnabled A boolean to enable/disable the auto-enable mode.
|
||||
*/
|
||||
void otSrpServerSetAutoEnableMode(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Indicates whether the auto-enable mode is enabled or disabled.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE` feature.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval TRUE The auto-enable mode is enabled.
|
||||
* @retval FALSE The auto-enable mode is disabled.
|
||||
*/
|
||||
bool otSrpServerIsAutoEnableMode(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Returns SRP server TTL configuration.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aTtlConfig A pointer to an `otSrpServerTtlConfig` instance.
|
||||
*/
|
||||
void otSrpServerGetTtlConfig(otInstance *aInstance, otSrpServerTtlConfig *aTtlConfig);
|
||||
|
||||
/**
|
||||
* Sets SRP server TTL configuration.
|
||||
*
|
||||
* The granted TTL will always be no greater than the max lease interval configured via `otSrpServerSetLeaseConfig()`,
|
||||
* regardless of the minimum and maximum TTL configuration.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aTtlConfig A pointer to an `otSrpServerTtlConfig` instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the TTL configuration.
|
||||
* @retval OT_ERROR_INVALID_ARGS The TTL configuration is not valid.
|
||||
*/
|
||||
otError otSrpServerSetTtlConfig(otInstance *aInstance, const otSrpServerTtlConfig *aTtlConfig);
|
||||
|
||||
/**
|
||||
* Returns SRP server LEASE and KEY-LEASE configurations.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aLeaseConfig A pointer to an `otSrpServerLeaseConfig` instance.
|
||||
*/
|
||||
void otSrpServerGetLeaseConfig(otInstance *aInstance, otSrpServerLeaseConfig *aLeaseConfig);
|
||||
|
||||
/**
|
||||
* Sets SRP server LEASE and KEY-LEASE configurations.
|
||||
*
|
||||
* When a non-zero LEASE time is requested from a client, the granted value will be
|
||||
* limited in range [aMinLease, aMaxLease]; and a non-zero KEY-LEASE will be granted
|
||||
* in range [aMinKeyLease, aMaxKeyLease]. For zero LEASE or KEY-LEASE time, zero will
|
||||
* be granted.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aLeaseConfig A pointer to an `otSrpServerLeaseConfig` instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the LEASE and KEY-LEASE ranges.
|
||||
* @retval OT_ERROR_INVALID_ARGS The LEASE or KEY-LEASE range is not valid.
|
||||
*/
|
||||
otError otSrpServerSetLeaseConfig(otInstance *aInstance, const otSrpServerLeaseConfig *aLeaseConfig);
|
||||
|
||||
/**
|
||||
* Handles SRP service updates.
|
||||
*
|
||||
* Is called by the SRP server to notify that a SRP host and possibly SRP services
|
||||
* are being updated. It is important that the SRP updates are not committed until the handler
|
||||
* returns the result by calling otSrpServerHandleServiceUpdateResult or times out after @p aTimeout.
|
||||
*
|
||||
* A SRP service observer should always call otSrpServerHandleServiceUpdateResult with error code
|
||||
* OT_ERROR_NONE immediately after receiving the update events.
|
||||
*
|
||||
* A more generic handler may perform validations on the SRP host/services and rejects the SRP updates
|
||||
* if any validation fails. For example, an Advertising Proxy should advertise (or remove) the host and
|
||||
* services on a multicast-capable link and returns specific error code if any failure occurs.
|
||||
*
|
||||
* @param[in] aId The service update transaction ID. This ID must be passed back with
|
||||
* `otSrpServerHandleServiceUpdateResult`.
|
||||
* @param[in] aHost A pointer to the otSrpServerHost object which contains the SRP updates. The
|
||||
* handler should publish/un-publish the host and each service points to this
|
||||
* host with below rules:
|
||||
* 1. If the host is not deleted (indicated by `otSrpServerHostIsDeleted`),
|
||||
* then it should be published or updated with mDNS. Otherwise, the host
|
||||
* should be un-published (remove AAAA RRs).
|
||||
* 2. For each service points to this host, it must be un-published if the host
|
||||
* is to be un-published. Otherwise, the handler should publish or update the
|
||||
* service when it is not deleted (indicated by `otSrpServerServiceIsDeleted`)
|
||||
* and un-publish it when deleted.
|
||||
* @param[in] aTimeout The maximum time in milliseconds for the handler to process the service event.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*
|
||||
* @sa otSrpServerSetServiceUpdateHandler
|
||||
* @sa otSrpServerHandleServiceUpdateResult
|
||||
*/
|
||||
typedef void (*otSrpServerServiceUpdateHandler)(otSrpServerServiceUpdateId aId,
|
||||
const otSrpServerHost *aHost,
|
||||
uint32_t aTimeout,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Sets the SRP service updates handler on SRP server.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aServiceHandler A pointer to a service handler. Use NULL to remove the handler.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
* May be NULL if not used.
|
||||
*/
|
||||
void otSrpServerSetServiceUpdateHandler(otInstance *aInstance,
|
||||
otSrpServerServiceUpdateHandler aServiceHandler,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Reports the result of processing a SRP update to the SRP server.
|
||||
*
|
||||
* The Service Update Handler should call this function to return the result of its
|
||||
* processing of a SRP update.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aId The service update transaction ID. This should be the same ID
|
||||
* provided via `otSrpServerServiceUpdateHandler`.
|
||||
* @param[in] aError An error to be returned to the SRP server. Use OT_ERROR_DUPLICATED
|
||||
* to represent DNS name conflicts.
|
||||
*/
|
||||
void otSrpServerHandleServiceUpdateResult(otInstance *aInstance, otSrpServerServiceUpdateId aId, otError aError);
|
||||
|
||||
/**
|
||||
* Returns the next registered host on the SRP server.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aHost A pointer to current host; use NULL to get the first host.
|
||||
*
|
||||
* @returns A pointer to the registered host. NULL, if no more hosts can be found.
|
||||
*/
|
||||
const otSrpServerHost *otSrpServerGetNextHost(otInstance *aInstance, const otSrpServerHost *aHost);
|
||||
|
||||
/**
|
||||
* Returns the response counters of the SRP server.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to the response counters of the SRP server.
|
||||
*/
|
||||
const otSrpServerResponseCounters *otSrpServerGetResponseCounters(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Tells if the SRP service host has been deleted.
|
||||
*
|
||||
* A SRP service host can be deleted but retains its name for future uses.
|
||||
* In this case, the host instance is not removed from the SRP server/registry.
|
||||
*
|
||||
* @param[in] aHost A pointer to the SRP service host.
|
||||
*
|
||||
* @returns TRUE if the host has been deleted, FALSE if not.
|
||||
*/
|
||||
bool otSrpServerHostIsDeleted(const otSrpServerHost *aHost);
|
||||
|
||||
/**
|
||||
* Returns the full name of the host.
|
||||
*
|
||||
* @param[in] aHost A pointer to the SRP service host.
|
||||
*
|
||||
* @returns A pointer to the null-terminated host name string.
|
||||
*/
|
||||
const char *otSrpServerHostGetFullName(const otSrpServerHost *aHost);
|
||||
|
||||
/**
|
||||
* Indicates whether the host matches a given host name.
|
||||
*
|
||||
* DNS name matches are performed using a case-insensitive string comparison (i.e., "Abc" and "aBc" are considered to
|
||||
* be the same).
|
||||
*
|
||||
* @param[in] aHost A pointer to the SRP service host.
|
||||
* @param[in] aFullName A full host name.
|
||||
*
|
||||
* @retval TRUE If host matches the host name.
|
||||
* @retval FALSE If host does not match the host name.
|
||||
*/
|
||||
bool otSrpServerHostMatchesFullName(const otSrpServerHost *aHost, const char *aFullName);
|
||||
|
||||
/**
|
||||
* Returns the addresses of given host.
|
||||
*
|
||||
* @param[in] aHost A pointer to the SRP service host.
|
||||
* @param[out] aAddressesNum A pointer to where we should output the number of the addresses to.
|
||||
*
|
||||
* @returns A pointer to the array of IPv6 Address.
|
||||
*/
|
||||
const otIp6Address *otSrpServerHostGetAddresses(const otSrpServerHost *aHost, uint8_t *aAddressesNum);
|
||||
|
||||
/**
|
||||
* Returns the LEASE and KEY-LEASE information of a given host.
|
||||
*
|
||||
* @param[in] aHost A pointer to the SRP server host.
|
||||
* @param[out] aLeaseInfo A pointer to where to output the LEASE and KEY-LEASE information.
|
||||
*/
|
||||
void otSrpServerHostGetLeaseInfo(const otSrpServerHost *aHost, otSrpServerLeaseInfo *aLeaseInfo);
|
||||
|
||||
/**
|
||||
* Returns the next service of given host.
|
||||
*
|
||||
* @param[in] aHost A pointer to the SRP service host.
|
||||
* @param[in] aService A pointer to current SRP service instance; use NULL to get the first service.
|
||||
*
|
||||
* @returns A pointer to the next service or NULL if there is no more services.
|
||||
*/
|
||||
const otSrpServerService *otSrpServerHostGetNextService(const otSrpServerHost *aHost,
|
||||
const otSrpServerService *aService);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the SRP service has been deleted.
|
||||
*
|
||||
* A SRP service can be deleted but retains its name for future uses.
|
||||
* In this case, the service instance is not removed from the SRP server/registry.
|
||||
* It is guaranteed that all services are deleted if the host is deleted.
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP service.
|
||||
*
|
||||
* @returns TRUE if the service has been deleted, FALSE if not.
|
||||
*/
|
||||
bool otSrpServerServiceIsDeleted(const otSrpServerService *aService);
|
||||
|
||||
/**
|
||||
* Returns the full service instance name of the service.
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP service.
|
||||
*
|
||||
* @returns A pointer to the null-terminated service instance name string.
|
||||
*/
|
||||
const char *otSrpServerServiceGetInstanceName(const otSrpServerService *aService);
|
||||
|
||||
/**
|
||||
* Indicates whether this service matches a given service instance name.
|
||||
*
|
||||
* DNS name matches are performed using a case-insensitive string comparison (i.e., "Abc" and "aBc" are considered to
|
||||
* be the same).
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP service.
|
||||
* @param[in] aInstanceName The service instance name.
|
||||
*
|
||||
* @retval TRUE If service matches the service instance name.
|
||||
* @retval FALSE If service does not match the service instance name.
|
||||
*/
|
||||
bool otSrpServerServiceMatchesInstanceName(const otSrpServerService *aService, const char *aInstanceName);
|
||||
|
||||
/**
|
||||
* Returns the service instance label (first label in instance name) of the service.
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP service.
|
||||
*
|
||||
* @returns A pointer to the null-terminated service instance label string..
|
||||
*/
|
||||
const char *otSrpServerServiceGetInstanceLabel(const otSrpServerService *aService);
|
||||
|
||||
/**
|
||||
* Returns the full service name of the service.
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP service.
|
||||
*
|
||||
* @returns A pointer to the null-terminated service name string.
|
||||
*/
|
||||
const char *otSrpServerServiceGetServiceName(const otSrpServerService *aService);
|
||||
|
||||
/**
|
||||
* Indicates whether this service matches a given service name.
|
||||
*
|
||||
* DNS name matches are performed using a case-insensitive string comparison (i.e., "Abc" and "aBc" are considered to
|
||||
* be the same).
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP service.
|
||||
* @param[in] aServiceName The service name.
|
||||
*
|
||||
* @retval TRUE If service matches the service name.
|
||||
* @retval FALSE If service does not match the service name.
|
||||
*/
|
||||
bool otSrpServerServiceMatchesServiceName(const otSrpServerService *aService, const char *aServiceName);
|
||||
|
||||
/**
|
||||
* Gets the number of sub-types of the service.
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP service.
|
||||
*
|
||||
* @returns The number of sub-types of @p aService.
|
||||
*/
|
||||
uint16_t otSrpServerServiceGetNumberOfSubTypes(const otSrpServerService *aService);
|
||||
|
||||
/**
|
||||
* Gets the sub-type service name (full name) of the service at a given index
|
||||
*
|
||||
* The full service name for a sub-type service follows "<sub-label>._sub.<service-labels>.<domain>.".
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP service.
|
||||
* @param[in] aIndex The index to get.
|
||||
*
|
||||
* @returns A pointer to sub-type service name at @p aIndex, or `NULL` if no sub-type at this index.
|
||||
*/
|
||||
const char *otSrpServerServiceGetSubTypeServiceNameAt(const otSrpServerService *aService, uint16_t aIndex);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the service has a given sub-type.
|
||||
*
|
||||
* DNS name matches are performed using a case-insensitive string comparison (i.e., "Abc" and "aBc" are considered to
|
||||
* be the same).
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP service.
|
||||
* @param[in] aSubTypeServiceName The sub-type service name (full name) to check.
|
||||
*
|
||||
* @retval TRUE Service contains the sub-type @p aSubTypeServiceName.
|
||||
* @retval FALSE Service does not contain the sub-type @p aSubTypeServiceName.
|
||||
*/
|
||||
bool otSrpServerServiceHasSubTypeServiceName(const otSrpServerService *aService, const char *aSubTypeServiceName);
|
||||
|
||||
/**
|
||||
* Parses a sub-type service name (full name) and extracts the sub-type label.
|
||||
*
|
||||
* The full service name for a sub-type service follows "<sub-label>._sub.<service-labels>.<domain>.".
|
||||
*
|
||||
* @param[in] aSubTypeServiceName A sub-type service name (full name).
|
||||
* @param[out] aLabel A pointer to a buffer to copy the extracted sub-type label.
|
||||
* @param[in] aLabelSize Maximum size of @p aLabel buffer.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Name was successfully parsed and @p aLabel was updated.
|
||||
* @retval OT_ERROR_NO_BUFS The sub-type label could not fit in @p aLabel buffer (number of chars from label
|
||||
* that could fit are copied in @p aLabel ensuring it is null-terminated).
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aSubTypeServiceName is not a valid sub-type format.
|
||||
*/
|
||||
otError otSrpServerParseSubTypeServiceName(const char *aSubTypeServiceName, char *aLabel, uint8_t aLabelSize);
|
||||
|
||||
/**
|
||||
* Returns the port of the service instance.
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP service.
|
||||
*
|
||||
* @returns The port of the service.
|
||||
*/
|
||||
uint16_t otSrpServerServiceGetPort(const otSrpServerService *aService);
|
||||
|
||||
/**
|
||||
* Returns the weight of the service instance.
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP service.
|
||||
*
|
||||
* @returns The weight of the service.
|
||||
*/
|
||||
uint16_t otSrpServerServiceGetWeight(const otSrpServerService *aService);
|
||||
|
||||
/**
|
||||
* Returns the priority of the service instance.
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP service.
|
||||
*
|
||||
* @returns The priority of the service.
|
||||
*/
|
||||
uint16_t otSrpServerServiceGetPriority(const otSrpServerService *aService);
|
||||
|
||||
/**
|
||||
* Returns the TTL of the service instance.
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP service.
|
||||
*
|
||||
* @returns The TTL of the service instance..
|
||||
*/
|
||||
uint32_t otSrpServerServiceGetTtl(const otSrpServerService *aService);
|
||||
|
||||
/**
|
||||
* Returns the TXT record data of the service instance.
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP service.
|
||||
* @param[out] aDataLength A pointer to return the TXT record data length. MUST NOT be NULL.
|
||||
*
|
||||
* @returns A pointer to the buffer containing the TXT record data (the TXT data length is returned in @p aDataLength).
|
||||
*/
|
||||
const uint8_t *otSrpServerServiceGetTxtData(const otSrpServerService *aService, uint16_t *aDataLength);
|
||||
|
||||
/**
|
||||
* Returns the host which the service instance reside on.
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP service.
|
||||
*
|
||||
* @returns A pointer to the host instance.
|
||||
*/
|
||||
const otSrpServerHost *otSrpServerServiceGetHost(const otSrpServerService *aService);
|
||||
|
||||
/**
|
||||
* Returns the LEASE and KEY-LEASE information of a given service.
|
||||
*
|
||||
* @param[in] aService A pointer to the SRP server service.
|
||||
* @param[out] aLeaseInfo A pointer to where to output the LEASE and KEY-LEASE information.
|
||||
*/
|
||||
void otSrpServerServiceGetLeaseInfo(const otSrpServerService *aService, otSrpServerLeaseInfo *aLeaseInfo);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_SRP_SERVER_H_
|
||||
85
Libs/util/third_party/openthread/include/openthread/tasklet.h
vendored
Normal file
85
Libs/util/third_party/openthread/include/openthread/tasklet.h
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread API for Tasklets.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_TASKLET_H_
|
||||
#define OPENTHREAD_TASKLET_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-tasklets
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control the Thread stack's execution.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Run all queued OpenThread tasklets at the time this is called.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otTaskletsProcess(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Indicates whether or not OpenThread has tasklets pending.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval TRUE If there are tasklets pending.
|
||||
* @retval FALSE If there are no tasklets pending.
|
||||
*/
|
||||
bool otTaskletsArePending(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* OpenThread calls this function when the tasklet queue transitions from empty to non-empty.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
extern void otTaskletsSignalPending(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_TASKLET_H_
|
||||
199
Libs/util/third_party/openthread/include/openthread/tcat.h
vendored
Normal file
199
Libs/util/third_party/openthread/include/openthread/tcat.h
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the top-level functions for the OpenThread TCAT.
|
||||
*
|
||||
* @note
|
||||
* The functions in this module require the build-time feature `OPENTHREAD_CONFIG_BLE_TCAT_ENABLE=1`.
|
||||
*
|
||||
* @note
|
||||
* To enable cipher suite DTLS_PSK_WITH_AES_128_CCM_8, MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
|
||||
* must be enabled in mbedtls-config.h
|
||||
* To enable cipher suite DTLS_ECDHE_ECDSA_WITH_AES_128_CCM_8,
|
||||
* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED must be enabled in mbedtls-config.h.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_TCAT_H_
|
||||
#define OPENTHREAD_TCAT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <openthread/message.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-ble-secure
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that implement TCAT communication.
|
||||
*
|
||||
* The functions in this module are available when TCAT feature
|
||||
* (`OPENTHREAD_CONFIG_BLE_TCAT_ENABLE`) is enabled.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define OT_TCAT_MAX_SERVICE_NAME_LENGTH \
|
||||
15 ///< Maximum string length of a UDP or TCP service name (does not include null char).
|
||||
|
||||
#define OT_TCAT_ADVERTISEMENT_MAX_LEN 29 ///< Maximum length of TCAT advertisement.
|
||||
#define OT_TCAT_OPCODE 0x2 ///< TCAT Advertisement Operation Code.
|
||||
#define OT_TCAT_MAX_ADVERTISED_DEVICEID_SIZE 5 ///< TCAT max size of any type of advertised Device ID.
|
||||
#define OT_TCAT_MAX_DEVICEID_SIZE 64 ///< TCAT max size of device ID.
|
||||
|
||||
/**
|
||||
* Represents TCAT status code.
|
||||
*/
|
||||
typedef enum otTcatStatusCode
|
||||
{
|
||||
OT_TCAT_STATUS_SUCCESS = 0, ///< Command or request was successfully processed
|
||||
OT_TCAT_STATUS_UNSUPPORTED = 1, ///< Requested command or received TLV is not supported
|
||||
OT_TCAT_STATUS_PARSE_ERROR = 2, ///< Request / command could not be parsed correctly
|
||||
OT_TCAT_STATUS_VALUE_ERROR = 3, ///< The value of the transmitted TLV has an error
|
||||
OT_TCAT_STATUS_GENERAL_ERROR = 4, ///< An error not matching any other category occurred
|
||||
OT_TCAT_STATUS_BUSY = 5, ///< Command cannot be executed because the resource is busy
|
||||
OT_TCAT_STATUS_UNDEFINED = 6, ///< The requested value, data or service is not defined (currently) or not present
|
||||
OT_TCAT_STATUS_HASH_ERROR = 7, ///< The hash value presented by the commissioner was incorrect
|
||||
OT_TCAT_STATUS_UNAUTHORIZED = 16, ///< Sender does not have sufficient authorization for the given command
|
||||
|
||||
} otTcatStatusCode;
|
||||
|
||||
/**
|
||||
* Represents TCAT application protocol.
|
||||
*/
|
||||
typedef enum otTcatApplicationProtocol
|
||||
{
|
||||
OT_TCAT_APPLICATION_PROTOCOL_NONE = 0, ///< Message which has been sent without activating the TCAT agent
|
||||
OT_TCAT_APPLICATION_PROTOCOL_STATUS = 1, ///< Message directed to a UDP service
|
||||
OT_TCAT_APPLICATION_PROTOCOL_TCP = 2, ///< Message directed to a TCP service
|
||||
|
||||
} otTcatApplicationProtocol;
|
||||
|
||||
/**
|
||||
* Represents a TCAT command class.
|
||||
*/
|
||||
typedef enum otTcatCommandClass
|
||||
{
|
||||
OT_TCAT_COMMAND_CLASS_GENERAL = 0, ///< TCAT commands related to general operations
|
||||
OT_TCAT_COMMAND_CLASS_COMMISSIONING = 1, ///< TCAT commands related to commissioning
|
||||
OT_TCAT_COMMAND_CLASS_EXTRACTION = 2, ///< TCAT commands related to key extraction
|
||||
OT_TCAT_COMMAND_CLASS_DECOMMISSIONING = 3, ///< TCAT commands related to de-commissioning
|
||||
OT_TCAT_COMMAND_CLASS_APPLICATION = 4, ///< TCAT commands related to application layer
|
||||
|
||||
} otTcatCommandClass;
|
||||
|
||||
/**
|
||||
* Represents Advertised Device ID type. (used during TCAT advertisement)
|
||||
*/
|
||||
typedef enum otTcatAdvertisedDeviceIdType
|
||||
{
|
||||
OT_TCAT_DEVICE_ID_EMPTY = 0, ///< Vendor device ID type not set
|
||||
OT_TCAT_DEVICE_ID_OUI24 = 1, ///< Vendor device ID type IEEE OUI-24
|
||||
OT_TCAT_DEVICE_ID_OUI36 = 2, ///< Vendor device ID type IEEE OUI-36
|
||||
OT_TCAT_DEVICE_ID_DISCRIMINATOR = 3, ///< Vendor device ID type Device Discriminator
|
||||
OT_TCAT_DEVICE_ID_IANAPEN = 4, ///< Vendor device ID type IANA PEN
|
||||
OT_TCAT_DEVICE_ID_MAX = 5, ///< Vendor device ID type size
|
||||
} otTcatAdvertisedDeviceIdType;
|
||||
|
||||
typedef struct otTcatAdvertisedDeviceId
|
||||
{
|
||||
otTcatAdvertisedDeviceIdType mDeviceIdType;
|
||||
uint16_t mDeviceIdLen;
|
||||
uint8_t mDeviceId[OT_TCAT_MAX_ADVERTISED_DEVICEID_SIZE];
|
||||
} otTcatAdvertisedDeviceId;
|
||||
|
||||
/**
|
||||
* Represents General Device ID type.
|
||||
*/
|
||||
typedef struct otTcatGeneralDeviceId
|
||||
{
|
||||
uint16_t mDeviceIdLen;
|
||||
uint8_t mDeviceId[OT_TCAT_MAX_DEVICEID_SIZE];
|
||||
} otTcatGeneralDeviceId;
|
||||
|
||||
/**
|
||||
* This structure represents a TCAT vendor information.
|
||||
*
|
||||
* The content of this structure MUST persist and remain unchanged while a TCAT session is running.
|
||||
*/
|
||||
typedef struct otTcatVendorInfo
|
||||
{
|
||||
const char *mProvisioningUrl; ///< Provisioning URL path string
|
||||
const char *mVendorName; ///< Vendor name string
|
||||
const char *mVendorModel; ///< Vendor model string
|
||||
const char *mVendorSwVersion; ///< Vendor software version string
|
||||
const char *mVendorData; ///< Vendor specific data string
|
||||
const char *mPskdString; ///< Vendor managed pre-shared key for device
|
||||
const char *mInstallCode; ///< Vendor managed install code string
|
||||
const otTcatAdvertisedDeviceId *mAdvertisedDeviceIds; /** Vendor managed advertised device ID array.
|
||||
Array is terminated like C string with OT_TCAT_DEVICE_ID_EMPTY */
|
||||
const otTcatGeneralDeviceId *mGeneralDeviceId; /** Vendor managed general device ID array.
|
||||
(if NULL: device ID is set to EUI-64 in binary format)*/
|
||||
|
||||
} otTcatVendorInfo;
|
||||
|
||||
/**
|
||||
* Pointer to call when application data was received over a TCAT TLS connection.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMessage A pointer to the message.
|
||||
* @param[in] aOffset The offset where the application data begins.
|
||||
* @param[in] aTcatApplicationProtocol The protocol type of the message received.
|
||||
* @param[in] aServiceName The name of the service the message is direced to.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*/
|
||||
typedef void (*otHandleTcatApplicationDataReceive)(otInstance *aInstance,
|
||||
const otMessage *aMessage,
|
||||
int32_t aOffset,
|
||||
otTcatApplicationProtocol aTcatApplicationProtocol,
|
||||
const char *aServiceName,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Pointer to call to notify the completion of a join operation.
|
||||
*
|
||||
* @param[in] aError OT_ERROR_NONE if the join process succeeded.
|
||||
* OT_ERROR_SECURITY if the join process failed due to security credentials.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*/
|
||||
typedef void (*otHandleTcatJoin)(otError aError, void *aContext);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif /* OPENTHREAD_TCAT_H_ */
|
||||
753
Libs/util/third_party/openthread/include/openthread/tcp.h
vendored
Normal file
753
Libs/util/third_party/openthread/include/openthread/tcp.h
vendored
Normal file
@@ -0,0 +1,753 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread TCP API.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_TCP_H_
|
||||
#define OPENTHREAD_TCP_H_
|
||||
|
||||
#include <openthread/ip6.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-tcp
|
||||
*
|
||||
* @brief
|
||||
* This module includes functions that control TCP communication.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* A linked buffer structure for use with TCP.
|
||||
*
|
||||
* A single otLinkedBuffer structure references an array of bytes in memory,
|
||||
* via mData and mLength. The mNext field is used to form a chain of
|
||||
* otLinkedBuffer structures.
|
||||
*/
|
||||
typedef struct otLinkedBuffer
|
||||
{
|
||||
struct otLinkedBuffer *mNext; ///< Pointer to the next linked buffer in the chain, or NULL if it is the end.
|
||||
const uint8_t *mData; ///< Pointer to data referenced by this linked buffer.
|
||||
size_t mLength; ///< Length of this linked buffer (number of bytes).
|
||||
} otLinkedBuffer;
|
||||
|
||||
struct otTcpEndpoint;
|
||||
typedef struct otTcpEndpoint otTcpEndpoint;
|
||||
|
||||
/**
|
||||
* This callback informs the application that the TCP 3-way handshake is
|
||||
* complete and that the connection is now established.
|
||||
*
|
||||
* @param[in] aEndpoint The TCP endpoint whose connection is now established.
|
||||
*/
|
||||
typedef void (*otTcpEstablished)(otTcpEndpoint *aEndpoint);
|
||||
|
||||
/**
|
||||
* This callback informs the application that data in the provided
|
||||
* @p aData have been acknowledged by the connection peer and that @p aData and
|
||||
* the data it contains can be reclaimed by the application.
|
||||
*
|
||||
* The @p aData are guaranteed to be identical to those passed in to TCP via
|
||||
* otTcpSendByReference(), including any extensions effected via
|
||||
* otTcpSendByExtension().
|
||||
*
|
||||
* @param[in] aEndpoint The TCP endpoint for the connection.
|
||||
* @param[in] aData A pointer to the otLinkedBuffer that can be reclaimed.
|
||||
*/
|
||||
typedef void (*otTcpSendDone)(otTcpEndpoint *aEndpoint, otLinkedBuffer *aData);
|
||||
|
||||
/**
|
||||
* This callback informs the application if forward progress has been made in
|
||||
* transferring data from the send buffer to the recipient. This callback is
|
||||
* not necessary for correct TCP operation. Most applications can just rely on
|
||||
* the otTcpSendDone() callback to reclaim linked buffers once the TCP stack is
|
||||
* done using them. The purpose of this callback is to support advanced
|
||||
* applications that benefit from finer-grained information about how the
|
||||
* the connection is making forward progress in transferring data to the
|
||||
* connection peer.
|
||||
*
|
||||
* This callback's operation is closely tied to TCP's send buffer. The send
|
||||
* buffer can be understood as having two regions. First, there is the
|
||||
* "in-flight" region at the head (front) of the send buffer. It corresponds
|
||||
* to data which has been sent to the recipient, but is not yet acknowledged.
|
||||
* Second, there is the "backlog" region, which consists of all data in the
|
||||
* send buffer that is not in the "in-flight" region. The "backlog" region
|
||||
* corresponds to data that is queued for sending, but has not yet been sent.
|
||||
*
|
||||
* The callback is invoked in response to two types of events. First, the
|
||||
* "in-flight" region of the send buffer may shrink (e.g., when the recipient
|
||||
* acknowledges data that we sent earlier). Second, the "backlog" region of the
|
||||
* send buffer may shrink (e.g., new data was sent out). These two conditions
|
||||
* often occur at the same time, in response to an ACK segment from the
|
||||
* connection peer, which is why they are combined in a single callback.
|
||||
*
|
||||
* The TCP stack only uses the @p aInSendBuffer bytes at the tail of the send
|
||||
* buffer; when @p aInSendBuffer decreases by an amount x, it means that x
|
||||
* additional bytes that were formerly at the head of the send buffer are no
|
||||
* longer part of the send buffer and can now be reclaimed (i.e., overwritten)
|
||||
* by the application. Note that the otLinkedBuffer structure itself can only
|
||||
* be reclaimed once all bytes that it references are no longer part of the
|
||||
* send buffer.
|
||||
*
|
||||
* This callback subsumes otTcpSendDone(), in the following sense: applications
|
||||
* can determine when linked buffers can be reclaimed by comparing
|
||||
* @p aInSendBuffer with how many bytes are in each linked buffer. However, we
|
||||
* expect otTcpSendDone(), which directly conveys which otLinkedBuffers can be
|
||||
* reclaimed, to be much simpler to use. If both callbacks are registered and
|
||||
* are triggered by the same event (e.g., the same ACK segment received), then
|
||||
* the otTcpSendDone() callback will be triggered first, followed by this
|
||||
* callback.
|
||||
*
|
||||
* Additionally, this callback provides @p aBacklog, which indicates how many
|
||||
* bytes of data in the send buffer are not yet in flight. For applications
|
||||
* that only want to add data to the send buffer when there is an assurance
|
||||
* that it will be sent out soon, it may be desirable to only send out data
|
||||
* when @p aBacklog is suitably small (0 or close to 0). For example, an
|
||||
* application may use @p aBacklog so that it can react to queue buildup by
|
||||
* dropping or aggregating data to avoid creating a backlog of data.
|
||||
*
|
||||
* After a call to otTcpSendByReference() or otTcpSendByExtension() with a
|
||||
* positive number of bytes, the otTcpForwardProgress() callback is guaranteed
|
||||
* to be called, to indicate when the bytes that were added to the send buffer
|
||||
* are sent out. The call to otTcpForwardProgress() may be made immediately
|
||||
* after the bytes are added to the send buffer (if some of those bytes are
|
||||
* immediately sent out, reducing the backlog), or sometime in the future (once
|
||||
* the connection sends out some or all of the data, reducing the backlog). By
|
||||
* "immediately," we mean that the callback is immediately scheduled for
|
||||
* execution in a tasklet; to avoid reentrancy-related complexity, the
|
||||
* otTcpForwardProgress() callback is never directly called from the
|
||||
* otTcpSendByReference() or otTcpSendByExtension() functions.
|
||||
*
|
||||
* @param[in] aEndpoint The TCP endpoint for the connection.
|
||||
* @param[in] aInSendBuffer The number of bytes in the send buffer (sum of "in-flight" and "backlog" regions).
|
||||
* @param[in] aBacklog The number of bytes that are queued for sending but have not yet been sent (the "backlog"
|
||||
* region).
|
||||
*/
|
||||
typedef void (*otTcpForwardProgress)(otTcpEndpoint *aEndpoint, size_t aInSendBuffer, size_t aBacklog);
|
||||
|
||||
/**
|
||||
* This callback indicates the number of bytes available for consumption from
|
||||
* the receive buffer.
|
||||
*
|
||||
* It is called whenever bytes are added to the receive buffer and when the
|
||||
* end of stream is reached. If the end of the stream has been reached (i.e.,
|
||||
* if no more data will become available to read because the connection peer
|
||||
* has closed their end of the connection for writing), then @p aEndOfStream is
|
||||
* true. Finally, @p aBytesRemaining indicates how much capacity is left in the
|
||||
* receive buffer to hold additional data that arrives.
|
||||
*
|
||||
* @param[in] aEndpoint The TCP endpoint for the connection.
|
||||
* @param[in] aBytesAvailable The number of bytes in the connection's receive buffer.
|
||||
* @param[in] aEndOfStream Indicates if additional data, beyond what is already in the connection's receive buffer,
|
||||
* can be received.
|
||||
* @param[in] aBytesRemaining The number of additional bytes that can be received before the receive buffer becomes
|
||||
* full.
|
||||
*/
|
||||
typedef void (*otTcpReceiveAvailable)(otTcpEndpoint *aEndpoint,
|
||||
size_t aBytesAvailable,
|
||||
bool aEndOfStream,
|
||||
size_t aBytesRemaining);
|
||||
|
||||
typedef enum otTcpDisconnectedReason
|
||||
{
|
||||
OT_TCP_DISCONNECTED_REASON_NORMAL,
|
||||
OT_TCP_DISCONNECTED_REASON_REFUSED,
|
||||
OT_TCP_DISCONNECTED_REASON_RESET,
|
||||
OT_TCP_DISCONNECTED_REASON_TIME_WAIT,
|
||||
OT_TCP_DISCONNECTED_REASON_TIMED_OUT,
|
||||
} otTcpDisconnectedReason;
|
||||
|
||||
/**
|
||||
* This callback indicates that the connection was broken and should no longer
|
||||
* be used, or that a connection has entered the TIME-WAIT state.
|
||||
*
|
||||
* It can occur if a connection establishment attempt (initiated by calling
|
||||
* otTcpConnect()) fails, or any point thereafter (e.g., if the connection
|
||||
* times out or an RST segment is received from the connection peer). Once this
|
||||
* callback fires, all resources that the application provided for this
|
||||
* connection (i.e., any `otLinkedBuffers` and memory they reference, but not
|
||||
* the TCP endpoint itself or space for the receive buffers) can be reclaimed.
|
||||
* In the case of a connection entering the TIME-WAIT state, this callback is
|
||||
* called twice, once upon entry into the TIME-WAIT state (with
|
||||
* OT_TCP_DISCONNECTED_REASON_TIME_WAIT, and again when the TIME-WAIT state
|
||||
* expires (with OT_TCP_DISCONNECTED_REASON_NORMAL).
|
||||
*
|
||||
* @param[in] aEndpoint The TCP endpoint whose connection has been lost.
|
||||
* @param[in] aReason The reason why the connection was lost.
|
||||
*/
|
||||
typedef void (*otTcpDisconnected)(otTcpEndpoint *aEndpoint, otTcpDisconnectedReason aReason);
|
||||
|
||||
/**
|
||||
* OT_TCP_ENDPOINT_TCB_SIZE_BASE and OT_TCP_ENDPOINT_TCB_NUM_POINTERS are
|
||||
* chosen such that the mTcb field of otTcpEndpoint has the same size as
|
||||
* struct tcpcb in TCPlp. This is necessary because the mTcb field, although
|
||||
* opaque in its declaration, is treated as struct tcpcb in the TCP
|
||||
* implementation.
|
||||
*/
|
||||
#define OT_TCP_ENDPOINT_TCB_SIZE_BASE 392
|
||||
#define OT_TCP_ENDPOINT_TCB_NUM_PTR 36
|
||||
|
||||
/**
|
||||
* Represents a TCP endpoint.
|
||||
*
|
||||
* A TCP endpoint acts an endpoint of TCP connection. It can be used to
|
||||
* initiate TCP connections, and, once a TCP connection is established, send
|
||||
* data to and receive data from the connection peer.
|
||||
*
|
||||
* The application should not inspect the fields of this structure directly; it
|
||||
* should only interact with it via the TCP API functions whose signatures are
|
||||
* provided in this file.
|
||||
*/
|
||||
struct otTcpEndpoint
|
||||
{
|
||||
union
|
||||
{
|
||||
uint8_t mSize[OT_TCP_ENDPOINT_TCB_SIZE_BASE + OT_TCP_ENDPOINT_TCB_NUM_PTR * sizeof(void *)];
|
||||
uint64_t mAlign;
|
||||
} mTcb;
|
||||
|
||||
struct otTcpEndpoint *mNext; ///< A pointer to the next TCP endpoint (internal use only)
|
||||
void *mContext; ///< A pointer to application-specific context
|
||||
|
||||
otTcpEstablished mEstablishedCallback; ///< "Established" callback function
|
||||
otTcpSendDone mSendDoneCallback; ///< "Send done" callback function
|
||||
otTcpForwardProgress mForwardProgressCallback; ///< "Forward progress" callback function
|
||||
otTcpReceiveAvailable mReceiveAvailableCallback; ///< "Receive available" callback function
|
||||
otTcpDisconnected mDisconnectedCallback; ///< "Disconnected" callback function
|
||||
|
||||
uint32_t mTimers[4];
|
||||
|
||||
otLinkedBuffer mReceiveLinks[2];
|
||||
otSockAddr mSockAddr;
|
||||
|
||||
uint8_t mPendingCallbacks;
|
||||
};
|
||||
|
||||
/**
|
||||
* Contains arguments to the otTcpEndpointInitialize() function.
|
||||
*/
|
||||
typedef struct otTcpEndpointInitializeArgs
|
||||
{
|
||||
void *mContext; ///< Pointer to application-specific context
|
||||
|
||||
otTcpEstablished mEstablishedCallback; ///< "Established" callback function
|
||||
otTcpSendDone mSendDoneCallback; ///< "Send done" callback function
|
||||
otTcpForwardProgress mForwardProgressCallback; ///< "Forward progress" callback function
|
||||
otTcpReceiveAvailable mReceiveAvailableCallback; ///< "Receive available" callback function
|
||||
otTcpDisconnected mDisconnectedCallback; ///< "Disconnected" callback function
|
||||
|
||||
void *mReceiveBuffer; ///< Pointer to memory provided to the system for the TCP receive buffer
|
||||
size_t mReceiveBufferSize; ///< Size of memory provided to the system for the TCP receive buffer
|
||||
} otTcpEndpointInitializeArgs;
|
||||
|
||||
/**
|
||||
* @def OT_TCP_RECEIVE_BUFFER_SIZE_FEW_HOPS
|
||||
*
|
||||
* Recommended buffer size for TCP connections that traverse about 3 wireless
|
||||
* hops or fewer.
|
||||
*
|
||||
* On platforms where memory is particularly constrained and in situations
|
||||
* where high bandwidth is not necessary, it may be desirable to manually
|
||||
* select a smaller buffer size.
|
||||
*/
|
||||
#define OT_TCP_RECEIVE_BUFFER_SIZE_FEW_HOPS 2598
|
||||
|
||||
/**
|
||||
* @def OT_TCP_RECEIVE_BUFFER_SIZE_MANY_HOPS
|
||||
*
|
||||
* Recommended buffer size for TCP connections that traverse many wireless
|
||||
* hops.
|
||||
*
|
||||
* If the TCP connection traverses a very large number of hops (more than 6 or
|
||||
* so), then it may be advisable to select a large buffer size manually.
|
||||
*/
|
||||
#define OT_TCP_RECEIVE_BUFFER_SIZE_MANY_HOPS 4157
|
||||
|
||||
/**
|
||||
* Initializes a TCP endpoint.
|
||||
*
|
||||
* Calling this function causes OpenThread to keep track of the TCP endpoint
|
||||
* and store and retrieve TCP data inside the @p aEndpoint. The application
|
||||
* should refrain from directly accessing or modifying the fields in
|
||||
* @p aEndpoint. If the application needs to reclaim the memory backing
|
||||
* @p aEndpoint, it should call otTcpEndpointDeinitialize().
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEndpoint A pointer to a TCP endpoint structure.
|
||||
* @param[in] aArgs A pointer to a structure of arguments.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully opened the TCP endpoint.
|
||||
* @retval OT_ERROR_FAILED Failed to open the TCP endpoint.
|
||||
*/
|
||||
otError otTcpEndpointInitialize(otInstance *aInstance,
|
||||
otTcpEndpoint *aEndpoint,
|
||||
const otTcpEndpointInitializeArgs *aArgs);
|
||||
|
||||
/**
|
||||
* Obtains the otInstance that was associated with @p aEndpoint upon
|
||||
* initialization.
|
||||
*
|
||||
* @param[in] aEndpoint The TCP endpoint whose instance to obtain.
|
||||
*
|
||||
* @returns The otInstance pointer associated with @p aEndpoint.
|
||||
*/
|
||||
otInstance *otTcpEndpointGetInstance(otTcpEndpoint *aEndpoint);
|
||||
|
||||
/**
|
||||
* Obtains the context pointer that was associated with @p aEndpoint upon
|
||||
* initialization.
|
||||
*
|
||||
* @param[in] aEndpoint The TCP endpoint whose context to obtain.
|
||||
*
|
||||
* @returns The context pointer associated with @p aEndpoint.
|
||||
*/
|
||||
void *otTcpEndpointGetContext(otTcpEndpoint *aEndpoint);
|
||||
|
||||
/**
|
||||
* Obtains a pointer to a TCP endpoint's local host and port.
|
||||
*
|
||||
* The contents of the host and port may be stale if this socket is not in a
|
||||
* connected state and has not been bound after it was last disconnected.
|
||||
*
|
||||
* @param[in] aEndpoint The TCP endpoint whose local host and port to obtain.
|
||||
*
|
||||
* @returns The local host and port of @p aEndpoint.
|
||||
*/
|
||||
const otSockAddr *otTcpGetLocalAddress(const otTcpEndpoint *aEndpoint);
|
||||
|
||||
/**
|
||||
* Obtains a pointer to a TCP endpoint's peer's host and port.
|
||||
*
|
||||
* The contents of the host and port may be stale if this socket is not in a
|
||||
* connected state.
|
||||
*
|
||||
* @param[in] aEndpoint The TCP endpoint whose peer's host and port to obtain.
|
||||
*
|
||||
* @returns The host and port of the connection peer of @p aEndpoint.
|
||||
*/
|
||||
const otSockAddr *otTcpGetPeerAddress(const otTcpEndpoint *aEndpoint);
|
||||
|
||||
/**
|
||||
* Binds the TCP endpoint to an IP address and port.
|
||||
*
|
||||
* @param[in] aEndpoint A pointer to the TCP endpoint structure to bind.
|
||||
* @param[in] aSockName The address and port to which to bind this TCP endpoint.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully bound the TCP endpoint.
|
||||
* @retval OT_ERROR_FAILED Failed to bind the TCP endpoint.
|
||||
*/
|
||||
otError otTcpBind(otTcpEndpoint *aEndpoint, const otSockAddr *aSockName);
|
||||
|
||||
/**
|
||||
* Defines flags passed to otTcpConnect().
|
||||
*/
|
||||
enum
|
||||
{
|
||||
OT_TCP_CONNECT_NO_FAST_OPEN = 1 << 0,
|
||||
};
|
||||
|
||||
/**
|
||||
* Records the remote host and port for this connection.
|
||||
*
|
||||
* TCP Fast Open must be enabled or disabled using @p aFlags. If it is
|
||||
* disabled, then the TCP connection establishment handshake is initiated
|
||||
* immediately. If it is enabled, then this function merely records the
|
||||
* the remote host and port, and the TCP connection establishment handshake
|
||||
* only happens on the first call to `otTcpSendByReference()`.
|
||||
*
|
||||
* If TCP Fast Open is disabled, then the caller must wait for the
|
||||
* `otTcpEstablished` callback indicating that TCP connection establishment
|
||||
* handshake is done before it can start sending data e.g., by calling
|
||||
* `otTcpSendByReference()`.
|
||||
*
|
||||
* @param[in] aEndpoint A pointer to the TCP endpoint structure to connect.
|
||||
* @param[in] aSockName The IP address and port of the host to which to connect.
|
||||
* @param[in] aFlags Flags specifying options for this operation (see enumeration above).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully completed the operation.
|
||||
* @retval OT_ERROR_FAILED Failed to complete the operation.
|
||||
*/
|
||||
otError otTcpConnect(otTcpEndpoint *aEndpoint, const otSockAddr *aSockName, uint32_t aFlags);
|
||||
|
||||
/**
|
||||
* Defines flags passed to @p otTcpSendByReference.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
OT_TCP_SEND_MORE_TO_COME = 1 << 0,
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds data referenced by the linked buffer pointed to by @p aBuffer to the
|
||||
* send buffer.
|
||||
*
|
||||
* Upon a successful call to this function, the linked buffer and data it
|
||||
* references are owned by the TCP stack; they should not be modified by the
|
||||
* application until a "send done" callback returns ownership of those objects
|
||||
* to the application. It is acceptable to call this function to add another
|
||||
* linked buffer to the send queue, even if the "send done" callback for a
|
||||
* previous invocation of this function has not yet fired.
|
||||
*
|
||||
* Note that @p aBuffer should not be chained; its mNext field should be
|
||||
* NULL. If additional data will be added right after this call, then the
|
||||
* OT_TCP_SEND_MORE_TO_COME flag should be used as a hint to the TCP
|
||||
* implementation.
|
||||
*
|
||||
* @param[in] aEndpoint A pointer to the TCP endpoint structure representing the TCP endpoint on which to send data.
|
||||
* @param[in] aBuffer A pointer to the linked buffer chain referencing data to add to the send buffer.
|
||||
* @param[in] aFlags Flags specifying options for this operation (see enumeration above).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added data to the send buffer.
|
||||
* @retval OT_ERROR_FAILED Failed to add data to the send buffer.
|
||||
*/
|
||||
otError otTcpSendByReference(otTcpEndpoint *aEndpoint, otLinkedBuffer *aBuffer, uint32_t aFlags);
|
||||
|
||||
/**
|
||||
* Adds data to the send buffer by extending the length of the final
|
||||
* otLinkedBuffer in the send buffer by the specified amount.
|
||||
*
|
||||
* If the send buffer is empty, then the operation fails.
|
||||
*
|
||||
* @param[in] aEndpoint A pointer to the TCP endpoint structure representing the TCP endpoint on which to send data.
|
||||
* @param[in] aNumBytes The number of bytes by which to extend the length of the final linked buffer.
|
||||
* @param[in] aFlags Flags specifying options for this operation (see enumeration above).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added data to the send buffer.
|
||||
* @retval OT_ERROR_FAILED Failed to add data to the send buffer.
|
||||
*/
|
||||
otError otTcpSendByExtension(otTcpEndpoint *aEndpoint, size_t aNumBytes, uint32_t aFlags);
|
||||
|
||||
/**
|
||||
* Provides the application with a linked buffer chain referencing data
|
||||
* currently in the TCP receive buffer.
|
||||
*
|
||||
* The linked buffer chain is valid until the "receive ready" callback is next
|
||||
* invoked, or until the next call to otTcpReceiveContiguify() or
|
||||
* otTcpCommitReceive().
|
||||
*
|
||||
* @param[in] aEndpoint A pointer to the TCP endpoint structure representing the TCP endpoint on which to receive
|
||||
* data.
|
||||
* @param[out] aBuffer A pointer to the linked buffer chain referencing data currently in the receive buffer.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully completed the operation.
|
||||
* @retval OT_ERROR_FAILED Failed to complete the operation.
|
||||
*/
|
||||
otError otTcpReceiveByReference(otTcpEndpoint *aEndpoint, const otLinkedBuffer **aBuffer);
|
||||
|
||||
/**
|
||||
* Reorganizes the receive buffer to be entirely contiguous in memory.
|
||||
*
|
||||
* This is optional; an application can simply traverse the linked buffer
|
||||
* chain obtained by calling @p otTcpReceiveByReference. Some
|
||||
* applications may wish to call this function to make the receive buffer
|
||||
* contiguous to simplify their data processing, but this comes at the expense
|
||||
* of CPU time to reorganize the data in the receive buffer.
|
||||
*
|
||||
* @param[in] aEndpoint A pointer to the TCP endpoint whose receive buffer to reorganize.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully completed the operation.
|
||||
* @retval OT_ERROR_FAILED Failed to complete the operation.
|
||||
*/
|
||||
otError otTcpReceiveContiguify(otTcpEndpoint *aEndpoint);
|
||||
|
||||
/**
|
||||
* Informs the TCP stack that the application has finished processing
|
||||
* @p aNumBytes bytes of data at the start of the receive buffer and that the
|
||||
* TCP stack need not continue maintaining those bytes in the receive buffer.
|
||||
*
|
||||
* @param[in] aEndpoint A pointer to the TCP endpoint structure representing the TCP endpoint on which to receive
|
||||
* data.
|
||||
* @param[in] aNumBytes The number of bytes consumed.
|
||||
* @param[in] aFlags Flags specifying options for this operation (none yet).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully completed the receive operation.
|
||||
* @retval OT_ERROR_FAILED Failed to complete the receive operation.
|
||||
*/
|
||||
otError otTcpCommitReceive(otTcpEndpoint *aEndpoint, size_t aNumBytes, uint32_t aFlags);
|
||||
|
||||
/**
|
||||
* Informs the connection peer that this TCP endpoint will not send more data.
|
||||
*
|
||||
* This should be used when the application has no more data to send to the
|
||||
* connection peer. For this connection, future reads on the connection peer
|
||||
* will result in the "end of stream" condition, and future writes on this
|
||||
* connection endpoint will fail.
|
||||
*
|
||||
* The "end of stream" condition only applies after any data previously
|
||||
* provided to the TCP stack to send out has been received by the connection
|
||||
* peer.
|
||||
*
|
||||
* @param[in] aEndpoint A pointer to the TCP endpoint structure representing the TCP endpoint to shut down.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully queued the "end of stream" condition for transmission.
|
||||
* @retval OT_ERROR_FAILED Failed to queue the "end of stream" condition for transmission.
|
||||
*/
|
||||
otError otTcpSendEndOfStream(otTcpEndpoint *aEndpoint);
|
||||
|
||||
/**
|
||||
* Forcibly ends the TCP connection associated with this TCP endpoint.
|
||||
*
|
||||
* This immediately makes the TCP endpoint free for use for another connection
|
||||
* and empties the send and receive buffers, transferring ownership of any data
|
||||
* provided by the application in otTcpSendByReference() and
|
||||
* otTcpSendByExtension() calls back to the application. The TCP endpoint's
|
||||
* callbacks and memory for the receive buffer remain associated with the
|
||||
* TCP endpoint.
|
||||
*
|
||||
* @param[in] aEndpoint A pointer to the TCP endpoint structure representing the TCP endpoint to abort.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully aborted the TCP endpoint's connection.
|
||||
* @retval OT_ERROR_FAILED Failed to abort the TCP endpoint's connection.
|
||||
*/
|
||||
otError otTcpAbort(otTcpEndpoint *aEndpoint);
|
||||
|
||||
/**
|
||||
* Deinitializes this TCP endpoint.
|
||||
*
|
||||
* This means that OpenThread no longer keeps track of this TCP endpoint and
|
||||
* deallocates all resources it has internally allocated for this TCP endpoint.
|
||||
* The application can reuse the memory backing the TCP endpoint as it sees fit.
|
||||
*
|
||||
* If it corresponds to a live TCP connection, the connection is terminated
|
||||
* unceremoniously (as in otTcpAbort()). All resources the application has
|
||||
* provided for this TCP endpoint (linked buffers for the send buffer, memory
|
||||
* for the receive buffer, the @p aEndpoint structure itself, etc.) are
|
||||
* immediately returned to the application.
|
||||
*
|
||||
* @param[in] aEndpoint A pointer to the TCP endpoint structure to deinitialize.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully deinitialized the TCP endpoint.
|
||||
* @retval OT_ERROR_FAILED Failed to deinitialize the TCP endpoint.
|
||||
*/
|
||||
otError otTcpEndpointDeinitialize(otTcpEndpoint *aEndpoint);
|
||||
|
||||
struct otTcpListener;
|
||||
typedef struct otTcpListener otTcpListener;
|
||||
|
||||
/**
|
||||
* Defines incoming connection actions.
|
||||
*
|
||||
* This is used in otTcpAcceptReady() callback.
|
||||
*/
|
||||
typedef enum otTcpIncomingConnectionAction
|
||||
{
|
||||
OT_TCP_INCOMING_CONNECTION_ACTION_ACCEPT, ///< Accept the incoming connection.
|
||||
OT_TCP_INCOMING_CONNECTION_ACTION_DEFER, ///< Defer (silently ignore) the incoming connection.
|
||||
OT_TCP_INCOMING_CONNECTION_ACTION_REFUSE, ///< Refuse the incoming connection.
|
||||
} otTcpIncomingConnectionAction;
|
||||
|
||||
/**
|
||||
* This callback indicates that an incoming connection that matches this TCP
|
||||
* listener has arrived.
|
||||
*
|
||||
* The typical response is for the application to accept the incoming
|
||||
* connection. It does so by populating @p aAcceptInto with a pointer to the
|
||||
* otTcpEndpoint into which to accept the incoming connection. This
|
||||
* otTcpEndpoint must already be initialized using otTcpEndpointInitialize().
|
||||
* Then, the application returns OT_TCP_INCOMING_CONNECTION_ACTION_ACCEPT.
|
||||
*
|
||||
* Alternatively, the application can decline to accept the incoming
|
||||
* connection. There are two ways for the application to do this. First, if the
|
||||
* application returns OT_TCP_INCOMING_CONNECTION_ACTION_DEFER, then OpenThread
|
||||
* silently ignores the connection establishment request; the connection peer
|
||||
* will likely retransmit the request, at which point the callback will be
|
||||
* called again. This is valuable if resources are not presently available to
|
||||
* accept the connection, but they may be available when the connection peer
|
||||
* retransmits its connection establishment attempt. Second, if the application
|
||||
* returns OT_TCP_INCOMING_CONNECTION_ACTION_REFUSE, then OpenThread sends a
|
||||
* "connection refused" message to the host that attempted to establish a
|
||||
* connection. If the application declines the incoming connection, it is not
|
||||
* required to populate @p aAcceptInto.
|
||||
*
|
||||
* @param[in] aListener The TCP listener that matches the incoming connection.
|
||||
* @param[in] aPeer The host and port from which the incoming connection originates.
|
||||
* @param[out] aAcceptInto The TCP endpoint into which to accept the incoming connection.
|
||||
*
|
||||
* @returns Description of how to handle the incoming connection.
|
||||
*/
|
||||
typedef otTcpIncomingConnectionAction (*otTcpAcceptReady)(otTcpListener *aListener,
|
||||
const otSockAddr *aPeer,
|
||||
otTcpEndpoint **aAcceptInto);
|
||||
|
||||
/**
|
||||
* This callback indicates that the TCP connection is now ready for two-way
|
||||
* communication.
|
||||
*
|
||||
* In the case of TCP Fast Open, this may be before the TCP
|
||||
* connection handshake has actually completed. The application is provided
|
||||
* with the context pointers both for the TCP listener that accepted the
|
||||
* connection and the TCP endpoint into which it was accepted. The provided
|
||||
* context is the one associated with the TCP listener.
|
||||
*
|
||||
* @param[in] aListener The TCP listener that matches the incoming connection.
|
||||
* @param[in] aEndpoint The TCP endpoint into which the incoming connection was accepted.
|
||||
* @param[in] aPeer the host and port from which the incoming connection originated.
|
||||
*/
|
||||
typedef void (*otTcpAcceptDone)(otTcpListener *aListener, otTcpEndpoint *aEndpoint, const otSockAddr *aPeer);
|
||||
|
||||
/**
|
||||
* OT_TCP_LISTENER_TCB_SIZE_BASE and OT_TCP_LISTENER_TCB_NUM_POINTERS are
|
||||
* chosen such that the mTcbListener field of otTcpListener has the same size
|
||||
* as struct tcpcb_listen in TCPlp. This is necessary because the mTcbListen
|
||||
* field, though opaque in its declaration, is treated as struct tcpcb in the
|
||||
* TCP implementation.
|
||||
*/
|
||||
#define OT_TCP_LISTENER_TCB_SIZE_BASE 16
|
||||
#define OT_TCP_LISTENER_TCB_NUM_PTR 3
|
||||
|
||||
/**
|
||||
* Represents a TCP listener.
|
||||
*
|
||||
* A TCP listener is used to listen for and accept incoming TCP connections.
|
||||
*
|
||||
* The application should not inspect the fields of this structure directly; it
|
||||
* should only interact with it via the TCP API functions whose signatures are
|
||||
* provided in this file.
|
||||
*/
|
||||
struct otTcpListener
|
||||
{
|
||||
union
|
||||
{
|
||||
uint8_t mSize[OT_TCP_LISTENER_TCB_SIZE_BASE + OT_TCP_LISTENER_TCB_NUM_PTR * sizeof(void *)];
|
||||
void *mAlign;
|
||||
} mTcbListen;
|
||||
|
||||
struct otTcpListener *mNext; ///< A pointer to the next TCP listener (internal use only)
|
||||
void *mContext; ///< A pointer to application-specific context
|
||||
|
||||
otTcpAcceptReady mAcceptReadyCallback; ///< "Accept ready" callback function
|
||||
otTcpAcceptDone mAcceptDoneCallback; ///< "Accept done" callback function
|
||||
};
|
||||
|
||||
/**
|
||||
* Contains arguments to the otTcpListenerInitialize() function.
|
||||
*/
|
||||
typedef struct otTcpListenerInitializeArgs
|
||||
{
|
||||
void *mContext; ///< Pointer to application-specific context
|
||||
|
||||
otTcpAcceptReady mAcceptReadyCallback; ///< "Accept ready" callback function
|
||||
otTcpAcceptDone mAcceptDoneCallback; ///< "Accept done" callback function
|
||||
} otTcpListenerInitializeArgs;
|
||||
|
||||
/**
|
||||
* Initializes a TCP listener.
|
||||
*
|
||||
* Calling this function causes OpenThread to keep track of the TCP listener
|
||||
* and store and retrieve TCP data inside @p aListener. The application should
|
||||
* refrain from directly accessing or modifying the fields in @p aListener. If
|
||||
* the application needs to reclaim the memory backing @p aListener, it should
|
||||
* call otTcpListenerDeinitialize().
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aListener A pointer to a TCP listener structure.
|
||||
* @param[in] aArgs A pointer to a structure of arguments.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully opened the TCP listener.
|
||||
* @retval OT_ERROR_FAILED Failed to open the TCP listener.
|
||||
*/
|
||||
otError otTcpListenerInitialize(otInstance *aInstance,
|
||||
otTcpListener *aListener,
|
||||
const otTcpListenerInitializeArgs *aArgs);
|
||||
|
||||
/**
|
||||
* Obtains the otInstance that was associated with @p aListener upon
|
||||
* initialization.
|
||||
*
|
||||
* @param[in] aListener The TCP listener whose instance to obtain.
|
||||
*
|
||||
* @returns The otInstance pointer associated with @p aListener.
|
||||
*/
|
||||
otInstance *otTcpListenerGetInstance(otTcpListener *aListener);
|
||||
|
||||
/**
|
||||
* Obtains the context pointer that was associated with @p aListener upon
|
||||
* initialization.
|
||||
*
|
||||
* @param[in] aListener The TCP listener whose context to obtain.
|
||||
*
|
||||
* @returns The context pointer associated with @p aListener.
|
||||
*/
|
||||
void *otTcpListenerGetContext(otTcpListener *aListener);
|
||||
|
||||
/**
|
||||
* Causes incoming TCP connections that match the specified IP address and port
|
||||
* to trigger this TCP listener's callbacks.
|
||||
*
|
||||
* @param[in] aListener A pointer to the TCP listener structure that should begin listening.
|
||||
* @param[in] aSockName The address and port on which to listen for incoming connections.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully initiated listening on the TCP listener.
|
||||
* @retval OT_ERROR_FAILED Failed to initiate listening on the TCP listener.
|
||||
*/
|
||||
otError otTcpListen(otTcpListener *aListener, const otSockAddr *aSockName);
|
||||
|
||||
/**
|
||||
* Causes this TCP listener to stop listening for incoming connections.
|
||||
*
|
||||
* @param[in] aListener A pointer to the TCP listener structure that should stop listening.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully stopped listening on the TCP listener.
|
||||
* @retval OT_ERROR_FAILED Failed to stop listening on the TCP listener.
|
||||
*/
|
||||
otError otTcpStopListening(otTcpListener *aListener);
|
||||
|
||||
/**
|
||||
* Deinitializes this TCP listener.
|
||||
*
|
||||
* This means that OpenThread no longer keeps track of this TCP listener and
|
||||
* deallocates all resources it has internally allocated for this TCP listener.
|
||||
* The application can reuse the memory backing the TCP listener as it sees
|
||||
* fit.
|
||||
*
|
||||
* If the TCP listener is currently listening, it stops listening.
|
||||
*
|
||||
* @param[in] aListener A pointer to the TCP listener structure to deinitialize.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully deinitialized the TCP listener.
|
||||
* @retval OT_ERROR_FAILED Failed to deinitialize the TCP listener.
|
||||
*/
|
||||
otError otTcpListenerDeinitialize(otTcpListener *aListener);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_TCP_H_
|
||||
253
Libs/util/third_party/openthread/include/openthread/tcp_ext.h
vendored
Normal file
253
Libs/util/third_party/openthread/include/openthread/tcp_ext.h
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
* Copyright (c) 2022, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines extensions to the OpenThread TCP API.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_TCP_EXT_H_
|
||||
#define OPENTHREAD_TCP_EXT_H_
|
||||
|
||||
#include <openthread/tcp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-tcp-ext
|
||||
*
|
||||
* @brief
|
||||
* This module includes easy-to-use abstractions on top of the base TCP API.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a circular send buffer for use with a TCP endpoint.
|
||||
*
|
||||
* Using a circular send buffer is optional. Applications can use a TCP
|
||||
* endpoint to send data by managing otLinkedBuffers directly. However, some
|
||||
* applications may find it more convenient to have a circular send buffer;
|
||||
* such applications can call otTcpCircularSendBufferWrite() to "attach" a
|
||||
* circular send buffer to a TCP endpoint and send out data on that TCP
|
||||
* endpoint, relying on the circular send buffer to manage the underlying
|
||||
* otLinkedBuffers.
|
||||
*
|
||||
* otTcpCircularSendBuffer is implemented on top of the otLinkedBuffer-based
|
||||
* API provided by an otTcpEndpoint. Once attached to an otTcpEndpoint, an
|
||||
* otTcpCircularSendBuffer performs all the work of managing otLinkedBuffers
|
||||
* for the connection. This means that, once an otTcpCircularSendBuffer is
|
||||
* attached to an otTcpEndpoint, the application should not call
|
||||
* otTcpSendByReference() or otTcpSendByExtension() on that otTcpEndpoint.
|
||||
* Instead, the application should use otTcpCircularSendBufferWrite() to add
|
||||
* data to the send buffer.
|
||||
*
|
||||
* The otTcpForwardProgress() callback is the intended way for users to learn
|
||||
* when space becomes available in the circular send buffer. On an
|
||||
* otTcpEndpoint to which an otTcpCircularSendBuffer is attached, the
|
||||
* application MUST install an otTcpForwardProgress() callback and call
|
||||
* otTcpCircularSendBufferHandleForwardProgress() on the attached
|
||||
* otTcpCircularSendBuffer at the start of the callback function. It is
|
||||
* recommended that the user NOT install an otTcpSendDone() callback, as all
|
||||
* management of otLinkedBuffers is handled by the circular send buffer.
|
||||
*
|
||||
* The application should not inspect the fields of this structure directly; it
|
||||
* should only interact with it via the TCP Circular Send Buffer API functions
|
||||
* whose signature are provided in this file.
|
||||
*/
|
||||
typedef struct otTcpCircularSendBuffer
|
||||
{
|
||||
uint8_t *mDataBuffer; ///< Pointer to data in the circular send buffer
|
||||
size_t mCapacity; ///< Length of the circular send buffer
|
||||
size_t mStartIndex; ///< Index of the first valid byte in the send buffer
|
||||
size_t mCapacityUsed; ///< Number of bytes stored in the send buffer
|
||||
|
||||
otLinkedBuffer mSendLinks[2];
|
||||
uint8_t mFirstSendLinkIndex;
|
||||
} otTcpCircularSendBuffer;
|
||||
|
||||
/**
|
||||
* Initializes a TCP circular send buffer.
|
||||
*
|
||||
* @param[in] aSendBuffer A pointer to the TCP circular send buffer to initialize.
|
||||
* @param[in] aDataBuffer A pointer to memory to use to store data in the TCP circular send buffer.
|
||||
* @param[in] aCapacity The capacity, in bytes, of the TCP circular send buffer, which must equal the size of
|
||||
* the memory pointed to by @p aDataBuffer .
|
||||
*/
|
||||
void otTcpCircularSendBufferInitialize(otTcpCircularSendBuffer *aSendBuffer, void *aDataBuffer, size_t aCapacity);
|
||||
|
||||
/**
|
||||
* Defines flags passed to @p otTcpCircularSendBufferWrite.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
OT_TCP_CIRCULAR_SEND_BUFFER_WRITE_MORE_TO_COME = 1 << 0,
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends out data on a TCP endpoint, using the provided TCP circular send
|
||||
* buffer to manage buffering.
|
||||
*
|
||||
* Once this function is called, @p aSendBuffer and @p aEndpoint are considered
|
||||
* "attached" to each other. While they are attached, ALL send operations for
|
||||
* @p aEndpoint must be made using @p aSendBuffer and ALL operations on
|
||||
* @p aSendBuffer must be associated with @p aEndpoint .
|
||||
*
|
||||
* The only way to "detach" a TCP circular send buffer and a TCP endpoint is to
|
||||
* wait for the send buffer to become completely empty. This can happen in two
|
||||
* ways: (1) all data in the send buffer is sent and acknowledged in the normal
|
||||
* course of TCP protocol operation, or (2) the connection is terminated.
|
||||
*
|
||||
* The recommended usage pattern is to use a single TCP circular send buffer
|
||||
* with a TCP endpoint, and to send data on that TCP endpoint only via its
|
||||
* associated TCP circular buffer. This recommended usage pattern sidesteps the
|
||||
* issues described above by always using a TCP endpoint and TCP circular send
|
||||
* buffer together.
|
||||
*
|
||||
* If the circular send buffer reaches capacity, only a prefix of the provided
|
||||
* data is copied into the circular send buffer.
|
||||
*
|
||||
* @param[in] aEndpoint The TCP endpoint on which to send out data.
|
||||
* @param[in] aSendBuffer The TCP circular send buffer into which to copy data.
|
||||
* @param[in] aData A pointer to data to copy into the TCP circular send buffer.
|
||||
* @param[in] aLength The length of the data pointed to by @p aData to copy into the TCP circular send buffer.
|
||||
* @param[out] aWritten Populated with the amount of data copied into the send buffer, which might be less than
|
||||
* @p aLength if the send buffer reaches capacity.
|
||||
* @param[in] aFlags Flags specifying options for this operation (see enumeration above).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully copied data into the send buffer and sent it on the TCP endpoint.
|
||||
* @retval OT_ERROR_FAILED Failed to send out data on the TCP endpoint.
|
||||
*/
|
||||
otError otTcpCircularSendBufferWrite(otTcpEndpoint *aEndpoint,
|
||||
otTcpCircularSendBuffer *aSendBuffer,
|
||||
const void *aData,
|
||||
size_t aLength,
|
||||
size_t *aWritten,
|
||||
uint32_t aFlags);
|
||||
|
||||
/**
|
||||
* Performs circular-send-buffer-specific handling in the otTcpForwardProgress
|
||||
* callback.
|
||||
*
|
||||
* The application is expected to install an otTcpForwardProgress() callback on
|
||||
* the otTcpEndpoint, and call this function at the start of the callback
|
||||
* function for circular-send-buffer-specific processing.
|
||||
*
|
||||
* In the callback function, the application can determine the amount of free
|
||||
* space in the circular send buffer by calling
|
||||
* otTcpCircularSendBufferFreeSpace(), or by comparing @p aInSendBuffer with
|
||||
* the send buffer's capacity, chosen by the user when calling
|
||||
* otTcpCircularSendBufferInitialize().
|
||||
*
|
||||
* @param[in] aSendBuffer A pointer to the TCP circular send buffer for the endpoint for which
|
||||
* otTcpForwardProgress() was invoked.
|
||||
* @param[in] aInSendBuffer Value of @p aInSendBuffer passed to the otTcpForwardProgress() callback.
|
||||
*/
|
||||
void otTcpCircularSendBufferHandleForwardProgress(otTcpCircularSendBuffer *aSendBuffer, size_t aInSendBuffer);
|
||||
|
||||
/**
|
||||
* Returns the amount of free space in the TCP circular send buffer.
|
||||
*
|
||||
* This operation will always succeed.
|
||||
*
|
||||
* @param[in] aSendBuffer A pointer to the TCP circular send buffer whose amount of free space to return.
|
||||
*
|
||||
* @returns The amount of free space in the send buffer.
|
||||
*/
|
||||
size_t otTcpCircularSendBufferGetFreeSpace(const otTcpCircularSendBuffer *aSendBuffer);
|
||||
|
||||
/**
|
||||
* Forcibly discards all data in the circular send buffer.
|
||||
*
|
||||
* The application is expected to call this function when a TCP connection is
|
||||
* terminated unceremoniously (e.g., if the application calls
|
||||
* otTcpEndpointAbort() or is informed of a reset connection via the
|
||||
* otTcpConnectionLost() callback).
|
||||
*
|
||||
* Calling this function on a nonempty TCP circular send buffer attached to a
|
||||
* TCP endpoint results in undefined behavior.
|
||||
*
|
||||
* @param[in] aSendBuffer The TCP circular send buffer whose data to discard.
|
||||
*/
|
||||
void otTcpCircularSendBufferForceDiscardAll(otTcpCircularSendBuffer *aSendBuffer);
|
||||
|
||||
/**
|
||||
* Deinitializes a TCP circular send buffer, detaching it if attached.
|
||||
*
|
||||
* If the TCP circular send buffer is not empty, then this operation will fail.
|
||||
*
|
||||
* @param[in] aSendBuffer The TCP circular send buffer to deinitialize.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully deinitialize the TCP circular send buffer.
|
||||
* @retval OT_ERROR_BUSY Circular buffer contains data and cannot be deinitialized.
|
||||
*/
|
||||
otError otTcpCircularSendBufferDeinitialize(otTcpCircularSendBuffer *aSendBuffer);
|
||||
|
||||
/**
|
||||
* Context structure to use with mbedtls_ssl_set_bio.
|
||||
*/
|
||||
typedef struct otTcpEndpointAndCircularSendBuffer
|
||||
{
|
||||
otTcpEndpoint *mEndpoint;
|
||||
otTcpCircularSendBuffer *mSendBuffer;
|
||||
} otTcpEndpointAndCircularSendBuffer;
|
||||
|
||||
/**
|
||||
* Non-blocking send callback to pass to mbedtls_ssl_set_bio.
|
||||
*
|
||||
* @param[in] aCtx A pointer to an otTcpEndpointAndCircularSendBuffer.
|
||||
* @param[in] aBuf The data to add to the send buffer.
|
||||
* @param[in] aLen The amount of data to add to the send buffer.
|
||||
*
|
||||
* @returns The number of bytes sent, or an mbedtls error code.
|
||||
*/
|
||||
int otTcpMbedTlsSslSendCallback(void *aCtx, const unsigned char *aBuf, size_t aLen);
|
||||
|
||||
/**
|
||||
* Non-blocking receive callback to pass to mbedtls_ssl_set_bio.
|
||||
*
|
||||
* @param[in] aCtx A pointer to an otTcpEndpointAndCircularSendBuffer.
|
||||
* @param[out] aBuf The buffer into which to receive data.
|
||||
* @param[in] aLen The maximum amount of data that can be received.
|
||||
*
|
||||
* @returns The number of bytes received, or an mbedtls error code.
|
||||
*/
|
||||
int otTcpMbedTlsSslRecvCallback(void *aCtx, unsigned char *aBuf, size_t aLen);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_TCP_EXT_H_
|
||||
1166
Libs/util/third_party/openthread/include/openthread/thread.h
vendored
Normal file
1166
Libs/util/third_party/openthread/include/openthread/thread.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
913
Libs/util/third_party/openthread/include/openthread/thread_ftd.h
vendored
Normal file
913
Libs/util/third_party/openthread/include/openthread/thread_ftd.h
vendored
Normal file
@@ -0,0 +1,913 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the OpenThread Thread API (FTD only).
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_THREAD_FTD_H_
|
||||
#define OPENTHREAD_THREAD_FTD_H_
|
||||
|
||||
#include <openthread/link.h>
|
||||
#include <openthread/message.h>
|
||||
#include <openthread/thread.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup api-thread-router
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Holds diagnostic information for a Thread Child
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
otExtAddress mExtAddress; ///< IEEE 802.15.4 Extended Address
|
||||
uint32_t mTimeout; ///< Timeout
|
||||
uint32_t mAge; ///< Seconds since last heard
|
||||
uint64_t mConnectionTime; ///< Seconds since attach (requires `OPENTHREAD_CONFIG_UPTIME_ENABLE`)
|
||||
uint16_t mRloc16; ///< RLOC16
|
||||
uint16_t mChildId; ///< Child ID
|
||||
uint8_t mNetworkDataVersion; ///< Network Data Version
|
||||
uint8_t mLinkQualityIn; ///< Link Quality In
|
||||
int8_t mAverageRssi; ///< Average RSSI
|
||||
int8_t mLastRssi; ///< Last observed RSSI
|
||||
uint16_t mFrameErrorRate; ///< Frame error rate (0xffff->100%). Requires error tracking feature.
|
||||
uint16_t mMessageErrorRate; ///< (IPv6) msg error rate (0xffff->100%). Requires error tracking feature.
|
||||
uint16_t mQueuedMessageCnt; ///< Number of queued messages for the child.
|
||||
uint16_t mSupervisionInterval; ///< Supervision interval (in seconds).
|
||||
uint8_t mVersion; ///< MLE version
|
||||
bool mRxOnWhenIdle : 1; ///< rx-on-when-idle
|
||||
bool mFullThreadDevice : 1; ///< Full Thread Device
|
||||
bool mFullNetworkData : 1; ///< Full Network Data
|
||||
bool mIsStateRestoring : 1; ///< Is in restoring state
|
||||
bool mIsCslSynced : 1; ///< Is child CSL synchronized
|
||||
} otChildInfo;
|
||||
|
||||
#define OT_CHILD_IP6_ADDRESS_ITERATOR_INIT 0 ///< Initializer for otChildIP6AddressIterator
|
||||
|
||||
typedef uint16_t otChildIp6AddressIterator; ///< Used to iterate through IPv6 addresses of a Thread Child entry.
|
||||
|
||||
/**
|
||||
* Defines the EID cache entry state.
|
||||
*/
|
||||
typedef enum otCacheEntryState
|
||||
{
|
||||
OT_CACHE_ENTRY_STATE_CACHED = 0, // Entry is cached and in-use.
|
||||
OT_CACHE_ENTRY_STATE_SNOOPED = 1, // Entry is created by snoop optimization (inspection of received msg).
|
||||
OT_CACHE_ENTRY_STATE_QUERY = 2, // Entry represents an ongoing query for the EID.
|
||||
OT_CACHE_ENTRY_STATE_RETRY_QUERY = 3, // Entry is in retry wait mode (a prior query did not get a response).
|
||||
} otCacheEntryState;
|
||||
|
||||
/**
|
||||
* Represents an EID cache entry.
|
||||
*/
|
||||
typedef struct otCacheEntryInfo
|
||||
{
|
||||
otIp6Address mTarget; ///< Target EID
|
||||
otShortAddress mRloc16; ///< RLOC16
|
||||
otCacheEntryState mState; ///< Entry state
|
||||
bool mCanEvict : 1; ///< Indicates whether the entry can be evicted.
|
||||
bool mRampDown : 1; ///< Whether in ramp-down mode while in `OT_CACHE_ENTRY_STATE_RETRY_QUERY`.
|
||||
bool mValidLastTrans : 1; ///< Indicates whether last transaction time and ML-EID are valid.
|
||||
uint32_t mLastTransTime; ///< Last transaction time (applicable in cached state).
|
||||
otIp6Address mMeshLocalEid; ///< Mesh Local EID (applicable if entry in cached state).
|
||||
uint16_t mTimeout; ///< Timeout in seconds (applicable if in snooped/query/retry-query states).
|
||||
uint16_t mRetryDelay; ///< Retry delay in seconds (applicable if in query-retry state).
|
||||
} otCacheEntryInfo;
|
||||
|
||||
/**
|
||||
* Represents an iterator used for iterating through the EID cache table entries.
|
||||
*
|
||||
* To initialize the iterator and start from the first entry in the cache table, set all its fields in the structure to
|
||||
* zero (e.g., `memset` the iterator to zero).
|
||||
*/
|
||||
typedef struct otCacheEntryIterator
|
||||
{
|
||||
const void *mData[2]; ///< Opaque data used by the core implementation. Should not be changed by user.
|
||||
} otCacheEntryIterator;
|
||||
|
||||
/**
|
||||
* Gets the maximum number of children currently allowed.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The maximum number of children currently allowed.
|
||||
*
|
||||
* @sa otThreadSetMaxAllowedChildren
|
||||
*/
|
||||
uint16_t otThreadGetMaxAllowedChildren(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the maximum number of children currently allowed.
|
||||
*
|
||||
* This parameter can only be set when Thread protocol operation has been stopped.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMaxChildren The maximum allowed children.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the max.
|
||||
* @retval OT_ERROR_INVALID_ARGS If @p aMaxChildren is not in the range [1, OPENTHREAD_CONFIG_MLE_MAX_CHILDREN].
|
||||
* @retval OT_ERROR_INVALID_STATE If Thread isn't stopped.
|
||||
*
|
||||
* @sa otThreadGetMaxAllowedChildren
|
||||
*/
|
||||
otError otThreadSetMaxAllowedChildren(otInstance *aInstance, uint16_t aMaxChildren);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the device is router-eligible.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval TRUE If device is router-eligible.
|
||||
* @retval FALSE If device is not router-eligible.
|
||||
*/
|
||||
bool otThreadIsRouterEligible(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets whether or not the device is router-eligible.
|
||||
*
|
||||
* If @p aEligible is false and the device is currently operating as a router, this call will cause the device to
|
||||
* detach and attempt to reattach as a child.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEligible TRUE to configure the device as router-eligible, FALSE otherwise.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the router-eligible configuration.
|
||||
* @retval OT_ERROR_NOT_CAPABLE The device is not capable of becoming a router.
|
||||
*/
|
||||
otError otThreadSetRouterEligible(otInstance *aInstance, bool aEligible);
|
||||
|
||||
/**
|
||||
* Set the preferred Router Id.
|
||||
*
|
||||
* Upon becoming a router/leader the node attempts to use this Router Id. If the preferred Router Id is not set or if
|
||||
* it can not be used, a randomly generated router id is picked. This property can be set only when the device role is
|
||||
* either detached or disabled.
|
||||
*
|
||||
* @note This API is reserved for testing and demo purposes only. Changing settings with
|
||||
* this API will render a production application non-compliant with the Thread Specification.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aRouterId The preferred Router Id.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the preferred Router Id.
|
||||
* @retval OT_ERROR_INVALID_STATE Could not set (role is not detached or disabled)
|
||||
*/
|
||||
otError otThreadSetPreferredRouterId(otInstance *aInstance, uint8_t aRouterId);
|
||||
|
||||
/**
|
||||
* Represents the power supply property on a device.
|
||||
*
|
||||
* This is used as a property in `otDeviceProperties` to calculate the leader weight.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_POWER_SUPPLY_BATTERY = 0, ///< Battery powered.
|
||||
OT_POWER_SUPPLY_EXTERNAL = 1, ///< Externally powered (mains-powered).
|
||||
OT_POWER_SUPPLY_EXTERNAL_STABLE = 2, ///< Stable external power with a battery backup or UPS.
|
||||
OT_POWER_SUPPLY_EXTERNAL_UNSTABLE = 3, ///< Potentially unstable ext power (e.g. light bulb powered via a switch).
|
||||
} otPowerSupply;
|
||||
|
||||
/**
|
||||
* Represents the device properties which are used for calculating the local leader weight on a
|
||||
* device.
|
||||
*
|
||||
* The parameters are set based on device's capability, whether acting as border router, its power supply config, etc.
|
||||
*
|
||||
* `mIsUnstable` indicates operational stability of device and is determined via a vendor specific mechanism. It can
|
||||
* include the following cases:
|
||||
* - Device internally detects that it loses external power supply more often than usual. What is usual is
|
||||
* determined by the vendor.
|
||||
* - Device internally detects that it reboots more often than usual. What is usual is determined by the vendor.
|
||||
*/
|
||||
typedef struct otDeviceProperties
|
||||
{
|
||||
otPowerSupply mPowerSupply; ///< Power supply config.
|
||||
bool mIsBorderRouter : 1; ///< Whether device is a border router.
|
||||
bool mSupportsCcm : 1; ///< Whether device supports CCM (can act as a CCM border router).
|
||||
bool mIsUnstable : 1; ///< Operational stability of device (vendor specific).
|
||||
int8_t mLeaderWeightAdjustment; ///< Weight adjustment. Should be -16 to +16 (clamped otherwise).
|
||||
} otDeviceProperties;
|
||||
|
||||
/**
|
||||
* Get the current device properties.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_MLE_DEVICE_PROPERTY_LEADER_WEIGHT_ENABLE`.
|
||||
*
|
||||
* @returns The device properties `otDeviceProperties`.
|
||||
*/
|
||||
const otDeviceProperties *otThreadGetDeviceProperties(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the device properties which are then used to determine and set the Leader Weight.
|
||||
*
|
||||
* Requires `OPENTHREAD_CONFIG_MLE_DEVICE_PROPERTY_LEADER_WEIGHT_ENABLE`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDeviceProperties The device properties.
|
||||
*/
|
||||
void otThreadSetDeviceProperties(otInstance *aInstance, const otDeviceProperties *aDeviceProperties);
|
||||
|
||||
/**
|
||||
* Gets the Thread Leader Weight used when operating in the Leader role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The Thread Leader Weight value.
|
||||
*
|
||||
* @sa otThreadSetLeaderWeight
|
||||
* @sa otThreadSetDeviceProperties
|
||||
*/
|
||||
uint8_t otThreadGetLocalLeaderWeight(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the Thread Leader Weight used when operating in the Leader role.
|
||||
*
|
||||
* Directly sets the Leader Weight to the new value, replacing its previous value (which may have been
|
||||
* determined from the current `otDeviceProperties`).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aWeight The Thread Leader Weight value.
|
||||
*
|
||||
* @sa otThreadGetLeaderWeight
|
||||
*/
|
||||
void otThreadSetLocalLeaderWeight(otInstance *aInstance, uint8_t aWeight);
|
||||
|
||||
/**
|
||||
* Get the preferred Thread Leader Partition Id used when operating in the Leader role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The Thread Leader Partition Id value.
|
||||
*/
|
||||
uint32_t otThreadGetPreferredLeaderPartitionId(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the preferred Thread Leader Partition Id used when operating in the Leader role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPartitionId The Thread Leader Partition Id value.
|
||||
*/
|
||||
void otThreadSetPreferredLeaderPartitionId(otInstance *aInstance, uint32_t aPartitionId);
|
||||
|
||||
/**
|
||||
* Gets the Joiner UDP Port.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The Joiner UDP Port number.
|
||||
*
|
||||
* @sa otThreadSetJoinerUdpPort
|
||||
*/
|
||||
uint16_t otThreadGetJoinerUdpPort(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets the Joiner UDP Port.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aJoinerUdpPort The Joiner UDP Port number.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the Joiner UDP Port.
|
||||
*
|
||||
* @sa otThreadGetJoinerUdpPort
|
||||
*/
|
||||
otError otThreadSetJoinerUdpPort(otInstance *aInstance, uint16_t aJoinerUdpPort);
|
||||
|
||||
/**
|
||||
* Set Steering data out of band.
|
||||
*
|
||||
* Configuration option `OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE` should be set to enable setting of steering
|
||||
* data out of band.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aExtAddress Address used to update the steering data.
|
||||
* All zeros to clear the steering data (no steering data).
|
||||
* All 0xFFs to set steering data/bloom filter to accept/allow all.
|
||||
* A specific EUI64 which is then added to current steering data/bloom filter.
|
||||
*/
|
||||
void otThreadSetSteeringData(otInstance *aInstance, const otExtAddress *aExtAddress);
|
||||
|
||||
/**
|
||||
* Get the CONTEXT_ID_REUSE_DELAY parameter used in the Leader role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The CONTEXT_ID_REUSE_DELAY value.
|
||||
*
|
||||
* @sa otThreadSetContextIdReuseDelay
|
||||
*/
|
||||
uint32_t otThreadGetContextIdReuseDelay(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the CONTEXT_ID_REUSE_DELAY parameter used in the Leader role.
|
||||
*
|
||||
* @note This API is reserved for testing and demo purposes only. Changing settings with
|
||||
* this API will render a production application non-compliant with the Thread Specification.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDelay The CONTEXT_ID_REUSE_DELAY value.
|
||||
*
|
||||
* @sa otThreadGetContextIdReuseDelay
|
||||
*/
|
||||
void otThreadSetContextIdReuseDelay(otInstance *aInstance, uint32_t aDelay);
|
||||
|
||||
/**
|
||||
* Get the `NETWORK_ID_TIMEOUT` parameter.
|
||||
*
|
||||
* @note This API is reserved for testing and demo purposes only. Changing settings with
|
||||
* this API will render a production application non-compliant with the Thread Specification.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The `NETWORK_ID_TIMEOUT` value.
|
||||
*
|
||||
* @sa otThreadSetNetworkIdTimeout
|
||||
*/
|
||||
uint8_t otThreadGetNetworkIdTimeout(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the `NETWORK_ID_TIMEOUT` parameter.
|
||||
*
|
||||
* @note This API is reserved for testing and demo purposes only. Changing settings with
|
||||
* this API will render a production application non-compliant with the Thread Specification.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aTimeout The `NETWORK_ID_TIMEOUT` value.
|
||||
*
|
||||
* @sa otThreadGetNetworkIdTimeout
|
||||
*/
|
||||
void otThreadSetNetworkIdTimeout(otInstance *aInstance, uint8_t aTimeout);
|
||||
|
||||
/**
|
||||
* Get the ROUTER_UPGRADE_THRESHOLD parameter used in the REED role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The ROUTER_UPGRADE_THRESHOLD value.
|
||||
*
|
||||
* @sa otThreadSetRouterUpgradeThreshold
|
||||
*/
|
||||
uint8_t otThreadGetRouterUpgradeThreshold(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the ROUTER_UPGRADE_THRESHOLD parameter used in the Leader role.
|
||||
*
|
||||
* @note This API is reserved for testing and demo purposes only. Changing settings with
|
||||
* this API will render a production application non-compliant with the Thread Specification.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aThreshold The ROUTER_UPGRADE_THRESHOLD value.
|
||||
*
|
||||
* @sa otThreadGetRouterUpgradeThreshold
|
||||
*/
|
||||
void otThreadSetRouterUpgradeThreshold(otInstance *aInstance, uint8_t aThreshold);
|
||||
|
||||
/**
|
||||
* Get the MLE_CHILD_ROUTER_LINKS parameter used in the REED role.
|
||||
*
|
||||
* This parameter specifies the max number of neighboring routers with which the device (as an FED)
|
||||
* will try to establish link.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The MLE_CHILD_ROUTER_LINKS value.
|
||||
*
|
||||
* @sa otThreadSetChildRouterLinks
|
||||
*/
|
||||
uint8_t otThreadGetChildRouterLinks(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the MLE_CHILD_ROUTER_LINKS parameter used in the REED role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aChildRouterLinks The MLE_CHILD_ROUTER_LINKS value.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the value.
|
||||
* @retval OT_ERROR_INVALID_STATE Thread protocols are enabled.
|
||||
*
|
||||
* @sa otThreadGetChildRouterLinks
|
||||
*/
|
||||
otError otThreadSetChildRouterLinks(otInstance *aInstance, uint8_t aChildRouterLinks);
|
||||
|
||||
/**
|
||||
* Release a Router ID that has been allocated by the device in the Leader role.
|
||||
*
|
||||
* @note This API is reserved for testing and demo purposes only. Changing settings with
|
||||
* this API will render a production application non-compliant with the Thread Specification.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aRouterId The Router ID to release. Valid range is [0, 62].
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully released the router id.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aRouterId is not in the range [0, 62].
|
||||
* @retval OT_ERROR_INVALID_STATE The device is not currently operating as a leader.
|
||||
* @retval OT_ERROR_NOT_FOUND The router id is not currently allocated.
|
||||
*/
|
||||
otError otThreadReleaseRouterId(otInstance *aInstance, uint8_t aRouterId);
|
||||
|
||||
/**
|
||||
* Attempt to become a router.
|
||||
*
|
||||
* @note This API is reserved for testing and demo purposes only. Changing settings with
|
||||
* this API will render a production application non-compliant with the Thread Specification.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully begin attempt to become a router.
|
||||
* @retval OT_ERROR_INVALID_STATE Thread is disabled.
|
||||
*/
|
||||
otError otThreadBecomeRouter(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Become a leader and start a new partition.
|
||||
*
|
||||
* If the device is not attached, this API will force the device to start as the leader of the network. This use case
|
||||
* is only intended for testing and demo purposes, and using the API while the device is detached can make a production
|
||||
* application non-compliant with the Thread Specification.
|
||||
*
|
||||
* If the device is already attached, this API can be used to try to take over as the leader, creating a new partition.
|
||||
* For this to work, the local leader weight (`otThreadGetLocalLeaderWeight()`) must be larger than the weight of the
|
||||
* current leader (`otThreadGetLeaderWeight()`). If it is not, `OT_ERROR_NOT_CAPABLE` is returned to indicate to the
|
||||
* caller that they need to adjust the weight.
|
||||
*
|
||||
* Taking over the leader role in this way is only allowed when triggered by an explicit user action. Using this API
|
||||
* without such user action can make a production application non-compliant with the Thread Specification.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully became a leader and started a new partition, or was leader already.
|
||||
* @retval OT_ERROR_INVALID_STATE Thread is disabled.
|
||||
* @retval OT_ERROR_NOT_CAPABLE Device cannot override the current leader due to its local leader weight being same
|
||||
* or smaller than current leader's weight, or device is not router eligible.
|
||||
*/
|
||||
otError otThreadBecomeLeader(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the ROUTER_DOWNGRADE_THRESHOLD parameter used in the Router role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The ROUTER_DOWNGRADE_THRESHOLD value.
|
||||
*
|
||||
* @sa otThreadSetRouterDowngradeThreshold
|
||||
*/
|
||||
uint8_t otThreadGetRouterDowngradeThreshold(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the ROUTER_DOWNGRADE_THRESHOLD parameter used in the Leader role.
|
||||
*
|
||||
* @note This API is reserved for testing and demo purposes only. Changing settings with
|
||||
* this API will render a production application non-compliant with the Thread Specification.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aThreshold The ROUTER_DOWNGRADE_THRESHOLD value.
|
||||
*
|
||||
* @sa otThreadGetRouterDowngradeThreshold
|
||||
*/
|
||||
void otThreadSetRouterDowngradeThreshold(otInstance *aInstance, uint8_t aThreshold);
|
||||
|
||||
/**
|
||||
* Get the ROUTER_SELECTION_JITTER parameter used in the REED/Router role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The ROUTER_SELECTION_JITTER value.
|
||||
*
|
||||
* @sa otThreadSetRouterSelectionJitter
|
||||
*/
|
||||
uint8_t otThreadGetRouterSelectionJitter(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the ROUTER_SELECTION_JITTER parameter used in the REED/Router role.
|
||||
*
|
||||
* @note This API is reserved for testing and demo purposes only. Changing settings with
|
||||
* this API will render a production application non-compliant with the Thread Specification.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aRouterJitter The ROUTER_SELECTION_JITTER value.
|
||||
*
|
||||
* @sa otThreadGetRouterSelectionJitter
|
||||
*/
|
||||
void otThreadSetRouterSelectionJitter(otInstance *aInstance, uint8_t aRouterJitter);
|
||||
|
||||
/**
|
||||
* Gets diagnostic information for an attached Child by its Child ID or RLOC16.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aChildId The Child ID or RLOC16 for the attached child.
|
||||
* @param[out] aChildInfo A pointer to where the child information is placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE @p aChildInfo was successfully updated with the info for the given ID.
|
||||
* @retval OT_ERROR_NOT_FOUND No valid child with this Child ID.
|
||||
* @retval OT_ERROR_INVALID_ARGS If @p aChildInfo is NULL.
|
||||
*/
|
||||
otError otThreadGetChildInfoById(otInstance *aInstance, uint16_t aChildId, otChildInfo *aChildInfo);
|
||||
|
||||
/**
|
||||
* The function retains diagnostic information for an attached Child by the internal table index.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aChildIndex The table index.
|
||||
* @param[out] aChildInfo A pointer to where the child information is placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE @p aChildInfo was successfully updated with the info for the given index.
|
||||
* @retval OT_ERROR_NOT_FOUND No valid child at this index.
|
||||
* @retval OT_ERROR_INVALID_ARGS Either @p aChildInfo is NULL, or @p aChildIndex is out of range (higher
|
||||
* than max table index).
|
||||
*
|
||||
* @sa otGetMaxAllowedChildren
|
||||
*/
|
||||
otError otThreadGetChildInfoByIndex(otInstance *aInstance, uint16_t aChildIndex, otChildInfo *aChildInfo);
|
||||
|
||||
/**
|
||||
* Gets the next IPv6 address (using an iterator) for a given child.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aChildIndex The child index.
|
||||
* @param[in,out] aIterator A pointer to the iterator. On success the iterator will be updated to point to next
|
||||
* entry in the list. To get the first IPv6 address the iterator should be set to
|
||||
* OT_CHILD_IP6_ADDRESS_ITERATOR_INIT.
|
||||
* @param[out] aAddress A pointer to an IPv6 address where the child's next address is placed (on success).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully found the next IPv6 address (@p aAddress was successfully updated).
|
||||
* @retval OT_ERROR_NOT_FOUND The child has no subsequent IPv6 address entry.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aIterator or @p aAddress are NULL, or child at @p aChildIndex is not valid.
|
||||
*
|
||||
* @sa otThreadGetChildInfoByIndex
|
||||
*/
|
||||
otError otThreadGetChildNextIp6Address(otInstance *aInstance,
|
||||
uint16_t aChildIndex,
|
||||
otChildIp6AddressIterator *aIterator,
|
||||
otIp6Address *aAddress);
|
||||
|
||||
/**
|
||||
* Get the current Router ID Sequence.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The Router ID Sequence.
|
||||
*/
|
||||
uint8_t otThreadGetRouterIdSequence(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* The function returns the maximum allowed router ID
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The maximum allowed router ID.
|
||||
*/
|
||||
uint8_t otThreadGetMaxRouterId(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* The function retains diagnostic information for a given Thread Router.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aRouterId The router ID or RLOC16 for a given router.
|
||||
* @param[out] aRouterInfo A pointer to where the router information is placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the router info for given id.
|
||||
* @retval OT_ERROR_NOT_FOUND No router entry with the given id.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aRouterInfo is NULL.
|
||||
*/
|
||||
otError otThreadGetRouterInfo(otInstance *aInstance, uint16_t aRouterId, otRouterInfo *aRouterInfo);
|
||||
|
||||
/**
|
||||
* Gets the next EID cache entry (using an iterator).
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aEntryInfo A pointer to where the EID cache entry information is placed.
|
||||
* @param[in,out] aIterator A pointer to an iterator. It will be updated to point to next entry on success. To get
|
||||
* the first entry, initialize the iterator by setting all its fields to zero
|
||||
* (e.g., `memset` the iterator structure to zero).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully populated @p aEntryInfo for next EID cache entry.
|
||||
* @retval OT_ERROR_NOT_FOUND No more entries in the address cache table.
|
||||
*/
|
||||
otError otThreadGetNextCacheEntry(otInstance *aInstance, otCacheEntryInfo *aEntryInfo, otCacheEntryIterator *aIterator);
|
||||
|
||||
/**
|
||||
* Get the Thread PSKc
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aPskc A pointer to an `otPskc` to return the retrieved Thread PSKc.
|
||||
*
|
||||
* @sa otThreadSetPskc
|
||||
*/
|
||||
void otThreadGetPskc(otInstance *aInstance, otPskc *aPskc);
|
||||
|
||||
/**
|
||||
* Get Key Reference to Thread PSKc stored
|
||||
*
|
||||
* Requires the build-time feature `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` to be enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns Key Reference to PSKc
|
||||
*
|
||||
* @sa otThreadSetPskcRef
|
||||
*/
|
||||
otPskcRef otThreadGetPskcRef(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the Thread PSKc
|
||||
*
|
||||
* Will only succeed when Thread protocols are disabled. A successful
|
||||
* call to this function will also invalidate the Active and Pending Operational Datasets in
|
||||
* non-volatile memory.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPskc A pointer to the new Thread PSKc.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the Thread PSKc.
|
||||
* @retval OT_ERROR_INVALID_STATE Thread protocols are enabled.
|
||||
*
|
||||
* @sa otThreadGetPskc
|
||||
*/
|
||||
otError otThreadSetPskc(otInstance *aInstance, const otPskc *aPskc);
|
||||
|
||||
/**
|
||||
* Set the Key Reference to the Thread PSKc
|
||||
*
|
||||
* Requires the build-time feature `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` to be enabled.
|
||||
*
|
||||
* Will only succeed when Thread protocols are disabled. Upon success,
|
||||
* this will also invalidate the Active and Pending Operational Datasets in
|
||||
* non-volatile memory.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aKeyRef Key Reference to the new Thread PSKc.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the Thread PSKc.
|
||||
* @retval OT_ERROR_INVALID_STATE Thread protocols are enabled.
|
||||
*
|
||||
* @sa otThreadGetPskcRef
|
||||
*/
|
||||
otError otThreadSetPskcRef(otInstance *aInstance, otPskcRef aKeyRef);
|
||||
|
||||
/**
|
||||
* Get the assigned parent priority.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The assigned parent priority value, -2 means not assigned.
|
||||
*
|
||||
* @sa otThreadSetParentPriority
|
||||
*/
|
||||
int8_t otThreadGetParentPriority(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the parent priority.
|
||||
*
|
||||
* @note This API is reserved for testing and demo purposes only. Changing settings with
|
||||
* this API will render a production application non-compliant with the Thread Specification.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aParentPriority The parent priority value.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the parent priority.
|
||||
* @retval OT_ERROR_INVALID_ARGS If the parent priority value is not among 1, 0, -1 and -2.
|
||||
*
|
||||
* @sa otThreadGetParentPriority
|
||||
*/
|
||||
otError otThreadSetParentPriority(otInstance *aInstance, int8_t aParentPriority);
|
||||
|
||||
/**
|
||||
* Gets the maximum number of IP addresses that each MTD child may register with this device as parent.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The maximum number of IP addresses that each MTD child may register with this device as parent.
|
||||
*
|
||||
* @sa otThreadSetMaxChildIpAddresses
|
||||
*/
|
||||
uint8_t otThreadGetMaxChildIpAddresses(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Sets or restores the maximum number of IP addresses that each MTD child may register with this
|
||||
* device as parent.
|
||||
*
|
||||
* Pass `0` to clear the setting and restore the default.
|
||||
*
|
||||
* Available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled.
|
||||
*
|
||||
* @note Only used by Thread Test Harness to limit the address registrations of the reference
|
||||
* parent in order to test the MTD DUT reaction.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMaxIpAddresses The maximum number of IP addresses that each MTD child may register with this
|
||||
* device as parent. 0 to clear the setting and restore the default.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set/cleared the number.
|
||||
* @retval OT_ERROR_INVALID_ARGS If exceeds the allowed maximum number.
|
||||
*
|
||||
* @sa otThreadGetMaxChildIpAddresses
|
||||
*/
|
||||
otError otThreadSetMaxChildIpAddresses(otInstance *aInstance, uint8_t aMaxIpAddresses);
|
||||
|
||||
/**
|
||||
* Defines the constants used in `otNeighborTableCallback` to indicate changes in neighbor table.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OT_NEIGHBOR_TABLE_EVENT_CHILD_ADDED, ///< A child is being added.
|
||||
OT_NEIGHBOR_TABLE_EVENT_CHILD_REMOVED, ///< A child is being removed.
|
||||
OT_NEIGHBOR_TABLE_EVENT_CHILD_MODE_CHANGED, ///< An existing child's mode is changed.
|
||||
OT_NEIGHBOR_TABLE_EVENT_ROUTER_ADDED, ///< A router is being added.
|
||||
OT_NEIGHBOR_TABLE_EVENT_ROUTER_REMOVED, ///< A router is being removed.
|
||||
} otNeighborTableEvent;
|
||||
|
||||
/**
|
||||
* Represent a neighbor table entry info (child or router) and is used as a parameter in the neighbor table
|
||||
* callback `otNeighborTableCallback`.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
otInstance *mInstance; ///< The OpenThread instance.
|
||||
union
|
||||
{
|
||||
otChildInfo mChild; ///< The child neighbor info.
|
||||
otNeighborInfo mRouter; ///< The router neighbor info.
|
||||
} mInfo;
|
||||
} otNeighborTableEntryInfo;
|
||||
|
||||
/**
|
||||
* Pointer is called to notify that there is a change in the neighbor table.
|
||||
*
|
||||
* @param[in] aEvent A event flag.
|
||||
* @param[in] aEntryInfo A pointer to table entry info.
|
||||
*/
|
||||
typedef void (*otNeighborTableCallback)(otNeighborTableEvent aEvent, const otNeighborTableEntryInfo *aEntryInfo);
|
||||
|
||||
/**
|
||||
* Registers a neighbor table callback function.
|
||||
*
|
||||
* The provided callback (if non-NULL) will be invoked when there is a change in the neighbor table (e.g., a child or a
|
||||
* router neighbor entry is being added/removed or an existing child's mode is changed).
|
||||
*
|
||||
* Subsequent calls to this method will overwrite the previous callback. Note that this callback in invoked while the
|
||||
* neighbor/child table is being updated and always before the `otStateChangedCallback`.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aCallback A pointer to callback handler function.
|
||||
*/
|
||||
void otThreadRegisterNeighborTableCallback(otInstance *aInstance, otNeighborTableCallback aCallback);
|
||||
|
||||
/**
|
||||
* Sets whether the device was commissioned using CCM.
|
||||
*
|
||||
* @note This API requires `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE`, and is only used by Thread Test Harness
|
||||
* to indicate whether this device was commissioned using CCM.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnabled TRUE if the device was commissioned using CCM, FALSE otherwise.
|
||||
*/
|
||||
void otThreadSetCcmEnabled(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Sets whether the Security Policy TLV version-threshold for routing (VR field) is enabled.
|
||||
*
|
||||
* @note This API requires `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE`, and is only used by Thread Test Harness
|
||||
* to indicate that thread protocol version check VR should be skipped.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnabled TRUE to enable Security Policy TLV version-threshold for routing, FALSE otherwise.
|
||||
*/
|
||||
void otThreadSetThreadVersionCheckEnabled(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Enables or disables the filter to drop TMF UDP messages from untrusted origin.
|
||||
*
|
||||
* TMF messages are only trusted when they originate from a trusted source, such as the Thread interface. In
|
||||
* special cases, such as when a device uses platform UDP socket to send TMF messages, they will be dropped due
|
||||
* to untrusted origin. This filter is enabled by default.
|
||||
*
|
||||
* When this filter is disabled, UDP messages sent to the TMF port that originate from untrusted origin (such as
|
||||
* host, CLI or an external IPv6 node) will be allowed.
|
||||
*
|
||||
* @note This API requires `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` and is only used by Thread Test Harness
|
||||
* to test network behavior by sending special TMF messages from the CLI on a POSIX host.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnabled TRUE to enable filter, FALSE otherwise.
|
||||
*/
|
||||
void otThreadSetTmfOriginFilterEnabled(otInstance *aInstance, bool aEnabled);
|
||||
|
||||
/**
|
||||
* Indicates whether the filter that drops TMF UDP messages from untrusted origin is enabled or not.
|
||||
*
|
||||
* This is intended for testing only and available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` config is enabled.
|
||||
*
|
||||
* @retval TRUE The filter is enabled.
|
||||
* @retval FALSE The filter is not enabled.
|
||||
*/
|
||||
bool otThreadIsTmfOriginFilterEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Gets the range of router IDs that are allowed to assign to nodes within the thread network.
|
||||
*
|
||||
* @note This API requires `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE`, and is only used for test purpose. All the
|
||||
* router IDs in the range [aMinRouterId, aMaxRouterId] are allowed.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aMinRouterId The minimum router ID.
|
||||
* @param[out] aMaxRouterId The maximum router ID.
|
||||
*
|
||||
* @sa otThreadSetRouterIdRange
|
||||
*/
|
||||
void otThreadGetRouterIdRange(otInstance *aInstance, uint8_t *aMinRouterId, uint8_t *aMaxRouterId);
|
||||
|
||||
/**
|
||||
* Sets the range of router IDs that are allowed to assign to nodes within the thread network.
|
||||
*
|
||||
* @note This API requires `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE`, and is only used for test purpose. All the
|
||||
* router IDs in the range [aMinRouterId, aMaxRouterId] are allowed.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMinRouterId The minimum router ID.
|
||||
* @param[in] aMaxRouterId The maximum router ID.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the range.
|
||||
* @retval OT_ERROR_INVALID_ARGS aMinRouterId > aMaxRouterId, or the range is not covered by [0, 62].
|
||||
*
|
||||
* @sa otThreadGetRouterIdRange
|
||||
*/
|
||||
otError otThreadSetRouterIdRange(otInstance *aInstance, uint8_t aMinRouterId, uint8_t aMaxRouterId);
|
||||
|
||||
/**
|
||||
* Gets the current Interval Max value used by Advertisement trickle timer.
|
||||
*
|
||||
* This API requires `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE`, and is intended for testing only.
|
||||
*
|
||||
* @returns The Interval Max of Advertisement trickle timer in milliseconds.
|
||||
*/
|
||||
uint32_t otThreadGetAdvertisementTrickleIntervalMax(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Indicates whether or not a Router ID is currently allocated.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aRouterId The router ID to check.
|
||||
*
|
||||
* @retval TRUE The @p aRouterId is allocated.
|
||||
* @retval FALSE The @p aRouterId is not allocated.
|
||||
*/
|
||||
bool otThreadIsRouterIdAllocated(otInstance *aInstance, uint8_t aRouterId);
|
||||
|
||||
/**
|
||||
* Gets the next hop and path cost towards a given RLOC16 destination.
|
||||
*
|
||||
* Can be used with either @p aNextHopRloc16 or @p aPathCost being NULL indicating caller does not want
|
||||
* to get the value.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDestRloc16 The RLOC16 of destination.
|
||||
* @param[out] aNextHopRloc16 A pointer to return RLOC16 of next hop, 0xfffe if no next hop.
|
||||
* @param[out] aPathCost A pointer to return path cost towards destination.
|
||||
*/
|
||||
void otThreadGetNextHopAndPathCost(otInstance *aInstance,
|
||||
uint16_t aDestRloc16,
|
||||
uint16_t *aNextHopRloc16,
|
||||
uint8_t *aPathCost);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_THREAD_FTD_H_
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user