Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1 | # Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 2 | # Copyright (c) 2011, 2012 Open Networking Foundation |
| 3 | # Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4 | # See the file LICENSE.pyloxi which should have been included in the source distribution |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5 | |
| 6 | # Automatically generated by LOXI from template module.py |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7 | # Do not modify |
| 8 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9 | import struct |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 10 | import loxi |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 11 | import const |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 12 | import action |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 13 | import oxm |
Harshmeet Singh | 1db4633 | 2014-10-14 16:29:13 -0700 | [diff] [blame] | 14 | import message |
| 15 | import instruction |
| 16 | import common |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 17 | import util |
| 18 | import loxi.generic_util |
| 19 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 20 | class bsn_interface(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 21 | |
| 22 | def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None): |
| 23 | if hw_addr != None: |
| 24 | self.hw_addr = hw_addr |
| 25 | else: |
| 26 | self.hw_addr = [0,0,0,0,0,0] |
| 27 | if name != None: |
| 28 | self.name = name |
| 29 | else: |
| 30 | self.name = "" |
| 31 | if ipv4_addr != None: |
| 32 | self.ipv4_addr = ipv4_addr |
| 33 | else: |
| 34 | self.ipv4_addr = 0 |
| 35 | if ipv4_netmask != None: |
| 36 | self.ipv4_netmask = ipv4_netmask |
| 37 | else: |
| 38 | self.ipv4_netmask = 0 |
| 39 | return |
| 40 | |
| 41 | def pack(self): |
| 42 | packed = [] |
| 43 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 44 | packed.append('\x00' * 2) |
| 45 | packed.append(struct.pack("!16s", self.name)) |
| 46 | packed.append(struct.pack("!L", self.ipv4_addr)) |
| 47 | packed.append(struct.pack("!L", self.ipv4_netmask)) |
| 48 | return ''.join(packed) |
| 49 | |
| 50 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 51 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 52 | obj = bsn_interface() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 53 | obj.hw_addr = list(reader.read('!6B')) |
| 54 | reader.skip(2) |
| 55 | obj.name = reader.read("!16s")[0].rstrip("\x00") |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 56 | obj.ipv4_addr = reader.read("!L")[0] |
| 57 | obj.ipv4_netmask = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 58 | return obj |
| 59 | |
| 60 | def __eq__(self, other): |
| 61 | if type(self) != type(other): return False |
| 62 | if self.hw_addr != other.hw_addr: return False |
| 63 | if self.name != other.name: return False |
| 64 | if self.ipv4_addr != other.ipv4_addr: return False |
| 65 | if self.ipv4_netmask != other.ipv4_netmask: return False |
| 66 | return True |
| 67 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 68 | def pretty_print(self, q): |
| 69 | q.text("bsn_interface {") |
| 70 | with q.group(): |
| 71 | with q.indent(2): |
| 72 | q.breakable() |
| 73 | q.text("hw_addr = "); |
| 74 | q.text(util.pretty_mac(self.hw_addr)) |
| 75 | q.text(","); q.breakable() |
| 76 | q.text("name = "); |
| 77 | q.pp(self.name) |
| 78 | q.text(","); q.breakable() |
| 79 | q.text("ipv4_addr = "); |
| 80 | q.text(util.pretty_ipv4(self.ipv4_addr)) |
| 81 | q.text(","); q.breakable() |
| 82 | q.text("ipv4_netmask = "); |
| 83 | q.text(util.pretty_ipv4(self.ipv4_netmask)) |
| 84 | q.breakable() |
| 85 | q.text('}') |
| 86 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 87 | |
| 88 | class bsn_vport(loxi.OFObject): |
| 89 | subtypes = {} |
| 90 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 91 | |
| 92 | def __init__(self, type=None): |
| 93 | if type != None: |
| 94 | self.type = type |
| 95 | else: |
| 96 | self.type = 0 |
| 97 | return |
| 98 | |
| 99 | def pack(self): |
| 100 | packed = [] |
| 101 | packed.append(struct.pack("!H", self.type)) |
| 102 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 103 | length = sum([len(x) for x in packed]) |
| 104 | packed[1] = struct.pack("!H", length) |
| 105 | return ''.join(packed) |
| 106 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 107 | @staticmethod |
| 108 | def unpack(reader): |
| 109 | subtype, = reader.peek('!H', 0) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 110 | subclass = bsn_vport.subtypes.get(subtype) |
| 111 | if subclass: |
| 112 | return subclass.unpack(reader) |
| 113 | |
| 114 | obj = bsn_vport() |
| 115 | obj.type = reader.read("!H")[0] |
| 116 | _length = reader.read("!H")[0] |
| 117 | orig_reader = reader |
| 118 | reader = orig_reader.slice(_length - (2 + 2)) |
| 119 | return obj |
| 120 | |
| 121 | def __eq__(self, other): |
| 122 | if type(self) != type(other): return False |
| 123 | if self.type != other.type: return False |
| 124 | return True |
| 125 | |
| 126 | def pretty_print(self, q): |
| 127 | q.text("bsn_vport {") |
| 128 | with q.group(): |
| 129 | with q.indent(2): |
| 130 | q.breakable() |
| 131 | q.breakable() |
| 132 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 133 | |
| 134 | |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 135 | class bsn_vport_l2gre(bsn_vport): |
| 136 | type = 1 |
| 137 | |
Rich Lane | f9530c4 | 2014-09-15 09:59:43 -0700 | [diff] [blame] | 138 | def __init__(self, flags=None, port_no=None, loopback_port_no=None, local_mac=None, nh_mac=None, src_ip=None, dst_ip=None, dscp=None, ttl=None, vpn=None, rate_limit=None, if_name=None): |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 139 | if flags != None: |
| 140 | self.flags = flags |
| 141 | else: |
| 142 | self.flags = 0 |
| 143 | if port_no != None: |
| 144 | self.port_no = port_no |
| 145 | else: |
| 146 | self.port_no = 0 |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 147 | if loopback_port_no != None: |
| 148 | self.loopback_port_no = loopback_port_no |
| 149 | else: |
| 150 | self.loopback_port_no = 0 |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 151 | if local_mac != None: |
| 152 | self.local_mac = local_mac |
| 153 | else: |
| 154 | self.local_mac = [0,0,0,0,0,0] |
| 155 | if nh_mac != None: |
| 156 | self.nh_mac = nh_mac |
| 157 | else: |
| 158 | self.nh_mac = [0,0,0,0,0,0] |
| 159 | if src_ip != None: |
| 160 | self.src_ip = src_ip |
| 161 | else: |
| 162 | self.src_ip = 0 |
| 163 | if dst_ip != None: |
| 164 | self.dst_ip = dst_ip |
| 165 | else: |
| 166 | self.dst_ip = 0 |
| 167 | if dscp != None: |
| 168 | self.dscp = dscp |
| 169 | else: |
| 170 | self.dscp = 0 |
| 171 | if ttl != None: |
| 172 | self.ttl = ttl |
| 173 | else: |
| 174 | self.ttl = 0 |
| 175 | if vpn != None: |
| 176 | self.vpn = vpn |
| 177 | else: |
| 178 | self.vpn = 0 |
Rich Lane | f9530c4 | 2014-09-15 09:59:43 -0700 | [diff] [blame] | 179 | if rate_limit != None: |
| 180 | self.rate_limit = rate_limit |
| 181 | else: |
| 182 | self.rate_limit = 0 |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 183 | if if_name != None: |
| 184 | self.if_name = if_name |
| 185 | else: |
| 186 | self.if_name = "" |
| 187 | return |
| 188 | |
| 189 | def pack(self): |
| 190 | packed = [] |
| 191 | packed.append(struct.pack("!H", self.type)) |
| 192 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 193 | packed.append(struct.pack("!L", self.flags)) |
| 194 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 195 | packed.append(util.pack_port_no(self.loopback_port_no)) |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 196 | packed.append(struct.pack("!6B", *self.local_mac)) |
| 197 | packed.append(struct.pack("!6B", *self.nh_mac)) |
| 198 | packed.append(struct.pack("!L", self.src_ip)) |
| 199 | packed.append(struct.pack("!L", self.dst_ip)) |
| 200 | packed.append(struct.pack("!B", self.dscp)) |
| 201 | packed.append(struct.pack("!B", self.ttl)) |
| 202 | packed.append('\x00' * 2) |
| 203 | packed.append(struct.pack("!L", self.vpn)) |
Rich Lane | f9530c4 | 2014-09-15 09:59:43 -0700 | [diff] [blame] | 204 | packed.append(struct.pack("!L", self.rate_limit)) |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 205 | packed.append(struct.pack("!16s", self.if_name)) |
| 206 | length = sum([len(x) for x in packed]) |
| 207 | packed[1] = struct.pack("!H", length) |
| 208 | return ''.join(packed) |
| 209 | |
| 210 | @staticmethod |
| 211 | def unpack(reader): |
| 212 | obj = bsn_vport_l2gre() |
| 213 | _type = reader.read("!H")[0] |
| 214 | assert(_type == 1) |
| 215 | _length = reader.read("!H")[0] |
| 216 | orig_reader = reader |
| 217 | reader = orig_reader.slice(_length - (2 + 2)) |
| 218 | obj.flags = reader.read("!L")[0] |
| 219 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 220 | obj.loopback_port_no = util.unpack_port_no(reader) |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 221 | obj.local_mac = list(reader.read('!6B')) |
| 222 | obj.nh_mac = list(reader.read('!6B')) |
| 223 | obj.src_ip = reader.read("!L")[0] |
| 224 | obj.dst_ip = reader.read("!L")[0] |
| 225 | obj.dscp = reader.read("!B")[0] |
| 226 | obj.ttl = reader.read("!B")[0] |
| 227 | reader.skip(2) |
| 228 | obj.vpn = reader.read("!L")[0] |
Rich Lane | f9530c4 | 2014-09-15 09:59:43 -0700 | [diff] [blame] | 229 | obj.rate_limit = reader.read("!L")[0] |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 230 | obj.if_name = reader.read("!16s")[0].rstrip("\x00") |
| 231 | return obj |
| 232 | |
| 233 | def __eq__(self, other): |
| 234 | if type(self) != type(other): return False |
| 235 | if self.flags != other.flags: return False |
| 236 | if self.port_no != other.port_no: return False |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 237 | if self.loopback_port_no != other.loopback_port_no: return False |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 238 | if self.local_mac != other.local_mac: return False |
| 239 | if self.nh_mac != other.nh_mac: return False |
| 240 | if self.src_ip != other.src_ip: return False |
| 241 | if self.dst_ip != other.dst_ip: return False |
| 242 | if self.dscp != other.dscp: return False |
| 243 | if self.ttl != other.ttl: return False |
| 244 | if self.vpn != other.vpn: return False |
Rich Lane | f9530c4 | 2014-09-15 09:59:43 -0700 | [diff] [blame] | 245 | if self.rate_limit != other.rate_limit: return False |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 246 | if self.if_name != other.if_name: return False |
| 247 | return True |
| 248 | |
| 249 | def pretty_print(self, q): |
| 250 | q.text("bsn_vport_l2gre {") |
| 251 | with q.group(): |
| 252 | with q.indent(2): |
| 253 | q.breakable() |
| 254 | q.text("flags = "); |
| 255 | q.text("%#x" % self.flags) |
| 256 | q.text(","); q.breakable() |
| 257 | q.text("port_no = "); |
| 258 | q.text(util.pretty_port(self.port_no)) |
| 259 | q.text(","); q.breakable() |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 260 | q.text("loopback_port_no = "); |
| 261 | q.text(util.pretty_port(self.loopback_port_no)) |
| 262 | q.text(","); q.breakable() |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 263 | q.text("local_mac = "); |
| 264 | q.text(util.pretty_mac(self.local_mac)) |
| 265 | q.text(","); q.breakable() |
| 266 | q.text("nh_mac = "); |
| 267 | q.text(util.pretty_mac(self.nh_mac)) |
| 268 | q.text(","); q.breakable() |
| 269 | q.text("src_ip = "); |
| 270 | q.text(util.pretty_ipv4(self.src_ip)) |
| 271 | q.text(","); q.breakable() |
| 272 | q.text("dst_ip = "); |
| 273 | q.text(util.pretty_ipv4(self.dst_ip)) |
| 274 | q.text(","); q.breakable() |
| 275 | q.text("dscp = "); |
| 276 | q.text("%#x" % self.dscp) |
| 277 | q.text(","); q.breakable() |
| 278 | q.text("ttl = "); |
| 279 | q.text("%#x" % self.ttl) |
| 280 | q.text(","); q.breakable() |
| 281 | q.text("vpn = "); |
| 282 | q.text("%#x" % self.vpn) |
| 283 | q.text(","); q.breakable() |
Rich Lane | f9530c4 | 2014-09-15 09:59:43 -0700 | [diff] [blame] | 284 | q.text("rate_limit = "); |
| 285 | q.text("%#x" % self.rate_limit) |
| 286 | q.text(","); q.breakable() |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 287 | q.text("if_name = "); |
| 288 | q.pp(self.if_name) |
| 289 | q.breakable() |
| 290 | q.text('}') |
| 291 | |
| 292 | bsn_vport.subtypes[1] = bsn_vport_l2gre |
| 293 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 294 | class bsn_vport_q_in_q(bsn_vport): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 295 | type = 0 |
| 296 | |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 297 | 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] | 298 | if port_no != None: |
| 299 | self.port_no = port_no |
| 300 | else: |
| 301 | self.port_no = 0 |
| 302 | if ingress_tpid != None: |
| 303 | self.ingress_tpid = ingress_tpid |
| 304 | else: |
| 305 | self.ingress_tpid = 0 |
| 306 | if ingress_vlan_id != None: |
| 307 | self.ingress_vlan_id = ingress_vlan_id |
| 308 | else: |
| 309 | self.ingress_vlan_id = 0 |
| 310 | if egress_tpid != None: |
| 311 | self.egress_tpid = egress_tpid |
| 312 | else: |
| 313 | self.egress_tpid = 0 |
| 314 | if egress_vlan_id != None: |
| 315 | self.egress_vlan_id = egress_vlan_id |
| 316 | else: |
| 317 | self.egress_vlan_id = 0 |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 318 | if if_name != None: |
| 319 | self.if_name = if_name |
| 320 | else: |
| 321 | self.if_name = "" |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 322 | return |
| 323 | |
| 324 | def pack(self): |
| 325 | packed = [] |
| 326 | packed.append(struct.pack("!H", self.type)) |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 327 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 328 | packed.append(struct.pack("!L", self.port_no)) |
| 329 | packed.append(struct.pack("!H", self.ingress_tpid)) |
| 330 | packed.append(struct.pack("!H", self.ingress_vlan_id)) |
| 331 | packed.append(struct.pack("!H", self.egress_tpid)) |
| 332 | packed.append(struct.pack("!H", self.egress_vlan_id)) |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 333 | packed.append(struct.pack("!16s", self.if_name)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 334 | length = sum([len(x) for x in packed]) |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 335 | packed[1] = struct.pack("!H", length) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 336 | return ''.join(packed) |
| 337 | |
| 338 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 339 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 340 | obj = bsn_vport_q_in_q() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 341 | _type = reader.read("!H")[0] |
| 342 | assert(_type == 0) |
| 343 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 344 | orig_reader = reader |
| 345 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 346 | obj.port_no = reader.read("!L")[0] |
| 347 | obj.ingress_tpid = reader.read("!H")[0] |
| 348 | obj.ingress_vlan_id = reader.read("!H")[0] |
| 349 | obj.egress_tpid = reader.read("!H")[0] |
| 350 | obj.egress_vlan_id = reader.read("!H")[0] |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 351 | obj.if_name = reader.read("!16s")[0].rstrip("\x00") |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 352 | return obj |
| 353 | |
| 354 | def __eq__(self, other): |
| 355 | if type(self) != type(other): return False |
| 356 | if self.port_no != other.port_no: return False |
| 357 | if self.ingress_tpid != other.ingress_tpid: return False |
| 358 | if self.ingress_vlan_id != other.ingress_vlan_id: return False |
| 359 | if self.egress_tpid != other.egress_tpid: return False |
| 360 | if self.egress_vlan_id != other.egress_vlan_id: return False |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 361 | if self.if_name != other.if_name: return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 362 | return True |
| 363 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 364 | def pretty_print(self, q): |
| 365 | q.text("bsn_vport_q_in_q {") |
| 366 | with q.group(): |
| 367 | with q.indent(2): |
| 368 | q.breakable() |
| 369 | q.text("port_no = "); |
| 370 | q.text("%#x" % self.port_no) |
| 371 | q.text(","); q.breakable() |
| 372 | q.text("ingress_tpid = "); |
| 373 | q.text("%#x" % self.ingress_tpid) |
| 374 | q.text(","); q.breakable() |
| 375 | q.text("ingress_vlan_id = "); |
| 376 | q.text("%#x" % self.ingress_vlan_id) |
| 377 | q.text(","); q.breakable() |
| 378 | q.text("egress_tpid = "); |
| 379 | q.text("%#x" % self.egress_tpid) |
| 380 | q.text(","); q.breakable() |
| 381 | q.text("egress_vlan_id = "); |
| 382 | q.text("%#x" % self.egress_vlan_id) |
Kiran Poola | 150d8b0 | 2013-09-20 13:30:39 -0700 | [diff] [blame] | 383 | q.text(","); q.breakable() |
| 384 | q.text("if_name = "); |
| 385 | q.pp(self.if_name) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 386 | q.breakable() |
| 387 | q.text('}') |
| 388 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 389 | bsn_vport.subtypes[0] = bsn_vport_q_in_q |
| 390 | |
| 391 | class bucket(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 392 | |
| 393 | def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None): |
| 394 | if weight != None: |
| 395 | self.weight = weight |
| 396 | else: |
| 397 | self.weight = 0 |
| 398 | if watch_port != None: |
| 399 | self.watch_port = watch_port |
| 400 | else: |
| 401 | self.watch_port = 0 |
| 402 | if watch_group != None: |
| 403 | self.watch_group = watch_group |
| 404 | else: |
| 405 | self.watch_group = 0 |
| 406 | if actions != None: |
| 407 | self.actions = actions |
| 408 | else: |
| 409 | self.actions = [] |
| 410 | return |
| 411 | |
| 412 | def pack(self): |
| 413 | packed = [] |
| 414 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 0 |
| 415 | packed.append(struct.pack("!H", self.weight)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 416 | packed.append(util.pack_port_no(self.watch_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 417 | packed.append(struct.pack("!L", self.watch_group)) |
| 418 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 419 | packed.append(loxi.generic_util.pack_list(self.actions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 420 | length = sum([len(x) for x in packed]) |
| 421 | packed[0] = struct.pack("!H", length) |
| 422 | return ''.join(packed) |
| 423 | |
| 424 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 425 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 426 | obj = bucket() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 427 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 428 | orig_reader = reader |
| 429 | reader = orig_reader.slice(_len - (0 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 430 | obj.weight = reader.read("!H")[0] |
| 431 | obj.watch_port = util.unpack_port_no(reader) |
| 432 | obj.watch_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 433 | reader.skip(4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 434 | obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 435 | return obj |
| 436 | |
| 437 | def __eq__(self, other): |
| 438 | if type(self) != type(other): return False |
| 439 | if self.weight != other.weight: return False |
| 440 | if self.watch_port != other.watch_port: return False |
| 441 | if self.watch_group != other.watch_group: return False |
| 442 | if self.actions != other.actions: return False |
| 443 | return True |
| 444 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 445 | def pretty_print(self, q): |
| 446 | q.text("bucket {") |
| 447 | with q.group(): |
| 448 | with q.indent(2): |
| 449 | q.breakable() |
| 450 | q.text("weight = "); |
| 451 | q.text("%#x" % self.weight) |
| 452 | q.text(","); q.breakable() |
| 453 | q.text("watch_port = "); |
| 454 | q.text(util.pretty_port(self.watch_port)) |
| 455 | q.text(","); q.breakable() |
| 456 | q.text("watch_group = "); |
| 457 | q.text("%#x" % self.watch_group) |
| 458 | q.text(","); q.breakable() |
| 459 | q.text("actions = "); |
| 460 | q.pp(self.actions) |
| 461 | q.breakable() |
| 462 | q.text('}') |
| 463 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 464 | |
| 465 | class bucket_counter(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 466 | |
| 467 | def __init__(self, packet_count=None, byte_count=None): |
| 468 | if packet_count != None: |
| 469 | self.packet_count = packet_count |
| 470 | else: |
| 471 | self.packet_count = 0 |
| 472 | if byte_count != None: |
| 473 | self.byte_count = byte_count |
| 474 | else: |
| 475 | self.byte_count = 0 |
| 476 | return |
| 477 | |
| 478 | def pack(self): |
| 479 | packed = [] |
| 480 | packed.append(struct.pack("!Q", self.packet_count)) |
| 481 | packed.append(struct.pack("!Q", self.byte_count)) |
| 482 | return ''.join(packed) |
| 483 | |
| 484 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 485 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 486 | obj = bucket_counter() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 487 | obj.packet_count = reader.read("!Q")[0] |
| 488 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 489 | return obj |
| 490 | |
| 491 | def __eq__(self, other): |
| 492 | if type(self) != type(other): return False |
| 493 | if self.packet_count != other.packet_count: return False |
| 494 | if self.byte_count != other.byte_count: return False |
| 495 | return True |
| 496 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 497 | def pretty_print(self, q): |
| 498 | q.text("bucket_counter {") |
| 499 | with q.group(): |
| 500 | with q.indent(2): |
| 501 | q.breakable() |
| 502 | q.text("packet_count = "); |
| 503 | q.text("%#x" % self.packet_count) |
| 504 | q.text(","); q.breakable() |
| 505 | q.text("byte_count = "); |
| 506 | q.text("%#x" % self.byte_count) |
| 507 | q.breakable() |
| 508 | q.text('}') |
| 509 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 510 | |
| 511 | class flow_stats_entry(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 512 | |
| 513 | def __init__(self, table_id=None, duration_sec=None, duration_nsec=None, priority=None, idle_timeout=None, hard_timeout=None, cookie=None, packet_count=None, byte_count=None, match=None, instructions=None): |
| 514 | if table_id != None: |
| 515 | self.table_id = table_id |
| 516 | else: |
| 517 | self.table_id = 0 |
| 518 | if duration_sec != None: |
| 519 | self.duration_sec = duration_sec |
| 520 | else: |
| 521 | self.duration_sec = 0 |
| 522 | if duration_nsec != None: |
| 523 | self.duration_nsec = duration_nsec |
| 524 | else: |
| 525 | self.duration_nsec = 0 |
| 526 | if priority != None: |
| 527 | self.priority = priority |
| 528 | else: |
| 529 | self.priority = 0 |
| 530 | if idle_timeout != None: |
| 531 | self.idle_timeout = idle_timeout |
| 532 | else: |
| 533 | self.idle_timeout = 0 |
| 534 | if hard_timeout != None: |
| 535 | self.hard_timeout = hard_timeout |
| 536 | else: |
| 537 | self.hard_timeout = 0 |
| 538 | if cookie != None: |
| 539 | self.cookie = cookie |
| 540 | else: |
| 541 | self.cookie = 0 |
| 542 | if packet_count != None: |
| 543 | self.packet_count = packet_count |
| 544 | else: |
| 545 | self.packet_count = 0 |
| 546 | if byte_count != None: |
| 547 | self.byte_count = byte_count |
| 548 | else: |
| 549 | self.byte_count = 0 |
| 550 | if match != None: |
| 551 | self.match = match |
| 552 | else: |
| 553 | self.match = common.match() |
| 554 | if instructions != None: |
| 555 | self.instructions = instructions |
| 556 | else: |
| 557 | self.instructions = [] |
| 558 | return |
| 559 | |
| 560 | def pack(self): |
| 561 | packed = [] |
| 562 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 563 | packed.append(struct.pack("!B", self.table_id)) |
| 564 | packed.append('\x00' * 1) |
| 565 | packed.append(struct.pack("!L", self.duration_sec)) |
| 566 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 567 | packed.append(struct.pack("!H", self.priority)) |
| 568 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 569 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 570 | packed.append('\x00' * 6) |
| 571 | packed.append(struct.pack("!Q", self.cookie)) |
| 572 | packed.append(struct.pack("!Q", self.packet_count)) |
| 573 | packed.append(struct.pack("!Q", self.byte_count)) |
| 574 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 575 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 576 | length = sum([len(x) for x in packed]) |
| 577 | packed[0] = struct.pack("!H", length) |
| 578 | return ''.join(packed) |
| 579 | |
| 580 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 581 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 582 | obj = flow_stats_entry() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 583 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 584 | orig_reader = reader |
| 585 | reader = orig_reader.slice(_length - (0 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 586 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 587 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 588 | obj.duration_sec = reader.read("!L")[0] |
| 589 | obj.duration_nsec = reader.read("!L")[0] |
| 590 | obj.priority = reader.read("!H")[0] |
| 591 | obj.idle_timeout = reader.read("!H")[0] |
| 592 | obj.hard_timeout = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 593 | reader.skip(6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 594 | obj.cookie = reader.read("!Q")[0] |
| 595 | obj.packet_count = reader.read("!Q")[0] |
| 596 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 597 | obj.match = common.match.unpack(reader) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 598 | obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 599 | return obj |
| 600 | |
| 601 | def __eq__(self, other): |
| 602 | if type(self) != type(other): return False |
| 603 | if self.table_id != other.table_id: return False |
| 604 | if self.duration_sec != other.duration_sec: return False |
| 605 | if self.duration_nsec != other.duration_nsec: return False |
| 606 | if self.priority != other.priority: return False |
| 607 | if self.idle_timeout != other.idle_timeout: return False |
| 608 | if self.hard_timeout != other.hard_timeout: return False |
| 609 | if self.cookie != other.cookie: return False |
| 610 | if self.packet_count != other.packet_count: return False |
| 611 | if self.byte_count != other.byte_count: return False |
| 612 | if self.match != other.match: return False |
| 613 | if self.instructions != other.instructions: return False |
| 614 | return True |
| 615 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 616 | def pretty_print(self, q): |
| 617 | q.text("flow_stats_entry {") |
| 618 | with q.group(): |
| 619 | with q.indent(2): |
| 620 | q.breakable() |
| 621 | q.text("table_id = "); |
| 622 | q.text("%#x" % self.table_id) |
| 623 | q.text(","); q.breakable() |
| 624 | q.text("duration_sec = "); |
| 625 | q.text("%#x" % self.duration_sec) |
| 626 | q.text(","); q.breakable() |
| 627 | q.text("duration_nsec = "); |
| 628 | q.text("%#x" % self.duration_nsec) |
| 629 | q.text(","); q.breakable() |
| 630 | q.text("priority = "); |
| 631 | q.text("%#x" % self.priority) |
| 632 | q.text(","); q.breakable() |
| 633 | q.text("idle_timeout = "); |
| 634 | q.text("%#x" % self.idle_timeout) |
| 635 | q.text(","); q.breakable() |
| 636 | q.text("hard_timeout = "); |
| 637 | q.text("%#x" % self.hard_timeout) |
| 638 | q.text(","); q.breakable() |
| 639 | q.text("cookie = "); |
| 640 | q.text("%#x" % self.cookie) |
| 641 | q.text(","); q.breakable() |
| 642 | q.text("packet_count = "); |
| 643 | q.text("%#x" % self.packet_count) |
| 644 | q.text(","); q.breakable() |
| 645 | q.text("byte_count = "); |
| 646 | q.text("%#x" % self.byte_count) |
| 647 | q.text(","); q.breakable() |
| 648 | q.text("match = "); |
| 649 | q.pp(self.match) |
| 650 | q.text(","); q.breakable() |
| 651 | q.text("instructions = "); |
| 652 | q.pp(self.instructions) |
| 653 | q.breakable() |
| 654 | q.text('}') |
| 655 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 656 | |
| 657 | class group_desc_stats_entry(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 658 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 659 | def __init__(self, group_type=None, group_id=None, buckets=None): |
| 660 | if group_type != None: |
| 661 | self.group_type = group_type |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 662 | else: |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 663 | self.group_type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 664 | if group_id != None: |
| 665 | self.group_id = group_id |
| 666 | else: |
| 667 | self.group_id = 0 |
| 668 | if buckets != None: |
| 669 | self.buckets = buckets |
| 670 | else: |
| 671 | self.buckets = [] |
| 672 | return |
| 673 | |
| 674 | def pack(self): |
| 675 | packed = [] |
| 676 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 677 | packed.append(struct.pack("!B", self.group_type)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 678 | packed.append('\x00' * 1) |
| 679 | packed.append(struct.pack("!L", self.group_id)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 680 | packed.append(loxi.generic_util.pack_list(self.buckets)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 681 | length = sum([len(x) for x in packed]) |
| 682 | packed[0] = struct.pack("!H", length) |
| 683 | return ''.join(packed) |
| 684 | |
| 685 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 686 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 687 | obj = group_desc_stats_entry() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 688 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 689 | orig_reader = reader |
| 690 | reader = orig_reader.slice(_length - (0 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 691 | obj.group_type = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 692 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 693 | obj.group_id = reader.read("!L")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 694 | obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 695 | return obj |
| 696 | |
| 697 | def __eq__(self, other): |
| 698 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 699 | if self.group_type != other.group_type: return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 700 | if self.group_id != other.group_id: return False |
| 701 | if self.buckets != other.buckets: return False |
| 702 | return True |
| 703 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 704 | def pretty_print(self, q): |
| 705 | q.text("group_desc_stats_entry {") |
| 706 | with q.group(): |
| 707 | with q.indent(2): |
| 708 | q.breakable() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 709 | q.text("group_type = "); |
| 710 | q.text("%#x" % self.group_type) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 711 | q.text(","); q.breakable() |
| 712 | q.text("group_id = "); |
| 713 | q.text("%#x" % self.group_id) |
| 714 | q.text(","); q.breakable() |
| 715 | q.text("buckets = "); |
| 716 | q.pp(self.buckets) |
| 717 | q.breakable() |
| 718 | q.text('}') |
| 719 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 720 | |
| 721 | class group_stats_entry(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 722 | |
| 723 | def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, bucket_stats=None): |
| 724 | if group_id != None: |
| 725 | self.group_id = group_id |
| 726 | else: |
| 727 | self.group_id = 0 |
| 728 | if ref_count != None: |
| 729 | self.ref_count = ref_count |
| 730 | else: |
| 731 | self.ref_count = 0 |
| 732 | if packet_count != None: |
| 733 | self.packet_count = packet_count |
| 734 | else: |
| 735 | self.packet_count = 0 |
| 736 | if byte_count != None: |
| 737 | self.byte_count = byte_count |
| 738 | else: |
| 739 | self.byte_count = 0 |
| 740 | if bucket_stats != None: |
| 741 | self.bucket_stats = bucket_stats |
| 742 | else: |
| 743 | self.bucket_stats = [] |
| 744 | return |
| 745 | |
| 746 | def pack(self): |
| 747 | packed = [] |
| 748 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 749 | packed.append('\x00' * 2) |
| 750 | packed.append(struct.pack("!L", self.group_id)) |
| 751 | packed.append(struct.pack("!L", self.ref_count)) |
| 752 | packed.append('\x00' * 4) |
| 753 | packed.append(struct.pack("!Q", self.packet_count)) |
| 754 | packed.append(struct.pack("!Q", self.byte_count)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 755 | packed.append(loxi.generic_util.pack_list(self.bucket_stats)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 756 | length = sum([len(x) for x in packed]) |
| 757 | packed[0] = struct.pack("!H", length) |
| 758 | return ''.join(packed) |
| 759 | |
| 760 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 761 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 762 | obj = group_stats_entry() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 763 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 764 | orig_reader = reader |
| 765 | reader = orig_reader.slice(_length - (0 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 766 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 767 | obj.group_id = reader.read("!L")[0] |
| 768 | obj.ref_count = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 769 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 770 | obj.packet_count = reader.read("!Q")[0] |
| 771 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 772 | obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack) |
| 773 | return obj |
| 774 | |
| 775 | def __eq__(self, other): |
| 776 | if type(self) != type(other): return False |
| 777 | if self.group_id != other.group_id: return False |
| 778 | if self.ref_count != other.ref_count: return False |
| 779 | if self.packet_count != other.packet_count: return False |
| 780 | if self.byte_count != other.byte_count: return False |
| 781 | if self.bucket_stats != other.bucket_stats: return False |
| 782 | return True |
| 783 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 784 | def pretty_print(self, q): |
| 785 | q.text("group_stats_entry {") |
| 786 | with q.group(): |
| 787 | with q.indent(2): |
| 788 | q.breakable() |
| 789 | q.text("group_id = "); |
| 790 | q.text("%#x" % self.group_id) |
| 791 | q.text(","); q.breakable() |
| 792 | q.text("ref_count = "); |
| 793 | q.text("%#x" % self.ref_count) |
| 794 | q.text(","); q.breakable() |
| 795 | q.text("packet_count = "); |
| 796 | q.text("%#x" % self.packet_count) |
| 797 | q.text(","); q.breakable() |
| 798 | q.text("byte_count = "); |
| 799 | q.text("%#x" % self.byte_count) |
| 800 | q.text(","); q.breakable() |
| 801 | q.text("bucket_stats = "); |
| 802 | q.pp(self.bucket_stats) |
| 803 | q.breakable() |
| 804 | q.text('}') |
| 805 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 806 | |
| 807 | class match_v3(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 808 | type = 1 |
| 809 | |
| 810 | def __init__(self, oxm_list=None): |
| 811 | if oxm_list != None: |
| 812 | self.oxm_list = oxm_list |
| 813 | else: |
| 814 | self.oxm_list = [] |
| 815 | return |
| 816 | |
| 817 | def pack(self): |
| 818 | packed = [] |
| 819 | packed.append(struct.pack("!H", self.type)) |
| 820 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 821 | packed.append(loxi.generic_util.pack_list(self.oxm_list)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 822 | length = sum([len(x) for x in packed]) |
| 823 | packed[1] = struct.pack("!H", length) |
Rich Lane | d53156a | 2013-08-05 17:17:33 -0700 | [diff] [blame] | 824 | packed.append(loxi.generic_util.pad_to(8, length)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 825 | return ''.join(packed) |
| 826 | |
| 827 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 828 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 829 | obj = match_v3() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 830 | _type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 831 | assert(_type == 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 832 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 833 | orig_reader = reader |
| 834 | reader = orig_reader.slice(_length - (2 + 2)) |
| 835 | obj.oxm_list = loxi.generic_util.unpack_list(reader, oxm.oxm.unpack) |
| 836 | orig_reader.skip_align() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 837 | return obj |
| 838 | |
| 839 | def __eq__(self, other): |
| 840 | if type(self) != type(other): return False |
| 841 | if self.oxm_list != other.oxm_list: return False |
| 842 | return True |
| 843 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 844 | def pretty_print(self, q): |
| 845 | q.text("match_v3 {") |
| 846 | with q.group(): |
| 847 | with q.indent(2): |
| 848 | q.breakable() |
| 849 | q.text("oxm_list = "); |
| 850 | q.pp(self.oxm_list) |
| 851 | q.breakable() |
| 852 | q.text('}') |
| 853 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 854 | |
| 855 | class packet_queue(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 856 | |
| 857 | def __init__(self, queue_id=None, port=None, properties=None): |
| 858 | if queue_id != None: |
| 859 | self.queue_id = queue_id |
| 860 | else: |
| 861 | self.queue_id = 0 |
| 862 | if port != None: |
| 863 | self.port = port |
| 864 | else: |
| 865 | self.port = 0 |
| 866 | if properties != None: |
| 867 | self.properties = properties |
| 868 | else: |
| 869 | self.properties = [] |
| 870 | return |
| 871 | |
| 872 | def pack(self): |
| 873 | packed = [] |
| 874 | packed.append(struct.pack("!L", self.queue_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 875 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 876 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 2 |
| 877 | packed.append('\x00' * 6) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 878 | packed.append(loxi.generic_util.pack_list(self.properties)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 879 | length = sum([len(x) for x in packed]) |
| 880 | packed[2] = struct.pack("!H", length) |
| 881 | return ''.join(packed) |
| 882 | |
| 883 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 884 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 885 | obj = packet_queue() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 886 | obj.queue_id = reader.read("!L")[0] |
| 887 | obj.port = util.unpack_port_no(reader) |
| 888 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 889 | orig_reader = reader |
| 890 | reader = orig_reader.slice(_len - (8 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 891 | reader.skip(6) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 892 | obj.properties = loxi.generic_util.unpack_list(reader, common.queue_prop.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 893 | return obj |
| 894 | |
| 895 | def __eq__(self, other): |
| 896 | if type(self) != type(other): return False |
| 897 | if self.queue_id != other.queue_id: return False |
| 898 | if self.port != other.port: return False |
| 899 | if self.properties != other.properties: return False |
| 900 | return True |
| 901 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 902 | def pretty_print(self, q): |
| 903 | q.text("packet_queue {") |
| 904 | with q.group(): |
| 905 | with q.indent(2): |
| 906 | q.breakable() |
| 907 | q.text("queue_id = "); |
| 908 | q.text("%#x" % self.queue_id) |
| 909 | q.text(","); q.breakable() |
| 910 | q.text("port = "); |
| 911 | q.text(util.pretty_port(self.port)) |
| 912 | q.text(","); q.breakable() |
| 913 | q.text("properties = "); |
| 914 | q.pp(self.properties) |
| 915 | q.breakable() |
| 916 | q.text('}') |
| 917 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 918 | |
| 919 | class port_desc(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 920 | |
| 921 | 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): |
| 922 | if port_no != None: |
| 923 | self.port_no = port_no |
| 924 | else: |
| 925 | self.port_no = 0 |
| 926 | if hw_addr != None: |
| 927 | self.hw_addr = hw_addr |
| 928 | else: |
| 929 | self.hw_addr = [0,0,0,0,0,0] |
| 930 | if name != None: |
| 931 | self.name = name |
| 932 | else: |
| 933 | self.name = "" |
| 934 | if config != None: |
| 935 | self.config = config |
| 936 | else: |
| 937 | self.config = 0 |
| 938 | if state != None: |
| 939 | self.state = state |
| 940 | else: |
| 941 | self.state = 0 |
| 942 | if curr != None: |
| 943 | self.curr = curr |
| 944 | else: |
| 945 | self.curr = 0 |
| 946 | if advertised != None: |
| 947 | self.advertised = advertised |
| 948 | else: |
| 949 | self.advertised = 0 |
| 950 | if supported != None: |
| 951 | self.supported = supported |
| 952 | else: |
| 953 | self.supported = 0 |
| 954 | if peer != None: |
| 955 | self.peer = peer |
| 956 | else: |
| 957 | self.peer = 0 |
| 958 | if curr_speed != None: |
| 959 | self.curr_speed = curr_speed |
| 960 | else: |
| 961 | self.curr_speed = 0 |
| 962 | if max_speed != None: |
| 963 | self.max_speed = max_speed |
| 964 | else: |
| 965 | self.max_speed = 0 |
| 966 | return |
| 967 | |
| 968 | def pack(self): |
| 969 | packed = [] |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 970 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 971 | packed.append('\x00' * 4) |
| 972 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 973 | packed.append('\x00' * 2) |
| 974 | packed.append(struct.pack("!16s", self.name)) |
| 975 | packed.append(struct.pack("!L", self.config)) |
| 976 | packed.append(struct.pack("!L", self.state)) |
| 977 | packed.append(struct.pack("!L", self.curr)) |
| 978 | packed.append(struct.pack("!L", self.advertised)) |
| 979 | packed.append(struct.pack("!L", self.supported)) |
| 980 | packed.append(struct.pack("!L", self.peer)) |
| 981 | packed.append(struct.pack("!L", self.curr_speed)) |
| 982 | packed.append(struct.pack("!L", self.max_speed)) |
| 983 | return ''.join(packed) |
| 984 | |
| 985 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 986 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 987 | obj = port_desc() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 988 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 989 | reader.skip(4) |
| 990 | obj.hw_addr = list(reader.read('!6B')) |
| 991 | reader.skip(2) |
| 992 | obj.name = reader.read("!16s")[0].rstrip("\x00") |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 993 | obj.config = reader.read("!L")[0] |
| 994 | obj.state = reader.read("!L")[0] |
| 995 | obj.curr = reader.read("!L")[0] |
| 996 | obj.advertised = reader.read("!L")[0] |
| 997 | obj.supported = reader.read("!L")[0] |
| 998 | obj.peer = reader.read("!L")[0] |
| 999 | obj.curr_speed = reader.read("!L")[0] |
| 1000 | obj.max_speed = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1001 | return obj |
| 1002 | |
| 1003 | def __eq__(self, other): |
| 1004 | if type(self) != type(other): return False |
| 1005 | if self.port_no != other.port_no: return False |
| 1006 | if self.hw_addr != other.hw_addr: return False |
| 1007 | if self.name != other.name: return False |
| 1008 | if self.config != other.config: return False |
| 1009 | if self.state != other.state: return False |
| 1010 | if self.curr != other.curr: return False |
| 1011 | if self.advertised != other.advertised: return False |
| 1012 | if self.supported != other.supported: return False |
| 1013 | if self.peer != other.peer: return False |
| 1014 | if self.curr_speed != other.curr_speed: return False |
| 1015 | if self.max_speed != other.max_speed: return False |
| 1016 | return True |
| 1017 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1018 | def pretty_print(self, q): |
| 1019 | q.text("port_desc {") |
| 1020 | with q.group(): |
| 1021 | with q.indent(2): |
| 1022 | q.breakable() |
| 1023 | q.text("port_no = "); |
| 1024 | q.text(util.pretty_port(self.port_no)) |
| 1025 | q.text(","); q.breakable() |
| 1026 | q.text("hw_addr = "); |
| 1027 | q.text(util.pretty_mac(self.hw_addr)) |
| 1028 | q.text(","); q.breakable() |
| 1029 | q.text("name = "); |
| 1030 | q.pp(self.name) |
| 1031 | q.text(","); q.breakable() |
| 1032 | q.text("config = "); |
| 1033 | q.text("%#x" % self.config) |
| 1034 | q.text(","); q.breakable() |
| 1035 | q.text("state = "); |
| 1036 | q.text("%#x" % self.state) |
| 1037 | q.text(","); q.breakable() |
| 1038 | q.text("curr = "); |
| 1039 | q.text("%#x" % self.curr) |
| 1040 | q.text(","); q.breakable() |
| 1041 | q.text("advertised = "); |
| 1042 | q.text("%#x" % self.advertised) |
| 1043 | q.text(","); q.breakable() |
| 1044 | q.text("supported = "); |
| 1045 | q.text("%#x" % self.supported) |
| 1046 | q.text(","); q.breakable() |
| 1047 | q.text("peer = "); |
| 1048 | q.text("%#x" % self.peer) |
| 1049 | q.text(","); q.breakable() |
| 1050 | q.text("curr_speed = "); |
| 1051 | q.text("%#x" % self.curr_speed) |
| 1052 | q.text(","); q.breakable() |
| 1053 | q.text("max_speed = "); |
| 1054 | q.text("%#x" % self.max_speed) |
| 1055 | q.breakable() |
| 1056 | q.text('}') |
| 1057 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1058 | |
| 1059 | class port_stats_entry(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1060 | |
| 1061 | 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): |
| 1062 | if port_no != None: |
| 1063 | self.port_no = port_no |
| 1064 | else: |
| 1065 | self.port_no = 0 |
| 1066 | if rx_packets != None: |
| 1067 | self.rx_packets = rx_packets |
| 1068 | else: |
| 1069 | self.rx_packets = 0 |
| 1070 | if tx_packets != None: |
| 1071 | self.tx_packets = tx_packets |
| 1072 | else: |
| 1073 | self.tx_packets = 0 |
| 1074 | if rx_bytes != None: |
| 1075 | self.rx_bytes = rx_bytes |
| 1076 | else: |
| 1077 | self.rx_bytes = 0 |
| 1078 | if tx_bytes != None: |
| 1079 | self.tx_bytes = tx_bytes |
| 1080 | else: |
| 1081 | self.tx_bytes = 0 |
| 1082 | if rx_dropped != None: |
| 1083 | self.rx_dropped = rx_dropped |
| 1084 | else: |
| 1085 | self.rx_dropped = 0 |
| 1086 | if tx_dropped != None: |
| 1087 | self.tx_dropped = tx_dropped |
| 1088 | else: |
| 1089 | self.tx_dropped = 0 |
| 1090 | if rx_errors != None: |
| 1091 | self.rx_errors = rx_errors |
| 1092 | else: |
| 1093 | self.rx_errors = 0 |
| 1094 | if tx_errors != None: |
| 1095 | self.tx_errors = tx_errors |
| 1096 | else: |
| 1097 | self.tx_errors = 0 |
| 1098 | if rx_frame_err != None: |
| 1099 | self.rx_frame_err = rx_frame_err |
| 1100 | else: |
| 1101 | self.rx_frame_err = 0 |
| 1102 | if rx_over_err != None: |
| 1103 | self.rx_over_err = rx_over_err |
| 1104 | else: |
| 1105 | self.rx_over_err = 0 |
| 1106 | if rx_crc_err != None: |
| 1107 | self.rx_crc_err = rx_crc_err |
| 1108 | else: |
| 1109 | self.rx_crc_err = 0 |
| 1110 | if collisions != None: |
| 1111 | self.collisions = collisions |
| 1112 | else: |
| 1113 | self.collisions = 0 |
| 1114 | return |
| 1115 | |
| 1116 | def pack(self): |
| 1117 | packed = [] |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1118 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1119 | packed.append('\x00' * 4) |
| 1120 | packed.append(struct.pack("!Q", self.rx_packets)) |
| 1121 | packed.append(struct.pack("!Q", self.tx_packets)) |
| 1122 | packed.append(struct.pack("!Q", self.rx_bytes)) |
| 1123 | packed.append(struct.pack("!Q", self.tx_bytes)) |
| 1124 | packed.append(struct.pack("!Q", self.rx_dropped)) |
| 1125 | packed.append(struct.pack("!Q", self.tx_dropped)) |
| 1126 | packed.append(struct.pack("!Q", self.rx_errors)) |
| 1127 | packed.append(struct.pack("!Q", self.tx_errors)) |
| 1128 | packed.append(struct.pack("!Q", self.rx_frame_err)) |
| 1129 | packed.append(struct.pack("!Q", self.rx_over_err)) |
| 1130 | packed.append(struct.pack("!Q", self.rx_crc_err)) |
| 1131 | packed.append(struct.pack("!Q", self.collisions)) |
| 1132 | return ''.join(packed) |
| 1133 | |
| 1134 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1135 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1136 | obj = port_stats_entry() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1137 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1138 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1139 | obj.rx_packets = reader.read("!Q")[0] |
| 1140 | obj.tx_packets = reader.read("!Q")[0] |
| 1141 | obj.rx_bytes = reader.read("!Q")[0] |
| 1142 | obj.tx_bytes = reader.read("!Q")[0] |
| 1143 | obj.rx_dropped = reader.read("!Q")[0] |
| 1144 | obj.tx_dropped = reader.read("!Q")[0] |
| 1145 | obj.rx_errors = reader.read("!Q")[0] |
| 1146 | obj.tx_errors = reader.read("!Q")[0] |
| 1147 | obj.rx_frame_err = reader.read("!Q")[0] |
| 1148 | obj.rx_over_err = reader.read("!Q")[0] |
| 1149 | obj.rx_crc_err = reader.read("!Q")[0] |
| 1150 | obj.collisions = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1151 | return obj |
| 1152 | |
| 1153 | def __eq__(self, other): |
| 1154 | if type(self) != type(other): return False |
| 1155 | if self.port_no != other.port_no: return False |
| 1156 | if self.rx_packets != other.rx_packets: return False |
| 1157 | if self.tx_packets != other.tx_packets: return False |
| 1158 | if self.rx_bytes != other.rx_bytes: return False |
| 1159 | if self.tx_bytes != other.tx_bytes: return False |
| 1160 | if self.rx_dropped != other.rx_dropped: return False |
| 1161 | if self.tx_dropped != other.tx_dropped: return False |
| 1162 | if self.rx_errors != other.rx_errors: return False |
| 1163 | if self.tx_errors != other.tx_errors: return False |
| 1164 | if self.rx_frame_err != other.rx_frame_err: return False |
| 1165 | if self.rx_over_err != other.rx_over_err: return False |
| 1166 | if self.rx_crc_err != other.rx_crc_err: return False |
| 1167 | if self.collisions != other.collisions: return False |
| 1168 | return True |
| 1169 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1170 | def pretty_print(self, q): |
| 1171 | q.text("port_stats_entry {") |
| 1172 | with q.group(): |
| 1173 | with q.indent(2): |
| 1174 | q.breakable() |
| 1175 | q.text("port_no = "); |
| 1176 | q.text(util.pretty_port(self.port_no)) |
| 1177 | q.text(","); q.breakable() |
| 1178 | q.text("rx_packets = "); |
| 1179 | q.text("%#x" % self.rx_packets) |
| 1180 | q.text(","); q.breakable() |
| 1181 | q.text("tx_packets = "); |
| 1182 | q.text("%#x" % self.tx_packets) |
| 1183 | q.text(","); q.breakable() |
| 1184 | q.text("rx_bytes = "); |
| 1185 | q.text("%#x" % self.rx_bytes) |
| 1186 | q.text(","); q.breakable() |
| 1187 | q.text("tx_bytes = "); |
| 1188 | q.text("%#x" % self.tx_bytes) |
| 1189 | q.text(","); q.breakable() |
| 1190 | q.text("rx_dropped = "); |
| 1191 | q.text("%#x" % self.rx_dropped) |
| 1192 | q.text(","); q.breakable() |
| 1193 | q.text("tx_dropped = "); |
| 1194 | q.text("%#x" % self.tx_dropped) |
| 1195 | q.text(","); q.breakable() |
| 1196 | q.text("rx_errors = "); |
| 1197 | q.text("%#x" % self.rx_errors) |
| 1198 | q.text(","); q.breakable() |
| 1199 | q.text("tx_errors = "); |
| 1200 | q.text("%#x" % self.tx_errors) |
| 1201 | q.text(","); q.breakable() |
| 1202 | q.text("rx_frame_err = "); |
| 1203 | q.text("%#x" % self.rx_frame_err) |
| 1204 | q.text(","); q.breakable() |
| 1205 | q.text("rx_over_err = "); |
| 1206 | q.text("%#x" % self.rx_over_err) |
| 1207 | q.text(","); q.breakable() |
| 1208 | q.text("rx_crc_err = "); |
| 1209 | q.text("%#x" % self.rx_crc_err) |
| 1210 | q.text(","); q.breakable() |
| 1211 | q.text("collisions = "); |
| 1212 | q.text("%#x" % self.collisions) |
| 1213 | q.breakable() |
| 1214 | q.text('}') |
| 1215 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1216 | |
| 1217 | class queue_prop(loxi.OFObject): |
| 1218 | subtypes = {} |
| 1219 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1220 | |
| 1221 | def __init__(self, type=None): |
| 1222 | if type != None: |
| 1223 | self.type = type |
| 1224 | else: |
| 1225 | self.type = 0 |
| 1226 | return |
| 1227 | |
| 1228 | def pack(self): |
| 1229 | packed = [] |
| 1230 | packed.append(struct.pack("!H", self.type)) |
| 1231 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1232 | packed.append('\x00' * 4) |
| 1233 | length = sum([len(x) for x in packed]) |
| 1234 | packed[1] = struct.pack("!H", length) |
| 1235 | return ''.join(packed) |
| 1236 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1237 | @staticmethod |
| 1238 | def unpack(reader): |
| 1239 | subtype, = reader.peek('!H', 0) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1240 | subclass = queue_prop.subtypes.get(subtype) |
| 1241 | if subclass: |
| 1242 | return subclass.unpack(reader) |
| 1243 | |
| 1244 | obj = queue_prop() |
| 1245 | obj.type = reader.read("!H")[0] |
| 1246 | _len = reader.read("!H")[0] |
| 1247 | orig_reader = reader |
| 1248 | reader = orig_reader.slice(_len - (2 + 2)) |
| 1249 | reader.skip(4) |
| 1250 | return obj |
| 1251 | |
| 1252 | def __eq__(self, other): |
| 1253 | if type(self) != type(other): return False |
| 1254 | if self.type != other.type: return False |
| 1255 | return True |
| 1256 | |
| 1257 | def pretty_print(self, q): |
| 1258 | q.text("queue_prop {") |
| 1259 | with q.group(): |
| 1260 | with q.indent(2): |
| 1261 | q.breakable() |
| 1262 | q.breakable() |
| 1263 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1264 | |
| 1265 | |
| 1266 | class queue_prop_experimenter(queue_prop): |
| 1267 | subtypes = {} |
| 1268 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1269 | type = 65535 |
| 1270 | |
| 1271 | def __init__(self, experimenter=None, data=None): |
| 1272 | if experimenter != None: |
| 1273 | self.experimenter = experimenter |
| 1274 | else: |
| 1275 | self.experimenter = 0 |
| 1276 | if data != None: |
| 1277 | self.data = data |
| 1278 | else: |
| 1279 | self.data = '' |
| 1280 | return |
| 1281 | |
| 1282 | def pack(self): |
| 1283 | packed = [] |
| 1284 | packed.append(struct.pack("!H", self.type)) |
| 1285 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1286 | packed.append('\x00' * 4) |
| 1287 | packed.append(struct.pack("!L", self.experimenter)) |
| 1288 | packed.append('\x00' * 4) |
| 1289 | packed.append(self.data) |
| 1290 | length = sum([len(x) for x in packed]) |
| 1291 | packed[1] = struct.pack("!H", length) |
| 1292 | return ''.join(packed) |
| 1293 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1294 | @staticmethod |
| 1295 | def unpack(reader): |
| 1296 | subtype, = reader.peek('!L', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1297 | subclass = queue_prop_experimenter.subtypes.get(subtype) |
| 1298 | if subclass: |
| 1299 | return subclass.unpack(reader) |
| 1300 | |
| 1301 | obj = queue_prop_experimenter() |
| 1302 | _type = reader.read("!H")[0] |
| 1303 | assert(_type == 65535) |
| 1304 | _len = reader.read("!H")[0] |
| 1305 | orig_reader = reader |
| 1306 | reader = orig_reader.slice(_len - (2 + 2)) |
| 1307 | reader.skip(4) |
| 1308 | obj.experimenter = reader.read("!L")[0] |
| 1309 | reader.skip(4) |
| 1310 | obj.data = str(reader.read_all()) |
| 1311 | return obj |
| 1312 | |
| 1313 | def __eq__(self, other): |
| 1314 | if type(self) != type(other): return False |
| 1315 | if self.experimenter != other.experimenter: return False |
| 1316 | if self.data != other.data: return False |
| 1317 | return True |
| 1318 | |
| 1319 | def pretty_print(self, q): |
| 1320 | q.text("queue_prop_experimenter {") |
| 1321 | with q.group(): |
| 1322 | with q.indent(2): |
| 1323 | q.breakable() |
| 1324 | q.text("data = "); |
| 1325 | q.pp(self.data) |
| 1326 | q.breakable() |
| 1327 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1328 | |
| 1329 | queue_prop.subtypes[65535] = queue_prop_experimenter |
| 1330 | |
| 1331 | class queue_prop_max_rate(queue_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1332 | type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1333 | |
| 1334 | def __init__(self, rate=None): |
| 1335 | if rate != None: |
| 1336 | self.rate = rate |
| 1337 | else: |
| 1338 | self.rate = 0 |
| 1339 | return |
| 1340 | |
| 1341 | def pack(self): |
| 1342 | packed = [] |
| 1343 | packed.append(struct.pack("!H", self.type)) |
| 1344 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1345 | packed.append('\x00' * 4) |
| 1346 | packed.append(struct.pack("!H", self.rate)) |
| 1347 | packed.append('\x00' * 6) |
| 1348 | length = sum([len(x) for x in packed]) |
| 1349 | packed[1] = struct.pack("!H", length) |
| 1350 | return ''.join(packed) |
| 1351 | |
| 1352 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1353 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1354 | obj = queue_prop_max_rate() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1355 | _type = reader.read("!H")[0] |
| 1356 | assert(_type == 2) |
| 1357 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1358 | orig_reader = reader |
| 1359 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1360 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1361 | obj.rate = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1362 | reader.skip(6) |
| 1363 | return obj |
| 1364 | |
| 1365 | def __eq__(self, other): |
| 1366 | if type(self) != type(other): return False |
| 1367 | if self.rate != other.rate: return False |
| 1368 | return True |
| 1369 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1370 | def pretty_print(self, q): |
| 1371 | q.text("queue_prop_max_rate {") |
| 1372 | with q.group(): |
| 1373 | with q.indent(2): |
| 1374 | q.breakable() |
| 1375 | q.text("rate = "); |
| 1376 | q.text("%#x" % self.rate) |
| 1377 | q.breakable() |
| 1378 | q.text('}') |
| 1379 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1380 | queue_prop.subtypes[2] = queue_prop_max_rate |
| 1381 | |
| 1382 | class queue_prop_min_rate(queue_prop): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1383 | type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1384 | |
| 1385 | def __init__(self, rate=None): |
| 1386 | if rate != None: |
| 1387 | self.rate = rate |
| 1388 | else: |
| 1389 | self.rate = 0 |
| 1390 | return |
| 1391 | |
| 1392 | def pack(self): |
| 1393 | packed = [] |
| 1394 | packed.append(struct.pack("!H", self.type)) |
| 1395 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1396 | packed.append('\x00' * 4) |
| 1397 | packed.append(struct.pack("!H", self.rate)) |
| 1398 | packed.append('\x00' * 6) |
| 1399 | length = sum([len(x) for x in packed]) |
| 1400 | packed[1] = struct.pack("!H", length) |
| 1401 | return ''.join(packed) |
| 1402 | |
| 1403 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1404 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1405 | obj = queue_prop_min_rate() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1406 | _type = reader.read("!H")[0] |
| 1407 | assert(_type == 1) |
| 1408 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1409 | orig_reader = reader |
| 1410 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1411 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1412 | obj.rate = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1413 | reader.skip(6) |
| 1414 | return obj |
| 1415 | |
| 1416 | def __eq__(self, other): |
| 1417 | if type(self) != type(other): return False |
| 1418 | if self.rate != other.rate: return False |
| 1419 | return True |
| 1420 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1421 | def pretty_print(self, q): |
| 1422 | q.text("queue_prop_min_rate {") |
| 1423 | with q.group(): |
| 1424 | with q.indent(2): |
| 1425 | q.breakable() |
| 1426 | q.text("rate = "); |
| 1427 | q.text("%#x" % self.rate) |
| 1428 | q.breakable() |
| 1429 | q.text('}') |
| 1430 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1431 | queue_prop.subtypes[1] = queue_prop_min_rate |
| 1432 | |
| 1433 | class queue_stats_entry(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1434 | |
| 1435 | def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None): |
| 1436 | if port_no != None: |
| 1437 | self.port_no = port_no |
| 1438 | else: |
| 1439 | self.port_no = 0 |
| 1440 | if queue_id != None: |
| 1441 | self.queue_id = queue_id |
| 1442 | else: |
| 1443 | self.queue_id = 0 |
| 1444 | if tx_bytes != None: |
| 1445 | self.tx_bytes = tx_bytes |
| 1446 | else: |
| 1447 | self.tx_bytes = 0 |
| 1448 | if tx_packets != None: |
| 1449 | self.tx_packets = tx_packets |
| 1450 | else: |
| 1451 | self.tx_packets = 0 |
| 1452 | if tx_errors != None: |
| 1453 | self.tx_errors = tx_errors |
| 1454 | else: |
| 1455 | self.tx_errors = 0 |
| 1456 | return |
| 1457 | |
| 1458 | def pack(self): |
| 1459 | packed = [] |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1460 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1461 | packed.append(struct.pack("!L", self.queue_id)) |
| 1462 | packed.append(struct.pack("!Q", self.tx_bytes)) |
| 1463 | packed.append(struct.pack("!Q", self.tx_packets)) |
| 1464 | packed.append(struct.pack("!Q", self.tx_errors)) |
| 1465 | return ''.join(packed) |
| 1466 | |
| 1467 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1468 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1469 | obj = queue_stats_entry() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1470 | obj.port_no = util.unpack_port_no(reader) |
| 1471 | obj.queue_id = reader.read("!L")[0] |
| 1472 | obj.tx_bytes = reader.read("!Q")[0] |
| 1473 | obj.tx_packets = reader.read("!Q")[0] |
| 1474 | obj.tx_errors = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1475 | return obj |
| 1476 | |
| 1477 | def __eq__(self, other): |
| 1478 | if type(self) != type(other): return False |
| 1479 | if self.port_no != other.port_no: return False |
| 1480 | if self.queue_id != other.queue_id: return False |
| 1481 | if self.tx_bytes != other.tx_bytes: return False |
| 1482 | if self.tx_packets != other.tx_packets: return False |
| 1483 | if self.tx_errors != other.tx_errors: return False |
| 1484 | return True |
| 1485 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1486 | def pretty_print(self, q): |
| 1487 | q.text("queue_stats_entry {") |
| 1488 | with q.group(): |
| 1489 | with q.indent(2): |
| 1490 | q.breakable() |
| 1491 | q.text("port_no = "); |
| 1492 | q.text(util.pretty_port(self.port_no)) |
| 1493 | q.text(","); q.breakable() |
| 1494 | q.text("queue_id = "); |
| 1495 | q.text("%#x" % self.queue_id) |
| 1496 | q.text(","); q.breakable() |
| 1497 | q.text("tx_bytes = "); |
| 1498 | q.text("%#x" % self.tx_bytes) |
| 1499 | q.text(","); q.breakable() |
| 1500 | q.text("tx_packets = "); |
| 1501 | q.text("%#x" % self.tx_packets) |
| 1502 | q.text(","); q.breakable() |
| 1503 | q.text("tx_errors = "); |
| 1504 | q.text("%#x" % self.tx_errors) |
| 1505 | q.breakable() |
| 1506 | q.text('}') |
| 1507 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1508 | |
| 1509 | class table_stats_entry(loxi.OFObject): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1510 | |
| 1511 | def __init__(self, table_id=None, name=None, match=None, wildcards=None, write_actions=None, apply_actions=None, write_setfields=None, apply_setfields=None, metadata_match=None, metadata_write=None, instructions=None, config=None, max_entries=None, active_count=None, lookup_count=None, matched_count=None): |
| 1512 | if table_id != None: |
| 1513 | self.table_id = table_id |
| 1514 | else: |
| 1515 | self.table_id = 0 |
| 1516 | if name != None: |
| 1517 | self.name = name |
| 1518 | else: |
| 1519 | self.name = "" |
| 1520 | if match != None: |
| 1521 | self.match = match |
| 1522 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1523 | self.match = util.init_match_bmap() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1524 | if wildcards != None: |
| 1525 | self.wildcards = wildcards |
| 1526 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1527 | self.wildcards = util.init_wc_bmap() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1528 | if write_actions != None: |
| 1529 | self.write_actions = write_actions |
| 1530 | else: |
| 1531 | self.write_actions = 0 |
| 1532 | if apply_actions != None: |
| 1533 | self.apply_actions = apply_actions |
| 1534 | else: |
| 1535 | self.apply_actions = 0 |
| 1536 | if write_setfields != None: |
| 1537 | self.write_setfields = write_setfields |
| 1538 | else: |
| 1539 | self.write_setfields = 0 |
| 1540 | if apply_setfields != None: |
| 1541 | self.apply_setfields = apply_setfields |
| 1542 | else: |
| 1543 | self.apply_setfields = 0 |
| 1544 | if metadata_match != None: |
| 1545 | self.metadata_match = metadata_match |
| 1546 | else: |
| 1547 | self.metadata_match = 0 |
| 1548 | if metadata_write != None: |
| 1549 | self.metadata_write = metadata_write |
| 1550 | else: |
| 1551 | self.metadata_write = 0 |
| 1552 | if instructions != None: |
| 1553 | self.instructions = instructions |
| 1554 | else: |
| 1555 | self.instructions = 0 |
| 1556 | if config != None: |
| 1557 | self.config = config |
| 1558 | else: |
| 1559 | self.config = 0 |
| 1560 | if max_entries != None: |
| 1561 | self.max_entries = max_entries |
| 1562 | else: |
| 1563 | self.max_entries = 0 |
| 1564 | if active_count != None: |
| 1565 | self.active_count = active_count |
| 1566 | else: |
| 1567 | self.active_count = 0 |
| 1568 | if lookup_count != None: |
| 1569 | self.lookup_count = lookup_count |
| 1570 | else: |
| 1571 | self.lookup_count = 0 |
| 1572 | if matched_count != None: |
| 1573 | self.matched_count = matched_count |
| 1574 | else: |
| 1575 | self.matched_count = 0 |
| 1576 | return |
| 1577 | |
| 1578 | def pack(self): |
| 1579 | packed = [] |
| 1580 | packed.append(struct.pack("!B", self.table_id)) |
| 1581 | packed.append('\x00' * 7) |
| 1582 | packed.append(struct.pack("!32s", self.name)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1583 | packed.append(util.pack_match_bmap(self.match)) |
| 1584 | packed.append(util.pack_wc_bmap(self.wildcards)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1585 | packed.append(struct.pack("!L", self.write_actions)) |
| 1586 | packed.append(struct.pack("!L", self.apply_actions)) |
| 1587 | packed.append(struct.pack("!Q", self.write_setfields)) |
| 1588 | packed.append(struct.pack("!Q", self.apply_setfields)) |
| 1589 | packed.append(struct.pack("!Q", self.metadata_match)) |
| 1590 | packed.append(struct.pack("!Q", self.metadata_write)) |
| 1591 | packed.append(struct.pack("!L", self.instructions)) |
| 1592 | packed.append(struct.pack("!L", self.config)) |
| 1593 | packed.append(struct.pack("!L", self.max_entries)) |
| 1594 | packed.append(struct.pack("!L", self.active_count)) |
| 1595 | packed.append(struct.pack("!Q", self.lookup_count)) |
| 1596 | packed.append(struct.pack("!Q", self.matched_count)) |
| 1597 | return ''.join(packed) |
| 1598 | |
| 1599 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1600 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1601 | obj = table_stats_entry() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1602 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1603 | reader.skip(7) |
| 1604 | obj.name = reader.read("!32s")[0].rstrip("\x00") |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1605 | obj.match = util.unpack_match_bmap(reader) |
| 1606 | obj.wildcards = util.unpack_wc_bmap(reader) |
| 1607 | obj.write_actions = reader.read("!L")[0] |
| 1608 | obj.apply_actions = reader.read("!L")[0] |
| 1609 | obj.write_setfields = reader.read("!Q")[0] |
| 1610 | obj.apply_setfields = reader.read("!Q")[0] |
| 1611 | obj.metadata_match = reader.read("!Q")[0] |
| 1612 | obj.metadata_write = reader.read("!Q")[0] |
| 1613 | obj.instructions = reader.read("!L")[0] |
| 1614 | obj.config = reader.read("!L")[0] |
| 1615 | obj.max_entries = reader.read("!L")[0] |
| 1616 | obj.active_count = reader.read("!L")[0] |
| 1617 | obj.lookup_count = reader.read("!Q")[0] |
| 1618 | obj.matched_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1619 | return obj |
| 1620 | |
| 1621 | def __eq__(self, other): |
| 1622 | if type(self) != type(other): return False |
| 1623 | if self.table_id != other.table_id: return False |
| 1624 | if self.name != other.name: return False |
| 1625 | if self.match != other.match: return False |
| 1626 | if self.wildcards != other.wildcards: return False |
| 1627 | if self.write_actions != other.write_actions: return False |
| 1628 | if self.apply_actions != other.apply_actions: return False |
| 1629 | if self.write_setfields != other.write_setfields: return False |
| 1630 | if self.apply_setfields != other.apply_setfields: return False |
| 1631 | if self.metadata_match != other.metadata_match: return False |
| 1632 | if self.metadata_write != other.metadata_write: return False |
| 1633 | if self.instructions != other.instructions: return False |
| 1634 | if self.config != other.config: return False |
| 1635 | if self.max_entries != other.max_entries: return False |
| 1636 | if self.active_count != other.active_count: return False |
| 1637 | if self.lookup_count != other.lookup_count: return False |
| 1638 | if self.matched_count != other.matched_count: return False |
| 1639 | return True |
| 1640 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1641 | def pretty_print(self, q): |
| 1642 | q.text("table_stats_entry {") |
| 1643 | with q.group(): |
| 1644 | with q.indent(2): |
| 1645 | q.breakable() |
| 1646 | q.text("table_id = "); |
| 1647 | q.text("%#x" % self.table_id) |
| 1648 | q.text(","); q.breakable() |
| 1649 | q.text("name = "); |
| 1650 | q.pp(self.name) |
| 1651 | q.text(","); q.breakable() |
| 1652 | q.text("match = "); |
| 1653 | q.pp(self.match) |
| 1654 | q.text(","); q.breakable() |
| 1655 | q.text("wildcards = "); |
| 1656 | q.pp(self.wildcards) |
| 1657 | q.text(","); q.breakable() |
| 1658 | q.text("write_actions = "); |
| 1659 | q.text("%#x" % self.write_actions) |
| 1660 | q.text(","); q.breakable() |
| 1661 | q.text("apply_actions = "); |
| 1662 | q.text("%#x" % self.apply_actions) |
| 1663 | q.text(","); q.breakable() |
| 1664 | q.text("write_setfields = "); |
| 1665 | q.text("%#x" % self.write_setfields) |
| 1666 | q.text(","); q.breakable() |
| 1667 | q.text("apply_setfields = "); |
| 1668 | q.text("%#x" % self.apply_setfields) |
| 1669 | q.text(","); q.breakable() |
| 1670 | q.text("metadata_match = "); |
| 1671 | q.text("%#x" % self.metadata_match) |
| 1672 | q.text(","); q.breakable() |
| 1673 | q.text("metadata_write = "); |
| 1674 | q.text("%#x" % self.metadata_write) |
| 1675 | q.text(","); q.breakable() |
| 1676 | q.text("instructions = "); |
| 1677 | q.text("%#x" % self.instructions) |
| 1678 | q.text(","); q.breakable() |
| 1679 | q.text("config = "); |
| 1680 | q.text("%#x" % self.config) |
| 1681 | q.text(","); q.breakable() |
| 1682 | q.text("max_entries = "); |
| 1683 | q.text("%#x" % self.max_entries) |
| 1684 | q.text(","); q.breakable() |
| 1685 | q.text("active_count = "); |
| 1686 | q.text("%#x" % self.active_count) |
| 1687 | q.text(","); q.breakable() |
| 1688 | q.text("lookup_count = "); |
| 1689 | q.text("%#x" % self.lookup_count) |
| 1690 | q.text(","); q.breakable() |
| 1691 | q.text("matched_count = "); |
| 1692 | q.text("%#x" % self.matched_count) |
| 1693 | q.breakable() |
| 1694 | q.text('}') |
| 1695 | |
| 1696 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1697 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1698 | match = match_v3 |