Add current time to posix RNG seed. (#730)

This commit is contained in:
Robert Lubos
2016-09-30 08:56:05 -07:00
committed by Jonathan Hui
parent 081a5acd07
commit 5eb602d443
+3 -1
View File
@@ -34,6 +34,7 @@
* This implementation is not a true random number generator and does @em satisfy the Thread requirements.
*/
#include <time.h>
#include <openthread-types.h>
#include <common/code_utils.hpp>
@@ -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)