ofm->header.length = htons(size);
ofm->cookie = 0;
ofm->match.wildcards = htonl(0);
- ofm->match.in_port = htons(flow->in_port == ODPP_LOCAL ? OFPP_LOCAL
+ ofm->match.in_port = htons(flow->in_port == XFLOWP_LOCAL ? OFPP_LOCAL
: flow->in_port);
memcpy(ofm->match.dl_src, flow->dl_src, sizeof ofm->match.dl_src);
memcpy(ofm->match.dl_dst, flow->dl_dst, sizeof ofm->match.dl_dst);
opo->header.length = htons(size);
opo->header.xid = htonl(0);
opo->buffer_id = htonl(buffer_id);
- opo->in_port = htons(in_port == ODPP_LOCAL ? OFPP_LOCAL : in_port);
+ opo->in_port = htons(in_port == XFLOWP_LOCAL ? XFLOWP_LOCAL : in_port);
opo->actions_len = htons(actions_len);
ofpbuf_put(out, actions, actions_len);
if (packet) {
return 0;
}
+struct ofpbuf *
+make_nxt_flow_mod_table_id(bool enable)
+{
+ struct nxt_flow_mod_table_id *flow_mod_table_id;
+ struct ofpbuf *buffer;
+
+ flow_mod_table_id = make_openflow(sizeof *flow_mod_table_id, OFPT_VENDOR,
+ &buffer);
+
+ flow_mod_table_id->vendor = htonl(NX_VENDOR_ID);
+ flow_mod_table_id->subtype = htonl(NXT_FLOW_MOD_TABLE_ID);
+ flow_mod_table_id->set = enable;
+ return buffer;
+}
+
const struct ofp_flow_stats *
flow_stats_first(struct flow_stats_iterator *iter,
const struct ofp_stats_reply *osr)
m->wildcards = htonl(wc);
}
+/* Converts all of the fields in 'opp' from host to native byte-order. */
+void
+hton_ofp_phy_port(struct ofp_phy_port *opp)
+{
+ opp->port_no = htons(opp->port_no);
+ opp->config = htonl(opp->config);
+ opp->state = htonl(opp->state);
+ opp->curr = htonl(opp->curr);
+ opp->advertised = htonl(opp->advertised);
+ opp->supported = htonl(opp->supported);
+ opp->peer = htonl(opp->peer);
+}
+
+/* Converts all of the fields in 'opp' from native to host byte-order. */
+void
+ntoh_ofp_phy_port(struct ofp_phy_port *opp)
+{
+ /* ntohX and htonX are really the same functions. */
+ hton_ofp_phy_port(opp);
+}
+
/* Returns a string that describes 'match' in a very literal way, without
* interpreting its contents except in a very basic fashion. The returned
* string is intended to be fixed-length, so that it is easy to see differences
ntohs(match->tp_src),
ntohs(match->tp_dst));
}
+
+static uint32_t
+vendor_code_to_id(uint8_t code)
+{
+ switch (code) {
+#define OFPUTIL_VENDOR(NAME, VENDOR_ID) case NAME: return VENDOR_ID;
+ OFPUTIL_VENDORS
+#undef OFPUTIL_VENDOR
+ default:
+ return UINT32_MAX;
+ }
+}
+
+/* Creates and returns an OpenFlow message of type OFPT_ERROR with the error
+ * information taken from 'error', whose encoding must be as described in the
+ * large comment in ofp-util.h. If 'oh' is nonnull, then the error will use
+ * oh->xid as its transaction ID, and it will include up to the first 64 bytes
+ * of 'oh'.
+ *
+ * Returns NULL if 'error' is not an OpenFlow error code. */
+struct ofpbuf *
+make_ofp_error_msg(int error, const struct ofp_header *oh)
+{
+ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+
+ struct ofpbuf *buf;
+ const void *data;
+ size_t len;
+ uint8_t vendor;
+ uint16_t type;
+ uint16_t code;
+ uint32_t xid;
+
+ if (!is_ofp_error(error)) {
+ /* We format 'error' with strerror() here since it seems likely to be
+ * a system errno value. */
+ VLOG_WARN_RL(&rl, "invalid OpenFlow error code %d (%s)",
+ error, strerror(error));
+ return NULL;
+ }
+
+ if (oh) {
+ xid = oh->xid;
+ data = oh;
+ len = ntohs(oh->length);
+ if (len > 64) {
+ len = 64;
+ }
+ } else {
+ xid = 0;
+ data = NULL;
+ len = 0;
+ }
+
+ vendor = get_ofp_err_vendor(error);
+ type = get_ofp_err_type(error);
+ code = get_ofp_err_code(error);
+ if (vendor == OFPUTIL_VENDOR_OPENFLOW) {
+ struct ofp_error_msg *oem;
+
+ oem = make_openflow_xid(len + sizeof *oem, OFPT_ERROR, xid, &buf);
+ oem->type = htons(type);
+ oem->code = htons(code);
+ } else {
+ struct ofp_error_msg *oem;
+ struct nx_vendor_error *ove;
+ uint32_t vendor_id;
+
+ vendor_id = vendor_code_to_id(vendor);
+ if (vendor_id == UINT32_MAX) {
+ VLOG_WARN_RL(&rl, "error %x contains invalid vendor code %d",
+ error, vendor);
+ return NULL;
+ }
+
+ oem = make_openflow_xid(len + sizeof *oem + sizeof *ove,
+ OFPT_ERROR, xid, &buf);
+ oem->type = htons(NXET_VENDOR);
+ oem->code = htons(NXVC_VENDOR_ERROR);
+
+ ove = ofpbuf_put_uninit(buf, sizeof *ove);
+ ove->vendor = htonl(vendor_id);
+ ove->type = htons(type);
+ ove->code = htons(code);
+ }
+
+ if (len) {
+ ofpbuf_put(buf, data, len);
+ }
+
+ return buf;
+}