ndn_discovery/hello/mod.rs
1//! SWIM/Hello neighbor discovery protocol family.
2//!
3//! This module contains the shared hello protocol state machine and its
4//! link-medium implementations.
5//!
6//! ## Module layout
7//!
8//! | Sub-module | Contents |
9//! |-------------|----------|
10//! | [`payload`] | `HelloPayload` TLV codec — the wire format for hello Data Content |
11//! | [`medium`] | `LinkMedium` trait — link-specific face creation, signing, address extraction |
12//! | [`protocol`]| `HelloProtocol<T>` — generic SWIM/hello/probe state machine |
13//! | [`udp`] | `UdpNeighborDiscovery` — UDP multicast neighbor discovery (requires `udp-hello` feature) |
14//! | [`probe`] | SWIM direct/indirect probe packet builders and parsers |
15//!
16//! ## Adding a new link-medium
17//!
18//! To support a new link type (e.g. Ethernet, Bluetooth, LoRa):
19//!
20//! 1. Create a new file in this module (e.g. `ether.rs`).
21//! 2. Implement [`medium::LinkMedium`] for your medium struct — this provides
22//! link-specific face creation, hello Data signing, and address extraction.
23//! 3. Define a type alias: `pub type EtherNeighborDiscovery = HelloProtocol<YourMedium>;`
24//! 4. Re-export it from this `mod.rs` and from the crate root (`lib.rs`).
25//!
26//! The generic [`protocol::HelloProtocol<T>`] handles all the shared logic:
27//! hello scheduling, SWIM probes, neighbor lifecycle, gossip diffs. Your
28//! medium only implements the link-specific parts.
29
30pub mod medium;
31pub mod payload;
32pub mod probe;
33pub mod protocol;
34
35#[cfg(feature = "udp-hello")]
36pub mod udp;
37
38#[cfg(all(feature = "ether-nd", target_os = "linux"))]
39pub mod ether;
40
41pub use medium::{HELLO_PREFIX_DEPTH, HELLO_PREFIX_STR, HelloCore, HelloState, LinkMedium};
42pub use payload::{
43 CAP_CONTENT_STORE, CAP_FRAGMENTATION, CAP_SVS, CAP_VALIDATION, DiffEntry, HelloPayload,
44 NeighborDiff, T_ADD_ENTRY, T_CAPABILITIES, T_NEIGHBOR_DIFF, T_NODE_NAME, T_PUBLIC_KEY,
45 T_REMOVE_ENTRY, T_SERVED_PREFIX, T_UNICAST_PORT,
46};
47pub use probe::{
48 DirectProbe, IndirectProbe, build_direct_probe, build_indirect_probe,
49 build_indirect_probe_encoded, build_probe_ack, is_probe_ack, parse_direct_probe,
50 parse_indirect_probe,
51};
52pub use protocol::HelloProtocol;
53
54#[cfg(feature = "udp-hello")]
55pub use udp::UdpNeighborDiscovery;