mirror of
https://github.com/espressif/openthread.git
synced 2026-09-08 10:10:06 +00:00
[api] change type from uint8_t* to otExtendedPanId (#2960)
This commit is contained in:
@@ -1506,7 +1506,7 @@ otLinkSetExtendedAddress(
|
||||
}
|
||||
|
||||
OTAPI
|
||||
const uint8_t *
|
||||
const otExtendedPanId *
|
||||
OTCALL
|
||||
otThreadGetExtendedPanId(
|
||||
_In_ otInstance *aInstance
|
||||
@@ -1515,12 +1515,13 @@ otThreadGetExtendedPanId(
|
||||
if (aInstance == nullptr) return nullptr;
|
||||
|
||||
otExtendedPanId *Result = (otExtendedPanId*)malloc(sizeof(otExtendedPanId));
|
||||
if (Result && QueryIOCTL(aInstance, IOCTL_OTLWF_OT_EXTENDED_PANID, Result) != ERROR_SUCCESS)
|
||||
if (Result == nullptr) return nullptr;
|
||||
if (QueryIOCTL(aInstance, IOCTL_OTLWF_OT_EXTENDED_PANID, Result) != ERROR_SUCCESS)
|
||||
{
|
||||
free(Result);
|
||||
Result = nullptr;
|
||||
}
|
||||
return (uint8_t*)Result;
|
||||
return Result;
|
||||
}
|
||||
|
||||
OTAPI
|
||||
@@ -1528,11 +1529,11 @@ otError
|
||||
OTCALL
|
||||
otThreadSetExtendedPanId(
|
||||
_In_ otInstance *aInstance,
|
||||
const uint8_t *aExtendedPanId
|
||||
const otExtendedPanId *aExtendedPanId
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_EXTENDED_PANID, (const otExtendedPanId*)aExtendedPanId));
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_EXTENDED_PANID, aExtendedPanId));
|
||||
}
|
||||
|
||||
OTAPI
|
||||
|
||||
@@ -1256,12 +1256,13 @@ otLwfIoCtl_otExtendedPanId(
|
||||
|
||||
if (InBufferLength >= sizeof(otExtendedPanId))
|
||||
{
|
||||
status = ThreadErrorToNtstatus(otThreadSetExtendedPanId(pFilter->otCtx, (uint8_t*)InBuffer));
|
||||
status = ThreadErrorToNtstatus(otThreadSetExtendedPanId(pFilter->otCtx, (otExtendedPanId*)InBuffer));
|
||||
*OutBufferLength = 0;
|
||||
}
|
||||
else if (*OutBufferLength >= sizeof(otExtendedPanId))
|
||||
{
|
||||
memcpy(OutBuffer, otThreadGetExtendedPanId(pFilter->otCtx), sizeof(otExtendedPanId));
|
||||
const otExtendedPanId* aExtendedPanId = otThreadGetExtendedPanId(pFilter->otCtx);
|
||||
memcpy(OutBuffer, aExtendedPanId, sizeof(otExtendedPanId));
|
||||
*OutBufferLength = sizeof(otExtendedPanId);
|
||||
status = STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#ifndef OPENTHREAD_COMMISSIONER_H_
|
||||
#define OPENTHREAD_COMMISSIONER_H_
|
||||
|
||||
#include <openthread/dataset.h>
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
#include <openthread/platform/toolchain.h>
|
||||
@@ -346,11 +347,11 @@ OTAPI otCommissionerState OTCALL otCommissionerGetState(otInstance *aInstance);
|
||||
* @retval OT_ERROR_INVALID_ARGS If any of the input arguments is invalid.
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otCommissionerGeneratePSKc(otInstance * aInstance,
|
||||
const char * aPassPhrase,
|
||||
const char * aNetworkName,
|
||||
const uint8_t *aExtPanId,
|
||||
uint8_t * aPSKc);
|
||||
OTAPI otError OTCALL otCommissionerGeneratePSKc(otInstance * aInstance,
|
||||
const char * aPassPhrase,
|
||||
const char * aNetworkName,
|
||||
const otExtendedPanId *aExtPanId,
|
||||
uint8_t * aPSKc);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -86,10 +86,17 @@ typedef struct otNetworkName
|
||||
* This structure represents an Extended PAN ID.
|
||||
*
|
||||
*/
|
||||
typedef struct otExtendedPanId
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otExtendedPanId
|
||||
{
|
||||
uint8_t m8[OT_EXT_PAN_ID_SIZE]; ///< Byte values
|
||||
} otExtendedPanId;
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* This structure represents an Extended PAN ID.
|
||||
*
|
||||
*/
|
||||
typedef struct otExtendedPanId otExtendedPanId;
|
||||
|
||||
#define OT_MESH_LOCAL_PREFIX_SIZE 8 ///< Size of the Mesh Local Prefix (bytes)
|
||||
|
||||
|
||||
@@ -262,7 +262,7 @@ OTAPI void OTCALL otThreadSetChildTimeout(otInstance *aInstance, uint32_t aTimeo
|
||||
*
|
||||
* @sa otThreadSetExtendedPanId
|
||||
*/
|
||||
OTAPI const uint8_t *OTCALL otThreadGetExtendedPanId(otInstance *aInstance);
|
||||
OTAPI const otExtendedPanId *OTCALL otThreadGetExtendedPanId(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the IEEE 802.15.4 Extended PAN ID.
|
||||
@@ -279,7 +279,7 @@ OTAPI const uint8_t *OTCALL otThreadGetExtendedPanId(otInstance *aInstance);
|
||||
*
|
||||
* @sa otThreadGetExtendedPanId
|
||||
*/
|
||||
OTAPI otError OTCALL otThreadSetExtendedPanId(otInstance *aInstance, const uint8_t *aExtendedPanId);
|
||||
OTAPI otError OTCALL otThreadSetExtendedPanId(otInstance *aInstance, const otExtendedPanId *aExtendedPanId);
|
||||
|
||||
/**
|
||||
* This function returns a pointer to the Leader's RLOC.
|
||||
|
||||
+4
-4
@@ -956,17 +956,17 @@ void Interpreter::ProcessExtPanId(int argc, char *argv[])
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
otBufferPtr extPanId(otThreadGetExtendedPanId(mInstance));
|
||||
otBufferPtr extPanId(reinterpret_cast<const uint8_t *>(otThreadGetExtendedPanId(mInstance)));
|
||||
OutputBytes(extPanId, OT_EXT_PAN_ID_SIZE);
|
||||
mServer->OutputFormat("\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t extPanId[8];
|
||||
otExtendedPanId extPanId;
|
||||
|
||||
VerifyOrExit(Hex2Bin(argv[0], extPanId, sizeof(extPanId)) >= 0, error = OT_ERROR_PARSE);
|
||||
VerifyOrExit(Hex2Bin(argv[0], extPanId.m8, sizeof(extPanId)) >= 0, error = OT_ERROR_PARSE);
|
||||
|
||||
error = otThreadSetExtendedPanId(mInstance, extPanId);
|
||||
error = otThreadSetExtendedPanId(mInstance, &extPanId);
|
||||
}
|
||||
|
||||
exit:
|
||||
|
||||
@@ -292,18 +292,18 @@ otCommissionerState otCommissionerGetState(otInstance *aInstance)
|
||||
return state;
|
||||
}
|
||||
|
||||
otError otCommissionerGeneratePSKc(otInstance * aInstance,
|
||||
const char * aPassPhrase,
|
||||
const char * aNetworkName,
|
||||
const uint8_t *aExtPanId,
|
||||
uint8_t * aPSKc)
|
||||
otError otCommissionerGeneratePSKc(otInstance * aInstance,
|
||||
const char * aPassPhrase,
|
||||
const char * aNetworkName,
|
||||
const otExtendedPanId *aExtPanId,
|
||||
uint8_t * aPSKc)
|
||||
{
|
||||
otError error = OT_ERROR_DISABLED_FEATURE;
|
||||
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_ENABLE_COMMISSIONER
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
error = instance.GetThreadNetif().GetCommissioner().GeneratePSKc(aPassPhrase, aNetworkName, aExtPanId, aPSKc);
|
||||
error = instance.GetThreadNetif().GetCommissioner().GeneratePSKc(aPassPhrase, aNetworkName, *aExtPanId, aPSKc);
|
||||
#else
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aPassPhrase);
|
||||
|
||||
@@ -57,14 +57,14 @@ void otThreadSetChildTimeout(otInstance *aInstance, uint32_t aTimeout)
|
||||
instance.GetThreadNetif().GetMle().SetTimeout(aTimeout);
|
||||
}
|
||||
|
||||
const uint8_t *otThreadGetExtendedPanId(otInstance *aInstance)
|
||||
const otExtendedPanId *otThreadGetExtendedPanId(otInstance *aInstance)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.GetThreadNetif().GetMac().GetExtendedPanId();
|
||||
return &instance.GetThreadNetif().GetMac().GetExtendedPanId();
|
||||
}
|
||||
|
||||
otError otThreadSetExtendedPanId(otInstance *aInstance, const uint8_t *aExtendedPanId)
|
||||
otError otThreadSetExtendedPanId(otInstance *aInstance, const otExtendedPanId *aExtendedPanId)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
@@ -73,10 +73,10 @@ otError otThreadSetExtendedPanId(otInstance *aInstance, const uint8_t *aExtended
|
||||
VerifyOrExit(instance.GetThreadNetif().GetMle().GetRole() == OT_DEVICE_ROLE_DISABLED,
|
||||
error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
instance.GetThreadNetif().GetMac().SetExtendedPanId(aExtendedPanId);
|
||||
instance.GetThreadNetif().GetMac().SetExtendedPanId(*aExtendedPanId);
|
||||
|
||||
mlPrefix[0] = 0xfd;
|
||||
memcpy(mlPrefix + 1, aExtendedPanId, 5);
|
||||
memcpy(mlPrefix + 1, aExtendedPanId->m8, 5);
|
||||
mlPrefix[6] = 0x00;
|
||||
mlPrefix[7] = 0x00;
|
||||
instance.GetThreadNetif().GetMle().SetMeshLocalPrefix(mlPrefix);
|
||||
|
||||
@@ -64,8 +64,10 @@ static const otExtAddress sMode2ExtAddress = {
|
||||
{0x35, 0x06, 0xfe, 0xb8, 0x23, 0xd4, 0x87, 0x12},
|
||||
};
|
||||
|
||||
static const uint8_t sExtendedPanidInit[] = {0xde, 0xad, 0x00, 0xbe, 0xef, 0x00, 0xca, 0xfe};
|
||||
static const char sNetworkNameInit[] = "OpenThread";
|
||||
static const otExtendedPanId sExtendedPanidInit = {
|
||||
{0xde, 0xad, 0x00, 0xbe, 0xef, 0x00, 0xca, 0xfe},
|
||||
};
|
||||
static const char sNetworkNameInit[] = "OpenThread";
|
||||
|
||||
#ifdef _WIN32
|
||||
const uint32_t kMinBackoffSum = kMinBackoff + (kUnitBackoffPeriod * OT_RADIO_SYMBOL_TIME * (1 << kMinBE)) / 1000;
|
||||
@@ -635,12 +637,12 @@ exit:
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError Mac::SetExtendedPanId(const uint8_t *aExtPanId)
|
||||
otError Mac::SetExtendedPanId(const otExtendedPanId &aExtendedPanId)
|
||||
{
|
||||
VerifyOrExit(memcmp(mExtendedPanId.m8, aExtPanId, sizeof(mExtendedPanId)) != 0,
|
||||
VerifyOrExit(memcmp(mExtendedPanId.m8, aExtendedPanId.m8, sizeof(mExtendedPanId)) != 0,
|
||||
GetNotifier().SignalIfFirst(OT_CHANGED_THREAD_EXT_PANID));
|
||||
|
||||
memcpy(mExtendedPanId.m8, aExtPanId, sizeof(mExtendedPanId));
|
||||
mExtendedPanId = aExtendedPanId;
|
||||
GetNotifier().Signal(OT_CHANGED_THREAD_EXT_PANID);
|
||||
|
||||
exit:
|
||||
|
||||
@@ -715,17 +715,17 @@ public:
|
||||
* @returns A pointer to the IEEE 802.15.4 Extended PAN ID.
|
||||
*
|
||||
*/
|
||||
const uint8_t *GetExtendedPanId(void) const { return mExtendedPanId.m8; }
|
||||
const otExtendedPanId &GetExtendedPanId(void) const { return mExtendedPanId; }
|
||||
|
||||
/**
|
||||
* This method sets the IEEE 802.15.4 Extended PAN ID.
|
||||
*
|
||||
* @param[in] aExtPanId The IEEE 802.15.4 Extended PAN ID.
|
||||
* @param[in] aExtendedPanId The IEEE 802.15.4 Extended PAN ID.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the IEEE 802.15.4 Extended PAN ID.
|
||||
*
|
||||
*/
|
||||
otError SetExtendedPanId(const uint8_t *aExtPanId);
|
||||
otError SetExtendedPanId(const otExtendedPanId &aExtendedPanId);
|
||||
|
||||
#if OPENTHREAD_ENABLE_MAC_FILTER
|
||||
/**
|
||||
|
||||
@@ -1059,10 +1059,10 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError Commissioner::GeneratePSKc(const char * aPassPhrase,
|
||||
const char * aNetworkName,
|
||||
const uint8_t *aExtPanId,
|
||||
uint8_t * aPSKc)
|
||||
otError Commissioner::GeneratePSKc(const char * aPassPhrase,
|
||||
const char * aNetworkName,
|
||||
const otExtendedPanId &aExtPanId,
|
||||
uint8_t * aPSKc)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
const char *saltPrefix = "Thread";
|
||||
@@ -1077,7 +1077,7 @@ otError Commissioner::GeneratePSKc(const char * aPassPhrase,
|
||||
memcpy(salt, saltPrefix, strlen(saltPrefix));
|
||||
saltLen += static_cast<uint16_t>(strlen(saltPrefix));
|
||||
|
||||
memcpy(salt + saltLen, aExtPanId, OT_EXT_PAN_ID_SIZE);
|
||||
memcpy(salt + saltLen, aExtPanId.m8, sizeof(aExtPanId));
|
||||
saltLen += OT_EXT_PAN_ID_SIZE;
|
||||
|
||||
memcpy(salt + saltLen, aNetworkName, strlen(aNetworkName));
|
||||
|
||||
@@ -210,10 +210,10 @@ public:
|
||||
* @retval OT_ERROR_INVALID_ARGS If the length of passphrase is out of range.
|
||||
*
|
||||
*/
|
||||
static otError GeneratePSKc(const char * aPassPhrase,
|
||||
const char * aNetworkName,
|
||||
const uint8_t *aExtPanId,
|
||||
uint8_t * aPSKc);
|
||||
static otError GeneratePSKc(const char * aPassPhrase,
|
||||
const char * aNetworkName,
|
||||
const otExtendedPanId &aExtPanId,
|
||||
uint8_t * aPSKc);
|
||||
|
||||
/**
|
||||
* This method returns a reference to the AnnounceBeginClient instance.
|
||||
|
||||
@@ -166,8 +166,8 @@ void Dataset::Get(otOperationalDataset &aDataset) const
|
||||
|
||||
case Tlv::kExtendedPanId:
|
||||
{
|
||||
const ExtendedPanIdTlv *tlv = static_cast<const ExtendedPanIdTlv *>(cur);
|
||||
memcpy(aDataset.mExtendedPanId.m8, tlv->GetExtendedPanId(), sizeof(aDataset.mExtendedPanId));
|
||||
const ExtendedPanIdTlv *tlv = static_cast<const ExtendedPanIdTlv *>(cur);
|
||||
aDataset.mExtendedPanId = tlv->GetExtendedPanId();
|
||||
aDataset.mComponents.mIsExtendedPanIdPresent = true;
|
||||
break;
|
||||
}
|
||||
@@ -310,7 +310,7 @@ otError Dataset::Set(const otOperationalDataset &aDataset)
|
||||
{
|
||||
MeshCoP::ExtendedPanIdTlv tlv;
|
||||
tlv.Init();
|
||||
tlv.SetExtendedPanId(aDataset.mExtendedPanId.m8);
|
||||
tlv.SetExtendedPanId(aDataset.mExtendedPanId);
|
||||
Set(tlv);
|
||||
}
|
||||
|
||||
|
||||
@@ -421,7 +421,7 @@ otError DatasetManager::SendSetRequest(const otOperationalDataset &aDataset, con
|
||||
{
|
||||
ExtendedPanIdTlv extpanid;
|
||||
extpanid.Init();
|
||||
extpanid.SetExtendedPanId(aDataset.mExtendedPanId.m8);
|
||||
extpanid.SetExtendedPanId(aDataset.mExtendedPanId);
|
||||
SuccessOrExit(error = message->Append(&extpanid, sizeof(extpanid)));
|
||||
}
|
||||
|
||||
|
||||
@@ -351,7 +351,7 @@ public:
|
||||
* @returns The Extended PAN ID value.
|
||||
*
|
||||
*/
|
||||
const uint8_t *GetExtendedPanId(void) const { return mExtendedPanId; }
|
||||
const otExtendedPanId &GetExtendedPanId(void) const { return mExtendedPanId; }
|
||||
|
||||
/**
|
||||
* This method sets the Extended PAN ID value.
|
||||
@@ -359,10 +359,10 @@ public:
|
||||
* @param[in] aExtendedPanId A pointer to the Extended PAN ID value.
|
||||
*
|
||||
*/
|
||||
void SetExtendedPanId(const uint8_t *aExtendedPanId) { memcpy(mExtendedPanId, aExtendedPanId, OT_EXT_PAN_ID_SIZE); }
|
||||
void SetExtendedPanId(const otExtendedPanId &aExtendedPanId) { mExtendedPanId = aExtendedPanId; }
|
||||
|
||||
private:
|
||||
uint8_t mExtendedPanId[OT_EXT_PAN_ID_SIZE];
|
||||
otExtendedPanId mExtendedPanId;
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
|
||||
@@ -158,7 +158,7 @@ Mle::Mle(Instance &aInstance)
|
||||
|
||||
// initialize Mesh Local Prefix
|
||||
meshLocalPrefix[0] = 0xfd;
|
||||
memcpy(meshLocalPrefix + 1, GetNetif().GetMac().GetExtendedPanId(), 5);
|
||||
memcpy(meshLocalPrefix + 1, GetNetif().GetMac().GetExtendedPanId().m8, 5);
|
||||
meshLocalPrefix[6] = 0x00;
|
||||
meshLocalPrefix[7] = 0x00;
|
||||
|
||||
@@ -3683,7 +3683,7 @@ otError Mle::HandleDiscoveryResponse(const Message &aMessage, const Ip6::Message
|
||||
case MeshCoP::Tlv::kExtendedPanId:
|
||||
aMessage.Read(offset, sizeof(extPanId), &extPanId);
|
||||
VerifyOrExit(extPanId.IsValid(), error = OT_ERROR_PARSE);
|
||||
memcpy(&result.mExtendedPanId, extPanId.GetExtendedPanId(), sizeof(result.mExtendedPanId));
|
||||
result.mExtendedPanId = extPanId.GetExtendedPanId();
|
||||
break;
|
||||
|
||||
case MeshCoP::Tlv::kNetworkName:
|
||||
|
||||
@@ -2640,7 +2640,7 @@ otError MleRouter::HandleDiscoveryRequest(const Message &aMessage, const Ip6::Me
|
||||
case MeshCoP::Tlv::kExtendedPanId:
|
||||
aMessage.Read(offset, sizeof(extPanId), &extPanId);
|
||||
VerifyOrExit(extPanId.IsValid(), error = OT_ERROR_PARSE);
|
||||
VerifyOrExit(memcmp(netif.GetMac().GetExtendedPanId(), extPanId.GetExtendedPanId(), OT_EXT_PAN_ID_SIZE));
|
||||
VerifyOrExit(memcmp(&netif.GetMac().GetExtendedPanId(), &extPanId.GetExtendedPanId(), OT_EXT_PAN_ID_SIZE));
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ exit:
|
||||
|
||||
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_NET_XPANID>(void)
|
||||
{
|
||||
return mEncoder.WriteData(otThreadGetExtendedPanId(mInstance), sizeof(spinel_net_xpanid_t));
|
||||
return mEncoder.WriteData(otThreadGetExtendedPanId(mInstance)->m8, sizeof(spinel_net_xpanid_t));
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_NET_XPANID>(void)
|
||||
@@ -408,7 +408,7 @@ template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_NET_XPANID>(void)
|
||||
|
||||
VerifyOrExit(len == sizeof(spinel_net_xpanid_t), error = OT_ERROR_PARSE);
|
||||
|
||||
error = otThreadSetExtendedPanId(mInstance, ptr);
|
||||
error = otThreadSetExtendedPanId(mInstance, reinterpret_cast<const otExtendedPanId *>(ptr));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "test_platform.h"
|
||||
#include "test_util.h"
|
||||
|
||||
static const uint8_t sXPanId[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
|
||||
static const otExtendedPanId sXPanId = {{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}};
|
||||
|
||||
void TestMinimumPassphrase(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user