ofpprop_end(msg, start_ofs);
}
+/* Adds a property with the given 'type' to 'msg', consisting of a struct
+ * ofp_prop_header or ofp_prop_experimenter followed by enough zero bytes to
+ * total 'len' bytes, followed by padding to bring the property up to a
+ * multiple of 8 bytes. Returns the property header. */
+void *
+ofpprop_put_zeros(struct ofpbuf *msg, uint64_t type, size_t len)
+{
+ void *header = ofpbuf_put_zeros(msg, ROUND_UP(len, 8));
+ if (!ofpprop_is_experimenter(type)) {
+ struct ofp_prop_header *oph = header;
+ oph->type = htons(type);
+ oph->len = htons(len);
+ } else {
+ struct ofp_prop_experimenter *ope = header;
+ ope->type = htons(0xffff);
+ ope->len = htons(len);
+ ope->experimenter = htonl(ofpprop_type_to_exp_id(type));
+ ope->exp_type = htonl(ofpprop_type_to_exp_type(type));
+ }
+ return header;
+}
+
/* Adds a property with the given 'type' and 16-bit 'value' to 'msg'. */
void
ofpprop_put_be16(struct ofpbuf *msg, uint64_t type, ovs_be16 value)
/* Serializing properties. */
void ofpprop_put(struct ofpbuf *, uint64_t type,
const void *value, size_t len);
+void *ofpprop_put_zeros(struct ofpbuf *, uint64_t type, size_t len);
void ofpprop_put_be16(struct ofpbuf *, uint64_t type, ovs_be16 value);
void ofpprop_put_be32(struct ofpbuf *, uint64_t type, ovs_be32 value);
void ofpprop_put_be64(struct ofpbuf *, uint64_t type, ovs_be64 value);
op->config = htonl(pp->config & OFPPC11_ALL);
op->state = htonl(pp->state & OFPPS11_ALL);
- eth = ofpbuf_put_zeros(b, sizeof *eth);
- eth->type = htons(OFPPDPT14_ETHERNET);
- eth->length = htons(sizeof *eth);
+ eth = ofpprop_put_zeros(b, OFPPDPT14_ETHERNET, sizeof *eth);
eth->curr = netdev_port_features_to_ofp11(pp->curr);
eth->advertised = netdev_port_features_to_ofp11(pp->advertised);
eth->supported = netdev_port_features_to_ofp11(pp->supported);
if (td->vacancy == OFPUTIL_TABLE_VACANCY_ON) {
struct ofp14_table_mod_prop_vacancy *otv;
- otv = ofpbuf_put_zeros(reply, sizeof *otv);
- otv->type = htons(OFPTMPT14_VACANCY);
- otv->length = htons(sizeof *otv);
+ otv = ofpprop_put_zeros(reply, OFPTMPT14_VACANCY, sizeof *otv);
otv->vacancy_down = td->table_vacancy.vacancy_down;
otv->vacancy_up = td->table_vacancy.vacancy_up;
otv->vacancy = td->table_vacancy.vacancy;
case OFP14_VERSION:
case OFP15_VERSION: {
struct ofp14_table_mod *otm;
- struct ofp14_table_mod_prop_vacancy *otv;
b = ofpraw_alloc(OFPRAW_OFPT14_TABLE_MOD, ofp_version, 0);
otm = ofpbuf_put_zeros(b, sizeof *otm);
ofpprop_put_u32(b, OFPTMPT14_EVICTION, tm->eviction_flags);
}
if (tm->vacancy == OFPUTIL_TABLE_VACANCY_ON) {
- otv = ofpbuf_put_zeros(b, sizeof *otv);
- otv->type = htons(OFPTMPT14_VACANCY);
- otv->length = htons(sizeof *otv);
+ struct ofp14_table_mod_prop_vacancy *otv;
+
+ otv = ofpprop_put_zeros(b, OFPTMPT14_VACANCY, sizeof *otv);
otv->vacancy_down = tm->table_vacancy.vacancy_down;
otv->vacancy_up = tm->table_vacancy.vacancy_up;
}
ps14->rx_errors = htonll(ops->stats.rx_errors);
ps14->tx_errors = htonll(ops->stats.tx_errors);
- eth = ofpbuf_put_uninit(reply, sizeof *eth);
- eth->type = htons(OFPPSPT14_ETHERNET);
- eth->length = htons(sizeof *eth);
- memset(eth->pad, 0, sizeof eth->pad);
+ eth = ofpprop_put_zeros(reply, OFPPSPT14_ETHERNET, sizeof *eth);
eth->rx_frame_err = htonll(ops->stats.rx_frame_errors);
eth->rx_over_err = htonll(ops->stats.rx_over_errors);
eth->rx_crc_err = htonll(ops->stats.rx_crc_errors);