mirror of
https://github.com/espressif/openthread.git
synced 2026-08-14 22:57:46 +00:00
[logging] add bbr region (#4819)
This commit is contained in:
@@ -204,6 +204,7 @@ if(OT_FULL_LOGS)
|
||||
list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG")
|
||||
list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_API=1")
|
||||
list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_ARP=1")
|
||||
list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_BBR=1")
|
||||
list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_CLI=1")
|
||||
list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_COAP=1")
|
||||
list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_ICMP=1")
|
||||
|
||||
@@ -263,6 +263,7 @@ ifeq ($(FULL_LOGS),1)
|
||||
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG
|
||||
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_API=1
|
||||
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_ICMP=1
|
||||
|
||||
@@ -134,6 +134,7 @@ typedef enum otLogRegion
|
||||
OT_LOG_REGION_CLI = 14, ///< CLI
|
||||
OT_LOG_REGION_CORE = 15, ///< OpenThread Core
|
||||
OT_LOG_REGION_UTIL = 16, ///< Utility module
|
||||
OT_LOG_REGION_BBR = 17, ///< Backbone Router (available since Thread 1.2)
|
||||
} otLogRegion;
|
||||
|
||||
/**
|
||||
|
||||
@@ -83,26 +83,26 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_NETDATA == 1)
|
||||
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_BBR == 1)
|
||||
void Leader::LogBackboneRouterPrimary(State aState, const BackboneRouterConfig &aConfig) const
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aConfig);
|
||||
|
||||
otLogInfoNetData("PBBR state: %s", StateToString(aState));
|
||||
otLogInfoBbr("PBBR state: %s", StateToString(aState));
|
||||
|
||||
if (aState != kStateRemoved && aState != kStateNone)
|
||||
{
|
||||
otLogInfoNetData("Rloc16: 0x%4X, seqno: %d, delay: %d, timeout %d", aConfig.mServer16, aConfig.mSequenceNumber,
|
||||
aConfig.mReregistrationDelay, aConfig.mMlrTimeout);
|
||||
otLogInfoBbr("Rloc16: 0x%4X, seqno: %d, delay: %d, timeout %d", aConfig.mServer16, aConfig.mSequenceNumber,
|
||||
aConfig.mReregistrationDelay, aConfig.mMlrTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
void Leader::LogDomainPrefix(DomainPrefixState aState, const otIp6Prefix &aPrefix) const
|
||||
{
|
||||
otLogInfoNetData("Domain Prefix: %s/%d, state: %s",
|
||||
aPrefix.mLength == 0 ? ""
|
||||
: static_cast<const Ip6::Address *>(&aPrefix.mPrefix)->ToString().AsCString(),
|
||||
aPrefix.mLength, DomainPrefixStateToString(aState));
|
||||
otLogInfoBbr("Domain Prefix: %s/%d, state: %s",
|
||||
aPrefix.mLength == 0 ? ""
|
||||
: static_cast<const Ip6::Address *>(&aPrefix.mPrefix)->ToString().AsCString(),
|
||||
aPrefix.mLength, DomainPrefixStateToString(aState));
|
||||
}
|
||||
|
||||
const char *Leader::StateToString(State aState)
|
||||
|
||||
@@ -155,7 +155,7 @@ public:
|
||||
private:
|
||||
void UpdateBackboneRouterPrimary(void);
|
||||
void UpdateDomainPrefixConfig(void);
|
||||
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_NETDATA == 1)
|
||||
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_BBR == 1)
|
||||
void LogBackboneRouterPrimary(State aState, const BackboneRouterConfig &aConfig) const;
|
||||
void LogDomainPrefix(DomainPrefixState aState, const otIp6Prefix &aPrefix) const;
|
||||
static const char *StateToString(State aState);
|
||||
|
||||
@@ -322,20 +322,20 @@ void Local::AddDomainPrefixToNetworkData(void)
|
||||
LogDomainPrefix("Add", error);
|
||||
}
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_NETDATA == 1)
|
||||
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_BBR == 1)
|
||||
void Local::LogDomainPrefix(const char *aAction, otError aError)
|
||||
{
|
||||
otLogInfoNetData("%s Domain Prefix: %s/%d, %s", aAction,
|
||||
mDomainPrefixConfig.mPrefix.mLength > 0
|
||||
? (*static_cast<Ip6::Address *>(&mDomainPrefixConfig.mPrefix.mPrefix)).ToString().AsCString()
|
||||
: "",
|
||||
mDomainPrefixConfig.mPrefix.mLength, otThreadErrorToString(aError));
|
||||
otLogInfoBbr("%s Domain Prefix: %s/%d, %s", aAction,
|
||||
mDomainPrefixConfig.mPrefix.mLength > 0
|
||||
? (*static_cast<Ip6::Address *>(&mDomainPrefixConfig.mPrefix.mPrefix)).ToString().AsCString()
|
||||
: "",
|
||||
mDomainPrefixConfig.mPrefix.mLength, otThreadErrorToString(aError));
|
||||
}
|
||||
|
||||
void Local::LogBackboneRouterService(const char *aAction, otError aError)
|
||||
{
|
||||
otLogInfoNetData("%s BBR Service: seqno (%d), delay (%ds), timeout (%ds), %s", aAction, mSequenceNumber,
|
||||
mReregistrationDelay, mMlrTimeout, otThreadErrorToString(aError));
|
||||
otLogInfoBbr("%s BBR Service: seqno (%d), delay (%ds), timeout (%ds), %s", aAction, mSequenceNumber,
|
||||
mReregistrationDelay, mMlrTimeout, otThreadErrorToString(aError));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ private:
|
||||
otError RemoveService(void);
|
||||
void AddDomainPrefixToNetworkData(void);
|
||||
void RemoveDomainPrefixFromNetworkData(void);
|
||||
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_NETDATA == 1)
|
||||
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_BBR == 1)
|
||||
void LogBackboneRouterService(const char *aAction, otError aError);
|
||||
void LogDomainPrefix(const char *aAction, otError aError);
|
||||
#else
|
||||
|
||||
@@ -89,6 +89,7 @@ extern "C" {
|
||||
#define _OT_REGION_CLI_PREFIX "-CLI-----: "
|
||||
#define _OT_REGION_CORE_PREFIX "-CORE----: "
|
||||
#define _OT_REGION_UTIL_PREFIX "-UTIL----: "
|
||||
#define _OT_REGION_BBR_PREFIX "-BBR-----: "
|
||||
#else
|
||||
#define _OT_REGION_API_PREFIX _OT_REGION_SUFFIX
|
||||
#define _OT_REGION_MLE_PREFIX _OT_REGION_SUFFIX
|
||||
@@ -106,6 +107,7 @@ extern "C" {
|
||||
#define _OT_REGION_CLI_PREFIX _OT_REGION_SUFFIX
|
||||
#define _OT_REGION_CORE_PREFIX _OT_REGION_SUFFIX
|
||||
#define _OT_REGION_UTIL_PREFIX _OT_REGION_SUFFIX
|
||||
#define _OT_REGION_BBR_PREFIX _OT_REGION_SUFFIX
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -458,6 +460,69 @@ extern "C" {
|
||||
#define otLogDebgArp(aFormat, ...)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def otLogCritBbr
|
||||
*
|
||||
* This method generates a log with level critical for the Backbone Router (BBR) region.
|
||||
*
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def otLogWarnBbr
|
||||
*
|
||||
* This method generates a log with level warning for the Backbone Router (BBR) region.
|
||||
*
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def otLogInfoBbr
|
||||
*
|
||||
* This method generates a log with level note for the Backbone Router (BBR) region.
|
||||
*
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def otLogInfoBbr
|
||||
*
|
||||
* This method generates a log with level info for the Backbone Router (BBR) region.
|
||||
*
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def otLogDebgBbr
|
||||
*
|
||||
* This method generates a log with level debug for the Backbone Router (BBR) region.
|
||||
*
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
#if OPENTHREAD_CONFIG_LOG_BBR == 1
|
||||
#define otLogCritBbr(aFormat, ...) otLogCrit(OT_LOG_REGION_BBR, _OT_REGION_BBR_PREFIX aFormat, ##__VA_ARGS__)
|
||||
#define otLogWarnBbr(aFormat, ...) otLogWarn(OT_LOG_REGION_BBR, _OT_REGION_BBR_PREFIX aFormat, ##__VA_ARGS__)
|
||||
#define otLogNoteBbr(aFormat, ...) otLogNote(OT_LOG_REGION_BBR, _OT_REGION_BBR_PREFIX aFormat, ##__VA_ARGS__)
|
||||
#define otLogInfoBbr(aFormat, ...) otLogInfo(OT_LOG_REGION_BBR, _OT_REGION_BBR_PREFIX aFormat, ##__VA_ARGS__)
|
||||
#define otLogDebgBbr(aFormat, ...) otLogDebg(OT_LOG_REGION_BBR, _OT_REGION_BBR_PREFIX aFormat, ##__VA_ARGS__)
|
||||
#else
|
||||
#define otLogCritBbr(aFormat, ...)
|
||||
#define otLogWarnBbr(aFormat, ...)
|
||||
#define otLogNoteBbr(aFormat, ...)
|
||||
#define otLogInfoBbr(aFormat, ...)
|
||||
#define otLogDebgBbr(aFormat, ...)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def otLogCritNetData
|
||||
*
|
||||
@@ -1484,6 +1549,74 @@ extern "C" {
|
||||
#define otDumpDebgArp(aId, aBuf, aLength)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def otDumpCritBbr
|
||||
*
|
||||
* This method generates a memory dump with log level critical and region Backbone Router (BBR).
|
||||
*
|
||||
* @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 otDumpWarnBbr
|
||||
*
|
||||
* This method generates a memory dump with log level warning and region Backbone Router (BBR).
|
||||
*
|
||||
* @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 otDumpNoteBbr
|
||||
*
|
||||
* This method generates a memory dump with log level note and region Backbone Router (BBR).
|
||||
*
|
||||
* @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 otDumpInfoBbr
|
||||
*
|
||||
* This method generates a memory dump with log level info and region Backbone Router (BBR).
|
||||
*
|
||||
* @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 otDumpDebgBbr
|
||||
*
|
||||
* This method generates a memory dump with log level debug and region Backbone Router (BBR).
|
||||
*
|
||||
* @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_BBR == 1
|
||||
#define otDumpCritBbr(aId, aBuf, aLength) otDumpCrit(OT_LOG_REGION_BBR, aId, aBuf, aLength)
|
||||
#define otDumpWarnBbr(aId, aBuf, aLength) otDumpWarn(OT_LOG_REGION_BBR, aId, aBuf, aLength)
|
||||
#define otDumpNoteBbr(aId, aBuf, aLength) otDumpNote(OT_LOG_REGION_BBR, aId, aBuf, aLength)
|
||||
#define otDumpInfoBbr(aId, aBuf, aLength) otDumpInfo(OT_LOG_REGION_BBR, aId, aBuf, aLength)
|
||||
#define otDumpDebgBbr(aId, aBuf, aLength) otDumpDebg(OT_LOG_REGION_BBR, aId, aBuf, aLength)
|
||||
#else
|
||||
#define otDumpCritBbr(aId, aBuf, aLength)
|
||||
#define otDumpWarnBbr(aId, aBuf, aLength)
|
||||
#define otDumpNoteBbr(aId, aBuf, aLength)
|
||||
#define otDumpInfoBbr(aId, aBuf, aLength)
|
||||
#define otDumpDebgBbr(aId, aBuf, aLength)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def otDumpCritIcmp
|
||||
*
|
||||
|
||||
@@ -256,6 +256,18 @@
|
||||
#define OPENTHREAD_CONFIG_LOG_UTIL 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_LOG_BBR
|
||||
*
|
||||
* Note: available since Thread 1.2.
|
||||
*
|
||||
* Define to enable Backbone Router (BBR) region logging.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_LOG_BBR
|
||||
#define OPENTHREAD_CONFIG_LOG_BBR 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
|
||||
*
|
||||
|
||||
@@ -621,6 +621,7 @@ enum
|
||||
SPINEL_NCP_LOG_REGION_OT_CLI = 14,
|
||||
SPINEL_NCP_LOG_REGION_OT_CORE = 15,
|
||||
SPINEL_NCP_LOG_REGION_OT_UTIL = 16,
|
||||
SPINEL_NCP_LOG_REGION_OT_BBR = 17,
|
||||
};
|
||||
|
||||
enum
|
||||
|
||||
@@ -608,6 +608,10 @@ unsigned int NcpBase::ConvertLogRegion(otLogRegion aLogRegion)
|
||||
case OT_LOG_REGION_UTIL:
|
||||
spinelLogRegion = SPINEL_NCP_LOG_REGION_OT_UTIL;
|
||||
break;
|
||||
|
||||
case OT_LOG_REGION_BBR:
|
||||
spinelLogRegion = SPINEL_NCP_LOG_REGION_OT_BBR;
|
||||
break;
|
||||
}
|
||||
|
||||
return spinelLogRegion;
|
||||
|
||||
Reference in New Issue
Block a user