Matteo Scandolo | a229eca | 2017-08-08 13:05:28 -0700 | [diff] [blame^] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 17 | # Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 18 | # Copyright (c) 2011, 2012 Open Networking Foundation |
| 19 | # Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
| 20 | # See the file LICENSE.pyloxi which should have been included in the source distribution |
| 21 | |
| 22 | # Automatically generated by LOXI from template module.py |
| 23 | # Do not modify |
| 24 | |
| 25 | import struct |
| 26 | import loxi |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 27 | import util |
| 28 | import loxi.generic_util |
| 29 | |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 30 | import sys |
| 31 | ofp = sys.modules['loxi.of14'] |
| 32 | |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 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 |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 63 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 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 |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 107 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 108 | reader.skip(4) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 109 | obj.actions = loxi.generic_util.unpack_list(reader, ofp.action.action.unpack) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 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 |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 167 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 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 |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 226 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 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 |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 274 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 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 | |
Harshmeet Singh | 301f717 | 2014-12-08 13:07:29 -0800 | [diff] [blame] | 296 | class bsn_auto_negotiation(bsn): |
| 297 | type = 65535 |
| 298 | experimenter = 6035143 |
| 299 | subtype = 11 |
| 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_auto_negotiation() |
| 318 | _type = reader.read("!H")[0] |
| 319 | assert(_type == 65535) |
| 320 | _len = reader.read("!H")[0] |
| 321 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 322 | reader = orig_reader.slice(_len, 4) |
Harshmeet Singh | 301f717 | 2014-12-08 13:07:29 -0800 | [diff] [blame] | 323 | _experimenter = reader.read("!L")[0] |
| 324 | assert(_experimenter == 6035143) |
| 325 | _subtype = reader.read("!L")[0] |
| 326 | assert(_subtype == 11) |
| 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_auto_negotiation {") |
| 336 | with q.group(): |
| 337 | with q.indent(2): |
| 338 | q.breakable() |
| 339 | q.breakable() |
| 340 | q.text('}') |
| 341 | |
| 342 | bsn.subtypes[11] = bsn_auto_negotiation |
| 343 | |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 344 | class bsn_deny(bsn): |
| 345 | type = 65535 |
| 346 | experimenter = 6035143 |
| 347 | subtype = 5 |
| 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_deny() |
| 366 | _type = reader.read("!H")[0] |
| 367 | assert(_type == 65535) |
| 368 | _len = reader.read("!H")[0] |
| 369 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 370 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 371 | _experimenter = reader.read("!L")[0] |
| 372 | assert(_experimenter == 6035143) |
| 373 | _subtype = reader.read("!L")[0] |
| 374 | assert(_subtype == 5) |
| 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_deny {") |
| 384 | with q.group(): |
| 385 | with q.indent(2): |
| 386 | q.breakable() |
| 387 | q.breakable() |
| 388 | q.text('}') |
| 389 | |
| 390 | bsn.subtypes[5] = bsn_deny |
| 391 | |
| 392 | class bsn_dhcp_offload(bsn): |
| 393 | type = 65535 |
| 394 | experimenter = 6035143 |
| 395 | subtype = 2 |
| 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_dhcp_offload() |
| 414 | _type = reader.read("!H")[0] |
| 415 | assert(_type == 65535) |
| 416 | _len = reader.read("!H")[0] |
| 417 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 418 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 419 | _experimenter = reader.read("!L")[0] |
| 420 | assert(_experimenter == 6035143) |
| 421 | _subtype = reader.read("!L")[0] |
| 422 | assert(_subtype == 2) |
| 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_dhcp_offload {") |
| 432 | with q.group(): |
| 433 | with q.indent(2): |
| 434 | q.breakable() |
| 435 | q.breakable() |
| 436 | q.text('}') |
| 437 | |
| 438 | bsn.subtypes[2] = bsn_dhcp_offload |
| 439 | |
Kiran Poola | 36a302c | 2015-04-22 11:20:16 -0700 | [diff] [blame] | 440 | class bsn_disable_l3(bsn): |
| 441 | type = 65535 |
| 442 | experimenter = 6035143 |
| 443 | subtype = 13 |
| 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_l3() |
| 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, 4) |
| 467 | _experimenter = reader.read("!L")[0] |
| 468 | assert(_experimenter == 6035143) |
| 469 | _subtype = reader.read("!L")[0] |
| 470 | assert(_subtype == 13) |
| 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_l3 {") |
| 480 | with q.group(): |
| 481 | with q.indent(2): |
| 482 | q.breakable() |
| 483 | q.breakable() |
| 484 | q.text('}') |
| 485 | |
| 486 | bsn.subtypes[13] = bsn_disable_l3 |
| 487 | |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 488 | class bsn_disable_src_mac_check(bsn): |
| 489 | type = 65535 |
| 490 | experimenter = 6035143 |
| 491 | subtype = 0 |
| 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_disable_src_mac_check() |
| 510 | _type = reader.read("!H")[0] |
| 511 | assert(_type == 65535) |
| 512 | _len = reader.read("!H")[0] |
| 513 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 514 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 515 | _experimenter = reader.read("!L")[0] |
| 516 | assert(_experimenter == 6035143) |
| 517 | _subtype = reader.read("!L")[0] |
| 518 | assert(_subtype == 0) |
| 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_disable_src_mac_check {") |
| 528 | with q.group(): |
| 529 | with q.indent(2): |
| 530 | q.breakable() |
| 531 | q.breakable() |
| 532 | q.text('}') |
| 533 | |
| 534 | bsn.subtypes[0] = bsn_disable_src_mac_check |
| 535 | |
| 536 | class bsn_disable_vlan_counters(bsn): |
| 537 | type = 65535 |
| 538 | experimenter = 6035143 |
| 539 | subtype = 9 |
| 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_disable_vlan_counters() |
| 558 | _type = reader.read("!H")[0] |
| 559 | assert(_type == 65535) |
| 560 | _len = reader.read("!H")[0] |
| 561 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 562 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 563 | _experimenter = reader.read("!L")[0] |
| 564 | assert(_experimenter == 6035143) |
| 565 | _subtype = reader.read("!L")[0] |
| 566 | assert(_subtype == 9) |
| 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_disable_vlan_counters {") |
| 576 | with q.group(): |
| 577 | with q.indent(2): |
| 578 | q.breakable() |
| 579 | q.breakable() |
| 580 | q.text('}') |
| 581 | |
| 582 | bsn.subtypes[9] = bsn_disable_vlan_counters |
| 583 | |
Rich Lane | 7b69e79 | 2015-03-31 11:12:50 -0700 | [diff] [blame] | 584 | class bsn_internal_priority(bsn): |
| 585 | type = 65535 |
| 586 | experimenter = 6035143 |
| 587 | subtype = 12 |
| 588 | |
| 589 | def __init__(self, value=None): |
| 590 | if value != None: |
| 591 | self.value = value |
| 592 | else: |
| 593 | self.value = 0 |
| 594 | return |
| 595 | |
| 596 | def pack(self): |
| 597 | packed = [] |
| 598 | packed.append(struct.pack("!H", self.type)) |
| 599 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 600 | packed.append(struct.pack("!L", self.experimenter)) |
| 601 | packed.append(struct.pack("!L", self.subtype)) |
| 602 | packed.append(struct.pack("!L", self.value)) |
| 603 | length = sum([len(x) for x in packed]) |
| 604 | packed[1] = struct.pack("!H", length) |
| 605 | return ''.join(packed) |
| 606 | |
| 607 | @staticmethod |
| 608 | def unpack(reader): |
| 609 | obj = bsn_internal_priority() |
| 610 | _type = reader.read("!H")[0] |
| 611 | assert(_type == 65535) |
| 612 | _len = reader.read("!H")[0] |
| 613 | orig_reader = reader |
| 614 | reader = orig_reader.slice(_len, 4) |
| 615 | _experimenter = reader.read("!L")[0] |
| 616 | assert(_experimenter == 6035143) |
| 617 | _subtype = reader.read("!L")[0] |
| 618 | assert(_subtype == 12) |
| 619 | obj.value = reader.read("!L")[0] |
| 620 | return obj |
| 621 | |
| 622 | def __eq__(self, other): |
| 623 | if type(self) != type(other): return False |
| 624 | if self.value != other.value: return False |
| 625 | return True |
| 626 | |
| 627 | def pretty_print(self, q): |
| 628 | q.text("bsn_internal_priority {") |
| 629 | with q.group(): |
| 630 | with q.indent(2): |
| 631 | q.breakable() |
| 632 | q.text("value = "); |
| 633 | q.text("%#x" % self.value) |
| 634 | q.breakable() |
| 635 | q.text('}') |
| 636 | |
| 637 | bsn.subtypes[12] = bsn_internal_priority |
| 638 | |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 639 | class bsn_packet_of_death(bsn): |
| 640 | type = 65535 |
| 641 | experimenter = 6035143 |
| 642 | subtype = 6 |
| 643 | |
| 644 | def __init__(self): |
| 645 | return |
| 646 | |
| 647 | def pack(self): |
| 648 | packed = [] |
| 649 | packed.append(struct.pack("!H", self.type)) |
| 650 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 651 | packed.append(struct.pack("!L", self.experimenter)) |
| 652 | packed.append(struct.pack("!L", self.subtype)) |
| 653 | packed.append('\x00' * 4) |
| 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 = bsn_packet_of_death() |
| 661 | _type = reader.read("!H")[0] |
| 662 | assert(_type == 65535) |
| 663 | _len = reader.read("!H")[0] |
| 664 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 665 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 666 | _experimenter = reader.read("!L")[0] |
| 667 | assert(_experimenter == 6035143) |
| 668 | _subtype = reader.read("!L")[0] |
| 669 | assert(_subtype == 6) |
| 670 | reader.skip(4) |
| 671 | return obj |
| 672 | |
| 673 | def __eq__(self, other): |
| 674 | if type(self) != type(other): return False |
| 675 | return True |
| 676 | |
| 677 | def pretty_print(self, q): |
| 678 | q.text("bsn_packet_of_death {") |
| 679 | with q.group(): |
| 680 | with q.indent(2): |
| 681 | q.breakable() |
| 682 | q.breakable() |
| 683 | q.text('}') |
| 684 | |
| 685 | bsn.subtypes[6] = bsn_packet_of_death |
| 686 | |
| 687 | class bsn_permit(bsn): |
| 688 | type = 65535 |
| 689 | experimenter = 6035143 |
| 690 | subtype = 4 |
| 691 | |
| 692 | def __init__(self): |
| 693 | return |
| 694 | |
| 695 | def pack(self): |
| 696 | packed = [] |
| 697 | packed.append(struct.pack("!H", self.type)) |
| 698 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 699 | packed.append(struct.pack("!L", self.experimenter)) |
| 700 | packed.append(struct.pack("!L", self.subtype)) |
| 701 | packed.append('\x00' * 4) |
| 702 | length = sum([len(x) for x in packed]) |
| 703 | packed[1] = struct.pack("!H", length) |
| 704 | return ''.join(packed) |
| 705 | |
| 706 | @staticmethod |
| 707 | def unpack(reader): |
| 708 | obj = bsn_permit() |
| 709 | _type = reader.read("!H")[0] |
| 710 | assert(_type == 65535) |
| 711 | _len = reader.read("!H")[0] |
| 712 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 713 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 714 | _experimenter = reader.read("!L")[0] |
| 715 | assert(_experimenter == 6035143) |
| 716 | _subtype = reader.read("!L")[0] |
| 717 | assert(_subtype == 4) |
| 718 | reader.skip(4) |
| 719 | return obj |
| 720 | |
| 721 | def __eq__(self, other): |
| 722 | if type(self) != type(other): return False |
| 723 | return True |
| 724 | |
| 725 | def pretty_print(self, q): |
| 726 | q.text("bsn_permit {") |
| 727 | with q.group(): |
| 728 | with q.indent(2): |
| 729 | q.breakable() |
| 730 | q.breakable() |
| 731 | q.text('}') |
| 732 | |
| 733 | bsn.subtypes[4] = bsn_permit |
| 734 | |
| 735 | class bsn_prioritize_pdus(bsn): |
| 736 | type = 65535 |
| 737 | experimenter = 6035143 |
| 738 | subtype = 7 |
| 739 | |
| 740 | def __init__(self): |
| 741 | return |
| 742 | |
| 743 | def pack(self): |
| 744 | packed = [] |
| 745 | packed.append(struct.pack("!H", self.type)) |
| 746 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 747 | packed.append(struct.pack("!L", self.experimenter)) |
| 748 | packed.append(struct.pack("!L", self.subtype)) |
| 749 | packed.append('\x00' * 4) |
| 750 | length = sum([len(x) for x in packed]) |
| 751 | packed[1] = struct.pack("!H", length) |
| 752 | return ''.join(packed) |
| 753 | |
| 754 | @staticmethod |
| 755 | def unpack(reader): |
| 756 | obj = bsn_prioritize_pdus() |
| 757 | _type = reader.read("!H")[0] |
| 758 | assert(_type == 65535) |
| 759 | _len = reader.read("!H")[0] |
| 760 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 761 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 762 | _experimenter = reader.read("!L")[0] |
| 763 | assert(_experimenter == 6035143) |
| 764 | _subtype = reader.read("!L")[0] |
| 765 | assert(_subtype == 7) |
| 766 | reader.skip(4) |
| 767 | return obj |
| 768 | |
| 769 | def __eq__(self, other): |
| 770 | if type(self) != type(other): return False |
| 771 | return True |
| 772 | |
| 773 | def pretty_print(self, q): |
| 774 | q.text("bsn_prioritize_pdus {") |
| 775 | with q.group(): |
| 776 | with q.indent(2): |
| 777 | q.breakable() |
| 778 | q.breakable() |
| 779 | q.text('}') |
| 780 | |
| 781 | bsn.subtypes[7] = bsn_prioritize_pdus |
| 782 | |
| 783 | class bsn_require_vlan_xlate(bsn): |
| 784 | type = 65535 |
| 785 | experimenter = 6035143 |
| 786 | subtype = 8 |
| 787 | |
| 788 | def __init__(self): |
| 789 | return |
| 790 | |
| 791 | def pack(self): |
| 792 | packed = [] |
| 793 | packed.append(struct.pack("!H", self.type)) |
| 794 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 795 | packed.append(struct.pack("!L", self.experimenter)) |
| 796 | packed.append(struct.pack("!L", self.subtype)) |
| 797 | packed.append('\x00' * 4) |
| 798 | length = sum([len(x) for x in packed]) |
| 799 | packed[1] = struct.pack("!H", length) |
| 800 | return ''.join(packed) |
| 801 | |
| 802 | @staticmethod |
| 803 | def unpack(reader): |
| 804 | obj = bsn_require_vlan_xlate() |
| 805 | _type = reader.read("!H")[0] |
| 806 | assert(_type == 65535) |
| 807 | _len = reader.read("!H")[0] |
| 808 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 809 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 810 | _experimenter = reader.read("!L")[0] |
| 811 | assert(_experimenter == 6035143) |
| 812 | _subtype = reader.read("!L")[0] |
| 813 | assert(_subtype == 8) |
| 814 | reader.skip(4) |
| 815 | return obj |
| 816 | |
| 817 | def __eq__(self, other): |
| 818 | if type(self) != type(other): return False |
| 819 | return True |
| 820 | |
| 821 | def pretty_print(self, q): |
| 822 | q.text("bsn_require_vlan_xlate {") |
| 823 | with q.group(): |
| 824 | with q.indent(2): |
| 825 | q.breakable() |
| 826 | q.breakable() |
| 827 | q.text('}') |
| 828 | |
| 829 | bsn.subtypes[8] = bsn_require_vlan_xlate |
| 830 | |
| 831 | class bsn_span_destination(bsn): |
| 832 | type = 65535 |
| 833 | experimenter = 6035143 |
| 834 | subtype = 10 |
| 835 | |
| 836 | def __init__(self): |
| 837 | return |
| 838 | |
| 839 | def pack(self): |
| 840 | packed = [] |
| 841 | packed.append(struct.pack("!H", self.type)) |
| 842 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 843 | packed.append(struct.pack("!L", self.experimenter)) |
| 844 | packed.append(struct.pack("!L", self.subtype)) |
| 845 | packed.append('\x00' * 4) |
| 846 | length = sum([len(x) for x in packed]) |
| 847 | packed[1] = struct.pack("!H", length) |
| 848 | return ''.join(packed) |
| 849 | |
| 850 | @staticmethod |
| 851 | def unpack(reader): |
| 852 | obj = bsn_span_destination() |
| 853 | _type = reader.read("!H")[0] |
| 854 | assert(_type == 65535) |
| 855 | _len = reader.read("!H")[0] |
| 856 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 857 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 858 | _experimenter = reader.read("!L")[0] |
| 859 | assert(_experimenter == 6035143) |
| 860 | _subtype = reader.read("!L")[0] |
| 861 | assert(_subtype == 10) |
| 862 | reader.skip(4) |
| 863 | return obj |
| 864 | |
| 865 | def __eq__(self, other): |
| 866 | if type(self) != type(other): return False |
| 867 | return True |
| 868 | |
| 869 | def pretty_print(self, q): |
| 870 | q.text("bsn_span_destination {") |
| 871 | with q.group(): |
| 872 | with q.indent(2): |
| 873 | q.breakable() |
| 874 | q.breakable() |
| 875 | q.text('}') |
| 876 | |
| 877 | bsn.subtypes[10] = bsn_span_destination |
| 878 | |
| 879 | class clear_actions(instruction): |
| 880 | type = 5 |
| 881 | |
| 882 | def __init__(self): |
| 883 | return |
| 884 | |
| 885 | def pack(self): |
| 886 | packed = [] |
| 887 | packed.append(struct.pack("!H", self.type)) |
| 888 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 889 | packed.append('\x00' * 4) |
| 890 | length = sum([len(x) for x in packed]) |
| 891 | packed[1] = struct.pack("!H", length) |
| 892 | return ''.join(packed) |
| 893 | |
| 894 | @staticmethod |
| 895 | def unpack(reader): |
| 896 | obj = clear_actions() |
| 897 | _type = reader.read("!H")[0] |
| 898 | assert(_type == 5) |
| 899 | _len = reader.read("!H")[0] |
| 900 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 901 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 902 | reader.skip(4) |
| 903 | return obj |
| 904 | |
| 905 | def __eq__(self, other): |
| 906 | if type(self) != type(other): return False |
| 907 | return True |
| 908 | |
| 909 | def pretty_print(self, q): |
| 910 | q.text("clear_actions {") |
| 911 | with q.group(): |
| 912 | with q.indent(2): |
| 913 | q.breakable() |
| 914 | q.breakable() |
| 915 | q.text('}') |
| 916 | |
| 917 | instruction.subtypes[5] = clear_actions |
| 918 | |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 919 | class goto_table(instruction): |
| 920 | type = 1 |
| 921 | |
| 922 | def __init__(self, table_id=None): |
| 923 | if table_id != None: |
| 924 | self.table_id = table_id |
| 925 | else: |
| 926 | self.table_id = 0 |
| 927 | return |
| 928 | |
| 929 | def pack(self): |
| 930 | packed = [] |
| 931 | packed.append(struct.pack("!H", self.type)) |
| 932 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 933 | packed.append(struct.pack("!B", self.table_id)) |
| 934 | packed.append('\x00' * 3) |
| 935 | length = sum([len(x) for x in packed]) |
| 936 | packed[1] = struct.pack("!H", length) |
| 937 | return ''.join(packed) |
| 938 | |
| 939 | @staticmethod |
| 940 | def unpack(reader): |
| 941 | obj = goto_table() |
| 942 | _type = reader.read("!H")[0] |
| 943 | assert(_type == 1) |
| 944 | _len = reader.read("!H")[0] |
| 945 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 946 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 947 | obj.table_id = reader.read("!B")[0] |
| 948 | reader.skip(3) |
| 949 | return obj |
| 950 | |
| 951 | def __eq__(self, other): |
| 952 | if type(self) != type(other): return False |
| 953 | if self.table_id != other.table_id: return False |
| 954 | return True |
| 955 | |
| 956 | def pretty_print(self, q): |
| 957 | q.text("goto_table {") |
| 958 | with q.group(): |
| 959 | with q.indent(2): |
| 960 | q.breakable() |
| 961 | q.text("table_id = "); |
| 962 | q.text("%#x" % self.table_id) |
| 963 | q.breakable() |
| 964 | q.text('}') |
| 965 | |
| 966 | instruction.subtypes[1] = goto_table |
| 967 | |
| 968 | class meter(instruction): |
| 969 | type = 6 |
| 970 | |
| 971 | def __init__(self, meter_id=None): |
| 972 | if meter_id != None: |
| 973 | self.meter_id = meter_id |
| 974 | else: |
| 975 | self.meter_id = 0 |
| 976 | return |
| 977 | |
| 978 | def pack(self): |
| 979 | packed = [] |
| 980 | packed.append(struct.pack("!H", self.type)) |
| 981 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 982 | packed.append(struct.pack("!L", self.meter_id)) |
| 983 | length = sum([len(x) for x in packed]) |
| 984 | packed[1] = struct.pack("!H", length) |
| 985 | return ''.join(packed) |
| 986 | |
| 987 | @staticmethod |
| 988 | def unpack(reader): |
| 989 | obj = meter() |
| 990 | _type = reader.read("!H")[0] |
| 991 | assert(_type == 6) |
| 992 | _len = reader.read("!H")[0] |
| 993 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 994 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 995 | obj.meter_id = reader.read("!L")[0] |
| 996 | return obj |
| 997 | |
| 998 | def __eq__(self, other): |
| 999 | if type(self) != type(other): return False |
| 1000 | if self.meter_id != other.meter_id: return False |
| 1001 | return True |
| 1002 | |
| 1003 | def pretty_print(self, q): |
| 1004 | q.text("meter {") |
| 1005 | with q.group(): |
| 1006 | with q.indent(2): |
| 1007 | q.breakable() |
| 1008 | q.text("meter_id = "); |
| 1009 | q.text("%#x" % self.meter_id) |
| 1010 | q.breakable() |
| 1011 | q.text('}') |
| 1012 | |
| 1013 | instruction.subtypes[6] = meter |
| 1014 | |
| 1015 | class write_actions(instruction): |
| 1016 | type = 3 |
| 1017 | |
| 1018 | def __init__(self, actions=None): |
| 1019 | if actions != None: |
| 1020 | self.actions = actions |
| 1021 | else: |
| 1022 | self.actions = [] |
| 1023 | return |
| 1024 | |
| 1025 | def pack(self): |
| 1026 | packed = [] |
| 1027 | packed.append(struct.pack("!H", self.type)) |
| 1028 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1029 | packed.append('\x00' * 4) |
| 1030 | packed.append(loxi.generic_util.pack_list(self.actions)) |
| 1031 | length = sum([len(x) for x in packed]) |
| 1032 | packed[1] = struct.pack("!H", length) |
| 1033 | return ''.join(packed) |
| 1034 | |
| 1035 | @staticmethod |
| 1036 | def unpack(reader): |
| 1037 | obj = write_actions() |
| 1038 | _type = reader.read("!H")[0] |
| 1039 | assert(_type == 3) |
| 1040 | _len = reader.read("!H")[0] |
| 1041 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1042 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 1043 | reader.skip(4) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 1044 | obj.actions = loxi.generic_util.unpack_list(reader, ofp.action.action.unpack) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 1045 | return obj |
| 1046 | |
| 1047 | def __eq__(self, other): |
| 1048 | if type(self) != type(other): return False |
| 1049 | if self.actions != other.actions: return False |
| 1050 | return True |
| 1051 | |
| 1052 | def pretty_print(self, q): |
| 1053 | q.text("write_actions {") |
| 1054 | with q.group(): |
| 1055 | with q.indent(2): |
| 1056 | q.breakable() |
| 1057 | q.text("actions = "); |
| 1058 | q.pp(self.actions) |
| 1059 | q.breakable() |
| 1060 | q.text('}') |
| 1061 | |
| 1062 | instruction.subtypes[3] = write_actions |
| 1063 | |
| 1064 | class write_metadata(instruction): |
| 1065 | type = 2 |
| 1066 | |
| 1067 | def __init__(self, metadata=None, metadata_mask=None): |
| 1068 | if metadata != None: |
| 1069 | self.metadata = metadata |
| 1070 | else: |
| 1071 | self.metadata = 0 |
| 1072 | if metadata_mask != None: |
| 1073 | self.metadata_mask = metadata_mask |
| 1074 | else: |
| 1075 | self.metadata_mask = 0 |
| 1076 | return |
| 1077 | |
| 1078 | def pack(self): |
| 1079 | packed = [] |
| 1080 | packed.append(struct.pack("!H", self.type)) |
| 1081 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1082 | packed.append('\x00' * 4) |
| 1083 | packed.append(struct.pack("!Q", self.metadata)) |
| 1084 | packed.append(struct.pack("!Q", self.metadata_mask)) |
| 1085 | length = sum([len(x) for x in packed]) |
| 1086 | packed[1] = struct.pack("!H", length) |
| 1087 | return ''.join(packed) |
| 1088 | |
| 1089 | @staticmethod |
| 1090 | def unpack(reader): |
| 1091 | obj = write_metadata() |
| 1092 | _type = reader.read("!H")[0] |
| 1093 | assert(_type == 2) |
| 1094 | _len = reader.read("!H")[0] |
| 1095 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1096 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 1097 | reader.skip(4) |
| 1098 | obj.metadata = reader.read("!Q")[0] |
| 1099 | obj.metadata_mask = reader.read("!Q")[0] |
| 1100 | return obj |
| 1101 | |
| 1102 | def __eq__(self, other): |
| 1103 | if type(self) != type(other): return False |
| 1104 | if self.metadata != other.metadata: return False |
| 1105 | if self.metadata_mask != other.metadata_mask: return False |
| 1106 | return True |
| 1107 | |
| 1108 | def pretty_print(self, q): |
| 1109 | q.text("write_metadata {") |
| 1110 | with q.group(): |
| 1111 | with q.indent(2): |
| 1112 | q.breakable() |
| 1113 | q.text("metadata = "); |
| 1114 | q.text("%#x" % self.metadata) |
| 1115 | q.text(","); q.breakable() |
| 1116 | q.text("metadata_mask = "); |
| 1117 | q.text("%#x" % self.metadata_mask) |
| 1118 | q.breakable() |
| 1119 | q.text('}') |
| 1120 | |
| 1121 | instruction.subtypes[2] = write_metadata |
| 1122 | |
| 1123 | |