[meshcop] use IEEE EUI-64 rather than Joiner ID on user input (#2311)

This commit is contained in:
Jonathan Hui
2017-11-07 09:41:46 -08:00
committed by GitHub
parent 27a30c7209
commit 74b3160f9d
40 changed files with 337 additions and 219 deletions
@@ -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
+7 -2
View File
@@ -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
+12 -12
View File
@@ -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
+3 -4
View File
@@ -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
{
+1 -1
View File
@@ -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);