1 # Copyright (C) 2015 Nippon Telegraph and Telephone Corporation.
2 # Copyright (C) 2015 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.
19 import ryu.ofproto.ofproto_v1_3_parser as ofpp
22 class Test_FlowSpec(unittest.TestCase):
23 def test_flowspec_src_0_dst_0(self):
24 user = ofpp.NXFlowSpecMatch(src=('in_port', 0),
29 b'\x80\x00\x00\x04\x00\x00'
30 b'\x80\x00\x00\x04\x00\x00'
32 self.assertEqual(on_wire, user.serialize())
33 (o, rest) = ofpp._NXFlowSpec.parse(on_wire)
34 self.assertEqual(user.to_jsondict(), o.to_jsondict())
35 self.assertEqual(str(user), str(o))
36 self.assertEqual(b'', rest)
38 def test_flowspec_src_1_dst_0(self):
39 user = ofpp.NXFlowSpecMatch(src=99,
45 b'\x80\x00\x00\x04\x00\x00'
47 self.assertEqual(on_wire, user.serialize())
48 (o, rest) = ofpp._NXFlowSpec.parse(on_wire)
49 self.assertEqual(user.to_jsondict(), o.to_jsondict())
50 self.assertEqual(str(user), str(o))
51 self.assertEqual(b'', rest)
53 def test_flowspec_src_0_dst_1(self):
54 user = ofpp.NXFlowSpecLoad(src=('in_port', 0),
59 b'\x80\x00\x00\x04\x00\x00'
60 b'\x80\x00\x00\x04\x00\x00'
62 self.assertEqual(on_wire, user.serialize())
63 (o, rest) = ofpp._NXFlowSpec.parse(on_wire)
64 self.assertEqual(user.to_jsondict(), o.to_jsondict())
65 self.assertEqual(str(user), str(o))
66 self.assertEqual(b'', rest)
68 def test_flowspec_src_1_dst_1(self):
69 user = ofpp.NXFlowSpecLoad(src=99,
75 b'\x80\x00\x00\x04\x00\x00'
77 self.assertEqual(on_wire, user.serialize())
78 (o, rest) = ofpp._NXFlowSpec.parse(on_wire)
79 self.assertEqual(user.to_jsondict(), o.to_jsondict())
80 self.assertEqual(str(user), str(o))
81 self.assertEqual(b'', rest)
83 def test_flowspec_src_0_dst_2(self):
84 user = ofpp.NXFlowSpecOutput(src=('in_port', 0),
89 b'\x80\x00\x00\x04\x00\x00'
91 self.assertEqual(on_wire, user.serialize())
92 (o, rest) = ofpp._NXFlowSpec.parse(on_wire)
93 self.assertEqual(user.to_jsondict(), o.to_jsondict())
94 self.assertEqual(str(user), str(o))
95 self.assertEqual(b'', rest)