source: tools/tracereport/dir_report.c @ a3041a4

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

Correct direction report (how embarrassing!)

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[49ce177]1#include <netdb.h>
2#include <inttypes.h>
[e3b0188]3#include <lt_inttypes.h>
[49ce177]4#include <stdio.h>
5#include "libtrace.h"
6#include "tracereport.h"
[466aed6]7#include "report.h"
[49ce177]8
9static uint64_t dir_bytes[8];
10static uint64_t dir_packets[8];
11
12void dir_per_packet(struct libtrace_packet_t *packet)
13{
[cbce651]14        if (trace_get_direction(packet)==~0U)
[3b49843]15                return;
[49ce177]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;
[bd4bec9]23        FILE *out = fopen("dir.rpt", "w");
[e991529]24        if (!out) {
25                perror("fopen");
26                return;
27        }
28        fprintf(out, "%-20s \t%12s\t%12s\n","DIRECTION","BYTES","PACKETS");
[49ce177]29        for(i=0;i<8;++i) {
30                if (!dir_packets[i])
31                        continue;
32                switch(i) {
[39aa3c7]33                        case TRACE_DIR_INCOMING: fprintf(out, "%20s:\t%12" PRIu64 "\t%12" PRIu64 "\n",
[e991529]34                                        "Incoming",dir_bytes[i],dir_packets[i]);
[49ce177]35                                break;
[39aa3c7]36                        case TRACE_DIR_OUTGOING: fprintf(out, "%20s:\t%12" PRIu64 "\t%12" PRIu64 "\n",
[e991529]37                                        "Outgoing",dir_bytes[i],dir_packets[i]);
[49ce177]38                                break;
[39aa3c7]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;
[e991529]42                        default: fprintf(out, "%20i:\t%12" PRIu64 "\t%12" PRIu64 "\n",
[49ce177]43                                        i,dir_bytes[i],dir_packets[i]);
44                                break;
45                }
46        }
[e991529]47        fclose(out);
[49ce177]48}
Note: See TracBrowser for help on using the repository browser.