4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since a7282fb was
a7282fb,
checked in by Perry Lorier <perry@…>, 16 years ago
|
Fix lots of little warnings
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[d3ff1fb] | 1 | #include <netdb.h> |
---|
| 2 | #include <inttypes.h> |
---|
[e3b0188] | 3 | #include <lt_inttypes.h> |
---|
[d3ff1fb] | 4 | #include <stdio.h> |
---|
| 5 | #include <stdlib.h> |
---|
| 6 | #include "libtrace.h" |
---|
| 7 | #include "tracereport.h" |
---|
[49ce177] | 8 | #include "contain.h" |
---|
[a7282fb] | 9 | #include "report.h" |
---|
[d3ff1fb] | 10 | |
---|
| 11 | static uint64_t flow_count=0; |
---|
| 12 | |
---|
| 13 | struct fivetuple_t { |
---|
| 14 | uint32_t ipa; |
---|
| 15 | uint32_t ipb; |
---|
| 16 | uint16_t porta; |
---|
| 17 | uint16_t portb; |
---|
| 18 | uint8_t prot; |
---|
| 19 | }; |
---|
| 20 | |
---|
[49ce177] | 21 | static int fivetuplecmp(struct fivetuple_t a, struct fivetuple_t b) |
---|
[d3ff1fb] | 22 | { |
---|
[49ce177] | 23 | if (a.porta != b.porta) return a.porta-b.porta; |
---|
| 24 | if (a.portb != b.portb) return a.portb-b.portb; |
---|
| 25 | if (a.ipa != b.ipa) return a.ipa-b.ipa; |
---|
| 26 | if (a.ipb != b.ipb) return a.ipb-b.ipb; |
---|
| 27 | return a.prot - b.prot; |
---|
[d3ff1fb] | 28 | } |
---|
| 29 | |
---|
[49ce177] | 30 | SET_CREATE(flowset,struct fivetuple_t,fivetuplecmp) |
---|
| 31 | |
---|
[d3ff1fb] | 32 | void flow_per_packet(struct libtrace_packet_t *packet) |
---|
| 33 | { |
---|
| 34 | struct libtrace_ip *ip = trace_get_ip(packet); |
---|
[49ce177] | 35 | struct fivetuple_t ft; |
---|
[d3ff1fb] | 36 | if (!ip) |
---|
| 37 | return; |
---|
[49ce177] | 38 | ft.ipa=ip->ip_src.s_addr; |
---|
| 39 | ft.ipb=ip->ip_dst.s_addr; |
---|
| 40 | ft.porta=trace_get_source_port(packet); |
---|
| 41 | ft.portb=trace_get_destination_port(packet); |
---|
| 42 | |
---|
| 43 | if (!SET_CONTAINS(flowset,ft)) { |
---|
| 44 | SET_INSERT(flowset,ft); |
---|
| 45 | flow_count++; |
---|
[d3ff1fb] | 46 | } |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | void flow_report(void) |
---|
| 50 | { |
---|
| 51 | printf("# Flows:\n"); |
---|
| 52 | printf("Flows: %" PRIu64 "\n",flow_count); |
---|
| 53 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.