@@ -204,15 +204,15 @@ pub enum AddressFamily {
204
204
impl AddressFamily {
205
205
pub fn from_i32 ( family : i32 ) -> Option < AddressFamily > {
206
206
match family {
207
- consts :: AF_UNIX => Some ( AddressFamily :: Unix ) ,
208
- consts :: AF_INET => Some ( AddressFamily :: Inet ) ,
209
- consts :: AF_INET6 => Some ( AddressFamily :: Inet6 ) ,
207
+ libc :: AF_UNIX => Some ( AddressFamily :: Unix ) ,
208
+ libc :: AF_INET => Some ( AddressFamily :: Inet ) ,
209
+ libc :: AF_INET6 => Some ( AddressFamily :: Inet6 ) ,
210
210
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
211
- consts :: AF_NETLINK => Some ( AddressFamily :: Netlink ) ,
211
+ libc :: AF_NETLINK => Some ( AddressFamily :: Netlink ) ,
212
212
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
213
- consts :: AF_PACKET => Some ( AddressFamily :: Packet ) ,
213
+ libc :: AF_PACKET => Some ( AddressFamily :: Packet ) ,
214
214
#[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
215
- consts :: AF_SYSTEM => Some ( AddressFamily :: System ) ,
215
+ libc :: AF_SYSTEM => Some ( AddressFamily :: System ) ,
216
216
_ => None
217
217
}
218
218
}
@@ -716,13 +716,15 @@ impl SockAddr {
716
716
InetAddr :: V4 ( * ( addr as * mut libc:: sockaddr_in ) ) ) ) ,
717
717
Some ( AddressFamily :: Inet6 ) => Some ( SockAddr :: Inet (
718
718
InetAddr :: V6 ( * ( addr as * mut libc:: sockaddr_in6 ) ) ) ) ,
719
- #[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
720
- Some ( AddressFamily :: Netlink ) => None ,
721
- #[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
722
- Some ( AddressFamily :: Packet ) => None ,
723
- #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
724
- Some ( AddressFamily :: System ) => None ,
725
- None => None
719
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
720
+ Some ( AddressFamily :: Netlink ) => Some ( SockAddr :: Netlink (
721
+ NetlinkAddr ( * ( addr as * mut libc:: sockaddr_nl ) ) ) ) ,
722
+ #[ cfg( any( target_os = "ios" , target_os = "macos" ) ) ]
723
+ Some ( AddressFamily :: SysControl ) => Some ( SockAddr :: SysControl (
724
+ SysControlAddr ( * ( addr as * mut sys_control:: sockaddr_ctl ) ) ) ) ,
725
+ // No other address families are supported, including netlink and syscontrol.
726
+ Some ( _) => None ,
727
+ None => None ,
726
728
}
727
729
}
728
730
}
0 commit comments