From: Alexander Wu Date: Fri, 17 Jan 2014 21:18:16 +0000 (-0800) Subject: ofp-actions: New function ovs_instruction_type_from_inst_type(). X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=c0621c394f09882b7d210102d0389c60b353d630;p=sliver-openvswitch.git ofp-actions: New function ovs_instruction_type_from_inst_type(). Signed-off-by: Alexander Wu Signed-off-by: Ben Pfaff --- diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index 273ceae57..c4cd8dc8b 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -1630,6 +1630,24 @@ ovs_instruction_type_from_ofpact_type(enum ofpact_type type) } } +enum ofperr +ovs_instruction_type_from_inst_type(enum ovs_instruction_type *instruction_type, + const uint16_t inst_type) +{ + switch (inst_type) { + +#define DEFINE_INST(ENUM, STRUCT, EXTENSIBLE, NAME) \ + case ENUM: \ + *instruction_type = OVSINST_##ENUM; \ + return 0; +OVS_INSTRUCTIONS +#undef DEFINE_INST + + default: + return OFPERR_OFPBIC_UNKNOWN_INST; + } +} + static inline struct ofp11_instruction * instruction_next(const struct ofp11_instruction *inst) { diff --git a/lib/ofp-actions.h b/lib/ofp-actions.h index 9dee74af4..89bf8678e 100644 --- a/lib/ofp-actions.h +++ b/lib/ofp-actions.h @@ -750,4 +750,7 @@ const char *ovs_instruction_name_from_type(enum ovs_instruction_type type); int ovs_instruction_type_from_name(const char *name); enum ovs_instruction_type ovs_instruction_type_from_ofpact_type( enum ofpact_type); +enum ofperr ovs_instruction_type_from_inst_type( + enum ovs_instruction_type *instruction_type, const uint16_t inst_type); + #endif /* ofp-actions.h */