source: tools/tracereport/dir_report.c @ 34e22d1

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 34e22d1 was cbce651, checked in by Perry Lorier <perry@…>, 14 years ago

Squash some more warnings.

  • 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#include "report.h"
8
9static uint64_t dir_bytes[8];
10static uint64_t dir_packets[8];
11
12void 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
20void 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 0: fprintf(out, "%20s:\t%12" PRIu64 "\t%12" PRIu64 "\n",
34                                        "Incoming",dir_bytes[i],dir_packets[i]);
35                                break;
36                        case 1: fprintf(out, "%20s:\t%12" PRIu64 "\t%12" PRIu64 "\n",
37                                        "Outgoing",dir_bytes[i],dir_packets[i]);
38                                break;
39                        default: fprintf(out, "%20i:\t%12" PRIu64 "\t%12" PRIu64 "\n",
40                                        i,dir_bytes[i],dir_packets[i]);
41                                break;
42                }
43        }
44        fclose(out);
45}
Note: See TracBrowser for help on using the repository browser.