From 2da7974c77dbfd95bd5bee303d2b805cea2df253 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 7 Jan 2016 12:04:56 -0800 Subject: [PATCH] ofp-util: New function ofputil_async_msg_type_to_string(). An upcoming commit will add another user. Signed-off-by: Ben Pfaff Acked-by: Jarno Rajahalme --- lib/ofp-print.c | 27 ++------------------------- lib/ofp-util.c | 17 +++++++++++++++++ lib/ofp-util.h | 1 + 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 42e822b91d9..bf97b04aee0 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -2151,31 +2151,8 @@ ofp_print_nxt_set_async_config(struct ds *string, ds_put_format(string, "\n %s:\n", i == 0 ? "master" : "slave"); for (type = 0; type < OAM_N_TYPES; type++) { - switch (type) { - case OAM_PACKET_IN: - ds_put_cstr(string, " PACKET_IN:"); - break; - - case OAM_PORT_STATUS: - ds_put_cstr(string, " PORT_STATUS:"); - break; - - case OAM_FLOW_REMOVED: - ds_put_cstr(string, " FLOW_REMOVED:"); - break; - - case OAM_ROLE_STATUS: - ds_put_cstr(string, " ROLE_STATUS:"); - break; - - case OAM_TABLE_STATUS: - ds_put_cstr(string, " TABLE_STATUS:"); - break; - - case OAM_REQUESTFORWARD: - ds_put_cstr(string, " REQUESTFORWARD:"); - break; - } + ds_put_format(string, "%16s:", + ofputil_async_msg_type_to_string(type)); for (j = 0; j < 32; j++) { if (role[i][type] & (1u << j)) { diff --git a/lib/ofp-util.c b/lib/ofp-util.c index f1aefdd30cb..d8564c3a517 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -9467,6 +9467,23 @@ ofputil_uninit_tlv_table(struct ovs_list *mappings) } } +const char * +ofputil_async_msg_type_to_string(enum ofputil_async_msg_type type) +{ + switch (type) { + case OAM_PACKET_IN: return "PACKET_IN"; + case OAM_PORT_STATUS: return "PORT_STATUS"; + case OAM_FLOW_REMOVED: return "FLOW_REMOVED"; + case OAM_ROLE_STATUS: return "ROLE_STATUS"; + case OAM_TABLE_STATUS: return "TABLE_STATUS"; + case OAM_REQUESTFORWARD: return "REQUESTFORWARD"; + + case OAM_N_TYPES: + default: + OVS_NOT_REACHED(); + } +} + /* Decodes the OpenFlow "set async config" request and "get async config * reply" message in '*oh' into an abstract form in 'master' and 'slave'. * diff --git a/lib/ofp-util.h b/lib/ofp-util.h index 89f3d953078..1fd013dc580 100644 --- a/lib/ofp-util.h +++ b/lib/ofp-util.h @@ -1323,6 +1323,7 @@ enum ofputil_async_msg_type { OAM_REQUESTFORWARD, /* OFPT_REQUESTFORWARD. */ OAM_N_TYPES }; +const char *ofputil_async_msg_type_to_string(enum ofputil_async_msg_type); enum ofperr ofputil_decode_set_async_config(const struct ofp_header *, uint32_t master[OAM_N_TYPES],