@@ -3188,18 +3188,34 @@ impl crate::Socket {
3188
3188
/// [`set_ip_bindany_v4`]: crate::Socket::set_ip_bindany_v4
3189
3189
#[ cfg( all(
3190
3190
feature = "all" ,
3191
- any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" )
3191
+ any(
3192
+ target_os = "android" ,
3193
+ target_os = "fuchsia" ,
3194
+ target_os = "linux" ,
3195
+ target_os = "freebsd" ,
3196
+ target_os = "openbsd"
3197
+ )
3192
3198
) ) ]
3193
3199
#[ cfg_attr(
3194
3200
docsrs,
3195
3201
doc( cfg( all(
3196
3202
feature = "all" ,
3197
- any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" )
3203
+ any(
3204
+ target_os = "android" ,
3205
+ target_os = "fuchsia" ,
3206
+ target_os = "linux" ,
3207
+ target_os = "freebsd" ,
3208
+ target_os = "openbsd"
3209
+ )
3198
3210
) ) )
3199
3211
) ]
3200
3212
pub fn ip_bindany_v4 ( & self ) -> io:: Result < bool > {
3201
3213
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
3202
3214
let ( level, opt) = ( libc:: SOL_IP , libc:: IP_FREEBIND ) ;
3215
+ #[ cfg( target_os = "freebsd" ) ]
3216
+ let ( level, opt) = ( libc:: IPPROTO_IP , libc:: IP_BINDANY ) ;
3217
+ #[ cfg( target_os = "openbsd" ) ]
3218
+ let ( level, opt) = ( libc:: SOL_SOCKET , libc:: SO_BINDANY ) ;
3203
3219
3204
3220
unsafe { getsockopt :: < c_int > ( self . as_raw ( ) , level, opt) . map ( |bindany| bindany != 0 ) }
3205
3221
}
@@ -3214,18 +3230,34 @@ impl crate::Socket {
3214
3230
/// be up at the time that the application is trying to bind to it.
3215
3231
#[ cfg( all(
3216
3232
feature = "all" ,
3217
- any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" )
3233
+ any(
3234
+ target_os = "android" ,
3235
+ target_os = "fuchsia" ,
3236
+ target_os = "linux" ,
3237
+ target_os = "freebsd" ,
3238
+ target_os = "openbsd"
3239
+ )
3218
3240
) ) ]
3219
3241
#[ cfg_attr(
3220
3242
docsrs,
3221
3243
doc( cfg( all(
3222
3244
feature = "all" ,
3223
- any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" )
3245
+ any(
3246
+ target_os = "android" ,
3247
+ target_os = "fuchsia" ,
3248
+ target_os = "linux" ,
3249
+ target_os = "freebsd" ,
3250
+ target_os = "openbsd"
3251
+ )
3224
3252
) ) )
3225
3253
) ]
3226
3254
pub fn set_ip_bindany_v4 ( & self , bindany : bool ) -> io:: Result < ( ) > {
3227
3255
#[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
3228
3256
let ( level, opt) = ( libc:: SOL_IP , libc:: IP_FREEBIND ) ;
3257
+ #[ cfg( target_os = "freebsd" ) ]
3258
+ let ( level, opt) = ( libc:: IPPROTO_IP , libc:: IP_BINDANY ) ;
3259
+ #[ cfg( target_os = "openbsd" ) ]
3260
+ let ( level, opt) = ( libc:: SOL_SOCKET , libc:: SO_BINDANY ) ;
3229
3261
3230
3262
unsafe { setsockopt ( self . as_raw ( ) , level, opt, bindany as c_int ) }
3231
3263
}
@@ -3237,14 +3269,34 @@ impl crate::Socket {
3237
3269
/// For more information about this option, see [`set_ip_bindany_v6`].
3238
3270
///
3239
3271
/// [`set_ip_bindany_v6`]: crate::Socket::set_ip_bindany_v6
3240
- #[ cfg( all( feature = "all" , any( target_os = "android" , target_os = "linux" ) ) ) ]
3272
+ #[ cfg( all(
3273
+ feature = "all" ,
3274
+ any(
3275
+ target_os = "android" ,
3276
+ target_os = "linux" ,
3277
+ target_os = "freebsd" ,
3278
+ target_os = "openbsd"
3279
+ )
3280
+ ) ) ]
3241
3281
#[ cfg_attr(
3242
3282
docsrs,
3243
- doc( cfg( all( feature = "all" , any( target_os = "android" , target_os = "linux" ) ) ) )
3283
+ doc( cfg( all(
3284
+ feature = "all" ,
3285
+ any(
3286
+ target_os = "android" ,
3287
+ target_os = "linux" ,
3288
+ target_os = "freebsd" ,
3289
+ target_os = "openbsd"
3290
+ )
3291
+ ) ) )
3244
3292
) ]
3245
3293
pub fn ip_bindany_v6 ( & self ) -> io:: Result < bool > {
3246
3294
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
3247
3295
let ( level, opt) = ( libc:: SOL_IPV6 , libc:: IPV6_FREEBIND ) ;
3296
+ #[ cfg( target_os = "freebsd" ) ]
3297
+ let ( level, opt) = ( libc:: IPPROTO_IPV6 , libc:: IPV6_BINDANY ) ;
3298
+ #[ cfg( target_os = "openbsd" ) ]
3299
+ let ( level, opt) = ( libc:: SOL_SOCKET , libc:: SO_BINDANY ) ;
3248
3300
3249
3301
unsafe { getsockopt :: < c_int > ( self . as_raw ( ) , level, opt) . map ( |bindany| bindany != 0 ) }
3250
3302
}
@@ -3257,14 +3309,34 @@ impl crate::Socket {
3257
3309
/// For more information about this option, see [`set_ip_bindany_v4`].
3258
3310
///
3259
3311
/// [`set_ip_bindany_v4`]: crate::Socket::set_ip_bindany_v4
3260
- #[ cfg( all( feature = "all" , any( target_os = "android" , target_os = "linux" ) ) ) ]
3312
+ #[ cfg( all(
3313
+ feature = "all" ,
3314
+ any(
3315
+ target_os = "android" ,
3316
+ target_os = "linux" ,
3317
+ target_os = "freebsd" ,
3318
+ target_os = "openbsd"
3319
+ )
3320
+ ) ) ]
3261
3321
#[ cfg_attr(
3262
3322
docsrs,
3263
- doc( cfg( all( feature = "all" , any( target_os = "android" , target_os = "linux" ) ) ) )
3323
+ doc( cfg( all(
3324
+ feature = "all" ,
3325
+ any(
3326
+ target_os = "android" ,
3327
+ target_os = "linux" ,
3328
+ target_os = "freebsd" ,
3329
+ target_os = "openbsd"
3330
+ )
3331
+ ) ) )
3264
3332
) ]
3265
3333
pub fn set_ip_bindany_v6 ( & self , bindany : bool ) -> io:: Result < ( ) > {
3266
3334
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
3267
3335
let ( level, opt) = ( libc:: SOL_IPV6 , libc:: IPV6_FREEBIND ) ;
3336
+ #[ cfg( target_os = "freebsd" ) ]
3337
+ let ( level, opt) = ( libc:: IPPROTO_IPV6 , libc:: IPV6_BINDANY ) ;
3338
+ #[ cfg( target_os = "openbsd" ) ]
3339
+ let ( level, opt) = ( libc:: SOL_SOCKET , libc:: SO_BINDANY ) ;
3268
3340
3269
3341
unsafe { setsockopt ( self . as_raw ( ) , level, opt, bindany as c_int ) }
3270
3342
}
0 commit comments