diff options
author | Youness Alaoui <youness.alaoui@collabora.co.uk> | 2014-04-16 18:51:54 -0400 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2014-05-17 00:22:36 -0400 |
commit | a6954838932761e5fb802139f61bc17f4e068e85 (patch) | |
tree | 9c012060873db3ba1fab3d88a66a40fb8349de15 /agent/discovery.c | |
parent | 53b3e4457efad8a954883686dbcde367780afbed (diff) | |
download | libnice-a6954838932761e5fb802139f61bc17f4e068e85.tar.gz |
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
Diffstat (limited to 'agent/discovery.c')
-rw-r--r-- | agent/discovery.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/agent/discovery.c b/agent/discovery.c index e39c2f9..42666d7 100644 --- a/agent/discovery.c +++ b/agent/discovery.c @@ -500,8 +500,12 @@ NiceCandidate *discovery_add_local_host_candidate ( level ufrag/password are used */ if (transport == NICE_CANDIDATE_TRANSPORT_UDP) { 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 { - /* TODO: Add ICE-TCP */ + /* TODO: Add TCP-SO */ } if (!nicesock) goto errors; @@ -693,10 +697,21 @@ discovery_add_peer_reflexive_candidate ( return NULL; candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_PEER_REFLEXIVE); - candidate->transport = local->transport; + if (local) + 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->component_id = component_id; candidate->addr = *address; + candidate->sockptr = base_socket; candidate->base_addr = base_socket->addr; if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) { @@ -746,10 +761,6 @@ discovery_add_peer_reflexive_candidate ( 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); if (result != TRUE) { /* error: memory allocation, or duplicate candidate */ @@ -796,6 +807,7 @@ NiceCandidate *discovery_learn_remote_peer_reflexive_candidate ( else candidate->transport = NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE; } + candidate->sockptr = nicesock; candidate->stream_id = stream->id; candidate->component_id = component->id; @@ -849,7 +861,6 @@ NiceCandidate *discovery_learn_remote_peer_reflexive_candidate ( candidate->password = g_strdup(remote->password); } - candidate->sockptr = NULL; /* not stored for remote candidates */ /* note: candidate username and password are left NULL as stream level ufrag/password are used */ |