[message] extend buffer info provided by otMessageGetBufferInfo() (#2249)

* Include application CoAP messages and buffers
* Include cached messages and buffers
* Set unused buffer info fields to zero
This commit is contained in:
Giedrius
2017-10-09 23:53:03 -07:00
committed by Jonathan Hui
parent 9a0b838e5b
commit e190edf8a0
3 changed files with 20 additions and 0 deletions
+2
View File
@@ -1007,6 +1007,8 @@ typedef struct otBufferInfo
uint16_t mCoapBuffers; ///< The number of buffers in the CoAP send queue.
uint16_t mCoapSecureMessages; ///< The number of messages in the CoAP secure send queue.
uint16_t mCoapSecureBuffers; ///< The number of buffers in the CoAP secure send queue.
uint16_t mApplicationCoapMessages;///< The number of messages in the application CoAP send queue.
uint16_t mApplicationCoapBuffers; ///< The number of buffers in the application CoAP send queue.
} otBufferInfo;
/**
+2
View File
@@ -441,6 +441,8 @@ void Interpreter::ProcessBufferInfo(int argc, char *argv[])
mServer->OutputFormat("arp: %d %d\r\n", bufferInfo.mArpMessages, bufferInfo.mArpBuffers);
mServer->OutputFormat("coap: %d %d\r\n", bufferInfo.mCoapMessages, bufferInfo.mCoapBuffers);
mServer->OutputFormat("coap secure: %d %d\r\n", bufferInfo.mCoapSecureMessages, bufferInfo.mCoapSecureBuffers);
mServer->OutputFormat("application coap: %d %d\r\n", bufferInfo.mApplicationCoapMessages,
bufferInfo.mApplicationCoapBuffers);
AppendResult(OT_ERROR_NONE);
}
+16
View File
@@ -152,6 +152,8 @@ exit:
void otMessageGetBufferInfo(otInstance *aInstance, otBufferInfo *aBufferInfo)
{
uint16_t messages, buffers;
aBufferInfo->mTotalBuffers = OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS;
aBufferInfo->mFreeBuffers = aInstance->mMessagePool.GetFreeBufferCount();
@@ -176,4 +178,18 @@ void otMessageGetBufferInfo(otInstance *aInstance, otBufferInfo *aBufferInfo)
aInstance->mThreadNetif.GetCoap().GetRequestMessages().GetInfo(aBufferInfo->mCoapMessages,
aBufferInfo->mCoapBuffers);
aInstance->mThreadNetif.GetCoap().GetCachedResponses().GetInfo(messages, buffers);
aBufferInfo->mCoapMessages += messages;
aBufferInfo->mCoapBuffers += buffers;
#if OPENTHREAD_ENABLE_APPLICATION_COAP
aInstance->mApplicationCoap.GetRequestMessages().GetInfo(aBufferInfo->mApplicationCoapMessages,
aBufferInfo->mApplicationCoapBuffers);
aInstance->mApplicationCoap.GetCachedResponses().GetInfo(messages, buffers);
aBufferInfo->mApplicationCoapMessages += messages;
aBufferInfo->mApplicationCoapBuffers += buffers;
#else
aBufferInfo->mApplicationCoapMessages = 0;
aBufferInfo->mApplicationCoapBuffers = 0;
#endif
}