ndn_discovery/
lib.rs

1//! # ndn-discovery — Pluggable neighbor and service discovery
2//!
3//! Provides the [`DiscoveryProtocol`] and [`DiscoveryContext`] traits that
4//! decouple discovery logic from the engine core, along with supporting types
5//! and the [`NoDiscovery`] null object for routers that do not need automatic
6//! neighbor finding.
7//!
8//! ## Architecture
9//!
10//! The engine owns a single `Arc<dyn DiscoveryProtocol>` field.  Protocols
11//! observe face lifecycle events and inbound packets via hooks; they mutate
12//! engine state (faces, FIB, neighbor table) exclusively through the narrow
13//! [`DiscoveryContext`] interface.
14//!
15//! Multiple protocols can run simultaneously via [`CompositeDiscovery`], which
16//! validates that their claimed name prefixes do not overlap at construction
17//! time and routes inbound packets by prefix match.
18//!
19//! ## Crate layout
20//!
21//! **Framework (crate root):** Core traits and shared infrastructure.
22//!
23//! | Module | Contents |
24//! |--------|----------|
25//! | [`protocol`]        | `DiscoveryProtocol` trait, `ProtocolId` |
26//! | [`context`]         | `DiscoveryContext`, `NeighborTableView` traits |
27//! | [`neighbor`]        | `NeighborTable`, `NeighborEntry`, `NeighborState`, `NeighborUpdate` |
28//! | [`mac_addr`]        | `MacAddr` — link-layer address shared between discovery and face layer |
29//! | [`no_discovery`]    | `NoDiscovery` — no-op protocol for standalone deployments |
30//! | [`composite`]       | `CompositeDiscovery` — runs multiple protocols simultaneously |
31//! | [`backoff`]         | `BackoffConfig`, `BackoffState` — exponential backoff with jitter |
32//! | [`config`]          | `DiscoveryConfig`, `DiscoveryProfile`, `ServiceDiscoveryConfig` |
33//! | [`scope`]           | Well-known namespace prefixes and link-local scope predicates |
34//! | [`wire`]            | Shared TLV encoding/decoding helpers |
35//!
36//! **Protocol implementations (subdirectories):**
37//!
38//! | Module | Contents |
39//! |--------|----------|
40//! | [`hello`]            | SWIM/Hello protocol family: payload codec, state machine, UDP impl |
41//! | [`hello::probe`]     | SWIM direct/indirect probe packet builders and parsers |
42//! | [`gossip`]           | Epidemic gossip and SVS service-discovery sync |
43//! | [`service_discovery`]| Service record publication and browsing (`/ndn/local/sd/services/`) |
44//! | [`strategy`]         | `NeighborProbeStrategy` trait and scheduler implementations |
45//! | [`prefix_announce`]  | Service record publisher and browser |
46
47#![allow(missing_docs)]
48
49pub mod backoff;
50pub mod composite;
51pub mod config;
52pub mod context;
53pub mod gossip;
54pub mod hello;
55pub mod mac_addr;
56pub mod neighbor;
57pub mod no_discovery;
58pub mod prefix_announce;
59pub mod protocol;
60pub mod scope;
61pub mod service_discovery;
62pub mod strategy;
63pub mod wire;
64
65pub use backoff::{BackoffConfig, BackoffState};
66pub use composite::CompositeDiscovery;
67pub use config::{
68    DiscoveryConfig, DiscoveryProfile, DiscoveryScope, HelloStrategyKind, PrefixAnnouncementMode,
69    ServiceDiscoveryConfig, ServiceValidationPolicy,
70};
71pub use context::{DiscoveryContext, NeighborTableView};
72pub use gossip::{EpidemicGossip, SvsServiceDiscovery};
73#[cfg(feature = "udp-hello")]
74pub use hello::UdpNeighborDiscovery;
75#[cfg(all(feature = "ether-nd", target_os = "linux"))]
76pub use hello::ether::EtherNeighborDiscovery;
77pub use hello::{
78    CAP_CONTENT_STORE, CAP_FRAGMENTATION, CAP_SVS, CAP_VALIDATION, DiffEntry, HelloPayload,
79    NeighborDiff, T_ADD_ENTRY, T_CAPABILITIES, T_NEIGHBOR_DIFF, T_NODE_NAME, T_REMOVE_ENTRY,
80    T_SERVED_PREFIX,
81};
82pub use hello::{
83    DirectProbe, IndirectProbe, build_direct_probe, build_indirect_probe,
84    build_indirect_probe_encoded, build_probe_ack, is_probe_ack, parse_direct_probe,
85    parse_indirect_probe,
86};
87pub use hello::{HelloCore, HelloProtocol, HelloState, LinkMedium};
88pub use mac_addr::MacAddr;
89pub use neighbor::{NeighborEntry, NeighborState, NeighborTable, NeighborUpdate};
90pub use no_discovery::NoDiscovery;
91pub use prefix_announce::{ServiceRecord, build_browse_interest, make_record_name};
92pub use protocol::{DiscoveryProtocol, InboundMeta, LinkAddr, ProtocolId};
93pub use scope::{
94    global_root, gossip_prefix, hello_prefix, is_link_local, is_nd_packet, is_sd_packet,
95    mgmt_prefix, nd_root, ndn_local, peers_prefix, probe_direct, probe_via, routing_lsa,
96    routing_prefix, scope_root, sd_services, sd_updates, site_root,
97};
98pub use service_discovery::{ServiceDiscoveryProtocol, decode_peer_list};
99pub use strategy::composite::CompositeStrategy;
100pub use strategy::{
101    BackoffScheduler, NeighborProbeStrategy, PassiveScheduler, ProbeRequest, ReactiveScheduler,
102    SwimScheduler, TriggerEvent, build_strategy,
103};