4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since dd1217b was
39aa3c7,
checked in by Perry Lorier <perry@…>, 15 years ago
|
Correct direction report (how embarrassing!)
|
-
Property mode set to
100644
|
File size:
1.2 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 uint64_t dir_bytes[8]; |
---|
10 | static uint64_t dir_packets[8]; |
---|
11 | |
---|
12 | void dir_per_packet(struct libtrace_packet_t *packet) |
---|
13 | { |
---|
14 | if (trace_get_direction(packet)==~0U) |
---|
15 | return; |
---|
16 | dir_bytes[trace_get_direction(packet)]+=trace_get_wire_length(packet); |
---|
17 | ++dir_packets[trace_get_direction(packet)]; |
---|
18 | } |
---|
19 | |
---|
20 | void dir_report(void) |
---|
21 | { |
---|
22 | int i; |
---|
23 | FILE *out = fopen("dir.rpt", "w"); |
---|
24 | if (!out) { |
---|
25 | perror("fopen"); |
---|
26 | return; |
---|
27 | } |
---|
28 | fprintf(out, "%-20s \t%12s\t%12s\n","DIRECTION","BYTES","PACKETS"); |
---|
29 | for(i=0;i<8;++i) { |
---|
30 | if (!dir_packets[i]) |
---|
31 | continue; |
---|
32 | switch(i) { |
---|
33 | case TRACE_DIR_INCOMING: fprintf(out, "%20s:\t%12" PRIu64 "\t%12" PRIu64 "\n", |
---|
34 | "Incoming",dir_bytes[i],dir_packets[i]); |
---|
35 | break; |
---|
36 | case TRACE_DIR_OUTGOING: fprintf(out, "%20s:\t%12" PRIu64 "\t%12" PRIu64 "\n", |
---|
37 | "Outgoing",dir_bytes[i],dir_packets[i]); |
---|
38 | break; |
---|
39 | case TRACE_DIR_OTHER: fprintf(out, "%20s:\t%12" PRIu64 "\t%12" PRIu64 "\n", |
---|
40 | "Other",dir_bytes[i],dir_packets[i]); |
---|
41 | break; |
---|
42 | default: fprintf(out, "%20i:\t%12" PRIu64 "\t%12" PRIu64 "\n", |
---|
43 | i,dir_bytes[i],dir_packets[i]); |
---|
44 | break; |
---|
45 | } |
---|
46 | } |
---|
47 | fclose(out); |
---|
48 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.