diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-07-13 18:58:41 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-07-14 08:52:53 +0900 |
commit | c9edce48725f17fef4330e4f41d81f1894b1575d (patch) | |
tree | c397bb1725268740e90976c2fe3efd966474e4ce | |
parent | 323610d21f161cc54a0d3a53fdf37c644af8620a (diff) |
of1.2: add OFPQueuePropMinRate and OFPQueuePropMaxRate
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/ofproto/ofproto_v1_2_parser.py | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/ryu/ofproto/ofproto_v1_2_parser.py b/ryu/ofproto/ofproto_v1_2_parser.py index 1f437d5d..d5b8ac26 100644 --- a/ryu/ofproto/ofproto_v1_2_parser.py +++ b/ryu/ofproto/ofproto_v1_2_parser.py @@ -1305,17 +1305,45 @@ class OFPPacketQueue(object): @classmethod def parser(cls, buf, offset): - (msg.queue_id, msg.port, msg.len) = struct.unpack_from( + (queue_id, port, len_) = struct.unpack_from( ofproto_v1_2.OFP_PACKET_QUEUE_PACK_STR, buf, offset) length = ofproto_v1_2.OFP_PACKET_QUEUE_SIZE offset += ofproto_v1_2.OFP_PACKET_QUEUE_SIZE - msg.properties = [] - while length < msg.len: + properties = [] + while length < len_: queue_prop = OFPQueueProp.parser(buf, offset) - msg.properties.append(queue_prop) + properties.append(queue_prop) offset += queue_prop.len - length += queue_prop - return msg + length += queue_prop.len + return cls(queue_id, port, len_, properties) + + +@OFPQueueProp.register_property(ofproto_v1_2.OFPQT_MIN_RATE, + ofproto_v1_2.OFP_QUEUE_PROP_MIN_RATE_SIZE) +class OFPQueuePropMinRate(OFPQueueProp): + def __init__(self, rate): + super(OFPQueuePropMinRate, self).__init__() + self.rate = rate + + @classmethod + def parser(cls, buf, offset): + (rate,) = struct.unpack_from( + ofproto_v1_2.OFP_QUEUE_PROP_MIN_RATE_PACK_STR, buf, offset) + return cls(rate) + + +@OFPQueueProp.register_property(ofproto_v1_2.OFPQT_MAX_RATE, + ofproto_v1_2.OFP_QUEUE_PROP_MAX_RATE_SIZE) +class OFPQueuePropMaxRate(OFPQueueProp): + def __init__(self, rate): + super(OFPQueuePropMaxRate, self).__init__() + self.rate = rate + + @classmethod + def parser(cls, buf, offset): + (rate,) = struct.unpack_from( + ofproto_v1_2.OFP_QUEUE_PROP_MAX_RATE_PACK_STR, buf, offset) + return cls(rate) @_register_parser @@ -1335,8 +1363,9 @@ class OFPQueueGetConfigReply(MsgBase): msg.queues = [] length = ofproto_v1_2.OFP_QUEUE_GET_CONFIG_REPLY_SIZE - while length < msg.length: - queue = OFPPacketQueue.parser(buf, offset) + offset = ofproto_v1_2.OFP_QUEUE_GET_CONFIG_REPLY_SIZE + while length < msg.msg_len: + queue = OFPPacketQueue.parser(msg.buf, offset) msg.queues.append(queue) offset += queue.len |