1
+ //! Socket options as used by `setsockopt` and `getsockopt`.
1
2
use cfg_if:: cfg_if;
2
3
use super :: { GetSockOpt , SetSockOpt } ;
3
4
use crate :: Result ;
@@ -241,17 +242,45 @@ macro_rules! sockopt_impl {
241
242
*
242
243
*/
243
244
244
- sockopt_impl ! ( ReuseAddr , Both , libc:: SOL_SOCKET , libc:: SO_REUSEADDR , bool ) ;
245
+ sockopt_impl ! (
246
+ /// Enables local address reuse
247
+ ReuseAddr , Both , libc:: SOL_SOCKET , libc:: SO_REUSEADDR , bool
248
+ ) ;
245
249
#[ cfg( not( any( target_os = "illumos" , target_os = "solaris" ) ) ) ]
246
- sockopt_impl ! ( ReusePort , Both , libc:: SOL_SOCKET , libc:: SO_REUSEPORT , bool ) ;
247
- sockopt_impl ! ( TcpNoDelay , Both , libc:: IPPROTO_TCP , libc:: TCP_NODELAY , bool ) ;
248
- sockopt_impl ! ( Linger , Both , libc:: SOL_SOCKET , libc:: SO_LINGER , libc:: linger) ;
249
- sockopt_impl ! ( IpAddMembership , SetOnly , libc:: IPPROTO_IP , libc:: IP_ADD_MEMBERSHIP , super :: IpMembershipRequest ) ;
250
- sockopt_impl ! ( IpDropMembership , SetOnly , libc:: IPPROTO_IP , libc:: IP_DROP_MEMBERSHIP , super :: IpMembershipRequest ) ;
250
+ sockopt_impl ! (
251
+ /// Permits multiple AF_INET or AF_INET6 sockets to be bound to an
252
+ /// identical socket address.
253
+ ReusePort , Both , libc:: SOL_SOCKET , libc:: SO_REUSEPORT , bool ) ;
254
+ sockopt_impl ! (
255
+ /// Under most circumstances, TCP sends data when it is presented; when
256
+ /// outstanding data has not yet been acknowledged, it gathers small amounts
257
+ /// of output to be sent in a single packet once an acknowledgement is
258
+ /// received. For a small number of clients, such as window systems that
259
+ /// send a stream of mouse events which receive no replies, this
260
+ /// packetization may cause significant delays. The boolean option
261
+ /// TCP_NODELAY defeats this algorithm.
262
+ TcpNoDelay , Both , libc:: IPPROTO_TCP , libc:: TCP_NODELAY , bool ) ;
263
+ sockopt_impl ! (
264
+ /// When enabled, a close(2) or shutdown(2) will not return until all
265
+ /// queued messages for the socket have been successfully sent or the
266
+ /// linger timeout has been reached.
267
+ Linger , Both , libc:: SOL_SOCKET , libc:: SO_LINGER , libc:: linger) ;
268
+ sockopt_impl ! (
269
+ /// Join a multicast group
270
+ IpAddMembership , SetOnly , libc:: IPPROTO_IP , libc:: IP_ADD_MEMBERSHIP ,
271
+ super :: IpMembershipRequest ) ;
272
+ sockopt_impl ! (
273
+ /// Leave a multicast group.
274
+ IpDropMembership , SetOnly , libc:: IPPROTO_IP , libc:: IP_DROP_MEMBERSHIP ,
275
+ super :: IpMembershipRequest ) ;
251
276
cfg_if ! {
252
277
if #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ] {
253
- sockopt_impl!( Ipv6AddMembership , SetOnly , libc:: IPPROTO_IPV6 , libc:: IPV6_ADD_MEMBERSHIP , super :: Ipv6MembershipRequest ) ;
254
- sockopt_impl!( Ipv6DropMembership , SetOnly , libc:: IPPROTO_IPV6 , libc:: IPV6_DROP_MEMBERSHIP , super :: Ipv6MembershipRequest ) ;
278
+ sockopt_impl!(
279
+ /// Join an IPv6 multicast group.
280
+ Ipv6AddMembership , SetOnly , libc:: IPPROTO_IPV6 , libc:: IPV6_ADD_MEMBERSHIP , super :: Ipv6MembershipRequest ) ;
281
+ sockopt_impl!(
282
+ /// Leave an IPv6 multicast group.
283
+ Ipv6DropMembership , SetOnly , libc:: IPPROTO_IPV6 , libc:: IPV6_DROP_MEMBERSHIP , super :: Ipv6MembershipRequest ) ;
255
284
} else if #[ cfg( any( target_os = "dragonfly" ,
256
285
target_os = "freebsd" ,
257
286
target_os = "illumos" ,
@@ -260,93 +289,194 @@ cfg_if! {
260
289
target_os = "netbsd" ,
261
290
target_os = "openbsd" ,
262
291
target_os = "solaris" ) ) ] {
263
- sockopt_impl!( Ipv6AddMembership , SetOnly , libc:: IPPROTO_IPV6 , libc:: IPV6_JOIN_GROUP , super :: Ipv6MembershipRequest ) ;
264
- sockopt_impl!( Ipv6DropMembership , SetOnly , libc:: IPPROTO_IPV6 , libc:: IPV6_LEAVE_GROUP , super :: Ipv6MembershipRequest ) ;
292
+ sockopt_impl!(
293
+ /// Join an IPv6 multicast group.
294
+ Ipv6AddMembership , SetOnly , libc:: IPPROTO_IPV6 ,
295
+ libc:: IPV6_JOIN_GROUP , super :: Ipv6MembershipRequest ) ;
296
+ sockopt_impl!(
297
+ /// Leave an IPv6 multicast group.
298
+ Ipv6DropMembership , SetOnly , libc:: IPPROTO_IPV6 ,
299
+ libc:: IPV6_LEAVE_GROUP , super :: Ipv6MembershipRequest ) ;
265
300
}
266
301
}
267
- sockopt_impl ! ( IpMulticastTtl , Both , libc:: IPPROTO_IP , libc:: IP_MULTICAST_TTL , u8 ) ;
268
- sockopt_impl ! ( IpMulticastLoop , Both , libc:: IPPROTO_IP , libc:: IP_MULTICAST_LOOP , bool ) ;
302
+ sockopt_impl ! (
303
+ /// Set or read the time-to-live value of outgoing multicast packets for
304
+ /// this socket.
305
+ IpMulticastTtl , Both , libc:: IPPROTO_IP , libc:: IP_MULTICAST_TTL , u8 ) ;
306
+ sockopt_impl ! (
307
+ /// Set or read a boolean integer argument that determines whether sent
308
+ /// multicast packets should be looped back to the local sockets.
309
+ IpMulticastLoop , Both , libc:: IPPROTO_IP , libc:: IP_MULTICAST_LOOP , bool ) ;
269
310
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
270
- sockopt_impl ! ( IpFreebind , Both , libc:: IPPROTO_IP , libc:: IP_FREEBIND , bool ) ;
271
- sockopt_impl ! ( ReceiveTimeout , Both , libc:: SOL_SOCKET , libc:: SO_RCVTIMEO , TimeVal ) ;
272
- sockopt_impl ! ( SendTimeout , Both , libc:: SOL_SOCKET , libc:: SO_SNDTIMEO , TimeVal ) ;
273
- sockopt_impl ! ( Broadcast , Both , libc:: SOL_SOCKET , libc:: SO_BROADCAST , bool ) ;
274
- sockopt_impl ! ( OobInline , Both , libc:: SOL_SOCKET , libc:: SO_OOBINLINE , bool ) ;
275
- sockopt_impl ! ( SocketError , GetOnly , libc:: SOL_SOCKET , libc:: SO_ERROR , i32 ) ;
276
- sockopt_impl ! ( KeepAlive , Both , libc:: SOL_SOCKET , libc:: SO_KEEPALIVE , bool ) ;
311
+ sockopt_impl ! (
312
+ /// If enabled, this boolean option allows binding to an IP address that
313
+ /// is nonlocal or does not (yet) exist.
314
+ IpFreebind , Both , libc:: IPPROTO_IP , libc:: IP_FREEBIND , bool ) ;
315
+ sockopt_impl ! (
316
+ /// Specify the receiving timeout until reporting an error.
317
+ ReceiveTimeout , Both , libc:: SOL_SOCKET , libc:: SO_RCVTIMEO , TimeVal ) ;
318
+ sockopt_impl ! (
319
+ /// Specify the sending timeout until reporting an error.
320
+ SendTimeout , Both , libc:: SOL_SOCKET , libc:: SO_SNDTIMEO , TimeVal ) ;
321
+ sockopt_impl ! (
322
+ /// Set or get the broadcast flag.
323
+ Broadcast , Both , libc:: SOL_SOCKET , libc:: SO_BROADCAST , bool ) ;
324
+ sockopt_impl ! (
325
+ /// If this option is enabled, out-of-band data is directly placed into
326
+ /// the receive data stream.
327
+ OobInline , Both , libc:: SOL_SOCKET , libc:: SO_OOBINLINE , bool ) ;
328
+ sockopt_impl ! (
329
+ /// Get and clear the pending socket error.
330
+ SocketError , GetOnly , libc:: SOL_SOCKET , libc:: SO_ERROR , i32 ) ;
331
+ sockopt_impl ! (
332
+ /// Enable sending of keep-alive messages on connection-oriented sockets.
333
+ KeepAlive , Both , libc:: SOL_SOCKET , libc:: SO_KEEPALIVE , bool ) ;
277
334
#[ cfg( any(
278
335
target_os = "dragonfly" ,
279
336
target_os = "freebsd" ,
280
337
target_os = "macos" ,
281
338
target_os = "ios"
282
339
) ) ]
283
- // Get the credentials of the peer process of a connected unix domain socket.
284
- sockopt_impl ! ( LocalPeerCred , GetOnly , 0 , libc:: LOCAL_PEERCRED , super :: XuCred ) ;
340
+ sockopt_impl ! (
341
+ /// Get the credentials of the peer process of a connected unix domain
342
+ /// socket.
343
+ LocalPeerCred , GetOnly , 0 , libc:: LOCAL_PEERCRED , super :: XuCred ) ;
285
344
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
286
- sockopt_impl ! ( PeerCredentials , GetOnly , libc:: SOL_SOCKET , libc:: SO_PEERCRED , super :: UnixCredentials ) ;
345
+ sockopt_impl ! (
346
+ /// Return the credentials of the foreign process connected to this socket.
347
+ PeerCredentials , GetOnly , libc:: SOL_SOCKET , libc:: SO_PEERCRED , super :: UnixCredentials ) ;
287
348
#[ cfg( any( target_os = "ios" ,
288
349
target_os = "macos" ) ) ]
289
- sockopt_impl ! ( TcpKeepAlive , Both , libc:: IPPROTO_TCP , libc:: TCP_KEEPALIVE , u32 ) ;
350
+ sockopt_impl ! (
351
+ /// Specify the amount of time, in seconds, that the connection must be idle
352
+ /// before keepalive probes (if enabled) are sent.
353
+ TcpKeepAlive , Both , libc:: IPPROTO_TCP , libc:: TCP_KEEPALIVE , u32 ) ;
290
354
#[ cfg( any( target_os = "android" ,
291
355
target_os = "dragonfly" ,
292
356
target_os = "freebsd" ,
293
357
target_os = "linux" ,
294
358
target_os = "nacl" ) ) ]
295
- sockopt_impl ! ( TcpKeepIdle , Both , libc:: IPPROTO_TCP , libc:: TCP_KEEPIDLE , u32 ) ;
359
+ sockopt_impl ! (
360
+ /// The time (in seconds) the connection needs to remain idle before TCP
361
+ /// starts sending keepalive probes
362
+ TcpKeepIdle , Both , libc:: IPPROTO_TCP , libc:: TCP_KEEPIDLE , u32 ) ;
296
363
cfg_if ! {
297
364
if #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ] {
298
- sockopt_impl!( TcpMaxSeg , Both , libc:: IPPROTO_TCP , libc:: TCP_MAXSEG , u32 ) ;
365
+ sockopt_impl!(
366
+ /// The maximum segment size for outgoing TCP packets.
367
+ TcpMaxSeg , Both , libc:: IPPROTO_TCP , libc:: TCP_MAXSEG , u32 ) ;
299
368
} else {
300
- sockopt_impl!( TcpMaxSeg , GetOnly , libc:: IPPROTO_TCP , libc:: TCP_MAXSEG , u32 ) ;
369
+ sockopt_impl!(
370
+ /// The maximum segment size for outgoing TCP packets.
371
+ TcpMaxSeg , GetOnly , libc:: IPPROTO_TCP , libc:: TCP_MAXSEG , u32 ) ;
301
372
}
302
373
}
303
374
#[ cfg( not( target_os = "openbsd" ) ) ]
304
- sockopt_impl ! ( TcpKeepCount , Both , libc:: IPPROTO_TCP , libc:: TCP_KEEPCNT , u32 ) ;
375
+ sockopt_impl ! (
376
+ /// The maximum number of keepalive probes TCP should send before
377
+ /// dropping the connection.
378
+ TcpKeepCount , Both , libc:: IPPROTO_TCP , libc:: TCP_KEEPCNT , u32 ) ;
305
379
#[ cfg( any( target_os = "android" ,
306
380
target_os = "fuchsia" ,
307
381
target_os = "linux" ) ) ]
308
- sockopt_impl ! ( TcpRepair , Both , libc:: IPPROTO_TCP , libc:: TCP_REPAIR , u32 ) ;
382
+ sockopt_impl ! (
383
+ #[ allow( missing_docs) ]
384
+ // Not documented by Linux!
385
+ TcpRepair , Both , libc:: IPPROTO_TCP , libc:: TCP_REPAIR , u32 ) ;
309
386
#[ cfg( not( target_os = "openbsd" ) ) ]
310
- sockopt_impl ! ( TcpKeepInterval , Both , libc:: IPPROTO_TCP , libc:: TCP_KEEPINTVL , u32 ) ;
387
+ sockopt_impl ! (
388
+ /// The time (in seconds) between individual keepalive probes.
389
+ TcpKeepInterval , Both , libc:: IPPROTO_TCP , libc:: TCP_KEEPINTVL , u32 ) ;
311
390
#[ cfg( any( target_os = "fuchsia" , target_os = "linux" ) ) ]
312
- sockopt_impl ! ( TcpUserTimeout , Both , libc:: IPPROTO_TCP , libc:: TCP_USER_TIMEOUT , u32 ) ;
313
- sockopt_impl ! ( RcvBuf , Both , libc:: SOL_SOCKET , libc:: SO_RCVBUF , usize ) ;
314
- sockopt_impl ! ( SndBuf , Both , libc:: SOL_SOCKET , libc:: SO_SNDBUF , usize ) ;
391
+ sockopt_impl ! (
392
+ /// Specifies the maximum amount of time in milliseconds that transmitted
393
+ /// data may remain unacknowledged before TCP will forcibly close the
394
+ /// corresponding connection
395
+ TcpUserTimeout , Both , libc:: IPPROTO_TCP , libc:: TCP_USER_TIMEOUT , u32 ) ;
396
+ sockopt_impl ! (
397
+ /// Sets or gets the maximum socket receive buffer in bytes.
398
+ RcvBuf , Both , libc:: SOL_SOCKET , libc:: SO_RCVBUF , usize ) ;
399
+ sockopt_impl ! (
400
+ /// Sets or gets the maximum socket send buffer in bytes.
401
+ SndBuf , Both , libc:: SOL_SOCKET , libc:: SO_SNDBUF , usize ) ;
315
402
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
316
- sockopt_impl ! ( RcvBufForce , SetOnly , libc:: SOL_SOCKET , libc:: SO_RCVBUFFORCE , usize ) ;
403
+ sockopt_impl ! (
404
+ /// Using this socket option, a privileged (`CAP_NET_ADMIN`) process can
405
+ /// perform the same task as `SO_RCVBUF`, but the `rmem_max limit` can be
406
+ /// overridden.
407
+ RcvBufForce , SetOnly , libc:: SOL_SOCKET , libc:: SO_RCVBUFFORCE , usize ) ;
317
408
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
318
- sockopt_impl ! ( SndBufForce , SetOnly , libc:: SOL_SOCKET , libc:: SO_SNDBUFFORCE , usize ) ;
319
- sockopt_impl ! ( SockType , GetOnly , libc:: SOL_SOCKET , libc:: SO_TYPE , super :: SockType ) ;
320
- sockopt_impl ! ( AcceptConn , GetOnly , libc:: SOL_SOCKET , libc:: SO_ACCEPTCONN , bool ) ;
409
+ sockopt_impl ! (
410
+ /// Using this socket option, a privileged (`CAP_NET_ADMIN`) process can
411
+ /// perform the same task as `SO_SNDBUF`, but the `wmem_max` limit can be
412
+ /// overridden.
413
+ SndBufForce , SetOnly , libc:: SOL_SOCKET , libc:: SO_SNDBUFFORCE , usize ) ;
414
+ sockopt_impl ! (
415
+ /// Gets the socket type as an integer.
416
+ SockType , GetOnly , libc:: SOL_SOCKET , libc:: SO_TYPE , super :: SockType ) ;
417
+ sockopt_impl ! (
418
+ /// Returns a value indicating whether or not this socket has been marked to
419
+ /// accept connections with `listen(2)`.
420
+ AcceptConn , GetOnly , libc:: SOL_SOCKET , libc:: SO_ACCEPTCONN , bool ) ;
321
421
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
322
- sockopt_impl ! ( BindToDevice , Both , libc:: SOL_SOCKET , libc:: SO_BINDTODEVICE , OsString <[ u8 ; libc:: IFNAMSIZ ] >) ;
422
+ sockopt_impl ! (
423
+ /// Bind this socket to a particular device like “eth0”.
424
+ BindToDevice , Both , libc:: SOL_SOCKET , libc:: SO_BINDTODEVICE , OsString <[ u8 ; libc:: IFNAMSIZ ] >) ;
323
425
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
324
- sockopt_impl ! ( OriginalDst , GetOnly , libc:: SOL_IP , libc:: SO_ORIGINAL_DST , libc:: sockaddr_in) ;
426
+ sockopt_impl ! (
427
+ #[ allow( missing_docs) ]
428
+ // Not documented by Linux!
429
+ OriginalDst , GetOnly , libc:: SOL_IP , libc:: SO_ORIGINAL_DST , libc:: sockaddr_in) ;
325
430
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
326
- sockopt_impl ! ( Ip6tOriginalDst , GetOnly , libc:: SOL_IPV6 , libc:: IP6T_SO_ORIGINAL_DST , libc:: sockaddr_in6) ;
327
- sockopt_impl ! ( ReceiveTimestamp , Both , libc:: SOL_SOCKET , libc:: SO_TIMESTAMP , bool ) ;
431
+ sockopt_impl ! (
432
+ #[ allow( missing_docs) ]
433
+ // Not documented by Linux!
434
+ Ip6tOriginalDst , GetOnly , libc:: SOL_IPV6 , libc:: IP6T_SO_ORIGINAL_DST , libc:: sockaddr_in6) ;
435
+ sockopt_impl ! (
436
+ /// Enable or disable the receiving of the `SO_TIMESTAMP` control message.
437
+ ReceiveTimestamp , Both , libc:: SOL_SOCKET , libc:: SO_TIMESTAMP , bool ) ;
328
438
#[ cfg( all( target_os = "linux" ) ) ]
329
- sockopt_impl ! ( ReceiveTimestampns , Both , libc:: SOL_SOCKET , libc:: SO_TIMESTAMPNS , bool ) ;
439
+ sockopt_impl ! (
440
+ /// Enable or disable the receiving of the `SO_TIMESTAMPNS` control message.
441
+ ReceiveTimestampns , Both , libc:: SOL_SOCKET , libc:: SO_TIMESTAMPNS , bool ) ;
330
442
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
331
- sockopt_impl ! ( IpTransparent , Both , libc:: SOL_IP , libc:: IP_TRANSPARENT , bool ) ;
443
+ sockopt_impl ! (
444
+ /// Setting this boolean option enables transparent proxying on this socket.
445
+ IpTransparent , Both , libc:: SOL_IP , libc:: IP_TRANSPARENT , bool ) ;
332
446
#[ cfg( target_os = "openbsd" ) ]
333
- sockopt_impl ! ( BindAny , Both , libc:: SOL_SOCKET , libc:: SO_BINDANY , bool ) ;
447
+ sockopt_impl ! (
448
+ BindAny , Both , libc:: SOL_SOCKET , libc:: SO_BINDANY , bool ) ;
334
449
#[ cfg( target_os = "freebsd" ) ]
335
- sockopt_impl ! ( BindAny , Both , libc:: IPPROTO_IP , libc:: IP_BINDANY , bool ) ;
450
+ sockopt_impl ! (
451
+ /// Can `bind(2)` to any address, even one not bound to any available
452
+ /// network interface in the system.
453
+ BindAny , Both , libc:: IPPROTO_IP , libc:: IP_BINDANY , bool ) ;
336
454
#[ cfg( target_os = "linux" ) ]
337
- sockopt_impl ! ( Mark , Both , libc:: SOL_SOCKET , libc:: SO_MARK , u32 ) ;
455
+ sockopt_impl ! (
456
+ /// Set the mark for each packet sent through this socket (similar to the
457
+ /// netfilter MARK target but socket-based).
458
+ Mark , Both , libc:: SOL_SOCKET , libc:: SO_MARK , u32 ) ;
338
459
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
339
- sockopt_impl ! ( PassCred , Both , libc:: SOL_SOCKET , libc:: SO_PASSCRED , bool ) ;
460
+ sockopt_impl ! (
461
+ /// Enable or disable the receiving of the `SCM_CREDENTIALS` control
462
+ /// message.
463
+ PassCred , Both , libc:: SOL_SOCKET , libc:: SO_PASSCRED , bool ) ;
340
464
#[ cfg( any( target_os = "freebsd" , target_os = "linux" ) ) ]
341
- sockopt_impl ! ( TcpCongestion , Both , libc:: IPPROTO_TCP , libc:: TCP_CONGESTION , OsString <[ u8 ; TCP_CA_NAME_MAX ] >) ;
465
+ sockopt_impl ! (
466
+ /// This option allows the caller to set the TCP congestion control
467
+ /// algorithm to be used, on a per-socket basis.
468
+ TcpCongestion , Both , libc:: IPPROTO_TCP , libc:: TCP_CONGESTION , OsString <[ u8 ; TCP_CA_NAME_MAX ] >) ;
342
469
#[ cfg( any(
343
470
target_os = "android" ,
344
471
target_os = "ios" ,
345
472
target_os = "linux" ,
346
473
target_os = "macos" ,
347
474
target_os = "netbsd" ,
348
475
) ) ]
349
- sockopt_impl ! ( Ipv4PacketInfo , Both , libc:: IPPROTO_IP , libc:: IP_PKTINFO , bool ) ;
476
+ sockopt_impl ! (
477
+ /// Pass an `IP_PKTINFO` ancillary message that contains a pktinfo
478
+ /// structure that supplies some information about the incoming packet.
479
+ Ipv4PacketInfo , Both , libc:: IPPROTO_IP , libc:: IP_PKTINFO , bool ) ;
350
480
#[ cfg( any(
351
481
target_os = "android" ,
352
482
target_os = "freebsd" ,
@@ -356,39 +486,71 @@ sockopt_impl!(Ipv4PacketInfo, Both, libc::IPPROTO_IP, libc::IP_PKTINFO, bool);
356
486
target_os = "netbsd" ,
357
487
target_os = "openbsd" ,
358
488
) ) ]
359
- sockopt_impl ! ( Ipv6RecvPacketInfo , Both , libc:: IPPROTO_IPV6 , libc:: IPV6_RECVPKTINFO , bool ) ;
489
+ sockopt_impl ! (
490
+ /// Set delivery of the `IPV6_PKTINFO` control message on incoming
491
+ /// datagrams.
492
+ Ipv6RecvPacketInfo , Both , libc:: IPPROTO_IPV6 , libc:: IPV6_RECVPKTINFO , bool ) ;
360
493
#[ cfg( any(
361
494
target_os = "freebsd" ,
362
495
target_os = "ios" ,
363
496
target_os = "macos" ,
364
497
target_os = "netbsd" ,
365
498
target_os = "openbsd" ,
366
499
) ) ]
367
- sockopt_impl ! ( Ipv4RecvIf , Both , libc:: IPPROTO_IP , libc:: IP_RECVIF , bool ) ;
500
+ sockopt_impl ! (
501
+ /// The `recvmsg(2)` call returns a `struct sockaddr_dl` corresponding to
502
+ /// the interface on which the packet was received.
503
+ Ipv4RecvIf , Both , libc:: IPPROTO_IP , libc:: IP_RECVIF , bool ) ;
368
504
#[ cfg( any(
369
505
target_os = "freebsd" ,
370
506
target_os = "ios" ,
371
507
target_os = "macos" ,
372
508
target_os = "netbsd" ,
373
509
target_os = "openbsd" ,
374
510
) ) ]
375
- sockopt_impl ! ( Ipv4RecvDstAddr , Both , libc:: IPPROTO_IP , libc:: IP_RECVDSTADDR , bool ) ;
511
+ sockopt_impl ! (
512
+ /// The `recvmsg(2)` call will return the destination IP address for a UDP
513
+ /// datagram.
514
+ Ipv4RecvDstAddr , Both , libc:: IPPROTO_IP , libc:: IP_RECVDSTADDR , bool ) ;
376
515
#[ cfg( target_os = "linux" ) ]
377
- sockopt_impl ! ( UdpGsoSegment , Both , libc:: SOL_UDP , libc:: UDP_SEGMENT , libc:: c_int) ;
516
+ sockopt_impl ! (
517
+ #[ allow( missing_docs) ]
518
+ // Not documented by Linux!
519
+ UdpGsoSegment , Both , libc:: SOL_UDP , libc:: UDP_SEGMENT , libc:: c_int) ;
378
520
#[ cfg( target_os = "linux" ) ]
379
- sockopt_impl ! ( UdpGroSegment , Both , libc:: IPPROTO_UDP , libc:: UDP_GRO , bool ) ;
521
+ sockopt_impl ! (
522
+ #[ allow( missing_docs) ]
523
+ // Not documented by Linux!
524
+ UdpGroSegment , Both , libc:: IPPROTO_UDP , libc:: UDP_GRO , bool ) ;
380
525
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
381
- sockopt_impl ! ( RxqOvfl , Both , libc:: SOL_SOCKET , libc:: SO_RXQ_OVFL , libc:: c_int) ;
382
- sockopt_impl ! ( Ipv6V6Only , Both , libc:: IPPROTO_IPV6 , libc:: IPV6_V6ONLY , bool ) ;
526
+ sockopt_impl ! (
527
+ /// Indicates that an unsigned 32-bit value ancillary message (cmsg) should
528
+ /// be attached to received skbs indicating the number of packets dropped by
529
+ /// the socket since its creation.
530
+ RxqOvfl , Both , libc:: SOL_SOCKET , libc:: SO_RXQ_OVFL , libc:: c_int) ;
531
+ sockopt_impl ! (
532
+ /// The socket is restricted to sending and receiving IPv6 packets only.
533
+ Ipv6V6Only , Both , libc:: IPPROTO_IPV6 , libc:: IPV6_V6ONLY , bool ) ;
383
534
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
384
- sockopt_impl ! ( Ipv4RecvErr , Both , libc:: IPPROTO_IP , libc:: IP_RECVERR , bool ) ;
535
+ sockopt_impl ! (
536
+ /// Enable extended reliable error message passing.
537
+ Ipv4RecvErr , Both , libc:: IPPROTO_IP , libc:: IP_RECVERR , bool ) ;
385
538
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
386
- sockopt_impl ! ( Ipv6RecvErr , Both , libc:: IPPROTO_IPV6 , libc:: IPV6_RECVERR , bool ) ;
539
+ sockopt_impl ! (
540
+ /// Control receiving of asynchronous error options.
541
+ Ipv6RecvErr , Both , libc:: IPPROTO_IPV6 , libc:: IPV6_RECVERR , bool ) ;
387
542
#[ cfg( any( target_os = "android" , target_os = "freebsd" , target_os = "linux" ) ) ]
388
- sockopt_impl ! ( Ipv4Ttl , Both , libc:: IPPROTO_IP , libc:: IP_TTL , libc:: c_int) ;
543
+ sockopt_impl ! (
544
+ /// Set or retrieve the current time-to-live field that is used in every
545
+ /// packet sent from this socket.
546
+ Ipv4Ttl , Both , libc:: IPPROTO_IP , libc:: IP_TTL , libc:: c_int) ;
389
547
#[ cfg( any( target_os = "android" , target_os = "freebsd" , target_os = "linux" ) ) ]
390
- sockopt_impl ! ( Ipv6Ttl , Both , libc:: IPPROTO_IPV6 , libc:: IPV6_UNICAST_HOPS , libc:: c_int) ;
548
+ sockopt_impl ! (
549
+ /// Set the unicast hop limit for the socket.
550
+ Ipv6Ttl , Both , libc:: IPPROTO_IPV6 , libc:: IPV6_UNICAST_HOPS , libc:: c_int) ;
391
551
552
+ #[ allow( missing_docs) ]
553
+ // Not documented by Linux!
392
554
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
393
555
#[ derive( Copy , Clone , Debug ) ]
394
556
pub struct AlgSetAeadAuthSize ;
@@ -411,6 +573,8 @@ impl SetSockOpt for AlgSetAeadAuthSize {
411
573
}
412
574
}
413
575
576
+ #[ allow( missing_docs) ]
577
+ // Not documented by Linux!
414
578
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
415
579
#[ derive( Clone , Debug ) ]
416
580
pub struct AlgSetKey < T > ( :: std:: marker:: PhantomData < T > ) ;
0 commit comments