[firefly] [PATCH 6/6] lib/ofp-print: add support for printing role status messages
Alexandru Copot
alex.mihai.c at gmail.com
Tue Oct 8 11:52:34 EEST 2013
Signed-off-by: Alexandru Copot <alex.mihai.c at gmail.com>
---
lib/ofp-print.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 0feabe1..1894778 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -1886,6 +1886,56 @@ ofp_print_role_message(struct ds *string, const struct ofp_header *oh)
}
static void
+ofp_print_role_status_message(struct ds *string, const struct ofp_header *oh)
+{
+ struct ofputil_role_status rs;
+ enum ofperr error;
+
+ error = ofputil_decode_role_status(oh, &rs);
+ if (error) {
+ ofp_print_error(string, error);
+ return;
+ }
+
+ ds_put_cstr(string, "role=");
+
+ switch (rs.role) {
+ case OFPCR12_ROLE_NOCHANGE:
+ ds_put_cstr(string, "nochange");
+ break;
+ case OFPCR12_ROLE_EQUAL:
+ ds_put_cstr(string, "equal"); /* OF 1.2 wording */
+ break;
+ case OFPCR12_ROLE_MASTER:
+ ds_put_cstr(string, "master");
+ break;
+ case OFPCR12_ROLE_SLAVE:
+ ds_put_cstr(string, "slave");
+ break;
+ default:
+ NOT_REACHED();
+ }
+
+ ds_put_cstr(string, " reason=");
+
+ switch (rs.reason) {
+ case OFPCRR_MASTER_REQUEST:
+ ds_put_cstr(string, "master_request");
+ break;
+ case OFPCRR_CONFIG:
+ ds_put_cstr(string, "configuration_changed");
+ break;
+ case OFPCRR_EXPERIMENTER:
+ ds_put_cstr(string, "experimenter_data_changed");
+ break;
+ default:
+ NOT_REACHED();
+ }
+
+ ds_put_format(string, " generation_id=%"PRIu64, rs.generation_id);
+}
+
+static void
ofp_print_nxt_flow_mod_table_id(struct ds *string,
const struct nx_flow_mod_table_id *nfmti)
{
@@ -2491,6 +2541,7 @@ ofp_to_string__(const struct ofp_header *oh, enum ofpraw raw,
ofp_print_role_message(string, oh);
break;
case OFPTYPE_ROLE_STATUS:
+ ofp_print_role_status_message(string, oh);
break;
case OFPTYPE_METER_STATS_REQUEST:
--
1.8.4
More information about the firefly
mailing list