NiceAgent *agent = (NiceAgent*)user_data;
NiceAddress localaddr;
NiceAddress externaddr;
-
+ NiceCandidateTransport transport;
GSList *i, *j, *k;
agent_lock();
goto end;
nice_address_set_port (&localaddr, local_port);
+ if (g_strcmp0 (proto, "TCP") == 0)
+ transport = NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE;
+ else
+ transport = NICE_CANDIDATE_TRANSPORT_UDP;
+
for (i = agent->upnp_mapping; i; i = i->next) {
NiceAddress *addr = i->data;
if (nice_address_equal (&localaddr, addr)) {
stream->id,
component->id,
&externaddr,
+ transport,
local_candidate->sockptr);
goto end;
}
nice_debug ("Agent %p: Trying to create host candidate on port %d", agent, current_port);
nice_address_set_port (addr, current_port);
host_candidate = discovery_add_local_host_candidate (agent, stream->id,
- cid, addr);
+ cid, addr, NICE_CANDIDATE_TRANSPORT_UDP);
if (current_port > 0)
current_port++;
if (current_port > component->max_port) current_port = component->min_port;
const gchar *addr = NULL;
guint16 port = 0;
const gchar *type = NULL;
+ const gchar *tcptype = NULL;
const gchar *raddr = NULL;
guint16 rport = 0;
static const gchar *type_names[] = {"host", "srflx", "prflx", "relay"};
+ NiceCandidateTransport ctransport;
guint i;
if (!g_str_has_prefix (sdp, "a=candidate:"))
raddr = tokens[i + 1];
} else if (g_strcmp0 (tokens[i], "rport") == 0) {
rport = (guint16) g_ascii_strtoull (tokens[i + 1], NULL, 10);
+ } else if (g_strcmp0 (tokens[i], "tcptype") == 0) {
+ tcptype = tokens[i + 1];
}
i++;
break;
if (ntype == -1)
goto done;
- if (g_strcmp0 (transport, "UDP") == 0) {
- candidate = nice_candidate_new(ntype);
- candidate->component_id = component_id;
- candidate->stream_id = stream_id;
- candidate->transport = NICE_CANDIDATE_TRANSPORT_UDP;
- g_strlcpy(candidate->foundation, foundation, NICE_CANDIDATE_MAX_FOUNDATION);
- candidate->priority = priority;
+ if (g_ascii_strcasecmp (transport, "UDP") == 0)
+ ctransport = NICE_CANDIDATE_TRANSPORT_UDP;
+ else if (g_ascii_strcasecmp (transport, "TCP-SO") == 0)
+ ctransport = NICE_CANDIDATE_TRANSPORT_TCP_SO;
+ else if (g_ascii_strcasecmp (transport, "TCP-ACT") == 0)
+ ctransport = NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE;
+ else if (g_ascii_strcasecmp (transport, "TCP-PASS") == 0)
+ ctransport = NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE;
+ else if (g_ascii_strcasecmp (transport, "TCP") == 0) {
+ if (g_ascii_strcasecmp (tcptype, "so") == 0)
+ ctransport = NICE_CANDIDATE_TRANSPORT_TCP_SO;
+ else if (g_ascii_strcasecmp (tcptype, "active") == 0)
+ ctransport = NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE;
+ else if (g_ascii_strcasecmp (tcptype, "passive") == 0)
+ ctransport = NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE;
+ else
+ goto done;
+ } else
+ goto done;
+
+ candidate = nice_candidate_new(ntype);
+ candidate->component_id = component_id;
+ candidate->stream_id = stream_id;
+ candidate->transport = ctransport;
+ g_strlcpy(candidate->foundation, foundation, NICE_CANDIDATE_MAX_FOUNDATION);
+ candidate->priority = priority;
- if (!nice_address_set_from_string (&candidate->addr, addr)) {
+ if (!nice_address_set_from_string (&candidate->addr, addr)) {
+ nice_candidate_free (candidate);
+ candidate = NULL;
+ goto done;
+ }
+ nice_address_set_port (&candidate->addr, port);
+
+ if (raddr && rport) {
+ if (!nice_address_set_from_string (&candidate->base_addr, raddr)) {
nice_candidate_free (candidate);
candidate = NULL;
goto done;
}
- nice_address_set_port (&candidate->addr, port);
-
- if (raddr && rport) {
- if (!nice_address_set_from_string (&candidate->base_addr, raddr)) {
- nice_candidate_free (candidate);
- candidate = NULL;
- goto done;
- }
- nice_address_set_port (&candidate->base_addr, rport);
- }
+ nice_address_set_port (&candidate->base_addr, rport);
}
done:
d->stream->id,
d->component->id,
&niceaddr,
+ NICE_CANDIDATE_TRANSPORT_UDP,
d->nicesock);
d->stun_message.buffer = NULL;
d->stream->id,
d->component->id,
&niceaddr,
+ NICE_CANDIDATE_TRANSPORT_UDP,
d->nicesock);
}
d->stream->id,
d->component->id,
&niceaddr,
+ NICE_CANDIDATE_TRANSPORT_UDP,
d->nicesock,
d->turn);
NiceCandidate *c = i->data;
if (nice_address_equal (&c->base_addr, &candidate->base_addr) &&
- nice_address_equal (&c->addr, &candidate->addr)) {
+ nice_address_equal (&c->addr, &candidate->addr) &&
+ c->transport == candidate->transport) {
nice_debug ("Candidate %p (component-id %u) redundant, ignoring.", candidate, component->id);
return FALSE;
}
NiceAgent *agent,
guint stream_id,
guint component_id,
- NiceAddress *address)
+ NiceAddress *address,
+ NiceCandidateTransport transport)
{
NiceCandidate *candidate;
Component *component;
Stream *stream;
- NiceSocket *udp_socket = NULL;
+ NiceSocket *nicesock = NULL;
if (!agent_find_component (agent, stream_id, component_id, &stream, &component))
return NULL;
candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_HOST);
+ candidate->transport = transport;
candidate->stream_id = stream_id;
candidate->component_id = component_id;
candidate->addr = *address;
/* note: candidate username and password are left NULL as stream
level ufrag/password are used */
- udp_socket = nice_udp_bsd_socket_new (address);
- if (!udp_socket)
+ if (transport == NICE_CANDIDATE_TRANSPORT_UDP) {
+ nicesock = nice_udp_bsd_socket_new (address);
+ } else {
+ /* TODO: Add ICE-TCP */
+ }
+ if (!nicesock)
goto errors;
- candidate->sockptr = udp_socket;
- candidate->addr = udp_socket->addr;
- candidate->base_addr = udp_socket->addr;
+ candidate->sockptr = nicesock;
+ candidate->addr = nicesock->addr;
+ candidate->base_addr = nicesock->addr;
if (!priv_add_local_candidate_pruned (agent, stream_id, component, candidate))
goto errors;
- _priv_set_socket_tos (agent, udp_socket, stream->tos);
- component_attach_socket (component, udp_socket);
+ _priv_set_socket_tos (agent, nicesock, stream->tos);
+ component_attach_socket (component, nicesock);
return candidate;
errors:
nice_candidate_free (candidate);
- if (udp_socket)
- nice_socket_free (udp_socket);
+ if (nicesock)
+ nice_socket_free (nicesock);
return NULL;
}
guint stream_id,
guint component_id,
NiceAddress *address,
+ NiceCandidateTransport transport,
NiceSocket *base_socket)
{
NiceCandidate *candidate;
candidate->priority = nice_candidate_ice_priority_full
(NICE_CANDIDATE_TYPE_PREF_SERVER_REFLEXIVE, 0, component_id);
}
+
+ candidate->transport = transport;
candidate->stream_id = stream_id;
candidate->component_id = component_id;
candidate->addr = *address;
*
* @return pointer to the created candidate, or NULL on error
*/
-NiceCandidate*
+NiceCandidate*
discovery_add_relay_candidate (
NiceAgent *agent,
guint stream_id,
guint component_id,
NiceAddress *address,
+ NiceCandidateTransport transport,
NiceSocket *base_socket,
TurnServer *turn)
{
candidate->priority = nice_candidate_ice_priority_full
(NICE_CANDIDATE_TYPE_PREF_RELAYED, 0, component_id);
}
+ candidate->transport = transport;
candidate->stream_id = stream_id;
candidate->component_id = component_id;
candidate->addr = *address;
candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_PEER_REFLEXIVE);
- candidate->transport = NICE_CANDIDATE_TRANSPORT_UDP;
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
candidate->priority = nice_candidate_jingle_priority (candidate);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
candidate->priority = nice_candidate_ice_priority_full
(NICE_CANDIDATE_TYPE_PREF_PEER_REFLEXIVE, 0, component_id);
}
+ candidate->transport = local->transport;
candidate->stream_id = stream_id;
candidate->component_id = component_id;
candidate->addr = *address;
candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_PEER_REFLEXIVE);
- candidate->transport = NICE_CANDIDATE_TRANSPORT_UDP;
candidate->addr = *remote_address;
candidate->base_addr = *remote_address;
candidate->priority = nice_candidate_ice_priority_full
(NICE_CANDIDATE_TYPE_PREF_PEER_REFLEXIVE, 0, component->id);
}
+ candidate->transport = remote->transport;
candidate->stream_id = stream->id;
candidate->component_id = component->id;
NiceAgent *agent,
guint stream_id,
guint component_id,
- NiceAddress *address);
+ NiceAddress *address,
+ NiceCandidateTransport transport);
NiceCandidate*
discovery_add_relay_candidate (
guint stream_id,
guint component_id,
NiceAddress *address,
+ NiceCandidateTransport transport,
NiceSocket *base_socket,
TurnServer *turn);
guint stream_id,
guint component_id,
NiceAddress *address,
+ NiceCandidateTransport transport,
NiceSocket *base_socket);
NiceCandidate*