Struct smoltcp::iface::InterfaceBuilder
source · pub struct InterfaceBuilder<'a, DeviceT: for<'d> Device<'d>> { /* private fields */ }
Expand description
A builder structure used for creating a network interface.
Implementations§
source§impl<'a, DeviceT> InterfaceBuilder<'a, DeviceT>where
DeviceT: for<'d> Device<'d>,
impl<'a, DeviceT> InterfaceBuilder<'a, DeviceT>where
DeviceT: for<'d> Device<'d>,
sourcepub fn new<SocketsT>(device: DeviceT, sockets: SocketsT) -> Selfwhere
SocketsT: Into<ManagedSlice<'a, SocketStorage<'a>>>,
pub fn new<SocketsT>(device: DeviceT, sockets: SocketsT) -> Selfwhere
SocketsT: Into<ManagedSlice<'a, SocketStorage<'a>>>,
Create a builder used for creating a network interface using the given device and address.
Examples
use smoltcp::iface::{InterfaceBuilder, NeighborCache};
use smoltcp::wire::{EthernetAddress, IpCidr, IpAddress};
let device = // ...
let hw_addr = // ...
let neighbor_cache = // ...
let ip_addrs = // ...
let iface = InterfaceBuilder::new(device, vec![])
.hardware_addr(hw_addr.into())
.neighbor_cache(neighbor_cache)
.ip_addrs(ip_addrs)
.finalize();
sourcepub fn random_seed(self, random_seed: u64) -> Self
pub fn random_seed(self, random_seed: u64) -> Self
Set the random seed for this interface.
It is strongly recommended that the random seed is different on each boot, to avoid problems with TCP port/sequence collisions.
The seed doesn’t have to be cryptographically secure.
sourcepub fn hardware_addr(self, addr: HardwareAddress) -> Self
pub fn hardware_addr(self, addr: HardwareAddress) -> Self
Set the Hardware address the interface will use. See also hardware_addr.
Panics
This function panics if the address is not unicast.
sourcepub fn pan_id(self, pan_id: Ieee802154Pan) -> Self
pub fn pan_id(self, pan_id: Ieee802154Pan) -> Self
Set the IEEE802.15.4 PAN ID the interface will use.
NOTE: we use the same PAN ID for destination and source.
sourcepub fn ip_addrs<T>(self, ip_addrs: T) -> Selfwhere
T: Into<ManagedSlice<'a, IpCidr>>,
pub fn ip_addrs<T>(self, ip_addrs: T) -> Selfwhere
T: Into<ManagedSlice<'a, IpCidr>>,
sourcepub fn any_ip(self, enabled: bool) -> Self
pub fn any_ip(self, enabled: bool) -> Self
Enable or disable the AnyIP capability, allowing packets to be received locally on IPv4 addresses other than the interface’s configured ip_addrs. When AnyIP is enabled and a route prefix in routes specifies one of the interface’s ip_addrs as its gateway, the interface will accept packets addressed to that prefix.
IPv6
This option is not available or required for IPv6 as packets sent to the interface are not filtered by IPv6 address.
sourcepub fn routes<T>(self, routes: T) -> InterfaceBuilder<'a, DeviceT>where
T: Into<Routes<'a>>,
pub fn routes<T>(self, routes: T) -> InterfaceBuilder<'a, DeviceT>where
T: Into<Routes<'a>>,
Set the IP routes the interface will use. See also routes.
sourcepub fn ipv4_multicast_groups<T>(self, ipv4_multicast_groups: T) -> Selfwhere
T: Into<ManagedMap<'a, Ipv4Address, ()>>,
pub fn ipv4_multicast_groups<T>(self, ipv4_multicast_groups: T) -> Selfwhere
T: Into<ManagedMap<'a, Ipv4Address, ()>>,
Provide storage for multicast groups.
Join multicast groups by calling join_multicast_group()
on an Interface
.
Using join_multicast_group()
will send initial membership reports.
A previously destroyed interface can be recreated by reusing the multicast group
storage, i.e. providing a non-empty storage to ipv4_multicast_groups()
.
Note that this way initial membership reports are not sent.
sourcepub fn neighbor_cache(self, neighbor_cache: NeighborCache<'a>) -> Self
pub fn neighbor_cache(self, neighbor_cache: NeighborCache<'a>) -> Self
Set the Neighbor Cache the interface will use.