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
DelAddrneed to include the address? yes -
Can
get_interfaces_asyncitself 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§
- getifaddrs
syncand non-target_os="none" - Static listing using Linux/glibc’s getifaddrs(3)
- linux_
netlink Linux and async - Dynamic listing using Linux’s netlink socket
- network_
event - Events passed to interface observers
Functions§
- get_
interfaces syncand non-target_os="none" - Obtain the current list of network interfaces
- get_
interfaces_ async Linux and async - Obtain the current list of network interfaces and a stream of future events