4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since bd4bec9 was
bd4bec9,
checked in by Shane Alcock <salcock@…>, 15 years ago
|
tcpsegment, protocol and tos reports all now write to files.
Changed the output filenames to be *.rpt rather than *.out
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | #include <netdb.h> |
---|
2 | #include <inttypes.h> |
---|
3 | #include <lt_inttypes.h> |
---|
4 | #include <stdio.h> |
---|
5 | #include "libtrace.h" |
---|
6 | #include "tracereport.h" |
---|
7 | |
---|
8 | static uint64_t dir_bytes[8]; |
---|
9 | static uint64_t dir_packets[8]; |
---|
10 | |
---|
11 | void dir_per_packet(struct libtrace_packet_t *packet) |
---|
12 | { |
---|
13 | if (trace_get_direction(packet)==-1) |
---|
14 | return; |
---|
15 | dir_bytes[trace_get_direction(packet)]+=trace_get_wire_length(packet); |
---|
16 | ++dir_packets[trace_get_direction(packet)]; |
---|
17 | } |
---|
18 | |
---|
19 | void dir_report(void) |
---|
20 | { |
---|
21 | int i; |
---|
22 | FILE *out = fopen("dir.rpt", "w"); |
---|
23 | if (!out) { |
---|
24 | perror("fopen"); |
---|
25 | return; |
---|
26 | } |
---|
27 | fprintf(out, "%-20s \t%12s\t%12s\n","DIRECTION","BYTES","PACKETS"); |
---|
28 | for(i=0;i<8;++i) { |
---|
29 | if (!dir_packets[i]) |
---|
30 | continue; |
---|
31 | switch(i) { |
---|
32 | case 0: fprintf(out, "%20s:\t%12" PRIu64 "\t%12" PRIu64 "\n", |
---|
33 | "Incoming",dir_bytes[i],dir_packets[i]); |
---|
34 | break; |
---|
35 | case 1: fprintf(out, "%20s:\t%12" PRIu64 "\t%12" PRIu64 "\n", |
---|
36 | "Outgoing",dir_bytes[i],dir_packets[i]); |
---|
37 | break; |
---|
38 | default: fprintf(out, "%20i:\t%12" PRIu64 "\t%12" PRIu64 "\n", |
---|
39 | i,dir_bytes[i],dir_packets[i]); |
---|
40 | break; |
---|
41 | } |
---|
42 | } |
---|
43 | fclose(out); |
---|
44 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.