Skip to content

Commit 25cbbfa

Browse files
committed
add tcp_info for getsockopt
1 parent e1e630f commit 25cbbfa

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

2691.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added TCP_INFO for `getsockopt`

src/sys/socket/sockopt.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,15 @@ sockopt_impl!(
13081308
libc::SO_ATTACH_REUSEPORT_CBPF,
13091309
libc::sock_fprog
13101310
);
1311+
#[cfg(target_os = "linux")]
1312+
sockopt_impl!(
1313+
/// Used to collect information about this socket.
1314+
TcpInfo,
1315+
GetOnly,
1316+
libc::SOL_TCP,
1317+
libc::TCP_INFO,
1318+
libc::tcp_info
1319+
);
13111320

13121321
#[allow(missing_docs)]
13131322
// Not documented by Linux!

test/sys/test_sockopt.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,3 +1270,16 @@ pub fn test_so_attach_reuseport_cbpf() {
12701270
assert_eq!(e, nix::errno::Errno::ENOPROTOOPT);
12711271
});
12721272
}
1273+
1274+
#[cfg(target_os = "linux")]
1275+
#[test]
1276+
pub fn test_so_tcp_info() {
1277+
let fd = socket(
1278+
AddressFamily::Inet6,
1279+
SockType::Stream,
1280+
SockFlag::empty(),
1281+
SockProtocol::Tcp,
1282+
)
1283+
.unwrap();
1284+
getsockopt(&fd, sockopt::TcpInfo).unwrap();
1285+
}

0 commit comments

Comments
 (0)