4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 870e501 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
|
Rev | Line | |
---|
[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 | #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 | { |
---|
[938dbd9] | 13 | uint8_t proto; |
---|
| 14 | if (trace_get_transport(packet,&proto,NULL)==NULL) |
---|
[d3ff1fb] | 15 | return; |
---|
[938dbd9] | 16 | |
---|
| 17 | prot_stat[proto].count++; |
---|
| 18 | prot_stat[proto].bytes+=trace_get_wire_length(packet); |
---|
[d3ff1fb] | 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.