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