File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -1268,6 +1268,17 @@ sockopt_impl!(
12681268 libc:: SO_EXCLBIND ,
12691269 bool
12701270) ;
1271+ #[ cfg( target_os = "linux" ) ]
1272+ #[ cfg( feature = "net" ) ]
1273+ sockopt_impl ! (
1274+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1275+ /// Get tcp_info structure.
1276+ TcpInfo ,
1277+ GetOnly ,
1278+ libc:: SOL_TCP ,
1279+ libc:: TCP_INFO ,
1280+ libc:: tcp_info
1281+ ) ;
12711282
12721283#[ allow( missing_docs) ]
12731284// Not documented by Linux!
Original file line number Diff line number Diff line change @@ -568,6 +568,23 @@ fn test_ipv6_tclass() {
568568 assert_eq ! ( getsockopt( & fd, sockopt:: Ipv6TClass ) . unwrap( ) , class) ;
569569}
570570
571+ #[ test]
572+ #[ cfg( target_os = "linux" ) ]
573+ fn test_tcp_info ( ) {
574+ let fd = socket (
575+ AddressFamily :: Inet6 ,
576+ SockType :: Stream ,
577+ SockFlag :: empty ( ) ,
578+ SockProtocol :: Tcp ,
579+ )
580+ . unwrap ( ) ;
581+ let tcp_info = getsockopt ( & fd, sockopt:: TcpInfo ) . unwrap ( ) ;
582+ // Silly assert for the sake of having one in the test.
583+ // There should be no retransmits because nothing is sent through the
584+ // socket in the first place.
585+ assert_eq ! ( tcp_info. tcpi_retransmits, 0 ) ;
586+ }
587+
571588#[ test]
572589#[ cfg( target_os = "freebsd" ) ]
573590fn test_receive_timestamp ( ) {
You can’t perform that action at this time.
0 commit comments