Skip to content
GitLab
Menu
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
7502f4ed
Commit
7502f4ed
authored
Feb 16, 2009
by
Youness Alaoui
Browse files
Change all stun_XXX_t enums/structs into StunXxx to have a common naming convention
parent
7a135101
Changes
19
Hide whitespace changes
Inline
Side-by-side
agent/conncheck.c
View file @
7502f4ed
...
...
@@ -1708,8 +1708,8 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
GSList
*
i
;
StunUsageIceReturn
res
;
gboolean
trans_found
=
FALSE
;
s
tun
_t
rans
id_t
discovery_id
;
s
tun
_t
rans
id_t
response_id
;
S
tun
T
rans
actionId
discovery_id
;
S
tun
T
rans
actionId
response_id
;
stun_message_id
(
resp
,
response_id
);
for
(
i
=
stream
->
conncheck_list
;
i
&&
trans_found
!=
TRUE
;
i
=
i
->
next
)
{
...
...
@@ -1718,7 +1718,7 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
if
(
p
->
stun_message
.
buffer
)
{
stun_message_id
(
&
p
->
stun_message
,
discovery_id
);
if
(
memcmp
(
discovery_id
,
response_id
,
sizeof
(
s
tun
_t
rans
id_t
))
==
0
)
{
if
(
memcmp
(
discovery_id
,
response_id
,
sizeof
(
S
tun
T
rans
actionId
))
==
0
)
{
res
=
stun_usage_ice_conncheck_process
(
resp
,
&
sockaddr
,
&
socklen
,
agent_to_ice_compatibility
(
agent
));
nice_debug
(
"Agent %p : stun_bind_process/conncheck for %p res %d "
...
...
@@ -1828,8 +1828,8 @@ static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, StunMessa
GSList
*
i
;
StunUsageBindReturn
res
;
gboolean
trans_found
=
FALSE
;
s
tun
_t
rans
id_t
discovery_id
;
s
tun
_t
rans
id_t
response_id
;
S
tun
T
rans
actionId
discovery_id
;
S
tun
T
rans
actionId
response_id
;
stun_message_id
(
resp
,
response_id
);
for
(
i
=
agent
->
discovery_list
;
i
&&
trans_found
!=
TRUE
;
i
=
i
->
next
)
{
...
...
@@ -1839,7 +1839,7 @@ static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, StunMessa
d
->
stun_message
.
buffer
)
{
stun_message_id
(
&
d
->
stun_message
,
discovery_id
);
if
(
memcmp
(
discovery_id
,
response_id
,
sizeof
(
s
tun
_t
rans
id_t
))
==
0
)
{
if
(
memcmp
(
discovery_id
,
response_id
,
sizeof
(
S
tun
T
rans
actionId
))
==
0
)
{
res
=
stun_usage_bind_process
(
resp
,
&
sockaddr
,
&
socklen
,
&
alternate
,
&
alternatelen
);
nice_debug
(
"Agent %p : stun_bind_process/disc for %p res %d."
,
...
...
@@ -1940,8 +1940,8 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
GSList
*
i
;
StunUsageTurnReturn
res
;
gboolean
trans_found
=
FALSE
;
s
tun
_t
rans
id_t
discovery_id
;
s
tun
_t
rans
id_t
response_id
;
S
tun
T
rans
actionId
discovery_id
;
S
tun
T
rans
actionId
response_id
;
stun_message_id
(
resp
,
response_id
);
for
(
i
=
agent
->
discovery_list
;
i
&&
trans_found
!=
TRUE
;
i
=
i
->
next
)
{
...
...
@@ -1951,7 +1951,7 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
d
->
stun_message
.
buffer
)
{
stun_message_id
(
&
d
->
stun_message
,
discovery_id
);
if
(
memcmp
(
discovery_id
,
response_id
,
sizeof
(
s
tun
_t
rans
id_t
))
==
0
)
{
if
(
memcmp
(
discovery_id
,
response_id
,
sizeof
(
S
tun
T
rans
actionId
))
==
0
)
{
res
=
stun_usage_turn_process
(
resp
,
&
relayaddr
,
&
relayaddrlen
,
&
sockaddr
,
&
socklen
,
&
alternate
,
&
alternatelen
,
&
bandwidth
,
&
lifetime
,
agent_to_turn_compatibility
(
agent
));
...
...
@@ -2062,8 +2062,8 @@ static gboolean priv_map_reply_to_relay_refresh (NiceAgent *agent, StunMessage *
GSList
*
i
;
StunUsageTurnReturn
res
;
gboolean
trans_found
=
FALSE
;
s
tun
_t
rans
id_t
refresh_id
;
s
tun
_t
rans
id_t
response_id
;
S
tun
T
rans
actionId
refresh_id
;
S
tun
T
rans
actionId
response_id
;
stun_message_id
(
resp
,
response_id
);
for
(
i
=
agent
->
refresh_list
;
i
&&
trans_found
!=
TRUE
;
i
=
i
->
next
)
{
...
...
@@ -2072,7 +2072,7 @@ static gboolean priv_map_reply_to_relay_refresh (NiceAgent *agent, StunMessage *
if
(
cand
->
stun_message
.
buffer
)
{
stun_message_id
(
&
cand
->
stun_message
,
refresh_id
);
if
(
memcmp
(
refresh_id
,
response_id
,
sizeof
(
s
tun
_t
rans
id_t
))
==
0
)
{
if
(
memcmp
(
refresh_id
,
response_id
,
sizeof
(
S
tun
T
rans
actionId
))
==
0
)
{
res
=
stun_usage_turn_refresh_process
(
resp
,
&
lifetime
,
agent_to_turn_compatibility
(
cand
->
agent
));
nice_debug
(
"Agent %p : stun_turn_refresh_process for %p res %d."
,
...
...
agent/conncheck.h
View file @
7502f4ed
...
...
@@ -74,7 +74,7 @@ struct _CandidateCheckPair
gboolean
controlling
;
guint64
priority
;
GTimeVal
next_tick
;
/* next tick timestamp */
s
tun
_t
imer
_t
timer
;
S
tun
T
imer
timer
;
uint8_t
stun_buffer
[
STUN_MAX_MESSAGE_SIZE
];
StunMessage
stun_message
;
};
...
...
agent/discovery.h
View file @
7502f4ed
...
...
@@ -56,7 +56,7 @@ typedef struct
StunAgent
stun_agent
;
uint8_t
*
msn_turn_username
;
uint8_t
*
msn_turn_password
;
s
tun
_t
imer
_t
timer
;
S
tun
T
imer
timer
;
uint8_t
stun_buffer
[
STUN_MAX_MESSAGE_SIZE
];
StunMessage
stun_message
;
uint8_t
stun_resp_buffer
[
STUN_MAX_MESSAGE_SIZE
];
...
...
@@ -77,7 +77,7 @@ typedef struct
GSource
*
tick_source
;
uint8_t
*
msn_turn_username
;
uint8_t
*
msn_turn_password
;
s
tun
_t
imer
_t
timer
;
S
tun
T
imer
timer
;
uint8_t
stun_buffer
[
STUN_MAX_MESSAGE_SIZE
];
StunMessage
stun_message
;
uint8_t
stun_resp_buffer
[
STUN_MAX_MESSAGE_SIZE
];
...
...
socket/turn.c
View file @
7502f4ed
...
...
@@ -56,7 +56,7 @@
typedef
struct
{
StunMessage
message
;
uint8_t
buffer
[
STUN_MAX_MESSAGE_SIZE
];
s
tun
_t
imer
_t
timer
;
S
tun
T
imer
timer
;
}
TURNMessage
;
...
...
@@ -339,12 +339,12 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
}
return
0
;
}
else
if
(
stun_message_get_method
(
&
msg
)
==
STUN_OLD_SET_ACTIVE_DST
)
{
s
tun
_t
rans
id_t
request_id
;
s
tun
_t
rans
id_t
response_id
;
S
tun
T
rans
actionId
request_id
;
S
tun
T
rans
actionId
response_id
;
if
(
priv
->
current_binding
&&
priv
->
current_binding_msg
)
{
stun_message_id
(
&
msg
,
response_id
);
stun_message_id
(
&
priv
->
current_binding_msg
->
message
,
request_id
);
if
(
memcmp
(
request_id
,
response_id
,
sizeof
(
s
tun
_t
rans
id_t
))
==
0
)
{
if
(
memcmp
(
request_id
,
response_id
,
sizeof
(
S
tun
T
rans
actionId
))
==
0
)
{
g_free
(
priv
->
current_binding_msg
);
priv
->
current_binding_msg
=
NULL
;
...
...
@@ -360,12 +360,12 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
return
0
;
}
else
if
(
stun_message_get_method
(
&
msg
)
==
STUN_CHANNELBIND
)
{
s
tun
_t
rans
id_t
request_id
;
s
tun
_t
rans
id_t
response_id
;
S
tun
T
rans
actionId
request_id
;
S
tun
T
rans
actionId
response_id
;
if
(
priv
->
current_binding
&&
priv
->
current_binding_msg
)
{
stun_message_id
(
&
msg
,
response_id
);
stun_message_id
(
&
priv
->
current_binding_msg
->
message
,
request_id
);
if
(
memcmp
(
request_id
,
response_id
,
sizeof
(
s
tun
_t
rans
id_t
))
==
0
)
{
if
(
memcmp
(
request_id
,
response_id
,
sizeof
(
S
tun
T
rans
actionId
))
==
0
)
{
if
(
stun_message_get_class
(
&
msg
)
==
STUN_ERROR
)
{
int
code
=
-
1
;
uint8_t
*
sent_realm
=
NULL
;
...
...
stun/stun5389.c
View file @
7502f4ed
...
...
@@ -72,7 +72,7 @@ uint32_t stun_fingerprint (const uint8_t *msg, size_t len)
bool
stun_has_cookie
(
const
StunMessage
*
msg
)
{
s
tun
_t
rans
id_t
id
;
S
tun
T
rans
actionId
id
;
uint32_t
cookie
=
htonl
(
STUN_MAGIC_COOKIE
);
stun_message_id
(
msg
,
id
);
return
memcmp
(
id
,
&
cookie
,
sizeof
(
cookie
))
==
0
;
...
...
stun/stunagent.c
View file @
7502f4ed
...
...
@@ -94,7 +94,7 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
const
uint8_t
*
buffer
,
size_t
buffer_len
,
StunMessageIntegrityValidate
validater
,
void
*
validater_data
)
{
s
tun
_t
rans
id_t
msg_id
;
S
tun
T
rans
actionId
msg_id
;
uint32_t
fpr
;
uint32_t
crc32
;
int
len
;
...
...
@@ -170,7 +170,7 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
if
(
agent
->
sent_ids
[
sent_id_idx
].
valid
==
TRUE
&&
agent
->
sent_ids
[
sent_id_idx
].
method
==
stun_message_get_method
(
msg
)
&&
memcmp
(
msg_id
,
agent
->
sent_ids
[
sent_id_idx
].
id
,
sizeof
(
s
tun
_t
rans
id_t
))
==
0
)
{
sizeof
(
S
tun
T
rans
actionId
))
==
0
)
{
key
=
agent
->
sent_ids
[
sent_id_idx
].
key
;
key_len
=
agent
->
sent_ids
[
sent_id_idx
].
key_len
;
...
...
@@ -323,10 +323,10 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
bool
stun_agent_init_request
(
StunAgent
*
agent
,
StunMessage
*
msg
,
uint8_t
*
buffer
,
size_t
buffer_len
,
s
tun
_m
ethod
_t
m
)
uint8_t
*
buffer
,
size_t
buffer_len
,
S
tun
M
ethod
m
)
{
bool
ret
;
s
tun
_t
rans
id_t
id
;
S
tun
T
rans
actionId
id
;
msg
->
buffer
=
buffer
;
msg
->
buffer_len
=
buffer_len
;
...
...
@@ -352,10 +352,10 @@ bool stun_agent_init_request (StunAgent *agent, StunMessage *msg,
bool
stun_agent_init_indication
(
StunAgent
*
agent
,
StunMessage
*
msg
,
uint8_t
*
buffer
,
size_t
buffer_len
,
s
tun
_m
ethod
_t
m
)
uint8_t
*
buffer
,
size_t
buffer_len
,
S
tun
M
ethod
m
)
{
bool
ret
;
s
tun
_t
rans
id_t
id
;
S
tun
T
rans
actionId
id
;
msg
->
buffer
=
buffer
;
msg
->
buffer_len
=
buffer_len
;
...
...
@@ -383,7 +383,7 @@ bool stun_agent_init_response (StunAgent *agent, StunMessage *msg,
uint8_t
*
buffer
,
size_t
buffer_len
,
const
StunMessage
*
request
)
{
s
tun
_t
rans
id_t
id
;
S
tun
T
rans
actionId
id
;
if
(
stun_message_get_class
(
request
)
!=
STUN_REQUEST
)
{
return
FALSE
;
...
...
@@ -416,9 +416,9 @@ bool stun_agent_init_response (StunAgent *agent, StunMessage *msg,
bool
stun_agent_init_error
(
StunAgent
*
agent
,
StunMessage
*
msg
,
uint8_t
*
buffer
,
size_t
buffer_len
,
const
StunMessage
*
request
,
s
tun
_e
rror
_t
err
)
S
tun
E
rror
err
)
{
s
tun
_t
rans
id_t
id
;
S
tun
T
rans
actionId
id
;
if
(
stun_message_get_class
(
request
)
!=
STUN_REQUEST
)
{
return
FALSE
;
...
...
@@ -488,7 +488,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
uint8_t
*
ptr
;
uint32_t
fpr
;
int
i
;
s
tun
_t
rans
id_t
id
;
S
tun
T
rans
actionId
id
;
uint8_t
md5
[
16
];
if
(
msg
->
key
!=
NULL
)
{
...
...
@@ -596,7 +596,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
for
(
i
=
0
;
i
<
STUN_AGENT_MAX_SAVED_IDS
;
i
++
)
{
if
(
agent
->
sent_ids
[
i
].
valid
==
FALSE
)
{
stun_message_id
(
msg
,
id
);
memcpy
(
agent
->
sent_ids
[
i
].
id
,
id
,
sizeof
(
s
tun
_t
rans
id_t
));
memcpy
(
agent
->
sent_ids
[
i
].
id
,
id
,
sizeof
(
S
tun
T
rans
actionId
));
agent
->
sent_ids
[
i
].
method
=
stun_message_get_method
(
msg
);
agent
->
sent_ids
[
i
].
key
=
(
uint8_t
*
)
key
;
agent
->
sent_ids
[
i
].
key_len
=
key_len
;
...
...
stun/stunagent.h
View file @
7502f4ed
...
...
@@ -97,8 +97,8 @@ typedef enum {
typedef
struct
{
s
tun
_t
rans
id_t
id
;
s
tun
_m
ethod
_t
method
;
S
tun
T
rans
actionId
id
;
S
tun
M
ethod
method
;
uint8_t
*
key
;
size_t
key_len
;
uint8_t
long_term_key
[
16
];
...
...
@@ -135,14 +135,14 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
const
uint8_t
*
buffer
,
size_t
buffer_len
,
StunMessageIntegrityValidate
validater
,
void
*
validater_data
);
bool
stun_agent_init_request
(
StunAgent
*
agent
,
StunMessage
*
msg
,
uint8_t
*
buffer
,
size_t
buffer_len
,
s
tun
_m
ethod
_t
m
);
uint8_t
*
buffer
,
size_t
buffer_len
,
S
tun
M
ethod
m
);
bool
stun_agent_init_indication
(
StunAgent
*
agent
,
StunMessage
*
msg
,
uint8_t
*
buffer
,
size_t
buffer_len
,
s
tun
_m
ethod
_t
m
);
uint8_t
*
buffer
,
size_t
buffer_len
,
S
tun
M
ethod
m
);
bool
stun_agent_init_response
(
StunAgent
*
agent
,
StunMessage
*
msg
,
uint8_t
*
buffer
,
size_t
buffer_len
,
const
StunMessage
*
request
);
bool
stun_agent_init_error
(
StunAgent
*
agent
,
StunMessage
*
msg
,
uint8_t
*
buffer
,
size_t
buffer_len
,
const
StunMessage
*
request
,
s
tun
_e
rror
_t
err
);
S
tun
E
rror
err
);
size_t
stun_agent_build_unknown_attributes_error
(
StunAgent
*
agent
,
StunMessage
*
msg
,
uint8_t
*
buffer
,
size_t
buffer_len
,
const
StunMessage
*
request
);
...
...
stun/stunhmac.c
View file @
7502f4ed
...
...
@@ -117,7 +117,7 @@ void stun_hash_creds (const uint8_t *realm, size_t realm_len,
}
void
stun_make_transid
(
s
tun
_t
rans
id_t
id
)
void
stun_make_transid
(
S
tun
T
rans
actionId
id
)
{
RAND_bytes
(
id
,
16
);
}
stun/stunhmac.h
View file @
7502f4ed
...
...
@@ -62,7 +62,7 @@ void stun_hash_creds (const uint8_t *realm, size_t realm_len,
/**
* Generates a pseudo-random secure STUN transaction ID.
*/
void
stun_make_transid
(
s
tun
_t
rans
id_t
id
);
void
stun_make_transid
(
S
tun
T
rans
actionId
id
);
#endif
/* _STUN_HMAC_H */
stun/stunmessage.c
View file @
7502f4ed
...
...
@@ -51,8 +51,8 @@
#include <string.h>
#include <stdlib.h>
bool
stun_message_init
(
StunMessage
*
msg
,
s
tun
_c
lass
_t
c
,
s
tun
_m
ethod
_t
m
,
const
s
tun
_t
rans
id_t
id
)
bool
stun_message_init
(
StunMessage
*
msg
,
S
tun
C
lass
c
,
S
tun
M
ethod
m
,
const
S
tun
T
rans
actionId
id
)
{
if
(
msg
->
buffer_len
<
STUN_MESSAGE_HEADER_LENGTH
)
...
...
@@ -77,7 +77,7 @@ uint16_t stun_message_length (const StunMessage *msg)
const
void
*
stun_message_find
(
const
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
stun_message_find
(
const
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
uint16_t
*
palen
)
{
size_t
length
=
stun_message_length
(
msg
);
...
...
@@ -122,7 +122,7 @@ stun_message_find (const StunMessage *msg, stun_attr_type_t type,
StunMessageReturn
stun_message_find_flag
(
const
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
)
stun_message_find_flag
(
const
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
)
{
const
void
*
ptr
;
uint16_t
len
;
...
...
@@ -136,7 +136,7 @@ stun_message_find_flag (const StunMessage *msg, stun_attr_type_t type)
StunMessageReturn
stun_message_find32
(
const
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
stun_message_find32
(
const
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
uint32_t
*
pval
)
{
const
void
*
ptr
;
...
...
@@ -159,7 +159,7 @@ stun_message_find32 (const StunMessage *msg, stun_attr_type_t type,
StunMessageReturn
stun_message_find64
(
const
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
stun_message_find64
(
const
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
uint64_t
*
pval
)
{
const
void
*
ptr
;
...
...
@@ -182,7 +182,7 @@ stun_message_find64 (const StunMessage *msg, stun_attr_type_t type,
StunMessageReturn
stun_message_find_string
(
const
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
stun_message_find_string
(
const
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
char
*
buf
,
size_t
buflen
)
{
const
unsigned
char
*
ptr
;
...
...
@@ -202,7 +202,7 @@ stun_message_find_string (const StunMessage *msg, stun_attr_type_t type,
StunMessageReturn
stun_message_find_addr
(
const
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
stun_message_find_addr
(
const
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
struct
sockaddr
*
addr
,
socklen_t
*
addrlen
)
{
const
uint8_t
*
ptr
;
...
...
@@ -262,7 +262,7 @@ stun_message_find_addr (const StunMessage *msg, stun_attr_type_t type,
}
StunMessageReturn
stun_message_find_xor_addr
(
const
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
stun_message_find_xor_addr
(
const
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
struct
sockaddr
*
addr
,
socklen_t
*
addrlen
)
{
...
...
@@ -274,7 +274,7 @@ stun_message_find_xor_addr (const StunMessage *msg, stun_attr_type_t type,
}
StunMessageReturn
stun_message_find_xor_addr_full
(
const
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
stun_message_find_xor_addr_full
(
const
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
struct
sockaddr
*
addr
,
socklen_t
*
addrlen
,
uint32_t
magic_cookie
)
{
...
...
@@ -318,7 +318,7 @@ stun_message_find_error (const StunMessage *msg, int *code)
* 32-bits boundary.
*/
void
*
stun_message_append
(
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
size_t
length
)
stun_message_append
(
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
size_t
length
)
{
uint8_t
*
a
;
uint16_t
mlen
=
stun_message_length
(
msg
);
...
...
@@ -353,7 +353,7 @@ stun_message_append (StunMessage *msg, stun_attr_type_t type, size_t length)
* @return 0 on success, ENOBUFS on error.
*/
StunMessageReturn
stun_message_append_bytes
(
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
stun_message_append_bytes
(
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
const
void
*
data
,
size_t
len
)
{
void
*
ptr
=
stun_message_append
(
msg
,
type
,
len
);
...
...
@@ -366,14 +366,14 @@ stun_message_append_bytes (StunMessage *msg, stun_attr_type_t type,
StunMessageReturn
stun_message_append_flag
(
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
)
stun_message_append_flag
(
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
)
{
return
stun_message_append_bytes
(
msg
,
type
,
NULL
,
0
);
}
StunMessageReturn
stun_message_append32
(
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
stun_message_append32
(
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
uint32_t
value
)
{
value
=
htonl
(
value
);
...
...
@@ -382,7 +382,7 @@ stun_message_append32 (StunMessage *msg, stun_attr_type_t type,
StunMessageReturn
stun_message_append64
(
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
stun_message_append64
(
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
uint64_t
value
)
{
uint32_t
tab
[
2
];
...
...
@@ -393,14 +393,14 @@ stun_message_append64 (StunMessage *msg, stun_attr_type_t type,
StunMessageReturn
stun_message_append_string
(
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
stun_message_append_string
(
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
const
char
*
str
)
{
return
stun_message_append_bytes
(
msg
,
type
,
str
,
strlen
(
str
));
}
StunMessageReturn
stun_message_append_addr
(
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
stun_message_append_addr
(
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
)
{
const
void
*
pa
;
...
...
@@ -453,7 +453,7 @@ stun_message_append_addr (StunMessage *msg, stun_attr_type_t type,
StunMessageReturn
stun_message_append_xor_addr
(
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
stun_message_append_xor_addr
(
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
)
{
StunMessageReturn
val
;
...
...
@@ -474,7 +474,7 @@ stun_message_append_xor_addr (StunMessage *msg, stun_attr_type_t type,
}
StunMessageReturn
stun_message_append_xor_addr_full
(
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
stun_message_append_xor_addr_full
(
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
,
uint32_t
magic_cookie
)
{
...
...
@@ -504,7 +504,7 @@ stun_message_append_xor_addr_full (StunMessage *msg, stun_attr_type_t type,
* @return 0 on success, or ENOBUFS otherwise
*/
StunMessageReturn
stun_message_append_error
(
StunMessage
*
msg
,
s
tun
_e
rror
_t
code
)
stun_message_append_error
(
StunMessage
*
msg
,
S
tun
E
rror
code
)
{
const
char
*
str
=
stun_strerror
(
code
);
size_t
len
=
strlen
(
str
);
...
...
@@ -589,7 +589,7 @@ int stun_message_validate_buffer_length (const uint8_t *msg, size_t length)
/**
* copies STUN message transaction ID
*/
void
stun_message_id
(
const
StunMessage
*
msg
,
s
tun
_t
rans
id_t
id
)
void
stun_message_id
(
const
StunMessage
*
msg
,
S
tun
T
rans
actionId
id
)
{
memcpy
(
id
,
msg
->
buffer
+
STUN_MESSAGE_TRANS_ID_POS
,
STUN_MESSAGE_TRANS_ID_LEN
);
}
...
...
@@ -597,7 +597,7 @@ void stun_message_id (const StunMessage *msg, stun_transid_t id)
/**
* @return STUN message method (value from 0 to 0xfff)
*/
s
tun
_m
ethod
_t
stun_message_get_method
(
const
StunMessage
*
msg
)
S
tun
M
ethod
stun_message_get_method
(
const
StunMessage
*
msg
)
{
uint16_t
t
=
stun_getw
(
msg
->
buffer
);
/* HACK HACK HACK
...
...
@@ -610,7 +610,7 @@ stun_method_t stun_message_get_method (const StunMessage *msg)
method doesn't exist anymore */
if
(
t
==
0x0115
)
t
=
0x0017
;
return
(
s
tun
_m
ethod
_t
)(((
t
&
0x3e00
)
>>
2
)
|
((
t
&
0x00e0
)
>>
1
)
|
return
(
S
tun
M
ethod
)(((
t
&
0x3e00
)
>>
2
)
|
((
t
&
0x00e0
)
>>
1
)
|
(
t
&
0x000f
));
}
...
...
@@ -618,7 +618,7 @@ stun_method_t stun_message_get_method (const StunMessage *msg)
/**
* @return STUN message class in host byte order (value from 0 to 3)
*/
s
tun
_c
lass
_t
stun_message_get_class
(
const
StunMessage
*
msg
)
S
tun
C
lass
stun_message_get_class
(
const
StunMessage
*
msg
)
{
uint16_t
t
=
stun_getw
(
msg
->
buffer
);
/* HACK HACK HACK
...
...
@@ -631,7 +631,7 @@ stun_class_t stun_message_get_class (const StunMessage *msg)
method doesn't exist anymore */
if
(
t
==
0x0115
)
t
=
0x0017
;
return
(
s
tun
_c
lass
_t
)(((
t
&
0x0100
)
>>
7
)
|
((
t
&
0x0010
)
>>
4
));
return
(
S
tun
C
lass
)(((
t
&
0x0100
)
>>
7
)
|
((
t
&
0x0010
)
>>
4
));
}
/**
...
...
@@ -642,7 +642,7 @@ stun_class_t stun_message_get_class (const StunMessage *msg)
*
* @return whether there is a MESSAGE-INTEGRITY attribute
*/
bool
stun_message_has_attribute
(
const
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
)
bool
stun_message_has_attribute
(
const
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
)
{
uint16_t
dummy
;
return
stun_message_find
(
msg
,
type
,
&
dummy
)
!=
NULL
;
...
...
stun/stunmessage.h
View file @
7502f4ed
...
...
@@ -57,7 +57,7 @@
typedef
struct
stun_message_t
StunMessage
;
/**
*
s
tun
_c
lass
_t
:
*
S
tun
C
lass:
* @STUN_REQUEST: A STUN Request message
* @STUN_INDICATION: A STUN indication message
* @STUN_RESPONSE: A STUN Response message
...
...
@@ -74,11 +74,11 @@ typedef enum
STUN_INDICATION
=
1
,
STUN_RESPONSE
=
2
,
STUN_ERROR
=
3
}
s
tun
_c
lass
_t
;
}
S
tun
C
lass
;
/**
*
s
tun
_m
ethod
_t
:
*
S
tun
M
ethod:
* @STUN_BINDING: The Binding method as defined by the RFC5389
* @STUN_SHARED_SECRET: The Shared-Secret method as defined by the RFC3489
* @STUN_ALLOCATE: The Allocate method as defined by the TURN draft 12
...
...
@@ -118,10 +118,10 @@ typedef enum
STUN_IND_CONNECT_STATUS
=
0x008
,
/* TURN-04 */
STUN_CREATEPERMISSION
=
0x008
,
/* TURN-12 */
STUN_CHANNELBIND
=
0x009
/* TURN-12 */
}
s
tun
_m
ethod
_t
;
}
S
tun
M
ethod
;
/**
*
s
tun
_a
ttr
_type_t
:
*
S
tun
A
ttr
ibute
:
*
* @STUN_ATTRIBUTE_MAPPED_ADDRESS: The MAPPED-ADDRESS attribute as defined
* by RFC5389
...
...
@@ -271,16 +271,16 @@ typedef enum
STUN_ATTRIBUTE_ICE_CONTROLLED
=
0x8029
,
/* ICE-19 */
STUN_ATTRIBUTE_ICE_CONTROLLING
=
0x802A
,
/* ICE-19 */
/* 0x802B-0xFFFF */
/* reserved */
}
s
tun
_a
ttr
_type_t
;
}
S
tun
A
ttr
ibute
;
/**
* STUN_ALL_KNOWN_ATTRIBUTES:
*
* An array containing all the currently known and defined mandatory attributes
* from
s
tun
_a
ttr
_type_t
* from
S
tun
A
ttr
ibute
*/
/* Should be in sync with
s
tun
_a
ttr
_type_t
*/
/* Should be in sync with
S
tun
A
ttr
ibute
*/
static
const
uint16_t
STUN_ALL_KNOWN_ATTRIBUTES
[]
=
{
STUN_ATTRIBUTE_MAPPED_ADDRESS
,
...
...
@@ -325,14 +325,14 @@ static const uint16_t STUN_ALL_KNOWN_ATTRIBUTES[] =
};
/**
*
s
tun
_t
rans
id_t
:
*
S
tun
T
rans
actionId
:
* A type that holds a STUN transaction id.
*/
typedef
uint8_t
s
tun
_t
rans
id_t
[
STUN_MESSAGE_TRANS_ID_LEN
];
typedef
uint8_t
S
tun
T
rans
actionId
[
STUN_MESSAGE_TRANS_ID_LEN
];
/**
*
s
tun
_e
rror
_t
:
*
S
tun
E
rror:
* @STUN_ERROR_TRY_ALTERNATE: The ERROR-CODE value for the
* "Try Alternate" error as defined in RFC5389
* @STUN_ERROR_BAD_REQUEST: The ERROR-CODE value for the
...
...
@@ -397,7 +397,7 @@ typedef enum
STUN_ERROR_SERVER_CAPACITY
=
507
,
/* TURN-04 */
STUN_ERROR_INSUFFICIENT_CAPACITY
=
508
,
/* TURN-12 */
STUN_ERROR_MAX
=
699
}
s
tun
_e
rror
_t
;
}
S
tun
E
rror
;
typedef
enum
...
...
@@ -432,8 +432,8 @@ struct stun_message_t {
* @param id 16-bytes transaction ID
* @return TRUE if the initialization was successful
*/
bool
stun_message_init
(
StunMessage
*
msg
,
s
tun
_c
lass
_t
c
,
s
tun
_m
ethod
_t
m
,
const
s
tun
_t
rans
id_t
id
);
bool
stun_message_init
(
StunMessage
*
msg
,
S
tun
C
lass
c
,
S
tun
M
ethod
m
,
const
S
tun
T
rans
actionId
id
);
/**
* Returns the length of the stun message
...
...
@@ -449,7 +449,7 @@ uint16_t stun_message_length (const StunMessage *msg);
* @return a pointer to the start of the attribute payload if found,
* otherwise NULL.
*/
const
void
*
stun_message_find
(
const
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
const
void
*
stun_message_find
(
const
StunMessage
*
msg
,
S
tun
A
ttr
ibute
type
,
uint16_t
*
palen
);
...
...
@@ -461,7 +461,7 @@ const void * stun_message_find (const StunMessage * msg, stun_attr_type_t type,
* size is not zero.
*/
StunMessageReturn
stun_message_find_flag
(
const
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
);
S
tun
A
ttr
ibute
type
);
/**
* Extracts a 32-bits attribute from a valid STUN message.
...
...
@@ -474,7 +474,7 @@ StunMessageReturn stun_message_find_flag (const StunMessage *msg,
* In case of error, @a *pval is not modified.
*/
StunMessageReturn
stun_message_find32
(
const
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
uint32_t
*
pval
);
S
tun
A
ttr
ibute
type
,
uint32_t
*
pval
);
/**
* Extracts a 64-bits attribute from a valid STUN message.
...
...
@@ -486,7 +486,7 @@ StunMessageReturn stun_message_find32 (const StunMessage *msg,
* In case of error, @a *pval is not modified.
*/
StunMessageReturn
stun_message_find64
(
const
StunMessage
*
msg
,
s
tun
_a
ttr
_type_t
type
,
uint64_t
*
pval
);
S
tun
A
ttr
ibute
type
,
uint64_t
*
pval
);
/**