pub struct TransportEngine { /* private fields */ }Expand description
The core transport/routing engine.
Maintains routing tables and processes packets without performing any I/O.
Returns Vec<TransportAction> that the caller must execute.
Implementations§
Source§impl TransportEngine
impl TransportEngine
pub fn new(config: TransportConfig) -> Self
pub fn register_interface(&mut self, info: InterfaceInfo)
pub fn deregister_interface(&mut self, id: InterfaceId)
pub fn register_destination(&mut self, dest_hash: [u8; 16], dest_type: u8)
pub fn deregister_destination(&mut self, dest_hash: &[u8; 16])
pub fn has_path(&self, dest_hash: &[u8; 16]) -> bool
pub fn hops_to(&self, dest_hash: &[u8; 16]) -> Option<u8>
pub fn next_hop(&self, dest_hash: &[u8; 16]) -> Option<[u8; 16]>
pub fn next_hop_interface(&self, dest_hash: &[u8; 16]) -> Option<InterfaceId>
pub fn mark_path_unresponsive(&mut self, dest_hash: &[u8; 16])
pub fn mark_path_responsive(&mut self, dest_hash: &[u8; 16])
pub fn path_is_unresponsive(&self, dest_hash: &[u8; 16]) -> bool
pub fn expire_path(&mut self, dest_hash: &[u8; 16])
pub fn register_link(&mut self, link_id: [u8; 16], entry: LinkEntry)
pub fn validate_link(&mut self, link_id: &[u8; 16])
pub fn remove_link(&mut self, link_id: &[u8; 16])
Sourcepub fn blackhole_identity(
&mut self,
identity_hash: [u8; 16],
now: f64,
duration_hours: Option<f64>,
reason: Option<String>,
)
pub fn blackhole_identity( &mut self, identity_hash: [u8; 16], now: f64, duration_hours: Option<f64>, reason: Option<String>, )
Add an identity hash to the blackhole list.
Sourcepub fn unblackhole_identity(&mut self, identity_hash: &[u8; 16]) -> bool
pub fn unblackhole_identity(&mut self, identity_hash: &[u8; 16]) -> bool
Remove an identity hash from the blackhole list.
Sourcepub fn is_blackholed(&self, identity_hash: &[u8; 16], now: f64) -> bool
pub fn is_blackholed(&self, identity_hash: &[u8; 16], now: f64) -> bool
Check if an identity hash is blackholed (and not expired).
Sourcepub fn blackholed_entries(
&self,
) -> impl Iterator<Item = (&[u8; 16], &BlackholeEntry)>
pub fn blackholed_entries( &self, ) -> impl Iterator<Item = (&[u8; 16], &BlackholeEntry)>
Get all blackhole entries (for queries).
Sourcepub fn handle_tunnel(
&mut self,
tunnel_id: [u8; 32],
interface: InterfaceId,
now: f64,
) -> Vec<TransportAction>
pub fn handle_tunnel( &mut self, tunnel_id: [u8; 32], interface: InterfaceId, now: f64, ) -> Vec<TransportAction>
Handle a validated tunnel synthesis — create new or reattach.
Returns actions for any restored paths.
Sourcepub fn synthesize_tunnel(
&self,
identity: &Identity,
interface_id: InterfaceId,
rng: &mut dyn Rng,
) -> Vec<TransportAction>
pub fn synthesize_tunnel( &self, identity: &Identity, interface_id: InterfaceId, rng: &mut dyn Rng, ) -> Vec<TransportAction>
Synthesize a tunnel on an interface.
identity: the transport identity (must have private key for signing)
interface_id: which interface to send the synthesis on
rng: random number generator
Returns TunnelSynthesize action to send the synthesis packet.
Sourcepub fn void_tunnel_interface(&mut self, tunnel_id: &[u8; 32])
pub fn void_tunnel_interface(&mut self, tunnel_id: &[u8; 32])
Void a tunnel’s interface connection (tunnel disconnected).
Sourcepub fn tunnel_table(&self) -> &TunnelTable
pub fn tunnel_table(&self) -> &TunnelTable
Access the tunnel table for queries.
Sourcepub fn handle_inbound(
&mut self,
raw: &[u8],
iface: InterfaceId,
now: f64,
rng: &mut dyn Rng,
) -> Vec<TransportAction>
pub fn handle_inbound( &mut self, raw: &[u8], iface: InterfaceId, now: f64, rng: &mut dyn Rng, ) -> Vec<TransportAction>
Process an inbound raw packet from a network interface.
Returns a list of actions for the caller to execute.
Sourcepub fn handle_outbound(
&mut self,
packet: &RawPacket,
dest_type: u8,
attached_interface: Option<InterfaceId>,
now: f64,
) -> Vec<TransportAction>
pub fn handle_outbound( &mut self, packet: &RawPacket, dest_type: u8, attached_interface: Option<InterfaceId>, now: f64, ) -> Vec<TransportAction>
Route an outbound packet.
Sourcepub fn tick(&mut self, now: f64, _rng: &mut dyn Rng) -> Vec<TransportAction>
pub fn tick(&mut self, now: f64, _rng: &mut dyn Rng) -> Vec<TransportAction>
Periodic maintenance. Call regularly (e.g., every 250ms).
Sourcepub fn handle_path_request(
&mut self,
data: &[u8],
interface_id: InterfaceId,
now: f64,
) -> Vec<TransportAction>
pub fn handle_path_request( &mut self, data: &[u8], interface_id: InterfaceId, now: f64, ) -> Vec<TransportAction>
Handle an incoming path request.
Sourcepub fn path_table_entries(
&self,
) -> impl Iterator<Item = (&[u8; 16], &PathEntry)>
pub fn path_table_entries( &self, ) -> impl Iterator<Item = (&[u8; 16], &PathEntry)>
Iterate over all path table entries.
Sourcepub fn interface_count(&self) -> usize
pub fn interface_count(&self) -> usize
Number of registered interfaces.
Sourcepub fn link_table_count(&self) -> usize
pub fn link_table_count(&self) -> usize
Number of link table entries.
Sourcepub fn rate_limiter(&self) -> &AnnounceRateLimiter
pub fn rate_limiter(&self) -> &AnnounceRateLimiter
Access the rate limiter for reading rate table entries.
Sourcepub fn interface_info(&self, id: &InterfaceId) -> Option<&InterfaceInfo>
pub fn interface_info(&self, id: &InterfaceId) -> Option<&InterfaceInfo>
Get interface info by id.
Sourcepub fn drop_all_via(&mut self, transport_hash: &[u8; 16]) -> usize
pub fn drop_all_via(&mut self, transport_hash: &[u8; 16]) -> usize
Drop all paths that route via a given transport hash.
Sourcepub fn drop_announce_queues(&mut self)
pub fn drop_announce_queues(&mut self)
Drop all pending announce retransmissions and bandwidth queues.
Sourcepub fn identity_hash(&self) -> Option<&[u8; 16]>
pub fn identity_hash(&self) -> Option<&[u8; 16]>
Get the transport identity hash.
Sourcepub fn transport_enabled(&self) -> bool
pub fn transport_enabled(&self) -> bool
Whether transport is enabled.
Sourcepub fn config(&self) -> &TransportConfig
pub fn config(&self) -> &TransportConfig
Access the transport configuration.
Sourcepub fn get_path_table(
&self,
max_hops: Option<u8>,
) -> Vec<([u8; 16], f64, [u8; 16], u8, f64, String)>
pub fn get_path_table( &self, max_hops: Option<u8>, ) -> Vec<([u8; 16], f64, [u8; 16], u8, f64, String)>
Get path table entries as tuples for management queries. Returns (dest_hash, timestamp, next_hop, hops, expires, interface_name).