Skip to content

Commit 4cac38d

Browse files
committed
Define TCP_CA_NAME_MAX
1 parent 535bc15 commit 4cac38d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/sys/socket/sockopt.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ use std::os::raw::c_char;
88
use std::os::unix::io::RawFd;
99
use std::ffi::{CStr, CString};
1010

11+
// Constants
12+
// TCP_CA_NAME_MAX isn't defined in user space include files
13+
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
14+
const TCP_CA_NAME_MAX: usize = 16;
15+
1116
/// Helper for implementing `SetSockOpt` for a given socket option. See
1217
/// [`::sys::socket::SetSockOpt`](sys/socket/trait.SetSockOpt.html).
1318
///
@@ -264,8 +269,7 @@ sockopt_impl!(Both, Mark, libc::SOL_SOCKET, libc::SO_MARK, u32);
264269
#[cfg(any(target_os = "android", target_os = "linux"))]
265270
sockopt_impl!(Both, PassCred, libc::SOL_SOCKET, libc::SO_PASSCRED, bool);
266271
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
267-
sockopt_impl!(Both, TcpCongestion, libc::IPPROTO_TCP, libc::TCP_CONGESTION, CString<[u8; 16]>);
268-
// TODO: Use libc::TCP_CA_NAME_MAX (https://github.com/rust-lang/libc/pull/1151)
272+
sockopt_impl!(Both, TcpCongestion, libc::IPPROTO_TCP, libc::TCP_CONGESTION, CString<[u8; TCP_CA_NAME_MAX]>);
269273

270274
/*
271275
*

0 commit comments

Comments
 (0)