Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / ot-br-posix / repo / src / dbus / common / types.hpp
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 types used by d-bus API.
32  */
33
34 #ifndef OTBR_DBUS_COMMON_TYPES_HPP_
35 #define OTBR_DBUS_COMMON_TYPES_HPP_
36
37 #include "dbus/common/error.hpp"
38
39 #include <stdint.h>
40
41 #include <string>
42 #include <vector>
43
44 namespace otbr {
45 namespace DBus {
46
47 enum DeviceRole
48 {
49     OTBR_DEVICE_ROLE_DISABLED = 0,
50     OTBR_DEVICE_ROLE_DETACHED = 1,
51     OTBR_DEVICE_ROLE_CHILD    = 2,
52     OTBR_DEVICE_ROLE_ROUTER   = 3,
53     OTBR_DEVICE_ROLE_LEADER   = 4,
54 };
55
56 struct ActiveScanResult
57 {
58     uint64_t             mExtAddress;    ///< IEEE 802.15.4 Extended Address
59     std::string          mNetworkName;   ///< Thread Network Name
60     uint64_t             mExtendedPanId; ///< Thread Extended PAN ID
61     std::vector<uint8_t> mSteeringData;  ///< Steering Data
62     uint16_t             mPanId;         ///< IEEE 802.15.4 PAN ID
63     uint16_t             mJoinerUdpPort; ///< Joiner UDP Port
64     uint8_t              mChannel;       ///< IEEE 802.15.4 Channel
65     int8_t               mRssi;          ///< RSSI (dBm)
66     uint8_t              mLqi;           ///< LQI
67     uint8_t              mVersion;       ///< Version
68     bool                 mIsNative;      ///< Native Commissioner flag
69     bool                 mIsJoinable;    ///< Joining Permitted flag
70 };
71
72 struct LinkModeConfig
73 {
74     bool mRxOnWhenIdle; ///< 1, if the sender has its receiver on when not transmitting. 0, otherwise.
75     bool mDeviceType;   ///< 1, if the sender is an FTD. 0, otherwise.
76     bool mNetworkData;  ///< 1, if the sender requires the full Network Data. 0, otherwise.
77 };
78
79 struct Ip6Prefix
80 {
81     std::vector<uint8_t> mPrefix; ///< The IPv6 prefix.
82
83     uint8_t mLength; ///< The IPv6 prefix length.
84 };
85
86 struct OnMeshPrefix
87 {
88     /**
89      * The IPv6 prefix.
90      */
91     Ip6Prefix mPrefix;
92
93     /**
94      * A 2-bit signed integer indicating router preference as defined in RFC 4191.
95      */
96     int8_t mPreference;
97
98     /**
99      * TRUE, if @p mPrefix is preferred.  FALSE, otherwise.
100      */
101     bool mPreferred;
102
103     /**
104      * TRUE, if @p mPrefix should be used for address autoconfiguration.  FALSE, otherwise.
105      */
106     bool mSlaac;
107
108     /**
109      * TRUE, if this border router is a DHCPv6 Agent that supplies IPv6 address configuration.  FALSE, otherwise.
110      */
111     bool mDhcp;
112
113     /**
114      * TRUE, if this border router is a DHCPv6 Agent that supplies other configuration data.  FALSE, otherwise.
115      */
116     bool mConfigure;
117
118     /**
119      * TRUE, if this border router is a default route for @p mPrefix.  FALSE, otherwise.
120      */
121     bool mDefaultRoute;
122
123     /**
124      * TRUE, if this prefix is considered on-mesh.  FALSE, otherwise.
125      */
126     bool mOnMesh;
127
128     /**
129      * TRUE, if this configuration is considered Stable Network Data.  FALSE, otherwise.
130      */
131     bool mStable;
132 };
133
134 struct ExternalRoute
135 {
136     /**
137      * The IPv6 prefix.
138      */
139     Ip6Prefix mPrefix;
140
141     /**
142      * The Rloc associated with the external route entry.
143      *
144      * This value is ignored when adding an external route. For any added route, the device's Rloc is used.
145      */
146     uint16_t mRloc16;
147
148     /**
149      * A 2-bit signed integer indicating router preference as defined in RFC 4191.
150      */
151     int8_t mPreference;
152
153     /**
154      * TRUE, if this configuration is considered Stable Network Data.  FALSE, otherwise.
155      */
156     bool mStable;
157
158     /**
159      * TRUE if the external route entry's next hop is this device itself (i.e., the route was added earlier by this
160      * device). FALSE otherwise.
161      *
162      * This value is ignored when adding an external route. For any added route the next hop is this device.
163      */
164     bool mNextHopIsThisDevice;
165 };
166
167 /**
168  * This structure represents the MAC layer counters.
169  *
170  */
171 struct MacCounters
172 {
173     /**
174      * The total number of unique MAC frame transmission requests.
175      *
176      * Note that this counter is incremented for each MAC transmission request only by one,
177      * regardless of the amount of CCA failures, CSMA-CA attempts, or retransmissions.
178      *
179      * This incrementation rule applies to the following counters:
180      *   @p mTxUnicast
181      *   @p mTxBroadcast
182      *   @p mTxAckRequested
183      *   @p mTxNoAckRequested
184      *   @p mTxData
185      *   @p mTxDataPoll
186      *   @p mTxBeacon
187      *   @p mTxBeaconRequest
188      *   @p mTxOther
189      *   @p mTxErrAbort
190      *   @p mTxErrBusyChannel
191      *
192      * The following equations are valid:
193      *     @p mTxTotal = @p mTxUnicast + @p mTxBroadcast
194      *     @p mTxTotal = @p mTxAckRequested + @p mTxNoAckRequested
195      *     @p mTxTotal = @p mTxData + @p mTxDataPoll + @p mTxBeacon + @p mTxBeaconRequest + @p mTxOther
196      *
197      */
198     uint32_t mTxTotal;
199
200     /**
201      * The total number of unique unicast MAC frame transmission requests.
202      *
203      */
204     uint32_t mTxUnicast;
205
206     /**
207      * The total number of unique broadcast MAC frame transmission requests.
208      *
209      */
210     uint32_t mTxBroadcast;
211
212     /**
213      * The total number of unique MAC frame transmission requests with requested acknowledgment.
214      *
215      */
216     uint32_t mTxAckRequested;
217
218     /**
219      * The total number of unique MAC frame transmission requests that were acked.
220      *
221      */
222     uint32_t mTxAcked;
223
224     /**
225      * The total number of unique MAC frame transmission requests without requested acknowledgment.
226      *
227      */
228     uint32_t mTxNoAckRequested;
229
230     /**
231      * The total number of unique MAC Data frame transmission requests.
232      *
233      */
234     uint32_t mTxData;
235
236     /**
237      * The total number of unique MAC Data Poll frame transmission requests.
238      *
239      */
240     uint32_t mTxDataPoll;
241
242     /**
243      * The total number of unique MAC Beacon frame transmission requests.
244      *
245      */
246     uint32_t mTxBeacon;
247
248     /**
249      * The total number of unique MAC Beacon Request frame transmission requests.
250      *
251      */
252     uint32_t mTxBeaconRequest;
253
254     /**
255      * The total number of unique other MAC frame transmission requests.
256      *
257      * This counter is currently unused.
258      *
259      */
260     uint32_t mTxOther;
261
262     /**
263      * The total number of MAC retransmission attempts.
264      *
265      * Note that this counter is incremented by one for each retransmission attempt that may be
266      * triggered by lack of acknowledgement, CSMA/CA failure, or other type of transmission error.
267      * The @p mTxRetry counter is incremented both for unicast and broadcast MAC frames.
268      *
269      * Check the following configuration parameters to control the amount of retransmissions in the system:
270      *   @sa OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_DIRECT
271      *   @sa OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT
272      *   @sa OPENTHREAD_CONFIG_MAC_TX_NUM_BCAST
273      *   @sa OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT
274      *   @sa OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_INDIRECT
275      *
276      * Currently, this counter is invalid if the platform's radio driver capability includes
277      * @sa OT_RADIO_CAPS_TRANSMIT_RETRIES.
278      *
279      */
280     uint32_t mTxRetry;
281
282     /**
283      * The total number of unique MAC transmission packets that meet maximal retry limit for direct packets.
284      *
285      */
286     uint32_t mTxDirectMaxRetryExpiry;
287
288     /**
289      * The total number of unique MAC transmission packets that meet maximal retry limit for indirect packets.
290      *
291      */
292     uint32_t mTxIndirectMaxRetryExpiry;
293
294     /**
295      * The total number of CCA failures.
296      *
297      * The meaning of this counter can be different and it depends on the platform's radio driver capabilities.
298      *
299      * If @sa OT_RADIO_CAPS_CSMA_BACKOFF is enabled, this counter represents the total number of full CSMA/CA
300      * failed attempts and it is incremented by one also for each retransmission (in case of a CSMA/CA fail).
301      *
302      * If @sa OT_RADIO_CAPS_TRANSMIT_RETRIES is enabled, this counter represents the total number of full CSMA/CA
303      * failed attempts and it is incremented by one for each individual data frame request (regardless of the amount of
304      * retransmissions).
305      *
306      */
307     uint32_t mTxErrCca;
308
309     /**
310      * The total number of unique MAC transmission request failures cause by an abort error.
311      *
312      */
313     uint32_t mTxErrAbort;
314
315     /**
316      * The total number of unique MAC transmission requests failures caused by a busy channel (a CSMA/CA fail).
317      *
318      */
319     uint32_t mTxErrBusyChannel;
320
321     /**
322      * The total number of received frames.
323      *
324      * This counter counts all frames reported by the platform's radio driver, including frames
325      * that were dropped, for example because of an FCS error.
326      *
327      */
328     uint32_t mRxTotal;
329
330     /**
331      * The total number of unicast frames received.
332      *
333      */
334     uint32_t mRxUnicast;
335
336     /**
337      * The total number of broadcast frames received.
338      *
339      */
340     uint32_t mRxBroadcast;
341
342     /**
343      * The total number of MAC Data frames received.
344      *
345      */
346     uint32_t mRxData;
347
348     /**
349      * The total number of MAC Data Poll frames received.
350      *
351      */
352     uint32_t mRxDataPoll;
353
354     /**
355      * The total number of MAC Beacon frames received.
356      *
357      */
358     uint32_t mRxBeacon;
359
360     /**
361      * The total number of MAC Beacon Request frames received.
362      *
363      */
364     uint32_t mRxBeaconRequest;
365
366     /**
367      * The total number of other types of frames received.
368      *
369      */
370     uint32_t mRxOther;
371
372     /**
373      * The total number of frames dropped by MAC Filter module, for example received from denylisted node.
374      *
375      */
376     uint32_t mRxAddressFiltered;
377
378     /**
379      * The total number of frames dropped by destination address check, for example received frame for other node.
380      *
381      */
382     uint32_t mRxDestAddrFiltered;
383
384     /**
385      * The total number of frames dropped due to duplication, that is when the frame has been already received.
386      *
387      * This counter may be incremented, for example when ACK frame generated by the receiver hasn't reached
388      * transmitter node which performed retransmission.
389      *
390      */
391     uint32_t mRxDuplicated;
392
393     /**
394      * The total number of frames dropped because of missing or malformed content.
395      *
396      */
397     uint32_t mRxErrNoFrame;
398
399     /**
400      * The total number of frames dropped due to unknown neighbor.
401      *
402      */
403     uint32_t mRxErrUnknownNeighbor;
404
405     /**
406      * The total number of frames dropped due to invalid source address.
407      *
408      */
409     uint32_t mRxErrInvalidSrcAddr;
410
411     /**
412      * The total number of frames dropped due to security error.
413      *
414      * This counter may be incremented, for example when lower than expected Frame Counter is used
415      * to encrypt the frame.
416      *
417      */
418     uint32_t mRxErrSec;
419
420     /**
421      * The total number of frames dropped due to invalid FCS.
422      *
423      */
424     uint32_t mRxErrFcs;
425
426     /**
427      * The total number of frames dropped due to other error.
428      *
429      */
430     uint32_t mRxErrOther;
431 };
432
433 struct IpCounters
434 {
435     uint32_t mTxSuccess; ///< The number of IPv6 packets successfully transmitted.
436     uint32_t mRxSuccess; ///< The number of IPv6 packets successfully received.
437     uint32_t mTxFailure; ///< The number of IPv6 packets failed to transmit.
438     uint32_t mRxFailure; ///< The number of IPv6 packets failed to receive.
439 };
440
441 struct ChannelQuality
442 {
443     uint8_t  mChannel;
444     uint16_t mOccupancy;
445 };
446
447 struct ChildInfo
448 {
449     uint64_t mExtAddress;         ///< IEEE 802.15.4 Extended Address
450     uint32_t mTimeout;            ///< Timeout
451     uint32_t mAge;                ///< Time last heard
452     uint16_t mRloc16;             ///< RLOC16
453     uint16_t mChildId;            ///< Child ID
454     uint8_t  mNetworkDataVersion; ///< Network Data Version
455     uint8_t  mLinkQualityIn;      ///< Link Quality In
456     int8_t   mAverageRssi;        ///< Average RSSI
457     int8_t   mLastRssi;           ///< Last observed RSSI
458     uint16_t mFrameErrorRate;     ///< Frame error rate (0xffff->100%). Requires error tracking feature.
459     uint16_t mMessageErrorRate;   ///< (IPv6) msg error rate (0xffff->100%). Requires error tracking feature.
460     bool     mRxOnWhenIdle;       ///< rx-on-when-idle
461     bool     mFullThreadDevice;   ///< Full Thread Device
462     bool     mFullNetworkData;    ///< Full Network Data
463     bool     mIsStateRestoring;   ///< Is in restoring state
464 };
465
466 struct NeighborInfo
467 {
468     uint64_t mExtAddress;       ///< IEEE 802.15.4 Extended Address
469     uint32_t mAge;              ///< Time last heard
470     uint16_t mRloc16;           ///< RLOC16
471     uint32_t mLinkFrameCounter; ///< Link Frame Counter
472     uint32_t mMleFrameCounter;  ///< MLE Frame Counter
473     uint8_t  mLinkQualityIn;    ///< Link Quality In
474     int8_t   mAverageRssi;      ///< Average RSSI
475     int8_t   mLastRssi;         ///< Last observed RSSI
476     uint16_t mFrameErrorRate;   ///< Frame error rate (0xffff->100%). Requires error tracking feature.
477     uint16_t mMessageErrorRate; ///< (IPv6) msg error rate (0xffff->100%). Requires error tracking feature.
478     bool     mRxOnWhenIdle;     ///< rx-on-when-idle
479     bool     mFullThreadDevice; ///< Full Thread Device
480     bool     mFullNetworkData;  ///< Full Network Data
481     bool     mIsChild;          ///< Is the neighbor a child
482 };
483
484 struct LeaderData
485 {
486     uint32_t mPartitionId;       ///< Partition ID
487     uint8_t  mWeighting;         ///< Leader Weight
488     uint8_t  mDataVersion;       ///< Full Network Data Version
489     uint8_t  mStableDataVersion; ///< Stable Network Data Version
490     uint8_t  mLeaderRouterId;    ///< Leader Router ID
491 };
492
493 } // namespace DBus
494 } // namespace otbr
495
496 #endif // OTBR_DBUS_COMMON_TYPES_HPP_