Skip to main content

matter_kit/clusters/generated/
thread_network_diagnostics.rs

1// Generated by `cargo xtask` from the CSA data model 1.6. Do not edit.
2//
3// Thread Network Diagnostics — cluster 0x0035.
4//
5// Regenerate with `cargo xtask clusters --dm <checkout>/data_model/1.6`; `cargo xtask check`
6// is the CI gate that keeps this file honest. The XML itself is not vendored here — it
7// carries the CSA's own copyright notice and is not redistributable.
8
9//! Thread Network Diagnostics (cluster `0x0035`, revision 3).
10//!
11//! 68 identifiers, 4 feature bits, and the specification's own conformance for
12//! every element. `CLUSTER` is the whole table.
13
14#![allow(unused_imports)]
15
16use crate::dm::conformance::{Clause, Condition, Conform, Conformance};
17use crate::dm::meta::{EventPriority, Reporting};
18use crate::dm::spec::{Attribute, Cluster, Command, Event, Feature};
19use crate::dm::{Access, AccessQualities, AttributeQualities, Privilege};
20use crate::error::Result;
21use crate::im::{AttributeId, ClusterId, CommandId, EventId};
22use crate::tlv::{
23    ContainerKind, Element, FromTlv, Nullable, Tag, TlvList, TlvReader, TlvWriter, ToTlv, Value,
24};
25
26/// The cluster id.
27pub const ID: ClusterId = 0x0035;
28
29/// The highest revision the specification's history defines — what `ClusterRevision`
30/// must report (Core §7.13.1).
31pub const REVISION: u16 = 3;
32
33/// The PICS code, which a certification declaration names the cluster by.
34pub const PICS: &str = "DGTHREAD";
35
36/// The `FeatureMap` bits (Core §7.13.2).
37///
38/// A feature has conformance of its own: a device may not claim one the
39/// specification forbids it alongside another.
40pub mod feature {
41    /// Server supports the counts for the number of received and transmitted packets on the Thread interface.
42    ///
43    /// Code `PKTCNT`, bit 0.
44    pub const PACKET_COUNTS: u32 = 1 << 0;
45    /// Server supports the counts for the number of errors that have occurred during the reception and transmission of packets on the Thread interface.
46    ///
47    /// Code `ERRCNT`, bit 1.
48    pub const ERROR_COUNTS: u32 = 1 << 1;
49    /// Server supports the counts for various MLE layer happenings.
50    ///
51    /// Code `MLECNT`, bit 2.
52    pub const MLE_COUNTS: u32 = 1 << 2;
53    /// Server supports the counts for various MAC layer happenings.
54    ///
55    /// Code `MACCNT`, bit 3.
56    pub const MAC_COUNTS: u32 = 1 << 3;
57}
58
59/// Every feature bit, with its conformance.
60pub const FEATURES: &[Feature] = &[
61    Feature {
62        bit: 0,
63        code: "PKTCNT",
64        name: "PacketCounts",
65        conform: Conform::OPTIONAL,
66    },
67    Feature {
68        bit: 1,
69        code: "ERRCNT",
70        name: "ErrorCounts",
71        conform: Conform::OPTIONAL,
72    },
73    Feature {
74        bit: 2,
75        code: "MLECNT",
76        name: "MLECounts",
77        conform: Conform::OPTIONAL,
78    },
79    Feature {
80        bit: 3,
81        code: "MACCNT",
82        name: "MACCounts",
83        conform: Conform::OPTIONAL,
84    },
85];
86
87/// The attribute ids.
88pub mod attribute {
89    use crate::im::AttributeId;
90
91    /// `Channel`.
92    pub const CHANNEL: AttributeId = 0x00;
93    /// `RoutingRole`.
94    pub const ROUTING_ROLE: AttributeId = 0x01;
95    /// `NetworkName`.
96    pub const NETWORK_NAME: AttributeId = 0x02;
97    /// `PanId`.
98    pub const PAN_ID: AttributeId = 0x03;
99    /// `ExtendedPanId`.
100    pub const EXTENDED_PAN_ID: AttributeId = 0x04;
101    /// `MeshLocalPrefix`.
102    pub const MESH_LOCAL_PREFIX: AttributeId = 0x05;
103    /// `OverrunCount`.
104    pub const OVERRUN_COUNT: AttributeId = 0x06;
105    /// `NeighborTable`.
106    pub const NEIGHBOR_TABLE: AttributeId = 0x07;
107    /// `RouteTable`.
108    pub const ROUTE_TABLE: AttributeId = 0x08;
109    /// `PartitionId`.
110    pub const PARTITION_ID: AttributeId = 0x09;
111    /// `Weighting`.
112    pub const WEIGHTING: AttributeId = 0x0A;
113    /// `DataVersion`.
114    pub const DATA_VERSION: AttributeId = 0x0B;
115    /// `StableDataVersion`.
116    pub const STABLE_DATA_VERSION: AttributeId = 0x0C;
117    /// `LeaderRouterId`.
118    pub const LEADER_ROUTER_ID: AttributeId = 0x0D;
119    /// `DetachedRoleCount`.
120    pub const DETACHED_ROLE_COUNT: AttributeId = 0x0E;
121    /// `ChildRoleCount`.
122    pub const CHILD_ROLE_COUNT: AttributeId = 0x0F;
123    /// `RouterRoleCount`.
124    pub const ROUTER_ROLE_COUNT: AttributeId = 0x10;
125    /// `LeaderRoleCount`.
126    pub const LEADER_ROLE_COUNT: AttributeId = 0x11;
127    /// `AttachAttemptCount`.
128    pub const ATTACH_ATTEMPT_COUNT: AttributeId = 0x12;
129    /// `PartitionIdChangeCount`.
130    pub const PARTITION_ID_CHANGE_COUNT: AttributeId = 0x13;
131    /// `BetterPartitionAttachAttemptCount`.
132    pub const BETTER_PARTITION_ATTACH_ATTEMPT_COUNT: AttributeId = 0x14;
133    /// `ParentChangeCount`.
134    pub const PARENT_CHANGE_COUNT: AttributeId = 0x15;
135    /// `TxTotalCount`.
136    pub const TX_TOTAL_COUNT: AttributeId = 0x16;
137    /// `TxUnicastCount`.
138    pub const TX_UNICAST_COUNT: AttributeId = 0x17;
139    /// `TxBroadcastCount`.
140    pub const TX_BROADCAST_COUNT: AttributeId = 0x18;
141    /// `TxAckRequestedCount`.
142    pub const TX_ACK_REQUESTED_COUNT: AttributeId = 0x19;
143    /// `TxAckedCount`.
144    pub const TX_ACKED_COUNT: AttributeId = 0x1A;
145    /// `TxNoAckRequestedCount`.
146    pub const TX_NO_ACK_REQUESTED_COUNT: AttributeId = 0x1B;
147    /// `TxDataCount`.
148    pub const TX_DATA_COUNT: AttributeId = 0x1C;
149    /// `TxDataPollCount`.
150    pub const TX_DATA_POLL_COUNT: AttributeId = 0x1D;
151    /// `TxBeaconCount`.
152    pub const TX_BEACON_COUNT: AttributeId = 0x1E;
153    /// `TxBeaconRequestCount`.
154    pub const TX_BEACON_REQUEST_COUNT: AttributeId = 0x1F;
155    /// `TxOtherCount`.
156    pub const TX_OTHER_COUNT: AttributeId = 0x20;
157    /// `TxRetryCount`.
158    pub const TX_RETRY_COUNT: AttributeId = 0x21;
159    /// `TxDirectMaxRetryExpiryCount`.
160    pub const TX_DIRECT_MAX_RETRY_EXPIRY_COUNT: AttributeId = 0x22;
161    /// `TxIndirectMaxRetryExpiryCount`.
162    pub const TX_INDIRECT_MAX_RETRY_EXPIRY_COUNT: AttributeId = 0x23;
163    /// `TxErrCcaCount`.
164    pub const TX_ERR_CCA_COUNT: AttributeId = 0x24;
165    /// `TxErrAbortCount`.
166    pub const TX_ERR_ABORT_COUNT: AttributeId = 0x25;
167    /// `TxErrBusyChannelCount`.
168    pub const TX_ERR_BUSY_CHANNEL_COUNT: AttributeId = 0x26;
169    /// `RxTotalCount`.
170    pub const RX_TOTAL_COUNT: AttributeId = 0x27;
171    /// `RxUnicastCount`.
172    pub const RX_UNICAST_COUNT: AttributeId = 0x28;
173    /// `RxBroadcastCount`.
174    pub const RX_BROADCAST_COUNT: AttributeId = 0x29;
175    /// `RxDataCount`.
176    pub const RX_DATA_COUNT: AttributeId = 0x2A;
177    /// `RxDataPollCount`.
178    pub const RX_DATA_POLL_COUNT: AttributeId = 0x2B;
179    /// `RxBeaconCount`.
180    pub const RX_BEACON_COUNT: AttributeId = 0x2C;
181    /// `RxBeaconRequestCount`.
182    pub const RX_BEACON_REQUEST_COUNT: AttributeId = 0x2D;
183    /// `RxOtherCount`.
184    pub const RX_OTHER_COUNT: AttributeId = 0x2E;
185    /// `RxAddressFilteredCount`.
186    pub const RX_ADDRESS_FILTERED_COUNT: AttributeId = 0x2F;
187    /// `RxDestAddrFilteredCount`.
188    pub const RX_DEST_ADDR_FILTERED_COUNT: AttributeId = 0x30;
189    /// `RxDuplicatedCount`.
190    pub const RX_DUPLICATED_COUNT: AttributeId = 0x31;
191    /// `RxErrNoFrameCount`.
192    pub const RX_ERR_NO_FRAME_COUNT: AttributeId = 0x32;
193    /// `RxErrUnknownNeighborCount`.
194    pub const RX_ERR_UNKNOWN_NEIGHBOR_COUNT: AttributeId = 0x33;
195    /// `RxErrInvalidSrcAddrCount`.
196    pub const RX_ERR_INVALID_SRC_ADDR_COUNT: AttributeId = 0x34;
197    /// `RxErrSecCount`.
198    pub const RX_ERR_SEC_COUNT: AttributeId = 0x35;
199    /// `RxErrFcsCount`.
200    pub const RX_ERR_FCS_COUNT: AttributeId = 0x36;
201    /// `RxErrOtherCount`.
202    pub const RX_ERR_OTHER_COUNT: AttributeId = 0x37;
203    /// `ActiveTimestamp`.
204    pub const ACTIVE_TIMESTAMP: AttributeId = 0x38;
205    /// `PendingTimestamp`.
206    pub const PENDING_TIMESTAMP: AttributeId = 0x39;
207    /// `Delay`.
208    pub const DELAY: AttributeId = 0x3A;
209    /// `SecurityPolicy`.
210    pub const SECURITY_POLICY: AttributeId = 0x3B;
211    /// `ChannelPage0Mask`.
212    pub const CHANNEL_PAGE0_MASK: AttributeId = 0x3C;
213    /// `OperationalDatasetComponents`.
214    pub const OPERATIONAL_DATASET_COMPONENTS: AttributeId = 0x3D;
215    /// `ActiveNetworkFaultsList`.
216    pub const ACTIVE_NETWORK_FAULTS_LIST: AttributeId = 0x3E;
217    /// `ExtAddress`.
218    pub const EXT_ADDRESS: AttributeId = 0x3F;
219    /// `Rloc16`.
220    pub const RLOC16: AttributeId = 0x40;
221}
222
223/// The command ids.
224pub mod command {
225    use crate::im::CommandId;
226
227    /// `ResetCounts`.
228    pub const RESET_COUNTS: CommandId = 0x00;
229}
230
231/// The event ids.
232pub mod event {
233    use crate::im::EventId;
234
235    /// `ConnectionStatus`.
236    pub const CONNECTION_STATUS: EventId = 0x00;
237    /// `NetworkFaultChange`.
238    pub const NETWORK_FAULT_CHANGE: EventId = 0x01;
239}
240
241/// `ConnectionStatusEnum`.
242#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
243#[repr(u8)]
244pub enum ConnectionStatusEnum {
245    /// Node is connected
246    Connected = 0,
247    /// Node is not connected
248    NotConnected = 1,
249}
250
251impl ConnectionStatusEnum {
252    /// Reads a wire value, or `None` for one this revision does not define.
253    #[must_use]
254    pub const fn from_value(value: u8) -> Option<Self> {
255        match value {
256            0 => Some(Self::Connected),
257            1 => Some(Self::NotConnected),
258            _ => None,
259        }
260    }
261
262    /// Its wire value.
263    #[must_use]
264    pub const fn value(self) -> u8 {
265        self as u8
266    }
267}
268
269impl ToTlv for ConnectionStatusEnum {
270    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
271        self.value().to_tlv(w, tag)
272    }
273}
274
275impl<'a> FromTlv<'a> for ConnectionStatusEnum {
276    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
277        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
278        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
279    }
280}
281
282/// `NetworkFaultEnum`.
283#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
284#[repr(u8)]
285pub enum NetworkFaultEnum {
286    /// Indicates an unspecified fault.
287    Unspecified = 0,
288    /// Indicates the Thread link is down.
289    LinkDown = 1,
290    /// Indicates there has been Thread hardware failure.
291    HardwareFailure = 2,
292    /// Indicates the Thread network is jammed.
293    NetworkJammed = 3,
294}
295
296impl NetworkFaultEnum {
297    /// Reads a wire value, or `None` for one this revision does not define.
298    #[must_use]
299    pub const fn from_value(value: u8) -> Option<Self> {
300        match value {
301            0 => Some(Self::Unspecified),
302            1 => Some(Self::LinkDown),
303            2 => Some(Self::HardwareFailure),
304            3 => Some(Self::NetworkJammed),
305            _ => None,
306        }
307    }
308
309    /// Its wire value.
310    #[must_use]
311    pub const fn value(self) -> u8 {
312        self as u8
313    }
314}
315
316impl ToTlv for NetworkFaultEnum {
317    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
318        self.value().to_tlv(w, tag)
319    }
320}
321
322impl<'a> FromTlv<'a> for NetworkFaultEnum {
323    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
324        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
325        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
326    }
327}
328
329/// `RoutingRoleEnum`.
330#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
331#[repr(u8)]
332pub enum RoutingRoleEnum {
333    /// Unspecified routing role.
334    Unspecified = 0,
335    /// The Node does not currently have a role as a result of the Thread interface not currently being configured or operational.
336    Unassigned = 1,
337    /// The Node acts as a Sleepy End Device with RX-off-when-idle sleepy radio behavior.
338    SleepyEndDevice = 2,
339    /// The Node acts as an End Device without RX-off-when-idle sleepy radio behavior.
340    EndDevice = 3,
341    /// The Node acts as an Router Eligible End Device.
342    REED = 4,
343    /// The Node acts as a Router Device.
344    Router = 5,
345    /// The Node acts as a Leader Device.
346    Leader = 6,
347}
348
349impl RoutingRoleEnum {
350    /// Reads a wire value, or `None` for one this revision does not define.
351    #[must_use]
352    pub const fn from_value(value: u8) -> Option<Self> {
353        match value {
354            0 => Some(Self::Unspecified),
355            1 => Some(Self::Unassigned),
356            2 => Some(Self::SleepyEndDevice),
357            3 => Some(Self::EndDevice),
358            4 => Some(Self::REED),
359            5 => Some(Self::Router),
360            6 => Some(Self::Leader),
361            _ => None,
362        }
363    }
364
365    /// Its wire value.
366    #[must_use]
367    pub const fn value(self) -> u8 {
368        self as u8
369    }
370}
371
372impl ToTlv for RoutingRoleEnum {
373    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
374        self.value().to_tlv(w, tag)
375    }
376}
377
378impl<'a> FromTlv<'a> for RoutingRoleEnum {
379    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
380        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
381        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
382    }
383}
384
385/// `NeighborTableStruct`.
386#[derive(Debug, Clone, Copy, PartialEq)]
387pub struct NeighborTableStruct {
388    /// `ExtAddress`, field 0.
389    pub ext_address: u64,
390    /// `Age`, field 1.
391    pub age: u32,
392    /// `Rloc16`, field 2.
393    pub rloc16: u16,
394    /// `LinkFrameCounter`, field 3.
395    pub link_frame_counter: u32,
396    /// `MleFrameCounter`, field 4.
397    pub mle_frame_counter: u32,
398    /// `LQI`, field 5.
399    pub lqi: u8,
400    /// `AverageRssi`, field 6.
401    pub average_rssi: Nullable<i8>,
402    /// `LastRssi`, field 7.
403    pub last_rssi: Nullable<i8>,
404    /// `FrameErrorRate`, field 8.
405    pub frame_error_rate: u8,
406    /// `MessageErrorRate`, field 9.
407    pub message_error_rate: u8,
408    /// `RxOnWhenIdle`, field 10.
409    pub rx_on_when_idle: bool,
410    /// `FullThreadDevice`, field 11.
411    pub full_thread_device: bool,
412    /// `FullNetworkData`, field 12.
413    pub full_network_data: bool,
414    /// `IsChild`, field 13.
415    pub is_child: bool,
416}
417
418impl ToTlv for NeighborTableStruct {
419    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
420        w.start_structure(tag)?;
421        self.ext_address.to_tlv(w, Tag::Context(0))?;
422        self.age.to_tlv(w, Tag::Context(1))?;
423        self.rloc16.to_tlv(w, Tag::Context(2))?;
424        self.link_frame_counter.to_tlv(w, Tag::Context(3))?;
425        self.mle_frame_counter.to_tlv(w, Tag::Context(4))?;
426        self.lqi.to_tlv(w, Tag::Context(5))?;
427        self.average_rssi.to_tlv(w, Tag::Context(6))?;
428        self.last_rssi.to_tlv(w, Tag::Context(7))?;
429        self.frame_error_rate.to_tlv(w, Tag::Context(8))?;
430        self.message_error_rate.to_tlv(w, Tag::Context(9))?;
431        self.rx_on_when_idle.to_tlv(w, Tag::Context(10))?;
432        self.full_thread_device.to_tlv(w, Tag::Context(11))?;
433        self.full_network_data.to_tlv(w, Tag::Context(12))?;
434        self.is_child.to_tlv(w, Tag::Context(13))?;
435        w.end_container()
436    }
437}
438
439impl<'a> FromTlv<'a> for NeighborTableStruct {
440    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
441        if element.value.container() != Some(ContainerKind::Structure) {
442            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
443        }
444        let mut ext_address = None;
445        let mut age = None;
446        let mut rloc16 = None;
447        let mut link_frame_counter = None;
448        let mut mle_frame_counter = None;
449        let mut lqi = None;
450        let mut average_rssi = None;
451        let mut last_rssi = None;
452        let mut frame_error_rate = None;
453        let mut message_error_rate = None;
454        let mut rx_on_when_idle = None;
455        let mut full_thread_device = None;
456        let mut full_network_data = None;
457        let mut is_child = None;
458        loop {
459            let Some(field) = reader.next_element()? else {
460                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
461            };
462            if field.value == Value::EndOfContainer {
463                break;
464            }
465            match field.tag.context() {
466                Some(0) => ext_address = Some(<u64>::from_tlv(reader, &field)?),
467                Some(1) => age = Some(<u32>::from_tlv(reader, &field)?),
468                Some(2) => rloc16 = Some(<u16>::from_tlv(reader, &field)?),
469                Some(3) => link_frame_counter = Some(<u32>::from_tlv(reader, &field)?),
470                Some(4) => mle_frame_counter = Some(<u32>::from_tlv(reader, &field)?),
471                Some(5) => lqi = Some(<u8>::from_tlv(reader, &field)?),
472                Some(6) => average_rssi = Some(<Nullable<i8>>::from_tlv(reader, &field)?),
473                Some(7) => last_rssi = Some(<Nullable<i8>>::from_tlv(reader, &field)?),
474                Some(8) => frame_error_rate = Some(<u8>::from_tlv(reader, &field)?),
475                Some(9) => message_error_rate = Some(<u8>::from_tlv(reader, &field)?),
476                Some(10) => rx_on_when_idle = Some(<bool>::from_tlv(reader, &field)?),
477                Some(11) => full_thread_device = Some(<bool>::from_tlv(reader, &field)?),
478                Some(12) => full_network_data = Some(<bool>::from_tlv(reader, &field)?),
479                Some(13) => is_child = Some(<bool>::from_tlv(reader, &field)?),
480                // A field this revision does not define. §7.19.2: a receiver
481                // ignores what it does not know rather than refusing the whole
482                // structure, which is what lets a newer peer talk to an older one.
483                _ => reader.skip_value(&field)?,
484            }
485        }
486        Ok(Self {
487            ext_address: ext_address.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
488            age: age.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
489            rloc16: rloc16.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
490            link_frame_counter: link_frame_counter
491                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
492            mle_frame_counter: mle_frame_counter
493                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
494            lqi: lqi.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
495            average_rssi: average_rssi.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
496            last_rssi: last_rssi.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
497            frame_error_rate: frame_error_rate
498                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
499            message_error_rate: message_error_rate
500                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
501            rx_on_when_idle: rx_on_when_idle
502                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
503            full_thread_device: full_thread_device
504                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
505            full_network_data: full_network_data
506                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
507            is_child: is_child.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
508        })
509    }
510}
511
512/// `OperationalDatasetComponents`.
513#[derive(Debug, Clone, Copy, PartialEq)]
514pub struct OperationalDatasetComponents {
515    /// `ActiveTimestampPresent`, field 0.
516    pub active_timestamp_present: bool,
517    /// `PendingTimestampPresent`, field 1.
518    pub pending_timestamp_present: bool,
519    /// `MasterKeyPresent`, field 2.
520    pub master_key_present: bool,
521    /// `NetworkNamePresent`, field 3.
522    pub network_name_present: bool,
523    /// `ExtendedPanIdPresent`, field 4.
524    pub extended_pan_id_present: bool,
525    /// `MeshLocalPrefixPresent`, field 5.
526    pub mesh_local_prefix_present: bool,
527    /// `DelayPresent`, field 6.
528    pub delay_present: bool,
529    /// `PanIdPresent`, field 7.
530    pub pan_id_present: bool,
531    /// `ChannelPresent`, field 8.
532    pub channel_present: bool,
533    /// `PskcPresent`, field 9.
534    pub pskc_present: bool,
535    /// `SecurityPolicyPresent`, field 10.
536    pub security_policy_present: bool,
537    /// `ChannelMaskPresent`, field 11.
538    pub channel_mask_present: bool,
539}
540
541impl ToTlv for OperationalDatasetComponents {
542    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
543        w.start_structure(tag)?;
544        self.active_timestamp_present.to_tlv(w, Tag::Context(0))?;
545        self.pending_timestamp_present.to_tlv(w, Tag::Context(1))?;
546        self.master_key_present.to_tlv(w, Tag::Context(2))?;
547        self.network_name_present.to_tlv(w, Tag::Context(3))?;
548        self.extended_pan_id_present.to_tlv(w, Tag::Context(4))?;
549        self.mesh_local_prefix_present.to_tlv(w, Tag::Context(5))?;
550        self.delay_present.to_tlv(w, Tag::Context(6))?;
551        self.pan_id_present.to_tlv(w, Tag::Context(7))?;
552        self.channel_present.to_tlv(w, Tag::Context(8))?;
553        self.pskc_present.to_tlv(w, Tag::Context(9))?;
554        self.security_policy_present.to_tlv(w, Tag::Context(10))?;
555        self.channel_mask_present.to_tlv(w, Tag::Context(11))?;
556        w.end_container()
557    }
558}
559
560impl<'a> FromTlv<'a> for OperationalDatasetComponents {
561    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
562        if element.value.container() != Some(ContainerKind::Structure) {
563            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
564        }
565        let mut active_timestamp_present = None;
566        let mut pending_timestamp_present = None;
567        let mut master_key_present = None;
568        let mut network_name_present = None;
569        let mut extended_pan_id_present = None;
570        let mut mesh_local_prefix_present = None;
571        let mut delay_present = None;
572        let mut pan_id_present = None;
573        let mut channel_present = None;
574        let mut pskc_present = None;
575        let mut security_policy_present = None;
576        let mut channel_mask_present = None;
577        loop {
578            let Some(field) = reader.next_element()? else {
579                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
580            };
581            if field.value == Value::EndOfContainer {
582                break;
583            }
584            match field.tag.context() {
585                Some(0) => active_timestamp_present = Some(<bool>::from_tlv(reader, &field)?),
586                Some(1) => pending_timestamp_present = Some(<bool>::from_tlv(reader, &field)?),
587                Some(2) => master_key_present = Some(<bool>::from_tlv(reader, &field)?),
588                Some(3) => network_name_present = Some(<bool>::from_tlv(reader, &field)?),
589                Some(4) => extended_pan_id_present = Some(<bool>::from_tlv(reader, &field)?),
590                Some(5) => mesh_local_prefix_present = Some(<bool>::from_tlv(reader, &field)?),
591                Some(6) => delay_present = Some(<bool>::from_tlv(reader, &field)?),
592                Some(7) => pan_id_present = Some(<bool>::from_tlv(reader, &field)?),
593                Some(8) => channel_present = Some(<bool>::from_tlv(reader, &field)?),
594                Some(9) => pskc_present = Some(<bool>::from_tlv(reader, &field)?),
595                Some(10) => security_policy_present = Some(<bool>::from_tlv(reader, &field)?),
596                Some(11) => channel_mask_present = Some(<bool>::from_tlv(reader, &field)?),
597                // A field this revision does not define. §7.19.2: a receiver
598                // ignores what it does not know rather than refusing the whole
599                // structure, which is what lets a newer peer talk to an older one.
600                _ => reader.skip_value(&field)?,
601            }
602        }
603        Ok(Self {
604            active_timestamp_present: active_timestamp_present
605                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
606            pending_timestamp_present: pending_timestamp_present
607                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
608            master_key_present: master_key_present
609                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
610            network_name_present: network_name_present
611                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
612            extended_pan_id_present: extended_pan_id_present
613                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
614            mesh_local_prefix_present: mesh_local_prefix_present
615                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
616            delay_present: delay_present.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
617            pan_id_present: pan_id_present
618                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
619            channel_present: channel_present
620                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
621            pskc_present: pskc_present.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
622            security_policy_present: security_policy_present
623                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
624            channel_mask_present: channel_mask_present
625                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
626        })
627    }
628}
629
630/// `RouteTableStruct`.
631#[derive(Debug, Clone, Copy, PartialEq)]
632pub struct RouteTableStruct {
633    /// `ExtAddress`, field 0.
634    pub ext_address: u64,
635    /// `Rloc16`, field 1.
636    pub rloc16: u16,
637    /// `RouterId`, field 2.
638    pub router_id: u8,
639    /// `NextHop`, field 3.
640    pub next_hop: u8,
641    /// `PathCost`, field 4.
642    pub path_cost: u8,
643    /// `LQIIn`, field 5.
644    pub lqi_in: u8,
645    /// `LQIOut`, field 6.
646    pub lqi_out: u8,
647    /// `Age`, field 7.
648    pub age: u8,
649    /// `Allocated`, field 8.
650    pub allocated: bool,
651    /// `LinkEstablished`, field 9.
652    pub link_established: bool,
653}
654
655impl ToTlv for RouteTableStruct {
656    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
657        w.start_structure(tag)?;
658        self.ext_address.to_tlv(w, Tag::Context(0))?;
659        self.rloc16.to_tlv(w, Tag::Context(1))?;
660        self.router_id.to_tlv(w, Tag::Context(2))?;
661        self.next_hop.to_tlv(w, Tag::Context(3))?;
662        self.path_cost.to_tlv(w, Tag::Context(4))?;
663        self.lqi_in.to_tlv(w, Tag::Context(5))?;
664        self.lqi_out.to_tlv(w, Tag::Context(6))?;
665        self.age.to_tlv(w, Tag::Context(7))?;
666        self.allocated.to_tlv(w, Tag::Context(8))?;
667        self.link_established.to_tlv(w, Tag::Context(9))?;
668        w.end_container()
669    }
670}
671
672impl<'a> FromTlv<'a> for RouteTableStruct {
673    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
674        if element.value.container() != Some(ContainerKind::Structure) {
675            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
676        }
677        let mut ext_address = None;
678        let mut rloc16 = None;
679        let mut router_id = None;
680        let mut next_hop = None;
681        let mut path_cost = None;
682        let mut lqi_in = None;
683        let mut lqi_out = None;
684        let mut age = None;
685        let mut allocated = None;
686        let mut link_established = None;
687        loop {
688            let Some(field) = reader.next_element()? else {
689                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
690            };
691            if field.value == Value::EndOfContainer {
692                break;
693            }
694            match field.tag.context() {
695                Some(0) => ext_address = Some(<u64>::from_tlv(reader, &field)?),
696                Some(1) => rloc16 = Some(<u16>::from_tlv(reader, &field)?),
697                Some(2) => router_id = Some(<u8>::from_tlv(reader, &field)?),
698                Some(3) => next_hop = Some(<u8>::from_tlv(reader, &field)?),
699                Some(4) => path_cost = Some(<u8>::from_tlv(reader, &field)?),
700                Some(5) => lqi_in = Some(<u8>::from_tlv(reader, &field)?),
701                Some(6) => lqi_out = Some(<u8>::from_tlv(reader, &field)?),
702                Some(7) => age = Some(<u8>::from_tlv(reader, &field)?),
703                Some(8) => allocated = Some(<bool>::from_tlv(reader, &field)?),
704                Some(9) => link_established = Some(<bool>::from_tlv(reader, &field)?),
705                // A field this revision does not define. §7.19.2: a receiver
706                // ignores what it does not know rather than refusing the whole
707                // structure, which is what lets a newer peer talk to an older one.
708                _ => reader.skip_value(&field)?,
709            }
710        }
711        Ok(Self {
712            ext_address: ext_address.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
713            rloc16: rloc16.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
714            router_id: router_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
715            next_hop: next_hop.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
716            path_cost: path_cost.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
717            lqi_in: lqi_in.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
718            lqi_out: lqi_out.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
719            age: age.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
720            allocated: allocated.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
721            link_established: link_established
722                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
723        })
724    }
725}
726
727/// `SecurityPolicy`.
728#[derive(Debug, Clone, Copy, PartialEq)]
729pub struct SecurityPolicy {
730    /// `RotationTime`, field 0.
731    pub rotation_time: u16,
732    /// `Flags`, field 1.
733    pub flags: u16,
734}
735
736impl ToTlv for SecurityPolicy {
737    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
738        w.start_structure(tag)?;
739        self.rotation_time.to_tlv(w, Tag::Context(0))?;
740        self.flags.to_tlv(w, Tag::Context(1))?;
741        w.end_container()
742    }
743}
744
745impl<'a> FromTlv<'a> for SecurityPolicy {
746    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
747        if element.value.container() != Some(ContainerKind::Structure) {
748            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
749        }
750        let mut rotation_time = None;
751        let mut flags = None;
752        loop {
753            let Some(field) = reader.next_element()? else {
754                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
755            };
756            if field.value == Value::EndOfContainer {
757                break;
758            }
759            match field.tag.context() {
760                Some(0) => rotation_time = Some(<u16>::from_tlv(reader, &field)?),
761                Some(1) => flags = Some(<u16>::from_tlv(reader, &field)?),
762                // A field this revision does not define. §7.19.2: a receiver
763                // ignores what it does not know rather than refusing the whole
764                // structure, which is what lets a newer peer talk to an older one.
765                _ => reader.skip_value(&field)?,
766            }
767        }
768        Ok(Self {
769            rotation_time: rotation_time.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
770            flags: flags.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
771        })
772    }
773}
774
775/// Every attribute the specification defines, with its conformance.
776pub const ATTRIBUTES: &[Attribute] = &[
777    Attribute {
778        id: 0x0000,
779        name: "Channel",
780        kind: "uint16",
781        access: Access::read_only(Privilege::View),
782        qualities: AttributeQualities::NULLABLE,
783        reporting: Reporting::OnChange,
784        conform: Conform::MANDATORY,
785    },
786    Attribute {
787        id: 0x0001,
788        name: "RoutingRole",
789        kind: "RoutingRoleEnum",
790        access: Access::read_only(Privilege::View),
791        qualities: AttributeQualities::NULLABLE,
792        reporting: Reporting::OnChange,
793        conform: Conform::MANDATORY,
794    },
795    Attribute {
796        id: 0x0002,
797        name: "NetworkName",
798        kind: "string",
799        access: Access::read_only(Privilege::View),
800        qualities: AttributeQualities::NULLABLE,
801        reporting: Reporting::OnChange,
802        conform: Conform::MANDATORY,
803    },
804    Attribute {
805        id: 0x0003,
806        name: "PanId",
807        kind: "uint16",
808        access: Access::read_only(Privilege::View),
809        qualities: AttributeQualities::NULLABLE,
810        reporting: Reporting::OnChange,
811        conform: Conform::MANDATORY,
812    },
813    Attribute {
814        id: 0x0004,
815        name: "ExtendedPanId",
816        kind: "uint64",
817        access: Access::read_only(Privilege::View),
818        qualities: AttributeQualities::NULLABLE,
819        reporting: Reporting::OnChange,
820        conform: Conform::MANDATORY,
821    },
822    Attribute {
823        id: 0x0005,
824        name: "MeshLocalPrefix",
825        kind: "ipv6pre",
826        access: Access::read_only(Privilege::View),
827        qualities: AttributeQualities::NULLABLE,
828        reporting: Reporting::OnChange,
829        conform: Conform::MANDATORY,
830    },
831    Attribute {
832        id: 0x0006,
833        name: "OverrunCount",
834        kind: "uint64",
835        access: Access::read_only(Privilege::View),
836        qualities: AttributeQualities::empty(),
837        reporting: Reporting::ChangesOmitted,
838        conform: Conform {
839            clauses: &[Clause {
840                verdict: Conformance::Mandatory,
841                when: Condition::Feature(1),
842            }],
843        },
844    },
845    Attribute {
846        id: 0x0007,
847        name: "NeighborTable",
848        kind: "list[NeighborTableStruct]",
849        access: Access::read_only(Privilege::View),
850        qualities: AttributeQualities::empty(),
851        reporting: Reporting::OnChange,
852        conform: Conform::MANDATORY,
853    },
854    Attribute {
855        id: 0x0008,
856        name: "RouteTable",
857        kind: "list[RouteTableStruct]",
858        access: Access::read_only(Privilege::View),
859        qualities: AttributeQualities::empty(),
860        reporting: Reporting::OnChange,
861        conform: Conform::MANDATORY,
862    },
863    Attribute {
864        id: 0x0009,
865        name: "PartitionId",
866        kind: "uint32",
867        access: Access::read_only(Privilege::View),
868        qualities: AttributeQualities::NULLABLE,
869        reporting: Reporting::OnChange,
870        conform: Conform::MANDATORY,
871    },
872    Attribute {
873        id: 0x000A,
874        name: "Weighting",
875        kind: "uint16",
876        access: Access::read_only(Privilege::View),
877        qualities: AttributeQualities::NULLABLE,
878        reporting: Reporting::OnChange,
879        conform: Conform::MANDATORY,
880    },
881    Attribute {
882        id: 0x000B,
883        name: "DataVersion",
884        kind: "uint16",
885        access: Access::read_only(Privilege::View),
886        qualities: AttributeQualities::NULLABLE,
887        reporting: Reporting::OnChange,
888        conform: Conform::MANDATORY,
889    },
890    Attribute {
891        id: 0x000C,
892        name: "StableDataVersion",
893        kind: "uint16",
894        access: Access::read_only(Privilege::View),
895        qualities: AttributeQualities::NULLABLE,
896        reporting: Reporting::OnChange,
897        conform: Conform::MANDATORY,
898    },
899    Attribute {
900        id: 0x000D,
901        name: "LeaderRouterId",
902        kind: "uint8",
903        access: Access::read_only(Privilege::View),
904        qualities: AttributeQualities::NULLABLE,
905        reporting: Reporting::OnChange,
906        conform: Conform::MANDATORY,
907    },
908    Attribute {
909        id: 0x000E,
910        name: "DetachedRoleCount",
911        kind: "uint16",
912        access: Access::read_only(Privilege::View),
913        qualities: AttributeQualities::empty(),
914        reporting: Reporting::ChangesOmitted,
915        conform: Conform {
916            clauses: &[Clause {
917                verdict: Conformance::Optional,
918                when: Condition::Feature(2),
919            }],
920        },
921    },
922    Attribute {
923        id: 0x000F,
924        name: "ChildRoleCount",
925        kind: "uint16",
926        access: Access::read_only(Privilege::View),
927        qualities: AttributeQualities::empty(),
928        reporting: Reporting::ChangesOmitted,
929        conform: Conform {
930            clauses: &[Clause {
931                verdict: Conformance::Optional,
932                when: Condition::Feature(2),
933            }],
934        },
935    },
936    Attribute {
937        id: 0x0010,
938        name: "RouterRoleCount",
939        kind: "uint16",
940        access: Access::read_only(Privilege::View),
941        qualities: AttributeQualities::empty(),
942        reporting: Reporting::ChangesOmitted,
943        conform: Conform {
944            clauses: &[Clause {
945                verdict: Conformance::Optional,
946                when: Condition::Feature(2),
947            }],
948        },
949    },
950    Attribute {
951        id: 0x0011,
952        name: "LeaderRoleCount",
953        kind: "uint16",
954        access: Access::read_only(Privilege::View),
955        qualities: AttributeQualities::empty(),
956        reporting: Reporting::ChangesOmitted,
957        conform: Conform {
958            clauses: &[Clause {
959                verdict: Conformance::Optional,
960                when: Condition::Feature(2),
961            }],
962        },
963    },
964    Attribute {
965        id: 0x0012,
966        name: "AttachAttemptCount",
967        kind: "uint16",
968        access: Access::read_only(Privilege::View),
969        qualities: AttributeQualities::empty(),
970        reporting: Reporting::ChangesOmitted,
971        conform: Conform {
972            clauses: &[Clause {
973                verdict: Conformance::Optional,
974                when: Condition::Feature(2),
975            }],
976        },
977    },
978    Attribute {
979        id: 0x0013,
980        name: "PartitionIdChangeCount",
981        kind: "uint16",
982        access: Access::read_only(Privilege::View),
983        qualities: AttributeQualities::empty(),
984        reporting: Reporting::ChangesOmitted,
985        conform: Conform {
986            clauses: &[Clause {
987                verdict: Conformance::Optional,
988                when: Condition::Feature(2),
989            }],
990        },
991    },
992    Attribute {
993        id: 0x0014,
994        name: "BetterPartitionAttachAttemptCount",
995        kind: "uint16",
996        access: Access::read_only(Privilege::View),
997        qualities: AttributeQualities::empty(),
998        reporting: Reporting::ChangesOmitted,
999        conform: Conform {
1000            clauses: &[Clause {
1001                verdict: Conformance::Optional,
1002                when: Condition::Feature(2),
1003            }],
1004        },
1005    },
1006    Attribute {
1007        id: 0x0015,
1008        name: "ParentChangeCount",
1009        kind: "uint16",
1010        access: Access::read_only(Privilege::View),
1011        qualities: AttributeQualities::empty(),
1012        reporting: Reporting::ChangesOmitted,
1013        conform: Conform {
1014            clauses: &[Clause {
1015                verdict: Conformance::Optional,
1016                when: Condition::Feature(2),
1017            }],
1018        },
1019    },
1020    Attribute {
1021        id: 0x0016,
1022        name: "TxTotalCount",
1023        kind: "uint32",
1024        access: Access::read_only(Privilege::View),
1025        qualities: AttributeQualities::empty(),
1026        reporting: Reporting::ChangesOmitted,
1027        conform: Conform {
1028            clauses: &[Clause {
1029                verdict: Conformance::Optional,
1030                when: Condition::Feature(3),
1031            }],
1032        },
1033    },
1034    Attribute {
1035        id: 0x0017,
1036        name: "TxUnicastCount",
1037        kind: "uint32",
1038        access: Access::read_only(Privilege::View),
1039        qualities: AttributeQualities::empty(),
1040        reporting: Reporting::ChangesOmitted,
1041        conform: Conform {
1042            clauses: &[Clause {
1043                verdict: Conformance::Optional,
1044                when: Condition::Feature(3),
1045            }],
1046        },
1047    },
1048    Attribute {
1049        id: 0x0018,
1050        name: "TxBroadcastCount",
1051        kind: "uint32",
1052        access: Access::read_only(Privilege::View),
1053        qualities: AttributeQualities::empty(),
1054        reporting: Reporting::ChangesOmitted,
1055        conform: Conform {
1056            clauses: &[Clause {
1057                verdict: Conformance::Optional,
1058                when: Condition::Feature(3),
1059            }],
1060        },
1061    },
1062    Attribute {
1063        id: 0x0019,
1064        name: "TxAckRequestedCount",
1065        kind: "uint32",
1066        access: Access::read_only(Privilege::View),
1067        qualities: AttributeQualities::empty(),
1068        reporting: Reporting::ChangesOmitted,
1069        conform: Conform {
1070            clauses: &[Clause {
1071                verdict: Conformance::Optional,
1072                when: Condition::Feature(3),
1073            }],
1074        },
1075    },
1076    Attribute {
1077        id: 0x001A,
1078        name: "TxAckedCount",
1079        kind: "uint32",
1080        access: Access::read_only(Privilege::View),
1081        qualities: AttributeQualities::empty(),
1082        reporting: Reporting::ChangesOmitted,
1083        conform: Conform {
1084            clauses: &[Clause {
1085                verdict: Conformance::Optional,
1086                when: Condition::Feature(3),
1087            }],
1088        },
1089    },
1090    Attribute {
1091        id: 0x001B,
1092        name: "TxNoAckRequestedCount",
1093        kind: "uint32",
1094        access: Access::read_only(Privilege::View),
1095        qualities: AttributeQualities::empty(),
1096        reporting: Reporting::ChangesOmitted,
1097        conform: Conform {
1098            clauses: &[Clause {
1099                verdict: Conformance::Optional,
1100                when: Condition::Feature(3),
1101            }],
1102        },
1103    },
1104    Attribute {
1105        id: 0x001C,
1106        name: "TxDataCount",
1107        kind: "uint32",
1108        access: Access::read_only(Privilege::View),
1109        qualities: AttributeQualities::empty(),
1110        reporting: Reporting::ChangesOmitted,
1111        conform: Conform {
1112            clauses: &[Clause {
1113                verdict: Conformance::Optional,
1114                when: Condition::Feature(3),
1115            }],
1116        },
1117    },
1118    Attribute {
1119        id: 0x001D,
1120        name: "TxDataPollCount",
1121        kind: "uint32",
1122        access: Access::read_only(Privilege::View),
1123        qualities: AttributeQualities::empty(),
1124        reporting: Reporting::ChangesOmitted,
1125        conform: Conform {
1126            clauses: &[Clause {
1127                verdict: Conformance::Optional,
1128                when: Condition::Feature(3),
1129            }],
1130        },
1131    },
1132    Attribute {
1133        id: 0x001E,
1134        name: "TxBeaconCount",
1135        kind: "uint32",
1136        access: Access::read_only(Privilege::View),
1137        qualities: AttributeQualities::empty(),
1138        reporting: Reporting::ChangesOmitted,
1139        conform: Conform {
1140            clauses: &[Clause {
1141                verdict: Conformance::Optional,
1142                when: Condition::Feature(3),
1143            }],
1144        },
1145    },
1146    Attribute {
1147        id: 0x001F,
1148        name: "TxBeaconRequestCount",
1149        kind: "uint32",
1150        access: Access::read_only(Privilege::View),
1151        qualities: AttributeQualities::empty(),
1152        reporting: Reporting::ChangesOmitted,
1153        conform: Conform {
1154            clauses: &[Clause {
1155                verdict: Conformance::Optional,
1156                when: Condition::Feature(3),
1157            }],
1158        },
1159    },
1160    Attribute {
1161        id: 0x0020,
1162        name: "TxOtherCount",
1163        kind: "uint32",
1164        access: Access::read_only(Privilege::View),
1165        qualities: AttributeQualities::empty(),
1166        reporting: Reporting::ChangesOmitted,
1167        conform: Conform {
1168            clauses: &[Clause {
1169                verdict: Conformance::Optional,
1170                when: Condition::Feature(3),
1171            }],
1172        },
1173    },
1174    Attribute {
1175        id: 0x0021,
1176        name: "TxRetryCount",
1177        kind: "uint32",
1178        access: Access::read_only(Privilege::View),
1179        qualities: AttributeQualities::empty(),
1180        reporting: Reporting::ChangesOmitted,
1181        conform: Conform {
1182            clauses: &[Clause {
1183                verdict: Conformance::Optional,
1184                when: Condition::Feature(3),
1185            }],
1186        },
1187    },
1188    Attribute {
1189        id: 0x0022,
1190        name: "TxDirectMaxRetryExpiryCount",
1191        kind: "uint32",
1192        access: Access::read_only(Privilege::View),
1193        qualities: AttributeQualities::empty(),
1194        reporting: Reporting::ChangesOmitted,
1195        conform: Conform {
1196            clauses: &[Clause {
1197                verdict: Conformance::Optional,
1198                when: Condition::Feature(3),
1199            }],
1200        },
1201    },
1202    Attribute {
1203        id: 0x0023,
1204        name: "TxIndirectMaxRetryExpiryCount",
1205        kind: "uint32",
1206        access: Access::read_only(Privilege::View),
1207        qualities: AttributeQualities::empty(),
1208        reporting: Reporting::ChangesOmitted,
1209        conform: Conform {
1210            clauses: &[Clause {
1211                verdict: Conformance::Optional,
1212                when: Condition::Feature(3),
1213            }],
1214        },
1215    },
1216    Attribute {
1217        id: 0x0024,
1218        name: "TxErrCcaCount",
1219        kind: "uint32",
1220        access: Access::read_only(Privilege::View),
1221        qualities: AttributeQualities::empty(),
1222        reporting: Reporting::ChangesOmitted,
1223        conform: Conform {
1224            clauses: &[Clause {
1225                verdict: Conformance::Optional,
1226                when: Condition::Feature(3),
1227            }],
1228        },
1229    },
1230    Attribute {
1231        id: 0x0025,
1232        name: "TxErrAbortCount",
1233        kind: "uint32",
1234        access: Access::read_only(Privilege::View),
1235        qualities: AttributeQualities::empty(),
1236        reporting: Reporting::ChangesOmitted,
1237        conform: Conform {
1238            clauses: &[Clause {
1239                verdict: Conformance::Optional,
1240                when: Condition::Feature(3),
1241            }],
1242        },
1243    },
1244    Attribute {
1245        id: 0x0026,
1246        name: "TxErrBusyChannelCount",
1247        kind: "uint32",
1248        access: Access::read_only(Privilege::View),
1249        qualities: AttributeQualities::empty(),
1250        reporting: Reporting::ChangesOmitted,
1251        conform: Conform {
1252            clauses: &[Clause {
1253                verdict: Conformance::Optional,
1254                when: Condition::Feature(3),
1255            }],
1256        },
1257    },
1258    Attribute {
1259        id: 0x0027,
1260        name: "RxTotalCount",
1261        kind: "uint32",
1262        access: Access::read_only(Privilege::View),
1263        qualities: AttributeQualities::empty(),
1264        reporting: Reporting::ChangesOmitted,
1265        conform: Conform {
1266            clauses: &[Clause {
1267                verdict: Conformance::Optional,
1268                when: Condition::Feature(3),
1269            }],
1270        },
1271    },
1272    Attribute {
1273        id: 0x0028,
1274        name: "RxUnicastCount",
1275        kind: "uint32",
1276        access: Access::read_only(Privilege::View),
1277        qualities: AttributeQualities::empty(),
1278        reporting: Reporting::ChangesOmitted,
1279        conform: Conform {
1280            clauses: &[Clause {
1281                verdict: Conformance::Optional,
1282                when: Condition::Feature(3),
1283            }],
1284        },
1285    },
1286    Attribute {
1287        id: 0x0029,
1288        name: "RxBroadcastCount",
1289        kind: "uint32",
1290        access: Access::read_only(Privilege::View),
1291        qualities: AttributeQualities::empty(),
1292        reporting: Reporting::ChangesOmitted,
1293        conform: Conform {
1294            clauses: &[Clause {
1295                verdict: Conformance::Optional,
1296                when: Condition::Feature(3),
1297            }],
1298        },
1299    },
1300    Attribute {
1301        id: 0x002A,
1302        name: "RxDataCount",
1303        kind: "uint32",
1304        access: Access::read_only(Privilege::View),
1305        qualities: AttributeQualities::empty(),
1306        reporting: Reporting::ChangesOmitted,
1307        conform: Conform {
1308            clauses: &[Clause {
1309                verdict: Conformance::Optional,
1310                when: Condition::Feature(3),
1311            }],
1312        },
1313    },
1314    Attribute {
1315        id: 0x002B,
1316        name: "RxDataPollCount",
1317        kind: "uint32",
1318        access: Access::read_only(Privilege::View),
1319        qualities: AttributeQualities::empty(),
1320        reporting: Reporting::ChangesOmitted,
1321        conform: Conform {
1322            clauses: &[Clause {
1323                verdict: Conformance::Optional,
1324                when: Condition::Feature(3),
1325            }],
1326        },
1327    },
1328    Attribute {
1329        id: 0x002C,
1330        name: "RxBeaconCount",
1331        kind: "uint32",
1332        access: Access::read_only(Privilege::View),
1333        qualities: AttributeQualities::empty(),
1334        reporting: Reporting::ChangesOmitted,
1335        conform: Conform {
1336            clauses: &[Clause {
1337                verdict: Conformance::Optional,
1338                when: Condition::Feature(3),
1339            }],
1340        },
1341    },
1342    Attribute {
1343        id: 0x002D,
1344        name: "RxBeaconRequestCount",
1345        kind: "uint32",
1346        access: Access::read_only(Privilege::View),
1347        qualities: AttributeQualities::empty(),
1348        reporting: Reporting::ChangesOmitted,
1349        conform: Conform {
1350            clauses: &[Clause {
1351                verdict: Conformance::Optional,
1352                when: Condition::Feature(3),
1353            }],
1354        },
1355    },
1356    Attribute {
1357        id: 0x002E,
1358        name: "RxOtherCount",
1359        kind: "uint32",
1360        access: Access::read_only(Privilege::View),
1361        qualities: AttributeQualities::empty(),
1362        reporting: Reporting::ChangesOmitted,
1363        conform: Conform {
1364            clauses: &[Clause {
1365                verdict: Conformance::Optional,
1366                when: Condition::Feature(3),
1367            }],
1368        },
1369    },
1370    Attribute {
1371        id: 0x002F,
1372        name: "RxAddressFilteredCount",
1373        kind: "uint32",
1374        access: Access::read_only(Privilege::View),
1375        qualities: AttributeQualities::empty(),
1376        reporting: Reporting::ChangesOmitted,
1377        conform: Conform {
1378            clauses: &[Clause {
1379                verdict: Conformance::Optional,
1380                when: Condition::Feature(3),
1381            }],
1382        },
1383    },
1384    Attribute {
1385        id: 0x0030,
1386        name: "RxDestAddrFilteredCount",
1387        kind: "uint32",
1388        access: Access::read_only(Privilege::View),
1389        qualities: AttributeQualities::empty(),
1390        reporting: Reporting::ChangesOmitted,
1391        conform: Conform {
1392            clauses: &[Clause {
1393                verdict: Conformance::Optional,
1394                when: Condition::Feature(3),
1395            }],
1396        },
1397    },
1398    Attribute {
1399        id: 0x0031,
1400        name: "RxDuplicatedCount",
1401        kind: "uint32",
1402        access: Access::read_only(Privilege::View),
1403        qualities: AttributeQualities::empty(),
1404        reporting: Reporting::ChangesOmitted,
1405        conform: Conform {
1406            clauses: &[Clause {
1407                verdict: Conformance::Optional,
1408                when: Condition::Feature(3),
1409            }],
1410        },
1411    },
1412    Attribute {
1413        id: 0x0032,
1414        name: "RxErrNoFrameCount",
1415        kind: "uint32",
1416        access: Access::read_only(Privilege::View),
1417        qualities: AttributeQualities::empty(),
1418        reporting: Reporting::ChangesOmitted,
1419        conform: Conform {
1420            clauses: &[Clause {
1421                verdict: Conformance::Optional,
1422                when: Condition::Feature(3),
1423            }],
1424        },
1425    },
1426    Attribute {
1427        id: 0x0033,
1428        name: "RxErrUnknownNeighborCount",
1429        kind: "uint32",
1430        access: Access::read_only(Privilege::View),
1431        qualities: AttributeQualities::empty(),
1432        reporting: Reporting::ChangesOmitted,
1433        conform: Conform {
1434            clauses: &[Clause {
1435                verdict: Conformance::Optional,
1436                when: Condition::Feature(3),
1437            }],
1438        },
1439    },
1440    Attribute {
1441        id: 0x0034,
1442        name: "RxErrInvalidSrcAddrCount",
1443        kind: "uint32",
1444        access: Access::read_only(Privilege::View),
1445        qualities: AttributeQualities::empty(),
1446        reporting: Reporting::ChangesOmitted,
1447        conform: Conform {
1448            clauses: &[Clause {
1449                verdict: Conformance::Optional,
1450                when: Condition::Feature(3),
1451            }],
1452        },
1453    },
1454    Attribute {
1455        id: 0x0035,
1456        name: "RxErrSecCount",
1457        kind: "uint32",
1458        access: Access::read_only(Privilege::View),
1459        qualities: AttributeQualities::empty(),
1460        reporting: Reporting::ChangesOmitted,
1461        conform: Conform {
1462            clauses: &[Clause {
1463                verdict: Conformance::Optional,
1464                when: Condition::Feature(3),
1465            }],
1466        },
1467    },
1468    Attribute {
1469        id: 0x0036,
1470        name: "RxErrFcsCount",
1471        kind: "uint32",
1472        access: Access::read_only(Privilege::View),
1473        qualities: AttributeQualities::empty(),
1474        reporting: Reporting::ChangesOmitted,
1475        conform: Conform {
1476            clauses: &[Clause {
1477                verdict: Conformance::Optional,
1478                when: Condition::Feature(3),
1479            }],
1480        },
1481    },
1482    Attribute {
1483        id: 0x0037,
1484        name: "RxErrOtherCount",
1485        kind: "uint32",
1486        access: Access::read_only(Privilege::View),
1487        qualities: AttributeQualities::empty(),
1488        reporting: Reporting::ChangesOmitted,
1489        conform: Conform {
1490            clauses: &[Clause {
1491                verdict: Conformance::Optional,
1492                when: Condition::Feature(3),
1493            }],
1494        },
1495    },
1496    Attribute {
1497        id: 0x0038,
1498        name: "ActiveTimestamp",
1499        kind: "uint64",
1500        access: Access::read_only(Privilege::View),
1501        qualities: AttributeQualities::NULLABLE,
1502        reporting: Reporting::OnChange,
1503        conform: Conform::OPTIONAL,
1504    },
1505    Attribute {
1506        id: 0x0039,
1507        name: "PendingTimestamp",
1508        kind: "uint64",
1509        access: Access::read_only(Privilege::View),
1510        qualities: AttributeQualities::NULLABLE,
1511        reporting: Reporting::OnChange,
1512        conform: Conform::OPTIONAL,
1513    },
1514    Attribute {
1515        id: 0x003A,
1516        name: "Delay",
1517        kind: "uint32",
1518        access: Access::read_only(Privilege::View),
1519        qualities: AttributeQualities::NULLABLE,
1520        reporting: Reporting::OnChange,
1521        conform: Conform::OPTIONAL,
1522    },
1523    Attribute {
1524        id: 0x003B,
1525        name: "SecurityPolicy",
1526        kind: "SecurityPolicy",
1527        access: Access::read_only(Privilege::View),
1528        qualities: AttributeQualities::NULLABLE,
1529        reporting: Reporting::OnChange,
1530        conform: Conform::MANDATORY,
1531    },
1532    Attribute {
1533        id: 0x003C,
1534        name: "ChannelPage0Mask",
1535        kind: "octstr",
1536        access: Access::read_only(Privilege::View),
1537        qualities: AttributeQualities::NULLABLE,
1538        reporting: Reporting::OnChange,
1539        conform: Conform::MANDATORY,
1540    },
1541    Attribute {
1542        id: 0x003D,
1543        name: "OperationalDatasetComponents",
1544        kind: "OperationalDatasetComponents",
1545        access: Access::read_only(Privilege::View),
1546        qualities: AttributeQualities::NULLABLE,
1547        reporting: Reporting::OnChange,
1548        conform: Conform::MANDATORY,
1549    },
1550    Attribute {
1551        id: 0x003E,
1552        name: "ActiveNetworkFaultsList",
1553        kind: "list[NetworkFaultEnum]",
1554        access: Access::read_only(Privilege::View),
1555        qualities: AttributeQualities::empty(),
1556        reporting: Reporting::OnChange,
1557        conform: Conform::MANDATORY,
1558    },
1559    Attribute {
1560        id: 0x003F,
1561        name: "ExtAddress",
1562        kind: "uint64",
1563        access: Access::read_only(Privilege::View),
1564        qualities: AttributeQualities::NULLABLE,
1565        reporting: Reporting::OnChange,
1566        conform: Conform {
1567            clauses: &[
1568                Clause {
1569                    verdict: Conformance::Provisional,
1570                    when: Condition::Always,
1571                },
1572                Clause {
1573                    verdict: Conformance::Mandatory,
1574                    when: Condition::Always,
1575                },
1576            ],
1577        },
1578    },
1579    Attribute {
1580        id: 0x0040,
1581        name: "Rloc16",
1582        kind: "uint16",
1583        access: Access::read_only(Privilege::View),
1584        qualities: AttributeQualities::NULLABLE,
1585        reporting: Reporting::OnChange,
1586        conform: Conform {
1587            clauses: &[
1588                Clause {
1589                    verdict: Conformance::Provisional,
1590                    when: Condition::Always,
1591                },
1592                Clause {
1593                    verdict: Conformance::Mandatory,
1594                    when: Condition::Always,
1595                },
1596            ],
1597        },
1598    },
1599];
1600
1601/// Every command, with its conformance.
1602pub const COMMANDS: &[Command] = &[Command {
1603    id: 0x00,
1604    name: "ResetCounts",
1605    to_server: true,
1606    response: None,
1607    access: Access::invoke(Privilege::Manage),
1608    conform: Conform {
1609        clauses: &[Clause {
1610            verdict: Conformance::Mandatory,
1611            when: Condition::Feature(1),
1612        }],
1613    },
1614}];
1615
1616/// Every event, with its conformance.
1617pub const EVENTS: &[Event] = &[
1618    Event {
1619        id: 0x00,
1620        name: "ConnectionStatus",
1621        priority: EventPriority::Info,
1622        access: Access::read_only(Privilege::View),
1623        conform: Conform::OPTIONAL,
1624    },
1625    Event {
1626        id: 0x01,
1627        name: "NetworkFaultChange",
1628        priority: EventPriority::Info,
1629        access: Access::read_only(Privilege::View),
1630        conform: Conform::OPTIONAL,
1631    },
1632];
1633
1634/// The whole cluster, as the specification defines it.
1635pub const CLUSTER: Cluster = Cluster {
1636    id: ID,
1637    name: "Thread Network Diagnostics",
1638    revision: REVISION,
1639    pics: "DGTHREAD",
1640    derived_from: None,
1641    features: FEATURES,
1642    attributes: ATTRIBUTES,
1643    commands: COMMANDS,
1644    events: EVENTS,
1645};