Commit 1352895a authored by Dafydd Harries's avatar Dafydd Harries

don't seed new RNGs to 0 by default; allow overriding RNG constructor

darcs-hash:20070205172439-c9803-1407272fc5941c986205b683b05756d7b52eca9e.gz
parent 00f0b1e2
......@@ -4,6 +4,7 @@
#include "agent.h"
#include "stun.h"
#include "udp-fake.h"
#include "random-glib.h"
void
send_connectivity_check (
......@@ -76,6 +77,8 @@ main (void)
/* set up */
nice_rng_set_new_func (nice_rng_glib_new_predictable);
nice_udp_fake_socket_factory_init (&factory);
agent = nice_agent_new (&factory);
......
......@@ -31,6 +31,7 @@ T nice_rng_generate_int
T nice_rng_glib_new
T nice_rng_glib_new_predictable
T nice_rng_new
T nice_rng_set_new_func
T nice_udp_bsd_socket_factory_init
T nice_udp_fake_socket_factory_init
T nice_udp_fake_socket_pop_send
......
......@@ -2,14 +2,21 @@
#include "random.h"
#include "random-glib.h"
static NiceRNG * (*nice_rng_new_func) (void) = NULL;
NiceRNG *
nice_rng_new (void)
{
NiceRNG *rng;
if (nice_rng_new_func == NULL)
return nice_rng_glib_new ();
else
return nice_rng_new_func ();
}
rng = nice_rng_glib_new ();
rng->seed (rng, 0);
return rng;
void
nice_rng_set_new_func (NiceRNG * (*func) (void))
{
nice_rng_new_func = func;
}
void
......
......@@ -19,6 +19,9 @@ struct _NiceRNG {
NiceRNG *
nice_rng_new (void);
void
nice_rng_set_new_func (NiceRNG * (*func) (void));
void
nice_rng_seed (NiceRNG *rng, guint32 seed);
......
#include <string.h>
#include "random.h"
#include "random-glib.h"
int
main (void)
......@@ -9,6 +9,7 @@ main (void)
NiceRNG *rng;
gchar buf[9];
nice_rng_set_new_func (nice_rng_glib_new_predictable);
rng = nice_rng_new ();
nice_rng_generate_bytes_print (rng, 8, buf);
buf[8] = '\0';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment