Commit a6954838 authored by Youness Alaoui's avatar Youness Alaoui Committed by Olivier Crête

Add support for ICE-TCP

This is a massive commit that can't be split. We add ice-tcp support
into the agent by creating local host tcp-active/tcp-passive candidates.
We also need to find the local and remote candidates whenever we discover
a peer-reflexive because their data is important to setup the peer-reflexive
so a few changes were added to look for the local or remote candidate.
For TCP-ACTIVE remote peer-reflexive candidates, we can't add conncheck
pairs normally because TCP-PASSIVE (local) do not generate candidate pairs,
and we also can't have a connection from any local host, so we can only create
a single candidatepair with the local/remote that are connected.
The pair->socket of a candidate check pair will hold the connected tcp socket
(through connect for ACT or accept for PASS) and we will either have a
remote or a local peer-reflexive which will create a new candidate pair,
we cannot trigger checks on the initial candidate pair, we must only do it
on the new check pairs. but in the case of a tcp-passive, we don't get a new
local peer-reflexive candidate, so there is no new candidate with a new NiceSocket, so
when we get a triggered check, we need to match it to the candidate check pair
or when we select a pair, it will still use the original TCP-PASS socket.
We must store the new connected tcp socket in the peer reflexive candidates
since they represent that unique peer-reflx candidate's connection
parent 53b3e445
...@@ -133,6 +133,7 @@ tests/test-build-io-stream ...@@ -133,6 +133,7 @@ tests/test-build-io-stream
tests/test-dribble tests/test-dribble
tests/test-fallback tests/test-fallback
tests/test-fullmode tests/test-fullmode
tests/test-icetcp
tests/test-io-stream-cancelling tests/test-io-stream-cancelling
tests/test-io-stream-closing-read tests/test-io-stream-closing-read
tests/test-io-stream-closing-write tests/test-io-stream-closing-write
......
...@@ -161,6 +161,8 @@ struct _NiceAgent ...@@ -161,6 +161,8 @@ struct _NiceAgent
GQueue pending_signals; GQueue pending_signals;
guint16 rfc4571_expecting_length; guint16 rfc4571_expecting_length;
gboolean use_ice_udp;
gboolean use_ice_tcp;
/* XXX: add pointer to internal data struct for ABI-safe extensions */ /* XXX: add pointer to internal data struct for ABI-safe extensions */
}; };
......
...@@ -106,7 +106,9 @@ enum ...@@ -106,7 +106,9 @@ enum
PROP_PROXY_PASSWORD, PROP_PROXY_PASSWORD,
PROP_UPNP, PROP_UPNP,
PROP_UPNP_TIMEOUT, PROP_UPNP_TIMEOUT,
PROP_RELIABLE PROP_RELIABLE,
PROP_ICE_UDP,
PROP_ICE_TCP,
}; };
...@@ -582,6 +584,20 @@ nice_agent_class_init (NiceAgentClass *klass) ...@@ -582,6 +584,20 @@ nice_agent_class_init (NiceAgentClass *klass)
FALSE, FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (gobject_class, PROP_ICE_UDP,
g_param_spec_boolean (
"ice-udp",
"Use ICE-UDP",
"Use ICE-UDP specification to generate UDP candidates",
TRUE, /* use ice-udp by default */
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_ICE_TCP,
g_param_spec_boolean (
"ice-tcp",
"Use ICE-TCP",
"Use ICE-TCP specification to generate TCP candidates",
TRUE, /* use ice-tcp by default */
G_PARAM_READWRITE));
/* install signals */ /* install signals */
/** /**
...@@ -807,6 +823,8 @@ nice_agent_init (NiceAgent *agent) ...@@ -807,6 +823,8 @@ nice_agent_init (NiceAgent *agent)
agent->compatibility = NICE_COMPATIBILITY_RFC5245; agent->compatibility = NICE_COMPATIBILITY_RFC5245;
agent->reliable = FALSE; agent->reliable = FALSE;
agent->use_ice_udp = TRUE;
agent->use_ice_tcp = TRUE;
stun_agent_init (&agent->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES, stun_agent_init (&agent->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
STUN_COMPATIBILITY_RFC5389, STUN_COMPATIBILITY_RFC5389,
...@@ -932,6 +950,14 @@ nice_agent_get_property ( ...@@ -932,6 +950,14 @@ nice_agent_get_property (
g_value_set_boolean (value, agent->reliable); g_value_set_boolean (value, agent->reliable);
break; break;
case PROP_ICE_UDP:
g_value_set_boolean (value, agent->use_ice_udp);
break;
case PROP_ICE_TCP:
g_value_set_boolean (value, agent->use_ice_tcp);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
} }
...@@ -1062,6 +1088,17 @@ nice_agent_set_property ( ...@@ -1062,6 +1088,17 @@ nice_agent_set_property (
agent->reliable = g_value_get_boolean (value); agent->reliable = g_value_get_boolean (value);
break; break;
/* Don't allow ice-udp and ice-tcp to be disabled at the same time */
case PROP_ICE_UDP:
if (agent->use_ice_tcp == TRUE || g_value_get_boolean (value) == TRUE)
agent->use_ice_udp = g_value_get_boolean (value);
break;
case PROP_ICE_TCP:
if (agent->use_ice_udp == TRUE || g_value_get_boolean (value) == TRUE)
agent->use_ice_tcp = g_value_get_boolean (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
} }
...@@ -1821,6 +1858,10 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent, ...@@ -1821,6 +1858,10 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent,
cdisco->type = NICE_CANDIDATE_TYPE_RELAYED; cdisco->type = NICE_CANDIDATE_TYPE_RELAYED;
if (turn->type == NICE_RELAY_TYPE_TURN_UDP) { if (turn->type == NICE_RELAY_TYPE_TURN_UDP) {
if (agent->use_ice_udp == FALSE) {
g_slice_free (CandidateDiscovery, cdisco);
return;
}
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) { if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
NiceAddress addr = nicesock->addr; NiceAddress addr = nicesock->addr;
NiceSocket *new_socket; NiceSocket *new_socket;
...@@ -1850,7 +1891,15 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent, ...@@ -1850,7 +1891,15 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent,
agent->compatibility == NICE_COMPATIBILITY_OC2007R2) agent->compatibility == NICE_COMPATIBILITY_OC2007R2)
reliable_tcp = TRUE; reliable_tcp = TRUE;
/* Ignore tcp candidates if we disabled ice-tcp */
if ((agent->use_ice_udp == FALSE && reliable_tcp == FALSE) ||
(agent->use_ice_tcp == FALSE && reliable_tcp == TRUE)) {
g_slice_free (CandidateDiscovery, cdisco);
return;
}
nicesock = NULL; nicesock = NULL;
/* TODO: add support for turn-tcp RFC 6062 */
if (agent->proxy_type != NICE_PROXY_TYPE_NONE && if (agent->proxy_type != NICE_PROXY_TYPE_NONE &&
agent->proxy_ip != NULL && agent->proxy_ip != NULL &&
nice_address_set_from_string (&proxy_server, agent->proxy_ip)) { nice_address_set_from_string (&proxy_server, agent->proxy_ip)) {
...@@ -2273,12 +2322,39 @@ nice_agent_gather_candidates ( ...@@ -2273,12 +2322,39 @@ nice_agent_gather_candidates (
for (cid = 1; cid <= stream->n_components; cid++) { for (cid = 1; cid <= stream->n_components; cid++) {
Component *component = stream_find_component_by_id (stream, cid); Component *component = stream_find_component_by_id (stream, cid);
enum {
ADD_HOST_MIN = 0,
ADD_HOST_UDP = ADD_HOST_MIN,
ADD_HOST_TCP_ACTIVE,
ADD_HOST_TCP_PASSIVE,
ADD_HOST_MAX = ADD_HOST_TCP_PASSIVE
} add_type;
if (component == NULL)
continue;
for (add_type = ADD_HOST_MIN; add_type <= ADD_HOST_MAX; add_type++) {
NiceCandidateTransport transport;
guint current_port; guint current_port;
guint start_port; guint start_port;
if (component == NULL) if ((agent->use_ice_udp == FALSE && add_type == ADD_HOST_UDP) ||
(agent->use_ice_tcp == FALSE && add_type != ADD_HOST_UDP))
continue; continue;
switch (add_type) {
default:
case ADD_HOST_UDP:
transport = NICE_CANDIDATE_TRANSPORT_UDP;
break;
case ADD_HOST_TCP_ACTIVE:
transport = NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE;
break;
case ADD_HOST_TCP_PASSIVE:
transport = NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE;
break;
}
start_port = component->min_port; start_port = component->min_port;
if(component->min_port != 0) { if(component->min_port != 0) {
start_port = nice_rng_generate_int(agent->rng, component->min_port, component->max_port+1); start_port = nice_rng_generate_int(agent->rng, component->min_port, component->max_port+1);
...@@ -2290,7 +2366,7 @@ nice_agent_gather_candidates ( ...@@ -2290,7 +2366,7 @@ nice_agent_gather_candidates (
nice_debug ("Agent %p: Trying to create host candidate on port %d", agent, current_port); nice_debug ("Agent %p: Trying to create host candidate on port %d", agent, current_port);
nice_address_set_port (addr, current_port); nice_address_set_port (addr, current_port);
host_candidate = discovery_add_local_host_candidate (agent, stream->id, host_candidate = discovery_add_local_host_candidate (agent, stream->id,
cid, addr, NICE_CANDIDATE_TRANSPORT_UDP); cid, addr, transport);
if (current_port > 0) if (current_port > 0)
current_port++; current_port++;
if (current_port > component->max_port) current_port = component->min_port; if (current_port > component->max_port) current_port = component->min_port;
...@@ -2316,15 +2392,17 @@ nice_agent_gather_candidates ( ...@@ -2316,15 +2392,17 @@ nice_agent_gather_candidates (
NiceAddress *base_addr = nice_address_dup (&host_candidate->base_addr); NiceAddress *base_addr = nice_address_dup (&host_candidate->base_addr);
nice_debug ("Agent %p: Adding UPnP port %s:%d", agent, local_ip, nice_debug ("Agent %p: Adding UPnP port %s:%d", agent, local_ip,
nice_address_get_port (base_addr)); nice_address_get_port (base_addr));
gupnp_simple_igd_add_port (GUPNP_SIMPLE_IGD (agent->upnp), "UDP", gupnp_simple_igd_add_port (GUPNP_SIMPLE_IGD (agent->upnp),
transport == NICE_CANDIDATE_TRANSPORT_UDP ? "UDP" : "TCP",
0, local_ip, nice_address_get_port (base_addr), 0, local_ip, nice_address_get_port (base_addr),
0, PACKAGE_STRING); 0, PACKAGE_STRING);
agent->upnp_mapping = g_slist_prepend (agent->upnp_mapping, base_addr); agent->upnp_mapping = g_slist_prepend (agent->upnp_mapping, base_addr);
} }
#endif #endif
if (agent->full_mode && /* TODO: Add server-reflexive support for TCP candidates */
agent->stun_server_ip) { if (agent->full_mode && agent->stun_server_ip &&
transport == NICE_CANDIDATE_TRANSPORT_UDP) {
NiceAddress stun_server; NiceAddress stun_server;
if (nice_address_set_from_string (&stun_server, agent->stun_server_ip)) { if (nice_address_set_from_string (&stun_server, agent->stun_server_ip)) {
nice_address_set_port (&stun_server, agent->stun_server_port); nice_address_set_port (&stun_server, agent->stun_server_port);
...@@ -2352,6 +2430,7 @@ nice_agent_gather_candidates ( ...@@ -2352,6 +2430,7 @@ nice_agent_gather_candidates (
} }
} }
} }
}
stream->gathering = TRUE; stream->gathering = TRUE;
stream->gathering_started = TRUE; stream->gathering_started = TRUE;
...@@ -2826,6 +2905,19 @@ agent_recv_message_unlocked ( ...@@ -2826,6 +2905,19 @@ agent_recv_message_unlocked (
message->length = ntohs (rfc4571_frame); message->length = ntohs (rfc4571_frame);
} }
g_free (local_bufs); g_free (local_bufs);
} else {
if (nicesock->type == NICE_SOCKET_TYPE_TCP_PASSIVE) {
NiceSocket *new_socket;
/* Passive candidates when readable should accept and create a new
* socket. When established, the connchecks will create a peer reflexive
* candidate for it */
new_socket = nice_tcp_passive_socket_accept (nicesock);
if (new_socket) {
_priv_set_socket_tos (agent, new_socket, stream->tos);
component_attach_socket (component, new_socket);
}
retval = 0;
} else { } else {
/* In the case of a real ICE-TCP connection, we can use the socket as a /* In the case of a real ICE-TCP connection, we can use the socket as a
* bytestream and do the read here with caching of data being read * bytestream and do the read here with caching of data being read
...@@ -2899,6 +2991,7 @@ agent_recv_message_unlocked ( ...@@ -2899,6 +2991,7 @@ agent_recv_message_unlocked (
retval = 0; retval = 0;
} }
} }
}
} else { } else {
retval = nice_socket_recv_messages (nicesock, message, 1); retval = nice_socket_recv_messages (nicesock, message, 1);
} }
......
...@@ -1040,6 +1040,14 @@ void conn_check_remote_candidates_set(NiceAgent *agent) ...@@ -1040,6 +1040,14 @@ void conn_check_remote_candidates_set(NiceAgent *agent)
} }
} }
} }
} else {
for (l = component->local_candidates; l; l = l->next) {
NiceCandidate *cand = l->data;
if (nice_address_equal (&cand->addr, &icheck->local_socket->addr)) {
local_candidate = cand;
break;
}
}
} }
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE && if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE &&
...@@ -1062,6 +1070,11 @@ void conn_check_remote_candidates_set(NiceAgent *agent) ...@@ -1062,6 +1070,11 @@ void conn_check_remote_candidates_set(NiceAgent *agent)
icheck->local_socket, icheck->local_socket,
local_candidate, remote_candidate); local_candidate, remote_candidate);
if (candidate) { if (candidate) {
if (local_candidate &&
local_candidate->transport == NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE)
priv_conn_check_add_for_candidate_pair_matched (agent,
stream->id, component, local_candidate, candidate);
else
conn_check_add_for_candidate (agent, stream->id, component, candidate); conn_check_add_for_candidate (agent, stream->id, component, candidate);
if (icheck->use_candidate) if (icheck->use_candidate)
...@@ -1300,6 +1313,9 @@ static void priv_add_new_check_pair (NiceAgent *agent, guint stream_id, Componen ...@@ -1300,6 +1313,9 @@ static void priv_add_new_check_pair (NiceAgent *agent, guint stream_id, Componen
pair->component_id = component->id;; pair->component_id = component->id;;
pair->local = local; pair->local = local;
pair->remote = remote; pair->remote = remote;
if (remote->type == NICE_CANDIDATE_TYPE_PEER_REFLEXIVE)
pair->sockptr = (NiceSocket *) remote->sockptr;
else
pair->sockptr = (NiceSocket *) local->sockptr; pair->sockptr = (NiceSocket *) local->sockptr;
g_snprintf (pair->foundation, NICE_CANDIDATE_PAIR_MAX_FOUNDATION, "%s:%s", local->foundation, remote->foundation); g_snprintf (pair->foundation, NICE_CANDIDATE_PAIR_MAX_FOUNDATION, "%s:%s", local->foundation, remote->foundation);
...@@ -1787,6 +1803,26 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair) ...@@ -1787,6 +1803,26 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS); STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS);
} }
/* TCP-ACTIVE candidate must create a new socket before sending
* by connecting to the peer. The new socket is stored in the candidate
* check pair, until we discover a new local peer reflexive */
if (pair->sockptr->fileno == NULL &&
pair->local->transport == NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE) {
Stream *stream = NULL;
Component *component = NULL;
NiceSocket *new_socket;
if (agent_find_component (agent, pair->stream_id, pair->component_id,
&stream, &component)) {
new_socket = nice_tcp_active_socket_connect (pair->sockptr,
&pair->remote->addr);
if (new_socket) {
pair->sockptr = new_socket;
_priv_set_socket_tos (agent, pair->sockptr, stream->tos);
component_attach_socket (component, new_socket);
}
}
}
/* send the conncheck */ /* send the conncheck */
agent_socket_send (pair->sockptr, &pair->remote->addr, agent_socket_send (pair->sockptr, &pair->remote->addr,
buffer_len, (gchar *)pair->stun_buffer); buffer_len, (gchar *)pair->stun_buffer);
...@@ -1893,7 +1929,13 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, Stream *stream, ...@@ -1893,7 +1929,13 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, Stream *stream,
CandidateCheckPair *p = i->data; CandidateCheckPair *p = i->data;
if (p->component_id == component->id && if (p->component_id == component->id &&
p->remote == remote_cand && p->remote == remote_cand &&
p->sockptr == local_socket) { ((p->local->transport == NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE &&
p->sockptr == local_socket) ||
(p->local->transport != NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE &&
p->local->sockptr == local_socket))) {
/* We don't check for p->sockptr because in the case of
* tcp-active we don't want to retrigger a check on a pair that
* was FAILED when a peer-reflexive pair was created */
nice_debug ("Agent %p : Found a matching pair %p for triggered check.", agent, p); nice_debug ("Agent %p : Found a matching pair %p for triggered check.", agent, p);
...@@ -2133,7 +2175,7 @@ static CandidateCheckPair *priv_process_response_check_for_peer_reflexive(NiceAg ...@@ -2133,7 +2175,7 @@ static CandidateCheckPair *priv_process_response_check_for_peer_reflexive(NiceAg
{ {
CandidateCheckPair *new_pair = NULL; CandidateCheckPair *new_pair = NULL;
NiceAddress mapped; NiceAddress mapped;
GSList *j; GSList *i, *j;
gboolean local_cand_matches = FALSE; gboolean local_cand_matches = FALSE;
nice_address_set_from_sockaddr (&mapped, mapped_sockaddr); nice_address_set_from_sockaddr (&mapped, mapped_sockaddr);
...@@ -2142,6 +2184,18 @@ static CandidateCheckPair *priv_process_response_check_for_peer_reflexive(NiceAg ...@@ -2142,6 +2184,18 @@ static CandidateCheckPair *priv_process_response_check_for_peer_reflexive(NiceAg
NiceCandidate *cand = j->data; NiceCandidate *cand = j->data;
if (nice_address_equal (&mapped, &cand->addr)) { if (nice_address_equal (&mapped, &cand->addr)) {
local_cand_matches = TRUE; local_cand_matches = TRUE;
/* We always need to select the peer-reflexive Candidate Pair in the case
* of a TCP-ACTIVE local candidate, so we find it even if an incoming
* check matched an existing pair because it could be the original
* ACTIVE-PASSIVE candidate pair which was retriggered */
for (i = stream->conncheck_list; i; i = i->next) {
CandidateCheckPair *pair = i->data;
if (pair->local == cand && remote_candidate == pair->remote) {
new_pair = pair;
break;
}
}
break; break;
} }
} }
...@@ -2988,7 +3042,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream, ...@@ -2988,7 +3042,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
} }
for (i = component->local_candidates; i; i = i->next) { for (i = component->local_candidates; i; i = i->next) {
NiceCandidate *cand = i->data; NiceCandidate *cand = i->data;
if (cand->sockptr == nicesock) { if (nice_address_equal (&nicesock->addr, &cand->addr)) {
local_candidate = cand; local_candidate = cand;
break; break;
} }
...@@ -3123,9 +3177,15 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream, ...@@ -3123,9 +3177,15 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
agent, stream, component, priority, from, nicesock, agent, stream, component, priority, from, nicesock,
local_candidate, local_candidate,
remote_candidate2 ? remote_candidate2 : remote_candidate); remote_candidate2 ? remote_candidate2 : remote_candidate);
if(remote_candidate) if(remote_candidate) {
if (local_candidate &&
local_candidate->transport == NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE)
priv_conn_check_add_for_candidate_pair_matched (agent,
stream->id, component, local_candidate, remote_candidate);
else
conn_check_add_for_candidate (agent, stream->id, component, remote_candidate); conn_check_add_for_candidate (agent, stream->id, component, remote_candidate);
} }
}
priv_reply_to_conn_check (agent, stream, component, remote_candidate, priv_reply_to_conn_check (agent, stream, component, remote_candidate,
from, nicesock, rbuf_len, rbuf, use_candidate); from, nicesock, rbuf_len, rbuf, use_candidate);
......
...@@ -500,8 +500,12 @@ NiceCandidate *discovery_add_local_host_candidate ( ...@@ -500,8 +500,12 @@ NiceCandidate *discovery_add_local_host_candidate (
level ufrag/password are used */ level ufrag/password are used */
if (transport == NICE_CANDIDATE_TRANSPORT_UDP) { if (transport == NICE_CANDIDATE_TRANSPORT_UDP) {
nicesock = nice_udp_bsd_socket_new (address); nicesock = nice_udp_bsd_socket_new (address);
} else if (transport == NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE) {
nicesock = nice_tcp_active_socket_new (agent->main_context, address);
} else if (transport == NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE) {
nicesock = nice_tcp_passive_socket_new (agent->main_context, address);
} else { } else {
/* TODO: Add ICE-TCP */ /* TODO: Add TCP-SO */
} }
if (!nicesock) if (!nicesock)
goto errors; goto errors;
...@@ -693,10 +697,21 @@ discovery_add_peer_reflexive_candidate ( ...@@ -693,10 +697,21 @@ discovery_add_peer_reflexive_candidate (
return NULL; return NULL;
candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_PEER_REFLEXIVE); candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_PEER_REFLEXIVE);
if (local)
candidate->transport = local->transport; candidate->transport = local->transport;
else if (remote)
candidate->transport = conn_check_match_transport (remote->transport);
else {
if (base_socket->type == NICE_SOCKET_TYPE_UDP_BSD ||
base_socket->type == NICE_SOCKET_TYPE_UDP_TURN)
candidate->transport = NICE_CANDIDATE_TRANSPORT_UDP;
else
candidate->transport = NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE;
}
candidate->stream_id = stream_id; candidate->stream_id = stream_id;
candidate->component_id = component_id; candidate->component_id = component_id;
candidate->addr = *address; candidate->addr = *address;
candidate->sockptr = base_socket;
candidate->base_addr = base_socket->addr; candidate->base_addr = base_socket->addr;
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) { if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
...@@ -746,10 +761,6 @@ discovery_add_peer_reflexive_candidate ( ...@@ -746,10 +761,6 @@ discovery_add_peer_reflexive_candidate (
candidate->password = g_strdup(local->password); candidate->password = g_strdup(local->password);
} }
/* step: link to the base candidate+socket */
candidate->sockptr = base_socket;
candidate->base_addr = base_socket->addr;
result = priv_add_local_candidate_pruned (agent, stream_id, component, candidate); result = priv_add_local_candidate_pruned (agent, stream_id, component, candidate);
if (result != TRUE) { if (result != TRUE) {
/* error: memory allocation, or duplicate candidate */ /* error: memory allocation, or duplicate candidate */
...@@ -796,6 +807,7 @@ NiceCandidate *discovery_learn_remote_peer_reflexive_candidate ( ...@@ -796,6 +807,7 @@ NiceCandidate *discovery_learn_remote_peer_reflexive_candidate (
else else
candidate->transport = NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE; candidate->transport = NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE;
} }
candidate->sockptr = nicesock;
candidate->stream_id = stream->id; candidate->stream_id = stream->id;
candidate->component_id = component->id; candidate->component_id = component->id;
...@@ -849,7 +861,6 @@ NiceCandidate *discovery_learn_remote_peer_reflexive_candidate ( ...@@ -849,7 +861,6 @@ NiceCandidate *discovery_learn_remote_peer_reflexive_candidate (
candidate->password = g_strdup(remote->password); candidate->password = g_strdup(remote->password);
} }
candidate->sockptr = NULL; /* not stored for remote candidates */
/* note: candidate username and password are left NULL as stream /* note: candidate username and password are left NULL as stream
level ufrag/password are used */ level ufrag/password are used */
......
...@@ -42,7 +42,8 @@ check_PROGRAMS = \ ...@@ -42,7 +42,8 @@ check_PROGRAMS = \
test-thread \ test-thread \
test-dribble \ test-dribble \
test-new-dribble \ test-new-dribble \
test-tcp test-tcp \
test-icetcp
dist_check_SCRIPTS = \ dist_check_SCRIPTS = \
check-test-fullmode-with-stun.sh \ check-test-fullmode-with-stun.sh \
...@@ -102,6 +103,8 @@ test_new_dribble_LDADD = $(COMMON_LDADD) ...@@ -102,6 +103,8 @@ test_new_dribble_LDADD = $(COMMON_LDADD)
test_tcp_LDADD = $(COMMON_LDADD) test_tcp_LDADD = $(COMMON_LDADD)
test_icetcp_LDADD = $(COMMON_LDADD)
all-local: all-local:
chmod a+x $(srcdir)/check-test-fullmode-with-stun.sh chmod a+x $(srcdir)/check-test-fullmode-with-stun.sh
chmod a+x $(srcdir)/test-pseudotcp-random.sh chmod a+x $(srcdir)/test-pseudotcp-random.sh
...@@ -857,6 +857,10 @@ int main (void) ...@@ -857,6 +857,10 @@ int main (void)
NICE_COMPATIBILITY); NICE_COMPATIBILITY);
#endif #endif
g_object_set (G_OBJECT (lagent), "ice-tcp", FALSE, NULL);
g_object_set (G_OBJECT (ragent), "ice-tcp", FALSE, NULL);
nice_agent_set_software (lagent, "Test-fullmode, Left Agent"); nice_agent_set_software (lagent, "Test-fullmode, Left Agent");
nice_agent_set_software (ragent, "Test-fullmode, Right Agent"); nice_agent_set_software (ragent, "Test-fullmode, Right Agent");
......
This diff is collapsed.
...@@ -744,6 +744,9 @@ int main(void) ...@@ -744,6 +744,9 @@ int main(void)
lagent = nice_agent_new (NULL, NICE_COMPATIBILITY_RFC5245); lagent = nice_agent_new (NULL, NICE_COMPATIBILITY_RFC5245);
ragent = nice_agent_new (NULL, NICE_COMPATIBILITY_RFC5245); ragent = nice_agent_new (NULL, NICE_COMPATIBILITY_RFC5245);
g_object_set (G_OBJECT (lagent), "ice-tcp", FALSE, NULL);
g_object_set (G_OBJECT (ragent), "ice-tcp", FALSE, NULL);
g_object_set (G_OBJECT (lagent), "controlling-mode", TRUE, NULL); g_object_set (G_OBJECT (lagent), "controlling-mode", TRUE, NULL);
g_object_set (G_OBJECT (ragent), "controlling-mode", FALSE, NULL); g_object_set (G_OBJECT (ragent), "controlling-mode", FALSE, NULL);
......
...@@ -414,6 +414,8 @@ int main (void) ...@@ -414,6 +414,8 @@ int main (void)
/* step: create the agents L and R */ /* step: create the agents L and R */
lagent = nice_agent_new (g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY_RFC5245); lagent = nice_agent_new (g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY_RFC5245);
ragent = nice_agent_new (g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY_RFC5245); ragent = nice_agent_new (g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY_RFC5245);
g_object_set (G_OBJECT (lagent), "ice-tcp", FALSE, NULL);
g_object_set (G_OBJECT (ragent), "ice-tcp", FALSE, NULL);
/* step: add a timer to catch state changes triggered by signals */ /* step: add a timer to catch state changes triggered by signals */
......
...@@ -69,6 +69,7 @@ main (void) ...@@ -69,6 +69,7 @@ main (void)
nice_address_set_port (&addr_remote, 2345); nice_address_set_port (&addr_remote, 2345);
agent = nice_agent_new ( NULL, NICE_COMPATIBILITY_RFC5245); agent = nice_agent_new ( NULL, NICE_COMPATIBILITY_RFC5245);
g_object_set (G_OBJECT (agent), "ice-tcp", FALSE, NULL);
g_assert (agent->local_addresses == NULL); g_assert (agent->local_addresses == NULL);
......
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