#include <stddef.h>
#include <stdint.h>
+#include "openflow/openflow.h"
+
struct ds;
-struct ofp_header;
+struct ofpbuf;
/* Error codes.
*
#define OFPERR_OFS (1 << 30)
+/* OpenFlow error codes.
+ *
+ * The comments below are parsed by the extract-ofp-errors program at build
+ * time and used to determine the mapping between "enum ofperr" constants and
+ * error type/code values used in the OpenFlow protocol:
+ *
+ * - The first part of each comment specifies OpenFlow type/code for each
+ * protocol that supports the error.
+ *
+ * - Additional text is a human-readable description of the meaning of each
+ * error, used to explain the error to the user. Any text enclosed in
+ * square brackets is omitted; this can be used to explain rationale for
+ * choice of error codes in the case where this is desirable. */
enum ofperr {
/* Expected duplications. */
/* OF1.0+(1,8). Specified buffer does not exist. */
OFPERR_OFPBRC_BUFFER_UNKNOWN,
- /* OF1.1+(1,9). Specified table-id invalid or does not exist. */
+ /* NX1.0(1,512), OF1.1+(1,9). Specified table-id invalid or does not exist.
+ * [ A non-standard error (1,512), formerly OFPERR_NXBRC_BAD_TABLE_ID,
+ * is used for OpenFlow 1.0 as there seems to be no appropriste error
+ * code defined the specification. ] */
OFPERR_OFPBRC_BAD_TABLE_ID,
/* OF1.2+(1,10). Denied because controller is slave. */
OFPERR_OFPBRC_IS_SLAVE,
- /* OF1.2+(1,11). Invalid port. */
+ /* NX1.0(1,514), NX1.1(1,514), OF1.2+(1,11). Invalid port.
+ * [ A non-standard error (1,514), formerly
+ * OFPERR_NXBRC_BAD_IN_PORT is used for OpenFlow 1.0 and 1.1 as there
+ * seems to be no appropriste error code defined the specifications. ] */
OFPERR_OFPBRC_BAD_PORT,
/* OF1.2+(1,12). Invalid packet in packet-out. */
* nxm_hasmask or nxm_length or both, is invalid or not implemented. */
OFPERR_NXBRC_NXM_BAD_TYPE,
- /* NX1.0+(1,512). A request specified a nonexistent table ID. */
- OFPERR_NXBRC_BAD_TABLE_ID,
-
- /* NX1.0+(1,514). The in_port in an ofp_packet_out request is invalid. */
- OFPERR_NXBRC_BAD_IN_PORT,
-
/* NX1.0+(1,515). Must-be-zero field had nonzero value. */
OFPERR_NXBRC_MUST_BE_ZERO,
/* 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 ## */
/* ## --------------- ## */
/* OF1.1+(4,6). Unsupported field in the match. */
OFPERR_OFPBMC_BAD_FIELD,
- /* NX1.0(1,258), NX1.1(1,258), OF1.2+(4,7). Unsupported value in a match
+ /* NX1.0(1,258), OF1.1+(4,7). Unsupported value in a match
* field. */
OFPERR_OFPBMC_BAD_VALUE,
/* OF1.1+(5,0). Unspecified error. */
OFPERR_OFPFMFC_UNKNOWN,
- /* OF1.0(3,0). Flow not added because of full tables. */
- OFPERR_OFPFMFC_ALL_TABLES_FULL,
-
- /* OF1.1+(5,1). Flow not added because table was full. */
+ /* OF1.0(3,0), OF1.1+(5,1). Flow not added because of full table(s). */
OFPERR_OFPFMFC_TABLE_FULL,
/* OF1.1+(5,2). Table does not exist */
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 *);
+const char *ofperr_domain_get_name(enum ofp_version);
bool ofperr_is_valid(enum ofperr);
bool ofperr_is_category(enum ofperr);
bool ofperr_is_nx_extension(enum ofperr);
-bool ofperr_is_encodable(enum ofperr, const struct ofperr_domain *);
+bool ofperr_is_encodable(enum ofperr, enum ofp_version);
-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_decode(enum ofp_version, uint16_t type, uint16_t code);
+enum ofperr ofperr_decode_type(enum ofp_version, 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 *,
+struct ofpbuf *ofperr_encode_hello(enum ofperr, enum ofp_version ofp_version,
const char *);
-int ofperr_get_type(enum ofperr, const struct ofperr_domain *);
-int ofperr_get_code(enum ofperr, const struct ofperr_domain *);
+int ofperr_get_type(enum ofperr, enum ofp_version);
+int ofperr_get_code(enum ofperr, enum ofp_version);
const char *ofperr_get_name(enum ofperr);
const char *ofperr_get_description(enum ofperr);