[ovs-dev] [PATCH 10/22] ofp-util: Refactor encoding of OpenFlow 1.1 group desc reply messages

Simon Horman simon.horman at netronome.com
Mon Nov 10 04:47:57 UTC 2014


This refactoring is in preparation for supporting encoding
of (draft) OpenFlow 1.5 group mod messages.

EXT-350
Signed-off-by: Simon Horman <simon.horman at netronome.com>
---
 lib/ofp-util.c | 39 +++++++++++++++++++++++++++++++--------
 1 file changed, 31 insertions(+), 8 deletions(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 7f8b920..d71bc80 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -7207,16 +7207,13 @@ ofputil_put_ofp11_bucket(const struct ofputil_bucket *bucket,
     ob->watch_group = htonl(bucket->watch_group);
 }
 
-/* Appends a group stats reply that contains the data in 'gds' to those already
- * present in the list of ofpbufs in 'replies'.  'replies' should have been
- * initialized with ofpmp_init(). */
-void
-ofputil_append_group_desc_reply(const struct ofputil_group_desc *gds,
-                                struct list *buckets,
-                                struct list *replies)
+static void
+ofputil_append_ofp11_group_desc_reply(const struct ofputil_group_desc *gds,
+                                      struct list *buckets,
+                                      struct list *replies,
+                                      enum ofp_version version)
 {
     struct ofpbuf *reply = ofpbuf_from_list(list_back(replies));
-    enum ofp_version version = ofpmp_version(replies);
     struct ofp11_group_desc_stats *ogds;
     struct ofputil_bucket *bucket;
     size_t start_ogds;
@@ -7234,6 +7231,32 @@ ofputil_append_group_desc_reply(const struct ofputil_group_desc *gds,
     ofpmp_postappend(replies, start_ogds);
 }
 
+/* Appends a group stats reply that contains the data in 'gds' to those already
+ * present in the list of ofpbufs in 'replies'.  'replies' should have been
+ * initialized with ofpmp_init(). */
+void
+ofputil_append_group_desc_reply(const struct ofputil_group_desc *gds,
+                                struct list *buckets,
+                                struct list *replies)
+{
+    enum ofp_version version = ofpmp_version(replies);
+
+    switch (version)
+    {
+    case OFP11_VERSION:
+    case OFP12_VERSION:
+    case OFP13_VERSION:
+    case OFP14_VERSION:
+    case OFP15_VERSION:
+        ofputil_append_ofp11_group_desc_reply(gds, buckets, replies, version);
+        break;
+
+    case OFP10_VERSION:
+    default:
+        OVS_NOT_REACHED();
+    }
+}
+
 static enum ofperr
 ofputil_pull_ofp11_buckets(struct ofpbuf *msg, size_t buckets_length,
                            enum ofp_version version, struct list *buckets)
-- 
2.1.1




More information about the dev mailing list