-
Notifications
You must be signed in to change notification settings - Fork 274
Adding DCCP support #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding DCCP support #352
Changes from 9 commits
2dbd20c
6da07c0
93a7c45
8678e52
096743f
7a5b733
2dcb6c7
d49a1fe
c49b344
2e2361e
560a951
18630ab
40d24d0
36bebec
7367fcf
4ad3329
cb99704
f1b9cc8
b51a939
24eba5f
d9e20d4
86c3b4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -57,14 +57,17 @@ pub(crate) use libc::c_int; | |||||||||||||||||||||||||||||||||||||||||
| // Used in `Domain`. | ||||||||||||||||||||||||||||||||||||||||||
| pub(crate) use libc::{AF_INET, AF_INET6, AF_UNIX}; | ||||||||||||||||||||||||||||||||||||||||||
| // Used in `Type`. | ||||||||||||||||||||||||||||||||||||||||||
| #[cfg(target_os = "linux")] | ||||||||||||||||||||||||||||||||||||||||||
| pub(crate) use libc::SOCK_DCCP; | ||||||||||||||||||||||||||||||||||||||||||
| #[cfg(all(feature = "all", not(target_os = "redox")))] | ||||||||||||||||||||||||||||||||||||||||||
| pub(crate) use libc::SOCK_RAW; | ||||||||||||||||||||||||||||||||||||||||||
| #[cfg(feature = "all")] | ||||||||||||||||||||||||||||||||||||||||||
| 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_DCCP, IPPROTO_MPTCP}; | ||||||||||||||||||||||||||||||||||||||||||
| pub(crate) use libc::{IPPROTO_ICMP, IPPROTO_ICMPV6, IPPROTO_TCP, IPPROTO_UDP}; | ||||||||||||||||||||||||||||||||||||||||||
| // Used in `SockAddr`. | ||||||||||||||||||||||||||||||||||||||||||
| pub(crate) use libc::{ | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -390,6 +393,8 @@ impl_debug!( | |||||||||||||||||||||||||||||||||||||||||
| libc::IPPROTO_UDP, | ||||||||||||||||||||||||||||||||||||||||||
| #[cfg(target_os = "linux")] | ||||||||||||||||||||||||||||||||||||||||||
| libc::IPPROTO_MPTCP, | ||||||||||||||||||||||||||||||||||||||||||
| #[cfg(target_os = "linux")] | ||||||||||||||||||||||||||||||||||||||||||
| libc::IPPROTO_DCCP | ||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// Unix-only API. | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1506,6 +1511,22 @@ impl crate::Socket { | |||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /// Returns list of CCIDs supported by the endpoint | ||||||||||||||||||||||||||||||||||||||||||
| #[cfg(target_os = "linux")] | ||||||||||||||||||||||||||||||||||||||||||
| pub fn dccp_available_ccids(&self) -> io::Result<Vec<u8>> { | ||||||||||||||||||||||||||||||||||||||||||
| let mut buf: [MaybeUninit<u8>; 10] = unsafe { MaybeUninit::uninit().assume_init() }; | ||||||||||||||||||||||||||||||||||||||||||
onestay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||
| let mut len = buf.len() as libc::socklen_t; | ||||||||||||||||||||||||||||||||||||||||||
| syscall!(getsockopt( | ||||||||||||||||||||||||||||||||||||||||||
| self.as_raw(), | ||||||||||||||||||||||||||||||||||||||||||
| libc::SOL_DCCP, | ||||||||||||||||||||||||||||||||||||||||||
| libc::DCCP_SOCKOPT_AVAILABLE_CCIDS, | ||||||||||||||||||||||||||||||||||||||||||
| buf.as_mut_ptr().cast(), | ||||||||||||||||||||||||||||||||||||||||||
| &mut len, | ||||||||||||||||||||||||||||||||||||||||||
| ))?; | ||||||||||||||||||||||||||||||||||||||||||
| let buf = &buf[..len as usize - 1]; | ||||||||||||||||||||||||||||||||||||||||||
| Ok(unsafe { &*(buf as *const [_] as *const [u8]) }.into()) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
| pub fn device(&self) -> io::Result<Option<Vec<u8>>> { | |
| // TODO: replace with `MaybeUninit::uninit_array` once stable. | |
| let mut buf: [MaybeUninit<u8>; libc::IFNAMSIZ] = | |
| unsafe { MaybeUninit::uninit().assume_init() }; | |
| let mut len = buf.len() as libc::socklen_t; | |
| syscall!(getsockopt( | |
| self.as_raw(), | |
| libc::SOL_SOCKET, | |
| libc::SO_BINDTODEVICE, | |
| buf.as_mut_ptr().cast(), | |
| &mut len, | |
| ))?; | |
| if len == 0 { | |
| Ok(None) | |
| } else { | |
| let buf = &buf[..len as usize - 1]; | |
| // TODO: use `MaybeUninit::slice_assume_init_ref` once stable. | |
| Ok(Some(unsafe { &*(buf as *const [_] as *const [u8]) }.into())) | |
| } | |
| } |
Uh oh!
There was an error while loading. Please reload this page.