From fc73bc35ef0ff6ddb9b3e6414ccf2b530ba2cdbf Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Wed, 16 Nov 2016 17:41:41 +0800 Subject: [PATCH] Fix an incorrect Tlv append operation and Dump output JOIN_FIN.req (#978) * Fix an incorrect Tlv append operation in Joiner::SendJoinerFinalize() * Dump output JOIN_FIN.req for certification test --- src/core/common/message.cpp | 1 - src/core/meshcop/commissioner.cpp | 9 ++++++++- src/core/meshcop/joiner.cpp | 11 +++++++++-- src/core/meshcop/joiner_router.cpp | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/core/common/message.cpp b/src/core/common/message.cpp index b53abba4a..670c5d800 100644 --- a/src/core/common/message.cpp +++ b/src/core/common/message.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include namespace Thread { diff --git a/src/core/meshcop/commissioner.cpp b/src/core/meshcop/commissioner.cpp index 6635b9d6a..3b0728961 100644 --- a/src/core/meshcop/commissioner.cpp +++ b/src/core/meshcop/commissioner.cpp @@ -799,7 +799,14 @@ void Commissioner::HandleJoinerFinalize(Coap::Header &aHeader, Message &aMessage } } - otLogCertMeshCoP("[THCI] direction=recv | type=JOIN_FIN.req"); +#if OPENTHREAD_ENABLE_CERT_LOG + uint8_t buf[OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE]; + VerifyOrExit(aMessage.GetLength() <= sizeof(buf), ;); + aMessage.Read(aHeader.GetLength(), aMessage.GetLength() - aHeader.GetLength(), buf); + otDumpCertMeshCoP("[THCI] direction=recv | type=JOIN_FIN.req |", buf, aMessage.GetLength() - aHeader.GetLength()); + +exit: +#endif SendJoinFinalizeResponse(aHeader, state); diff --git a/src/core/meshcop/joiner.cpp b/src/core/meshcop/joiner.cpp index b3d2b2091..7a4a646dd 100644 --- a/src/core/meshcop/joiner.cpp +++ b/src/core/meshcop/joiner.cpp @@ -207,13 +207,20 @@ void Joiner::SendJoinerFinalize(void) if (length > 0) { - SuccessOrExit(error = message->Append(&stateTlv, length + sizeof(Tlv))); + SuccessOrExit(error = message->Append(&mSecureCoapClient.GetDtls().mProvisioningUrl, length + sizeof(Tlv))); } +#if OPENTHREAD_ENABLE_CERT_LOG + uint8_t buf[OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE]; + VerifyOrExit(message->GetLength() <= sizeof(buf), ;); + message->Read(header.GetLength(), message->GetLength() - header.GetLength(), buf); + otDumpCertMeshCoP("[THCI] direction=send | type=JOIN_FIN.req |", buf, message->GetLength() - header.GetLength()); +#endif + mSecureCoapClient.SendMessage(*message, Joiner::HandleJoinerFinalizeResponse, this); otLogInfoMeshCoP("Sent joiner finalize"); - otLogCertMeshCoP("[THCI] direction=send | type=JOIN_FIN.req"); + exit: if (error != kThreadError_None && message != NULL) diff --git a/src/core/meshcop/joiner_router.cpp b/src/core/meshcop/joiner_router.cpp index f9aa66846..977ddd53b 100644 --- a/src/core/meshcop/joiner_router.cpp +++ b/src/core/meshcop/joiner_router.cpp @@ -419,7 +419,7 @@ ThreadError JoinerRouter::SendJoinerEntrust(const Ip6::MessageInfo &aMessageInfo SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo)); otLogInfoMeshCoP("Sent joiner entrust length = %d", message->GetLength()); - otLogCertMeshCoP("[THCI] direction=send | msg_type=JOIN_ENT.ntf"); + otLogCertMeshCoP("[THCI] direction=send | type=JOIN_ENT.ntf"); exit: