switch (code) {
case OFPUTIL_ACTION_INVALID:
#define OFPAT10_ACTION(ENUM, STRUCT, NAME) case OFPUTIL_##ENUM:
-#define OFPAT11_ACTION(ENUM, STRUCT, NAME) case OFPUTIL_##ENUM:
+#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) case OFPUTIL_##ENUM:
#include "ofp-util.def"
NOT_REACHED();
switch (code) {
case OFPUTIL_ACTION_INVALID:
-#define OFPAT11_ACTION(ENUM, STRUCT, NAME) case OFPUTIL_##ENUM:
+#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) case OFPUTIL_##ENUM:
#include "ofp-util.def"
NOT_REACHED();
decode_openflow11_action(const union ofp_action *a,
enum ofputil_action_code *code)
{
+ uint16_t len;
+
switch (a->type) {
case CONSTANT_HTONS(OFPAT11_EXPERIMENTER):
return decode_nxast_action(a, code);
-#define OFPAT11_ACTION(ENUM, STRUCT, NAME) \
- case CONSTANT_HTONS(ENUM): \
- if (a->header.len == htons(sizeof(struct STRUCT))) { \
- *code = OFPUTIL_##ENUM; \
- return 0; \
- } else { \
- return OFPERR_OFPBAC_BAD_LEN; \
- } \
- break;
+#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) \
+ case CONSTANT_HTONS(ENUM): \
+ len = ntohs(a->header.len); \
+ if (EXTENSIBLE \
+ ? len >= sizeof(struct STRUCT) \
+ : len == sizeof(struct STRUCT)) { \
+ *code = OFPUTIL_##ENUM; \
+ return 0; \
+ } else { \
+ return OFPERR_OFPBAC_BAD_LEN; \
+ } \
+ NOT_REACHED();
#include "ofp-util.def"
default:
{
static const char *names[OFPUTIL_N_ACTIONS] = {
NULL,
-#define OFPAT10_ACTION(ENUM, STRUCT, NAME) NAME,
-#define OFPAT11_ACTION(ENUM, STRUCT, NAME) NAME,
-#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) NAME,
+#define OFPAT10_ACTION(ENUM, STRUCT, NAME) NAME,
+#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) NAME,
+#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) NAME,
#include "ofp-util.def"
};
case OFPUTIL_ACTION_INVALID:
NOT_REACHED();
-#define OFPAT10_ACTION(ENUM, STRUCT, NAME) \
+#define OFPAT10_ACTION(ENUM, STRUCT, NAME) \
+ case OFPUTIL_##ENUM: return ofputil_put_##ENUM(buf);
+#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) \
case OFPUTIL_##ENUM: return ofputil_put_##ENUM(buf);
-#define OFPAT11_ACTION OFPAT10_ACTION
#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) \
case OFPUTIL_##ENUM: return ofputil_put_##ENUM(buf);
#include "ofp-util.def"
ofputil_init_##ENUM(s); \
return s; \
}
-#define OFPAT11_ACTION OFPAT10_ACTION
+#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) \
+ OFPAT10_ACTION(ENUM, STRUCT, NAME)
#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) \
void \
ofputil_init_##ENUM(struct STRUCT *s) \
OFPAT10_ACTION(OFPAT10_ENQUEUE, ofp_action_enqueue, "enqueue")
#ifndef OFPAT11_ACTION
-#define OFPAT11_ACTION(ENUM, STRUCT, NAME)
+#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME)
#endif
-OFPAT11_ACTION(OFPAT11_OUTPUT, ofp11_action_output, "output")
-OFPAT11_ACTION(OFPAT11_SET_VLAN_VID, ofp_action_vlan_vid, "mod_vlan_vid")
-OFPAT11_ACTION(OFPAT11_SET_VLAN_PCP, ofp_action_vlan_pcp, "mod_vlan_pcp")
-OFPAT11_ACTION(OFPAT11_SET_DL_SRC, ofp_action_dl_addr, "mod_dl_src")
-OFPAT11_ACTION(OFPAT11_SET_DL_DST, ofp_action_dl_addr, "mod_dl_dst")
-OFPAT11_ACTION(OFPAT11_SET_NW_SRC, ofp_action_nw_addr, "mod_nw_src")
-OFPAT11_ACTION(OFPAT11_SET_NW_DST, ofp_action_nw_addr, "mod_nw_dst")
-OFPAT11_ACTION(OFPAT11_SET_NW_TOS, ofp_action_nw_tos, "mod_nw_tos")
-//OFPAT11_ACTION(OFPAT11_SET_NW_ECN, ofp11_action_nw_ecn, "mod_nw_ecn")
-OFPAT11_ACTION(OFPAT11_SET_TP_SRC, ofp_action_tp_port, "mod_tp_src")
-OFPAT11_ACTION(OFPAT11_SET_TP_DST, ofp_action_tp_port, "mod_tp_dst")
-//OFPAT11_ACTION(OFPAT11_PUSH_VLAN, ofp11_action_push, "push_vlan")
-//OFPAT11_ACTION(OFPAT11_POP_VLAN, ofp_action_header, "pop_vlan")
-//OFPAT11_ACTION(OFPAT11_SET_QUEUE, ofp11_action_set_queue, "set_queue")
-//OFPAT11_ACTION(OFPAT11_SET_NW_TTL, ofp11_action_nw_ttl, "set_nw_ttl")
-//OFPAT11_ACTION(OFPAT11_DEC_NW_TTL, ofp_action_header, "dec_ttl")
-OFPAT11_ACTION(OFPAT12_SET_FIELD, ofp12_action_set_field, NULL)
+OFPAT11_ACTION(OFPAT11_OUTPUT, ofp11_action_output, 0, "output")
+OFPAT11_ACTION(OFPAT11_SET_VLAN_VID, ofp_action_vlan_vid, 0, "mod_vlan_vid")
+OFPAT11_ACTION(OFPAT11_SET_VLAN_PCP, ofp_action_vlan_pcp, 0, "mod_vlan_pcp")
+OFPAT11_ACTION(OFPAT11_SET_DL_SRC, ofp_action_dl_addr, 0, "mod_dl_src")
+OFPAT11_ACTION(OFPAT11_SET_DL_DST, ofp_action_dl_addr, 0, "mod_dl_dst")
+OFPAT11_ACTION(OFPAT11_SET_NW_SRC, ofp_action_nw_addr, 0, "mod_nw_src")
+OFPAT11_ACTION(OFPAT11_SET_NW_DST, ofp_action_nw_addr, 0, "mod_nw_dst")
+OFPAT11_ACTION(OFPAT11_SET_NW_TOS, ofp_action_nw_tos, 0, "mod_nw_tos")
+//OFPAT11_ACTION(OFPAT11_SET_NW_ECN, ofp11_action_nw_ecn, "0, mod_nw_ecn")
+OFPAT11_ACTION(OFPAT11_SET_TP_SRC, ofp_action_tp_port, 0, "mod_tp_src")
+OFPAT11_ACTION(OFPAT11_SET_TP_DST, ofp_action_tp_port, 0, "mod_tp_dst")
+//OFPAT11_ACTION(OFPAT11_PUSH_VLAN, ofp11_action_push, 0, "push_vlan")
+//OFPAT11_ACTION(OFPAT11_POP_VLAN, ofp_action_header, 0, "pop_vlan")
+//OFPAT11_ACTION(OFPAT11_SET_QUEUE, ofp11_action_set_queue, 0, "set_queue")
+//OFPAT11_ACTION(OFPAT11_SET_NW_TTL, ofp11_action_nw_ttl, 0, "set_nw_ttl")
+//OFPAT11_ACTION(OFPAT11_DEC_NW_TTL, ofp_action_header, 0, "dec_ttl")
+OFPAT11_ACTION(OFPAT12_SET_FIELD, ofp12_action_set_field, 1, NULL)
#ifndef NXAST_ACTION
#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME)
*/
enum OVS_PACKED_ENUM ofputil_action_code {
OFPUTIL_ACTION_INVALID,
-#define OFPAT10_ACTION(ENUM, STRUCT, NAME) OFPUTIL_##ENUM,
-#define OFPAT11_ACTION(ENUM, STRUCT, NAME) OFPUTIL_##ENUM,
-#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) OFPUTIL_##ENUM,
+#define OFPAT10_ACTION(ENUM, STRUCT, NAME) OFPUTIL_##ENUM,
+#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) OFPUTIL_##ENUM,
+#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) OFPUTIL_##ENUM,
#include "ofp-util.def"
};
/* The number of values of "enum ofputil_action_code". */
enum {
-#define OFPAT10_ACTION(ENUM, STRUCT, NAME) + 1
-#define OFPAT11_ACTION(ENUM, STRUCT, NAME) + 1
-#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) + 1
+#define OFPAT10_ACTION(ENUM, STRUCT, NAME) + 1
+#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) + 1
+#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) + 1
OFPUTIL_N_ACTIONS = 1
#include "ofp-util.def"
};
#define OFPAT10_ACTION(ENUM, STRUCT, NAME) \
void ofputil_init_##ENUM(struct STRUCT *); \
struct STRUCT *ofputil_put_##ENUM(struct ofpbuf *);
-#define OFPAT11_ACTION(ENUM, STRUCT, NAME) \
+#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) \
void ofputil_init_##ENUM(struct STRUCT *); \
struct STRUCT *ofputil_put_##ENUM(struct ofpbuf *);
#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) \