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 |
| 11 | import const |
| 12 | import port_desc_prop |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame^] | 13 | import bsn_tlv |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 14 | import meter_band |
| 15 | import table_mod_prop |
| 16 | import instruction |
| 17 | import queue_desc_prop |
| 18 | import oxm |
| 19 | import bundle_prop |
| 20 | import common |
| 21 | import instruction_id |
| 22 | import action |
| 23 | import role_prop |
| 24 | import message |
| 25 | import queue_stats_prop |
| 26 | import port_stats_prop |
| 27 | import port_mod_prop |
| 28 | import async_config_prop |
| 29 | import action_id |
| 30 | import util |
| 31 | import loxi.generic_util |
| 32 | |
| 33 | class instruction(loxi.OFObject): |
| 34 | subtypes = {} |
| 35 | |
| 36 | |
| 37 | def __init__(self, type=None): |
| 38 | if type != None: |
| 39 | self.type = type |
| 40 | else: |
| 41 | self.type = 0 |
| 42 | return |
| 43 | |
| 44 | def pack(self): |
| 45 | packed = [] |
| 46 | packed.append(struct.pack("!H", self.type)) |
| 47 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 48 | length = sum([len(x) for x in packed]) |
| 49 | packed[1] = struct.pack("!H", length) |
| 50 | return ''.join(packed) |
| 51 | |
| 52 | @staticmethod |
| 53 | def unpack(reader): |
| 54 | subtype, = reader.peek('!H', 0) |
| 55 | subclass = instruction.subtypes.get(subtype) |
| 56 | if subclass: |
| 57 | return subclass.unpack(reader) |
| 58 | |
| 59 | obj = instruction() |
| 60 | obj.type = reader.read("!H")[0] |
| 61 | _len = reader.read("!H")[0] |
| 62 | orig_reader = reader |
| 63 | reader = orig_reader.slice(_len - (2 + 2)) |
| 64 | return obj |
| 65 | |
| 66 | def __eq__(self, other): |
| 67 | if type(self) != type(other): return False |
| 68 | if self.type != other.type: return False |
| 69 | return True |
| 70 | |
| 71 | def pretty_print(self, q): |
| 72 | q.text("instruction {") |
| 73 | with q.group(): |
| 74 | with q.indent(2): |
| 75 | q.breakable() |
| 76 | q.breakable() |
| 77 | q.text('}') |
| 78 | |
| 79 | |
| 80 | class apply_actions(instruction): |
| 81 | type = 4 |
| 82 | |
| 83 | def __init__(self, actions=None): |
| 84 | if actions != None: |
| 85 | self.actions = actions |
| 86 | else: |
| 87 | self.actions = [] |
| 88 | return |
| 89 | |
| 90 | def pack(self): |
| 91 | packed = [] |
| 92 | packed.append(struct.pack("!H", self.type)) |
| 93 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 94 | packed.append('\x00' * 4) |
| 95 | packed.append(loxi.generic_util.pack_list(self.actions)) |
| 96 | length = sum([len(x) for x in packed]) |
| 97 | packed[1] = struct.pack("!H", length) |
| 98 | return ''.join(packed) |
| 99 | |
| 100 | @staticmethod |
| 101 | def unpack(reader): |
| 102 | obj = apply_actions() |
| 103 | _type = reader.read("!H")[0] |
| 104 | assert(_type == 4) |
| 105 | _len = reader.read("!H")[0] |
| 106 | orig_reader = reader |
| 107 | reader = orig_reader.slice(_len - (2 + 2)) |
| 108 | reader.skip(4) |
| 109 | obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack) |
| 110 | return obj |
| 111 | |
| 112 | def __eq__(self, other): |
| 113 | if type(self) != type(other): return False |
| 114 | if self.actions != other.actions: return False |
| 115 | return True |
| 116 | |
| 117 | def pretty_print(self, q): |
| 118 | q.text("apply_actions {") |
| 119 | with q.group(): |
| 120 | with q.indent(2): |
| 121 | q.breakable() |
| 122 | q.text("actions = "); |
| 123 | q.pp(self.actions) |
| 124 | q.breakable() |
| 125 | q.text('}') |
| 126 | |
| 127 | instruction.subtypes[4] = apply_actions |
| 128 | |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 129 | class experimenter(instruction): |
| 130 | subtypes = {} |
| 131 | |
| 132 | type = 65535 |
| 133 | |
| 134 | def __init__(self, experimenter=None, data=None): |
| 135 | if experimenter != None: |
| 136 | self.experimenter = experimenter |
| 137 | else: |
| 138 | self.experimenter = 0 |
| 139 | if data != None: |
| 140 | self.data = data |
| 141 | else: |
| 142 | self.data = '' |
| 143 | return |
| 144 | |
| 145 | def pack(self): |
| 146 | packed = [] |
| 147 | packed.append(struct.pack("!H", self.type)) |
| 148 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 149 | packed.append(struct.pack("!L", self.experimenter)) |
| 150 | packed.append(self.data) |
| 151 | length = sum([len(x) for x in packed]) |
| 152 | packed[1] = struct.pack("!H", length) |
| 153 | return ''.join(packed) |
| 154 | |
| 155 | @staticmethod |
| 156 | def unpack(reader): |
| 157 | subtype, = reader.peek('!L', 4) |
| 158 | subclass = experimenter.subtypes.get(subtype) |
| 159 | if subclass: |
| 160 | return subclass.unpack(reader) |
| 161 | |
| 162 | obj = experimenter() |
| 163 | _type = reader.read("!H")[0] |
| 164 | assert(_type == 65535) |
| 165 | _len = reader.read("!H")[0] |
| 166 | orig_reader = reader |
| 167 | reader = orig_reader.slice(_len - (2 + 2)) |
| 168 | obj.experimenter = reader.read("!L")[0] |
| 169 | obj.data = str(reader.read_all()) |
| 170 | return obj |
| 171 | |
| 172 | def __eq__(self, other): |
| 173 | if type(self) != type(other): return False |
| 174 | if self.experimenter != other.experimenter: return False |
| 175 | if self.data != other.data: return False |
| 176 | return True |
| 177 | |
| 178 | def pretty_print(self, q): |
| 179 | q.text("experimenter {") |
| 180 | with q.group(): |
| 181 | with q.indent(2): |
| 182 | q.breakable() |
| 183 | q.text("data = "); |
| 184 | q.pp(self.data) |
| 185 | q.breakable() |
| 186 | q.text('}') |
| 187 | |
| 188 | instruction.subtypes[65535] = experimenter |
| 189 | |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame^] | 190 | class bsn(experimenter): |
| 191 | subtypes = {} |
| 192 | |
| 193 | type = 65535 |
| 194 | experimenter = 6035143 |
| 195 | |
| 196 | def __init__(self, subtype=None): |
| 197 | if subtype != None: |
| 198 | self.subtype = subtype |
| 199 | else: |
| 200 | self.subtype = 0 |
| 201 | return |
| 202 | |
| 203 | def pack(self): |
| 204 | packed = [] |
| 205 | packed.append(struct.pack("!H", self.type)) |
| 206 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 207 | packed.append(struct.pack("!L", self.experimenter)) |
| 208 | packed.append(struct.pack("!L", self.subtype)) |
| 209 | packed.append('\x00' * 4) |
| 210 | length = sum([len(x) for x in packed]) |
| 211 | packed[1] = struct.pack("!H", length) |
| 212 | return ''.join(packed) |
| 213 | |
| 214 | @staticmethod |
| 215 | def unpack(reader): |
| 216 | subtype, = reader.peek('!L', 8) |
| 217 | subclass = bsn.subtypes.get(subtype) |
| 218 | if subclass: |
| 219 | return subclass.unpack(reader) |
| 220 | |
| 221 | obj = bsn() |
| 222 | _type = reader.read("!H")[0] |
| 223 | assert(_type == 65535) |
| 224 | _len = reader.read("!H")[0] |
| 225 | orig_reader = reader |
| 226 | reader = orig_reader.slice(_len - (2 + 2)) |
| 227 | _experimenter = reader.read("!L")[0] |
| 228 | assert(_experimenter == 6035143) |
| 229 | obj.subtype = reader.read("!L")[0] |
| 230 | reader.skip(4) |
| 231 | return obj |
| 232 | |
| 233 | def __eq__(self, other): |
| 234 | if type(self) != type(other): return False |
| 235 | if self.subtype != other.subtype: return False |
| 236 | return True |
| 237 | |
| 238 | def pretty_print(self, q): |
| 239 | q.text("bsn {") |
| 240 | with q.group(): |
| 241 | with q.indent(2): |
| 242 | q.breakable() |
| 243 | q.breakable() |
| 244 | q.text('}') |
| 245 | |
| 246 | experimenter.subtypes[6035143] = bsn |
| 247 | |
| 248 | class bsn_arp_offload(bsn): |
| 249 | type = 65535 |
| 250 | experimenter = 6035143 |
| 251 | subtype = 1 |
| 252 | |
| 253 | def __init__(self): |
| 254 | return |
| 255 | |
| 256 | def pack(self): |
| 257 | packed = [] |
| 258 | packed.append(struct.pack("!H", self.type)) |
| 259 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 260 | packed.append(struct.pack("!L", self.experimenter)) |
| 261 | packed.append(struct.pack("!L", self.subtype)) |
| 262 | packed.append('\x00' * 4) |
| 263 | length = sum([len(x) for x in packed]) |
| 264 | packed[1] = struct.pack("!H", length) |
| 265 | return ''.join(packed) |
| 266 | |
| 267 | @staticmethod |
| 268 | def unpack(reader): |
| 269 | obj = bsn_arp_offload() |
| 270 | _type = reader.read("!H")[0] |
| 271 | assert(_type == 65535) |
| 272 | _len = reader.read("!H")[0] |
| 273 | orig_reader = reader |
| 274 | reader = orig_reader.slice(_len - (2 + 2)) |
| 275 | _experimenter = reader.read("!L")[0] |
| 276 | assert(_experimenter == 6035143) |
| 277 | _subtype = reader.read("!L")[0] |
| 278 | assert(_subtype == 1) |
| 279 | reader.skip(4) |
| 280 | return obj |
| 281 | |
| 282 | def __eq__(self, other): |
| 283 | if type(self) != type(other): return False |
| 284 | return True |
| 285 | |
| 286 | def pretty_print(self, q): |
| 287 | q.text("bsn_arp_offload {") |
| 288 | with q.group(): |
| 289 | with q.indent(2): |
| 290 | q.breakable() |
| 291 | q.breakable() |
| 292 | q.text('}') |
| 293 | |
| 294 | bsn.subtypes[1] = bsn_arp_offload |
| 295 | |
| 296 | class bsn_deny(bsn): |
| 297 | type = 65535 |
| 298 | experimenter = 6035143 |
| 299 | subtype = 5 |
| 300 | |
| 301 | def __init__(self): |
| 302 | return |
| 303 | |
| 304 | def pack(self): |
| 305 | packed = [] |
| 306 | packed.append(struct.pack("!H", self.type)) |
| 307 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 308 | packed.append(struct.pack("!L", self.experimenter)) |
| 309 | packed.append(struct.pack("!L", self.subtype)) |
| 310 | packed.append('\x00' * 4) |
| 311 | length = sum([len(x) for x in packed]) |
| 312 | packed[1] = struct.pack("!H", length) |
| 313 | return ''.join(packed) |
| 314 | |
| 315 | @staticmethod |
| 316 | def unpack(reader): |
| 317 | obj = bsn_deny() |
| 318 | _type = reader.read("!H")[0] |
| 319 | assert(_type == 65535) |
| 320 | _len = reader.read("!H")[0] |
| 321 | orig_reader = reader |
| 322 | reader = orig_reader.slice(_len - (2 + 2)) |
| 323 | _experimenter = reader.read("!L")[0] |
| 324 | assert(_experimenter == 6035143) |
| 325 | _subtype = reader.read("!L")[0] |
| 326 | assert(_subtype == 5) |
| 327 | reader.skip(4) |
| 328 | return obj |
| 329 | |
| 330 | def __eq__(self, other): |
| 331 | if type(self) != type(other): return False |
| 332 | return True |
| 333 | |
| 334 | def pretty_print(self, q): |
| 335 | q.text("bsn_deny {") |
| 336 | with q.group(): |
| 337 | with q.indent(2): |
| 338 | q.breakable() |
| 339 | q.breakable() |
| 340 | q.text('}') |
| 341 | |
| 342 | bsn.subtypes[5] = bsn_deny |
| 343 | |
| 344 | class bsn_dhcp_offload(bsn): |
| 345 | type = 65535 |
| 346 | experimenter = 6035143 |
| 347 | subtype = 2 |
| 348 | |
| 349 | def __init__(self): |
| 350 | return |
| 351 | |
| 352 | def pack(self): |
| 353 | packed = [] |
| 354 | packed.append(struct.pack("!H", self.type)) |
| 355 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 356 | packed.append(struct.pack("!L", self.experimenter)) |
| 357 | packed.append(struct.pack("!L", self.subtype)) |
| 358 | packed.append('\x00' * 4) |
| 359 | length = sum([len(x) for x in packed]) |
| 360 | packed[1] = struct.pack("!H", length) |
| 361 | return ''.join(packed) |
| 362 | |
| 363 | @staticmethod |
| 364 | def unpack(reader): |
| 365 | obj = bsn_dhcp_offload() |
| 366 | _type = reader.read("!H")[0] |
| 367 | assert(_type == 65535) |
| 368 | _len = reader.read("!H")[0] |
| 369 | orig_reader = reader |
| 370 | reader = orig_reader.slice(_len - (2 + 2)) |
| 371 | _experimenter = reader.read("!L")[0] |
| 372 | assert(_experimenter == 6035143) |
| 373 | _subtype = reader.read("!L")[0] |
| 374 | assert(_subtype == 2) |
| 375 | reader.skip(4) |
| 376 | return obj |
| 377 | |
| 378 | def __eq__(self, other): |
| 379 | if type(self) != type(other): return False |
| 380 | return True |
| 381 | |
| 382 | def pretty_print(self, q): |
| 383 | q.text("bsn_dhcp_offload {") |
| 384 | with q.group(): |
| 385 | with q.indent(2): |
| 386 | q.breakable() |
| 387 | q.breakable() |
| 388 | q.text('}') |
| 389 | |
| 390 | bsn.subtypes[2] = bsn_dhcp_offload |
| 391 | |
| 392 | class bsn_disable_src_mac_check(bsn): |
| 393 | type = 65535 |
| 394 | experimenter = 6035143 |
| 395 | subtype = 0 |
| 396 | |
| 397 | def __init__(self): |
| 398 | return |
| 399 | |
| 400 | def pack(self): |
| 401 | packed = [] |
| 402 | packed.append(struct.pack("!H", self.type)) |
| 403 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 404 | packed.append(struct.pack("!L", self.experimenter)) |
| 405 | packed.append(struct.pack("!L", self.subtype)) |
| 406 | packed.append('\x00' * 4) |
| 407 | length = sum([len(x) for x in packed]) |
| 408 | packed[1] = struct.pack("!H", length) |
| 409 | return ''.join(packed) |
| 410 | |
| 411 | @staticmethod |
| 412 | def unpack(reader): |
| 413 | obj = bsn_disable_src_mac_check() |
| 414 | _type = reader.read("!H")[0] |
| 415 | assert(_type == 65535) |
| 416 | _len = reader.read("!H")[0] |
| 417 | orig_reader = reader |
| 418 | reader = orig_reader.slice(_len - (2 + 2)) |
| 419 | _experimenter = reader.read("!L")[0] |
| 420 | assert(_experimenter == 6035143) |
| 421 | _subtype = reader.read("!L")[0] |
| 422 | assert(_subtype == 0) |
| 423 | reader.skip(4) |
| 424 | return obj |
| 425 | |
| 426 | def __eq__(self, other): |
| 427 | if type(self) != type(other): return False |
| 428 | return True |
| 429 | |
| 430 | def pretty_print(self, q): |
| 431 | q.text("bsn_disable_src_mac_check {") |
| 432 | with q.group(): |
| 433 | with q.indent(2): |
| 434 | q.breakable() |
| 435 | q.breakable() |
| 436 | q.text('}') |
| 437 | |
| 438 | bsn.subtypes[0] = bsn_disable_src_mac_check |
| 439 | |
| 440 | class bsn_disable_vlan_counters(bsn): |
| 441 | type = 65535 |
| 442 | experimenter = 6035143 |
| 443 | subtype = 9 |
| 444 | |
| 445 | def __init__(self): |
| 446 | return |
| 447 | |
| 448 | def pack(self): |
| 449 | packed = [] |
| 450 | packed.append(struct.pack("!H", self.type)) |
| 451 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 452 | packed.append(struct.pack("!L", self.experimenter)) |
| 453 | packed.append(struct.pack("!L", self.subtype)) |
| 454 | packed.append('\x00' * 4) |
| 455 | length = sum([len(x) for x in packed]) |
| 456 | packed[1] = struct.pack("!H", length) |
| 457 | return ''.join(packed) |
| 458 | |
| 459 | @staticmethod |
| 460 | def unpack(reader): |
| 461 | obj = bsn_disable_vlan_counters() |
| 462 | _type = reader.read("!H")[0] |
| 463 | assert(_type == 65535) |
| 464 | _len = reader.read("!H")[0] |
| 465 | orig_reader = reader |
| 466 | reader = orig_reader.slice(_len - (2 + 2)) |
| 467 | _experimenter = reader.read("!L")[0] |
| 468 | assert(_experimenter == 6035143) |
| 469 | _subtype = reader.read("!L")[0] |
| 470 | assert(_subtype == 9) |
| 471 | reader.skip(4) |
| 472 | return obj |
| 473 | |
| 474 | def __eq__(self, other): |
| 475 | if type(self) != type(other): return False |
| 476 | return True |
| 477 | |
| 478 | def pretty_print(self, q): |
| 479 | q.text("bsn_disable_vlan_counters {") |
| 480 | with q.group(): |
| 481 | with q.indent(2): |
| 482 | q.breakable() |
| 483 | q.breakable() |
| 484 | q.text('}') |
| 485 | |
| 486 | bsn.subtypes[9] = bsn_disable_vlan_counters |
| 487 | |
| 488 | class bsn_packet_of_death(bsn): |
| 489 | type = 65535 |
| 490 | experimenter = 6035143 |
| 491 | subtype = 6 |
| 492 | |
| 493 | def __init__(self): |
| 494 | return |
| 495 | |
| 496 | def pack(self): |
| 497 | packed = [] |
| 498 | packed.append(struct.pack("!H", self.type)) |
| 499 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 500 | packed.append(struct.pack("!L", self.experimenter)) |
| 501 | packed.append(struct.pack("!L", self.subtype)) |
| 502 | packed.append('\x00' * 4) |
| 503 | length = sum([len(x) for x in packed]) |
| 504 | packed[1] = struct.pack("!H", length) |
| 505 | return ''.join(packed) |
| 506 | |
| 507 | @staticmethod |
| 508 | def unpack(reader): |
| 509 | obj = bsn_packet_of_death() |
| 510 | _type = reader.read("!H")[0] |
| 511 | assert(_type == 65535) |
| 512 | _len = reader.read("!H")[0] |
| 513 | orig_reader = reader |
| 514 | reader = orig_reader.slice(_len - (2 + 2)) |
| 515 | _experimenter = reader.read("!L")[0] |
| 516 | assert(_experimenter == 6035143) |
| 517 | _subtype = reader.read("!L")[0] |
| 518 | assert(_subtype == 6) |
| 519 | reader.skip(4) |
| 520 | return obj |
| 521 | |
| 522 | def __eq__(self, other): |
| 523 | if type(self) != type(other): return False |
| 524 | return True |
| 525 | |
| 526 | def pretty_print(self, q): |
| 527 | q.text("bsn_packet_of_death {") |
| 528 | with q.group(): |
| 529 | with q.indent(2): |
| 530 | q.breakable() |
| 531 | q.breakable() |
| 532 | q.text('}') |
| 533 | |
| 534 | bsn.subtypes[6] = bsn_packet_of_death |
| 535 | |
| 536 | class bsn_permit(bsn): |
| 537 | type = 65535 |
| 538 | experimenter = 6035143 |
| 539 | subtype = 4 |
| 540 | |
| 541 | def __init__(self): |
| 542 | return |
| 543 | |
| 544 | def pack(self): |
| 545 | packed = [] |
| 546 | packed.append(struct.pack("!H", self.type)) |
| 547 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 548 | packed.append(struct.pack("!L", self.experimenter)) |
| 549 | packed.append(struct.pack("!L", self.subtype)) |
| 550 | packed.append('\x00' * 4) |
| 551 | length = sum([len(x) for x in packed]) |
| 552 | packed[1] = struct.pack("!H", length) |
| 553 | return ''.join(packed) |
| 554 | |
| 555 | @staticmethod |
| 556 | def unpack(reader): |
| 557 | obj = bsn_permit() |
| 558 | _type = reader.read("!H")[0] |
| 559 | assert(_type == 65535) |
| 560 | _len = reader.read("!H")[0] |
| 561 | orig_reader = reader |
| 562 | reader = orig_reader.slice(_len - (2 + 2)) |
| 563 | _experimenter = reader.read("!L")[0] |
| 564 | assert(_experimenter == 6035143) |
| 565 | _subtype = reader.read("!L")[0] |
| 566 | assert(_subtype == 4) |
| 567 | reader.skip(4) |
| 568 | return obj |
| 569 | |
| 570 | def __eq__(self, other): |
| 571 | if type(self) != type(other): return False |
| 572 | return True |
| 573 | |
| 574 | def pretty_print(self, q): |
| 575 | q.text("bsn_permit {") |
| 576 | with q.group(): |
| 577 | with q.indent(2): |
| 578 | q.breakable() |
| 579 | q.breakable() |
| 580 | q.text('}') |
| 581 | |
| 582 | bsn.subtypes[4] = bsn_permit |
| 583 | |
| 584 | class bsn_prioritize_pdus(bsn): |
| 585 | type = 65535 |
| 586 | experimenter = 6035143 |
| 587 | subtype = 7 |
| 588 | |
| 589 | def __init__(self): |
| 590 | return |
| 591 | |
| 592 | def pack(self): |
| 593 | packed = [] |
| 594 | packed.append(struct.pack("!H", self.type)) |
| 595 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 596 | packed.append(struct.pack("!L", self.experimenter)) |
| 597 | packed.append(struct.pack("!L", self.subtype)) |
| 598 | packed.append('\x00' * 4) |
| 599 | length = sum([len(x) for x in packed]) |
| 600 | packed[1] = struct.pack("!H", length) |
| 601 | return ''.join(packed) |
| 602 | |
| 603 | @staticmethod |
| 604 | def unpack(reader): |
| 605 | obj = bsn_prioritize_pdus() |
| 606 | _type = reader.read("!H")[0] |
| 607 | assert(_type == 65535) |
| 608 | _len = reader.read("!H")[0] |
| 609 | orig_reader = reader |
| 610 | reader = orig_reader.slice(_len - (2 + 2)) |
| 611 | _experimenter = reader.read("!L")[0] |
| 612 | assert(_experimenter == 6035143) |
| 613 | _subtype = reader.read("!L")[0] |
| 614 | assert(_subtype == 7) |
| 615 | reader.skip(4) |
| 616 | return obj |
| 617 | |
| 618 | def __eq__(self, other): |
| 619 | if type(self) != type(other): return False |
| 620 | return True |
| 621 | |
| 622 | def pretty_print(self, q): |
| 623 | q.text("bsn_prioritize_pdus {") |
| 624 | with q.group(): |
| 625 | with q.indent(2): |
| 626 | q.breakable() |
| 627 | q.breakable() |
| 628 | q.text('}') |
| 629 | |
| 630 | bsn.subtypes[7] = bsn_prioritize_pdus |
| 631 | |
| 632 | class bsn_require_vlan_xlate(bsn): |
| 633 | type = 65535 |
| 634 | experimenter = 6035143 |
| 635 | subtype = 8 |
| 636 | |
| 637 | def __init__(self): |
| 638 | return |
| 639 | |
| 640 | def pack(self): |
| 641 | packed = [] |
| 642 | packed.append(struct.pack("!H", self.type)) |
| 643 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 644 | packed.append(struct.pack("!L", self.experimenter)) |
| 645 | packed.append(struct.pack("!L", self.subtype)) |
| 646 | packed.append('\x00' * 4) |
| 647 | length = sum([len(x) for x in packed]) |
| 648 | packed[1] = struct.pack("!H", length) |
| 649 | return ''.join(packed) |
| 650 | |
| 651 | @staticmethod |
| 652 | def unpack(reader): |
| 653 | obj = bsn_require_vlan_xlate() |
| 654 | _type = reader.read("!H")[0] |
| 655 | assert(_type == 65535) |
| 656 | _len = reader.read("!H")[0] |
| 657 | orig_reader = reader |
| 658 | reader = orig_reader.slice(_len - (2 + 2)) |
| 659 | _experimenter = reader.read("!L")[0] |
| 660 | assert(_experimenter == 6035143) |
| 661 | _subtype = reader.read("!L")[0] |
| 662 | assert(_subtype == 8) |
| 663 | reader.skip(4) |
| 664 | return obj |
| 665 | |
| 666 | def __eq__(self, other): |
| 667 | if type(self) != type(other): return False |
| 668 | return True |
| 669 | |
| 670 | def pretty_print(self, q): |
| 671 | q.text("bsn_require_vlan_xlate {") |
| 672 | with q.group(): |
| 673 | with q.indent(2): |
| 674 | q.breakable() |
| 675 | q.breakable() |
| 676 | q.text('}') |
| 677 | |
| 678 | bsn.subtypes[8] = bsn_require_vlan_xlate |
| 679 | |
| 680 | class bsn_span_destination(bsn): |
| 681 | type = 65535 |
| 682 | experimenter = 6035143 |
| 683 | subtype = 10 |
| 684 | |
| 685 | def __init__(self): |
| 686 | return |
| 687 | |
| 688 | def pack(self): |
| 689 | packed = [] |
| 690 | packed.append(struct.pack("!H", self.type)) |
| 691 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 692 | packed.append(struct.pack("!L", self.experimenter)) |
| 693 | packed.append(struct.pack("!L", self.subtype)) |
| 694 | packed.append('\x00' * 4) |
| 695 | length = sum([len(x) for x in packed]) |
| 696 | packed[1] = struct.pack("!H", length) |
| 697 | return ''.join(packed) |
| 698 | |
| 699 | @staticmethod |
| 700 | def unpack(reader): |
| 701 | obj = bsn_span_destination() |
| 702 | _type = reader.read("!H")[0] |
| 703 | assert(_type == 65535) |
| 704 | _len = reader.read("!H")[0] |
| 705 | orig_reader = reader |
| 706 | reader = orig_reader.slice(_len - (2 + 2)) |
| 707 | _experimenter = reader.read("!L")[0] |
| 708 | assert(_experimenter == 6035143) |
| 709 | _subtype = reader.read("!L")[0] |
| 710 | assert(_subtype == 10) |
| 711 | reader.skip(4) |
| 712 | return obj |
| 713 | |
| 714 | def __eq__(self, other): |
| 715 | if type(self) != type(other): return False |
| 716 | return True |
| 717 | |
| 718 | def pretty_print(self, q): |
| 719 | q.text("bsn_span_destination {") |
| 720 | with q.group(): |
| 721 | with q.indent(2): |
| 722 | q.breakable() |
| 723 | q.breakable() |
| 724 | q.text('}') |
| 725 | |
| 726 | bsn.subtypes[10] = bsn_span_destination |
| 727 | |
| 728 | class clear_actions(instruction): |
| 729 | type = 5 |
| 730 | |
| 731 | def __init__(self): |
| 732 | return |
| 733 | |
| 734 | def pack(self): |
| 735 | packed = [] |
| 736 | packed.append(struct.pack("!H", self.type)) |
| 737 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 738 | packed.append('\x00' * 4) |
| 739 | length = sum([len(x) for x in packed]) |
| 740 | packed[1] = struct.pack("!H", length) |
| 741 | return ''.join(packed) |
| 742 | |
| 743 | @staticmethod |
| 744 | def unpack(reader): |
| 745 | obj = clear_actions() |
| 746 | _type = reader.read("!H")[0] |
| 747 | assert(_type == 5) |
| 748 | _len = reader.read("!H")[0] |
| 749 | orig_reader = reader |
| 750 | reader = orig_reader.slice(_len - (2 + 2)) |
| 751 | reader.skip(4) |
| 752 | return obj |
| 753 | |
| 754 | def __eq__(self, other): |
| 755 | if type(self) != type(other): return False |
| 756 | return True |
| 757 | |
| 758 | def pretty_print(self, q): |
| 759 | q.text("clear_actions {") |
| 760 | with q.group(): |
| 761 | with q.indent(2): |
| 762 | q.breakable() |
| 763 | q.breakable() |
| 764 | q.text('}') |
| 765 | |
| 766 | instruction.subtypes[5] = clear_actions |
| 767 | |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 768 | class goto_table(instruction): |
| 769 | type = 1 |
| 770 | |
| 771 | def __init__(self, table_id=None): |
| 772 | if table_id != None: |
| 773 | self.table_id = table_id |
| 774 | else: |
| 775 | self.table_id = 0 |
| 776 | return |
| 777 | |
| 778 | def pack(self): |
| 779 | packed = [] |
| 780 | packed.append(struct.pack("!H", self.type)) |
| 781 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 782 | packed.append(struct.pack("!B", self.table_id)) |
| 783 | packed.append('\x00' * 3) |
| 784 | length = sum([len(x) for x in packed]) |
| 785 | packed[1] = struct.pack("!H", length) |
| 786 | return ''.join(packed) |
| 787 | |
| 788 | @staticmethod |
| 789 | def unpack(reader): |
| 790 | obj = goto_table() |
| 791 | _type = reader.read("!H")[0] |
| 792 | assert(_type == 1) |
| 793 | _len = reader.read("!H")[0] |
| 794 | orig_reader = reader |
| 795 | reader = orig_reader.slice(_len - (2 + 2)) |
| 796 | obj.table_id = reader.read("!B")[0] |
| 797 | reader.skip(3) |
| 798 | return obj |
| 799 | |
| 800 | def __eq__(self, other): |
| 801 | if type(self) != type(other): return False |
| 802 | if self.table_id != other.table_id: return False |
| 803 | return True |
| 804 | |
| 805 | def pretty_print(self, q): |
| 806 | q.text("goto_table {") |
| 807 | with q.group(): |
| 808 | with q.indent(2): |
| 809 | q.breakable() |
| 810 | q.text("table_id = "); |
| 811 | q.text("%#x" % self.table_id) |
| 812 | q.breakable() |
| 813 | q.text('}') |
| 814 | |
| 815 | instruction.subtypes[1] = goto_table |
| 816 | |
| 817 | class meter(instruction): |
| 818 | type = 6 |
| 819 | |
| 820 | def __init__(self, meter_id=None): |
| 821 | if meter_id != None: |
| 822 | self.meter_id = meter_id |
| 823 | else: |
| 824 | self.meter_id = 0 |
| 825 | return |
| 826 | |
| 827 | def pack(self): |
| 828 | packed = [] |
| 829 | packed.append(struct.pack("!H", self.type)) |
| 830 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 831 | packed.append(struct.pack("!L", self.meter_id)) |
| 832 | length = sum([len(x) for x in packed]) |
| 833 | packed[1] = struct.pack("!H", length) |
| 834 | return ''.join(packed) |
| 835 | |
| 836 | @staticmethod |
| 837 | def unpack(reader): |
| 838 | obj = meter() |
| 839 | _type = reader.read("!H")[0] |
| 840 | assert(_type == 6) |
| 841 | _len = reader.read("!H")[0] |
| 842 | orig_reader = reader |
| 843 | reader = orig_reader.slice(_len - (2 + 2)) |
| 844 | obj.meter_id = reader.read("!L")[0] |
| 845 | return obj |
| 846 | |
| 847 | def __eq__(self, other): |
| 848 | if type(self) != type(other): return False |
| 849 | if self.meter_id != other.meter_id: return False |
| 850 | return True |
| 851 | |
| 852 | def pretty_print(self, q): |
| 853 | q.text("meter {") |
| 854 | with q.group(): |
| 855 | with q.indent(2): |
| 856 | q.breakable() |
| 857 | q.text("meter_id = "); |
| 858 | q.text("%#x" % self.meter_id) |
| 859 | q.breakable() |
| 860 | q.text('}') |
| 861 | |
| 862 | instruction.subtypes[6] = meter |
| 863 | |
| 864 | class write_actions(instruction): |
| 865 | type = 3 |
| 866 | |
| 867 | def __init__(self, actions=None): |
| 868 | if actions != None: |
| 869 | self.actions = actions |
| 870 | else: |
| 871 | self.actions = [] |
| 872 | return |
| 873 | |
| 874 | def pack(self): |
| 875 | packed = [] |
| 876 | packed.append(struct.pack("!H", self.type)) |
| 877 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 878 | packed.append('\x00' * 4) |
| 879 | packed.append(loxi.generic_util.pack_list(self.actions)) |
| 880 | length = sum([len(x) for x in packed]) |
| 881 | packed[1] = struct.pack("!H", length) |
| 882 | return ''.join(packed) |
| 883 | |
| 884 | @staticmethod |
| 885 | def unpack(reader): |
| 886 | obj = write_actions() |
| 887 | _type = reader.read("!H")[0] |
| 888 | assert(_type == 3) |
| 889 | _len = reader.read("!H")[0] |
| 890 | orig_reader = reader |
| 891 | reader = orig_reader.slice(_len - (2 + 2)) |
| 892 | reader.skip(4) |
| 893 | obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack) |
| 894 | return obj |
| 895 | |
| 896 | def __eq__(self, other): |
| 897 | if type(self) != type(other): return False |
| 898 | if self.actions != other.actions: return False |
| 899 | return True |
| 900 | |
| 901 | def pretty_print(self, q): |
| 902 | q.text("write_actions {") |
| 903 | with q.group(): |
| 904 | with q.indent(2): |
| 905 | q.breakable() |
| 906 | q.text("actions = "); |
| 907 | q.pp(self.actions) |
| 908 | q.breakable() |
| 909 | q.text('}') |
| 910 | |
| 911 | instruction.subtypes[3] = write_actions |
| 912 | |
| 913 | class write_metadata(instruction): |
| 914 | type = 2 |
| 915 | |
| 916 | def __init__(self, metadata=None, metadata_mask=None): |
| 917 | if metadata != None: |
| 918 | self.metadata = metadata |
| 919 | else: |
| 920 | self.metadata = 0 |
| 921 | if metadata_mask != None: |
| 922 | self.metadata_mask = metadata_mask |
| 923 | else: |
| 924 | self.metadata_mask = 0 |
| 925 | return |
| 926 | |
| 927 | def pack(self): |
| 928 | packed = [] |
| 929 | packed.append(struct.pack("!H", self.type)) |
| 930 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 931 | packed.append('\x00' * 4) |
| 932 | packed.append(struct.pack("!Q", self.metadata)) |
| 933 | packed.append(struct.pack("!Q", self.metadata_mask)) |
| 934 | length = sum([len(x) for x in packed]) |
| 935 | packed[1] = struct.pack("!H", length) |
| 936 | return ''.join(packed) |
| 937 | |
| 938 | @staticmethod |
| 939 | def unpack(reader): |
| 940 | obj = write_metadata() |
| 941 | _type = reader.read("!H")[0] |
| 942 | assert(_type == 2) |
| 943 | _len = reader.read("!H")[0] |
| 944 | orig_reader = reader |
| 945 | reader = orig_reader.slice(_len - (2 + 2)) |
| 946 | reader.skip(4) |
| 947 | obj.metadata = reader.read("!Q")[0] |
| 948 | obj.metadata_mask = reader.read("!Q")[0] |
| 949 | return obj |
| 950 | |
| 951 | def __eq__(self, other): |
| 952 | if type(self) != type(other): return False |
| 953 | if self.metadata != other.metadata: return False |
| 954 | if self.metadata_mask != other.metadata_mask: return False |
| 955 | return True |
| 956 | |
| 957 | def pretty_print(self, q): |
| 958 | q.text("write_metadata {") |
| 959 | with q.group(): |
| 960 | with q.indent(2): |
| 961 | q.breakable() |
| 962 | q.text("metadata = "); |
| 963 | q.text("%#x" % self.metadata) |
| 964 | q.text(","); q.breakable() |
| 965 | q.text("metadata_mask = "); |
| 966 | q.text("%#x" % self.metadata_mask) |
| 967 | q.breakable() |
| 968 | q.text('}') |
| 969 | |
| 970 | instruction.subtypes[2] = write_metadata |
| 971 | |
| 972 | |