mirror of
https://github.com/espressif/openthread.git
synced 2026-08-04 18:07:47 +00:00
Some Logging Cleanup (#810)
* Remove unnecessary WPP definition. * Various other small fixes.
This commit is contained in:
@@ -66,9 +66,9 @@
|
||||
#define PLATFORM_INFO "Windows"
|
||||
|
||||
// Windows Kernel only has sprintf_s
|
||||
#ifdef WINDOWS_KERNEL
|
||||
#ifdef _KERNEL_MODE
|
||||
#define snprintf sprintf_s
|
||||
#endif // WINDOWS_KERNEL
|
||||
#endif // _KERNEL_MODE
|
||||
|
||||
// Redefine rand to random for test code
|
||||
#define random rand
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#ifndef _LOGGING_WINDOWS_H
|
||||
#define _LOGGING_WINDOWS_H
|
||||
|
||||
#define OPENTHREAD_ENABLE_CERT_LOG 1
|
||||
|
||||
//
|
||||
// Tracing Definitions: {1AA98926-2E40-43D1-9D83-34C6BE816365}
|
||||
//
|
||||
@@ -57,6 +59,9 @@
|
||||
WPP_DEFINE_BIT(OT_NCP) /* 0x00001000 */ \
|
||||
WPP_DEFINE_BIT(OT_COAP) /* 0x00002000 */ \
|
||||
WPP_DEFINE_BIT(OT_DEFAULT) /* 0x00004000 */ \
|
||||
WPP_DEFINE_BIT(OT_MBEDTLS) /* 0x00008000 */ \
|
||||
WPP_DEFINE_BIT(OT_DUMP) /* 0x00010000 */ \
|
||||
WPP_DEFINE_BIT(OT_NDIAG) /* 0x00020000 */ \
|
||||
)
|
||||
|
||||
#define WPP_LEVEL_FLAGS_LOGGER(lvl,flag) \
|
||||
@@ -85,65 +90,60 @@
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (TraceEvents, "%!STDPREFIX!%!SPACE!");
|
||||
// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX(LogFuncEntry, "%!STDPREFIX! ---> %!FUNC!");
|
||||
// USEPREFIX(LogFuncEntry, "---> %!FUNC!");
|
||||
// FUNC LogFuncEntry{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX(LogFuncEntryMsg, "%!STDPREFIX! ---> %!FUNC!%!SPACE!");
|
||||
// USEPREFIX(LogFuncEntryMsg, "---> %!FUNC!%!SPACE!");
|
||||
// FUNC LogFuncEntryMsg{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS, MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX(LogFuncExit, "%!STDPREFIX! <--- %!FUNC!");
|
||||
// USEPREFIX(LogFuncExit, "<--- %!FUNC!");
|
||||
// FUNC LogFuncExit{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX(LogFuncExitMsg, "%!STDPREFIX! <--- %!FUNC!%!SPACE!");
|
||||
// USEPREFIX(LogFuncExitMsg, "<--- %!FUNC!%!SPACE!");
|
||||
// FUNC LogFuncExitMsg{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS, MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX(LogFuncExitNT, "%!STDPREFIX! <--- %!FUNC!");
|
||||
// USEPREFIX(LogFuncExitNT, "<--- %!FUNC!");
|
||||
// FUNC LogFuncExitNT{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS, EXP);
|
||||
// USESUFFIX(LogFuncExitNT, " %!STATUS!", EXP);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX(LogFuncExitNDIS, "%!STDPREFIX! <--- %!FUNC!");
|
||||
// USEPREFIX(LogFuncExitNDIS, "<--- %!FUNC!");
|
||||
// FUNC LogFuncExitNDIS{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS, EXP);
|
||||
// USESUFFIX(LogFuncExitNDIS, " %!NDIS_STATUS!", EXP);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX(LogFuncExitWIN, "%!STDPREFIX! <--- %!FUNC!");
|
||||
// USEPREFIX(LogFuncExitWIN, "<--- %!FUNC!");
|
||||
// FUNC LogFuncExitWIN{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS, EXP);
|
||||
// USESUFFIX(LogFuncExitWIN, " %!WINERROR!", EXP);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (LogError, "%!STDPREFIX!%!SPACE!");
|
||||
// LogError{LEVEL=TRACE_LEVEL_ERROR}(FLAGS, MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (LogWarning, "%!STDPREFIX!%!SPACE!");
|
||||
// LogWarning{LEVEL=TRACE_LEVEL_WARNING}(FLAGS, MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (LogInfo, "%!STDPREFIX!%!SPACE!");
|
||||
// LogInfo{LEVEL=TRACE_LEVEL_INFORMATION}(FLAGS, MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (LogVerbose, "%!STDPREFIX!%!SPACE!");
|
||||
// LogVerbose{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS, MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
@@ -163,247 +163,314 @@
|
||||
// ==API==
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogCritApi, "%!STDPREFIX!%!SPACE!API%!SPACE!");
|
||||
// USEPREFIX (otLogCritApi, "API%!SPACE!");
|
||||
// otLogCritApi{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_API}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogWarnApi, "%!STDPREFIX!%!SPACE!API%!SPACE!");
|
||||
// USEPREFIX (otLogWarnApi, "API%!SPACE!");
|
||||
// otLogWarnApi{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_API}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogInfoApi, "%!STDPREFIX!%!SPACE!API%!SPACE!");
|
||||
// USEPREFIX (otLogInfoApi, "API%!SPACE!");
|
||||
// otLogInfoApi{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_API}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogDebgApi, "%!STDPREFIX!%!SPACE!API%!SPACE!");
|
||||
// USEPREFIX (otLogDebgApi, "API%!SPACE!");
|
||||
// otLogDebgApi{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_API}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// ==NCP==
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogCritNcp, "%!STDPREFIX!%!SPACE!NCP%!SPACE!");
|
||||
// USEPREFIX (otLogCritNcp, "NCP%!SPACE!");
|
||||
// otLogCritNcp{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_NCP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogWarnNcp, "%!STDPREFIX!%!SPACE!NCP%!SPACE!");
|
||||
// USEPREFIX (otLogWarnNcp, "NCP%!SPACE!");
|
||||
// otLogWarnNcp{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_NCP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogInfoNcp, "%!STDPREFIX!%!SPACE!NCP%!SPACE!");
|
||||
// USEPREFIX (otLogInfoNcp, "NCP%!SPACE!");
|
||||
// otLogInfoNcp{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_NCP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogDebgNcp, "%!STDPREFIX!%!SPACE!NCP%!SPACE!");
|
||||
// USEPREFIX (otLogDebgNcp, "NCP%!SPACE!");
|
||||
// otLogDebgNcp{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_NCP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// ==COAP==
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogCritMeshCoP, "%!STDPREFIX!%!SPACE!COAP%!SPACE!");
|
||||
// USEPREFIX (otLogCritMeshCoP, "COAP%!SPACE!");
|
||||
// otLogCritMeshCoP{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_COAP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogWarnMeshCoP, "%!STDPREFIX!%!SPACE!COAP%!SPACE!");
|
||||
// USEPREFIX (otLogWarnMeshCoP, "COAP%!SPACE!");
|
||||
// otLogWarnMeshCoP{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_COAP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogInfoMeshCoP, "%!STDPREFIX!%!SPACE!COAP%!SPACE!");
|
||||
// USEPREFIX (otLogInfoMeshCoP, "COAP%!SPACE!");
|
||||
// otLogInfoMeshCoP{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_COAP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogDebgMeshCoP, "%!STDPREFIX!%!SPACE!COAP%!SPACE!");
|
||||
// USEPREFIX (otLogDebgMeshCoP, "COAP%!SPACE!");
|
||||
// otLogDebgMeshCoP{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_COAP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogCertMeshCoP, "COAP%!SPACE!");
|
||||
// otLogCertMeshCoP{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_COAP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// ==MBEDTLS==
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogCritMbedTls, "MBED%!SPACE!");
|
||||
// otLogCritMbedTls{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_MBEDTLS}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogWarnMbedTls, "MBED%!SPACE!");
|
||||
// otLogWarnMbedTls{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_MBEDTLS}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogInfoMbedTls, "MBED%!SPACE!");
|
||||
// otLogInfoMbedTls{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_MBEDTLS}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogDebgMbedTls, "MBED%!SPACE!");
|
||||
// otLogDebgMbedTls{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MBEDTLS}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// ==MLE==
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogCritMle, "%!STDPREFIX!%!SPACE!MLE%!SPACE!");
|
||||
// USEPREFIX (otLogCritMle, "MLE%!SPACE!");
|
||||
// otLogCritMle{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_MLE}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogWarnMle, "%!STDPREFIX!%!SPACE!MLE%!SPACE!");
|
||||
// USEPREFIX (otLogWarnMle, "MLE%!SPACE!");
|
||||
// otLogWarnMle{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_MLE}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogInfoMle, "%!STDPREFIX!%!SPACE!MLE%!SPACE!");
|
||||
// USEPREFIX (otLogWarnMleErr, "MLE%!SPACE!");
|
||||
// otLogWarnMleErr{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_MLE}(EXP, MSG, ...);
|
||||
// USESUFFIX(otLogWarnMleErr, ", %!otError!", EXP);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogInfoMle, "MLE%!SPACE!");
|
||||
// otLogInfoMle{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_MLE}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogDebgMle, "%!STDPREFIX!%!SPACE!MLE%!SPACE!");
|
||||
// USEPREFIX (otLogDebgMle, "MLE%!SPACE!");
|
||||
// otLogDebgMle{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MLE}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// ==ARP==
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogCritArp, "%!STDPREFIX!%!SPACE!ARP%!SPACE!");
|
||||
// USEPREFIX (otLogCritArp, "ARP%!SPACE!");
|
||||
// otLogCritArp{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_ARP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogWarnArp, "%!STDPREFIX!%!SPACE!ARP%!SPACE!");
|
||||
// USEPREFIX (otLogWarnArp, "ARP%!SPACE!");
|
||||
// otLogWarnArp{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_ARP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogInfoArp, "%!STDPREFIX!%!SPACE!ARP%!SPACE!");
|
||||
// USEPREFIX (otLogInfoArp, "ARP%!SPACE!");
|
||||
// otLogInfoArp{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_ARP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogDebgArp, "%!STDPREFIX!%!SPACE!ARP%!SPACE!");
|
||||
// USEPREFIX (otLogDebgArp, "ARP%!SPACE!");
|
||||
// otLogDebgArp{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_ARP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// ==NETD==
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogCritNetData, "%!STDPREFIX!%!SPACE!NETD%!SPACE!");
|
||||
// USEPREFIX (otLogCritNetData, "NETD%!SPACE!");
|
||||
// otLogCritNetData{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_NETD}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogWarnNetData, "%!STDPREFIX!%!SPACE!NETD%!SPACE!");
|
||||
// USEPREFIX (otLogWarnNetData, "NETD%!SPACE!");
|
||||
// otLogWarnNetData{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_NETD}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogInfoNetData, "%!STDPREFIX!%!SPACE!NETD%!SPACE!");
|
||||
// USEPREFIX (otLogInfoNetData, "NETD%!SPACE!");
|
||||
// otLogInfoNetData{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_NETD}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogDebgNetData, "%!STDPREFIX!%!SPACE!NETD%!SPACE!");
|
||||
// USEPREFIX (otLogDebgNetData, "NETD%!SPACE!");
|
||||
// otLogDebgNetData{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_NETD}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// ==ICMP==
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogCritIcmp, "%!STDPREFIX!%!SPACE!ICMP%!SPACE!");
|
||||
// USEPREFIX (otLogCritIcmp, "ICMP%!SPACE!");
|
||||
// otLogCritIcmp{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_ICMP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogWarnIcmp, "%!STDPREFIX!%!SPACE!ICMP%!SPACE!");
|
||||
// USEPREFIX (otLogWarnIcmp, "ICMP%!SPACE!");
|
||||
// otLogWarnIcmp{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_ICMP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogInfoIcmp, "%!STDPREFIX!%!SPACE!ICMP%!SPACE!");
|
||||
// USEPREFIX (otLogInfoIcmp, "ICMP%!SPACE!");
|
||||
// otLogInfoIcmp{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_ICMP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogDebgIcmp, "%!STDPREFIX!%!SPACE!ICMP%!SPACE!");
|
||||
// USEPREFIX (otLogDebgIcmp, "ICMP%!SPACE!");
|
||||
// otLogDebgIcmp{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_ICMP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// ==IPV6==
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogCritIp6, "%!STDPREFIX!%!SPACE!IPV6%!SPACE!");
|
||||
// USEPREFIX (otLogCritIp6, "IPV6%!SPACE!");
|
||||
// otLogCritIp6{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_IPV6}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogWarnIp6, "%!STDPREFIX!%!SPACE!IPV6%!SPACE!");
|
||||
// USEPREFIX (otLogWarnIp6, "IPV6%!SPACE!");
|
||||
// otLogWarnIp6{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_IPV6}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogInfoIp6, "%!STDPREFIX!%!SPACE!IPV6%!SPACE!");
|
||||
// USEPREFIX (otLogInfoIp6, "IPV6%!SPACE!");
|
||||
// otLogInfoIp6{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_IPV6}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogDebgIp6, "%!STDPREFIX!%!SPACE!IPV6%!SPACE!");
|
||||
// USEPREFIX (otLogDebgIp6, "IPV6%!SPACE!");
|
||||
// otLogDebgIp6{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_IPV6}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// ==MAC==
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogCritMac, "%!STDPREFIX!%!SPACE!MAC%!SPACE!");
|
||||
// USEPREFIX (otLogCritMac, "MAC%!SPACE!");
|
||||
// otLogCritMac{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_MAC}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogWarnMac, "%!STDPREFIX!%!SPACE!MAC%!SPACE!");
|
||||
// USEPREFIX (otLogWarnMac, "MAC%!SPACE!");
|
||||
// otLogWarnMac{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_MAC}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogInfoMac, "%!STDPREFIX!%!SPACE!MAC%!SPACE!");
|
||||
// USEPREFIX (otLogInfoMac, "MAC%!SPACE!");
|
||||
// otLogInfoMac{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_MAC}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogDebgMac, "%!STDPREFIX!%!SPACE!MAC%!SPACE!");
|
||||
// USEPREFIX (otLogDebgMac, "MAC%!SPACE!");
|
||||
// otLogDebgMac{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MAC}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogDebgMacErr, "MAC%!SPACE!");
|
||||
// otLogDebgMacErr{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MAC}(EXP, MSG, ...);
|
||||
// USESUFFIX(otLogDebgMacErr, ", %!otError!", EXP);
|
||||
// end_wpp
|
||||
|
||||
// ==MEM==
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogCritMem, "%!STDPREFIX!%!SPACE!MEM%!SPACE!");
|
||||
// USEPREFIX (otLogCritMem, "MEM%!SPACE!");
|
||||
// otLogCritMem{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_MEM}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogWarnMem, "%!STDPREFIX!%!SPACE!MEM%!SPACE!");
|
||||
// USEPREFIX (otLogWarnMem, "MEM%!SPACE!");
|
||||
// otLogWarnMem{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_MEM}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogInfoMem, "%!STDPREFIX!%!SPACE!MEM%!SPACE!");
|
||||
// USEPREFIX (otLogInfoMem, "MEM%!SPACE!");
|
||||
// otLogInfoMem{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_MEM}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogDebgMem, "%!STDPREFIX!%!SPACE!MEM%!SPACE!");
|
||||
// USEPREFIX (otLogDebgMem, "MEM%!SPACE!");
|
||||
// otLogDebgMem{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MEM}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// ==DUMP==
|
||||
|
||||
// begin_wpp config
|
||||
// otLogDump{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_DUMP}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// ==MEM==
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogCritNetDiag, "NETDIAG%!SPACE!");
|
||||
// otLogCritNetDiag{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_NDIAG}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogWarnNetDiag, "NETDIAG%!SPACE!");
|
||||
// otLogWarnNetDiag{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_NDIAG}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogInfoNetDiag, "NETDIAG%!SPACE!");
|
||||
// otLogInfoNetDiag{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_NDIAG}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX (otLogDebgNetDiag, "NETDIAG%!SPACE!");
|
||||
// otLogDebgNetDiag{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_NDIAG}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// ==FUNC==
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX(otLogFuncEntry, "%!STDPREFIX! ---> %!FUNC!");
|
||||
// USEPREFIX(otLogFuncEntry, "---> %!FUNC!");
|
||||
// FUNC otLogFuncEntry{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_DEFAULT}(...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX(otLogFuncEntryMsg, "%!STDPREFIX! ---> %!FUNC!%!SPACE!");
|
||||
// USEPREFIX(otLogFuncEntryMsg, "---> %!FUNC!%!SPACE!");
|
||||
// FUNC otLogFuncEntryMsg{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_DEFAULT}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX(otLogFuncExit, "%!STDPREFIX! <--- %!FUNC!");
|
||||
// USEPREFIX(otLogFuncExit, "<--- %!FUNC!");
|
||||
// FUNC otLogFuncExit{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_DEFAULT}(...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX(otLogFuncExitMsg, "%!STDPREFIX! <--- %!FUNC!%!SPACE!");
|
||||
// USEPREFIX(otLogFuncExitMsg, "<--- %!FUNC!%!SPACE!");
|
||||
// FUNC otLogFuncExitMsg{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_DEFAULT}(MSG, ...);
|
||||
// end_wpp
|
||||
|
||||
// begin_wpp config
|
||||
// USEPREFIX(otLogFuncExitErr, "%!STDPREFIX! <--- %!FUNC!");
|
||||
// USEPREFIX(otLogFuncExitErr, "<--- %!FUNC!");
|
||||
// FUNC otLogFuncExitErr{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_DEFAULT}(EXP);
|
||||
// USESUFFIX(otLogFuncExitErr, " %!otError!", EXP);
|
||||
// end_wpp
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#elif defined(WINDOWS_KERNEL)
|
||||
#elif defined(_KERNEL_MODE)
|
||||
|
||||
#include <wdm.h>
|
||||
|
||||
|
||||
@@ -31,17 +31,19 @@
|
||||
* This file implements the tasklet scheduler.
|
||||
*/
|
||||
|
||||
#define WPP_NAME "logging.tmh"
|
||||
|
||||
#ifdef OPENTHREAD_CONFIG_FILE
|
||||
#include OPENTHREAD_CONFIG_FILE
|
||||
#else
|
||||
#include <openthread-config.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <common/logging.hpp>
|
||||
|
||||
#include <platform/logging.h>
|
||||
#ifndef WINDOWS_LOGGING
|
||||
#define otLogDump(aFormat, ...) otPlatLog(aLogLevel, aLogRegion, aFormat, ## __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -103,7 +105,7 @@ static void DumpLine(otLogLevel aLogLevel, otLogRegion aLogRegion, const void *a
|
||||
}
|
||||
}
|
||||
|
||||
otPlatLog(aLogLevel, aLogRegion, "%s\r\n", buf);
|
||||
otLogDump("%s\n", buf);
|
||||
}
|
||||
|
||||
void otDump(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aId, const void *aBuf, const size_t aLength)
|
||||
@@ -113,7 +115,9 @@ void otDump(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aId, const
|
||||
char buf[80];
|
||||
char *cur = buf;
|
||||
|
||||
otPlatLog(aLogLevel, aLogRegion, "\r\n");
|
||||
#ifndef WINDOWS_LOGGING
|
||||
otLogDump("\n");
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < (width - idlen) / 2 - 5; i++)
|
||||
{
|
||||
@@ -130,7 +134,7 @@ void otDump(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aId, const
|
||||
cur += strlen(cur);
|
||||
}
|
||||
|
||||
otPlatLog(aLogLevel, aLogRegion, "%s\r\n", buf);
|
||||
otLogDump("%s\n", buf);
|
||||
|
||||
for (size_t i = 0; i < aLength; i += 16)
|
||||
{
|
||||
@@ -145,7 +149,7 @@ void otDump(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aId, const
|
||||
cur += strlen(cur);
|
||||
}
|
||||
|
||||
otPlatLog(aLogLevel, aLogRegion, "%s\r\n", buf);
|
||||
otLogDump("%s\n", buf);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
+77
-68
@@ -42,7 +42,7 @@
|
||||
#include <platform/logging.h>
|
||||
|
||||
#ifdef WINDOWS_LOGGING
|
||||
#ifdef WINDOWS_KERNEL
|
||||
#ifdef _KERNEL_MODE
|
||||
#include <wdm.h>
|
||||
#endif
|
||||
#include <platform/logging-windows.h>
|
||||
@@ -231,6 +231,11 @@ extern "C" {
|
||||
#define otLogDebgMeshCoP(aFormat, ...)
|
||||
#endif
|
||||
|
||||
#define otLogCritMbedTls(aFormat, ...) otLogCritMeshCoP(aFormat, ## __VA_ARGS__)
|
||||
#define otLogWarnMbedTls(aFormat, ...) otLogWarnMeshCoP(aFormat, ## __VA_ARGS__)
|
||||
#define otLogInfoMbedTls(aFormat, ...) otLogInfoMeshCoP(aFormat, ## __VA_ARGS__)
|
||||
#define otLogDebgMbedTls(aFormat, ...) otLogDebgMeshCoP(aFormat, ## __VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @def otLogCritMle
|
||||
*
|
||||
@@ -273,11 +278,13 @@ extern "C" {
|
||||
#ifdef OPENTHREAD_CONFIG_LOG_MLE
|
||||
#define otLogCritMle(aFormat, ...) otLogCrit(kLogRegionMle, aFormat, ## __VA_ARGS__)
|
||||
#define otLogWarnMle(aFormat, ...) otLogWarn(kLogRegionMle, aFormat, ## __VA_ARGS__)
|
||||
#define otLogWarnMleErr(aError, aFormat, ...) otLogWarn(kLogRegionMle, aFormat ", 0x%x\n", ## __VA_ARGS__)
|
||||
#define otLogInfoMle(aFormat, ...) otLogInfo(kLogRegionMle, aFormat, ## __VA_ARGS__)
|
||||
#define otLogDebgMle(aFormat, ...) otLogDebg(kLogRegionMle, aFormat, ## __VA_ARGS__)
|
||||
#else
|
||||
#define otLogCritMle(aFormat, ...)
|
||||
#define otLogWarnMle(aFormat, ...)
|
||||
#define otLogWarnMleErr(aError, aFormat, ...)
|
||||
#define otLogInfoMle(aFormat, ...)
|
||||
#define otLogDebgMle(aFormat, ...)
|
||||
#endif
|
||||
@@ -530,11 +537,13 @@ extern "C" {
|
||||
#define otLogWarnMac(aFormat, ...) otLogWarn(kLogRegionMac, aFormat, ## __VA_ARGS__)
|
||||
#define otLogInfoMac(aFormat, ...) otLogInfo(kLogRegionMac, aFormat, ## __VA_ARGS__)
|
||||
#define otLogDebgMac(aFormat, ...) otLogDebg(kLogRegionMac, aFormat, ## __VA_ARGS__)
|
||||
#define otLogDebgMacErr(aError, aFormat, ...) otLogWarn(kLogRegionMac, aFormat ", 0x%x\n", ## __VA_ARGS__)
|
||||
#else
|
||||
#define otLogCritMac(aFormat, ...)
|
||||
#define otLogWarnMac(aFormat, ...)
|
||||
#define otLogInfoMac(aFormat, ...)
|
||||
#define otLogDebgMac(aFormat, ...)
|
||||
#define otLogDebgMacErr(aError, aFormat, ...)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -588,6 +597,72 @@ extern "C" {
|
||||
#define otLogDebgMem(aFormat, ...)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def otLogCritNetDiag
|
||||
*
|
||||
* This method generates a log with level critical for the NETDIAG region.
|
||||
*
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def otLogWarnNetDiag
|
||||
*
|
||||
* This method generates a log with level warning for the NETDIAG region.
|
||||
*
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def otLogInfoNetDiag
|
||||
*
|
||||
* This method generates a log with level info for the NETDIAG region.
|
||||
*
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def otLogDebgNetDiag
|
||||
*
|
||||
* This method generates a log with level debug for the NETDIAG region.
|
||||
*
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
#ifdef OPENTHREAD_CONFIG_LOG_NETDIAG
|
||||
#define otLogCritNetDiag(aFormat, ...) otLogCrit(kLogRegionNetDiag, aFormat, ## __VA_ARGS__)
|
||||
#define otLogWarnNetDiag(aFormat, ...) otLogWarn(kLogRegionNetDiag, aFormat, ## __VA_ARGS__)
|
||||
#define otLogInfoNetDiag(aFormat, ...) otLogInfo(kLogRegionNetDiag, aFormat, ## __VA_ARGS__)
|
||||
#define otLogDebgNetDiag(aFormat, ...) otLogDebg(kLogRegionNetDiag, aFormat, ## __VA_ARGS__)
|
||||
#else
|
||||
#define otLogCritNetDiag(aFormat, ...)
|
||||
#define otLogWarnNetDiag(aFormat, ...)
|
||||
#define otLogInfoNetDiag(aFormat, ...)
|
||||
#define otLogDebgNetDiag(aFormat, ...)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def otLogCert
|
||||
*
|
||||
* This method generates a log with level none for the certification test.
|
||||
*
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
#if OPENTHREAD_ENABLE_CERT_LOG
|
||||
#define otLogCertMeshCoP(aFormat, ...) otPlatLog(kLogLevelNone, kLogRegionMeshCoP, aFormat, ## __VA_ARGS__)
|
||||
#else
|
||||
#define otLogCertMeshCoP(aFormat, ...)
|
||||
#endif
|
||||
|
||||
#endif // WINDOWS_LOGGING
|
||||
|
||||
/**
|
||||
@@ -1043,72 +1118,6 @@ extern "C" {
|
||||
#define otDumpDebgMem(aId, aBuf, aLength)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def otLogCritNetDiag
|
||||
*
|
||||
* This method generates a log with level critical for the NETDIAG region.
|
||||
*
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def otLogWarnNetDiag
|
||||
*
|
||||
* This method generates a log with level warning for the NETDIAG region.
|
||||
*
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def otLogInfoNetDiag
|
||||
*
|
||||
* This method generates a log with level info for the NETDIAG region.
|
||||
*
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def otLogDebgNetDiag
|
||||
*
|
||||
* This method generates a log with level debug for the NETDIAG region.
|
||||
*
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
#ifdef OPENTHREAD_CONFIG_LOG_NETDIAG
|
||||
#define otLogCritNetDiag(aFormat, ...) otLogCrit(kLogRegionNetDiag, aFormat, ## __VA_ARGS__)
|
||||
#define otLogWarnNetDiag(aFormat, ...) otLogWarn(kLogRegionNetDiag, aFormat, ## __VA_ARGS__)
|
||||
#define otLogInfoNetDiag(aFormat, ...) otLogInfo(kLogRegionNetDiag, aFormat, ## __VA_ARGS__)
|
||||
#define otLogDebgNetDiag(aFormat, ...) otLogDebg(kLogRegionNetDiag, aFormat, ## __VA_ARGS__)
|
||||
#else
|
||||
#define otLogCritNetDiag(aFormat, ...)
|
||||
#define otLogWarnNetDiag(aFormat, ...)
|
||||
#define otLogInfoNetDiag(aFormat, ...)
|
||||
#define otLogDebgNetDiag(aFormat, ...)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def otLogCert
|
||||
*
|
||||
* This method generates a log with level none for the certification test.
|
||||
*
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
#if OPENTHREAD_ENABLE_CERT_LOG
|
||||
#define otLogCertMeshCoP(aFormat, ...) otPlatLog(kLogLevelNone, kLogRegionMeshCoP, aFormat, ## __VA_ARGS__)
|
||||
#else
|
||||
#define otLogCertMeshCoP(aFormat, ...)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def otDumpCert
|
||||
*
|
||||
@@ -1135,7 +1144,7 @@ extern "C" {
|
||||
* @param[in] aLength Number of bytes to print.
|
||||
*
|
||||
*/
|
||||
void otDump(otLogLevel aLevel, otLogRegion aRegion, const char *aId, const void *aBuf, const int aLength);
|
||||
void otDump(otLogLevel aLevel, otLogRegion aRegion, const char *aId, const void *aBuf, const size_t aLength);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
||||
@@ -44,6 +44,9 @@ namespace Thread {
|
||||
|
||||
MessagePool::MessagePool(void)
|
||||
{
|
||||
memset(mBuffers, 0, sizeof(mBuffers));
|
||||
memset(&mAll, 0, sizeof(mAll));
|
||||
|
||||
mFreeBuffers = mBuffers;
|
||||
|
||||
for (int i = 0; i < kNumBuffers - 1; i++)
|
||||
@@ -209,7 +212,7 @@ ThreadError Message::MoveOffset(int aDelta)
|
||||
assert(GetOffset() + aDelta <= GetLength());
|
||||
VerifyOrExit(GetOffset() + aDelta <= GetLength(), error = kThreadError_InvalidArgs);
|
||||
|
||||
mInfo.mOffset += static_cast<uint16_t>(aDelta);
|
||||
mInfo.mOffset += static_cast<int16_t>(aDelta);
|
||||
assert(mInfo.mOffset <= GetLength());
|
||||
|
||||
exit:
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
* This file implements a multiplexed timer service on top of the alarm abstraction.
|
||||
*/
|
||||
|
||||
#define WPP_NAME "timer.tmh"
|
||||
|
||||
#include <common/code_utils.hpp>
|
||||
#include <common/timer.hpp>
|
||||
#include <common/debug.hpp>
|
||||
@@ -148,7 +150,9 @@ void TimerScheduler::SetAlarm(void)
|
||||
|
||||
extern "C" void otPlatAlarmFired(otInstance *aInstance)
|
||||
{
|
||||
otLogFuncEntry();
|
||||
aInstance->mIp6.mTimerScheduler.FireTimers();
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void TimerScheduler::FireTimers()
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
#include <common/code_utils.hpp>
|
||||
#include <common/debug.hpp>
|
||||
#include <common/encoding.hpp>
|
||||
#include <common/logging.hpp>
|
||||
#include <crypto/aes_ccm.hpp>
|
||||
#include <crypto/sha256.hpp>
|
||||
@@ -53,6 +54,8 @@
|
||||
#include <thread/thread_netif.hpp>
|
||||
#include <openthread-instance.h>
|
||||
|
||||
using Thread::Encoding::BigEndian::HostSwap64;
|
||||
|
||||
namespace Thread {
|
||||
namespace Mac {
|
||||
|
||||
@@ -353,6 +356,8 @@ void Mac::SetExtAddress(const ExtAddress &aExtAddress)
|
||||
{
|
||||
uint8_t buf[sizeof(aExtAddress)];
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
for (size_t i = 0; i < sizeof(buf); i++)
|
||||
{
|
||||
buf[i] = aExtAddress.m8[7 - i];
|
||||
@@ -360,6 +365,8 @@ void Mac::SetExtAddress(const ExtAddress &aExtAddress)
|
||||
|
||||
otPlatRadioSetExtendedAddress(mNetif.GetInstance(), buf);
|
||||
mExtAddress = aExtAddress;
|
||||
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void Mac::GetHashMacAddress(ExtAddress *aHashMacAddress)
|
||||
@@ -367,6 +374,8 @@ void Mac::GetHashMacAddress(ExtAddress *aHashMacAddress)
|
||||
Crypto::Sha256 sha256;
|
||||
uint8_t buf[Crypto::Sha256::kHashSize];
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
otPlatRadioGetIeeeEui64(mNetif.GetInstance(), buf);
|
||||
sha256.Start();
|
||||
sha256.Update(buf, OT_EXT_ADDRESS_SIZE);
|
||||
@@ -374,6 +383,8 @@ void Mac::GetHashMacAddress(ExtAddress *aHashMacAddress)
|
||||
|
||||
memcpy(aHashMacAddress->m8, buf, OT_EXT_ADDRESS_SIZE);
|
||||
aHashMacAddress->SetLocal(true);
|
||||
|
||||
otLogFuncExitMsg("%llX", HostSwap64(*reinterpret_cast<uint64_t *>(aHashMacAddress)));
|
||||
}
|
||||
|
||||
ShortAddress Mac::GetShortAddress(void) const
|
||||
@@ -383,8 +394,10 @@ ShortAddress Mac::GetShortAddress(void) const
|
||||
|
||||
ThreadError Mac::SetShortAddress(ShortAddress aShortAddress)
|
||||
{
|
||||
otLogFuncEntryMsg("%d", aShortAddress);
|
||||
mShortAddress = aShortAddress;
|
||||
otPlatRadioSetShortAddress(mNetif.GetInstance(), aShortAddress);
|
||||
otLogFuncExit();
|
||||
return kThreadError_None;
|
||||
}
|
||||
|
||||
@@ -395,6 +408,7 @@ uint8_t Mac::GetChannel(void) const
|
||||
|
||||
ThreadError Mac::SetChannel(uint8_t aChannel)
|
||||
{
|
||||
otLogFuncEntryMsg("%d", aChannel);
|
||||
mChannel = aChannel;
|
||||
|
||||
if (mState == kStateIdle)
|
||||
@@ -402,6 +416,7 @@ ThreadError Mac::SetChannel(uint8_t aChannel)
|
||||
NextOperation();
|
||||
}
|
||||
|
||||
otLogFuncExit();
|
||||
return kThreadError_None;
|
||||
}
|
||||
|
||||
@@ -424,12 +439,15 @@ ThreadError Mac::SetNetworkName(const char *aNetworkName)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
otLogFuncEntryMsg("%s", aNetworkName);
|
||||
|
||||
VerifyOrExit(strlen(aNetworkName) <= OT_NETWORK_NAME_MAX_SIZE, error = kThreadError_InvalidArgs);
|
||||
|
||||
memset(&mNetworkName, 0, sizeof(mNetworkName));
|
||||
strncpy(mNetworkName.m8, aNetworkName, sizeof(mNetworkName));
|
||||
|
||||
exit:
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -440,8 +458,10 @@ PanId Mac::GetPanId(void) const
|
||||
|
||||
ThreadError Mac::SetPanId(PanId aPanId)
|
||||
{
|
||||
otLogFuncEntryMsg("%d", aPanId);
|
||||
mPanId = aPanId;
|
||||
otPlatRadioSetPanId(mNetif.GetInstance(), mPanId);
|
||||
otLogFuncExit();
|
||||
return kThreadError_None;
|
||||
}
|
||||
|
||||
@@ -748,7 +768,9 @@ exit:
|
||||
|
||||
extern "C" void otPlatRadioTransmitDone(otInstance *aInstance, bool aRxPending, ThreadError aError)
|
||||
{
|
||||
otLogFuncEntryMsg("%!otError!, aRxPending=%u", aError, aRxPending ? 1 : 0);
|
||||
aInstance->mThreadNetif.GetMac().TransmitDoneTask(aRxPending, aError);
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void Mac::TransmitDoneTask(bool aRxPending, ThreadError aError)
|
||||
@@ -1080,7 +1102,9 @@ exit:
|
||||
|
||||
extern "C" void otPlatRadioReceiveDone(otInstance *aInstance, RadioPacket *aFrame, ThreadError aError)
|
||||
{
|
||||
otLogFuncEntryMsg("%!otError!", aError);
|
||||
aInstance->mThreadNetif.GetMac().ReceiveDoneTask(static_cast<Frame *>(aFrame), aError);
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void Mac::ReceiveDoneTask(Frame *aFrame, ThreadError aError)
|
||||
@@ -1246,6 +1270,8 @@ exit:
|
||||
|
||||
if (error != kThreadError_None)
|
||||
{
|
||||
otLogDebgMacErr(error, "Dropping received frame");
|
||||
|
||||
switch (error)
|
||||
{
|
||||
case kThreadError_Security:
|
||||
|
||||
@@ -121,7 +121,7 @@ ThreadError AnnounceBeginClient::SendRequest(uint32_t aChannelMask, uint8_t aCou
|
||||
messageInfo.mInterfaceId = mNetif.GetInterfaceId();
|
||||
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent announce begin query\r\n");
|
||||
otLogInfoMeshCoP("sent announce begin query\n");
|
||||
|
||||
exit:
|
||||
|
||||
@@ -135,7 +135,7 @@ exit:
|
||||
|
||||
void AnnounceBeginClient::HandleUdpReceive(void *aContext, otMessage aMessage, const otMessageInfo *aMessageInfo)
|
||||
{
|
||||
otLogInfoMeshCoP("received announce begin response\r\n");
|
||||
otLogInfoMeshCoP("received announce begin response\n");
|
||||
(void)aContext;
|
||||
(void)aMessage;
|
||||
(void)aMessageInfo;
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
#include <coap/coap_header.hpp>
|
||||
#include <common/crc16.hpp>
|
||||
#include <common/encoding.hpp>
|
||||
#include <common/logging.hpp>
|
||||
#include <meshcop/commissioner.hpp>
|
||||
#include <meshcop/joiner_router.hpp>
|
||||
@@ -53,6 +54,8 @@
|
||||
#include <thread/thread_tlvs.hpp>
|
||||
#include <thread/thread_uris.hpp>
|
||||
|
||||
using Thread::Encoding::BigEndian::HostSwap64;
|
||||
|
||||
namespace Thread {
|
||||
namespace MeshCoP {
|
||||
|
||||
@@ -79,6 +82,7 @@ ThreadError Commissioner::Start(void)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
otLogFuncEntry();
|
||||
VerifyOrExit(mState == kStateDisabled, error = kThreadError_InvalidState);
|
||||
|
||||
SuccessOrExit(error = mSocket.Open(HandleUdpReceive, this));
|
||||
@@ -89,6 +93,7 @@ ThreadError Commissioner::Start(void)
|
||||
SendPetition();
|
||||
|
||||
exit:
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -96,6 +101,7 @@ ThreadError Commissioner::Stop(void)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
otLogFuncEntry();
|
||||
VerifyOrExit(mState != kStateDisabled, error = kThreadError_InvalidState);
|
||||
|
||||
mState = kStateDisabled;
|
||||
@@ -104,6 +110,7 @@ ThreadError Commissioner::Stop(void)
|
||||
SendKeepAlive();
|
||||
|
||||
exit:
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -113,6 +120,7 @@ ThreadError Commissioner::SendCommissionerSet(void)
|
||||
otCommissioningDataset dataset;
|
||||
SteeringDataTlv steeringData;
|
||||
|
||||
otLogFuncEntry();
|
||||
VerifyOrExit(mState == kStateActive, error = kThreadError_InvalidState);
|
||||
|
||||
memset(&dataset, 0, sizeof(dataset));
|
||||
@@ -161,23 +169,28 @@ ThreadError Commissioner::SendCommissionerSet(void)
|
||||
SuccessOrExit(error = SendMgmtCommissionerSetRequest(dataset, NULL, 0));
|
||||
|
||||
exit:
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
void Commissioner::ClearJoiners(void)
|
||||
{
|
||||
otLogFuncEntry();
|
||||
|
||||
for (size_t i = 0; i < sizeof(mJoiners) / sizeof(mJoiners[0]); i++)
|
||||
{
|
||||
mJoiners[i].mValid = false;
|
||||
}
|
||||
|
||||
SendCommissionerSet();
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
ThreadError Commissioner::AddJoiner(const Mac::ExtAddress *aExtAddress, const char *aPSKd)
|
||||
{
|
||||
ThreadError error = kThreadError_NoBufs;
|
||||
|
||||
otLogFuncEntryMsg("%llX, %s", (aExtAddress ? HostSwap64(*reinterpret_cast<const uint64_t *>(aExtAddress)) : 0), aPSKd);
|
||||
VerifyOrExit(strlen(aPSKd) <= Dtls::kPskMaxLength, error = kThreadError_InvalidArgs);
|
||||
RemoveJoiner(aExtAddress);
|
||||
|
||||
@@ -207,6 +220,7 @@ ThreadError Commissioner::AddJoiner(const Mac::ExtAddress *aExtAddress, const ch
|
||||
}
|
||||
|
||||
exit:
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -214,6 +228,8 @@ ThreadError Commissioner::RemoveJoiner(const Mac::ExtAddress *aExtAddress)
|
||||
{
|
||||
ThreadError error = kThreadError_NotFound;
|
||||
|
||||
otLogFuncEntryMsg("%llX", (aExtAddress ? HostSwap64(*reinterpret_cast<const uint64_t *>(aExtAddress)) : 0));
|
||||
|
||||
for (size_t i = 0; i < sizeof(mJoiners) / sizeof(mJoiners[0]); i++)
|
||||
{
|
||||
if (!mJoiners[i].mValid)
|
||||
@@ -241,6 +257,7 @@ ThreadError Commissioner::RemoveJoiner(const Mac::ExtAddress *aExtAddress)
|
||||
}
|
||||
|
||||
exit:
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -291,6 +308,7 @@ ThreadError Commissioner::SendMgmtCommissionerGetRequest(const uint8_t *aTlvs,
|
||||
Ip6::MessageInfo messageInfo;
|
||||
MeshCoP::Tlv tlv;
|
||||
|
||||
otLogFuncEntry();
|
||||
mIsSendMgmtCommRequest = true;
|
||||
|
||||
for (size_t i = 0; i < sizeof(mCoapToken); i++)
|
||||
@@ -332,6 +350,7 @@ exit:
|
||||
message->Free();
|
||||
}
|
||||
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -343,6 +362,7 @@ ThreadError Commissioner::SendMgmtCommissionerSetRequest(const otCommissioningDa
|
||||
Message *message;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
otLogFuncEntry();
|
||||
mIsSendMgmtCommRequest = true;
|
||||
|
||||
for (size_t i = 0; i < sizeof(mCoapToken); i++)
|
||||
@@ -414,6 +434,7 @@ exit:
|
||||
message->Free();
|
||||
}
|
||||
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -425,6 +446,8 @@ ThreadError Commissioner::SendPetition(void)
|
||||
Ip6::MessageInfo messageInfo;
|
||||
CommissionerIdTlv commissionerId;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
if (mTransmitAttempts >= kPetitionRetryCount)
|
||||
{
|
||||
mState = kStateDisabled;
|
||||
@@ -460,7 +483,7 @@ ThreadError Commissioner::SendPetition(void)
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent petition\r\n");
|
||||
otLogInfoMeshCoP("sent petition\n");
|
||||
|
||||
exit:
|
||||
|
||||
@@ -469,6 +492,7 @@ exit:
|
||||
message->Free();
|
||||
}
|
||||
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -481,6 +505,8 @@ ThreadError Commissioner::SendKeepAlive(void)
|
||||
StateTlv state;
|
||||
CommissionerSessionIdTlv sessionId;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
if (mTransmitAttempts >= kPetitionRetryCount)
|
||||
{
|
||||
mState = kStateDisabled;
|
||||
@@ -519,7 +545,7 @@ ThreadError Commissioner::SendKeepAlive(void)
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent keep alive\r\n");
|
||||
otLogInfoMeshCoP("sent keep alive\n");
|
||||
|
||||
exit:
|
||||
|
||||
@@ -528,6 +554,7 @@ exit:
|
||||
message->Free();
|
||||
}
|
||||
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -546,11 +573,11 @@ void Commissioner::HandleRelayReceive(Coap::Header &aHeader, Message &aMessage,
|
||||
uint16_t offset;
|
||||
uint16_t length;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
VerifyOrExit(aHeader.GetType() == Coap::Header::kTypeNonConfirmable &&
|
||||
aHeader.GetCode() == Coap::Header::kCodePost, ;);
|
||||
|
||||
otLogInfoMeshCoP("Received relay receive\r\n");
|
||||
|
||||
SuccessOrExit(error = Tlv::GetTlv(aMessage, Tlv::kJoinerUdpPort, sizeof(joinerPort), joinerPort));
|
||||
VerifyOrExit(joinerPort.IsValid(), error = kThreadError_Parse);
|
||||
|
||||
@@ -566,6 +593,8 @@ void Commissioner::HandleRelayReceive(Coap::Header &aHeader, Message &aMessage,
|
||||
mJoinerPort = joinerPort.GetUdpPort();
|
||||
mJoinerRloc = joinerRloc.GetJoinerRouterLocator();
|
||||
|
||||
otLogInfoMeshCoP("Received relay receive for %llX, rloc:%x\n", HostSwap64(mJoinerIid64), mJoinerRloc);
|
||||
|
||||
if (!mNetif.GetDtls().IsStarted())
|
||||
{
|
||||
mJoinerIid[0] ^= 0x2;
|
||||
@@ -582,7 +611,7 @@ void Commissioner::HandleRelayReceive(Coap::Header &aHeader, Message &aMessage,
|
||||
SuccessOrExit(error = mNetif.GetDtls().SetPsk(reinterpret_cast<const uint8_t *>(mJoiners[i].mPsk),
|
||||
static_cast<uint8_t>(strlen(mJoiners[i].mPsk))));
|
||||
SuccessOrExit(error = mNetif.GetDtls().Start(false, HandleDtlsReceive, HandleDtlsSend, this));
|
||||
otLogInfoMeshCoP("found joiner, starting new session\r\n");
|
||||
otLogInfoMeshCoP("found joiner, starting new session\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -597,7 +626,7 @@ void Commissioner::HandleRelayReceive(Coap::Header &aHeader, Message &aMessage,
|
||||
|
||||
exit:
|
||||
(void)aMessageInfo;
|
||||
return;
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void Commissioner::HandleDatasetChanged(void *aContext, Coap::Header &aHeader,
|
||||
@@ -608,16 +637,17 @@ void Commissioner::HandleDatasetChanged(void *aContext, Coap::Header &aHeader,
|
||||
|
||||
void Commissioner::HandleDatasetChanged(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||
{
|
||||
otLogFuncEntry();
|
||||
VerifyOrExit(aHeader.GetType() == Coap::Header::kTypeConfirmable &&
|
||||
aHeader.GetCode() == Coap::Header::kCodePost, ;);
|
||||
|
||||
otLogInfoMeshCoP("received dataset changed\r\n");
|
||||
otLogInfoMeshCoP("received dataset changed\n");
|
||||
(void)aMessage;
|
||||
|
||||
SendDatasetChangedResponse(aHeader, aMessageInfo);
|
||||
|
||||
exit:
|
||||
return;
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void Commissioner::SendDatasetChangedResponse(const Coap::Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo)
|
||||
@@ -626,6 +656,7 @@ void Commissioner::SendDatasetChangedResponse(const Coap::Header &aRequestHeader
|
||||
Coap::Header responseHeader;
|
||||
Message *message;
|
||||
|
||||
otLogFuncEntry();
|
||||
VerifyOrExit((message = mCoapServer.NewMessage(0)) != NULL, error = kThreadError_NoBufs);
|
||||
responseHeader.Init();
|
||||
responseHeader.SetType(Coap::Header::kTypeAcknowledgment);
|
||||
@@ -644,6 +675,8 @@ exit:
|
||||
{
|
||||
message->Free();
|
||||
}
|
||||
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void Commissioner::HandleUdpReceive(void *aContext, otMessage aMessage, const otMessageInfo *aMessageInfo)
|
||||
@@ -658,6 +691,7 @@ void Commissioner::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &a
|
||||
StateTlv state;
|
||||
CommissionerSessionIdTlv sessionId;
|
||||
|
||||
otLogFuncEntry();
|
||||
SuccessOrExit(header.FromMessage(aMessage));
|
||||
VerifyOrExit(header.GetType() == Coap::Header::kTypeAcknowledgment &&
|
||||
header.GetCode() == Coap::Header::kCodeChanged &&
|
||||
@@ -670,7 +704,7 @@ void Commissioner::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &a
|
||||
{
|
||||
mIsSendMgmtCommRequest = false;
|
||||
|
||||
otLogInfoMeshCoP("received MGMT_COMMISSIONER_SET and MGMT_COMMISSIONER_GET response\r\n");
|
||||
otLogInfoMeshCoP("received MGMT_COMMISSIONER_SET and MGMT_COMMISSIONER_GET response\n");
|
||||
|
||||
ExitNow();
|
||||
}
|
||||
@@ -690,7 +724,7 @@ void Commissioner::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &a
|
||||
VerifyOrExit(sessionId.IsValid(), ;);
|
||||
mSessionId = sessionId.GetCommissionerSessionId();
|
||||
|
||||
otLogInfoMeshCoP("received petition response\r\n");
|
||||
otLogInfoMeshCoP("received petition response\n");
|
||||
|
||||
mState = kStateActive;
|
||||
mTransmitAttempts = 0;
|
||||
@@ -698,7 +732,7 @@ void Commissioner::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &a
|
||||
break;
|
||||
|
||||
case kStateActive:
|
||||
otLogInfoMeshCoP("received keep alive response\r\n");
|
||||
otLogInfoMeshCoP("received keep alive response\n");
|
||||
mTransmitAttempts = 0;
|
||||
mTimer.Start(Timer::SecToMsec(kKeepAliveTimeout) / 2);
|
||||
break;
|
||||
@@ -706,12 +740,12 @@ void Commissioner::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &a
|
||||
|
||||
exit:
|
||||
(void)aMessageInfo;
|
||||
return;
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
ThreadError Commissioner::HandleDtlsSend(void *aContext, const uint8_t *aBuf, uint16_t aLength)
|
||||
{
|
||||
otLogInfoMeshCoP("Commissioner::HandleDtlsTransmit\r\n");
|
||||
otLogInfoMeshCoP("Commissioner::HandleDtlsTransmit\n");
|
||||
return static_cast<Commissioner *>(aContext)->HandleDtlsSend(aBuf, aLength);
|
||||
}
|
||||
|
||||
@@ -719,6 +753,8 @@ ThreadError Commissioner::HandleDtlsSend(const unsigned char *aBuf, uint16_t aLe
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
if (mTransmitMessage == NULL)
|
||||
{
|
||||
Coap::Header header;
|
||||
@@ -776,23 +812,26 @@ exit:
|
||||
mTransmitMessage->Free();
|
||||
}
|
||||
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
void Commissioner::HandleDtlsReceive(void *aContext, uint8_t *aBuf, uint16_t aLength)
|
||||
{
|
||||
otLogInfoMeshCoP("Commissioner::HandleDtlsReceive\r\n");
|
||||
otLogInfoMeshCoP("Commissioner::HandleDtlsReceive\n");
|
||||
static_cast<Commissioner *>(aContext)->HandleDtlsReceive(aBuf, aLength);
|
||||
}
|
||||
|
||||
void Commissioner::HandleDtlsReceive(uint8_t *aBuf, uint16_t aLength)
|
||||
{
|
||||
otLogFuncEntry();
|
||||
ReceiveJoinerFinalize(aBuf, aLength);
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void Commissioner::HandleUdpTransmit(void *aContext)
|
||||
{
|
||||
otLogInfoMeshCoP("Commissioner::HandleUdpTransmit\r\n");
|
||||
otLogInfoMeshCoP("Commissioner::HandleUdpTransmit\n");
|
||||
static_cast<Commissioner *>(aContext)->HandleUdpTransmit();
|
||||
}
|
||||
|
||||
@@ -802,6 +841,7 @@ void Commissioner::HandleUdpTransmit(void)
|
||||
Ip6::MessageInfo messageInfo;
|
||||
ExtendedTlv tlv;
|
||||
|
||||
otLogFuncEntry();
|
||||
VerifyOrExit(mTransmitMessage != NULL, error = kThreadError_NoBufs);
|
||||
|
||||
tlv.SetType(Tlv::kJoinerDtlsEncapsulation);
|
||||
@@ -824,6 +864,7 @@ exit:
|
||||
}
|
||||
|
||||
mTransmitMessage = NULL;
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void Commissioner::ReceiveJoinerFinalize(uint8_t *buf, uint16_t length)
|
||||
@@ -837,7 +878,8 @@ void Commissioner::ReceiveJoinerFinalize(uint8_t *buf, uint16_t length)
|
||||
StateTlv::State state = StateTlv::kAccept;
|
||||
ProvisioningUrlTlv provisioningUrl;
|
||||
|
||||
otLogInfoMeshCoP("receive joiner finalize 1\r\n");
|
||||
otLogFuncEntry();
|
||||
otLogInfoMeshCoP("receive joiner finalize 1\n");
|
||||
|
||||
VerifyOrExit((message = mNetif.GetIp6().mMessagePool.New(Message::kTypeIp6, 0)) != NULL, ;);
|
||||
SuccessOrExit(message->Append(buf, length));
|
||||
@@ -894,6 +936,8 @@ exit:
|
||||
{
|
||||
message->Free();
|
||||
}
|
||||
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void Commissioner::SendJoinFinalizeResponse(const Coap::Header &aRequestHeader, StateTlv::State aState)
|
||||
@@ -903,6 +947,8 @@ void Commissioner::SendJoinFinalizeResponse(const Coap::Header &aRequestHeader,
|
||||
uint8_t buf[128];
|
||||
uint8_t *cur = buf;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
responseHeader.Init();
|
||||
responseHeader.SetType(Coap::Header::kTypeAcknowledgment);
|
||||
responseHeader.SetCode(Coap::Header::kCodeChanged);
|
||||
@@ -921,8 +967,9 @@ void Commissioner::SendJoinFinalizeResponse(const Coap::Header &aRequestHeader,
|
||||
mNetif.GetDtls().Send(buf, static_cast<uint16_t>(cur - buf));
|
||||
mSendKek = false;
|
||||
|
||||
otLogInfoMeshCoP("sent joiner finalize response\r\n");
|
||||
otLogCertMeshCoP("[THCI] direction=send | type=JOIN_FIN.rsp\r\n");
|
||||
otLogInfoMeshCoP("sent joiner finalize response\n");
|
||||
otLogCertMeshCoP("[THCI] direction=send | type=JOIN_FIN.rsp\n");
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
} // namespace MeshCoP
|
||||
|
||||
@@ -227,7 +227,11 @@ private:
|
||||
};
|
||||
Joiner mJoiners[OPENTHREAD_CONFIG_MAX_JOINER_ENTRIES];
|
||||
|
||||
uint8_t mJoinerIid[8];
|
||||
union
|
||||
{
|
||||
uint8_t mJoinerIid[8];
|
||||
uint64_t mJoinerIid64;
|
||||
};
|
||||
uint16_t mJoinerPort;
|
||||
uint16_t mJoinerRloc;
|
||||
|
||||
|
||||
+28
-17
@@ -33,10 +33,8 @@
|
||||
|
||||
#define WPP_NAME "dtls.tmh"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <common/code_utils.hpp>
|
||||
#include <common/debug.hpp>
|
||||
#include <common/encoding.hpp>
|
||||
#include <common/logging.hpp>
|
||||
#include <common/timer.hpp>
|
||||
@@ -99,7 +97,7 @@ ThreadError Dtls::Start(bool aClient, ReceiveHandler aReceiveHandler, SendHandle
|
||||
mbedtls_ssl_conf_ciphersuites(&mConf, ciphersuites);
|
||||
mbedtls_ssl_conf_export_keys_cb(&mConf, HandleMbedtlsExportKeys, this);
|
||||
mbedtls_ssl_conf_handshake_timeout(&mConf, 8000, 60000);
|
||||
mbedtls_ssl_conf_dbg(&mConf, HandleMbedtlsDebug, stdout);
|
||||
mbedtls_ssl_conf_dbg(&mConf, HandleMbedtlsDebug, NULL);
|
||||
|
||||
if (!mClient)
|
||||
{
|
||||
@@ -123,7 +121,7 @@ ThreadError Dtls::Start(bool aClient, ReceiveHandler aReceiveHandler, SendHandle
|
||||
mStarted = true;
|
||||
Process();
|
||||
|
||||
otLogInfoMeshCoP("DTLS started\r\n");
|
||||
otLogInfoMeshCoP("DTLS started\n");
|
||||
|
||||
exit:
|
||||
return MapError(rval);
|
||||
@@ -202,7 +200,7 @@ int Dtls::HandleMbedtlsTransmit(const unsigned char *aBuf, size_t aLength)
|
||||
ThreadError error;
|
||||
int rval = 0;
|
||||
|
||||
otLogInfoMeshCoP("Dtls::HandleMbedtlsTransmit\r\n");
|
||||
otLogInfoMeshCoP("Dtls::HandleMbedtlsTransmit\n");
|
||||
|
||||
error = mSendHandler(mContext, aBuf, (uint16_t)aLength);
|
||||
|
||||
@@ -233,7 +231,7 @@ int Dtls::HandleMbedtlsReceive(unsigned char *aBuf, size_t aLength)
|
||||
{
|
||||
int rval;
|
||||
|
||||
otLogInfoMeshCoP("Dtls::HandleMbedtlsReceive\r\n");
|
||||
otLogInfoMeshCoP("Dtls::HandleMbedtlsReceive\n");
|
||||
|
||||
VerifyOrExit(mReceiveMessage != NULL && mReceiveLength != 0, rval = MBEDTLS_ERR_SSL_WANT_READ);
|
||||
|
||||
@@ -259,7 +257,7 @@ int Dtls::HandleMbedtlsGetTimer(void)
|
||||
{
|
||||
int rval;
|
||||
|
||||
otLogInfoMeshCoP("Dtls::HandleMbedtlsGetTimer\r\n");
|
||||
otLogInfoMeshCoP("Dtls::HandleMbedtlsGetTimer\n");
|
||||
|
||||
if (!mTimerSet)
|
||||
{
|
||||
@@ -288,7 +286,7 @@ void Dtls::HandleMbedtlsSetTimer(void *aContext, uint32_t aIntermediate, uint32_
|
||||
|
||||
void Dtls::HandleMbedtlsSetTimer(uint32_t aIntermediate, uint32_t aFinish)
|
||||
{
|
||||
otLogInfoMeshCoP("Dtls::SetTimer\r\n");
|
||||
otLogInfoMeshCoP("Dtls::SetTimer\n");
|
||||
|
||||
if (aFinish == 0)
|
||||
{
|
||||
@@ -322,7 +320,7 @@ int Dtls::HandleMbedtlsExportKeys(const unsigned char *aMasterSecret, const unsi
|
||||
|
||||
mNetif.GetKeyManager().SetKek(kek);
|
||||
|
||||
otLogInfoMeshCoP("Generated KEK\r\n");
|
||||
otLogInfoMeshCoP("Generated KEK\n");
|
||||
|
||||
(void)aMasterSecret;
|
||||
return 0;
|
||||
@@ -436,14 +434,27 @@ ThreadError Dtls::MapError(int rval)
|
||||
return error;
|
||||
}
|
||||
|
||||
void Dtls::HandleMbedtlsDebug(void *ctx, int level, const char *file, int line, const char *str)
|
||||
void Dtls::HandleMbedtlsDebug(void *, int level, const char *, int , const char *str)
|
||||
{
|
||||
otLogInfoMeshCoP("%s:%04d: %s\r\n", file, line, str);
|
||||
(void)ctx;
|
||||
(void)level;
|
||||
(void)file;
|
||||
(void)line;
|
||||
(void)str;
|
||||
switch (level)
|
||||
{
|
||||
case 1:
|
||||
otLogCritMbedTls("%s\n", str);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
otLogWarnMbedTls("%s\n", str);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
otLogInfoMbedTls("%s\n", str);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
default:
|
||||
otLogDebgMbedTls("%s\n", str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace MeshCoP
|
||||
|
||||
@@ -132,7 +132,7 @@ ThreadError EnergyScanClient::SendQuery(uint32_t aChannelMask, uint8_t aCount, u
|
||||
messageInfo.mInterfaceId = mNetif.GetInterfaceId();
|
||||
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent energy scan query\r\n");
|
||||
otLogInfoMeshCoP("sent energy scan query\n");
|
||||
|
||||
mCallback = aCallback;
|
||||
mContext = aContext;
|
||||
@@ -173,7 +173,7 @@ void EnergyScanClient::HandleReport(Coap::Header &aHeader, Message &aMessage, co
|
||||
VerifyOrExit(aHeader.GetType() == Coap::Header::kTypeConfirmable &&
|
||||
aHeader.GetCode() == Coap::Header::kCodePost, ;);
|
||||
|
||||
otLogInfoMeshCoP("received energy scan report\r\n");
|
||||
otLogInfoMeshCoP("received energy scan report\n");
|
||||
|
||||
SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kChannelMask, sizeof(channelMask), channelMask.tlv));
|
||||
VerifyOrExit(channelMask.tlv.IsValid() &&
|
||||
@@ -227,7 +227,7 @@ exit:
|
||||
|
||||
void EnergyScanClient::HandleUdpReceive(void *aContext, otMessage aMessage, const otMessageInfo *aMessageInfo)
|
||||
{
|
||||
otLogInfoMeshCoP("received energy scan query response\r\n");
|
||||
otLogInfoMeshCoP("received energy scan query response\n");
|
||||
(void)aContext;
|
||||
(void)aMessage;
|
||||
(void)aMessageInfo;
|
||||
|
||||
+49
-13
@@ -39,7 +39,6 @@
|
||||
#include <openthread-config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <common/code_utils.hpp>
|
||||
@@ -54,6 +53,7 @@
|
||||
#include <thread/thread_uris.hpp>
|
||||
|
||||
using Thread::Encoding::BigEndian::HostSwap16;
|
||||
using Thread::Encoding::BigEndian::HostSwap64;
|
||||
|
||||
namespace Thread {
|
||||
namespace MeshCoP {
|
||||
@@ -74,6 +74,8 @@ ThreadError Joiner::Start(const char *aPSKd, const char *aProvisioningUrl)
|
||||
ThreadError error;
|
||||
Mac::ExtAddress extAddress;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
// use extended address based on factory-assigned IEEE EUI-64
|
||||
mNetif.GetMac().GetHashMacAddress(&extAddress);
|
||||
mNetif.GetMac().SetExtAddress(extAddress);
|
||||
@@ -87,14 +89,17 @@ ThreadError Joiner::Start(const char *aPSKd, const char *aProvisioningUrl)
|
||||
SuccessOrExit(error = mNetif.GetMle().Discover(0, 0, mNetif.GetMac().GetPanId(), HandleDiscoverResult, this));
|
||||
|
||||
exit:
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
ThreadError Joiner::Stop(void)
|
||||
{
|
||||
otLogFuncEntry();
|
||||
mNetif.GetIp6Filter().RemoveUnsecurePort(mSocket.GetSockName().mPort);
|
||||
mSocket.Close();
|
||||
mNetif.GetDtls().Stop();
|
||||
otLogFuncExit();
|
||||
return kThreadError_None;
|
||||
}
|
||||
|
||||
@@ -107,6 +112,8 @@ void Joiner::HandleDiscoverResult(otActiveScanResult *aResult)
|
||||
{
|
||||
if (aResult != NULL)
|
||||
{
|
||||
otLogFuncEntryMsg("aResult = %llX", HostSwap64(*reinterpret_cast<uint64_t *>(&aResult->mExtAddress)));
|
||||
|
||||
SteeringDataTlv steeringData;
|
||||
Mac::ExtAddress extAddress;
|
||||
Crc16 ccitt(Crc16::kCcitt);
|
||||
@@ -131,9 +138,15 @@ void Joiner::HandleDiscoverResult(otActiveScanResult *aResult)
|
||||
mJoinerRouterChannel = aResult->mChannel;
|
||||
memcpy(&mJoinerRouter, &aResult->mExtAddress, sizeof(mJoinerRouter));
|
||||
}
|
||||
else
|
||||
{
|
||||
otLogDebgMeshCoP("Steering data not set\n");
|
||||
}
|
||||
}
|
||||
else if (mJoinerRouterPanId != Mac::kPanIdBroadcast)
|
||||
{
|
||||
otLogFuncEntryMsg("aResult = NULL");
|
||||
|
||||
// open UDP port
|
||||
Ip6::SockAddr sockaddr;
|
||||
sockaddr.mPort = mJoinerUdpPort;
|
||||
@@ -146,11 +159,13 @@ void Joiner::HandleDiscoverResult(otActiveScanResult *aResult)
|
||||
|
||||
mNetif.GetDtls().Start(true, HandleDtlsReceive, HandleDtlsSend, this);
|
||||
}
|
||||
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
ThreadError Joiner::HandleDtlsSend(void *aContext, const uint8_t *aBuf, uint16_t aLength)
|
||||
{
|
||||
otLogInfoMeshCoP("Joiner::HandleDtlsTransmit\r\n");
|
||||
otLogInfoMeshCoP("Joiner::HandleDtlsTransmit\n");
|
||||
return static_cast<Joiner *>(aContext)->HandleDtlsSend(aBuf, aLength);
|
||||
}
|
||||
|
||||
@@ -158,6 +173,8 @@ ThreadError Joiner::HandleDtlsSend(const unsigned char *aBuf, uint16_t aLength)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
if (mTransmitMessage == NULL)
|
||||
{
|
||||
VerifyOrExit((mTransmitMessage = mSocket.NewMessage(0)) != NULL, error = kThreadError_NoBufs);
|
||||
@@ -175,12 +192,13 @@ exit:
|
||||
mTransmitMessage->Free();
|
||||
}
|
||||
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
void Joiner::HandleDtlsReceive(void *aContext, uint8_t *aBuf, uint16_t aLength)
|
||||
{
|
||||
otLogInfoMeshCoP("Joiner::HandleDtlsReceive\r\n");
|
||||
otLogInfoMeshCoP("Joiner::HandleDtlsReceive\n");
|
||||
static_cast<Joiner *>(aContext)->HandleDtlsReceive(aBuf, aLength);
|
||||
}
|
||||
|
||||
@@ -191,13 +209,14 @@ void Joiner::HandleDtlsReceive(uint8_t *aBuf, uint16_t aLength)
|
||||
|
||||
void Joiner::HandleUdpReceive(void *aContext, otMessage aMessage, const otMessageInfo *aMessageInfo)
|
||||
{
|
||||
otLogInfoMeshCoP("Joiner::HandleUdpReceive\r\n");
|
||||
otLogInfoMeshCoP("Joiner::HandleUdpReceive\n");
|
||||
static_cast<Joiner *>(aContext)->HandleUdpReceive(*static_cast<Message *>(aMessage),
|
||||
*static_cast<const Ip6::MessageInfo *>(aMessageInfo));
|
||||
}
|
||||
|
||||
void Joiner::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||
{
|
||||
otLogFuncEntry();
|
||||
(void)aMessageInfo;
|
||||
|
||||
mNetif.GetDtls().Receive(aMessage, aMessage.GetOffset(), aMessage.GetLength() - aMessage.GetOffset());
|
||||
@@ -206,11 +225,13 @@ void Joiner::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessag
|
||||
{
|
||||
SendJoinerFinalize();
|
||||
}
|
||||
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void Joiner::HandleUdpTransmit(void *aContext)
|
||||
{
|
||||
otLogInfoMeshCoP("Joiner::HandleUdpTransmit\r\n");
|
||||
otLogInfoMeshCoP("Joiner::HandleUdpTransmit\n");
|
||||
static_cast<Joiner *>(aContext)->HandleUdpTransmit();
|
||||
}
|
||||
|
||||
@@ -219,9 +240,12 @@ void Joiner::HandleUdpTransmit(void)
|
||||
ThreadError error = kThreadError_None;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
VerifyOrExit(mTransmitMessage != NULL, error = kThreadError_NoBufs);
|
||||
|
||||
otLogInfoMeshCoP("transmit %d\r\n", mTransmitMessage->GetLength());
|
||||
otLogInfoMeshCoP("transmit %d (to %llX)\n", mTransmitMessage->GetLength(),
|
||||
HostSwap64(*reinterpret_cast<uint64_t *>(&mJoinerRouter)));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr().mFields.m16[0] = HostSwap16(0xfe80);
|
||||
@@ -239,6 +263,7 @@ exit:
|
||||
}
|
||||
|
||||
mTransmitMessage = NULL;
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void Joiner::SendJoinerFinalize(void)
|
||||
@@ -249,6 +274,8 @@ void Joiner::SendJoinerFinalize(void)
|
||||
uint8_t buf[128];
|
||||
uint8_t *cur = buf;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
header.Init();
|
||||
header.SetType(Coap::Header::kTypeConfirmable);
|
||||
header.SetCode(Coap::Header::kCodePost);
|
||||
@@ -275,9 +302,10 @@ void Joiner::SendJoinerFinalize(void)
|
||||
|
||||
mNetif.GetDtls().Send(buf, static_cast<uint16_t>(cur - buf));
|
||||
|
||||
otLogInfoMeshCoP("Sent joiner finalize\r\n");
|
||||
otLogInfoMeshCoP("Sent joiner finalize\n");
|
||||
otDumpCertMeshCoP("[THCI] direction=send | type=JOIN_FIN.req |", buf + header.GetLength(),
|
||||
cur - buf - header.GetLength());
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void Joiner::ReceiveJoinerFinalizeResponse(uint8_t *buf, uint16_t length)
|
||||
@@ -286,6 +314,8 @@ void Joiner::ReceiveJoinerFinalizeResponse(uint8_t *buf, uint16_t length)
|
||||
Coap::Header header;
|
||||
StateTlv state;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
VerifyOrExit((message = mNetif.GetIp6().mMessagePool.New(Message::kTypeIp6, 0)) != NULL, ;);
|
||||
SuccessOrExit(message->Append(buf, length));
|
||||
SuccessOrExit(header.FromMessage(*message));
|
||||
@@ -299,8 +329,8 @@ void Joiner::ReceiveJoinerFinalizeResponse(uint8_t *buf, uint16_t length)
|
||||
SuccessOrExit(Tlv::GetTlv(*message, Tlv::kState, sizeof(state), state));
|
||||
VerifyOrExit(state.IsValid(), ;);
|
||||
|
||||
otLogInfoMeshCoP("received joiner finalize response %d\r\n", static_cast<uint8_t>(state.GetState()));
|
||||
otLogCertMeshCoP("[THCI] direction=recv | type=JOIN_FIN.rsp\r\n");
|
||||
otLogInfoMeshCoP("received joiner finalize response %d\n", static_cast<uint8_t>(state.GetState()));
|
||||
otLogCertMeshCoP("[THCI] direction=recv | type=JOIN_FIN.rsp\n");
|
||||
|
||||
Close();
|
||||
|
||||
@@ -310,6 +340,8 @@ exit:
|
||||
{
|
||||
message->Free();
|
||||
}
|
||||
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void Joiner::HandleJoinerEntrust(void *aContext, Coap::Header &aHeader,
|
||||
@@ -328,11 +360,13 @@ void Joiner::HandleJoinerEntrust(Coap::Header &aHeader, Message &aMessage, const
|
||||
NetworkNameTlv networkName;
|
||||
ActiveTimestampTlv activeTimestamp;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
VerifyOrExit(aHeader.GetType() == Coap::Header::kTypeConfirmable &&
|
||||
aHeader.GetCode() == Coap::Header::kCodePost, error = kThreadError_Drop);
|
||||
|
||||
otLogInfoMeshCoP("Received joiner entrust\r\n");
|
||||
otLogCertMeshCoP("[THCI] direction=recv | type=JOIN_ENT.ntf\r\n");
|
||||
otLogInfoMeshCoP("Received joiner entrust\n");
|
||||
otLogCertMeshCoP("[THCI] direction=recv | type=JOIN_ENT.ntf\n");
|
||||
|
||||
SuccessOrExit(error = Tlv::GetTlv(aMessage, Tlv::kNetworkMasterKey, sizeof(masterKey), masterKey));
|
||||
VerifyOrExit(masterKey.IsValid(), error = kThreadError_Parse);
|
||||
@@ -354,14 +388,14 @@ void Joiner::HandleJoinerEntrust(Coap::Header &aHeader, Message &aMessage, const
|
||||
mNetif.GetMac().SetExtendedPanId(extendedPanId.GetExtendedPanId());
|
||||
mNetif.GetMac().SetNetworkName(networkName.GetNetworkName());
|
||||
|
||||
otLogInfoMeshCoP("join success!\r\n");
|
||||
otLogInfoMeshCoP("join success!\n");
|
||||
|
||||
// Delay extended address configuration to allow DTLS wrap up.
|
||||
mTimer.Start(kConfigExtAddressDelay);
|
||||
|
||||
exit:
|
||||
(void)aMessageInfo;
|
||||
return;
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void Joiner::HandleTimer(void *aContext)
|
||||
@@ -384,7 +418,9 @@ void Joiner::HandleTimer(void)
|
||||
|
||||
void Joiner::Close(void)
|
||||
{
|
||||
otLogFuncEntry();
|
||||
mNetif.GetDtls().Stop();
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
} // namespace Dtls
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include <openthread-config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <common/code_utils.hpp>
|
||||
@@ -52,6 +51,7 @@
|
||||
#include <thread/thread_uris.hpp>
|
||||
|
||||
using Thread::Encoding::BigEndian::HostSwap16;
|
||||
using Thread::Encoding::BigEndian::HostSwap64;
|
||||
|
||||
namespace Thread {
|
||||
namespace MeshCoP {
|
||||
@@ -91,7 +91,7 @@ void JoinerRouter::HandleNetifStateChanged(uint32_t aFlags)
|
||||
mSocket.Open(&JoinerRouter::HandleUdpReceive, this);
|
||||
mSocket.Bind(sockaddr);
|
||||
mNetif.GetIp6Filter().AddUnsecurePort(sockaddr.mPort);
|
||||
otLogInfoMeshCoP("Joiner Router: start\r\n");
|
||||
otLogInfoMeshCoP("Joiner Router: start\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -160,9 +160,11 @@ exit:
|
||||
|
||||
ThreadError JoinerRouter::SetJoinerUdpPort(uint16_t aJoinerUdpPort)
|
||||
{
|
||||
otLogFuncEntry();
|
||||
mJoinerUdpPort = aJoinerUdpPort;
|
||||
mIsJoinerPortConfigured = true;
|
||||
HandleNetifStateChanged(OT_THREAD_NETDATA_UPDATED);
|
||||
otLogFuncExit();
|
||||
return kThreadError_None;
|
||||
}
|
||||
|
||||
@@ -184,7 +186,9 @@ void JoinerRouter::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &a
|
||||
ExtendedTlv tlv;
|
||||
uint16_t borderAgentRloc;
|
||||
|
||||
otLogInfoMeshCoP("JoinerRouter::HandleUdpReceive\r\n");
|
||||
otLogFuncEntryMsg("from peer: %llX",
|
||||
HostSwap64(*reinterpret_cast<const uint64_t *>(aMessageInfo.GetPeerAddr().mFields.m8 + 8)));
|
||||
otLogInfoMeshCoP("JoinerRouter::HandleUdpReceive\n");
|
||||
|
||||
SuccessOrExit(error = GetBorderAgentRloc(borderAgentRloc));
|
||||
|
||||
@@ -240,7 +244,7 @@ void JoinerRouter::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &a
|
||||
|
||||
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("Sent relay rx\r\n");
|
||||
otLogInfoMeshCoP("Sent relay rx\n");
|
||||
|
||||
exit:
|
||||
|
||||
@@ -248,6 +252,8 @@ exit:
|
||||
{
|
||||
message->Free();
|
||||
}
|
||||
|
||||
otLogFuncExitErr(error);
|
||||
}
|
||||
|
||||
void JoinerRouter::HandleRelayTransmit(void *aContext, Coap::Header &aHeader,
|
||||
@@ -267,10 +273,11 @@ void JoinerRouter::HandleRelayTransmit(Coap::Header &aHeader, Message &aMessage,
|
||||
Message *message = NULL;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
otLogFuncEntry();
|
||||
VerifyOrExit(aHeader.GetType() == Coap::Header::kTypeNonConfirmable &&
|
||||
aHeader.GetCode() == Coap::Header::kCodePost, error = kThreadError_Drop);
|
||||
|
||||
otLogInfoMeshCoP("Received relay transmit\r\n");
|
||||
otLogInfoMeshCoP("Received relay transmit\n");
|
||||
|
||||
SuccessOrExit(error = Tlv::GetTlv(aMessage, Tlv::kJoinerUdpPort, sizeof(joinerPort), joinerPort));
|
||||
VerifyOrExit(joinerPort.IsValid(), error = kThreadError_Parse);
|
||||
@@ -312,7 +319,7 @@ void JoinerRouter::HandleRelayTransmit(Coap::Header &aHeader, Message &aMessage,
|
||||
|
||||
if (Tlv::GetTlv(aMessage, Tlv::kJoinerRouterKek, sizeof(kek), kek) == kThreadError_None)
|
||||
{
|
||||
otLogInfoMeshCoP("Received kek\r\n");
|
||||
otLogInfoMeshCoP("Received kek\n");
|
||||
mNetif.GetKeyManager().SetKek(kek.GetKek());
|
||||
SendJoinerEntrust(messageInfo);
|
||||
}
|
||||
@@ -324,6 +331,8 @@ exit:
|
||||
{
|
||||
message->Free();
|
||||
}
|
||||
|
||||
otLogFuncExitErr(error);
|
||||
}
|
||||
|
||||
ThreadError JoinerRouter::SendJoinerEntrust(const Ip6::MessageInfo &aMessageInfo)
|
||||
@@ -339,6 +348,7 @@ ThreadError JoinerRouter::SendJoinerEntrust(const Ip6::MessageInfo &aMessageInfo
|
||||
NetworkNameTlv networkName;
|
||||
Tlv *tlv;
|
||||
|
||||
otLogFuncEntry();
|
||||
VerifyOrExit((message = mSocket.NewMessage(0)) != NULL, error = kThreadError_NoBufs);
|
||||
message->SetSubType(Message::kSubTypeJoinerEntrust);
|
||||
|
||||
@@ -415,8 +425,8 @@ ThreadError JoinerRouter::SendJoinerEntrust(const Ip6::MessageInfo &aMessageInfo
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("Sent joiner entrust length = %d\r\n", message->GetLength());
|
||||
otLogCertMeshCoP("[THCI] direction=send | msg_type=JOIN_ENT.ntf\r\n");
|
||||
otLogInfoMeshCoP("Sent joiner entrust length = %d\n", message->GetLength());
|
||||
otLogCertMeshCoP("[THCI] direction=send | msg_type=JOIN_ENT.ntf\n");
|
||||
|
||||
exit:
|
||||
|
||||
@@ -425,6 +435,7 @@ exit:
|
||||
message->Free();
|
||||
}
|
||||
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ void Leader::HandlePetition(Coap::Header &aHeader, Message &aMessage, const Ip6:
|
||||
CommissionerIdTlv commissionerId;
|
||||
StateTlv::State state = StateTlv::kReject;
|
||||
|
||||
otLogInfoMeshCoP("received petition\r\n");
|
||||
otLogInfoMeshCoP("received petition\n");
|
||||
|
||||
SuccessOrExit(Tlv::GetTlv(aMessage, Tlv::kCommissionerId, sizeof(commissionerId), commissionerId));
|
||||
|
||||
@@ -139,7 +139,7 @@ ThreadError Leader::SendPetitionResponse(const Coap::Header &aRequestHeader, con
|
||||
|
||||
SuccessOrExit(error = mCoapServer.SendMessage(*message, aMessageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent petition response\r\n");
|
||||
otLogInfoMeshCoP("sent petition response\n");
|
||||
|
||||
exit:
|
||||
|
||||
@@ -163,7 +163,7 @@ void Leader::HandleKeepAlive(Coap::Header &aHeader, Message &aMessage, const Ip6
|
||||
CommissionerSessionIdTlv sessionId;
|
||||
StateTlv::State responseState;
|
||||
|
||||
otLogInfoMeshCoP("received keep alive\r\n");
|
||||
otLogInfoMeshCoP("received keep alive\n");
|
||||
|
||||
SuccessOrExit(Tlv::GetTlv(aMessage, Tlv::kState, sizeof(state), state));
|
||||
SuccessOrExit(Tlv::GetTlv(aMessage, Tlv::kCommissionerSessionId, sizeof(sessionId), sessionId));
|
||||
@@ -177,7 +177,7 @@ void Leader::HandleKeepAlive(Coap::Header &aHeader, Message &aMessage, const Ip6
|
||||
responseState = StateTlv::kReject;
|
||||
mTimer.Stop();
|
||||
mNetworkData.SetCommissioningData(NULL, 0);
|
||||
otLogInfoMeshCoP("commissioner inactive\r\n");
|
||||
otLogInfoMeshCoP("commissioner inactive\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -214,7 +214,7 @@ ThreadError Leader::SendKeepAliveResponse(const Coap::Header &aRequestHeader, co
|
||||
|
||||
SuccessOrExit(error = mCoapServer.SendMessage(*message, aMessageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent keep alive response\r\n");
|
||||
otLogInfoMeshCoP("sent keep alive response\n");
|
||||
|
||||
exit:
|
||||
|
||||
@@ -228,7 +228,7 @@ exit:
|
||||
|
||||
void Leader::HandleUdpReceive(void *aContext, otMessage aMessage, const otMessageInfo *aMessageInfo)
|
||||
{
|
||||
otLogInfoMeshCoP("received dataset changed response\r\n");
|
||||
otLogInfoMeshCoP("received dataset changed response\n");
|
||||
(void)aContext;
|
||||
(void)aMessage;
|
||||
(void)aMessageInfo;
|
||||
@@ -262,7 +262,7 @@ ThreadError Leader::SendDatasetChanged(const Ip6::Address &aAddress)
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent dataset changed\r\n");
|
||||
otLogInfoMeshCoP("sent dataset changed\n");
|
||||
|
||||
exit:
|
||||
|
||||
@@ -283,7 +283,7 @@ void Leader::HandleTimer(void)
|
||||
{
|
||||
VerifyOrExit(mNetif.GetMle().GetDeviceState() == Mle::kDeviceStateLeader, ;);
|
||||
|
||||
otLogInfoMeshCoP("commissioner inactive\r\n");
|
||||
otLogInfoMeshCoP("commissioner inactive\n");
|
||||
mNetworkData.SetCommissioningData(NULL, 0);
|
||||
|
||||
exit:
|
||||
|
||||
@@ -117,7 +117,7 @@ ThreadError PanIdQueryClient::SendQuery(uint16_t aPanId, uint32_t aChannelMask,
|
||||
messageInfo.mInterfaceId = mNetif.GetInterfaceId();
|
||||
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent panid query\r\n");
|
||||
otLogInfoMeshCoP("sent panid query\n");
|
||||
|
||||
mCallback = aCallback;
|
||||
mContext = aContext;
|
||||
@@ -153,7 +153,7 @@ void PanIdQueryClient::HandleConflict(Coap::Header &aHeader, Message &aMessage,
|
||||
VerifyOrExit(aHeader.GetType() == Coap::Header::kTypeConfirmable &&
|
||||
aHeader.GetCode() == Coap::Header::kCodePost, ;);
|
||||
|
||||
otLogInfoMeshCoP("received panid conflict\r\n");
|
||||
otLogInfoMeshCoP("received panid conflict\n");
|
||||
|
||||
SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kPanId, sizeof(panId), panId));
|
||||
VerifyOrExit(panId.IsValid(), ;);
|
||||
@@ -214,7 +214,7 @@ exit:
|
||||
|
||||
void PanIdQueryClient::HandleUdpReceive(void *aContext, otMessage aMessage, const otMessageInfo *aMessageInfo)
|
||||
{
|
||||
otLogInfoMeshCoP("received panid query response\r\n");
|
||||
otLogInfoMeshCoP("received panid query response\n");
|
||||
(void)aContext;
|
||||
(void)aMessage;
|
||||
(void)aMessageInfo;
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
* This file implements IPv6 networking.
|
||||
*/
|
||||
|
||||
#define WPP_NAME "ip6.tmh"
|
||||
|
||||
#include <common/code_utils.hpp>
|
||||
#include <common/debug.hpp>
|
||||
#include <common/logging.hpp>
|
||||
@@ -430,6 +432,8 @@ ThreadError Ip6::HandleDatagram(Message &message, Netif *netif, int8_t interface
|
||||
uint8_t nextHeader;
|
||||
uint8_t hopLimit;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
#if 0
|
||||
uint8_t buf[1024];
|
||||
message.Read(0, sizeof(buf), buf);
|
||||
@@ -533,6 +537,7 @@ exit:
|
||||
message.Free();
|
||||
}
|
||||
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -542,6 +547,8 @@ ThreadError Ip6::ForwardMessage(Message &message, MessageInfo &messageInfo, uint
|
||||
int8_t interfaceId;
|
||||
Netif *netif;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
if (messageInfo.GetSockAddr().IsMulticast())
|
||||
{
|
||||
// multicast
|
||||
@@ -590,6 +597,8 @@ ThreadError Ip6::ForwardMessage(Message &message, MessageInfo &messageInfo, uint
|
||||
SuccessOrExit(error = netif->SendMessage(message));
|
||||
|
||||
exit:
|
||||
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
+32
-2
@@ -90,7 +90,9 @@ static void HandleMleDiscover(otActiveScanResult *aResult, void *aContext);
|
||||
|
||||
void otProcessQueuedTasklets(otInstance *aInstance)
|
||||
{
|
||||
otLogFuncEntry();
|
||||
aInstance->mIp6.mTaskletScheduler.ProcessQueuedTasklets();
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
bool otAreTaskletsPending(otInstance *aInstance)
|
||||
@@ -1004,6 +1006,7 @@ otInstance *otInstanceInit(void *aInstanceBuffer, size_t *aInstanceBufferSize)
|
||||
{
|
||||
otInstance *aInstance = NULL;
|
||||
|
||||
otLogFuncEntry();
|
||||
otLogInfoApi("otInstanceInit\n");
|
||||
|
||||
VerifyOrExit(aInstanceBufferSize != NULL, ;);
|
||||
@@ -1018,6 +1021,7 @@ otInstance *otInstanceInit(void *aInstanceBuffer, size_t *aInstanceBufferSize)
|
||||
|
||||
exit:
|
||||
|
||||
otLogFuncExit();
|
||||
return aInstance;
|
||||
}
|
||||
|
||||
@@ -1025,6 +1029,8 @@ exit:
|
||||
|
||||
otInstance *otInstanceInit()
|
||||
{
|
||||
otLogFuncEntry();
|
||||
|
||||
otLogInfoApi("otInstanceInit\n");
|
||||
|
||||
VerifyOrExit(sInstance == NULL, ;);
|
||||
@@ -1034,6 +1040,7 @@ otInstance *otInstanceInit()
|
||||
|
||||
exit:
|
||||
|
||||
otLogFuncExit();
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@@ -1059,6 +1066,8 @@ ThreadError otSendDiagnosticReset(otInstance *aInstance, const otIp6Address *aDe
|
||||
|
||||
void otInstanceFinalize(otInstance *aInstance)
|
||||
{
|
||||
otLogFuncEntry();
|
||||
|
||||
// Ensure we are disabled
|
||||
(void)otThreadStop(aInstance);
|
||||
(void)otInterfaceDown(aInstance);
|
||||
@@ -1069,14 +1078,18 @@ void otInstanceFinalize(otInstance *aInstance)
|
||||
#ifndef OPENTHREAD_MULTIPLE_INSTANCE
|
||||
sInstance = NULL;
|
||||
#endif
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
ThreadError otInterfaceUp(otInstance *aInstance)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
error = aInstance->mThreadNetif.Up();
|
||||
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1084,8 +1097,11 @@ ThreadError otInterfaceDown(otInstance *aInstance)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
error = aInstance->mThreadNetif.Down();
|
||||
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1098,11 +1114,14 @@ ThreadError otThreadStart(otInstance *aInstance)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
VerifyOrExit(aInstance->mThreadNetif.GetMac().GetPanId() != Mac::kPanIdBroadcast, error = kThreadError_InvalidState);
|
||||
|
||||
error = aInstance->mThreadNetif.GetMle().Start();
|
||||
|
||||
exit:
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1110,8 +1129,11 @@ ThreadError otThreadStop(otInstance *aInstance)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
error = aInstance->mThreadNetif.GetMle().Stop();
|
||||
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1233,8 +1255,16 @@ void otSetReceiveIp6DatagramFilterEnabled(otInstance *aInstance, bool aEnabled)
|
||||
|
||||
ThreadError otSendIp6Datagram(otInstance *aInstance, otMessage aMessage)
|
||||
{
|
||||
return aInstance->mIp6.HandleDatagram(*static_cast<Message *>(aMessage), NULL, aInstance->mThreadNetif.GetInterfaceId(),
|
||||
NULL, true);
|
||||
ThreadError error;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
error = aInstance->mIp6.HandleDatagram(*static_cast<Message *>(aMessage), NULL,
|
||||
aInstance->mThreadNetif.GetInterfaceId(), NULL, true);
|
||||
|
||||
otLogFuncExitErr(error);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
otMessage otNewUdpMessage(otInstance *aInstance, bool aLinkSecurityEnabled)
|
||||
|
||||
@@ -151,7 +151,7 @@ ThreadError AnnounceBeginServer::SendResponse(const Coap::Header &aRequestHeader
|
||||
memset(&responseInfo.mSockAddr, 0, sizeof(responseInfo.mSockAddr));
|
||||
SuccessOrExit(error = mCoapServer.SendMessage(*message, responseInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent announce begin response\r\n");
|
||||
otLogInfoMeshCoP("sent announce begin response\n");
|
||||
|
||||
exit:
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ ThreadError EnergyScanServer::SendResponse(const Coap::Header &aRequestHeader, c
|
||||
memset(&responseInfo.mSockAddr, 0, sizeof(responseInfo.mSockAddr));
|
||||
SuccessOrExit(error = mCoapServer.SendMessage(*message, responseInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent energy scan query response\r\n");
|
||||
otLogInfoMeshCoP("sent energy scan query response\n");
|
||||
|
||||
exit:
|
||||
|
||||
@@ -166,7 +166,7 @@ void EnergyScanServer::HandleTimer(void)
|
||||
{
|
||||
// grab the lowest channel to scan
|
||||
uint32_t channelMask = mChannelMaskCurrent & ~(mChannelMaskCurrent - 1);
|
||||
otLogInfoMeshCoP("%x\r\n", channelMask);
|
||||
otLogInfoMeshCoP("%x\n", channelMask);
|
||||
mNetif.GetMac().EnergyScan(channelMask, mScanDuration, HandleScanResult, this);
|
||||
}
|
||||
else
|
||||
@@ -261,7 +261,7 @@ ThreadError EnergyScanServer::SendReport(void)
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent scan results\r\n");
|
||||
otLogInfoMeshCoP("sent scan results\n");
|
||||
|
||||
exit:
|
||||
|
||||
@@ -277,7 +277,7 @@ exit:
|
||||
|
||||
void EnergyScanServer::HandleUdpReceive(void *aContext, otMessage aMessage, const otMessageInfo *aMessageInfo)
|
||||
{
|
||||
otLogInfoMeshCoP("received scan report response\r\n");
|
||||
otLogInfoMeshCoP("received scan report response\n");
|
||||
(void)aContext;
|
||||
(void)aMessage;
|
||||
(void)aMessageInfo;
|
||||
|
||||
@@ -1348,6 +1348,7 @@ void MeshForwarder::HandleReceivedFrame(Mac::Frame &aFrame, ThreadError aError)
|
||||
Ip6::Address destination;
|
||||
uint8_t commandId;
|
||||
Child *child = NULL;
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
#if 0
|
||||
dump("received frame", aFrame.GetHeader(), aFrame.GetLength());
|
||||
@@ -1355,10 +1356,10 @@ void MeshForwarder::HandleReceivedFrame(Mac::Frame &aFrame, ThreadError aError)
|
||||
|
||||
if (!mEnabled)
|
||||
{
|
||||
ExitNow();
|
||||
ExitNow(error = kThreadError_InvalidState);
|
||||
}
|
||||
|
||||
SuccessOrExit(aFrame.GetSrcAddr(macSource));
|
||||
SuccessOrExit(error = aFrame.GetSrcAddr(macSource));
|
||||
|
||||
if (aError == kThreadError_Security)
|
||||
{
|
||||
@@ -1378,11 +1379,11 @@ void MeshForwarder::HandleReceivedFrame(Mac::Frame &aFrame, ThreadError aError)
|
||||
break;
|
||||
|
||||
default:
|
||||
ExitNow();
|
||||
ExitNow(error = kThreadError_Parse);
|
||||
}
|
||||
|
||||
mMle.SendLinkReject(destination);
|
||||
ExitNow();
|
||||
ExitNow(error = kThreadError_Security);
|
||||
}
|
||||
|
||||
SuccessOrExit(aFrame.GetDstAddr(macDest));
|
||||
@@ -1441,7 +1442,11 @@ void MeshForwarder::HandleReceivedFrame(Mac::Frame &aFrame, ThreadError aError)
|
||||
}
|
||||
|
||||
exit:
|
||||
{}
|
||||
|
||||
if (error != kThreadError_None)
|
||||
{
|
||||
otLogDebgMacErr(error, "Dropping received frame");
|
||||
}
|
||||
}
|
||||
|
||||
void MeshForwarder::HandleMesh(uint8_t *aFrame, uint8_t aFrameLength, const ThreadMessageInfo &aMessageInfo)
|
||||
@@ -1453,7 +1458,7 @@ void MeshForwarder::HandleMesh(uint8_t *aFrame, uint8_t aFrameLength, const Thre
|
||||
Lowpan::MeshHeader *meshHeader = reinterpret_cast<Lowpan::MeshHeader *>(aFrame);
|
||||
|
||||
// Security Check: only process Mesh Header frames that had security enabled.
|
||||
VerifyOrExit(aMessageInfo.mLinkSecurity && meshHeader->IsValid(), error = kThreadError_Drop);
|
||||
VerifyOrExit(aMessageInfo.mLinkSecurity && meshHeader->IsValid(), error = kThreadError_Security);
|
||||
|
||||
meshSource.mLength = sizeof(meshSource.mShortAddress);
|
||||
meshSource.mShortAddress = meshHeader->GetSource();
|
||||
@@ -1475,7 +1480,7 @@ void MeshForwarder::HandleMesh(uint8_t *aFrame, uint8_t aFrameLength, const Thre
|
||||
}
|
||||
else
|
||||
{
|
||||
ExitNow();
|
||||
ExitNow(error = kThreadError_Parse);
|
||||
}
|
||||
}
|
||||
else if (meshHeader->GetHopsLeft() > 0)
|
||||
@@ -1485,7 +1490,7 @@ void MeshForwarder::HandleMesh(uint8_t *aFrame, uint8_t aFrameLength, const Thre
|
||||
meshHeader->SetHopsLeft(meshHeader->GetHopsLeft() - 1);
|
||||
|
||||
VerifyOrExit((message = mNetif.GetIp6().mMessagePool.New(Message::kType6lowpan, 0)) != NULL,
|
||||
error = kThreadError_Drop);
|
||||
error = kThreadError_NoBufs);
|
||||
SuccessOrExit(error = message->SetLength(aFrameLength));
|
||||
message->Write(0, aFrameLength, aFrame);
|
||||
message->SetLinkSecurityEnabled(aMessageInfo.mLinkSecurity);
|
||||
@@ -1496,9 +1501,14 @@ void MeshForwarder::HandleMesh(uint8_t *aFrame, uint8_t aFrameLength, const Thre
|
||||
|
||||
exit:
|
||||
|
||||
if (error != kThreadError_None && message != NULL)
|
||||
if (error != kThreadError_None)
|
||||
{
|
||||
message->Free();
|
||||
otLogDebgMacErr(error, "Dropping received mesh frame");
|
||||
|
||||
if (message != NULL)
|
||||
{
|
||||
message->Free();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1551,12 +1561,12 @@ void MeshForwarder::HandleFragment(uint8_t *aFrame, uint8_t aFrameLength,
|
||||
message->SetLinkSecurityEnabled(aMessageInfo.mLinkSecurity);
|
||||
message->SetPanId(aMessageInfo.mPanId);
|
||||
headerLength = mLowpan.Decompress(*message, aMacSource, aMacDest, aFrame, aFrameLength, datagramLength);
|
||||
VerifyOrExit(headerLength > 0, error = kThreadError_NoBufs);
|
||||
VerifyOrExit(headerLength > 0, error = kThreadError_Parse);
|
||||
|
||||
aFrame += headerLength;
|
||||
aFrameLength -= static_cast<uint8_t>(headerLength);
|
||||
|
||||
VerifyOrExit(message->SetLength(datagramLength) == kThreadError_None, error = kThreadError_NoBufs);
|
||||
SuccessOrExit(error = message->SetLength(datagramLength));
|
||||
datagramLength = HostSwap16(datagramLength - sizeof(Ip6::Header));
|
||||
message->Write(Ip6::Header::GetPayloadLengthOffset(), sizeof(datagramLength), &datagramLength);
|
||||
message->SetDatagramTag(datagramTag);
|
||||
@@ -1610,9 +1620,14 @@ exit:
|
||||
HandleDatagram(*message, aMessageInfo);
|
||||
}
|
||||
}
|
||||
else if (message != NULL)
|
||||
else
|
||||
{
|
||||
message->Free();
|
||||
otLogDebgMacErr(error, "Dropping received fragment");
|
||||
|
||||
if (message != NULL)
|
||||
{
|
||||
message->Free();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1663,7 +1678,7 @@ void MeshForwarder::HandleLowpanHC(uint8_t *aFrame, uint8_t aFrameLength,
|
||||
message->SetPanId(aMessageInfo.mPanId);
|
||||
|
||||
headerLength = mLowpan.Decompress(*message, aMacSource, aMacDest, aFrame, aFrameLength, 0);
|
||||
VerifyOrExit(headerLength > 0, error = kThreadError_Drop);
|
||||
VerifyOrExit(headerLength > 0, error = kThreadError_Parse);
|
||||
|
||||
aFrame += headerLength;
|
||||
aFrameLength -= static_cast<uint8_t>(headerLength);
|
||||
@@ -1684,9 +1699,14 @@ exit:
|
||||
{
|
||||
HandleDatagram(*message, aMessageInfo);
|
||||
}
|
||||
else if (message != NULL)
|
||||
else
|
||||
{
|
||||
message->Free();
|
||||
otLogDebgMacErr(error, "Dropping received lowpan HC");
|
||||
|
||||
if (message != NULL)
|
||||
{
|
||||
message->Free();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -195,11 +195,14 @@ ThreadError Mle::Start(void)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
// cannot bring up the interface if IEEE 802.15.4 promiscuous mode is enabled
|
||||
VerifyOrExit(otPlatRadioGetPromiscuous(mNetif.GetInstance()) == false, error = kThreadError_InvalidState);
|
||||
VerifyOrExit(mNetif.IsUp(), error = kThreadError_InvalidState);
|
||||
|
||||
mDeviceState = kDeviceStateDetached;
|
||||
mNetif.SetStateChangedFlags(OT_NET_ROLE);
|
||||
SetStateDetached();
|
||||
|
||||
mKeyManager.Start();
|
||||
@@ -220,11 +223,13 @@ ThreadError Mle::Start(void)
|
||||
}
|
||||
|
||||
exit:
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
ThreadError Mle::Stop(void)
|
||||
{
|
||||
otLogFuncEntry();
|
||||
mKeyManager.Stop();
|
||||
SetStateDetached();
|
||||
mNetif.RemoveUnicastAddress(mLinkLocal16);
|
||||
@@ -236,6 +241,7 @@ ThreadError Mle::Stop(void)
|
||||
}
|
||||
|
||||
mDeviceState = kDeviceStateDisabled;
|
||||
otLogFuncExit();
|
||||
return kThreadError_None;
|
||||
}
|
||||
|
||||
@@ -309,6 +315,8 @@ ThreadError Mle::BecomeDetached(void)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
VerifyOrExit(mDeviceState != kDeviceStateDisabled, error = kThreadError_InvalidState);
|
||||
|
||||
SetStateDetached();
|
||||
@@ -316,6 +324,7 @@ ThreadError Mle::BecomeDetached(void)
|
||||
BecomeChild(kMleAttachAnyPartition);
|
||||
|
||||
exit:
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -323,6 +332,8 @@ ThreadError Mle::BecomeChild(otMleAttachFilter aFilter)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
VerifyOrExit(mDeviceState != kDeviceStateDisabled, error = kThreadError_InvalidState);
|
||||
VerifyOrExit(mParentRequestState == kParentIdle, error = kThreadError_Busy);
|
||||
|
||||
@@ -338,6 +349,7 @@ ThreadError Mle::BecomeChild(otMleAttachFilter aFilter)
|
||||
mParentRequestTimer.Start(kParentRequestRouterTimeout);
|
||||
|
||||
exit:
|
||||
otLogFuncExitErr(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1870,6 +1882,12 @@ ThreadError Mle::HandleAdvertisement(const Message &aMessage, const Ip6::Message
|
||||
}
|
||||
|
||||
exit:
|
||||
|
||||
if (error != kThreadError_None)
|
||||
{
|
||||
otLogWarnMleErr(error, "Failed to process Advertisement");
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1992,6 +2010,12 @@ ThreadError Mle::HandleDataResponse(const Message &aMessage, const Ip6::MessageI
|
||||
mRetrieveNewNetworkData = false;
|
||||
|
||||
exit:
|
||||
|
||||
if (error != kThreadError_None)
|
||||
{
|
||||
otLogWarnMleErr(error, "Failed to process Data Response");
|
||||
}
|
||||
|
||||
(void)aMessageInfo;
|
||||
|
||||
if (dataRequest)
|
||||
@@ -2175,6 +2199,12 @@ ThreadError Mle::HandleParentResponse(const Message &aMessage, const Ip6::Messag
|
||||
mParentIsSingleton = connectivity.GetActiveRouters() <= 1;
|
||||
|
||||
exit:
|
||||
|
||||
if (error != kThreadError_None)
|
||||
{
|
||||
otLogWarnMleErr(error, "Failed to process Parent Response");
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -2284,6 +2314,12 @@ ThreadError Mle::HandleChildIdResponse(const Message &aMessage, const Ip6::Messa
|
||||
}
|
||||
|
||||
exit:
|
||||
|
||||
if (error != kThreadError_None)
|
||||
{
|
||||
otLogWarnMleErr(error, "Failed to process Child ID Response");
|
||||
}
|
||||
|
||||
(void)aMessageInfo;
|
||||
return error;
|
||||
}
|
||||
@@ -2394,6 +2430,12 @@ ThreadError Mle::HandleChildUpdateResponse(const Message &aMessage, const Ip6::M
|
||||
}
|
||||
|
||||
exit:
|
||||
|
||||
if (error != kThreadError_None)
|
||||
{
|
||||
otLogWarnMleErr(error, "Failed to process Child Update Response");
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -2501,6 +2543,12 @@ ThreadError Mle::HandleDiscoveryRequest(const Message &aMessage, const Ip6::Mess
|
||||
error = SendDiscoveryResponse(aMessageInfo.GetPeerAddr(), aMessage.GetPanId());
|
||||
|
||||
exit:
|
||||
|
||||
if (error != kThreadError_None)
|
||||
{
|
||||
otLogWarnMleErr(error, "Failed to process Discovery Request");
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -2682,6 +2730,12 @@ ThreadError Mle::HandleDiscoveryResponse(const Message &aMessage, const Ip6::Mes
|
||||
mDiscoverHandler(&result, mDiscoverContext);
|
||||
|
||||
exit:
|
||||
|
||||
if (error != kThreadError_None)
|
||||
{
|
||||
otLogWarnMleErr(error, "Failed to process Discovery Response");
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
* This file implements Thread's Network Diagnostic processing.
|
||||
*/
|
||||
|
||||
#define WPP_NAME "network_diag.tmh"
|
||||
|
||||
#include <coap/coap_header.hpp>
|
||||
#include <common/code_utils.hpp>
|
||||
#include <common/debug.hpp>
|
||||
|
||||
@@ -125,7 +125,7 @@ ThreadError PanIdQueryServer::SendQueryResponse(const Coap::Header &aRequestHead
|
||||
memset(&responseInfo.mSockAddr, 0, sizeof(responseInfo.mSockAddr));
|
||||
SuccessOrExit(error = mCoapServer.SendMessage(*message, responseInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent panid query response\r\n");
|
||||
otLogInfoMeshCoP("sent panid query response\n");
|
||||
|
||||
exit:
|
||||
|
||||
@@ -214,7 +214,7 @@ ThreadError PanIdQueryServer::SendConflict(void)
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent panid conflict\r\n");
|
||||
otLogInfoMeshCoP("sent panid conflict\n");
|
||||
|
||||
exit:
|
||||
|
||||
@@ -233,14 +233,14 @@ void PanIdQueryServer::HandleTimer(void *aContext)
|
||||
|
||||
void PanIdQueryServer::HandleTimer(void)
|
||||
{
|
||||
otLogInfoMeshCoP("%x\r\n", mChannelMask);
|
||||
otLogInfoMeshCoP("%x\n", mChannelMask);
|
||||
mNetif.GetMac().ActiveScan(mChannelMask, 0, HandleScanResult, this);
|
||||
mChannelMask = 0;
|
||||
}
|
||||
|
||||
void PanIdQueryServer::HandleUdpReceive(void *aContext, otMessage aMessage, const otMessageInfo *aMessageInfo)
|
||||
{
|
||||
otLogInfoMeshCoP("received panid conflict response\r\n");
|
||||
otLogInfoMeshCoP("received panid conflict response\n");
|
||||
(void)aContext;
|
||||
(void)aMessage;
|
||||
(void)aMessageInfo;
|
||||
|
||||
@@ -39,13 +39,13 @@
|
||||
|
||||
#include <openthread.h>
|
||||
#include <openthread-types.h>
|
||||
#include <common/debug.hpp>
|
||||
#include <common/code_utils.hpp>
|
||||
#include <crypto/sha256.hpp>
|
||||
#include <mac/mac.hpp>
|
||||
#include <net/ip6_address.hpp>
|
||||
#include <utils/global_address.hpp>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace Thread {
|
||||
@@ -151,11 +151,8 @@ void Slaac::UpdateAddresses(otInstance *aInstance, otNetifAddress *aAddresses, u
|
||||
}
|
||||
}
|
||||
|
||||
ThreadError Slaac::CreateRandomIid(otInstance *aInstance, otNetifAddress *aAddress, void *aContext)
|
||||
ThreadError Slaac::CreateRandomIid(otInstance *, otNetifAddress *aAddress, void *)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void) aContext;
|
||||
|
||||
for (size_t i = sizeof(aAddress[i].mAddress) - OT_IP6_IID_SIZE; i < sizeof(aAddress[i].mAddress); i++)
|
||||
{
|
||||
aAddress->mAddress.mFields.m8[i] = static_cast<uint8_t>(otPlatRandomGet());
|
||||
@@ -166,8 +163,6 @@ ThreadError Slaac::CreateRandomIid(otInstance *aInstance, otNetifAddress *aAddre
|
||||
|
||||
ThreadError SemanticallyOpaqueIidGenerator::CreateIid(otInstance *aInstance, otNetifAddress *aAddress)
|
||||
{
|
||||
(void) aInstance;
|
||||
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
for (uint32_t i = 0; i <= kMaxRetries; i++)
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <common/code_utils.hpp>
|
||||
#include <platform/alarm.h>
|
||||
#include <platform/logging.h>
|
||||
#include <platform/misc.h>
|
||||
#include <platform/radio.h>
|
||||
#include <platform/random.h>
|
||||
@@ -305,6 +306,10 @@ exit:
|
||||
return kPlatResetReason_PowerOn;
|
||||
}
|
||||
|
||||
void otPlatLog(otLogLevel , otLogRegion , const char *, ...)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Flash
|
||||
//
|
||||
|
||||
Vendored
+14
-1
@@ -41,7 +41,20 @@
|
||||
#pragma warning(disable:4244) // conversion from '*' to '*', possible loss of data
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
|
||||
#if defined(_KERNEL_MODE)
|
||||
#define MBEDTLS_PLATFORM_EXIT_MACRO
|
||||
__inline int windows_kernel_snprintf(char * s, size_t n, const char * format, ...)
|
||||
{
|
||||
va_list argp;
|
||||
va_start( argp, format );
|
||||
int ret = _vsnprintf_s( s, n, _TRUNCATE, format, argp );
|
||||
va_end( argp );
|
||||
return ret;
|
||||
}
|
||||
#define MBEDTLS_PLATFORM_STD_SNPRINTF windows_kernel_snprintf
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) && !defined(_KERNEL_MODE)
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user