... | ... |
@@ -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 | 1010 |
|
1008 | 1011 |
len = 0; |
1009 | 1012 |
/*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; |
|
1013 |
+ len += 4/*reply code and one space*/+ |
|
1014 |
+ p_msg->first_line.u.request.version.len+CRLF_LEN; |
|
1015 |
+ /*uri's len*/ |
|
1016 |
+ if (p_msg->new_uri.s) |
|
1017 |
+ len += p_msg->new_uri.len +1; |
|
1018 |
+ else |
|
1019 |
+ len += p_msg->first_line.u.request.uri.len +1; |
|
1012 | 1020 |
/*via*/ |
1013 | 1021 |
via = via_builder( p_msg , &via_len ); |
1014 | 1022 |
if (!via) |
... | ... |
@@ -1045,8 +1053,16 @@ int t_build_and_send_ACK( struct cell *Trans, unsigned int branch, struct sip_ms |
1045 | 1053 |
memcpy( p , "ACK " , 4); |
1046 | 1054 |
p += 4; |
1047 | 1055 |
|
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; |
|
1056 |
+ if ( p_msg->new_uri.s ) |
|
1057 |
+ { |
|
1058 |
+ memcpy(p,p_msg->orig+(p_msg->new_uri.s-p_msg->buf), |
|
1059 |
+ p_msg->new_uri.len ); |
|
1060 |
+ p +=p_msg->new_uri.len; |
|
1061 |
+ }else{ |
|
1062 |
+ memcpy(p,p_msg->orig+(p_msg->first_line.u.request.uri.s-p_msg->buf), |
|
1063 |
+ p_msg->first_line.u.request.uri.len ); |
|
1064 |
+ p += p_msg->first_line.u.request.uri.len; |
|
1065 |
+ } |
|
1050 | 1066 |
|
1051 | 1067 |
*(p++) = ' '; |
1052 | 1068 |
|
... | ... |
@@ -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 | 585 |
/*lumps length*/ |
585 | 586 |
for(lump=msg->reply_lump;lump;lump=lump->next) |
586 | 587 |
len += lump->text.len; |
588 |
+ /*user agent header*/ |
|
589 |
+ len += USER_AGENT_LEN ; |
|
587 | 590 |
/*content length header*/ |
588 | 591 |
len +=CONTENT_LEN_LEN + CRLF_LEN; |
589 | 592 |
/* end of message */ |
... | ... |
@@ -652,6 +655,11 @@ char * build_res_buf_from_sip_req( unsigned int code , |
652 | 655 |
memcpy(p,lump->text.s,lump->text.len); |
653 | 656 |
p += lump->text.len; |
654 | 657 |
} |
658 |
+ /*user agent header*/ |
|
659 |
+ memcpy( p, USER_AGENT , USER_AGENT_LEN ); |
|
660 |
+ p+=USER_AGENT_LEN; |
|
661 |
+ memcpy( p, CRLF, CRLF_LEN ); |
|
662 |
+ p+=CRLF_LEN; |
|
655 | 663 |
/* content length header*/ |
656 | 664 |
memcpy( p, CONTENT_LEN , CONTENT_LEN_LEN ); |
657 | 665 |
p+=CONTENT_LEN_LEN; |