Function nix::ifaddrs::getifaddrs [−][src]
pub fn getifaddrs() -> Result<InterfaceAddressIterator>
Expand description
Get interface addresses using libc’s getifaddrs
Note that the underlying implementation differs between OSes. Only the
most common address families are supported by the nix crate (due to
lack of time and complexity of testing). The address family is encoded
in the specific variant of SockAddr
returned for the fields address
,
netmask
, broadcast
, and destination
. For any entry not supported,
the returned list will contain a None
entry.
Example
let addrs = nix::ifaddrs::getifaddrs().unwrap();
for ifaddr in addrs {
match ifaddr.address {
Some(address) => {
println!("interface {} address {}",
ifaddr.interface_name, address);
},
None => {
println!("interface {} with unsupported address family",
ifaddr.interface_name);
}
}
}