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