blob: 088acb46143e3ec3d184ac4a27bade3a0cbbbe39 [file] [log] [blame]
Matteo Scandoloa229eca2017-08-08 13:05:28 -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
Rich Lanec2ee4b82013-04-24 17:12:38 -070017# 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.
Dan Talaycof6202252013-07-02 01:00:29 -070020# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Laneb658ddd2013-03-12 10:15:10 -070021# Automatically generated by LOXI from template toplevel_init.py
22# Do not modify
23
Rich Lane7b0f2012013-11-22 14:15:26 -080024version_names = {
25 1: "1.0",
26 2: "1.1",
27 3: "1.2",
28 4: "1.3",
Rich Lane2e079da2014-10-29 15:30:24 -070029 5: "1.4",
Rich Lane7b0f2012013-11-22 14:15:26 -080030}
Rich Lanec2ee4b82013-04-24 17:12:38 -070031
Rich Laneb658ddd2013-03-12 10:15:10 -070032def 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
Rich Lane2e079da2014-10-29 15:30:24 -070039
40 if ver == 2:
Rich Lanec2ee4b82013-04-24 17:12:38 -070041 import of11
42 return of11
Rich Lane2e079da2014-10-29 15:30:24 -070043
44 if ver == 3:
Rich Lanec2ee4b82013-04-24 17:12:38 -070045 import of12
46 return of12
Rich Lane2e079da2014-10-29 15:30:24 -070047
48 if ver == 4:
Rich Lanec2ee4b82013-04-24 17:12:38 -070049 import of13
50 return of13
Rich Lane2e079da2014-10-29 15:30:24 -070051
52 if ver == 5:
53 import of14
54 return of14
55
56 raise ValueError
Rich Laneb658ddd2013-03-12 10:15:10 -070057
58class ProtocolError(Exception):
59 """
60 Raised when failing to deserialize an invalid OpenFlow message.
61 """
62 pass
Rich Lanec2ee4b82013-04-24 17:12:38 -070063
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)
Rich Lane7dcdf022013-12-11 14:45:27 -080072
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)