@@ -10,7 +10,7 @@ use std::mem;
10
10
use std:: option:: Option ;
11
11
12
12
use crate :: { Result , Errno } ;
13
- use crate :: sys:: socket:: SockAddr ;
13
+ use crate :: sys:: socket:: { SockaddrLike , SockaddrStorage } ;
14
14
use crate :: net:: if_:: * ;
15
15
16
16
/// Describes a single address for an interface as returned by `getifaddrs`.
@@ -21,13 +21,13 @@ pub struct InterfaceAddress {
21
21
/// Flags as from `SIOCGIFFLAGS` ioctl
22
22
pub flags : InterfaceFlags ,
23
23
/// Network address of this interface
24
- pub address : Option < SockAddr > ,
24
+ pub address : Option < SockaddrStorage > ,
25
25
/// Netmask of this interface
26
- pub netmask : Option < SockAddr > ,
26
+ pub netmask : Option < SockaddrStorage > ,
27
27
/// Broadcast address of this interface, if applicable
28
- pub broadcast : Option < SockAddr > ,
28
+ pub broadcast : Option < SockaddrStorage > ,
29
29
/// Point-to-point destination address
30
- pub destination : Option < SockAddr > ,
30
+ pub destination : Option < SockaddrStorage > ,
31
31
}
32
32
33
33
cfg_if ! {
@@ -46,8 +46,8 @@ impl InterfaceAddress {
46
46
/// Create an `InterfaceAddress` from the libc struct.
47
47
fn from_libc_ifaddrs ( info : & libc:: ifaddrs ) -> InterfaceAddress {
48
48
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 ) } ;
51
51
let mut addr = InterfaceAddress {
52
52
interface_name : ifname. to_string_lossy ( ) . to_string ( ) ,
53
53
flags : InterfaceFlags :: from_bits_truncate ( info. ifa_flags as i32 ) ,
@@ -59,9 +59,9 @@ impl InterfaceAddress {
59
59
60
60
let ifu = get_ifu_from_sockaddr ( info) ;
61
61
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 ) } ;
63
63
} 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 ) } ;
65
65
}
66
66
67
67
addr
@@ -103,9 +103,9 @@ impl Iterator for InterfaceAddressIterator {
103
103
/// Note that the underlying implementation differs between OSes. Only the
104
104
/// most common address families are supported by the nix crate (due to
105
105
/// 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.
109
109
///
110
110
/// # Example
111
111
/// ```
0 commit comments