OFPP_NONE in OpenFlow 1.0 is equivalent to OFPP_ANY in OpenFlow 1.1+.
Signed-off-by: Satoshi Kobayashi <[email protected]>
---
ryu/controller/controller.py | 6 ++-
ryu/tests/unit/controller/test_controller.py | 55 ++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 1 deletions(-)
create mode 100644 ryu/tests/unit/controller/__init__.py
create mode 100644 ryu/tests/unit/controller/test_controller.py
diff --git a/ryu/controller/controller.py b/ryu/controller/controller.py
index d6bc3de..a425be7 100644
--- a/ryu/controller/controller.py
+++ b/ryu/controller/controller.py
@@ -240,7 +240,11 @@ class Datapath(object):
def send_packet_out(self, buffer_id=0xffffffff, in_port=None,
actions=None, data=None):
if in_port is None:
- in_port = self.ofproto.OFPP_NONE
+ ofp_version = self.ofproto.OFP_VERSION
+ if ofp_version > 0x01:
+ in_port = self.ofproto.OFPP_ANY
+ else:
+ in_port = self.ofproto.OFPP_NONE
packet_out = self.ofproto_parser.OFPPacketOut(
self, buffer_id, in_port, actions, data)
self.send_msg(packet_out)
diff --git a/ryu/tests/unit/controller/__init__.py
b/ryu/tests/unit/controller/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/ryu/tests/unit/controller/test_controller.py
b/ryu/tests/unit/controller/test_controller.py
new file mode 100644
index 0000000..2c1a3f3
--- /dev/null
+++ b/ryu/tests/unit/controller/test_controller.py
@@ -0,0 +1,55 @@
+# Copyright (C) 2013 Stratosphere Inc.
+#
+# 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.
+
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+import unittest
+import logging
+from nose.tools import *
+
+from ryu.controller.controller import Datapath
+from ryu.ofproto import ofproto_v1_3, ofproto_v1_0
+import ryu.base.app_manager
+
+LOG = logging.getLogger('test_controller')
+
+
+class _RyuApp(object):
+
+ def send_event_to_observers(self, ev, state):
+ pass
+
+
+class Test_controller(unittest.TestCase):
+
+ """ Test case for controller
+ """
+
+ def setUp(self):
+ ryu.base.app_manager.lookup_service_brick = lambda s: _RyuApp()
+
+ def tearDown(self):
+ pass
+
+ def test_dp_send_packet_out_ofp_version(self):
+ dp = Datapath(None, None)
+
+ dp.send_msg = lambda pkt: eq_(pkt.in_port, ofproto_v1_3.OFPP_ANY)
+ dp.set_version(ofproto_v1_3.OFP_VERSION)
+ dp.send_packet_out()
+
+ dp.send_msg = lambda pkt: eq_(pkt.in_port, ofproto_v1_0.OFPP_NONE)
+ dp.set_version(ofproto_v1_0.OFP_VERSION)
+ dp.send_packet_out()
--
1.7.1
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel