Expand description
Core wire-format types and packet construction/parsing utilities for UMSH.
Note: This reference implementation is a work in progress and was developed with the assistance of an LLM. It should be considered experimental.
This crate stays focused on byte layout, typed header fields, and zero-copy parsing. It does not perform any cryptographic operations or I/O.
The main entry points are:
PacketHeader::parseto inspect a received frame.PacketBuilderto construct outbound frames with typestate guards.feed_aadto stream canonical authenticated data into a MAC state.options::OptionEncoderandoptions::OptionDecoderfor CoAP-style option blocks used throughout the protocol.
§Example
use umsh_core::{MicSize, NodeHint, PacketBuilder, PacketHeader, PublicKey};
let mut buf = [0u8; 128];
let src = PublicKey([0x11; 32]);
let dst = NodeHint([0xAA, 0xBB, 0xCC]);
let packet = PacketBuilder::new(&mut buf)
.unicast(dst)
.source_full(&src)
.frame_counter(7)
.encrypted()
.mic_size(MicSize::Mic16)
.payload(b"hello")
.build()
.unwrap();
let header = PacketHeader::parse(packet.as_bytes()).unwrap();
assert_eq!(header.dst, Some(dst));
assert_eq!(header.body_range.len(), 5);Modules§
- options
- state
- Typestate markers used by
PacketBuilderand its specialized builders.
Structs§
- Channel
Id - Two-byte multicast channel identifier.
- Channel
Key - Raw 32-byte multicast channel secret.
- Fcf
- Frame-control field wrapper.
- Flood
Hops - Combined remaining/accumulated flood-hop counters.
- Node
Hint - Three-byte node hint derived from a public key.
- Packet
Builder - Entry point for typestate packet construction.
- Packet
Header - Parsed packet header with borrowed ranges into the original frame.
- Parsed
Options - Public
Key - Node public key, which also acts as the full network address.
- Router
Hint - Two-byte router hint used in learned routes.
- Scf
- Security-control field wrapper.
- SecInfo
- Decoded SECINFO structure.
- Unsealed
Packet
Enums§
- Build
Error - Errors returned while assembling a full packet with
crate::PacketBuilder. - Encode
Error - Errors returned while encoding wire-format values into caller-provided buffers.
- MicSize
- Authenticator size carried by secured packets.
- Option
Number - Known packet-option numbers.
- Packet
Type - Packet class encoded in the frame-control field.
- Parse
Error - Errors returned while parsing on-wire UMSH structures.
- Payload
Type - Application payload type carried inside the MAC body.
- Source
Addr - Source address supplied while constructing packets.
- Source
Addr Ref - Parsed source-address location used by zero-copy packet processing.
Constants§
- UMSH_
VERSION - Current UMSH packet version encoded in the FCF high bits.
Functions§
Type Aliases§
- Blind
Unicast Builder - Blind-unicast packet builder alias.
- Broadcast
Builder - Broadcast packet builder alias.
- MacAck
Builder - MAC ACK packet builder alias.
- Multicast
Builder - Multicast packet builder alias.
- Unicast
Builder - Unicast packet builder alias.