Commit 7502f4ed authored by Youness Alaoui's avatar Youness Alaoui

Change all stun_XXX_t enums/structs into StunXxx to have a common naming convention

parent 7a135101
......@@ -1708,8 +1708,8 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
GSList *i;
StunUsageIceReturn res;
gboolean trans_found = FALSE;
stun_transid_t discovery_id;
stun_transid_t response_id;
StunTransactionId discovery_id;
StunTransactionId 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(stun_transid_t)) == 0) {
if (memcmp (discovery_id, response_id, sizeof(StunTransactionId)) == 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;
stun_transid_t discovery_id;
stun_transid_t response_id;
StunTransactionId discovery_id;
StunTransactionId 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(stun_transid_t)) == 0) {
if (memcmp (discovery_id, response_id, sizeof(StunTransactionId)) == 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;
stun_transid_t discovery_id;
stun_transid_t response_id;
StunTransactionId discovery_id;
StunTransactionId 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(stun_transid_t)) == 0) {
if (memcmp (discovery_id, response_id, sizeof(StunTransactionId)) == 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;
stun_transid_t refresh_id;
stun_transid_t response_id;
StunTransactionId refresh_id;
StunTransactionId 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(stun_transid_t)) == 0) {
if (memcmp (refresh_id, response_id, sizeof(StunTransactionId)) == 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.",
......
......@@ -74,7 +74,7 @@ struct _CandidateCheckPair
gboolean controlling;
guint64 priority;
GTimeVal next_tick; /* next tick timestamp */
stun_timer_t timer;
StunTimer timer;
uint8_t stun_buffer[STUN_MAX_MESSAGE_SIZE];
StunMessage stun_message;
};
......
......@@ -56,7 +56,7 @@ typedef struct
StunAgent stun_agent;
uint8_t *msn_turn_username;
uint8_t *msn_turn_password;
stun_timer_t timer;
StunTimer 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;
stun_timer_t timer;
StunTimer timer;
uint8_t stun_buffer[STUN_MAX_MESSAGE_SIZE];
StunMessage stun_message;
uint8_t stun_resp_buffer[STUN_MAX_MESSAGE_SIZE];
......
......@@ -56,7 +56,7 @@
typedef struct {
StunMessage message;
uint8_t buffer[STUN_MAX_MESSAGE_SIZE];
stun_timer_t timer;
StunTimer 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) {
stun_transid_t request_id;
stun_transid_t response_id;
StunTransactionId request_id;
StunTransactionId 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(stun_transid_t)) == 0) {
if (memcmp (request_id, response_id, sizeof(StunTransactionId)) == 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) {
stun_transid_t request_id;
stun_transid_t response_id;
StunTransactionId request_id;
StunTransactionId 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(stun_transid_t)) == 0) {
if (memcmp (request_id, response_id, sizeof(StunTransactionId)) == 0) {
if (stun_message_get_class (&msg) == STUN_ERROR) {
int code = -1;
uint8_t *sent_realm = NULL;
......
......@@ -72,7 +72,7 @@ uint32_t stun_fingerprint (const uint8_t *msg, size_t len)
bool stun_has_cookie (const StunMessage *msg)
{
stun_transid_t id;
StunTransactionId id;
uint32_t cookie = htonl (STUN_MAGIC_COOKIE);
stun_message_id (msg, id);
return memcmp (id, &cookie, sizeof (cookie)) == 0;
......
......@@ -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)
{
stun_transid_t msg_id;
StunTransactionId 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(stun_transid_t)) == 0) {
sizeof(StunTransactionId)) == 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, stun_method_t m)
uint8_t *buffer, size_t buffer_len, StunMethod m)
{
bool ret;
stun_transid_t id;
StunTransactionId 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, stun_method_t m)
uint8_t *buffer, size_t buffer_len, StunMethod m)
{
bool ret;
stun_transid_t id;
StunTransactionId 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)
{
stun_transid_t id;
StunTransactionId 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,
stun_error_t err)
StunError err)
{
stun_transid_t id;
StunTransactionId 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;
stun_transid_t id;
StunTransactionId 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(stun_transid_t));
memcpy (agent->sent_ids[i].id, id, sizeof(StunTransactionId));
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;
......
......@@ -97,8 +97,8 @@ typedef enum {
typedef struct {
stun_transid_t id;
stun_method_t method;
StunTransactionId id;
StunMethod 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, stun_method_t m);
uint8_t *buffer, size_t buffer_len, StunMethod m);
bool stun_agent_init_indication (StunAgent *agent, StunMessage *msg,
uint8_t *buffer, size_t buffer_len, stun_method_t m);
uint8_t *buffer, size_t buffer_len, StunMethod 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,
stun_error_t err);
StunError err);
size_t stun_agent_build_unknown_attributes_error (StunAgent *agent,
StunMessage *msg, uint8_t *buffer, size_t buffer_len,
const StunMessage *request);
......
......@@ -117,7 +117,7 @@ void stun_hash_creds (const uint8_t *realm, size_t realm_len,
}
void stun_make_transid (stun_transid_t id)
void stun_make_transid (StunTransactionId id)
{
RAND_bytes (id, 16);
}
......@@ -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 (stun_transid_t id);
void stun_make_transid (StunTransactionId id);
#endif /* _STUN_HMAC_H */
......@@ -51,8 +51,8 @@
#include <string.h>
#include <stdlib.h>
bool stun_message_init (StunMessage *msg, stun_class_t c, stun_method_t m,
const stun_transid_t id)
bool stun_message_init (StunMessage *msg, StunClass c, StunMethod m,
const StunTransactionId 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, stun_attr_type_t type,
stun_message_find (const StunMessage *msg, StunAttribute 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, stun_attr_type_t type)
stun_message_find_flag (const StunMessage *msg, StunAttribute 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, stun_attr_type_t type,
stun_message_find32 (const StunMessage *msg, StunAttribute 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, stun_attr_type_t type,
stun_message_find64 (const StunMessage *msg, StunAttribute 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, stun_attr_type_t type,
stun_message_find_string (const StunMessage *msg, StunAttribute 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, stun_attr_type_t type,
stun_message_find_addr (const StunMessage *msg, StunAttribute 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, stun_attr_type_t type,
stun_message_find_xor_addr (const StunMessage *msg, StunAttribute 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, stun_attr_type_t type,
stun_message_find_xor_addr_full (const StunMessage *msg, StunAttribute 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, stun_attr_type_t type, size_t length)
stun_message_append (StunMessage *msg, StunAttribute 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, stun_attr_type_t type,
stun_message_append_bytes (StunMessage *msg, StunAttribute 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, stun_attr_type_t type)
stun_message_append_flag (StunMessage *msg, StunAttribute type)
{
return stun_message_append_bytes (msg, type, NULL, 0);
}
StunMessageReturn
stun_message_append32 (StunMessage *msg, stun_attr_type_t type,
stun_message_append32 (StunMessage *msg, StunAttribute 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, stun_attr_type_t type,
stun_message_append64 (StunMessage *msg, StunAttribute 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, stun_attr_type_t type,
stun_message_append_string (StunMessage * msg, StunAttribute type,
const char *str)
{
return stun_message_append_bytes (msg, type, str, strlen (str));
}
StunMessageReturn
stun_message_append_addr (StunMessage *msg, stun_attr_type_t type,
stun_message_append_addr (StunMessage *msg, StunAttribute 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, stun_attr_type_t type,
stun_message_append_xor_addr (StunMessage *msg, StunAttribute 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, stun_attr_type_t type,
stun_message_append_xor_addr_full (StunMessage *msg, StunAttribute 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, stun_error_t code)
stun_message_append_error (StunMessage *msg, StunError 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, stun_transid_t id)
void stun_message_id (const StunMessage *msg, StunTransactionId 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)
*/
stun_method_t stun_message_get_method (const StunMessage *msg)
StunMethod 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 (stun_method_t)(((t & 0x3e00) >> 2) | ((t & 0x00e0) >> 1) |
return (StunMethod)(((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)
*/
stun_class_t stun_message_get_class (const StunMessage *msg)
StunClass 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 (stun_class_t)(((t & 0x0100) >> 7) | ((t & 0x0010) >> 4));
return (StunClass)(((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, stun_attr_type_t type)
bool stun_message_has_attribute (const StunMessage *msg, StunAttribute type)
{
uint16_t dummy;
return stun_message_find (msg, type, &dummy) != NULL;
......
......@@ -57,7 +57,7 @@
typedef struct stun_message_t StunMessage;
/**
* stun_class_t:
* StunClass:
* @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
} stun_class_t;
} StunClass;
/**
* stun_method_t:
* StunMethod:
* @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 */
} stun_method_t;
} StunMethod;
/**
* stun_attr_type_t:
* StunAttribute:
*
* @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 */
} stun_attr_type_t;
} StunAttribute;
/**
* STUN_ALL_KNOWN_ATTRIBUTES:
*
* An array containing all the currently known and defined mandatory attributes
* from stun_attr_type_t
* from StunAttribute
*/
/* Should be in sync with stun_attr_type_t */
/* Should be in sync with StunAttribute */
static const uint16_t STUN_ALL_KNOWN_ATTRIBUTES[] =
{
STUN_ATTRIBUTE_MAPPED_ADDRESS,
......@@ -325,14 +325,14 @@ static const uint16_t STUN_ALL_KNOWN_ATTRIBUTES[] =
};
/**
* stun_transid_t:
* StunTransactionId:
* A type that holds a STUN transaction id.
*/
typedef uint8_t stun_transid_t[STUN_MESSAGE_TRANS_ID_LEN];
typedef uint8_t StunTransactionId[STUN_MESSAGE_TRANS_ID_LEN];
/**
* stun_error_t:
* StunError:
* @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
} stun_error_t;
} StunError;
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, stun_class_t c, stun_method_t m,
const stun_transid_t id);
bool stun_message_init (StunMessage *msg, StunClass c, StunMethod m,
const StunTransactionId 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, stun_attr_type_t type,
const void * stun_message_find (const StunMessage * msg, StunAttribute 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,
stun_attr_type_t type);
StunAttribute 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,
stun_attr_type_t type, uint32_t *pval);
StunAttribute 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,
stun_attr_type_t type, uint64_t *pval);
StunAttribute type, uint64_t *pval);
/**
* Extracts an UTF-8 string from a valid STUN message.
......@@ -502,7 +502,7 @@ StunMessageReturn stun_message_find64 (const StunMessage *msg,
* @note A nul-byte is appended at the end.
*/
StunMessageReturn stun_message_find_string (const StunMessage *msg,
stun_attr_type_t type, char *buf, size_t buflen);
StunAttribute type, char *buf, size_t buflen);
/**
* Extracts a network address attribute from a valid STUN message.
......@@ -517,7 +517,7 @@ StunMessageReturn stun_message_find_string (const StunMessage *msg,
* EAFNOSUPPORT if address family is unknown.
*/
StunMessageReturn stun_message_find_addr (const StunMessage *msg,
stun_attr_type_t type, struct sockaddr *addr, socklen_t *addrlen);
StunAttribute type, struct sockaddr *addr, socklen_t *addrlen);
/**
* Extracts an obfuscated network address attribute from a valid STUN message.
......@@ -532,20 +532,20 @@ StunMessageReturn stun_message_find_addr (const StunMessage *msg,
* EAFNOSUPPORT if address family is unknown.
*/
StunMessageReturn stun_message_find_xor_addr (const StunMessage *msg,
stun_attr_type_t type, struct sockaddr *addr, socklen_t *addrlen);
StunAttribute type, struct sockaddr *addr, socklen_t *addrlen);
StunMessageReturn stun_message_find_xor_addr_full (const StunMessage *msg,
stun_attr_type_t type, struct sockaddr *addr,
StunAttribute type, struct sockaddr *addr,
socklen_t *addrlen, uint32_t magic_cookie);
StunMessageReturn stun_message_find_error (const StunMessage *msg, int *code);
void *stun_message_append (StunMessage *msg, stun_attr_type_t type,
void *stun_message_append (StunMessage *msg, StunAttribute type,
size_t length);
StunMessageReturn stun_message_append_bytes (StunMessage *msg,
stun_attr_type_t type, const void *data, size_t len);
StunAttribute type, const void *data, size_t len);
/**
* Appends an empty ("flag") attribute to a STUN message.
......@@ -555,7 +555,7 @@ StunMessageReturn stun_message_append_bytes (StunMessage *msg,
* @return 0 on success, ENOBUFS on error.
*/
StunMessageReturn stun_message_append_flag (StunMessage *msg,
stun_attr_type_t type);
StunAttribute type);
/**
* Appends an attribute consisting of a 32-bits value to a STUN message.
......@@ -566,7 +566,7 @@ StunMessageReturn stun_message_append_flag (StunMessage *msg,
* @return 0 on success, ENOBUFS on error.
*/
StunMessageReturn stun_message_append32 (StunMessage *msg,
stun_attr_type_t type, uint32_t value);
StunAttribute type, uint32_t value);
/**
* Appends an attribute consisting of a 64-bits value to a STUN message.
......@@ -577,7 +577,7 @@ StunMessageReturn stun_message_append32 (StunMessage *msg,
* @return 0 on success, ENOBUFS on error.
*/
StunMessageReturn stun_message_append64 (StunMessage *msg,
stun_attr_type_t type, uint64_t value);
StunAttribute type, uint64_t value);
/**
* Appends an attribute from a nul-terminated string.
......@@ -588,7 +588,7 @@ StunMessageReturn stun_message_append64 (StunMessage *msg,
* @return 0 on success, ENOBUFS on error.
*/
StunMessageReturn stun_message_append_string (StunMessage *msg,
stun_attr_type_t type, const char *str);
StunAttribute type, const char *str);
/**
* Appends an attribute consisting of a network address to a STUN message.
......@@ -602,7 +602,7 @@ StunMessageReturn stun_message_append_string (StunMessage *msg,
* EINVAL if the socket address length is too small w.r.t. the address family.
*/
StunMessageReturn stun_message_append_addr (StunMessage * msg,
stun_attr_type_t type, const struct sockaddr *addr, socklen_t addrlen);
StunAttribute type, const struct sockaddr *addr, socklen_t addrlen);
/**
* Appends an attribute consisting of a xor'ed network address.
......@@ -616,10 +616,10 @@ StunMessageReturn stun_message_append_addr (StunMessage * msg,
* EINVAL if the socket address length is too small w.r.t. the address family.
*/
StunMessageReturn stun_message_append_xor_addr (StunMessage * msg,
stun_attr_type_t type, const struct sockaddr *addr, socklen_t addrlen);
StunAttribute type, const struct sockaddr *addr, socklen_t addrlen);
StunMessageReturn stun_message_append_xor_addr_full (StunMessage * msg,
stun_attr_type_t type, const struct sockaddr *addr, socklen_t addrlen,
StunAttribute type, const struct sockaddr *addr, socklen_t addrlen,
uint32_t magic_cookie);
/**
......@@ -630,7 +630,7 @@ StunMessageReturn stun_message_append_xor_addr_full (StunMessage * msg,
* @return 0 on success, or ENOBUFS otherwise
*/
StunMessageReturn stun_message_append_error (StunMessage * msg,
stun_error_t code);
StunError code);
#define STUN_MESSAGE_BUFFER_INCOMPLETE 0
#define STUN_MESSAGE_BUFFER_INVALID -1
......@@ -638,10 +638,10 @@ StunMessageReturn stun_message_append_error (StunMessage * msg,
int stun_message_validate_buffer_length (const uint8_t *msg, size_t length);
void stun_message_id (const StunMessage *msg, stun_transid_t id);
void stun_message_id (const StunMessage *msg, StunTransactionId id);
stun_class_t stun_message_get_class (const StunMessage *msg);
stun_method_t stun_message_get_method (const StunMessage *msg);
bool stun_message_has_attribute (const StunMessage *msg, stun_attr_type_t type);