diff --git a/etc/cmake/options.cmake b/etc/cmake/options.cmake index e9414a9d7..0cadec375 100644 --- a/etc/cmake/options.cmake +++ b/etc/cmake/options.cmake @@ -238,6 +238,7 @@ if(OT_FULL_LOGS) target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_BBR=1") target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_CLI=1") target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_COAP=1") + target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_DUA=1") target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_ICMP=1") target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_IP6=1") target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_MAC=1") diff --git a/examples/common-switches.mk b/examples/common-switches.mk index 59fc043f6..cf0e7bb13 100644 --- a/examples/common-switches.mk +++ b/examples/common-switches.mk @@ -286,6 +286,7 @@ LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_ARP=1 LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_BBR=1 LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_CLI=1 LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_COAP=1 +LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_DUA=1 LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_ICMP=1 LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_IP6=1 LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_MAC=1 diff --git a/include/openthread/instance.h b/include/openthread/instance.h index e144eed97..60940ff0f 100644 --- a/include/openthread/instance.h +++ b/include/openthread/instance.h @@ -53,7 +53,7 @@ extern "C" { * @note This number versions both OpenThread platform and user APIs. * */ -#define OPENTHREAD_API_VERSION (17) +#define OPENTHREAD_API_VERSION (18) /** * @addtogroup api-instance diff --git a/include/openthread/platform/logging.h b/include/openthread/platform/logging.h index df40aeeef..3744825b9 100644 --- a/include/openthread/platform/logging.h +++ b/include/openthread/platform/logging.h @@ -136,6 +136,7 @@ typedef enum otLogRegion OT_LOG_REGION_UTIL = 16, ///< Utility module OT_LOG_REGION_BBR = 17, ///< Backbone Router (available since Thread 1.2) OT_LOG_REGION_MLR = 18, ///< Multicast Listener Registration (available since Thread 1.2) + OT_LOG_REGION_DUA = 19, ///< Domain Unicast Address (available since Thread 1.2) } otLogRegion; /** diff --git a/src/core/common/logging.hpp b/src/core/common/logging.hpp index 6e9ff1661..dc08ca4ca 100644 --- a/src/core/common/logging.hpp +++ b/src/core/common/logging.hpp @@ -91,6 +91,7 @@ extern "C" { #define _OT_REGION_UTIL_PREFIX "-UTIL----: " #define _OT_REGION_BBR_PREFIX "-BBR-----: " #define _OT_REGION_MLR_PREFIX "-MLR-----: " +#define _OT_REGION_DUA_PREFIX "-DUA-----: " #else #define _OT_REGION_API_PREFIX _OT_REGION_SUFFIX #define _OT_REGION_MLE_PREFIX _OT_REGION_SUFFIX @@ -110,6 +111,7 @@ extern "C" { #define _OT_REGION_UTIL_PREFIX _OT_REGION_SUFFIX #define _OT_REGION_BBR_PREFIX _OT_REGION_SUFFIX #define _OT_REGION_MLR_PREFIX _OT_REGION_SUFFIX +#define _OT_REGION_DUA_PREFIX _OT_REGION_SUFFIX #endif /** @@ -1160,6 +1162,64 @@ extern "C" { #define otLogDebgCoap(...) #endif +/** + * @def otLogCritDua + * + * This method generates a log with level critical for the Domain Unicast Address region. + * + * @param[in] ... Arguments for the format specification. + * + */ + +/** + * @def otLogWarnDua + * + * This method generates a log with level warning for the Domain Unicast Address region. + * + * @param[in] ... Arguments for the format specification. + * + */ + +/** + * @def otLogNoteDua + * + * This method generates a log with level note for the Domain Unicast Address region. + * + * @param[in] ... Arguments for the format specification. + * + */ + +/** + * @def otLogInfoDua + * + * This method generates a log with level info for the Domain Unicast Address region. + * + * @param[in] ... Arguments for the format specification. + * + */ + +/** + * @def otLogDebgDua + * + * This method generates a log with level debug for the Domain Unicast Address region. + * + * @param[in] ... Arguments for the format specification. + * + */ +#if OPENTHREAD_CONFIG_LOG_DUA == 1 +#define otLogCritDua(...) otLogCrit(OT_LOG_REGION_DUA, _OT_REGION_DUA_PREFIX __VA_ARGS__) +#define otLogWarnDua(...) otLogWarn(OT_LOG_REGION_DUA, _OT_REGION_DUA_PREFIX __VA_ARGS__) +#define otLogNoteDua(...) otLogNote(OT_LOG_REGION_DUA, _OT_REGION_DUA_PREFIX __VA_ARGS__) +#define otLogInfoDua(...) otLogInfo(OT_LOG_REGION_DUA, _OT_REGION_DUA_PREFIX __VA_ARGS__) +#define otLogDebgDua(...) otLogDebg(OT_LOG_REGION_DUA, _OT_REGION_DUA_PREFIX __VA_ARGS__) +#else +#define otLogCritDua(...) +#define otLogWarnDua(...) +#define otLogNoteDua(...) +#define otLogInfoDua(...) +#define otLogDebgDua(...) +#endif + /** * @def otLogCritPlat * @@ -1923,6 +1983,74 @@ extern "C" { #define otDumpDebgCore(aId, aBuf, aLength) #endif +/** + * @def otDumpCritDua + * + * This method generates a memory dump with log level critical and region Domain Unicast Address. + * + * @param[in] aId A pointer to a NULL-terminated string that is printed before the bytes. + * @param[in] aBuf A pointer to the buffer. + * @param[in] aLength Number of bytes to print. + * + */ + +/** + * @def otDumpWarnDua + * + * This method generates a memory dump with log level warning and region Domain Unicast Address. + * + * @param[in] aId A pointer to a NULL-terminated string that is printed before the bytes. + * @param[in] aBuf A pointer to the buffer. + * @param[in] aLength Number of bytes to print. + * + */ + +/** + * @def otDumpNoteDua + * + * This method generates a memory dump with log level note and region Domain Unicast Address. + * + * @param[in] aId A pointer to a NULL-terminated string that is printed before the bytes. + * @param[in] aBuf A pointer to the buffer. + * @param[in] aLength Number of bytes to print. + * + */ + +/** + * @def otDumpInfoDua + * + * This method generates a memory dump with log level info and region Domain Unicast Address. + * + * @param[in] aId A pointer to a NULL-terminated string that is printed before the bytes. + * @param[in] aBuf A pointer to the buffer. + * @param[in] aLength Number of bytes to print. + * + */ + +/** + * @def otDumpDebgDua + * + * This method generates a memory dump with log level debug and region Domain Unicast Address. + * + * @param[in] aId A pointer to a NULL-terminated string that is printed before the bytes. + * @param[in] aBuf A pointer to the buffer. + * @param[in] aLength Number of bytes to print. + * + */ +#if OPENTHREAD_CONFIG_LOG_DUA == 1 +#define otDumpCritDua(aId, aBuf, aLength) otDumpCrit(OT_LOG_REGION_DUA, aId, aBuf, aLength) +#define otDumpWarnDua(aId, aBuf, aLength) otDumpWarn(OT_LOG_REGION_DUA, aId, aBuf, aLength) +#define otDumpNoteDua(aId, aBuf, aLength) otDumpNote(OT_LOG_REGION_DUA, aId, aBuf, aLength) +#define otDumpInfoDua(aId, aBuf, aLength) otDumpInfo(OT_LOG_REGION_DUA, aId, aBuf, aLength) +#define otDumpDebgDua(aId, aBuf, aLength) otDumpDebg(OT_LOG_REGION_DUA, aId, aBuf, aLength) +#else +#define otDumpCritDua(aId, aBuf, aLength) +#define otDumpWarnDua(aId, aBuf, aLength) +#define otDumpNoteDua(aId, aBuf, aLength) +#define otDumpInfoDua(aId, aBuf, aLength) +#define otDumpDebgDua(aId, aBuf, aLength) +#endif + /** * @def otDumpCritMem * diff --git a/src/core/config/logging.h b/src/core/config/logging.h index c8d46ed29..54241da80 100644 --- a/src/core/config/logging.h +++ b/src/core/config/logging.h @@ -287,6 +287,18 @@ #define OPENTHREAD_CONFIG_LOG_MLR 1 #endif +/** + * @def OPENTHREAD_CONFIG_LOG_DUA + * + * Note: available since Thread 1.2. + * + * Define to enable Domain Unicast Address (DUA) region logging. + * + */ +#ifndef OPENTHREAD_CONFIG_LOG_DUA +#define OPENTHREAD_CONFIG_LOG_DUA 1 +#endif + /** * @def OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL * diff --git a/src/lib/spinel/spinel.h b/src/lib/spinel/spinel.h index 915751f68..3cd74853f 100644 --- a/src/lib/spinel/spinel.h +++ b/src/lib/spinel/spinel.h @@ -645,6 +645,7 @@ enum SPINEL_NCP_LOG_REGION_OT_UTIL = 16, SPINEL_NCP_LOG_REGION_OT_BBR = 17, SPINEL_NCP_LOG_REGION_OT_MLR = 18, + SPINEL_NCP_LOG_REGION_OT_DUA = 19, }; enum diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp index bd17952fe..bb2378217 100644 --- a/src/ncp/ncp_base.cpp +++ b/src/ncp/ncp_base.cpp @@ -612,9 +612,14 @@ unsigned int NcpBase::ConvertLogRegion(otLogRegion aLogRegion) case OT_LOG_REGION_BBR: spinelLogRegion = SPINEL_NCP_LOG_REGION_OT_BBR; break; + case OT_LOG_REGION_MLR: spinelLogRegion = SPINEL_NCP_LOG_REGION_OT_MLR; break; + + case OT_LOG_REGION_DUA: + spinelLogRegion = SPINEL_NCP_LOG_REGION_OT_DUA; + break; } return spinelLogRegion;