@@ -3274,6 +3274,41 @@ impl crate::Socket {
32743274 )
32753275 }
32763276 }
3277+
3278+ /// Get the value of the `IPV6_BINDANY` option on this socket.
3279+ ///
3280+ /// For more information about this option, see [`set_ip_bindany_v6`].
3281+ ///
3282+ /// [`set_ip_bindany_v6`]: crate::Socket::set_ip_bindany_v6
3283+ #[ cfg( all( feature = "all" , target_os = "freebsd" ) ) ]
3284+ #[ cfg_attr( docsrs, doc( cfg( all( feature = "all" , target_os = "freebsd" ) ) ) ) ]
3285+ pub fn ip_bindany_v6 ( & self ) -> io:: Result < bool > {
3286+ unsafe {
3287+ getsockopt :: < c_int > ( self . as_raw ( ) , libc:: IPPROTO_IPV6 , libc:: IPV6_BINDANY )
3288+ . map ( |bindany| bindany != 0 )
3289+ }
3290+ }
3291+
3292+ /// Set the value of the `IPV6_BINDANY` option on this socket.
3293+ ///
3294+ /// If the IPV6_BINDANY option is enabled on a SOCK_STREAM, SOCK_DGRAM or a
3295+ /// SOCK_RAW socket, one can bind(2) to any address, even one not bound to
3296+ /// any available network interface in the system. This functionality (in
3297+ /// conjunction with special firewall rules) can be used for implementing a
3298+ /// transparent proxy. The PRIV_NETINET_BINDANY privilege is needed to set
3299+ /// this option.
3300+ #[ cfg( all( feature = "all" , target_os = "freebsd" ) ) ]
3301+ #[ cfg_attr( docsrs, doc( cfg( all( feature = "all" , target_os = "freebsd" ) ) ) ) ]
3302+ pub fn set_ip_bindany_v6 ( & self , bindany : bool ) -> io:: Result < ( ) > {
3303+ unsafe {
3304+ setsockopt (
3305+ self . as_raw ( ) ,
3306+ libc:: IPPROTO_IPV6 ,
3307+ libc:: IPV6_BINDANY ,
3308+ bindany as c_int ,
3309+ )
3310+ }
3311+ }
32773312}
32783313
32793314/// See [`Socket::dccp_available_ccids`].
0 commit comments