pub struct CoreStack { /* private fields */ }Expand description
Internally i/o free userspace network stack built around smoltcp.
Implementations§
Source§impl Netstack
impl Netstack
Sourcepub fn new(ns_config: Config, now: Instant) -> Netstack
pub fn new(ns_config: Config, now: Instant) -> Netstack
Construct a netstack with the given config and starting instant.
§Panics
If ns_config.loopback is set and smoltcp’s iface-max-addr-count (feature flag)
is less than 2.
Sourcepub fn poll_at(&mut self, now: Instant) -> Option<Instant>
pub fn poll_at(&mut self, now: Instant) -> Option<Instant>
Report the next time the netstack should be polled.
Sourcepub fn poll_delay(&mut self, now: Instant) -> Option<Duration>
pub fn poll_delay(&mut self, now: Instant) -> Option<Duration>
Report the amount of time until the netstack should next be polled.
Sourcepub fn process_cmds(&mut self)
pub fn process_cmds(&mut self)
Process all commands available in the command queue.
Sourcepub fn wait_for_cmd_blocking(
&mut self,
timeout: Option<Duration>,
) -> Result<Request, RecvTimeoutError>
pub fn wait_for_cmd_blocking( &mut self, timeout: Option<Duration>, ) -> Result<Request, RecvTimeoutError>
Synchronously block for a single command over the channel.
Sourcepub fn wait_for_cmd(&self) -> impl Future<Output = Option<Request>> + use<>
pub fn wait_for_cmd(&self) -> impl Future<Output = Option<Request>> + use<>
Asynchronously wait for a single command over the channel.
Sourcepub fn direct_set_ips(&mut self, ips: impl IntoIterator<Item = IpAddr>) -> bool
pub fn direct_set_ips(&mut self, ips: impl IntoIterator<Item = IpAddr>) -> bool
Set the IP addresses for this interface.
Loopback addresses are automatically appended if indicated by Config::loopback.
The return value reports whether the operation was successful: if not, it was because there wasn’t enough storage configured in smoltcp’s feature flags for the number of submitted interface IPs.
Sourcepub fn process_one_cmd(&mut self, _: Request)
pub fn process_one_cmd(&mut self, _: Request)
Process a single command.
Sourcepub fn poll_device_io(&mut self, now: Instant, dev: &mut impl Device) -> bool
pub fn poll_device_io(&mut self, now: Instant, dev: &mut impl Device) -> bool
Poll the lower device to send and receive packets, and attempt to complete any blocked socket commands.
Returns whether there were any updates to socket state.
Sourcepub fn poll_device_ingress_async(
&mut self,
cx: &mut Context<'_>,
now: Instant,
dev: Pin<&mut (impl AsyncWakeDevice + Device + Unpin)>,
) -> Poll<bool>
pub fn poll_device_ingress_async( &mut self, cx: &mut Context<'_>, now: Instant, dev: Pin<&mut (impl AsyncWakeDevice + Device + Unpin)>, ) -> Poll<bool>
Poll the device for all synchronously-available packets and process them.
The return value indicates whether packets were consumed and if sockets made progress:
Poll::Pending: no packets were processed because we were waiting for them to arrive from `dev.Poll::Ready(false): we received packets but socket state did not make progressPoll::Ready(true): we received packets and socket state did make progress
When this function returns, it is guaranteed that all packets currently available to
receive from dev have been processed.
Unlike the synchronous poll_device_io, this does not call
drain_tcp_closes: the async driver loop (the netstack Future’s poll) owns that, calling
it once per poll after both ingress and egress have run (so a socket smoltcp drove to Closed
here — which always reports Poll::Ready(true) — is reaped in the same poll cycle). A future
caller that drives this method outside that loop must call drain_tcp_closes itself, or
autonomously-Closed sockets will linger in pending_tcp_closes until the next drain.
Sourcepub fn poll_device_egress_async(
&mut self,
cx: &mut Context<'_>,
now: Instant,
dev: Pin<&mut (impl AsyncWakeDevice + Device + Unpin)>,
) -> Poll<bool>
pub fn poll_device_egress_async( &mut self, cx: &mut Context<'_>, now: Instant, dev: Pin<&mut (impl AsyncWakeDevice + Device + Unpin)>, ) -> Poll<bool>
Send all packets the netstack wants to transmit on the network.
Returns:
Poll::Pendingif no packets could be sent becausedevwasn’t ready (ifAsyncWakeDevice::poll_txreturnsPoll::Pending)Poll::Ready(false)ifdevwas ready but no packets needed to be sentPoll::Ready(true)ifdevwas ready and packets were sent
Sourcepub fn wait_io_async<'stack, 'dev, D>(
&'stack mut self,
now: Instant,
dev: &'dev mut D,
) -> IoPoller<'stack, 'dev, D>
pub fn wait_io_async<'stack, 'dev, D>( &'stack mut self, now: Instant, dev: &'dev mut D, ) -> IoPoller<'stack, 'dev, D>
Attempt to send and receive packets on dev.
The future becomes ready when dev sends or receives packets on the network. All
synchronously-available network I/O is always performed.
Assumes that alarms are handled separately and that now does not advance
over the course of the polled future.
Trait Implementations§
Source§impl HasChannel for Netstack
impl HasChannel for Netstack
Source§fn borrow_channel(&self) -> impl Borrow<WeakSender<Request>> + Send
fn borrow_channel(&self) -> impl Borrow<WeakSender<Request>> + Send
Source§fn command_channel(&self) -> WeakSender<Request>
fn command_channel(&self) -> WeakSender<Request>
Source§fn request_blocking(
&self,
handle: Option<SocketHandle>,
command: impl Into<Command>,
) -> Result<Response, ChannelClosedError>
fn request_blocking( &self, handle: Option<SocketHandle>, command: impl Into<Command>, ) -> Result<Response, ChannelClosedError>
Source§fn request(
&self,
handle: Option<SocketHandle>,
command: impl Into<Command>,
) -> impl Future<Output = Result<Response, Error>> + Send
fn request( &self, handle: Option<SocketHandle>, command: impl Into<Command>, ) -> impl Future<Output = Result<Response, Error>> + Send
Source§fn request_nonblocking(
&self,
handle: Option<SocketHandle>,
command: impl Into<Command>,
) -> Result<(), ChannelClosedError>
fn request_nonblocking( &self, handle: Option<SocketHandle>, command: impl Into<Command>, ) -> Result<(), ChannelClosedError>
Auto Trait Implementations§
impl !UnwindSafe for Netstack
impl Freeze for Netstack
impl RefUnwindSafe for Netstack
impl Send for Netstack
impl Sync for Netstack
impl Unpin for Netstack
impl UnsafeUnpin 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
Source§impl<T> CreateSocket for Twhere
T: HasChannel + Sync,
impl<T> CreateSocket for Twhere
T: HasChannel + Sync,
Source§fn udp_bind_blocking(&self, endpoint: SocketAddr) -> Result<UdpSocket, Error>
fn udp_bind_blocking(&self, endpoint: SocketAddr) -> Result<UdpSocket, Error>
UdpSocket to the given local endpoint.Source§async fn udp_bind(&self, endpoint: SocketAddr) -> Result<UdpSocket, Error>
async fn udp_bind(&self, endpoint: SocketAddr) -> Result<UdpSocket, Error>
UdpSocket to the given local endpoint.Source§fn tcp_listen_blocking(
&self,
local_endpoint: SocketAddr,
) -> Result<TcpListener, Error>
fn tcp_listen_blocking( &self, local_endpoint: SocketAddr, ) -> Result<TcpListener, Error>
TcpListener on the given endpoint.Source§async fn tcp_listen(
&self,
local_endpoint: SocketAddr,
) -> Result<TcpListener, Error>
async fn tcp_listen( &self, local_endpoint: SocketAddr, ) -> Result<TcpListener, Error>
TcpListener on the given endpoint.Source§fn bound_tcp_ports_blocking(&self) -> Result<Vec<u16>, Error>
fn bound_tcp_ports_blocking(&self) -> Result<Vec<u16>, Error>
Source§async fn bound_tcp_ports(&self) -> Result<Vec<u16>, Error>
async fn bound_tcp_ports(&self) -> Result<Vec<u16>, Error>
CreateSocket::bound_tcp_ports_blocking.