Matteo Scandolo | a229eca | 2017-08-08 13:05:28 -0700 | [diff] [blame] | 1 | |
| 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 Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 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. |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 20 | # 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] | 21 | # Automatically generated by LOXI from template toplevel_init.py |
| 22 | # Do not modify |
| 23 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 24 | version_names = { |
| 25 | 1: "1.0", |
| 26 | 2: "1.1", |
| 27 | 3: "1.2", |
| 28 | 4: "1.3", |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 29 | 5: "1.4", |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 30 | } |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 31 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 32 | def 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 Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 39 | |
| 40 | if ver == 2: |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 41 | import of11 |
| 42 | return of11 |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 43 | |
| 44 | if ver == 3: |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 45 | import of12 |
| 46 | return of12 |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 47 | |
| 48 | if ver == 4: |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 49 | import of13 |
| 50 | return of13 |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 51 | |
| 52 | if ver == 5: |
| 53 | import of14 |
| 54 | return of14 |
| 55 | |
| 56 | raise ValueError |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 57 | |
| 58 | class ProtocolError(Exception): |
| 59 | """ |
| 60 | Raised when failing to deserialize an invalid OpenFlow message. |
| 61 | """ |
| 62 | pass |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 63 | |
| 64 | class Unimplemented(Exception): |
| 65 | """ |
| 66 | Raised when an OpenFlow feature is not yet implemented in PyLoxi. |
| 67 | """ |
| 68 | pass |
| 69 | |
| 70 | def unimplemented(msg): |
| 71 | raise Unimplemented(msg) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 72 | |
| 73 | class 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) |