... | ... |
@@ -99,10 +99,10 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \ |
99 | 99 |
-DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \ |
100 | 100 |
-DUSE_IPV6 \ |
101 | 101 |
-DEXTRA_DEBUG \ |
102 |
- -DDBG_QM_MALLOC \ |
|
102 |
+ -DVQ_MALLOC -DDBG_QM_MALLOC \ |
|
103 |
+ #-DF_MALLOC \ |
|
103 | 104 |
#-DVQ_MALLOC |
104 | 105 |
#-DCONTACT_BUG |
105 |
- #-DF_MALLOC \ |
|
106 | 106 |
#-DDBG_LOCK |
107 | 107 |
#-DNO_DEBUG \ |
108 | 108 |
#-DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=0 \ |
... | ... |
@@ -18,6 +18,7 @@ |
18 | 18 |
#include <fcntl.h> |
19 | 19 |
#include <signal.h> |
20 | 20 |
#include <string.h> |
21 |
+#include <time.h> |
|
21 | 22 |
#include "dprint.h" |
22 | 23 |
#include "ut.h" |
23 | 24 |
#include "error.h" |
... | ... |
@@ -38,6 +39,9 @@ static FILE *fifo_stream; |
38 | 39 |
/* list of fifo command */ |
39 | 40 |
static struct fifo_command *cmd_list=0; |
40 | 41 |
|
42 |
+/* up time */ |
|
43 |
+static time_t up_since; |
|
44 |
+ |
|
41 | 45 |
static struct fifo_command *lookup_fifo_cmd( char *name ) |
42 | 46 |
{ |
43 | 47 |
struct fifo_command *c; |
... | ... |
@@ -188,12 +192,30 @@ static char *trim_filename( char * file ) |
188 | 192 |
return new_fn; |
189 | 193 |
} |
190 | 194 |
|
195 |
+FILE *open_reply_pipe( char *pipe_name ) |
|
196 |
+{ |
|
197 |
+ FILE *file_handle; |
|
198 |
+ |
|
199 |
+ if (!pipe_name) { |
|
200 |
+ DBG("DEBUG: open_reply_pipe: no file to write to about missing cmd\n"); |
|
201 |
+ return 0; |
|
202 |
+ } |
|
203 |
+ file_handle=fopen( pipe_name, "w"); |
|
204 |
+ if (file_handle==NULL) { |
|
205 |
+ LOG(L_ERR, "ERROR: open_reply_pipe: open error (%s): %s\n", |
|
206 |
+ pipe_name, strerror(errno)); |
|
207 |
+ return 0; |
|
208 |
+ } |
|
209 |
+ return file_handle; |
|
210 |
+} |
|
211 |
+ |
|
191 | 212 |
static void fifo_server(FILE *fifo_stream) |
192 | 213 |
{ |
193 | 214 |
char buf[MAX_FIFO_COMMAND]; |
194 | 215 |
int line_len; |
195 | 216 |
char *file_sep, *command, *file; |
196 | 217 |
struct fifo_command *f; |
218 |
+ FILE *file_handle; |
|
197 | 219 |
|
198 | 220 |
file_sep=command=file=0; |
199 | 221 |
|
... | ... |
@@ -208,7 +230,7 @@ static void fifo_server(FILE *fifo_stream) |
208 | 230 |
goto consume; |
209 | 231 |
} |
210 | 232 |
if (line_len==0) { |
211 |
- LOG(L_ERR, "ERROR: fifo_server: command empty\n"); |
|
233 |
+ LOG(L_INFO, "INFO: fifo_server: command empty\n"); |
|
212 | 234 |
continue; |
213 | 235 |
} |
214 | 236 |
if (line_len<3) { |
... | ... |
@@ -246,11 +268,31 @@ static void fifo_server(FILE *fifo_stream) |
246 | 268 |
if (f==0) { |
247 | 269 |
LOG(L_ERR, "ERROR: fifo_server: command %s is not available\n", |
248 | 270 |
command); |
271 |
+ file_handle=open_reply_pipe(file); |
|
272 |
+ if (file_handle==0) { |
|
273 |
+ LOG(L_ERR, "ERROR: fifo_server: no reply pipe\n"); |
|
274 |
+ goto consume; |
|
275 |
+ } |
|
276 |
+ if (fprintf(file_handle, "[%s not available]\n", command)<=0) { |
|
277 |
+ LOG(L_ERR, "ERROR: fifo_server: write error: %s\n", |
|
278 |
+ strerror(errno)); |
|
279 |
+ } |
|
280 |
+ fclose(file_handle); |
|
249 | 281 |
goto consume; |
250 | 282 |
} |
251 | 283 |
if (f->f(fifo_stream, file)<0) { |
252 | 284 |
LOG(L_ERR, "ERROR: fifo_server: command (%s) " |
253 | 285 |
"processing failed\n", command ); |
286 |
+ file_handle=open_reply_pipe(file); |
|
287 |
+ if (file_handle==0) { |
|
288 |
+ LOG(L_ERR, "ERROR: fifo_server: no reply pipe\n"); |
|
289 |
+ goto consume; |
|
290 |
+ } |
|
291 |
+ if (fprintf(file_handle, "[%s failed]\n", command)<=0) { |
|
292 |
+ LOG(L_ERR, "ERROR: fifo_server: write error: %s\n", |
|
293 |
+ strerror(errno)); |
|
294 |
+ } |
|
295 |
+ fclose(file_handle); |
|
254 | 296 |
goto consume; |
255 | 297 |
} |
256 | 298 |
|
... | ... |
@@ -273,6 +315,7 @@ int open_fifo_server() |
273 | 315 |
strerror(errno)); |
274 | 316 |
return -1; |
275 | 317 |
} |
318 |
+ time(&up_since); |
|
276 | 319 |
process_no++; |
277 | 320 |
fifo_pid=fork(); |
278 | 321 |
if (fifo_pid<0) { |
... | ... |
@@ -311,7 +354,7 @@ int open_fifo_server() |
311 | 354 |
} |
312 | 355 |
|
313 | 356 |
/* diagnostic and hello-world FIFO command */ |
314 |
-int print_fifo_cmd( FILE *stream, char *response_file ) |
|
357 |
+static int print_fifo_cmd( FILE *stream, char *response_file ) |
|
315 | 358 |
{ |
316 | 359 |
char text[MAX_PRINT_TEXT]; |
317 | 360 |
int text_len; |
... | ... |
@@ -343,3 +386,42 @@ int print_fifo_cmd( FILE *stream, char *response_file ) |
343 | 386 |
} |
344 | 387 |
return 1; |
345 | 388 |
} |
389 |
+ |
|
390 |
+static int uptime_fifo_cmd( FILE *stream, char *response_file ) |
|
391 |
+{ |
|
392 |
+ FILE *file; |
|
393 |
+ time_t now; |
|
394 |
+ |
|
395 |
+ if (response_file==0 || *response_file==0 ) { |
|
396 |
+ LOG(L_ERR, "ERROR: uptime_fifo_cmd: null file\n"); |
|
397 |
+ return -1; |
|
398 |
+ } |
|
399 |
+ file=fopen(response_file, "w" ); |
|
400 |
+ if (file==NULL) { |
|
401 |
+ LOG(L_ERR, "ERROR: uptime_fifo_cmd: file %s bad: %s\n", |
|
402 |
+ response_file, strerror(errno) ); |
|
403 |
+ return -1; |
|
404 |
+ } |
|
405 |
+ |
|
406 |
+ time(&now); |
|
407 |
+ fprintf(file, "Now: %s", ctime(&now) ); |
|
408 |
+ fprintf(file, "Up since: %s", ctime(&up_since) ); |
|
409 |
+ fprintf(file, "Up time: %.0f [sec]\n", difftime(now, up_since)); |
|
410 |
+ |
|
411 |
+ fclose(file); |
|
412 |
+ return 1; |
|
413 |
+} |
|
414 |
+ |
|
415 |
+ |
|
416 |
+int register_core_fifo() |
|
417 |
+{ |
|
418 |
+ if (register_fifo_cmd(print_fifo_cmd, FIFO_PRINT, 0)<0) { |
|
419 |
+ LOG(L_CRIT, "unable to register 'print' FIFO cmd\n"); |
|
420 |
+ return -1; |
|
421 |
+ } |
|
422 |
+ if (register_fifo_cmd(uptime_fifo_cmd, FIFO_UPTIME, 0)<0) { |
|
423 |
+ LOG(L_CRIT, "unable to register 'print' FIFO cmd\n"); |
|
424 |
+ return -1; |
|
425 |
+ } |
|
426 |
+ return 1; |
|
427 |
+} |
... | ... |
@@ -10,6 +10,10 @@ |
10 | 10 |
|
11 | 11 |
#define CMD_SEPARATOR ':' |
12 | 12 |
|
13 |
+/* core FIFO command set */ |
|
14 |
+#define FIFO_PRINT "print" |
|
15 |
+#define FIFO_UPTIME "uptime" |
|
16 |
+ |
|
13 | 17 |
typedef int (fifo_cmd)( FILE *fifo_stream, char *response_file ); |
14 | 18 |
|
15 | 19 |
struct fifo_command{ |
... | ... |
@@ -30,5 +34,9 @@ int read_line_set(char *buf, int max_len, FILE *fifo, int *len); |
30 | 34 |
|
31 | 35 |
int open_fifo_server(); |
32 | 36 |
|
33 |
-int print_fifo_cmd( FILE *stream, char *response_file ); |
|
37 |
+/* regsiter core FIFO command set */ |
|
38 |
+int register_core_fifo(); |
|
39 |
+ |
|
40 |
+FILE *open_reply_pipe( char *pipe_name ); |
|
41 |
+ |
|
34 | 42 |
#endif |
... | ... |
@@ -874,8 +874,8 @@ int main(int argc, char** argv) |
874 | 874 |
} |
875 | 875 |
|
876 | 876 |
/* register a diagnostic FIFO command */ |
877 |
- if (register_fifo_cmd(print_fifo_cmd, "print", 0)<0) { |
|
878 |
- LOG(L_CRIT, "unable to register 'print' FIFO cmd\n"); |
|
877 |
+ if (register_core_fifo()<0) { |
|
878 |
+ LOG(L_CRIT, "unable to register core FIFO commands\n"); |
|
879 | 879 |
goto error; |
880 | 880 |
} |
881 | 881 |
|
... | ... |
@@ -23,6 +23,11 @@ |
23 | 23 |
(_d) += (_len);\ |
24 | 24 |
}while(0); |
25 | 25 |
|
26 |
+#define append_str(_p,_str) \ |
|
27 |
+ do{ \ |
|
28 |
+ memcpy((_p), (_str).s, (_str).len); \ |
|
29 |
+ (_p)+=(_str).len; \ |
|
30 |
+ } while(0); |
|
26 | 31 |
|
27 | 32 |
/* Build a local request based on a previous request; main |
28 | 33 |
customers of this function are local ACK and local CANCEL |
... | ... |
@@ -20,41 +20,33 @@ struct t_stats *cur_stats, *acc_stats; |
20 | 20 |
|
21 | 21 |
int print_stats( FILE *f ) |
22 | 22 |
{ |
23 |
- time_t now; |
|
24 |
- |
|
25 |
- time(&now); |
|
26 |
- |
|
27 |
- fprintf(f, "Time:\n----------------\n"); |
|
28 |
- fprintf(f, "Now: %s", ctime(&now)); |
|
29 |
- fprintf(f, "Up since: %s", ctime(&acc_stats->up_since)); |
|
30 |
- fprintf(f, "Up time: %.0f [sec]\n", difftime(now, acc_stats->up_since)); |
|
31 |
- fprintf(f, "\nCurrent values:\n----------------\n"); |
|
32 |
- fprintf(f, "# of transactions: %d\n", |
|
23 |
+ fprintf(f, "Current:\n"); |
|
24 |
+ fprintf(f, "# of transactions: %d, ", |
|
33 | 25 |
cur_stats->transactions ); |
34 |
- fprintf(f, " - local: %d\n", |
|
26 |
+ fprintf(f, "local: %d, ", |
|
35 | 27 |
cur_stats->client_transactions ); |
36 |
- fprintf(f, " - waiting: %d\n", |
|
28 |
+ fprintf(f, "waiting: %d\n", |
|
37 | 29 |
cur_stats->waiting ); |
38 | 30 |
|
39 |
- fprintf(f, "\nCummulative values:\n----------------\n"); |
|
40 |
- fprintf(f, "# of transactions: %d\n", |
|
31 |
+ fprintf(f, "Total:\n"); |
|
32 |
+ fprintf(f, "# of transactions: %d,", |
|
41 | 33 |
acc_stats->transactions ); |
42 |
- fprintf(f, " - local: %d\n", |
|
34 |
+ fprintf(f, " local: %d,", |
|
43 | 35 |
acc_stats->client_transactions ); |
44 |
- fprintf(f, " - waiting: %d\n", |
|
36 |
+ fprintf(f, " waiting: %d\n", |
|
45 | 37 |
acc_stats->waiting ); |
46 | 38 |
|
47 | 39 |
fprintf(f, "Replied localy: %d\n", |
48 | 40 |
acc_stats->replied_localy ); |
49 |
- fprintf(f, "Completion status 6xx: %d\n", |
|
41 |
+ fprintf(f, "Completion status 6xx: %d,", |
|
50 | 42 |
acc_stats->completed_6xx ); |
51 |
- fprintf(f, "Completion status 5xx: %d\n", |
|
43 |
+ fprintf(f, " 5xx: %d,", |
|
52 | 44 |
acc_stats->completed_5xx ); |
53 |
- fprintf(f, "Completion status 4xx: %d\n", |
|
45 |
+ fprintf(f, " 4xx: %d,", |
|
54 | 46 |
acc_stats->completed_4xx ); |
55 |
- fprintf(f, "Completion status 3xx: %d\n", |
|
47 |
+ fprintf(f, " 3xx: %d,", |
|
56 | 48 |
acc_stats->completed_3xx ); |
57 |
- fprintf(f, "Completion status 2xx: %d\n", |
|
49 |
+ fprintf(f, "2xx: %d\n", |
|
58 | 50 |
acc_stats->completed_2xx ); |
59 | 51 |
|
60 | 52 |
return 1; |
... | ... |
@@ -82,7 +74,7 @@ int static fifo_stats( FILE *pipe, char *response_file ) |
82 | 74 |
|
83 | 75 |
} |
84 | 76 |
|
85 |
-int init_stats(void) |
|
77 |
+int init_tm_stats(void) |
|
86 | 78 |
{ |
87 | 79 |
cur_stats=shm_malloc(sizeof(struct t_stats)); |
88 | 80 |
if (cur_stats==0) { |
... | ... |
@@ -103,6 +95,5 @@ int init_stats(void) |
103 | 95 |
|
104 | 96 |
memset(cur_stats, 0, sizeof(struct t_stats) ); |
105 | 97 |
memset(acc_stats, 0, sizeof(struct t_stats) ); |
106 |
- time(&acc_stats->up_since); |
|
107 | 98 |
return 1; |
108 | 99 |
} |
... | ... |
@@ -7,7 +7,6 @@ |
7 | 7 |
#ifndef _T_STATS_H |
8 | 8 |
#define _T_STATS_H |
9 | 9 |
|
10 |
-#include <time.h> |
|
11 | 10 |
|
12 | 11 |
extern struct t_stats *cur_stats, *acc_stats; |
13 | 12 |
|
... | ... |
@@ -22,9 +21,8 @@ struct t_stats { |
22 | 21 |
unsigned int completed_3xx, completed_4xx, completed_5xx, |
23 | 22 |
completed_6xx, completed_2xx; |
24 | 23 |
unsigned int replied_localy; |
25 |
- time_t up_since; |
|
26 | 24 |
}; |
27 | 25 |
|
28 |
-int init_stats(void); |
|
26 |
+int init_tm_stats(void); |
|
29 | 27 |
|
30 | 28 |
#endif |
... | ... |
@@ -105,12 +105,42 @@ prompt_pw() { |
105 | 105 |
|
106 | 106 |
# $1 = name $2=path $3=attempt |
107 | 107 |
print_stats() { |
108 |
-echo "[cycle: $3; if screen empty, make sure server is alive]" |
|
108 |
+ |
|
109 |
+echo "[cycle: $3; if screen empty, make sure server is alive and option fifo is set]" |
|
110 |
+ |
|
111 |
+echo Up Time |
|
112 |
+cat > $SER_FIFO <<EOF |
|
113 |
+ |
|
114 |
+:uptime:$1 |
|
115 |
+EOF |
|
116 |
+cat < $2 |
|
117 |
+echo |
|
118 |
+ |
|
119 |
+echo Transaction Statistics |
|
109 | 120 |
cat > $SER_FIFO <<EOF |
110 | 121 |
|
111 | 122 |
:t_stats:$1 |
112 | 123 |
EOF |
113 | 124 |
cat < $2 |
125 |
+echo |
|
126 |
+ |
|
127 |
+echo Stateless Server Statistics |
|
128 |
+cat > $SER_FIFO <<EOF |
|
129 |
+ |
|
130 |
+:sl_stats:$1 |
|
131 |
+EOF |
|
132 |
+cat < $2 |
|
133 |
+echo |
|
134 |
+ |
|
135 |
+echo UsrLoc Stats |
|
136 |
+cat > $SER_FIFO <<EOF |
|
137 |
+ |
|
138 |
+:ul_stats:$1 |
|
139 |
+EOF |
|
140 |
+cat < $2 |
|
141 |
+echo |
|
142 |
+ |
|
143 |
+ |
|
114 | 144 |
} |
115 | 145 |
|
116 | 146 |
|
... | ... |
@@ -385,7 +415,7 @@ case $1 in |
385 | 415 |
fi |
386 | 416 |
;; |
387 | 417 |
|
388 |
- stats) |
|
418 |
+ monitor|console|moni|con) |
|
389 | 419 |
name=ser_receiver_$$ |
390 | 420 |
path=/tmp/$name |
391 | 421 |
if [ ! -w $SER_FIFO ]; then |
... | ... |
@@ -399,9 +429,11 @@ case $1 in |
399 | 429 |
exit 1 |
400 | 430 |
fi |
401 | 431 |
attempt=0 |
432 |
+ clear |
|
402 | 433 |
while [ 1 -eq 1 ]; do |
403 | 434 |
attempt=`expr $attempt + 1` |
404 |
- clear |
|
435 |
+ #clear |
|
436 |
+ tput cup 0 0 |
|
405 | 437 |
print_stats $name $path $attempt |
406 | 438 |
sleep $WATCH_PERIOD |
407 | 439 |
done |
... | ... |
@@ -1,11 +1,10 @@ |
1 | 1 |
MESSAGE sip:756843@iptel.org SIP/2.0 |
2 |
-Via: SIP/2.0/UDP fox.iptel.org:5060 |
|
2 |
+Via: SIP/2.0/UDP bat.iptel.org:9 |
|
3 | 3 |
From: "bogdan" <sip:bogdan@iptel.org>;tag=0e99b1e7-ff50-4875-94ef-4ca5c27e2705 |
4 |
-To: |
|
5 |
-Call-ID: 02b1191c-447e-4bd0-b771-c039fc0d9d84@195.37.78.169 |
|
4 |
+xCall-ID: 02b1191c-447e-4bd0-b771-c039fc0d9d84@195.37.78.169 |
|
6 | 5 |
CSeq: 7 MESSAGE |
7 | 6 |
Contact: <sip:195.37.78.169:11457> |
8 | 7 |
User-Agent: Windows RTC/1.0 |
9 |
-Content-Type: text/plain |
|
8 |
+text/plain |
|
10 | 9 |
Content-Length: 4 |
11 | 10 |
|
... | ... |
@@ -1,5 +1,5 @@ |
1 |
-MESSAGE sip:jiri@iptel.org SIP/2.0 |
|
2 |
-Via: SIP/2.0/UDP fox.iptel.org:5060 |
|
1 |
+MESSAGE sip:x@bat.iptel.org SIP/2.0 |
|
2 |
+Via: SIP/2.0/UDP bat.iptel.org:9 |
|
3 | 3 |
From: sip:msilo@iptel.org;tag=16df4fe56e8782ecaa5d53ae36fb9240 |
4 | 4 |
To: sip:dcm@iptel.org |
5 | 5 |
Call-ID: 02b1191c-447e-4bd0-b771-c039fc0d9d84@195.37.78.169 |
... | ... |
@@ -6,13 +6,14 @@ |
6 | 6 |
|
7 | 7 |
# ----------- global configuration parameters ------------------------ |
8 | 8 |
|
9 |
-debug=3 |
|
10 |
-fork=no |
|
9 |
+debug=0 |
|
10 |
+fork=1 |
|
11 | 11 |
log_stderror=yes # (cmd line: -E) |
12 | 12 |
check_via=no # (cmd. line: -v) |
13 | 13 |
dns=no # (cmd. line: -r) |
14 | 14 |
syn_branch=1 |
15 | 15 |
reply_to_via=0 |
16 |
+fifo="/tmp/ser_fifo" |
|
16 | 17 |
|
17 | 18 |
# advertise IP address in Via (as opposed to advertising DNS name |
18 | 19 |
# which is annoying for downstream servers and some phones can |
... | ... |
@@ -23,7 +24,7 @@ listen=195.37.77.100 |
23 | 24 |
|
24 | 25 |
loadmodule "../sip_router/modules/sl/sl.so" |
25 | 26 |
loadmodule "../sip_router/modules/print/print.so" |
26 |
-#loadmodule "../sip_router/modules/tm/tm.so" |
|
27 |
+#loadmodule "../sip_router/modules/tm/tm_mod.so" |
|
27 | 28 |
loadmodule "../sip_router/modules/usrloc/usrloc.so" |
28 | 29 |
|
29 | 30 |
# ----------------- setting module-specific parameters --------------- |
... | ... |
@@ -34,14 +35,22 @@ modparam("usrloc", "use_database", 0) |
34 | 35 |
modparam("usrloc", "flush_interval", 3600) |
35 | 36 |
|
36 | 37 |
# -- tm params -- |
37 |
-modparam("tm", "fr_timer", 10 ) |
|
38 |
+modparam("tm", "fr_timer", 5 ) |
|
38 | 39 |
modparam("tm", "fr_inv_timer", 5 ) |
40 |
+modparam("tm", "wt_timer", 5 ) |
|
39 | 41 |
|
40 | 42 |
# ------------------------- request routing logic ------------------- |
41 | 43 |
|
42 | 44 |
# main routing logic |
43 | 45 |
|
44 | 46 |
route{ |
47 |
+ append_branch("sip:bla@bat.iptel.org:5088"); |
|
48 |
+ append_branch("sip:blb@bat.iptel.org:5088"); |
|
49 |
+ t_on_negative("1"); |
|
45 | 50 |
t_relay_to("bat.iptel.org","5088"); |
46 | 51 |
} |
47 | 52 |
|
53 |
+reply_route[1] { |
|
54 |
+ append_branch("sip:mrx@bat.iptel.org:5088"); |
|
55 |
+} |
|
56 |
+ |