Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1 | # 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 Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4 | # See the file LICENSE.pyloxi which should have been included in the source distribution |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5 | # Automatically generated by LOXI from template toplevel_init.py |
| 6 | # Do not modify |
| 7 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 8 | version_names = { |
| 9 | 1: "1.0", |
| 10 | 2: "1.1", |
| 11 | 3: "1.2", |
| 12 | 4: "1.3", |
| 13 | } |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 14 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 15 | def protocol(ver): |
| 16 | """ |
| 17 | Import and return the protocol module for the given wire version. |
| 18 | """ |
| 19 | if ver == 1: |
| 20 | import of10 |
| 21 | return of10 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 22 | elif ver == 2: |
| 23 | import of11 |
| 24 | return of11 |
| 25 | elif ver == 3: |
| 26 | import of12 |
| 27 | return of12 |
| 28 | elif ver == 4: |
| 29 | import of13 |
| 30 | return of13 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 31 | else: |
| 32 | raise ValueError |
| 33 | |
| 34 | class ProtocolError(Exception): |
| 35 | """ |
| 36 | Raised when failing to deserialize an invalid OpenFlow message. |
| 37 | """ |
| 38 | pass |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 39 | |
| 40 | class Unimplemented(Exception): |
| 41 | """ |
| 42 | Raised when an OpenFlow feature is not yet implemented in PyLoxi. |
| 43 | """ |
| 44 | pass |
| 45 | |
| 46 | def unimplemented(msg): |
| 47 | raise Unimplemented(msg) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 48 | |
| 49 | class OFObject(object): |
| 50 | """ |
| 51 | Superclass of all OpenFlow classes |
| 52 | """ |
| 53 | def __init__(self, *args): |
| 54 | raise NotImplementedError("cannot instantiate abstract class") |
| 55 | |
| 56 | def __ne__(self, other): |
| 57 | return not self.__eq__(other) |
| 58 | |
| 59 | def show(self): |
| 60 | import loxi.pp |
| 61 | return loxi.pp.pp(self) |