Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
#include "mpr_selector_set.h"
#include "gateway.h"
#include "olsr_niit.h"
#include "mpr_selector_set.h"
#include "gateway.h"
#include "olsr_niit.h"
+#include "olsr_random.h"
#ifdef __linux__
#include <linux/types.h>
#ifdef __linux__
#include <linux/types.h>
-static void initRandom(void) {
- unsigned int seed = (unsigned int)time(NULL);
-
-#ifndef _WIN32
- int randomFile;
-
- randomFile = open("/dev/urandom", O_RDONLY);
- if (randomFile == -1) {
- randomFile = open("/dev/random", O_RDONLY);
- }
-
- if (randomFile != -1) {
- if (read(randomFile, &seed, sizeof(seed)) != sizeof(seed)) {
- ; /* to fix an 'unused result' compiler warning */
- }
- close(randomFile);
- }
-#endif /* _WIN32 */
-
- srandom(seed);
-}
-
olsr_openlog("olsrd");
/* setup random seed */
olsr_openlog("olsrd");
/* setup random seed */
/* Init widely used statics */
memset(&all_zero, 0, sizeof(union olsr_ip_addr));
/* Init widely used statics */
memset(&all_zero, 0, sizeof(union olsr_ip_addr));
#include "lq_plugin.h"
#include "gateway.h"
#include "duplicate_handler.h"
#include "lq_plugin.h"
#include "gateway.h"
#include "duplicate_handler.h"
+#include "olsr_random.h"
#include <stdarg.h>
#include <signal.h>
#include <stdarg.h>
#include <signal.h>
void
init_msg_seqno(void)
{
void
init_msg_seqno(void)
{
- message_seqno = random() & 0xFFFF;
+ message_seqno = olsr_random() & 0xFFFF;
set_buffer_timer(struct interface_olsr *ifn)
{
/* Set timer */
set_buffer_timer(struct interface_olsr *ifn)
{
/* Set timer */
- ifn->fwdtimer = GET_TIMESTAMP(random() * olsr_cnf->max_jitter * MSEC_PER_SEC / RAND_MAX);
+ ifn->fwdtimer = GET_TIMESTAMP(olsr_random() * olsr_cnf->max_jitter * MSEC_PER_SEC / OLSR_RANDOM_MAX);
#include "olsr_cookie.h"
#include "net_os.h"
#include "mpr_selector_set.h"
#include "olsr_cookie.h"
#include "net_os.h"
#include "mpr_selector_set.h"
+#include "olsr_random.h"
*/
if (timer->timer_period) {
/* For periodical timers, rehash the random number and restart */
*/
if (timer->timer_period) {
/* For periodical timers, rehash the random number and restart */
- timer->timer_random = random();
+ timer->timer_random = olsr_random();
olsr_change_timer(timer, timer->timer_period, timer->timer_jitter_pct, OLSR_TIMER_PERIODIC);
} else {
/* Singleshot timers are stopped */
olsr_change_timer(timer, timer->timer_period, timer->timer_jitter_pct, OLSR_TIMER_PERIODIC);
} else {
/* Singleshot timers are stopped */
* Compute random numbers only once.
*/
if (!timer->timer_random) {
* Compute random numbers only once.
*/
if (!timer->timer_random) {
- timer->timer_random = random();
+ timer->timer_random = olsr_random();