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