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