@@ -50,35 +50,37 @@ extern "C" {
5050 *
5151 */
5252
53- #define OT_MASTER_KEY_SIZE 16 ///< Size of the Thread Master Key (bytes)
53+ #define OT_NETWORK_KEY_SIZE 16 ///< Size of the Thread Network Key (bytes)
5454
5555/**
56- * @struct otMasterKey
56+ * @struct otNetworkKey
5757 *
58- * This structure represents a Thread Master Key.
58+ * This structure represents a Thread Network Key.
5959 *
6060 */
6161OT_TOOL_PACKED_BEGIN
62- struct otMasterKey
62+ struct otNetworkKey
6363{
64- uint8_t m8 [OT_MASTER_KEY_SIZE ]; ///< Byte values
64+ uint8_t m8 [OT_NETWORK_KEY_SIZE ]; ///< Byte values
6565} OT_TOOL_PACKED_END ;
6666
6767/**
68- * This structure represents a Thread Master Key.
68+ * This structure represents a Thread Network Key.
6969 *
7070 */
71- typedef struct otMasterKey otMasterKey ;
71+ typedef struct otNetworkKey otNetworkKey ;
7272
7373#define OT_NETWORK_NAME_MAX_SIZE 16 ///< Maximum size of the Thread Network Name field (bytes)
7474
7575/**
7676 * This structure represents a Network Name.
7777 *
78+ * The `otNetworkName` is a null terminated C string (i.e., `m8` char array MUST end with null char `\0`).
79+ *
7880 */
7981typedef struct otNetworkName
8082{
81- char m8 [OT_NETWORK_NAME_MAX_SIZE + 1 ]; ///< Byte values
83+ char m8 [OT_NETWORK_NAME_MAX_SIZE + 1 ]; ///< Byte values. The `+ 1` is for null char.
8284} otNetworkName ;
8385
8486#define OT_EXT_PAN_ID_SIZE 8 ///< Size of a Thread PAN ID (bytes)
@@ -133,14 +135,14 @@ typedef struct otSecurityPolicy
133135{
134136 uint16_t mRotationTime ; ///< The value for thrKeyRotation in units of hours.
135137
136- bool mObtainMasterKeyEnabled : 1 ; ///< Obtaining the Master Key for out-of-band commissioning is enabled
138+ bool mObtainNetworkKeyEnabled : 1 ; ///< Obtaining the Network Key for out-of-band commissioning is enabled
137139 bool mNativeCommissioningEnabled : 1 ; ///< Native Commissioning using PSKc is allowed
138140 bool mRoutersEnabled : 1 ; ///< Thread 1.0/1.1.x Routers are enabled
139141 bool mExternalCommissioningEnabled : 1 ; ///< External Commissioner authentication is allowed
140142 bool mBeaconsEnabled : 1 ; ///< Thread 1.0/1.1.x Beacons are enabled
141143 bool mCommercialCommissioningEnabled : 1 ; ///< Commercial Commissioning is enabled
142144 bool mAutonomousEnrollmentEnabled : 1 ; ///< Autonomous Enrollment is enabled
143- bool mMasterKeyProvisioningEnabled : 1 ; ///< Network Master-key Provisioning is enabled
145+ bool mNetworkKeyProvisioningEnabled : 1 ; ///< Network Key Provisioning is enabled
144146 bool mTobleLinkEnabled : 1 ; ///< ToBLE link is enabled
145147 bool mNonCcmRoutersEnabled : 1 ; ///< Non-CCM Routers enabled
146148 uint8_t mVersionThresholdForRouting : 3 ; ///< Version-threshold for Routing
@@ -187,7 +189,7 @@ typedef struct otOperationalDatasetComponents
187189{
188190 bool mIsActiveTimestampPresent : 1 ; ///< TRUE if Active Timestamp is present, FALSE otherwise.
189191 bool mIsPendingTimestampPresent : 1 ; ///< TRUE if Pending Timestamp is present, FALSE otherwise.
190- bool mIsMasterKeyPresent : 1 ; ///< TRUE if Network Master Key is present, FALSE otherwise.
192+ bool mIsNetworkKeyPresent : 1 ; ///< TRUE if Network Key is present, FALSE otherwise.
191193 bool mIsNetworkNamePresent : 1 ; ///< TRUE if Network Name is present, FALSE otherwise.
192194 bool mIsExtendedPanIdPresent : 1 ; ///< TRUE if Extended PAN ID is present, FALSE otherwise.
193195 bool mIsMeshLocalPrefixPresent : 1 ; ///< TRUE if Mesh Local Prefix is present, FALSE otherwise.
@@ -209,7 +211,7 @@ typedef struct otOperationalDataset
209211{
210212 uint64_t mActiveTimestamp ; ///< Active Timestamp
211213 uint64_t mPendingTimestamp ; ///< Pending Timestamp
212- otMasterKey mMasterKey ; ///< Network Master Key
214+ otNetworkKey mNetworkKey ; ///< Network Key
213215 otNetworkName mNetworkName ; ///< Network Name
214216 otExtendedPanId mExtendedPanId ; ///< Extended PAN ID
215217 otMeshLocalPrefix mMeshLocalPrefix ; ///< Mesh Local Prefix
@@ -251,7 +253,7 @@ typedef enum otMeshcopTlvType
251253 OT_MESHCOP_TLV_EXTPANID = 2 , ///< meshcop Extended Pan Id TLV
252254 OT_MESHCOP_TLV_NETWORKNAME = 3 , ///< meshcop Network Name TLV
253255 OT_MESHCOP_TLV_PSKC = 4 , ///< meshcop PSKc TLV
254- OT_MESHCOP_TLV_MASTERKEY = 5 , ///< meshcop Network Master Key TLV
256+ OT_MESHCOP_TLV_NETWORKKEY = 5 , ///< meshcop Network Key TLV
255257 OT_MESHCOP_TLV_NETWORK_KEY_SEQUENCE = 6 , ///< meshcop Network Key Sequence TLV
256258 OT_MESHCOP_TLV_MESHLOCALPREFIX = 7 , ///< meshcop Mesh Local Prefix TLV
257259 OT_MESHCOP_TLV_STEERING_DATA = 8 , ///< meshcop Steering Data TLV
@@ -288,6 +290,21 @@ typedef enum otMeshcopTlvType
288290 OT_MESHCOP_TLV_JOINERADVERTISEMENT = 241 , ///< meshcop Joiner Advertisement TLV
289291} otMeshcopTlvType ;
290292
293+ /**
294+ * This function pointer is called when a response to a MGMT_SET request is received or times out.
295+ *
296+ * @param[in] aResult A result of the operation.
297+ * @param[in] aContext A pointer to application-specific context.
298+ *
299+ * @retval OT_ERROR_NONE The request was accepted by the leader.
300+ * @retval OT_ERROR_REJECTED The request was rejected by the leader.
301+ * @retval OT_ERROR_PARSE An error occurred during parsing the response.
302+ * @retval OT_ERROR_ABORT The request was reset by peer.
303+ * @retval OT_ERROR_RESPONSE_TIMEOUT No response or acknowledgment received during timeout period.
304+ *
305+ */
306+ typedef void (* otDatasetMgmtSetCallback )(otError aResult , void * aContext );
307+
291308/**
292309 * This function indicates whether a valid network is present in the Active Operational Dataset or not.
293310 *
@@ -328,7 +345,7 @@ otError otDatasetGetActiveTlvs(otInstance *aInstance, otOperationalDatasetTlvs *
328345 * If the dataset does not include an Active Timestamp, the dataset is only partially complete.
329346 *
330347 * If Thread is enabled on a device that has a partially complete Active Dataset, the device will attempt to attach to
331- * an existing Thread network using any existing information in the dataset. Only the Thread Master Key is needed to
348+ * an existing Thread network using any existing information in the dataset. Only the Thread Network Key is needed to
332349 * attach to a network.
333350 *
334351 * If channel is not included in the dataset, the device will send MLE Announce messages across different channels to
@@ -354,7 +371,7 @@ otError otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aD
354371 * If the dataset does not include an Active Timestamp, the dataset is only partially complete.
355372 *
356373 * If Thread is enabled on a device that has a partially complete Active Dataset, the device will attempt to attach to
357- * an existing Thread network using any existing information in the dataset. Only the Thread Master Key is needed to
374+ * an existing Thread network using any existing information in the dataset. Only the Thread Network Key is needed to
358375 * attach to a network.
359376 *
360377 * If channel is not included in the dataset, the device will send MLE Announce messages across different channels to
@@ -450,15 +467,20 @@ otError otDatasetSendMgmtActiveGet(otInstance * aInstan
450467 * @param[in] aDataset A pointer to operational dataset.
451468 * @param[in] aTlvs A pointer to TLVs.
452469 * @param[in] aLength The length of TLVs.
470+ * @param[in] aCallback A pointer to a function that is called on response reception or timeout.
471+ * @param[in] aContext A pointer to application-specific context for @p aCallback.
453472 *
454473 * @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
455474 * @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
475+ * @retval OT_ERROR_BUSY A previous request is ongoing.
456476 *
457477 */
458478otError otDatasetSendMgmtActiveSet (otInstance * aInstance ,
459479 const otOperationalDataset * aDataset ,
460480 const uint8_t * aTlvs ,
461- uint8_t aLength );
481+ uint8_t aLength ,
482+ otDatasetMgmtSetCallback aCallback ,
483+ void * aContext );
462484
463485/**
464486 * This function sends MGMT_PENDING_GET.
@@ -486,15 +508,20 @@ otError otDatasetSendMgmtPendingGet(otInstance * aInsta
486508 * @param[in] aDataset A pointer to operational dataset.
487509 * @param[in] aTlvs A pointer to TLVs.
488510 * @param[in] aLength The length of TLVs.
511+ * @param[in] aCallback A pointer to a function that is called on response reception or timeout.
512+ * @param[in] aContext A pointer to application-specific context for @p aCallback.
489513 *
490514 * @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
491515 * @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
516+ * @retval OT_ERROR_BUSY A previous request is ongoing.
492517 *
493518 */
494519otError otDatasetSendMgmtPendingSet (otInstance * aInstance ,
495520 const otOperationalDataset * aDataset ,
496521 const uint8_t * aTlvs ,
497- uint8_t aLength );
522+ uint8_t aLength ,
523+ otDatasetMgmtSetCallback aCallback ,
524+ void * aContext );
498525
499526/**
500527 * This function generates PSKc from a given pass-phrase, network name, and extended PAN ID.
@@ -515,6 +542,33 @@ otError otDatasetGeneratePskc(const char * aPassPhrase,
515542 const otExtendedPanId * aExtPanId ,
516543 otPskc * aPskc );
517544
545+ /**
546+ * This function sets an `otNetworkName` instance from a given null terminated C string.
547+ *
548+ * This function also validates that the given @p aNameString follows UTF-8 encoding and its length is not longer than
549+ * `OT_NETWORK_NAME_MAX_SIZE`.
550+ *
551+ * @param[out] aNetworkName A pointer to the `otNetworkName` to set.
552+ * @param[in] aNameString A name C string.
553+ *
554+ * @retval OT_ERROR_NONE Successfully set @p aNetworkName from @p aNameString.
555+ * @retval OT_ERROR_INVALID_ARGS @p aNameStrng is invalid (too long or does not follow UTF-8 encoding).
556+ *
557+ */
558+ otError otNetworkNameFromString (otNetworkName * aNetworkName , const char * aNameString );
559+
560+ /**
561+ * This function parses an Operational Dataset from a `otOperationalDatasetTlvs`.
562+ *
563+ * @param[in] aDatasetTlvs A pointer to dataset TLVs.
564+ * @param[out] aDataset A pointer to where the dataset will be placed.
565+ *
566+ * @retval OT_ERROR_NONE Successfully set @p aDataset from @p aDatasetTlvs.
567+ * @retval OT_ERROR_INVALID_ARGS @p aDatasetTlvs is invalid.
568+ *
569+ */
570+ otError otDatasetParseTlvs (const otOperationalDatasetTlvs * aDatasetTlvs , otOperationalDataset * aDataset );
571+
518572/**
519573 * @}
520574 *
0 commit comments