diff options
author | Russ Dill | 2004-05-19 08:29:05 +0000 |
---|---|---|
committer | Russ Dill | 2004-05-19 08:29:05 +0000 |
commit | 309c7b71e66f45225f369591caf2441bfa2d1670 (patch) | |
tree | 364fc965115e6ba6010ec150f29334af25b159ee | |
parent | 91e006c1adf660a0180b6d3988a14150ccb36fa9 (diff) | |
download | busybox-309c7b71e66f45225f369591caf2441bfa2d1670.zip busybox-309c7b71e66f45225f369591caf2441bfa2d1670.tar.gz |
fix timewarp in client (server fix later)
-rw-r--r-- | networking/udhcp/arpping.c | 6 | ||||
-rw-r--r-- | networking/udhcp/common.c | 9 | ||||
-rw-r--r-- | networking/udhcp/common.h | 1 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 6 |
4 files changed, 16 insertions, 6 deletions
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c index ab4c6d2..7cc2be4 100644 --- a/networking/udhcp/arpping.c +++ b/networking/udhcp/arpping.c @@ -79,7 +79,7 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface) /* wait arp reply, and check it */ tm.tv_usec = 0; - time(&prevTime); + prevTime = uptime(); while (timeout > 0) { FD_ZERO(&fdset); FD_SET(s, &fdset); @@ -97,8 +97,8 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface) break; } } - timeout -= time(NULL) - prevTime; - time(&prevTime); + timeout -= uptime() - prevTime; + prevTime = uptime(); } close(s); DEBUG(LOG_INFO, "%salid arp replies for this address", rv ? "No v" : "V"); diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c index 4f856ee..ce76c51 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c @@ -29,6 +29,7 @@ #include <signal.h> #include <paths.h> #include <sys/socket.h> +#include <sys/sysinfo.h> #include <stdarg.h> #include "common.h" @@ -37,6 +38,14 @@ static int daemonized; +long uptime(void) +{ + struct sysinfo info; + sysinfo(&info); + printf("uptime %d\n", info.uptime); + return info.uptime; +} + /* * This function makes sure our first socket calls diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index cdc51cf..ca19a24 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h @@ -39,6 +39,7 @@ enum syslog_levels { #include <syslog.h> #endif +long uptime(void); void background(const char *pidfile); void start_log_and_pid(const char *client_server, const char *pidfile); void background(const char *pidfile); diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index dda6789..449b517 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -188,7 +188,7 @@ int main(int argc, char *argv[]) int c, len; struct dhcpMessage packet; struct in_addr temp_addr; - time_t now; + long now; int max_fd; int sig; @@ -290,7 +290,7 @@ int main(int argc, char *argv[]) for (;;) { - tv.tv_sec = timeout - time(0); + tv.tv_sec = timeout - uptime(); tv.tv_usec = 0; if (listen_mode != LISTEN_NONE && fd < 0) { @@ -310,7 +310,7 @@ int main(int argc, char *argv[]) retval = select(max_fd + 1, &rfds, NULL, NULL, &tv); } else retval = 0; /* If we already timed out, fall through */ - now = time(0); + now = uptime(); if (retval == 0) { /* timeout dropped to zero */ switch (state) { |