ofp-util: Add OFPUTIL_ACTION_INVALID to enum ofputil_action_code.
authorBen Pfaff <blp@nicira.com>
Fri, 8 Jun 2012 00:23:59 +0000 (20:23 -0400)
committerBen Pfaff <blp@nicira.com>
Wed, 4 Jul 2012 05:21:11 +0000 (22:21 -0700)
Possibly the ofputil_decode_action() interface should be rethought now
that ofputil_action_code has an invalid value.

Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ofp-parse.c
lib/ofp-print.c
lib/ofp-util.c
lib/ofp-util.h
ofproto/ofproto-dpif.c

index 73a70c60c053ff13885f53ce54f5e9c8258345fd..1d331bb4baf8e4e7773d9dabfca12d7a9fc4c740 100644 (file)
@@ -323,6 +323,9 @@ parse_named_action(enum ofputil_action_code code, const struct flow *flow,
     struct ofp_action_tp_port *oata;
 
     switch (code) {
+    case OFPUTIL_ACTION_INVALID:
+        NOT_REACHED();
+
     case OFPUTIL_OFPAT10_OUTPUT:
         parse_output(b, arg);
         break;
index 5103c3e10e1f7521acc65c90397ff4ca5492fc1c..335ebed93286c740ecd418bd99266e29be982a34 100644 (file)
@@ -190,6 +190,9 @@ ofp_print_action(struct ds *s, const union ofp_action *a,
     uint16_t port;
 
     switch (code) {
+    case OFPUTIL_ACTION_INVALID:
+        NOT_REACHED();
+
     case OFPUTIL_OFPAT10_OUTPUT:
         port = ntohs(a->output.port);
         if (port < OFPP_MAX) {
index 60d0cfd4d105e105fbc9385a6d09b749ac8eecba..3329ed7ff1a28c3bcff356987d160ef5c24341d8 100644 (file)
@@ -3711,6 +3711,9 @@ validate_actions(const union ofp_action *actions, size_t n_actions,
 
         error = 0;
         switch ((enum ofputil_action_code) code) {
+        case OFPUTIL_ACTION_INVALID:
+            NOT_REACHED();
+
         case OFPUTIL_OFPAT10_OUTPUT:
             error = ofputil_check_output_port(ntohs(a->output.port),
                                               max_ports);
@@ -3941,6 +3944,7 @@ int
 ofputil_action_code_from_name(const char *name)
 {
     static const char *names[OFPUTIL_N_ACTIONS] = {
+        NULL,
 #define OFPAT10_ACTION(ENUM, STRUCT, NAME)             NAME,
 #define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) NAME,
 #include "ofp-util.def"
@@ -3965,6 +3969,9 @@ void *
 ofputil_put_action(enum ofputil_action_code code, struct ofpbuf *buf)
 {
     switch (code) {
+    case OFPUTIL_ACTION_INVALID:
+        NOT_REACHED();
+
 #define OFPAT10_ACTION(ENUM, STRUCT, NAME)                    \
     case OFPUTIL_##ENUM: return ofputil_put_##ENUM(buf);
 #define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME)        \
index aaab83cbdbc091f0b65af45a4ad4d250863b71cc..3f9e440b380eb50e8662134c8a2eb1ce8f952c29 100644 (file)
@@ -598,6 +598,7 @@ bool ofputil_frag_handling_from_string(const char *, enum ofp_config_flags *);
  * (The above list helps developers who want to "grep" for these definitions.)
  */
 enum ofputil_action_code {
+    OFPUTIL_ACTION_INVALID,
 #define OFPAT10_ACTION(ENUM, STRUCT, NAME)             OFPUTIL_##ENUM,
 #define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) OFPUTIL_##ENUM,
 #include "ofp-util.def"
@@ -607,7 +608,7 @@ enum ofputil_action_code {
 enum {
 #define OFPAT10_ACTION(ENUM, STRUCT, NAME)             + 1
 #define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) + 1
-    OFPUTIL_N_ACTIONS = 0
+    OFPUTIL_N_ACTIONS = 1
 #include "ofp-util.def"
 };
 
index 7b86f8079ce3da6df1c5b176552492630b5331b9..f51182af28cc2663300005c25ab994b98df1b29c 100644 (file)
@@ -5397,6 +5397,9 @@ do_xlate_actions(const union ofp_action *in, size_t n_in,
 
         code = ofputil_decode_action_unsafe(ia);
         switch (code) {
+        case OFPUTIL_ACTION_INVALID:
+            NOT_REACHED();
+
         case OFPUTIL_OFPAT10_OUTPUT:
             xlate_output_action(ctx, &ia->output);
             break;