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 | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5 | |
| 6 | # Automatically generated by LOXI from template common.py |
| 7 | # Do not modify |
| 8 | |
| 9 | import sys |
| 10 | import struct |
| 11 | import action |
| 12 | import instruction # for unpack_list |
| 13 | import meter_band # for unpack_list |
| 14 | import const |
| 15 | import util |
| 16 | import loxi.generic_util |
| 17 | |
| 18 | import oxm |
| 19 | |
| 20 | # HACK make this module visible as 'common' to simplify code generation |
| 21 | common = sys.modules[__name__] |
| 22 | |
| 23 | def unpack_list_flow_stats_entry(reader): |
| 24 | return loxi.generic_util.unpack_list_lv16(reader, flow_stats_entry.unpack) |
| 25 | |
| 26 | def unpack_list_queue_prop(reader): |
| 27 | def deserializer(reader, typ): |
| 28 | if typ == const.OFPQT_MIN_RATE: |
| 29 | return queue_prop_min_rate.unpack(reader) |
| 30 | else: |
| 31 | raise loxi.ProtocolError("unknown queue prop %d" % typ) |
| 32 | return loxi.generic_util.unpack_list_tlv16(reader, deserializer) |
| 33 | |
| 34 | def unpack_list_packet_queue(reader): |
| 35 | def wrapper(reader): |
| 36 | length, = reader.peek('!4xH') |
| 37 | return packet_queue.unpack(reader.slice(length)) |
| 38 | return loxi.generic_util.unpack_list(reader, wrapper) |
| 39 | |
| 40 | def unpack_list_hello_elem(reader): |
| 41 | def deserializer(reader, typ): |
| 42 | if typ == const.OFPHET_VERSIONBITMAP: |
| 43 | return hello_elem_versionbitmap.unpack(reader) |
| 44 | else: |
| 45 | return None |
| 46 | return [x for x in loxi.generic_util.unpack_list_tlv16(reader, deserializer) if x != None] |
| 47 | |
| 48 | def unpack_list_bucket(reader): |
| 49 | return loxi.generic_util.unpack_list_lv16(reader, bucket.unpack) |
| 50 | |
| 51 | def unpack_list_group_desc_stats_entry(reader): |
| 52 | return loxi.generic_util.unpack_list_lv16(reader, group_desc_stats_entry.unpack) |
| 53 | |
| 54 | def unpack_list_group_stats_entry(reader): |
| 55 | return loxi.generic_util.unpack_list_lv16(reader, group_stats_entry.unpack) |
| 56 | |
| 57 | def unpack_list_meter_stats(reader): |
| 58 | def wrapper(reader): |
| 59 | length, = reader.peek('!4xH') |
| 60 | return meter_stats.unpack(reader.slice(length)) |
| 61 | return loxi.generic_util.unpack_list(reader, wrapper) |
| 62 | |
Kiran Poola | ae8fbf1 | 2013-09-19 16:32:32 -0700 | [diff] [blame] | 63 | class action_id(object): |
| 64 | |
| 65 | def __init__(self, type=None): |
| 66 | if type != None: |
| 67 | self.type = type |
| 68 | else: |
| 69 | self.type = 0 |
| 70 | return |
| 71 | |
| 72 | def pack(self): |
| 73 | packed = [] |
| 74 | packed.append(struct.pack("!H", self.type)) |
| 75 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 76 | packed.append('\x00' * 4) |
| 77 | length = sum([len(x) for x in packed]) |
| 78 | packed[1] = struct.pack("!H", length) |
| 79 | return ''.join(packed) |
| 80 | |
| 81 | @staticmethod |
| 82 | def unpack(buf): |
| 83 | obj = action_id() |
| 84 | if type(buf) == loxi.generic_util.OFReader: |
| 85 | reader = buf |
| 86 | else: |
| 87 | reader = loxi.generic_util.OFReader(buf) |
| 88 | obj.type = reader.read("!H")[0] |
| 89 | _len = reader.read("!H")[0] |
| 90 | reader.skip(4) |
| 91 | return obj |
| 92 | |
| 93 | def __eq__(self, other): |
| 94 | if type(self) != type(other): return False |
| 95 | if self.type != other.type: return False |
| 96 | return True |
| 97 | |
| 98 | def __ne__(self, other): |
| 99 | return not self.__eq__(other) |
| 100 | |
| 101 | def show(self): |
| 102 | import loxi.pp |
| 103 | return loxi.pp.pp(self) |
| 104 | |
| 105 | def pretty_print(self, q): |
| 106 | q.text("action_id {") |
| 107 | with q.group(): |
| 108 | with q.indent(2): |
| 109 | q.breakable() |
| 110 | q.text("type = "); |
| 111 | q.text("%#x" % self.type) |
| 112 | q.breakable() |
| 113 | q.text('}') |
| 114 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 115 | class bsn_interface(object): |
| 116 | |
| 117 | def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None): |
| 118 | if hw_addr != None: |
| 119 | self.hw_addr = hw_addr |
| 120 | else: |
| 121 | self.hw_addr = [0,0,0,0,0,0] |
| 122 | if name != None: |
| 123 | self.name = name |
| 124 | else: |
| 125 | self.name = "" |
| 126 | if ipv4_addr != None: |
| 127 | self.ipv4_addr = ipv4_addr |
| 128 | else: |
| 129 | self.ipv4_addr = 0 |
| 130 | if ipv4_netmask != None: |
| 131 | self.ipv4_netmask = ipv4_netmask |
| 132 | else: |
| 133 | self.ipv4_netmask = 0 |
| 134 | return |
| 135 | |
| 136 | def pack(self): |
| 137 | packed = [] |
| 138 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 139 | packed.append('\x00' * 2) |
| 140 | packed.append(struct.pack("!16s", self.name)) |
| 141 | packed.append(struct.pack("!L", self.ipv4_addr)) |
| 142 | packed.append(struct.pack("!L", self.ipv4_netmask)) |
| 143 | return ''.join(packed) |
| 144 | |
| 145 | @staticmethod |
| 146 | def unpack(buf): |
| 147 | obj = bsn_interface() |
| 148 | if type(buf) == loxi.generic_util.OFReader: |
| 149 | reader = buf |
| 150 | else: |
| 151 | reader = loxi.generic_util.OFReader(buf) |
| 152 | obj.hw_addr = list(reader.read('!6B')) |
| 153 | reader.skip(2) |
| 154 | obj.name = reader.read("!16s")[0].rstrip("\x00") |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 155 | obj.ipv4_addr = reader.read("!L")[0] |
| 156 | obj.ipv4_netmask = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 157 | return obj |
| 158 | |
| 159 | def __eq__(self, other): |
| 160 | if type(self) != type(other): return False |
| 161 | if self.hw_addr != other.hw_addr: return False |
| 162 | if self.name != other.name: return False |
| 163 | if self.ipv4_addr != other.ipv4_addr: return False |
| 164 | if self.ipv4_netmask != other.ipv4_netmask: return False |
| 165 | return True |
| 166 | |
| 167 | def __ne__(self, other): |
| 168 | return not self.__eq__(other) |
| 169 | |
| 170 | def show(self): |
| 171 | import loxi.pp |
| 172 | return loxi.pp.pp(self) |
| 173 | |
| 174 | def pretty_print(self, q): |
| 175 | q.text("bsn_interface {") |
| 176 | with q.group(): |
| 177 | with q.indent(2): |
| 178 | q.breakable() |
| 179 | q.text("hw_addr = "); |
| 180 | q.text(util.pretty_mac(self.hw_addr)) |
| 181 | q.text(","); q.breakable() |
| 182 | q.text("name = "); |
| 183 | q.pp(self.name) |
| 184 | q.text(","); q.breakable() |
| 185 | q.text("ipv4_addr = "); |
| 186 | q.text(util.pretty_ipv4(self.ipv4_addr)) |
| 187 | q.text(","); q.breakable() |
| 188 | q.text("ipv4_netmask = "); |
| 189 | q.text(util.pretty_ipv4(self.ipv4_netmask)) |
| 190 | q.breakable() |
| 191 | q.text('}') |
| 192 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 193 | class bsn_vport_q_in_q(object): |
| 194 | type = 0 |
| 195 | |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 196 | 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] | 197 | if port_no != None: |
| 198 | self.port_no = port_no |
| 199 | else: |
| 200 | self.port_no = 0 |
| 201 | if ingress_tpid != None: |
| 202 | self.ingress_tpid = ingress_tpid |
| 203 | else: |
| 204 | self.ingress_tpid = 0 |
| 205 | if ingress_vlan_id != None: |
| 206 | self.ingress_vlan_id = ingress_vlan_id |
| 207 | else: |
| 208 | self.ingress_vlan_id = 0 |
| 209 | if egress_tpid != None: |
| 210 | self.egress_tpid = egress_tpid |
| 211 | else: |
| 212 | self.egress_tpid = 0 |
| 213 | if egress_vlan_id != None: |
| 214 | self.egress_vlan_id = egress_vlan_id |
| 215 | else: |
| 216 | self.egress_vlan_id = 0 |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 217 | if if_name != None: |
| 218 | self.if_name = if_name |
| 219 | else: |
| 220 | self.if_name = "" |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 221 | return |
| 222 | |
| 223 | def pack(self): |
| 224 | packed = [] |
| 225 | packed.append(struct.pack("!H", self.type)) |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 226 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 227 | packed.append(struct.pack("!L", self.port_no)) |
| 228 | packed.append(struct.pack("!H", self.ingress_tpid)) |
| 229 | packed.append(struct.pack("!H", self.ingress_vlan_id)) |
| 230 | packed.append(struct.pack("!H", self.egress_tpid)) |
| 231 | packed.append(struct.pack("!H", self.egress_vlan_id)) |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 232 | packed.append(struct.pack("!16s", self.if_name)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 233 | length = sum([len(x) for x in packed]) |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 234 | packed[1] = struct.pack("!H", length) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 235 | return ''.join(packed) |
| 236 | |
| 237 | @staticmethod |
| 238 | def unpack(buf): |
| 239 | obj = bsn_vport_q_in_q() |
| 240 | if type(buf) == loxi.generic_util.OFReader: |
| 241 | reader = buf |
| 242 | else: |
| 243 | reader = loxi.generic_util.OFReader(buf) |
| 244 | _type = reader.read("!H")[0] |
| 245 | assert(_type == 0) |
| 246 | _length = reader.read("!H")[0] |
| 247 | obj.port_no = reader.read("!L")[0] |
| 248 | obj.ingress_tpid = reader.read("!H")[0] |
| 249 | obj.ingress_vlan_id = reader.read("!H")[0] |
| 250 | obj.egress_tpid = reader.read("!H")[0] |
| 251 | obj.egress_vlan_id = reader.read("!H")[0] |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 252 | obj.if_name = reader.read("!16s")[0].rstrip("\x00") |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 253 | return obj |
| 254 | |
| 255 | def __eq__(self, other): |
| 256 | if type(self) != type(other): return False |
| 257 | if self.port_no != other.port_no: return False |
| 258 | if self.ingress_tpid != other.ingress_tpid: return False |
| 259 | if self.ingress_vlan_id != other.ingress_vlan_id: return False |
| 260 | if self.egress_tpid != other.egress_tpid: return False |
| 261 | if self.egress_vlan_id != other.egress_vlan_id: return False |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 262 | if self.if_name != other.if_name: return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 263 | return True |
| 264 | |
| 265 | def __ne__(self, other): |
| 266 | return not self.__eq__(other) |
| 267 | |
| 268 | def show(self): |
| 269 | import loxi.pp |
| 270 | return loxi.pp.pp(self) |
| 271 | |
| 272 | def pretty_print(self, q): |
| 273 | q.text("bsn_vport_q_in_q {") |
| 274 | with q.group(): |
| 275 | with q.indent(2): |
| 276 | q.breakable() |
| 277 | q.text("port_no = "); |
| 278 | q.text("%#x" % self.port_no) |
| 279 | q.text(","); q.breakable() |
| 280 | q.text("ingress_tpid = "); |
| 281 | q.text("%#x" % self.ingress_tpid) |
| 282 | q.text(","); q.breakable() |
| 283 | q.text("ingress_vlan_id = "); |
| 284 | q.text("%#x" % self.ingress_vlan_id) |
| 285 | q.text(","); q.breakable() |
| 286 | q.text("egress_tpid = "); |
| 287 | q.text("%#x" % self.egress_tpid) |
| 288 | q.text(","); q.breakable() |
| 289 | q.text("egress_vlan_id = "); |
| 290 | q.text("%#x" % self.egress_vlan_id) |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 291 | q.text(","); q.breakable() |
| 292 | q.text("if_name = "); |
| 293 | q.pp(self.if_name) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 294 | q.breakable() |
| 295 | q.text('}') |
| 296 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 297 | class bucket(object): |
| 298 | |
| 299 | def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None): |
| 300 | if weight != None: |
| 301 | self.weight = weight |
| 302 | else: |
| 303 | self.weight = 0 |
| 304 | if watch_port != None: |
| 305 | self.watch_port = watch_port |
| 306 | else: |
| 307 | self.watch_port = 0 |
| 308 | if watch_group != None: |
| 309 | self.watch_group = watch_group |
| 310 | else: |
| 311 | self.watch_group = 0 |
| 312 | if actions != None: |
| 313 | self.actions = actions |
| 314 | else: |
| 315 | self.actions = [] |
| 316 | return |
| 317 | |
| 318 | def pack(self): |
| 319 | packed = [] |
| 320 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 0 |
| 321 | packed.append(struct.pack("!H", self.weight)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 322 | packed.append(util.pack_port_no(self.watch_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 323 | packed.append(struct.pack("!L", self.watch_group)) |
| 324 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 325 | packed.append(util.pack_list(self.actions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 326 | length = sum([len(x) for x in packed]) |
| 327 | packed[0] = struct.pack("!H", length) |
| 328 | return ''.join(packed) |
| 329 | |
| 330 | @staticmethod |
| 331 | def unpack(buf): |
| 332 | obj = bucket() |
| 333 | if type(buf) == loxi.generic_util.OFReader: |
| 334 | reader = buf |
| 335 | else: |
| 336 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 337 | _len = reader.read("!H")[0] |
| 338 | obj.weight = reader.read("!H")[0] |
| 339 | obj.watch_port = util.unpack_port_no(reader) |
| 340 | obj.watch_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 341 | reader.skip(4) |
| 342 | obj.actions = action.unpack_list(reader) |
| 343 | return obj |
| 344 | |
| 345 | def __eq__(self, other): |
| 346 | if type(self) != type(other): return False |
| 347 | if self.weight != other.weight: return False |
| 348 | if self.watch_port != other.watch_port: return False |
| 349 | if self.watch_group != other.watch_group: return False |
| 350 | if self.actions != other.actions: return False |
| 351 | return True |
| 352 | |
| 353 | def __ne__(self, other): |
| 354 | return not self.__eq__(other) |
| 355 | |
| 356 | def show(self): |
| 357 | import loxi.pp |
| 358 | return loxi.pp.pp(self) |
| 359 | |
| 360 | def pretty_print(self, q): |
| 361 | q.text("bucket {") |
| 362 | with q.group(): |
| 363 | with q.indent(2): |
| 364 | q.breakable() |
| 365 | q.text("weight = "); |
| 366 | q.text("%#x" % self.weight) |
| 367 | q.text(","); q.breakable() |
| 368 | q.text("watch_port = "); |
| 369 | q.text(util.pretty_port(self.watch_port)) |
| 370 | q.text(","); q.breakable() |
| 371 | q.text("watch_group = "); |
| 372 | q.text("%#x" % self.watch_group) |
| 373 | q.text(","); q.breakable() |
| 374 | q.text("actions = "); |
| 375 | q.pp(self.actions) |
| 376 | q.breakable() |
| 377 | q.text('}') |
| 378 | |
| 379 | class bucket_counter(object): |
| 380 | |
| 381 | def __init__(self, packet_count=None, byte_count=None): |
| 382 | if packet_count != None: |
| 383 | self.packet_count = packet_count |
| 384 | else: |
| 385 | self.packet_count = 0 |
| 386 | if byte_count != None: |
| 387 | self.byte_count = byte_count |
| 388 | else: |
| 389 | self.byte_count = 0 |
| 390 | return |
| 391 | |
| 392 | def pack(self): |
| 393 | packed = [] |
| 394 | packed.append(struct.pack("!Q", self.packet_count)) |
| 395 | packed.append(struct.pack("!Q", self.byte_count)) |
| 396 | return ''.join(packed) |
| 397 | |
| 398 | @staticmethod |
| 399 | def unpack(buf): |
| 400 | obj = bucket_counter() |
| 401 | if type(buf) == loxi.generic_util.OFReader: |
| 402 | reader = buf |
| 403 | else: |
| 404 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 405 | obj.packet_count = reader.read("!Q")[0] |
| 406 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 407 | return obj |
| 408 | |
| 409 | def __eq__(self, other): |
| 410 | if type(self) != type(other): return False |
| 411 | if self.packet_count != other.packet_count: return False |
| 412 | if self.byte_count != other.byte_count: return False |
| 413 | return True |
| 414 | |
| 415 | def __ne__(self, other): |
| 416 | return not self.__eq__(other) |
| 417 | |
| 418 | def show(self): |
| 419 | import loxi.pp |
| 420 | return loxi.pp.pp(self) |
| 421 | |
| 422 | def pretty_print(self, q): |
| 423 | q.text("bucket_counter {") |
| 424 | with q.group(): |
| 425 | with q.indent(2): |
| 426 | q.breakable() |
| 427 | q.text("packet_count = "); |
| 428 | q.text("%#x" % self.packet_count) |
| 429 | q.text(","); q.breakable() |
| 430 | q.text("byte_count = "); |
| 431 | q.text("%#x" % self.byte_count) |
| 432 | q.breakable() |
| 433 | q.text('}') |
| 434 | |
| 435 | class flow_stats_entry(object): |
| 436 | |
Kiran Poola | ae8fbf1 | 2013-09-19 16:32:32 -0700 | [diff] [blame] | 437 | 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] | 438 | if table_id != None: |
| 439 | self.table_id = table_id |
| 440 | else: |
| 441 | self.table_id = 0 |
| 442 | if duration_sec != None: |
| 443 | self.duration_sec = duration_sec |
| 444 | else: |
| 445 | self.duration_sec = 0 |
| 446 | if duration_nsec != None: |
| 447 | self.duration_nsec = duration_nsec |
| 448 | else: |
| 449 | self.duration_nsec = 0 |
| 450 | if priority != None: |
| 451 | self.priority = priority |
| 452 | else: |
| 453 | self.priority = 0 |
| 454 | if idle_timeout != None: |
| 455 | self.idle_timeout = idle_timeout |
| 456 | else: |
| 457 | self.idle_timeout = 0 |
| 458 | if hard_timeout != None: |
| 459 | self.hard_timeout = hard_timeout |
| 460 | else: |
| 461 | self.hard_timeout = 0 |
Kiran Poola | ae8fbf1 | 2013-09-19 16:32:32 -0700 | [diff] [blame] | 462 | if flags != None: |
| 463 | self.flags = flags |
| 464 | else: |
| 465 | self.flags = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 466 | if cookie != None: |
| 467 | self.cookie = cookie |
| 468 | else: |
| 469 | self.cookie = 0 |
| 470 | if packet_count != None: |
| 471 | self.packet_count = packet_count |
| 472 | else: |
| 473 | self.packet_count = 0 |
| 474 | if byte_count != None: |
| 475 | self.byte_count = byte_count |
| 476 | else: |
| 477 | self.byte_count = 0 |
| 478 | if match != None: |
| 479 | self.match = match |
| 480 | else: |
| 481 | self.match = common.match() |
| 482 | if instructions != None: |
| 483 | self.instructions = instructions |
| 484 | else: |
| 485 | self.instructions = [] |
| 486 | return |
| 487 | |
| 488 | def pack(self): |
| 489 | packed = [] |
| 490 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 491 | packed.append(struct.pack("!B", self.table_id)) |
| 492 | packed.append('\x00' * 1) |
| 493 | packed.append(struct.pack("!L", self.duration_sec)) |
| 494 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 495 | packed.append(struct.pack("!H", self.priority)) |
| 496 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 497 | packed.append(struct.pack("!H", self.hard_timeout)) |
Kiran Poola | ae8fbf1 | 2013-09-19 16:32:32 -0700 | [diff] [blame] | 498 | packed.append(struct.pack("!H", self.flags)) |
| 499 | packed.append('\x00' * 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 500 | packed.append(struct.pack("!Q", self.cookie)) |
| 501 | packed.append(struct.pack("!Q", self.packet_count)) |
| 502 | packed.append(struct.pack("!Q", self.byte_count)) |
| 503 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 504 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 505 | length = sum([len(x) for x in packed]) |
| 506 | packed[0] = struct.pack("!H", length) |
| 507 | return ''.join(packed) |
| 508 | |
| 509 | @staticmethod |
| 510 | def unpack(buf): |
| 511 | obj = flow_stats_entry() |
| 512 | if type(buf) == loxi.generic_util.OFReader: |
| 513 | reader = buf |
| 514 | else: |
| 515 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 516 | _length = reader.read("!H")[0] |
| 517 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 518 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 519 | obj.duration_sec = reader.read("!L")[0] |
| 520 | obj.duration_nsec = reader.read("!L")[0] |
| 521 | obj.priority = reader.read("!H")[0] |
| 522 | obj.idle_timeout = reader.read("!H")[0] |
| 523 | obj.hard_timeout = reader.read("!H")[0] |
Kiran Poola | ae8fbf1 | 2013-09-19 16:32:32 -0700 | [diff] [blame] | 524 | obj.flags = reader.read("!H")[0] |
| 525 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 526 | obj.cookie = reader.read("!Q")[0] |
| 527 | obj.packet_count = reader.read("!Q")[0] |
| 528 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 529 | obj.match = common.match.unpack(reader) |
| 530 | obj.instructions = instruction.unpack_list(reader) |
| 531 | return obj |
| 532 | |
| 533 | def __eq__(self, other): |
| 534 | if type(self) != type(other): return False |
| 535 | if self.table_id != other.table_id: return False |
| 536 | if self.duration_sec != other.duration_sec: return False |
| 537 | if self.duration_nsec != other.duration_nsec: return False |
| 538 | if self.priority != other.priority: return False |
| 539 | if self.idle_timeout != other.idle_timeout: return False |
| 540 | if self.hard_timeout != other.hard_timeout: return False |
Kiran Poola | ae8fbf1 | 2013-09-19 16:32:32 -0700 | [diff] [blame] | 541 | if self.flags != other.flags: return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 542 | if self.cookie != other.cookie: return False |
| 543 | if self.packet_count != other.packet_count: return False |
| 544 | if self.byte_count != other.byte_count: return False |
| 545 | if self.match != other.match: return False |
| 546 | if self.instructions != other.instructions: return False |
| 547 | return True |
| 548 | |
| 549 | def __ne__(self, other): |
| 550 | return not self.__eq__(other) |
| 551 | |
| 552 | def show(self): |
| 553 | import loxi.pp |
| 554 | return loxi.pp.pp(self) |
| 555 | |
| 556 | def pretty_print(self, q): |
| 557 | q.text("flow_stats_entry {") |
| 558 | with q.group(): |
| 559 | with q.indent(2): |
| 560 | q.breakable() |
| 561 | q.text("table_id = "); |
| 562 | q.text("%#x" % self.table_id) |
| 563 | q.text(","); q.breakable() |
| 564 | q.text("duration_sec = "); |
| 565 | q.text("%#x" % self.duration_sec) |
| 566 | q.text(","); q.breakable() |
| 567 | q.text("duration_nsec = "); |
| 568 | q.text("%#x" % self.duration_nsec) |
| 569 | q.text(","); q.breakable() |
| 570 | q.text("priority = "); |
| 571 | q.text("%#x" % self.priority) |
| 572 | q.text(","); q.breakable() |
| 573 | q.text("idle_timeout = "); |
| 574 | q.text("%#x" % self.idle_timeout) |
| 575 | q.text(","); q.breakable() |
| 576 | q.text("hard_timeout = "); |
| 577 | q.text("%#x" % self.hard_timeout) |
| 578 | q.text(","); q.breakable() |
Kiran Poola | ae8fbf1 | 2013-09-19 16:32:32 -0700 | [diff] [blame] | 579 | q.text("flags = "); |
| 580 | q.text("%#x" % self.flags) |
| 581 | q.text(","); q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 582 | q.text("cookie = "); |
| 583 | q.text("%#x" % self.cookie) |
| 584 | q.text(","); q.breakable() |
| 585 | q.text("packet_count = "); |
| 586 | q.text("%#x" % self.packet_count) |
| 587 | q.text(","); q.breakable() |
| 588 | q.text("byte_count = "); |
| 589 | q.text("%#x" % self.byte_count) |
| 590 | q.text(","); q.breakable() |
| 591 | q.text("match = "); |
| 592 | q.pp(self.match) |
| 593 | q.text(","); q.breakable() |
| 594 | q.text("instructions = "); |
| 595 | q.pp(self.instructions) |
| 596 | q.breakable() |
| 597 | q.text('}') |
| 598 | |
| 599 | class group_desc_stats_entry(object): |
| 600 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 601 | def __init__(self, group_type=None, group_id=None, buckets=None): |
| 602 | if group_type != None: |
| 603 | self.group_type = group_type |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 604 | else: |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 605 | self.group_type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 606 | if group_id != None: |
| 607 | self.group_id = group_id |
| 608 | else: |
| 609 | self.group_id = 0 |
| 610 | if buckets != None: |
| 611 | self.buckets = buckets |
| 612 | else: |
| 613 | self.buckets = [] |
| 614 | return |
| 615 | |
| 616 | def pack(self): |
| 617 | packed = [] |
| 618 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 619 | packed.append(struct.pack("!B", self.group_type)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 620 | packed.append('\x00' * 1) |
| 621 | packed.append(struct.pack("!L", self.group_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 622 | packed.append(util.pack_list(self.buckets)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 623 | length = sum([len(x) for x in packed]) |
| 624 | packed[0] = struct.pack("!H", length) |
| 625 | return ''.join(packed) |
| 626 | |
| 627 | @staticmethod |
| 628 | def unpack(buf): |
| 629 | obj = group_desc_stats_entry() |
| 630 | if type(buf) == loxi.generic_util.OFReader: |
| 631 | reader = buf |
| 632 | else: |
| 633 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 634 | _length = reader.read("!H")[0] |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 635 | obj.group_type = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 636 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 637 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 638 | obj.buckets = common.unpack_list_bucket(reader) |
| 639 | return obj |
| 640 | |
| 641 | def __eq__(self, other): |
| 642 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 643 | if self.group_type != other.group_type: return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 644 | if self.group_id != other.group_id: return False |
| 645 | if self.buckets != other.buckets: return False |
| 646 | return True |
| 647 | |
| 648 | def __ne__(self, other): |
| 649 | return not self.__eq__(other) |
| 650 | |
| 651 | def show(self): |
| 652 | import loxi.pp |
| 653 | return loxi.pp.pp(self) |
| 654 | |
| 655 | def pretty_print(self, q): |
| 656 | q.text("group_desc_stats_entry {") |
| 657 | with q.group(): |
| 658 | with q.indent(2): |
| 659 | q.breakable() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 660 | q.text("group_type = "); |
| 661 | q.text("%#x" % self.group_type) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 662 | q.text(","); q.breakable() |
| 663 | q.text("group_id = "); |
| 664 | q.text("%#x" % self.group_id) |
| 665 | q.text(","); q.breakable() |
| 666 | q.text("buckets = "); |
| 667 | q.pp(self.buckets) |
| 668 | q.breakable() |
| 669 | q.text('}') |
| 670 | |
| 671 | class group_stats_entry(object): |
| 672 | |
| 673 | def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, duration_sec=None, duration_nsec=None, bucket_stats=None): |
| 674 | if group_id != None: |
| 675 | self.group_id = group_id |
| 676 | else: |
| 677 | self.group_id = 0 |
| 678 | if ref_count != None: |
| 679 | self.ref_count = ref_count |
| 680 | else: |
| 681 | self.ref_count = 0 |
| 682 | if packet_count != None: |
| 683 | self.packet_count = packet_count |
| 684 | else: |
| 685 | self.packet_count = 0 |
| 686 | if byte_count != None: |
| 687 | self.byte_count = byte_count |
| 688 | else: |
| 689 | self.byte_count = 0 |
| 690 | if duration_sec != None: |
| 691 | self.duration_sec = duration_sec |
| 692 | else: |
| 693 | self.duration_sec = 0 |
| 694 | if duration_nsec != None: |
| 695 | self.duration_nsec = duration_nsec |
| 696 | else: |
| 697 | self.duration_nsec = 0 |
| 698 | if bucket_stats != None: |
| 699 | self.bucket_stats = bucket_stats |
| 700 | else: |
| 701 | self.bucket_stats = [] |
| 702 | return |
| 703 | |
| 704 | def pack(self): |
| 705 | packed = [] |
| 706 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 707 | packed.append('\x00' * 2) |
| 708 | packed.append(struct.pack("!L", self.group_id)) |
| 709 | packed.append(struct.pack("!L", self.ref_count)) |
| 710 | packed.append('\x00' * 4) |
| 711 | packed.append(struct.pack("!Q", self.packet_count)) |
| 712 | packed.append(struct.pack("!Q", self.byte_count)) |
| 713 | packed.append(struct.pack("!L", self.duration_sec)) |
| 714 | packed.append(struct.pack("!L", self.duration_nsec)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 715 | packed.append(util.pack_list(self.bucket_stats)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 716 | length = sum([len(x) for x in packed]) |
| 717 | packed[0] = struct.pack("!H", length) |
| 718 | return ''.join(packed) |
| 719 | |
| 720 | @staticmethod |
| 721 | def unpack(buf): |
| 722 | obj = group_stats_entry() |
| 723 | if type(buf) == loxi.generic_util.OFReader: |
| 724 | reader = buf |
| 725 | else: |
| 726 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 727 | _length = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 728 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 729 | obj.group_id = reader.read("!L")[0] |
| 730 | obj.ref_count = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 731 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 732 | obj.packet_count = reader.read("!Q")[0] |
| 733 | obj.byte_count = reader.read("!Q")[0] |
| 734 | obj.duration_sec = reader.read("!L")[0] |
| 735 | obj.duration_nsec = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 736 | obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack) |
| 737 | return obj |
| 738 | |
| 739 | def __eq__(self, other): |
| 740 | if type(self) != type(other): return False |
| 741 | if self.group_id != other.group_id: return False |
| 742 | if self.ref_count != other.ref_count: return False |
| 743 | if self.packet_count != other.packet_count: return False |
| 744 | if self.byte_count != other.byte_count: return False |
| 745 | if self.duration_sec != other.duration_sec: return False |
| 746 | if self.duration_nsec != other.duration_nsec: return False |
| 747 | if self.bucket_stats != other.bucket_stats: return False |
| 748 | return True |
| 749 | |
| 750 | def __ne__(self, other): |
| 751 | return not self.__eq__(other) |
| 752 | |
| 753 | def show(self): |
| 754 | import loxi.pp |
| 755 | return loxi.pp.pp(self) |
| 756 | |
| 757 | def pretty_print(self, q): |
| 758 | q.text("group_stats_entry {") |
| 759 | with q.group(): |
| 760 | with q.indent(2): |
| 761 | q.breakable() |
| 762 | q.text("group_id = "); |
| 763 | q.text("%#x" % self.group_id) |
| 764 | q.text(","); q.breakable() |
| 765 | q.text("ref_count = "); |
| 766 | q.text("%#x" % self.ref_count) |
| 767 | q.text(","); q.breakable() |
| 768 | q.text("packet_count = "); |
| 769 | q.text("%#x" % self.packet_count) |
| 770 | q.text(","); q.breakable() |
| 771 | q.text("byte_count = "); |
| 772 | q.text("%#x" % self.byte_count) |
| 773 | q.text(","); q.breakable() |
| 774 | q.text("duration_sec = "); |
| 775 | q.text("%#x" % self.duration_sec) |
| 776 | q.text(","); q.breakable() |
| 777 | q.text("duration_nsec = "); |
| 778 | q.text("%#x" % self.duration_nsec) |
| 779 | q.text(","); q.breakable() |
| 780 | q.text("bucket_stats = "); |
| 781 | q.pp(self.bucket_stats) |
| 782 | q.breakable() |
| 783 | q.text('}') |
| 784 | |
| 785 | class hello_elem_versionbitmap(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 786 | type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 787 | |
| 788 | def __init__(self, bitmaps=None): |
| 789 | if bitmaps != None: |
| 790 | self.bitmaps = bitmaps |
| 791 | else: |
| 792 | self.bitmaps = [] |
| 793 | return |
| 794 | |
| 795 | def pack(self): |
| 796 | packed = [] |
| 797 | packed.append(struct.pack("!H", self.type)) |
| 798 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 799 | packed.append(util.pack_list(self.bitmaps)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 800 | length = sum([len(x) for x in packed]) |
| 801 | packed[1] = struct.pack("!H", length) |
| 802 | return ''.join(packed) |
| 803 | |
| 804 | @staticmethod |
| 805 | def unpack(buf): |
| 806 | obj = hello_elem_versionbitmap() |
| 807 | if type(buf) == loxi.generic_util.OFReader: |
| 808 | reader = buf |
| 809 | else: |
| 810 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 811 | _type = reader.read("!H")[0] |
| 812 | assert(_type == 1) |
| 813 | _length = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 814 | obj.bitmaps = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 815 | return obj |
| 816 | |
| 817 | def __eq__(self, other): |
| 818 | if type(self) != type(other): return False |
| 819 | if self.bitmaps != other.bitmaps: return False |
| 820 | return True |
| 821 | |
| 822 | def __ne__(self, other): |
| 823 | return not self.__eq__(other) |
| 824 | |
| 825 | def show(self): |
| 826 | import loxi.pp |
| 827 | return loxi.pp.pp(self) |
| 828 | |
| 829 | def pretty_print(self, q): |
| 830 | q.text("hello_elem_versionbitmap {") |
| 831 | with q.group(): |
| 832 | with q.indent(2): |
| 833 | q.breakable() |
| 834 | q.text("bitmaps = "); |
| 835 | q.pp(self.bitmaps) |
| 836 | q.breakable() |
| 837 | q.text('}') |
| 838 | |
| 839 | class match_v3(object): |
| 840 | type = 1 |
| 841 | |
| 842 | def __init__(self, oxm_list=None): |
| 843 | if oxm_list != None: |
| 844 | self.oxm_list = oxm_list |
| 845 | else: |
| 846 | self.oxm_list = [] |
| 847 | return |
| 848 | |
| 849 | def pack(self): |
| 850 | packed = [] |
| 851 | packed.append(struct.pack("!H", self.type)) |
| 852 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 853 | packed.append(util.pack_list(self.oxm_list)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 854 | length = sum([len(x) for x in packed]) |
| 855 | packed[1] = struct.pack("!H", length) |
Rich Lane | d53156a | 2013-08-05 17:17:33 -0700 | [diff] [blame] | 856 | packed.append(loxi.generic_util.pad_to(8, length)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 857 | return ''.join(packed) |
| 858 | |
| 859 | @staticmethod |
| 860 | def unpack(buf): |
| 861 | obj = match_v3() |
| 862 | if type(buf) == loxi.generic_util.OFReader: |
| 863 | reader = buf |
| 864 | else: |
| 865 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 866 | _type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 867 | assert(_type == 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 868 | _length = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 869 | obj.oxm_list = oxm.unpack_list(reader.slice(_length-4)) |
Rich Lane | d53156a | 2013-08-05 17:17:33 -0700 | [diff] [blame] | 870 | reader.skip_align() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 871 | return obj |
| 872 | |
| 873 | def __eq__(self, other): |
| 874 | if type(self) != type(other): return False |
| 875 | if self.oxm_list != other.oxm_list: return False |
| 876 | return True |
| 877 | |
| 878 | def __ne__(self, other): |
| 879 | return not self.__eq__(other) |
| 880 | |
| 881 | def show(self): |
| 882 | import loxi.pp |
| 883 | return loxi.pp.pp(self) |
| 884 | |
| 885 | def pretty_print(self, q): |
| 886 | q.text("match_v3 {") |
| 887 | with q.group(): |
| 888 | with q.indent(2): |
| 889 | q.breakable() |
| 890 | q.text("oxm_list = "); |
| 891 | q.pp(self.oxm_list) |
| 892 | q.breakable() |
| 893 | q.text('}') |
| 894 | |
| 895 | class meter_band_stats(object): |
| 896 | |
| 897 | def __init__(self, packet_band_count=None, byte_band_count=None): |
| 898 | if packet_band_count != None: |
| 899 | self.packet_band_count = packet_band_count |
| 900 | else: |
| 901 | self.packet_band_count = 0 |
| 902 | if byte_band_count != None: |
| 903 | self.byte_band_count = byte_band_count |
| 904 | else: |
| 905 | self.byte_band_count = 0 |
| 906 | return |
| 907 | |
| 908 | def pack(self): |
| 909 | packed = [] |
| 910 | packed.append(struct.pack("!Q", self.packet_band_count)) |
| 911 | packed.append(struct.pack("!Q", self.byte_band_count)) |
| 912 | return ''.join(packed) |
| 913 | |
| 914 | @staticmethod |
| 915 | def unpack(buf): |
| 916 | obj = meter_band_stats() |
| 917 | if type(buf) == loxi.generic_util.OFReader: |
| 918 | reader = buf |
| 919 | else: |
| 920 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 921 | obj.packet_band_count = reader.read("!Q")[0] |
| 922 | obj.byte_band_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 923 | return obj |
| 924 | |
| 925 | def __eq__(self, other): |
| 926 | if type(self) != type(other): return False |
| 927 | if self.packet_band_count != other.packet_band_count: return False |
| 928 | if self.byte_band_count != other.byte_band_count: return False |
| 929 | return True |
| 930 | |
| 931 | def __ne__(self, other): |
| 932 | return not self.__eq__(other) |
| 933 | |
| 934 | def show(self): |
| 935 | import loxi.pp |
| 936 | return loxi.pp.pp(self) |
| 937 | |
| 938 | def pretty_print(self, q): |
| 939 | q.text("meter_band_stats {") |
| 940 | with q.group(): |
| 941 | with q.indent(2): |
| 942 | q.breakable() |
| 943 | q.text("packet_band_count = "); |
| 944 | q.text("%#x" % self.packet_band_count) |
| 945 | q.text(","); q.breakable() |
| 946 | q.text("byte_band_count = "); |
| 947 | q.text("%#x" % self.byte_band_count) |
| 948 | q.breakable() |
| 949 | q.text('}') |
| 950 | |
| 951 | class meter_config(object): |
| 952 | |
| 953 | def __init__(self, flags=None, meter_id=None, entries=None): |
| 954 | if flags != None: |
| 955 | self.flags = flags |
| 956 | else: |
| 957 | self.flags = 0 |
| 958 | if meter_id != None: |
| 959 | self.meter_id = meter_id |
| 960 | else: |
| 961 | self.meter_id = 0 |
| 962 | if entries != None: |
| 963 | self.entries = entries |
| 964 | else: |
| 965 | self.entries = [] |
| 966 | return |
| 967 | |
| 968 | def pack(self): |
| 969 | packed = [] |
| 970 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 971 | packed.append(struct.pack("!H", self.flags)) |
| 972 | packed.append(struct.pack("!L", self.meter_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 973 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 974 | length = sum([len(x) for x in packed]) |
| 975 | packed[0] = struct.pack("!H", length) |
| 976 | return ''.join(packed) |
| 977 | |
| 978 | @staticmethod |
| 979 | def unpack(buf): |
| 980 | obj = meter_config() |
| 981 | if type(buf) == loxi.generic_util.OFReader: |
| 982 | reader = buf |
| 983 | else: |
| 984 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 985 | _length = reader.read("!H")[0] |
| 986 | obj.flags = reader.read("!H")[0] |
| 987 | obj.meter_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 988 | obj.entries = meter_band.unpack_list(reader) |
| 989 | return obj |
| 990 | |
| 991 | def __eq__(self, other): |
| 992 | if type(self) != type(other): return False |
| 993 | if self.flags != other.flags: return False |
| 994 | if self.meter_id != other.meter_id: return False |
| 995 | if self.entries != other.entries: return False |
| 996 | return True |
| 997 | |
| 998 | def __ne__(self, other): |
| 999 | return not self.__eq__(other) |
| 1000 | |
| 1001 | def show(self): |
| 1002 | import loxi.pp |
| 1003 | return loxi.pp.pp(self) |
| 1004 | |
| 1005 | def pretty_print(self, q): |
| 1006 | q.text("meter_config {") |
| 1007 | with q.group(): |
| 1008 | with q.indent(2): |
| 1009 | q.breakable() |
| 1010 | q.text("flags = "); |
| 1011 | q.text("%#x" % self.flags) |
| 1012 | q.text(","); q.breakable() |
| 1013 | q.text("meter_id = "); |
| 1014 | q.text("%#x" % self.meter_id) |
| 1015 | q.text(","); q.breakable() |
| 1016 | q.text("entries = "); |
| 1017 | q.pp(self.entries) |
| 1018 | q.breakable() |
| 1019 | q.text('}') |
| 1020 | |
| 1021 | class meter_features(object): |
| 1022 | |
| 1023 | def __init__(self, max_meter=None, band_types=None, capabilities=None, max_bands=None, max_color=None): |
| 1024 | if max_meter != None: |
| 1025 | self.max_meter = max_meter |
| 1026 | else: |
| 1027 | self.max_meter = 0 |
| 1028 | if band_types != None: |
| 1029 | self.band_types = band_types |
| 1030 | else: |
| 1031 | self.band_types = 0 |
| 1032 | if capabilities != None: |
| 1033 | self.capabilities = capabilities |
| 1034 | else: |
| 1035 | self.capabilities = 0 |
| 1036 | if max_bands != None: |
| 1037 | self.max_bands = max_bands |
| 1038 | else: |
| 1039 | self.max_bands = 0 |
| 1040 | if max_color != None: |
| 1041 | self.max_color = max_color |
| 1042 | else: |
| 1043 | self.max_color = 0 |
| 1044 | return |
| 1045 | |
| 1046 | def pack(self): |
| 1047 | packed = [] |
| 1048 | packed.append(struct.pack("!L", self.max_meter)) |
| 1049 | packed.append(struct.pack("!L", self.band_types)) |
| 1050 | packed.append(struct.pack("!L", self.capabilities)) |
| 1051 | packed.append(struct.pack("!B", self.max_bands)) |
| 1052 | packed.append(struct.pack("!B", self.max_color)) |
| 1053 | packed.append('\x00' * 2) |
| 1054 | return ''.join(packed) |
| 1055 | |
| 1056 | @staticmethod |
| 1057 | def unpack(buf): |
| 1058 | obj = meter_features() |
| 1059 | if type(buf) == loxi.generic_util.OFReader: |
| 1060 | reader = buf |
| 1061 | else: |
| 1062 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1063 | obj.max_meter = reader.read("!L")[0] |
| 1064 | obj.band_types = reader.read("!L")[0] |
| 1065 | obj.capabilities = reader.read("!L")[0] |
| 1066 | obj.max_bands = reader.read("!B")[0] |
| 1067 | obj.max_color = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1068 | reader.skip(2) |
| 1069 | return obj |
| 1070 | |
| 1071 | def __eq__(self, other): |
| 1072 | if type(self) != type(other): return False |
| 1073 | if self.max_meter != other.max_meter: return False |
| 1074 | if self.band_types != other.band_types: return False |
| 1075 | if self.capabilities != other.capabilities: return False |
| 1076 | if self.max_bands != other.max_bands: return False |
| 1077 | if self.max_color != other.max_color: return False |
| 1078 | return True |
| 1079 | |
| 1080 | def __ne__(self, other): |
| 1081 | return not self.__eq__(other) |
| 1082 | |
| 1083 | def show(self): |
| 1084 | import loxi.pp |
| 1085 | return loxi.pp.pp(self) |
| 1086 | |
| 1087 | def pretty_print(self, q): |
| 1088 | q.text("meter_features {") |
| 1089 | with q.group(): |
| 1090 | with q.indent(2): |
| 1091 | q.breakable() |
| 1092 | q.text("max_meter = "); |
| 1093 | q.text("%#x" % self.max_meter) |
| 1094 | q.text(","); q.breakable() |
| 1095 | q.text("band_types = "); |
| 1096 | q.text("%#x" % self.band_types) |
| 1097 | q.text(","); q.breakable() |
| 1098 | q.text("capabilities = "); |
| 1099 | q.text("%#x" % self.capabilities) |
| 1100 | q.text(","); q.breakable() |
| 1101 | q.text("max_bands = "); |
| 1102 | q.text("%#x" % self.max_bands) |
| 1103 | q.text(","); q.breakable() |
| 1104 | q.text("max_color = "); |
| 1105 | q.text("%#x" % self.max_color) |
| 1106 | q.breakable() |
| 1107 | q.text('}') |
| 1108 | |
| 1109 | class meter_stats(object): |
| 1110 | |
| 1111 | 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): |
| 1112 | if meter_id != None: |
| 1113 | self.meter_id = meter_id |
| 1114 | else: |
| 1115 | self.meter_id = 0 |
| 1116 | if flow_count != None: |
| 1117 | self.flow_count = flow_count |
| 1118 | else: |
| 1119 | self.flow_count = 0 |
| 1120 | if packet_in_count != None: |
| 1121 | self.packet_in_count = packet_in_count |
| 1122 | else: |
| 1123 | self.packet_in_count = 0 |
| 1124 | if byte_in_count != None: |
| 1125 | self.byte_in_count = byte_in_count |
| 1126 | else: |
| 1127 | self.byte_in_count = 0 |
| 1128 | if duration_sec != None: |
| 1129 | self.duration_sec = duration_sec |
| 1130 | else: |
| 1131 | self.duration_sec = 0 |
| 1132 | if duration_nsec != None: |
| 1133 | self.duration_nsec = duration_nsec |
| 1134 | else: |
| 1135 | self.duration_nsec = 0 |
| 1136 | if band_stats != None: |
| 1137 | self.band_stats = band_stats |
| 1138 | else: |
| 1139 | self.band_stats = [] |
| 1140 | return |
| 1141 | |
| 1142 | def pack(self): |
| 1143 | packed = [] |
| 1144 | packed.append(struct.pack("!L", self.meter_id)) |
| 1145 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1146 | packed.append('\x00' * 6) |
| 1147 | packed.append(struct.pack("!L", self.flow_count)) |
| 1148 | packed.append(struct.pack("!Q", self.packet_in_count)) |
| 1149 | packed.append(struct.pack("!Q", self.byte_in_count)) |
| 1150 | packed.append(struct.pack("!L", self.duration_sec)) |
| 1151 | packed.append(struct.pack("!L", self.duration_nsec)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1152 | packed.append(util.pack_list(self.band_stats)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1153 | length = sum([len(x) for x in packed]) |
| 1154 | packed[1] = struct.pack("!H", length) |
| 1155 | return ''.join(packed) |
| 1156 | |
| 1157 | @staticmethod |
| 1158 | def unpack(buf): |
| 1159 | obj = meter_stats() |
| 1160 | if type(buf) == loxi.generic_util.OFReader: |
| 1161 | reader = buf |
| 1162 | else: |
| 1163 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1164 | obj.meter_id = reader.read("!L")[0] |
| 1165 | _len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1166 | reader.skip(6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1167 | obj.flow_count = reader.read("!L")[0] |
| 1168 | obj.packet_in_count = reader.read("!Q")[0] |
| 1169 | obj.byte_in_count = reader.read("!Q")[0] |
| 1170 | obj.duration_sec = reader.read("!L")[0] |
| 1171 | obj.duration_nsec = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1172 | obj.band_stats = loxi.generic_util.unpack_list(reader, common.meter_band_stats.unpack) |
| 1173 | return obj |
| 1174 | |
| 1175 | def __eq__(self, other): |
| 1176 | if type(self) != type(other): return False |
| 1177 | if self.meter_id != other.meter_id: return False |
| 1178 | if self.flow_count != other.flow_count: return False |
| 1179 | if self.packet_in_count != other.packet_in_count: return False |
| 1180 | if self.byte_in_count != other.byte_in_count: return False |
| 1181 | if self.duration_sec != other.duration_sec: return False |
| 1182 | if self.duration_nsec != other.duration_nsec: return False |
| 1183 | if self.band_stats != other.band_stats: return False |
| 1184 | return True |
| 1185 | |
| 1186 | def __ne__(self, other): |
| 1187 | return not self.__eq__(other) |
| 1188 | |
| 1189 | def show(self): |
| 1190 | import loxi.pp |
| 1191 | return loxi.pp.pp(self) |
| 1192 | |
| 1193 | def pretty_print(self, q): |
| 1194 | q.text("meter_stats {") |
| 1195 | with q.group(): |
| 1196 | with q.indent(2): |
| 1197 | q.breakable() |
| 1198 | q.text("meter_id = "); |
| 1199 | q.text("%#x" % self.meter_id) |
| 1200 | q.text(","); q.breakable() |
| 1201 | q.text("flow_count = "); |
| 1202 | q.text("%#x" % self.flow_count) |
| 1203 | q.text(","); q.breakable() |
| 1204 | q.text("packet_in_count = "); |
| 1205 | q.text("%#x" % self.packet_in_count) |
| 1206 | q.text(","); q.breakable() |
| 1207 | q.text("byte_in_count = "); |
| 1208 | q.text("%#x" % self.byte_in_count) |
| 1209 | q.text(","); q.breakable() |
| 1210 | q.text("duration_sec = "); |
| 1211 | q.text("%#x" % self.duration_sec) |
| 1212 | q.text(","); q.breakable() |
| 1213 | q.text("duration_nsec = "); |
| 1214 | q.text("%#x" % self.duration_nsec) |
| 1215 | q.text(","); q.breakable() |
| 1216 | q.text("band_stats = "); |
| 1217 | q.pp(self.band_stats) |
| 1218 | q.breakable() |
| 1219 | q.text('}') |
| 1220 | |
| 1221 | class packet_queue(object): |
| 1222 | |
| 1223 | def __init__(self, queue_id=None, port=None, properties=None): |
| 1224 | if queue_id != None: |
| 1225 | self.queue_id = queue_id |
| 1226 | else: |
| 1227 | self.queue_id = 0 |
| 1228 | if port != None: |
| 1229 | self.port = port |
| 1230 | else: |
| 1231 | self.port = 0 |
| 1232 | if properties != None: |
| 1233 | self.properties = properties |
| 1234 | else: |
| 1235 | self.properties = [] |
| 1236 | return |
| 1237 | |
| 1238 | def pack(self): |
| 1239 | packed = [] |
| 1240 | packed.append(struct.pack("!L", self.queue_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1241 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1242 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 2 |
| 1243 | packed.append('\x00' * 6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1244 | packed.append(util.pack_list(self.properties)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1245 | length = sum([len(x) for x in packed]) |
| 1246 | packed[2] = struct.pack("!H", length) |
| 1247 | return ''.join(packed) |
| 1248 | |
| 1249 | @staticmethod |
| 1250 | def unpack(buf): |
| 1251 | obj = packet_queue() |
| 1252 | if type(buf) == loxi.generic_util.OFReader: |
| 1253 | reader = buf |
| 1254 | else: |
| 1255 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1256 | obj.queue_id = reader.read("!L")[0] |
| 1257 | obj.port = util.unpack_port_no(reader) |
| 1258 | _len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1259 | reader.skip(6) |
| 1260 | obj.properties = common.unpack_list_queue_prop(reader) |
| 1261 | return obj |
| 1262 | |
| 1263 | def __eq__(self, other): |
| 1264 | if type(self) != type(other): return False |
| 1265 | if self.queue_id != other.queue_id: return False |
| 1266 | if self.port != other.port: return False |
| 1267 | if self.properties != other.properties: return False |
| 1268 | return True |
| 1269 | |
| 1270 | def __ne__(self, other): |
| 1271 | return not self.__eq__(other) |
| 1272 | |
| 1273 | def show(self): |
| 1274 | import loxi.pp |
| 1275 | return loxi.pp.pp(self) |
| 1276 | |
| 1277 | def pretty_print(self, q): |
| 1278 | q.text("packet_queue {") |
| 1279 | with q.group(): |
| 1280 | with q.indent(2): |
| 1281 | q.breakable() |
| 1282 | q.text("queue_id = "); |
| 1283 | q.text("%#x" % self.queue_id) |
| 1284 | q.text(","); q.breakable() |
| 1285 | q.text("port = "); |
| 1286 | q.text(util.pretty_port(self.port)) |
| 1287 | q.text(","); q.breakable() |
| 1288 | q.text("properties = "); |
| 1289 | q.pp(self.properties) |
| 1290 | q.breakable() |
| 1291 | q.text('}') |
| 1292 | |
| 1293 | class port_desc(object): |
| 1294 | |
| 1295 | 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): |
| 1296 | if port_no != None: |
| 1297 | self.port_no = port_no |
| 1298 | else: |
| 1299 | self.port_no = 0 |
| 1300 | if hw_addr != None: |
| 1301 | self.hw_addr = hw_addr |
| 1302 | else: |
| 1303 | self.hw_addr = [0,0,0,0,0,0] |
| 1304 | if name != None: |
| 1305 | self.name = name |
| 1306 | else: |
| 1307 | self.name = "" |
| 1308 | if config != None: |
| 1309 | self.config = config |
| 1310 | else: |
| 1311 | self.config = 0 |
| 1312 | if state != None: |
| 1313 | self.state = state |
| 1314 | else: |
| 1315 | self.state = 0 |
| 1316 | if curr != None: |
| 1317 | self.curr = curr |
| 1318 | else: |
| 1319 | self.curr = 0 |
| 1320 | if advertised != None: |
| 1321 | self.advertised = advertised |
| 1322 | else: |
| 1323 | self.advertised = 0 |
| 1324 | if supported != None: |
| 1325 | self.supported = supported |
| 1326 | else: |
| 1327 | self.supported = 0 |
| 1328 | if peer != None: |
| 1329 | self.peer = peer |
| 1330 | else: |
| 1331 | self.peer = 0 |
| 1332 | if curr_speed != None: |
| 1333 | self.curr_speed = curr_speed |
| 1334 | else: |
| 1335 | self.curr_speed = 0 |
| 1336 | if max_speed != None: |
| 1337 | self.max_speed = max_speed |
| 1338 | else: |
| 1339 | self.max_speed = 0 |
| 1340 | return |
| 1341 | |
| 1342 | def pack(self): |
| 1343 | packed = [] |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1344 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1345 | packed.append('\x00' * 4) |
| 1346 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 1347 | packed.append('\x00' * 2) |
| 1348 | packed.append(struct.pack("!16s", self.name)) |
| 1349 | packed.append(struct.pack("!L", self.config)) |
| 1350 | packed.append(struct.pack("!L", self.state)) |
| 1351 | packed.append(struct.pack("!L", self.curr)) |
| 1352 | packed.append(struct.pack("!L", self.advertised)) |
| 1353 | packed.append(struct.pack("!L", self.supported)) |
| 1354 | packed.append(struct.pack("!L", self.peer)) |
| 1355 | packed.append(struct.pack("!L", self.curr_speed)) |
| 1356 | packed.append(struct.pack("!L", self.max_speed)) |
| 1357 | return ''.join(packed) |
| 1358 | |
| 1359 | @staticmethod |
| 1360 | def unpack(buf): |
| 1361 | obj = port_desc() |
| 1362 | if type(buf) == loxi.generic_util.OFReader: |
| 1363 | reader = buf |
| 1364 | else: |
| 1365 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1366 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1367 | reader.skip(4) |
| 1368 | obj.hw_addr = list(reader.read('!6B')) |
| 1369 | reader.skip(2) |
| 1370 | obj.name = reader.read("!16s")[0].rstrip("\x00") |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1371 | obj.config = reader.read("!L")[0] |
| 1372 | obj.state = reader.read("!L")[0] |
| 1373 | obj.curr = reader.read("!L")[0] |
| 1374 | obj.advertised = reader.read("!L")[0] |
| 1375 | obj.supported = reader.read("!L")[0] |
| 1376 | obj.peer = reader.read("!L")[0] |
| 1377 | obj.curr_speed = reader.read("!L")[0] |
| 1378 | obj.max_speed = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1379 | return obj |
| 1380 | |
| 1381 | def __eq__(self, other): |
| 1382 | if type(self) != type(other): return False |
| 1383 | if self.port_no != other.port_no: return False |
| 1384 | if self.hw_addr != other.hw_addr: return False |
| 1385 | if self.name != other.name: return False |
| 1386 | if self.config != other.config: return False |
| 1387 | if self.state != other.state: return False |
| 1388 | if self.curr != other.curr: return False |
| 1389 | if self.advertised != other.advertised: return False |
| 1390 | if self.supported != other.supported: return False |
| 1391 | if self.peer != other.peer: return False |
| 1392 | if self.curr_speed != other.curr_speed: return False |
| 1393 | if self.max_speed != other.max_speed: return False |
| 1394 | return True |
| 1395 | |
| 1396 | def __ne__(self, other): |
| 1397 | return not self.__eq__(other) |
| 1398 | |
| 1399 | def show(self): |
| 1400 | import loxi.pp |
| 1401 | return loxi.pp.pp(self) |
| 1402 | |
| 1403 | def pretty_print(self, q): |
| 1404 | q.text("port_desc {") |
| 1405 | with q.group(): |
| 1406 | with q.indent(2): |
| 1407 | q.breakable() |
| 1408 | q.text("port_no = "); |
| 1409 | q.text(util.pretty_port(self.port_no)) |
| 1410 | q.text(","); q.breakable() |
| 1411 | q.text("hw_addr = "); |
| 1412 | q.text(util.pretty_mac(self.hw_addr)) |
| 1413 | q.text(","); q.breakable() |
| 1414 | q.text("name = "); |
| 1415 | q.pp(self.name) |
| 1416 | q.text(","); q.breakable() |
| 1417 | q.text("config = "); |
| 1418 | q.text("%#x" % self.config) |
| 1419 | q.text(","); q.breakable() |
| 1420 | q.text("state = "); |
| 1421 | q.text("%#x" % self.state) |
| 1422 | q.text(","); q.breakable() |
| 1423 | q.text("curr = "); |
| 1424 | q.text("%#x" % self.curr) |
| 1425 | q.text(","); q.breakable() |
| 1426 | q.text("advertised = "); |
| 1427 | q.text("%#x" % self.advertised) |
| 1428 | q.text(","); q.breakable() |
| 1429 | q.text("supported = "); |
| 1430 | q.text("%#x" % self.supported) |
| 1431 | q.text(","); q.breakable() |
| 1432 | q.text("peer = "); |
| 1433 | q.text("%#x" % self.peer) |
| 1434 | q.text(","); q.breakable() |
| 1435 | q.text("curr_speed = "); |
| 1436 | q.text("%#x" % self.curr_speed) |
| 1437 | q.text(","); q.breakable() |
| 1438 | q.text("max_speed = "); |
| 1439 | q.text("%#x" % self.max_speed) |
| 1440 | q.breakable() |
| 1441 | q.text('}') |
| 1442 | |
| 1443 | class port_stats_entry(object): |
| 1444 | |
| 1445 | 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): |
| 1446 | if port_no != None: |
| 1447 | self.port_no = port_no |
| 1448 | else: |
| 1449 | self.port_no = 0 |
| 1450 | if rx_packets != None: |
| 1451 | self.rx_packets = rx_packets |
| 1452 | else: |
| 1453 | self.rx_packets = 0 |
| 1454 | if tx_packets != None: |
| 1455 | self.tx_packets = tx_packets |
| 1456 | else: |
| 1457 | self.tx_packets = 0 |
| 1458 | if rx_bytes != None: |
| 1459 | self.rx_bytes = rx_bytes |
| 1460 | else: |
| 1461 | self.rx_bytes = 0 |
| 1462 | if tx_bytes != None: |
| 1463 | self.tx_bytes = tx_bytes |
| 1464 | else: |
| 1465 | self.tx_bytes = 0 |
| 1466 | if rx_dropped != None: |
| 1467 | self.rx_dropped = rx_dropped |
| 1468 | else: |
| 1469 | self.rx_dropped = 0 |
| 1470 | if tx_dropped != None: |
| 1471 | self.tx_dropped = tx_dropped |
| 1472 | else: |
| 1473 | self.tx_dropped = 0 |
| 1474 | if rx_errors != None: |
| 1475 | self.rx_errors = rx_errors |
| 1476 | else: |
| 1477 | self.rx_errors = 0 |
| 1478 | if tx_errors != None: |
| 1479 | self.tx_errors = tx_errors |
| 1480 | else: |
| 1481 | self.tx_errors = 0 |
| 1482 | if rx_frame_err != None: |
| 1483 | self.rx_frame_err = rx_frame_err |
| 1484 | else: |
| 1485 | self.rx_frame_err = 0 |
| 1486 | if rx_over_err != None: |
| 1487 | self.rx_over_err = rx_over_err |
| 1488 | else: |
| 1489 | self.rx_over_err = 0 |
| 1490 | if rx_crc_err != None: |
| 1491 | self.rx_crc_err = rx_crc_err |
| 1492 | else: |
| 1493 | self.rx_crc_err = 0 |
| 1494 | if collisions != None: |
| 1495 | self.collisions = collisions |
| 1496 | else: |
| 1497 | self.collisions = 0 |
| 1498 | if duration_sec != None: |
| 1499 | self.duration_sec = duration_sec |
| 1500 | else: |
| 1501 | self.duration_sec = 0 |
| 1502 | if duration_nsec != None: |
| 1503 | self.duration_nsec = duration_nsec |
| 1504 | else: |
| 1505 | self.duration_nsec = 0 |
| 1506 | return |
| 1507 | |
| 1508 | def pack(self): |
| 1509 | packed = [] |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1510 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1511 | packed.append('\x00' * 4) |
| 1512 | packed.append(struct.pack("!Q", self.rx_packets)) |
| 1513 | packed.append(struct.pack("!Q", self.tx_packets)) |
| 1514 | packed.append(struct.pack("!Q", self.rx_bytes)) |
| 1515 | packed.append(struct.pack("!Q", self.tx_bytes)) |
| 1516 | packed.append(struct.pack("!Q", self.rx_dropped)) |
| 1517 | packed.append(struct.pack("!Q", self.tx_dropped)) |
| 1518 | packed.append(struct.pack("!Q", self.rx_errors)) |
| 1519 | packed.append(struct.pack("!Q", self.tx_errors)) |
| 1520 | packed.append(struct.pack("!Q", self.rx_frame_err)) |
| 1521 | packed.append(struct.pack("!Q", self.rx_over_err)) |
| 1522 | packed.append(struct.pack("!Q", self.rx_crc_err)) |
| 1523 | packed.append(struct.pack("!Q", self.collisions)) |
| 1524 | packed.append(struct.pack("!L", self.duration_sec)) |
| 1525 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 1526 | return ''.join(packed) |
| 1527 | |
| 1528 | @staticmethod |
| 1529 | def unpack(buf): |
| 1530 | obj = port_stats_entry() |
| 1531 | if type(buf) == loxi.generic_util.OFReader: |
| 1532 | reader = buf |
| 1533 | else: |
| 1534 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1535 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1536 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1537 | obj.rx_packets = reader.read("!Q")[0] |
| 1538 | obj.tx_packets = reader.read("!Q")[0] |
| 1539 | obj.rx_bytes = reader.read("!Q")[0] |
| 1540 | obj.tx_bytes = reader.read("!Q")[0] |
| 1541 | obj.rx_dropped = reader.read("!Q")[0] |
| 1542 | obj.tx_dropped = reader.read("!Q")[0] |
| 1543 | obj.rx_errors = reader.read("!Q")[0] |
| 1544 | obj.tx_errors = reader.read("!Q")[0] |
| 1545 | obj.rx_frame_err = reader.read("!Q")[0] |
| 1546 | obj.rx_over_err = reader.read("!Q")[0] |
| 1547 | obj.rx_crc_err = reader.read("!Q")[0] |
| 1548 | obj.collisions = reader.read("!Q")[0] |
| 1549 | obj.duration_sec = reader.read("!L")[0] |
| 1550 | obj.duration_nsec = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1551 | return obj |
| 1552 | |
| 1553 | def __eq__(self, other): |
| 1554 | if type(self) != type(other): return False |
| 1555 | if self.port_no != other.port_no: return False |
| 1556 | if self.rx_packets != other.rx_packets: return False |
| 1557 | if self.tx_packets != other.tx_packets: return False |
| 1558 | if self.rx_bytes != other.rx_bytes: return False |
| 1559 | if self.tx_bytes != other.tx_bytes: return False |
| 1560 | if self.rx_dropped != other.rx_dropped: return False |
| 1561 | if self.tx_dropped != other.tx_dropped: return False |
| 1562 | if self.rx_errors != other.rx_errors: return False |
| 1563 | if self.tx_errors != other.tx_errors: return False |
| 1564 | if self.rx_frame_err != other.rx_frame_err: return False |
| 1565 | if self.rx_over_err != other.rx_over_err: return False |
| 1566 | if self.rx_crc_err != other.rx_crc_err: return False |
| 1567 | if self.collisions != other.collisions: return False |
| 1568 | if self.duration_sec != other.duration_sec: return False |
| 1569 | if self.duration_nsec != other.duration_nsec: return False |
| 1570 | return True |
| 1571 | |
| 1572 | def __ne__(self, other): |
| 1573 | return not self.__eq__(other) |
| 1574 | |
| 1575 | def show(self): |
| 1576 | import loxi.pp |
| 1577 | return loxi.pp.pp(self) |
| 1578 | |
| 1579 | def pretty_print(self, q): |
| 1580 | q.text("port_stats_entry {") |
| 1581 | with q.group(): |
| 1582 | with q.indent(2): |
| 1583 | q.breakable() |
| 1584 | q.text("port_no = "); |
| 1585 | q.text(util.pretty_port(self.port_no)) |
| 1586 | q.text(","); q.breakable() |
| 1587 | q.text("rx_packets = "); |
| 1588 | q.text("%#x" % self.rx_packets) |
| 1589 | q.text(","); q.breakable() |
| 1590 | q.text("tx_packets = "); |
| 1591 | q.text("%#x" % self.tx_packets) |
| 1592 | q.text(","); q.breakable() |
| 1593 | q.text("rx_bytes = "); |
| 1594 | q.text("%#x" % self.rx_bytes) |
| 1595 | q.text(","); q.breakable() |
| 1596 | q.text("tx_bytes = "); |
| 1597 | q.text("%#x" % self.tx_bytes) |
| 1598 | q.text(","); q.breakable() |
| 1599 | q.text("rx_dropped = "); |
| 1600 | q.text("%#x" % self.rx_dropped) |
| 1601 | q.text(","); q.breakable() |
| 1602 | q.text("tx_dropped = "); |
| 1603 | q.text("%#x" % self.tx_dropped) |
| 1604 | q.text(","); q.breakable() |
| 1605 | q.text("rx_errors = "); |
| 1606 | q.text("%#x" % self.rx_errors) |
| 1607 | q.text(","); q.breakable() |
| 1608 | q.text("tx_errors = "); |
| 1609 | q.text("%#x" % self.tx_errors) |
| 1610 | q.text(","); q.breakable() |
| 1611 | q.text("rx_frame_err = "); |
| 1612 | q.text("%#x" % self.rx_frame_err) |
| 1613 | q.text(","); q.breakable() |
| 1614 | q.text("rx_over_err = "); |
| 1615 | q.text("%#x" % self.rx_over_err) |
| 1616 | q.text(","); q.breakable() |
| 1617 | q.text("rx_crc_err = "); |
| 1618 | q.text("%#x" % self.rx_crc_err) |
| 1619 | q.text(","); q.breakable() |
| 1620 | q.text("collisions = "); |
| 1621 | q.text("%#x" % self.collisions) |
| 1622 | q.text(","); q.breakable() |
| 1623 | q.text("duration_sec = "); |
| 1624 | q.text("%#x" % self.duration_sec) |
| 1625 | q.text(","); q.breakable() |
| 1626 | q.text("duration_nsec = "); |
| 1627 | q.text("%#x" % self.duration_nsec) |
| 1628 | q.breakable() |
| 1629 | q.text('}') |
| 1630 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1631 | class queue_prop_max_rate(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1632 | type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1633 | |
| 1634 | def __init__(self, rate=None): |
| 1635 | if rate != None: |
| 1636 | self.rate = rate |
| 1637 | else: |
| 1638 | self.rate = 0 |
| 1639 | return |
| 1640 | |
| 1641 | def pack(self): |
| 1642 | packed = [] |
| 1643 | packed.append(struct.pack("!H", self.type)) |
| 1644 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1645 | packed.append('\x00' * 4) |
| 1646 | packed.append(struct.pack("!H", self.rate)) |
| 1647 | packed.append('\x00' * 6) |
| 1648 | length = sum([len(x) for x in packed]) |
| 1649 | packed[1] = struct.pack("!H", length) |
| 1650 | return ''.join(packed) |
| 1651 | |
| 1652 | @staticmethod |
| 1653 | def unpack(buf): |
| 1654 | obj = queue_prop_max_rate() |
| 1655 | if type(buf) == loxi.generic_util.OFReader: |
| 1656 | reader = buf |
| 1657 | else: |
| 1658 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1659 | _type = reader.read("!H")[0] |
| 1660 | assert(_type == 2) |
| 1661 | _len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1662 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1663 | obj.rate = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1664 | reader.skip(6) |
| 1665 | return obj |
| 1666 | |
| 1667 | def __eq__(self, other): |
| 1668 | if type(self) != type(other): return False |
| 1669 | if self.rate != other.rate: return False |
| 1670 | return True |
| 1671 | |
| 1672 | def __ne__(self, other): |
| 1673 | return not self.__eq__(other) |
| 1674 | |
| 1675 | def show(self): |
| 1676 | import loxi.pp |
| 1677 | return loxi.pp.pp(self) |
| 1678 | |
| 1679 | def pretty_print(self, q): |
| 1680 | q.text("queue_prop_max_rate {") |
| 1681 | with q.group(): |
| 1682 | with q.indent(2): |
| 1683 | q.breakable() |
| 1684 | q.text("rate = "); |
| 1685 | q.text("%#x" % self.rate) |
| 1686 | q.breakable() |
| 1687 | q.text('}') |
| 1688 | |
| 1689 | class queue_prop_min_rate(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1690 | type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1691 | |
| 1692 | def __init__(self, rate=None): |
| 1693 | if rate != None: |
| 1694 | self.rate = rate |
| 1695 | else: |
| 1696 | self.rate = 0 |
| 1697 | return |
| 1698 | |
| 1699 | def pack(self): |
| 1700 | packed = [] |
| 1701 | packed.append(struct.pack("!H", self.type)) |
| 1702 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1703 | packed.append('\x00' * 4) |
| 1704 | packed.append(struct.pack("!H", self.rate)) |
| 1705 | packed.append('\x00' * 6) |
| 1706 | length = sum([len(x) for x in packed]) |
| 1707 | packed[1] = struct.pack("!H", length) |
| 1708 | return ''.join(packed) |
| 1709 | |
| 1710 | @staticmethod |
| 1711 | def unpack(buf): |
| 1712 | obj = queue_prop_min_rate() |
| 1713 | if type(buf) == loxi.generic_util.OFReader: |
| 1714 | reader = buf |
| 1715 | else: |
| 1716 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1717 | _type = reader.read("!H")[0] |
| 1718 | assert(_type == 1) |
| 1719 | _len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1720 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1721 | obj.rate = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1722 | reader.skip(6) |
| 1723 | return obj |
| 1724 | |
| 1725 | def __eq__(self, other): |
| 1726 | if type(self) != type(other): return False |
| 1727 | if self.rate != other.rate: return False |
| 1728 | return True |
| 1729 | |
| 1730 | def __ne__(self, other): |
| 1731 | return not self.__eq__(other) |
| 1732 | |
| 1733 | def show(self): |
| 1734 | import loxi.pp |
| 1735 | return loxi.pp.pp(self) |
| 1736 | |
| 1737 | def pretty_print(self, q): |
| 1738 | q.text("queue_prop_min_rate {") |
| 1739 | with q.group(): |
| 1740 | with q.indent(2): |
| 1741 | q.breakable() |
| 1742 | q.text("rate = "); |
| 1743 | q.text("%#x" % self.rate) |
| 1744 | q.breakable() |
| 1745 | q.text('}') |
| 1746 | |
| 1747 | class queue_stats_entry(object): |
| 1748 | |
| 1749 | def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None, duration_sec=None, duration_nsec=None): |
| 1750 | if port_no != None: |
| 1751 | self.port_no = port_no |
| 1752 | else: |
| 1753 | self.port_no = 0 |
| 1754 | if queue_id != None: |
| 1755 | self.queue_id = queue_id |
| 1756 | else: |
| 1757 | self.queue_id = 0 |
| 1758 | if tx_bytes != None: |
| 1759 | self.tx_bytes = tx_bytes |
| 1760 | else: |
| 1761 | self.tx_bytes = 0 |
| 1762 | if tx_packets != None: |
| 1763 | self.tx_packets = tx_packets |
| 1764 | else: |
| 1765 | self.tx_packets = 0 |
| 1766 | if tx_errors != None: |
| 1767 | self.tx_errors = tx_errors |
| 1768 | else: |
| 1769 | self.tx_errors = 0 |
| 1770 | if duration_sec != None: |
| 1771 | self.duration_sec = duration_sec |
| 1772 | else: |
| 1773 | self.duration_sec = 0 |
| 1774 | if duration_nsec != None: |
| 1775 | self.duration_nsec = duration_nsec |
| 1776 | else: |
| 1777 | self.duration_nsec = 0 |
| 1778 | return |
| 1779 | |
| 1780 | def pack(self): |
| 1781 | packed = [] |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1782 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1783 | packed.append(struct.pack("!L", self.queue_id)) |
| 1784 | packed.append(struct.pack("!Q", self.tx_bytes)) |
| 1785 | packed.append(struct.pack("!Q", self.tx_packets)) |
| 1786 | packed.append(struct.pack("!Q", self.tx_errors)) |
| 1787 | packed.append(struct.pack("!L", self.duration_sec)) |
| 1788 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 1789 | return ''.join(packed) |
| 1790 | |
| 1791 | @staticmethod |
| 1792 | def unpack(buf): |
| 1793 | obj = queue_stats_entry() |
| 1794 | if type(buf) == loxi.generic_util.OFReader: |
| 1795 | reader = buf |
| 1796 | else: |
| 1797 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1798 | obj.port_no = util.unpack_port_no(reader) |
| 1799 | obj.queue_id = reader.read("!L")[0] |
| 1800 | obj.tx_bytes = reader.read("!Q")[0] |
| 1801 | obj.tx_packets = reader.read("!Q")[0] |
| 1802 | obj.tx_errors = reader.read("!Q")[0] |
| 1803 | obj.duration_sec = reader.read("!L")[0] |
| 1804 | obj.duration_nsec = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1805 | return obj |
| 1806 | |
| 1807 | def __eq__(self, other): |
| 1808 | if type(self) != type(other): return False |
| 1809 | if self.port_no != other.port_no: return False |
| 1810 | if self.queue_id != other.queue_id: return False |
| 1811 | if self.tx_bytes != other.tx_bytes: return False |
| 1812 | if self.tx_packets != other.tx_packets: return False |
| 1813 | if self.tx_errors != other.tx_errors: return False |
| 1814 | if self.duration_sec != other.duration_sec: return False |
| 1815 | if self.duration_nsec != other.duration_nsec: return False |
| 1816 | return True |
| 1817 | |
| 1818 | def __ne__(self, other): |
| 1819 | return not self.__eq__(other) |
| 1820 | |
| 1821 | def show(self): |
| 1822 | import loxi.pp |
| 1823 | return loxi.pp.pp(self) |
| 1824 | |
| 1825 | def pretty_print(self, q): |
| 1826 | q.text("queue_stats_entry {") |
| 1827 | with q.group(): |
| 1828 | with q.indent(2): |
| 1829 | q.breakable() |
| 1830 | q.text("port_no = "); |
| 1831 | q.text(util.pretty_port(self.port_no)) |
| 1832 | q.text(","); q.breakable() |
| 1833 | q.text("queue_id = "); |
| 1834 | q.text("%#x" % self.queue_id) |
| 1835 | q.text(","); q.breakable() |
| 1836 | q.text("tx_bytes = "); |
| 1837 | q.text("%#x" % self.tx_bytes) |
| 1838 | q.text(","); q.breakable() |
| 1839 | q.text("tx_packets = "); |
| 1840 | q.text("%#x" % self.tx_packets) |
| 1841 | q.text(","); q.breakable() |
| 1842 | q.text("tx_errors = "); |
| 1843 | q.text("%#x" % self.tx_errors) |
| 1844 | q.text(","); q.breakable() |
| 1845 | q.text("duration_sec = "); |
| 1846 | q.text("%#x" % self.duration_sec) |
| 1847 | q.text(","); q.breakable() |
| 1848 | q.text("duration_nsec = "); |
| 1849 | q.text("%#x" % self.duration_nsec) |
| 1850 | q.breakable() |
| 1851 | q.text('}') |
| 1852 | |
| 1853 | class table_feature_prop_apply_actions(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1854 | type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1855 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1856 | def __init__(self, action_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1857 | if action_ids != None: |
| 1858 | self.action_ids = action_ids |
| 1859 | else: |
| 1860 | self.action_ids = [] |
| 1861 | return |
| 1862 | |
| 1863 | def pack(self): |
| 1864 | packed = [] |
| 1865 | packed.append(struct.pack("!H", self.type)) |
| 1866 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1867 | packed.append(util.pack_list(self.action_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1868 | length = sum([len(x) for x in packed]) |
| 1869 | packed[1] = struct.pack("!H", length) |
| 1870 | return ''.join(packed) |
| 1871 | |
| 1872 | @staticmethod |
| 1873 | def unpack(buf): |
| 1874 | obj = table_feature_prop_apply_actions() |
| 1875 | if type(buf) == loxi.generic_util.OFReader: |
| 1876 | reader = buf |
| 1877 | else: |
| 1878 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1879 | _type = reader.read("!H")[0] |
| 1880 | assert(_type == 6) |
| 1881 | _length = reader.read("!H")[0] |
| 1882 | obj.action_ids = loxi.unimplemented('unpack list(of_action_id_t)') |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1883 | return obj |
| 1884 | |
| 1885 | def __eq__(self, other): |
| 1886 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1887 | if self.action_ids != other.action_ids: return False |
| 1888 | return True |
| 1889 | |
| 1890 | def __ne__(self, other): |
| 1891 | return not self.__eq__(other) |
| 1892 | |
| 1893 | def show(self): |
| 1894 | import loxi.pp |
| 1895 | return loxi.pp.pp(self) |
| 1896 | |
| 1897 | def pretty_print(self, q): |
| 1898 | q.text("table_feature_prop_apply_actions {") |
| 1899 | with q.group(): |
| 1900 | with q.indent(2): |
| 1901 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1902 | q.text("action_ids = "); |
| 1903 | q.pp(self.action_ids) |
| 1904 | q.breakable() |
| 1905 | q.text('}') |
| 1906 | |
| 1907 | class table_feature_prop_apply_actions_miss(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1908 | type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1909 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1910 | def __init__(self, action_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1911 | if action_ids != None: |
| 1912 | self.action_ids = action_ids |
| 1913 | else: |
| 1914 | self.action_ids = [] |
| 1915 | return |
| 1916 | |
| 1917 | def pack(self): |
| 1918 | packed = [] |
| 1919 | packed.append(struct.pack("!H", self.type)) |
| 1920 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1921 | packed.append(util.pack_list(self.action_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1922 | length = sum([len(x) for x in packed]) |
| 1923 | packed[1] = struct.pack("!H", length) |
| 1924 | return ''.join(packed) |
| 1925 | |
| 1926 | @staticmethod |
| 1927 | def unpack(buf): |
| 1928 | obj = table_feature_prop_apply_actions_miss() |
| 1929 | if type(buf) == loxi.generic_util.OFReader: |
| 1930 | reader = buf |
| 1931 | else: |
| 1932 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1933 | _type = reader.read("!H")[0] |
| 1934 | assert(_type == 7) |
| 1935 | _length = reader.read("!H")[0] |
| 1936 | obj.action_ids = loxi.unimplemented('unpack list(of_action_id_t)') |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1937 | return obj |
| 1938 | |
| 1939 | def __eq__(self, other): |
| 1940 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1941 | if self.action_ids != other.action_ids: return False |
| 1942 | return True |
| 1943 | |
| 1944 | def __ne__(self, other): |
| 1945 | return not self.__eq__(other) |
| 1946 | |
| 1947 | def show(self): |
| 1948 | import loxi.pp |
| 1949 | return loxi.pp.pp(self) |
| 1950 | |
| 1951 | def pretty_print(self, q): |
| 1952 | q.text("table_feature_prop_apply_actions_miss {") |
| 1953 | with q.group(): |
| 1954 | with q.indent(2): |
| 1955 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1956 | q.text("action_ids = "); |
| 1957 | q.pp(self.action_ids) |
| 1958 | q.breakable() |
| 1959 | q.text('}') |
| 1960 | |
| 1961 | class table_feature_prop_apply_setfield(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1962 | type = 14 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1963 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1964 | def __init__(self, oxm_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1965 | if oxm_ids != None: |
| 1966 | self.oxm_ids = oxm_ids |
| 1967 | else: |
| 1968 | self.oxm_ids = [] |
| 1969 | return |
| 1970 | |
| 1971 | def pack(self): |
| 1972 | packed = [] |
| 1973 | packed.append(struct.pack("!H", self.type)) |
| 1974 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1975 | packed.append(util.pack_list(self.oxm_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1976 | length = sum([len(x) for x in packed]) |
| 1977 | packed[1] = struct.pack("!H", length) |
| 1978 | return ''.join(packed) |
| 1979 | |
| 1980 | @staticmethod |
| 1981 | def unpack(buf): |
| 1982 | obj = table_feature_prop_apply_setfield() |
| 1983 | if type(buf) == loxi.generic_util.OFReader: |
| 1984 | reader = buf |
| 1985 | else: |
| 1986 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1987 | _type = reader.read("!H")[0] |
| 1988 | assert(_type == 14) |
| 1989 | _length = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1990 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 1991 | return obj |
| 1992 | |
| 1993 | def __eq__(self, other): |
| 1994 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1995 | if self.oxm_ids != other.oxm_ids: return False |
| 1996 | return True |
| 1997 | |
| 1998 | def __ne__(self, other): |
| 1999 | return not self.__eq__(other) |
| 2000 | |
| 2001 | def show(self): |
| 2002 | import loxi.pp |
| 2003 | return loxi.pp.pp(self) |
| 2004 | |
| 2005 | def pretty_print(self, q): |
| 2006 | q.text("table_feature_prop_apply_setfield {") |
| 2007 | with q.group(): |
| 2008 | with q.indent(2): |
| 2009 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2010 | q.text("oxm_ids = "); |
| 2011 | q.pp(self.oxm_ids) |
| 2012 | q.breakable() |
| 2013 | q.text('}') |
| 2014 | |
| 2015 | class table_feature_prop_apply_setfield_miss(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2016 | type = 15 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2017 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2018 | def __init__(self, oxm_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2019 | if oxm_ids != None: |
| 2020 | self.oxm_ids = oxm_ids |
| 2021 | else: |
| 2022 | self.oxm_ids = [] |
| 2023 | return |
| 2024 | |
| 2025 | def pack(self): |
| 2026 | packed = [] |
| 2027 | packed.append(struct.pack("!H", self.type)) |
| 2028 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2029 | packed.append(util.pack_list(self.oxm_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2030 | length = sum([len(x) for x in packed]) |
| 2031 | packed[1] = struct.pack("!H", length) |
| 2032 | return ''.join(packed) |
| 2033 | |
| 2034 | @staticmethod |
| 2035 | def unpack(buf): |
| 2036 | obj = table_feature_prop_apply_setfield_miss() |
| 2037 | if type(buf) == loxi.generic_util.OFReader: |
| 2038 | reader = buf |
| 2039 | else: |
| 2040 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2041 | _type = reader.read("!H")[0] |
| 2042 | assert(_type == 15) |
| 2043 | _length = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2044 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 2045 | return obj |
| 2046 | |
| 2047 | def __eq__(self, other): |
| 2048 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2049 | if self.oxm_ids != other.oxm_ids: return False |
| 2050 | return True |
| 2051 | |
| 2052 | def __ne__(self, other): |
| 2053 | return not self.__eq__(other) |
| 2054 | |
| 2055 | def show(self): |
| 2056 | import loxi.pp |
| 2057 | return loxi.pp.pp(self) |
| 2058 | |
| 2059 | def pretty_print(self, q): |
| 2060 | q.text("table_feature_prop_apply_setfield_miss {") |
| 2061 | with q.group(): |
| 2062 | with q.indent(2): |
| 2063 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2064 | q.text("oxm_ids = "); |
| 2065 | q.pp(self.oxm_ids) |
| 2066 | q.breakable() |
| 2067 | q.text('}') |
| 2068 | |
| 2069 | class table_feature_prop_experimenter(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2070 | type = 65535 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2071 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2072 | def __init__(self, experimenter=None, subtype=None, experimenter_data=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2073 | if experimenter != None: |
| 2074 | self.experimenter = experimenter |
| 2075 | else: |
| 2076 | self.experimenter = 0 |
| 2077 | if subtype != None: |
| 2078 | self.subtype = subtype |
| 2079 | else: |
| 2080 | self.subtype = 0 |
| 2081 | if experimenter_data != None: |
| 2082 | self.experimenter_data = experimenter_data |
| 2083 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2084 | self.experimenter_data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2085 | return |
| 2086 | |
| 2087 | def pack(self): |
| 2088 | packed = [] |
| 2089 | packed.append(struct.pack("!H", self.type)) |
| 2090 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 2091 | packed.append(struct.pack("!L", self.experimenter)) |
| 2092 | packed.append(struct.pack("!L", self.subtype)) |
| 2093 | packed.append(self.experimenter_data) |
| 2094 | length = sum([len(x) for x in packed]) |
| 2095 | packed[1] = struct.pack("!H", length) |
| 2096 | return ''.join(packed) |
| 2097 | |
| 2098 | @staticmethod |
| 2099 | def unpack(buf): |
| 2100 | obj = table_feature_prop_experimenter() |
| 2101 | if type(buf) == loxi.generic_util.OFReader: |
| 2102 | reader = buf |
| 2103 | else: |
| 2104 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2105 | _type = reader.read("!H")[0] |
| 2106 | assert(_type == 65535) |
| 2107 | _length = reader.read("!H")[0] |
| 2108 | obj.experimenter = reader.read("!L")[0] |
| 2109 | obj.subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2110 | obj.experimenter_data = str(reader.read_all()) |
| 2111 | return obj |
| 2112 | |
| 2113 | def __eq__(self, other): |
| 2114 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2115 | if self.experimenter != other.experimenter: return False |
| 2116 | if self.subtype != other.subtype: return False |
| 2117 | if self.experimenter_data != other.experimenter_data: return False |
| 2118 | return True |
| 2119 | |
| 2120 | def __ne__(self, other): |
| 2121 | return not self.__eq__(other) |
| 2122 | |
| 2123 | def show(self): |
| 2124 | import loxi.pp |
| 2125 | return loxi.pp.pp(self) |
| 2126 | |
| 2127 | def pretty_print(self, q): |
| 2128 | q.text("table_feature_prop_experimenter {") |
| 2129 | with q.group(): |
| 2130 | with q.indent(2): |
| 2131 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2132 | q.text("experimenter = "); |
| 2133 | q.text("%#x" % self.experimenter) |
| 2134 | q.text(","); q.breakable() |
| 2135 | q.text("subtype = "); |
| 2136 | q.text("%#x" % self.subtype) |
| 2137 | q.text(","); q.breakable() |
| 2138 | q.text("experimenter_data = "); |
| 2139 | q.pp(self.experimenter_data) |
| 2140 | q.breakable() |
| 2141 | q.text('}') |
| 2142 | |
| 2143 | class table_feature_prop_instructions(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2144 | type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2145 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2146 | def __init__(self, instruction_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2147 | if instruction_ids != None: |
| 2148 | self.instruction_ids = instruction_ids |
| 2149 | else: |
| 2150 | self.instruction_ids = [] |
| 2151 | return |
| 2152 | |
| 2153 | def pack(self): |
| 2154 | packed = [] |
| 2155 | packed.append(struct.pack("!H", self.type)) |
| 2156 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2157 | packed.append(util.pack_list(self.instruction_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2158 | length = sum([len(x) for x in packed]) |
| 2159 | packed[1] = struct.pack("!H", length) |
| 2160 | return ''.join(packed) |
| 2161 | |
| 2162 | @staticmethod |
| 2163 | def unpack(buf): |
| 2164 | obj = table_feature_prop_instructions() |
| 2165 | if type(buf) == loxi.generic_util.OFReader: |
| 2166 | reader = buf |
| 2167 | else: |
| 2168 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2169 | _type = reader.read("!H")[0] |
| 2170 | assert(_type == 0) |
| 2171 | _length = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2172 | obj.instruction_ids = instruction.unpack_list(reader) |
| 2173 | return obj |
| 2174 | |
| 2175 | def __eq__(self, other): |
| 2176 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2177 | if self.instruction_ids != other.instruction_ids: return False |
| 2178 | return True |
| 2179 | |
| 2180 | def __ne__(self, other): |
| 2181 | return not self.__eq__(other) |
| 2182 | |
| 2183 | def show(self): |
| 2184 | import loxi.pp |
| 2185 | return loxi.pp.pp(self) |
| 2186 | |
| 2187 | def pretty_print(self, q): |
| 2188 | q.text("table_feature_prop_instructions {") |
| 2189 | with q.group(): |
| 2190 | with q.indent(2): |
| 2191 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2192 | q.text("instruction_ids = "); |
| 2193 | q.pp(self.instruction_ids) |
| 2194 | q.breakable() |
| 2195 | q.text('}') |
| 2196 | |
| 2197 | class table_feature_prop_instructions_miss(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2198 | type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2199 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2200 | def __init__(self, instruction_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2201 | if instruction_ids != None: |
| 2202 | self.instruction_ids = instruction_ids |
| 2203 | else: |
| 2204 | self.instruction_ids = [] |
| 2205 | return |
| 2206 | |
| 2207 | def pack(self): |
| 2208 | packed = [] |
| 2209 | packed.append(struct.pack("!H", self.type)) |
| 2210 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2211 | packed.append(util.pack_list(self.instruction_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2212 | length = sum([len(x) for x in packed]) |
| 2213 | packed[1] = struct.pack("!H", length) |
| 2214 | return ''.join(packed) |
| 2215 | |
| 2216 | @staticmethod |
| 2217 | def unpack(buf): |
| 2218 | obj = table_feature_prop_instructions_miss() |
| 2219 | if type(buf) == loxi.generic_util.OFReader: |
| 2220 | reader = buf |
| 2221 | else: |
| 2222 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2223 | _type = reader.read("!H")[0] |
| 2224 | assert(_type == 1) |
| 2225 | _length = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2226 | obj.instruction_ids = instruction.unpack_list(reader) |
| 2227 | return obj |
| 2228 | |
| 2229 | def __eq__(self, other): |
| 2230 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2231 | if self.instruction_ids != other.instruction_ids: return False |
| 2232 | return True |
| 2233 | |
| 2234 | def __ne__(self, other): |
| 2235 | return not self.__eq__(other) |
| 2236 | |
| 2237 | def show(self): |
| 2238 | import loxi.pp |
| 2239 | return loxi.pp.pp(self) |
| 2240 | |
| 2241 | def pretty_print(self, q): |
| 2242 | q.text("table_feature_prop_instructions_miss {") |
| 2243 | with q.group(): |
| 2244 | with q.indent(2): |
| 2245 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2246 | q.text("instruction_ids = "); |
| 2247 | q.pp(self.instruction_ids) |
| 2248 | q.breakable() |
| 2249 | q.text('}') |
| 2250 | |
| 2251 | class table_feature_prop_match(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2252 | type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2253 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2254 | def __init__(self, oxm_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2255 | if oxm_ids != None: |
| 2256 | self.oxm_ids = oxm_ids |
| 2257 | else: |
| 2258 | self.oxm_ids = [] |
| 2259 | return |
| 2260 | |
| 2261 | def pack(self): |
| 2262 | packed = [] |
| 2263 | packed.append(struct.pack("!H", self.type)) |
| 2264 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2265 | packed.append(util.pack_list(self.oxm_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2266 | length = sum([len(x) for x in packed]) |
| 2267 | packed[1] = struct.pack("!H", length) |
| 2268 | return ''.join(packed) |
| 2269 | |
| 2270 | @staticmethod |
| 2271 | def unpack(buf): |
| 2272 | obj = table_feature_prop_match() |
| 2273 | if type(buf) == loxi.generic_util.OFReader: |
| 2274 | reader = buf |
| 2275 | else: |
| 2276 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2277 | _type = reader.read("!H")[0] |
| 2278 | assert(_type == 8) |
| 2279 | _length = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2280 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 2281 | return obj |
| 2282 | |
| 2283 | def __eq__(self, other): |
| 2284 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2285 | if self.oxm_ids != other.oxm_ids: return False |
| 2286 | return True |
| 2287 | |
| 2288 | def __ne__(self, other): |
| 2289 | return not self.__eq__(other) |
| 2290 | |
| 2291 | def show(self): |
| 2292 | import loxi.pp |
| 2293 | return loxi.pp.pp(self) |
| 2294 | |
| 2295 | def pretty_print(self, q): |
| 2296 | q.text("table_feature_prop_match {") |
| 2297 | with q.group(): |
| 2298 | with q.indent(2): |
| 2299 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2300 | q.text("oxm_ids = "); |
| 2301 | q.pp(self.oxm_ids) |
| 2302 | q.breakable() |
| 2303 | q.text('}') |
| 2304 | |
| 2305 | class table_feature_prop_next_tables(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2306 | type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2307 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2308 | def __init__(self, next_table_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2309 | if next_table_ids != None: |
| 2310 | self.next_table_ids = next_table_ids |
| 2311 | else: |
| 2312 | self.next_table_ids = [] |
| 2313 | return |
| 2314 | |
| 2315 | def pack(self): |
| 2316 | packed = [] |
| 2317 | packed.append(struct.pack("!H", self.type)) |
| 2318 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2319 | packed.append(util.pack_list(self.next_table_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2320 | length = sum([len(x) for x in packed]) |
| 2321 | packed[1] = struct.pack("!H", length) |
| 2322 | return ''.join(packed) |
| 2323 | |
| 2324 | @staticmethod |
| 2325 | def unpack(buf): |
| 2326 | obj = table_feature_prop_next_tables() |
| 2327 | if type(buf) == loxi.generic_util.OFReader: |
| 2328 | reader = buf |
| 2329 | else: |
| 2330 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2331 | _type = reader.read("!H")[0] |
| 2332 | assert(_type == 2) |
| 2333 | _length = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2334 | obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack) |
| 2335 | return obj |
| 2336 | |
| 2337 | def __eq__(self, other): |
| 2338 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2339 | if self.next_table_ids != other.next_table_ids: return False |
| 2340 | return True |
| 2341 | |
| 2342 | def __ne__(self, other): |
| 2343 | return not self.__eq__(other) |
| 2344 | |
| 2345 | def show(self): |
| 2346 | import loxi.pp |
| 2347 | return loxi.pp.pp(self) |
| 2348 | |
| 2349 | def pretty_print(self, q): |
| 2350 | q.text("table_feature_prop_next_tables {") |
| 2351 | with q.group(): |
| 2352 | with q.indent(2): |
| 2353 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2354 | q.text("next_table_ids = "); |
| 2355 | q.pp(self.next_table_ids) |
| 2356 | q.breakable() |
| 2357 | q.text('}') |
| 2358 | |
| 2359 | class table_feature_prop_next_tables_miss(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2360 | type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2361 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2362 | def __init__(self, next_table_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2363 | if next_table_ids != None: |
| 2364 | self.next_table_ids = next_table_ids |
| 2365 | else: |
| 2366 | self.next_table_ids = [] |
| 2367 | return |
| 2368 | |
| 2369 | def pack(self): |
| 2370 | packed = [] |
| 2371 | packed.append(struct.pack("!H", self.type)) |
| 2372 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2373 | packed.append(util.pack_list(self.next_table_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2374 | length = sum([len(x) for x in packed]) |
| 2375 | packed[1] = struct.pack("!H", length) |
| 2376 | return ''.join(packed) |
| 2377 | |
| 2378 | @staticmethod |
| 2379 | def unpack(buf): |
| 2380 | obj = table_feature_prop_next_tables_miss() |
| 2381 | if type(buf) == loxi.generic_util.OFReader: |
| 2382 | reader = buf |
| 2383 | else: |
| 2384 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2385 | _type = reader.read("!H")[0] |
| 2386 | assert(_type == 3) |
| 2387 | _length = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2388 | obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack) |
| 2389 | return obj |
| 2390 | |
| 2391 | def __eq__(self, other): |
| 2392 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2393 | if self.next_table_ids != other.next_table_ids: return False |
| 2394 | return True |
| 2395 | |
| 2396 | def __ne__(self, other): |
| 2397 | return not self.__eq__(other) |
| 2398 | |
| 2399 | def show(self): |
| 2400 | import loxi.pp |
| 2401 | return loxi.pp.pp(self) |
| 2402 | |
| 2403 | def pretty_print(self, q): |
| 2404 | q.text("table_feature_prop_next_tables_miss {") |
| 2405 | with q.group(): |
| 2406 | with q.indent(2): |
| 2407 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2408 | q.text("next_table_ids = "); |
| 2409 | q.pp(self.next_table_ids) |
| 2410 | q.breakable() |
| 2411 | q.text('}') |
| 2412 | |
| 2413 | class table_feature_prop_wildcards(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2414 | type = 10 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2415 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2416 | def __init__(self, oxm_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2417 | if oxm_ids != None: |
| 2418 | self.oxm_ids = oxm_ids |
| 2419 | else: |
| 2420 | self.oxm_ids = [] |
| 2421 | return |
| 2422 | |
| 2423 | def pack(self): |
| 2424 | packed = [] |
| 2425 | packed.append(struct.pack("!H", self.type)) |
| 2426 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2427 | packed.append(util.pack_list(self.oxm_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2428 | length = sum([len(x) for x in packed]) |
| 2429 | packed[1] = struct.pack("!H", length) |
| 2430 | return ''.join(packed) |
| 2431 | |
| 2432 | @staticmethod |
| 2433 | def unpack(buf): |
| 2434 | obj = table_feature_prop_wildcards() |
| 2435 | if type(buf) == loxi.generic_util.OFReader: |
| 2436 | reader = buf |
| 2437 | else: |
| 2438 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2439 | _type = reader.read("!H")[0] |
| 2440 | assert(_type == 10) |
| 2441 | _length = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2442 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 2443 | return obj |
| 2444 | |
| 2445 | def __eq__(self, other): |
| 2446 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2447 | if self.oxm_ids != other.oxm_ids: return False |
| 2448 | return True |
| 2449 | |
| 2450 | def __ne__(self, other): |
| 2451 | return not self.__eq__(other) |
| 2452 | |
| 2453 | def show(self): |
| 2454 | import loxi.pp |
| 2455 | return loxi.pp.pp(self) |
| 2456 | |
| 2457 | def pretty_print(self, q): |
| 2458 | q.text("table_feature_prop_wildcards {") |
| 2459 | with q.group(): |
| 2460 | with q.indent(2): |
| 2461 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2462 | q.text("oxm_ids = "); |
| 2463 | q.pp(self.oxm_ids) |
| 2464 | q.breakable() |
| 2465 | q.text('}') |
| 2466 | |
| 2467 | class table_feature_prop_write_actions(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2468 | type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2469 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2470 | def __init__(self, action_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2471 | if action_ids != None: |
| 2472 | self.action_ids = action_ids |
| 2473 | else: |
| 2474 | self.action_ids = [] |
| 2475 | return |
| 2476 | |
| 2477 | def pack(self): |
| 2478 | packed = [] |
| 2479 | packed.append(struct.pack("!H", self.type)) |
| 2480 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2481 | packed.append(util.pack_list(self.action_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2482 | length = sum([len(x) for x in packed]) |
| 2483 | packed[1] = struct.pack("!H", length) |
| 2484 | return ''.join(packed) |
| 2485 | |
| 2486 | @staticmethod |
| 2487 | def unpack(buf): |
| 2488 | obj = table_feature_prop_write_actions() |
| 2489 | if type(buf) == loxi.generic_util.OFReader: |
| 2490 | reader = buf |
| 2491 | else: |
| 2492 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2493 | _type = reader.read("!H")[0] |
| 2494 | assert(_type == 4) |
| 2495 | _length = reader.read("!H")[0] |
| 2496 | obj.action_ids = loxi.unimplemented('unpack list(of_action_id_t)') |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2497 | return obj |
| 2498 | |
| 2499 | def __eq__(self, other): |
| 2500 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2501 | if self.action_ids != other.action_ids: return False |
| 2502 | return True |
| 2503 | |
| 2504 | def __ne__(self, other): |
| 2505 | return not self.__eq__(other) |
| 2506 | |
| 2507 | def show(self): |
| 2508 | import loxi.pp |
| 2509 | return loxi.pp.pp(self) |
| 2510 | |
| 2511 | def pretty_print(self, q): |
| 2512 | q.text("table_feature_prop_write_actions {") |
| 2513 | with q.group(): |
| 2514 | with q.indent(2): |
| 2515 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2516 | q.text("action_ids = "); |
| 2517 | q.pp(self.action_ids) |
| 2518 | q.breakable() |
| 2519 | q.text('}') |
| 2520 | |
| 2521 | class table_feature_prop_write_actions_miss(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2522 | type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2523 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2524 | def __init__(self, action_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2525 | if action_ids != None: |
| 2526 | self.action_ids = action_ids |
| 2527 | else: |
| 2528 | self.action_ids = [] |
| 2529 | return |
| 2530 | |
| 2531 | def pack(self): |
| 2532 | packed = [] |
| 2533 | packed.append(struct.pack("!H", self.type)) |
| 2534 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2535 | packed.append(util.pack_list(self.action_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2536 | length = sum([len(x) for x in packed]) |
| 2537 | packed[1] = struct.pack("!H", length) |
| 2538 | return ''.join(packed) |
| 2539 | |
| 2540 | @staticmethod |
| 2541 | def unpack(buf): |
| 2542 | obj = table_feature_prop_write_actions_miss() |
| 2543 | if type(buf) == loxi.generic_util.OFReader: |
| 2544 | reader = buf |
| 2545 | else: |
| 2546 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2547 | _type = reader.read("!H")[0] |
| 2548 | assert(_type == 5) |
| 2549 | _length = reader.read("!H")[0] |
| 2550 | obj.action_ids = loxi.unimplemented('unpack list(of_action_id_t)') |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2551 | return obj |
| 2552 | |
| 2553 | def __eq__(self, other): |
| 2554 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2555 | if self.action_ids != other.action_ids: return False |
| 2556 | return True |
| 2557 | |
| 2558 | def __ne__(self, other): |
| 2559 | return not self.__eq__(other) |
| 2560 | |
| 2561 | def show(self): |
| 2562 | import loxi.pp |
| 2563 | return loxi.pp.pp(self) |
| 2564 | |
| 2565 | def pretty_print(self, q): |
| 2566 | q.text("table_feature_prop_write_actions_miss {") |
| 2567 | with q.group(): |
| 2568 | with q.indent(2): |
| 2569 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2570 | q.text("action_ids = "); |
| 2571 | q.pp(self.action_ids) |
| 2572 | q.breakable() |
| 2573 | q.text('}') |
| 2574 | |
| 2575 | class table_feature_prop_write_setfield(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2576 | type = 12 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2577 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2578 | def __init__(self, oxm_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2579 | if oxm_ids != None: |
| 2580 | self.oxm_ids = oxm_ids |
| 2581 | else: |
| 2582 | self.oxm_ids = [] |
| 2583 | return |
| 2584 | |
| 2585 | def pack(self): |
| 2586 | packed = [] |
| 2587 | packed.append(struct.pack("!H", self.type)) |
| 2588 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2589 | packed.append(util.pack_list(self.oxm_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2590 | length = sum([len(x) for x in packed]) |
| 2591 | packed[1] = struct.pack("!H", length) |
| 2592 | return ''.join(packed) |
| 2593 | |
| 2594 | @staticmethod |
| 2595 | def unpack(buf): |
| 2596 | obj = table_feature_prop_write_setfield() |
| 2597 | if type(buf) == loxi.generic_util.OFReader: |
| 2598 | reader = buf |
| 2599 | else: |
| 2600 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2601 | _type = reader.read("!H")[0] |
| 2602 | assert(_type == 12) |
| 2603 | _length = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2604 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 2605 | return obj |
| 2606 | |
| 2607 | def __eq__(self, other): |
| 2608 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2609 | if self.oxm_ids != other.oxm_ids: return False |
| 2610 | return True |
| 2611 | |
| 2612 | def __ne__(self, other): |
| 2613 | return not self.__eq__(other) |
| 2614 | |
| 2615 | def show(self): |
| 2616 | import loxi.pp |
| 2617 | return loxi.pp.pp(self) |
| 2618 | |
| 2619 | def pretty_print(self, q): |
| 2620 | q.text("table_feature_prop_write_setfield {") |
| 2621 | with q.group(): |
| 2622 | with q.indent(2): |
| 2623 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2624 | q.text("oxm_ids = "); |
| 2625 | q.pp(self.oxm_ids) |
| 2626 | q.breakable() |
| 2627 | q.text('}') |
| 2628 | |
| 2629 | class table_feature_prop_write_setfield_miss(object): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2630 | type = 13 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2631 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2632 | def __init__(self, oxm_ids=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2633 | if oxm_ids != None: |
| 2634 | self.oxm_ids = oxm_ids |
| 2635 | else: |
| 2636 | self.oxm_ids = [] |
| 2637 | return |
| 2638 | |
| 2639 | def pack(self): |
| 2640 | packed = [] |
| 2641 | packed.append(struct.pack("!H", self.type)) |
| 2642 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2643 | packed.append(util.pack_list(self.oxm_ids)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2644 | length = sum([len(x) for x in packed]) |
| 2645 | packed[1] = struct.pack("!H", length) |
| 2646 | return ''.join(packed) |
| 2647 | |
| 2648 | @staticmethod |
| 2649 | def unpack(buf): |
| 2650 | obj = table_feature_prop_write_setfield_miss() |
| 2651 | if type(buf) == loxi.generic_util.OFReader: |
| 2652 | reader = buf |
| 2653 | else: |
| 2654 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2655 | _type = reader.read("!H")[0] |
| 2656 | assert(_type == 13) |
| 2657 | _length = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2658 | obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack) |
| 2659 | return obj |
| 2660 | |
| 2661 | def __eq__(self, other): |
| 2662 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2663 | if self.oxm_ids != other.oxm_ids: return False |
| 2664 | return True |
| 2665 | |
| 2666 | def __ne__(self, other): |
| 2667 | return not self.__eq__(other) |
| 2668 | |
| 2669 | def show(self): |
| 2670 | import loxi.pp |
| 2671 | return loxi.pp.pp(self) |
| 2672 | |
| 2673 | def pretty_print(self, q): |
| 2674 | q.text("table_feature_prop_write_setfield_miss {") |
| 2675 | with q.group(): |
| 2676 | with q.indent(2): |
| 2677 | q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2678 | q.text("oxm_ids = "); |
| 2679 | q.pp(self.oxm_ids) |
| 2680 | q.breakable() |
| 2681 | q.text('}') |
| 2682 | |
| 2683 | class table_features(object): |
| 2684 | |
| 2685 | def __init__(self, table_id=None, name=None, metadata_match=None, metadata_write=None, config=None, max_entries=None, properties=None): |
| 2686 | if table_id != None: |
| 2687 | self.table_id = table_id |
| 2688 | else: |
| 2689 | self.table_id = 0 |
| 2690 | if name != None: |
| 2691 | self.name = name |
| 2692 | else: |
| 2693 | self.name = "" |
| 2694 | if metadata_match != None: |
| 2695 | self.metadata_match = metadata_match |
| 2696 | else: |
| 2697 | self.metadata_match = 0 |
| 2698 | if metadata_write != None: |
| 2699 | self.metadata_write = metadata_write |
| 2700 | else: |
| 2701 | self.metadata_write = 0 |
| 2702 | if config != None: |
| 2703 | self.config = config |
| 2704 | else: |
| 2705 | self.config = 0 |
| 2706 | if max_entries != None: |
| 2707 | self.max_entries = max_entries |
| 2708 | else: |
| 2709 | self.max_entries = 0 |
| 2710 | if properties != None: |
| 2711 | self.properties = properties |
| 2712 | else: |
| 2713 | self.properties = [] |
| 2714 | return |
| 2715 | |
| 2716 | def pack(self): |
| 2717 | packed = [] |
| 2718 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 2719 | packed.append(struct.pack("!B", self.table_id)) |
| 2720 | packed.append('\x00' * 5) |
| 2721 | packed.append(struct.pack("!32s", self.name)) |
| 2722 | packed.append(struct.pack("!Q", self.metadata_match)) |
| 2723 | packed.append(struct.pack("!Q", self.metadata_write)) |
| 2724 | packed.append(struct.pack("!L", self.config)) |
| 2725 | packed.append(struct.pack("!L", self.max_entries)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2726 | packed.append(util.pack_list(self.properties)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2727 | length = sum([len(x) for x in packed]) |
| 2728 | packed[0] = struct.pack("!H", length) |
| 2729 | return ''.join(packed) |
| 2730 | |
| 2731 | @staticmethod |
| 2732 | def unpack(buf): |
| 2733 | obj = table_features() |
| 2734 | if type(buf) == loxi.generic_util.OFReader: |
| 2735 | reader = buf |
| 2736 | else: |
| 2737 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2738 | _length = reader.read("!H")[0] |
| 2739 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2740 | reader.skip(5) |
| 2741 | obj.name = reader.read("!32s")[0].rstrip("\x00") |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2742 | obj.metadata_match = reader.read("!Q")[0] |
| 2743 | obj.metadata_write = reader.read("!Q")[0] |
| 2744 | obj.config = reader.read("!L")[0] |
| 2745 | obj.max_entries = reader.read("!L")[0] |
| 2746 | obj.properties = loxi.unimplemented('unpack list(of_table_feature_prop_t)') |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2747 | return obj |
| 2748 | |
| 2749 | def __eq__(self, other): |
| 2750 | if type(self) != type(other): return False |
| 2751 | if self.table_id != other.table_id: return False |
| 2752 | if self.name != other.name: return False |
| 2753 | if self.metadata_match != other.metadata_match: return False |
| 2754 | if self.metadata_write != other.metadata_write: return False |
| 2755 | if self.config != other.config: return False |
| 2756 | if self.max_entries != other.max_entries: return False |
| 2757 | if self.properties != other.properties: return False |
| 2758 | return True |
| 2759 | |
| 2760 | def __ne__(self, other): |
| 2761 | return not self.__eq__(other) |
| 2762 | |
| 2763 | def show(self): |
| 2764 | import loxi.pp |
| 2765 | return loxi.pp.pp(self) |
| 2766 | |
| 2767 | def pretty_print(self, q): |
| 2768 | q.text("table_features {") |
| 2769 | with q.group(): |
| 2770 | with q.indent(2): |
| 2771 | q.breakable() |
| 2772 | q.text("table_id = "); |
| 2773 | q.text("%#x" % self.table_id) |
| 2774 | q.text(","); q.breakable() |
| 2775 | q.text("name = "); |
| 2776 | q.pp(self.name) |
| 2777 | q.text(","); q.breakable() |
| 2778 | q.text("metadata_match = "); |
| 2779 | q.text("%#x" % self.metadata_match) |
| 2780 | q.text(","); q.breakable() |
| 2781 | q.text("metadata_write = "); |
| 2782 | q.text("%#x" % self.metadata_write) |
| 2783 | q.text(","); q.breakable() |
| 2784 | q.text("config = "); |
| 2785 | q.text("%#x" % self.config) |
| 2786 | q.text(","); q.breakable() |
| 2787 | q.text("max_entries = "); |
| 2788 | q.text("%#x" % self.max_entries) |
| 2789 | q.text(","); q.breakable() |
| 2790 | q.text("properties = "); |
| 2791 | q.pp(self.properties) |
| 2792 | q.breakable() |
| 2793 | q.text('}') |
| 2794 | |
| 2795 | class table_stats_entry(object): |
| 2796 | |
| 2797 | def __init__(self, table_id=None, active_count=None, lookup_count=None, matched_count=None): |
| 2798 | if table_id != None: |
| 2799 | self.table_id = table_id |
| 2800 | else: |
| 2801 | self.table_id = 0 |
| 2802 | if active_count != None: |
| 2803 | self.active_count = active_count |
| 2804 | else: |
| 2805 | self.active_count = 0 |
| 2806 | if lookup_count != None: |
| 2807 | self.lookup_count = lookup_count |
| 2808 | else: |
| 2809 | self.lookup_count = 0 |
| 2810 | if matched_count != None: |
| 2811 | self.matched_count = matched_count |
| 2812 | else: |
| 2813 | self.matched_count = 0 |
| 2814 | return |
| 2815 | |
| 2816 | def pack(self): |
| 2817 | packed = [] |
| 2818 | packed.append(struct.pack("!B", self.table_id)) |
| 2819 | packed.append('\x00' * 3) |
| 2820 | packed.append(struct.pack("!L", self.active_count)) |
| 2821 | packed.append(struct.pack("!Q", self.lookup_count)) |
| 2822 | packed.append(struct.pack("!Q", self.matched_count)) |
| 2823 | return ''.join(packed) |
| 2824 | |
| 2825 | @staticmethod |
| 2826 | def unpack(buf): |
| 2827 | obj = table_stats_entry() |
| 2828 | if type(buf) == loxi.generic_util.OFReader: |
| 2829 | reader = buf |
| 2830 | else: |
| 2831 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2832 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2833 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2834 | obj.active_count = reader.read("!L")[0] |
| 2835 | obj.lookup_count = reader.read("!Q")[0] |
| 2836 | obj.matched_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2837 | return obj |
| 2838 | |
| 2839 | def __eq__(self, other): |
| 2840 | if type(self) != type(other): return False |
| 2841 | if self.table_id != other.table_id: return False |
| 2842 | if self.active_count != other.active_count: return False |
| 2843 | if self.lookup_count != other.lookup_count: return False |
| 2844 | if self.matched_count != other.matched_count: return False |
| 2845 | return True |
| 2846 | |
| 2847 | def __ne__(self, other): |
| 2848 | return not self.__eq__(other) |
| 2849 | |
| 2850 | def show(self): |
| 2851 | import loxi.pp |
| 2852 | return loxi.pp.pp(self) |
| 2853 | |
| 2854 | def pretty_print(self, q): |
| 2855 | q.text("table_stats_entry {") |
| 2856 | with q.group(): |
| 2857 | with q.indent(2): |
| 2858 | q.breakable() |
| 2859 | q.text("table_id = "); |
| 2860 | q.text("%#x" % self.table_id) |
| 2861 | q.text(","); q.breakable() |
| 2862 | q.text("active_count = "); |
| 2863 | q.text("%#x" % self.active_count) |
| 2864 | q.text(","); q.breakable() |
| 2865 | q.text("lookup_count = "); |
| 2866 | q.text("%#x" % self.lookup_count) |
| 2867 | q.text(","); q.breakable() |
| 2868 | q.text("matched_count = "); |
| 2869 | q.text("%#x" % self.matched_count) |
| 2870 | q.breakable() |
| 2871 | q.text('}') |
| 2872 | |
| 2873 | class uint32(object): |
| 2874 | |
| 2875 | def __init__(self, value=None): |
| 2876 | if value != None: |
| 2877 | self.value = value |
| 2878 | else: |
| 2879 | self.value = 0 |
| 2880 | return |
| 2881 | |
| 2882 | def pack(self): |
| 2883 | packed = [] |
| 2884 | packed.append(struct.pack("!L", self.value)) |
| 2885 | return ''.join(packed) |
| 2886 | |
| 2887 | @staticmethod |
| 2888 | def unpack(buf): |
| 2889 | obj = uint32() |
| 2890 | if type(buf) == loxi.generic_util.OFReader: |
| 2891 | reader = buf |
| 2892 | else: |
| 2893 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2894 | obj.value = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2895 | return obj |
| 2896 | |
| 2897 | def __eq__(self, other): |
| 2898 | if type(self) != type(other): return False |
| 2899 | if self.value != other.value: return False |
| 2900 | return True |
| 2901 | |
| 2902 | def __ne__(self, other): |
| 2903 | return not self.__eq__(other) |
| 2904 | |
| 2905 | def show(self): |
| 2906 | import loxi.pp |
| 2907 | return loxi.pp.pp(self) |
| 2908 | |
| 2909 | def pretty_print(self, q): |
| 2910 | q.text("uint32 {") |
| 2911 | with q.group(): |
| 2912 | with q.indent(2): |
| 2913 | q.breakable() |
| 2914 | q.text("value = "); |
| 2915 | q.text("%#x" % self.value) |
| 2916 | q.breakable() |
| 2917 | q.text('}') |
| 2918 | |
| 2919 | class uint8(object): |
| 2920 | |
| 2921 | def __init__(self, value=None): |
| 2922 | if value != None: |
| 2923 | self.value = value |
| 2924 | else: |
| 2925 | self.value = 0 |
| 2926 | return |
| 2927 | |
| 2928 | def pack(self): |
| 2929 | packed = [] |
| 2930 | packed.append(struct.pack("!B", self.value)) |
| 2931 | return ''.join(packed) |
| 2932 | |
| 2933 | @staticmethod |
| 2934 | def unpack(buf): |
| 2935 | obj = uint8() |
| 2936 | if type(buf) == loxi.generic_util.OFReader: |
| 2937 | reader = buf |
| 2938 | else: |
| 2939 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2940 | obj.value = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2941 | return obj |
| 2942 | |
| 2943 | def __eq__(self, other): |
| 2944 | if type(self) != type(other): return False |
| 2945 | if self.value != other.value: return False |
| 2946 | return True |
| 2947 | |
| 2948 | def __ne__(self, other): |
| 2949 | return not self.__eq__(other) |
| 2950 | |
| 2951 | def show(self): |
| 2952 | import loxi.pp |
| 2953 | return loxi.pp.pp(self) |
| 2954 | |
| 2955 | def pretty_print(self, q): |
| 2956 | q.text("uint8 {") |
| 2957 | with q.group(): |
| 2958 | with q.indent(2): |
| 2959 | q.breakable() |
| 2960 | q.text("value = "); |
| 2961 | q.text("%#x" % self.value) |
| 2962 | q.breakable() |
| 2963 | q.text('}') |
| 2964 | |
| 2965 | |
| 2966 | match = match_v3 |