Commit 1877b999 authored by Kai Vehmanen's avatar Kai Vehmanen

Updated agent to use the new address API.

darcs-hash:20070830070237-77cd4-19e867ed64911e10f6931efff7d787f8048f2eb1.gz
parent c71d4f24
...@@ -717,7 +717,7 @@ nice_agent_add_local_address (NiceAgent *agent, NiceAddress *addr) ...@@ -717,7 +717,7 @@ nice_agent_add_local_address (NiceAgent *agent, NiceAddress *addr)
GSList *modified_list; GSList *modified_list;
dup = nice_address_dup (addr); dup = nice_address_dup (addr);
dup->port = 0; nice_address_set_port (dup, 0);
modified_list = g_slist_append (agent->local_addresses, dup); modified_list = g_slist_append (agent->local_addresses, dup);
if (modified_list) { if (modified_list) {
agent->local_addresses = modified_list; agent->local_addresses = modified_list;
...@@ -767,8 +767,9 @@ static gboolean priv_add_remote_candidate ( ...@@ -767,8 +767,9 @@ static gboolean priv_add_remote_candidate (
#ifndef NDEBUG #ifndef NDEBUG
{ {
gchar tmpbuf[INET6_ADDRSTRLEN]; gchar tmpbuf[INET6_ADDRSTRLEN];
nice_address_to_string ((NiceAddress *)addr, tmpbuf); nice_address_to_string (addr, tmpbuf);
g_debug ("Adding remote candidate with addr %s:%u.", tmpbuf, addr->port); g_debug ("Adding remote candidate with addr [%s]:%u.", tmpbuf,
nice_address_get_port (addr));
} }
#endif #endif
...@@ -880,7 +881,6 @@ nice_agent_get_local_credentials ( ...@@ -880,7 +881,6 @@ nice_agent_get_local_credentials (
* @component_id: the ID of the component the candidate is for * @component_id: the ID of the component the candidate is for
* @type: the type of the new candidate * @type: the type of the new candidate
* @addr: the new candidate's IP address * @addr: the new candidate's IP address
* @port: the new candidate's port
* @username: the new candidate's username (XXX: candidates don't have usernames) * @username: the new candidate's username (XXX: candidates don't have usernames)
* @password: the new candidate's password (XXX: candidates don't have usernames) * @password: the new candidate's password (XXX: candidates don't have usernames)
* *
...@@ -1279,8 +1279,12 @@ nice_agent_send ( ...@@ -1279,8 +1279,12 @@ nice_agent_send (
NiceAddress *addr; NiceAddress *addr;
#ifndef NDEBUG #ifndef NDEBUG
g_debug ("s%d:%d: sending %d bytes to %08x:%d", stream_id, component_id, gchar tmpbuf[INET6_ADDRSTRLEN];
len, component->selected_pair.remote->addr.addr.addr_ipv4, component->selected_pair.remote->addr.port); nice_address_to_string (&component->selected_pair.remote->addr, tmpbuf);
g_debug ("s%d:%d: sending %d bytes to [%s]:%d", stream_id, component_id,
len, tmpbuf,
nice_address_get_port (&component->selected_pair.remote->addr));
#endif #endif
sock = component->selected_pair.local->sockptr; sock = component->selected_pair.local->sockptr;
......
...@@ -525,7 +525,7 @@ int conn_check_add_for_candidate (NiceAgent *agent, guint stream_id, Component * ...@@ -525,7 +525,7 @@ int conn_check_add_for_candidate (NiceAgent *agent, guint stream_id, Component *
/* note: match pairs only if transport and address family are the same */ /* note: match pairs only if transport and address family are the same */
if (local->transport == remote->transport && if (local->transport == remote->transport &&
local->addr.type == remote->addr.type) { local->addr.s.addr.sa_family == remote->addr.s.addr.sa_family) {
gboolean result; gboolean result;
...@@ -991,7 +991,7 @@ static void priv_reply_to_conn_check (NiceAgent *agent, Stream *stream, Componen ...@@ -991,7 +991,7 @@ static void priv_reply_to_conn_check (NiceAgent *agent, Stream *stream, Componen
nice_address_to_string (&cand->addr, tmpbuf); nice_address_to_string (&cand->addr, tmpbuf);
g_debug ("STUN-CC RESP to '%s:%u', socket=%u, len=%u, cand=%p (c-id:%u), use-cand=%d.", g_debug ("STUN-CC RESP to '%s:%u', socket=%u, len=%u, cand=%p (c-id:%u), use-cand=%d.",
tmpbuf, tmpbuf,
cand->addr.port, nice_address_get_port (&cand->addr),
udp_socket->fileno, udp_socket->fileno,
rbuf_len, rbuf_len,
cand, component->id, cand, component->id,
...@@ -1228,10 +1228,7 @@ static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, gchar *bu ...@@ -1228,10 +1228,7 @@ static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, gchar *bu
if (res == 0) { if (res == 0) {
/* case: succesful binding discovery, create a new local candidate */ /* case: succesful binding discovery, create a new local candidate */
NiceAddress niceaddr; NiceAddress niceaddr;
struct sockaddr_in *mapped = (struct sockaddr_in *)&sockaddr; nice_address_set_from_sockaddr (&niceaddr, &sockaddr);
niceaddr.type = NICE_ADDRESS_TYPE_IPV4;
niceaddr.addr.addr_ipv4 = ntohl(mapped->sin_addr.s_addr);
niceaddr.port = ntohs(mapped->sin_port);
discovery_add_server_reflexive_candidate ( discovery_add_server_reflexive_candidate (
d->agent, d->agent,
......
...@@ -475,18 +475,13 @@ static gboolean priv_discovery_tick (gpointer pointer) ...@@ -475,18 +475,13 @@ static gboolean priv_discovery_tick (gpointer pointer)
if (cand->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE && if (cand->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE &&
cand->server_addr) { cand->server_addr) {
NiceAddress stun_server;
struct sockaddr_in stun_server;
int res; int res;
memset (&stun_server, 0, sizeof(stun_server)); /* XXX FIXME TODO: handle error here?! Kai, help me! */
if (!nice_address_set_from_string (&stun_server, cand->server_addr))
if (strchr (cand->server_addr, ':') == NULL) g_assert_not_reached();
stun_server.sin_family = AF_INET; nice_address_set_port (&stun_server, cand->server_port);
else
stun_server.sin_family = AF_INET6;
stun_server.sin_addr.s_addr = inet_addr(cand->server_addr);
stun_server.sin_port = htons(cand->server_port);
agent_signal_component_state_change (agent, agent_signal_component_state_change (agent,
cand->stream->id, cand->stream->id,
...@@ -494,8 +489,7 @@ static gboolean priv_discovery_tick (gpointer pointer) ...@@ -494,8 +489,7 @@ static gboolean priv_discovery_tick (gpointer pointer)
NICE_COMPONENT_STATE_GATHERING); NICE_COMPONENT_STATE_GATHERING);
res = stun_bind_start (&cand->stun_ctx, cand->socket, res = stun_bind_start (&cand->stun_ctx, cand->socket,
(struct sockaddr*)&stun_server, sizeof(stun_server)); &stun_server.s.addr, sizeof(stun_server.s));
if (res == 0) { if (res == 0) {
/* case: success, start waiting for the result */ /* case: success, start waiting for the result */
g_get_current_time (&cand->next_tick); g_get_current_time (&cand->next_tick);
......
...@@ -56,7 +56,7 @@ main (void) ...@@ -56,7 +56,7 @@ main (void)
nice_udp_fake_socket_factory_init (&factory); nice_udp_fake_socket_factory_init (&factory);
if (!nice_address_set_ipv4_from_string (&addr, "127.0.0.1")) if (!nice_address_set_from_string (&addr, "127.0.0.1"))
g_assert_not_reached (); g_assert_not_reached ();
agent = nice_agent_new (&factory); agent = nice_agent_new (&factory);
......
...@@ -477,7 +477,8 @@ static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent, ...@@ -477,7 +477,8 @@ static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent,
for (i = cands; i; i = i->next) { for (i = cands; i; i = i->next) {
NiceCandidate *cand = i->data; NiceCandidate *cand = i->data;
if (cand) { if (cand) {
g_debug ("test-fullmode: local port R %u", cand->addr.port); g_debug ("test-fullmode: local port R %u",
nice_address_get_port (&cand->addr));
raddr = cand->addr; raddr = cand->addr;
} }
} }
...@@ -552,7 +553,7 @@ int main (void) ...@@ -552,7 +553,7 @@ int main (void)
timer_id = g_timeout_add (30000, timer_cb, NULL); timer_id = g_timeout_add (30000, timer_cb, NULL);
/* step: specify which local interface to use */ /* step: specify which local interface to use */
if (!nice_address_set_ipv4_from_string (&baseaddr, "127.0.0.1")) if (!nice_address_set_from_string (&baseaddr, "127.0.0.1"))
g_assert_not_reached (); g_assert_not_reached ();
nice_agent_add_local_address (lagent, &baseaddr); nice_agent_add_local_address (lagent, &baseaddr);
nice_agent_add_local_address (ragent, &baseaddr); nice_agent_add_local_address (ragent, &baseaddr);
......
...@@ -83,7 +83,7 @@ main (void) ...@@ -83,7 +83,7 @@ main (void)
/* set up agent */ /* set up agent */
if (!nice_address_set_ipv4_from_string (&addr, "127.0.0.1")) if (!nice_address_set_from_string (&addr, "127.0.0.1"))
g_assert_not_reached (); g_assert_not_reached ();
nice_udp_fake_socket_factory_init (&factory); nice_udp_fake_socket_factory_init (&factory);
......
...@@ -58,7 +58,7 @@ main (void) ...@@ -58,7 +58,7 @@ main (void)
/* set up agent */ /* set up agent */
agent = nice_agent_new (&factory); agent = nice_agent_new (&factory);
g_assert (nice_address_set_ipv4_from_string (&addr, "192.168.0.1")); g_assert (nice_address_set_from_string (&addr, "192.168.0.1"));
nice_agent_add_local_address (agent, &addr); nice_agent_add_local_address (agent, &addr);
nice_agent_add_stream (agent, 1); nice_agent_add_stream (agent, 1);
......
...@@ -246,16 +246,20 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress * ...@@ -246,16 +246,20 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
/* step: find out the local candidates of each agent */ /* step: find out the local candidates of each agent */
priv_get_local_addr (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, &raddr); priv_get_local_addr (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, &raddr);
g_debug ("test-restart: local RTP port R %u", raddr.port); g_debug ("test-restart: local RTP port R %u",
nice_address_get_port (&raddr));
priv_get_local_addr (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, &laddr); priv_get_local_addr (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, &laddr);
g_debug ("test-restart: local RTP port L %u", laddr.port); g_debug ("test-restart: local RTP port L %u",
nice_address_get_port (&laddr));
priv_get_local_addr (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, &raddr_rtcp); priv_get_local_addr (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, &raddr_rtcp);
g_debug ("test-restart: local RTCP port R %u", raddr_rtcp.port); g_debug ("test-restart: local RTCP port R %u",
nice_address_get_port (&raddr_rtcp));
priv_get_local_addr (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, &laddr_rtcp); priv_get_local_addr (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, &laddr_rtcp);
g_debug ("test-restart: local RTCP port L %u", laddr_rtcp.port); g_debug ("test-restart: local RTCP port L %u",
nice_address_get_port (&laddr_rtcp));
/* step: pass the remote candidates to agents */ /* step: pass the remote candidates to agents */
cands = g_slist_append (NULL, &cdes); cands = g_slist_append (NULL, &cdes);
...@@ -392,7 +396,7 @@ int main (void) ...@@ -392,7 +396,7 @@ int main (void)
timer_id = g_timeout_add (30000, timer_cb, NULL); timer_id = g_timeout_add (30000, timer_cb, NULL);
/* step: specify which local interface to use */ /* step: specify which local interface to use */
if (!nice_address_set_ipv4_from_string (&baseaddr, "127.0.0.1")) if (!nice_address_set_from_string (&baseaddr, "127.0.0.1"))
g_assert_not_reached (); g_assert_not_reached ();
nice_agent_add_local_address (lagent, &baseaddr); nice_agent_add_local_address (lagent, &baseaddr);
nice_agent_add_local_address (ragent, &baseaddr); nice_agent_add_local_address (ragent, &baseaddr);
......
...@@ -59,9 +59,9 @@ main (void) ...@@ -59,9 +59,9 @@ main (void)
nice_udp_fake_socket_factory_init (&factory); nice_udp_fake_socket_factory_init (&factory);
g_assert (nice_address_set_ipv4_from_string (&addr_local, "192.168.0.1")); g_assert (nice_address_set_from_string (&addr_local, "192.168.0.1"));
g_assert (nice_address_set_ipv4_from_string (&addr_remote, "192.168.0.2")); g_assert (nice_address_set_from_string (&addr_remote, "192.168.0.2"));
addr_remote.port = 2345; nice_address_set_port (&addr_remote, 2345);
agent = nice_agent_new (&factory); agent = nice_agent_new (&factory);
...@@ -82,7 +82,7 @@ main (void) ...@@ -82,7 +82,7 @@ main (void)
g_assert (g_slist_length (candidates) == 1); g_assert (g_slist_length (candidates) == 1);
candidate = candidates->data; candidate = candidates->data;
/* fake socket manager uses incremental port numbers starting at 1 */ /* fake socket manager uses incremental port numbers starting at 1 */
addr_local.port = 1; nice_address_set_port (&addr_local, 1);
g_assert (nice_address_equal (&(candidate->addr), &addr_local)); g_assert (nice_address_equal (&(candidate->addr), &addr_local));
g_assert (strncmp (candidate->foundation, "1", 1) == 0); g_assert (strncmp (candidate->foundation, "1", 1) == 0);
g_slist_free (candidates); g_slist_free (candidates);
......
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