X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=lib%2Fofp-msgs.c;h=00e1a84481a3fa96238fde092e899cc3a8a2adb1;hb=0135dc8b4e91886b0e9f5c3e1c3e973d9ee575c7;hp=1d11e7f359f7bdd0f2fa621cf1f4d1c0886a8100;hpb=982697a4d24caa0a3bdaf85db67619338b382e50;p=openvswitch diff --git a/lib/ofp-msgs.c b/lib/ofp-msgs.c index 1d11e7f3..00e1a844 100644 --- a/lib/ofp-msgs.c +++ b/lib/ofp-msgs.c @@ -174,13 +174,13 @@ ofphdrs_decode(struct ofphdrs *hdrs, } else if (hdrs->version == OFP10_VERSION && (hdrs->type == OFPT10_STATS_REQUEST || hdrs->type == OFPT10_STATS_REPLY)) { - const struct ofp_stats_msg *osm; + const struct ofp10_stats_msg *osm; /* Get statistic type (OFPST_*). */ if (length < sizeof *osm) { return OFPERR_OFPBRC_BAD_LEN; } - osm = (const struct ofp_stats_msg *) oh; + osm = (const struct ofp10_stats_msg *) oh; hdrs->stat = ntohs(osm->type); if (hdrs->stat == OFPST_VENDOR) { @@ -259,11 +259,17 @@ ofphdrs_decode_assert(struct ofphdrs *hdrs, 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 @@ -273,20 +279,25 @@ ofphdrs_len(const struct ofphdrs *hdrs) 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 ofp_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); @@ -619,7 +630,7 @@ ofpraw_put__(enum ofpraw raw, uint8_t version, ovs_be32 xid, } else if (version == OFP10_VERSION && (hdrs->type == OFPT10_STATS_REQUEST || hdrs->type == OFPT10_STATS_REPLY)) { - struct ofp_stats_msg *osm = buf->l2; + struct ofp10_stats_msg *osm = buf->l2; osm->type = htons(hdrs->stat); osm->flags = htons(0); @@ -686,12 +697,18 @@ ofpraw_stats_request_to_reply(enum ofpraw raw, uint8_t version) 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); @@ -772,6 +789,8 @@ ofpmsg_body(const struct ofp_header *oh) return (const uint8_t *) oh + ofphdrs_len(&hdrs); } +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 @@ -815,6 +834,8 @@ ofpmp_reserve(struct list *replies, size_t len) ofpbuf_put(next, msg->data, hdrs_len); list_push_back(replies, &next->list_node); + *ofpmp_flags__(msg->data) |= htons(OFPSF_REPLY_MORE); + return next; } } @@ -854,9 +875,15 @@ ofpmp_postappend(struct list *replies, size_t start_ofs) static ovs_be16 * ofpmp_flags__(const struct ofp_header *oh) { - return (oh->version == OFP10_VERSION - ? &((struct ofp_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