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 <[email protected]>
---
 ryu/ofproto/ofproto_v1_5_parser.py | 43 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/ryu/ofproto/ofproto_v1_5_parser.py 
b/ryu/ofproto/ofproto_v1_5_parser.py
index 066ace2..01c7a4a 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 = {}
 
 
[email protected]_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
-- 
1.9.1



------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to