Skip to content

Commit

Permalink
Expand ECN support
Browse files Browse the repository at this point in the history
libc's CMSG macros got built out to many more platforms. There may
remain some obscure platforms where this will still fail to build, but
we can account for them as they show up in practice.
  • Loading branch information
Ralith committed Feb 2, 2019
1 parent 47bc288 commit b0510d9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion quinn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ untrusted = "0.6.2"
webpki = "0.19"
webpki-roots = "0.16"
ct-logs = "0.5"
libc = "0.2.46"
libc = "0.2.48"
mio = "0.6"

[dev-dependencies]
Expand Down
10 changes: 4 additions & 6 deletions quinn/src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
use quinn_proto::EcnCodepoint;
use std::{io, net::SocketAddr};

// The Linux code should work for most unixes, but as of this writing nobody's ported the
// CMSG_... macros to the libc crate for any of the BSDs.
#[cfg(target_os = "linux")]
#[cfg(unix)]
mod cmsg;
#[cfg(target_os = "linux")]
mod linux;
#[cfg(unix)]
mod unix;

// No ECN support
#[cfg(not(target_os = "linux"))]
#[cfg(not(unix))]
mod fallback;

pub trait UdpExt {
Expand Down
6 changes: 3 additions & 3 deletions quinn/src/platform/linux.rs → quinn/src/platform/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ impl super::UdpExt for UdpSocket {
mem::size_of::<SocketAddrV6>(),
mem::size_of::<libc::sockaddr_in6>()
);
assert_eq!(CMSG_LEN, unsafe {
libc::CMSG_SPACE(mem::size_of::<libc::c_int>() as _) as usize
});
assert!(
CMSG_LEN >= unsafe { libc::CMSG_SPACE(mem::size_of::<libc::c_int>() as _) as usize }
);

let addr = self.local_addr()?;

Expand Down

0 comments on commit b0510d9

Please sign in to comment.