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