Commit 15e6e04d authored by Dafydd Harries's avatar Dafydd Harries
Browse files

remove NiceCandidate.port in favour of using NiceCandidate.addr.port

darcs-hash:20070202114458-c9803-41d9f70a5684037cf9ecf6a6774cd76c88a6eb4c.gz
parent 418d8846
......@@ -219,7 +219,8 @@ nice_agent_add_local_host_candidate (
sin.sin_port = 0;
/* XXX: handle error */
nice_udp_socket_factory_make (agent->socket_factory, &(candidate->sock), &sin);
candidate->port = ntohs (candidate->sock.addr.sin_port);
candidate->addr.port = ntohs (candidate->sock.addr.sin_port);
candidate->base_addr.port = ntohs (candidate->sock.addr.sin_port);
}
......@@ -304,7 +305,6 @@ nice_agent_add_remote_candidate (
guint component_id,
NiceCandidateType type,
NiceAddress *addr,
guint port,
gchar *username,
gchar *password)
{
......@@ -318,7 +318,6 @@ nice_agent_add_remote_candidate (
/* do remote candidates need IDs? */
candidate->id = 0;
candidate->addr = *addr;
candidate->port = port;
strncpy (candidate->username, username, sizeof (candidate->username));
strncpy (candidate->password, password, sizeof (candidate->password));
......
......@@ -58,7 +58,6 @@ nice_agent_add_remote_candidate (
guint component_id,
NiceCandidateType type,
NiceAddress *addr,
guint port,
gchar *username,
gchar *password);
......
......@@ -23,7 +23,6 @@ struct _NiceCandidate
guint id;
NiceAddress addr;
NiceAddress base_addr;
guint16 port;
guint32 priority;
guint stream_id;
guint component_id;
......
......@@ -207,17 +207,18 @@ main (void)
nice_address_set_ipv4_from_string (&local_addr, "192.168.0.1");
nice_address_set_ipv4_from_string (&remote_addr, "192.168.0.5");
remote_addr.port = 5678;
from.sin_family = AF_INET;
from.sin_addr.s_addr = htonl (remote_addr.addr_ipv4);
from.sin_port = htons (5678);
from.sin_port = htons (remote_addr.port);
/* set up agent */
agent = nice_agent_new (&factory);
nice_agent_add_local_address (agent, &local_addr);
nice_agent_add_stream (agent, handle_recv, NULL);
nice_agent_add_remote_candidate (agent, 1, 1, NICE_CANDIDATE_TYPE_HOST,
&remote_addr, 5678, "username", "password");
&remote_addr, "username", "password");
g_assert (agent->local_candidates != NULL);
candidate = agent->local_candidates->data;
sock = &(candidate->sock);
......
......@@ -20,14 +20,17 @@ gint
main (void)
{
NiceAgent *agent;
NiceAddress addr_local, addr_remote;
NiceAddress addr_local = {0,}, addr_remote = {0,};
NiceCandidate *candidate;
NiceUDPSocketFactory factory;
nice_udp_fake_socket_factory_init (&factory);
nice_address_set_ipv4_from_string (&addr_local, "192.168.0.1");
/* fake socket manager uses incremental port numbers starting at 1 */
addr_local.port = 1;
nice_address_set_ipv4_from_string (&addr_remote, "192.168.0.2");
addr_remote.port = 2345;
agent = nice_agent_new (&factory);
......@@ -54,17 +57,14 @@ main (void)
candidate = agent->local_candidates->data;
g_assert (nice_address_equal (&(candidate->addr), &addr_local));
g_assert (candidate->id == 1);
/* fake socket manager uses incremental port numbers starting at 1 */
g_assert (candidate->port == 1);
/* add remote candidate */
nice_agent_add_remote_candidate (agent, 1, 1, NICE_CANDIDATE_TYPE_HOST,
&addr_remote, 2345, "username", "password");
&addr_remote, "username", "password");
g_assert (agent->remote_candidates != NULL);
g_assert (g_slist_length (agent->remote_candidates) == 1);
candidate = agent->remote_candidates->data;
g_assert (nice_address_equal (&(candidate->addr), &addr_remote));
g_assert (candidate->port == 2345);
g_assert (candidate->stream_id == 1);
g_assert (candidate->component_id == 1);
g_assert (candidate->type == NICE_CANDIDATE_TYPE_HOST);
......
......@@ -95,7 +95,7 @@ handle_connection (guint sock)
// agent doesn't initiate connectivity checks, so make our own for now
sin.sin_addr.s_addr = htonl (candidate->addr.addr_ipv4);
sin.sin_port = htons (candidate->port);
sin.sin_port = htons (candidate->addr.port);
{
gchar *username;
......
......@@ -72,8 +72,7 @@ handle_tcp_read (guint fileno, NiceAgent *agent)
g_debug ("got remote candidate: %s", line);
nice_agent_add_remote_candidate (agent, 1, 1, candidate->type,
&candidate->addr, candidate->port, candidate->username,
candidate->password);
&candidate->addr, candidate->username, candidate->password);
nice_candidate_free (candidate);
g_free (line);
......
......@@ -15,10 +15,10 @@ main (void)
g_assert (candidate == NULL);
g_assert (nice_address_set_ipv4_from_string (&addr, "192.168.0.1"));
addr.port = 1234;
candidate = nice_candidate_from_string ("H/192.168.0.1/1234/foo/bar");
g_assert (candidate != NULL);
g_assert (nice_address_equal (&addr, &(candidate->addr)));
g_assert (candidate->port == 1234);
g_assert (0 == strcmp (candidate->username, "foo"));
g_assert (0 == strcmp (candidate->password, "bar"));
......
......@@ -53,7 +53,7 @@ nice_candidate_from_string (const gchar *s)
candidate = nice_candidate_new (type);
nice_address_set_ipv4 (&candidate->addr, ntohl (ip));
candidate->port = port;
candidate->addr.port = port;
memcpy (candidate->username, bits[3],
MIN (strlen (bits[3]), sizeof (candidate->username)));
......@@ -94,8 +94,8 @@ nice_candidate_to_string (NiceCandidate *candidate)
}
addr_tmp = nice_address_to_string (&(candidate->addr));
ret = g_strdup_printf ("%c/%s/%d/%s/%s", type, addr_tmp, candidate->port,
candidate->username, candidate->password);
ret = g_strdup_printf ("%c/%s/%d/%s/%s", type, addr_tmp,
candidate->addr.port, candidate->username, candidate->password);
g_free (addr_tmp);
return ret;
}
......
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