aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Vander Stoep <jeffv@google.com>2023-02-06 23:43:32 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-02-06 23:43:32 +0000
commitd29693b8cc7ee1f5c0f9e5f75311f475ece9d0d8 (patch)
tree5b380ad2d4d358429b1df0cad378c47cfe7ed269
parent69be0cc0a012a9aa45b11e2383d43105aa9440d3 (diff)
parentd66d827e98ed8d80ecf2e73900bf9fd9f2406848 (diff)
downloadsocket2-d29693b8cc7ee1f5c0f9e5f75311f475ece9d0d8.tar.gz
Upgrade socket2 to 0.4.7 am: 750ca7fdb2 am: d66d827e98
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/socket2/+/2422399 Change-Id: Iac8d4a4a64df83bebe49250f881dd52958cd55a3 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp5
-rw-r--r--Cargo.toml47
-rw-r--r--Cargo.toml.orig4
-rw-r--r--METADATA15
-rw-r--r--README.md4
-rw-r--r--cargo.out20
-rw-r--r--src/lib.rs35
-rw-r--r--src/sockaddr.rs1
-rw-r--r--src/socket.rs130
-rw-r--r--src/sys/unix.rs46
-rw-r--r--src/sys/windows.rs9
12 files changed, 246 insertions, 72 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index b0a8014..85f94b1 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,6 +1,6 @@
{
"git": {
- "sha1": "ac391b27fe7ab6740a61b8d52c2920ee383d5817"
+ "sha1": "ff79dee5174b8beb32b54e35636fc45358e2d705"
},
"path_in_vcs": ""
} \ No newline at end of file
diff --git a/Android.bp b/Android.bp
index 8afbaff..4d34996 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,8 +1,6 @@
// This file is generated by cargo2android.py --config cargo2android.json.
// Do not modify this file as changes will be overridden on upgrade.
-
-
package {
default_applicable_licenses: ["external_rust_crates_socket2_license"],
}
@@ -41,11 +39,10 @@ license {
rust_library {
name: "libsocket2",
- // has rustc warnings
host_supported: true,
crate_name: "socket2",
cargo_env_compat: true,
- cargo_pkg_version: "0.4.4",
+ cargo_pkg_version: "0.4.7",
srcs: ["src/lib.rs"],
edition: "2018",
features: ["all"],
diff --git a/Cargo.toml b/Cargo.toml
index 8fd3884..70a2506 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,28 +12,57 @@
[package]
edition = "2018"
name = "socket2"
-version = "0.4.4"
-authors = ["Alex Crichton <alex@alexcrichton.com>", "Thomas de Zeeuw <thomasdezeeuw@gmail.com>"]
-include = ["Cargo.toml", "LICENSE-APACHE", "LICENSE-MIT", "README.md", "src/**/*.rs"]
-description = "Utilities for handling networking sockets with a maximal amount of configuration\npossible intended.\n"
+version = "0.4.7"
+authors = [
+ "Alex Crichton <alex@alexcrichton.com>",
+ "Thomas de Zeeuw <thomasdezeeuw@gmail.com>",
+]
+include = [
+ "Cargo.toml",
+ "LICENSE-APACHE",
+ "LICENSE-MIT",
+ "README.md",
+ "src/**/*.rs",
+]
+description = """
+Utilities for handling networking sockets with a maximal amount of configuration
+possible intended.
+"""
homepage = "https://github.com/rust-lang/socket2"
documentation = "https://docs.rs/socket2"
readme = "README.md"
-keywords = ["io", "socket", "network"]
-categories = ["api-bindings", "network-programming"]
+keywords = [
+ "io",
+ "socket",
+ "network",
+]
+categories = [
+ "api-bindings",
+ "network-programming",
+]
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/socket2"
+
[package.metadata.docs.rs]
all-features = true
-rustdoc-args = ["--cfg", "docsrs"]
+rustdoc-args = [
+ "--cfg",
+ "docsrs",
+]
[package.metadata.playground]
features = ["all"]
[features]
all = []
+
[target."cfg(unix)".dependencies.libc]
-version = "0.2.114"
+version = "0.2.124"
+
[target."cfg(windows)".dependencies.winapi]
version = "0.3.9"
-features = ["handleapi", "ws2ipdef", "ws2tcpip"]
+features = [
+ "handleapi",
+ "ws2ipdef",
+ "ws2tcpip",
+]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 6ca3422..6784df9 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "socket2"
-version = "0.4.4"
+version = "0.4.7"
authors = [
"Alex Crichton <alex@alexcrichton.com>",
"Thomas de Zeeuw <thomasdezeeuw@gmail.com>"
@@ -33,7 +33,7 @@ rustdoc-args = ["--cfg", "docsrs"]
features = ["all"]
[target."cfg(unix)".dependencies]
-libc = "0.2.114"
+libc = "0.2.124"
[target."cfg(windows)".dependencies]
winapi = { version = "0.3.9", features = ["handleapi", "ws2ipdef", "ws2tcpip"] }
diff --git a/METADATA b/METADATA
index 7c214be..4be1590 100644
--- a/METADATA
+++ b/METADATA
@@ -1,3 +1,7 @@
+# This project was upgraded with external_updater.
+# Usage: tools/external_updater/updater.sh update rust/crates/socket2
+# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
+
name: "socket2"
description: "Utilities for handling networking sockets with a maximal amount of configuration possible intended."
third_party {
@@ -7,14 +11,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/socket2/socket2-0.4.4.crate"
+ value: "https://static.crates.io/crates/socket2/socket2-0.4.7.crate"
}
- version: "0.4.4"
- # Dual-licensed, using the least restrictive per go/thirdpartylicenses#same.
+ version: "0.4.7"
license_type: NOTICE
last_upgrade_date {
- year: 2022
- month: 12
- day: 12
+ year: 2023
+ month: 2
+ day: 6
}
}
diff --git a/README.md b/README.md
index 45f4cf8..77963b7 100644
--- a/README.md
+++ b/README.md
@@ -71,9 +71,9 @@ Socket2 uses 1.46.0 as MSRV.
This project is licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
- http://www.apache.org/licenses/LICENSE-2.0)
+ https://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
- http://opensource.org/licenses/MIT)
+ https://opensource.org/licenses/MIT)
at your option.
diff --git a/cargo.out b/cargo.out
deleted file mode 100644
index cec2d0b..0000000
--- a/cargo.out
+++ /dev/null
@@ -1,20 +0,0 @@
-### Running: /usr/local/google/home/chriswailes/projects/android/aosp-plus-rust/development/scripts/../../prebuilts/rust/linux-x86/1.64.0/bin/cargo -v clean --target-dir target.tmp >> ./cargo.out 2>&1
- Removing /usr/local/google/home/chriswailes/projects/android/aosp-plus-rust/external/rust/crates/socket2/target.tmp
-### Running: /usr/local/google/home/chriswailes/projects/android/aosp-plus-rust/development/scripts/../../prebuilts/rust/linux-x86/1.64.0/bin/cargo -v build --target x86_64-unknown-linux-gnu --no-default-features --features all --target-dir target.tmp >> ./cargo.out 2>&1
- Updating crates.io index
- Compiling libc v0.2.138
- Running `rustc --crate-name build_script_build /usr/local/google/home/chriswailes/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.138/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=a91c13d3321fe99a -C extra-filename=-a91c13d3321fe99a --out-dir /usr/local/google/home/chriswailes/projects/android/aosp-plus-rust/external/rust/crates/socket2/target.tmp/debug/build/libc-a91c13d3321fe99a -L dependency=/usr/local/google/home/chriswailes/projects/android/aosp-plus-rust/external/rust/crates/socket2/target.tmp/debug/deps --cap-lints allow`
- Running `/usr/local/google/home/chriswailes/projects/android/aosp-plus-rust/external/rust/crates/socket2/target.tmp/debug/build/libc-a91c13d3321fe99a/build-script-build`
- Running `rustc --crate-name libc /usr/local/google/home/chriswailes/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.138/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=c27f6107a08ccd2c -C extra-filename=-c27f6107a08ccd2c --out-dir /usr/local/google/home/chriswailes/projects/android/aosp-plus-rust/external/rust/crates/socket2/target.tmp/x86_64-unknown-linux-gnu/debug/deps --target x86_64-unknown-linux-gnu -L dependency=/usr/local/google/home/chriswailes/projects/android/aosp-plus-rust/external/rust/crates/socket2/target.tmp/x86_64-unknown-linux-gnu/debug/deps -L dependency=/usr/local/google/home/chriswailes/projects/android/aosp-plus-rust/external/rust/crates/socket2/target.tmp/debug/deps --cap-lints allow --cfg freebsd11 --cfg libc_priv_mod_use --cfg libc_union --cfg libc_const_size_of --cfg libc_align --cfg libc_int128 --cfg libc_core_cvoid --cfg libc_packedN --cfg libc_cfg_target_vendor --cfg libc_non_exhaustive --cfg libc_ptr_addr_of --cfg libc_underscore_const_names --cfg libc_const_extern_fn`
- Compiling socket2 v0.4.4 (/usr/local/google/home/chriswailes/projects/android/aosp-plus-rust/external/rust/crates/socket2)
- Running `rustc --crate-name socket2 --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="all"' -C metadata=96fa3d53ddb1d7a8 -C extra-filename=-96fa3d53ddb1d7a8 --out-dir /usr/local/google/home/chriswailes/projects/android/aosp-plus-rust/external/rust/crates/socket2/target.tmp/x86_64-unknown-linux-gnu/debug/deps --target x86_64-unknown-linux-gnu -C incremental=/usr/local/google/home/chriswailes/projects/android/aosp-plus-rust/external/rust/crates/socket2/target.tmp/x86_64-unknown-linux-gnu/debug/incremental -L dependency=/usr/local/google/home/chriswailes/projects/android/aosp-plus-rust/external/rust/crates/socket2/target.tmp/x86_64-unknown-linux-gnu/debug/deps -L dependency=/usr/local/google/home/chriswailes/projects/android/aosp-plus-rust/external/rust/crates/socket2/target.tmp/debug/deps --extern libc=/usr/local/google/home/chriswailes/projects/android/aosp-plus-rust/external/rust/crates/socket2/target.tmp/x86_64-unknown-linux-gnu/debug/deps/liblibc-c27f6107a08ccd2c.rmeta`
-warning: unnecessary `unsafe` block
- --> src/sys/unix.rs:1486:9
- |
-1486 | unsafe {
- | ^^^^^^ unnecessary `unsafe` block
- |
- = note: `#[warn(unused_unsafe)]` on by default
-
-warning: `socket2` (lib) generated 1 warning
- Finished dev [unoptimized + debuginfo] target(s) in 2.18s
diff --git a/src/lib.rs b/src/lib.rs
index d01b652..da9e864 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,8 +1,8 @@
// Copyright 2015 The Rust Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
@@ -50,7 +50,7 @@
//! This crate has a single feature `all`, which enables all functions even ones
//! that are not available on all OSs.
-#![doc(html_root_url = "https://docs.rs/socket2/0.3")]
+#![doc(html_root_url = "https://docs.rs/socket2/0.4")]
#![deny(missing_docs, missing_debug_implementations, rust_2018_idioms)]
// Show required OS/features on docs.rs.
#![cfg_attr(docsrs, feature(doc_cfg))]
@@ -327,10 +327,16 @@ impl<'a> DerefMut for MaybeUninitSlice<'a> {
/// See [`Socket::set_tcp_keepalive`].
#[derive(Debug, Clone)]
pub struct TcpKeepalive {
+ #[cfg_attr(target_os = "openbsd", allow(dead_code))]
time: Option<Duration>,
- #[cfg(not(any(target_os = "redox", target_os = "solaris")))]
+ #[cfg(not(any(target_os = "openbsd", target_os = "redox", target_os = "solaris")))]
interval: Option<Duration>,
- #[cfg(not(any(target_os = "redox", target_os = "solaris", target_os = "windows")))]
+ #[cfg(not(any(
+ target_os = "openbsd",
+ target_os = "redox",
+ target_os = "solaris",
+ target_os = "windows"
+ )))]
retries: Option<u32>,
}
@@ -339,9 +345,14 @@ impl TcpKeepalive {
pub const fn new() -> TcpKeepalive {
TcpKeepalive {
time: None,
- #[cfg(not(any(target_os = "redox", target_os = "solaris")))]
+ #[cfg(not(any(target_os = "openbsd", target_os = "redox", target_os = "solaris")))]
interval: None,
- #[cfg(not(any(target_os = "redox", target_os = "solaris", target_os = "windows")))]
+ #[cfg(not(any(
+ target_os = "openbsd",
+ target_os = "redox",
+ target_os = "solaris",
+ target_os = "windows"
+ )))]
retries: None,
}
}
@@ -374,9 +385,11 @@ impl TcpKeepalive {
#[cfg(all(
feature = "all",
any(
+ target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "fuchsia",
+ target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
@@ -388,8 +401,11 @@ impl TcpKeepalive {
doc(cfg(all(
feature = "all",
any(
+ target_os = "android",
+ target_os = "dragonfly",
target_os = "freebsd",
target_os = "fuchsia",
+ target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
@@ -412,9 +428,11 @@ impl TcpKeepalive {
feature = "all",
any(
doc,
+ target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "fuchsia",
+ target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
@@ -425,8 +443,11 @@ impl TcpKeepalive {
doc(cfg(all(
feature = "all",
any(
+ target_os = "android",
+ target_os = "dragonfly",
target_os = "freebsd",
target_os = "fuchsia",
+ target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
diff --git a/src/sockaddr.rs b/src/sockaddr.rs
index 55951b6..16a4f0e 100644
--- a/src/sockaddr.rs
+++ b/src/sockaddr.rs
@@ -13,6 +13,7 @@ use winapi::shared::ws2ipdef::SOCKADDR_IN6_LH_u;
///
/// `SockAddr`s may be constructed directly to and from the standard library
/// [`SocketAddr`], [`SocketAddrV4`], and [`SocketAddrV6`] types.
+#[derive(Clone)]
pub struct SockAddr {
storage: sockaddr_storage,
len: socklen_t,
diff --git a/src/socket.rs b/src/socket.rs
index 028c4ae..87c143a 100644
--- a/src/socket.rs
+++ b/src/socket.rs
@@ -1,8 +1,8 @@
// Copyright 2015 The Rust Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
@@ -1135,6 +1135,7 @@ impl Socket {
target_os = "haiku",
target_os = "illumos",
target_os = "netbsd",
+ target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
@@ -1163,6 +1164,7 @@ impl Socket {
target_os = "haiku",
target_os = "illumos",
target_os = "netbsd",
+ target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
@@ -1182,6 +1184,76 @@ impl Socket {
}
}
+ /// Join a multicast SSM channel using `IP_ADD_SOURCE_MEMBERSHIP` option on this socket.
+ ///
+ /// This function specifies a new multicast channel for this socket to join.
+ /// The group must be a valid SSM group address, the source must be the address of the sender
+ /// and `interface` is the address of the local interface with which the system should join the
+ /// multicast group. If it's [`Ipv4Addr::UNSPECIFIED`] (`INADDR_ANY`) then
+ /// an appropriate interface is chosen by the system.
+ #[cfg(not(any(
+ target_os = "dragonfly",
+ target_os = "haiku",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "redox",
+ target_os = "fuchsia",
+ )))]
+ pub fn join_ssm_v4(
+ &self,
+ source: &Ipv4Addr,
+ group: &Ipv4Addr,
+ interface: &Ipv4Addr,
+ ) -> io::Result<()> {
+ let mreqs = sys::IpMreqSource {
+ imr_multiaddr: sys::to_in_addr(group),
+ imr_interface: sys::to_in_addr(interface),
+ imr_sourceaddr: sys::to_in_addr(source),
+ };
+ unsafe {
+ setsockopt(
+ self.as_raw(),
+ sys::IPPROTO_IP,
+ sys::IP_ADD_SOURCE_MEMBERSHIP,
+ mreqs,
+ )
+ }
+ }
+
+ /// Leave a multicast group using `IP_DROP_SOURCE_MEMBERSHIP` option on this socket.
+ ///
+ /// For more information about this option, see [`join_ssm_v4`].
+ ///
+ /// [`join_ssm_v4`]: Socket::join_ssm_v4
+ #[cfg(not(any(
+ target_os = "dragonfly",
+ target_os = "haiku",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "redox",
+ target_os = "fuchsia",
+ )))]
+ pub fn leave_ssm_v4(
+ &self,
+ source: &Ipv4Addr,
+ group: &Ipv4Addr,
+ interface: &Ipv4Addr,
+ ) -> io::Result<()> {
+ let mreqs = sys::IpMreqSource {
+ imr_multiaddr: sys::to_in_addr(group),
+ imr_interface: sys::to_in_addr(interface),
+ imr_sourceaddr: sys::to_in_addr(source),
+ };
+ unsafe {
+ setsockopt(
+ self.as_raw(),
+ sys::IPPROTO_IP,
+ sys::IP_DROP_SOURCE_MEMBERSHIP,
+ mreqs,
+ )
+ }
+ }
+
/// Get the value of the `IP_MULTICAST_IF` option for this socket.
///
/// For more information about this option, see [`set_multicast_if_v4`].
@@ -1292,7 +1364,7 @@ impl Socket {
/// NOTE: <https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options>
/// documents that not all versions of windows support `IP_TOS`.
#[cfg(not(any(
- target_os = "fuschia",
+ target_os = "fuchsia",
target_os = "redox",
target_os = "solaris",
target_os = "illumos",
@@ -1310,7 +1382,7 @@ impl Socket {
///
/// [`set_tos`]: Socket::set_tos
#[cfg(not(any(
- target_os = "fuschia",
+ target_os = "fuchsia",
target_os = "redox",
target_os = "solaris",
target_os = "illumos",
@@ -1320,6 +1392,56 @@ impl Socket {
getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IP, sys::IP_TOS).map(|tos| tos as u32)
}
}
+
+ /// Set the value of the `IP_RECVTOS` option for this socket.
+ ///
+ /// If enabled, the IP_TOS ancillary message is passed with
+ /// incoming packets. It contains a byte which specifies the
+ /// Type of Service/Precedence field of the packet header.
+ #[cfg(not(any(
+ target_os = "dragonfly",
+ target_os = "fuchsia",
+ target_os = "illumos",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "redox",
+ target_os = "solaris",
+ target_os = "windows",
+ )))]
+ pub fn set_recv_tos(&self, recv_tos: bool) -> io::Result<()> {
+ let recv_tos = if recv_tos { 1 } else { 0 };
+
+ unsafe {
+ setsockopt(
+ self.as_raw(),
+ sys::IPPROTO_IP,
+ sys::IP_RECVTOS,
+ recv_tos as c_int,
+ )
+ }
+ }
+
+ /// Get the value of the `IP_RECVTOS` option for this socket.
+ ///
+ /// For more information about this option, see [`set_recv_tos`].
+ ///
+ /// [`set_recv_tos`]: Socket::set_recv_tos
+ #[cfg(not(any(
+ target_os = "dragonfly",
+ target_os = "fuchsia",
+ target_os = "illumos",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "redox",
+ target_os = "solaris",
+ target_os = "windows",
+ )))]
+ pub fn recv_tos(&self) -> io::Result<bool> {
+ unsafe {
+ getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IP, sys::IP_RECVTOS)
+ .map(|recv_tos| recv_tos > 0)
+ }
+ }
}
/// Socket options for IPv6 sockets, get/set using `IPPROTO_IPV6`.
diff --git a/src/sys/unix.rs b/src/sys/unix.rs
index 873b323..8400d14 100644
--- a/src/sys/unix.rs
+++ b/src/sys/unix.rs
@@ -1,8 +1,8 @@
// Copyright 2015 The Rust Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
@@ -78,7 +78,17 @@ pub(crate) use libc::{MSG_TRUNC, SO_OOBINLINE};
#[cfg(all(feature = "all", not(target_os = "redox")))]
pub(crate) use libc::IP_HDRINCL;
#[cfg(not(any(
- target_os = "fuschia",
+ target_os = "dragonfly",
+ target_os = "fuchsia",
+ target_os = "illumos",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "redox",
+ target_os = "solaris",
+)))]
+pub(crate) use libc::IP_RECVTOS;
+#[cfg(not(any(
+ target_os = "fuchsia",
target_os = "redox",
target_os = "solaris",
target_os = "illumos",
@@ -97,6 +107,17 @@ pub(crate) use libc::{
};
#[cfg(not(any(
target_os = "dragonfly",
+ target_os = "haiku",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "redox",
+ target_os = "fuchsia",
+)))]
+pub(crate) use libc::{
+ ip_mreq_source as IpMreqSource, IP_ADD_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP,
+};
+#[cfg(not(any(
+ target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
@@ -1004,6 +1025,7 @@ pub(crate) fn from_in6_addr(addr: in6_addr) -> Ipv6Addr {
target_os = "haiku",
target_os = "illumos",
target_os = "netbsd",
+ target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
@@ -1438,7 +1460,7 @@ impl crate::Socket {
}
/// Set the value of the `TCP_THIN_LINEAR_TIMEOUTS` option on this socket.
- ///
+ ///
/// If set, the kernel will dynamically detect a thin-stream connection if there are less than four packets in flight.
/// With less than four packets in flight the normal TCP fast retransmission will not be effective.
/// The kernel will modify the retransmission to avoid the very high latencies that thin stream suffer because of exponential backoff.
@@ -1483,15 +1505,13 @@ impl crate::Socket {
let mut buf: [MaybeUninit<u8>; libc::IFNAMSIZ] =
unsafe { MaybeUninit::uninit().assume_init() };
let mut len = buf.len() as libc::socklen_t;
- unsafe {
- syscall!(getsockopt(
- self.as_raw(),
- libc::SOL_SOCKET,
- libc::SO_BINDTODEVICE,
- buf.as_mut_ptr().cast(),
- &mut len,
- ))?;
- }
+ syscall!(getsockopt(
+ self.as_raw(),
+ libc::SOL_SOCKET,
+ libc::SO_BINDTODEVICE,
+ buf.as_mut_ptr().cast(),
+ &mut len,
+ ))?;
if len == 0 {
Ok(None)
} else {
diff --git a/src/sys/windows.rs b/src/sys/windows.rs
index ab59839..c37ca85 100644
--- a/src/sys/windows.rs
+++ b/src/sys/windows.rs
@@ -1,8 +1,8 @@
// Copyright 2015 The Rust Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
@@ -71,8 +71,9 @@ pub(crate) use winapi::shared::ws2ipdef::IP_HDRINCL;
pub(crate) use winapi::shared::ws2ipdef::{
IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP, IPV6_MREQ as Ipv6Mreq, IPV6_MULTICAST_HOPS,
IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY, IP_ADD_MEMBERSHIP,
- IP_DROP_MEMBERSHIP, IP_MREQ as IpMreq, IP_MULTICAST_IF, IP_MULTICAST_LOOP, IP_MULTICAST_TTL,
- IP_TOS, IP_TTL,
+ IP_ADD_SOURCE_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP, IP_MREQ as IpMreq,
+ IP_MREQ_SOURCE as IpMreqSource, IP_MULTICAST_IF, IP_MULTICAST_LOOP, IP_MULTICAST_TTL, IP_TOS,
+ IP_TTL,
};
pub(crate) use winapi::um::winsock2::{linger, MSG_OOB, MSG_PEEK};
pub(crate) const IPPROTO_IPV6: c_int = winapi::shared::ws2def::IPPROTO_IPV6 as c_int;