@@ -3239,6 +3239,41 @@ impl crate::Socket {
3239
3239
)
3240
3240
}
3241
3241
}
3242
+
3243
+ /// Get the value of the `IP_BINDANY` option on this socket.
3244
+ ///
3245
+ /// For more information about this option, see [`set_ip_bindany_v4`].
3246
+ ///
3247
+ /// [`set_ip_bindany_v4`]: crate::Socket::set_ip_bindany_v4
3248
+ #[ cfg( all( feature = "all" , target_os = "freebsd" ) ) ]
3249
+ #[ cfg_attr( docsrs, doc( cfg( all( feature = "all" , target_os = "freebsd" ) ) ) ) ]
3250
+ pub fn ip_bindany_v4 ( & self ) -> io:: Result < bool > {
3251
+ unsafe {
3252
+ getsockopt :: < c_int > ( self . as_raw ( ) , libc:: IPPROTO_IP , libc:: IP_BINDANY )
3253
+ . map ( |bindany| bindany != 0 )
3254
+ }
3255
+ }
3256
+
3257
+ /// Set the value of the `IP_BINDANY` option on this socket.
3258
+ ///
3259
+ /// If the IP_BINDANY option is enabled on a SOCK_STREAM, SOCK_DGRAM or a
3260
+ /// SOCK_RAW socket, one can bind(2) to any address, even one not bound to
3261
+ /// any available network interface in the system. This functionality (in
3262
+ /// conjunction with special firewall rules) can be used for implementing a
3263
+ /// transparent proxy. The PRIV_NETINET_BINDANY privilege is needed to set
3264
+ /// this option.
3265
+ #[ cfg( all( feature = "all" , target_os = "freebsd" ) ) ]
3266
+ #[ cfg_attr( docsrs, doc( cfg( all( feature = "all" , target_os = "freebsd" ) ) ) ) ]
3267
+ pub fn set_ip_bindany_v4 ( & self , bindany : bool ) -> io:: Result < ( ) > {
3268
+ unsafe {
3269
+ setsockopt (
3270
+ self . as_raw ( ) ,
3271
+ libc:: IPPROTO_IP ,
3272
+ libc:: IP_BINDANY ,
3273
+ bindany as c_int ,
3274
+ )
3275
+ }
3276
+ }
3242
3277
}
3243
3278
3244
3279
/// See [`Socket::dccp_available_ccids`].
0 commit comments