summaryrefslogtreecommitdiff
path: root/networking/udhcp
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp')
-rw-r--r--networking/udhcp/clientpacket.c16
-rw-r--r--networking/udhcp/dhcpc.h2
2 files changed, 6 insertions, 12 deletions
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c
index 69d7f2d..af97962 100644
--- a/networking/udhcp/clientpacket.c
+++ b/networking/udhcp/clientpacket.c
@@ -25,19 +25,13 @@
/* Create a random xid */
-unsigned long random_xid(void)
+unsigned random_xid(void)
{
- static int initialized;
+ static smallint initialized;
+
if (!initialized) {
- unsigned long seed;
-
- if (open_read_close("/dev/urandom", &seed, sizeof(seed)) < 0) {
- bb_info_msg("Cannot load seed "
- "from /dev/urandom: %s", strerror(errno));
- seed = time(0);
- }
- srand(seed);
- initialized++;
+ srand(monotonic_us());
+ initialized = 1;
}
return rand();
}
diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h
index 4ddd121..fa091bf 100644
--- a/networking/udhcp/dhcpc.h
+++ b/networking/udhcp/dhcpc.h
@@ -38,7 +38,7 @@ extern struct client_config_t client_config;
/*** clientpacket.h ***/
-unsigned long random_xid(void);
+unsigned random_xid(void);
int send_discover(unsigned long xid, unsigned long requested);
int send_selecting(unsigned long xid, unsigned long server, unsigned long requested);
int send_renew(unsigned long xid, unsigned long server, unsigned long ciaddr);