flow: Set ttl in flow_compose().
[openvswitch] / lib / ofp-msgs.c
index 48ecafc6b75297c7bf7b02b559f446982bf9c68c..00e1a84481a3fa96238fde092e899cc3a8a2adb1 100644 (file)
@@ -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 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);
@@ -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);
 }
 \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
@@ -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 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