diff options
author | Youness Alaoui <youness.alaoui@collabora.co.uk> | 2008-12-08 15:20:40 -0500 |
---|---|---|
committer | Youness Alaoui <youness.alaoui@collabora.co.uk> | 2008-12-08 15:20:40 -0500 |
commit | e416912e14291d37bed7e6c6b96669ec2d8f5a09 (patch) | |
tree | 751a4db1d1be823a2563243aaa2b362881214400 /agent | |
parent | 68b829bb776b31a282168ce80d7fbe4411a43c9c (diff) | |
download | libnice-e416912e14291d37bed7e6c6b96669ec2d8f5a09.tar.gz |
Change the priv_agent_to_turn_* functions into non static functions instead of duplicating them
Diffstat (limited to 'agent')
-rw-r--r-- | agent/agent-priv.h | 6 | ||||
-rw-r--r-- | agent/agent.c | 30 | ||||
-rw-r--r-- | agent/conncheck.c | 31 | ||||
-rw-r--r-- | agent/discovery.c | 27 |
4 files changed, 42 insertions, 52 deletions
diff --git a/agent/agent-priv.h b/agent/agent-priv.h index c08bd53..28f0cd3 100644 --- a/agent/agent-priv.h +++ b/agent/agent-priv.h @@ -50,6 +50,8 @@ #include "conncheck.h" #include "component.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 * to session bandwidth -> this is not yet implemented in NICE */ @@ -140,4 +142,8 @@ void agent_attach_stream_component_socket (NiceAgent *agent, Component *component, 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 */ diff --git a/agent/agent.c b/agent/agent.c index 206f85c..1933ad1 100644 --- a/agent/agent.c +++ b/agent/agent.c @@ -110,8 +110,21 @@ static gboolean priv_attach_stream_component (NiceAgent *agent, Component *component); static void priv_detach_stream_component (Stream *stream, Component *component); -static StunUsageTurnCompatibility -priv_agent_to_turn_compatibility (NiceAgent *agent) { +StunUsageIceCompatibility +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 ? STUN_USAGE_TURN_COMPATIBILITY_DRAFT9 : agent->compatibility == NICE_COMPATIBILITY_GOOGLE ? @@ -120,6 +133,18 @@ priv_agent_to_turn_compatibility (NiceAgent *agent) { 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) { GSList *i; @@ -769,7 +794,6 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent, cdisco = g_slice_new0 (CandidateDiscovery); if (cdisco) { modified_list = g_slist_append (agent->discovery_list, cdisco); - priv_agent_to_turn_compatibility (agent); if (modified_list) { Component *component = stream_find_component_by_id (stream, component_id); diff --git a/agent/conncheck.c b/agent/conncheck.c index 5e99ad6..3cae647 100644 --- a/agent/conncheck.c +++ b/agent/conncheck.c @@ -72,25 +72,6 @@ static int priv_timer_expired (GTimeVal *timer, GTimeVal *now) 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. */ @@ -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, username, username_len, password, password_len, - priv_agent_to_turn_compatibility (cand->agent)); + agent_to_turn_compatibility (cand->agent)); if (cand->agent->compatibility == NICE_COMPATIBILITY_MSN) { g_free (cand->msn_turn_username); @@ -1329,7 +1310,7 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair) uname, uname_len, password, password_len, cand_use, controlling, priority, 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); @@ -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) { 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 " "(controlling=%d).", agent, p, (int)res, agent->controlling_mode); @@ -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) { res = stun_usage_turn_process (resp, &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.", agent, d, (int)res); @@ -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) { 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.", agent, cand, (int)res); if (res == STUN_USAGE_TURN_RETURN_RELAY_SUCCESS) { @@ -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, &msg, rbuf, &rbuf_len, &sockaddr, sizeof (sockaddr), &control, agent->tie_breaker, - priv_agent_to_ice_compatibility (agent)); + agent_to_ice_compatibility (agent)); if (agent->compatibility == NICE_COMPATIBILITY_MSN) { g_free (req.key); diff --git a/agent/discovery.c b/agent/discovery.c index 2629842..8f5fe6d 100644 --- a/agent/discovery.c +++ b/agent/discovery.c @@ -66,27 +66,6 @@ static inline int priv_timer_expired (GTimeVal *timer, GTimeVal *now) 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 * by 'user data'. Compatible with g_slist_foreach(). @@ -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, username, username_len, password, password_len, - priv_agent_to_turn_compatibility (agent)); + agent_to_turn_compatibility (agent)); if (buffer_len > 0) { /* send the refresh twice since we won't do retransmissions */ @@ -554,7 +533,7 @@ discovery_add_relay_candidate ( relay_socket = nice_udp_turn_socket_new (agent, address, base_socket, &turn->server, turn->username, turn->password, - priv_agent_to_udp_turn_compatibility (agent)); + agent_to_turn_socket_compatibility (agent)); if (relay_socket) { candidate->sockptr = relay_socket; candidate->base_addr = base_socket->addr; @@ -860,7 +839,7 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer) -1, -1, username, username_len, password, password_len, - priv_agent_to_turn_compatibility (agent)); + agent_to_turn_compatibility (agent)); if (agent->compatibility == NICE_COMPATIBILITY_MSN) { g_free (cand->msn_turn_username); |