The main use of OFPERR_* is to define specific errors, but OFPERR_* also
existed for each possible category of error, to enable partial decoding of
unknown specific errors within a known category. However, in practice,
it was very easy to misuse the error categories as if they were particular
errors. This commit removes the error category values, to make that error
impossible.
(If partial decoding of unknown specific errors turns out to have been a
valuable feature, then we can reintroduce it some other way.)
Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
const char *name;
uint8_t version;
enum ofperr (*decode)(uint16_t type, uint16_t code);
const char *name;
uint8_t version;
enum ofperr (*decode)(uint16_t type, uint16_t code);
- enum ofperr (*decode_type)(uint16_t type);
struct pair errors[OFPERR_N_ERRORS];
};
struct pair errors[OFPERR_N_ERRORS];
};
- return 0;
-}
-
-static enum ofperr
-%s_decode_type(uint16_t type)
-{
- switch (type) {""" % name
- for enum in names:
- if enum not in map:
- continue
- type_, code = map[enum]
- if code is not None:
- continue
- print " case %d:" % type_
- print " return OFPERR_%s;" % enum
- print """\
- }
-
- %s_decode_type,
- {""" % (name, description, version, name, name)
+ {""" % (name, description, version, name)
for enum in names:
if enum in map:
type_, code = map[enum]
for enum in names:
if enum in map:
type_, code = map[enum]
return error >= OFPERR_OFS && error < OFPERR_OFS + OFPERR_N_ERRORS;
}
return error >= OFPERR_OFS && error < OFPERR_OFS + OFPERR_N_ERRORS;
}
-/* Returns true if 'error' is a valid OFPERR_* value that designates a whole
- * category of errors instead of a particular error, e.g. if it is an
- * OFPERR_OFPET_* value, and false otherwise. */
-bool
-ofperr_is_category(enum ofperr error)
-{
- return (ofperr_is_valid(error)
- && ofperr_of10.errors[error - OFPERR_OFS].code == -1
- && ofperr_of11.errors[error - OFPERR_OFS].code == -1);
-}
/* Returns true if 'error' can be encoded as an OpenFlow error message in
* 'domain', false otherwise.
*
/* Returns true if 'error' can be encoded as an OpenFlow error message in
* 'domain', false otherwise.
*
return domain ? domain->decode(type, code) : 0;
}
return domain ? domain->decode(type, code) : 0;
}
-/* Returns the OFPERR_* value that corresponds to the category 'type' within
- * 'version', or 0 if either no such OFPERR_* value exists or 'version' is
- * unknown. */
-enum ofperr
-ofperr_decode_type(enum ofp_version version, uint16_t type)
-{
- const struct ofperr_domain *domain = ofperr_domain_from_version(version);
- return domain ? domain->decode_type(type) : 0;
-}
-
/* Returns the name of 'error', e.g. "OFPBRC_BAD_TYPE" if 'error' is
* OFPBRC_BAD_TYPE, or "<invalid>" if 'error' is not a valid OFPERR_* value.
*
/* Returns the name of 'error', e.g. "OFPBRC_BAD_TYPE" if 'error' is
* OFPBRC_BAD_TYPE, or "<invalid>" if 'error' is not a valid OFPERR_* value.
*
code = ntohs(nve->code);
}
code = ntohs(nve->code);
}
- /* Translate the error type and code into an ofperr.
- * If we don't know the error type and code, at least try for the type. */
+ /* Translate the error type and code into an ofperr. */
error = ofperr_decode(oh->version, type, code);
error = ofperr_decode(oh->version, type, code);
- if (!error) {
- error = ofperr_decode_type(oh->version, type);
- }
if (error && payload) {
ofpbuf_use_const(payload, b.data, b.size);
}
if (error && payload) {
ofpbuf_use_const(payload, b.data, b.size);
}
/* ## OFPET_HELLO_FAILED ## */
/* ## ------------------ ## */
/* ## OFPET_HELLO_FAILED ## */
/* ## ------------------ ## */
- /* OF1.0+(0). Hello protocol failed. */
- OFPERR_OFPET_HELLO_FAILED = OFPERR_OFS,
-
/* OF1.0+(0,0). No compatible version. */
/* OF1.0+(0,0). No compatible version. */
- OFPERR_OFPHFC_INCOMPATIBLE,
+ OFPERR_OFPHFC_INCOMPATIBLE = OFPERR_OFS,
/* OF1.0+(0,1). Permissions error. */
OFPERR_OFPHFC_EPERM,
/* OF1.0+(0,1). Permissions error. */
OFPERR_OFPHFC_EPERM,
/* ## OFPET_BAD_REQUEST ## */
/* ## ----------------- ## */
/* ## OFPET_BAD_REQUEST ## */
/* ## ----------------- ## */
- /* OF1.0+(1). Request was not understood. */
- OFPERR_OFPET_BAD_REQUEST,
-
/* OF1.0+(1,0). ofp_header.version not supported. */
OFPERR_OFPBRC_BAD_VERSION,
/* OF1.0+(1,0). ofp_header.version not supported. */
OFPERR_OFPBRC_BAD_VERSION,
/* ## OFPET_BAD_ACTION ## */
/* ## ---------------- ## */
/* ## OFPET_BAD_ACTION ## */
/* ## ---------------- ## */
- /* OF1.0+(2). Error in action description. */
- OFPERR_OFPET_BAD_ACTION,
-
/* OF1.0+(2,0). Unknown action type. */
OFPERR_OFPBAC_BAD_TYPE,
/* OF1.0+(2,0). Unknown action type. */
OFPERR_OFPBAC_BAD_TYPE,
/* ## OFPET_BAD_INSTRUCTION ## */
/* ## --------------------- ## */
/* ## OFPET_BAD_INSTRUCTION ## */
/* ## --------------------- ## */
- /* OF1.1+(3). Error in instruction list. */
- OFPERR_OFPIT_BAD_INSTRUCTION,
-
/* OF1.1+(3,0). Unknown instruction. */
OFPERR_OFPBIC_UNKNOWN_INST,
/* OF1.1+(3,0). Unknown instruction. */
OFPERR_OFPBIC_UNKNOWN_INST,
/* ## OFPET_BAD_MATCH ## */
/* ## --------------- ## */
/* ## OFPET_BAD_MATCH ## */
/* ## --------------- ## */
- /* OF1.1+(4). Error in match. */
- OFPERR_OFPET_BAD_MATCH,
-
/* OF1.1+(4,0). Unsupported match type specified by the match */
OFPERR_OFPBMC_BAD_TYPE,
/* OF1.1+(4,0). Unsupported match type specified by the match */
OFPERR_OFPBMC_BAD_TYPE,
/* ## OFPET_FLOW_MOD_FAILED ## */
/* ## --------------------- ## */
/* ## OFPET_FLOW_MOD_FAILED ## */
/* ## --------------------- ## */
- /* OF1.0(3), OF1.1+(5). Problem modifying flow entry. */
- OFPERR_OFPET_FLOW_MOD_FAILED,
-
/* OF1.1+(5,0). Unspecified error. */
OFPERR_OFPFMFC_UNKNOWN,
/* OF1.1+(5,0). Unspecified error. */
OFPERR_OFPFMFC_UNKNOWN,
/* ## OFPET_GROUP_MOD_FAILED ## */
/* ## ---------------------- ## */
/* ## OFPET_GROUP_MOD_FAILED ## */
/* ## ---------------------- ## */
- /* OF1.1+(6). Problem modifying group entry. */
- OFPERR_OFPET_GROUP_MOD_FAILED,
-
/* OF1.1+(6,0). Group not added because a group ADD attempted to replace
* an already-present group. */
OFPERR_OFPGMFC_GROUP_EXISTS,
/* OF1.1+(6,0). Group not added because a group ADD attempted to replace
* an already-present group. */
OFPERR_OFPGMFC_GROUP_EXISTS,
/* ## OFPET_PORT_MOD_FAILED ## */
/* ## --------------------- ## */
/* ## OFPET_PORT_MOD_FAILED ## */
/* ## --------------------- ## */
- /* OF1.0(4), OF1.1+(7). OFPT_PORT_MOD failed. */
- OFPERR_OFPET_PORT_MOD_FAILED,
-
/* OF1.0(4,0), OF1.1+(7,0). Specified port does not exist. */
OFPERR_OFPPMFC_BAD_PORT,
/* OF1.0(4,0), OF1.1+(7,0). Specified port does not exist. */
OFPERR_OFPPMFC_BAD_PORT,
/* ## OFPET_TABLE_MOD_FAILED ## */
/* ## ---------------------- ## */
/* ## OFPET_TABLE_MOD_FAILED ## */
/* ## ---------------------- ## */
- /* OF1.1+(8). Table mod request failed. */
- OFPERR_OFPET_TABLE_MOD_FAILED,
-
/* OF1.1+(8,0). Specified table does not exist. */
OFPERR_OFPTMFC_BAD_TABLE,
/* OF1.1+(8,0). Specified table does not exist. */
OFPERR_OFPTMFC_BAD_TABLE,
/* ## OFPET_QUEUE_OP_FAILED ## */
/* ## --------------------- ## */
/* ## OFPET_QUEUE_OP_FAILED ## */
/* ## --------------------- ## */
- /* OF1.0(5), OF1.1+(9). Queue operation failed. */
- OFPERR_OFPET_QUEUE_OP_FAILED,
-
/* OF1.0(5,0), OF1.1+(9,0). Invalid port (or port does not exist). */
OFPERR_OFPQOFC_BAD_PORT,
/* OF1.0(5,0), OF1.1+(9,0). Invalid port (or port does not exist). */
OFPERR_OFPQOFC_BAD_PORT,
/* ## OFPET_SWITCH_CONFIG_FAILED ## */
/* ## -------------------------- ## */
/* ## OFPET_SWITCH_CONFIG_FAILED ## */
/* ## -------------------------- ## */
- /* OF1.1+(10). Switch config request failed. */
- OFPERR_OFPET_SWITCH_CONFIG_FAILED,
-
/* OF1.1+(10,0). Specified flags is invalid. */
OFPERR_OFPSCFC_BAD_FLAGS,
/* OF1.1+(10,0). Specified flags is invalid. */
OFPERR_OFPSCFC_BAD_FLAGS,
/* ## OFPET_ROLE_REQUEST_FAILED ## */
/* ## ------------------------- ## */
/* ## 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,0). Stale Message: old generation_id. */
OFPERR_OFPRRFC_STALE,
/* ## OFPET_METER_MOD_FAILED ## */
/* ## ---------------------- ## */
/* ## OFPET_METER_MOD_FAILED ## */
/* ## ---------------------- ## */
- /* OF1.3+(12). Error in meter. */
- OFPERR_OFPET_METER_MOD_FAILED,
-
/* OF1.3+(12,0). Unspecified error. */
OFPERR_OFPMMFC_UNKNOWN,
/* OF1.3+(12,0). Unspecified error. */
OFPERR_OFPMMFC_UNKNOWN,
/* ## OFPET_TABLE_FEATURES_FAILED ## */
/* ## --------------------------- ## */
/* ## OFPET_TABLE_FEATURES_FAILED ## */
/* ## --------------------------- ## */
- /* OF1.3+(13). Setting table features failed. */
- OFPERR_OFPET_TABLE_FEATURES_FAILED,
-
/* OF1.3+(13,0). Specified table does not exist. */
OFPERR_OFPTFFC_BAD_TABLE,
/* OF1.3+(13,0). Specified table does not exist. */
OFPERR_OFPTFFC_BAD_TABLE,
/* ## ------------------ ## */
/* ## OFPET_EXPERIMENTER ## */
/* ## ------------------ ## */
/* ## ------------------ ## */
/* ## OFPET_EXPERIMENTER ## */
/* ## ------------------ ## */
-
- /* OF1.2+(0xffff). Experimenter error messages. */
- OFPERR_OFPET_EXPERIMENTER,
};
const char *ofperr_domain_get_name(enum ofp_version);
bool ofperr_is_valid(enum ofperr);
};
const char *ofperr_domain_get_name(enum ofp_version);
bool ofperr_is_valid(enum ofperr);
-bool ofperr_is_category(enum ofperr);
bool ofperr_is_encodable(enum ofperr, enum ofp_version);
enum ofperr ofperr_decode(enum ofp_version, uint16_t type, uint16_t code);
bool ofperr_is_encodable(enum ofperr, enum ofp_version);
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 *,
enum ofperr ofperr_from_name(const char *);
enum ofperr ofperr_decode_msg(const struct ofp_header *,