1 /* 2 * Copyright (c) 2020, The OpenThread Authors. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 3. Neither the name of the copyright holder nor the 13 * names of its contributors may be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** 30 * @file 31 * @brief 32 * This file includes the OpenThread API for Dataset Updater module. 33 */ 34 35 #ifndef OPENTHREAD_DATASET_UPDATER_H_ 36 #define OPENTHREAD_DATASET_UPDATER_H_ 37 38 #include <openthread/dataset.h> 39 #include <openthread/instance.h> 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 /** 46 * @addtogroup api-operational-dataset 47 * 48 * @brief 49 * This module includes functions for Dataset Updater. 50 * 51 * The functions in this module are available when Dataset Updater feature is enabled (i.e. 52 * `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE` is set to 1). Further this feature is available only on an FTD build. 53 * 54 * @{ 55 * 56 */ 57 58 /** 59 * This callback function pointer is called when a Dataset update request finishes, reporting success or failure status 60 * of the Dataset update request. 61 * 62 * @param[in] aError The error status. 63 * OT_ERROR_NONE indicates successful Dataset update. 64 * OT_ERROR_INVALID_STATE indicates failure due invalid state (MLE being disabled). 65 * OT_ERROR_ALREADY indicates failure due to another device within network requesting 66 * a conflicting Dataset update. 67 * 68 * @param[in] aContext A pointer to the arbitrary context (provided by user in `otDatasetUpdaterRequestUpdate()`). 69 * 70 */ 71 typedef void (*otDatasetUpdaterCallback)(otError aError, void *aContext); 72 73 /** 74 * This function requests an update to Operational Dataset. 75 * 76 * @p aDataset should contain the fields to be updated and their new value. It must not contain Active or Pending 77 * Timestamp fields. The Delay field is optional, if not provided a default value (1000 ms) would be used. 78 * 79 * @param[in] aInstance A pointer to an OpenThread instance. 80 * @param[in] aDataset A pointer to the Dataset containing the fields to change. 81 * @param[in] aCallback A callback to indicate when Dataset update request finishes. 82 * @param[in] aContext An arbitrary context passed to callback. 83 * 84 * @retval OT_ERROR_NONE Dataset update started successfully (@p aCallback will be invoked on completion). 85 * @retval OT_ERROR_INVALID_STATE Device is disabled (MLE is disabled). 86 * @retval OT_ERROR_INVALID_ARGS The @p aDataset is not valid (contains Active or Pending Timestamp). 87 * @retval OT_ERROR_BUSY Cannot start update, a previous one is ongoing. 88 * @retval OT_ERROR_NO_BUFS Could not allocated buffer to save Dataset. 89 * 90 */ 91 otError otDatasetUpdaterRequestUpdate(otInstance * aInstance, 92 const otOperationalDataset *aDataset, 93 otDatasetUpdaterCallback aCallback, 94 void * aContext); 95 96 /** 97 * This function cancels an ongoing (if any) Operational Dataset update request. 98 * 99 * @param[in] aInstance A pointer to an OpenThread instance. 100 * 101 */ 102 void otDatasetUpdaterCancelUpdate(otInstance *aInstance); 103 104 /** 105 * This function indicates whether there is an ongoing Operation Dataset update request. 106 * 107 * @param[in] aInstance A pointer to an OpenThread instance. 108 * 109 * @retval TRUE There is an ongoing update. 110 * @retval FALSE There is no ongoing update. 111 * 112 */ 113 bool otDatasetUpdaterIsUpdateOngoing(otInstance *aInstance); 114 115 /** 116 * @} 117 * 118 */ 119 120 #ifdef __cplusplus 121 } // extern "C" 122 #endif 123 124 #endif // OPENTHREAD_DATASET_UPDATER_H_ 125