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
bbd1d93e
Commit
bbd1d93e
authored
Aug 23, 2010
by
Marcus Lundblad
Committed by
Youness Alaoui
Dec 14, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remaining changes for RFC 5766
parent
a58b6e00
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
465 additions
and
47 deletions
+465
-47
agent/interfaces.c
agent/interfaces.c
+1
-1
socket/turn.c
socket/turn.c
+376
-32
socket/turn.h
socket/turn.h
+1
-0
stun/stunagent.c
stun/stunagent.c
+5
-1
stun/stunmessage.c
stun/stunmessage.c
+0
-1
stun/tests/test-turn.c
stun/tests/test-turn.c
+1
-1
stun/usages/turn.c
stun/usages/turn.c
+56
-5
stun/usages/turn.h
stun/usages/turn.h
+18
-1
tests/test-fullmode.c
tests/test-fullmode.c
+7
-5
No files found.
agent/interfaces.c
View file @
bbd1d93e
...
@@ -172,7 +172,7 @@ nice_interfaces_get_local_ips (gboolean include_loopback)
...
@@ -172,7 +172,7 @@ nice_interfaces_get_local_ips (gboolean include_loopback)
GList
*
ips
=
NULL
;
GList
*
ips
=
NULL
;
struct
ifaddrs
*
ifa
,
*
results
;
struct
ifaddrs
*
ifa
,
*
results
;
GList
*
loopbacks
=
NULL
;
GList
*
loopbacks
=
NULL
;
int
ret
;
if
(
getifaddrs
(
&
results
)
<
0
)
if
(
getifaddrs
(
&
results
)
<
0
)
return
NULL
;
return
NULL
;
...
...
socket/turn.c
View file @
bbd1d93e
This diff is collapsed.
Click to expand it.
socket/turn.h
View file @
bbd1d93e
...
@@ -43,6 +43,7 @@ typedef enum {
...
@@ -43,6 +43,7 @@ typedef enum {
NICE_TURN_SOCKET_COMPATIBILITY_GOOGLE
,
NICE_TURN_SOCKET_COMPATIBILITY_GOOGLE
,
NICE_TURN_SOCKET_COMPATIBILITY_MSN
,
NICE_TURN_SOCKET_COMPATIBILITY_MSN
,
NICE_TURN_SOCKET_COMPATIBILITY_OC2007
,
NICE_TURN_SOCKET_COMPATIBILITY_OC2007
,
NICE_TURN_SOCKET_COMPATIBILITY_RFC5766
,
}
NiceTurnSocketCompatibility
;
}
NiceTurnSocketCompatibility
;
#include "socket.h"
#include "socket.h"
...
...
stun/stunagent.c
View file @
bbd1d93e
...
@@ -43,6 +43,7 @@
...
@@ -43,6 +43,7 @@
#include "stunhmac.h"
#include "stunhmac.h"
#include "stun5389.h"
#include "stun5389.h"
#include "utils.h"
#include "utils.h"
#include "debug.h"
#include <string.h>
#include <string.h>
#include <stdlib.h>
#include <stdlib.h>
...
@@ -548,6 +549,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
...
@@ -548,6 +549,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
STUN_ATTRIBUTE_REALM
,
&
realm_len
);
STUN_ATTRIBUTE_REALM
,
&
realm_len
);
username
=
(
uint8_t
*
)
stun_message_find
(
msg
,
username
=
(
uint8_t
*
)
stun_message_find
(
msg
,
STUN_ATTRIBUTE_USERNAME
,
&
username_len
);
STUN_ATTRIBUTE_USERNAME
,
&
username_len
);
if
(
username
==
NULL
||
realm
==
NULL
)
{
if
(
username
==
NULL
||
realm
==
NULL
)
{
skip
=
TRUE
;
skip
=
TRUE
;
}
else
{
}
else
{
...
@@ -640,6 +642,8 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
...
@@ -640,6 +642,8 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
msg
->
key
=
(
uint8_t
*
)
key
;
msg
->
key
=
(
uint8_t
*
)
key
;
msg
->
key_len
=
key_len
;
msg
->
key_len
=
key_len
;
stun_debug
(
"stun_agent_finish_message, returning lenght: %d
\n
"
,
stun_message_length
(
msg
));
return
stun_message_length
(
msg
);
return
stun_message_length
(
msg
);
}
}
...
...
stun/stunmessage.c
View file @
bbd1d93e
...
@@ -59,7 +59,6 @@
...
@@ -59,7 +59,6 @@
bool
stun_message_init
(
StunMessage
*
msg
,
StunClass
c
,
StunMethod
m
,
bool
stun_message_init
(
StunMessage
*
msg
,
StunClass
c
,
StunMethod
m
,
const
StunTransactionId
id
)
const
StunTransactionId
id
)
{
{
if
(
msg
->
buffer_len
<
STUN_MESSAGE_HEADER_LENGTH
)
if
(
msg
->
buffer_len
<
STUN_MESSAGE_HEADER_LENGTH
)
return
FALSE
;
return
FALSE
;
...
...
stun/tests/test-turn.c
View file @
bbd1d93e
...
@@ -238,7 +238,7 @@ static void test_turn (char *username, char *password, char *hostname, int port)
...
@@ -238,7 +238,7 @@ static void test_turn (char *username, char *password, char *hostname, int port)
static
void
turnserver
(
void
)
static
void
turnserver
(
void
)
{
{
test_turn
(
"
toto"
,
"password"
,
"127.0.0.1"
,
"3478
"
);
test_turn
(
"
anonymous"
,
"anonymous"
,
"91.121.109.155"
,
"3480
"
);
}
}
static
void
numb
(
void
)
static
void
numb
(
void
)
...
...
stun/usages/turn.c
View file @
bbd1d93e
...
@@ -79,7 +79,8 @@ size_t stun_usage_turn_create (StunAgent *agent, StunMessage *msg,
...
@@ -79,7 +79,8 @@ size_t stun_usage_turn_create (StunAgent *agent, StunMessage *msg,
{
{
stun_agent_init_request
(
agent
,
msg
,
buffer
,
buffer_len
,
STUN_ALLOCATE
);
stun_agent_init_request
(
agent
,
msg
,
buffer
,
buffer_len
,
STUN_ALLOCATE
);
if
(
compatibility
==
STUN_USAGE_TURN_COMPATIBILITY_DRAFT9
)
{
if
(
compatibility
==
STUN_USAGE_TURN_COMPATIBILITY_DRAFT9
||
compatibility
==
STUN_USAGE_TURN_COMPATIBILITY_RFC5766
)
{
if
(
stun_message_append32
(
msg
,
STUN_ATTRIBUTE_REQUESTED_TRANSPORT
,
if
(
stun_message_append32
(
msg
,
STUN_ATTRIBUTE_REQUESTED_TRANSPORT
,
TURN_REQUESTED_TRANSPORT_UDP
)
!=
STUN_MESSAGE_RETURN_SUCCESS
)
TURN_REQUESTED_TRANSPORT_UDP
)
!=
STUN_MESSAGE_RETURN_SUCCESS
)
return
0
;
return
0
;
...
@@ -104,7 +105,8 @@ size_t stun_usage_turn_create (StunAgent *agent, StunMessage *msg,
...
@@ -104,7 +105,8 @@ size_t stun_usage_turn_create (StunAgent *agent, StunMessage *msg,
return
0
;
return
0
;
}
}
if
(
compatibility
==
STUN_USAGE_TURN_COMPATIBILITY_DRAFT9
&&
if
((
compatibility
==
STUN_USAGE_TURN_COMPATIBILITY_DRAFT9
||
compatibility
==
STUN_USAGE_TURN_COMPATIBILITY_RFC5766
)
&&
request_props
!=
STUN_USAGE_TURN_REQUEST_PORT_NORMAL
)
{
request_props
!=
STUN_USAGE_TURN_REQUEST_PORT_NORMAL
)
{
uint32_t
req
=
0
;
uint32_t
req
=
0
;
...
@@ -166,7 +168,8 @@ size_t stun_usage_turn_create_refresh (StunAgent *agent, StunMessage *msg,
...
@@ -166,7 +168,8 @@ size_t stun_usage_turn_create_refresh (StunAgent *agent, StunMessage *msg,
StunUsageTurnCompatibility
compatibility
)
StunUsageTurnCompatibility
compatibility
)
{
{
if
(
compatibility
!=
STUN_USAGE_TURN_COMPATIBILITY_DRAFT9
)
{
if
(
compatibility
!=
STUN_USAGE_TURN_COMPATIBILITY_DRAFT9
&&
compatibility
!=
STUN_USAGE_TURN_COMPATIBILITY_RFC5766
)
{
return
stun_usage_turn_create
(
agent
,
msg
,
buffer
,
buffer_len
,
return
stun_usage_turn_create
(
agent
,
msg
,
buffer
,
buffer_len
,
previous_response
,
STUN_USAGE_TURN_REQUEST_PORT_NORMAL
,
0
,
lifetime
,
previous_response
,
STUN_USAGE_TURN_REQUEST_PORT_NORMAL
,
0
,
lifetime
,
username
,
username_len
,
password
,
password_len
,
compatibility
);
username
,
username_len
,
password
,
password_len
,
compatibility
);
...
@@ -211,6 +214,52 @@ size_t stun_usage_turn_create_refresh (StunAgent *agent, StunMessage *msg,
...
@@ -211,6 +214,52 @@ size_t stun_usage_turn_create_refresh (StunAgent *agent, StunMessage *msg,
return
stun_agent_finish_message
(
agent
,
msg
,
password
,
password_len
);
return
stun_agent_finish_message
(
agent
,
msg
,
password
,
password_len
);
}
}
size_t
stun_usage_turn_create_permission
(
StunAgent
*
agent
,
StunMessage
*
msg
,
uint8_t
*
buffer
,
size_t
buffer_len
,
uint8_t
*
username
,
size_t
username_len
,
uint8_t
*
password
,
size_t
password_len
,
uint8_t
*
realm
,
size_t
realm_len
,
uint8_t
*
nonce
,
size_t
nonce_len
,
struct
sockaddr
*
peer
,
StunUsageTurnCompatibility
compatibility
)
{
stun_agent_init_request
(
agent
,
msg
,
buffer
,
buffer_len
,
STUN_CREATEPERMISSION
);
/* PEER address */
if
(
peer
)
{
if
(
stun_message_append_xor_addr
(
msg
,
STUN_ATTRIBUTE_XOR_PEER_ADDRESS
,
peer
,
sizeof
(
*
peer
))
!=
STUN_MESSAGE_RETURN_SUCCESS
)
{
return
0
;
}
}
/* nonce */
if
(
nonce
!=
NULL
)
{
if
(
stun_message_append_bytes
(
msg
,
STUN_ATTRIBUTE_NONCE
,
nonce
,
nonce_len
)
!=
STUN_MESSAGE_RETURN_SUCCESS
)
return
0
;
}
/* realm */
if
(
realm
!=
NULL
)
{
if
(
stun_message_append_bytes
(
msg
,
STUN_ATTRIBUTE_REALM
,
realm
,
realm_len
)
!=
STUN_MESSAGE_RETURN_SUCCESS
)
return
0
;
}
/* username */
if
(
username
!=
NULL
)
{
if
(
stun_message_append_bytes
(
msg
,
STUN_ATTRIBUTE_USERNAME
,
username
,
username_len
)
!=
STUN_MESSAGE_RETURN_SUCCESS
)
return
0
;
}
stun_debug
(
"before stun_agent_finish_message
\n
"
);
return
stun_agent_finish_message
(
agent
,
msg
,
password
,
password_len
);
}
StunUsageTurnReturn
stun_usage_turn_process
(
StunMessage
*
msg
,
StunUsageTurnReturn
stun_usage_turn_process
(
StunMessage
*
msg
,
struct
sockaddr
*
relay_addr
,
socklen_t
*
relay_addrlen
,
struct
sockaddr
*
relay_addr
,
socklen_t
*
relay_addrlen
,
struct
sockaddr
*
addr
,
socklen_t
*
addrlen
,
struct
sockaddr
*
addr
,
socklen_t
*
addrlen
,
...
@@ -269,7 +318,8 @@ StunUsageTurnReturn stun_usage_turn_process (StunMessage *msg,
...
@@ -269,7 +318,8 @@ StunUsageTurnReturn stun_usage_turn_process (StunMessage *msg,
stun_debug
(
"Received %u-bytes STUN message
\n
"
,
stun_message_length
(
msg
));
stun_debug
(
"Received %u-bytes STUN message
\n
"
,
stun_message_length
(
msg
));
if
(
compatibility
==
STUN_USAGE_TURN_COMPATIBILITY_DRAFT9
)
{
if
(
compatibility
==
STUN_USAGE_TURN_COMPATIBILITY_DRAFT9
||
compatibility
==
STUN_USAGE_TURN_COMPATIBILITY_RFC5766
)
{
val
=
stun_message_find_xor_addr
(
msg
,
val
=
stun_message_find_xor_addr
(
msg
,
STUN_ATTRIBUTE_XOR_MAPPED_ADDRESS
,
addr
,
addrlen
);
STUN_ATTRIBUTE_XOR_MAPPED_ADDRESS
,
addr
,
addrlen
);
...
@@ -320,7 +370,8 @@ StunUsageTurnReturn stun_usage_turn_refresh_process (StunMessage *msg,
...
@@ -320,7 +370,8 @@ StunUsageTurnReturn stun_usage_turn_refresh_process (StunMessage *msg,
int
code
=
-
1
;
int
code
=
-
1
;
StunUsageTurnReturn
ret
=
STUN_USAGE_TURN_RETURN_RELAY_SUCCESS
;
StunUsageTurnReturn
ret
=
STUN_USAGE_TURN_RETURN_RELAY_SUCCESS
;
if
(
compatibility
==
STUN_USAGE_TURN_COMPATIBILITY_DRAFT9
)
{
if
(
compatibility
==
STUN_USAGE_TURN_COMPATIBILITY_DRAFT9
||
compatibility
==
STUN_USAGE_TURN_COMPATIBILITY_RFC5766
)
{
if
(
stun_message_get_method
(
msg
)
!=
STUN_REFRESH
)
if
(
stun_message_get_method
(
msg
)
!=
STUN_REFRESH
)
return
STUN_USAGE_TURN_RETURN_INVALID
;
return
STUN_USAGE_TURN_RETURN_INVALID
;
}
else
{
}
else
{
...
...
stun/usages/turn.h
View file @
bbd1d93e
...
@@ -59,8 +59,14 @@
...
@@ -59,8 +59,14 @@
# include <stdint.h>
# include <stdint.h>
#endif
#endif
# include "stun/stunagent.h"
#ifdef _WIN32
#include <winsock2.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#endif
# include "stun/stunagent.h"
# ifdef __cplusplus
# ifdef __cplusplus
extern
"C"
{
extern
"C"
{
# endif
# endif
...
@@ -97,6 +103,7 @@ typedef enum {
...
@@ -97,6 +103,7 @@ typedef enum {
STUN_USAGE_TURN_COMPATIBILITY_GOOGLE
,
STUN_USAGE_TURN_COMPATIBILITY_GOOGLE
,
STUN_USAGE_TURN_COMPATIBILITY_MSN
,
STUN_USAGE_TURN_COMPATIBILITY_MSN
,
STUN_USAGE_TURN_COMPATIBILITY_OC2007
STUN_USAGE_TURN_COMPATIBILITY_OC2007
STUN_USAGE_TURN_COMPATIBILITY_RFC5766
,
}
StunUsageTurnCompatibility
;
}
StunUsageTurnCompatibility
;
/**
/**
...
@@ -197,6 +204,16 @@ size_t stun_usage_turn_create_refresh (StunAgent *agent, StunMessage *msg,
...
@@ -197,6 +204,16 @@ size_t stun_usage_turn_create_refresh (StunAgent *agent, StunMessage *msg,
uint8_t
*
password
,
size_t
password_len
,
uint8_t
*
password
,
size_t
password_len
,
StunUsageTurnCompatibility
compatibility
);
StunUsageTurnCompatibility
compatibility
);
size_t
stun_usage_turn_create_permission
(
StunAgent
*
agent
,
StunMessage
*
msg
,
uint8_t
*
buffer
,
size_t
buffer_len
,
uint8_t
*
username
,
size_t
username_len
,
uint8_t
*
password
,
size_t
password_len
,
uint8_t
*
realm
,
size_t
realm_len
,
uint8_t
*
nonce
,
size_t
nonce_len
,
struct
sockaddr
*
peer
,
StunUsageTurnCompatibility
compatibility
);
/**
/**
* stun_usage_turn_process:
* stun_usage_turn_process:
* @msg: The message containing the response
* @msg: The message containing the response
...
...
tests/test-fullmode.c
View file @
bbd1d93e
...
@@ -44,9 +44,10 @@
...
@@ -44,9 +44,10 @@
#include <string.h>
#include <string.h>
#define USE_TURN
0
#define USE_TURN
1
#define USE_LOOPBACK 1
#define USE_LOOPBACK 1
#define TEST_GOOGLE 0
#define TEST_GOOGLE 0
#define USE_TURN_SERVER_ORG 1
#define PROXY_IP "127.0.0.1"
#define PROXY_IP "127.0.0.1"
#define PROXY_PORT 1080
#define PROXY_PORT 1080
...
@@ -85,10 +86,10 @@
...
@@ -85,10 +86,10 @@
#define NUMB_USER "youness.alaoui@collabora.co.uk"
#define NUMB_USER "youness.alaoui@collabora.co.uk"
#define NUMB_PASS "badger"
#define NUMB_PASS "badger"
#define TSORG_IP "
127.0.0.1
"
#define TSORG_IP "
91.121.109.155
"
#define TSORG_PORT 34
78
#define TSORG_PORT 34
80
#define TSORG_USER "
toto
"
#define TSORG_USER "
anonymous
"
#define TSORG_PASS "
password
"
#define TSORG_PASS "
anonymous
"
#if USE_TURN_SERVER_ORG
#if USE_TURN_SERVER_ORG
...
@@ -348,6 +349,7 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
...
@@ -348,6 +349,7 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
g_assert
(
ls_id
>
0
);
g_assert
(
ls_id
>
0
);
g_assert
(
rs_id
>
0
);
g_assert
(
rs_id
>
0
);
#if USE_TURN
#if USE_TURN
nice_debug
(
"TURN_IP: %s
\n
"
,
TURN_IP
);
nice_agent_set_relay_info
(
lagent
,
ls_id
,
1
,
nice_agent_set_relay_info
(
lagent
,
ls_id
,
1
,
TURN_IP
,
TURN_PORT
,
TURN_USER
,
TURN_PASS
,
TURN_TYPE
);
TURN_IP
,
TURN_PORT
,
TURN_USER
,
TURN_PASS
,
TURN_TYPE
);
nice_agent_set_relay_info
(
lagent
,
ls_id
,
2
,
nice_agent_set_relay_info
(
lagent
,
ls_id
,
2
,
...
...
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