+/* Extracts the flow stats for a packet. The 'flow' and 'packet'
+ * arguments must have been initialized through a call to flow_extract().
+ * 'used' is stored into stats->used. */
+void
+dpif_flow_stats_extract(const struct flow *flow, const struct ofpbuf *packet,
+ long long int used, struct dpif_flow_stats *stats)
+{
+ stats->tcp_flags = packet_get_tcp_flags(packet, flow);
+ stats->n_bytes = packet->size;
+ stats->n_packets = 1;
+ stats->used = used;
+}
+
+/* Appends a human-readable representation of 'stats' to 's'. */
+void
+dpif_flow_stats_format(const struct dpif_flow_stats *stats, struct ds *s)
+{
+ ds_put_format(s, "packets:%"PRIu64", bytes:%"PRIu64", used:",
+ stats->n_packets, stats->n_bytes);
+ if (stats->used) {
+ ds_put_format(s, "%.3fs", (time_msec() - stats->used) / 1000.0);
+ } else {
+ ds_put_format(s, "never");
+ }
+ if (stats->tcp_flags) {
+ ds_put_cstr(s, ", flags:");
+ packet_format_tcp_flags(s, stats->tcp_flags);
+ }
+}
+