source: tools/tracereport/drops_report.c @ d74ca03

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivendag_formatrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since d74ca03 was ee6e802, checked in by Shane Alcock <salcock@…>, 5 years ago

Updated copyright blurb on all source files

In some cases, this meant adding copyright blurbs to files that
had never had them before.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *
3 * Copyright (c) 2007-2016 The University of Waikato, Hamilton, New Zealand.
4 * All rights reserved.
5 *
6 * This file is part of libtrace.
7 *
8 * This code has been developed by the University of Waikato WAND
9 * research group. For further information please see http://www.wand.net.nz/
10 *
11 * libtrace is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * libtrace is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 *
24 *
25 */
26
27
28#include <inttypes.h>
29#include <stdio.h>
30#include <stdbool.h>
31#include <time.h>
32#include <string.h>
33#include <stdlib.h>
34#include "libtrace.h"
35#include "tracereport.h"
36#include "report.h"
37
38static uint64_t received_packets = 0;
39static uint64_t filtered_packets = 0;
40static uint64_t dropped_packets = 0;
41static uint64_t accepted_packets = 0;
42
43static bool has_received=false;
44static bool has_filtered=false;
45static bool has_dropped=false;
46static bool has_accepted=false;
47
48void drops_per_trace(libtrace_t *trace)
49{
50        libtrace_stat_t *stat;
51
52        stat = trace_create_statistics();
53
54        trace_get_statistics(trace, stat);
55
56        if (stat->received_valid) {
57                received_packets+=stat->received;
58                has_received=true;
59        }
60
61        if (stat->filtered_valid) {
62                filtered_packets+=stat->filtered;
63                has_filtered=true;
64        }
65
66        if (stat->dropped_valid) {
67                dropped_packets+=stat->dropped;
68                has_dropped=true;
69        }
70
71        if (stat->accepted_valid) {
72                accepted_packets+=stat->accepted;
73                has_accepted=true;
74        }
75        free(stat);
76}
77
78
79void drops_report(void)
80{
81        FILE *out = fopen("drop.rpt", "w");
82        if (!out) {
83                perror("fopen");
84                return;
85        }
86        if (has_received)
87                fprintf(out, "Received Packets: %" PRIu64 "\n", received_packets);
88        if (has_filtered)
89                fprintf(out, "Filtered Packets: %" PRIu64 "\n", filtered_packets);
90        if (has_dropped)
91                fprintf(out, "Dropped Packets: %" PRIu64 "\n", dropped_packets);
92
93        if (has_accepted)
94                fprintf(out, "Accepted Packets: %" PRIu64 "\n", accepted_packets);
95        fclose(out);
96}
Note: See TracBrowser for help on using the repository browser.