1 /* 2 * Copyright (c) 2016, 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 defines the errors used in the OpenThread. 33 */ 34 35 #ifndef OPENTHREAD_ERROR_H_ 36 #define OPENTHREAD_ERROR_H_ 37 38 #include <openthread/platform/toolchain.h> 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /** 45 * @addtogroup api-error 46 * 47 * @brief 48 * This module includes error definitions used in OpenThread. 49 * 50 * @{ 51 */ 52 53 /** 54 * Represents error codes used throughout OpenThread. 55 */ 56 typedef enum OT_MUST_USE_RESULT otError 57 { 58 /** 59 * No error. 60 */ 61 OT_ERROR_NONE = 0, 62 63 /** 64 * Operational failed. 65 */ 66 OT_ERROR_FAILED = 1, 67 68 /** 69 * Message was dropped. 70 */ 71 OT_ERROR_DROP = 2, 72 73 /** 74 * Insufficient buffers. 75 */ 76 OT_ERROR_NO_BUFS = 3, 77 78 /** 79 * No route available. 80 */ 81 OT_ERROR_NO_ROUTE = 4, 82 83 /** 84 * Service is busy and could not service the operation. 85 */ 86 OT_ERROR_BUSY = 5, 87 88 /** 89 * Failed to parse message. 90 */ 91 OT_ERROR_PARSE = 6, 92 93 /** 94 * Input arguments are invalid. 95 */ 96 OT_ERROR_INVALID_ARGS = 7, 97 98 /** 99 * Security checks failed. 100 */ 101 OT_ERROR_SECURITY = 8, 102 103 /** 104 * Address resolution requires an address query operation. 105 */ 106 OT_ERROR_ADDRESS_QUERY = 9, 107 108 /** 109 * Address is not in the source match table. 110 */ 111 OT_ERROR_NO_ADDRESS = 10, 112 113 /** 114 * Operation was aborted. 115 */ 116 OT_ERROR_ABORT = 11, 117 118 /** 119 * Function or method is not implemented. 120 */ 121 OT_ERROR_NOT_IMPLEMENTED = 12, 122 123 /** 124 * Cannot complete due to invalid state. 125 */ 126 OT_ERROR_INVALID_STATE = 13, 127 128 /** 129 * No acknowledgment was received after macMaxFrameRetries (IEEE 802.15.4-2006). 130 */ 131 OT_ERROR_NO_ACK = 14, 132 133 /** 134 * A transmission could not take place due to activity on the channel, i.e., the CSMA-CA mechanism has failed 135 * (IEEE 802.15.4-2006). 136 */ 137 OT_ERROR_CHANNEL_ACCESS_FAILURE = 15, 138 139 /** 140 * Not currently attached to a Thread Partition. 141 */ 142 OT_ERROR_DETACHED = 16, 143 144 /** 145 * FCS check failure while receiving. 146 */ 147 OT_ERROR_FCS = 17, 148 149 /** 150 * No frame received. 151 */ 152 OT_ERROR_NO_FRAME_RECEIVED = 18, 153 154 /** 155 * Received a frame from an unknown neighbor. 156 */ 157 OT_ERROR_UNKNOWN_NEIGHBOR = 19, 158 159 /** 160 * Received a frame from an invalid source address. 161 */ 162 OT_ERROR_INVALID_SOURCE_ADDRESS = 20, 163 164 /** 165 * Received a frame filtered by the address filter (allowlisted or denylisted). 166 */ 167 OT_ERROR_ADDRESS_FILTERED = 21, 168 169 /** 170 * Received a frame filtered by the destination address check. 171 */ 172 OT_ERROR_DESTINATION_ADDRESS_FILTERED = 22, 173 174 /** 175 * The requested item could not be found. 176 */ 177 OT_ERROR_NOT_FOUND = 23, 178 179 /** 180 * The operation is already in progress. 181 */ 182 OT_ERROR_ALREADY = 24, 183 184 /** 185 * The creation of IPv6 address failed. 186 */ 187 OT_ERROR_IP6_ADDRESS_CREATION_FAILURE = 26, 188 189 /** 190 * Operation prevented by mode flags 191 */ 192 OT_ERROR_NOT_CAPABLE = 27, 193 194 /** 195 * Coap response or acknowledgment or DNS, SNTP response not received. 196 */ 197 OT_ERROR_RESPONSE_TIMEOUT = 28, 198 199 /** 200 * Received a duplicated frame. 201 */ 202 OT_ERROR_DUPLICATED = 29, 203 204 /** 205 * Message is being dropped from reassembly list due to timeout. 206 */ 207 OT_ERROR_REASSEMBLY_TIMEOUT = 30, 208 209 /** 210 * Message is not a TMF Message. 211 */ 212 OT_ERROR_NOT_TMF = 31, 213 214 /** 215 * Received a non-lowpan data frame. 216 */ 217 OT_ERROR_NOT_LOWPAN_DATA_FRAME = 32, 218 219 /** 220 * The link margin was too low. 221 */ 222 OT_ERROR_LINK_MARGIN_LOW = 34, 223 224 /** 225 * Input (CLI) command is invalid. 226 */ 227 OT_ERROR_INVALID_COMMAND = 35, 228 229 /** 230 * Special error code used to indicate success/error status is pending and not yet known. 231 */ 232 OT_ERROR_PENDING = 36, 233 234 /** 235 * Request rejected. 236 */ 237 OT_ERROR_REJECTED = 37, 238 239 /** 240 * The number of defined errors. 241 */ 242 OT_NUM_ERRORS, 243 244 /** 245 * Generic error (should not use). 246 */ 247 OT_ERROR_GENERIC = 255, 248 } otError; 249 250 /** 251 * Converts an otError enum into a string. 252 * 253 * @param[in] aError An otError enum. 254 * 255 * @returns A string representation of an otError. 256 */ 257 const char *otThreadErrorToString(otError aError); 258 259 /** 260 * @} 261 */ 262 263 #ifdef __cplusplus 264 } // extern "C" 265 #endif 266 267 #endif // OPENTHREAD_ERROR_H_ 268