@@ -202,6 +202,110 @@ pub enum Timeout {
202
202
Send = c:: SO_SNDTIMEO as _ ,
203
203
}
204
204
205
+ /// A type for holding raw integer IPv4 Path MTU Discovery options.
206
+ #[ cfg( linux_kernel) ]
207
+ pub type RawIpv4PathMtuDiscovery = i32 ;
208
+
209
+ /// IPv4 Path MTU Discovery option values (`IP_PMTUDISC_*`) for use with
210
+ /// [`set_ip_mtu_discover`] and [`ip_mtu_discover`].
211
+ ///
212
+ /// # References
213
+ /// - [Linux]
214
+ /// - [Linux INET header]
215
+ ///
216
+ /// [Linux]: https://man7.org/linux/man-pages/man7/ip.7.html
217
+ /// [Linux INET header]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/in.h?h=v6.14#n135
218
+ #[ cfg( linux_kernel) ]
219
+ #[ derive( Debug , Clone , Copy , Eq , PartialEq , Hash ) ]
220
+ #[ repr( transparent) ]
221
+ pub struct Ipv4PathMtuDiscovery ( RawIpv4PathMtuDiscovery ) ;
222
+
223
+ #[ cfg( linux_kernel) ]
224
+ impl Ipv4PathMtuDiscovery {
225
+ /// `IP_PMTUDISC_DONT`
226
+ #[ doc( alias = "IP_PMTUDISC_DONT" ) ]
227
+ pub const DONT : Self = Self ( c:: IP_PMTUDISC_DONT as _ ) ;
228
+ /// `IP_PMTUDISC_WANT`
229
+ #[ doc( alias = "IP_PMTUDISC_WANT" ) ]
230
+ pub const WANT : Self = Self ( c:: IP_PMTUDISC_WANT as _ ) ;
231
+ /// `IP_PMTUDISC_DO`
232
+ #[ doc( alias = "IP_PMTUDISC_DO" ) ]
233
+ pub const DO : Self = Self ( c:: IP_PMTUDISC_DO as _ ) ;
234
+ /// `IP_PMTUDISC_PROBE`
235
+ #[ doc( alias = "IP_PMTUDISC_PROBE" ) ]
236
+ pub const PROBE : Self = Self ( c:: IP_PMTUDISC_PROBE as _ ) ;
237
+ /// `IP_PMTUDISC_INTERFACE`
238
+ #[ doc( alias = "IP_PMTUDISC_INTERFACE" ) ]
239
+ pub const INTERFACE : Self = Self ( c:: IP_PMTUDISC_INTERFACE as _ ) ;
240
+ /// `IP_PMTUDISC_OMIT`
241
+ #[ doc( alias = "IP_PMTUDISC_OMIT" ) ]
242
+ pub const OMIT : Self = Self ( c:: IP_PMTUDISC_OMIT as _ ) ;
243
+
244
+ /// Constructs an option from a raw integer.
245
+ #[ inline]
246
+ pub const fn from_raw ( raw : RawIpv4PathMtuDiscovery ) -> Self {
247
+ Self ( raw)
248
+ }
249
+
250
+ /// Returns the raw integer for this option.
251
+ #[ inline]
252
+ pub const fn as_raw ( self ) -> RawIpv4PathMtuDiscovery {
253
+ self . 0
254
+ }
255
+ }
256
+
257
+ /// A type for holding raw integer IPv6 Path MTU Discovery options.
258
+ #[ cfg( linux_kernel) ]
259
+ pub type RawIpv6PathMtuDiscovery = i32 ;
260
+
261
+ /// IPv6 Path MTU Discovery option values (`IPV6_PMTUDISC_*`) for use with
262
+ /// [`set_ipv6_mtu_discover`] and [`ipv6_mtu_discover`].
263
+ ///
264
+ /// # References
265
+ /// - [Linux]
266
+ /// - [Linux INET6 header]
267
+ ///
268
+ /// [Linux]: https://man7.org/linux/man-pages/man7/ipv6.7.html
269
+ /// [Linux INET6 header]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/in6.h?h=v6.14#n185
270
+ #[ cfg( linux_kernel) ]
271
+ #[ derive( Debug , Clone , Copy , Eq , PartialEq , Hash ) ]
272
+ #[ repr( transparent) ]
273
+ pub struct Ipv6PathMtuDiscovery ( RawIpv6PathMtuDiscovery ) ;
274
+
275
+ #[ cfg( linux_kernel) ]
276
+ impl Ipv6PathMtuDiscovery {
277
+ /// `IPV6_PMTUDISC_DONT`
278
+ #[ doc( alias = "IPV6_PMTUDISC_DONT" ) ]
279
+ pub const DONT : Self = Self ( c:: IPV6_PMTUDISC_DONT as _ ) ;
280
+ /// `IPV6_PMTUDISC_WANT`
281
+ #[ doc( alias = "IPV6_PMTUDISC_WANT" ) ]
282
+ pub const WANT : Self = Self ( c:: IPV6_PMTUDISC_WANT as _ ) ;
283
+ /// `IPV6_PMTUDISC_DO`
284
+ #[ doc( alias = "IPV6_PMTUDISC_DO" ) ]
285
+ pub const DO : Self = Self ( c:: IPV6_PMTUDISC_DO as _ ) ;
286
+ /// `IPV6_PMTUDISC_PROBE`
287
+ #[ doc( alias = "IPV6_PMTUDISC_PROBE" ) ]
288
+ pub const PROBE : Self = Self ( c:: IPV6_PMTUDISC_PROBE as _ ) ;
289
+ /// `IPV6_PMTUDISC_INTERFACE`
290
+ #[ doc( alias = "IPV6_PMTUDISC_INTERFACE" ) ]
291
+ pub const INTERFACE : Self = Self ( c:: IPV6_PMTUDISC_INTERFACE as _ ) ;
292
+ /// `IPV6_PMTUDISC_OMIT`
293
+ #[ doc( alias = "IPV6_PMTUDISC_OMIT" ) ]
294
+ pub const OMIT : Self = Self ( c:: IPV6_PMTUDISC_OMIT as _ ) ;
295
+
296
+ /// Constructs an option from a raw integer.
297
+ #[ inline]
298
+ pub const fn from_raw ( raw : RawIpv6PathMtuDiscovery ) -> Self {
299
+ Self ( raw)
300
+ }
301
+
302
+ /// Returns the raw integer for this option.
303
+ #[ inline]
304
+ pub const fn as_raw ( self ) -> RawIpv6PathMtuDiscovery {
305
+ self . 0
306
+ }
307
+ }
308
+
205
309
/// `getsockopt(fd, SOL_SOCKET, SO_TYPE)`—Returns the type of a socket.
206
310
///
207
311
/// See the [module-level documentation] for more.
@@ -690,6 +794,54 @@ pub fn ipv6_mtu<Fd: AsFd>(fd: Fd) -> io::Result<u32> {
690
794
backend:: net:: sockopt:: ipv6_mtu ( fd. as_fd ( ) )
691
795
}
692
796
797
+ /// `setsockopt(fd, IPPROTO_IP, IP_MTU_DISCOVER, value)`
798
+ ///
799
+ /// See the [module-level documentation] for more.
800
+ ///
801
+ /// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
802
+ #[ cfg( linux_kernel) ]
803
+ #[ inline]
804
+ #[ doc( alias = "IP_MTU_DISCOVER" ) ]
805
+ pub fn set_ip_mtu_discover < Fd : AsFd > ( fd : Fd , value : Ipv4PathMtuDiscovery ) -> io:: Result < ( ) > {
806
+ backend:: net:: sockopt:: set_ip_mtu_discover ( fd. as_fd ( ) , value)
807
+ }
808
+
809
+ /// `getsockopt(fd, IPPROTO_IP, IP_MTU_DISCOVER)`
810
+ ///
811
+ /// See the [module-level documentation] for more.
812
+ ///
813
+ /// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
814
+ #[ cfg( linux_kernel) ]
815
+ #[ inline]
816
+ #[ doc( alias = "IP_MTU_DISCOVER" ) ]
817
+ pub fn ip_mtu_discover < Fd : AsFd > ( fd : Fd ) -> io:: Result < Ipv4PathMtuDiscovery > {
818
+ backend:: net:: sockopt:: ip_mtu_discover ( fd. as_fd ( ) )
819
+ }
820
+
821
+ /// `setsockopt(fd, IPPROTO_IPV6, IPV6_MTU_DISCOVER, value)`
822
+ ///
823
+ /// See the [module-level documentation] for more.
824
+ ///
825
+ /// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions
826
+ #[ cfg( linux_kernel) ]
827
+ #[ inline]
828
+ #[ doc( alias = "IPV6_MTU_DISCOVER" ) ]
829
+ pub fn set_ipv6_mtu_discover < Fd : AsFd > ( fd : Fd , value : Ipv6PathMtuDiscovery ) -> io:: Result < ( ) > {
830
+ backend:: net:: sockopt:: set_ipv6_mtu_discover ( fd. as_fd ( ) , value)
831
+ }
832
+
833
+ /// `getsockopt(fd, IPPROTO_IPV6, IPV6_MTU_DISCOVER)`
834
+ ///
835
+ /// See the [module-level documentation] for more.
836
+ ///
837
+ /// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions
838
+ #[ cfg( linux_kernel) ]
839
+ #[ inline]
840
+ #[ doc( alias = "IPV6_MTU_DISCOVER" ) ]
841
+ pub fn ipv6_mtu_discover < Fd : AsFd > ( fd : Fd ) -> io:: Result < Ipv6PathMtuDiscovery > {
842
+ backend:: net:: sockopt:: ipv6_mtu_discover ( fd. as_fd ( ) )
843
+ }
844
+
693
845
/// `setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, value)`
694
846
///
695
847
/// See the [module-level documentation] for more.
0 commit comments