Struct smoltcp::iface::EthernetInterface
source · pub struct EthernetInterface<'b, 'c, 'e, DeviceT: for<'d> Device<'d>> { /* private fields */ }
Expand description
An Ethernet 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<'b, 'c, 'e, DeviceT> Interface<'b, 'c, 'e, DeviceT>where
DeviceT: for<'d> Device<'d>,
impl<'b, 'c, 'e, DeviceT> Interface<'b, 'c, 'e, DeviceT>where
DeviceT: for<'d> Device<'d>,
sourcepub fn ethernet_addr(&self) -> EthernetAddress
pub fn ethernet_addr(&self) -> EthernetAddress
Get the Ethernet address of the interface.
sourcepub fn set_ethernet_addr(&mut self, addr: EthernetAddress)
pub fn set_ethernet_addr(&mut self, addr: EthernetAddress)
Set the Ethernet address of the interface.
Panics
This function panics if the address is not unicast.
sourcepub fn join_multicast_group<T: Into<IpAddress>>(
&mut self,
addr: T,
_timestamp: Instant
) -> Result<bool>
pub fn join_multicast_group<T: Into<IpAddress>>(
&mut self,
addr: T,
_timestamp: Instant
) -> Result<bool>
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<T: Into<IpAddress>>(
&mut self,
addr: T,
_timestamp: Instant
) -> Result<bool>
pub fn leave_multicast_group<T: Into<IpAddress>>(
&mut self,
addr: T,
_timestamp: Instant
) -> Result<bool>
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.
sourcepub fn update_ip_addrs<F: FnOnce(&mut ManagedSlice<'c, IpCidr>)>(&mut self, f: F)
pub fn update_ip_addrs<F: FnOnce(&mut ManagedSlice<'c, IpCidr>)>(&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.
sourcepub fn ipv4_address(&self) -> Option<Ipv4Address>
pub fn ipv4_address(&self) -> Option<Ipv4Address>
Get the first IPv4 address of the interface.
pub fn routes(&self) -> &Routes<'e>
pub fn routes_mut(&mut self) -> &mut Routes<'e>
sourcepub fn poll(
&mut self,
sockets: &mut SocketSet<'_, '_, '_>,
timestamp: Instant
) -> Result<bool>
pub fn poll(
&mut self,
sockets: &mut SocketSet<'_, '_, '_>,
timestamp: Instant
) -> Result<bool>
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.
Errors
This method will routinely return errors in response to normal network activity as well as certain boundary conditions such as buffer exhaustion. These errors are provided as an aid for troubleshooting, and are meant to be logged and ignored.
As a special case, Err(Error::Unrecognized)
is returned in response to
packets containing any unsupported protocol, option, or form, which is
a very common occurrence and on a production system it should not even
be logged.
sourcepub fn poll_at(
&self,
sockets: &SocketSet<'_, '_, '_>,
timestamp: Instant
) -> Option<Instant>
pub fn poll_at(
&self,
sockets: &SocketSet<'_, '_, '_>,
timestamp: Instant
) -> Option<Instant>
sourcepub fn poll_delay(
&self,
sockets: &SocketSet<'_, '_, '_>,
timestamp: Instant
) -> Option<Duration>
pub fn poll_delay(
&self,
sockets: &SocketSet<'_, '_, '_>,
timestamp: Instant
) -> 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.