X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fofp-msgs.c;h=d0f5da69c7efe82640b116f3dc4047f9f9383eaf;hb=c4069512603ea753576911da052b3f233026886d;hp=48ecafc6b75297c7bf7b02b559f446982bf9c68c;hpb=e2b9ac44c82590c2a9a27bff79ae43899277f703;p=sliver-openvswitch.git diff --git a/lib/ofp-msgs.c b/lib/ofp-msgs.c index 48ecafc6b..d0f5da69c 100644 --- a/lib/ofp-msgs.c +++ b/lib/ofp-msgs.c @@ -259,11 +259,18 @@ 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: + case OFP13_VERSION: + return (hdrs->type == OFPT11_STATS_REQUEST || + hdrs->type == OFPT11_STATS_REPLY); + } + + return false; } size_t @@ -273,20 +280,26 @@ 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 ofp10_stats_msg)); } - } else { + break; + + case OFP11_VERSION: + case OFP12_VERSION: + case OFP13_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); @@ -686,12 +699,19 @@ 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: + case OFP13_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 +792,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 +837,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 +878,16 @@ 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 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: + case OFP13_VERSION: + return &((struct ofp11_stats_msg *) oh)->flags; + default: + NOT_REACHED(); + } } /* Returns the OFPSF_* flags found in the OpenFlow stats header of 'oh', which