Browse code

back in history with timers!!

Bogdan-Andrei Iancu authored on 15/02/2002 01:28:12
Showing 5 changed files
... ...
@@ -36,6 +36,10 @@
36 36
 #define CONTENT_LEN "Content-Length: 0"
37 37
 #define CONTENT_LEN_LEN 17
38 38
 
39
+#define USER_AGENT "User-Agent: Sip EXpress router"\
40
+                                     "(" VERSION " (" ARCH "/" OS"))"
41
+ #define USER_AGENT_LEN (sizeof(USER_AGENT)-1)
42
+
39 43
 #define MY_BRANCH ";branch=0"
40 44
 #define MY_BRANCH_LEN 9
41 45
 
... ...
@@ -140,7 +140,7 @@ void receive_stdin_loop()
140 140
 	#define BSIZE 1024
141 141
 	char buf[BSIZE+1];
142 142
 	int len;
143
-	
143
+
144 144
 	while(1){
145 145
 		len=fread(buf,1,BSIZE,stdin);
146 146
 		buf[len+1]=0;
... ...
@@ -460,7 +460,6 @@ int main(int argc, char** argv)
460 460
 	//memtest();
461 461
 	//hashtest();
462 462
 
463
-
464 463
 	/* process command line (get port no, cfg. file path etc) */
465 464
 	opterr=0;
466 465
 	options=
... ...
@@ -65,24 +65,27 @@ static inline void reset_retr_timers( struct s_table *h_table,
65 65
 
66 66
 	DBG("DEBUG:stop_RETR_and_FR_timers : start \n");
67 67
 	/* lock the first timer list of the FR group -- all other
68
-	   lists share the same lock
69
-	*/
70
-	lock(  hash_table->timers[RT_T1_TO_1].mutex );
68
+	   lists share the same lock*/
69
+	lock(  hash_table->timers[FR_TIMER_LIST].mutex );
70
+	/* reset_timer( h_table, &(p_cell->outbound_response.retr_timer)); */
71 71
 	remove_timer_unsafe( & p_cell->outbound_response.retr_timer );
72 72
 	for( ijk=0 ; ijk<(p_cell)->nr_of_outgoings ; ijk++ )  {
73 73
 			if ( rb = p_cell->outbound_request[ijk] ) {
74
+				/* reset_timer(h_table, &(rb->retr_timer)); */
74 75
 				remove_timer_unsafe( & rb->retr_timer );
75 76
 			}
76 77
 		}
77
-	unlock(  hash_table->timers[RT_T1_TO_1].mutex );
78
-	lock(  hash_table->timers[FR_TIMER_LIST].mutex );
78
+	unlock(  hash_table->timers[FR_TIMER_LIST].mutex );
79
+	lock(  hash_table->timers[RT_T1_TO_1].mutex );
80
+	/* reset_timer( h_table, &(p_cell->outbound_response.fr_timer)); */
79 81
 	remove_timer_unsafe( & p_cell->outbound_response.fr_timer );
80 82
 	for( ijk=0 ; ijk<(p_cell)->nr_of_outgoings ; ijk++ )  {
81 83
 			if ( rb = p_cell->outbound_request[ijk] ) {
84
+				/* reset_timer(h_table, &(rb->fr_timer)); */
82 85
 				remove_timer_unsafe( & rb->fr_timer );
83 86
 			}
84 87
 		}
85
-	unlock(  hash_table->timers[FR_TIMER_LIST].mutex );
88
+	unlock(  hash_table->timers[RT_T1_TO_1].mutex );
86 89
 	DBG("DEBUG:stop_RETR_and_FR_timers : stop\n");
87 90
 }
88 91
 
... ...
@@ -1007,8 +1010,13 @@ int t_build_and_send_ACK( struct cell *Trans, unsigned int branch, struct sip_ms
1007 1007
 
1008 1008
     len = 0;
1009 1009
     /*first line's len */
1010
-    len += 4+p_msg->first_line.u.request.uri.len+1+
1011
-		p_msg->first_line.u.request.version.len+CRLF_LEN;
1010
+    len += 4/*reply code and one space*/+
1011
+       p_msg->first_line.u.request.version.len+CRLF_LEN;
1012
+    /*uri's len*/
1013
+    if (p_msg->new_uri.s)
1014
+       len += p_msg->new_uri.len +1;
1015
+    else
1016
+       len += p_msg->first_line.u.request.uri.len +1;
1012 1017
     /*via*/
1013 1018
     via = via_builder( p_msg , &via_len );
1014 1019
     if (!via)
... ...
@@ -1045,8 +1053,16 @@ int t_build_and_send_ACK( struct cell *Trans, unsigned int branch, struct sip_ms
1045 1045
    memcpy( p , "ACK " , 4);
1046 1046
    p += 4;
1047 1047
 
1048
-   memcpy( p , p_msg->orig+(p_msg->first_line.u.request.uri.s-p_msg->buf) , p_msg->first_line.u.request.uri.len );
1049
-   p += p_msg->first_line.u.request.uri.len;
1048
+   if ( p_msg->new_uri.s )
1049
+   {
1050
+      memcpy(p,p_msg->orig+(p_msg->new_uri.s-p_msg->buf),
1051
+         p_msg->new_uri.len );
1052
+      p +=p_msg->new_uri.len;
1053
+   }else{
1054
+      memcpy(p,p_msg->orig+(p_msg->first_line.u.request.uri.s-p_msg->buf),
1055
+         p_msg->first_line.u.request.uri.len );
1056
+      p += p_msg->first_line.u.request.uri.len;
1057
+   }
1050 1058
 
1051 1059
    *(p++) = ' ';
1052 1060
 
... ...
@@ -31,7 +31,8 @@
31 31
 		(_dest) += (_len) ;\
32 32
 	}while(0);
33 33
 
34
-
34
+extern char version[];
35
+extern int version_len;
35 36
 
36 37
 /* faster than inet_ntoa */
37 38
 static inline char* q_inet_itoa(unsigned long ip)
... ...
@@ -584,6 +585,8 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
584 584
 	/*lumps length*/
585 585
 	for(lump=msg->reply_lump;lump;lump=lump->next)
586 586
 		len += lump->text.len;
587
+	/*user agent header*/
588
+	len += USER_AGENT_LEN ;
587 589
 	/*content length header*/
588 590
 	len +=CONTENT_LEN_LEN + CRLF_LEN;
589 591
 	/* end of message */
... ...
@@ -652,6 +655,11 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
652 652
 		memcpy(p,lump->text.s,lump->text.len);
653 653
 		p += lump->text.len;
654 654
 	}
655
+	/*user agent header*/
656
+	memcpy( p, USER_AGENT , USER_AGENT_LEN );
657
+	p+=USER_AGENT_LEN;
658
+	memcpy( p, CRLF, CRLF_LEN );
659
+	p+=CRLF_LEN;
655 660
 	/* content length header*/
656 661
 	memcpy( p, CONTENT_LEN , CONTENT_LEN_LEN );
657 662
 	p+=CONTENT_LEN_LEN;
... ...
@@ -51,6 +51,7 @@ route{
51 51
              };
52 52
 
53 53
 
54
+
54 55
              if (method=="INVITE")
55 56
              {
56 57
                 log("SER : runing CPL!! :)\n");
... ...
@@ -69,7 +70,7 @@ route{
69 69
                        drop();
70 70
                    };
71 71
                 };
72
-             };
72
+             }; 
73 73
 
74 74
            #  if ( !rewriteFromRoute() )
75 75
             # {