#include "compiler.h"
#include "dynamic-string.h"
#include "flow.h"
+#include "ofp-util.h"
#include "ofpbuf.h"
#include "openflow/openflow.h"
#include "openflow/nicira-ext.h"
return -1;
}
- if ((len % 8) != 0) {
+ if ((len % OFP_ACTION_ALIGN) != 0) {
ds_put_format(string,
- "***action %"PRIu16" length not a multiple of 8***\n",
- type);
+ "***action %"PRIu16" length not a multiple of %d***\n",
+ type, OFP_ACTION_ALIGN);
return -1;
}
return fs;
}
-/* Alignment of ofp_actions. */
-#define ACTION_ALIGNMENT 8
-
static int
check_action_exact_len(const union ofp_action *a, unsigned int len,
unsigned int required_len)
for (i = 0; i < n_actions; ) {
const union ofp_action *a = &actions[i];
unsigned int len = ntohs(a->header.len);
- unsigned int n_slots = len / ACTION_ALIGNMENT;
+ unsigned int n_slots = len / OFP_ACTION_ALIGN;
unsigned int slots_left = &actions[n_actions] - a;
int error;
} else if (!len) {
VLOG_DBG_RL(&bad_ofmsg_rl, "action has invalid length 0");
return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_LEN);
- } else if (len % ACTION_ALIGNMENT) {
+ } else if (len % OFP_ACTION_ALIGN) {
VLOG_DBG_RL(&bad_ofmsg_rl, "action length %u is not a multiple "
- "of %d", len, ACTION_ALIGNMENT);
+ "of %d", len, OFP_ACTION_ALIGN);
return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_LEN);
}
if (iter->pos != iter->end) {
const union ofp_action *a = iter->pos;
unsigned int len = ntohs(a->header.len);
- iter->pos += len / ACTION_ALIGNMENT;
+ iter->pos += len / OFP_ACTION_ALIGN;
return a;
} else {
return NULL;
ofputil_pull_actions(struct ofpbuf *b, unsigned int actions_len,
union ofp_action **actionsp, size_t *n_actionsp)
{
- if (actions_len % ACTION_ALIGNMENT != 0) {
+ if (actions_len % OFP_ACTION_ALIGN != 0) {
VLOG_DBG_RL(&bad_ofmsg_rl, "OpenFlow message actions length %u "
- "is not a multiple of %d", actions_len, ACTION_ALIGNMENT);
+ "is not a multiple of %d", actions_len, OFP_ACTION_ALIGN);
goto error;
}
goto error;
}
- *n_actionsp = actions_len / ACTION_ALIGNMENT;
+ *n_actionsp = actions_len / OFP_ACTION_ALIGN;
return 0;
error:
struct ofpbuf;
struct ofp_action_header;
+/* Alignment of ofp_actions. */
+#define OFP_ACTION_ALIGN 8
+
/* OpenFlow protocol utility functions. */
void *make_openflow(size_t openflow_len, uint8_t type, struct ofpbuf **);
void *make_nxmsg(size_t openflow_len, uint32_t subtype, struct ofpbuf **);