pub struct Interface { /* private fields */ }
Expand description
A network interface.
The network interface logically owns a number of other data structures; to avoid
a dependency on heap allocation, it instead owns a BorrowMut<[T]>
, which can be
a &mut [T]
, or Vec<T>
if a heap is available.
Implementations§
source§impl Interface
impl Interface
sourcepub fn join_multicast_group<D, T: Into<IpAddress>>(
&mut self,
device: &mut D,
addr: T,
timestamp: Instant
) -> Result<bool, MulticastError>where
D: Device + ?Sized,
pub fn join_multicast_group<D, T: Into<IpAddress>>(
&mut self,
device: &mut D,
addr: T,
timestamp: Instant
) -> Result<bool, MulticastError>where
D: Device + ?Sized,
Add an address to a list of subscribed multicast IP addresses.
Returns Ok(announce_sent)
if the address was added successfully, where annouce_sent
indicates whether an initial immediate announcement has been sent.
sourcepub fn leave_multicast_group<D, T: Into<IpAddress>>(
&mut self,
device: &mut D,
addr: T,
timestamp: Instant
) -> Result<bool, MulticastError>where
D: Device + ?Sized,
pub fn leave_multicast_group<D, T: Into<IpAddress>>(
&mut self,
device: &mut D,
addr: T,
timestamp: Instant
) -> Result<bool, MulticastError>where
D: Device + ?Sized,
Remove an address from the subscribed multicast IP addresses.
Returns Ok(leave_sent)
if the address was removed successfully, where leave_sent
indicates whether an immediate leave packet has been sent.
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 given destination multicast IP address.
source§impl Interface
impl Interface
sourcepub fn new<D>(config: Config, device: &mut D) -> Selfwhere
D: Device + ?Sized,
pub fn new<D>(config: Config, device: &mut D) -> Selfwhere
D: Device + ?Sized,
Create a network interface using the previously provided configuration.
Panics
If a required option is not provided, this function will panic. Required options are:
sourcepub fn context(&mut self) -> &mut InterfaceInner
pub fn context(&mut self) -> &mut InterfaceInner
Get the socket context.
The context is needed for some socket methods.
sourcepub fn hardware_addr(&self) -> HardwareAddress
pub fn hardware_addr(&self) -> HardwareAddress
Get the HardwareAddress address of the interface.
Panics
This function panics if the medium is not Ethernet or Ieee802154.
sourcepub fn set_hardware_addr(&mut self, addr: HardwareAddress)
pub fn set_hardware_addr(&mut self, addr: HardwareAddress)
Set the HardwareAddress address of the interface.
Panics
This function panics if the address is not unicast, and if the medium is not Ethernet or Ieee802154.
sourcepub fn ipv4_addr(&self) -> Option<Ipv4Address>
pub fn ipv4_addr(&self) -> Option<Ipv4Address>
Get the first IPv4 address if present.
sourcepub fn ipv6_addr(&self) -> Option<Ipv6Address>
pub fn ipv6_addr(&self) -> Option<Ipv6Address>
Get the first IPv6 address if present.
sourcepub fn update_ip_addrs<F: FnOnce(&mut Vec<IpCidr, IFACE_MAX_ADDR_COUNT>)>(
&mut self,
f: F
)
pub fn update_ip_addrs<F: FnOnce(&mut Vec<IpCidr, IFACE_MAX_ADDR_COUNT>)>(
&mut self,
f: F
)
Update the IP addresses of the interface.
Panics
This function panics if any of the addresses are not unicast.
sourcepub fn has_ip_addr<T: Into<IpAddress>>(&self, addr: T) -> bool
pub fn has_ip_addr<T: Into<IpAddress>>(&self, addr: T) -> bool
Check whether the interface has the given IP address assigned.
pub fn routes(&self) -> &Routes
pub fn routes_mut(&mut self) -> &mut Routes
sourcepub fn set_any_ip(&mut self, any_ip: bool)
pub fn set_any_ip(&mut self, any_ip: bool)
Enable or disable the AnyIP capability.
AnyIP allowins 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 any_ip(&self) -> bool
pub fn any_ip(&self) -> bool
Get whether AnyIP is enabled.
See set_any_ip
for details on AnyIP
sourcepub fn sixlowpan_address_context(
&self
) -> &Vec<SixlowpanAddressContext, IFACE_MAX_SIXLOWPAN_ADDRESS_CONTEXT_COUNT>
pub fn sixlowpan_address_context(
&self
) -> &Vec<SixlowpanAddressContext, IFACE_MAX_SIXLOWPAN_ADDRESS_CONTEXT_COUNT>
Get the 6LoWPAN address contexts.
sourcepub fn sixlowpan_address_context_mut(
&mut self
) -> &mut Vec<SixlowpanAddressContext, IFACE_MAX_SIXLOWPAN_ADDRESS_CONTEXT_COUNT>
pub fn sixlowpan_address_context_mut(
&mut self
) -> &mut Vec<SixlowpanAddressContext, IFACE_MAX_SIXLOWPAN_ADDRESS_CONTEXT_COUNT>
Get a mutable reference to the 6LoWPAN address contexts.
sourcepub fn reassembly_timeout(&self) -> Duration
pub fn reassembly_timeout(&self) -> Duration
Get the packet reassembly timeout.
sourcepub fn set_reassembly_timeout(&mut self, timeout: Duration)
pub fn set_reassembly_timeout(&mut self, timeout: Duration)
Set the packet reassembly timeout.
sourcepub fn poll<D>(
&mut self,
timestamp: Instant,
device: &mut D,
sockets: &mut SocketSet<'_>
) -> boolwhere
D: Device + ?Sized,
pub fn poll<D>(
&mut self,
timestamp: Instant,
device: &mut D,
sockets: &mut SocketSet<'_>
) -> boolwhere
D: Device + ?Sized,
Transmit packets queued in the given sockets, and receive packets queued in the device.
This function returns a boolean value indicating whether any packets were processed or emitted, and thus, whether the readiness of any socket might have changed.
sourcepub fn poll_delay(
&mut self,
timestamp: Instant,
sockets: &SocketSet<'_>
) -> Option<Duration>
pub fn poll_delay(
&mut self,
timestamp: Instant,
sockets: &SocketSet<'_>
) -> Option<Duration>
Return an advisory wait time for calling poll the next time. The Duration returned is the time left to wait before calling poll next. It is harmless (but wastes energy) to call it before the Duration has passed, and potentially harmful (impacting quality of service) to call it after the Duration has passed.