4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 41816bf was
938dbd9,
checked in by Perry Lorier <perry@…>, 16 years ago
|
Move to being IPv{4,6} independant
|
-
Property mode set to
100644
|
File size:
973 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 | #include "report.h" |
---|
8 | |
---|
9 | static stat_t prot_stat[256] = { {0,0} } ; |
---|
10 | |
---|
11 | void protocol_per_packet(struct libtrace_packet_t *packet) |
---|
12 | { |
---|
13 | uint8_t proto; |
---|
14 | if (trace_get_transport(packet,&proto,NULL)==NULL) |
---|
15 | return; |
---|
16 | |
---|
17 | prot_stat[proto].count++; |
---|
18 | prot_stat[proto].bytes+=trace_get_wire_length(packet); |
---|
19 | } |
---|
20 | |
---|
21 | void protocol_report(void) |
---|
22 | { |
---|
23 | int i; |
---|
24 | printf("# Protocol breakdown:\n"); |
---|
25 | printf("%-20s \t%12s\t%12s\n","Protocol","bytes","packets"); |
---|
26 | setprotoent(1); |
---|
27 | for(i=0;i<256;++i) { |
---|
28 | struct protoent *prot; |
---|
29 | if (prot_stat[i].count==0) |
---|
30 | continue; |
---|
31 | prot = getprotobynumber(i); |
---|
32 | if (prot) { |
---|
33 | printf("%20s:\t%12" PRIu64 "\t%12" PRIu64 "\n", |
---|
34 | prot->p_name, |
---|
35 | prot_stat[i].bytes, |
---|
36 | prot_stat[i].count); |
---|
37 | } |
---|
38 | else { |
---|
39 | printf("%20i:\t%12" PRIu64 "\t%12" PRIu64 "\n", |
---|
40 | i, |
---|
41 | prot_stat[i].bytes, |
---|
42 | prot_stat[i].count); |
---|
43 | |
---|
44 | } |
---|
45 | } |
---|
46 | setprotoent(0); |
---|
47 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.