-
Notifications
You must be signed in to change notification settings - Fork 258
Expand file tree
/
Copy pathsockopt.rs
More file actions
1879 lines (1748 loc) · 61.4 KB
/
sockopt.rs
File metadata and controls
1879 lines (1748 loc) · 61.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//! `getsockopt` and `setsockopt` functions.
//!
//! In the rustix API, there is a separate function for each option, so that it
//! can be given an option-specific type signature.
//!
//! # References for all getter functions:
//!
//! - [POSIX `getsockopt`]
//! - [Linux `getsockopt`]
//! - [Winsock `getsockopt`]
//! - [Apple `getsockopt`]
//! - [FreeBSD `getsockopt`]
//! - [NetBSD `getsockopt`]
//! - [OpenBSD `getsockopt`]
//! - [DragonFly BSD `getsockopt`]
//! - [illumos `getsockopt`]
//! - [glibc `getsockopt`]
//!
//! [POSIX `getsockopt`]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/getsockopt.html
//! [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html
//! [Winsock `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt
//! [Apple `getsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html
//! [FreeBSD `getsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2
//! [NetBSD `getsockopt`]: https://man.netbsd.org/getsockopt.2
//! [OpenBSD `getsockopt`]: https://man.openbsd.org/getsockopt.2
//! [DragonFly BSD `getsockopt`]: https://man.dragonflybsd.org/?command=getsockopt§ion=2
//! [illumos `getsockopt`]: https://illumos.org/man/3SOCKET/getsockopt
//! [glibc `getsockopt`]: https://sourceware.org/glibc/manual/latest/html_node/Socket-Option-Functions.html
//!
//! # References for all `set_*` functions:
//!
//! - [POSIX `setsockopt`]
//! - [Linux `setsockopt`]
//! - [Winsock `setsockopt`]
//! - [Apple `setsockopt`]
//! - [FreeBSD `setsockopt`]
//! - [NetBSD `setsockopt`]
//! - [OpenBSD `setsockopt`]
//! - [DragonFly BSD `setsockopt`]
//! - [illumos `setsockopt`]
//! - [glibc `setsockopt`]
//!
//! [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/setsockopt.html
//! [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html
//! [Winsock `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt
//! [Apple `setsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html
//! [FreeBSD `setsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2
//! [NetBSD `setsockopt`]: https://man.netbsd.org/setsockopt.2
//! [OpenBSD `setsockopt`]: https://man.openbsd.org/setsockopt.2
//! [DragonFly BSD `setsockopt`]: https://man.dragonflybsd.org/?command=setsockopt§ion=2
//! [illumos `setsockopt`]: https://illumos.org/man/3SOCKET/setsockopt
//! [glibc `setsockopt`]: https://sourceware.org/glibc/manual/latest/html_node/Socket-Option-Functions.html
//!
//! # References for `get_socket_*` and `set_socket_*` functions:
//!
//! - [References for all getter functions]
//! - [References for all `set_*` functions]
//! - [POSIX `sys/socket.h`]
//! - [Linux `socket`]
//! - [Winsock `SOL_SOCKET` options]
//! - [glibc `SOL_SOCKET` Options]
//!
//! [POSIX `sys/socket.h`]: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_socket.h.html
//! [Linux `socket`]: https://man7.org/linux/man-pages/man7/socket.7.html
//! [Winsock `SOL_SOCKET` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options
//! [glibc `SOL_SOCKET` options]: https://sourceware.org/glibc/manual/latest/html_node/Socket_002dLevel-Options.html
//!
//! # References for `get_ip_*` and `set_ip_*` functions:
//!
//! - [References for all getter functions]
//! - [References for all `set_*` functions]
//! - [POSIX `netinet/in.h`]
//! - [Linux `ip`]
//! - [Winsock `IPPROTO_IP` options]
//! - [Apple `ip`]
//! - [FreeBSD `ip`]
//! - [NetBSD `ip`]
//! - [OpenBSD `ip`]
//! - [DragonFly BSD `ip`]
//! - [illumos `ip`]
//!
//! [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/netinet_in.h.html
//! [Linux `ip`]: https://man7.org/linux/man-pages/man7/ip.7.html
//! [Winsock `IPPROTO_IP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options
//! [Apple `ip`]: https://github.com/apple-oss-distributions/xnu/blob/main/bsd/man/man4/ip.4
//! [FreeBSD `ip`]: https://man.freebsd.org/cgi/man.cgi?query=ip&sektion=4
//! [NetBSD `ip`]: https://man.netbsd.org/ip.4
//! [OpenBSD `ip`]: https://man.openbsd.org/ip.4
//! [DragonFly BSD `ip`]: https://man.dragonflybsd.org/?command=ip§ion=4
//! [illumos `ip`]: https://illumos.org/man/4P/ip
//!
//! # References for `get_ipv6_*` and `set_ipv6_*` functions:
//!
//! - [References for all getter functions]
//! - [References for all `set_*` functions]
//! - [POSIX `netinet/in.h`]
//! - [Linux `ipv6`]
//! - [Winsock `IPPROTO_IPV6` options]
//! - [Apple `ip6`]
//! - [FreeBSD `ip6`]
//! - [NetBSD `ip6`]
//! - [OpenBSD `ip6`]
//! - [DragonFly BSD `ip6`]
//! - [illumos `ip6`]
//!
//! [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/netinet_in.h.html
//! [Linux `ipv6`]: https://man7.org/linux/man-pages/man7/ipv6.7.html
//! [Winsock `IPPROTO_IPV6` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options
//! [Apple `ip6`]: https://github.com/apple-oss-distributions/xnu/blob/main/bsd/man/man4/ip6.4
//! [FreeBSD `ip6`]: https://man.freebsd.org/cgi/man.cgi?query=ip6&sektion=4
//! [NetBSD `ip6`]: https://man.netbsd.org/ip6.4
//! [OpenBSD `ip6`]: https://man.openbsd.org/ip6.4
//! [DragonFly BSD `ip6`]: https://man.dragonflybsd.org/?command=ip6§ion=4
//! [illumos `ip6`]: https://illumos.org/man/4P/ip6
//!
//! # References for `get_tcp_*` and `set_tcp_*` functions:
//!
//! - [References for all getter functions]
//! - [References for all `set_*` functions]
//! - [POSIX `netinet/tcp.h`]
//! - [Linux `tcp`]
//! - [Winsock `IPPROTO_TCP` options]
//! - [Apple `tcp`]
//! - [FreeBSD `tcp`]
//! - [NetBSD `tcp`]
//! - [OpenBSD `tcp`]
//! - [DragonFly BSD `tcp`]
//! - [illumos `tcp`]
//!
//! [POSIX `netinet/tcp.h`]: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/netinet_tcp.h.html
//! [Linux `tcp`]: https://man7.org/linux/man-pages/man7/tcp.7.html
//! [Winsock `IPPROTO_TCP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options
//! [Apple `tcp`]: https://github.com/apple-oss-distributions/xnu/blob/main/bsd/man/man4/tcp.4
//! [FreeBSD `tcp`]: https://man.freebsd.org/cgi/man.cgi?query=tcp&sektion=4
//! [NetBSD `tcp`]: https://man.netbsd.org/tcp.4
//! [OpenBSD `tcp`]: https://man.openbsd.org/tcp.4
//! [DragonFly BSD `tcp`]: https://man.dragonflybsd.org/?command=tcp§ion=4
//! [illumos `tcp`]: https://illumos.org/man/4P/tcp
//!
//! [References for all getter functions]: #references-for-all-getter-functions
//! [References for all `set_*` functions]: #references-for-all-set_-functions
#![doc(alias = "getsockopt")]
#![doc(alias = "setsockopt")]
#[cfg(all(target_os = "linux", feature = "time"))]
use crate::clockid::ClockId;
#[cfg(target_os = "linux")]
use crate::net::xdp::{XdpMmapOffsets, XdpOptionsFlags, XdpStatistics, XdpUmemReg};
#[cfg(not(any(
apple,
windows,
target_os = "aix",
target_os = "cygwin",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "espidf",
target_os = "haiku",
target_os = "netbsd",
target_os = "nto",
target_os = "vita",
)))]
use crate::net::AddressFamily;
#[cfg(any(
linux_kernel,
target_os = "freebsd",
target_os = "fuchsia",
target_os = "openbsd",
target_os = "redox",
target_env = "newlib"
))]
use crate::net::Protocol;
#[cfg(any(linux_kernel, target_os = "fuchsia"))]
use crate::net::SocketAddrV4;
#[cfg(linux_kernel)]
use crate::net::SocketAddrV6;
#[cfg(all(target_os = "linux", feature = "time"))]
use crate::net::TxTimeFlags;
use crate::net::{Ipv4Addr, Ipv6Addr, SocketType};
use crate::{backend, io};
#[cfg(feature = "alloc")]
#[cfg(any(
linux_like,
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos"
))]
use alloc::string::String;
use backend::c;
use backend::fd::AsFd;
use core::time::Duration;
/// Timeout identifier for use with [`set_socket_timeout`] and
/// [`socket_timeout`].
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
#[repr(u32)]
pub enum Timeout {
/// `SO_RCVTIMEO`—Timeout for receiving.
Recv = c::SO_RCVTIMEO as _,
/// `SO_SNDTIMEO`—Timeout for sending.
Send = c::SO_SNDTIMEO as _,
}
/// A type for holding raw integer IPv4 Path MTU Discovery options.
#[cfg(linux_kernel)]
pub type RawIpv4PathMtuDiscovery = i32;
/// IPv4 Path MTU Discovery option values (`IP_PMTUDISC_*`) for use with
/// [`set_ip_mtu_discover`] and [`ip_mtu_discover`].
///
/// # References
/// - [Linux]
/// - [Linux INET header]
///
/// [Linux]: https://man7.org/linux/man-pages/man7/ip.7.html
/// [Linux INET header]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/in.h?h=v6.14#n135
#[cfg(linux_kernel)]
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
#[repr(transparent)]
pub struct Ipv4PathMtuDiscovery(RawIpv4PathMtuDiscovery);
#[cfg(linux_kernel)]
impl Ipv4PathMtuDiscovery {
/// `IP_PMTUDISC_DONT`
#[doc(alias = "IP_PMTUDISC_DONT")]
pub const DONT: Self = Self(c::IP_PMTUDISC_DONT as _);
/// `IP_PMTUDISC_WANT`
#[doc(alias = "IP_PMTUDISC_WANT")]
pub const WANT: Self = Self(c::IP_PMTUDISC_WANT as _);
/// `IP_PMTUDISC_DO`
#[doc(alias = "IP_PMTUDISC_DO")]
pub const DO: Self = Self(c::IP_PMTUDISC_DO as _);
/// `IP_PMTUDISC_PROBE`
#[doc(alias = "IP_PMTUDISC_PROBE")]
pub const PROBE: Self = Self(c::IP_PMTUDISC_PROBE as _);
/// `IP_PMTUDISC_INTERFACE`
#[doc(alias = "IP_PMTUDISC_INTERFACE")]
pub const INTERFACE: Self = Self(c::IP_PMTUDISC_INTERFACE as _);
/// `IP_PMTUDISC_OMIT`
#[doc(alias = "IP_PMTUDISC_OMIT")]
pub const OMIT: Self = Self(c::IP_PMTUDISC_OMIT as _);
/// Constructs an option from a raw integer.
#[inline]
pub const fn from_raw(raw: RawIpv4PathMtuDiscovery) -> Self {
Self(raw)
}
/// Returns the raw integer for this option.
#[inline]
pub const fn as_raw(self) -> RawIpv4PathMtuDiscovery {
self.0
}
}
/// A type for holding raw integer IPv6 Path MTU Discovery options.
#[cfg(linux_kernel)]
pub type RawIpv6PathMtuDiscovery = i32;
/// IPv6 Path MTU Discovery option values (`IPV6_PMTUDISC_*`) for use with
/// [`set_ipv6_mtu_discover`] and [`ipv6_mtu_discover`].
///
/// # References
/// - [Linux]
/// - [Linux INET6 header]
///
/// [Linux]: https://man7.org/linux/man-pages/man7/ipv6.7.html
/// [Linux INET6 header]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/in6.h?h=v6.14#n185
#[cfg(linux_kernel)]
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
#[repr(transparent)]
pub struct Ipv6PathMtuDiscovery(RawIpv6PathMtuDiscovery);
#[cfg(linux_kernel)]
impl Ipv6PathMtuDiscovery {
/// `IPV6_PMTUDISC_DONT`
#[doc(alias = "IPV6_PMTUDISC_DONT")]
pub const DONT: Self = Self(c::IPV6_PMTUDISC_DONT as _);
/// `IPV6_PMTUDISC_WANT`
#[doc(alias = "IPV6_PMTUDISC_WANT")]
pub const WANT: Self = Self(c::IPV6_PMTUDISC_WANT as _);
/// `IPV6_PMTUDISC_DO`
#[doc(alias = "IPV6_PMTUDISC_DO")]
pub const DO: Self = Self(c::IPV6_PMTUDISC_DO as _);
/// `IPV6_PMTUDISC_PROBE`
#[doc(alias = "IPV6_PMTUDISC_PROBE")]
pub const PROBE: Self = Self(c::IPV6_PMTUDISC_PROBE as _);
/// `IPV6_PMTUDISC_INTERFACE`
#[doc(alias = "IPV6_PMTUDISC_INTERFACE")]
pub const INTERFACE: Self = Self(c::IPV6_PMTUDISC_INTERFACE as _);
/// `IPV6_PMTUDISC_OMIT`
#[doc(alias = "IPV6_PMTUDISC_OMIT")]
pub const OMIT: Self = Self(c::IPV6_PMTUDISC_OMIT as _);
/// Constructs an option from a raw integer.
#[inline]
pub const fn from_raw(raw: RawIpv6PathMtuDiscovery) -> Self {
Self(raw)
}
/// Returns the raw integer for this option.
#[inline]
pub const fn as_raw(self) -> RawIpv6PathMtuDiscovery {
self.0
}
}
/// `getsockopt(fd, SOL_SOCKET, SO_TYPE)`—Returns the type of a socket.
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_TYPE")]
pub fn socket_type<Fd: AsFd>(fd: Fd) -> io::Result<SocketType> {
backend::net::sockopt::socket_type(fd.as_fd())
}
/// `setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, value)`—Set whether local
/// addresses may be reused in `bind`.
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_REUSEADDR")]
pub fn set_socket_reuseaddr<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
backend::net::sockopt::set_socket_reuseaddr(fd.as_fd(), value)
}
/// `getsockopt(fd, SOL_SOCKET, SO_REUSEADDR)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_REUSEADDR")]
pub fn socket_reuseaddr<Fd: AsFd>(fd: Fd) -> io::Result<bool> {
backend::net::sockopt::socket_reuseaddr(fd.as_fd())
}
/// `setsockopt(fd, SOL_SOCKET, SO_BROADCAST, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_BROADCAST")]
pub fn set_socket_broadcast<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
backend::net::sockopt::set_socket_broadcast(fd.as_fd(), value)
}
/// `getsockopt(fd, SOL_SOCKET, SO_BROADCAST)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_BROADCAST")]
pub fn socket_broadcast<Fd: AsFd>(fd: Fd) -> io::Result<bool> {
backend::net::sockopt::socket_broadcast(fd.as_fd())
}
/// `setsockopt(fd, SOL_SOCKET, SO_LINGER, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_LINGER")]
pub fn set_socket_linger<Fd: AsFd>(fd: Fd, value: Option<Duration>) -> io::Result<()> {
backend::net::sockopt::set_socket_linger(fd.as_fd(), value)
}
/// `getsockopt(fd, SOL_SOCKET, SO_LINGER)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_LINGER")]
pub fn socket_linger<Fd: AsFd>(fd: Fd) -> io::Result<Option<Duration>> {
backend::net::sockopt::socket_linger(fd.as_fd())
}
/// `setsockopt(fd, SOL_SOCKET, SO_PASSCRED, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(linux_kernel)]
#[inline]
#[doc(alias = "SO_PASSCRED")]
pub fn set_socket_passcred<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
backend::net::sockopt::set_socket_passcred(fd.as_fd(), value)
}
/// `getsockopt(fd, SOL_SOCKET, SO_PASSCRED)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(linux_kernel)]
#[inline]
#[doc(alias = "SO_PASSCRED")]
pub fn socket_passcred<Fd: AsFd>(fd: Fd) -> io::Result<bool> {
backend::net::sockopt::socket_passcred(fd.as_fd())
}
/// `setsockopt(fd, SOL_SOCKET, id, value)`—Set the sending or receiving
/// timeout.
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_RCVTIMEO")]
#[doc(alias = "SO_SNDTIMEO")]
pub fn set_socket_timeout<Fd: AsFd>(
fd: Fd,
id: Timeout,
value: Option<Duration>,
) -> io::Result<()> {
backend::net::sockopt::set_socket_timeout(fd.as_fd(), id, value)
}
/// `getsockopt(fd, SOL_SOCKET, id)`—Get the sending or receiving timeout.
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_RCVTIMEO")]
#[doc(alias = "SO_SNDTIMEO")]
pub fn socket_timeout<Fd: AsFd>(fd: Fd, id: Timeout) -> io::Result<Option<Duration>> {
backend::net::sockopt::socket_timeout(fd.as_fd(), id)
}
/// `getsockopt(fd, SOL_SOCKET, SO_ERROR)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_ERROR")]
pub fn socket_error<Fd: AsFd>(fd: Fd) -> io::Result<Result<(), io::Errno>> {
backend::net::sockopt::socket_error(fd.as_fd())
}
/// `getsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(any(apple, freebsdlike, target_os = "netbsd"))]
#[doc(alias = "SO_NOSIGPIPE")]
#[inline]
pub fn socket_nosigpipe<Fd: AsFd>(fd: Fd) -> io::Result<bool> {
backend::net::sockopt::socket_nosigpipe(fd.as_fd())
}
/// `setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(any(apple, freebsdlike, target_os = "netbsd"))]
#[doc(alias = "SO_NOSIGPIPE")]
#[inline]
pub fn set_socket_nosigpipe<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
backend::net::sockopt::set_socket_nosigpipe(fd.as_fd(), value)
}
/// `setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_KEEPALIVE")]
pub fn set_socket_keepalive<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
backend::net::sockopt::set_socket_keepalive(fd.as_fd(), value)
}
/// `getsockopt(fd, SOL_SOCKET, SO_KEEPALIVE)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_KEEPALIVE")]
pub fn socket_keepalive<Fd: AsFd>(fd: Fd) -> io::Result<bool> {
backend::net::sockopt::socket_keepalive(fd.as_fd())
}
/// `setsockopt(fd, SOL_SOCKET, SO_RCVBUF, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_RCVBUF")]
pub fn set_socket_recv_buffer_size<Fd: AsFd>(fd: Fd, value: usize) -> io::Result<()> {
backend::net::sockopt::set_socket_recv_buffer_size(fd.as_fd(), value)
}
/// `setsockopt(fd, SOL_SOCKET, SO_RCVBUFFORCE, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(any(linux_kernel, target_os = "fuchsia", target_os = "redox"))]
#[inline]
#[doc(alias = "SO_RCVBUFFORCE")]
pub fn set_socket_recv_buffer_size_force<Fd: AsFd>(fd: Fd, value: usize) -> io::Result<()> {
backend::net::sockopt::set_socket_recv_buffer_size_force(fd.as_fd(), value)
}
/// `getsockopt(fd, SOL_SOCKET, SO_RCVBUF)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_RCVBUF")]
pub fn socket_recv_buffer_size<Fd: AsFd>(fd: Fd) -> io::Result<usize> {
backend::net::sockopt::socket_recv_buffer_size(fd.as_fd())
}
/// `setsockopt(fd, SOL_SOCKET, SO_SNDBUF, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_SNDBUF")]
pub fn set_socket_send_buffer_size<Fd: AsFd>(fd: Fd, value: usize) -> io::Result<()> {
backend::net::sockopt::set_socket_send_buffer_size(fd.as_fd(), value)
}
/// `setsockopt(fd, SOL_SOCKET, SO_SNDBUFFORCE, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(any(linux_kernel, target_os = "fuchsia", target_os = "redox"))]
#[inline]
#[doc(alias = "SO_SNDBUFFORCE")]
pub fn set_socket_send_buffer_size_force<Fd: AsFd>(fd: Fd, value: usize) -> io::Result<()> {
backend::net::sockopt::set_socket_send_buffer_size_force(fd.as_fd(), value)
}
/// `getsockopt(fd, SOL_SOCKET, SO_SNDBUF)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_SNDBUF")]
pub fn socket_send_buffer_size<Fd: AsFd>(fd: Fd) -> io::Result<usize> {
backend::net::sockopt::socket_send_buffer_size(fd.as_fd())
}
/// `getsockopt(fd, SOL_SOCKET, SO_DOMAIN)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(not(any(
apple,
windows,
target_os = "aix",
target_os = "cygwin",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "espidf",
target_os = "haiku",
target_os = "horizon",
target_os = "hurd",
target_os = "netbsd",
target_os = "nto",
target_os = "vita",
)))]
#[inline]
#[doc(alias = "SO_DOMAIN")]
pub fn socket_domain<Fd: AsFd>(fd: Fd) -> io::Result<AddressFamily> {
backend::net::sockopt::socket_domain(fd.as_fd())
}
/// `getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(not(apple))] // Apple platforms declare the constant, but do not actually implement it.
#[inline]
#[doc(alias = "SO_ACCEPTCONN")]
pub fn socket_acceptconn<Fd: AsFd>(fd: Fd) -> io::Result<bool> {
backend::net::sockopt::socket_acceptconn(fd.as_fd())
}
/// `setsockopt(fd, SOL_SOCKET, SO_OOBINLINE, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_OOBINLINE")]
pub fn set_socket_oobinline<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
backend::net::sockopt::set_socket_oobinline(fd.as_fd(), value)
}
/// `getsockopt(fd, SOL_SOCKET, SO_OOBINLINE)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "SO_OOBINLINE")]
pub fn socket_oobinline<Fd: AsFd>(fd: Fd) -> io::Result<bool> {
backend::net::sockopt::socket_oobinline(fd.as_fd())
}
/// `setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(not(any(solarish, windows, target_os = "cygwin")))]
#[cfg(not(windows))]
#[inline]
#[doc(alias = "SO_REUSEPORT")]
pub fn set_socket_reuseport<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
backend::net::sockopt::set_socket_reuseport(fd.as_fd(), value)
}
/// `getsockopt(fd, SOL_SOCKET, SO_REUSEPORT)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(not(any(solarish, windows, target_os = "cygwin")))]
#[inline]
#[doc(alias = "SO_REUSEPORT")]
pub fn socket_reuseport<Fd: AsFd>(fd: Fd) -> io::Result<bool> {
backend::net::sockopt::socket_reuseport(fd.as_fd())
}
/// `setsockopt(fd, SOL_SOCKET, SO_REUSEPORT_LB, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(target_os = "freebsd")]
#[inline]
#[doc(alias = "SO_REUSEPORT_LB")]
pub fn set_socket_reuseport_lb<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
backend::net::sockopt::set_socket_reuseport_lb(fd.as_fd(), value)
}
/// `getsockopt(fd, SOL_SOCKET, SO_REUSEPORT_LB)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(target_os = "freebsd")]
#[inline]
#[doc(alias = "SO_REUSEPORT_LB")]
pub fn socket_reuseport_lb<Fd: AsFd>(fd: Fd) -> io::Result<bool> {
backend::net::sockopt::socket_reuseport_lb(fd.as_fd())
}
/// `getsockopt(fd, SOL_SOCKET, SO_PROTOCOL)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(any(
linux_kernel,
target_os = "freebsd",
target_os = "fuchsia",
target_os = "openbsd",
target_os = "redox",
target_env = "newlib"
))]
#[inline]
#[doc(alias = "SO_PROTOCOL")]
pub fn socket_protocol<Fd: AsFd>(fd: Fd) -> io::Result<Option<Protocol>> {
backend::net::sockopt::socket_protocol(fd.as_fd())
}
/// `getsockopt(fd, SOL_SOCKET, SO_COOKIE)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(target_os = "linux")]
#[inline]
#[doc(alias = "SO_COOKIE")]
pub fn socket_cookie<Fd: AsFd>(fd: Fd) -> io::Result<u64> {
backend::net::sockopt::socket_cookie(fd.as_fd())
}
/// `getsockopt(fd, SOL_SOCKET, SO_INCOMING_CPU)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(target_os = "linux")]
#[inline]
#[doc(alias = "SO_INCOMING_CPU")]
pub fn socket_incoming_cpu<Fd: AsFd>(fd: Fd) -> io::Result<u32> {
backend::net::sockopt::socket_incoming_cpu(fd.as_fd())
}
/// `setsockopt(fd, SOL_SOCKET, SO_INCOMING_CPU, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[cfg(target_os = "linux")]
#[inline]
#[doc(alias = "SO_INCOMING_CPU")]
pub fn set_socket_incoming_cpu<Fd: AsFd>(fd: Fd, value: u32) -> io::Result<()> {
backend::net::sockopt::set_socket_incoming_cpu(fd.as_fd(), value)
}
/// `setsockopt(fd, IPPROTO_IP, IP_TTL, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions
#[inline]
#[doc(alias = "IP_TTL")]
pub fn set_ip_ttl<Fd: AsFd>(fd: Fd, value: u32) -> io::Result<()> {
backend::net::sockopt::set_ip_ttl(fd.as_fd(), value)
}
/// `getsockopt(fd, IPPROTO_IP, IP_TTL)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[inline]
#[doc(alias = "IP_TTL")]
pub fn ip_ttl<Fd: AsFd>(fd: Fd) -> io::Result<u32> {
backend::net::sockopt::ip_ttl(fd.as_fd())
}
/// `setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions
#[inline]
#[doc(alias = "IPV6_V6ONLY")]
pub fn set_ipv6_v6only<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
backend::net::sockopt::set_ipv6_v6only(fd.as_fd(), value)
}
/// `getsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions
#[inline]
#[doc(alias = "IPV6_V6ONLY")]
pub fn ipv6_v6only<Fd: AsFd>(fd: Fd) -> io::Result<bool> {
backend::net::sockopt::ipv6_v6only(fd.as_fd())
}
/// `getsockopt(fd, IPPROTO_IP, IP_MTU)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[inline]
#[cfg(any(linux_kernel, target_os = "cygwin"))]
#[doc(alias = "IP_MTU")]
pub fn ip_mtu<Fd: AsFd>(fd: Fd) -> io::Result<u32> {
backend::net::sockopt::ip_mtu(fd.as_fd())
}
/// `getsockopt(fd, IPPROTO_IPV6, IPV6_MTU)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[inline]
#[cfg(any(linux_kernel, target_os = "cygwin"))]
#[doc(alias = "IPV6_MTU")]
pub fn ipv6_mtu<Fd: AsFd>(fd: Fd) -> io::Result<u32> {
backend::net::sockopt::ipv6_mtu(fd.as_fd())
}
/// `setsockopt(fd, IPPROTO_IP, IP_MTU_DISCOVER, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[cfg(linux_kernel)]
#[inline]
#[doc(alias = "IP_MTU_DISCOVER")]
pub fn set_ip_mtu_discover<Fd: AsFd>(fd: Fd, value: Ipv4PathMtuDiscovery) -> io::Result<()> {
backend::net::sockopt::set_ip_mtu_discover(fd.as_fd(), value)
}
/// `getsockopt(fd, IPPROTO_IP, IP_MTU_DISCOVER)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[cfg(linux_kernel)]
#[inline]
#[doc(alias = "IP_MTU_DISCOVER")]
pub fn ip_mtu_discover<Fd: AsFd>(fd: Fd) -> io::Result<Ipv4PathMtuDiscovery> {
backend::net::sockopt::ip_mtu_discover(fd.as_fd())
}
/// `setsockopt(fd, IPPROTO_IPV6, IPV6_MTU_DISCOVER, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions
#[cfg(linux_kernel)]
#[inline]
#[doc(alias = "IPV6_MTU_DISCOVER")]
pub fn set_ipv6_mtu_discover<Fd: AsFd>(fd: Fd, value: Ipv6PathMtuDiscovery) -> io::Result<()> {
backend::net::sockopt::set_ipv6_mtu_discover(fd.as_fd(), value)
}
/// `getsockopt(fd, IPPROTO_IPV6, IPV6_MTU_DISCOVER)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions
#[cfg(linux_kernel)]
#[inline]
#[doc(alias = "IPV6_MTU_DISCOVER")]
pub fn ipv6_mtu_discover<Fd: AsFd>(fd: Fd) -> io::Result<Ipv6PathMtuDiscovery> {
backend::net::sockopt::ipv6_mtu_discover(fd.as_fd())
}
/// `setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[inline]
#[doc(alias = "IP_MULTICAST_IF")]
pub fn set_ip_multicast_if<Fd: AsFd>(fd: Fd, value: &Ipv4Addr) -> io::Result<()> {
backend::net::sockopt::set_ip_multicast_if(fd.as_fd(), value)
}
/// `setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, multiaddr, address,
/// ifindex)`
///
/// This is similar to [`set_ip_multicast_if`] but additionally allows an
/// `ifindex` value to be given.
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[cfg(any(
apple,
freebsdlike,
linux_like,
target_os = "fuchsia",
target_os = "openbsd"
))]
#[inline]
#[doc(alias = "IP_MULTICAST_IF")]
pub fn set_ip_multicast_if_with_ifindex<Fd: AsFd>(
fd: Fd,
multiaddr: &Ipv4Addr,
address: &Ipv4Addr,
ifindex: u32,
) -> io::Result<()> {
backend::net::sockopt::set_ip_multicast_if_with_ifindex(fd.as_fd(), multiaddr, address, ifindex)
}
/// `getsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[inline]
#[doc(alias = "IP_MULTICAST_IF")]
pub fn ip_multicast_if<Fd: AsFd>(fd: Fd) -> io::Result<Ipv4Addr> {
backend::net::sockopt::ip_multicast_if(fd.as_fd())
}
/// `setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[inline]
#[doc(alias = "IPV6_MULTICAST_IF")]
pub fn set_ipv6_multicast_if<Fd: AsFd>(fd: Fd, value: u32) -> io::Result<()> {
backend::net::sockopt::set_ipv6_multicast_if(fd.as_fd(), value)
}
/// `getsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[inline]
#[doc(alias = "IPV6_MULTICAST_IF")]
pub fn ipv6_multicast_if<Fd: AsFd>(fd: Fd) -> io::Result<u32> {
backend::net::sockopt::ipv6_multicast_if(fd.as_fd())
}
/// `setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[inline]
#[doc(alias = "IP_MULTICAST_LOOP")]
pub fn set_ip_multicast_loop<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
backend::net::sockopt::set_ip_multicast_loop(fd.as_fd(), value)
}
/// `getsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[inline]
#[doc(alias = "IP_MULTICAST_LOOP")]
pub fn ip_multicast_loop<Fd: AsFd>(fd: Fd) -> io::Result<bool> {
backend::net::sockopt::ip_multicast_loop(fd.as_fd())
}
/// `setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[inline]
#[doc(alias = "IP_MULTICAST_TTL")]
pub fn set_ip_multicast_ttl<Fd: AsFd>(fd: Fd, value: u32) -> io::Result<()> {
backend::net::sockopt::set_ip_multicast_ttl(fd.as_fd(), value)
}
/// `getsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[inline]
#[doc(alias = "IP_MULTICAST_TTL")]
pub fn ip_multicast_ttl<Fd: AsFd>(fd: Fd) -> io::Result<u32> {
backend::net::sockopt::ip_multicast_ttl(fd.as_fd())
}
/// `setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions
#[inline]
#[doc(alias = "IPV6_MULTICAST_LOOP")]
pub fn set_ipv6_multicast_loop<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
backend::net::sockopt::set_ipv6_multicast_loop(fd.as_fd(), value)
}
/// `getsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions
#[inline]
#[doc(alias = "IPV6_MULTICAST_LOOP")]
pub fn ipv6_multicast_loop<Fd: AsFd>(fd: Fd) -> io::Result<bool> {
backend::net::sockopt::ipv6_multicast_loop(fd.as_fd())
}
/// `getsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions
#[inline]
#[doc(alias = "IPV6_UNICAST_HOPS")]
pub fn ipv6_unicast_hops<Fd: AsFd>(fd: Fd) -> io::Result<u8> {
backend::net::sockopt::ipv6_unicast_hops(fd.as_fd())
}
/// `setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, value)`
///
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions
#[inline]
#[doc(alias = "IPV6_UNICAST_HOPS")]
pub fn set_ipv6_unicast_hops<Fd: AsFd>(fd: Fd, value: Option<u8>) -> io::Result<()> {