source: tools/tracereport/tos_report.c @ 28df3e6

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 28df3e6 was e3b0188, checked in by Daniel Lawson <dlawson@…>, 16 years ago

a lot of changes for cross-compilation support

  • header ordering
  • os-specific headers
  • an lt_inttypes.h which defines PRIu64 etc for platforms that don't have them
  • removed daglegacy.h, merged with dagformat.h
  • Property mode set to 100644
File size: 703 bytes
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
8static stat_t tos_stat[256] = { {0,0} } ;
9
10void tos_per_packet(struct libtrace_packet_t *packet)
11{
12        struct libtrace_ip *ip = trace_get_ip(packet);
13        if (!ip)
14                return;
15
16        tos_stat[ip->ip_tos].count++;
17        tos_stat[ip->ip_tos].bytes+=trace_get_wire_length(packet);
18}
19
20void tos_report(void)
21{
22        int i;
23        printf("# TOS breakdown:\n");
24        printf("%-20s \t%12s\t%12s\n","ToS","bytes","packets");
25        for(i=0;i<256;++i) {
26                if (tos_stat[i].count==0)
27                        continue;
28                printf("%16s0x%02x:\t%12" PRIu64 ":\t%12" PRIu64 "\n",
29                                " ",
30                                i,
31                                tos_stat[i].bytes,
32                                tos_stat[i].count);
33        }
34}
Note: See TracBrowser for help on using the repository browser.