ofp-actions: New function ovs_instruction_type_from_inst_type().
authorAlexander Wu <alexander.wu@huawei.com>
Fri, 17 Jan 2014 21:18:16 +0000 (13:18 -0800)
committerBen Pfaff <blp@nicira.com>
Mon, 24 Mar 2014 05:58:51 +0000 (22:58 -0700)
Signed-off-by: Alexander Wu <alexander.wu@huawei.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ofp-actions.c
lib/ofp-actions.h

index 273ceae..c4cd8dc 100644 (file)
@@ -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)
 {
index 9dee74a..89bf867 100644 (file)
@@ -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 */