[ovs-dev] [PATCH 33/41] ofp-util: Allow decoding of Open Flow 1.1 & 1.2 Port Status Request Messages

Simon Horman horms at verge.net.au
Tue Aug 7 21:50:08 UTC 2012


Signed-off-by: Simon Horman <horms at verge.net.au>

---

v10
* No change

v9
* Manual Rebase
* Make use of enum ofp_version

v8
* Omitted

v7
* Omitted

v6
* No change

v5
* Initial Post
---
 ofproto/ofproto.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index cbf90c9..00b9bc4 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -2428,13 +2428,34 @@ handle_port_stats_request(struct ofconn *ofconn,
                           const struct ofp_header *request)
 {
     struct ofproto *p = ofconn_get_ofproto(ofconn);
-    const struct ofp10_port_stats_request *psr = ofpmsg_body(request);
     struct ofport *port;
     struct list replies;
+    uint16_t port_no;
+
+    switch ((enum ofp_version)request->version) {
+    case OFP12_VERSION:
+    case OFP11_VERSION: {
+        const struct ofp11_port_stats_request *psr = ofpmsg_body(request);
+        enum ofperr error = ofputil_port_from_ofp11(psr->port_no, &port_no);
+        if (error) {
+            return error;
+        }
+        break;
+    }
+
+    case OFP10_VERSION: {
+        const struct ofp10_port_stats_request *psr = ofpmsg_body(request);
+        port_no = ntohs(psr->port_no);
+        break;
+    }
+
+    default:
+        NOT_REACHED();
+    }
 
     ofpmp_init(&replies, request);
-    if (psr->port_no != htons(OFPP_NONE)) {
-        port = ofproto_get_port(p, ntohs(psr->port_no));
+    if (port_no != OFPP_NONE) {
+        port = ofproto_get_port(p, port_no);
         if (port) {
             append_port_stat(port, request->version, &replies);
         }
-- 
1.7.10.2.484.gcd07cc5




More information about the dev mailing list