|
|
@ -328,15 +328,15 @@ static int clnet_allocate(int verbose, |
|
|
|
app_ur_conn_info *clnet_info, |
|
|
|
app_ur_conn_info *clnet_info, |
|
|
|
ioa_addr *relay_addr, |
|
|
|
ioa_addr *relay_addr, |
|
|
|
int af, |
|
|
|
int af, |
|
|
|
char *turn_addr, u16bits *turn_port, |
|
|
|
char *turn_addr, u16bits *turn_port) { |
|
|
|
stun_tid *in_tid, |
|
|
|
|
|
|
|
stun_tid *out_tid) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int af_cycle = 0; |
|
|
|
int af_cycle = 0; |
|
|
|
int reopen_socket = 0; |
|
|
|
int reopen_socket = 0; |
|
|
|
|
|
|
|
|
|
|
|
int allocate_finished; |
|
|
|
int allocate_finished; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stun_buffer request_message, response_message; |
|
|
|
|
|
|
|
|
|
|
|
beg_allocate: |
|
|
|
beg_allocate: |
|
|
|
|
|
|
|
|
|
|
|
allocate_finished=0; |
|
|
|
allocate_finished=0; |
|
|
@ -355,15 +355,14 @@ static int clnet_allocate(int verbose, |
|
|
|
reopen_socket = 0; |
|
|
|
reopen_socket = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
stun_buffer message; |
|
|
|
if(current_reservation_token) { |
|
|
|
if(!in_tid && current_reservation_token) { |
|
|
|
|
|
|
|
af = STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_DEFAULT; |
|
|
|
af = STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_DEFAULT; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int af4 = dual_allocation || (af == STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4); |
|
|
|
int af4 = dual_allocation || (af == STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4); |
|
|
|
int af6 = dual_allocation || (af == STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6); |
|
|
|
int af6 = dual_allocation || (af == STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6); |
|
|
|
|
|
|
|
|
|
|
|
if(!no_rtcp && !in_tid) { |
|
|
|
if(!no_rtcp) { |
|
|
|
if (!never_allocate_rtcp && allocate_rtcp) { |
|
|
|
if (!never_allocate_rtcp && allocate_rtcp) { |
|
|
|
af4 = 0; |
|
|
|
af4 = 0; |
|
|
|
af6 = 0; |
|
|
|
af6 = 0; |
|
|
@ -371,42 +370,34 @@ static int clnet_allocate(int verbose, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!dos) |
|
|
|
if(!dos) |
|
|
|
stun_set_allocate_request(&message, UCLIENT_SESSION_LIFETIME, af4, af6, relay_transport, mobility); |
|
|
|
stun_set_allocate_request(&request_message, UCLIENT_SESSION_LIFETIME, af4, af6, relay_transport, mobility); |
|
|
|
else |
|
|
|
else |
|
|
|
stun_set_allocate_request(&message, UCLIENT_SESSION_LIFETIME/3, af4, af6, relay_transport, mobility); |
|
|
|
stun_set_allocate_request(&request_message, UCLIENT_SESSION_LIFETIME/3, af4, af6, relay_transport, mobility); |
|
|
|
|
|
|
|
|
|
|
|
if(bps) |
|
|
|
if(bps) |
|
|
|
stun_attr_add_bandwidth_str(message.buf, (size_t*)(&(message.len)), bps); |
|
|
|
stun_attr_add_bandwidth_str(request_message.buf, (size_t*)(&(request_message.len)), bps); |
|
|
|
|
|
|
|
|
|
|
|
if(in_tid) { |
|
|
|
|
|
|
|
stun_tid_message_cpy(message.buf, in_tid); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(dont_fragment) |
|
|
|
if(dont_fragment) |
|
|
|
stun_attr_add(&message, STUN_ATTRIBUTE_DONT_FRAGMENT, NULL, 0); |
|
|
|
stun_attr_add(&request_message, STUN_ATTRIBUTE_DONT_FRAGMENT, NULL, 0); |
|
|
|
if(!no_rtcp && !in_tid) { |
|
|
|
if(!no_rtcp) { |
|
|
|
if (!never_allocate_rtcp && allocate_rtcp) { |
|
|
|
if (!never_allocate_rtcp && allocate_rtcp) { |
|
|
|
uint64_t reservation_token = ioa_ntoh64(current_reservation_token); |
|
|
|
uint64_t reservation_token = ioa_ntoh64(current_reservation_token); |
|
|
|
stun_attr_add(&message, STUN_ATTRIBUTE_RESERVATION_TOKEN, |
|
|
|
stun_attr_add(&request_message, STUN_ATTRIBUTE_RESERVATION_TOKEN, |
|
|
|
(char*) (&reservation_token), 8); |
|
|
|
(char*) (&reservation_token), 8); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
stun_attr_add_even_port(&message, 1); |
|
|
|
stun_attr_add_even_port(&request_message, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
add_origin(&message); |
|
|
|
add_origin(&request_message); |
|
|
|
|
|
|
|
|
|
|
|
if(add_integrity(clnet_info, &message)<0) return -1; |
|
|
|
if(add_integrity(clnet_info, &request_message)<0) return -1; |
|
|
|
|
|
|
|
|
|
|
|
stun_attr_add_fingerprint_str(message.buf,(size_t*)&(message.len)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(out_tid) { |
|
|
|
stun_attr_add_fingerprint_str(request_message.buf,(size_t*)&(request_message.len)); |
|
|
|
stun_tid_from_message_str(message.buf, (size_t)message.len, out_tid); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (!allocate_sent) { |
|
|
|
while (!allocate_sent) { |
|
|
|
|
|
|
|
|
|
|
|
int len = send_buffer(clnet_info, &message,0,0); |
|
|
|
int len = send_buffer(clnet_info, &request_message,0,0); |
|
|
|
|
|
|
|
|
|
|
|
if (len > 0) { |
|
|
|
if (len > 0) { |
|
|
|
if (verbose) { |
|
|
|
if (verbose) { |
|
|
@ -426,25 +417,24 @@ static int clnet_allocate(int verbose, |
|
|
|
////////allocate response==>>
|
|
|
|
////////allocate response==>>
|
|
|
|
{ |
|
|
|
{ |
|
|
|
int allocate_received = 0; |
|
|
|
int allocate_received = 0; |
|
|
|
stun_buffer message; |
|
|
|
|
|
|
|
while (!allocate_received) { |
|
|
|
while (!allocate_received) { |
|
|
|
|
|
|
|
|
|
|
|
int len = recv_buffer(clnet_info, &message, 1, 0); |
|
|
|
int len = recv_buffer(clnet_info, &response_message, 1, NULL, &request_message); |
|
|
|
|
|
|
|
|
|
|
|
if (len > 0) { |
|
|
|
if (len > 0) { |
|
|
|
if (verbose) { |
|
|
|
if (verbose) { |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, |
|
|
|
"allocate response received: \n"); |
|
|
|
"allocate response received: \n"); |
|
|
|
} |
|
|
|
} |
|
|
|
message.len = len; |
|
|
|
response_message.len = len; |
|
|
|
int err_code = 0; |
|
|
|
int err_code = 0; |
|
|
|
u08bits err_msg[129]; |
|
|
|
u08bits err_msg[129]; |
|
|
|
if (stun_is_success_response(&message)) { |
|
|
|
if (stun_is_success_response(&response_message)) { |
|
|
|
allocate_received = 1; |
|
|
|
allocate_received = 1; |
|
|
|
allocate_finished = 1; |
|
|
|
allocate_finished = 1; |
|
|
|
|
|
|
|
|
|
|
|
if(clnet_info->nonce[0] || use_short_term) { |
|
|
|
if(clnet_info->nonce[0] || use_short_term) { |
|
|
|
if(check_integrity(clnet_info, &message)<0) |
|
|
|
if(check_integrity(clnet_info, &response_message)<0) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -454,13 +444,13 @@ static int clnet_allocate(int verbose, |
|
|
|
{ |
|
|
|
{ |
|
|
|
int found = 0; |
|
|
|
int found = 0; |
|
|
|
|
|
|
|
|
|
|
|
stun_attr_ref sar = stun_attr_get_first(&message); |
|
|
|
stun_attr_ref sar = stun_attr_get_first(&response_message); |
|
|
|
while (sar) { |
|
|
|
while (sar) { |
|
|
|
|
|
|
|
|
|
|
|
int attr_type = stun_attr_get_type(sar); |
|
|
|
int attr_type = stun_attr_get_type(sar); |
|
|
|
if(attr_type == STUN_ATTRIBUTE_XOR_RELAYED_ADDRESS) { |
|
|
|
if(attr_type == STUN_ATTRIBUTE_XOR_RELAYED_ADDRESS) { |
|
|
|
|
|
|
|
|
|
|
|
if (stun_attr_get_addr(&message, sar, relay_addr, NULL) < 0) { |
|
|
|
if (stun_attr_get_addr(&response_message, sar, relay_addr, NULL) < 0) { |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, |
|
|
|
"%s: !!!: relay addr cannot be received (1)\n", |
|
|
|
"%s: !!!: relay addr cannot be received (1)\n", |
|
|
|
__FUNCTION__); |
|
|
|
__FUNCTION__); |
|
|
@ -491,7 +481,7 @@ static int clnet_allocate(int verbose, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sar = stun_attr_get_next(&message,sar); |
|
|
|
sar = stun_attr_get_next(&response_message,sar); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!found) { |
|
|
|
if(!found) { |
|
|
@ -503,16 +493,16 @@ static int clnet_allocate(int verbose, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
stun_attr_ref rt_sar = stun_attr_get_first_by_type( |
|
|
|
stun_attr_ref rt_sar = stun_attr_get_first_by_type( |
|
|
|
&message, STUN_ATTRIBUTE_RESERVATION_TOKEN); |
|
|
|
&response_message, STUN_ATTRIBUTE_RESERVATION_TOKEN); |
|
|
|
uint64_t rtv = stun_attr_get_reservation_token_value(rt_sar); |
|
|
|
uint64_t rtv = stun_attr_get_reservation_token_value(rt_sar); |
|
|
|
current_reservation_token = rtv; |
|
|
|
current_reservation_token = rtv; |
|
|
|
if (verbose) |
|
|
|
if (verbose) |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, |
|
|
|
"%s: rtv=%llu\n", __FUNCTION__, (long long unsigned int)rtv); |
|
|
|
"%s: rtv=%llu\n", __FUNCTION__, (long long unsigned int)rtv); |
|
|
|
|
|
|
|
|
|
|
|
read_mobility_ticket(clnet_info, &message); |
|
|
|
read_mobility_ticket(clnet_info, &response_message); |
|
|
|
|
|
|
|
|
|
|
|
} else if (stun_is_challenge_response_str(message.buf, (size_t)message.len, |
|
|
|
} else if (stun_is_challenge_response_str(response_message.buf, (size_t)response_message.len, |
|
|
|
&err_code,err_msg,sizeof(err_msg), |
|
|
|
&err_code,err_msg,sizeof(err_msg), |
|
|
|
clnet_info->realm,clnet_info->nonce, |
|
|
|
clnet_info->realm,clnet_info->nonce, |
|
|
|
clnet_info->server_name, &(clnet_info->oauth))) { |
|
|
|
clnet_info->server_name, &(clnet_info->oauth))) { |
|
|
@ -521,7 +511,7 @@ static int clnet_allocate(int verbose, |
|
|
|
recalculate_restapi_hmac(); |
|
|
|
recalculate_restapi_hmac(); |
|
|
|
} |
|
|
|
} |
|
|
|
goto beg_allocate; |
|
|
|
goto beg_allocate; |
|
|
|
} else if (stun_is_error_response(&message, &err_code,err_msg,sizeof(err_msg))) { |
|
|
|
} else if (stun_is_error_response(&response_message, &err_code,err_msg,sizeof(err_msg))) { |
|
|
|
|
|
|
|
|
|
|
|
if(err_code == SHA_TOO_WEAK_ERROR_CODE && (clnet_info->shatype == SHATYPE_SHA1) && use_short_term) { |
|
|
|
if(err_code == SHA_TOO_WEAK_ERROR_CODE && (clnet_info->shatype == SHATYPE_SHA1) && use_short_term) { |
|
|
|
clnet_info->shatype = SHATYPE_SHA256; |
|
|
|
clnet_info->shatype = SHATYPE_SHA256; |
|
|
@ -533,12 +523,12 @@ static int clnet_allocate(int verbose, |
|
|
|
if(err_code == 300) { |
|
|
|
if(err_code == 300) { |
|
|
|
|
|
|
|
|
|
|
|
if(clnet_info->nonce[0] || use_short_term) { |
|
|
|
if(clnet_info->nonce[0] || use_short_term) { |
|
|
|
if(check_integrity(clnet_info, &message)<0) |
|
|
|
if(check_integrity(clnet_info, &response_message)<0) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ioa_addr alternate_server; |
|
|
|
ioa_addr alternate_server; |
|
|
|
if(stun_attr_get_first_addr(&message, STUN_ATTRIBUTE_ALTERNATE_SERVER, &alternate_server, NULL)==-1) { |
|
|
|
if(stun_attr_get_first_addr(&response_message, STUN_ATTRIBUTE_ALTERNATE_SERVER, &alternate_server, NULL)==-1) { |
|
|
|
//error
|
|
|
|
//error
|
|
|
|
} else if(turn_addr && turn_port){ |
|
|
|
} else if(turn_addr && turn_port){ |
|
|
|
addr_to_string_no_port(&alternate_server, (u08bits*)turn_addr); |
|
|
|
addr_to_string_no_port(&alternate_server, (u08bits*)turn_addr); |
|
|
@ -582,9 +572,7 @@ static int clnet_allocate(int verbose, |
|
|
|
exit(-1); |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!in_tid) { |
|
|
|
allocate_rtcp = !allocate_rtcp; |
|
|
|
allocate_rtcp = !allocate_rtcp; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (1) { |
|
|
|
if (1) { |
|
|
|
|
|
|
|
|
|
|
@ -643,24 +631,23 @@ static int clnet_allocate(int verbose, |
|
|
|
{ |
|
|
|
{ |
|
|
|
int refresh_sent = 0; |
|
|
|
int refresh_sent = 0; |
|
|
|
|
|
|
|
|
|
|
|
stun_buffer message; |
|
|
|
stun_init_request(STUN_METHOD_REFRESH, &request_message); |
|
|
|
stun_init_request(STUN_METHOD_REFRESH, &message); |
|
|
|
|
|
|
|
uint32_t lt = htonl(UCLIENT_SESSION_LIFETIME); |
|
|
|
uint32_t lt = htonl(UCLIENT_SESSION_LIFETIME); |
|
|
|
stun_attr_add(&message, STUN_ATTRIBUTE_LIFETIME, (const char*) <, 4); |
|
|
|
stun_attr_add(&request_message, STUN_ATTRIBUTE_LIFETIME, (const char*) <, 4); |
|
|
|
|
|
|
|
|
|
|
|
if(clnet_info->s_mobile_id[0]) { |
|
|
|
if(clnet_info->s_mobile_id[0]) { |
|
|
|
stun_attr_add(&message, STUN_ATTRIBUTE_MOBILITY_TICKET, (const char*)clnet_info->s_mobile_id, strlen(clnet_info->s_mobile_id)); |
|
|
|
stun_attr_add(&request_message, STUN_ATTRIBUTE_MOBILITY_TICKET, (const char*)clnet_info->s_mobile_id, strlen(clnet_info->s_mobile_id)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
add_origin(&message); |
|
|
|
add_origin(&request_message); |
|
|
|
|
|
|
|
|
|
|
|
if(add_integrity(clnet_info, &message)<0) return -1; |
|
|
|
if(add_integrity(clnet_info, &request_message)<0) return -1; |
|
|
|
|
|
|
|
|
|
|
|
stun_attr_add_fingerprint_str(message.buf,(size_t*)&(message.len)); |
|
|
|
stun_attr_add_fingerprint_str(request_message.buf,(size_t*)&(request_message.len)); |
|
|
|
|
|
|
|
|
|
|
|
while (!refresh_sent) { |
|
|
|
while (!refresh_sent) { |
|
|
|
|
|
|
|
|
|
|
|
int len = send_buffer(clnet_info, &message, 0,0); |
|
|
|
int len = send_buffer(clnet_info, &request_message, 0,0); |
|
|
|
|
|
|
|
|
|
|
|
if (len > 0) { |
|
|
|
if (len > 0) { |
|
|
|
if (verbose) { |
|
|
|
if (verbose) { |
|
|
@ -670,7 +657,7 @@ static int clnet_allocate(int verbose, |
|
|
|
|
|
|
|
|
|
|
|
if(clnet_info->s_mobile_id[0]) { |
|
|
|
if(clnet_info->s_mobile_id[0]) { |
|
|
|
usleep(10000); |
|
|
|
usleep(10000); |
|
|
|
send_buffer(clnet_info, &message, 0,0); |
|
|
|
send_buffer(clnet_info, &request_message, 0,0); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
perror("send"); |
|
|
|
perror("send"); |
|
|
@ -684,13 +671,12 @@ static int clnet_allocate(int verbose, |
|
|
|
////////refresh response==>>
|
|
|
|
////////refresh response==>>
|
|
|
|
{ |
|
|
|
{ |
|
|
|
int refresh_received = 0; |
|
|
|
int refresh_received = 0; |
|
|
|
stun_buffer message; |
|
|
|
|
|
|
|
while (!refresh_received) { |
|
|
|
while (!refresh_received) { |
|
|
|
|
|
|
|
|
|
|
|
int len = recv_buffer(clnet_info, &message, 1, 0); |
|
|
|
int len = recv_buffer(clnet_info, &response_message, 1, 0, &request_message); |
|
|
|
|
|
|
|
|
|
|
|
if(clnet_info->s_mobile_id[0]) { |
|
|
|
if(clnet_info->s_mobile_id[0]) { |
|
|
|
len = recv_buffer(clnet_info, &message, 1, 0); |
|
|
|
len = recv_buffer(clnet_info, &response_message, 1, 0, &request_message); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (len > 0) { |
|
|
|
if (len > 0) { |
|
|
@ -698,16 +684,16 @@ static int clnet_allocate(int verbose, |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, |
|
|
|
"refresh response received: \n"); |
|
|
|
"refresh response received: \n"); |
|
|
|
} |
|
|
|
} |
|
|
|
message.len = len; |
|
|
|
response_message.len = len; |
|
|
|
int err_code = 0; |
|
|
|
int err_code = 0; |
|
|
|
u08bits err_msg[129]; |
|
|
|
u08bits err_msg[129]; |
|
|
|
if (stun_is_success_response(&message)) { |
|
|
|
if (stun_is_success_response(&response_message)) { |
|
|
|
read_mobility_ticket(clnet_info, &message); |
|
|
|
read_mobility_ticket(clnet_info, &response_message); |
|
|
|
refresh_received = 1; |
|
|
|
refresh_received = 1; |
|
|
|
if (verbose) { |
|
|
|
if (verbose) { |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "success\n"); |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "success\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (stun_is_challenge_response_str(message.buf, (size_t)message.len, |
|
|
|
} else if (stun_is_challenge_response_str(response_message.buf, (size_t)response_message.len, |
|
|
|
&err_code,err_msg,sizeof(err_msg), |
|
|
|
&err_code,err_msg,sizeof(err_msg), |
|
|
|
clnet_info->realm,clnet_info->nonce, |
|
|
|
clnet_info->realm,clnet_info->nonce, |
|
|
|
clnet_info->server_name, &(clnet_info->oauth))) { |
|
|
|
clnet_info->server_name, &(clnet_info->oauth))) { |
|
|
@ -716,7 +702,7 @@ static int clnet_allocate(int verbose, |
|
|
|
recalculate_restapi_hmac(); |
|
|
|
recalculate_restapi_hmac(); |
|
|
|
} |
|
|
|
} |
|
|
|
goto beg_refresh; |
|
|
|
goto beg_refresh; |
|
|
|
} else if (stun_is_error_response(&message, &err_code,err_msg,sizeof(err_msg))) { |
|
|
|
} else if (stun_is_error_response(&response_message, &err_code,err_msg,sizeof(err_msg))) { |
|
|
|
refresh_received = 1; |
|
|
|
refresh_received = 1; |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "error %d (%s)\n", |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "error %d (%s)\n", |
|
|
|
err_code,(char*)err_msg); |
|
|
|
err_code,(char*)err_msg); |
|
|
@ -740,28 +726,28 @@ static int clnet_allocate(int verbose, |
|
|
|
static int turn_channel_bind(int verbose, uint16_t *chn, |
|
|
|
static int turn_channel_bind(int verbose, uint16_t *chn, |
|
|
|
app_ur_conn_info *clnet_info, ioa_addr *peer_addr) { |
|
|
|
app_ur_conn_info *clnet_info, ioa_addr *peer_addr) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stun_buffer request_message, response_message; |
|
|
|
|
|
|
|
|
|
|
|
beg_bind: |
|
|
|
beg_bind: |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
int cb_sent = 0; |
|
|
|
int cb_sent = 0; |
|
|
|
|
|
|
|
|
|
|
|
stun_buffer message; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(negative_test) { |
|
|
|
if(negative_test) { |
|
|
|
*chn = stun_set_channel_bind_request(&message, peer_addr, (u16bits)random()); |
|
|
|
*chn = stun_set_channel_bind_request(&request_message, peer_addr, (u16bits)random()); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
*chn = stun_set_channel_bind_request(&message, peer_addr, *chn); |
|
|
|
*chn = stun_set_channel_bind_request(&request_message, peer_addr, *chn); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
add_origin(&message); |
|
|
|
add_origin(&request_message); |
|
|
|
|
|
|
|
|
|
|
|
if(add_integrity(clnet_info, &message)<0) return -1; |
|
|
|
if(add_integrity(clnet_info, &request_message)<0) return -1; |
|
|
|
|
|
|
|
|
|
|
|
stun_attr_add_fingerprint_str(message.buf,(size_t*)&(message.len)); |
|
|
|
stun_attr_add_fingerprint_str(request_message.buf,(size_t*)&(request_message.len)); |
|
|
|
|
|
|
|
|
|
|
|
while (!cb_sent) { |
|
|
|
while (!cb_sent) { |
|
|
|
|
|
|
|
|
|
|
|
int len = send_buffer(clnet_info, &message, 0,0); |
|
|
|
int len = send_buffer(clnet_info, &request_message, 0,0); |
|
|
|
if (len > 0) { |
|
|
|
if (len > 0) { |
|
|
|
if (verbose) { |
|
|
|
if (verbose) { |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "channel bind sent\n"); |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "channel bind sent\n"); |
|
|
@ -782,10 +768,9 @@ static int turn_channel_bind(int verbose, uint16_t *chn, |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
int cb_received = 0; |
|
|
|
int cb_received = 0; |
|
|
|
stun_buffer message; |
|
|
|
|
|
|
|
while (!cb_received) { |
|
|
|
while (!cb_received) { |
|
|
|
|
|
|
|
|
|
|
|
int len = recv_buffer(clnet_info, &message, 1, 0); |
|
|
|
int len = recv_buffer(clnet_info, &response_message, 1, NULL, &request_message); |
|
|
|
if (len > 0) { |
|
|
|
if (len > 0) { |
|
|
|
if (verbose) { |
|
|
|
if (verbose) { |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, |
|
|
@ -793,12 +778,12 @@ static int turn_channel_bind(int verbose, uint16_t *chn, |
|
|
|
} |
|
|
|
} |
|
|
|
int err_code = 0; |
|
|
|
int err_code = 0; |
|
|
|
u08bits err_msg[129]; |
|
|
|
u08bits err_msg[129]; |
|
|
|
if (stun_is_success_response(&message)) { |
|
|
|
if (stun_is_success_response(&response_message)) { |
|
|
|
|
|
|
|
|
|
|
|
cb_received = 1; |
|
|
|
cb_received = 1; |
|
|
|
|
|
|
|
|
|
|
|
if(clnet_info->nonce[0] || use_short_term) { |
|
|
|
if(clnet_info->nonce[0] || use_short_term) { |
|
|
|
if(check_integrity(clnet_info, &message)<0) |
|
|
|
if(check_integrity(clnet_info, &response_message)<0) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -806,7 +791,7 @@ static int turn_channel_bind(int verbose, uint16_t *chn, |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "success: 0x%x\n", |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "success: 0x%x\n", |
|
|
|
(int) (*chn)); |
|
|
|
(int) (*chn)); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (stun_is_challenge_response_str(message.buf, (size_t)message.len, |
|
|
|
} else if (stun_is_challenge_response_str(response_message.buf, (size_t)response_message.len, |
|
|
|
&err_code,err_msg,sizeof(err_msg), |
|
|
|
&err_code,err_msg,sizeof(err_msg), |
|
|
|
clnet_info->realm,clnet_info->nonce, |
|
|
|
clnet_info->realm,clnet_info->nonce, |
|
|
|
clnet_info->server_name, &(clnet_info->oauth))) { |
|
|
|
clnet_info->server_name, &(clnet_info->oauth))) { |
|
|
@ -815,7 +800,7 @@ static int turn_channel_bind(int verbose, uint16_t *chn, |
|
|
|
recalculate_restapi_hmac(); |
|
|
|
recalculate_restapi_hmac(); |
|
|
|
} |
|
|
|
} |
|
|
|
goto beg_bind; |
|
|
|
goto beg_bind; |
|
|
|
} else if (stun_is_error_response(&message, &err_code,err_msg,sizeof(err_msg))) { |
|
|
|
} else if (stun_is_error_response(&response_message, &err_code,err_msg,sizeof(err_msg))) { |
|
|
|
cb_received = 1; |
|
|
|
cb_received = 1; |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "channel bind: error %d (%s)\n", |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "channel bind: error %d (%s)\n", |
|
|
|
err_code,(char*)err_msg); |
|
|
|
err_code,(char*)err_msg); |
|
|
@ -847,30 +832,30 @@ static int turn_create_permission(int verbose, app_ur_conn_info *clnet_info, |
|
|
|
addr_to_string(peer_addr,(u08bits*)saddr); |
|
|
|
addr_to_string(peer_addr,(u08bits*)saddr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stun_buffer request_message, response_message; |
|
|
|
|
|
|
|
|
|
|
|
beg_cp: |
|
|
|
beg_cp: |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
int cp_sent = 0; |
|
|
|
int cp_sent = 0; |
|
|
|
|
|
|
|
|
|
|
|
stun_buffer message; |
|
|
|
stun_init_request(STUN_METHOD_CREATE_PERMISSION, &request_message); |
|
|
|
|
|
|
|
|
|
|
|
stun_init_request(STUN_METHOD_CREATE_PERMISSION, &message); |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
int addrindex; |
|
|
|
int addrindex; |
|
|
|
for(addrindex=0;addrindex<addrnum;++addrindex) { |
|
|
|
for(addrindex=0;addrindex<addrnum;++addrindex) { |
|
|
|
stun_attr_add_addr(&message, STUN_ATTRIBUTE_XOR_PEER_ADDRESS, peer_addr+addrindex); |
|
|
|
stun_attr_add_addr(&request_message, STUN_ATTRIBUTE_XOR_PEER_ADDRESS, peer_addr+addrindex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
add_origin(&message); |
|
|
|
add_origin(&request_message); |
|
|
|
|
|
|
|
|
|
|
|
if(add_integrity(clnet_info, &message)<0) return -1; |
|
|
|
if(add_integrity(clnet_info, &request_message)<0) return -1; |
|
|
|
|
|
|
|
|
|
|
|
stun_attr_add_fingerprint_str(message.buf,(size_t*)&(message.len)); |
|
|
|
stun_attr_add_fingerprint_str(request_message.buf,(size_t*)&(request_message.len)); |
|
|
|
|
|
|
|
|
|
|
|
while (!cp_sent) { |
|
|
|
while (!cp_sent) { |
|
|
|
|
|
|
|
|
|
|
|
int len = send_buffer(clnet_info, &message, 0,0); |
|
|
|
int len = send_buffer(clnet_info, &request_message, 0,0); |
|
|
|
|
|
|
|
|
|
|
|
if (len > 0) { |
|
|
|
if (len > 0) { |
|
|
|
if (verbose) { |
|
|
|
if (verbose) { |
|
|
@ -892,10 +877,9 @@ static int turn_create_permission(int verbose, app_ur_conn_info *clnet_info, |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
int cp_received = 0; |
|
|
|
int cp_received = 0; |
|
|
|
stun_buffer message; |
|
|
|
|
|
|
|
while (!cp_received) { |
|
|
|
while (!cp_received) { |
|
|
|
|
|
|
|
|
|
|
|
int len = recv_buffer(clnet_info, &message, 1, 0); |
|
|
|
int len = recv_buffer(clnet_info, &response_message, 1, NULL, &request_message); |
|
|
|
if (len > 0) { |
|
|
|
if (len > 0) { |
|
|
|
if (verbose) { |
|
|
|
if (verbose) { |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, |
|
|
@ -903,19 +887,19 @@ static int turn_create_permission(int verbose, app_ur_conn_info *clnet_info, |
|
|
|
} |
|
|
|
} |
|
|
|
int err_code = 0; |
|
|
|
int err_code = 0; |
|
|
|
u08bits err_msg[129]; |
|
|
|
u08bits err_msg[129]; |
|
|
|
if (stun_is_success_response(&message)) { |
|
|
|
if (stun_is_success_response(&response_message)) { |
|
|
|
|
|
|
|
|
|
|
|
cp_received = 1; |
|
|
|
cp_received = 1; |
|
|
|
|
|
|
|
|
|
|
|
if(clnet_info->nonce[0] || use_short_term) { |
|
|
|
if(clnet_info->nonce[0] || use_short_term) { |
|
|
|
if(check_integrity(clnet_info, &message)<0) |
|
|
|
if(check_integrity(clnet_info, &response_message)<0) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (verbose) { |
|
|
|
if (verbose) { |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "success\n"); |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "success\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (stun_is_challenge_response_str(message.buf, (size_t)message.len, |
|
|
|
} else if (stun_is_challenge_response_str(response_message.buf, (size_t)response_message.len, |
|
|
|
&err_code,err_msg,sizeof(err_msg), |
|
|
|
&err_code,err_msg,sizeof(err_msg), |
|
|
|
clnet_info->realm,clnet_info->nonce, |
|
|
|
clnet_info->realm,clnet_info->nonce, |
|
|
|
clnet_info->server_name, &(clnet_info->oauth))) { |
|
|
|
clnet_info->server_name, &(clnet_info->oauth))) { |
|
|
@ -924,7 +908,7 @@ static int turn_create_permission(int verbose, app_ur_conn_info *clnet_info, |
|
|
|
recalculate_restapi_hmac(); |
|
|
|
recalculate_restapi_hmac(); |
|
|
|
} |
|
|
|
} |
|
|
|
goto beg_cp; |
|
|
|
goto beg_cp; |
|
|
|
} else if (stun_is_error_response(&message, &err_code,err_msg,sizeof(err_msg))) { |
|
|
|
} else if (stun_is_error_response(&response_message, &err_code,err_msg,sizeof(err_msg))) { |
|
|
|
cp_received = 1; |
|
|
|
cp_received = 1; |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "create permission error %d (%s)\n", |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "create permission error %d (%s)\n", |
|
|
|
err_code,(char*)err_msg); |
|
|
|
err_code,(char*)err_msg); |
|
|
@ -971,9 +955,7 @@ int start_connection(uint16_t clnet_remote_port0, |
|
|
|
char remote_address[1025]; |
|
|
|
char remote_address[1025]; |
|
|
|
STRCPY(remote_address,remote_address0); |
|
|
|
STRCPY(remote_address,remote_address0); |
|
|
|
|
|
|
|
|
|
|
|
stun_tid tid; |
|
|
|
clnet_allocate(verbose, clnet_info_probe, &relay_addr, default_address_family, remote_address, &clnet_remote_port); |
|
|
|
|
|
|
|
|
|
|
|
clnet_allocate(verbose, clnet_info_probe, &relay_addr, default_address_family, remote_address, &clnet_remote_port,NULL,NULL); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Real: */ |
|
|
|
/* Real: */ |
|
|
|
|
|
|
|
|
|
|
@ -993,20 +975,15 @@ int start_connection(uint16_t clnet_remote_port0, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int af = default_address_family ? default_address_family : get_allocate_address_family(&peer_addr); |
|
|
|
int af = default_address_family ? default_address_family : get_allocate_address_family(&peer_addr); |
|
|
|
if (clnet_allocate(verbose, clnet_info, &relay_addr, af, NULL,NULL,NULL,&tid) < 0) { |
|
|
|
if (clnet_allocate(verbose, clnet_info, &relay_addr, af, NULL,NULL) < 0) { |
|
|
|
exit(-1); |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//strcpy((char*)g_uname,"qqq");
|
|
|
|
|
|
|
|
//if (clnet_allocate(verbose, clnet_info, &relay_addr, af, NULL,NULL,&tid,NULL) < 0) {
|
|
|
|
|
|
|
|
// exit(-1);
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(rare_event()) return 0; |
|
|
|
if(rare_event()) return 0; |
|
|
|
|
|
|
|
|
|
|
|
if(!no_rtcp) { |
|
|
|
if(!no_rtcp) { |
|
|
|
af = default_address_family ? default_address_family : get_allocate_address_family(&peer_addr_rtcp); |
|
|
|
af = default_address_family ? default_address_family : get_allocate_address_family(&peer_addr_rtcp); |
|
|
|
if (clnet_allocate(verbose, clnet_info_rtcp, &relay_addr_rtcp, af,NULL,NULL,NULL,NULL) < 0) { |
|
|
|
if (clnet_allocate(verbose, clnet_info_rtcp, &relay_addr_rtcp, af,NULL,NULL) < 0) { |
|
|
|
exit(-1); |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
} |
|
|
|
if(rare_event()) return 0; |
|
|
|
if(rare_event()) return 0; |
|
|
@ -1193,7 +1170,7 @@ int start_c2c_connection(uint16_t clnet_remote_port0, |
|
|
|
char remote_address[1025]; |
|
|
|
char remote_address[1025]; |
|
|
|
STRCPY(remote_address,remote_address0); |
|
|
|
STRCPY(remote_address,remote_address0); |
|
|
|
|
|
|
|
|
|
|
|
clnet_allocate(verbose, clnet_info_probe, &relay_addr1, default_address_family, remote_address, &clnet_remote_port,NULL,NULL); |
|
|
|
clnet_allocate(verbose, clnet_info_probe, &relay_addr1, default_address_family, remote_address, &clnet_remote_port); |
|
|
|
|
|
|
|
|
|
|
|
if(rare_event()) return 0; |
|
|
|
if(rare_event()) return 0; |
|
|
|
|
|
|
|
|
|
|
@ -1226,7 +1203,7 @@ int start_c2c_connection(uint16_t clnet_remote_port0, |
|
|
|
|
|
|
|
|
|
|
|
if(!no_rtcp) { |
|
|
|
if(!no_rtcp) { |
|
|
|
|
|
|
|
|
|
|
|
if (clnet_allocate(verbose, clnet_info1, &relay_addr1, default_address_family,NULL,NULL,NULL,NULL) |
|
|
|
if (clnet_allocate(verbose, clnet_info1, &relay_addr1, default_address_family,NULL,NULL) |
|
|
|
< 0) { |
|
|
|
< 0) { |
|
|
|
exit(-1); |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
} |
|
|
@ -1234,13 +1211,13 @@ int start_c2c_connection(uint16_t clnet_remote_port0, |
|
|
|
if(rare_event()) return 0; |
|
|
|
if(rare_event()) return 0; |
|
|
|
|
|
|
|
|
|
|
|
if (clnet_allocate(verbose, clnet_info1_rtcp, |
|
|
|
if (clnet_allocate(verbose, clnet_info1_rtcp, |
|
|
|
&relay_addr1_rtcp, default_address_family,NULL,NULL,NULL,NULL) < 0) { |
|
|
|
&relay_addr1_rtcp, default_address_family,NULL,NULL) < 0) { |
|
|
|
exit(-1); |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(rare_event()) return 0; |
|
|
|
if(rare_event()) return 0; |
|
|
|
|
|
|
|
|
|
|
|
if (clnet_allocate(verbose, clnet_info2, &relay_addr2, default_address_family,NULL,NULL,NULL,NULL) |
|
|
|
if (clnet_allocate(verbose, clnet_info2, &relay_addr2, default_address_family,NULL,NULL) |
|
|
|
< 0) { |
|
|
|
< 0) { |
|
|
|
exit(-1); |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
} |
|
|
@ -1248,20 +1225,20 @@ int start_c2c_connection(uint16_t clnet_remote_port0, |
|
|
|
if(rare_event()) return 0; |
|
|
|
if(rare_event()) return 0; |
|
|
|
|
|
|
|
|
|
|
|
if (clnet_allocate(verbose, clnet_info2_rtcp, |
|
|
|
if (clnet_allocate(verbose, clnet_info2_rtcp, |
|
|
|
&relay_addr2_rtcp, default_address_family,NULL,NULL,NULL,NULL) < 0) { |
|
|
|
&relay_addr2_rtcp, default_address_family,NULL,NULL) < 0) { |
|
|
|
exit(-1); |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(rare_event()) return 0; |
|
|
|
if(rare_event()) return 0; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
if (clnet_allocate(verbose, clnet_info1, &relay_addr1, default_address_family,NULL,NULL,NULL,NULL) |
|
|
|
if (clnet_allocate(verbose, clnet_info1, &relay_addr1, default_address_family,NULL,NULL) |
|
|
|
< 0) { |
|
|
|
< 0) { |
|
|
|
exit(-1); |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
} |
|
|
|
if(rare_event()) return 0; |
|
|
|
if(rare_event()) return 0; |
|
|
|
if(!(clnet_info2->is_peer)) { |
|
|
|
if(!(clnet_info2->is_peer)) { |
|
|
|
if (clnet_allocate(verbose, clnet_info2, &relay_addr2, default_address_family,NULL,NULL,NULL,NULL) < 0) { |
|
|
|
if (clnet_allocate(verbose, clnet_info2, &relay_addr2, default_address_family,NULL,NULL) < 0) { |
|
|
|
exit(-1); |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
} |
|
|
|
if(rare_event()) return 0; |
|
|
|
if(rare_event()) return 0; |
|
|
@ -1432,27 +1409,28 @@ int turn_tcp_connect(int verbose, app_ur_conn_info *clnet_info, ioa_addr *peer_a |
|
|
|
|
|
|
|
|
|
|
|
static int turn_tcp_connection_bind(int verbose, app_ur_conn_info *clnet_info, app_tcp_conn_info *atc, int errorOK) { |
|
|
|
static int turn_tcp_connection_bind(int verbose, app_ur_conn_info *clnet_info, app_tcp_conn_info *atc, int errorOK) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stun_buffer request_message, response_message; |
|
|
|
|
|
|
|
|
|
|
|
beg_cb: |
|
|
|
beg_cb: |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
int cb_sent = 0; |
|
|
|
int cb_sent = 0; |
|
|
|
|
|
|
|
|
|
|
|
stun_buffer message; |
|
|
|
|
|
|
|
u32bits cid = atc->cid; |
|
|
|
u32bits cid = atc->cid; |
|
|
|
|
|
|
|
|
|
|
|
stun_init_request(STUN_METHOD_CONNECTION_BIND, &message); |
|
|
|
stun_init_request(STUN_METHOD_CONNECTION_BIND, &request_message); |
|
|
|
|
|
|
|
|
|
|
|
stun_attr_add(&message, STUN_ATTRIBUTE_CONNECTION_ID, (const s08bits*)&cid,4); |
|
|
|
stun_attr_add(&request_message, STUN_ATTRIBUTE_CONNECTION_ID, (const s08bits*)&cid,4); |
|
|
|
|
|
|
|
|
|
|
|
add_origin(&message); |
|
|
|
add_origin(&request_message); |
|
|
|
|
|
|
|
|
|
|
|
if(add_integrity(clnet_info, &message)<0) return -1; |
|
|
|
if(add_integrity(clnet_info, &request_message)<0) return -1; |
|
|
|
|
|
|
|
|
|
|
|
stun_attr_add_fingerprint_str(message.buf,(size_t*)&(message.len)); |
|
|
|
stun_attr_add_fingerprint_str(request_message.buf,(size_t*)&(request_message.len)); |
|
|
|
|
|
|
|
|
|
|
|
while (!cb_sent) { |
|
|
|
while (!cb_sent) { |
|
|
|
|
|
|
|
|
|
|
|
int len = send_buffer(clnet_info, &message, 1, atc); |
|
|
|
int len = send_buffer(clnet_info, &request_message, 1, atc); |
|
|
|
|
|
|
|
|
|
|
|
if (len > 0) { |
|
|
|
if (len > 0) { |
|
|
|
if (verbose) { |
|
|
|
if (verbose) { |
|
|
@ -1476,10 +1454,9 @@ static int turn_tcp_connection_bind(int verbose, app_ur_conn_info *clnet_info, a |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
int cb_received = 0; |
|
|
|
int cb_received = 0; |
|
|
|
stun_buffer message; |
|
|
|
|
|
|
|
while (!cb_received) { |
|
|
|
while (!cb_received) { |
|
|
|
|
|
|
|
|
|
|
|
int len = recv_buffer(clnet_info, &message, 1, atc); |
|
|
|
int len = recv_buffer(clnet_info, &response_message, 1, atc, &request_message); |
|
|
|
if (len > 0) { |
|
|
|
if (len > 0) { |
|
|
|
if (verbose) { |
|
|
|
if (verbose) { |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, |
|
|
@ -1487,21 +1464,21 @@ static int turn_tcp_connection_bind(int verbose, app_ur_conn_info *clnet_info, a |
|
|
|
} |
|
|
|
} |
|
|
|
int err_code = 0; |
|
|
|
int err_code = 0; |
|
|
|
u08bits err_msg[129]; |
|
|
|
u08bits err_msg[129]; |
|
|
|
if (stun_is_success_response(&message)) { |
|
|
|
if (stun_is_success_response(&response_message)) { |
|
|
|
|
|
|
|
|
|
|
|
if(clnet_info->nonce[0] || use_short_term) { |
|
|
|
if(clnet_info->nonce[0] || use_short_term) { |
|
|
|
if(check_integrity(clnet_info, &message)<0) |
|
|
|
if(check_integrity(clnet_info, &response_message)<0) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(stun_get_method(&message)!=STUN_METHOD_CONNECTION_BIND) |
|
|
|
if(stun_get_method(&response_message)!=STUN_METHOD_CONNECTION_BIND) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
cb_received = 1; |
|
|
|
cb_received = 1; |
|
|
|
if (verbose) { |
|
|
|
if (verbose) { |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "success\n"); |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "success\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
atc->tcp_data_bound = 1; |
|
|
|
atc->tcp_data_bound = 1; |
|
|
|
} else if (stun_is_challenge_response_str(message.buf, (size_t)message.len, |
|
|
|
} else if (stun_is_challenge_response_str(response_message.buf, (size_t)response_message.len, |
|
|
|
&err_code,err_msg,sizeof(err_msg), |
|
|
|
&err_code,err_msg,sizeof(err_msg), |
|
|
|
clnet_info->realm,clnet_info->nonce, |
|
|
|
clnet_info->realm,clnet_info->nonce, |
|
|
|
clnet_info->server_name, &(clnet_info->oauth))) { |
|
|
|
clnet_info->server_name, &(clnet_info->oauth))) { |
|
|
@ -1510,7 +1487,7 @@ static int turn_tcp_connection_bind(int verbose, app_ur_conn_info *clnet_info, a |
|
|
|
recalculate_restapi_hmac(); |
|
|
|
recalculate_restapi_hmac(); |
|
|
|
} |
|
|
|
} |
|
|
|
goto beg_cb; |
|
|
|
goto beg_cb; |
|
|
|
} else if (stun_is_error_response(&message, &err_code,err_msg,sizeof(err_msg))) { |
|
|
|
} else if (stun_is_error_response(&response_message, &err_code,err_msg,sizeof(err_msg))) { |
|
|
|
cb_received = 1; |
|
|
|
cb_received = 1; |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "connection bind error %d (%s)\n", |
|
|
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "connection bind error %d (%s)\n", |
|
|
|
err_code,(char*)err_msg); |
|
|
|
err_code,(char*)err_msg); |
|
|
|