diff --git a/src/lib.rs b/src/lib.rs index 4d588974..1994a540 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -302,6 +302,10 @@ impl Protocol { /// Protocol corresponding to `UDP`. pub const UDP: Protocol = Protocol(sys::IPPROTO_UDP); + + #[cfg(target_os = "linux")] + /// Protocol corresponding to `MPTCP`. + pub const MPTCP: Protocol = Protocol(sys::IPPROTO_MPTCP); } impl From for Protocol { diff --git a/src/sys/unix.rs b/src/sys/unix.rs index b54c2f63..fbe5a171 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -63,6 +63,8 @@ pub(crate) use libc::SOCK_RAW; pub(crate) use libc::SOCK_SEQPACKET; pub(crate) use libc::{SOCK_DGRAM, SOCK_STREAM}; // Used in `Protocol`. +#[cfg(target_os = "linux")] +pub(crate) use libc::IPPROTO_MPTCP; pub(crate) use libc::{IPPROTO_ICMP, IPPROTO_ICMPV6, IPPROTO_TCP, IPPROTO_UDP}; // Used in `SockAddr`. pub(crate) use libc::{ @@ -386,6 +388,8 @@ impl_debug!( libc::IPPROTO_ICMPV6, libc::IPPROTO_TCP, libc::IPPROTO_UDP, + #[cfg(target_os = "linux")] + libc::IPPROTO_MPTCP, ); /// Unix-only API. diff --git a/tests/socket.rs b/tests/socket.rs index f06febbc..e0161bda 100644 --- a/tests/socket.rs +++ b/tests/socket.rs @@ -106,6 +106,8 @@ fn protocol_fmt_debug() { (Protocol::ICMPV6, "IPPROTO_ICMPV6"), (Protocol::TCP, "IPPROTO_TCP"), (Protocol::UDP, "IPPROTO_UDP"), + #[cfg(target_os = "linux")] + (Protocol::MPTCP, "IPPROTO_MPTCP"), (500.into(), "500"), ];