xref: /aosp_15_r20/external/ot-br-posix/src/dbus/common/error.hpp (revision 4a64e381480ef79f0532b2421e44e6ee336b8e0d)
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  * This file includes definitions for d-bus client errors.
32  */
33 
34 #ifndef OTBR_DBUS_COMMON_ERROR_HPP_
35 #define OTBR_DBUS_COMMON_ERROR_HPP_
36 
37 #include "openthread-br/config.h"
38 
39 #include <string>
40 
41 #include <dbus/dbus.h>
42 
43 namespace otbr {
44 
45 /**
46  * @namespace otbr::DBus
47  *
48  * @brief This namespace contains OpenThread Border Router DBus API.
49  */
50 namespace DBus {
51 
52 enum class ClientError
53 {
54     ERROR_NONE = 0, ///< No error.
55 
56     ERROR_ERRNO = -1, ///< Error defined by errno.
57     ERROR_DBUS  = -3, ///< DBus error.
58 
59     /**
60      * Operational failed.
61      */
62     OT_ERROR_FAILED = 1,
63 
64     /**
65      * Message was dropped.
66      */
67     OT_ERROR_DROP = 2,
68 
69     /**
70      * Insufficient buffers.
71      */
72     OT_ERROR_NO_BUFS = 3,
73 
74     /**
75      * No route available.
76      */
77     OT_ERROR_NO_ROUTE = 4,
78 
79     /**
80      * Service is busy and could not service the operation.
81      */
82     OT_ERROR_BUSY = 5,
83 
84     /**
85      * Failed to parse message or arguments.
86      */
87     OT_ERROR_PARSE = 6,
88 
89     /**
90      * Input arguments are invalid.
91      */
92     OT_ERROR_INVALID_ARGS = 7,
93 
94     /**
95      * Security checks failed.
96      */
97     OT_ERROR_SECURITY = 8,
98 
99     /**
100      * Address resolution requires an address query operation.
101      */
102     OT_ERROR_ADDRESS_QUERY = 9,
103 
104     /**
105      * Address is not in the source match table.
106      */
107     OT_ERROR_NO_ADDRESS = 10,
108 
109     /**
110      * Operation was aborted.
111      */
112     OT_ERROR_ABORT = 11,
113 
114     /**
115      * Function or method is not implemented.
116      */
117     OT_ERROR_NOT_IMPLEMENTED = 12,
118 
119     /**
120      * Cannot complete due to invalid state.
121      */
122     OT_ERROR_INVALID_STATE = 13,
123 
124     /**
125      * No acknowledgment was received after macMaxFrameRetries (IEEE 802.15.4-2006).
126      */
127     OT_ERROR_NO_ACK = 14,
128 
129     /**
130      * A transmission could not take place due to activity on the channel, i.e., the CSMA-CA mechanism has failed
131      * (IEEE 802.15.4-2006).
132      */
133     OT_ERROR_CHANNEL_ACCESS_FAILURE = 15,
134 
135     /**
136      * Not currently attached to a Thread Partition.
137      */
138     OT_ERROR_DETACHED = 16,
139 
140     /**
141      * FCS check failure while receiving.
142      */
143     OT_ERROR_FCS = 17,
144 
145     /**
146      * No frame received.
147      */
148     OT_ERROR_NO_FRAME_RECEIVED = 18,
149 
150     /**
151      * Received a frame from an unknown neighbor.
152      */
153     OT_ERROR_UNKNOWN_NEIGHBOR = 19,
154 
155     /**
156      * Received a frame from an invalid source address.
157      */
158     OT_ERROR_INVALID_SOURCE_ADDRESS = 20,
159 
160     /**
161      * Received a frame filtered by the address filter (allowlisted or denylisted).
162      */
163     OT_ERROR_ADDRESS_FILTERED = 21,
164 
165     /**
166      * Received a frame filtered by the destination address check.
167      */
168     OT_ERROR_DESTINATION_ADDRESS_FILTERED = 22,
169 
170     /**
171      * The requested item could not be found.
172      */
173     OT_ERROR_NOT_FOUND = 23,
174 
175     /**
176      * The operation is already in progress.
177      */
178     OT_ERROR_ALREADY = 24,
179 
180     /**
181      * The creation of IPv6 address failed.
182      */
183     OT_ERROR_IP6_ADDRESS_CREATION_FAILURE = 26,
184 
185     /**
186      * Operation prevented by mode flags
187      */
188     OT_ERROR_NOT_CAPABLE = 27,
189 
190     /**
191      * Coap response or acknowledgment or DNS, SNTP response not received.
192      */
193     OT_ERROR_RESPONSE_TIMEOUT = 28,
194 
195     /**
196      * Received a duplicated frame.
197      */
198     OT_ERROR_DUPLICATED = 29,
199 
200     /**
201      * Message is being dropped from reassembly list due to timeout.
202      */
203     OT_ERROR_REASSEMBLY_TIMEOUT = 30,
204 
205     /**
206      * Message is not a TMF Message.
207      */
208     OT_ERROR_NOT_TMF = 31,
209 
210     /**
211      * Received a non-lowpan data frame.
212      */
213     OT_ERROR_NOT_LOWPAN_DATA_FRAME = 32,
214 
215     /**
216      * The link margin was too low.
217      */
218     OT_ERROR_LINK_MARGIN_LOW = 34,
219 
220     /**
221      * Request rejected.
222      */
223     OT_ERROR_REJECTED = 37,
224 
225     /**
226      * Generic error (should not use).
227      */
228     OT_ERROR_GENERIC = 255,
229 };
230 
231 bool operator==(ClientError aError, int aValue);
232 bool operator!=(ClientError aError, int aValue);
233 
234 } // namespace DBus
235 } // namespace otbr
236 
237 #endif // OTBR_DBUS_COMMON_ERROR_HPP_
238