source: tools/tracereport/error_report.c @ f3576f5

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since f3576f5 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.2 KB
RevLine 
[d3ff1fb]1#include <netdb.h>
2#include <inttypes.h>
[e3b0188]3#include <lt_inttypes.h>
[d3ff1fb]4#include <stdio.h>
5#include "libtrace.h"
6#include "tracereport.h"
7
8static uint64_t rx_errors = 0;
9static uint64_t ip_errors = 0;
[49ce177]10static uint64_t tcp_errors = 0;
[d3ff1fb]11
12void error_per_packet(struct libtrace_packet_t *packet)
13{
14        struct libtrace_ip *ip = trace_get_ip(packet);
[49ce177]15        struct libtrace_tcp *tcp = trace_get_tcp(packet);
[d3ff1fb]16        void *link = trace_get_link(packet);
17        if (!link) {
18                ++rx_errors;
19        }
[a1b899f]20       
21        /* This isn't quite as simple as it seems.
22         *
23         * If the packets were captured via wdcap's anonymisation module,
[e991529]24         * the checksum is set to 0 when it is correct and 1 if incorrect.
[a1b899f]25         *
26         * If a different capture method is used, there's a good chance the
27         * checksum has not been altered
28         */
[d3ff1fb]29        if (ip) {
30                if (ntohs(ip->ip_sum)!=0)
31                        ++ip_errors;
32        }
[49ce177]33        if (tcp) {
34                if (ntohs(tcp->check)!=0)
35                        ++tcp_errors;
36        }
[d3ff1fb]37}
38
39void error_report(void)
40{
[bd4bec9]41        FILE *out = fopen("error.rpt", "w");
[e991529]42        if (!out) {
43                perror("fopen");
44                return;
45        }
46       
47        fprintf(out, "RX Errors: %" PRIu64 "\n",rx_errors);
48        fprintf(out, "IP Checksum errors: %" PRIu64 "\n",ip_errors);
[853603a]49        /*printf("TCP Checksum errors: %" PRIu64 "\n",tcp_errors); */
[e991529]50
51        fclose(out);
[d3ff1fb]52}
Note: See TracBrowser for help on using the repository browser.