openthread/ot/types/
mac_counters.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

use crate::prelude_internal::*;

/// This structure represents the MAC layer counters.
///
/// Functional equivalent of [`otsys::otMacCounters`](crate::otsys::otMacCounters).
#[derive(Debug, Default, Clone)]
#[repr(transparent)]
pub struct MacCounters(pub otMacCounters);

impl_ot_castable!(MacCounters, otMacCounters);

impl MacCounters {
    /// The total number of unique MAC frame transmission requests.
    pub fn tx_total(&self) -> u32 {
        self.0.mTxTotal
    }

    /// The total number of unique unicast MAC frame transmission requests.
    pub fn tx_unicast(&self) -> u32 {
        self.0.mTxUnicast
    }

    /// The total number of unique broadcast MAC frame transmission requests.
    pub fn tx_broadcast(&self) -> u32 {
        self.0.mTxBroadcast
    }

    /// The total number of unique MAC frame transmission requests with requested acknowledgment.
    pub fn tx_ack_requested(&self) -> u32 {
        self.0.mTxAckRequested
    }

    /// The total number of unique MAC frame transmission requests that were acked.
    pub fn tx_acked(&self) -> u32 {
        self.0.mTxAcked
    }

    /// The total number of unique MAC frame transmission requests without requested acknowledgment.
    pub fn tx_no_ack_requested(&self) -> u32 {
        self.0.mTxNoAckRequested
    }

    /// The total number of unique MAC Data frame transmission requests.
    pub fn tx_data(&self) -> u32 {
        self.0.mTxData
    }

    /// The total number of unique MAC Data Poll frame transmission requests.
    pub fn tx_data_poll(&self) -> u32 {
        self.0.mTxDataPoll
    }

    /// The total number of unique MAC Beacon frame transmission requests.
    pub fn tx_beacon(&self) -> u32 {
        self.0.mTxBeacon
    }

    /// The total number of unique MAC Beacon Request frame transmission requests.
    pub fn tx_beacon_request(&self) -> u32 {
        self.0.mTxBeaconRequest
    }

    /// The total number of unique other MAC frame transmission requests.
    pub fn tx_other(&self) -> u32 {
        self.0.mTxOther
    }

    /// The total number of MAC retransmission attempts.
    pub fn tx_retry(&self) -> u32 {
        self.0.mTxRetry
    }

    /// The total number of unique MAC transmission packets that meet maximal retry limit for direct packets.
    pub fn tx_direct_max_retry_expiry(&self) -> u32 {
        self.0.mTxDirectMaxRetryExpiry
    }

    /// The total number of unique MAC transmission packets that meet maximal retry limit for indirect packets.
    pub fn tx_indirect_max_retry_expiry(&self) -> u32 {
        self.0.mTxIndirectMaxRetryExpiry
    }

    /// The total number of CCA failures.
    pub fn tx_err_cca(&self) -> u32 {
        self.0.mTxErrCca
    }

    /// The total number of unique MAC transmission request failures cause by an abort error.
    pub fn tx_err_abort(&self) -> u32 {
        self.0.mTxErrAbort
    }

    /// The total number of unique MAC transmission requests failures caused by a busy channel (a CSMA/CA fail).
    pub fn tx_err_busy_channel(&self) -> u32 {
        self.0.mTxErrBusyChannel
    }

    /// The total number of received frames.
    pub fn rx_total(&self) -> u32 {
        self.0.mRxTotal
    }

    /// The total number of unicast frames received.
    pub fn rx_unicast(&self) -> u32 {
        self.0.mRxUnicast
    }

    /// The total number of broadcast frames received.
    pub fn rx_broadcast(&self) -> u32 {
        self.0.mRxBroadcast
    }

    /// The total number of MAC Data frames received.
    pub fn rx_data(&self) -> u32 {
        self.0.mRxData
    }

    /// The total number of MAC Data Poll frames received.
    pub fn rx_data_poll(&self) -> u32 {
        self.0.mRxDataPoll
    }

    /// The total number of MAC Beacon frames received.
    pub fn rx_beacon(&self) -> u32 {
        self.0.mRxBeacon
    }

    /// The total number of MAC Beacon Request frames received.
    pub fn rx_beacon_request(&self) -> u32 {
        self.0.mRxBeaconRequest
    }

    /// The total number of other types of frames received.
    pub fn rx_other(&self) -> u32 {
        self.0.mRxOther
    }

    /// The total number of frames dropped by MAC Filter module.
    pub fn rx_address_filtered(&self) -> u32 {
        self.0.mRxAddressFiltered
    }

    /// The total number of frames dropped by destination address check.
    pub fn rx_dest_addr_filtered(&self) -> u32 {
        self.0.mRxDestAddrFiltered
    }

    /// The total number of frames dropped due to duplication.
    pub fn rx_duplicated(&self) -> u32 {
        self.0.mRxDuplicated
    }

    /// The total number of frames dropped because of missing or malformed content.
    pub fn rx_err_no_frame(&self) -> u32 {
        self.0.mRxErrNoFrame
    }

    /// The total number of frames dropped due to unknown neighbor.
    pub fn rx_err_unknown_neighbor(&self) -> u32 {
        self.0.mRxErrUnknownNeighbor
    }

    /// The total number of frames dropped due to invalid source address.
    pub fn rx_err_invalid_src_addr(&self) -> u32 {
        self.0.mRxErrInvalidSrcAddr
    }

    /// The total number of frames dropped due to security error.
    pub fn rx_err_sec(&self) -> u32 {
        self.0.mRxErrSec
    }

    /// The total number of frames dropped due to invalid FCS.
    pub fn rx_err_fcs(&self) -> u32 {
        self.0.mRxErrFcs
    }

    /// The total number of frames dropped due to other error.
    pub fn rx_err_other(&self) -> u32 {
        self.0.mRxErrOther
    }
}