@@ -3309,6 +3309,40 @@ impl crate::Socket {
3309
3309
)
3310
3310
}
3311
3311
}
3312
+
3313
+ /// Get the value of the `SO_BINDANY` option on this socket.
3314
+ ///
3315
+ /// For more information about this option, see [`set_so_bindany`].
3316
+ ///
3317
+ /// [`set_so_bindany`]: crate::Socket::set_so_bindany
3318
+ #[ cfg( all( feature = "all" , target_os = "openbsd" ) ) ]
3319
+ #[ cfg_attr( docsrs, doc( cfg( all( feature = "all" , target_os = "openbsd" ) ) ) ) ]
3320
+ pub fn so_bindany ( & self ) -> io:: Result < bool > {
3321
+ unsafe {
3322
+ getsockopt :: < c_int > ( self . as_raw ( ) , libc:: SOL_SOCKET , libc:: SO_BINDANY )
3323
+ . map ( |bindany| bindany != 0 )
3324
+ }
3325
+ }
3326
+
3327
+ /// Set the value of the `SO_BINDANY` option on this socket.
3328
+ ///
3329
+ /// SO_BINDANY allows the socket to be bound to addresses which are not
3330
+ /// local to the machine, so it can be used to make a transparent proxy.
3331
+ /// Note that this option is limited to the superuser. In order to
3332
+ /// receive packets for these addresses, SO_BINDANY needs to be combined
3333
+ /// with matching outgoing pf(4) rules with the divert-reply parameter.
3334
+ #[ cfg( all( feature = "all" , target_os = "openbsd" ) ) ]
3335
+ #[ cfg_attr( docsrs, doc( cfg( all( feature = "all" , target_os = "openbsd" ) ) ) ) ]
3336
+ pub fn set_so_bindany ( & self , bindany : bool ) -> io:: Result < ( ) > {
3337
+ unsafe {
3338
+ setsockopt (
3339
+ self . as_raw ( ) ,
3340
+ libc:: IPPROTO_IP ,
3341
+ libc:: SO_BINDANY ,
3342
+ bindany as c_int ,
3343
+ )
3344
+ }
3345
+ }
3312
3346
}
3313
3347
3314
3348
/// See [`Socket::dccp_available_ccids`].
0 commit comments