source: tools/tracereport/error_report.c @ 1ed69dc

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivendag_formatrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 1ed69dc 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.1 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 <netdb.h>
29#include <inttypes.h>
30#include <lt_inttypes.h>
31#include <stdio.h>
32#include "libtrace.h"
33#include "tracereport.h"
34#include "report.h"
35
36static uint64_t rx_errors = 0;
37static uint64_t ip_errors = 0;
38static uint64_t tcp_errors = 0;
39
40void error_per_packet(struct libtrace_packet_t *packet)
41{
42        struct libtrace_ip *ip = trace_get_ip(packet);
43        struct libtrace_tcp *tcp = trace_get_tcp(packet);
44        void *link = trace_get_packet_buffer(packet,NULL,NULL);
45        if (!link) {
46                ++rx_errors;
47        }
48       
49        /* This isn't quite as simple as it seems.
50         *
51         * If the packets were captured via wdcap's anonymisation module,
52         * the checksum is set to 0 when it is correct and 1 if incorrect.
53         *
54         * If a different capture method is used, there's a good chance the
55         * checksum has not been altered
56         */
57        if (ip) {
58                if (ntohs(ip->ip_sum)!=0)
59                        ++ip_errors;
60        }
61        if (tcp) {
62                if (ntohs(tcp->check)!=0)
63                        ++tcp_errors;
64        }
65}
66
67void error_report(void)
68{
69        FILE *out = fopen("error.rpt", "w");
70        if (!out) {
71                perror("fopen");
72                return;
73        }
74       
75        fprintf(out, "RX Errors: %" PRIu64 "\n",rx_errors);
76        fprintf(out, "IP Checksum errors: %" PRIu64 "\n",ip_errors);
77        /*printf("TCP Checksum errors: %" PRIu64 "\n",tcp_errors); */
78
79        fclose(out);
80}
Note: See TracBrowser for help on using the repository browser.