Skip to main content

SubnetGateway

Struct SubnetGateway 

Source
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

Source

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.

Source

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.

Source

pub fn peer_subnets(&self) -> Vec<SubnetId>

Snapshot of every peer subnet currently bridged to, sorted by raw bits for stable operator-tool output.

Source

pub fn export_channel(&self, channel_hash: u16, targets: Vec<SubnetId>)

Export a channel to specific subnets.

Source

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.

Source

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.

Source

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.

Source

pub fn record_drop(&self, _reason: DropReason)

Companion to Self::record_forward — drops a packet the host visibility check rejected.

Source

pub fn local_subnet(&self) -> SubnetId

Get this gateway’s local subnet.

Source

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.

Source

pub fn forwarded_count(&self) -> u64

Get the number of forwarded packets.

Source

pub fn dropped_count(&self) -> u64

Get the number of dropped packets.

Trait Implementations§

Source§

impl Debug for SubnetGateway

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more