diff options
author | Ben Pfaff <blp@nicira.com> | 2011-09-29 15:36:14 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2011-09-30 08:58:10 -0700 |
commit | 572b70687b27ef6fdd1ed90d1ac932d6de35701f (patch) | |
tree | 9d648b8dfbf7e0f06ea841154f02a667d8218ac6 /lib/dpif.c | |
parent | a946b636edd932994a8972cf23168e4c08b21e8e (diff) |
flow: Move flow_extract_stats() to dpif.c, as dpif_flow_stats_extract().
The "flow" module is concerned only with OpenFlow flows these days. It
shouldn't have anything to do with ODP or dpifs. However, it included
dpif.h just to implement flow_extract_stats(). This function is a better
fit for dpif.c, so this commit moves it there and removes the dpif.h
#include from flow.h and flow.c
This commit also removes a few more dpif.h #includes that weren't needed.
Diffstat (limited to 'lib/dpif.c')
-rw-r--r-- | lib/dpif.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -661,6 +661,26 @@ dpif_port_poll_wait(const struct dpif *dpif) dpif->dpif_class->port_poll_wait(dpif); } +/* Extracts the flow stats for a packet. The 'flow' and 'packet' + * arguments must have been initialized through a call to flow_extract(). + */ +void +dpif_flow_stats_extract(const struct flow *flow, struct ofpbuf *packet, + struct dpif_flow_stats *stats) +{ + memset(stats, 0, sizeof(*stats)); + + if ((flow->dl_type == htons(ETH_TYPE_IP)) && packet->l4) { + if ((flow->nw_proto == IPPROTO_TCP) && packet->l7) { + struct tcp_header *tcp = packet->l4; + stats->tcp_flags = TCP_FLAGS(tcp->tcp_ctl); + } + } + + stats->n_bytes = packet->size; + stats->n_packets = 1; +} + /* Appends a human-readable representation of 'stats' to 's'. */ void dpif_flow_stats_format(const struct dpif_flow_stats *stats, struct ds *s) |