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