@@ -10,7 +10,7 @@ use std::mem;
1010use std:: option:: Option ;
1111
1212use crate :: { Result , Errno } ;
13- use crate :: sys:: socket:: SockAddr ;
13+ use crate :: sys:: socket:: { SockaddrLike , SockaddrStorage } ;
1414use crate :: net:: if_:: * ;
1515
1616/// Describes a single address for an interface as returned by `getifaddrs`.
@@ -21,13 +21,13 @@ pub struct InterfaceAddress {
2121 /// Flags as from `SIOCGIFFLAGS` ioctl
2222 pub flags : InterfaceFlags ,
2323 /// Network address of this interface
24- pub address : Option < SockAddr > ,
24+ pub address : Option < SockaddrStorage > ,
2525 /// Netmask of this interface
26- pub netmask : Option < SockAddr > ,
26+ pub netmask : Option < SockaddrStorage > ,
2727 /// Broadcast address of this interface, if applicable
28- pub broadcast : Option < SockAddr > ,
28+ pub broadcast : Option < SockaddrStorage > ,
2929 /// Point-to-point destination address
30- pub destination : Option < SockAddr > ,
30+ pub destination : Option < SockaddrStorage > ,
3131}
3232
3333cfg_if ! {
@@ -46,8 +46,8 @@ impl InterfaceAddress {
4646 /// Create an `InterfaceAddress` from the libc struct.
4747 fn from_libc_ifaddrs ( info : & libc:: ifaddrs ) -> InterfaceAddress {
4848 let ifname = unsafe { ffi:: CStr :: from_ptr ( info. ifa_name ) } ;
49- let address = unsafe { SockAddr :: from_libc_sockaddr ( info. ifa_addr ) } ;
50- let netmask = unsafe { SockAddr :: from_libc_sockaddr ( info. ifa_netmask ) } ;
49+ let address = unsafe { SockaddrStorage :: from_raw ( info. ifa_addr , None ) } ;
50+ let netmask = unsafe { SockaddrStorage :: from_raw ( info. ifa_netmask , None ) } ;
5151 let mut addr = InterfaceAddress {
5252 interface_name : ifname. to_string_lossy ( ) . to_string ( ) ,
5353 flags : InterfaceFlags :: from_bits_truncate ( info. ifa_flags as i32 ) ,
@@ -59,9 +59,9 @@ impl InterfaceAddress {
5959
6060 let ifu = get_ifu_from_sockaddr ( info) ;
6161 if addr. flags . contains ( InterfaceFlags :: IFF_POINTOPOINT ) {
62- addr. destination = unsafe { SockAddr :: from_libc_sockaddr ( ifu) } ;
62+ addr. destination = unsafe { SockaddrStorage :: from_raw ( ifu, None ) } ;
6363 } else if addr. flags . contains ( InterfaceFlags :: IFF_BROADCAST ) {
64- addr. broadcast = unsafe { SockAddr :: from_libc_sockaddr ( ifu) } ;
64+ addr. broadcast = unsafe { SockaddrStorage :: from_raw ( ifu, None ) } ;
6565 }
6666
6767 addr
@@ -103,9 +103,9 @@ impl Iterator for InterfaceAddressIterator {
103103/// Note that the underlying implementation differs between OSes. Only the
104104/// most common address families are supported by the nix crate (due to
105105/// lack of time and complexity of testing). The address family is encoded
106- /// in the specific variant of `SockAddr ` returned for the fields `address`,
107- /// `netmask`, `broadcast`, and `destination`. For any entry not supported,
108- /// the returned list will contain a `None` entry.
106+ /// in the specific variant of `SockaddrStorage ` returned for the fields
107+ /// `address`, ` netmask`, `broadcast`, and `destination`. For any entry not
108+ /// supported, the returned list will contain a `None` entry.
109109///
110110/// # Example
111111/// ```
0 commit comments