Selaa lähdekoodia

Mobility ticket retransmission fixed.

mom040267 11 vuotta sitten
vanhempi
sitoutus
4f94e42494
4 muutettua tiedostoa jossa 26 lisäystä ja 5 poistoa
  1. 2 1
      ChangeLog
  2. 9 0
      src/apps/uclient/startuclient.c
  3. 14 4
      src/server/ns_turn_server.c
  4. 1 0
      src/server/ns_turn_session.h

+ 2 - 1
ChangeLog

@@ -1,6 +1,7 @@
 08/22/2014 Oleg Moskalenko <[email protected]>
 Version 4.1.2.2 'Vitari':
-	- SHA-256 memory leak fixed. 
+	- SHA-256 memory leak fixed.
+	- Mobility ticket retransmission fixed.
 	
 08/14/2014 Oleg Moskalenko <[email protected]>
 Version 4.1.2.1 'Vitari':

+ 9 - 0
src/apps/uclient/startuclient.c

@@ -665,6 +665,11 @@ static int clnet_allocate(int verbose,
 						TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "refresh sent\n");
 					}
 					refresh_sent = 1;
+
+					if(clnet_info->s_mobile_id[0]) {
+						usleep(10000);
+						send_buffer(clnet_info, &message, 0,0);
+					}
 				} else {
 					perror("send");
 					exit(1);
@@ -682,6 +687,10 @@ static int clnet_allocate(int verbose,
 
 				int len = recv_buffer(clnet_info, &message, 1, 0);
 
+				if(clnet_info->s_mobile_id[0]) {
+					len = recv_buffer(clnet_info, &message, 1, 0);
+				}
+
 				if (len > 0) {
 					if (verbose) {
 						TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,

+ 14 - 4
src/server/ns_turn_server.c

@@ -1411,9 +1411,6 @@ static int handle_turn_refresh(turn_turnserver *server,
 				if(!(*(server->mobility))) {
 					*err_code = 405;
 					*reason = (const u08bits *)"Mobility forbidden";
-				} if(is_allocation_valid(a)) {
-					*err_code = 400;
-					*reason = (const u08bits *)"Mobility ticket cannot be used for a stable, already established allocation";
 				} else {
 					int smid_len = stun_attr_get_len(sar);
 					if(smid_len>0 && (((size_t)smid_len)<sizeof(smid))) {
@@ -1421,6 +1418,10 @@ static int handle_turn_refresh(turn_turnserver *server,
 						if(smid_val) {
 							ns_bcopy(smid_val, smid, (size_t)smid_len);
 							mid = string_to_mobile_id(smid);
+							if(is_allocation_valid(a) && (mid != ss->old_mobile_id)) {
+								*err_code = 400;
+								*reason = (const u08bits *)"Mobility ticket cannot be used for a stable, already established allocation";
+							}
 						}
 					} else {
 						*err_code = 400;
@@ -1610,6 +1611,7 @@ static int handle_turn_refresh(turn_turnserver *server,
 										//Use new buffer and redefine ss:
 										nbh = ioa_network_buffer_allocate(server->e);
 										ss = orig_ss;
+										ss->old_mobile_id = mid;
 										size_t len = ioa_network_buffer_get_size(nbh);
 
 										turn_report_allocation_set(&(ss->alloc), lifetime, 1);
@@ -1699,10 +1701,18 @@ static int handle_turn_refresh(turn_turnserver *server,
 
 				size_t len = ioa_network_buffer_get_size(nbh);
 				stun_init_success_response_str(STUN_METHOD_REFRESH, ioa_network_buffer_data(nbh), &len, tid);
-				u32bits lt = nswap32(lifetime);
 
+				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));
+					ioa_network_buffer_set_size(nbh,len);
+				}
+
+				u32bits lt = nswap32(lifetime);
 				stun_attr_add_str(ioa_network_buffer_data(nbh), &len, STUN_ATTRIBUTE_LIFETIME,
 						(const u08bits*) &lt, 4);
+
 				ioa_network_buffer_set_size(nbh,len);
 
 				*resp_constructed = 1;

+ 1 - 0
src/server/ns_turn_session.h

@@ -97,6 +97,7 @@ struct _ts_ur_super_session {
   /* Mobile */
   int is_mobile;
   mobile_id_t mobile_id;
+  mobile_id_t old_mobile_id;
   char s_mobile_id[33];
   /* Realm */
   realm_options_t realm_options;