blob: 088acb46143e3ec3d184ac4a27bade3a0cbbbe39 [file] [log] [blame]
Sreeju Sreedhare3fefd92019-04-02 15:57:15 -07001
2# Copyright 2017-present Open Networking Foundation
3#
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
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
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 implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
17# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
18# Copyright (c) 2011, 2012 Open Networking Foundation
19# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
20# See the file LICENSE.pyloxi which should have been included in the source distribution
21# Automatically generated by LOXI from template toplevel_init.py
22# Do not modify
23
24version_names = {
25 1: "1.0",
26 2: "1.1",
27 3: "1.2",
28 4: "1.3",
29 5: "1.4",
30}
31
32def protocol(ver):
33 """
34 Import and return the protocol module for the given wire version.
35 """
36 if ver == 1:
37 import of10
38 return of10
39
40 if ver == 2:
41 import of11
42 return of11
43
44 if ver == 3:
45 import of12
46 return of12
47
48 if ver == 4:
49 import of13
50 return of13
51
52 if ver == 5:
53 import of14
54 return of14
55
56 raise ValueError
57
58class ProtocolError(Exception):
59 """
60 Raised when failing to deserialize an invalid OpenFlow message.
61 """
62 pass
63
64class Unimplemented(Exception):
65 """
66 Raised when an OpenFlow feature is not yet implemented in PyLoxi.
67 """
68 pass
69
70def unimplemented(msg):
71 raise Unimplemented(msg)
72
73class OFObject(object):
74 """
75 Superclass of all OpenFlow classes
76 """
77 def __init__(self, *args):
78 raise NotImplementedError("cannot instantiate abstract class")
79
80 def __ne__(self, other):
81 return not self.__eq__(other)
82
83 def show(self):
84 import loxi.pp
85 return loxi.pp.pp(self)