aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/clientpacket.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/clientpacket.c')
-rw-r--r--networking/udhcp/clientpacket.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c
index 69d7f2d38..af97962a0 100644
--- a/networking/udhcp/clientpacket.c
+++ b/networking/udhcp/clientpacket.c
@@ -25,19 +25,13 @@
25 25
26 26
27/* Create a random xid */ 27/* Create a random xid */
28unsigned long random_xid(void) 28unsigned random_xid(void)
29{ 29{
30 static int initialized; 30 static smallint initialized;
31
31 if (!initialized) { 32 if (!initialized) {
32 unsigned long seed; 33 srand(monotonic_us());
33 34 initialized = 1;
34 if (open_read_close("/dev/urandom", &seed, sizeof(seed)) < 0) {
35 bb_info_msg("Cannot load seed "
36 "from /dev/urandom: %s", strerror(errno));
37 seed = time(0);
38 }
39 srand(seed);
40 initialized++;
41 } 35 }
42 return rand(); 36 return rand();
43} 37}