From 8e86318a13d7390377adfdb09b5f11b9407f4df7 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 24 Mar 2021 00:49:08 +0100 Subject: [PATCH 1/2] Fix feature-related compilation issues. --- Cargo.toml | 8 ++++---- src/lib.rs | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bed522b..125c4ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,12 +32,12 @@ url = "1.0" std = ["managed/std"] alloc = ["managed/alloc"] verbose = [] -ethernet = [] -"phy-raw_socket" = ["std", "libc"] -"phy-tap_interface" = ["std", "libc"] +ethernet = ["socket"] +"phy-raw_socket" = ["std", "libc", "ethernet"] +"phy-tap_interface" = ["std", "libc", "ethernet"] "proto-ipv4" = [] "proto-igmp" = ["proto-ipv4"] -"proto-dhcpv4" = ["proto-ipv4", "socket-raw"] +"proto-dhcpv4" = ["proto-ipv4", "socket-raw", "ethernet"] "proto-ipv6" = [] "socket" = [] "socket-raw" = ["socket"] diff --git a/src/lib.rs b/src/lib.rs index 8f28466..624b6b9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,6 +83,20 @@ compile_error!("at least one socket needs to be enabled"); */ #[cfg(feature = "alloc")] extern crate alloc; +#[cfg(not(any(feature = "proto-ipv4", feature = "proto-ipv6")))] +compile_error!("You must enable at least one of the following features: proto-ipv4, proto-ipv6"); + +#[cfg(all( + feature = "socket", + not(any( + feature = "socket-raw", + feature = "socket-udp", + feature = "socket-tcp", + feature = "socket-icmp", + )) +))] +compile_error!("If you enable the socket feature, you must enable at least one of the following features: socket-raw, socket-udp, socket-tcp, socket-icmp"); + use core::fmt; #[macro_use] From a5763893409a43898fad3f9a24fde38ce3a27573 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 24 Mar 2021 02:58:51 +0100 Subject: [PATCH 2/2] Fix timeval in phy_wait for times greater than 1 second --- src/phy/sys/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/phy/sys/mod.rs b/src/phy/sys/mod.rs index 59f59cf..0730d1b 100644 --- a/src/phy/sys/mod.rs +++ b/src/phy/sys/mod.rs @@ -47,7 +47,8 @@ pub fn wait(fd: RawFd, duration: Option) -> io::Result<()> { let mut timeout = libc::timeval { tv_sec: 0, tv_usec: 0 }; let timeout_ptr = if let Some(duration) = duration { - timeout.tv_usec = (duration.total_millis() * 1_000) as libc::suseconds_t; + timeout.tv_sec = duration.secs() as libc::time_t; + timeout.tv_usec = (duration.millis() * 1_000) as libc::suseconds_t; &mut timeout as *mut _ } else { ptr::null_mut()