openthread/ot/types/
mac_counters.rs

1// Copyright 2022 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::prelude_internal::*;
6
7/// This structure represents the MAC layer counters.
8///
9/// Functional equivalent of [`otsys::otMacCounters`](crate::otsys::otMacCounters).
10#[derive(Debug, Default, Clone)]
11#[repr(transparent)]
12pub struct MacCounters(pub otMacCounters);
13
14impl_ot_castable!(MacCounters, otMacCounters);
15
16impl MacCounters {
17    /// The total number of unique MAC frame transmission requests.
18    pub fn tx_total(&self) -> u32 {
19        self.0.mTxTotal
20    }
21
22    /// The total number of unique unicast MAC frame transmission requests.
23    pub fn tx_unicast(&self) -> u32 {
24        self.0.mTxUnicast
25    }
26
27    /// The total number of unique broadcast MAC frame transmission requests.
28    pub fn tx_broadcast(&self) -> u32 {
29        self.0.mTxBroadcast
30    }
31
32    /// The total number of unique MAC frame transmission requests with requested acknowledgment.
33    pub fn tx_ack_requested(&self) -> u32 {
34        self.0.mTxAckRequested
35    }
36
37    /// The total number of unique MAC frame transmission requests that were acked.
38    pub fn tx_acked(&self) -> u32 {
39        self.0.mTxAcked
40    }
41
42    /// The total number of unique MAC frame transmission requests without requested acknowledgment.
43    pub fn tx_no_ack_requested(&self) -> u32 {
44        self.0.mTxNoAckRequested
45    }
46
47    /// The total number of unique MAC Data frame transmission requests.
48    pub fn tx_data(&self) -> u32 {
49        self.0.mTxData
50    }
51
52    /// The total number of unique MAC Data Poll frame transmission requests.
53    pub fn tx_data_poll(&self) -> u32 {
54        self.0.mTxDataPoll
55    }
56
57    /// The total number of unique MAC Beacon frame transmission requests.
58    pub fn tx_beacon(&self) -> u32 {
59        self.0.mTxBeacon
60    }
61
62    /// The total number of unique MAC Beacon Request frame transmission requests.
63    pub fn tx_beacon_request(&self) -> u32 {
64        self.0.mTxBeaconRequest
65    }
66
67    /// The total number of unique other MAC frame transmission requests.
68    pub fn tx_other(&self) -> u32 {
69        self.0.mTxOther
70    }
71
72    /// The total number of MAC retransmission attempts.
73    pub fn tx_retry(&self) -> u32 {
74        self.0.mTxRetry
75    }
76
77    /// The total number of unique MAC transmission packets that meet maximal retry limit for direct packets.
78    pub fn tx_direct_max_retry_expiry(&self) -> u32 {
79        self.0.mTxDirectMaxRetryExpiry
80    }
81
82    /// The total number of unique MAC transmission packets that meet maximal retry limit for indirect packets.
83    pub fn tx_indirect_max_retry_expiry(&self) -> u32 {
84        self.0.mTxIndirectMaxRetryExpiry
85    }
86
87    /// The total number of CCA failures.
88    pub fn tx_err_cca(&self) -> u32 {
89        self.0.mTxErrCca
90    }
91
92    /// The total number of unique MAC transmission request failures cause by an abort error.
93    pub fn tx_err_abort(&self) -> u32 {
94        self.0.mTxErrAbort
95    }
96
97    /// The total number of unique MAC transmission requests failures caused by a busy channel (a CSMA/CA fail).
98    pub fn tx_err_busy_channel(&self) -> u32 {
99        self.0.mTxErrBusyChannel
100    }
101
102    /// The total number of received frames.
103    pub fn rx_total(&self) -> u32 {
104        self.0.mRxTotal
105    }
106
107    /// The total number of unicast frames received.
108    pub fn rx_unicast(&self) -> u32 {
109        self.0.mRxUnicast
110    }
111
112    /// The total number of broadcast frames received.
113    pub fn rx_broadcast(&self) -> u32 {
114        self.0.mRxBroadcast
115    }
116
117    /// The total number of MAC Data frames received.
118    pub fn rx_data(&self) -> u32 {
119        self.0.mRxData
120    }
121
122    /// The total number of MAC Data Poll frames received.
123    pub fn rx_data_poll(&self) -> u32 {
124        self.0.mRxDataPoll
125    }
126
127    /// The total number of MAC Beacon frames received.
128    pub fn rx_beacon(&self) -> u32 {
129        self.0.mRxBeacon
130    }
131
132    /// The total number of MAC Beacon Request frames received.
133    pub fn rx_beacon_request(&self) -> u32 {
134        self.0.mRxBeaconRequest
135    }
136
137    /// The total number of other types of frames received.
138    pub fn rx_other(&self) -> u32 {
139        self.0.mRxOther
140    }
141
142    /// The total number of frames dropped by MAC Filter module.
143    pub fn rx_address_filtered(&self) -> u32 {
144        self.0.mRxAddressFiltered
145    }
146
147    /// The total number of frames dropped by destination address check.
148    pub fn rx_dest_addr_filtered(&self) -> u32 {
149        self.0.mRxDestAddrFiltered
150    }
151
152    /// The total number of frames dropped due to duplication.
153    pub fn rx_duplicated(&self) -> u32 {
154        self.0.mRxDuplicated
155    }
156
157    /// The total number of frames dropped because of missing or malformed content.
158    pub fn rx_err_no_frame(&self) -> u32 {
159        self.0.mRxErrNoFrame
160    }
161
162    /// The total number of frames dropped due to unknown neighbor.
163    pub fn rx_err_unknown_neighbor(&self) -> u32 {
164        self.0.mRxErrUnknownNeighbor
165    }
166
167    /// The total number of frames dropped due to invalid source address.
168    pub fn rx_err_invalid_src_addr(&self) -> u32 {
169        self.0.mRxErrInvalidSrcAddr
170    }
171
172    /// The total number of frames dropped due to security error.
173    pub fn rx_err_sec(&self) -> u32 {
174        self.0.mRxErrSec
175    }
176
177    /// The total number of frames dropped due to invalid FCS.
178    pub fn rx_err_fcs(&self) -> u32 {
179        self.0.mRxErrFcs
180    }
181
182    /// The total number of frames dropped due to other error.
183    pub fn rx_err_other(&self) -> u32 {
184        self.0.mRxErrOther
185    }
186}