blob: adb067b550d2fa5a9375da74cfc6c545b5d00c9a [file] [log] [blame]
Stephane Barbarie6e1bd502018-11-05 22:44:45 -05001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
15# Copyright (c) 2011, 2012 Open Networking Foundation
16# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
17# See the file LICENSE.pyloxi which should have been included in the source distribution
18# Automatically generated by LOXI from template toplevel_init.py
19# Do not modify
20
21version_names = {
22 1: "1.0",
23 2: "1.1",
24 3: "1.2",
25 4: "1.3",
26 5: "1.4",
27}
28
29def protocol(ver):
30 """
31 Import and return the protocol module for the given wire version.
32 """
33 if ver == 1:
34 import of10
35 return of10
36
37 if ver == 2:
38 import of11
39 return of11
40
41 if ver == 3:
42 import of12
43 return of12
44
45 if ver == 4:
46 import of13
47 return of13
48
49 if ver == 5:
50 import of14
51 return of14
52
53 raise ValueError
54
55class ProtocolError(Exception):
56 """
57 Raised when failing to deserialize an invalid OpenFlow message.
58 """
59 pass
60
61class Unimplemented(Exception):
62 """
63 Raised when an OpenFlow feature is not yet implemented in PyLoxi.
64 """
65 pass
66
67def unimplemented(msg):
68 raise Unimplemented(msg)
69
70class OFObject(object):
71 """
72 Superclass of all OpenFlow classes
73 """
74 def __init__(self, *args):
75 raise NotImplementedError("cannot instantiate abstract class")
76
77 def __ne__(self, other):
78 return not self.__eq__(other)
79
80 def show(self):
81 import loxi.pp
82 return loxi.pp.pp(self)