[ovs-dev] [PATCH 36/48] ofp-util: Allow decoding of Open Flow 1.1 and 1.2 Packet Out Messages

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


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

---

v4
* No change

v3
* Manual rebase
* Correct title: This patch relates to Packet Out not Packet In
* Use OFPT_PACKET_OUT instead of OFPT11_PACKET_OUT, it seems
  easier to use a single code and differentiate using the version
  in the ofp_header
* Return error value returned by ofputil_port_from_ofp11()
  rather than OFPERR_OFPBMC_BAD_VALUE.

v2
* No change
---
 lib/ofp-util.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 09739b2..f4ade7d 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -806,6 +806,8 @@ static const struct ofputil_msg_type ofputil_msg_types[] = {
            sizeof(struct ofp_switch_features), sizeof(struct ofp11_port)),
     OFPT11(OFPT_PORT_STATUS,    OFPT_PORT_STATUS,
            sizeof(struct ofp_port_status) + sizeof(struct ofp11_port), 0),
+    OFPT11(OFPT_PACKET_OUT,     OFPT11_PACKET_OUT,
+           sizeof(struct ofp11_packet_out), 1),
     OFPT11(OFPT11_FLOW_MOD,     OFPT11_FLOW_MOD,
            sizeof(struct ofp11_flow_mod), 1),
     OFPT11(OFPT_PORT_MOD,       OFPT11_PORT_MOD,
@@ -826,6 +828,8 @@ static const struct ofputil_msg_type ofputil_msg_types[] = {
            sizeof(struct ofp12_flow_removed), 0),
     OFPT12(OFPT_PACKET_IN,          OFPT_PACKET_IN,
            offsetof(struct ofp_packet_in, data), 1),
+    OFPT12(OFPT_PACKET_OUT,     OFPT11_PACKET_OUT,
+           sizeof(struct ofp11_packet_out), 1),
     OFPT12(OFPT11_FLOW_MOD,     OFPT11_FLOW_MOD,
            sizeof(struct ofp11_flow_mod), 1),
     OFPT12(OFPT_PORT_MOD,       OFPT11_PORT_MOD,
@@ -2714,7 +2718,25 @@ ofputil_decode_packet_out(struct ofputil_packet_out *po,
 
     ofpbuf_use_const(&b, oh, ntohs(oh->length));
 
-    if (oh->version == OFP10_VERSION) {
+    if (oh->version == OFP11_VERSION || oh->version == OFP12_VERSION) {
+        const struct ofp11_packet_out *opo = (const struct ofp11_packet_out *) oh;
+        enum ofperr error;
+
+        ofpbuf_pull(&b, sizeof *opo);
+
+        po->buffer_id = ntohl(opo->buffer_id);
+        error = ofputil_port_from_ofp11(opo->in_port, &po->in_port);
+        if (error) {
+            return error;
+        }
+
+        error = ofpacts_pull_openflow11_instructions(&b,
+                                                     ntohs(opo->actions_len),
+                                                     ofpacts);
+        if (error) {
+            return error;
+        }
+    } else if (oh->version == OFP10_VERSION) {
         const struct ofp_packet_out *opo = (const struct ofp_packet_out *) oh;
         enum ofperr error;
 
-- 
1.7.10.2.484.gcd07cc5




More information about the dev mailing list