@@ -129,8 +129,6 @@ macro_rules! getsockopt_impl {
129
129
/// * `$ty:ty`: type of the value that will be get/set.
130
130
/// * `$getter:ty`: `Get` implementation; optional; only for `GetOnly` and `Both`.
131
131
/// * `$setter:ty`: `Set` implementation; optional; only for `SetOnly` and `Both`.
132
- // TODO: make sockopt_impl work with:
133
- // * cfg(doc) (and therefore feature!)
134
132
macro_rules! sockopt_impl {
135
133
( $( #[ $attr: meta] ) * $name: ident, GetOnly , $level: expr, $flag: path, bool ) => {
136
134
sockopt_impl!( $( #[ $attr] ) *
@@ -254,8 +252,9 @@ sockopt_impl!(
254
252
/// Permits multiple AF_INET or AF_INET6 sockets to be bound to an
255
253
/// identical socket address.
256
254
ReusePort , Both , libc:: SOL_SOCKET , libc:: SO_REUSEPORT , bool ) ;
257
- #[ cfg( feature = "net" ) ]
258
255
sockopt_impl ! (
256
+ #[ cfg( feature = "net" ) ]
257
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
259
258
/// Under most circumstances, TCP sends data when it is presented; when
260
259
/// outstanding data has not yet been acknowledged, it gathers small amounts
261
260
/// of output to be sent in a single packet once an acknowledgement is
@@ -269,24 +268,28 @@ sockopt_impl!(
269
268
/// queued messages for the socket have been successfully sent or the
270
269
/// linger timeout has been reached.
271
270
Linger , Both , libc:: SOL_SOCKET , libc:: SO_LINGER , libc:: linger) ;
272
- #[ cfg( feature = "net" ) ]
273
271
sockopt_impl ! (
272
+ #[ cfg( feature = "net" ) ]
273
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
274
274
/// Join a multicast group
275
275
IpAddMembership , SetOnly , libc:: IPPROTO_IP , libc:: IP_ADD_MEMBERSHIP ,
276
276
super :: IpMembershipRequest ) ;
277
- #[ cfg( feature = "net" ) ]
278
277
sockopt_impl ! (
278
+ #[ cfg( feature = "net" ) ]
279
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
279
280
/// Leave a multicast group.
280
281
IpDropMembership , SetOnly , libc:: IPPROTO_IP , libc:: IP_DROP_MEMBERSHIP ,
281
282
super :: IpMembershipRequest ) ;
282
283
cfg_if ! {
283
284
if #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ] {
284
- #[ cfg( feature = "net" ) ]
285
285
sockopt_impl!(
286
+ #[ cfg( feature = "net" ) ]
287
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
286
288
/// Join an IPv6 multicast group.
287
289
Ipv6AddMembership , SetOnly , libc:: IPPROTO_IPV6 , libc:: IPV6_ADD_MEMBERSHIP , super :: Ipv6MembershipRequest ) ;
288
- #[ cfg( feature = "net" ) ]
289
290
sockopt_impl!(
291
+ #[ cfg( feature = "net" ) ]
292
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
290
293
/// Leave an IPv6 multicast group.
291
294
Ipv6DropMembership , SetOnly , libc:: IPPROTO_IPV6 , libc:: IPV6_DROP_MEMBERSHIP , super :: Ipv6MembershipRequest ) ;
292
295
} else if #[ cfg( any( target_os = "dragonfly" ,
@@ -297,31 +300,36 @@ cfg_if! {
297
300
target_os = "netbsd" ,
298
301
target_os = "openbsd" ,
299
302
target_os = "solaris" ) ) ] {
300
- #[ cfg( feature = "net" ) ]
301
303
sockopt_impl!(
304
+ #[ cfg( feature = "net" ) ]
305
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
302
306
/// Join an IPv6 multicast group.
303
307
Ipv6AddMembership , SetOnly , libc:: IPPROTO_IPV6 ,
304
308
libc:: IPV6_JOIN_GROUP , super :: Ipv6MembershipRequest ) ;
305
- #[ cfg( feature = "net" ) ]
306
309
sockopt_impl!(
310
+ #[ cfg( feature = "net" ) ]
311
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
307
312
/// Leave an IPv6 multicast group.
308
313
Ipv6DropMembership , SetOnly , libc:: IPPROTO_IPV6 ,
309
314
libc:: IPV6_LEAVE_GROUP , super :: Ipv6MembershipRequest ) ;
310
315
}
311
316
}
312
- #[ cfg( feature = "net" ) ]
313
317
sockopt_impl ! (
318
+ #[ cfg( feature = "net" ) ]
319
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
314
320
/// Set or read the time-to-live value of outgoing multicast packets for
315
321
/// this socket.
316
322
IpMulticastTtl , Both , libc:: IPPROTO_IP , libc:: IP_MULTICAST_TTL , u8 ) ;
317
- #[ cfg( feature = "net" ) ]
318
323
sockopt_impl ! (
324
+ #[ cfg( feature = "net" ) ]
325
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
319
326
/// Set or read a boolean integer argument that determines whether sent
320
327
/// multicast packets should be looped back to the local sockets.
321
328
IpMulticastLoop , Both , libc:: IPPROTO_IP , libc:: IP_MULTICAST_LOOP , bool ) ;
322
329
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
323
- #[ cfg( feature = "net" ) ]
324
330
sockopt_impl ! (
331
+ #[ cfg( feature = "net" ) ]
332
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
325
333
/// If enabled, this boolean option allows binding to an IP address that
326
334
/// is nonlocal or does not (yet) exist.
327
335
IpFreebind , Both , libc:: IPPROTO_IP , libc:: IP_FREEBIND , bool ) ;
@@ -360,8 +368,9 @@ sockopt_impl!(
360
368
PeerCredentials , GetOnly , libc:: SOL_SOCKET , libc:: SO_PEERCRED , super :: UnixCredentials ) ;
361
369
#[ cfg( any( target_os = "ios" ,
362
370
target_os = "macos" ) ) ]
363
- #[ cfg( feature = "net" ) ]
364
371
sockopt_impl ! (
372
+ #[ cfg( feature = "net" ) ]
373
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
365
374
/// Specify the amount of time, in seconds, that the connection must be idle
366
375
/// before keepalive probes (if enabled) are sent.
367
376
TcpKeepAlive , Both , libc:: IPPROTO_TCP , libc:: TCP_KEEPALIVE , u32 ) ;
@@ -370,8 +379,9 @@ sockopt_impl!(
370
379
target_os = "freebsd" ,
371
380
target_os = "linux" ,
372
381
target_os = "nacl" ) ) ]
373
- #[ cfg( feature = "net" ) ]
374
382
sockopt_impl ! (
383
+ #[ cfg( feature = "net" ) ]
384
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
375
385
/// The time (in seconds) the connection needs to remain idle before TCP
376
386
/// starts sending keepalive probes
377
387
TcpKeepIdle , Both , libc:: IPPROTO_TCP , libc:: TCP_KEEPIDLE , u32 ) ;
@@ -387,8 +397,9 @@ cfg_if! {
387
397
}
388
398
}
389
399
#[ cfg( not( target_os = "openbsd" ) ) ]
390
- #[ cfg( feature = "net" ) ]
391
400
sockopt_impl ! (
401
+ #[ cfg( feature = "net" ) ]
402
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
392
403
/// The maximum number of keepalive probes TCP should send before
393
404
/// dropping the connection.
394
405
TcpKeepCount , Both , libc:: IPPROTO_TCP , libc:: TCP_KEEPCNT , u32 ) ;
@@ -400,13 +411,15 @@ sockopt_impl!(
400
411
// Not documented by Linux!
401
412
TcpRepair , Both , libc:: IPPROTO_TCP , libc:: TCP_REPAIR , u32 ) ;
402
413
#[ cfg( not( target_os = "openbsd" ) ) ]
403
- #[ cfg( feature = "net" ) ]
404
414
sockopt_impl ! (
415
+ #[ cfg( feature = "net" ) ]
416
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
405
417
/// The time (in seconds) between individual keepalive probes.
406
418
TcpKeepInterval , Both , libc:: IPPROTO_TCP , libc:: TCP_KEEPINTVL , u32 ) ;
407
419
#[ cfg( any( target_os = "fuchsia" , target_os = "linux" ) ) ]
408
- #[ cfg( feature = "net" ) ]
409
420
sockopt_impl ! (
421
+ #[ cfg( feature = "net" ) ]
422
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
410
423
/// Specifies the maximum amount of time in milliseconds that transmitted
411
424
/// data may remain unacknowledged before TCP will forcibly close the
412
425
/// corresponding connection
@@ -441,8 +454,9 @@ sockopt_impl!(
441
454
/// Bind this socket to a particular device like “eth0”.
442
455
BindToDevice , Both , libc:: SOL_SOCKET , libc:: SO_BINDTODEVICE , OsString <[ u8 ; libc:: IFNAMSIZ ] >) ;
443
456
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
444
- #[ cfg( feature = "net" ) ]
445
457
sockopt_impl ! (
458
+ #[ cfg( feature = "net" ) ]
459
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
446
460
#[ allow( missing_docs) ]
447
461
// Not documented by Linux!
448
462
OriginalDst , GetOnly , libc:: SOL_IP , libc:: SO_ORIGINAL_DST , libc:: sockaddr_in) ;
@@ -459,19 +473,22 @@ sockopt_impl!(
459
473
/// Enable or disable the receiving of the `SO_TIMESTAMPNS` control message.
460
474
ReceiveTimestampns , Both , libc:: SOL_SOCKET , libc:: SO_TIMESTAMPNS , bool ) ;
461
475
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
462
- #[ cfg( feature = "net" ) ]
463
476
sockopt_impl ! (
477
+ #[ cfg( feature = "net" ) ]
478
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
464
479
/// Setting this boolean option enables transparent proxying on this socket.
465
480
IpTransparent , Both , libc:: SOL_IP , libc:: IP_TRANSPARENT , bool ) ;
466
481
#[ cfg( target_os = "openbsd" ) ]
467
- #[ cfg( feature = "net" ) ]
468
482
sockopt_impl ! (
483
+ #[ cfg( feature = "net" ) ]
484
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
469
485
/// Allows the socket to be bound to addresses which are not local to the
470
486
/// machine, so it can be used to make a transparent proxy.
471
487
BindAny , Both , libc:: SOL_SOCKET , libc:: SO_BINDANY , bool ) ;
472
488
#[ cfg( target_os = "freebsd" ) ]
473
- #[ cfg( feature = "net" ) ]
474
489
sockopt_impl ! (
490
+ #[ cfg( feature = "net" ) ]
491
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
475
492
/// Can `bind(2)` to any address, even one not bound to any available
476
493
/// network interface in the system.
477
494
BindAny , Both , libc:: IPPROTO_IP , libc:: IP_BINDANY , bool ) ;
@@ -486,8 +503,9 @@ sockopt_impl!(
486
503
/// message.
487
504
PassCred , Both , libc:: SOL_SOCKET , libc:: SO_PASSCRED , bool ) ;
488
505
#[ cfg( any( target_os = "freebsd" , target_os = "linux" ) ) ]
489
- #[ cfg( feature = "net" ) ]
490
506
sockopt_impl ! (
507
+ #[ cfg( feature = "net" ) ]
508
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
491
509
/// This option allows the caller to set the TCP congestion control
492
510
/// algorithm to be used, on a per-socket basis.
493
511
TcpCongestion , Both , libc:: IPPROTO_TCP , libc:: TCP_CONGESTION , OsString <[ u8 ; TCP_CA_NAME_MAX ] >) ;
@@ -498,8 +516,9 @@ sockopt_impl!(
498
516
target_os = "macos" ,
499
517
target_os = "netbsd" ,
500
518
) ) ]
501
- #[ cfg( feature = "net" ) ]
502
519
sockopt_impl ! (
520
+ #[ cfg( feature = "net" ) ]
521
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
503
522
/// Pass an `IP_PKTINFO` ancillary message that contains a pktinfo
504
523
/// structure that supplies some information about the incoming packet.
505
524
Ipv4PacketInfo , Both , libc:: IPPROTO_IP , libc:: IP_PKTINFO , bool ) ;
@@ -512,8 +531,9 @@ sockopt_impl!(
512
531
target_os = "netbsd" ,
513
532
target_os = "openbsd" ,
514
533
) ) ]
515
- #[ cfg( feature = "net" ) ]
516
534
sockopt_impl ! (
535
+ #[ cfg( feature = "net" ) ]
536
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
517
537
/// Set delivery of the `IPV6_PKTINFO` control message on incoming
518
538
/// datagrams.
519
539
Ipv6RecvPacketInfo , Both , libc:: IPPROTO_IPV6 , libc:: IPV6_RECVPKTINFO , bool ) ;
@@ -524,8 +544,9 @@ sockopt_impl!(
524
544
target_os = "netbsd" ,
525
545
target_os = "openbsd" ,
526
546
) ) ]
527
- #[ cfg( feature = "net" ) ]
528
547
sockopt_impl ! (
548
+ #[ cfg( feature = "net" ) ]
549
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
529
550
/// The `recvmsg(2)` call returns a `struct sockaddr_dl` corresponding to
530
551
/// the interface on which the packet was received.
531
552
Ipv4RecvIf , Both , libc:: IPPROTO_IP , libc:: IP_RECVIF , bool ) ;
@@ -536,20 +557,23 @@ sockopt_impl!(
536
557
target_os = "netbsd" ,
537
558
target_os = "openbsd" ,
538
559
) ) ]
539
- #[ cfg( feature = "net" ) ]
540
560
sockopt_impl ! (
561
+ #[ cfg( feature = "net" ) ]
562
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
541
563
/// The `recvmsg(2)` call will return the destination IP address for a UDP
542
564
/// datagram.
543
565
Ipv4RecvDstAddr , Both , libc:: IPPROTO_IP , libc:: IP_RECVDSTADDR , bool ) ;
544
566
#[ cfg( target_os = "linux" ) ]
545
- #[ cfg( feature = "net" ) ]
546
567
sockopt_impl ! (
568
+ #[ cfg( feature = "net" ) ]
569
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
547
570
#[ allow( missing_docs) ]
548
571
// Not documented by Linux!
549
572
UdpGsoSegment , Both , libc:: SOL_UDP , libc:: UDP_SEGMENT , libc:: c_int) ;
550
573
#[ cfg( target_os = "linux" ) ]
551
- #[ cfg( feature = "net" ) ]
552
574
sockopt_impl ! (
575
+ #[ cfg( feature = "net" ) ]
576
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
553
577
#[ allow( missing_docs) ]
554
578
// Not documented by Linux!
555
579
UdpGroSegment , Both , libc:: IPPROTO_UDP , libc:: UDP_GRO , bool ) ;
@@ -559,8 +583,9 @@ sockopt_impl!(
559
583
/// be attached to received skbs indicating the number of packets dropped by
560
584
/// the socket since its creation.
561
585
RxqOvfl , Both , libc:: SOL_SOCKET , libc:: SO_RXQ_OVFL , libc:: c_int) ;
562
- #[ cfg( feature = "net" ) ]
563
586
sockopt_impl ! (
587
+ #[ cfg( feature = "net" ) ]
588
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
564
589
/// The socket is restricted to sending and receiving IPv6 packets only.
565
590
Ipv6V6Only , Both , libc:: IPPROTO_IPV6 , libc:: IPV6_V6ONLY , bool ) ;
566
591
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
0 commit comments