-
Notifications
You must be signed in to change notification settings - Fork 230
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
Add: header_included_v6() and set_header_included_v6() #518
Merged
+99
−5
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1138,6 +1138,16 @@ const fn into_linger(duration: Option<Duration>) -> sys::linger { | |
/// * Linux: <https://man7.org/linux/man-pages/man7/ip.7.html> | ||
/// * Windows: <https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options> | ||
impl Socket { | ||
/// This method is deprecated, use [`crate::Socket::header_included_v4`]. | ||
#[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))] | ||
#[cfg_attr( | ||
docsrs, | ||
doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))) | ||
)] | ||
#[deprecated = "Use `Socket::header_included_v4` instead"] | ||
pub fn header_included(&self) -> io::Result<bool> { | ||
self.header_included_v4() | ||
} | ||
/// Get the value of the `IP_HDRINCL` option on this socket. | ||
/// | ||
/// For more information about this option, see [`set_header_included`]. | ||
|
@@ -1148,13 +1158,28 @@ impl Socket { | |
docsrs, | ||
doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))) | ||
)] | ||
pub fn header_included(&self) -> io::Result<bool> { | ||
pub fn header_included_v4(&self) -> io::Result<bool> { | ||
unsafe { | ||
getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IP, sys::IP_HDRINCL) | ||
.map(|included| included != 0) | ||
} | ||
} | ||
|
||
/// This method is deprecated, use [`crate::Socket::set_header_included_v4`]. | ||
#[cfg_attr( | ||
any(target_os = "fuchsia", target_os = "illumos", target_os = "solaris"), | ||
allow(rustdoc::broken_intra_doc_links) | ||
)] | ||
#[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))] | ||
#[cfg_attr( | ||
docsrs, | ||
doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))) | ||
)] | ||
#[deprecated = "Use `Socket::set_header_included_v4` instead"] | ||
pub fn set_header_included(&self, included: bool) -> io::Result<()> { | ||
self.set_header_included_v4(included) | ||
} | ||
|
||
/// Set the value of the `IP_HDRINCL` option on this socket. | ||
/// | ||
/// If enabled, the user supplies an IP header in front of the user data. | ||
|
@@ -1175,7 +1200,7 @@ impl Socket { | |
docsrs, | ||
doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))) | ||
)] | ||
pub fn set_header_included(&self, included: bool) -> io::Result<()> { | ||
pub fn set_header_included_v4(&self, included: bool) -> io::Result<()> { | ||
unsafe { | ||
setsockopt( | ||
self.as_raw(), | ||
|
@@ -1651,6 +1676,51 @@ impl Socket { | |
/// * Linux: <https://man7.org/linux/man-pages/man7/ipv6.7.html> | ||
/// * Windows: <https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options> | ||
impl Socket { | ||
/// Get the value of the `IP_HDRINCL` option on this socket. | ||
/// | ||
/// For more information about this option, see [`set_header_included`]. | ||
/// | ||
/// [`set_header_included`]: Socket::set_header_included | ||
#[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))] | ||
#[cfg_attr( | ||
docsrs, | ||
doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))) | ||
)] | ||
pub fn header_included_v6(&self) -> io::Result<bool> { | ||
unsafe { | ||
getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IPV6, sys::IP_HDRINCL) | ||
.map(|included| included != 0) | ||
} | ||
} | ||
|
||
/// Set the value of the `IP_HDRINCL` option on this socket. | ||
/// | ||
/// If enabled, the user supplies an IP header in front of the user data. | ||
/// Valid only for [`SOCK_RAW`] sockets; see [raw(7)] for more information. | ||
/// When this flag is enabled, the values set by `IP_OPTIONS` are ignored. | ||
/// | ||
/// [`SOCK_RAW`]: Type::RAW | ||
/// [raw(7)]: https://man7.org/linux/man-pages/man7/raw.7.html | ||
#[cfg_attr( | ||
any(target_os = "fuchsia", target_os = "illumos", target_os = "solaris"), | ||
allow(rustdoc::broken_intra_doc_links) | ||
)] | ||
Comment on lines
+1704
to
+1707
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
#[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))] | ||
#[cfg_attr( | ||
docsrs, | ||
doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))) | ||
)] | ||
pub fn set_header_included_v6(&self, included: bool) -> io::Result<()> { | ||
unsafe { | ||
setsockopt( | ||
self.as_raw(), | ||
sys::IPPROTO_IPV6, | ||
sys::IP_HDRINCL, | ||
included as c_int, | ||
) | ||
} | ||
} | ||
|
||
/// Join a multicast group using `IPV6_ADD_MEMBERSHIP` option on this socket. | ||
/// | ||
/// Some OSs use `IPV6_JOIN_GROUP` for this option. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see it's on
set_header_included_v4
, hmmm.. ok to leave then for now.