@@ -18,7 +18,7 @@ use libc::{
18
18
use std:: io:: { IoSlice , IoSliceMut } ;
19
19
#[ cfg( feature = "net" ) ]
20
20
use std:: net;
21
- use std:: os:: unix:: io:: { AsFd , AsRawFd , FromRawFd , RawFd , OwnedFd } ;
21
+ use std:: os:: unix:: io:: { AsFd , AsRawFd , FromRawFd , OwnedFd , RawFd } ;
22
22
use std:: { mem, ptr} ;
23
23
24
24
#[ deny( missing_docs) ]
@@ -62,7 +62,11 @@ pub use crate::sys::socket::addr::netlink::NetlinkAddr;
62
62
#[ cfg( any( target_os = "ios" , target_os = "macos" ) ) ]
63
63
#[ cfg( feature = "ioctl" ) ]
64
64
pub use crate :: sys:: socket:: addr:: sys_control:: SysControlAddr ;
65
- #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
65
+ #[ cfg( any(
66
+ target_os = "android" ,
67
+ target_os = "linux" ,
68
+ target_os = "macos"
69
+ ) ) ]
66
70
pub use crate :: sys:: socket:: addr:: vsock:: VsockAddr ;
67
71
68
72
#[ cfg( all( feature = "uio" , not( target_os = "redox" ) ) ) ]
@@ -1147,7 +1151,7 @@ pub enum ControlMessage<'a> {
1147
1151
#[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1148
1152
UdpGsoSegments ( & ' a u16 ) ,
1149
1153
1150
- /// Configure the sending addressing and interface for v4
1154
+ /// Configure the sending addressing and interface for v4.
1151
1155
///
1152
1156
/// For further information, please refer to the
1153
1157
/// [`ip(7)`](https://man7.org/linux/man-pages/man7/ip.7.html) man page.
@@ -1160,7 +1164,7 @@ pub enum ControlMessage<'a> {
1160
1164
#[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1161
1165
Ipv4PacketInfo ( & ' a libc:: in_pktinfo) ,
1162
1166
1163
- /// Configure the sending addressing and interface for v6
1167
+ /// Configure the sending addressing and interface for v6.
1164
1168
///
1165
1169
/// For further information, please refer to the
1166
1170
/// [`ipv6(7)`](https://man7.org/linux/man-pages/man7/ipv6.7.html) man page.
@@ -1185,6 +1189,22 @@ pub enum ControlMessage<'a> {
1185
1189
#[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1186
1190
Ipv4SendSrcAddr ( & ' a libc:: in_addr) ,
1187
1191
1192
+ /// Configure the hop limit for v6 multicast traffic.
1193
+ ///
1194
+ /// Set the IPv6 hop limit for this message. The argument is an integer
1195
+ /// between 0 and 255. A value of -1 will set the hop limit to the route
1196
+ /// default if possible on the interface. Without this cmsg, packets sent
1197
+ /// with sendmsg have a hop limit of 1 and will not leave the local network.
1198
+ /// For further information, please refer to the
1199
+ /// [`ipv6(7)`](https://man7.org/linux/man-pages/man7/ipv6.7.html) man page.
1200
+ #[ cfg( any( target_os = "linux" , target_os = "macos" ,
1201
+ target_os = "freebsd" , target_os = "dragonfly" ,
1202
+ target_os = "android" , target_os = "ios" ,
1203
+ target_os = "haiku" ) ) ]
1204
+ #[ cfg( feature = "net" ) ]
1205
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1206
+ Ipv6HopLimit ( & ' a libc:: c_int) ,
1207
+
1188
1208
/// SO_RXQ_OVFL indicates that an unsigned 32 bit value
1189
1209
/// ancilliary msg (cmsg) should be attached to recieved
1190
1210
/// skbs indicating the number of packets dropped by the
@@ -1298,6 +1318,12 @@ impl<'a> ControlMessage<'a> {
1298
1318
target_os = "openbsd" , target_os = "dragonfly" ) ) ]
1299
1319
#[ cfg( feature = "net" ) ]
1300
1320
ControlMessage :: Ipv4SendSrcAddr ( addr) => addr as * const _ as * const u8 ,
1321
+ #[ cfg( any( target_os = "linux" , target_os = "macos" ,
1322
+ target_os = "freebsd" , target_os = "dragonfly" ,
1323
+ target_os = "android" , target_os = "ios" ,
1324
+ target_os = "haiku" ) ) ]
1325
+ #[ cfg( feature = "net" ) ]
1326
+ ControlMessage :: Ipv6HopLimit ( limit) => limit as * const _ as * const u8 ,
1301
1327
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
1302
1328
ControlMessage :: RxqOvfl ( drop_count) => {
1303
1329
drop_count as * const _ as * const u8
@@ -1361,6 +1387,14 @@ impl<'a> ControlMessage<'a> {
1361
1387
target_os = "openbsd" , target_os = "dragonfly" ) ) ]
1362
1388
#[ cfg( feature = "net" ) ]
1363
1389
ControlMessage :: Ipv4SendSrcAddr ( addr) => mem:: size_of_val( addr) ,
1390
+ #[ cfg( any( target_os = "linux" , target_os = "macos" ,
1391
+ target_os = "freebsd" , target_os = "dragonfly" ,
1392
+ target_os = "android" , target_os = "ios" ,
1393
+ target_os = "haiku" ) ) ]
1394
+ #[ cfg( feature = "net" ) ]
1395
+ ControlMessage :: Ipv6HopLimit ( limit) => {
1396
+ mem:: size_of_val( limit)
1397
+ } ,
1364
1398
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
1365
1399
ControlMessage :: RxqOvfl ( drop_count) => {
1366
1400
mem:: size_of_val( drop_count)
@@ -1400,6 +1434,12 @@ impl<'a> ControlMessage<'a> {
1400
1434
target_os = "openbsd" , target_os = "dragonfly" ) ) ]
1401
1435
#[ cfg( feature = "net" ) ]
1402
1436
ControlMessage :: Ipv4SendSrcAddr ( _) => libc:: IPPROTO_IP ,
1437
+ #[ cfg( any( target_os = "linux" , target_os = "macos" ,
1438
+ target_os = "freebsd" , target_os = "dragonfly" ,
1439
+ target_os = "android" , target_os = "ios" ,
1440
+ target_os = "haiku" ) ) ]
1441
+ #[ cfg( feature = "net" ) ]
1442
+ ControlMessage :: Ipv6HopLimit ( _) => libc:: IPPROTO_IPV6 ,
1403
1443
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
1404
1444
ControlMessage :: RxqOvfl ( _) => libc:: SOL_SOCKET ,
1405
1445
#[ cfg( target_os = "linux" ) ]
@@ -1446,6 +1486,12 @@ impl<'a> ControlMessage<'a> {
1446
1486
target_os = "openbsd" , target_os = "dragonfly" ) ) ]
1447
1487
#[ cfg( feature = "net" ) ]
1448
1488
ControlMessage :: Ipv4SendSrcAddr ( _) => libc:: IP_SENDSRCADDR ,
1489
+ #[ cfg( any( target_os = "linux" , target_os = "macos" ,
1490
+ target_os = "freebsd" , target_os = "dragonfly" ,
1491
+ target_os = "android" , target_os = "ios" ,
1492
+ target_os = "haiku" ) ) ]
1493
+ #[ cfg( feature = "net" ) ]
1494
+ ControlMessage :: Ipv6HopLimit ( _) => libc:: IPV6_HOPLIMIT ,
1449
1495
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
1450
1496
ControlMessage :: RxqOvfl ( _) => {
1451
1497
libc:: SO_RXQ_OVFL
@@ -2186,9 +2232,7 @@ pub fn socketpair<T: Into<Option<SockProtocol>>>(
2186
2232
Errno :: result ( res) ?;
2187
2233
2188
2234
// Safe because socketpair returned success.
2189
- unsafe {
2190
- Ok ( ( OwnedFd :: from_raw_fd ( fds[ 0 ] ) , OwnedFd :: from_raw_fd ( fds[ 1 ] ) ) )
2191
- }
2235
+ unsafe { Ok ( ( OwnedFd :: from_raw_fd ( fds[ 0 ] ) , OwnedFd :: from_raw_fd ( fds[ 1 ] ) ) ) }
2192
2236
}
2193
2237
2194
2238
/// Listen for connections on a socket
@@ -2296,13 +2340,7 @@ pub fn recvfrom<T: SockaddrLike>(
2296
2340
& mut len as * mut socklen_t ,
2297
2341
) ) ? as usize ;
2298
2342
2299
- Ok ( (
2300
- ret,
2301
- T :: from_raw (
2302
- addr. assume_init ( ) . as_ptr ( ) ,
2303
- Some ( len) ,
2304
- ) ,
2305
- ) )
2343
+ Ok ( ( ret, T :: from_raw ( addr. assume_init ( ) . as_ptr ( ) , Some ( len) ) ) )
2306
2344
}
2307
2345
}
2308
2346
0 commit comments