DiscoveryContext

Trait DiscoveryContext 

Source
pub trait DiscoveryContext: Send + Sync {
    // Required methods
    fn alloc_face_id(&self) -> FaceId;
    fn add_face(&self, face: Arc<dyn ErasedFace>) -> FaceId;
    fn remove_face(&self, face_id: FaceId);
    fn add_fib_entry(
        &self,
        prefix: &Name,
        nexthop: FaceId,
        cost: u32,
        owner: ProtocolId,
    );
    fn remove_fib_entry(
        &self,
        prefix: &Name,
        nexthop: FaceId,
        owner: ProtocolId,
    );
    fn remove_fib_entries_by_owner(&self, owner: ProtocolId);
    fn neighbors(&self) -> Arc<dyn NeighborTableView>;
    fn update_neighbor(&self, update: NeighborUpdate);
    fn send_on(&self, face_id: FaceId, pkt: Bytes);
    fn now(&self) -> Instant;
}
Expand description

Narrow interface through which discovery protocols mutate engine state.

The engine implements this trait on a context struct that holds Arc references to the face table, FIB, and neighbor table. Protocol implementations only see this interface, making them easy to unit-test with a stub context.

Required Methods§

Source

fn alloc_face_id(&self) -> FaceId

Allocate a unique FaceId from the engine’s face table.

Discovery protocols call this before constructing a face object (e.g. [NamedEtherFace::new]) that requires an ID at construction time.

Source

fn add_face(&self, face: Arc<dyn ErasedFace>) -> FaceId

Add a dynamically created face to the engine.

Returns the FaceId assigned by the face table. The engine spawns recv/send tasks and begins forwarding through the face immediately.

Source

fn remove_face(&self, face_id: FaceId)

Remove a face from the engine, stopping its tasks.

Source

fn add_fib_entry( &self, prefix: &Name, nexthop: FaceId, cost: u32, owner: ProtocolId, )

Install a FIB route owned by owner.

Routes tagged with a ProtocolId can be bulk-removed via [remove_fib_entries_by_owner] when the protocol shuts down or reconfigures.

Source

fn remove_fib_entry(&self, prefix: &Name, nexthop: FaceId, owner: ProtocolId)

Remove a single FIB nexthop.

Source

fn remove_fib_entries_by_owner(&self, owner: ProtocolId)

Remove every FIB route installed by owner.

Source

fn neighbors(&self) -> Arc<dyn NeighborTableView>

Read access to the engine-owned neighbor table.

Source

fn update_neighbor(&self, update: NeighborUpdate)

Apply a mutation to the engine-owned neighbor table.

Source

fn send_on(&self, face_id: FaceId, pkt: Bytes)

Send raw bytes directly on a face, bypassing the pipeline.

Used by discovery protocols to transmit hello packets and probes without entering the forwarding plane.

Source

fn now(&self) -> Instant

Current monotonic time.

Implementors§