ofp-msgs: New approach to encoding and decoding OpenFlow headers.
[openvswitch] / lib / ofp-errors.h
index bd6095b394a3d6a2193aa486014c27936684e1f4..1af70da90a06bcead19f82853e31a10df6a69a55 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
 
 struct ds;
 struct ofp_header;
+struct ofpbuf;
 
 /* Error codes.
  *
@@ -44,6 +45,11 @@ struct ofp_header;
 #define OFPERR_OFS (1 << 30)
 
 enum ofperr {
+/* Expected duplications. */
+
+    /* Expected: 3,5 in OF1.1 means both OFPBIC_BAD_EXPERIMENTER and
+     * OFPBIC_BAD_EXP_TYPE. */
+
 /* ## ------------------ ## */
 /* ## OFPET_HELLO_FAILED ## */
 /* ## ------------------ ## */
@@ -95,6 +101,15 @@ enum ofperr {
     /* OF1.1+(1,9).  Specified table-id invalid or does not exist. */
     OFPERR_OFPBRC_BAD_TABLE_ID,
 
+    /* OF1.2+(1,10).  Denied because controller is slave. */
+    OFPERR_OFPBRC_IS_SLAVE,
+
+    /* OF1.2+(1,11).  Invalid port. */
+    OFPERR_OFPBRC_BAD_PORT,
+
+    /* OF1.2+(1,12).  Invalid packet in packet-out. */
+    OFPERR_OFPBRC_BAD_PACKET,
+
     /* NX1.0+(1,256).  Invalid NXM flow match. */
     OFPERR_NXBRC_NXM_INVALID,
 
@@ -102,24 +117,9 @@ enum ofperr {
      * nxm_hasmask or nxm_length or both, is invalid or not implemented. */
     OFPERR_NXBRC_NXM_BAD_TYPE,
 
-    /* NX1.0+(1,258).  Invalid nxm_value. */
-    OFPERR_NXBRC_NXM_BAD_VALUE,
-
-    /* NX1.0+(1,259).  Invalid nxm_mask. */
-    OFPERR_NXBRC_NXM_BAD_MASK,
-
-    /* NX1.0+(1,260).  A prerequisite was not met. */
-    OFPERR_NXBRC_NXM_BAD_PREREQ,
-
-    /* NX1.0+(1,261).  A given nxm_type was specified more than once. */
-    OFPERR_NXBRC_NXM_DUP_TYPE,
-
     /* NX1.0+(1,512).  A request specified a nonexistent table ID. */
     OFPERR_NXBRC_BAD_TABLE_ID,
 
-    /* NX1.0+(1,513).  NXT_ROLE_REQUEST specified an invalid role. */
-    OFPERR_NXBRC_BAD_ROLE,
-
     /* NX1.0+(1,514).  The in_port in an ofp_packet_out request is invalid. */
     OFPERR_NXBRC_BAD_IN_PORT,
 
@@ -130,6 +130,20 @@ enum ofperr {
      * valid. */
     OFPERR_NXBRC_BAD_REASON,
 
+    /* NX1.0+(1,517).  The 'id' in an NXST_FLOW_MONITOR request is the same as
+     * an existing monitor id (or two monitors in the same NXST_FLOW_MONITOR
+     * request have the same 'id').  */
+    OFPERR_NXBRC_FM_DUPLICATE_ID,
+
+    /* NX1.0+(1,518).  The 'flags' in an NXST_FLOW_MONITOR request either does
+     * not specify at least one of the NXFMF_ADD, NXFMF_DELETE, or NXFMF_MODIFY
+     * flags, or specifies a flag bit that is not defined. */
+    OFPERR_NXBRC_FM_BAD_FLAGS,
+
+    /* NX1.0+(1,519).  The 'id' in an NXT_FLOW_MONITOR_CANCEL request is not
+     * the id of any existing monitor. */
+    OFPERR_NXBRC_FM_BAD_ID,
+
 /* ## ---------------- ## */
 /* ## OFPET_BAD_ACTION ## */
 /* ## ---------------- ## */
@@ -177,6 +191,15 @@ enum ofperr {
     /* OF1.1+(2,12).  Actions uses an unsupported tag/encap. */
     OFPERR_OFPBAC_BAD_TAG,
 
+    /* OF1.2+(2,13).  Unsupported type in SET_FIELD action. */
+    OFPERR_OFPBAC_SET_TYPE,
+
+    /* OF1.2+(2,14).  Length problem in SET_FIELD action. */
+    OFPERR_OFPBAC_SET_LEN,
+
+    /* OF1.2+(2,15).  Bad argument in SET_FIELD action. */
+    OFPERR_OFPBAC_ARGUMENT,
+
     /* NX1.0+(2,256).  Must-be-zero action argument had nonzero value. */
     OFPERR_NXBAC_MUST_BE_ZERO,
 
@@ -185,7 +208,7 @@ enum ofperr {
 /* ## --------------------- ## */
 
     /* OF1.1+(3).  Error in instruction list. */
-    OFPERR_OFPET_BAD_INSTRUCTION,
+    OFPERR_OFPIT_BAD_INSTRUCTION,
 
     /* OF1.1+(3,0).  Unknown instruction. */
     OFPERR_OFPBIC_UNKNOWN_INST,
@@ -202,8 +225,20 @@ enum ofperr {
     /* OF1.1+(3,4).  Metadata mask value unsupported by datapath. */
     OFPERR_OFPBIC_UNSUP_METADATA_MASK,
 
-    /* OF1.1+(3,5).  Specific experimenter instruction unsupported. */
-    OFPERR_OFPBIC_UNSUP_EXP_INST,
+    /* OF1.1+(3,5).  Unknown experimenter id specified. */
+    OFPERR_OFPBIC_BAD_EXPERIMENTER,
+
+    /* OF1.1(3,5), OF1.2+(3,6).  Unknown instruction for experimenter id. */
+    OFPERR_OFPBIC_BAD_EXP_TYPE,
+
+    /* OF1.2+(3,7).  Length problem in instructions. */
+    OFPERR_OFPBIC_BAD_LEN,
+
+    /* OF1.2+(3,8).  Permissions error. */
+    OFPERR_OFPBIC_EPERM,
+
+    /* NX1.1+(3,256).  Duplicate instruction type in set of instructions. */
+    OFPERR_NXBIC_DUP_TYPE,
 
 /* ## --------------- ## */
 /* ## OFPET_BAD_MATCH ## */
@@ -235,9 +270,24 @@ enum ofperr {
     /* OF1.1+(4,6).  Unsupported field in the match. */
     OFPERR_OFPBMC_BAD_FIELD,
 
-    /* OF1.1+(4,7).  Unsupported value in a match field. */
+    /* NX1.0(1,258), NX1.1(1,258), OF1.2+(4,7).  Unsupported value in a match
+     * field. */
     OFPERR_OFPBMC_BAD_VALUE,
 
+    /* NX1.0(1,259), NX1.1(1,259), OF1.2+(4,8).  Unsupported mask specified in
+     * the match, field is not dl-address or nw-address. */
+    OFPERR_OFPBMC_BAD_MASK,
+
+    /* NX1.0(1,260), NX1.1(1,260), OF1.2+(4,9).  A prerequisite was not met. */
+    OFPERR_OFPBMC_BAD_PREREQ,
+
+    /* NX1.0(1,261), NX1.1(1,261), OF1.2+(4,10).  A field type was
+     * duplicated. */
+    OFPERR_OFPBMC_DUP_FIELD,
+
+    /* OF1.2+(4,11).  Permissions error. */
+    OFPERR_OFPBMC_EPERM,
+
 /* ## --------------------- ## */
 /* ## OFPET_FLOW_MOD_FAILED ## */
 /* ## --------------------- ## */
@@ -274,6 +324,9 @@ enum ofperr {
     /* OF1.0(3,4), OF1.1+(5,6).  Unsupported or unknown command. */
     OFPERR_OFPFMFC_BAD_COMMAND,
 
+    /* OF1.2+(5,7).  Unsupported or unknown flags. */
+    OFPERR_OFPFMFC_BAD_FLAGS,
+
     /* OF1.0(3,5).  Unsupported action list - cannot process in the order
      * specified. */
     OFPERR_OFPFMFC_UNSUPPORTED,
@@ -325,6 +378,25 @@ enum ofperr {
      * modify a non-existent group. */
     OFPERR_OFPGMFC_UNKNOWN_GROUP,
 
+    /* OF1.2+(6,9).  Group not deleted because another
+                    group is forwarding to it. */
+    OFPERR_OFPGMFC_CHAINED_GROUP,
+
+    /* OF1.2+(6,10).  Unsupported or unknown group type. */
+    OFPERR_OFPGMFC_BAD_TYPE,
+
+    /* OF1.2+(6,11).  Unsupported or unknown command. */
+    OFPERR_OFPGMFC_BAD_COMMAND,
+
+    /* OF1.2+(6,12).  Error in bucket. */
+    OFPERR_OFPGMFC_OFPGMFC_BAD_BUCKET,
+
+    /* OF1.2+(6,13).  Error in watch port/group. */
+    OFPERR_OFPGMFC_OFPGMFC_BAD_WATCH,
+
+    /* OF1.2+(6,14).  Permissions error. */
+    OFPERR_OFPGMFC_OFPGMFC_EPERM,
+
 /* ## --------------------- ## */
 /* ## OFPET_PORT_MOD_FAILED ## */
 /* ## --------------------- ## */
@@ -345,6 +417,9 @@ enum ofperr {
     /* OF1.1+(7,3).  Specified advertise is invalid. */
     OFPERR_OFPPMFC_BAD_ADVERTISE,
 
+    /* OF1.2+(7,4).  Permissions error. */
+    OFPERR_OFPPMFC_EPERM,
+
 /* ## ---------------------- ## */
 /* ## OFPET_TABLE_MOD_FAILED ## */
 /* ## ---------------------- ## */
@@ -358,6 +433,9 @@ enum ofperr {
     /* OF1.1+(8,1).  Specified config is invalid. */
     OFPERR_OFPTMFC_BAD_CONFIG,
 
+    /* OF1.2+(8,2).  Permissions error. */
+    OFPERR_OFPTMFC_EPERM,
+
 /* ## --------------------- ## */
 /* ## OFPET_QUEUE_OP_FAILED ## */
 /* ## --------------------- ## */
@@ -386,12 +464,40 @@ enum ofperr {
 
     /* OF1.1+(10,1).  Specified len is invalid. */
     OFPERR_OFPSCFC_BAD_LEN,
+
+    /* OF1.2+(10,2).  Permissions error. */
+    OFPERR_OFPSCFC_EPERM,
+
+/* ## ------------------------- ## */
+/* ## OFPET_ROLE_REQUEST_FAILED ## */
+/* ## ------------------------- ## */
+
+    /* OF1.2+(11).  Controller Role request failed. */
+    OFPERR_OFPET_ROLE_REQUEST_FAILED,
+
+    /* OF1.2+(11,0).  Stale Message: old generation_id. */
+    OFPERR_OFPRRFC_STALE,
+
+    /* OF1.2+(11,1).  Controller role change unsupported. */
+    OFPERR_OFPRRFC_UNSUP,
+
+    /* NX1.0(1,513), NX1.1(1,513), OF1.2+(11,2).  Invalid role. */
+    OFPERR_OFPRRFC_BAD_ROLE,
+
+/* ## ------------------ ## */
+/* ## OFPET_EXPERIMENTER ## */
+/* ## ------------------ ## */
+
+    /* OF1.2+(0xffff).  Experimenter error messages. */
+    OFPERR_OFPET_EXPERIMENTER,
 };
 
 extern const struct ofperr_domain ofperr_of10;
 extern const struct ofperr_domain ofperr_of11;
+extern const struct ofperr_domain ofperr_of12;
 
 const struct ofperr_domain *ofperr_domain_from_version(uint8_t version);
+const char *ofperr_domain_get_name(const struct ofperr_domain *);
 
 bool ofperr_is_valid(enum ofperr);
 bool ofperr_is_category(enum ofperr);
@@ -401,11 +507,15 @@ bool ofperr_is_encodable(enum ofperr, const struct ofperr_domain *);
 enum ofperr ofperr_decode(const struct ofperr_domain *,
                           uint16_t type, uint16_t code);
 enum ofperr ofperr_decode_type(const struct ofperr_domain *, uint16_t type);
+enum ofperr ofperr_from_name(const char *);
 
-enum ofperr ofperr_decode_msg(const struct ofp_header *, size_t *payload_ofs);
+enum ofperr ofperr_decode_msg(const struct ofp_header *,
+                              struct ofpbuf *payload);
 struct ofpbuf *ofperr_encode_reply(enum ofperr, const struct ofp_header *);
 struct ofpbuf *ofperr_encode_hello(enum ofperr, const struct ofperr_domain *,
                                    const char *);
+int ofperr_get_type(enum ofperr, const struct ofperr_domain *);
+int ofperr_get_code(enum ofperr, const struct ofperr_domain *);
 
 const char *ofperr_get_name(enum ofperr);
 const char *ofperr_get_description(enum ofperr);