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