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
4c8e1f40
Commit
4c8e1f40
authored
Aug 05, 2008
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add full TURN support for the turn usage allocate request
parent
0c08c052
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
5 deletions
+76
-5
stun/usages/turn.c
stun/usages/turn.c
+56
-2
stun/usages/turn.h
stun/usages/turn.h
+20
-3
No files found.
stun/usages/turn.c
View file @
4c8e1f40
...
...
@@ -50,16 +50,70 @@
#include <sys/time.h>
#include <fcntl.h>
/** Non-blocking mode STUN TURN usage */
size_t
stun_usage_turn_create
(
StunAgent
*
agent
,
StunMessage
*
msg
,
uint8_t
*
buffer
,
size_t
buffer_len
,
StunMessage
*
previous_request
,
uint32_t
request_ports
,
uint32_t
bandwidth
,
uint32_t
lifetime
,
uint8_t
*
username
,
size_t
username_len
,
uint8_t
*
password
,
size_t
password_len
,
uint8_t
*
buffer
,
size_t
buffer_len
)
StunUsageTurnCompatibility
compatibility
)
{
stun_agent_init_request
(
agent
,
msg
,
buffer
,
buffer_len
,
STUN_ALLOCATE
);
if
(
compatibility
==
STUN_USAGE_TURN_COMPATIBILITY_TD9
)
{
if
(
bandwidth
>
0
)
{
if
(
stun_message_append32
(
msg
,
STUN_ATTRIBUTE_BANDWIDTH
,
bandwidth
)
!=
0
)
return
0
;
}
if
(
lifetime
>
0
)
{
if
(
stun_message_append32
(
msg
,
STUN_ATTRIBUTE_LIFETIME
,
lifetime
)
!=
0
)
return
0
;
}
}
else
{
if
(
stun_message_append32
(
msg
,
STUN_ATTRIBUTE_MAGIC_COOKIE
,
TURN_MAGIC_COOKIE
)
!=
0
)
return
0
;
}
#if 0
if (request_ports != STUN_USAGE_TURN_REQUEST_PORT_NORMAL) {
uint32_t req = 0;
if (compatibility == STUN_USAGE_TURN_COMPATIBILITY_TD9) {
}
if (stun_message_append32 (msg, STUN_ATTRIBUTE_REQUESTED_PORT_PROPS,
req) != 0)
return 0;
}
#endif
if
(
previous_request
)
{
char
realm
[
100
];
char
nonce
[
100
];
uint64_t
reservation
;
if
(
stun_message_find_string
(
previous_request
,
STUN_ATTRIBUTE_REALM
,
realm
,
sizeof
(
realm
))
==
0
)
{
if
(
stun_message_append_string
(
msg
,
STUN_ATTRIBUTE_REALM
,
realm
)
!=
0
)
return
0
;
}
if
(
stun_message_find_string
(
previous_request
,
STUN_ATTRIBUTE_NONCE
,
nonce
,
sizeof
(
nonce
))
==
0
)
{
if
(
stun_message_append_string
(
msg
,
STUN_ATTRIBUTE_NONCE
,
nonce
)
!=
0
)
return
0
;
}
if
(
stun_message_find64
(
previous_request
,
STUN_ATTRIBUTE_RESERVATION_TOKEN
,
&
reservation
)
==
0
)
{
if
(
stun_message_append64
(
msg
,
STUN_ATTRIBUTE_RESERVATION_TOKEN
,
reservation
)
!=
0
)
return
0
;
}
}
if
(
username
!=
NULL
&&
username_len
>
0
)
{
if
(
stun_message_append_bytes
(
msg
,
STUN_ATTRIBUTE_USERNAME
,
username
,
username_len
)
!=
0
)
...
...
stun/usages/turn.h
View file @
4c8e1f40
...
...
@@ -33,8 +33,8 @@
* file under either the MPL or the LGPL.
*/
#ifndef STUN_
BIND
_H
# define STUN_
BIND
_H 1
#ifndef STUN_
TURN
_H
# define STUN_
TURN
_H 1
/**
* @file bind.h
...
...
@@ -50,6 +50,19 @@
extern
"C"
{
# endif
#define STUN_USAGE_TURN_REQUEST_PORT_NORMAL 0
#define STUN_USAGE_TURN_REQUEST_PORT_ODD 1
#define STUN_USAGE_TURN_REQUEST_PORT_EVEN 2
#define STUN_USAGE_TURN_REQUEST_PORT_BOTH 4
#define STUN_USAGE_TURN_REQUEST_PORT_PRESERVING 8
typedef
enum
{
STUN_USAGE_TURN_COMPATIBILITY_TD9
,
STUN_USAGE_TURN_COMPATIBILITY_GOOGLE
,
STUN_USAGE_TURN_COMPATIBILITY_MSN
,
}
StunUsageTurnCompatibility
;
typedef
enum
{
STUN_USAGE_TURN_RETURN_SUCCESS
,
STUN_USAGE_TURN_RETURN_ERROR
,
...
...
@@ -59,9 +72,13 @@ typedef enum {
size_t
stun_usage_turn_create
(
StunAgent
*
agent
,
StunMessage
*
msg
,
uint8_t
*
buffer
,
size_t
buffer_len
,
StunMessage
*
previous_request
,
uint32_t
request_ports
,
uint32_t
bandwidth
,
uint32_t
lifetime
,
uint8_t
*
username
,
size_t
username_len
,
uint8_t
*
password
,
size_t
password_len
,
uint8_t
*
buffer
,
size_t
buffer_len
);
StunUsageTurnCompatibility
compatibility
);
StunUsageTurnReturn
stun_usage_turn_process
(
StunMessage
*
msg
,
struct
sockaddr
*
addr
,
socklen_t
*
addrlen
,
...
...
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