mirror of
https://github.com/espressif/openthread.git
synced 2026-07-31 08:07:47 +00:00
[mac] remove beacons payload (#7472)
Thread Specification v1.2.1 removes support for Thread Beacons payload.
This commit is contained in:
@@ -34,7 +34,7 @@ Network Key: dfd34f0f05cad978ec4e32b0413038ff
|
||||
Network Name: OpenThread-8f28
|
||||
PAN ID: 0x8f28
|
||||
PSKc: c23a76e98f1a6483639b1ac1271e2e27
|
||||
Security Policy: 0, onrcb
|
||||
Security Policy: 0, onrc
|
||||
Done
|
||||
> dataset commit active
|
||||
Done
|
||||
|
||||
@@ -152,7 +152,6 @@ typedef struct otSecurityPolicy
|
||||
bool mNativeCommissioningEnabled : 1; ///< Native Commissioning using PSKc is allowed
|
||||
bool mRoutersEnabled : 1; ///< Thread 1.0/1.1.x Routers are enabled
|
||||
bool mExternalCommissioningEnabled : 1; ///< External Commissioner authentication is allowed
|
||||
bool mBeaconsEnabled : 1; ///< Thread 1.0/1.1.x Beacons are enabled
|
||||
bool mCommercialCommissioningEnabled : 1; ///< Commercial Commissioning is enabled
|
||||
bool mAutonomousEnrollmentEnabled : 1; ///< Autonomous Enrollment is enabled
|
||||
bool mNetworkKeyProvisioningEnabled : 1; ///< Network Key Provisioning is enabled
|
||||
|
||||
@@ -53,7 +53,7 @@ extern "C" {
|
||||
* @note This number versions both OpenThread platform and user APIs.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_API_VERSION (200)
|
||||
#define OPENTHREAD_API_VERSION (201)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
|
||||
+12
-12
@@ -379,18 +379,18 @@ typedef struct otMacCounters
|
||||
*/
|
||||
typedef struct otActiveScanResult
|
||||
{
|
||||
otExtAddress mExtAddress; ///< IEEE 802.15.4 Extended Address
|
||||
otNetworkName mNetworkName; ///< Thread Network Name
|
||||
otExtendedPanId mExtendedPanId; ///< Thread Extended PAN ID
|
||||
otSteeringData mSteeringData; ///< Steering Data
|
||||
uint16_t mPanId; ///< IEEE 802.15.4 PAN ID
|
||||
uint16_t mJoinerUdpPort; ///< Joiner UDP Port
|
||||
uint8_t mChannel; ///< IEEE 802.15.4 Channel
|
||||
int8_t mRssi; ///< RSSI (dBm)
|
||||
uint8_t mLqi; ///< LQI
|
||||
unsigned int mVersion : 4; ///< Version
|
||||
bool mIsNative : 1; ///< Native Commissioner flag
|
||||
bool mIsJoinable : 1; ///< Joining Permitted flag
|
||||
otExtAddress mExtAddress; ///< IEEE 802.15.4 Extended Address
|
||||
otNetworkName mNetworkName; ///< Thread Network Name
|
||||
otExtendedPanId mExtendedPanId; ///< Thread Extended PAN ID
|
||||
otSteeringData mSteeringData; ///< Steering Data
|
||||
uint16_t mPanId; ///< IEEE 802.15.4 PAN ID
|
||||
uint16_t mJoinerUdpPort; ///< Joiner UDP Port
|
||||
uint8_t mChannel; ///< IEEE 802.15.4 Channel
|
||||
int8_t mRssi; ///< RSSI (dBm)
|
||||
uint8_t mLqi; ///< LQI
|
||||
unsigned int mVersion : 4; ///< Version
|
||||
bool mIsNative : 1; ///< Native Commissioner flag
|
||||
bool mDiscover : 1; ///< Result from MLE Discovery
|
||||
} otActiveScanResult;
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -2481,9 +2481,9 @@ Perform an IEEE 802.15.4 Active Scan.
|
||||
|
||||
```bash
|
||||
> scan
|
||||
| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |
|
||||
+---+------------------+------------------+------+------------------+----+-----+-----+
|
||||
| 0 | OpenThread | dead00beef00cafe | ffff | f1d92a82c8d8fe43 | 11 | -20 | 0 |
|
||||
| PAN | MAC Address | Ch | dBm | LQI |
|
||||
+------+------------------+----+-----+-----+
|
||||
| ffff | f1d92a82c8d8fe43 | 11 | -20 | 0 |
|
||||
Done
|
||||
```
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ Form a network with the device that has Commissioner support.
|
||||
Network Name: OpenThread-8f28
|
||||
PAN ID: 0x8f28
|
||||
PSKc: c23a76e98f1a6483639b1ac1271e2e27
|
||||
Security Policy: 0, onrcb
|
||||
Security Policy: 0, onrc
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -107,7 +107,7 @@ Form a network with the device that has Commissioner support.
|
||||
Network Name: OpenThread-8f28
|
||||
PAN ID: 0x8f28
|
||||
PSKc: c23a76e98f1a6483639b1ac1271e2e27
|
||||
Security Policy: 0, onrcb
|
||||
Security Policy: 0, onrc
|
||||
Done
|
||||
```
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ The Pending Operational Dataset is used to communicate changes to the Active Ope
|
||||
Network Name: OpenThread-8f28
|
||||
PAN ID: 0x8f28
|
||||
PSKc: c23a76e98f1a6483639b1ac1271e2e27
|
||||
Security Policy: 0, onrcb
|
||||
Security Policy: 0, onrc
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -103,7 +103,7 @@ After the device successfully attaches to a Thread network, the device will retr
|
||||
Network Name: OpenThread-8f28
|
||||
PAN ID: 0x8f28
|
||||
PSKc: c23a76e98f1a6483639b1ac1271e2e27
|
||||
Security Policy: 0, onrcb
|
||||
Security Policy: 0, onrc
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -180,7 +180,7 @@ Network Key: dfd34f0f05cad978ec4e32b0413038ff
|
||||
Network Name: OpenThread-8f28
|
||||
PAN ID: 0x8f28
|
||||
PSKc: c23a76e98f1a6483639b1ac1271e2e27
|
||||
Security Policy: 0, onrcb
|
||||
Security Policy: 0, onrc
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -359,7 +359,7 @@ Usage: `dataset mgmtsetcommand <active|pending> [TLV Type list] [-x]`
|
||||
Send MGMT_ACTIVE_SET or MGMT_PENDING_SET.
|
||||
|
||||
```bash
|
||||
> dataset mgmtsetcommand active activetimestamp 123 securitypolicy 1 onrcb
|
||||
> dataset mgmtsetcommand active activetimestamp 123 securitypolicy 1 onrc
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -441,7 +441,7 @@ Network Key: dfd34f0f05cad978ec4e32b0413038ff
|
||||
Network Name: OpenThread-8f28
|
||||
PAN ID: 0x8f28
|
||||
PSKc: c23a76e98f1a6483639b1ac1271e2e27
|
||||
Security Policy: 0, onrcb
|
||||
Security Policy: 0, onrc
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -503,7 +503,7 @@ Get security policy.
|
||||
|
||||
```bash
|
||||
> dataset securitypolicy
|
||||
672 onrcb
|
||||
672 onrc
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -520,7 +520,7 @@ Set security policy.
|
||||
- R: Non-CCM routers are allowed in Thread 1.2 CCM networks.
|
||||
|
||||
```bash
|
||||
> dataset securitypolicy 672 onrcb
|
||||
> dataset securitypolicy 672 onrc
|
||||
Done
|
||||
```
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ Border Router and service information may be stable or temporary. Stable Thread
|
||||
Network Name: OpenThread-8f28
|
||||
PAN ID: 0x8f28
|
||||
PSKc: c23a76e98f1a6483639b1ac1271e2e27
|
||||
Security Policy: 0, onrcb
|
||||
Security Policy: 0, onrc
|
||||
Done
|
||||
```
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ Network Key: 7fcbae4153cc2955c28440c15d4d4219
|
||||
Network Name: OpenThread-f7af
|
||||
PAN ID: 0xf7af
|
||||
PSKc: b658e40f174e3a11be149b302ef07a0f
|
||||
Security Policy: 672, onrcb
|
||||
Security Policy: 672, onrc
|
||||
Done
|
||||
> dataset commit active
|
||||
Done
|
||||
|
||||
+21
-21
@@ -1471,7 +1471,15 @@ template <> otError Interpreter::Process<Cmd("discover")>(Arg aArgs[])
|
||||
SuccessOrExit(error = otThreadDiscover(GetInstancePtr(), scanChannels, OT_PANID_BROADCAST, false, false,
|
||||
&Interpreter::HandleActiveScanResult, this));
|
||||
|
||||
OutputScanTableHeader();
|
||||
static const char *const kScanTableTitles[] = {
|
||||
"Network Name", "Extended PAN", "PAN", "MAC Address", "Ch", "dBm", "LQI",
|
||||
};
|
||||
|
||||
static const uint8_t kScanTableColumnWidths[] = {
|
||||
18, 18, 6, 18, 4, 5, 5,
|
||||
};
|
||||
|
||||
OutputTableHeader(kScanTableTitles, kScanTableColumnWidths);
|
||||
|
||||
error = OT_ERROR_PENDING;
|
||||
|
||||
@@ -3898,7 +3906,11 @@ template <> otError Interpreter::Process<Cmd("scan")>(Arg aArgs[])
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputScanTableHeader();
|
||||
static const char *const kScanTableTitles[] = {"PAN", "MAC Address", "Ch", "dBm", "LQI"};
|
||||
static const uint8_t kScanTableColumnWidths[] = {6, 18, 4, 5, 5};
|
||||
|
||||
OutputTableHeader(kScanTableTitles, kScanTableColumnWidths);
|
||||
|
||||
SuccessOrExit(error = otLinkActiveScan(GetInstancePtr(), scanChannels, scanDuration,
|
||||
&Interpreter::HandleActiveScanResult, this));
|
||||
}
|
||||
@@ -3909,19 +3921,6 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void Interpreter::OutputScanTableHeader(void)
|
||||
{
|
||||
static const char *const kScanTableTitles[] = {
|
||||
"J", "Network Name", "Extended PAN", "PAN", "MAC Address", "Ch", "dBm", "LQI",
|
||||
};
|
||||
|
||||
static const uint8_t kScanTableColumnWidths[] = {
|
||||
3, 18, 18, 6, 18, 4, 5, 5,
|
||||
};
|
||||
|
||||
OutputTableHeader(kScanTableTitles, kScanTableColumnWidths);
|
||||
}
|
||||
|
||||
void Interpreter::HandleActiveScanResult(otActiveScanResult *aResult, void *aContext)
|
||||
{
|
||||
static_cast<Interpreter *>(aContext)->HandleActiveScanResult(aResult);
|
||||
@@ -3935,13 +3934,14 @@ void Interpreter::HandleActiveScanResult(otActiveScanResult *aResult)
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
OutputFormat("| %d ", aResult->mIsJoinable);
|
||||
if (aResult->mDiscover)
|
||||
{
|
||||
OutputFormat("| %-16s ", aResult->mNetworkName.m8);
|
||||
|
||||
OutputFormat("| %-16s ", aResult->mNetworkName.m8);
|
||||
|
||||
OutputFormat("| ");
|
||||
OutputBytes(aResult->mExtendedPanId.m8);
|
||||
OutputFormat(" ");
|
||||
OutputFormat("| ");
|
||||
OutputBytes(aResult->mExtendedPanId.m8);
|
||||
OutputFormat(" ");
|
||||
}
|
||||
|
||||
OutputFormat("| %04x | ", aResult->mPanId);
|
||||
OutputExtAddress(aResult->mExtAddress);
|
||||
|
||||
@@ -377,7 +377,6 @@ private:
|
||||
static void HandlePingReply(const otPingSenderReply *aReply, void *aContext);
|
||||
static void HandlePingStatistics(const otPingSenderStatistics *aStatistics, void *aContext);
|
||||
#endif
|
||||
void OutputScanTableHeader(void);
|
||||
static void HandleActiveScanResult(otActiveScanResult *aResult, void *aContext);
|
||||
static void HandleEnergyScanResult(otEnergyScanResult *aResult, void *aContext);
|
||||
static void HandleLinkPcapReceive(const otRadioFrame *aFrame, bool aIsTx, void *aContext);
|
||||
|
||||
@@ -711,11 +711,6 @@ void Dataset::OutputSecurityPolicy(const otSecurityPolicy &aSecurityPolicy)
|
||||
OutputFormat("c");
|
||||
}
|
||||
|
||||
if (aSecurityPolicy.mBeaconsEnabled)
|
||||
{
|
||||
OutputFormat("b");
|
||||
}
|
||||
|
||||
if (aSecurityPolicy.mCommercialCommissioningEnabled)
|
||||
{
|
||||
OutputFormat("C");
|
||||
@@ -771,10 +766,6 @@ otError Dataset::ParseSecurityPolicy(otSecurityPolicy &aSecurityPolicy, Arg *&aA
|
||||
policy.mExternalCommissioningEnabled = true;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
policy.mBeaconsEnabled = true;
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
policy.mCommercialCommissioningEnabled = true;
|
||||
break;
|
||||
|
||||
+10
-54
@@ -224,11 +224,8 @@ bool Mac::IsInTransmitState(void) const
|
||||
|
||||
Error Mac::ConvertBeaconToActiveScanResult(const RxFrame *aBeaconFrame, ActiveScanResult &aResult)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Address address;
|
||||
const Beacon * beacon = nullptr;
|
||||
const BeaconPayload *beaconPayload = nullptr;
|
||||
uint16_t payloadLength;
|
||||
Error error = kErrorNone;
|
||||
Address address;
|
||||
|
||||
memset(&aResult, 0, sizeof(ActiveScanResult));
|
||||
|
||||
@@ -248,22 +245,7 @@ Error Mac::ConvertBeaconToActiveScanResult(const RxFrame *aBeaconFrame, ActiveSc
|
||||
aResult.mRssi = aBeaconFrame->GetRssi();
|
||||
aResult.mLqi = aBeaconFrame->GetLqi();
|
||||
|
||||
payloadLength = aBeaconFrame->GetPayloadLength();
|
||||
|
||||
beacon = reinterpret_cast<const Beacon *>(aBeaconFrame->GetPayload());
|
||||
beaconPayload = reinterpret_cast<const BeaconPayload *>(beacon->GetPayload());
|
||||
|
||||
if ((payloadLength >= (sizeof(*beacon) + sizeof(*beaconPayload))) && beacon->IsValid() && beaconPayload->IsValid())
|
||||
{
|
||||
aResult.mVersion = beaconPayload->GetProtocolVersion();
|
||||
aResult.mIsJoinable = beaconPayload->IsJoiningPermitted();
|
||||
aResult.mIsNative = beaconPayload->IsNative();
|
||||
IgnoreError(AsCoreType(&aResult.mNetworkName).Set(beaconPayload->GetNetworkName()));
|
||||
VerifyOrExit(IsValidUtf8String(aResult.mNetworkName.m8), error = kErrorParse);
|
||||
aResult.mExtendedPanId = beaconPayload->GetExtendedPanId();
|
||||
}
|
||||
|
||||
LogBeacon("Received", *beaconPayload);
|
||||
LogBeacon("Received");
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -797,11 +779,9 @@ TxFrame *Mac::PrepareBeaconRequest(void)
|
||||
|
||||
TxFrame *Mac::PrepareBeacon(void)
|
||||
{
|
||||
TxFrame * frame;
|
||||
uint8_t beaconLength;
|
||||
uint16_t fcf;
|
||||
Beacon * beacon = nullptr;
|
||||
BeaconPayload *beaconPayload = nullptr;
|
||||
TxFrame *frame;
|
||||
uint16_t fcf;
|
||||
Beacon * beacon = nullptr;
|
||||
|
||||
#if OPENTHREAD_CONFIG_MULTI_RADIO
|
||||
OT_ASSERT(!mTxBeaconRadioLinks.IsEmpty());
|
||||
@@ -818,32 +798,8 @@ TxFrame *Mac::PrepareBeacon(void)
|
||||
|
||||
beacon = reinterpret_cast<Beacon *>(frame->GetPayload());
|
||||
beacon->Init();
|
||||
beaconLength = sizeof(*beacon);
|
||||
|
||||
beaconPayload = reinterpret_cast<BeaconPayload *>(beacon->GetPayload());
|
||||
|
||||
if (Get<KeyManager>().GetSecurityPolicy().mBeaconsEnabled)
|
||||
{
|
||||
beaconPayload->Init();
|
||||
|
||||
if (IsJoinable())
|
||||
{
|
||||
beaconPayload->SetJoiningPermitted();
|
||||
}
|
||||
else
|
||||
{
|
||||
beaconPayload->ClearJoiningPermitted();
|
||||
}
|
||||
|
||||
beaconPayload->SetNetworkName(mNetworkName.GetAsData());
|
||||
beaconPayload->SetExtendedPanId(mExtendedPanId);
|
||||
|
||||
beaconLength += sizeof(*beaconPayload);
|
||||
}
|
||||
|
||||
frame->SetPayloadLength(beaconLength);
|
||||
|
||||
LogBeacon("Sending", *beaconPayload);
|
||||
LogBeacon("Sending");
|
||||
|
||||
return frame;
|
||||
}
|
||||
@@ -2276,9 +2232,9 @@ void Mac::LogFrameTxFailure(const TxFrame &aFrame, Error aError, uint8_t aRetryC
|
||||
}
|
||||
}
|
||||
|
||||
void Mac::LogBeacon(const char *aActionText, const BeaconPayload &aBeaconPayload) const
|
||||
void Mac::LogBeacon(const char *aActionText) const
|
||||
{
|
||||
LogInfo("%s Beacon, %s", aActionText, aBeaconPayload.ToInfoString().AsCString());
|
||||
LogInfo("%s Beacon", aActionText);
|
||||
}
|
||||
|
||||
#else // #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO)
|
||||
@@ -2287,7 +2243,7 @@ void Mac::LogFrameRxFailure(const RxFrame *, Error) const
|
||||
{
|
||||
}
|
||||
|
||||
void Mac::LogBeacon(const char *, const BeaconPayload &) const
|
||||
void Mac::LogBeacon(const char *) const
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -856,7 +856,7 @@ private:
|
||||
|
||||
void LogFrameRxFailure(const RxFrame *aFrame, Error aError) const;
|
||||
void LogFrameTxFailure(const TxFrame &aFrame, Error aError, uint8_t aRetryCount, bool aWillRetx) const;
|
||||
void LogBeacon(const char *aActionText, const BeaconPayload &aBeaconPayload) const;
|
||||
void LogBeacon(const char *aActionText) const;
|
||||
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
uint8_t GetTimeIeOffset(const Frame &aFrame);
|
||||
|
||||
@@ -1447,19 +1447,6 @@ Frame::InfoString Frame::ToInfoString(void) const
|
||||
return string;
|
||||
}
|
||||
|
||||
BeaconPayload::InfoString BeaconPayload::ToInfoString(void) const
|
||||
{
|
||||
NetworkName name;
|
||||
InfoString string;
|
||||
|
||||
IgnoreError(name.Set(GetNetworkName()));
|
||||
|
||||
string.Append("name:%s, xpanid:%s, id:%d, ver:%d, joinable:%s, native:%s", name.GetAsCString(),
|
||||
mExtendedPanId.ToString().AsCString(), GetProtocolId(), GetProtocolVersion(),
|
||||
ToYesNo(IsJoiningPermitted()), ToYesNo(IsNative()));
|
||||
return string;
|
||||
}
|
||||
|
||||
#endif // #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_NOTE)
|
||||
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
@@ -1482,161 +1482,6 @@ private:
|
||||
uint8_t mPendingAddressSpec;
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* This class implements IEEE 802.15.4 Beacon Payload generation and parsing.
|
||||
*
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
class BeaconPayload
|
||||
{
|
||||
public:
|
||||
static constexpr uint8_t kProtocolId = 3; ///< Thread Protocol ID.
|
||||
static constexpr uint8_t kProtocolVersion = 2; ///< Thread Protocol version.
|
||||
static constexpr uint8_t kVersionOffset = 4; ///< Version field bit offset.
|
||||
static constexpr uint8_t kVersionMask = 0xf << kVersionOffset; ///< Version field mask.
|
||||
static constexpr uint8_t kNativeFlag = 1 << 3; ///< Native Commissioner flag.
|
||||
static constexpr uint8_t kJoiningFlag = 1 << 0; ///< Joining Permitted flag.
|
||||
|
||||
static constexpr uint16_t kInfoStringSize = 92; ///< Max chars for the info string (@sa ToInfoString()).
|
||||
|
||||
/**
|
||||
* This type defines the fixed-length `String` object returned from `ToInfoString()` method.
|
||||
*
|
||||
*/
|
||||
typedef String<kInfoStringSize> InfoString;
|
||||
|
||||
/**
|
||||
* This method initializes the Beacon Payload.
|
||||
*
|
||||
*/
|
||||
void Init(void)
|
||||
{
|
||||
mProtocolId = kProtocolId;
|
||||
mFlags = kProtocolVersion << kVersionOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the beacon appears to be a valid Thread Beacon Payload.
|
||||
*
|
||||
* @retval TRUE If the beacon appears to be a valid Thread Beacon Payload.
|
||||
* @retval FALSE If the beacon does not appear to be a valid Thread Beacon Payload.
|
||||
*
|
||||
*/
|
||||
bool IsValid(void) const { return (mProtocolId == kProtocolId); }
|
||||
|
||||
/**
|
||||
* This method returns the Protocol ID value.
|
||||
*
|
||||
* @returns the Protocol ID value.
|
||||
*
|
||||
*/
|
||||
uint8_t GetProtocolId(void) const { return mProtocolId; }
|
||||
|
||||
/**
|
||||
* This method returns the Protocol Version value.
|
||||
*
|
||||
* @returns The Protocol Version value.
|
||||
*
|
||||
*/
|
||||
uint8_t GetProtocolVersion(void) const { return mFlags >> kVersionOffset; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Native Commissioner flag is set.
|
||||
*
|
||||
* @retval TRUE If the Native Commissioner flag is set.
|
||||
* @retval FALSE If the Native Commissioner flag is not set.
|
||||
*
|
||||
*/
|
||||
bool IsNative(void) const { return (mFlags & kNativeFlag) != 0; }
|
||||
|
||||
/**
|
||||
* This method clears the Native Commissioner flag.
|
||||
*
|
||||
*/
|
||||
void ClearNative(void) { mFlags &= ~kNativeFlag; }
|
||||
|
||||
/**
|
||||
* This method sets the Native Commissioner flag.
|
||||
*
|
||||
*/
|
||||
void SetNative(void) { mFlags |= kNativeFlag; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Joining Permitted flag is set.
|
||||
*
|
||||
* @retval TRUE If the Joining Permitted flag is set.
|
||||
* @retval FALSE If the Joining Permitted flag is not set.
|
||||
*
|
||||
*/
|
||||
bool IsJoiningPermitted(void) const { return (mFlags & kJoiningFlag) != 0; }
|
||||
|
||||
/**
|
||||
* This method clears the Joining Permitted flag.
|
||||
*
|
||||
*/
|
||||
void ClearJoiningPermitted(void) { mFlags &= ~kJoiningFlag; }
|
||||
|
||||
/**
|
||||
* This method sets the Joining Permitted flag.
|
||||
*
|
||||
*/
|
||||
void SetJoiningPermitted(void)
|
||||
{
|
||||
mFlags |= kJoiningFlag;
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_JOIN_BEACON_VERSION != 2 // check against kProtocolVersion
|
||||
mFlags &= ~kVersionMask;
|
||||
mFlags |= OPENTHREAD_CONFIG_MAC_JOIN_BEACON_VERSION << kVersionOffset;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets the Network Name field.
|
||||
*
|
||||
* @returns The Network Name field as `NameData`.
|
||||
*
|
||||
*/
|
||||
NameData GetNetworkName(void) const { return NameData(mNetworkName, sizeof(mNetworkName)); }
|
||||
|
||||
/**
|
||||
* This method sets the Network Name field.
|
||||
*
|
||||
* @param[in] aNameData The Network Name (as a `NameData`).
|
||||
*
|
||||
*/
|
||||
void SetNetworkName(const NameData &aNameData) { aNameData.CopyTo(mNetworkName, sizeof(mNetworkName)); }
|
||||
|
||||
/**
|
||||
* This method returns the Extended PAN ID field.
|
||||
*
|
||||
* @returns The Extended PAN ID field.
|
||||
*
|
||||
*/
|
||||
const ExtendedPanId &GetExtendedPanId(void) const { return mExtendedPanId; }
|
||||
|
||||
/**
|
||||
* This method sets the Extended PAN ID field.
|
||||
*
|
||||
* @param[in] aExtPanId An Extended PAN ID.
|
||||
*
|
||||
*/
|
||||
void SetExtendedPanId(const ExtendedPanId &aExtPanId) { mExtendedPanId = aExtPanId; }
|
||||
|
||||
/**
|
||||
* This method returns information about the Beacon as a `InfoString`.
|
||||
*
|
||||
* @returns An `InfoString` representing the beacon payload.
|
||||
*
|
||||
*/
|
||||
InfoString ToInfoString(void) const;
|
||||
|
||||
private:
|
||||
uint8_t mProtocolId;
|
||||
uint8_t mFlags;
|
||||
char mNetworkName[NetworkName::kMaxSize];
|
||||
ExtendedPanId mExtendedPanId;
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* This class implements CSL IE data structure.
|
||||
*
|
||||
|
||||
@@ -310,10 +310,11 @@ void DiscoverScanner::HandleDiscoveryResponse(const Message &aMessage, const Ip6
|
||||
end = offset + tlv.GetLength();
|
||||
|
||||
memset(&result, 0, sizeof(result));
|
||||
result.mPanId = linkInfo->mPanId;
|
||||
result.mChannel = linkInfo->mChannel;
|
||||
result.mRssi = linkInfo->mRss;
|
||||
result.mLqi = linkInfo->mLqi;
|
||||
result.mDiscover = true;
|
||||
result.mPanId = linkInfo->mPanId;
|
||||
result.mChannel = linkInfo->mChannel;
|
||||
result.mRssi = linkInfo->mRss;
|
||||
result.mLqi = linkInfo->mLqi;
|
||||
|
||||
aMessageInfo.GetPeerAddr().GetIid().ConvertToExtAddress(AsCoreType(&result.mExtAddress));
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ void SecurityPolicy::SetToDefaultFlags(void)
|
||||
mNativeCommissioningEnabled = true;
|
||||
mRoutersEnabled = true;
|
||||
mExternalCommissioningEnabled = true;
|
||||
mBeaconsEnabled = true;
|
||||
mCommercialCommissioningEnabled = false;
|
||||
mAutonomousEnrollmentEnabled = false;
|
||||
mNetworkKeyProvisioningEnabled = false;
|
||||
@@ -91,7 +90,6 @@ void SecurityPolicy::SetFlags(const uint8_t *aFlags, uint8_t aFlagsLength)
|
||||
mNativeCommissioningEnabled = aFlags[0] & kNativeCommissioningMask;
|
||||
mRoutersEnabled = aFlags[0] & kRoutersMask;
|
||||
mExternalCommissioningEnabled = aFlags[0] & kExternalCommissioningMask;
|
||||
mBeaconsEnabled = aFlags[0] & kBeaconsMask;
|
||||
mCommercialCommissioningEnabled = (aFlags[0] & kCommercialCommissioningMask) == 0;
|
||||
mAutonomousEnrollmentEnabled = (aFlags[0] & kAutonomousEnrollmentMask) == 0;
|
||||
mNetworkKeyProvisioningEnabled = (aFlags[0] & kNetworkKeyProvisioningMask) == 0;
|
||||
@@ -131,11 +129,6 @@ void SecurityPolicy::GetFlags(uint8_t *aFlags, uint8_t aFlagsLength) const
|
||||
aFlags[0] |= kExternalCommissioningMask;
|
||||
}
|
||||
|
||||
if (mBeaconsEnabled)
|
||||
{
|
||||
aFlags[0] |= kBeaconsMask;
|
||||
}
|
||||
|
||||
if (!mCommercialCommissioningEnabled)
|
||||
{
|
||||
aFlags[0] |= kCommercialCommissioningMask;
|
||||
|
||||
@@ -4221,11 +4221,6 @@ void NcpBase::HandleActiveScanResult(otActiveScanResult *aResult)
|
||||
{
|
||||
uint8_t flags = static_cast<uint8_t>(aResult->mVersion << SPINEL_BEACON_THREAD_FLAG_VERSION_SHIFT);
|
||||
|
||||
if (aResult->mIsJoinable)
|
||||
{
|
||||
flags |= SPINEL_BEACON_THREAD_FLAG_JOINABLE;
|
||||
}
|
||||
|
||||
if (aResult->mIsNative)
|
||||
{
|
||||
flags |= SPINEL_BEACON_THREAD_FLAG_NATIVE;
|
||||
|
||||
@@ -102,10 +102,10 @@ expect_line "Done"
|
||||
send "dataset pskc\n"
|
||||
expect "00112233445566778899aabbccddeeff"
|
||||
expect_line "Done"
|
||||
send "dataset securitypolicy 678 onrcb\n"
|
||||
send "dataset securitypolicy 678 onrc\n"
|
||||
expect_line "Done"
|
||||
send "dataset securitypolicy\n"
|
||||
expect "678 onrcb"
|
||||
expect "678 onrc"
|
||||
expect_line "Done"
|
||||
send "dataset pendingtimestamp 100\n"
|
||||
expect_line "Done"
|
||||
@@ -135,7 +135,7 @@ expect "Network Key: aabbccddeeff00112233445566778899"
|
||||
expect "Network Name: OT-network"
|
||||
expect "PAN ID: 0xface"
|
||||
expect "PSKc: 00112233445566778899aabbccddeeff"
|
||||
expect "Security Policy: 678 onrcb"
|
||||
expect "Security Policy: 678 onrc"
|
||||
expect_line "Done"
|
||||
send "dataset pending -x\n"
|
||||
expect "dataset pending -x"
|
||||
@@ -161,7 +161,7 @@ expect "Network Key: aabbccddeeff00112233445566778899"
|
||||
expect "Network Name: OT-network"
|
||||
expect "PAN ID: 0xface"
|
||||
expect "PSKc: 00112233445566778899aabbccddeeff"
|
||||
expect "Security Policy: 678 onrcb"
|
||||
expect "Security Policy: 678 onrc"
|
||||
expect_line "Done"
|
||||
|
||||
sleep 30
|
||||
@@ -183,7 +183,7 @@ expect "Network Key: aabbccddeeff00112233445566778899"
|
||||
expect "Network Name: OT-network"
|
||||
expect "PAN ID: 0xface"
|
||||
expect "PSKc: 00112233445566778899aabbccddeeff"
|
||||
expect "Security Policy: 678 onrcb"
|
||||
expect "Security Policy: 678 onrc"
|
||||
expect_line "Done"
|
||||
send "dataset clear\n"
|
||||
expect_line "Done"
|
||||
@@ -203,7 +203,7 @@ expect "Network Key: aabbccddeeff00112233445566778899"
|
||||
expect "Network Name: OT-network"
|
||||
expect "PAN ID: 0xface"
|
||||
expect "PSKc: 00112233445566778899aabbccddeeff"
|
||||
expect "Security Policy: 678 onrcb"
|
||||
expect "Security Policy: 678 onrc"
|
||||
expect_line "Done"
|
||||
send "dataset init pending\n"
|
||||
expect "Error 23: NotFound"
|
||||
|
||||
@@ -43,7 +43,9 @@ wait_for "state" "leader"
|
||||
expect_line "Done"
|
||||
|
||||
switch_node 2
|
||||
send "scan\n"
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
send "discover\n"
|
||||
expect "Thread Network"
|
||||
expect_line "Done"
|
||||
|
||||
@@ -58,7 +60,7 @@ wait_for "state" "leader"
|
||||
expect_line "Done"
|
||||
|
||||
switch_node 2
|
||||
send "scan\n"
|
||||
send "discover\n"
|
||||
expect "Thread 网络"
|
||||
expect_line "Done"
|
||||
|
||||
@@ -73,7 +75,7 @@ wait_for "state" "leader"
|
||||
expect_line "Done"
|
||||
|
||||
switch_node 2
|
||||
send "scan\n"
|
||||
send "discover\n"
|
||||
expect "スレッド"
|
||||
expect_line "Done"
|
||||
|
||||
|
||||
@@ -60,9 +60,9 @@ expect_line "Done"
|
||||
|
||||
switch_node 3
|
||||
send "scan $channel\n"
|
||||
expect "| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |"
|
||||
expect "+---+------------------+------------------+------+------------------+----+-----+-----+"
|
||||
wait_for "" "\\| \\d \\| $network +\\| $extpan \\| $pan \\| $extaddr \\| +$channel \\| +-?\\d+ \\| +\\d \\|"
|
||||
expect "| PAN | MAC Address | Ch | dBm | LQI |"
|
||||
expect "+------+------------------+----+-----+-----+"
|
||||
wait_for "" "\\| $pan \\| $extaddr \\| +$channel \\| +-?\\d+ \\| +\\d \\|"
|
||||
wait_for "" "Done"
|
||||
send "scan energy 100\n"
|
||||
expect "| Ch | RSSI |"
|
||||
@@ -83,9 +83,9 @@ expect "Error 13: InvalidState"
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
send "discover $channel\n"
|
||||
expect "| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |"
|
||||
expect "+---+------------------+------------------+------+------------------+----+-----+-----+"
|
||||
wait_for "" "\\| \\d \\| $network +\\| $extpan \\| $pan \\| $extaddr \\| +$channel \\| +-?\\d+ \\| +\\d \\|"
|
||||
expect "| Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |"
|
||||
expect "+------------------+------------------+------+------------------+----+-----+-----+"
|
||||
wait_for "" "\\| $network +\\| $extpan \\| $pan \\| $extaddr \\| +$channel \\| +-?\\d+ \\| +\\d \\|"
|
||||
wait_for "" "Done"
|
||||
send "discover something_invalid\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
|
||||
@@ -49,17 +49,6 @@ expect "panid"
|
||||
expect -re {([0-9a-f]{4})}
|
||||
set pan $expect_out(1,string)
|
||||
expect_line "Done"
|
||||
send "extpanid\n"
|
||||
expect "extpanid"
|
||||
expect -re {([0-9a-f]{16})}
|
||||
set extpan $expect_out(1,string)
|
||||
expect_line "Done"
|
||||
expect "> "
|
||||
send "networkname\n"
|
||||
expect "networkname"
|
||||
expect -re {[\r\n]([^\r\n]+)[\r\n]}
|
||||
set network $expect_out(1,string)
|
||||
expect_line "Done"
|
||||
send "channel\n"
|
||||
expect "channel"
|
||||
expect -re {(\d+)}
|
||||
@@ -68,9 +57,9 @@ expect_line "Done"
|
||||
|
||||
spawn_node 2 "rcp" "spinel+hdlc+uart://$env(OT_SIMULATION_APPS)/ncp/ot-rcp?forkpty-arg=--sleep-to-tx&forkpty-arg=2"
|
||||
send "scan\n"
|
||||
expect "| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |"
|
||||
expect "+---+------------------+------------------+------+------------------+----+-----+-----+"
|
||||
wait_for "" "\\| \\d \\| $network +\\| $extpan \\| $pan \\| $extaddr \\| +$channel \\| +-?\\d+ \\| +\\d \\|"
|
||||
expect "| PAN | MAC Address | Ch | dBm | LQI |"
|
||||
expect "+------+------------------+----+-----+-----+"
|
||||
wait_for "" "\\| $pan \\| $extaddr \\| +$channel \\| +-?\\d+ \\| +\\d \\|"
|
||||
wait_for "" "Done"
|
||||
|
||||
dispose_all
|
||||
|
||||
@@ -77,7 +77,7 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
|
||||
'timestamp': 1,
|
||||
'channel': 19,
|
||||
'network_key': '00112233445566778899aabbccddeeff',
|
||||
'security_policy': [3600, 'onrcb']
|
||||
'security_policy': [3600, 'onrc']
|
||||
},
|
||||
'mode': 'rdn',
|
||||
},
|
||||
@@ -87,7 +87,7 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
|
||||
'timestamp': 1,
|
||||
'channel': 19,
|
||||
'network_key': '00112233445566778899aabbccddeeff',
|
||||
'security_policy': [3600, 'onrcb']
|
||||
'security_policy': [3600, 'onrc']
|
||||
},
|
||||
'mode': 'rdn',
|
||||
'allowlist': [LEADER]
|
||||
@@ -103,7 +103,7 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
|
||||
'timestamp': 1,
|
||||
'channel': 19,
|
||||
'network_key': '00112233445566778899aabbccddeeff',
|
||||
'security_policy': [3600, 'onrcb']
|
||||
'security_policy': [3600, 'onrc']
|
||||
},
|
||||
'mode': 'rdn',
|
||||
},
|
||||
@@ -130,10 +130,10 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
|
||||
self.simulator.go(5)
|
||||
|
||||
# Step 5
|
||||
# Disabling O-Bit security_policy = [3600, 0b01111000]
|
||||
# Disabling O-Bit security_policy = [3600, 0b01110000]
|
||||
self.nodes[COMMISSIONER_1].send_mgmt_active_set(
|
||||
active_timestamp=15,
|
||||
security_policy=[3600, 'nrcb'],
|
||||
security_policy=[3600, 'nrc'],
|
||||
)
|
||||
self.simulator.go(5)
|
||||
|
||||
@@ -143,10 +143,10 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
|
||||
self.simulator.go(5)
|
||||
|
||||
# Step 9
|
||||
# Disabling N-Bit security_policy = [3600, 0b10111000]
|
||||
# Disabling N-Bit security_policy = [3600, 0b10110000]
|
||||
self.nodes[COMMISSIONER_1].send_mgmt_active_set(
|
||||
active_timestamp=20,
|
||||
security_policy=[3600, 'orcb'],
|
||||
security_policy=[3600, 'orc'],
|
||||
)
|
||||
self.simulator.go(5)
|
||||
|
||||
@@ -173,10 +173,10 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
|
||||
self.simulator.go(20)
|
||||
|
||||
# Step 17
|
||||
# Disabling R-Bit security_policy = [3600, 0b11011000]
|
||||
# Disabling R-Bit security_policy = [3600, 0b11010000]
|
||||
self.nodes[COMMISSIONER_1].send_mgmt_active_set(
|
||||
active_timestamp=30,
|
||||
security_policy=[3600, 'oncb'],
|
||||
security_policy=[3600, 'onc'],
|
||||
)
|
||||
self.simulator.go(5)
|
||||
|
||||
@@ -209,7 +209,7 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
|
||||
# 2.04 Changed
|
||||
# CoAP Payload
|
||||
# Security Policy TLV
|
||||
# Bits “O”,”N”,”R”,”C”,”B” should be set to 1
|
||||
# Bits “O”,”N”,”R”,”C” should be set to 1
|
||||
pkts.filter_wpan_src64(LEADER).\
|
||||
filter_ipv6_dst(COMMISSIONER_1_RLOC).\
|
||||
filter_coap_ack(MGMT_ACTIVE_GET_URI).\
|
||||
@@ -217,9 +217,8 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
|
||||
p.thread_meshcop.tlv.sec_policy_o == 1 and
|
||||
p.thread_meshcop.tlv.sec_policy_n == 1 and
|
||||
p.thread_meshcop.tlv.sec_policy_r == 1 and
|
||||
p.thread_meshcop.tlv.sec_policy_c == 1 and
|
||||
p.thread_meshcop.tlv.sec_policy_b == 1) or
|
||||
(p.thread_meshcop.tlv.unknown == '0e10ff')).\
|
||||
p.thread_meshcop.tlv.sec_policy_c == 1) or
|
||||
(p.thread_meshcop.tlv.unknown == '0e10f7')).\
|
||||
must_next()
|
||||
|
||||
# Step 5: Commissioner_1 sends MGMT_ACTIVE_SET.req to Leader
|
||||
@@ -239,7 +238,7 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
|
||||
} == set(p.thread_meshcop.tlv.type) and\
|
||||
p.thread_meshcop.tlv.active_tstamp == 15 and\
|
||||
(p.thread_meshcop.tlv.sec_policy_o == 0 or
|
||||
p.thread_meshcop.tlv.unknown == '0e107f')).\
|
||||
p.thread_meshcop.tlv.unknown == '0e1077')).\
|
||||
must_next()
|
||||
|
||||
# Step 6: Leader MUST send MGMT_ACTIVE_SET.rsp to the Commissioner_1
|
||||
@@ -292,7 +291,7 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
|
||||
} == set(p.thread_meshcop.tlv.type) and\
|
||||
p.thread_meshcop.tlv.active_tstamp == 20 and\
|
||||
(p.thread_meshcop.tlv.sec_policy_n == 0 or
|
||||
p.thread_meshcop.tlv.unknown == '0e10bf')).\
|
||||
p.thread_meshcop.tlv.unknown == '0e10b7')).\
|
||||
must_next()
|
||||
|
||||
# Step 10: Leader MUST send MGMT_ACTIVE_SET.rsp to the Commissioner_1
|
||||
@@ -376,7 +375,7 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
|
||||
} == set(p.thread_meshcop.tlv.type) and\
|
||||
p.thread_meshcop.tlv.active_tstamp == 30 and\
|
||||
(p.thread_meshcop.tlv.sec_policy_r == 0 or
|
||||
p.thread_meshcop.tlv.unknown == '0e10df')).\
|
||||
p.thread_meshcop.tlv.unknown == '0e10d7')).\
|
||||
must_next()
|
||||
|
||||
# Step 18: Leader MUST send MGMT_ACTIVE_SET.rsp to the Commissioner_1
|
||||
@@ -407,7 +406,7 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
|
||||
filter(lambda p:
|
||||
p.mle.tlv.active_tstamp == 30 and\
|
||||
(p.thread_meshcop.tlv.sec_policy_r == 0 or
|
||||
p.thread_meshcop.tlv.unknown == '0e10df')).\
|
||||
p.thread_meshcop.tlv.unknown == '0e10d7')).\
|
||||
must_next()
|
||||
|
||||
|
||||
|
||||
@@ -2085,15 +2085,11 @@ class NodeImpl:
|
||||
if result == 1:
|
||||
networks = []
|
||||
for line in self._expect_command_output()[2:]:
|
||||
_, J, networkname, extpanid, panid, extaddr, channel, dbm, lqi, _ = map(str.strip, line.split('|'))
|
||||
J = bool(int(J))
|
||||
_, panid, extaddr, channel, dbm, lqi, _ = map(str.strip, line.split('|'))
|
||||
panid = int(panid, 16)
|
||||
channel, dbm, lqi = map(int, (channel, dbm, lqi))
|
||||
|
||||
networks.append({
|
||||
'joinable': J,
|
||||
'networkname': networkname,
|
||||
'extpanid': extpanid,
|
||||
'panid': panid,
|
||||
'extaddr': extaddr,
|
||||
'channel': channel,
|
||||
|
||||
@@ -70,8 +70,6 @@ class Test_MacScan(thread_cert.TestCase):
|
||||
self.assertEqual(len(results), 1)
|
||||
network = results[0]
|
||||
self.assertEqual(network['extaddr'], self.nodes[ROUTER].get_addr64())
|
||||
self.assertEqual(network['extpanid'], self.nodes[ROUTER].get_extpanid())
|
||||
self.assertEqual(network['networkname'], self.nodes[ROUTER].get_network_name())
|
||||
self.assertEqual(network['channel'], CHANNEL)
|
||||
|
||||
|
||||
|
||||
@@ -124,7 +124,6 @@ wpan1 => [
|
||||
"Network:PANID" => 0x9D81
|
||||
"IPv6:MeshLocalAddress" => "fda4:38cf:5973:0:b899:3436:15c6:941d"
|
||||
"IPv6:MeshLocalPrefix" => "fda4:38cf:5973::/64"
|
||||
"com.nestlabs.internal:Network:AllowingJoin" => false
|
||||
]
|
||||
```
|
||||
|
||||
@@ -348,9 +347,9 @@ $ Node1.wpanctl('form "toranj-net"'):
|
||||
Forming WPAN "toranj-net" as node type "router"
|
||||
Successfully formed!
|
||||
$ Node2.wpanctl('scan'):
|
||||
| Joinable | NetworkName | PAN ID | Ch | XPanID | HWAddr | RSSI
|
||||
---+----------+--------------------+--------+----+------------------+------------------+------
|
||||
1 | NO | "toranj-net" | 0x9DEB | 16 | 8CC6CFC810F23E1B | BEECDAF3439DC931 | -20
|
||||
| PAN ID | Ch | XPanID | HWAddr | RSSI
|
||||
---+--------+----+------------------+------------------+------
|
||||
1 | 0x9DEB | 16 | 8CC6CFC810F23E1B | BEECDAF3439DC931 | -20
|
||||
$ Node1.wpanctl('get -v NCP:State') -> '"associated"'
|
||||
$ Node1.wpanctl('get -v Network:Name') -> '"toranj-net"'
|
||||
$ Node1.wpanctl('get -v Network:PANID') -> '0x9DEB'
|
||||
|
||||
@@ -101,7 +101,6 @@ all_gettable_props = [
|
||||
wpan.WPAN_PARTITION_ID,
|
||||
wpan.WPAN_NCP_VERSION,
|
||||
wpan.WPAN_NCP_MCU_POWER_STATE,
|
||||
wpan.WPAN_NETWORK_ALLOW_JOIN,
|
||||
wpan.WPAN_NETWORK_PASSTHRU_PORT,
|
||||
wpan.WPAN_IP6_LINK_LOCAL_ADDRESS,
|
||||
wpan.WPAN_IP6_MESH_LOCAL_ADDRESS,
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (c) 2018, 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.
|
||||
|
||||
import time
|
||||
import wpan
|
||||
from wpan import verify
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------------
|
||||
# Test description: check wpantund `permit-join` functionality and timeout
|
||||
|
||||
test_name = __file__[:-3] if __file__.endswith('.py') else __file__
|
||||
print('-' * 120)
|
||||
print('Starting \'{}\''.format(test_name))
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------------
|
||||
# Creating `wpan.Nodes` instances
|
||||
|
||||
node = wpan.Node()
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------------
|
||||
# Init all nodes
|
||||
|
||||
wpan.Node.init_all_nodes()
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------------
|
||||
# Build network topology
|
||||
|
||||
node.form("permit-join-test")
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------------
|
||||
# Test implementation
|
||||
|
||||
verify(node.get(wpan.WPAN_NETWORK_ALLOW_JOIN) == 'false')
|
||||
|
||||
node.permit_join()
|
||||
verify(node.get(wpan.WPAN_NETWORK_ALLOW_JOIN) == 'true')
|
||||
|
||||
node.permit_join('0')
|
||||
verify(node.get(wpan.WPAN_NETWORK_ALLOW_JOIN) == 'false')
|
||||
|
||||
node.permit_join(port='1234')
|
||||
verify(node.get(wpan.WPAN_NETWORK_ALLOW_JOIN) == 'true')
|
||||
|
||||
node.permit_join('0')
|
||||
verify(node.get(wpan.WPAN_NETWORK_ALLOW_JOIN) == 'false')
|
||||
|
||||
# check the timeout
|
||||
node.permit_join('1')
|
||||
verify(node.get(wpan.WPAN_NETWORK_ALLOW_JOIN) == 'true')
|
||||
time.sleep(1.5)
|
||||
verify(node.get(wpan.WPAN_NETWORK_ALLOW_JOIN) == 'false')
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------------
|
||||
# Test finished
|
||||
|
||||
wpan.Node.finalize_all_nodes()
|
||||
|
||||
print('\'{}\' passed.'.format(test_name))
|
||||
@@ -60,7 +60,6 @@ NUM_MSGS = 4
|
||||
|
||||
# Make node1 joinable and set the insecure port
|
||||
node1.permit_join(duration_sec='100', port=str(insecure_port))
|
||||
verify(node1.get(wpan.WPAN_NETWORK_ALLOW_JOIN) == 'true')
|
||||
|
||||
# Join node1 network from node2 without setting the key
|
||||
node2.join_node(node1, should_set_key=False)
|
||||
|
||||
+16
-20
@@ -56,7 +56,6 @@ WPAN_ROLE = 'Network:Role'
|
||||
WPAN_PARTITION_ID = 'Network:PartitionId'
|
||||
WPAN_NCP_VERSION = 'NCP:Version'
|
||||
WPAN_NCP_MCU_POWER_STATE = "NCP:MCUPowerState"
|
||||
WPAN_NETWORK_ALLOW_JOIN = 'com.nestlabs.internal:Network:AllowingJoin'
|
||||
WPAN_NETWORK_PASSTHRU_PORT = 'com.nestlabs.internal:Network:PassthruPort'
|
||||
WPAN_RCP_VERSION = "POSIXApp:RCPVersion"
|
||||
|
||||
@@ -568,7 +567,6 @@ class Node(object):
|
||||
"""Checks if node is in the scan results
|
||||
`scan_result` must be an array of `ScanResult` object (see `parse_scan_result`).
|
||||
"""
|
||||
joinable = (self.get(WPAN_NETWORK_ALLOW_JOIN) == 'true')
|
||||
panid = self.get(WPAN_PANID)
|
||||
xpanid = self.get(WPAN_XPANID)[2:]
|
||||
name = self.get(WPAN_NAME)[1:-1]
|
||||
@@ -576,11 +574,12 @@ class Node(object):
|
||||
ext_address = self.get(WPAN_EXT_ADDRESS)[1:-1]
|
||||
|
||||
for item in scan_result:
|
||||
if all([
|
||||
item.network_name == name, item.panid == panid, item.xpanid == xpanid,
|
||||
item.channel == channel, item.ext_address == ext_address,
|
||||
(item.type == ScanResult.TYPE_DISCOVERY_SCAN) or (item.joinable == joinable)
|
||||
]):
|
||||
if all([item.panid == panid, item.channel == channel, item.ext_address == ext_address]):
|
||||
if (item.type == ScanResult.TYPE_DISCOVERY_SCAN):
|
||||
if all([item.network_name == name, item.xpanid == xpanid]):
|
||||
return True
|
||||
else:
|
||||
continue
|
||||
return True
|
||||
|
||||
return False
|
||||
@@ -1061,16 +1060,17 @@ class ScanResult(object):
|
||||
|
||||
items = [item.strip() for item in result_text.split('|')]
|
||||
|
||||
if len(items) == 8:
|
||||
if len(items) == 2:
|
||||
self._type = ScanResult.TYPE_ENERGY_SCAN
|
||||
self._channel = items[0]
|
||||
self._rssi = items[1]
|
||||
if len(items) == 7 and '------ NONE ------' in items[1]:
|
||||
self._type = ScanResult.TYPE_ACTIVE_SCAN
|
||||
self._index = items[0]
|
||||
self._joinable = (items[1] == 'YES')
|
||||
self._network_name = items[2][1:-1]
|
||||
self._panid = items[3]
|
||||
self._channel = items[4]
|
||||
self._xpanid = items[5]
|
||||
self._ext_address = items[6]
|
||||
self._rssi = items[7]
|
||||
self._panid = items[2]
|
||||
self._channel = items[3]
|
||||
self._ext_address = items[5]
|
||||
self._rssi = items[6]
|
||||
elif len(items) == 7:
|
||||
self._type = ScanResult.TYPE_DISCOVERY_SCAN
|
||||
self._index = items[0]
|
||||
@@ -1080,12 +1080,8 @@ class ScanResult(object):
|
||||
self._xpanid = items[4]
|
||||
self._ext_address = items[5]
|
||||
self._rssi = items[6]
|
||||
elif len(items) == 2:
|
||||
self._type = ScanResult.TYPE_ENERGY_SCAN
|
||||
self._channel = items[0]
|
||||
self._rssi = items[1]
|
||||
else:
|
||||
raise ValueError('"{}" does not seem to be a valid scan result string'.result_text)
|
||||
raise ValueError('"%s" does not seem to be a valid scan result string' % result_text)
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
|
||||
@@ -152,7 +152,6 @@ run ncp/test-004-scan.py
|
||||
run ncp/test-005-discover-scan.py
|
||||
run ncp/test-006-traffic-router-end-device.py
|
||||
run ncp/test-007-traffic-router-sleepy.py
|
||||
run ncp/test-008-permit-join.py
|
||||
run ncp/test-009-insecure-traffic-join.py
|
||||
run ncp/test-010-on-mesh-prefix-config-gateway.py
|
||||
run ncp/test-011-child-table.py
|
||||
|
||||
@@ -1460,7 +1460,7 @@ class OpenThreadTHCI(object):
|
||||
ModuleHelper.Default_NwkName)
|
||||
self.pskc = hex(stretchedPSKc).rstrip('L').lstrip('0x')
|
||||
self.securityPolicySecs = ModuleHelper.Default_SecurityPolicy
|
||||
self.securityPolicyFlags = 'onrcb'
|
||||
self.securityPolicyFlags = 'onrc'
|
||||
self.activetimestamp = ModuleHelper.Default_ActiveTimestamp
|
||||
# self.sedPollingRate = ModuleHelper.Default_Harness_SED_Polling_Rate
|
||||
self.__sedPollPeriod = 3 * 1000 # in milliseconds
|
||||
|
||||
@@ -648,8 +648,8 @@ class OpenThread_WpanCtl(IThci):
|
||||
print('call _setSecurityPolicy')
|
||||
try:
|
||||
cmd1 = self.wpan_cmd_prefix + 'setprop Dataset:SecPolicy:KeyRotation %s' % str(securityPolicySecs)
|
||||
if securityPolicyFlags == 'onrcb':
|
||||
cmd2 = self.wpan_cmd_prefix + 'setprop Dataset:SecPolicy:Flags 0xff'
|
||||
if securityPolicyFlags == 'onrc':
|
||||
cmd2 = self.wpan_cmd_prefix + 'setprop Dataset:SecPolicy:Flags 0xf7'
|
||||
else:
|
||||
print('unknown policy flag :' + securityPolicyFlags)
|
||||
return False
|
||||
@@ -1442,7 +1442,7 @@ class OpenThread_WpanCtl(IThci):
|
||||
# OT only accept hex format PSKc for now
|
||||
self.pskc = '00000000000000000000000000000000'
|
||||
self.securityPolicySecs = ModuleHelper.Default_SecurityPolicy
|
||||
self.securityPolicyFlags = 'onrcb'
|
||||
self.securityPolicyFlags = 'onrc'
|
||||
self.activetimestamp = ModuleHelper.Default_ActiveTimestamp
|
||||
# self.sedPollingRate = ModuleHelper.Default_Harness_SED_Polling_Rate
|
||||
self.__sedPollPeriod = 3 * 1000 # in milliseconds
|
||||
|
||||
@@ -1717,7 +1717,7 @@ class OTCI(object):
|
||||
# Network Name: OpenThread-7caa
|
||||
# PAN ID: 0x7caa
|
||||
# PSKc: 167d89fd169e439ca0b8266de248090f
|
||||
# Security Policy: 0, onrcb
|
||||
# Security Policy: 0, onrc
|
||||
|
||||
dataset = {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user