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