source: tools/tracereport/dir_report.c @ bd4bec9

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
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"
7
8static uint64_t dir_bytes[8];
9static uint64_t dir_packets[8];
10
11void dir_per_packet(struct libtrace_packet_t *packet)
12{
[d4336d5]13        if (trace_get_direction(packet)==-1)
[3b49843]14                return;
[49ce177]15        dir_bytes[trace_get_direction(packet)]+=trace_get_wire_length(packet);
16        ++dir_packets[trace_get_direction(packet)];
17}
18
19void dir_report(void)
20{
21        int i;
[bd4bec9]22        FILE *out = fopen("dir.rpt", "w");
[e991529]23        if (!out) {
24                perror("fopen");
25                return;
26        }
27        fprintf(out, "%-20s \t%12s\t%12s\n","DIRECTION","BYTES","PACKETS");
[49ce177]28        for(i=0;i<8;++i) {
29                if (!dir_packets[i])
30                        continue;
31                switch(i) {
[e991529]32                        case 0: fprintf(out, "%20s:\t%12" PRIu64 "\t%12" PRIu64 "\n",
33                                        "Incoming",dir_bytes[i],dir_packets[i]);
[49ce177]34                                break;
[e991529]35                        case 1: fprintf(out, "%20s:\t%12" PRIu64 "\t%12" PRIu64 "\n",
36                                        "Outgoing",dir_bytes[i],dir_packets[i]);
[49ce177]37                                break;
[e991529]38                        default: fprintf(out, "%20i:\t%12" PRIu64 "\t%12" PRIu64 "\n",
[49ce177]39                                        i,dir_bytes[i],dir_packets[i]);
40                                break;
41                }
42        }
[e991529]43        fclose(out);
[49ce177]44}
Note: See TracBrowser for help on using the repository browser.