@@ -1138,6 +1138,16 @@ const fn into_linger(duration: Option<Duration>) -> sys::linger {
11381138/// * Linux: <https://man7.org/linux/man-pages/man7/ip.7.html>
11391139/// * Windows: <https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options>
11401140impl Socket {
1141+ /// This method is deprecated, use [`crate::Socket::header_included_v4`].
1142+ #[ cfg( all( feature = "all" , not( any( target_os = "redox" , target_os = "espidf" ) ) ) ) ]
1143+ #[ cfg_attr(
1144+ docsrs,
1145+ doc( cfg( all( feature = "all" , not( any( target_os = "redox" , target_os = "espidf" ) ) ) ) )
1146+ ) ]
1147+ #[ deprecated = "Use `Socket::header_included_v4` instead" ]
1148+ pub fn header_included ( & self ) -> io:: Result < bool > {
1149+ self . header_included_v4 ( )
1150+ }
11411151 /// Get the value of the `IP_HDRINCL` option on this socket.
11421152 ///
11431153 /// For more information about this option, see [`set_header_included`].
@@ -1148,13 +1158,28 @@ impl Socket {
11481158 docsrs,
11491159 doc( cfg( all( feature = "all" , not( any( target_os = "redox" , target_os = "espidf" ) ) ) ) )
11501160 ) ]
1151- pub fn header_included ( & self ) -> io:: Result < bool > {
1161+ pub fn header_included_v4 ( & self ) -> io:: Result < bool > {
11521162 unsafe {
11531163 getsockopt :: < c_int > ( self . as_raw ( ) , sys:: IPPROTO_IP , sys:: IP_HDRINCL )
11541164 . map ( |included| included != 0 )
11551165 }
11561166 }
11571167
1168+ /// This method is deprecated, use [`crate::Socket::set_header_included_v4`].
1169+ #[ cfg_attr(
1170+ any( target_os = "fuchsia" , target_os = "illumos" , target_os = "solaris" ) ,
1171+ allow( rustdoc:: broken_intra_doc_links)
1172+ ) ]
1173+ #[ cfg( all( feature = "all" , not( any( target_os = "redox" , target_os = "espidf" ) ) ) ) ]
1174+ #[ cfg_attr(
1175+ docsrs,
1176+ doc( cfg( all( feature = "all" , not( any( target_os = "redox" , target_os = "espidf" ) ) ) ) )
1177+ ) ]
1178+ #[ deprecated = "Use `Socket::set_header_included_v4` instead" ]
1179+ pub fn set_header_included ( & self , included : bool ) -> io:: Result < ( ) > {
1180+ self . set_header_included_v4 ( included)
1181+ }
1182+
11581183 /// Set the value of the `IP_HDRINCL` option on this socket.
11591184 ///
11601185 /// If enabled, the user supplies an IP header in front of the user data.
@@ -1175,7 +1200,7 @@ impl Socket {
11751200 docsrs,
11761201 doc( cfg( all( feature = "all" , not( any( target_os = "redox" , target_os = "espidf" ) ) ) ) )
11771202 ) ]
1178- pub fn set_header_included ( & self , included : bool ) -> io:: Result < ( ) > {
1203+ pub fn set_header_included_v4 ( & self , included : bool ) -> io:: Result < ( ) > {
11791204 unsafe {
11801205 setsockopt (
11811206 self . as_raw ( ) ,
@@ -1651,6 +1676,51 @@ impl Socket {
16511676/// * Linux: <https://man7.org/linux/man-pages/man7/ipv6.7.html>
16521677/// * Windows: <https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options>
16531678impl Socket {
1679+ /// Get the value of the `IP_HDRINCL` option on this socket.
1680+ ///
1681+ /// For more information about this option, see [`set_header_included`].
1682+ ///
1683+ /// [`set_header_included`]: Socket::set_header_included
1684+ #[ cfg( all( feature = "all" , not( any( target_os = "redox" , target_os = "espidf" ) ) ) ) ]
1685+ #[ cfg_attr(
1686+ docsrs,
1687+ doc( cfg( all( feature = "all" , not( any( target_os = "redox" , target_os = "espidf" ) ) ) ) )
1688+ ) ]
1689+ pub fn header_included_v6 ( & self ) -> io:: Result < bool > {
1690+ unsafe {
1691+ getsockopt :: < c_int > ( self . as_raw ( ) , sys:: IPPROTO_IPV6 , sys:: IP_HDRINCL )
1692+ . map ( |included| included != 0 )
1693+ }
1694+ }
1695+
1696+ /// Set the value of the `IP_HDRINCL` option on this socket.
1697+ ///
1698+ /// If enabled, the user supplies an IP header in front of the user data.
1699+ /// Valid only for [`SOCK_RAW`] sockets; see [raw(7)] for more information.
1700+ /// When this flag is enabled, the values set by `IP_OPTIONS` are ignored.
1701+ ///
1702+ /// [`SOCK_RAW`]: Type::RAW
1703+ /// [raw(7)]: https://man7.org/linux/man-pages/man7/raw.7.html
1704+ #[ cfg_attr(
1705+ any( target_os = "fuchsia" , target_os = "illumos" , target_os = "solaris" ) ,
1706+ allow( rustdoc:: broken_intra_doc_links)
1707+ ) ]
1708+ #[ cfg( all( feature = "all" , not( any( target_os = "redox" , target_os = "espidf" ) ) ) ) ]
1709+ #[ cfg_attr(
1710+ docsrs,
1711+ doc( cfg( all( feature = "all" , not( any( target_os = "redox" , target_os = "espidf" ) ) ) ) )
1712+ ) ]
1713+ pub fn set_header_included_v6 ( & self , included : bool ) -> io:: Result < ( ) > {
1714+ unsafe {
1715+ setsockopt (
1716+ self . as_raw ( ) ,
1717+ sys:: IPPROTO_IPV6 ,
1718+ sys:: IP_HDRINCL ,
1719+ included as c_int ,
1720+ )
1721+ }
1722+ }
1723+
16541724 /// Join a multicast group using `IPV6_ADD_MEMBERSHIP` option on this socket.
16551725 ///
16561726 /// Some OSs use `IPV6_JOIN_GROUP` for this option.
0 commit comments