POP_MPLS (class OFPActionPopMpls) requires ethertype.

Signed-off-by: Satoshi Kobayashi <[email protected]>
---
Changes for v2:
  - Fix Copytight
 ryu/lib/ofctl_v1_3.py                 |    3 +-
 ryu/tests/unit/lib/test_ofctl_v1_3.py |   58 +++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 1 deletions(-)
 create mode 100644 ryu/tests/unit/lib/test_ofctl_v1_3.py

diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py
index c67cde1..e2a2717 100644
--- a/ryu/lib/ofctl_v1_3.py
+++ b/ryu/lib/ofctl_v1_3.py
@@ -60,7 +60,8 @@ def to_actions(dp, acts):
             ethertype = int(a.get('ethertype'))
             actions.append(parser.OFPActionPushMpls(ethertype))
         elif action_type == 'POP_MPLS':
-            actions.append(parser.OFPActionPopMpls())
+            ethertype = int(a.get('ethertype'))
+            actions.append(parser.OFPActionPopMpls(ethertype))
         elif action_type == 'SET_QUEUE':
             queue_id = int(a.get('queue_id'))
             actions.append(parser.OFPActionSetQueue(queue_id))
diff --git a/ryu/tests/unit/lib/test_ofctl_v1_3.py 
b/ryu/tests/unit/lib/test_ofctl_v1_3.py
new file mode 100644
index 0000000..17f0cd7
--- /dev/null
+++ b/ryu/tests/unit/lib/test_ofctl_v1_3.py
@@ -0,0 +1,58 @@
+# 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.lib import ofctl_v1_3
+from ryu.ofproto import ofproto_v1_3, ofproto_v1_3_parser
+from ryu.ofproto.ofproto_v1_3_parser import OFPActionPopMpls
+
+LOG = logging.getLogger('test_ofctl_v1_3')
+
+
+class _Datapath(object):
+    ofproto = ofproto_v1_3
+    ofproto_parser = ofproto_v1_3_parser
+
+
+class Test_ofctl_v1_3(unittest.TestCase):
+
+    """ Test case for ofctl_v1_3
+    """
+
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+    def test_to_actions_pop_mpls(self):
+        dp = _Datapath()
+
+        acts = [
+            {
+                'type': 'POP_MPLS',
+                'ethertype': 0x0800
+            }
+        ]
+        result = ofctl_v1_3.to_actions(dp, acts)
+        insts = result[0]
+        act = insts.actions[0]
+        ok_(isinstance(act, OFPActionPopMpls))
+        eq_(act.ethertype, 0x0800)
-- 
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

Reply via email to