[ovs-dev] [PATCH 26/48] ofp-util: Allow decoding of Open Flow 1.2 Flow Removed Messages

Simon Horman horms at verge.net.au
Mon Jun 25 06:44:29 UTC 2012


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

---

v4
* No change

v3
* No change

*v3
Initial post
---
 lib/ofp-util.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 194d1de..160bdb5 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -820,6 +820,8 @@ static const struct ofputil_msg_type ofputil_msg_types[] = {
         MIN_SIZE,                               \
         EXTRA_MULTIPLE                          \
     }
+    OFPT12(OFPT_FLOW_REMOVED,       OFPT_FLOW_REMOVED,
+           sizeof(struct ofp12_flow_removed), 0),
     OFPT12(OFPT11_FLOW_MOD,     OFPT11_FLOW_MOD,
            sizeof(struct ofp11_flow_mod), 1),
 #undef OPFT12
@@ -2291,7 +2293,31 @@ ofputil_decode_flow_removed(struct ofputil_flow_removed *fr,
 
     ofputil_decode_msg_type(oh, &type);
     code = ofputil_msg_type_code(type);
-    if (code == OFPUTIL_OFPT_FLOW_REMOVED) {
+    if (code == OFPUTIL_OFPT_FLOW_REMOVED && oh->version == OFP12_VERSION) {
+        const struct ofp12_flow_removed *ofr;
+        struct ofpbuf b;
+        int error;
+
+        ofpbuf_use_const(&b, oh, ntohs(oh->length));
+
+        ofr = ofpbuf_pull(&b, sizeof *ofr);
+        error = ofputil_pull_ofp12_match(&b, ntohs(ofr->priority),
+                                         &fr->rule, NULL, NULL);
+        if (error) {
+            return error;
+        }
+
+        fr->cookie = ofr->cookie;
+        fr->reason = ofr->reason;
+        /* FIXMIE: table_id is ignored */
+        fr->duration_sec = ntohl(ofr->duration_sec);
+        fr->duration_nsec = ntohl(ofr->duration_nsec);
+        fr->idle_timeout = ntohs(ofr->idle_timeout);
+        /* FIXMIE: hard_timeout is ignored */
+        fr->packet_count = ntohll(ofr->packet_count);
+        fr->byte_count = ntohll(ofr->byte_count);
+    } else if (code == OFPUTIL_OFPT_FLOW_REMOVED &&
+               oh->version == OFP10_VERSION) {
         const struct ofp_flow_removed *ofr;
 
         ofr = (const struct ofp_flow_removed *) oh;
-- 
1.7.10.2.484.gcd07cc5




More information about the dev mailing list