diff options
author | Quentin Monnet <quentin.monnet@6wind.com> | 2016-03-02 15:56:18 +0100 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2016-03-18 14:02:45 -0700 |
commit | ab8e7f7db9fae70af44cec4daf3f3e5b9cdc4de8 (patch) | |
tree | 45c52b3a42202c6621a285e9a57c7f56409c56dc /lib/ofp-print.c | |
parent | ef7b593bdd86ce9976aff3a7de985ad7dbae7ae4 (diff) | |
download | openvswitch-ab8e7f7db9fae70af44cec4daf3f3e5b9cdc4de8.tar.gz |
ovs-ofctl: Add output colors for flow attributes.
This commit adds colors to the “left part” of printed flows (to flow
properties that are always present: `cookie`, `table`, timeouts, etc.).
Signed-off-by: Quentin Monnet <quentin.monnet@6wind.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib/ofp-print.c')
-rw-r--r-- | lib/ofp-print.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 271b095b7..47b88e4cf 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -28,6 +28,7 @@ #include "bundle.h" #include "byte-order.h" +#include "colors.h" #include "compiler.h" #include "dynamic-string.h" #include "flow.h" @@ -1580,30 +1581,39 @@ ofp_print_flow_stats_request(struct ds *string, const struct ofp_header *oh) void ofp_print_flow_stats(struct ds *string, struct ofputil_flow_stats *fs) { - ds_put_format(string, " cookie=0x%"PRIx64", duration=", - ntohll(fs->cookie)); + ds_put_format(string, " %scookie=%s0x%"PRIx64", %sduration=%s", + colors.param, colors.end, ntohll(fs->cookie), + colors.param, colors.end); ofp_print_duration(string, fs->duration_sec, fs->duration_nsec); - ds_put_format(string, ", table=%"PRIu8", ", fs->table_id); - ds_put_format(string, "n_packets=%"PRIu64", ", fs->packet_count); - ds_put_format(string, "n_bytes=%"PRIu64", ", fs->byte_count); + ds_put_format(string, ", %stable=%s%"PRIu8", ", + colors.special, colors.end, fs->table_id); + ds_put_format(string, "%sn_packets=%s%"PRIu64", ", + colors.param, colors.end, fs->packet_count); + ds_put_format(string, "%sn_bytes=%s%"PRIu64", ", + colors.param, colors.end, fs->byte_count); if (fs->idle_timeout != OFP_FLOW_PERMANENT) { - ds_put_format(string, "idle_timeout=%"PRIu16", ", fs->idle_timeout); + ds_put_format(string, "%sidle_timeout=%s%"PRIu16", ", + colors.param, colors.end, fs->idle_timeout); } if (fs->hard_timeout != OFP_FLOW_PERMANENT) { - ds_put_format(string, "hard_timeout=%"PRIu16", ", fs->hard_timeout); + ds_put_format(string, "%shard_timeout=%s%"PRIu16", ", + colors.param, colors.end, fs->hard_timeout); } if (fs->flags) { ofp_print_flow_flags(string, fs->flags); } if (fs->importance != 0) { - ds_put_format(string, "importance=%"PRIu16", ", fs->importance); + ds_put_format(string, "%simportance=%s%"PRIu16", ", + colors.param, colors.end, fs->importance); } if (fs->idle_age >= 0) { - ds_put_format(string, "idle_age=%d, ", fs->idle_age); + ds_put_format(string, "%sidle_age=%s%d, ", + colors.param, colors.end, fs->idle_age); } if (fs->hard_age >= 0 && fs->hard_age != fs->duration_sec) { - ds_put_format(string, "hard_age=%d, ", fs->hard_age); + ds_put_format(string, "%shard_age=%s%d, ", + colors.param, colors.end, fs->hard_age); } match_format(&fs->match, string, fs->priority); @@ -1611,7 +1621,7 @@ ofp_print_flow_stats(struct ds *string, struct ofputil_flow_stats *fs) ds_put_char(string, ' '); } - ds_put_cstr(string, "actions="); + ds_put_format(string, "%sactions=%s", colors.actions, colors.end); ofpacts_format(fs->ofpacts, fs->ofpacts_len, string); } |