13
13
) ) ]
14
14
#[ cfg( feature = "net" ) ]
15
15
pub use self :: datalink:: LinkAddr ;
16
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
16
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
17
17
pub use self :: vsock:: VsockAddr ;
18
18
use super :: sa_family_t;
19
19
use crate :: errno:: Errno ;
@@ -249,7 +249,7 @@ pub enum AddressFamily {
249
249
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
250
250
Nfc = libc:: AF_NFC ,
251
251
/// VMWare VSockets protocol for hypervisor-guest interaction.
252
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
252
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
253
253
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
254
254
Vsock = libc:: AF_VSOCK ,
255
255
/// ARPANet IMP addresses
@@ -444,7 +444,7 @@ impl AddressFamily {
444
444
target_os = "openbsd"
445
445
) ) ]
446
446
libc:: AF_LINK => Some ( AddressFamily :: Link ) ,
447
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
447
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
448
448
libc:: AF_VSOCK => Some ( AddressFamily :: Vsock ) ,
449
449
_ => None ,
450
450
}
@@ -1246,7 +1246,7 @@ pub union SockaddrStorage {
1246
1246
sin6 : SockaddrIn6 ,
1247
1247
ss : libc:: sockaddr_storage ,
1248
1248
su : UnixAddr ,
1249
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1249
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
1250
1250
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
1251
1251
vsock : VsockAddr ,
1252
1252
}
@@ -1338,7 +1338,7 @@ impl SockaddrLike for SockaddrStorage {
1338
1338
libc:: AF_SYSTEM => {
1339
1339
SysControlAddr :: from_raw ( addr, l) . map ( |sctl| Self { sctl } )
1340
1340
}
1341
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1341
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
1342
1342
libc:: AF_VSOCK => {
1343
1343
VsockAddr :: from_raw ( addr, l) . map ( |vsock| Self { vsock } )
1344
1344
}
@@ -1505,7 +1505,7 @@ impl SockaddrStorage {
1505
1505
accessors ! { as_sys_control_addr, as_sys_control_addr_mut, SysControlAddr ,
1506
1506
AddressFamily :: System , libc:: sockaddr_ctl, sctl}
1507
1507
1508
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1508
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
1509
1509
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
1510
1510
accessors ! { as_vsock_addr, as_vsock_addr_mut, VsockAddr ,
1511
1511
AddressFamily :: Vsock , libc:: sockaddr_vm, vsock}
@@ -1555,7 +1555,7 @@ impl fmt::Display for SockaddrStorage {
1555
1555
#[ cfg( feature = "ioctl" ) ]
1556
1556
libc:: AF_SYSTEM => self . sctl . fmt ( f) ,
1557
1557
libc:: AF_UNIX => self . su . fmt ( f) ,
1558
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1558
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
1559
1559
libc:: AF_VSOCK => self . vsock . fmt ( f) ,
1560
1560
_ => "<Address family unspecified>" . fmt ( f) ,
1561
1561
}
@@ -1629,7 +1629,7 @@ impl Hash for SockaddrStorage {
1629
1629
#[ cfg( feature = "ioctl" ) ]
1630
1630
libc:: AF_SYSTEM => self . sctl . hash ( s) ,
1631
1631
libc:: AF_UNIX => self . su . hash ( s) ,
1632
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1632
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
1633
1633
libc:: AF_VSOCK => self . vsock . hash ( s) ,
1634
1634
_ => self . ss . hash ( s) ,
1635
1635
}
@@ -1671,7 +1671,7 @@ impl PartialEq for SockaddrStorage {
1671
1671
#[ cfg( feature = "ioctl" ) ]
1672
1672
( libc:: AF_SYSTEM , libc:: AF_SYSTEM ) => self . sctl == other. sctl ,
1673
1673
( libc:: AF_UNIX , libc:: AF_UNIX ) => self . su == other. su ,
1674
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1674
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
1675
1675
( libc:: AF_VSOCK , libc:: AF_VSOCK ) => self . vsock == other. vsock ,
1676
1676
_ => false ,
1677
1677
}
@@ -2220,7 +2220,7 @@ mod datalink {
2220
2220
}
2221
2221
}
2222
2222
2223
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
2223
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
2224
2224
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
2225
2225
pub mod vsock {
2226
2226
use super :: * ;
@@ -2266,20 +2266,33 @@ pub mod vsock {
2266
2266
}
2267
2267
2268
2268
impl PartialEq for VsockAddr {
2269
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
2269
2270
fn eq ( & self , other : & Self ) -> bool {
2270
2271
let ( inner, other) = ( self . 0 , other. 0 ) ;
2271
2272
( inner. svm_family , inner. svm_cid , inner. svm_port )
2272
2273
== ( other. svm_family , other. svm_cid , other. svm_port )
2273
2274
}
2275
+ #[ cfg( target_os = "macos" ) ]
2276
+ fn eq ( & self , other : & Self ) -> bool {
2277
+ let ( inner, other) = ( self . 0 , other. 0 ) ;
2278
+ ( inner. svm_family , inner. svm_cid , inner. svm_port , inner. svm_len )
2279
+ == ( other. svm_family , other. svm_cid , other. svm_port , inner. svm_len )
2280
+ }
2274
2281
}
2275
2282
2276
2283
impl Eq for VsockAddr { }
2277
2284
2278
2285
impl Hash for VsockAddr {
2286
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
2279
2287
fn hash < H : Hasher > ( & self , s : & mut H ) {
2280
2288
let inner = self . 0 ;
2281
2289
( inner. svm_family , inner. svm_cid , inner. svm_port ) . hash ( s) ;
2282
2290
}
2291
+ #[ cfg( target_os = "macos" ) ]
2292
+ fn hash < H : Hasher > ( & self , s : & mut H ) {
2293
+ let inner = self . 0 ;
2294
+ ( inner. svm_family , inner. svm_cid , inner. svm_port , inner. svm_len ) . hash ( s) ;
2295
+ }
2283
2296
}
2284
2297
2285
2298
/// VSOCK Address
@@ -2294,6 +2307,10 @@ pub mod vsock {
2294
2307
addr. svm_cid = cid;
2295
2308
addr. svm_port = port;
2296
2309
2310
+ #[ cfg( target_os = "macos" ) ]
2311
+ {
2312
+ addr. svm_len = std:: mem:: size_of :: < sockaddr_vm > ( ) as u8 ;
2313
+ }
2297
2314
VsockAddr ( addr)
2298
2315
}
2299
2316
0 commit comments