Skip to content

Commit e90add9

Browse files
nathaniel-bennettThomasdezeeuw
authored andcommitted
add IPPROTO_SCTP as protocol option
1 parent 4c43681 commit e90add9

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,16 @@ impl Protocol {
306306
#[cfg(target_os = "linux")]
307307
/// Protocol corresponding to `MPTCP`.
308308
pub const MPTCP: Protocol = Protocol(sys::IPPROTO_MPTCP);
309+
310+
#[cfg(all(
311+
feature = "all",
312+
any(
313+
target_os = "freebsd",
314+
target_os = "linux",
315+
)
316+
))]
317+
/// Protocol corresponding to `SCTP`.
318+
pub const SCTP: Protocol = Protocol(sys::IPPROTO_SCTP);
309319
}
310320

311321
impl From<c_int> for Protocol {

src/sys/unix.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ pub(crate) use libc::{SOCK_DGRAM, SOCK_STREAM};
6565
// Used in `Protocol`.
6666
#[cfg(target_os = "linux")]
6767
pub(crate) use libc::IPPROTO_MPTCP;
68+
#[cfg(all(
69+
feature = "all",
70+
any(
71+
target_os = "freebsd",
72+
target_os = "linux",
73+
)
74+
))]
75+
pub(crate) use libc::IPPROTO_SCTP;
6876
pub(crate) use libc::{IPPROTO_ICMP, IPPROTO_ICMPV6, IPPROTO_TCP, IPPROTO_UDP};
6977
// Used in `SockAddr`.
7078
pub(crate) use libc::{
@@ -390,6 +398,14 @@ impl_debug!(
390398
libc::IPPROTO_UDP,
391399
#[cfg(target_os = "linux")]
392400
libc::IPPROTO_MPTCP,
401+
#[cfg(all(
402+
feature = "all",
403+
any(
404+
target_os = "freebsd",
405+
target_os = "linux",
406+
)
407+
))]
408+
libc::IPPROTO_SCTP,
393409
);
394410

395411
/// Unix-only API.

tests/socket.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ fn protocol_fmt_debug() {
108108
(Protocol::UDP, "IPPROTO_UDP"),
109109
#[cfg(target_os = "linux")]
110110
(Protocol::MPTCP, "IPPROTO_MPTCP"),
111+
#[cfg(all(
112+
feature = "all",
113+
any(
114+
target_os = "freebsd",
115+
target_os = "linux",
116+
)
117+
))]
118+
(Protocol::SCTP, "IPPROTO_SCTP"),
111119
(500.into(), "500"),
112120
];
113121

0 commit comments

Comments
 (0)