From 5eb602d4434dfe07f41f2ab53ca6f70b33917e4a Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Fri, 30 Sep 2016 17:56:05 +0200 Subject: [PATCH] Add current time to posix RNG seed. (#730) --- examples/platforms/posix/random.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/platforms/posix/random.c b/examples/platforms/posix/random.c index 09dce589a..72a27a4c5 100644 --- a/examples/platforms/posix/random.c +++ b/examples/platforms/posix/random.c @@ -34,6 +34,7 @@ * This implementation is not a true random number generator and does @em satisfy the Thread requirements. */ +#include #include #include @@ -44,7 +45,8 @@ static uint32_t s_state = 1; void posixRandomInit(void) { - s_state = NODE_ID; + // Multiplying NODE_ID assures that no two nodes gets the same seed within an hour. + s_state = (uint32_t)time(NULL) + (3600 * NODE_ID); } uint32_t otPlatRandomGet(void)