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 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 80 | length = sum([len(x) for x in packed]) |
| 81 | packed[1] = struct.pack("!H", length) |
| 82 | return ''.join(packed) |
| 83 | |
| 84 | @staticmethod |
| 85 | def unpack(reader): |
| 86 | obj = apply_actions() |
| 87 | _type = reader.read("!H")[0] |
| 88 | assert(_type == 4) |
| 89 | _len = reader.read("!H")[0] |
| 90 | orig_reader = reader |
| 91 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 92 | return obj |
| 93 | |
| 94 | def __eq__(self, other): |
| 95 | if type(self) != type(other): return False |
| 96 | return True |
| 97 | |
| 98 | def pretty_print(self, q): |
| 99 | q.text("apply_actions {") |
| 100 | with q.group(): |
| 101 | with q.indent(2): |
| 102 | q.breakable() |
| 103 | q.breakable() |
| 104 | q.text('}') |
| 105 | |
| 106 | instruction_id.subtypes[4] = apply_actions |
| 107 | |
| 108 | class experimenter(instruction_id): |
| 109 | subtypes = {} |
| 110 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 111 | type = 65535 |
| 112 | |
| 113 | def __init__(self, experimenter=None): |
| 114 | if experimenter != None: |
| 115 | self.experimenter = experimenter |
| 116 | else: |
| 117 | self.experimenter = 0 |
| 118 | return |
| 119 | |
| 120 | def pack(self): |
| 121 | packed = [] |
| 122 | packed.append(struct.pack("!H", self.type)) |
| 123 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 124 | packed.append(struct.pack("!L", self.experimenter)) |
| 125 | length = sum([len(x) for x in packed]) |
| 126 | packed[1] = struct.pack("!H", length) |
| 127 | return ''.join(packed) |
| 128 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 129 | @staticmethod |
| 130 | def unpack(reader): |
| 131 | subtype, = reader.peek('!L', 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 132 | subclass = experimenter.subtypes.get(subtype) |
| 133 | if subclass: |
| 134 | return subclass.unpack(reader) |
| 135 | |
| 136 | obj = experimenter() |
| 137 | _type = reader.read("!H")[0] |
| 138 | assert(_type == 65535) |
| 139 | _len = reader.read("!H")[0] |
| 140 | orig_reader = reader |
| 141 | reader = orig_reader.slice(_len - (2 + 2)) |
| 142 | obj.experimenter = reader.read("!L")[0] |
| 143 | return obj |
| 144 | |
| 145 | def __eq__(self, other): |
| 146 | if type(self) != type(other): return False |
| 147 | if self.experimenter != other.experimenter: return False |
| 148 | return True |
| 149 | |
| 150 | def pretty_print(self, q): |
| 151 | q.text("experimenter {") |
| 152 | with q.group(): |
| 153 | with q.indent(2): |
| 154 | q.breakable() |
| 155 | q.breakable() |
| 156 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 157 | |
| 158 | instruction_id.subtypes[65535] = experimenter |
| 159 | |
| 160 | class bsn(experimenter): |
| 161 | subtypes = {} |
| 162 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 163 | type = 65535 |
| 164 | experimenter = 6035143 |
| 165 | |
| 166 | def __init__(self, subtype=None): |
| 167 | if subtype != None: |
| 168 | self.subtype = subtype |
| 169 | else: |
| 170 | self.subtype = 0 |
| 171 | return |
| 172 | |
| 173 | def pack(self): |
| 174 | packed = [] |
| 175 | packed.append(struct.pack("!H", self.type)) |
| 176 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 177 | packed.append(struct.pack("!L", self.experimenter)) |
| 178 | packed.append(struct.pack("!L", self.subtype)) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 179 | length = sum([len(x) for x in packed]) |
| 180 | packed[1] = struct.pack("!H", length) |
| 181 | return ''.join(packed) |
| 182 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 183 | @staticmethod |
| 184 | def unpack(reader): |
| 185 | subtype, = reader.peek('!L', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 186 | subclass = bsn.subtypes.get(subtype) |
| 187 | if subclass: |
| 188 | return subclass.unpack(reader) |
| 189 | |
| 190 | obj = bsn() |
| 191 | _type = reader.read("!H")[0] |
| 192 | assert(_type == 65535) |
| 193 | _len = reader.read("!H")[0] |
| 194 | orig_reader = reader |
| 195 | reader = orig_reader.slice(_len - (2 + 2)) |
| 196 | _experimenter = reader.read("!L")[0] |
| 197 | assert(_experimenter == 6035143) |
| 198 | obj.subtype = reader.read("!L")[0] |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 199 | return obj |
| 200 | |
| 201 | def __eq__(self, other): |
| 202 | if type(self) != type(other): return False |
| 203 | if self.subtype != other.subtype: return False |
| 204 | return True |
| 205 | |
| 206 | def pretty_print(self, q): |
| 207 | q.text("bsn {") |
| 208 | with q.group(): |
| 209 | with q.indent(2): |
| 210 | q.breakable() |
| 211 | q.breakable() |
| 212 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 213 | |
| 214 | experimenter.subtypes[6035143] = bsn |
| 215 | |
Rich Lane | 5454b68 | 2014-01-14 17:07:36 -0800 | [diff] [blame] | 216 | class bsn_arp_offload(bsn): |
| 217 | type = 65535 |
| 218 | experimenter = 6035143 |
| 219 | subtype = 1 |
| 220 | |
| 221 | def __init__(self): |
| 222 | return |
| 223 | |
| 224 | def pack(self): |
| 225 | packed = [] |
| 226 | packed.append(struct.pack("!H", self.type)) |
| 227 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 228 | packed.append(struct.pack("!L", self.experimenter)) |
| 229 | packed.append(struct.pack("!L", self.subtype)) |
Rich Lane | 5454b68 | 2014-01-14 17:07:36 -0800 | [diff] [blame] | 230 | length = sum([len(x) for x in packed]) |
| 231 | packed[1] = struct.pack("!H", length) |
| 232 | return ''.join(packed) |
| 233 | |
| 234 | @staticmethod |
| 235 | def unpack(reader): |
| 236 | obj = bsn_arp_offload() |
| 237 | _type = reader.read("!H")[0] |
| 238 | assert(_type == 65535) |
| 239 | _len = reader.read("!H")[0] |
| 240 | orig_reader = reader |
| 241 | reader = orig_reader.slice(_len - (2 + 2)) |
| 242 | _experimenter = reader.read("!L")[0] |
| 243 | assert(_experimenter == 6035143) |
| 244 | _subtype = reader.read("!L")[0] |
| 245 | assert(_subtype == 1) |
Rich Lane | 5454b68 | 2014-01-14 17:07:36 -0800 | [diff] [blame] | 246 | return obj |
| 247 | |
| 248 | def __eq__(self, other): |
| 249 | if type(self) != type(other): return False |
| 250 | return True |
| 251 | |
| 252 | def pretty_print(self, q): |
| 253 | q.text("bsn_arp_offload {") |
| 254 | with q.group(): |
| 255 | with q.indent(2): |
| 256 | q.breakable() |
| 257 | q.breakable() |
| 258 | q.text('}') |
| 259 | |
| 260 | bsn.subtypes[1] = bsn_arp_offload |
| 261 | |
Rich Lane | 9ec3fca | 2014-02-26 16:22:56 -0800 | [diff] [blame] | 262 | class bsn_deny(bsn): |
| 263 | type = 65535 |
| 264 | experimenter = 6035143 |
| 265 | subtype = 5 |
| 266 | |
| 267 | def __init__(self): |
| 268 | return |
| 269 | |
| 270 | def pack(self): |
| 271 | packed = [] |
| 272 | packed.append(struct.pack("!H", self.type)) |
| 273 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 274 | packed.append(struct.pack("!L", self.experimenter)) |
| 275 | packed.append(struct.pack("!L", self.subtype)) |
| 276 | length = sum([len(x) for x in packed]) |
| 277 | packed[1] = struct.pack("!H", length) |
| 278 | return ''.join(packed) |
| 279 | |
| 280 | @staticmethod |
| 281 | def unpack(reader): |
| 282 | obj = bsn_deny() |
| 283 | _type = reader.read("!H")[0] |
| 284 | assert(_type == 65535) |
| 285 | _len = reader.read("!H")[0] |
| 286 | orig_reader = reader |
| 287 | reader = orig_reader.slice(_len - (2 + 2)) |
| 288 | _experimenter = reader.read("!L")[0] |
| 289 | assert(_experimenter == 6035143) |
| 290 | _subtype = reader.read("!L")[0] |
| 291 | assert(_subtype == 5) |
| 292 | return obj |
| 293 | |
| 294 | def __eq__(self, other): |
| 295 | if type(self) != type(other): return False |
| 296 | return True |
| 297 | |
| 298 | def pretty_print(self, q): |
| 299 | q.text("bsn_deny {") |
| 300 | with q.group(): |
| 301 | with q.indent(2): |
| 302 | q.breakable() |
| 303 | q.breakable() |
| 304 | q.text('}') |
| 305 | |
| 306 | bsn.subtypes[5] = bsn_deny |
| 307 | |
Rich Lane | 1b75abf | 2014-02-05 11:23:20 -0800 | [diff] [blame] | 308 | class bsn_dhcp_offload(bsn): |
| 309 | type = 65535 |
| 310 | experimenter = 6035143 |
| 311 | subtype = 2 |
| 312 | |
| 313 | def __init__(self): |
| 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 len at index 1 |
| 320 | packed.append(struct.pack("!L", self.experimenter)) |
| 321 | packed.append(struct.pack("!L", self.subtype)) |
Rich Lane | 1b75abf | 2014-02-05 11:23:20 -0800 | [diff] [blame] | 322 | length = sum([len(x) for x in packed]) |
| 323 | packed[1] = struct.pack("!H", length) |
| 324 | return ''.join(packed) |
| 325 | |
| 326 | @staticmethod |
| 327 | def unpack(reader): |
| 328 | obj = bsn_dhcp_offload() |
| 329 | _type = reader.read("!H")[0] |
| 330 | assert(_type == 65535) |
| 331 | _len = reader.read("!H")[0] |
| 332 | orig_reader = reader |
| 333 | reader = orig_reader.slice(_len - (2 + 2)) |
| 334 | _experimenter = reader.read("!L")[0] |
| 335 | assert(_experimenter == 6035143) |
| 336 | _subtype = reader.read("!L")[0] |
| 337 | assert(_subtype == 2) |
Rich Lane | 1b75abf | 2014-02-05 11:23:20 -0800 | [diff] [blame] | 338 | return obj |
| 339 | |
| 340 | def __eq__(self, other): |
| 341 | if type(self) != type(other): return False |
| 342 | return True |
| 343 | |
| 344 | def pretty_print(self, q): |
| 345 | q.text("bsn_dhcp_offload {") |
| 346 | with q.group(): |
| 347 | with q.indent(2): |
| 348 | q.breakable() |
| 349 | q.breakable() |
| 350 | q.text('}') |
| 351 | |
| 352 | bsn.subtypes[2] = bsn_dhcp_offload |
| 353 | |
Rich Lane | 9ec3fca | 2014-02-26 16:22:56 -0800 | [diff] [blame] | 354 | class bsn_disable_split_horizon_check(bsn): |
| 355 | type = 65535 |
| 356 | experimenter = 6035143 |
| 357 | subtype = 3 |
| 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(struct.pack("!L", self.experimenter)) |
| 367 | packed.append(struct.pack("!L", self.subtype)) |
| 368 | length = sum([len(x) for x in packed]) |
| 369 | packed[1] = struct.pack("!H", length) |
| 370 | return ''.join(packed) |
| 371 | |
| 372 | @staticmethod |
| 373 | def unpack(reader): |
| 374 | obj = bsn_disable_split_horizon_check() |
| 375 | _type = reader.read("!H")[0] |
| 376 | assert(_type == 65535) |
| 377 | _len = reader.read("!H")[0] |
| 378 | orig_reader = reader |
| 379 | reader = orig_reader.slice(_len - (2 + 2)) |
| 380 | _experimenter = reader.read("!L")[0] |
| 381 | assert(_experimenter == 6035143) |
| 382 | _subtype = reader.read("!L")[0] |
| 383 | assert(_subtype == 3) |
| 384 | return obj |
| 385 | |
| 386 | def __eq__(self, other): |
| 387 | if type(self) != type(other): return False |
| 388 | return True |
| 389 | |
| 390 | def pretty_print(self, q): |
| 391 | q.text("bsn_disable_split_horizon_check {") |
| 392 | with q.group(): |
| 393 | with q.indent(2): |
| 394 | q.breakable() |
| 395 | q.breakable() |
| 396 | q.text('}') |
| 397 | |
| 398 | bsn.subtypes[3] = bsn_disable_split_horizon_check |
| 399 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 400 | class bsn_disable_src_mac_check(bsn): |
| 401 | type = 65535 |
| 402 | experimenter = 6035143 |
| 403 | subtype = 0 |
| 404 | |
| 405 | def __init__(self): |
| 406 | return |
| 407 | |
| 408 | def pack(self): |
| 409 | packed = [] |
| 410 | packed.append(struct.pack("!H", self.type)) |
| 411 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 412 | packed.append(struct.pack("!L", self.experimenter)) |
| 413 | packed.append(struct.pack("!L", self.subtype)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 414 | length = sum([len(x) for x in packed]) |
| 415 | packed[1] = struct.pack("!H", length) |
| 416 | return ''.join(packed) |
| 417 | |
| 418 | @staticmethod |
| 419 | def unpack(reader): |
| 420 | obj = bsn_disable_src_mac_check() |
| 421 | _type = reader.read("!H")[0] |
| 422 | assert(_type == 65535) |
| 423 | _len = reader.read("!H")[0] |
| 424 | orig_reader = reader |
| 425 | reader = orig_reader.slice(_len - (2 + 2)) |
| 426 | _experimenter = reader.read("!L")[0] |
| 427 | assert(_experimenter == 6035143) |
| 428 | _subtype = reader.read("!L")[0] |
| 429 | assert(_subtype == 0) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 430 | return obj |
| 431 | |
| 432 | def __eq__(self, other): |
| 433 | if type(self) != type(other): return False |
| 434 | return True |
| 435 | |
| 436 | def pretty_print(self, q): |
| 437 | q.text("bsn_disable_src_mac_check {") |
| 438 | with q.group(): |
| 439 | with q.indent(2): |
| 440 | q.breakable() |
| 441 | q.breakable() |
| 442 | q.text('}') |
| 443 | |
| 444 | bsn.subtypes[0] = bsn_disable_src_mac_check |
| 445 | |
Rich Lane | 9ec3fca | 2014-02-26 16:22:56 -0800 | [diff] [blame] | 446 | class bsn_permit(bsn): |
| 447 | type = 65535 |
| 448 | experimenter = 6035143 |
| 449 | subtype = 4 |
| 450 | |
| 451 | def __init__(self): |
| 452 | return |
| 453 | |
| 454 | def pack(self): |
| 455 | packed = [] |
| 456 | packed.append(struct.pack("!H", self.type)) |
| 457 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 458 | packed.append(struct.pack("!L", self.experimenter)) |
| 459 | packed.append(struct.pack("!L", self.subtype)) |
| 460 | length = sum([len(x) for x in packed]) |
| 461 | packed[1] = struct.pack("!H", length) |
| 462 | return ''.join(packed) |
| 463 | |
| 464 | @staticmethod |
| 465 | def unpack(reader): |
| 466 | obj = bsn_permit() |
| 467 | _type = reader.read("!H")[0] |
| 468 | assert(_type == 65535) |
| 469 | _len = reader.read("!H")[0] |
| 470 | orig_reader = reader |
| 471 | reader = orig_reader.slice(_len - (2 + 2)) |
| 472 | _experimenter = reader.read("!L")[0] |
| 473 | assert(_experimenter == 6035143) |
| 474 | _subtype = reader.read("!L")[0] |
| 475 | assert(_subtype == 4) |
| 476 | return obj |
| 477 | |
| 478 | def __eq__(self, other): |
| 479 | if type(self) != type(other): return False |
| 480 | return True |
| 481 | |
| 482 | def pretty_print(self, q): |
| 483 | q.text("bsn_permit {") |
| 484 | with q.group(): |
| 485 | with q.indent(2): |
| 486 | q.breakable() |
| 487 | q.breakable() |
| 488 | q.text('}') |
| 489 | |
| 490 | bsn.subtypes[4] = bsn_permit |
| 491 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 492 | class clear_actions(instruction_id): |
| 493 | type = 5 |
| 494 | |
| 495 | def __init__(self): |
| 496 | return |
| 497 | |
| 498 | def pack(self): |
| 499 | packed = [] |
| 500 | packed.append(struct.pack("!H", self.type)) |
| 501 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 502 | length = sum([len(x) for x in packed]) |
| 503 | packed[1] = struct.pack("!H", length) |
| 504 | return ''.join(packed) |
| 505 | |
| 506 | @staticmethod |
| 507 | def unpack(reader): |
| 508 | obj = clear_actions() |
| 509 | _type = reader.read("!H")[0] |
| 510 | assert(_type == 5) |
| 511 | _len = reader.read("!H")[0] |
| 512 | orig_reader = reader |
| 513 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 514 | return obj |
| 515 | |
| 516 | def __eq__(self, other): |
| 517 | if type(self) != type(other): return False |
| 518 | return True |
| 519 | |
| 520 | def pretty_print(self, q): |
| 521 | q.text("clear_actions {") |
| 522 | with q.group(): |
| 523 | with q.indent(2): |
| 524 | q.breakable() |
| 525 | q.breakable() |
| 526 | q.text('}') |
| 527 | |
| 528 | instruction_id.subtypes[5] = clear_actions |
| 529 | |
| 530 | class goto_table(instruction_id): |
| 531 | type = 1 |
| 532 | |
| 533 | def __init__(self): |
| 534 | return |
| 535 | |
| 536 | def pack(self): |
| 537 | packed = [] |
| 538 | packed.append(struct.pack("!H", self.type)) |
| 539 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 540 | length = sum([len(x) for x in packed]) |
| 541 | packed[1] = struct.pack("!H", length) |
| 542 | return ''.join(packed) |
| 543 | |
| 544 | @staticmethod |
| 545 | def unpack(reader): |
| 546 | obj = goto_table() |
| 547 | _type = reader.read("!H")[0] |
| 548 | assert(_type == 1) |
| 549 | _len = reader.read("!H")[0] |
| 550 | orig_reader = reader |
| 551 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 552 | return obj |
| 553 | |
| 554 | def __eq__(self, other): |
| 555 | if type(self) != type(other): return False |
| 556 | return True |
| 557 | |
| 558 | def pretty_print(self, q): |
| 559 | q.text("goto_table {") |
| 560 | with q.group(): |
| 561 | with q.indent(2): |
| 562 | q.breakable() |
| 563 | q.breakable() |
| 564 | q.text('}') |
| 565 | |
| 566 | instruction_id.subtypes[1] = goto_table |
| 567 | |
| 568 | class meter(instruction_id): |
| 569 | type = 6 |
| 570 | |
| 571 | def __init__(self): |
| 572 | return |
| 573 | |
| 574 | def pack(self): |
| 575 | packed = [] |
| 576 | packed.append(struct.pack("!H", self.type)) |
| 577 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 578 | length = sum([len(x) for x in packed]) |
| 579 | packed[1] = struct.pack("!H", length) |
| 580 | return ''.join(packed) |
| 581 | |
| 582 | @staticmethod |
| 583 | def unpack(reader): |
| 584 | obj = meter() |
| 585 | _type = reader.read("!H")[0] |
| 586 | assert(_type == 6) |
| 587 | _len = reader.read("!H")[0] |
| 588 | orig_reader = reader |
| 589 | reader = orig_reader.slice(_len - (2 + 2)) |
| 590 | return obj |
| 591 | |
| 592 | def __eq__(self, other): |
| 593 | if type(self) != type(other): return False |
| 594 | return True |
| 595 | |
| 596 | def pretty_print(self, q): |
| 597 | q.text("meter {") |
| 598 | with q.group(): |
| 599 | with q.indent(2): |
| 600 | q.breakable() |
| 601 | q.breakable() |
| 602 | q.text('}') |
| 603 | |
| 604 | instruction_id.subtypes[6] = meter |
| 605 | |
| 606 | class write_actions(instruction_id): |
| 607 | type = 3 |
| 608 | |
| 609 | def __init__(self): |
| 610 | return |
| 611 | |
| 612 | def pack(self): |
| 613 | packed = [] |
| 614 | packed.append(struct.pack("!H", self.type)) |
| 615 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 616 | length = sum([len(x) for x in packed]) |
| 617 | packed[1] = struct.pack("!H", length) |
| 618 | return ''.join(packed) |
| 619 | |
| 620 | @staticmethod |
| 621 | def unpack(reader): |
| 622 | obj = write_actions() |
| 623 | _type = reader.read("!H")[0] |
| 624 | assert(_type == 3) |
| 625 | _len = reader.read("!H")[0] |
| 626 | orig_reader = reader |
| 627 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 628 | return obj |
| 629 | |
| 630 | def __eq__(self, other): |
| 631 | if type(self) != type(other): return False |
| 632 | return True |
| 633 | |
| 634 | def pretty_print(self, q): |
| 635 | q.text("write_actions {") |
| 636 | with q.group(): |
| 637 | with q.indent(2): |
| 638 | q.breakable() |
| 639 | q.breakable() |
| 640 | q.text('}') |
| 641 | |
| 642 | instruction_id.subtypes[3] = write_actions |
| 643 | |
| 644 | class write_metadata(instruction_id): |
| 645 | type = 2 |
| 646 | |
| 647 | def __init__(self): |
| 648 | return |
| 649 | |
| 650 | def pack(self): |
| 651 | packed = [] |
| 652 | packed.append(struct.pack("!H", self.type)) |
| 653 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 654 | length = sum([len(x) for x in packed]) |
| 655 | packed[1] = struct.pack("!H", length) |
| 656 | return ''.join(packed) |
| 657 | |
| 658 | @staticmethod |
| 659 | def unpack(reader): |
| 660 | obj = write_metadata() |
| 661 | _type = reader.read("!H")[0] |
| 662 | assert(_type == 2) |
| 663 | _len = reader.read("!H")[0] |
| 664 | orig_reader = reader |
| 665 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 666 | return obj |
| 667 | |
| 668 | def __eq__(self, other): |
| 669 | if type(self) != type(other): return False |
| 670 | return True |
| 671 | |
| 672 | def pretty_print(self, q): |
| 673 | q.text("write_metadata {") |
| 674 | with q.group(): |
| 675 | with q.indent(2): |
| 676 | q.breakable() |
| 677 | q.breakable() |
| 678 | q.text('}') |
| 679 | |
| 680 | instruction_id.subtypes[2] = write_metadata |
| 681 | |
| 682 | |