pub struct Stack<'d> { /* private fields */ }Expand description
A network stack.
This is a handle to the stack created by Stack::new. It’s Copy, so
you can pass it by value instead of by reference.
Implementations§
Source§impl<'d> Stack<'d>
impl<'d> Stack<'d>
Sourcepub fn new(
storage: &'d mut StackStorage<'d>,
random_seed: u64,
) -> (Self, Runner<'d>)
pub fn new( storage: &'d mut StackStorage<'d>, random_seed: u64, ) -> (Self, Runner<'d>)
Create a new network stack.
The stack starts out with no interfaces: add them with
add_iface.
Sourcepub fn iface(&self, handle: IfaceHandle) -> Iface<'d>
pub fn iface(&self, handle: IfaceHandle) -> Iface<'d>
Get an interface by its handle.
§Panics
Panics if the handle does not belong to an interface on this stack.
Sourcepub fn remove_iface(&self, handle: IfaceHandle)
pub fn remove_iface(&self, handle: IfaceHandle)
Remove an interface from the stack.
Its addresses, routes and neighbor cache entries go with it. Sockets bound to one of its addresses are not closed, they just stop receiving.
§Panics
Panics if the handle does not belong to an interface on this stack.
Sourcepub fn hostname<R>(&self, f: impl FnOnce(Option<&str>) -> R) -> R
pub fn hostname<R>(&self, f: impl FnOnce(Option<&str>) -> R) -> R
The stack’s hostname, or None if not set.
Sourcepub fn set_hostname(&self, hostname: &str)
pub fn set_hostname(&self, hostname: &str)
Set the stack’s hostname.
If set, it is sent to the DHCP server in outgoing DHCP messages, as the host name option.
An empty string clears the hostname.
§Panics
Panics if hostname is longer than 63 bytes.
Sourcepub fn neighbor_cache(&self) -> NeighborCache<'d>
pub fn neighbor_cache(&self) -> NeighborCache<'d>
The stack’s neighbor cache, shared by all interfaces.
Sourcepub fn set_dns_servers(&self, servers: &[IpAddress])
pub fn set_dns_servers(&self, servers: &[IpAddress])
Set the DNS servers to use, on top of the ones learned from DHCPv4.
The runner keeps the DNS client’s server list in step with the DHCPv4 leases of every interface. The servers set here are used in addition to those, and come first.