Selaa lähdekoodia

*** empty log message ***

Bogdan-Andrei Iancu 23 vuotta sitten
vanhempi
commit
76f8a73ff3
6 muutettua tiedostoa jossa 57 lisäystä ja 15 poistoa
  1. 5 0
      modules/tm/h_table.c
  2. 1 0
      modules/tm/h_table.h
  3. 1 1
      modules/tm/t_funcs.c
  4. 7 0
      modules/tm/t_lookup.c
  5. 40 11
      modules/tm/t_reply.c
  6. 3 3
      test/th-uri.cfg

+ 5 - 0
modules/tm/h_table.c

@@ -44,6 +44,11 @@ void free_cell( struct cell* dead_cell )
 			shm_free_unsafe( b );
 			shm_free_unsafe( b );
 			b = 0;
 			b = 0;
 		}
 		}
+		if ( (b=dead_cell->uac[i].rpl_buffer.s) )
+		{
+			shm_free_unsafe( b );
+			b = 0;
+		}
 	}
 	}
 
 
 	/* the cell's body */
 	/* the cell's body */

+ 1 - 0
modules/tm/h_table.h

@@ -88,6 +88,7 @@ typedef struct ua_client
 	struct retr_buf  request;
 	struct retr_buf  request;
 	unsigned int     status;
 	unsigned int     status;
 	str              tag;
 	str              tag;
+	str              rpl_buffer;
 	unsigned int     rpl_received;
 	unsigned int     rpl_received;
 }ua_client_type;
 }ua_client_type;
 
 

+ 1 - 1
modules/tm/t_funcs.c

@@ -258,7 +258,7 @@ int t_should_relay_response( struct cell *Trans , int new_code,
 		else {
 		else {
 			if (!T->uac[branch].rpl_received) *should_store=1;
 			if (!T->uac[branch].rpl_received) *should_store=1;
 				else *should_store=0;
 				else *should_store=0;
-			if (T_code==0) return branch;
+			if (Trans->uas.status==0) return branch;
 				else return -1;
 				else return -1;
 		}
 		}
 	}
 	}

+ 7 - 0
modules/tm/t_lookup.c

@@ -130,12 +130,19 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
 		{ /* it's a ACK request*/
 		{ /* it's a ACK request*/
 			/* first only the length are checked */
 			/* first only the length are checked */
 			if ( t_msg->first_line.u.request.method_value==METHOD_INVITE
 			if ( t_msg->first_line.u.request.method_value==METHOD_INVITE
+			//&& (printf("------Method name OK ->testing callid len...\n"))
 			&& /*callid length*/ EQ_LEN(callid)
 			&& /*callid length*/ EQ_LEN(callid)
+			//&& (printf("------CallID OK -> testing cseq nr len\n"))
 			&& get_cseq(t_msg)->number.len==get_cseq(p_msg)->number.len
 			&& get_cseq(t_msg)->number.len==get_cseq(p_msg)->number.len
+			//&& (printf("------Cseq nr OK -> testing from len\n"))
 			&& /*from length*/ EQ_LEN(from)
 			&& /*from length*/ EQ_LEN(from)
+			//&& (printf("------from OK -> testing To uri len\n"))
 			&& /*to uri*/get_to(t_msg)->uri.len==get_to(p_msg)->uri.len
 			&& /*to uri*/get_to(t_msg)->uri.len==get_to(p_msg)->uri.len
+			//&& (printf("------To uri OK -> testing To tag len\n"))
 			&& /*to tag*/p_cell->uas.tag->len==get_to(p_msg)->tag_value.len
 			&& /*to tag*/p_cell->uas.tag->len==get_to(p_msg)->tag_value.len
+			//&& (printf("------To tag OK -> testing uri len\n"))
 			&& /*req URI*/(p_cell->uas.status==200 || EQ_REQ_URI_LEN )
 			&& /*req URI*/(p_cell->uas.status==200 || EQ_REQ_URI_LEN )
+			//&& (printf("------uri OK -> testing via len\n"))
 			&& /*VIA*/(p_cell->uas.status==200 || EQ_VIA_LEN(via1)) )
 			&& /*VIA*/(p_cell->uas.status==200 || EQ_VIA_LEN(via1)) )
 				/* so far the lengths are the same
 				/* so far the lengths are the same
 				-> let's check the contents */
 				-> let's check the contents */

+ 40 - 11
modules/tm/t_reply.c

@@ -202,6 +202,7 @@ int t_on_reply( struct sip_msg  *p_msg )
 	unsigned int res_len, ack_len;
 	unsigned int res_len, ack_len;
 	/* buffer length (might be somewhat larger than message size */
 	/* buffer length (might be somewhat larger than message size */
 	unsigned int alloc_len;
 	unsigned int alloc_len;
+	str *str_foo;
 
 
 
 
 	/* make sure we know the assosociated tranaction ... */
 	/* make sure we know the assosociated tranaction ... */
@@ -267,16 +268,29 @@ int t_on_reply( struct sip_msg  *p_msg )
 
 
 	if (save_clone)
 	if (save_clone)
 	{
 	{
-		if (T->uac[branch].tag.s)
-			T->uac[branch].tag.s = shm_resize(T->uac[branch].tag.s,
-				get_to(p_msg)->tag_value.len+TAG_OVERBUFFER_LEN);
-		else
-			T->uac[branch].tag.s = shm_malloc( get_to(p_msg)->tag_value.len );
-		if (!T->uac[branch].tag.s)
+		str_foo = &(T->uac[branch].tag);
+		str_foo->s = shm_resize(str_foo->s, (str_foo?0:TAG_OVERBUFFER_LEN) +
+			get_to(p_msg)->tag_value.len);
+		if (!str_foo->s)
 		{
 		{
 			LOG( L_ERR , "ERROR: t_on_reply: connot alocate memory!\n");
 			LOG( L_ERR , "ERROR: t_on_reply: connot alocate memory!\n");
 			goto error1;
 			goto error1;
 		}
 		}
+		/* when forking, replies greater then 300 are saved */
+		if (T->nr_of_outgoings>1 && msg_status>=300 )
+		{
+			str_foo = &(T->uac[branch].rpl_buffer);
+			str_foo->s = shm_resize(str_foo->s, res_len+
+				(str_foo->s?0:REPLY_OVERBUFFER_LEN) );
+			if (!str_foo->s)
+			{
+				LOG( L_ERR , "ERROR: t_on_reply: connot alocate memory!\n");
+				goto error1;
+			}
+			memcpy(str_foo->s,buf,res_len);
+			str_foo->len = res_len;
+		}
+		/*copy the TO tag from reply*/
 		T->uac[branch].tag.len = get_to(p_msg)->tag_value.len;
 		T->uac[branch].tag.len = get_to(p_msg)->tag_value.len;
 		memcpy( T->uac[branch].tag.s, get_to(p_msg)->tag_value.s,
 		memcpy( T->uac[branch].tag.s, get_to(p_msg)->tag_value.s,
 			T->uac[branch].tag.len );
 			T->uac[branch].tag.len );
@@ -286,6 +300,21 @@ int t_on_reply( struct sip_msg  *p_msg )
 
 
 	rb = & T->uas.response;
 	rb = & T->uas.response;
 	if (relay >= 0 ) {
 	if (relay >= 0 ) {
+		if (relay!=branch)
+		{
+			str_foo = &(T->uac[relay].rpl_buffer);
+			if (buf) pkg_free(buf);
+			buf = (char*)pkg_malloc(str_foo->len);
+			if (!buf)
+			{
+				UNLOCK_REPLIES( T );
+				start_fr = 1;
+				LOG(L_ERR, "ERROR: t_on_reply: cannot alloc pkg mem\n");
+				goto error1;
+			}
+			memcpy( buf , str_foo->s , str_foo->len );
+			res_len = str_foo->len;
+		}
 		/* if there is no reply yet, initialize the structure */
 		/* if there is no reply yet, initialize the structure */
 		if ( ! rb->buffer ) {
 		if ( ! rb->buffer ) {
 			/*init retrans buffer*/
 			/*init retrans buffer*/
@@ -302,23 +331,23 @@ int t_on_reply( struct sip_msg  *p_msg )
 			   subsequent messages will be longer and buffer
 			   subsequent messages will be longer and buffer
 			   reusing will save us a malloc lock */
 			   reusing will save us a malloc lock */
 			alloc_len = res_len + REPLY_OVERBUFFER_LEN ;
 			alloc_len = res_len + REPLY_OVERBUFFER_LEN ;
-		} else {
+		}else{
 			alloc_len = res_len;
 			alloc_len = res_len;
 		}
 		}
 		/* puts the reply's buffer to uas.response */
 		/* puts the reply's buffer to uas.response */
-		if (! (rb->buffer = (char *)shm_resize( rb->buffer, alloc_len ))) {
+		if (! (rb->buffer = (char*)shm_resize( rb->buffer, alloc_len ))) {
 			UNLOCK_REPLIES( T );
 			UNLOCK_REPLIES( T );
 			start_fr = 1;
 			start_fr = 1;
 			LOG(L_ERR, "ERROR: t_on_reply: cannot alloc shmem\n");
 			LOG(L_ERR, "ERROR: t_on_reply: cannot alloc shmem\n");
 			goto error1;
 			goto error1;
-		};
+		}
 		rb->buffer_len = res_len;
 		rb->buffer_len = res_len;
 		memcpy( rb->buffer, buf, res_len );
 		memcpy( rb->buffer, buf, res_len );
 		/* update the status ... */
 		/* update the status ... */
 		T->uas.status = p_msg->REPLY_STATUS;
 		T->uas.status = p_msg->REPLY_STATUS;
-		T->uas.tag=&(T->uac[branch].tag);
+		T->uas.tag=&(T->uac[relay].tag);
 		if (T->uas.status >=200 && T->relaied_reply_branch==-1 )
 		if (T->uas.status >=200 && T->relaied_reply_branch==-1 )
-				T->relaied_reply_branch = branch;
+				T->relaied_reply_branch = relay;
 	}; /* if relay ... */
 	}; /* if relay ... */
 
 
 	UNLOCK_REPLIES( T );
 	UNLOCK_REPLIES( T );

+ 3 - 3
test/th-uri.cfg

@@ -5,7 +5,7 @@
 #
 #
 
 
 
 
-debug=3          # debug level (cmd line: -dddddddddd)
+debug=9          # debug level (cmd line: -dddddddddd)
 #fork=yes          # (cmd. line: -D)
 #fork=yes          # (cmd. line: -D)
 fork=no
 fork=no
 log_stderror=yes  # (cmd line: -E)
 log_stderror=yes  # (cmd line: -E)
@@ -62,9 +62,9 @@ route{
 	};
 	};
 */
 */
 	t_clear_forks();
 	t_clear_forks();
-/*	if (method=="INVITE")
+/*	if (method=="INVITE" && uri=~"sip:[email protected]")
 	{
 	{
-		t_fork_to("195.37.78.125","5060");
+		t_fork_to("195.37.78.153","5060");
 		#t_fork_to("195.37.78.246","5060");
 		#t_fork_to("195.37.78.246","5060");
 	};*/
 	};*/