diff --git a/src/sys/unix.rs b/src/sys/unix.rs index 413632e7..8a070681 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -1348,6 +1348,22 @@ impl crate::Socket { .map(|_| ()) } + /// Sets the value for the `SO_SETFIB` option on this socket. + /// + /// Bind socket to the specified forwarding table (VRF) on a FreeBSD. + #[cfg(all(feature = "all", any(target_os = "freebsd")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", any(target_os = "freebsd")))))] + pub fn set_fib(&self, fib: u32) -> io::Result<()> { + syscall!(setsockopt( + self.as_raw(), + libc::SOL_SOCKET, + libc::SO_SETFIB, + (&fib as *const u32).cast(), + mem::size_of::() as libc::socklen_t, + )) + .map(|_| ()) + } + /// Sets the value for `IP_BOUND_IF` option on this socket. /// /// If a socket is bound to an interface, only packets received from that