blob: 0fdcdb7371631a7d51d1de312cc33929eee6dcab [file] [log] [blame]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2# Copyright (c) 2011, 2012 Open Networking Foundation
3# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
Dan Talaycof6202252013-07-02 01:00:29 -07004# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Laneb658ddd2013-03-12 10:15:10 -07005# Automatically generated by LOXI from template toplevel_init.py
6# Do not modify
7
Rich Lane7b0f2012013-11-22 14:15:26 -08008version_names = {
9 1: "1.0",
10 2: "1.1",
11 3: "1.2",
12 4: "1.3",
Rich Lane2e079da2014-10-29 15:30:24 -070013 5: "1.4",
Rich Lane7b0f2012013-11-22 14:15:26 -080014}
Rich Lanec2ee4b82013-04-24 17:12:38 -070015
Rich Laneb658ddd2013-03-12 10:15:10 -070016def protocol(ver):
17 """
18 Import and return the protocol module for the given wire version.
19 """
20 if ver == 1:
21 import of10
22 return of10
Rich Lane2e079da2014-10-29 15:30:24 -070023
24 if ver == 2:
Rich Lanec2ee4b82013-04-24 17:12:38 -070025 import of11
26 return of11
Rich Lane2e079da2014-10-29 15:30:24 -070027
28 if ver == 3:
Rich Lanec2ee4b82013-04-24 17:12:38 -070029 import of12
30 return of12
Rich Lane2e079da2014-10-29 15:30:24 -070031
32 if ver == 4:
Rich Lanec2ee4b82013-04-24 17:12:38 -070033 import of13
34 return of13
Rich Lane2e079da2014-10-29 15:30:24 -070035
36 if ver == 5:
37 import of14
38 return of14
39
40 raise ValueError
Rich Laneb658ddd2013-03-12 10:15:10 -070041
42class ProtocolError(Exception):
43 """
44 Raised when failing to deserialize an invalid OpenFlow message.
45 """
46 pass
Rich Lanec2ee4b82013-04-24 17:12:38 -070047
48class Unimplemented(Exception):
49 """
50 Raised when an OpenFlow feature is not yet implemented in PyLoxi.
51 """
52 pass
53
54def unimplemented(msg):
55 raise Unimplemented(msg)
Rich Lane7dcdf022013-12-11 14:45:27 -080056
57class OFObject(object):
58 """
59 Superclass of all OpenFlow classes
60 """
61 def __init__(self, *args):
62 raise NotImplementedError("cannot instantiate abstract class")
63
64 def __ne__(self, other):
65 return not self.__eq__(other)
66
67 def show(self):
68 import loxi.pp
69 return loxi.pp.pp(self)