static bool
ofphdrs_is_stat(const struct ofphdrs *hdrs)
{
- return (hdrs->version == OFP10_VERSION
- ? (hdrs->type == OFPT10_STATS_REQUEST ||
- hdrs->type == OFPT10_STATS_REPLY)
- : (hdrs->type == OFPT11_STATS_REQUEST ||
- hdrs->type == OFPT11_STATS_REPLY));
+ switch ((enum ofp_version) hdrs->version) {
+ case OFP10_VERSION:
+ return (hdrs->type == OFPT10_STATS_REQUEST ||
+ hdrs->type == OFPT10_STATS_REPLY);
+ case OFP11_VERSION:
+ case OFP12_VERSION:
+ return (hdrs->type == OFPT11_STATS_REQUEST ||
+ hdrs->type == OFPT11_STATS_REPLY);
+ }
+
+ return false;
}
size_t
return sizeof(struct nicira_header);
}
- if (hdrs->version == OFP10_VERSION) {
+ switch ((enum ofp_version) hdrs->version) {
+ case OFP10_VERSION:
if (hdrs->type == OFPT10_STATS_REQUEST ||
hdrs->type == OFPT10_STATS_REPLY) {
return (hdrs->stat == OFPST_VENDOR
? sizeof(struct nicira10_stats_msg)
: sizeof(struct ofp10_stats_msg));
}
- } else {
+ break;
+
+ case OFP11_VERSION:
+ case OFP12_VERSION:
if (hdrs->type == OFPT11_STATS_REQUEST ||
hdrs->type == OFPT11_STATS_REPLY) {
return (hdrs->stat == OFPST_VENDOR
? sizeof(struct nicira11_stats_msg)
: sizeof(struct ofp11_stats_msg));
}
+ break;
}
return sizeof(struct ofp_header);
enum ofperr error;
hdrs = instance->hdrs;
- if (hdrs.version == OFP10_VERSION) {
+ switch ((enum ofp_version)hdrs.version) {
+ case OFP10_VERSION:
assert(hdrs.type == OFPT10_STATS_REQUEST);
hdrs.type = OFPT10_STATS_REPLY;
- } else {
+ break;
+ case OFP11_VERSION:
+ case OFP12_VERSION:
assert(hdrs.type == OFPT11_STATS_REQUEST);
hdrs.type = OFPT11_STATS_REPLY;
+ break;
+ default:
+ NOT_REACHED();
}
error = ofpraw_from_ofphdrs(&reply_raw, &hdrs);
return (const uint8_t *) oh + ofphdrs_len(&hdrs);
}
\f
+static ovs_be16 *ofpmp_flags__(const struct ofp_header *);
+
/* Initializes 'replies' as a new list of stats messages that reply to
* 'request', which must be a stats request message. Initially the list will
* consist of only a single reply part without any body. The caller should
ofpbuf_put(next, msg->data, hdrs_len);
list_push_back(replies, &next->list_node);
+ *ofpmp_flags__(msg->data) |= htons(OFPSF_REPLY_MORE);
+
return next;
}
}
static ovs_be16 *
ofpmp_flags__(const struct ofp_header *oh)
{
- return (oh->version == OFP10_VERSION
- ? &((struct ofp10_stats_msg *) oh)->flags
- : &((struct ofp11_stats_msg *) oh)->flags);
+ switch ((enum ofp_version)oh->version) {
+ case OFP10_VERSION:
+ return &((struct ofp10_stats_msg *) oh)->flags;
+ case OFP11_VERSION:
+ case OFP12_VERSION:
+ return &((struct ofp11_stats_msg *) oh)->flags;
+ default:
+ NOT_REACHED();
+ }
}
/* Returns the OFPSF_* flags found in the OpenFlow stats header of 'oh', which