Crate cotton_netif

Source
Expand description

Enumerating network interfaces and their IP addresses

The netif crate encapsulates the obtaining of the host’s network interfaces and IP addresses. It supports both static/synchronous listing (i.e., a snapshot of the current list of network interfaces) using get_interfaces and dynamic/asynchronous listing (i.e., getting events as network interfaces and addresses come and go) using get_interfaces_async.

At present this crate only works on Linux (and maybe BSD) but the structure is such that adding compatibility with other platforms in future, shouldn’t require changes to any client code.

Todo:

  • IPv6 in linux_netlink
  • Better test coverage
  • Does DelAddr need to include the address? yes
  • Can get_interfaces_async itself not be async?
  • Can we use just one netlink socket, perhaps with lower-level neli?
  • Turn async into a (cargo) Feature

Re-exports§

pub use network_event::Flags;
pub use network_event::InterfaceIndex;
pub use network_event::NetworkEvent;

Modules§

getifaddrssync and non-target_os="none"
Static listing using Linux/glibc’s getifaddrs(3)
linux_netlinkLinux and async
Dynamic listing using Linux’s netlink socket
network_event
Events passed to interface observers

Functions§

get_interfacessync and non-target_os="none"
Obtain the current list of network interfaces
get_interfaces_asyncLinux and async
Obtain the current list of network interfaces and a stream of future events