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 ;
@@ -248,7 +248,7 @@ pub enum AddressFamily {
248
248
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
249
249
Nfc = libc:: AF_NFC ,
250
250
/// VMWare VSockets protocol for hypervisor-guest interaction.
251
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
251
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
252
252
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
253
253
Vsock = libc:: AF_VSOCK ,
254
254
/// ARPANet IMP addresses
@@ -443,7 +443,7 @@ impl AddressFamily {
443
443
target_os = "openbsd"
444
444
) ) ]
445
445
libc:: AF_LINK => Some ( AddressFamily :: Link ) ,
446
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
446
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
447
447
libc:: AF_VSOCK => Some ( AddressFamily :: Vsock ) ,
448
448
_ => None ,
449
449
}
@@ -1286,7 +1286,7 @@ pub union SockaddrStorage {
1286
1286
sin6 : SockaddrIn6 ,
1287
1287
ss : libc:: sockaddr_storage ,
1288
1288
su : UnixAddr ,
1289
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1289
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
1290
1290
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
1291
1291
vsock : VsockAddr ,
1292
1292
}
@@ -1378,7 +1378,7 @@ impl SockaddrLike for SockaddrStorage {
1378
1378
libc:: AF_SYSTEM => {
1379
1379
SysControlAddr :: from_raw ( addr, l) . map ( |sctl| Self { sctl } )
1380
1380
}
1381
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1381
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
1382
1382
libc:: AF_VSOCK => {
1383
1383
VsockAddr :: from_raw ( addr, l) . map ( |vsock| Self { vsock } )
1384
1384
}
@@ -1554,7 +1554,7 @@ impl SockaddrStorage {
1554
1554
accessors ! { as_sys_control_addr, as_sys_control_addr_mut, SysControlAddr ,
1555
1555
AddressFamily :: System , libc:: sockaddr_ctl, sctl}
1556
1556
1557
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1557
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
1558
1558
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
1559
1559
accessors ! { as_vsock_addr, as_vsock_addr_mut, VsockAddr ,
1560
1560
AddressFamily :: Vsock , libc:: sockaddr_vm, vsock}
@@ -1604,7 +1604,7 @@ impl fmt::Display for SockaddrStorage {
1604
1604
#[ cfg( feature = "ioctl" ) ]
1605
1605
libc:: AF_SYSTEM => self . sctl . fmt ( f) ,
1606
1606
libc:: AF_UNIX => self . su . fmt ( f) ,
1607
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1607
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
1608
1608
libc:: AF_VSOCK => self . vsock . fmt ( f) ,
1609
1609
_ => "<Address family unspecified>" . fmt ( f) ,
1610
1610
}
@@ -1678,7 +1678,7 @@ impl Hash for SockaddrStorage {
1678
1678
#[ cfg( feature = "ioctl" ) ]
1679
1679
libc:: AF_SYSTEM => self . sctl . hash ( s) ,
1680
1680
libc:: AF_UNIX => self . su . hash ( s) ,
1681
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1681
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
1682
1682
libc:: AF_VSOCK => self . vsock . hash ( s) ,
1683
1683
_ => self . ss . hash ( s) ,
1684
1684
}
@@ -1720,7 +1720,7 @@ impl PartialEq for SockaddrStorage {
1720
1720
#[ cfg( feature = "ioctl" ) ]
1721
1721
( libc:: AF_SYSTEM , libc:: AF_SYSTEM ) => self . sctl == other. sctl ,
1722
1722
( libc:: AF_UNIX , libc:: AF_UNIX ) => self . su == other. su ,
1723
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1723
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
1724
1724
( libc:: AF_VSOCK , libc:: AF_VSOCK ) => self . vsock == other. vsock ,
1725
1725
_ => false ,
1726
1726
}
@@ -2268,7 +2268,7 @@ mod datalink {
2268
2268
}
2269
2269
}
2270
2270
2271
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
2271
+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
2272
2272
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
2273
2273
pub mod vsock {
2274
2274
use super :: * ;
@@ -2314,20 +2314,33 @@ pub mod vsock {
2314
2314
}
2315
2315
2316
2316
impl PartialEq for VsockAddr {
2317
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
2317
2318
fn eq ( & self , other : & Self ) -> bool {
2318
2319
let ( inner, other) = ( self . 0 , other. 0 ) ;
2319
2320
( inner. svm_family , inner. svm_cid , inner. svm_port )
2320
2321
== ( other. svm_family , other. svm_cid , other. svm_port )
2321
2322
}
2323
+ #[ cfg( target_os = "macos" ) ]
2324
+ fn eq ( & self , other : & Self ) -> bool {
2325
+ let ( inner, other) = ( self . 0 , other. 0 ) ;
2326
+ ( inner. svm_family , inner. svm_cid , inner. svm_port , inner. svm_len )
2327
+ == ( other. svm_family , other. svm_cid , other. svm_port , inner. svm_len )
2328
+ }
2322
2329
}
2323
2330
2324
2331
impl Eq for VsockAddr { }
2325
2332
2326
2333
impl Hash for VsockAddr {
2334
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
2327
2335
fn hash < H : Hasher > ( & self , s : & mut H ) {
2328
2336
let inner = self . 0 ;
2329
2337
( inner. svm_family , inner. svm_cid , inner. svm_port ) . hash ( s) ;
2330
2338
}
2339
+ #[ cfg( target_os = "macos" ) ]
2340
+ fn hash < H : Hasher > ( & self , s : & mut H ) {
2341
+ let inner = self . 0 ;
2342
+ ( inner. svm_family , inner. svm_cid , inner. svm_port , inner. svm_len ) . hash ( s) ;
2343
+ }
2331
2344
}
2332
2345
2333
2346
/// VSOCK Address
@@ -2342,6 +2355,10 @@ pub mod vsock {
2342
2355
addr. svm_cid = cid;
2343
2356
addr. svm_port = port;
2344
2357
2358
+ #[ cfg( target_os = "macos" ) ]
2359
+ {
2360
+ addr. svm_len = std:: mem:: size_of :: < sockaddr_vm > ( ) as u8 ;
2361
+ }
2345
2362
VsockAddr ( addr)
2346
2363
}
2347
2364
0 commit comments