Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
libnice
Commits
4ee70c86
Commit
4ee70c86
authored
Jul 20, 2010
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote branch 'tester/misc-fixes' into nice-kakaroto
Conflicts: agent/agent.c
parents
358a999f
3b16d8b0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
530 additions
and
739 deletions
+530
-739
agent/agent.c
agent/agent.c
+179
-255
agent/agent.h
agent/agent.h
+3
-1
agent/component.c
agent/component.c
+3
-13
agent/conncheck.c
agent/conncheck.c
+108
-155
agent/discovery.c
agent/discovery.c
+233
-294
agent/stream.c
agent/stream.c
+1
-16
socket/tcp-bsd.c
socket/tcp-bsd.c
+3
-1
socket/udp-bsd.c
socket/udp-bsd.c
+0
-4
No files found.
agent/agent.c
View file @
4ee70c86
...
...
@@ -1294,171 +1294,134 @@ agent_candidate_pair_priority (NiceAgent *agent, NiceCandidate *local, NiceCandi
return
nice_candidate_pair_priority
(
remote
->
priority
,
local
->
priority
);
}
static
gboolean
static
void
priv_add_new_candidate_discovery_stun
(
NiceAgent
*
agent
,
NiceSocket
*
socket
,
NiceAddress
server
,
Stream
*
stream
,
guint
component_id
)
{
CandidateDiscovery
*
cdisco
;
GSList
*
modified_list
;
/* note: no need to check for redundant candidates, as this is
* done later on in the process */
cdisco
=
g_slice_new0
(
CandidateDiscovery
);
if
(
cdisco
)
{
modified_list
=
g_slist_append
(
agent
->
discovery_list
,
cdisco
);
if
(
modified_list
)
{
cdisco
->
type
=
NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE
;
cdisco
->
nicesock
=
socket
;
cdisco
->
server
=
server
;
cdisco
->
stream
=
stream
;
cdisco
->
component
=
stream_find_component_by_id
(
stream
,
component_id
);
cdisco
->
agent
=
agent
;
stun_agent_init
(
&
cdisco
->
stun_agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
STUN_COMPATIBILITY_RFC3489
,
0
);
nice_debug
(
"Agent %p : Adding new srv-rflx candidate discovery %p
\n
"
,
agent
,
cdisco
);
agent
->
discovery_list
=
modified_list
;
++
agent
->
discovery_unsched_items
;
}
return
TRUE
;
}
cdisco
->
type
=
NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE
;
cdisco
->
nicesock
=
socket
;
cdisco
->
server
=
server
;
cdisco
->
stream
=
stream
;
cdisco
->
component
=
stream_find_component_by_id
(
stream
,
component_id
);
cdisco
->
agent
=
agent
;
stun_agent_init
(
&
cdisco
->
stun_agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
STUN_COMPATIBILITY_RFC3489
,
0
);
return
FALSE
;
nice_debug
(
"Agent %p : Adding new srv-rflx candidate discovery %p
\n
"
,
agent
,
cdisco
);
agent
->
discovery_list
=
g_slist_append
(
agent
->
discovery_list
,
cdisco
);
++
agent
->
discovery_unsched_items
;
}
static
gboolean
static
void
priv_add_new_candidate_discovery_turn
(
NiceAgent
*
agent
,
NiceSocket
*
socket
,
TurnServer
*
turn
,
Stream
*
stream
,
guint
component_id
)
{
CandidateDiscovery
*
cdisco
;
GSList
*
modified_list
;
GSList
*
socket_modified_list
;
Component
*
component
=
stream_find_component_by_id
(
stream
,
component_id
);
/* note: no need to check for redundant candidates, as this is
* done later on in the process */
cdisco
=
g_slice_new0
(
CandidateDiscovery
);
if
(
cdisco
)
{
modified_list
=
g_slist_append
(
agent
->
discovery_list
,
cdisco
);
if
(
modified_list
)
{
Component
*
component
=
stream_find_component_by_id
(
stream
,
component_id
);
cdisco
->
type
=
NICE_CANDIDATE_TYPE_RELAYED
;
if
(
turn
->
type
==
NICE_RELAY_TYPE_TURN_UDP
)
{
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
NiceAddress
addr
=
socket
->
addr
;
NiceSocket
*
new_socket
;
nice_address_set_port
(
&
addr
,
0
);
new_socket
=
nice_udp_bsd_socket_new
(
&
addr
);
if
(
new_socket
)
{
_priv_set_socket_tos
(
agent
,
new_socket
,
stream
->
tos
);
agent_attach_stream_component_socket
(
agent
,
stream
,
component
,
new_socket
);
socket_modified_list
=
g_slist_append
(
component
->
sockets
,
new_socket
);
if
(
socket_modified_list
)
{
/* success: store a pointer to the sockaddr */
component
->
sockets
=
socket_modified_list
;
socket
=
new_socket
;
}
else
{
nice_socket_free
(
new_socket
);
}
}
}
cdisco
->
nicesock
=
socket
;
}
else
{
NiceAddress
proxy_server
;
socket
=
NULL
;
if
(
agent
->
proxy_type
!=
NICE_PROXY_TYPE_NONE
&&
agent
->
proxy_ip
!=
NULL
&&
nice_address_set_from_string
(
&
proxy_server
,
agent
->
proxy_ip
))
{
nice_address_set_port
(
&
proxy_server
,
agent
->
proxy_port
);
socket
=
nice_tcp_bsd_socket_new
(
agent
,
component
->
ctx
,
&
proxy_server
);
if
(
socket
)
{
_priv_set_socket_tos
(
agent
,
socket
,
stream
->
tos
);
if
(
agent
->
proxy_type
==
NICE_PROXY_TYPE_SOCKS5
)
{
socket
=
nice_socks5_socket_new
(
socket
,
&
turn
->
server
,
agent
->
proxy_username
,
agent
->
proxy_password
);
}
else
if
(
agent
->
proxy_type
==
NICE_PROXY_TYPE_HTTP
){
socket
=
nice_http_socket_new
(
socket
,
&
turn
->
server
,
agent
->
proxy_username
,
agent
->
proxy_password
);
}
else
{
nice_socket_free
(
socket
);
socket
=
NULL
;
}
}
}
if
(
socket
==
NULL
)
{
socket
=
nice_tcp_bsd_socket_new
(
agent
,
component
->
ctx
,
&
turn
->
server
);
_priv_set_socket_tos
(
agent
,
socket
,
stream
->
tos
);
}
if
(
turn
->
type
==
NICE_RELAY_TYPE_TURN_TLS
&&
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
socket
=
nice_pseudossl_socket_new
(
agent
,
socket
);
}
cdisco
->
nicesock
=
nice_tcp_turn_socket_new
(
agent
,
socket
,
agent_to_turn_socket_compatibility
(
agent
));
cdisco
->
type
=
NICE_CANDIDATE_TYPE_RELAYED
;
if
(
!
cdisco
->
nicesock
)
{
agent
->
discovery_list
=
g_slist_remove
(
modified_list
,
cdisco
);
g_slice_free
(
CandidateDiscovery
,
cdisco
)
;
return
FALSE
;
}
if
(
turn
->
type
==
NICE_RELAY_TYPE_TURN_UDP
)
{
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
NiceAddress
addr
=
socket
->
addr
;
NiceSocket
*
new_socket
;
nice_address_set_port
(
&
addr
,
0
);
new_socket
=
nice_udp_bsd_socket_new
(
&
addr
);
if
(
new_socket
)
{
_priv_set_socket_tos
(
agent
,
new_socket
,
stream
->
tos
);
agent_attach_stream_component_socket
(
agent
,
stream
,
component
,
cdisco
->
nicesock
);
socket_modified_list
=
g_slist_append
(
component
->
sockets
,
cdisco
->
nicesock
);
if
(
socket_modified_list
)
{
/* success: store a pointer to the sockaddr */
component
->
sockets
=
socket_modified_list
;
}
component
,
new_socket
);
component
->
sockets
=
g_slist_append
(
component
->
sockets
,
new_socket
);
socket
=
new_socket
;
}
cdisco
->
turn
=
turn
;
cdisco
->
server
=
turn
->
server
;
cdisco
->
stream
=
stream
;
cdisco
->
component
=
stream_find_component_by_id
(
stream
,
component_id
);
cdisco
->
agent
=
agent
;
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
stun_agent_init
(
&
cdisco
->
stun_agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
STUN_COMPATIBILITY_RFC3489
,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS
|
STUN_AGENT_USAGE_IGNORE_CREDENTIALS
);
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
||
agent
->
compatibility
==
NICE_COMPATIBILITY_WLM2009
)
{
stun_agent_init
(
&
cdisco
->
stun_agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
STUN_COMPATIBILITY_RFC3489
,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS
);
}
else
{
stun_agent_init
(
&
cdisco
->
stun_agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
STUN_COMPATIBILITY_RFC5389
,
STUN_AGENT_USAGE_ADD_SOFTWARE
|
STUN_AGENT_USAGE_LONG_TERM_CREDENTIALS
);
}
cdisco
->
nicesock
=
socket
;
}
else
{
NiceAddress
proxy_server
;
socket
=
NULL
;
if
(
agent
->
proxy_type
!=
NICE_PROXY_TYPE_NONE
&&
agent
->
proxy_ip
!=
NULL
&&
nice_address_set_from_string
(
&
proxy_server
,
agent
->
proxy_ip
))
{
nice_address_set_port
(
&
proxy_server
,
agent
->
proxy_port
);
socket
=
nice_tcp_bsd_socket_new
(
agent
,
component
->
ctx
,
&
proxy_server
);
if
(
socket
)
{
_priv_set_socket_tos
(
agent
,
socket
,
stream
->
tos
);
if
(
agent
->
proxy_type
==
NICE_PROXY_TYPE_SOCKS5
)
{
socket
=
nice_socks5_socket_new
(
socket
,
&
turn
->
server
,
agent
->
proxy_username
,
agent
->
proxy_password
);
}
else
if
(
agent
->
proxy_type
==
NICE_PROXY_TYPE_HTTP
){
socket
=
nice_http_socket_new
(
socket
,
&
turn
->
server
,
agent
->
proxy_username
,
agent
->
proxy_password
);
}
else
{
nice_socket_free
(
socket
);
socket
=
NULL
;
}
}
stun_agent_set_software
(
&
cdisco
->
stun_agent
,
agent
->
software_attribute
);
nice_debug
(
"Agent %p : Adding new relay-rflx candidate discovery %p
\n
"
,
agent
,
cdisco
);
agent
->
discovery_list
=
modified_list
;
++
agent
->
discovery_unsched_items
;
}
return
TRUE
;
if
(
socket
==
NULL
)
{
socket
=
nice_tcp_bsd_socket_new
(
agent
,
component
->
ctx
,
&
turn
->
server
);
_priv_set_socket_tos
(
agent
,
socket
,
stream
->
tos
);
}
if
(
turn
->
type
==
NICE_RELAY_TYPE_TURN_TLS
&&
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
socket
=
nice_pseudossl_socket_new
(
agent
,
socket
);
}
cdisco
->
nicesock
=
nice_tcp_turn_socket_new
(
agent
,
socket
,
agent_to_turn_socket_compatibility
(
agent
));
agent_attach_stream_component_socket
(
agent
,
stream
,
component
,
cdisco
->
nicesock
);
component
->
sockets
=
g_slist_append
(
component
->
sockets
,
cdisco
->
nicesock
);
}
cdisco
->
turn
=
turn
;
cdisco
->
server
=
turn
->
server
;
cdisco
->
stream
=
stream
;
cdisco
->
component
=
stream_find_component_by_id
(
stream
,
component_id
);
cdisco
->
agent
=
agent
;
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
stun_agent_init
(
&
cdisco
->
stun_agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
STUN_COMPATIBILITY_RFC3489
,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS
|
STUN_AGENT_USAGE_IGNORE_CREDENTIALS
);
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
||
agent
->
compatibility
==
NICE_COMPATIBILITY_WLM2009
)
{
stun_agent_init
(
&
cdisco
->
stun_agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
STUN_COMPATIBILITY_RFC3489
,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS
);
}
else
{
stun_agent_init
(
&
cdisco
->
stun_agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
STUN_COMPATIBILITY_RFC5389
,
STUN_AGENT_USAGE_ADD_SOFTWARE
|
STUN_AGENT_USAGE_LONG_TERM_CREDENTIALS
);
}
stun_agent_set_software
(
&
cdisco
->
stun_agent
,
agent
->
software_attribute
);
return
FALSE
;
nice_debug
(
"Agent %p : Adding new relay-rflx candidate discovery %p
\n
"
,
agent
,
cdisco
);
agent
->
discovery_list
=
g_slist_append
(
agent
->
discovery_list
,
cdisco
);
++
agent
->
discovery_unsched_items
;
}
NICEAPI_EXPORT
guint
...
...
@@ -1467,51 +1430,43 @@ nice_agent_add_stream (
guint
n_components
)
{
Stream
*
stream
;
GSList
*
modified_list
=
NULL
;
guint
ret
=
0
;
guint
i
;
agent_lock
();
stream
=
stream_new
(
n_components
);
if
(
stream
)
{
modified_list
=
g_slist_append
(
agent
->
streams
,
stream
);
if
(
modified_list
)
{
stream
->
id
=
agent
->
next_stream_id
++
;
nice_debug
(
"Agent %p : allocating stream id %u (%p)"
,
agent
,
stream
->
id
,
stream
);
if
(
agent
->
reliable
)
{
nice_debug
(
"Agent %p : reliable stream"
,
agent
);
for
(
i
=
0
;
i
<
n_components
;
i
++
)
{
Component
*
component
=
stream_find_component_by_id
(
stream
,
i
+
1
);
if
(
component
)
{
TcpUserData
*
data
=
g_slice_new0
(
TcpUserData
);
PseudoTcpCallbacks
tcp_callbacks
=
{
data
,
pseudo_tcp_socket_opened
,
pseudo_tcp_socket_readable
,
pseudo_tcp_socket_writable
,
pseudo_tcp_socket_closed
,
pseudo_tcp_socket_write_packet
};
data
->
agent
=
agent
;
data
->
stream
=
stream
;
data
->
component
=
component
;
component
->
tcp_data
=
data
;
component
->
tcp
=
pseudo_tcp_socket_new
(
0
,
&
tcp_callbacks
);
adjust_tcp_clock
(
agent
,
stream
,
component
);
nice_debug
(
"Agent %p: Create Pseudo Tcp Socket for component %d"
,
agent
,
i
+
1
);
}
else
{
nice_debug
(
"Agent %p: couldn't find component %d"
,
agent
,
i
+
1
);
}
}
}
stream_initialize_credentials
(
stream
,
agent
->
rng
);
agent
->
streams
=
modified_list
;
agent
->
streams
=
g_slist_append
(
agent
->
streams
,
stream
);
stream
->
id
=
agent
->
next_stream_id
++
;
nice_debug
(
"Agent %p : allocating stream id %u (%p)"
,
agent
,
stream
->
id
,
stream
);
if
(
agent
->
reliable
)
{
nice_debug
(
"Agent %p : reliable stream"
,
agent
);
for
(
i
=
0
;
i
<
n_components
;
i
++
)
{
Component
*
component
=
stream_find_component_by_id
(
stream
,
i
+
1
);
if
(
component
)
{
TcpUserData
*
data
=
g_slice_new0
(
TcpUserData
);
PseudoTcpCallbacks
tcp_callbacks
=
{
data
,
pseudo_tcp_socket_opened
,
pseudo_tcp_socket_readable
,
pseudo_tcp_socket_writable
,
pseudo_tcp_socket_closed
,
pseudo_tcp_socket_write_packet
};
data
->
agent
=
agent
;
data
->
stream
=
stream
;
data
->
component
=
component
;
component
->
tcp_data
=
data
;
component
->
tcp
=
pseudo_tcp_socket_new
(
0
,
&
tcp_callbacks
);
adjust_tcp_clock
(
agent
,
stream
,
component
);
nice_debug
(
"Agent %p: Create Pseudo Tcp Socket for component %d"
,
agent
,
i
+
1
);
}
else
{
nice_debug
(
"Agent %p: couldn't find component %d"
,
agent
,
i
+
1
);
}
}
else
stream_free
(
stream
);
}
stream_initialize_credentials
(
stream
,
agent
->
rng
);
ret
=
stream
->
id
;
agent_unlock
();
...
...
@@ -1703,7 +1658,7 @@ static void _upnp_error_mapping_port (GUPnPSimpleIgd *self, GError *error,
#endif
NICEAPI_EXPORT
void
NICEAPI_EXPORT
gboolean
nice_agent_gather_candidates
(
NiceAgent
*
agent
,
guint
stream_id
)
...
...
@@ -1788,8 +1743,8 @@ nice_agent_gather_candidates (
n
+
1
,
addr
);
if
(
!
host_candidate
)
{
g_
error
(
"No host candidate??"
);
break
;
g_
warning
(
"No host candidate??"
);
return
FALSE
;
}
#ifdef HAVE_GUPNP
...
...
@@ -1808,20 +1763,13 @@ nice_agent_gather_candidates (
agent
->
stun_server_ip
)
{
NiceAddress
stun_server
;
if
(
nice_address_set_from_string
(
&
stun_server
,
agent
->
stun_server_ip
))
{
gboolean
res
;
nice_address_set_port
(
&
stun_server
,
agent
->
stun_server_port
);
res
=
priv_add_new_candidate_discovery_stun
(
agent
,
host_candidate
->
sockptr
,
stun_server
,
stream
,
n
+
1
);
if
(
res
!=
TRUE
)
{
/* note: memory allocation failure, return error */
g_error
(
"Memory allocation failure?"
);
}
priv_add_new_candidate_discovery_stun
(
agent
,
host_candidate
->
sockptr
,
stun_server
,
stream
,
n
+
1
);
}
}
...
...
@@ -1831,17 +1779,11 @@ nice_agent_gather_candidates (
for
(
item
=
component
->
turn_servers
;
item
;
item
=
item
->
next
)
{
TurnServer
*
turn
=
item
->
data
;
gboolean
res
=
priv_add_new_candidate_discovery_turn
(
agent
,
host_candidate
->
sockptr
,
turn
,
stream
,
n
+
1
);
if
(
res
!=
TRUE
)
{
/* note: memory allocation failure, return error */
g_error
(
"Memory allocation failure?"
);
}
priv_add_new_candidate_discovery_turn
(
agent
,
host_candidate
->
sockptr
,
turn
,
stream
,
n
+
1
);
}
}
}
...
...
@@ -1863,6 +1805,8 @@ nice_agent_gather_candidates (
done:
agent_unlock
();
return
TRUE
;
}
static
void
priv_free_upnp
(
NiceAgent
*
agent
)
...
...
@@ -1935,24 +1879,15 @@ NICEAPI_EXPORT gboolean
nice_agent_add_local_address
(
NiceAgent
*
agent
,
NiceAddress
*
addr
)
{
NiceAddress
*
dup
;
GSList
*
modified_list
;
gboolean
ret
=
FALSE
;
agent_lock
();
dup
=
nice_address_dup
(
addr
);
nice_address_set_port
(
dup
,
0
);
modified_list
=
g_slist_append
(
agent
->
local_addresses
,
dup
);
if
(
modified_list
)
{
agent
->
local_addresses
=
modified_list
;
ret
=
TRUE
;
goto
done
;
}
agent
->
local_addresses
=
g_slist_append
(
agent
->
local_addresses
,
dup
);
done:
agent_unlock
();
return
ret
;
return
TRUE
;
}
static
gboolean
priv_add_remote_candidate
(
...
...
@@ -1970,7 +1905,6 @@ static gboolean priv_add_remote_candidate (
{
Component
*
component
;
NiceCandidate
*
candidate
;
gboolean
error_flag
=
FALSE
;
if
(
!
agent_find_component
(
agent
,
stream_id
,
component_id
,
NULL
,
&
component
))
return
FALSE
;
...
...
@@ -2013,62 +1947,53 @@ static gboolean priv_add_remote_candidate (
candidate
->
password
=
g_strdup
(
password
);
}
if
(
conn_check_add_for_candidate
(
agent
,
stream_id
,
component
,
candidate
)
<
0
)
error_flag
=
TRUE
;
goto
errors
;
}
else
{
/* case 2: add a new candidate */
candidate
=
nice_candidate_new
(
type
);
if
(
candidate
)
{
GSList
*
modified_list
=
g_slist_append
(
component
->
remote_candidates
,
candidate
);
if
(
modified_list
)
{
component
->
remote_candidates
=
modified_list
;
component
->
remote_candidates
=
g_slist_append
(
component
->
remote_candidates
,
candidate
);
candidate
->
stream_id
=
stream_id
;
candidate
->
component_id
=
component_id
;
candidate
->
stream_id
=
stream_id
;
candidate
->
component_id
=
component_id
;
candidate
->
type
=
type
;
if
(
addr
)
candidate
->
addr
=
*
addr
;
{
gchar
tmpbuf
[
INET6_ADDRSTRLEN
]
=
{
0
};
if
(
addr
)
nice_address_to_string
(
addr
,
tmpbuf
);
nice_debug
(
"Agent %p : Adding remote candidate with addr [%s]:%u"
" for s%d/c%d. U/P '%s'/'%s' prio: %u"
,
agent
,
tmpbuf
,
addr
?
nice_address_get_port
(
addr
)
:
0
,
stream_id
,
component_id
,
username
,
password
,
priority
);
}
candidate
->
type
=
type
;
if
(
addr
)
candidate
->
addr
=
*
addr
;
if
(
base_addr
)
candidate
->
base_addr
=
*
base_addr
;
{
gchar
tmpbuf
[
INET6_ADDRSTRLEN
]
=
{
0
};
if
(
addr
)
nice_address_to_string
(
addr
,
tmpbuf
);
nice_debug
(
"Agent %p : Adding remote candidate with addr [%s]:%u"
" for s%d/c%d. U/P '%s'/'%s' prio: %u"
,
agent
,
tmpbuf
,
addr
?
nice_address_get_port
(
addr
)
:
0
,
stream_id
,
component_id
,
username
,
password
,
priority
);
}
candidate
->
transport
=
transport
;
candidate
->
priority
=
priority
;
candidate
->
username
=
g_strdup
(
username
);
candidate
->
password
=
g_strdup
(
password
);
if
(
base_addr
)
candidate
->
base_addr
=
*
base_addr
;
if
(
foundation
)
g_strlcpy
(
candidate
->
foundation
,
foundation
,
NICE_CANDIDATE_MAX_FOUNDATION
);
candidate
->
transport
=
transport
;
candidate
->
priority
=
priority
;
candidate
->
username
=
g_strdup
(
username
);
candidate
->
password
=
g_strdup
(
password
);
if
(
conn_check_add_for_candidate
(
agent
,
stream_id
,
component
,
candidate
)
<
0
)
error_flag
=
TRUE
;
}
else
/* memory alloc error: list insert */
error_flag
=
TRUE
;
}
else
/* memory alloc error: candidate creation */
error_flag
=
TRUE
;
}
if
(
foundation
)
g_strlcpy
(
candidate
->
foundation
,
foundation
,
NICE_CANDIDATE_MAX_FOUNDATION
);
if
(
error_flag
)
{
if
(
candidate
)
nice_candidate_free
(
candidate
);
return
FALSE
;
if
(
conn_check_add_for_candidate
(
agent
,
stream_id
,
component
,
candidate
)
<
0
)
goto
errors
;
}
return
TRUE
;
errors:
nice_candidate_free
(
candidate
);
return
FALSE
;
}
NICEAPI_EXPORT
gboolean
...
...
@@ -2490,14 +2415,13 @@ io_ctx_new (
IOCtx
*
ctx
;
ctx
=
g_slice_new0
(
IOCtx
);
if
(
ctx
)
{
ctx
->
agent
=
agent
;
ctx
->
stream
=
stream
;
ctx
->
component
=
component
;
ctx
->
socket
=
socket
;
ctx
->
channel
=
channel
;
ctx
->
source
=
source
;
}
ctx
->
agent
=
agent
;
ctx
->
stream
=
stream
;
ctx
->
component
=
component
;
ctx
->
socket
=
socket
;
ctx
->
channel
=
channel
;
ctx
->
source
=
source
;
return
ctx
;
}
...
...
agent/agent.h
View file @
4ee70c86
...
...
@@ -385,6 +385,8 @@ gboolean nice_agent_set_relay_info(
* Start the candidate gathering process.
* Once done, #NiceAgent::candidate-gathering-done is called for the stream
*
* Returns: %FALSE if there were no local addresses and they couldn't be discovered. In this case, call nice_agent_add_local_address() first.
*
* See also: nice_agent_add_local_address()
<note>
<para>
...
...
@@ -397,7 +399,7 @@ gboolean nice_agent_set_relay_info(
</para>
</note>
*/
void
gboolean
nice_agent_gather_candidates
(
NiceAgent
*
agent
,
guint
stream_id
);
...
...
agent/component.c
View file @
4ee70c86
...
...
@@ -310,20 +310,10 @@ component_set_selected_remote_candidate (NiceAgent *agent, Component *component,
candidate
->
transport
);
if
(
!
remote
)
{
GSList
*
modified_list
=
NULL
;
remote
=
nice_candidate_copy
(
candidate
);
modified_list
=
g_slist_append
(
component
->
remote_candidates
,
remote
);
if
(
modified_list
)
{
component
->
remote_candidates
=
modified_list
;
agent_signal_new_remote_candidate
(
agent
,
remote
);
}
else
{
/* error: memory alloc / list */
nice_candidate_free
(
remote
),
remote
=
NULL
;
return
NULL
;
}
component
->
remote_candidates
=
g_slist_append
(
component
->
remote_candidates
,
remote
);
agent_signal_new_remote_candidate
(
agent
,
remote
);
}
if
(
component
->
selected_pair
.
keepalive
.
tick_source
!=
NULL
)
{
...
...
agent/conncheck.c
View file @
4ee70c86
...
...
@@ -1249,60 +1249,39 @@ static void priv_mark_pair_nominated (NiceAgent *agent, Stream *stream, Componen
* Creates a new connectivity check pair and adds it to
* the agent's list of checks.
*/
static
gboolean
priv_add_new_check_pair
(
NiceAgent
*
agent
,
guint
stream_id
,
Component
*
component
,
NiceCandidate
*
local
,
NiceCandidate
*
remote
,
NiceCheckState
initial_state
,
gboolean
use_candidate
)
static
void
priv_add_new_check_pair
(
NiceAgent
*
agent
,
guint
stream_id
,
Component
*
component
,
NiceCandidate
*
local
,
NiceCandidate
*
remote
,
NiceCheckState
initial_state
,
gboolean
use_candidate
)
{
gboolean
result
=
FALSE
;
Stream
*
stream
=
agent_find_stream
(
agent
,
stream_id
);
CandidateCheckPair
*
pair
=
g_slice_new0
(
CandidateCheckPair
);
if
(
pair
)
{
GSList
*
modified_list
=
g_slist_insert_sorted
(
stream
->
conncheck_list
,
pair
,
(
GCompareFunc
)
conn_check_compare
);
if
(
modified_list
)
{
/* step: allocation and addition succesful, do rest of the work */
pair
->
agent
=
agent
;
pair
->
stream_id
=
stream_id
;
pair
->
component_id
=
component
->
id
;;
pair
->
local
=
local
;
pair
->
remote
=
remote
;
g_snprintf
(
pair
->
foundation
,
NICE_CANDIDATE_PAIR_MAX_FOUNDATION
,
"%s:%s"
,
local
->
foundation
,
remote
->
foundation
);
pair
->
priority
=
agent_candidate_pair_priority
(
agent
,
local
,
remote
);
pair
->
state
=
initial_state
;
nice_debug
(
"Agent %p : creating new pair %p state %d"
,
agent
,
pair
,
initial_state
);
pair
->
nominated
=
use_candidate
;
pair
->
controlling
=
agent
->
controlling_mode
;
/* note: for the first added check */
if
(
!
stream
->
conncheck_list
)
stream
->
conncheck_state
=
NICE_CHECKLIST_RUNNING
;
stream
->
conncheck_list
=
modified_list
;
result
=
TRUE
;
nice_debug
(
"Agent %p : added a new conncheck %p with foundation of '%s' to list %u."
,
agent
,
pair
,
pair
->
foundation
,
stream_id
);
/* implement the hard upper limit for number of
checks (see sect 5.7.3 ICE ID-19): */
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_RFC5245
)
{
stream
->
conncheck_list
=
priv_limit_conn_check_list_size
(
stream
->
conncheck_list
,
agent
->
max_conn_checks
);
}
if
(
!
stream
->
conncheck_list
)
{
stream
->
conncheck_state
=
NICE_CHECKLIST_FAILED
;
result
=
FALSE
;
}
}
else
{
/* memory alloc failed: list insert */
conn_check_free_item
(
pair
,
NULL
);
stream
->
conncheck_state
=
NICE_CHECKLIST_FAILED
;
}
}
else
{
/* memory alloc failed: new pair */
stream
->
conncheck_state
=
NICE_CHECKLIST_FAILED
;
}
return
result
;
stream
->
conncheck_list
=
g_slist_insert_sorted
(
stream
->
conncheck_list
,
pair
,
(
GCompareFunc
)
conn_check_compare
);
pair
->
agent
=
agent
;
pair
->
stream_id
=
stream_id
;
pair
->
component_id
=
component
->
id
;;
pair
->
local
=
local
;
pair
->
remote
=
remote
;
g_snprintf
(
pair
->
foundation
,
NICE_CANDIDATE_PAIR_MAX_FOUNDATION
,
"%s:%s"
,
local
->
foundation
,
remote
->
foundation
);
pair
->
priority
=
agent_candidate_pair_priority
(
agent
,
local
,
remote
);
pair
->
state
=
initial_state
;
nice_debug
(
"Agent %p : creating new pair %p state %d"
,
agent
,
pair
,
initial_state
);
pair
->
nominated
=
use_candidate
;
pair
->
controlling
=
agent
->
controlling_mode
;
/* note: for the first added check */
if
(
!
stream
->
conncheck_list
)
stream
->
conncheck_state
=
NICE_CHECKLIST_RUNNING
;
nice_debug
(
"Agent %p : added a new conncheck %p with foundation of '%s' to list %u."
,
agent
,
pair
,
pair
->
foundation
,
stream_id
);
/* implement the hard upper limit for number of
checks (see sect 5.7.3 ICE ID-19): */
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_RFC5245
)
{
stream
->
conncheck_list
=
priv_limit_conn_check_list_size
(
stream
->
conncheck_list
,
agent
->
max_conn_checks
);
}
}
/*
...
...
@@ -1330,8 +1309,6 @@ int conn_check_add_for_candidate (NiceAgent *agent, guint stream_id, Component *
if
(
local
->
transport
==
remote
->
transport
&&
local
->
addr
.
s
.
addr
.
sa_family
==
remote
->
addr
.
s
.
addr
.
sa_family
)
{
gboolean
result
;
/* note: do not create pairs where local candidate is
* a srv-reflexive (ICE 5.7.3. "Pruning the Pairs" ID-19) */
if
((
agent
->
compatibility
==
NICE_COMPATIBILITY_RFC5245
||
...
...
@@ -1339,24 +1316,18 @@ int conn_check_add_for_candidate (NiceAgent *agent, guint stream_id, Component *
local
->
type
==
NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE
)
continue
;
result
=
priv_add_new_check_pair
(
agent
,
stream_id
,
component
,
local
,
remote
,
NICE_CHECK_FROZEN
,
FALSE
);
if
(
result
)
{
++
added
;
if
(
component
->
state
<
NICE_COMPONENT_STATE_CONNECTED
)
{
agent_signal_component_state_change
(
agent
,
stream_id
,
component
->
id
,
NICE_COMPONENT_STATE_CONNECTING
);
}
else
{
agent_signal_component_state_change
(
agent
,
stream_id
,
component
->
id
,
NICE_COMPONENT_STATE_CONNECTED
);
}
}
else
{
added
=
-
1
;
break
;
priv_add_new_check_pair
(
agent
,
stream_id
,
component
,
local
,
remote
,
NICE_CHECK_FROZEN
,
FALSE
);
++
added
;
if
(
component
->
state
<
NICE_COMPONENT_STATE_CONNECTED
)
{
agent_signal_component_state_change
(
agent
,
stream_id
,
component
->
id
,
NICE_COMPONENT_STATE_CONNECTING
);
}
else
{
agent_signal_component_state_change
(
agent
,
stream_id
,
component
->
id
,
NICE_COMPONENT_STATE_CONNECTED
);
}
}
}
...
...
@@ -1766,7 +1737,7 @@ static guint priv_prune_pending_checks (Stream *stream, guint component_id)
static
gboolean
priv_schedule_triggered_check
(
NiceAgent
*
agent
,
Stream
*
stream
,
Component
*
component
,
NiceSocket
*
local_socket
,
NiceCandidate
*
remote_cand
,
gboolean
use_candidate
)
{
GSList
*
i
;
gboolean
result
=
FALSE
;
NiceCandidate
*
local
=
NULL
;
for
(
i
=
stream
->
conncheck_list
;
i
;
i
=
i
->
next
)
{
CandidateCheckPair
*
p
=
i
->
data
;
...
...
@@ -1807,23 +1778,21 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, Stream *stream,
}
}
{
NiceCandidate
*
local
=
NULL
;
for
(
i
=
component
->
local_candidates
;
i
;
i
=
i
->
next
)
{
local
=
i
->
data
;
if
(
local
->
sockptr
==
local_socket
)
break
;
}
if
(
i
)
{
nice_debug
(
"Agent %p : Adding a triggered check to conn.check list (local=%p)."
,
agent
,
local
);
result
=
priv_add_new_check_pair
(
agent
,
stream
->
id
,
component
,
local
,
remote_cand
,
NICE_CHECK_WAITING
,
use_candidate
);
}
else
nice_debug
(
"Agent %p : Didn't find a matching pair for triggered check (remote-cand=%p)."
,
agent
,
remote_cand
);
for
(
i
=
component
->
local_candidates
;
i
;
i
=
i
->
next
)
{
local
=
i
->
data
;
if
(
local
->
sockptr
==
local_socket
)
break
;
}
return
result
;
if
(
i
)
{
nice_debug
(
"Agent %p : Adding a triggered check to conn.check list (local=%p)."
,
agent
,
local
);
priv_add_new_check_pair
(
agent
,
stream
->
id
,
component
,
local
,
remote_cand
,
NICE_CHECK_WAITING
,
use_candidate
);
return
TRUE
;
}
else
{
nice_debug
(
"Agent %p : Didn't find a matching pair for triggered check (remote-cand=%p)."
,
agent
,
remote_cand
);
return
FALSE
;
}
}
...
...
@@ -1895,23 +1864,17 @@ static int priv_store_pending_check (NiceAgent *agent, Component *component,
}
icheck
=
g_slice_new0
(
IncomingCheck
);
if
(
icheck
)
{
GSList
*
pending
=
g_slist_append
(
component
->
incoming_checks
,
icheck
);
if
(
pending
)
{
component
->
incoming_checks
=
pending
;
icheck
->
from
=
*
from
;
icheck
->
local_socket
=
socket
;
icheck
->
priority
=
priority
;
icheck
->
use_candidate
=
use_candidate
;
icheck
->
username_len
=
username_len
;
icheck
->
username
=
NULL
;
if
(
username_len
>
0
)
icheck
->
username
=
g_memdup
(
username
,
username_len
);
return
0
;
}
}
component
->
incoming_checks
=
g_slist_append
(
component
->
incoming_checks
,
icheck
);
icheck
->
from
=
*
from
;
icheck
->
local_socket
=
socket
;
icheck
->
priority
=
priority
;
icheck
->
use_candidate
=
use_candidate
;
icheck
->
username_len
=
username_len
;
icheck
->
username
=
NULL
;
if
(
username_len
>
0
)
icheck
->
username
=
g_memdup
(
username
,
username_len
);
return
-
1
;
return
0
;
}
/*
...
...
@@ -1923,31 +1886,29 @@ static int priv_store_pending_check (NiceAgent *agent, Component *component,
static
CandidateCheckPair
*
priv_add_peer_reflexive_pair
(
NiceAgent
*
agent
,
guint
stream_id
,
guint
component_id
,
NiceCandidate
*
local_cand
,
CandidateCheckPair
*
parent_pair
)
{
CandidateCheckPair
*
pair
=
g_slice_new0
(
CandidateCheckPair
);
if
(
pair
)
{
Stream
*
stream
=
agent_find_stream
(
agent
,
stream_id
);
GSList
*
modified_list
=
g_slist_append
(
stream
->
conncheck_list
,
pair
);
if
(
modified_list
)
{
stream
->
conncheck_list
=
modified_list
;
pair
->
agent
=
agent
;
pair
->
stream_id
=
stream_id
;
pair
->
component_id
=
component_id
;;
pair
->
local
=
local_cand
;
pair
->
remote
=
parent_pair
->
remote
;
pair
->
state
=
NICE_CHECK_DISCOVERED
;
nice_debug
(
"Agent %p : pair %p state DISCOVERED"
,
agent
,
pair
);
g_snprintf
(
pair
->
foundation
,
NICE_CANDIDATE_PAIR_MAX_FOUNDATION
,
"%s:%s"
,
local_cand
->
foundation
,
parent_pair
->
remote
->
foundation
);
if
(
agent
->
controlling_mode
==
TRUE
)
pair
->
priority
=
nice_candidate_pair_priority
(
local_cand
->
priority
,
parent_pair
->
priority
);
else
pair
->
priority
=
nice_candidate_pair_priority
(
parent_pair
->
priority
,
local_cand
->
priority
);
pair
->
nominated
=
FALSE
;
pair
->
controlling
=
agent
->
controlling_mode
;
nice_debug
(
"Agent %p : added a new peer-discovered pair with foundation of '%s'."
,
agent
,
pair
->
foundation
);
return
pair
;
}
}
Stream
*
stream
=
agent_find_stream
(
agent
,
stream_id
);
return
NULL
;
stream
->
conncheck_list
=
g_slist_append
(
stream
->
conncheck_list
,
pair
);
pair
->
agent
=
agent
;
pair
->
stream_id
=
stream_id
;
pair
->
component_id
=
component_id
;;
pair
->
local
=
local_cand
;
pair
->
remote
=
parent_pair
->
remote
;
pair
->
state
=
NICE_CHECK_DISCOVERED
;
nice_debug
(
"Agent %p : pair %p state DISCOVERED"
,
agent
,
pair
);
g_snprintf
(
pair
->
foundation
,
NICE_CANDIDATE_PAIR_MAX_FOUNDATION
,
"%s:%s"
,
local_cand
->
foundation
,
parent_pair
->
remote
->
foundation
);
if
(
agent
->
controlling_mode
==
TRUE
)
pair
->
priority
=
nice_candidate_pair_priority
(
local_cand
->
priority
,
parent_pair
->
priority
);
else
pair
->
priority
=
nice_candidate_pair_priority
(
parent_pair
->
priority
,
local_cand
->
priority
);
pair
->
nominated
=
FALSE
;
pair
->
controlling
=
agent
->
controlling_mode
;
nice_debug
(
"Agent %p : added a new peer-discovered pair with foundation of '%s'."
,
agent
,
pair
->
foundation
);
return
pair
;
}
/*
...
...
@@ -2254,34 +2215,28 @@ priv_add_new_turn_refresh (CandidateDiscovery *cdisco, NiceCandidate *relay_cand
{
CandidateRefresh
*
cand
;
NiceAgent
*
agent
=
cdisco
->
agent
;
GSList
*
modified_list
;
cand
=
g_slice_new0
(
CandidateRefresh
);
if
(
cand
)
{
modified_list
=
g_slist_append
(
agent
->
refresh_list
,
cand
);
if
(
modified_list
)
{
cand
->
nicesock
=
cdisco
->
nicesock
;
cand
->
relay_socket
=
relay_cand
->
sockptr
;
cand
->
server
=
cdisco
->
server
;
cand
->
turn
=
cdisco
->
turn
;
cand
->
stream
=
cdisco
->
stream
;
cand
->
component
=
cdisco
->
component
;
cand
->
agent
=
cdisco
->
agent
;
memcpy
(
&
cand
->
stun_agent
,
&
cdisco
->
stun_agent
,
sizeof
(
StunAgent
));
nice_debug
(
"Agent %p : Adding new refresh candidate %p with timeout %d"
,
agent
,
cand
,
(
lifetime
-
60
)
*
1000
);
agent
->
refresh_list
=
modified_list
;
/* step: also start the refresh timer */
/* refresh should be sent 1 minute before it expires */
cand
->
timer_source
=
agent_timeout_add_with_context
(
agent
,
(
lifetime
-
60
)
*
1000
,
priv_turn_allocate_refresh_tick
,
cand
);
nice_debug
(
"timer source is : %d"
,
cand
->
timer_source
);
}
}
agent
->
refresh_list
=
g_slist_append
(
agent
->
refresh_list
,
cand
);
cand
->
nicesock
=
cdisco
->
nicesock
;
cand
->
relay_socket
=
relay_cand
->
sockptr
;
cand
->
server
=
cdisco
->
server
;
cand
->
turn
=
cdisco
->
turn
;
cand
->
stream
=
cdisco
->
stream
;
cand
->
component
=
cdisco
->
component
;
cand
->
agent
=
cdisco
->
agent
;
memcpy
(
&
cand
->
stun_agent
,
&
cdisco
->
stun_agent
,
sizeof
(
StunAgent
));
nice_debug
(
"Agent %p : Adding new refresh candidate %p with timeout %d"
,
agent
,
cand
,
(
lifetime
-
60
)
*
1000
);
/* step: also start the refresh timer */
/* refresh should be sent 1 minute before it expires */
cand
->
timer_source
=
agent_timeout_add_with_context
(
agent
,
(
lifetime
-
60
)
*
1000
,
priv_turn_allocate_refresh_tick
,
cand
);
nice_debug
(
"timer source is : %d"
,
cand
->
timer_source
);
return
cand
;
}
...
...
@@ -2700,9 +2655,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
}
}
if
(
validater_data
.
password
)
g_free
(
validater_data
.
password
);
g_free
(
validater_data
.
password
);
if
(
valid
==
STUN_VALIDATION_NOT_STUN
||
valid
==
STUN_VALIDATION_INCOMPLETE_STUN
||
...
...
agent/discovery.c
View file @
4ee70c86
...
...
@@ -87,15 +87,12 @@ void discovery_free_item (gpointer data, gpointer user_data)
*/
void
discovery_free
(
NiceAgent
*
agent
)
{
if
(
agent
->
discovery_list
)
{
GSList
*
tmp
=
agent
->
discovery_list
;
agent
->
discovery_list
=
NULL
;
g_slist_foreach
(
tmp
,
discovery_free_item
,
NULL
);
g_slist_free
(
tmp
);
g_slist_foreach
(
agent
->
discovery_list
,
discovery_free_item
,
NULL
);
g_slist_free
(
agent
->
discovery_list
);
agent
->
discovery_list
=
NULL
;
agent
->
discovery_unsched_items
=
0
;
agent
->
discovery_unsched_items
=
0
;
}
if
(
agent
->
discovery_timer_source
!=
NULL
)
{
g_source_destroy
(
agent
->
discovery_timer_source
);
g_source_unref
(
agent
->
discovery_timer_source
);
...
...
@@ -204,14 +201,9 @@ void refresh_free_item (gpointer data, gpointer user_data)
*/
void
refresh_free
(
NiceAgent
*
agent
)
{
if
(
agent
->
refresh_list
)
{
GSList
*
tmp
=
agent
->
refresh_list
;
agent
->
refresh_list
=
NULL
;
g_slist_foreach
(
tmp
,
refresh_free_item
,
NULL
);
g_slist_free
(
tmp
);
}
g_slist_foreach
(
agent
->
refresh_list
,
refresh_free_item
,
NULL
);
g_slist_free
(
agent
->
refresh_list
);
agent
->
refresh_list
=
NULL
;
}
/*
...
...
@@ -252,11 +244,11 @@ void refresh_cancel (CandidateRefresh *refresh)
*/
static
gboolean
priv_add_local_candidate_pruned
(
Component
*
component
,
NiceCandidate
*
candidate
)
{
GSList
*
modified_list
,
*
i
;
GSList
*
i
;
for
(
i
=
component
->
local_candidates
;
i
;
i
=
i
->
next
)
{
NiceCandidate
*
c
=
i
->
data
;
if
(
nice_address_equal
(
&
c
->
base_addr
,
&
candidate
->
base_addr
)
&&
nice_address_equal
(
&
c
->
addr
,
&
candidate
->
addr
))
{
nice_debug
(
"Candidate %p (component-id %u) redundant, ignoring."
,
candidate
,
component
->
id
);
...
...
@@ -264,11 +256,8 @@ static gboolean priv_add_local_candidate_pruned (Component *component, NiceCandi
}
}
modified_list
=
g_slist_append
(
component
->
local_candidates
,
candidate
);
if
(
modified_list
)
{
component
->
local_candidates
=
modified_list
;
}
component
->
local_candidates
=
g_slist_append
(
component
->
local_candidates
,
candidate
);
return
TRUE
;
}
...
...
@@ -418,10 +407,8 @@ void priv_generate_candidate_credentials (NiceAgent *agent,
guchar
username
[
32
];
guchar
password
[
16
];
if
(
candidate
->
username
)
g_free
(
candidate
->
username
);
if
(
candidate
->
password
)
g_free
(
candidate
->
password
);
g_free
(
candidate
->
username
);
g_free
(
candidate
->
password
);
nice_rng_generate_bytes
(
agent
->
rng
,
32
,
(
gchar
*
)
username
);
nice_rng_generate_bytes
(
agent
->
rng
,
16
,
(
gchar
*
)
password
);
...
...
@@ -432,10 +419,8 @@ void priv_generate_candidate_credentials (NiceAgent *agent,
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
gchar
username
[
16
];
if
(
candidate
->
username
)
g_free
(
candidate
->
username
);
if
(
candidate
->
password
)
g_free
(
candidate
->
password
);
g_free
(
candidate
->
username
);
g_free
(
candidate
->
password
);
candidate
->
password
=
NULL
;
nice_rng_generate_bytes_print
(
agent
->
rng
,
16
,
(
gchar
*
)
username
);
...
...
@@ -462,72 +447,54 @@ NiceCandidate *discovery_add_local_host_candidate (
Component
*
component
;
Stream
*
stream
;
NiceSocket
*
udp_socket
=
NULL
;
gboolean
errors
=
FALSE
;
if
(
!
agent_find_component
(
agent
,
stream_id
,
component_id
,
&
stream
,
&
component
))
return
NULL
;
candidate
=
nice_candidate_new
(
NICE_CANDIDATE_TYPE_HOST
);
if
(
candidate
)
{
candidate
->
stream_id
=
stream_id
;
candidate
->
component_id
=
component_id
;
candidate
->
addr
=
*
address
;
candidate
->
base_addr
=
*
address
;
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
candidate
->
priority
=
nice_candidate_jingle_priority
(
candidate
);
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
)
{
candidate
->
priority
=
nice_candidate_msn_priority
(
candidate
);
}
else
{
candidate
->
priority
=
nice_candidate_ice_priority
(
candidate
);
}
priv_generate_candidate_credentials
(
agent
,
candidate
);
priv_assign_foundation
(
agent
,
candidate
);
/* 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
)
{
gboolean
result
;
_priv_set_socket_tos
(
agent
,
udp_socket
,
stream
->
tos
);
agent_attach_stream_component_socket
(
agent
,
stream
,
component
,
udp_socket
);
candidate
->
sockptr
=
udp_socket
;
candidate
->
addr
=
udp_socket
->
addr
;
candidate
->
base_addr
=
udp_socket
->
addr
;
result
=
priv_add_local_candidate_pruned
(
component
,
candidate
);
if
(
result
==
TRUE
)
{
GSList
*
modified_list
=
g_slist_append
(
component
->
sockets
,
udp_socket
);
if
(
modified_list
)
{
/* success: store a pointer to the sockaddr */
component
->
sockets
=
modified_list
;
agent_signal_new_candidate
(
agent
,
candidate
);
}
else
{
/* error: list memory allocation */
candidate
=
NULL
;
/* note: candidate already owned by component */
}
}
else
{
/* error: memory allocation, or duplicate candidates */
errors
=
TRUE
;
}
}
else
{
/* error: socket new */
errors
=
TRUE
;
}
candidate
->
stream_id
=
stream_id
;
candidate
->
component_id
=
component_id
;
candidate
->
addr
=
*
address
;
candidate
->
base_addr
=
*
address
;
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
candidate
->
priority
=
nice_candidate_jingle_priority
(
candidate
);
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
)
{
candidate
->
priority
=
nice_candidate_msn_priority
(
candidate
);
}
else
{
candidate
->
priority
=
nice_candidate_ice_priority
(
candidate
);
}
/* clean up after errors */
if
(
errors
)
{
if
(
candidate
)
nice_candidate_free
(
candidate
),
candidate
=
NULL
;
if
(
udp_socket
)
nice_socket_free
(
udp_socket
);
}
priv_generate_candidate_credentials
(
agent
,
candidate
);
priv_assign_foundation
(
agent
,
candidate
);
/* 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
)
goto
errors
;
_priv_set_socket_tos
(
agent
,
udp_socket
,
stream
->
tos
);
agent_attach_stream_component_socket
(
agent
,
stream
,
component
,
udp_socket
);
candidate
->
sockptr
=
udp_socket
;
candidate
->
addr
=
udp_socket
->
addr
;
candidate
->
base_addr
=
udp_socket
->
addr
;
if
(
!
priv_add_local_candidate_pruned
(
component
,
candidate
))
goto
errors
;
component
->
sockets
=
g_slist_append
(
component
->
sockets
,
udp_socket
);
agent_signal_new_candidate
(
agent
,
candidate
);
return
candidate
;
errors:
nice_candidate_free
(
candidate
);
if
(
udp_socket
)
nice_socket_free
(
udp_socket
);
return
NULL
;
}
/*
...
...
@@ -553,34 +520,33 @@ discovery_add_server_reflexive_candidate (
return
NULL
;
candidate
=
nice_candidate_new
(
NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE
);
if
(
candidate
)
{
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
candidate
->
priority
=
nice_candidate_jingle_priority
(
candidate
);
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
)
{
candidate
->
priority
=
nice_candidate_msn_priority
(
candidate
);
}
else
{
candidate
->
priority
=
nice_candidate_ice_priority_full
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
candidate
->
priority
=
nice_candidate_jingle_priority
(
candidate
);
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
)
{
candidate
->
priority
=
nice_candidate_msn_priority
(
candidate
);
}
else
{
candidate
->
priority
=
nice_candidate_ice_priority_full
(
NICE_CANDIDATE_TYPE_PREF_SERVER_REFLEXIVE
,
0
,
component_id
);
}
candidate
->
stream_id
=
stream_id
;
candidate
->
component_id
=
component_id
;
candidate
->
addr
=
*
address
;
}
candidate
->
stream_id
=
stream_id
;
candidate
->
component_id
=
component_id
;
candidate
->
addr
=
*
address
;
/* step: link to the base candidate+socket */
candidate
->
sockptr
=
base_socket
;
candidate
->
base_addr
=
base_socket
->
addr
;
/* step: link to the base candidate+socket */
candidate
->
sockptr
=
base_socket
;
candidate
->
base_addr
=
base_socket
->
addr
;
priv_generate_candidate_credentials
(
agent
,
candidate
);
priv_assign_foundation
(
agent
,
candidate
);
priv_generate_candidate_credentials
(
agent
,
candidate
);
priv_assign_foundation
(
agent
,
candidate
);
result
=
priv_add_local_candidate_pruned
(
component
,
candidate
);
if
(
result
)
{
agent_signal_new_candidate
(
agent
,
candidate
);
}
else
{
/* error: memory allocation, or duplicate candidatet */
nice_candidate_free
(
candidate
),
candidate
=
NULL
;
}
result
=
priv_add_local_candidate_pruned
(
component
,
candidate
);
if
(
result
)
{
agent_signal_new_candidate
(
agent
,
candidate
);
}
else
{
/* error: duplicate candidate */
nice_candidate_free
(
candidate
),
candidate
=
NULL
;
}
return
candidate
;
...
...
@@ -605,76 +571,60 @@ discovery_add_relay_candidate (
NiceCandidate
*
candidate
;
Component
*
component
;
Stream
*
stream
;
gboolean
result
=
FALSE
;
gboolean
errors
=
FALSE
;
NiceSocket
*
relay_socket
=
NULL
;
if
(
!
agent_find_component
(
agent
,
stream_id
,
component_id
,
&
stream
,
&
component
))
return
NULL
;
candidate
=
nice_candidate_new
(
NICE_CANDIDATE_TYPE_RELAYED
);
if
(
candidate
)
{
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
candidate
->
priority
=
nice_candidate_jingle_priority
(
candidate
);
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
)
{
candidate
->
priority
=
nice_candidate_msn_priority
(
candidate
);
}
else
{
candidate
->
priority
=
nice_candidate_ice_priority_full
(
NICE_CANDIDATE_TYPE_PREF_RELAYED
,
0
,
component_id
);
}
candidate
->
stream_id
=
stream_id
;
candidate
->
component_id
=
component_id
;
candidate
->
addr
=
*
address
;
candidate
->
turn
=
turn
;
/* step: link to the base candidate+socket */
relay_socket
=
nice_turn_socket_new
(
agent
,
address
,
base_socket
,
&
turn
->
server
,
turn
->
username
,
turn
->
password
,
agent_to_turn_socket_compatibility
(
agent
));
if
(
relay_socket
)
{
candidate
->
sockptr
=
relay_socket
;
candidate
->
base_addr
=
base_socket
->
addr
;
priv_generate_candidate_credentials
(
agent
,
candidate
);
/* Google uses the turn username as the candidate username */
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
g_free
(
candidate
->
username
);
candidate
->
username
=
g_strdup
(
turn
->
username
);
}
priv_assign_foundation
(
agent
,
candidate
);
result
=
priv_add_local_candidate_pruned
(
component
,
candidate
);
if
(
result
)
{
GSList
*
modified_list
=
g_slist_append
(
component
->
sockets
,
relay_socket
);
if
(
modified_list
)
{
/* success: store a pointer to the sockaddr */
component
->
sockets
=
modified_list
;
}
agent_signal_new_candidate
(
agent
,
candidate
);
}
else
{
/* error: memory allocation, or duplicate candidate */
errors
=
TRUE
;
}
}
else
{
/* error: socket factory make */
errors
=
TRUE
;
}
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
candidate
->
priority
=
nice_candidate_jingle_priority
(
candidate
);
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
)
{
candidate
->
priority
=
nice_candidate_msn_priority
(
candidate
);
}
else
{
/* error: udp socket memory allocation */
errors
=
TRUE
;
candidate
->
priority
=
nice_candidate_ice_priority_full
(
NICE_CANDIDATE_TYPE_PREF_RELAYED
,
0
,
component_id
)
;
}
/* clean up after errors */
if
(
errors
)
{
if
(
candidate
)
nice_candidate_free
(
candidate
),
candidate
=
NULL
;
if
(
relay_socket
)
nice_socket_free
(
relay_socket
);
candidate
->
stream_id
=
stream_id
;
candidate
->
component_id
=
component_id
;
candidate
->
addr
=
*
address
;
candidate
->
turn
=
turn
;
/* step: link to the base candidate+socket */
relay_socket
=
nice_turn_socket_new
(
agent
,
address
,
base_socket
,
&
turn
->
server
,
turn
->
username
,
turn
->
password
,
agent_to_turn_socket_compatibility
(
agent
));
if
(
!
relay_socket
)
goto
errors
;
candidate
->
sockptr
=
relay_socket
;
candidate
->
base_addr
=
base_socket
->
addr
;
priv_generate_candidate_credentials
(
agent
,
candidate
);
/* Google uses the turn username as the candidate username */
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
g_free
(
candidate
->
username
);
candidate
->
username
=
g_strdup
(
turn
->
username
);
}
priv_assign_foundation
(
agent
,
candidate
);
if
(
!
priv_add_local_candidate_pruned
(
component
,
candidate
))
goto
errors
;
component
->
sockets
=
g_slist_append
(
component
->
sockets
,
relay_socket
);
agent_signal_new_candidate
(
agent
,
candidate
);
return
candidate
;
errors:
nice_candidate_free
(
candidate
);
if
(
relay_socket
)
nice_socket_free
(
relay_socket
);
return
NULL
;
}
/*
...
...
@@ -683,7 +633,7 @@ discovery_add_relay_candidate (
*
* @return pointer to the created candidate, or NULL on error
*/
NiceCandidate
*
NiceCandidate
*
discovery_add_peer_reflexive_candidate
(
NiceAgent
*
agent
,
guint
stream_id
,
...
...
@@ -696,71 +646,69 @@ discovery_add_peer_reflexive_candidate (
NiceCandidate
*
candidate
;
Component
*
component
;
Stream
*
stream
;
gboolean
result
;
if
(
!
agent_find_component
(
agent
,
stream_id
,
component_id
,
&
stream
,
&
component
))
return
NULL
;
candidate
=
nice_candidate_new
(
NICE_CANDIDATE_TYPE_PEER_REFLEXIVE
);
if
(
candidate
)
{
gboolean
result
;
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_msn_priority
(
candidate
);
}
else
{
candidate
->
priority
=
nice_candidate_ice_priority_full
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_msn_priority
(
candidate
);
}
else
{
candidate
->
priority
=
nice_candidate_ice_priority_full
(
NICE_CANDIDATE_TYPE_PREF_PEER_REFLEXIVE
,
0
,
component_id
);
}
candidate
->
stream_id
=
stream_id
;
candidate
->
component_id
=
component_id
;
candidate
->
addr
=
*
address
;
candidate
->
base_addr
=
base_socket
->
addr
;
priv_assign_foundation
(
agent
,
candidate
);
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
&&
remote
&&
local
)
{
guchar
*
new_username
=
NULL
;
guchar
*
decoded_local
=
NULL
;
guchar
*
decoded_remote
=
NULL
;
gsize
local_size
;
gsize
remote_size
;
g_free
(
candidate
->
username
);
g_free
(
candidate
->
password
);
decoded_local
=
g_base64_decode
(
local
->
username
,
&
local_size
);
decoded_remote
=
g_base64_decode
(
remote
->
username
,
&
remote_size
);
new_username
=
g_new0
(
guchar
,
local_size
+
remote_size
);
memcpy
(
new_username
,
decoded_local
,
local_size
);
memcpy
(
new_username
+
local_size
,
decoded_remote
,
remote_size
);
candidate
->
username
=
g_base64_encode
(
new_username
,
local_size
+
remote_size
);
g_free
(
new_username
);
g_free
(
decoded_local
);
g_free
(
decoded_remote
);
candidate
->
password
=
g_strdup
(
local
->
password
);
}
else
if
(
local
)
{
g_free
(
candidate
->
username
);
g_free
(
candidate
->
password
);
candidate
->
username
=
g_strdup
(
local
->
username
);
candidate
->
password
=
g_strdup
(
local
->
password
);
}
}
candidate
->
stream_id
=
stream_id
;
candidate
->
component_id
=
component_id
;
candidate
->
addr
=
*
address
;
candidate
->
base_addr
=
base_socket
->
addr
;
priv_assign_foundation
(
agent
,
candidate
);
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
&&
remote
&&
local
)
{
guchar
*
new_username
=
NULL
;
guchar
*
decoded_local
=
NULL
;
guchar
*
decoded_remote
=
NULL
;
gsize
local_size
;
gsize
remote_size
;
g_free
(
candidate
->
username
);
g_free
(
candidate
->
password
);
decoded_local
=
g_base64_decode
(
local
->
username
,
&
local_size
);
decoded_remote
=
g_base64_decode
(
remote
->
username
,
&
remote_size
);
new_username
=
g_new0
(
guchar
,
local_size
+
remote_size
);
memcpy
(
new_username
,
decoded_local
,
local_size
);
memcpy
(
new_username
+
local_size
,
decoded_remote
,
remote_size
);
candidate
->
username
=
g_base64_encode
(
new_username
,
local_size
+
remote_size
);
g_free
(
new_username
);
g_free
(
decoded_local
);
g_free
(
decoded_remote
);
candidate
->
password
=
g_strdup
(
local
->
password
);
}
else
if
(
local
)
{
g_free
(
candidate
->
username
);
g_free
(
candidate
->
password
);
candidate
->
username
=
g_strdup
(
local
->
username
);
candidate
->
password
=
g_strdup
(
local
->
password
);
}
/* step: link to the base candidate+socket */
candidate
->
sockptr
=
base_socket
;
candidate
->
base_addr
=
base_socket
->
addr
;
/* step: link to the base candidate+socket */
candidate
->
sockptr
=
base_socket
;
candidate
->
base_addr
=
base_socket
->
addr
;
result
=
priv_add_local_candidate_pruned
(
component
,
candidate
);
if
(
result
!=
TRUE
)
{
/* error: memory allocation, or duplicate candidatet */
nice_candidate_free
(
candidate
),
candidate
=
NULL
;
}
result
=
priv_add_local_candidate_pruned
(
component
,
candidate
);
if
(
result
!=
TRUE
)
{
/* error: memory allocation, or duplicate candidatet */
nice_candidate_free
(
candidate
),
candidate
=
NULL
;
}
return
candidate
;
...
...
@@ -792,76 +740,67 @@ NiceCandidate *discovery_learn_remote_peer_reflexive_candidate (
(
void
)
udp_socket
;
candidate
=
nice_candidate_new
(
NICE_CANDIDATE_TYPE_PEER_REFLEXIVE
);
if
(
candidate
)
{
GSList
*
modified_list
;
candidate
->
transport
=
NICE_CANDIDATE_TRANSPORT_UDP
;
candidate
->
addr
=
*
remote_address
;
candidate
->
base_addr
=
*
remote_address
;
/* if the check didn't contain the PRIORITY attribute, then the priority will
* be 0, which is invalid... */
if
(
priority
!=
0
)
{
candidate
->
priority
=
priority
;
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
candidate
->
priority
=
nice_candidate_jingle_priority
(
candidate
);
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
)
{
candidate
->
priority
=
nice_candidate_msn_priority
(
candidate
);
}
else
{
candidate
->
priority
=
nice_candidate_ice_priority_full
candidate
->
transport
=
NICE_CANDIDATE_TRANSPORT_UDP
;
candidate
->
addr
=
*
remote_address
;
candidate
->
base_addr
=
*
remote_address
;
/* if the check didn't contain the PRIORITY attribute, then the priority will
* be 0, which is invalid... */
if
(
priority
!=
0
)
{
candidate
->
priority
=
priority
;
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
candidate
->
priority
=
nice_candidate_jingle_priority
(
candidate
);
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
)
{
candidate
->
priority
=
nice_candidate_msn_priority
(
candidate
);
}
else
{
candidate
->
priority
=
nice_candidate_ice_priority_full
(
NICE_CANDIDATE_TYPE_PREF_PEER_REFLEXIVE
,
0
,
component
->
id
);
}
candidate
->
stream_id
=
stream
->
id
;
candidate
->
component_id
=
component
->
id
;
priv_assign_remote_foundation
(
agent
,
candidate
);
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
&&
remote
&&
local
)
{
guchar
*
new_username
=
NULL
;
guchar
*
decoded_local
=
NULL
;
guchar
*
decoded_remote
=
NULL
;
gsize
local_size
;
gsize
remote_size
;
g_free
(
candidate
->
username
);
g_free
(
candidate
->
password
);
decoded_local
=
g_base64_decode
(
local
->
username
,
&
local_size
);
decoded_remote
=
g_base64_decode
(
remote
->
username
,
&
remote_size
);
new_username
=
g_new0
(
guchar
,
local_size
+
remote_size
);
memcpy
(
new_username
,
decoded_remote
,
remote_size
);
memcpy
(
new_username
+
remote_size
,
decoded_local
,
local_size
);
candidate
->
username
=
g_base64_encode
(
new_username
,
local_size
+
remote_size
);
g_free
(
new_username
);
g_free
(
decoded_local
);
g_free
(
decoded_remote
);
candidate
->
password
=
g_strdup
(
remote
->
password
);
}
else
if
(
remote
)
{
g_free
(
candidate
->
username
);
g_free
(
candidate
->
password
);
candidate
->
username
=
g_strdup
(
remote
->
username
);
candidate
->
password
=
g_strdup
(
remote
->
password
);
}
}
candidate
->
stream_id
=
stream
->
id
;
candidate
->
component_id
=
component
->
id
;
priv_assign_remote_foundation
(
agent
,
candidate
);
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_MSN
&&
remote
&&
local
)
{
guchar
*
new_username
=
NULL
;
guchar
*
decoded_local
=
NULL
;
guchar
*
decoded_remote
=
NULL
;
gsize
local_size
;
gsize
remote_size
;
g_free
(
candidate
->
username
);
g_free
(
candidate
->
password
);
decoded_local
=
g_base64_decode
(
local
->
username
,
&
local_size
);
decoded_remote
=
g_base64_decode
(
remote
->
username
,
&
remote_size
);
new_username
=
g_new0
(
guchar
,
local_size
+
remote_size
);
memcpy
(
new_username
,
decoded_remote
,
remote_size
);
memcpy
(
new_username
+
remote_size
,
decoded_local
,
local_size
);
candidate
->
username
=
g_base64_encode
(
new_username
,
local_size
+
remote_size
);
g_free
(
new_username
);
g_free
(
decoded_local
);
g_free
(
decoded_remote
);
candidate
->
password
=
g_strdup
(
remote
->
password
);
}
else
if
(
remote
)
{
g_free
(
candidate
->
username
);
g_free
(
candidate
->
password
);
candidate
->
username
=
g_strdup
(
remote
->
username
);
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 */
candidate
->
sockptr
=
NULL
;
/* not stored for remote candidates */
/* note: candidate username and password are left NULL as stream
level ufrag/password are used */
component
->
remote_candidates
=
g_slist_append
(
component
->
remote_candidates
,
candidate
);
modified_list
=
g_slist_append
(
component
->
remote_candidates
,
candidate
);
if
(
modified_list
)
{
component
->
remote_candidates
=
modified_list
;
agent_signal_new_remote_candidate
(
agent
,
candidate
);
}
else
{
/* error: memory alloc / list */
nice_candidate_free
(
candidate
),
candidate
=
NULL
;
}
}
agent_signal_new_remote_candidate
(
agent
,
candidate
);
return
candidate
;
}
...
...
agent/stream.c
View file @
4ee70c86
...
...
@@ -52,27 +52,12 @@ stream_new (guint n_components)
{
Stream
*
stream
;
guint
n
;
gboolean
errors
=
FALSE
;
GSList
*
modified_list
;
Component
*
component
;
stream
=
g_slice_new0
(
Stream
);
for
(
n
=
0
;
n
<
n_components
;
n
++
)
{
component
=
component_new
(
n
+
1
);
if
(
component
)
{
modified_list
=
g_slist_append
(
stream
->
components
,
component
);
if
(
modified_list
)
stream
->
components
=
modified_list
;
else
errors
=
TRUE
;
}
else
errors
=
TRUE
;
}
if
(
errors
)
{
stream_free
(
stream
);
return
NULL
;
stream
->
components
=
g_slist_append
(
stream
->
components
,
component
);
}
stream
->
n_components
=
n_components
;
...
...
socket/tcp-bsd.c
View file @
4ee70c86
...
...
@@ -91,7 +91,7 @@ nice_tcp_bsd_socket_new (NiceAgent *agent, GMainContext *ctx, NiceAddress *addr)
int
ret
;
struct
sockaddr_storage
name
;
guint
name_len
=
sizeof
(
name
);
NiceSocket
*
sock
=
g_slice_new0
(
NiceSocket
)
;
NiceSocket
*
sock
;
TcpPriv
*
priv
;
if
(
addr
==
NULL
)
{
...
...
@@ -99,6 +99,8 @@ nice_tcp_bsd_socket_new (NiceAgent *agent, GMainContext *ctx, NiceAddress *addr)
return
NULL
;
}
sock
=
g_slice_new0
(
NiceSocket
);
nice_address_copy_to_sockaddr
(
addr
,
(
struct
sockaddr
*
)
&
name
);
if
(
sockfd
==
-
1
)
{
...
...
socket/udp-bsd.c
View file @
4ee70c86
...
...
@@ -73,10 +73,6 @@ nice_udp_bsd_socket_new (NiceAddress *addr)
socklen_t
name_len
=
sizeof
(
name
);
NiceSocket
*
sock
=
g_slice_new0
(
NiceSocket
);
if
(
!
sock
)
{
return
NULL
;
}
if
(
addr
!=
NULL
)
{
nice_address_copy_to_sockaddr
(
addr
,
(
struct
sockaddr
*
)
&
name
);
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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