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 | |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 975 | def __init__(self, flags=None, port_no=None, loopback_port_no=None, local_mac=None, nh_mac=None, src_ip=None, dst_ip=None, dscp=None, ttl=None, vpn=None, if_name=None): |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 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 |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 984 | if loopback_port_no != None: |
| 985 | self.loopback_port_no = loopback_port_no |
| 986 | else: |
| 987 | self.loopback_port_no = 0 |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 988 | if local_mac != None: |
| 989 | self.local_mac = local_mac |
| 990 | else: |
| 991 | self.local_mac = [0,0,0,0,0,0] |
| 992 | if nh_mac != None: |
| 993 | self.nh_mac = nh_mac |
| 994 | else: |
| 995 | self.nh_mac = [0,0,0,0,0,0] |
| 996 | if src_ip != None: |
| 997 | self.src_ip = src_ip |
| 998 | else: |
| 999 | self.src_ip = 0 |
| 1000 | if dst_ip != None: |
| 1001 | self.dst_ip = dst_ip |
| 1002 | else: |
| 1003 | self.dst_ip = 0 |
| 1004 | if dscp != None: |
| 1005 | self.dscp = dscp |
| 1006 | else: |
| 1007 | self.dscp = 0 |
| 1008 | if ttl != None: |
| 1009 | self.ttl = ttl |
| 1010 | else: |
| 1011 | self.ttl = 0 |
| 1012 | if vpn != None: |
| 1013 | self.vpn = vpn |
| 1014 | else: |
| 1015 | self.vpn = 0 |
| 1016 | if if_name != None: |
| 1017 | self.if_name = if_name |
| 1018 | else: |
| 1019 | self.if_name = "" |
| 1020 | return |
| 1021 | |
| 1022 | def pack(self): |
| 1023 | packed = [] |
| 1024 | packed.append(struct.pack("!H", self.type)) |
| 1025 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 1026 | packed.append(struct.pack("!L", self.flags)) |
| 1027 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 1028 | packed.append(util.pack_port_no(self.loopback_port_no)) |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 1029 | packed.append(struct.pack("!6B", *self.local_mac)) |
| 1030 | packed.append(struct.pack("!6B", *self.nh_mac)) |
| 1031 | packed.append(struct.pack("!L", self.src_ip)) |
| 1032 | packed.append(struct.pack("!L", self.dst_ip)) |
| 1033 | packed.append(struct.pack("!B", self.dscp)) |
| 1034 | packed.append(struct.pack("!B", self.ttl)) |
| 1035 | packed.append('\x00' * 2) |
| 1036 | packed.append(struct.pack("!L", self.vpn)) |
| 1037 | packed.append(struct.pack("!16s", self.if_name)) |
| 1038 | length = sum([len(x) for x in packed]) |
| 1039 | packed[1] = struct.pack("!H", length) |
| 1040 | return ''.join(packed) |
| 1041 | |
| 1042 | @staticmethod |
| 1043 | def unpack(reader): |
| 1044 | obj = bsn_vport_l2gre() |
| 1045 | _type = reader.read("!H")[0] |
| 1046 | assert(_type == 1) |
| 1047 | _length = reader.read("!H")[0] |
| 1048 | orig_reader = reader |
| 1049 | reader = orig_reader.slice(_length - (2 + 2)) |
| 1050 | obj.flags = reader.read("!L")[0] |
| 1051 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 1052 | obj.loopback_port_no = util.unpack_port_no(reader) |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 1053 | obj.local_mac = list(reader.read('!6B')) |
| 1054 | obj.nh_mac = list(reader.read('!6B')) |
| 1055 | obj.src_ip = reader.read("!L")[0] |
| 1056 | obj.dst_ip = reader.read("!L")[0] |
| 1057 | obj.dscp = reader.read("!B")[0] |
| 1058 | obj.ttl = reader.read("!B")[0] |
| 1059 | reader.skip(2) |
| 1060 | obj.vpn = reader.read("!L")[0] |
| 1061 | obj.if_name = reader.read("!16s")[0].rstrip("\x00") |
| 1062 | return obj |
| 1063 | |
| 1064 | def __eq__(self, other): |
| 1065 | if type(self) != type(other): return False |
| 1066 | if self.flags != other.flags: return False |
| 1067 | if self.port_no != other.port_no: return False |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 1068 | if self.loopback_port_no != other.loopback_port_no: return False |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 1069 | if self.local_mac != other.local_mac: return False |
| 1070 | if self.nh_mac != other.nh_mac: return False |
| 1071 | if self.src_ip != other.src_ip: return False |
| 1072 | if self.dst_ip != other.dst_ip: return False |
| 1073 | if self.dscp != other.dscp: return False |
| 1074 | if self.ttl != other.ttl: return False |
| 1075 | if self.vpn != other.vpn: return False |
| 1076 | if self.if_name != other.if_name: return False |
| 1077 | return True |
| 1078 | |
| 1079 | def pretty_print(self, q): |
| 1080 | q.text("bsn_vport_l2gre {") |
| 1081 | with q.group(): |
| 1082 | with q.indent(2): |
| 1083 | q.breakable() |
| 1084 | q.text("flags = "); |
| 1085 | q.text("%#x" % self.flags) |
| 1086 | q.text(","); q.breakable() |
| 1087 | q.text("port_no = "); |
| 1088 | q.text(util.pretty_port(self.port_no)) |
| 1089 | q.text(","); q.breakable() |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 1090 | q.text("loopback_port_no = "); |
| 1091 | q.text(util.pretty_port(self.loopback_port_no)) |
| 1092 | q.text(","); q.breakable() |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 1093 | q.text("local_mac = "); |
| 1094 | q.text(util.pretty_mac(self.local_mac)) |
| 1095 | q.text(","); q.breakable() |
| 1096 | q.text("nh_mac = "); |
| 1097 | q.text(util.pretty_mac(self.nh_mac)) |
| 1098 | q.text(","); q.breakable() |
| 1099 | q.text("src_ip = "); |
| 1100 | q.text(util.pretty_ipv4(self.src_ip)) |
| 1101 | q.text(","); q.breakable() |
| 1102 | q.text("dst_ip = "); |
| 1103 | q.text(util.pretty_ipv4(self.dst_ip)) |
| 1104 | q.text(","); q.breakable() |
| 1105 | q.text("dscp = "); |
| 1106 | q.text("%#x" % self.dscp) |
| 1107 | q.text(","); q.breakable() |
| 1108 | q.text("ttl = "); |
| 1109 | q.text("%#x" % self.ttl) |
| 1110 | q.text(","); q.breakable() |
| 1111 | q.text("vpn = "); |
| 1112 | q.text("%#x" % self.vpn) |
| 1113 | q.text(","); q.breakable() |
| 1114 | q.text("if_name = "); |
| 1115 | q.pp(self.if_name) |
| 1116 | q.breakable() |
| 1117 | q.text('}') |
| 1118 | |
| 1119 | bsn_vport.subtypes[1] = bsn_vport_l2gre |
| 1120 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1121 | class bsn_vport_q_in_q(bsn_vport): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1122 | type = 0 |
| 1123 | |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 1124 | 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] | 1125 | if port_no != None: |
| 1126 | self.port_no = port_no |
| 1127 | else: |
| 1128 | self.port_no = 0 |
| 1129 | if ingress_tpid != None: |
| 1130 | self.ingress_tpid = ingress_tpid |
| 1131 | else: |
| 1132 | self.ingress_tpid = 0 |
| 1133 | if ingress_vlan_id != None: |
| 1134 | self.ingress_vlan_id = ingress_vlan_id |
| 1135 | else: |
| 1136 | self.ingress_vlan_id = 0 |
| 1137 | if egress_tpid != None: |
| 1138 | self.egress_tpid = egress_tpid |
| 1139 | else: |
| 1140 | self.egress_tpid = 0 |
| 1141 | if egress_vlan_id != None: |
| 1142 | self.egress_vlan_id = egress_vlan_id |
| 1143 | else: |
| 1144 | self.egress_vlan_id = 0 |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 1145 | if if_name != None: |
| 1146 | self.if_name = if_name |
| 1147 | else: |
| 1148 | self.if_name = "" |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1149 | return |
| 1150 | |
| 1151 | def pack(self): |
| 1152 | packed = [] |
| 1153 | packed.append(struct.pack("!H", self.type)) |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 1154 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1155 | packed.append(struct.pack("!L", self.port_no)) |
| 1156 | packed.append(struct.pack("!H", self.ingress_tpid)) |
| 1157 | packed.append(struct.pack("!H", self.ingress_vlan_id)) |
| 1158 | packed.append(struct.pack("!H", self.egress_tpid)) |
| 1159 | packed.append(struct.pack("!H", self.egress_vlan_id)) |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 1160 | packed.append(struct.pack("!16s", self.if_name)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1161 | length = sum([len(x) for x in packed]) |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 1162 | packed[1] = struct.pack("!H", length) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1163 | return ''.join(packed) |
| 1164 | |
| 1165 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1166 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1167 | obj = bsn_vport_q_in_q() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1168 | _type = reader.read("!H")[0] |
| 1169 | assert(_type == 0) |
| 1170 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1171 | orig_reader = reader |
| 1172 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1173 | obj.port_no = reader.read("!L")[0] |
| 1174 | obj.ingress_tpid = reader.read("!H")[0] |
| 1175 | obj.ingress_vlan_id = reader.read("!H")[0] |
| 1176 | obj.egress_tpid = reader.read("!H")[0] |
| 1177 | obj.egress_vlan_id = reader.read("!H")[0] |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 1178 | obj.if_name = reader.read("!16s")[0].rstrip("\x00") |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1179 | return obj |
| 1180 | |
| 1181 | def __eq__(self, other): |
| 1182 | if type(self) != type(other): return False |
| 1183 | if self.port_no != other.port_no: return False |
| 1184 | if self.ingress_tpid != other.ingress_tpid: return False |
| 1185 | if self.ingress_vlan_id != other.ingress_vlan_id: return False |
| 1186 | if self.egress_tpid != other.egress_tpid: return False |
| 1187 | if self.egress_vlan_id != other.egress_vlan_id: return False |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 1188 | if self.if_name != other.if_name: return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1189 | return True |
| 1190 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1191 | def pretty_print(self, q): |
| 1192 | q.text("bsn_vport_q_in_q {") |
| 1193 | with q.group(): |
| 1194 | with q.indent(2): |
| 1195 | q.breakable() |
| 1196 | q.text("port_no = "); |
| 1197 | q.text("%#x" % self.port_no) |
| 1198 | q.text(","); q.breakable() |
| 1199 | q.text("ingress_tpid = "); |
| 1200 | q.text("%#x" % self.ingress_tpid) |
| 1201 | q.text(","); q.breakable() |
| 1202 | q.text("ingress_vlan_id = "); |
| 1203 | q.text("%#x" % self.ingress_vlan_id) |
| 1204 | q.text(","); q.breakable() |
| 1205 | q.text("egress_tpid = "); |
| 1206 | q.text("%#x" % self.egress_tpid) |
| 1207 | q.text(","); q.breakable() |
| 1208 | q.text("egress_vlan_id = "); |
| 1209 | q.text("%#x" % self.egress_vlan_id) |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 1210 | q.text(","); q.breakable() |
| 1211 | q.text("if_name = "); |
| 1212 | q.pp(self.if_name) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1213 | q.breakable() |
| 1214 | q.text('}') |
| 1215 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1216 | bsn_vport.subtypes[0] = bsn_vport_q_in_q |
| 1217 | |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 1218 | class bsn_vrf_counter_stats_entry(loxi.OFObject): |
| 1219 | |
| 1220 | def __init__(self, vrf=None, values=None): |
| 1221 | if vrf != None: |
| 1222 | self.vrf = vrf |
| 1223 | else: |
| 1224 | self.vrf = 0 |
| 1225 | if values != None: |
| 1226 | self.values = values |
| 1227 | else: |
| 1228 | self.values = [] |
| 1229 | return |
| 1230 | |
| 1231 | def pack(self): |
| 1232 | packed = [] |
| 1233 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 1234 | packed.append('\x00' * 2) |
| 1235 | packed.append(struct.pack("!L", self.vrf)) |
| 1236 | packed.append(loxi.generic_util.pack_list(self.values)) |
| 1237 | length = sum([len(x) for x in packed]) |
| 1238 | packed[0] = struct.pack("!H", length) |
| 1239 | return ''.join(packed) |
| 1240 | |
| 1241 | @staticmethod |
| 1242 | def unpack(reader): |
| 1243 | obj = bsn_vrf_counter_stats_entry() |
| 1244 | _length = reader.read("!H")[0] |
| 1245 | orig_reader = reader |
| 1246 | reader = orig_reader.slice(_length - (0 + 2)) |
| 1247 | reader.skip(2) |
| 1248 | obj.vrf = reader.read("!L")[0] |
| 1249 | obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack) |
| 1250 | return obj |
| 1251 | |
| 1252 | def __eq__(self, other): |
| 1253 | if type(self) != type(other): return False |
| 1254 | if self.vrf != other.vrf: return False |
| 1255 | if self.values != other.values: return False |
| 1256 | return True |
| 1257 | |
| 1258 | def pretty_print(self, q): |
| 1259 | q.text("bsn_vrf_counter_stats_entry {") |
| 1260 | with q.group(): |
| 1261 | with q.indent(2): |
| 1262 | q.breakable() |
| 1263 | q.text("vrf = "); |
| 1264 | q.text("%#x" % self.vrf) |
| 1265 | q.text(","); q.breakable() |
| 1266 | q.text("values = "); |
| 1267 | q.pp(self.values) |
| 1268 | q.breakable() |
| 1269 | q.text('}') |
| 1270 | |
| 1271 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1272 | class bucket(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1273 | |
| 1274 | def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None): |
| 1275 | if weight != None: |
| 1276 | self.weight = weight |
| 1277 | else: |
| 1278 | self.weight = 0 |
| 1279 | if watch_port != None: |
| 1280 | self.watch_port = watch_port |
| 1281 | else: |
| 1282 | self.watch_port = 0 |
| 1283 | if watch_group != None: |
| 1284 | self.watch_group = watch_group |
| 1285 | else: |
| 1286 | self.watch_group = 0 |
| 1287 | if actions != None: |
| 1288 | self.actions = actions |
| 1289 | else: |
| 1290 | self.actions = [] |
| 1291 | return |
| 1292 | |
| 1293 | def pack(self): |
| 1294 | packed = [] |
| 1295 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 0 |
| 1296 | packed.append(struct.pack("!H", self.weight)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1297 | packed.append(util.pack_port_no(self.watch_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1298 | packed.append(struct.pack("!L", self.watch_group)) |
| 1299 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1300 | packed.append(loxi.generic_util.pack_list(self.actions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1301 | length = sum([len(x) for x in packed]) |
| 1302 | packed[0] = struct.pack("!H", length) |
| 1303 | return ''.join(packed) |
| 1304 | |
| 1305 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1306 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1307 | obj = bucket() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1308 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1309 | orig_reader = reader |
| 1310 | reader = orig_reader.slice(_len - (0 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1311 | obj.weight = reader.read("!H")[0] |
| 1312 | obj.watch_port = util.unpack_port_no(reader) |
| 1313 | obj.watch_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1314 | reader.skip(4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1315 | obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1316 | return obj |
| 1317 | |
| 1318 | def __eq__(self, other): |
| 1319 | if type(self) != type(other): return False |
| 1320 | if self.weight != other.weight: return False |
| 1321 | if self.watch_port != other.watch_port: return False |
| 1322 | if self.watch_group != other.watch_group: return False |
| 1323 | if self.actions != other.actions: return False |
| 1324 | return True |
| 1325 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1326 | def pretty_print(self, q): |
| 1327 | q.text("bucket {") |
| 1328 | with q.group(): |
| 1329 | with q.indent(2): |
| 1330 | q.breakable() |
| 1331 | q.text("weight = "); |
| 1332 | q.text("%#x" % self.weight) |
| 1333 | q.text(","); q.breakable() |
| 1334 | q.text("watch_port = "); |
| 1335 | q.text(util.pretty_port(self.watch_port)) |
| 1336 | q.text(","); q.breakable() |
| 1337 | q.text("watch_group = "); |
| 1338 | q.text("%#x" % self.watch_group) |
| 1339 | q.text(","); q.breakable() |
| 1340 | q.text("actions = "); |
| 1341 | q.pp(self.actions) |
| 1342 | q.breakable() |
| 1343 | q.text('}') |
| 1344 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1345 | |
| 1346 | class bucket_counter(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1347 | |
| 1348 | def __init__(self, packet_count=None, byte_count=None): |
| 1349 | if packet_count != None: |
| 1350 | self.packet_count = packet_count |
| 1351 | else: |
| 1352 | self.packet_count = 0 |
| 1353 | if byte_count != None: |
| 1354 | self.byte_count = byte_count |
| 1355 | else: |
| 1356 | self.byte_count = 0 |
| 1357 | return |
| 1358 | |
| 1359 | def pack(self): |
| 1360 | packed = [] |
| 1361 | packed.append(struct.pack("!Q", self.packet_count)) |
| 1362 | packed.append(struct.pack("!Q", self.byte_count)) |
| 1363 | return ''.join(packed) |
| 1364 | |
| 1365 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1366 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1367 | obj = bucket_counter() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1368 | obj.packet_count = reader.read("!Q")[0] |
| 1369 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1370 | return obj |
| 1371 | |
| 1372 | def __eq__(self, other): |
| 1373 | if type(self) != type(other): return False |
| 1374 | if self.packet_count != other.packet_count: return False |
| 1375 | if self.byte_count != other.byte_count: return False |
| 1376 | return True |
| 1377 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1378 | def pretty_print(self, q): |
| 1379 | q.text("bucket_counter {") |
| 1380 | with q.group(): |
| 1381 | with q.indent(2): |
| 1382 | q.breakable() |
| 1383 | q.text("packet_count = "); |
| 1384 | q.text("%#x" % self.packet_count) |
| 1385 | q.text(","); q.breakable() |
| 1386 | q.text("byte_count = "); |
| 1387 | q.text("%#x" % self.byte_count) |
| 1388 | q.breakable() |
| 1389 | q.text('}') |
| 1390 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1391 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1392 | class flow_stats_entry(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1393 | |
Kiran Poola | ae8fbf1 | 2013-09-19 16:32:32 -0700 | [diff] [blame] | 1394 | 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] | 1395 | if table_id != None: |
| 1396 | self.table_id = table_id |
| 1397 | else: |
| 1398 | self.table_id = 0 |
| 1399 | if duration_sec != None: |
| 1400 | self.duration_sec = duration_sec |
| 1401 | else: |
| 1402 | self.duration_sec = 0 |
| 1403 | if duration_nsec != None: |
| 1404 | self.duration_nsec = duration_nsec |
| 1405 | else: |
| 1406 | self.duration_nsec = 0 |
| 1407 | if priority != None: |
| 1408 | self.priority = priority |
| 1409 | else: |
| 1410 | self.priority = 0 |
| 1411 | if idle_timeout != None: |
| 1412 | self.idle_timeout = idle_timeout |
| 1413 | else: |
| 1414 | self.idle_timeout = 0 |
| 1415 | if hard_timeout != None: |
| 1416 | self.hard_timeout = hard_timeout |
| 1417 | else: |
| 1418 | self.hard_timeout = 0 |
Kiran Poola | ae8fbf1 | 2013-09-19 16:32:32 -0700 | [diff] [blame] | 1419 | if flags != None: |
| 1420 | self.flags = flags |
| 1421 | else: |
| 1422 | self.flags = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1423 | if cookie != None: |
| 1424 | self.cookie = cookie |
| 1425 | else: |
| 1426 | self.cookie = 0 |
| 1427 | if packet_count != None: |
| 1428 | self.packet_count = packet_count |
| 1429 | else: |
| 1430 | self.packet_count = 0 |
| 1431 | if byte_count != None: |
| 1432 | self.byte_count = byte_count |
| 1433 | else: |
| 1434 | self.byte_count = 0 |
| 1435 | if match != None: |
| 1436 | self.match = match |
| 1437 | else: |
| 1438 | self.match = common.match() |
| 1439 | if instructions != None: |
| 1440 | self.instructions = instructions |
| 1441 | else: |
| 1442 | self.instructions = [] |
| 1443 | return |
| 1444 | |
| 1445 | def pack(self): |
| 1446 | packed = [] |
| 1447 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 1448 | packed.append(struct.pack("!B", self.table_id)) |
| 1449 | packed.append('\x00' * 1) |
| 1450 | packed.append(struct.pack("!L", self.duration_sec)) |
| 1451 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 1452 | packed.append(struct.pack("!H", self.priority)) |
| 1453 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 1454 | packed.append(struct.pack("!H", self.hard_timeout)) |
Kiran Poola | ae8fbf1 | 2013-09-19 16:32:32 -0700 | [diff] [blame] | 1455 | packed.append(struct.pack("!H", self.flags)) |
| 1456 | packed.append('\x00' * 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1457 | packed.append(struct.pack("!Q", self.cookie)) |
| 1458 | packed.append(struct.pack("!Q", self.packet_count)) |
| 1459 | packed.append(struct.pack("!Q", self.byte_count)) |
| 1460 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1461 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1462 | length = sum([len(x) for x in packed]) |
| 1463 | packed[0] = struct.pack("!H", length) |
| 1464 | return ''.join(packed) |
| 1465 | |
| 1466 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1467 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1468 | obj = flow_stats_entry() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1469 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1470 | orig_reader = reader |
| 1471 | reader = orig_reader.slice(_length - (0 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1472 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1473 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1474 | obj.duration_sec = reader.read("!L")[0] |
| 1475 | obj.duration_nsec = reader.read("!L")[0] |
| 1476 | obj.priority = reader.read("!H")[0] |
| 1477 | obj.idle_timeout = reader.read("!H")[0] |
| 1478 | obj.hard_timeout = reader.read("!H")[0] |
Kiran Poola | ae8fbf1 | 2013-09-19 16:32:32 -0700 | [diff] [blame] | 1479 | obj.flags = reader.read("!H")[0] |
| 1480 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1481 | obj.cookie = reader.read("!Q")[0] |
| 1482 | obj.packet_count = reader.read("!Q")[0] |
| 1483 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1484 | obj.match = common.match.unpack(reader) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1485 | obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1486 | return obj |
| 1487 | |
| 1488 | def __eq__(self, other): |
| 1489 | if type(self) != type(other): return False |
| 1490 | if self.table_id != other.table_id: return False |
| 1491 | if self.duration_sec != other.duration_sec: return False |
| 1492 | if self.duration_nsec != other.duration_nsec: return False |
| 1493 | if self.priority != other.priority: return False |
| 1494 | if self.idle_timeout != other.idle_timeout: return False |
| 1495 | if self.hard_timeout != other.hard_timeout: return False |
Kiran Poola | ae8fbf1 | 2013-09-19 16:32:32 -0700 | [diff] [blame] | 1496 | if self.flags != other.flags: return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1497 | if self.cookie != other.cookie: return False |
| 1498 | if self.packet_count != other.packet_count: return False |
| 1499 | if self.byte_count != other.byte_count: return False |
| 1500 | if self.match != other.match: return False |
| 1501 | if self.instructions != other.instructions: return False |
| 1502 | return True |
| 1503 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1504 | def pretty_print(self, q): |
| 1505 | q.text("flow_stats_entry {") |
| 1506 | with q.group(): |
| 1507 | with q.indent(2): |
| 1508 | q.breakable() |
| 1509 | q.text("table_id = "); |
| 1510 | q.text("%#x" % self.table_id) |
| 1511 | q.text(","); q.breakable() |
| 1512 | q.text("duration_sec = "); |
| 1513 | q.text("%#x" % self.duration_sec) |
| 1514 | q.text(","); q.breakable() |
| 1515 | q.text("duration_nsec = "); |
| 1516 | q.text("%#x" % self.duration_nsec) |
| 1517 | q.text(","); q.breakable() |
| 1518 | q.text("priority = "); |
| 1519 | q.text("%#x" % self.priority) |
| 1520 | q.text(","); q.breakable() |
| 1521 | q.text("idle_timeout = "); |
| 1522 | q.text("%#x" % self.idle_timeout) |
| 1523 | q.text(","); q.breakable() |
| 1524 | q.text("hard_timeout = "); |
| 1525 | q.text("%#x" % self.hard_timeout) |
| 1526 | q.text(","); q.breakable() |
Kiran Poola | ae8fbf1 | 2013-09-19 16:32:32 -0700 | [diff] [blame] | 1527 | q.text("flags = "); |
| 1528 | q.text("%#x" % self.flags) |
| 1529 | q.text(","); q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1530 | q.text("cookie = "); |
| 1531 | q.text("%#x" % self.cookie) |
| 1532 | q.text(","); q.breakable() |
| 1533 | q.text("packet_count = "); |
| 1534 | q.text("%#x" % self.packet_count) |
| 1535 | q.text(","); q.breakable() |
| 1536 | q.text("byte_count = "); |
| 1537 | q.text("%#x" % self.byte_count) |
| 1538 | q.text(","); q.breakable() |
| 1539 | q.text("match = "); |
| 1540 | q.pp(self.match) |
| 1541 | q.text(","); q.breakable() |
| 1542 | q.text("instructions = "); |
| 1543 | q.pp(self.instructions) |
| 1544 | q.breakable() |
| 1545 | q.text('}') |
| 1546 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1547 | |
| 1548 | class group_desc_stats_entry(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1549 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1550 | def __init__(self, group_type=None, group_id=None, buckets=None): |
| 1551 | if group_type != None: |
| 1552 | self.group_type = group_type |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1553 | else: |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1554 | self.group_type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1555 | if group_id != None: |
| 1556 | self.group_id = group_id |
| 1557 | else: |
| 1558 | self.group_id = 0 |
| 1559 | if buckets != None: |
| 1560 | self.buckets = buckets |
| 1561 | else: |
| 1562 | self.buckets = [] |
| 1563 | return |
| 1564 | |
| 1565 | def pack(self): |
| 1566 | packed = [] |
| 1567 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1568 | packed.append(struct.pack("!B", self.group_type)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1569 | packed.append('\x00' * 1) |
| 1570 | packed.append(struct.pack("!L", self.group_id)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1571 | packed.append(loxi.generic_util.pack_list(self.buckets)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1572 | length = sum([len(x) for x in packed]) |
| 1573 | packed[0] = struct.pack("!H", length) |
| 1574 | return ''.join(packed) |
| 1575 | |
| 1576 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1577 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1578 | obj = group_desc_stats_entry() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1579 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1580 | orig_reader = reader |
| 1581 | reader = orig_reader.slice(_length - (0 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1582 | obj.group_type = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1583 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1584 | obj.group_id = reader.read("!L")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1585 | obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1586 | return obj |
| 1587 | |
| 1588 | def __eq__(self, other): |
| 1589 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1590 | if self.group_type != other.group_type: return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1591 | if self.group_id != other.group_id: return False |
| 1592 | if self.buckets != other.buckets: return False |
| 1593 | return True |
| 1594 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1595 | def pretty_print(self, q): |
| 1596 | q.text("group_desc_stats_entry {") |
| 1597 | with q.group(): |
| 1598 | with q.indent(2): |
| 1599 | q.breakable() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1600 | q.text("group_type = "); |
| 1601 | q.text("%#x" % self.group_type) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1602 | q.text(","); q.breakable() |
| 1603 | q.text("group_id = "); |
| 1604 | q.text("%#x" % self.group_id) |
| 1605 | q.text(","); q.breakable() |
| 1606 | q.text("buckets = "); |
| 1607 | q.pp(self.buckets) |
| 1608 | q.breakable() |
| 1609 | q.text('}') |
| 1610 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1611 | |
| 1612 | class group_stats_entry(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1613 | |
| 1614 | def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, duration_sec=None, duration_nsec=None, bucket_stats=None): |
| 1615 | if group_id != None: |
| 1616 | self.group_id = group_id |
| 1617 | else: |
| 1618 | self.group_id = 0 |
| 1619 | if ref_count != None: |
| 1620 | self.ref_count = ref_count |
| 1621 | else: |
| 1622 | self.ref_count = 0 |
| 1623 | if packet_count != None: |
| 1624 | self.packet_count = packet_count |
| 1625 | else: |
| 1626 | self.packet_count = 0 |
| 1627 | if byte_count != None: |
| 1628 | self.byte_count = byte_count |
| 1629 | else: |
| 1630 | self.byte_count = 0 |
| 1631 | if duration_sec != None: |
| 1632 | self.duration_sec = duration_sec |
| 1633 | else: |
| 1634 | self.duration_sec = 0 |
| 1635 | if duration_nsec != None: |
| 1636 | self.duration_nsec = duration_nsec |
| 1637 | else: |
| 1638 | self.duration_nsec = 0 |
| 1639 | if bucket_stats != None: |
| 1640 | self.bucket_stats = bucket_stats |
| 1641 | else: |
| 1642 | self.bucket_stats = [] |
| 1643 | return |
| 1644 | |
| 1645 | def pack(self): |
| 1646 | packed = [] |
| 1647 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 1648 | packed.append('\x00' * 2) |
| 1649 | packed.append(struct.pack("!L", self.group_id)) |
| 1650 | packed.append(struct.pack("!L", self.ref_count)) |
| 1651 | packed.append('\x00' * 4) |
| 1652 | packed.append(struct.pack("!Q", self.packet_count)) |
| 1653 | packed.append(struct.pack("!Q", self.byte_count)) |
| 1654 | packed.append(struct.pack("!L", self.duration_sec)) |
| 1655 | packed.append(struct.pack("!L", self.duration_nsec)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1656 | packed.append(loxi.generic_util.pack_list(self.bucket_stats)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1657 | length = sum([len(x) for x in packed]) |
| 1658 | packed[0] = struct.pack("!H", length) |
| 1659 | return ''.join(packed) |
| 1660 | |
| 1661 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1662 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1663 | obj = group_stats_entry() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1664 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1665 | orig_reader = reader |
| 1666 | reader = orig_reader.slice(_length - (0 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1667 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1668 | obj.group_id = reader.read("!L")[0] |
| 1669 | obj.ref_count = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1670 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1671 | obj.packet_count = reader.read("!Q")[0] |
| 1672 | obj.byte_count = reader.read("!Q")[0] |
| 1673 | obj.duration_sec = reader.read("!L")[0] |
| 1674 | obj.duration_nsec = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1675 | obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack) |
| 1676 | return obj |
| 1677 | |
| 1678 | def __eq__(self, other): |
| 1679 | if type(self) != type(other): return False |
| 1680 | if self.group_id != other.group_id: return False |
| 1681 | if self.ref_count != other.ref_count: return False |
| 1682 | if self.packet_count != other.packet_count: return False |
| 1683 | if self.byte_count != other.byte_count: return False |
| 1684 | if self.duration_sec != other.duration_sec: return False |
| 1685 | if self.duration_nsec != other.duration_nsec: return False |
| 1686 | if self.bucket_stats != other.bucket_stats: return False |
| 1687 | return True |
| 1688 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1689 | def pretty_print(self, q): |
| 1690 | q.text("group_stats_entry {") |
| 1691 | with q.group(): |
| 1692 | with q.indent(2): |
| 1693 | q.breakable() |
| 1694 | q.text("group_id = "); |
| 1695 | q.text("%#x" % self.group_id) |
| 1696 | q.text(","); q.breakable() |
| 1697 | q.text("ref_count = "); |
| 1698 | q.text("%#x" % self.ref_count) |
| 1699 | q.text(","); q.breakable() |
| 1700 | q.text("packet_count = "); |
| 1701 | q.text("%#x" % self.packet_count) |
| 1702 | q.text(","); q.breakable() |
| 1703 | q.text("byte_count = "); |
| 1704 | q.text("%#x" % self.byte_count) |
| 1705 | q.text(","); q.breakable() |
| 1706 | q.text("duration_sec = "); |
| 1707 | q.text("%#x" % self.duration_sec) |
| 1708 | q.text(","); q.breakable() |
| 1709 | q.text("duration_nsec = "); |
| 1710 | q.text("%#x" % self.duration_nsec) |
| 1711 | q.text(","); q.breakable() |
| 1712 | q.text("bucket_stats = "); |
| 1713 | q.pp(self.bucket_stats) |
| 1714 | q.breakable() |
| 1715 | q.text('}') |
| 1716 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1717 | |
| 1718 | class hello_elem(loxi.OFObject): |
| 1719 | subtypes = {} |
| 1720 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1721 | |
| 1722 | def __init__(self, type=None): |
| 1723 | if type != None: |
| 1724 | self.type = type |
| 1725 | else: |
| 1726 | self.type = 0 |
| 1727 | return |
| 1728 | |
| 1729 | def pack(self): |
| 1730 | packed = [] |
| 1731 | packed.append(struct.pack("!H", self.type)) |
| 1732 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 1733 | length = sum([len(x) for x in packed]) |
| 1734 | packed[1] = struct.pack("!H", length) |
| 1735 | return ''.join(packed) |
| 1736 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1737 | @staticmethod |
| 1738 | def unpack(reader): |
| 1739 | subtype, = reader.peek('!H', 0) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1740 | subclass = hello_elem.subtypes.get(subtype) |
| 1741 | if subclass: |
| 1742 | return subclass.unpack(reader) |
| 1743 | |
| 1744 | obj = hello_elem() |
| 1745 | obj.type = reader.read("!H")[0] |
| 1746 | _length = reader.read("!H")[0] |
| 1747 | orig_reader = reader |
| 1748 | reader = orig_reader.slice(_length - (2 + 2)) |
| 1749 | return obj |
| 1750 | |
| 1751 | def __eq__(self, other): |
| 1752 | if type(self) != type(other): return False |
| 1753 | if self.type != other.type: return False |
| 1754 | return True |
| 1755 | |
| 1756 | def pretty_print(self, q): |
| 1757 | q.text("hello_elem {") |
| 1758 | with q.group(): |
| 1759 | with q.indent(2): |
| 1760 | q.breakable() |
| 1761 | q.breakable() |
| 1762 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1763 | |
| 1764 | |
| 1765 | class hello_elem_versionbitmap(hello_elem): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1766 | type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1767 | |
| 1768 | def __init__(self, bitmaps=None): |
| 1769 | if bitmaps != None: |
| 1770 | self.bitmaps = bitmaps |
| 1771 | else: |
| 1772 | self.bitmaps = [] |
| 1773 | return |
| 1774 | |
| 1775 | def pack(self): |
| 1776 | packed = [] |
| 1777 | packed.append(struct.pack("!H", self.type)) |
| 1778 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1779 | packed.append(loxi.generic_util.pack_list(self.bitmaps)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1780 | length = sum([len(x) for x in packed]) |
| 1781 | packed[1] = struct.pack("!H", length) |
| 1782 | return ''.join(packed) |
| 1783 | |
| 1784 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1785 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1786 | obj = hello_elem_versionbitmap() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1787 | _type = reader.read("!H")[0] |
| 1788 | assert(_type == 1) |
| 1789 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1790 | orig_reader = reader |
| 1791 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1792 | obj.bitmaps = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 1793 | return obj |
| 1794 | |
| 1795 | def __eq__(self, other): |
| 1796 | if type(self) != type(other): return False |
| 1797 | if self.bitmaps != other.bitmaps: return False |
| 1798 | return True |
| 1799 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1800 | def pretty_print(self, q): |
| 1801 | q.text("hello_elem_versionbitmap {") |
| 1802 | with q.group(): |
| 1803 | with q.indent(2): |
| 1804 | q.breakable() |
| 1805 | q.text("bitmaps = "); |
| 1806 | q.pp(self.bitmaps) |
| 1807 | q.breakable() |
| 1808 | q.text('}') |
| 1809 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1810 | hello_elem.subtypes[1] = hello_elem_versionbitmap |
| 1811 | |
| 1812 | class match_v3(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1813 | type = 1 |
| 1814 | |
| 1815 | def __init__(self, oxm_list=None): |
| 1816 | if oxm_list != None: |
| 1817 | self.oxm_list = oxm_list |
| 1818 | else: |
| 1819 | self.oxm_list = [] |
| 1820 | return |
| 1821 | |
| 1822 | def pack(self): |
| 1823 | packed = [] |
| 1824 | packed.append(struct.pack("!H", self.type)) |
| 1825 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1826 | packed.append(loxi.generic_util.pack_list(self.oxm_list)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1827 | length = sum([len(x) for x in packed]) |
| 1828 | packed[1] = struct.pack("!H", length) |
Rich Lane | d53156a | 2013-08-05 17:17:33 -0700 | [diff] [blame] | 1829 | packed.append(loxi.generic_util.pad_to(8, length)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1830 | return ''.join(packed) |
| 1831 | |
| 1832 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1833 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1834 | obj = match_v3() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1835 | _type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1836 | assert(_type == 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1837 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1838 | orig_reader = reader |
| 1839 | reader = orig_reader.slice(_length - (2 + 2)) |
| 1840 | obj.oxm_list = loxi.generic_util.unpack_list(reader, oxm.oxm.unpack) |
| 1841 | orig_reader.skip_align() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1842 | return obj |
| 1843 | |
| 1844 | def __eq__(self, other): |
| 1845 | if type(self) != type(other): return False |
| 1846 | if self.oxm_list != other.oxm_list: return False |
| 1847 | return True |
| 1848 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1849 | def pretty_print(self, q): |
| 1850 | q.text("match_v3 {") |
| 1851 | with q.group(): |
| 1852 | with q.indent(2): |
| 1853 | q.breakable() |
| 1854 | q.text("oxm_list = "); |
| 1855 | q.pp(self.oxm_list) |
| 1856 | q.breakable() |
| 1857 | q.text('}') |
| 1858 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1859 | |
| 1860 | class meter_band_stats(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1861 | |
| 1862 | def __init__(self, packet_band_count=None, byte_band_count=None): |
| 1863 | if packet_band_count != None: |
| 1864 | self.packet_band_count = packet_band_count |
| 1865 | else: |
| 1866 | self.packet_band_count = 0 |
| 1867 | if byte_band_count != None: |
| 1868 | self.byte_band_count = byte_band_count |
| 1869 | else: |
| 1870 | self.byte_band_count = 0 |
| 1871 | return |
| 1872 | |
| 1873 | def pack(self): |
| 1874 | packed = [] |
| 1875 | packed.append(struct.pack("!Q", self.packet_band_count)) |
| 1876 | packed.append(struct.pack("!Q", self.byte_band_count)) |
| 1877 | return ''.join(packed) |
| 1878 | |
| 1879 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1880 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1881 | obj = meter_band_stats() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1882 | obj.packet_band_count = reader.read("!Q")[0] |
| 1883 | obj.byte_band_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1884 | return obj |
| 1885 | |
| 1886 | def __eq__(self, other): |
| 1887 | if type(self) != type(other): return False |
| 1888 | if self.packet_band_count != other.packet_band_count: return False |
| 1889 | if self.byte_band_count != other.byte_band_count: return False |
| 1890 | return True |
| 1891 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1892 | def pretty_print(self, q): |
| 1893 | q.text("meter_band_stats {") |
| 1894 | with q.group(): |
| 1895 | with q.indent(2): |
| 1896 | q.breakable() |
| 1897 | q.text("packet_band_count = "); |
| 1898 | q.text("%#x" % self.packet_band_count) |
| 1899 | q.text(","); q.breakable() |
| 1900 | q.text("byte_band_count = "); |
| 1901 | q.text("%#x" % self.byte_band_count) |
| 1902 | q.breakable() |
| 1903 | q.text('}') |
| 1904 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1905 | |
| 1906 | class meter_config(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1907 | |
| 1908 | def __init__(self, flags=None, meter_id=None, entries=None): |
| 1909 | if flags != None: |
| 1910 | self.flags = flags |
| 1911 | else: |
| 1912 | self.flags = 0 |
| 1913 | if meter_id != None: |
| 1914 | self.meter_id = meter_id |
| 1915 | else: |
| 1916 | self.meter_id = 0 |
| 1917 | if entries != None: |
| 1918 | self.entries = entries |
| 1919 | else: |
| 1920 | self.entries = [] |
| 1921 | return |
| 1922 | |
| 1923 | def pack(self): |
| 1924 | packed = [] |
| 1925 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 1926 | packed.append(struct.pack("!H", self.flags)) |
| 1927 | packed.append(struct.pack("!L", self.meter_id)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1928 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1929 | length = sum([len(x) for x in packed]) |
| 1930 | packed[0] = struct.pack("!H", length) |
| 1931 | return ''.join(packed) |
| 1932 | |
| 1933 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1934 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1935 | obj = meter_config() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1936 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1937 | orig_reader = reader |
| 1938 | reader = orig_reader.slice(_length - (0 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1939 | obj.flags = reader.read("!H")[0] |
| 1940 | obj.meter_id = reader.read("!L")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1941 | 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] | 1942 | return obj |
| 1943 | |
| 1944 | def __eq__(self, other): |
| 1945 | if type(self) != type(other): return False |
| 1946 | if self.flags != other.flags: return False |
| 1947 | if self.meter_id != other.meter_id: return False |
| 1948 | if self.entries != other.entries: return False |
| 1949 | return True |
| 1950 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1951 | def pretty_print(self, q): |
| 1952 | q.text("meter_config {") |
| 1953 | with q.group(): |
| 1954 | with q.indent(2): |
| 1955 | q.breakable() |
| 1956 | q.text("flags = "); |
| 1957 | q.text("%#x" % self.flags) |
| 1958 | q.text(","); q.breakable() |
| 1959 | q.text("meter_id = "); |
| 1960 | q.text("%#x" % self.meter_id) |
| 1961 | q.text(","); q.breakable() |
| 1962 | q.text("entries = "); |
| 1963 | q.pp(self.entries) |
| 1964 | q.breakable() |
| 1965 | q.text('}') |
| 1966 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1967 | |
| 1968 | class meter_features(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1969 | |
| 1970 | def __init__(self, max_meter=None, band_types=None, capabilities=None, max_bands=None, max_color=None): |
| 1971 | if max_meter != None: |
| 1972 | self.max_meter = max_meter |
| 1973 | else: |
| 1974 | self.max_meter = 0 |
| 1975 | if band_types != None: |
| 1976 | self.band_types = band_types |
| 1977 | else: |
| 1978 | self.band_types = 0 |
| 1979 | if capabilities != None: |
| 1980 | self.capabilities = capabilities |
| 1981 | else: |
| 1982 | self.capabilities = 0 |
| 1983 | if max_bands != None: |
| 1984 | self.max_bands = max_bands |
| 1985 | else: |
| 1986 | self.max_bands = 0 |
| 1987 | if max_color != None: |
| 1988 | self.max_color = max_color |
| 1989 | else: |
| 1990 | self.max_color = 0 |
| 1991 | return |
| 1992 | |
| 1993 | def pack(self): |
| 1994 | packed = [] |
| 1995 | packed.append(struct.pack("!L", self.max_meter)) |
| 1996 | packed.append(struct.pack("!L", self.band_types)) |
| 1997 | packed.append(struct.pack("!L", self.capabilities)) |
| 1998 | packed.append(struct.pack("!B", self.max_bands)) |
| 1999 | packed.append(struct.pack("!B", self.max_color)) |
| 2000 | packed.append('\x00' * 2) |
| 2001 | return ''.join(packed) |
| 2002 | |
| 2003 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2004 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2005 | obj = meter_features() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2006 | obj.max_meter = reader.read("!L")[0] |
| 2007 | obj.band_types = reader.read("!L")[0] |
| 2008 | obj.capabilities = reader.read("!L")[0] |
| 2009 | obj.max_bands = reader.read("!B")[0] |
| 2010 | obj.max_color = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2011 | reader.skip(2) |
| 2012 | return obj |
| 2013 | |
| 2014 | def __eq__(self, other): |
| 2015 | if type(self) != type(other): return False |
| 2016 | if self.max_meter != other.max_meter: return False |
| 2017 | if self.band_types != other.band_types: return False |
| 2018 | if self.capabilities != other.capabilities: return False |
| 2019 | if self.max_bands != other.max_bands: return False |
| 2020 | if self.max_color != other.max_color: return False |
| 2021 | return True |
| 2022 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2023 | def pretty_print(self, q): |
| 2024 | q.text("meter_features {") |
| 2025 | with q.group(): |
| 2026 | with q.indent(2): |
| 2027 | q.breakable() |
| 2028 | q.text("max_meter = "); |
| 2029 | q.text("%#x" % self.max_meter) |
| 2030 | q.text(","); q.breakable() |
| 2031 | q.text("band_types = "); |
| 2032 | q.text("%#x" % self.band_types) |
| 2033 | q.text(","); q.breakable() |
| 2034 | q.text("capabilities = "); |
| 2035 | q.text("%#x" % self.capabilities) |
| 2036 | q.text(","); q.breakable() |
| 2037 | q.text("max_bands = "); |
| 2038 | q.text("%#x" % self.max_bands) |
| 2039 | q.text(","); q.breakable() |
| 2040 | q.text("max_color = "); |
| 2041 | q.text("%#x" % self.max_color) |
| 2042 | q.breakable() |
| 2043 | q.text('}') |
| 2044 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2045 | |
| 2046 | class meter_stats(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2047 | |
| 2048 | 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): |
| 2049 | if meter_id != None: |
| 2050 | self.meter_id = meter_id |
| 2051 | else: |
| 2052 | self.meter_id = 0 |
| 2053 | if flow_count != None: |
| 2054 | self.flow_count = flow_count |
| 2055 | else: |
| 2056 | self.flow_count = 0 |
| 2057 | if packet_in_count != None: |
| 2058 | self.packet_in_count = packet_in_count |
| 2059 | else: |
| 2060 | self.packet_in_count = 0 |
| 2061 | if byte_in_count != None: |
| 2062 | self.byte_in_count = byte_in_count |
| 2063 | else: |
| 2064 | self.byte_in_count = 0 |
| 2065 | if duration_sec != None: |
| 2066 | self.duration_sec = duration_sec |
| 2067 | else: |
| 2068 | self.duration_sec = 0 |
| 2069 | if duration_nsec != None: |
| 2070 | self.duration_nsec = duration_nsec |
| 2071 | else: |
| 2072 | self.duration_nsec = 0 |
| 2073 | if band_stats != None: |
| 2074 | self.band_stats = band_stats |
| 2075 | else: |
| 2076 | self.band_stats = [] |
| 2077 | return |
| 2078 | |
| 2079 | def pack(self): |
| 2080 | packed = [] |
| 2081 | packed.append(struct.pack("!L", self.meter_id)) |
| 2082 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 2083 | packed.append('\x00' * 6) |
| 2084 | packed.append(struct.pack("!L", self.flow_count)) |
| 2085 | packed.append(struct.pack("!Q", self.packet_in_count)) |
| 2086 | packed.append(struct.pack("!Q", self.byte_in_count)) |
| 2087 | packed.append(struct.pack("!L", self.duration_sec)) |
| 2088 | packed.append(struct.pack("!L", self.duration_nsec)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2089 | packed.append(loxi.generic_util.pack_list(self.band_stats)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2090 | length = sum([len(x) for x in packed]) |
| 2091 | packed[1] = struct.pack("!H", length) |
| 2092 | return ''.join(packed) |
| 2093 | |
| 2094 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2095 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2096 | obj = meter_stats() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2097 | obj.meter_id = reader.read("!L")[0] |
| 2098 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2099 | orig_reader = reader |
| 2100 | reader = orig_reader.slice(_len - (4 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2101 | reader.skip(6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2102 | obj.flow_count = reader.read("!L")[0] |
| 2103 | obj.packet_in_count = reader.read("!Q")[0] |
| 2104 | obj.byte_in_count = reader.read("!Q")[0] |
| 2105 | obj.duration_sec = reader.read("!L")[0] |
| 2106 | obj.duration_nsec = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2107 | obj.band_stats = loxi.generic_util.unpack_list(reader, common.meter_band_stats.unpack) |
| 2108 | return obj |
| 2109 | |
| 2110 | def __eq__(self, other): |
| 2111 | if type(self) != type(other): return False |
| 2112 | if self.meter_id != other.meter_id: return False |
| 2113 | if self.flow_count != other.flow_count: return False |
| 2114 | if self.packet_in_count != other.packet_in_count: return False |
| 2115 | if self.byte_in_count != other.byte_in_count: return False |
| 2116 | if self.duration_sec != other.duration_sec: return False |
| 2117 | if self.duration_nsec != other.duration_nsec: return False |
| 2118 | if self.band_stats != other.band_stats: return False |
| 2119 | return True |
| 2120 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2121 | def pretty_print(self, q): |
| 2122 | q.text("meter_stats {") |
| 2123 | with q.group(): |
| 2124 | with q.indent(2): |
| 2125 | q.breakable() |
| 2126 | q.text("meter_id = "); |
| 2127 | q.text("%#x" % self.meter_id) |
| 2128 | q.text(","); q.breakable() |
| 2129 | q.text("flow_count = "); |
| 2130 | q.text("%#x" % self.flow_count) |
| 2131 | q.text(","); q.breakable() |
| 2132 | q.text("packet_in_count = "); |
| 2133 | q.text("%#x" % self.packet_in_count) |
| 2134 | q.text(","); q.breakable() |
| 2135 | q.text("byte_in_count = "); |
| 2136 | q.text("%#x" % self.byte_in_count) |
| 2137 | q.text(","); q.breakable() |
| 2138 | q.text("duration_sec = "); |
| 2139 | q.text("%#x" % self.duration_sec) |
| 2140 | q.text(","); q.breakable() |
| 2141 | q.text("duration_nsec = "); |
| 2142 | q.text("%#x" % self.duration_nsec) |
| 2143 | q.text(","); q.breakable() |
| 2144 | q.text("band_stats = "); |
| 2145 | q.pp(self.band_stats) |
| 2146 | q.breakable() |
| 2147 | q.text('}') |
| 2148 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2149 | |
| 2150 | class packet_queue(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2151 | |
| 2152 | def __init__(self, queue_id=None, port=None, properties=None): |
| 2153 | if queue_id != None: |
| 2154 | self.queue_id = queue_id |
| 2155 | else: |
| 2156 | self.queue_id = 0 |
| 2157 | if port != None: |
| 2158 | self.port = port |
| 2159 | else: |
| 2160 | self.port = 0 |
| 2161 | if properties != None: |
| 2162 | self.properties = properties |
| 2163 | else: |
| 2164 | self.properties = [] |
| 2165 | return |
| 2166 | |
| 2167 | def pack(self): |
| 2168 | packed = [] |
| 2169 | packed.append(struct.pack("!L", self.queue_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2170 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2171 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 2 |
| 2172 | packed.append('\x00' * 6) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2173 | packed.append(loxi.generic_util.pack_list(self.properties)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2174 | length = sum([len(x) for x in packed]) |
| 2175 | packed[2] = struct.pack("!H", length) |
| 2176 | return ''.join(packed) |
| 2177 | |
| 2178 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2179 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2180 | obj = packet_queue() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2181 | obj.queue_id = reader.read("!L")[0] |
| 2182 | obj.port = util.unpack_port_no(reader) |
| 2183 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2184 | orig_reader = reader |
| 2185 | reader = orig_reader.slice(_len - (8 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2186 | reader.skip(6) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2187 | obj.properties = loxi.generic_util.unpack_list(reader, common.queue_prop.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2188 | return obj |
| 2189 | |
| 2190 | def __eq__(self, other): |
| 2191 | if type(self) != type(other): return False |
| 2192 | if self.queue_id != other.queue_id: return False |
| 2193 | if self.port != other.port: return False |
| 2194 | if self.properties != other.properties: return False |
| 2195 | return True |
| 2196 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2197 | def pretty_print(self, q): |
| 2198 | q.text("packet_queue {") |
| 2199 | with q.group(): |
| 2200 | with q.indent(2): |
| 2201 | q.breakable() |
| 2202 | q.text("queue_id = "); |
| 2203 | q.text("%#x" % self.queue_id) |
| 2204 | q.text(","); q.breakable() |
| 2205 | q.text("port = "); |
| 2206 | q.text(util.pretty_port(self.port)) |
| 2207 | q.text(","); q.breakable() |
| 2208 | q.text("properties = "); |
| 2209 | q.pp(self.properties) |
| 2210 | q.breakable() |
| 2211 | q.text('}') |
| 2212 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2213 | |
| 2214 | class port_desc(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2215 | |
| 2216 | 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): |
| 2217 | if port_no != None: |
| 2218 | self.port_no = port_no |
| 2219 | else: |
| 2220 | self.port_no = 0 |
| 2221 | if hw_addr != None: |
| 2222 | self.hw_addr = hw_addr |
| 2223 | else: |
| 2224 | self.hw_addr = [0,0,0,0,0,0] |
| 2225 | if name != None: |
| 2226 | self.name = name |
| 2227 | else: |
| 2228 | self.name = "" |
| 2229 | if config != None: |
| 2230 | self.config = config |
| 2231 | else: |
| 2232 | self.config = 0 |
| 2233 | if state != None: |
| 2234 | self.state = state |
| 2235 | else: |
| 2236 | self.state = 0 |
| 2237 | if curr != None: |
| 2238 | self.curr = curr |
| 2239 | else: |
| 2240 | self.curr = 0 |
| 2241 | if advertised != None: |
| 2242 | self.advertised = advertised |
| 2243 | else: |
| 2244 | self.advertised = 0 |
| 2245 | if supported != None: |
| 2246 | self.supported = supported |
| 2247 | else: |
| 2248 | self.supported = 0 |
| 2249 | if peer != None: |
| 2250 | self.peer = peer |
| 2251 | else: |
| 2252 | self.peer = 0 |
| 2253 | if curr_speed != None: |
| 2254 | self.curr_speed = curr_speed |
| 2255 | else: |
| 2256 | self.curr_speed = 0 |
| 2257 | if max_speed != None: |
| 2258 | self.max_speed = max_speed |
| 2259 | else: |
| 2260 | self.max_speed = 0 |
| 2261 | return |
| 2262 | |
| 2263 | def pack(self): |
| 2264 | packed = [] |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2265 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2266 | packed.append('\x00' * 4) |
| 2267 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 2268 | packed.append('\x00' * 2) |
| 2269 | packed.append(struct.pack("!16s", self.name)) |
| 2270 | packed.append(struct.pack("!L", self.config)) |
| 2271 | packed.append(struct.pack("!L", self.state)) |
| 2272 | packed.append(struct.pack("!L", self.curr)) |
| 2273 | packed.append(struct.pack("!L", self.advertised)) |
| 2274 | packed.append(struct.pack("!L", self.supported)) |
| 2275 | packed.append(struct.pack("!L", self.peer)) |
| 2276 | packed.append(struct.pack("!L", self.curr_speed)) |
| 2277 | packed.append(struct.pack("!L", self.max_speed)) |
| 2278 | return ''.join(packed) |
| 2279 | |
| 2280 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2281 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2282 | obj = port_desc() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2283 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2284 | reader.skip(4) |
| 2285 | obj.hw_addr = list(reader.read('!6B')) |
| 2286 | reader.skip(2) |
| 2287 | obj.name = reader.read("!16s")[0].rstrip("\x00") |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2288 | obj.config = reader.read("!L")[0] |
| 2289 | obj.state = reader.read("!L")[0] |
| 2290 | obj.curr = reader.read("!L")[0] |
| 2291 | obj.advertised = reader.read("!L")[0] |
| 2292 | obj.supported = reader.read("!L")[0] |
| 2293 | obj.peer = reader.read("!L")[0] |
| 2294 | obj.curr_speed = reader.read("!L")[0] |
| 2295 | obj.max_speed = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2296 | return obj |
| 2297 | |
| 2298 | def __eq__(self, other): |
| 2299 | if type(self) != type(other): return False |
| 2300 | if self.port_no != other.port_no: return False |
| 2301 | if self.hw_addr != other.hw_addr: return False |
| 2302 | if self.name != other.name: return False |
| 2303 | if self.config != other.config: return False |
| 2304 | if self.state != other.state: return False |
| 2305 | if self.curr != other.curr: return False |
| 2306 | if self.advertised != other.advertised: return False |
| 2307 | if self.supported != other.supported: return False |
| 2308 | if self.peer != other.peer: return False |
| 2309 | if self.curr_speed != other.curr_speed: return False |
| 2310 | if self.max_speed != other.max_speed: return False |
| 2311 | return True |
| 2312 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2313 | def pretty_print(self, q): |
| 2314 | q.text("port_desc {") |
| 2315 | with q.group(): |
| 2316 | with q.indent(2): |
| 2317 | q.breakable() |
| 2318 | q.text("port_no = "); |
| 2319 | q.text(util.pretty_port(self.port_no)) |
| 2320 | q.text(","); q.breakable() |
| 2321 | q.text("hw_addr = "); |
| 2322 | q.text(util.pretty_mac(self.hw_addr)) |
| 2323 | q.text(","); q.breakable() |
| 2324 | q.text("name = "); |
| 2325 | q.pp(self.name) |
| 2326 | q.text(","); q.breakable() |
| 2327 | q.text("config = "); |
| 2328 | q.text("%#x" % self.config) |
| 2329 | q.text(","); q.breakable() |
| 2330 | q.text("state = "); |
| 2331 | q.text("%#x" % self.state) |
| 2332 | q.text(","); q.breakable() |
| 2333 | q.text("curr = "); |
| 2334 | q.text("%#x" % self.curr) |
| 2335 | q.text(","); q.breakable() |
| 2336 | q.text("advertised = "); |
| 2337 | q.text("%#x" % self.advertised) |
| 2338 | q.text(","); q.breakable() |
| 2339 | q.text("supported = "); |
| 2340 | q.text("%#x" % self.supported) |
| 2341 | q.text(","); q.breakable() |
| 2342 | q.text("peer = "); |
| 2343 | q.text("%#x" % self.peer) |
| 2344 | q.text(","); q.breakable() |
| 2345 | q.text("curr_speed = "); |
| 2346 | q.text("%#x" % self.curr_speed) |
| 2347 | q.text(","); q.breakable() |
| 2348 | q.text("max_speed = "); |
| 2349 | q.text("%#x" % self.max_speed) |
| 2350 | q.breakable() |
| 2351 | q.text('}') |
| 2352 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2353 | |
| 2354 | class port_stats_entry(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2355 | |
| 2356 | 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): |
| 2357 | if port_no != None: |
| 2358 | self.port_no = port_no |
| 2359 | else: |
| 2360 | self.port_no = 0 |
| 2361 | if rx_packets != None: |
| 2362 | self.rx_packets = rx_packets |
| 2363 | else: |
| 2364 | self.rx_packets = 0 |
| 2365 | if tx_packets != None: |
| 2366 | self.tx_packets = tx_packets |
| 2367 | else: |
| 2368 | self.tx_packets = 0 |
| 2369 | if rx_bytes != None: |
| 2370 | self.rx_bytes = rx_bytes |
| 2371 | else: |
| 2372 | self.rx_bytes = 0 |
| 2373 | if tx_bytes != None: |
| 2374 | self.tx_bytes = tx_bytes |
| 2375 | else: |
| 2376 | self.tx_bytes = 0 |
| 2377 | if rx_dropped != None: |
| 2378 | self.rx_dropped = rx_dropped |
| 2379 | else: |
| 2380 | self.rx_dropped = 0 |
| 2381 | if tx_dropped != None: |
| 2382 | self.tx_dropped = tx_dropped |
| 2383 | else: |
| 2384 | self.tx_dropped = 0 |
| 2385 | if rx_errors != None: |
| 2386 | self.rx_errors = rx_errors |
| 2387 | else: |
| 2388 | self.rx_errors = 0 |
| 2389 | if tx_errors != None: |
| 2390 | self.tx_errors = tx_errors |
| 2391 | else: |
| 2392 | self.tx_errors = 0 |
| 2393 | if rx_frame_err != None: |
| 2394 | self.rx_frame_err = rx_frame_err |
| 2395 | else: |
| 2396 | self.rx_frame_err = 0 |
| 2397 | if rx_over_err != None: |
| 2398 | self.rx_over_err = rx_over_err |
| 2399 | else: |
| 2400 | self.rx_over_err = 0 |
| 2401 | if rx_crc_err != None: |
| 2402 | self.rx_crc_err = rx_crc_err |
| 2403 | else: |
| 2404 | self.rx_crc_err = 0 |
| 2405 | if collisions != None: |
| 2406 | self.collisions = collisions |
| 2407 | else: |
| 2408 | self.collisions = 0 |
| 2409 | if duration_sec != None: |
| 2410 | self.duration_sec = duration_sec |
| 2411 | else: |
| 2412 | self.duration_sec = 0 |
| 2413 | if duration_nsec != None: |
| 2414 | self.duration_nsec = duration_nsec |
| 2415 | else: |
| 2416 | self.duration_nsec = 0 |
| 2417 | return |
| 2418 | |
| 2419 | def pack(self): |
| 2420 | packed = [] |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2421 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2422 | packed.append('\x00' * 4) |
| 2423 | packed.append(struct.pack("!Q", self.rx_packets)) |
| 2424 | packed.append(struct.pack("!Q", self.tx_packets)) |
| 2425 | packed.append(struct.pack("!Q", self.rx_bytes)) |
| 2426 | packed.append(struct.pack("!Q", self.tx_bytes)) |
| 2427 | packed.append(struct.pack("!Q", self.rx_dropped)) |
| 2428 | packed.append(struct.pack("!Q", self.tx_dropped)) |
| 2429 | packed.append(struct.pack("!Q", self.rx_errors)) |
| 2430 | packed.append(struct.pack("!Q", self.tx_errors)) |
| 2431 | packed.append(struct.pack("!Q", self.rx_frame_err)) |
| 2432 | packed.append(struct.pack("!Q", self.rx_over_err)) |
| 2433 | packed.append(struct.pack("!Q", self.rx_crc_err)) |
| 2434 | packed.append(struct.pack("!Q", self.collisions)) |
| 2435 | packed.append(struct.pack("!L", self.duration_sec)) |
| 2436 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 2437 | return ''.join(packed) |
| 2438 | |
| 2439 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2440 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2441 | obj = port_stats_entry() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2442 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2443 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2444 | obj.rx_packets = reader.read("!Q")[0] |
| 2445 | obj.tx_packets = reader.read("!Q")[0] |
| 2446 | obj.rx_bytes = reader.read("!Q")[0] |
| 2447 | obj.tx_bytes = reader.read("!Q")[0] |
| 2448 | obj.rx_dropped = reader.read("!Q")[0] |
| 2449 | obj.tx_dropped = reader.read("!Q")[0] |
| 2450 | obj.rx_errors = reader.read("!Q")[0] |
| 2451 | obj.tx_errors = reader.read("!Q")[0] |
| 2452 | obj.rx_frame_err = reader.read("!Q")[0] |
| 2453 | obj.rx_over_err = reader.read("!Q")[0] |
| 2454 | obj.rx_crc_err = reader.read("!Q")[0] |
| 2455 | obj.collisions = reader.read("!Q")[0] |
| 2456 | obj.duration_sec = reader.read("!L")[0] |
| 2457 | obj.duration_nsec = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2458 | return obj |
| 2459 | |
| 2460 | def __eq__(self, other): |
| 2461 | if type(self) != type(other): return False |
| 2462 | if self.port_no != other.port_no: return False |
| 2463 | if self.rx_packets != other.rx_packets: return False |
| 2464 | if self.tx_packets != other.tx_packets: return False |
| 2465 | if self.rx_bytes != other.rx_bytes: return False |
| 2466 | if self.tx_bytes != other.tx_bytes: return False |
| 2467 | if self.rx_dropped != other.rx_dropped: return False |
| 2468 | if self.tx_dropped != other.tx_dropped: return False |
| 2469 | if self.rx_errors != other.rx_errors: return False |
| 2470 | if self.tx_errors != other.tx_errors: return False |
| 2471 | if self.rx_frame_err != other.rx_frame_err: return False |
| 2472 | if self.rx_over_err != other.rx_over_err: return False |
| 2473 | if self.rx_crc_err != other.rx_crc_err: return False |
| 2474 | if self.collisions != other.collisions: return False |
| 2475 | if self.duration_sec != other.duration_sec: return False |
| 2476 | if self.duration_nsec != other.duration_nsec: return False |
| 2477 | return True |
| 2478 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2479 | def pretty_print(self, q): |
| 2480 | q.text("port_stats_entry {") |
| 2481 | with q.group(): |
| 2482 | with q.indent(2): |
| 2483 | q.breakable() |
| 2484 | q.text("port_no = "); |
| 2485 | q.text(util.pretty_port(self.port_no)) |
| 2486 | q.text(","); q.breakable() |
| 2487 | q.text("rx_packets = "); |
| 2488 | q.text("%#x" % self.rx_packets) |
| 2489 | q.text(","); q.breakable() |
| 2490 | q.text("tx_packets = "); |
| 2491 | q.text("%#x" % self.tx_packets) |
| 2492 | q.text(","); q.breakable() |
| 2493 | q.text("rx_bytes = "); |
| 2494 | q.text("%#x" % self.rx_bytes) |
| 2495 | q.text(","); q.breakable() |
| 2496 | q.text("tx_bytes = "); |
| 2497 | q.text("%#x" % self.tx_bytes) |
| 2498 | q.text(","); q.breakable() |
| 2499 | q.text("rx_dropped = "); |
| 2500 | q.text("%#x" % self.rx_dropped) |
| 2501 | q.text(","); q.breakable() |
| 2502 | q.text("tx_dropped = "); |
| 2503 | q.text("%#x" % self.tx_dropped) |
| 2504 | q.text(","); q.breakable() |
| 2505 | q.text("rx_errors = "); |
| 2506 | q.text("%#x" % self.rx_errors) |
| 2507 | q.text(","); q.breakable() |
| 2508 | q.text("tx_errors = "); |
| 2509 | q.text("%#x" % self.tx_errors) |
| 2510 | q.text(","); q.breakable() |
| 2511 | q.text("rx_frame_err = "); |
| 2512 | q.text("%#x" % self.rx_frame_err) |
| 2513 | q.text(","); q.breakable() |
| 2514 | q.text("rx_over_err = "); |
| 2515 | q.text("%#x" % self.rx_over_err) |
| 2516 | q.text(","); q.breakable() |
| 2517 | q.text("rx_crc_err = "); |
| 2518 | q.text("%#x" % self.rx_crc_err) |
| 2519 | q.text(","); q.breakable() |
| 2520 | q.text("collisions = "); |
| 2521 | q.text("%#x" % self.collisions) |
| 2522 | q.text(","); q.breakable() |
| 2523 | q.text("duration_sec = "); |
| 2524 | q.text("%#x" % self.duration_sec) |
| 2525 | q.text(","); q.breakable() |
| 2526 | q.text("duration_nsec = "); |
| 2527 | q.text("%#x" % self.duration_nsec) |
| 2528 | q.breakable() |
| 2529 | q.text('}') |
| 2530 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2531 | |
| 2532 | class queue_prop(loxi.OFObject): |
| 2533 | subtypes = {} |
| 2534 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2535 | |
| 2536 | def __init__(self, type=None): |
| 2537 | if type != None: |
| 2538 | self.type = type |
| 2539 | else: |
| 2540 | self.type = 0 |
| 2541 | return |
| 2542 | |
| 2543 | def pack(self): |
| 2544 | packed = [] |
| 2545 | packed.append(struct.pack("!H", self.type)) |
| 2546 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 2547 | packed.append('\x00' * 4) |
| 2548 | length = sum([len(x) for x in packed]) |
| 2549 | packed[1] = struct.pack("!H", length) |
| 2550 | return ''.join(packed) |
| 2551 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2552 | @staticmethod |
| 2553 | def unpack(reader): |
| 2554 | subtype, = reader.peek('!H', 0) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2555 | subclass = queue_prop.subtypes.get(subtype) |
| 2556 | if subclass: |
| 2557 | return subclass.unpack(reader) |
| 2558 | |
| 2559 | obj = queue_prop() |
| 2560 | obj.type = reader.read("!H")[0] |
| 2561 | _len = reader.read("!H")[0] |
| 2562 | orig_reader = reader |
| 2563 | reader = orig_reader.slice(_len - (2 + 2)) |
| 2564 | reader.skip(4) |
| 2565 | return obj |
| 2566 | |
| 2567 | def __eq__(self, other): |
| 2568 | if type(self) != type(other): return False |
| 2569 | if self.type != other.type: return False |
| 2570 | return True |
| 2571 | |
| 2572 | def pretty_print(self, q): |
| 2573 | q.text("queue_prop {") |
| 2574 | with q.group(): |
| 2575 | with q.indent(2): |
| 2576 | q.breakable() |
| 2577 | q.breakable() |
| 2578 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2579 | |
| 2580 | |
| 2581 | class queue_prop_experimenter(queue_prop): |
| 2582 | subtypes = {} |
| 2583 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2584 | type = 65535 |
| 2585 | |
| 2586 | def __init__(self, experimenter=None, data=None): |
| 2587 | if experimenter != None: |
| 2588 | self.experimenter = experimenter |
| 2589 | else: |
| 2590 | self.experimenter = 0 |
| 2591 | if data != None: |
| 2592 | self.data = data |
| 2593 | else: |
| 2594 | self.data = '' |
| 2595 | return |
| 2596 | |
| 2597 | def pack(self): |
| 2598 | packed = [] |
| 2599 | packed.append(struct.pack("!H", self.type)) |
| 2600 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 2601 | packed.append('\x00' * 4) |
| 2602 | packed.append(struct.pack("!L", self.experimenter)) |
| 2603 | packed.append('\x00' * 4) |
| 2604 | packed.append(self.data) |
| 2605 | length = sum([len(x) for x in packed]) |
| 2606 | packed[1] = struct.pack("!H", length) |
| 2607 | return ''.join(packed) |
| 2608 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2609 | @staticmethod |
| 2610 | def unpack(reader): |
| 2611 | subtype, = reader.peek('!L', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2612 | subclass = queue_prop_experimenter.subtypes.get(subtype) |
| 2613 | if subclass: |
| 2614 | return subclass.unpack(reader) |
| 2615 | |
| 2616 | obj = queue_prop_experimenter() |
| 2617 | _type = reader.read("!H")[0] |
| 2618 | assert(_type == 65535) |
| 2619 | _len = reader.read("!H")[0] |
| 2620 | orig_reader = reader |
| 2621 | reader = orig_reader.slice(_len - (2 + 2)) |
| 2622 | reader.skip(4) |
| 2623 | obj.experimenter = reader.read("!L")[0] |
| 2624 | reader.skip(4) |
| 2625 | obj.data = str(reader.read_all()) |
| 2626 | return obj |
| 2627 | |
| 2628 | def __eq__(self, other): |
| 2629 | if type(self) != type(other): return False |
| 2630 | if self.experimenter != other.experimenter: return False |
| 2631 | if self.data != other.data: return False |
| 2632 | return True |
| 2633 | |
| 2634 | def pretty_print(self, q): |
| 2635 | q.text("queue_prop_experimenter {") |
| 2636 | with q.group(): |
| 2637 | with q.indent(2): |
| 2638 | q.breakable() |
| 2639 | q.text("data = "); |
| 2640 | q.pp(self.data) |
| 2641 | q.breakable() |
| 2642 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2643 | |
| 2644 | queue_prop.subtypes[65535] = queue_prop_experimenter |
| 2645 | |
| 2646 | class queue_prop_max_rate(queue_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2647 | type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2648 | |
| 2649 | def __init__(self, rate=None): |
| 2650 | if rate != None: |
| 2651 | self.rate = rate |
| 2652 | else: |
| 2653 | self.rate = 0 |
| 2654 | return |
| 2655 | |
| 2656 | def pack(self): |
| 2657 | packed = [] |
| 2658 | packed.append(struct.pack("!H", self.type)) |
| 2659 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 2660 | packed.append('\x00' * 4) |
| 2661 | packed.append(struct.pack("!H", self.rate)) |
| 2662 | packed.append('\x00' * 6) |
| 2663 | length = sum([len(x) for x in packed]) |
| 2664 | packed[1] = struct.pack("!H", length) |
| 2665 | return ''.join(packed) |
| 2666 | |
| 2667 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2668 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2669 | obj = queue_prop_max_rate() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2670 | _type = reader.read("!H")[0] |
| 2671 | assert(_type == 2) |
| 2672 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2673 | orig_reader = reader |
| 2674 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2675 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2676 | obj.rate = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2677 | reader.skip(6) |
| 2678 | return obj |
| 2679 | |
| 2680 | def __eq__(self, other): |
| 2681 | if type(self) != type(other): return False |
| 2682 | if self.rate != other.rate: return False |
| 2683 | return True |
| 2684 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2685 | def pretty_print(self, q): |
| 2686 | q.text("queue_prop_max_rate {") |
| 2687 | with q.group(): |
| 2688 | with q.indent(2): |
| 2689 | q.breakable() |
| 2690 | q.text("rate = "); |
| 2691 | q.text("%#x" % self.rate) |
| 2692 | q.breakable() |
| 2693 | q.text('}') |
| 2694 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2695 | queue_prop.subtypes[2] = queue_prop_max_rate |
| 2696 | |
| 2697 | class queue_prop_min_rate(queue_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2698 | type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2699 | |
| 2700 | def __init__(self, rate=None): |
| 2701 | if rate != None: |
| 2702 | self.rate = rate |
| 2703 | else: |
| 2704 | self.rate = 0 |
| 2705 | return |
| 2706 | |
| 2707 | def pack(self): |
| 2708 | packed = [] |
| 2709 | packed.append(struct.pack("!H", self.type)) |
| 2710 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 2711 | packed.append('\x00' * 4) |
| 2712 | packed.append(struct.pack("!H", self.rate)) |
| 2713 | packed.append('\x00' * 6) |
| 2714 | length = sum([len(x) for x in packed]) |
| 2715 | packed[1] = struct.pack("!H", length) |
| 2716 | return ''.join(packed) |
| 2717 | |
| 2718 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2719 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2720 | obj = queue_prop_min_rate() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2721 | _type = reader.read("!H")[0] |
| 2722 | assert(_type == 1) |
| 2723 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2724 | orig_reader = reader |
| 2725 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2726 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2727 | obj.rate = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2728 | reader.skip(6) |
| 2729 | return obj |
| 2730 | |
| 2731 | def __eq__(self, other): |
| 2732 | if type(self) != type(other): return False |
| 2733 | if self.rate != other.rate: return False |
| 2734 | return True |
| 2735 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2736 | def pretty_print(self, q): |
| 2737 | q.text("queue_prop_min_rate {") |
| 2738 | with q.group(): |
| 2739 | with q.indent(2): |
| 2740 | q.breakable() |
| 2741 | q.text("rate = "); |
| 2742 | q.text("%#x" % self.rate) |
| 2743 | q.breakable() |
| 2744 | q.text('}') |
| 2745 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2746 | queue_prop.subtypes[1] = queue_prop_min_rate |
| 2747 | |
| 2748 | class queue_stats_entry(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2749 | |
| 2750 | def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None, duration_sec=None, duration_nsec=None): |
| 2751 | if port_no != None: |
| 2752 | self.port_no = port_no |
| 2753 | else: |
| 2754 | self.port_no = 0 |
| 2755 | if queue_id != None: |
| 2756 | self.queue_id = queue_id |
| 2757 | else: |
| 2758 | self.queue_id = 0 |
| 2759 | if tx_bytes != None: |
| 2760 | self.tx_bytes = tx_bytes |
| 2761 | else: |
| 2762 | self.tx_bytes = 0 |
| 2763 | if tx_packets != None: |
| 2764 | self.tx_packets = tx_packets |
| 2765 | else: |
| 2766 | self.tx_packets = 0 |
| 2767 | if tx_errors != None: |
| 2768 | self.tx_errors = tx_errors |
| 2769 | else: |
| 2770 | self.tx_errors = 0 |
| 2771 | if duration_sec != None: |
| 2772 | self.duration_sec = duration_sec |
| 2773 | else: |
| 2774 | self.duration_sec = 0 |
| 2775 | if duration_nsec != None: |
| 2776 | self.duration_nsec = duration_nsec |
| 2777 | else: |
| 2778 | self.duration_nsec = 0 |
| 2779 | return |
| 2780 | |
| 2781 | def pack(self): |
| 2782 | packed = [] |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2783 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2784 | packed.append(struct.pack("!L", self.queue_id)) |
| 2785 | packed.append(struct.pack("!Q", self.tx_bytes)) |
| 2786 | packed.append(struct.pack("!Q", self.tx_packets)) |
| 2787 | packed.append(struct.pack("!Q", self.tx_errors)) |
| 2788 | packed.append(struct.pack("!L", self.duration_sec)) |
| 2789 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 2790 | return ''.join(packed) |
| 2791 | |
| 2792 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2793 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2794 | obj = queue_stats_entry() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2795 | obj.port_no = util.unpack_port_no(reader) |
| 2796 | obj.queue_id = reader.read("!L")[0] |
| 2797 | obj.tx_bytes = reader.read("!Q")[0] |
| 2798 | obj.tx_packets = reader.read("!Q")[0] |
| 2799 | obj.tx_errors = reader.read("!Q")[0] |
| 2800 | obj.duration_sec = reader.read("!L")[0] |
| 2801 | obj.duration_nsec = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2802 | return obj |
| 2803 | |
| 2804 | def __eq__(self, other): |
| 2805 | if type(self) != type(other): return False |
| 2806 | if self.port_no != other.port_no: return False |
| 2807 | if self.queue_id != other.queue_id: return False |
| 2808 | if self.tx_bytes != other.tx_bytes: return False |
| 2809 | if self.tx_packets != other.tx_packets: return False |
| 2810 | if self.tx_errors != other.tx_errors: return False |
| 2811 | if self.duration_sec != other.duration_sec: return False |
| 2812 | if self.duration_nsec != other.duration_nsec: return False |
| 2813 | return True |
| 2814 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2815 | def pretty_print(self, q): |
| 2816 | q.text("queue_stats_entry {") |
| 2817 | with q.group(): |
| 2818 | with q.indent(2): |
| 2819 | q.breakable() |
| 2820 | q.text("port_no = "); |
| 2821 | q.text(util.pretty_port(self.port_no)) |
| 2822 | q.text(","); q.breakable() |
| 2823 | q.text("queue_id = "); |
| 2824 | q.text("%#x" % self.queue_id) |
| 2825 | q.text(","); q.breakable() |
| 2826 | q.text("tx_bytes = "); |
| 2827 | q.text("%#x" % self.tx_bytes) |
| 2828 | q.text(","); q.breakable() |
| 2829 | q.text("tx_packets = "); |
| 2830 | q.text("%#x" % self.tx_packets) |
| 2831 | q.text(","); q.breakable() |
| 2832 | q.text("tx_errors = "); |
| 2833 | q.text("%#x" % self.tx_errors) |
| 2834 | q.text(","); q.breakable() |
| 2835 | q.text("duration_sec = "); |
| 2836 | q.text("%#x" % self.duration_sec) |
| 2837 | q.text(","); q.breakable() |
| 2838 | q.text("duration_nsec = "); |
| 2839 | q.text("%#x" % self.duration_nsec) |
| 2840 | q.breakable() |
| 2841 | q.text('}') |
| 2842 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2843 | |
| 2844 | class table_feature_prop(loxi.OFObject): |
| 2845 | subtypes = {} |
| 2846 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2847 | |
| 2848 | def __init__(self, type=None): |
| 2849 | if type != None: |
| 2850 | self.type = type |
| 2851 | else: |
| 2852 | self.type = 0 |
| 2853 | return |
| 2854 | |
| 2855 | def pack(self): |
| 2856 | packed = [] |
| 2857 | packed.append(struct.pack("!H", self.type)) |
| 2858 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 2859 | length = sum([len(x) for x in packed]) |
| 2860 | packed[1] = struct.pack("!H", length) |
| 2861 | return ''.join(packed) |
| 2862 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2863 | @staticmethod |
| 2864 | def unpack(reader): |
| 2865 | subtype, = reader.peek('!H', 0) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2866 | subclass = table_feature_prop.subtypes.get(subtype) |
| 2867 | if subclass: |
| 2868 | return subclass.unpack(reader) |
| 2869 | |
| 2870 | obj = table_feature_prop() |
| 2871 | obj.type = reader.read("!H")[0] |
| 2872 | _length = reader.read("!H")[0] |
| 2873 | orig_reader = reader |
| 2874 | reader = orig_reader.slice(_length - (2 + 2)) |
| 2875 | return obj |
| 2876 | |
| 2877 | def __eq__(self, other): |
| 2878 | if type(self) != type(other): return False |
| 2879 | if self.type != other.type: return False |
| 2880 | return True |
| 2881 | |
| 2882 | def pretty_print(self, q): |
| 2883 | q.text("table_feature_prop {") |
| 2884 | with q.group(): |
| 2885 | with q.indent(2): |
| 2886 | q.breakable() |
| 2887 | q.breakable() |
| 2888 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2889 | |
| 2890 | |
| 2891 | class table_feature_prop_apply_actions(table_feature_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2892 | type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2893 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2894 | def __init__(self, action_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2895 | if action_ids != None: |
| 2896 | self.action_ids = action_ids |
| 2897 | else: |
| 2898 | self.action_ids = [] |
| 2899 | return |
| 2900 | |
| 2901 | def pack(self): |
| 2902 | packed = [] |
| 2903 | packed.append(struct.pack("!H", self.type)) |
| 2904 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2905 | packed.append(loxi.generic_util.pack_list(self.action_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2906 | length = sum([len(x) for x in packed]) |
| 2907 | packed[1] = struct.pack("!H", length) |
| 2908 | return ''.join(packed) |
| 2909 | |
| 2910 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2911 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2912 | obj = table_feature_prop_apply_actions() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2913 | _type = reader.read("!H")[0] |
| 2914 | assert(_type == 6) |
| 2915 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2916 | orig_reader = reader |
| 2917 | reader = orig_reader.slice(_length - (2 + 2)) |
| 2918 | 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] | 2919 | return obj |
| 2920 | |
| 2921 | def __eq__(self, other): |
| 2922 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2923 | if self.action_ids != other.action_ids: return False |
| 2924 | return True |
| 2925 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2926 | def pretty_print(self, q): |
| 2927 | q.text("table_feature_prop_apply_actions {") |
| 2928 | with q.group(): |
| 2929 | with q.indent(2): |
| 2930 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2931 | q.text("action_ids = "); |
| 2932 | q.pp(self.action_ids) |
| 2933 | q.breakable() |
| 2934 | q.text('}') |
| 2935 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2936 | table_feature_prop.subtypes[6] = table_feature_prop_apply_actions |
| 2937 | |
| 2938 | class table_feature_prop_apply_actions_miss(table_feature_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2939 | type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2940 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2941 | def __init__(self, action_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2942 | if action_ids != None: |
| 2943 | self.action_ids = action_ids |
| 2944 | else: |
| 2945 | self.action_ids = [] |
| 2946 | return |
| 2947 | |
| 2948 | def pack(self): |
| 2949 | packed = [] |
| 2950 | packed.append(struct.pack("!H", self.type)) |
| 2951 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2952 | packed.append(loxi.generic_util.pack_list(self.action_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2953 | length = sum([len(x) for x in packed]) |
| 2954 | packed[1] = struct.pack("!H", length) |
| 2955 | return ''.join(packed) |
| 2956 | |
| 2957 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2958 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2959 | obj = table_feature_prop_apply_actions_miss() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2960 | _type = reader.read("!H")[0] |
| 2961 | assert(_type == 7) |
| 2962 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2963 | orig_reader = reader |
| 2964 | reader = orig_reader.slice(_length - (2 + 2)) |
| 2965 | 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] | 2966 | return obj |
| 2967 | |
| 2968 | def __eq__(self, other): |
| 2969 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2970 | if self.action_ids != other.action_ids: return False |
| 2971 | return True |
| 2972 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2973 | def pretty_print(self, q): |
| 2974 | q.text("table_feature_prop_apply_actions_miss {") |
| 2975 | with q.group(): |
| 2976 | with q.indent(2): |
| 2977 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2978 | q.text("action_ids = "); |
| 2979 | q.pp(self.action_ids) |
| 2980 | q.breakable() |
| 2981 | q.text('}') |
| 2982 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2983 | table_feature_prop.subtypes[7] = table_feature_prop_apply_actions_miss |
| 2984 | |
| 2985 | class table_feature_prop_apply_setfield(table_feature_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2986 | type = 14 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2987 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2988 | def __init__(self, oxm_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2989 | if oxm_ids != None: |
| 2990 | self.oxm_ids = oxm_ids |
| 2991 | else: |
| 2992 | self.oxm_ids = [] |
| 2993 | return |
| 2994 | |
| 2995 | def pack(self): |
| 2996 | packed = [] |
| 2997 | packed.append(struct.pack("!H", self.type)) |
| 2998 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2999 | packed.append(loxi.generic_util.pack_list(self.oxm_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3000 | length = sum([len(x) for x in packed]) |
| 3001 | packed[1] = struct.pack("!H", length) |
| 3002 | return ''.join(packed) |
| 3003 | |
| 3004 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3005 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3006 | obj = table_feature_prop_apply_setfield() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3007 | _type = reader.read("!H")[0] |
| 3008 | assert(_type == 14) |
| 3009 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3010 | orig_reader = reader |
| 3011 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3012 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 3013 | return obj |
| 3014 | |
| 3015 | def __eq__(self, other): |
| 3016 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3017 | if self.oxm_ids != other.oxm_ids: return False |
| 3018 | return True |
| 3019 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3020 | def pretty_print(self, q): |
| 3021 | q.text("table_feature_prop_apply_setfield {") |
| 3022 | with q.group(): |
| 3023 | with q.indent(2): |
| 3024 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3025 | q.text("oxm_ids = "); |
| 3026 | q.pp(self.oxm_ids) |
| 3027 | q.breakable() |
| 3028 | q.text('}') |
| 3029 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3030 | table_feature_prop.subtypes[14] = table_feature_prop_apply_setfield |
| 3031 | |
| 3032 | class table_feature_prop_apply_setfield_miss(table_feature_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3033 | type = 15 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3034 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3035 | def __init__(self, oxm_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3036 | if oxm_ids != None: |
| 3037 | self.oxm_ids = oxm_ids |
| 3038 | else: |
| 3039 | self.oxm_ids = [] |
| 3040 | return |
| 3041 | |
| 3042 | def pack(self): |
| 3043 | packed = [] |
| 3044 | packed.append(struct.pack("!H", self.type)) |
| 3045 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3046 | packed.append(loxi.generic_util.pack_list(self.oxm_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3047 | length = sum([len(x) for x in packed]) |
| 3048 | packed[1] = struct.pack("!H", length) |
| 3049 | return ''.join(packed) |
| 3050 | |
| 3051 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3052 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3053 | obj = table_feature_prop_apply_setfield_miss() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3054 | _type = reader.read("!H")[0] |
| 3055 | assert(_type == 15) |
| 3056 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3057 | orig_reader = reader |
| 3058 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3059 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 3060 | return obj |
| 3061 | |
| 3062 | def __eq__(self, other): |
| 3063 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3064 | if self.oxm_ids != other.oxm_ids: return False |
| 3065 | return True |
| 3066 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3067 | def pretty_print(self, q): |
| 3068 | q.text("table_feature_prop_apply_setfield_miss {") |
| 3069 | with q.group(): |
| 3070 | with q.indent(2): |
| 3071 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3072 | q.text("oxm_ids = "); |
| 3073 | q.pp(self.oxm_ids) |
| 3074 | q.breakable() |
| 3075 | q.text('}') |
| 3076 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3077 | table_feature_prop.subtypes[15] = table_feature_prop_apply_setfield_miss |
| 3078 | |
| 3079 | class table_feature_prop_experimenter(table_feature_prop): |
Rich Lane | 9ec3fca | 2014-02-26 16:22:56 -0800 | [diff] [blame] | 3080 | type = 65534 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3081 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3082 | def __init__(self, experimenter=None, subtype=None, experimenter_data=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3083 | if experimenter != None: |
| 3084 | self.experimenter = experimenter |
| 3085 | else: |
| 3086 | self.experimenter = 0 |
| 3087 | if subtype != None: |
| 3088 | self.subtype = subtype |
| 3089 | else: |
| 3090 | self.subtype = 0 |
| 3091 | if experimenter_data != None: |
| 3092 | self.experimenter_data = experimenter_data |
| 3093 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3094 | self.experimenter_data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3095 | return |
| 3096 | |
| 3097 | def pack(self): |
| 3098 | packed = [] |
| 3099 | packed.append(struct.pack("!H", self.type)) |
| 3100 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3101 | packed.append(struct.pack("!L", self.experimenter)) |
| 3102 | packed.append(struct.pack("!L", self.subtype)) |
| 3103 | packed.append(self.experimenter_data) |
| 3104 | length = sum([len(x) for x in packed]) |
| 3105 | packed[1] = struct.pack("!H", length) |
| 3106 | return ''.join(packed) |
| 3107 | |
| 3108 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3109 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3110 | obj = table_feature_prop_experimenter() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3111 | _type = reader.read("!H")[0] |
Rich Lane | 9ec3fca | 2014-02-26 16:22:56 -0800 | [diff] [blame] | 3112 | assert(_type == 65534) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3113 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3114 | orig_reader = reader |
| 3115 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3116 | obj.experimenter = reader.read("!L")[0] |
| 3117 | obj.subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3118 | obj.experimenter_data = str(reader.read_all()) |
| 3119 | return obj |
| 3120 | |
| 3121 | def __eq__(self, other): |
| 3122 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3123 | if self.experimenter != other.experimenter: return False |
| 3124 | if self.subtype != other.subtype: return False |
| 3125 | if self.experimenter_data != other.experimenter_data: return False |
| 3126 | return True |
| 3127 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3128 | def pretty_print(self, q): |
| 3129 | q.text("table_feature_prop_experimenter {") |
| 3130 | with q.group(): |
| 3131 | with q.indent(2): |
| 3132 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3133 | q.text("experimenter = "); |
| 3134 | q.text("%#x" % self.experimenter) |
| 3135 | q.text(","); q.breakable() |
| 3136 | q.text("subtype = "); |
| 3137 | q.text("%#x" % self.subtype) |
| 3138 | q.text(","); q.breakable() |
| 3139 | q.text("experimenter_data = "); |
| 3140 | q.pp(self.experimenter_data) |
| 3141 | q.breakable() |
| 3142 | q.text('}') |
| 3143 | |
Rich Lane | 9ec3fca | 2014-02-26 16:22:56 -0800 | [diff] [blame] | 3144 | table_feature_prop.subtypes[65534] = table_feature_prop_experimenter |
| 3145 | |
| 3146 | class table_feature_prop_experimenter_miss(table_feature_prop): |
| 3147 | type = 65535 |
| 3148 | |
| 3149 | def __init__(self, experimenter=None, subtype=None, experimenter_data=None): |
| 3150 | if experimenter != None: |
| 3151 | self.experimenter = experimenter |
| 3152 | else: |
| 3153 | self.experimenter = 0 |
| 3154 | if subtype != None: |
| 3155 | self.subtype = subtype |
| 3156 | else: |
| 3157 | self.subtype = 0 |
| 3158 | if experimenter_data != None: |
| 3159 | self.experimenter_data = experimenter_data |
| 3160 | else: |
| 3161 | self.experimenter_data = '' |
| 3162 | return |
| 3163 | |
| 3164 | def pack(self): |
| 3165 | packed = [] |
| 3166 | packed.append(struct.pack("!H", self.type)) |
| 3167 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 3168 | packed.append(struct.pack("!L", self.experimenter)) |
| 3169 | packed.append(struct.pack("!L", self.subtype)) |
| 3170 | packed.append(self.experimenter_data) |
| 3171 | length = sum([len(x) for x in packed]) |
| 3172 | packed[1] = struct.pack("!H", length) |
| 3173 | return ''.join(packed) |
| 3174 | |
| 3175 | @staticmethod |
| 3176 | def unpack(reader): |
| 3177 | obj = table_feature_prop_experimenter_miss() |
| 3178 | _type = reader.read("!H")[0] |
| 3179 | assert(_type == 65535) |
| 3180 | _length = reader.read("!H")[0] |
| 3181 | orig_reader = reader |
| 3182 | reader = orig_reader.slice(_length - (2 + 2)) |
| 3183 | obj.experimenter = reader.read("!L")[0] |
| 3184 | obj.subtype = reader.read("!L")[0] |
| 3185 | obj.experimenter_data = str(reader.read_all()) |
| 3186 | return obj |
| 3187 | |
| 3188 | def __eq__(self, other): |
| 3189 | if type(self) != type(other): return False |
| 3190 | if self.experimenter != other.experimenter: return False |
| 3191 | if self.subtype != other.subtype: return False |
| 3192 | if self.experimenter_data != other.experimenter_data: return False |
| 3193 | return True |
| 3194 | |
| 3195 | def pretty_print(self, q): |
| 3196 | q.text("table_feature_prop_experimenter_miss {") |
| 3197 | with q.group(): |
| 3198 | with q.indent(2): |
| 3199 | q.breakable() |
| 3200 | q.text("experimenter = "); |
| 3201 | q.text("%#x" % self.experimenter) |
| 3202 | q.text(","); q.breakable() |
| 3203 | q.text("subtype = "); |
| 3204 | q.text("%#x" % self.subtype) |
| 3205 | q.text(","); q.breakable() |
| 3206 | q.text("experimenter_data = "); |
| 3207 | q.pp(self.experimenter_data) |
| 3208 | q.breakable() |
| 3209 | q.text('}') |
| 3210 | |
| 3211 | table_feature_prop.subtypes[65535] = table_feature_prop_experimenter_miss |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3212 | |
| 3213 | class table_feature_prop_instructions(table_feature_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3214 | type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3215 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3216 | def __init__(self, instruction_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3217 | if instruction_ids != None: |
| 3218 | self.instruction_ids = instruction_ids |
| 3219 | else: |
| 3220 | self.instruction_ids = [] |
| 3221 | return |
| 3222 | |
| 3223 | def pack(self): |
| 3224 | packed = [] |
| 3225 | packed.append(struct.pack("!H", self.type)) |
| 3226 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3227 | packed.append(loxi.generic_util.pack_list(self.instruction_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3228 | length = sum([len(x) for x in packed]) |
| 3229 | packed[1] = struct.pack("!H", length) |
| 3230 | return ''.join(packed) |
| 3231 | |
| 3232 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3233 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3234 | obj = table_feature_prop_instructions() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3235 | _type = reader.read("!H")[0] |
| 3236 | assert(_type == 0) |
| 3237 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3238 | orig_reader = reader |
| 3239 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | c0d05d1 | 2014-03-11 18:02:24 -0700 | [diff] [blame] | 3240 | 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] | 3241 | return obj |
| 3242 | |
| 3243 | def __eq__(self, other): |
| 3244 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3245 | if self.instruction_ids != other.instruction_ids: return False |
| 3246 | return True |
| 3247 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3248 | def pretty_print(self, q): |
| 3249 | q.text("table_feature_prop_instructions {") |
| 3250 | with q.group(): |
| 3251 | with q.indent(2): |
| 3252 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3253 | q.text("instruction_ids = "); |
| 3254 | q.pp(self.instruction_ids) |
| 3255 | q.breakable() |
| 3256 | q.text('}') |
| 3257 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3258 | table_feature_prop.subtypes[0] = table_feature_prop_instructions |
| 3259 | |
| 3260 | class table_feature_prop_instructions_miss(table_feature_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3261 | type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3262 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3263 | def __init__(self, instruction_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3264 | if instruction_ids != None: |
| 3265 | self.instruction_ids = instruction_ids |
| 3266 | else: |
| 3267 | self.instruction_ids = [] |
| 3268 | return |
| 3269 | |
| 3270 | def pack(self): |
| 3271 | packed = [] |
| 3272 | packed.append(struct.pack("!H", self.type)) |
| 3273 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3274 | packed.append(loxi.generic_util.pack_list(self.instruction_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3275 | length = sum([len(x) for x in packed]) |
| 3276 | packed[1] = struct.pack("!H", length) |
| 3277 | return ''.join(packed) |
| 3278 | |
| 3279 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3280 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3281 | obj = table_feature_prop_instructions_miss() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3282 | _type = reader.read("!H")[0] |
| 3283 | assert(_type == 1) |
| 3284 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3285 | orig_reader = reader |
| 3286 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | c0d05d1 | 2014-03-11 18:02:24 -0700 | [diff] [blame] | 3287 | 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] | 3288 | return obj |
| 3289 | |
| 3290 | def __eq__(self, other): |
| 3291 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3292 | if self.instruction_ids != other.instruction_ids: return False |
| 3293 | return True |
| 3294 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3295 | def pretty_print(self, q): |
| 3296 | q.text("table_feature_prop_instructions_miss {") |
| 3297 | with q.group(): |
| 3298 | with q.indent(2): |
| 3299 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3300 | q.text("instruction_ids = "); |
| 3301 | q.pp(self.instruction_ids) |
| 3302 | q.breakable() |
| 3303 | q.text('}') |
| 3304 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3305 | table_feature_prop.subtypes[1] = table_feature_prop_instructions_miss |
| 3306 | |
| 3307 | class table_feature_prop_match(table_feature_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3308 | type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3309 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3310 | def __init__(self, oxm_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3311 | if oxm_ids != None: |
| 3312 | self.oxm_ids = oxm_ids |
| 3313 | else: |
| 3314 | self.oxm_ids = [] |
| 3315 | return |
| 3316 | |
| 3317 | def pack(self): |
| 3318 | packed = [] |
| 3319 | packed.append(struct.pack("!H", self.type)) |
| 3320 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3321 | packed.append(loxi.generic_util.pack_list(self.oxm_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3322 | length = sum([len(x) for x in packed]) |
| 3323 | packed[1] = struct.pack("!H", length) |
| 3324 | return ''.join(packed) |
| 3325 | |
| 3326 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3327 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3328 | obj = table_feature_prop_match() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3329 | _type = reader.read("!H")[0] |
| 3330 | assert(_type == 8) |
| 3331 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3332 | orig_reader = reader |
| 3333 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3334 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 3335 | return obj |
| 3336 | |
| 3337 | def __eq__(self, other): |
| 3338 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3339 | if self.oxm_ids != other.oxm_ids: return False |
| 3340 | return True |
| 3341 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3342 | def pretty_print(self, q): |
| 3343 | q.text("table_feature_prop_match {") |
| 3344 | with q.group(): |
| 3345 | with q.indent(2): |
| 3346 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3347 | q.text("oxm_ids = "); |
| 3348 | q.pp(self.oxm_ids) |
| 3349 | q.breakable() |
| 3350 | q.text('}') |
| 3351 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3352 | table_feature_prop.subtypes[8] = table_feature_prop_match |
| 3353 | |
| 3354 | class table_feature_prop_next_tables(table_feature_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3355 | type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3356 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3357 | def __init__(self, next_table_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3358 | if next_table_ids != None: |
| 3359 | self.next_table_ids = next_table_ids |
| 3360 | else: |
| 3361 | self.next_table_ids = [] |
| 3362 | return |
| 3363 | |
| 3364 | def pack(self): |
| 3365 | packed = [] |
| 3366 | packed.append(struct.pack("!H", self.type)) |
| 3367 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3368 | packed.append(loxi.generic_util.pack_list(self.next_table_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3369 | length = sum([len(x) for x in packed]) |
| 3370 | packed[1] = struct.pack("!H", length) |
| 3371 | return ''.join(packed) |
| 3372 | |
| 3373 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3374 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3375 | obj = table_feature_prop_next_tables() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3376 | _type = reader.read("!H")[0] |
| 3377 | assert(_type == 2) |
| 3378 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3379 | orig_reader = reader |
| 3380 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3381 | obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack) |
| 3382 | return obj |
| 3383 | |
| 3384 | def __eq__(self, other): |
| 3385 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3386 | if self.next_table_ids != other.next_table_ids: return False |
| 3387 | return True |
| 3388 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3389 | def pretty_print(self, q): |
| 3390 | q.text("table_feature_prop_next_tables {") |
| 3391 | with q.group(): |
| 3392 | with q.indent(2): |
| 3393 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3394 | q.text("next_table_ids = "); |
| 3395 | q.pp(self.next_table_ids) |
| 3396 | q.breakable() |
| 3397 | q.text('}') |
| 3398 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3399 | table_feature_prop.subtypes[2] = table_feature_prop_next_tables |
| 3400 | |
| 3401 | class table_feature_prop_next_tables_miss(table_feature_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3402 | type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3403 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3404 | def __init__(self, next_table_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3405 | if next_table_ids != None: |
| 3406 | self.next_table_ids = next_table_ids |
| 3407 | else: |
| 3408 | self.next_table_ids = [] |
| 3409 | return |
| 3410 | |
| 3411 | def pack(self): |
| 3412 | packed = [] |
| 3413 | packed.append(struct.pack("!H", self.type)) |
| 3414 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3415 | packed.append(loxi.generic_util.pack_list(self.next_table_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3416 | length = sum([len(x) for x in packed]) |
| 3417 | packed[1] = struct.pack("!H", length) |
| 3418 | return ''.join(packed) |
| 3419 | |
| 3420 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3421 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3422 | obj = table_feature_prop_next_tables_miss() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3423 | _type = reader.read("!H")[0] |
| 3424 | assert(_type == 3) |
| 3425 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3426 | orig_reader = reader |
| 3427 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3428 | obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack) |
| 3429 | return obj |
| 3430 | |
| 3431 | def __eq__(self, other): |
| 3432 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3433 | if self.next_table_ids != other.next_table_ids: return False |
| 3434 | return True |
| 3435 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3436 | def pretty_print(self, q): |
| 3437 | q.text("table_feature_prop_next_tables_miss {") |
| 3438 | with q.group(): |
| 3439 | with q.indent(2): |
| 3440 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3441 | q.text("next_table_ids = "); |
| 3442 | q.pp(self.next_table_ids) |
| 3443 | q.breakable() |
| 3444 | q.text('}') |
| 3445 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3446 | table_feature_prop.subtypes[3] = table_feature_prop_next_tables_miss |
| 3447 | |
| 3448 | class table_feature_prop_wildcards(table_feature_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3449 | type = 10 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3450 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3451 | def __init__(self, oxm_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3452 | if oxm_ids != None: |
| 3453 | self.oxm_ids = oxm_ids |
| 3454 | else: |
| 3455 | self.oxm_ids = [] |
| 3456 | return |
| 3457 | |
| 3458 | def pack(self): |
| 3459 | packed = [] |
| 3460 | packed.append(struct.pack("!H", self.type)) |
| 3461 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3462 | packed.append(loxi.generic_util.pack_list(self.oxm_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3463 | length = sum([len(x) for x in packed]) |
| 3464 | packed[1] = struct.pack("!H", length) |
| 3465 | return ''.join(packed) |
| 3466 | |
| 3467 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3468 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3469 | obj = table_feature_prop_wildcards() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3470 | _type = reader.read("!H")[0] |
| 3471 | assert(_type == 10) |
| 3472 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3473 | orig_reader = reader |
| 3474 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3475 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 3476 | return obj |
| 3477 | |
| 3478 | def __eq__(self, other): |
| 3479 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3480 | if self.oxm_ids != other.oxm_ids: return False |
| 3481 | return True |
| 3482 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3483 | def pretty_print(self, q): |
| 3484 | q.text("table_feature_prop_wildcards {") |
| 3485 | with q.group(): |
| 3486 | with q.indent(2): |
| 3487 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3488 | q.text("oxm_ids = "); |
| 3489 | q.pp(self.oxm_ids) |
| 3490 | q.breakable() |
| 3491 | q.text('}') |
| 3492 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3493 | table_feature_prop.subtypes[10] = table_feature_prop_wildcards |
| 3494 | |
| 3495 | class table_feature_prop_write_actions(table_feature_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3496 | type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3497 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3498 | def __init__(self, action_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3499 | if action_ids != None: |
| 3500 | self.action_ids = action_ids |
| 3501 | else: |
| 3502 | self.action_ids = [] |
| 3503 | return |
| 3504 | |
| 3505 | def pack(self): |
| 3506 | packed = [] |
| 3507 | packed.append(struct.pack("!H", self.type)) |
| 3508 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3509 | packed.append(loxi.generic_util.pack_list(self.action_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3510 | length = sum([len(x) for x in packed]) |
| 3511 | packed[1] = struct.pack("!H", length) |
| 3512 | return ''.join(packed) |
| 3513 | |
| 3514 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3515 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3516 | obj = table_feature_prop_write_actions() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3517 | _type = reader.read("!H")[0] |
| 3518 | assert(_type == 4) |
| 3519 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3520 | orig_reader = reader |
| 3521 | reader = orig_reader.slice(_length - (2 + 2)) |
| 3522 | 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] | 3523 | return obj |
| 3524 | |
| 3525 | def __eq__(self, other): |
| 3526 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3527 | if self.action_ids != other.action_ids: return False |
| 3528 | return True |
| 3529 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3530 | def pretty_print(self, q): |
| 3531 | q.text("table_feature_prop_write_actions {") |
| 3532 | with q.group(): |
| 3533 | with q.indent(2): |
| 3534 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3535 | q.text("action_ids = "); |
| 3536 | q.pp(self.action_ids) |
| 3537 | q.breakable() |
| 3538 | q.text('}') |
| 3539 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3540 | table_feature_prop.subtypes[4] = table_feature_prop_write_actions |
| 3541 | |
| 3542 | class table_feature_prop_write_actions_miss(table_feature_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3543 | type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3544 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3545 | def __init__(self, action_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3546 | if action_ids != None: |
| 3547 | self.action_ids = action_ids |
| 3548 | else: |
| 3549 | self.action_ids = [] |
| 3550 | return |
| 3551 | |
| 3552 | def pack(self): |
| 3553 | packed = [] |
| 3554 | packed.append(struct.pack("!H", self.type)) |
| 3555 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3556 | packed.append(loxi.generic_util.pack_list(self.action_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3557 | length = sum([len(x) for x in packed]) |
| 3558 | packed[1] = struct.pack("!H", length) |
| 3559 | return ''.join(packed) |
| 3560 | |
| 3561 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3562 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3563 | obj = table_feature_prop_write_actions_miss() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3564 | _type = reader.read("!H")[0] |
| 3565 | assert(_type == 5) |
| 3566 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3567 | orig_reader = reader |
| 3568 | reader = orig_reader.slice(_length - (2 + 2)) |
| 3569 | 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] | 3570 | return obj |
| 3571 | |
| 3572 | def __eq__(self, other): |
| 3573 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3574 | if self.action_ids != other.action_ids: return False |
| 3575 | return True |
| 3576 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3577 | def pretty_print(self, q): |
| 3578 | q.text("table_feature_prop_write_actions_miss {") |
| 3579 | with q.group(): |
| 3580 | with q.indent(2): |
| 3581 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3582 | q.text("action_ids = "); |
| 3583 | q.pp(self.action_ids) |
| 3584 | q.breakable() |
| 3585 | q.text('}') |
| 3586 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3587 | table_feature_prop.subtypes[5] = table_feature_prop_write_actions_miss |
| 3588 | |
| 3589 | class table_feature_prop_write_setfield(table_feature_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3590 | type = 12 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3591 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3592 | def __init__(self, oxm_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3593 | if oxm_ids != None: |
| 3594 | self.oxm_ids = oxm_ids |
| 3595 | else: |
| 3596 | self.oxm_ids = [] |
| 3597 | return |
| 3598 | |
| 3599 | def pack(self): |
| 3600 | packed = [] |
| 3601 | packed.append(struct.pack("!H", self.type)) |
| 3602 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3603 | packed.append(loxi.generic_util.pack_list(self.oxm_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3604 | length = sum([len(x) for x in packed]) |
| 3605 | packed[1] = struct.pack("!H", length) |
| 3606 | return ''.join(packed) |
| 3607 | |
| 3608 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3609 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3610 | obj = table_feature_prop_write_setfield() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3611 | _type = reader.read("!H")[0] |
| 3612 | assert(_type == 12) |
| 3613 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3614 | orig_reader = reader |
| 3615 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3616 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 3617 | return obj |
| 3618 | |
| 3619 | def __eq__(self, other): |
| 3620 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3621 | if self.oxm_ids != other.oxm_ids: return False |
| 3622 | return True |
| 3623 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3624 | def pretty_print(self, q): |
| 3625 | q.text("table_feature_prop_write_setfield {") |
| 3626 | with q.group(): |
| 3627 | with q.indent(2): |
| 3628 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3629 | q.text("oxm_ids = "); |
| 3630 | q.pp(self.oxm_ids) |
| 3631 | q.breakable() |
| 3632 | q.text('}') |
| 3633 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3634 | table_feature_prop.subtypes[12] = table_feature_prop_write_setfield |
| 3635 | |
| 3636 | class table_feature_prop_write_setfield_miss(table_feature_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3637 | type = 13 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3638 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3639 | def __init__(self, oxm_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3640 | if oxm_ids != None: |
| 3641 | self.oxm_ids = oxm_ids |
| 3642 | else: |
| 3643 | self.oxm_ids = [] |
| 3644 | return |
| 3645 | |
| 3646 | def pack(self): |
| 3647 | packed = [] |
| 3648 | packed.append(struct.pack("!H", self.type)) |
| 3649 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3650 | packed.append(loxi.generic_util.pack_list(self.oxm_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3651 | length = sum([len(x) for x in packed]) |
| 3652 | packed[1] = struct.pack("!H", length) |
| 3653 | return ''.join(packed) |
| 3654 | |
| 3655 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3656 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3657 | obj = table_feature_prop_write_setfield_miss() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3658 | _type = reader.read("!H")[0] |
| 3659 | assert(_type == 13) |
| 3660 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3661 | orig_reader = reader |
| 3662 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3663 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 3664 | return obj |
| 3665 | |
| 3666 | def __eq__(self, other): |
| 3667 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3668 | if self.oxm_ids != other.oxm_ids: return False |
| 3669 | return True |
| 3670 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3671 | def pretty_print(self, q): |
| 3672 | q.text("table_feature_prop_write_setfield_miss {") |
| 3673 | with q.group(): |
| 3674 | with q.indent(2): |
| 3675 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3676 | q.text("oxm_ids = "); |
| 3677 | q.pp(self.oxm_ids) |
| 3678 | q.breakable() |
| 3679 | q.text('}') |
| 3680 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3681 | table_feature_prop.subtypes[13] = table_feature_prop_write_setfield_miss |
| 3682 | |
| 3683 | class table_features(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3684 | |
| 3685 | def __init__(self, table_id=None, name=None, metadata_match=None, metadata_write=None, config=None, max_entries=None, properties=None): |
| 3686 | if table_id != None: |
| 3687 | self.table_id = table_id |
| 3688 | else: |
| 3689 | self.table_id = 0 |
| 3690 | if name != None: |
| 3691 | self.name = name |
| 3692 | else: |
| 3693 | self.name = "" |
| 3694 | if metadata_match != None: |
| 3695 | self.metadata_match = metadata_match |
| 3696 | else: |
| 3697 | self.metadata_match = 0 |
| 3698 | if metadata_write != None: |
| 3699 | self.metadata_write = metadata_write |
| 3700 | else: |
| 3701 | self.metadata_write = 0 |
| 3702 | if config != None: |
| 3703 | self.config = config |
| 3704 | else: |
| 3705 | self.config = 0 |
| 3706 | if max_entries != None: |
| 3707 | self.max_entries = max_entries |
| 3708 | else: |
| 3709 | self.max_entries = 0 |
| 3710 | if properties != None: |
| 3711 | self.properties = properties |
| 3712 | else: |
| 3713 | self.properties = [] |
| 3714 | return |
| 3715 | |
| 3716 | def pack(self): |
| 3717 | packed = [] |
| 3718 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 3719 | packed.append(struct.pack("!B", self.table_id)) |
| 3720 | packed.append('\x00' * 5) |
| 3721 | packed.append(struct.pack("!32s", self.name)) |
| 3722 | packed.append(struct.pack("!Q", self.metadata_match)) |
| 3723 | packed.append(struct.pack("!Q", self.metadata_write)) |
| 3724 | packed.append(struct.pack("!L", self.config)) |
| 3725 | packed.append(struct.pack("!L", self.max_entries)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3726 | packed.append(loxi.generic_util.pack_list(self.properties)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3727 | length = sum([len(x) for x in packed]) |
| 3728 | packed[0] = struct.pack("!H", length) |
| 3729 | return ''.join(packed) |
| 3730 | |
| 3731 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3732 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3733 | obj = table_features() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3734 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3735 | orig_reader = reader |
| 3736 | reader = orig_reader.slice(_length - (0 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3737 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3738 | reader.skip(5) |
| 3739 | obj.name = reader.read("!32s")[0].rstrip("\x00") |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3740 | obj.metadata_match = reader.read("!Q")[0] |
| 3741 | obj.metadata_write = reader.read("!Q")[0] |
| 3742 | obj.config = reader.read("!L")[0] |
| 3743 | obj.max_entries = reader.read("!L")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3744 | 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] | 3745 | return obj |
| 3746 | |
| 3747 | def __eq__(self, other): |
| 3748 | if type(self) != type(other): return False |
| 3749 | if self.table_id != other.table_id: return False |
| 3750 | if self.name != other.name: return False |
| 3751 | if self.metadata_match != other.metadata_match: return False |
| 3752 | if self.metadata_write != other.metadata_write: return False |
| 3753 | if self.config != other.config: return False |
| 3754 | if self.max_entries != other.max_entries: return False |
| 3755 | if self.properties != other.properties: return False |
| 3756 | return True |
| 3757 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3758 | def pretty_print(self, q): |
| 3759 | q.text("table_features {") |
| 3760 | with q.group(): |
| 3761 | with q.indent(2): |
| 3762 | q.breakable() |
| 3763 | q.text("table_id = "); |
| 3764 | q.text("%#x" % self.table_id) |
| 3765 | q.text(","); q.breakable() |
| 3766 | q.text("name = "); |
| 3767 | q.pp(self.name) |
| 3768 | q.text(","); q.breakable() |
| 3769 | q.text("metadata_match = "); |
| 3770 | q.text("%#x" % self.metadata_match) |
| 3771 | q.text(","); q.breakable() |
| 3772 | q.text("metadata_write = "); |
| 3773 | q.text("%#x" % self.metadata_write) |
| 3774 | q.text(","); q.breakable() |
| 3775 | q.text("config = "); |
| 3776 | q.text("%#x" % self.config) |
| 3777 | q.text(","); q.breakable() |
| 3778 | q.text("max_entries = "); |
| 3779 | q.text("%#x" % self.max_entries) |
| 3780 | q.text(","); q.breakable() |
| 3781 | q.text("properties = "); |
| 3782 | q.pp(self.properties) |
| 3783 | q.breakable() |
| 3784 | q.text('}') |
| 3785 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3786 | |
| 3787 | class table_stats_entry(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3788 | |
| 3789 | def __init__(self, table_id=None, active_count=None, lookup_count=None, matched_count=None): |
| 3790 | if table_id != None: |
| 3791 | self.table_id = table_id |
| 3792 | else: |
| 3793 | self.table_id = 0 |
| 3794 | if active_count != None: |
| 3795 | self.active_count = active_count |
| 3796 | else: |
| 3797 | self.active_count = 0 |
| 3798 | if lookup_count != None: |
| 3799 | self.lookup_count = lookup_count |
| 3800 | else: |
| 3801 | self.lookup_count = 0 |
| 3802 | if matched_count != None: |
| 3803 | self.matched_count = matched_count |
| 3804 | else: |
| 3805 | self.matched_count = 0 |
| 3806 | return |
| 3807 | |
| 3808 | def pack(self): |
| 3809 | packed = [] |
| 3810 | packed.append(struct.pack("!B", self.table_id)) |
| 3811 | packed.append('\x00' * 3) |
| 3812 | packed.append(struct.pack("!L", self.active_count)) |
| 3813 | packed.append(struct.pack("!Q", self.lookup_count)) |
| 3814 | packed.append(struct.pack("!Q", self.matched_count)) |
| 3815 | return ''.join(packed) |
| 3816 | |
| 3817 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3818 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3819 | obj = table_stats_entry() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3820 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3821 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3822 | obj.active_count = reader.read("!L")[0] |
| 3823 | obj.lookup_count = reader.read("!Q")[0] |
| 3824 | obj.matched_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3825 | return obj |
| 3826 | |
| 3827 | def __eq__(self, other): |
| 3828 | if type(self) != type(other): return False |
| 3829 | if self.table_id != other.table_id: return False |
| 3830 | if self.active_count != other.active_count: return False |
| 3831 | if self.lookup_count != other.lookup_count: return False |
| 3832 | if self.matched_count != other.matched_count: return False |
| 3833 | return True |
| 3834 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3835 | def pretty_print(self, q): |
| 3836 | q.text("table_stats_entry {") |
| 3837 | with q.group(): |
| 3838 | with q.indent(2): |
| 3839 | q.breakable() |
| 3840 | q.text("table_id = "); |
| 3841 | q.text("%#x" % self.table_id) |
| 3842 | q.text(","); q.breakable() |
| 3843 | q.text("active_count = "); |
| 3844 | q.text("%#x" % self.active_count) |
| 3845 | q.text(","); q.breakable() |
| 3846 | q.text("lookup_count = "); |
| 3847 | q.text("%#x" % self.lookup_count) |
| 3848 | q.text(","); q.breakable() |
| 3849 | q.text("matched_count = "); |
| 3850 | q.text("%#x" % self.matched_count) |
| 3851 | q.breakable() |
| 3852 | q.text('}') |
| 3853 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3854 | |
| 3855 | class uint32(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3856 | |
| 3857 | def __init__(self, value=None): |
| 3858 | if value != None: |
| 3859 | self.value = value |
| 3860 | else: |
| 3861 | self.value = 0 |
| 3862 | return |
| 3863 | |
| 3864 | def pack(self): |
| 3865 | packed = [] |
| 3866 | packed.append(struct.pack("!L", self.value)) |
| 3867 | return ''.join(packed) |
| 3868 | |
| 3869 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3870 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3871 | obj = uint32() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3872 | obj.value = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3873 | return obj |
| 3874 | |
| 3875 | def __eq__(self, other): |
| 3876 | if type(self) != type(other): return False |
| 3877 | if self.value != other.value: return False |
| 3878 | return True |
| 3879 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3880 | def pretty_print(self, q): |
| 3881 | q.text("uint32 {") |
| 3882 | with q.group(): |
| 3883 | with q.indent(2): |
| 3884 | q.breakable() |
| 3885 | q.text("value = "); |
| 3886 | q.text("%#x" % self.value) |
| 3887 | q.breakable() |
| 3888 | q.text('}') |
| 3889 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3890 | |
| 3891 | class uint64(loxi.OFObject): |
| 3892 | |
| 3893 | def __init__(self, value=None): |
| 3894 | if value != None: |
| 3895 | self.value = value |
| 3896 | else: |
| 3897 | self.value = 0 |
| 3898 | return |
| 3899 | |
| 3900 | def pack(self): |
| 3901 | packed = [] |
| 3902 | packed.append(struct.pack("!Q", self.value)) |
| 3903 | return ''.join(packed) |
| 3904 | |
| 3905 | @staticmethod |
| 3906 | def unpack(reader): |
| 3907 | obj = uint64() |
| 3908 | obj.value = reader.read("!Q")[0] |
| 3909 | return obj |
| 3910 | |
| 3911 | def __eq__(self, other): |
| 3912 | if type(self) != type(other): return False |
| 3913 | if self.value != other.value: return False |
| 3914 | return True |
| 3915 | |
| 3916 | def pretty_print(self, q): |
| 3917 | q.text("uint64 {") |
| 3918 | with q.group(): |
| 3919 | with q.indent(2): |
| 3920 | q.breakable() |
| 3921 | q.text("value = "); |
| 3922 | q.text("%#x" % self.value) |
| 3923 | q.breakable() |
| 3924 | q.text('}') |
| 3925 | |
| 3926 | |
| 3927 | class uint8(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3928 | |
| 3929 | def __init__(self, value=None): |
| 3930 | if value != None: |
| 3931 | self.value = value |
| 3932 | else: |
| 3933 | self.value = 0 |
| 3934 | return |
| 3935 | |
| 3936 | def pack(self): |
| 3937 | packed = [] |
| 3938 | packed.append(struct.pack("!B", self.value)) |
| 3939 | return ''.join(packed) |
| 3940 | |
| 3941 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3942 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3943 | obj = uint8() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3944 | obj.value = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3945 | return obj |
| 3946 | |
| 3947 | def __eq__(self, other): |
| 3948 | if type(self) != type(other): return False |
| 3949 | if self.value != other.value: return False |
| 3950 | return True |
| 3951 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3952 | def pretty_print(self, q): |
| 3953 | q.text("uint8 {") |
| 3954 | with q.group(): |
| 3955 | with q.indent(2): |
| 3956 | q.breakable() |
| 3957 | q.text("value = "); |
| 3958 | q.text("%#x" % self.value) |
| 3959 | q.breakable() |
| 3960 | q.text('}') |
| 3961 | |
| 3962 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3963 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3964 | match = match_v3 |