of1.3: fix OFPT_PACKET_IN parser

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
FUJITA Tomonori 2012-12-01 00:16:59 +09:00
parent 6df14f6ffd
commit 3e98bf7aac
2 changed files with 13 additions and 4 deletions

View File

@ -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

View File

@ -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