summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYusuke Iwase <iwase.yusuke0@gmail.com>2015-08-07 11:29:48 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-08-08 13:24:20 +0900
commit605165ce9209341a66b22172ffd24a770a3d7106 (patch)
treea507f4796ac0984a84b65c5275ad3cab0fc40dde
parent964df7e69d1d5661eda0f7051903e2fe10d4bdab (diff)
ofproto_v1_5_parser: Add OFPBundleFeaturesProp support
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 <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/ofproto/ofproto_v1_5.py11
-rw-r--r--ryu/ofproto/ofproto_v1_5_parser.py51
2 files changed, 55 insertions, 7 deletions
diff --git a/ryu/ofproto/ofproto_v1_5.py b/ryu/ofproto/ofproto_v1_5.py
index e55eea33..e93a820d 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 c5b7655f..f6b5d286 100644
--- a/ryu/ofproto/ofproto_v1_5_parser.py
+++ b/ryu/ofproto/ofproto_v1_5_parser.py
@@ -4063,6 +4063,57 @@ class OFPFlowMonitorReply(OFPMultipartReply):
super(OFPFlowMonitorReply, self).__init__(datapath, **kwargs)
+class OFPBundleFeaturesProp(OFPPropBase):
+ _TYPES = {}
+
+
+@OFPBundleFeaturesProp.register_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
+
+
+@OFPBundleFeaturesProp.register_type(ofproto.OFPTMPBF_EXPERIMENTER)
+class OFPBundleFeaturesPropExperimenter(OFPPropCommonExperimenter4ByteData):
+ pass
+
+
class OFPExperimenterMultipart(ofproto_parser.namedtuple(
'OFPExperimenterMultipart',
('experimenter', 'exp_type', 'data'))):