diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-14 02:23:43 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-14 02:23:43 +0000 |
commit | ea62077b850076c4d7dc3cf78ebd1888928c6ddf (patch) | |
tree | 37b7584ae40b99edb5583fbc4392b62ffdadf278 /networking/udhcp | |
parent | 88ca06769028e442bf873b270c176ca0e9f021f8 (diff) | |
download | busybox-w32-ea62077b850076c4d7dc3cf78ebd1888928c6ddf.tar.gz busybox-w32-ea62077b850076c4d7dc3cf78ebd1888928c6ddf.tar.bz2 busybox-w32-ea62077b850076c4d7dc3cf78ebd1888928c6ddf.zip |
add open_read_close() and similar stuff
Diffstat (limited to 'networking/udhcp')
-rw-r--r-- | networking/udhcp/arpping.c | 2 | ||||
-rw-r--r-- | networking/udhcp/clientpacket.c | 7 | ||||
-rw-r--r-- | networking/udhcp/options.c | 2 | ||||
-rw-r--r-- | networking/udhcp/signalpipe.c | 2 |
4 files changed, 5 insertions, 8 deletions
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c index 587339f9b..086692082 100644 --- a/networking/udhcp/arpping.c +++ b/networking/udhcp/arpping.c | |||
@@ -49,7 +49,7 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface) | |||
49 | } | 49 | } |
50 | 50 | ||
51 | if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval)) == -1) { | 51 | if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval)) == -1) { |
52 | bb_perror_msg("Could not setsocketopt on raw socket"); | 52 | bb_perror_msg("cannot setsocketopt on raw socket"); |
53 | close(s); | 53 | close(s); |
54 | return -1; | 54 | return -1; |
55 | } | 55 | } |
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c index f9f5a3b8c..439aa0250 100644 --- a/networking/udhcp/clientpacket.c +++ b/networking/udhcp/clientpacket.c | |||
@@ -39,16 +39,13 @@ unsigned long random_xid(void) | |||
39 | { | 39 | { |
40 | static int initialized; | 40 | static int initialized; |
41 | if (!initialized) { | 41 | if (!initialized) { |
42 | int fd; | ||
43 | unsigned long seed; | 42 | unsigned long seed; |
44 | 43 | ||
45 | fd = open("/dev/urandom", 0); | 44 | if (open_read_close("/dev/urandom", &seed, sizeof(seed)) < 0) { |
46 | if (fd < 0 || read(fd, &seed, sizeof(seed)) < 0) { | 45 | bb_info_msg("Cannot load seed " |
47 | bb_info_msg("Could not load seed " | ||
48 | "from /dev/urandom: %s", strerror(errno)); | 46 | "from /dev/urandom: %s", strerror(errno)); |
49 | seed = time(0); | 47 | seed = time(0); |
50 | } | 48 | } |
51 | if (fd >= 0) close(fd); | ||
52 | srand(seed); | 49 | srand(seed); |
53 | initialized++; | 50 | initialized++; |
54 | } | 51 | } |
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c index ded0f7b9b..8dba2ef69 100644 --- a/networking/udhcp/options.c +++ b/networking/udhcp/options.c | |||
@@ -171,6 +171,6 @@ int add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data) | |||
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | bb_error_msg("Could not add option 0x%02x", code); | 174 | bb_error_msg("cannot add option 0x%02x", code); |
175 | return 0; | 175 | return 0; |
176 | } | 176 | } |
diff --git a/networking/udhcp/signalpipe.c b/networking/udhcp/signalpipe.c index 6c4a9f1f2..bece4193a 100644 --- a/networking/udhcp/signalpipe.c +++ b/networking/udhcp/signalpipe.c | |||
@@ -36,7 +36,7 @@ static int signal_pipe[2]; | |||
36 | static void signal_handler(int sig) | 36 | static void signal_handler(int sig) |
37 | { | 37 | { |
38 | if (send(signal_pipe[1], &sig, sizeof(sig), MSG_DONTWAIT) < 0) | 38 | if (send(signal_pipe[1], &sig, sizeof(sig), MSG_DONTWAIT) < 0) |
39 | bb_perror_msg("Could not send signal"); | 39 | bb_perror_msg("cannot send signal"); |
40 | } | 40 | } |
41 | 41 | ||
42 | 42 | ||