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", |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame^] | 13 | 5: "1.4", |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 14 | } |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 15 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 16 | def 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 Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame^] | 23 | |
| 24 | if ver == 2: |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 25 | import of11 |
| 26 | return of11 |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame^] | 27 | |
| 28 | if ver == 3: |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 29 | import of12 |
| 30 | return of12 |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame^] | 31 | |
| 32 | if ver == 4: |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 33 | import of13 |
| 34 | return of13 |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame^] | 35 | |
| 36 | if ver == 5: |
| 37 | import of14 |
| 38 | return of14 |
| 39 | |
| 40 | raise ValueError |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 41 | |
| 42 | class ProtocolError(Exception): |
| 43 | """ |
| 44 | Raised when failing to deserialize an invalid OpenFlow message. |
| 45 | """ |
| 46 | pass |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 47 | |
| 48 | class Unimplemented(Exception): |
| 49 | """ |
| 50 | Raised when an OpenFlow feature is not yet implemented in PyLoxi. |
| 51 | """ |
| 52 | pass |
| 53 | |
| 54 | def unimplemented(msg): |
| 55 | raise Unimplemented(msg) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 56 | |
| 57 | class 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) |