pub struct NetStack { /* private fields */ }Expand description
A userspace TCP/IP network stack.
Implementations§
Source§impl NetStack
impl NetStack
Sourcepub fn new(wg_tunnel: Arc<WireGuardTunnel>) -> Arc<Self>
pub fn new(wg_tunnel: Arc<WireGuardTunnel>) -> Arc<Self>
Create a new network stack backed by a WireGuard tunnel.
Sourcepub fn create_tcp_socket(&self) -> SocketHandle
pub fn create_tcp_socket(&self) -> SocketHandle
Create a new TCP socket and return its handle.
Sourcepub fn connect(&self, handle: SocketHandle, addr: SocketAddr) -> Result<()>
pub fn connect(&self, handle: SocketHandle, addr: SocketAddr) -> Result<()>
Connect a TCP socket to the given address.
Sourcepub fn is_connected(&self, handle: SocketHandle) -> bool
pub fn is_connected(&self, handle: SocketHandle) -> bool
Check if a TCP socket is connected.
Sourcepub fn can_send(&self, handle: SocketHandle) -> bool
pub fn can_send(&self, handle: SocketHandle) -> bool
Check if a TCP socket can send data.
Sourcepub fn can_recv(&self, handle: SocketHandle) -> bool
pub fn can_recv(&self, handle: SocketHandle) -> bool
Check if a TCP socket can receive data.
Sourcepub fn may_send(&self, handle: SocketHandle) -> bool
pub fn may_send(&self, handle: SocketHandle) -> bool
Check if a TCP socket may send data (connection in progress or established).
Sourcepub fn may_recv(&self, handle: SocketHandle) -> bool
pub fn may_recv(&self, handle: SocketHandle) -> bool
Check if a TCP socket may receive data.
Sourcepub fn socket_state(&self, handle: SocketHandle) -> TcpState
pub fn socket_state(&self, handle: SocketHandle) -> TcpState
Get the TCP socket state.
Sourcepub fn send(&self, handle: SocketHandle, data: &[u8]) -> Result<usize>
pub fn send(&self, handle: SocketHandle, data: &[u8]) -> Result<usize>
Send data on a TCP socket.
Sourcepub fn recv(&self, handle: SocketHandle, buffer: &mut [u8]) -> Result<usize>
pub fn recv(&self, handle: SocketHandle, buffer: &mut [u8]) -> Result<usize>
Receive data from a TCP socket.
Sourcepub fn close(&self, handle: SocketHandle)
pub fn close(&self, handle: SocketHandle)
Close a TCP socket.
Sourcepub fn remove_socket(&self, handle: SocketHandle)
pub fn remove_socket(&self, handle: SocketHandle)
Remove a socket from the socket set.
Sourcepub fn poll(&self) -> bool
pub fn poll(&self) -> bool
Poll the network stack, processing packets and updating socket states. Returns true if there was any activity.
Sourcepub fn push_rx_packet(&self, packet: BytesMut)
pub fn push_rx_packet(&self, packet: BytesMut)
Push a received packet (from WireGuard) into the network stack.
Sourcepub async fn run_poll_loop(self: &Arc<Self>) -> Result<()>
pub async fn run_poll_loop(self: &Arc<Self>) -> Result<()>
Run the network stack polling loop.
Auto Trait Implementations§
impl !Freeze for NetStack
impl !RefUnwindSafe for NetStack
impl Send for NetStack
impl Sync for NetStack
impl Unpin for NetStack
impl UnsafeUnpin for NetStack
impl !UnwindSafe for NetStack
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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