Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 2691.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added TCP_INFO for `getsockopt`
9 changes: 9 additions & 0 deletions src/sys/socket/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,15 @@ sockopt_impl!(
libc::SO_ATTACH_REUSEPORT_CBPF,
libc::sock_fprog
);
#[cfg(target_os = "linux")]
sockopt_impl!(
/// Used to collect information about this socket.
TcpInfo,
GetOnly,
libc::SOL_TCP,
libc::TCP_INFO,
libc::tcp_info
);

#[allow(missing_docs)]
// Not documented by Linux!
Expand Down
13 changes: 13 additions & 0 deletions test/sys/test_sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,3 +1270,16 @@ pub fn test_so_attach_reuseport_cbpf() {
assert_eq!(e, nix::errno::Errno::ENOPROTOOPT);
});
}

#[cfg(target_os = "linux")]
#[test]
pub fn test_so_tcp_info() {
let fd = socket(
AddressFamily::Inet6,
SockType::Stream,
SockFlag::empty(),
SockProtocol::Tcp,
)
.unwrap();
getsockopt(&fd, sockopt::TcpInfo).unwrap();
}
Loading