Skip to content

Commit bf4f273

Browse files
bors[bot]rtzoellercemeyer
authored
Merge #1509 #1515
1509: Allow Android to use timerfd r=asomers a=rtzoeller This is a continuation of #1336 which also enables the timerfd tests. ``` running 3 tests test sys::test_timerfd::test_timerfd_unset ... ok test sys::test_timerfd::test_timerfd_oneshot ... ok test sys::test_timerfd::test_timerfd_interval ... ok ``` 1515: Add IP_TTL/IPV6_UNICAST_HOPS SockOpts r=asomers a=cemeyer Test: `cargo test --test test test_ttl_opts` Co-authored-by: Ryan Zoeller <[email protected]> Co-authored-by: Conrad Meyer <[email protected]>
3 parents f44a506 + 2a31ac1 + 1ce595f commit bf4f273

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
4040
(#[1514](https://github.com/nix-rust/nix/pull/1514))
4141
- Added `AsRawFd` implementation on `PollFd`.
4242
(#[1516](https://github.com/nix-rust/nix/pull/1516))
43+
- Added `Ipv4Ttl` and `Ipv6Ttl` sockopts.
44+
(#[1515](https://github.com/nix-rust/nix/pull/1515))
4345

4446
### Changed
4547

src/sys/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,6 @@ pub mod wait;
126126
#[allow(missing_docs)]
127127
pub mod inotify;
128128

129-
#[cfg(target_os = "linux")]
129+
#[cfg(any(target_os = "android", target_os = "linux"))]
130130
#[allow(missing_docs)]
131131
pub mod timerfd;

src/sys/socket/sockopt.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,10 @@ sockopt_impl!(Both, Ipv6V6Only, libc::IPPROTO_IPV6, libc::IPV6_V6ONLY, bool);
356356
sockopt_impl!(Both, Ipv4RecvErr, libc::IPPROTO_IP, libc::IP_RECVERR, bool);
357357
#[cfg(any(target_os = "android", target_os = "linux"))]
358358
sockopt_impl!(Both, Ipv6RecvErr, libc::IPPROTO_IPV6, libc::IPV6_RECVERR, bool);
359+
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
360+
sockopt_impl!(Both, Ipv4Ttl, libc::IPPROTO_IP, libc::IP_TTL, libc::c_int);
361+
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
362+
sockopt_impl!(Both, Ipv6Ttl, libc::IPPROTO_IPV6, libc::IPV6_UNICAST_HOPS, libc::c_int);
359363

360364
#[cfg(any(target_os = "android", target_os = "linux"))]
361365
#[derive(Copy, Clone, Debug)]

test/sys/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ mod test_pthread;
4141
target_os = "netbsd",
4242
target_os = "openbsd"))]
4343
mod test_ptrace;
44-
#[cfg(target_os = "linux")]
44+
#[cfg(any(target_os = "android", target_os = "linux"))]
4545
mod test_timerfd;

test/sys/test_sockopt.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,14 @@ fn test_so_tcp_keepalive() {
186186
assert_eq!(getsockopt(fd, sockopt::TcpKeepInterval).unwrap(), x + 1);
187187
}
188188
}
189+
190+
#[test]
191+
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
192+
fn test_ttl_opts() {
193+
let fd4 = socket(AddressFamily::Inet, SockType::Datagram, SockFlag::empty(), None).unwrap();
194+
setsockopt(fd4, sockopt::Ipv4Ttl, &1)
195+
.expect("setting ipv4ttl on an inet socket should succeed");
196+
let fd6 = socket(AddressFamily::Inet6, SockType::Datagram, SockFlag::empty(), None).unwrap();
197+
setsockopt(fd6, sockopt::Ipv6Ttl, &1)
198+
.expect("setting ipv6ttl on an inet6 socket should succeed");
199+
}

0 commit comments

Comments
 (0)