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