LinkMedium

Trait LinkMedium 

Source
pub trait LinkMedium:
    Send
    + Sync
    + 'static {
    // Required methods
    fn protocol_id(&self) -> ProtocolId;
    fn build_hello_data(&self, core: &HelloCore, interest_name: &Name) -> Bytes;
    fn handle_hello_interest(
        &self,
        raw: &Bytes,
        incoming_face: FaceId,
        meta: &InboundMeta,
        core: &HelloCore,
        ctx: &dyn DiscoveryContext,
    ) -> bool;
    fn verify_and_ensure_peer(
        &self,
        raw: &Bytes,
        payload: &HelloPayload,
        meta: &InboundMeta,
        core: &HelloCore,
        ctx: &dyn DiscoveryContext,
    ) -> Option<(Name, Option<FaceId>)>;
    fn send_multicast(&self, ctx: &dyn DiscoveryContext, pkt: Bytes);
    fn is_multicast_face(&self, face_id: FaceId) -> bool;
    fn on_face_down(
        &self,
        face_id: FaceId,
        state: &mut HelloState,
        ctx: &dyn DiscoveryContext,
    );
    fn on_peer_removed(&self, entry: &NeighborEntry, state: &mut HelloState);
}
Expand description

Abstraction over link-layer differences between discovery protocols.

Implementations provide the link-specific operations (face creation, address extraction, packet signing) while the shared SWIM/hello/probe state machine lives in HelloProtocol<T>.

Required Methods§

Source

fn protocol_id(&self) -> ProtocolId

Protocol identifier (e.g. "udp-nd", "ether-nd").

Source

fn build_hello_data(&self, core: &HelloCore, interest_name: &Name) -> Bytes

Build the hello Data reply for the given Interest name.

UDP signs with Ed25519; Ethernet uses an unsigned placeholder.

Source

fn handle_hello_interest( &self, raw: &Bytes, incoming_face: FaceId, meta: &InboundMeta, core: &HelloCore, ctx: &dyn DiscoveryContext, ) -> bool

Handle a hello Interest (link-specific dispatch).

Extracts the source address from meta, performs any link-specific actions (e.g. passive detection for new MACs), builds and sends the reply via ctx.send_on. Returns true if the Interest was consumed.

Source

fn verify_and_ensure_peer( &self, raw: &Bytes, payload: &HelloPayload, meta: &InboundMeta, core: &HelloCore, ctx: &dyn DiscoveryContext, ) -> Option<(Name, Option<FaceId>)>

Verify signature (if applicable), extract source address, and ensure a unicast face to the peer exists.

Called by HelloProtocol::handle_hello_data after the shared code has parsed the hello Data, extracted the nonce, and decoded the HelloPayload.

Returns (responder_name, optional_face_id) on success, or None to silently drop the packet.

Source

fn send_multicast(&self, ctx: &dyn DiscoveryContext, pkt: Bytes)

Send a packet on all multicast face(s).

Source

fn is_multicast_face(&self, face_id: FaceId) -> bool

Whether face_id is one of this medium’s multicast faces.

Source

fn on_face_down( &self, face_id: FaceId, state: &mut HelloState, ctx: &dyn DiscoveryContext, )

Handle face-down event (clean up link-specific state).

Source

fn on_peer_removed(&self, entry: &NeighborEntry, state: &mut HelloState)

Clean up link-specific state when a peer is being removed (reached miss_limit in the liveness state machine).

Implementors§