Commit e416912e authored by Youness Alaoui's avatar Youness Alaoui

Change the priv_agent_to_turn_* functions into non static functions instead of duplicating them

parent 68b829bb
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
#include "conncheck.h" #include "conncheck.h"
#include "component.h" #include "component.h"
#include "stun/stunagent.h" #include "stun/stunagent.h"
#include "stun/usages/turn.h"
#include "stun/usages/ice.h"
/* XXX: starting from ICE ID-18, Ta SHOULD now be set according /* XXX: starting from ICE ID-18, Ta SHOULD now be set according
* to session bandwidth -> this is not yet implemented in NICE */ * to session bandwidth -> this is not yet implemented in NICE */
...@@ -140,4 +142,8 @@ void agent_attach_stream_component_socket (NiceAgent *agent, ...@@ -140,4 +142,8 @@ void agent_attach_stream_component_socket (NiceAgent *agent,
Component *component, Component *component,
NiceSocket *socket); NiceSocket *socket);
StunUsageIceCompatibility agent_to_ice_compatibility (NiceAgent *agent);
StunUsageTurnCompatibility agent_to_turn_compatibility (NiceAgent *agent);
NiceTurnSocketCompatibility agent_to_turn_socket_compatibility (NiceAgent *agent);
#endif /*_NICE_AGENT_PRIV_H */ #endif /*_NICE_AGENT_PRIV_H */
...@@ -110,8 +110,21 @@ static gboolean priv_attach_stream_component (NiceAgent *agent, ...@@ -110,8 +110,21 @@ static gboolean priv_attach_stream_component (NiceAgent *agent,
Component *component); Component *component);
static void priv_detach_stream_component (Stream *stream, Component *component); static void priv_detach_stream_component (Stream *stream, Component *component);
static StunUsageTurnCompatibility StunUsageIceCompatibility
priv_agent_to_turn_compatibility (NiceAgent *agent) { agent_to_ice_compatibility (NiceAgent *agent)
{
return agent->compatibility == NICE_COMPATIBILITY_DRAFT19 ?
STUN_USAGE_ICE_COMPATIBILITY_DRAFT19 :
agent->compatibility == NICE_COMPATIBILITY_GOOGLE ?
STUN_USAGE_ICE_COMPATIBILITY_GOOGLE :
agent->compatibility == NICE_COMPATIBILITY_MSN ?
STUN_USAGE_ICE_COMPATIBILITY_MSN : STUN_USAGE_ICE_COMPATIBILITY_DRAFT19;
}
StunUsageTurnCompatibility
agent_to_turn_compatibility (NiceAgent *agent)
{
return agent->compatibility == NICE_COMPATIBILITY_DRAFT19 ? return agent->compatibility == NICE_COMPATIBILITY_DRAFT19 ?
STUN_USAGE_TURN_COMPATIBILITY_DRAFT9 : STUN_USAGE_TURN_COMPATIBILITY_DRAFT9 :
agent->compatibility == NICE_COMPATIBILITY_GOOGLE ? agent->compatibility == NICE_COMPATIBILITY_GOOGLE ?
...@@ -120,6 +133,18 @@ priv_agent_to_turn_compatibility (NiceAgent *agent) { ...@@ -120,6 +133,18 @@ priv_agent_to_turn_compatibility (NiceAgent *agent) {
STUN_USAGE_TURN_COMPATIBILITY_MSN : STUN_USAGE_TURN_COMPATIBILITY_DRAFT9; STUN_USAGE_TURN_COMPATIBILITY_MSN : STUN_USAGE_TURN_COMPATIBILITY_DRAFT9;
} }
NiceTurnSocketCompatibility
agent_to_turn_socket_compatibility (NiceAgent *agent)
{
return agent->compatibility == NICE_COMPATIBILITY_DRAFT19 ?
NICE_TURN_SOCKET_COMPATIBILITY_DRAFT9 :
agent->compatibility == NICE_COMPATIBILITY_GOOGLE ?
NICE_TURN_SOCKET_COMPATIBILITY_GOOGLE :
agent->compatibility == NICE_COMPATIBILITY_MSN ?
NICE_TURN_SOCKET_COMPATIBILITY_MSN :
NICE_TURN_SOCKET_COMPATIBILITY_DRAFT9;
}
Stream *agent_find_stream (NiceAgent *agent, guint stream_id) Stream *agent_find_stream (NiceAgent *agent, guint stream_id)
{ {
GSList *i; GSList *i;
...@@ -769,7 +794,6 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent, ...@@ -769,7 +794,6 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent,
cdisco = g_slice_new0 (CandidateDiscovery); cdisco = g_slice_new0 (CandidateDiscovery);
if (cdisco) { if (cdisco) {
modified_list = g_slist_append (agent->discovery_list, cdisco); modified_list = g_slist_append (agent->discovery_list, cdisco);
priv_agent_to_turn_compatibility (agent);
if (modified_list) { if (modified_list) {
Component *component = stream_find_component_by_id (stream, component_id); Component *component = stream_find_component_by_id (stream, component_id);
......
...@@ -72,25 +72,6 @@ static int priv_timer_expired (GTimeVal *timer, GTimeVal *now) ...@@ -72,25 +72,6 @@ static int priv_timer_expired (GTimeVal *timer, GTimeVal *now)
now->tv_sec >= timer->tv_sec; now->tv_sec >= timer->tv_sec;
} }
static StunUsageIceCompatibility priv_agent_to_ice_compatibility (NiceAgent *agent) {
return agent->compatibility == NICE_COMPATIBILITY_DRAFT19 ?
STUN_USAGE_ICE_COMPATIBILITY_DRAFT19 :
agent->compatibility == NICE_COMPATIBILITY_GOOGLE ?
STUN_USAGE_ICE_COMPATIBILITY_GOOGLE :
agent->compatibility == NICE_COMPATIBILITY_MSN ?
STUN_USAGE_ICE_COMPATIBILITY_MSN : STUN_USAGE_ICE_COMPATIBILITY_DRAFT19;
}
static StunUsageTurnCompatibility priv_agent_to_turn_compatibility (NiceAgent *agent) {
return agent->compatibility == NICE_COMPATIBILITY_DRAFT19 ?
STUN_USAGE_TURN_COMPATIBILITY_DRAFT9 :
agent->compatibility == NICE_COMPATIBILITY_GOOGLE ?
STUN_USAGE_TURN_COMPATIBILITY_GOOGLE :
agent->compatibility == NICE_COMPATIBILITY_MSN ?
STUN_USAGE_TURN_COMPATIBILITY_MSN : STUN_USAGE_TURN_COMPATIBILITY_DRAFT9;
}
/** /**
* Finds the next connectivity check in WAITING state. * Finds the next connectivity check in WAITING state.
*/ */
...@@ -576,7 +557,7 @@ static void priv_turn_allocate_refresh_tick_unlocked (CandidateRefresh *cand) ...@@ -576,7 +557,7 @@ static void priv_turn_allocate_refresh_tick_unlocked (CandidateRefresh *cand)
cand->stun_resp_msg.buffer == NULL ? NULL : &cand->stun_resp_msg, -1, cand->stun_resp_msg.buffer == NULL ? NULL : &cand->stun_resp_msg, -1,
username, username_len, username, username_len,
password, password_len, password, password_len,
priv_agent_to_turn_compatibility (cand->agent)); agent_to_turn_compatibility (cand->agent));
if (cand->agent->compatibility == NICE_COMPATIBILITY_MSN) { if (cand->agent->compatibility == NICE_COMPATIBILITY_MSN) {
g_free (cand->msn_turn_username); g_free (cand->msn_turn_username);
...@@ -1329,7 +1310,7 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair) ...@@ -1329,7 +1310,7 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
uname, uname_len, password, password_len, uname, uname_len, password, password_len,
cand_use, controlling, priority, cand_use, controlling, priority,
agent->tie_breaker, agent->tie_breaker,
priv_agent_to_ice_compatibility (agent)); agent_to_ice_compatibility (agent));
nice_debug ("Agent %p: conncheck created %d - %p", agent, buffer_len, pair->stun_message.buffer); nice_debug ("Agent %p: conncheck created %d - %p", agent, buffer_len, pair->stun_message.buffer);
...@@ -1694,7 +1675,7 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream * ...@@ -1694,7 +1675,7 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
if (memcmp (discovery_id, response_id, sizeof(stun_transid_t)) == 0) { if (memcmp (discovery_id, response_id, sizeof(stun_transid_t)) == 0) {
res = stun_usage_ice_conncheck_process (resp, &sockaddr, &socklen, res = stun_usage_ice_conncheck_process (resp, &sockaddr, &socklen,
priv_agent_to_ice_compatibility (agent)); agent_to_ice_compatibility (agent));
nice_debug ("Agent %p : stun_bind_process/conncheck for %p res %d " nice_debug ("Agent %p : stun_bind_process/conncheck for %p res %d "
"(controlling=%d).", agent, p, (int)res, agent->controlling_mode); "(controlling=%d).", agent, p, (int)res, agent->controlling_mode);
...@@ -1928,7 +1909,7 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage * ...@@ -1928,7 +1909,7 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
if (memcmp (discovery_id, response_id, sizeof(stun_transid_t)) == 0) { if (memcmp (discovery_id, response_id, sizeof(stun_transid_t)) == 0) {
res = stun_usage_turn_process (resp, res = stun_usage_turn_process (resp,
&relayaddr, &relayaddrlen, &sockaddr, &socklen, &alternate, &alternatelen, &relayaddr, &relayaddrlen, &sockaddr, &socklen, &alternate, &alternatelen,
&bandwidth, &lifetime, priv_agent_to_turn_compatibility (agent)); &bandwidth, &lifetime, agent_to_turn_compatibility (agent));
nice_debug ("Agent %p : stun_turn_process/disc for %p res %d.", nice_debug ("Agent %p : stun_turn_process/disc for %p res %d.",
agent, d, (int)res); agent, d, (int)res);
...@@ -2047,7 +2028,7 @@ static gboolean priv_map_reply_to_relay_refresh (NiceAgent *agent, StunMessage * ...@@ -2047,7 +2028,7 @@ static gboolean priv_map_reply_to_relay_refresh (NiceAgent *agent, StunMessage *
if (memcmp (refresh_id, response_id, sizeof(stun_transid_t)) == 0) { if (memcmp (refresh_id, response_id, sizeof(stun_transid_t)) == 0) {
res = stun_usage_turn_refresh_process (resp, res = stun_usage_turn_refresh_process (resp,
&lifetime, priv_agent_to_turn_compatibility (cand->agent)); &lifetime, agent_to_turn_compatibility (cand->agent));
nice_debug ("Agent %p : stun_turn_refresh_process for %p res %d.", nice_debug ("Agent %p : stun_turn_refresh_process for %p res %d.",
agent, cand, (int)res); agent, cand, (int)res);
if (res == STUN_USAGE_TURN_RETURN_RELAY_SUCCESS) { if (res == STUN_USAGE_TURN_RETURN_RELAY_SUCCESS) {
...@@ -2408,7 +2389,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream, ...@@ -2408,7 +2389,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
res = stun_usage_ice_conncheck_create_reply (&agent->stun_agent, &req, res = stun_usage_ice_conncheck_create_reply (&agent->stun_agent, &req,
&msg, rbuf, &rbuf_len, &sockaddr, sizeof (sockaddr), &msg, rbuf, &rbuf_len, &sockaddr, sizeof (sockaddr),
&control, agent->tie_breaker, &control, agent->tie_breaker,
priv_agent_to_ice_compatibility (agent)); agent_to_ice_compatibility (agent));
if (agent->compatibility == NICE_COMPATIBILITY_MSN) { if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
g_free (req.key); g_free (req.key);
......
...@@ -66,27 +66,6 @@ static inline int priv_timer_expired (GTimeVal *timer, GTimeVal *now) ...@@ -66,27 +66,6 @@ static inline int priv_timer_expired (GTimeVal *timer, GTimeVal *now)
now->tv_sec >= timer->tv_sec; now->tv_sec >= timer->tv_sec;
} }
static StunUsageTurnCompatibility
priv_agent_to_turn_compatibility (NiceAgent *agent) {
return agent->compatibility == NICE_COMPATIBILITY_DRAFT19 ?
STUN_USAGE_TURN_COMPATIBILITY_DRAFT9 :
agent->compatibility == NICE_COMPATIBILITY_GOOGLE ?
STUN_USAGE_TURN_COMPATIBILITY_GOOGLE :
agent->compatibility == NICE_COMPATIBILITY_MSN ?
STUN_USAGE_TURN_COMPATIBILITY_MSN : STUN_USAGE_TURN_COMPATIBILITY_DRAFT9;
}
static NiceUdpTurnSocketCompatibility
priv_agent_to_udp_turn_compatibility (NiceAgent *agent) {
return agent->compatibility == NICE_COMPATIBILITY_DRAFT19 ?
NICE_UDP_TURN_SOCKET_COMPATIBILITY_DRAFT9 :
agent->compatibility == NICE_COMPATIBILITY_GOOGLE ?
NICE_UDP_TURN_SOCKET_COMPATIBILITY_GOOGLE :
agent->compatibility == NICE_COMPATIBILITY_MSN ?
NICE_UDP_TURN_SOCKET_COMPATIBILITY_MSN :
NICE_UDP_TURN_SOCKET_COMPATIBILITY_DRAFT9;
}
/** /**
* Frees the CandidateDiscovery structure pointed to * Frees the CandidateDiscovery structure pointed to
* by 'user data'. Compatible with g_slist_foreach(). * by 'user data'. Compatible with g_slist_foreach().
...@@ -191,7 +170,7 @@ void refresh_free_item (gpointer data, gpointer user_data) ...@@ -191,7 +170,7 @@ void refresh_free_item (gpointer data, gpointer user_data)
cand->stun_resp_msg.buffer == NULL ? NULL : &cand->stun_resp_msg, 0, cand->stun_resp_msg.buffer == NULL ? NULL : &cand->stun_resp_msg, 0,
username, username_len, username, username_len,
password, password_len, password, password_len,
priv_agent_to_turn_compatibility (agent)); agent_to_turn_compatibility (agent));
if (buffer_len > 0) { if (buffer_len > 0) {
/* send the refresh twice since we won't do retransmissions */ /* send the refresh twice since we won't do retransmissions */
...@@ -554,7 +533,7 @@ discovery_add_relay_candidate ( ...@@ -554,7 +533,7 @@ discovery_add_relay_candidate (
relay_socket = nice_udp_turn_socket_new (agent, address, relay_socket = nice_udp_turn_socket_new (agent, address,
base_socket, &turn->server, base_socket, &turn->server,
turn->username, turn->password, turn->username, turn->password,
priv_agent_to_udp_turn_compatibility (agent)); agent_to_turn_socket_compatibility (agent));
if (relay_socket) { if (relay_socket) {
candidate->sockptr = relay_socket; candidate->sockptr = relay_socket;
candidate->base_addr = base_socket->addr; candidate->base_addr = base_socket->addr;
...@@ -860,7 +839,7 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer) ...@@ -860,7 +839,7 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer)
-1, -1, -1, -1,
username, username_len, username, username_len,
password, password_len, password, password_len,
priv_agent_to_turn_compatibility (agent)); agent_to_turn_compatibility (agent));
if (agent->compatibility == NICE_COMPATIBILITY_MSN) { if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
g_free (cand->msn_turn_username); g_free (cand->msn_turn_username);
......
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