... | ... |
@@ -147,10 +147,6 @@ struct cell* build_cell( struct sip_msg* p_msg ) |
147 | 147 |
new_cell->wait_tl.payload = new_cell; |
148 | 148 |
new_cell->dele_tl.payload = new_cell; |
149 | 149 |
|
150 |
- /* inbound request */ |
|
151 |
- /* force parsing all the needed headers*/ |
|
152 |
- if (parse_headers(p_msg, HDR_EOH )==-1) |
|
153 |
- goto error; |
|
154 | 150 |
new_cell->inbound_request = sip_msg_cloner(p_msg) ; |
155 | 151 |
DBG("DEBUG: build_cell : clone done\n"); |
156 | 152 |
if (!new_cell->inbound_request) |
... | ... |
@@ -152,7 +152,7 @@ int t_add_transaction( struct sip_msg* p_msg, char* foo, char* bar ) |
152 | 152 |
} |
153 | 153 |
|
154 | 154 |
/* it's about the same transaction or not?*/ |
155 |
- t_check( p_msg , 0 ); |
|
155 |
+ if (t_check( p_msg , 0 )==-1) return -1; |
|
156 | 156 |
|
157 | 157 |
/* if the lookup's result is not 0 means that it's a retransmission */ |
158 | 158 |
if ( T ) |
... | ... |
@@ -198,7 +198,7 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int |
198 | 198 |
branch = 0; /* we don't do any forking right now */ |
199 | 199 |
|
200 | 200 |
/* it's about the same transaction or not? */ |
201 |
- t_check( p_msg , 0 ); |
|
201 |
+ if (t_check( p_msg , 0 )==-1) return -1; |
|
202 | 202 |
|
203 | 203 |
/*if T hasn't been found after all -> return not found (error) */ |
204 | 204 |
if ( !T ) |
... | ... |
@@ -355,7 +355,7 @@ int t_forward_uri( struct sip_msg* p_msg, char* foo, char* bar ) |
355 | 355 |
int err; |
356 | 356 |
|
357 | 357 |
/* it's about the same transaction or not? */ |
358 |
- t_check( p_msg , 0); |
|
358 |
+ if (t_check( p_msg , 0 )==-1) return -1; |
|
359 | 359 |
|
360 | 360 |
/*if T hasn't been found after all -> return not found (error) */ |
361 | 361 |
if ( !T ) |
... | ... |
@@ -428,12 +428,7 @@ int t_on_reply_received( struct sip_msg *p_msg ) |
428 | 428 |
a chance for minimum routing; parse only what's needed |
429 | 429 |
for MPLS-ize reply matching |
430 | 430 |
*/ |
431 |
- if ( parse_headers(p_msg, HDR_VIA1|HDR_VIA2|HDR_TO|HDR_CSEQ )==-1 || |
|
432 |
- !p_msg->via1 || !p_msg->via2 || !p_msg->to || !p_msg->cseq ) |
|
433 |
- return 1; |
|
434 |
- |
|
435 |
- /* we use label-matching to lookup for T */ |
|
436 |
- t_check( p_msg , &branch ); |
|
431 |
+ if (t_check( p_msg , &branch )==-1) return 1; |
|
437 | 432 |
|
438 | 433 |
/* if no T found ->tell the core router to forward statelessly */ |
439 | 434 |
if ( T<=0 ) |
... | ... |
@@ -536,7 +531,7 @@ error: |
536 | 531 |
*/ |
537 | 532 |
int t_release_transaction( struct sip_msg* p_msg) |
538 | 533 |
{ |
539 |
- t_check( p_msg , 0 ); |
|
534 |
+ if (t_check( p_msg , 0 )==-1) return 1; |
|
540 | 535 |
|
541 | 536 |
if ( T && T!=T_UNDEFINED ) |
542 | 537 |
return t_put_on_wait( T ); |
... | ... |
@@ -556,7 +551,7 @@ int t_release_transaction( struct sip_msg* p_msg) |
556 | 551 |
*/ |
557 | 552 |
int t_retransmit_reply( struct sip_msg* p_msg, char* foo, char* bar ) |
558 | 553 |
{ |
559 |
- t_check( p_msg , 0 ); |
|
554 |
+ if (t_check( p_msg , 0 )==-1) return 1; |
|
560 | 555 |
|
561 | 556 |
/* if no transaction exists or no reply to be resend -> out */ |
562 | 557 |
if ( T ) |
... | ... |
@@ -592,7 +587,7 @@ int t_send_reply( struct sip_msg* p_msg , unsigned int code , char * text ) |
592 | 587 |
char *b; |
593 | 588 |
|
594 | 589 |
DBG("DEBUG: t_send_reply: entered\n"); |
595 |
- t_check( p_msg , 0 ); |
|
590 |
+ if (t_check( p_msg , 0 )==-1) return -1; |
|
596 | 591 |
|
597 | 592 |
if (!T) |
598 | 593 |
{ |
... | ... |
@@ -312,6 +312,7 @@ nomatch2: |
312 | 312 |
|
313 | 313 |
/* Functions update T (T gets either a valid pointer in it or it equals zero) if no transaction |
314 | 314 |
* for current message exists; |
315 |
+ * it returns 1 if found, 0 if not found, -1 on error |
|
315 | 316 |
*/ |
316 | 317 |
int t_check( struct sip_msg* p_msg , int *param_branch) |
317 | 318 |
{ |
... | ... |
@@ -326,10 +327,19 @@ int t_check( struct sip_msg* p_msg , int *param_branch) |
326 | 327 |
unref_T(T); |
327 | 328 |
T = T_UNDEFINED; |
328 | 329 |
/* transaction lookup */ |
329 |
- if ( p_msg->first_line.type==SIP_REQUEST ) |
|
330 |
+ if ( p_msg->first_line.type==SIP_REQUEST ) { |
|
331 |
+ |
|
332 |
+ /* force parsing all the needed headers*/ |
|
333 |
+ if (parse_headers(p_msg, HDR_EOH )==-1) |
|
334 |
+ return -1; |
|
330 | 335 |
t_lookup_request( p_msg ); |
331 |
- else |
|
336 |
+ } else { |
|
337 |
+ if ( parse_headers(p_msg, HDR_VIA1|HDR_VIA2|HDR_TO|HDR_CSEQ )==-1 || |
|
338 |
+ !p_msg->via1 || !p_msg->via2 || !p_msg->to || !p_msg->cseq ) |
|
339 |
+ return -1; |
|
340 |
+ |
|
332 | 341 |
t_reply_matching( p_msg , ((param_branch!=0)?(param_branch):(&local_branch)) ); |
342 |
+ } |
|
333 | 343 |
#ifdef EXTRA_DEBUG |
334 | 344 |
if ( T && T!=T_UNDEFINED && T->damocles) { |
335 | 345 |
LOG( L_ERR, "ERROR: transaction %p scheduled for deletion and called from t_check\n", T); |
... | ... |
@@ -346,7 +356,7 @@ int t_check( struct sip_msg* p_msg , int *param_branch) |
346 | 356 |
DBG("DEBUG: t_check: T previously sought and not found\n"); |
347 | 357 |
} |
348 | 358 |
|
349 |
- return ((T)?1:-1) ; |
|
359 |
+ return ((T)?1:0) ; |
|
350 | 360 |
} |
351 | 361 |
|
352 | 362 |
|
... | ... |
@@ -4,6 +4,7 @@ |
4 | 4 |
|
5 | 5 |
#include <string.h> |
6 | 6 |
#include <stdlib.h> |
7 |
+#include <sys/time.h> |
|
7 | 8 |
|
8 | 9 |
#include "receive.h" |
9 | 10 |
#include "dprint.h" |
... | ... |
@@ -26,6 +27,9 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip) |
26 | 27 |
struct sip_msg* msg; |
27 | 28 |
#ifdef STATS |
28 | 29 |
int skipped = 1; |
30 |
+ struct timeval tvb, tve; |
|
31 |
+ struct timezone tz; |
|
32 |
+ unsigned int diff; |
|
29 | 33 |
#endif |
30 | 34 |
|
31 | 35 |
msg=pkg_malloc(sizeof(struct sip_msg)); |
... | ... |
@@ -69,13 +73,22 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip) |
69 | 73 |
|
70 | 74 |
/* exec routing script */ |
71 | 75 |
DBG("preparing to run routing scripts...\n"); |
76 |
+#ifdef STATS |
|
77 |
+ gettimeofday( & tvb, &tz ); |
|
78 |
+#endif |
|
72 | 79 |
if (run_actions(rlist[0], msg)<0){ |
73 | 80 |
LOG(L_WARN, "WARNING: receive_msg: " |
74 | 81 |
"error while trying script\n"); |
75 | 82 |
goto error; |
76 | 83 |
} |
77 |
- DBG("succesfully ran routing scripts...\n"); |
|
84 |
+#ifdef STATS |
|
85 |
+ gettimeofday( & tve, &tz ); |
|
86 |
+ diff = (tve.tv_sec-tvb.tv_sec)*1000000+(tve.tv_usec-tvb.tv_usec); |
|
87 |
+ stats->processed_requests++; |
|
88 |
+ stats->acc_req_time += diff; |
|
89 |
+ DBG("succesfully ran routing scripts...(%d usec)\n", diff); |
|
78 | 90 |
STATS_RX_REQUEST( msg->first_line.u.request.method_value ); |
91 |
+#endif |
|
79 | 92 |
}else if (msg->first_line.type==SIP_REPLY){ |
80 | 93 |
DBG("msg= reply\n"); |
81 | 94 |
/* sanity checks */ |
... | ... |
@@ -91,7 +104,10 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip) |
91 | 104 |
} |
92 | 105 |
/* check if via1 == us */ |
93 | 106 |
|
107 |
+#ifdef STATS |
|
108 |
+ gettimeofday( & tvb, &tz ); |
|
94 | 109 |
STATS_RX_RESPONSE ( msg->first_line.u.reply.statusclass ); |
110 |
+#endif |
|
95 | 111 |
|
96 | 112 |
/* send the msg */ |
97 | 113 |
if (forward_reply(msg)==0){ |
... | ... |
@@ -99,6 +115,13 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip) |
99 | 115 |
msg->via2->host.s, |
100 | 116 |
(unsigned short) msg->via2->port); |
101 | 117 |
} |
118 |
+#ifdef STATS |
|
119 |
+ gettimeofday( & tve, &tz ); |
|
120 |
+ diff = (tve.tv_sec-tvb.tv_sec)*1000000+(tve.tv_usec-tvb.tv_usec); |
|
121 |
+ stats->processed_responses++; |
|
122 |
+ stats->acc_res_time+=diff; |
|
123 |
+ DBG("succesfully ran reply processing...(%d usec)\n", diff); |
|
124 |
+#endif |
|
102 | 125 |
} |
103 | 126 |
#ifdef STATS |
104 | 127 |
skipped = 0; |
... | ... |
@@ -8,9 +8,10 @@ debug=1 # debug level (cmd line: -dddddddddd) |
8 | 8 |
check_via=yes # (cmd. line: -v) |
9 | 9 |
dns=on # (cmd. line: -r) |
10 | 10 |
rev_dns=yes # (cmd. line: -R) |
11 |
-fork=yes # (cmd. line: -D) |
|
11 |
+#fork=yes # (cmd. line: -D) |
|
12 |
+fork=no |
|
12 | 13 |
children=16 |
13 |
-#log_stderror=yes # (cmd line: -E) |
|
14 |
+log_stderror=yes # (cmd line: -E) |
|
14 | 15 |
log_stderror=no # (cmd line: -E) |
15 | 16 |
port=5080 |
16 | 17 |
#listen=127.0.0.1 |
... | ... |
@@ -4,7 +4,7 @@ |
4 | 4 |
# |
5 | 5 |
|
6 | 6 |
|
7 |
-debug=9 # debug level (cmd line: -dddddddddd) |
|
7 |
+debug=3 # debug level (cmd line: -dddddddddd) |
|
8 | 8 |
log_stderror=yes # (cmd line: -E) |
9 | 9 |
check_via=yes # (cmd. line: -v) |
10 | 10 |
dns=on # (cmd. line: -r) |
... | ... |
@@ -20,7 +20,12 @@ loop_checks=1 |
20 | 20 |
loadmodule "modules/print/print.so" |
21 | 21 |
#loadmodule "modules/tm/tm.so" |
22 | 22 |
|
23 |
-route{ |
|
23 |
+route[0] { |
|
24 |
+ forward(195.37.78.146, 5060); |
|
25 |
+ drop; |
|
26 |
+} |
|
27 |
+ |
|
28 |
+route[1]{ |
|
24 | 29 |
if ( t_lookup_request()) { |
25 | 30 |
if ( method=="ACK" ) { |
26 | 31 |
t_release(); |