Signed-off-by: FUJITA Tomonori <[email protected]>
---
 ryu/ofproto/ofproto_v1_3.py        |    4 ++--
 ryu/ofproto/ofproto_v1_3_parser.py |   13 +++++++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/ryu/ofproto/ofproto_v1_3.py b/ryu/ofproto/ofproto_v1_3.py
index ec54ef8..e2869df 100644
--- a/ryu/ofproto/ofproto_v1_3.py
+++ b/ryu/ofproto/ofproto_v1_3.py
@@ -763,10 +763,10 @@ assert (calcsize(OFP_ASYNC_CONFIG_PACK_STR) + 
OFP_HEADER_SIZE ==
         OFP_ASYNC_CONFIG_SIZE)
 
 # struct ofp_packet_in
-OFP_PACKET_IN_PACK_STR = '!IHBBQ' + _OFP_MATCH_PACK_STR
+OFP_PACKET_IN_PACK_STR = '!IHBBQ'
 OFP_PACKET_IN_SIZE = 32
 OFP_PACKET_IN_DATA_OFFSET = 18
-assert (calcsize(OFP_PACKET_IN_PACK_STR) + OFP_HEADER_SIZE ==
+assert (calcsize(OFP_PACKET_IN_PACK_STR) + OFP_MATCH_SIZE + OFP_HEADER_SIZE ==
         OFP_PACKET_IN_SIZE)
 
 # enum ofp_packet_in_reason
diff --git a/ryu/ofproto/ofproto_v1_3_parser.py 
b/ryu/ofproto/ofproto_v1_3_parser.py
index 1499ce9..db31dea 100644
--- a/ryu/ofproto/ofproto_v1_3_parser.py
+++ b/ryu/ofproto/ofproto_v1_3_parser.py
@@ -1286,8 +1286,17 @@ class OFPPacketIn(MsgBase):
              ofproto_v1_3.OFP_PACKET_IN_PACK_STR,
              msg.buf, ofproto_v1_3.OFP_HEADER_SIZE)
 
-        offset = ofproto_v1_3.OFP_HEADER_SIZE + ofproto_v1_3.OFP_PACKET_IN_SIZE
-        msg.match = OFPMatch.parser(buf, offset - ofproto_v1_3.OFP_MATCH_SIZE)
+        msg.match = OFPMatch.parser(msg.buf, ofproto_v1_3.OFP_PACKET_IN_SIZE -
+                                    ofproto_v1_3.OFP_MATCH_SIZE)
+
+        match_len = utils.round_up(msg.match.length, 8)
+        msg.data = msg.buf[(ofproto_v1_3.OFP_PACKET_IN_SIZE -
+                            ofproto_v1_3.OFP_MATCH_SIZE + match_len + 2):]
+
+        if msg.total_len < len(msg.data):
+            # discard padding for 8-byte alignment of OFP packet
+            msg.data = msg.data[:msg.total_len]
+
         return msg
 
 
-- 
1.7.4.4


------------------------------------------------------------------------------
Keep yourself connected to Go Parallel: 
TUNE You got it built. Now make it sing. Tune shows you how.
http://goparallel.sourceforge.net
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to