Skip to main content

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