Zack Williams | 9731cdc | 2019-11-22 15:42:30 -0700 | [diff] [blame^] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 15 | # Copyright (c) 2011, 2012 Open Networking Foundation |
| 16 | # Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
| 17 | # See the file LICENSE.pyloxi which should have been included in the source distribution |
| 18 | |
| 19 | # Automatically generated by LOXI from template module.py |
| 20 | # Do not modify |
| 21 | |
| 22 | import struct |
| 23 | import loxi |
| 24 | import util |
| 25 | import loxi.generic_util |
| 26 | |
| 27 | import sys |
| 28 | ofp = sys.modules['loxi.of13'] |
| 29 | |
| 30 | class action(loxi.OFObject): |
| 31 | subtypes = {} |
| 32 | |
| 33 | |
| 34 | def __init__(self, type=None): |
| 35 | if type != None: |
| 36 | self.type = type |
| 37 | else: |
| 38 | self.type = 0 |
| 39 | return |
| 40 | |
| 41 | def pack(self): |
| 42 | packed = [] |
| 43 | packed.append(struct.pack("!H", self.type)) |
| 44 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 45 | packed.append('\x00' * 4) |
| 46 | length = sum([len(x) for x in packed]) |
| 47 | packed[1] = struct.pack("!H", length) |
| 48 | return ''.join(packed) |
| 49 | |
| 50 | @staticmethod |
| 51 | def unpack(reader): |
| 52 | subtype, = reader.peek('!H', 0) |
| 53 | subclass = action.subtypes.get(subtype) |
| 54 | if subclass: |
| 55 | return subclass.unpack(reader) |
| 56 | |
| 57 | obj = action() |
| 58 | obj.type = reader.read("!H")[0] |
| 59 | _len = reader.read("!H")[0] |
| 60 | orig_reader = reader |
| 61 | reader = orig_reader.slice(_len, 4) |
| 62 | reader.skip(4) |
| 63 | return obj |
| 64 | |
| 65 | def __eq__(self, other): |
| 66 | if type(self) != type(other): return False |
| 67 | if self.type != other.type: return False |
| 68 | return True |
| 69 | |
| 70 | def pretty_print(self, q): |
| 71 | q.text("action {") |
| 72 | with q.group(): |
| 73 | with q.indent(2): |
| 74 | q.breakable() |
| 75 | q.breakable() |
| 76 | q.text('}') |
| 77 | |
| 78 | |
| 79 | class experimenter(action): |
| 80 | subtypes = {} |
| 81 | |
| 82 | type = 65535 |
| 83 | |
| 84 | def __init__(self, experimenter=None, data=None): |
| 85 | if experimenter != None: |
| 86 | self.experimenter = experimenter |
| 87 | else: |
| 88 | self.experimenter = 0 |
| 89 | if data != None: |
| 90 | self.data = data |
| 91 | else: |
| 92 | self.data = '' |
| 93 | return |
| 94 | |
| 95 | def pack(self): |
| 96 | packed = [] |
| 97 | packed.append(struct.pack("!H", self.type)) |
| 98 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 99 | packed.append(struct.pack("!L", self.experimenter)) |
| 100 | packed.append(self.data) |
| 101 | length = sum([len(x) for x in packed]) |
| 102 | packed.append(loxi.generic_util.pad_to(8, length)) |
| 103 | length += len(packed[-1]) |
| 104 | packed[1] = struct.pack("!H", length) |
| 105 | return ''.join(packed) |
| 106 | |
| 107 | @staticmethod |
| 108 | def unpack(reader): |
| 109 | subtype, = reader.peek('!L', 4) |
| 110 | subclass = experimenter.subtypes.get(subtype) |
| 111 | if subclass: |
| 112 | return subclass.unpack(reader) |
| 113 | |
| 114 | obj = experimenter() |
| 115 | _type = reader.read("!H")[0] |
| 116 | assert(_type == 65535) |
| 117 | _len = reader.read("!H")[0] |
| 118 | orig_reader = reader |
| 119 | reader = orig_reader.slice(_len, 4) |
| 120 | obj.experimenter = reader.read("!L")[0] |
| 121 | obj.data = str(reader.read_all()) |
| 122 | return obj |
| 123 | |
| 124 | def __eq__(self, other): |
| 125 | if type(self) != type(other): return False |
| 126 | if self.experimenter != other.experimenter: return False |
| 127 | if self.data != other.data: return False |
| 128 | return True |
| 129 | |
| 130 | def pretty_print(self, q): |
| 131 | q.text("experimenter {") |
| 132 | with q.group(): |
| 133 | with q.indent(2): |
| 134 | q.breakable() |
| 135 | q.text("data = "); |
| 136 | q.pp(self.data) |
| 137 | q.breakable() |
| 138 | q.text('}') |
| 139 | |
| 140 | action.subtypes[65535] = experimenter |
| 141 | |
| 142 | class bsn(experimenter): |
| 143 | subtypes = {} |
| 144 | |
| 145 | type = 65535 |
| 146 | experimenter = 6035143 |
| 147 | |
| 148 | def __init__(self, subtype=None): |
| 149 | if subtype != None: |
| 150 | self.subtype = subtype |
| 151 | else: |
| 152 | self.subtype = 0 |
| 153 | return |
| 154 | |
| 155 | def pack(self): |
| 156 | packed = [] |
| 157 | packed.append(struct.pack("!H", self.type)) |
| 158 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 159 | packed.append(struct.pack("!L", self.experimenter)) |
| 160 | packed.append(struct.pack("!L", self.subtype)) |
| 161 | packed.append('\x00' * 4) |
| 162 | length = sum([len(x) for x in packed]) |
| 163 | packed[1] = struct.pack("!H", length) |
| 164 | return ''.join(packed) |
| 165 | |
| 166 | @staticmethod |
| 167 | def unpack(reader): |
| 168 | subtype, = reader.peek('!L', 8) |
| 169 | subclass = bsn.subtypes.get(subtype) |
| 170 | if subclass: |
| 171 | return subclass.unpack(reader) |
| 172 | |
| 173 | obj = bsn() |
| 174 | _type = reader.read("!H")[0] |
| 175 | assert(_type == 65535) |
| 176 | _len = reader.read("!H")[0] |
| 177 | orig_reader = reader |
| 178 | reader = orig_reader.slice(_len, 4) |
| 179 | _experimenter = reader.read("!L")[0] |
| 180 | assert(_experimenter == 6035143) |
| 181 | obj.subtype = reader.read("!L")[0] |
| 182 | reader.skip(4) |
| 183 | return obj |
| 184 | |
| 185 | def __eq__(self, other): |
| 186 | if type(self) != type(other): return False |
| 187 | if self.subtype != other.subtype: return False |
| 188 | return True |
| 189 | |
| 190 | def pretty_print(self, q): |
| 191 | q.text("bsn {") |
| 192 | with q.group(): |
| 193 | with q.indent(2): |
| 194 | q.breakable() |
| 195 | q.breakable() |
| 196 | q.text('}') |
| 197 | |
| 198 | experimenter.subtypes[6035143] = bsn |
| 199 | |
| 200 | class bsn_checksum(bsn): |
| 201 | type = 65535 |
| 202 | experimenter = 6035143 |
| 203 | subtype = 4 |
| 204 | |
| 205 | def __init__(self, checksum=None): |
| 206 | if checksum != None: |
| 207 | self.checksum = checksum |
| 208 | else: |
| 209 | self.checksum = 0 |
| 210 | return |
| 211 | |
| 212 | def pack(self): |
| 213 | packed = [] |
| 214 | packed.append(struct.pack("!H", self.type)) |
| 215 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 216 | packed.append(struct.pack("!L", self.experimenter)) |
| 217 | packed.append(struct.pack("!L", self.subtype)) |
| 218 | packed.append(util.pack_checksum_128(self.checksum)) |
| 219 | length = sum([len(x) for x in packed]) |
| 220 | packed[1] = struct.pack("!H", length) |
| 221 | return ''.join(packed) |
| 222 | |
| 223 | @staticmethod |
| 224 | def unpack(reader): |
| 225 | obj = bsn_checksum() |
| 226 | _type = reader.read("!H")[0] |
| 227 | assert(_type == 65535) |
| 228 | _len = reader.read("!H")[0] |
| 229 | orig_reader = reader |
| 230 | reader = orig_reader.slice(_len, 4) |
| 231 | _experimenter = reader.read("!L")[0] |
| 232 | assert(_experimenter == 6035143) |
| 233 | _subtype = reader.read("!L")[0] |
| 234 | assert(_subtype == 4) |
| 235 | obj.checksum = util.unpack_checksum_128(reader) |
| 236 | return obj |
| 237 | |
| 238 | def __eq__(self, other): |
| 239 | if type(self) != type(other): return False |
| 240 | if self.checksum != other.checksum: return False |
| 241 | return True |
| 242 | |
| 243 | def pretty_print(self, q): |
| 244 | q.text("bsn_checksum {") |
| 245 | with q.group(): |
| 246 | with q.indent(2): |
| 247 | q.breakable() |
| 248 | q.text("checksum = "); |
| 249 | q.pp(self.checksum) |
| 250 | q.breakable() |
| 251 | q.text('}') |
| 252 | |
| 253 | bsn.subtypes[4] = bsn_checksum |
| 254 | |
| 255 | class bsn_gentable(bsn): |
| 256 | type = 65535 |
| 257 | experimenter = 6035143 |
| 258 | subtype = 5 |
| 259 | |
| 260 | def __init__(self, table_id=None, key=None): |
| 261 | if table_id != None: |
| 262 | self.table_id = table_id |
| 263 | else: |
| 264 | self.table_id = 0 |
| 265 | if key != None: |
| 266 | self.key = key |
| 267 | else: |
| 268 | self.key = [] |
| 269 | return |
| 270 | |
| 271 | def pack(self): |
| 272 | packed = [] |
| 273 | packed.append(struct.pack("!H", self.type)) |
| 274 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 275 | packed.append(struct.pack("!L", self.experimenter)) |
| 276 | packed.append(struct.pack("!L", self.subtype)) |
| 277 | packed.append(struct.pack("!L", self.table_id)) |
| 278 | packed.append(loxi.generic_util.pack_list(self.key)) |
| 279 | length = sum([len(x) for x in packed]) |
| 280 | packed[1] = struct.pack("!H", length) |
| 281 | return ''.join(packed) |
| 282 | |
| 283 | @staticmethod |
| 284 | def unpack(reader): |
| 285 | obj = bsn_gentable() |
| 286 | _type = reader.read("!H")[0] |
| 287 | assert(_type == 65535) |
| 288 | _len = reader.read("!H")[0] |
| 289 | orig_reader = reader |
| 290 | reader = orig_reader.slice(_len, 4) |
| 291 | _experimenter = reader.read("!L")[0] |
| 292 | assert(_experimenter == 6035143) |
| 293 | _subtype = reader.read("!L")[0] |
| 294 | assert(_subtype == 5) |
| 295 | obj.table_id = reader.read("!L")[0] |
| 296 | obj.key = loxi.generic_util.unpack_list(reader, ofp.bsn_tlv.bsn_tlv.unpack) |
| 297 | return obj |
| 298 | |
| 299 | def __eq__(self, other): |
| 300 | if type(self) != type(other): return False |
| 301 | if self.table_id != other.table_id: return False |
| 302 | if self.key != other.key: return False |
| 303 | return True |
| 304 | |
| 305 | def pretty_print(self, q): |
| 306 | q.text("bsn_gentable {") |
| 307 | with q.group(): |
| 308 | with q.indent(2): |
| 309 | q.breakable() |
| 310 | q.text("table_id = "); |
| 311 | q.text("%#x" % self.table_id) |
| 312 | q.text(","); q.breakable() |
| 313 | q.text("key = "); |
| 314 | q.pp(self.key) |
| 315 | q.breakable() |
| 316 | q.text('}') |
| 317 | |
| 318 | bsn.subtypes[5] = bsn_gentable |
| 319 | |
| 320 | class bsn_mirror(bsn): |
| 321 | type = 65535 |
| 322 | experimenter = 6035143 |
| 323 | subtype = 1 |
| 324 | |
| 325 | def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None): |
| 326 | if dest_port != None: |
| 327 | self.dest_port = dest_port |
| 328 | else: |
| 329 | self.dest_port = 0 |
| 330 | if vlan_tag != None: |
| 331 | self.vlan_tag = vlan_tag |
| 332 | else: |
| 333 | self.vlan_tag = 0 |
| 334 | if copy_stage != None: |
| 335 | self.copy_stage = copy_stage |
| 336 | else: |
| 337 | self.copy_stage = 0 |
| 338 | return |
| 339 | |
| 340 | def pack(self): |
| 341 | packed = [] |
| 342 | packed.append(struct.pack("!H", self.type)) |
| 343 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 344 | packed.append(struct.pack("!L", self.experimenter)) |
| 345 | packed.append(struct.pack("!L", self.subtype)) |
| 346 | packed.append(struct.pack("!L", self.dest_port)) |
| 347 | packed.append(struct.pack("!L", self.vlan_tag)) |
| 348 | packed.append(struct.pack("!B", self.copy_stage)) |
| 349 | packed.append('\x00' * 3) |
| 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_mirror() |
| 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, 4) |
| 362 | _experimenter = reader.read("!L")[0] |
| 363 | assert(_experimenter == 6035143) |
| 364 | _subtype = reader.read("!L")[0] |
| 365 | assert(_subtype == 1) |
| 366 | obj.dest_port = reader.read("!L")[0] |
| 367 | obj.vlan_tag = reader.read("!L")[0] |
| 368 | obj.copy_stage = reader.read("!B")[0] |
| 369 | reader.skip(3) |
| 370 | return obj |
| 371 | |
| 372 | def __eq__(self, other): |
| 373 | if type(self) != type(other): return False |
| 374 | if self.dest_port != other.dest_port: return False |
| 375 | if self.vlan_tag != other.vlan_tag: return False |
| 376 | if self.copy_stage != other.copy_stage: return False |
| 377 | return True |
| 378 | |
| 379 | def pretty_print(self, q): |
| 380 | q.text("bsn_mirror {") |
| 381 | with q.group(): |
| 382 | with q.indent(2): |
| 383 | q.breakable() |
| 384 | q.text("dest_port = "); |
| 385 | q.text("%#x" % self.dest_port) |
| 386 | q.text(","); q.breakable() |
| 387 | q.text("vlan_tag = "); |
| 388 | q.text("%#x" % self.vlan_tag) |
| 389 | q.text(","); q.breakable() |
| 390 | q.text("copy_stage = "); |
| 391 | q.text("%#x" % self.copy_stage) |
| 392 | q.breakable() |
| 393 | q.text('}') |
| 394 | |
| 395 | bsn.subtypes[1] = bsn_mirror |
| 396 | |
| 397 | class bsn_set_tunnel_dst(bsn): |
| 398 | type = 65535 |
| 399 | experimenter = 6035143 |
| 400 | subtype = 2 |
| 401 | |
| 402 | def __init__(self, dst=None): |
| 403 | if dst != None: |
| 404 | self.dst = dst |
| 405 | else: |
| 406 | self.dst = 0 |
| 407 | return |
| 408 | |
| 409 | def pack(self): |
| 410 | packed = [] |
| 411 | packed.append(struct.pack("!H", self.type)) |
| 412 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 413 | packed.append(struct.pack("!L", self.experimenter)) |
| 414 | packed.append(struct.pack("!L", self.subtype)) |
| 415 | packed.append(struct.pack("!L", self.dst)) |
| 416 | length = sum([len(x) for x in packed]) |
| 417 | packed[1] = struct.pack("!H", length) |
| 418 | return ''.join(packed) |
| 419 | |
| 420 | @staticmethod |
| 421 | def unpack(reader): |
| 422 | obj = bsn_set_tunnel_dst() |
| 423 | _type = reader.read("!H")[0] |
| 424 | assert(_type == 65535) |
| 425 | _len = reader.read("!H")[0] |
| 426 | orig_reader = reader |
| 427 | reader = orig_reader.slice(_len, 4) |
| 428 | _experimenter = reader.read("!L")[0] |
| 429 | assert(_experimenter == 6035143) |
| 430 | _subtype = reader.read("!L")[0] |
| 431 | assert(_subtype == 2) |
| 432 | obj.dst = reader.read("!L")[0] |
| 433 | return obj |
| 434 | |
| 435 | def __eq__(self, other): |
| 436 | if type(self) != type(other): return False |
| 437 | if self.dst != other.dst: return False |
| 438 | return True |
| 439 | |
| 440 | def pretty_print(self, q): |
| 441 | q.text("bsn_set_tunnel_dst {") |
| 442 | with q.group(): |
| 443 | with q.indent(2): |
| 444 | q.breakable() |
| 445 | q.text("dst = "); |
| 446 | q.text("%#x" % self.dst) |
| 447 | q.breakable() |
| 448 | q.text('}') |
| 449 | |
| 450 | bsn.subtypes[2] = bsn_set_tunnel_dst |
| 451 | |
| 452 | class copy_ttl_in(action): |
| 453 | type = 12 |
| 454 | |
| 455 | def __init__(self): |
| 456 | return |
| 457 | |
| 458 | def pack(self): |
| 459 | packed = [] |
| 460 | packed.append(struct.pack("!H", self.type)) |
| 461 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 462 | packed.append('\x00' * 4) |
| 463 | length = sum([len(x) for x in packed]) |
| 464 | packed[1] = struct.pack("!H", length) |
| 465 | return ''.join(packed) |
| 466 | |
| 467 | @staticmethod |
| 468 | def unpack(reader): |
| 469 | obj = copy_ttl_in() |
| 470 | _type = reader.read("!H")[0] |
| 471 | assert(_type == 12) |
| 472 | _len = reader.read("!H")[0] |
| 473 | orig_reader = reader |
| 474 | reader = orig_reader.slice(_len, 4) |
| 475 | reader.skip(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("copy_ttl_in {") |
| 484 | with q.group(): |
| 485 | with q.indent(2): |
| 486 | q.breakable() |
| 487 | q.breakable() |
| 488 | q.text('}') |
| 489 | |
| 490 | action.subtypes[12] = copy_ttl_in |
| 491 | |
| 492 | class copy_ttl_out(action): |
| 493 | type = 11 |
| 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 |
| 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 = copy_ttl_out() |
| 510 | _type = reader.read("!H")[0] |
| 511 | assert(_type == 11) |
| 512 | _len = reader.read("!H")[0] |
| 513 | orig_reader = reader |
| 514 | reader = orig_reader.slice(_len, 4) |
| 515 | reader.skip(4) |
| 516 | return obj |
| 517 | |
| 518 | def __eq__(self, other): |
| 519 | if type(self) != type(other): return False |
| 520 | return True |
| 521 | |
| 522 | def pretty_print(self, q): |
| 523 | q.text("copy_ttl_out {") |
| 524 | with q.group(): |
| 525 | with q.indent(2): |
| 526 | q.breakable() |
| 527 | q.breakable() |
| 528 | q.text('}') |
| 529 | |
| 530 | action.subtypes[11] = copy_ttl_out |
| 531 | |
| 532 | class dec_mpls_ttl(action): |
| 533 | type = 16 |
| 534 | |
| 535 | def __init__(self): |
| 536 | return |
| 537 | |
| 538 | def pack(self): |
| 539 | packed = [] |
| 540 | packed.append(struct.pack("!H", self.type)) |
| 541 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 542 | packed.append('\x00' * 4) |
| 543 | length = sum([len(x) for x in packed]) |
| 544 | packed[1] = struct.pack("!H", length) |
| 545 | return ''.join(packed) |
| 546 | |
| 547 | @staticmethod |
| 548 | def unpack(reader): |
| 549 | obj = dec_mpls_ttl() |
| 550 | _type = reader.read("!H")[0] |
| 551 | assert(_type == 16) |
| 552 | _len = reader.read("!H")[0] |
| 553 | orig_reader = reader |
| 554 | reader = orig_reader.slice(_len, 4) |
| 555 | reader.skip(4) |
| 556 | return obj |
| 557 | |
| 558 | def __eq__(self, other): |
| 559 | if type(self) != type(other): return False |
| 560 | return True |
| 561 | |
| 562 | def pretty_print(self, q): |
| 563 | q.text("dec_mpls_ttl {") |
| 564 | with q.group(): |
| 565 | with q.indent(2): |
| 566 | q.breakable() |
| 567 | q.breakable() |
| 568 | q.text('}') |
| 569 | |
| 570 | action.subtypes[16] = dec_mpls_ttl |
| 571 | |
| 572 | class dec_nw_ttl(action): |
| 573 | type = 24 |
| 574 | |
| 575 | def __init__(self): |
| 576 | return |
| 577 | |
| 578 | def pack(self): |
| 579 | packed = [] |
| 580 | packed.append(struct.pack("!H", self.type)) |
| 581 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 582 | packed.append('\x00' * 4) |
| 583 | length = sum([len(x) for x in packed]) |
| 584 | packed[1] = struct.pack("!H", length) |
| 585 | return ''.join(packed) |
| 586 | |
| 587 | @staticmethod |
| 588 | def unpack(reader): |
| 589 | obj = dec_nw_ttl() |
| 590 | _type = reader.read("!H")[0] |
| 591 | assert(_type == 24) |
| 592 | _len = reader.read("!H")[0] |
| 593 | orig_reader = reader |
| 594 | reader = orig_reader.slice(_len, 4) |
| 595 | reader.skip(4) |
| 596 | return obj |
| 597 | |
| 598 | def __eq__(self, other): |
| 599 | if type(self) != type(other): return False |
| 600 | return True |
| 601 | |
| 602 | def pretty_print(self, q): |
| 603 | q.text("dec_nw_ttl {") |
| 604 | with q.group(): |
| 605 | with q.indent(2): |
| 606 | q.breakable() |
| 607 | q.breakable() |
| 608 | q.text('}') |
| 609 | |
| 610 | action.subtypes[24] = dec_nw_ttl |
| 611 | |
| 612 | class group(action): |
| 613 | type = 22 |
| 614 | |
| 615 | def __init__(self, group_id=None): |
| 616 | if group_id != None: |
| 617 | self.group_id = group_id |
| 618 | else: |
| 619 | self.group_id = 0 |
| 620 | return |
| 621 | |
| 622 | def pack(self): |
| 623 | packed = [] |
| 624 | packed.append(struct.pack("!H", self.type)) |
| 625 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 626 | packed.append(struct.pack("!L", self.group_id)) |
| 627 | length = sum([len(x) for x in packed]) |
| 628 | packed[1] = struct.pack("!H", length) |
| 629 | return ''.join(packed) |
| 630 | |
| 631 | @staticmethod |
| 632 | def unpack(reader): |
| 633 | obj = group() |
| 634 | _type = reader.read("!H")[0] |
| 635 | assert(_type == 22) |
| 636 | _len = reader.read("!H")[0] |
| 637 | orig_reader = reader |
| 638 | reader = orig_reader.slice(_len, 4) |
| 639 | obj.group_id = reader.read("!L")[0] |
| 640 | return obj |
| 641 | |
| 642 | def __eq__(self, other): |
| 643 | if type(self) != type(other): return False |
| 644 | if self.group_id != other.group_id: return False |
| 645 | return True |
| 646 | |
| 647 | def pretty_print(self, q): |
| 648 | q.text("group {") |
| 649 | with q.group(): |
| 650 | with q.indent(2): |
| 651 | q.breakable() |
| 652 | q.text("group_id = "); |
| 653 | q.text("%#x" % self.group_id) |
| 654 | q.breakable() |
| 655 | q.text('}') |
| 656 | |
| 657 | action.subtypes[22] = group |
| 658 | |
| 659 | class nicira(experimenter): |
| 660 | subtypes = {} |
| 661 | |
| 662 | type = 65535 |
| 663 | experimenter = 8992 |
| 664 | |
| 665 | def __init__(self, subtype=None): |
| 666 | if subtype != None: |
| 667 | self.subtype = subtype |
| 668 | else: |
| 669 | self.subtype = 0 |
| 670 | return |
| 671 | |
| 672 | def pack(self): |
| 673 | packed = [] |
| 674 | packed.append(struct.pack("!H", self.type)) |
| 675 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 676 | packed.append(struct.pack("!L", self.experimenter)) |
| 677 | packed.append(struct.pack("!H", self.subtype)) |
| 678 | packed.append('\x00' * 2) |
| 679 | packed.append('\x00' * 4) |
| 680 | length = sum([len(x) for x in packed]) |
| 681 | packed[1] = struct.pack("!H", length) |
| 682 | return ''.join(packed) |
| 683 | |
| 684 | @staticmethod |
| 685 | def unpack(reader): |
| 686 | subtype, = reader.peek('!H', 8) |
| 687 | subclass = nicira.subtypes.get(subtype) |
| 688 | if subclass: |
| 689 | return subclass.unpack(reader) |
| 690 | |
| 691 | obj = nicira() |
| 692 | _type = reader.read("!H")[0] |
| 693 | assert(_type == 65535) |
| 694 | _len = reader.read("!H")[0] |
| 695 | orig_reader = reader |
| 696 | reader = orig_reader.slice(_len, 4) |
| 697 | _experimenter = reader.read("!L")[0] |
| 698 | assert(_experimenter == 8992) |
| 699 | obj.subtype = reader.read("!H")[0] |
| 700 | reader.skip(2) |
| 701 | reader.skip(4) |
| 702 | return obj |
| 703 | |
| 704 | def __eq__(self, other): |
| 705 | if type(self) != type(other): return False |
| 706 | if self.subtype != other.subtype: return False |
| 707 | return True |
| 708 | |
| 709 | def pretty_print(self, q): |
| 710 | q.text("nicira {") |
| 711 | with q.group(): |
| 712 | with q.indent(2): |
| 713 | q.breakable() |
| 714 | q.breakable() |
| 715 | q.text('}') |
| 716 | |
| 717 | experimenter.subtypes[8992] = nicira |
| 718 | |
| 719 | class nicira_dec_ttl(nicira): |
| 720 | type = 65535 |
| 721 | experimenter = 8992 |
| 722 | subtype = 18 |
| 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("!H", self.subtype)) |
| 733 | packed.append('\x00' * 2) |
| 734 | packed.append('\x00' * 4) |
| 735 | length = sum([len(x) for x in packed]) |
| 736 | packed[1] = struct.pack("!H", length) |
| 737 | return ''.join(packed) |
| 738 | |
| 739 | @staticmethod |
| 740 | def unpack(reader): |
| 741 | obj = nicira_dec_ttl() |
| 742 | _type = reader.read("!H")[0] |
| 743 | assert(_type == 65535) |
| 744 | _len = reader.read("!H")[0] |
| 745 | orig_reader = reader |
| 746 | reader = orig_reader.slice(_len, 4) |
| 747 | _experimenter = reader.read("!L")[0] |
| 748 | assert(_experimenter == 8992) |
| 749 | _subtype = reader.read("!H")[0] |
| 750 | assert(_subtype == 18) |
| 751 | reader.skip(2) |
| 752 | reader.skip(4) |
| 753 | return obj |
| 754 | |
| 755 | def __eq__(self, other): |
| 756 | if type(self) != type(other): return False |
| 757 | return True |
| 758 | |
| 759 | def pretty_print(self, q): |
| 760 | q.text("nicira_dec_ttl {") |
| 761 | with q.group(): |
| 762 | with q.indent(2): |
| 763 | q.breakable() |
| 764 | q.breakable() |
| 765 | q.text('}') |
| 766 | |
| 767 | nicira.subtypes[18] = nicira_dec_ttl |
| 768 | |
| 769 | class output(action): |
| 770 | type = 0 |
| 771 | |
| 772 | def __init__(self, port=None, max_len=None): |
| 773 | if port != None: |
| 774 | self.port = port |
| 775 | else: |
| 776 | self.port = 0 |
| 777 | if max_len != None: |
| 778 | self.max_len = max_len |
| 779 | else: |
| 780 | self.max_len = 0 |
| 781 | return |
| 782 | |
| 783 | def pack(self): |
| 784 | packed = [] |
| 785 | packed.append(struct.pack("!H", self.type)) |
| 786 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 787 | packed.append(util.pack_port_no(self.port)) |
| 788 | packed.append(struct.pack("!H", self.max_len)) |
| 789 | packed.append('\x00' * 6) |
| 790 | length = sum([len(x) for x in packed]) |
| 791 | packed[1] = struct.pack("!H", length) |
| 792 | return ''.join(packed) |
| 793 | |
| 794 | @staticmethod |
| 795 | def unpack(reader): |
| 796 | obj = output() |
| 797 | _type = reader.read("!H")[0] |
| 798 | assert(_type == 0) |
| 799 | _len = reader.read("!H")[0] |
| 800 | orig_reader = reader |
| 801 | reader = orig_reader.slice(_len, 4) |
| 802 | obj.port = util.unpack_port_no(reader) |
| 803 | obj.max_len = reader.read("!H")[0] |
| 804 | reader.skip(6) |
| 805 | return obj |
| 806 | |
| 807 | def __eq__(self, other): |
| 808 | if type(self) != type(other): return False |
| 809 | if self.port != other.port: return False |
| 810 | if self.max_len != other.max_len: return False |
| 811 | return True |
| 812 | |
| 813 | def pretty_print(self, q): |
| 814 | q.text("output {") |
| 815 | with q.group(): |
| 816 | with q.indent(2): |
| 817 | q.breakable() |
| 818 | q.text("port = "); |
| 819 | q.text(util.pretty_port(self.port)) |
| 820 | q.text(","); q.breakable() |
| 821 | q.text("max_len = "); |
| 822 | q.text("%#x" % self.max_len) |
| 823 | q.breakable() |
| 824 | q.text('}') |
| 825 | |
| 826 | action.subtypes[0] = output |
| 827 | |
| 828 | class pop_mpls(action): |
| 829 | type = 20 |
| 830 | |
| 831 | def __init__(self, ethertype=None): |
| 832 | if ethertype != None: |
| 833 | self.ethertype = ethertype |
| 834 | else: |
| 835 | self.ethertype = 0 |
| 836 | return |
| 837 | |
| 838 | def pack(self): |
| 839 | packed = [] |
| 840 | packed.append(struct.pack("!H", self.type)) |
| 841 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 842 | packed.append(struct.pack("!H", self.ethertype)) |
| 843 | packed.append('\x00' * 2) |
| 844 | length = sum([len(x) for x in packed]) |
| 845 | packed[1] = struct.pack("!H", length) |
| 846 | return ''.join(packed) |
| 847 | |
| 848 | @staticmethod |
| 849 | def unpack(reader): |
| 850 | obj = pop_mpls() |
| 851 | _type = reader.read("!H")[0] |
| 852 | assert(_type == 20) |
| 853 | _len = reader.read("!H")[0] |
| 854 | orig_reader = reader |
| 855 | reader = orig_reader.slice(_len, 4) |
| 856 | obj.ethertype = reader.read("!H")[0] |
| 857 | reader.skip(2) |
| 858 | return obj |
| 859 | |
| 860 | def __eq__(self, other): |
| 861 | if type(self) != type(other): return False |
| 862 | if self.ethertype != other.ethertype: return False |
| 863 | return True |
| 864 | |
| 865 | def pretty_print(self, q): |
| 866 | q.text("pop_mpls {") |
| 867 | with q.group(): |
| 868 | with q.indent(2): |
| 869 | q.breakable() |
| 870 | q.text("ethertype = "); |
| 871 | q.text("%#x" % self.ethertype) |
| 872 | q.breakable() |
| 873 | q.text('}') |
| 874 | |
| 875 | action.subtypes[20] = pop_mpls |
| 876 | |
| 877 | class pop_pbb(action): |
| 878 | type = 27 |
| 879 | |
| 880 | def __init__(self): |
| 881 | return |
| 882 | |
| 883 | def pack(self): |
| 884 | packed = [] |
| 885 | packed.append(struct.pack("!H", self.type)) |
| 886 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 887 | packed.append('\x00' * 4) |
| 888 | length = sum([len(x) for x in packed]) |
| 889 | packed[1] = struct.pack("!H", length) |
| 890 | return ''.join(packed) |
| 891 | |
| 892 | @staticmethod |
| 893 | def unpack(reader): |
| 894 | obj = pop_pbb() |
| 895 | _type = reader.read("!H")[0] |
| 896 | assert(_type == 27) |
| 897 | _len = reader.read("!H")[0] |
| 898 | orig_reader = reader |
| 899 | reader = orig_reader.slice(_len, 4) |
| 900 | reader.skip(4) |
| 901 | return obj |
| 902 | |
| 903 | def __eq__(self, other): |
| 904 | if type(self) != type(other): return False |
| 905 | return True |
| 906 | |
| 907 | def pretty_print(self, q): |
| 908 | q.text("pop_pbb {") |
| 909 | with q.group(): |
| 910 | with q.indent(2): |
| 911 | q.breakable() |
| 912 | q.breakable() |
| 913 | q.text('}') |
| 914 | |
| 915 | action.subtypes[27] = pop_pbb |
| 916 | |
| 917 | class pop_vlan(action): |
| 918 | type = 18 |
| 919 | |
| 920 | def __init__(self): |
| 921 | return |
| 922 | |
| 923 | def pack(self): |
| 924 | packed = [] |
| 925 | packed.append(struct.pack("!H", self.type)) |
| 926 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 927 | packed.append('\x00' * 4) |
| 928 | length = sum([len(x) for x in packed]) |
| 929 | packed[1] = struct.pack("!H", length) |
| 930 | return ''.join(packed) |
| 931 | |
| 932 | @staticmethod |
| 933 | def unpack(reader): |
| 934 | obj = pop_vlan() |
| 935 | _type = reader.read("!H")[0] |
| 936 | assert(_type == 18) |
| 937 | _len = reader.read("!H")[0] |
| 938 | orig_reader = reader |
| 939 | reader = orig_reader.slice(_len, 4) |
| 940 | reader.skip(4) |
| 941 | return obj |
| 942 | |
| 943 | def __eq__(self, other): |
| 944 | if type(self) != type(other): return False |
| 945 | return True |
| 946 | |
| 947 | def pretty_print(self, q): |
| 948 | q.text("pop_vlan {") |
| 949 | with q.group(): |
| 950 | with q.indent(2): |
| 951 | q.breakable() |
| 952 | q.breakable() |
| 953 | q.text('}') |
| 954 | |
| 955 | action.subtypes[18] = pop_vlan |
| 956 | |
| 957 | class push_mpls(action): |
| 958 | type = 19 |
| 959 | |
| 960 | def __init__(self, ethertype=None): |
| 961 | if ethertype != None: |
| 962 | self.ethertype = ethertype |
| 963 | else: |
| 964 | self.ethertype = 0 |
| 965 | return |
| 966 | |
| 967 | def pack(self): |
| 968 | packed = [] |
| 969 | packed.append(struct.pack("!H", self.type)) |
| 970 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 971 | packed.append(struct.pack("!H", self.ethertype)) |
| 972 | packed.append('\x00' * 2) |
| 973 | length = sum([len(x) for x in packed]) |
| 974 | packed[1] = struct.pack("!H", length) |
| 975 | return ''.join(packed) |
| 976 | |
| 977 | @staticmethod |
| 978 | def unpack(reader): |
| 979 | obj = push_mpls() |
| 980 | _type = reader.read("!H")[0] |
| 981 | assert(_type == 19) |
| 982 | _len = reader.read("!H")[0] |
| 983 | orig_reader = reader |
| 984 | reader = orig_reader.slice(_len, 4) |
| 985 | obj.ethertype = reader.read("!H")[0] |
| 986 | reader.skip(2) |
| 987 | return obj |
| 988 | |
| 989 | def __eq__(self, other): |
| 990 | if type(self) != type(other): return False |
| 991 | if self.ethertype != other.ethertype: return False |
| 992 | return True |
| 993 | |
| 994 | def pretty_print(self, q): |
| 995 | q.text("push_mpls {") |
| 996 | with q.group(): |
| 997 | with q.indent(2): |
| 998 | q.breakable() |
| 999 | q.text("ethertype = "); |
| 1000 | q.text("%#x" % self.ethertype) |
| 1001 | q.breakable() |
| 1002 | q.text('}') |
| 1003 | |
| 1004 | action.subtypes[19] = push_mpls |
| 1005 | |
| 1006 | class push_pbb(action): |
| 1007 | type = 26 |
| 1008 | |
| 1009 | def __init__(self, ethertype=None): |
| 1010 | if ethertype != None: |
| 1011 | self.ethertype = ethertype |
| 1012 | else: |
| 1013 | self.ethertype = 0 |
| 1014 | return |
| 1015 | |
| 1016 | def pack(self): |
| 1017 | packed = [] |
| 1018 | packed.append(struct.pack("!H", self.type)) |
| 1019 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1020 | packed.append(struct.pack("!H", self.ethertype)) |
| 1021 | packed.append('\x00' * 2) |
| 1022 | length = sum([len(x) for x in packed]) |
| 1023 | packed[1] = struct.pack("!H", length) |
| 1024 | return ''.join(packed) |
| 1025 | |
| 1026 | @staticmethod |
| 1027 | def unpack(reader): |
| 1028 | obj = push_pbb() |
| 1029 | _type = reader.read("!H")[0] |
| 1030 | assert(_type == 26) |
| 1031 | _len = reader.read("!H")[0] |
| 1032 | orig_reader = reader |
| 1033 | reader = orig_reader.slice(_len, 4) |
| 1034 | obj.ethertype = reader.read("!H")[0] |
| 1035 | reader.skip(2) |
| 1036 | return obj |
| 1037 | |
| 1038 | def __eq__(self, other): |
| 1039 | if type(self) != type(other): return False |
| 1040 | if self.ethertype != other.ethertype: return False |
| 1041 | return True |
| 1042 | |
| 1043 | def pretty_print(self, q): |
| 1044 | q.text("push_pbb {") |
| 1045 | with q.group(): |
| 1046 | with q.indent(2): |
| 1047 | q.breakable() |
| 1048 | q.text("ethertype = "); |
| 1049 | q.text("%#x" % self.ethertype) |
| 1050 | q.breakable() |
| 1051 | q.text('}') |
| 1052 | |
| 1053 | action.subtypes[26] = push_pbb |
| 1054 | |
| 1055 | class push_vlan(action): |
| 1056 | type = 17 |
| 1057 | |
| 1058 | def __init__(self, ethertype=None): |
| 1059 | if ethertype != None: |
| 1060 | self.ethertype = ethertype |
| 1061 | else: |
| 1062 | self.ethertype = 0 |
| 1063 | return |
| 1064 | |
| 1065 | def pack(self): |
| 1066 | packed = [] |
| 1067 | packed.append(struct.pack("!H", self.type)) |
| 1068 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1069 | packed.append(struct.pack("!H", self.ethertype)) |
| 1070 | packed.append('\x00' * 2) |
| 1071 | length = sum([len(x) for x in packed]) |
| 1072 | packed[1] = struct.pack("!H", length) |
| 1073 | return ''.join(packed) |
| 1074 | |
| 1075 | @staticmethod |
| 1076 | def unpack(reader): |
| 1077 | obj = push_vlan() |
| 1078 | _type = reader.read("!H")[0] |
| 1079 | assert(_type == 17) |
| 1080 | _len = reader.read("!H")[0] |
| 1081 | orig_reader = reader |
| 1082 | reader = orig_reader.slice(_len, 4) |
| 1083 | obj.ethertype = reader.read("!H")[0] |
| 1084 | reader.skip(2) |
| 1085 | return obj |
| 1086 | |
| 1087 | def __eq__(self, other): |
| 1088 | if type(self) != type(other): return False |
| 1089 | if self.ethertype != other.ethertype: return False |
| 1090 | return True |
| 1091 | |
| 1092 | def pretty_print(self, q): |
| 1093 | q.text("push_vlan {") |
| 1094 | with q.group(): |
| 1095 | with q.indent(2): |
| 1096 | q.breakable() |
| 1097 | q.text("ethertype = "); |
| 1098 | q.text("%#x" % self.ethertype) |
| 1099 | q.breakable() |
| 1100 | q.text('}') |
| 1101 | |
| 1102 | action.subtypes[17] = push_vlan |
| 1103 | |
| 1104 | class set_field(action): |
| 1105 | type = 25 |
| 1106 | |
| 1107 | def __init__(self, field=None): |
| 1108 | if field != None: |
| 1109 | self.field = field |
| 1110 | else: |
| 1111 | self.field = None |
| 1112 | return |
| 1113 | |
| 1114 | def pack(self): |
| 1115 | packed = [] |
| 1116 | packed.append(struct.pack("!H", self.type)) |
| 1117 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1118 | packed.append(self.field.pack()) |
| 1119 | length = sum([len(x) for x in packed]) |
| 1120 | packed.append(loxi.generic_util.pad_to(8, length)) |
| 1121 | length += len(packed[-1]) |
| 1122 | packed[1] = struct.pack("!H", length) |
| 1123 | return ''.join(packed) |
| 1124 | |
| 1125 | @staticmethod |
| 1126 | def unpack(reader): |
| 1127 | obj = set_field() |
| 1128 | _type = reader.read("!H")[0] |
| 1129 | assert(_type == 25) |
| 1130 | _len = reader.read("!H")[0] |
| 1131 | orig_reader = reader |
| 1132 | reader = orig_reader.slice(_len, 4) |
| 1133 | obj.field = ofp.oxm.oxm.unpack(reader) |
| 1134 | return obj |
| 1135 | |
| 1136 | def __eq__(self, other): |
| 1137 | if type(self) != type(other): return False |
| 1138 | if self.field != other.field: return False |
| 1139 | return True |
| 1140 | |
| 1141 | def pretty_print(self, q): |
| 1142 | q.text("set_field {") |
| 1143 | with q.group(): |
| 1144 | with q.indent(2): |
| 1145 | q.breakable() |
| 1146 | q.text("field = "); |
| 1147 | q.pp(self.field) |
| 1148 | q.breakable() |
| 1149 | q.text('}') |
| 1150 | |
| 1151 | action.subtypes[25] = set_field |
| 1152 | |
| 1153 | class set_mpls_ttl(action): |
| 1154 | type = 15 |
| 1155 | |
| 1156 | def __init__(self, mpls_ttl=None): |
| 1157 | if mpls_ttl != None: |
| 1158 | self.mpls_ttl = mpls_ttl |
| 1159 | else: |
| 1160 | self.mpls_ttl = 0 |
| 1161 | return |
| 1162 | |
| 1163 | def pack(self): |
| 1164 | packed = [] |
| 1165 | packed.append(struct.pack("!H", self.type)) |
| 1166 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1167 | packed.append(struct.pack("!B", self.mpls_ttl)) |
| 1168 | packed.append('\x00' * 3) |
| 1169 | length = sum([len(x) for x in packed]) |
| 1170 | packed[1] = struct.pack("!H", length) |
| 1171 | return ''.join(packed) |
| 1172 | |
| 1173 | @staticmethod |
| 1174 | def unpack(reader): |
| 1175 | obj = set_mpls_ttl() |
| 1176 | _type = reader.read("!H")[0] |
| 1177 | assert(_type == 15) |
| 1178 | _len = reader.read("!H")[0] |
| 1179 | orig_reader = reader |
| 1180 | reader = orig_reader.slice(_len, 4) |
| 1181 | obj.mpls_ttl = reader.read("!B")[0] |
| 1182 | reader.skip(3) |
| 1183 | return obj |
| 1184 | |
| 1185 | def __eq__(self, other): |
| 1186 | if type(self) != type(other): return False |
| 1187 | if self.mpls_ttl != other.mpls_ttl: return False |
| 1188 | return True |
| 1189 | |
| 1190 | def pretty_print(self, q): |
| 1191 | q.text("set_mpls_ttl {") |
| 1192 | with q.group(): |
| 1193 | with q.indent(2): |
| 1194 | q.breakable() |
| 1195 | q.text("mpls_ttl = "); |
| 1196 | q.text("%#x" % self.mpls_ttl) |
| 1197 | q.breakable() |
| 1198 | q.text('}') |
| 1199 | |
| 1200 | action.subtypes[15] = set_mpls_ttl |
| 1201 | |
| 1202 | class set_nw_ttl(action): |
| 1203 | type = 23 |
| 1204 | |
| 1205 | def __init__(self, nw_ttl=None): |
| 1206 | if nw_ttl != None: |
| 1207 | self.nw_ttl = nw_ttl |
| 1208 | else: |
| 1209 | self.nw_ttl = 0 |
| 1210 | return |
| 1211 | |
| 1212 | def pack(self): |
| 1213 | packed = [] |
| 1214 | packed.append(struct.pack("!H", self.type)) |
| 1215 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1216 | packed.append(struct.pack("!B", self.nw_ttl)) |
| 1217 | packed.append('\x00' * 3) |
| 1218 | length = sum([len(x) for x in packed]) |
| 1219 | packed[1] = struct.pack("!H", length) |
| 1220 | return ''.join(packed) |
| 1221 | |
| 1222 | @staticmethod |
| 1223 | def unpack(reader): |
| 1224 | obj = set_nw_ttl() |
| 1225 | _type = reader.read("!H")[0] |
| 1226 | assert(_type == 23) |
| 1227 | _len = reader.read("!H")[0] |
| 1228 | orig_reader = reader |
| 1229 | reader = orig_reader.slice(_len, 4) |
| 1230 | obj.nw_ttl = reader.read("!B")[0] |
| 1231 | reader.skip(3) |
| 1232 | return obj |
| 1233 | |
| 1234 | def __eq__(self, other): |
| 1235 | if type(self) != type(other): return False |
| 1236 | if self.nw_ttl != other.nw_ttl: return False |
| 1237 | return True |
| 1238 | |
| 1239 | def pretty_print(self, q): |
| 1240 | q.text("set_nw_ttl {") |
| 1241 | with q.group(): |
| 1242 | with q.indent(2): |
| 1243 | q.breakable() |
| 1244 | q.text("nw_ttl = "); |
| 1245 | q.text("%#x" % self.nw_ttl) |
| 1246 | q.breakable() |
| 1247 | q.text('}') |
| 1248 | |
| 1249 | action.subtypes[23] = set_nw_ttl |
| 1250 | |
| 1251 | class set_queue(action): |
| 1252 | type = 21 |
| 1253 | |
| 1254 | def __init__(self, queue_id=None): |
| 1255 | if queue_id != None: |
| 1256 | self.queue_id = queue_id |
| 1257 | else: |
| 1258 | self.queue_id = 0 |
| 1259 | return |
| 1260 | |
| 1261 | def pack(self): |
| 1262 | packed = [] |
| 1263 | packed.append(struct.pack("!H", self.type)) |
| 1264 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1265 | packed.append(struct.pack("!L", self.queue_id)) |
| 1266 | length = sum([len(x) for x in packed]) |
| 1267 | packed[1] = struct.pack("!H", length) |
| 1268 | return ''.join(packed) |
| 1269 | |
| 1270 | @staticmethod |
| 1271 | def unpack(reader): |
| 1272 | obj = set_queue() |
| 1273 | _type = reader.read("!H")[0] |
| 1274 | assert(_type == 21) |
| 1275 | _len = reader.read("!H")[0] |
| 1276 | orig_reader = reader |
| 1277 | reader = orig_reader.slice(_len, 4) |
| 1278 | obj.queue_id = reader.read("!L")[0] |
| 1279 | return obj |
| 1280 | |
| 1281 | def __eq__(self, other): |
| 1282 | if type(self) != type(other): return False |
| 1283 | if self.queue_id != other.queue_id: return False |
| 1284 | return True |
| 1285 | |
| 1286 | def pretty_print(self, q): |
| 1287 | q.text("set_queue {") |
| 1288 | with q.group(): |
| 1289 | with q.indent(2): |
| 1290 | q.breakable() |
| 1291 | q.text("queue_id = "); |
| 1292 | q.text("%#x" % self.queue_id) |
| 1293 | q.breakable() |
| 1294 | q.text('}') |
| 1295 | |
| 1296 | action.subtypes[21] = set_queue |
| 1297 | |
| 1298 | |