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.of10'] |
| 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[1] = struct.pack("!H", length) |
| 103 | return ''.join(packed) |
| 104 | |
| 105 | @staticmethod |
| 106 | def unpack(reader): |
| 107 | subtype, = reader.peek('!L', 4) |
| 108 | subclass = experimenter.subtypes.get(subtype) |
| 109 | if subclass: |
| 110 | return subclass.unpack(reader) |
| 111 | |
| 112 | obj = experimenter() |
| 113 | _type = reader.read("!H")[0] |
| 114 | assert(_type == 65535) |
| 115 | _len = reader.read("!H")[0] |
| 116 | orig_reader = reader |
| 117 | reader = orig_reader.slice(_len, 4) |
| 118 | obj.experimenter = reader.read("!L")[0] |
| 119 | obj.data = str(reader.read_all()) |
| 120 | return obj |
| 121 | |
| 122 | def __eq__(self, other): |
| 123 | if type(self) != type(other): return False |
| 124 | if self.experimenter != other.experimenter: return False |
| 125 | if self.data != other.data: return False |
| 126 | return True |
| 127 | |
| 128 | def pretty_print(self, q): |
| 129 | q.text("experimenter {") |
| 130 | with q.group(): |
| 131 | with q.indent(2): |
| 132 | q.breakable() |
| 133 | q.text("data = "); |
| 134 | q.pp(self.data) |
| 135 | q.breakable() |
| 136 | q.text('}') |
| 137 | |
| 138 | action.subtypes[65535] = experimenter |
| 139 | |
| 140 | class bsn(experimenter): |
| 141 | subtypes = {} |
| 142 | |
| 143 | type = 65535 |
| 144 | experimenter = 6035143 |
| 145 | |
| 146 | def __init__(self, subtype=None): |
| 147 | if subtype != None: |
| 148 | self.subtype = subtype |
| 149 | else: |
| 150 | self.subtype = 0 |
| 151 | return |
| 152 | |
| 153 | def pack(self): |
| 154 | packed = [] |
| 155 | packed.append(struct.pack("!H", self.type)) |
| 156 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 157 | packed.append(struct.pack("!L", self.experimenter)) |
| 158 | packed.append(struct.pack("!L", self.subtype)) |
| 159 | packed.append('\x00' * 4) |
| 160 | length = sum([len(x) for x in packed]) |
| 161 | packed[1] = struct.pack("!H", length) |
| 162 | return ''.join(packed) |
| 163 | |
| 164 | @staticmethod |
| 165 | def unpack(reader): |
| 166 | subtype, = reader.peek('!L', 8) |
| 167 | subclass = bsn.subtypes.get(subtype) |
| 168 | if subclass: |
| 169 | return subclass.unpack(reader) |
| 170 | |
| 171 | obj = bsn() |
| 172 | _type = reader.read("!H")[0] |
| 173 | assert(_type == 65535) |
| 174 | _len = reader.read("!H")[0] |
| 175 | orig_reader = reader |
| 176 | reader = orig_reader.slice(_len, 4) |
| 177 | _experimenter = reader.read("!L")[0] |
| 178 | assert(_experimenter == 6035143) |
| 179 | obj.subtype = reader.read("!L")[0] |
| 180 | reader.skip(4) |
| 181 | return obj |
| 182 | |
| 183 | def __eq__(self, other): |
| 184 | if type(self) != type(other): return False |
| 185 | if self.subtype != other.subtype: return False |
| 186 | return True |
| 187 | |
| 188 | def pretty_print(self, q): |
| 189 | q.text("bsn {") |
| 190 | with q.group(): |
| 191 | with q.indent(2): |
| 192 | q.breakable() |
| 193 | q.breakable() |
| 194 | q.text('}') |
| 195 | |
| 196 | experimenter.subtypes[6035143] = bsn |
| 197 | |
| 198 | class bsn_checksum(bsn): |
| 199 | type = 65535 |
| 200 | experimenter = 6035143 |
| 201 | subtype = 4 |
| 202 | |
| 203 | def __init__(self, checksum=None): |
| 204 | if checksum != None: |
| 205 | self.checksum = checksum |
| 206 | else: |
| 207 | self.checksum = 0 |
| 208 | return |
| 209 | |
| 210 | def pack(self): |
| 211 | packed = [] |
| 212 | packed.append(struct.pack("!H", self.type)) |
| 213 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 214 | packed.append(struct.pack("!L", self.experimenter)) |
| 215 | packed.append(struct.pack("!L", self.subtype)) |
| 216 | packed.append(util.pack_checksum_128(self.checksum)) |
| 217 | length = sum([len(x) for x in packed]) |
| 218 | packed[1] = struct.pack("!H", length) |
| 219 | return ''.join(packed) |
| 220 | |
| 221 | @staticmethod |
| 222 | def unpack(reader): |
| 223 | obj = bsn_checksum() |
| 224 | _type = reader.read("!H")[0] |
| 225 | assert(_type == 65535) |
| 226 | _len = reader.read("!H")[0] |
| 227 | orig_reader = reader |
| 228 | reader = orig_reader.slice(_len, 4) |
| 229 | _experimenter = reader.read("!L")[0] |
| 230 | assert(_experimenter == 6035143) |
| 231 | _subtype = reader.read("!L")[0] |
| 232 | assert(_subtype == 4) |
| 233 | obj.checksum = util.unpack_checksum_128(reader) |
| 234 | return obj |
| 235 | |
| 236 | def __eq__(self, other): |
| 237 | if type(self) != type(other): return False |
| 238 | if self.checksum != other.checksum: return False |
| 239 | return True |
| 240 | |
| 241 | def pretty_print(self, q): |
| 242 | q.text("bsn_checksum {") |
| 243 | with q.group(): |
| 244 | with q.indent(2): |
| 245 | q.breakable() |
| 246 | q.text("checksum = "); |
| 247 | q.pp(self.checksum) |
| 248 | q.breakable() |
| 249 | q.text('}') |
| 250 | |
| 251 | bsn.subtypes[4] = bsn_checksum |
| 252 | |
| 253 | class bsn_mirror(bsn): |
| 254 | type = 65535 |
| 255 | experimenter = 6035143 |
| 256 | subtype = 1 |
| 257 | |
| 258 | def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None): |
| 259 | if dest_port != None: |
| 260 | self.dest_port = dest_port |
| 261 | else: |
| 262 | self.dest_port = 0 |
| 263 | if vlan_tag != None: |
| 264 | self.vlan_tag = vlan_tag |
| 265 | else: |
| 266 | self.vlan_tag = 0 |
| 267 | if copy_stage != None: |
| 268 | self.copy_stage = copy_stage |
| 269 | else: |
| 270 | self.copy_stage = 0 |
| 271 | return |
| 272 | |
| 273 | def pack(self): |
| 274 | packed = [] |
| 275 | packed.append(struct.pack("!H", self.type)) |
| 276 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 277 | packed.append(struct.pack("!L", self.experimenter)) |
| 278 | packed.append(struct.pack("!L", self.subtype)) |
| 279 | packed.append(struct.pack("!L", self.dest_port)) |
| 280 | packed.append(struct.pack("!L", self.vlan_tag)) |
| 281 | packed.append(struct.pack("!B", self.copy_stage)) |
| 282 | packed.append('\x00' * 3) |
| 283 | length = sum([len(x) for x in packed]) |
| 284 | packed[1] = struct.pack("!H", length) |
| 285 | return ''.join(packed) |
| 286 | |
| 287 | @staticmethod |
| 288 | def unpack(reader): |
| 289 | obj = bsn_mirror() |
| 290 | _type = reader.read("!H")[0] |
| 291 | assert(_type == 65535) |
| 292 | _len = reader.read("!H")[0] |
| 293 | orig_reader = reader |
| 294 | reader = orig_reader.slice(_len, 4) |
| 295 | _experimenter = reader.read("!L")[0] |
| 296 | assert(_experimenter == 6035143) |
| 297 | _subtype = reader.read("!L")[0] |
| 298 | assert(_subtype == 1) |
| 299 | obj.dest_port = reader.read("!L")[0] |
| 300 | obj.vlan_tag = reader.read("!L")[0] |
| 301 | obj.copy_stage = reader.read("!B")[0] |
| 302 | reader.skip(3) |
| 303 | return obj |
| 304 | |
| 305 | def __eq__(self, other): |
| 306 | if type(self) != type(other): return False |
| 307 | if self.dest_port != other.dest_port: return False |
| 308 | if self.vlan_tag != other.vlan_tag: return False |
| 309 | if self.copy_stage != other.copy_stage: return False |
| 310 | return True |
| 311 | |
| 312 | def pretty_print(self, q): |
| 313 | q.text("bsn_mirror {") |
| 314 | with q.group(): |
| 315 | with q.indent(2): |
| 316 | q.breakable() |
| 317 | q.text("dest_port = "); |
| 318 | q.text("%#x" % self.dest_port) |
| 319 | q.text(","); q.breakable() |
| 320 | q.text("vlan_tag = "); |
| 321 | q.text("%#x" % self.vlan_tag) |
| 322 | q.text(","); q.breakable() |
| 323 | q.text("copy_stage = "); |
| 324 | q.text("%#x" % self.copy_stage) |
| 325 | q.breakable() |
| 326 | q.text('}') |
| 327 | |
| 328 | bsn.subtypes[1] = bsn_mirror |
| 329 | |
| 330 | class bsn_set_tunnel_dst(bsn): |
| 331 | type = 65535 |
| 332 | experimenter = 6035143 |
| 333 | subtype = 2 |
| 334 | |
| 335 | def __init__(self, dst=None): |
| 336 | if dst != None: |
| 337 | self.dst = dst |
| 338 | else: |
| 339 | self.dst = 0 |
| 340 | return |
| 341 | |
| 342 | def pack(self): |
| 343 | packed = [] |
| 344 | packed.append(struct.pack("!H", self.type)) |
| 345 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 346 | packed.append(struct.pack("!L", self.experimenter)) |
| 347 | packed.append(struct.pack("!L", self.subtype)) |
| 348 | packed.append(struct.pack("!L", self.dst)) |
| 349 | length = sum([len(x) for x in packed]) |
| 350 | packed[1] = struct.pack("!H", length) |
| 351 | return ''.join(packed) |
| 352 | |
| 353 | @staticmethod |
| 354 | def unpack(reader): |
| 355 | obj = bsn_set_tunnel_dst() |
| 356 | _type = reader.read("!H")[0] |
| 357 | assert(_type == 65535) |
| 358 | _len = reader.read("!H")[0] |
| 359 | orig_reader = reader |
| 360 | reader = orig_reader.slice(_len, 4) |
| 361 | _experimenter = reader.read("!L")[0] |
| 362 | assert(_experimenter == 6035143) |
| 363 | _subtype = reader.read("!L")[0] |
| 364 | assert(_subtype == 2) |
| 365 | obj.dst = reader.read("!L")[0] |
| 366 | return obj |
| 367 | |
| 368 | def __eq__(self, other): |
| 369 | if type(self) != type(other): return False |
| 370 | if self.dst != other.dst: return False |
| 371 | return True |
| 372 | |
| 373 | def pretty_print(self, q): |
| 374 | q.text("bsn_set_tunnel_dst {") |
| 375 | with q.group(): |
| 376 | with q.indent(2): |
| 377 | q.breakable() |
| 378 | q.text("dst = "); |
| 379 | q.text("%#x" % self.dst) |
| 380 | q.breakable() |
| 381 | q.text('}') |
| 382 | |
| 383 | bsn.subtypes[2] = bsn_set_tunnel_dst |
| 384 | |
| 385 | class enqueue(action): |
| 386 | type = 11 |
| 387 | |
| 388 | def __init__(self, port=None, queue_id=None): |
| 389 | if port != None: |
| 390 | self.port = port |
| 391 | else: |
| 392 | self.port = 0 |
| 393 | if queue_id != None: |
| 394 | self.queue_id = queue_id |
| 395 | else: |
| 396 | self.queue_id = 0 |
| 397 | return |
| 398 | |
| 399 | def pack(self): |
| 400 | packed = [] |
| 401 | packed.append(struct.pack("!H", self.type)) |
| 402 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 403 | packed.append(util.pack_port_no(self.port)) |
| 404 | packed.append('\x00' * 6) |
| 405 | packed.append(struct.pack("!L", self.queue_id)) |
| 406 | length = sum([len(x) for x in packed]) |
| 407 | packed[1] = struct.pack("!H", length) |
| 408 | return ''.join(packed) |
| 409 | |
| 410 | @staticmethod |
| 411 | def unpack(reader): |
| 412 | obj = enqueue() |
| 413 | _type = reader.read("!H")[0] |
| 414 | assert(_type == 11) |
| 415 | _len = reader.read("!H")[0] |
| 416 | orig_reader = reader |
| 417 | reader = orig_reader.slice(_len, 4) |
| 418 | obj.port = util.unpack_port_no(reader) |
| 419 | reader.skip(6) |
| 420 | obj.queue_id = reader.read("!L")[0] |
| 421 | return obj |
| 422 | |
| 423 | def __eq__(self, other): |
| 424 | if type(self) != type(other): return False |
| 425 | if self.port != other.port: return False |
| 426 | if self.queue_id != other.queue_id: return False |
| 427 | return True |
| 428 | |
| 429 | def pretty_print(self, q): |
| 430 | q.text("enqueue {") |
| 431 | with q.group(): |
| 432 | with q.indent(2): |
| 433 | q.breakable() |
| 434 | q.text("port = "); |
| 435 | q.text(util.pretty_port(self.port)) |
| 436 | q.text(","); q.breakable() |
| 437 | q.text("queue_id = "); |
| 438 | q.text("%#x" % self.queue_id) |
| 439 | q.breakable() |
| 440 | q.text('}') |
| 441 | |
| 442 | action.subtypes[11] = enqueue |
| 443 | |
| 444 | class nicira(experimenter): |
| 445 | subtypes = {} |
| 446 | |
| 447 | type = 65535 |
| 448 | experimenter = 8992 |
| 449 | |
| 450 | def __init__(self, subtype=None): |
| 451 | if subtype != None: |
| 452 | self.subtype = subtype |
| 453 | else: |
| 454 | self.subtype = 0 |
| 455 | return |
| 456 | |
| 457 | def pack(self): |
| 458 | packed = [] |
| 459 | packed.append(struct.pack("!H", self.type)) |
| 460 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 461 | packed.append(struct.pack("!L", self.experimenter)) |
| 462 | packed.append(struct.pack("!H", self.subtype)) |
| 463 | packed.append('\x00' * 2) |
| 464 | packed.append('\x00' * 4) |
| 465 | length = sum([len(x) for x in packed]) |
| 466 | packed[1] = struct.pack("!H", length) |
| 467 | return ''.join(packed) |
| 468 | |
| 469 | @staticmethod |
| 470 | def unpack(reader): |
| 471 | subtype, = reader.peek('!H', 8) |
| 472 | subclass = nicira.subtypes.get(subtype) |
| 473 | if subclass: |
| 474 | return subclass.unpack(reader) |
| 475 | |
| 476 | obj = nicira() |
| 477 | _type = reader.read("!H")[0] |
| 478 | assert(_type == 65535) |
| 479 | _len = reader.read("!H")[0] |
| 480 | orig_reader = reader |
| 481 | reader = orig_reader.slice(_len, 4) |
| 482 | _experimenter = reader.read("!L")[0] |
| 483 | assert(_experimenter == 8992) |
| 484 | obj.subtype = reader.read("!H")[0] |
| 485 | reader.skip(2) |
| 486 | reader.skip(4) |
| 487 | return obj |
| 488 | |
| 489 | def __eq__(self, other): |
| 490 | if type(self) != type(other): return False |
| 491 | if self.subtype != other.subtype: return False |
| 492 | return True |
| 493 | |
| 494 | def pretty_print(self, q): |
| 495 | q.text("nicira {") |
| 496 | with q.group(): |
| 497 | with q.indent(2): |
| 498 | q.breakable() |
| 499 | q.breakable() |
| 500 | q.text('}') |
| 501 | |
| 502 | experimenter.subtypes[8992] = nicira |
| 503 | |
| 504 | class nicira_dec_ttl(nicira): |
| 505 | type = 65535 |
| 506 | experimenter = 8992 |
| 507 | subtype = 18 |
| 508 | |
| 509 | def __init__(self): |
| 510 | return |
| 511 | |
| 512 | def pack(self): |
| 513 | packed = [] |
| 514 | packed.append(struct.pack("!H", self.type)) |
| 515 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 516 | packed.append(struct.pack("!L", self.experimenter)) |
| 517 | packed.append(struct.pack("!H", self.subtype)) |
| 518 | packed.append('\x00' * 2) |
| 519 | packed.append('\x00' * 4) |
| 520 | length = sum([len(x) for x in packed]) |
| 521 | packed[1] = struct.pack("!H", length) |
| 522 | return ''.join(packed) |
| 523 | |
| 524 | @staticmethod |
| 525 | def unpack(reader): |
| 526 | obj = nicira_dec_ttl() |
| 527 | _type = reader.read("!H")[0] |
| 528 | assert(_type == 65535) |
| 529 | _len = reader.read("!H")[0] |
| 530 | orig_reader = reader |
| 531 | reader = orig_reader.slice(_len, 4) |
| 532 | _experimenter = reader.read("!L")[0] |
| 533 | assert(_experimenter == 8992) |
| 534 | _subtype = reader.read("!H")[0] |
| 535 | assert(_subtype == 18) |
| 536 | reader.skip(2) |
| 537 | reader.skip(4) |
| 538 | return obj |
| 539 | |
| 540 | def __eq__(self, other): |
| 541 | if type(self) != type(other): return False |
| 542 | return True |
| 543 | |
| 544 | def pretty_print(self, q): |
| 545 | q.text("nicira_dec_ttl {") |
| 546 | with q.group(): |
| 547 | with q.indent(2): |
| 548 | q.breakable() |
| 549 | q.breakable() |
| 550 | q.text('}') |
| 551 | |
| 552 | nicira.subtypes[18] = nicira_dec_ttl |
| 553 | |
| 554 | class output(action): |
| 555 | type = 0 |
| 556 | |
| 557 | def __init__(self, port=None, max_len=None): |
| 558 | if port != None: |
| 559 | self.port = port |
| 560 | else: |
| 561 | self.port = 0 |
| 562 | if max_len != None: |
| 563 | self.max_len = max_len |
| 564 | else: |
| 565 | self.max_len = 0 |
| 566 | return |
| 567 | |
| 568 | def pack(self): |
| 569 | packed = [] |
| 570 | packed.append(struct.pack("!H", self.type)) |
| 571 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 572 | packed.append(util.pack_port_no(self.port)) |
| 573 | packed.append(struct.pack("!H", self.max_len)) |
| 574 | length = sum([len(x) for x in packed]) |
| 575 | packed[1] = struct.pack("!H", length) |
| 576 | return ''.join(packed) |
| 577 | |
| 578 | @staticmethod |
| 579 | def unpack(reader): |
| 580 | obj = output() |
| 581 | _type = reader.read("!H")[0] |
| 582 | assert(_type == 0) |
| 583 | _len = reader.read("!H")[0] |
| 584 | orig_reader = reader |
| 585 | reader = orig_reader.slice(_len, 4) |
| 586 | obj.port = util.unpack_port_no(reader) |
| 587 | obj.max_len = reader.read("!H")[0] |
| 588 | return obj |
| 589 | |
| 590 | def __eq__(self, other): |
| 591 | if type(self) != type(other): return False |
| 592 | if self.port != other.port: return False |
| 593 | if self.max_len != other.max_len: return False |
| 594 | return True |
| 595 | |
| 596 | def pretty_print(self, q): |
| 597 | q.text("output {") |
| 598 | with q.group(): |
| 599 | with q.indent(2): |
| 600 | q.breakable() |
| 601 | q.text("port = "); |
| 602 | q.text(util.pretty_port(self.port)) |
| 603 | q.text(","); q.breakable() |
| 604 | q.text("max_len = "); |
| 605 | q.text("%#x" % self.max_len) |
| 606 | q.breakable() |
| 607 | q.text('}') |
| 608 | |
| 609 | action.subtypes[0] = output |
| 610 | |
| 611 | class set_dl_dst(action): |
| 612 | type = 5 |
| 613 | |
| 614 | def __init__(self, dl_addr=None): |
| 615 | if dl_addr != None: |
| 616 | self.dl_addr = dl_addr |
| 617 | else: |
| 618 | self.dl_addr = [0,0,0,0,0,0] |
| 619 | return |
| 620 | |
| 621 | def pack(self): |
| 622 | packed = [] |
| 623 | packed.append(struct.pack("!H", self.type)) |
| 624 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 625 | packed.append(struct.pack("!6B", *self.dl_addr)) |
| 626 | packed.append('\x00' * 6) |
| 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 = set_dl_dst() |
| 634 | _type = reader.read("!H")[0] |
| 635 | assert(_type == 5) |
| 636 | _len = reader.read("!H")[0] |
| 637 | orig_reader = reader |
| 638 | reader = orig_reader.slice(_len, 4) |
| 639 | obj.dl_addr = list(reader.read('!6B')) |
| 640 | reader.skip(6) |
| 641 | return obj |
| 642 | |
| 643 | def __eq__(self, other): |
| 644 | if type(self) != type(other): return False |
| 645 | if self.dl_addr != other.dl_addr: return False |
| 646 | return True |
| 647 | |
| 648 | def pretty_print(self, q): |
| 649 | q.text("set_dl_dst {") |
| 650 | with q.group(): |
| 651 | with q.indent(2): |
| 652 | q.breakable() |
| 653 | q.text("dl_addr = "); |
| 654 | q.text(util.pretty_mac(self.dl_addr)) |
| 655 | q.breakable() |
| 656 | q.text('}') |
| 657 | |
| 658 | action.subtypes[5] = set_dl_dst |
| 659 | |
| 660 | class set_dl_src(action): |
| 661 | type = 4 |
| 662 | |
| 663 | def __init__(self, dl_addr=None): |
| 664 | if dl_addr != None: |
| 665 | self.dl_addr = dl_addr |
| 666 | else: |
| 667 | self.dl_addr = [0,0,0,0,0,0] |
| 668 | return |
| 669 | |
| 670 | def pack(self): |
| 671 | packed = [] |
| 672 | packed.append(struct.pack("!H", self.type)) |
| 673 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 674 | packed.append(struct.pack("!6B", *self.dl_addr)) |
| 675 | packed.append('\x00' * 6) |
| 676 | length = sum([len(x) for x in packed]) |
| 677 | packed[1] = struct.pack("!H", length) |
| 678 | return ''.join(packed) |
| 679 | |
| 680 | @staticmethod |
| 681 | def unpack(reader): |
| 682 | obj = set_dl_src() |
| 683 | _type = reader.read("!H")[0] |
| 684 | assert(_type == 4) |
| 685 | _len = reader.read("!H")[0] |
| 686 | orig_reader = reader |
| 687 | reader = orig_reader.slice(_len, 4) |
| 688 | obj.dl_addr = list(reader.read('!6B')) |
| 689 | reader.skip(6) |
| 690 | return obj |
| 691 | |
| 692 | def __eq__(self, other): |
| 693 | if type(self) != type(other): return False |
| 694 | if self.dl_addr != other.dl_addr: return False |
| 695 | return True |
| 696 | |
| 697 | def pretty_print(self, q): |
| 698 | q.text("set_dl_src {") |
| 699 | with q.group(): |
| 700 | with q.indent(2): |
| 701 | q.breakable() |
| 702 | q.text("dl_addr = "); |
| 703 | q.text(util.pretty_mac(self.dl_addr)) |
| 704 | q.breakable() |
| 705 | q.text('}') |
| 706 | |
| 707 | action.subtypes[4] = set_dl_src |
| 708 | |
| 709 | class set_nw_dst(action): |
| 710 | type = 7 |
| 711 | |
| 712 | def __init__(self, nw_addr=None): |
| 713 | if nw_addr != None: |
| 714 | self.nw_addr = nw_addr |
| 715 | else: |
| 716 | self.nw_addr = 0 |
| 717 | return |
| 718 | |
| 719 | def pack(self): |
| 720 | packed = [] |
| 721 | packed.append(struct.pack("!H", self.type)) |
| 722 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 723 | packed.append(struct.pack("!L", self.nw_addr)) |
| 724 | length = sum([len(x) for x in packed]) |
| 725 | packed[1] = struct.pack("!H", length) |
| 726 | return ''.join(packed) |
| 727 | |
| 728 | @staticmethod |
| 729 | def unpack(reader): |
| 730 | obj = set_nw_dst() |
| 731 | _type = reader.read("!H")[0] |
| 732 | assert(_type == 7) |
| 733 | _len = reader.read("!H")[0] |
| 734 | orig_reader = reader |
| 735 | reader = orig_reader.slice(_len, 4) |
| 736 | obj.nw_addr = reader.read("!L")[0] |
| 737 | return obj |
| 738 | |
| 739 | def __eq__(self, other): |
| 740 | if type(self) != type(other): return False |
| 741 | if self.nw_addr != other.nw_addr: return False |
| 742 | return True |
| 743 | |
| 744 | def pretty_print(self, q): |
| 745 | q.text("set_nw_dst {") |
| 746 | with q.group(): |
| 747 | with q.indent(2): |
| 748 | q.breakable() |
| 749 | q.text("nw_addr = "); |
| 750 | q.text("%#x" % self.nw_addr) |
| 751 | q.breakable() |
| 752 | q.text('}') |
| 753 | |
| 754 | action.subtypes[7] = set_nw_dst |
| 755 | |
| 756 | class set_nw_src(action): |
| 757 | type = 6 |
| 758 | |
| 759 | def __init__(self, nw_addr=None): |
| 760 | if nw_addr != None: |
| 761 | self.nw_addr = nw_addr |
| 762 | else: |
| 763 | self.nw_addr = 0 |
| 764 | return |
| 765 | |
| 766 | def pack(self): |
| 767 | packed = [] |
| 768 | packed.append(struct.pack("!H", self.type)) |
| 769 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 770 | packed.append(struct.pack("!L", self.nw_addr)) |
| 771 | length = sum([len(x) for x in packed]) |
| 772 | packed[1] = struct.pack("!H", length) |
| 773 | return ''.join(packed) |
| 774 | |
| 775 | @staticmethod |
| 776 | def unpack(reader): |
| 777 | obj = set_nw_src() |
| 778 | _type = reader.read("!H")[0] |
| 779 | assert(_type == 6) |
| 780 | _len = reader.read("!H")[0] |
| 781 | orig_reader = reader |
| 782 | reader = orig_reader.slice(_len, 4) |
| 783 | obj.nw_addr = reader.read("!L")[0] |
| 784 | return obj |
| 785 | |
| 786 | def __eq__(self, other): |
| 787 | if type(self) != type(other): return False |
| 788 | if self.nw_addr != other.nw_addr: return False |
| 789 | return True |
| 790 | |
| 791 | def pretty_print(self, q): |
| 792 | q.text("set_nw_src {") |
| 793 | with q.group(): |
| 794 | with q.indent(2): |
| 795 | q.breakable() |
| 796 | q.text("nw_addr = "); |
| 797 | q.text("%#x" % self.nw_addr) |
| 798 | q.breakable() |
| 799 | q.text('}') |
| 800 | |
| 801 | action.subtypes[6] = set_nw_src |
| 802 | |
| 803 | class set_nw_tos(action): |
| 804 | type = 8 |
| 805 | |
| 806 | def __init__(self, nw_tos=None): |
| 807 | if nw_tos != None: |
| 808 | self.nw_tos = nw_tos |
| 809 | else: |
| 810 | self.nw_tos = 0 |
| 811 | return |
| 812 | |
| 813 | def pack(self): |
| 814 | packed = [] |
| 815 | packed.append(struct.pack("!H", self.type)) |
| 816 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 817 | packed.append(struct.pack("!B", self.nw_tos)) |
| 818 | packed.append('\x00' * 3) |
| 819 | length = sum([len(x) for x in packed]) |
| 820 | packed[1] = struct.pack("!H", length) |
| 821 | return ''.join(packed) |
| 822 | |
| 823 | @staticmethod |
| 824 | def unpack(reader): |
| 825 | obj = set_nw_tos() |
| 826 | _type = reader.read("!H")[0] |
| 827 | assert(_type == 8) |
| 828 | _len = reader.read("!H")[0] |
| 829 | orig_reader = reader |
| 830 | reader = orig_reader.slice(_len, 4) |
| 831 | obj.nw_tos = reader.read("!B")[0] |
| 832 | reader.skip(3) |
| 833 | return obj |
| 834 | |
| 835 | def __eq__(self, other): |
| 836 | if type(self) != type(other): return False |
| 837 | if self.nw_tos != other.nw_tos: return False |
| 838 | return True |
| 839 | |
| 840 | def pretty_print(self, q): |
| 841 | q.text("set_nw_tos {") |
| 842 | with q.group(): |
| 843 | with q.indent(2): |
| 844 | q.breakable() |
| 845 | q.text("nw_tos = "); |
| 846 | q.text("%#x" % self.nw_tos) |
| 847 | q.breakable() |
| 848 | q.text('}') |
| 849 | |
| 850 | action.subtypes[8] = set_nw_tos |
| 851 | |
| 852 | class set_tp_dst(action): |
| 853 | type = 10 |
| 854 | |
| 855 | def __init__(self, tp_port=None): |
| 856 | if tp_port != None: |
| 857 | self.tp_port = tp_port |
| 858 | else: |
| 859 | self.tp_port = 0 |
| 860 | return |
| 861 | |
| 862 | def pack(self): |
| 863 | packed = [] |
| 864 | packed.append(struct.pack("!H", self.type)) |
| 865 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 866 | packed.append(struct.pack("!H", self.tp_port)) |
| 867 | packed.append('\x00' * 2) |
| 868 | length = sum([len(x) for x in packed]) |
| 869 | packed[1] = struct.pack("!H", length) |
| 870 | return ''.join(packed) |
| 871 | |
| 872 | @staticmethod |
| 873 | def unpack(reader): |
| 874 | obj = set_tp_dst() |
| 875 | _type = reader.read("!H")[0] |
| 876 | assert(_type == 10) |
| 877 | _len = reader.read("!H")[0] |
| 878 | orig_reader = reader |
| 879 | reader = orig_reader.slice(_len, 4) |
| 880 | obj.tp_port = reader.read("!H")[0] |
| 881 | reader.skip(2) |
| 882 | return obj |
| 883 | |
| 884 | def __eq__(self, other): |
| 885 | if type(self) != type(other): return False |
| 886 | if self.tp_port != other.tp_port: return False |
| 887 | return True |
| 888 | |
| 889 | def pretty_print(self, q): |
| 890 | q.text("set_tp_dst {") |
| 891 | with q.group(): |
| 892 | with q.indent(2): |
| 893 | q.breakable() |
| 894 | q.text("tp_port = "); |
| 895 | q.text("%#x" % self.tp_port) |
| 896 | q.breakable() |
| 897 | q.text('}') |
| 898 | |
| 899 | action.subtypes[10] = set_tp_dst |
| 900 | |
| 901 | class set_tp_src(action): |
| 902 | type = 9 |
| 903 | |
| 904 | def __init__(self, tp_port=None): |
| 905 | if tp_port != None: |
| 906 | self.tp_port = tp_port |
| 907 | else: |
| 908 | self.tp_port = 0 |
| 909 | return |
| 910 | |
| 911 | def pack(self): |
| 912 | packed = [] |
| 913 | packed.append(struct.pack("!H", self.type)) |
| 914 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 915 | packed.append(struct.pack("!H", self.tp_port)) |
| 916 | packed.append('\x00' * 2) |
| 917 | length = sum([len(x) for x in packed]) |
| 918 | packed[1] = struct.pack("!H", length) |
| 919 | return ''.join(packed) |
| 920 | |
| 921 | @staticmethod |
| 922 | def unpack(reader): |
| 923 | obj = set_tp_src() |
| 924 | _type = reader.read("!H")[0] |
| 925 | assert(_type == 9) |
| 926 | _len = reader.read("!H")[0] |
| 927 | orig_reader = reader |
| 928 | reader = orig_reader.slice(_len, 4) |
| 929 | obj.tp_port = reader.read("!H")[0] |
| 930 | reader.skip(2) |
| 931 | return obj |
| 932 | |
| 933 | def __eq__(self, other): |
| 934 | if type(self) != type(other): return False |
| 935 | if self.tp_port != other.tp_port: return False |
| 936 | return True |
| 937 | |
| 938 | def pretty_print(self, q): |
| 939 | q.text("set_tp_src {") |
| 940 | with q.group(): |
| 941 | with q.indent(2): |
| 942 | q.breakable() |
| 943 | q.text("tp_port = "); |
| 944 | q.text("%#x" % self.tp_port) |
| 945 | q.breakable() |
| 946 | q.text('}') |
| 947 | |
| 948 | action.subtypes[9] = set_tp_src |
| 949 | |
| 950 | class set_vlan_pcp(action): |
| 951 | type = 2 |
| 952 | |
| 953 | def __init__(self, vlan_pcp=None): |
| 954 | if vlan_pcp != None: |
| 955 | self.vlan_pcp = vlan_pcp |
| 956 | else: |
| 957 | self.vlan_pcp = 0 |
| 958 | return |
| 959 | |
| 960 | def pack(self): |
| 961 | packed = [] |
| 962 | packed.append(struct.pack("!H", self.type)) |
| 963 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 964 | packed.append(struct.pack("!B", self.vlan_pcp)) |
| 965 | packed.append('\x00' * 3) |
| 966 | length = sum([len(x) for x in packed]) |
| 967 | packed[1] = struct.pack("!H", length) |
| 968 | return ''.join(packed) |
| 969 | |
| 970 | @staticmethod |
| 971 | def unpack(reader): |
| 972 | obj = set_vlan_pcp() |
| 973 | _type = reader.read("!H")[0] |
| 974 | assert(_type == 2) |
| 975 | _len = reader.read("!H")[0] |
| 976 | orig_reader = reader |
| 977 | reader = orig_reader.slice(_len, 4) |
| 978 | obj.vlan_pcp = reader.read("!B")[0] |
| 979 | reader.skip(3) |
| 980 | return obj |
| 981 | |
| 982 | def __eq__(self, other): |
| 983 | if type(self) != type(other): return False |
| 984 | if self.vlan_pcp != other.vlan_pcp: return False |
| 985 | return True |
| 986 | |
| 987 | def pretty_print(self, q): |
| 988 | q.text("set_vlan_pcp {") |
| 989 | with q.group(): |
| 990 | with q.indent(2): |
| 991 | q.breakable() |
| 992 | q.text("vlan_pcp = "); |
| 993 | q.text("%#x" % self.vlan_pcp) |
| 994 | q.breakable() |
| 995 | q.text('}') |
| 996 | |
| 997 | action.subtypes[2] = set_vlan_pcp |
| 998 | |
| 999 | class set_vlan_vid(action): |
| 1000 | type = 1 |
| 1001 | |
| 1002 | def __init__(self, vlan_vid=None): |
| 1003 | if vlan_vid != None: |
| 1004 | self.vlan_vid = vlan_vid |
| 1005 | else: |
| 1006 | self.vlan_vid = 0 |
| 1007 | return |
| 1008 | |
| 1009 | def pack(self): |
| 1010 | packed = [] |
| 1011 | packed.append(struct.pack("!H", self.type)) |
| 1012 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1013 | packed.append(struct.pack("!H", self.vlan_vid)) |
| 1014 | packed.append('\x00' * 2) |
| 1015 | length = sum([len(x) for x in packed]) |
| 1016 | packed[1] = struct.pack("!H", length) |
| 1017 | return ''.join(packed) |
| 1018 | |
| 1019 | @staticmethod |
| 1020 | def unpack(reader): |
| 1021 | obj = set_vlan_vid() |
| 1022 | _type = reader.read("!H")[0] |
| 1023 | assert(_type == 1) |
| 1024 | _len = reader.read("!H")[0] |
| 1025 | orig_reader = reader |
| 1026 | reader = orig_reader.slice(_len, 4) |
| 1027 | obj.vlan_vid = reader.read("!H")[0] |
| 1028 | reader.skip(2) |
| 1029 | return obj |
| 1030 | |
| 1031 | def __eq__(self, other): |
| 1032 | if type(self) != type(other): return False |
| 1033 | if self.vlan_vid != other.vlan_vid: return False |
| 1034 | return True |
| 1035 | |
| 1036 | def pretty_print(self, q): |
| 1037 | q.text("set_vlan_vid {") |
| 1038 | with q.group(): |
| 1039 | with q.indent(2): |
| 1040 | q.breakable() |
| 1041 | q.text("vlan_vid = "); |
| 1042 | q.text("%#x" % self.vlan_vid) |
| 1043 | q.breakable() |
| 1044 | q.text('}') |
| 1045 | |
| 1046 | action.subtypes[1] = set_vlan_vid |
| 1047 | |
| 1048 | class strip_vlan(action): |
| 1049 | type = 3 |
| 1050 | |
| 1051 | def __init__(self): |
| 1052 | return |
| 1053 | |
| 1054 | def pack(self): |
| 1055 | packed = [] |
| 1056 | packed.append(struct.pack("!H", self.type)) |
| 1057 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1058 | packed.append('\x00' * 4) |
| 1059 | length = sum([len(x) for x in packed]) |
| 1060 | packed[1] = struct.pack("!H", length) |
| 1061 | return ''.join(packed) |
| 1062 | |
| 1063 | @staticmethod |
| 1064 | def unpack(reader): |
| 1065 | obj = strip_vlan() |
| 1066 | _type = reader.read("!H")[0] |
| 1067 | assert(_type == 3) |
| 1068 | _len = reader.read("!H")[0] |
| 1069 | orig_reader = reader |
| 1070 | reader = orig_reader.slice(_len, 4) |
| 1071 | reader.skip(4) |
| 1072 | return obj |
| 1073 | |
| 1074 | def __eq__(self, other): |
| 1075 | if type(self) != type(other): return False |
| 1076 | return True |
| 1077 | |
| 1078 | def pretty_print(self, q): |
| 1079 | q.text("strip_vlan {") |
| 1080 | with q.group(): |
| 1081 | with q.indent(2): |
| 1082 | q.breakable() |
| 1083 | q.breakable() |
| 1084 | q.text('}') |
| 1085 | |
| 1086 | action.subtypes[3] = strip_vlan |
| 1087 | |
| 1088 | |