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