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