summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKONDOH Tasuku <kondoh.tasuku@po.ntts.co.jp>2013-02-13 10:59:37 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-02-13 18:05:18 +0900
commitd4822f6da8dfc6c162f8aa30628d3dc5807a2df6 (patch)
tree5233aba38d17fe695a872b97b9d981da1b90c142
parentbdaf539ebdc756fec60d02f7d054272215a5630f (diff)
of1.2: fix OFPQueueProp parser
- add OFP_QUEUE_PROP_HEADER_SIZE to offset of argument of propreties class. Signed-off-by: KONDOH Tasuku <kondoh.tasuku@po.ntts.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/ofproto/ofproto_v1_2_parser.py1
-rw-r--r--ryu/tests/unit/ofproto/test_parser_v12.py110
2 files changed, 55 insertions, 56 deletions
diff --git a/ryu/ofproto/ofproto_v1_2_parser.py b/ryu/ofproto/ofproto_v1_2_parser.py
index f8d2af4b..989a494e 100644
--- a/ryu/ofproto/ofproto_v1_2_parser.py
+++ b/ryu/ofproto/ofproto_v1_2_parser.py
@@ -1300,6 +1300,7 @@ class OFPQueueProp(OFPQueuePropHeader):
ofproto_v1_2.OFP_QUEUE_PROP_HEADER_PACK_STR,
buf, offset)
cls_ = cls._QUEUE_PROP_PROPERTIES.get(property_)
+ offset += ofproto_v1_2.OFP_QUEUE_PROP_HEADER_SIZE
return cls_.parser(buf, offset)
diff --git a/ryu/tests/unit/ofproto/test_parser_v12.py b/ryu/tests/unit/ofproto/test_parser_v12.py
index b1e1cfc8..75e2208a 100644
--- a/ryu/tests/unit/ofproto/test_parser_v12.py
+++ b/ryu/tests/unit/ofproto/test_parser_v12.py
@@ -3181,50 +3181,6 @@ class TestOFPQueueGetConfigReply(unittest.TestCase):
""" Test case for ofproto_v1_2_parser.OFPQueueGetConfigReply
"""
- class Datapath(object):
- ofproto = ofproto_v1_2
- ofproto_parser = ofproto_v1_2_parser
-
- # OFP_HEADER_PACK_STR
- version = ofproto_v1_2.OFP_VERSION
- msg_type = ofproto_v1_2.OFPT_QUEUE_GET_CONFIG_REPLY
- msg_len = ofproto_v1_2.OFP_QUEUE_GET_CONFIG_REPLY_SIZE \
- + ofproto_v1_2.OFP_PACKET_QUEUE_SIZE \
- + ofproto_v1_2.OFP_QUEUE_PROP_HEADER_SIZE
- xid = 2495926989
-
- fmt = ofproto_v1_2.OFP_HEADER_PACK_STR
- buf = pack(fmt, version, msg_type, msg_len, xid)
-
- # OFP_QUEUE_GET_CONFIG_REPLY_PACK_STR = '!I4x'
- # OFP_QUEUE_GET_CONFIG_REPLY_SIZE = 16
- port = 65037
-
- fmt = ofproto_v1_2.OFP_QUEUE_GET_CONFIG_REPLY_PACK_STR
- buf += pack(fmt, port)
-
- # OFP_QUEUE_PROP_HEADER_PACK_STR = '!HH4x'
- # OFP_QUEUE_PROP_HEADER_SIZE = 8
- property_ = ofproto_v1_2.OFPQT_MIN_RATE
- properties_len = ofproto_v1_2.OFP_QUEUE_PROP_HEADER_SIZE
- properties = [OFPQueuePropHeader(property_, properties_len)]
-
- buf_properties = bytearray()
- properties[0].serialize(buf_properties, 0)
-
- # OFP_PACKET_QUEUE_PACK_STR = '!IIH6x'
- # OFP_PACKET_QUEUE_SIZE = 16
- queue_id = 6606
- queue_port = 41186
- queue_len = ofproto_v1_2.OFP_PACKET_QUEUE_SIZE \
- + ofproto_v1_2.OFP_QUEUE_PROP_HEADER_SIZE
- queues = [OFPPacketQueue(queue_id, queue_port, queue_len, properties)]
-
- fmt = ofproto_v1_2.OFP_PACKET_QUEUE_PACK_STR
- buf += pack(fmt, queue_id, queue_port, queue_len) + buf_properties
-
- c = OFPQueueGetConfigReply(Datapath)
-
def setUp(self):
pass
@@ -3235,18 +3191,60 @@ class TestOFPQueueGetConfigReply(unittest.TestCase):
pass
def test_parser(self):
- res = self.c.parser(object, self.version, self.msg_type, self.msg_len,
- self.xid, self.buf)
-
- eq_(self.version, res.version)
- eq_(self.msg_type, res.msg_type)
- eq_(self.msg_len, res.msg_len)
- eq_(self.xid, res.xid)
-
- eq_(self.queue_id, res.queues[0].queue_id)
- eq_(self.queue_port, res.queues[0].port)
- eq_(self.queue_len, res.queues[0].len)
- eq_(self.property_, res.queues[0].properties[0].property)
+ version = ofproto_v1_2.OFP_VERSION
+ msg_type = ofproto_v1_2.OFPT_QUEUE_GET_CONFIG_REPLY
+ msg_len = ofproto_v1_2.OFP_QUEUE_GET_CONFIG_REPLY_SIZE \
+ + ofproto_v1_2.OFP_PACKET_QUEUE_SIZE \
+ + ofproto_v1_2.OFP_QUEUE_PROP_MIN_RATE_SIZE
+ xid = 0
+ # OFP_HEADER_PACK_STR = '!BBHI'
+ fmt = ofproto_v1_2.OFP_HEADER_PACK_STR
+ buf = pack(fmt, version, msg_type, msg_len, xid)
+
+ # OFP_QUEUE_GET_CONFIG_REPLY_PACK_STR = '!I4x'
+ fmt = ofproto_v1_2.OFP_QUEUE_GET_CONFIG_REPLY_PACK_STR
+ port = 1
+ buf += pack(fmt, port)
+
+ # OFP_PACKET_QUEUE_PACK_STR = '!IIH6x'
+ fmt = ofproto_v1_2.OFP_PACKET_QUEUE_PACK_STR
+ queue_id = 2
+ queue_port = 3
+ queue_len = ofproto_v1_2.OFP_PACKET_QUEUE_SIZE \
+ + ofproto_v1_2.OFP_QUEUE_PROP_MIN_RATE_SIZE
+ buf += pack(fmt, queue_id, queue_port, queue_len)
+
+ # OFP_QUEUE_PROP_HEADER_PACK_STR = '!HH4x'
+ fmt = ofproto_v1_2.OFP_QUEUE_PROP_HEADER_PACK_STR
+ prop_type = ofproto_v1_2.OFPQT_MIN_RATE
+ prop_len = ofproto_v1_2.OFP_QUEUE_PROP_MIN_RATE_SIZE
+ buf += pack(fmt, prop_type, prop_len)
+
+ # OFP_QUEUE_PROP_MIN_RATE_PACK_STR = '!H6x'
+ fmt = ofproto_v1_2.OFP_QUEUE_PROP_MIN_RATE_PACK_STR
+ prop_rate = 4
+ buf += pack(fmt, prop_rate)
+
+ res = OFPQueueGetConfigReply.parser(object, version, msg_type,
+ msg_len, xid, buf)
+
+ eq_(version, res.version)
+ eq_(msg_type, res.msg_type)
+ eq_(msg_len, res.msg_len)
+ eq_(xid, res.xid)
+ eq_(port, res.port)
+ ok_(res.queues)
+
+ queue = res.queues[0]
+ eq_(queue_id, queue.queue_id)
+ eq_(queue_port, queue.port)
+ eq_(queue_len, queue.len)
+ ok_(queue.properties)
+
+ prop = queue.properties[0]
+ eq_(prop_type, prop.property)
+ eq_(prop_len, prop.len)
+ eq_(prop_rate, prop.rate)
class TestOFPBarrierRequest(unittest.TestCase):