working on even-port.

This commit is contained in:
mom040267 2015-02-01 07:26:29 +00:00
parent 3c40c14f40
commit d5b84163b6
8 changed files with 47 additions and 22 deletions

View File

@ -104,7 +104,7 @@ Flags:
-B Random disconnect after a few initial packets.
-Z Dual allocation (SSODA draft support).
-Z Dual allocation (SSODA). Implies -c option.
-J Use oAuth with default test key kid='north'.

View File

@ -1,5 +1,5 @@
.\" Text automatically generated by txt2man
.TH TURN 1 "24 January 2015" "" ""
.TH TURN 1 "31 January 2015" "" ""
.SH GENERAL INFORMATION
\fIturnadmin\fP is a TURN administration tool. This tool can be used to manage

View File

@ -1,5 +1,5 @@
.\" Text automatically generated by txt2man
.TH TURN 1 "24 January 2015" "" ""
.TH TURN 1 "31 January 2015" "" ""
.SH GENERAL INFORMATION
The \fBTURN Server\fP project contains the source code of a TURN server and TURN client

View File

@ -1,5 +1,5 @@
.\" Text automatically generated by txt2man
.TH TURN 1 "24 January 2015" "" ""
.TH TURN 1 "31 January 2015" "" ""
.SH GENERAL INFORMATION
A set of turnutils_* programs provides some utility functionality to be used
@ -161,7 +161,7 @@ Random disconnect after a few initial packets.
.TP
.B
\fB\-Z\fP
Dual allocation (SSODA draft support).
Dual allocation (SSODA). Implies \fB\-c\fP option.
.TP
.B
\fB\-J\fP

View File

@ -135,7 +135,7 @@ static char Usage[] =
" (for testing the non-standard server relay functionality).\n"
" -G Generate extra requests (create permissions, channel bind).\n"
" -B Random disconnect after a few initial packets.\n"
" -Z Dual allocation.\n"
" -Z Dual allocation (implies -c).\n"
" -J Use oAuth with default test key kid='north' or 'oldempire'.\n"
"Options:\n"
" -l Message length (Default: 100 Bytes).\n"
@ -467,10 +467,16 @@ 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 u08bits*) peer_address, peer_port, &peer_addr) < 0) {
return -1;
if(peer_addr.ss.sa_family == AF_INET6)
}
if(peer_addr.ss.sa_family == AF_INET6) {
default_address_family = STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6;
} else if(peer_addr.ss.sa_family == AF_INET) {
default_address_family = STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4;
}
}

View File

@ -375,7 +375,7 @@ static int clnet_allocate(int verbose,
uint64_t reservation_token = 0;
char* rt = NULL;
int ep = !no_rtcp;
int ep = !no_rtcp && !dual_allocation;
if(!no_rtcp) {
if (!never_allocate_rtcp && allocate_rtcp) {
@ -384,6 +384,15 @@ static int clnet_allocate(int verbose,
}
}
if(is_TCP_relay()) {
ep = -1;
} else if(rt) {
ep = -1;
} else if(!ep) {
ep = (((u08bits)random()) % 2);
ep = ep-1;
}
if(!dos)
stun_set_allocate_request(&request_message, UCLIENT_SESSION_LIFETIME, af4, af6, relay_transport, mobility, rt, ep);
else

View File

@ -758,21 +758,23 @@ int stun_set_allocate_request_str(u08bits* buf, size_t *len, u32bits lifetime, i
if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_LIFETIME,(u08bits*)(&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(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;
}
//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);
} else {
if(mobile) {
if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_MOBILITY_TICKET,(const u08bits*)"",0)<0) return -1;
}
if(ep) {
uint8_t value = 0x80;
if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_EVEN_PORT,(const u08bits*)&value,1)<0) return -1;
}
//ADRESS-FAMILY
if (af4 && !af6) {
u08bits field[4];

View File

@ -1088,11 +1088,14 @@ static int handle_turn_allocate(turn_turnserver *server,
if (in_reservation_token) {
*err_code = 400;
*reason = (const u08bits *)"Even Port and Reservation Token cannot be used together";
} else if (even_port >= 0) {
*err_code = 400;
*reason = (const u08bits *)"Even Port cannot be used in this request";
} 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";
}
}
}
}
break;
@ -1118,6 +1121,11 @@ static int handle_turn_allocate(turn_turnserver *server,
}
break;
case STUN_ATTRIBUTE_ADDITIONAL_ADDRESS_FAMILY:
if(even_port>0) {
*err_code = 400;
*reason = (const u08bits *)"Even Port cannot be used with Dual Allocation";
break;
}
case STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY: {
if(in_reservation_token) {
*err_code = 400;
@ -1220,7 +1228,7 @@ static int handle_turn_allocate(turn_turnserver *server,
*err_code = 440;
*reason = (const u08bits *)"Dual allocation cannot be supported in the current server configuration";
}
if(even_port >= 0) {
if(even_port > 0) {
*err_code = 440;
*reason = (const u08bits *)"Dual allocation cannot be supported with even-port functionality";
}