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
675487c9
Commit
675487c9
authored
Jun 20, 2008
by
Youness Alaoui
Browse files
(WIP) Ported libnice to the new API...
parent
8febb558
Changes
6
Hide whitespace changes
Inline
Side-by-side
agent/Makefile.am
View file @
675487c9
...
...
@@ -72,8 +72,8 @@ check_PROGRAMS = \
test-mainloop
\
test-fullmode
\
test-restart
\
test-fallback
\
test-thread
test-fallback
#
test-thread
dist_check_SCRIPTS
=
\
check-test-fullmode-with-stun.sh
...
...
agent/agent-priv.h
View file @
675487c9
...
...
@@ -48,6 +48,7 @@
#include
"stream.h"
#include
"conncheck.h"
#include
"component.h"
#include
"stun/stunagent.h"
/* XXX: starting from ICE ID-18, Ta SHOULD now be set according
* to session bandwidth -> this is not yet implemented in NICE */
...
...
@@ -93,6 +94,7 @@ struct _NiceAgent
"Determining Role" ID-19) */
GStaticRecMutex
mutex
;
/* Mutex used for thread-safe lib */
NiceCompatibility
compatibility
;
/* property: Compatibility mode */
StunAgent
stun_agent
;
/* STUN agent */
/* XXX: add pointer to internal data struct for ABI-safe extensions */
};
...
...
agent/agent.c
View file @
675487c9
...
...
@@ -399,6 +399,11 @@ nice_agent_init (NiceAgent *agent)
agent
->
keepalive_timer_id
=
0
;
agent
->
compatibility
=
NICE_COMPATIBILITY_ID19
;
stun_agent_init
(
&
agent
->
stun_agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
STUN_COMPATIBILITY_3489BIS
,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS
|
STUN_AGENT_USAGE_USE_FINGERPRINT
);
agent
->
rng
=
nice_rng_new
();
priv_generate_tie_breaker
(
agent
);
...
...
@@ -517,6 +522,18 @@ nice_agent_set_property (
case
PROP_COMPATIBILITY
:
agent
->
compatibility
=
g_value_get_uint
(
value
);
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_ID19
)
{
stun_agent_init
(
&
agent
->
stun_agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
STUN_COMPATIBILITY_3489BIS
,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS
|
STUN_AGENT_USAGE_USE_FINGERPRINT
);
}
else
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
stun_agent_init
(
&
agent
->
stun_agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
STUN_COMPATIBILITY_RFC3489
,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS
|
STUN_AGENT_USAGE_IGNORE_CREDENTIALS
);
}
break
;
case
PROP_STUN_SERVER
:
...
...
@@ -1260,7 +1277,7 @@ _nice_agent_recv (
}
/* step: validate using the new STUN API */
/* - note: old check '((buf[0] & 0xc0) == 0)' */
else
if
(
stun_
validate
((
uint8_t
*
)
buf
,
len
)
>
0
)
{
else
if
(
stun_
message_validate_buffer_length
((
uint8_t
*
)
buf
,
(
size_t
)
len
)
==
len
)
{
/* If the retval is no 0, its not a valid stun packet, probably data */
conn_check_handle_inbound_stun
(
agent
,
stream
,
component
,
udp_socket
,
&
from
,
buf
,
len
);
...
...
agent/agent.h
View file @
675487c9
...
...
@@ -46,6 +46,7 @@
#include
"candidate.h"
#include
"random.h"
G_BEGIN_DECLS
#define NICE_TYPE_AGENT nice_agent_get_type()
...
...
agent/conncheck.c
View file @
675487c9
...
...
@@ -1564,6 +1564,8 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream, Compo
size_t
rbuf_len
=
sizeof
(
rbuf
);
bool
control
=
agent
->
controlling_mode
;
gchar
uname
[
NICE_STREAM_MAX_UNAME
];
StunMessage
req
;
StunMessage
msg
;
nice_address_copy_to_sockaddr
(
from
,
&
sockaddr
);
g_snprintf
(
uname
,
sizeof
(
uname
),
"%s:%s"
,
stream
->
local_ufrag
,
...
...
@@ -1576,9 +1578,10 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream, Compo
/* note: ICE 7.2. "STUN Server Procedures" (ID-19) */
res
=
stun_conncheck_reply
(
rbuf
,
&
rbuf_len
,
(
const
uint8_t
*
)
buf
,
&
sockaddr
,
sizeof
(
sockaddr
),
stream
->
local_ufrag
,
stream
->
local_password
,
&
control
,
agent
->
tie_breaker
,
agent
->
compatibility
);
res
=
stun_conncheck_reply
(
&
agent
->
stun_agent
,
&
req
,
(
uint8_t
*
)
buf
,
(
size_t
)
len
,
&
msg
,
rbuf
,
&
rbuf_len
,
&
sockaddr
,
sizeof
(
sockaddr
),
(
uint8_t
*
)
stream
->
local_ufrag
,
strlen
(
stream
->
local_ufrag
),
(
uint8_t
*
)
stream
->
local_password
,
strlen
(
stream
->
local_password
),
&
control
,
agent
->
tie_breaker
,
agent
->
compatibility
);
if
(
res
==
EACCES
)
priv_check_for_role_conflict
(
agent
,
control
);
...
...
@@ -1588,8 +1591,8 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream, Compo
GSList
*
i
;
bool
use_candidate
=
stun_conncheck_use_candidate
(
(
const
uint8_t
*
)
buf
);
uint32_t
priority
=
stun_conncheck_priority
(
(
const
uint8_t
*
)
buf
);
stun_conncheck_use_candidate
(
&
req
);
uint32_t
priority
=
stun_conncheck_priority
(
&
req
);
if
(
agent
->
controlling_mode
||
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
...
...
agent/conncheck.h
View file @
675487c9
...
...
@@ -43,7 +43,8 @@
#include
"agent.h"
#include
"stream.h"
#include
"usages/stun-ice.h"
/* note: the new STUN API */
#include
"stun/usages/stun-ice.h"
#include
"stun/usages/bind.h"
#define NICE_CANDIDATE_PAIR_MAX_FOUNDATION NICE_CANDIDATE_MAX_FOUNDATION*2
...
...
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