diff -ur socket2-0.4.10-org/src/socket.rs socket2-0.4.10/src/socket.rs --- socket2-0.4.10-org/src/socket.rs 2006-07-24 02:21:28.000000000 +0100 +++ socket2-0.4.10/src/socket.rs 2023-11-27 23:04:25.888522534 +0000 @@ -19,6 +19,7 @@ #[cfg(windows)] use std::os::windows::io::{FromRawSocket, IntoRawSocket}; use std::time::Duration; +use libc; use crate::sys::{self, c_int, getsockopt, setsockopt, Bool}; use crate::{Domain, Protocol, SockAddr, TcpKeepalive, Type}; @@ -833,6 +834,36 @@ } } + /// Set value for the `IP_MTU_DISCOVER` option, aka. DF bit, on this socket. + /// + /// Enable setting the DF bit on the sockets. + pub fn set_mtu_discover(&self, mtu_discover: bool) -> io::Result<()> { + let mut res1 = Err(io::ErrorKind::TimedOut.into()); + if mtu_discover == true { + //print!("set_mtu_discover true\n"); + unsafe { + res1 = setsockopt( + self.as_raw(), + libc::SOL_IP, + libc::IP_MTU_DISCOVER, + libc::IP_PMTUDISC_DO, + ) + } + } + if mtu_discover == false { + //print!("set_mtu_discover false\n"); + unsafe { + res1 = setsockopt( + self.as_raw(), + libc::SOL_IP, + libc::IP_MTU_DISCOVER, + libc::IP_PMTUDISC_DONT, + ) + } + } + return res1; + } + /// Get the value of the `SO_LINGER` option on this socket. /// /// For more information about this option, see [`set_linger`].