1
0
mirror of https://github.com/coturn/coturn.git synced 2025-10-23 20:11:17 +02:00

Remove [su]{08,16,32,64}bits type defines

Do not overload the standard types with #defines, just use them
directly.
This commit is contained in:
Bradley T. Hughes 2019-03-08 09:08:30 +01:00
parent 7663167dff
commit d2ee3ac291
54 changed files with 1553 additions and 1564 deletions

View File

@ -279,7 +279,7 @@ int addr_bind(evutil_socket_t fd, const ioa_addr* addr, int reusable, int debug,
int err = errno; int err = errno;
perror("bind"); perror("bind");
char str[129]; char str[129];
addr_to_string(addr,(u08bits*)str); addr_to_string(addr,(uint8_t*)str);
TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING, "Trying to bind fd %d to <%s>: errno=%d\n", fd, str, err); TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING, "Trying to bind fd %d to <%s>: errno=%d\n", fd, str, err);
} }
} }
@ -893,15 +893,15 @@ void ignore_sigpipe(void)
} }
} }
static u64bits turn_getRandTime(void) { static uint64_t turn_getRandTime(void) {
struct timespec tp={0,0}; struct timespec tp={0,0};
#if defined(CLOCK_REALTIME) #if defined(CLOCK_REALTIME)
clock_gettime(CLOCK_REALTIME, &tp); clock_gettime(CLOCK_REALTIME, &tp);
#else #else
tp.tv_sec = time(NULL); tp.tv_sec = time(NULL);
#endif #endif
u64bits current_time = (u64bits)(tp.tv_sec); uint64_t current_time = (uint64_t)(tp.tv_sec);
u64bits current_mstime = (u64bits)(current_time + (tp.tv_nsec)); uint64_t current_mstime = (uint64_t)(current_time + (tp.tv_nsec));
return current_mstime; return current_mstime;
} }
@ -956,11 +956,11 @@ char *base64_encode(const unsigned char *data,
size_t i,j; size_t i,j;
for (i = 0, j = 0; i < input_length;) { for (i = 0, j = 0; i < input_length;) {
u32bits octet_a = i < input_length ? data[i++] : 0; uint32_t octet_a = i < input_length ? data[i++] : 0;
u32bits octet_b = i < input_length ? data[i++] : 0; uint32_t octet_b = i < input_length ? data[i++] : 0;
u32bits octet_c = i < input_length ? data[i++] : 0; uint32_t octet_c = i < input_length ? data[i++] : 0;
u32bits triple = (octet_a << 0x10) + (octet_b << 0x08) + octet_c; uint32_t triple = (octet_a << 0x10) + (octet_b << 0x08) + octet_c;
encoded_data[j++] = encoding_table[(triple >> 3 * 6) & 0x3F]; encoded_data[j++] = encoding_table[(triple >> 3 * 6) & 0x3F];
encoded_data[j++] = encoding_table[(triple >> 2 * 6) & 0x3F]; encoded_data[j++] = encoding_table[(triple >> 2 * 6) & 0x3F];

View File

@ -135,8 +135,8 @@ typedef enum _TURN_TLS_TYPE TURN_TLS_TYPE;
struct _oauth_key_data_raw { struct _oauth_key_data_raw {
char kid[OAUTH_KID_SIZE+1]; char kid[OAUTH_KID_SIZE+1];
char ikm_key[OAUTH_KEY_SIZE+1]; char ikm_key[OAUTH_KEY_SIZE+1];
u64bits timestamp; uint64_t timestamp;
u32bits lifetime; uint32_t lifetime;
char as_rs_alg[OAUTH_ALG_SIZE+1]; char as_rs_alg[OAUTH_ALG_SIZE+1];
char realm[STUN_MAX_REALM_SIZE+1]; char realm[STUN_MAX_REALM_SIZE+1];
}; };

View File

@ -148,7 +148,7 @@ int turn_mutex_destroy(turn_mutex* mutex) {
///////////////////////// LOG /////////////////////////////////// ///////////////////////// LOG ///////////////////////////////////
#if defined(TURN_LOG_FUNC_IMPL) #if defined(TURN_LOG_FUNC_IMPL)
extern void TURN_LOG_FUNC_IMPL(TURN_LOG_LEVEL level, const s08bits* format, va_list args); extern void TURN_LOG_FUNC_IMPL(TURN_LOG_LEVEL level, const char* format, va_list args);
#endif #endif
static int no_stdout_log = 0; static int no_stdout_log = 0;
@ -158,7 +158,7 @@ void set_no_stdout_log(int val)
no_stdout_log = val; no_stdout_log = val;
} }
void turn_log_func_default(TURN_LOG_LEVEL level, const s08bits* format, ...) void turn_log_func_default(TURN_LOG_LEVEL level, const char* format, ...)
{ {
#if !defined(TURN_LOG_FUNC_IMPL) #if !defined(TURN_LOG_FUNC_IMPL)
{ {
@ -194,13 +194,13 @@ void turn_log_func_default(TURN_LOG_LEVEL level, const s08bits* format, ...)
} }
} }
void addr_debug_print(int verbose, const ioa_addr *addr, const s08bits* s) void addr_debug_print(int verbose, const ioa_addr *addr, const char* s)
{ {
if (verbose) { if (verbose) {
if (!addr) { if (!addr) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s: EMPTY\n", s); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s: EMPTY\n", s);
} else { } else {
s08bits addrbuf[INET6_ADDRSTRLEN]; char addrbuf[INET6_ADDRSTRLEN];
if (!s) if (!s)
s = ""; s = "";
if (addr->ss.sa_family == AF_INET) { if (addr->ss.sa_family == AF_INET) {
@ -663,7 +663,7 @@ int get_canonic_origin(const char* o, char *co, int sz)
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
int is_secure_string(const u08bits *string, int sanitizesql) int is_secure_string(const uint8_t *string, int sanitizesql)
{ {
int ret = 0; int ret = 0;
if(string) { if(string) {

View File

@ -61,9 +61,9 @@ void set_no_stdout_log(int val);
void set_log_to_syslog(int val); void set_log_to_syslog(int val);
void set_simple_log(int val); void set_simple_log(int val);
void turn_log_func_default(TURN_LOG_LEVEL level, const s08bits* format, ...); void turn_log_func_default(TURN_LOG_LEVEL level, const char* format, ...);
void addr_debug_print(int verbose, const ioa_addr *addr, const s08bits* s); void addr_debug_print(int verbose, const ioa_addr *addr, const char* s);
/* Log */ /* Log */
@ -78,7 +78,7 @@ void rollover_logfile(void);
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
int is_secure_string(const u08bits *string, int sanitizesql); int is_secure_string(const uint8_t *string, int sanitizesql);
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////

View File

@ -82,7 +82,7 @@ int stun_is_success_response(const stun_buffer* buf) {
return stun_is_success_response_str(buf->buf, (size_t)(buf->len)); return stun_is_success_response_str(buf->buf, (size_t)(buf->len));
} }
int stun_is_error_response(const stun_buffer* buf, int *err_code, u08bits *err_msg, size_t err_msg_size) { int stun_is_error_response(const stun_buffer* buf, int *err_code, uint8_t *err_msg, size_t err_msg_size) {
return stun_is_error_response_str(buf->buf, (size_t)(buf->len), err_code, err_msg, err_msg_size); return stun_is_error_response_str(buf->buf, (size_t)(buf->len), err_code, err_msg, err_msg_size);
} }
@ -95,36 +95,36 @@ int stun_is_indication(const stun_buffer* buf) {
return IS_STUN_INDICATION(stun_get_msg_type(buf)); return IS_STUN_INDICATION(stun_get_msg_type(buf));
} }
u16bits stun_get_method(const stun_buffer* buf) { uint16_t stun_get_method(const stun_buffer* buf) {
return stun_get_method_str(buf->buf, (size_t)(buf->len)); return stun_get_method_str(buf->buf, (size_t)(buf->len));
} }
u16bits stun_get_msg_type(const stun_buffer* buf) { uint16_t stun_get_msg_type(const stun_buffer* buf) {
if(!buf) return (u16bits)-1; if(!buf) return (uint16_t)-1;
return stun_get_msg_type_str(buf->buf,(size_t)buf->len); return stun_get_msg_type_str(buf->buf,(size_t)buf->len);
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static void stun_init_command(u16bits message_type, stun_buffer* buf) { static void stun_init_command(uint16_t message_type, stun_buffer* buf) {
buf->len=stun_get_size(buf); buf->len=stun_get_size(buf);
stun_init_command_str(message_type, buf->buf, (size_t*)(&(buf->len))); stun_init_command_str(message_type, buf->buf, (size_t*)(&(buf->len)));
} }
void stun_init_request(u16bits method, stun_buffer* buf) { void stun_init_request(uint16_t method, stun_buffer* buf) {
stun_init_command(stun_make_request(method), buf); stun_init_command(stun_make_request(method), buf);
} }
void stun_init_indication(u16bits method, stun_buffer* buf) { void stun_init_indication(uint16_t method, stun_buffer* buf) {
stun_init_command(stun_make_indication(method), buf); stun_init_command(stun_make_indication(method), buf);
} }
void stun_init_success_response(u16bits method, stun_buffer* buf, stun_tid* id) { void stun_init_success_response(uint16_t method, stun_buffer* buf, stun_tid* id) {
buf->len=stun_get_size(buf); buf->len=stun_get_size(buf);
stun_init_success_response_str(method, buf->buf, (size_t*)(&(buf->len)), id); stun_init_success_response_str(method, buf->buf, (size_t*)(&(buf->len)), id);
} }
void stun_init_error_response(u16bits method, stun_buffer* buf, u16bits error_code, const u08bits *reason, stun_tid* id) { void stun_init_error_response(uint16_t method, stun_buffer* buf, uint16_t error_code, const uint8_t *reason, stun_tid* id) {
buf->len=stun_get_size(buf); buf->len=stun_get_size(buf);
stun_init_error_response_str(method, buf->buf, (size_t*)(&(buf->len)), error_code, reason, id); stun_init_error_response_str(method, buf->buf, (size_t*)(&(buf->len)), error_code, reason, id);
} }
@ -137,11 +137,11 @@ int stun_get_command_message_len(const stun_buffer* buf) {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
int stun_init_channel_message(u16bits chnumber, stun_buffer* buf, int length, int do_padding) { int stun_init_channel_message(uint16_t chnumber, stun_buffer* buf, int length, int do_padding) {
return stun_init_channel_message_str(chnumber, buf->buf, (size_t*)(&(buf->len)), length, do_padding); return stun_init_channel_message_str(chnumber, buf->buf, (size_t*)(&(buf->len)), length, do_padding);
} }
int stun_is_channel_message(stun_buffer* buf, u16bits* chnumber, int is_padding_mandatory) { int stun_is_channel_message(stun_buffer* buf, uint16_t* chnumber, int is_padding_mandatory) {
if(!buf) return 0; if(!buf) return 0;
size_t blen = (size_t)buf->len; size_t blen = (size_t)buf->len;
int ret = stun_is_channel_message_str(buf->buf, &blen, chnumber, is_padding_mandatory); int ret = stun_is_channel_message_str(buf->buf, &blen, chnumber, is_padding_mandatory);
@ -153,15 +153,15 @@ int stun_is_channel_message(stun_buffer* buf, u16bits* chnumber, int is_padding_
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
int stun_set_allocate_request(stun_buffer* buf, u32bits lifetime, int af4, int af6, u08bits transport, int mobile, const char *rt, int ep) { int stun_set_allocate_request(stun_buffer* buf, uint32_t lifetime, int af4, int af6, uint8_t transport, int mobile, const char *rt, int ep) {
return stun_set_allocate_request_str(buf->buf, (size_t*)(&(buf->len)), lifetime, af4, af6, transport, mobile, rt, ep); return stun_set_allocate_request_str(buf->buf, (size_t*)(&(buf->len)), lifetime, af4, af6, transport, mobile, rt, ep);
} }
int stun_set_allocate_response(stun_buffer* buf, stun_tid* tid, int stun_set_allocate_response(stun_buffer* buf, stun_tid* tid,
const ioa_addr *relayed_addr1, const ioa_addr *relayed_addr2, const ioa_addr *relayed_addr1, const ioa_addr *relayed_addr2,
const ioa_addr *reflexive_addr, const ioa_addr *reflexive_addr,
u32bits lifetime, u32bits max_lifetime, int error_code, const u08bits *reason, uint32_t lifetime, uint32_t max_lifetime, int error_code, const uint8_t *reason,
u64bits reservation_token, char *mobile_id) { uint64_t reservation_token, char *mobile_id) {
return stun_set_allocate_response_str(buf->buf, (size_t*)(&(buf->len)), tid, return stun_set_allocate_response_str(buf->buf, (size_t*)(&(buf->len)), tid,
relayed_addr1, relayed_addr2, reflexive_addr, relayed_addr1, relayed_addr2, reflexive_addr,
@ -172,13 +172,13 @@ int stun_set_allocate_response(stun_buffer* buf, stun_tid* tid,
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
u16bits stun_set_channel_bind_request(stun_buffer* buf, uint16_t stun_set_channel_bind_request(stun_buffer* buf,
const ioa_addr* peer_addr, u16bits channel_number) { const ioa_addr* peer_addr, uint16_t channel_number) {
return stun_set_channel_bind_request_str(buf->buf,(size_t*)(&(buf->len)), peer_addr, channel_number); return stun_set_channel_bind_request_str(buf->buf,(size_t*)(&(buf->len)), peer_addr, channel_number);
} }
void stun_set_channel_bind_response(stun_buffer* buf, stun_tid* tid, int error_code, const u08bits *reason) { void stun_set_channel_bind_response(stun_buffer* buf, stun_tid* tid, int error_code, const uint8_t *reason) {
stun_set_channel_bind_response_str(buf->buf, (size_t*)(&(buf->len)), tid, error_code, reason); stun_set_channel_bind_response_str(buf->buf, (size_t*)(&(buf->len)), tid, error_code, reason);
} }
@ -192,15 +192,15 @@ stun_attr_ref stun_attr_get_next(const stun_buffer* buf, stun_attr_ref prev) {
return stun_attr_get_next_str(buf->buf, (size_t)(buf->len), prev); return stun_attr_get_next_str(buf->buf, (size_t)(buf->len), prev);
} }
int stun_attr_add(stun_buffer* buf, u16bits attr, const s08bits* avalue, int alen) { int stun_attr_add(stun_buffer* buf, uint16_t attr, const char* avalue, int alen) {
return stun_attr_add_str(buf->buf, (size_t*)(&(buf->len)), attr, (const u08bits *)avalue, alen); return stun_attr_add_str(buf->buf, (size_t*)(&(buf->len)), attr, (const uint8_t *)avalue, alen);
} }
int stun_attr_add_channel_number(stun_buffer* buf, u16bits chnumber) { int stun_attr_add_channel_number(stun_buffer* buf, uint16_t chnumber) {
return stun_attr_add_channel_number_str(buf->buf, (size_t *)(&(buf->len)), chnumber); return stun_attr_add_channel_number_str(buf->buf, (size_t *)(&(buf->len)), chnumber);
} }
int stun_attr_add_addr(stun_buffer *buf,u16bits attr_type, const ioa_addr* ca) { int stun_attr_add_addr(stun_buffer *buf,uint16_t attr_type, const ioa_addr* ca) {
return stun_attr_add_addr_str(buf->buf,(size_t*)(&(buf->len)), attr_type, ca); return stun_attr_add_addr_str(buf->buf,(size_t*)(&(buf->len)), attr_type, ca);
} }
@ -210,7 +210,7 @@ int stun_attr_get_addr(const stun_buffer *buf, stun_attr_ref attr, ioa_addr* ca,
return stun_attr_get_addr_str(buf->buf, (size_t)(buf->len), attr, ca, default_addr); return stun_attr_get_addr_str(buf->buf, (size_t)(buf->len), attr, ca, default_addr);
} }
int stun_attr_get_first_addr(const stun_buffer *buf, u16bits attr_type, ioa_addr* ca, int stun_attr_get_first_addr(const stun_buffer *buf, uint16_t attr_type, ioa_addr* ca,
const ioa_addr *default_addr) { const ioa_addr *default_addr) {
return stun_attr_get_first_addr_str(buf->buf, (size_t)(buf->len), attr_type, ca, default_addr); return stun_attr_get_first_addr_str(buf->buf, (size_t)(buf->len), attr_type, ca, default_addr);
@ -218,14 +218,14 @@ int stun_attr_get_first_addr(const stun_buffer *buf, u16bits attr_type, ioa_addr
int stun_attr_add_even_port(stun_buffer* buf, uint8_t value) { int stun_attr_add_even_port(stun_buffer* buf, uint8_t value) {
if(value) value=0x80; if(value) value=0x80;
return stun_attr_add(buf,STUN_ATTRIBUTE_EVEN_PORT,(const s08bits*)&value,1); return stun_attr_add(buf,STUN_ATTRIBUTE_EVEN_PORT,(const char*)&value,1);
} }
u16bits stun_attr_get_first_channel_number(const stun_buffer *buf) { uint16_t stun_attr_get_first_channel_number(const stun_buffer *buf) {
return stun_attr_get_first_channel_number_str(buf->buf, (size_t)(buf->len)); return stun_attr_get_first_channel_number_str(buf->buf, (size_t)(buf->len));
} }
stun_attr_ref stun_attr_get_first_by_type(const stun_buffer* buf, u16bits attr_type) { stun_attr_ref stun_attr_get_first_by_type(const stun_buffer* buf, uint16_t attr_type) {
return stun_attr_get_first_by_type_str(buf->buf, (size_t)(buf->len), attr_type); return stun_attr_get_first_by_type_str(buf->buf, (size_t)(buf->len), attr_type);
} }
@ -236,7 +236,7 @@ void stun_set_binding_request(stun_buffer* buf) {
} }
int stun_set_binding_response(stun_buffer* buf, stun_tid* tid, int stun_set_binding_response(stun_buffer* buf, stun_tid* tid,
const ioa_addr *reflexive_addr, int error_code, const u08bits *reason) { const ioa_addr *reflexive_addr, int error_code, const uint8_t *reason) {
return stun_set_binding_response_str(buf->buf, (size_t*)(&(buf->len)), tid, return stun_set_binding_response_str(buf->buf, (size_t*)(&(buf->len)), tid,
reflexive_addr, error_code, reason, reflexive_addr, error_code, reason,
0,0); 0,0);

View File

@ -40,11 +40,11 @@ extern "C" {
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
typedef struct _stun_buffer { typedef struct _stun_buffer {
u08bits channel[STUN_CHANNEL_HEADER_LENGTH]; uint8_t channel[STUN_CHANNEL_HEADER_LENGTH];
u08bits buf[STUN_BUFFER_SIZE]; uint8_t buf[STUN_BUFFER_SIZE];
size_t len; size_t len;
u16bits offset; uint16_t offset;
u08bits coffset; uint8_t coffset;
} stun_buffer; } stun_buffer;
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
@ -63,32 +63,32 @@ int stun_is_command_message(const stun_buffer* buf);
int stun_is_request(const stun_buffer* buf); int stun_is_request(const stun_buffer* buf);
int stun_is_response(const stun_buffer* buf); int stun_is_response(const stun_buffer* buf);
int stun_is_success_response(const stun_buffer* buf); int stun_is_success_response(const stun_buffer* buf);
int stun_is_error_response(const stun_buffer* buf, int *err_code, u08bits *err_msg, size_t err_msg_size); int stun_is_error_response(const stun_buffer* buf, int *err_code, uint8_t *err_msg, size_t err_msg_size);
int stun_is_indication(const stun_buffer* buf); int stun_is_indication(const stun_buffer* buf);
u16bits stun_get_method(const stun_buffer* buf); uint16_t stun_get_method(const stun_buffer* buf);
u16bits stun_get_msg_type(const stun_buffer* buf); uint16_t stun_get_msg_type(const stun_buffer* buf);
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
void stun_init_request(u16bits method, stun_buffer* buf); void stun_init_request(uint16_t method, stun_buffer* buf);
void stun_init_indication(u16bits method, stun_buffer* buf); void stun_init_indication(uint16_t method, stun_buffer* buf);
void stun_init_success_response(u16bits method, stun_buffer* buf, stun_tid* id); void stun_init_success_response(uint16_t method, stun_buffer* buf, stun_tid* id);
void stun_init_error_response(u16bits method, stun_buffer* buf, u16bits error_code, const u08bits *reason, stun_tid* id); void stun_init_error_response(uint16_t method, stun_buffer* buf, uint16_t error_code, const uint8_t *reason, stun_tid* id);
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
int stun_attr_add(stun_buffer* buf, u16bits attr, const s08bits* avalue, int alen); int stun_attr_add(stun_buffer* buf, uint16_t attr, const char* avalue, int alen);
int stun_attr_add_channel_number(stun_buffer* buf, u16bits chnumber); int stun_attr_add_channel_number(stun_buffer* buf, uint16_t chnumber);
int stun_attr_add_addr(stun_buffer *buf,u16bits attr_type, const ioa_addr* ca); int stun_attr_add_addr(stun_buffer *buf,uint16_t attr_type, const ioa_addr* ca);
stun_attr_ref stun_attr_get_first(const stun_buffer* buf); stun_attr_ref stun_attr_get_first(const stun_buffer* buf);
stun_attr_ref stun_attr_get_first_by_type(const stun_buffer* buf, u16bits attr_type); stun_attr_ref stun_attr_get_first_by_type(const stun_buffer* buf, uint16_t attr_type);
stun_attr_ref stun_attr_get_next(const stun_buffer* buf, stun_attr_ref prev); stun_attr_ref stun_attr_get_next(const stun_buffer* buf, stun_attr_ref prev);
int stun_attr_get_addr(const stun_buffer *buf, stun_attr_ref attr, ioa_addr* ca, const ioa_addr *default_addr); int stun_attr_get_addr(const stun_buffer *buf, stun_attr_ref attr, ioa_addr* ca, const ioa_addr *default_addr);
int stun_attr_add_even_port(stun_buffer* buf, uint8_t value); int stun_attr_add_even_port(stun_buffer* buf, uint8_t value);
int stun_attr_get_first_addr(const stun_buffer *buf, u16bits attr_type, ioa_addr* ca, const ioa_addr *default_addr); int stun_attr_get_first_addr(const stun_buffer *buf, uint16_t attr_type, ioa_addr* ca, const ioa_addr *default_addr);
u16bits stun_attr_get_first_channel_number(const stun_buffer *buf); uint16_t stun_attr_get_first_channel_number(const stun_buffer *buf);
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
@ -96,32 +96,32 @@ int stun_get_command_message_len(const stun_buffer* buf);
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
int stun_init_channel_message(u16bits chnumber, stun_buffer* buf, int length, int do_padding); int stun_init_channel_message(uint16_t chnumber, stun_buffer* buf, int length, int do_padding);
int stun_is_channel_message(stun_buffer* buf, u16bits* chnumber, int is_padding_madatory); int stun_is_channel_message(stun_buffer* buf, uint16_t* chnumber, int is_padding_madatory);
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
int stun_set_allocate_request(stun_buffer* buf, u32bits lifetime, int af4, int af6, u08bits transport, int mobile, const char* rt, int ep); int stun_set_allocate_request(stun_buffer* buf, uint32_t lifetime, int af4, int af6, uint8_t transport, int mobile, const char* rt, int ep);
int stun_set_allocate_response(stun_buffer* buf, stun_tid* tid, int stun_set_allocate_response(stun_buffer* buf, stun_tid* tid,
const ioa_addr *relayed_addr1, const ioa_addr *relayed_addr2, const ioa_addr *relayed_addr1, const ioa_addr *relayed_addr2,
const ioa_addr *reflexive_addr, const ioa_addr *reflexive_addr,
u32bits lifetime, u32bits max_lifetime, uint32_t lifetime, uint32_t max_lifetime,
int error_code, const u08bits *reason, int error_code, const uint8_t *reason,
u64bits reservation_token, char *mobile_id); uint64_t reservation_token, char *mobile_id);
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
void stun_set_binding_request(stun_buffer* buf); void stun_set_binding_request(stun_buffer* buf);
int stun_set_binding_response(stun_buffer* buf, stun_tid* tid, int stun_set_binding_response(stun_buffer* buf, stun_tid* tid,
const ioa_addr *reflexive_addr, int error_code, const u08bits *reason); const ioa_addr *reflexive_addr, int error_code, const uint8_t *reason);
void stun_prepare_binding_request(stun_buffer* buf); void stun_prepare_binding_request(stun_buffer* buf);
int stun_is_binding_response(const stun_buffer* buf); int stun_is_binding_response(const stun_buffer* buf);
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
u16bits stun_set_channel_bind_request(stun_buffer* buf, const ioa_addr* peer_addr, u16bits channel_number); uint16_t stun_set_channel_bind_request(stun_buffer* buf, const ioa_addr* peer_addr, uint16_t channel_number);
void stun_set_channel_bind_response(stun_buffer* buf, stun_tid* tid, int error_code, const u08bits *reason); void stun_set_channel_bind_response(stun_buffer* buf, stun_tid* tid, int error_code, const uint8_t *reason);
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////

View File

@ -81,7 +81,7 @@ static int stunclient_send(int sockfd, ioa_addr *local_addr, int *local_port, io
if (response_port >= 0) { if (response_port >= 0) {
turn::StunAttrResponsePort rpa; turn::StunAttrResponsePort rpa;
rpa.setResponsePort((u16bits)response_port); rpa.setResponsePort((uint16_t)response_port);
try { try {
req.addAttr(rpa); req.addAttr(rpa);
} catch(turn::WrongStunAttrFormatException &ex1) { } catch(turn::WrongStunAttrFormatException &ex1) {
@ -159,7 +159,7 @@ static int stunclient_receive(int sockfd, ioa_addr *local_addr, ioa_addr *reflex
{ {
int len = 0; int len = 0;
stun_buffer buf; stun_buffer buf;
u08bits *ptr = buf.buf; uint8_t *ptr = buf.buf;
int recvd = 0; int recvd = 0;
const int to_recv = sizeof(buf.buf); const int to_recv = sizeof(buf.buf);
struct timeval tv; struct timeval tv;
@ -353,13 +353,13 @@ static int stunclient_send(stun_buffer *buf, int sockfd, ioa_addr *local_addr, i
stun_prepare_binding_request(buf); stun_prepare_binding_request(buf);
if (response_port >= 0) { if (response_port >= 0) {
stun_attr_add_response_port_str((u08bits*) (buf->buf), (size_t*) &(buf->len), (u16bits) response_port); stun_attr_add_response_port_str((uint8_t*) (buf->buf), (size_t*) &(buf->len), (uint16_t) response_port);
} }
if (change_ip || change_port) { if (change_ip || change_port) {
stun_attr_add_change_request_str((u08bits*) buf->buf, (size_t*) &(buf->len), change_ip, change_port); stun_attr_add_change_request_str((uint8_t*) buf->buf, (size_t*) &(buf->len), change_ip, change_port);
} }
if (padding) { if (padding) {
if(stun_attr_add_padding_str((u08bits*) buf->buf, (size_t*) &(buf->len), 1500)<0) { if(stun_attr_add_padding_str((uint8_t*) buf->buf, (size_t*) &(buf->len), 1500)<0) {
printf("%s: ERROR: Cannot add padding\n",__FUNCTION__); printf("%s: ERROR: Cannot add padding\n",__FUNCTION__);
} }
} }
@ -393,7 +393,7 @@ static int stunclient_receive(stun_buffer *buf, int sockfd, ioa_addr *local_addr
{ {
int len = 0; int len = 0;
u08bits *ptr = buf->buf; uint8_t *ptr = buf->buf;
int recvd = 0; int recvd = 0;
const int to_recv = sizeof(buf->buf); const int to_recv = sizeof(buf->buf);
struct timeval tv; struct timeval tv;
@ -444,11 +444,11 @@ static int stunclient_receive(stun_buffer *buf, int sockfd, ioa_addr *local_addr
} else { } else {
printf("Not received mapped address attribute.\n"); printf("Not received mapped address attribute.\n");
} }
stun_attr_get_addr_str((u08bits *) buf->buf, (size_t) buf->len, sar, other_addr, NULL); stun_attr_get_addr_str((uint8_t *) buf->buf, (size_t) buf->len, sar, other_addr, NULL);
sar = stun_attr_get_first_by_type_str(buf->buf, buf->len, STUN_ATTRIBUTE_RESPONSE_ORIGIN); sar = stun_attr_get_first_by_type_str(buf->buf, buf->len, STUN_ATTRIBUTE_RESPONSE_ORIGIN);
if (sar) { if (sar) {
ioa_addr response_origin; ioa_addr response_origin;
stun_attr_get_addr_str((u08bits *) buf->buf, (size_t) buf->len, sar, &response_origin, NULL); stun_attr_get_addr_str((uint8_t *) buf->buf, (size_t) buf->len, sar, &response_origin, NULL);
addr_debug_print(1, &response_origin, "Response origin: "); addr_debug_print(1, &response_origin, "Response origin: ");
} }
addr_debug_print(1, other_addr, "Other addr: "); addr_debug_print(1, other_addr, "Other addr: ");
@ -463,7 +463,7 @@ static int stunclient_receive(stun_buffer *buf, int sockfd, ioa_addr *local_addr
} }
} else { } else {
int err_code = 0; int err_code = 0;
u08bits err_msg[1025] = "\0"; uint8_t err_msg[1025] = "\0";
size_t err_msg_size = sizeof(err_msg); size_t err_msg_size = sizeof(err_msg);
if (stun_is_error_response(buf, &err_code, err_msg, err_msg_size)) { if (stun_is_error_response(buf, &err_code, err_msg, err_msg_size)) {
printf("The response is an error %d (%s)\n", err_code, (char*) err_msg); printf("The response is an error %d (%s)\n", err_code, (char*) err_msg);
@ -592,14 +592,14 @@ static void init(int first, ioa_addr *local_addr, ioa_addr *remote_addr, int *lo
addr_set_any(local_addr); addr_set_any(local_addr);
if(local_addr_string[0]) { if(local_addr_string[0]) {
if(make_ioa_addr((const u08bits*)local_addr_string, 0, local_addr)<0) { if(make_ioa_addr((const uint8_t*)local_addr_string, 0, local_addr)<0) {
err(-1,NULL); err(-1,NULL);
} }
} }
if (!first) *local_port=-1; if (!first) *local_port=-1;
*rfc5780 = 0; *rfc5780 = 0;
if (make_ioa_addr((const u08bits*)remote_param, port, remote_addr) < 0) if (make_ioa_addr((const uint8_t*)remote_param, port, remote_addr) < 0)
err(-1, NULL); err(-1, NULL);
} }
@ -791,7 +791,7 @@ int main(int argc, char **argv)
addr_set_any(&local2_addr); addr_set_any(&local2_addr);
if(local2_addr_string[0]) { if(local2_addr_string[0]) {
if(make_ioa_addr((const u08bits*)local2_addr_string, 0, &local2_addr)<0) { if(make_ioa_addr((const uint8_t*)local2_addr_string, 0, &local2_addr)<0) {
err(-1,NULL); err(-1,NULL);
} }
} }

View File

@ -117,7 +117,7 @@ static int encode_token(const char* server_name,
// TODO: avoid this hack // TODO: avoid this hack
if (!*gcm_nonce) gcm_nonce=NULL; if (!*gcm_nonce) gcm_nonce=NULL;
if (encode_oauth_token((const u08bits *) server_name, &etoken, &key, &ot,(const u08bits *) gcm_nonce) < 0) { if (encode_oauth_token((const uint8_t *) server_name, &etoken, &key, &ot,(const uint8_t *) gcm_nonce) < 0) {
fprintf(stderr, "%s: cannot encode oauth token\n", fprintf(stderr, "%s: cannot encode oauth token\n",
__FUNCTION__); __FUNCTION__);
return -1; return -1;
@ -144,7 +144,7 @@ static int validate_decode_token(const char* server_name,
const unsigned char *tmp = base64_decode(base64encoded_etoken,base64encoded_etoken_length,&etoken.size); const unsigned char *tmp = base64_decode(base64encoded_etoken,base64encoded_etoken_length,&etoken.size);
memcpy(etoken.token,tmp,etoken.size); memcpy(etoken.token,tmp,etoken.size);
if (decode_oauth_token((const u08bits *) server_name, &etoken, &key, dot) < 0) { if (decode_oauth_token((const uint8_t *) server_name, &etoken, &key, dot) < 0) {
fprintf(stderr, "%s: cannot decode oauth token\n", fprintf(stderr, "%s: cannot decode oauth token\n",
__FUNCTION__); __FUNCTION__);
return -1; return -1;

View File

@ -72,7 +72,7 @@ static int udp_create_server_socket(server_type* server,
STRCPY(server->ifname,ifname); STRCPY(server->ifname,ifname);
if(make_ioa_addr((const u08bits*)local_address, port, server_addr)<0) return -1; if(make_ioa_addr((const uint8_t*)local_address, port, server_addr)<0) return -1;
udp_fd = socket(server_addr->ss.sa_family, RELAY_DGRAM_SOCKET_TYPE, RELAY_DGRAM_SOCKET_PROTOCOL); udp_fd = socket(server_addr->ss.sa_family, RELAY_DGRAM_SOCKET_TYPE, RELAY_DGRAM_SOCKET_PROTOCOL);
if (udp_fd < 0) { if (udp_fd < 0) {

View File

@ -144,7 +144,7 @@ static mongoc_collection_t * mongo_get_collection(const char * name) {
/////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
static int mongo_get_auth_secrets(secrets_list_t *sl, u08bits *realm) { static int mongo_get_auth_secrets(secrets_list_t *sl, uint8_t *realm) {
mongoc_collection_t * collection = mongo_get_collection("turn_secret"); mongoc_collection_t * collection = mongo_get_collection("turn_secret");
if(!collection) if(!collection)
@ -186,7 +186,7 @@ static int mongo_get_auth_secrets(secrets_list_t *sl, u08bits *realm) {
return ret; return ret;
} }
static int mongo_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) { static int mongo_get_user_key(uint8_t *usname, uint8_t *realm, hmackey_t key) {
mongoc_collection_t * collection = mongo_get_collection("turnusers_lt"); mongoc_collection_t * collection = mongo_get_collection("turnusers_lt");
if(!collection) if(!collection)
@ -239,7 +239,7 @@ static int mongo_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) {
return ret; return ret;
} }
static int mongo_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) { static int mongo_get_oauth_key(const uint8_t *kid, oauth_key_data_raw *key) {
mongoc_collection_t * collection = mongo_get_collection("oauth_key"); mongoc_collection_t * collection = mongo_get_collection("oauth_key");
@ -285,10 +285,10 @@ static int mongo_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
STRCPY(key->ikm_key,bson_iter_utf8(&iter, &length)); STRCPY(key->ikm_key,bson_iter_utf8(&iter, &length));
} }
if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "timestamp") && BSON_ITER_HOLDS_INT64(&iter)) { if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "timestamp") && BSON_ITER_HOLDS_INT64(&iter)) {
key->timestamp = (u64bits)bson_iter_int64(&iter); key->timestamp = (uint64_t)bson_iter_int64(&iter);
} }
if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "lifetime") && BSON_ITER_HOLDS_INT32(&iter)) { if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "lifetime") && BSON_ITER_HOLDS_INT32(&iter)) {
key->lifetime = (u32bits)bson_iter_int32(&iter); key->lifetime = (uint32_t)bson_iter_int32(&iter);
} }
ret = 0; ret = 0;
} }
@ -300,7 +300,7 @@ static int mongo_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
return ret; return ret;
} }
static int mongo_set_user_key(u08bits *usname, u08bits *realm, const char *key) { static int mongo_set_user_key(uint8_t *usname, uint8_t *realm, const char *key) {
mongoc_collection_t * collection = mongo_get_collection("turnusers_lt"); mongoc_collection_t * collection = mongo_get_collection("turnusers_lt");
if(!collection) if(!collection)
@ -363,7 +363,7 @@ static int mongo_set_oauth_key(oauth_key_data_raw *key) {
return ret; return ret;
} }
static int mongo_del_user(u08bits *usname, u08bits *realm) { static int mongo_del_user(uint8_t *usname, uint8_t *realm) {
mongoc_collection_t * collection = mongo_get_collection("turnusers_lt"); mongoc_collection_t * collection = mongo_get_collection("turnusers_lt");
if(!collection) if(!collection)
@ -386,7 +386,7 @@ static int mongo_del_user(u08bits *usname, u08bits *realm) {
return ret; return ret;
} }
static int mongo_del_oauth_key(const u08bits *kid) { static int mongo_del_oauth_key(const uint8_t *kid) {
mongoc_collection_t * collection = mongo_get_collection("oauth_key"); mongoc_collection_t * collection = mongo_get_collection("oauth_key");
@ -409,12 +409,12 @@ static int mongo_del_oauth_key(const u08bits *kid) {
return ret; return ret;
} }
static int mongo_list_users(u08bits *realm, secrets_list_t *users, secrets_list_t *realms) static int mongo_list_users(uint8_t *realm, secrets_list_t *users, secrets_list_t *realms)
{ {
const char * collection_name = "turnusers_lt"; const char * collection_name = "turnusers_lt";
mongoc_collection_t * collection = mongo_get_collection(collection_name); mongoc_collection_t * collection = mongo_get_collection(collection_name);
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
if(!collection) if(!collection)
@ -538,10 +538,10 @@ static int mongo_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
STRCPY(key->ikm_key,bson_iter_utf8(&iter, &length)); STRCPY(key->ikm_key,bson_iter_utf8(&iter, &length));
} }
if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "timestamp") && BSON_ITER_HOLDS_INT64(&iter)) { if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "timestamp") && BSON_ITER_HOLDS_INT64(&iter)) {
key->timestamp = (u64bits)bson_iter_int64(&iter); key->timestamp = (uint64_t)bson_iter_int64(&iter);
} }
if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "lifetime") && BSON_ITER_HOLDS_INT32(&iter)) { if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "lifetime") && BSON_ITER_HOLDS_INT32(&iter)) {
key->lifetime = (u32bits)bson_iter_int32(&iter); key->lifetime = (uint32_t)bson_iter_int32(&iter);
} }
if(kids) { if(kids) {
add_to_secrets_list(kids,key->kid); add_to_secrets_list(kids,key->kid);
@ -572,11 +572,11 @@ static int mongo_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
return ret; return ret;
} }
static int mongo_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_list_t *realms) static int mongo_list_secrets(uint8_t *realm, secrets_list_t *secrets, secrets_list_t *realms)
{ {
mongoc_collection_t * collection = mongo_get_collection("turn_secret"); mongoc_collection_t * collection = mongo_get_collection("turn_secret");
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
if(!collection) if(!collection)
@ -644,7 +644,7 @@ static int mongo_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_l
return ret; return ret;
} }
static int mongo_del_secret(u08bits *secret, u08bits *realm) { static int mongo_del_secret(uint8_t *secret, uint8_t *realm) {
mongoc_collection_t * collection = mongo_get_collection("turn_secret"); mongoc_collection_t * collection = mongo_get_collection("turn_secret");
if(!collection) if(!collection)
@ -663,7 +663,7 @@ static int mongo_del_secret(u08bits *secret, u08bits *realm) {
return 0; return 0;
} }
static int mongo_set_secret(u08bits *secret, u08bits *realm) { static int mongo_set_secret(uint8_t *secret, uint8_t *realm) {
mongoc_collection_t * collection = mongo_get_collection("turn_secret"); mongoc_collection_t * collection = mongo_get_collection("turn_secret");
if(!collection) if(!collection)
@ -686,7 +686,7 @@ static int mongo_set_secret(u08bits *secret, u08bits *realm) {
} }
} }
static int mongo_set_permission_ip(const char *kind, u08bits *realm, const char* ip, int del) static int mongo_set_permission_ip(const char *kind, uint8_t *realm, const char* ip, int del)
{ {
char sub_collection_name[129]; char sub_collection_name[129];
snprintf(sub_collection_name,sizeof(sub_collection_name)-1,"%s_peer_ip",kind); snprintf(sub_collection_name,sizeof(sub_collection_name)-1,"%s_peer_ip",kind);
@ -698,7 +698,7 @@ static int mongo_set_permission_ip(const char *kind, u08bits *realm, const char*
int ret = -1; int ret = -1;
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
bson_t query, doc, child; bson_t query, doc, child;
@ -732,7 +732,7 @@ static int mongo_set_permission_ip(const char *kind, u08bits *realm, const char*
return ret; return ret;
} }
static int mongo_add_origin(u08bits *origin, u08bits *realm) static int mongo_add_origin(uint8_t *origin, uint8_t *realm)
{ {
mongoc_collection_t * collection = mongo_get_collection("realm"); mongoc_collection_t * collection = mongo_get_collection("realm");
@ -741,7 +741,7 @@ static int mongo_add_origin(u08bits *origin, u08bits *realm)
int ret = -1; int ret = -1;
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
bson_t query, doc, child; bson_t query, doc, child;
@ -763,7 +763,7 @@ static int mongo_add_origin(u08bits *origin, u08bits *realm)
return ret; return ret;
} }
static int mongo_del_origin(u08bits *origin) static int mongo_del_origin(uint8_t *origin)
{ {
mongoc_collection_t * collection = mongo_get_collection("realm"); mongoc_collection_t * collection = mongo_get_collection("realm");
@ -790,14 +790,14 @@ static int mongo_del_origin(u08bits *origin)
return ret; return ret;
} }
static int mongo_list_origins(u08bits *realm, secrets_list_t *origins, secrets_list_t *realms) static int mongo_list_origins(uint8_t *realm, secrets_list_t *origins, secrets_list_t *realms)
{ {
mongoc_collection_t * collection = mongo_get_collection("realm"); mongoc_collection_t * collection = mongo_get_collection("realm");
if(!collection) if(!collection)
return -1; return -1;
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
bson_t query, child; bson_t query, child;
@ -868,7 +868,7 @@ static int mongo_list_origins(u08bits *realm, secrets_list_t *origins, secrets_l
return ret; return ret;
} }
static int mongo_set_realm_option_one(u08bits *realm, unsigned long value, const char* opt) { static int mongo_set_realm_option_one(uint8_t *realm, unsigned long value, const char* opt) {
mongoc_collection_t * collection = mongo_get_collection("realm"); mongoc_collection_t * collection = mongo_get_collection("realm");
if(!collection) if(!collection)
@ -908,7 +908,7 @@ static int mongo_set_realm_option_one(u08bits *realm, unsigned long value, const
return ret; return ret;
} }
static int mongo_list_realm_options(u08bits *realm) { static int mongo_list_realm_options(uint8_t *realm) {
mongoc_collection_t * collection = mongo_get_collection("realm"); mongoc_collection_t * collection = mongo_get_collection("realm");
if(!collection) if(!collection)
@ -1186,7 +1186,7 @@ static void mongo_reread_realms(secrets_list_t * realms_list) {
///////////////////////////////////////////////// /////////////////////////////////////////////////
static int mongo_get_admin_user(const u08bits *usname, u08bits *realm, password_t pwd) static int mongo_get_admin_user(const uint8_t *usname, uint8_t *realm, password_t pwd)
{ {
mongoc_collection_t * collection = mongo_get_collection("admin_user"); mongoc_collection_t * collection = mongo_get_collection("admin_user");
@ -1234,7 +1234,7 @@ static int mongo_get_admin_user(const u08bits *usname, u08bits *realm, password_
return ret; return ret;
} }
static int mongo_set_admin_user(const u08bits *usname, const u08bits *realm, const password_t pwd) static int mongo_set_admin_user(const uint8_t *usname, const uint8_t *realm, const password_t pwd)
{ {
mongoc_collection_t * collection = mongo_get_collection("admin_user"); mongoc_collection_t * collection = mongo_get_collection("admin_user");
@ -1264,7 +1264,7 @@ static int mongo_set_admin_user(const u08bits *usname, const u08bits *realm, con
return ret; return ret;
} }
static int mongo_del_admin_user(const u08bits *usname) static int mongo_del_admin_user(const uint8_t *usname)
{ {
mongoc_collection_t * collection = mongo_get_collection("admin_user"); mongoc_collection_t * collection = mongo_get_collection("admin_user");

View File

@ -299,7 +299,7 @@ static MYSQL *get_mydb_connection(void) {
/////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
static int mysql_get_auth_secrets(secrets_list_t *sl, u08bits *realm) { static int mysql_get_auth_secrets(secrets_list_t *sl, uint8_t *realm) {
int ret = -1; int ret = -1;
MYSQL * myc = get_mydb_connection(); MYSQL * myc = get_mydb_connection();
if(myc) { if(myc) {
@ -340,7 +340,7 @@ static int mysql_get_auth_secrets(secrets_list_t *sl, u08bits *realm) {
return ret; return ret;
} }
static int mysql_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) { static int mysql_get_user_key(uint8_t *usname, uint8_t *realm, hmackey_t key) {
int ret = -1; int ret = -1;
MYSQL * myc = get_mydb_connection(); MYSQL * myc = get_mydb_connection();
if(myc) { if(myc) {
@ -385,7 +385,7 @@ static int mysql_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) {
return ret; return ret;
} }
static int mysql_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) { static int mysql_get_oauth_key(const uint8_t *kid, oauth_key_data_raw *key) {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -415,12 +415,12 @@ static int mysql_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
char stimestamp[128]; char stimestamp[128];
bcopy(row[1],stimestamp,lengths[1]); bcopy(row[1],stimestamp,lengths[1]);
stimestamp[lengths[1]]=0; stimestamp[lengths[1]]=0;
key->timestamp = (u64bits)strtoull(stimestamp,NULL,10); key->timestamp = (uint64_t)strtoull(stimestamp,NULL,10);
char slifetime[128]; char slifetime[128];
bcopy(row[2],slifetime,lengths[2]); bcopy(row[2],slifetime,lengths[2]);
slifetime[lengths[2]]=0; slifetime[lengths[2]]=0;
key->lifetime = (u32bits)strtoul(slifetime,NULL,10); key->lifetime = (uint32_t)strtoul(slifetime,NULL,10);
bcopy(row[3],key->as_rs_alg,lengths[3]); bcopy(row[3],key->as_rs_alg,lengths[3]);
key->as_rs_alg[lengths[3]]=0; key->as_rs_alg[lengths[3]]=0;
@ -471,12 +471,12 @@ static int mysql_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
char stimestamp[128]; char stimestamp[128];
bcopy(row[1],stimestamp,lengths[1]); bcopy(row[1],stimestamp,lengths[1]);
stimestamp[lengths[1]]=0; stimestamp[lengths[1]]=0;
key->timestamp = (u64bits)strtoull(stimestamp,NULL,10); key->timestamp = (uint64_t)strtoull(stimestamp,NULL,10);
char slifetime[128]; char slifetime[128];
bcopy(row[2],slifetime,lengths[2]); bcopy(row[2],slifetime,lengths[2]);
slifetime[lengths[2]]=0; slifetime[lengths[2]]=0;
key->lifetime = (u32bits)strtoul(slifetime,NULL,10); key->lifetime = (uint32_t)strtoul(slifetime,NULL,10);
bcopy(row[3],key->as_rs_alg,lengths[3]); bcopy(row[3],key->as_rs_alg,lengths[3]);
key->as_rs_alg[lengths[3]]=0; key->as_rs_alg[lengths[3]]=0;
@ -519,7 +519,7 @@ static int mysql_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
return ret; return ret;
} }
static int mysql_set_user_key(u08bits *usname, u08bits *realm, const char *key) static int mysql_set_user_key(uint8_t *usname, uint8_t *realm, const char *key)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -568,7 +568,7 @@ static int mysql_set_oauth_key(oauth_key_data_raw *key)
return ret; return ret;
} }
static int mysql_del_user(u08bits *usname, u08bits *realm) { static int mysql_del_user(uint8_t *usname, uint8_t *realm) {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
MYSQL * myc = get_mydb_connection(); MYSQL * myc = get_mydb_connection();
@ -584,7 +584,7 @@ static int mysql_del_user(u08bits *usname, u08bits *realm) {
return ret; return ret;
} }
static int mysql_del_oauth_key(const u08bits *kid) { static int mysql_del_oauth_key(const uint8_t *kid) {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
MYSQL * myc = get_mydb_connection(); MYSQL * myc = get_mydb_connection();
@ -600,12 +600,12 @@ static int mysql_del_oauth_key(const u08bits *kid) {
return ret; return ret;
} }
static int mysql_list_users(u08bits *realm, secrets_list_t *users, secrets_list_t *realms) static int mysql_list_users(uint8_t *realm, secrets_list_t *users, secrets_list_t *realms)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
MYSQL * myc = get_mydb_connection(); MYSQL * myc = get_mydb_connection();
@ -656,11 +656,11 @@ static int mysql_list_users(u08bits *realm, secrets_list_t *users, secrets_list_
return ret; return ret;
} }
static int mysql_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_list_t *realms) static int mysql_list_secrets(uint8_t *realm, secrets_list_t *secrets, secrets_list_t *realms)
{ {
int ret = -1; int ret = -1;
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -717,7 +717,7 @@ static int mysql_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_l
return ret; return ret;
} }
static int mysql_del_secret(u08bits *secret, u08bits *realm) { static int mysql_del_secret(uint8_t *secret, uint8_t *realm) {
int ret = -1; int ret = -1;
donot_print_connection_success=1; donot_print_connection_success=1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -733,7 +733,7 @@ static int mysql_del_secret(u08bits *secret, u08bits *realm) {
return ret; return ret;
} }
static int mysql_set_secret(u08bits *secret, u08bits *realm) { static int mysql_set_secret(uint8_t *secret, uint8_t *realm) {
int ret = -1; int ret = -1;
donot_print_connection_success = 1; donot_print_connection_success = 1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -753,11 +753,11 @@ static int mysql_set_secret(u08bits *secret, u08bits *realm) {
return ret; return ret;
} }
static int mysql_set_permission_ip(const char *kind, u08bits *realm, const char* ip, int del) static int mysql_set_permission_ip(const char *kind, uint8_t *realm, const char* ip, int del)
{ {
int ret = -1; int ret = -1;
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
donot_print_connection_success = 1; donot_print_connection_success = 1;
@ -784,7 +784,7 @@ static int mysql_set_permission_ip(const char *kind, u08bits *realm, const char*
return ret; return ret;
} }
static int mysql_add_origin(u08bits *origin, u08bits *realm) { static int mysql_add_origin(uint8_t *origin, uint8_t *realm) {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
MYSQL * myc = get_mydb_connection(); MYSQL * myc = get_mydb_connection();
@ -803,7 +803,7 @@ static int mysql_add_origin(u08bits *origin, u08bits *realm) {
return ret; return ret;
} }
static int mysql_del_origin(u08bits *origin) { static int mysql_del_origin(uint8_t *origin) {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
MYSQL * myc = get_mydb_connection(); MYSQL * myc = get_mydb_connection();
@ -822,11 +822,11 @@ static int mysql_del_origin(u08bits *origin) {
return ret; return ret;
} }
static int mysql_list_origins(u08bits *realm, secrets_list_t *origins, secrets_list_t *realms) static int mysql_list_origins(uint8_t *realm, secrets_list_t *origins, secrets_list_t *realms)
{ {
int ret = -1; int ret = -1;
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
donot_print_connection_success = 1; donot_print_connection_success = 1;
@ -882,7 +882,7 @@ static int mysql_list_origins(u08bits *realm, secrets_list_t *origins, secrets_l
return ret; return ret;
} }
static int mysql_set_realm_option_one(u08bits *realm, unsigned long value, const char* opt) { static int mysql_set_realm_option_one(uint8_t *realm, unsigned long value, const char* opt) {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
MYSQL * myc = get_mydb_connection(); MYSQL * myc = get_mydb_connection();
@ -907,7 +907,7 @@ static int mysql_set_realm_option_one(u08bits *realm, unsigned long value, const
return ret; return ret;
} }
static int mysql_list_realm_options(u08bits *realm) { static int mysql_list_realm_options(uint8_t *realm) {
int ret = -1; int ret = -1;
donot_print_connection_success = 1; donot_print_connection_success = 1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -1140,7 +1140,7 @@ static void mysql_reread_realms(secrets_list_t * realms_list) {
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
static int mysql_get_admin_user(const u08bits *usname, u08bits *realm, password_t pwd) static int mysql_get_admin_user(const uint8_t *usname, uint8_t *realm, password_t pwd)
{ {
int ret = -1; int ret = -1;
@ -1176,7 +1176,7 @@ static int mysql_get_admin_user(const u08bits *usname, u08bits *realm, password_
return ret; return ret;
} }
static int mysql_set_admin_user(const u08bits *usname, const u08bits *realm, const password_t pwd) static int mysql_set_admin_user(const uint8_t *usname, const uint8_t *realm, const password_t pwd)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -1200,7 +1200,7 @@ static int mysql_set_admin_user(const u08bits *usname, const u08bits *realm, con
return ret; return ret;
} }
static int mysql_del_admin_user(const u08bits *usname) static int mysql_del_admin_user(const uint8_t *usname)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];

View File

@ -91,7 +91,7 @@ static PGconn *get_pqdb_connection(void) {
/////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
static int pgsql_get_auth_secrets(secrets_list_t *sl, u08bits *realm) { static int pgsql_get_auth_secrets(secrets_list_t *sl, uint8_t *realm) {
int ret = -1; int ret = -1;
PGconn * pqc = get_pqdb_connection(); PGconn * pqc = get_pqdb_connection();
if(pqc) { if(pqc) {
@ -119,7 +119,7 @@ static int pgsql_get_auth_secrets(secrets_list_t *sl, u08bits *realm) {
return ret; return ret;
} }
static int pgsql_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) { static int pgsql_get_user_key(uint8_t *usname, uint8_t *realm, hmackey_t key) {
int ret = -1; int ret = -1;
PGconn * pqc = get_pqdb_connection(); PGconn * pqc = get_pqdb_connection();
if(pqc) { if(pqc) {
@ -154,7 +154,7 @@ static int pgsql_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) {
return ret; return ret;
} }
static int pgsql_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) { static int pgsql_get_oauth_key(const uint8_t *kid, oauth_key_data_raw *key) {
int ret = -1; int ret = -1;
@ -170,8 +170,8 @@ static int pgsql_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Error retrieving PostgreSQL DB information: %s\n",PQerrorMessage(pqc)); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Error retrieving PostgreSQL DB information: %s\n",PQerrorMessage(pqc));
} else { } else {
STRCPY(key->ikm_key,PQgetvalue(res,0,0)); STRCPY(key->ikm_key,PQgetvalue(res,0,0));
key->timestamp = (u64bits)strtoll(PQgetvalue(res,0,1),NULL,10); key->timestamp = (uint64_t)strtoll(PQgetvalue(res,0,1),NULL,10);
key->lifetime = (u32bits)strtol(PQgetvalue(res,0,2),NULL,10); key->lifetime = (uint32_t)strtol(PQgetvalue(res,0,2),NULL,10);
STRCPY(key->as_rs_alg,PQgetvalue(res,0,3)); STRCPY(key->as_rs_alg,PQgetvalue(res,0,3));
STRCPY(key->realm,PQgetvalue(res,0,4)); STRCPY(key->realm,PQgetvalue(res,0,4));
STRCPY(key->kid,kid); STRCPY(key->kid,kid);
@ -207,8 +207,8 @@ static int pgsql_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
for(i=0;i<PQntuples(res);i++) { for(i=0;i<PQntuples(res);i++) {
STRCPY(key->ikm_key,PQgetvalue(res,i,0)); STRCPY(key->ikm_key,PQgetvalue(res,i,0));
key->timestamp = (u64bits)strtoll(PQgetvalue(res,i,1),NULL,10); key->timestamp = (uint64_t)strtoll(PQgetvalue(res,i,1),NULL,10);
key->lifetime = (u32bits)strtol(PQgetvalue(res,i,2),NULL,10); key->lifetime = (uint32_t)strtol(PQgetvalue(res,i,2),NULL,10);
STRCPY(key->as_rs_alg,PQgetvalue(res,i,3)); STRCPY(key->as_rs_alg,PQgetvalue(res,i,3));
STRCPY(key->realm,PQgetvalue(res,i,4)); STRCPY(key->realm,PQgetvalue(res,i,4));
STRCPY(key->kid,PQgetvalue(res,i,5)); STRCPY(key->kid,PQgetvalue(res,i,5));
@ -245,7 +245,7 @@ static int pgsql_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
return ret; return ret;
} }
static int pgsql_set_user_key(u08bits *usname, u08bits *realm, const char *key) { static int pgsql_set_user_key(uint8_t *usname, uint8_t *realm, const char *key) {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
PGconn *pqc = get_pqdb_connection(); PGconn *pqc = get_pqdb_connection();
@ -306,7 +306,7 @@ static int pgsql_set_oauth_key(oauth_key_data_raw *key) {
return ret; return ret;
} }
static int pgsql_del_user(u08bits *usname, u08bits *realm) { static int pgsql_del_user(uint8_t *usname, uint8_t *realm) {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
PGconn *pqc = get_pqdb_connection(); PGconn *pqc = get_pqdb_connection();
@ -321,7 +321,7 @@ static int pgsql_del_user(u08bits *usname, u08bits *realm) {
return ret; return ret;
} }
static int pgsql_del_oauth_key(const u08bits *kid) { static int pgsql_del_oauth_key(const uint8_t *kid) {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -342,12 +342,12 @@ static int pgsql_del_oauth_key(const u08bits *kid) {
return ret; return ret;
} }
static int pgsql_list_users(u08bits *realm, secrets_list_t *users, secrets_list_t *realms) static int pgsql_list_users(uint8_t *realm, secrets_list_t *users, secrets_list_t *realms)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
PGconn *pqc = get_pqdb_connection(); PGconn *pqc = get_pqdb_connection();
@ -391,11 +391,11 @@ static int pgsql_list_users(u08bits *realm, secrets_list_t *users, secrets_list_
return ret; return ret;
} }
static int pgsql_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_list_t *realms) static int pgsql_list_secrets(uint8_t *realm, secrets_list_t *secrets, secrets_list_t *realms)
{ {
int ret = -1; int ret = -1;
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -441,7 +441,7 @@ static int pgsql_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_l
return ret; return ret;
} }
static int pgsql_del_secret(u08bits *secret, u08bits *realm) { static int pgsql_del_secret(uint8_t *secret, uint8_t *realm) {
int ret = -1; int ret = -1;
donot_print_connection_success=1; donot_print_connection_success=1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -461,7 +461,7 @@ static int pgsql_del_secret(u08bits *secret, u08bits *realm) {
return ret; return ret;
} }
static int pgsql_set_secret(u08bits *secret, u08bits *realm) { static int pgsql_set_secret(uint8_t *secret, uint8_t *realm) {
int ret = -1; int ret = -1;
donot_print_connection_success = 1; donot_print_connection_success = 1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -485,11 +485,11 @@ static int pgsql_set_secret(u08bits *secret, u08bits *realm) {
return ret; return ret;
} }
static int pgsql_set_permission_ip(const char *kind, u08bits *realm, const char* ip, int del) static int pgsql_set_permission_ip(const char *kind, uint8_t *realm, const char* ip, int del)
{ {
int ret = -1; int ret = -1;
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
donot_print_connection_success = 1; donot_print_connection_success = 1;
@ -523,7 +523,7 @@ static int pgsql_set_permission_ip(const char *kind, u08bits *realm, const char*
return ret; return ret;
} }
static int pgsql_add_origin(u08bits *origin, u08bits *realm) { static int pgsql_add_origin(uint8_t *origin, uint8_t *realm) {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
PGconn *pqc = get_pqdb_connection(); PGconn *pqc = get_pqdb_connection();
@ -542,7 +542,7 @@ static int pgsql_add_origin(u08bits *origin, u08bits *realm) {
return ret; return ret;
} }
static int pgsql_del_origin(u08bits *origin) { static int pgsql_del_origin(uint8_t *origin) {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
PGconn *pqc = get_pqdb_connection(); PGconn *pqc = get_pqdb_connection();
@ -561,11 +561,11 @@ static int pgsql_del_origin(u08bits *origin) {
return ret; return ret;
} }
static int pgsql_list_origins(u08bits *realm, secrets_list_t *origins, secrets_list_t *realms) static int pgsql_list_origins(uint8_t *realm, secrets_list_t *origins, secrets_list_t *realms)
{ {
int ret = -1; int ret = -1;
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
donot_print_connection_success = 1; donot_print_connection_success = 1;
@ -615,7 +615,7 @@ static int pgsql_list_origins(u08bits *realm, secrets_list_t *origins, secrets_l
return ret; return ret;
} }
static int pgsql_set_realm_option_one(u08bits *realm, unsigned long value, const char* opt) { static int pgsql_set_realm_option_one(uint8_t *realm, unsigned long value, const char* opt) {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
PGconn *pqc = get_pqdb_connection(); PGconn *pqc = get_pqdb_connection();
@ -643,7 +643,7 @@ static int pgsql_set_realm_option_one(u08bits *realm, unsigned long value, const
return ret; return ret;
} }
static int pgsql_list_realm_options(u08bits *realm) { static int pgsql_list_realm_options(uint8_t *realm) {
int ret = -1; int ret = -1;
donot_print_connection_success = 1; donot_print_connection_success = 1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -835,7 +835,7 @@ static void pgsql_reread_realms(secrets_list_t * realms_list) {
////////////////////////////////////////////// //////////////////////////////////////////////
static int pgsql_get_admin_user(const u08bits *usname, u08bits *realm, password_t pwd) static int pgsql_get_admin_user(const uint8_t *usname, uint8_t *realm, password_t pwd)
{ {
int ret = -1; int ret = -1;
@ -869,7 +869,7 @@ static int pgsql_get_admin_user(const u08bits *usname, u08bits *realm, password_
return ret; return ret;
} }
static int pgsql_set_admin_user(const u08bits *usname, const u08bits *realm, const password_t pwd) static int pgsql_set_admin_user(const uint8_t *usname, const uint8_t *realm, const password_t pwd)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -898,7 +898,7 @@ static int pgsql_set_admin_user(const u08bits *usname, const u08bits *realm, con
return ret; return ret;
} }
static int pgsql_del_admin_user(const u08bits *usname) static int pgsql_del_admin_user(const uint8_t *usname)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];

View File

@ -397,7 +397,7 @@ static int set_redis_realm_opt(char *realm, const char* key, unsigned long *valu
/////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
static int redis_get_auth_secrets(secrets_list_t *sl, u08bits *realm) static int redis_get_auth_secrets(secrets_list_t *sl, uint8_t *realm)
{ {
int ret = -1; int ret = -1;
redisContext *rc = get_redis_connection(); redisContext *rc = get_redis_connection();
@ -425,7 +425,7 @@ static int redis_get_auth_secrets(secrets_list_t *sl, u08bits *realm)
return ret; return ret;
} }
static int redis_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) { static int redis_get_user_key(uint8_t *usname, uint8_t *realm, hmackey_t key) {
int ret = -1; int ret = -1;
redisContext * rc = get_redis_connection(); redisContext * rc = get_redis_connection();
if(rc) { if(rc) {
@ -454,7 +454,7 @@ static int redis_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) {
return ret; return ret;
} }
static int redis_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) { static int redis_get_oauth_key(const uint8_t *kid, oauth_key_data_raw *key) {
int ret = -1; int ret = -1;
redisContext * rc = get_redis_connection(); redisContext * rc = get_redis_connection();
if(rc) { if(rc) {
@ -482,9 +482,9 @@ static int redis_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
} else if(!strcmp(kw,"ikm_key")) { } else if(!strcmp(kw,"ikm_key")) {
STRCPY(key->ikm_key,val); STRCPY(key->ikm_key,val);
} else if(!strcmp(kw,"timestamp")) { } else if(!strcmp(kw,"timestamp")) {
key->timestamp = (u64bits)strtoull(val,NULL,10); key->timestamp = (uint64_t)strtoull(val,NULL,10);
} else if(!strcmp(kw,"lifetime")) { } else if(!strcmp(kw,"lifetime")) {
key->lifetime = (u32bits)strtoul(val,NULL,10); key->lifetime = (uint32_t)strtoul(val,NULL,10);
} }
} }
} }
@ -496,7 +496,7 @@ static int redis_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
return ret; return ret;
} }
static int redis_set_user_key(u08bits *usname, u08bits *realm, const char *key) { static int redis_set_user_key(uint8_t *usname, uint8_t *realm, const char *key) {
int ret = -1; int ret = -1;
redisContext *rc = get_redis_connection(); redisContext *rc = get_redis_connection();
if(rc) { if(rc) {
@ -523,7 +523,7 @@ static int redis_set_oauth_key(oauth_key_data_raw *key) {
return ret; return ret;
} }
static int redis_del_user(u08bits *usname, u08bits *realm) { static int redis_del_user(uint8_t *usname, uint8_t *realm) {
int ret = -1; int ret = -1;
redisContext *rc = get_redis_connection(); redisContext *rc = get_redis_connection();
if(rc) { if(rc) {
@ -539,7 +539,7 @@ static int redis_del_user(u08bits *usname, u08bits *realm) {
return ret; return ret;
} }
static int redis_del_oauth_key(const u08bits *kid) { static int redis_del_oauth_key(const uint8_t *kid) {
int ret = -1; int ret = -1;
redisContext *rc = get_redis_connection(); redisContext *rc = get_redis_connection();
if(rc) { if(rc) {
@ -552,12 +552,12 @@ static int redis_del_oauth_key(const u08bits *kid) {
return ret; return ret;
} }
static int redis_list_users(u08bits *realm, secrets_list_t *users, secrets_list_t *realms) static int redis_list_users(uint8_t *realm, secrets_list_t *users, secrets_list_t *realms)
{ {
int ret = -1; int ret = -1;
redisContext *rc = get_redis_connection(); redisContext *rc = get_redis_connection();
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
if(rc) { if(rc) {
@ -666,7 +666,7 @@ static int redis_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
s += strlen("turn/oauth/kid/"); s += strlen("turn/oauth/kid/");
oauth_key_data_raw key_; oauth_key_data_raw key_;
oauth_key_data_raw *key=&key_; oauth_key_data_raw *key=&key_;
if(redis_get_oauth_key((const u08bits*)s,key) == 0) { if(redis_get_oauth_key((const uint8_t*)s,key) == 0) {
if(kids) { if(kids) {
add_to_secrets_list(kids,key->kid); add_to_secrets_list(kids,key->kid);
add_to_secrets_list(teas,key->as_rs_alg); add_to_secrets_list(teas,key->as_rs_alg);
@ -696,11 +696,11 @@ static int redis_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
} }
static int redis_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_list_t *realms) static int redis_list_secrets(uint8_t *realm, secrets_list_t *secrets, secrets_list_t *realms)
{ {
int ret = -1; int ret = -1;
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
donot_print_connection_success = 1; donot_print_connection_success = 1;
@ -787,7 +787,7 @@ static int redis_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_l
} }
static int redis_del_secret(u08bits *secret, u08bits *realm) static int redis_del_secret(uint8_t *secret, uint8_t *realm)
{ {
int ret = -1; int ret = -1;
donot_print_connection_success = 1; donot_print_connection_success = 1;
@ -801,7 +801,7 @@ static int redis_del_secret(u08bits *secret, u08bits *realm)
} }
static int redis_set_secret(u08bits *secret, u08bits *realm) static int redis_set_secret(uint8_t *secret, uint8_t *realm)
{ {
int ret = -1; int ret = -1;
donot_print_connection_success = 1; donot_print_connection_success = 1;
@ -820,11 +820,11 @@ static int redis_set_secret(u08bits *secret, u08bits *realm)
return ret; return ret;
} }
static int redis_set_permission_ip(const char *kind, u08bits *realm, const char* ip, int del) static int redis_set_permission_ip(const char *kind, uint8_t *realm, const char* ip, int del)
{ {
int ret = -1; int ret = -1;
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
donot_print_connection_success = 1; donot_print_connection_success = 1;
@ -846,7 +846,7 @@ static int redis_set_permission_ip(const char *kind, u08bits *realm, const char*
return ret; return ret;
} }
static int redis_add_origin(u08bits *origin, u08bits *realm) { static int redis_add_origin(uint8_t *origin, uint8_t *realm) {
int ret = -1; int ret = -1;
redisContext *rc = get_redis_connection(); redisContext *rc = get_redis_connection();
if(rc) { if(rc) {
@ -861,7 +861,7 @@ static int redis_add_origin(u08bits *origin, u08bits *realm) {
return ret; return ret;
} }
static int redis_del_origin(u08bits *origin) { static int redis_del_origin(uint8_t *origin) {
int ret = -1; int ret = -1;
redisContext *rc = get_redis_connection(); redisContext *rc = get_redis_connection();
if(rc) { if(rc) {
@ -876,11 +876,11 @@ static int redis_del_origin(u08bits *origin) {
return ret; return ret;
} }
static int redis_list_origins(u08bits *realm, secrets_list_t *origins, secrets_list_t *realms) static int redis_list_origins(uint8_t *realm, secrets_list_t *origins, secrets_list_t *realms)
{ {
int ret = -1; int ret = -1;
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
donot_print_connection_success = 1; donot_print_connection_success = 1;
@ -948,7 +948,7 @@ static int redis_list_origins(u08bits *realm, secrets_list_t *origins, secrets_l
return ret; return ret;
} }
static int redis_set_realm_option_one(u08bits *realm, unsigned long value, const char* opt) { static int redis_set_realm_option_one(uint8_t *realm, unsigned long value, const char* opt) {
int ret = -1; int ret = -1;
redisContext *rc = get_redis_connection(); redisContext *rc = get_redis_connection();
if(rc) { if(rc) {
@ -966,7 +966,7 @@ static int redis_set_realm_option_one(u08bits *realm, unsigned long value, const
return ret; return ret;
} }
static int redis_list_realm_options(u08bits *realm) { static int redis_list_realm_options(uint8_t *realm) {
int ret = -1; int ret = -1;
donot_print_connection_success = 1; donot_print_connection_success = 1;
redisContext *rc = get_redis_connection(); redisContext *rc = get_redis_connection();
@ -1222,7 +1222,7 @@ static void redis_reread_realms(secrets_list_t * realms_list) {
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
static int redis_get_admin_user(const u08bits *usname, u08bits *realm, password_t pwd) static int redis_get_admin_user(const uint8_t *usname, uint8_t *realm, password_t pwd)
{ {
int ret = -1; int ret = -1;
redisContext * rc = get_redis_connection(); redisContext * rc = get_redis_connection();
@ -1259,7 +1259,7 @@ static int redis_get_admin_user(const u08bits *usname, u08bits *realm, password_
return ret; return ret;
} }
static int redis_set_admin_user(const u08bits *usname, const u08bits *realm, const password_t pwd) static int redis_set_admin_user(const uint8_t *usname, const uint8_t *realm, const password_t pwd)
{ {
int ret = -1; int ret = -1;
donot_print_connection_success = 1; donot_print_connection_success = 1;
@ -1278,7 +1278,7 @@ static int redis_set_admin_user(const u08bits *usname, const u08bits *realm, con
return ret; return ret;
} }
static int redis_del_admin_user(const u08bits *usname) { static int redis_del_admin_user(const uint8_t *usname) {
int ret = -1; int ret = -1;
donot_print_connection_success = 1; donot_print_connection_success = 1;
redisContext *rc = get_redis_connection(); redisContext *rc = get_redis_connection();
@ -1328,9 +1328,9 @@ static int redis_list_admin_users(int no_print)
for(isz=0;isz<keys.sz;++isz) { for(isz=0;isz<keys.sz;++isz) {
char *s = keys.secrets[isz]; char *s = keys.secrets[isz];
s += strlen("turn/admin_user/"); s += strlen("turn/admin_user/");
u08bits realm[STUN_MAX_REALM_SIZE]; uint8_t realm[STUN_MAX_REALM_SIZE];
password_t pwd; password_t pwd;
if(redis_get_admin_user((const u08bits*)s,realm,pwd) == 0) { if(redis_get_admin_user((const uint8_t*)s,realm,pwd) == 0) {
++ret; ++ret;
if(!no_print) { if(!no_print) {
if(realm[0]) { if(realm[0]) {

View File

@ -207,7 +207,7 @@ static sqlite3 * get_sqlite_connection(void) {
/////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
static int sqlite_get_auth_secrets(secrets_list_t *sl, u08bits *realm) static int sqlite_get_auth_secrets(secrets_list_t *sl, uint8_t *realm)
{ {
int ret = -1; int ret = -1;
sqlite3 *sqliteconnection = get_sqlite_connection(); sqlite3 *sqliteconnection = get_sqlite_connection();
@ -253,7 +253,7 @@ static int sqlite_get_auth_secrets(secrets_list_t *sl, u08bits *realm)
return ret; return ret;
} }
static int sqlite_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) static int sqlite_get_user_key(uint8_t *usname, uint8_t *realm, hmackey_t key)
{ {
int ret = -1; int ret = -1;
sqlite3 *sqliteconnection = get_sqlite_connection(); sqlite3 *sqliteconnection = get_sqlite_connection();
@ -290,7 +290,7 @@ static int sqlite_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key)
return ret; return ret;
} }
static int sqlite_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) { static int sqlite_get_oauth_key(const uint8_t *kid, oauth_key_data_raw *key) {
int ret = -1; int ret = -1;
@ -312,8 +312,8 @@ static int sqlite_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
if (res == SQLITE_ROW) { if (res == SQLITE_ROW) {
STRCPY(key->ikm_key,sqlite3_column_text(st, 0)); STRCPY(key->ikm_key,sqlite3_column_text(st, 0));
key->timestamp = (u64bits)strtoll((const char*)sqlite3_column_text(st, 1),NULL,10); key->timestamp = (uint64_t)strtoll((const char*)sqlite3_column_text(st, 1),NULL,10);
key->lifetime = (u32bits)strtol((const char*)sqlite3_column_text(st, 2),NULL,10); key->lifetime = (uint32_t)strtol((const char*)sqlite3_column_text(st, 2),NULL,10);
STRCPY(key->as_rs_alg,sqlite3_column_text(st, 3)); STRCPY(key->as_rs_alg,sqlite3_column_text(st, 3));
STRCPY(key->realm,sqlite3_column_text(st, 4)); STRCPY(key->realm,sqlite3_column_text(st, 4));
STRCPY(key->kid,kid); STRCPY(key->kid,kid);
@ -359,8 +359,8 @@ static int sqlite_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secr
if (res == SQLITE_ROW) { if (res == SQLITE_ROW) {
STRCPY(key->ikm_key,sqlite3_column_text(st, 0)); STRCPY(key->ikm_key,sqlite3_column_text(st, 0));
key->timestamp = (u64bits)strtoll((const char*)sqlite3_column_text(st, 1),NULL,10); key->timestamp = (uint64_t)strtoll((const char*)sqlite3_column_text(st, 1),NULL,10);
key->lifetime = (u32bits)strtol((const char*)sqlite3_column_text(st, 2),NULL,10); key->lifetime = (uint32_t)strtol((const char*)sqlite3_column_text(st, 2),NULL,10);
STRCPY(key->as_rs_alg,sqlite3_column_text(st, 3)); STRCPY(key->as_rs_alg,sqlite3_column_text(st, 3));
STRCPY(key->realm,sqlite3_column_text(st, 4)); STRCPY(key->realm,sqlite3_column_text(st, 4));
STRCPY(key->kid,sqlite3_column_text(st, 5)); STRCPY(key->kid,sqlite3_column_text(st, 5));
@ -407,7 +407,7 @@ static int sqlite_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secr
return ret; return ret;
} }
static int sqlite_set_user_key(u08bits *usname, u08bits *realm, const char *key) static int sqlite_set_user_key(uint8_t *usname, uint8_t *realm, const char *key)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -471,7 +471,7 @@ static int sqlite_set_oauth_key(oauth_key_data_raw *key)
return ret; return ret;
} }
static int sqlite_del_user(u08bits *usname, u08bits *realm) static int sqlite_del_user(uint8_t *usname, uint8_t *realm)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -500,7 +500,7 @@ static int sqlite_del_user(u08bits *usname, u08bits *realm)
return ret; return ret;
} }
static int sqlite_del_oauth_key(const u08bits *kid) static int sqlite_del_oauth_key(const uint8_t *kid)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -531,14 +531,14 @@ static int sqlite_del_oauth_key(const u08bits *kid)
} }
static int sqlite_list_users(u08bits *realm, secrets_list_t *users, secrets_list_t *realms) static int sqlite_list_users(uint8_t *realm, secrets_list_t *users, secrets_list_t *realms)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
sqlite3_stmt *st = NULL; sqlite3_stmt *st = NULL;
int rc = 0; int rc = 0;
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
donot_print_connection_success=1; donot_print_connection_success=1;
@ -596,12 +596,12 @@ static int sqlite_list_users(u08bits *realm, secrets_list_t *users, secrets_list
return ret; return ret;
} }
static int sqlite_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_list_t *realms) static int sqlite_list_secrets(uint8_t *realm, secrets_list_t *secrets, secrets_list_t *realms)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
sqlite3_stmt *st = NULL; sqlite3_stmt *st = NULL;
@ -660,7 +660,7 @@ static int sqlite_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_
return ret; return ret;
} }
static int sqlite_del_secret(u08bits *secret, u08bits *realm) static int sqlite_del_secret(uint8_t *secret, uint8_t *realm)
{ {
int ret = -1; int ret = -1;
donot_print_connection_success=1; donot_print_connection_success=1;
@ -691,7 +691,7 @@ static int sqlite_del_secret(u08bits *secret, u08bits *realm)
return ret; return ret;
} }
static int sqlite_set_secret(u08bits *secret, u08bits *realm) static int sqlite_set_secret(uint8_t *secret, uint8_t *realm)
{ {
int ret = -1; int ret = -1;
donot_print_connection_success = 1; donot_print_connection_success = 1;
@ -720,7 +720,7 @@ static int sqlite_set_secret(u08bits *secret, u08bits *realm)
return ret; return ret;
} }
static int sqlite_add_origin(u08bits *origin, u08bits *realm) static int sqlite_add_origin(uint8_t *origin, uint8_t *realm)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -748,7 +748,7 @@ static int sqlite_add_origin(u08bits *origin, u08bits *realm)
return ret; return ret;
} }
static int sqlite_del_origin(u08bits *origin) static int sqlite_del_origin(uint8_t *origin)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -776,11 +776,11 @@ static int sqlite_del_origin(u08bits *origin)
return ret; return ret;
} }
static int sqlite_list_origins(u08bits *realm, secrets_list_t *origins, secrets_list_t *realms) static int sqlite_list_origins(uint8_t *realm, secrets_list_t *origins, secrets_list_t *realms)
{ {
int ret = -1; int ret = -1;
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
donot_print_connection_success = 1; donot_print_connection_success = 1;
@ -841,7 +841,7 @@ static int sqlite_list_origins(u08bits *realm, secrets_list_t *origins, secrets_
return ret; return ret;
} }
static int sqlite_set_realm_option_one(u08bits *realm, unsigned long value, const char* opt) static int sqlite_set_realm_option_one(uint8_t *realm, unsigned long value, const char* opt)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -871,7 +871,7 @@ static int sqlite_set_realm_option_one(u08bits *realm, unsigned long value, cons
return ret; return ret;
} }
static int sqlite_list_realm_options(u08bits *realm) static int sqlite_list_realm_options(uint8_t *realm)
{ {
int ret = -1; int ret = -1;
donot_print_connection_success = 1; donot_print_connection_success = 1;
@ -974,11 +974,11 @@ static int sqlite_get_ip_list(const char *kind, ip_range_list_t * list)
return ret; return ret;
} }
static int sqlite_set_permission_ip(const char *kind, u08bits *realm, const char* ip, int del) static int sqlite_set_permission_ip(const char *kind, uint8_t *realm, const char* ip, int del)
{ {
int ret = -1; int ret = -1;
u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
if(!realm) realm=realm0; if(!realm) realm=realm0;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -1139,7 +1139,7 @@ static void sqlite_reread_realms(secrets_list_t * realms_list)
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
static int sqlite_get_admin_user(const u08bits *usname, u08bits *realm, password_t pwd) static int sqlite_get_admin_user(const uint8_t *usname, uint8_t *realm, password_t pwd)
{ {
int ret = -1; int ret = -1;
@ -1180,7 +1180,7 @@ static int sqlite_get_admin_user(const u08bits *usname, u08bits *realm, password
return ret; return ret;
} }
static int sqlite_set_admin_user(const u08bits *usname, const u08bits *realm, const password_t pwd) static int sqlite_set_admin_user(const uint8_t *usname, const uint8_t *realm, const password_t pwd)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];
@ -1210,7 +1210,7 @@ static int sqlite_set_admin_user(const u08bits *usname, const u08bits *realm, co
return ret; return ret;
} }
static int sqlite_del_admin_user(const u08bits *usname) static int sqlite_del_admin_user(const uint8_t *usname)
{ {
int ret = -1; int ret = -1;
char statement[TURN_LONG_STRING_SIZE]; char statement[TURN_LONG_STRING_SIZE];

View File

@ -48,30 +48,30 @@ extern pthread_key_t connection_key;
extern pthread_once_t connection_key_once; extern pthread_once_t connection_key_once;
typedef struct _turn_dbdriver_t { typedef struct _turn_dbdriver_t {
int (*get_auth_secrets)(secrets_list_t *sl, u08bits *realm); int (*get_auth_secrets)(secrets_list_t *sl, uint8_t *realm);
int (*get_user_key)(u08bits *usname, u08bits *realm, hmackey_t key); int (*get_user_key)(uint8_t *usname, uint8_t *realm, hmackey_t key);
int (*set_user_key)(u08bits *usname, u08bits *realm, const char *key); int (*set_user_key)(uint8_t *usname, uint8_t *realm, const char *key);
int (*del_user)(u08bits *usname, u08bits *realm); int (*del_user)(uint8_t *usname, uint8_t *realm);
int (*list_users)(u08bits *realm, secrets_list_t *users, secrets_list_t *realms); int (*list_users)(uint8_t *realm, secrets_list_t *users, secrets_list_t *realms);
int (*list_secrets)(u08bits *realm, secrets_list_t *secrets, secrets_list_t *realms); int (*list_secrets)(uint8_t *realm, secrets_list_t *secrets, secrets_list_t *realms);
int (*del_secret)(u08bits *secret, u08bits *realm); int (*del_secret)(uint8_t *secret, uint8_t *realm);
int (*set_secret)(u08bits *secret, u08bits *realm); int (*set_secret)(uint8_t *secret, uint8_t *realm);
int (*add_origin)(u08bits *origin, u08bits *realm); int (*add_origin)(uint8_t *origin, uint8_t *realm);
int (*del_origin)(u08bits *origin); int (*del_origin)(uint8_t *origin);
int (*list_origins)(u08bits *realm, secrets_list_t *origins, secrets_list_t *realms); int (*list_origins)(uint8_t *realm, secrets_list_t *origins, secrets_list_t *realms);
int (*set_realm_option_one)(u08bits *realm, unsigned long value, const char* opt); int (*set_realm_option_one)(uint8_t *realm, unsigned long value, const char* opt);
int (*list_realm_options)(u08bits *realm); int (*list_realm_options)(uint8_t *realm);
void (*auth_ping)(void * rch); void (*auth_ping)(void * rch);
int (*get_ip_list)(const char *kind, ip_range_list_t * list); int (*get_ip_list)(const char *kind, ip_range_list_t * list);
int (*set_permission_ip)(const char *kind, u08bits *realm, const char* ip, int del); int (*set_permission_ip)(const char *kind, uint8_t *realm, const char* ip, int del);
void (*reread_realms)(secrets_list_t * realms_list); void (*reread_realms)(secrets_list_t * realms_list);
int (*set_oauth_key)(oauth_key_data_raw *key); int (*set_oauth_key)(oauth_key_data_raw *key);
int (*get_oauth_key)(const u08bits *kid, oauth_key_data_raw *key); int (*get_oauth_key)(const uint8_t *kid, oauth_key_data_raw *key);
int (*del_oauth_key)(const u08bits *kid); int (*del_oauth_key)(const uint8_t *kid);
int (*list_oauth_keys)(secrets_list_t *kids,secrets_list_t *teas,secrets_list_t *tss,secrets_list_t *lts,secrets_list_t *realms); int (*list_oauth_keys)(secrets_list_t *kids,secrets_list_t *teas,secrets_list_t *tss,secrets_list_t *lts,secrets_list_t *realms);
int (*get_admin_user)(const u08bits *usname, u08bits *realm, password_t pwd); int (*get_admin_user)(const uint8_t *usname, uint8_t *realm, password_t pwd);
int (*set_admin_user)(const u08bits *usname, const u08bits *realm, const password_t pwd); int (*set_admin_user)(const uint8_t *usname, const uint8_t *realm, const password_t pwd);
int (*del_admin_user)(const u08bits *usname); int (*del_admin_user)(const uint8_t *usname);
int (*list_admin_users)(int no_print); int (*list_admin_users)(int no_print);
} turn_dbdriver_t; } turn_dbdriver_t;

View File

@ -396,8 +396,8 @@ static int handle_udp_packet(dtls_listener_relay_server_type *server,
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
"%s: socket to be closed\n", __FUNCTION__); "%s: socket to be closed\n", __FUNCTION__);
{ {
u08bits saddr[129]; uint8_t saddr[129];
u08bits rsaddr[129]; uint8_t rsaddr[129];
long thrid = (long) pthread_self(); long thrid = (long) pthread_self();
addr_to_string(get_local_addr_from_ioa_socket(chs),saddr); addr_to_string(get_local_addr_from_ioa_socket(chs),saddr);
addr_to_string(get_remote_addr_from_ioa_socket(chs),rsaddr); addr_to_string(get_remote_addr_from_ioa_socket(chs),rsaddr);
@ -419,8 +419,8 @@ static int handle_udp_packet(dtls_listener_relay_server_type *server,
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
"%s: wrong socket container\n", __FUNCTION__); "%s: wrong socket container\n", __FUNCTION__);
{ {
u08bits saddr[129]; uint8_t saddr[129];
u08bits rsaddr[129]; uint8_t rsaddr[129];
long thrid = (long) pthread_self(); long thrid = (long) pthread_self();
addr_to_string(get_local_addr_from_ioa_socket(chs),saddr); addr_to_string(get_local_addr_from_ioa_socket(chs),saddr);
addr_to_string(get_remote_addr_from_ioa_socket(chs),rsaddr); addr_to_string(get_remote_addr_from_ioa_socket(chs),rsaddr);
@ -457,8 +457,8 @@ static int handle_udp_packet(dtls_listener_relay_server_type *server,
if (s) { if (s) {
if(verbose) { if(verbose) {
u08bits saddr[129]; uint8_t saddr[129];
u08bits rsaddr[129]; uint8_t rsaddr[129];
addr_to_string(get_local_addr_from_ioa_socket(s),saddr); addr_to_string(get_local_addr_from_ioa_socket(s),saddr);
addr_to_string(get_remote_addr_from_ioa_socket(s),rsaddr); addr_to_string(get_remote_addr_from_ioa_socket(s),rsaddr);
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,
@ -528,8 +528,8 @@ static int create_new_connected_udp_socket(
if (addr_connect(udp_fd, &(server->sm.m.sm.nd.src_addr), &connect_err) < 0) { if (addr_connect(udp_fd, &(server->sm.m.sm.nd.src_addr), &connect_err) < 0) {
char sl[129]; char sl[129];
char sr[129]; char sr[129];
addr_to_string(&(ret->local_addr),(u08bits*)sl); addr_to_string(&(ret->local_addr),(uint8_t*)sl);
addr_to_string(&(server->sm.m.sm.nd.src_addr),(u08bits*)sr); addr_to_string(&(server->sm.m.sm.nd.src_addr),(uint8_t*)sr);
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
"Cannot connect new detached udp client socket from local addr %s to remote addr %s\n",sl,sr); "Cannot connect new detached udp client socket from local addr %s to remote addr %s\n",sl,sr);
IOA_CLOSE_SOCKET(ret); IOA_CLOSE_SOCKET(ret);
@ -651,7 +651,7 @@ static void udp_server_input_handler(evutil_socket_t fd, short what, void* arg)
int flags = MSG_DONTWAIT; int flags = MSG_DONTWAIT;
bsize = udp_recvfrom(fd, &(server->sm.m.sm.nd.src_addr), &(server->addr), bsize = udp_recvfrom(fd, &(server->sm.m.sm.nd.src_addr), &(server->addr),
(s08bits*)ioa_network_buffer_data(elem), (int)ioa_network_buffer_get_capacity_udp(), (char*)ioa_network_buffer_data(elem), (int)ioa_network_buffer_get_capacity_udp(),
&(server->sm.m.sm.nd.recv_ttl), &(server->sm.m.sm.nd.recv_tos), &(server->sm.m.sm.nd.recv_ttl), &(server->sm.m.sm.nd.recv_tos),
server->e->cmsg, flags, NULL); server->e->cmsg, flags, NULL);
@ -671,8 +671,8 @@ static void udp_server_input_handler(evutil_socket_t fd, short what, void* arg)
//Linux //Linux
int eflags = MSG_ERRQUEUE | MSG_DONTWAIT; int eflags = MSG_ERRQUEUE | MSG_DONTWAIT;
static s08bits buffer[65535]; static char buffer[65535];
u32bits errcode = 0; uint32_t errcode = 0;
ioa_addr orig_addr; ioa_addr orig_addr;
int ttl = 0; int ttl = 0;
int tos = 0; int tos = 0;
@ -782,7 +782,7 @@ static int create_server_socket(dtls_listener_relay_server_type* server, int rep
if(addr_bind(udp_listen_fd,&server->addr,1,1,UDP_SOCKET)<0) { if(addr_bind(udp_listen_fd,&server->addr,1,1,UDP_SOCKET)<0) {
perror("Cannot bind local socket to addr"); perror("Cannot bind local socket to addr");
char saddr[129]; char saddr[129];
addr_to_string(&server->addr,(u08bits*)saddr); addr_to_string(&server->addr,(uint8_t*)saddr);
TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING,"Cannot bind DTLS/UDP listener socket to addr %s\n",saddr); TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING,"Cannot bind DTLS/UDP listener socket to addr %s\n",saddr);
if(addr_bind_cycle++<max_binding_time) { if(addr_bind_cycle++<max_binding_time) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"Trying to bind DTLS/UDP listener socket to addr %s, again...\n",saddr); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"Trying to bind DTLS/UDP listener socket to addr %s, again...\n",saddr);
@ -860,7 +860,7 @@ static int reopen_server_socket(dtls_listener_relay_server_type* server, evutil_
if(addr_bind(udp_listen_fd,&server->addr,1,1,UDP_SOCKET)<0) { if(addr_bind(udp_listen_fd,&server->addr,1,1,UDP_SOCKET)<0) {
perror("Cannot bind local socket to addr"); perror("Cannot bind local socket to addr");
char saddr[129]; char saddr[129];
addr_to_string(&server->addr,(u08bits*)saddr); addr_to_string(&server->addr,(uint8_t*)saddr);
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"Cannot bind listener socket to addr %s\n",saddr); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"Cannot bind listener socket to addr %s\n",saddr);
return -1; return -1;
} }
@ -925,7 +925,7 @@ static int init_server(dtls_listener_relay_server_type* server,
if(ifname) STRCPY(server->ifname,ifname); if(ifname) STRCPY(server->ifname,ifname);
if(make_ioa_addr((const u08bits*)local_address, port, &server->addr)<0) { if(make_ioa_addr((const uint8_t*)local_address, port, &server->addr)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot create a DTLS/UDP listener for address: %s\n",local_address); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot create a DTLS/UDP listener for address: %s\n",local_address);
return -1; return -1;
} }
@ -1014,7 +1014,7 @@ ioa_engine_handle get_engine(dtls_listener_relay_server_type* server)
void udp_send_message(dtls_listener_relay_server_type *server, ioa_network_buffer_handle nbh, ioa_addr *dest) void udp_send_message(dtls_listener_relay_server_type *server, ioa_network_buffer_handle nbh, ioa_addr *dest)
{ {
if(server && dest && nbh && (server->udp_listen_s)) if(server && dest && nbh && (server->udp_listen_s))
udp_send(server->udp_listen_s, dest, (s08bits*)ioa_network_buffer_data(nbh), (int)ioa_network_buffer_get_size(nbh)); udp_send(server->udp_listen_s, dest, (char*)ioa_network_buffer_data(nbh), (int)ioa_network_buffer_get_size(nbh));
} }
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////

View File

@ -59,7 +59,7 @@ static void write_http_echo(ioa_socket_handle s)
if((sat == HTTP_CLIENT_SOCKET) || (sat == HTTPS_CLIENT_SOCKET)) { if((sat == HTTP_CLIENT_SOCKET) || (sat == HTTPS_CLIENT_SOCKET)) {
ioa_network_buffer_handle nbh_http = ioa_network_buffer_allocate(s->e); ioa_network_buffer_handle nbh_http = ioa_network_buffer_allocate(s->e);
size_t len_http = ioa_network_buffer_get_size(nbh_http); size_t len_http = ioa_network_buffer_get_size(nbh_http);
u08bits *data = ioa_network_buffer_data(nbh_http); uint8_t *data = ioa_network_buffer_data(nbh_http);
char data_http[1025]; char data_http[1025];
char content_http[1025]; char content_http[1025];
const char* title = "TURN Server"; const char* title = "TURN Server";

View File

@ -359,7 +359,7 @@ int get_a_local_relay(int family, ioa_addr *relay_addr)
} else } else
continue; continue;
if (make_ioa_addr((const u08bits*) saddr, 0, relay_addr) < 0) { if (make_ioa_addr((const uint8_t*) saddr, 0, relay_addr) < 0) {
continue; continue;
} else { } else {
ret = 0; ret = 0;
@ -1181,7 +1181,7 @@ static void set_option(int c, char *value)
use_cli = !get_bool_value(value); use_cli = !get_bool_value(value);
break; break;
case CLI_IP_OPT: case CLI_IP_OPT:
if(make_ioa_addr((const u08bits*)value,0,&cli_addr)<0) { if(make_ioa_addr((const uint8_t*)value,0,&cli_addr)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot set cli address: %s\n",value); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot set cli address: %s\n",value);
} else{ } else{
cli_addr_set = 1; cli_addr_set = 1;
@ -1197,7 +1197,7 @@ static void set_option(int c, char *value)
use_web_admin = get_bool_value(value); use_web_admin = get_bool_value(value);
break; break;
case WEB_ADMIN_IP_OPT: case WEB_ADMIN_IP_OPT:
if(make_ioa_addr((const u08bits*)value, 0, &web_admin_addr) < 0) { if(make_ioa_addr((const uint8_t*)value, 0, &web_admin_addr) < 0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot set web-admin address: %s\n", value); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot set web-admin address: %s\n", value);
} else { } else {
web_admin_addr_set = 1; web_admin_addr_set = 1;
@ -1317,10 +1317,10 @@ static void set_option(int c, char *value)
div[0]=0; div[0]=0;
++div; ++div;
ioa_addr apub,apriv; ioa_addr apub,apriv;
if(make_ioa_addr((const u08bits*)nval,0,&apub)<0) { if(make_ioa_addr((const uint8_t*)nval,0,&apub)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"-X : Wrong address format: %s\n",nval); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"-X : Wrong address format: %s\n",nval);
} else { } else {
if(make_ioa_addr((const u08bits*)div,0,&apriv)<0) { if(make_ioa_addr((const uint8_t*)div,0,&apriv)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"-X : Wrong address format: %s\n",div); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"-X : Wrong address format: %s\n",div);
} else { } else {
ioa_addr_add_mapping(&apub,&apriv); ioa_addr_add_mapping(&apub,&apriv);
@ -1332,7 +1332,7 @@ static void set_option(int c, char *value)
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "You cannot define external IP more than once in the configuration\n"); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "You cannot define external IP more than once in the configuration\n");
} else { } else {
turn_params.external_ip = (ioa_addr*)allocate_super_memory_engine(turn_params.listener.ioa_eng, sizeof(ioa_addr)); turn_params.external_ip = (ioa_addr*)allocate_super_memory_engine(turn_params.listener.ioa_eng, sizeof(ioa_addr));
if(make_ioa_addr((const u08bits*)value,0,turn_params.external_ip)<0) { if(make_ioa_addr((const uint8_t*)value,0,turn_params.external_ip)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"-X : Wrong address format: %s\n",value); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"-X : Wrong address format: %s\n",value);
free(turn_params.external_ip); free(turn_params.external_ip);
turn_params.external_ip = NULL; turn_params.external_ip = NULL;
@ -1698,11 +1698,11 @@ static int adminmain(int argc, char **argv)
FILE* fptr; FILE* fptr;
unsigned char generated_key[16]; //changed unsigned char generated_key[16]; //changed
u08bits user[STUN_MAX_USERNAME_SIZE+1]="\0"; uint8_t user[STUN_MAX_USERNAME_SIZE+1]="\0";
u08bits realm[STUN_MAX_REALM_SIZE+1]="\0"; uint8_t realm[STUN_MAX_REALM_SIZE+1]="\0";
u08bits pwd[STUN_MAX_PWD_SIZE+1]="\0"; uint8_t pwd[STUN_MAX_PWD_SIZE+1]="\0";
u08bits secret[AUTH_SECRET_SIZE+1]="\0"; uint8_t secret[AUTH_SECRET_SIZE+1]="\0";
u08bits origin[STUN_MAX_ORIGIN_SIZE+1]="\0"; uint8_t origin[STUN_MAX_ORIGIN_SIZE+1]="\0";
perf_options_t po = {(band_limit_t)-1,-1,-1}; perf_options_t po = {(band_limit_t)-1,-1,-1};
struct uoptions uo; struct uoptions uo;
@ -1823,11 +1823,11 @@ static int adminmain(int argc, char **argv)
#endif #endif
case 'u': case 'u':
STRCPY(user,optarg); STRCPY(user,optarg);
if(!is_secure_string((u08bits*)user,1)) { if(!is_secure_string((uint8_t*)user,1)) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong user name structure or symbols, choose another name: %s\n",user); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong user name structure or symbols, choose another name: %s\n",user);
exit(-1); exit(-1);
} }
if(SASLprep((u08bits*)user)<0) { if(SASLprep((uint8_t*)user)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong user name: %s\n",user); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong user name: %s\n",user);
exit(-1); exit(-1);
} }
@ -1835,14 +1835,14 @@ static int adminmain(int argc, char **argv)
case 'r': case 'r':
set_default_realm_name(optarg); set_default_realm_name(optarg);
STRCPY(realm,optarg); STRCPY(realm,optarg);
if(SASLprep((u08bits*)realm)<0) { if(SASLprep((uint8_t*)realm)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong realm: %s\n",realm); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong realm: %s\n",realm);
exit(-1); exit(-1);
} }
break; break;
case 'p': case 'p':
STRCPY(pwd,optarg); STRCPY(pwd,optarg);
if(SASLprep((u08bits*)pwd)<0) { if(SASLprep((uint8_t*)pwd)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong password: %s\n",pwd); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong password: %s\n",pwd);
exit(-1); exit(-1);
} }
@ -2336,7 +2336,7 @@ int main(int argc, char **argv)
const char* sra = (const char*)turn_params.relay_addrs[ir]; const char* sra = (const char*)turn_params.relay_addrs[ir];
if((strstr(sra,"127.0.0.1") != sra)&&(strstr(sra,"::1")!=sra)) { if((strstr(sra,"127.0.0.1") != sra)&&(strstr(sra,"::1")!=sra)) {
ioa_addr ra; ioa_addr ra;
if(make_ioa_addr((const u08bits*)sra,0,&ra)<0) { if(make_ioa_addr((const uint8_t*)sra,0,&ra)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"-X : Wrong address format: %s\n",sra); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"-X : Wrong address format: %s\n",sra);
} else if(ra.ss.sa_family == turn_params.external_ip->ss.sa_family) { } else if(ra.ss.sa_family == turn_params.external_ip->ss.sa_family) {
ioa_addr_add_mapping(turn_params.external_ip,&ra); ioa_addr_add_mapping(turn_params.external_ip,&ra);

View File

@ -98,7 +98,7 @@ extern "C" {
#define DEFAULT_EC_CURVE_NAME "prime256v1" #define DEFAULT_EC_CURVE_NAME "prime256v1"
#define MAX_NUMBER_OF_GENERAL_RELAY_SERVERS ((u08bits)(0x80)) #define MAX_NUMBER_OF_GENERAL_RELAY_SERVERS ((uint8_t)(0x80))
#define TURNSERVER_ID_BOUNDARY_BETWEEN_TCP_AND_UDP MAX_NUMBER_OF_GENERAL_RELAY_SERVERS #define TURNSERVER_ID_BOUNDARY_BETWEEN_TCP_AND_UDP MAX_NUMBER_OF_GENERAL_RELAY_SERVERS
#define TURNSERVER_ID_BOUNDARY_BETWEEN_UDP_AND_TCP TURNSERVER_ID_BOUNDARY_BETWEEN_TCP_AND_UDP #define TURNSERVER_ID_BOUNDARY_BETWEEN_UDP_AND_TCP TURNSERVER_ID_BOUNDARY_BETWEEN_TCP_AND_UDP
@ -249,8 +249,8 @@ typedef struct _turn_params_ {
//////////////// Relay servers ///////////// //////////////// Relay servers /////////////
u16bits min_port; uint16_t min_port;
u16bits max_port; uint16_t max_port;
vint check_origin; vint check_origin;

View File

@ -182,13 +182,13 @@ static void add_aux_server_list(const char *saddr, turn_server_addrs_list_t *lis
{ {
if(saddr && list) { if(saddr && list) {
ioa_addr addr; ioa_addr addr;
if(make_ioa_addr_from_full_string((const u08bits*)saddr, 0, &addr)!=0) { if(make_ioa_addr_from_full_string((const uint8_t*)saddr, 0, &addr)!=0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong full address format: %s\n",saddr); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong full address format: %s\n",saddr);
} else { } else {
list->addrs = (ioa_addr*)realloc(list->addrs,sizeof(ioa_addr)*(list->size+1)); list->addrs = (ioa_addr*)realloc(list->addrs,sizeof(ioa_addr)*(list->size+1));
addr_cpy(&(list->addrs[(list->size)++]),&addr); addr_cpy(&(list->addrs[(list->size)++]),&addr);
{ {
u08bits s[1025]; uint8_t s[1025];
addr_to_string(&addr, s); addr_to_string(&addr, s);
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Aux server: %s\n",s); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Aux server: %s\n",s);
} }
@ -210,13 +210,13 @@ static void add_alt_server(const char *saddr, int default_port, turn_server_addr
turn_mutex_lock(&(list->m)); turn_mutex_lock(&(list->m));
if(make_ioa_addr_from_full_string((const u08bits*)saddr, default_port, &addr)!=0) { if(make_ioa_addr_from_full_string((const uint8_t*)saddr, default_port, &addr)!=0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong IP address format: %s\n",saddr); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong IP address format: %s\n",saddr);
} else { } else {
list->addrs = (ioa_addr*)realloc(list->addrs,sizeof(ioa_addr)*(list->size+1)); list->addrs = (ioa_addr*)realloc(list->addrs,sizeof(ioa_addr)*(list->size+1));
addr_cpy(&(list->addrs[(list->size)++]),&addr); addr_cpy(&(list->addrs[(list->size)++]),&addr);
{ {
u08bits s[1025]; uint8_t s[1025];
addr_to_string(&addr, s); addr_to_string(&addr, s);
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Alternate server added: %s\n",s); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Alternate server added: %s\n",s);
} }
@ -234,7 +234,7 @@ static void del_alt_server(const char *saddr, int default_port, turn_server_addr
turn_mutex_lock(&(list->m)); turn_mutex_lock(&(list->m));
if(make_ioa_addr_from_full_string((const u08bits*)saddr, default_port, &addr)!=0) { if(make_ioa_addr_from_full_string((const uint8_t*)saddr, default_port, &addr)!=0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong IP address format: %s\n",saddr); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong IP address format: %s\n",saddr);
} else { } else {
@ -263,7 +263,7 @@ static void del_alt_server(const char *saddr, int default_port, turn_server_addr
list->size -= 1; list->size -= 1;
{ {
u08bits s[1025]; uint8_t s[1025];
addr_to_string(&addr, s); addr_to_string(&addr, s);
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Alternate server removed: %s\n",s); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Alternate server removed: %s\n",s);
} }
@ -357,12 +357,12 @@ void set_ssl_ctx(ioa_engine_handle e, turn_params_t *params)
void add_listener_addr(const char* addr) { void add_listener_addr(const char* addr) {
ioa_addr baddr; ioa_addr baddr;
if(make_ioa_addr((const u08bits*)addr,0,&baddr)<0) { if(make_ioa_addr((const uint8_t*)addr,0,&baddr)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot add a listener address: %s\n",addr); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot add a listener address: %s\n",addr);
} else { } else {
char sbaddr[129]; char sbaddr[129];
addr_to_string_no_port(&baddr,(u08bits*)sbaddr); addr_to_string_no_port(&baddr,(uint8_t*)sbaddr);
size_t i = 0; size_t i = 0;
for(i=0;i<turn_params.listener.addrs_number;++i) { for(i=0;i<turn_params.listener.addrs_number;++i) {
@ -383,13 +383,13 @@ void add_listener_addr(const char* addr) {
int add_relay_addr(const char* addr) { int add_relay_addr(const char* addr) {
ioa_addr baddr; ioa_addr baddr;
if(make_ioa_addr((const u08bits*)addr,0,&baddr)<0) { if(make_ioa_addr((const uint8_t*)addr,0,&baddr)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot add a relay address: %s\n",addr); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot add a relay address: %s\n",addr);
return -1; return -1;
} else { } else {
char sbaddr[129]; char sbaddr[129];
addr_to_string_no_port(&baddr,(u08bits*)sbaddr); addr_to_string_no_port(&baddr,(uint8_t*)sbaddr);
size_t i = 0; size_t i = 0;
for(i=0;i<turn_params.relays_number;++i) { for(i=0;i<turn_params.relays_number;++i) {
@ -412,7 +412,7 @@ static void allocate_relay_addrs_ports(void) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Wait for relay ports initialization...\n"); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Wait for relay ports initialization...\n");
for(i=0;i<(int)turn_params.relays_number;i++) { for(i=0;i<(int)turn_params.relays_number;i++) {
ioa_addr baddr; ioa_addr baddr;
if(make_ioa_addr((const u08bits*)turn_params.relay_addrs[i],0,&baddr)>=0) { if(make_ioa_addr((const uint8_t*)turn_params.relay_addrs[i],0,&baddr)>=0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, " relay %s initialization...\n",turn_params.relay_addrs[i]); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, " relay %s initialization...\n",turn_params.relay_addrs[i]);
turnipports_add_ip(STUN_ATTRIBUTE_TRANSPORT_UDP_VALUE, &baddr); turnipports_add_ip(STUN_ATTRIBUTE_TRANSPORT_UDP_VALUE, &baddr);
turnipports_add_ip(STUN_ATTRIBUTE_TRANSPORT_TCP_VALUE, &baddr); turnipports_add_ip(STUN_ATTRIBUTE_TRANSPORT_TCP_VALUE, &baddr);
@ -560,7 +560,7 @@ static int send_socket_to_general_relay(ioa_engine_handle e, struct message_to_r
return 0; return 0;
} }
static int send_socket_to_relay(turnserver_id id, u64bits cid, stun_tid *tid, ioa_socket_handle s, static int send_socket_to_relay(turnserver_id id, uint64_t cid, stun_tid *tid, ioa_socket_handle s,
int message_integrity, MESSAGE_TO_RELAY_TYPE rmt, ioa_net_data *nd, int message_integrity, MESSAGE_TO_RELAY_TYPE rmt, ioa_net_data *nd,
int can_resume) int can_resume)
{ {
@ -996,7 +996,7 @@ static void listener_receive_message(struct bufferevent *bev, void *ptr)
} }
if(!found) { if(!found) {
u08bits saddr[129]; uint8_t saddr[129];
addr_to_string(&mm.m.tc.origin, saddr); addr_to_string(&mm.m.tc.origin, saddr);
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"%s: Cannot find local source %s\n",__FUNCTION__,saddr); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"%s: Cannot find local source %s\n",__FUNCTION__,saddr);
} }
@ -1205,7 +1205,7 @@ static void setup_socket_per_endpoint_udp_listener_servers(void)
char saddr[129]; char saddr[129];
addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]); addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]);
int port = (int)addr_get_port(&addr); int port = (int)addr_get_port(&addr);
addr_to_string_no_port(&addr,(u08bits*)saddr); addr_to_string_no_port(&addr,(uint8_t*)saddr);
turn_params.listener.aux_udp_services[index] = (dtls_listener_relay_server_type**)allocate_super_memory_engine(udp_relay_servers[udp_relay_server_index]->ioa_eng, sizeof(dtls_listener_relay_server_type*)); turn_params.listener.aux_udp_services[index] = (dtls_listener_relay_server_type**)allocate_super_memory_engine(udp_relay_servers[udp_relay_server_index]->ioa_eng, sizeof(dtls_listener_relay_server_type*));
turn_params.listener.aux_udp_services[index][0] = create_dtls_listener_server(turn_params.listener_ifname, saddr, port, turn_params.verbose, udp_relay_servers[udp_relay_server_index]->ioa_eng, &(udp_relay_servers[udp_relay_server_index]->server), 1, NULL); turn_params.listener.aux_udp_services[index][0] = create_dtls_listener_server(turn_params.listener_ifname, saddr, port, turn_params.verbose, udp_relay_servers[udp_relay_server_index]->ioa_eng, &(udp_relay_servers[udp_relay_server_index]->server), 1, NULL);
@ -1324,7 +1324,7 @@ static void setup_socket_per_thread_udp_listener_servers(void)
char saddr[129]; char saddr[129];
addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]); addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]);
int port = (int)addr_get_port(&addr); int port = (int)addr_get_port(&addr);
addr_to_string_no_port(&addr,(u08bits*)saddr); addr_to_string_no_port(&addr,(uint8_t*)saddr);
turn_params.listener.aux_udp_services[index] = (dtls_listener_relay_server_type**)allocate_super_memory_engine(turn_params.listener.ioa_eng, sizeof(dtls_listener_relay_server_type*) * get_real_general_relay_servers_number()); turn_params.listener.aux_udp_services[index] = (dtls_listener_relay_server_type**)allocate_super_memory_engine(turn_params.listener.ioa_eng, sizeof(dtls_listener_relay_server_type*) * get_real_general_relay_servers_number());
@ -1405,7 +1405,7 @@ static void setup_socket_per_session_udp_listener_servers(void)
char saddr[129]; char saddr[129];
addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]); addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]);
int port = (int)addr_get_port(&addr); int port = (int)addr_get_port(&addr);
addr_to_string_no_port(&addr,(u08bits*)saddr); addr_to_string_no_port(&addr,(uint8_t*)saddr);
turn_params.listener.aux_udp_services[index] = (dtls_listener_relay_server_type**)allocate_super_memory_engine(turn_params.listener.ioa_eng, sizeof(dtls_listener_relay_server_type*)); turn_params.listener.aux_udp_services[index] = (dtls_listener_relay_server_type**)allocate_super_memory_engine(turn_params.listener.ioa_eng, sizeof(dtls_listener_relay_server_type*));
@ -1481,7 +1481,7 @@ static void setup_tcp_listener_servers(ioa_engine_handle e, struct relay_server
char saddr[129]; char saddr[129];
addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]); addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]);
int port = (int)addr_get_port(&addr); int port = (int)addr_get_port(&addr);
addr_to_string_no_port(&addr,(u08bits*)saddr); addr_to_string_no_port(&addr,(uint8_t*)saddr);
aux_tcp_services[i] = create_tls_listener_server(turn_params.listener_ifname, saddr, port, turn_params.verbose, e, send_socket_to_general_relay, relay_server); aux_tcp_services[i] = create_tls_listener_server(turn_params.listener_ifname, saddr, port, turn_params.verbose, e, send_socket_to_general_relay, relay_server);
} }

View File

@ -202,8 +202,8 @@ static void log_socket_event(ioa_socket_handle s, const char *msg, int error) {
{ {
char sraddr[129]="\0"; char sraddr[129]="\0";
char sladdr[129]="\0"; char sladdr[129]="\0";
addr_to_string(&(s->remote_addr),(u08bits*)sraddr); addr_to_string(&(s->remote_addr),(uint8_t*)sraddr);
addr_to_string(&(s->local_addr),(u08bits*)sladdr); addr_to_string(&(s->local_addr),(uint8_t*)sladdr);
if(EVUTIL_SOCKET_ERROR()) { if(EVUTIL_SOCKET_ERROR()) {
TURN_LOG_FUNC(ll,"session %018llu: %s: %s (local %s, remote %s)\n",(unsigned long long)id, TURN_LOG_FUNC(ll,"session %018llu: %s: %s (local %s, remote %s)\n",(unsigned long long)id,
@ -309,7 +309,7 @@ static inline void add_elem_to_buffer_list(stun_buffer_list *bufs, stun_buffer_l
bufs->tsz += 1; bufs->tsz += 1;
} }
static void add_buffer_to_buffer_list(stun_buffer_list *bufs, s08bits *buf, size_t len) static void add_buffer_to_buffer_list(stun_buffer_list *bufs, char *buf, size_t len)
{ {
if(bufs && buf && (bufs->tsz<MAX_SOCKET_BUFFER_BACKLOG)) { if(bufs && buf && (bufs->tsz<MAX_SOCKET_BUFFER_BACKLOG)) {
stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)malloc(sizeof(stun_buffer_list_elem)); stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)malloc(sizeof(stun_buffer_list_elem));
@ -345,8 +345,8 @@ static void timer_handler(ioa_engine_handle e, void* arg) {
} }
ioa_engine_handle create_ioa_engine(super_memory_t *sm, ioa_engine_handle create_ioa_engine(super_memory_t *sm,
struct event_base *eb, turnipports *tp, const s08bits* relay_ifname, struct event_base *eb, turnipports *tp, const char* relay_ifname,
size_t relays_number, s08bits **relay_addrs, int default_relays, size_t relays_number, char **relay_addrs, int default_relays,
int verbose int verbose
#if !defined(TURN_NO_HIREDIS) #if !defined(TURN_NO_HIREDIS)
,const char* redis_report_connection_string ,const char* redis_report_connection_string
@ -423,7 +423,7 @@ ioa_engine_handle create_ioa_engine(super_memory_t *sm,
size_t i = 0; size_t i = 0;
e->relay_addrs = (ioa_addr*)allocate_super_memory_region(sm, relays_number * sizeof(ioa_addr)+8); e->relay_addrs = (ioa_addr*)allocate_super_memory_region(sm, relays_number * sizeof(ioa_addr)+8);
for (i = 0; i < relays_number; i++) { for (i = 0; i < relays_number; i++) {
if(make_ioa_addr((u08bits*) relay_addrs[i], 0, &(e->relay_addrs[i]))<0) { if(make_ioa_addr((uint8_t*) relay_addrs[i], 0, &(e->relay_addrs[i]))<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot add a relay address: %s\n",relay_addrs[i]); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot add a relay address: %s\n",relay_addrs[i]);
} }
} }
@ -543,7 +543,7 @@ static void timer_event_handler(evutil_socket_t fd, short what, void* arg)
cb(e, ctx); cb(e, ctx);
} }
ioa_timer_handle set_ioa_timer(ioa_engine_handle e, int secs, int ms, ioa_timer_event_handler cb, void* ctx, int persist, const s08bits *txt) ioa_timer_handle set_ioa_timer(ioa_engine_handle e, int secs, int ms, ioa_timer_event_handler cb, void* ctx, int persist, const char *txt)
{ {
ioa_timer_handle ret = NULL; ioa_timer_handle ret = NULL;
@ -628,9 +628,9 @@ int ioa_socket_check_bandwidth(ioa_socket_handle s, ioa_network_buffer_handle nb
struct traffic_bytes *traffic = &(s->data_traffic); struct traffic_bytes *traffic = &(s->data_traffic);
if(s->sat == CLIENT_SOCKET) { if(s->sat == CLIENT_SOCKET) {
u08bits *buf = ioa_network_buffer_data(nbh); uint8_t *buf = ioa_network_buffer_data(nbh);
if(stun_is_command_message_str(buf,sz)) { if(stun_is_command_message_str(buf,sz)) {
u16bits method = stun_get_method_str(buf,sz); uint16_t method = stun_get_method_str(buf,sz);
if((method != STUN_METHOD_SEND) && (method != STUN_METHOD_DATA)) { if((method != STUN_METHOD_SEND) && (method != STUN_METHOD_DATA)) {
traffic = &(s->control_traffic); traffic = &(s->control_traffic);
} }
@ -675,7 +675,7 @@ int ioa_socket_check_bandwidth(ioa_socket_handle s, ioa_network_buffer_handle nb
return 1; return 1;
} }
int get_ioa_socket_from_reservation(ioa_engine_handle e, u64bits in_reservation_token, ioa_socket_handle *s) int get_ioa_socket_from_reservation(ioa_engine_handle e, uint64_t in_reservation_token, ioa_socket_handle *s)
{ {
if (e && in_reservation_token && s) { if (e && in_reservation_token && s) {
*s = rtcp_map_get(e->map_rtcp, in_reservation_token); *s = rtcp_map_get(e->map_rtcp, in_reservation_token);
@ -948,10 +948,10 @@ static int bind_ioa_socket(ioa_socket_handle s, const ioa_addr* local_addr, int
int create_relay_ioa_sockets(ioa_engine_handle e, int create_relay_ioa_sockets(ioa_engine_handle e,
ioa_socket_handle client_s, ioa_socket_handle client_s,
int address_family, u08bits transport, int address_family, uint8_t transport,
int even_port, ioa_socket_handle *rtp_s, int even_port, ioa_socket_handle *rtp_s,
ioa_socket_handle *rtcp_s, uint64_t *out_reservation_token, ioa_socket_handle *rtcp_s, uint64_t *out_reservation_token,
int *err_code, const u08bits **reason, int *err_code, const uint8_t **reason,
accept_cb acb, void *acbarg) accept_cb acb, void *acbarg)
{ {
@ -972,7 +972,7 @@ int create_relay_ioa_sockets(ioa_engine_handle e,
if(*err_code) { if(*err_code) {
if(*err_code == 440) if(*err_code == 440)
*reason = (const u08bits *) "Unsupported address family"; *reason = (const uint8_t *) "Unsupported address family";
return -1; return -1;
} }
@ -1800,14 +1800,14 @@ int ssl_read(evutil_socket_t fd, SSL* ssl, ioa_network_buffer_handle nbh, int ve
if (!ssl || !nbh) if (!ssl || !nbh)
return -1; return -1;
s08bits* buffer = (s08bits*)ioa_network_buffer_data(nbh); char* buffer = (char*)ioa_network_buffer_data(nbh);
int buf_size = (int)ioa_network_buffer_get_capacity_udp(); int buf_size = (int)ioa_network_buffer_get_capacity_udp();
int read_len = (int)ioa_network_buffer_get_size(nbh); int read_len = (int)ioa_network_buffer_get_size(nbh);
if(read_len < 1) if(read_len < 1)
return -1; return -1;
s08bits *new_buffer = buffer + buf_size; char *new_buffer = buffer + buf_size;
int old_buffer_len = read_len; int old_buffer_len = read_len;
int len = 0; int len = 0;
@ -1900,7 +1900,7 @@ int ssl_read(evutil_socket_t fd, SSL* ssl, ioa_network_buffer_handle nbh, int ve
case SSL_ERROR_SSL: case SSL_ERROR_SSL:
if (verbose) { if (verbose) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "SSL read error: "); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "SSL read error: ");
s08bits buf[65536]; char buf[65536];
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s (%d)\n", ERR_error_string(ERR_get_error(), buf), SSL_get_error(ssl, len)); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s (%d)\n", ERR_error_string(ERR_get_error(), buf), SSL_get_error(ssl, len));
} }
if (verbose) if (verbose)
@ -1917,7 +1917,7 @@ int ssl_read(evutil_socket_t fd, SSL* ssl, ioa_network_buffer_handle nbh, int ve
} }
if(ret>0) { if(ret>0) {
ioa_network_buffer_add_offset_size(nbh, (u16bits)buf_size, 0, (size_t)ret); ioa_network_buffer_add_offset_size(nbh, (uint16_t)buf_size, 0, (size_t)ret);
} }
#if OPENSSL_VERSION_NUMBER < 0x10100000L #if OPENSSL_VERSION_NUMBER < 0x10100000L
ssl->rbio = NULL; ssl->rbio = NULL;
@ -1936,7 +1936,7 @@ static int socket_readerr(evutil_socket_t fd, ioa_addr *orig_addr)
#if defined(CMSG_SPACE) && defined(MSG_ERRQUEUE) && defined(IP_RECVERR) #if defined(CMSG_SPACE) && defined(MSG_ERRQUEUE) && defined(IP_RECVERR)
u08bits ecmsg[TURN_CMSG_SZ+1]; uint8_t ecmsg[TURN_CMSG_SZ+1];
int flags = MSG_ERRQUEUE; int flags = MSG_ERRQUEUE;
int len = 0; int len = 0;
@ -1976,7 +1976,7 @@ static int socket_readerr(evutil_socket_t fd, ioa_addr *orig_addr)
typedef unsigned char recv_ttl_t; typedef unsigned char recv_ttl_t;
typedef unsigned char recv_tos_t; typedef unsigned char recv_tos_t;
int udp_recvfrom(evutil_socket_t fd, ioa_addr* orig_addr, const ioa_addr *like_addr, s08bits* buffer, int buf_size, int *ttl, int *tos, s08bits *ecmsg, int flags, u32bits *errcode) int udp_recvfrom(evutil_socket_t fd, ioa_addr* orig_addr, const ioa_addr *like_addr, char* buffer, int buf_size, int *ttl, int *tos, char *ecmsg, int flags, uint32_t *errcode)
{ {
int len = 0; int len = 0;
@ -1995,7 +1995,7 @@ int udp_recvfrom(evutil_socket_t fd, ioa_addr* orig_addr, const ioa_addr *like_a
len = recvfrom(fd, buffer, buf_size, flags, (struct sockaddr*) orig_addr, (socklen_t*) &slen); len = recvfrom(fd, buffer, buf_size, flags, (struct sockaddr*) orig_addr, (socklen_t*) &slen);
} while (len < 0 && (errno == EINTR)); } while (len < 0 && (errno == EINTR));
if(len<0 && errcode) if(len<0 && errcode)
*errcode = (u32bits)errno; *errcode = (uint32_t)errno;
#else #else
struct msghdr msg; struct msghdr msg;
struct iovec iov; struct iovec iov;
@ -2032,7 +2032,7 @@ int udp_recvfrom(evutil_socket_t fd, ioa_addr* orig_addr, const ioa_addr *like_a
if((len<0) && (!(flags & MSG_ERRQUEUE))) { if((len<0) && (!(flags & MSG_ERRQUEUE))) {
//Linux //Linux
int eflags = MSG_ERRQUEUE | MSG_DONTWAIT; int eflags = MSG_ERRQUEUE | MSG_DONTWAIT;
u32bits errcode1 = 0; uint32_t errcode1 = 0;
udp_recvfrom(fd, orig_addr, like_addr, buffer, buf_size, ttl, tos, ecmsg, eflags, &errcode1); udp_recvfrom(fd, orig_addr, like_addr, buffer, buf_size, ttl, tos, ecmsg, eflags, &errcode1);
//try again... //try again...
do { do {
@ -2421,7 +2421,7 @@ static int socket_input_worker(ioa_socket_handle s)
if(len == 0) if(len == 0)
len = -1; len = -1;
} else if(s->fd>=0){ /* UDP and DTLS */ } else if(s->fd>=0){ /* UDP and DTLS */
ret = udp_recvfrom(s->fd, &remote_addr, &(s->local_addr), (s08bits*)(buf_elem->buf.buf), UDP_STUN_BUFFER_SIZE, &ttl, &tos, s->e->cmsg, 0, NULL); ret = udp_recvfrom(s->fd, &remote_addr, &(s->local_addr), (char*)(buf_elem->buf.buf), UDP_STUN_BUFFER_SIZE, &ttl, &tos, s->e->cmsg, 0, NULL);
len = ret; len = ret;
if(s->ssl && (len>0)) { /* DTLS */ if(s->ssl && (len>0)) { /* DTLS */
send_ssl_backlog_buffers(s); send_ssl_backlog_buffers(s);
@ -2740,7 +2740,7 @@ static void eventcb_bev(struct bufferevent *bev, short events, void *arg)
if(!(s->session) && !(s->sub_session)) { if(!(s->session) && !(s->sub_session)) {
char sraddr[129]="\0"; char sraddr[129]="\0";
addr_to_string(&(s->remote_addr),(u08bits*)sraddr); addr_to_string(&(s->remote_addr),(uint8_t*)sraddr);
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s https server socket closed: 0x%lx, st=%d, sat=%d, remote addr=%s\n", __FUNCTION__,(long)s, get_ioa_socket_type(s), get_ioa_socket_app_type(s),sraddr); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s https server socket closed: 0x%lx, st=%d, sat=%d, remote addr=%s\n", __FUNCTION__,(long)s, get_ioa_socket_type(s), get_ioa_socket_app_type(s),sraddr);
IOA_CLOSE_SOCKET(s); IOA_CLOSE_SOCKET(s);
return; return;
@ -2767,7 +2767,7 @@ static void eventcb_bev(struct bufferevent *bev, short events, void *arg)
{ {
char sraddr[129]="\0"; char sraddr[129]="\0";
addr_to_string(&(s->remote_addr),(u08bits*)sraddr); addr_to_string(&(s->remote_addr),(uint8_t*)sraddr);
if (events & BEV_EVENT_EOF) { if (events & BEV_EVENT_EOF) {
if(server->verbose) if(server->verbose)
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"session %018llu: %s socket closed remotely %s\n", TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"session %018llu: %s socket closed remotely %s\n",
@ -2810,7 +2810,7 @@ static void eventcb_bev(struct bufferevent *bev, short events, void *arg)
} }
} }
static int ssl_send(ioa_socket_handle s, const s08bits* buffer, int len, int verbose) static int ssl_send(ioa_socket_handle s, const char* buffer, int len, int verbose)
{ {
if (!s || !(s->ssl) || !buffer || (s->fd<0)) if (!s || !(s->ssl) || !buffer || (s->fd<0))
@ -2925,7 +2925,7 @@ static int ssl_send(ioa_socket_handle s, const s08bits* buffer, int len, int ver
case SSL_ERROR_SSL: case SSL_ERROR_SSL:
if (verbose) { if (verbose) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "SSL write error: "); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "SSL write error: ");
s08bits buf[65536]; char buf[65536];
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s (%d)\n", ERR_error_string(ERR_get_error(), buf), TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s (%d)\n", ERR_error_string(ERR_get_error(), buf),
SSL_get_error(ssl, rc)); SSL_get_error(ssl, rc));
} }
@ -2945,7 +2945,7 @@ static int send_ssl_backlog_buffers(ioa_socket_handle s)
if(s) { if(s) {
stun_buffer_list_elem *buf_elem = s->bufs.head; stun_buffer_list_elem *buf_elem = s->bufs.head;
while(buf_elem) { while(buf_elem) {
int rc = ssl_send(s, (s08bits*)buf_elem->buf.buf + buf_elem->buf.offset - buf_elem->buf.coffset, (size_t)buf_elem->buf.len, ((s->e) && s->e->verbose)); int rc = ssl_send(s, (char*)buf_elem->buf.buf + buf_elem->buf.offset - buf_elem->buf.coffset, (size_t)buf_elem->buf.len, ((s->e) && s->e->verbose));
if(rc<1) if(rc<1)
break; break;
++ret; ++ret;
@ -2976,7 +2976,7 @@ int would_block(void) {
return (errno == EAGAIN); return (errno == EAGAIN);
} }
int udp_send(ioa_socket_handle s, const ioa_addr* dest_addr, const s08bits* buffer, int len) int udp_send(ioa_socket_handle s, const ioa_addr* dest_addr, const char* buffer, int len)
{ {
int rc = 0; int rc = 0;
evutil_socket_t fd = -1; evutil_socket_t fd = -1;
@ -3119,7 +3119,7 @@ int send_data_from_ioa_socket_nbh(ioa_socket_handle s, ioa_addr* dest_addr,
send_ssl_backlog_buffers(s); send_ssl_backlog_buffers(s);
ret = ssl_send( ret = ssl_send(
s, s,
(s08bits*) ioa_network_buffer_data(nbh), (char*) ioa_network_buffer_data(nbh),
ioa_network_buffer_get_size(nbh), ioa_network_buffer_get_size(nbh),
((s->e) && s->e->verbose)); ((s->e) && s->e->verbose));
if (ret < 0) if (ret < 0)
@ -3127,7 +3127,7 @@ int send_data_from_ioa_socket_nbh(ioa_socket_handle s, ioa_addr* dest_addr,
else if (ret == 0) else if (ret == 0)
add_buffer_to_buffer_list( add_buffer_to_buffer_list(
&(s->bufs), &(s->bufs),
(s08bits*) ioa_network_buffer_data(nbh), (char*) ioa_network_buffer_data(nbh),
ioa_network_buffer_get_size(nbh)); ioa_network_buffer_get_size(nbh));
} else if (s->fd >= 0) { } else if (s->fd >= 0) {
@ -3139,7 +3139,7 @@ int send_data_from_ioa_socket_nbh(ioa_socket_handle s, ioa_addr* dest_addr,
ret = udp_send(s, ret = udp_send(s,
dest_addr, dest_addr,
(s08bits*) ioa_network_buffer_data(nbh),ioa_network_buffer_get_size(nbh)); (char*) ioa_network_buffer_data(nbh),ioa_network_buffer_get_size(nbh));
if (ret < 0) { if (ret < 0) {
s->tobeclosed = 1; s->tobeclosed = 1;
#if defined(EADDRNOTAVAIL) #if defined(EADDRNOTAVAIL)
@ -3149,9 +3149,9 @@ int send_data_from_ioa_socket_nbh(ioa_socket_handle s, ioa_addr* dest_addr,
#if defined(EADDRNOTAVAIL) #if defined(EADDRNOTAVAIL)
if(dest_addr && (perr==EADDRNOTAVAIL)) { if(dest_addr && (perr==EADDRNOTAVAIL)) {
char sfrom[129]; char sfrom[129];
addr_to_string(&(s->local_addr), (u08bits*)sfrom); addr_to_string(&(s->local_addr), (uint8_t*)sfrom);
char sto[129]; char sto[129];
addr_to_string(dest_addr, (u08bits*)sto); addr_to_string(dest_addr, (uint8_t*)sto);
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
"%s: network error: address unreachable from %s to %s\n", "%s: network error: address unreachable from %s to %s\n",
__FUNCTION__,sfrom,sto); __FUNCTION__,sfrom,sto);
@ -3406,7 +3406,7 @@ void ioa_network_buffer_header_init(ioa_network_buffer_handle nbh)
UNUSED_ARG(nbh); UNUSED_ARG(nbh);
} }
u08bits *ioa_network_buffer_data(ioa_network_buffer_handle nbh) uint8_t *ioa_network_buffer_data(ioa_network_buffer_handle nbh)
{ {
stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)nbh; stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)nbh;
return buf_elem->buf.buf + buf_elem->buf.offset - buf_elem->buf.coffset; return buf_elem->buf.buf + buf_elem->buf.offset - buf_elem->buf.coffset;
@ -3446,7 +3446,7 @@ void ioa_network_buffer_set_size(ioa_network_buffer_handle nbh, size_t len)
buf_elem->buf.len=(size_t)len; buf_elem->buf.len=(size_t)len;
} }
void ioa_network_buffer_add_offset_size(ioa_network_buffer_handle nbh, u16bits offset, u08bits coffset, size_t len) void ioa_network_buffer_add_offset_size(ioa_network_buffer_handle nbh, uint16_t offset, uint8_t coffset, size_t len)
{ {
stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)nbh; stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)nbh;
buf_elem->buf.len=(size_t)len; buf_elem->buf.len=(size_t)len;
@ -3462,13 +3462,13 @@ void ioa_network_buffer_add_offset_size(ioa_network_buffer_handle nbh, u16bits o
} }
} }
u16bits ioa_network_buffer_get_offset(ioa_network_buffer_handle nbh) uint16_t ioa_network_buffer_get_offset(ioa_network_buffer_handle nbh)
{ {
stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)nbh; stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)nbh;
return buf_elem->buf.offset; return buf_elem->buf.offset;
} }
u08bits ioa_network_buffer_get_coffset(ioa_network_buffer_handle nbh) uint8_t ioa_network_buffer_get_coffset(ioa_network_buffer_handle nbh)
{ {
stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)nbh; stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)nbh;
return buf_elem->buf.coffset; return buf_elem->buf.coffset;
@ -3600,8 +3600,8 @@ void turn_report_session_usage(void *session, int force_invalid)
turn_time_t ct = get_turn_server_time(server); turn_time_t ct = get_turn_server_time(server);
if(ct != ss->start_time) { if(ct != ss->start_time) {
ct = ct - ss->start_time; ct = ct - ss->start_time;
ss->received_rate = (u32bits)(ss->t_received_bytes / ct); ss->received_rate = (uint32_t)(ss->t_received_bytes / ct);
ss->sent_rate = (u32bits)(ss->t_sent_bytes / ct); ss->sent_rate = (uint32_t)(ss->t_sent_bytes / ct);
ss->total_rate = ss->received_rate + ss->sent_rate; ss->total_rate = ss->received_rate + ss->sent_rate;
} }
} }
@ -3644,7 +3644,7 @@ struct _super_memory {
size_t *sm_allocated; size_t *sm_allocated;
size_t sm_total_sz; size_t sm_total_sz;
size_t sm_chunk; size_t sm_chunk;
u32bits id; uint32_t id;
}; };
static void init_super_memory_region(super_memory_t *r) static void init_super_memory_region(super_memory_t *r)
@ -3663,7 +3663,7 @@ static void init_super_memory_region(super_memory_t *r)
r->sm_chunk = 0; r->sm_chunk = 0;
while(r->id == 0) while(r->id == 0)
r->id = (u32bits)random(); r->id = (uint32_t)random();
pthread_mutex_init(&r->mutex_sm, NULL); pthread_mutex_init(&r->mutex_sm, NULL);
} }

View File

@ -157,11 +157,11 @@ struct _ioa_engine
#endif #endif
turn_time_t jiffie; /* bandwidth check interval */ turn_time_t jiffie; /* bandwidth check interval */
ioa_timer_handle timer_ev; ioa_timer_handle timer_ev;
s08bits cmsg[TURN_CMSG_SZ+1]; char cmsg[TURN_CMSG_SZ+1];
int predef_timer_intervals[PREDEF_TIMERS_NUM]; int predef_timer_intervals[PREDEF_TIMERS_NUM];
struct timeval predef_timers[PREDEF_TIMERS_NUM]; struct timeval predef_timers[PREDEF_TIMERS_NUM];
/* Relays */ /* Relays */
s08bits relay_ifname[1025]; char relay_ifname[1025];
int default_relays; int default_relays;
size_t relays_number; size_t relays_number;
size_t relay_addr_counter; size_t relay_addr_counter;
@ -180,7 +180,7 @@ struct _ioa_socket
{ {
evutil_socket_t fd; evutil_socket_t fd;
struct _ioa_socket *parent_s; struct _ioa_socket *parent_s;
u32bits magic; uint32_t magic;
ur_addr_map *sockets_container; /* relay container for UDP sockets */ ur_addr_map *sockets_container; /* relay container for UDP sockets */
struct bufferevent *bev; struct bufferevent *bev;
ioa_network_buffer_handle defer_nbh; ioa_network_buffer_handle defer_nbh;
@ -188,7 +188,7 @@ struct _ioa_socket
SOCKET_TYPE st; SOCKET_TYPE st;
SOCKET_APP_TYPE sat; SOCKET_APP_TYPE sat;
SSL* ssl; SSL* ssl;
u32bits ssl_renegs; uint32_t ssl_renegs;
int in_write; int in_write;
int bound; int bound;
int local_addr_known; int local_addr_known;
@ -236,7 +236,7 @@ typedef struct _timer_event
ioa_engine_handle e; ioa_engine_handle e;
ioa_timer_event_handler cb; ioa_timer_event_handler cb;
void *ctx; void *ctx;
s08bits* txt; char* txt;
} timer_event; } timer_event;
/////////////////////////////////// ///////////////////////////////////
@ -250,8 +250,8 @@ int get_realm_data(char* name, realm_params_t* rp);
ioa_engine_handle create_ioa_engine(super_memory_t *sm, ioa_engine_handle create_ioa_engine(super_memory_t *sm,
struct event_base *eb, turnipports* tp, struct event_base *eb, turnipports* tp,
const s08bits* relay_if, const char* relay_if,
size_t relays_number, s08bits **relay_addrs, int default_relays, size_t relays_number, char **relay_addrs, int default_relays,
int verbose int verbose
#if !defined(TURN_NO_HIREDIS) #if !defined(TURN_NO_HIREDIS)
,const char* redis_report_connection_string ,const char* redis_report_connection_string
@ -273,8 +273,8 @@ void delete_socket_from_map(ioa_socket_handle s);
int is_connreset(void); int is_connreset(void);
int would_block(void); int would_block(void);
int udp_send(ioa_socket_handle s, const ioa_addr* dest_addr, const s08bits* buffer, int len); int udp_send(ioa_socket_handle s, const ioa_addr* dest_addr, const char* buffer, int len);
int udp_recvfrom(evutil_socket_t fd, ioa_addr* orig_addr, const ioa_addr *like_addr, s08bits* buffer, int buf_size, int *ttl, int *tos, s08bits *ecmsg, int flags, u32bits *errcode); int udp_recvfrom(evutil_socket_t fd, ioa_addr* orig_addr, const ioa_addr *like_addr, char* buffer, int buf_size, int *ttl, int *tos, char *ecmsg, int flags, uint32_t *errcode);
int ssl_read(evutil_socket_t fd, SSL* ssl, ioa_network_buffer_handle nbh, int verbose); int ssl_read(evutil_socket_t fd, SSL* ssl, ioa_network_buffer_handle nbh, int verbose);
int set_raw_socket_ttl_options(evutil_socket_t fd, int family); int set_raw_socket_ttl_options(evutil_socket_t fd, int family);

View File

@ -216,7 +216,7 @@ static int create_server_listener(tls_listener_relay_server_type* server) {
if(addr_bind(tls_listen_fd,&server->addr,1,1,TCP_SOCKET)<0) { if(addr_bind(tls_listen_fd,&server->addr,1,1,TCP_SOCKET)<0) {
perror("Cannot bind local socket to addr"); perror("Cannot bind local socket to addr");
char saddr[129]; char saddr[129];
addr_to_string(&server->addr,(u08bits*)saddr); addr_to_string(&server->addr,(uint8_t*)saddr);
TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING,"Cannot bind TLS/TCP listener socket to addr %s\n",saddr); TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING,"Cannot bind TLS/TCP listener socket to addr %s\n",saddr);
if(addr_bind_cycle++<max_binding_time) { if(addr_bind_cycle++<max_binding_time) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"Trying to bind TLS/TCP listener socket to addr %s, again...\n",saddr); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"Trying to bind TLS/TCP listener socket to addr %s, again...\n",saddr);
@ -322,7 +322,7 @@ static int init_server(tls_listener_relay_server_type* server,
if(ifname) STRCPY(server->ifname,ifname); if(ifname) STRCPY(server->ifname,ifname);
if(make_ioa_addr((const u08bits*)local_address, port, &server->addr)<0) { if(make_ioa_addr((const uint8_t*)local_address, port, &server->addr)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot create a TCP/TLS listener for address: %s\n",local_address); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot create a TCP/TLS listener for address: %s\n",local_address);
return -1; return -1;
} }

View File

@ -282,9 +282,9 @@ static void cli_print_addr(struct cli_session* cs, ioa_addr *value, int use_port
sc=" (**)"; sc=" (**)";
char s[256]; char s[256];
if(!use_port) if(!use_port)
addr_to_string_no_port(value,(u08bits*)s); addr_to_string_no_port(value,(uint8_t*)s);
else else
addr_to_string(value,(u08bits*)s); addr_to_string(value,(uint8_t*)s);
myprintf(cs," %s: %s%s\n",name,s,sc); myprintf(cs," %s: %s%s\n",name,s,sc);
} }
} }
@ -301,9 +301,9 @@ static void cli_print_addr_list(struct cli_session* cs, turn_server_addrs_list_t
size_t i; size_t i;
for(i=0;i<value->size;i++) { for(i=0;i<value->size;i++) {
if(!use_port) if(!use_port)
addr_to_string_no_port(&(value->addrs[i]),(u08bits*)s); addr_to_string_no_port(&(value->addrs[i]),(uint8_t*)s);
else else
addr_to_string(&(value->addrs[i]),(u08bits*)s); addr_to_string(&(value->addrs[i]),(uint8_t*)s);
myprintf(cs," %s: %s%s\n",name,s,sc); myprintf(cs," %s: %s%s\n",name,s,sc);
} }
} }
@ -504,13 +504,13 @@ static int print_session(ur_map_key_type key, ur_map_value_type value, void *arg
myprintf(cs," client protocol %s, relay protocol %s\n",socket_type_name(tsi->client_protocol),socket_type_name(tsi->peer_protocol)); myprintf(cs," client protocol %s, relay protocol %s\n",socket_type_name(tsi->client_protocol),socket_type_name(tsi->peer_protocol));
{ {
if(!tsi->local_addr_data.saddr[0]) if(!tsi->local_addr_data.saddr[0])
addr_to_string(&(tsi->local_addr_data.addr),(u08bits*)tsi->local_addr_data.saddr); addr_to_string(&(tsi->local_addr_data.addr),(uint8_t*)tsi->local_addr_data.saddr);
if(!tsi->remote_addr_data.saddr[0]) if(!tsi->remote_addr_data.saddr[0])
addr_to_string(&(tsi->remote_addr_data.addr),(u08bits*)tsi->remote_addr_data.saddr); addr_to_string(&(tsi->remote_addr_data.addr),(uint8_t*)tsi->remote_addr_data.saddr);
if(!tsi->relay_addr_data_ipv4.saddr[0]) if(!tsi->relay_addr_data_ipv4.saddr[0])
addr_to_string(&(tsi->relay_addr_data_ipv4.addr),(u08bits*)tsi->relay_addr_data_ipv4.saddr); addr_to_string(&(tsi->relay_addr_data_ipv4.addr),(uint8_t*)tsi->relay_addr_data_ipv4.saddr);
if(!tsi->relay_addr_data_ipv6.saddr[0]) if(!tsi->relay_addr_data_ipv6.saddr[0])
addr_to_string(&(tsi->relay_addr_data_ipv6.addr),(u08bits*)tsi->relay_addr_data_ipv6.saddr); addr_to_string(&(tsi->relay_addr_data_ipv6.addr),(uint8_t*)tsi->relay_addr_data_ipv6.saddr);
myprintf(cs," client addr %s, server addr %s\n", myprintf(cs," client addr %s, server addr %s\n",
tsi->remote_addr_data.saddr, tsi->remote_addr_data.saddr,
tsi->local_addr_data.saddr); tsi->local_addr_data.saddr);
@ -536,13 +536,13 @@ static int print_session(ur_map_key_type key, ur_map_value_type value, void *arg
size_t i; size_t i;
for(i=0;i<tsi->main_peers_size;++i) { for(i=0;i<tsi->main_peers_size;++i) {
if(!(tsi->main_peers_data[i].saddr[0])) if(!(tsi->main_peers_data[i].saddr[0]))
addr_to_string(&(tsi->main_peers_data[i].addr),(u08bits*)tsi->main_peers_data[i].saddr); addr_to_string(&(tsi->main_peers_data[i].addr),(uint8_t*)tsi->main_peers_data[i].saddr);
myprintf(cs," %s\n",tsi->main_peers_data[i].saddr); myprintf(cs," %s\n",tsi->main_peers_data[i].saddr);
} }
if(tsi->extra_peers_size && tsi->extra_peers_data) { if(tsi->extra_peers_size && tsi->extra_peers_data) {
for(i=0;i<tsi->extra_peers_size;++i) { for(i=0;i<tsi->extra_peers_size;++i) {
if(!(tsi->extra_peers_data[i].saddr[0])) if(!(tsi->extra_peers_data[i].saddr[0]))
addr_to_string(&(tsi->extra_peers_data[i].addr),(u08bits*)tsi->extra_peers_data[i].saddr); addr_to_string(&(tsi->extra_peers_data[i].addr),(uint8_t*)tsi->extra_peers_data[i].saddr);
myprintf(cs," %s\n",tsi->extra_peers_data[i].saddr); myprintf(cs," %s\n",tsi->extra_peers_data[i].saddr);
} }
} }
@ -1349,7 +1349,7 @@ void setup_admin_thread(void)
// Setup the web-admin server // Setup the web-admin server
if(use_web_admin) { if(use_web_admin) {
if(!web_admin_addr_set) { if(!web_admin_addr_set) {
if(make_ioa_addr((const u08bits*)WEB_ADMIN_DEFAULT_IP, 0, &web_admin_addr) < 0) { if(make_ioa_addr((const uint8_t*)WEB_ADMIN_DEFAULT_IP, 0, &web_admin_addr) < 0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot set web-admin address %s\n", WEB_ADMIN_DEFAULT_IP); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot set web-admin address %s\n", WEB_ADMIN_DEFAULT_IP);
return; return;
} }
@ -1358,7 +1358,7 @@ void setup_admin_thread(void)
addr_set_port(&web_admin_addr, web_admin_port); addr_set_port(&web_admin_addr, web_admin_port);
char saddr[129]; char saddr[129];
addr_to_string_no_port(&web_admin_addr,(u08bits*)saddr); addr_to_string_no_port(&web_admin_addr,(uint8_t*)saddr);
tls_listener_relay_server_type *tls_service = create_tls_listener_server(turn_params.listener_ifname, saddr, web_admin_port, turn_params.verbose, adminserver.e, send_socket_to_admin_server, NULL); tls_listener_relay_server_type *tls_service = create_tls_listener_server(turn_params.listener_ifname, saddr, web_admin_port, turn_params.verbose, adminserver.e, send_socket_to_admin_server, NULL);
@ -1372,7 +1372,7 @@ void setup_admin_thread(void)
if(use_cli) { if(use_cli) {
if(!cli_addr_set) { if(!cli_addr_set) {
if(make_ioa_addr((const u08bits*)CLI_DEFAULT_IP,0,&cli_addr)<0) { if(make_ioa_addr((const uint8_t*)CLI_DEFAULT_IP,0,&cli_addr)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot set cli address %s\n",CLI_DEFAULT_IP); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot set cli address %s\n",CLI_DEFAULT_IP);
return; return;
} }
@ -1390,7 +1390,7 @@ void setup_admin_thread(void)
if(addr_bind(adminserver.listen_fd,&cli_addr,1,1,TCP_SOCKET)<0) { if(addr_bind(adminserver.listen_fd,&cli_addr,1,1,TCP_SOCKET)<0) {
perror("Cannot bind CLI socket to addr"); perror("Cannot bind CLI socket to addr");
char saddr[129]; char saddr[129];
addr_to_string(&cli_addr,(u08bits*)saddr); addr_to_string(&cli_addr,(uint8_t*)saddr);
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot bind CLI listener socket to addr %s\n",saddr); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot bind CLI listener socket to addr %s\n",saddr);
socket_closesocket(adminserver.listen_fd); socket_closesocket(adminserver.listen_fd);
return; return;
@ -1895,9 +1895,9 @@ static void https_print_addr(struct str_buffer* sb, ioa_addr *value, int use_por
if(sb && name && value) { if(sb && name && value) {
char s[256]; char s[256];
if(!use_port) if(!use_port)
addr_to_string_no_port(value,(u08bits*)s); addr_to_string_no_port(value,(uint8_t*)s);
else else
addr_to_string(value,(u08bits*)s); addr_to_string(value,(uint8_t*)s);
sbprintf(sb,"<tr><td> %s</td><td> %s</td></tr>\r\n",name,s); sbprintf(sb,"<tr><td> %s</td><td> %s</td></tr>\r\n",name,s);
} }
} }
@ -1909,9 +1909,9 @@ static size_t https_print_addr_list(struct str_buffer* sb, turn_server_addrs_lis
size_t i; size_t i;
for(i=0;i<value->size;i++) { for(i=0;i<value->size;i++) {
if(!use_port) if(!use_port)
addr_to_string_no_port(&(value->addrs[i]),(u08bits*)s); addr_to_string_no_port(&(value->addrs[i]),(uint8_t*)s);
else else
addr_to_string(&(value->addrs[i]),(u08bits*)s); addr_to_string(&(value->addrs[i]),(uint8_t*)s);
sbprintf(sb,"</tr><td> %s</td><td> %s</td></tr>\r\n",name,s); sbprintf(sb,"</tr><td> %s</td><td> %s</td></tr>\r\n",name,s);
} }
return i; return i;
@ -2013,13 +2013,13 @@ static void update_param(const char* pn, const char *value)
if (dbd && dbd->set_realm_option_one) { if (dbd && dbd->set_realm_option_one) {
if(strstr(pn,"cr-total-quota")==pn) { if(strstr(pn,"cr-total-quota")==pn) {
rp->options.perf_options.total_quota = atoi(value); rp->options.perf_options.total_quota = atoi(value);
dbd->set_realm_option_one((u08bits*)rp->options.name,rp->options.perf_options.total_quota,"total-quota"); dbd->set_realm_option_one((uint8_t*)rp->options.name,rp->options.perf_options.total_quota,"total-quota");
} else if(strstr(pn,"cr-user-quota")==pn) { } else if(strstr(pn,"cr-user-quota")==pn) {
rp->options.perf_options.user_quota = atoi(value); rp->options.perf_options.user_quota = atoi(value);
dbd->set_realm_option_one((u08bits*)rp->options.name,rp->options.perf_options.user_quota,"user-quota"); dbd->set_realm_option_one((uint8_t*)rp->options.name,rp->options.perf_options.user_quota,"user-quota");
} else if(strstr(pn,"cr-max-bps")==pn) { } else if(strstr(pn,"cr-max-bps")==pn) {
rp->options.perf_options.max_bps = (band_limit_t)strtoul(value,NULL,10); rp->options.perf_options.max_bps = (band_limit_t)strtoul(value,NULL,10);
dbd->set_realm_option_one((u08bits*)rp->options.name,rp->options.perf_options.max_bps,"max-bps"); dbd->set_realm_option_one((uint8_t*)rp->options.name,rp->options.perf_options.max_bps,"max-bps");
} }
} }
} }
@ -2355,13 +2355,13 @@ static int https_print_session(ur_map_key_type key, ur_map_value_type value, voi
str_buffer_append(sb,"</td><td>"); str_buffer_append(sb,"</td><td>");
{ {
if(!tsi->local_addr_data.saddr[0]) if(!tsi->local_addr_data.saddr[0])
addr_to_string(&(tsi->local_addr_data.addr),(u08bits*)tsi->local_addr_data.saddr); addr_to_string(&(tsi->local_addr_data.addr),(uint8_t*)tsi->local_addr_data.saddr);
if(!tsi->remote_addr_data.saddr[0]) if(!tsi->remote_addr_data.saddr[0])
addr_to_string(&(tsi->remote_addr_data.addr),(u08bits*)tsi->remote_addr_data.saddr); addr_to_string(&(tsi->remote_addr_data.addr),(uint8_t*)tsi->remote_addr_data.saddr);
if(!tsi->relay_addr_data_ipv4.saddr[0]) if(!tsi->relay_addr_data_ipv4.saddr[0])
addr_to_string(&(tsi->relay_addr_data_ipv4.addr),(u08bits*)tsi->relay_addr_data_ipv4.saddr); addr_to_string(&(tsi->relay_addr_data_ipv4.addr),(uint8_t*)tsi->relay_addr_data_ipv4.saddr);
if(!tsi->relay_addr_data_ipv6.saddr[0]) if(!tsi->relay_addr_data_ipv6.saddr[0])
addr_to_string(&(tsi->relay_addr_data_ipv6.addr),(u08bits*)tsi->relay_addr_data_ipv6.saddr); addr_to_string(&(tsi->relay_addr_data_ipv6.addr),(uint8_t*)tsi->relay_addr_data_ipv6.saddr);
str_buffer_append(sb,tsi->remote_addr_data.saddr); str_buffer_append(sb,tsi->remote_addr_data.saddr);
str_buffer_append(sb,"</td><td>"); str_buffer_append(sb,"</td><td>");
str_buffer_append(sb,tsi->local_addr_data.saddr); str_buffer_append(sb,tsi->local_addr_data.saddr);
@ -2397,7 +2397,7 @@ static int https_print_session(ur_map_key_type key, ur_map_value_type value, voi
size_t i; size_t i;
for(i=0;i<tsi->main_peers_size;++i) { for(i=0;i<tsi->main_peers_size;++i) {
if(!(tsi->main_peers_data[i].saddr[0])) if(!(tsi->main_peers_data[i].saddr[0]))
addr_to_string(&(tsi->main_peers_data[i].addr),(u08bits*)tsi->main_peers_data[i].saddr); addr_to_string(&(tsi->main_peers_data[i].addr),(uint8_t*)tsi->main_peers_data[i].saddr);
str_buffer_append(sb," "); str_buffer_append(sb," ");
str_buffer_append(sb,tsi->main_peers_data[i].saddr); str_buffer_append(sb,tsi->main_peers_data[i].saddr);
str_buffer_append(sb," "); str_buffer_append(sb," ");
@ -2405,7 +2405,7 @@ static int https_print_session(ur_map_key_type key, ur_map_value_type value, voi
if(tsi->extra_peers_size && tsi->extra_peers_data) { if(tsi->extra_peers_size && tsi->extra_peers_data) {
for(i=0;i<tsi->extra_peers_size;++i) { for(i=0;i<tsi->extra_peers_size;++i) {
if(!(tsi->extra_peers_data[i].saddr[0])) if(!(tsi->extra_peers_data[i].saddr[0]))
addr_to_string(&(tsi->extra_peers_data[i].addr),(u08bits*)tsi->extra_peers_data[i].saddr); addr_to_string(&(tsi->extra_peers_data[i].addr),(uint8_t*)tsi->extra_peers_data[i].saddr);
str_buffer_append(sb," "); str_buffer_append(sb," ");
str_buffer_append(sb,tsi->extra_peers_data[i].saddr); str_buffer_append(sb,tsi->extra_peers_data[i].saddr);
str_buffer_append(sb," "); str_buffer_append(sb," ");
@ -2509,7 +2509,7 @@ static size_t https_print_users(struct str_buffer* sb)
secrets_list_t users,realms; secrets_list_t users,realms;
init_secrets_list(&users); init_secrets_list(&users);
init_secrets_list(&realms); init_secrets_list(&realms);
dbd->list_users((u08bits*)current_eff_realm(),&users,&realms); dbd->list_users((uint8_t*)current_eff_realm(),&users,&realms);
size_t sz = get_secrets_list_size(&users); size_t sz = get_secrets_list_size(&users);
size_t i; size_t i;
@ -2548,7 +2548,7 @@ static size_t https_print_users(struct str_buffer* sb)
return ret; return ret;
} }
static void write_users_page(ioa_socket_handle s, const u08bits *add_user, const u08bits *add_realm, const char* msg) static void write_users_page(ioa_socket_handle s, const uint8_t *add_user, const uint8_t *add_realm, const char* msg)
{ {
if(s && !ioa_socket_tobeclosed(s)) { if(s && !ioa_socket_tobeclosed(s)) {
@ -2657,7 +2657,7 @@ static size_t https_print_secrets(struct str_buffer* sb)
secrets_list_t secrets,realms; secrets_list_t secrets,realms;
init_secrets_list(&secrets); init_secrets_list(&secrets);
init_secrets_list(&realms); init_secrets_list(&realms);
dbd->list_secrets((u08bits*)current_eff_realm(),&secrets,&realms); dbd->list_secrets((uint8_t*)current_eff_realm(),&secrets,&realms);
size_t sz = get_secrets_list_size(&secrets); size_t sz = get_secrets_list_size(&secrets);
size_t i; size_t i;
@ -2791,7 +2791,7 @@ static size_t https_print_origins(struct str_buffer* sb)
secrets_list_t origins,realms; secrets_list_t origins,realms;
init_secrets_list(&origins); init_secrets_list(&origins);
init_secrets_list(&realms); init_secrets_list(&realms);
dbd->list_origins((u08bits*)current_eff_realm(),&origins,&realms); dbd->list_origins((uint8_t*)current_eff_realm(),&origins,&realms);
size_t sz = get_secrets_list_size(&origins); size_t sz = get_secrets_list_size(&origins);
size_t i; size_t i;
@ -3006,7 +3006,7 @@ static void write_https_oauth_show_keys(ioa_socket_handle s, const char* kid)
const turn_dbdriver_t * dbd = get_dbdriver(); const turn_dbdriver_t * dbd = get_dbdriver();
if (dbd && dbd->get_oauth_key) { if (dbd && dbd->get_oauth_key) {
oauth_key_data_raw key; oauth_key_data_raw key;
if((*dbd->get_oauth_key)((const u08bits*)kid,&key)<0) { if((*dbd->get_oauth_key)((const uint8_t*)kid,&key)<0) {
str_buffer_append(sb,"data retrieval error"); str_buffer_append(sb,"data retrieval error");
} else { } else {
@ -3232,7 +3232,7 @@ static void handle_update_request(ioa_socket_handle s, struct http_request* hr)
//forbidden //forbidden
} else { } else {
u08bits realm[STUN_MAX_REALM_SIZE+1]="\0"; uint8_t realm[STUN_MAX_REALM_SIZE+1]="\0";
STRCPY(realm,r); STRCPY(realm,r);
dbd->set_permission_ip(kind, realm, ip, 1); dbd->set_permission_ip(kind, realm, ip, 1);
@ -3265,7 +3265,7 @@ static void handle_update_request(ioa_socket_handle s, struct http_request* hr)
//forbidden //forbidden
} else { } else {
u08bits realm[STUN_MAX_REALM_SIZE+1]="\0"; uint8_t realm[STUN_MAX_REALM_SIZE+1]="\0";
STRCPY(realm,r); STRCPY(realm,r);
dbd->set_permission_ip(kind, realm, ip, 0); dbd->set_permission_ip(kind, realm, ip, 0);
@ -3292,12 +3292,12 @@ static void handle_logon_request(ioa_socket_handle s, struct http_request* hr)
s->special_session_size = sizeof(struct admin_session); s->special_session_size = sizeof(struct admin_session);
} }
if(!(as->as_ok) && uname && is_secure_string((const u08bits*)uname,1) && pwd) { if(!(as->as_ok) && uname && is_secure_string((const uint8_t*)uname,1) && pwd) {
const turn_dbdriver_t * dbd = get_dbdriver(); const turn_dbdriver_t * dbd = get_dbdriver();
if (dbd && dbd->get_admin_user) { if (dbd && dbd->get_admin_user) {
password_t password; password_t password;
char realm[STUN_MAX_REALM_SIZE+1]="\0"; char realm[STUN_MAX_REALM_SIZE+1]="\0";
if((*(dbd->get_admin_user))((const u08bits*)uname,(u08bits*)realm,password)>=0) { if((*(dbd->get_admin_user))((const uint8_t*)uname,(uint8_t*)realm,password)>=0) {
if(!check_password(pwd,(char*)password)) { if(!check_password(pwd,(char*)password)) {
STRCPY(as->as_login,uname); STRCPY(as->as_login,uname);
STRCPY(as->as_realm,realm); STRCPY(as->as_realm,realm);
@ -3410,17 +3410,17 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
} }
{ {
const u08bits *user = (const u08bits*)get_http_header_value(hr, HR_DELETE_USER, NULL); const uint8_t *user = (const uint8_t*)get_http_header_value(hr, HR_DELETE_USER, NULL);
if(user && user[0]) { if(user && user[0]) {
const u08bits *realm = (const u08bits*)get_http_header_value(hr, HR_DELETE_REALM, ""); const uint8_t *realm = (const uint8_t*)get_http_header_value(hr, HR_DELETE_REALM, "");
if(!is_superuser()) { if(!is_superuser()) {
realm = (const u08bits*)current_realm(); realm = (const uint8_t*)current_realm();
} }
if(realm && realm[0]) { if(realm && realm[0]) {
const turn_dbdriver_t * dbd = get_dbdriver(); const turn_dbdriver_t * dbd = get_dbdriver();
if (dbd && dbd->del_user) { if (dbd && dbd->del_user) {
u08bits u[STUN_MAX_USERNAME_SIZE+1]; uint8_t u[STUN_MAX_USERNAME_SIZE+1];
u08bits r[STUN_MAX_REALM_SIZE+1]; uint8_t r[STUN_MAX_REALM_SIZE+1];
STRCPY(u,user); STRCPY(u,user);
STRCPY(r,realm); STRCPY(r,realm);
dbd->del_user(u,r); dbd->del_user(u,r);
@ -3429,31 +3429,31 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
} }
} }
const u08bits *add_realm = (const u08bits*)current_eff_realm(); const uint8_t *add_realm = (const uint8_t*)current_eff_realm();
const u08bits *add_user = (const u08bits*)get_http_header_value(hr, HR_ADD_USER,""); const uint8_t *add_user = (const uint8_t*)get_http_header_value(hr, HR_ADD_USER,"");
const char* msg = ""; const char* msg = "";
if(wrong_html_name((const char*)add_user)) { if(wrong_html_name((const char*)add_user)) {
msg = "Error: wrong user name"; msg = "Error: wrong user name";
add_user = (const u08bits*)""; add_user = (const uint8_t*)"";
} }
if(add_user[0]) { if(add_user[0]) {
add_realm = (const u08bits*)get_http_header_value(hr, HR_ADD_REALM, current_realm()); add_realm = (const uint8_t*)get_http_header_value(hr, HR_ADD_REALM, current_realm());
if(!is_superuser()) { if(!is_superuser()) {
add_realm = (const u08bits*)current_realm(); add_realm = (const uint8_t*)current_realm();
} }
if(!add_realm[0]) { if(!add_realm[0]) {
add_realm=(const u08bits*)current_eff_realm(); add_realm=(const uint8_t*)current_eff_realm();
} }
if(!add_realm[0]) { if(!add_realm[0]) {
add_realm = (const u08bits*)get_realm(NULL)->options.name; add_realm = (const uint8_t*)get_realm(NULL)->options.name;
} }
if(wrong_html_name((const char*)add_realm)) { if(wrong_html_name((const char*)add_realm)) {
msg = "Error: wrong realm name"; msg = "Error: wrong realm name";
add_realm = (const u08bits*)""; add_realm = (const uint8_t*)"";
} }
if(add_realm[0]) { if(add_realm[0]) {
const u08bits *pwd = (const u08bits*)get_http_header_value(hr, HR_PASSWORD, NULL); const uint8_t *pwd = (const uint8_t*)get_http_header_value(hr, HR_PASSWORD, NULL);
const u08bits *pwd1 = (const u08bits*)get_http_header_value(hr, HR_PASSWORD1, NULL); const uint8_t *pwd1 = (const uint8_t*)get_http_header_value(hr, HR_PASSWORD1, NULL);
if(pwd && pwd1 && pwd[0] && pwd1[0] && !strcmp((const char*)pwd,(const char*)pwd1)) { if(pwd && pwd1 && pwd[0] && pwd1[0] && !strcmp((const char*)pwd,(const char*)pwd1)) {
const turn_dbdriver_t * dbd = get_dbdriver(); const turn_dbdriver_t * dbd = get_dbdriver();
@ -3463,9 +3463,9 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
char skey[sizeof(hmackey_t) * 2 + 1]; char skey[sizeof(hmackey_t) * 2 + 1];
{ {
u08bits u[STUN_MAX_USERNAME_SIZE+1]; uint8_t u[STUN_MAX_USERNAME_SIZE+1];
u08bits r[STUN_MAX_REALM_SIZE+1]; uint8_t r[STUN_MAX_REALM_SIZE+1];
u08bits p[STUN_MAX_PWD_SIZE+1]; uint8_t p[STUN_MAX_PWD_SIZE+1];
STRCPY(u,add_user); STRCPY(u,add_user);
STRCPY(r,add_realm); STRCPY(r,add_realm);
STRCPY(p,pwd); STRCPY(p,pwd);
@ -3484,8 +3484,8 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
(*dbd->set_user_key)(u, r, skey); (*dbd->set_user_key)(u, r, skey);
} }
add_realm=(const u08bits*)""; add_realm=(const uint8_t*)"";
add_user=(const u08bits*)""; add_user=(const uint8_t*)"";
} }
} else { } else {
msg = "Error: wrong password"; msg = "Error: wrong password";
@ -3510,17 +3510,17 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
} }
{ {
const u08bits *secret = (const u08bits*)get_http_header_value(hr, HR_DELETE_SECRET, NULL); const uint8_t *secret = (const uint8_t*)get_http_header_value(hr, HR_DELETE_SECRET, NULL);
if(secret && secret[0]) { if(secret && secret[0]) {
const u08bits *realm = (const u08bits*)get_http_header_value(hr, HR_DELETE_REALM, NULL); const uint8_t *realm = (const uint8_t*)get_http_header_value(hr, HR_DELETE_REALM, NULL);
if(!is_superuser()) { if(!is_superuser()) {
realm = (const u08bits*)current_realm(); realm = (const uint8_t*)current_realm();
} }
if(realm && realm[0]) { if(realm && realm[0]) {
const turn_dbdriver_t * dbd = get_dbdriver(); const turn_dbdriver_t * dbd = get_dbdriver();
if (dbd && dbd->del_secret) { if (dbd && dbd->del_secret) {
u08bits ss[AUTH_SECRET_SIZE+1]; uint8_t ss[AUTH_SECRET_SIZE+1];
u08bits r[STUN_MAX_REALM_SIZE+1]; uint8_t r[STUN_MAX_REALM_SIZE+1];
STRCPY(ss,secret); STRCPY(ss,secret);
STRCPY(r,realm); STRCPY(r,realm);
dbd->del_secret(ss,r); dbd->del_secret(ss,r);
@ -3529,40 +3529,40 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
} }
} }
const u08bits *add_realm = (const u08bits*)current_eff_realm(); const uint8_t *add_realm = (const uint8_t*)current_eff_realm();
const u08bits *add_secret = (const u08bits*)get_http_header_value(hr, HR_ADD_SECRET, ""); const uint8_t *add_secret = (const uint8_t*)get_http_header_value(hr, HR_ADD_SECRET, "");
const char* msg = ""; const char* msg = "";
if(wrong_html_name((const char*)add_secret)) { if(wrong_html_name((const char*)add_secret)) {
msg = "Error: wrong secret value"; msg = "Error: wrong secret value";
add_secret = (const u08bits*)""; add_secret = (const uint8_t*)"";
} }
if(add_secret[0]) { if(add_secret[0]) {
add_realm = (const u08bits*)get_http_header_value(hr, HR_ADD_REALM, current_realm()); add_realm = (const uint8_t*)get_http_header_value(hr, HR_ADD_REALM, current_realm());
if(!is_superuser()) { if(!is_superuser()) {
add_realm = (const u08bits*)current_realm(); add_realm = (const uint8_t*)current_realm();
} }
if(!add_realm[0]) { if(!add_realm[0]) {
add_realm=(const u08bits*)current_eff_realm(); add_realm=(const uint8_t*)current_eff_realm();
} }
if(!add_realm[0]) { if(!add_realm[0]) {
add_realm = (const u08bits*)get_realm(NULL)->options.name; add_realm = (const uint8_t*)get_realm(NULL)->options.name;
} }
if(wrong_html_name((const char*)add_realm)) { if(wrong_html_name((const char*)add_realm)) {
msg = "Error: wrong realm name"; msg = "Error: wrong realm name";
add_realm = (const u08bits*)""; add_realm = (const uint8_t*)"";
} }
if(add_realm[0]) { if(add_realm[0]) {
const turn_dbdriver_t * dbd = get_dbdriver(); const turn_dbdriver_t * dbd = get_dbdriver();
if (dbd && dbd->set_secret) { if (dbd && dbd->set_secret) {
u08bits ss[AUTH_SECRET_SIZE+1]; uint8_t ss[AUTH_SECRET_SIZE+1];
u08bits r[STUN_MAX_REALM_SIZE+1]; uint8_t r[STUN_MAX_REALM_SIZE+1];
STRCPY(ss,add_secret); STRCPY(ss,add_secret);
STRCPY(r,add_realm); STRCPY(r,add_realm);
(*dbd->set_secret)(ss, r); (*dbd->set_secret)(ss, r);
} }
add_secret=(const u08bits*)""; add_secret=(const uint8_t*)"";
add_realm=(const u08bits*)""; add_realm=(const uint8_t*)"";
} }
} }
@ -3583,48 +3583,48 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
} }
if(is_superuser()) { if(is_superuser()) {
const u08bits *origin = (const u08bits*)get_http_header_value(hr, HR_DELETE_ORIGIN, NULL); const uint8_t *origin = (const uint8_t*)get_http_header_value(hr, HR_DELETE_ORIGIN, NULL);
if(origin && origin[0]) { if(origin && origin[0]) {
const turn_dbdriver_t * dbd = get_dbdriver(); const turn_dbdriver_t * dbd = get_dbdriver();
if (dbd && dbd->del_origin) { if (dbd && dbd->del_origin) {
u08bits o[STUN_MAX_ORIGIN_SIZE+1]; uint8_t o[STUN_MAX_ORIGIN_SIZE+1];
STRCPY(o,origin); STRCPY(o,origin);
dbd->del_origin(o); dbd->del_origin(o);
u08bits corigin[STUN_MAX_ORIGIN_SIZE+1]; uint8_t corigin[STUN_MAX_ORIGIN_SIZE+1];
get_canonic_origin((const char *)origin, (char *)corigin, sizeof(corigin)-1); get_canonic_origin((const char *)origin, (char *)corigin, sizeof(corigin)-1);
dbd->del_origin(corigin); dbd->del_origin(corigin);
} }
} }
} }
const u08bits *add_realm = (const u08bits*)current_eff_realm(); const uint8_t *add_realm = (const uint8_t*)current_eff_realm();
const u08bits *add_origin = (const u08bits*)get_http_header_value(hr, HR_ADD_ORIGIN, ""); const uint8_t *add_origin = (const uint8_t*)get_http_header_value(hr, HR_ADD_ORIGIN, "");
const char* msg = ""; const char* msg = "";
u08bits corigin[STUN_MAX_ORIGIN_SIZE+1]; uint8_t corigin[STUN_MAX_ORIGIN_SIZE+1];
get_canonic_origin((const char *)add_origin, (char *)corigin, sizeof(corigin)-1); get_canonic_origin((const char *)add_origin, (char *)corigin, sizeof(corigin)-1);
if(corigin[0]) { if(corigin[0]) {
add_realm = (const u08bits*)get_http_header_value(hr, HR_ADD_REALM, current_realm()); add_realm = (const uint8_t*)get_http_header_value(hr, HR_ADD_REALM, current_realm());
if(!is_superuser()) { if(!is_superuser()) {
add_realm = (const u08bits*)current_realm(); add_realm = (const uint8_t*)current_realm();
} }
if(!add_realm[0]) { if(!add_realm[0]) {
add_realm=(const u08bits*)current_eff_realm(); add_realm=(const uint8_t*)current_eff_realm();
} }
if(!add_realm[0]) { if(!add_realm[0]) {
add_realm = (const u08bits*)get_realm(NULL)->options.name; add_realm = (const uint8_t*)get_realm(NULL)->options.name;
} }
if(add_realm[0]) { if(add_realm[0]) {
const turn_dbdriver_t * dbd = get_dbdriver(); const turn_dbdriver_t * dbd = get_dbdriver();
if (dbd && dbd->add_origin) { if (dbd && dbd->add_origin) {
u08bits o[STUN_MAX_ORIGIN_SIZE+1]; uint8_t o[STUN_MAX_ORIGIN_SIZE+1];
u08bits r[STUN_MAX_REALM_SIZE+1]; uint8_t r[STUN_MAX_REALM_SIZE+1];
STRCPY(o,corigin); STRCPY(o,corigin);
STRCPY(r,add_realm); STRCPY(r,add_realm);
(*dbd->add_origin)(o, r); (*dbd->add_origin)(o, r);
} }
add_origin=(const u08bits*)""; add_origin=(const uint8_t*)"";
add_realm=(const u08bits*)""; add_realm=(const uint8_t*)"";
} }
} }
@ -3658,7 +3658,7 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
if(del_kid[0]) { if(del_kid[0]) {
const turn_dbdriver_t * dbd = get_dbdriver(); const turn_dbdriver_t * dbd = get_dbdriver();
if (dbd && dbd->del_oauth_key) { if (dbd && dbd->del_oauth_key) {
(*dbd->del_oauth_key)((const u08bits*)del_kid); (*dbd->del_oauth_key)((const uint8_t*)del_kid);
} }
} }
} }
@ -3688,17 +3688,17 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
STRCPY(key.kid,add_kid); STRCPY(key.kid,add_kid);
if(add_lt && add_lt[0]) { if(add_lt && add_lt[0]) {
key.lifetime = (u32bits)strtoul(add_lt,NULL,10); key.lifetime = (uint32_t)strtoul(add_lt,NULL,10);
if(key.lifetime) { if(key.lifetime) {
if(add_ts && add_ts[0]) { if(add_ts && add_ts[0]) {
key.timestamp = (u64bits)strtoull(add_ts,NULL,10); key.timestamp = (uint64_t)strtoull(add_ts,NULL,10);
} }
if(!key.timestamp) { if(!key.timestamp) {
key.timestamp = (u64bits)time(NULL); key.timestamp = (uint64_t)time(NULL);
} }
} }
} else if(add_ts && add_ts[0]) { } else if(add_ts && add_ts[0]) {
key.timestamp = (u64bits)strtoull(add_ts,NULL,10); key.timestamp = (uint64_t)strtoull(add_ts,NULL,10);
} }
if(add_realm && add_realm[0]) STRCPY(key.realm,add_realm); if(add_realm && add_realm[0]) STRCPY(key.realm,add_realm);

View File

@ -39,38 +39,38 @@
////////// DATA //////////////////////////////////////////// ////////// DATA ////////////////////////////////////////////
#define PORTS_SIZE (0xFFFF+1) #define PORTS_SIZE (0xFFFF+1)
#define TPS_OUT_OF_RANGE ((u32bits)(-1)) #define TPS_OUT_OF_RANGE ((uint32_t)(-1))
#define TPS_TAKEN_SINGLE ((u32bits)(-2)) #define TPS_TAKEN_SINGLE ((uint32_t)(-2))
#define TPS_TAKEN_EVEN ((u32bits)(-3)) #define TPS_TAKEN_EVEN ((uint32_t)(-3))
#define TPS_TAKEN_ODD ((u32bits)(-4)) #define TPS_TAKEN_ODD ((uint32_t)(-4))
struct _turnports { struct _turnports {
u32bits status[PORTS_SIZE]; uint32_t status[PORTS_SIZE];
u32bits low; uint32_t low;
u32bits high; uint32_t high;
u16bits range_start; uint16_t range_start;
u16bits range_stop; uint16_t range_stop;
u16bits ports[PORTS_SIZE]; uint16_t ports[PORTS_SIZE];
TURN_MUTEX_DECLARE(mutex) TURN_MUTEX_DECLARE(mutex)
}; };
typedef struct _turnports turnports; typedef struct _turnports turnports;
/////////////// TURNPORTS statics ////////////////////////// /////////////// TURNPORTS statics //////////////////////////
static turnports* turnports_create(super_memory_t *sm, u16bits start, u16bits end); static turnports* turnports_create(super_memory_t *sm, uint16_t start, uint16_t end);
static u16bits turnports_size(turnports* tp); static uint16_t turnports_size(turnports* tp);
static int turnports_allocate(turnports* tp); static int turnports_allocate(turnports* tp);
static int turnports_allocate_even(turnports* tp, int allocate_rtcp, u64bits *reservation_token); static int turnports_allocate_even(turnports* tp, int allocate_rtcp, uint64_t *reservation_token);
static void turnports_release(turnports* tp, u16bits port); static void turnports_release(turnports* tp, uint16_t port);
static int turnports_is_allocated(turnports* tp, u16bits port); static int turnports_is_allocated(turnports* tp, uint16_t port);
static int turnports_is_available(turnports* tp, u16bits port); static int turnports_is_available(turnports* tp, uint16_t port);
/////////////// UTILS ////////////////////////////////////// /////////////// UTILS //////////////////////////////////////
static int is_taken(u32bits status) { static int is_taken(uint32_t status) {
int ret = -1; int ret = -1;
switch (status) { switch (status) {
case TPS_TAKEN_SINGLE : case TPS_TAKEN_SINGLE :
@ -90,26 +90,26 @@ static void turnports_randomize(turnports* tp) {
unsigned int i=0; unsigned int i=0;
unsigned int cycles=size*10; unsigned int cycles=size*10;
for(i=0;i<cycles;i++) { for(i=0;i<cycles;i++) {
u16bits port1 = (u16bits)(tp->low + (u16bits)(((unsigned long)random())%((unsigned long)size))); uint16_t port1 = (uint16_t)(tp->low + (uint16_t)(((unsigned long)random())%((unsigned long)size)));
u16bits port2 = (u16bits)(tp->low + (u16bits)(((unsigned long)random())%((unsigned long)size))); uint16_t port2 = (uint16_t)(tp->low + (uint16_t)(((unsigned long)random())%((unsigned long)size)));
if(port1!=port2) { if(port1!=port2) {
int pos1=tp->status[port1]; int pos1=tp->status[port1];
int pos2=tp->status[port2]; int pos2=tp->status[port2];
int tmp=(int)tp->status[port1]; int tmp=(int)tp->status[port1];
tp->status[port1]=tp->status[port2]; tp->status[port1]=tp->status[port2];
tp->status[port2]=(u32bits)tmp; tp->status[port2]=(uint32_t)tmp;
tmp=(int)tp->ports[pos1]; tmp=(int)tp->ports[pos1];
tp->ports[pos1]=tp->ports[pos2]; tp->ports[pos1]=tp->ports[pos2];
tp->ports[pos2]=(u16bits)tmp; tp->ports[pos2]=(uint16_t)tmp;
} }
} }
} }
} }
static void turnports_init(turnports* tp, u16bits start, u16bits end) { static void turnports_init(turnports* tp, uint16_t start, uint16_t end) {
tp->low=start; tp->low=start;
tp->high=((u32bits)end)+1; tp->high=((uint32_t)end)+1;
tp->range_start=start; tp->range_start=start;
tp->range_stop=end; tp->range_stop=end;
@ -117,15 +117,15 @@ static void turnports_init(turnports* tp, u16bits start, u16bits end) {
int i=0; int i=0;
for(i=0;i<start;i++) { for(i=0;i<start;i++) {
tp->status[i]=TPS_OUT_OF_RANGE; tp->status[i]=TPS_OUT_OF_RANGE;
tp->ports[i]=(u16bits)i; tp->ports[i]=(uint16_t)i;
} }
for(i=start;i<=end;i++) { for(i=start;i<=end;i++) {
tp->status[i]=(u32bits)i; tp->status[i]=(uint32_t)i;
tp->ports[i]=(u16bits)i; tp->ports[i]=(uint16_t)i;
} }
for(i=((int)end)+1;i<PORTS_SIZE;i++) { for(i=((int)end)+1;i<PORTS_SIZE;i++) {
tp->status[i]=TPS_OUT_OF_RANGE; tp->status[i]=TPS_OUT_OF_RANGE;
tp->ports[i]=(u16bits)i; tp->ports[i]=(uint16_t)i;
} }
turnports_randomize(tp); turnports_randomize(tp);
@ -135,7 +135,7 @@ static void turnports_init(turnports* tp, u16bits start, u16bits end) {
/////////////// FUNC /////////////////////////////////////// /////////////// FUNC ///////////////////////////////////////
turnports* turnports_create(super_memory_t *sm, u16bits start, u16bits end) { turnports* turnports_create(super_memory_t *sm, uint16_t start, uint16_t end) {
if(start>end) return NULL; if(start>end) return NULL;
@ -145,11 +145,11 @@ turnports* turnports_create(super_memory_t *sm, u16bits start, u16bits end) {
return ret; return ret;
} }
u16bits turnports_size(turnports* tp) { uint16_t turnports_size(turnports* tp) {
if(!tp) return 0; if(!tp) return 0;
else { else {
TURN_MUTEX_LOCK(&tp->mutex); TURN_MUTEX_LOCK(&tp->mutex);
u16bits ret = (u16bits)((tp->high-tp->low)); uint16_t ret = (uint16_t)((tp->high-tp->low));
TURN_MUTEX_UNLOCK(&tp->mutex); TURN_MUTEX_UNLOCK(&tp->mutex);
return ret; return ret;
} }
@ -170,7 +170,7 @@ int turnports_allocate(turnports* tp) {
return -1; return -1;
} }
int position=(u16bits)(tp->low & 0x0000FFFF); int position=(uint16_t)(tp->low & 0x0000FFFF);
port=(int)tp->ports[position]; port=(int)tp->ports[position];
if(port<(int)(tp->range_start) || port>((int)(tp->range_stop))) { if(port<(int)(tp->range_start) || port>((int)(tp->range_stop))) {
@ -196,10 +196,10 @@ int turnports_allocate(turnports* tp) {
return port; return port;
} }
void turnports_release(turnports* tp, u16bits port) { void turnports_release(turnports* tp, uint16_t port) {
TURN_MUTEX_LOCK(&tp->mutex); TURN_MUTEX_LOCK(&tp->mutex);
if(tp && port>=tp->range_start && port<=tp->range_stop) { if(tp && port>=tp->range_start && port<=tp->range_stop) {
u16bits position=(u16bits)(tp->high & 0x0000FFFF); uint16_t position=(uint16_t)(tp->high & 0x0000FFFF);
if(is_taken(tp->status[port])) { if(is_taken(tp->status[port])) {
tp->status[port]=tp->high; tp->status[port]=tp->high;
tp->ports[position]=port; tp->ports[position]=port;
@ -209,12 +209,12 @@ void turnports_release(turnports* tp, u16bits port) {
TURN_MUTEX_UNLOCK(&tp->mutex); TURN_MUTEX_UNLOCK(&tp->mutex);
} }
int turnports_allocate_even(turnports* tp, int allocate_rtcp, u64bits *reservation_token) { int turnports_allocate_even(turnports* tp, int allocate_rtcp, uint64_t *reservation_token) {
if(tp) { if(tp) {
TURN_MUTEX_LOCK(&tp->mutex); TURN_MUTEX_LOCK(&tp->mutex);
u16bits size = turnports_size(tp); uint16_t size = turnports_size(tp);
if(size>1) { if(size>1) {
u16bits i=0; uint16_t i=0;
for(i=0;i<size;i++) { for(i=0;i<size;i++) {
int port=turnports_allocate(tp); int port=turnports_allocate(tp);
if(port & 0x00000001) { if(port & 0x00000001) {
@ -233,11 +233,11 @@ int turnports_allocate_even(turnports* tp, int allocate_rtcp, u64bits *reservati
tp->status[port]=TPS_TAKEN_EVEN; tp->status[port]=TPS_TAKEN_EVEN;
tp->status[rtcp_port]=TPS_TAKEN_ODD; tp->status[rtcp_port]=TPS_TAKEN_ODD;
if(reservation_token) { if(reservation_token) {
u16bits *v16=(u16bits*)reservation_token; uint16_t *v16=(uint16_t*)reservation_token;
u32bits *v32=(u32bits*)reservation_token; uint32_t *v32=(uint32_t*)reservation_token;
v16[0]=(u16bits)(tp->ports[(u16bits)(tp->low & 0x0000FFFF)]); v16[0]=(uint16_t)(tp->ports[(uint16_t)(tp->low & 0x0000FFFF)]);
v16[1]=(u16bits)(tp->ports[(u16bits)(tp->high & 0x0000FFFF)]); v16[1]=(uint16_t)(tp->ports[(uint16_t)(tp->high & 0x0000FFFF)]);
v32[1]=(u32bits)turn_random(); v32[1]=(uint32_t)turn_random();
} }
TURN_MUTEX_UNLOCK(&tp->mutex); TURN_MUTEX_UNLOCK(&tp->mutex);
return port; return port;
@ -251,7 +251,7 @@ int turnports_allocate_even(turnports* tp, int allocate_rtcp, u64bits *reservati
return -1; return -1;
} }
int turnports_is_allocated(turnports* tp, u16bits port) { int turnports_is_allocated(turnports* tp, uint16_t port) {
if(!tp) return 0; if(!tp) return 0;
else { else {
TURN_MUTEX_LOCK(&tp->mutex); TURN_MUTEX_LOCK(&tp->mutex);
@ -261,12 +261,12 @@ int turnports_is_allocated(turnports* tp, u16bits port) {
} }
} }
int turnports_is_available(turnports* tp, u16bits port) { int turnports_is_available(turnports* tp, uint16_t port) {
if(tp) { if(tp) {
TURN_MUTEX_LOCK(&tp->mutex); TURN_MUTEX_LOCK(&tp->mutex);
u32bits status = tp->status[port]; uint32_t status = tp->status[port];
if((status!=TPS_OUT_OF_RANGE) && !is_taken(status)) { if((status!=TPS_OUT_OF_RANGE) && !is_taken(status)) {
u16bits position=(u16bits)(status & 0x0000FFFF); uint16_t position=(uint16_t)(status & 0x0000FFFF);
if(tp->ports[position]==port) { if(tp->ports[position]==port) {
TURN_MUTEX_UNLOCK(&tp->mutex); TURN_MUTEX_UNLOCK(&tp->mutex);
return 1; return 1;
@ -282,8 +282,8 @@ int turnports_is_available(turnports* tp, u16bits port) {
struct _turnipports struct _turnipports
{ {
super_memory_t *sm; super_memory_t *sm;
u16bits start; uint16_t start;
u16bits end; uint16_t end;
ur_addr_map ip_to_turnports_udp; ur_addr_map ip_to_turnports_udp;
ur_addr_map ip_to_turnports_tcp; ur_addr_map ip_to_turnports_tcp;
TURN_MUTEX_DECLARE(mutex) TURN_MUTEX_DECLARE(mutex)
@ -291,7 +291,7 @@ struct _turnipports
////////////////////////////////////////////////// //////////////////////////////////////////////////
static ur_addr_map *get_map(turnipports *tp, u08bits transport) static ur_addr_map *get_map(turnipports *tp, uint8_t transport)
{ {
if(transport == STUN_ATTRIBUTE_TRANSPORT_TCP_VALUE) if(transport == STUN_ATTRIBUTE_TRANSPORT_TCP_VALUE)
return &(tp->ip_to_turnports_tcp); return &(tp->ip_to_turnports_tcp);
@ -301,7 +301,7 @@ static ur_addr_map *get_map(turnipports *tp, u08bits transport)
static turnipports* turnipports_singleton = NULL; static turnipports* turnipports_singleton = NULL;
turnipports* turnipports_create(super_memory_t *sm, u16bits start, u16bits end) turnipports* turnipports_create(super_memory_t *sm, uint16_t start, uint16_t end)
{ {
turnipports *ret = (turnipports*) allocate_super_memory_region(sm, sizeof(turnipports)); turnipports *ret = (turnipports*) allocate_super_memory_region(sm, sizeof(turnipports));
ret->sm = sm; ret->sm = sm;
@ -314,7 +314,7 @@ turnipports* turnipports_create(super_memory_t *sm, u16bits start, u16bits end)
return ret; return ret;
} }
static turnports* turnipports_add(turnipports* tp, u08bits transport, const ioa_addr *backend_addr) static turnports* turnipports_add(turnipports* tp, uint8_t transport, const ioa_addr *backend_addr)
{ {
ur_addr_map_value_type t = 0; ur_addr_map_value_type t = 0;
if (tp && backend_addr) { if (tp && backend_addr) {
@ -331,12 +331,12 @@ static turnports* turnipports_add(turnipports* tp, u08bits transport, const ioa_
return (turnports*) t; return (turnports*) t;
} }
void turnipports_add_ip(u08bits transport, const ioa_addr *backend_addr) void turnipports_add_ip(uint8_t transport, const ioa_addr *backend_addr)
{ {
turnipports_add(turnipports_singleton, transport, backend_addr); turnipports_add(turnipports_singleton, transport, backend_addr);
} }
int turnipports_allocate(turnipports* tp, u08bits transport, const ioa_addr *backend_addr) int turnipports_allocate(turnipports* tp, uint8_t transport, const ioa_addr *backend_addr)
{ {
int ret = -1; int ret = -1;
if (tp && backend_addr) { if (tp && backend_addr) {
@ -349,7 +349,7 @@ int turnipports_allocate(turnipports* tp, u08bits transport, const ioa_addr *bac
} }
int turnipports_allocate_even(turnipports* tp, const ioa_addr *backend_addr, int allocate_rtcp, int turnipports_allocate_even(turnipports* tp, const ioa_addr *backend_addr, int allocate_rtcp,
u64bits *reservation_token) uint64_t *reservation_token)
{ {
int ret = -1; int ret = -1;
if (tp && backend_addr) { if (tp && backend_addr) {
@ -361,7 +361,7 @@ int turnipports_allocate_even(turnipports* tp, const ioa_addr *backend_addr, int
return ret; return ret;
} }
void turnipports_release(turnipports* tp, u08bits transport, const ioa_addr *socket_addr) void turnipports_release(turnipports* tp, uint8_t transport, const ioa_addr *socket_addr)
{ {
if (tp && socket_addr) { if (tp && socket_addr) {
ioa_addr ba; ioa_addr ba;
@ -376,7 +376,7 @@ void turnipports_release(turnipports* tp, u08bits transport, const ioa_addr *soc
} }
} }
int turnipports_is_allocated(turnipports* tp, u08bits transport, const ioa_addr *backend_addr, u16bits port) int turnipports_is_allocated(turnipports* tp, uint8_t transport, const ioa_addr *backend_addr, uint16_t port)
{ {
int ret = 0; int ret = 0;
if (tp && backend_addr) { if (tp && backend_addr) {
@ -393,7 +393,7 @@ int turnipports_is_allocated(turnipports* tp, u08bits transport, const ioa_addr
return ret; return ret;
} }
int turnipports_is_available(turnipports* tp, u08bits transport, const ioa_addr *backend_addr, u16bits port) int turnipports_is_available(turnipports* tp, uint8_t transport, const ioa_addr *backend_addr, uint16_t port)
{ {
int ret = 0; int ret = 0;
if (tp && backend_addr) { if (tp && backend_addr) {

View File

@ -51,18 +51,18 @@ typedef struct _turnipports turnipports;
////////////////////////////////////////////////// //////////////////////////////////////////////////
turnipports* turnipports_create(super_memory_t *sm, u16bits start, u16bits end); turnipports* turnipports_create(super_memory_t *sm, uint16_t start, uint16_t end);
void turnipports_add_ip(u08bits transport, const ioa_addr *backend_addr); void turnipports_add_ip(uint8_t transport, const ioa_addr *backend_addr);
int turnipports_allocate(turnipports* tp, u08bits transport, const ioa_addr *backend_addr); int turnipports_allocate(turnipports* tp, uint8_t transport, const ioa_addr *backend_addr);
int turnipports_allocate_even(turnipports* tp, const ioa_addr *backend_addr, int turnipports_allocate_even(turnipports* tp, const ioa_addr *backend_addr,
int allocate_rtcp, u64bits *reservation_token); int allocate_rtcp, uint64_t *reservation_token);
void turnipports_release(turnipports* tp, u08bits transport, const ioa_addr *socket_addr); void turnipports_release(turnipports* tp, uint8_t transport, const ioa_addr *socket_addr);
int turnipports_is_allocated(turnipports* tp, u08bits transport, const ioa_addr *backend_addr, u16bits port); int turnipports_is_allocated(turnipports* tp, uint8_t transport, const ioa_addr *backend_addr, uint16_t port);
int turnipports_is_available(turnipports* tp, u08bits transport, const ioa_addr *backend_addr, u16bits port); int turnipports_is_available(turnipports* tp, uint8_t transport, const ioa_addr *backend_addr, uint16_t port);
////////////////////////////////////////////////// //////////////////////////////////////////////////

View File

@ -299,7 +299,7 @@ void add_to_secrets_list(secrets_list_t *sl, const char* elem)
//////////////////////////////////////////// ////////////////////////////////////////////
static int get_auth_secrets(secrets_list_t *sl, u08bits *realm) static int get_auth_secrets(secrets_list_t *sl, uint8_t *realm)
{ {
int ret = -1; int ret = -1;
const turn_dbdriver_t * dbd = get_dbdriver(); const turn_dbdriver_t * dbd = get_dbdriver();
@ -398,7 +398,7 @@ static char *get_real_username(char *usname)
/* /*
* Password retrieval * Password retrieval
*/ */
int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *usname, u08bits *realm, hmackey_t key, ioa_network_buffer_handle nbh) int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, uint8_t *usname, uint8_t *realm, hmackey_t key, ioa_network_buffer_handle nbh)
{ {
int ret = -1; int ret = -1;
@ -413,7 +413,7 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
if(sar) { if(sar) {
int len = stun_attr_get_len(sar); int len = stun_attr_get_len(sar);
const u08bits *value = stun_attr_get_value(sar); const uint8_t *value = stun_attr_get_value(sar);
*out_oauth = 1; *out_oauth = 1;
@ -477,7 +477,7 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
} }
} }
if (decode_oauth_token((const u08bits *) server_name, &etoken,&okey, &dot) < 0) { if (decode_oauth_token((const uint8_t *) server_name, &etoken,&okey, &dot) < 0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot decode oauth token\n"); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot decode oauth token\n");
return -1; return -1;
} }
@ -548,7 +548,7 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
if(!turn_time_before(ts, ctime)) { if(!turn_time_before(ts, ctime)) {
u08bits hmac[MAXSHASIZE]; uint8_t hmac[MAXSHASIZE];
unsigned int hmac_len; unsigned int hmac_len;
password_t pwdtmp; password_t pwdtmp;
@ -577,7 +577,7 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
const char* secret = get_secrets_list_elem(&sl,sll); const char* secret = get_secrets_list_elem(&sl,sll);
if(secret) { if(secret) {
if(stun_calculate_hmac(usname, strlen((char*)usname), (const u08bits*)secret, strlen(secret), hmac, &hmac_len, SHATYPE_DEFAULT)>=0) { if(stun_calculate_hmac(usname, strlen((char*)usname), (const uint8_t*)secret, strlen(secret), hmac, &hmac_len, SHATYPE_DEFAULT)>=0) {
size_t pwd_length = 0; size_t pwd_length = 0;
char *pwd = base64_encode(hmac,hmac_len,&pwd_length); char *pwd = base64_encode(hmac,hmac_len,&pwd_length);
@ -585,7 +585,7 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
if(pwd_length<1) { if(pwd_length<1) {
free(pwd); free(pwd);
} else { } else {
if(stun_produce_integrity_key_str((u08bits*)usname, realm, (u08bits*)pwd, key, SHATYPE_DEFAULT)>=0) { if(stun_produce_integrity_key_str((uint8_t*)usname, realm, (uint8_t*)pwd, key, SHATYPE_DEFAULT)>=0) {
if(stun_check_message_integrity_by_key_str(TURN_CREDENTIALS_LONG_TERM, if(stun_check_message_integrity_by_key_str(TURN_CREDENTIALS_LONG_TERM,
ioa_network_buffer_data(nbh), ioa_network_buffer_data(nbh),
@ -634,7 +634,7 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
return ret; return ret;
} }
u08bits *start_user_check(turnserver_id id, turn_credential_type ct, int in_oauth, int *out_oauth, u08bits *usname, u08bits *realm, get_username_resume_cb resume, ioa_net_data *in_buffer, u64bits ctxkey, int *postpone_reply) uint8_t *start_user_check(turnserver_id id, turn_credential_type ct, int in_oauth, int *out_oauth, uint8_t *usname, uint8_t *realm, get_username_resume_cb resume, ioa_net_data *in_buffer, uint64_t ctxkey, int *postpone_reply)
{ {
*postpone_reply = 1; *postpone_reply = 1;
@ -656,11 +656,11 @@ u08bits *start_user_check(turnserver_id id, turn_credential_type ct, int in_oaut
return NULL; return NULL;
} }
int check_new_allocation_quota(u08bits *user, int oauth, u08bits *realm) int check_new_allocation_quota(uint8_t *user, int oauth, uint8_t *realm)
{ {
int ret = 0; int ret = 0;
if (user || oauth) { if (user || oauth) {
u08bits *username = oauth ? (u08bits*)strdup("") : (u08bits*)get_real_username((char*)user); uint8_t *username = oauth ? (uint8_t*)strdup("") : (uint8_t*)get_real_username((char*)user);
realm_params_t *rp = get_realm((char*)realm); realm_params_t *rp = get_realm((char*)realm);
ur_string_map_lock(rp->status.alloc_counters); ur_string_map_lock(rp->status.alloc_counters);
if (rp->options.perf_options.total_quota && (rp->status.total_current_allocs >= rp->options.perf_options.total_quota)) { if (rp->options.perf_options.total_quota && (rp->status.total_current_allocs >= rp->options.perf_options.total_quota)) {
@ -689,10 +689,10 @@ int check_new_allocation_quota(u08bits *user, int oauth, u08bits *realm)
return ret; return ret;
} }
void release_allocation_quota(u08bits *user, int oauth, u08bits *realm) void release_allocation_quota(uint8_t *user, int oauth, uint8_t *realm)
{ {
if (user) { if (user) {
u08bits *username = oauth ? (u08bits*)strdup("") : (u08bits*)get_real_username((char*)user); uint8_t *username = oauth ? (uint8_t*)strdup("") : (uint8_t*)get_real_username((char*)user);
realm_params_t *rp = get_realm((char*)realm); realm_params_t *rp = get_realm((char*)realm);
ur_string_map_lock(rp->status.alloc_counters); ur_string_map_lock(rp->status.alloc_counters);
if(username[0]) { if(username[0]) {
@ -724,7 +724,7 @@ int add_static_user_account(char *user)
char *usname = (char*)malloc(sizeof(char)*(ulen+1)); char *usname = (char*)malloc(sizeof(char)*(ulen+1));
strncpy(usname,user,ulen); strncpy(usname,user,ulen);
usname[ulen]=0; usname[ulen]=0;
if(SASLprep((u08bits*)usname)<0) { if(SASLprep((uint8_t*)usname)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong user name: %s\n",user); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong user name: %s\n",user);
free(usname); free(usname);
return -1; return -1;
@ -744,7 +744,7 @@ int add_static_user_account(char *user)
} }
} else { } else {
//this is only for default realm //this is only for default realm
stun_produce_integrity_key_str((u08bits*)usname, (u08bits*)get_realm(NULL)->options.name, (u08bits*)s, *key, SHATYPE_DEFAULT); stun_produce_integrity_key_str((uint8_t*)usname, (uint8_t*)get_realm(NULL)->options.name, (uint8_t*)s, *key, SHATYPE_DEFAULT);
} }
{ {
ur_string_map_lock(turn_params.default_users_db.ram_db.static_accounts); ur_string_map_lock(turn_params.default_users_db.ram_db.static_accounts);
@ -762,7 +762,7 @@ int add_static_user_account(char *user)
////////////////// Admin ///////////////////////// ////////////////// Admin /////////////////////////
static int list_users(u08bits *realm, int is_admin) static int list_users(uint8_t *realm, int is_admin)
{ {
const turn_dbdriver_t * dbd = get_dbdriver(); const turn_dbdriver_t * dbd = get_dbdriver();
if (dbd) { if (dbd) {
@ -780,7 +780,7 @@ static int list_users(u08bits *realm, int is_admin)
return 0; return 0;
} }
static int show_secret(u08bits *realm) static int show_secret(uint8_t *realm)
{ {
const turn_dbdriver_t * dbd = get_dbdriver(); const turn_dbdriver_t * dbd = get_dbdriver();
if (dbd && dbd->list_secrets) { if (dbd && dbd->list_secrets) {
@ -790,7 +790,7 @@ static int show_secret(u08bits *realm)
return 0; return 0;
} }
static int del_secret(u08bits *secret, u08bits *realm) { static int del_secret(uint8_t *secret, uint8_t *realm) {
must_set_admin_realm(realm); must_set_admin_realm(realm);
@ -802,7 +802,7 @@ static int del_secret(u08bits *secret, u08bits *realm) {
return 0; return 0;
} }
static int set_secret(u08bits *secret, u08bits *realm) { static int set_secret(uint8_t *secret, uint8_t *realm) {
if(!secret || (secret[0]==0)) if(!secret || (secret[0]==0))
return 0; return 0;
@ -819,9 +819,9 @@ static int set_secret(u08bits *secret, u08bits *realm) {
return 0; return 0;
} }
static int add_origin(u08bits *origin0, u08bits *realm) static int add_origin(uint8_t *origin0, uint8_t *realm)
{ {
u08bits origin[STUN_MAX_ORIGIN_SIZE+1]; uint8_t origin[STUN_MAX_ORIGIN_SIZE+1];
get_canonic_origin((const char *)origin0, (char *)origin, sizeof(origin)-1); get_canonic_origin((const char *)origin0, (char *)origin, sizeof(origin)-1);
@ -833,9 +833,9 @@ static int add_origin(u08bits *origin0, u08bits *realm)
return 0; return 0;
} }
static int del_origin(u08bits *origin0) static int del_origin(uint8_t *origin0)
{ {
u08bits origin[STUN_MAX_ORIGIN_SIZE+1]; uint8_t origin[STUN_MAX_ORIGIN_SIZE+1];
get_canonic_origin((const char *)origin0, (char *)origin, sizeof(origin)-1); get_canonic_origin((const char *)origin0, (char *)origin, sizeof(origin)-1);
@ -847,7 +847,7 @@ static int del_origin(u08bits *origin0)
return 0; return 0;
} }
static int list_origins(u08bits *realm) static int list_origins(uint8_t *realm)
{ {
const turn_dbdriver_t * dbd = get_dbdriver(); const turn_dbdriver_t * dbd = get_dbdriver();
if (dbd && dbd->list_origins) { if (dbd && dbd->list_origins) {
@ -857,7 +857,7 @@ static int list_origins(u08bits *realm)
return 0; return 0;
} }
static int set_realm_option_one(u08bits *realm, unsigned long value, const char* opt) static int set_realm_option_one(uint8_t *realm, unsigned long value, const char* opt)
{ {
if(value == (unsigned long)-1) if(value == (unsigned long)-1)
return 0; return 0;
@ -870,7 +870,7 @@ static int set_realm_option_one(u08bits *realm, unsigned long value, const char*
return 0; return 0;
} }
static int set_realm_option(u08bits *realm, perf_options_t *po) static int set_realm_option(uint8_t *realm, perf_options_t *po)
{ {
set_realm_option_one(realm,(unsigned long)po->max_bps,"max-bps"); set_realm_option_one(realm,(unsigned long)po->max_bps,"max-bps");
set_realm_option_one(realm,(unsigned long)po->user_quota,"user-quota"); set_realm_option_one(realm,(unsigned long)po->user_quota,"user-quota");
@ -878,7 +878,7 @@ static int set_realm_option(u08bits *realm, perf_options_t *po)
return 0; return 0;
} }
static int list_realm_options(u08bits *realm) static int list_realm_options(uint8_t *realm)
{ {
const turn_dbdriver_t * dbd = get_dbdriver(); const turn_dbdriver_t * dbd = get_dbdriver();
if (dbd && dbd->list_realm_options) { if (dbd && dbd->list_realm_options) {
@ -888,7 +888,7 @@ static int list_realm_options(u08bits *realm)
return 0; return 0;
} }
int adminuser(u08bits *user, u08bits *realm, u08bits *pwd, u08bits *secret, u08bits *origin, TURNADMIN_COMMAND_TYPE ct, perf_options_t *po, int is_admin) int adminuser(uint8_t *user, uint8_t *realm, uint8_t *pwd, uint8_t *secret, uint8_t *origin, TURNADMIN_COMMAND_TYPE ct, perf_options_t *po, int is_admin)
{ {
hmackey_t key; hmackey_t key;
char skey[sizeof(hmackey_t) * 2 + 1]; char skey[sizeof(hmackey_t) * 2 + 1];
@ -1021,7 +1021,7 @@ void run_db_test(void)
printf("DB TEST 2:\n"); printf("DB TEST 2:\n");
oauth_key_data_raw key_; oauth_key_data_raw key_;
oauth_key_data_raw *key=&key_; oauth_key_data_raw *key=&key_;
dbd->get_oauth_key((const u08bits*)"north",key); dbd->get_oauth_key((const uint8_t*)"north",key);
printf(" kid=%s, ikm_key=%s, timestamp=%llu, lifetime=%lu, as_rs_alg=%s\n", printf(" kid=%s, ikm_key=%s, timestamp=%llu, lifetime=%lu, as_rs_alg=%s\n",
key->kid, key->ikm_key, (unsigned long long)key->timestamp, (unsigned long)key->lifetime, key->as_rs_alg); key->kid, key->ikm_key, (unsigned long long)key->timestamp, (unsigned long)key->lifetime, key->as_rs_alg);
@ -1032,22 +1032,22 @@ void run_db_test(void)
STRCPY(key->kid,"kid"); STRCPY(key->kid,"kid");
key->timestamp = 123; key->timestamp = 123;
key->lifetime = 456; key->lifetime = 456;
dbd->del_oauth_key((const u08bits*)"kid"); dbd->del_oauth_key((const uint8_t*)"kid");
dbd->set_oauth_key(key); dbd->set_oauth_key(key);
dbd->list_oauth_keys(); dbd->list_oauth_keys();
printf("DB TEST 4:\n"); printf("DB TEST 4:\n");
dbd->get_oauth_key((const u08bits*)"kid",key); dbd->get_oauth_key((const uint8_t*)"kid",key);
printf(" kid=%s, ikm_key=%s, timestamp=%llu, lifetime=%lu, as_rs_alg=%s\n", printf(" kid=%s, ikm_key=%s, timestamp=%llu, lifetime=%lu, as_rs_alg=%s\n",
key->kid, key->ikm_key, (unsigned long long)key->timestamp, (unsigned long)key->lifetime, key->as_rs_alg); key->kid, key->ikm_key, (unsigned long long)key->timestamp, (unsigned long)key->lifetime, key->as_rs_alg);
printf("DB TEST 5:\n"); printf("DB TEST 5:\n");
dbd->del_oauth_key((const u08bits*)"kid"); dbd->del_oauth_key((const uint8_t*)"kid");
dbd->list_oauth_keys(); dbd->list_oauth_keys();
printf("DB TEST 6:\n"); printf("DB TEST 6:\n");
dbd->get_oauth_key((const u08bits*)"north",key); dbd->get_oauth_key((const uint8_t*)"north",key);
oauth_key_data oakd; oauth_key_data oakd;
convert_oauth_key_data_raw(key, &oakd); convert_oauth_key_data_raw(key, &oakd);
@ -1219,14 +1219,14 @@ int add_ip_list_range(const char * range0, const char * realm, ip_range_list_t *
ioa_addr min, max; ioa_addr min, max;
if (make_ioa_addr((const u08bits*) range, 0, &min) < 0) { if (make_ioa_addr((const uint8_t*) range, 0, &min) < 0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong address format: %s\n", range); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong address format: %s\n", range);
free(range); free(range);
return -1; return -1;
} }
if (separator) { if (separator) {
if (make_ioa_addr((const u08bits*) separator + 1, 0, &max) < 0) { if (make_ioa_addr((const uint8_t*) separator + 1, 0, &max) < 0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong address format: %s\n", separator + 1); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong address format: %s\n", separator + 1);
free(range); free(range);
return -1; return -1;
@ -1264,14 +1264,14 @@ int check_ip_list_range(const char * range0)
ioa_addr min, max; ioa_addr min, max;
if (make_ioa_addr((const u08bits*) range, 0, &min) < 0) { if (make_ioa_addr((const uint8_t*) range, 0, &min) < 0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong address range format: %s\n", range); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong address range format: %s\n", range);
free(range); free(range);
return -1; return -1;
} }
if (separator) { if (separator) {
if (make_ioa_addr((const u08bits*) separator + 1, 0, &max) < 0) { if (make_ioa_addr((const uint8_t*) separator + 1, 0, &max) < 0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong address range format: %s\n", separator + 1); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong address range format: %s\n", separator + 1);
free(range); free(range);
return -1; return -1;

View File

@ -83,13 +83,13 @@ struct auth_message {
int in_oauth; int in_oauth;
int out_oauth; int out_oauth;
int max_session_time; int max_session_time;
u08bits username[STUN_MAX_USERNAME_SIZE + 1]; uint8_t username[STUN_MAX_USERNAME_SIZE + 1];
u08bits realm[STUN_MAX_REALM_SIZE + 1]; uint8_t realm[STUN_MAX_REALM_SIZE + 1];
hmackey_t key; hmackey_t key;
password_t pwd; password_t pwd;
get_username_resume_cb resume_func; get_username_resume_cb resume_func;
ioa_net_data in_buffer; ioa_net_data in_buffer;
u64bits ctxkey; uint64_t ctxkey;
int success; int success;
}; };
@ -185,10 +185,10 @@ void add_to_secrets_list(secrets_list_t *sl, const char* elem);
/////////// USER DB CHECK ////////////////// /////////// USER DB CHECK //////////////////
int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *uname, u08bits *realm, hmackey_t key, ioa_network_buffer_handle nbh); int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, uint8_t *uname, uint8_t *realm, hmackey_t key, ioa_network_buffer_handle nbh);
u08bits *start_user_check(turnserver_id id, turn_credential_type ct, int in_oauth, int *out_oauth, u08bits *uname, u08bits *realm, get_username_resume_cb resume, ioa_net_data *in_buffer, u64bits ctxkey, int *postpone_reply); uint8_t *start_user_check(turnserver_id id, turn_credential_type ct, int in_oauth, int *out_oauth, uint8_t *uname, uint8_t *realm, get_username_resume_cb resume, ioa_net_data *in_buffer, uint64_t ctxkey, int *postpone_reply);
int check_new_allocation_quota(u08bits *username, int oauth, u08bits *realm); int check_new_allocation_quota(uint8_t *username, int oauth, uint8_t *realm);
void release_allocation_quota(u08bits *username, int oauth, u08bits *realm); void release_allocation_quota(uint8_t *username, int oauth, uint8_t *realm);
/////////// Handle user DB ///////////////// /////////// Handle user DB /////////////////
@ -199,7 +199,7 @@ void release_allocation_quota(u08bits *username, int oauth, u08bits *realm);
void auth_ping(redis_context_handle rch); void auth_ping(redis_context_handle rch);
void reread_realms(void); void reread_realms(void);
int add_static_user_account(char *user); int add_static_user_account(char *user);
int adminuser(u08bits *user, u08bits *realm, u08bits *pwd, u08bits *secret, u08bits *origin, TURNADMIN_COMMAND_TYPE ct, perf_options_t* po, int is_admin); int adminuser(uint8_t *user, uint8_t *realm, uint8_t *pwd, uint8_t *secret, uint8_t *origin, TURNADMIN_COMMAND_TYPE ct, perf_options_t* po, int is_admin);
int add_ip_list_range(const char* range, const char* realm, ip_range_list_t * list); int add_ip_list_range(const char* range, const char* realm, ip_range_list_t * list);
int check_ip_list_range(const char* range); int check_ip_list_range(const char* range);

View File

@ -143,8 +143,8 @@ static int check_oauth(void) {
encoded_oauth_token etoken; encoded_oauth_token etoken;
bzero(&etoken,sizeof(etoken)); bzero(&etoken,sizeof(etoken));
if (encode_oauth_token((const u08bits *) server_name, &etoken, if (encode_oauth_token((const uint8_t *) server_name, &etoken,
&key, &ot, (const u08bits*)gcm_nonce) < 0) { &key, &ot, (const uint8_t*)gcm_nonce) < 0) {
fprintf(stderr, "%s: cannot encode oauth token\n", fprintf(stderr, "%s: cannot encode oauth token\n",
__FUNCTION__); __FUNCTION__);
return -1; return -1;
@ -154,7 +154,7 @@ static int check_oauth(void) {
print_field5769("encoded token",etoken.token,etoken.size); print_field5769("encoded token",etoken.token,etoken.size);
} }
if (decode_oauth_token((const u08bits *) server_name, &etoken, if (decode_oauth_token((const uint8_t *) server_name, &etoken,
&key, &dot) < 0) { &key, &dot) < 0) {
fprintf(stderr, "%s: cannot decode oauth token\n", fprintf(stderr, "%s: cannot decode oauth token\n",
__FUNCTION__); __FUNCTION__);
@ -235,7 +235,7 @@ int main(int argc, const char **argv)
"\x80\x28\x00\x04" "\x80\x28\x00\x04"
"\xe5\x7a\x3b\xcf"; "\xe5\x7a\x3b\xcf";
u08bits buf[sizeof(reqstc)]; uint8_t buf[sizeof(reqstc)];
memcpy(buf, reqstc, sizeof(reqstc)); memcpy(buf, reqstc, sizeof(reqstc));
{//fingerprintfs etc {//fingerprintfs etc
@ -252,9 +252,9 @@ int main(int argc, const char **argv)
} }
{//short-term credentials {//short-term credentials
u08bits uname[33]; uint8_t uname[33];
u08bits realm[33]; uint8_t realm[33];
u08bits upwd[33]; uint8_t upwd[33];
strcpy((char*) upwd, "VOkJxbRl1RmTxUk/WvJxBt"); strcpy((char*) upwd, "VOkJxbRl1RmTxUk/WvJxBt");
res = stun_check_message_integrity_str(TURN_CREDENTIALS_SHORT_TERM, buf, sizeof(reqstc) - 1, uname, realm, upwd, shatype); res = stun_check_message_integrity_str(TURN_CREDENTIALS_SHORT_TERM, buf, sizeof(reqstc) - 1, uname, realm, upwd, shatype);
@ -303,17 +303,17 @@ int main(int argc, const char **argv)
"\xf6\x70\x24\x65\x6d\xd6\x4a\x3e\x02\xb8\xe0\x71" "\xf6\x70\x24\x65\x6d\xd6\x4a\x3e\x02\xb8\xe0\x71"
"\x2e\x85\xc9\xa2\x8c\xa8\x96\x66"; "\x2e\x85\xc9\xa2\x8c\xa8\x96\x66";
u08bits user[] = "\xe3\x83\x9e\xe3\x83\x88\xe3\x83\xaa\xe3\x83\x83" uint8_t user[] = "\xe3\x83\x9e\xe3\x83\x88\xe3\x83\xaa\xe3\x83\x83"
"\xe3\x82\xaf\xe3\x82\xb9"; "\xe3\x82\xaf\xe3\x82\xb9";
u08bits realm[33]; uint8_t realm[33];
u08bits nonce[29]; uint8_t nonce[29];
u08bits upwd[33]; uint8_t upwd[33];
u08bits buf[sizeof(reqltc)]; uint8_t buf[sizeof(reqltc)];
memcpy(buf, reqltc, sizeof(reqltc)); memcpy(buf, reqltc, sizeof(reqltc));
u08bits uname[sizeof(user)]; uint8_t uname[sizeof(user)];
memcpy(uname, user, sizeof(user)); memcpy(uname, user, sizeof(user));
strcpy((char*) realm, "example.org"); strcpy((char*) realm, "example.org");
@ -338,13 +338,13 @@ int main(int argc, const char **argv)
{ //encoding test { //encoding test
printf("RFC 5769 message encoding test result: "); printf("RFC 5769 message encoding test result: ");
size_t len = 0; size_t len = 0;
u16bits message_type = STUN_METHOD_BINDING; uint16_t message_type = STUN_METHOD_BINDING;
stun_tid tid; stun_tid tid;
u16bits *buf16 = (u16bits*)buf; uint16_t *buf16 = (uint16_t*)buf;
u32bits *buf32 = (u32bits*)buf; uint32_t *buf32 = (uint32_t*)buf;
memcpy(tid.tsx_id,"\x78\xad\x34\x33\xc6\xad\x72\xc0\x29\xda\x41\x2e",12); memcpy(tid.tsx_id,"\x78\xad\x34\x33\xc6\xad\x72\xc0\x29\xda\x41\x2e",12);
stun_init_buffer_str(buf,&len); stun_init_buffer_str(buf,&len);
message_type &= (u16bits)(0x3FFF); message_type &= (uint16_t)(0x3FFF);
buf16[0]=nswap16(message_type); buf16[0]=nswap16(message_type);
buf16[1]=0; buf16[1]=0;
buf32[1]=nswap32(STUN_MAGIC_COOKIE); buf32[1]=nswap32(STUN_MAGIC_COOKIE);
@ -363,7 +363,7 @@ int main(int argc, const char **argv)
int cols = 4; int cols = 4;
for(line = 0;line<lines;line++) { for(line = 0;line<lines;line++) {
for(col = 0; col<cols; col++) { for(col = 0; col<cols; col++) {
u08bits c = buf[line*4+col]; uint8_t c = buf[line*4+col];
printf(" %2x",(int)c); printf(" %2x",(int)c);
} }
printf("\n"); printf("\n");
@ -403,7 +403,7 @@ int main(int argc, const char **argv)
"\x80\x28\x00\x04" "\x80\x28\x00\x04"
"\xc0\x7d\x4c\x96"; "\xc0\x7d\x4c\x96";
u08bits buf[sizeof(respv4)]; uint8_t buf[sizeof(respv4)];
memcpy(buf, respv4, sizeof(respv4)); memcpy(buf, respv4, sizeof(respv4));
{//fingerprintfs etc {//fingerprintfs etc
@ -420,9 +420,9 @@ int main(int argc, const char **argv)
} }
{//short-term credentials {//short-term credentials
u08bits uname[33]; uint8_t uname[33];
u08bits realm[33]; uint8_t realm[33];
u08bits upwd[33]; uint8_t upwd[33];
strcpy((char*) upwd, "VOkJxbRl1RmTxUk/WvJxBt"); strcpy((char*) upwd, "VOkJxbRl1RmTxUk/WvJxBt");
res = stun_check_message_integrity_str(TURN_CREDENTIALS_SHORT_TERM, buf, sizeof(respv4) - 1, uname, realm, upwd, shatype); res = stun_check_message_integrity_str(TURN_CREDENTIALS_SHORT_TERM, buf, sizeof(respv4) - 1, uname, realm, upwd, shatype);
@ -465,7 +465,7 @@ int main(int argc, const char **argv)
exit(-1); exit(-1);
} }
make_ioa_addr((const u08bits*)"192.0.2.1", 32853, &addr4_test); make_ioa_addr((const uint8_t*)"192.0.2.1", 32853, &addr4_test);
if(addr_eq(&addr4,&addr4_test)) { if(addr_eq(&addr4,&addr4_test)) {
printf("success\n"); printf("success\n");
} else { } else {
@ -491,7 +491,7 @@ int main(int argc, const char **argv)
"\x80\x28\x00\x04" "\x80\x28\x00\x04"
"\xc8\xfb\x0b\x4c"; "\xc8\xfb\x0b\x4c";
u08bits buf[sizeof(respv6)]; uint8_t buf[sizeof(respv6)];
{ //decoding test { //decoding test
memcpy(buf, respv6, sizeof(respv6)); memcpy(buf, respv6, sizeof(respv6));
@ -508,9 +508,9 @@ int main(int argc, const char **argv)
} }
{//short-term credentials test {//short-term credentials test
u08bits uname[33]; uint8_t uname[33];
u08bits realm[33]; uint8_t realm[33];
u08bits upwd[33]; uint8_t upwd[33];
strcpy((char*) upwd, "VOkJxbRl1RmTxUk/WvJxBt"); strcpy((char*) upwd, "VOkJxbRl1RmTxUk/WvJxBt");
res = stun_check_message_integrity_str(TURN_CREDENTIALS_SHORT_TERM, buf, sizeof(respv6) - 1, uname, realm, upwd, shatype); res = stun_check_message_integrity_str(TURN_CREDENTIALS_SHORT_TERM, buf, sizeof(respv6) - 1, uname, realm, upwd, shatype);
@ -554,7 +554,7 @@ int main(int argc, const char **argv)
exit(-1); exit(-1);
} }
make_ioa_addr((const u08bits*) "2001:db8:1234:5678:11:2233:4455:6677", 32853, &addr6_test); make_ioa_addr((const uint8_t*) "2001:db8:1234:5678:11:2233:4455:6677", 32853, &addr6_test);
if (addr_eq(&addr6, &addr6_test)) { if (addr_eq(&addr6, &addr6_test)) {
printf("success\n"); printf("success\n");
} else { } else {

View File

@ -58,7 +58,7 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
int new_udp_fd = -1; int new_udp_fd = -1;
memset((void *) &remote_addr, 0, sizeof(ioa_addr)); memset((void *) &remote_addr, 0, sizeof(ioa_addr));
if (make_ioa_addr((const u08bits*) rip, rport, &remote_addr) < 0) if (make_ioa_addr((const uint8_t*) rip, rport, &remote_addr) < 0)
err(-1, NULL); err(-1, NULL);
if (udp_fd < 0) { if (udp_fd < 0) {
@ -90,7 +90,7 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
if (response_port >= 0) { if (response_port >= 0) {
turn::StunAttrResponsePort rpa; turn::StunAttrResponsePort rpa;
rpa.setResponsePort((u16bits)response_port); rpa.setResponsePort((uint16_t)response_port);
try { try {
req.addAttr(rpa); req.addAttr(rpa);
} catch(turn::WrongStunAttrFormatException &ex1) { } catch(turn::WrongStunAttrFormatException &ex1) {
@ -168,7 +168,7 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
{ {
int len = 0; int len = 0;
stun_buffer buf; stun_buffer buf;
u08bits *ptr = buf.buf; uint8_t *ptr = buf.buf;
int recvd = 0; int recvd = 0;
const int to_recv = sizeof(buf.buf); const int to_recv = sizeof(buf.buf);
@ -254,7 +254,7 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
stun_buffer buf; stun_buffer buf;
bzero(&remote_addr, sizeof(remote_addr)); bzero(&remote_addr, sizeof(remote_addr));
if (make_ioa_addr((const u08bits*) rip, rport, &remote_addr) < 0) if (make_ioa_addr((const uint8_t*) rip, rport, &remote_addr) < 0)
err(-1, NULL); err(-1, NULL);
if (udp_fd < 0) { if (udp_fd < 0) {
@ -283,13 +283,13 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
stun_prepare_binding_request(&buf); stun_prepare_binding_request(&buf);
if (response_port >= 0) { if (response_port >= 0) {
stun_attr_add_response_port_str((u08bits*) (buf.buf), (size_t*) &(buf.len), (u16bits) response_port); stun_attr_add_response_port_str((uint8_t*) (buf.buf), (size_t*) &(buf.len), (uint16_t) response_port);
} }
if (change_ip || change_port) { if (change_ip || change_port) {
stun_attr_add_change_request_str((u08bits*) buf.buf, (size_t*) &(buf.len), change_ip, change_port); stun_attr_add_change_request_str((uint8_t*) buf.buf, (size_t*) &(buf.len), change_ip, change_port);
} }
if (padding) { if (padding) {
if(stun_attr_add_padding_str((u08bits*) buf.buf, (size_t*) &(buf.len), 1500)<0) { if(stun_attr_add_padding_str((uint8_t*) buf.buf, (size_t*) &(buf.len), 1500)<0) {
printf("%s: ERROR: Cannot add padding\n",__FUNCTION__); printf("%s: ERROR: Cannot add padding\n",__FUNCTION__);
} }
} }
@ -323,7 +323,7 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
{ {
int len = 0; int len = 0;
u08bits *ptr = buf.buf; uint8_t *ptr = buf.buf;
int recvd = 0; int recvd = 0;
const int to_recv = sizeof(buf.buf); const int to_recv = sizeof(buf.buf);
@ -358,11 +358,11 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
printf("\n========================================\n"); printf("\n========================================\n");
printf("RFC 5780 response %d\n",++counter); printf("RFC 5780 response %d\n",++counter);
ioa_addr other_addr; ioa_addr other_addr;
stun_attr_get_addr_str((u08bits *) buf.buf, (size_t) buf.len, sar, &other_addr, NULL); stun_attr_get_addr_str((uint8_t *) buf.buf, (size_t) buf.len, sar, &other_addr, NULL);
sar = stun_attr_get_first_by_type_str(buf.buf, buf.len, STUN_ATTRIBUTE_RESPONSE_ORIGIN); sar = stun_attr_get_first_by_type_str(buf.buf, buf.len, STUN_ATTRIBUTE_RESPONSE_ORIGIN);
if (sar) { if (sar) {
ioa_addr response_origin; ioa_addr response_origin;
stun_attr_get_addr_str((u08bits *) buf.buf, (size_t) buf.len, sar, &response_origin, NULL); stun_attr_get_addr_str((uint8_t *) buf.buf, (size_t) buf.len, sar, &response_origin, NULL);
addr_debug_print(1, &response_origin, "Response origin: "); addr_debug_print(1, &response_origin, "Response origin: ");
} }
addr_debug_print(1, &other_addr, "Other addr: "); addr_debug_print(1, &other_addr, "Other addr: ");
@ -377,7 +377,7 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
} }
} else { } else {
int err_code = 0; int err_code = 0;
u08bits err_msg[1025] = "\0"; uint8_t err_msg[1025] = "\0";
size_t err_msg_size = sizeof(err_msg); size_t err_msg_size = sizeof(err_msg);
if (stun_is_error_response(&buf, &err_code, err_msg, err_msg_size)) { if (stun_is_error_response(&buf, &err_code, err_msg, err_msg_size)) {
printf("The response is an error %d (%s)\n", err_code, (char*) err_msg); printf("The response is an error %d (%s)\n", err_code, (char*) err_msg);
@ -445,7 +445,7 @@ int main(int argc, char **argv)
addr_set_any(&real_local_addr); addr_set_any(&real_local_addr);
if(local_addr[0]) { if(local_addr[0]) {
if(make_ioa_addr((const u08bits*)local_addr, 0, &real_local_addr)<0) { if(make_ioa_addr((const uint8_t*)local_addr, 0, &real_local_addr)<0) {
err(-1,NULL); err(-1,NULL);
} }
} }

View File

@ -60,7 +60,7 @@ ioa_addr peer_addr;
int no_rtcp = 0; int no_rtcp = 0;
int default_address_family = STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_DEFAULT; int default_address_family = STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_DEFAULT;
int dont_fragment = 0; int dont_fragment = 0;
u08bits g_uname[STUN_MAX_USERNAME_SIZE+1]; uint8_t g_uname[STUN_MAX_USERNAME_SIZE+1];
password_t g_upwd; password_t g_upwd;
char g_auth_secret[1025]="\0"; char g_auth_secret[1025]="\0";
int g_use_auth_secret_with_timestamp = 0; int g_use_auth_secret_with_timestamp = 0;
@ -73,7 +73,7 @@ char pkey_file[1025]="";
SSL_CTX *root_tls_ctx[32]; SSL_CTX *root_tls_ctx[32];
int root_tls_ctx_num = 0; int root_tls_ctx_num = 0;
u08bits relay_transport = STUN_ATTRIBUTE_TRANSPORT_UDP_VALUE; uint8_t relay_transport = STUN_ATTRIBUTE_TRANSPORT_UDP_VALUE;
unsigned char client_ifname[1025] = ""; unsigned char client_ifname[1025] = "";
int passive_tcp = 0; int passive_tcp = 0;
int mandatory_channel_padding = 0; int mandatory_channel_padding = 0;
@ -389,7 +389,7 @@ int main(int argc, char **argv)
STRCPY(g_uname,new_uname); STRCPY(g_uname,new_uname);
} }
{ {
u08bits hmac[MAXSHASIZE]; uint8_t hmac[MAXSHASIZE];
unsigned int hmac_len; unsigned int hmac_len;
switch(shatype) { switch(shatype) {
@ -408,7 +408,7 @@ int main(int argc, char **argv)
hmac[0]=0; hmac[0]=0;
if(stun_calculate_hmac(g_uname, strlen((char*)g_uname), (u08bits*)g_auth_secret, strlen(g_auth_secret), hmac, &hmac_len, shatype)>=0) { if(stun_calculate_hmac(g_uname, strlen((char*)g_uname), (uint8_t*)g_auth_secret, strlen(g_auth_secret), hmac, &hmac_len, shatype)>=0) {
size_t pwd_length = 0; size_t pwd_length = 0;
char *pwd = base64_encode(hmac,hmac_len,&pwd_length); char *pwd = base64_encode(hmac,hmac_len,&pwd_length);
@ -454,7 +454,7 @@ int main(int argc, char **argv)
if (!c2c) { if (!c2c) {
if (make_ioa_addr((const u08bits*) peer_address, peer_port, &peer_addr) < 0) { if (make_ioa_addr((const uint8_t*) peer_address, peer_port, &peer_addr) < 0) {
return -1; return -1;
} }

View File

@ -61,7 +61,7 @@ typedef enum _UR_STATE UR_STATE;
typedef struct typedef struct
{ {
/* RFC 6062 */ /* RFC 6062 */
u32bits cid; uint32_t cid;
ioa_addr tcp_data_local_addr; ioa_addr tcp_data_local_addr;
ioa_socket_raw tcp_data_fd; ioa_socket_raw tcp_data_fd;
SSL *tcp_data_ssl; SSL *tcp_data_ssl;
@ -79,11 +79,11 @@ typedef struct {
ioa_socket_raw fd; ioa_socket_raw fd;
SSL *ssl; SSL *ssl;
int broken; int broken;
u08bits nonce[STUN_MAX_NONCE_SIZE+1]; uint8_t nonce[STUN_MAX_NONCE_SIZE+1];
u08bits realm[STUN_MAX_REALM_SIZE+1]; uint8_t realm[STUN_MAX_REALM_SIZE+1];
/* oAuth */ /* oAuth */
int oauth; int oauth;
u08bits server_name[STUN_MAX_SERVER_NAME_SIZE+1]; uint8_t server_name[STUN_MAX_SERVER_NAME_SIZE+1];
hmackey_t key; hmackey_t key;
int key_set; int key_set;
int cok; int cok;
@ -106,26 +106,26 @@ typedef struct {
struct event *input_tcp_data_ev; struct event *input_tcp_data_ev;
stun_buffer in_buffer; stun_buffer in_buffer;
stun_buffer out_buffer; stun_buffer out_buffer;
u32bits refresh_time; uint32_t refresh_time;
u32bits finished_time; uint32_t finished_time;
//Msg counters: //Msg counters:
int tot_msgnum; int tot_msgnum;
int wmsgnum; int wmsgnum;
int rmsgnum; int rmsgnum;
int recvmsgnum; int recvmsgnum;
u32bits recvtimems; uint32_t recvtimems;
u32bits to_send_timems; uint32_t to_send_timems;
//Statistics: //Statistics:
size_t loss; size_t loss;
u64bits latency; uint64_t latency;
u64bits jitter; uint64_t jitter;
} app_ur_session; } app_ur_session;
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
typedef struct _message_info { typedef struct _message_info {
int msgnum; int msgnum;
u64bits mstime; uint64_t mstime;
} message_info; } message_info;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -223,7 +223,7 @@ static int clnet_connect(uint16_t clnet_remote_port, const char *remote_address,
connect_err = 0; connect_err = 0;
bzero(&remote_addr, sizeof(ioa_addr)); bzero(&remote_addr, sizeof(ioa_addr));
if (make_ioa_addr((const u08bits*) remote_address, clnet_remote_port, if (make_ioa_addr((const uint8_t*) remote_address, clnet_remote_port,
&remote_addr) < 0) &remote_addr) < 0)
return -1; return -1;
@ -250,11 +250,11 @@ static int clnet_connect(uint16_t clnet_remote_port, const char *remote_address,
if(clnet_info->is_peer && (*local_address==0)) { if(clnet_info->is_peer && (*local_address==0)) {
if(remote_addr.ss.sa_family == AF_INET6) { if(remote_addr.ss.sa_family == AF_INET6) {
if (make_ioa_addr((const u08bits*) "::1", 0, &local_addr) < 0) { if (make_ioa_addr((const uint8_t*) "::1", 0, &local_addr) < 0) {
return -1; return -1;
} }
} else { } else {
if (make_ioa_addr((const u08bits*) "127.0.0.1", 0, &local_addr) < 0) { if (make_ioa_addr((const uint8_t*) "127.0.0.1", 0, &local_addr) < 0) {
return -1; return -1;
} }
} }
@ -263,7 +263,7 @@ static int clnet_connect(uint16_t clnet_remote_port, const char *remote_address,
} else if (strlen(local_address) > 0) { } else if (strlen(local_address) > 0) {
if (make_ioa_addr((const u08bits*) local_address, 0, if (make_ioa_addr((const uint8_t*) local_address, 0,
&local_addr) < 0) &local_addr) < 0)
return -1; return -1;
@ -315,7 +315,7 @@ int read_mobility_ticket(app_ur_conn_info *clnet_info, stun_buffer *message)
if(s_mobile_id_sar) { if(s_mobile_id_sar) {
int smid_len = stun_attr_get_len(s_mobile_id_sar); int smid_len = stun_attr_get_len(s_mobile_id_sar);
if(smid_len>0 && (((size_t)smid_len)<sizeof(clnet_info->s_mobile_id))) { if(smid_len>0 && (((size_t)smid_len)<sizeof(clnet_info->s_mobile_id))) {
const u08bits* smid_val = stun_attr_get_value(s_mobile_id_sar); const uint8_t* smid_val = stun_attr_get_value(s_mobile_id_sar);
if(smid_val) { if(smid_val) {
bcopy(smid_val, clnet_info->s_mobile_id, (size_t)smid_len); bcopy(smid_val, clnet_info->s_mobile_id, (size_t)smid_len);
clnet_info->s_mobile_id[smid_len] = 0; clnet_info->s_mobile_id[smid_len] = 0;
@ -348,7 +348,7 @@ static int clnet_allocate(int verbose,
app_ur_conn_info *clnet_info, app_ur_conn_info *clnet_info,
ioa_addr *relay_addr, ioa_addr *relay_addr,
int af, int af,
char *turn_addr, u16bits *turn_port) { char *turn_addr, uint16_t *turn_port) {
int af_cycle = 0; int af_cycle = 0;
int reopen_socket = 0; int reopen_socket = 0;
@ -368,7 +368,7 @@ static int clnet_allocate(int verbose,
if(reopen_socket && !use_tcp) { if(reopen_socket && !use_tcp) {
socket_closesocket(clnet_info->fd); socket_closesocket(clnet_info->fd);
clnet_info->fd = -1; clnet_info->fd = -1;
if (clnet_connect(addr_get_port(&(clnet_info->remote_addr)), clnet_info->rsaddr, (u08bits*)clnet_info->ifname, clnet_info->lsaddr, if (clnet_connect(addr_get_port(&(clnet_info->remote_addr)), clnet_info->rsaddr, (uint8_t*)clnet_info->ifname, clnet_info->lsaddr,
verbose, clnet_info) < 0) { verbose, clnet_info) < 0) {
exit(-1); exit(-1);
} }
@ -394,7 +394,7 @@ static int clnet_allocate(int verbose,
} else if(rt) { } else if(rt) {
ep = -1; ep = -1;
} else if(!ep) { } else if(!ep) {
ep = (((u08bits)random()) % 2); ep = (((uint8_t)random()) % 2);
ep = ep-1; ep = ep-1;
} }
@ -448,7 +448,7 @@ static int clnet_allocate(int verbose,
} }
response_message.len = len; response_message.len = len;
int err_code = 0; int err_code = 0;
u08bits err_msg[129]; uint8_t err_msg[129];
if (stun_is_success_response(&response_message)) { if (stun_is_success_response(&response_message)) {
allocate_received = 1; allocate_received = 1;
allocate_finished = 1; allocate_finished = 1;
@ -542,8 +542,8 @@ static int clnet_allocate(int verbose,
if(stun_attr_get_first_addr(&response_message, STUN_ATTRIBUTE_ALTERNATE_SERVER, &alternate_server, NULL)==-1) { if(stun_attr_get_first_addr(&response_message, STUN_ATTRIBUTE_ALTERNATE_SERVER, &alternate_server, NULL)==-1) {
//error //error
} else if(turn_addr && turn_port){ } else if(turn_addr && turn_port){
addr_to_string_no_port(&alternate_server, (u08bits*)turn_addr); addr_to_string_no_port(&alternate_server, (uint8_t*)turn_addr);
*turn_port = (u16bits)addr_get_port(&alternate_server); *turn_port = (uint16_t)addr_get_port(&alternate_server);
} }
} }
@ -651,10 +651,10 @@ static int clnet_allocate(int verbose,
} }
if(dual_allocation && !mobility) { if(dual_allocation && !mobility) {
int t = ((u08bits)random())%3; int t = ((uint8_t)random())%3;
if(t) { if(t) {
u08bits field[4]; uint8_t field[4];
field[0] = (t==1) ? (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4 : (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6; field[0] = (t==1) ? (uint8_t)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4 : (uint8_t)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6;
field[1]=0; field[1]=0;
field[2]=0; field[2]=0;
field[3]=0; field[3]=0;
@ -709,7 +709,7 @@ static int clnet_allocate(int verbose,
} }
response_message.len = len; response_message.len = len;
int err_code = 0; int err_code = 0;
u08bits err_msg[129]; uint8_t err_msg[129];
if (stun_is_success_response(&response_message)) { if (stun_is_success_response(&response_message)) {
read_mobility_ticket(clnet_info, &response_message); read_mobility_ticket(clnet_info, &response_message);
refresh_received = 1; refresh_received = 1;
@ -753,7 +753,7 @@ static int turn_channel_bind(int verbose, uint16_t *chn,
int cb_sent = 0; int cb_sent = 0;
if(negative_test) { if(negative_test) {
*chn = stun_set_channel_bind_request(&request_message, peer_addr, (u16bits)random()); *chn = stun_set_channel_bind_request(&request_message, peer_addr, (uint16_t)random());
} else { } else {
*chn = stun_set_channel_bind_request(&request_message, peer_addr, *chn); *chn = stun_set_channel_bind_request(&request_message, peer_addr, *chn);
} }
@ -796,7 +796,7 @@ static int turn_channel_bind(int verbose, uint16_t *chn,
"cb response received: \n"); "cb response received: \n");
} }
int err_code = 0; int err_code = 0;
u08bits err_msg[129]; uint8_t err_msg[129];
if (stun_is_success_response(&response_message)) { if (stun_is_success_response(&response_message)) {
cb_received = 1; cb_received = 1;
@ -844,7 +844,7 @@ static int turn_create_permission(int verbose, app_ur_conn_info *clnet_info,
char saddr[129]="\0"; char saddr[129]="\0";
if (verbose) { if (verbose) {
addr_to_string(peer_addr,(u08bits*)saddr); addr_to_string(peer_addr,(uint8_t*)saddr);
} }
stun_buffer request_message, response_message; stun_buffer request_message, response_message;
@ -901,7 +901,7 @@ static int turn_create_permission(int verbose, app_ur_conn_info *clnet_info,
"cp response received: \n"); "cp response received: \n");
} }
int err_code = 0; int err_code = 0;
u08bits err_msg[129]; uint8_t err_msg[129];
if (stun_is_success_response(&response_message)) { if (stun_is_success_response(&response_message)) {
cp_received = 1; cp_received = 1;
@ -1031,18 +1031,18 @@ int start_connection(uint16_t clnet_remote_port0,
if(random() % 2 == 0) if(random() % 2 == 0)
sarbaddr = "2001::172"; sarbaddr = "2001::172";
ioa_addr arbaddr; ioa_addr arbaddr;
make_ioa_addr((const u08bits*)sarbaddr, 333, &arbaddr); make_ioa_addr((const uint8_t*)sarbaddr, 333, &arbaddr);
int i; int i;
int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS; int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS;
for(i=0;i<maxi;i++) { for(i=0;i<maxi;i++) {
u16bits chni=0; uint16_t chni=0;
int port = (unsigned short)random(); int port = (unsigned short)random();
if(port<1024) port += 1024; if(port<1024) port += 1024;
addr_set_port(&arbaddr, port); addr_set_port(&arbaddr, port);
u08bits *u=(u08bits*)&(arbaddr.s4.sin_addr); uint8_t *u=(uint8_t*)&(arbaddr.s4.sin_addr);
u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1; u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1;
//char sss[128]; //char sss[128];
//addr_to_string(&arbaddr,(u08bits*)sss); //addr_to_string(&arbaddr,(uint8_t*)sss);
//printf("%s: 111.111: %s\n",__FUNCTION__,sss); //printf("%s: 111.111: %s\n",__FUNCTION__,sss);
turn_channel_bind(verbose, &chni, clnet_info, &arbaddr); turn_channel_bind(verbose, &chni, clnet_info, &arbaddr);
} }
@ -1061,17 +1061,17 @@ int start_connection(uint16_t clnet_remote_port0,
if(random() % 2 == 0) if(random() % 2 == 0)
sarbaddr = "2001::172"; sarbaddr = "2001::172";
ioa_addr arbaddr[EXTRA_CREATE_PERMS]; ioa_addr arbaddr[EXTRA_CREATE_PERMS];
make_ioa_addr((const u08bits*)sarbaddr, 333, &arbaddr[0]); make_ioa_addr((const uint8_t*)sarbaddr, 333, &arbaddr[0]);
int i; int i;
int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS; int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS;
for(i=0;i<maxi;i++) { for(i=0;i<maxi;i++) {
if(i>0) if(i>0)
addr_cpy(&arbaddr[i],&arbaddr[0]); addr_cpy(&arbaddr[i],&arbaddr[0]);
addr_set_port(&arbaddr[i], (unsigned short)random()); addr_set_port(&arbaddr[i], (unsigned short)random());
u08bits *u=(u08bits*)&(arbaddr[i].s4.sin_addr); uint8_t *u=(uint8_t*)&(arbaddr[i].s4.sin_addr);
u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1; u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1;
//char sss[128]; //char sss[128];
//addr_to_string(&arbaddr[i],(u08bits*)sss); //addr_to_string(&arbaddr[i],(uint8_t*)sss);
//printf("%s: 111.111: %s\n",__FUNCTION__,sss); //printf("%s: 111.111: %s\n",__FUNCTION__,sss);
} }
turn_create_permission(verbose, clnet_info, arbaddr, maxi); turn_create_permission(verbose, clnet_info, arbaddr, maxi);
@ -1097,17 +1097,17 @@ int start_connection(uint16_t clnet_remote_port0,
if(random() % 2 == 0) if(random() % 2 == 0)
sarbaddr = "2001::172"; sarbaddr = "2001::172";
ioa_addr arbaddr[EXTRA_CREATE_PERMS]; ioa_addr arbaddr[EXTRA_CREATE_PERMS];
make_ioa_addr((const u08bits*)sarbaddr, 333, &arbaddr[0]); make_ioa_addr((const uint8_t*)sarbaddr, 333, &arbaddr[0]);
int i; int i;
int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS; int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS;
for(i=0;i<maxi;i++) { for(i=0;i<maxi;i++) {
if(i>0) if(i>0)
addr_cpy(&arbaddr[i],&arbaddr[0]); addr_cpy(&arbaddr[i],&arbaddr[0]);
addr_set_port(&arbaddr[i], (unsigned short)random()); addr_set_port(&arbaddr[i], (unsigned short)random());
u08bits *u=(u08bits*)&(arbaddr[i].s4.sin_addr); uint8_t *u=(uint8_t*)&(arbaddr[i].s4.sin_addr);
u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1; u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1;
//char sss[128]; //char sss[128];
//addr_to_string(&arbaddr,(u08bits*)sss); //addr_to_string(&arbaddr,(uint8_t*)sss);
//printf("%s: 111.111: %s\n",__FUNCTION__,sss); //printf("%s: 111.111: %s\n",__FUNCTION__,sss);
} }
turn_create_permission(verbose, clnet_info, arbaddr, maxi); turn_create_permission(verbose, clnet_info, arbaddr, maxi);
@ -1269,18 +1269,18 @@ int start_c2c_connection(uint16_t clnet_remote_port0,
if(random() % 2 == 0) if(random() % 2 == 0)
sarbaddr = "2001::172"; sarbaddr = "2001::172";
ioa_addr arbaddr; ioa_addr arbaddr;
make_ioa_addr((const u08bits*)sarbaddr, 333, &arbaddr); make_ioa_addr((const uint8_t*)sarbaddr, 333, &arbaddr);
int i; int i;
int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS; int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS;
for(i=0;i<maxi;i++) { for(i=0;i<maxi;i++) {
u16bits chni=0; uint16_t chni=0;
int port = (unsigned short)random(); int port = (unsigned short)random();
if(port<1024) port += 1024; if(port<1024) port += 1024;
addr_set_port(&arbaddr, port); addr_set_port(&arbaddr, port);
u08bits *u=(u08bits*)&(arbaddr.s4.sin_addr); uint8_t *u=(uint8_t*)&(arbaddr.s4.sin_addr);
u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1; u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1;
//char sss[128]; //char sss[128];
//addr_to_string(&arbaddr,(u08bits*)sss); //addr_to_string(&arbaddr,(uint8_t*)sss);
//printf("%s: 111.111: %s\n",__FUNCTION__,sss); //printf("%s: 111.111: %s\n",__FUNCTION__,sss);
turn_channel_bind(verbose, &chni, clnet_info1, &arbaddr); turn_channel_bind(verbose, &chni, clnet_info1, &arbaddr);
} }
@ -1293,17 +1293,17 @@ int start_c2c_connection(uint16_t clnet_remote_port0,
if(random() % 2 == 0) if(random() % 2 == 0)
sarbaddr = "2001::172"; sarbaddr = "2001::172";
ioa_addr arbaddr[EXTRA_CREATE_PERMS]; ioa_addr arbaddr[EXTRA_CREATE_PERMS];
make_ioa_addr((const u08bits*)sarbaddr, 333, &arbaddr[0]); make_ioa_addr((const uint8_t*)sarbaddr, 333, &arbaddr[0]);
int i; int i;
int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS; int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS;
for(i=0;i<maxi;i++) { for(i=0;i<maxi;i++) {
if(i>0) if(i>0)
addr_cpy(&arbaddr[i],&arbaddr[0]); addr_cpy(&arbaddr[i],&arbaddr[0]);
addr_set_port(&arbaddr[i], (unsigned short)random()); addr_set_port(&arbaddr[i], (unsigned short)random());
u08bits *u=(u08bits*)&(arbaddr[i].s4.sin_addr); uint8_t *u=(uint8_t*)&(arbaddr[i].s4.sin_addr);
u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1; u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1;
//char sss[128]; //char sss[128];
//addr_to_string(&arbaddr[i],(u08bits*)sss); //addr_to_string(&arbaddr[i],(uint8_t*)sss);
//printf("%s: 111.111: %s\n",__FUNCTION__,sss); //printf("%s: 111.111: %s\n",__FUNCTION__,sss);
} }
turn_create_permission(verbose, clnet_info1, arbaddr, maxi); turn_create_permission(verbose, clnet_info1, arbaddr, maxi);
@ -1336,15 +1336,15 @@ int start_c2c_connection(uint16_t clnet_remote_port0,
if(random() % 2 == 0) if(random() % 2 == 0)
sarbaddr = "2001::172"; sarbaddr = "2001::172";
ioa_addr arbaddr; ioa_addr arbaddr;
make_ioa_addr((const u08bits*)sarbaddr, 333, &arbaddr); make_ioa_addr((const uint8_t*)sarbaddr, 333, &arbaddr);
int i; int i;
int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS; int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS;
for(i=0;i<maxi;i++) { for(i=0;i<maxi;i++) {
addr_set_port(&arbaddr, (unsigned short)random()); addr_set_port(&arbaddr, (unsigned short)random());
u08bits *u=(u08bits*)&(arbaddr.s4.sin_addr); uint8_t *u=(uint8_t*)&(arbaddr.s4.sin_addr);
u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1; u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1;
//char sss[128]; //char sss[128];
//addr_to_string(&arbaddr,(u08bits*)sss); //addr_to_string(&arbaddr,(uint8_t*)sss);
//printf("%s: 111.111: %s\n",__FUNCTION__,sss); //printf("%s: 111.111: %s\n",__FUNCTION__,sss);
turn_create_permission(verbose, clnet_info1, &arbaddr, 1); turn_create_permission(verbose, clnet_info1, &arbaddr, 1);
} }
@ -1427,11 +1427,11 @@ static int turn_tcp_connection_bind(int verbose, app_ur_conn_info *clnet_info, a
{ {
int cb_sent = 0; int cb_sent = 0;
u32bits cid = atc->cid; uint32_t cid = atc->cid;
stun_init_request(STUN_METHOD_CONNECTION_BIND, &request_message); stun_init_request(STUN_METHOD_CONNECTION_BIND, &request_message);
stun_attr_add(&request_message, STUN_ATTRIBUTE_CONNECTION_ID, (const s08bits*)&cid,4); stun_attr_add(&request_message, STUN_ATTRIBUTE_CONNECTION_ID, (const char*)&cid,4);
add_origin(&request_message); add_origin(&request_message);
@ -1474,7 +1474,7 @@ static int turn_tcp_connection_bind(int verbose, app_ur_conn_info *clnet_info, a
"connect bind response received: \n"); "connect bind response received: \n");
} }
int err_code = 0; int err_code = 0;
u08bits err_msg[129]; uint8_t err_msg[129];
if (stun_is_success_response(&response_message)) { if (stun_is_success_response(&response_message)) {
if(clnet_info->nonce[0]) { if(clnet_info->nonce[0]) {
@ -1515,7 +1515,7 @@ static int turn_tcp_connection_bind(int verbose, app_ur_conn_info *clnet_info, a
return 0; return 0;
} }
void tcp_data_connect(app_ur_session *elem, u32bits cid) void tcp_data_connect(app_ur_session *elem, uint32_t cid)
{ {
int clnet_fd; int clnet_fd;
int connect_cycle = 0; int connect_cycle = 0;

View File

@ -71,7 +71,7 @@ int start_connection(uint16_t clnet_remote_port,
int turn_tcp_connect(int verbose, app_ur_conn_info *clnet_info, ioa_addr *peer_addr); int turn_tcp_connect(int verbose, app_ur_conn_info *clnet_info, ioa_addr *peer_addr);
void tcp_data_connect(app_ur_session *elem, u32bits cid); void tcp_data_connect(app_ur_session *elem, uint32_t cid);
int socket_connect(evutil_socket_t clnet_fd, ioa_addr *remote_addr, int *connect_err); int socket_connect(evutil_socket_t clnet_fd, ioa_addr *remote_addr, int *connect_err);

View File

@ -46,20 +46,20 @@ static int verbose_packets=0;
static size_t current_clients_number = 0; static size_t current_clients_number = 0;
static int start_full_timer=0; static int start_full_timer=0;
static u32bits tot_messages=0; static uint32_t tot_messages=0;
static u32bits tot_send_messages=0; static uint32_t tot_send_messages=0;
static u64bits tot_send_bytes = 0; static uint64_t tot_send_bytes = 0;
static u32bits tot_recv_messages=0; static uint32_t tot_recv_messages=0;
static u64bits tot_recv_bytes = 0; static uint64_t tot_recv_bytes = 0;
static u64bits tot_send_dropped = 0; static uint64_t tot_send_dropped = 0;
struct event_base* client_event_base=NULL; struct event_base* client_event_base=NULL;
static int client_write(app_ur_session *elem); static int client_write(app_ur_session *elem);
static int client_shutdown(app_ur_session *elem); static int client_shutdown(app_ur_session *elem);
static u64bits current_time = 0; static uint64_t current_time = 0;
static u64bits current_mstime = 0; static uint64_t current_mstime = 0;
static char buffer_to_send[65536]="\0"; static char buffer_to_send[65536]="\0";
@ -74,18 +74,18 @@ static app_ur_session** elems = NULL;
int RTP_PACKET_INTERVAL = 20; int RTP_PACKET_INTERVAL = 20;
static inline s64bits time_minus(u64bits t1, u64bits t2) { static inline int64_t time_minus(uint64_t t1, uint64_t t2) {
return ( (s64bits)t1 - (s64bits)t2 ); return ( (int64_t)t1 - (int64_t)t2 );
} }
static u64bits total_loss = 0; static uint64_t total_loss = 0;
static u64bits total_jitter = 0; static uint64_t total_jitter = 0;
static u64bits total_latency = 0; static uint64_t total_latency = 0;
static u64bits min_latency = 0xFFFFFFFF; static uint64_t min_latency = 0xFFFFFFFF;
static u64bits max_latency = 0; static uint64_t max_latency = 0;
static u64bits min_jitter = 0xFFFFFFFF; static uint64_t min_jitter = 0xFFFFFFFF;
static u64bits max_jitter = 0; static uint64_t max_jitter = 0;
static int show_statistics = 0; static int show_statistics = 0;
@ -93,7 +93,7 @@ static int show_statistics = 0;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
static void __turn_getMSTime(void) { static void __turn_getMSTime(void) {
static u64bits start_sec = 0; static uint64_t start_sec = 0;
struct timespec tp={0,0}; struct timespec tp={0,0};
#if defined(CLOCK_REALTIME) #if defined(CLOCK_REALTIME)
clock_gettime(CLOCK_REALTIME, &tp); clock_gettime(CLOCK_REALTIME, &tp);
@ -102,15 +102,15 @@ static void __turn_getMSTime(void) {
#endif #endif
if(!start_sec) if(!start_sec)
start_sec = tp.tv_sec; start_sec = tp.tv_sec;
if(current_time != (u64bits)((u64bits)(tp.tv_sec)-start_sec)) if(current_time != (uint64_t)((uint64_t)(tp.tv_sec)-start_sec))
show_statistics = 1; show_statistics = 1;
current_time = (u64bits)((u64bits)(tp.tv_sec)-start_sec); current_time = (uint64_t)((uint64_t)(tp.tv_sec)-start_sec);
current_mstime = (u64bits)((current_time * 1000) + (tp.tv_nsec/1000000)); current_mstime = (uint64_t)((current_time * 1000) + (tp.tv_nsec/1000000));
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
static int refresh_channel(app_ur_session* elem, u16bits method, uint32_t lt); static int refresh_channel(app_ur_session* elem, uint16_t method, uint32_t lt);
//////////////////////// SS //////////////////////////////////////// //////////////////////// SS ////////////////////////////////////////
@ -202,7 +202,7 @@ int send_buffer(app_ur_conn_info *clnet_info, stun_buffer* message, int data_con
while(np-->0) { while(np-->0) {
int pos = (int)((unsigned long)random()%(unsigned long)message->len); int pos = (int)((unsigned long)random()%(unsigned long)message->len);
int val = (int)((unsigned long)random()%256); int val = (int)((unsigned long)random()%256);
message->buf[pos]=(u08bits)val; message->buf[pos]=(uint8_t)val;
} }
} }
} }
@ -361,7 +361,7 @@ int recv_buffer(app_ur_conn_info *clnet_info, stun_buffer* message, int sync, in
int rc = 0; int rc = 0;
stun_tid tid; stun_tid tid;
u16bits method = 0; uint16_t method = 0;
if(request_message) { if(request_message) {
stun_tid_from_message(request_message, &tid); stun_tid_from_message(request_message, &tid);
@ -620,7 +620,7 @@ int recv_buffer(app_ur_conn_info *clnet_info, stun_buffer* message, int sync, in
if(request_message) { if(request_message) {
stun_tid recv_tid; stun_tid recv_tid;
u16bits recv_method = 0; uint16_t recv_method = 0;
stun_tid_from_message(message, &recv_tid); stun_tid_from_message(message, &recv_tid);
recv_method = stun_get_method(message); recv_method = stun_get_method(message);
@ -652,7 +652,7 @@ static int client_read(app_ur_session *elem, int is_tcp_data, app_tcp_conn_info
app_ur_conn_info *clnet_info = &(elem->pinfo); app_ur_conn_info *clnet_info = &(elem->pinfo);
int err_code = 0; int err_code = 0;
u08bits err_msg[129]; uint8_t err_msg[129];
int rc = 0; int rc = 0;
int applen = 0; int applen = 0;
@ -687,17 +687,17 @@ static int client_read(app_ur_session *elem, int is_tcp_data, app_tcp_conn_info
if((method == STUN_METHOD_CONNECTION_ATTEMPT)&& is_TCP_relay()) { if((method == STUN_METHOD_CONNECTION_ATTEMPT)&& is_TCP_relay()) {
stun_attr_ref sar = stun_attr_get_first(&(elem->in_buffer)); stun_attr_ref sar = stun_attr_get_first(&(elem->in_buffer));
u32bits cid = 0; uint32_t cid = 0;
while(sar) { while(sar) {
int attr_type = stun_attr_get_type(sar); int attr_type = stun_attr_get_type(sar);
if(attr_type == STUN_ATTRIBUTE_CONNECTION_ID) { if(attr_type == STUN_ATTRIBUTE_CONNECTION_ID) {
cid = *((const u32bits*)stun_attr_get_value(sar)); cid = *((const uint32_t*)stun_attr_get_value(sar));
break; break;
} }
sar = stun_attr_get_next_str(elem->in_buffer.buf,elem->in_buffer.len,sar); sar = stun_attr_get_next_str(elem->in_buffer.buf,elem->in_buffer.len,sar);
} }
if(negative_test) { if(negative_test) {
tcp_data_connect(elem,(u64bits)random()); tcp_data_connect(elem,(uint64_t)random());
} else { } else {
/* positive test */ /* positive test */
tcp_data_connect(elem,cid); tcp_data_connect(elem,cid);
@ -725,7 +725,7 @@ static int client_read(app_ur_session *elem, int is_tcp_data, app_tcp_conn_info
return rc; return rc;
} }
const u08bits* data = stun_attr_get_value(sar); const uint8_t* data = stun_attr_get_value(sar);
bcopy(data, &mi, sizeof(message_info)); bcopy(data, &mi, sizeof(message_info));
miset=1; miset=1;
@ -740,11 +740,11 @@ static int client_read(app_ur_session *elem, int is_tcp_data, app_tcp_conn_info
if(is_TCP_relay() && (stun_get_method(&(elem->in_buffer)) == STUN_METHOD_CONNECT)) { if(is_TCP_relay() && (stun_get_method(&(elem->in_buffer)) == STUN_METHOD_CONNECT)) {
stun_attr_ref sar = stun_attr_get_first(&(elem->in_buffer)); stun_attr_ref sar = stun_attr_get_first(&(elem->in_buffer));
u32bits cid = 0; uint32_t cid = 0;
while(sar) { while(sar) {
int attr_type = stun_attr_get_type(sar); int attr_type = stun_attr_get_type(sar);
if(attr_type == STUN_ATTRIBUTE_CONNECTION_ID) { if(attr_type == STUN_ATTRIBUTE_CONNECTION_ID) {
cid = *((const u32bits*)stun_attr_get_value(sar)); cid = *((const uint32_t*)stun_attr_get_value(sar));
break; break;
} }
sar = stun_attr_get_next_str(elem->in_buffer.buf,elem->in_buffer.len,sar); sar = stun_attr_get_next_str(elem->in_buffer.buf,elem->in_buffer.len,sar);
@ -801,14 +801,14 @@ static int client_read(app_ur_session *elem, int is_tcp_data, app_tcp_conn_info
if(mi.msgnum != elem->recvmsgnum+1) if(mi.msgnum != elem->recvmsgnum+1)
++(elem->loss); ++(elem->loss);
else { else {
u64bits clatency = (u64bits)time_minus(current_mstime,mi.mstime); uint64_t clatency = (uint64_t)time_minus(current_mstime,mi.mstime);
if(clatency>max_latency) if(clatency>max_latency)
max_latency = clatency; max_latency = clatency;
if(clatency<min_latency) if(clatency<min_latency)
min_latency = clatency; min_latency = clatency;
elem->latency += clatency; elem->latency += clatency;
if(elem->rmsgnum>0) { if(elem->rmsgnum>0) {
u64bits cjitter = abs((int)(current_mstime-elem->recvtimems)-RTP_PACKET_INTERVAL); uint64_t cjitter = abs((int)(current_mstime-elem->recvtimems)-RTP_PACKET_INTERVAL);
if(cjitter>max_jitter) if(cjitter>max_jitter)
max_jitter = cjitter; max_jitter = cjitter;
@ -1219,7 +1219,7 @@ static int start_c2c(const char *remote_address, int port,
return 0; return 0;
} }
static int refresh_channel(app_ur_session* elem, u16bits method, uint32_t lt) static int refresh_channel(app_ur_session* elem, uint16_t method, uint32_t lt)
{ {
stun_buffer message; stun_buffer message;
@ -1234,10 +1234,10 @@ static int refresh_channel(app_ur_session* elem, u16bits method, uint32_t lt)
stun_attr_add(&message, STUN_ATTRIBUTE_LIFETIME, (const char*) &lt, 4); stun_attr_add(&message, STUN_ATTRIBUTE_LIFETIME, (const char*) &lt, 4);
if(dual_allocation && !mobility) { if(dual_allocation && !mobility) {
int t = ((u08bits)random())%3; int t = ((uint8_t)random())%3;
if(t) { if(t) {
u08bits field[4]; uint8_t field[4];
field[0] = (t==1) ? (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4 : (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6; field[0] = (t==1) ? (uint8_t)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4 : (uint8_t)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6;
field[1]=0; field[1]=0;
field[2]=0; field[2]=0;
field[3]=0; field[3]=0;
@ -1391,7 +1391,7 @@ void start_mclient(const char *remote_address, int port,
elems = (app_ur_session**)malloc(sizeof(app_ur_session)*((mclient*2)+1)+sizeof(void*)); elems = (app_ur_session**)malloc(sizeof(app_ur_session)*((mclient*2)+1)+sizeof(void*));
__turn_getMSTime(); __turn_getMSTime();
u32bits stime = current_time; uint32_t stime = current_time;
memset(buffer_to_send, 7, clmessage_length); memset(buffer_to_send, 7, clmessage_length);
@ -1483,7 +1483,7 @@ void start_mclient(const char *remote_address, int port,
stime = current_time; stime = current_time;
if(is_TCP_relay()) { if(is_TCP_relay()) {
u64bits connect_wait_start_time = current_time; uint64_t connect_wait_start_time = current_time;
while(1) { while(1) {
int i = 0; int i = 0;
int completed = 0; int completed = 0;
@ -1525,7 +1525,7 @@ void start_mclient(const char *remote_address, int port,
stime = current_time; stime = current_time;
for(i=0;i<total_clients;i++) { for(i=0;i<total_clients;i++) {
elems[i]->to_send_timems = current_mstime + 1000 + ((u32bits)random())%5000; elems[i]->to_send_timems = current_mstime + 1000 + ((uint32_t)random())%5000;
} }
tot_messages = elems[0]->tot_msgnum * total_clients; tot_messages = elems[0]->tot_msgnum * total_clients;
@ -1602,7 +1602,7 @@ int add_integrity(app_ur_conn_info *clnet_info, stun_buffer *message)
if(oauth && clnet_info->oauth) { if(oauth && clnet_info->oauth) {
u16bits method = stun_get_method_str(message->buf, message->len); uint16_t method = stun_get_method_str(message->buf, message->len);
int cok = clnet_info->cok; int cok = clnet_info->cok;
@ -1613,7 +1613,7 @@ int add_integrity(app_ur_conn_info *clnet_info, stun_buffer *message)
clnet_info->cok = cok; clnet_info->cok = cok;
oauth_token otoken; oauth_token otoken;
encoded_oauth_token etoken; encoded_oauth_token etoken;
u08bits nonce[12]; uint8_t nonce[12];
RAND_bytes((unsigned char*)nonce,12); RAND_bytes((unsigned char*)nonce,12);
long halflifetime = OAUTH_SESSION_LIFETIME/2; long halflifetime = OAUTH_SESSION_LIFETIME/2;
long random_lifetime = 0; long random_lifetime = 0;
@ -1639,13 +1639,13 @@ int add_integrity(app_ur_conn_info *clnet_info, stun_buffer *message)
return -1; return -1;
} }
stun_attr_add_str(message->buf, (size_t*)&(message->len), STUN_ATTRIBUTE_OAUTH_ACCESS_TOKEN, stun_attr_add_str(message->buf, (size_t*)&(message->len), STUN_ATTRIBUTE_OAUTH_ACCESS_TOKEN,
(const u08bits*)etoken.token, (int)etoken.size); (const uint8_t*)etoken.token, (int)etoken.size);
bcopy(otoken.enc_block.mac_key,clnet_info->key,otoken.enc_block.key_length); bcopy(otoken.enc_block.mac_key,clnet_info->key,otoken.enc_block.key_length);
clnet_info->key_set = 1; clnet_info->key_set = 1;
} }
if(stun_attr_add_integrity_by_key_str(message->buf, (size_t*)&(message->len), (u08bits*)okey_array[cok].kid, if(stun_attr_add_integrity_by_key_str(message->buf, (size_t*)&(message->len), (uint8_t*)okey_array[cok].kid,
clnet_info->realm, clnet_info->key, clnet_info->nonce, shatype)<0) { clnet_info->realm, clnet_info->key, clnet_info->nonce, shatype)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO," Cannot add integrity to the message\n"); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO," Cannot add integrity to the message\n");
return -1; return -1;

View File

@ -60,7 +60,7 @@ extern ioa_addr peer_addr;
extern int no_rtcp; extern int no_rtcp;
extern int default_address_family; extern int default_address_family;
extern int dont_fragment; extern int dont_fragment;
extern u08bits g_uname[STUN_MAX_USERNAME_SIZE+1]; extern uint8_t g_uname[STUN_MAX_USERNAME_SIZE+1];
extern password_t g_upwd; extern password_t g_upwd;
extern char g_auth_secret[1025]; extern char g_auth_secret[1025];
extern int g_use_auth_secret_with_timestamp; extern int g_use_auth_secret_with_timestamp;
@ -68,7 +68,7 @@ extern int use_fingerprints;
extern SSL_CTX *root_tls_ctx[32]; extern SSL_CTX *root_tls_ctx[32];
extern int root_tls_ctx_num; extern int root_tls_ctx_num;
extern int RTP_PACKET_INTERVAL; extern int RTP_PACKET_INTERVAL;
extern u08bits relay_transport; extern uint8_t relay_transport;
extern unsigned char client_ifname[1025]; extern unsigned char client_ifname[1025];
extern struct event_base* client_event_base; extern struct event_base* client_event_base;
extern int passive_tcp; extern int passive_tcp;

View File

@ -75,7 +75,7 @@ public:
/** /**
* Iterator constructor: creates iterator on raw messagebuffer. * Iterator constructor: creates iterator on raw messagebuffer.
*/ */
StunAttrIterator(u08bits *buf, size_t sz) throw (WrongStunBufferFormatException) : StunAttrIterator(uint8_t *buf, size_t sz) throw (WrongStunBufferFormatException) :
_buf(buf), _sz(sz) { _buf(buf), _sz(sz) {
if(!stun_is_command_message_str(_buf, _sz)) { if(!stun_is_command_message_str(_buf, _sz)) {
throw WrongStunBufferFormatException(); throw WrongStunBufferFormatException();
@ -99,7 +99,7 @@ public:
* Iterator constructor: creates iterator over raw buffer, starting from first * Iterator constructor: creates iterator over raw buffer, starting from first
* location of an attribute of particular type. * location of an attribute of particular type.
*/ */
StunAttrIterator(u08bits *buf, size_t sz, u16bits attr_type) throw (WrongStunBufferFormatException) : StunAttrIterator(uint8_t *buf, size_t sz, uint16_t attr_type) throw (WrongStunBufferFormatException) :
_buf(buf), _sz(sz) { _buf(buf), _sz(sz) {
if(!stun_is_command_message_str(_buf, _sz)) { if(!stun_is_command_message_str(_buf, _sz)) {
throw WrongStunBufferFormatException(); throw WrongStunBufferFormatException();
@ -112,7 +112,7 @@ public:
* location of an attribute of particular type. * location of an attribute of particular type.
*/ */
template<class T> template<class T>
StunAttrIterator(T &msg, u16bits attr_type) throw (WrongStunBufferFormatException) : StunAttrIterator(T &msg, uint16_t attr_type) throw (WrongStunBufferFormatException) :
_buf(msg.getRawBuffer()), _sz(msg.getSize()) { _buf(msg.getRawBuffer()), _sz(msg.getSize()) {
if(!stun_is_command_message_str(_buf, _sz)) { if(!stun_is_command_message_str(_buf, _sz)) {
throw WrongStunBufferFormatException(); throw WrongStunBufferFormatException();
@ -167,17 +167,17 @@ public:
* Return raw memroy field of the attribute value. * Return raw memroy field of the attribute value.
* If the attribute value length is zero (0), then return NULL. * If the attribute value length is zero (0), then return NULL.
*/ */
const u08bits *getRawBuffer(size_t &sz) const throw(WrongStunAttrFormatException) { const uint8_t *getRawBuffer(size_t &sz) const throw(WrongStunAttrFormatException) {
int len = stun_attr_get_len(_sar); int len = stun_attr_get_len(_sar);
if(len<0) if(len<0)
throw WrongStunAttrFormatException(); throw WrongStunAttrFormatException();
sz = (size_t)len; sz = (size_t)len;
const u08bits *value = stun_attr_get_value(_sar); const uint8_t *value = stun_attr_get_value(_sar);
return value; return value;
} }
friend class StunAttr; friend class StunAttr;
private: private:
u08bits *_buf; uint8_t *_buf;
size_t _sz; size_t _sz;
stun_attr_ref _sar; stun_attr_ref _sar;
}; };
@ -201,15 +201,15 @@ public:
throw EndOfStunMsgException(); throw EndOfStunMsgException();
} }
size_t sz = 0; size_t sz = 0;
const u08bits *ptr = iter.getRawBuffer(sz); const uint8_t *ptr = iter.getRawBuffer(sz);
if(sz>=0xFFFF) if(sz>=0xFFFF)
throw WrongStunAttrFormatException(); throw WrongStunAttrFormatException();
int at = iter.getType(); int at = iter.getType();
if(at<0) if(at<0)
throw WrongStunAttrFormatException(); throw WrongStunAttrFormatException();
_attr_type = (u16bits)at; _attr_type = (uint16_t)at;
_sz = sz; _sz = sz;
_value=(u08bits*)malloc(_sz); _value=(uint8_t*)malloc(_sz);
if(ptr) if(ptr)
bcopy(ptr,_value,_sz); bcopy(ptr,_value,_sz);
} }
@ -225,7 +225,7 @@ public:
/** /**
* Return raw data representation of the attribute * Return raw data representation of the attribute
*/ */
const u08bits *getRawValue(size_t &sz) const { const uint8_t *getRawValue(size_t &sz) const {
sz=_sz; sz=_sz;
return _value; return _value;
} }
@ -233,13 +233,13 @@ public:
/** /**
* Set raw data value * Set raw data value
*/ */
void setRawValue(u08bits *value, size_t sz) throw(WrongStunAttrFormatException) { void setRawValue(uint8_t *value, size_t sz) throw(WrongStunAttrFormatException) {
if(sz>0xFFFF) if(sz>0xFFFF)
throw WrongStunAttrFormatException(); throw WrongStunAttrFormatException();
if(_value) if(_value)
free(_value,_sz); free(_value,_sz);
_sz = sz; _sz = sz;
_value=(u08bits*)malloc(_sz); _value=(uint8_t*)malloc(_sz);
if(value) if(value)
bcopy(value,_value,_sz); bcopy(value,_value,_sz);
} }
@ -247,14 +247,14 @@ public:
/** /**
* Get attribute type * Get attribute type
*/ */
u16bits getType() const { uint16_t getType() const {
return _attr_type; return _attr_type;
} }
/** /**
* Set attribute type * Set attribute type
*/ */
void setType(u16bits at) { void setType(uint16_t at) {
_attr_type = at; _attr_type = at;
} }
@ -265,7 +265,7 @@ public:
int addToMsg(T &msg) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) { int addToMsg(T &msg) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
if(!_attr_type) if(!_attr_type)
throw WrongStunAttrFormatException(); throw WrongStunAttrFormatException();
u08bits *buffer = msg.getRawBuffer(); uint8_t *buffer = msg.getRawBuffer();
if(buffer) { if(buffer) {
size_t sz = msg.getSize(); size_t sz = msg.getSize();
if(addToBuffer(buffer, sz)<0) { if(addToBuffer(buffer, sz)<0) {
@ -281,7 +281,7 @@ protected:
/** /**
* Virtual function member to add attribute to a raw buffer * Virtual function member to add attribute to a raw buffer
*/ */
virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) { virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
if(buffer) { if(buffer) {
if(!_value) if(!_value)
throw WrongStunAttrFormatException(); throw WrongStunAttrFormatException();
@ -300,8 +300,8 @@ protected:
return iter._sar; return iter._sar;
} }
private: private:
u16bits _attr_type; uint16_t _attr_type;
u08bits *_value; uint8_t *_value;
size_t _sz; size_t _sz;
}; };
@ -324,18 +324,18 @@ public:
throw WrongStunAttrFormatException(); throw WrongStunAttrFormatException();
} }
virtual ~StunAttrChannelNumber() {} virtual ~StunAttrChannelNumber() {}
u16bits getChannelNumber() const { uint16_t getChannelNumber() const {
return _cn; return _cn;
} }
void setChannelNumber(u16bits cn) { void setChannelNumber(uint16_t cn) {
_cn = cn; _cn = cn;
} }
protected: protected:
virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) { virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
return stun_attr_add_channel_number_str(buffer,&sz,_cn); return stun_attr_add_channel_number_str(buffer,&sz,_cn);
} }
private: private:
u16bits _cn; uint16_t _cn;
}; };
/** /**
@ -355,18 +355,18 @@ public:
_ep = stun_attr_get_even_port(getSar(iter)); _ep = stun_attr_get_even_port(getSar(iter));
} }
virtual ~StunAttrEvenPort() {} virtual ~StunAttrEvenPort() {}
u08bits getEvenPort() const { uint8_t getEvenPort() const {
return _ep; return _ep;
} }
void setEvenPort(u08bits ep) { void setEvenPort(uint8_t ep) {
_ep = ep; _ep = ep;
} }
protected: protected:
virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) { virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
return stun_attr_add_str(buffer, &sz, STUN_ATTRIBUTE_EVEN_PORT, &_ep, 1); return stun_attr_add_str(buffer, &sz, STUN_ATTRIBUTE_EVEN_PORT, &_ep, 1);
} }
private: private:
u08bits _ep; uint8_t _ep;
}; };
/** /**
@ -386,19 +386,19 @@ public:
_rt = stun_attr_get_reservation_token_value(getSar(iter)); _rt = stun_attr_get_reservation_token_value(getSar(iter));
} }
virtual ~StunAttrReservationToken() {} virtual ~StunAttrReservationToken() {}
u64bits getReservationToken() const { uint64_t getReservationToken() const {
return _rt; return _rt;
} }
void setReservationToken(u64bits rt) { void setReservationToken(uint64_t rt) {
_rt = rt; _rt = rt;
} }
protected: protected:
virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) { virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
uint64_t reservation_token = ioa_ntoh64(_rt); uint64_t reservation_token = ioa_ntoh64(_rt);
return stun_attr_add_str(buffer, &sz, STUN_ATTRIBUTE_RESERVATION_TOKEN, (u08bits*) (&reservation_token), 8); return stun_attr_add_str(buffer, &sz, STUN_ATTRIBUTE_RESERVATION_TOKEN, (uint8_t*) (&reservation_token), 8);
} }
private: private:
u64bits _rt; uint64_t _rt;
}; };
/** /**
@ -406,7 +406,7 @@ private:
*/ */
class StunAttrAddr : public StunAttr { class StunAttrAddr : public StunAttr {
public: public:
StunAttrAddr(u16bits attr_type = 0) { StunAttrAddr(uint16_t attr_type = 0) {
addr_set_any(&_addr); addr_set_any(&_addr);
setType(attr_type); setType(attr_type);
} }
@ -417,7 +417,7 @@ public:
if(iter.eof()) if(iter.eof())
throw EndOfStunMsgException(); throw EndOfStunMsgException();
size_t sz = 0; size_t sz = 0;
const u08bits *buf = iter.getRawBuffer(sz); const uint8_t *buf = iter.getRawBuffer(sz);
if(stun_attr_get_addr_str(buf,sz,getSar(iter),&_addr,NULL)<0) { if(stun_attr_get_addr_str(buf,sz,getSar(iter),&_addr,NULL)<0) {
throw WrongStunAttrFormatException(); throw WrongStunAttrFormatException();
} }
@ -430,7 +430,7 @@ public:
addr_cpy(&_addr,&addr); addr_cpy(&_addr,&addr);
} }
protected: protected:
virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) { virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
return stun_attr_add_addr_str(buffer, &sz, getType(), &_addr); return stun_attr_add_addr_str(buffer, &sz, getType(), &_addr);
} }
private: private:
@ -476,7 +476,7 @@ public:
_changePort = 0; _changePort = 0;
} }
protected: protected:
virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) { virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
return stun_attr_add_change_request_str(buffer, &sz, _changeIp, _changePort); return stun_attr_add_change_request_str(buffer, &sz, _changeIp, _changePort);
} }
private: private:
@ -503,21 +503,21 @@ public:
if(rp<0) { if(rp<0) {
throw WrongStunAttrFormatException(); throw WrongStunAttrFormatException();
} }
_rp = (u16bits)rp; _rp = (uint16_t)rp;
} }
virtual ~StunAttrResponsePort() {} virtual ~StunAttrResponsePort() {}
u16bits getResponsePort() const { uint16_t getResponsePort() const {
return _rp; return _rp;
} }
void setResponsePort(u16bits p) { void setResponsePort(uint16_t p) {
_rp = p; _rp = p;
} }
protected: protected:
virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) { virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
return stun_attr_add_response_port_str(buffer, &sz, _rp); return stun_attr_add_response_port_str(buffer, &sz, _rp);
} }
private: private:
u16bits _rp; uint16_t _rp;
}; };
/** /**
@ -539,24 +539,24 @@ public:
if(p<0) { if(p<0) {
throw WrongStunAttrFormatException(); throw WrongStunAttrFormatException();
} }
_p = (u16bits)p; _p = (uint16_t)p;
} }
virtual ~StunAttrPadding() {} virtual ~StunAttrPadding() {}
u16bits getPadding() const { uint16_t getPadding() const {
return _p; return _p;
} }
/** /**
* Set length of padding * Set length of padding
*/ */
void setPadding(u16bits p) { void setPadding(uint16_t p) {
_p = p; _p = p;
} }
protected: protected:
virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) { virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
return stun_attr_add_padding_str(buffer, &sz, _p); return stun_attr_add_padding_str(buffer, &sz, _p);
} }
private: private:
u16bits _p; uint16_t _p;
}; };
/** /**
@ -569,7 +569,7 @@ public:
*/ */
StunMsg() { StunMsg() {
_allocated_sz = 0xFFFF; _allocated_sz = 0xFFFF;
_buffer = (u08bits*)malloc(_allocated_sz); _buffer = (uint8_t*)malloc(_allocated_sz);
_deallocate = true; _deallocate = true;
_sz = 0; _sz = 0;
_constructed = 0; _constructed = 0;
@ -579,7 +579,7 @@ public:
* Construct message over raw buffer. * Construct message over raw buffer.
* Parameter "construct" is true if the buffer is initialized. * Parameter "construct" is true if the buffer is initialized.
*/ */
StunMsg(u08bits *buffer, size_t total_sz, size_t sz, bool constructed) : StunMsg(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed) :
_buffer(buffer), _deallocate(false), _allocated_sz(total_sz), _buffer(buffer), _deallocate(false), _allocated_sz(total_sz),
_sz(sz), _constructed(constructed) {} _sz(sz), _constructed(constructed) {}
@ -609,7 +609,7 @@ public:
/** /**
* get raw buffer * get raw buffer
*/ */
u08bits *getRawBuffer() { uint8_t *getRawBuffer() {
return _buffer; return _buffer;
} }
@ -632,7 +632,7 @@ public:
/** /**
* Check if the raw buffer is a TURN "command" (request, response or indication). * Check if the raw buffer is a TURN "command" (request, response or indication).
*/ */
static bool isCommand(u08bits *buffer, size_t sz) { static bool isCommand(uint8_t *buffer, size_t sz) {
return stun_is_command_message_str(buffer, sz); return stun_is_command_message_str(buffer, sz);
} }
@ -643,44 +643,44 @@ public:
return stun_is_command_message_str(_buffer, _sz); return stun_is_command_message_str(_buffer, _sz);
} }
static bool isIndication(u08bits *buffer, size_t sz) { static bool isIndication(uint8_t *buffer, size_t sz) {
return stun_is_indication_str(buffer, sz); return stun_is_indication_str(buffer, sz);
} }
static bool isRequest(u08bits *buffer, size_t sz) { static bool isRequest(uint8_t *buffer, size_t sz) {
return stun_is_request_str(buffer, sz); return stun_is_request_str(buffer, sz);
} }
static bool isSuccessResponse(u08bits *buffer, size_t sz) { static bool isSuccessResponse(uint8_t *buffer, size_t sz) {
return stun_is_success_response_str(buffer, sz); return stun_is_success_response_str(buffer, sz);
} }
static bool isErrorResponse(u08bits *buffer, size_t sz, static bool isErrorResponse(uint8_t *buffer, size_t sz,
int &err_code, u08bits *err_msg, size_t err_msg_size) { int &err_code, uint8_t *err_msg, size_t err_msg_size) {
return stun_is_error_response_str(buffer, sz, &err_code, err_msg, err_msg_size); return stun_is_error_response_str(buffer, sz, &err_code, err_msg, err_msg_size);
} }
/** /**
* Check if the raw buffer is a challenge response (the one with 401 error and realm and nonce values). * Check if the raw buffer is a challenge response (the one with 401 error and realm and nonce values).
*/ */
static bool isChallengeResponse(const u08bits* buf, size_t sz, static bool isChallengeResponse(const uint8_t* buf, size_t sz,
int &err_code, u08bits *err_msg, size_t err_msg_size, int &err_code, uint8_t *err_msg, size_t err_msg_size,
u08bits *realm, u08bits *nonce, uint8_t *realm, uint8_t *nonce,
u08bits *server_name, int *oauth) { uint8_t *server_name, int *oauth) {
return stun_is_challenge_response_str(buf, sz, &err_code, err_msg, err_msg_size, realm, nonce, server_name, oauth); return stun_is_challenge_response_str(buf, sz, &err_code, err_msg, err_msg_size, realm, nonce, server_name, oauth);
} }
/** /**
* Check if the message is a channel message * Check if the message is a channel message
*/ */
static bool isChannel(u08bits *buffer, size_t sz) { static bool isChannel(uint8_t *buffer, size_t sz) {
return is_channel_msg_str(buffer, sz); return is_channel_msg_str(buffer, sz);
} }
/** /**
* Check if the fingerprint is present. * Check if the fingerprint is present.
*/ */
static bool isFingerprintPresent(u08bits *buffer, size_t sz) { static bool isFingerprintPresent(uint8_t *buffer, size_t sz) {
if(!stun_is_command_message_str(buffer,sz)) if(!stun_is_command_message_str(buffer,sz))
return false; return false;
stun_attr_ref sar = stun_attr_get_first_by_type_str(buffer, sz, STUN_ATTRIBUTE_FINGERPRINT); stun_attr_ref sar = stun_attr_get_first_by_type_str(buffer, sz, STUN_ATTRIBUTE_FINGERPRINT);
@ -693,7 +693,7 @@ public:
/** /**
* Check the fingerprint * Check the fingerprint
*/ */
static bool checkFingerprint(u08bits *buffer, size_t sz) { static bool checkFingerprint(uint8_t *buffer, size_t sz) {
return stun_is_command_message_full_check_str(buffer, sz, 1, NULL); return stun_is_command_message_full_check_str(buffer, sz, 1, NULL);
} }
@ -740,9 +740,9 @@ public:
throw(WrongStunBufferFormatException) { throw(WrongStunBufferFormatException) {
if(!_constructed || !isCommand()) if(!_constructed || !isCommand())
throw WrongStunBufferFormatException(); throw WrongStunBufferFormatException();
u08bits *suname=(u08bits*)strdup(uname.c_str()); uint8_t *suname=(uint8_t*)strdup(uname.c_str());
u08bits *srealm=(u08bits*)strdup(realm.c_str()); uint8_t *srealm=(uint8_t*)strdup(realm.c_str());
u08bits *supwd=(u08bits*)strdup(upwd.c_str()); uint8_t *supwd=(uint8_t*)strdup(upwd.c_str());
SHATYPE sht = SHATYPE_SHA1; SHATYPE sht = SHATYPE_SHA1;
bool ret = (0< stun_check_message_integrity_str(ct,_buffer, _sz, suname, srealm, supwd, sht)); bool ret = (0< stun_check_message_integrity_str(ct,_buffer, _sz, suname, srealm, supwd, sht));
free(suname); free(suname);
@ -760,10 +760,10 @@ public:
if(!_constructed || !isCommand()) if(!_constructed || !isCommand())
throw WrongStunBufferFormatException(); throw WrongStunBufferFormatException();
u08bits *suname=(u08bits*)strdup(uname.c_str()); uint8_t *suname=(uint8_t*)strdup(uname.c_str());
u08bits *srealm=(u08bits*)strdup(realm.c_str()); uint8_t *srealm=(uint8_t*)strdup(realm.c_str());
u08bits *supwd=(u08bits*)strdup(upwd.c_str()); uint8_t *supwd=(uint8_t*)strdup(upwd.c_str());
u08bits *snonce=(u08bits*)strdup(nonce.c_str()); uint8_t *snonce=(uint8_t*)strdup(nonce.c_str());
stun_attr_add_integrity_by_user_str(_buffer, &_sz, suname, srealm, supwd, snonce, SHATYPE_SHA1); stun_attr_add_integrity_by_user_str(_buffer, &_sz, suname, srealm, supwd, snonce, SHATYPE_SHA1);
@ -782,8 +782,8 @@ public:
if(!_constructed || !isCommand()) if(!_constructed || !isCommand())
throw WrongStunBufferFormatException(); throw WrongStunBufferFormatException();
u08bits *suname=(u08bits*)strdup(uname.c_str()); uint8_t *suname=(uint8_t*)strdup(uname.c_str());
u08bits *supwd=(u08bits*)strdup(upwd.c_str()); uint8_t *supwd=(uint8_t*)strdup(upwd.c_str());
stun_attr_add_integrity_by_user_short_term_str(_buffer, &_sz, suname, supwd, SHATYPE_SHA1); stun_attr_add_integrity_by_user_short_term_str(_buffer, &_sz, suname, supwd, SHATYPE_SHA1);
@ -795,7 +795,7 @@ protected:
virtual void constructBuffer() = 0; virtual void constructBuffer() = 0;
virtual bool check() = 0; virtual bool check() = 0;
protected: protected:
u08bits *_buffer; uint8_t *_buffer;
bool _deallocate; bool _deallocate;
size_t _allocated_sz; size_t _allocated_sz;
size_t _sz; size_t _sz;
@ -807,8 +807,8 @@ protected:
*/ */
class StunMsgRequest : public StunMsg { class StunMsgRequest : public StunMsg {
public: public:
StunMsgRequest(u16bits method) : _method(method) {}; StunMsgRequest(uint16_t method) : _method(method) {};
StunMsgRequest(u08bits *buffer, size_t total_sz, size_t sz, bool constructed) StunMsgRequest(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed)
throw(WrongStunBufferFormatException) : throw(WrongStunBufferFormatException) :
StunMsg(buffer,total_sz,sz,constructed),_method(0) { StunMsg(buffer,total_sz,sz,constructed),_method(0) {
@ -824,14 +824,14 @@ public:
/** /**
* Get request method * Get request method
*/ */
u16bits getMethod() const { uint16_t getMethod() const {
return _method; return _method;
} }
/** /**
* Set method * Set method
*/ */
void setMethod(u16bits method) { void setMethod(uint16_t method) {
_method = method; _method = method;
} }
@ -849,14 +849,14 @@ public:
/** /**
* Construct allocate request * Construct allocate request
*/ */
void constructAllocateRequest(u32bits lifetime, int af4, int af6, u08bits transport, int mobile, const char* rt, int ep) { void constructAllocateRequest(uint32_t lifetime, int af4, int af6, uint8_t transport, int mobile, const char* rt, int ep) {
stun_set_allocate_request_str(_buffer, &_sz, lifetime, af4, af6, transport, mobile, rt, ep); stun_set_allocate_request_str(_buffer, &_sz, lifetime, af4, af6, transport, mobile, rt, ep);
} }
/** /**
* Construct channel bind request * Construct channel bind request
*/ */
void constructChannelBindRequest(const ioa_addr &peer_addr, u16bits channel_number) { void constructChannelBindRequest(const ioa_addr &peer_addr, uint16_t channel_number) {
stun_set_channel_bind_request_str(_buffer, &_sz, stun_set_channel_bind_request_str(_buffer, &_sz,
&peer_addr, channel_number); &peer_addr, channel_number);
} }
@ -880,7 +880,7 @@ protected:
} }
private: private:
u16bits _method; uint16_t _method;
}; };
/** /**
@ -888,18 +888,18 @@ private:
*/ */
class StunMsgResponse : public StunMsg { class StunMsgResponse : public StunMsg {
public: public:
StunMsgResponse(u16bits method, stun_tid &tid) : _method(method), _err(0), _reason(""), _tid(tid) {}; StunMsgResponse(uint16_t method, stun_tid &tid) : _method(method), _err(0), _reason(""), _tid(tid) {};
StunMsgResponse(u16bits method, int error_code, std::string reason, stun_tid &tid) : StunMsgResponse(uint16_t method, int error_code, std::string reason, stun_tid &tid) :
_method(method), _err(error_code), _reason(reason), _tid(tid) { _method(method), _err(error_code), _reason(reason), _tid(tid) {
}; };
StunMsgResponse(u08bits *buffer, size_t total_sz, size_t sz, bool constructed) StunMsgResponse(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed)
throw(WrongStunBufferFormatException) : throw(WrongStunBufferFormatException) :
StunMsg(buffer,total_sz,sz,constructed),_method(0),_err(0),_reason("") { StunMsg(buffer,total_sz,sz,constructed),_method(0),_err(0),_reason("") {
if(constructed) { if(constructed) {
if(!stun_is_success_response_str(buffer,sz)) { if(!stun_is_success_response_str(buffer,sz)) {
u08bits errtxt[0xFFFF]; uint8_t errtxt[0xFFFF];
if(!stun_is_error_response_str(buffer,sz,&_err,errtxt,sizeof(errtxt))) { if(!stun_is_error_response_str(buffer,sz,&_err,errtxt,sizeof(errtxt))) {
throw WrongStunBufferFormatException(); throw WrongStunBufferFormatException();
} }
@ -910,11 +910,11 @@ public:
} }
} }
u16bits getMethod() const { uint16_t getMethod() const {
return _method; return _method;
} }
void setMethod(u16bits method) { void setMethod(uint16_t method) {
_method = method; _method = method;
} }
@ -967,10 +967,10 @@ public:
bool ret = false; bool ret = false;
if(_constructed) { if(_constructed) {
int err_code; int err_code;
u08bits err_msg[1025]; uint8_t err_msg[1025];
size_t err_msg_size=sizeof(err_msg); size_t err_msg_size=sizeof(err_msg);
u08bits srealm[0xFFFF]; uint8_t srealm[0xFFFF];
u08bits snonce[0xFFFF]; uint8_t snonce[0xFFFF];
ret = stun_is_challenge_response_str(_buffer, _sz, &err_code, err_msg, err_msg_size, srealm, snonce, NULL, NULL); ret = stun_is_challenge_response_str(_buffer, _sz, &err_code, err_msg, err_msg_size, srealm, snonce, NULL, NULL);
if(ret) { if(ret) {
realm = (char*)srealm; realm = (char*)srealm;
@ -997,7 +997,7 @@ public:
*/ */
void constructBindingResponse(stun_tid &tid, void constructBindingResponse(stun_tid &tid,
const ioa_addr &reflexive_addr, int error_code, const ioa_addr &reflexive_addr, int error_code,
const u08bits *reason) { const uint8_t *reason) {
stun_set_binding_response_str(_buffer, &_sz, &tid, stun_set_binding_response_str(_buffer, &_sz, &tid,
&reflexive_addr, error_code, &reflexive_addr, error_code,
@ -1015,8 +1015,8 @@ public:
const ioa_addr &relayed_addr1, const ioa_addr &relayed_addr1,
const ioa_addr &relayed_addr2, const ioa_addr &relayed_addr2,
const ioa_addr &reflexive_addr, const ioa_addr &reflexive_addr,
u32bits lifetime, int error_code, const u08bits *reason, uint32_t lifetime, int error_code, const uint8_t *reason,
u64bits reservation_token, char *mobile_id) { uint64_t reservation_token, char *mobile_id) {
stun_set_allocate_response_str(_buffer, &_sz, &tid, stun_set_allocate_response_str(_buffer, &_sz, &tid,
&relayed_addr1, &relayed_addr2, &relayed_addr1, &relayed_addr2,
@ -1028,14 +1028,14 @@ public:
/** /**
* Construct channel bind response * Construct channel bind response
*/ */
void constructChannelBindResponse(stun_tid &tid, int error_code, const u08bits *reason) { void constructChannelBindResponse(stun_tid &tid, int error_code, const uint8_t *reason) {
stun_set_channel_bind_response_str(_buffer, &_sz, &tid, error_code, reason); stun_set_channel_bind_response_str(_buffer, &_sz, &tid, error_code, reason);
} }
protected: protected:
virtual void constructBuffer() { virtual void constructBuffer() {
if(_err) { if(_err) {
stun_init_error_response_str(_method, _buffer, &_sz, _err, (const u08bits*)_reason.c_str(), &_tid); stun_init_error_response_str(_method, _buffer, &_sz, _err, (const uint8_t*)_reason.c_str(), &_tid);
} else { } else {
stun_init_success_response_str(_method, _buffer, &_sz, &_tid); stun_init_success_response_str(_method, _buffer, &_sz, &_tid);
} }
@ -1046,7 +1046,7 @@ protected:
if(!_constructed) if(!_constructed)
return false; return false;
if(!stun_is_success_response_str(_buffer,_sz)) { if(!stun_is_success_response_str(_buffer,_sz)) {
u08bits errtxt[0xFFFF]; uint8_t errtxt[0xFFFF];
int cerr=0; int cerr=0;
if(!stun_is_error_response_str(_buffer,_sz,&cerr,errtxt,sizeof(errtxt))) { if(!stun_is_error_response_str(_buffer,_sz,&cerr,errtxt,sizeof(errtxt))) {
throw WrongStunBufferFormatException(); throw WrongStunBufferFormatException();
@ -1062,7 +1062,7 @@ protected:
} }
private: private:
u16bits _method; uint16_t _method;
int _err; int _err;
std::string _reason; std::string _reason;
stun_tid _tid; stun_tid _tid;
@ -1073,8 +1073,8 @@ private:
*/ */
class StunMsgIndication : public StunMsg { class StunMsgIndication : public StunMsg {
public: public:
StunMsgIndication(u16bits method) : _method(method) {}; StunMsgIndication(uint16_t method) : _method(method) {};
StunMsgIndication(u08bits *buffer, size_t total_sz, size_t sz, bool constructed) StunMsgIndication(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed)
throw(WrongStunBufferFormatException) : throw(WrongStunBufferFormatException) :
StunMsg(buffer,total_sz,sz,constructed),_method(0) { StunMsg(buffer,total_sz,sz,constructed),_method(0) {
@ -1087,11 +1087,11 @@ public:
} }
virtual ~StunMsgIndication() {} virtual ~StunMsgIndication() {}
u16bits getMethod() const { uint16_t getMethod() const {
return _method; return _method;
} }
void setMethod(u16bits method) { void setMethod(uint16_t method) {
_method = method; _method = method;
} }
@ -1114,7 +1114,7 @@ protected:
} }
private: private:
u16bits _method; uint16_t _method;
}; };
/** /**
@ -1122,8 +1122,8 @@ private:
*/ */
class StunMsgChannel : public StunMsg { class StunMsgChannel : public StunMsg {
public: public:
StunMsgChannel(u16bits cn, int length) : _cn(cn), _len(length) {}; StunMsgChannel(uint16_t cn, int length) : _cn(cn), _len(length) {};
StunMsgChannel(u08bits *buffer, size_t total_sz, size_t sz, bool constructed) StunMsgChannel(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed)
throw(WrongStunBufferFormatException) : throw(WrongStunBufferFormatException) :
StunMsg(buffer,total_sz,sz,constructed),_cn(0) { StunMsg(buffer,total_sz,sz,constructed),_cn(0) {
@ -1144,11 +1144,11 @@ public:
} }
virtual ~StunMsgChannel() {} virtual ~StunMsgChannel() {}
u16bits getChannelNumber() const { uint16_t getChannelNumber() const {
return _cn; return _cn;
} }
void setChannelNumber(u16bits cn) { void setChannelNumber(uint16_t cn) {
_cn = cn; _cn = cn;
} }
@ -1175,7 +1175,7 @@ protected:
virtual bool check() { virtual bool check() {
if(!_constructed) if(!_constructed)
return false; return false;
u16bits cn = 0; uint16_t cn = 0;
if(!stun_is_channel_message_str(_buffer,&_sz,&cn,0)) { if(!stun_is_channel_message_str(_buffer,&_sz,&cn,0)) {
return false; return false;
} }
@ -1186,7 +1186,7 @@ protected:
} }
private: private:
u16bits _cn; uint16_t _cn;
size_t _len; size_t _len;
}; };

View File

@ -34,7 +34,7 @@
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
u32bits get_ioa_addr_len(const ioa_addr* addr) { uint32_t get_ioa_addr_len(const ioa_addr* addr) {
if(addr->ss.sa_family == AF_INET) return sizeof(struct sockaddr_in); if(addr->ss.sa_family == AF_INET) return sizeof(struct sockaddr_in);
else if(addr->ss.sa_family == AF_INET6) return sizeof(struct sockaddr_in6); else if(addr->ss.sa_family == AF_INET6) return sizeof(struct sockaddr_in6);
return 0; return 0;
@ -59,7 +59,7 @@ int addr_any(const ioa_addr* addr) {
else { else {
size_t i; size_t i;
for(i=0;i<sizeof(addr->s6.sin6_addr);i++) for(i=0;i<sizeof(addr->s6.sin6_addr);i++)
if(((const s08bits*)&(addr->s6.sin6_addr))[i]) return 0; if(((const char*)&(addr->s6.sin6_addr))[i]) return 0;
} }
} }
@ -75,13 +75,13 @@ int addr_any_no_port(const ioa_addr* addr) {
} else if(addr->ss.sa_family == AF_INET6) { } else if(addr->ss.sa_family == AF_INET6) {
size_t i; size_t i;
for(i=0;i<sizeof(addr->s6.sin6_addr);i++) for(i=0;i<sizeof(addr->s6.sin6_addr);i++)
if(((const s08bits*)(&(addr->s6.sin6_addr)))[i]) return 0; if(((const char*)(&(addr->s6.sin6_addr)))[i]) return 0;
} }
return 1; return 1;
} }
u32bits hash_int32(u32bits a) uint32_t hash_int32(uint32_t a)
{ {
a = a ^ (a>>4); a = a ^ (a>>4);
a = (a^0xdeadbeef) + (a<<5); a = (a^0xdeadbeef) + (a<<5);
@ -89,7 +89,7 @@ u32bits hash_int32(u32bits a)
return a; return a;
} }
u64bits hash_int64(u64bits a) uint64_t hash_int64(uint64_t a)
{ {
a = a ^ (a>>4); a = a ^ (a>>4);
a = (a^0xdeadbeefdeadbeefLL) + (a<<5); a = (a^0xdeadbeefdeadbeefLL) + (a<<5);
@ -97,34 +97,34 @@ u64bits hash_int64(u64bits a)
return a; return a;
} }
u32bits addr_hash(const ioa_addr *addr) uint32_t addr_hash(const ioa_addr *addr)
{ {
if(!addr) if(!addr)
return 0; return 0;
u32bits ret = 0; uint32_t ret = 0;
if (addr->ss.sa_family == AF_INET) { if (addr->ss.sa_family == AF_INET) {
ret = hash_int32(addr->s4.sin_addr.s_addr + addr->s4.sin_port); ret = hash_int32(addr->s4.sin_addr.s_addr + addr->s4.sin_port);
} else { } else {
u64bits a[2]; uint64_t a[2];
bcopy(&(addr->s6.sin6_addr), &a, sizeof(a)); bcopy(&(addr->s6.sin6_addr), &a, sizeof(a));
ret = (u32bits)((hash_int64(a[0])<<3) + (hash_int64(a[1] + addr->s6.sin6_port))); ret = (uint32_t)((hash_int64(a[0])<<3) + (hash_int64(a[1] + addr->s6.sin6_port)));
} }
return ret; return ret;
} }
u32bits addr_hash_no_port(const ioa_addr *addr) uint32_t addr_hash_no_port(const ioa_addr *addr)
{ {
if(!addr) if(!addr)
return 0; return 0;
u32bits ret = 0; uint32_t ret = 0;
if (addr->ss.sa_family == AF_INET) { if (addr->ss.sa_family == AF_INET) {
ret = hash_int32(addr->s4.sin_addr.s_addr); ret = hash_int32(addr->s4.sin_addr.s_addr);
} else { } else {
u64bits a[2]; uint64_t a[2];
bcopy(&(addr->s6.sin6_addr), &a, sizeof(a)); bcopy(&(addr->s6.sin6_addr), &a, sizeof(a));
ret = (u32bits)((hash_int64(a[0])<<3) + (hash_int64(a[1]))); ret = (uint32_t)((hash_int64(a[0])<<3) + (hash_int64(a[1])));
} }
return ret; return ret;
} }
@ -183,7 +183,7 @@ int addr_eq_no_port(const ioa_addr* a1, const ioa_addr *a2) {
return 0; return 0;
} }
int make_ioa_addr(const u08bits* saddr0, int port, ioa_addr *addr) { int make_ioa_addr(const uint8_t* saddr0, int port, ioa_addr *addr) {
if(!saddr0 || !addr) return -1; if(!saddr0 || !addr) return -1;
@ -315,7 +315,7 @@ static char* get_addr_string_and_port(char* s0, int *port)
return NULL; return NULL;
} }
int make_ioa_addr_from_full_string(const u08bits* saddr, int default_port, ioa_addr *addr) int make_ioa_addr_from_full_string(const uint8_t* saddr, int default_port, ioa_addr *addr)
{ {
if(!addr) if(!addr)
return -1; return -1;
@ -327,31 +327,31 @@ int make_ioa_addr_from_full_string(const u08bits* saddr, int default_port, ioa_a
if(sa) { if(sa) {
if(port<1) if(port<1)
port = default_port; port = default_port;
ret = make_ioa_addr((u08bits*)sa,port,addr); ret = make_ioa_addr((uint8_t*)sa,port,addr);
} }
free(s); free(s);
return ret; return ret;
} }
int addr_to_string(const ioa_addr* addr, u08bits* saddr) int addr_to_string(const ioa_addr* addr, uint8_t* saddr)
{ {
if (addr && saddr) { if (addr && saddr) {
s08bits addrtmp[INET6_ADDRSTRLEN]; char addrtmp[INET6_ADDRSTRLEN];
if (addr->ss.sa_family == AF_INET) { if (addr->ss.sa_family == AF_INET) {
inet_ntop(AF_INET, &addr->s4.sin_addr, addrtmp, INET_ADDRSTRLEN); inet_ntop(AF_INET, &addr->s4.sin_addr, addrtmp, INET_ADDRSTRLEN);
if(addr_get_port(addr)>0) if(addr_get_port(addr)>0)
snprintf((s08bits*)saddr, MAX_IOA_ADDR_STRING, "%s:%d", addrtmp, addr_get_port(addr)); snprintf((char*)saddr, MAX_IOA_ADDR_STRING, "%s:%d", addrtmp, addr_get_port(addr));
else else
strncpy((s08bits*)saddr, addrtmp, MAX_IOA_ADDR_STRING); strncpy((char*)saddr, addrtmp, MAX_IOA_ADDR_STRING);
} else if (addr->ss.sa_family == AF_INET6) { } else if (addr->ss.sa_family == AF_INET6) {
inet_ntop(AF_INET6, &addr->s6.sin6_addr, addrtmp, INET6_ADDRSTRLEN); inet_ntop(AF_INET6, &addr->s6.sin6_addr, addrtmp, INET6_ADDRSTRLEN);
if(addr_get_port(addr)>0) if(addr_get_port(addr)>0)
snprintf((s08bits*)saddr, MAX_IOA_ADDR_STRING, "[%s]:%d", addrtmp, addr_get_port(addr)); snprintf((char*)saddr, MAX_IOA_ADDR_STRING, "[%s]:%d", addrtmp, addr_get_port(addr));
else else
strncpy((s08bits*)saddr, addrtmp, MAX_IOA_ADDR_STRING); strncpy((char*)saddr, addrtmp, MAX_IOA_ADDR_STRING);
} else { } else {
return -1; return -1;
} }
@ -362,19 +362,19 @@ int addr_to_string(const ioa_addr* addr, u08bits* saddr)
return -1; return -1;
} }
int addr_to_string_no_port(const ioa_addr* addr, u08bits* saddr) int addr_to_string_no_port(const ioa_addr* addr, uint8_t* saddr)
{ {
if (addr && saddr) { if (addr && saddr) {
s08bits addrtmp[MAX_IOA_ADDR_STRING]; char addrtmp[MAX_IOA_ADDR_STRING];
if (addr->ss.sa_family == AF_INET) { if (addr->ss.sa_family == AF_INET) {
inet_ntop(AF_INET, &addr->s4.sin_addr, addrtmp, INET_ADDRSTRLEN); inet_ntop(AF_INET, &addr->s4.sin_addr, addrtmp, INET_ADDRSTRLEN);
strncpy((s08bits*)saddr, addrtmp, MAX_IOA_ADDR_STRING); strncpy((char*)saddr, addrtmp, MAX_IOA_ADDR_STRING);
} else if (addr->ss.sa_family == AF_INET6) { } else if (addr->ss.sa_family == AF_INET6) {
inet_ntop(AF_INET6, &addr->s6.sin6_addr, addrtmp, INET6_ADDRSTRLEN); inet_ntop(AF_INET6, &addr->s6.sin6_addr, addrtmp, INET6_ADDRSTRLEN);
strncpy((s08bits*)saddr, addrtmp, MAX_IOA_ADDR_STRING); strncpy((char*)saddr, addrtmp, MAX_IOA_ADDR_STRING);
} else { } else {
return -1; return -1;
} }
@ -425,11 +425,11 @@ int addr_less_eq(const ioa_addr* addr1, const ioa_addr* addr2) {
else { else {
if(addr1->ss.sa_family != addr2->ss.sa_family) return (addr1->ss.sa_family < addr2->ss.sa_family); if(addr1->ss.sa_family != addr2->ss.sa_family) return (addr1->ss.sa_family < addr2->ss.sa_family);
else if(addr1->ss.sa_family == AF_INET) { else if(addr1->ss.sa_family == AF_INET) {
return ((u32bits)nswap32(addr1->s4.sin_addr.s_addr) <= (u32bits)nswap32(addr2->s4.sin_addr.s_addr)); return ((uint32_t)nswap32(addr1->s4.sin_addr.s_addr) <= (uint32_t)nswap32(addr2->s4.sin_addr.s_addr));
} else if(addr1->ss.sa_family == AF_INET6) { } else if(addr1->ss.sa_family == AF_INET6) {
int i; int i;
for(i=0;i<16;i++) { for(i=0;i<16;i++) {
if((u08bits)(((const s08bits*)&(addr1->s6.sin6_addr))[i]) > (u08bits)(((const s08bits*)&(addr2->s6.sin6_addr))[i])) if((uint8_t)(((const char*)&(addr1->s6.sin6_addr))[i]) > (uint8_t)(((const char*)&(addr2->s6.sin6_addr))[i]))
return 0; return 0;
} }
return 1; return 1;
@ -465,10 +465,10 @@ int ioa_addr_is_multicast(ioa_addr *addr)
{ {
if(addr) { if(addr) {
if(addr->ss.sa_family == AF_INET) { if(addr->ss.sa_family == AF_INET) {
const u08bits *u = ((const u08bits*)&(addr->s4.sin_addr)); const uint8_t *u = ((const uint8_t*)&(addr->s4.sin_addr));
return (u[0] > 223); return (u[0] > 223);
} else if(addr->ss.sa_family == AF_INET6) { } else if(addr->ss.sa_family == AF_INET6) {
u08bits u = ((const u08bits*)&(addr->s6.sin6_addr))[0]; uint8_t u = ((const uint8_t*)&(addr->s6.sin6_addr))[0];
return (u == 255); return (u == 255);
} }
} }
@ -479,10 +479,10 @@ int ioa_addr_is_loopback(ioa_addr *addr)
{ {
if(addr) { if(addr) {
if(addr->ss.sa_family == AF_INET) { if(addr->ss.sa_family == AF_INET) {
const u08bits *u = ((const u08bits*)&(addr->s4.sin_addr)); const uint8_t *u = ((const uint8_t*)&(addr->s4.sin_addr));
return (u[0] == 127); return (u[0] == 127);
} else if(addr->ss.sa_family == AF_INET6) { } else if(addr->ss.sa_family == AF_INET6) {
const u08bits *u = ((const u08bits*)&(addr->s6.sin6_addr)); const uint8_t *u = ((const uint8_t*)&(addr->s6.sin6_addr));
if(u[7] == 1) { if(u[7] == 1) {
int i; int i;
for(i=0;i<7;++i) { for(i=0;i<7;++i) {

View File

@ -54,29 +54,29 @@ typedef struct {
//////////////////////////// ////////////////////////////
u32bits get_ioa_addr_len(const ioa_addr* addr); uint32_t get_ioa_addr_len(const ioa_addr* addr);
//////////////////////////// ////////////////////////////
void addr_set_any(ioa_addr *addr); void addr_set_any(ioa_addr *addr);
int addr_any(const ioa_addr* addr); int addr_any(const ioa_addr* addr);
int addr_any_no_port(const ioa_addr* addr); int addr_any_no_port(const ioa_addr* addr);
u32bits addr_hash(const ioa_addr *addr); uint32_t addr_hash(const ioa_addr *addr);
u32bits addr_hash_no_port(const ioa_addr *addr); uint32_t addr_hash_no_port(const ioa_addr *addr);
void addr_cpy(ioa_addr* dst, const ioa_addr* src); void addr_cpy(ioa_addr* dst, const ioa_addr* src);
void addr_cpy4(ioa_addr* dst, const struct sockaddr_in* src); void addr_cpy4(ioa_addr* dst, const struct sockaddr_in* src);
void addr_cpy6(ioa_addr* dst, const struct sockaddr_in6* src); void addr_cpy6(ioa_addr* dst, const struct sockaddr_in6* src);
int addr_eq(const ioa_addr* a1, const ioa_addr *a2); int addr_eq(const ioa_addr* a1, const ioa_addr *a2);
int addr_eq_no_port(const ioa_addr* a1, const ioa_addr *a2); int addr_eq_no_port(const ioa_addr* a1, const ioa_addr *a2);
int make_ioa_addr(const u08bits* saddr, int port, ioa_addr *addr); int make_ioa_addr(const uint8_t* saddr, int port, ioa_addr *addr);
int make_ioa_addr_from_full_string(const u08bits* saddr, int default_port, ioa_addr *addr); int make_ioa_addr_from_full_string(const uint8_t* saddr, int default_port, ioa_addr *addr);
void addr_set_port(ioa_addr* addr, int port); void addr_set_port(ioa_addr* addr, int port);
int addr_get_port(const ioa_addr* addr); int addr_get_port(const ioa_addr* addr);
int addr_to_string(const ioa_addr* addr, u08bits* saddr); int addr_to_string(const ioa_addr* addr, uint8_t* saddr);
int addr_to_string_no_port(const ioa_addr* addr, u08bits* saddr); int addr_to_string_no_port(const ioa_addr* addr, uint8_t* saddr);
u32bits hash_int32(u32bits a); uint32_t hash_int32(uint32_t a);
u64bits hash_int64(u64bits a); uint64_t hash_int64(uint64_t a);
/////////////////////////////////////////// ///////////////////////////////////////////

File diff suppressed because it is too large Load Diff

View File

@ -61,9 +61,9 @@ typedef enum {
/** /**
* HMAC key * HMAC key
*/ */
typedef u08bits hmackey_t[64]; typedef uint8_t hmackey_t[64];
typedef u08bits password_t[STUN_MAX_PWD_SIZE+1]; typedef uint8_t password_t[STUN_MAX_PWD_SIZE+1];
typedef unsigned long band_limit_t; typedef unsigned long band_limit_t;
/////////////////////////////////// ///////////////////////////////////
@ -78,11 +78,11 @@ void stun_tid_generate(stun_tid* id);
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
u16bits stun_make_type(u16bits method); uint16_t stun_make_type(uint16_t method);
u16bits stun_make_request(u16bits method); uint16_t stun_make_request(uint16_t method);
u16bits stun_make_indication(u16bits method); uint16_t stun_make_indication(uint16_t method);
u16bits stun_make_success_response(u16bits method); uint16_t stun_make_success_response(uint16_t method);
u16bits stun_make_error_response(u16bits method); uint16_t stun_make_error_response(uint16_t method);
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
@ -90,90 +90,90 @@ turn_time_t stun_adjust_allocate_lifetime(turn_time_t lifetime, turn_time_t max_
///////////// STR //////////////////////////////////////////////// ///////////// STR ////////////////////////////////////////////////
int stun_method_str(u16bits method, char *smethod); int stun_method_str(uint16_t method, char *smethod);
int stun_get_message_len_str(u08bits *buf, size_t len, int padding, size_t *app_len); int stun_get_message_len_str(uint8_t *buf, size_t len, int padding, size_t *app_len);
void stun_init_buffer_str(u08bits *buf, size_t *len); void stun_init_buffer_str(uint8_t *buf, size_t *len);
void stun_init_command_str(u16bits message_type, u08bits* buf, size_t *len); void stun_init_command_str(uint16_t message_type, uint8_t* buf, size_t *len);
void old_stun_init_command_str(u16bits message_type, u08bits* buf, size_t *len, u32bits cookie); void old_stun_init_command_str(uint16_t message_type, uint8_t* buf, size_t *len, uint32_t cookie);
void stun_init_request_str(u16bits method, u08bits* buf, size_t *len); void stun_init_request_str(uint16_t method, uint8_t* buf, size_t *len);
void stun_init_indication_str(u16bits method, u08bits* buf, size_t *len); void stun_init_indication_str(uint16_t method, uint8_t* buf, size_t *len);
void stun_init_success_response_str(u16bits method, u08bits* buf, size_t *len, stun_tid* id); void stun_init_success_response_str(uint16_t method, uint8_t* buf, size_t *len, stun_tid* id);
void old_stun_init_success_response_str(u16bits method, u08bits* buf, size_t *len, stun_tid* id, u32bits cookie); void old_stun_init_success_response_str(uint16_t method, uint8_t* buf, size_t *len, stun_tid* id, uint32_t cookie);
void stun_init_error_response_str(u16bits method, u08bits* buf, size_t *len, u16bits error_code, const u08bits *reason, stun_tid* id); void stun_init_error_response_str(uint16_t method, uint8_t* buf, size_t *len, uint16_t error_code, const uint8_t *reason, stun_tid* id);
void old_stun_init_error_response_str(u16bits method, u08bits* buf, size_t *len, u16bits error_code, const u08bits *reason, stun_tid* id, u32bits cookie); void old_stun_init_error_response_str(uint16_t method, uint8_t* buf, size_t *len, uint16_t error_code, const uint8_t *reason, stun_tid* id, uint32_t cookie);
int stun_init_channel_message_str(u16bits chnumber, u08bits* buf, size_t *len, int length, int do_padding); int stun_init_channel_message_str(uint16_t chnumber, uint8_t* buf, size_t *len, int length, int do_padding);
int stun_is_command_message_str(const u08bits* buf, size_t blen); int stun_is_command_message_str(const uint8_t* buf, size_t blen);
int old_stun_is_command_message_str(const u08bits* buf, size_t blen, u32bits *cookie); int old_stun_is_command_message_str(const uint8_t* buf, size_t blen, uint32_t *cookie);
int stun_is_command_message_full_check_str(const u08bits* buf, size_t blen, int must_check_fingerprint, int *fingerprint_present); int stun_is_command_message_full_check_str(const uint8_t* buf, size_t blen, int must_check_fingerprint, int *fingerprint_present);
int stun_is_command_message_offset_str(const u08bits* buf, size_t blen, int offset); int stun_is_command_message_offset_str(const uint8_t* buf, size_t blen, int offset);
int stun_is_request_str(const u08bits* buf, size_t len); int stun_is_request_str(const uint8_t* buf, size_t len);
int stun_is_success_response_str(const u08bits* buf, size_t len); int stun_is_success_response_str(const uint8_t* buf, size_t len);
int stun_is_error_response_str(const u08bits* buf, size_t len, int *err_code, u08bits *err_msg, size_t err_msg_size); int stun_is_error_response_str(const uint8_t* buf, size_t len, int *err_code, uint8_t *err_msg, size_t err_msg_size);
int stun_is_challenge_response_str(const u08bits* buf, size_t len, int *err_code, u08bits *err_msg, size_t err_msg_size, u08bits *realm, u08bits *nonce, u08bits *server_name, int *oauth); int stun_is_challenge_response_str(const uint8_t* buf, size_t len, int *err_code, uint8_t *err_msg, size_t err_msg_size, uint8_t *realm, uint8_t *nonce, uint8_t *server_name, int *oauth);
int stun_is_response_str(const u08bits* buf, size_t len); int stun_is_response_str(const uint8_t* buf, size_t len);
int stun_is_indication_str(const u08bits* buf, size_t len); int stun_is_indication_str(const uint8_t* buf, size_t len);
u16bits stun_get_method_str(const u08bits *buf, size_t len); uint16_t stun_get_method_str(const uint8_t *buf, size_t len);
u16bits stun_get_msg_type_str(const u08bits *buf, size_t len); uint16_t stun_get_msg_type_str(const uint8_t *buf, size_t len);
int stun_is_channel_message_str(const u08bits *buf, size_t *blen, u16bits* chnumber, int mandatory_padding); int stun_is_channel_message_str(const uint8_t *buf, size_t *blen, uint16_t* chnumber, int mandatory_padding);
int is_channel_msg_str(const u08bits* buf, size_t blen); int is_channel_msg_str(const uint8_t* buf, size_t blen);
void stun_set_binding_request_str(u08bits* buf, size_t *len); void stun_set_binding_request_str(uint8_t* buf, size_t *len);
int stun_set_binding_response_str(u08bits* buf, size_t *len, stun_tid* tid, int stun_set_binding_response_str(uint8_t* buf, size_t *len, stun_tid* tid,
const ioa_addr *reflexive_addr, int error_code, const ioa_addr *reflexive_addr, int error_code,
const u08bits *reason, const uint8_t *reason,
u32bits cookie, int old_stun); uint32_t cookie, int old_stun);
int stun_is_binding_request_str(const u08bits* buf, size_t len, size_t offset); int stun_is_binding_request_str(const uint8_t* buf, size_t len, size_t offset);
int stun_is_binding_response_str(const u08bits* buf, size_t len); int stun_is_binding_response_str(const uint8_t* buf, size_t len);
void stun_tid_from_message_str(const u08bits* buf, size_t len, stun_tid* id); void stun_tid_from_message_str(const uint8_t* buf, size_t len, stun_tid* id);
void stun_tid_message_cpy(u08bits *buf, const stun_tid* id); void stun_tid_message_cpy(uint8_t *buf, const stun_tid* id);
void stun_tid_generate_in_message_str(u08bits* buf, stun_tid* id); void stun_tid_generate_in_message_str(uint8_t* buf, stun_tid* id);
int stun_get_command_message_len_str(const u08bits* buf, size_t len); int stun_get_command_message_len_str(const uint8_t* buf, size_t len);
const u08bits* get_default_reason(int error_code); const uint8_t* get_default_reason(int error_code);
int stun_attr_is_addr(stun_attr_ref attr); int stun_attr_is_addr(stun_attr_ref attr);
int stun_attr_get_type(stun_attr_ref attr); int stun_attr_get_type(stun_attr_ref attr);
int stun_attr_get_len(stun_attr_ref attr); int stun_attr_get_len(stun_attr_ref attr);
const u08bits* stun_attr_get_value(stun_attr_ref attr); const uint8_t* stun_attr_get_value(stun_attr_ref attr);
u16bits stun_attr_get_channel_number(stun_attr_ref attr); uint16_t stun_attr_get_channel_number(stun_attr_ref attr);
band_limit_t stun_attr_get_bandwidth(stun_attr_ref attr); band_limit_t stun_attr_get_bandwidth(stun_attr_ref attr);
u08bits stun_attr_get_even_port(stun_attr_ref attr); uint8_t stun_attr_get_even_port(stun_attr_ref attr);
u64bits stun_attr_get_reservation_token_value(stun_attr_ref attr); uint64_t stun_attr_get_reservation_token_value(stun_attr_ref attr);
stun_attr_ref stun_attr_get_first_by_type_str(const u08bits* buf, size_t len, u16bits attr_type); stun_attr_ref stun_attr_get_first_by_type_str(const uint8_t* buf, size_t len, uint16_t attr_type);
stun_attr_ref stun_attr_get_first_str(const u08bits* buf, size_t len); stun_attr_ref stun_attr_get_first_str(const uint8_t* buf, size_t len);
stun_attr_ref stun_attr_get_next_str(const u08bits* buf, size_t len, stun_attr_ref prev); stun_attr_ref stun_attr_get_next_str(const uint8_t* buf, size_t len, stun_attr_ref prev);
int stun_attr_add_str(u08bits* buf, size_t *len, u16bits attr, const u08bits* avalue, int alen); int stun_attr_add_str(uint8_t* buf, size_t *len, uint16_t attr, const uint8_t* avalue, int alen);
int stun_attr_add_addr_str(u08bits *buf, size_t *len, u16bits attr_type, const ioa_addr* ca); int stun_attr_add_addr_str(uint8_t *buf, size_t *len, uint16_t attr_type, const ioa_addr* ca);
int stun_attr_get_addr_str(const u08bits *buf, size_t len, stun_attr_ref attr, ioa_addr* ca, const ioa_addr *default_addr); int stun_attr_get_addr_str(const uint8_t *buf, size_t len, stun_attr_ref attr, ioa_addr* ca, const ioa_addr *default_addr);
int stun_attr_get_first_addr_str(const u08bits *buf, size_t len, u16bits attr_type, ioa_addr* ca, const ioa_addr *default_addr); int stun_attr_get_first_addr_str(const uint8_t *buf, size_t len, uint16_t attr_type, ioa_addr* ca, const ioa_addr *default_addr);
int stun_attr_add_channel_number_str(u08bits* buf, size_t *len, u16bits chnumber); int stun_attr_add_channel_number_str(uint8_t* buf, size_t *len, uint16_t chnumber);
int stun_attr_add_bandwidth_str(u08bits* buf, size_t *len, band_limit_t bps); int stun_attr_add_bandwidth_str(uint8_t* buf, size_t *len, band_limit_t bps);
int stun_attr_add_address_error_code(u08bits* buf, size_t *len, int requested_address_family, int error_code); int stun_attr_add_address_error_code(uint8_t* buf, size_t *len, int requested_address_family, int error_code);
/* return +1 if present, 0 if not, -1 if error: */ /* return +1 if present, 0 if not, -1 if error: */
int stun_attr_get_address_error_code(u08bits* buf, size_t len, int *requested_address_family, int *error_code); int stun_attr_get_address_error_code(uint8_t* buf, size_t len, int *requested_address_family, int *error_code);
u16bits stun_attr_get_first_channel_number_str(const u08bits *buf, size_t len); uint16_t stun_attr_get_first_channel_number_str(const uint8_t *buf, size_t len);
int stun_set_allocate_request_str(u08bits* buf, size_t *len, u32bits lifetime, int af4, int af6, u08bits transport, int mobile, const char* rt, int ep); int stun_set_allocate_request_str(uint8_t* buf, size_t *len, uint32_t lifetime, int af4, int af6, uint8_t transport, int mobile, const char* rt, int ep);
int stun_set_allocate_response_str(u08bits* buf, size_t *len, stun_tid* tid, int stun_set_allocate_response_str(uint8_t* buf, size_t *len, stun_tid* tid,
const ioa_addr *relayed_addr1, const ioa_addr *relayed_addr2, const ioa_addr *relayed_addr1, const ioa_addr *relayed_addr2,
const ioa_addr *reflexive_addr, const ioa_addr *reflexive_addr,
u32bits lifetime, u32bits max_lifetime, int error_code, const u08bits *reason, uint32_t lifetime, uint32_t max_lifetime, int error_code, const uint8_t *reason,
u64bits reservation_token, char *mobile_id); uint64_t reservation_token, char *mobile_id);
u16bits stun_set_channel_bind_request_str(u08bits* buf, size_t *len, uint16_t stun_set_channel_bind_request_str(uint8_t* buf, size_t *len,
const ioa_addr* peer_addr, u16bits channel_number); const ioa_addr* peer_addr, uint16_t channel_number);
void stun_set_channel_bind_response_str(u08bits* buf, size_t *len, stun_tid* tid, int error_code, const u08bits *reason); void stun_set_channel_bind_response_str(uint8_t* buf, size_t *len, stun_tid* tid, int error_code, const uint8_t *reason);
int stun_get_requested_address_family(stun_attr_ref attr); int stun_get_requested_address_family(stun_attr_ref attr);
int stun_attr_add_fingerprint_str(u08bits *buf, size_t *len); int stun_attr_add_fingerprint_str(uint8_t *buf, size_t *len);
int SASLprep(u08bits *s); int SASLprep(uint8_t *s);
#define print_bin(str, len, field) print_bin_func(str,len,field,__FUNCTION__) #define print_bin(str, len, field) print_bin_func(str,len,field,__FUNCTION__)
void print_bin_func(const char *name, size_t len, const void *s, const char *func); void print_bin_func(const char *name, size_t len, const void *s, const char *func);
@ -181,12 +181,12 @@ void print_bin_func(const char *name, size_t len, const void *s, const char *fun
/* /*
* Return -1 if failure, 0 if the integrity is not correct, 1 if OK * Return -1 if failure, 0 if the integrity is not correct, 1 if OK
*/ */
int stun_check_message_integrity_by_key_str(turn_credential_type ct, u08bits *buf, size_t len, hmackey_t key, password_t pwd, SHATYPE shatype); int stun_check_message_integrity_by_key_str(turn_credential_type ct, uint8_t *buf, size_t len, hmackey_t key, password_t pwd, SHATYPE shatype);
int stun_check_message_integrity_str(turn_credential_type ct, u08bits *buf, size_t len, u08bits *uname, u08bits *realm, u08bits *upwd, SHATYPE shatype); int stun_check_message_integrity_str(turn_credential_type ct, uint8_t *buf, size_t len, uint8_t *uname, uint8_t *realm, uint8_t *upwd, SHATYPE shatype);
int stun_attr_add_integrity_str(turn_credential_type ct, u08bits *buf, size_t *len, hmackey_t key, password_t pwd, SHATYPE shatype); int stun_attr_add_integrity_str(turn_credential_type ct, uint8_t *buf, size_t *len, hmackey_t key, password_t pwd, SHATYPE shatype);
int stun_attr_add_integrity_by_key_str(u08bits *buf, size_t *len, u08bits *uname, u08bits *realm, hmackey_t key, u08bits *nonce, SHATYPE shatype); int stun_attr_add_integrity_by_key_str(uint8_t *buf, size_t *len, uint8_t *uname, uint8_t *realm, hmackey_t key, uint8_t *nonce, SHATYPE shatype);
int stun_attr_add_integrity_by_user_str(u08bits *buf, size_t *len, u08bits *uname, u08bits *realm, u08bits *upwd, u08bits *nonce, SHATYPE shatype); int stun_attr_add_integrity_by_user_str(uint8_t *buf, size_t *len, uint8_t *uname, uint8_t *realm, uint8_t *upwd, uint8_t *nonce, SHATYPE shatype);
int stun_attr_add_integrity_by_user_short_term_str(u08bits *buf, size_t *len, u08bits *uname, password_t pwd, SHATYPE shatype); int stun_attr_add_integrity_by_user_short_term_str(uint8_t *buf, size_t *len, uint8_t *uname, password_t pwd, SHATYPE shatype);
size_t get_hmackey_size(SHATYPE shatype); size_t get_hmackey_size(SHATYPE shatype);
/* /*
@ -196,24 +196,24 @@ size_t get_hmackey_size(SHATYPE shatype);
#define TURN_RANDOM_SIZE (sizeof(long)) #define TURN_RANDOM_SIZE (sizeof(long))
long turn_random(void); long turn_random(void);
int stun_produce_integrity_key_str(u08bits *uname, u08bits *realm, u08bits *upwd, hmackey_t key, SHATYPE shatype); int stun_produce_integrity_key_str(uint8_t *uname, uint8_t *realm, uint8_t *upwd, hmackey_t key, SHATYPE shatype);
int stun_calculate_hmac(const u08bits *buf, size_t len, const u08bits *key, size_t sz, u08bits *hmac, unsigned int *hmac_len, SHATYPE shatype); int stun_calculate_hmac(const uint8_t *buf, size_t len, const uint8_t *key, size_t sz, uint8_t *hmac, unsigned int *hmac_len, SHATYPE shatype);
/* RFC 5780 */ /* RFC 5780 */
int stun_attr_get_change_request_str(stun_attr_ref attr, int *change_ip, int *change_port); int stun_attr_get_change_request_str(stun_attr_ref attr, int *change_ip, int *change_port);
int stun_attr_add_change_request_str(u08bits *buf, size_t *len, int change_ip, int change_port); int stun_attr_add_change_request_str(uint8_t *buf, size_t *len, int change_ip, int change_port);
int stun_attr_get_response_port_str(stun_attr_ref attr); int stun_attr_get_response_port_str(stun_attr_ref attr);
int stun_attr_add_response_port_str(u08bits *buf, size_t *len, u16bits port); int stun_attr_add_response_port_str(uint8_t *buf, size_t *len, uint16_t port);
int stun_attr_get_padding_len_str(stun_attr_ref attr); int stun_attr_get_padding_len_str(stun_attr_ref attr);
int stun_attr_add_padding_str(u08bits *buf, size_t *len, u16bits padding_len); int stun_attr_add_padding_str(uint8_t *buf, size_t *len, uint16_t padding_len);
/* HTTP */ /* HTTP */
int is_http(const char *s, size_t blen); int is_http(const char *s, size_t blen);
/* OAUTH */ /* OAUTH */
int convert_oauth_key_data(const oauth_key_data *oakd, oauth_key *key, char *err_msg, size_t err_msg_size); int convert_oauth_key_data(const oauth_key_data *oakd, oauth_key *key, char *err_msg, size_t err_msg_size);
int decode_oauth_token(const u08bits *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken); int decode_oauth_token(const uint8_t *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken);
int encode_oauth_token(const u08bits *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken, const u08bits *nonce); int encode_oauth_token(const uint8_t *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken, const uint8_t *nonce);
/* Encrypted password */ /* Encrypted password */
void generate_new_enc_password(const char* pwd, char *result); void generate_new_enc_password(const char* pwd, char *result);

View File

@ -32,7 +32,7 @@
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
int stun_addr_encode(const ioa_addr* ca, u08bits *cfield, int *clen, int xor_ed, u32bits mc, const u08bits *tsx_id) { int stun_addr_encode(const ioa_addr* ca, uint8_t *cfield, int *clen, int xor_ed, uint32_t mc, const uint8_t *tsx_id) {
if(!cfield || !clen || !ca || !tsx_id) return -1; if(!cfield || !clen || !ca || !tsx_id) return -1;
@ -48,18 +48,18 @@ int stun_addr_encode(const ioa_addr* ca, u08bits *cfield, int *clen, int xor_ed,
if (xor_ed) { if (xor_ed) {
/* Port */ /* Port */
((u16bits*)cfield)[1] = (ca->s4.sin_port) ^ nswap16(mc >> 16); ((uint16_t*)cfield)[1] = (ca->s4.sin_port) ^ nswap16(mc >> 16);
/* Address */ /* Address */
((u32bits*)cfield)[1] = (ca->s4.sin_addr.s_addr) ^ nswap32(mc); ((uint32_t*)cfield)[1] = (ca->s4.sin_addr.s_addr) ^ nswap32(mc);
} else { } else {
/* Port */ /* Port */
((u16bits*)cfield)[1]=ca->s4.sin_port; ((uint16_t*)cfield)[1]=ca->s4.sin_port;
/* Address */ /* Address */
((u32bits*)cfield)[1]=ca->s4.sin_addr.s_addr; ((uint32_t*)cfield)[1]=ca->s4.sin_addr.s_addr;
} }
} else if (ca->ss.sa_family == AF_INET6) { } else if (ca->ss.sa_family == AF_INET6) {
@ -74,29 +74,29 @@ int stun_addr_encode(const ioa_addr* ca, u08bits *cfield, int *clen, int xor_ed,
if (xor_ed) { if (xor_ed) {
unsigned int i; unsigned int i;
u08bits *dst = ((u08bits*)cfield)+4; uint8_t *dst = ((uint8_t*)cfield)+4;
const u08bits *src = (const u08bits*)&(ca->s6.sin6_addr); const uint8_t *src = (const uint8_t*)&(ca->s6.sin6_addr);
u32bits magic = nswap32(mc); uint32_t magic = nswap32(mc);
/* Port */ /* Port */
((u16bits*)cfield)[1] = ca->s6.sin6_port ^ nswap16(mc >> 16); ((uint16_t*)cfield)[1] = ca->s6.sin6_port ^ nswap16(mc >> 16);
/* Address */ /* Address */
for (i=0; i<4; ++i) { for (i=0; i<4; ++i) {
dst[i] = (u08bits)(src[i] ^ ((const u08bits*)&magic)[i]); dst[i] = (uint8_t)(src[i] ^ ((const uint8_t*)&magic)[i]);
} }
for (i=0; i<12; ++i) { for (i=0; i<12; ++i) {
dst[i+4] = (u08bits)(src[i+4] ^ tsx_id[i]); dst[i+4] = (uint8_t)(src[i+4] ^ tsx_id[i]);
} }
} else { } else {
/* Port */ /* Port */
((u16bits*)cfield)[1]=ca->s6.sin6_port; ((uint16_t*)cfield)[1]=ca->s6.sin6_port;
/* Address */ /* Address */
bcopy(&ca->s6.sin6_addr, ((u08bits*)cfield)+4, 16); bcopy(&ca->s6.sin6_addr, ((uint8_t*)cfield)+4, 16);
} }
} else { } else {
@ -106,7 +106,7 @@ int stun_addr_encode(const ioa_addr* ca, u08bits *cfield, int *clen, int xor_ed,
return 0; return 0;
} }
int stun_addr_decode(ioa_addr* ca, const u08bits *cfield, int len, int xor_ed, u32bits mc, const u08bits *tsx_id) { int stun_addr_decode(ioa_addr* ca, const uint8_t *cfield, int len, int xor_ed, uint32_t mc, const uint8_t *tsx_id) {
if(!cfield || !len || !ca || !tsx_id || (len<8)) return -1; if(!cfield || !len || !ca || !tsx_id || (len<8)) return -1;
@ -129,10 +129,10 @@ int stun_addr_decode(ioa_addr* ca, const u08bits *cfield, int len, int xor_ed, u
/* IPv4 address */ /* IPv4 address */
/* Port */ /* Port */
ca->s4.sin_port=((const u16bits*)cfield)[1]; ca->s4.sin_port=((const uint16_t*)cfield)[1];
/* Address */ /* Address */
ca->s4.sin_addr.s_addr=((const u32bits*)cfield)[1]; ca->s4.sin_addr.s_addr=((const uint32_t*)cfield)[1];
if (xor_ed) { if (xor_ed) {
ca->s4.sin_port ^= nswap16(mc >> 16); ca->s4.sin_port ^= nswap16(mc >> 16);
@ -146,29 +146,29 @@ int stun_addr_decode(ioa_addr* ca, const u08bits *cfield, int len, int xor_ed, u
if(len!=20) return -1; if(len!=20) return -1;
/* Port */ /* Port */
ca->s6.sin6_port = ((const u16bits*)cfield)[1]; ca->s6.sin6_port = ((const uint16_t*)cfield)[1];
/* Address */ /* Address */
bcopy(((const u08bits*)cfield)+4, &ca->s6.sin6_addr, 16); bcopy(((const uint8_t*)cfield)+4, &ca->s6.sin6_addr, 16);
if (xor_ed) { if (xor_ed) {
unsigned int i; unsigned int i;
u08bits *dst; uint8_t *dst;
const u08bits *src; const uint8_t *src;
u32bits magic = nswap32(mc); uint32_t magic = nswap32(mc);
/* Port */ /* Port */
ca->s6.sin6_port ^= nswap16(mc >> 16); ca->s6.sin6_port ^= nswap16(mc >> 16);
/* Address */ /* Address */
src = ((const u08bits*)cfield)+4; src = ((const uint8_t*)cfield)+4;
dst = (u08bits*)&ca->s6.sin6_addr; dst = (uint8_t*)&ca->s6.sin6_addr;
for (i=0; i<4; ++i) { for (i=0; i<4; ++i) {
dst[i] = (u08bits)(src[i] ^ ((const u08bits*)&magic)[i]); dst[i] = (uint8_t)(src[i] ^ ((const uint8_t*)&magic)[i]);
} }
for (i=0; i<12; ++i) { for (i=0; i<12; ++i) {
dst[i+4] = (u08bits)(src[i+4] ^ tsx_id[i]); dst[i+4] = (uint8_t)(src[i+4] ^ tsx_id[i]);
} }
} }

View File

@ -39,8 +39,8 @@ extern "C" {
/////////////////////////////////////////// ///////////////////////////////////////////
int stun_addr_encode(const ioa_addr* ca, u08bits *cfield, int *clen, int xor_ed, u32bits mc, const u08bits *tsx_id); int stun_addr_encode(const ioa_addr* ca, uint8_t *cfield, int *clen, int xor_ed, uint32_t mc, const uint8_t *tsx_id);
int stun_addr_decode(ioa_addr* ca, const u08bits *cfield, int len, int xor_ed, u32bits mc, const u08bits *tsx_id); int stun_addr_decode(ioa_addr* ca, const uint8_t *cfield, int len, int xor_ed, uint32_t mc, const uint8_t *tsx_id);
/////////////////////////////////////////// ///////////////////////////////////////////

View File

@ -46,6 +46,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <net/if.h> #include <net/if.h>
#include <ctype.h> #include <ctype.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -60,29 +61,17 @@
extern "C" { extern "C" {
#endif #endif
/* NS types: */
#define s08bits char
#define s16bits int16_t
#define s32bits int32_t
#define s64bits int64_t
#define u08bits unsigned char
#define u16bits uint16_t
#define u32bits uint32_t
#define u64bits uint64_t
#define nswap16(s) ntohs(s) #define nswap16(s) ntohs(s)
#define nswap32(ul) ntohl(ul) #define nswap32(ul) ntohl(ul)
#define nswap64(ull) ioa_ntoh64(ull) #define nswap64(ull) ioa_ntoh64(ull)
static inline u64bits _ioa_ntoh64(u64bits v) static inline uint64_t _ioa_ntoh64(uint64_t v)
{ {
#if BYTE_ORDER == LITTLE_ENDIAN #if BYTE_ORDER == LITTLE_ENDIAN
u08bits *src = (u08bits*) &v; uint8_t *src = (uint8_t*) &v;
u08bits* dst = src + 7; uint8_t* dst = src + 7;
while (src < dst) { while (src < dst) {
u08bits vdst = *dst; uint8_t vdst = *dst;
*(dst--) = *src; *(dst--) = *src;
*(src++) = vdst; *(src++) = vdst;
} }
@ -112,9 +101,9 @@ static inline u64bits _ioa_ntoh64(u64bits v)
typedef int vint; typedef int vint;
typedef vint* vintp; typedef vint* vintp;
typedef u32bits turn_time_t; typedef uint32_t turn_time_t;
#define turn_time_before(t1,t2) ((((s32bits)(t1))-((s32bits)(t2))) < 0) #define turn_time_before(t1,t2) ((((int32_t)(t1))-((int32_t)(t2))) < 0)
#if !defined(UNUSED_ARG) #if !defined(UNUSED_ARG)
#define UNUSED_ARG(A) do { A=A; } while(0) #define UNUSED_ARG(A) do { A=A; } while(0)

View File

@ -174,7 +174,7 @@ void turn_permission_clean(turn_permission_info* tinfo)
if(tinfo->verbose) { if(tinfo->verbose) {
char s[257]="\0"; char s[257]="\0";
addr_to_string(&(tinfo->addr),(u08bits*)s); addr_to_string(&(tinfo->addr),(uint8_t*)s);
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "session %018llu: peer %s deleted\n",tinfo->session_id,s); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "session %018llu: peer %s deleted\n",tinfo->session_id,s);
} }
@ -238,7 +238,7 @@ static turn_permission_info* get_from_turn_permission_hashtable(turn_permission_
if (!addr || !map) if (!addr || !map)
return NULL; return NULL;
u32bits index = addr_hash_no_port(addr) & (TURN_PERMISSION_HASHTABLE_SIZE-1); uint32_t index = addr_hash_no_port(addr) & (TURN_PERMISSION_HASHTABLE_SIZE-1);
turn_permission_array *parray = &(map->table[index]); turn_permission_array *parray = &(map->table[index]);
{ {
@ -300,7 +300,7 @@ void turn_channel_delete(ch_info* chn)
int port = addr_get_port(&(chn->peer_addr)); int port = addr_get_port(&(chn->peer_addr));
if(port<1) { if(port<1) {
char s[129]; char s[129];
addr_to_string(&(chn->peer_addr),(u08bits*)s); addr_to_string(&(chn->peer_addr),(uint8_t*)s);
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "!!! %s: strange (1) channel to be cleaned: port is empty: %s\n",__FUNCTION__,s); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "!!! %s: strange (1) channel to be cleaned: port is empty: %s\n",__FUNCTION__,s);
} }
{ {
@ -315,7 +315,7 @@ void turn_channel_delete(ch_info* chn)
} }
} }
ch_info* allocation_get_new_ch_info(allocation* a, u16bits chnum, ioa_addr* peer_addr) ch_info* allocation_get_new_ch_info(allocation* a, uint16_t chnum, ioa_addr* peer_addr)
{ {
turn_permission_info* tinfo = get_from_turn_permission_hashtable(&(a->addr_to_perm), peer_addr); turn_permission_info* tinfo = get_from_turn_permission_hashtable(&(a->addr_to_perm), peer_addr);
@ -336,7 +336,7 @@ ch_info* allocation_get_new_ch_info(allocation* a, u16bits chnum, ioa_addr* peer
return chn; return chn;
} }
ch_info* allocation_get_ch_info(allocation* a, u16bits chnum) { ch_info* allocation_get_ch_info(allocation* a, uint16_t chnum) {
return ch_map_get(&(a->chns), chnum, 0); return ch_map_get(&(a->chns), chnum, 0);
} }
@ -348,7 +348,7 @@ ch_info* allocation_get_ch_info_by_peer_addr(allocation* a, ioa_addr* peer_addr)
return NULL; return NULL;
} }
u16bits get_turn_channel_number(turn_permission_info* tinfo, ioa_addr *addr) uint16_t get_turn_channel_number(turn_permission_info* tinfo, ioa_addr *addr)
{ {
if (tinfo) { if (tinfo) {
ur_map_value_type t = 0; ur_map_value_type t = 0;
@ -388,7 +388,7 @@ turn_permission_info* allocation_add_permission(allocation *a, const ioa_addr* a
if (a && addr) { if (a && addr) {
turn_permission_hashtable *map = &(a->addr_to_perm); turn_permission_hashtable *map = &(a->addr_to_perm);
u32bits hash = addr_hash_no_port(addr); uint32_t hash = addr_hash_no_port(addr);
size_t fds = (size_t) (hash & (TURN_PERMISSION_HASHTABLE_SIZE-1)); size_t fds = (size_t) (hash & (TURN_PERMISSION_HASHTABLE_SIZE-1));
turn_permission_array *parray = &(map->table[fds]); turn_permission_array *parray = &(map->table[fds]);
@ -448,7 +448,7 @@ turn_permission_info* allocation_add_permission(allocation *a, const ioa_addr* a
} }
} }
ch_info *ch_map_get(ch_map* map, u16bits chnum, int new_chn) ch_info *ch_map_get(ch_map* map, uint16_t chnum, int new_chn)
{ {
ch_info *ret = NULL; ch_info *ret = NULL;
if(map) { if(map) {
@ -535,16 +535,16 @@ void ch_map_clean(ch_map* map)
////////////////// TCP connections /////////////////////////////// ////////////////// TCP connections ///////////////////////////////
static void set_new_tc_id(u08bits server_id, tcp_connection *tc) { static void set_new_tc_id(uint8_t server_id, tcp_connection *tc) {
allocation *a = (allocation*)(tc->owner); allocation *a = (allocation*)(tc->owner);
ur_map *map = a->tcp_connections; ur_map *map = a->tcp_connections;
u32bits newid; uint32_t newid;
u32bits sid = server_id; uint32_t sid = server_id;
sid = sid<<24; sid = sid<<24;
do { do {
newid = 0; newid = 0;
while (!newid) { while (!newid) {
newid = (u32bits)turn_random(); newid = (uint32_t)turn_random();
if(!newid) { if(!newid) {
continue; continue;
} }
@ -559,7 +559,7 @@ static void set_new_tc_id(u08bits server_id, tcp_connection *tc) {
ur_map_put(map, (ur_map_key_type)newid, (ur_map_value_type)tc); ur_map_put(map, (ur_map_key_type)newid, (ur_map_value_type)tc);
} }
tcp_connection *create_tcp_connection(u08bits server_id, allocation *a, stun_tid *tid, ioa_addr *peer_addr, int *err_code) tcp_connection *create_tcp_connection(uint8_t server_id, allocation *a, stun_tid *tid, ioa_addr *peer_addr, int *err_code)
{ {
tcp_connection_list *tcl = &(a->tcs); tcp_connection_list *tcl = &(a->tcs);
if(tcl->elems) { if(tcl->elems) {

View File

@ -75,7 +75,7 @@ enum _TC_STATE {
typedef enum _TC_STATE TC_STATE; typedef enum _TC_STATE TC_STATE;
typedef u32bits tcp_connection_id; typedef uint32_t tcp_connection_id;
typedef struct { typedef struct {
size_t sz; size_t sz;
@ -110,9 +110,9 @@ typedef struct _tcp_connection_list {
struct _allocation; struct _allocation;
typedef struct _ch_info { typedef struct _ch_info {
u16bits chnum; uint16_t chnum;
int allocated; int allocated;
u16bits port; uint16_t port;
ioa_addr peer_addr; ioa_addr peer_addr;
turn_time_t expiration_time; turn_time_t expiration_time;
ioa_timer_handle lifetime_ev; ioa_timer_handle lifetime_ev;
@ -135,7 +135,7 @@ typedef struct _ch_map {
ch_map_array table[CH_MAP_HASH_SIZE]; ch_map_array table[CH_MAP_HASH_SIZE];
} ch_map; } ch_map;
ch_info *ch_map_get(ch_map* map, u16bits chnum, int new_chn); ch_info *ch_map_get(ch_map* map, uint16_t chnum, int new_chn);
void ch_map_clean(ch_map* map); void ch_map_clean(ch_map* map);
//////////////////////////// ////////////////////////////
@ -187,7 +187,7 @@ typedef struct _allocation {
//////////// CHANNELS //////////////////// //////////// CHANNELS ////////////////////
u16bits get_turn_channel_number(turn_permission_info* tinfo, ioa_addr *addr); uint16_t get_turn_channel_number(turn_permission_info* tinfo, ioa_addr *addr);
ch_info *get_turn_channel(turn_permission_info* tinfo, ioa_addr *addr); ch_info *get_turn_channel(turn_permission_info* tinfo, ioa_addr *addr);
void turn_channel_delete(ch_info* chn); void turn_channel_delete(ch_info* chn);
@ -206,8 +206,8 @@ turn_permission_info* allocation_get_permission(allocation* a, const ioa_addr *a
turn_permission_hashtable* allocation_get_turn_permission_hashtable(allocation *a); turn_permission_hashtable* allocation_get_turn_permission_hashtable(allocation *a);
turn_permission_info* allocation_add_permission(allocation *a, const ioa_addr* addr); turn_permission_info* allocation_add_permission(allocation *a, const ioa_addr* addr);
ch_info* allocation_get_new_ch_info(allocation* a, u16bits chnum, ioa_addr* peer_addr); ch_info* allocation_get_new_ch_info(allocation* a, uint16_t chnum, ioa_addr* peer_addr);
ch_info* allocation_get_ch_info(allocation* a, u16bits chnum); ch_info* allocation_get_ch_info(allocation* a, uint16_t chnum);
ch_info* allocation_get_ch_info_by_peer_addr(allocation* a, ioa_addr* peer_addr); ch_info* allocation_get_ch_info_by_peer_addr(allocation* a, ioa_addr* peer_addr);
relay_endpoint_session *get_relay_session(allocation *a, int family); relay_endpoint_session *get_relay_session(allocation *a, int family);
@ -220,7 +220,7 @@ tcp_connection *get_and_clean_tcp_connection_by_id(ur_map *map, tcp_connection_i
tcp_connection *get_tcp_connection_by_id(ur_map *map, tcp_connection_id id); tcp_connection *get_tcp_connection_by_id(ur_map *map, tcp_connection_id id);
tcp_connection *get_tcp_connection_by_peer(allocation *a, ioa_addr *peer_addr); tcp_connection *get_tcp_connection_by_peer(allocation *a, ioa_addr *peer_addr);
int can_accept_tcp_connection_from_peer(allocation *a, ioa_addr *peer_addr, int server_relay); int can_accept_tcp_connection_from_peer(allocation *a, ioa_addr *peer_addr, int server_relay);
tcp_connection *create_tcp_connection(u08bits server_id, allocation *a, stun_tid *tid, ioa_addr *peer_addr, int *err_code); tcp_connection *create_tcp_connection(uint8_t server_id, allocation *a, stun_tid *tid, ioa_addr *peer_addr, int *err_code);
void delete_tcp_connection(tcp_connection *tc); void delete_tcp_connection(tcp_connection *tc);
void clear_unsent_buffer(unsent_buffer *ub); void clear_unsent_buffer(unsent_buffer *ub);

View File

@ -53,7 +53,7 @@ typedef struct _tcp_connection tcp_connection;
////////////// Mutexes ///////////////////// ////////////// Mutexes /////////////////////
struct _turn_mutex { struct _turn_mutex {
u32bits data; uint32_t data;
void* mutex; void* mutex;
}; };
@ -172,14 +172,14 @@ const ip_range_list_t* ioa_get_blacklist(ioa_engine_handle e);
*/ */
ioa_network_buffer_handle ioa_network_buffer_allocate(ioa_engine_handle e); ioa_network_buffer_handle ioa_network_buffer_allocate(ioa_engine_handle e);
void ioa_network_buffer_header_init(ioa_network_buffer_handle nbh); void ioa_network_buffer_header_init(ioa_network_buffer_handle nbh);
u08bits *ioa_network_buffer_data(ioa_network_buffer_handle nbh); uint8_t *ioa_network_buffer_data(ioa_network_buffer_handle nbh);
size_t ioa_network_buffer_get_size(ioa_network_buffer_handle nbh); size_t ioa_network_buffer_get_size(ioa_network_buffer_handle nbh);
size_t ioa_network_buffer_get_capacity(ioa_network_buffer_handle nbh); size_t ioa_network_buffer_get_capacity(ioa_network_buffer_handle nbh);
size_t ioa_network_buffer_get_capacity_udp(void); size_t ioa_network_buffer_get_capacity_udp(void);
void ioa_network_buffer_set_size(ioa_network_buffer_handle nbh, size_t len); void ioa_network_buffer_set_size(ioa_network_buffer_handle nbh, size_t len);
void ioa_network_buffer_add_offset_size(ioa_network_buffer_handle nbh, u16bits offset, u08bits coffset, size_t len); void ioa_network_buffer_add_offset_size(ioa_network_buffer_handle nbh, uint16_t offset, uint8_t coffset, size_t len);
u16bits ioa_network_buffer_get_offset(ioa_network_buffer_handle nbh); uint16_t ioa_network_buffer_get_offset(ioa_network_buffer_handle nbh);
u08bits ioa_network_buffer_get_coffset(ioa_network_buffer_handle nbh); uint8_t ioa_network_buffer_get_coffset(ioa_network_buffer_handle nbh);
void ioa_network_buffer_delete(ioa_engine_handle e, ioa_network_buffer_handle nbh); void ioa_network_buffer_delete(ioa_engine_handle e, ioa_network_buffer_handle nbh);
/* /*
@ -204,7 +204,7 @@ typedef void (*ioa_timer_event_handler)(ioa_engine_handle e, void *ctx);
/* timers */ /* timers */
ioa_timer_handle set_ioa_timer(ioa_engine_handle e, int secs, int ms, ioa_timer_event_handler cb, void *ctx, int persist, const s08bits *txt); ioa_timer_handle set_ioa_timer(ioa_engine_handle e, int secs, int ms, ioa_timer_event_handler cb, void *ctx, int persist, const char *txt);
void stop_ioa_timer(ioa_timer_handle th); void stop_ioa_timer(ioa_timer_handle th);
void delete_ioa_timer(ioa_timer_handle th); void delete_ioa_timer(ioa_timer_handle th);
#define IOA_EVENT_DEL(E) do { if(E) { delete_ioa_timer(E); E = NULL; } } while(0) #define IOA_EVENT_DEL(E) do { if(E) { delete_ioa_timer(E); E = NULL; } } while(0)
@ -220,14 +220,14 @@ void inc_ioa_socket_ref_counter(ioa_socket_handle s);
* even_port == +1: reserve and bind rtcp. * even_port == +1: reserve and bind rtcp.
*/ */
int create_relay_ioa_sockets(ioa_engine_handle e, ioa_socket_handle client_s, int create_relay_ioa_sockets(ioa_engine_handle e, ioa_socket_handle client_s,
int address_family, u08bits transport, int address_family, uint8_t transport,
int even_port, ioa_socket_handle *rtp_s, ioa_socket_handle *rtcp_s, int even_port, ioa_socket_handle *rtp_s, ioa_socket_handle *rtcp_s,
u64bits *out_reservation_token, int *err_code, const u08bits **reason, uint64_t *out_reservation_token, int *err_code, const uint8_t **reason,
accept_cb acb, void *acbarg); accept_cb acb, void *acbarg);
ioa_socket_handle ioa_create_connecting_tcp_relay_socket(ioa_socket_handle s, ioa_addr *peer_addr, connect_cb cb, void *arg); ioa_socket_handle ioa_create_connecting_tcp_relay_socket(ioa_socket_handle s, ioa_addr *peer_addr, connect_cb cb, void *arg);
int get_ioa_socket_from_reservation(ioa_engine_handle e, u64bits in_reservation_token, ioa_socket_handle *s); int get_ioa_socket_from_reservation(ioa_engine_handle e, uint64_t in_reservation_token, ioa_socket_handle *s);
int get_ioa_socket_address_family(ioa_socket_handle s); int get_ioa_socket_address_family(ioa_socket_handle s);
int is_stream_socket(int st); int is_stream_socket(int st);

View File

@ -32,7 +32,7 @@
An example: An example:
#include "khash.h" #include "khash.h"
KHASH_MAP_INIT_INT(32, s08bits) KHASH_MAP_INIT_INT(32, char)
int main() { int main() {
int ret, is_missing; int ret, is_missing;
khiter_t k; khiter_t k;
@ -87,16 +87,16 @@ int main() {
#include "ns_turn_defs.h" #include "ns_turn_defs.h"
typedef u32bits khint_t; typedef uint32_t khint_t;
typedef khint_t khiter_t; typedef khint_t khiter_t;
typedef struct _str_chunk_t { typedef struct _str_chunk_t {
const s08bits *str; const char *str;
size_t len; size_t len;
} str_chunk_t; } str_chunk_t;
#define __ac_HASH_PRIME_SIZE 32 #define __ac_HASH_PRIME_SIZE 32
static const u32bits __ac_prime_list[__ac_HASH_PRIME_SIZE] = static const uint32_t __ac_prime_list[__ac_HASH_PRIME_SIZE] =
{ {
0ul, 3ul, 11ul, 23ul, 53ul, 0ul, 3ul, 11ul, 23ul, 53ul,
97ul, 193ul, 389ul, 769ul, 1543ul, 97ul, 193ul, 389ul, 769ul, 1543ul,
@ -120,9 +120,9 @@ static const double __ac_HASH_UPPER = 0.77;
#define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \ #define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
typedef struct { \ typedef struct { \
khint_t n_buckets, size, n_occupied, upper_bound; \ khint_t n_buckets, size, n_occupied, upper_bound; \
u32bits *flags; u32bits flags_size; \ uint32_t *flags; uint32_t flags_size; \
khkey_t *keys; u32bits keys_size; \ khkey_t *keys; uint32_t keys_size; \
khval_t *vals; u32bits vals_size; \ khval_t *vals; uint32_t vals_size; \
} kh_##name##_t; \ } kh_##name##_t; \
static inline kh_##name##_t *kh_init_##name(void) { \ static inline kh_##name##_t *kh_init_##name(void) { \
return (kh_##name##_t*)calloc(1, sizeof(kh_##name##_t)); \ return (kh_##name##_t*)calloc(1, sizeof(kh_##name##_t)); \
@ -138,7 +138,7 @@ static const double __ac_HASH_UPPER = 0.77;
static inline void kh_clear_##name(kh_##name##_t *h) \ static inline void kh_clear_##name(kh_##name##_t *h) \
{ \ { \
if (h && h->flags) { \ if (h && h->flags) { \
memset(h->flags, 0xaa, ((h->n_buckets>>4) + 1) * sizeof(u32bits)); \ memset(h->flags, 0xaa, ((h->n_buckets>>4) + 1) * sizeof(uint32_t)); \
h->size = h->n_occupied = 0; \ h->size = h->n_occupied = 0; \
} \ } \
} \ } \
@ -158,8 +158,8 @@ static const double __ac_HASH_UPPER = 0.77;
} \ } \
static inline void kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \ static inline void kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \
{ \ { \
u32bits *new_flags = 0; \ uint32_t *new_flags = 0; \
u32bits new_flags_size = 0; \ uint32_t new_flags_size = 0; \
khint_t j = 1; \ khint_t j = 1; \
{ \ { \
khint_t t = __ac_HASH_PRIME_SIZE - 1; \ khint_t t = __ac_HASH_PRIME_SIZE - 1; \
@ -167,8 +167,8 @@ static const double __ac_HASH_UPPER = 0.77;
new_n_buckets = __ac_prime_list[t+1]; \ new_n_buckets = __ac_prime_list[t+1]; \
if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0; \ if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0; \
else { \ else { \
new_flags_size = ((new_n_buckets>>4) + 1) * sizeof(u32bits); \ new_flags_size = ((new_n_buckets>>4) + 1) * sizeof(uint32_t); \
new_flags = (u32bits*)malloc(new_flags_size); \ new_flags = (uint32_t*)malloc(new_flags_size); \
memset(new_flags, 0xaa, new_flags_size); \ memset(new_flags, 0xaa, new_flags_size); \
if (h->n_buckets < new_n_buckets) { \ if (h->n_buckets < new_n_buckets) { \
h->keys = (khkey_t*)realloc(h->keys, new_n_buckets * sizeof(khkey_t)); \ h->keys = (khkey_t*)realloc(h->keys, new_n_buckets * sizeof(khkey_t)); \
@ -273,12 +273,12 @@ static const double __ac_HASH_UPPER = 0.77;
/* --- BEGIN OF HASH FUNCTIONS --- */ /* --- BEGIN OF HASH FUNCTIONS --- */
#define kh_int_hash_func(key) (u32bits)((key<<3) + nswap32(key>>7)) #define kh_int_hash_func(key) (uint32_t)((key<<3) + nswap32(key>>7))
#define kh_int_hash_equal(a, b) (a == b) #define kh_int_hash_equal(a, b) (a == b)
#define kh_int64_hash_func(key) (u32bits)((key)>>33^(key)^(key)<<11) #define kh_int64_hash_func(key) (uint32_t)((key)>>33^(key)^(key)<<11)
#define kh_int64_hash_equal(a, b) (a == b) #define kh_int64_hash_equal(a, b) (a == b)
static inline khint_t __ac_X31_hash_string(const s08bits *s) static inline khint_t __ac_X31_hash_string(const char *s)
{ {
khint_t h = *s; khint_t h = *s;
if (h) if (h)
@ -286,7 +286,7 @@ static inline khint_t __ac_X31_hash_string(const s08bits *s)
h = (h << 5) - h + *s; h = (h << 5) - h + *s;
return h; return h;
} }
static inline khint_t __ac_X31_hash_cstring(const s08bits *s) static inline khint_t __ac_X31_hash_cstring(const char *s)
{ {
khint_t h = tolower((int)*s); khint_t h = tolower((int)*s);
if (h) if (h)
@ -349,39 +349,39 @@ static inline khint_t __ac_X31_hash_ncstring(const str_chunk_t *s)
/* More convenient interfaces */ /* More convenient interfaces */
#define KHASH_SET_INIT_INT(name) \ #define KHASH_SET_INIT_INT(name) \
KHASH_INIT(name, u32bits, s08bits, 0, kh_int_hash_func, kh_int_hash_equal) KHASH_INIT(name, uint32_t, char, 0, kh_int_hash_func, kh_int_hash_equal)
#define KHASH_MAP_INIT_INT(name, khval_t) \ #define KHASH_MAP_INIT_INT(name, khval_t) \
KHASH_INIT(name, u32bits, khval_t, 1, kh_int_hash_func, kh_int_hash_equal) KHASH_INIT(name, uint32_t, khval_t, 1, kh_int_hash_func, kh_int_hash_equal)
#define KHASH_SET_INIT_INT64(name) \ #define KHASH_SET_INIT_INT64(name) \
KHASH_INIT(name, u64bits, s08bits, 0, kh_int64_hash_func, kh_int64_hash_equal) KHASH_INIT(name, uint64_t, char, 0, kh_int64_hash_func, kh_int64_hash_equal)
#define KHASH_MAP_INIT_INT64(name, khval_t) \ #define KHASH_MAP_INIT_INT64(name, khval_t) \
KHASH_INIT(name, u64bits, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal) KHASH_INIT(name, uint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
typedef const s08bits *kh_cstr_t; typedef const char *kh_cstr_t;
typedef const str_chunk_t *kh_ncstr_t; typedef const str_chunk_t *kh_ncstr_t;
#define KHASH_SET_INIT_STR(name) \ #define KHASH_SET_INIT_STR(name) \
KHASH_INIT(name, kh_cstr_t, s08bits, 0, kh_str_hash_func, kh_str_hash_equal) KHASH_INIT(name, kh_cstr_t, char, 0, kh_str_hash_func, kh_str_hash_equal)
#define KHASH_MAP_INIT_STR(name, khval_t) \ #define KHASH_MAP_INIT_STR(name, khval_t) \
KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_str_hash_func, kh_str_hash_equal) KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_str_hash_func, kh_str_hash_equal)
#define KHASH_SET_INIT_CSTR(name) \ #define KHASH_SET_INIT_CSTR(name) \
KHASH_INIT(name, kh_cstr_t, s08bits, 0, kh_cstr_hash_func, kh_cstr_hash_equal) KHASH_INIT(name, kh_cstr_t, char, 0, kh_cstr_hash_func, kh_cstr_hash_equal)
#define KHASH_MAP_INIT_CSTR(name, khval_t) \ #define KHASH_MAP_INIT_CSTR(name, khval_t) \
KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_cstr_hash_func, kh_cstr_hash_equal) KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_cstr_hash_func, kh_cstr_hash_equal)
#define KHASH_SET_INIT_NSTR(name) \ #define KHASH_SET_INIT_NSTR(name) \
KHASH_INIT(name, kh_ncstr_t, s08bits, 0, kh_nstr_hash_func, kh_nstr_hash_equal) KHASH_INIT(name, kh_ncstr_t, char, 0, kh_nstr_hash_func, kh_nstr_hash_equal)
#define KHASH_MAP_INIT_NSTR(name, khval_t) \ #define KHASH_MAP_INIT_NSTR(name, khval_t) \
KHASH_INIT(name, kh_ncstr_t, khval_t, 1, kh_nstr_hash_func, kh_nstr_hash_equal) KHASH_INIT(name, kh_ncstr_t, khval_t, 1, kh_nstr_hash_func, kh_nstr_hash_equal)
#define KHASH_SET_INIT_NCSTR(name) \ #define KHASH_SET_INIT_NCSTR(name) \
KHASH_INIT(name, kh_ncstr_t, s08bits, 0, kh_ncstr_hash_func, kh_ncstr_hash_equal) KHASH_INIT(name, kh_ncstr_t, char, 0, kh_ncstr_hash_func, kh_ncstr_hash_equal)
#define KHASH_MAP_INIT_NCSTR(name, khval_t) \ #define KHASH_MAP_INIT_NCSTR(name, khval_t) \
KHASH_INIT(name, kh_ncstr_t, khval_t, 1, kh_ncstr_hash_func, kh_ncstr_hash_equal) KHASH_INIT(name, kh_ncstr_t, khval_t, 1, kh_ncstr_hash_func, kh_ncstr_hash_equal)

View File

@ -36,11 +36,11 @@
KHASH_MAP_INIT_INT64(3, ur_map_value_type) KHASH_MAP_INIT_INT64(3, ur_map_value_type)
#define MAGIC_HASH ((u64bits)(0x90ABCDEFL)) #define MAGIC_HASH ((uint64_t)(0x90ABCDEFL))
struct _ur_map { struct _ur_map {
khash_t(3) *h; khash_t(3) *h;
u64bits magic; uint64_t magic;
TURN_MUTEX_DECLARE(mutex) TURN_MUTEX_DECLARE(mutex)
}; };
@ -809,7 +809,7 @@ void ur_addr_map_init(ur_addr_map* map) {
void ur_addr_map_clean(ur_addr_map* map) { void ur_addr_map_clean(ur_addr_map* map) {
if(map && ur_addr_map_valid(map)) { if(map && ur_addr_map_valid(map)) {
u32bits i=0; uint32_t i=0;
for(i=0;i<ADDR_MAP_SIZE;i++) { for(i=0;i<ADDR_MAP_SIZE;i++) {
addr_list_free(&(map->lists[i])); addr_list_free(&(map->lists[i]));
} }
@ -895,7 +895,7 @@ void ur_addr_map_foreach(ur_addr_map* map, ur_addr_map_func func) {
if(ur_addr_map_valid(map)) { if(ur_addr_map_valid(map)) {
u32bits i=0; uint32_t i=0;
for(i=0;i<ADDR_MAP_SIZE;i++) { for(i=0;i<ADDR_MAP_SIZE;i++) {
addr_list_header* slh = &(map->lists[i]); addr_list_header* slh = &(map->lists[i]);
@ -910,7 +910,7 @@ size_t ur_addr_map_num_elements(const ur_addr_map* map) {
size_t ret = 0; size_t ret = 0;
if (ur_addr_map_valid(map)) { if (ur_addr_map_valid(map)) {
u32bits i = 0; uint32_t i = 0;
for (i = 0; i < ADDR_MAP_SIZE; i++) { for (i = 0; i < ADDR_MAP_SIZE; i++) {
const addr_list_header* slh = &(map->lists[i]); const addr_list_header* slh = &(map->lists[i]);
@ -927,7 +927,7 @@ size_t ur_addr_map_size(const ur_addr_map* map) {
size_t ret = 0; size_t ret = 0;
if (ur_addr_map_valid(map)) { if (ur_addr_map_valid(map)) {
u32bits i = 0; uint32_t i = 0;
for (i = 0; i < ADDR_MAP_SIZE; i++) { for (i = 0; i < ADDR_MAP_SIZE; i++) {
const addr_list_header* slh = &(map->lists[i]); const addr_list_header* slh = &(map->lists[i]);
@ -948,7 +948,7 @@ typedef struct _string_list {
typedef struct _string_elem { typedef struct _string_elem {
string_list list; string_list list;
ur_string_map_key_type key; ur_string_map_key_type key;
u32bits key_size; uint32_t key_size;
ur_string_map_value_type value; ur_string_map_value_type value;
} string_elem; } string_elem;
@ -982,7 +982,7 @@ static string_list* string_list_add(string_list* sl, const ur_string_map_key_typ
string_elem *elem=(string_elem*)malloc(sizeof(string_elem)); string_elem *elem=(string_elem*)malloc(sizeof(string_elem));
elem->list.next=sl; elem->list.next=sl;
elem->key_size = strlen(key)+1; elem->key_size = strlen(key)+1;
elem->key=(s08bits*)malloc(elem->key_size); elem->key=(char*)malloc(elem->key_size);
bcopy(key,elem->key,elem->key_size); bcopy(key,elem->key,elem->key_size);
elem->value=value; elem->value=value;
return &(elem->list); return &(elem->list);
@ -1024,16 +1024,16 @@ static string_elem* string_list_get(string_list* sl, const ur_string_map_key_typ
struct _ur_string_map { struct _ur_string_map {
string_list_header lists[STRING_MAP_SIZE]; string_list_header lists[STRING_MAP_SIZE];
u64bits magic; uint64_t magic;
ur_string_map_func del_value_func; ur_string_map_func del_value_func;
TURN_MUTEX_DECLARE(mutex) TURN_MUTEX_DECLARE(mutex)
}; };
static u32bits string_hash(const ur_string_map_key_type key) { static uint32_t string_hash(const ur_string_map_key_type key) {
u08bits *str=(u08bits*)key; uint8_t *str=(uint8_t*)key;
u32bits hash = 0; uint32_t hash = 0;
int c = 0; int c = 0;
while ((c = *str++)) while ((c = *str++))

View File

@ -44,7 +44,7 @@ typedef struct _ur_map ur_map;
//////////////// Common Definitions ////// //////////////// Common Definitions //////
typedef u64bits ur_map_key_type; typedef uint64_t ur_map_key_type;
typedef unsigned long ur_map_value_type; typedef unsigned long ur_map_value_type;
typedef void (*ur_map_del_func)(ur_map_value_type); typedef void (*ur_map_del_func)(ur_map_value_type);
@ -176,7 +176,7 @@ typedef struct _addr_list_header {
struct _ur_addr_map { struct _ur_addr_map {
addr_list_header lists[ADDR_MAP_SIZE]; addr_list_header lists[ADDR_MAP_SIZE];
u64bits magic; uint64_t magic;
}; };
struct _ur_addr_map; struct _ur_addr_map;
@ -221,7 +221,7 @@ size_t ur_addr_map_size(const ur_addr_map* map);
//////////////// UR STRING MAP ////////////////// //////////////// UR STRING MAP //////////////////
typedef s08bits* ur_string_map_key_type; typedef char* ur_string_map_key_type;
typedef void* ur_string_map_value_type; typedef void* ur_string_map_value_type;
struct _ur_string_map; struct _ur_string_map;
typedef struct _ur_string_map ur_string_map; typedef struct _ur_string_map ur_string_map;

View File

@ -42,7 +42,7 @@
//////////////////////////////////////////// ////////////////////////////////////////////
struct _rtcp_map { struct _rtcp_map {
u32bits magic; uint32_t magic;
ur_map *map; ur_map *map;
ioa_timer_handle timer_ev; ioa_timer_handle timer_ev;
TURN_MUTEX_DECLARE(mutex) TURN_MUTEX_DECLARE(mutex)

File diff suppressed because it is too large Load Diff

View File

@ -64,7 +64,7 @@ typedef int (*send_message_cb)(ioa_engine_handle e, ioa_network_buffer_handle nb
extern int TURN_MAX_ALLOCATE_TIMEOUT; extern int TURN_MAX_ALLOCATE_TIMEOUT;
extern int TURN_MAX_ALLOCATE_TIMEOUT_STUN_ONLY; extern int TURN_MAX_ALLOCATE_TIMEOUT_STUN_ONLY;
typedef u08bits turnserver_id; typedef uint8_t turnserver_id;
enum _MESSAGE_TO_RELAY_TYPE { enum _MESSAGE_TO_RELAY_TYPE {
RMT_UNKNOWN = 0, RMT_UNKNOWN = 0,
@ -90,11 +90,11 @@ typedef enum {
struct _turn_turnserver; struct _turn_turnserver;
typedef struct _turn_turnserver turn_turnserver; typedef struct _turn_turnserver turn_turnserver;
typedef void (*get_username_resume_cb)(int success, int oauth, int max_session_time, hmackey_t hmackey, password_t pwd, turn_turnserver *server, u64bits ctxkey, ioa_net_data *in_buffer, u08bits* realm); typedef void (*get_username_resume_cb)(int success, int oauth, int max_session_time, hmackey_t hmackey, password_t pwd, turn_turnserver *server, uint64_t ctxkey, ioa_net_data *in_buffer, uint8_t* realm);
typedef u08bits *(*get_user_key_cb)(turnserver_id id, turn_credential_type ct, int in_oauth, int *out_oauth, u08bits *uname, u08bits *realm, get_username_resume_cb resume, ioa_net_data *in_buffer, u64bits ctxkey, int *postpone_reply); typedef uint8_t *(*get_user_key_cb)(turnserver_id id, turn_credential_type ct, int in_oauth, int *out_oauth, uint8_t *uname, uint8_t *realm, get_username_resume_cb resume, ioa_net_data *in_buffer, uint64_t ctxkey, int *postpone_reply);
typedef int (*check_new_allocation_quota_cb)(u08bits *username, int oauth, u08bits *realm); typedef int (*check_new_allocation_quota_cb)(uint8_t *username, int oauth, uint8_t *realm);
typedef void (*release_allocation_quota_cb)(u08bits *username, int oauth, u08bits *realm); typedef void (*release_allocation_quota_cb)(uint8_t *username, int oauth, uint8_t *realm);
typedef int (*send_socket_to_relay_cb)(turnserver_id id, u64bits cid, stun_tid *tid, ioa_socket_handle s, int message_integrity, MESSAGE_TO_RELAY_TYPE rmt, ioa_net_data *nd, int can_resume); typedef int (*send_socket_to_relay_cb)(turnserver_id id, uint64_t cid, stun_tid *tid, ioa_socket_handle s, int message_integrity, MESSAGE_TO_RELAY_TYPE rmt, ioa_net_data *nd, int can_resume);
typedef int (*send_turn_session_info_cb)(struct turn_session_info *tsi); typedef int (*send_turn_session_info_cb)(struct turn_session_info *tsi);
typedef void (*send_https_socket_cb)(ioa_socket_handle s); typedef void (*send_https_socket_cb)(ioa_socket_handle s);

View File

@ -52,18 +52,18 @@ typedef struct _perf_options_t {
struct _realm_options_t { struct _realm_options_t {
s08bits name[STUN_MAX_REALM_SIZE + 1]; char name[STUN_MAX_REALM_SIZE + 1];
perf_options_t perf_options; perf_options_t perf_options;
}; };
//////////////// session info ////////////////////// //////////////// session info //////////////////////
typedef u64bits turnsession_id; typedef uint64_t turnsession_id;
#define NONCE_MAX_SIZE (NONCE_LENGTH_32BITS*4+1) #define NONCE_MAX_SIZE (NONCE_LENGTH_32BITS*4+1)
typedef u64bits mobile_id_t; typedef uint64_t mobile_id_t;
struct _ts_ur_super_session { struct _ts_ur_super_session {
void* server; void* server;
@ -76,9 +76,9 @@ struct _ts_ur_super_session {
int is_tcp_relay; int is_tcp_relay;
int to_be_closed; int to_be_closed;
/* Auth */ /* Auth */
u08bits nonce[NONCE_MAX_SIZE]; uint8_t nonce[NONCE_MAX_SIZE];
turn_time_t nonce_expiration_time; turn_time_t nonce_expiration_time;
u08bits username[STUN_MAX_USERNAME_SIZE+1]; uint8_t username[STUN_MAX_USERNAME_SIZE+1];
hmackey_t hmackey; hmackey_t hmackey;
int hmackey_set; int hmackey_set;
password_t pwd; password_t pwd;
@ -88,17 +88,17 @@ struct _ts_ur_super_session {
/* Realm */ /* Realm */
realm_options_t realm_options; realm_options_t realm_options;
int origin_set; int origin_set;
s08bits origin[STUN_MAX_ORIGIN_SIZE + 1]; char origin[STUN_MAX_ORIGIN_SIZE + 1];
/* Stats */ /* Stats */
u32bits received_packets; uint32_t received_packets;
u32bits sent_packets; uint32_t sent_packets;
u32bits received_bytes; uint32_t received_bytes;
u32bits sent_bytes; uint32_t sent_bytes;
u64bits t_received_packets; uint64_t t_received_packets;
u64bits t_sent_packets; uint64_t t_sent_packets;
u64bits t_received_bytes; uint64_t t_received_bytes;
u64bits t_sent_bytes; uint64_t t_sent_bytes;
u64bits received_rate; uint64_t received_rate;
size_t sent_rate; size_t sent_rate;
size_t total_rate; size_t total_rate;
/* Mobile */ /* Mobile */
@ -133,16 +133,16 @@ struct turn_session_info {
addr_data remote_addr_data; addr_data remote_addr_data;
addr_data relay_addr_data_ipv4; addr_data relay_addr_data_ipv4;
addr_data relay_addr_data_ipv6; addr_data relay_addr_data_ipv6;
u08bits username[STUN_MAX_USERNAME_SIZE+1]; uint8_t username[STUN_MAX_USERNAME_SIZE+1];
int enforce_fingerprints; int enforce_fingerprints;
/* Stats */ /* Stats */
u64bits received_packets; uint64_t received_packets;
u64bits sent_packets; uint64_t sent_packets;
u64bits received_bytes; uint64_t received_bytes;
u64bits sent_bytes; uint64_t sent_bytes;
u32bits received_rate; uint32_t received_rate;
u32bits sent_rate; uint32_t sent_rate;
u32bits total_rate; uint32_t total_rate;
/* Mobile */ /* Mobile */
int is_mobile; int is_mobile;
/* Peers */ /* Peers */