4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 40f19df was
466aed6,
checked in by Perry Lorier <perry@…>, 15 years ago
|
Flag functions as static if they're not actually used.
Include report.h too to make sure that functions have the right prototypes
|
-
Property mode set to
100644
|
File size:
1.4 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 | #include "report.h" |
---|
8 | |
---|
9 | static stat_t tos_stat[3][256] = {{{0,0}}} ; |
---|
10 | static bool suppress[3] = {true,true,true}; |
---|
11 | |
---|
12 | void tos_per_packet(struct libtrace_packet_t *packet) |
---|
13 | { |
---|
14 | struct libtrace_ip *ip = trace_get_ip(packet); |
---|
15 | libtrace_direction_t dir = trace_get_direction(packet); |
---|
16 | |
---|
17 | if (!ip) |
---|
18 | return; |
---|
19 | |
---|
20 | if (dir != TRACE_DIR_INCOMING && dir != TRACE_DIR_OUTGOING) |
---|
21 | dir = TRACE_DIR_OTHER; |
---|
22 | |
---|
23 | tos_stat[dir][ip->ip_tos].count++; |
---|
24 | tos_stat[dir][ip->ip_tos].bytes+=trace_get_wire_length(packet); |
---|
25 | suppress[dir] = false; |
---|
26 | } |
---|
27 | |
---|
28 | |
---|
29 | void tos_report(void) |
---|
30 | { |
---|
31 | int i,j; |
---|
32 | FILE *out = fopen("tos.rpt", "w"); |
---|
33 | if (!out) { |
---|
34 | perror("fopen"); |
---|
35 | return; |
---|
36 | } |
---|
37 | |
---|
38 | fprintf(out, "%-12s\t%10s\t%16s %16s\n", |
---|
39 | "TOS", |
---|
40 | "DIRECTION", |
---|
41 | "BYTES", |
---|
42 | "PACKETS"); |
---|
43 | |
---|
44 | |
---|
45 | for(i=0;i<256;++i) { |
---|
46 | if (tos_stat[0][i].count==0 && |
---|
47 | tos_stat[1][i].count==0 && tos_stat[2][i].count==0) |
---|
48 | continue; |
---|
49 | fprintf(out, "%12i:",i); |
---|
50 | for(j=0;j<3;j++){ |
---|
51 | if (j != 0) { |
---|
52 | fprintf(out, "%12s", " "); |
---|
53 | } |
---|
54 | switch(j) { |
---|
55 | case 0: |
---|
56 | fprintf(out, "\t%10s", "Outbound"); |
---|
57 | break; |
---|
58 | case 1: |
---|
59 | fprintf(out, "\t%10s", "Inbound"); |
---|
60 | break; |
---|
61 | case 2: |
---|
62 | fprintf(out, "\t%10s", "Unknown"); |
---|
63 | break; |
---|
64 | } |
---|
65 | fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", |
---|
66 | tos_stat[j][i].bytes, |
---|
67 | tos_stat[j][i].count); |
---|
68 | } |
---|
69 | } |
---|
70 | fclose(out); |
---|
71 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.