Rich Lane | 4d9f0f6 | 2013-05-09 15:50:57 -0700 | [diff] [blame] | 1 | # Copyright 2013, Big Switch Networks, Inc. |
| 2 | # |
| 3 | # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with |
| 4 | # the following special exception: |
| 5 | # |
| 6 | # LOXI Exception |
| 7 | # |
| 8 | # As a special exception to the terms of the EPL, you may distribute libraries |
| 9 | # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided |
| 10 | # that copyright and licensing notices generated by LoxiGen are not altered or removed |
| 11 | # from the LoxiGen Libraries and the notice provided below is (i) included in |
| 12 | # the LoxiGen Libraries, if distributed in source code form and (ii) included in any |
| 13 | # documentation for the LoxiGen Libraries, if distributed in binary form. |
| 14 | # |
| 15 | # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler." |
| 16 | # |
| 17 | # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain |
| 18 | # a copy of the EPL at: |
| 19 | # |
| 20 | # http://www.eclipse.org/legal/epl-v10.html |
| 21 | # |
| 22 | # Unless required by applicable law or agreed to in writing, software |
| 23 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 24 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 25 | # EPL for the specific language governing permissions and limitations |
| 26 | # under the EPL. |
| 27 | |
| 28 | from collections import namedtuple |
| 29 | |
| 30 | # This module is intended to be imported like this: from loxi_ir import * |
| 31 | # All public names are prefixed with 'OF'. |
| 32 | __all__ = [ |
| 33 | 'OFInput', |
| 34 | 'OFProtocol', |
| 35 | 'OFClass', |
| 36 | 'OFDataMember', |
| 37 | 'OFTypeMember', |
| 38 | 'OFLengthMember', |
| 39 | 'OFFieldLengthMember', |
| 40 | 'OFPadMember', |
| 41 | 'OFEnum', |
| 42 | ] |
| 43 | |
| 44 | """ |
| 45 | One input file |
| 46 | |
| 47 | @param wire_versions Set of integer wire versions this file applies to |
| 48 | @param classes List of OFClass objects in the same order as in the file |
| 49 | @param enums List of Enum objects in the same order as in the file |
| 50 | """ |
| 51 | OFInput = namedtuple('OFInput', ['wire_versions', 'classes', 'enums']) |
| 52 | |
| 53 | """ |
| 54 | One version of the OpenFlow protocol |
| 55 | |
| 56 | Combination of multiple OFInput objects. |
| 57 | |
| 58 | @param wire_version |
| 59 | @param classes List of OFClass objects |
| 60 | @param enums List of Enum objects |
| 61 | """ |
| 62 | OFProtocol = namedtuple('OFProtocol', ['wire_version', 'classes', 'enums']) |
| 63 | |
| 64 | """ |
| 65 | An OpenFlow class |
| 66 | |
| 67 | All compound objects like messages, actions, instructions, etc are |
| 68 | uniformly represented by this class. |
| 69 | |
| 70 | The members are in the same order as on the wire. |
| 71 | |
| 72 | @param name |
| 73 | @param members List of *Member objects |
| 74 | """ |
| 75 | OFClass = namedtuple('OFClass', ['name', 'members']) |
| 76 | |
| 77 | """ |
| 78 | Normal field |
| 79 | |
| 80 | @param name |
| 81 | @param oftype C-like type string |
| 82 | |
| 83 | Example: packet_in.buffer_id |
| 84 | """ |
| 85 | OFDataMember = namedtuple('OFDataMember', ['name', 'oftype']) |
| 86 | |
| 87 | """ |
| 88 | Field used to determine the type of an OpenFlow object |
| 89 | |
| 90 | @param name |
| 91 | @param oftype C-like type string |
| 92 | @param value Fixed type value |
| 93 | |
| 94 | Example: packet_in.type, flow_add._command |
| 95 | """ |
| 96 | OFTypeMember = namedtuple('OFTypeMember', ['name', 'oftype', 'value']) |
| 97 | |
| 98 | """ |
| 99 | Field with the length of the containing object |
| 100 | |
| 101 | @param name |
| 102 | @param oftype C-like type string |
| 103 | |
| 104 | Example: packet_in.length, action_output.len |
| 105 | """ |
| 106 | OFLengthMember = namedtuple('OFLengthMember', ['name', 'oftype']) |
| 107 | |
| 108 | """ |
| 109 | Field with the length of another field in the containing object |
| 110 | |
| 111 | @param name |
| 112 | @param oftype C-like type string |
| 113 | @param field_name Peer field whose length this field contains |
| 114 | |
| 115 | Example: packet_out.actions_len (only usage) |
| 116 | """ |
| 117 | OFFieldLengthMember = namedtuple('OFFieldLengthMember', ['name', 'oftype', 'field_name']) |
| 118 | |
| 119 | """ |
| 120 | Zero-filled padding |
| 121 | |
| 122 | @param length Length in bytes |
| 123 | |
| 124 | Example: packet_in.pad |
| 125 | """ |
| 126 | OFPadMember = namedtuple('OFPadMember', ['length']) |
| 127 | |
| 128 | """ |
| 129 | An OpenFlow enumeration |
| 130 | |
| 131 | All values are Python ints. |
| 132 | |
| 133 | @param name |
| 134 | @param values List of (name, value) tuples in input order |
| 135 | """ |
| 136 | OFEnum = namedtuple('OFEnum', ['name', 'values']) |