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_desc_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_desc_prop.subtypes.get(subtype) |
| 53 | if subclass: |
| 54 | return subclass.unpack(reader) |
| 55 | |
| 56 | obj = port_desc_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_desc_prop {") |
| 70 | with q.group(): |
| 71 | with q.indent(2): |
| 72 | q.breakable() |
| 73 | q.breakable() |
| 74 | q.text('}') |
| 75 | |
| 76 | |
| 77 | class experimenter(port_desc_prop): |
| 78 | subtypes = {} |
| 79 | |
| 80 | type = 65535 |
| 81 | |
| 82 | def __init__(self, experimenter=None): |
| 83 | if experimenter != None: |
| 84 | self.experimenter = experimenter |
| 85 | else: |
| 86 | self.experimenter = 0 |
| 87 | return |
| 88 | |
| 89 | def pack(self): |
| 90 | packed = [] |
| 91 | packed.append(struct.pack("!H", self.type)) |
| 92 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 93 | packed.append(struct.pack("!L", self.experimenter)) |
| 94 | length = sum([len(x) for x in packed]) |
| 95 | packed[1] = struct.pack("!H", length) |
| 96 | return ''.join(packed) |
| 97 | |
| 98 | @staticmethod |
| 99 | def unpack(reader): |
| 100 | subtype, = reader.peek('!L', 4) |
| 101 | subclass = experimenter.subtypes.get(subtype) |
| 102 | if subclass: |
| 103 | return subclass.unpack(reader) |
| 104 | |
| 105 | obj = experimenter() |
| 106 | _type = reader.read("!H")[0] |
| 107 | assert(_type == 65535) |
| 108 | _length = reader.read("!H")[0] |
| 109 | orig_reader = reader |
| 110 | reader = orig_reader.slice(_length, 4) |
| 111 | obj.experimenter = reader.read("!L")[0] |
| 112 | return obj |
| 113 | |
| 114 | def __eq__(self, other): |
| 115 | if type(self) != type(other): return False |
| 116 | if self.experimenter != other.experimenter: return False |
| 117 | return True |
| 118 | |
| 119 | def pretty_print(self, q): |
| 120 | q.text("experimenter {") |
| 121 | with q.group(): |
| 122 | with q.indent(2): |
| 123 | q.breakable() |
| 124 | q.breakable() |
| 125 | q.text('}') |
| 126 | |
| 127 | port_desc_prop.subtypes[65535] = experimenter |
| 128 | |
| 129 | class bsn(experimenter): |
| 130 | subtypes = {} |
| 131 | |
| 132 | type = 65535 |
| 133 | experimenter = 6035143 |
| 134 | |
| 135 | def __init__(self, exp_type=None): |
| 136 | if exp_type != None: |
| 137 | self.exp_type = exp_type |
| 138 | else: |
| 139 | self.exp_type = 0 |
| 140 | return |
| 141 | |
| 142 | def pack(self): |
| 143 | packed = [] |
| 144 | packed.append(struct.pack("!H", self.type)) |
| 145 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 146 | packed.append(struct.pack("!L", self.experimenter)) |
| 147 | packed.append(struct.pack("!L", self.exp_type)) |
| 148 | length = sum([len(x) for x in packed]) |
| 149 | packed[1] = struct.pack("!H", length) |
| 150 | return ''.join(packed) |
| 151 | |
| 152 | @staticmethod |
| 153 | def unpack(reader): |
| 154 | subtype, = reader.peek('!L', 8) |
| 155 | subclass = bsn.subtypes.get(subtype) |
| 156 | if subclass: |
| 157 | return subclass.unpack(reader) |
| 158 | |
| 159 | obj = bsn() |
| 160 | _type = reader.read("!H")[0] |
| 161 | assert(_type == 65535) |
| 162 | _length = reader.read("!H")[0] |
| 163 | orig_reader = reader |
| 164 | reader = orig_reader.slice(_length, 4) |
| 165 | _experimenter = reader.read("!L")[0] |
| 166 | assert(_experimenter == 6035143) |
| 167 | obj.exp_type = reader.read("!L")[0] |
| 168 | return obj |
| 169 | |
| 170 | def __eq__(self, other): |
| 171 | if type(self) != type(other): return False |
| 172 | if self.exp_type != other.exp_type: return False |
| 173 | return True |
| 174 | |
| 175 | def pretty_print(self, q): |
| 176 | q.text("bsn {") |
| 177 | with q.group(): |
| 178 | with q.indent(2): |
| 179 | q.breakable() |
| 180 | q.breakable() |
| 181 | q.text('}') |
| 182 | |
| 183 | experimenter.subtypes[6035143] = bsn |
| 184 | |
| 185 | class bsn_generation_id(bsn): |
| 186 | type = 65535 |
| 187 | experimenter = 6035143 |
| 188 | exp_type = 1 |
| 189 | |
| 190 | def __init__(self, generation_id=None): |
| 191 | if generation_id != None: |
| 192 | self.generation_id = generation_id |
| 193 | else: |
| 194 | self.generation_id = 0 |
| 195 | return |
| 196 | |
| 197 | def pack(self): |
| 198 | packed = [] |
| 199 | packed.append(struct.pack("!H", self.type)) |
| 200 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 201 | packed.append(struct.pack("!L", self.experimenter)) |
| 202 | packed.append(struct.pack("!L", self.exp_type)) |
| 203 | packed.append(struct.pack("!Q", self.generation_id)) |
| 204 | length = sum([len(x) for x in packed]) |
| 205 | packed[1] = struct.pack("!H", length) |
| 206 | return ''.join(packed) |
| 207 | |
| 208 | @staticmethod |
| 209 | def unpack(reader): |
| 210 | obj = bsn_generation_id() |
| 211 | _type = reader.read("!H")[0] |
| 212 | assert(_type == 65535) |
| 213 | _length = reader.read("!H")[0] |
| 214 | orig_reader = reader |
| 215 | reader = orig_reader.slice(_length, 4) |
| 216 | _experimenter = reader.read("!L")[0] |
| 217 | assert(_experimenter == 6035143) |
| 218 | _exp_type = reader.read("!L")[0] |
| 219 | assert(_exp_type == 1) |
| 220 | obj.generation_id = reader.read("!Q")[0] |
| 221 | return obj |
| 222 | |
| 223 | def __eq__(self, other): |
| 224 | if type(self) != type(other): return False |
| 225 | if self.generation_id != other.generation_id: return False |
| 226 | return True |
| 227 | |
| 228 | def pretty_print(self, q): |
| 229 | q.text("bsn_generation_id {") |
| 230 | with q.group(): |
| 231 | with q.indent(2): |
| 232 | q.breakable() |
| 233 | q.text("generation_id = "); |
| 234 | q.text("%#x" % self.generation_id) |
| 235 | q.breakable() |
| 236 | q.text('}') |
| 237 | |
| 238 | bsn.subtypes[1] = bsn_generation_id |
| 239 | |
| 240 | class bsn_uplink(bsn): |
| 241 | type = 65535 |
| 242 | experimenter = 6035143 |
| 243 | exp_type = 0 |
| 244 | |
| 245 | def __init__(self): |
| 246 | return |
| 247 | |
| 248 | def pack(self): |
| 249 | packed = [] |
| 250 | packed.append(struct.pack("!H", self.type)) |
| 251 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 252 | packed.append(struct.pack("!L", self.experimenter)) |
| 253 | packed.append(struct.pack("!L", self.exp_type)) |
| 254 | length = sum([len(x) for x in packed]) |
| 255 | packed[1] = struct.pack("!H", length) |
| 256 | return ''.join(packed) |
| 257 | |
| 258 | @staticmethod |
| 259 | def unpack(reader): |
| 260 | obj = bsn_uplink() |
| 261 | _type = reader.read("!H")[0] |
| 262 | assert(_type == 65535) |
| 263 | _length = reader.read("!H")[0] |
| 264 | orig_reader = reader |
| 265 | reader = orig_reader.slice(_length, 4) |
| 266 | _experimenter = reader.read("!L")[0] |
| 267 | assert(_experimenter == 6035143) |
| 268 | _exp_type = reader.read("!L")[0] |
| 269 | assert(_exp_type == 0) |
| 270 | return obj |
| 271 | |
| 272 | def __eq__(self, other): |
| 273 | if type(self) != type(other): return False |
| 274 | return True |
| 275 | |
| 276 | def pretty_print(self, q): |
| 277 | q.text("bsn_uplink {") |
| 278 | with q.group(): |
| 279 | with q.indent(2): |
| 280 | q.breakable() |
| 281 | q.breakable() |
| 282 | q.text('}') |
| 283 | |
| 284 | bsn.subtypes[0] = bsn_uplink |
| 285 | |
| 286 | class ethernet(port_desc_prop): |
| 287 | type = 0 |
| 288 | |
| 289 | def __init__(self, curr=None, advertised=None, supported=None, peer=None, curr_speed=None, max_speed=None): |
| 290 | if curr != None: |
| 291 | self.curr = curr |
| 292 | else: |
| 293 | self.curr = 0 |
| 294 | if advertised != None: |
| 295 | self.advertised = advertised |
| 296 | else: |
| 297 | self.advertised = 0 |
| 298 | if supported != None: |
| 299 | self.supported = supported |
| 300 | else: |
| 301 | self.supported = 0 |
| 302 | if peer != None: |
| 303 | self.peer = peer |
| 304 | else: |
| 305 | self.peer = 0 |
| 306 | if curr_speed != None: |
| 307 | self.curr_speed = curr_speed |
| 308 | else: |
| 309 | self.curr_speed = 0 |
| 310 | if max_speed != None: |
| 311 | self.max_speed = max_speed |
| 312 | else: |
| 313 | self.max_speed = 0 |
| 314 | return |
| 315 | |
| 316 | def pack(self): |
| 317 | packed = [] |
| 318 | packed.append(struct.pack("!H", self.type)) |
| 319 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 320 | packed.append('\x00' * 4) |
| 321 | packed.append(struct.pack("!L", self.curr)) |
| 322 | packed.append(struct.pack("!L", self.advertised)) |
| 323 | packed.append(struct.pack("!L", self.supported)) |
| 324 | packed.append(struct.pack("!L", self.peer)) |
| 325 | packed.append(struct.pack("!L", self.curr_speed)) |
| 326 | packed.append(struct.pack("!L", self.max_speed)) |
| 327 | length = sum([len(x) for x in packed]) |
| 328 | packed[1] = struct.pack("!H", length) |
| 329 | return ''.join(packed) |
| 330 | |
| 331 | @staticmethod |
| 332 | def unpack(reader): |
| 333 | obj = ethernet() |
| 334 | _type = reader.read("!H")[0] |
| 335 | assert(_type == 0) |
| 336 | _length = reader.read("!H")[0] |
| 337 | orig_reader = reader |
| 338 | reader = orig_reader.slice(_length, 4) |
| 339 | reader.skip(4) |
| 340 | obj.curr = reader.read("!L")[0] |
| 341 | obj.advertised = reader.read("!L")[0] |
| 342 | obj.supported = reader.read("!L")[0] |
| 343 | obj.peer = reader.read("!L")[0] |
| 344 | obj.curr_speed = reader.read("!L")[0] |
| 345 | obj.max_speed = reader.read("!L")[0] |
| 346 | return obj |
| 347 | |
| 348 | def __eq__(self, other): |
| 349 | if type(self) != type(other): return False |
| 350 | if self.curr != other.curr: return False |
| 351 | if self.advertised != other.advertised: return False |
| 352 | if self.supported != other.supported: return False |
| 353 | if self.peer != other.peer: return False |
| 354 | if self.curr_speed != other.curr_speed: return False |
| 355 | if self.max_speed != other.max_speed: return False |
| 356 | return True |
| 357 | |
| 358 | def pretty_print(self, q): |
| 359 | q.text("ethernet {") |
| 360 | with q.group(): |
| 361 | with q.indent(2): |
| 362 | q.breakable() |
| 363 | q.text("curr = "); |
| 364 | q.text("%#x" % self.curr) |
| 365 | q.text(","); q.breakable() |
| 366 | q.text("advertised = "); |
| 367 | q.text("%#x" % self.advertised) |
| 368 | q.text(","); q.breakable() |
| 369 | q.text("supported = "); |
| 370 | q.text("%#x" % self.supported) |
| 371 | q.text(","); q.breakable() |
| 372 | q.text("peer = "); |
| 373 | q.text("%#x" % self.peer) |
| 374 | q.text(","); q.breakable() |
| 375 | q.text("curr_speed = "); |
| 376 | q.text("%#x" % self.curr_speed) |
| 377 | q.text(","); q.breakable() |
| 378 | q.text("max_speed = "); |
| 379 | q.text("%#x" % self.max_speed) |
| 380 | q.breakable() |
| 381 | q.text('}') |
| 382 | |
| 383 | port_desc_prop.subtypes[0] = ethernet |
| 384 | |
| 385 | class optical(port_desc_prop): |
| 386 | type = 1 |
| 387 | |
| 388 | def __init__(self, supported=None, tx_min_freq_lmda=None, tx_max_freq_lmda=None, tx_grid_freq_lmda=None, rx_min_freq_lmda=None, rx_max_freq_lmda=None, rx_grid_freq_lmda=None, tx_pwr_min=None, tx_pwr_max=None): |
| 389 | if supported != None: |
| 390 | self.supported = supported |
| 391 | else: |
| 392 | self.supported = 0 |
| 393 | if tx_min_freq_lmda != None: |
| 394 | self.tx_min_freq_lmda = tx_min_freq_lmda |
| 395 | else: |
| 396 | self.tx_min_freq_lmda = 0 |
| 397 | if tx_max_freq_lmda != None: |
| 398 | self.tx_max_freq_lmda = tx_max_freq_lmda |
| 399 | else: |
| 400 | self.tx_max_freq_lmda = 0 |
| 401 | if tx_grid_freq_lmda != None: |
| 402 | self.tx_grid_freq_lmda = tx_grid_freq_lmda |
| 403 | else: |
| 404 | self.tx_grid_freq_lmda = 0 |
| 405 | if rx_min_freq_lmda != None: |
| 406 | self.rx_min_freq_lmda = rx_min_freq_lmda |
| 407 | else: |
| 408 | self.rx_min_freq_lmda = 0 |
| 409 | if rx_max_freq_lmda != None: |
| 410 | self.rx_max_freq_lmda = rx_max_freq_lmda |
| 411 | else: |
| 412 | self.rx_max_freq_lmda = 0 |
| 413 | if rx_grid_freq_lmda != None: |
| 414 | self.rx_grid_freq_lmda = rx_grid_freq_lmda |
| 415 | else: |
| 416 | self.rx_grid_freq_lmda = 0 |
| 417 | if tx_pwr_min != None: |
| 418 | self.tx_pwr_min = tx_pwr_min |
| 419 | else: |
| 420 | self.tx_pwr_min = 0 |
| 421 | if tx_pwr_max != None: |
| 422 | self.tx_pwr_max = tx_pwr_max |
| 423 | else: |
| 424 | self.tx_pwr_max = 0 |
| 425 | return |
| 426 | |
| 427 | def pack(self): |
| 428 | packed = [] |
| 429 | packed.append(struct.pack("!H", self.type)) |
| 430 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 431 | packed.append('\x00' * 4) |
| 432 | packed.append(struct.pack("!L", self.supported)) |
| 433 | packed.append(struct.pack("!L", self.tx_min_freq_lmda)) |
| 434 | packed.append(struct.pack("!L", self.tx_max_freq_lmda)) |
| 435 | packed.append(struct.pack("!L", self.tx_grid_freq_lmda)) |
| 436 | packed.append(struct.pack("!L", self.rx_min_freq_lmda)) |
| 437 | packed.append(struct.pack("!L", self.rx_max_freq_lmda)) |
| 438 | packed.append(struct.pack("!L", self.rx_grid_freq_lmda)) |
| 439 | packed.append(struct.pack("!L", self.tx_pwr_min)) |
| 440 | packed.append(struct.pack("!L", self.tx_pwr_max)) |
| 441 | length = sum([len(x) for x in packed]) |
| 442 | packed[1] = struct.pack("!H", length) |
| 443 | return ''.join(packed) |
| 444 | |
| 445 | @staticmethod |
| 446 | def unpack(reader): |
| 447 | obj = optical() |
| 448 | _type = reader.read("!H")[0] |
| 449 | assert(_type == 1) |
| 450 | _length = reader.read("!H")[0] |
| 451 | orig_reader = reader |
| 452 | reader = orig_reader.slice(_length, 4) |
| 453 | reader.skip(4) |
| 454 | obj.supported = reader.read("!L")[0] |
| 455 | obj.tx_min_freq_lmda = reader.read("!L")[0] |
| 456 | obj.tx_max_freq_lmda = reader.read("!L")[0] |
| 457 | obj.tx_grid_freq_lmda = reader.read("!L")[0] |
| 458 | obj.rx_min_freq_lmda = reader.read("!L")[0] |
| 459 | obj.rx_max_freq_lmda = reader.read("!L")[0] |
| 460 | obj.rx_grid_freq_lmda = reader.read("!L")[0] |
| 461 | obj.tx_pwr_min = reader.read("!L")[0] |
| 462 | obj.tx_pwr_max = reader.read("!L")[0] |
| 463 | return obj |
| 464 | |
| 465 | def __eq__(self, other): |
| 466 | if type(self) != type(other): return False |
| 467 | if self.supported != other.supported: return False |
| 468 | if self.tx_min_freq_lmda != other.tx_min_freq_lmda: return False |
| 469 | if self.tx_max_freq_lmda != other.tx_max_freq_lmda: return False |
| 470 | if self.tx_grid_freq_lmda != other.tx_grid_freq_lmda: return False |
| 471 | if self.rx_min_freq_lmda != other.rx_min_freq_lmda: return False |
| 472 | if self.rx_max_freq_lmda != other.rx_max_freq_lmda: return False |
| 473 | if self.rx_grid_freq_lmda != other.rx_grid_freq_lmda: return False |
| 474 | if self.tx_pwr_min != other.tx_pwr_min: return False |
| 475 | if self.tx_pwr_max != other.tx_pwr_max: return False |
| 476 | return True |
| 477 | |
| 478 | def pretty_print(self, q): |
| 479 | q.text("optical {") |
| 480 | with q.group(): |
| 481 | with q.indent(2): |
| 482 | q.breakable() |
| 483 | q.text("supported = "); |
| 484 | q.text("%#x" % self.supported) |
| 485 | q.text(","); q.breakable() |
| 486 | q.text("tx_min_freq_lmda = "); |
| 487 | q.text("%#x" % self.tx_min_freq_lmda) |
| 488 | q.text(","); q.breakable() |
| 489 | q.text("tx_max_freq_lmda = "); |
| 490 | q.text("%#x" % self.tx_max_freq_lmda) |
| 491 | q.text(","); q.breakable() |
| 492 | q.text("tx_grid_freq_lmda = "); |
| 493 | q.text("%#x" % self.tx_grid_freq_lmda) |
| 494 | q.text(","); q.breakable() |
| 495 | q.text("rx_min_freq_lmda = "); |
| 496 | q.text("%#x" % self.rx_min_freq_lmda) |
| 497 | q.text(","); q.breakable() |
| 498 | q.text("rx_max_freq_lmda = "); |
| 499 | q.text("%#x" % self.rx_max_freq_lmda) |
| 500 | q.text(","); q.breakable() |
| 501 | q.text("rx_grid_freq_lmda = "); |
| 502 | q.text("%#x" % self.rx_grid_freq_lmda) |
| 503 | q.text(","); q.breakable() |
| 504 | q.text("tx_pwr_min = "); |
| 505 | q.text("%#x" % self.tx_pwr_min) |
| 506 | q.text(","); q.breakable() |
| 507 | q.text("tx_pwr_max = "); |
| 508 | q.text("%#x" % self.tx_pwr_max) |
| 509 | q.breakable() |
| 510 | q.text('}') |
| 511 | |
| 512 | port_desc_prop.subtypes[1] = optical |
| 513 | |
| 514 | |