4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 548c76b was
fbc4342,
checked in by Perry Lorier <perry@…>, 15 years ago
|
Port tools over to using the new api's
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
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 | #include "report.h" |
---|
8 | |
---|
9 | static uint64_t rx_errors = 0; |
---|
10 | static uint64_t ip_errors = 0; |
---|
11 | static uint64_t tcp_errors = 0; |
---|
12 | |
---|
13 | void error_per_packet(struct libtrace_packet_t *packet) |
---|
14 | { |
---|
15 | struct libtrace_ip *ip = trace_get_ip(packet); |
---|
16 | struct libtrace_tcp *tcp = trace_get_tcp(packet); |
---|
17 | void *link = trace_get_packet_buffer(packet,NULL,NULL); |
---|
18 | if (!link) { |
---|
19 | ++rx_errors; |
---|
20 | } |
---|
21 | |
---|
22 | /* This isn't quite as simple as it seems. |
---|
23 | * |
---|
24 | * If the packets were captured via wdcap's anonymisation module, |
---|
25 | * the checksum is set to 0 when it is correct and 1 if incorrect. |
---|
26 | * |
---|
27 | * If a different capture method is used, there's a good chance the |
---|
28 | * checksum has not been altered |
---|
29 | */ |
---|
30 | if (ip) { |
---|
31 | if (ntohs(ip->ip_sum)!=0) |
---|
32 | ++ip_errors; |
---|
33 | } |
---|
34 | if (tcp) { |
---|
35 | if (ntohs(tcp->check)!=0) |
---|
36 | ++tcp_errors; |
---|
37 | } |
---|
38 | } |
---|
39 | |
---|
40 | void error_report(void) |
---|
41 | { |
---|
42 | FILE *out = fopen("error.rpt", "w"); |
---|
43 | if (!out) { |
---|
44 | perror("fopen"); |
---|
45 | return; |
---|
46 | } |
---|
47 | |
---|
48 | fprintf(out, "RX Errors: %" PRIu64 "\n",rx_errors); |
---|
49 | fprintf(out, "IP Checksum errors: %" PRIu64 "\n",ip_errors); |
---|
50 | /*printf("TCP Checksum errors: %" PRIu64 "\n",tcp_errors); */ |
---|
51 | |
---|
52 | fclose(out); |
---|
53 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.