OpenFlow Spec 1.5 introduces bundle features properties to  indicate
the bundle-related features that are supported by the switch.

This patch adds bundle features properties support.

Signed-off-by: IWASE Yusuke <[email protected]>
---
 ryu/ofproto/ofproto_v1_5.py        | 11 +++-----
 ryu/ofproto/ofproto_v1_5_parser.py | 51 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 7 deletions(-)

diff --git a/ryu/ofproto/ofproto_v1_5.py b/ryu/ofproto/ofproto_v1_5.py
index e55eea3..e93a820 100644
--- a/ryu/ofproto/ofproto_v1_5.py
+++ b/ryu/ofproto/ofproto_v1_5.py
@@ -1629,14 +1629,11 @@ OFP_TIME_SIZE = 16
 assert calcsize(OFP_TIME_PACK_STR) == OFP_TIME_SIZE
 
 # struct ofp_bundle_features_prop_time
-OFP_BUNDLE_FEATURES_PROP_TIME_PACK_STR = ('!HH4x' +
-                                          _OFP_TIME_PACK_STR +
-                                          _OFP_TIME_PACK_STR +
-                                          _OFP_TIME_PACK_STR +
-                                          _OFP_TIME_PACK_STR)
+OFP_BUNDLE_FEATURES_PROP_TIME_0_PACK_STR = '!HH4x'
+OFP_BUNDLE_FEATURES_PROP_TIME_0_SIZE = 8
 OFP_BUNDLE_FEATURES_PROP_TIME_SIZE = 72
-assert (calcsize(OFP_BUNDLE_FEATURES_PROP_TIME_PACK_STR) ==
-        OFP_BUNDLE_FEATURES_PROP_TIME_SIZE)
+assert (calcsize(OFP_BUNDLE_FEATURES_PROP_TIME_0_PACK_STR) +
+        OFP_TIME_SIZE * 4 == OFP_BUNDLE_FEATURES_PROP_TIME_SIZE)
 
 # enum ofp_bundle_feature_flags
 OFPBF_TIMESTAMP = 1 << 0        # Request includes a timestamp.
diff --git a/ryu/ofproto/ofproto_v1_5_parser.py 
b/ryu/ofproto/ofproto_v1_5_parser.py
index 01c7a4a..c5a28fb 100644
--- a/ryu/ofproto/ofproto_v1_5_parser.py
+++ b/ryu/ofproto/ofproto_v1_5_parser.py
@@ -4022,6 +4022,57 @@ class OFPFlowMonitorReply(OFPMultipartReply):
         super(OFPFlowMonitorReply, self).__init__(datapath, **kwargs)
 
 
+class OFPBundleFeaturesProp(OFPPropBase):
+    _TYPES = {}
+
+
[email protected]_type(ofproto.OFPTMPBF_TIME_CAPABILITY)
+class OFPBundleFeaturesPropTime(OFPBundleFeaturesProp):
+    def __init__(self, type_=None, length=None, sched_accuracy=None,
+                 sched_max_future=None, sched_max_past=None, timestamp=None):
+        super(OFPBundleFeaturesPropTime, self).__init__(type_, length)
+        self.sched_accuracy = sched_accuracy
+        self.sched_max_future = sched_max_future
+        self.sched_max_past = sched_max_past
+        self.timestamp = timestamp
+
+    @classmethod
+    def parser(cls, buf):
+        prop = cls()
+        (prop.type, prop.length) = struct.unpack_from(
+            ofproto.OFP_BUNDLE_FEATURES_PROP_TIME_0_PACK_STR, buf)
+        offset = ofproto.OFP_BUNDLE_FEATURES_PROP_TIME_0_SIZE
+
+        for f in ['sched_accuracy', 'sched_max_future', 'sched_max_past',
+                  'timestamp']:
+            t = OFPTime.parser(buf, offset)
+            setattr(prop, f, t)
+            offset += ofproto.OFP_TIME_SIZE
+
+        return prop
+
+    def serialize(self):
+        # fixup
+        self.length = ofproto.OFP_BUNDLE_FEATURES_PROP_TIME_SIZE
+
+        buf = bytearray()
+        msg_pack_into(ofproto.OFP_BUNDLE_FEATURES_PROP_TIME_0_PACK_STR, buf, 0,
+                      self.type, self.length)
+        offset = ofproto.OFP_BUNDLE_FEATURES_PROP_TIME_0_SIZE
+
+        for f in [self.sched_accuracy, self.sched_max_future,
+                  self.sched_max_past, self.timestamp]:
+            f.serialize(buf, offset)
+            offset += ofproto.OFP_TIME_SIZE
+
+        return buf
+
+
[email protected]_type(ofproto.OFPTMPBF_EXPERIMENTER)
+class OFPBundleFeaturesPropExperimenter(OFPPropCommonExperimenter4ByteData):
+    pass
+
+
 class OFPExperimenterMultipart(ofproto_parser.namedtuple(
                                'OFPExperimenterMultipart',
                                ('experimenter', 'exp_type', 'data'))):
-- 
1.9.1


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

Reply via email to