@@ -896,6 +896,44 @@ impl SockAddr {
896896 #[ cfg( not( any( target_os = "linux" , target_os = "android" ) ) ) ]
897897 None
898898 }
899+
900+ /// Get the value of the `UDP_GRO` option on this socket.
901+ ///
902+ /// For more information about this option, see [`set_udp_gro`].
903+ ///
904+ /// [`set_udp_gro`]: Socket::set_udp_gro
905+ #[ cfg( all( feature = "all" , any( target_os = "android" , target_os = "linux" ) ) ) ]
906+ #[ cfg_attr(
907+ docsrs,
908+ doc( cfg( all( feature = "all" , any( target_os = "android" , target_os = "linux" ) ) ) )
909+ ) ]
910+ pub fn udp_gro ( & self ) -> io:: Result < bool > {
911+ unsafe {
912+ getsockopt :: < c_int > ( self . as_raw ( ) , libc:: SOL_UDP , libc:: UDP_GRO )
913+ . map ( |reuse| reuse != 0 )
914+ }
915+ }
916+
917+ /// Set value for the `UDP_GRO` option on this socket.
918+ ///
919+ /// This indicates that the kernel can combine multiple datagrams into a
920+ /// single buffer, this needs to be used in combination with [`Self::recvmsg`]
921+ /// to get the number of segments in the buffer from the [`MsgHdr`].
922+ #[ cfg( all( feature = "all" , any( target_os = "android" , target_os = "linux" ) ) ) ]
923+ #[ cfg_attr(
924+ docsrs,
925+ doc( cfg( all( feature = "all" , any( target_os = "android" , target_os = "linux" ) ) ) )
926+ ) ]
927+ pub fn set_udp_gro ( & self , reuse : bool ) -> io:: Result < ( ) > {
928+ unsafe {
929+ setsockopt (
930+ self . as_raw ( ) ,
931+ sys:: SOL_UDP ,
932+ sys:: UDP_GRO ,
933+ reuse as c_int ,
934+ )
935+ }
936+ }
899937}
900938
901939pub ( crate ) type Socket = c_int ;
0 commit comments