pub struct Iface<'a, 'd> { /* private fields */ }Expand description
An interface borrowed from a Stack, returned by Stack::iface.
Implementations§
Source§impl<'d> Iface<'_, 'd>
impl<'d> Iface<'_, 'd>
Sourcepub fn capabilities(&self) -> Capabilities
pub fn capabilities(&self) -> Capabilities
The capabilities reported by the device.
Sourcepub fn link_state(&mut self) -> LinkState
pub fn link_state(&mut self) -> LinkState
The link state reported by the device.
Sourcepub fn ip_mtu(&self) -> usize
pub fn ip_mtu(&self) -> usize
The interface’s IP-layer MTU: the device MTU minus the link-layer header,
clamped to what a PacketBuf can carry.
Sourcepub fn poll_tx_timestamp(&mut self) -> Option<TxTimestamp>
pub fn poll_tx_timestamp(&mut self) -> Option<TxTimestamp>
Poll the device for the timestamp of an already-transmitted packet, sent with
PacketMeta::request_timestamp set.
Returns None if no timestamp is available right now, which is also all a
device without transmit timestamping support ever returns. See
Driver::poll_tx_timestamp for what a caller must tolerate: timestamps
arrive an arbitrary time after the packet was sent, possibly out of order, and
possibly never.
Sourcepub fn hardware_addr(&self) -> HardwareAddress
pub fn hardware_addr(&self) -> HardwareAddress
The hardware address of the interface.
Initially the address the device reported when the interface was added.
set_hardware_addr overrides it.
Sourcepub fn set_hardware_addr(&mut self, addr: HardwareAddress)
pub fn set_hardware_addr(&mut self, addr: HardwareAddress)
Set the hardware address of the interface.
The stack starts using it for the frames it sends and for ingress filtering immediately. It does not announce the change on the link, so peers keep the old address in their neighbor caches until it expires. Send a gratuitous ARP or unsolicited neighbor advertisement from a raw socket if that matters.
An IEEE 802.15.4 interface must use an extended address. A short address is accepted, but the stack can not put it in NDISC link-layer address options, so neighbor discovery does not work with one.
§Panics
Panics if the address is not of the kind the device’s medium uses.
Sourcepub fn ip_addrs(&self) -> &[IfaceAddr]
pub fn ip_addrs(&self) -> &[IfaceAddr]
The IP addresses assigned to the interface, with their origin.
Sourcepub fn has_ip_addr(&self, addr: impl Into<IpAddress>) -> bool
pub fn has_ip_addr(&self, addr: impl Into<IpAddress>) -> bool
Check whether the given address is assigned to the interface.
Sourcepub fn add_ip_addr(&mut self, cidr: IpCidr) -> Result<Option<IpCidr>, Full>
pub fn add_ip_addr(&mut self, cidr: IpCidr) -> Result<Option<IpCidr>, Full>
Assign an IP address to the interface.
If the same address is already assigned, its prefix is updated and the
previous CIDR returned. Otherwise the address is appended and None is
returned. Source address selection prefers the first address matching the
destination’s subnet, so ordering only matters between addresses of the same
subnet.
§Panics
Panics if the address is not unicast.
Errors:
Fullif the interface has no room for another address. Only possible without theallocfeature, where the limit isIFACE_ADDR_COUNT.
Sourcepub fn remove_ip_addr(&mut self, addr: impl Into<IpAddress>) -> Option<IpCidr>
pub fn remove_ip_addr(&mut self, addr: impl Into<IpAddress>) -> Option<IpCidr>
Unassign an IP address from the interface, returning the CIDR it was
assigned with, or None if it was not assigned.
Sourcepub fn set_ip_addrs(
&mut self,
new_addrs: impl IntoIterator<Item = IpCidr>,
) -> Result<(), Full>
pub fn set_ip_addrs( &mut self, new_addrs: impl IntoIterator<Item = IpCidr>, ) -> Result<(), Full>
Replace the interface’s entire set of IP addresses.
Equivalent to removing every address and adding the given ones. The automatic IPv6 link-local address is kept.
§Panics
Panics if any of the addresses is not unicast.
Errors:
Fullif the addresses do not fit. Only possible without theallocfeature, where the limit isIFACE_ADDR_COUNT. The interface is left unchanged.
Sourcepub fn config_generation(&self) -> u32
pub fn config_generation(&self) -> u32
A counter that goes up every time the interface’s configuration changes for any reason (manual changes, DHCP, SLAAC)
Compare it with a saved value to find out whether anything changed since.
Sourcepub fn register_config_waker(&mut self, waker: &Waker)
pub fn register_config_waker(&mut self, waker: &Waker)
Register a waker to be woken when config_generation
changes.
Only one waker is kept. Registering another replaces it. A woken waker must be registered again to be woken again.
Sourcepub fn set_dhcpv4(&mut self, config: Option<DhcpConfig>)
pub fn set_dhcpv4(&mut self, config: Option<DhcpConfig>)
Turn the DHCPv4 client on, with the given configuration, or off with None.
While on, the client runs from Stack::poll. When it gets a lease the
leased address and the default route via the leased router are installed on
the interface, and removed again when the lease is lost or the client is
turned off. Turning it on when it is already on restarts it with the new
configuration.
§Panics
Panics if the interface is not an Ethernet interface.
Sourcepub fn set_slaac(&mut self, config: Option<SlaacConfig>)
pub fn set_slaac(&mut self, config: Option<SlaacConfig>)
Turn IPv6 stateless address autoconfiguration on, with the given
configuration, or off with None.
While on, the stack sends router solicitations from Stack::poll. Every
prefix a router advertises for autoconfiguration becomes an address on the
interface (the prefix plus the EUI-64 of the hardware address), and every
advertising router becomes a default route. Both are removed when their
lifetime runs out or when SLAAC is turned off. Turning it on when it is
already on restarts it.
§Panics
Panics if the interface is not an Ethernet or IEEE 802.15.4 interface.
Sourcepub fn slaac(&self) -> Option<&SlaacState>
pub fn slaac(&self) -> Option<&SlaacState>
What SLAAC has learned from the routers on the link, or None if SLAAC is off.
Sourcepub fn dhcpv4_lease(&self) -> Option<&DhcpLease>
pub fn dhcpv4_lease(&self) -> Option<&DhcpLease>
The lease the DHCPv4 client currently holds, if any.
Sourcepub fn restart_dhcpv4(&mut self)
pub fn restart_dhcpv4(&mut self)
Drop the DHCPv4 lease, if any, and look for a server again.
Call this when the link went down and came back up, so an address on the new network is obtained right away. Does nothing if the client is off.
Source§impl Iface<'_, '_>
impl Iface<'_, '_>
Sourcepub fn join_multicast_group<T: Into<IpAddress>>(
&mut self,
addr: T,
) -> Result<(), MulticastError>
pub fn join_multicast_group<T: Into<IpAddress>>( &mut self, addr: T, ) -> Result<(), MulticastError>
Join a multicast group.
The stack accepts packets sent to the group right away, and reports the
membership to the routers on the link from the next Stack::poll.
Errors:
Unaddressableif the address is not a multicast address.
Sourcepub fn leave_multicast_group<T: Into<IpAddress>>(
&mut self,
addr: T,
) -> Result<(), MulticastError>
pub fn leave_multicast_group<T: Into<IpAddress>>( &mut self, addr: T, ) -> Result<(), MulticastError>
Leave a multicast group.
The stack stops accepting packets sent to the group right away, and
reports the leave to the routers on the link from the next
Stack::poll. Leaving a group that was not joined
does nothing.
Errors:
Unaddressableif the address is not a multicast address.
Sourcepub fn has_multicast_group<T: Into<IpAddress>>(&self, addr: T) -> bool
pub fn has_multicast_group<T: Into<IpAddress>>(&self, addr: T) -> bool
Check whether the interface listens to the given multicast address.
Besides the joined groups, this is true for the groups every host is a member of: the IPv4 all systems group, the IPv6 all nodes group, and the IPv6 solicited node group of each address assigned to the interface.
Source§impl Iface<'_, '_>
impl Iface<'_, '_>
Sourcepub fn pan_id(&self) -> Option<Ieee802154Pan>
pub fn pan_id(&self) -> Option<Ieee802154Pan>
The PAN identifier of an IEEE 802.15.4 interface, None for any PAN.
Sourcepub fn set_pan_id(&mut self, pan_id: Option<Ieee802154Pan>)
pub fn set_pan_id(&mut self, pan_id: Option<Ieee802154Pan>)
Set the PAN identifier of an IEEE 802.15.4 interface.
With a PAN set, frames for another PAN are dropped, except broadcast
ones. With None, the default, frames for every PAN are accepted.
Sent frames carry the PAN, or a zero PAN with None.
Does nothing on other media.
Sourcepub fn sixlowpan_address_context(&self) -> &[SixlowpanAddressContext]
pub fn sixlowpan_address_context(&self) -> &[SixlowpanAddressContext]
The 6LoWPAN address contexts, by context identifier.
Sourcepub fn set_sixlowpan_address_context(
&mut self,
contexts: impl IntoIterator<Item = SixlowpanAddressContext>,
) -> Result<(), Full>
pub fn set_sixlowpan_address_context( &mut self, contexts: impl IntoIterator<Item = SixlowpanAddressContext>, ) -> Result<(), Full>
Replace the 6LoWPAN address contexts.
Received packets whose addresses are compressed against a context identifier are resolved with the context at that index. Sent packets never use contexts.
Errors:
Fullif the contexts do not fit. Only possible without theallocfeature, where the limit isSIXLOWPAN_ADDRESS_CONTEXT_COUNT. The interface is left unchanged.