diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-12-01 00:16:59 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-12-07 11:49:11 +0900 |
commit | 3e98bf7aaccd3657a13a6a72505bd36541fbad2c (patch) | |
tree | 4dc6e1700e0e2248efd2df2b9ab526aa613c46ac | |
parent | 6df14f6ffd161a3710c699f69a09d41355f8f34a (diff) |
of1.3: fix OFPT_PACKET_IN parser
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/ofproto/ofproto_v1_3.py | 4 | ||||
-rw-r--r-- | 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 ec54ef8c..e2869df3 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 1499ce90..db31dea8 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 |