1 # Copyright (C) 2014 Nippon Telegraph and Telephone Corporation.
2 # Copyright (C) 2014 YAMAMOTO Takashi <yamamoto at valinux co jp>
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 from ryu.ofproto import ofproto_v1_0
18 from ryu.ofproto import ofproto_v1_0_parser
19 from ryu.ofproto import ofproto_v1_2
20 from ryu.ofproto import ofproto_v1_2_parser
21 from ryu.ofproto import ofproto_v1_3
22 from ryu.ofproto import ofproto_v1_3_parser
23 from ryu.ofproto import ofproto_v1_4
24 from ryu.ofproto import ofproto_v1_4_parser
25 from ryu.ofproto import ofproto_v1_5
26 from ryu.ofproto import ofproto_v1_5_parser
30 ofproto_v1_0.OFP_VERSION: (ofproto_v1_0, ofproto_v1_0_parser),
31 ofproto_v1_2.OFP_VERSION: (ofproto_v1_2, ofproto_v1_2_parser),
32 ofproto_v1_3.OFP_VERSION: (ofproto_v1_3, ofproto_v1_3_parser),
33 ofproto_v1_4.OFP_VERSION: (ofproto_v1_4, ofproto_v1_4_parser),
34 ofproto_v1_5.OFP_VERSION: (ofproto_v1_5, ofproto_v1_5_parser),
38 # OF versions supported by every apps in this process (intersection)
39 _supported_versions = set(_versions.keys())
42 def set_app_supported_versions(vers):
43 global _supported_versions
45 _supported_versions &= set(vers)
46 assert _supported_versions, 'No OpenFlow version is available'
49 class ProtocolDesc(object):
51 OpenFlow protocol version flavor descriptor
54 def __init__(self, version=None):
56 version = max(_supported_versions)
57 self.set_version(version)
59 def set_version(self, version):
60 assert version in _supported_versions
61 (self.ofproto, self.ofproto_parser) = _versions[version]
64 def supported_ofp_version(self):
65 return _supported_versions