Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
libnice
libnice
Commits
e416912e
Commit
e416912e
authored
Dec 08, 2008
by
Youness Alaoui
Browse files
Change the priv_agent_to_turn_* functions into non static functions instead of duplicating them
parent
68b829bb
Changes
4
Hide whitespace changes
Inline
Side-by-side
agent/agent-priv.h
View file @
e416912e
...
...
@@ -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 */
agent/agent.c
View file @
e416912e
...
...
@@ -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
);
...
...
agent/conncheck.c
View file @
e416912e
...
...
@@ -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
);
...
...
agent/discovery.c
View file @
e416912e
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment