Переглянути джерело

back in history with timers!!

Bogdan-Andrei Iancu 23 роки тому
батько
коміт
5655ca6fe5
5 змінених файлів з 42 додано та 14 видалено
  1. 4 0
      config.h
  2. 1 2
      main.c
  3. 26 10
      modules/tm/t_funcs.c
  4. 9 1
      msg_translator.c
  5. 2 1
      test/th-uri.cfg

+ 4 - 0
config.h

@@ -36,6 +36,10 @@
 #define CONTENT_LEN "Content-Length: 0"
 #define CONTENT_LEN_LEN 17
 
+#define USER_AGENT "User-Agent: Sip EXpress router"\
+                                     "(" VERSION " (" ARCH "/" OS"))"
+ #define USER_AGENT_LEN (sizeof(USER_AGENT)-1)
+
 #define MY_BRANCH ";branch=0"
 #define MY_BRANCH_LEN 9
 

+ 1 - 2
main.c

@@ -140,7 +140,7 @@ void receive_stdin_loop()
 	#define BSIZE 1024
 	char buf[BSIZE+1];
 	int len;
-	
+
 	while(1){
 		len=fread(buf,1,BSIZE,stdin);
 		buf[len+1]=0;
@@ -460,7 +460,6 @@ int main(int argc, char** argv)
 	//memtest();
 	//hashtest();
 
-
 	/* process command line (get port no, cfg. file path etc) */
 	opterr=0;
 	options=

+ 26 - 10
modules/tm/t_funcs.c

@@ -65,24 +65,27 @@ static inline void reset_retr_timers( struct s_table *h_table,
 
 	DBG("DEBUG:stop_RETR_and_FR_timers : start \n");
 	/* lock the first timer list of the FR group -- all other
-	   lists share the same lock
-	*/
-	lock(  hash_table->timers[RT_T1_TO_1].mutex );
+	   lists share the same lock*/
+	lock(  hash_table->timers[FR_TIMER_LIST].mutex );
+	/* reset_timer( h_table, &(p_cell->outbound_response.retr_timer)); */
 	remove_timer_unsafe( & p_cell->outbound_response.retr_timer );
 	for( ijk=0 ; ijk<(p_cell)->nr_of_outgoings ; ijk++ )  {
 			if ( rb = p_cell->outbound_request[ijk] ) {
+				/* reset_timer(h_table, &(rb->retr_timer)); */
 				remove_timer_unsafe( & rb->retr_timer );
 			}
 		}
-	unlock(  hash_table->timers[RT_T1_TO_1].mutex );
-	lock(  hash_table->timers[FR_TIMER_LIST].mutex );
+	unlock(  hash_table->timers[FR_TIMER_LIST].mutex );
+	lock(  hash_table->timers[RT_T1_TO_1].mutex );
+	/* reset_timer( h_table, &(p_cell->outbound_response.fr_timer)); */
 	remove_timer_unsafe( & p_cell->outbound_response.fr_timer );
 	for( ijk=0 ; ijk<(p_cell)->nr_of_outgoings ; ijk++ )  {
 			if ( rb = p_cell->outbound_request[ijk] ) {
+				/* reset_timer(h_table, &(rb->fr_timer)); */
 				remove_timer_unsafe( & rb->fr_timer );
 			}
 		}
-	unlock(  hash_table->timers[FR_TIMER_LIST].mutex );
+	unlock(  hash_table->timers[RT_T1_TO_1].mutex );
 	DBG("DEBUG:stop_RETR_and_FR_timers : stop\n");
 }
 
@@ -1007,8 +1010,13 @@ int t_build_and_send_ACK( struct cell *Trans, unsigned int branch, struct sip_ms
 
     len = 0;
     /*first line's len */
-    len += 4+p_msg->first_line.u.request.uri.len+1+
-		p_msg->first_line.u.request.version.len+CRLF_LEN;
+    len += 4/*reply code and one space*/+
+       p_msg->first_line.u.request.version.len+CRLF_LEN;
+    /*uri's len*/
+    if (p_msg->new_uri.s)
+       len += p_msg->new_uri.len +1;
+    else
+       len += p_msg->first_line.u.request.uri.len +1;
     /*via*/
     via = via_builder( p_msg , &via_len );
     if (!via)
@@ -1045,8 +1053,16 @@ int t_build_and_send_ACK( struct cell *Trans, unsigned int branch, struct sip_ms
    memcpy( p , "ACK " , 4);
    p += 4;
 
-   memcpy( p , p_msg->orig+(p_msg->first_line.u.request.uri.s-p_msg->buf) , p_msg->first_line.u.request.uri.len );
-   p += p_msg->first_line.u.request.uri.len;
+   if ( p_msg->new_uri.s )
+   {
+      memcpy(p,p_msg->orig+(p_msg->new_uri.s-p_msg->buf),
+         p_msg->new_uri.len );
+      p +=p_msg->new_uri.len;
+   }else{
+      memcpy(p,p_msg->orig+(p_msg->first_line.u.request.uri.s-p_msg->buf),
+         p_msg->first_line.u.request.uri.len );
+      p += p_msg->first_line.u.request.uri.len;
+   }
 
    *(p++) = ' ';
 

+ 9 - 1
msg_translator.c

@@ -31,7 +31,8 @@
 		(_dest) += (_len) ;\
 	}while(0);
 
-
+extern char version[];
+extern int version_len;
 
 /* faster than inet_ntoa */
 static inline char* q_inet_itoa(unsigned long ip)
@@ -584,6 +585,8 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
 	/*lumps length*/
 	for(lump=msg->reply_lump;lump;lump=lump->next)
 		len += lump->text.len;
+	/*user agent header*/
+	len += USER_AGENT_LEN ;
 	/*content length header*/
 	len +=CONTENT_LEN_LEN + CRLF_LEN;
 	/* end of message */
@@ -652,6 +655,11 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
 		memcpy(p,lump->text.s,lump->text.len);
 		p += lump->text.len;
 	}
+	/*user agent header*/
+	memcpy( p, USER_AGENT , USER_AGENT_LEN );
+	p+=USER_AGENT_LEN;
+	memcpy( p, CRLF, CRLF_LEN );
+	p+=CRLF_LEN;
 	/* content length header*/
 	memcpy( p, CONTENT_LEN , CONTENT_LEN_LEN );
 	p+=CONTENT_LEN_LEN;

+ 2 - 1
test/th-uri.cfg

@@ -51,6 +51,7 @@ route{
              };
 
 
+
              if (method=="INVITE")
              {
                 log("SER : runing CPL!! :)\n");
@@ -69,7 +70,7 @@ route{
                        drop();
                    };
                 };
-             };
+             }; 
 
            #  if ( !rewriteFromRoute() )
             # {