diff options
author | Oren Spector <oren@oliver-solutions.com> | 2013-06-10 15:44:09 +0300 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2013-06-11 00:01:47 +0900 |
commit | 6b2b043c4e458a116ae79024b6ad718f70e567ec (patch) | |
tree | f79a4c08e06598a6410b0ca479c09819d03e99cb | |
parent | 6d414d0cdd802f015a4bc63a0e3c1f50385e03b7 (diff) |
of1.3: Fix parsing of OFP_QUEUE_GET_CONFIG_REPLY
Make parsing similar to that of OpenFlow 1.2 (message has the same format as in 1.3)
Signed-off-by: Oren Spector <oren@oliver-solutions.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/ofproto/ofproto_v1_3_parser.py | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/ryu/ofproto/ofproto_v1_3_parser.py b/ryu/ofproto/ofproto_v1_3_parser.py index 524994d3..f8221f27 100644 --- a/ryu/ofproto/ofproto_v1_3_parser.py +++ b/ryu/ofproto/ofproto_v1_3_parser.py @@ -2702,12 +2702,9 @@ class OFPQueuePropMinRate(OFPQueueProp): @classmethod def parser(cls, buf, offset): - msg = super(OFPQueuePropMinRate, cls).parser(cls, buf, offset) - offset += ofproto_v1_3.OFP_QUEUE_PROP_MIN_RATE_SIZE - (msg.rate,) = struct.unpack_from( - ofproto_v1_3.OFP_QUEUE_PROP_MIN_RATE_PACK_STR, buf, - offset) - return msg + (rate,) = struct.unpack_from( + ofproto_v1_3.OFP_QUEUE_PROP_MIN_RATE_PACK_STR, buf, offset) + return cls(rate) @OFPQueueProp.register_queue_property( @@ -2715,41 +2712,40 @@ class OFPQueuePropMinRate(OFPQueueProp): ofproto_v1_3.OFP_QUEUE_PROP_MAX_RATE_SIZE) class OFPQueuePropMaxRate(OFPQueueProp): def __init__(self, rate): - super(OFPQueuePropMinRate, self).__init__() + super(OFPQueuePropMaxRate, self).__init__() self.rate = rate @classmethod def parser(cls, buf, offset): - msg = super(OFPQueuePropMinRate, cls).parser(cls, buf, offset) - offset += ofproto_v1_3.OFP_QUEUE_PROP_MIN_RATE_SIZE - (msg.rate,) = struct.unpack_from( - ofproto_v1_3.OFP_QUEUE_PROP_MIN_RATE_PACK_STR, buf, - offset) - return msg + (rate,) = struct.unpack_from( + ofproto_v1_3.OFP_QUEUE_PROP_MAX_RATE_PACK_STR, buf, offset) + return cls(rate) # TODO: add ofp_queue_prop_experimenter -class OFPPacketQueue(MsgBase): - def __init__(self, datapath): - super(OFPPacketQueue, self).__init__(datapath) +class OFPPacketQueue(object): + def __init__(self, queue_id, port, len_, properties): + super(OFPPacketQueue, self).__init__() + self.queue_id = queue_id + self.port = port + self.len = len_ + self.properties = properties @classmethod def parser(cls, buf, offset): - (msg.queue_id, msg.port, msg.len) = struct.unpack_from( - ofproto_v1_3.OFP_PACKET_QUEUE_PACK_STR, msg.buf, offset) - + (queue_id, port, len_) = struct.unpack_from( + ofproto_v1_3.OFP_PACKET_QUEUE_PACK_STR, buf, offset) length = ofproto_v1_3.OFP_PACKET_QUEUE_SIZE offset += ofproto_v1_3.OFP_PACKET_QUEUE_SIZE - msg.properties = [] - while length < msg.len: - properties = OFPQueueProp.parser(buf, offset) - msg.properties.append(properties) - offset += properties.len - length += properties.len - - return msg + properties = [] + while length < len_: + queue_prop = OFPQueueProp.parser(buf, offset) + properties.append(queue_prop) + offset += queue_prop.len + length += queue_prop.len + return cls(queue_id, port, len_, properties) @_register_parser @@ -2763,15 +2759,14 @@ class OFPQueueGetConfigReply(MsgBase): msg = super(OFPQueueGetConfigReply, cls).parser(datapath, version, msg_type, msg_len, xid, buf) - offset = ofproto_v1_3.OFP_HEADER_SIZE (msg.port,) = struct.unpack_from( ofproto_v1_3.OFP_QUEUE_GET_CONFIG_REPLY_PACK_STR, msg.buf, - offset) + ofproto_v1_3.OFP_HEADER_SIZE) msg.queues = [] - offset += ofproto_v1_3.OFP_QUEUE_GET_CONFIG_REPLY_SIZE + offset = ofproto_v1_3.OFP_QUEUE_GET_CONFIG_REPLY_SIZE while offset < msg_len: - queue = OFPPacketQueue.parser(buf, offset) + queue = OFPPacketQueue.parser(msg.buf, offset) msg.queues.append(queue) offset += queue.len |