Skip to content

Commit 42fcdc8

Browse files
committed
use libc instead of sys
1 parent 8787a4b commit 42fcdc8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/socket.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ use std::os::windows::io::{FromRawSocket, IntoRawSocket};
2121
#[cfg(target_os = "wasi")]
2222
use std::os::wasi::io::{FromRawFd, IntoRawFd};
2323
use std::time::Duration;
24+
use libc::IP_HDRINCL;
25+
use libc::IPV6_RECVHOPLIMIT;
2426

2527
use crate::sys::{self, c_int, getsockopt, setsockopt, Bool};
2628
#[cfg(all(unix, not(target_os = "redox")))]
@@ -1135,7 +1137,7 @@ impl Socket {
11351137
#[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))]
11361138
pub fn header_included_v4(&self) -> io::Result<bool> {
11371139
unsafe {
1138-
getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IP, libc::IP_HDRINCL)
1140+
getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IP, IP_HDRINCL)
11391141
.map(|included| included != 0)
11401142
}
11411143
}
@@ -1161,7 +1163,7 @@ impl Socket {
11611163
setsockopt(
11621164
self.as_raw(),
11631165
sys::IPPROTO_IP,
1164-
libc::IP_HDRINCL,
1166+
IP_HDRINCL,
11651167
included as c_int,
11661168
)
11671169
}
@@ -1646,7 +1648,7 @@ impl Socket {
16461648
))]
16471649
pub fn header_included_v6(&self) -> io::Result<bool> {
16481650
unsafe {
1649-
getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IPV6, sys::IP_HDRINCL)
1651+
getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IPV6, IP_HDRINCL)
16501652
.map(|included| included != 0)
16511653
}
16521654
}
@@ -1679,7 +1681,7 @@ impl Socket {
16791681
setsockopt(
16801682
self.as_raw(),
16811683
sys::IPPROTO_IPV6,
1682-
sys::IP_HDRINCL,
1684+
IP_HDRINCL,
16831685
included as c_int,
16841686
)
16851687
}
@@ -1986,7 +1988,7 @@ impl Socket {
19861988
))]
19871989
pub fn recv_hoplimit_v6(&self) -> io::Result<bool> {
19881990
unsafe {
1989-
getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IPV6, sys::IPV6_RECVHOPLIMIT)
1991+
getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IPV6, IPV6_RECVHOPLIMIT)
19901992
.map(|recv_hoplimit| recv_hoplimit > 0)
19911993
}
19921994
}
@@ -2017,7 +2019,7 @@ impl Socket {
20172019
setsockopt(
20182020
self.as_raw(),
20192021
sys::IPPROTO_IPV6,
2020-
sys::IPV6_RECVHOPLIMIT,
2022+
IPV6_RECVHOPLIMIT,
20212023
recv_hoplimit as c_int,
20222024
)
20232025
}

0 commit comments

Comments
 (0)