diff options
author | Russ Dill <Russ.Dill@asu.edu> | 2004-05-19 08:29:05 +0000 |
---|---|---|
committer | Russ Dill <Russ.Dill@asu.edu> | 2004-05-19 08:29:05 +0000 |
commit | 309c7b71e66f45225f369591caf2441bfa2d1670 (patch) | |
tree | 364fc965115e6ba6010ec150f29334af25b159ee | |
parent | 91e006c1adf660a0180b6d3988a14150ccb36fa9 (diff) | |
download | busybox-w32-309c7b71e66f45225f369591caf2441bfa2d1670.tar.gz busybox-w32-309c7b71e66f45225f369591caf2441bfa2d1670.tar.bz2 busybox-w32-309c7b71e66f45225f369591caf2441bfa2d1670.zip |
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 ab4c6d20c..7cc2be42e 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) | |||
79 | 79 | ||
80 | /* wait arp reply, and check it */ | 80 | /* wait arp reply, and check it */ |
81 | tm.tv_usec = 0; | 81 | tm.tv_usec = 0; |
82 | time(&prevTime); | 82 | prevTime = uptime(); |
83 | while (timeout > 0) { | 83 | while (timeout > 0) { |
84 | FD_ZERO(&fdset); | 84 | FD_ZERO(&fdset); |
85 | FD_SET(s, &fdset); | 85 | FD_SET(s, &fdset); |
@@ -97,8 +97,8 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface) | |||
97 | break; | 97 | break; |
98 | } | 98 | } |
99 | } | 99 | } |
100 | timeout -= time(NULL) - prevTime; | 100 | timeout -= uptime() - prevTime; |
101 | time(&prevTime); | 101 | prevTime = uptime(); |
102 | } | 102 | } |
103 | close(s); | 103 | close(s); |
104 | DEBUG(LOG_INFO, "%salid arp replies for this address", rv ? "No v" : "V"); | 104 | 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 4f856ee6c..ce76c516d 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <signal.h> | 29 | #include <signal.h> |
30 | #include <paths.h> | 30 | #include <paths.h> |
31 | #include <sys/socket.h> | 31 | #include <sys/socket.h> |
32 | #include <sys/sysinfo.h> | ||
32 | #include <stdarg.h> | 33 | #include <stdarg.h> |
33 | 34 | ||
34 | #include "common.h" | 35 | #include "common.h" |
@@ -37,6 +38,14 @@ | |||
37 | 38 | ||
38 | static int daemonized; | 39 | static int daemonized; |
39 | 40 | ||
41 | long uptime(void) | ||
42 | { | ||
43 | struct sysinfo info; | ||
44 | sysinfo(&info); | ||
45 | printf("uptime %d\n", info.uptime); | ||
46 | return info.uptime; | ||
47 | } | ||
48 | |||
40 | 49 | ||
41 | /* | 50 | /* |
42 | * This function makes sure our first socket calls | 51 | * This function makes sure our first socket calls |
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index cdc51cf8a..ca19a2497 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h | |||
@@ -39,6 +39,7 @@ enum syslog_levels { | |||
39 | #include <syslog.h> | 39 | #include <syslog.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | long uptime(void); | ||
42 | void background(const char *pidfile); | 43 | void background(const char *pidfile); |
43 | void start_log_and_pid(const char *client_server, const char *pidfile); | 44 | void start_log_and_pid(const char *client_server, const char *pidfile); |
44 | void background(const char *pidfile); | 45 | void background(const char *pidfile); |
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index dda678933..449b51763 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -188,7 +188,7 @@ int main(int argc, char *argv[]) | |||
188 | int c, len; | 188 | int c, len; |
189 | struct dhcpMessage packet; | 189 | struct dhcpMessage packet; |
190 | struct in_addr temp_addr; | 190 | struct in_addr temp_addr; |
191 | time_t now; | 191 | long now; |
192 | int max_fd; | 192 | int max_fd; |
193 | int sig; | 193 | int sig; |
194 | 194 | ||
@@ -290,7 +290,7 @@ int main(int argc, char *argv[]) | |||
290 | 290 | ||
291 | for (;;) { | 291 | for (;;) { |
292 | 292 | ||
293 | tv.tv_sec = timeout - time(0); | 293 | tv.tv_sec = timeout - uptime(); |
294 | tv.tv_usec = 0; | 294 | tv.tv_usec = 0; |
295 | 295 | ||
296 | if (listen_mode != LISTEN_NONE && fd < 0) { | 296 | if (listen_mode != LISTEN_NONE && fd < 0) { |
@@ -310,7 +310,7 @@ int main(int argc, char *argv[]) | |||
310 | retval = select(max_fd + 1, &rfds, NULL, NULL, &tv); | 310 | retval = select(max_fd + 1, &rfds, NULL, NULL, &tv); |
311 | } else retval = 0; /* If we already timed out, fall through */ | 311 | } else retval = 0; /* If we already timed out, fall through */ |
312 | 312 | ||
313 | now = time(0); | 313 | now = uptime(); |
314 | if (retval == 0) { | 314 | if (retval == 0) { |
315 | /* timeout dropped to zero */ | 315 | /* timeout dropped to zero */ |
316 | switch (state) { | 316 | switch (state) { |