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