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 |
| 11 | import const |
| 12 | import port_desc_prop |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 13 | import bsn_tlv |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 14 | import meter_band |
| 15 | import table_mod_prop |
| 16 | import instruction |
| 17 | import queue_desc_prop |
| 18 | import oxm |
| 19 | import bundle_prop |
| 20 | import common |
| 21 | import instruction_id |
| 22 | import action |
| 23 | import role_prop |
| 24 | import message |
| 25 | import queue_stats_prop |
| 26 | import port_stats_prop |
| 27 | import port_mod_prop |
| 28 | import async_config_prop |
| 29 | import action_id |
| 30 | import util |
| 31 | import loxi.generic_util |
| 32 | |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 33 | class bsn_controller_connection(loxi.OFObject): |
| 34 | |
| 35 | def __init__(self, state=None, auxiliary_id=None, role=None, uri=None): |
| 36 | if state != None: |
| 37 | self.state = state |
| 38 | else: |
| 39 | self.state = 0 |
| 40 | if auxiliary_id != None: |
| 41 | self.auxiliary_id = auxiliary_id |
| 42 | else: |
| 43 | self.auxiliary_id = 0 |
| 44 | if role != None: |
| 45 | self.role = role |
| 46 | else: |
| 47 | self.role = 0 |
| 48 | if uri != None: |
| 49 | self.uri = uri |
| 50 | else: |
| 51 | self.uri = "" |
| 52 | return |
| 53 | |
| 54 | def pack(self): |
| 55 | packed = [] |
| 56 | packed.append(struct.pack("!B", self.state)) |
| 57 | packed.append(struct.pack("!B", self.auxiliary_id)) |
| 58 | packed.append('\x00' * 2) |
| 59 | packed.append(struct.pack("!L", self.role)) |
| 60 | packed.append(struct.pack("!256s", self.uri)) |
| 61 | return ''.join(packed) |
| 62 | |
| 63 | @staticmethod |
| 64 | def unpack(reader): |
| 65 | obj = bsn_controller_connection() |
| 66 | obj.state = reader.read("!B")[0] |
| 67 | obj.auxiliary_id = reader.read("!B")[0] |
| 68 | reader.skip(2) |
| 69 | obj.role = reader.read("!L")[0] |
| 70 | obj.uri = reader.read("!256s")[0].rstrip("\x00") |
| 71 | return obj |
| 72 | |
| 73 | def __eq__(self, other): |
| 74 | if type(self) != type(other): return False |
| 75 | if self.state != other.state: return False |
| 76 | if self.auxiliary_id != other.auxiliary_id: return False |
| 77 | if self.role != other.role: return False |
| 78 | if self.uri != other.uri: return False |
| 79 | return True |
| 80 | |
| 81 | def pretty_print(self, q): |
| 82 | q.text("bsn_controller_connection {") |
| 83 | with q.group(): |
| 84 | with q.indent(2): |
| 85 | q.breakable() |
| 86 | q.text("state = "); |
| 87 | q.text("%#x" % self.state) |
| 88 | q.text(","); q.breakable() |
| 89 | q.text("auxiliary_id = "); |
| 90 | q.text("%#x" % self.auxiliary_id) |
| 91 | q.text(","); q.breakable() |
| 92 | q.text("role = "); |
| 93 | q.text("%#x" % self.role) |
| 94 | q.text(","); q.breakable() |
| 95 | q.text("uri = "); |
| 96 | q.pp(self.uri) |
| 97 | q.breakable() |
| 98 | q.text('}') |
| 99 | |
| 100 | |
| 101 | class bsn_debug_counter_desc_stats_entry(loxi.OFObject): |
| 102 | |
| 103 | def __init__(self, counter_id=None, name=None, description=None): |
| 104 | if counter_id != None: |
| 105 | self.counter_id = counter_id |
| 106 | else: |
| 107 | self.counter_id = 0 |
| 108 | if name != None: |
| 109 | self.name = name |
| 110 | else: |
| 111 | self.name = "" |
| 112 | if description != None: |
| 113 | self.description = description |
| 114 | else: |
| 115 | self.description = "" |
| 116 | return |
| 117 | |
| 118 | def pack(self): |
| 119 | packed = [] |
| 120 | packed.append(struct.pack("!Q", self.counter_id)) |
| 121 | packed.append(struct.pack("!64s", self.name)) |
| 122 | packed.append(struct.pack("!256s", self.description)) |
| 123 | return ''.join(packed) |
| 124 | |
| 125 | @staticmethod |
| 126 | def unpack(reader): |
| 127 | obj = bsn_debug_counter_desc_stats_entry() |
| 128 | obj.counter_id = reader.read("!Q")[0] |
| 129 | obj.name = reader.read("!64s")[0].rstrip("\x00") |
| 130 | obj.description = reader.read("!256s")[0].rstrip("\x00") |
| 131 | return obj |
| 132 | |
| 133 | def __eq__(self, other): |
| 134 | if type(self) != type(other): return False |
| 135 | if self.counter_id != other.counter_id: return False |
| 136 | if self.name != other.name: return False |
| 137 | if self.description != other.description: return False |
| 138 | return True |
| 139 | |
| 140 | def pretty_print(self, q): |
| 141 | q.text("bsn_debug_counter_desc_stats_entry {") |
| 142 | with q.group(): |
| 143 | with q.indent(2): |
| 144 | q.breakable() |
| 145 | q.text("counter_id = "); |
| 146 | q.text("%#x" % self.counter_id) |
| 147 | q.text(","); q.breakable() |
| 148 | q.text("name = "); |
| 149 | q.pp(self.name) |
| 150 | q.text(","); q.breakable() |
| 151 | q.text("description = "); |
| 152 | q.pp(self.description) |
| 153 | q.breakable() |
| 154 | q.text('}') |
| 155 | |
| 156 | |
| 157 | class bsn_debug_counter_stats_entry(loxi.OFObject): |
| 158 | |
| 159 | def __init__(self, counter_id=None, value=None): |
| 160 | if counter_id != None: |
| 161 | self.counter_id = counter_id |
| 162 | else: |
| 163 | self.counter_id = 0 |
| 164 | if value != None: |
| 165 | self.value = value |
| 166 | else: |
| 167 | self.value = 0 |
| 168 | return |
| 169 | |
| 170 | def pack(self): |
| 171 | packed = [] |
| 172 | packed.append(struct.pack("!Q", self.counter_id)) |
| 173 | packed.append(struct.pack("!Q", self.value)) |
| 174 | return ''.join(packed) |
| 175 | |
| 176 | @staticmethod |
| 177 | def unpack(reader): |
| 178 | obj = bsn_debug_counter_stats_entry() |
| 179 | obj.counter_id = reader.read("!Q")[0] |
| 180 | obj.value = reader.read("!Q")[0] |
| 181 | return obj |
| 182 | |
| 183 | def __eq__(self, other): |
| 184 | if type(self) != type(other): return False |
| 185 | if self.counter_id != other.counter_id: return False |
| 186 | if self.value != other.value: return False |
| 187 | return True |
| 188 | |
| 189 | def pretty_print(self, q): |
| 190 | q.text("bsn_debug_counter_stats_entry {") |
| 191 | with q.group(): |
| 192 | with q.indent(2): |
| 193 | q.breakable() |
| 194 | q.text("counter_id = "); |
| 195 | q.text("%#x" % self.counter_id) |
| 196 | q.text(","); q.breakable() |
| 197 | q.text("value = "); |
| 198 | q.text("%#x" % self.value) |
| 199 | q.breakable() |
| 200 | q.text('}') |
| 201 | |
| 202 | |
| 203 | class bsn_flow_checksum_bucket_stats_entry(loxi.OFObject): |
| 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("!Q", self.checksum)) |
| 215 | return ''.join(packed) |
| 216 | |
| 217 | @staticmethod |
| 218 | def unpack(reader): |
| 219 | obj = bsn_flow_checksum_bucket_stats_entry() |
| 220 | obj.checksum = reader.read("!Q")[0] |
| 221 | return obj |
| 222 | |
| 223 | def __eq__(self, other): |
| 224 | if type(self) != type(other): return False |
| 225 | if self.checksum != other.checksum: return False |
| 226 | return True |
| 227 | |
| 228 | def pretty_print(self, q): |
| 229 | q.text("bsn_flow_checksum_bucket_stats_entry {") |
| 230 | with q.group(): |
| 231 | with q.indent(2): |
| 232 | q.breakable() |
| 233 | q.text("checksum = "); |
| 234 | q.text("%#x" % self.checksum) |
| 235 | q.breakable() |
| 236 | q.text('}') |
| 237 | |
| 238 | |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 239 | class bsn_generic_stats_entry(loxi.OFObject): |
| 240 | |
| 241 | def __init__(self, tlvs=None): |
| 242 | if tlvs != None: |
| 243 | self.tlvs = tlvs |
| 244 | else: |
| 245 | self.tlvs = [] |
| 246 | return |
| 247 | |
| 248 | def pack(self): |
| 249 | packed = [] |
| 250 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 251 | packed.append(loxi.generic_util.pack_list(self.tlvs)) |
| 252 | length = sum([len(x) for x in packed]) |
| 253 | packed[0] = struct.pack("!H", length) |
| 254 | return ''.join(packed) |
| 255 | |
| 256 | @staticmethod |
| 257 | def unpack(reader): |
| 258 | obj = bsn_generic_stats_entry() |
| 259 | _length = reader.read("!H")[0] |
| 260 | orig_reader = reader |
| 261 | reader = orig_reader.slice(_length, 2) |
| 262 | obj.tlvs = loxi.generic_util.unpack_list(reader, bsn_tlv.bsn_tlv.unpack) |
| 263 | return obj |
| 264 | |
| 265 | def __eq__(self, other): |
| 266 | if type(self) != type(other): return False |
| 267 | if self.tlvs != other.tlvs: return False |
| 268 | return True |
| 269 | |
| 270 | def pretty_print(self, q): |
| 271 | q.text("bsn_generic_stats_entry {") |
| 272 | with q.group(): |
| 273 | with q.indent(2): |
| 274 | q.breakable() |
| 275 | q.text("tlvs = "); |
| 276 | q.pp(self.tlvs) |
| 277 | q.breakable() |
| 278 | q.text('}') |
| 279 | |
| 280 | |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 281 | class bsn_gentable_bucket_stats_entry(loxi.OFObject): |
| 282 | |
| 283 | def __init__(self, checksum=None): |
| 284 | if checksum != None: |
| 285 | self.checksum = checksum |
| 286 | else: |
| 287 | self.checksum = 0 |
| 288 | return |
| 289 | |
| 290 | def pack(self): |
| 291 | packed = [] |
| 292 | packed.append(util.pack_checksum_128(self.checksum)) |
| 293 | return ''.join(packed) |
| 294 | |
| 295 | @staticmethod |
| 296 | def unpack(reader): |
| 297 | obj = bsn_gentable_bucket_stats_entry() |
| 298 | obj.checksum = util.unpack_checksum_128(reader) |
| 299 | return obj |
| 300 | |
| 301 | def __eq__(self, other): |
| 302 | if type(self) != type(other): return False |
| 303 | if self.checksum != other.checksum: return False |
| 304 | return True |
| 305 | |
| 306 | def pretty_print(self, q): |
| 307 | q.text("bsn_gentable_bucket_stats_entry {") |
| 308 | with q.group(): |
| 309 | with q.indent(2): |
| 310 | q.breakable() |
| 311 | q.text("checksum = "); |
| 312 | q.pp(self.checksum) |
| 313 | q.breakable() |
| 314 | q.text('}') |
| 315 | |
| 316 | |
| 317 | class bsn_gentable_desc_stats_entry(loxi.OFObject): |
| 318 | |
| 319 | def __init__(self, table_id=None, name=None, buckets_size=None, max_entries=None): |
| 320 | if table_id != None: |
| 321 | self.table_id = table_id |
| 322 | else: |
| 323 | self.table_id = 0 |
| 324 | if name != None: |
| 325 | self.name = name |
| 326 | else: |
| 327 | self.name = "" |
| 328 | if buckets_size != None: |
| 329 | self.buckets_size = buckets_size |
| 330 | else: |
| 331 | self.buckets_size = 0 |
| 332 | if max_entries != None: |
| 333 | self.max_entries = max_entries |
| 334 | else: |
| 335 | self.max_entries = 0 |
| 336 | return |
| 337 | |
| 338 | def pack(self): |
| 339 | packed = [] |
| 340 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 341 | packed.append(struct.pack("!H", self.table_id)) |
| 342 | packed.append(struct.pack("!32s", self.name)) |
| 343 | packed.append(struct.pack("!L", self.buckets_size)) |
| 344 | packed.append(struct.pack("!L", self.max_entries)) |
| 345 | packed.append('\x00' * 4) |
| 346 | length = sum([len(x) for x in packed]) |
| 347 | packed[0] = struct.pack("!H", length) |
| 348 | return ''.join(packed) |
| 349 | |
| 350 | @staticmethod |
| 351 | def unpack(reader): |
| 352 | obj = bsn_gentable_desc_stats_entry() |
| 353 | _length = reader.read("!H")[0] |
| 354 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 355 | reader = orig_reader.slice(_length, 2) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 356 | obj.table_id = reader.read("!H")[0] |
| 357 | obj.name = reader.read("!32s")[0].rstrip("\x00") |
| 358 | obj.buckets_size = reader.read("!L")[0] |
| 359 | obj.max_entries = reader.read("!L")[0] |
| 360 | reader.skip(4) |
| 361 | return obj |
| 362 | |
| 363 | def __eq__(self, other): |
| 364 | if type(self) != type(other): return False |
| 365 | if self.table_id != other.table_id: return False |
| 366 | if self.name != other.name: return False |
| 367 | if self.buckets_size != other.buckets_size: return False |
| 368 | if self.max_entries != other.max_entries: return False |
| 369 | return True |
| 370 | |
| 371 | def pretty_print(self, q): |
| 372 | q.text("bsn_gentable_desc_stats_entry {") |
| 373 | with q.group(): |
| 374 | with q.indent(2): |
| 375 | q.breakable() |
| 376 | q.text("table_id = "); |
| 377 | q.text("%#x" % self.table_id) |
| 378 | q.text(","); q.breakable() |
| 379 | q.text("name = "); |
| 380 | q.pp(self.name) |
| 381 | q.text(","); q.breakable() |
| 382 | q.text("buckets_size = "); |
| 383 | q.text("%#x" % self.buckets_size) |
| 384 | q.text(","); q.breakable() |
| 385 | q.text("max_entries = "); |
| 386 | q.text("%#x" % self.max_entries) |
| 387 | q.breakable() |
| 388 | q.text('}') |
| 389 | |
| 390 | |
| 391 | class bsn_gentable_entry_desc_stats_entry(loxi.OFObject): |
| 392 | |
| 393 | def __init__(self, checksum=None, key=None, value=None): |
| 394 | if checksum != None: |
| 395 | self.checksum = checksum |
| 396 | else: |
| 397 | self.checksum = 0 |
| 398 | if key != None: |
| 399 | self.key = key |
| 400 | else: |
| 401 | self.key = [] |
| 402 | if value != None: |
| 403 | self.value = value |
| 404 | else: |
| 405 | self.value = [] |
| 406 | return |
| 407 | |
| 408 | def pack(self): |
| 409 | packed = [] |
| 410 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 411 | packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1 |
| 412 | packed.append(util.pack_checksum_128(self.checksum)) |
| 413 | packed.append(loxi.generic_util.pack_list(self.key)) |
| 414 | packed[1] = struct.pack("!H", len(packed[-1])) |
| 415 | packed.append(loxi.generic_util.pack_list(self.value)) |
| 416 | length = sum([len(x) for x in packed]) |
| 417 | packed[0] = struct.pack("!H", length) |
| 418 | return ''.join(packed) |
| 419 | |
| 420 | @staticmethod |
| 421 | def unpack(reader): |
| 422 | obj = bsn_gentable_entry_desc_stats_entry() |
| 423 | _length = reader.read("!H")[0] |
| 424 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 425 | reader = orig_reader.slice(_length, 2) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 426 | _key_length = reader.read("!H")[0] |
| 427 | obj.checksum = util.unpack_checksum_128(reader) |
| 428 | obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), bsn_tlv.bsn_tlv.unpack) |
| 429 | obj.value = loxi.generic_util.unpack_list(reader, bsn_tlv.bsn_tlv.unpack) |
| 430 | return obj |
| 431 | |
| 432 | def __eq__(self, other): |
| 433 | if type(self) != type(other): return False |
| 434 | if self.checksum != other.checksum: return False |
| 435 | if self.key != other.key: return False |
| 436 | if self.value != other.value: return False |
| 437 | return True |
| 438 | |
| 439 | def pretty_print(self, q): |
| 440 | q.text("bsn_gentable_entry_desc_stats_entry {") |
| 441 | with q.group(): |
| 442 | with q.indent(2): |
| 443 | q.breakable() |
| 444 | q.text("checksum = "); |
| 445 | q.pp(self.checksum) |
| 446 | q.text(","); q.breakable() |
| 447 | q.text("key = "); |
| 448 | q.pp(self.key) |
| 449 | q.text(","); q.breakable() |
| 450 | q.text("value = "); |
| 451 | q.pp(self.value) |
| 452 | q.breakable() |
| 453 | q.text('}') |
| 454 | |
| 455 | |
| 456 | class bsn_gentable_entry_stats_entry(loxi.OFObject): |
| 457 | |
| 458 | def __init__(self, key=None, stats=None): |
| 459 | if key != None: |
| 460 | self.key = key |
| 461 | else: |
| 462 | self.key = [] |
| 463 | if stats != None: |
| 464 | self.stats = stats |
| 465 | else: |
| 466 | self.stats = [] |
| 467 | return |
| 468 | |
| 469 | def pack(self): |
| 470 | packed = [] |
| 471 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 472 | packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1 |
| 473 | packed.append(loxi.generic_util.pack_list(self.key)) |
| 474 | packed[1] = struct.pack("!H", len(packed[-1])) |
| 475 | packed.append(loxi.generic_util.pack_list(self.stats)) |
| 476 | length = sum([len(x) for x in packed]) |
| 477 | packed[0] = struct.pack("!H", length) |
| 478 | return ''.join(packed) |
| 479 | |
| 480 | @staticmethod |
| 481 | def unpack(reader): |
| 482 | obj = bsn_gentable_entry_stats_entry() |
| 483 | _length = reader.read("!H")[0] |
| 484 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 485 | reader = orig_reader.slice(_length, 2) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 486 | _key_length = reader.read("!H")[0] |
| 487 | obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), bsn_tlv.bsn_tlv.unpack) |
| 488 | obj.stats = loxi.generic_util.unpack_list(reader, bsn_tlv.bsn_tlv.unpack) |
| 489 | return obj |
| 490 | |
| 491 | def __eq__(self, other): |
| 492 | if type(self) != type(other): return False |
| 493 | if self.key != other.key: return False |
| 494 | if self.stats != other.stats: return False |
| 495 | return True |
| 496 | |
| 497 | def pretty_print(self, q): |
| 498 | q.text("bsn_gentable_entry_stats_entry {") |
| 499 | with q.group(): |
| 500 | with q.indent(2): |
| 501 | q.breakable() |
| 502 | q.text("key = "); |
| 503 | q.pp(self.key) |
| 504 | q.text(","); q.breakable() |
| 505 | q.text("stats = "); |
| 506 | q.pp(self.stats) |
| 507 | q.breakable() |
| 508 | q.text('}') |
| 509 | |
| 510 | |
| 511 | class bsn_gentable_stats_entry(loxi.OFObject): |
| 512 | |
| 513 | def __init__(self, table_id=None, entry_count=None, checksum=None): |
| 514 | if table_id != None: |
| 515 | self.table_id = table_id |
| 516 | else: |
| 517 | self.table_id = 0 |
| 518 | if entry_count != None: |
| 519 | self.entry_count = entry_count |
| 520 | else: |
| 521 | self.entry_count = 0 |
| 522 | if checksum != None: |
| 523 | self.checksum = checksum |
| 524 | else: |
| 525 | self.checksum = 0 |
| 526 | return |
| 527 | |
| 528 | def pack(self): |
| 529 | packed = [] |
| 530 | packed.append(struct.pack("!H", self.table_id)) |
| 531 | packed.append('\x00' * 2) |
| 532 | packed.append(struct.pack("!L", self.entry_count)) |
| 533 | packed.append(util.pack_checksum_128(self.checksum)) |
| 534 | return ''.join(packed) |
| 535 | |
| 536 | @staticmethod |
| 537 | def unpack(reader): |
| 538 | obj = bsn_gentable_stats_entry() |
| 539 | obj.table_id = reader.read("!H")[0] |
| 540 | reader.skip(2) |
| 541 | obj.entry_count = reader.read("!L")[0] |
| 542 | obj.checksum = util.unpack_checksum_128(reader) |
| 543 | return obj |
| 544 | |
| 545 | def __eq__(self, other): |
| 546 | if type(self) != type(other): return False |
| 547 | if self.table_id != other.table_id: return False |
| 548 | if self.entry_count != other.entry_count: return False |
| 549 | if self.checksum != other.checksum: return False |
| 550 | return True |
| 551 | |
| 552 | def pretty_print(self, q): |
| 553 | q.text("bsn_gentable_stats_entry {") |
| 554 | with q.group(): |
| 555 | with q.indent(2): |
| 556 | q.breakable() |
| 557 | q.text("table_id = "); |
| 558 | q.text("%#x" % self.table_id) |
| 559 | q.text(","); q.breakable() |
| 560 | q.text("entry_count = "); |
| 561 | q.text("%#x" % self.entry_count) |
| 562 | q.text(","); q.breakable() |
| 563 | q.text("checksum = "); |
| 564 | q.pp(self.checksum) |
| 565 | q.breakable() |
| 566 | q.text('}') |
| 567 | |
| 568 | |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 569 | class bsn_interface(loxi.OFObject): |
| 570 | |
| 571 | def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None): |
| 572 | if hw_addr != None: |
| 573 | self.hw_addr = hw_addr |
| 574 | else: |
| 575 | self.hw_addr = [0,0,0,0,0,0] |
| 576 | if name != None: |
| 577 | self.name = name |
| 578 | else: |
| 579 | self.name = "" |
| 580 | if ipv4_addr != None: |
| 581 | self.ipv4_addr = ipv4_addr |
| 582 | else: |
| 583 | self.ipv4_addr = 0 |
| 584 | if ipv4_netmask != None: |
| 585 | self.ipv4_netmask = ipv4_netmask |
| 586 | else: |
| 587 | self.ipv4_netmask = 0 |
| 588 | return |
| 589 | |
| 590 | def pack(self): |
| 591 | packed = [] |
| 592 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 593 | packed.append('\x00' * 2) |
| 594 | packed.append(struct.pack("!16s", self.name)) |
| 595 | packed.append(struct.pack("!L", self.ipv4_addr)) |
| 596 | packed.append(struct.pack("!L", self.ipv4_netmask)) |
| 597 | return ''.join(packed) |
| 598 | |
| 599 | @staticmethod |
| 600 | def unpack(reader): |
| 601 | obj = bsn_interface() |
| 602 | obj.hw_addr = list(reader.read('!6B')) |
| 603 | reader.skip(2) |
| 604 | obj.name = reader.read("!16s")[0].rstrip("\x00") |
| 605 | obj.ipv4_addr = reader.read("!L")[0] |
| 606 | obj.ipv4_netmask = reader.read("!L")[0] |
| 607 | return obj |
| 608 | |
| 609 | def __eq__(self, other): |
| 610 | if type(self) != type(other): return False |
| 611 | if self.hw_addr != other.hw_addr: return False |
| 612 | if self.name != other.name: return False |
| 613 | if self.ipv4_addr != other.ipv4_addr: return False |
| 614 | if self.ipv4_netmask != other.ipv4_netmask: return False |
| 615 | return True |
| 616 | |
| 617 | def pretty_print(self, q): |
| 618 | q.text("bsn_interface {") |
| 619 | with q.group(): |
| 620 | with q.indent(2): |
| 621 | q.breakable() |
| 622 | q.text("hw_addr = "); |
| 623 | q.text(util.pretty_mac(self.hw_addr)) |
| 624 | q.text(","); q.breakable() |
| 625 | q.text("name = "); |
| 626 | q.pp(self.name) |
| 627 | q.text(","); q.breakable() |
| 628 | q.text("ipv4_addr = "); |
| 629 | q.text(util.pretty_ipv4(self.ipv4_addr)) |
| 630 | q.text(","); q.breakable() |
| 631 | q.text("ipv4_netmask = "); |
| 632 | q.text(util.pretty_ipv4(self.ipv4_netmask)) |
| 633 | q.breakable() |
| 634 | q.text('}') |
| 635 | |
| 636 | |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 637 | class bsn_lacp_stats_entry(loxi.OFObject): |
| 638 | |
| 639 | def __init__(self, port_no=None, actor_sys_priority=None, actor_sys_mac=None, actor_port_priority=None, actor_port_num=None, actor_key=None, convergence_status=None, partner_sys_priority=None, partner_sys_mac=None, partner_port_priority=None, partner_port_num=None, partner_key=None): |
| 640 | if port_no != None: |
| 641 | self.port_no = port_no |
| 642 | else: |
| 643 | self.port_no = 0 |
| 644 | if actor_sys_priority != None: |
| 645 | self.actor_sys_priority = actor_sys_priority |
| 646 | else: |
| 647 | self.actor_sys_priority = 0 |
| 648 | if actor_sys_mac != None: |
| 649 | self.actor_sys_mac = actor_sys_mac |
| 650 | else: |
| 651 | self.actor_sys_mac = [0,0,0,0,0,0] |
| 652 | if actor_port_priority != None: |
| 653 | self.actor_port_priority = actor_port_priority |
| 654 | else: |
| 655 | self.actor_port_priority = 0 |
| 656 | if actor_port_num != None: |
| 657 | self.actor_port_num = actor_port_num |
| 658 | else: |
| 659 | self.actor_port_num = 0 |
| 660 | if actor_key != None: |
| 661 | self.actor_key = actor_key |
| 662 | else: |
| 663 | self.actor_key = 0 |
| 664 | if convergence_status != None: |
| 665 | self.convergence_status = convergence_status |
| 666 | else: |
| 667 | self.convergence_status = 0 |
| 668 | if partner_sys_priority != None: |
| 669 | self.partner_sys_priority = partner_sys_priority |
| 670 | else: |
| 671 | self.partner_sys_priority = 0 |
| 672 | if partner_sys_mac != None: |
| 673 | self.partner_sys_mac = partner_sys_mac |
| 674 | else: |
| 675 | self.partner_sys_mac = [0,0,0,0,0,0] |
| 676 | if partner_port_priority != None: |
| 677 | self.partner_port_priority = partner_port_priority |
| 678 | else: |
| 679 | self.partner_port_priority = 0 |
| 680 | if partner_port_num != None: |
| 681 | self.partner_port_num = partner_port_num |
| 682 | else: |
| 683 | self.partner_port_num = 0 |
| 684 | if partner_key != None: |
| 685 | self.partner_key = partner_key |
| 686 | else: |
| 687 | self.partner_key = 0 |
| 688 | return |
| 689 | |
| 690 | def pack(self): |
| 691 | packed = [] |
| 692 | packed.append(util.pack_port_no(self.port_no)) |
| 693 | packed.append(struct.pack("!H", self.actor_sys_priority)) |
| 694 | packed.append(struct.pack("!6B", *self.actor_sys_mac)) |
| 695 | packed.append(struct.pack("!H", self.actor_port_priority)) |
| 696 | packed.append(struct.pack("!H", self.actor_port_num)) |
| 697 | packed.append(struct.pack("!H", self.actor_key)) |
| 698 | packed.append(struct.pack("!B", self.convergence_status)) |
| 699 | packed.append('\x00' * 1) |
| 700 | packed.append(struct.pack("!H", self.partner_sys_priority)) |
| 701 | packed.append(struct.pack("!6B", *self.partner_sys_mac)) |
| 702 | packed.append(struct.pack("!H", self.partner_port_priority)) |
| 703 | packed.append(struct.pack("!H", self.partner_port_num)) |
| 704 | packed.append(struct.pack("!H", self.partner_key)) |
| 705 | packed.append('\x00' * 2) |
| 706 | return ''.join(packed) |
| 707 | |
| 708 | @staticmethod |
| 709 | def unpack(reader): |
| 710 | obj = bsn_lacp_stats_entry() |
| 711 | obj.port_no = util.unpack_port_no(reader) |
| 712 | obj.actor_sys_priority = reader.read("!H")[0] |
| 713 | obj.actor_sys_mac = list(reader.read('!6B')) |
| 714 | obj.actor_port_priority = reader.read("!H")[0] |
| 715 | obj.actor_port_num = reader.read("!H")[0] |
| 716 | obj.actor_key = reader.read("!H")[0] |
| 717 | obj.convergence_status = reader.read("!B")[0] |
| 718 | reader.skip(1) |
| 719 | obj.partner_sys_priority = reader.read("!H")[0] |
| 720 | obj.partner_sys_mac = list(reader.read('!6B')) |
| 721 | obj.partner_port_priority = reader.read("!H")[0] |
| 722 | obj.partner_port_num = reader.read("!H")[0] |
| 723 | obj.partner_key = reader.read("!H")[0] |
| 724 | reader.skip(2) |
| 725 | return obj |
| 726 | |
| 727 | def __eq__(self, other): |
| 728 | if type(self) != type(other): return False |
| 729 | if self.port_no != other.port_no: return False |
| 730 | if self.actor_sys_priority != other.actor_sys_priority: return False |
| 731 | if self.actor_sys_mac != other.actor_sys_mac: return False |
| 732 | if self.actor_port_priority != other.actor_port_priority: return False |
| 733 | if self.actor_port_num != other.actor_port_num: return False |
| 734 | if self.actor_key != other.actor_key: return False |
| 735 | if self.convergence_status != other.convergence_status: return False |
| 736 | if self.partner_sys_priority != other.partner_sys_priority: return False |
| 737 | if self.partner_sys_mac != other.partner_sys_mac: return False |
| 738 | if self.partner_port_priority != other.partner_port_priority: return False |
| 739 | if self.partner_port_num != other.partner_port_num: return False |
| 740 | if self.partner_key != other.partner_key: return False |
| 741 | return True |
| 742 | |
| 743 | def pretty_print(self, q): |
| 744 | q.text("bsn_lacp_stats_entry {") |
| 745 | with q.group(): |
| 746 | with q.indent(2): |
| 747 | q.breakable() |
| 748 | q.text("port_no = "); |
| 749 | q.text(util.pretty_port(self.port_no)) |
| 750 | q.text(","); q.breakable() |
| 751 | q.text("actor_sys_priority = "); |
| 752 | q.text("%#x" % self.actor_sys_priority) |
| 753 | q.text(","); q.breakable() |
| 754 | q.text("actor_sys_mac = "); |
| 755 | q.text(util.pretty_mac(self.actor_sys_mac)) |
| 756 | q.text(","); q.breakable() |
| 757 | q.text("actor_port_priority = "); |
| 758 | q.text("%#x" % self.actor_port_priority) |
| 759 | q.text(","); q.breakable() |
| 760 | q.text("actor_port_num = "); |
| 761 | q.text("%#x" % self.actor_port_num) |
| 762 | q.text(","); q.breakable() |
| 763 | q.text("actor_key = "); |
| 764 | q.text("%#x" % self.actor_key) |
| 765 | q.text(","); q.breakable() |
| 766 | q.text("convergence_status = "); |
| 767 | q.text("%#x" % self.convergence_status) |
| 768 | q.text(","); q.breakable() |
| 769 | q.text("partner_sys_priority = "); |
| 770 | q.text("%#x" % self.partner_sys_priority) |
| 771 | q.text(","); q.breakable() |
| 772 | q.text("partner_sys_mac = "); |
| 773 | q.text(util.pretty_mac(self.partner_sys_mac)) |
| 774 | q.text(","); q.breakable() |
| 775 | q.text("partner_port_priority = "); |
| 776 | q.text("%#x" % self.partner_port_priority) |
| 777 | q.text(","); q.breakable() |
| 778 | q.text("partner_port_num = "); |
| 779 | q.text("%#x" % self.partner_port_num) |
| 780 | q.text(","); q.breakable() |
| 781 | q.text("partner_key = "); |
| 782 | q.text("%#x" % self.partner_key) |
| 783 | q.breakable() |
| 784 | q.text('}') |
| 785 | |
| 786 | |
| 787 | class bsn_port_counter_stats_entry(loxi.OFObject): |
| 788 | |
| 789 | def __init__(self, port_no=None, values=None): |
| 790 | if port_no != None: |
| 791 | self.port_no = port_no |
| 792 | else: |
| 793 | self.port_no = 0 |
| 794 | if values != None: |
| 795 | self.values = values |
| 796 | else: |
| 797 | self.values = [] |
| 798 | return |
| 799 | |
| 800 | def pack(self): |
| 801 | packed = [] |
| 802 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 803 | packed.append('\x00' * 2) |
| 804 | packed.append(util.pack_port_no(self.port_no)) |
| 805 | packed.append(loxi.generic_util.pack_list(self.values)) |
| 806 | length = sum([len(x) for x in packed]) |
| 807 | packed[0] = struct.pack("!H", length) |
| 808 | return ''.join(packed) |
| 809 | |
| 810 | @staticmethod |
| 811 | def unpack(reader): |
| 812 | obj = bsn_port_counter_stats_entry() |
| 813 | _length = reader.read("!H")[0] |
| 814 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 815 | reader = orig_reader.slice(_length, 2) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 816 | reader.skip(2) |
| 817 | obj.port_no = util.unpack_port_no(reader) |
| 818 | obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack) |
| 819 | return obj |
| 820 | |
| 821 | def __eq__(self, other): |
| 822 | if type(self) != type(other): return False |
| 823 | if self.port_no != other.port_no: return False |
| 824 | if self.values != other.values: return False |
| 825 | return True |
| 826 | |
| 827 | def pretty_print(self, q): |
| 828 | q.text("bsn_port_counter_stats_entry {") |
| 829 | with q.group(): |
| 830 | with q.indent(2): |
| 831 | q.breakable() |
| 832 | q.text("port_no = "); |
| 833 | q.text(util.pretty_port(self.port_no)) |
| 834 | q.text(","); q.breakable() |
| 835 | q.text("values = "); |
| 836 | q.pp(self.values) |
| 837 | q.breakable() |
| 838 | q.text('}') |
| 839 | |
| 840 | |
| 841 | class bsn_switch_pipeline_stats_entry(loxi.OFObject): |
| 842 | |
| 843 | def __init__(self, pipeline=None): |
| 844 | if pipeline != None: |
| 845 | self.pipeline = pipeline |
| 846 | else: |
| 847 | self.pipeline = "" |
| 848 | return |
| 849 | |
| 850 | def pack(self): |
| 851 | packed = [] |
| 852 | packed.append(struct.pack("!256s", self.pipeline)) |
| 853 | return ''.join(packed) |
| 854 | |
| 855 | @staticmethod |
| 856 | def unpack(reader): |
| 857 | obj = bsn_switch_pipeline_stats_entry() |
| 858 | obj.pipeline = reader.read("!256s")[0].rstrip("\x00") |
| 859 | return obj |
| 860 | |
| 861 | def __eq__(self, other): |
| 862 | if type(self) != type(other): return False |
| 863 | if self.pipeline != other.pipeline: return False |
| 864 | return True |
| 865 | |
| 866 | def pretty_print(self, q): |
| 867 | q.text("bsn_switch_pipeline_stats_entry {") |
| 868 | with q.group(): |
| 869 | with q.indent(2): |
| 870 | q.breakable() |
| 871 | q.text("pipeline = "); |
| 872 | q.pp(self.pipeline) |
| 873 | q.breakable() |
| 874 | q.text('}') |
| 875 | |
| 876 | |
| 877 | class bsn_table_checksum_stats_entry(loxi.OFObject): |
| 878 | |
| 879 | def __init__(self, table_id=None, checksum=None): |
| 880 | if table_id != None: |
| 881 | self.table_id = table_id |
| 882 | else: |
| 883 | self.table_id = 0 |
| 884 | if checksum != None: |
| 885 | self.checksum = checksum |
| 886 | else: |
| 887 | self.checksum = 0 |
| 888 | return |
| 889 | |
| 890 | def pack(self): |
| 891 | packed = [] |
| 892 | packed.append(struct.pack("!B", self.table_id)) |
| 893 | packed.append(struct.pack("!Q", self.checksum)) |
| 894 | return ''.join(packed) |
| 895 | |
| 896 | @staticmethod |
| 897 | def unpack(reader): |
| 898 | obj = bsn_table_checksum_stats_entry() |
| 899 | obj.table_id = reader.read("!B")[0] |
| 900 | obj.checksum = reader.read("!Q")[0] |
| 901 | return obj |
| 902 | |
| 903 | def __eq__(self, other): |
| 904 | if type(self) != type(other): return False |
| 905 | if self.table_id != other.table_id: return False |
| 906 | if self.checksum != other.checksum: return False |
| 907 | return True |
| 908 | |
| 909 | def pretty_print(self, q): |
| 910 | q.text("bsn_table_checksum_stats_entry {") |
| 911 | with q.group(): |
| 912 | with q.indent(2): |
| 913 | q.breakable() |
| 914 | q.text("table_id = "); |
| 915 | q.text("%#x" % self.table_id) |
| 916 | q.text(","); q.breakable() |
| 917 | q.text("checksum = "); |
| 918 | q.text("%#x" % self.checksum) |
| 919 | q.breakable() |
| 920 | q.text('}') |
| 921 | |
| 922 | |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 923 | class bsn_vport(loxi.OFObject): |
| 924 | subtypes = {} |
| 925 | |
| 926 | |
| 927 | def __init__(self, type=None): |
| 928 | if type != None: |
| 929 | self.type = type |
| 930 | else: |
| 931 | self.type = 0 |
| 932 | return |
| 933 | |
| 934 | def pack(self): |
| 935 | packed = [] |
| 936 | packed.append(struct.pack("!H", self.type)) |
| 937 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 938 | length = sum([len(x) for x in packed]) |
| 939 | packed[1] = struct.pack("!H", length) |
| 940 | return ''.join(packed) |
| 941 | |
| 942 | @staticmethod |
| 943 | def unpack(reader): |
| 944 | subtype, = reader.peek('!H', 0) |
| 945 | subclass = bsn_vport.subtypes.get(subtype) |
| 946 | if subclass: |
| 947 | return subclass.unpack(reader) |
| 948 | |
| 949 | obj = bsn_vport() |
| 950 | obj.type = reader.read("!H")[0] |
| 951 | _length = reader.read("!H")[0] |
| 952 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 953 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 954 | return obj |
| 955 | |
| 956 | def __eq__(self, other): |
| 957 | if type(self) != type(other): return False |
| 958 | if self.type != other.type: return False |
| 959 | return True |
| 960 | |
| 961 | def pretty_print(self, q): |
| 962 | q.text("bsn_vport {") |
| 963 | with q.group(): |
| 964 | with q.indent(2): |
| 965 | q.breakable() |
| 966 | q.breakable() |
| 967 | q.text('}') |
| 968 | |
| 969 | |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 970 | class bsn_vlan_counter_stats_entry(loxi.OFObject): |
| 971 | |
| 972 | def __init__(self, vlan_vid=None, values=None): |
| 973 | if vlan_vid != None: |
| 974 | self.vlan_vid = vlan_vid |
| 975 | else: |
| 976 | self.vlan_vid = 0 |
| 977 | if values != None: |
| 978 | self.values = values |
| 979 | else: |
| 980 | self.values = [] |
| 981 | return |
| 982 | |
| 983 | def pack(self): |
| 984 | packed = [] |
| 985 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 986 | packed.append(struct.pack("!H", self.vlan_vid)) |
| 987 | packed.append('\x00' * 4) |
| 988 | packed.append(loxi.generic_util.pack_list(self.values)) |
| 989 | length = sum([len(x) for x in packed]) |
| 990 | packed[0] = struct.pack("!H", length) |
| 991 | return ''.join(packed) |
| 992 | |
| 993 | @staticmethod |
| 994 | def unpack(reader): |
| 995 | obj = bsn_vlan_counter_stats_entry() |
| 996 | _length = reader.read("!H")[0] |
| 997 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 998 | reader = orig_reader.slice(_length, 2) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 999 | obj.vlan_vid = reader.read("!H")[0] |
| 1000 | reader.skip(4) |
| 1001 | obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack) |
| 1002 | return obj |
| 1003 | |
| 1004 | def __eq__(self, other): |
| 1005 | if type(self) != type(other): return False |
| 1006 | if self.vlan_vid != other.vlan_vid: return False |
| 1007 | if self.values != other.values: return False |
| 1008 | return True |
| 1009 | |
| 1010 | def pretty_print(self, q): |
| 1011 | q.text("bsn_vlan_counter_stats_entry {") |
| 1012 | with q.group(): |
| 1013 | with q.indent(2): |
| 1014 | q.breakable() |
| 1015 | q.text("vlan_vid = "); |
| 1016 | q.text("%#x" % self.vlan_vid) |
| 1017 | q.text(","); q.breakable() |
| 1018 | q.text("values = "); |
| 1019 | q.pp(self.values) |
| 1020 | q.breakable() |
| 1021 | q.text('}') |
| 1022 | |
| 1023 | |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 1024 | class bsn_vport_l2gre(bsn_vport): |
| 1025 | type = 1 |
| 1026 | |
| 1027 | def __init__(self, flags=None, port_no=None, loopback_port_no=None, local_mac=None, nh_mac=None, src_ip=None, dst_ip=None, dscp=None, ttl=None, vpn=None, rate_limit=None, if_name=None): |
| 1028 | if flags != None: |
| 1029 | self.flags = flags |
| 1030 | else: |
| 1031 | self.flags = 0 |
| 1032 | if port_no != None: |
| 1033 | self.port_no = port_no |
| 1034 | else: |
| 1035 | self.port_no = 0 |
| 1036 | if loopback_port_no != None: |
| 1037 | self.loopback_port_no = loopback_port_no |
| 1038 | else: |
| 1039 | self.loopback_port_no = 0 |
| 1040 | if local_mac != None: |
| 1041 | self.local_mac = local_mac |
| 1042 | else: |
| 1043 | self.local_mac = [0,0,0,0,0,0] |
| 1044 | if nh_mac != None: |
| 1045 | self.nh_mac = nh_mac |
| 1046 | else: |
| 1047 | self.nh_mac = [0,0,0,0,0,0] |
| 1048 | if src_ip != None: |
| 1049 | self.src_ip = src_ip |
| 1050 | else: |
| 1051 | self.src_ip = 0 |
| 1052 | if dst_ip != None: |
| 1053 | self.dst_ip = dst_ip |
| 1054 | else: |
| 1055 | self.dst_ip = 0 |
| 1056 | if dscp != None: |
| 1057 | self.dscp = dscp |
| 1058 | else: |
| 1059 | self.dscp = 0 |
| 1060 | if ttl != None: |
| 1061 | self.ttl = ttl |
| 1062 | else: |
| 1063 | self.ttl = 0 |
| 1064 | if vpn != None: |
| 1065 | self.vpn = vpn |
| 1066 | else: |
| 1067 | self.vpn = 0 |
| 1068 | if rate_limit != None: |
| 1069 | self.rate_limit = rate_limit |
| 1070 | else: |
| 1071 | self.rate_limit = 0 |
| 1072 | if if_name != None: |
| 1073 | self.if_name = if_name |
| 1074 | else: |
| 1075 | self.if_name = "" |
| 1076 | return |
| 1077 | |
| 1078 | def pack(self): |
| 1079 | packed = [] |
| 1080 | packed.append(struct.pack("!H", self.type)) |
| 1081 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 1082 | packed.append(struct.pack("!L", self.flags)) |
| 1083 | packed.append(util.pack_port_no(self.port_no)) |
| 1084 | packed.append(util.pack_port_no(self.loopback_port_no)) |
| 1085 | packed.append(struct.pack("!6B", *self.local_mac)) |
| 1086 | packed.append(struct.pack("!6B", *self.nh_mac)) |
| 1087 | packed.append(struct.pack("!L", self.src_ip)) |
| 1088 | packed.append(struct.pack("!L", self.dst_ip)) |
| 1089 | packed.append(struct.pack("!B", self.dscp)) |
| 1090 | packed.append(struct.pack("!B", self.ttl)) |
| 1091 | packed.append('\x00' * 2) |
| 1092 | packed.append(struct.pack("!L", self.vpn)) |
| 1093 | packed.append(struct.pack("!L", self.rate_limit)) |
| 1094 | packed.append(struct.pack("!16s", self.if_name)) |
| 1095 | length = sum([len(x) for x in packed]) |
| 1096 | packed[1] = struct.pack("!H", length) |
| 1097 | return ''.join(packed) |
| 1098 | |
| 1099 | @staticmethod |
| 1100 | def unpack(reader): |
| 1101 | obj = bsn_vport_l2gre() |
| 1102 | _type = reader.read("!H")[0] |
| 1103 | assert(_type == 1) |
| 1104 | _length = reader.read("!H")[0] |
| 1105 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1106 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 1107 | obj.flags = reader.read("!L")[0] |
| 1108 | obj.port_no = util.unpack_port_no(reader) |
| 1109 | obj.loopback_port_no = util.unpack_port_no(reader) |
| 1110 | obj.local_mac = list(reader.read('!6B')) |
| 1111 | obj.nh_mac = list(reader.read('!6B')) |
| 1112 | obj.src_ip = reader.read("!L")[0] |
| 1113 | obj.dst_ip = reader.read("!L")[0] |
| 1114 | obj.dscp = reader.read("!B")[0] |
| 1115 | obj.ttl = reader.read("!B")[0] |
| 1116 | reader.skip(2) |
| 1117 | obj.vpn = reader.read("!L")[0] |
| 1118 | obj.rate_limit = reader.read("!L")[0] |
| 1119 | obj.if_name = reader.read("!16s")[0].rstrip("\x00") |
| 1120 | return obj |
| 1121 | |
| 1122 | def __eq__(self, other): |
| 1123 | if type(self) != type(other): return False |
| 1124 | if self.flags != other.flags: return False |
| 1125 | if self.port_no != other.port_no: return False |
| 1126 | if self.loopback_port_no != other.loopback_port_no: return False |
| 1127 | if self.local_mac != other.local_mac: return False |
| 1128 | if self.nh_mac != other.nh_mac: return False |
| 1129 | if self.src_ip != other.src_ip: return False |
| 1130 | if self.dst_ip != other.dst_ip: return False |
| 1131 | if self.dscp != other.dscp: return False |
| 1132 | if self.ttl != other.ttl: return False |
| 1133 | if self.vpn != other.vpn: return False |
| 1134 | if self.rate_limit != other.rate_limit: return False |
| 1135 | if self.if_name != other.if_name: return False |
| 1136 | return True |
| 1137 | |
| 1138 | def pretty_print(self, q): |
| 1139 | q.text("bsn_vport_l2gre {") |
| 1140 | with q.group(): |
| 1141 | with q.indent(2): |
| 1142 | q.breakable() |
| 1143 | q.text("flags = "); |
| 1144 | q.text("%#x" % self.flags) |
| 1145 | q.text(","); q.breakable() |
| 1146 | q.text("port_no = "); |
| 1147 | q.text(util.pretty_port(self.port_no)) |
| 1148 | q.text(","); q.breakable() |
| 1149 | q.text("loopback_port_no = "); |
| 1150 | q.text(util.pretty_port(self.loopback_port_no)) |
| 1151 | q.text(","); q.breakable() |
| 1152 | q.text("local_mac = "); |
| 1153 | q.text(util.pretty_mac(self.local_mac)) |
| 1154 | q.text(","); q.breakable() |
| 1155 | q.text("nh_mac = "); |
| 1156 | q.text(util.pretty_mac(self.nh_mac)) |
| 1157 | q.text(","); q.breakable() |
| 1158 | q.text("src_ip = "); |
| 1159 | q.text(util.pretty_ipv4(self.src_ip)) |
| 1160 | q.text(","); q.breakable() |
| 1161 | q.text("dst_ip = "); |
| 1162 | q.text(util.pretty_ipv4(self.dst_ip)) |
| 1163 | q.text(","); q.breakable() |
| 1164 | q.text("dscp = "); |
| 1165 | q.text("%#x" % self.dscp) |
| 1166 | q.text(","); q.breakable() |
| 1167 | q.text("ttl = "); |
| 1168 | q.text("%#x" % self.ttl) |
| 1169 | q.text(","); q.breakable() |
| 1170 | q.text("vpn = "); |
| 1171 | q.text("%#x" % self.vpn) |
| 1172 | q.text(","); q.breakable() |
| 1173 | q.text("rate_limit = "); |
| 1174 | q.text("%#x" % self.rate_limit) |
| 1175 | q.text(","); q.breakable() |
| 1176 | q.text("if_name = "); |
| 1177 | q.pp(self.if_name) |
| 1178 | q.breakable() |
| 1179 | q.text('}') |
| 1180 | |
| 1181 | bsn_vport.subtypes[1] = bsn_vport_l2gre |
| 1182 | |
| 1183 | class bsn_vport_q_in_q(bsn_vport): |
| 1184 | type = 0 |
| 1185 | |
| 1186 | def __init__(self, port_no=None, ingress_tpid=None, ingress_vlan_id=None, egress_tpid=None, egress_vlan_id=None, if_name=None): |
| 1187 | if port_no != None: |
| 1188 | self.port_no = port_no |
| 1189 | else: |
| 1190 | self.port_no = 0 |
| 1191 | if ingress_tpid != None: |
| 1192 | self.ingress_tpid = ingress_tpid |
| 1193 | else: |
| 1194 | self.ingress_tpid = 0 |
| 1195 | if ingress_vlan_id != None: |
| 1196 | self.ingress_vlan_id = ingress_vlan_id |
| 1197 | else: |
| 1198 | self.ingress_vlan_id = 0 |
| 1199 | if egress_tpid != None: |
| 1200 | self.egress_tpid = egress_tpid |
| 1201 | else: |
| 1202 | self.egress_tpid = 0 |
| 1203 | if egress_vlan_id != None: |
| 1204 | self.egress_vlan_id = egress_vlan_id |
| 1205 | else: |
| 1206 | self.egress_vlan_id = 0 |
| 1207 | if if_name != None: |
| 1208 | self.if_name = if_name |
| 1209 | else: |
| 1210 | self.if_name = "" |
| 1211 | return |
| 1212 | |
| 1213 | def pack(self): |
| 1214 | packed = [] |
| 1215 | packed.append(struct.pack("!H", self.type)) |
| 1216 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 1217 | packed.append(struct.pack("!L", self.port_no)) |
| 1218 | packed.append(struct.pack("!H", self.ingress_tpid)) |
| 1219 | packed.append(struct.pack("!H", self.ingress_vlan_id)) |
| 1220 | packed.append(struct.pack("!H", self.egress_tpid)) |
| 1221 | packed.append(struct.pack("!H", self.egress_vlan_id)) |
| 1222 | packed.append(struct.pack("!16s", self.if_name)) |
| 1223 | length = sum([len(x) for x in packed]) |
| 1224 | packed[1] = struct.pack("!H", length) |
| 1225 | return ''.join(packed) |
| 1226 | |
| 1227 | @staticmethod |
| 1228 | def unpack(reader): |
| 1229 | obj = bsn_vport_q_in_q() |
| 1230 | _type = reader.read("!H")[0] |
| 1231 | assert(_type == 0) |
| 1232 | _length = reader.read("!H")[0] |
| 1233 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1234 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 1235 | obj.port_no = reader.read("!L")[0] |
| 1236 | obj.ingress_tpid = reader.read("!H")[0] |
| 1237 | obj.ingress_vlan_id = reader.read("!H")[0] |
| 1238 | obj.egress_tpid = reader.read("!H")[0] |
| 1239 | obj.egress_vlan_id = reader.read("!H")[0] |
| 1240 | obj.if_name = reader.read("!16s")[0].rstrip("\x00") |
| 1241 | return obj |
| 1242 | |
| 1243 | def __eq__(self, other): |
| 1244 | if type(self) != type(other): return False |
| 1245 | if self.port_no != other.port_no: return False |
| 1246 | if self.ingress_tpid != other.ingress_tpid: return False |
| 1247 | if self.ingress_vlan_id != other.ingress_vlan_id: return False |
| 1248 | if self.egress_tpid != other.egress_tpid: return False |
| 1249 | if self.egress_vlan_id != other.egress_vlan_id: return False |
| 1250 | if self.if_name != other.if_name: return False |
| 1251 | return True |
| 1252 | |
| 1253 | def pretty_print(self, q): |
| 1254 | q.text("bsn_vport_q_in_q {") |
| 1255 | with q.group(): |
| 1256 | with q.indent(2): |
| 1257 | q.breakable() |
| 1258 | q.text("port_no = "); |
| 1259 | q.text("%#x" % self.port_no) |
| 1260 | q.text(","); q.breakable() |
| 1261 | q.text("ingress_tpid = "); |
| 1262 | q.text("%#x" % self.ingress_tpid) |
| 1263 | q.text(","); q.breakable() |
| 1264 | q.text("ingress_vlan_id = "); |
| 1265 | q.text("%#x" % self.ingress_vlan_id) |
| 1266 | q.text(","); q.breakable() |
| 1267 | q.text("egress_tpid = "); |
| 1268 | q.text("%#x" % self.egress_tpid) |
| 1269 | q.text(","); q.breakable() |
| 1270 | q.text("egress_vlan_id = "); |
| 1271 | q.text("%#x" % self.egress_vlan_id) |
| 1272 | q.text(","); q.breakable() |
| 1273 | q.text("if_name = "); |
| 1274 | q.pp(self.if_name) |
| 1275 | q.breakable() |
| 1276 | q.text('}') |
| 1277 | |
| 1278 | bsn_vport.subtypes[0] = bsn_vport_q_in_q |
| 1279 | |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 1280 | class bsn_vrf_counter_stats_entry(loxi.OFObject): |
| 1281 | |
| 1282 | def __init__(self, vrf=None, values=None): |
| 1283 | if vrf != None: |
| 1284 | self.vrf = vrf |
| 1285 | else: |
| 1286 | self.vrf = 0 |
| 1287 | if values != None: |
| 1288 | self.values = values |
| 1289 | else: |
| 1290 | self.values = [] |
| 1291 | return |
| 1292 | |
| 1293 | def pack(self): |
| 1294 | packed = [] |
| 1295 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 1296 | packed.append('\x00' * 2) |
| 1297 | packed.append(struct.pack("!L", self.vrf)) |
| 1298 | packed.append(loxi.generic_util.pack_list(self.values)) |
| 1299 | length = sum([len(x) for x in packed]) |
| 1300 | packed[0] = struct.pack("!H", length) |
| 1301 | return ''.join(packed) |
| 1302 | |
| 1303 | @staticmethod |
| 1304 | def unpack(reader): |
| 1305 | obj = bsn_vrf_counter_stats_entry() |
| 1306 | _length = reader.read("!H")[0] |
| 1307 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1308 | reader = orig_reader.slice(_length, 2) |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame] | 1309 | reader.skip(2) |
| 1310 | obj.vrf = reader.read("!L")[0] |
| 1311 | obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack) |
| 1312 | return obj |
| 1313 | |
| 1314 | def __eq__(self, other): |
| 1315 | if type(self) != type(other): return False |
| 1316 | if self.vrf != other.vrf: return False |
| 1317 | if self.values != other.values: return False |
| 1318 | return True |
| 1319 | |
| 1320 | def pretty_print(self, q): |
| 1321 | q.text("bsn_vrf_counter_stats_entry {") |
| 1322 | with q.group(): |
| 1323 | with q.indent(2): |
| 1324 | q.breakable() |
| 1325 | q.text("vrf = "); |
| 1326 | q.text("%#x" % self.vrf) |
| 1327 | q.text(","); q.breakable() |
| 1328 | q.text("values = "); |
| 1329 | q.pp(self.values) |
| 1330 | q.breakable() |
| 1331 | q.text('}') |
| 1332 | |
| 1333 | |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 1334 | class bucket(loxi.OFObject): |
| 1335 | |
| 1336 | def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None): |
| 1337 | if weight != None: |
| 1338 | self.weight = weight |
| 1339 | else: |
| 1340 | self.weight = 0 |
| 1341 | if watch_port != None: |
| 1342 | self.watch_port = watch_port |
| 1343 | else: |
| 1344 | self.watch_port = 0 |
| 1345 | if watch_group != None: |
| 1346 | self.watch_group = watch_group |
| 1347 | else: |
| 1348 | self.watch_group = 0 |
| 1349 | if actions != None: |
| 1350 | self.actions = actions |
| 1351 | else: |
| 1352 | self.actions = [] |
| 1353 | return |
| 1354 | |
| 1355 | def pack(self): |
| 1356 | packed = [] |
| 1357 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 0 |
| 1358 | packed.append(struct.pack("!H", self.weight)) |
| 1359 | packed.append(util.pack_port_no(self.watch_port)) |
| 1360 | packed.append(struct.pack("!L", self.watch_group)) |
| 1361 | packed.append('\x00' * 4) |
| 1362 | packed.append(loxi.generic_util.pack_list(self.actions)) |
| 1363 | length = sum([len(x) for x in packed]) |
| 1364 | packed[0] = struct.pack("!H", length) |
| 1365 | return ''.join(packed) |
| 1366 | |
| 1367 | @staticmethod |
| 1368 | def unpack(reader): |
| 1369 | obj = bucket() |
| 1370 | _len = reader.read("!H")[0] |
| 1371 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1372 | reader = orig_reader.slice(_len, 2) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 1373 | obj.weight = reader.read("!H")[0] |
| 1374 | obj.watch_port = util.unpack_port_no(reader) |
| 1375 | obj.watch_group = reader.read("!L")[0] |
| 1376 | reader.skip(4) |
| 1377 | obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack) |
| 1378 | return obj |
| 1379 | |
| 1380 | def __eq__(self, other): |
| 1381 | if type(self) != type(other): return False |
| 1382 | if self.weight != other.weight: return False |
| 1383 | if self.watch_port != other.watch_port: return False |
| 1384 | if self.watch_group != other.watch_group: return False |
| 1385 | if self.actions != other.actions: return False |
| 1386 | return True |
| 1387 | |
| 1388 | def pretty_print(self, q): |
| 1389 | q.text("bucket {") |
| 1390 | with q.group(): |
| 1391 | with q.indent(2): |
| 1392 | q.breakable() |
| 1393 | q.text("weight = "); |
| 1394 | q.text("%#x" % self.weight) |
| 1395 | q.text(","); q.breakable() |
| 1396 | q.text("watch_port = "); |
| 1397 | q.text(util.pretty_port(self.watch_port)) |
| 1398 | q.text(","); q.breakable() |
| 1399 | q.text("watch_group = "); |
| 1400 | q.text("%#x" % self.watch_group) |
| 1401 | q.text(","); q.breakable() |
| 1402 | q.text("actions = "); |
| 1403 | q.pp(self.actions) |
| 1404 | q.breakable() |
| 1405 | q.text('}') |
| 1406 | |
| 1407 | |
| 1408 | class bucket_counter(loxi.OFObject): |
| 1409 | |
| 1410 | def __init__(self, packet_count=None, byte_count=None): |
| 1411 | if packet_count != None: |
| 1412 | self.packet_count = packet_count |
| 1413 | else: |
| 1414 | self.packet_count = 0 |
| 1415 | if byte_count != None: |
| 1416 | self.byte_count = byte_count |
| 1417 | else: |
| 1418 | self.byte_count = 0 |
| 1419 | return |
| 1420 | |
| 1421 | def pack(self): |
| 1422 | packed = [] |
| 1423 | packed.append(struct.pack("!Q", self.packet_count)) |
| 1424 | packed.append(struct.pack("!Q", self.byte_count)) |
| 1425 | return ''.join(packed) |
| 1426 | |
| 1427 | @staticmethod |
| 1428 | def unpack(reader): |
| 1429 | obj = bucket_counter() |
| 1430 | obj.packet_count = reader.read("!Q")[0] |
| 1431 | obj.byte_count = reader.read("!Q")[0] |
| 1432 | return obj |
| 1433 | |
| 1434 | def __eq__(self, other): |
| 1435 | if type(self) != type(other): return False |
| 1436 | if self.packet_count != other.packet_count: return False |
| 1437 | if self.byte_count != other.byte_count: return False |
| 1438 | return True |
| 1439 | |
| 1440 | def pretty_print(self, q): |
| 1441 | q.text("bucket_counter {") |
| 1442 | with q.group(): |
| 1443 | with q.indent(2): |
| 1444 | q.breakable() |
| 1445 | q.text("packet_count = "); |
| 1446 | q.text("%#x" % self.packet_count) |
| 1447 | q.text(","); q.breakable() |
| 1448 | q.text("byte_count = "); |
| 1449 | q.text("%#x" % self.byte_count) |
| 1450 | q.breakable() |
| 1451 | q.text('}') |
| 1452 | |
| 1453 | |
| 1454 | class flow_stats_entry(loxi.OFObject): |
| 1455 | |
| 1456 | def __init__(self, table_id=None, duration_sec=None, duration_nsec=None, priority=None, idle_timeout=None, hard_timeout=None, flags=None, importance=None, cookie=None, packet_count=None, byte_count=None, match=None, instructions=None): |
| 1457 | if table_id != None: |
| 1458 | self.table_id = table_id |
| 1459 | else: |
| 1460 | self.table_id = 0 |
| 1461 | if duration_sec != None: |
| 1462 | self.duration_sec = duration_sec |
| 1463 | else: |
| 1464 | self.duration_sec = 0 |
| 1465 | if duration_nsec != None: |
| 1466 | self.duration_nsec = duration_nsec |
| 1467 | else: |
| 1468 | self.duration_nsec = 0 |
| 1469 | if priority != None: |
| 1470 | self.priority = priority |
| 1471 | else: |
| 1472 | self.priority = 0 |
| 1473 | if idle_timeout != None: |
| 1474 | self.idle_timeout = idle_timeout |
| 1475 | else: |
| 1476 | self.idle_timeout = 0 |
| 1477 | if hard_timeout != None: |
| 1478 | self.hard_timeout = hard_timeout |
| 1479 | else: |
| 1480 | self.hard_timeout = 0 |
| 1481 | if flags != None: |
| 1482 | self.flags = flags |
| 1483 | else: |
| 1484 | self.flags = 0 |
| 1485 | if importance != None: |
| 1486 | self.importance = importance |
| 1487 | else: |
| 1488 | self.importance = 0 |
| 1489 | if cookie != None: |
| 1490 | self.cookie = cookie |
| 1491 | else: |
| 1492 | self.cookie = 0 |
| 1493 | if packet_count != None: |
| 1494 | self.packet_count = packet_count |
| 1495 | else: |
| 1496 | self.packet_count = 0 |
| 1497 | if byte_count != None: |
| 1498 | self.byte_count = byte_count |
| 1499 | else: |
| 1500 | self.byte_count = 0 |
| 1501 | if match != None: |
| 1502 | self.match = match |
| 1503 | else: |
| 1504 | self.match = common.match() |
| 1505 | if instructions != None: |
| 1506 | self.instructions = instructions |
| 1507 | else: |
| 1508 | self.instructions = [] |
| 1509 | return |
| 1510 | |
| 1511 | def pack(self): |
| 1512 | packed = [] |
| 1513 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 1514 | packed.append(struct.pack("!B", self.table_id)) |
| 1515 | packed.append('\x00' * 1) |
| 1516 | packed.append(struct.pack("!L", self.duration_sec)) |
| 1517 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 1518 | packed.append(struct.pack("!H", self.priority)) |
| 1519 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 1520 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 1521 | packed.append(struct.pack("!H", self.flags)) |
| 1522 | packed.append(struct.pack("!H", self.importance)) |
| 1523 | packed.append('\x00' * 2) |
| 1524 | packed.append(struct.pack("!Q", self.cookie)) |
| 1525 | packed.append(struct.pack("!Q", self.packet_count)) |
| 1526 | packed.append(struct.pack("!Q", self.byte_count)) |
| 1527 | packed.append(self.match.pack()) |
| 1528 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
| 1529 | length = sum([len(x) for x in packed]) |
| 1530 | packed[0] = struct.pack("!H", length) |
| 1531 | return ''.join(packed) |
| 1532 | |
| 1533 | @staticmethod |
| 1534 | def unpack(reader): |
| 1535 | obj = flow_stats_entry() |
| 1536 | _length = reader.read("!H")[0] |
| 1537 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1538 | reader = orig_reader.slice(_length, 2) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 1539 | obj.table_id = reader.read("!B")[0] |
| 1540 | reader.skip(1) |
| 1541 | obj.duration_sec = reader.read("!L")[0] |
| 1542 | obj.duration_nsec = reader.read("!L")[0] |
| 1543 | obj.priority = reader.read("!H")[0] |
| 1544 | obj.idle_timeout = reader.read("!H")[0] |
| 1545 | obj.hard_timeout = reader.read("!H")[0] |
| 1546 | obj.flags = reader.read("!H")[0] |
| 1547 | obj.importance = reader.read("!H")[0] |
| 1548 | reader.skip(2) |
| 1549 | obj.cookie = reader.read("!Q")[0] |
| 1550 | obj.packet_count = reader.read("!Q")[0] |
| 1551 | obj.byte_count = reader.read("!Q")[0] |
| 1552 | obj.match = common.match.unpack(reader) |
| 1553 | obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack) |
| 1554 | return obj |
| 1555 | |
| 1556 | def __eq__(self, other): |
| 1557 | if type(self) != type(other): return False |
| 1558 | if self.table_id != other.table_id: return False |
| 1559 | if self.duration_sec != other.duration_sec: return False |
| 1560 | if self.duration_nsec != other.duration_nsec: return False |
| 1561 | if self.priority != other.priority: return False |
| 1562 | if self.idle_timeout != other.idle_timeout: return False |
| 1563 | if self.hard_timeout != other.hard_timeout: return False |
| 1564 | if self.flags != other.flags: return False |
| 1565 | if self.importance != other.importance: return False |
| 1566 | if self.cookie != other.cookie: return False |
| 1567 | if self.packet_count != other.packet_count: return False |
| 1568 | if self.byte_count != other.byte_count: return False |
| 1569 | if self.match != other.match: return False |
| 1570 | if self.instructions != other.instructions: return False |
| 1571 | return True |
| 1572 | |
| 1573 | def pretty_print(self, q): |
| 1574 | q.text("flow_stats_entry {") |
| 1575 | with q.group(): |
| 1576 | with q.indent(2): |
| 1577 | q.breakable() |
| 1578 | q.text("table_id = "); |
| 1579 | q.text("%#x" % self.table_id) |
| 1580 | q.text(","); q.breakable() |
| 1581 | q.text("duration_sec = "); |
| 1582 | q.text("%#x" % self.duration_sec) |
| 1583 | q.text(","); q.breakable() |
| 1584 | q.text("duration_nsec = "); |
| 1585 | q.text("%#x" % self.duration_nsec) |
| 1586 | q.text(","); q.breakable() |
| 1587 | q.text("priority = "); |
| 1588 | q.text("%#x" % self.priority) |
| 1589 | q.text(","); q.breakable() |
| 1590 | q.text("idle_timeout = "); |
| 1591 | q.text("%#x" % self.idle_timeout) |
| 1592 | q.text(","); q.breakable() |
| 1593 | q.text("hard_timeout = "); |
| 1594 | q.text("%#x" % self.hard_timeout) |
| 1595 | q.text(","); q.breakable() |
| 1596 | q.text("flags = "); |
| 1597 | q.text("%#x" % self.flags) |
| 1598 | q.text(","); q.breakable() |
| 1599 | q.text("importance = "); |
| 1600 | q.text("%#x" % self.importance) |
| 1601 | q.text(","); q.breakable() |
| 1602 | q.text("cookie = "); |
| 1603 | q.text("%#x" % self.cookie) |
| 1604 | q.text(","); q.breakable() |
| 1605 | q.text("packet_count = "); |
| 1606 | q.text("%#x" % self.packet_count) |
| 1607 | q.text(","); q.breakable() |
| 1608 | q.text("byte_count = "); |
| 1609 | q.text("%#x" % self.byte_count) |
| 1610 | q.text(","); q.breakable() |
| 1611 | q.text("match = "); |
| 1612 | q.pp(self.match) |
| 1613 | q.text(","); q.breakable() |
| 1614 | q.text("instructions = "); |
| 1615 | q.pp(self.instructions) |
| 1616 | q.breakable() |
| 1617 | q.text('}') |
| 1618 | |
| 1619 | |
| 1620 | class group_desc_stats_entry(loxi.OFObject): |
| 1621 | |
| 1622 | def __init__(self, group_type=None, group_id=None, buckets=None): |
| 1623 | if group_type != None: |
| 1624 | self.group_type = group_type |
| 1625 | else: |
| 1626 | self.group_type = 0 |
| 1627 | if group_id != None: |
| 1628 | self.group_id = group_id |
| 1629 | else: |
| 1630 | self.group_id = 0 |
| 1631 | if buckets != None: |
| 1632 | self.buckets = buckets |
| 1633 | else: |
| 1634 | self.buckets = [] |
| 1635 | return |
| 1636 | |
| 1637 | def pack(self): |
| 1638 | packed = [] |
| 1639 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 1640 | packed.append(struct.pack("!B", self.group_type)) |
| 1641 | packed.append('\x00' * 1) |
| 1642 | packed.append(struct.pack("!L", self.group_id)) |
| 1643 | packed.append(loxi.generic_util.pack_list(self.buckets)) |
| 1644 | length = sum([len(x) for x in packed]) |
| 1645 | packed[0] = struct.pack("!H", length) |
| 1646 | return ''.join(packed) |
| 1647 | |
| 1648 | @staticmethod |
| 1649 | def unpack(reader): |
| 1650 | obj = group_desc_stats_entry() |
| 1651 | _length = reader.read("!H")[0] |
| 1652 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1653 | reader = orig_reader.slice(_length, 2) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 1654 | obj.group_type = reader.read("!B")[0] |
| 1655 | reader.skip(1) |
| 1656 | obj.group_id = reader.read("!L")[0] |
| 1657 | obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack) |
| 1658 | return obj |
| 1659 | |
| 1660 | def __eq__(self, other): |
| 1661 | if type(self) != type(other): return False |
| 1662 | if self.group_type != other.group_type: return False |
| 1663 | if self.group_id != other.group_id: return False |
| 1664 | if self.buckets != other.buckets: return False |
| 1665 | return True |
| 1666 | |
| 1667 | def pretty_print(self, q): |
| 1668 | q.text("group_desc_stats_entry {") |
| 1669 | with q.group(): |
| 1670 | with q.indent(2): |
| 1671 | q.breakable() |
| 1672 | q.text("group_type = "); |
| 1673 | q.text("%#x" % self.group_type) |
| 1674 | q.text(","); q.breakable() |
| 1675 | q.text("group_id = "); |
| 1676 | q.text("%#x" % self.group_id) |
| 1677 | q.text(","); q.breakable() |
| 1678 | q.text("buckets = "); |
| 1679 | q.pp(self.buckets) |
| 1680 | q.breakable() |
| 1681 | q.text('}') |
| 1682 | |
| 1683 | |
| 1684 | class group_stats_entry(loxi.OFObject): |
| 1685 | |
| 1686 | def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, duration_sec=None, duration_nsec=None, bucket_stats=None): |
| 1687 | if group_id != None: |
| 1688 | self.group_id = group_id |
| 1689 | else: |
| 1690 | self.group_id = 0 |
| 1691 | if ref_count != None: |
| 1692 | self.ref_count = ref_count |
| 1693 | else: |
| 1694 | self.ref_count = 0 |
| 1695 | if packet_count != None: |
| 1696 | self.packet_count = packet_count |
| 1697 | else: |
| 1698 | self.packet_count = 0 |
| 1699 | if byte_count != None: |
| 1700 | self.byte_count = byte_count |
| 1701 | else: |
| 1702 | self.byte_count = 0 |
| 1703 | if duration_sec != None: |
| 1704 | self.duration_sec = duration_sec |
| 1705 | else: |
| 1706 | self.duration_sec = 0 |
| 1707 | if duration_nsec != None: |
| 1708 | self.duration_nsec = duration_nsec |
| 1709 | else: |
| 1710 | self.duration_nsec = 0 |
| 1711 | if bucket_stats != None: |
| 1712 | self.bucket_stats = bucket_stats |
| 1713 | else: |
| 1714 | self.bucket_stats = [] |
| 1715 | return |
| 1716 | |
| 1717 | def pack(self): |
| 1718 | packed = [] |
| 1719 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 1720 | packed.append('\x00' * 2) |
| 1721 | packed.append(struct.pack("!L", self.group_id)) |
| 1722 | packed.append(struct.pack("!L", self.ref_count)) |
| 1723 | packed.append('\x00' * 4) |
| 1724 | packed.append(struct.pack("!Q", self.packet_count)) |
| 1725 | packed.append(struct.pack("!Q", self.byte_count)) |
| 1726 | packed.append(struct.pack("!L", self.duration_sec)) |
| 1727 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 1728 | packed.append(loxi.generic_util.pack_list(self.bucket_stats)) |
| 1729 | length = sum([len(x) for x in packed]) |
| 1730 | packed[0] = struct.pack("!H", length) |
| 1731 | return ''.join(packed) |
| 1732 | |
| 1733 | @staticmethod |
| 1734 | def unpack(reader): |
| 1735 | obj = group_stats_entry() |
| 1736 | _length = reader.read("!H")[0] |
| 1737 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1738 | reader = orig_reader.slice(_length, 2) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 1739 | reader.skip(2) |
| 1740 | obj.group_id = reader.read("!L")[0] |
| 1741 | obj.ref_count = reader.read("!L")[0] |
| 1742 | reader.skip(4) |
| 1743 | obj.packet_count = reader.read("!Q")[0] |
| 1744 | obj.byte_count = reader.read("!Q")[0] |
| 1745 | obj.duration_sec = reader.read("!L")[0] |
| 1746 | obj.duration_nsec = reader.read("!L")[0] |
| 1747 | obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack) |
| 1748 | return obj |
| 1749 | |
| 1750 | def __eq__(self, other): |
| 1751 | if type(self) != type(other): return False |
| 1752 | if self.group_id != other.group_id: return False |
| 1753 | if self.ref_count != other.ref_count: return False |
| 1754 | if self.packet_count != other.packet_count: return False |
| 1755 | if self.byte_count != other.byte_count: return False |
| 1756 | if self.duration_sec != other.duration_sec: return False |
| 1757 | if self.duration_nsec != other.duration_nsec: return False |
| 1758 | if self.bucket_stats != other.bucket_stats: return False |
| 1759 | return True |
| 1760 | |
| 1761 | def pretty_print(self, q): |
| 1762 | q.text("group_stats_entry {") |
| 1763 | with q.group(): |
| 1764 | with q.indent(2): |
| 1765 | q.breakable() |
| 1766 | q.text("group_id = "); |
| 1767 | q.text("%#x" % self.group_id) |
| 1768 | q.text(","); q.breakable() |
| 1769 | q.text("ref_count = "); |
| 1770 | q.text("%#x" % self.ref_count) |
| 1771 | q.text(","); q.breakable() |
| 1772 | q.text("packet_count = "); |
| 1773 | q.text("%#x" % self.packet_count) |
| 1774 | q.text(","); q.breakable() |
| 1775 | q.text("byte_count = "); |
| 1776 | q.text("%#x" % self.byte_count) |
| 1777 | q.text(","); q.breakable() |
| 1778 | q.text("duration_sec = "); |
| 1779 | q.text("%#x" % self.duration_sec) |
| 1780 | q.text(","); q.breakable() |
| 1781 | q.text("duration_nsec = "); |
| 1782 | q.text("%#x" % self.duration_nsec) |
| 1783 | q.text(","); q.breakable() |
| 1784 | q.text("bucket_stats = "); |
| 1785 | q.pp(self.bucket_stats) |
| 1786 | q.breakable() |
| 1787 | q.text('}') |
| 1788 | |
| 1789 | |
| 1790 | class hello_elem(loxi.OFObject): |
| 1791 | subtypes = {} |
| 1792 | |
| 1793 | |
| 1794 | def __init__(self, type=None): |
| 1795 | if type != None: |
| 1796 | self.type = type |
| 1797 | else: |
| 1798 | self.type = 0 |
| 1799 | return |
| 1800 | |
| 1801 | def pack(self): |
| 1802 | packed = [] |
| 1803 | packed.append(struct.pack("!H", self.type)) |
| 1804 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 1805 | length = sum([len(x) for x in packed]) |
| 1806 | packed[1] = struct.pack("!H", length) |
| 1807 | return ''.join(packed) |
| 1808 | |
| 1809 | @staticmethod |
| 1810 | def unpack(reader): |
| 1811 | subtype, = reader.peek('!H', 0) |
| 1812 | subclass = hello_elem.subtypes.get(subtype) |
| 1813 | if subclass: |
| 1814 | return subclass.unpack(reader) |
| 1815 | |
| 1816 | obj = hello_elem() |
| 1817 | obj.type = reader.read("!H")[0] |
| 1818 | _length = reader.read("!H")[0] |
| 1819 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1820 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 1821 | return obj |
| 1822 | |
| 1823 | def __eq__(self, other): |
| 1824 | if type(self) != type(other): return False |
| 1825 | if self.type != other.type: return False |
| 1826 | return True |
| 1827 | |
| 1828 | def pretty_print(self, q): |
| 1829 | q.text("hello_elem {") |
| 1830 | with q.group(): |
| 1831 | with q.indent(2): |
| 1832 | q.breakable() |
| 1833 | q.breakable() |
| 1834 | q.text('}') |
| 1835 | |
| 1836 | |
| 1837 | class hello_elem_versionbitmap(hello_elem): |
| 1838 | type = 1 |
| 1839 | |
| 1840 | def __init__(self, bitmaps=None): |
| 1841 | if bitmaps != None: |
| 1842 | self.bitmaps = bitmaps |
| 1843 | else: |
| 1844 | self.bitmaps = [] |
| 1845 | return |
| 1846 | |
| 1847 | def pack(self): |
| 1848 | packed = [] |
| 1849 | packed.append(struct.pack("!H", self.type)) |
| 1850 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 1851 | packed.append(loxi.generic_util.pack_list(self.bitmaps)) |
| 1852 | length = sum([len(x) for x in packed]) |
| 1853 | packed[1] = struct.pack("!H", length) |
| 1854 | return ''.join(packed) |
| 1855 | |
| 1856 | @staticmethod |
| 1857 | def unpack(reader): |
| 1858 | obj = hello_elem_versionbitmap() |
| 1859 | _type = reader.read("!H")[0] |
| 1860 | assert(_type == 1) |
| 1861 | _length = reader.read("!H")[0] |
| 1862 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1863 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 1864 | obj.bitmaps = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 1865 | return obj |
| 1866 | |
| 1867 | def __eq__(self, other): |
| 1868 | if type(self) != type(other): return False |
| 1869 | if self.bitmaps != other.bitmaps: return False |
| 1870 | return True |
| 1871 | |
| 1872 | def pretty_print(self, q): |
| 1873 | q.text("hello_elem_versionbitmap {") |
| 1874 | with q.group(): |
| 1875 | with q.indent(2): |
| 1876 | q.breakable() |
| 1877 | q.text("bitmaps = "); |
| 1878 | q.pp(self.bitmaps) |
| 1879 | q.breakable() |
| 1880 | q.text('}') |
| 1881 | |
| 1882 | hello_elem.subtypes[1] = hello_elem_versionbitmap |
| 1883 | |
| 1884 | class match_v3(loxi.OFObject): |
| 1885 | type = 1 |
| 1886 | |
| 1887 | def __init__(self, oxm_list=None): |
| 1888 | if oxm_list != None: |
| 1889 | self.oxm_list = oxm_list |
| 1890 | else: |
| 1891 | self.oxm_list = [] |
| 1892 | return |
| 1893 | |
| 1894 | def pack(self): |
| 1895 | packed = [] |
| 1896 | packed.append(struct.pack("!H", self.type)) |
| 1897 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 1898 | packed.append(loxi.generic_util.pack_list(self.oxm_list)) |
| 1899 | length = sum([len(x) for x in packed]) |
| 1900 | packed[1] = struct.pack("!H", length) |
| 1901 | packed.append(loxi.generic_util.pad_to(8, length)) |
| 1902 | return ''.join(packed) |
| 1903 | |
| 1904 | @staticmethod |
| 1905 | def unpack(reader): |
| 1906 | obj = match_v3() |
| 1907 | _type = reader.read("!H")[0] |
| 1908 | assert(_type == 1) |
| 1909 | _length = reader.read("!H")[0] |
| 1910 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1911 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 1912 | obj.oxm_list = loxi.generic_util.unpack_list(reader, oxm.oxm.unpack) |
| 1913 | orig_reader.skip_align() |
| 1914 | return obj |
| 1915 | |
| 1916 | def __eq__(self, other): |
| 1917 | if type(self) != type(other): return False |
| 1918 | if self.oxm_list != other.oxm_list: return False |
| 1919 | return True |
| 1920 | |
| 1921 | def pretty_print(self, q): |
| 1922 | q.text("match_v3 {") |
| 1923 | with q.group(): |
| 1924 | with q.indent(2): |
| 1925 | q.breakable() |
| 1926 | q.text("oxm_list = "); |
| 1927 | q.pp(self.oxm_list) |
| 1928 | q.breakable() |
| 1929 | q.text('}') |
| 1930 | |
| 1931 | |
| 1932 | class meter_band_stats(loxi.OFObject): |
| 1933 | |
| 1934 | def __init__(self, packet_band_count=None, byte_band_count=None): |
| 1935 | if packet_band_count != None: |
| 1936 | self.packet_band_count = packet_band_count |
| 1937 | else: |
| 1938 | self.packet_band_count = 0 |
| 1939 | if byte_band_count != None: |
| 1940 | self.byte_band_count = byte_band_count |
| 1941 | else: |
| 1942 | self.byte_band_count = 0 |
| 1943 | return |
| 1944 | |
| 1945 | def pack(self): |
| 1946 | packed = [] |
| 1947 | packed.append(struct.pack("!Q", self.packet_band_count)) |
| 1948 | packed.append(struct.pack("!Q", self.byte_band_count)) |
| 1949 | return ''.join(packed) |
| 1950 | |
| 1951 | @staticmethod |
| 1952 | def unpack(reader): |
| 1953 | obj = meter_band_stats() |
| 1954 | obj.packet_band_count = reader.read("!Q")[0] |
| 1955 | obj.byte_band_count = reader.read("!Q")[0] |
| 1956 | return obj |
| 1957 | |
| 1958 | def __eq__(self, other): |
| 1959 | if type(self) != type(other): return False |
| 1960 | if self.packet_band_count != other.packet_band_count: return False |
| 1961 | if self.byte_band_count != other.byte_band_count: return False |
| 1962 | return True |
| 1963 | |
| 1964 | def pretty_print(self, q): |
| 1965 | q.text("meter_band_stats {") |
| 1966 | with q.group(): |
| 1967 | with q.indent(2): |
| 1968 | q.breakable() |
| 1969 | q.text("packet_band_count = "); |
| 1970 | q.text("%#x" % self.packet_band_count) |
| 1971 | q.text(","); q.breakable() |
| 1972 | q.text("byte_band_count = "); |
| 1973 | q.text("%#x" % self.byte_band_count) |
| 1974 | q.breakable() |
| 1975 | q.text('}') |
| 1976 | |
| 1977 | |
| 1978 | class meter_config(loxi.OFObject): |
| 1979 | |
| 1980 | def __init__(self, flags=None, meter_id=None, entries=None): |
| 1981 | if flags != None: |
| 1982 | self.flags = flags |
| 1983 | else: |
| 1984 | self.flags = 0 |
| 1985 | if meter_id != None: |
| 1986 | self.meter_id = meter_id |
| 1987 | else: |
| 1988 | self.meter_id = 0 |
| 1989 | if entries != None: |
| 1990 | self.entries = entries |
| 1991 | else: |
| 1992 | self.entries = [] |
| 1993 | return |
| 1994 | |
| 1995 | def pack(self): |
| 1996 | packed = [] |
| 1997 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 1998 | packed.append(struct.pack("!H", self.flags)) |
| 1999 | packed.append(struct.pack("!L", self.meter_id)) |
| 2000 | packed.append(loxi.generic_util.pack_list(self.entries)) |
| 2001 | length = sum([len(x) for x in packed]) |
| 2002 | packed[0] = struct.pack("!H", length) |
| 2003 | return ''.join(packed) |
| 2004 | |
| 2005 | @staticmethod |
| 2006 | def unpack(reader): |
| 2007 | obj = meter_config() |
| 2008 | _length = reader.read("!H")[0] |
| 2009 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2010 | reader = orig_reader.slice(_length, 2) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 2011 | obj.flags = reader.read("!H")[0] |
| 2012 | obj.meter_id = reader.read("!L")[0] |
| 2013 | obj.entries = loxi.generic_util.unpack_list(reader, meter_band.meter_band.unpack) |
| 2014 | return obj |
| 2015 | |
| 2016 | def __eq__(self, other): |
| 2017 | if type(self) != type(other): return False |
| 2018 | if self.flags != other.flags: return False |
| 2019 | if self.meter_id != other.meter_id: return False |
| 2020 | if self.entries != other.entries: return False |
| 2021 | return True |
| 2022 | |
| 2023 | def pretty_print(self, q): |
| 2024 | q.text("meter_config {") |
| 2025 | with q.group(): |
| 2026 | with q.indent(2): |
| 2027 | q.breakable() |
| 2028 | q.text("flags = "); |
| 2029 | q.text("%#x" % self.flags) |
| 2030 | q.text(","); q.breakable() |
| 2031 | q.text("meter_id = "); |
| 2032 | q.text("%#x" % self.meter_id) |
| 2033 | q.text(","); q.breakable() |
| 2034 | q.text("entries = "); |
| 2035 | q.pp(self.entries) |
| 2036 | q.breakable() |
| 2037 | q.text('}') |
| 2038 | |
| 2039 | |
| 2040 | class meter_features(loxi.OFObject): |
| 2041 | |
| 2042 | def __init__(self, max_meter=None, band_types=None, capabilities=None, max_bands=None, max_color=None): |
| 2043 | if max_meter != None: |
| 2044 | self.max_meter = max_meter |
| 2045 | else: |
| 2046 | self.max_meter = 0 |
| 2047 | if band_types != None: |
| 2048 | self.band_types = band_types |
| 2049 | else: |
| 2050 | self.band_types = 0 |
| 2051 | if capabilities != None: |
| 2052 | self.capabilities = capabilities |
| 2053 | else: |
| 2054 | self.capabilities = 0 |
| 2055 | if max_bands != None: |
| 2056 | self.max_bands = max_bands |
| 2057 | else: |
| 2058 | self.max_bands = 0 |
| 2059 | if max_color != None: |
| 2060 | self.max_color = max_color |
| 2061 | else: |
| 2062 | self.max_color = 0 |
| 2063 | return |
| 2064 | |
| 2065 | def pack(self): |
| 2066 | packed = [] |
| 2067 | packed.append(struct.pack("!L", self.max_meter)) |
| 2068 | packed.append(struct.pack("!L", self.band_types)) |
| 2069 | packed.append(struct.pack("!L", self.capabilities)) |
| 2070 | packed.append(struct.pack("!B", self.max_bands)) |
| 2071 | packed.append(struct.pack("!B", self.max_color)) |
| 2072 | packed.append('\x00' * 2) |
| 2073 | return ''.join(packed) |
| 2074 | |
| 2075 | @staticmethod |
| 2076 | def unpack(reader): |
| 2077 | obj = meter_features() |
| 2078 | obj.max_meter = reader.read("!L")[0] |
| 2079 | obj.band_types = reader.read("!L")[0] |
| 2080 | obj.capabilities = reader.read("!L")[0] |
| 2081 | obj.max_bands = reader.read("!B")[0] |
| 2082 | obj.max_color = reader.read("!B")[0] |
| 2083 | reader.skip(2) |
| 2084 | return obj |
| 2085 | |
| 2086 | def __eq__(self, other): |
| 2087 | if type(self) != type(other): return False |
| 2088 | if self.max_meter != other.max_meter: return False |
| 2089 | if self.band_types != other.band_types: return False |
| 2090 | if self.capabilities != other.capabilities: return False |
| 2091 | if self.max_bands != other.max_bands: return False |
| 2092 | if self.max_color != other.max_color: return False |
| 2093 | return True |
| 2094 | |
| 2095 | def pretty_print(self, q): |
| 2096 | q.text("meter_features {") |
| 2097 | with q.group(): |
| 2098 | with q.indent(2): |
| 2099 | q.breakable() |
| 2100 | q.text("max_meter = "); |
| 2101 | q.text("%#x" % self.max_meter) |
| 2102 | q.text(","); q.breakable() |
| 2103 | q.text("band_types = "); |
| 2104 | q.text("%#x" % self.band_types) |
| 2105 | q.text(","); q.breakable() |
| 2106 | q.text("capabilities = "); |
| 2107 | q.text("%#x" % self.capabilities) |
| 2108 | q.text(","); q.breakable() |
| 2109 | q.text("max_bands = "); |
| 2110 | q.text("%#x" % self.max_bands) |
| 2111 | q.text(","); q.breakable() |
| 2112 | q.text("max_color = "); |
| 2113 | q.text("%#x" % self.max_color) |
| 2114 | q.breakable() |
| 2115 | q.text('}') |
| 2116 | |
| 2117 | |
| 2118 | class meter_stats(loxi.OFObject): |
| 2119 | |
| 2120 | def __init__(self, meter_id=None, flow_count=None, packet_in_count=None, byte_in_count=None, duration_sec=None, duration_nsec=None, band_stats=None): |
| 2121 | if meter_id != None: |
| 2122 | self.meter_id = meter_id |
| 2123 | else: |
| 2124 | self.meter_id = 0 |
| 2125 | if flow_count != None: |
| 2126 | self.flow_count = flow_count |
| 2127 | else: |
| 2128 | self.flow_count = 0 |
| 2129 | if packet_in_count != None: |
| 2130 | self.packet_in_count = packet_in_count |
| 2131 | else: |
| 2132 | self.packet_in_count = 0 |
| 2133 | if byte_in_count != None: |
| 2134 | self.byte_in_count = byte_in_count |
| 2135 | else: |
| 2136 | self.byte_in_count = 0 |
| 2137 | if duration_sec != None: |
| 2138 | self.duration_sec = duration_sec |
| 2139 | else: |
| 2140 | self.duration_sec = 0 |
| 2141 | if duration_nsec != None: |
| 2142 | self.duration_nsec = duration_nsec |
| 2143 | else: |
| 2144 | self.duration_nsec = 0 |
| 2145 | if band_stats != None: |
| 2146 | self.band_stats = band_stats |
| 2147 | else: |
| 2148 | self.band_stats = [] |
| 2149 | return |
| 2150 | |
| 2151 | def pack(self): |
| 2152 | packed = [] |
| 2153 | packed.append(struct.pack("!L", self.meter_id)) |
| 2154 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 2155 | packed.append('\x00' * 6) |
| 2156 | packed.append(struct.pack("!L", self.flow_count)) |
| 2157 | packed.append(struct.pack("!Q", self.packet_in_count)) |
| 2158 | packed.append(struct.pack("!Q", self.byte_in_count)) |
| 2159 | packed.append(struct.pack("!L", self.duration_sec)) |
| 2160 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 2161 | packed.append(loxi.generic_util.pack_list(self.band_stats)) |
| 2162 | length = sum([len(x) for x in packed]) |
| 2163 | packed[1] = struct.pack("!H", length) |
| 2164 | return ''.join(packed) |
| 2165 | |
| 2166 | @staticmethod |
| 2167 | def unpack(reader): |
| 2168 | obj = meter_stats() |
| 2169 | obj.meter_id = reader.read("!L")[0] |
| 2170 | _len = reader.read("!H")[0] |
| 2171 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2172 | reader = orig_reader.slice(_len, 6) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 2173 | reader.skip(6) |
| 2174 | obj.flow_count = reader.read("!L")[0] |
| 2175 | obj.packet_in_count = reader.read("!Q")[0] |
| 2176 | obj.byte_in_count = reader.read("!Q")[0] |
| 2177 | obj.duration_sec = reader.read("!L")[0] |
| 2178 | obj.duration_nsec = reader.read("!L")[0] |
| 2179 | obj.band_stats = loxi.generic_util.unpack_list(reader, common.meter_band_stats.unpack) |
| 2180 | return obj |
| 2181 | |
| 2182 | def __eq__(self, other): |
| 2183 | if type(self) != type(other): return False |
| 2184 | if self.meter_id != other.meter_id: return False |
| 2185 | if self.flow_count != other.flow_count: return False |
| 2186 | if self.packet_in_count != other.packet_in_count: return False |
| 2187 | if self.byte_in_count != other.byte_in_count: return False |
| 2188 | if self.duration_sec != other.duration_sec: return False |
| 2189 | if self.duration_nsec != other.duration_nsec: return False |
| 2190 | if self.band_stats != other.band_stats: return False |
| 2191 | return True |
| 2192 | |
| 2193 | def pretty_print(self, q): |
| 2194 | q.text("meter_stats {") |
| 2195 | with q.group(): |
| 2196 | with q.indent(2): |
| 2197 | q.breakable() |
| 2198 | q.text("meter_id = "); |
| 2199 | q.text("%#x" % self.meter_id) |
| 2200 | q.text(","); q.breakable() |
| 2201 | q.text("flow_count = "); |
| 2202 | q.text("%#x" % self.flow_count) |
| 2203 | q.text(","); q.breakable() |
| 2204 | q.text("packet_in_count = "); |
| 2205 | q.text("%#x" % self.packet_in_count) |
| 2206 | q.text(","); q.breakable() |
| 2207 | q.text("byte_in_count = "); |
| 2208 | q.text("%#x" % self.byte_in_count) |
| 2209 | q.text(","); q.breakable() |
| 2210 | q.text("duration_sec = "); |
| 2211 | q.text("%#x" % self.duration_sec) |
| 2212 | q.text(","); q.breakable() |
| 2213 | q.text("duration_nsec = "); |
| 2214 | q.text("%#x" % self.duration_nsec) |
| 2215 | q.text(","); q.breakable() |
| 2216 | q.text("band_stats = "); |
| 2217 | q.pp(self.band_stats) |
| 2218 | q.breakable() |
| 2219 | q.text('}') |
| 2220 | |
| 2221 | |
| 2222 | class packet_queue(loxi.OFObject): |
| 2223 | |
| 2224 | def __init__(self, queue_id=None, port=None, properties=None): |
| 2225 | if queue_id != None: |
| 2226 | self.queue_id = queue_id |
| 2227 | else: |
| 2228 | self.queue_id = 0 |
| 2229 | if port != None: |
| 2230 | self.port = port |
| 2231 | else: |
| 2232 | self.port = 0 |
| 2233 | if properties != None: |
| 2234 | self.properties = properties |
| 2235 | else: |
| 2236 | self.properties = [] |
| 2237 | return |
| 2238 | |
| 2239 | def pack(self): |
| 2240 | packed = [] |
| 2241 | packed.append(struct.pack("!L", self.queue_id)) |
| 2242 | packed.append(util.pack_port_no(self.port)) |
| 2243 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 2 |
| 2244 | packed.append('\x00' * 6) |
| 2245 | packed.append(loxi.generic_util.pack_list(self.properties)) |
| 2246 | length = sum([len(x) for x in packed]) |
| 2247 | packed[2] = struct.pack("!H", length) |
| 2248 | return ''.join(packed) |
| 2249 | |
| 2250 | @staticmethod |
| 2251 | def unpack(reader): |
| 2252 | obj = packet_queue() |
| 2253 | obj.queue_id = reader.read("!L")[0] |
| 2254 | obj.port = util.unpack_port_no(reader) |
| 2255 | _len = reader.read("!H")[0] |
| 2256 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2257 | reader = orig_reader.slice(_len, 10) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 2258 | reader.skip(6) |
| 2259 | obj.properties = loxi.generic_util.unpack_list(reader, common.queue_prop.unpack) |
| 2260 | return obj |
| 2261 | |
| 2262 | def __eq__(self, other): |
| 2263 | if type(self) != type(other): return False |
| 2264 | if self.queue_id != other.queue_id: return False |
| 2265 | if self.port != other.port: return False |
| 2266 | if self.properties != other.properties: return False |
| 2267 | return True |
| 2268 | |
| 2269 | def pretty_print(self, q): |
| 2270 | q.text("packet_queue {") |
| 2271 | with q.group(): |
| 2272 | with q.indent(2): |
| 2273 | q.breakable() |
| 2274 | q.text("queue_id = "); |
| 2275 | q.text("%#x" % self.queue_id) |
| 2276 | q.text(","); q.breakable() |
| 2277 | q.text("port = "); |
| 2278 | q.text(util.pretty_port(self.port)) |
| 2279 | q.text(","); q.breakable() |
| 2280 | q.text("properties = "); |
| 2281 | q.pp(self.properties) |
| 2282 | q.breakable() |
| 2283 | q.text('}') |
| 2284 | |
| 2285 | |
| 2286 | class port_desc(loxi.OFObject): |
| 2287 | |
| 2288 | def __init__(self, port_no=None, hw_addr=None, name=None, config=None, state=None, properties=None): |
| 2289 | if port_no != None: |
| 2290 | self.port_no = port_no |
| 2291 | else: |
| 2292 | self.port_no = 0 |
| 2293 | if hw_addr != None: |
| 2294 | self.hw_addr = hw_addr |
| 2295 | else: |
| 2296 | self.hw_addr = [0,0,0,0,0,0] |
| 2297 | if name != None: |
| 2298 | self.name = name |
| 2299 | else: |
| 2300 | self.name = "" |
| 2301 | if config != None: |
| 2302 | self.config = config |
| 2303 | else: |
| 2304 | self.config = 0 |
| 2305 | if state != None: |
| 2306 | self.state = state |
| 2307 | else: |
| 2308 | self.state = 0 |
| 2309 | if properties != None: |
| 2310 | self.properties = properties |
| 2311 | else: |
| 2312 | self.properties = [] |
| 2313 | return |
| 2314 | |
| 2315 | def pack(self): |
| 2316 | packed = [] |
| 2317 | packed.append(util.pack_port_no(self.port_no)) |
| 2318 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 2319 | packed.append('\x00' * 2) |
| 2320 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 2321 | packed.append('\x00' * 2) |
| 2322 | packed.append(struct.pack("!16s", self.name)) |
| 2323 | packed.append(struct.pack("!L", self.config)) |
| 2324 | packed.append(struct.pack("!L", self.state)) |
| 2325 | packed.append(loxi.generic_util.pack_list(self.properties)) |
| 2326 | length = sum([len(x) for x in packed]) |
| 2327 | packed[1] = struct.pack("!H", length) |
| 2328 | return ''.join(packed) |
| 2329 | |
| 2330 | @staticmethod |
| 2331 | def unpack(reader): |
| 2332 | obj = port_desc() |
| 2333 | obj.port_no = util.unpack_port_no(reader) |
| 2334 | _length = reader.read("!H")[0] |
| 2335 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2336 | reader = orig_reader.slice(_length, 6) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 2337 | reader.skip(2) |
| 2338 | obj.hw_addr = list(reader.read('!6B')) |
| 2339 | reader.skip(2) |
| 2340 | obj.name = reader.read("!16s")[0].rstrip("\x00") |
| 2341 | obj.config = reader.read("!L")[0] |
| 2342 | obj.state = reader.read("!L")[0] |
| 2343 | obj.properties = loxi.generic_util.unpack_list(reader, port_desc_prop.port_desc_prop.unpack) |
| 2344 | return obj |
| 2345 | |
| 2346 | def __eq__(self, other): |
| 2347 | if type(self) != type(other): return False |
| 2348 | if self.port_no != other.port_no: return False |
| 2349 | if self.hw_addr != other.hw_addr: return False |
| 2350 | if self.name != other.name: return False |
| 2351 | if self.config != other.config: return False |
| 2352 | if self.state != other.state: return False |
| 2353 | if self.properties != other.properties: return False |
| 2354 | return True |
| 2355 | |
| 2356 | def pretty_print(self, q): |
| 2357 | q.text("port_desc {") |
| 2358 | with q.group(): |
| 2359 | with q.indent(2): |
| 2360 | q.breakable() |
| 2361 | q.text("port_no = "); |
| 2362 | q.text(util.pretty_port(self.port_no)) |
| 2363 | q.text(","); q.breakable() |
| 2364 | q.text("hw_addr = "); |
| 2365 | q.text(util.pretty_mac(self.hw_addr)) |
| 2366 | q.text(","); q.breakable() |
| 2367 | q.text("name = "); |
| 2368 | q.pp(self.name) |
| 2369 | q.text(","); q.breakable() |
| 2370 | q.text("config = "); |
| 2371 | q.text("%#x" % self.config) |
| 2372 | q.text(","); q.breakable() |
| 2373 | q.text("state = "); |
| 2374 | q.text("%#x" % self.state) |
| 2375 | q.text(","); q.breakable() |
| 2376 | q.text("properties = "); |
| 2377 | q.pp(self.properties) |
| 2378 | q.breakable() |
| 2379 | q.text('}') |
| 2380 | |
| 2381 | |
| 2382 | class port_stats_entry(loxi.OFObject): |
| 2383 | |
| 2384 | def __init__(self, port_no=None, duration_sec=None, duration_nsec=None, rx_packets=None, tx_packets=None, rx_bytes=None, tx_bytes=None, rx_dropped=None, tx_dropped=None, rx_errors=None, tx_errors=None, properties=None): |
| 2385 | if port_no != None: |
| 2386 | self.port_no = port_no |
| 2387 | else: |
| 2388 | self.port_no = 0 |
| 2389 | if duration_sec != None: |
| 2390 | self.duration_sec = duration_sec |
| 2391 | else: |
| 2392 | self.duration_sec = 0 |
| 2393 | if duration_nsec != None: |
| 2394 | self.duration_nsec = duration_nsec |
| 2395 | else: |
| 2396 | self.duration_nsec = 0 |
| 2397 | if rx_packets != None: |
| 2398 | self.rx_packets = rx_packets |
| 2399 | else: |
| 2400 | self.rx_packets = 0 |
| 2401 | if tx_packets != None: |
| 2402 | self.tx_packets = tx_packets |
| 2403 | else: |
| 2404 | self.tx_packets = 0 |
| 2405 | if rx_bytes != None: |
| 2406 | self.rx_bytes = rx_bytes |
| 2407 | else: |
| 2408 | self.rx_bytes = 0 |
| 2409 | if tx_bytes != None: |
| 2410 | self.tx_bytes = tx_bytes |
| 2411 | else: |
| 2412 | self.tx_bytes = 0 |
| 2413 | if rx_dropped != None: |
| 2414 | self.rx_dropped = rx_dropped |
| 2415 | else: |
| 2416 | self.rx_dropped = 0 |
| 2417 | if tx_dropped != None: |
| 2418 | self.tx_dropped = tx_dropped |
| 2419 | else: |
| 2420 | self.tx_dropped = 0 |
| 2421 | if rx_errors != None: |
| 2422 | self.rx_errors = rx_errors |
| 2423 | else: |
| 2424 | self.rx_errors = 0 |
| 2425 | if tx_errors != None: |
| 2426 | self.tx_errors = tx_errors |
| 2427 | else: |
| 2428 | self.tx_errors = 0 |
| 2429 | if properties != None: |
| 2430 | self.properties = properties |
| 2431 | else: |
| 2432 | self.properties = [] |
| 2433 | return |
| 2434 | |
| 2435 | def pack(self): |
| 2436 | packed = [] |
| 2437 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 2438 | packed.append('\x00' * 2) |
| 2439 | packed.append(util.pack_port_no(self.port_no)) |
| 2440 | packed.append(struct.pack("!L", self.duration_sec)) |
| 2441 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 2442 | packed.append(struct.pack("!Q", self.rx_packets)) |
| 2443 | packed.append(struct.pack("!Q", self.tx_packets)) |
| 2444 | packed.append(struct.pack("!Q", self.rx_bytes)) |
| 2445 | packed.append(struct.pack("!Q", self.tx_bytes)) |
| 2446 | packed.append(struct.pack("!Q", self.rx_dropped)) |
| 2447 | packed.append(struct.pack("!Q", self.tx_dropped)) |
| 2448 | packed.append(struct.pack("!Q", self.rx_errors)) |
| 2449 | packed.append(struct.pack("!Q", self.tx_errors)) |
| 2450 | packed.append(loxi.generic_util.pack_list(self.properties)) |
| 2451 | length = sum([len(x) for x in packed]) |
| 2452 | packed[0] = struct.pack("!H", length) |
| 2453 | return ''.join(packed) |
| 2454 | |
| 2455 | @staticmethod |
| 2456 | def unpack(reader): |
| 2457 | obj = port_stats_entry() |
| 2458 | _length = reader.read("!H")[0] |
| 2459 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2460 | reader = orig_reader.slice(_length, 2) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 2461 | reader.skip(2) |
| 2462 | obj.port_no = util.unpack_port_no(reader) |
| 2463 | obj.duration_sec = reader.read("!L")[0] |
| 2464 | obj.duration_nsec = reader.read("!L")[0] |
| 2465 | obj.rx_packets = reader.read("!Q")[0] |
| 2466 | obj.tx_packets = reader.read("!Q")[0] |
| 2467 | obj.rx_bytes = reader.read("!Q")[0] |
| 2468 | obj.tx_bytes = reader.read("!Q")[0] |
| 2469 | obj.rx_dropped = reader.read("!Q")[0] |
| 2470 | obj.tx_dropped = reader.read("!Q")[0] |
| 2471 | obj.rx_errors = reader.read("!Q")[0] |
| 2472 | obj.tx_errors = reader.read("!Q")[0] |
| 2473 | obj.properties = loxi.generic_util.unpack_list(reader, port_stats_prop.port_stats_prop.unpack) |
| 2474 | return obj |
| 2475 | |
| 2476 | def __eq__(self, other): |
| 2477 | if type(self) != type(other): return False |
| 2478 | if self.port_no != other.port_no: return False |
| 2479 | if self.duration_sec != other.duration_sec: return False |
| 2480 | if self.duration_nsec != other.duration_nsec: return False |
| 2481 | if self.rx_packets != other.rx_packets: return False |
| 2482 | if self.tx_packets != other.tx_packets: return False |
| 2483 | if self.rx_bytes != other.rx_bytes: return False |
| 2484 | if self.tx_bytes != other.tx_bytes: return False |
| 2485 | if self.rx_dropped != other.rx_dropped: return False |
| 2486 | if self.tx_dropped != other.tx_dropped: return False |
| 2487 | if self.rx_errors != other.rx_errors: return False |
| 2488 | if self.tx_errors != other.tx_errors: return False |
| 2489 | if self.properties != other.properties: return False |
| 2490 | return True |
| 2491 | |
| 2492 | def pretty_print(self, q): |
| 2493 | q.text("port_stats_entry {") |
| 2494 | with q.group(): |
| 2495 | with q.indent(2): |
| 2496 | q.breakable() |
| 2497 | q.text("port_no = "); |
| 2498 | q.text(util.pretty_port(self.port_no)) |
| 2499 | q.text(","); q.breakable() |
| 2500 | q.text("duration_sec = "); |
| 2501 | q.text("%#x" % self.duration_sec) |
| 2502 | q.text(","); q.breakable() |
| 2503 | q.text("duration_nsec = "); |
| 2504 | q.text("%#x" % self.duration_nsec) |
| 2505 | q.text(","); q.breakable() |
| 2506 | q.text("rx_packets = "); |
| 2507 | q.text("%#x" % self.rx_packets) |
| 2508 | q.text(","); q.breakable() |
| 2509 | q.text("tx_packets = "); |
| 2510 | q.text("%#x" % self.tx_packets) |
| 2511 | q.text(","); q.breakable() |
| 2512 | q.text("rx_bytes = "); |
| 2513 | q.text("%#x" % self.rx_bytes) |
| 2514 | q.text(","); q.breakable() |
| 2515 | q.text("tx_bytes = "); |
| 2516 | q.text("%#x" % self.tx_bytes) |
| 2517 | q.text(","); q.breakable() |
| 2518 | q.text("rx_dropped = "); |
| 2519 | q.text("%#x" % self.rx_dropped) |
| 2520 | q.text(","); q.breakable() |
| 2521 | q.text("tx_dropped = "); |
| 2522 | q.text("%#x" % self.tx_dropped) |
| 2523 | q.text(","); q.breakable() |
| 2524 | q.text("rx_errors = "); |
| 2525 | q.text("%#x" % self.rx_errors) |
| 2526 | q.text(","); q.breakable() |
| 2527 | q.text("tx_errors = "); |
| 2528 | q.text("%#x" % self.tx_errors) |
| 2529 | q.text(","); q.breakable() |
| 2530 | q.text("properties = "); |
| 2531 | q.pp(self.properties) |
| 2532 | q.breakable() |
| 2533 | q.text('}') |
| 2534 | |
| 2535 | |
| 2536 | class queue_desc(loxi.OFObject): |
| 2537 | |
| 2538 | def __init__(self, port_no=None, queue_id=None, properties=None): |
| 2539 | if port_no != None: |
| 2540 | self.port_no = port_no |
| 2541 | else: |
| 2542 | self.port_no = 0 |
| 2543 | if queue_id != None: |
| 2544 | self.queue_id = queue_id |
| 2545 | else: |
| 2546 | self.queue_id = 0 |
| 2547 | if properties != None: |
| 2548 | self.properties = properties |
| 2549 | else: |
| 2550 | self.properties = [] |
| 2551 | return |
| 2552 | |
| 2553 | def pack(self): |
| 2554 | packed = [] |
| 2555 | packed.append(struct.pack("!L", self.port_no)) |
| 2556 | packed.append(struct.pack("!L", self.queue_id)) |
| 2557 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2558 | packed.append('\x00' * 6) |
| 2559 | packed.append(loxi.generic_util.pack_list(self.properties)) |
| 2560 | length = sum([len(x) for x in packed]) |
| 2561 | packed[2] = struct.pack("!H", length) |
| 2562 | return ''.join(packed) |
| 2563 | |
| 2564 | @staticmethod |
| 2565 | def unpack(reader): |
| 2566 | obj = queue_desc() |
| 2567 | obj.port_no = reader.read("!L")[0] |
| 2568 | obj.queue_id = reader.read("!L")[0] |
| 2569 | _length = reader.read("!H")[0] |
| 2570 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2571 | reader = orig_reader.slice(_length, 10) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 2572 | reader.skip(6) |
| 2573 | obj.properties = loxi.generic_util.unpack_list(reader, queue_desc_prop.queue_desc_prop.unpack) |
| 2574 | return obj |
| 2575 | |
| 2576 | def __eq__(self, other): |
| 2577 | if type(self) != type(other): return False |
| 2578 | if self.port_no != other.port_no: return False |
| 2579 | if self.queue_id != other.queue_id: return False |
| 2580 | if self.properties != other.properties: return False |
| 2581 | return True |
| 2582 | |
| 2583 | def pretty_print(self, q): |
| 2584 | q.text("queue_desc {") |
| 2585 | with q.group(): |
| 2586 | with q.indent(2): |
| 2587 | q.breakable() |
| 2588 | q.text("port_no = "); |
| 2589 | q.text("%#x" % self.port_no) |
| 2590 | q.text(","); q.breakable() |
| 2591 | q.text("queue_id = "); |
| 2592 | q.text("%#x" % self.queue_id) |
| 2593 | q.text(","); q.breakable() |
| 2594 | q.text("properties = "); |
| 2595 | q.pp(self.properties) |
| 2596 | q.breakable() |
| 2597 | q.text('}') |
| 2598 | |
| 2599 | |
| 2600 | class queue_prop(loxi.OFObject): |
| 2601 | subtypes = {} |
| 2602 | |
| 2603 | |
| 2604 | def __init__(self, type=None): |
| 2605 | if type != None: |
| 2606 | self.type = type |
| 2607 | else: |
| 2608 | self.type = 0 |
| 2609 | return |
| 2610 | |
| 2611 | def pack(self): |
| 2612 | packed = [] |
| 2613 | packed.append(struct.pack("!H", self.type)) |
| 2614 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 2615 | packed.append('\x00' * 4) |
| 2616 | length = sum([len(x) for x in packed]) |
| 2617 | packed[1] = struct.pack("!H", length) |
| 2618 | return ''.join(packed) |
| 2619 | |
| 2620 | @staticmethod |
| 2621 | def unpack(reader): |
| 2622 | subtype, = reader.peek('!H', 0) |
| 2623 | subclass = queue_prop.subtypes.get(subtype) |
| 2624 | if subclass: |
| 2625 | return subclass.unpack(reader) |
| 2626 | |
| 2627 | obj = queue_prop() |
| 2628 | obj.type = reader.read("!H")[0] |
| 2629 | _len = reader.read("!H")[0] |
| 2630 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2631 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 2632 | reader.skip(4) |
| 2633 | return obj |
| 2634 | |
| 2635 | def __eq__(self, other): |
| 2636 | if type(self) != type(other): return False |
| 2637 | if self.type != other.type: return False |
| 2638 | return True |
| 2639 | |
| 2640 | def pretty_print(self, q): |
| 2641 | q.text("queue_prop {") |
| 2642 | with q.group(): |
| 2643 | with q.indent(2): |
| 2644 | q.breakable() |
| 2645 | q.breakable() |
| 2646 | q.text('}') |
| 2647 | |
| 2648 | |
| 2649 | class queue_prop_experimenter(queue_prop): |
| 2650 | subtypes = {} |
| 2651 | |
| 2652 | type = 65535 |
| 2653 | |
| 2654 | def __init__(self, experimenter=None, data=None): |
| 2655 | if experimenter != None: |
| 2656 | self.experimenter = experimenter |
| 2657 | else: |
| 2658 | self.experimenter = 0 |
| 2659 | if data != None: |
| 2660 | self.data = data |
| 2661 | else: |
| 2662 | self.data = '' |
| 2663 | return |
| 2664 | |
| 2665 | def pack(self): |
| 2666 | packed = [] |
| 2667 | packed.append(struct.pack("!H", self.type)) |
| 2668 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 2669 | packed.append('\x00' * 4) |
| 2670 | packed.append(struct.pack("!L", self.experimenter)) |
| 2671 | packed.append('\x00' * 4) |
| 2672 | packed.append(self.data) |
| 2673 | length = sum([len(x) for x in packed]) |
| 2674 | packed[1] = struct.pack("!H", length) |
| 2675 | return ''.join(packed) |
| 2676 | |
| 2677 | @staticmethod |
| 2678 | def unpack(reader): |
| 2679 | subtype, = reader.peek('!L', 8) |
| 2680 | subclass = queue_prop_experimenter.subtypes.get(subtype) |
| 2681 | if subclass: |
| 2682 | return subclass.unpack(reader) |
| 2683 | |
| 2684 | obj = queue_prop_experimenter() |
| 2685 | _type = reader.read("!H")[0] |
| 2686 | assert(_type == 65535) |
| 2687 | _len = reader.read("!H")[0] |
| 2688 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2689 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 2690 | reader.skip(4) |
| 2691 | obj.experimenter = reader.read("!L")[0] |
| 2692 | reader.skip(4) |
| 2693 | obj.data = str(reader.read_all()) |
| 2694 | return obj |
| 2695 | |
| 2696 | def __eq__(self, other): |
| 2697 | if type(self) != type(other): return False |
| 2698 | if self.experimenter != other.experimenter: return False |
| 2699 | if self.data != other.data: return False |
| 2700 | return True |
| 2701 | |
| 2702 | def pretty_print(self, q): |
| 2703 | q.text("queue_prop_experimenter {") |
| 2704 | with q.group(): |
| 2705 | with q.indent(2): |
| 2706 | q.breakable() |
| 2707 | q.text("data = "); |
| 2708 | q.pp(self.data) |
| 2709 | q.breakable() |
| 2710 | q.text('}') |
| 2711 | |
| 2712 | queue_prop.subtypes[65535] = queue_prop_experimenter |
| 2713 | |
| 2714 | class queue_prop_max_rate(queue_prop): |
| 2715 | type = 2 |
| 2716 | |
| 2717 | def __init__(self, rate=None): |
| 2718 | if rate != None: |
| 2719 | self.rate = rate |
| 2720 | else: |
| 2721 | self.rate = 0 |
| 2722 | return |
| 2723 | |
| 2724 | def pack(self): |
| 2725 | packed = [] |
| 2726 | packed.append(struct.pack("!H", self.type)) |
| 2727 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 2728 | packed.append('\x00' * 4) |
| 2729 | packed.append(struct.pack("!H", self.rate)) |
| 2730 | packed.append('\x00' * 6) |
| 2731 | length = sum([len(x) for x in packed]) |
| 2732 | packed[1] = struct.pack("!H", length) |
| 2733 | return ''.join(packed) |
| 2734 | |
| 2735 | @staticmethod |
| 2736 | def unpack(reader): |
| 2737 | obj = queue_prop_max_rate() |
| 2738 | _type = reader.read("!H")[0] |
| 2739 | assert(_type == 2) |
| 2740 | _len = reader.read("!H")[0] |
| 2741 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2742 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 2743 | reader.skip(4) |
| 2744 | obj.rate = reader.read("!H")[0] |
| 2745 | reader.skip(6) |
| 2746 | return obj |
| 2747 | |
| 2748 | def __eq__(self, other): |
| 2749 | if type(self) != type(other): return False |
| 2750 | if self.rate != other.rate: return False |
| 2751 | return True |
| 2752 | |
| 2753 | def pretty_print(self, q): |
| 2754 | q.text("queue_prop_max_rate {") |
| 2755 | with q.group(): |
| 2756 | with q.indent(2): |
| 2757 | q.breakable() |
| 2758 | q.text("rate = "); |
| 2759 | q.text("%#x" % self.rate) |
| 2760 | q.breakable() |
| 2761 | q.text('}') |
| 2762 | |
| 2763 | queue_prop.subtypes[2] = queue_prop_max_rate |
| 2764 | |
| 2765 | class queue_prop_min_rate(queue_prop): |
| 2766 | type = 1 |
| 2767 | |
| 2768 | def __init__(self, rate=None): |
| 2769 | if rate != None: |
| 2770 | self.rate = rate |
| 2771 | else: |
| 2772 | self.rate = 0 |
| 2773 | return |
| 2774 | |
| 2775 | def pack(self): |
| 2776 | packed = [] |
| 2777 | packed.append(struct.pack("!H", self.type)) |
| 2778 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 2779 | packed.append('\x00' * 4) |
| 2780 | packed.append(struct.pack("!H", self.rate)) |
| 2781 | packed.append('\x00' * 6) |
| 2782 | length = sum([len(x) for x in packed]) |
| 2783 | packed[1] = struct.pack("!H", length) |
| 2784 | return ''.join(packed) |
| 2785 | |
| 2786 | @staticmethod |
| 2787 | def unpack(reader): |
| 2788 | obj = queue_prop_min_rate() |
| 2789 | _type = reader.read("!H")[0] |
| 2790 | assert(_type == 1) |
| 2791 | _len = reader.read("!H")[0] |
| 2792 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2793 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 2794 | reader.skip(4) |
| 2795 | obj.rate = reader.read("!H")[0] |
| 2796 | reader.skip(6) |
| 2797 | return obj |
| 2798 | |
| 2799 | def __eq__(self, other): |
| 2800 | if type(self) != type(other): return False |
| 2801 | if self.rate != other.rate: return False |
| 2802 | return True |
| 2803 | |
| 2804 | def pretty_print(self, q): |
| 2805 | q.text("queue_prop_min_rate {") |
| 2806 | with q.group(): |
| 2807 | with q.indent(2): |
| 2808 | q.breakable() |
| 2809 | q.text("rate = "); |
| 2810 | q.text("%#x" % self.rate) |
| 2811 | q.breakable() |
| 2812 | q.text('}') |
| 2813 | |
| 2814 | queue_prop.subtypes[1] = queue_prop_min_rate |
| 2815 | |
| 2816 | class queue_stats_entry(loxi.OFObject): |
| 2817 | |
| 2818 | def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None, duration_sec=None, duration_nsec=None, properties=None): |
| 2819 | if port_no != None: |
| 2820 | self.port_no = port_no |
| 2821 | else: |
| 2822 | self.port_no = 0 |
| 2823 | if queue_id != None: |
| 2824 | self.queue_id = queue_id |
| 2825 | else: |
| 2826 | self.queue_id = 0 |
| 2827 | if tx_bytes != None: |
| 2828 | self.tx_bytes = tx_bytes |
| 2829 | else: |
| 2830 | self.tx_bytes = 0 |
| 2831 | if tx_packets != None: |
| 2832 | self.tx_packets = tx_packets |
| 2833 | else: |
| 2834 | self.tx_packets = 0 |
| 2835 | if tx_errors != None: |
| 2836 | self.tx_errors = tx_errors |
| 2837 | else: |
| 2838 | self.tx_errors = 0 |
| 2839 | if duration_sec != None: |
| 2840 | self.duration_sec = duration_sec |
| 2841 | else: |
| 2842 | self.duration_sec = 0 |
| 2843 | if duration_nsec != None: |
| 2844 | self.duration_nsec = duration_nsec |
| 2845 | else: |
| 2846 | self.duration_nsec = 0 |
| 2847 | if properties != None: |
| 2848 | self.properties = properties |
| 2849 | else: |
| 2850 | self.properties = [] |
| 2851 | return |
| 2852 | |
| 2853 | def pack(self): |
| 2854 | packed = [] |
| 2855 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 2856 | packed.append('\x00' * 6) |
| 2857 | packed.append(util.pack_port_no(self.port_no)) |
| 2858 | packed.append(struct.pack("!L", self.queue_id)) |
| 2859 | packed.append(struct.pack("!Q", self.tx_bytes)) |
| 2860 | packed.append(struct.pack("!Q", self.tx_packets)) |
| 2861 | packed.append(struct.pack("!Q", self.tx_errors)) |
| 2862 | packed.append(struct.pack("!L", self.duration_sec)) |
| 2863 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 2864 | packed.append(loxi.generic_util.pack_list(self.properties)) |
| 2865 | length = sum([len(x) for x in packed]) |
| 2866 | packed[0] = struct.pack("!H", length) |
| 2867 | return ''.join(packed) |
| 2868 | |
| 2869 | @staticmethod |
| 2870 | def unpack(reader): |
| 2871 | obj = queue_stats_entry() |
| 2872 | _length = reader.read("!H")[0] |
| 2873 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2874 | reader = orig_reader.slice(_length, 2) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 2875 | reader.skip(6) |
| 2876 | obj.port_no = util.unpack_port_no(reader) |
| 2877 | obj.queue_id = reader.read("!L")[0] |
| 2878 | obj.tx_bytes = reader.read("!Q")[0] |
| 2879 | obj.tx_packets = reader.read("!Q")[0] |
| 2880 | obj.tx_errors = reader.read("!Q")[0] |
| 2881 | obj.duration_sec = reader.read("!L")[0] |
| 2882 | obj.duration_nsec = reader.read("!L")[0] |
| 2883 | obj.properties = loxi.generic_util.unpack_list(reader, queue_stats_prop.queue_stats_prop.unpack) |
| 2884 | return obj |
| 2885 | |
| 2886 | def __eq__(self, other): |
| 2887 | if type(self) != type(other): return False |
| 2888 | if self.port_no != other.port_no: return False |
| 2889 | if self.queue_id != other.queue_id: return False |
| 2890 | if self.tx_bytes != other.tx_bytes: return False |
| 2891 | if self.tx_packets != other.tx_packets: return False |
| 2892 | if self.tx_errors != other.tx_errors: return False |
| 2893 | if self.duration_sec != other.duration_sec: return False |
| 2894 | if self.duration_nsec != other.duration_nsec: return False |
| 2895 | if self.properties != other.properties: return False |
| 2896 | return True |
| 2897 | |
| 2898 | def pretty_print(self, q): |
| 2899 | q.text("queue_stats_entry {") |
| 2900 | with q.group(): |
| 2901 | with q.indent(2): |
| 2902 | q.breakable() |
| 2903 | q.text("port_no = "); |
| 2904 | q.text(util.pretty_port(self.port_no)) |
| 2905 | q.text(","); q.breakable() |
| 2906 | q.text("queue_id = "); |
| 2907 | q.text("%#x" % self.queue_id) |
| 2908 | q.text(","); q.breakable() |
| 2909 | q.text("tx_bytes = "); |
| 2910 | q.text("%#x" % self.tx_bytes) |
| 2911 | q.text(","); q.breakable() |
| 2912 | q.text("tx_packets = "); |
| 2913 | q.text("%#x" % self.tx_packets) |
| 2914 | q.text(","); q.breakable() |
| 2915 | q.text("tx_errors = "); |
| 2916 | q.text("%#x" % self.tx_errors) |
| 2917 | q.text(","); q.breakable() |
| 2918 | q.text("duration_sec = "); |
| 2919 | q.text("%#x" % self.duration_sec) |
| 2920 | q.text(","); q.breakable() |
| 2921 | q.text("duration_nsec = "); |
| 2922 | q.text("%#x" % self.duration_nsec) |
| 2923 | q.text(","); q.breakable() |
| 2924 | q.text("properties = "); |
| 2925 | q.pp(self.properties) |
| 2926 | q.breakable() |
| 2927 | q.text('}') |
| 2928 | |
| 2929 | |
| 2930 | class table_desc(loxi.OFObject): |
| 2931 | |
| 2932 | def __init__(self, table_id=None, config=None): |
| 2933 | if table_id != None: |
| 2934 | self.table_id = table_id |
| 2935 | else: |
| 2936 | self.table_id = 0 |
| 2937 | if config != None: |
| 2938 | self.config = config |
| 2939 | else: |
| 2940 | self.config = 0 |
| 2941 | return |
| 2942 | |
| 2943 | def pack(self): |
| 2944 | packed = [] |
| 2945 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 2946 | packed.append(struct.pack("!B", self.table_id)) |
| 2947 | packed.append('\x00' * 1) |
| 2948 | packed.append(struct.pack("!L", self.config)) |
| 2949 | length = sum([len(x) for x in packed]) |
| 2950 | packed[0] = struct.pack("!H", length) |
| 2951 | return ''.join(packed) |
| 2952 | |
| 2953 | @staticmethod |
| 2954 | def unpack(reader): |
| 2955 | obj = table_desc() |
| 2956 | _length = reader.read("!H")[0] |
| 2957 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2958 | reader = orig_reader.slice(_length, 2) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 2959 | obj.table_id = reader.read("!B")[0] |
| 2960 | reader.skip(1) |
| 2961 | obj.config = reader.read("!L")[0] |
| 2962 | return obj |
| 2963 | |
| 2964 | def __eq__(self, other): |
| 2965 | if type(self) != type(other): return False |
| 2966 | if self.table_id != other.table_id: return False |
| 2967 | if self.config != other.config: return False |
| 2968 | return True |
| 2969 | |
| 2970 | def pretty_print(self, q): |
| 2971 | q.text("table_desc {") |
| 2972 | with q.group(): |
| 2973 | with q.indent(2): |
| 2974 | q.breakable() |
| 2975 | q.text("table_id = "); |
| 2976 | q.text("%#x" % self.table_id) |
| 2977 | q.text(","); q.breakable() |
| 2978 | q.text("config = "); |
| 2979 | q.text("%#x" % self.config) |
| 2980 | q.breakable() |
| 2981 | q.text('}') |
| 2982 | |
| 2983 | |
| 2984 | class table_feature_prop(loxi.OFObject): |
| 2985 | subtypes = {} |
| 2986 | |
| 2987 | |
| 2988 | def __init__(self, type=None): |
| 2989 | if type != None: |
| 2990 | self.type = type |
| 2991 | else: |
| 2992 | self.type = 0 |
| 2993 | return |
| 2994 | |
| 2995 | def pack(self): |
| 2996 | packed = [] |
| 2997 | packed.append(struct.pack("!H", self.type)) |
| 2998 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 2999 | length = sum([len(x) for x in packed]) |
| 3000 | packed[1] = struct.pack("!H", length) |
| 3001 | return ''.join(packed) |
| 3002 | |
| 3003 | @staticmethod |
| 3004 | def unpack(reader): |
| 3005 | subtype, = reader.peek('!H', 0) |
| 3006 | subclass = table_feature_prop.subtypes.get(subtype) |
| 3007 | if subclass: |
| 3008 | return subclass.unpack(reader) |
| 3009 | |
| 3010 | obj = table_feature_prop() |
| 3011 | obj.type = reader.read("!H")[0] |
| 3012 | _length = reader.read("!H")[0] |
| 3013 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3014 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3015 | return obj |
| 3016 | |
| 3017 | def __eq__(self, other): |
| 3018 | if type(self) != type(other): return False |
| 3019 | if self.type != other.type: return False |
| 3020 | return True |
| 3021 | |
| 3022 | def pretty_print(self, q): |
| 3023 | q.text("table_feature_prop {") |
| 3024 | with q.group(): |
| 3025 | with q.indent(2): |
| 3026 | q.breakable() |
| 3027 | q.breakable() |
| 3028 | q.text('}') |
| 3029 | |
| 3030 | |
| 3031 | class table_feature_prop_apply_actions(table_feature_prop): |
| 3032 | type = 6 |
| 3033 | |
| 3034 | def __init__(self, action_ids=None): |
| 3035 | if action_ids != None: |
| 3036 | self.action_ids = action_ids |
| 3037 | else: |
| 3038 | self.action_ids = [] |
| 3039 | return |
| 3040 | |
| 3041 | def pack(self): |
| 3042 | packed = [] |
| 3043 | packed.append(struct.pack("!H", self.type)) |
| 3044 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3045 | packed.append(loxi.generic_util.pack_list(self.action_ids)) |
| 3046 | length = sum([len(x) for x in packed]) |
| 3047 | packed[1] = struct.pack("!H", length) |
| 3048 | return ''.join(packed) |
| 3049 | |
| 3050 | @staticmethod |
| 3051 | def unpack(reader): |
| 3052 | obj = table_feature_prop_apply_actions() |
| 3053 | _type = reader.read("!H")[0] |
| 3054 | assert(_type == 6) |
| 3055 | _length = reader.read("!H")[0] |
| 3056 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3057 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3058 | obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack) |
| 3059 | return obj |
| 3060 | |
| 3061 | def __eq__(self, other): |
| 3062 | if type(self) != type(other): return False |
| 3063 | if self.action_ids != other.action_ids: return False |
| 3064 | return True |
| 3065 | |
| 3066 | def pretty_print(self, q): |
| 3067 | q.text("table_feature_prop_apply_actions {") |
| 3068 | with q.group(): |
| 3069 | with q.indent(2): |
| 3070 | q.breakable() |
| 3071 | q.text("action_ids = "); |
| 3072 | q.pp(self.action_ids) |
| 3073 | q.breakable() |
| 3074 | q.text('}') |
| 3075 | |
| 3076 | table_feature_prop.subtypes[6] = table_feature_prop_apply_actions |
| 3077 | |
| 3078 | class table_feature_prop_apply_actions_miss(table_feature_prop): |
| 3079 | type = 7 |
| 3080 | |
| 3081 | def __init__(self, action_ids=None): |
| 3082 | if action_ids != None: |
| 3083 | self.action_ids = action_ids |
| 3084 | else: |
| 3085 | self.action_ids = [] |
| 3086 | return |
| 3087 | |
| 3088 | def pack(self): |
| 3089 | packed = [] |
| 3090 | packed.append(struct.pack("!H", self.type)) |
| 3091 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3092 | packed.append(loxi.generic_util.pack_list(self.action_ids)) |
| 3093 | length = sum([len(x) for x in packed]) |
| 3094 | packed[1] = struct.pack("!H", length) |
| 3095 | return ''.join(packed) |
| 3096 | |
| 3097 | @staticmethod |
| 3098 | def unpack(reader): |
| 3099 | obj = table_feature_prop_apply_actions_miss() |
| 3100 | _type = reader.read("!H")[0] |
| 3101 | assert(_type == 7) |
| 3102 | _length = reader.read("!H")[0] |
| 3103 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3104 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3105 | obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack) |
| 3106 | return obj |
| 3107 | |
| 3108 | def __eq__(self, other): |
| 3109 | if type(self) != type(other): return False |
| 3110 | if self.action_ids != other.action_ids: return False |
| 3111 | return True |
| 3112 | |
| 3113 | def pretty_print(self, q): |
| 3114 | q.text("table_feature_prop_apply_actions_miss {") |
| 3115 | with q.group(): |
| 3116 | with q.indent(2): |
| 3117 | q.breakable() |
| 3118 | q.text("action_ids = "); |
| 3119 | q.pp(self.action_ids) |
| 3120 | q.breakable() |
| 3121 | q.text('}') |
| 3122 | |
| 3123 | table_feature_prop.subtypes[7] = table_feature_prop_apply_actions_miss |
| 3124 | |
| 3125 | class table_feature_prop_apply_setfield(table_feature_prop): |
| 3126 | type = 14 |
| 3127 | |
| 3128 | def __init__(self, oxm_ids=None): |
| 3129 | if oxm_ids != None: |
| 3130 | self.oxm_ids = oxm_ids |
| 3131 | else: |
| 3132 | self.oxm_ids = [] |
| 3133 | return |
| 3134 | |
| 3135 | def pack(self): |
| 3136 | packed = [] |
| 3137 | packed.append(struct.pack("!H", self.type)) |
| 3138 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3139 | packed.append(loxi.generic_util.pack_list(self.oxm_ids)) |
| 3140 | length = sum([len(x) for x in packed]) |
| 3141 | packed[1] = struct.pack("!H", length) |
| 3142 | return ''.join(packed) |
| 3143 | |
| 3144 | @staticmethod |
| 3145 | def unpack(reader): |
| 3146 | obj = table_feature_prop_apply_setfield() |
| 3147 | _type = reader.read("!H")[0] |
| 3148 | assert(_type == 14) |
| 3149 | _length = reader.read("!H")[0] |
| 3150 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3151 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3152 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 3153 | return obj |
| 3154 | |
| 3155 | def __eq__(self, other): |
| 3156 | if type(self) != type(other): return False |
| 3157 | if self.oxm_ids != other.oxm_ids: return False |
| 3158 | return True |
| 3159 | |
| 3160 | def pretty_print(self, q): |
| 3161 | q.text("table_feature_prop_apply_setfield {") |
| 3162 | with q.group(): |
| 3163 | with q.indent(2): |
| 3164 | q.breakable() |
| 3165 | q.text("oxm_ids = "); |
| 3166 | q.pp(self.oxm_ids) |
| 3167 | q.breakable() |
| 3168 | q.text('}') |
| 3169 | |
| 3170 | table_feature_prop.subtypes[14] = table_feature_prop_apply_setfield |
| 3171 | |
| 3172 | class table_feature_prop_apply_setfield_miss(table_feature_prop): |
| 3173 | type = 15 |
| 3174 | |
| 3175 | def __init__(self, oxm_ids=None): |
| 3176 | if oxm_ids != None: |
| 3177 | self.oxm_ids = oxm_ids |
| 3178 | else: |
| 3179 | self.oxm_ids = [] |
| 3180 | return |
| 3181 | |
| 3182 | def pack(self): |
| 3183 | packed = [] |
| 3184 | packed.append(struct.pack("!H", self.type)) |
| 3185 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3186 | packed.append(loxi.generic_util.pack_list(self.oxm_ids)) |
| 3187 | length = sum([len(x) for x in packed]) |
| 3188 | packed[1] = struct.pack("!H", length) |
| 3189 | return ''.join(packed) |
| 3190 | |
| 3191 | @staticmethod |
| 3192 | def unpack(reader): |
| 3193 | obj = table_feature_prop_apply_setfield_miss() |
| 3194 | _type = reader.read("!H")[0] |
| 3195 | assert(_type == 15) |
| 3196 | _length = reader.read("!H")[0] |
| 3197 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3198 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3199 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 3200 | return obj |
| 3201 | |
| 3202 | def __eq__(self, other): |
| 3203 | if type(self) != type(other): return False |
| 3204 | if self.oxm_ids != other.oxm_ids: return False |
| 3205 | return True |
| 3206 | |
| 3207 | def pretty_print(self, q): |
| 3208 | q.text("table_feature_prop_apply_setfield_miss {") |
| 3209 | with q.group(): |
| 3210 | with q.indent(2): |
| 3211 | q.breakable() |
| 3212 | q.text("oxm_ids = "); |
| 3213 | q.pp(self.oxm_ids) |
| 3214 | q.breakable() |
| 3215 | q.text('}') |
| 3216 | |
| 3217 | table_feature_prop.subtypes[15] = table_feature_prop_apply_setfield_miss |
| 3218 | |
| 3219 | class table_feature_prop_experimenter(table_feature_prop): |
| 3220 | subtypes = {} |
| 3221 | |
| 3222 | type = 65534 |
| 3223 | |
| 3224 | def __init__(self, experimenter=None, subtype=None, experimenter_data=None): |
| 3225 | if experimenter != None: |
| 3226 | self.experimenter = experimenter |
| 3227 | else: |
| 3228 | self.experimenter = 0 |
| 3229 | if subtype != None: |
| 3230 | self.subtype = subtype |
| 3231 | else: |
| 3232 | self.subtype = 0 |
| 3233 | if experimenter_data != None: |
| 3234 | self.experimenter_data = experimenter_data |
| 3235 | else: |
| 3236 | self.experimenter_data = '' |
| 3237 | return |
| 3238 | |
| 3239 | def pack(self): |
| 3240 | packed = [] |
| 3241 | packed.append(struct.pack("!H", self.type)) |
| 3242 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3243 | packed.append(struct.pack("!L", self.experimenter)) |
| 3244 | packed.append(struct.pack("!L", self.subtype)) |
| 3245 | packed.append(self.experimenter_data) |
| 3246 | length = sum([len(x) for x in packed]) |
| 3247 | packed[1] = struct.pack("!H", length) |
| 3248 | return ''.join(packed) |
| 3249 | |
| 3250 | @staticmethod |
| 3251 | def unpack(reader): |
| 3252 | subtype, = reader.peek('!L', 4) |
| 3253 | subclass = table_feature_prop_experimenter.subtypes.get(subtype) |
| 3254 | if subclass: |
| 3255 | return subclass.unpack(reader) |
| 3256 | |
| 3257 | obj = table_feature_prop_experimenter() |
| 3258 | _type = reader.read("!H")[0] |
| 3259 | assert(_type == 65534) |
| 3260 | _length = reader.read("!H")[0] |
| 3261 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3262 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3263 | obj.experimenter = reader.read("!L")[0] |
| 3264 | obj.subtype = reader.read("!L")[0] |
| 3265 | obj.experimenter_data = str(reader.read_all()) |
| 3266 | return obj |
| 3267 | |
| 3268 | def __eq__(self, other): |
| 3269 | if type(self) != type(other): return False |
| 3270 | if self.experimenter != other.experimenter: return False |
| 3271 | if self.subtype != other.subtype: return False |
| 3272 | if self.experimenter_data != other.experimenter_data: return False |
| 3273 | return True |
| 3274 | |
| 3275 | def pretty_print(self, q): |
| 3276 | q.text("table_feature_prop_experimenter {") |
| 3277 | with q.group(): |
| 3278 | with q.indent(2): |
| 3279 | q.breakable() |
| 3280 | q.text("subtype = "); |
| 3281 | q.text("%#x" % self.subtype) |
| 3282 | q.text(","); q.breakable() |
| 3283 | q.text("experimenter_data = "); |
| 3284 | q.pp(self.experimenter_data) |
| 3285 | q.breakable() |
| 3286 | q.text('}') |
| 3287 | |
| 3288 | table_feature_prop.subtypes[65534] = table_feature_prop_experimenter |
| 3289 | |
| 3290 | class table_feature_prop_experimenter_miss(table_feature_prop): |
| 3291 | subtypes = {} |
| 3292 | |
| 3293 | type = 65535 |
| 3294 | |
| 3295 | def __init__(self, experimenter=None, subtype=None, experimenter_data=None): |
| 3296 | if experimenter != None: |
| 3297 | self.experimenter = experimenter |
| 3298 | else: |
| 3299 | self.experimenter = 0 |
| 3300 | if subtype != None: |
| 3301 | self.subtype = subtype |
| 3302 | else: |
| 3303 | self.subtype = 0 |
| 3304 | if experimenter_data != None: |
| 3305 | self.experimenter_data = experimenter_data |
| 3306 | else: |
| 3307 | self.experimenter_data = '' |
| 3308 | return |
| 3309 | |
| 3310 | def pack(self): |
| 3311 | packed = [] |
| 3312 | packed.append(struct.pack("!H", self.type)) |
| 3313 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3314 | packed.append(struct.pack("!L", self.experimenter)) |
| 3315 | packed.append(struct.pack("!L", self.subtype)) |
| 3316 | packed.append(self.experimenter_data) |
| 3317 | length = sum([len(x) for x in packed]) |
| 3318 | packed[1] = struct.pack("!H", length) |
| 3319 | return ''.join(packed) |
| 3320 | |
| 3321 | @staticmethod |
| 3322 | def unpack(reader): |
| 3323 | subtype, = reader.peek('!L', 4) |
| 3324 | subclass = table_feature_prop_experimenter_miss.subtypes.get(subtype) |
| 3325 | if subclass: |
| 3326 | return subclass.unpack(reader) |
| 3327 | |
| 3328 | obj = table_feature_prop_experimenter_miss() |
| 3329 | _type = reader.read("!H")[0] |
| 3330 | assert(_type == 65535) |
| 3331 | _length = reader.read("!H")[0] |
| 3332 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3333 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3334 | obj.experimenter = reader.read("!L")[0] |
| 3335 | obj.subtype = reader.read("!L")[0] |
| 3336 | obj.experimenter_data = str(reader.read_all()) |
| 3337 | return obj |
| 3338 | |
| 3339 | def __eq__(self, other): |
| 3340 | if type(self) != type(other): return False |
| 3341 | if self.experimenter != other.experimenter: return False |
| 3342 | if self.subtype != other.subtype: return False |
| 3343 | if self.experimenter_data != other.experimenter_data: return False |
| 3344 | return True |
| 3345 | |
| 3346 | def pretty_print(self, q): |
| 3347 | q.text("table_feature_prop_experimenter_miss {") |
| 3348 | with q.group(): |
| 3349 | with q.indent(2): |
| 3350 | q.breakable() |
| 3351 | q.text("subtype = "); |
| 3352 | q.text("%#x" % self.subtype) |
| 3353 | q.text(","); q.breakable() |
| 3354 | q.text("experimenter_data = "); |
| 3355 | q.pp(self.experimenter_data) |
| 3356 | q.breakable() |
| 3357 | q.text('}') |
| 3358 | |
| 3359 | table_feature_prop.subtypes[65535] = table_feature_prop_experimenter_miss |
| 3360 | |
| 3361 | class table_feature_prop_instructions(table_feature_prop): |
| 3362 | type = 0 |
| 3363 | |
| 3364 | def __init__(self, instruction_ids=None): |
| 3365 | if instruction_ids != None: |
| 3366 | self.instruction_ids = instruction_ids |
| 3367 | else: |
| 3368 | self.instruction_ids = [] |
| 3369 | return |
| 3370 | |
| 3371 | def pack(self): |
| 3372 | packed = [] |
| 3373 | packed.append(struct.pack("!H", self.type)) |
| 3374 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3375 | packed.append(loxi.generic_util.pack_list(self.instruction_ids)) |
| 3376 | length = sum([len(x) for x in packed]) |
| 3377 | packed[1] = struct.pack("!H", length) |
| 3378 | return ''.join(packed) |
| 3379 | |
| 3380 | @staticmethod |
| 3381 | def unpack(reader): |
| 3382 | obj = table_feature_prop_instructions() |
| 3383 | _type = reader.read("!H")[0] |
| 3384 | assert(_type == 0) |
| 3385 | _length = reader.read("!H")[0] |
| 3386 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3387 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3388 | obj.instruction_ids = loxi.generic_util.unpack_list(reader, instruction_id.instruction_id.unpack) |
| 3389 | return obj |
| 3390 | |
| 3391 | def __eq__(self, other): |
| 3392 | if type(self) != type(other): return False |
| 3393 | if self.instruction_ids != other.instruction_ids: return False |
| 3394 | return True |
| 3395 | |
| 3396 | def pretty_print(self, q): |
| 3397 | q.text("table_feature_prop_instructions {") |
| 3398 | with q.group(): |
| 3399 | with q.indent(2): |
| 3400 | q.breakable() |
| 3401 | q.text("instruction_ids = "); |
| 3402 | q.pp(self.instruction_ids) |
| 3403 | q.breakable() |
| 3404 | q.text('}') |
| 3405 | |
| 3406 | table_feature_prop.subtypes[0] = table_feature_prop_instructions |
| 3407 | |
| 3408 | class table_feature_prop_instructions_miss(table_feature_prop): |
| 3409 | type = 1 |
| 3410 | |
| 3411 | def __init__(self, instruction_ids=None): |
| 3412 | if instruction_ids != None: |
| 3413 | self.instruction_ids = instruction_ids |
| 3414 | else: |
| 3415 | self.instruction_ids = [] |
| 3416 | return |
| 3417 | |
| 3418 | def pack(self): |
| 3419 | packed = [] |
| 3420 | packed.append(struct.pack("!H", self.type)) |
| 3421 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3422 | packed.append(loxi.generic_util.pack_list(self.instruction_ids)) |
| 3423 | length = sum([len(x) for x in packed]) |
| 3424 | packed[1] = struct.pack("!H", length) |
| 3425 | return ''.join(packed) |
| 3426 | |
| 3427 | @staticmethod |
| 3428 | def unpack(reader): |
| 3429 | obj = table_feature_prop_instructions_miss() |
| 3430 | _type = reader.read("!H")[0] |
| 3431 | assert(_type == 1) |
| 3432 | _length = reader.read("!H")[0] |
| 3433 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3434 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3435 | obj.instruction_ids = loxi.generic_util.unpack_list(reader, instruction_id.instruction_id.unpack) |
| 3436 | return obj |
| 3437 | |
| 3438 | def __eq__(self, other): |
| 3439 | if type(self) != type(other): return False |
| 3440 | if self.instruction_ids != other.instruction_ids: return False |
| 3441 | return True |
| 3442 | |
| 3443 | def pretty_print(self, q): |
| 3444 | q.text("table_feature_prop_instructions_miss {") |
| 3445 | with q.group(): |
| 3446 | with q.indent(2): |
| 3447 | q.breakable() |
| 3448 | q.text("instruction_ids = "); |
| 3449 | q.pp(self.instruction_ids) |
| 3450 | q.breakable() |
| 3451 | q.text('}') |
| 3452 | |
| 3453 | table_feature_prop.subtypes[1] = table_feature_prop_instructions_miss |
| 3454 | |
| 3455 | class table_feature_prop_match(table_feature_prop): |
| 3456 | type = 8 |
| 3457 | |
| 3458 | def __init__(self, oxm_ids=None): |
| 3459 | if oxm_ids != None: |
| 3460 | self.oxm_ids = oxm_ids |
| 3461 | else: |
| 3462 | self.oxm_ids = [] |
| 3463 | return |
| 3464 | |
| 3465 | def pack(self): |
| 3466 | packed = [] |
| 3467 | packed.append(struct.pack("!H", self.type)) |
| 3468 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3469 | packed.append(loxi.generic_util.pack_list(self.oxm_ids)) |
| 3470 | length = sum([len(x) for x in packed]) |
| 3471 | packed[1] = struct.pack("!H", length) |
| 3472 | return ''.join(packed) |
| 3473 | |
| 3474 | @staticmethod |
| 3475 | def unpack(reader): |
| 3476 | obj = table_feature_prop_match() |
| 3477 | _type = reader.read("!H")[0] |
| 3478 | assert(_type == 8) |
| 3479 | _length = reader.read("!H")[0] |
| 3480 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3481 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3482 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 3483 | return obj |
| 3484 | |
| 3485 | def __eq__(self, other): |
| 3486 | if type(self) != type(other): return False |
| 3487 | if self.oxm_ids != other.oxm_ids: return False |
| 3488 | return True |
| 3489 | |
| 3490 | def pretty_print(self, q): |
| 3491 | q.text("table_feature_prop_match {") |
| 3492 | with q.group(): |
| 3493 | with q.indent(2): |
| 3494 | q.breakable() |
| 3495 | q.text("oxm_ids = "); |
| 3496 | q.pp(self.oxm_ids) |
| 3497 | q.breakable() |
| 3498 | q.text('}') |
| 3499 | |
| 3500 | table_feature_prop.subtypes[8] = table_feature_prop_match |
| 3501 | |
| 3502 | class table_feature_prop_next_tables(table_feature_prop): |
| 3503 | type = 2 |
| 3504 | |
| 3505 | def __init__(self, next_table_ids=None): |
| 3506 | if next_table_ids != None: |
| 3507 | self.next_table_ids = next_table_ids |
| 3508 | else: |
| 3509 | self.next_table_ids = [] |
| 3510 | return |
| 3511 | |
| 3512 | def pack(self): |
| 3513 | packed = [] |
| 3514 | packed.append(struct.pack("!H", self.type)) |
| 3515 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3516 | packed.append(loxi.generic_util.pack_list(self.next_table_ids)) |
| 3517 | length = sum([len(x) for x in packed]) |
| 3518 | packed[1] = struct.pack("!H", length) |
| 3519 | return ''.join(packed) |
| 3520 | |
| 3521 | @staticmethod |
| 3522 | def unpack(reader): |
| 3523 | obj = table_feature_prop_next_tables() |
| 3524 | _type = reader.read("!H")[0] |
| 3525 | assert(_type == 2) |
| 3526 | _length = reader.read("!H")[0] |
| 3527 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3528 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3529 | obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack) |
| 3530 | return obj |
| 3531 | |
| 3532 | def __eq__(self, other): |
| 3533 | if type(self) != type(other): return False |
| 3534 | if self.next_table_ids != other.next_table_ids: return False |
| 3535 | return True |
| 3536 | |
| 3537 | def pretty_print(self, q): |
| 3538 | q.text("table_feature_prop_next_tables {") |
| 3539 | with q.group(): |
| 3540 | with q.indent(2): |
| 3541 | q.breakable() |
| 3542 | q.text("next_table_ids = "); |
| 3543 | q.pp(self.next_table_ids) |
| 3544 | q.breakable() |
| 3545 | q.text('}') |
| 3546 | |
| 3547 | table_feature_prop.subtypes[2] = table_feature_prop_next_tables |
| 3548 | |
| 3549 | class table_feature_prop_next_tables_miss(table_feature_prop): |
| 3550 | type = 3 |
| 3551 | |
| 3552 | def __init__(self, next_table_ids=None): |
| 3553 | if next_table_ids != None: |
| 3554 | self.next_table_ids = next_table_ids |
| 3555 | else: |
| 3556 | self.next_table_ids = [] |
| 3557 | return |
| 3558 | |
| 3559 | def pack(self): |
| 3560 | packed = [] |
| 3561 | packed.append(struct.pack("!H", self.type)) |
| 3562 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3563 | packed.append(loxi.generic_util.pack_list(self.next_table_ids)) |
| 3564 | length = sum([len(x) for x in packed]) |
| 3565 | packed[1] = struct.pack("!H", length) |
| 3566 | return ''.join(packed) |
| 3567 | |
| 3568 | @staticmethod |
| 3569 | def unpack(reader): |
| 3570 | obj = table_feature_prop_next_tables_miss() |
| 3571 | _type = reader.read("!H")[0] |
| 3572 | assert(_type == 3) |
| 3573 | _length = reader.read("!H")[0] |
| 3574 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3575 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3576 | obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack) |
| 3577 | return obj |
| 3578 | |
| 3579 | def __eq__(self, other): |
| 3580 | if type(self) != type(other): return False |
| 3581 | if self.next_table_ids != other.next_table_ids: return False |
| 3582 | return True |
| 3583 | |
| 3584 | def pretty_print(self, q): |
| 3585 | q.text("table_feature_prop_next_tables_miss {") |
| 3586 | with q.group(): |
| 3587 | with q.indent(2): |
| 3588 | q.breakable() |
| 3589 | q.text("next_table_ids = "); |
| 3590 | q.pp(self.next_table_ids) |
| 3591 | q.breakable() |
| 3592 | q.text('}') |
| 3593 | |
| 3594 | table_feature_prop.subtypes[3] = table_feature_prop_next_tables_miss |
| 3595 | |
| 3596 | class table_feature_prop_table_sync_from(table_feature_prop): |
| 3597 | type = 16 |
| 3598 | |
| 3599 | def __init__(self, table_ids=None): |
| 3600 | if table_ids != None: |
| 3601 | self.table_ids = table_ids |
| 3602 | else: |
| 3603 | self.table_ids = [] |
| 3604 | return |
| 3605 | |
| 3606 | def pack(self): |
| 3607 | packed = [] |
| 3608 | packed.append(struct.pack("!H", self.type)) |
| 3609 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3610 | packed.append(loxi.generic_util.pack_list(self.table_ids)) |
| 3611 | length = sum([len(x) for x in packed]) |
| 3612 | packed[1] = struct.pack("!H", length) |
| 3613 | return ''.join(packed) |
| 3614 | |
| 3615 | @staticmethod |
| 3616 | def unpack(reader): |
| 3617 | obj = table_feature_prop_table_sync_from() |
| 3618 | _type = reader.read("!H")[0] |
| 3619 | assert(_type == 16) |
| 3620 | _length = reader.read("!H")[0] |
| 3621 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3622 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3623 | obj.table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack) |
| 3624 | return obj |
| 3625 | |
| 3626 | def __eq__(self, other): |
| 3627 | if type(self) != type(other): return False |
| 3628 | if self.table_ids != other.table_ids: return False |
| 3629 | return True |
| 3630 | |
| 3631 | def pretty_print(self, q): |
| 3632 | q.text("table_feature_prop_table_sync_from {") |
| 3633 | with q.group(): |
| 3634 | with q.indent(2): |
| 3635 | q.breakable() |
| 3636 | q.text("table_ids = "); |
| 3637 | q.pp(self.table_ids) |
| 3638 | q.breakable() |
| 3639 | q.text('}') |
| 3640 | |
| 3641 | table_feature_prop.subtypes[16] = table_feature_prop_table_sync_from |
| 3642 | |
| 3643 | class table_feature_prop_wildcards(table_feature_prop): |
| 3644 | type = 10 |
| 3645 | |
| 3646 | def __init__(self, oxm_ids=None): |
| 3647 | if oxm_ids != None: |
| 3648 | self.oxm_ids = oxm_ids |
| 3649 | else: |
| 3650 | self.oxm_ids = [] |
| 3651 | return |
| 3652 | |
| 3653 | def pack(self): |
| 3654 | packed = [] |
| 3655 | packed.append(struct.pack("!H", self.type)) |
| 3656 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3657 | packed.append(loxi.generic_util.pack_list(self.oxm_ids)) |
| 3658 | length = sum([len(x) for x in packed]) |
| 3659 | packed[1] = struct.pack("!H", length) |
| 3660 | return ''.join(packed) |
| 3661 | |
| 3662 | @staticmethod |
| 3663 | def unpack(reader): |
| 3664 | obj = table_feature_prop_wildcards() |
| 3665 | _type = reader.read("!H")[0] |
| 3666 | assert(_type == 10) |
| 3667 | _length = reader.read("!H")[0] |
| 3668 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3669 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3670 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 3671 | return obj |
| 3672 | |
| 3673 | def __eq__(self, other): |
| 3674 | if type(self) != type(other): return False |
| 3675 | if self.oxm_ids != other.oxm_ids: return False |
| 3676 | return True |
| 3677 | |
| 3678 | def pretty_print(self, q): |
| 3679 | q.text("table_feature_prop_wildcards {") |
| 3680 | with q.group(): |
| 3681 | with q.indent(2): |
| 3682 | q.breakable() |
| 3683 | q.text("oxm_ids = "); |
| 3684 | q.pp(self.oxm_ids) |
| 3685 | q.breakable() |
| 3686 | q.text('}') |
| 3687 | |
| 3688 | table_feature_prop.subtypes[10] = table_feature_prop_wildcards |
| 3689 | |
| 3690 | class table_feature_prop_write_actions(table_feature_prop): |
| 3691 | type = 4 |
| 3692 | |
| 3693 | def __init__(self, action_ids=None): |
| 3694 | if action_ids != None: |
| 3695 | self.action_ids = action_ids |
| 3696 | else: |
| 3697 | self.action_ids = [] |
| 3698 | return |
| 3699 | |
| 3700 | def pack(self): |
| 3701 | packed = [] |
| 3702 | packed.append(struct.pack("!H", self.type)) |
| 3703 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3704 | packed.append(loxi.generic_util.pack_list(self.action_ids)) |
| 3705 | length = sum([len(x) for x in packed]) |
| 3706 | packed[1] = struct.pack("!H", length) |
| 3707 | return ''.join(packed) |
| 3708 | |
| 3709 | @staticmethod |
| 3710 | def unpack(reader): |
| 3711 | obj = table_feature_prop_write_actions() |
| 3712 | _type = reader.read("!H")[0] |
| 3713 | assert(_type == 4) |
| 3714 | _length = reader.read("!H")[0] |
| 3715 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3716 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3717 | obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack) |
| 3718 | return obj |
| 3719 | |
| 3720 | def __eq__(self, other): |
| 3721 | if type(self) != type(other): return False |
| 3722 | if self.action_ids != other.action_ids: return False |
| 3723 | return True |
| 3724 | |
| 3725 | def pretty_print(self, q): |
| 3726 | q.text("table_feature_prop_write_actions {") |
| 3727 | with q.group(): |
| 3728 | with q.indent(2): |
| 3729 | q.breakable() |
| 3730 | q.text("action_ids = "); |
| 3731 | q.pp(self.action_ids) |
| 3732 | q.breakable() |
| 3733 | q.text('}') |
| 3734 | |
| 3735 | table_feature_prop.subtypes[4] = table_feature_prop_write_actions |
| 3736 | |
| 3737 | class table_feature_prop_write_actions_miss(table_feature_prop): |
| 3738 | type = 5 |
| 3739 | |
| 3740 | def __init__(self, action_ids=None): |
| 3741 | if action_ids != None: |
| 3742 | self.action_ids = action_ids |
| 3743 | else: |
| 3744 | self.action_ids = [] |
| 3745 | return |
| 3746 | |
| 3747 | def pack(self): |
| 3748 | packed = [] |
| 3749 | packed.append(struct.pack("!H", self.type)) |
| 3750 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3751 | packed.append(loxi.generic_util.pack_list(self.action_ids)) |
| 3752 | length = sum([len(x) for x in packed]) |
| 3753 | packed[1] = struct.pack("!H", length) |
| 3754 | return ''.join(packed) |
| 3755 | |
| 3756 | @staticmethod |
| 3757 | def unpack(reader): |
| 3758 | obj = table_feature_prop_write_actions_miss() |
| 3759 | _type = reader.read("!H")[0] |
| 3760 | assert(_type == 5) |
| 3761 | _length = reader.read("!H")[0] |
| 3762 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3763 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3764 | obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack) |
| 3765 | return obj |
| 3766 | |
| 3767 | def __eq__(self, other): |
| 3768 | if type(self) != type(other): return False |
| 3769 | if self.action_ids != other.action_ids: return False |
| 3770 | return True |
| 3771 | |
| 3772 | def pretty_print(self, q): |
| 3773 | q.text("table_feature_prop_write_actions_miss {") |
| 3774 | with q.group(): |
| 3775 | with q.indent(2): |
| 3776 | q.breakable() |
| 3777 | q.text("action_ids = "); |
| 3778 | q.pp(self.action_ids) |
| 3779 | q.breakable() |
| 3780 | q.text('}') |
| 3781 | |
| 3782 | table_feature_prop.subtypes[5] = table_feature_prop_write_actions_miss |
| 3783 | |
| 3784 | class table_feature_prop_write_setfield(table_feature_prop): |
| 3785 | type = 12 |
| 3786 | |
| 3787 | def __init__(self, oxm_ids=None): |
| 3788 | if oxm_ids != None: |
| 3789 | self.oxm_ids = oxm_ids |
| 3790 | else: |
| 3791 | self.oxm_ids = [] |
| 3792 | return |
| 3793 | |
| 3794 | def pack(self): |
| 3795 | packed = [] |
| 3796 | packed.append(struct.pack("!H", self.type)) |
| 3797 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3798 | packed.append(loxi.generic_util.pack_list(self.oxm_ids)) |
| 3799 | length = sum([len(x) for x in packed]) |
| 3800 | packed[1] = struct.pack("!H", length) |
| 3801 | return ''.join(packed) |
| 3802 | |
| 3803 | @staticmethod |
| 3804 | def unpack(reader): |
| 3805 | obj = table_feature_prop_write_setfield() |
| 3806 | _type = reader.read("!H")[0] |
| 3807 | assert(_type == 12) |
| 3808 | _length = reader.read("!H")[0] |
| 3809 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3810 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3811 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 3812 | return obj |
| 3813 | |
| 3814 | def __eq__(self, other): |
| 3815 | if type(self) != type(other): return False |
| 3816 | if self.oxm_ids != other.oxm_ids: return False |
| 3817 | return True |
| 3818 | |
| 3819 | def pretty_print(self, q): |
| 3820 | q.text("table_feature_prop_write_setfield {") |
| 3821 | with q.group(): |
| 3822 | with q.indent(2): |
| 3823 | q.breakable() |
| 3824 | q.text("oxm_ids = "); |
| 3825 | q.pp(self.oxm_ids) |
| 3826 | q.breakable() |
| 3827 | q.text('}') |
| 3828 | |
| 3829 | table_feature_prop.subtypes[12] = table_feature_prop_write_setfield |
| 3830 | |
| 3831 | class table_feature_prop_write_setfield_miss(table_feature_prop): |
| 3832 | type = 13 |
| 3833 | |
| 3834 | def __init__(self, oxm_ids=None): |
| 3835 | if oxm_ids != None: |
| 3836 | self.oxm_ids = oxm_ids |
| 3837 | else: |
| 3838 | self.oxm_ids = [] |
| 3839 | return |
| 3840 | |
| 3841 | def pack(self): |
| 3842 | packed = [] |
| 3843 | packed.append(struct.pack("!H", self.type)) |
| 3844 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3845 | packed.append(loxi.generic_util.pack_list(self.oxm_ids)) |
| 3846 | length = sum([len(x) for x in packed]) |
| 3847 | packed[1] = struct.pack("!H", length) |
| 3848 | return ''.join(packed) |
| 3849 | |
| 3850 | @staticmethod |
| 3851 | def unpack(reader): |
| 3852 | obj = table_feature_prop_write_setfield_miss() |
| 3853 | _type = reader.read("!H")[0] |
| 3854 | assert(_type == 13) |
| 3855 | _length = reader.read("!H")[0] |
| 3856 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3857 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3858 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 3859 | return obj |
| 3860 | |
| 3861 | def __eq__(self, other): |
| 3862 | if type(self) != type(other): return False |
| 3863 | if self.oxm_ids != other.oxm_ids: return False |
| 3864 | return True |
| 3865 | |
| 3866 | def pretty_print(self, q): |
| 3867 | q.text("table_feature_prop_write_setfield_miss {") |
| 3868 | with q.group(): |
| 3869 | with q.indent(2): |
| 3870 | q.breakable() |
| 3871 | q.text("oxm_ids = "); |
| 3872 | q.pp(self.oxm_ids) |
| 3873 | q.breakable() |
| 3874 | q.text('}') |
| 3875 | |
| 3876 | table_feature_prop.subtypes[13] = table_feature_prop_write_setfield_miss |
| 3877 | |
| 3878 | class table_features(loxi.OFObject): |
| 3879 | |
| 3880 | def __init__(self, table_id=None, name=None, metadata_match=None, metadata_write=None, config=None, max_entries=None, properties=None): |
| 3881 | if table_id != None: |
| 3882 | self.table_id = table_id |
| 3883 | else: |
| 3884 | self.table_id = 0 |
| 3885 | if name != None: |
| 3886 | self.name = name |
| 3887 | else: |
| 3888 | self.name = "" |
| 3889 | if metadata_match != None: |
| 3890 | self.metadata_match = metadata_match |
| 3891 | else: |
| 3892 | self.metadata_match = 0 |
| 3893 | if metadata_write != None: |
| 3894 | self.metadata_write = metadata_write |
| 3895 | else: |
| 3896 | self.metadata_write = 0 |
| 3897 | if config != None: |
| 3898 | self.config = config |
| 3899 | else: |
| 3900 | self.config = 0 |
| 3901 | if max_entries != None: |
| 3902 | self.max_entries = max_entries |
| 3903 | else: |
| 3904 | self.max_entries = 0 |
| 3905 | if properties != None: |
| 3906 | self.properties = properties |
| 3907 | else: |
| 3908 | self.properties = [] |
| 3909 | return |
| 3910 | |
| 3911 | def pack(self): |
| 3912 | packed = [] |
| 3913 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 3914 | packed.append(struct.pack("!B", self.table_id)) |
| 3915 | packed.append('\x00' * 5) |
| 3916 | packed.append(struct.pack("!32s", self.name)) |
| 3917 | packed.append(struct.pack("!Q", self.metadata_match)) |
| 3918 | packed.append(struct.pack("!Q", self.metadata_write)) |
| 3919 | packed.append(struct.pack("!L", self.config)) |
| 3920 | packed.append(struct.pack("!L", self.max_entries)) |
| 3921 | packed.append(loxi.generic_util.pack_list(self.properties)) |
| 3922 | length = sum([len(x) for x in packed]) |
| 3923 | packed[0] = struct.pack("!H", length) |
| 3924 | return ''.join(packed) |
| 3925 | |
| 3926 | @staticmethod |
| 3927 | def unpack(reader): |
| 3928 | obj = table_features() |
| 3929 | _length = reader.read("!H")[0] |
| 3930 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3931 | reader = orig_reader.slice(_length, 2) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 3932 | obj.table_id = reader.read("!B")[0] |
| 3933 | reader.skip(5) |
| 3934 | obj.name = reader.read("!32s")[0].rstrip("\x00") |
| 3935 | obj.metadata_match = reader.read("!Q")[0] |
| 3936 | obj.metadata_write = reader.read("!Q")[0] |
| 3937 | obj.config = reader.read("!L")[0] |
| 3938 | obj.max_entries = reader.read("!L")[0] |
| 3939 | obj.properties = loxi.generic_util.unpack_list(reader, common.table_feature_prop.unpack) |
| 3940 | return obj |
| 3941 | |
| 3942 | def __eq__(self, other): |
| 3943 | if type(self) != type(other): return False |
| 3944 | if self.table_id != other.table_id: return False |
| 3945 | if self.name != other.name: return False |
| 3946 | if self.metadata_match != other.metadata_match: return False |
| 3947 | if self.metadata_write != other.metadata_write: return False |
| 3948 | if self.config != other.config: return False |
| 3949 | if self.max_entries != other.max_entries: return False |
| 3950 | if self.properties != other.properties: return False |
| 3951 | return True |
| 3952 | |
| 3953 | def pretty_print(self, q): |
| 3954 | q.text("table_features {") |
| 3955 | with q.group(): |
| 3956 | with q.indent(2): |
| 3957 | q.breakable() |
| 3958 | q.text("table_id = "); |
| 3959 | q.text("%#x" % self.table_id) |
| 3960 | q.text(","); q.breakable() |
| 3961 | q.text("name = "); |
| 3962 | q.pp(self.name) |
| 3963 | q.text(","); q.breakable() |
| 3964 | q.text("metadata_match = "); |
| 3965 | q.text("%#x" % self.metadata_match) |
| 3966 | q.text(","); q.breakable() |
| 3967 | q.text("metadata_write = "); |
| 3968 | q.text("%#x" % self.metadata_write) |
| 3969 | q.text(","); q.breakable() |
| 3970 | q.text("config = "); |
| 3971 | q.text("%#x" % self.config) |
| 3972 | q.text(","); q.breakable() |
| 3973 | q.text("max_entries = "); |
| 3974 | q.text("%#x" % self.max_entries) |
| 3975 | q.text(","); q.breakable() |
| 3976 | q.text("properties = "); |
| 3977 | q.pp(self.properties) |
| 3978 | q.breakable() |
| 3979 | q.text('}') |
| 3980 | |
| 3981 | |
| 3982 | class table_mod_prop_eviction(loxi.OFObject): |
| 3983 | type = 2 |
| 3984 | |
| 3985 | def __init__(self, flags=None): |
| 3986 | if flags != None: |
| 3987 | self.flags = flags |
| 3988 | else: |
| 3989 | self.flags = 0 |
| 3990 | return |
| 3991 | |
| 3992 | def pack(self): |
| 3993 | packed = [] |
| 3994 | packed.append(struct.pack("!H", self.type)) |
| 3995 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3996 | packed.append(struct.pack("!L", self.flags)) |
| 3997 | length = sum([len(x) for x in packed]) |
| 3998 | packed[1] = struct.pack("!H", length) |
| 3999 | return ''.join(packed) |
| 4000 | |
| 4001 | @staticmethod |
| 4002 | def unpack(reader): |
| 4003 | obj = table_mod_prop_eviction() |
| 4004 | _type = reader.read("!H")[0] |
| 4005 | assert(_type == 2) |
| 4006 | _length = reader.read("!H")[0] |
| 4007 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 4008 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 4009 | obj.flags = reader.read("!L")[0] |
| 4010 | return obj |
| 4011 | |
| 4012 | def __eq__(self, other): |
| 4013 | if type(self) != type(other): return False |
| 4014 | if self.flags != other.flags: return False |
| 4015 | return True |
| 4016 | |
| 4017 | def pretty_print(self, q): |
| 4018 | q.text("table_mod_prop_eviction {") |
| 4019 | with q.group(): |
| 4020 | with q.indent(2): |
| 4021 | q.breakable() |
| 4022 | q.text("flags = "); |
| 4023 | q.text("%#x" % self.flags) |
| 4024 | q.breakable() |
| 4025 | q.text('}') |
| 4026 | |
| 4027 | |
| 4028 | class table_mod_prop_experimenter(loxi.OFObject): |
| 4029 | subtypes = {} |
| 4030 | |
| 4031 | type = 65535 |
| 4032 | |
| 4033 | def __init__(self, experimenter=None, exp_type=None): |
| 4034 | if experimenter != None: |
| 4035 | self.experimenter = experimenter |
| 4036 | else: |
| 4037 | self.experimenter = 0 |
| 4038 | if exp_type != None: |
| 4039 | self.exp_type = exp_type |
| 4040 | else: |
| 4041 | self.exp_type = 0 |
| 4042 | return |
| 4043 | |
| 4044 | def pack(self): |
| 4045 | packed = [] |
| 4046 | packed.append(struct.pack("!H", self.type)) |
| 4047 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 4048 | packed.append(struct.pack("!L", self.experimenter)) |
| 4049 | packed.append(struct.pack("!L", self.exp_type)) |
| 4050 | length = sum([len(x) for x in packed]) |
| 4051 | packed[1] = struct.pack("!H", length) |
| 4052 | return ''.join(packed) |
| 4053 | |
| 4054 | @staticmethod |
| 4055 | def unpack(reader): |
| 4056 | subtype, = reader.peek('!L', 4) |
| 4057 | subclass = table_mod_prop_experimenter.subtypes.get(subtype) |
| 4058 | if subclass: |
| 4059 | return subclass.unpack(reader) |
| 4060 | |
| 4061 | obj = table_mod_prop_experimenter() |
| 4062 | _type = reader.read("!H")[0] |
| 4063 | assert(_type == 65535) |
| 4064 | _length = reader.read("!H")[0] |
| 4065 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 4066 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 4067 | obj.experimenter = reader.read("!L")[0] |
| 4068 | obj.exp_type = reader.read("!L")[0] |
| 4069 | return obj |
| 4070 | |
| 4071 | def __eq__(self, other): |
| 4072 | if type(self) != type(other): return False |
| 4073 | if self.experimenter != other.experimenter: return False |
| 4074 | if self.exp_type != other.exp_type: return False |
| 4075 | return True |
| 4076 | |
| 4077 | def pretty_print(self, q): |
| 4078 | q.text("table_mod_prop_experimenter {") |
| 4079 | with q.group(): |
| 4080 | with q.indent(2): |
| 4081 | q.breakable() |
| 4082 | q.text("exp_type = "); |
| 4083 | q.text("%#x" % self.exp_type) |
| 4084 | q.breakable() |
| 4085 | q.text('}') |
| 4086 | |
| 4087 | |
| 4088 | class table_mod_prop_vacancy(loxi.OFObject): |
| 4089 | type = 3 |
| 4090 | |
| 4091 | def __init__(self, vacancy_down=None, vacancy_up=None, vacancy=None): |
| 4092 | if vacancy_down != None: |
| 4093 | self.vacancy_down = vacancy_down |
| 4094 | else: |
| 4095 | self.vacancy_down = 0 |
| 4096 | if vacancy_up != None: |
| 4097 | self.vacancy_up = vacancy_up |
| 4098 | else: |
| 4099 | self.vacancy_up = 0 |
| 4100 | if vacancy != None: |
| 4101 | self.vacancy = vacancy |
| 4102 | else: |
| 4103 | self.vacancy = 0 |
| 4104 | return |
| 4105 | |
| 4106 | def pack(self): |
| 4107 | packed = [] |
| 4108 | packed.append(struct.pack("!H", self.type)) |
| 4109 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 4110 | packed.append(struct.pack("!B", self.vacancy_down)) |
| 4111 | packed.append(struct.pack("!B", self.vacancy_up)) |
| 4112 | packed.append(struct.pack("!B", self.vacancy)) |
| 4113 | packed.append('\x00' * 1) |
| 4114 | length = sum([len(x) for x in packed]) |
| 4115 | packed[1] = struct.pack("!H", length) |
| 4116 | return ''.join(packed) |
| 4117 | |
| 4118 | @staticmethod |
| 4119 | def unpack(reader): |
| 4120 | obj = table_mod_prop_vacancy() |
| 4121 | _type = reader.read("!H")[0] |
| 4122 | assert(_type == 3) |
| 4123 | _length = reader.read("!H")[0] |
| 4124 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 4125 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 4126 | obj.vacancy_down = reader.read("!B")[0] |
| 4127 | obj.vacancy_up = reader.read("!B")[0] |
| 4128 | obj.vacancy = reader.read("!B")[0] |
| 4129 | reader.skip(1) |
| 4130 | return obj |
| 4131 | |
| 4132 | def __eq__(self, other): |
| 4133 | if type(self) != type(other): return False |
| 4134 | if self.vacancy_down != other.vacancy_down: return False |
| 4135 | if self.vacancy_up != other.vacancy_up: return False |
| 4136 | if self.vacancy != other.vacancy: return False |
| 4137 | return True |
| 4138 | |
| 4139 | def pretty_print(self, q): |
| 4140 | q.text("table_mod_prop_vacancy {") |
| 4141 | with q.group(): |
| 4142 | with q.indent(2): |
| 4143 | q.breakable() |
| 4144 | q.text("vacancy_down = "); |
| 4145 | q.text("%#x" % self.vacancy_down) |
| 4146 | q.text(","); q.breakable() |
| 4147 | q.text("vacancy_up = "); |
| 4148 | q.text("%#x" % self.vacancy_up) |
| 4149 | q.text(","); q.breakable() |
| 4150 | q.text("vacancy = "); |
| 4151 | q.text("%#x" % self.vacancy) |
| 4152 | q.breakable() |
| 4153 | q.text('}') |
| 4154 | |
| 4155 | |
| 4156 | class table_stats_entry(loxi.OFObject): |
| 4157 | |
| 4158 | def __init__(self, table_id=None, active_count=None, lookup_count=None, matched_count=None): |
| 4159 | if table_id != None: |
| 4160 | self.table_id = table_id |
| 4161 | else: |
| 4162 | self.table_id = 0 |
| 4163 | if active_count != None: |
| 4164 | self.active_count = active_count |
| 4165 | else: |
| 4166 | self.active_count = 0 |
| 4167 | if lookup_count != None: |
| 4168 | self.lookup_count = lookup_count |
| 4169 | else: |
| 4170 | self.lookup_count = 0 |
| 4171 | if matched_count != None: |
| 4172 | self.matched_count = matched_count |
| 4173 | else: |
| 4174 | self.matched_count = 0 |
| 4175 | return |
| 4176 | |
| 4177 | def pack(self): |
| 4178 | packed = [] |
| 4179 | packed.append(struct.pack("!B", self.table_id)) |
| 4180 | packed.append('\x00' * 3) |
| 4181 | packed.append(struct.pack("!L", self.active_count)) |
| 4182 | packed.append(struct.pack("!Q", self.lookup_count)) |
| 4183 | packed.append(struct.pack("!Q", self.matched_count)) |
| 4184 | return ''.join(packed) |
| 4185 | |
| 4186 | @staticmethod |
| 4187 | def unpack(reader): |
| 4188 | obj = table_stats_entry() |
| 4189 | obj.table_id = reader.read("!B")[0] |
| 4190 | reader.skip(3) |
| 4191 | obj.active_count = reader.read("!L")[0] |
| 4192 | obj.lookup_count = reader.read("!Q")[0] |
| 4193 | obj.matched_count = reader.read("!Q")[0] |
| 4194 | return obj |
| 4195 | |
| 4196 | def __eq__(self, other): |
| 4197 | if type(self) != type(other): return False |
| 4198 | if self.table_id != other.table_id: return False |
| 4199 | if self.active_count != other.active_count: return False |
| 4200 | if self.lookup_count != other.lookup_count: return False |
| 4201 | if self.matched_count != other.matched_count: return False |
| 4202 | return True |
| 4203 | |
| 4204 | def pretty_print(self, q): |
| 4205 | q.text("table_stats_entry {") |
| 4206 | with q.group(): |
| 4207 | with q.indent(2): |
| 4208 | q.breakable() |
| 4209 | q.text("table_id = "); |
| 4210 | q.text("%#x" % self.table_id) |
| 4211 | q.text(","); q.breakable() |
| 4212 | q.text("active_count = "); |
| 4213 | q.text("%#x" % self.active_count) |
| 4214 | q.text(","); q.breakable() |
| 4215 | q.text("lookup_count = "); |
| 4216 | q.text("%#x" % self.lookup_count) |
| 4217 | q.text(","); q.breakable() |
| 4218 | q.text("matched_count = "); |
| 4219 | q.text("%#x" % self.matched_count) |
| 4220 | q.breakable() |
| 4221 | q.text('}') |
| 4222 | |
| 4223 | |
| 4224 | class uint32(loxi.OFObject): |
| 4225 | |
| 4226 | def __init__(self, value=None): |
| 4227 | if value != None: |
| 4228 | self.value = value |
| 4229 | else: |
| 4230 | self.value = 0 |
| 4231 | return |
| 4232 | |
| 4233 | def pack(self): |
| 4234 | packed = [] |
| 4235 | packed.append(struct.pack("!L", self.value)) |
| 4236 | return ''.join(packed) |
| 4237 | |
| 4238 | @staticmethod |
| 4239 | def unpack(reader): |
| 4240 | obj = uint32() |
| 4241 | obj.value = reader.read("!L")[0] |
| 4242 | return obj |
| 4243 | |
| 4244 | def __eq__(self, other): |
| 4245 | if type(self) != type(other): return False |
| 4246 | if self.value != other.value: return False |
| 4247 | return True |
| 4248 | |
| 4249 | def pretty_print(self, q): |
| 4250 | q.text("uint32 {") |
| 4251 | with q.group(): |
| 4252 | with q.indent(2): |
| 4253 | q.breakable() |
| 4254 | q.text("value = "); |
| 4255 | q.text("%#x" % self.value) |
| 4256 | q.breakable() |
| 4257 | q.text('}') |
| 4258 | |
| 4259 | |
| 4260 | class uint64(loxi.OFObject): |
| 4261 | |
| 4262 | def __init__(self, value=None): |
| 4263 | if value != None: |
| 4264 | self.value = value |
| 4265 | else: |
| 4266 | self.value = 0 |
| 4267 | return |
| 4268 | |
| 4269 | def pack(self): |
| 4270 | packed = [] |
| 4271 | packed.append(struct.pack("!Q", self.value)) |
| 4272 | return ''.join(packed) |
| 4273 | |
| 4274 | @staticmethod |
| 4275 | def unpack(reader): |
| 4276 | obj = uint64() |
| 4277 | obj.value = reader.read("!Q")[0] |
| 4278 | return obj |
| 4279 | |
| 4280 | def __eq__(self, other): |
| 4281 | if type(self) != type(other): return False |
| 4282 | if self.value != other.value: return False |
| 4283 | return True |
| 4284 | |
| 4285 | def pretty_print(self, q): |
| 4286 | q.text("uint64 {") |
| 4287 | with q.group(): |
| 4288 | with q.indent(2): |
| 4289 | q.breakable() |
| 4290 | q.text("value = "); |
| 4291 | q.text("%#x" % self.value) |
| 4292 | q.breakable() |
| 4293 | q.text('}') |
| 4294 | |
| 4295 | |
| 4296 | class uint8(loxi.OFObject): |
| 4297 | |
| 4298 | def __init__(self, value=None): |
| 4299 | if value != None: |
| 4300 | self.value = value |
| 4301 | else: |
| 4302 | self.value = 0 |
| 4303 | return |
| 4304 | |
| 4305 | def pack(self): |
| 4306 | packed = [] |
| 4307 | packed.append(struct.pack("!B", self.value)) |
| 4308 | return ''.join(packed) |
| 4309 | |
| 4310 | @staticmethod |
| 4311 | def unpack(reader): |
| 4312 | obj = uint8() |
| 4313 | obj.value = reader.read("!B")[0] |
| 4314 | return obj |
| 4315 | |
| 4316 | def __eq__(self, other): |
| 4317 | if type(self) != type(other): return False |
| 4318 | if self.value != other.value: return False |
| 4319 | return True |
| 4320 | |
| 4321 | def pretty_print(self, q): |
| 4322 | q.text("uint8 {") |
| 4323 | with q.group(): |
| 4324 | with q.indent(2): |
| 4325 | q.breakable() |
| 4326 | q.text("value = "); |
| 4327 | q.text("%#x" % self.value) |
| 4328 | q.breakable() |
| 4329 | q.text('}') |
| 4330 | |
| 4331 | |
| 4332 | |
| 4333 | match = match_v3 |