pub struct SubnetGateway { /* private fields */ }Expand description
Subnet gateway that enforces visibility policy at subnet boundaries.
The gateway reads only header fields — it does not decrypt or modify packet payloads. This is the “causal membrane” that filters traffic between subnets.
Implementations§
Source§impl SubnetGateway
impl SubnetGateway
Sourcepub fn new(
local_subnet: SubnetId,
channel_configs: Arc<ChannelConfigRegistry>,
) -> SubnetGateway
pub fn new( local_subnet: SubnetId, channel_configs: Arc<ChannelConfigRegistry>, ) -> SubnetGateway
Create a new gateway for a subnet, sharing the supplied
ChannelConfigRegistry with the host. The registry is held
behind an Arc so subsequent inserts on the substrate side
flow through to gateway visibility lookups.
Sourcepub fn add_peer(&self, subnet: SubnetId)
pub fn add_peer(&self, subnet: SubnetId)
Add a peer subnet this gateway bridges to. Idempotent —
re-registering the same subnet is a no-op. The Vec is
kept sorted by raw bits on insert so Self::peer_subnets
can return a plain clone without re-sorting.
Sourcepub fn peer_subnets(&self) -> Vec<SubnetId>
pub fn peer_subnets(&self) -> Vec<SubnetId>
Snapshot of every peer subnet currently bridged to, sorted by raw bits for stable operator-tool output.
Sourcepub fn export_channel(&self, channel_hash: u16, targets: Vec<SubnetId>)
pub fn export_channel(&self, channel_hash: u16, targets: Vec<SubnetId>)
Export a channel to specific subnets.
Sourcepub fn exports(&self) -> Vec<(u16, Vec<SubnetId>)>
pub fn exports(&self) -> Vec<(u16, Vec<SubnetId>)>
Snapshot of the export table as (channel_hash, targets)
pairs, sorted by channel_hash for stable output. Used by
operator tooling (net gateway exports) to render the
current set of explicit cross-subnet allow-rules.
Sourcepub fn exports_for_channel(&self, channel_hash: u16) -> Option<Vec<SubnetId>>
pub fn exports_for_channel(&self, channel_hash: u16) -> Option<Vec<SubnetId>>
Look up the export targets for a single channel_hash, or
None if the channel is not in the export table. Used by
net gateway export <channel> to render the current
allow-list before an operator mutates it.
Sourcepub fn record_forward(&self)
pub fn record_forward(&self)
Record a forward decision that bypassed the gateway’s
own should_forward entrypoint (e.g. an inline
publish-fanout visibility check on MeshNode). Lets
gateway counters reflect every visibility decision the
host node makes, not just the ones routed through
should_forward.
Sourcepub fn record_drop(&self, _reason: DropReason)
pub fn record_drop(&self, _reason: DropReason)
Companion to Self::record_forward — drops a packet
the host visibility check rejected.
Sourcepub fn local_subnet(&self) -> SubnetId
pub fn local_subnet(&self) -> SubnetId
Get this gateway’s local subnet.
Sourcepub fn should_forward(
&self,
source_subnet: SubnetId,
dest_subnet: SubnetId,
channel_hash: u16,
hop_ttl: u8,
hop_count: u8,
) -> ForwardDecision
pub fn should_forward( &self, source_subnet: SubnetId, dest_subnet: SubnetId, channel_hash: u16, hop_ttl: u8, hop_count: u8, ) -> ForwardDecision
Make a forwarding decision for a packet crossing this gateway.
Reads only header fields: subnet_id, channel_hash, hop_ttl, hop_count.
No decryption, no payload inspection.
Sourcepub fn forwarded_count(&self) -> u64
pub fn forwarded_count(&self) -> u64
Get the number of forwarded packets.
Sourcepub fn dropped_count(&self) -> u64
pub fn dropped_count(&self) -> u64
Get the number of dropped packets.