Skip to main content

NetStack

Struct NetStack 

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

Host user-space NAT network stack bridged to wasm_driver_net_*.

Implementations§

Source§

impl NetStack

Source

pub fn new(cfg: NetConfig, raise_irq: Arc<dyn Fn() + Send + Sync>) -> Arc<Self> ⓘ

Construct a NetStack, pre-reading host DNS resolvers from /etc/resolv.conf.

Source

pub fn new_with_resolvers( cfg: NetConfig, resolvers: Vec<SocketAddrV4>, monitor: Option<Arc<Monitor>>, raise_irq: Arc<dyn Fn() + Send + Sync>, ) -> Arc<Self> ⓘ

Construct a NetStack using pre-loaded DNS resolvers (allows calling apply_landlock before spawning unkernel-net-timer so every thread inherits Landlock).

Source

pub fn new_with_tls( cfg: NetConfig, resolvers: Vec<SocketAddrV4>, monitor: Option<Arc<Monitor>>, vmi_tls: Option<Arc<VmiTlsContext>>, mitm_ca: Option<Arc<MitmCa>>, raise_irq: Arc<dyn Fn() + Send + Sync>, ) -> Arc<Self> ⓘ

Construct a NetStack with optional Method-1 VMI TLS key extraction and/or Method-2 MITM CA.

Source

pub fn new_with_identity( cfg: NetConfig, resolvers: Vec<SocketAddrV4>, monitor: Option<Arc<Monitor>>, vmi_tls: Option<Arc<VmiTlsContext>>, mitm_ca: Option<Arc<MitmCa>>, guest_mac: [u8; 6], guest_ip: u32, gateway_only_arp: bool, frame_sink: Option<Arc<dyn Fn(Vec<u8>) + Send + Sync>>, raise_irq: Arc<dyn Fn() + Send + Sync>, ) -> Arc<Self> ⓘ

Construct a NetStack with custom guest MAC/IP identity (used as a per-port NAT uplink behind a crate::switch::VirtualSwitch).

Source

pub fn mac(&self) -> [u8; 6]

Source

pub fn rx_len(&self) -> usize

Source

pub fn recv_frame(&self) -> Option<Vec<u8>>

Source

pub fn send_frame(self: &Arc<Self>, frame: &[u8])

Source

pub fn shutdown(&self)

Auto Trait Implementations§

§

impl !Freeze for NetStack

§

impl !RefUnwindSafe for NetStack

§

impl !UnwindSafe for NetStack

§

impl Forget for NetStack

§

impl Move for NetStack

§

impl Send for NetStack
where RawVecInner: Send, Arc<Mutex<File>>: Send, Arc<Monitor>: Send, Arc<VmiTlsContext>: Send, Arc<MitmCa>: Send, Arc<dyn Fn(Vec<u8>) + Send + Sync>: Send, Mutex<NetInner>: Send, Arc<dyn Fn() + Send + Sync>: Send, Atomic<u16>: Send, Atomic<bool>: Send,

§

impl Sync for NetStack
where RawVecInner: Sync, Arc<Mutex<File>>: Sync, Arc<Monitor>: Sync, Arc<VmiTlsContext>: Sync, Arc<MitmCa>: Sync, Arc<dyn Fn(Vec<u8>) + Send + Sync>: Sync, Mutex<NetInner>: Sync, Arc<dyn Fn() + Send + Sync>: Sync, Atomic<u16>: Sync, Atomic<bool>: Sync,

§

impl Unpin for NetStack
where *const u8 is !null: Unpin, Arc<Mutex<File>>: Unpin, Arc<Monitor>: Unpin, Arc<VmiTlsContext>: Unpin, Arc<MitmCa>: Unpin, Arc<dyn Fn(Vec<u8>) + Send + Sync>: Unpin, Align4<u32>: Unpin, Align1<u8>: Unpin, Arc<Mutex<TcpConn>>: Unpin, Arc<dyn Fn() + Send + Sync>: Unpin, Align2<u16>: Unpin,

§

impl UnsafeUnpin for NetStack

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.