Merge branch 'master' into feature/dhcp-lease-updates

This commit is contained in:
Dario Nieuwenhuis 2021-03-24 03:26:42 +01:00 committed by GitHub
commit f6259f8113
3 changed files with 20 additions and 5 deletions

View File

@ -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"]

View File

@ -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]

View File

@ -47,7 +47,8 @@ pub fn wait(fd: RawFd, duration: Option<Duration>) -> 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()