@@ -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" ) ) ) ]
@@ -1139,7 +1143,7 @@ pub enum ControlMessage<'a> {
1139
1143
#[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1140
1144
UdpGsoSegments ( & ' a u16 ) ,
1141
1145
1142
- /// Configure the sending addressing and interface for v4
1146
+ /// Configure the sending addressing and interface for v4.
1143
1147
///
1144
1148
/// For further information, please refer to the
1145
1149
/// [`ip(7)`](https://man7.org/linux/man-pages/man7/ip.7.html) man page.
@@ -1152,7 +1156,7 @@ pub enum ControlMessage<'a> {
1152
1156
#[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1153
1157
Ipv4PacketInfo ( & ' a libc:: in_pktinfo) ,
1154
1158
1155
- /// Configure the sending addressing and interface for v6
1159
+ /// Configure the sending addressing and interface for v6.
1156
1160
///
1157
1161
/// For further information, please refer to the
1158
1162
/// [`ipv6(7)`](https://man7.org/linux/man-pages/man7/ipv6.7.html) man page.
@@ -1177,6 +1181,22 @@ pub enum ControlMessage<'a> {
1177
1181
#[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1178
1182
Ipv4SendSrcAddr ( & ' a libc:: in_addr) ,
1179
1183
1184
+ /// Configure the hop limit for v6 multicast traffic.
1185
+ ///
1186
+ /// Set the IPv6 hop limit for this message. The argument is an integer
1187
+ /// between 0 and 255. A value of -1 will set the hop limit to the route
1188
+ /// default if possible on the interface. Without this cmsg, packets sent
1189
+ /// with sendmsg have a hop limit of 1 and will not leave the local network.
1190
+ /// For further information, please refer to the
1191
+ /// [`ipv6(7)`](https://man7.org/linux/man-pages/man7/ipv6.7.html) man page.
1192
+ #[ cfg( any( target_os = "linux" , target_os = "macos" ,
1193
+ target_os = "freebsd" , target_os = "dragonfly" ,
1194
+ target_os = "android" , target_os = "ios" ,
1195
+ target_os = "haiku" ) ) ]
1196
+ #[ cfg( feature = "net" ) ]
1197
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1198
+ Ipv6HopLimit ( & ' a libc:: c_int) ,
1199
+
1180
1200
/// SO_RXQ_OVFL indicates that an unsigned 32 bit value
1181
1201
/// ancilliary msg (cmsg) should be attached to recieved
1182
1202
/// skbs indicating the number of packets dropped by the
@@ -1290,6 +1310,12 @@ impl<'a> ControlMessage<'a> {
1290
1310
target_os = "openbsd" , target_os = "dragonfly" ) ) ]
1291
1311
#[ cfg( feature = "net" ) ]
1292
1312
ControlMessage :: Ipv4SendSrcAddr ( addr) => addr as * const _ as * const u8 ,
1313
+ #[ cfg( any( target_os = "linux" , target_os = "macos" ,
1314
+ target_os = "freebsd" , target_os = "dragonfly" ,
1315
+ target_os = "android" , target_os = "ios" ,
1316
+ target_os = "haiku" ) ) ]
1317
+ #[ cfg( feature = "net" ) ]
1318
+ ControlMessage :: Ipv6HopLimit ( limit) => limit as * const _ as * const u8 ,
1293
1319
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
1294
1320
ControlMessage :: RxqOvfl ( drop_count) => {
1295
1321
drop_count as * const _ as * const u8
@@ -1353,6 +1379,14 @@ impl<'a> ControlMessage<'a> {
1353
1379
target_os = "openbsd" , target_os = "dragonfly" ) ) ]
1354
1380
#[ cfg( feature = "net" ) ]
1355
1381
ControlMessage :: Ipv4SendSrcAddr ( addr) => mem:: size_of_val( addr) ,
1382
+ #[ cfg( any( target_os = "linux" , target_os = "macos" ,
1383
+ target_os = "freebsd" , target_os = "dragonfly" ,
1384
+ target_os = "android" , target_os = "ios" ,
1385
+ target_os = "haiku" ) ) ]
1386
+ #[ cfg( feature = "net" ) ]
1387
+ ControlMessage :: Ipv6HopLimit ( limit) => {
1388
+ mem:: size_of_val( limit)
1389
+ } ,
1356
1390
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
1357
1391
ControlMessage :: RxqOvfl ( drop_count) => {
1358
1392
mem:: size_of_val( drop_count)
@@ -1392,6 +1426,12 @@ impl<'a> ControlMessage<'a> {
1392
1426
target_os = "openbsd" , target_os = "dragonfly" ) ) ]
1393
1427
#[ cfg( feature = "net" ) ]
1394
1428
ControlMessage :: Ipv4SendSrcAddr ( _) => libc:: IPPROTO_IP ,
1429
+ #[ cfg( any( target_os = "linux" , target_os = "macos" ,
1430
+ target_os = "freebsd" , target_os = "dragonfly" ,
1431
+ target_os = "android" , target_os = "ios" ,
1432
+ target_os = "haiku" ) ) ]
1433
+ #[ cfg( feature = "net" ) ]
1434
+ ControlMessage :: Ipv6HopLimit ( _) => libc:: IPPROTO_IPV6 ,
1395
1435
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
1396
1436
ControlMessage :: RxqOvfl ( _) => libc:: SOL_SOCKET ,
1397
1437
#[ cfg( target_os = "linux" ) ]
@@ -1438,6 +1478,12 @@ impl<'a> ControlMessage<'a> {
1438
1478
target_os = "openbsd" , target_os = "dragonfly" ) ) ]
1439
1479
#[ cfg( feature = "net" ) ]
1440
1480
ControlMessage :: Ipv4SendSrcAddr ( _) => libc:: IP_SENDSRCADDR ,
1481
+ #[ cfg( any( target_os = "linux" , target_os = "macos" ,
1482
+ target_os = "freebsd" , target_os = "dragonfly" ,
1483
+ target_os = "android" , target_os = "ios" ,
1484
+ target_os = "haiku" ) ) ]
1485
+ #[ cfg( feature = "net" ) ]
1486
+ ControlMessage :: Ipv6HopLimit ( _) => libc:: IPV6_HOPLIMIT ,
1441
1487
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
1442
1488
ControlMessage :: RxqOvfl ( _) => {
1443
1489
libc:: SO_RXQ_OVFL
@@ -2166,9 +2212,7 @@ pub fn socketpair<T: Into<Option<SockProtocol>>>(
2166
2212
Errno :: result ( res) ?;
2167
2213
2168
2214
// Safe because socketpair returned success.
2169
- unsafe {
2170
- Ok ( ( OwnedFd :: from_raw_fd ( fds[ 0 ] ) , OwnedFd :: from_raw_fd ( fds[ 1 ] ) ) )
2171
- }
2215
+ unsafe { Ok ( ( OwnedFd :: from_raw_fd ( fds[ 0 ] ) , OwnedFd :: from_raw_fd ( fds[ 1 ] ) ) ) }
2172
2216
}
2173
2217
2174
2218
/// Listen for connections on a socket
@@ -2276,13 +2320,7 @@ pub fn recvfrom<T: SockaddrLike>(
2276
2320
& mut len as * mut socklen_t ,
2277
2321
) ) ? as usize ;
2278
2322
2279
- Ok ( (
2280
- ret,
2281
- T :: from_raw (
2282
- addr. assume_init ( ) . as_ptr ( ) ,
2283
- Some ( len) ,
2284
- ) ,
2285
- ) )
2323
+ Ok ( ( ret, T :: from_raw ( addr. assume_init ( ) . as_ptr ( ) , Some ( len) ) ) )
2286
2324
}
2287
2325
}
2288
2326
0 commit comments