This patch adds a new module "nx_message" in order to export Nicira messages, which defined only in "ofproto_v1_0_parser", to other parsers for other OpenFlow versions.
Note: This patch exports only "NXTSetControllerId" at this time, because other Nicira messages have alternatives of the standard OpenFlow messages. Signed-off-by: IWASE Yusuke <iwase.yusu...@gmail.com> --- doc/source/nicira_ext_ref.rst | 7 +++++++ ryu/ofproto/nx_message.py | 32 ++++++++++++++++++++++++++++++++ ryu/ofproto/ofproto_v1_0_parser.py | 23 +++++++++++++++++++++++ ryu/ofproto/ofproto_v1_2_parser.py | 5 +++++ ryu/ofproto/ofproto_v1_3_parser.py | 5 +++++ ryu/ofproto/ofproto_v1_4_parser.py | 5 +++++ ryu/ofproto/ofproto_v1_5_parser.py | 5 +++++ 7 files changed, 82 insertions(+) create mode 100644 ryu/ofproto/nx_message.py diff --git a/doc/source/nicira_ext_ref.rst b/doc/source/nicira_ext_ref.rst index 7ca1b0c..0f10f25 100644 --- a/doc/source/nicira_ext_ref.rst +++ b/doc/source/nicira_ext_ref.rst @@ -2,6 +2,13 @@ Nicira Extension Structures *************************** +Nicira Extended Messages Structures +=================================== + +.. py:currentmodule:: ryu.ofproto.ofproto_v1_3_parser + +.. autoclass:: NXTSetControllerId + .. _nx_actions_structures: Nicira Extension Actions Structures diff --git a/ryu/ofproto/nx_message.py b/ryu/ofproto/nx_message.py new file mode 100644 index 0000000..3996172 --- /dev/null +++ b/ryu/ofproto/nx_message.py @@ -0,0 +1,32 @@ +# Copyright (C) 2018 Nippon Telegraph and Telephone Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys + +from ryu.ofproto import ofproto_v1_0_parser + + +def generate(parser_name): + parser = sys.modules[parser_name] + + def add_attr(key, value): + value.__module__ = parser.__name__ # Necessary for stringify stuff + setattr(parser, key, value) + + _classes = [ + ofproto_v1_0_parser.NXTSetControllerId, + ] + for cls in _classes: + add_attr(cls.__name__, cls) diff --git a/ryu/ofproto/ofproto_v1_0_parser.py b/ryu/ofproto/ofproto_v1_0_parser.py index a288964..25bf61f 100644 --- a/ryu/ofproto/ofproto_v1_0_parser.py +++ b/ryu/ofproto/ofproto_v1_0_parser.py @@ -1644,6 +1644,29 @@ class NXTSetAsyncConfig(NiciraHeader): class NXTSetControllerId(NiciraHeader): + """ + Set controller connection ID message + + Each OpenFlow controller connection has a 16-bit identifier that is + initially 0. This message changes the connection's ID to the given ID. + + Controller connection IDs need not be unique. + + ================ ====================================================== + Attribute Description + ================ ====================================================== + controller_id 16-bit identifier value for controller connection. + ================ ====================================================== + + Example:: + + def send_set_controller_id(self, datapath, controller_id): + parser = datapath.ofproto_parser + + msg = parser.NXTSetControllerId(datapath, controller_id) + datapath.send_msg(msg) + """ + def __init__(self, datapath, controller_id): super(NXTSetControllerId, self).__init__( datapath, ofproto.NXT_SET_CONTROLLER_ID) diff --git a/ryu/ofproto/ofproto_v1_2_parser.py b/ryu/ofproto/ofproto_v1_2_parser.py index 5c7ba8f..9862fc9 100644 --- a/ryu/ofproto/ofproto_v1_2_parser.py +++ b/ryu/ofproto/ofproto_v1_2_parser.py @@ -31,6 +31,7 @@ from ryu import utils from ryu.ofproto.ofproto_parser import StringifyMixin, MsgBase from ryu.ofproto import ether from ryu.ofproto import nx_actions +from ryu.ofproto import nx_message from ryu.ofproto import ofproto_parser from ryu.ofproto import ofproto_v1_2 as ofproto @@ -4676,3 +4677,7 @@ nx_actions.generate( 'ryu.ofproto.ofproto_v1_2', 'ryu.ofproto.ofproto_v1_2_parser' ) + +nx_message.generate( + 'ryu.ofproto.ofproto_v1_2_parser', +) diff --git a/ryu/ofproto/ofproto_v1_3_parser.py b/ryu/ofproto/ofproto_v1_3_parser.py index 0324c82..7ff866c 100644 --- a/ryu/ofproto/ofproto_v1_3_parser.py +++ b/ryu/ofproto/ofproto_v1_3_parser.py @@ -54,6 +54,7 @@ from ryu import utils from ryu.ofproto.ofproto_parser import StringifyMixin, MsgBase from ryu.ofproto import ether from ryu.ofproto import nx_actions +from ryu.ofproto import nx_message from ryu.ofproto import ofproto_parser from ryu.ofproto import ofproto_common from ryu.ofproto import ofproto_v1_3 as ofproto @@ -6496,3 +6497,7 @@ nx_actions.generate( 'ryu.ofproto.ofproto_v1_3', 'ryu.ofproto.ofproto_v1_3_parser' ) + +nx_message.generate( + 'ryu.ofproto.ofproto_v1_3_parser', +) diff --git a/ryu/ofproto/ofproto_v1_4_parser.py b/ryu/ofproto/ofproto_v1_4_parser.py index 470e201..9754eea 100644 --- a/ryu/ofproto/ofproto_v1_4_parser.py +++ b/ryu/ofproto/ofproto_v1_4_parser.py @@ -30,6 +30,7 @@ from ryu import utils from ryu.ofproto.ofproto_parser import StringifyMixin, MsgBase, MsgInMsgBase from ryu.ofproto import ether from ryu.ofproto import nx_actions +from ryu.ofproto import nx_message from ryu.ofproto import ofproto_parser from ryu.ofproto import ofproto_common from ryu.ofproto import ofproto_v1_4 as ofproto @@ -5837,3 +5838,7 @@ nx_actions.generate( 'ryu.ofproto.ofproto_v1_4', 'ryu.ofproto.ofproto_v1_4_parser' ) + +nx_message.generate( + 'ryu.ofproto.ofproto_v1_4_parser', +) diff --git a/ryu/ofproto/ofproto_v1_5_parser.py b/ryu/ofproto/ofproto_v1_5_parser.py index c19a7e8..d8786ae 100644 --- a/ryu/ofproto/ofproto_v1_5_parser.py +++ b/ryu/ofproto/ofproto_v1_5_parser.py @@ -31,6 +31,7 @@ from ryu import utils from ryu.ofproto.ofproto_parser import StringifyMixin, MsgBase, MsgInMsgBase from ryu.ofproto import ether from ryu.ofproto import nx_actions +from ryu.ofproto import nx_message from ryu.ofproto import ofproto_parser from ryu.ofproto import ofproto_common from ryu.ofproto import ofproto_v1_5 as ofproto @@ -6938,3 +6939,7 @@ nx_actions.generate( 'ryu.ofproto.ofproto_v1_5', 'ryu.ofproto.ofproto_v1_5_parser' ) + +nx_message.generate( + 'ryu.ofproto.ofproto_v1_5_parser', +) -- 2.7.4 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Ryu-devel mailing list Ryu-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ryu-devel