Stephane Barbarie | 6e1bd50 | 2018-11-05 22:44:45 -0500 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 15 | # Copyright (c) 2011, 2012 Open Networking Foundation |
| 16 | # Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
| 17 | # See the file LICENSE.pyloxi which should have been included in the source distribution |
| 18 | |
| 19 | # Automatically generated by LOXI from template module.py |
| 20 | # Do not modify |
| 21 | |
| 22 | import struct |
| 23 | import loxi |
| 24 | import util |
| 25 | import loxi.generic_util |
| 26 | |
| 27 | import sys |
| 28 | ofp = sys.modules['loxi.of14'] |
| 29 | |
| 30 | class port_mod_prop(loxi.OFObject): |
| 31 | subtypes = {} |
| 32 | |
| 33 | |
| 34 | def __init__(self, type=None): |
| 35 | if type != None: |
| 36 | self.type = type |
| 37 | else: |
| 38 | self.type = 0 |
| 39 | return |
| 40 | |
| 41 | def pack(self): |
| 42 | packed = [] |
| 43 | packed.append(struct.pack("!H", self.type)) |
| 44 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 45 | length = sum([len(x) for x in packed]) |
| 46 | packed[1] = struct.pack("!H", length) |
| 47 | return ''.join(packed) |
| 48 | |
| 49 | @staticmethod |
| 50 | def unpack(reader): |
| 51 | subtype, = reader.peek('!H', 0) |
| 52 | subclass = port_mod_prop.subtypes.get(subtype) |
| 53 | if subclass: |
| 54 | return subclass.unpack(reader) |
| 55 | |
| 56 | obj = port_mod_prop() |
| 57 | obj.type = reader.read("!H")[0] |
| 58 | _length = reader.read("!H")[0] |
| 59 | orig_reader = reader |
| 60 | reader = orig_reader.slice(_length, 4) |
| 61 | return obj |
| 62 | |
| 63 | def __eq__(self, other): |
| 64 | if type(self) != type(other): return False |
| 65 | if self.type != other.type: return False |
| 66 | return True |
| 67 | |
| 68 | def pretty_print(self, q): |
| 69 | q.text("port_mod_prop {") |
| 70 | with q.group(): |
| 71 | with q.indent(2): |
| 72 | q.breakable() |
| 73 | q.breakable() |
| 74 | q.text('}') |
| 75 | |
| 76 | |
| 77 | class ethernet(port_mod_prop): |
| 78 | type = 0 |
| 79 | |
| 80 | def __init__(self, advertise=None): |
| 81 | if advertise != None: |
| 82 | self.advertise = advertise |
| 83 | else: |
| 84 | self.advertise = 0 |
| 85 | return |
| 86 | |
| 87 | def pack(self): |
| 88 | packed = [] |
| 89 | packed.append(struct.pack("!H", self.type)) |
| 90 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 91 | packed.append(struct.pack("!L", self.advertise)) |
| 92 | length = sum([len(x) for x in packed]) |
| 93 | packed[1] = struct.pack("!H", length) |
| 94 | return ''.join(packed) |
| 95 | |
| 96 | @staticmethod |
| 97 | def unpack(reader): |
| 98 | obj = ethernet() |
| 99 | _type = reader.read("!H")[0] |
| 100 | assert(_type == 0) |
| 101 | _length = reader.read("!H")[0] |
| 102 | orig_reader = reader |
| 103 | reader = orig_reader.slice(_length, 4) |
| 104 | obj.advertise = reader.read("!L")[0] |
| 105 | return obj |
| 106 | |
| 107 | def __eq__(self, other): |
| 108 | if type(self) != type(other): return False |
| 109 | if self.advertise != other.advertise: return False |
| 110 | return True |
| 111 | |
| 112 | def pretty_print(self, q): |
| 113 | q.text("ethernet {") |
| 114 | with q.group(): |
| 115 | with q.indent(2): |
| 116 | q.breakable() |
| 117 | q.text("advertise = "); |
| 118 | q.text("%#x" % self.advertise) |
| 119 | q.breakable() |
| 120 | q.text('}') |
| 121 | |
| 122 | port_mod_prop.subtypes[0] = ethernet |
| 123 | |
| 124 | class experimenter(port_mod_prop): |
| 125 | subtypes = {} |
| 126 | |
| 127 | type = 65535 |
| 128 | |
| 129 | def __init__(self, experimenter=None, exp_type=None): |
| 130 | if experimenter != None: |
| 131 | self.experimenter = experimenter |
| 132 | else: |
| 133 | self.experimenter = 0 |
| 134 | if exp_type != None: |
| 135 | self.exp_type = exp_type |
| 136 | else: |
| 137 | self.exp_type = 0 |
| 138 | return |
| 139 | |
| 140 | def pack(self): |
| 141 | packed = [] |
| 142 | packed.append(struct.pack("!H", self.type)) |
| 143 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 144 | packed.append(struct.pack("!L", self.experimenter)) |
| 145 | packed.append(struct.pack("!L", self.exp_type)) |
| 146 | length = sum([len(x) for x in packed]) |
| 147 | packed[1] = struct.pack("!H", length) |
| 148 | return ''.join(packed) |
| 149 | |
| 150 | @staticmethod |
| 151 | def unpack(reader): |
| 152 | subtype, = reader.peek('!L', 4) |
| 153 | subclass = experimenter.subtypes.get(subtype) |
| 154 | if subclass: |
| 155 | return subclass.unpack(reader) |
| 156 | |
| 157 | obj = experimenter() |
| 158 | _type = reader.read("!H")[0] |
| 159 | assert(_type == 65535) |
| 160 | _length = reader.read("!H")[0] |
| 161 | orig_reader = reader |
| 162 | reader = orig_reader.slice(_length, 4) |
| 163 | obj.experimenter = reader.read("!L")[0] |
| 164 | obj.exp_type = reader.read("!L")[0] |
| 165 | return obj |
| 166 | |
| 167 | def __eq__(self, other): |
| 168 | if type(self) != type(other): return False |
| 169 | if self.experimenter != other.experimenter: return False |
| 170 | if self.exp_type != other.exp_type: return False |
| 171 | return True |
| 172 | |
| 173 | def pretty_print(self, q): |
| 174 | q.text("experimenter {") |
| 175 | with q.group(): |
| 176 | with q.indent(2): |
| 177 | q.breakable() |
| 178 | q.text("exp_type = "); |
| 179 | q.text("%#x" % self.exp_type) |
| 180 | q.breakable() |
| 181 | q.text('}') |
| 182 | |
| 183 | port_mod_prop.subtypes[65535] = experimenter |
| 184 | |
| 185 | class optical(port_mod_prop): |
| 186 | type = 1 |
| 187 | |
| 188 | def __init__(self, configure=None, freq_ldma=None, fl_offset=None, grid_span=None, tx_pwr=None): |
| 189 | if configure != None: |
| 190 | self.configure = configure |
| 191 | else: |
| 192 | self.configure = 0 |
| 193 | if freq_ldma != None: |
| 194 | self.freq_ldma = freq_ldma |
| 195 | else: |
| 196 | self.freq_ldma = 0 |
| 197 | if fl_offset != None: |
| 198 | self.fl_offset = fl_offset |
| 199 | else: |
| 200 | self.fl_offset = 0 |
| 201 | if grid_span != None: |
| 202 | self.grid_span = grid_span |
| 203 | else: |
| 204 | self.grid_span = 0 |
| 205 | if tx_pwr != None: |
| 206 | self.tx_pwr = tx_pwr |
| 207 | else: |
| 208 | self.tx_pwr = 0 |
| 209 | return |
| 210 | |
| 211 | def pack(self): |
| 212 | packed = [] |
| 213 | packed.append(struct.pack("!H", self.type)) |
| 214 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 215 | packed.append(struct.pack("!L", self.configure)) |
| 216 | packed.append(struct.pack("!L", self.freq_ldma)) |
| 217 | packed.append(struct.pack("!L", self.fl_offset)) |
| 218 | packed.append(struct.pack("!L", self.grid_span)) |
| 219 | packed.append(struct.pack("!L", self.tx_pwr)) |
| 220 | length = sum([len(x) for x in packed]) |
| 221 | packed[1] = struct.pack("!H", length) |
| 222 | return ''.join(packed) |
| 223 | |
| 224 | @staticmethod |
| 225 | def unpack(reader): |
| 226 | obj = optical() |
| 227 | _type = reader.read("!H")[0] |
| 228 | assert(_type == 1) |
| 229 | _length = reader.read("!H")[0] |
| 230 | orig_reader = reader |
| 231 | reader = orig_reader.slice(_length, 4) |
| 232 | obj.configure = reader.read("!L")[0] |
| 233 | obj.freq_ldma = reader.read("!L")[0] |
| 234 | obj.fl_offset = reader.read("!L")[0] |
| 235 | obj.grid_span = reader.read("!L")[0] |
| 236 | obj.tx_pwr = reader.read("!L")[0] |
| 237 | return obj |
| 238 | |
| 239 | def __eq__(self, other): |
| 240 | if type(self) != type(other): return False |
| 241 | if self.configure != other.configure: return False |
| 242 | if self.freq_ldma != other.freq_ldma: return False |
| 243 | if self.fl_offset != other.fl_offset: return False |
| 244 | if self.grid_span != other.grid_span: return False |
| 245 | if self.tx_pwr != other.tx_pwr: return False |
| 246 | return True |
| 247 | |
| 248 | def pretty_print(self, q): |
| 249 | q.text("optical {") |
| 250 | with q.group(): |
| 251 | with q.indent(2): |
| 252 | q.breakable() |
| 253 | q.text("configure = "); |
| 254 | q.text("%#x" % self.configure) |
| 255 | q.text(","); q.breakable() |
| 256 | q.text("freq_ldma = "); |
| 257 | q.text("%#x" % self.freq_ldma) |
| 258 | q.text(","); q.breakable() |
| 259 | q.text("fl_offset = "); |
| 260 | q.text("%#x" % self.fl_offset) |
| 261 | q.text(","); q.breakable() |
| 262 | q.text("grid_span = "); |
| 263 | q.text("%#x" % self.grid_span) |
| 264 | q.text(","); q.breakable() |
| 265 | q.text("tx_pwr = "); |
| 266 | q.text("%#x" % self.tx_pwr) |
| 267 | q.breakable() |
| 268 | q.text('}') |
| 269 | |
| 270 | port_mod_prop.subtypes[1] = optical |
| 271 | |
| 272 | |