diff --git a/src/apps/common/apputils.c b/src/apps/common/apputils.c index 476acf0e..5036020b 100644 --- a/src/apps/common/apputils.c +++ b/src/apps/common/apputils.c @@ -279,7 +279,7 @@ int addr_bind(evutil_socket_t fd, const ioa_addr* addr, int reusable, int debug, int err = errno; perror("bind"); 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); } } @@ -893,15 +893,15 @@ void ignore_sigpipe(void) } } -static u64bits turn_getRandTime(void) { +static uint64_t turn_getRandTime(void) { struct timespec tp={0,0}; #if defined(CLOCK_REALTIME) clock_gettime(CLOCK_REALTIME, &tp); #else tp.tv_sec = time(NULL); #endif - u64bits current_time = (u64bits)(tp.tv_sec); - u64bits current_mstime = (u64bits)(current_time + (tp.tv_nsec)); + uint64_t current_time = (uint64_t)(tp.tv_sec); + uint64_t current_mstime = (uint64_t)(current_time + (tp.tv_nsec)); return current_mstime; } @@ -956,11 +956,11 @@ char *base64_encode(const unsigned char *data, size_t i,j; for (i = 0, j = 0; i < input_length;) { - u32bits octet_a = i < input_length ? data[i++] : 0; - u32bits octet_b = i < input_length ? data[i++] : 0; - u32bits octet_c = i < input_length ? data[i++] : 0; + uint32_t octet_a = i < input_length ? data[i++] : 0; + uint32_t octet_b = 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 >> 2 * 6) & 0x3F]; diff --git a/src/apps/common/apputils.h b/src/apps/common/apputils.h index f137ab07..0d8efa7f 100644 --- a/src/apps/common/apputils.h +++ b/src/apps/common/apputils.h @@ -135,8 +135,8 @@ typedef enum _TURN_TLS_TYPE TURN_TLS_TYPE; struct _oauth_key_data_raw { char kid[OAUTH_KID_SIZE+1]; char ikm_key[OAUTH_KEY_SIZE+1]; - u64bits timestamp; - u32bits lifetime; + uint64_t timestamp; + uint32_t lifetime; char as_rs_alg[OAUTH_ALG_SIZE+1]; char realm[STUN_MAX_REALM_SIZE+1]; }; diff --git a/src/apps/common/ns_turn_utils.c b/src/apps/common/ns_turn_utils.c index 5fd33293..2c656d74 100644 --- a/src/apps/common/ns_turn_utils.c +++ b/src/apps/common/ns_turn_utils.c @@ -148,7 +148,7 @@ int turn_mutex_destroy(turn_mutex* mutex) { ///////////////////////// LOG /////////////////////////////////// #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 static int no_stdout_log = 0; @@ -158,7 +158,7 @@ void set_no_stdout_log(int 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) { @@ -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 (!addr) { TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s: EMPTY\n", s); } else { - s08bits addrbuf[INET6_ADDRSTRLEN]; + char addrbuf[INET6_ADDRSTRLEN]; if (!s) s = ""; 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; if(string) { diff --git a/src/apps/common/ns_turn_utils.h b/src/apps/common/ns_turn_utils.h index da3b777e..77ade9aa 100644 --- a/src/apps/common/ns_turn_utils.h +++ b/src/apps/common/ns_turn_utils.h @@ -61,9 +61,9 @@ void set_no_stdout_log(int val); void set_log_to_syslog(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 */ @@ -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); /////////////////////////////////////////////////////// diff --git a/src/apps/common/stun_buffer.c b/src/apps/common/stun_buffer.c index 0e6f5db4..e3f3b9a2 100644 --- a/src/apps/common/stun_buffer.c +++ b/src/apps/common/stun_buffer.c @@ -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)); } -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); } @@ -95,36 +95,36 @@ int stun_is_indication(const stun_buffer* 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)); } -u16bits stun_get_msg_type(const stun_buffer* buf) { - if(!buf) return (u16bits)-1; +uint16_t stun_get_msg_type(const stun_buffer* buf) { + if(!buf) return (uint16_t)-1; 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); 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); } -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); } -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); 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); 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); } -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; size_t blen = (size_t)buf->len; 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); } int stun_set_allocate_response(stun_buffer* buf, stun_tid* tid, const ioa_addr *relayed_addr1, const ioa_addr *relayed_addr2, const ioa_addr *reflexive_addr, - u32bits lifetime, u32bits max_lifetime, int error_code, const u08bits *reason, - u64bits reservation_token, char *mobile_id) { + uint32_t lifetime, uint32_t max_lifetime, int error_code, const uint8_t *reason, + uint64_t reservation_token, char *mobile_id) { return stun_set_allocate_response_str(buf->buf, (size_t*)(&(buf->len)), tid, 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, - 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) { 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); } @@ -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); } -int stun_attr_add(stun_buffer* buf, u16bits attr, const s08bits* avalue, int alen) { - return stun_attr_add_str(buf->buf, (size_t*)(&(buf->len)), attr, (const u08bits *)avalue, 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 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); } -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); } @@ -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); } -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) { 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) { 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)); } -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); } @@ -236,7 +236,7 @@ void stun_set_binding_request(stun_buffer* buf) { } 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, reflexive_addr, error_code, reason, 0,0); diff --git a/src/apps/common/stun_buffer.h b/src/apps/common/stun_buffer.h index 943df0ce..5ab35c23 100644 --- a/src/apps/common/stun_buffer.h +++ b/src/apps/common/stun_buffer.h @@ -40,11 +40,11 @@ extern "C" { /////////////////////////////////////////////////////////////// typedef struct _stun_buffer { - u08bits channel[STUN_CHANNEL_HEADER_LENGTH]; - u08bits buf[STUN_BUFFER_SIZE]; + uint8_t channel[STUN_CHANNEL_HEADER_LENGTH]; + uint8_t buf[STUN_BUFFER_SIZE]; size_t len; - u16bits offset; - u08bits coffset; + uint16_t offset; + uint8_t coffset; } 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_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); -u16bits stun_get_method(const stun_buffer* buf); -u16bits stun_get_msg_type(const stun_buffer* buf); +uint16_t stun_get_method(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_indication(u16bits method, stun_buffer* buf); -void stun_init_success_response(u16bits 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_request(uint16_t method, stun_buffer* buf); +void stun_init_indication(uint16_t method, stun_buffer* buf); +void stun_init_success_response(uint16_t method, stun_buffer* buf, 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_channel_number(stun_buffer* buf, u16bits chnumber); -int stun_attr_add_addr(stun_buffer *buf,u16bits attr_type, const ioa_addr* ca); +int stun_attr_add(stun_buffer* buf, uint16_t attr, const char* avalue, int alen); +int stun_attr_add_channel_number(stun_buffer* buf, uint16_t chnumber); +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_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); 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_get_first_addr(const stun_buffer *buf, u16bits attr_type, ioa_addr* ca, const ioa_addr *default_addr); -u16bits stun_attr_get_first_channel_number(const stun_buffer *buf); +int stun_attr_get_first_addr(const stun_buffer *buf, uint16_t attr_type, ioa_addr* ca, const ioa_addr *default_addr); +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_is_channel_message(stun_buffer* buf, u16bits* chnumber, int is_padding_madatory); +int stun_init_channel_message(uint16_t chnumber, stun_buffer* buf, int length, int do_padding); +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, const ioa_addr *relayed_addr1, const ioa_addr *relayed_addr2, const ioa_addr *reflexive_addr, - u32bits lifetime, u32bits max_lifetime, - int error_code, const u08bits *reason, - u64bits reservation_token, char *mobile_id); + uint32_t lifetime, uint32_t max_lifetime, + int error_code, const uint8_t *reason, + uint64_t reservation_token, char *mobile_id); /////////////////////////////////////////////////////////////// void stun_set_binding_request(stun_buffer* buf); 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); 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); -void stun_set_channel_bind_response(stun_buffer* buf, stun_tid* tid, int error_code, const u08bits *reason); +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 uint8_t *reason); /////////////////////////////////////////////////////////////// diff --git a/src/apps/natdiscovery/natdiscovery.c b/src/apps/natdiscovery/natdiscovery.c index 5d6a0884..78d82974 100644 --- a/src/apps/natdiscovery/natdiscovery.c +++ b/src/apps/natdiscovery/natdiscovery.c @@ -81,7 +81,7 @@ static int stunclient_send(int sockfd, ioa_addr *local_addr, int *local_port, io if (response_port >= 0) { turn::StunAttrResponsePort rpa; - rpa.setResponsePort((u16bits)response_port); + rpa.setResponsePort((uint16_t)response_port); try { req.addAttr(rpa); } catch(turn::WrongStunAttrFormatException &ex1) { @@ -159,7 +159,7 @@ static int stunclient_receive(int sockfd, ioa_addr *local_addr, ioa_addr *reflex { int len = 0; stun_buffer buf; - u08bits *ptr = buf.buf; + uint8_t *ptr = buf.buf; int recvd = 0; const int to_recv = sizeof(buf.buf); 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); 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) { - 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(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__); } } @@ -393,7 +393,7 @@ static int stunclient_receive(stun_buffer *buf, int sockfd, ioa_addr *local_addr { int len = 0; - u08bits *ptr = buf->buf; + uint8_t *ptr = buf->buf; int recvd = 0; const int to_recv = sizeof(buf->buf); struct timeval tv; @@ -444,11 +444,11 @@ static int stunclient_receive(stun_buffer *buf, int sockfd, ioa_addr *local_addr } else { 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); if (sar) { 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, other_addr, "Other addr: "); @@ -463,7 +463,7 @@ static int stunclient_receive(stun_buffer *buf, int sockfd, ioa_addr *local_addr } } else { int err_code = 0; - u08bits err_msg[1025] = "\0"; + uint8_t err_msg[1025] = "\0"; size_t err_msg_size = sizeof(err_msg); 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); @@ -592,14 +592,14 @@ static void init(int first, ioa_addr *local_addr, ioa_addr *remote_addr, int *lo addr_set_any(local_addr); 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); } } if (!first) *local_port=-1; *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); } @@ -791,7 +791,7 @@ int main(int argc, char **argv) addr_set_any(&local2_addr); 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); } } diff --git a/src/apps/oauth/oauth.c b/src/apps/oauth/oauth.c index 0dae0715..f11e9791 100644 --- a/src/apps/oauth/oauth.c +++ b/src/apps/oauth/oauth.c @@ -117,7 +117,7 @@ static int encode_token(const char* server_name, // TODO: avoid this hack 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", __FUNCTION__); 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); 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", __FUNCTION__); return -1; diff --git a/src/apps/peer/udpserver.c b/src/apps/peer/udpserver.c index b289fa07..521ffafc 100644 --- a/src/apps/peer/udpserver.c +++ b/src/apps/peer/udpserver.c @@ -72,7 +72,7 @@ static int udp_create_server_socket(server_type* server, 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); if (udp_fd < 0) { diff --git a/src/apps/relay/dbdrivers/dbd_mongo.c b/src/apps/relay/dbdrivers/dbd_mongo.c index c3c05e30..88609442 100644 --- a/src/apps/relay/dbdrivers/dbd_mongo.c +++ b/src/apps/relay/dbdrivers/dbd_mongo.c @@ -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"); if(!collection) @@ -186,7 +186,7 @@ static int mongo_get_auth_secrets(secrets_list_t *sl, u08bits *realm) { 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"); if(!collection) @@ -239,7 +239,7 @@ static int mongo_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) { 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"); @@ -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)); } 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)) { - key->lifetime = (u32bits)bson_iter_int32(&iter); + key->lifetime = (uint32_t)bson_iter_int32(&iter); } ret = 0; } @@ -300,7 +300,7 @@ static int mongo_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) { 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"); if(!collection) @@ -363,7 +363,7 @@ static int mongo_set_oauth_key(oauth_key_data_raw *key) { 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"); if(!collection) @@ -386,7 +386,7 @@ static int mongo_del_user(u08bits *usname, u08bits *realm) { 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"); @@ -409,12 +409,12 @@ static int mongo_del_oauth_key(const u08bits *kid) { 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"; 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(!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)); } 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)) { - key->lifetime = (u32bits)bson_iter_int32(&iter); + key->lifetime = (uint32_t)bson_iter_int32(&iter); } if(kids) { 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; } -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"); - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; if(!collection) @@ -644,7 +644,7 @@ static int mongo_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_l 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"); if(!collection) @@ -663,7 +663,7 @@ static int mongo_del_secret(u08bits *secret, u08bits *realm) { 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"); 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]; 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; - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; bson_t query, doc, child; @@ -732,7 +732,7 @@ static int mongo_set_permission_ip(const char *kind, u08bits *realm, const char* 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"); @@ -741,7 +741,7 @@ static int mongo_add_origin(u08bits *origin, u08bits *realm) int ret = -1; - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; bson_t query, doc, child; @@ -763,7 +763,7 @@ static int mongo_add_origin(u08bits *origin, u08bits *realm) 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"); @@ -790,14 +790,14 @@ static int mongo_del_origin(u08bits *origin) 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"); if(!collection) return -1; - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; bson_t query, child; @@ -868,7 +868,7 @@ static int mongo_list_origins(u08bits *realm, secrets_list_t *origins, secrets_l 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"); if(!collection) @@ -908,7 +908,7 @@ static int mongo_set_realm_option_one(u08bits *realm, unsigned long value, const 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"); 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"); @@ -1234,7 +1234,7 @@ static int mongo_get_admin_user(const u08bits *usname, u08bits *realm, password_ 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"); @@ -1264,7 +1264,7 @@ static int mongo_set_admin_user(const u08bits *usname, const u08bits *realm, con 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"); diff --git a/src/apps/relay/dbdrivers/dbd_mysql.c b/src/apps/relay/dbdrivers/dbd_mysql.c index 59398767..66446e65 100644 --- a/src/apps/relay/dbdrivers/dbd_mysql.c +++ b/src/apps/relay/dbdrivers/dbd_mysql.c @@ -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; MYSQL * myc = get_mydb_connection(); if(myc) { @@ -340,7 +340,7 @@ static int mysql_get_auth_secrets(secrets_list_t *sl, u08bits *realm) { 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; MYSQL * myc = get_mydb_connection(); if(myc) { @@ -385,7 +385,7 @@ static int mysql_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) { 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; 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]; bcopy(row[1],stimestamp,lengths[1]); stimestamp[lengths[1]]=0; - key->timestamp = (u64bits)strtoull(stimestamp,NULL,10); + key->timestamp = (uint64_t)strtoull(stimestamp,NULL,10); char slifetime[128]; bcopy(row[2],slifetime,lengths[2]); 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]); 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]; bcopy(row[1],stimestamp,lengths[1]); stimestamp[lengths[1]]=0; - key->timestamp = (u64bits)strtoull(stimestamp,NULL,10); + key->timestamp = (uint64_t)strtoull(stimestamp,NULL,10); char slifetime[128]; bcopy(row[2],slifetime,lengths[2]); 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]); 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; } -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; char statement[TURN_LONG_STRING_SIZE]; @@ -568,7 +568,7 @@ static int mysql_set_oauth_key(oauth_key_data_raw *key) 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; char statement[TURN_LONG_STRING_SIZE]; MYSQL * myc = get_mydb_connection(); @@ -584,7 +584,7 @@ static int mysql_del_user(u08bits *usname, u08bits *realm) { return ret; } -static int mysql_del_oauth_key(const u08bits *kid) { +static int mysql_del_oauth_key(const uint8_t *kid) { int ret = -1; char statement[TURN_LONG_STRING_SIZE]; MYSQL * myc = get_mydb_connection(); @@ -600,12 +600,12 @@ static int mysql_del_oauth_key(const u08bits *kid) { 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; 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; MYSQL * myc = get_mydb_connection(); @@ -656,11 +656,11 @@ static int mysql_list_users(u08bits *realm, secrets_list_t *users, secrets_list_ 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; - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; 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; } -static int mysql_del_secret(u08bits *secret, u08bits *realm) { +static int mysql_del_secret(uint8_t *secret, uint8_t *realm) { int ret = -1; donot_print_connection_success=1; char statement[TURN_LONG_STRING_SIZE]; @@ -733,7 +733,7 @@ static int mysql_del_secret(u08bits *secret, u08bits *realm) { 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; donot_print_connection_success = 1; char statement[TURN_LONG_STRING_SIZE]; @@ -753,11 +753,11 @@ static int mysql_set_secret(u08bits *secret, u08bits *realm) { 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; - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; donot_print_connection_success = 1; @@ -784,7 +784,7 @@ static int mysql_set_permission_ip(const char *kind, u08bits *realm, const char* 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; char statement[TURN_LONG_STRING_SIZE]; MYSQL * myc = get_mydb_connection(); @@ -803,7 +803,7 @@ static int mysql_add_origin(u08bits *origin, u08bits *realm) { return ret; } -static int mysql_del_origin(u08bits *origin) { +static int mysql_del_origin(uint8_t *origin) { int ret = -1; char statement[TURN_LONG_STRING_SIZE]; MYSQL * myc = get_mydb_connection(); @@ -822,11 +822,11 @@ static int mysql_del_origin(u08bits *origin) { 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; - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; donot_print_connection_success = 1; @@ -882,7 +882,7 @@ static int mysql_list_origins(u08bits *realm, secrets_list_t *origins, secrets_l 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; char statement[TURN_LONG_STRING_SIZE]; MYSQL * myc = get_mydb_connection(); @@ -907,7 +907,7 @@ static int mysql_set_realm_option_one(u08bits *realm, unsigned long value, const return ret; } -static int mysql_list_realm_options(u08bits *realm) { +static int mysql_list_realm_options(uint8_t *realm) { int ret = -1; donot_print_connection_success = 1; 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; @@ -1176,7 +1176,7 @@ static int mysql_get_admin_user(const u08bits *usname, u08bits *realm, password_ 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; 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; } -static int mysql_del_admin_user(const u08bits *usname) +static int mysql_del_admin_user(const uint8_t *usname) { int ret = -1; char statement[TURN_LONG_STRING_SIZE]; diff --git a/src/apps/relay/dbdrivers/dbd_pgsql.c b/src/apps/relay/dbdrivers/dbd_pgsql.c index e7a1d7c8..ac62aa32 100644 --- a/src/apps/relay/dbdrivers/dbd_pgsql.c +++ b/src/apps/relay/dbdrivers/dbd_pgsql.c @@ -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; PGconn * pqc = get_pqdb_connection(); if(pqc) { @@ -119,7 +119,7 @@ static int pgsql_get_auth_secrets(secrets_list_t *sl, u08bits *realm) { 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; PGconn * pqc = get_pqdb_connection(); if(pqc) { @@ -154,7 +154,7 @@ static int pgsql_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) { 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; @@ -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)); } else { STRCPY(key->ikm_key,PQgetvalue(res,0,0)); - key->timestamp = (u64bits)strtoll(PQgetvalue(res,0,1),NULL,10); - key->lifetime = (u32bits)strtol(PQgetvalue(res,0,2),NULL,10); + key->timestamp = (uint64_t)strtoll(PQgetvalue(res,0,1),NULL,10); + key->lifetime = (uint32_t)strtol(PQgetvalue(res,0,2),NULL,10); STRCPY(key->as_rs_alg,PQgetvalue(res,0,3)); STRCPY(key->realm,PQgetvalue(res,0,4)); 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;iikm_key,PQgetvalue(res,i,0)); - key->timestamp = (u64bits)strtoll(PQgetvalue(res,i,1),NULL,10); - key->lifetime = (u32bits)strtol(PQgetvalue(res,i,2),NULL,10); + key->timestamp = (uint64_t)strtoll(PQgetvalue(res,i,1),NULL,10); + key->lifetime = (uint32_t)strtol(PQgetvalue(res,i,2),NULL,10); STRCPY(key->as_rs_alg,PQgetvalue(res,i,3)); STRCPY(key->realm,PQgetvalue(res,i,4)); 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; } -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; char statement[TURN_LONG_STRING_SIZE]; PGconn *pqc = get_pqdb_connection(); @@ -306,7 +306,7 @@ static int pgsql_set_oauth_key(oauth_key_data_raw *key) { 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; char statement[TURN_LONG_STRING_SIZE]; PGconn *pqc = get_pqdb_connection(); @@ -321,7 +321,7 @@ static int pgsql_del_user(u08bits *usname, u08bits *realm) { return ret; } -static int pgsql_del_oauth_key(const u08bits *kid) { +static int pgsql_del_oauth_key(const uint8_t *kid) { int ret = -1; char statement[TURN_LONG_STRING_SIZE]; @@ -342,12 +342,12 @@ static int pgsql_del_oauth_key(const u08bits *kid) { 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; 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; PGconn *pqc = get_pqdb_connection(); @@ -391,11 +391,11 @@ static int pgsql_list_users(u08bits *realm, secrets_list_t *users, secrets_list_ 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; - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; 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; } -static int pgsql_del_secret(u08bits *secret, u08bits *realm) { +static int pgsql_del_secret(uint8_t *secret, uint8_t *realm) { int ret = -1; donot_print_connection_success=1; char statement[TURN_LONG_STRING_SIZE]; @@ -461,7 +461,7 @@ static int pgsql_del_secret(u08bits *secret, u08bits *realm) { 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; donot_print_connection_success = 1; char statement[TURN_LONG_STRING_SIZE]; @@ -485,11 +485,11 @@ static int pgsql_set_secret(u08bits *secret, u08bits *realm) { 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; - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; donot_print_connection_success = 1; @@ -523,7 +523,7 @@ static int pgsql_set_permission_ip(const char *kind, u08bits *realm, const char* 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; char statement[TURN_LONG_STRING_SIZE]; PGconn *pqc = get_pqdb_connection(); @@ -542,7 +542,7 @@ static int pgsql_add_origin(u08bits *origin, u08bits *realm) { return ret; } -static int pgsql_del_origin(u08bits *origin) { +static int pgsql_del_origin(uint8_t *origin) { int ret = -1; char statement[TURN_LONG_STRING_SIZE]; PGconn *pqc = get_pqdb_connection(); @@ -561,11 +561,11 @@ static int pgsql_del_origin(u08bits *origin) { 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; - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; donot_print_connection_success = 1; @@ -615,7 +615,7 @@ static int pgsql_list_origins(u08bits *realm, secrets_list_t *origins, secrets_l 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; char statement[TURN_LONG_STRING_SIZE]; PGconn *pqc = get_pqdb_connection(); @@ -643,7 +643,7 @@ static int pgsql_set_realm_option_one(u08bits *realm, unsigned long value, const return ret; } -static int pgsql_list_realm_options(u08bits *realm) { +static int pgsql_list_realm_options(uint8_t *realm) { int ret = -1; donot_print_connection_success = 1; 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; @@ -869,7 +869,7 @@ static int pgsql_get_admin_user(const u08bits *usname, u08bits *realm, password_ 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; 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; } -static int pgsql_del_admin_user(const u08bits *usname) +static int pgsql_del_admin_user(const uint8_t *usname) { int ret = -1; char statement[TURN_LONG_STRING_SIZE]; diff --git a/src/apps/relay/dbdrivers/dbd_redis.c b/src/apps/relay/dbdrivers/dbd_redis.c index 1844b1d1..2371a155 100644 --- a/src/apps/relay/dbdrivers/dbd_redis.c +++ b/src/apps/relay/dbdrivers/dbd_redis.c @@ -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; redisContext *rc = get_redis_connection(); @@ -425,7 +425,7 @@ static int redis_get_auth_secrets(secrets_list_t *sl, u08bits *realm) 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; redisContext * rc = get_redis_connection(); if(rc) { @@ -454,7 +454,7 @@ static int redis_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) { 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; redisContext * rc = get_redis_connection(); 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")) { STRCPY(key->ikm_key,val); } 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")) { - 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; } -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; redisContext *rc = get_redis_connection(); if(rc) { @@ -523,7 +523,7 @@ static int redis_set_oauth_key(oauth_key_data_raw *key) { 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; redisContext *rc = get_redis_connection(); if(rc) { @@ -539,7 +539,7 @@ static int redis_del_user(u08bits *usname, u08bits *realm) { return ret; } -static int redis_del_oauth_key(const u08bits *kid) { +static int redis_del_oauth_key(const uint8_t *kid) { int ret = -1; redisContext *rc = get_redis_connection(); if(rc) { @@ -552,12 +552,12 @@ static int redis_del_oauth_key(const u08bits *kid) { 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; 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(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/"); oauth_key_data_raw 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) { add_to_secrets_list(kids,key->kid); 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; - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; 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; 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; donot_print_connection_success = 1; @@ -820,11 +820,11 @@ static int redis_set_secret(u08bits *secret, u08bits *realm) 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; - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; donot_print_connection_success = 1; @@ -846,7 +846,7 @@ static int redis_set_permission_ip(const char *kind, u08bits *realm, const char* 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; redisContext *rc = get_redis_connection(); if(rc) { @@ -861,7 +861,7 @@ static int redis_add_origin(u08bits *origin, u08bits *realm) { return ret; } -static int redis_del_origin(u08bits *origin) { +static int redis_del_origin(uint8_t *origin) { int ret = -1; redisContext *rc = get_redis_connection(); if(rc) { @@ -876,11 +876,11 @@ static int redis_del_origin(u08bits *origin) { 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; - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; donot_print_connection_success = 1; @@ -948,7 +948,7 @@ static int redis_list_origins(u08bits *realm, secrets_list_t *origins, secrets_l 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; redisContext *rc = get_redis_connection(); if(rc) { @@ -966,7 +966,7 @@ static int redis_set_realm_option_one(u08bits *realm, unsigned long value, const return ret; } -static int redis_list_realm_options(u08bits *realm) { +static int redis_list_realm_options(uint8_t *realm) { int ret = -1; donot_print_connection_success = 1; 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; redisContext * rc = get_redis_connection(); @@ -1259,7 +1259,7 @@ static int redis_get_admin_user(const u08bits *usname, u08bits *realm, password_ 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; donot_print_connection_success = 1; @@ -1278,7 +1278,7 @@ static int redis_set_admin_user(const u08bits *usname, const u08bits *realm, con return ret; } -static int redis_del_admin_user(const u08bits *usname) { +static int redis_del_admin_user(const uint8_t *usname) { int ret = -1; donot_print_connection_success = 1; redisContext *rc = get_redis_connection(); @@ -1328,9 +1328,9 @@ static int redis_list_admin_users(int no_print) for(isz=0;iszikm_key,sqlite3_column_text(st, 0)); - key->timestamp = (u64bits)strtoll((const char*)sqlite3_column_text(st, 1),NULL,10); - key->lifetime = (u32bits)strtol((const char*)sqlite3_column_text(st, 2),NULL,10); + key->timestamp = (uint64_t)strtoll((const char*)sqlite3_column_text(st, 1),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->realm,sqlite3_column_text(st, 4)); 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) { STRCPY(key->ikm_key,sqlite3_column_text(st, 0)); - key->timestamp = (u64bits)strtoll((const char*)sqlite3_column_text(st, 1),NULL,10); - key->lifetime = (u32bits)strtol((const char*)sqlite3_column_text(st, 2),NULL,10); + key->timestamp = (uint64_t)strtoll((const char*)sqlite3_column_text(st, 1),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->realm,sqlite3_column_text(st, 4)); 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; } -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; char statement[TURN_LONG_STRING_SIZE]; @@ -471,7 +471,7 @@ static int sqlite_set_oauth_key(oauth_key_data_raw *key) 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; char statement[TURN_LONG_STRING_SIZE]; @@ -500,7 +500,7 @@ static int sqlite_del_user(u08bits *usname, u08bits *realm) return ret; } -static int sqlite_del_oauth_key(const u08bits *kid) +static int sqlite_del_oauth_key(const uint8_t *kid) { int ret = -1; 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; char statement[TURN_LONG_STRING_SIZE]; sqlite3_stmt *st = NULL; int rc = 0; - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; donot_print_connection_success=1; @@ -596,12 +596,12 @@ static int sqlite_list_users(u08bits *realm, secrets_list_t *users, secrets_list 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; 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; sqlite3_stmt *st = NULL; @@ -660,7 +660,7 @@ static int sqlite_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_ 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; donot_print_connection_success=1; @@ -691,7 +691,7 @@ static int sqlite_del_secret(u08bits *secret, u08bits *realm) 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; donot_print_connection_success = 1; @@ -720,7 +720,7 @@ static int sqlite_set_secret(u08bits *secret, u08bits *realm) 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; char statement[TURN_LONG_STRING_SIZE]; @@ -748,7 +748,7 @@ static int sqlite_add_origin(u08bits *origin, u08bits *realm) return ret; } -static int sqlite_del_origin(u08bits *origin) +static int sqlite_del_origin(uint8_t *origin) { int ret = -1; char statement[TURN_LONG_STRING_SIZE]; @@ -776,11 +776,11 @@ static int sqlite_del_origin(u08bits *origin) 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; - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; donot_print_connection_success = 1; @@ -841,7 +841,7 @@ static int sqlite_list_origins(u08bits *realm, secrets_list_t *origins, secrets_ 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; 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; } -static int sqlite_list_realm_options(u08bits *realm) +static int sqlite_list_realm_options(uint8_t *realm) { int ret = -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; } -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; - u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0"; + uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0"; if(!realm) realm=realm0; 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; @@ -1180,7 +1180,7 @@ static int sqlite_get_admin_user(const u08bits *usname, u08bits *realm, password 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; 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; } -static int sqlite_del_admin_user(const u08bits *usname) +static int sqlite_del_admin_user(const uint8_t *usname) { int ret = -1; char statement[TURN_LONG_STRING_SIZE]; diff --git a/src/apps/relay/dbdrivers/dbdriver.h b/src/apps/relay/dbdrivers/dbdriver.h index b6ad537d..4fe2d696 100644 --- a/src/apps/relay/dbdrivers/dbdriver.h +++ b/src/apps/relay/dbdrivers/dbdriver.h @@ -48,30 +48,30 @@ extern pthread_key_t connection_key; extern pthread_once_t connection_key_once; typedef struct _turn_dbdriver_t { - int (*get_auth_secrets)(secrets_list_t *sl, u08bits *realm); - int (*get_user_key)(u08bits *usname, u08bits *realm, hmackey_t key); - int (*set_user_key)(u08bits *usname, u08bits *realm, const char *key); - int (*del_user)(u08bits *usname, u08bits *realm); - int (*list_users)(u08bits *realm, secrets_list_t *users, secrets_list_t *realms); - int (*list_secrets)(u08bits *realm, secrets_list_t *secrets, secrets_list_t *realms); - int (*del_secret)(u08bits *secret, u08bits *realm); - int (*set_secret)(u08bits *secret, u08bits *realm); - int (*add_origin)(u08bits *origin, u08bits *realm); - int (*del_origin)(u08bits *origin); - int (*list_origins)(u08bits *realm, secrets_list_t *origins, secrets_list_t *realms); - int (*set_realm_option_one)(u08bits *realm, unsigned long value, const char* opt); - int (*list_realm_options)(u08bits *realm); + int (*get_auth_secrets)(secrets_list_t *sl, uint8_t *realm); + int (*get_user_key)(uint8_t *usname, uint8_t *realm, hmackey_t key); + int (*set_user_key)(uint8_t *usname, uint8_t *realm, const char *key); + int (*del_user)(uint8_t *usname, uint8_t *realm); + int (*list_users)(uint8_t *realm, secrets_list_t *users, secrets_list_t *realms); + int (*list_secrets)(uint8_t *realm, secrets_list_t *secrets, secrets_list_t *realms); + int (*del_secret)(uint8_t *secret, uint8_t *realm); + int (*set_secret)(uint8_t *secret, uint8_t *realm); + int (*add_origin)(uint8_t *origin, uint8_t *realm); + int (*del_origin)(uint8_t *origin); + int (*list_origins)(uint8_t *realm, secrets_list_t *origins, secrets_list_t *realms); + int (*set_realm_option_one)(uint8_t *realm, unsigned long value, const char* opt); + int (*list_realm_options)(uint8_t *realm); void (*auth_ping)(void * rch); 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); int (*set_oauth_key)(oauth_key_data_raw *key); - int (*get_oauth_key)(const u08bits *kid, oauth_key_data_raw *key); - int (*del_oauth_key)(const u08bits *kid); + int (*get_oauth_key)(const uint8_t *kid, oauth_key_data_raw *key); + 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 (*get_admin_user)(const u08bits *usname, u08bits *realm, password_t pwd); - int (*set_admin_user)(const u08bits *usname, const u08bits *realm, const password_t pwd); - int (*del_admin_user)(const u08bits *usname); + int (*get_admin_user)(const uint8_t *usname, uint8_t *realm, password_t pwd); + int (*set_admin_user)(const uint8_t *usname, const uint8_t *realm, const password_t pwd); + int (*del_admin_user)(const uint8_t *usname); int (*list_admin_users)(int no_print); } turn_dbdriver_t; diff --git a/src/apps/relay/dtls_listener.c b/src/apps/relay/dtls_listener.c index 2ad0feff..08a17e7d 100644 --- a/src/apps/relay/dtls_listener.c +++ b/src/apps/relay/dtls_listener.c @@ -396,8 +396,8 @@ static int handle_udp_packet(dtls_listener_relay_server_type *server, TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "%s: socket to be closed\n", __FUNCTION__); { - u08bits saddr[129]; - u08bits rsaddr[129]; + uint8_t saddr[129]; + uint8_t rsaddr[129]; long thrid = (long) pthread_self(); addr_to_string(get_local_addr_from_ioa_socket(chs),saddr); 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, "%s: wrong socket container\n", __FUNCTION__); { - u08bits saddr[129]; - u08bits rsaddr[129]; + uint8_t saddr[129]; + uint8_t rsaddr[129]; long thrid = (long) pthread_self(); addr_to_string(get_local_addr_from_ioa_socket(chs),saddr); 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(verbose) { - u08bits saddr[129]; - u08bits rsaddr[129]; + uint8_t saddr[129]; + uint8_t rsaddr[129]; addr_to_string(get_local_addr_from_ioa_socket(s),saddr); addr_to_string(get_remote_addr_from_ioa_socket(s),rsaddr); 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) { char sl[129]; char sr[129]; - addr_to_string(&(ret->local_addr),(u08bits*)sl); - addr_to_string(&(server->sm.m.sm.nd.src_addr),(u08bits*)sr); + addr_to_string(&(ret->local_addr),(uint8_t*)sl); + addr_to_string(&(server->sm.m.sm.nd.src_addr),(uint8_t*)sr); 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); 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; 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->e->cmsg, flags, NULL); @@ -671,8 +671,8 @@ static void udp_server_input_handler(evutil_socket_t fd, short what, void* arg) //Linux int eflags = MSG_ERRQUEUE | MSG_DONTWAIT; - static s08bits buffer[65535]; - u32bits errcode = 0; + static char buffer[65535]; + uint32_t errcode = 0; ioa_addr orig_addr; int ttl = 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) { perror("Cannot bind local socket to addr"); 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); if(addr_bind_cycle++addr,1,1,UDP_SOCKET)<0) { perror("Cannot bind local socket to addr"); 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); return -1; } @@ -925,7 +925,7 @@ static int init_server(dtls_listener_relay_server_type* server, 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); 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) { 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)); } ////////////////////////////////////////////////////////////////// diff --git a/src/apps/relay/http_server.c b/src/apps/relay/http_server.c index 2c9d51ed..573af49b 100644 --- a/src/apps/relay/http_server.c +++ b/src/apps/relay/http_server.c @@ -59,7 +59,7 @@ static void write_http_echo(ioa_socket_handle s) if((sat == HTTP_CLIENT_SOCKET) || (sat == HTTPS_CLIENT_SOCKET)) { ioa_network_buffer_handle nbh_http = ioa_network_buffer_allocate(s->e); 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 content_http[1025]; const char* title = "TURN Server"; diff --git a/src/apps/relay/mainrelay.c b/src/apps/relay/mainrelay.c index 54928c2a..f531c576 100644 --- a/src/apps/relay/mainrelay.c +++ b/src/apps/relay/mainrelay.c @@ -359,7 +359,7 @@ int get_a_local_relay(int family, ioa_addr *relay_addr) } else 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; } else { ret = 0; @@ -1181,7 +1181,7 @@ static void set_option(int c, char *value) use_cli = !get_bool_value(value); break; 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); } else{ cli_addr_set = 1; @@ -1197,7 +1197,7 @@ static void set_option(int c, char *value) use_web_admin = get_bool_value(value); break; 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); } else { web_admin_addr_set = 1; @@ -1317,10 +1317,10 @@ static void set_option(int c, char *value) div[0]=0; ++div; 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); } 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); } else { 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"); } else { 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); free(turn_params.external_ip); turn_params.external_ip = NULL; @@ -1698,11 +1698,11 @@ static int adminmain(int argc, char **argv) FILE* fptr; unsigned char generated_key[16]; //changed - u08bits user[STUN_MAX_USERNAME_SIZE+1]="\0"; - u08bits realm[STUN_MAX_REALM_SIZE+1]="\0"; - u08bits pwd[STUN_MAX_PWD_SIZE+1]="\0"; - u08bits secret[AUTH_SECRET_SIZE+1]="\0"; - u08bits origin[STUN_MAX_ORIGIN_SIZE+1]="\0"; + uint8_t user[STUN_MAX_USERNAME_SIZE+1]="\0"; + uint8_t realm[STUN_MAX_REALM_SIZE+1]="\0"; + uint8_t pwd[STUN_MAX_PWD_SIZE+1]="\0"; + uint8_t secret[AUTH_SECRET_SIZE+1]="\0"; + uint8_t origin[STUN_MAX_ORIGIN_SIZE+1]="\0"; perf_options_t po = {(band_limit_t)-1,-1,-1}; struct uoptions uo; @@ -1823,11 +1823,11 @@ static int adminmain(int argc, char **argv) #endif case 'u': 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); 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); exit(-1); } @@ -1835,14 +1835,14 @@ static int adminmain(int argc, char **argv) case 'r': set_default_realm_name(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); exit(-1); } break; case 'p': 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); exit(-1); } @@ -2336,7 +2336,7 @@ int main(int argc, char **argv) const char* sra = (const char*)turn_params.relay_addrs[ir]; if((strstr(sra,"127.0.0.1") != sra)&&(strstr(sra,"::1")!=sra)) { 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); } else if(ra.ss.sa_family == turn_params.external_ip->ss.sa_family) { ioa_addr_add_mapping(turn_params.external_ip,&ra); diff --git a/src/apps/relay/mainrelay.h b/src/apps/relay/mainrelay.h index b679ad93..ea139846 100644 --- a/src/apps/relay/mainrelay.h +++ b/src/apps/relay/mainrelay.h @@ -98,7 +98,7 @@ extern "C" { #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_UDP_AND_TCP TURNSERVER_ID_BOUNDARY_BETWEEN_TCP_AND_UDP @@ -249,8 +249,8 @@ typedef struct _turn_params_ { //////////////// Relay servers ///////////// - u16bits min_port; - u16bits max_port; + uint16_t min_port; + uint16_t max_port; vint check_origin; diff --git a/src/apps/relay/netengine.c b/src/apps/relay/netengine.c index 75af2b75..1a69dcd8 100644 --- a/src/apps/relay/netengine.c +++ b/src/apps/relay/netengine.c @@ -182,13 +182,13 @@ static void add_aux_server_list(const char *saddr, turn_server_addrs_list_t *lis { if(saddr && list) { 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); } else { list->addrs = (ioa_addr*)realloc(list->addrs,sizeof(ioa_addr)*(list->size+1)); addr_cpy(&(list->addrs[(list->size)++]),&addr); { - u08bits s[1025]; + uint8_t s[1025]; addr_to_string(&addr, 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)); - 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); } else { list->addrs = (ioa_addr*)realloc(list->addrs,sizeof(ioa_addr)*(list->size+1)); addr_cpy(&(list->addrs[(list->size)++]),&addr); { - u08bits s[1025]; + uint8_t s[1025]; addr_to_string(&addr, 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)); - 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); } else { @@ -263,7 +263,7 @@ static void del_alt_server(const char *saddr, int default_port, turn_server_addr list->size -= 1; { - u08bits s[1025]; + uint8_t s[1025]; addr_to_string(&addr, 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) { 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); } else { char sbaddr[129]; - addr_to_string_no_port(&baddr,(u08bits*)sbaddr); + addr_to_string_no_port(&baddr,(uint8_t*)sbaddr); size_t i = 0; for(i=0;i=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]); turnipports_add_ip(STUN_ATTRIBUTE_TRANSPORT_UDP_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; } -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 can_resume) { @@ -996,7 +996,7 @@ static void listener_receive_message(struct bufferevent *bev, void *ptr) } if(!found) { - u08bits saddr[129]; + uint8_t saddr[129]; addr_to_string(&mm.m.tc.origin, 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]; addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]); 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][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]; addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]); 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()); @@ -1405,7 +1405,7 @@ static void setup_socket_per_session_udp_listener_servers(void) char saddr[129]; addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]); 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*)); @@ -1481,7 +1481,7 @@ static void setup_tcp_listener_servers(ioa_engine_handle e, struct relay_server char saddr[129]; addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]); 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); } diff --git a/src/apps/relay/ns_ioalib_engine_impl.c b/src/apps/relay/ns_ioalib_engine_impl.c index 1839d0fa..91cae049 100644 --- a/src/apps/relay/ns_ioalib_engine_impl.c +++ b/src/apps/relay/ns_ioalib_engine_impl.c @@ -202,8 +202,8 @@ static void log_socket_event(ioa_socket_handle s, const char *msg, int error) { { char sraddr[129]="\0"; char sladdr[129]="\0"; - addr_to_string(&(s->remote_addr),(u08bits*)sraddr); - addr_to_string(&(s->local_addr),(u08bits*)sladdr); + addr_to_string(&(s->remote_addr),(uint8_t*)sraddr); + addr_to_string(&(s->local_addr),(uint8_t*)sladdr); if(EVUTIL_SOCKET_ERROR()) { 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; } -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->tszrelay_addrs = (ioa_addr*)allocate_super_memory_region(sm, relays_number * sizeof(ioa_addr)+8); 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]); } } @@ -543,7 +543,7 @@ static void timer_event_handler(evutil_socket_t fd, short what, void* arg) 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; @@ -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); 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)) { - 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)) { traffic = &(s->control_traffic); } @@ -675,7 +675,7 @@ int ioa_socket_check_bandwidth(ioa_socket_handle s, ioa_network_buffer_handle nb 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) { *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, 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, uint64_t *out_reservation_token, - int *err_code, const u08bits **reason, + int *err_code, const uint8_t **reason, accept_cb acb, void *acbarg) { @@ -972,7 +972,7 @@ int create_relay_ioa_sockets(ioa_engine_handle e, if(*err_code) { if(*err_code == 440) - *reason = (const u08bits *) "Unsupported address family"; + *reason = (const uint8_t *) "Unsupported address family"; 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) 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 read_len = (int)ioa_network_buffer_get_size(nbh); if(read_len < 1) return -1; - s08bits *new_buffer = buffer + buf_size; + char *new_buffer = buffer + buf_size; int old_buffer_len = read_len; 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: if (verbose) { 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)); } 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) { - 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 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) - u08bits ecmsg[TURN_CMSG_SZ+1]; + uint8_t ecmsg[TURN_CMSG_SZ+1]; int flags = MSG_ERRQUEUE; 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_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; @@ -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); } while (len < 0 && (errno == EINTR)); if(len<0 && errcode) - *errcode = (u32bits)errno; + *errcode = (uint32_t)errno; #else struct msghdr msg; 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))) { //Linux 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); //try again... do { @@ -2421,7 +2421,7 @@ static int socket_input_worker(ioa_socket_handle s) if(len == 0) len = -1; } 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; if(s->ssl && (len>0)) { /* DTLS */ 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)) { 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); IOA_CLOSE_SOCKET(s); return; @@ -2767,7 +2767,7 @@ static void eventcb_bev(struct bufferevent *bev, short events, void *arg) { 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(server->verbose) 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)) @@ -2925,7 +2925,7 @@ static int ssl_send(ioa_socket_handle s, const s08bits* buffer, int len, int ver case SSL_ERROR_SSL: if (verbose) { 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), SSL_get_error(ssl, rc)); } @@ -2945,7 +2945,7 @@ static int send_ssl_backlog_buffers(ioa_socket_handle s) if(s) { stun_buffer_list_elem *buf_elem = s->bufs.head; 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) break; ++ret; @@ -2976,7 +2976,7 @@ int would_block(void) { 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; 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); ret = ssl_send( s, - (s08bits*) ioa_network_buffer_data(nbh), + (char*) ioa_network_buffer_data(nbh), ioa_network_buffer_get_size(nbh), ((s->e) && s->e->verbose)); 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) add_buffer_to_buffer_list( &(s->bufs), - (s08bits*) ioa_network_buffer_data(nbh), + (char*) ioa_network_buffer_data(nbh), ioa_network_buffer_get_size(nbh)); } 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, 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) { s->tobeclosed = 1; #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(dest_addr && (perr==EADDRNOTAVAIL)) { char sfrom[129]; - addr_to_string(&(s->local_addr), (u08bits*)sfrom); + addr_to_string(&(s->local_addr), (uint8_t*)sfrom); 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, "%s: network error: address unreachable from %s to %s\n", __FUNCTION__,sfrom,sto); @@ -3406,7 +3406,7 @@ void ioa_network_buffer_header_init(ioa_network_buffer_handle 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; 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; } -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; 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; 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; 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); if(ct != ss->start_time) { ct = ct - ss->start_time; - ss->received_rate = (u32bits)(ss->t_received_bytes / ct); - ss->sent_rate = (u32bits)(ss->t_sent_bytes / ct); + ss->received_rate = (uint32_t)(ss->t_received_bytes / ct); + ss->sent_rate = (uint32_t)(ss->t_sent_bytes / ct); ss->total_rate = ss->received_rate + ss->sent_rate; } } @@ -3644,7 +3644,7 @@ struct _super_memory { size_t *sm_allocated; size_t sm_total_sz; size_t sm_chunk; - u32bits id; + uint32_t id; }; 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; while(r->id == 0) - r->id = (u32bits)random(); + r->id = (uint32_t)random(); pthread_mutex_init(&r->mutex_sm, NULL); } diff --git a/src/apps/relay/ns_ioalib_impl.h b/src/apps/relay/ns_ioalib_impl.h index 7b9acabe..69e748c7 100644 --- a/src/apps/relay/ns_ioalib_impl.h +++ b/src/apps/relay/ns_ioalib_impl.h @@ -157,11 +157,11 @@ struct _ioa_engine #endif turn_time_t jiffie; /* bandwidth check interval */ ioa_timer_handle timer_ev; - s08bits cmsg[TURN_CMSG_SZ+1]; + char cmsg[TURN_CMSG_SZ+1]; int predef_timer_intervals[PREDEF_TIMERS_NUM]; struct timeval predef_timers[PREDEF_TIMERS_NUM]; /* Relays */ - s08bits relay_ifname[1025]; + char relay_ifname[1025]; int default_relays; size_t relays_number; size_t relay_addr_counter; @@ -180,7 +180,7 @@ struct _ioa_socket { evutil_socket_t fd; struct _ioa_socket *parent_s; - u32bits magic; + uint32_t magic; ur_addr_map *sockets_container; /* relay container for UDP sockets */ struct bufferevent *bev; ioa_network_buffer_handle defer_nbh; @@ -188,7 +188,7 @@ struct _ioa_socket SOCKET_TYPE st; SOCKET_APP_TYPE sat; SSL* ssl; - u32bits ssl_renegs; + uint32_t ssl_renegs; int in_write; int bound; int local_addr_known; @@ -236,7 +236,7 @@ typedef struct _timer_event ioa_engine_handle e; ioa_timer_event_handler cb; void *ctx; - s08bits* txt; + char* txt; } 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, struct event_base *eb, turnipports* tp, - const s08bits* relay_if, - size_t relays_number, s08bits **relay_addrs, int default_relays, + const char* relay_if, + size_t relays_number, char **relay_addrs, int default_relays, int verbose #if !defined(TURN_NO_HIREDIS) ,const char* redis_report_connection_string @@ -273,8 +273,8 @@ void delete_socket_from_map(ioa_socket_handle s); int is_connreset(void); int would_block(void); -int udp_send(ioa_socket_handle s, const ioa_addr* dest_addr, const s08bits* 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_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, 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 set_raw_socket_ttl_options(evutil_socket_t fd, int family); diff --git a/src/apps/relay/tls_listener.c b/src/apps/relay/tls_listener.c index 1a76eafd..a75c1875 100644 --- a/src/apps/relay/tls_listener.c +++ b/src/apps/relay/tls_listener.c @@ -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) { perror("Cannot bind local socket to addr"); 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); if(addr_bind_cycle++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); return -1; } diff --git a/src/apps/relay/turn_admin_server.c b/src/apps/relay/turn_admin_server.c index 1d7c8f68..7e03964a 100644 --- a/src/apps/relay/turn_admin_server.c +++ b/src/apps/relay/turn_admin_server.c @@ -282,9 +282,9 @@ static void cli_print_addr(struct cli_session* cs, ioa_addr *value, int use_port sc=" (**)"; char s[256]; if(!use_port) - addr_to_string_no_port(value,(u08bits*)s); + addr_to_string_no_port(value,(uint8_t*)s); else - addr_to_string(value,(u08bits*)s); + addr_to_string(value,(uint8_t*)s); 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; for(i=0;isize;i++) { 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 - 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); } } @@ -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)); { 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]) - 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]) - 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]) - 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", tsi->remote_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; for(i=0;imain_peers_size;++i) { 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); } if(tsi->extra_peers_size && tsi->extra_peers_data) { for(i=0;iextra_peers_size;++i) { 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); } } @@ -1349,7 +1349,7 @@ void setup_admin_thread(void) // Setup the web-admin server if(use_web_admin) { 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); return; } @@ -1358,7 +1358,7 @@ void setup_admin_thread(void) addr_set_port(&web_admin_addr, web_admin_port); 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); @@ -1372,7 +1372,7 @@ void setup_admin_thread(void) if(use_cli) { 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); return; } @@ -1390,7 +1390,7 @@ void setup_admin_thread(void) if(addr_bind(adminserver.listen_fd,&cli_addr,1,1,TCP_SOCKET)<0) { perror("Cannot bind CLI socket to addr"); 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); socket_closesocket(adminserver.listen_fd); return; @@ -1895,9 +1895,9 @@ static void https_print_addr(struct str_buffer* sb, ioa_addr *value, int use_por if(sb && name && value) { char s[256]; if(!use_port) - addr_to_string_no_port(value,(u08bits*)s); + addr_to_string_no_port(value,(uint8_t*)s); else - addr_to_string(value,(u08bits*)s); + addr_to_string(value,(uint8_t*)s); sbprintf(sb," %s %s\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; for(i=0;isize;i++) { 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 - addr_to_string(&(value->addrs[i]),(u08bits*)s); + addr_to_string(&(value->addrs[i]),(uint8_t*)s); sbprintf(sb," %s %s\r\n",name,s); } return i; @@ -2013,13 +2013,13 @@ static void update_param(const char* pn, const char *value) if (dbd && dbd->set_realm_option_one) { if(strstr(pn,"cr-total-quota")==pn) { 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) { 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) { 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,""); { 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]) - 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]) - 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]) - 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,""); 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; for(i=0;imain_peers_size;++i) { 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,tsi->main_peers_data[i].saddr); 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) { for(i=0;iextra_peers_size;++i) { 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,tsi->extra_peers_data[i].saddr); str_buffer_append(sb," "); @@ -2509,7 +2509,7 @@ static size_t https_print_users(struct str_buffer* sb) secrets_list_t users,realms; init_secrets_list(&users); 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 i; @@ -2548,7 +2548,7 @@ static size_t https_print_users(struct str_buffer* sb) 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)) { @@ -2657,7 +2657,7 @@ static size_t https_print_secrets(struct str_buffer* sb) secrets_list_t secrets,realms; init_secrets_list(&secrets); 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 i; @@ -2791,7 +2791,7 @@ static size_t https_print_origins(struct str_buffer* sb) secrets_list_t origins,realms; init_secrets_list(&origins); 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 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(); if (dbd && dbd->get_oauth_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"); } else { @@ -3232,7 +3232,7 @@ static void handle_update_request(ioa_socket_handle s, struct http_request* hr) //forbidden } else { - u08bits realm[STUN_MAX_REALM_SIZE+1]="\0"; + uint8_t realm[STUN_MAX_REALM_SIZE+1]="\0"; STRCPY(realm,r); 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 } else { - u08bits realm[STUN_MAX_REALM_SIZE+1]="\0"; + uint8_t realm[STUN_MAX_REALM_SIZE+1]="\0"; STRCPY(realm,r); 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); } - 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(); if (dbd && dbd->get_admin_user) { password_t password; 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)) { STRCPY(as->as_login,uname); 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]) { - 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()) { - realm = (const u08bits*)current_realm(); + realm = (const uint8_t*)current_realm(); } if(realm && realm[0]) { const turn_dbdriver_t * dbd = get_dbdriver(); if (dbd && dbd->del_user) { - u08bits u[STUN_MAX_USERNAME_SIZE+1]; - u08bits r[STUN_MAX_REALM_SIZE+1]; + uint8_t u[STUN_MAX_USERNAME_SIZE+1]; + uint8_t r[STUN_MAX_REALM_SIZE+1]; STRCPY(u,user); STRCPY(r,realm); 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 u08bits *add_user = (const u08bits*)get_http_header_value(hr, HR_ADD_USER,""); + const uint8_t *add_realm = (const uint8_t*)current_eff_realm(); + const uint8_t *add_user = (const uint8_t*)get_http_header_value(hr, HR_ADD_USER,""); const char* msg = ""; if(wrong_html_name((const char*)add_user)) { msg = "Error: wrong user name"; - add_user = (const u08bits*)""; + add_user = (const uint8_t*)""; } 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()) { - add_realm = (const u08bits*)current_realm(); + add_realm = (const uint8_t*)current_realm(); } if(!add_realm[0]) { - add_realm=(const u08bits*)current_eff_realm(); + add_realm=(const uint8_t*)current_eff_realm(); } 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)) { msg = "Error: wrong realm name"; - add_realm = (const u08bits*)""; + add_realm = (const uint8_t*)""; } if(add_realm[0]) { - const u08bits *pwd = (const u08bits*)get_http_header_value(hr, HR_PASSWORD, NULL); - const u08bits *pwd1 = (const u08bits*)get_http_header_value(hr, HR_PASSWORD1, NULL); + const uint8_t *pwd = (const uint8_t*)get_http_header_value(hr, HR_PASSWORD, 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)) { 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]; { - u08bits u[STUN_MAX_USERNAME_SIZE+1]; - u08bits r[STUN_MAX_REALM_SIZE+1]; - u08bits p[STUN_MAX_PWD_SIZE+1]; + uint8_t u[STUN_MAX_USERNAME_SIZE+1]; + uint8_t r[STUN_MAX_REALM_SIZE+1]; + uint8_t p[STUN_MAX_PWD_SIZE+1]; STRCPY(u,add_user); STRCPY(r,add_realm); 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); } - add_realm=(const u08bits*)""; - add_user=(const u08bits*)""; + add_realm=(const uint8_t*)""; + add_user=(const uint8_t*)""; } } else { 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]) { - 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()) { - realm = (const u08bits*)current_realm(); + realm = (const uint8_t*)current_realm(); } if(realm && realm[0]) { const turn_dbdriver_t * dbd = get_dbdriver(); if (dbd && dbd->del_secret) { - u08bits ss[AUTH_SECRET_SIZE+1]; - u08bits r[STUN_MAX_REALM_SIZE+1]; + uint8_t ss[AUTH_SECRET_SIZE+1]; + uint8_t r[STUN_MAX_REALM_SIZE+1]; STRCPY(ss,secret); STRCPY(r,realm); 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 u08bits *add_secret = (const u08bits*)get_http_header_value(hr, HR_ADD_SECRET, ""); + const uint8_t *add_realm = (const uint8_t*)current_eff_realm(); + const uint8_t *add_secret = (const uint8_t*)get_http_header_value(hr, HR_ADD_SECRET, ""); const char* msg = ""; if(wrong_html_name((const char*)add_secret)) { msg = "Error: wrong secret value"; - add_secret = (const u08bits*)""; + add_secret = (const uint8_t*)""; } 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()) { - add_realm = (const u08bits*)current_realm(); + add_realm = (const uint8_t*)current_realm(); } if(!add_realm[0]) { - add_realm=(const u08bits*)current_eff_realm(); + add_realm=(const uint8_t*)current_eff_realm(); } 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)) { msg = "Error: wrong realm name"; - add_realm = (const u08bits*)""; + add_realm = (const uint8_t*)""; } if(add_realm[0]) { const turn_dbdriver_t * dbd = get_dbdriver(); if (dbd && dbd->set_secret) { - u08bits ss[AUTH_SECRET_SIZE+1]; - u08bits r[STUN_MAX_REALM_SIZE+1]; + uint8_t ss[AUTH_SECRET_SIZE+1]; + uint8_t r[STUN_MAX_REALM_SIZE+1]; STRCPY(ss,add_secret); STRCPY(r,add_realm); (*dbd->set_secret)(ss, r); } - add_secret=(const u08bits*)""; - add_realm=(const u08bits*)""; + add_secret=(const uint8_t*)""; + 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()) { - 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]) { const turn_dbdriver_t * dbd = get_dbdriver(); if (dbd && dbd->del_origin) { - u08bits o[STUN_MAX_ORIGIN_SIZE+1]; + uint8_t o[STUN_MAX_ORIGIN_SIZE+1]; STRCPY(o,origin); 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); dbd->del_origin(corigin); } } } - const u08bits *add_realm = (const u08bits*)current_eff_realm(); - const u08bits *add_origin = (const u08bits*)get_http_header_value(hr, HR_ADD_ORIGIN, ""); + const uint8_t *add_realm = (const uint8_t*)current_eff_realm(); + const uint8_t *add_origin = (const uint8_t*)get_http_header_value(hr, HR_ADD_ORIGIN, ""); 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); 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()) { - add_realm = (const u08bits*)current_realm(); + add_realm = (const uint8_t*)current_realm(); } if(!add_realm[0]) { - add_realm=(const u08bits*)current_eff_realm(); + add_realm=(const uint8_t*)current_eff_realm(); } 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]) { const turn_dbdriver_t * dbd = get_dbdriver(); if (dbd && dbd->add_origin) { - u08bits o[STUN_MAX_ORIGIN_SIZE+1]; - u08bits r[STUN_MAX_REALM_SIZE+1]; + uint8_t o[STUN_MAX_ORIGIN_SIZE+1]; + uint8_t r[STUN_MAX_REALM_SIZE+1]; STRCPY(o,corigin); STRCPY(r,add_realm); (*dbd->add_origin)(o, r); } - add_origin=(const u08bits*)""; - add_realm=(const u08bits*)""; + add_origin=(const uint8_t*)""; + 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]) { const turn_dbdriver_t * dbd = get_dbdriver(); 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); 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(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) { - key.timestamp = (u64bits)time(NULL); + key.timestamp = (uint64_t)time(NULL); } } } 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); diff --git a/src/apps/relay/turn_ports.c b/src/apps/relay/turn_ports.c index 9db5a928..113eb125 100644 --- a/src/apps/relay/turn_ports.c +++ b/src/apps/relay/turn_ports.c @@ -39,38 +39,38 @@ ////////// DATA //////////////////////////////////////////// #define PORTS_SIZE (0xFFFF+1) -#define TPS_OUT_OF_RANGE ((u32bits)(-1)) -#define TPS_TAKEN_SINGLE ((u32bits)(-2)) -#define TPS_TAKEN_EVEN ((u32bits)(-3)) -#define TPS_TAKEN_ODD ((u32bits)(-4)) +#define TPS_OUT_OF_RANGE ((uint32_t)(-1)) +#define TPS_TAKEN_SINGLE ((uint32_t)(-2)) +#define TPS_TAKEN_EVEN ((uint32_t)(-3)) +#define TPS_TAKEN_ODD ((uint32_t)(-4)) struct _turnports { - u32bits status[PORTS_SIZE]; - u32bits low; - u32bits high; - u16bits range_start; - u16bits range_stop; - u16bits ports[PORTS_SIZE]; + uint32_t status[PORTS_SIZE]; + uint32_t low; + uint32_t high; + uint16_t range_start; + uint16_t range_stop; + uint16_t ports[PORTS_SIZE]; TURN_MUTEX_DECLARE(mutex) }; typedef struct _turnports turnports; /////////////// TURNPORTS statics ////////////////////////// -static turnports* turnports_create(super_memory_t *sm, u16bits start, u16bits end); -static u16bits turnports_size(turnports* tp); +static turnports* turnports_create(super_memory_t *sm, uint16_t start, uint16_t end); +static uint16_t turnports_size(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_available(turnports* tp, u16bits port); +static int turnports_is_allocated(turnports* tp, uint16_t port); +static int turnports_is_available(turnports* tp, uint16_t port); /////////////// UTILS ////////////////////////////////////// -static int is_taken(u32bits status) { +static int is_taken(uint32_t status) { int ret = -1; switch (status) { case TPS_TAKEN_SINGLE : @@ -90,26 +90,26 @@ static void turnports_randomize(turnports* tp) { unsigned int i=0; unsigned int cycles=size*10; for(i=0;ilow + (u16bits)(((unsigned long)random())%((unsigned long)size))); - u16bits port2 = (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))); + uint16_t port2 = (uint16_t)(tp->low + (uint16_t)(((unsigned long)random())%((unsigned long)size))); if(port1!=port2) { int pos1=tp->status[port1]; int pos2=tp->status[port2]; int tmp=(int)tp->status[port1]; tp->status[port1]=tp->status[port2]; - tp->status[port2]=(u32bits)tmp; + tp->status[port2]=(uint32_t)tmp; tmp=(int)tp->ports[pos1]; 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->high=((u32bits)end)+1; + tp->high=((uint32_t)end)+1; tp->range_start=start; tp->range_stop=end; @@ -117,15 +117,15 @@ static void turnports_init(turnports* tp, u16bits start, u16bits end) { int i=0; for(i=0;istatus[i]=TPS_OUT_OF_RANGE; - tp->ports[i]=(u16bits)i; + tp->ports[i]=(uint16_t)i; } for(i=start;i<=end;i++) { - tp->status[i]=(u32bits)i; - tp->ports[i]=(u16bits)i; + tp->status[i]=(uint32_t)i; + tp->ports[i]=(uint16_t)i; } for(i=((int)end)+1;istatus[i]=TPS_OUT_OF_RANGE; - tp->ports[i]=(u16bits)i; + tp->ports[i]=(uint16_t)i; } turnports_randomize(tp); @@ -135,7 +135,7 @@ static void turnports_init(turnports* tp, u16bits start, u16bits end) { /////////////// 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; @@ -145,11 +145,11 @@ turnports* turnports_create(super_memory_t *sm, u16bits start, u16bits end) { return ret; } -u16bits turnports_size(turnports* tp) { +uint16_t turnports_size(turnports* tp) { if(!tp) return 0; else { 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); return ret; } @@ -170,7 +170,7 @@ int turnports_allocate(turnports* tp) { return -1; } - int position=(u16bits)(tp->low & 0x0000FFFF); + int position=(uint16_t)(tp->low & 0x0000FFFF); port=(int)tp->ports[position]; if(port<(int)(tp->range_start) || port>((int)(tp->range_stop))) { @@ -196,10 +196,10 @@ int turnports_allocate(turnports* tp) { return port; } -void turnports_release(turnports* tp, u16bits port) { +void turnports_release(turnports* tp, uint16_t port) { TURN_MUTEX_LOCK(&tp->mutex); 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])) { tp->status[port]=tp->high; tp->ports[position]=port; @@ -209,12 +209,12 @@ void turnports_release(turnports* tp, u16bits port) { 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) { TURN_MUTEX_LOCK(&tp->mutex); - u16bits size = turnports_size(tp); + uint16_t size = turnports_size(tp); if(size>1) { - u16bits i=0; + uint16_t i=0; for(i=0;istatus[port]=TPS_TAKEN_EVEN; tp->status[rtcp_port]=TPS_TAKEN_ODD; if(reservation_token) { - u16bits *v16=(u16bits*)reservation_token; - u32bits *v32=(u32bits*)reservation_token; - v16[0]=(u16bits)(tp->ports[(u16bits)(tp->low & 0x0000FFFF)]); - v16[1]=(u16bits)(tp->ports[(u16bits)(tp->high & 0x0000FFFF)]); - v32[1]=(u32bits)turn_random(); + uint16_t *v16=(uint16_t*)reservation_token; + uint32_t *v32=(uint32_t*)reservation_token; + v16[0]=(uint16_t)(tp->ports[(uint16_t)(tp->low & 0x0000FFFF)]); + v16[1]=(uint16_t)(tp->ports[(uint16_t)(tp->high & 0x0000FFFF)]); + v32[1]=(uint32_t)turn_random(); } TURN_MUTEX_UNLOCK(&tp->mutex); return port; @@ -251,7 +251,7 @@ int turnports_allocate_even(turnports* tp, int allocate_rtcp, u64bits *reservati return -1; } -int turnports_is_allocated(turnports* tp, u16bits port) { +int turnports_is_allocated(turnports* tp, uint16_t port) { if(!tp) return 0; else { 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) { 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)) { - u16bits position=(u16bits)(status & 0x0000FFFF); + uint16_t position=(uint16_t)(status & 0x0000FFFF); if(tp->ports[position]==port) { TURN_MUTEX_UNLOCK(&tp->mutex); return 1; @@ -282,8 +282,8 @@ int turnports_is_available(turnports* tp, u16bits port) { struct _turnipports { super_memory_t *sm; - u16bits start; - u16bits end; + uint16_t start; + uint16_t end; ur_addr_map ip_to_turnports_udp; ur_addr_map ip_to_turnports_tcp; 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) 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; -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)); ret->sm = sm; @@ -314,7 +314,7 @@ turnipports* turnipports_create(super_memory_t *sm, u16bits start, u16bits end) 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; if (tp && backend_addr) { @@ -331,12 +331,12 @@ static turnports* turnipports_add(turnipports* tp, u08bits transport, const ioa_ 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); } -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; 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, - u64bits *reservation_token) + uint64_t *reservation_token) { int ret = -1; if (tp && backend_addr) { @@ -361,7 +361,7 @@ int turnipports_allocate_even(turnipports* tp, const ioa_addr *backend_addr, int 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) { 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; if (tp && backend_addr) { @@ -393,7 +393,7 @@ int turnipports_is_allocated(turnipports* tp, u08bits transport, const ioa_addr 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; if (tp && backend_addr) { diff --git a/src/apps/relay/turn_ports.h b/src/apps/relay/turn_ports.h index 6b059afb..6a363c49 100644 --- a/src/apps/relay/turn_ports.h +++ b/src/apps/relay/turn_ports.h @@ -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 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_available(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, uint8_t transport, const ioa_addr *backend_addr, uint16_t port); ////////////////////////////////////////////////// diff --git a/src/apps/relay/userdb.c b/src/apps/relay/userdb.c index 2cd45e8a..76d0c7c5 100644 --- a/src/apps/relay/userdb.c +++ b/src/apps/relay/userdb.c @@ -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; const turn_dbdriver_t * dbd = get_dbdriver(); @@ -398,7 +398,7 @@ static char *get_real_username(char *usname) /* * 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; @@ -413,7 +413,7 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u if(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; @@ -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"); 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)) { - u08bits hmac[MAXSHASIZE]; + uint8_t hmac[MAXSHASIZE]; unsigned int hmac_len; 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); 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; 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) { free(pwd); } 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, 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; } -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; @@ -656,11 +656,11 @@ u08bits *start_user_check(turnserver_id id, turn_credential_type ct, int in_oaut 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; 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); 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)) { @@ -689,10 +689,10 @@ int check_new_allocation_quota(u08bits *user, int oauth, u08bits *realm) 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) { - 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); ur_string_map_lock(rp->status.alloc_counters); if(username[0]) { @@ -724,7 +724,7 @@ int add_static_user_account(char *user) char *usname = (char*)malloc(sizeof(char)*(ulen+1)); strncpy(usname,user,ulen); 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); free(usname); return -1; @@ -744,7 +744,7 @@ int add_static_user_account(char *user) } } else { //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); @@ -762,7 +762,7 @@ int add_static_user_account(char *user) ////////////////// 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(); if (dbd) { @@ -780,7 +780,7 @@ static int list_users(u08bits *realm, int is_admin) return 0; } -static int show_secret(u08bits *realm) +static int show_secret(uint8_t *realm) { const turn_dbdriver_t * dbd = get_dbdriver(); if (dbd && dbd->list_secrets) { @@ -790,7 +790,7 @@ static int show_secret(u08bits *realm) 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); @@ -802,7 +802,7 @@ static int del_secret(u08bits *secret, u08bits *realm) { 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)) return 0; @@ -819,9 +819,9 @@ static int set_secret(u08bits *secret, u08bits *realm) { 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); @@ -833,9 +833,9 @@ static int add_origin(u08bits *origin0, u08bits *realm) 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); @@ -847,7 +847,7 @@ static int del_origin(u08bits *origin0) return 0; } -static int list_origins(u08bits *realm) +static int list_origins(uint8_t *realm) { const turn_dbdriver_t * dbd = get_dbdriver(); if (dbd && dbd->list_origins) { @@ -857,7 +857,7 @@ static int list_origins(u08bits *realm) 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) return 0; @@ -870,7 +870,7 @@ static int set_realm_option_one(u08bits *realm, unsigned long value, const char* 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->user_quota,"user-quota"); @@ -878,7 +878,7 @@ static int set_realm_option(u08bits *realm, perf_options_t *po) return 0; } -static int list_realm_options(u08bits *realm) +static int list_realm_options(uint8_t *realm) { const turn_dbdriver_t * dbd = get_dbdriver(); if (dbd && dbd->list_realm_options) { @@ -888,7 +888,7 @@ static int list_realm_options(u08bits *realm) 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; char skey[sizeof(hmackey_t) * 2 + 1]; @@ -1021,7 +1021,7 @@ void run_db_test(void) printf("DB TEST 2:\n"); oauth_key_data_raw 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", 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"); key->timestamp = 123; key->lifetime = 456; - dbd->del_oauth_key((const u08bits*)"kid"); + dbd->del_oauth_key((const uint8_t*)"kid"); dbd->set_oauth_key(key); dbd->list_oauth_keys(); 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", key->kid, key->ikm_key, (unsigned long long)key->timestamp, (unsigned long)key->lifetime, key->as_rs_alg); printf("DB TEST 5:\n"); - dbd->del_oauth_key((const u08bits*)"kid"); + dbd->del_oauth_key((const uint8_t*)"kid"); dbd->list_oauth_keys(); 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; 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; - 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); free(range); return -1; } 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); free(range); return -1; @@ -1264,14 +1264,14 @@ int check_ip_list_range(const char * range0) 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); free(range); return -1; } 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); free(range); return -1; diff --git a/src/apps/relay/userdb.h b/src/apps/relay/userdb.h index c14a24e9..a1c03720 100644 --- a/src/apps/relay/userdb.h +++ b/src/apps/relay/userdb.h @@ -83,13 +83,13 @@ struct auth_message { int in_oauth; int out_oauth; int max_session_time; - u08bits username[STUN_MAX_USERNAME_SIZE + 1]; - u08bits realm[STUN_MAX_REALM_SIZE + 1]; + uint8_t username[STUN_MAX_USERNAME_SIZE + 1]; + uint8_t realm[STUN_MAX_REALM_SIZE + 1]; hmackey_t key; password_t pwd; get_username_resume_cb resume_func; ioa_net_data in_buffer; - u64bits ctxkey; + uint64_t ctxkey; int success; }; @@ -185,10 +185,10 @@ void add_to_secrets_list(secrets_list_t *sl, const char* elem); /////////// 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); -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); -int check_new_allocation_quota(u08bits *username, int oauth, u08bits *realm); -void release_allocation_quota(u08bits *username, int oauth, u08bits *realm); +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); +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(uint8_t *username, int oauth, uint8_t *realm); +void release_allocation_quota(uint8_t *username, int oauth, uint8_t *realm); /////////// 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 reread_realms(void); 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 check_ip_list_range(const char* range); diff --git a/src/apps/rfc5769/rfc5769check.c b/src/apps/rfc5769/rfc5769check.c index df419fb1..579dfca9 100644 --- a/src/apps/rfc5769/rfc5769check.c +++ b/src/apps/rfc5769/rfc5769check.c @@ -143,8 +143,8 @@ static int check_oauth(void) { encoded_oauth_token etoken; bzero(&etoken,sizeof(etoken)); - 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", __FUNCTION__); return -1; @@ -154,7 +154,7 @@ static int check_oauth(void) { 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) { fprintf(stderr, "%s: cannot decode oauth token\n", __FUNCTION__); @@ -235,7 +235,7 @@ int main(int argc, const char **argv) "\x80\x28\x00\x04" "\xe5\x7a\x3b\xcf"; - u08bits buf[sizeof(reqstc)]; + uint8_t buf[sizeof(reqstc)]; memcpy(buf, reqstc, sizeof(reqstc)); {//fingerprintfs etc @@ -252,9 +252,9 @@ int main(int argc, const char **argv) } {//short-term credentials - u08bits uname[33]; - u08bits realm[33]; - u08bits upwd[33]; + uint8_t uname[33]; + uint8_t realm[33]; + uint8_t upwd[33]; strcpy((char*) upwd, "VOkJxbRl1RmTxUk/WvJxBt"); 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" "\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"; - u08bits realm[33]; - u08bits nonce[29]; - u08bits upwd[33]; + uint8_t realm[33]; + uint8_t nonce[29]; + uint8_t upwd[33]; - u08bits buf[sizeof(reqltc)]; + uint8_t buf[sizeof(reqltc)]; memcpy(buf, reqltc, sizeof(reqltc)); - u08bits uname[sizeof(user)]; + uint8_t uname[sizeof(user)]; memcpy(uname, user, sizeof(user)); strcpy((char*) realm, "example.org"); @@ -338,13 +338,13 @@ int main(int argc, const char **argv) { //encoding test printf("RFC 5769 message encoding test result: "); size_t len = 0; - u16bits message_type = STUN_METHOD_BINDING; + uint16_t message_type = STUN_METHOD_BINDING; stun_tid tid; - u16bits *buf16 = (u16bits*)buf; - u32bits *buf32 = (u32bits*)buf; + uint16_t *buf16 = (uint16_t*)buf; + uint32_t *buf32 = (uint32_t*)buf; memcpy(tid.tsx_id,"\x78\xad\x34\x33\xc6\xad\x72\xc0\x29\xda\x41\x2e",12); stun_init_buffer_str(buf,&len); - message_type &= (u16bits)(0x3FFF); + message_type &= (uint16_t)(0x3FFF); buf16[0]=nswap16(message_type); buf16[1]=0; buf32[1]=nswap32(STUN_MAGIC_COOKIE); @@ -363,7 +363,7 @@ int main(int argc, const char **argv) int cols = 4; for(line = 0;line= 0) { turn::StunAttrResponsePort rpa; - rpa.setResponsePort((u16bits)response_port); + rpa.setResponsePort((uint16_t)response_port); try { req.addAttr(rpa); } 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; stun_buffer buf; - u08bits *ptr = buf.buf; + uint8_t *ptr = buf.buf; int recvd = 0; 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; 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); 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); 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) { - 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(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__); } } @@ -323,7 +323,7 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i { int len = 0; - u08bits *ptr = buf.buf; + uint8_t *ptr = buf.buf; int recvd = 0; 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("RFC 5780 response %d\n",++counter); 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); if (sar) { 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, &other_addr, "Other addr: "); @@ -377,7 +377,7 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i } } else { int err_code = 0; - u08bits err_msg[1025] = "\0"; + uint8_t err_msg[1025] = "\0"; size_t err_msg_size = sizeof(err_msg); 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); @@ -445,7 +445,7 @@ int main(int argc, char **argv) addr_set_any(&real_local_addr); 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); } } diff --git a/src/apps/uclient/mainuclient.c b/src/apps/uclient/mainuclient.c index d9204fae..8a824cc8 100644 --- a/src/apps/uclient/mainuclient.c +++ b/src/apps/uclient/mainuclient.c @@ -60,7 +60,7 @@ ioa_addr peer_addr; int no_rtcp = 0; int default_address_family = STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_DEFAULT; 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; char g_auth_secret[1025]="\0"; int g_use_auth_secret_with_timestamp = 0; @@ -73,7 +73,7 @@ char pkey_file[1025]=""; SSL_CTX *root_tls_ctx[32]; 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] = ""; int passive_tcp = 0; int mandatory_channel_padding = 0; @@ -389,7 +389,7 @@ int main(int argc, char **argv) STRCPY(g_uname,new_uname); } { - u08bits hmac[MAXSHASIZE]; + uint8_t hmac[MAXSHASIZE]; unsigned int hmac_len; switch(shatype) { @@ -408,7 +408,7 @@ int main(int argc, char **argv) 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; char *pwd = base64_encode(hmac,hmac_len,&pwd_length); @@ -454,7 +454,7 @@ int main(int argc, char **argv) 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; } diff --git a/src/apps/uclient/session.h b/src/apps/uclient/session.h index 33fb278b..fd77e5b0 100644 --- a/src/apps/uclient/session.h +++ b/src/apps/uclient/session.h @@ -61,7 +61,7 @@ typedef enum _UR_STATE UR_STATE; typedef struct { /* RFC 6062 */ - u32bits cid; + uint32_t cid; ioa_addr tcp_data_local_addr; ioa_socket_raw tcp_data_fd; SSL *tcp_data_ssl; @@ -79,11 +79,11 @@ typedef struct { ioa_socket_raw fd; SSL *ssl; int broken; - u08bits nonce[STUN_MAX_NONCE_SIZE+1]; - u08bits realm[STUN_MAX_REALM_SIZE+1]; + uint8_t nonce[STUN_MAX_NONCE_SIZE+1]; + uint8_t realm[STUN_MAX_REALM_SIZE+1]; /* 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; int key_set; int cok; @@ -106,26 +106,26 @@ typedef struct { struct event *input_tcp_data_ev; stun_buffer in_buffer; stun_buffer out_buffer; - u32bits refresh_time; - u32bits finished_time; + uint32_t refresh_time; + uint32_t finished_time; //Msg counters: int tot_msgnum; int wmsgnum; int rmsgnum; int recvmsgnum; - u32bits recvtimems; - u32bits to_send_timems; + uint32_t recvtimems; + uint32_t to_send_timems; //Statistics: size_t loss; - u64bits latency; - u64bits jitter; + uint64_t latency; + uint64_t jitter; } app_ur_session; /////////////////////////////////////////////////////// typedef struct _message_info { int msgnum; - u64bits mstime; + uint64_t mstime; } message_info; /////////////////////////////////////////////////////////////////////////////// diff --git a/src/apps/uclient/startuclient.c b/src/apps/uclient/startuclient.c index f0b3135d..96e53722 100644 --- a/src/apps/uclient/startuclient.c +++ b/src/apps/uclient/startuclient.c @@ -223,7 +223,7 @@ static int clnet_connect(uint16_t clnet_remote_port, const char *remote_address, connect_err = 0; 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) 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(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; } } 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; } } @@ -263,7 +263,7 @@ static int clnet_connect(uint16_t clnet_remote_port, const char *remote_address, } 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) return -1; @@ -315,7 +315,7 @@ int read_mobility_ticket(app_ur_conn_info *clnet_info, stun_buffer *message) if(s_mobile_id_sar) { int smid_len = stun_attr_get_len(s_mobile_id_sar); if(smid_len>0 && (((size_t)smid_len)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) { bcopy(smid_val, clnet_info->s_mobile_id, (size_t)smid_len); clnet_info->s_mobile_id[smid_len] = 0; @@ -348,7 +348,7 @@ static int clnet_allocate(int verbose, app_ur_conn_info *clnet_info, ioa_addr *relay_addr, int af, - char *turn_addr, u16bits *turn_port) { + char *turn_addr, uint16_t *turn_port) { int af_cycle = 0; int reopen_socket = 0; @@ -368,7 +368,7 @@ static int clnet_allocate(int verbose, if(reopen_socket && !use_tcp) { socket_closesocket(clnet_info->fd); 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) { exit(-1); } @@ -394,7 +394,7 @@ static int clnet_allocate(int verbose, } else if(rt) { ep = -1; } else if(!ep) { - ep = (((u08bits)random()) % 2); + ep = (((uint8_t)random()) % 2); ep = ep-1; } @@ -448,7 +448,7 @@ static int clnet_allocate(int verbose, } response_message.len = len; int err_code = 0; - u08bits err_msg[129]; + uint8_t err_msg[129]; if (stun_is_success_response(&response_message)) { allocate_received = 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) { //error } else if(turn_addr && turn_port){ - addr_to_string_no_port(&alternate_server, (u08bits*)turn_addr); - *turn_port = (u16bits)addr_get_port(&alternate_server); + addr_to_string_no_port(&alternate_server, (uint8_t*)turn_addr); + *turn_port = (uint16_t)addr_get_port(&alternate_server); } } @@ -651,10 +651,10 @@ static int clnet_allocate(int verbose, } if(dual_allocation && !mobility) { - int t = ((u08bits)random())%3; + int t = ((uint8_t)random())%3; if(t) { - u08bits field[4]; - field[0] = (t==1) ? (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4 : (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6; + uint8_t field[4]; + 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[2]=0; field[3]=0; @@ -709,7 +709,7 @@ static int clnet_allocate(int verbose, } response_message.len = len; int err_code = 0; - u08bits err_msg[129]; + uint8_t err_msg[129]; if (stun_is_success_response(&response_message)) { read_mobility_ticket(clnet_info, &response_message); refresh_received = 1; @@ -753,7 +753,7 @@ static int turn_channel_bind(int verbose, uint16_t *chn, int cb_sent = 0; 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 { *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"); } int err_code = 0; - u08bits err_msg[129]; + uint8_t err_msg[129]; if (stun_is_success_response(&response_message)) { cb_received = 1; @@ -844,7 +844,7 @@ static int turn_create_permission(int verbose, app_ur_conn_info *clnet_info, char saddr[129]="\0"; if (verbose) { - addr_to_string(peer_addr,(u08bits*)saddr); + addr_to_string(peer_addr,(uint8_t*)saddr); } 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"); } int err_code = 0; - u08bits err_msg[129]; + uint8_t err_msg[129]; if (stun_is_success_response(&response_message)) { cp_received = 1; @@ -1031,18 +1031,18 @@ int start_connection(uint16_t clnet_remote_port0, if(random() % 2 == 0) sarbaddr = "2001::172"; ioa_addr arbaddr; - make_ioa_addr((const u08bits*)sarbaddr, 333, &arbaddr); + make_ioa_addr((const uint8_t*)sarbaddr, 333, &arbaddr); int i; int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS; for(i=0;i0) addr_cpy(&arbaddr[i],&arbaddr[0]); 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; //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); } turn_create_permission(verbose, clnet_info, arbaddr, maxi); @@ -1097,17 +1097,17 @@ int start_connection(uint16_t clnet_remote_port0, if(random() % 2 == 0) sarbaddr = "2001::172"; 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 maxi = (unsigned short)random() % EXTRA_CREATE_PERMS; for(i=0;i0) addr_cpy(&arbaddr[i],&arbaddr[0]); 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; //char sss[128]; - //addr_to_string(&arbaddr,(u08bits*)sss); + //addr_to_string(&arbaddr,(uint8_t*)sss); //printf("%s: 111.111: %s\n",__FUNCTION__,sss); } 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) sarbaddr = "2001::172"; ioa_addr arbaddr; - make_ioa_addr((const u08bits*)sarbaddr, 333, &arbaddr); + make_ioa_addr((const uint8_t*)sarbaddr, 333, &arbaddr); int i; int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS; for(i=0;i0) addr_cpy(&arbaddr[i],&arbaddr[0]); 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; //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); } 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) sarbaddr = "2001::172"; ioa_addr arbaddr; - make_ioa_addr((const u08bits*)sarbaddr, 333, &arbaddr); + make_ioa_addr((const uint8_t*)sarbaddr, 333, &arbaddr); int i; int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS; for(i=0;icid; + uint32_t cid = atc->cid; 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); @@ -1474,7 +1474,7 @@ static int turn_tcp_connection_bind(int verbose, app_ur_conn_info *clnet_info, a "connect bind response received: \n"); } int err_code = 0; - u08bits err_msg[129]; + uint8_t err_msg[129]; if (stun_is_success_response(&response_message)) { 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; } -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 connect_cycle = 0; diff --git a/src/apps/uclient/startuclient.h b/src/apps/uclient/startuclient.h index 30b6d31e..f04e00dd 100644 --- a/src/apps/uclient/startuclient.h +++ b/src/apps/uclient/startuclient.h @@ -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); -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); diff --git a/src/apps/uclient/uclient.c b/src/apps/uclient/uclient.c index b2a05ec8..7e229c80 100644 --- a/src/apps/uclient/uclient.c +++ b/src/apps/uclient/uclient.c @@ -46,20 +46,20 @@ static int verbose_packets=0; static size_t current_clients_number = 0; static int start_full_timer=0; -static u32bits tot_messages=0; -static u32bits tot_send_messages=0; -static u64bits tot_send_bytes = 0; -static u32bits tot_recv_messages=0; -static u64bits tot_recv_bytes = 0; -static u64bits tot_send_dropped = 0; +static uint32_t tot_messages=0; +static uint32_t tot_send_messages=0; +static uint64_t tot_send_bytes = 0; +static uint32_t tot_recv_messages=0; +static uint64_t tot_recv_bytes = 0; +static uint64_t tot_send_dropped = 0; struct event_base* client_event_base=NULL; static int client_write(app_ur_session *elem); static int client_shutdown(app_ur_session *elem); -static u64bits current_time = 0; -static u64bits current_mstime = 0; +static uint64_t current_time = 0; +static uint64_t current_mstime = 0; static char buffer_to_send[65536]="\0"; @@ -74,18 +74,18 @@ static app_ur_session** elems = NULL; int RTP_PACKET_INTERVAL = 20; -static inline s64bits time_minus(u64bits t1, u64bits t2) { - return ( (s64bits)t1 - (s64bits)t2 ); +static inline int64_t time_minus(uint64_t t1, uint64_t t2) { + return ( (int64_t)t1 - (int64_t)t2 ); } -static u64bits total_loss = 0; -static u64bits total_jitter = 0; -static u64bits total_latency = 0; +static uint64_t total_loss = 0; +static uint64_t total_jitter = 0; +static uint64_t total_latency = 0; -static u64bits min_latency = 0xFFFFFFFF; -static u64bits max_latency = 0; -static u64bits min_jitter = 0xFFFFFFFF; -static u64bits max_jitter = 0; +static uint64_t min_latency = 0xFFFFFFFF; +static uint64_t max_latency = 0; +static uint64_t min_jitter = 0xFFFFFFFF; +static uint64_t max_jitter = 0; static int show_statistics = 0; @@ -93,7 +93,7 @@ static int show_statistics = 0; /////////////////////////////////////////////////////////////////////////////// static void __turn_getMSTime(void) { - static u64bits start_sec = 0; + static uint64_t start_sec = 0; struct timespec tp={0,0}; #if defined(CLOCK_REALTIME) clock_gettime(CLOCK_REALTIME, &tp); @@ -102,15 +102,15 @@ static void __turn_getMSTime(void) { #endif if(!start_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; - current_time = (u64bits)((u64bits)(tp.tv_sec)-start_sec); - current_mstime = (u64bits)((current_time * 1000) + (tp.tv_nsec/1000000)); + current_time = (uint64_t)((uint64_t)(tp.tv_sec)-start_sec); + 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 //////////////////////////////////////// @@ -202,7 +202,7 @@ int send_buffer(app_ur_conn_info *clnet_info, stun_buffer* message, int data_con while(np-->0) { int pos = (int)((unsigned long)random()%(unsigned long)message->len); 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; stun_tid tid; - u16bits method = 0; + uint16_t method = 0; if(request_message) { 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) { stun_tid recv_tid; - u16bits recv_method = 0; + uint16_t recv_method = 0; stun_tid_from_message(message, &recv_tid); 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); int err_code = 0; - u08bits err_msg[129]; + uint8_t err_msg[129]; int rc = 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()) { stun_attr_ref sar = stun_attr_get_first(&(elem->in_buffer)); - u32bits cid = 0; + uint32_t cid = 0; while(sar) { int attr_type = stun_attr_get_type(sar); 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; } sar = stun_attr_get_next_str(elem->in_buffer.buf,elem->in_buffer.len,sar); } if(negative_test) { - tcp_data_connect(elem,(u64bits)random()); + tcp_data_connect(elem,(uint64_t)random()); } else { /* positive test */ 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; } - const u08bits* data = stun_attr_get_value(sar); + const uint8_t* data = stun_attr_get_value(sar); bcopy(data, &mi, sizeof(message_info)); 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)) { stun_attr_ref sar = stun_attr_get_first(&(elem->in_buffer)); - u32bits cid = 0; + uint32_t cid = 0; while(sar) { int attr_type = stun_attr_get_type(sar); 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; } 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) ++(elem->loss); 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) max_latency = clatency; if(clatencylatency += clatency; 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) max_jitter = cjitter; @@ -1219,7 +1219,7 @@ static int start_c2c(const char *remote_address, int port, 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; @@ -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*) <, 4); if(dual_allocation && !mobility) { - int t = ((u08bits)random())%3; + int t = ((uint8_t)random())%3; if(t) { - u08bits field[4]; - field[0] = (t==1) ? (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4 : (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6; + uint8_t field[4]; + 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[2]=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*)); __turn_getMSTime(); - u32bits stime = current_time; + uint32_t stime = current_time; memset(buffer_to_send, 7, clmessage_length); @@ -1483,7 +1483,7 @@ void start_mclient(const char *remote_address, int port, stime = current_time; if(is_TCP_relay()) { - u64bits connect_wait_start_time = current_time; + uint64_t connect_wait_start_time = current_time; while(1) { int i = 0; int completed = 0; @@ -1525,7 +1525,7 @@ void start_mclient(const char *remote_address, int port, stime = current_time; for(i=0;ito_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; @@ -1602,7 +1602,7 @@ int add_integrity(app_ur_conn_info *clnet_info, stun_buffer *message) 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; @@ -1613,7 +1613,7 @@ int add_integrity(app_ur_conn_info *clnet_info, stun_buffer *message) clnet_info->cok = cok; oauth_token otoken; encoded_oauth_token etoken; - u08bits nonce[12]; + uint8_t nonce[12]; RAND_bytes((unsigned char*)nonce,12); long halflifetime = OAUTH_SESSION_LIFETIME/2; long random_lifetime = 0; @@ -1639,13 +1639,13 @@ int add_integrity(app_ur_conn_info *clnet_info, stun_buffer *message) return -1; } 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); 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) { TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO," Cannot add integrity to the message\n"); return -1; diff --git a/src/apps/uclient/uclient.h b/src/apps/uclient/uclient.h index c7bc6d78..ea0fa645 100644 --- a/src/apps/uclient/uclient.h +++ b/src/apps/uclient/uclient.h @@ -60,7 +60,7 @@ extern ioa_addr peer_addr; extern int no_rtcp; extern int default_address_family; 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 char g_auth_secret[1025]; extern int g_use_auth_secret_with_timestamp; @@ -68,7 +68,7 @@ extern int use_fingerprints; extern SSL_CTX *root_tls_ctx[32]; extern int root_tls_ctx_num; extern int RTP_PACKET_INTERVAL; -extern u08bits relay_transport; +extern uint8_t relay_transport; extern unsigned char client_ifname[1025]; extern struct event_base* client_event_base; extern int passive_tcp; diff --git a/src/client++/TurnMsgLib.h b/src/client++/TurnMsgLib.h index af796d10..9c4a6279 100644 --- a/src/client++/TurnMsgLib.h +++ b/src/client++/TurnMsgLib.h @@ -75,7 +75,7 @@ public: /** * 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) { if(!stun_is_command_message_str(_buf, _sz)) { throw WrongStunBufferFormatException(); @@ -99,7 +99,7 @@ public: * Iterator constructor: creates iterator over raw buffer, starting from first * 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) { if(!stun_is_command_message_str(_buf, _sz)) { throw WrongStunBufferFormatException(); @@ -112,7 +112,7 @@ public: * location of an attribute of particular type. */ template - StunAttrIterator(T &msg, u16bits attr_type) throw (WrongStunBufferFormatException) : + StunAttrIterator(T &msg, uint16_t attr_type) throw (WrongStunBufferFormatException) : _buf(msg.getRawBuffer()), _sz(msg.getSize()) { if(!stun_is_command_message_str(_buf, _sz)) { throw WrongStunBufferFormatException(); @@ -167,17 +167,17 @@ public: * Return raw memroy field of the attribute value. * 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); if(len<0) throw WrongStunAttrFormatException(); sz = (size_t)len; - const u08bits *value = stun_attr_get_value(_sar); + const uint8_t *value = stun_attr_get_value(_sar); return value; } friend class StunAttr; private: - u08bits *_buf; + uint8_t *_buf; size_t _sz; stun_attr_ref _sar; }; @@ -201,15 +201,15 @@ public: throw EndOfStunMsgException(); } size_t sz = 0; - const u08bits *ptr = iter.getRawBuffer(sz); + const uint8_t *ptr = iter.getRawBuffer(sz); if(sz>=0xFFFF) throw WrongStunAttrFormatException(); int at = iter.getType(); if(at<0) throw WrongStunAttrFormatException(); - _attr_type = (u16bits)at; + _attr_type = (uint16_t)at; _sz = sz; - _value=(u08bits*)malloc(_sz); + _value=(uint8_t*)malloc(_sz); if(ptr) bcopy(ptr,_value,_sz); } @@ -225,7 +225,7 @@ public: /** * Return raw data representation of the attribute */ - const u08bits *getRawValue(size_t &sz) const { + const uint8_t *getRawValue(size_t &sz) const { sz=_sz; return _value; } @@ -233,13 +233,13 @@ public: /** * 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) throw WrongStunAttrFormatException(); if(_value) free(_value,_sz); _sz = sz; - _value=(u08bits*)malloc(_sz); + _value=(uint8_t*)malloc(_sz); if(value) bcopy(value,_value,_sz); } @@ -247,14 +247,14 @@ public: /** * Get attribute type */ - u16bits getType() const { + uint16_t getType() const { return _attr_type; } /** * Set attribute type */ - void setType(u16bits at) { + void setType(uint16_t at) { _attr_type = at; } @@ -265,7 +265,7 @@ public: int addToMsg(T &msg) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) { if(!_attr_type) throw WrongStunAttrFormatException(); - u08bits *buffer = msg.getRawBuffer(); + uint8_t *buffer = msg.getRawBuffer(); if(buffer) { size_t sz = msg.getSize(); if(addToBuffer(buffer, sz)<0) { @@ -281,7 +281,7 @@ protected: /** * 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(!_value) throw WrongStunAttrFormatException(); @@ -300,8 +300,8 @@ protected: return iter._sar; } private: - u16bits _attr_type; - u08bits *_value; + uint16_t _attr_type; + uint8_t *_value; size_t _sz; }; @@ -324,18 +324,18 @@ public: throw WrongStunAttrFormatException(); } virtual ~StunAttrChannelNumber() {} - u16bits getChannelNumber() const { + uint16_t getChannelNumber() const { return _cn; } - void setChannelNumber(u16bits cn) { + void setChannelNumber(uint16_t cn) { _cn = cn; } 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); } private: - u16bits _cn; + uint16_t _cn; }; /** @@ -355,18 +355,18 @@ public: _ep = stun_attr_get_even_port(getSar(iter)); } virtual ~StunAttrEvenPort() {} - u08bits getEvenPort() const { + uint8_t getEvenPort() const { return _ep; } - void setEvenPort(u08bits ep) { + void setEvenPort(uint8_t ep) { _ep = ep; } 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); } private: - u08bits _ep; + uint8_t _ep; }; /** @@ -386,19 +386,19 @@ public: _rt = stun_attr_get_reservation_token_value(getSar(iter)); } virtual ~StunAttrReservationToken() {} - u64bits getReservationToken() const { + uint64_t getReservationToken() const { return _rt; } - void setReservationToken(u64bits rt) { + void setReservationToken(uint64_t rt) { _rt = rt; } 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); - 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: - u64bits _rt; + uint64_t _rt; }; /** @@ -406,7 +406,7 @@ private: */ class StunAttrAddr : public StunAttr { public: - StunAttrAddr(u16bits attr_type = 0) { + StunAttrAddr(uint16_t attr_type = 0) { addr_set_any(&_addr); setType(attr_type); } @@ -417,7 +417,7 @@ public: if(iter.eof()) throw EndOfStunMsgException(); 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) { throw WrongStunAttrFormatException(); } @@ -430,7 +430,7 @@ public: addr_cpy(&_addr,&addr); } 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); } private: @@ -476,7 +476,7 @@ public: _changePort = 0; } 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); } private: @@ -503,21 +503,21 @@ public: if(rp<0) { throw WrongStunAttrFormatException(); } - _rp = (u16bits)rp; + _rp = (uint16_t)rp; } virtual ~StunAttrResponsePort() {} - u16bits getResponsePort() const { + uint16_t getResponsePort() const { return _rp; } - void setResponsePort(u16bits p) { + void setResponsePort(uint16_t p) { _rp = p; } 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); } private: - u16bits _rp; + uint16_t _rp; }; /** @@ -539,24 +539,24 @@ public: if(p<0) { throw WrongStunAttrFormatException(); } - _p = (u16bits)p; + _p = (uint16_t)p; } virtual ~StunAttrPadding() {} - u16bits getPadding() const { + uint16_t getPadding() const { return _p; } /** * Set length of padding */ - void setPadding(u16bits p) { + void setPadding(uint16_t p) { _p = p; } 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); } private: - u16bits _p; + uint16_t _p; }; /** @@ -569,7 +569,7 @@ public: */ StunMsg() { _allocated_sz = 0xFFFF; - _buffer = (u08bits*)malloc(_allocated_sz); + _buffer = (uint8_t*)malloc(_allocated_sz); _deallocate = true; _sz = 0; _constructed = 0; @@ -579,7 +579,7 @@ public: * Construct message over raw buffer. * 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), _sz(sz), _constructed(constructed) {} @@ -609,7 +609,7 @@ public: /** * get raw buffer */ - u08bits *getRawBuffer() { + uint8_t *getRawBuffer() { return _buffer; } @@ -632,7 +632,7 @@ public: /** * 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); } @@ -643,44 +643,44 @@ public: 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); } - static bool isRequest(u08bits *buffer, size_t sz) { + static bool isRequest(uint8_t *buffer, size_t 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); } - static bool isErrorResponse(u08bits *buffer, size_t sz, - int &err_code, u08bits *err_msg, size_t err_msg_size) { + static bool isErrorResponse(uint8_t *buffer, size_t sz, + 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); } /** * 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, - int &err_code, u08bits *err_msg, size_t err_msg_size, - u08bits *realm, u08bits *nonce, - u08bits *server_name, int *oauth) { + static bool isChallengeResponse(const uint8_t* buf, size_t sz, + int &err_code, uint8_t *err_msg, size_t err_msg_size, + uint8_t *realm, uint8_t *nonce, + 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); } /** * 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); } /** * 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)) return false; stun_attr_ref sar = stun_attr_get_first_by_type_str(buffer, sz, STUN_ATTRIBUTE_FINGERPRINT); @@ -693,7 +693,7 @@ public: /** * 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); } @@ -740,9 +740,9 @@ public: throw(WrongStunBufferFormatException) { if(!_constructed || !isCommand()) throw WrongStunBufferFormatException(); - u08bits *suname=(u08bits*)strdup(uname.c_str()); - u08bits *srealm=(u08bits*)strdup(realm.c_str()); - u08bits *supwd=(u08bits*)strdup(upwd.c_str()); + uint8_t *suname=(uint8_t*)strdup(uname.c_str()); + uint8_t *srealm=(uint8_t*)strdup(realm.c_str()); + uint8_t *supwd=(uint8_t*)strdup(upwd.c_str()); SHATYPE sht = SHATYPE_SHA1; bool ret = (0< stun_check_message_integrity_str(ct,_buffer, _sz, suname, srealm, supwd, sht)); free(suname); @@ -760,10 +760,10 @@ public: if(!_constructed || !isCommand()) throw WrongStunBufferFormatException(); - u08bits *suname=(u08bits*)strdup(uname.c_str()); - u08bits *srealm=(u08bits*)strdup(realm.c_str()); - u08bits *supwd=(u08bits*)strdup(upwd.c_str()); - u08bits *snonce=(u08bits*)strdup(nonce.c_str()); + uint8_t *suname=(uint8_t*)strdup(uname.c_str()); + uint8_t *srealm=(uint8_t*)strdup(realm.c_str()); + uint8_t *supwd=(uint8_t*)strdup(upwd.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); @@ -782,8 +782,8 @@ public: if(!_constructed || !isCommand()) throw WrongStunBufferFormatException(); - u08bits *suname=(u08bits*)strdup(uname.c_str()); - u08bits *supwd=(u08bits*)strdup(upwd.c_str()); + uint8_t *suname=(uint8_t*)strdup(uname.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); @@ -795,7 +795,7 @@ protected: virtual void constructBuffer() = 0; virtual bool check() = 0; protected: - u08bits *_buffer; + uint8_t *_buffer; bool _deallocate; size_t _allocated_sz; size_t _sz; @@ -807,8 +807,8 @@ protected: */ class StunMsgRequest : public StunMsg { public: - StunMsgRequest(u16bits method) : _method(method) {}; - StunMsgRequest(u08bits *buffer, size_t total_sz, size_t sz, bool constructed) + StunMsgRequest(uint16_t method) : _method(method) {}; + StunMsgRequest(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed) throw(WrongStunBufferFormatException) : StunMsg(buffer,total_sz,sz,constructed),_method(0) { @@ -824,14 +824,14 @@ public: /** * Get request method */ - u16bits getMethod() const { + uint16_t getMethod() const { return _method; } /** * Set method */ - void setMethod(u16bits method) { + void setMethod(uint16_t method) { _method = method; } @@ -849,14 +849,14 @@ public: /** * 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); } /** * 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, &peer_addr, channel_number); } @@ -880,7 +880,7 @@ protected: } private: - u16bits _method; + uint16_t _method; }; /** @@ -888,18 +888,18 @@ private: */ class StunMsgResponse : public StunMsg { public: - StunMsgResponse(u16bits 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, stun_tid &tid) : _method(method), _err(0), _reason(""), _tid(tid) {}; + StunMsgResponse(uint16_t method, int error_code, std::string reason, stun_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) : StunMsg(buffer,total_sz,sz,constructed),_method(0),_err(0),_reason("") { if(constructed) { 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))) { throw WrongStunBufferFormatException(); } @@ -910,11 +910,11 @@ public: } } - u16bits getMethod() const { + uint16_t getMethod() const { return _method; } - void setMethod(u16bits method) { + void setMethod(uint16_t method) { _method = method; } @@ -967,10 +967,10 @@ public: bool ret = false; if(_constructed) { int err_code; - u08bits err_msg[1025]; + uint8_t err_msg[1025]; size_t err_msg_size=sizeof(err_msg); - u08bits srealm[0xFFFF]; - u08bits snonce[0xFFFF]; + uint8_t srealm[0xFFFF]; + uint8_t snonce[0xFFFF]; ret = stun_is_challenge_response_str(_buffer, _sz, &err_code, err_msg, err_msg_size, srealm, snonce, NULL, NULL); if(ret) { realm = (char*)srealm; @@ -997,7 +997,7 @@ public: */ void constructBindingResponse(stun_tid &tid, const ioa_addr &reflexive_addr, int error_code, - const u08bits *reason) { + const uint8_t *reason) { stun_set_binding_response_str(_buffer, &_sz, &tid, &reflexive_addr, error_code, @@ -1015,8 +1015,8 @@ public: const ioa_addr &relayed_addr1, const ioa_addr &relayed_addr2, const ioa_addr &reflexive_addr, - u32bits lifetime, int error_code, const u08bits *reason, - u64bits reservation_token, char *mobile_id) { + uint32_t lifetime, int error_code, const uint8_t *reason, + uint64_t reservation_token, char *mobile_id) { stun_set_allocate_response_str(_buffer, &_sz, &tid, &relayed_addr1, &relayed_addr2, @@ -1028,14 +1028,14 @@ public: /** * 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); } protected: virtual void constructBuffer() { 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 { stun_init_success_response_str(_method, _buffer, &_sz, &_tid); } @@ -1046,7 +1046,7 @@ protected: if(!_constructed) return false; if(!stun_is_success_response_str(_buffer,_sz)) { - u08bits errtxt[0xFFFF]; + uint8_t errtxt[0xFFFF]; int cerr=0; if(!stun_is_error_response_str(_buffer,_sz,&cerr,errtxt,sizeof(errtxt))) { throw WrongStunBufferFormatException(); @@ -1062,7 +1062,7 @@ protected: } private: - u16bits _method; + uint16_t _method; int _err; std::string _reason; stun_tid _tid; @@ -1073,8 +1073,8 @@ private: */ class StunMsgIndication : public StunMsg { public: - StunMsgIndication(u16bits method) : _method(method) {}; - StunMsgIndication(u08bits *buffer, size_t total_sz, size_t sz, bool constructed) + StunMsgIndication(uint16_t method) : _method(method) {}; + StunMsgIndication(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed) throw(WrongStunBufferFormatException) : StunMsg(buffer,total_sz,sz,constructed),_method(0) { @@ -1087,11 +1087,11 @@ public: } virtual ~StunMsgIndication() {} - u16bits getMethod() const { + uint16_t getMethod() const { return _method; } - void setMethod(u16bits method) { + void setMethod(uint16_t method) { _method = method; } @@ -1114,7 +1114,7 @@ protected: } private: - u16bits _method; + uint16_t _method; }; /** @@ -1122,8 +1122,8 @@ private: */ class StunMsgChannel : public StunMsg { public: - StunMsgChannel(u16bits cn, int length) : _cn(cn), _len(length) {}; - StunMsgChannel(u08bits *buffer, size_t total_sz, size_t sz, bool constructed) + StunMsgChannel(uint16_t cn, int length) : _cn(cn), _len(length) {}; + StunMsgChannel(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed) throw(WrongStunBufferFormatException) : StunMsg(buffer,total_sz,sz,constructed),_cn(0) { @@ -1144,11 +1144,11 @@ public: } virtual ~StunMsgChannel() {} - u16bits getChannelNumber() const { + uint16_t getChannelNumber() const { return _cn; } - void setChannelNumber(u16bits cn) { + void setChannelNumber(uint16_t cn) { _cn = cn; } @@ -1175,7 +1175,7 @@ protected: virtual bool check() { if(!_constructed) return false; - u16bits cn = 0; + uint16_t cn = 0; if(!stun_is_channel_message_str(_buffer,&_sz,&cn,0)) { return false; } @@ -1186,7 +1186,7 @@ protected: } private: - u16bits _cn; + uint16_t _cn; size_t _len; }; diff --git a/src/client/ns_turn_ioaddr.c b/src/client/ns_turn_ioaddr.c index 652036b3..5740e7c8 100644 --- a/src/client/ns_turn_ioaddr.c +++ b/src/client/ns_turn_ioaddr.c @@ -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); else if(addr->ss.sa_family == AF_INET6) return sizeof(struct sockaddr_in6); return 0; @@ -59,7 +59,7 @@ int addr_any(const ioa_addr* addr) { else { size_t i; for(i=0;is6.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) { size_t i; for(i=0;is6.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; } -u32bits hash_int32(u32bits a) +uint32_t hash_int32(uint32_t a) { a = a ^ (a>>4); a = (a^0xdeadbeef) + (a<<5); @@ -89,7 +89,7 @@ u32bits hash_int32(u32bits a) return a; } -u64bits hash_int64(u64bits a) +uint64_t hash_int64(uint64_t a) { a = a ^ (a>>4); a = (a^0xdeadbeefdeadbeefLL) + (a<<5); @@ -97,34 +97,34 @@ u64bits hash_int64(u64bits a) return a; } -u32bits addr_hash(const ioa_addr *addr) +uint32_t addr_hash(const ioa_addr *addr) { if(!addr) return 0; - u32bits ret = 0; + uint32_t ret = 0; if (addr->ss.sa_family == AF_INET) { ret = hash_int32(addr->s4.sin_addr.s_addr + addr->s4.sin_port); } else { - u64bits a[2]; + uint64_t a[2]; 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; } -u32bits addr_hash_no_port(const ioa_addr *addr) +uint32_t addr_hash_no_port(const ioa_addr *addr) { if(!addr) return 0; - u32bits ret = 0; + uint32_t ret = 0; if (addr->ss.sa_family == AF_INET) { ret = hash_int32(addr->s4.sin_addr.s_addr); } else { - u64bits a[2]; + uint64_t a[2]; 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; } @@ -183,7 +183,7 @@ int addr_eq_no_port(const ioa_addr* a1, const ioa_addr *a2) { 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; @@ -315,7 +315,7 @@ static char* get_addr_string_and_port(char* s0, int *port) 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) return -1; @@ -327,31 +327,31 @@ int make_ioa_addr_from_full_string(const u08bits* saddr, int default_port, ioa_a if(sa) { if(port<1) port = default_port; - ret = make_ioa_addr((u08bits*)sa,port,addr); + ret = make_ioa_addr((uint8_t*)sa,port,addr); } free(s); 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) { - s08bits addrtmp[INET6_ADDRSTRLEN]; + char addrtmp[INET6_ADDRSTRLEN]; if (addr->ss.sa_family == AF_INET) { inet_ntop(AF_INET, &addr->s4.sin_addr, addrtmp, INET_ADDRSTRLEN); 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 - strncpy((s08bits*)saddr, addrtmp, MAX_IOA_ADDR_STRING); + strncpy((char*)saddr, addrtmp, MAX_IOA_ADDR_STRING); } else if (addr->ss.sa_family == AF_INET6) { inet_ntop(AF_INET6, &addr->s6.sin6_addr, addrtmp, INET6_ADDRSTRLEN); 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 - strncpy((s08bits*)saddr, addrtmp, MAX_IOA_ADDR_STRING); + strncpy((char*)saddr, addrtmp, MAX_IOA_ADDR_STRING); } else { return -1; } @@ -362,19 +362,19 @@ int addr_to_string(const ioa_addr* addr, u08bits* saddr) 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) { - s08bits addrtmp[MAX_IOA_ADDR_STRING]; + char addrtmp[MAX_IOA_ADDR_STRING]; if (addr->ss.sa_family == AF_INET) { 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) { 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 { return -1; } @@ -425,11 +425,11 @@ int addr_less_eq(const ioa_addr* addr1, const ioa_addr* addr2) { else { 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) { - 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) { int 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 1; @@ -465,10 +465,10 @@ int ioa_addr_is_multicast(ioa_addr *addr) { if(addr) { 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); } 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); } } @@ -479,10 +479,10 @@ int ioa_addr_is_loopback(ioa_addr *addr) { if(addr) { 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); } 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) { int i; for(i=0;i<7;++i) { diff --git a/src/client/ns_turn_ioaddr.h b/src/client/ns_turn_ioaddr.h index 29c8e08f..a83d0fab 100644 --- a/src/client/ns_turn_ioaddr.h +++ b/src/client/ns_turn_ioaddr.h @@ -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); int addr_any(const ioa_addr* addr); int addr_any_no_port(const ioa_addr* addr); -u32bits addr_hash(const ioa_addr *addr); -u32bits addr_hash_no_port(const ioa_addr *addr); +uint32_t addr_hash(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_cpy4(ioa_addr* dst, const struct sockaddr_in* 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_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_from_full_string(const u08bits* saddr, int default_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 uint8_t* saddr, int default_port, ioa_addr *addr); void addr_set_port(ioa_addr* addr, int port); int addr_get_port(const ioa_addr* addr); -int addr_to_string(const ioa_addr* addr, u08bits* saddr); -int addr_to_string_no_port(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, uint8_t* saddr); -u32bits hash_int32(u32bits a); -u64bits hash_int64(u64bits a); +uint32_t hash_int32(uint32_t a); +uint64_t hash_int64(uint64_t a); /////////////////////////////////////////// diff --git a/src/client/ns_turn_msg.c b/src/client/ns_turn_msg.c index 715a7408..60483120 100644 --- a/src/client/ns_turn_msg.c +++ b/src/client/ns_turn_msg.c @@ -45,7 +45,7 @@ static void generate_random_nonce(unsigned char *nonce, size_t sz); /////////// -int stun_method_str(u16bits method, char *smethod) +int stun_method_str(uint16_t method, char *smethod) { int ret = 0; @@ -103,16 +103,16 @@ long turn_random(void) static void turn_random_tid_size(void *id) { - u32bits *ar=(u32bits*)id; + uint32_t *ar=(uint32_t*)id; if(!RAND_pseudo_bytes((unsigned char *)ar,12)) { size_t i; for(i=0;i<3;++i) { - ar[i] = (u32bits)random(); + ar[i] = (uint32_t)random(); } } } -int stun_calculate_hmac(const u08bits *buf, size_t len, const u08bits *key, size_t keylen, 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 keylen, uint8_t *hmac, unsigned int *hmac_len, SHATYPE shatype) { ERR_clear_error(); UNUSED_ARG(shatype); @@ -152,23 +152,23 @@ int stun_calculate_hmac(const u08bits *buf, size_t len, const u08bits *key, size return 0; } -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) { ERR_clear_error(); UNUSED_ARG(shatype); - size_t ulen = strlen((s08bits*)uname); - size_t rlen = strlen((s08bits*)realm); - size_t plen = strlen((s08bits*)upwd); + size_t ulen = strlen((char*)uname); + size_t rlen = strlen((char*)realm); + size_t plen = strlen((char*)upwd); size_t sz = ulen+1+rlen+1+plen+1+10; size_t strl = ulen+1+rlen+1+plen; - u08bits *str = (u08bits*)malloc(sz+1); + uint8_t *str = (uint8_t*)malloc(sz+1); - strncpy((s08bits*)str,(s08bits*)uname,sz); + strncpy((char*)str,(char*)uname,sz); str[ulen]=':'; - strncpy((s08bits*)str+ulen+1,(s08bits*)realm,sz-ulen-1); + strncpy((char*)str+ulen+1,(char*)realm,sz-ulen-1); str[ulen+1+rlen]=':'; - strncpy((s08bits*)str+ulen+1+rlen+1,(s08bits*)upwd,sz-ulen-1-rlen-1); + strncpy((char*)str+ulen+1+rlen+1,(char*)upwd,sz-ulen-1-rlen-1); str[strl]=0; if(shatype == SHATYPE_SHA256) { @@ -350,61 +350,61 @@ int check_password(const char* pin, const char* pwd) ///////////////////////////////////////////////////////////////// -static u32bits ns_crc32(const u08bits *buffer, u32bits len); +static uint32_t ns_crc32(const uint8_t *buffer, uint32_t len); void print_hmac(const char *name, const void *s, size_t len); ///////////////////////////////////////////////////////////////// -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) { if (len < STUN_HEADER_LENGTH) return -1; - return (int) (nswap16(((const u16bits*)(buf))[1]) + STUN_HEADER_LENGTH); + return (int) (nswap16(((const uint16_t*)(buf))[1]) + STUN_HEADER_LENGTH); } -static int stun_set_command_message_len_str(u08bits* buf, int len) { +static int stun_set_command_message_len_str(uint8_t* buf, int len) { if(len>1) | ((tt & 0x0E00)>>2) | ((tt & 0x3000)>>2); } -u16bits stun_get_msg_type_str(const u08bits *buf, size_t len) { - if(!buf || len<2) return (u16bits)-1; - return ((nswap16(((const u16bits*)buf)[0])) & 0x3FFF); +uint16_t stun_get_msg_type_str(const uint8_t *buf, size_t len) { + if(!buf || len<2) return (uint16_t)-1; + return ((nswap16(((const uint16_t*)buf)[0])) & 0x3FFF); } -int is_channel_msg_str(const u08bits* buf, size_t blen) { - return (buf && blen>=4 && STUN_VALID_CHANNEL(nswap16(((const u16bits*)buf)[0]))); +int is_channel_msg_str(const uint8_t* buf, size_t blen) { + return (buf && blen>=4 && STUN_VALID_CHANNEL(nswap16(((const uint16_t*)buf)[0]))); } /////////////// message types ///////////////////////////////// -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) { if (buf && blen >= STUN_HEADER_LENGTH) { - if (!STUN_VALID_CHANNEL(nswap16(((const u16bits*)buf)[0]))) { - if ((((u08bits) buf[0]) & ((u08bits) (0xC0))) == 0) { - if (nswap32(((const u32bits*)(buf))[1]) + if (!STUN_VALID_CHANNEL(nswap16(((const uint16_t*)buf)[0]))) { + if ((((uint8_t) buf[0]) & ((uint8_t) (0xC0))) == 0) { + if (nswap32(((const uint32_t*)(buf))[1]) == STUN_MAGIC_COOKIE) { - u16bits len = nswap16(((const u16bits*)(buf))[1]); + uint16_t len = nswap16(((const uint16_t*)(buf))[1]); if ((len & 0x0003) == 0) { if ((size_t) (len + STUN_HEADER_LENGTH) == blen) { return 1; @@ -417,17 +417,17 @@ int stun_is_command_message_str(const u08bits* buf, size_t blen) return 0; } -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) { if (buf && blen >= STUN_HEADER_LENGTH) { - if (!STUN_VALID_CHANNEL(nswap16(((const u16bits*)buf)[0]))) { - if ((((u08bits) buf[0]) & ((u08bits) (0xC0))) == 0) { - if (nswap32(((const u32bits*)(buf))[1]) + if (!STUN_VALID_CHANNEL(nswap16(((const uint16_t*)buf)[0]))) { + if ((((uint8_t) buf[0]) & ((uint8_t) (0xC0))) == 0) { + if (nswap32(((const uint32_t*)(buf))[1]) != STUN_MAGIC_COOKIE) { - u16bits len = nswap16(((const u16bits*)(buf))[1]); + uint16_t len = nswap16(((const uint16_t*)(buf))[1]); if ((len & 0x0003) == 0) { if ((size_t) (len + STUN_HEADER_LENGTH) == blen) { - *cookie = nswap32(((const u32bits*)(buf))[1]); + *cookie = nswap32(((const uint32_t*)(buf))[1]); return 1; } } @@ -438,7 +438,7 @@ int old_stun_is_command_message_str(const u08bits* buf, size_t blen, u32bits *co return 0; } -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) { if(!stun_is_command_message_str(buf,blen)) return 0; stun_attr_ref sar = stun_attr_get_first_by_type_str(buf, blen, STUN_ATTRIBUTE_FINGERPRINT); @@ -452,38 +452,38 @@ int stun_is_command_message_full_check_str(const u08bits* buf, size_t blen, int } if(stun_attr_get_len(sar) != 4) return 0; - const u32bits* fingerprint = (const u32bits*)stun_attr_get_value(sar); + const uint32_t* fingerprint = (const uint32_t*)stun_attr_get_value(sar); if(!fingerprint) return !must_check_fingerprint; - u32bits crc32len = (u32bits)((((const u08bits*)fingerprint)-buf)-4); - int ret = (*fingerprint == nswap32(ns_crc32(buf,crc32len) ^ ((u32bits)0x5354554e))); + uint32_t crc32len = (uint32_t)((((const uint8_t*)fingerprint)-buf)-4); + int ret = (*fingerprint == nswap32(ns_crc32(buf,crc32len) ^ ((uint32_t)0x5354554e))); if(ret && fingerprint_present) *fingerprint_present = ret; return ret; } -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) { return stun_is_command_message_str(buf + offset, blen); } -int stun_is_request_str(const u08bits* buf, size_t len) { +int stun_is_request_str(const uint8_t* buf, size_t len) { if(is_channel_msg_str(buf,len)) return 0; return IS_STUN_REQUEST(stun_get_msg_type_str(buf,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) { if(is_channel_msg_str(buf,len)) return 0; return IS_STUN_SUCCESS_RESP(stun_get_msg_type_str(buf,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) { if(is_channel_msg_str(buf,len)) return 0; if(IS_STUN_ERR_RESP(stun_get_msg_type_str(buf,len))) { if(err_code) { stun_attr_ref sar = stun_attr_get_first_by_type_str(buf, len, STUN_ATTRIBUTE_ERROR_CODE); if(sar) { if(stun_attr_get_len(sar)>=4) { - const u08bits* val = (const u08bits*)stun_attr_get_value(sar); + const uint8_t* val = (const uint8_t*)stun_attr_get_value(sar); *err_code=(int)(val[2]*100 + val[3]); if(err_msg && err_msg_size>0) { err_msg[0]=0; @@ -503,8 +503,8 @@ int stun_is_error_response_str(const u08bits* buf, size_t len, int *err_code, u0 return 0; } -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 ret = stun_is_error_response_str(buf, len, err_code, err_msg, err_msg_size); @@ -515,7 +515,7 @@ int stun_is_challenge_response_str(const u08bits* buf, size_t len, int *err_code int found_oauth = 0; - const u08bits *value = stun_attr_get_value(sar); + const uint8_t *value = stun_attr_get_value(sar); if(value) { size_t vlen = (size_t)stun_attr_get_len(sar); bcopy(value,realm,vlen); @@ -524,7 +524,7 @@ int stun_is_challenge_response_str(const u08bits* buf, size_t len, int *err_code { stun_attr_ref sar = stun_attr_get_first_by_type_str(buf,len,STUN_ATTRIBUTE_THIRD_PARTY_AUTHORIZATION); if(sar) { - const u08bits *value = stun_attr_get_value(sar); + const uint8_t *value = stun_attr_get_value(sar); if(value) { size_t vlen = (size_t)stun_attr_get_len(sar); if(vlen>0) { @@ -557,139 +557,139 @@ int stun_is_challenge_response_str(const u08bits* buf, size_t len, int *err_code return 0; } -int stun_is_response_str(const u08bits* buf, size_t len) { +int stun_is_response_str(const uint8_t* buf, size_t len) { if(is_channel_msg_str(buf,len)) return 0; if(IS_STUN_SUCCESS_RESP(stun_get_msg_type_str(buf,len))) return 1; if(IS_STUN_ERR_RESP(stun_get_msg_type_str(buf,len))) return 1; return 0; } -int stun_is_indication_str(const u08bits* buf, size_t len) { +int stun_is_indication_str(const uint8_t* buf, size_t len) { if(is_channel_msg_str(buf,len)) return 0; return IS_STUN_INDICATION(stun_get_msg_type_str(buf,len)); } -u16bits stun_make_request(u16bits method) { +uint16_t stun_make_request(uint16_t method) { return GET_STUN_REQUEST(stun_make_type(method)); } -u16bits stun_make_indication(u16bits method) { +uint16_t stun_make_indication(uint16_t method) { return GET_STUN_INDICATION(stun_make_type(method)); } -u16bits stun_make_success_response(u16bits method) { +uint16_t stun_make_success_response(uint16_t method) { return GET_STUN_SUCCESS_RESP(stun_make_type(method)); } -u16bits stun_make_error_response(u16bits method) { +uint16_t stun_make_error_response(uint16_t method) { return GET_STUN_ERR_RESP(stun_make_type(method)); } //////////////// INIT //////////////////////////////////////////// -void stun_init_buffer_str(u08bits *buf, size_t *len) { +void stun_init_buffer_str(uint8_t *buf, size_t *len) { *len=STUN_HEADER_LENGTH; bzero(buf,*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) { stun_init_buffer_str(buf,len); - message_type &= (u16bits)(0x3FFF); - ((u16bits*)buf)[0]=nswap16(message_type); - ((u16bits*)buf)[1]=0; - ((u32bits*)buf)[1]=nswap32(STUN_MAGIC_COOKIE); + message_type &= (uint16_t)(0x3FFF); + ((uint16_t*)buf)[0]=nswap16(message_type); + ((uint16_t*)buf)[1]=0; + ((uint32_t*)buf)[1]=nswap32(STUN_MAGIC_COOKIE); stun_tid_generate_in_message_str(buf,NULL); } -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) { stun_init_buffer_str(buf,len); - message_type &= (u16bits)(0x3FFF); - ((u16bits*)buf)[0]=nswap16(message_type); - ((u16bits*)buf)[1]=0; - ((u32bits*)buf)[1]=nswap32(cookie); + message_type &= (uint16_t)(0x3FFF); + ((uint16_t*)buf)[0]=nswap16(message_type); + ((uint16_t*)buf)[1]=0; + ((uint32_t*)buf)[1]=nswap32(cookie); stun_tid_generate_in_message_str(buf,NULL); } -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) { stun_init_command_str(stun_make_request(method), buf, 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) { stun_init_command_str(stun_make_indication(method), buf, 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) { stun_init_command_str(stun_make_success_response(method), buf, len); if(id) { stun_tid_message_cpy(buf, 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) { old_stun_init_command_str(stun_make_success_response(method), buf, len, cookie); if(id) { stun_tid_message_cpy(buf, id); } } -const u08bits* get_default_reason(int error_code) +const uint8_t* get_default_reason(int error_code) { - const u08bits* reason = (const u08bits *) "Unknown error"; + const uint8_t* reason = (const uint8_t *) "Unknown error"; switch (error_code){ case 300: - reason = (const u08bits *) "Try Alternate"; + reason = (const uint8_t *) "Try Alternate"; break; case 400: - reason = (const u08bits *) "Bad Request"; + reason = (const uint8_t *) "Bad Request"; break; case 401: - reason = (const u08bits *) "Unauthorized"; + reason = (const uint8_t *) "Unauthorized"; break; case 403: - reason = (const u08bits *) "Forbidden"; + reason = (const uint8_t *) "Forbidden"; break; case 404: - reason = (const u08bits *) "Not Found"; + reason = (const uint8_t *) "Not Found"; break; case 420: - reason = (const u08bits *) "Unknown Attribute"; + reason = (const uint8_t *) "Unknown Attribute"; break; case 437: - reason = (const u08bits *) "Allocation Mismatch"; + reason = (const uint8_t *) "Allocation Mismatch"; break; case 438: - reason = (const u08bits *) "Stale Nonce"; + reason = (const uint8_t *) "Stale Nonce"; break; case 440: - reason = (const u08bits *) "Address Family not Supported"; + reason = (const uint8_t *) "Address Family not Supported"; break; case 441: - reason = (const u08bits *) "Wrong Credentials"; + reason = (const uint8_t *) "Wrong Credentials"; break; case 442: - reason = (const u08bits *) "Unsupported Transport Protocol"; + reason = (const uint8_t *) "Unsupported Transport Protocol"; break; case 443: - reason = (const u08bits *) "Peer Address Family Mismatch"; + reason = (const uint8_t *) "Peer Address Family Mismatch"; break; case 446: - reason = (const u08bits *) "Connection Already Exists"; + reason = (const uint8_t *) "Connection Already Exists"; break; case 447: - reason = (const u08bits *) "Connection Timeout or Failure"; + reason = (const uint8_t *) "Connection Timeout or Failure"; break; case 486: - reason = (const u08bits *) "Allocation Quota Reached"; + reason = (const uint8_t *) "Allocation Quota Reached"; break; case 487: - reason = (const u08bits *) "Role Conflict"; + reason = (const uint8_t *) "Role Conflict"; break; case 500: - reason = (const u08bits *) "Server Error"; + reason = (const uint8_t *) "Server Error"; break; case 508: - reason = (const u08bits *) "Insufficient Capacity"; + reason = (const uint8_t *) "Insufficient Capacity"; break; default: ; @@ -698,8 +698,8 @@ const u08bits* get_default_reason(int error_code) return reason; } -static void stun_init_error_response_common_str(u08bits* buf, size_t *len, - u16bits error_code, const u08bits *reason, +static void stun_init_error_response_common_str(uint8_t* buf, size_t *len, + uint16_t error_code, const uint8_t *reason, stun_tid* id) { @@ -707,14 +707,14 @@ static void stun_init_error_response_common_str(u08bits* buf, size_t *len, reason = get_default_reason(error_code); } - u08bits avalue[513]; + uint8_t avalue[513]; avalue[0] = 0; avalue[1] = 0; - avalue[2] = (u08bits) (error_code / 100); - avalue[3] = (u08bits) (error_code % 100); - strncpy((s08bits*) (avalue + 4), (const s08bits*) reason, sizeof(avalue)-4); + avalue[2] = (uint8_t) (error_code / 100); + avalue[3] = (uint8_t) (error_code % 100); + strncpy((char*) (avalue + 4), (const char*) reason, sizeof(avalue)-4); avalue[sizeof(avalue)-1]=0; - int alen = 4 + strlen((const s08bits*) (avalue+4)); + int alen = 4 + strlen((const char*) (avalue+4)); //"Manual" padding for compatibility with classic old stun: { @@ -724,15 +724,15 @@ static void stun_init_error_response_common_str(u08bits* buf, size_t *len, } } - stun_attr_add_str(buf, len, STUN_ATTRIBUTE_ERROR_CODE, (u08bits*) avalue, alen); + stun_attr_add_str(buf, len, STUN_ATTRIBUTE_ERROR_CODE, (uint8_t*) avalue, alen); if (id) { stun_tid_message_cpy(buf, 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) { old_stun_init_command_str(stun_make_error_response(method), buf, len, cookie); @@ -742,8 +742,8 @@ void old_stun_init_error_response_str(u16bits method, u08bits* buf, size_t *len, id); } -void stun_init_error_response_str(u16bits method, u08bits* buf, size_t *len, - u16bits error_code, const u08bits *reason, +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) { @@ -756,13 +756,13 @@ void stun_init_error_response_str(u16bits method, u08bits* buf, size_t *len, /////////// CHANNEL //////////////////////////////////////////////// -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) { - u16bits rlen = (u16bits)length; + uint16_t rlen = (uint16_t)length; if(length<0 || (MAX_STUN_MESSAGE_SIZE<(4+length))) return -1; - ((u16bits*)(buf))[0]=nswap16(chnumber); - ((u16bits*)(buf))[1]=nswap16((u16bits)length); + ((uint16_t*)(buf))[0]=nswap16(chnumber); + ((uint16_t*)(buf))[1]=nswap16((uint16_t)length); if(do_padding && (rlen & 0x0003)) rlen = ((rlen>>2)+1)<<2; @@ -772,23 +772,23 @@ int stun_init_channel_message_str(u16bits chnumber, u08bits* buf, size_t *len, i return 0; } -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) { - u16bits datalen_header; - u16bits datalen_actual; + uint16_t datalen_header; + uint16_t datalen_actual; if (!blen || (*blen < 4)) return 0; - u16bits chn = nswap16(((const u16bits*)(buf))[0]); + uint16_t chn = nswap16(((const uint16_t*)(buf))[0]); if (!STUN_VALID_CHANNEL(chn)) return 0; - if(*blen>(u16bits)-1) - *blen=(u16bits)-1; + if(*blen>(uint16_t)-1) + *blen=(uint16_t)-1; - datalen_actual = (u16bits)(*blen) - 4; - datalen_header = ((const u16bits*)buf)[1]; + datalen_actual = (uint16_t)(*blen) - 4; + datalen_header = ((const uint16_t*)buf)[1]; datalen_header = nswap16(datalen_header); if (datalen_header > datalen_actual) @@ -805,7 +805,7 @@ int stun_is_channel_message_str(const u08bits *buf, size_t *blen, u16bits* chnum } else if ((datalen_actual < datalen_header) || (datalen_header == 0)) { return 0; } else { - u16bits diff = datalen_actual - datalen_header; + uint16_t diff = datalen_actual - datalen_header; if (diff > 3) return 0; } @@ -891,15 +891,15 @@ int is_http(const char *s, size_t blen) { return is_http_inline(s, blen); } -int stun_get_message_len_str(u08bits *buf, size_t blen, int padding, size_t *app_len) { +int stun_get_message_len_str(uint8_t *buf, size_t blen, int padding, size_t *app_len) { if (buf && blen) { /* STUN request/response ? */ if (buf && blen >= STUN_HEADER_LENGTH) { - if (!STUN_VALID_CHANNEL(nswap16(((const u16bits*)buf)[0]))) { - if ((((u08bits) buf[0]) & ((u08bits) (0xC0))) == 0) { - if (nswap32(((const u32bits*)(buf))[1]) + if (!STUN_VALID_CHANNEL(nswap16(((const uint16_t*)buf)[0]))) { + if ((((uint8_t) buf[0]) & ((uint8_t) (0xC0))) == 0) { + if (nswap32(((const uint32_t*)(buf))[1]) == STUN_MAGIC_COOKIE) { - u16bits len = nswap16(((const u16bits*)(buf))[1]); + uint16_t len = nswap16(((const uint16_t*)(buf))[1]); if ((len & 0x0003) == 0) { len += STUN_HEADER_LENGTH; if ((size_t) len <= blen) { @@ -923,10 +923,10 @@ int stun_get_message_len_str(u08bits *buf, size_t blen, int padding, size_t *app /* STUN channel ? */ if(blen>=4) { - u16bits chn=nswap16(((const u16bits*)(buf))[0]); + uint16_t chn=nswap16(((const uint16_t*)(buf))[0]); if(STUN_VALID_CHANNEL(chn)) { - u16bits bret = (4+(nswap16(((const u16bits*)(buf))[1]))); + uint16_t bret = (4+(nswap16(((const uint16_t*)(buf))[1]))); *app_len = bret; @@ -947,14 +947,14 @@ int stun_get_message_len_str(u08bits *buf, size_t blen, int padding, size_t *app ////////// ALLOCATE /////////////////////////////////// -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) { stun_init_request_str(STUN_METHOD_ALLOCATE, buf, len); //REQUESTED-TRANSPORT { - u08bits field[4]; + uint8_t field[4]; field[0]=transport; field[1]=0; field[2]=0; @@ -965,31 +965,31 @@ int stun_set_allocate_request_str(u08bits* buf, size_t *len, u32bits lifetime, i //LIFETIME { if(lifetime<1) lifetime=STUN_DEFAULT_ALLOCATE_LIFETIME; - u32bits field=nswap32(lifetime); - if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_LIFETIME,(u08bits*)(&field),sizeof(field))<0) return -1; + uint32_t field=nswap32(lifetime); + if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_LIFETIME,(uint8_t*)(&field),sizeof(field))<0) return -1; } //MICE if(mobile) { - if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_MOBILITY_TICKET,(const u08bits*)"",0)<0) return -1; + if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_MOBILITY_TICKET,(const uint8_t*)"",0)<0) return -1; } if(ep>-1) { uint8_t value = ep ? 0x80 : 0x00; - if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_EVEN_PORT,(const u08bits*)&value,1)<0) return -1; + if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_EVEN_PORT,(const uint8_t*)&value,1)<0) return -1; } //RESERVATION-TOKEN, EVEN-PORT and DUAL-ALLOCATION are mutually exclusive: if(rt) { - stun_attr_add_str(buf,len, STUN_ATTRIBUTE_RESERVATION_TOKEN, (const u08bits*) rt, 8); + stun_attr_add_str(buf,len, STUN_ATTRIBUTE_RESERVATION_TOKEN, (const uint8_t*) rt, 8); } else { //ADRESS-FAMILY if (af4 && !af6) { - u08bits field[4]; - field[0] = (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4; + uint8_t field[4]; + field[0] = (uint8_t)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4; field[1]=0; field[2]=0; field[3]=0; @@ -997,8 +997,8 @@ int stun_set_allocate_request_str(u08bits* buf, size_t *len, u32bits lifetime, i } if (af6 && !af4) { - u08bits field[4]; - field[0] = (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6; + uint8_t field[4]; + field[0] = (uint8_t)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6; field[1]=0; field[2]=0; field[3]=0; @@ -1006,8 +1006,8 @@ int stun_set_allocate_request_str(u08bits* buf, size_t *len, u32bits lifetime, i } if (af4 && af6) { - u08bits field[4]; - field[0] = (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6; + uint8_t field[4]; + field[0] = (uint8_t)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6; field[1]=0; field[2]=0; field[3]=0; @@ -1018,11 +1018,11 @@ int stun_set_allocate_request_str(u08bits* buf, size_t *len, u32bits lifetime, i return 0; } -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 *reflexive_addr, - u32bits lifetime, u32bits max_lifetime, int error_code, const u08bits *reason, - u64bits reservation_token, char* mobile_id) { + uint32_t lifetime, uint32_t max_lifetime, int error_code, const uint8_t *reason, + uint64_t reservation_token, char* mobile_id) { if(!error_code) { @@ -1042,19 +1042,19 @@ int stun_set_allocate_response_str(u08bits* buf, size_t *len, stun_tid* tid, if(reservation_token) { reservation_token=nswap64(reservation_token); - stun_attr_add_str(buf,len,STUN_ATTRIBUTE_RESERVATION_TOKEN,(u08bits*)(&reservation_token),8); + stun_attr_add_str(buf,len,STUN_ATTRIBUTE_RESERVATION_TOKEN,(uint8_t*)(&reservation_token),8); } { if(lifetime<1) lifetime=STUN_DEFAULT_ALLOCATE_LIFETIME; else if(lifetime>max_lifetime) lifetime = max_lifetime; - u32bits field=nswap32(lifetime); - if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_LIFETIME,(u08bits*)(&field),sizeof(field))<0) return -1; + uint32_t field=nswap32(lifetime); + if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_LIFETIME,(uint8_t*)(&field),sizeof(field))<0) return -1; } if(mobile_id && *mobile_id) { - if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_MOBILITY_TICKET,(u08bits*)mobile_id,strlen(mobile_id))<0) return -1; + if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_MOBILITY_TICKET,(uint8_t*)mobile_id,strlen(mobile_id))<0) return -1; } } else { @@ -1066,11 +1066,11 @@ int stun_set_allocate_response_str(u08bits* buf, size_t *len, stun_tid* tid, /////////////// CHANNEL BIND /////////////////////////////////////// -u16bits stun_set_channel_bind_request_str(u08bits* buf, size_t *len, - const ioa_addr* peer_addr, u16bits channel_number) { +uint16_t stun_set_channel_bind_request_str(uint8_t* buf, size_t *len, + const ioa_addr* peer_addr, uint16_t channel_number) { if(!STUN_VALID_CHANNEL(channel_number)) { - channel_number = 0x4000 + ((u16bits)(((u32bits)turn_random())%(0x7FFF-0x4000+1))); + channel_number = 0x4000 + ((uint16_t)(((uint32_t)turn_random())%(0x7FFF-0x4000+1))); } stun_init_request_str(STUN_METHOD_CHANNEL_BIND, buf, len); @@ -1089,7 +1089,7 @@ u16bits stun_set_channel_bind_request_str(u08bits* buf, size_t *len, return 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) { if(!error_code) { stun_init_success_response_str(STUN_METHOD_CHANNEL_BIND, buf, len, tid); } else { @@ -1099,13 +1099,13 @@ void stun_set_channel_bind_response_str(u08bits* buf, size_t *len, stun_tid* tid /////////////// BINDING /////////////////////////////////////// -void stun_set_binding_request_str(u08bits* buf, size_t *len) { +void stun_set_binding_request_str(uint8_t* buf, size_t *len) { stun_init_request_str(STUN_METHOD_BINDING, buf, len); } -int stun_set_binding_response_str(u08bits* buf, size_t *len, stun_tid* tid, - const ioa_addr *reflexive_addr, int error_code, const u08bits *reason, - u32bits cookie, int old_stun) +int stun_set_binding_response_str(uint8_t* buf, size_t *len, stun_tid* tid, + const ioa_addr *reflexive_addr, int error_code, const uint8_t *reason, + uint32_t cookie, int old_stun) { if (!error_code) { @@ -1131,7 +1131,7 @@ int stun_set_binding_response_str(u08bits* buf, size_t *len, stun_tid* tid, return 0; } -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) { if(offset < len) { buf += offset; @@ -1145,7 +1145,7 @@ int stun_is_binding_request_str(const u08bits* buf, size_t len, size_t offset) return 0; } -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) { if(stun_is_command_message_str(buf,len) && (stun_get_method_str(buf,len)==STUN_METHOD_BINDING)) { if(stun_is_response_str(buf,len)) { @@ -1177,24 +1177,24 @@ void stun_tid_cpy(stun_tid *id1, const stun_tid *id2) { bcopy((const void*)(id2->tsx_id),(void*)(id1->tsx_id),STUN_TID_SIZE); } -static void stun_tid_string_cpy(u08bits* s, const stun_tid* id) { +static void stun_tid_string_cpy(uint8_t* s, const stun_tid* id) { if(s && id) { bcopy((const void*)(id->tsx_id),s,STUN_TID_SIZE); } } -static void stun_tid_from_string(const u08bits* s, stun_tid* id) { +static void stun_tid_from_string(const uint8_t* s, stun_tid* id) { if(s && id) { bcopy(s,(void*)(id->tsx_id),STUN_TID_SIZE); } } -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) { UNUSED_ARG(len); stun_tid_from_string(buf+8, id); } -void stun_tid_message_cpy(u08bits* buf, const stun_tid* id) { +void stun_tid_message_cpy(uint8_t* buf, const stun_tid* id) { if(buf && id) { stun_tid_string_cpy(buf+8, id); } @@ -1206,7 +1206,7 @@ void stun_tid_generate(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) { stun_tid tmp; if(!id) id=&tmp; stun_tid_generate(id); @@ -1232,21 +1232,21 @@ turn_time_t stun_adjust_allocate_lifetime(turn_time_t lifetime, turn_time_t max_ int stun_attr_get_type(stun_attr_ref attr) { if(attr) - return (int)(nswap16(((const u16bits*)attr)[0])); + return (int)(nswap16(((const uint16_t*)attr)[0])); return -1; } int stun_attr_get_len(stun_attr_ref attr) { if(attr) - return (int)(nswap16(((const u16bits*)attr)[1])); + return (int)(nswap16(((const uint16_t*)attr)[1])); return -1; } -const u08bits* stun_attr_get_value(stun_attr_ref attr) { +const uint8_t* stun_attr_get_value(stun_attr_ref attr) { if(attr) { - int len = (int)(nswap16(((const u16bits*)attr)[1])); + int len = (int)(nswap16(((const uint16_t*)attr)[1])); if(len<1) return NULL; - return ((const u08bits*)attr)+4; + return ((const uint8_t*)attr)+4; } return NULL; } @@ -1254,10 +1254,10 @@ const u08bits* stun_attr_get_value(stun_attr_ref attr) { int stun_get_requested_address_family(stun_attr_ref attr) { if (attr) { - int len = (int) (nswap16(((const u16bits*)attr)[1])); + int len = (int) (nswap16(((const uint16_t*)attr)[1])); if (len != 4) return STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_INVALID; - int val = ((const u08bits*) attr)[4]; + int val = ((const uint8_t*) attr)[4]; switch (val){ case STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4: return val; @@ -1270,11 +1270,11 @@ int stun_get_requested_address_family(stun_attr_ref attr) return STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_DEFAULT; } -u16bits stun_attr_get_channel_number(stun_attr_ref attr) { +uint16_t stun_attr_get_channel_number(stun_attr_ref attr) { if(attr) { - const u08bits* value = stun_attr_get_value(attr); + const uint8_t* value = stun_attr_get_value(attr); if(value && (stun_attr_get_len(attr) >= 2)) { - u16bits cn=nswap16(((const u16bits*)value)[0]); + uint16_t cn=nswap16(((const uint16_t*)value)[0]); if(STUN_VALID_CHANNEL(cn)) return cn; } } @@ -1283,21 +1283,21 @@ u16bits stun_attr_get_channel_number(stun_attr_ref attr) { band_limit_t stun_attr_get_bandwidth(stun_attr_ref attr) { if(attr) { - const u08bits* value = stun_attr_get_value(attr); + const uint8_t* value = stun_attr_get_value(attr); if(value && (stun_attr_get_len(attr) >= 4)) { - u32bits bps=nswap32(((const u32bits*)value)[0]); + uint32_t bps=nswap32(((const uint32_t*)value)[0]); return (band_limit_t)(bps << 7); } } return 0; } -u64bits stun_attr_get_reservation_token_value(stun_attr_ref attr) { +uint64_t stun_attr_get_reservation_token_value(stun_attr_ref attr) { if(attr) { - const u08bits* value = stun_attr_get_value(attr); + const uint8_t* value = stun_attr_get_value(attr); if(value && (stun_attr_get_len(attr) == 8)) { - u64bits token; - bcopy(value, &token, sizeof(u64bits)); + uint64_t token; + bcopy(value, &token, sizeof(uint64_t)); return nswap64(token); } } @@ -1328,17 +1328,17 @@ int stun_attr_is_addr(stun_attr_ref attr) { return 0; } -u08bits stun_attr_get_even_port(stun_attr_ref attr) { +uint8_t stun_attr_get_even_port(stun_attr_ref attr) { if(attr) { - const u08bits* value=stun_attr_get_value(attr); + const uint8_t* value=stun_attr_get_value(attr); if(value) { - if((u08bits)(value[0]) > 0x7F) return 1; + if((uint8_t)(value[0]) > 0x7F) return 1; } } return 0; } -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 attr=stun_attr_get_first_str(buf,len); while(attr) { @@ -1351,7 +1351,7 @@ stun_attr_ref stun_attr_get_first_by_type_str(const u08bits* buf, size_t len, u1 return NULL; } -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) { if(stun_get_command_message_len_str(buf,len)>STUN_HEADER_LENGTH) { return (stun_attr_ref)(buf+STUN_HEADER_LENGTH); @@ -1360,25 +1360,25 @@ stun_attr_ref stun_attr_get_first_str(const u08bits* buf, size_t len) { return NULL; } -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) { if(!prev) return stun_attr_get_first_str(buf,len); else { - const u08bits* end = buf + stun_get_command_message_len_str(buf,len); + const uint8_t* end = buf + stun_get_command_message_len_str(buf,len); int attrlen=stun_attr_get_len(prev); - u16bits rem4 = ((u16bits)attrlen) & 0x0003; + uint16_t rem4 = ((uint16_t)attrlen) & 0x0003; if(rem4) { attrlen = attrlen+4-(int)rem4; } - const u08bits* attr_end=(const u08bits*)prev+4+attrlen; + const uint8_t* attr_end=(const uint8_t*)prev+4+attrlen; if(attr_end=MAX_STUN_MESSAGE_SIZE) return -1; else { - u08bits* attr_start=buf+clen; + uint8_t* attr_start=buf+clen; - u16bits *attr_start_16t=(u16bits*)attr_start; + uint16_t *attr_start_16t=(uint16_t*)attr_start; stun_set_command_message_len_str(buf,newlen); *len = newlen; @@ -1405,7 +1405,7 @@ int stun_attr_add_str(u08bits* buf, size_t *len, u16bits attr, const u08bits* av } } -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) { stun_tid tid; stun_tid_from_message_str(buf, *len, &tid); @@ -1424,18 +1424,18 @@ int stun_attr_add_addr_str(u08bits *buf, size_t *len, u16bits attr_type, const i ioa_addr public_addr; map_addr_from_private_to_public(ca,&public_addr); - u08bits cfield[64]; + uint8_t cfield[64]; int clen=0; if(stun_addr_encode(&public_addr, cfield, &clen, xor_ed, STUN_MAGIC_COOKIE, tid.tsx_id)<0) { return -1; } - if(stun_attr_add_str(buf,len,attr_type,(u08bits*)(&cfield),clen)<0) return -1; + if(stun_attr_add_str(buf,len,attr_type,(uint8_t*)(&cfield),clen)<0) return -1; return 0; } -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) { stun_tid tid; stun_tid_from_message_str(buf, len, &tid); @@ -1458,7 +1458,7 @@ int stun_attr_get_addr_str(const u08bits *buf, size_t len, stun_attr_ref attr, i ; }; - const u08bits *cfield=stun_attr_get_value(attr); + const uint8_t *cfield=stun_attr_get_value(attr); if(!cfield) return -1; if(stun_addr_decode(&public_addr, cfield, stun_attr_get_len(attr), xor_ed, STUN_MAGIC_COOKIE, tid.tsx_id)<0) { @@ -1476,7 +1476,7 @@ int stun_attr_get_addr_str(const u08bits *buf, size_t len, stun_attr_ref attr, i return 0; } -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) { stun_attr_ref attr=stun_attr_get_first_str(buf,len); @@ -1492,36 +1492,36 @@ int stun_attr_get_first_addr_str(const u08bits *buf, size_t len, u16bits attr_ty return -1; } -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) { - u16bits field[2]; + uint16_t field[2]; field[0]=nswap16(chnumber); field[1]=0; - return stun_attr_add_str(buf,len,STUN_ATTRIBUTE_CHANNEL_NUMBER,(u08bits*)(field),sizeof(field)); + return stun_attr_add_str(buf,len,STUN_ATTRIBUTE_CHANNEL_NUMBER,(uint8_t*)(field),sizeof(field)); } -int stun_attr_add_bandwidth_str(u08bits* buf, size_t *len, band_limit_t bps0) { +int stun_attr_add_bandwidth_str(uint8_t* buf, size_t *len, band_limit_t bps0) { - u32bits bps = (band_limit_t)(bps0 >> 7); + uint32_t bps = (band_limit_t)(bps0 >> 7); - u32bits field=nswap32(bps); + uint32_t field=nswap32(bps); - return stun_attr_add_str(buf,len,STUN_ATTRIBUTE_NEW_BANDWIDTH,(u08bits*)(&field),sizeof(field)); + return stun_attr_add_str(buf,len,STUN_ATTRIBUTE_NEW_BANDWIDTH,(uint8_t*)(&field),sizeof(field)); } -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) { - const u08bits *reason = get_default_reason(error_code); + const uint8_t *reason = get_default_reason(error_code); - u08bits avalue[513]; - avalue[0] = (u08bits)requested_address_family; + uint8_t avalue[513]; + avalue[0] = (uint8_t)requested_address_family; avalue[1] = 0; - avalue[2] = (u08bits) (error_code / 100); - avalue[3] = (u08bits) (error_code % 100); - strncpy((s08bits*) (avalue + 4), (const s08bits*) reason, sizeof(avalue)-4); + avalue[2] = (uint8_t) (error_code / 100); + avalue[3] = (uint8_t) (error_code % 100); + strncpy((char*) (avalue + 4), (const char*) reason, sizeof(avalue)-4); avalue[sizeof(avalue)-1]=0; - int alen = 4 + strlen((const s08bits*) (avalue+4)); + int alen = 4 + strlen((const char*) (avalue+4)); //"Manual" padding for compatibility with classic old stun: { @@ -1531,12 +1531,12 @@ int stun_attr_add_address_error_code(u08bits* buf, size_t *len, int requested_ad } } - stun_attr_add_str(buf, len, STUN_ATTRIBUTE_ADDRESS_ERROR_CODE, (u08bits*) avalue, alen); + stun_attr_add_str(buf, len, STUN_ATTRIBUTE_ADDRESS_ERROR_CODE, (uint8_t*) avalue, alen); return 0; } -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) { if(requested_address_family) { *requested_address_family = 0; @@ -1547,7 +1547,7 @@ int stun_attr_get_address_error_code(u08bits* buf, size_t len, int *requested_ad if(buf && len) { stun_attr_ref sar = stun_attr_get_first_by_type_str(buf, len, STUN_ATTRIBUTE_ADDRESS_ERROR_CODE); if(sar) { - const u08bits* value = stun_attr_get_value(sar); + const uint8_t* value = stun_attr_get_value(sar); if(!value) { return -1; } else { @@ -1568,12 +1568,12 @@ int stun_attr_get_address_error_code(u08bits* buf, size_t len, int *requested_ad return 0; } -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) { stun_attr_ref attr=stun_attr_get_first_str(buf,len); while(attr) { if(stun_attr_get_type(attr) == STUN_ATTRIBUTE_CHANNEL_NUMBER) { - u16bits ret = stun_attr_get_channel_number(attr); + uint16_t ret = stun_attr_get_channel_number(attr); if(STUN_VALID_CHANNEL(ret)) { return ret; } @@ -1586,21 +1586,21 @@ u16bits stun_attr_get_first_channel_number_str(const u08bits *buf, size_t len) { ////////////// FINGERPRINT //////////////////////////// -int stun_attr_add_fingerprint_str(u08bits *buf, size_t *len) +int stun_attr_add_fingerprint_str(uint8_t *buf, size_t *len) { - u32bits crc32 = 0; - stun_attr_add_str(buf, len, STUN_ATTRIBUTE_FINGERPRINT, (u08bits*)&crc32, 4); + uint32_t crc32 = 0; + stun_attr_add_str(buf, len, STUN_ATTRIBUTE_FINGERPRINT, (uint8_t*)&crc32, 4); crc32 = ns_crc32(buf,*len-8); - *((u32bits*)(buf+*len-4)) = nswap32(crc32 ^ ((u32bits)0x5354554e)); + *((uint32_t*)(buf+*len-4)) = nswap32(crc32 ^ ((uint32_t)0x5354554e)); return 0; } ////////////// CRC /////////////////////////////////////////////// #define CRC_MASK 0xFFFFFFFFUL -#define UPDATE_CRC(crc, c) crc = crctable[(u08bits)crc ^ (u08bits)(c)] ^ (crc >> 8) +#define UPDATE_CRC(crc, c) crc = crctable[(uint8_t)crc ^ (uint8_t)(c)] ^ (crc >> 8) -static const u32bits crctable[256] = { +static const uint32_t crctable[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, @@ -1676,7 +1676,7 @@ reversed 0x04C11DB7 static void make_crctable(void) { uint i, j; - u32bits r; + uint32_t r; for (i = 0; i < 256; ++i) { r = i; @@ -1691,9 +1691,9 @@ static void make_crctable(void) } */ -static u32bits ns_crc32(const u08bits *buffer, u32bits len) +static uint32_t ns_crc32(const uint8_t *buffer, uint32_t len) { - u32bits crc = CRC_MASK; + uint32_t crc = CRC_MASK; while ( len-- ) UPDATE_CRC( crc, *buffer++ ); return (~crc); } @@ -1702,13 +1702,13 @@ static u32bits ns_crc32(const u08bits *buffer, u32bits len) /* We support only basic ASCII table */ -int SASLprep(u08bits *s) +int SASLprep(uint8_t *s) { if(s) { - u08bits *strin = s; - u08bits *strout = s; + uint8_t *strin = s; + uint8_t *strout = s; for(;;) { - u08bits c = *strin; + uint8_t c = *strin; if(!c) { *strout=0; break; @@ -1759,14 +1759,14 @@ void print_bin_func(const char *name, size_t len, const void *s, const char *fun printf("<%s>:<%s>:len=%d:[",func,name,(int)len); size_t i; for(i=0;i orig_len) return -1; @@ -1917,7 +1917,7 @@ int stun_check_message_integrity_by_key_str(turn_credential_type ct, u08bits *bu /* * Return -1 if failure, 0 if the integrity is not correct, 1 if OK */ -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) { hmackey_t key; password_t pwd; @@ -1935,19 +1935,19 @@ int stun_check_message_integrity_str(turn_credential_type ct, u08bits *buf, size int stun_attr_get_change_request_str(stun_attr_ref attr, int *change_ip, int *change_port) { if(stun_attr_get_len(attr) == 4) { - const u08bits* value = stun_attr_get_value(attr); + const uint8_t* value = stun_attr_get_value(attr); if(value) { - *change_ip = (value[3] & (u08bits)0x04); - *change_port = (value[3] & (u08bits)0x02); + *change_ip = (value[3] & (uint8_t)0x04); + *change_port = (value[3] & (uint8_t)0x02); return 0; } } return -1; } -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) { - u08bits avalue[4]={0,0,0,0}; + uint8_t avalue[4]={0,0,0,0}; if(change_ip) { if(change_port) { @@ -1965,18 +1965,18 @@ int stun_attr_add_change_request_str(u08bits *buf, size_t *len, int change_ip, i int stun_attr_get_response_port_str(stun_attr_ref attr) { if(stun_attr_get_len(attr) >= 2) { - const u08bits* value = stun_attr_get_value(attr); + const uint8_t* value = stun_attr_get_value(attr); if(value) { - return nswap16(((const u16bits*)value)[0]); + return nswap16(((const uint16_t*)value)[0]); } } return -1; } -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) { - u08bits avalue[4]={0,0,0,0}; - u16bits *port_ptr = (u16bits*)avalue; + uint8_t avalue[4]={0,0,0,0}; + uint16_t *port_ptr = (uint16_t*)avalue; *port_ptr = nswap16(port); @@ -1987,12 +1987,12 @@ int stun_attr_get_padding_len_str(stun_attr_ref attr) { int len = stun_attr_get_len(attr); if(len<0) return -1; - return (u16bits)len; + return (uint16_t)len; } -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) { - u08bits avalue[0xFFFF]; + uint8_t avalue[0xFFFF]; bzero(avalue,padding_len); return stun_attr_add_str(buf, len, STUN_ATTRIBUTE_PADDING, avalue, padding_len); @@ -2236,8 +2236,8 @@ void print_field(const char* name, const unsigned char* f, size_t len) { printf("\n<<==field %s\n",name); } -int encode_oauth_token_normal(const u08bits *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken); -int encode_oauth_token_normal(const u08bits *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken) +int encode_oauth_token_normal(const uint8_t *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken); +int encode_oauth_token_normal(const uint8_t *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken) { UNUSED_ARG(server_name); UNUSED_ARG(etoken); @@ -2310,8 +2310,8 @@ int encode_oauth_token_normal(const u08bits *server_name, encoded_oauth_token *e return -1; } -int decode_oauth_token_normal(const u08bits *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken); -int decode_oauth_token_normal(const u08bits *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken) +int decode_oauth_token_normal(const uint8_t *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken); +int decode_oauth_token_normal(const uint8_t *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken) { UNUSED_ARG(server_name); UNUSED_ARG(etoken); @@ -2407,7 +2407,7 @@ static void generate_random_nonce(unsigned char *nonce, size_t sz) { #if !defined(TURN_NO_GCM) -static int encode_oauth_token_gcm(const u08bits *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken, const u08bits* nonce0) { +static int encode_oauth_token_gcm(const uint8_t *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken, const uint8_t* nonce0) { if(server_name && etoken && key && dtoken && (dtoken->enc_block.key_length<=MAXSHASIZE)) { unsigned char orig_field[MAX_ENCODED_OAUTH_TOKEN_SIZE]; @@ -2506,7 +2506,7 @@ static int encode_oauth_token_gcm(const u08bits *server_name, encoded_oauth_toke return -1; } -static int decode_oauth_token_gcm(const u08bits *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken) +static int decode_oauth_token_gcm(const uint8_t *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken) { if(server_name && etoken && key && dtoken) { @@ -2628,7 +2628,7 @@ static int decode_oauth_token_gcm(const u08bits *server_name, const encoded_oaut #endif -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) { UNUSED_ARG(nonce); if(server_name && etoken && key && dtoken) { @@ -2646,7 +2646,7 @@ int encode_oauth_token(const u08bits *server_name, encoded_oauth_token *etoken, return -1; } -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) { if(server_name && etoken && key && dtoken) { switch(key->as_rs_alg) { diff --git a/src/client/ns_turn_msg.h b/src/client/ns_turn_msg.h index 1667fe06..04352723 100644 --- a/src/client/ns_turn_msg.h +++ b/src/client/ns_turn_msg.h @@ -61,9 +61,9 @@ typedef enum { /** * 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; /////////////////////////////////// @@ -78,11 +78,11 @@ void stun_tid_generate(stun_tid* id); /////////////////////////////////////////////////////////////// -u16bits stun_make_type(u16bits method); -u16bits stun_make_request(u16bits method); -u16bits stun_make_indication(u16bits method); -u16bits stun_make_success_response(u16bits method); -u16bits stun_make_error_response(u16bits method); +uint16_t stun_make_type(uint16_t method); +uint16_t stun_make_request(uint16_t method); +uint16_t stun_make_indication(uint16_t method); +uint16_t stun_make_success_response(uint16_t 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 //////////////////////////////////////////////// -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_command_str(u16bits message_type, u08bits* buf, size_t *len); -void old_stun_init_command_str(u16bits message_type, u08bits* buf, size_t *len, u32bits cookie); -void stun_init_request_str(u16bits method, u08bits* buf, size_t *len); -void stun_init_indication_str(u16bits method, u08bits* buf, size_t *len); -void stun_init_success_response_str(u16bits method, u08bits* 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 stun_init_error_response_str(u16bits method, u08bits* buf, size_t *len, u16bits error_code, const u08bits *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); -int stun_init_channel_message_str(u16bits chnumber, u08bits* buf, size_t *len, int length, int do_padding); +void stun_init_buffer_str(uint8_t *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(uint16_t message_type, uint8_t* buf, size_t *len, uint32_t cookie); +void stun_init_request_str(uint16_t method, uint8_t* buf, size_t *len); +void stun_init_indication_str(uint16_t method, uint8_t* buf, size_t *len); +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(uint16_t method, uint8_t* buf, size_t *len, stun_tid* id, uint32_t cookie); +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(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(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 old_stun_is_command_message_str(const u08bits* buf, size_t blen, u32bits *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_offset_str(const u08bits* buf, size_t blen, int offset); -int stun_is_request_str(const u08bits* buf, size_t len); -int stun_is_success_response_str(const u08bits* 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_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_response_str(const u08bits* buf, size_t len); -int stun_is_indication_str(const u08bits* buf, size_t len); -u16bits stun_get_method_str(const u08bits *buf, size_t len); -u16bits stun_get_msg_type_str(const u08bits *buf, size_t len); -int stun_is_channel_message_str(const u08bits *buf, size_t *blen, u16bits* chnumber, int mandatory_padding); -int is_channel_msg_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 uint8_t* buf, size_t blen, uint32_t *cookie); +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 uint8_t* buf, size_t blen, int offset); +int stun_is_request_str(const uint8_t* buf, size_t len); +int stun_is_success_response_str(const uint8_t* buf, size_t len); +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 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 uint8_t* buf, size_t len); +int stun_is_indication_str(const uint8_t* buf, size_t len); +uint16_t stun_get_method_str(const uint8_t *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 uint8_t *buf, size_t *blen, uint16_t* chnumber, int mandatory_padding); +int is_channel_msg_str(const uint8_t* buf, size_t blen); -void stun_set_binding_request_str(u08bits* buf, size_t *len); -int stun_set_binding_response_str(u08bits* buf, size_t *len, stun_tid* tid, +void stun_set_binding_request_str(uint8_t* buf, size_t *len); +int stun_set_binding_response_str(uint8_t* buf, size_t *len, stun_tid* tid, const ioa_addr *reflexive_addr, int error_code, - const u08bits *reason, - u32bits cookie, int old_stun); -int stun_is_binding_request_str(const u08bits* buf, size_t len, size_t offset); -int stun_is_binding_response_str(const u08bits* buf, size_t len); + const uint8_t *reason, + uint32_t cookie, int old_stun); +int stun_is_binding_request_str(const uint8_t* buf, size_t len, size_t offset); +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_message_cpy(u08bits *buf, const stun_tid* id); -void stun_tid_generate_in_message_str(u08bits* buf, stun_tid* id); +void stun_tid_from_message_str(const uint8_t* buf, size_t len, stun_tid* id); +void stun_tid_message_cpy(uint8_t *buf, const 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_get_type(stun_attr_ref attr); int stun_attr_get_len(stun_attr_ref attr); -const u08bits* stun_attr_get_value(stun_attr_ref attr); -u16bits stun_attr_get_channel_number(stun_attr_ref attr); +const uint8_t* stun_attr_get_value(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); -u08bits stun_attr_get_even_port(stun_attr_ref attr); -u64bits 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_str(const u08bits* buf, size_t len); -stun_attr_ref stun_attr_get_next_str(const u08bits* 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_addr_str(u08bits *buf, size_t *len, u16bits 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_first_addr_str(const u08bits *buf, size_t len, u16bits 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_bandwidth_str(u08bits* 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); +uint8_t stun_attr_get_even_port(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 uint8_t* buf, size_t len, uint16_t attr_type); +stun_attr_ref stun_attr_get_first_str(const uint8_t* buf, size_t len); +stun_attr_ref stun_attr_get_next_str(const uint8_t* buf, size_t len, stun_attr_ref prev); +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(uint8_t *buf, size_t *len, uint16_t attr_type, const ioa_addr* ca); +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 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(uint8_t* buf, size_t *len, uint16_t chnumber); +int stun_attr_add_bandwidth_str(uint8_t* buf, size_t *len, band_limit_t bps); +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: */ -int stun_attr_get_address_error_code(u08bits* 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); +int stun_attr_get_address_error_code(uint8_t* buf, size_t len, int *requested_address_family, int *error_code); +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_response_str(u08bits* buf, size_t *len, stun_tid* tid, +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(uint8_t* buf, size_t *len, stun_tid* tid, const ioa_addr *relayed_addr1, const ioa_addr *relayed_addr2, const ioa_addr *reflexive_addr, - u32bits lifetime, u32bits max_lifetime, int error_code, const u08bits *reason, - u64bits reservation_token, char *mobile_id); + uint32_t lifetime, uint32_t max_lifetime, int error_code, const uint8_t *reason, + uint64_t reservation_token, char *mobile_id); -u16bits stun_set_channel_bind_request_str(u08bits* buf, size_t *len, - const ioa_addr* peer_addr, u16bits channel_number); -void stun_set_channel_bind_response_str(u08bits* buf, size_t *len, stun_tid* tid, int error_code, const u08bits *reason); +uint16_t stun_set_channel_bind_request_str(uint8_t* buf, size_t *len, + const ioa_addr* peer_addr, uint16_t channel_number); +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_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__) 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 */ -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_str(turn_credential_type ct, u08bits *buf, size_t len, u08bits *uname, u08bits *realm, u08bits *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_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_user_str(u08bits *buf, size_t *len, u08bits *uname, u08bits *realm, u08bits *upwd, u08bits *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_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, 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, uint8_t *buf, size_t *len, hmackey_t key, password_t pwd, 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(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(uint8_t *buf, size_t *len, uint8_t *uname, password_t pwd, 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)) long turn_random(void); -int stun_produce_integrity_key_str(u08bits *uname, u08bits *realm, u08bits *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_produce_integrity_key_str(uint8_t *uname, uint8_t *realm, uint8_t *upwd, hmackey_t key, 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 */ 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_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_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 */ int is_http(const char *s, size_t blen); /* OAUTH */ 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 encode_oauth_token(const u08bits *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken, const u08bits *nonce); +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 uint8_t *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken, const uint8_t *nonce); /* Encrypted password */ void generate_new_enc_password(const char* pwd, char *result); diff --git a/src/client/ns_turn_msg_addr.c b/src/client/ns_turn_msg_addr.c index 33e65608..e5367216 100644 --- a/src/client/ns_turn_msg_addr.c +++ b/src/client/ns_turn_msg_addr.c @@ -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; @@ -48,18 +48,18 @@ int stun_addr_encode(const ioa_addr* ca, u08bits *cfield, int *clen, int xor_ed, if (xor_ed) { /* Port */ - ((u16bits*)cfield)[1] = (ca->s4.sin_port) ^ nswap16(mc >> 16); + ((uint16_t*)cfield)[1] = (ca->s4.sin_port) ^ nswap16(mc >> 16); /* 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 { /* Port */ - ((u16bits*)cfield)[1]=ca->s4.sin_port; + ((uint16_t*)cfield)[1]=ca->s4.sin_port; /* 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) { @@ -74,29 +74,29 @@ int stun_addr_encode(const ioa_addr* ca, u08bits *cfield, int *clen, int xor_ed, if (xor_ed) { unsigned int i; - u08bits *dst = ((u08bits*)cfield)+4; - const u08bits *src = (const u08bits*)&(ca->s6.sin6_addr); - u32bits magic = nswap32(mc); + uint8_t *dst = ((uint8_t*)cfield)+4; + const uint8_t *src = (const uint8_t*)&(ca->s6.sin6_addr); + uint32_t magic = nswap32(mc); /* Port */ - ((u16bits*)cfield)[1] = ca->s6.sin6_port ^ nswap16(mc >> 16); + ((uint16_t*)cfield)[1] = ca->s6.sin6_port ^ nswap16(mc >> 16); /* Address */ 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) { - dst[i+4] = (u08bits)(src[i+4] ^ tsx_id[i]); + dst[i+4] = (uint8_t)(src[i+4] ^ tsx_id[i]); } } else { /* Port */ - ((u16bits*)cfield)[1]=ca->s6.sin6_port; + ((uint16_t*)cfield)[1]=ca->s6.sin6_port; /* Address */ - bcopy(&ca->s6.sin6_addr, ((u08bits*)cfield)+4, 16); + bcopy(&ca->s6.sin6_addr, ((uint8_t*)cfield)+4, 16); } } else { @@ -106,7 +106,7 @@ int stun_addr_encode(const ioa_addr* ca, u08bits *cfield, int *clen, int xor_ed, 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; @@ -129,10 +129,10 @@ int stun_addr_decode(ioa_addr* ca, const u08bits *cfield, int len, int xor_ed, u /* IPv4 address */ /* Port */ - ca->s4.sin_port=((const u16bits*)cfield)[1]; + ca->s4.sin_port=((const uint16_t*)cfield)[1]; /* 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) { 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; /* Port */ - ca->s6.sin6_port = ((const u16bits*)cfield)[1]; + ca->s6.sin6_port = ((const uint16_t*)cfield)[1]; /* 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) { unsigned int i; - u08bits *dst; - const u08bits *src; - u32bits magic = nswap32(mc); + uint8_t *dst; + const uint8_t *src; + uint32_t magic = nswap32(mc); /* Port */ ca->s6.sin6_port ^= nswap16(mc >> 16); /* Address */ - src = ((const u08bits*)cfield)+4; - dst = (u08bits*)&ca->s6.sin6_addr; + src = ((const uint8_t*)cfield)+4; + dst = (uint8_t*)&ca->s6.sin6_addr; 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) { - dst[i+4] = (u08bits)(src[i+4] ^ tsx_id[i]); + dst[i+4] = (uint8_t)(src[i+4] ^ tsx_id[i]); } } diff --git a/src/client/ns_turn_msg_addr.h b/src/client/ns_turn_msg_addr.h index 6d03c3c7..da10a488 100644 --- a/src/client/ns_turn_msg_addr.h +++ b/src/client/ns_turn_msg_addr.h @@ -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_decode(ioa_addr* ca, const u08bits *cfield, int len, 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 uint8_t *cfield, int len, int xor_ed, uint32_t mc, const uint8_t *tsx_id); /////////////////////////////////////////// diff --git a/src/ns_turn_defs.h b/src/ns_turn_defs.h index 66f9fce9..71b60e57 100644 --- a/src/ns_turn_defs.h +++ b/src/ns_turn_defs.h @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -60,29 +61,17 @@ extern "C" { #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 nswap32(ul) ntohl(ul) #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 - u08bits *src = (u08bits*) &v; - u08bits* dst = src + 7; + uint8_t *src = (uint8_t*) &v; + uint8_t* dst = src + 7; while (src < dst) { - u08bits vdst = *dst; + uint8_t vdst = *dst; *(dst--) = *src; *(src++) = vdst; } @@ -112,9 +101,9 @@ static inline u64bits _ioa_ntoh64(u64bits v) typedef int vint; 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) #define UNUSED_ARG(A) do { A=A; } while(0) diff --git a/src/server/ns_turn_allocation.c b/src/server/ns_turn_allocation.c index 79f4ba44..54ed484b 100644 --- a/src/server/ns_turn_allocation.c +++ b/src/server/ns_turn_allocation.c @@ -174,7 +174,7 @@ void turn_permission_clean(turn_permission_info* tinfo) if(tinfo->verbose) { 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); } @@ -238,7 +238,7 @@ static turn_permission_info* get_from_turn_permission_hashtable(turn_permission_ if (!addr || !map) 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]); { @@ -300,7 +300,7 @@ void turn_channel_delete(ch_info* chn) int port = addr_get_port(&(chn->peer_addr)); if(port<1) { 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); } { @@ -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); @@ -336,7 +336,7 @@ ch_info* allocation_get_new_ch_info(allocation* a, u16bits chnum, ioa_addr* peer 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); } @@ -348,7 +348,7 @@ ch_info* allocation_get_ch_info_by_peer_addr(allocation* a, ioa_addr* peer_addr) 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) { 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) { 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)); 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; if(map) { @@ -535,16 +535,16 @@ void ch_map_clean(ch_map* map) ////////////////// 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); ur_map *map = a->tcp_connections; - u32bits newid; - u32bits sid = server_id; + uint32_t newid; + uint32_t sid = server_id; sid = sid<<24; do { newid = 0; while (!newid) { - newid = (u32bits)turn_random(); + newid = (uint32_t)turn_random(); if(!newid) { 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); } -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); if(tcl->elems) { diff --git a/src/server/ns_turn_allocation.h b/src/server/ns_turn_allocation.h index ff3d4594..f3fcbb18 100644 --- a/src/server/ns_turn_allocation.h +++ b/src/server/ns_turn_allocation.h @@ -75,7 +75,7 @@ enum _TC_STATE { typedef enum _TC_STATE TC_STATE; -typedef u32bits tcp_connection_id; +typedef uint32_t tcp_connection_id; typedef struct { size_t sz; @@ -110,9 +110,9 @@ typedef struct _tcp_connection_list { struct _allocation; typedef struct _ch_info { - u16bits chnum; + uint16_t chnum; int allocated; - u16bits port; + uint16_t port; ioa_addr peer_addr; turn_time_t expiration_time; ioa_timer_handle lifetime_ev; @@ -135,7 +135,7 @@ typedef struct _ch_map { ch_map_array table[CH_MAP_HASH_SIZE]; } 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); //////////////////////////// @@ -187,7 +187,7 @@ typedef struct _allocation { //////////// 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); 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_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_ch_info(allocation* a, u16bits chnum); +ch_info* allocation_get_new_ch_info(allocation* a, uint16_t chnum, ioa_addr* peer_addr); +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); 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_peer(allocation *a, ioa_addr *peer_addr); 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 clear_unsent_buffer(unsent_buffer *ub); diff --git a/src/server/ns_turn_ioalib.h b/src/server/ns_turn_ioalib.h index 32c7aa9f..074e618e 100644 --- a/src/server/ns_turn_ioalib.h +++ b/src/server/ns_turn_ioalib.h @@ -53,7 +53,7 @@ typedef struct _tcp_connection tcp_connection; ////////////// Mutexes ///////////////////// struct _turn_mutex { - u32bits data; + uint32_t data; 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); 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_capacity(ioa_network_buffer_handle nbh); 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_add_offset_size(ioa_network_buffer_handle nbh, u16bits offset, u08bits coffset, size_t len); -u16bits ioa_network_buffer_get_offset(ioa_network_buffer_handle nbh); -u08bits ioa_network_buffer_get_coffset(ioa_network_buffer_handle nbh); +void ioa_network_buffer_add_offset_size(ioa_network_buffer_handle nbh, uint16_t offset, uint8_t coffset, size_t len); +uint16_t ioa_network_buffer_get_offset(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); /* @@ -204,7 +204,7 @@ typedef void (*ioa_timer_event_handler)(ioa_engine_handle e, void *ctx); /* 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 delete_ioa_timer(ioa_timer_handle th); #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. */ 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, - 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); 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 is_stream_socket(int st); diff --git a/src/server/ns_turn_khash.h b/src/server/ns_turn_khash.h index 1087da09..945c4658 100644 --- a/src/server/ns_turn_khash.h +++ b/src/server/ns_turn_khash.h @@ -32,7 +32,7 @@ An example: #include "khash.h" -KHASH_MAP_INIT_INT(32, s08bits) +KHASH_MAP_INIT_INT(32, char) int main() { int ret, is_missing; khiter_t k; @@ -87,16 +87,16 @@ int main() { #include "ns_turn_defs.h" -typedef u32bits khint_t; +typedef uint32_t khint_t; typedef khint_t khiter_t; typedef struct _str_chunk_t { - const s08bits *str; + const char *str; size_t len; } str_chunk_t; #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, 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) \ typedef struct { \ khint_t n_buckets, size, n_occupied, upper_bound; \ - u32bits *flags; u32bits flags_size; \ - khkey_t *keys; u32bits keys_size; \ - khval_t *vals; u32bits vals_size; \ + uint32_t *flags; uint32_t flags_size; \ + khkey_t *keys; uint32_t keys_size; \ + khval_t *vals; uint32_t vals_size; \ } kh_##name##_t; \ static inline kh_##name##_t *kh_init_##name(void) { \ 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) \ { \ 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; \ } \ } \ @@ -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) \ { \ - u32bits *new_flags = 0; \ - u32bits new_flags_size = 0; \ + uint32_t *new_flags = 0; \ + uint32_t new_flags_size = 0; \ khint_t j = 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]; \ if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0; \ else { \ - new_flags_size = ((new_n_buckets>>4) + 1) * sizeof(u32bits); \ - new_flags = (u32bits*)malloc(new_flags_size); \ + new_flags_size = ((new_n_buckets>>4) + 1) * sizeof(uint32_t); \ + new_flags = (uint32_t*)malloc(new_flags_size); \ memset(new_flags, 0xaa, new_flags_size); \ if (h->n_buckets < new_n_buckets) { \ 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 --- */ -#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_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) -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; if (h) @@ -286,7 +286,7 @@ static inline khint_t __ac_X31_hash_string(const s08bits *s) h = (h << 5) - h + *s; 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); if (h) @@ -349,39 +349,39 @@ static inline khint_t __ac_X31_hash_ncstring(const str_chunk_t *s) /* More convenient interfaces */ #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) \ - 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) \ - 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) \ - 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; #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) \ KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_str_hash_func, kh_str_hash_equal) #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) \ KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_cstr_hash_func, kh_cstr_hash_equal) #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) \ KHASH_INIT(name, kh_ncstr_t, khval_t, 1, kh_nstr_hash_func, kh_nstr_hash_equal) #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) \ KHASH_INIT(name, kh_ncstr_t, khval_t, 1, kh_ncstr_hash_func, kh_ncstr_hash_equal) diff --git a/src/server/ns_turn_maps.c b/src/server/ns_turn_maps.c index 4273cfd8..c55f8964 100644 --- a/src/server/ns_turn_maps.c +++ b/src/server/ns_turn_maps.c @@ -36,11 +36,11 @@ KHASH_MAP_INIT_INT64(3, ur_map_value_type) -#define MAGIC_HASH ((u64bits)(0x90ABCDEFL)) +#define MAGIC_HASH ((uint64_t)(0x90ABCDEFL)) struct _ur_map { khash_t(3) *h; - u64bits magic; + uint64_t magic; 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) { if(map && ur_addr_map_valid(map)) { - u32bits i=0; + uint32_t i=0; for(i=0;ilists[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)) { - u32bits i=0; + uint32_t i=0; for(i=0;ilists[i]); @@ -910,7 +910,7 @@ size_t ur_addr_map_num_elements(const ur_addr_map* map) { size_t ret = 0; if (ur_addr_map_valid(map)) { - u32bits i = 0; + uint32_t i = 0; for (i = 0; i < ADDR_MAP_SIZE; 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; if (ur_addr_map_valid(map)) { - u32bits i = 0; + uint32_t i = 0; for (i = 0; i < ADDR_MAP_SIZE; i++) { const addr_list_header* slh = &(map->lists[i]); @@ -948,7 +948,7 @@ typedef struct _string_list { typedef struct _string_elem { string_list list; ur_string_map_key_type key; - u32bits key_size; + uint32_t key_size; ur_string_map_value_type value; } 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)); elem->list.next=sl; 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); elem->value=value; 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 { string_list_header lists[STRING_MAP_SIZE]; - u64bits magic; + uint64_t magic; ur_string_map_func del_value_func; 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; while ((c = *str++)) diff --git a/src/server/ns_turn_maps.h b/src/server/ns_turn_maps.h index 636e7aac..46b3c008 100644 --- a/src/server/ns_turn_maps.h +++ b/src/server/ns_turn_maps.h @@ -44,7 +44,7 @@ typedef struct _ur_map ur_map; //////////////// Common Definitions ////// -typedef u64bits ur_map_key_type; +typedef uint64_t ur_map_key_type; typedef unsigned long 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 { addr_list_header lists[ADDR_MAP_SIZE]; - u64bits magic; + uint64_t magic; }; struct _ur_addr_map; @@ -221,7 +221,7 @@ size_t ur_addr_map_size(const ur_addr_map* 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; struct _ur_string_map; typedef struct _ur_string_map ur_string_map; diff --git a/src/server/ns_turn_maps_rtcp.c b/src/server/ns_turn_maps_rtcp.c index 84a44f58..5edeeaf5 100644 --- a/src/server/ns_turn_maps_rtcp.c +++ b/src/server/ns_turn_maps_rtcp.c @@ -42,7 +42,7 @@ //////////////////////////////////////////// struct _rtcp_map { - u32bits magic; + uint32_t magic; ur_map *map; ioa_timer_handle timer_ev; TURN_MUTEX_DECLARE(mutex) diff --git a/src/server/ns_turn_server.c b/src/server/ns_turn_server.c index 77e70c92..f7cf64e5 100644 --- a/src/server/ns_turn_server.c +++ b/src/server/ns_turn_server.c @@ -76,7 +76,7 @@ const char * get_version(turn_turnserver *server) { int TURN_MAX_ALLOCATE_TIMEOUT = 60; int TURN_MAX_ALLOCATE_TIMEOUT_STUN_ONLY = 3; -static inline void log_method(ts_ur_super_session* ss, const char *method, int err_code, const u08bits *reason) +static inline void log_method(ts_ur_super_session* ss, const char *method, int err_code, const uint8_t *reason) { if(ss) { if(!method) method = "unknown"; @@ -111,21 +111,21 @@ static int attach_socket_to_session(turn_turnserver* server, ioa_socket_handle s static int check_stun_auth(turn_turnserver *server, ts_ur_super_session *ss, stun_tid *tid, int *resp_constructed, - int *err_code, const u08bits **reason, + int *err_code, const uint8_t **reason, ioa_net_data *in_buffer, ioa_network_buffer_handle nbh, - u16bits method, int *message_integrity, + uint16_t method, int *message_integrity, int *postpone_reply, int can_resume); static int create_relay_connection(turn_turnserver* server, - ts_ur_super_session *ss, u32bits lifetime, - int address_family, u08bits transport, - int even_port, u64bits in_reservation_token, u64bits *out_reservation_token, - int *err_code, const u08bits **reason, accept_cb acb); + ts_ur_super_session *ss, uint32_t lifetime, + int address_family, uint8_t transport, + int even_port, uint64_t in_reservation_token, uint64_t *out_reservation_token, + int *err_code, const uint8_t **reason, accept_cb acb); static int refresh_relay_connection(turn_turnserver* server, - ts_ur_super_session *ss, u32bits lifetime, int even_port, - u64bits in_reservation_token, u64bits *out_reservation_token, + ts_ur_super_session *ss, uint32_t lifetime, int even_port, + uint64_t in_reservation_token, uint64_t *out_reservation_token, int *err_code, int family); static int write_client_connection(turn_turnserver *server, ts_ur_super_session* ss, ioa_network_buffer_handle nbh, int ttl, int tos); @@ -159,7 +159,7 @@ turn_time_t get_turn_server_time(turn_turnserver *server) /////////////////// quota ////////////////////// -static int inc_quota(ts_ur_super_session* ss, u08bits *username) +static int inc_quota(ts_ur_super_session* ss, uint8_t *username) { if(ss && !(ss->quota_used) && ss->server && ((turn_turnserver*)ss->server)->chquotacb && username) { @@ -169,7 +169,7 @@ static int inc_quota(ts_ur_super_session* ss, u08bits *username) } } - if((((turn_turnserver*)ss->server)->chquotacb)(username, ss->oauth, (u08bits*)ss->realm_options.name)<0) { + if((((turn_turnserver*)ss->server)->chquotacb)(username, ss->oauth, (uint8_t*)ss->realm_options.name)<0) { return -1; @@ -190,7 +190,7 @@ static void dec_quota(ts_ur_super_session* ss) ss->quota_used = 0; - (((turn_turnserver*)ss->server)->raqcb)(ss->username, ss->oauth, (u08bits*)ss->realm_options.name); + (((turn_turnserver*)ss->server)->raqcb)(ss->username, ss->oauth, (uint8_t*)ss->realm_options.name); } } @@ -310,7 +310,7 @@ static int good_peer_addr(turn_turnserver *server, const char* realm, ioa_addr * CHECK_REALM(server->ip_blacklist->rs[i].realm); if (ioa_addr_in_range(&(server->ip_blacklist->rs[i].enc), peer_addr)) { char saddr[129]; - addr_to_string_no_port(peer_addr,(u08bits*)saddr); + addr_to_string_no_port(peer_addr,(uint8_t*)saddr); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "A peer IP %s denied in the range: %s\n",saddr,server->ip_blacklist->rs[i].str); return 0; } @@ -328,7 +328,7 @@ static int good_peer_addr(turn_turnserver *server, const char* realm, ioa_addr * if (ioa_addr_in_range(&(bl->rs[i].enc), peer_addr)) { ioa_unlock_blacklist(server->e); char saddr[129]; - addr_to_string_no_port(peer_addr,(u08bits*)saddr); + addr_to_string_no_port(peer_addr,(uint8_t*)saddr); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "A peer IP %s denied in the range: %s\n",saddr,bl->rs[i].str); return 0; } @@ -392,7 +392,7 @@ void turn_session_info_add_peer(struct turn_session_info* tsi, ioa_addr *peer) if(tsi->main_peers_size < TURN_MAIN_PEERS_ARRAY_SIZE) { addr_cpy(&(tsi->main_peers_data[tsi->main_peers_size].addr),peer); addr_to_string(&(tsi->main_peers_data[tsi->main_peers_size].addr), - (u08bits*)tsi->main_peers_data[tsi->main_peers_size].saddr); + (uint8_t*)tsi->main_peers_data[tsi->main_peers_size].saddr); tsi->main_peers_size += 1; return; } @@ -409,7 +409,7 @@ void turn_session_info_add_peer(struct turn_session_info* tsi, ioa_addr *peer) tsi->extra_peers_data = (addr_data*)realloc(tsi->extra_peers_data,(tsi->extra_peers_size+1)*sizeof(addr_data)); addr_cpy(&(tsi->extra_peers_data[tsi->extra_peers_size].addr),peer); addr_to_string(&(tsi->extra_peers_data[tsi->extra_peers_size].addr), - (u08bits*)tsi->extra_peers_data[tsi->extra_peers_size].saddr); + (uint8_t*)tsi->extra_peers_data[tsi->extra_peers_size].saddr); tsi->extra_peers_size += 1; } } @@ -457,23 +457,23 @@ int turn_session_info_copy_from(struct turn_session_info* tsi, ts_ur_super_sessi if(ss->client_socket) { tsi->client_protocol = get_ioa_socket_type(ss->client_socket); addr_cpy(&(tsi->local_addr_data.addr),get_local_addr_from_ioa_socket(ss->client_socket)); - 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); addr_cpy(&(tsi->remote_addr_data.addr),get_remote_addr_from_ioa_socket(ss->client_socket)); - 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(ss->alloc.relay_sessions[ALLOC_IPV4_INDEX].s) { tsi->peer_protocol = get_ioa_socket_type(ss->alloc.relay_sessions[ALLOC_IPV4_INDEX].s); if(ss->alloc.is_valid) { addr_cpy(&(tsi->relay_addr_data_ipv4.addr),get_local_addr_from_ioa_socket(ss->alloc.relay_sessions[ALLOC_IPV4_INDEX].s)); - 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(ss->alloc.relay_sessions[ALLOC_IPV6_INDEX].s) { tsi->peer_protocol = get_ioa_socket_type(ss->alloc.relay_sessions[ALLOC_IPV6_INDEX].s); if(ss->alloc.is_valid) { addr_cpy(&(tsi->relay_addr_data_ipv6.addr),get_local_addr_from_ioa_socket(ss->alloc.relay_sessions[ALLOC_IPV6_INDEX].s)); - 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); } } } @@ -657,7 +657,7 @@ static mobile_id_t get_new_mobile_id(turn_turnserver* server) if(server && server->mobile_connections_map) { ur_map *map = server->mobile_connections_map; - u64bits sid = server->id; + uint64_t sid = server->id; sid = sid<<56; do { while (!newid) { @@ -874,7 +874,7 @@ static int update_turn_permission_lifetime(ts_ur_super_session *ss, turn_permiss tinfo->verbose = 1; tinfo->session_id = ss->id; 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 lifetime updated: %lu\n",(unsigned long long)ss->id,s,(unsigned long)time_delta); } @@ -923,7 +923,7 @@ static int update_channel_lifetime(ts_ur_super_session *ss, ch_info* chn) ioa_network_buffer_get_size(in_buffer->nbh), sar); \ continue -static u08bits get_transport_value(const u08bits *value) { +static uint8_t get_transport_value(const uint8_t *value) { if((value[0] == STUN_ATTRIBUTE_TRANSPORT_UDP_VALUE)|| (value[0] == STUN_ATTRIBUTE_TRANSPORT_TCP_VALUE)) { return value[0]; @@ -933,7 +933,7 @@ static u08bits get_transport_value(const u08bits *value) { static int handle_turn_allocate(turn_turnserver *server, ts_ur_super_session *ss, stun_tid *tid, int *resp_constructed, - int *err_code, const u08bits **reason, u16bits *unknown_attrs, u16bits *ua_num, + int *err_code, const uint8_t **reason, uint16_t *unknown_attrs, uint16_t *ua_num, ioa_net_data *in_buffer, ioa_network_buffer_handle nbh) { @@ -946,7 +946,7 @@ static int handle_turn_allocate(turn_turnserver *server, if (!stun_tid_equals(tid, &(alloc->tid))) { *err_code = 437; - *reason = (const u08bits *)"Wrong TID"; + *reason = (const uint8_t *)"Wrong TID"; } else { size_t len = ioa_network_buffer_get_size(nbh); ioa_addr xor_relayed_addr1, *pxor_relayed_addr1=NULL; @@ -981,7 +981,7 @@ static int handle_turn_allocate(turn_turnserver *server, } if(pxor_relayed_addr1 || pxor_relayed_addr2) { - u32bits lifetime = 0; + uint32_t lifetime = 0; if(pxor_relayed_addr1) { lifetime = (get_relay_session(alloc,pxor_relayed_addr1->ss.sa_family)->expiration_time - server->ctime); } else if(pxor_relayed_addr2) { @@ -1000,14 +1000,14 @@ static int handle_turn_allocate(turn_turnserver *server, } else { - u08bits transport = 0; + uint8_t transport = 0; turn_time_t lifetime = 0; int even_port = -1; int dont_fragment = 0; - u64bits in_reservation_token = 0; + uint64_t in_reservation_token = 0; int af4 = 0; int af6 = 0; - u08bits username[STUN_MAX_USERNAME_SIZE+1]="\0"; + uint8_t username[STUN_MAX_USERNAME_SIZE+1]="\0"; size_t ulen = 0; band_limit_t bps = 0; band_limit_t max_bps = 0; @@ -1019,12 +1019,12 @@ static int handle_turn_allocate(turn_turnserver *server, int attr_type = stun_attr_get_type(sar); if(attr_type == STUN_ATTRIBUTE_USERNAME) { - const u08bits* value = stun_attr_get_value(sar); + const uint8_t* value = stun_attr_get_value(sar); if (value) { ulen = stun_attr_get_len(sar); if(ulen>=sizeof(username)) { *err_code = 400; - *reason = (const u08bits *)"User name is too long"; + *reason = (const uint8_t *)"User name is too long"; break; } bcopy(value,username,ulen); @@ -1046,10 +1046,10 @@ static int handle_turn_allocate(turn_turnserver *server, case STUN_ATTRIBUTE_MOBILITY_TICKET: if(!(*(server->mobility))) { *err_code = 405; - *reason = (const u08bits *)"Mobility Forbidden"; + *reason = (const uint8_t *)"Mobility Forbidden"; } else if (stun_attr_get_len(sar) != 0) { *err_code = 400; - *reason = (const u08bits *)"Wrong Mobility Field"; + *reason = (const uint8_t *)"Wrong Mobility Field"; } else { ss->is_mobile = 1; } @@ -1057,12 +1057,12 @@ static int handle_turn_allocate(turn_turnserver *server, case STUN_ATTRIBUTE_REQUESTED_TRANSPORT: { if (stun_attr_get_len(sar) != 4) { *err_code = 400; - *reason = (const u08bits *)"Wrong Transport Field"; + *reason = (const uint8_t *)"Wrong Transport Field"; } else if(transport) { *err_code = 400; - *reason = (const u08bits *)"Duplicate Transport Fields"; + *reason = (const uint8_t *)"Duplicate Transport Fields"; } else { - const u08bits* value = stun_attr_get_value(sar); + const uint8_t* value = stun_attr_get_value(sar); if (value) { transport = get_transport_value(value); if (!transport) { @@ -1070,22 +1070,22 @@ static int handle_turn_allocate(turn_turnserver *server, } if((transport == STUN_ATTRIBUTE_TRANSPORT_TCP_VALUE) && *(server->no_tcp_relay)) { *err_code = 442; - *reason = (const u08bits *)"TCP Transport is not allowed by the TURN Server configuration"; + *reason = (const uint8_t *)"TCP Transport is not allowed by the TURN Server configuration"; } else if((transport == STUN_ATTRIBUTE_TRANSPORT_UDP_VALUE) && *(server->no_udp_relay)) { *err_code = 442; - *reason = (const u08bits *)"UDP Transport is not allowed by the TURN Server configuration"; + *reason = (const uint8_t *)"UDP Transport is not allowed by the TURN Server configuration"; } else if(ss->client_socket) { SOCKET_TYPE cst = get_ioa_socket_type(ss->client_socket); if((transport == STUN_ATTRIBUTE_TRANSPORT_TCP_VALUE) && !is_stream_socket(cst)) { *err_code = 400; - *reason = (const u08bits *)"Wrong Transport Data"; + *reason = (const uint8_t *)"Wrong Transport Data"; } else { ss->is_tcp_relay = (transport == STUN_ATTRIBUTE_TRANSPORT_TCP_VALUE); } } } else { *err_code = 400; - *reason = (const u08bits *)"Wrong Transport Data"; + *reason = (const uint8_t *)"Wrong Transport Data"; } } } @@ -1098,14 +1098,14 @@ static int handle_turn_allocate(turn_turnserver *server, case STUN_ATTRIBUTE_LIFETIME: { if (stun_attr_get_len(sar) != 4) { *err_code = 400; - *reason = (const u08bits *)"Wrong Lifetime Field"; + *reason = (const uint8_t *)"Wrong Lifetime Field"; } else { - const u08bits* value = stun_attr_get_value(sar); + const uint8_t* value = stun_attr_get_value(sar); if (!value) { *err_code = 400; - *reason = (const u08bits *)"Wrong Lifetime Data"; + *reason = (const uint8_t *)"Wrong Lifetime Data"; } else { - lifetime = nswap32(*((const u32bits*)value)); + lifetime = nswap32(*((const uint32_t*)value)); } } } @@ -1113,13 +1113,13 @@ static int handle_turn_allocate(turn_turnserver *server, case STUN_ATTRIBUTE_EVEN_PORT: { if (in_reservation_token) { *err_code = 400; - *reason = (const u08bits *)"Even Port and Reservation Token cannot be used together"; + *reason = (const uint8_t *)"Even Port and Reservation Token cannot be used together"; } else { even_port = stun_attr_get_even_port(sar); if(even_port) { if (af4 && af6) { *err_code = 400; - *reason = (const u08bits *)"Even Port cannot be used with Dual Allocation"; + *reason = (const uint8_t *)"Even Port cannot be used with Dual Allocation"; } } } @@ -1129,17 +1129,17 @@ static int handle_turn_allocate(turn_turnserver *server, int len = stun_attr_get_len(sar); if (len != 8) { *err_code = 400; - *reason = (const u08bits *)"Wrong Format of Reservation Token"; + *reason = (const uint8_t *)"Wrong Format of Reservation Token"; } else if(af4 || af6) { *err_code = 400; - *reason = (const u08bits *)"Address family attribute can not be used with reservation token request"; + *reason = (const uint8_t *)"Address family attribute can not be used with reservation token request"; } else { if (even_port >= 0) { *err_code = 400; - *reason = (const u08bits *)"Reservation Token cannot be used in this request with even port"; + *reason = (const uint8_t *)"Reservation Token cannot be used in this request with even port"; } else if (in_reservation_token) { *err_code = 400; - *reason = (const u08bits *)"Reservation Token cannot be used in this request"; + *reason = (const uint8_t *)"Reservation Token cannot be used in this request"; } else { in_reservation_token = stun_attr_get_reservation_token_value(sar); } @@ -1149,24 +1149,24 @@ static int handle_turn_allocate(turn_turnserver *server, case STUN_ATTRIBUTE_ADDITIONAL_ADDRESS_FAMILY: if(even_port>0) { *err_code = 400; - *reason = (const u08bits *)"Even Port cannot be used with Dual Allocation"; + *reason = (const uint8_t *)"Even Port cannot be used with Dual Allocation"; break; } /* Falls through. */ case STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY: { if(in_reservation_token) { *err_code = 400; - *reason = (const u08bits *)"Address family attribute can not be used with reservation token request"; + *reason = (const uint8_t *)"Address family attribute can not be used with reservation token request"; } else if(af4 || af6) { *err_code = 400; - *reason = (const u08bits *)"Extra address family attribute can not be used in the request"; + *reason = (const uint8_t *)"Extra address family attribute can not be used in the request"; } else { int af_req = stun_get_requested_address_family(sar); switch (af_req) { case STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4: if(attr_type == STUN_ATTRIBUTE_ADDITIONAL_ADDRESS_FAMILY) { *err_code = 400; - *reason = (const u08bits *)"Invalid value of the additional address family attribute"; + *reason = (const uint8_t *)"Invalid value of the additional address family attribute"; } else { af4 = af_req; } @@ -1196,7 +1196,7 @@ static int handle_turn_allocate(turn_turnserver *server, *err_code = 400; if(!(*reason)) - *reason = (const u08bits *)"Transport field missed or wrong"; + *reason = (const uint8_t *)"Transport field missed or wrong"; } else if (*ua_num > 0) { @@ -1210,7 +1210,7 @@ static int handle_turn_allocate(turn_turnserver *server, *err_code = 400; if(!(*reason)) - *reason = (const u08bits *)"Request parameters are incompatible with TCP transport"; + *reason = (const uint8_t *)"Request parameters are incompatible with TCP transport"; } else { @@ -1221,7 +1221,7 @@ static int handle_turn_allocate(turn_turnserver *server, } lifetime = stun_adjust_allocate_lifetime(lifetime, *(server->max_allocate_lifetime), ss->max_session_time_auth); - u64bits out_reservation_token = 0; + uint64_t out_reservation_token = 0; if(inc_quota(ss, username)<0) { @@ -1238,7 +1238,7 @@ static int handle_turn_allocate(turn_turnserver *server, ss->bps = server->allocate_bps_func(bps,1); if(!(ss->bps)) { *err_code = 486; - *reason = (const u08bits *)"Allocation Bandwidth Quota Reached"; + *reason = (const uint8_t *)"Allocation Bandwidth Quota Reached"; } } } @@ -1249,11 +1249,11 @@ static int handle_turn_allocate(turn_turnserver *server, if(af4 && af6) { if(server->external_ip_set) { *err_code = 440; - *reason = (const u08bits *)"Dual allocation cannot be supported in the current server configuration"; + *reason = (const uint8_t *)"Dual allocation cannot be supported in the current server configuration"; } if(even_port > 0) { *err_code = 440; - *reason = (const u08bits *)"Dual allocation cannot be supported with even-port functionality"; + *reason = (const uint8_t *)"Dual allocation cannot be supported with even-port functionality"; } } @@ -1308,8 +1308,8 @@ static int handle_turn_allocate(turn_turnserver *server, } } } else { - const u08bits *reason4 = NULL; - const u08bits *reason6 = NULL; + const uint8_t *reason4 = NULL; + const uint8_t *reason6 = NULL; { int af4res = create_relay_connection(server, ss, lifetime, af4, transport, @@ -1354,7 +1354,7 @@ static int handle_turn_allocate(turn_turnserver *server, if (*err_code) { if(!(*reason)) { - *reason = (const u08bits *)"Cannot create relay endpoint(s)"; + *reason = (const uint8_t *)"Cannot create relay endpoint(s)"; } } else { @@ -1467,7 +1467,7 @@ static void copy_auth_parameters(ts_ur_super_session *orig_ss, ts_ur_super_sessi static int handle_turn_refresh(turn_turnserver *server, ts_ur_super_session *ss, stun_tid *tid, int *resp_constructed, - int *err_code, const u08bits **reason, u16bits *unknown_attrs, u16bits *ua_num, + int *err_code, const uint8_t **reason, uint16_t *unknown_attrs, uint16_t *ua_num, ioa_net_data *in_buffer, ioa_network_buffer_handle nbh, int message_integrity, int *no_response, int can_resume) { @@ -1493,7 +1493,7 @@ static int handle_turn_refresh(turn_turnserver *server, if (!is_allocation_valid(a) && !(*(server->mobility))) { *err_code = 437; - *reason = (const u08bits *)"Invalid allocation"; + *reason = (const uint8_t *)"Invalid allocation"; } else { @@ -1511,22 +1511,22 @@ static int handle_turn_refresh(turn_turnserver *server, case STUN_ATTRIBUTE_MOBILITY_TICKET: { if(!(*(server->mobility))) { *err_code = 405; - *reason = (const u08bits *)"Mobility forbidden"; + *reason = (const uint8_t *)"Mobility forbidden"; } else { int smid_len = stun_attr_get_len(sar); if(smid_len>0 && (((size_t)smid_len)old_mobile_id)) { *err_code = 400; - *reason = (const u08bits *)"Mobility ticket cannot be used for a stable, already established allocation"; + *reason = (const uint8_t *)"Mobility ticket cannot be used for a stable, already established allocation"; } } } else { *err_code = 400; - *reason = (const u08bits *)"Mobility ticket has wrong length"; + *reason = (const uint8_t *)"Mobility ticket has wrong length"; } } } @@ -1534,14 +1534,14 @@ static int handle_turn_refresh(turn_turnserver *server, case STUN_ATTRIBUTE_LIFETIME: { if (stun_attr_get_len(sar) != 4) { *err_code = 400; - *reason = (const u08bits *)"Wrong Lifetime field format"; + *reason = (const uint8_t *)"Wrong Lifetime field format"; } else { - const u08bits* value = stun_attr_get_value(sar); + const uint8_t* value = stun_attr_get_value(sar); if (!value) { *err_code = 400; - *reason = (const u08bits *)"Wrong lifetime field data"; + *reason = (const uint8_t *)"Wrong lifetime field data"; } else { - lifetime = nswap32(*((const u32bits*)value)); + lifetime = nswap32(*((const uint32_t*)value)); if (!lifetime) to_delete = 1; } @@ -1574,7 +1574,7 @@ static int handle_turn_refresh(turn_turnserver *server, if(is_err) { *err_code = 443; - *reason = (const u08bits *)"Peer Address Family Mismatch (1)"; + *reason = (const uint8_t *)"Peer Address Family Mismatch (1)"; } } } @@ -1609,18 +1609,18 @@ static int handle_turn_refresh(turn_turnserver *server, if(server->send_socket_to_relay(tsid, mid, tid, new_s, message_integrity, RMT_MOBILE_SOCKET, in_buffer, can_resume)<0) { *err_code = 400; - *reason = (const u08bits *)"Wrong mobile ticket"; + *reason = (const uint8_t *)"Wrong mobile ticket"; } else { *no_response = 1; } } else { *err_code = 500; - *reason = (const u08bits *)"Cannot create new socket"; + *reason = (const uint8_t *)"Cannot create new socket"; return -1; } } else { *err_code = 500; - *reason = (const u08bits *)"Server send socket procedure is not set"; + *reason = (const uint8_t *)"Server send socket procedure is not set"; } ss->to_be_closed = 1; @@ -1630,19 +1630,19 @@ static int handle_turn_refresh(turn_turnserver *server, ts_ur_super_session *orig_ss = get_session_from_mobile_map(server, mid); if(!orig_ss || orig_ss->to_be_closed || ioa_socket_tobeclosed(orig_ss->client_socket)) { *err_code = 404; - *reason = (const u08bits *)"Allocation not found"; + *reason = (const uint8_t *)"Allocation not found"; } else if(orig_ss == ss) { *err_code = 437; - *reason = (const u08bits *)"Invalid allocation"; + *reason = (const uint8_t *)"Invalid allocation"; } else if(!(orig_ss->is_mobile)) { *err_code = 500; - *reason = (const u08bits *)"Software error: invalid mobile allocation"; + *reason = (const uint8_t *)"Software error: invalid mobile allocation"; } else if(orig_ss->client_socket == ss->client_socket) { *err_code = 500; - *reason = (const u08bits *)"Software error: invalid mobile client socket (orig)"; + *reason = (const uint8_t *)"Software error: invalid mobile client socket (orig)"; } else if(!(ss->client_socket)) { *err_code = 500; - *reason = (const u08bits *)"Software error: invalid mobile client socket (new)"; + *reason = (const uint8_t *)"Software error: invalid mobile client socket (new)"; } else { get_realm_options_by_name(orig_ss->realm_options.name, &(ss->realm_options)); @@ -1680,7 +1680,7 @@ static int handle_turn_refresh(turn_turnserver *server, if (!(*err_code)) { *err_code = 437; - *reason = (const u08bits *)"Cannot refresh relay connection (internal error)"; + *reason = (const uint8_t *)"Cannot refresh relay connection (internal error)"; } } else if (af6c && refresh_relay_connection(server, orig_ss, lifetime, 0, 0, 0, @@ -1688,7 +1688,7 @@ static int handle_turn_refresh(turn_turnserver *server, if (!(*err_code)) { *err_code = 437; - *reason = (const u08bits *)"Cannot refresh relay connection (internal error)"; + *reason = (const uint8_t *)"Cannot refresh relay connection (internal error)"; } } else { @@ -1731,19 +1731,19 @@ static int handle_turn_refresh(turn_turnserver *server, turn_report_allocation_set(&(ss->alloc), lifetime, 1); stun_init_success_response_str(STUN_METHOD_REFRESH, ioa_network_buffer_data(nbh), &len, tid); - u32bits lt = nswap32(lifetime); + uint32_t lt = nswap32(lifetime); stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_LIFETIME, - (const u08bits*) <, 4); + (const uint8_t*) <, 4); ioa_network_buffer_set_size(nbh,len); stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_MOBILITY_TICKET, - (u08bits*)ss->s_mobile_id,strlen(ss->s_mobile_id)); + (uint8_t*)ss->s_mobile_id,strlen(ss->s_mobile_id)); ioa_network_buffer_set_size(nbh,len); { - const u08bits *field = (const u08bits *) get_version(server); + const uint8_t *field = (const uint8_t *) get_version(server); size_t fsz = strlen(get_version(server)); size_t len = ioa_network_buffer_get_size(nbh); stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_SOFTWARE, field, fsz); @@ -1777,7 +1777,7 @@ static int handle_turn_refresh(turn_turnserver *server, } } else { *err_code = 437; - *reason = (const u08bits *)"Invalid allocation"; + *reason = (const uint8_t *)"Invalid allocation"; } } else { @@ -1798,7 +1798,7 @@ static int handle_turn_refresh(turn_turnserver *server, if (!(*err_code)) { *err_code = 437; - *reason = (const u08bits *)"Cannot refresh relay connection (internal error)"; + *reason = (const uint8_t *)"Cannot refresh relay connection (internal error)"; } } else if (af6 && refresh_relay_connection(server, ss, lifetime, 0, 0, 0, @@ -1806,7 +1806,7 @@ static int handle_turn_refresh(turn_turnserver *server, if (!(*err_code)) { *err_code = 437; - *reason = (const u08bits *)"Cannot refresh relay connection (internal error)"; + *reason = (const uint8_t *)"Cannot refresh relay connection (internal error)"; } } else { @@ -1819,13 +1819,13 @@ static int handle_turn_refresh(turn_turnserver *server, if(ss->s_mobile_id[0]) { stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_MOBILITY_TICKET, - (u08bits*)ss->s_mobile_id,strlen(ss->s_mobile_id)); + (uint8_t*)ss->s_mobile_id,strlen(ss->s_mobile_id)); ioa_network_buffer_set_size(nbh,len); } - u32bits lt = nswap32(lifetime); + uint32_t lt = nswap32(lifetime); stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_LIFETIME, - (const u08bits*) <, 4); + (const uint8_t*) <, 4); ioa_network_buffer_set_size(nbh,len); @@ -1863,7 +1863,7 @@ static void tcp_deliver_delayed_buffer(unsent_buffer *ub, ioa_socket_handle s, t if(!nbh) break; - u32bits bytes = (u32bits)ioa_network_buffer_get_size(nbh); + uint32_t bytes = (uint32_t)ioa_network_buffer_get_size(nbh); int ret = send_data_from_ioa_socket_nbh(s, NULL, nbh, TTL_IGNORE, TOS_IGNORE, NULL); if (ret < 0) { @@ -1902,7 +1902,7 @@ static void tcp_peer_input_handler(ioa_socket_handle s, int event_type, ioa_net_ ioa_network_buffer_handle nbh = in_buffer->nbh; in_buffer->nbh = NULL; - u32bits bytes = (u32bits)ioa_network_buffer_get_size(nbh); + uint32_t bytes = (uint32_t)ioa_network_buffer_get_size(nbh); int ret = send_data_from_ioa_socket_nbh(tc->client_s, NULL, nbh, TTL_IGNORE, TOS_IGNORE, NULL); if (ret < 0) { @@ -1939,7 +1939,7 @@ static void tcp_client_input_handler_rfc6062data(ioa_socket_handle s, int event_ in_buffer->nbh = NULL; if(ss) { - u32bits bytes = (u32bits)ioa_network_buffer_get_size(nbh); + uint32_t bytes = (uint32_t)ioa_network_buffer_get_size(nbh); ++(ss->received_packets); ss->received_bytes += bytes; } @@ -1987,7 +1987,7 @@ static void tcp_peer_connection_completed_callback(int success, void *arg) tc->state = TC_STATE_PEER_CONNECTED; stun_init_success_response_str(STUN_METHOD_CONNECT, ioa_network_buffer_data(nbh), &len, &(tc->tid)); stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_CONNECTION_ID, - (const u08bits*)&(tc->id), 4); + (const uint8_t*)&(tc->id), 4); IOA_EVENT_DEL(tc->conn_bind_timeout); tc->conn_bind_timeout = set_ioa_timer(server->e, TCP_CONN_BIND_TIMEOUT, 0, @@ -2004,8 +2004,8 @@ static void tcp_peer_connection_completed_callback(int success, void *arg) char rs[257]="\0"; ioa_addr *laddr = get_local_addr_from_ioa_socket(ss->client_socket); if(laddr) - addr_to_string(laddr,(u08bits*)ls); - addr_to_string(&(tc->peer_addr),(u08bits*)rs); + addr_to_string(laddr,(uint8_t*)ls); + addr_to_string(&(tc->peer_addr),(uint8_t*)rs); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s: failure to connect from %s to %s\n", __FUNCTION__, ls,rs); } stun_init_error_response_str(STUN_METHOD_CONNECT, ioa_network_buffer_data(nbh), &len, err_code, NULL, &(tc->tid)); @@ -2030,7 +2030,7 @@ static void tcp_peer_connection_completed_callback(int success, void *arg) for(i=0;i<22;i++) { ioa_network_buffer_handle nbh_test = ioa_network_buffer_allocate(server->e); size_t len_test = ioa_network_buffer_get_size(nbh_test); - u08bits *data = ioa_network_buffer_data(nbh_test); + uint8_t *data = ioa_network_buffer_data(nbh_test); const char* data_test="111.111.111.111.111"; len_test = strlen(data_test); bcopy(data_test,data,len_test); @@ -2050,27 +2050,27 @@ static void tcp_peer_conn_timeout_handler(ioa_engine_handle e, void *arg) static int tcp_start_connection_to_peer(turn_turnserver *server, ts_ur_super_session *ss, stun_tid *tid, allocation *a, ioa_addr *peer_addr, - int *err_code, const u08bits **reason) + int *err_code, const uint8_t **reason) { FUNCSTART; if(!ss) { *err_code = 500; - *reason = (const u08bits *)"Server error: empty session"; + *reason = (const uint8_t *)"Server error: empty session"; FUNCEND; return -1; } if(!peer_addr) { *err_code = 500; - *reason = (const u08bits *)"Server error: empty peer addr"; + *reason = (const uint8_t *)"Server error: empty peer addr"; FUNCEND; return -1; } if(!get_relay_socket(a,peer_addr->ss.sa_family)) { *err_code = 500; - *reason = (const u08bits *)"Server error: no relay connection created"; + *reason = (const uint8_t *)"Server error: no relay connection created"; FUNCEND; return -1; } @@ -2086,7 +2086,7 @@ static int tcp_start_connection_to_peer(turn_turnserver *server, ts_ur_super_ses if(!tc) { if(!(*err_code)) { *err_code = 500; - *reason = (const u08bits *)"Server error: TCP connection object creation failed"; + *reason = (const uint8_t *)"Server error: TCP connection object creation failed"; } FUNCEND; return -1; @@ -2106,7 +2106,7 @@ static int tcp_start_connection_to_peer(turn_turnserver *server, ts_ur_super_ses if(!tcs) { delete_tcp_connection(tc); *err_code = 500; - *reason = (const u08bits *)"Server error: TCP relay socket for connection cannot be created"; + *reason = (const uint8_t *)"Server error: TCP relay socket for connection cannot be created"; FUNCEND; return -1; } @@ -2154,7 +2154,7 @@ static void tcp_peer_accept_connection(ioa_socket_handle s, void *arg) } if(!good_peer_addr(server, ss->realm_options.name, peer_addr)) { - u08bits saddr[256]; + uint8_t saddr[256]; addr_to_string(peer_addr, saddr); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "%s: an attempt to connect from a peer with forbidden address: %s\n", __FUNCTION__,saddr); close_ioa_socket(s); @@ -2204,13 +2204,13 @@ static void tcp_peer_accept_connection(ioa_socket_handle s, void *arg) stun_init_indication_str(STUN_METHOD_CONNECTION_ATTEMPT, ioa_network_buffer_data(nbh), &len); stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_CONNECTION_ID, - (const u08bits*)&(tc->id), 4); + (const uint8_t*)&(tc->id), 4); stun_attr_add_addr_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_XOR_PEER_ADDRESS, peer_addr); ioa_network_buffer_set_size(nbh,len); { - const u08bits *field = (const u08bits *) get_version(server); + const uint8_t *field = (const uint8_t *) get_version(server); size_t fsz = strlen(get_version(server)); size_t len = ioa_network_buffer_get_size(nbh); stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_SOFTWARE, field, fsz); @@ -2231,7 +2231,7 @@ static void tcp_peer_accept_connection(ioa_socket_handle s, void *arg) static int handle_turn_connect(turn_turnserver *server, ts_ur_super_session *ss, stun_tid *tid, - int *err_code, const u08bits **reason, u16bits *unknown_attrs, u16bits *ua_num, + int *err_code, const uint8_t **reason, uint16_t *unknown_attrs, uint16_t *ua_num, ioa_net_data *in_buffer) { FUNCSTART; @@ -2242,7 +2242,7 @@ static int handle_turn_connect(turn_turnserver *server, if(!(ss->is_tcp_relay)) { *err_code = 403; - *reason = (const u08bits *)"Connect cannot be used with UDP relay"; + *reason = (const uint8_t *)"Connect cannot be used with UDP relay"; } else if (!is_allocation_valid(a)) { *err_code = 437; } else { @@ -2260,11 +2260,11 @@ static int handle_turn_connect(turn_turnserver *server, sar, &peer_addr, NULL) == -1) { *err_code = 400; - *reason = (const u08bits *)"Bad Peer Address"; + *reason = (const uint8_t *)"Bad Peer Address"; } else { if(!get_relay_socket(a,peer_addr.ss.sa_family)) { *err_code = 443; - *reason = (const u08bits *)"Peer Address Family Mismatch (2)"; + *reason = (const uint8_t *)"Peer Address Family Mismatch (2)"; } peer_found = 1; @@ -2291,12 +2291,12 @@ static int handle_turn_connect(turn_turnserver *server, } else if (!peer_found) { *err_code = 400; - *reason = (const u08bits *)"Where is Peer Address ?"; + *reason = (const uint8_t *)"Where is Peer Address ?"; } else { if(!good_peer_addr(server,ss->realm_options.name,&peer_addr)) { *err_code = 403; - *reason = (const u08bits *) "Forbidden IP"; + *reason = (const uint8_t *) "Forbidden IP"; } else { tcp_start_connection_to_peer(server, ss, tid, a, &peer_addr, err_code, reason); } @@ -2309,13 +2309,13 @@ static int handle_turn_connect(turn_turnserver *server, static int handle_turn_connection_bind(turn_turnserver *server, ts_ur_super_session *ss, stun_tid *tid, int *resp_constructed, - int *err_code, const u08bits **reason, u16bits *unknown_attrs, u16bits *ua_num, + int *err_code, const uint8_t **reason, uint16_t *unknown_attrs, uint16_t *ua_num, ioa_net_data *in_buffer, ioa_network_buffer_handle nbh, int message_integrity, int can_resume) { allocation* a = get_allocation_ss(ss); - u16bits method = STUN_METHOD_CONNECTION_BIND; + uint16_t method = STUN_METHOD_CONNECTION_BIND; if(ss->to_be_closed) { @@ -2324,12 +2324,12 @@ static int handle_turn_connection_bind(turn_turnserver *server, } else if (is_allocation_valid(a)) { *err_code = 400; - *reason = (const u08bits *)"Bad request: CONNECTION_BIND cannot be issued after allocation"; + *reason = (const uint8_t *)"Bad request: CONNECTION_BIND cannot be issued after allocation"; } else if(!is_stream_socket(get_ioa_socket_type(ss->client_socket))) { *err_code = 400; - *reason = (const u08bits *)"Bad request: CONNECTION_BIND only possible with TCP/TLS"; + *reason = (const uint8_t *)"Bad request: CONNECTION_BIND only possible with TCP/TLS"; } else { tcp_connection_id id = 0; @@ -2343,14 +2343,14 @@ static int handle_turn_connection_bind(turn_turnserver *server, case STUN_ATTRIBUTE_CONNECTION_ID: { if (stun_attr_get_len(sar) != 4) { *err_code = 400; - *reason = (const u08bits *)"Wrong Connection ID field format"; + *reason = (const uint8_t *)"Wrong Connection ID field format"; } else { - const u08bits* value = stun_attr_get_value(sar); + const uint8_t* value = stun_attr_get_value(sar); if (!value) { *err_code = 400; - *reason = (const u08bits *)"Wrong Connection ID field data"; + *reason = (const uint8_t *)"Wrong Connection ID field data"; } else { - id = *((const u32bits*)value); //AS-IS encoding, no conversion to/from network byte order + id = *((const uint32_t*)value); //AS-IS encoding, no conversion to/from network byte order } } } @@ -2380,7 +2380,7 @@ static int handle_turn_connection_bind(turn_turnserver *server, if(new_s) { if(server->send_socket_to_relay(sid, id, tid, new_s, message_integrity, RMT_CB_SOCKET, in_buffer, can_resume)<0) { *err_code = 400; - *reason = (const u08bits *)"Wrong connection id"; + *reason = (const uint8_t *)"Wrong connection id"; } } else { *err_code = 500; @@ -2422,7 +2422,7 @@ int turnserver_accept_tcp_client_data_connection(turn_turnserver *server, tcp_co ts_ur_super_session *ss = NULL; int err_code = 0; - const u08bits *reason = NULL; + const uint8_t *reason = NULL; ioa_socket_handle s_to_delete = s; @@ -2488,7 +2488,7 @@ int turnserver_accept_tcp_client_data_connection(turn_turnserver *server, tcp_co { size_t fsz = strlen(get_version(server)); - const u08bits *field = (const u08bits *) get_version(server); + const uint8_t *field = (const uint8_t *) get_version(server); size_t len = ioa_network_buffer_get_size(nbh); stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_SOFTWARE, field, fsz); ioa_network_buffer_set_size(nbh, len); @@ -2537,11 +2537,11 @@ int turnserver_accept_tcp_client_data_connection(turn_turnserver *server, tcp_co static int handle_turn_channel_bind(turn_turnserver *server, ts_ur_super_session *ss, stun_tid *tid, int *resp_constructed, - int *err_code, const u08bits **reason, u16bits *unknown_attrs, u16bits *ua_num, + int *err_code, const uint8_t **reason, uint16_t *unknown_attrs, uint16_t *ua_num, ioa_net_data *in_buffer, ioa_network_buffer_handle nbh) { FUNCSTART; - u16bits chnum = 0; + uint16_t chnum = 0; ioa_addr peer_addr; addr_set_any(&peer_addr); allocation* a = get_allocation_ss(ss); @@ -2549,7 +2549,7 @@ static int handle_turn_channel_bind(turn_turnserver *server, if(ss->is_tcp_relay) { *err_code = 403; - *reason = (const u08bits *)"Channel bind cannot be used with TCP relay"; + *reason = (const uint8_t *)"Channel bind cannot be used with TCP relay"; } else if (is_allocation_valid(a)) { stun_attr_ref sar = stun_attr_get_first_str(ioa_network_buffer_data(in_buffer->nbh), @@ -2562,13 +2562,13 @@ static int handle_turn_channel_bind(turn_turnserver *server, if (chnum) { chnum = 0; *err_code = 400; - *reason = (const u08bits *)"Channel number cannot be duplicated in this request"; + *reason = (const uint8_t *)"Channel number cannot be duplicated in this request"; break; } chnum = stun_attr_get_channel_number(sar); if (!chnum) { *err_code = 400; - *reason = (const u08bits *)"Channel number cannot be zero in this request"; + *reason = (const uint8_t *)"Channel number cannot be zero in this request"; break; } } @@ -2582,12 +2582,12 @@ static int handle_turn_channel_bind(turn_turnserver *server, if(!get_relay_socket(a,peer_addr.ss.sa_family)) { *err_code = 443; - *reason = (const u08bits *)"Peer Address Family Mismatch (3)"; + *reason = (const uint8_t *)"Peer Address Family Mismatch (3)"; } if(addr_get_port(&peer_addr) < 1) { *err_code = 400; - *reason = (const u08bits *)"Empty port number in channel bind request"; + *reason = (const uint8_t *)"Empty port number in channel bind request"; } else { addr_found = 1; } @@ -2614,12 +2614,12 @@ static int handle_turn_channel_bind(turn_turnserver *server, } else if (!chnum || addr_any(&peer_addr) || !addr_found) { *err_code = 400; - *reason = (const u08bits *)"Bad channel bind request"; + *reason = (const uint8_t *)"Bad channel bind request"; } else if(!STUN_VALID_CHANNEL(chnum)) { *err_code = 400; - *reason = (const u08bits *)"Bad channel number"; + *reason = (const uint8_t *)"Bad channel number"; } else { @@ -2629,19 +2629,19 @@ static int handle_turn_channel_bind(turn_turnserver *server, if (chn) { if (!addr_eq(&peer_addr, &(chn->peer_addr))) { *err_code = 400; - *reason = (const u08bits *)"You cannot use the same channel number with different peer"; + *reason = (const uint8_t *)"You cannot use the same channel number with different peer"; } else { tinfo = (turn_permission_info*) (chn->owner); if (!tinfo) { *err_code = 500; - *reason = (const u08bits *)"Wrong permission info"; + *reason = (const uint8_t *)"Wrong permission info"; } else { if (!addr_eq_no_port(&peer_addr, &(tinfo->addr))) { *err_code = 500; - *reason = (const u08bits *)"Wrong permission info and peer addr combination"; + *reason = (const uint8_t *)"Wrong permission info and peer addr combination"; } else if (chn->port != addr_get_port(&peer_addr)) { *err_code = 500; - *reason = (const u08bits *)"Wrong port number"; + *reason = (const uint8_t *)"Wrong port number"; } } } @@ -2651,22 +2651,22 @@ static int handle_turn_channel_bind(turn_turnserver *server, chn = allocation_get_ch_info_by_peer_addr(a, &peer_addr); if(chn) { *err_code = 400; - *reason = (const u08bits *)"You cannot use the same peer with different channel number"; + *reason = (const uint8_t *)"You cannot use the same peer with different channel number"; } else { if(!good_peer_addr(server,ss->realm_options.name,&peer_addr)) { *err_code = 403; - *reason = (const u08bits *) "Forbidden IP"; + *reason = (const uint8_t *) "Forbidden IP"; } else { chn = allocation_get_new_ch_info(a, chnum, &peer_addr); if (!chn) { *err_code = 500; - *reason = (const u08bits *) "Cannot find channel data"; + *reason = (const uint8_t *) "Cannot find channel data"; } else { tinfo = (turn_permission_info*) (chn->owner); if (!tinfo) { *err_code = 500; *reason - = (const u08bits *) "Wrong turn permission info"; + = (const uint8_t *) "Wrong turn permission info"; } } } @@ -2677,7 +2677,7 @@ static int handle_turn_channel_bind(turn_turnserver *server, if (update_channel_lifetime(ss,chn) < 0) { *err_code = 500; - *reason = (const u08bits *)"Cannot update channel lifetime (internal error)"; + *reason = (const uint8_t *)"Cannot update channel lifetime (internal error)"; } else { size_t len = ioa_network_buffer_get_size(nbh); stun_set_channel_bind_response_str(ioa_network_buffer_data(nbh), &len, tid, 0, NULL); @@ -2712,18 +2712,18 @@ static int handle_turn_channel_bind(turn_turnserver *server, static int handle_turn_binding(turn_turnserver *server, ts_ur_super_session *ss, stun_tid *tid, int *resp_constructed, - int *err_code, const u08bits **reason, u16bits *unknown_attrs, u16bits *ua_num, + int *err_code, const uint8_t **reason, uint16_t *unknown_attrs, uint16_t *ua_num, ioa_net_data *in_buffer, ioa_network_buffer_handle nbh, int *origin_changed, ioa_addr *response_origin, int *dest_changed, ioa_addr *response_destination, - u32bits cookie, int old_stun) { + uint32_t cookie, int old_stun) { FUNCSTART; int change_ip = 0; int change_port = 0; int padding = 0; int response_port_present = 0; - u16bits response_port = 0; + uint16_t response_port = 0; SOCKET_TYPE st = get_ioa_socket_type(ss->client_socket); int use_reflected_from = 0; @@ -2760,23 +2760,23 @@ static int handle_turn_binding(turn_turnserver *server, stun_attr_get_change_request_str(sar, &change_ip, &change_port); if( (!is_rfc5780(server)) && (change_ip || change_port)) { *err_code = 420; - *reason = (const u08bits *)"Unknown attribute: TURN server was configured without RFC 5780 support"; + *reason = (const uint8_t *)"Unknown attribute: TURN server was configured without RFC 5780 support"; break; } if(change_ip || change_port) { if(st != UDP_SOCKET) { *err_code = 400; - *reason = (const u08bits *)"Wrong request: applicable only to UDP protocol"; + *reason = (const uint8_t *)"Wrong request: applicable only to UDP protocol"; } } break; case STUN_ATTRIBUTE_PADDING: if(response_port_present) { *err_code = 400; - *reason = (const u08bits *)"Wrong request format: you cannot use PADDING and RESPONSE_PORT together"; + *reason = (const uint8_t *)"Wrong request format: you cannot use PADDING and RESPONSE_PORT together"; } else if((st != UDP_SOCKET) && (st != DTLS_SOCKET)) { *err_code = 400; - *reason = (const u08bits *)"Wrong request: padding applicable only to UDP and DTLS protocols"; + *reason = (const uint8_t *)"Wrong request: padding applicable only to UDP and DTLS protocols"; } else { padding = 1; } @@ -2784,18 +2784,18 @@ static int handle_turn_binding(turn_turnserver *server, case STUN_ATTRIBUTE_RESPONSE_PORT: if(padding) { *err_code = 400; - *reason = (const u08bits *)"Wrong request format: you cannot use PADDING and RESPONSE_PORT together"; + *reason = (const uint8_t *)"Wrong request format: you cannot use PADDING and RESPONSE_PORT together"; } else if(st != UDP_SOCKET) { *err_code = 400; - *reason = (const u08bits *)"Wrong request: applicable only to UDP protocol"; + *reason = (const uint8_t *)"Wrong request: applicable only to UDP protocol"; } else { int rp = stun_attr_get_response_port_str(sar); if(rp>=0) { response_port_present = 1; - response_port = (u16bits)rp; + response_port = (uint16_t)rp; } else { *err_code = 400; - *reason = (const u08bits *)"Wrong response port format"; + *reason = (const uint8_t *)"Wrong response port format"; } } break; @@ -2897,7 +2897,7 @@ static int handle_turn_binding(turn_turnserver *server, mtu=1500; mtu = (mtu >> 2) << 2; - stun_attr_add_padding_str(ioa_network_buffer_data(nbh), &len, (u16bits)mtu); + stun_attr_add_padding_str(ioa_network_buffer_data(nbh), &len, (uint16_t)mtu); } } } @@ -2910,13 +2910,13 @@ static int handle_turn_binding(turn_turnserver *server, } static int handle_turn_send(turn_turnserver *server, ts_ur_super_session *ss, - int *err_code, const u08bits **reason, u16bits *unknown_attrs, u16bits *ua_num, + int *err_code, const uint8_t **reason, uint16_t *unknown_attrs, uint16_t *ua_num, ioa_net_data *in_buffer) { FUNCSTART; ioa_addr peer_addr; - const u08bits* value = NULL; + const uint8_t* value = NULL; int len = -1; int addr_found = 0; int set_df = 0; @@ -2926,7 +2926,7 @@ static int handle_turn_send(turn_turnserver *server, ts_ur_super_session *ss, if(ss->is_tcp_relay) { *err_code = 403; - *reason = (const u08bits *)"Send cannot be used with TCP relay"; + *reason = (const uint8_t *)"Send cannot be used with TCP relay"; } else if (is_allocation_valid(a) && (in_buffer->recv_ttl != 0)) { stun_attr_ref sar = stun_attr_get_first_str(ioa_network_buffer_data(in_buffer->nbh), @@ -2944,7 +2944,7 @@ static int handle_turn_send(turn_turnserver *server, ts_ur_super_session *ss, case STUN_ATTRIBUTE_XOR_PEER_ADDRESS: { if (addr_found) { *err_code = 400; - *reason = (const u08bits *)"Address duplication"; + *reason = (const uint8_t *)"Address duplication"; } else { stun_attr_get_addr_str(ioa_network_buffer_data(in_buffer->nbh), ioa_network_buffer_get_size(in_buffer->nbh), @@ -2956,7 +2956,7 @@ static int handle_turn_send(turn_turnserver *server, ts_ur_super_session *ss, case STUN_ATTRIBUTE_DATA: { if (len >= 0) { *err_code = 400; - *reason = (const u08bits *)"Data duplication"; + *reason = (const uint8_t *)"Data duplication"; } else { len = stun_attr_get_len(sar); value = stun_attr_get_value(sar); @@ -2991,7 +2991,7 @@ static int handle_turn_send(turn_turnserver *server, ts_ur_super_session *ss, ioa_network_buffer_handle nbh = in_buffer->nbh; if(value && len>0) { - u16bits offset = (u16bits)(value - ioa_network_buffer_data(nbh)); + uint16_t offset = (uint16_t)(value - ioa_network_buffer_data(nbh)); ioa_network_buffer_add_offset_size(nbh,offset,0,len); } else { len = 0; @@ -3004,7 +3004,7 @@ static int handle_turn_send(turn_turnserver *server, ts_ur_super_session *ss, } else { *err_code = 400; - *reason = (const u08bits *)"No address found"; + *reason = (const uint8_t *)"No address found"; } } @@ -3042,7 +3042,7 @@ static int update_permission(ts_ur_super_session *ss, ioa_addr *peer_addr) { static int handle_turn_create_permission(turn_turnserver *server, ts_ur_super_session *ss, stun_tid *tid, int *resp_constructed, - int *err_code, const u08bits **reason, u16bits *unknown_attrs, u16bits *ua_num, + int *err_code, const uint8_t **reason, uint16_t *unknown_attrs, uint16_t *ua_num, ioa_net_data *in_buffer, ioa_network_buffer_handle nbh) { int ret = -1; @@ -3079,10 +3079,10 @@ static int handle_turn_create_permission(turn_turnserver *server, if(!get_relay_socket(a,peer_addr.ss.sa_family)) { *err_code = 443; - *reason = (const u08bits *)"Peer Address Family Mismatch (4)"; + *reason = (const uint8_t *)"Peer Address Family Mismatch (4)"; } else if(!good_peer_addr(server, ss->realm_options.name, &peer_addr)) { *err_code = 403; - *reason = (const u08bits *) "Forbidden IP"; + *reason = (const uint8_t *) "Forbidden IP"; } else { addr_found++; } @@ -3109,7 +3109,7 @@ static int handle_turn_create_permission(turn_turnserver *server, } else if (!addr_found) { *err_code = 400; - *reason = (const u08bits *)"No address found"; + *reason = (const uint8_t *)"No address found"; } else { @@ -3137,7 +3137,7 @@ static int handle_turn_create_permission(turn_turnserver *server, addr_set_port(&peer_addr, 0); if (update_permission(ss, &peer_addr) < 0) { *err_code = 500; - *reason = (const u08bits *)"Cannot update some permissions (critical server software error)"; + *reason = (const uint8_t *)"Cannot update some permissions (critical server software error)"; } } break; @@ -3184,9 +3184,9 @@ static int need_stun_authentication(turn_turnserver *server, ts_ur_super_session } static int create_challenge_response(ts_ur_super_session *ss, stun_tid *tid, int *resp_constructed, - int *err_code, const u08bits **reason, + int *err_code, const uint8_t **reason, ioa_network_buffer_handle nbh, - u16bits method) + uint16_t method) { size_t len = ioa_network_buffer_get_size(nbh); stun_init_error_response_str(method, ioa_network_buffer_data(nbh), &len, *err_code, *reason, tid); @@ -3195,7 +3195,7 @@ static int create_challenge_response(ts_ur_super_session *ss, stun_tid *tid, int ss->nonce, (int)(NONCE_MAX_SIZE-1)); char *realm = ss->realm_options.name; stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_REALM, - (u08bits*)realm, (int)(strlen((s08bits*)(realm)))); + (uint8_t*)realm, (int)(strlen((char*)(realm)))); if(ss->server) { turn_turnserver* server = (turn_turnserver*)ss->server; @@ -3206,7 +3206,7 @@ static int create_challenge_response(ts_ur_super_session *ss, stun_tid *tid, int } stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_THIRD_PARTY_AUTHORIZATION, - (const u08bits*)(server_name), + (const uint8_t*)(server_name), strlen(server_name)); } } @@ -3219,7 +3219,7 @@ static int create_challenge_response(ts_ur_super_session *ss, stun_tid *tid, int #define min(a,b) ((a)<=(b) ? (a) : (b)) #endif -static void resume_processing_after_username_check(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) +static void resume_processing_after_username_check(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) { if(server && in_buffer && in_buffer->nbh) { @@ -3253,15 +3253,15 @@ static void resume_processing_after_username_check(int success, int oauth, int static int check_stun_auth(turn_turnserver *server, ts_ur_super_session *ss, stun_tid *tid, int *resp_constructed, - int *err_code, const u08bits **reason, + int *err_code, const uint8_t **reason, ioa_net_data *in_buffer, ioa_network_buffer_handle nbh, - u16bits method, int *message_integrity, + uint16_t method, int *message_integrity, int *postpone_reply, int can_resume) { - u08bits usname[STUN_MAX_USERNAME_SIZE+1]; - u08bits nonce[STUN_MAX_NONCE_SIZE+1]; - u08bits realm[STUN_MAX_REALM_SIZE+1]; + uint8_t usname[STUN_MAX_USERNAME_SIZE+1]; + uint8_t nonce[STUN_MAX_NONCE_SIZE+1]; + uint8_t realm[STUN_MAX_REALM_SIZE+1]; size_t alen = 0; if(!need_stun_authentication(server, ss)) @@ -3288,15 +3288,15 @@ static int check_stun_auth(turn_turnserver *server, if(TURN_RANDOM_SIZE == 8) { for(i=0;i<(NONCE_LENGTH_32BITS>>1);i++) { - u08bits *s = ss->nonce + 8*i; - u64bits rand=(u64bits)turn_random(); - snprintf((s08bits*)s, NONCE_MAX_SIZE-8*i, "%08lx",(unsigned long)rand); + uint8_t *s = ss->nonce + 8*i; + uint64_t rand=(uint64_t)turn_random(); + snprintf((char*)s, NONCE_MAX_SIZE-8*i, "%08lx",(unsigned long)rand); } } else { for(i=0;inonce + 4*i; - u32bits rand=(u32bits)turn_random(); - snprintf((s08bits*)s, NONCE_MAX_SIZE-4*i, "%04x",(unsigned int)rand); + uint8_t *s = ss->nonce + 4*i; + uint32_t rand=(uint32_t)turn_random(); + snprintf((char*)s, NONCE_MAX_SIZE-4*i, "%04x",(unsigned int)rand); } } ss->nonce_expiration_time = server->ctime + *(server->stale_nonce); @@ -3361,10 +3361,10 @@ static int check_stun_auth(turn_turnserver *server, if(!(ss->oauth)){ if(method == STUN_METHOD_ALLOCATE) { *err_code = 437; - *reason = (const u08bits*)"Allocation mismatch: wrong credentials: the realm value is incorrect"; + *reason = (const uint8_t*)"Allocation mismatch: wrong credentials: the realm value is incorrect"; } else { *err_code = 441; - *reason = (const u08bits*)"Wrong credentials: the realm value is incorrect"; + *reason = (const uint8_t*)"Wrong credentials: the realm value is incorrect"; } return -1; } else { @@ -3401,7 +3401,7 @@ static int check_stun_auth(turn_turnserver *server, } else { if(method == STUN_METHOD_ALLOCATE) { *err_code = 437; - *reason = (const u08bits*)"Allocation mismatch: wrong credentials"; + *reason = (const uint8_t*)"Allocation mismatch: wrong credentials"; } else { *err_code = 441; } @@ -3432,13 +3432,13 @@ static int check_stun_auth(turn_turnserver *server, if(new_nonce) { *err_code = 438; - *reason = (const u08bits*)"Wrong nonce"; + *reason = (const uint8_t*)"Wrong nonce"; return create_challenge_response(ss,tid,resp_constructed,err_code,reason,nbh,method); } - if(strcmp((s08bits*)ss->nonce,(s08bits*)nonce)) { + if(strcmp((char*)ss->nonce,(char*)nonce)) { *err_code = 438; - *reason = (const u08bits*)"Stale nonce"; + *reason = (const uint8_t*)"Stale nonce"; return create_challenge_response(ss,tid,resp_constructed,err_code,reason,nbh,method); } } @@ -3487,7 +3487,7 @@ static int check_stun_auth(turn_turnserver *server, //<<== AUTH -static void set_alternate_server(turn_server_addrs_list_t *asl, const ioa_addr *local_addr, size_t *counter, u16bits method, stun_tid *tid, int *resp_constructed, int *err_code, const u08bits **reason, ioa_network_buffer_handle nbh) +static void set_alternate_server(turn_server_addrs_list_t *asl, const ioa_addr *local_addr, size_t *counter, uint16_t method, stun_tid *tid, int *resp_constructed, int *err_code, const uint8_t **reason, ioa_network_buffer_handle nbh) { if(asl && asl->size && local_addr) { @@ -3527,16 +3527,16 @@ static int handle_turn_command(turn_turnserver *server, ts_ur_super_session *ss, stun_tid tid; int err_code = 0; - const u08bits *reason = NULL; + const uint8_t *reason = NULL; int no_response = 0; int message_integrity = 0; if(!(ss->client_socket)) return -1; - u16bits unknown_attrs[MAX_NUMBER_OF_UNKNOWN_ATTRS]; - u16bits ua_num = 0; - u16bits method = stun_get_method_str(ioa_network_buffer_data(in_buffer->nbh), + uint16_t unknown_attrs[MAX_NUMBER_OF_UNKNOWN_ATTRS]; + uint16_t ua_num = 0; + uint16_t method = stun_get_method_str(ioa_network_buffer_data(in_buffer->nbh), ioa_network_buffer_get_size(in_buffer->nbh)); *resp_constructed = 0; @@ -3574,7 +3574,7 @@ static int handle_turn_command(turn_turnserver *server, ts_ur_super_session *ss, if(is_allocation_valid(a)) { if(!stun_tid_equals(&(a->tid), &tid)) { err_code = 437; - reason = (const u08bits *)"Mismatched allocation: wrong transaction ID"; + reason = (const uint8_t *)"Mismatched allocation: wrong transaction ID"; } } @@ -3636,7 +3636,7 @@ static int handle_turn_command(turn_turnserver *server, ts_ur_super_session *ss, if(ss->origin[0]) { if(!origin_found) { err_code = 441; - reason = (const u08bits *)"The origin attribute does not match the initial session origin value"; + reason = (const uint8_t *)"The origin attribute does not match the initial session origin value"; if(server->verbose) { char smethod[129]; stun_method_str(method,smethod); @@ -3645,7 +3645,7 @@ static int handle_turn_command(turn_turnserver *server, ts_ur_super_session *ss, } } else if(norigins > 0){ err_code = 441; - reason = (const u08bits *)"The origin attribute is empty, does not match the initial session origin value"; + reason = (const uint8_t *)"The origin attribute is empty, does not match the initial session origin value"; if(server->verbose) { char smethod[129]; stun_method_str(method,smethod); @@ -3800,7 +3800,7 @@ static int handle_turn_command(turn_turnserver *server, ts_ur_super_session *ss, } { - const u08bits *field = (const u08bits *) get_version(server); + const uint8_t *field = (const uint8_t *) get_version(server); size_t fsz = strlen(get_version(server)); size_t len = ioa_network_buffer_get_size(nbh); stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_SOFTWARE, field, fsz); @@ -3879,7 +3879,7 @@ static int handle_turn_command(turn_turnserver *server, ts_ur_super_session *ss, size_t len = ioa_network_buffer_get_size(nbh); stun_init_error_response_str(method, ioa_network_buffer_data(nbh), &len, err_code, NULL, &tid); - stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_UNKNOWN_ATTRIBUTES, (const u08bits*) unknown_attrs, (ua_num + stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_UNKNOWN_ATTRIBUTES, (const uint8_t*) unknown_attrs, (ua_num * 2)); ioa_network_buffer_set_size(nbh,len); @@ -3901,7 +3901,7 @@ static int handle_turn_command(turn_turnserver *server, ts_ur_super_session *ss, } { - const u08bits *field = (const u08bits *) get_version(server); + const uint8_t *field = (const uint8_t *) get_version(server); size_t fsz = strlen(get_version(server)); size_t len = ioa_network_buffer_get_size(nbh); stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_SOFTWARE, field, fsz); @@ -3927,17 +3927,17 @@ static int handle_turn_command(turn_turnserver *server, ts_ur_super_session *ss, return 0; } -static int handle_old_stun_command(turn_turnserver *server, ts_ur_super_session *ss, ioa_net_data *in_buffer, ioa_network_buffer_handle nbh, int *resp_constructed, u32bits cookie) +static int handle_old_stun_command(turn_turnserver *server, ts_ur_super_session *ss, ioa_net_data *in_buffer, ioa_network_buffer_handle nbh, int *resp_constructed, uint32_t cookie) { stun_tid tid; int err_code = 0; - const u08bits *reason = NULL; + const uint8_t *reason = NULL; int no_response = 0; - u16bits unknown_attrs[MAX_NUMBER_OF_UNKNOWN_ATTRS]; - u16bits ua_num = 0; - u16bits method = stun_get_method_str(ioa_network_buffer_data(in_buffer->nbh), + uint16_t unknown_attrs[MAX_NUMBER_OF_UNKNOWN_ATTRS]; + uint16_t ua_num = 0; + uint16_t method = stun_get_method_str(ioa_network_buffer_data(in_buffer->nbh), ioa_network_buffer_get_size(in_buffer->nbh)); *resp_constructed = 0; @@ -3984,7 +3984,7 @@ static int handle_old_stun_command(turn_turnserver *server, ts_ur_super_session { size_t oldsz = strlen(get_version(server)); size_t newsz = (((oldsz)>>2) + 1)<<2; - u08bits software[120]; + uint8_t software[120]; bzero(software,sizeof(software)); if(newsz>sizeof(software)) newsz = sizeof(software); @@ -4015,7 +4015,7 @@ static int handle_old_stun_command(turn_turnserver *server, ts_ur_super_session size_t len = ioa_network_buffer_get_size(nbh); old_stun_init_error_response_str(method, ioa_network_buffer_data(nbh), &len, err_code, NULL, &tid, cookie); - stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_UNKNOWN_ATTRIBUTES, (const u08bits*) unknown_attrs, (ua_num * 2)); + stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_UNKNOWN_ATTRIBUTES, (const uint8_t*) unknown_attrs, (ua_num * 2)); ioa_network_buffer_set_size(nbh,len); @@ -4038,7 +4038,7 @@ static int handle_old_stun_command(turn_turnserver *server, ts_ur_super_session { size_t oldsz = strlen(get_version(server)); size_t newsz = (((oldsz)>>2) + 1)<<2; - u08bits software[120]; + uint8_t software[120]; bzero(software,sizeof(software)); if(newsz>sizeof(software)) newsz = sizeof(software); @@ -4063,7 +4063,7 @@ static int handle_old_stun_command(turn_turnserver *server, ts_ur_super_session ////////////////////////////////////////////////////////////////// -static int write_to_peerchannel(ts_ur_super_session* ss, u16bits chnum, ioa_net_data *in_buffer) { +static int write_to_peerchannel(ts_ur_super_session* ss, uint16_t chnum, ioa_net_data *in_buffer) { int rc = 0; @@ -4124,8 +4124,8 @@ int shutdown_client_connection(turn_turnserver *server, ts_ur_super_session *ss, char sraddr[129]="\0"; char sladdr[129]="\0"; - addr_to_string(get_remote_addr_from_ioa_socket(ss->client_socket),(u08bits*)sraddr); - addr_to_string(get_local_addr_from_ioa_socket(ss->client_socket),(u08bits*)sladdr); + addr_to_string(get_remote_addr_from_ioa_socket(ss->client_socket),(uint8_t*)sraddr); + addr_to_string(get_local_addr_from_ioa_socket(ss->client_socket),(uint8_t*)sladdr); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "session %018llu: closed (1st stage), user <%s> realm <%s> origin <%s>, local %s, remote %s, reason: %s\n",(unsigned long long)(ss->id),(char*)ss->username,(char*)ss->realm_options.name,(char*)ss->origin, sladdr,sraddr,reason); } @@ -4152,8 +4152,8 @@ int shutdown_client_connection(turn_turnserver *server, ts_ur_super_session *ss, char sraddr[129]="\0"; char sladdr[129]="\0"; - addr_to_string(get_remote_addr_from_ioa_socket(ss->client_socket),(u08bits*)sraddr); - addr_to_string(get_local_addr_from_ioa_socket(ss->client_socket),(u08bits*)sladdr); + addr_to_string(get_remote_addr_from_ioa_socket(ss->client_socket),(uint8_t*)sraddr); + addr_to_string(get_local_addr_from_ioa_socket(ss->client_socket),(uint8_t*)sladdr); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "session %018llu: closed (2nd stage), user <%s> realm <%s> origin <%s>, local %s, remote %s, reason: %s\n", (unsigned long long)(ss->id), (char*)ss->username,(char*)ss->realm_options.name,(char*)ss->origin, sladdr,sraddr, reason); @@ -4243,7 +4243,7 @@ static int write_client_connection(turn_turnserver *server, ts_ur_super_session* if(!skip) { ++(ss->sent_packets); - ss->sent_bytes += (u32bits)ioa_network_buffer_get_size(nbh); + ss->sent_bytes += (uint32_t)ioa_network_buffer_get_size(nbh); turn_report_session_usage(ss, 0); } @@ -4292,10 +4292,10 @@ static void client_ss_allocation_timeout_handler(ioa_engine_handle e, void *arg) } static int create_relay_connection(turn_turnserver* server, - ts_ur_super_session *ss, u32bits lifetime, - int address_family, u08bits transport, - int even_port, u64bits in_reservation_token, u64bits *out_reservation_token, - int *err_code, const u08bits **reason, + ts_ur_super_session *ss, uint32_t lifetime, + int address_family, uint8_t transport, + int even_port, uint64_t in_reservation_token, uint64_t *out_reservation_token, + int *err_code, const uint8_t **reason, accept_cb acb) { if (server && ss && ss->client_socket && !ioa_socket_tobeclosed(ss->client_socket)) { @@ -4314,7 +4314,7 @@ static int create_relay_connection(turn_turnserver* server, IOA_CLOSE_SOCKET(s); *err_code = 404; - *reason = (const u08bits *)"Cannot find reserved socket"; + *reason = (const uint8_t *)"Cannot find reserved socket"; return -1; } @@ -4352,7 +4352,7 @@ static int create_relay_connection(turn_turnserver* server, if(!(*err_code)) *err_code = 508; if(!(*reason)) - *reason = (const u08bits *)"Cannot create socket"; + *reason = (const uint8_t *)"Cannot create socket"; IOA_CLOSE_SOCKET(newelem->s); IOA_CLOSE_SOCKET(rtcp_s); return -1; @@ -4362,7 +4362,7 @@ static int create_relay_connection(turn_turnserver* server, if (newelem->s == NULL) { IOA_CLOSE_SOCKET(rtcp_s); *err_code = 508; - *reason = (const u08bits *)"Cannot create relay socket"; + *reason = (const uint8_t *)"Cannot create relay socket"; return -1; } @@ -4373,7 +4373,7 @@ static int create_relay_connection(turn_turnserver* server, IOA_CLOSE_SOCKET(newelem->s); IOA_CLOSE_SOCKET(rtcp_s); *err_code = 500; - *reason = (const u08bits *)"Wrong reservation tokens (internal error)"; + *reason = (const uint8_t *)"Wrong reservation tokens (internal error)"; return -1; } } @@ -4391,8 +4391,8 @@ static int create_relay_connection(turn_turnserver* server, if (lifetime<1) lifetime = STUN_DEFAULT_ALLOCATE_LIFETIME; - else if(lifetime>(u32bits)*(server->max_allocate_lifetime)) - lifetime = (u32bits)*(server->max_allocate_lifetime); + else if(lifetime>(uint32_t)*(server->max_allocate_lifetime)) + lifetime = (uint32_t)*(server->max_allocate_lifetime); ioa_timer_handle ev = set_ioa_timer(server->e, lifetime, 0, client_ss_allocation_timeout_handler, newelem, 0, @@ -4406,8 +4406,8 @@ static int create_relay_connection(turn_turnserver* server, } static int refresh_relay_connection(turn_turnserver* server, - ts_ur_super_session *ss, u32bits lifetime, int even_port, - u64bits in_reservation_token, u64bits *out_reservation_token, + ts_ur_super_session *ss, uint32_t lifetime, int even_port, + uint64_t in_reservation_token, uint64_t *out_reservation_token, int *err_code, int family) { UNUSED_ARG(even_port); @@ -4455,7 +4455,7 @@ static int read_client_connection(turn_turnserver *server, if(count_usage) { ++(ss->received_packets); - ss->received_bytes += (u32bits)ioa_network_buffer_get_size(in_buffer->nbh); + ss->received_bytes += (uint32_t)ioa_network_buffer_get_size(in_buffer->nbh); turn_report_session_usage(ss, 0); } @@ -4466,8 +4466,8 @@ static int read_client_connection(turn_turnserver *server, (long)ioa_network_buffer_get_size(in_buffer->nbh)); } - u16bits chnum = 0; - u32bits old_stun_cookie = 0; + uint16_t chnum = 0; + uint32_t old_stun_cookie = 0; size_t blen = ioa_network_buffer_get_size(in_buffer->nbh); size_t orig_blen = blen; @@ -4518,7 +4518,7 @@ static int read_client_connection(turn_turnserver *server, ioa_network_buffer_handle nbh = ioa_network_buffer_allocate(server->e); int resp_constructed = 0; - u16bits method = stun_get_method_str(ioa_network_buffer_data(in_buffer->nbh), + uint16_t method = stun_get_method_str(ioa_network_buffer_data(in_buffer->nbh), ioa_network_buffer_get_size(in_buffer->nbh)); handle_turn_command(server, ss, in_buffer, nbh, &resp_constructed, can_resume); @@ -4722,7 +4722,7 @@ static void peer_input_handler(ioa_socket_handle s, int event_type, allocation* a = get_allocation_ss(ss); if (is_allocation_valid(a)) { - u16bits chnum = 0; + uint16_t chnum = 0; ioa_network_buffer_handle nbh = NULL; @@ -4772,7 +4772,7 @@ static void peer_input_handler(ioa_socket_handle s, int event_type, ioa_network_buffer_set_size(nbh,len); { - const u08bits *field = (const u08bits *) get_version(server); + const uint8_t *field = (const uint8_t *) get_version(server); size_t fsz = strlen(get_version(server)); size_t len = ioa_network_buffer_get_size(nbh); stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_SOFTWARE, field, fsz); @@ -4786,7 +4786,7 @@ static void peer_input_handler(ioa_socket_handle s, int event_type, } } if (eve(server->verbose)) { - u16bits* t = (u16bits*) ioa_network_buffer_data(nbh); + uint16_t* t = (uint16_t*) ioa_network_buffer_data(nbh); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Send data: 0x%x\n", (int) (nswap16(t[0]))); } diff --git a/src/server/ns_turn_server.h b/src/server/ns_turn_server.h index 60d352e4..628457f3 100644 --- a/src/server/ns_turn_server.h +++ b/src/server/ns_turn_server.h @@ -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_STUN_ONLY; -typedef u08bits turnserver_id; +typedef uint8_t turnserver_id; enum _MESSAGE_TO_RELAY_TYPE { RMT_UNKNOWN = 0, @@ -90,11 +90,11 @@ typedef enum { struct _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 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 int (*check_new_allocation_quota_cb)(u08bits *username, int oauth, u08bits *realm); -typedef void (*release_allocation_quota_cb)(u08bits *username, int oauth, u08bits *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 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 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)(uint8_t *username, int oauth, uint8_t *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, 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 void (*send_https_socket_cb)(ioa_socket_handle s); diff --git a/src/server/ns_turn_session.h b/src/server/ns_turn_session.h index a3f4542e..c131c727 100644 --- a/src/server/ns_turn_session.h +++ b/src/server/ns_turn_session.h @@ -52,18 +52,18 @@ typedef struct _perf_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; }; //////////////// session info ////////////////////// -typedef u64bits turnsession_id; +typedef uint64_t turnsession_id; #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 { void* server; @@ -76,9 +76,9 @@ struct _ts_ur_super_session { int is_tcp_relay; int to_be_closed; /* Auth */ - u08bits nonce[NONCE_MAX_SIZE]; + uint8_t nonce[NONCE_MAX_SIZE]; turn_time_t nonce_expiration_time; - u08bits username[STUN_MAX_USERNAME_SIZE+1]; + uint8_t username[STUN_MAX_USERNAME_SIZE+1]; hmackey_t hmackey; int hmackey_set; password_t pwd; @@ -88,17 +88,17 @@ struct _ts_ur_super_session { /* Realm */ realm_options_t realm_options; int origin_set; - s08bits origin[STUN_MAX_ORIGIN_SIZE + 1]; + char origin[STUN_MAX_ORIGIN_SIZE + 1]; /* Stats */ - u32bits received_packets; - u32bits sent_packets; - u32bits received_bytes; - u32bits sent_bytes; - u64bits t_received_packets; - u64bits t_sent_packets; - u64bits t_received_bytes; - u64bits t_sent_bytes; - u64bits received_rate; + uint32_t received_packets; + uint32_t sent_packets; + uint32_t received_bytes; + uint32_t sent_bytes; + uint64_t t_received_packets; + uint64_t t_sent_packets; + uint64_t t_received_bytes; + uint64_t t_sent_bytes; + uint64_t received_rate; size_t sent_rate; size_t total_rate; /* Mobile */ @@ -133,16 +133,16 @@ struct turn_session_info { addr_data remote_addr_data; addr_data relay_addr_data_ipv4; addr_data relay_addr_data_ipv6; - u08bits username[STUN_MAX_USERNAME_SIZE+1]; + uint8_t username[STUN_MAX_USERNAME_SIZE+1]; int enforce_fingerprints; /* Stats */ - u64bits received_packets; - u64bits sent_packets; - u64bits received_bytes; - u64bits sent_bytes; - u32bits received_rate; - u32bits sent_rate; - u32bits total_rate; + uint64_t received_packets; + uint64_t sent_packets; + uint64_t received_bytes; + uint64_t sent_bytes; + uint32_t received_rate; + uint32_t sent_rate; + uint32_t total_rate; /* Mobile */ int is_mobile; /* Peers */