Commit 8c014b0b authored by Dafydd Harries's avatar Dafydd Harries

use one RNG per agent

darcs-hash:20070313171803-c9803-70fea1434bb7bf49145812c7d1797c23fd052151.gz
parent 29db0956
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "stun.h" #include "stun.h"
#include "udp.h" #include "udp.h"
#include "random.h"
#include "agent.h" #include "agent.h"
#include "agent-signals-marshal.h" #include "agent-signals-marshal.h"
...@@ -293,6 +292,7 @@ nice_agent_init (NiceAgent *agent) ...@@ -293,6 +292,7 @@ nice_agent_init (NiceAgent *agent)
{ {
agent->next_candidate_id = 1; agent->next_candidate_id = 1;
agent->next_stream_id = 1; agent->next_stream_id = 1;
agent->rng = nice_rng_new ();
} }
...@@ -368,7 +368,6 @@ nice_agent_add_local_host_candidate ( ...@@ -368,7 +368,6 @@ nice_agent_add_local_host_candidate (
guint component_id, guint component_id,
NiceAddress *address) NiceAddress *address)
{ {
NiceRNG *rng;
NiceCandidate *candidate; NiceCandidate *candidate;
Component *component; Component *component;
...@@ -385,10 +384,8 @@ nice_agent_add_local_host_candidate ( ...@@ -385,10 +384,8 @@ nice_agent_add_local_host_candidate (
candidate); candidate);
/* generate username/password */ /* generate username/password */
rng = nice_rng_new (); nice_rng_generate_bytes_print (agent->rng, 8, candidate->username);
nice_rng_generate_bytes_print (rng, 8, candidate->username); nice_rng_generate_bytes_print (agent->rng, 8, candidate->password);
nice_rng_generate_bytes_print (rng, 8, candidate->password);
nice_rng_free (rng);
/* allocate socket */ /* allocate socket */
/* XXX: handle error */ /* XXX: handle error */
...@@ -1213,6 +1210,9 @@ nice_agent_dispose (GObject *object) ...@@ -1213,6 +1210,9 @@ nice_agent_dispose (GObject *object)
g_free (agent->stun_server); g_free (agent->stun_server);
agent->stun_server = NULL; agent->stun_server = NULL;
nice_rng_free (agent->rng);
agent->rng = NULL;
if (G_OBJECT_CLASS (nice_agent_parent_class)->dispose) if (G_OBJECT_CLASS (nice_agent_parent_class)->dispose)
G_OBJECT_CLASS (nice_agent_parent_class)->dispose (object); G_OBJECT_CLASS (nice_agent_parent_class)->dispose (object);
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "udp.h" #include "udp.h"
#include "address.h" #include "address.h"
#include "candidate.h" #include "candidate.h"
#include "random.h"
G_BEGIN_DECLS G_BEGIN_DECLS
...@@ -58,6 +59,7 @@ struct _NiceAgent ...@@ -58,6 +59,7 @@ struct _NiceAgent
NiceAgentRecvFunc read_func; NiceAgentRecvFunc read_func;
gpointer read_func_data; gpointer read_func_data;
gchar *stun_server; gchar *stun_server;
NiceRNG *rng;
}; };
typedef struct _NiceAgentClass NiceAgentClass; typedef struct _NiceAgentClass NiceAgentClass;
......
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