@@ -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" ) ) ) ]
@@ -1118,7 +1122,7 @@ pub enum ControlMessage<'a> {
1118
1122
#[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1119
1123
UdpGsoSegments ( & ' a u16 ) ,
1120
1124
1121
- /// Configure the sending addressing and interface for v4
1125
+ /// Configure the sending addressing and interface for v4.
1122
1126
///
1123
1127
/// For further information, please refer to the
1124
1128
/// [`ip(7)`](https://man7.org/linux/man-pages/man7/ip.7.html) man page.
@@ -1131,7 +1135,7 @@ pub enum ControlMessage<'a> {
1131
1135
#[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1132
1136
Ipv4PacketInfo ( & ' a libc:: in_pktinfo) ,
1133
1137
1134
- /// Configure the sending addressing and interface for v6
1138
+ /// Configure the sending addressing and interface for v6.
1135
1139
///
1136
1140
/// For further information, please refer to the
1137
1141
/// [`ipv6(7)`](https://man7.org/linux/man-pages/man7/ipv6.7.html) man page.
@@ -1156,6 +1160,22 @@ pub enum ControlMessage<'a> {
1156
1160
#[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1157
1161
Ipv4SendSrcAddr ( & ' a libc:: in_addr) ,
1158
1162
1163
+ /// Configure the hop limit for v6 multicast traffic.
1164
+ ///
1165
+ /// Set the IPv6 hop limit for this message. The argument is an integer
1166
+ /// between 0 and 255. A value of -1 will set the hop limit to the route
1167
+ /// default if possible on the interface. Without this cmsg, packets sent
1168
+ /// with sendmsg have a hop limit of 1 and will not leave the local network.
1169
+ /// For further information, please refer to the
1170
+ /// [`ipv6(7)`](https://man7.org/linux/man-pages/man7/ipv6.7.html) man page.
1171
+ #[ cfg( any( target_os = "linux" , target_os = "macos" ,
1172
+ target_os = "freebsd" , target_os = "dragonfly" ,
1173
+ target_os = "android" , target_os = "ios" ,
1174
+ target_os = "haiku" ) ) ]
1175
+ #[ cfg( feature = "net" ) ]
1176
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1177
+ Ipv6HopLimit ( & ' a libc:: c_int) ,
1178
+
1159
1179
/// SO_RXQ_OVFL indicates that an unsigned 32 bit value
1160
1180
/// ancilliary msg (cmsg) should be attached to recieved
1161
1181
/// skbs indicating the number of packets dropped by the
@@ -1269,6 +1289,12 @@ impl<'a> ControlMessage<'a> {
1269
1289
target_os = "openbsd" , target_os = "dragonfly" ) ) ]
1270
1290
#[ cfg( feature = "net" ) ]
1271
1291
ControlMessage :: Ipv4SendSrcAddr ( addr) => addr as * const _ as * const u8 ,
1292
+ #[ cfg( any( target_os = "linux" , target_os = "macos" ,
1293
+ target_os = "freebsd" , target_os = "dragonfly" ,
1294
+ target_os = "android" , target_os = "ios" ,
1295
+ target_os = "haiku" ) ) ]
1296
+ #[ cfg( feature = "net" ) ]
1297
+ ControlMessage :: Ipv6HopLimit ( limit) => limit as * const _ as * const u8 ,
1272
1298
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
1273
1299
ControlMessage :: RxqOvfl ( drop_count) => {
1274
1300
drop_count as * const _ as * const u8
@@ -1332,6 +1358,14 @@ impl<'a> ControlMessage<'a> {
1332
1358
target_os = "openbsd" , target_os = "dragonfly" ) ) ]
1333
1359
#[ cfg( feature = "net" ) ]
1334
1360
ControlMessage :: Ipv4SendSrcAddr ( addr) => mem:: size_of_val( addr) ,
1361
+ #[ cfg( any( target_os = "linux" , target_os = "macos" ,
1362
+ target_os = "freebsd" , target_os = "dragonfly" ,
1363
+ target_os = "android" , target_os = "ios" ,
1364
+ target_os = "haiku" ) ) ]
1365
+ #[ cfg( feature = "net" ) ]
1366
+ ControlMessage :: Ipv6HopLimit ( limit) => {
1367
+ mem:: size_of_val( limit)
1368
+ } ,
1335
1369
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
1336
1370
ControlMessage :: RxqOvfl ( drop_count) => {
1337
1371
mem:: size_of_val( drop_count)
@@ -1371,6 +1405,12 @@ impl<'a> ControlMessage<'a> {
1371
1405
target_os = "openbsd" , target_os = "dragonfly" ) ) ]
1372
1406
#[ cfg( feature = "net" ) ]
1373
1407
ControlMessage :: Ipv4SendSrcAddr ( _) => libc:: IPPROTO_IP ,
1408
+ #[ cfg( any( target_os = "linux" , target_os = "macos" ,
1409
+ target_os = "freebsd" , target_os = "dragonfly" ,
1410
+ target_os = "android" , target_os = "ios" ,
1411
+ target_os = "haiku" ) ) ]
1412
+ #[ cfg( feature = "net" ) ]
1413
+ ControlMessage :: Ipv6HopLimit ( _) => libc:: IPPROTO_IPV6 ,
1374
1414
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
1375
1415
ControlMessage :: RxqOvfl ( _) => libc:: SOL_SOCKET ,
1376
1416
#[ cfg( target_os = "linux" ) ]
@@ -1417,6 +1457,12 @@ impl<'a> ControlMessage<'a> {
1417
1457
target_os = "openbsd" , target_os = "dragonfly" ) ) ]
1418
1458
#[ cfg( feature = "net" ) ]
1419
1459
ControlMessage :: Ipv4SendSrcAddr ( _) => libc:: IP_SENDSRCADDR ,
1460
+ #[ cfg( any( target_os = "linux" , target_os = "macos" ,
1461
+ target_os = "freebsd" , target_os = "dragonfly" ,
1462
+ target_os = "android" , target_os = "ios" ,
1463
+ target_os = "haiku" ) ) ]
1464
+ #[ cfg( feature = "net" ) ]
1465
+ ControlMessage :: Ipv6HopLimit ( _) => libc:: IPV6_HOPLIMIT ,
1420
1466
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
1421
1467
ControlMessage :: RxqOvfl ( _) => {
1422
1468
libc:: SO_RXQ_OVFL
@@ -2145,9 +2191,7 @@ pub fn socketpair<T: Into<Option<SockProtocol>>>(
2145
2191
Errno :: result ( res) ?;
2146
2192
2147
2193
// Safe because socketpair returned success.
2148
- unsafe {
2149
- Ok ( ( OwnedFd :: from_raw_fd ( fds[ 0 ] ) , OwnedFd :: from_raw_fd ( fds[ 1 ] ) ) )
2150
- }
2194
+ unsafe { Ok ( ( OwnedFd :: from_raw_fd ( fds[ 0 ] ) , OwnedFd :: from_raw_fd ( fds[ 1 ] ) ) ) }
2151
2195
}
2152
2196
2153
2197
/// Listen for connections on a socket
@@ -2255,13 +2299,7 @@ pub fn recvfrom<T: SockaddrLike>(
2255
2299
& mut len as * mut socklen_t ,
2256
2300
) ) ? as usize ;
2257
2301
2258
- Ok ( (
2259
- ret,
2260
- T :: from_raw (
2261
- addr. assume_init ( ) . as_ptr ( ) ,
2262
- Some ( len) ,
2263
- ) ,
2264
- ) )
2302
+ Ok ( ( ret, T :: from_raw ( addr. assume_init ( ) . as_ptr ( ) , Some ( len) ) ) )
2265
2303
}
2266
2304
}
2267
2305
0 commit comments