openthread/ot/types/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

mod backbone_router_multicast_listener_event;
mod backbone_router_multicast_listener_info;
mod border_router_config;
mod border_routing_counters;
mod castable;
mod channel_mask;
mod device_role;
mod dnssd_counters;
mod ext_address;
mod extended_pan_id;
mod external_route_config;
mod ip_counters;
mod ipv6;
mod leader_data;
mod link_metrics;
mod link_mode;
mod log_region;
mod mac_counters;
mod nat64;
mod neighbor_info;
mod network_key;
mod network_name;
mod operational_dataset;
mod packets_and_bytes;
mod radio_coex_metrics;
mod radio_region;
mod resolver;
mod route_preference;
mod router_info;
mod scan_results;
mod security_policy;
mod srp_server_lease_info;
mod srp_server_response_counters;
mod timestamp;
mod tlv;
mod trel;

use crate::prelude_internal::*;

pub use backbone_router_multicast_listener_event::*;
pub use backbone_router_multicast_listener_info::*;
pub use border_router_config::*;
pub use border_routing_counters::*;
pub use castable::*;
pub use channel_mask::*;
pub use device_role::*;
pub use dnssd_counters::*;
pub use ext_address::*;
pub use extended_pan_id::*;
pub use external_route_config::*;
pub use ip_counters::*;
pub use ipv6::*;
pub use leader_data::*;
pub use link_metrics::*;
pub use link_mode::*;
pub use log_region::*;
pub use mac_counters::*;
pub use nat64::*;
pub use neighbor_info::*;
pub use network_key::*;
pub use network_name::*;
pub use operational_dataset::*;
pub use packets_and_bytes::*;
pub use radio_coex_metrics::*;
pub use radio_region::*;
pub use resolver::*;
pub use route_preference::*;
pub use router_info::*;
pub use scan_results::*;
pub use security_policy::*;
pub use srp_server_lease_info::*;
pub use srp_server_response_counters::*;
pub use timestamp::*;
pub use tlv::*;
pub use trel::*;

/// 802.15.4 PAN Identifier. Same type as [`otsys::otPanId`](crate::otsys::otPanId).
pub type PanId = otPanId;

/// 802.15.4 Short Address. Same type as [`otsys::otShortAddress`](crate::otsys::otShortAddress).
pub type ShortAddress = otShortAddress;

/// Type for representing decibels, such as RSSI or transmit power.
pub type Decibels = i8;

/// Channel index value. Identifies an individual radio channel for transmitting and receiving.
pub type ChannelIndex = u8;

/// Mesh-Local Prefix.
///
/// Same type as [`Ip6NetworkPrefix`]. Functional equivalent of [`otsys::otMeshLocalPrefix`](crate::otsys::otMeshLocalPrefix).
pub type MeshLocalPrefix = Ip6NetworkPrefix;

/// Network Interface Identifier.
pub type NetifIndex = u32;

/// Unspecified network index.
pub const NETIF_INDEX_UNSPECIFIED: NetifIndex = 0;

/// Unspecified power
pub const DECIBELS_UNSPECIFIED: Decibels = -128;

/// The largest child ID supported by OpenThread, 511.
pub const MAX_CHILD_ID: u16 = 0x1FF;

/// The bit offset to the router ID in an RLOC16.
pub const ROUTER_ID_OFFSET: usize = 9;

/// Extracts the child ID from an RLOC16.
pub fn rloc16_to_child_id(rloc16: u16) -> u16 {
    rloc16 & MAX_CHILD_ID
}

/// Extracts the router ID from an RLOC16.
pub fn rloc16_to_router_id(rloc16: u16) -> u8 {
    (rloc16 >> ROUTER_ID_OFFSET) as u8
}