wget: use monotonic_sec instead of gettimeofday
[oweals/busybox.git] / networking / udhcp / clientpacket.c
index 15cbda2f5c895f50f9ae7c500969a02d1dd4b444..af97962a0b523873a82af7bbfefa988e3119dd9b 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #include <features.h>
-#if (__GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined _NEWLIB_VERSION
+#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined _NEWLIB_VERSION
 #include <netpacket/packet.h>
 #include <net/ethernet.h>
 #else
 
 
 /* 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();
 }