diff --git a/etc/cmake/options.cmake b/etc/cmake/options.cmake index cb1b00cb4..bf5564144 100644 --- a/etc/cmake/options.cmake +++ b/etc/cmake/options.cmake @@ -312,6 +312,7 @@ if(OT_FULL_LOGS) target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PLATFORM=1") target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1") target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PREPEND_REGION=1") + target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_SRP=1") endif() option(OT_OTNS "enable OTNS support") diff --git a/examples/common-switches.mk b/examples/common-switches.mk index a3050ab32..b5f545487 100644 --- a/examples/common-switches.mk +++ b/examples/common-switches.mk @@ -341,6 +341,7 @@ LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_PKT_DUMP=1 LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_PLATFORM=1 LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1 LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_PREPEND_REGION=1 +LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_SRP=1 endif CFLAGS += ${LOG_FLAGS} diff --git a/include/openthread/instance.h b/include/openthread/instance.h index 700e4d710..25a505876 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 (59) +#define OPENTHREAD_API_VERSION (60) /** * @addtogroup api-instance diff --git a/include/openthread/platform/logging.h b/include/openthread/platform/logging.h index 0808ee911..48f0c8acc 100644 --- a/include/openthread/platform/logging.h +++ b/include/openthread/platform/logging.h @@ -138,6 +138,7 @@ typedef enum otLogRegion 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) OT_LOG_REGION_BR = 20, ///< Border Router + OT_LOG_REGION_SRP = 21, ///< Service Registration Protocol (SRP) } otLogRegion; /** diff --git a/src/core/BUILD.gn b/src/core/BUILD.gn index 03e4da63c..0dc011bde 100644 --- a/src/core/BUILD.gn +++ b/src/core/BUILD.gn @@ -255,6 +255,7 @@ if (openthread_enable_core_config_args) { "OPENTHREAD_CONFIG_LOG_PLATFORM=1", "OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1", "OPENTHREAD_CONFIG_LOG_PREPEND_REGION=1", + "OPENTHREAD_CONFIG_LOG_SRP=1", ] } diff --git a/src/core/common/logging.hpp b/src/core/common/logging.hpp index 460633b59..5716a9f4e 100644 --- a/src/core/common/logging.hpp +++ b/src/core/common/logging.hpp @@ -95,6 +95,7 @@ extern "C" { #define _OT_REGION_MLR_PREFIX "-MLR-----: " #define _OT_REGION_DUA_PREFIX "-DUA-----: " #define _OT_REGION_BR_PREFIX "-BR------: " +#define _OT_REGION_SRP_PREFIX "-SRP-----: " #else #define _OT_REGION_API_PREFIX _OT_REGION_SUFFIX #define _OT_REGION_MLE_PREFIX _OT_REGION_SUFFIX @@ -116,6 +117,7 @@ extern "C" { #define _OT_REGION_MLR_PREFIX _OT_REGION_SUFFIX #define _OT_REGION_DUA_PREFIX _OT_REGION_SUFFIX #define _OT_REGION_BR_PREFIX _OT_REGION_SUFFIX +#define _OT_REGION_SRP_PREFIX _OT_REGION_SUFFIX #endif /** @@ -1302,6 +1304,64 @@ void otLogCertMeshCoP(const char *aFormat, ...); #define otLogDebgDua(...) #endif +/** + * @def otLogCritSrp + * + * This function generates a log with level critical for the Service Registration Protocol (SRP) region. + * + * @param[in] ... Arguments for the format specification. + * + */ + +/** + * @def otLogWarnSrp + * + * This function generates a log with level warning for the Service Registration Protocol (SRP) region. + * + * @param[in] ... Arguments for the format specification. + * + */ + +/** + * @def otLogNoteSrp + * + * This function generates a log with level note for the Service Registration Protocol (SRP) region. + * + * @param[in] ... Arguments for the format specification. + * + */ + +/** + * @def otLogInfoSrp + * + * This function generates a log with level info for the Service Registration Protocol (SRP) region. + * + * @param[in] ... Arguments for the format specification. + * + */ + +/** + * @def otLogDebgSrp + * + * This function generates a log with level debug for the Service Registration Protocol (SRP) region. + * + * @param[in] ... Arguments for the format specification. + * + */ +#if OPENTHREAD_CONFIG_LOG_SRP +#define otLogCritSrp(...) otLogCrit(OT_LOG_REGION_SRP, _OT_REGION_SRP_PREFIX, __VA_ARGS__) +#define otLogWarnSrp(...) otLogWarn(OT_LOG_REGION_SRP, _OT_REGION_SRP_PREFIX, __VA_ARGS__) +#define otLogNoteSrp(...) otLogNote(OT_LOG_REGION_SRP, _OT_REGION_SRP_PREFIX, __VA_ARGS__) +#define otLogInfoSrp(...) otLogInfo(OT_LOG_REGION_SRP, _OT_REGION_SRP_PREFIX, __VA_ARGS__) +#define otLogDebgSrp(...) otLogDebg(OT_LOG_REGION_SRP, _OT_REGION_SRP_PREFIX, __VA_ARGS__) +#else +#define otLogCritSrp(...) +#define otLogWarnSrp(...) +#define otLogNoteSrp(...) +#define otLogInfoSrp(...) +#define otLogDebgSrp(...) +#endif + /** * @def otLogCritPlat * @@ -2137,6 +2197,74 @@ void otLogOtns(const char *aFormat, ...); #define otDumpDebgDua(aId, aBuf, aLength) #endif +/** + * @def otDumpCritSrp + * + * This function generates a memory dump with log level critical and region Service Registration Protocol (SRP). + * + * @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 otDumpWarnSrp + * + * This function generates a memory dump with log level warning and region Service Registration Protocol (SRP). + * + * @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 otDumpNoteSrp + * + * This function generates a memory dump with log level note and region Service Registration Protocol (SRP). + * + * @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 otDumpInfoSrp + * + * This function generates a memory dump with log level info and region Service Registration Protocol (SRP). + * + * @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 otDumpDebgSrp + * + * This function generates a memory dump with log level debug and region Service Registration Protocol (SRP). + * + * @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_SRP +#define otDumpCritSrp(aId, aBuf, aLength) otDumpCrit(OT_LOG_REGION_SRP, aId, aBuf, aLength) +#define otDumpWarnSrp(aId, aBuf, aLength) otDumpWarn(OT_LOG_REGION_SRP, aId, aBuf, aLength) +#define otDumpNoteSrp(aId, aBuf, aLength) otDumpNote(OT_LOG_REGION_SRP, aId, aBuf, aLength) +#define otDumpInfoSrp(aId, aBuf, aLength) otDumpInfo(OT_LOG_REGION_SRP, aId, aBuf, aLength) +#define otDumpDebgSrp(aId, aBuf, aLength) otDumpDebg(OT_LOG_REGION_SRP, aId, aBuf, aLength) +#else +#define otDumpCritSrp(aId, aBuf, aLength) +#define otDumpWarnSrp(aId, aBuf, aLength) +#define otDumpNoteSrp(aId, aBuf, aLength) +#define otDumpInfoSrp(aId, aBuf, aLength) +#define otDumpDebgSrp(aId, aBuf, aLength) +#endif + /** * @def otDumpCritMem * diff --git a/src/core/config/logging.h b/src/core/config/logging.h index 7d4a912be..818426862 100644 --- a/src/core/config/logging.h +++ b/src/core/config/logging.h @@ -309,6 +309,16 @@ #define OPENTHREAD_CONFIG_LOG_BR 1 #endif +/** + * @def OPENTHREAD_CONFIG_LOG_SRP + * + * Define to enable Service Registration Protocol (SRP) region logging. + * + */ +#ifndef OPENTHREAD_CONFIG_LOG_SRP +#define OPENTHREAD_CONFIG_LOG_SRP 1 +#endif + /** * @def OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL * diff --git a/src/lib/spinel/spinel.h b/src/lib/spinel/spinel.h index 3c9b5ac9a..d156c9375 100644 --- a/src/lib/spinel/spinel.h +++ b/src/lib/spinel/spinel.h @@ -693,6 +693,7 @@ enum SPINEL_NCP_LOG_REGION_OT_MLR = 18, SPINEL_NCP_LOG_REGION_OT_DUA = 19, SPINEL_NCP_LOG_REGION_OT_BR = 20, + SPINEL_NCP_LOG_REGION_OT_SRP = 21, }; enum diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp index 277080e19..d13c40c48 100644 --- a/src/ncp/ncp_base.cpp +++ b/src/ncp/ncp_base.cpp @@ -624,9 +624,14 @@ unsigned int NcpBase::ConvertLogRegion(otLogRegion aLogRegion) case OT_LOG_REGION_DUA: spinelLogRegion = SPINEL_NCP_LOG_REGION_OT_DUA; break; + case OT_LOG_REGION_BR: spinelLogRegion = SPINEL_NCP_LOG_REGION_OT_BR; break; + + case OT_LOG_REGION_SRP: + spinelLogRegion = SPINEL_NCP_LOG_REGION_OT_SRP; + break; } return spinelLogRegion;