openthread/ot/types/
mod.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
5mod backbone_router_multicast_listener_event;
6mod backbone_router_multicast_listener_info;
7mod border_router_config;
8mod border_routing_counters;
9mod border_routing_peer;
10mod border_routing_router;
11mod castable;
12mod channel_mask;
13mod device_role;
14mod dnssd_counters;
15mod ext_address;
16mod extended_pan_id;
17mod external_route_config;
18mod ip_counters;
19mod ipv6;
20mod leader_data;
21mod link_metrics;
22mod link_mode;
23mod log_region;
24mod mac_counters;
25mod nat64;
26mod neighbor_info;
27mod network_key;
28mod network_name;
29mod operational_dataset;
30mod packets_and_bytes;
31mod radio_coex_metrics;
32mod radio_region;
33mod resolver;
34mod route_preference;
35mod router_info;
36mod scan_results;
37mod security_policy;
38mod srp_server_lease_info;
39mod srp_server_response_counters;
40mod timestamp;
41mod tlv;
42mod trel;
43
44use crate::prelude_internal::*;
45
46pub use backbone_router_multicast_listener_event::*;
47pub use backbone_router_multicast_listener_info::*;
48pub use border_router_config::*;
49pub use border_routing_counters::*;
50pub use border_routing_peer::*;
51pub use border_routing_router::*;
52pub use castable::*;
53pub use channel_mask::*;
54pub use device_role::*;
55pub use dnssd_counters::*;
56pub use ext_address::*;
57pub use extended_pan_id::*;
58pub use external_route_config::*;
59pub use ip_counters::*;
60pub use ipv6::*;
61pub use leader_data::*;
62pub use link_metrics::*;
63pub use link_mode::*;
64pub use log_region::*;
65pub use mac_counters::*;
66pub use nat64::*;
67pub use neighbor_info::*;
68pub use network_key::*;
69pub use network_name::*;
70pub use operational_dataset::*;
71pub use packets_and_bytes::*;
72pub use radio_coex_metrics::*;
73pub use radio_region::*;
74pub use resolver::*;
75pub use route_preference::*;
76pub use router_info::*;
77pub use scan_results::*;
78pub use security_policy::*;
79pub use srp_server_lease_info::*;
80pub use srp_server_response_counters::*;
81pub use timestamp::*;
82pub use tlv::*;
83pub use trel::*;
84
85/// 802.15.4 PAN Identifier. Same type as [`otsys::otPanId`](crate::otsys::otPanId).
86pub type PanId = otPanId;
87
88/// 802.15.4 Short Address. Same type as [`otsys::otShortAddress`](crate::otsys::otShortAddress).
89pub type ShortAddress = otShortAddress;
90
91/// Type for representing decibels, such as RSSI or transmit power.
92pub type Decibels = i8;
93
94/// Channel index value. Identifies an individual radio channel for transmitting and receiving.
95pub type ChannelIndex = u8;
96
97/// Mesh-Local Prefix.
98///
99/// Same type as [`Ip6NetworkPrefix`]. Functional equivalent of [`otsys::otMeshLocalPrefix`](crate::otsys::otMeshLocalPrefix).
100pub type MeshLocalPrefix = Ip6NetworkPrefix;
101
102/// Network Interface Identifier.
103pub type NetifIndex = u32;
104
105/// Unspecified network index.
106pub const NETIF_INDEX_UNSPECIFIED: NetifIndex = 0;
107
108/// Unspecified power
109pub const DECIBELS_UNSPECIFIED: Decibels = -128;
110
111/// The largest child ID supported by OpenThread, 511.
112pub const MAX_CHILD_ID: u16 = 0x1FF;
113
114/// The bit offset to the router ID in an RLOC16.
115pub const ROUTER_ID_OFFSET: usize = 9;
116
117/// Extracts the child ID from an RLOC16.
118pub fn rloc16_to_child_id(rloc16: u16) -> u16 {
119    rloc16 & MAX_CHILD_ID
120}
121
122/// Extracts the router ID from an RLOC16.
123pub fn rloc16_to_router_id(rloc16: u16) -> u8 {
124    (rloc16 >> ROUTER_ID_OFFSET) as u8
125}