aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2011-01-04 19:49:31 +0700
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2011-01-04 19:49:31 +0700
commit808c59093f66849fd65c283ec2f68745a98cd291 (patch)
tree53a7fca34f88c1513334deea30457ca8902f1faf /networking
parent85031e551c05fa13e268a085983fb7f61f11dde2 (diff)
parente08ef581af510312dacba40e78a6af7ca36ffbc5 (diff)
downloadbusybox-w32-808c59093f66849fd65c283ec2f68745a98cd291.tar.gz
busybox-w32-808c59093f66849fd65c283ec2f68745a98cd291.tar.bz2
busybox-w32-808c59093f66849fd65c283ec2f68745a98cd291.zip
Merge commit 'eb7fe6dbf5bc93a229379a8047539dd8b90e0974^'
Diffstat (limited to 'networking')
-rw-r--r--networking/udhcp/dumpleases.c13
-rw-r--r--networking/udhcp/files.c14
2 files changed, 3 insertions, 24 deletions
diff --git a/networking/udhcp/dumpleases.c b/networking/udhcp/dumpleases.c
index 2eaadb6eb..46610fc63 100644
--- a/networking/udhcp/dumpleases.c
+++ b/networking/udhcp/dumpleases.c
@@ -6,17 +6,6 @@
6#include "dhcpd.h" 6#include "dhcpd.h"
7#include "unicode.h" 7#include "unicode.h"
8 8
9#if BB_LITTLE_ENDIAN
10static inline uint64_t hton64(uint64_t v)
11{
12 return (((uint64_t)htonl(v)) << 32) | htonl(v >> 32);
13}
14#else
15#define hton64(v) (v)
16#endif
17#define ntoh64(v) hton64(v)
18
19
20int dumpleases_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 9int dumpleases_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
21int dumpleases_main(int argc UNUSED_PARAM, char **argv) 10int dumpleases_main(int argc UNUSED_PARAM, char **argv)
22{ 11{
@@ -54,7 +43,7 @@ int dumpleases_main(int argc UNUSED_PARAM, char **argv)
54 /* "123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 */ 43 /* "123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 */
55 44
56 xread(fd, &written_at, sizeof(written_at)); 45 xread(fd, &written_at, sizeof(written_at));
57 written_at = ntoh64(written_at); 46 written_at = SWAP_BE64(written_at);
58 curr = time(NULL); 47 curr = time(NULL);
59 if (curr < written_at) 48 if (curr < written_at)
60 written_at = curr; /* lease file from future! :) */ 49 written_at = curr; /* lease file from future! :) */
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
index f5348f658..49bcafb9c 100644
--- a/networking/udhcp/files.c
+++ b/networking/udhcp/files.c
@@ -11,16 +11,6 @@
11#include "common.h" 11#include "common.h"
12#include "dhcpd.h" 12#include "dhcpd.h"
13 13
14#if BB_LITTLE_ENDIAN
15static inline uint64_t hton64(uint64_t v)
16{
17 return (((uint64_t)htonl(v)) << 32) | htonl(v >> 32);
18}
19#else
20#define hton64(v) (v)
21#endif
22#define ntoh64(v) hton64(v)
23
24/* on these functions, make sure your datatype matches */ 14/* on these functions, make sure your datatype matches */
25static int FAST_FUNC read_str(const char *line, void *arg) 15static int FAST_FUNC read_str(const char *line, void *arg)
26{ 16{
@@ -140,7 +130,7 @@ void FAST_FUNC write_leases(void)
140 130
141 curr = written_at = time(NULL); 131 curr = written_at = time(NULL);
142 132
143 written_at = hton64(written_at); 133 written_at = SWAP_BE64(written_at);
144 full_write(fd, &written_at, sizeof(written_at)); 134 full_write(fd, &written_at, sizeof(written_at));
145 135
146 for (i = 0; i < server_config.max_leases; i++) { 136 for (i = 0; i < server_config.max_leases; i++) {
@@ -190,7 +180,7 @@ void FAST_FUNC read_leases(const char *file)
190 180
191 if (full_read(fd, &written_at, sizeof(written_at)) != sizeof(written_at)) 181 if (full_read(fd, &written_at, sizeof(written_at)) != sizeof(written_at))
192 goto ret; 182 goto ret;
193 written_at = ntoh64(written_at); 183 written_at = SWAP_BE64(written_at);
194 184
195 time_passed = time(NULL) - written_at; 185 time_passed = time(NULL) - written_at;
196 /* Strange written_at, or lease file from old version of udhcpd 186 /* Strange written_at, or lease file from old version of udhcpd