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 * ...@@ -1708,8 +1708,8 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
GSList *i; GSList *i;
StunUsageIceReturn res; StunUsageIceReturn res;
gboolean trans_found = FALSE; gboolean trans_found = FALSE;
stun_transid_t discovery_id; StunTransactionId discovery_id;
stun_transid_t response_id; StunTransactionId response_id;
stun_message_id (resp, response_id); stun_message_id (resp, response_id);
for (i = stream->conncheck_list; i && trans_found != TRUE; i = i->next) { 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 * ...@@ -1718,7 +1718,7 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
if (p->stun_message.buffer) { if (p->stun_message.buffer) {
stun_message_id (&p->stun_message, discovery_id); 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, res = stun_usage_ice_conncheck_process (resp, &sockaddr, &socklen,
agent_to_ice_compatibility (agent)); agent_to_ice_compatibility (agent));
nice_debug ("Agent %p : stun_bind_process/conncheck for %p res %d " 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 ...@@ -1828,8 +1828,8 @@ static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, StunMessa
GSList *i; GSList *i;
StunUsageBindReturn res; StunUsageBindReturn res;
gboolean trans_found = FALSE; gboolean trans_found = FALSE;
stun_transid_t discovery_id; StunTransactionId discovery_id;
stun_transid_t response_id; StunTransactionId response_id;
stun_message_id (resp, response_id); stun_message_id (resp, response_id);
for (i = agent->discovery_list; i && trans_found != TRUE; i = i->next) { 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 ...@@ -1839,7 +1839,7 @@ static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, StunMessa
d->stun_message.buffer) { d->stun_message.buffer) {
stun_message_id (&d->stun_message, discovery_id); 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, res = stun_usage_bind_process (resp, &sockaddr, &socklen,
&alternate, &alternatelen); &alternate, &alternatelen);
nice_debug ("Agent %p : stun_bind_process/disc for %p res %d.", 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 * ...@@ -1940,8 +1940,8 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
GSList *i; GSList *i;
StunUsageTurnReturn res; StunUsageTurnReturn res;
gboolean trans_found = FALSE; gboolean trans_found = FALSE;
stun_transid_t discovery_id; StunTransactionId discovery_id;
stun_transid_t response_id; StunTransactionId response_id;
stun_message_id (resp, response_id); stun_message_id (resp, response_id);
for (i = agent->discovery_list; i && trans_found != TRUE; i = i->next) { 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 * ...@@ -1951,7 +1951,7 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
d->stun_message.buffer) { d->stun_message.buffer) {
stun_message_id (&d->stun_message, discovery_id); 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, res = stun_usage_turn_process (resp,
&relayaddr, &relayaddrlen, &sockaddr, &socklen, &alternate, &alternatelen, &relayaddr, &relayaddrlen, &sockaddr, &socklen, &alternate, &alternatelen,
&bandwidth, &lifetime, agent_to_turn_compatibility (agent)); &bandwidth, &lifetime, agent_to_turn_compatibility (agent));
...@@ -2062,8 +2062,8 @@ static gboolean priv_map_reply_to_relay_refresh (NiceAgent *agent, StunMessage * ...@@ -2062,8 +2062,8 @@ static gboolean priv_map_reply_to_relay_refresh (NiceAgent *agent, StunMessage *
GSList *i; GSList *i;
StunUsageTurnReturn res; StunUsageTurnReturn res;
gboolean trans_found = FALSE; gboolean trans_found = FALSE;
stun_transid_t refresh_id; StunTransactionId refresh_id;
stun_transid_t response_id; StunTransactionId response_id;
stun_message_id (resp, response_id); stun_message_id (resp, response_id);
for (i = agent->refresh_list; i && trans_found != TRUE; i = i->next) { 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 * ...@@ -2072,7 +2072,7 @@ static gboolean priv_map_reply_to_relay_refresh (NiceAgent *agent, StunMessage *
if (cand->stun_message.buffer) { if (cand->stun_message.buffer) {
stun_message_id (&cand->stun_message, refresh_id); 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, res = stun_usage_turn_refresh_process (resp,
&lifetime, agent_to_turn_compatibility (cand->agent)); &lifetime, agent_to_turn_compatibility (cand->agent));
nice_debug ("Agent %p : stun_turn_refresh_process for %p res %d.", nice_debug ("Agent %p : stun_turn_refresh_process for %p res %d.",
......
...@@ -74,7 +74,7 @@ struct _CandidateCheckPair ...@@ -74,7 +74,7 @@ struct _CandidateCheckPair
gboolean controlling; gboolean controlling;
guint64 priority; guint64 priority;
GTimeVal next_tick; /* next tick timestamp */ GTimeVal next_tick; /* next tick timestamp */
stun_timer_t timer; StunTimer timer;
uint8_t stun_buffer[STUN_MAX_MESSAGE_SIZE]; uint8_t stun_buffer[STUN_MAX_MESSAGE_SIZE];
StunMessage stun_message; StunMessage stun_message;
}; };
......
...@@ -56,7 +56,7 @@ typedef struct ...@@ -56,7 +56,7 @@ typedef struct
StunAgent stun_agent; StunAgent stun_agent;
uint8_t *msn_turn_username; uint8_t *msn_turn_username;
uint8_t *msn_turn_password; uint8_t *msn_turn_password;
stun_timer_t timer; StunTimer timer;
uint8_t stun_buffer[STUN_MAX_MESSAGE_SIZE]; uint8_t stun_buffer[STUN_MAX_MESSAGE_SIZE];
StunMessage stun_message; StunMessage stun_message;
uint8_t stun_resp_buffer[STUN_MAX_MESSAGE_SIZE]; uint8_t stun_resp_buffer[STUN_MAX_MESSAGE_SIZE];
...@@ -77,7 +77,7 @@ typedef struct ...@@ -77,7 +77,7 @@ typedef struct
GSource *tick_source; GSource *tick_source;
uint8_t *msn_turn_username; uint8_t *msn_turn_username;
uint8_t *msn_turn_password; uint8_t *msn_turn_password;
stun_timer_t timer; StunTimer timer;
uint8_t stun_buffer[STUN_MAX_MESSAGE_SIZE]; uint8_t stun_buffer[STUN_MAX_MESSAGE_SIZE];
StunMessage stun_message; StunMessage stun_message;
uint8_t stun_resp_buffer[STUN_MAX_MESSAGE_SIZE]; uint8_t stun_resp_buffer[STUN_MAX_MESSAGE_SIZE];
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
typedef struct { typedef struct {
StunMessage message; StunMessage message;
uint8_t buffer[STUN_MAX_MESSAGE_SIZE]; uint8_t buffer[STUN_MAX_MESSAGE_SIZE];
stun_timer_t timer; StunTimer timer;
} TURNMessage; } TURNMessage;
...@@ -339,12 +339,12 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock, ...@@ -339,12 +339,12 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
} }
return 0; return 0;
} else if (stun_message_get_method (&msg) == STUN_OLD_SET_ACTIVE_DST) { } else if (stun_message_get_method (&msg) == STUN_OLD_SET_ACTIVE_DST) {
stun_transid_t request_id; StunTransactionId request_id;
stun_transid_t response_id; StunTransactionId response_id;
if (priv->current_binding && priv->current_binding_msg) { if (priv->current_binding && priv->current_binding_msg) {
stun_message_id (&msg, response_id); stun_message_id (&msg, response_id);
stun_message_id (&priv->current_binding_msg->message, request_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); g_free (priv->current_binding_msg);
priv->current_binding_msg = NULL; priv->current_binding_msg = NULL;
...@@ -360,12 +360,12 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock, ...@@ -360,12 +360,12 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
return 0; return 0;
} else if (stun_message_get_method (&msg) == STUN_CHANNELBIND) { } else if (stun_message_get_method (&msg) == STUN_CHANNELBIND) {
stun_transid_t request_id; StunTransactionId request_id;
stun_transid_t response_id; StunTransactionId response_id;
if (priv->current_binding && priv->current_binding_msg) { if (priv->current_binding && priv->current_binding_msg) {
stun_message_id (&msg, response_id); stun_message_id (&msg, response_id);
stun_message_id (&priv->current_binding_msg->message, request_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) { if (stun_message_get_class (&msg) == STUN_ERROR) {
int code = -1; int code = -1;
uint8_t *sent_realm = NULL; uint8_t *sent_realm = NULL;
......
...@@ -72,7 +72,7 @@ uint32_t stun_fingerprint (const uint8_t *msg, size_t len) ...@@ -72,7 +72,7 @@ uint32_t stun_fingerprint (const uint8_t *msg, size_t len)
bool stun_has_cookie (const StunMessage *msg) bool stun_has_cookie (const StunMessage *msg)
{ {
stun_transid_t id; StunTransactionId id;
uint32_t cookie = htonl (STUN_MAGIC_COOKIE); uint32_t cookie = htonl (STUN_MAGIC_COOKIE);
stun_message_id (msg, id); stun_message_id (msg, id);
return memcmp (id, &cookie, sizeof (cookie)) == 0; return memcmp (id, &cookie, sizeof (cookie)) == 0;
......
...@@ -94,7 +94,7 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg, ...@@ -94,7 +94,7 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
const uint8_t *buffer, size_t buffer_len, const uint8_t *buffer, size_t buffer_len,
StunMessageIntegrityValidate validater, void * validater_data) StunMessageIntegrityValidate validater, void * validater_data)
{ {
stun_transid_t msg_id; StunTransactionId msg_id;
uint32_t fpr; uint32_t fpr;
uint32_t crc32; uint32_t crc32;
int len; int len;
...@@ -170,7 +170,7 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg, ...@@ -170,7 +170,7 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
if (agent->sent_ids[sent_id_idx].valid == TRUE && if (agent->sent_ids[sent_id_idx].valid == TRUE &&
agent->sent_ids[sent_id_idx].method == stun_message_get_method (msg) && agent->sent_ids[sent_id_idx].method == stun_message_get_method (msg) &&
memcmp (msg_id, agent->sent_ids[sent_id_idx].id, 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 = agent->sent_ids[sent_id_idx].key;
key_len = agent->sent_ids[sent_id_idx].key_len; key_len = agent->sent_ids[sent_id_idx].key_len;
...@@ -323,10 +323,10 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg, ...@@ -323,10 +323,10 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
bool stun_agent_init_request (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; bool ret;
stun_transid_t id; StunTransactionId id;
msg->buffer = buffer; msg->buffer = buffer;
msg->buffer_len = buffer_len; msg->buffer_len = buffer_len;
...@@ -352,10 +352,10 @@ bool stun_agent_init_request (StunAgent *agent, StunMessage *msg, ...@@ -352,10 +352,10 @@ bool stun_agent_init_request (StunAgent *agent, StunMessage *msg,
bool stun_agent_init_indication (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; bool ret;
stun_transid_t id; StunTransactionId id;
msg->buffer = buffer; msg->buffer = buffer;
msg->buffer_len = buffer_len; msg->buffer_len = buffer_len;
...@@ -383,7 +383,7 @@ bool stun_agent_init_response (StunAgent *agent, StunMessage *msg, ...@@ -383,7 +383,7 @@ bool stun_agent_init_response (StunAgent *agent, StunMessage *msg,
uint8_t *buffer, size_t buffer_len, const StunMessage *request) uint8_t *buffer, size_t buffer_len, const StunMessage *request)
{ {
stun_transid_t id; StunTransactionId id;
if (stun_message_get_class (request) != STUN_REQUEST) { if (stun_message_get_class (request) != STUN_REQUEST) {
return FALSE; return FALSE;
...@@ -416,9 +416,9 @@ bool stun_agent_init_response (StunAgent *agent, StunMessage *msg, ...@@ -416,9 +416,9 @@ bool stun_agent_init_response (StunAgent *agent, StunMessage *msg,
bool stun_agent_init_error (StunAgent *agent, StunMessage *msg, bool stun_agent_init_error (StunAgent *agent, StunMessage *msg,
uint8_t *buffer, size_t buffer_len, const StunMessage *request, 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) { if (stun_message_get_class (request) != STUN_REQUEST) {
return FALSE; return FALSE;
...@@ -488,7 +488,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg, ...@@ -488,7 +488,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
uint8_t *ptr; uint8_t *ptr;
uint32_t fpr; uint32_t fpr;
int i; int i;
stun_transid_t id; StunTransactionId id;
uint8_t md5[16]; uint8_t md5[16];
if (msg->key != NULL) { if (msg->key != NULL) {
...@@ -596,7 +596,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg, ...@@ -596,7 +596,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
for (i = 0; i < STUN_AGENT_MAX_SAVED_IDS; i++) { for (i = 0; i < STUN_AGENT_MAX_SAVED_IDS; i++) {
if (agent->sent_ids[i].valid == FALSE) { if (agent->sent_ids[i].valid == FALSE) {
stun_message_id (msg, id); 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].method = stun_message_get_method (msg);
agent->sent_ids[i].key = (uint8_t *) key; agent->sent_ids[i].key = (uint8_t *) key;
agent->sent_ids[i].key_len = key_len; agent->sent_ids[i].key_len = key_len;
......
...@@ -97,8 +97,8 @@ typedef enum { ...@@ -97,8 +97,8 @@ typedef enum {
typedef struct { typedef struct {
stun_transid_t id; StunTransactionId id;
stun_method_t method; StunMethod method;
uint8_t *key; uint8_t *key;
size_t key_len; size_t key_len;
uint8_t long_term_key[16]; uint8_t long_term_key[16];
...@@ -135,14 +135,14 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg, ...@@ -135,14 +135,14 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
const uint8_t *buffer, size_t buffer_len, const uint8_t *buffer, size_t buffer_len,
StunMessageIntegrityValidate validater, void * validater_data); StunMessageIntegrityValidate validater, void * validater_data);
bool stun_agent_init_request (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 stun_agent_init_indication (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 stun_agent_init_response (StunAgent *agent, StunMessage *msg, bool stun_agent_init_response (StunAgent *agent, StunMessage *msg,
uint8_t *buffer, size_t buffer_len, const StunMessage *request); uint8_t *buffer, size_t buffer_len, const StunMessage *request);
bool stun_agent_init_error (StunAgent *agent, StunMessage *msg, bool stun_agent_init_error (StunAgent *agent, StunMessage *msg,
uint8_t *buffer, size_t buffer_len, const StunMessage *request, 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, size_t stun_agent_build_unknown_attributes_error (StunAgent *agent,
StunMessage *msg, uint8_t *buffer, size_t buffer_len, StunMessage *msg, uint8_t *buffer, size_t buffer_len,
const StunMessage *request); const StunMessage *request);
......
...@@ -117,7 +117,7 @@ void stun_hash_creds (const uint8_t *realm, size_t realm_len, ...@@ -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); RAND_bytes (id, 16);
} }
...@@ -62,7 +62,7 @@ void stun_hash_creds (const uint8_t *realm, size_t realm_len, ...@@ -62,7 +62,7 @@ void stun_hash_creds (const uint8_t *realm, size_t realm_len,
/** /**
* Generates a pseudo-random secure STUN transaction ID. * 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 */ #endif /* _STUN_HMAC_H */
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
bool stun_message_init (StunMessage *msg, stun_class_t c, stun_method_t m, bool stun_message_init (StunMessage *msg, StunClass c, StunMethod m,
const stun_transid_t id) const StunTransactionId id)
{ {
if (msg->buffer_len < STUN_MESSAGE_HEADER_LENGTH) if (msg->buffer_len < STUN_MESSAGE_HEADER_LENGTH)
...@@ -77,7 +77,7 @@ uint16_t stun_message_length (const StunMessage *msg) ...@@ -77,7 +77,7 @@ uint16_t stun_message_length (const StunMessage *msg)
const void * const void *
stun_message_find (const StunMessage *msg, stun_attr_type_t type, stun_message_find (const StunMessage *msg, StunAttribute type,
uint16_t *palen) uint16_t *palen)
{ {
size_t length = stun_message_length (msg); size_t length = stun_message_length (msg);
...@@ -122,7 +122,7 @@ stun_message_find (const StunMessage *msg, stun_attr_type_t type, ...@@ -122,7 +122,7 @@ stun_message_find (const StunMessage *msg, stun_attr_type_t type,
StunMessageReturn 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; const void *ptr;
uint16_t len; uint16_t len;
...@@ -136,7 +136,7 @@ stun_message_find_flag (const StunMessage *msg, stun_attr_type_t type) ...@@ -136,7 +136,7 @@ stun_message_find_flag (const StunMessage *msg, stun_attr_type_t type)
StunMessageReturn StunMessageReturn
stun_message_find32 (const StunMessage *msg, stun_attr_type_t type, stun_message_find32 (const StunMessage *msg, StunAttribute type,
uint32_t *pval) uint32_t *pval)
{ {
const void *ptr; const void *ptr;
...@@ -159,7 +159,7 @@ stun_message_find32 (const StunMessage *msg, stun_attr_type_t type, ...@@ -159,7 +159,7 @@ stun_message_find32 (const StunMessage *msg, stun_attr_type_t type,
StunMessageReturn StunMessageReturn
stun_message_find64 (const StunMessage *msg, stun_attr_type_t type, stun_message_find64 (const StunMessage *msg, StunAttribute type,
uint64_t *pval) uint64_t *pval)
{ {
const void *ptr; const void *ptr;
...@@ -182,7 +182,7 @@ stun_message_find64 (const StunMessage *msg, stun_attr_type_t type, ...@@ -182,7 +182,7 @@ stun_message_find64 (const StunMessage *msg, stun_attr_type_t type,
StunMessageReturn 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) char *buf, size_t buflen)
{ {
const unsigned char *ptr; const unsigned char *ptr;
...@@ -202,7 +202,7 @@ stun_message_find_string (const StunMessage *msg, stun_attr_type_t type, ...@@ -202,7 +202,7 @@ stun_message_find_string (const StunMessage *msg, stun_attr_type_t type,
StunMessageReturn 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) struct sockaddr *addr, socklen_t *addrlen)
{ {
const uint8_t *ptr; const uint8_t *ptr;
...@@ -262,7 +262,7 @@ stun_message_find_addr (const StunMessage *msg, stun_attr_type_t type, ...@@ -262,7 +262,7 @@ stun_message_find_addr (const StunMessage *msg, stun_attr_type_t type,
} }
StunMessageReturn 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, struct sockaddr *addr,
socklen_t *addrlen) socklen_t *addrlen)
{ {
...@@ -274,7 +274,7 @@ stun_message_find_xor_addr (const StunMessage *msg, stun_attr_type_t type, ...@@ -274,7 +274,7 @@ stun_message_find_xor_addr (const StunMessage *msg, stun_attr_type_t type,
} }
StunMessageReturn 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, struct sockaddr *addr, socklen_t *addrlen,
uint32_t magic_cookie) uint32_t magic_cookie)
{ {
...@@ -318,7 +318,7 @@ stun_message_find_error (const StunMessage *msg, int *code) ...@@ -318,7 +318,7 @@ stun_message_find_error (const StunMessage *msg, int *code)
* 32-bits boundary. * 32-bits boundary.
*/ */
void * 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; uint8_t *a;
uint16_t mlen = stun_message_length (msg); uint16_t mlen = stun_message_length (msg);
...@@ -353,7 +353,7 @@ stun_message_append (StunMessage *msg, stun_attr_type_t type, size_t length) ...@@ -353,7 +353,7 @@ stun_message_append (StunMessage *msg, stun_attr_type_t type, size_t length)
* @return 0 on success, ENOBUFS on error. * @return 0 on success, ENOBUFS on error.
*/ */
StunMessageReturn 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) const void *data, size_t len)
{ {
void *ptr = stun_message_append (msg, type, len); void *ptr = stun_message_append (msg, type, len);
...@@ -366,14 +366,14 @@ stun_message_append_bytes (StunMessage *msg, stun_attr_type_t type, ...@@ -366,14 +366,14 @@ stun_message_append_bytes (StunMessage *msg, stun_attr_type_t type,
StunMessageReturn 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); return stun_message_append_bytes (msg, type, NULL, 0);
} }
StunMessageReturn StunMessageReturn
stun_message_append32 (StunMessage *msg, stun_attr_type_t type, stun_message_append32 (StunMessage *msg, StunAttribute type,
uint32_t value) uint32_t value)
{ {
value = htonl (value); value = htonl (value);
...@@ -382,7 +382,7 @@ stun_message_append32 (StunMessage *msg, stun_attr_type_t type, ...@@ -382,7 +382,7 @@ stun_message_append32 (StunMessage *msg, stun_attr_type_t type,
StunMessageReturn StunMessageReturn
stun_message_append64 (StunMessage *msg, stun_attr_type_t type, stun_message_append64 (StunMessage *msg, StunAttribute type,
uint64_t value) uint64_t value)
{ {
uint32_t tab[2]; uint32_t tab[2];
...@@ -393,14 +393,14 @@ stun_message_append64 (StunMessage *msg, stun_attr_type_t type, ...@@ -393,14 +393,14 @@ stun_message_append64 (StunMessage *msg, stun_attr_type_t type,
StunMessageReturn StunMessageReturn
stun_message_append_string (StunMessage * msg, stun_attr_type_t type, stun_message_append_string (StunMessage * msg, StunAttribute type,
const char *str) const char *str)
{ {
return stun_message_append_bytes (msg, type, str, strlen (str)); return stun_message_append_bytes (msg, type, str, strlen (str));
} }
StunMessageReturn 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 struct sockaddr *addr, socklen_t addrlen)
{ {
const void *pa; const void *pa;
...@@ -453,7 +453,7 @@ stun_message_append_addr (StunMessage *msg, stun_attr_type_t type, ...@@ -453,7 +453,7 @@ stun_message_append_addr (StunMessage *msg, stun_attr_type_t type,
StunMessageReturn 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) const struct sockaddr *addr, socklen_t addrlen)
{ {
StunMessageReturn val; StunMessageReturn val;
...@@ -474,7 +474,7 @@ stun_message_append_xor_addr (StunMessage *msg, stun_attr_type_t type, ...@@ -474,7 +474,7 @@ stun_message_append_xor_addr (StunMessage *msg, stun_attr_type_t type,
} }
StunMessageReturn 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, const struct sockaddr *addr, socklen_t addrlen,
uint32_t magic_cookie) uint32_t magic_cookie)
{ {
...@@ -504,7 +504,7 @@ stun_message_append_xor_addr_full (StunMessage *msg, stun_attr_type_t type, ...@@ -504,7 +504,7 @@ stun_message_append_xor_addr_full (StunMessage *msg, stun_attr_type_t type,
* @return 0 on success, or ENOBUFS otherwise * @return 0 on success, or ENOBUFS otherwise
*/ */
StunMessageReturn 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); const char *str = stun_strerror (code);
size_t len = strlen (str); size_t len = strlen (str);
...@@ -589,7 +589,7 @@ int stun_message_validate_buffer_length (const uint8_t *msg, size_t length) ...@@ -589,7 +589,7 @@ int stun_message_validate_buffer_length (const uint8_t *msg, size_t length)
/** /**
* copies STUN message transaction ID * 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); 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) ...@@ -597,7 +597,7 @@ void stun_message_id (const StunMessage *msg, stun_transid_t id)
/** /**
* @return STUN message method (value from 0 to 0xfff) * @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); uint16_t t = stun_getw (msg->buffer);
/* HACK HACK HACK /* HACK HACK HACK
...@@ -610,7 +610,7 @@ stun_method_t stun_message_get_method (const StunMessage *msg) ...@@ -610,7 +610,7 @@ stun_method_t stun_message_get_method (const StunMessage *msg)
method doesn't exist anymore */ method doesn't exist anymore */
if (t == 0x0115) if (t == 0x0115)
t = 0x0017; t = 0x0017;
return (stun_method_t)(((t & 0x3e00) >> 2) | ((t & 0x00e0) >> 1) | return (StunMethod)(((t & 0x3e00) >> 2) | ((t & 0x00e0) >> 1) |
(t & 0x000f)); (t & 0x000f));
} }
...@@ -618,7 +618,7 @@ stun_method_t stun_message_get_method (const StunMessage *msg) ...@@ -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) * @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); uint16_t t = stun_getw (msg->buffer);
/* HACK HACK HACK /* HACK HACK HACK
...@@ -631,7 +631,7 @@ stun_class_t stun_message_get_class (const StunMessage *msg) ...@@ -631,7 +631,7 @@ stun_class_t stun_message_get_class (const StunMessage *msg)
method doesn't exist anymore */ method doesn't exist anymore */
if (t == 0x0115) if (t == 0x0115)
t = 0x0017; 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) ...@@ -642,7 +642,7 @@ stun_class_t stun_message_get_class (const StunMessage *msg)
* *
* @return whether there is a MESSAGE-INTEGRITY attribute * @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; uint16_t dummy;
return stun_message_find (msg, type, &dummy) != NULL; return stun_message_find (msg, type, &dummy) != NULL;
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
typedef struct stun_message_t StunMessage; typedef struct stun_message_t StunMessage;
/** /**
* stun_class_t: * StunClass:
* @STUN_REQUEST: A STUN Request message * @STUN_REQUEST: A STUN Request message
* @STUN_INDICATION: A STUN indication message * @STUN_INDICATION: A STUN indication message
* @STUN_RESPONSE: A STUN Response message * @STUN_RESPONSE: A STUN Response message
...@@ -74,11 +74,11 @@ typedef enum ...@@ -74,11 +74,11 @@ typedef enum
STUN_INDICATION=1, STUN_INDICATION=1,
STUN_RESPONSE=2, STUN_RESPONSE=2,
STUN_ERROR=3 STUN_ERROR=3
} stun_class_t; } StunClass;
/** /**
* stun_method_t: * StunMethod:
* @STUN_BINDING: The Binding method as defined by the RFC5389 * @STUN_BINDING: The Binding method as defined by the RFC5389
* @STUN_SHARED_SECRET: The Shared-Secret method as defined by the RFC3489 * @STUN_SHARED_SECRET: The Shared-Secret method as defined by the RFC3489
* @STUN_ALLOCATE: The Allocate method as defined by the TURN draft 12 * @STUN_ALLOCATE: The Allocate method as defined by the TURN draft 12
...@@ -118,10 +118,10 @@ typedef enum ...@@ -118,10 +118,10 @@ typedef enum
STUN_IND_CONNECT_STATUS=0x008, /* TURN-04 */ STUN_IND_CONNECT_STATUS=0x008, /* TURN-04 */
STUN_CREATEPERMISSION= 0x008, /* TURN-12 */ STUN_CREATEPERMISSION= 0x008, /* TURN-12 */
STUN_CHANNELBIND= 0x009 /* 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 * @STUN_ATTRIBUTE_MAPPED_ADDRESS: The MAPPED-ADDRESS attribute as defined
* by RFC5389 * by RFC5389
...@@ -271,16 +271,16 @@ typedef enum ...@@ -271,16 +271,16 @@ typedef enum
STUN_ATTRIBUTE_ICE_CONTROLLED=0x8029, /* ICE-19 */ STUN_ATTRIBUTE_ICE_CONTROLLED=0x8029, /* ICE-19 */
STUN_ATTRIBUTE_ICE_CONTROLLING=0x802A, /* ICE-19 */ STUN_ATTRIBUTE_ICE_CONTROLLING=0x802A, /* ICE-19 */
/* 0x802B-0xFFFF */ /* reserved */ /* 0x802B-0xFFFF */ /* reserved */
} stun_attr_type_t; } StunAttribute;
/** /**
* STUN_ALL_KNOWN_ATTRIBUTES: * STUN_ALL_KNOWN_ATTRIBUTES:
* *
* An array containing all the currently known and defined mandatory 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[] = static const uint16_t STUN_ALL_KNOWN_ATTRIBUTES[] =
{ {
STUN_ATTRIBUTE_MAPPED_ADDRESS, STUN_ATTRIBUTE_MAPPED_ADDRESS,
...@@ -325,14 +325,14 @@ static const uint16_t STUN_ALL_KNOWN_ATTRIBUTES[] = ...@@ -325,14 +325,14 @@ static const uint16_t STUN_ALL_KNOWN_ATTRIBUTES[] =
}; };
/** /**
* stun_transid_t: * StunTransactionId:
* A type that holds a STUN transaction id. * 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 * @STUN_ERROR_TRY_ALTERNATE: The ERROR-CODE value for the
* "Try Alternate" error as defined in RFC5389 * "Try Alternate" error as defined in RFC5389
* @STUN_ERROR_BAD_REQUEST: The ERROR-CODE value for the * @STUN_ERROR_BAD_REQUEST: The ERROR-CODE value for the
...@@ -397,7 +397,7 @@ typedef enum ...@@ -397,7 +397,7 @@ typedef enum
STUN_ERROR_SERVER_CAPACITY=507, /* TURN-04 */ STUN_ERROR_SERVER_CAPACITY=507, /* TURN-04 */
STUN_ERROR_INSUFFICIENT_CAPACITY=508, /* TURN-12 */ STUN_ERROR_INSUFFICIENT_CAPACITY=508, /* TURN-12 */
STUN_ERROR_MAX=699 STUN_ERROR_MAX=699
} stun_error_t; } StunError;
typedef enum typedef enum
...@@ -432,8 +432,8 @@ struct stun_message_t { ...@@ -432,8 +432,8 @@ struct stun_message_t {
* @param id 16-bytes transaction ID * @param id 16-bytes transaction ID
* @return TRUE if the initialization was successful * @return TRUE if the initialization was successful
*/ */
bool stun_message_init (StunMessage *msg, stun_class_t c, stun_method_t m, bool stun_message_init (StunMessage *msg, StunClass c, StunMethod m,
const stun_transid_t id); const StunTransactionId id);
/** /**
* Returns the length of the stun message * Returns the length of the stun message
...@@ -449,7 +449,7 @@ uint16_t stun_message_length (const StunMessage *msg); ...@@ -449,7 +449,7 @@ uint16_t stun_message_length (const StunMessage *msg);
* @return a pointer to the start of the attribute payload if found, * @return a pointer to the start of the attribute payload if found,
* otherwise NULL. * 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); uint16_t *palen);
...@@ -461,7 +461,7 @@ const void * stun_message_find (const StunMessage * msg, stun_attr_type_t type, ...@@ -461,7 +461,7 @@ const void * stun_message_find (const StunMessage * msg, stun_attr_type_t type,
* size is not zero. * size is not zero.
*/ */
StunMessageReturn stun_message_find_flag (const StunMessage *msg, 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. * Extracts a 32-bits attribute from a valid STUN message.
...@@ -474,7 +474,7 @@ StunMessageReturn stun_message_find_flag (const StunMessage *msg, ...@@ -474,7 +474,7 @@ StunMessageReturn stun_message_find_flag (const StunMessage *msg,
* In case of error, @a *pval is not modified. * In case of error, @a *pval is not modified.
*/ */
StunMessageReturn stun_message_find32 (const StunMessage *msg, 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. * Extracts a 64-bits attribute from a valid STUN message.
...@@ -486,7 +486,7 @@ StunMessageReturn stun_message_find32 (const StunMessage *msg, ...@@ -486,7 +486,7 @@ StunMessageReturn stun_message_find32 (const StunMessage *msg,
* In case of error, @a *pval is not modified. * In case of error, @a *pval is not modified.
*/ */
StunMessageReturn stun_message_find64 (const StunMessage *msg, 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. * Extracts an UTF-8 string from a valid STUN message.
...@@ -502,7 +502,7 @@ StunMessageReturn stun_message_find64 (const StunMessage *msg, ...@@ -502,7 +502,7 @@ StunMessageReturn stun_message_find64 (const StunMessage *msg,
* @note A nul-byte is appended at the end. * @note A nul-byte is appended at the end.
*/ */
StunMessageReturn stun_message_find_string (const StunMessage *msg, 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. * Extracts a network address attribute from a valid STUN message.
...@@ -517,7 +517,7 @@ StunMessageReturn stun_message_find_string (const StunMessage *msg, ...@@ -517,7 +517,7 @@ StunMessageReturn stun_message_find_string (const StunMessage *msg,
* EAFNOSUPPORT if address family is unknown. * EAFNOSUPPORT if address family is unknown.
*/ */
StunMessageReturn stun_message_find_addr (const StunMessage *msg, 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. * Extracts an obfuscated network address attribute from a valid STUN message.
...@@ -532,20 +532,20 @@ StunMessageReturn stun_message_find_addr (const StunMessage *msg, ...@@ -532,20 +532,20 @@ StunMessageReturn stun_message_find_addr (const StunMessage *msg,
* EAFNOSUPPORT if address family is unknown. * EAFNOSUPPORT if address family is unknown.
*/ */
StunMessageReturn stun_message_find_xor_addr (const StunMessage *msg, 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, 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); socklen_t *addrlen, uint32_t magic_cookie);
StunMessageReturn stun_message_find_error (const StunMessage *msg, int *code); 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); size_t length);
StunMessageReturn stun_message_append_bytes (StunMessage *msg, 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. * Appends an empty ("flag") attribute to a STUN message.
...@@ -555,7 +555,7 @@ StunMessageReturn stun_message_append_bytes (StunMessage *msg, ...@@ -555,7 +555,7 @@ StunMessageReturn stun_message_append_bytes (StunMessage *msg,
* @return 0 on success, ENOBUFS on error. * @return 0 on success, ENOBUFS on error.
*/ */
StunMessageReturn stun_message_append_flag (StunMessage *msg, 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. * Appends an attribute consisting of a 32-bits value to a STUN message.
...@@ -566,7 +566,7 @@ StunMessageReturn stun_message_append_flag (StunMessage *msg, ...@@ -566,7 +566,7 @@ StunMessageReturn stun_message_append_flag (StunMessage *msg,
* @return 0 on success, ENOBUFS on error. * @return 0 on success, ENOBUFS on error.
*/ */
StunMessageReturn stun_message_append32 (StunMessage *msg, 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. * Appends an attribute consisting of a 64-bits value to a STUN message.
...@@ -577,7 +577,7 @@ StunMessageReturn stun_message_append32 (StunMessage *msg, ...@@ -577,7 +577,7 @@ StunMessageReturn stun_message_append32 (StunMessage *msg,
* @return 0 on success, ENOBUFS on error. * @return 0 on success, ENOBUFS on error.
*/ */
StunMessageReturn stun_message_append64 (StunMessage *msg, 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. * Appends an attribute from a nul-terminated string.
...@@ -588,7 +588,7 @@ StunMessageReturn stun_message_append64 (StunMessage *msg, ...@@ -588,7 +588,7 @@ StunMessageReturn stun_message_append64 (StunMessage *msg,
* @return 0 on success, ENOBUFS on error. * @return 0 on success, ENOBUFS on error.
*/ */
StunMessageReturn stun_message_append_string (StunMessage *msg, 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. * Appends an attribute consisting of a network address to a STUN message.
...@@ -602,7 +602,7 @@ StunMessageReturn stun_message_append_string (StunMessage *msg, ...@@ -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. * EINVAL if the socket address length is too small w.r.t. the address family.
*/ */
StunMessageReturn stun_message_append_addr (StunMessage * msg, 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. * Appends an attribute consisting of a xor'ed network address.
...@@ -616,10 +616,10 @@ StunMessageReturn stun_message_append_addr (StunMessage * msg, ...@@ -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. * EINVAL if the socket address length is too small w.r.t. the address family.
*/ */
StunMessageReturn stun_message_append_xor_addr (StunMessage * msg, 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, 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); uint32_t magic_cookie);
/** /**
...@@ -630,7 +630,7 @@ StunMessageReturn stun_message_append_xor_addr_full (StunMessage * msg, ...@@ -630,7 +630,7 @@ StunMessageReturn stun_message_append_xor_addr_full (StunMessage * msg,
* @return 0 on success, or ENOBUFS otherwise * @return 0 on success, or ENOBUFS otherwise
*/ */
StunMessageReturn stun_message_append_error (StunMessage * msg, StunMessageReturn stun_message_append_error (StunMessage * msg,
stun_error_t code); StunError code);
#define STUN_MESSAGE_BUFFER_INCOMPLETE 0 #define STUN_MESSAGE_BUFFER_INCOMPLETE 0
#define STUN_MESSAGE_BUFFER_INVALID -1 #define STUN_MESSAGE_BUFFER_INVALID -1
...@@ -638,10 +638,10 @@ StunMessageReturn stun_message_append_error (StunMessage * msg, ...@@ -638,10 +638,10 @@ StunMessageReturn stun_message_append_error (StunMessage * msg,
int stun_message_validate_buffer_length (const uint8_t *msg, size_t length); 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); StunClass stun_message_get_class (const StunMessage *msg);
stun_method_t stun_message_get_method (const StunMessage *msg); StunMethod stun_message_get_method (const StunMessage *msg);
bool stun_message_has_attribute (const StunMessage *msg, stun_attr_type_t type); bool stun_message_has_attribute (const StunMessage *msg, StunAttribute type);
#endif /* _STUN_MESSAGE_H */ #endif /* _STUN_MESSAGE_H */
...@@ -161,8 +161,8 @@ stun_usage_bind_keepalive (StunAgent *agent, StunMessage *msg, ...@@ -161,8 +161,8 @@ stun_usage_bind_keepalive (StunAgent *agent, StunMessage *msg,
StunUsageBindReturn stun_usage_bind_run (const struct sockaddr *srv, StunUsageBindReturn stun_usage_bind_run (const struct sockaddr *srv,
socklen_t srvlen, struct sockaddr *addr, socklen_t *addrlen) socklen_t srvlen, struct sockaddr *addr, socklen_t *addrlen)
{ {
stun_timer_t timer; StunTimer timer;
stun_trans_t trans; StunTransport trans;
StunAgent agent; StunAgent agent;
StunMessage req; StunMessage req;
uint8_t req_buf[STUN_MAX_MESSAGE_SIZE]; uint8_t req_buf[STUN_MAX_MESSAGE_SIZE];
......
...@@ -137,7 +137,7 @@ StunUsageIceReturn stun_usage_ice_conncheck_process (StunMessage *msg, ...@@ -137,7 +137,7 @@ StunUsageIceReturn stun_usage_ice_conncheck_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_ICE_COMPATIBILITY_MSN) { if (compatibility == STUN_USAGE_ICE_COMPATIBILITY_MSN) {
stun_transid_t transid; StunTransactionId transid;
uint32_t magic_cookie; uint32_t magic_cookie;
stun_message_id (msg, transid); stun_message_id (msg, transid);
magic_cookie = *((uint32_t *) transid); magic_cookie = *((uint32_t *) transid);
...@@ -167,7 +167,7 @@ StunUsageIceReturn stun_usage_ice_conncheck_process (StunMessage *msg, ...@@ -167,7 +167,7 @@ StunUsageIceReturn stun_usage_ice_conncheck_process (StunMessage *msg,
static int static int
stun_bind_error (StunAgent *agent, StunMessage *msg, stun_bind_error (StunAgent *agent, StunMessage *msg,
uint8_t *buf, size_t *plen, const StunMessage *req, uint8_t *buf, size_t *plen, const StunMessage *req,
stun_error_t code) StunError code)
{ {
size_t len = *plen; size_t len = *plen;
int val; int val;
...@@ -256,7 +256,7 @@ stun_usage_ice_conncheck_create_reply (StunAgent *agent, StunMessage *req, ...@@ -256,7 +256,7 @@ stun_usage_ice_conncheck_create_reply (StunAgent *agent, StunMessage *req,
goto failure; goto failure;
} }
if (compatibility == STUN_USAGE_ICE_COMPATIBILITY_MSN) { if (compatibility == STUN_USAGE_ICE_COMPATIBILITY_MSN) {
stun_transid_t transid; StunTransactionId transid;
uint32_t magic_cookie; uint32_t magic_cookie;
stun_message_id (msg, transid); stun_message_id (msg, transid);
magic_cookie = *((uint32_t *) transid); magic_cookie = *((uint32_t *) transid);
......
...@@ -118,14 +118,14 @@ static void add_delay (struct timeval *ts, unsigned delay) ...@@ -118,14 +118,14 @@ static void add_delay (struct timeval *ts, unsigned delay)
} }
void stun_timer_start (stun_timer_t *timer) void stun_timer_start (StunTimer *timer)
{ {
stun_gettime (&timer->deadline); stun_gettime (&timer->deadline);
add_delay (&timer->deadline, timer->delay = STUN_INIT_TIMEOUT); add_delay (&timer->deadline, timer->delay = STUN_INIT_TIMEOUT);
} }
void stun_timer_start_reliable (stun_timer_t *timer) void stun_timer_start_reliable (StunTimer *timer)
{ {
stun_gettime (&timer->deadline); stun_gettime (&timer->deadline);
add_delay (&timer->deadline, timer->delay = STUN_RELIABLE_TIMEOUT); add_delay (&timer->deadline, timer->delay = STUN_RELIABLE_TIMEOUT);
...@@ -133,7 +133,7 @@ void stun_timer_start_reliable (stun_timer_t *timer) ...@@ -133,7 +133,7 @@ void stun_timer_start_reliable (stun_timer_t *timer)
unsigned stun_timer_remainder (const stun_timer_t *timer) unsigned stun_timer_remainder (const StunTimer *timer)
{ {
unsigned delay; unsigned delay;
struct timeval now; struct timeval now;
...@@ -152,7 +152,7 @@ unsigned stun_timer_remainder (const stun_timer_t *timer) ...@@ -152,7 +152,7 @@ unsigned stun_timer_remainder (const stun_timer_t *timer)
} }
StunUsageTimerReturn stun_timer_refresh (stun_timer_t *timer) StunUsageTimerReturn stun_timer_refresh (StunTimer *timer)
{ {
unsigned delay = stun_timer_remainder (timer); unsigned delay = stun_timer_remainder (timer);
if (delay == 0) if (delay == 0)
......
...@@ -52,7 +52,7 @@ typedef struct stun_timer_s ...@@ -52,7 +52,7 @@ typedef struct stun_timer_s
{ {
struct timeval deadline; struct timeval deadline;
unsigned delay; unsigned delay;
} stun_timer_t; } StunTimer;
typedef enum { typedef enum {
STUN_USAGE_TIMER_RETURN_SUCCESS, STUN_USAGE_TIMER_RETURN_SUCCESS,
...@@ -68,8 +68,8 @@ extern "C" { ...@@ -68,8 +68,8 @@ extern "C" {
* Starts a STUN transaction retransmission timer. * Starts a STUN transaction retransmission timer.
* @param timer structure for internal timer state * @param timer structure for internal timer state
*/ */
void stun_timer_start (stun_timer_t *timer); void stun_timer_start (StunTimer *timer);
void stun_timer_start_reliable (stun_timer_t *timer); void stun_timer_start_reliable (StunTimer *timer);
/** /**
* Updates a STUN transaction retransmission timer. * Updates a STUN transaction retransmission timer.
...@@ -78,8 +78,8 @@ void stun_timer_start_reliable (stun_timer_t *timer); ...@@ -78,8 +78,8 @@ void stun_timer_start_reliable (stun_timer_t *timer);
* 0 if the transaction should be retransmitted, * 0 if the transaction should be retransmitted,
* otherwise milliseconds left until next time out or retransmit. * otherwise milliseconds left until next time out or retransmit.
*/ */
StunUsageTimerReturn stun_timer_refresh (stun_timer_t *timer); StunUsageTimerReturn stun_timer_refresh (StunTimer *timer);
unsigned stun_timer_remainder (const stun_timer_t *timer); unsigned stun_timer_remainder (const StunTimer *timer);
# ifdef __cplusplus # ifdef __cplusplus
} }
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
#include "trans.h" #include "trans.h"
StunUsageTransReturn stun_trans_init (stun_trans_t *tr, int fd, StunUsageTransReturn stun_trans_init (StunTransport *tr, int fd,
const struct sockaddr *srv, socklen_t srvlen) const struct sockaddr *srv, socklen_t srvlen)
{ {
assert (fd != -1); assert (fd != -1);
...@@ -112,7 +112,7 @@ static int stun_socket (int family, int type, int proto) ...@@ -112,7 +112,7 @@ static int stun_socket (int family, int type, int proto)
} }
StunUsageTransReturn stun_trans_create (stun_trans_t *tr, int type, int proto, StunUsageTransReturn stun_trans_create (StunTransport *tr, int type, int proto,
const struct sockaddr *srv, socklen_t srvlen) const struct sockaddr *srv, socklen_t srvlen)
{ {
StunUsageTransReturn val = STUN_USAGE_TRANS_RETURN_ERROR; StunUsageTransReturn val = STUN_USAGE_TRANS_RETURN_ERROR;
...@@ -147,7 +147,7 @@ error: ...@@ -147,7 +147,7 @@ error:
} }
void stun_trans_deinit (stun_trans_t *tr) void stun_trans_deinit (StunTransport *tr)
{ {
int saved = errno; int saved = errno;
...@@ -187,19 +187,19 @@ static int stun_err_dequeue (int fd) ...@@ -187,19 +187,19 @@ static int stun_err_dequeue (int fd)
} }
ssize_t stun_trans_send (stun_trans_t *tr, const uint8_t *buf, size_t len) ssize_t stun_trans_send (StunTransport *tr, const uint8_t *buf, size_t len)
{ {
return stun_trans_sendto (tr, buf, len, return stun_trans_sendto (tr, buf, len,
(struct sockaddr *)&tr->dst, tr->dstlen); (struct sockaddr *)&tr->dst, tr->dstlen);
} }
ssize_t stun_trans_recv (stun_trans_t *tr, uint8_t *buf, size_t maxlen) ssize_t stun_trans_recv (StunTransport *tr, uint8_t *buf, size_t maxlen)
{ {
return stun_trans_recvfrom (tr, buf, maxlen, NULL, NULL); return stun_trans_recvfrom (tr, buf, maxlen, NULL, NULL);
} }
ssize_t stun_trans_sendto (stun_trans_t *tr, const uint8_t *buf, size_t len, ssize_t stun_trans_sendto (StunTransport *tr, const uint8_t *buf, size_t len,
const struct sockaddr *dst, socklen_t dstlen) const struct sockaddr *dst, socklen_t dstlen)
{ {
static const int flags = MSG_DONTWAIT | MSG_NOSIGNAL; static const int flags = MSG_DONTWAIT | MSG_NOSIGNAL;
...@@ -218,7 +218,7 @@ ssize_t stun_trans_sendto (stun_trans_t *tr, const uint8_t *buf, size_t len, ...@@ -218,7 +218,7 @@ ssize_t stun_trans_sendto (stun_trans_t *tr, const uint8_t *buf, size_t len,
} }
ssize_t stun_trans_recvfrom (stun_trans_t *tr, uint8_t *buf, size_t maxlen, ssize_t stun_trans_recvfrom (StunTransport *tr, uint8_t *buf, size_t maxlen,
struct sockaddr * dst, struct sockaddr * dst,
socklen_t * dstlen) socklen_t * dstlen)
{ {
...@@ -238,7 +238,7 @@ ssize_t stun_trans_recvfrom (stun_trans_t *tr, uint8_t *buf, size_t maxlen, ...@@ -238,7 +238,7 @@ ssize_t stun_trans_recvfrom (stun_trans_t *tr, uint8_t *buf, size_t maxlen,
int stun_trans_fd (const stun_trans_t *tr) int stun_trans_fd (const StunTransport *tr)
{ {
assert (tr != NULL); assert (tr != NULL);
return tr->fd; return tr->fd;
...@@ -251,7 +251,7 @@ int stun_trans_fd (const stun_trans_t *tr) ...@@ -251,7 +251,7 @@ int stun_trans_fd (const stun_trans_t *tr)
* @return ETIMEDOUT if the transaction has timed out, or 0 if an incoming * @return ETIMEDOUT if the transaction has timed out, or 0 if an incoming
* message needs to be processed. * message needs to be processed.
*/ */
StunUsageTransReturn stun_trans_poll (stun_trans_t *tr, unsigned int delay) StunUsageTransReturn stun_trans_poll (StunTransport *tr, unsigned int delay)
{ {
#ifdef HAVE_POLL #ifdef HAVE_POLL
struct pollfd ufd; struct pollfd ufd;
......
...@@ -62,7 +62,7 @@ typedef struct stun_trans_s ...@@ -62,7 +62,7 @@ typedef struct stun_trans_s
int own_fd; int own_fd;
socklen_t dstlen; socklen_t dstlen;
struct sockaddr_storage dst; struct sockaddr_storage dst;
} stun_trans_t; } StunTransport;
typedef enum { typedef enum {
...@@ -85,7 +85,7 @@ extern "C" { ...@@ -85,7 +85,7 @@ extern "C" {
* @param srv STUN server socket address (ignored if @a srvlen is 0) * @param srv STUN server socket address (ignored if @a srvlen is 0)
* @param srvlen STUN server socket address length (or 0 @a fd is connected) * @param srvlen STUN server socket address length (or 0 @a fd is connected)
*/ */
StunUsageTransReturn stun_trans_init (stun_trans_t *tr, int fd, StunUsageTransReturn stun_trans_init (StunTransport *tr, int fd,
const struct sockaddr *srv, socklen_t srvlen); const struct sockaddr *srv, socklen_t srvlen);
/** /**
...@@ -97,14 +97,14 @@ StunUsageTransReturn stun_trans_init (stun_trans_t *tr, int fd, ...@@ -97,14 +97,14 @@ StunUsageTransReturn stun_trans_init (stun_trans_t *tr, int fd,
* @param srv STUN server socket address (ignored if @a srvlen is 0) * @param srv STUN server socket address (ignored if @a srvlen is 0)
* @param srvlen STUN server socket address length (or 0 @a fd is connected) * @param srvlen STUN server socket address length (or 0 @a fd is connected)
*/ */
StunUsageTransReturn stun_trans_create (stun_trans_t *tr, int sotype, int proto, StunUsageTransReturn stun_trans_create (StunTransport *tr, int sotype, int proto,
const struct sockaddr *srv, socklen_t srvlen); const struct sockaddr *srv, socklen_t srvlen);
/** /**
* Releases resources allocated by stun_trans_init() or stun_trans_create(), * Releases resources allocated by stun_trans_init() or stun_trans_create(),
* and cancel the transaction if still pending. * and cancel the transaction if still pending.
*/ */
void stun_trans_deinit (stun_trans_t *tr); void stun_trans_deinit (StunTransport *tr);
/** /**
* This is meant to integrate with I/O polling loops and event frameworks. * This is meant to integrate with I/O polling loops and event frameworks.
...@@ -112,8 +112,8 @@ void stun_trans_deinit (stun_trans_t *tr); ...@@ -112,8 +112,8 @@ void stun_trans_deinit (stun_trans_t *tr);
* @return file descriptor the transaction is waiting for. * @return file descriptor the transaction is waiting for.
* Always succeeds. * Always succeeds.
*/ */
int stun_trans_fd (const stun_trans_t *tr); int stun_trans_fd (const StunTransport *tr);
StunUsageTransReturn stun_trans_poll (stun_trans_t *tr, unsigned int delay); StunUsageTransReturn stun_trans_poll (StunTransport *tr, unsigned int delay);
/** /**
* Safe wrapper around sendto() * Safe wrapper around sendto()
...@@ -125,16 +125,16 @@ StunUsageTransReturn stun_trans_poll (stun_trans_t *tr, unsigned int delay); ...@@ -125,16 +125,16 @@ StunUsageTransReturn stun_trans_poll (stun_trans_t *tr, unsigned int delay);
* This can be used to send non-requests message, i.e. whenever the * This can be used to send non-requests message, i.e. whenever the
* transaction is not used. * transaction is not used.
*/ */
ssize_t stun_trans_sendto (stun_trans_t *tr, const uint8_t *buf, size_t len, ssize_t stun_trans_sendto (StunTransport *tr, const uint8_t *buf, size_t len,
const struct sockaddr *dst, socklen_t dstlen); const struct sockaddr *dst, socklen_t dstlen);
ssize_t stun_trans_recvfrom (stun_trans_t *tr, uint8_t *buf, size_t maxlen, ssize_t stun_trans_recvfrom (StunTransport *tr, uint8_t *buf, size_t maxlen,
struct sockaddr *src, struct sockaddr *src,
socklen_t *srclen); socklen_t *srclen);
ssize_t stun_trans_send (stun_trans_t *tr, const uint8_t *buf, size_t len); ssize_t stun_trans_send (StunTransport *tr, const uint8_t *buf, size_t len);
ssize_t stun_trans_recv (stun_trans_t *tr, uint8_t *buf, size_t maxlen); ssize_t stun_trans_recv (StunTransport *tr, uint8_t *buf, size_t maxlen);
# ifdef __cplusplus # ifdef __cplusplus
} }
......
...@@ -200,7 +200,7 @@ void *stun_setw (uint8_t *ptr, uint16_t value) ...@@ -200,7 +200,7 @@ void *stun_setw (uint8_t *ptr, uint16_t value)
} }
void stun_set_type (uint8_t *h, stun_class_t c, stun_method_t m) void stun_set_type (uint8_t *h, StunClass c, StunMethod m)
{ {
/* assert (c < 4); */ /* assert (c < 4); */
/* assert (m < (1 << 12)); */ /* assert (m < (1 << 12)); */
...@@ -218,11 +218,11 @@ void stun_set_type (uint8_t *h, stun_class_t c, stun_method_t m) ...@@ -218,11 +218,11 @@ void stun_set_type (uint8_t *h, stun_class_t c, stun_method_t m)
* @param code host-byte order error code * @param code host-byte order error code
* @return a static pointer to a nul-terminated error message string. * @return a static pointer to a nul-terminated error message string.
*/ */
const char *stun_strerror (stun_error_t code) const char *stun_strerror (StunError code)
{ {
static const struct static const struct
{ {
stun_error_t code; StunError code;
char phrase[32]; char phrase[32];
} tab[] = } tab[] =
{ {
......
...@@ -77,9 +77,9 @@ StunMessageReturn stun_xor_address (const StunMessage *msg, ...@@ -77,9 +77,9 @@ StunMessageReturn stun_xor_address (const StunMessage *msg,
void *stun_setw (uint8_t *ptr, uint16_t value); void *stun_setw (uint8_t *ptr, uint16_t value);
void stun_set_type (uint8_t *h, stun_class_t c, stun_method_t m); void stun_set_type (uint8_t *h, StunClass c, StunMethod m);
const char *stun_strerror (stun_error_t code); const char *stun_strerror (StunError code);
# ifdef __cplusplus # ifdef __cplusplus
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment