Expand description
Implements Type-Length-Value (TLV) encoding and decoding as outlined in the Thread 1.1.1 Specification.
TLVs are used to serialize information exchanged during mesh link establishment (MLE). MLE is covered in Chapter 4.
MLE messages consist of a command type and a series of TLV parameters.
This module, as it stands, implements the minimum subset of TLVs required to support MLE for attaching a Sleepy End Device (SED) to a Thread network.
MLE for network attaching comprises a four-step handshake that works as follows:
- A child device multicasts a Parent Request MLE command.
- Each potential parent device on the network unicasts a Parent Response MLE command.
- The child device selects a parent based on a hierarchy of connectivity metrics and unicasts a Child ID Request MLE command.
- The selected parent unicasts a Child ID Response MLE command.
A TLV is comprised of three parts:
- Type - A one-byte TLV type number.
- Length - A one-byte number representing the length of the TLV value in bytes.
- Value - The TLV value.
For some TLVs, the TLV type number is shifted left by one to leave the least significant bit to denote whether information in the TLV value is stable. Stable network data is data that is expected to be stable over weeks or months (Section 5.14).
TLVs can be nested within a TLV value. Some types of Network Data TLVs, for example, contain sub-TLVs inside of their TLV value.
To simplify variable-length TLV value decoding in Rust, TLV values are assumed to have a maximum length of 128 bytes. This assumption is made only when a variable-length value must be decoded from network byte order before it can be interpreted correctly. Excluded from this case are variable-length values that contain data that must later be decoded by the caller before being interpreted (for example, sub-TLVs). Such a value is instead returned as a slice of the original buffer passed to the decode function.
Author: Mateo Garcia mateog@stanford.edu
Structs§
- Border
Router TlvValue - Used in Border Router TLV.
- Channel
Mask Entry - Used in Channel Mask TLV.
- HasRoute
TlvValue - Used in Has Route TLV.
Enums§
- Border
Router TlvValue Bit - Used in Border Router TLV value.
- Link
Mode - Used in Mode TLV.
- Multicast
Responder - Used in Scan Mask TLV.
- Network
Data Tlv - These TLVs are contained within the value of a Network Data TLV. See Section 5.18.
- Network
Data TlvType - Value encoded in the type field of a Network Data TLV. Gaps in type numbers are filled by PrefixSubTlv and ServiceSubTlv.
- Network
Management Tlv - These TLVs are contained within the value of a Pending Operational Dataset TLV or an Active Operational Dataset TLV. See Section 8.10.1.
- Network
Management TlvType - Value encoded in the type field of a Network Management TLV.
- Parent
Priority - Used in Connectivity TLV.
- Prefix
SubTlv - These TLVs are contained within the value of a Prefix TLV.
- Prefix
SubTlv Type - Value encoded in the type field of a Prefix sub-TLV. Gaps in type numbers are filled by NetworkDataTlv and ServiceSubTlv.
- Security
Policy - Used in Security Policy TLV. See 8.10.1.15
- Service
SubTlv - These TLVs are contained within the value of a Service TLV.
- Service
SubTlv Type - Value encoded in the type field of a Service sub-TLV. Gaps in type numbers are filled by NetworkDataTlv and PrefixSubTlv.
- Tlv
- Type-Length-Value structure.
- TlvType
- Value encoded in the type field of a Type-Length-Value (TLV) structure.