mirror of
https://github.com/espressif/openthread.git
synced 2026-06-06 05:24:51 +00:00
[meshcop] use IEEE EUI-64 rather than Joiner ID on user input (#2311)
This commit is contained in:
@@ -256,7 +256,7 @@ Data per item is:
|
||||
|
||||
* `U`: PSKd
|
||||
* `L`: Timeout in seconds
|
||||
* `E`: Extended/long address (optional)
|
||||
* `E`: IEEE EUI-64 (optional)
|
||||
|
||||
Passess Pre-Shared Key for the Device to the NCP in the commissioning process.
|
||||
When the Extended address is ommited all Devices which provided a valid PSKd
|
||||
|
||||
@@ -104,9 +104,10 @@
|
||||
<ClCompile Include="..\..\src\core\meshcop\joiner.cpp" />
|
||||
<ClCompile Include="..\..\src\core\meshcop\joiner_router.cpp" />
|
||||
<ClCompile Include="..\..\src\core\meshcop\leader.cpp" />
|
||||
<ClCompile Include="..\..\src\core\meshcop\meshcop.cpp" />
|
||||
<ClCompile Include="..\..\src\core\meshcop\meshcop_tlvs.cpp" />
|
||||
<ClCompile Include="..\..\src\core\meshcop\panid_query_client.cpp" />
|
||||
<ClCompile Include="..\..\src\core\meshcop\timestamp.cpp" />
|
||||
<ClCompile Include="..\..\src\core\meshcop\meshcop_tlvs.cpp" />
|
||||
<ClCompile Include="..\..\src\core\net\dhcp6_client.cpp" />
|
||||
<ClCompile Include="..\..\src\core\net\dhcp6_server.cpp" />
|
||||
<ClCompile Include="..\..\src\core\net\icmp6.cpp" />
|
||||
@@ -181,9 +182,10 @@
|
||||
<ClInclude Include="..\..\src\core\meshcop\joiner.hpp" />
|
||||
<ClInclude Include="..\..\src\core\meshcop\joiner_router.hpp" />
|
||||
<ClInclude Include="..\..\src\core\meshcop\leader.hpp" />
|
||||
<ClInclude Include="..\..\src\core\meshcop\meshcop.hpp" />
|
||||
<ClInclude Include="..\..\src\core\meshcop\meshcop_tlvs.hpp" />
|
||||
<ClInclude Include="..\..\src\core\meshcop\panid_query_client.hpp" />
|
||||
<ClInclude Include="..\..\src\core\meshcop\timestamp.hpp" />
|
||||
<ClInclude Include="..\..\src\core\meshcop\tlvs.hpp" />
|
||||
<ClInclude Include="..\..\src\core\net\icmp6.hpp" />
|
||||
<ClInclude Include="..\..\src\core\net\ip6.hpp" />
|
||||
<ClInclude Include="..\..\src\core\net\ip6_address.hpp" />
|
||||
|
||||
@@ -112,9 +112,10 @@
|
||||
<ClCompile Include="..\..\src\core\meshcop\joiner.cpp" />
|
||||
<ClCompile Include="..\..\src\core\meshcop\joiner_router.cpp" />
|
||||
<ClCompile Include="..\..\src\core\meshcop\leader.cpp" />
|
||||
<ClCompile Include="..\..\src\core\meshcop\meshcop.cpp" />
|
||||
<ClCompile Include="..\..\src\core\meshcop\meshcop_tlvs.cpp" />
|
||||
<ClCompile Include="..\..\src\core\meshcop\panid_query_client.cpp" />
|
||||
<ClCompile Include="..\..\src\core\meshcop\timestamp.cpp" />
|
||||
<ClCompile Include="..\..\src\core\meshcop\meshcop_tlvs.cpp" />
|
||||
<ClCompile Include="..\..\src\core\net\dhcp6_client.cpp" />
|
||||
<ClCompile Include="..\..\src\core\net\dhcp6_server.cpp" />
|
||||
<ClCompile Include="..\..\src\core\net\icmp6.cpp" />
|
||||
@@ -213,9 +214,10 @@
|
||||
<ClInclude Include="..\..\src\core\meshcop\joiner.hpp" />
|
||||
<ClInclude Include="..\..\src\core\meshcop\joiner_router.hpp" />
|
||||
<ClInclude Include="..\..\src\core\meshcop\leader.hpp" />
|
||||
<ClInclude Include="..\..\src\core\meshcop\meshcop.hpp" />
|
||||
<ClInclude Include="..\..\src\core\meshcop\meshcop_tlvs.hpp" />
|
||||
<ClInclude Include="..\..\src\core\meshcop\panid_query_client.hpp" />
|
||||
<ClInclude Include="..\..\src\core\meshcop\timestamp.hpp" />
|
||||
<ClInclude Include="..\..\src\core\meshcop\tlvs.hpp" />
|
||||
<ClInclude Include="..\..\src\core\net\dhcp6.hpp" />
|
||||
<ClInclude Include="..\..\src\core\net\dhcp6_client.hpp" />
|
||||
<ClInclude Include="..\..\src\core\net\dhcp6_server.hpp" />
|
||||
|
||||
@@ -211,7 +211,7 @@ public:
|
||||
uint64_t get()
|
||||
{
|
||||
uint64_t addr;
|
||||
otLinkGetJoinerId(DeviceInstance, (otExtAddress*)&addr);
|
||||
otJoinerGetId(DeviceInstance, (otExtAddress*)&addr);
|
||||
return addr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,7 +542,7 @@ typedef struct otCommissionConfig
|
||||
// GUID - InterfaceGuid
|
||||
// otExtAddress - aEui64
|
||||
|
||||
#define IOCTL_OTLWF_OT_HASH_MAC_ADDRESS \
|
||||
#define IOCTL_OTLWF_OT_JOINER_ID \
|
||||
OTLWF_CTL_CODE(172, METHOD_BUFFERED, FILE_READ_DATA)
|
||||
// GUID - InterfaceGuid
|
||||
// otExtAddress - aEui64
|
||||
|
||||
@@ -146,9 +146,14 @@ OTNODEAPI uint16_t OTCALL otNodeGetAddr16(otNode* aNode);
|
||||
OTNODEAPI const char* OTCALL otNodeGetAddr64(otNode* aNode);
|
||||
|
||||
/**
|
||||
* Gets the node's hash mac address
|
||||
* Gets the node's eui-64 address
|
||||
*/
|
||||
OTNODEAPI const char* OTCALL otNodeGetHashMacAddress(otNode* aNode);
|
||||
OTNODEAPI const char* OTCALL otNodeGetEui64(otNode* aNode);
|
||||
|
||||
/**
|
||||
* Gets the node's joiner id
|
||||
*/
|
||||
OTNODEAPI const char* OTCALL otNodeGetJoinerId(otNode* aNode);
|
||||
|
||||
/**
|
||||
* Sets the channel for the node
|
||||
|
||||
@@ -1547,18 +1547,6 @@ otLinkGetFactoryAssignedIeeeEui64(
|
||||
(void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_FACTORY_EUI64, aEui64);
|
||||
}
|
||||
|
||||
OTAPI
|
||||
void
|
||||
OTCALL
|
||||
otLinkGetJoinerId(
|
||||
_In_ otInstance *aInstance,
|
||||
_Out_ otExtAddress *aHashMacAddress
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return;
|
||||
(void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_HASH_MAC_ADDRESS, aHashMacAddress);
|
||||
}
|
||||
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
@@ -3919,6 +3907,18 @@ otJoinerStop(
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_JOINER_STOP));
|
||||
}
|
||||
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otJoinerGetId(
|
||||
_In_ otInstance *aInstance,
|
||||
_Out_ otExtAddress *aJoinerId
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_JOINER_ID, aJoinerId));
|
||||
}
|
||||
|
||||
OTAPI
|
||||
int8_t
|
||||
OTCALL
|
||||
|
||||
@@ -116,7 +116,7 @@ OTLWF_IOCTL_HANDLER IoCtls[] =
|
||||
{ "IOCTL_OTLWF_OT_JOINER_START", REF_IOCTL_FUNC(otJoinerStart) },
|
||||
{ "IOCTL_OTLWF_OT_JOINER_STOP", REF_IOCTL_FUNC(otJoinerStop) },
|
||||
{ "IOCTL_OTLWF_OT_FACTORY_EUI64", REF_IOCTL_FUNC(otFactoryAssignedIeeeEui64) },
|
||||
{ "IOCTL_OTLWF_OT_HASH_MAC_ADDRESS", REF_IOCTL_FUNC(otHashMacAddress) },
|
||||
{ "IOCTL_OTLWF_OT_JOINER_ID", REF_IOCTL_FUNC(otJoinerId) },
|
||||
{ "IOCTL_OTLWF_OT_ROUTER_DOWNGRADE_THRESHOLD", REF_IOCTL_FUNC_WITH_TUN(otRouterDowngradeThreshold) },
|
||||
{ "IOCTL_OTLWF_OT_COMMISSIONER_PANID_QUERY", REF_IOCTL_FUNC(otCommissionerPanIdQuery) },
|
||||
{ "IOCTL_OTLWF_OT_COMMISSIONER_ENERGY_SCAN", REF_IOCTL_FUNC(otCommissionerEnergyScan) },
|
||||
@@ -1374,7 +1374,7 @@ otLwfIoCtl_otFactoryAssignedIeeeEui64(
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfIoCtl_otHashMacAddress(
|
||||
otLwfIoCtl_otJoinerId(
|
||||
_In_ PMS_FILTER pFilter,
|
||||
_In_reads_bytes_(InBufferLength)
|
||||
PUCHAR InBuffer,
|
||||
@@ -1391,9 +1391,8 @@ otLwfIoCtl_otHashMacAddress(
|
||||
|
||||
if (*OutBufferLength >= sizeof(otExtAddress))
|
||||
{
|
||||
otLinkGetJoinerId(pFilter->otCtx, (otExtAddress*)OutBuffer);
|
||||
status = ThreadErrorToNtstatus(otJoinerGetId(pFilter->otCtx, (otExtAddress*)OutBuffer));
|
||||
*OutBufferLength = sizeof(otExtAddress);
|
||||
status = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -202,7 +202,7 @@ DECL_IOCTL_FUNC(otCommissionerStop);
|
||||
DECL_IOCTL_FUNC(otJoinerStart);
|
||||
DECL_IOCTL_FUNC(otJoinerStop);
|
||||
DECL_IOCTL_FUNC(otFactoryAssignedIeeeEui64);
|
||||
DECL_IOCTL_FUNC(otHashMacAddress);
|
||||
DECL_IOCTL_FUNC(otJoinerId);
|
||||
DECL_IOCTL_FUNC_WITH_TUN2(otRouterDowngradeThreshold);
|
||||
DECL_IOCTL_FUNC(otCommissionerPanIdQuery);
|
||||
DECL_IOCTL_FUNC(otCommissionerEnergyScan);
|
||||
|
||||
@@ -1146,23 +1146,6 @@ OTNODEAPI uint16_t OTCALL otNodeGetAddr16(otNode* aNode)
|
||||
return result;
|
||||
}
|
||||
|
||||
OTNODEAPI const char* OTCALL otNodeGetHashMacAddress(otNode* aNode)
|
||||
{
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
otExtAddress aHashMacAddress = {};
|
||||
otLinkGetJoinerId(aNode->mInstance, &aHashMacAddress);
|
||||
char* str = (char*)malloc(18);
|
||||
if (str != nullptr)
|
||||
{
|
||||
aNode->mMemoryToFree.push_back(str);
|
||||
for (int i = 0; i < 8; i++)
|
||||
sprintf_s(str + i * 2, 18 - (2 * i), "%02x", aHashMacAddress.m8[i]);
|
||||
printf("%d: hashmacaddr\r\n%s\r\n", aNode->mId, str);
|
||||
}
|
||||
otLogFuncExit();
|
||||
return str;
|
||||
}
|
||||
|
||||
OTNODEAPI const char* OTCALL otNodeGetAddr64(otNode* aNode)
|
||||
{
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
@@ -1180,6 +1163,40 @@ OTNODEAPI const char* OTCALL otNodeGetAddr64(otNode* aNode)
|
||||
return str;
|
||||
}
|
||||
|
||||
OTNODEAPI const char* OTCALL otNodeGetEui64(otNode* aNode)
|
||||
{
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
otExtAddress aEui64 = {};
|
||||
otLinkGetFactoryAssignedIeeeEui64(aNode->mInstance, &aEui64);
|
||||
char* str = (char*)malloc(18);
|
||||
if (str != nullptr)
|
||||
{
|
||||
aNode->mMemoryToFree.push_back(str);
|
||||
for (int i = 0; i < 8; i++)
|
||||
sprintf_s(str + i * 2, 18 - (2 * i), "%02x", aEui64.m8[i]);
|
||||
printf("%d: eui64\r\n%s\r\n", aNode->mId, str);
|
||||
}
|
||||
otLogFuncExit();
|
||||
return str;
|
||||
}
|
||||
|
||||
OTNODEAPI const char* OTCALL otNodeGetJoinerId(otNode* aNode)
|
||||
{
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
otExtAddress aJoinerId = {};
|
||||
otJoinerGetId(aNode->mInstance, &aJoinerId);
|
||||
char* str = (char*)malloc(18);
|
||||
if (str != nullptr)
|
||||
{
|
||||
aNode->mMemoryToFree.push_back(str);
|
||||
for (int i = 0; i < 8; i++)
|
||||
sprintf_s(str + i * 2, 18 - (2 * i), "%02x", aJoinerId.m8[i]);
|
||||
printf("%d: joinerid\r\n%s\r\n", aNode->mId, str);
|
||||
}
|
||||
otLogFuncExit();
|
||||
return str;
|
||||
}
|
||||
|
||||
OTNODEAPI int32_t OTCALL otNodeSetChannel(otNode* aNode, uint8_t aChannel)
|
||||
{
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
|
||||
@@ -86,37 +86,37 @@ OTAPI otError OTCALL otCommissionerStop(otInstance *aInstance);
|
||||
/**
|
||||
* This function adds a Joiner entry.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aExtAddress A pointer to the Joiner's extended address or NULL for any Joiner.
|
||||
* @param[in] aPSKd A pointer to the PSKd.
|
||||
* @param[in] aTimeout A time after which a Joiner is automatically removed, in seconds.
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEui64 A pointer to the Joiner's IEEE EUI-64 or NULL for any Joiner.
|
||||
* @param[in] aPSKd A pointer to the PSKd.
|
||||
* @param[in] aTimeout A time after which a Joiner is automatically removed, in seconds.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added the Joiner.
|
||||
* @retval OT_ERROR_NO_BUFS No buffers available to add the Joiner.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aExtAddress or @p aPSKd is invalid.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aEui64 or @p aPSKd is invalid.
|
||||
* @retval OT_ERROR_INVALID_STATE The commissioner is not active.
|
||||
*
|
||||
* @note Only use this after successfully starting the Commissioner role with otCommissionerStart().
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otCommissionerAddJoiner(otInstance *aInstance, const otExtAddress *aExtAddress,
|
||||
OTAPI otError OTCALL otCommissionerAddJoiner(otInstance *aInstance, const otExtAddress *aEui64,
|
||||
const char *aPSKd, uint32_t aTimeout);
|
||||
|
||||
/**
|
||||
* This function removes a Joiner entry.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aExtAddress A pointer to the Joiner's extended address or NULL for any Joiner.
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEui64 A pointer to the Joiner's IEEE EUI-64 or NULL for any Joiner.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully removed the Joiner.
|
||||
* @retval OT_ERROR_NOT_FOUND The Joiner specified by @p aExtAddress was not found.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aExtAddress is invalid.
|
||||
* @retval OT_ERROR_NOT_FOUND The Joiner specified by @p aEui64 was not found.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aEui64 is invalid.
|
||||
* @retval OT_ERROR_INVALID_STATE The commissioner is not active.
|
||||
*
|
||||
* @note Only use this after successfully starting the Commissioner role with otCommissionerStart().
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otCommissionerRemoveJoiner(otInstance *aInstance, const otExtAddress *aExtAddress);
|
||||
OTAPI otError OTCALL otCommissionerRemoveJoiner(otInstance *aInstance, const otExtAddress *aEui64);
|
||||
|
||||
/**
|
||||
* This function sets the Provisioning URL.
|
||||
|
||||
@@ -91,8 +91,9 @@ typedef void (OTCALL *otJoinerCallback)(otError aError, void *aContext);
|
||||
* @param[in] aCallback A pointer to a function that is called when the join operation completes.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the Commissioner role.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aPSKd or @p aProvisioningUrl is invalid.
|
||||
* @retval OT_ERROR_NONE Successfully started the Commissioner role.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aPSKd or @p aProvisioningUrl is invalid.
|
||||
* @retval OT_ERROR_DISABLED_FEATURE The Joiner feature is not enabled in this build.
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otJoinerStart(otInstance *aInstance, const char *aPSKd, const char *aProvisioningUrl,
|
||||
@@ -105,6 +106,9 @@ OTAPI otError OTCALL otJoinerStart(otInstance *aInstance, const char *aPSKd, con
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully disabled the Joiner role.
|
||||
* @retval OT_ERROR_DISABLED_FEATURE The Joiner feature is not enabled in this build.
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otJoinerStop(otInstance *aInstance);
|
||||
|
||||
@@ -123,6 +127,21 @@ OTAPI otError OTCALL otJoinerStop(otInstance *aInstance);
|
||||
*/
|
||||
OTAPI otJoinerState OTCALL otJoinerGetState(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the Joiner ID.
|
||||
*
|
||||
* Joiner ID is the first 64 bits of the result of computing SHA-256 over factory-assigned
|
||||
* IEEE EUI-64, which is used as IEEE 802.15.4 Extended Address during commissioning process.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[out] aJoinerId A pointer to where the Joiner ID is placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the Joiner ID.
|
||||
* @retval OT_ERROR_DISABLED_FEATURE The Joiner feature is not enabled in this build.
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otJoinerGetId(otInstance *aInstance, otExtAddress *aJoinerId);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
|
||||
@@ -212,18 +212,6 @@ OTAPI otError OTCALL otLinkSetExtendedAddress(otInstance *aInstance, const otExt
|
||||
*/
|
||||
OTAPI void OTCALL otLinkGetFactoryAssignedIeeeEui64(otInstance *aInstance, otExtAddress *aEui64);
|
||||
|
||||
/**
|
||||
* Get the Joiner ID.
|
||||
*
|
||||
* Joiner ID is the first 64 bits of the result of computing SHA-256 over factory-assigned
|
||||
* IEEE EUI-64, which is used as IEEE 802.15.4 Extended Address during commissioning process.
|
||||
*
|
||||
* @param[in] aInstance A pointer to the OpenThread instance.
|
||||
* @param[out] aHashMacAddress A pointer to where the Hash Mac Address is placed.
|
||||
*
|
||||
*/
|
||||
OTAPI void OTCALL otLinkGetJoinerId(otInstance *aInstance, otExtAddress *aHashMacAddress);
|
||||
|
||||
/**
|
||||
* This function returns the maximum transmit power setting in dBm.
|
||||
*
|
||||
|
||||
+15
-15
@@ -26,11 +26,11 @@ OpenThread test scripts use the CLI to execute test cases.
|
||||
* [extaddr](#extaddr)
|
||||
* [extpanid](#extpanid)
|
||||
* [factoryreset](#factoryreset)
|
||||
* [hashmacaddr](#hashmacaddr)
|
||||
* [ifconfig](#ifconfig)
|
||||
* [ipaddr](#ipaddr)
|
||||
* [ipmaddr](#ipmaddr)
|
||||
* [joiner](#joiner-start-pskd-provisioningurl)
|
||||
* [joinerid](#joinerid)
|
||||
* [joinerport](#joinerport-port)
|
||||
* [keysequence](#keysequence-counter)
|
||||
* [leaderdata](#leaderdata)
|
||||
@@ -295,11 +295,11 @@ This command will cause the device to send LEAD_KA[Reject] messages.
|
||||
Done
|
||||
```
|
||||
|
||||
### commissioner joiner add \<hashmacaddr\> \<psdk\>
|
||||
### commissioner joiner add \<eui64\> \<psdk\>
|
||||
|
||||
Add a Joiner entry.
|
||||
|
||||
* hashmacaddr: The Extended Address of the Joiner or '*' to match any Joiner.
|
||||
* eui64: The IEEE EUI-64 of the Joiner or '*' to match any Joiner.
|
||||
* pskd: Pre-Shared Key for the Joiner.
|
||||
|
||||
```bash
|
||||
@@ -307,11 +307,11 @@ Add a Joiner entry.
|
||||
Done
|
||||
```
|
||||
|
||||
### commissioner joiner remove \<hashmacaddr\>
|
||||
### commissioner joiner remove \<eui64\>
|
||||
|
||||
Remove a Joiner entry.
|
||||
|
||||
* hashmacaddr: The Extended Address of the Joiner or '*' to match any Joiner.
|
||||
* eui64: The IEEE EUI-64 of the Joiner or '*' to match any Joiner.
|
||||
|
||||
```bash
|
||||
> commissioner joiner remove d45e64fa83f81cf7
|
||||
@@ -768,16 +768,6 @@ Delete all stored settings, and signal a platform reset.
|
||||
> factoryreset
|
||||
```
|
||||
|
||||
### hashmacaddr
|
||||
|
||||
Get the HashMac address.
|
||||
|
||||
```bash
|
||||
> hashmacaddr
|
||||
e0b220eb7d8dda7e
|
||||
Done
|
||||
```
|
||||
|
||||
### ifconfig
|
||||
|
||||
Show the status of the IPv6 interface.
|
||||
@@ -918,6 +908,16 @@ Stop the Joiner role.
|
||||
Done
|
||||
```
|
||||
|
||||
### joinerid
|
||||
|
||||
Get the Joiner ID.
|
||||
|
||||
```bash
|
||||
> joinerid
|
||||
e0b220eb7d8dda7e
|
||||
Done
|
||||
```
|
||||
|
||||
### joinerport \<port\>
|
||||
|
||||
Set the Joiner port.
|
||||
|
||||
+17
-17
@@ -136,7 +136,6 @@ const struct Command Interpreter::sCommands[] =
|
||||
{ "extaddr", &Interpreter::ProcessExtAddress },
|
||||
{ "extpanid", &Interpreter::ProcessExtPanId },
|
||||
{ "factoryreset", &Interpreter::ProcessFactoryReset },
|
||||
{ "hashmacaddr", &Interpreter::ProcessHashMacAddress },
|
||||
{ "ifconfig", &Interpreter::ProcessIfconfig },
|
||||
#ifdef OTDLL
|
||||
{ "instance", &Interpreter::ProcessInstance },
|
||||
@@ -148,6 +147,7 @@ const struct Command Interpreter::sCommands[] =
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_JOINER
|
||||
{ "joiner", &Interpreter::ProcessJoiner },
|
||||
{ "joinerid", &Interpreter::ProcessJoinerId },
|
||||
#endif
|
||||
#if OPENTHREAD_FTD
|
||||
{ "joinerport", &Interpreter::ProcessJoinerPort },
|
||||
@@ -984,22 +984,6 @@ void Interpreter::ProcessFactoryReset(int argc, char *argv[])
|
||||
OT_UNUSED_VARIABLE(argv);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessHashMacAddress(int argc, char *argv[])
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otExtAddress hashMacAddress;
|
||||
|
||||
VerifyOrExit(argc == 0, error = OT_ERROR_PARSE);
|
||||
|
||||
otLinkGetJoinerId(mInstance, &hashMacAddress);
|
||||
OutputBytes(hashMacAddress.m8, OT_EXT_ADDRESS_SIZE);
|
||||
mServer->OutputFormat("\r\n");
|
||||
|
||||
exit:
|
||||
OT_UNUSED_VARIABLE(argv);
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessIfconfig(int argc, char *argv[])
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
@@ -2984,6 +2968,22 @@ exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessJoinerId(int argc, char *argv[])
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otExtAddress joinerId;
|
||||
|
||||
VerifyOrExit(argc == 0, error = OT_ERROR_PARSE);
|
||||
|
||||
otJoinerGetId(mInstance, &joinerId);
|
||||
OutputBytes(joinerId.m8, sizeof(joinerId));
|
||||
mServer->OutputFormat("\r\n");
|
||||
|
||||
exit:
|
||||
OT_UNUSED_VARIABLE(argv);
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_JOINER
|
||||
|
||||
void OTCALL Interpreter::s_HandleJoinerCallback(otError aError, void *aContext)
|
||||
|
||||
+1
-1
@@ -226,7 +226,6 @@ private:
|
||||
void ProcessExtAddress(int argc, char *argv[]);
|
||||
void ProcessExtPanId(int argc, char *argv[]);
|
||||
void ProcessFactoryReset(int argc, char *argv[]);
|
||||
void ProcessHashMacAddress(int argc, char *argv[]);
|
||||
void ProcessIfconfig(int argc, char *argv[]);
|
||||
void ProcessIpAddr(int argc, char *argv[]);
|
||||
otError ProcessIpAddrAdd(int argc, char *argv[]);
|
||||
@@ -239,6 +238,7 @@ private:
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_JOINER
|
||||
void ProcessJoiner(int argc, char *argv[]);
|
||||
void ProcessJoinerId(int argc, char *argv[]);
|
||||
#endif // OPENTHREAD_ENABLE_JOINER
|
||||
#if OPENTHREAD_FTD
|
||||
void ProcessJoinerPort(int argc, char *argv[]);
|
||||
|
||||
@@ -144,9 +144,10 @@ SOURCES_COMMON = \
|
||||
meshcop/joiner.cpp \
|
||||
meshcop/joiner_router.cpp \
|
||||
meshcop/leader.cpp \
|
||||
meshcop/meshcop.cpp \
|
||||
meshcop/meshcop_tlvs.cpp \
|
||||
meshcop/panid_query_client.cpp \
|
||||
meshcop/timestamp.cpp \
|
||||
meshcop/meshcop_tlvs.cpp \
|
||||
net/dhcp6_client.cpp \
|
||||
net/dhcp6_server.cpp \
|
||||
net/dns_client.cpp \
|
||||
@@ -242,9 +243,9 @@ HEADERS_COMMON = \
|
||||
meshcop/joiner_router.hpp \
|
||||
meshcop/leader.hpp \
|
||||
meshcop/meshcop.hpp \
|
||||
meshcop/meshcop_tlvs.hpp \
|
||||
meshcop/panid_query_client.hpp \
|
||||
meshcop/timestamp.hpp \
|
||||
meshcop/meshcop_tlvs.hpp \
|
||||
net/dhcp6.hpp \
|
||||
net/dhcp6_client.hpp \
|
||||
net/dhcp6_server.hpp \
|
||||
|
||||
@@ -65,17 +65,17 @@ otError otCommissionerStop(otInstance *aInstance)
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otCommissionerAddJoiner(otInstance *aInstance, const otExtAddress *aExtAddress, const char *aPSKd,
|
||||
otError otCommissionerAddJoiner(otInstance *aInstance, const otExtAddress *aEui64, const char *aPSKd,
|
||||
uint32_t aTimeout)
|
||||
{
|
||||
otError error = OT_ERROR_DISABLED_FEATURE;
|
||||
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_ENABLE_COMMISSIONER
|
||||
error = aInstance->mThreadNetif.GetCommissioner().AddJoiner(static_cast<const Mac::ExtAddress *>(aExtAddress), aPSKd,
|
||||
error = aInstance->mThreadNetif.GetCommissioner().AddJoiner(static_cast<const Mac::ExtAddress *>(aEui64), aPSKd,
|
||||
aTimeout);
|
||||
#else // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aExtAddress);
|
||||
OT_UNUSED_VARIABLE(aEui64);
|
||||
OT_UNUSED_VARIABLE(aPSKd);
|
||||
OT_UNUSED_VARIABLE(aTimeout);
|
||||
#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
|
||||
@@ -83,15 +83,15 @@ otError otCommissionerAddJoiner(otInstance *aInstance, const otExtAddress *aExtA
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otCommissionerRemoveJoiner(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
otError otCommissionerRemoveJoiner(otInstance *aInstance, const otExtAddress *aEui64)
|
||||
{
|
||||
otError error = OT_ERROR_DISABLED_FEATURE;
|
||||
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_ENABLE_COMMISSIONER
|
||||
error = aInstance->mThreadNetif.GetCommissioner().RemoveJoiner(static_cast<const Mac::ExtAddress *>(aExtAddress), 0);
|
||||
error = aInstance->mThreadNetif.GetCommissioner().RemoveJoiner(static_cast<const Mac::ExtAddress *>(aEui64), 0);
|
||||
#else // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aExtAddress);
|
||||
OT_UNUSED_VARIABLE(aEui64);
|
||||
#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
|
||||
|
||||
return error;
|
||||
|
||||
@@ -50,7 +50,7 @@ otError otJoinerStart(otInstance *aInstance, const char *aPSKd, const char *aPro
|
||||
error = aInstance->mThreadNetif.GetJoiner().Start(aPSKd, aProvisioningUrl,
|
||||
aVendorName, aVendorModel, aVendorSwVersion, aVendorData,
|
||||
aCallback, aContext);
|
||||
#else // OPENTHREAD_ENABLE_JOINER
|
||||
#else
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aPSKd);
|
||||
OT_UNUSED_VARIABLE(aProvisioningUrl);
|
||||
@@ -60,7 +60,7 @@ otError otJoinerStart(otInstance *aInstance, const char *aPSKd, const char *aPro
|
||||
OT_UNUSED_VARIABLE(aVendorData);
|
||||
OT_UNUSED_VARIABLE(aCallback);
|
||||
OT_UNUSED_VARIABLE(aContext);
|
||||
#endif // OPENTHREAD_ENABLE_JOINER
|
||||
#endif
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -71,9 +71,9 @@ otError otJoinerStop(otInstance *aInstance)
|
||||
|
||||
#if OPENTHREAD_ENABLE_JOINER
|
||||
error = aInstance->mThreadNetif.GetJoiner().Stop();
|
||||
#else // OPENTHREAD_ENABLE_JOINER
|
||||
#else
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
#endif // OPENTHREAD_ENABLE_JOINER
|
||||
#endif
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -84,9 +84,24 @@ otJoinerState otJoinerGetState(otInstance *aInstance)
|
||||
|
||||
#if OPENTHREAD_ENABLE_JOINER
|
||||
state = aInstance->mThreadNetif.GetJoiner().GetState();
|
||||
#else // OPENTHREAD_ENABLE_JOINER
|
||||
#else
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
#endif // OPENTHREAD_ENABLE_JOINER
|
||||
#endif
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
otError otJoinerGetId(otInstance *aInstance, otExtAddress *aJoinerId)
|
||||
{
|
||||
otError error = OT_ERROR_DISABLED_FEATURE;
|
||||
|
||||
#if OPENTHREAD_ENABLE_JOINER
|
||||
aInstance->mThreadNetif.GetJoiner().GetJoinerId(*static_cast<Mac::ExtAddress *>(aJoinerId));
|
||||
error = OT_ERROR_NONE;
|
||||
#else
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aJoinerId);
|
||||
#endif
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -88,11 +88,6 @@ void otLinkGetFactoryAssignedIeeeEui64(otInstance *aInstance, otExtAddress *aEui
|
||||
otPlatRadioGetIeeeEui64(aInstance, aEui64->m8);
|
||||
}
|
||||
|
||||
void otLinkGetJoinerId(otInstance *aInstance, otExtAddress *aHashMacAddress)
|
||||
{
|
||||
aInstance->mThreadNetif.GetMac().GetHashMacAddress(static_cast<Mac::ExtAddress *>(aHashMacAddress));
|
||||
}
|
||||
|
||||
int8_t otLinkGetMaxTransmitPower(otInstance *aInstance)
|
||||
{
|
||||
return aInstance->mThreadNetif.GetMac().GetMaxTransmitPower();
|
||||
|
||||
@@ -489,24 +489,6 @@ void Mac::SetExtAddress(const ExtAddress &aExtAddress)
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
void Mac::GetHashMacAddress(ExtAddress *aHashMacAddress)
|
||||
{
|
||||
Crypto::Sha256 sha256;
|
||||
uint8_t buf[Crypto::Sha256::kHashSize];
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
otPlatRadioGetIeeeEui64(&GetInstance(), buf);
|
||||
sha256.Start();
|
||||
sha256.Update(buf, OT_EXT_ADDRESS_SIZE);
|
||||
sha256.Finish(buf);
|
||||
|
||||
memcpy(aHashMacAddress->m8, buf, OT_EXT_ADDRESS_SIZE);
|
||||
aHashMacAddress->SetLocal(true);
|
||||
|
||||
otLogFuncExitMsg("%llX", HostSwap64(*reinterpret_cast<uint64_t *>(aHashMacAddress)));
|
||||
}
|
||||
|
||||
otError Mac::SetShortAddress(ShortAddress aShortAddress)
|
||||
{
|
||||
otLogFuncEntryMsg("%d", aShortAddress);
|
||||
|
||||
@@ -366,17 +366,6 @@ public:
|
||||
*/
|
||||
void SetExtAddress(const ExtAddress &aExtAddress);
|
||||
|
||||
/**
|
||||
* This method gets the Hash Mac Address.
|
||||
*
|
||||
* Hash Mac Address is the first 64 bits of the result of computing SHA-256 over factory-assigned
|
||||
* IEEE EUI-64, which is used as IEEE 802.15.4 Extended Address during commissioning process.
|
||||
*
|
||||
* @param[out] aHashMacAddress A pointer to where the Hash Mac Address is placed.
|
||||
*
|
||||
*/
|
||||
void GetHashMacAddress(ExtAddress *aHashMacAddress);
|
||||
|
||||
/**
|
||||
* This method returns the IEEE 802.15.4 Short Address.
|
||||
*
|
||||
|
||||
@@ -174,7 +174,7 @@ otError Commissioner::SendCommissionerSet(void)
|
||||
break;
|
||||
}
|
||||
|
||||
steeringData.ComputeBloomFilter(&mJoiners[i].mExtAddress);
|
||||
steeringData.ComputeBloomFilter(mJoiners[i].mJoinerId);
|
||||
}
|
||||
|
||||
// set bloom filter
|
||||
@@ -202,15 +202,15 @@ void Commissioner::ClearJoiners(void)
|
||||
otLogFuncExit();
|
||||
}
|
||||
|
||||
otError Commissioner::AddJoiner(const Mac::ExtAddress *aExtAddress, const char *aPSKd, uint32_t aTimeout)
|
||||
otError Commissioner::AddJoiner(const Mac::ExtAddress *aEui64, const char *aPSKd, uint32_t aTimeout)
|
||||
{
|
||||
otError error = OT_ERROR_NO_BUFS;
|
||||
|
||||
VerifyOrExit(mState == OT_COMMISSIONER_STATE_ACTIVE, error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
otLogFuncEntryMsg("%llX, %s", (aExtAddress ? HostSwap64(*reinterpret_cast<const uint64_t *>(aExtAddress)) : 0), aPSKd);
|
||||
otLogFuncEntryMsg("%llX, %s", (aEui64 ? HostSwap64(*reinterpret_cast<const uint64_t *>(aEui64)) : 0), aPSKd);
|
||||
VerifyOrExit(strlen(aPSKd) <= Dtls::kPskMaxLength, error = OT_ERROR_INVALID_ARGS);
|
||||
RemoveJoiner(aExtAddress, 0); // remove imediately
|
||||
RemoveJoiner(aEui64, 0); // remove immediately
|
||||
|
||||
for (size_t i = 0; i < sizeof(mJoiners) / sizeof(mJoiners[0]); i++)
|
||||
{
|
||||
@@ -219,9 +219,9 @@ otError Commissioner::AddJoiner(const Mac::ExtAddress *aExtAddress, const char *
|
||||
continue;
|
||||
}
|
||||
|
||||
if (aExtAddress != NULL)
|
||||
if (aEui64 != NULL)
|
||||
{
|
||||
mJoiners[i].mExtAddress = *aExtAddress;
|
||||
ComputeJoinerId(*aEui64, mJoiners[i].mJoinerId);
|
||||
mJoiners[i].mAny = false;
|
||||
}
|
||||
else
|
||||
@@ -245,13 +245,19 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError Commissioner::RemoveJoiner(const Mac::ExtAddress *aExtAddress, uint32_t aDelay)
|
||||
otError Commissioner::RemoveJoiner(const Mac::ExtAddress *aEui64, uint32_t aDelay)
|
||||
{
|
||||
otError error = OT_ERROR_NOT_FOUND;
|
||||
Mac::ExtAddress joinerId;
|
||||
|
||||
VerifyOrExit(mState == OT_COMMISSIONER_STATE_ACTIVE, error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
otLogFuncEntryMsg("%llX", (aExtAddress ? HostSwap64(*reinterpret_cast<const uint64_t *>(aExtAddress)) : 0));
|
||||
otLogFuncEntryMsg("%llX", (aEui64 ? HostSwap64(*reinterpret_cast<const uint64_t *>(aEui64)) : 0));
|
||||
|
||||
if (aEui64 != NULL)
|
||||
{
|
||||
ComputeJoinerId(*aEui64, joinerId);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < sizeof(mJoiners) / sizeof(mJoiners[0]); i++)
|
||||
{
|
||||
@@ -260,9 +266,9 @@ otError Commissioner::RemoveJoiner(const Mac::ExtAddress *aExtAddress, uint32_t
|
||||
continue;
|
||||
}
|
||||
|
||||
if (aExtAddress != NULL)
|
||||
if (aEui64 != NULL)
|
||||
{
|
||||
if (memcmp(&mJoiners[i].mExtAddress, aExtAddress, sizeof(mJoiners[i].mExtAddress)))
|
||||
if (memcmp(&mJoiners[i].mJoinerId, &joinerId, sizeof(mJoiners[i].mJoinerId)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -355,7 +361,7 @@ void Commissioner::HandleJoinerExpirationTimer(void)
|
||||
if (static_cast<int32_t>(now - mJoiners[i].mExpirationTime) >= 0)
|
||||
{
|
||||
otLogDebgMeshCoP(GetInstance(), "removing joiner due to timeout or successfully joined");
|
||||
RemoveJoiner(&mJoiners[i].mExtAddress, 0); // remove imediately
|
||||
RemoveJoiner(&mJoiners[i].mJoinerId, 0); // remove immediately
|
||||
}
|
||||
}
|
||||
|
||||
@@ -812,7 +818,7 @@ void Commissioner::HandleRelayReceive(Coap::Header &aHeader, Message &aMessage,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mJoiners[i].mAny || !memcmp(&mJoiners[i].mExtAddress, mJoinerIid, sizeof(mJoiners[i].mExtAddress)))
|
||||
if (mJoiners[i].mAny || !memcmp(&mJoiners[i].mJoinerId, mJoinerIid, sizeof(mJoiners[i].mJoinerId)))
|
||||
{
|
||||
|
||||
error = netif.GetCoapSecure().SetPsk(reinterpret_cast<const uint8_t *>(mJoiners[i].mPsk),
|
||||
|
||||
@@ -92,27 +92,27 @@ public:
|
||||
/**
|
||||
* This method adds a Joiner entry.
|
||||
*
|
||||
* @param[in] aExtAddress A pointer to the Joiner's extended address or NULL for any Joiner.
|
||||
* @param[in] aPSKd A pointer to the PSKd.
|
||||
* @param[in] aTimeout A time after which a Joiner is automatically removed, in seconds.
|
||||
* @param[in] aEui64 A pointer to the Joiner's IEEE EUI-64 or NULL for any Joiner.
|
||||
* @param[in] aPSKd A pointer to the PSKd.
|
||||
* @param[in] aTimeout A time after which a Joiner is automatically removed, in seconds.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added the Joiner.
|
||||
* @retval OT_ERROR_NO_BUFS No buffers available to add the Joiner.
|
||||
*
|
||||
*/
|
||||
otError AddJoiner(const Mac::ExtAddress *aExtAddress, const char *aPSKd, uint32_t aTimeout);
|
||||
otError AddJoiner(const Mac::ExtAddress *aEui64, const char *aPSKd, uint32_t aTimeout);
|
||||
|
||||
/**
|
||||
* This method removes a Joiner entry.
|
||||
*
|
||||
* @param[in] aExtAddress A pointer to the Joiner's extended address or NULL for any Joiner.
|
||||
* @param[in] aDelay The delay to remove Joiner (in seconds).
|
||||
* @param[in] aEui64 A pointer to the Joiner's IEEE EUI-64 or NULL for any Joiner.
|
||||
* @param[in] aDelay The delay to remove Joiner (in seconds).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added the Joiner.
|
||||
* @retval OT_ERROR_NOT_FOUND The Joiner specified by @p aExtAddress was not found.
|
||||
* @retval OT_ERROR_NOT_FOUND The Joiner specified by @p aEui64 was not found.
|
||||
*
|
||||
*/
|
||||
otError RemoveJoiner(const Mac::ExtAddress *aExtAddress, uint32_t aDelay);
|
||||
otError RemoveJoiner(const Mac::ExtAddress *aEui64, uint32_t aDelay);
|
||||
|
||||
/**
|
||||
* This method sets the Provisioning URL.
|
||||
@@ -285,7 +285,7 @@ private:
|
||||
|
||||
struct Joiner
|
||||
{
|
||||
Mac::ExtAddress mExtAddress;
|
||||
Mac::ExtAddress mJoinerId;
|
||||
uint32_t mExpirationTime;
|
||||
char mPsk[Dtls::kPskMaxLength + 1];
|
||||
bool mValid : 1;
|
||||
|
||||
@@ -76,13 +76,19 @@ Joiner::Joiner(otInstance &aInstance):
|
||||
GetNetif().GetCoap().AddResource(mJoinerEntrust);
|
||||
}
|
||||
|
||||
void Joiner::GetJoinerId(Mac::ExtAddress &aJoinerId) const
|
||||
{
|
||||
otPlatRadioGetIeeeEui64(&GetInstance(), aJoinerId.m8);
|
||||
ComputeJoinerId(aJoinerId, aJoinerId);
|
||||
}
|
||||
|
||||
otError Joiner::Start(const char *aPSKd, const char *aProvisioningUrl,
|
||||
const char *aVendorName, const char *aVendorModel, const char *aVendorSwVersion,
|
||||
const char *aVendorData, otJoinerCallback aCallback, void *aContext)
|
||||
{
|
||||
ThreadNetif &netif = GetNetif();
|
||||
otError error;
|
||||
Mac::ExtAddress extAddress;
|
||||
Mac::ExtAddress joinerId;
|
||||
Crc16 ccitt(Crc16::kCcitt);
|
||||
Crc16 ansi(Crc16::kAnsi);
|
||||
|
||||
@@ -93,14 +99,14 @@ otError Joiner::Start(const char *aPSKd, const char *aProvisioningUrl,
|
||||
GetNetif().SetStateChangedFlags(OT_CHANGED_JOINER_STATE);
|
||||
|
||||
// use extended address based on factory-assigned IEEE EUI-64
|
||||
netif.GetMac().GetHashMacAddress(&extAddress);
|
||||
netif.GetMac().SetExtAddress(extAddress);
|
||||
GetJoinerId(joinerId);
|
||||
netif.GetMac().SetExtAddress(joinerId);
|
||||
netif.GetMle().UpdateLinkLocalAddress();
|
||||
|
||||
for (size_t i = 0; i < sizeof(extAddress); i++)
|
||||
for (size_t i = 0; i < sizeof(joinerId); i++)
|
||||
{
|
||||
ccitt.Update(extAddress.m8[i]);
|
||||
ansi.Update(extAddress.m8[i]);
|
||||
ccitt.Update(joinerId.m8[i]);
|
||||
ansi.Update(joinerId.m8[i]);
|
||||
}
|
||||
|
||||
mCcitt = ccitt.Get();
|
||||
|
||||
@@ -96,8 +96,6 @@ public:
|
||||
/**
|
||||
* This function returns the Joiner State.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @retval OT_JOINER_STATE_IDLE
|
||||
* @retval OT_JOINER_STATE_DISCOVER
|
||||
* @retval OT_JOINER_STATE_CONNECT
|
||||
@@ -108,6 +106,14 @@ public:
|
||||
*/
|
||||
otJoinerState GetState(void) const;
|
||||
|
||||
/**
|
||||
* This method retrieves the Joiner ID.
|
||||
*
|
||||
* @param[out] aJoinerId The Joiner ID.
|
||||
*
|
||||
*/
|
||||
void GetJoinerId(Mac::ExtAddress &aJoinerId) const;
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2017, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file implements common MeshCoP utility functions.
|
||||
*/
|
||||
|
||||
#include "crypto/sha256.hpp"
|
||||
#include "mac/mac_frame.hpp"
|
||||
|
||||
namespace ot {
|
||||
namespace MeshCoP {
|
||||
|
||||
void ComputeJoinerId(const Mac::ExtAddress &aEui64, Mac::ExtAddress &aJoinerId)
|
||||
{
|
||||
Crypto::Sha256 sha256;
|
||||
uint8_t hash[Crypto::Sha256::kHashSize];
|
||||
|
||||
sha256.Start();
|
||||
sha256.Update(aEui64.m8, sizeof(aEui64));
|
||||
sha256.Finish(hash);
|
||||
|
||||
memcpy(&aJoinerId, hash, sizeof(aJoinerId));
|
||||
aJoinerId.SetLocal(true);
|
||||
}
|
||||
|
||||
} // namespace MeshCoP
|
||||
} // namespace ot
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#include "coap/coap.hpp"
|
||||
#include "common/message.hpp"
|
||||
#include "mac/mac_frame.hpp"
|
||||
|
||||
namespace ot {
|
||||
namespace MeshCoP {
|
||||
@@ -57,6 +58,14 @@ inline Message *NewMeshCoPMessage(Coap::CoapBase &aCoap, const Coap::Header &aHe
|
||||
return aCoap.NewMessage(aHeader, kMeshCoPMessagePriority);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function computes the Joiner ID from a factory-assigned IEEE EUI-64.
|
||||
*
|
||||
* @param[in] aEui64 The factory-assigned IEEE EUI-64.
|
||||
* @param[out] aJoinerId The Joiner ID.
|
||||
*
|
||||
*/
|
||||
void ComputeJoinerId(const Mac::ExtAddress &aEui64, Mac::ExtAddress &aJoinerId);
|
||||
|
||||
} // namespace MeshCoP
|
||||
|
||||
|
||||
@@ -52,14 +52,14 @@ bool SteeringDataTlv::IsCleared(void) const
|
||||
return rval;
|
||||
}
|
||||
|
||||
void SteeringDataTlv::ComputeBloomFilter(const otExtAddress *aExtAddress)
|
||||
void SteeringDataTlv::ComputeBloomFilter(const otExtAddress &aJoinerId)
|
||||
{
|
||||
Crc16 ccitt(Crc16::kCcitt);
|
||||
Crc16 ansi(Crc16::kAnsi);
|
||||
|
||||
for (size_t j = 0; j < sizeof(otExtAddress); j++)
|
||||
{
|
||||
uint8_t byte = aExtAddress->m8[j];
|
||||
uint8_t byte = aJoinerId.m8[j];
|
||||
ccitt.Update(byte);
|
||||
ansi.Update(byte);
|
||||
}
|
||||
|
||||
@@ -645,10 +645,10 @@ public:
|
||||
/**
|
||||
* This method computes the Bloom Filter.
|
||||
*
|
||||
* @param[in] aExtAddress Extended address
|
||||
* @param[in] aJoinerId The Joiner ID.
|
||||
*
|
||||
*/
|
||||
void ComputeBloomFilter(const otExtAddress *aExtAddress);
|
||||
void ComputeBloomFilter(const otExtAddress &aJoinerId);
|
||||
|
||||
private:
|
||||
uint8_t mSteeringData[OT_STEERING_DATA_MAX_LENGTH];
|
||||
|
||||
@@ -2663,7 +2663,7 @@ otError MleRouter::SetSteeringData(const otExtAddress *aExtAddress)
|
||||
else
|
||||
{
|
||||
// Set bloom filter with the extended address passed in
|
||||
mSteeringData.ComputeBloomFilter(aExtAddress);
|
||||
mSteeringData.ComputeBloomFilter(*aExtAddress);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
@@ -381,7 +381,7 @@ exit:
|
||||
otError NcpBase::InsertPropertyHandler_THREAD_JOINERS(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
const otExtAddress *extAddress = NULL;
|
||||
const otExtAddress *eui64 = NULL;
|
||||
const char *aPSKd = NULL;
|
||||
uint32_t joinerTimeout = 0;
|
||||
|
||||
@@ -390,13 +390,13 @@ otError NcpBase::InsertPropertyHandler_THREAD_JOINERS(void)
|
||||
SuccessOrExit(error = mDecoder.ReadUtf8(aPSKd));
|
||||
SuccessOrExit(error = mDecoder.ReadUint32(joinerTimeout));
|
||||
|
||||
if (mDecoder.ReadEui64(extAddress) != OT_ERROR_NONE)
|
||||
if (mDecoder.ReadEui64(eui64) != OT_ERROR_NONE)
|
||||
{
|
||||
extAddress = NULL;
|
||||
eui64 = NULL;
|
||||
}
|
||||
|
||||
|
||||
error = otCommissionerAddJoiner(mInstance, extAddress, aPSKd, joinerTimeout);
|
||||
error = otCommissionerAddJoiner(mInstance, eui64, aPSKd, joinerTimeout);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
@@ -61,10 +61,10 @@ class Cert_8_1_01_Commissioning(unittest.TestCase):
|
||||
self.assertEqual(self.nodes[COMMISSIONER].get_state(), 'leader')
|
||||
self.nodes[COMMISSIONER].commissioner_start()
|
||||
time.sleep(3)
|
||||
self.nodes[COMMISSIONER].commissioner_add_joiner(self.nodes[JOINER].get_hashmacaddr(), 'openthread')
|
||||
self.nodes[COMMISSIONER].commissioner_add_joiner(self.nodes[JOINER].get_eui64(), 'OPENTHREAD')
|
||||
|
||||
self.nodes[JOINER].interface_up()
|
||||
self.nodes[JOINER].joiner_start('openthread')
|
||||
self.nodes[JOINER].joiner_start('OPENTHREAD')
|
||||
time.sleep(10)
|
||||
self.assertEqual(self.nodes[JOINER].get_masterkey(), self.nodes[COMMISSIONER].get_masterkey())
|
||||
|
||||
|
||||
@@ -61,10 +61,10 @@ class Cert_8_1_02_Commissioning(unittest.TestCase):
|
||||
self.assertEqual(self.nodes[COMMISSIONER].get_state(), 'leader')
|
||||
self.nodes[COMMISSIONER].commissioner_start()
|
||||
time.sleep(3)
|
||||
self.nodes[COMMISSIONER].commissioner_add_joiner(self.nodes[JOINER].get_hashmacaddr(), 'openthread')
|
||||
self.nodes[COMMISSIONER].commissioner_add_joiner(self.nodes[JOINER].get_eui64(), 'OPENTHREAD')
|
||||
|
||||
self.nodes[JOINER].interface_up()
|
||||
self.nodes[JOINER].joiner_start('daerhtnepo')
|
||||
self.nodes[JOINER].joiner_start('DAERHTNEPO')
|
||||
time.sleep(10)
|
||||
self.assertNotEqual(self.nodes[JOINER].get_masterkey(), self.nodes[COMMISSIONER].get_masterkey())
|
||||
|
||||
|
||||
@@ -71,15 +71,15 @@ class Cert_8_2_01_JoinerRouter(unittest.TestCase):
|
||||
|
||||
self.nodes[COMMISSIONER].commissioner_start()
|
||||
time.sleep(5)
|
||||
self.nodes[COMMISSIONER].commissioner_add_joiner(self.nodes[JOINER_ROUTER].get_hashmacaddr(), 'openthread')
|
||||
self.nodes[COMMISSIONER].commissioner_add_joiner(self.nodes[JOINER].get_hashmacaddr(), 'openthread2')
|
||||
self.nodes[COMMISSIONER].commissioner_add_joiner(self.nodes[JOINER_ROUTER].get_eui64(), 'OPENTHREAD')
|
||||
self.nodes[COMMISSIONER].commissioner_add_joiner(self.nodes[JOINER].get_eui64(), 'OPENTHREAD2')
|
||||
time.sleep(5)
|
||||
|
||||
self.nodes[COMMISSIONER].add_whitelist(self.nodes[JOINER_ROUTER].get_hashmacaddr())
|
||||
self.nodes[COMMISSIONER].add_whitelist(self.nodes[JOINER_ROUTER].get_joiner_id())
|
||||
self.nodes[JOINER_ROUTER].add_whitelist(self.nodes[COMMISSIONER].get_addr64())
|
||||
|
||||
self.nodes[JOINER_ROUTER].interface_up()
|
||||
self.nodes[JOINER_ROUTER].joiner_start('openthread')
|
||||
self.nodes[JOINER_ROUTER].joiner_start('OPENTHREAD')
|
||||
time.sleep(10)
|
||||
self.assertEqual(self.nodes[JOINER_ROUTER].get_masterkey(), self.nodes[COMMISSIONER].get_masterkey())
|
||||
|
||||
@@ -89,11 +89,11 @@ class Cert_8_2_01_JoinerRouter(unittest.TestCase):
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[JOINER_ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[JOINER_ROUTER].add_whitelist(self.nodes[JOINER].get_hashmacaddr())
|
||||
self.nodes[JOINER_ROUTER].add_whitelist(self.nodes[JOINER].get_joiner_id())
|
||||
self.nodes[JOINER].add_whitelist(self.nodes[JOINER_ROUTER].get_addr64())
|
||||
|
||||
self.nodes[JOINER].interface_up()
|
||||
self.nodes[JOINER].joiner_start('openthread2')
|
||||
self.nodes[JOINER].joiner_start('OPENTHREAD2')
|
||||
time.sleep(10)
|
||||
self.assertEqual(self.nodes[JOINER].get_masterkey(), self.nodes[COMMISSIONER].get_masterkey())
|
||||
|
||||
|
||||
@@ -71,15 +71,15 @@ class Cert_8_2_02_JoinerRouter(unittest.TestCase):
|
||||
|
||||
self.nodes[COMMISSIONER].commissioner_start()
|
||||
time.sleep(5)
|
||||
self.nodes[COMMISSIONER].commissioner_add_joiner(self.nodes[JOINER_ROUTER].get_hashmacaddr(), 'openthread')
|
||||
self.nodes[COMMISSIONER].commissioner_add_joiner(self.nodes[JOINER].get_hashmacaddr(), 'openthread2')
|
||||
self.nodes[COMMISSIONER].commissioner_add_joiner(self.nodes[JOINER_ROUTER].get_eui64(), 'OPENTHREAD')
|
||||
self.nodes[COMMISSIONER].commissioner_add_joiner(self.nodes[JOINER].get_eui64(), 'OPENTHREAD2')
|
||||
time.sleep(5)
|
||||
|
||||
self.nodes[COMMISSIONER].add_whitelist(self.nodes[JOINER_ROUTER].get_hashmacaddr())
|
||||
self.nodes[COMMISSIONER].add_whitelist(self.nodes[JOINER_ROUTER].get_joiner_id())
|
||||
self.nodes[JOINER_ROUTER].add_whitelist(self.nodes[COMMISSIONER].get_addr64())
|
||||
|
||||
self.nodes[JOINER_ROUTER].interface_up()
|
||||
self.nodes[JOINER_ROUTER].joiner_start('openthread')
|
||||
self.nodes[JOINER_ROUTER].joiner_start('OPENTHREAD')
|
||||
time.sleep(10)
|
||||
self.assertEqual(self.nodes[JOINER_ROUTER].get_masterkey(), self.nodes[COMMISSIONER].get_masterkey())
|
||||
|
||||
@@ -89,11 +89,11 @@ class Cert_8_2_02_JoinerRouter(unittest.TestCase):
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[JOINER_ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[JOINER_ROUTER].add_whitelist(self.nodes[JOINER].get_hashmacaddr())
|
||||
self.nodes[JOINER_ROUTER].add_whitelist(self.nodes[JOINER].get_joiner_id())
|
||||
self.nodes[JOINER].add_whitelist(self.nodes[JOINER_ROUTER].get_addr64())
|
||||
|
||||
self.nodes[JOINER].interface_up()
|
||||
self.nodes[JOINER].joiner_start('2daerhtnepo')
|
||||
self.nodes[JOINER].joiner_start('2DAERHTNEPO')
|
||||
time.sleep(10)
|
||||
self.assertNotEqual(self.nodes[JOINER].get_masterkey(), self.nodes[COMMISSIONER].get_masterkey())
|
||||
|
||||
|
||||
@@ -107,8 +107,11 @@ class Node:
|
||||
def get_addr64(self):
|
||||
return self.interface.get_addr64()
|
||||
|
||||
def get_hashmacaddr(self):
|
||||
return self.interface.get_hashmacaddr()
|
||||
def get_eui64(self):
|
||||
return self.interface.get_eui64()
|
||||
|
||||
def get_joiner_id(self):
|
||||
return self.interface.get_joiner_id()
|
||||
|
||||
def get_channel(self):
|
||||
return self.interface.get_channel()
|
||||
|
||||
@@ -100,8 +100,11 @@ class otApi:
|
||||
def get_addr64(self):
|
||||
return self.Api.otNodeGetAddr64(self.otNode).decode('utf-8')
|
||||
|
||||
def get_hashmacaddr(self):
|
||||
return self.Api.otNodeGetHashMacAddress(self.otNode).decode('utf-8')
|
||||
def get_eui64(self):
|
||||
return self.Api.otNodeGetEui64(self.otNode).decode('utf-8')
|
||||
|
||||
def get_joiner_id(self):
|
||||
return self.Api.otNodeGetJoinerId(self.otNode).decode('utf-8')
|
||||
|
||||
def get_channel(self):
|
||||
return self.Api.otNodeGetChannel(self.otNode)
|
||||
@@ -420,10 +423,13 @@ class otApi:
|
||||
|
||||
self.Api.otNodeGetAddr64.argtypes = [ctypes.c_void_p]
|
||||
self.Api.otNodeGetAddr64.restype = ctypes.c_char_p
|
||||
|
||||
self.Api.otNodeGetHashMacAddress.argtypes = [ctypes.c_void_p]
|
||||
self.Api.otNodeGetHashMacAddress.restype = ctypes.c_char_p
|
||||
|
||||
self.Api.otNodeGetEui64.argtypes = [ctypes.c_void_p]
|
||||
self.Api.otNodeGetEui64.restype = ctypes.c_char_p
|
||||
|
||||
self.Api.otNodeGetJoinerId.argtypes = [ctypes.c_void_p]
|
||||
self.Api.otNodeGetJoinerId.restype = ctypes.c_char_p
|
||||
|
||||
self.Api.otNodeSetChannel.argtypes = [ctypes.c_void_p,
|
||||
ctypes.c_ubyte]
|
||||
|
||||
|
||||
@@ -201,8 +201,17 @@ class otCli:
|
||||
self.pexpect.expect('Done')
|
||||
return addr64
|
||||
|
||||
def get_hashmacaddr(self):
|
||||
self.send_command('hashmacaddr')
|
||||
def get_eui64(self):
|
||||
self.send_command('eui64')
|
||||
i = self.pexpect.expect('([0-9a-fA-F]{16})')
|
||||
if i == 0:
|
||||
addr64 = self.pexpect.match.groups()[0].decode("utf-8")
|
||||
|
||||
self.pexpect.expect('Done')
|
||||
return addr64
|
||||
|
||||
def get_joiner_id(self):
|
||||
self.send_command('joinerid')
|
||||
i = self.pexpect.expect('([0-9a-fA-F]{16})')
|
||||
if i == 0:
|
||||
addr = self.pexpect.match.groups()[0].decode("utf-8")
|
||||
|
||||
@@ -756,7 +756,7 @@ class OpenThread(IThci):
|
||||
if bType == MacType.FactoryMac:
|
||||
macAddr64 = self.__sendCommand('eui64')[0]
|
||||
elif bType == MacType.HashMac:
|
||||
macAddr64 = self.__sendCommand('hashmacaddr')[0]
|
||||
macAddr64 = self.__sendCommand('joinerid')[0]
|
||||
else:
|
||||
macAddr64 = self.__sendCommand('extaddr')[0]
|
||||
print macAddr64
|
||||
@@ -1964,16 +1964,21 @@ class OpenThread(IThci):
|
||||
False: fail to add Joiner's steering data
|
||||
"""
|
||||
print '%s call scanJoiner' % self.port
|
||||
if xEUI == '*':
|
||||
JoinerHashMac = '*'
|
||||
else:
|
||||
JoinerAddr = ModuleHelper.CalculateHashMac(xEUI)
|
||||
JoinerHashMac = hex(int(JoinerAddr)).rstrip("L").lstrip("0x")
|
||||
|
||||
# long timeout value to avoid automatic joiner removal (in seconds)
|
||||
timeout = 500
|
||||
|
||||
cmd = 'commissioner joiner add %s %s %s' % (JoinerHashMac, strPSKd, str(timeout))
|
||||
if not isinstance(xEUI, str):
|
||||
eui64 = self.__convertLongToString(xEUI)
|
||||
|
||||
# prepend 0 at the beginning
|
||||
if len(eui64) < 16:
|
||||
eui64 = eui64.zfill(16)
|
||||
print eui64
|
||||
else:
|
||||
eui64 = xEUI
|
||||
|
||||
cmd = 'commissioner joiner add %s %s %s' % (eui64, strPSKd, str(timeout))
|
||||
print cmd
|
||||
if self.__sendCommand(cmd)[0] == 'Done':
|
||||
if self.logThreadStatus == self.logStatus['stop']:
|
||||
|
||||
Reference in New Issue
Block a user