diff options
author | Yusuke Iwase <iwase.yusuke0@gmail.com> | 2015-08-07 11:29:12 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-08 13:24:20 +0900 |
commit | 1fef327dc49ca5d32256f94cf73a8257f71d9255 (patch) | |
tree | 8f734b8b7f8b33a8221e185b2f8e8ca7e7b93dc7 | |
parent | a4a75eb2a50eaffdd06e3bbb480dc55bde0e30c9 (diff) |
ofproto_v1_5_parser: Add OFPBundlePropTime support
OpenFlow Spec 1.5 introduces ofp_bundle_prop_time property
which is used in scheduled bundles.
This patch adds ofp_bundle_prop_time property support.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/ofproto/ofproto_v1_5_parser.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/ryu/ofproto/ofproto_v1_5_parser.py b/ryu/ofproto/ofproto_v1_5_parser.py index f6b5d286..bd398a21 100644 --- a/ryu/ofproto/ofproto_v1_5_parser.py +++ b/ryu/ofproto/ofproto_v1_5_parser.py @@ -1283,10 +1283,53 @@ class OFPRolePropExperimenter(OFPPropCommonExperimenter4ByteData): pass +class OFPTime(StringifyMixin): + def __init__(self, seconds=None, nanoseconds=None): + self.seconds = seconds + self.nanoseconds = nanoseconds + + @classmethod + def parser(cls, buf, offset): + cls_ = cls() + (cls_.seconds, cls_.nanoseconds) = struct.unpack_from( + ofproto.OFP_TIME_PACK_STR, buf, offset) + return cls_ + + def serialize(self, buf, offset): + msg_pack_into(ofproto.OFP_TIME_PACK_STR, buf, offset, + self.seconds, self.nanoseconds) + return ofproto.OFP_TIME_SIZE + + class OFPBundleProp(OFPPropBase): _TYPES = {} +@OFPBundleProp.register_type(ofproto.OFPBPT_TIME) +class OFPBundlePropTime(OFPBundleProp): + def __init__(self, type_=None, length=None, scheduled_time=None): + super(OFPBundlePropTime, self).__init__(type_, length) + self.scheduled_time = scheduled_time + + @classmethod + def parser(cls, buf): + prop = cls() + offset = ofproto.OFP_BUNDLE_PROP_TIME_PACK_STR0_SIZE + prop.scheduled_time = OFPTime.parser(buf, offset) + return prop + + def serialize(self): + # fixup + self.length = ofproto.OFP_BUNDLE_PROP_TIME_PACK_STR_SIZE + + buf = bytearray() + msg_pack_into(ofproto.OFP_BUNDLE_PROP_TIME_PACK_STR0, buf, 0, + self.type, self.length) + offset = ofproto.OFP_BUNDLE_PROP_TIME_PACK_STR0_SIZE + self.scheduled_time.serialize(buf, offset) + return buf + + @OFPBundleProp.register_type(ofproto.OFPRPT_EXPERIMENTER) class OFPBundlePropExperimenter(OFPPropCommonExperimenter4ByteData): pass |