mirror of
https://github.com/espressif/openthread.git
synced 2026-08-04 01:47:47 +00:00
[key-manager] add helper method (#4838)
This commit is contained in:
@@ -889,7 +889,7 @@ void Mac::PrepareBeacon(TxFrame &aFrame)
|
||||
|
||||
beaconPayload = reinterpret_cast<BeaconPayload *>(beacon->GetPayload());
|
||||
|
||||
if (Get<KeyManager>().GetSecurityPolicyFlags() & OT_SECURITY_POLICY_BEACONS)
|
||||
if (Get<KeyManager>().IsThreadBeaconEnabled())
|
||||
{
|
||||
beaconPayload->Init();
|
||||
|
||||
|
||||
@@ -358,8 +358,7 @@ void DatasetManager::SendGetResponse(const Coap::Message & aRequest,
|
||||
|
||||
while (cur < end)
|
||||
{
|
||||
if (cur->GetType() != Tlv::kNetworkMasterKey ||
|
||||
(Get<KeyManager>().GetSecurityPolicyFlags() & OT_SECURITY_POLICY_OBTAIN_MASTER_KEY))
|
||||
if (cur->GetType() != Tlv::kNetworkMasterKey || Get<KeyManager>().IsObtainMasterKeyEnabled())
|
||||
{
|
||||
SuccessOrExit(error = cur->AppendTo(*message));
|
||||
}
|
||||
@@ -373,8 +372,7 @@ void DatasetManager::SendGetResponse(const Coap::Message & aRequest,
|
||||
{
|
||||
const Tlv *tlv;
|
||||
|
||||
if (aTlvs[index] == Tlv::kNetworkMasterKey &&
|
||||
!(Get<KeyManager>().GetSecurityPolicyFlags() & OT_SECURITY_POLICY_OBTAIN_MASTER_KEY))
|
||||
if (aTlvs[index] == Tlv::kNetworkMasterKey && !Get<KeyManager>().IsObtainMasterKeyEnabled())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -481,6 +481,62 @@ public:
|
||||
*/
|
||||
void SetSecurityPolicyFlags(uint8_t aSecurityPolicyFlags);
|
||||
|
||||
/**
|
||||
* This method indicates whether or not obtaining Master key for out-of-band is enabled.
|
||||
*
|
||||
* @retval TRUE If obtaining Master key for out-of-band is enabled.
|
||||
* @retval FALSE If obtaining Master key for out-of-band is not enabled.
|
||||
*
|
||||
*/
|
||||
bool IsObtainMasterKeyEnabled(void) const
|
||||
{
|
||||
return (mSecurityPolicyFlags & OT_SECURITY_POLICY_OBTAIN_MASTER_KEY) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not Native Commissioning using PSKc is allowed.
|
||||
*
|
||||
* @retval TRUE If Native Commissioning using PSKc is allowed.
|
||||
* @retval FALSE If Native Commissioning using PSKc is not allowed.
|
||||
*
|
||||
*/
|
||||
bool IsNativeCommissioningAllowed(void) const
|
||||
{
|
||||
return (mSecurityPolicyFlags & OT_SECURITY_POLICY_NATIVE_COMMISSIONING) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not Thread 1.1 Routers are enabled.
|
||||
*
|
||||
* @retval TRUE If Thread 1.1 Routers are enabled.
|
||||
* @retval FALSE If Thread 1.1 Routers are not enabled.
|
||||
*
|
||||
*/
|
||||
bool IsRouterEnabled(void) const { return (mSecurityPolicyFlags & OT_SECURITY_POLICY_ROUTERS) != 0; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not external Commissioner authentication is allowed using PSKc.
|
||||
*
|
||||
* @retval TRUE If the commissioning sessions by an external Commissioner based on the PSKc are allowed
|
||||
* to be established and that changes to the Commissioner Dataset by on-mesh nodes are allowed.
|
||||
* @retval FALSE If the commissioning sessions by an external Commissioner based on the PSKc are not allowed
|
||||
* to be established and that changes to the Commissioner Dataset by on-mesh nodes are not allowed.
|
||||
*
|
||||
*/
|
||||
bool IsExternalCommissionerAllowed(void) const
|
||||
{
|
||||
return (mSecurityPolicyFlags & OT_SECURITY_POLICY_EXTERNAL_COMMISSIONER) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not Thread Beacons are enabled.
|
||||
*
|
||||
* @retval TRUE If Thread Beacons are enabled.
|
||||
* @retval FALSE If Thread Beacons are not enabled.
|
||||
*
|
||||
*/
|
||||
bool IsThreadBeaconEnabled(void) const { return (mSecurityPolicyFlags & OT_SECURITY_POLICY_BEACONS) != 0; }
|
||||
|
||||
/**
|
||||
* This static method generates IEEE 802.15.4 nonce byte sequence.
|
||||
*
|
||||
|
||||
@@ -1636,8 +1636,7 @@ void Mle::HandleStateChanged(otChangedFlags aFlags)
|
||||
|
||||
if (aFlags & OT_CHANGED_SECURITY_POLICY)
|
||||
{
|
||||
Get<Ip6::Filter>().AllowNativeCommissioner(
|
||||
(Get<KeyManager>().GetSecurityPolicyFlags() & OT_SECURITY_POLICY_NATIVE_COMMISSIONING) != 0);
|
||||
Get<Ip6::Filter>().AllowNativeCommissioner(Get<KeyManager>().IsNativeCommissioningAllowed());
|
||||
}
|
||||
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
|
||||
|
||||
@@ -2886,7 +2886,7 @@ otError MleRouter::SendDiscoveryResponse(const Ip6::Address &aDestination, uint1
|
||||
discoveryResponse.Init();
|
||||
discoveryResponse.SetVersion(kThreadVersion);
|
||||
|
||||
if (Get<KeyManager>().GetSecurityPolicyFlags() & OT_SECURITY_POLICY_NATIVE_COMMISSIONING)
|
||||
if (Get<KeyManager>().IsNativeCommissioningAllowed())
|
||||
{
|
||||
SuccessOrExit(
|
||||
error = Tlv::AppendUint16Tlv(*message, MeshCoP::Tlv::kCommissionerUdpPort, MeshCoP::kBorderAgentUdpPort));
|
||||
|
||||
Reference in New Issue
Block a user