Struct MapTunnel

Source
pub struct MapTunnel { /* private fields */ }
Expand description

MAP tunnel implementation supporting both MAP-E and MAP-T

Implementations§

Source§

impl MapTunnel

Source

pub fn new(config: TunnelConfig, protocol_variant: MapProtocol) -> Result<Self>

Create a new MAP tunnel

Source

pub fn add_map_rule(&mut self, rule: MapRule)

Add a MAP rule to the configuration

Source

pub fn calculate_ipv6_address( &self, ipv4_addr: Ipv4Addr, rule: &MapRule, ) -> Result<Ipv6Addr>

Calculate IPv6 address from IPv4 address and MAP rule

Source

pub fn calculate_port_set(&self, psid: u16, rule: &MapRule) -> PortSet

Calculate port set for a given PSID

Source

pub fn extract_psid(&self, ipv4_addr: Ipv4Addr, rule: &MapRule) -> u16

Extract PSID from IPv4 address using MAP rule

Source

pub async fn initialize_addresses(&mut self) -> Result<()>

Initialize local IPv4 address and generate ISATAP address (public for testing)

Source

pub fn encapsulate_ipv4_in_ipv6(&self, ipv4_packet: &[u8]) -> Result<Vec<u8>>

Encapsulate IPv4 packet in IPv6 for MAP-E

Source

pub fn translate_ipv4_to_ipv6(&mut self, ipv4_packet: &[u8]) -> Result<Vec<u8>>

Translate IPv4 packet to IPv6 for MAP-T

Source

pub fn is_port_allowed(&self, port: u16) -> bool

Validate port against assigned port set

Trait Implementations§

Source§

impl Tunnel for MapTunnel

Source§

fn protocol(&self) -> TunnelProtocol

Get the protocol type for this tunnel
Source§

fn config(&self) -> &TunnelConfig

Get the current configuration
Source§

fn state<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TunnelState> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the current tunnel state
Source§

fn metrics<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TunnelMetrics> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get tunnel performance metrics
Source§

fn connect<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Establish the tunnel connection
Source§

fn is_active<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if the tunnel is currently active and usable
Source§

fn disconnect<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Close the tunnel connection
Source§

fn encapsulate<'life0, 'life1, 'async_trait>( &'life0 self, ipv4_packet: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Encapsulate IPv6 packet for transmission over IPv4
Source§

fn decapsulate<'life0, 'life1, 'async_trait>( &'life0 self, packet: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Decapsulate IPv4 packet to extract IPv6 content
Source§

fn send<'life0, 'life1, 'async_trait>( &'life0 mut self, packet: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a packet through the tunnel
Source§

fn receive<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Receive a packet from the tunnel
Source§

fn maintain<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Perform periodic maintenance (keepalive, metrics update, etc.)
Source§

fn local_ipv6_addr<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Ipv6Addr>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the IPv6 address assigned to this tunnel
Source§

fn local_ipv4_addr<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Ipv4Addr>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the IPv4 endpoint address for this tunnel
Source§

fn ping<'life0, 'async_trait>( &'life0 mut self, _timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<Duration>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Test tunnel connectivity with a ping

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,