xarxa

Crates

git

Versions

default

Flavors

Skip to main content

Iface

Struct Iface 

Source
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>

Source

pub fn capabilities(&self) -> Capabilities

The capabilities reported by the device.

The link state reported by the device.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn ip_addrs(&self) -> &[IfaceAddr]

The IP addresses assigned to the interface, with their origin.

Source

pub fn has_ip_addr(&self, addr: impl Into<IpAddress>) -> bool

Check whether the given address is assigned to the interface.

Source

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:

  • Full if the interface has no room for another address. Only possible without the alloc feature, where the limit is IFACE_ADDR_COUNT.
Source

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.

Source

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:

  • Full if the addresses do not fit. Only possible without the alloc feature, where the limit is IFACE_ADDR_COUNT. The interface is left unchanged.
Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn slaac(&self) -> Option<&SlaacState>

What SLAAC has learned from the routers on the link, or None if SLAAC is off.

Source

pub fn dhcpv4_lease(&self) -> Option<&DhcpLease>

The lease the DHCPv4 client currently holds, if any.

Source

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<'_, '_>

Source

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:

  • Unaddressable if the address is not a multicast address.
Source

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:

  • Unaddressable if the address is not a multicast address.
Source

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<'_, '_>

Source

pub fn pan_id(&self) -> Option<Ieee802154Pan>

The PAN identifier of an IEEE 802.15.4 interface, None for any PAN.

Source

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.

Source

pub fn sixlowpan_address_context(&self) -> &[SixlowpanAddressContext]

The 6LoWPAN address contexts, by context identifier.

Source

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:

  • Full if the contexts do not fit. Only possible without the alloc feature, where the limit is SIXLOWPAN_ADDRESS_CONTEXT_COUNT. The interface is left unchanged.

Auto Trait Implementations§

§

impl<'a, 'd> !RefUnwindSafe for Iface<'a, 'd>

§

impl<'a, 'd> !Send for Iface<'a, 'd>

§

impl<'a, 'd> !Sync for Iface<'a, 'd>

§

impl<'a, 'd> !UnwindSafe for Iface<'a, 'd>

§

impl<'a, 'd> Freeze for Iface<'a, 'd>

§

impl<'a, 'd> Unpin for Iface<'a, 'd>

§

impl<'a, 'd> UnsafeUnpin for Iface<'a, 'd>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.