@@ -1138,6 +1138,16 @@ const fn into_linger(duration: Option<Duration>) -> sys::linger {
1138
1138
/// * Linux: <https://man7.org/linux/man-pages/man7/ip.7.html>
1139
1139
/// * Windows: <https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options>
1140
1140
impl 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
+ }
1141
1151
/// Get the value of the `IP_HDRINCL` option on this socket.
1142
1152
///
1143
1153
/// For more information about this option, see [`set_header_included`].
@@ -1148,13 +1158,28 @@ impl Socket {
1148
1158
docsrs,
1149
1159
doc( cfg( all( feature = "all" , not( any( target_os = "redox" , target_os = "espidf" ) ) ) ) )
1150
1160
) ]
1151
- pub fn header_included ( & self ) -> io:: Result < bool > {
1161
+ pub fn header_included_v4 ( & self ) -> io:: Result < bool > {
1152
1162
unsafe {
1153
1163
getsockopt :: < c_int > ( self . as_raw ( ) , sys:: IPPROTO_IP , sys:: IP_HDRINCL )
1154
1164
. map ( |included| included != 0 )
1155
1165
}
1156
1166
}
1157
1167
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
+
1158
1183
/// Set the value of the `IP_HDRINCL` option on this socket.
1159
1184
///
1160
1185
/// If enabled, the user supplies an IP header in front of the user data.
@@ -1175,7 +1200,7 @@ impl Socket {
1175
1200
docsrs,
1176
1201
doc( cfg( all( feature = "all" , not( any( target_os = "redox" , target_os = "espidf" ) ) ) ) )
1177
1202
) ]
1178
- pub fn set_header_included ( & self , included : bool ) -> io:: Result < ( ) > {
1203
+ pub fn set_header_included_v4 ( & self , included : bool ) -> io:: Result < ( ) > {
1179
1204
unsafe {
1180
1205
setsockopt (
1181
1206
self . as_raw ( ) ,
@@ -1651,6 +1676,51 @@ impl Socket {
1651
1676
/// * Linux: <https://man7.org/linux/man-pages/man7/ipv6.7.html>
1652
1677
/// * Windows: <https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options>
1653
1678
impl 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
+
1654
1724
/// Join a multicast group using `IPV6_ADD_MEMBERSHIP` option on this socket.
1655
1725
///
1656
1726
/// Some OSs use `IPV6_JOIN_GROUP` for this option.
0 commit comments