net-mumu 0.2.0-rc.3

Network tools plugin for the Lava language
Documentation
// LOCAL/src/lldp/mod.rs
// src/lldp/mod.rs
//
// LLDP/CDP module facade.
//
// This module wires together the LLDP/CDP components:
//   - options.rs  : public API options (LldpOptions / LldpMode)
//   - proto/      : protocol enum (DiscoveryProtocol)
//   - iterator.rs : LldpEngine trait + iterator <-> transform adapters
//   - capture.rs  : raw frame capture (AF_PACKET / BPF, platform-specific)
//   - parse.rs    : LLDP/CDP TLV parsing into rows (used by the engine)
//   - table.rs    : neighbor table with TTL and change detection
//   - engine.rs   : real engine (Linux listen mode)
//   - stub.rs     : synthetic stream (explicitly opt-in)
//
// Public surface used by the plugin bridge (src/bridge.rs):
//   * spawn_iterator(opts: LldpOptions) -> IteratorHandle
//   * iter_to_transform(handle: IteratorHandle) -> Box<FunctionValue>
//   * LldpMode / LldpOptions
//   * DiscoveryProtocol
//
// POLICY:
//   • **Engine by default.** We only use the stub when `opts.stub == true` or
//     the environment variable `MUMU_LLDP_USE_STUB` is present (test/dev rigs).
//   • This prevents silent stubbing in production pipelines.
//
// (c) 2025 — MIT/Apache-2.0

mod options;
pub mod proto;

mod iterator;
mod capture;
mod parse;
mod table;
mod engine;
mod stub;
mod row; // keep the internal row module visible to submodules

pub use options::{LldpMode, LldpOptions};
pub use iterator::iter_to_transform;

// Re-export LldpRow for external users of the library. Not referenced inside
// this crate directly, so suppress the "unused import" warning here.
#[allow(unused_imports)]
pub use row::LldpRow;

pub fn spawn_iterator(opts: LldpOptions) -> mumu::parser::types::IteratorHandle {
    let env_force_stub = std::env::var_os("MUMU_LLDP_USE_STUB").is_some();

    // Engine-first: only route to stub when explicitly requested.
    if env_force_stub || opts.stub {
        return stub::spawn_iterator(opts);
    }

    engine::spawn_iterator(opts)
}