Zack Williams | 41513bf | 2018-07-07 20:08:35 -0700 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
Nathan Knuth | 418fdc8 | 2016-09-16 22:51:15 -0700 | [diff] [blame] | 14 | # Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 15 | # Copyright (c) 2011, 2012 Open Networking Foundation |
| 16 | # Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
| 17 | # See the file LICENSE.pyloxi which should have been included in the source distribution |
| 18 | |
| 19 | # Automatically generated by LOXI from template module.py |
| 20 | # Do not modify |
| 21 | |
| 22 | import struct |
| 23 | import loxi |
| 24 | import util |
| 25 | import loxi.generic_util |
| 26 | |
| 27 | import sys |
| 28 | ofp = sys.modules['loxi.of10'] |
| 29 | |
| 30 | class bsn_interface(loxi.OFObject): |
| 31 | |
| 32 | def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None): |
| 33 | if hw_addr != None: |
| 34 | self.hw_addr = hw_addr |
| 35 | else: |
| 36 | self.hw_addr = [0,0,0,0,0,0] |
| 37 | if name != None: |
| 38 | self.name = name |
| 39 | else: |
| 40 | self.name = "" |
| 41 | if ipv4_addr != None: |
| 42 | self.ipv4_addr = ipv4_addr |
| 43 | else: |
| 44 | self.ipv4_addr = 0 |
| 45 | if ipv4_netmask != None: |
| 46 | self.ipv4_netmask = ipv4_netmask |
| 47 | else: |
| 48 | self.ipv4_netmask = 0 |
| 49 | return |
| 50 | |
| 51 | def pack(self): |
| 52 | packed = [] |
| 53 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 54 | packed.append('\x00' * 2) |
| 55 | packed.append(struct.pack("!16s", self.name)) |
| 56 | packed.append(struct.pack("!L", self.ipv4_addr)) |
| 57 | packed.append(struct.pack("!L", self.ipv4_netmask)) |
| 58 | return ''.join(packed) |
| 59 | |
| 60 | @staticmethod |
| 61 | def unpack(reader): |
| 62 | obj = bsn_interface() |
| 63 | obj.hw_addr = list(reader.read('!6B')) |
| 64 | reader.skip(2) |
| 65 | obj.name = reader.read("!16s")[0].rstrip("\x00") |
| 66 | obj.ipv4_addr = reader.read("!L")[0] |
| 67 | obj.ipv4_netmask = reader.read("!L")[0] |
| 68 | return obj |
| 69 | |
| 70 | def __eq__(self, other): |
| 71 | if type(self) != type(other): return False |
| 72 | if self.hw_addr != other.hw_addr: return False |
| 73 | if self.name != other.name: return False |
| 74 | if self.ipv4_addr != other.ipv4_addr: return False |
| 75 | if self.ipv4_netmask != other.ipv4_netmask: return False |
| 76 | return True |
| 77 | |
| 78 | def pretty_print(self, q): |
| 79 | q.text("bsn_interface {") |
| 80 | with q.group(): |
| 81 | with q.indent(2): |
| 82 | q.breakable() |
| 83 | q.text("hw_addr = "); |
| 84 | q.text(util.pretty_mac(self.hw_addr)) |
| 85 | q.text(","); q.breakable() |
| 86 | q.text("name = "); |
| 87 | q.pp(self.name) |
| 88 | q.text(","); q.breakable() |
| 89 | q.text("ipv4_addr = "); |
| 90 | q.text(util.pretty_ipv4(self.ipv4_addr)) |
| 91 | q.text(","); q.breakable() |
| 92 | q.text("ipv4_netmask = "); |
| 93 | q.text(util.pretty_ipv4(self.ipv4_netmask)) |
| 94 | q.breakable() |
| 95 | q.text('}') |
| 96 | |
| 97 | |
| 98 | class bsn_vport(loxi.OFObject): |
| 99 | subtypes = {} |
| 100 | |
| 101 | |
| 102 | def __init__(self, type=None): |
| 103 | if type != None: |
| 104 | self.type = type |
| 105 | else: |
| 106 | self.type = 0 |
| 107 | return |
| 108 | |
| 109 | def pack(self): |
| 110 | packed = [] |
| 111 | packed.append(struct.pack("!H", self.type)) |
| 112 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 113 | length = sum([len(x) for x in packed]) |
| 114 | packed[1] = struct.pack("!H", length) |
| 115 | return ''.join(packed) |
| 116 | |
| 117 | @staticmethod |
| 118 | def unpack(reader): |
| 119 | subtype, = reader.peek('!H', 0) |
| 120 | subclass = bsn_vport.subtypes.get(subtype) |
| 121 | if subclass: |
| 122 | return subclass.unpack(reader) |
| 123 | |
| 124 | obj = bsn_vport() |
| 125 | obj.type = reader.read("!H")[0] |
| 126 | _length = reader.read("!H")[0] |
| 127 | orig_reader = reader |
| 128 | reader = orig_reader.slice(_length, 4) |
| 129 | return obj |
| 130 | |
| 131 | def __eq__(self, other): |
| 132 | if type(self) != type(other): return False |
| 133 | if self.type != other.type: return False |
| 134 | return True |
| 135 | |
| 136 | def pretty_print(self, q): |
| 137 | q.text("bsn_vport {") |
| 138 | with q.group(): |
| 139 | with q.indent(2): |
| 140 | q.breakable() |
| 141 | q.breakable() |
| 142 | q.text('}') |
| 143 | |
| 144 | |
| 145 | class bsn_vport_l2gre(bsn_vport): |
| 146 | type = 1 |
| 147 | |
| 148 | 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): |
| 149 | if flags != None: |
| 150 | self.flags = flags |
| 151 | else: |
| 152 | self.flags = 0 |
| 153 | if port_no != None: |
| 154 | self.port_no = port_no |
| 155 | else: |
| 156 | self.port_no = 0 |
| 157 | if loopback_port_no != None: |
| 158 | self.loopback_port_no = loopback_port_no |
| 159 | else: |
| 160 | self.loopback_port_no = 0 |
| 161 | if local_mac != None: |
| 162 | self.local_mac = local_mac |
| 163 | else: |
| 164 | self.local_mac = [0,0,0,0,0,0] |
| 165 | if nh_mac != None: |
| 166 | self.nh_mac = nh_mac |
| 167 | else: |
| 168 | self.nh_mac = [0,0,0,0,0,0] |
| 169 | if src_ip != None: |
| 170 | self.src_ip = src_ip |
| 171 | else: |
| 172 | self.src_ip = 0 |
| 173 | if dst_ip != None: |
| 174 | self.dst_ip = dst_ip |
| 175 | else: |
| 176 | self.dst_ip = 0 |
| 177 | if dscp != None: |
| 178 | self.dscp = dscp |
| 179 | else: |
| 180 | self.dscp = 0 |
| 181 | if ttl != None: |
| 182 | self.ttl = ttl |
| 183 | else: |
| 184 | self.ttl = 0 |
| 185 | if vpn != None: |
| 186 | self.vpn = vpn |
| 187 | else: |
| 188 | self.vpn = 0 |
| 189 | if rate_limit != None: |
| 190 | self.rate_limit = rate_limit |
| 191 | else: |
| 192 | self.rate_limit = 0 |
| 193 | if if_name != None: |
| 194 | self.if_name = if_name |
| 195 | else: |
| 196 | self.if_name = "" |
| 197 | return |
| 198 | |
| 199 | def pack(self): |
| 200 | packed = [] |
| 201 | packed.append(struct.pack("!H", self.type)) |
| 202 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 203 | packed.append(struct.pack("!L", self.flags)) |
| 204 | packed.append(util.pack_port_no(self.port_no)) |
| 205 | packed.append(util.pack_port_no(self.loopback_port_no)) |
| 206 | packed.append(struct.pack("!6B", *self.local_mac)) |
| 207 | packed.append(struct.pack("!6B", *self.nh_mac)) |
| 208 | packed.append(struct.pack("!L", self.src_ip)) |
| 209 | packed.append(struct.pack("!L", self.dst_ip)) |
| 210 | packed.append(struct.pack("!B", self.dscp)) |
| 211 | packed.append(struct.pack("!B", self.ttl)) |
| 212 | packed.append('\x00' * 2) |
| 213 | packed.append(struct.pack("!L", self.vpn)) |
| 214 | packed.append(struct.pack("!L", self.rate_limit)) |
| 215 | packed.append(struct.pack("!16s", self.if_name)) |
| 216 | length = sum([len(x) for x in packed]) |
| 217 | packed[1] = struct.pack("!H", length) |
| 218 | return ''.join(packed) |
| 219 | |
| 220 | @staticmethod |
| 221 | def unpack(reader): |
| 222 | obj = bsn_vport_l2gre() |
| 223 | _type = reader.read("!H")[0] |
| 224 | assert(_type == 1) |
| 225 | _length = reader.read("!H")[0] |
| 226 | orig_reader = reader |
| 227 | reader = orig_reader.slice(_length, 4) |
| 228 | obj.flags = reader.read("!L")[0] |
| 229 | obj.port_no = util.unpack_port_no(reader) |
| 230 | obj.loopback_port_no = util.unpack_port_no(reader) |
| 231 | obj.local_mac = list(reader.read('!6B')) |
| 232 | obj.nh_mac = list(reader.read('!6B')) |
| 233 | obj.src_ip = reader.read("!L")[0] |
| 234 | obj.dst_ip = reader.read("!L")[0] |
| 235 | obj.dscp = reader.read("!B")[0] |
| 236 | obj.ttl = reader.read("!B")[0] |
| 237 | reader.skip(2) |
| 238 | obj.vpn = reader.read("!L")[0] |
| 239 | obj.rate_limit = reader.read("!L")[0] |
| 240 | obj.if_name = reader.read("!16s")[0].rstrip("\x00") |
| 241 | return obj |
| 242 | |
| 243 | def __eq__(self, other): |
| 244 | if type(self) != type(other): return False |
| 245 | if self.flags != other.flags: return False |
| 246 | if self.port_no != other.port_no: return False |
| 247 | if self.loopback_port_no != other.loopback_port_no: return False |
| 248 | if self.local_mac != other.local_mac: return False |
| 249 | if self.nh_mac != other.nh_mac: return False |
| 250 | if self.src_ip != other.src_ip: return False |
| 251 | if self.dst_ip != other.dst_ip: return False |
| 252 | if self.dscp != other.dscp: return False |
| 253 | if self.ttl != other.ttl: return False |
| 254 | if self.vpn != other.vpn: return False |
| 255 | if self.rate_limit != other.rate_limit: return False |
| 256 | if self.if_name != other.if_name: return False |
| 257 | return True |
| 258 | |
| 259 | def pretty_print(self, q): |
| 260 | q.text("bsn_vport_l2gre {") |
| 261 | with q.group(): |
| 262 | with q.indent(2): |
| 263 | q.breakable() |
| 264 | q.text("flags = "); |
| 265 | q.text("%#x" % self.flags) |
| 266 | q.text(","); q.breakable() |
| 267 | q.text("port_no = "); |
| 268 | q.text(util.pretty_port(self.port_no)) |
| 269 | q.text(","); q.breakable() |
| 270 | q.text("loopback_port_no = "); |
| 271 | q.text(util.pretty_port(self.loopback_port_no)) |
| 272 | q.text(","); q.breakable() |
| 273 | q.text("local_mac = "); |
| 274 | q.text(util.pretty_mac(self.local_mac)) |
| 275 | q.text(","); q.breakable() |
| 276 | q.text("nh_mac = "); |
| 277 | q.text(util.pretty_mac(self.nh_mac)) |
| 278 | q.text(","); q.breakable() |
| 279 | q.text("src_ip = "); |
| 280 | q.text(util.pretty_ipv4(self.src_ip)) |
| 281 | q.text(","); q.breakable() |
| 282 | q.text("dst_ip = "); |
| 283 | q.text(util.pretty_ipv4(self.dst_ip)) |
| 284 | q.text(","); q.breakable() |
| 285 | q.text("dscp = "); |
| 286 | q.text("%#x" % self.dscp) |
| 287 | q.text(","); q.breakable() |
| 288 | q.text("ttl = "); |
| 289 | q.text("%#x" % self.ttl) |
| 290 | q.text(","); q.breakable() |
| 291 | q.text("vpn = "); |
| 292 | q.text("%#x" % self.vpn) |
| 293 | q.text(","); q.breakable() |
| 294 | q.text("rate_limit = "); |
| 295 | q.text("%#x" % self.rate_limit) |
| 296 | q.text(","); q.breakable() |
| 297 | q.text("if_name = "); |
| 298 | q.pp(self.if_name) |
| 299 | q.breakable() |
| 300 | q.text('}') |
| 301 | |
| 302 | bsn_vport.subtypes[1] = bsn_vport_l2gre |
| 303 | |
| 304 | class bsn_vport_q_in_q(bsn_vport): |
| 305 | type = 0 |
| 306 | |
| 307 | def __init__(self, port_no=None, ingress_tpid=None, ingress_vlan_id=None, egress_tpid=None, egress_vlan_id=None, if_name=None): |
| 308 | if port_no != None: |
| 309 | self.port_no = port_no |
| 310 | else: |
| 311 | self.port_no = 0 |
| 312 | if ingress_tpid != None: |
| 313 | self.ingress_tpid = ingress_tpid |
| 314 | else: |
| 315 | self.ingress_tpid = 0 |
| 316 | if ingress_vlan_id != None: |
| 317 | self.ingress_vlan_id = ingress_vlan_id |
| 318 | else: |
| 319 | self.ingress_vlan_id = 0 |
| 320 | if egress_tpid != None: |
| 321 | self.egress_tpid = egress_tpid |
| 322 | else: |
| 323 | self.egress_tpid = 0 |
| 324 | if egress_vlan_id != None: |
| 325 | self.egress_vlan_id = egress_vlan_id |
| 326 | else: |
| 327 | self.egress_vlan_id = 0 |
| 328 | if if_name != None: |
| 329 | self.if_name = if_name |
| 330 | else: |
| 331 | self.if_name = "" |
| 332 | return |
| 333 | |
| 334 | def pack(self): |
| 335 | packed = [] |
| 336 | packed.append(struct.pack("!H", self.type)) |
| 337 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 338 | packed.append(struct.pack("!L", self.port_no)) |
| 339 | packed.append(struct.pack("!H", self.ingress_tpid)) |
| 340 | packed.append(struct.pack("!H", self.ingress_vlan_id)) |
| 341 | packed.append(struct.pack("!H", self.egress_tpid)) |
| 342 | packed.append(struct.pack("!H", self.egress_vlan_id)) |
| 343 | packed.append(struct.pack("!16s", self.if_name)) |
| 344 | length = sum([len(x) for x in packed]) |
| 345 | packed[1] = struct.pack("!H", length) |
| 346 | return ''.join(packed) |
| 347 | |
| 348 | @staticmethod |
| 349 | def unpack(reader): |
| 350 | obj = bsn_vport_q_in_q() |
| 351 | _type = reader.read("!H")[0] |
| 352 | assert(_type == 0) |
| 353 | _length = reader.read("!H")[0] |
| 354 | orig_reader = reader |
| 355 | reader = orig_reader.slice(_length, 4) |
| 356 | obj.port_no = reader.read("!L")[0] |
| 357 | obj.ingress_tpid = reader.read("!H")[0] |
| 358 | obj.ingress_vlan_id = reader.read("!H")[0] |
| 359 | obj.egress_tpid = reader.read("!H")[0] |
| 360 | obj.egress_vlan_id = reader.read("!H")[0] |
| 361 | obj.if_name = reader.read("!16s")[0].rstrip("\x00") |
| 362 | return obj |
| 363 | |
| 364 | def __eq__(self, other): |
| 365 | if type(self) != type(other): return False |
| 366 | if self.port_no != other.port_no: return False |
| 367 | if self.ingress_tpid != other.ingress_tpid: return False |
| 368 | if self.ingress_vlan_id != other.ingress_vlan_id: return False |
| 369 | if self.egress_tpid != other.egress_tpid: return False |
| 370 | if self.egress_vlan_id != other.egress_vlan_id: return False |
| 371 | if self.if_name != other.if_name: return False |
| 372 | return True |
| 373 | |
| 374 | def pretty_print(self, q): |
| 375 | q.text("bsn_vport_q_in_q {") |
| 376 | with q.group(): |
| 377 | with q.indent(2): |
| 378 | q.breakable() |
| 379 | q.text("port_no = "); |
| 380 | q.text("%#x" % self.port_no) |
| 381 | q.text(","); q.breakable() |
| 382 | q.text("ingress_tpid = "); |
| 383 | q.text("%#x" % self.ingress_tpid) |
| 384 | q.text(","); q.breakable() |
| 385 | q.text("ingress_vlan_id = "); |
| 386 | q.text("%#x" % self.ingress_vlan_id) |
| 387 | q.text(","); q.breakable() |
| 388 | q.text("egress_tpid = "); |
| 389 | q.text("%#x" % self.egress_tpid) |
| 390 | q.text(","); q.breakable() |
| 391 | q.text("egress_vlan_id = "); |
| 392 | q.text("%#x" % self.egress_vlan_id) |
| 393 | q.text(","); q.breakable() |
| 394 | q.text("if_name = "); |
| 395 | q.pp(self.if_name) |
| 396 | q.breakable() |
| 397 | q.text('}') |
| 398 | |
| 399 | bsn_vport.subtypes[0] = bsn_vport_q_in_q |
| 400 | |
| 401 | class flow_stats_entry(loxi.OFObject): |
| 402 | |
| 403 | def __init__(self, table_id=None, match=None, duration_sec=None, duration_nsec=None, priority=None, idle_timeout=None, hard_timeout=None, cookie=None, packet_count=None, byte_count=None, actions=None): |
| 404 | if table_id != None: |
| 405 | self.table_id = table_id |
| 406 | else: |
| 407 | self.table_id = 0 |
| 408 | if match != None: |
| 409 | self.match = match |
| 410 | else: |
| 411 | self.match = ofp.match() |
| 412 | if duration_sec != None: |
| 413 | self.duration_sec = duration_sec |
| 414 | else: |
| 415 | self.duration_sec = 0 |
| 416 | if duration_nsec != None: |
| 417 | self.duration_nsec = duration_nsec |
| 418 | else: |
| 419 | self.duration_nsec = 0 |
| 420 | if priority != None: |
| 421 | self.priority = priority |
| 422 | else: |
| 423 | self.priority = 0 |
| 424 | if idle_timeout != None: |
| 425 | self.idle_timeout = idle_timeout |
| 426 | else: |
| 427 | self.idle_timeout = 0 |
| 428 | if hard_timeout != None: |
| 429 | self.hard_timeout = hard_timeout |
| 430 | else: |
| 431 | self.hard_timeout = 0 |
| 432 | if cookie != None: |
| 433 | self.cookie = cookie |
| 434 | else: |
| 435 | self.cookie = 0 |
| 436 | if packet_count != None: |
| 437 | self.packet_count = packet_count |
| 438 | else: |
| 439 | self.packet_count = 0 |
| 440 | if byte_count != None: |
| 441 | self.byte_count = byte_count |
| 442 | else: |
| 443 | self.byte_count = 0 |
| 444 | if actions != None: |
| 445 | self.actions = actions |
| 446 | else: |
| 447 | self.actions = [] |
| 448 | return |
| 449 | |
| 450 | def pack(self): |
| 451 | packed = [] |
| 452 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 0 |
| 453 | packed.append(struct.pack("!B", self.table_id)) |
| 454 | packed.append('\x00' * 1) |
| 455 | packed.append(self.match.pack()) |
| 456 | packed.append(struct.pack("!L", self.duration_sec)) |
| 457 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 458 | packed.append(struct.pack("!H", self.priority)) |
| 459 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 460 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 461 | packed.append('\x00' * 6) |
| 462 | packed.append(struct.pack("!Q", self.cookie)) |
| 463 | packed.append(struct.pack("!Q", self.packet_count)) |
| 464 | packed.append(struct.pack("!Q", self.byte_count)) |
| 465 | packed.append(loxi.generic_util.pack_list(self.actions)) |
| 466 | length = sum([len(x) for x in packed]) |
| 467 | packed[0] = struct.pack("!H", length) |
| 468 | return ''.join(packed) |
| 469 | |
| 470 | @staticmethod |
| 471 | def unpack(reader): |
| 472 | obj = flow_stats_entry() |
| 473 | _length = reader.read("!H")[0] |
| 474 | orig_reader = reader |
| 475 | reader = orig_reader.slice(_length, 2) |
| 476 | obj.table_id = reader.read("!B")[0] |
| 477 | reader.skip(1) |
| 478 | obj.match = ofp.match.unpack(reader) |
| 479 | obj.duration_sec = reader.read("!L")[0] |
| 480 | obj.duration_nsec = reader.read("!L")[0] |
| 481 | obj.priority = reader.read("!H")[0] |
| 482 | obj.idle_timeout = reader.read("!H")[0] |
| 483 | obj.hard_timeout = reader.read("!H")[0] |
| 484 | reader.skip(6) |
| 485 | obj.cookie = reader.read("!Q")[0] |
| 486 | obj.packet_count = reader.read("!Q")[0] |
| 487 | obj.byte_count = reader.read("!Q")[0] |
| 488 | obj.actions = loxi.generic_util.unpack_list(reader, ofp.action.action.unpack) |
| 489 | return obj |
| 490 | |
| 491 | def __eq__(self, other): |
| 492 | if type(self) != type(other): return False |
| 493 | if self.table_id != other.table_id: return False |
| 494 | if self.match != other.match: return False |
| 495 | if self.duration_sec != other.duration_sec: return False |
| 496 | if self.duration_nsec != other.duration_nsec: return False |
| 497 | if self.priority != other.priority: return False |
| 498 | if self.idle_timeout != other.idle_timeout: return False |
| 499 | if self.hard_timeout != other.hard_timeout: return False |
| 500 | if self.cookie != other.cookie: return False |
| 501 | if self.packet_count != other.packet_count: return False |
| 502 | if self.byte_count != other.byte_count: return False |
| 503 | if self.actions != other.actions: return False |
| 504 | return True |
| 505 | |
| 506 | def pretty_print(self, q): |
| 507 | q.text("flow_stats_entry {") |
| 508 | with q.group(): |
| 509 | with q.indent(2): |
| 510 | q.breakable() |
| 511 | q.text("table_id = "); |
| 512 | q.text("%#x" % self.table_id) |
| 513 | q.text(","); q.breakable() |
| 514 | q.text("match = "); |
| 515 | q.pp(self.match) |
| 516 | q.text(","); q.breakable() |
| 517 | q.text("duration_sec = "); |
| 518 | q.text("%#x" % self.duration_sec) |
| 519 | q.text(","); q.breakable() |
| 520 | q.text("duration_nsec = "); |
| 521 | q.text("%#x" % self.duration_nsec) |
| 522 | q.text(","); q.breakable() |
| 523 | q.text("priority = "); |
| 524 | q.text("%#x" % self.priority) |
| 525 | q.text(","); q.breakable() |
| 526 | q.text("idle_timeout = "); |
| 527 | q.text("%#x" % self.idle_timeout) |
| 528 | q.text(","); q.breakable() |
| 529 | q.text("hard_timeout = "); |
| 530 | q.text("%#x" % self.hard_timeout) |
| 531 | q.text(","); q.breakable() |
| 532 | q.text("cookie = "); |
| 533 | q.text("%#x" % self.cookie) |
| 534 | q.text(","); q.breakable() |
| 535 | q.text("packet_count = "); |
| 536 | q.text("%#x" % self.packet_count) |
| 537 | q.text(","); q.breakable() |
| 538 | q.text("byte_count = "); |
| 539 | q.text("%#x" % self.byte_count) |
| 540 | q.text(","); q.breakable() |
| 541 | q.text("actions = "); |
| 542 | q.pp(self.actions) |
| 543 | q.breakable() |
| 544 | q.text('}') |
| 545 | |
| 546 | |
| 547 | class match_v1(loxi.OFObject): |
| 548 | |
| 549 | def __init__(self, wildcards=None, in_port=None, eth_src=None, eth_dst=None, vlan_vid=None, vlan_pcp=None, eth_type=None, ip_dscp=None, ip_proto=None, ipv4_src=None, ipv4_dst=None, tcp_src=None, tcp_dst=None): |
| 550 | if wildcards != None: |
| 551 | self.wildcards = wildcards |
| 552 | else: |
| 553 | self.wildcards = util.init_wc_bmap() |
| 554 | if in_port != None: |
| 555 | self.in_port = in_port |
| 556 | else: |
| 557 | self.in_port = 0 |
| 558 | if eth_src != None: |
| 559 | self.eth_src = eth_src |
| 560 | else: |
| 561 | self.eth_src = [0,0,0,0,0,0] |
| 562 | if eth_dst != None: |
| 563 | self.eth_dst = eth_dst |
| 564 | else: |
| 565 | self.eth_dst = [0,0,0,0,0,0] |
| 566 | if vlan_vid != None: |
| 567 | self.vlan_vid = vlan_vid |
| 568 | else: |
| 569 | self.vlan_vid = 0 |
| 570 | if vlan_pcp != None: |
| 571 | self.vlan_pcp = vlan_pcp |
| 572 | else: |
| 573 | self.vlan_pcp = 0 |
| 574 | if eth_type != None: |
| 575 | self.eth_type = eth_type |
| 576 | else: |
| 577 | self.eth_type = 0 |
| 578 | if ip_dscp != None: |
| 579 | self.ip_dscp = ip_dscp |
| 580 | else: |
| 581 | self.ip_dscp = 0 |
| 582 | if ip_proto != None: |
| 583 | self.ip_proto = ip_proto |
| 584 | else: |
| 585 | self.ip_proto = 0 |
| 586 | if ipv4_src != None: |
| 587 | self.ipv4_src = ipv4_src |
| 588 | else: |
| 589 | self.ipv4_src = 0 |
| 590 | if ipv4_dst != None: |
| 591 | self.ipv4_dst = ipv4_dst |
| 592 | else: |
| 593 | self.ipv4_dst = 0 |
| 594 | if tcp_src != None: |
| 595 | self.tcp_src = tcp_src |
| 596 | else: |
| 597 | self.tcp_src = 0 |
| 598 | if tcp_dst != None: |
| 599 | self.tcp_dst = tcp_dst |
| 600 | else: |
| 601 | self.tcp_dst = 0 |
| 602 | return |
| 603 | |
| 604 | def pack(self): |
| 605 | packed = [] |
| 606 | packed.append(util.pack_wc_bmap(self.wildcards)) |
| 607 | packed.append(util.pack_port_no(self.in_port)) |
| 608 | packed.append(struct.pack("!6B", *self.eth_src)) |
| 609 | packed.append(struct.pack("!6B", *self.eth_dst)) |
| 610 | packed.append(struct.pack("!H", self.vlan_vid)) |
| 611 | packed.append(struct.pack("!B", self.vlan_pcp)) |
| 612 | packed.append('\x00' * 1) |
| 613 | packed.append(struct.pack("!H", self.eth_type)) |
| 614 | packed.append(struct.pack("!B", self.ip_dscp)) |
| 615 | packed.append(struct.pack("!B", self.ip_proto)) |
| 616 | packed.append('\x00' * 2) |
| 617 | packed.append(struct.pack("!L", self.ipv4_src)) |
| 618 | packed.append(struct.pack("!L", self.ipv4_dst)) |
| 619 | packed.append(struct.pack("!H", self.tcp_src)) |
| 620 | packed.append(struct.pack("!H", self.tcp_dst)) |
| 621 | return ''.join(packed) |
| 622 | |
| 623 | @staticmethod |
| 624 | def unpack(reader): |
| 625 | obj = match_v1() |
| 626 | obj.wildcards = util.unpack_wc_bmap(reader) |
| 627 | obj.in_port = util.unpack_port_no(reader) |
| 628 | obj.eth_src = list(reader.read('!6B')) |
| 629 | obj.eth_dst = list(reader.read('!6B')) |
| 630 | obj.vlan_vid = reader.read("!H")[0] |
| 631 | obj.vlan_pcp = reader.read("!B")[0] |
| 632 | reader.skip(1) |
| 633 | obj.eth_type = reader.read("!H")[0] |
| 634 | obj.ip_dscp = reader.read("!B")[0] |
| 635 | obj.ip_proto = reader.read("!B")[0] |
| 636 | reader.skip(2) |
| 637 | obj.ipv4_src = reader.read("!L")[0] |
| 638 | obj.ipv4_dst = reader.read("!L")[0] |
| 639 | obj.tcp_src = reader.read("!H")[0] |
| 640 | obj.tcp_dst = reader.read("!H")[0] |
| 641 | return obj |
| 642 | |
| 643 | def __eq__(self, other): |
| 644 | if type(self) != type(other): return False |
| 645 | if self.wildcards != other.wildcards: return False |
| 646 | if self.in_port != other.in_port: return False |
| 647 | if self.eth_src != other.eth_src: return False |
| 648 | if self.eth_dst != other.eth_dst: return False |
| 649 | if self.vlan_vid != other.vlan_vid: return False |
| 650 | if self.vlan_pcp != other.vlan_pcp: return False |
| 651 | if self.eth_type != other.eth_type: return False |
| 652 | if self.ip_dscp != other.ip_dscp: return False |
| 653 | if self.ip_proto != other.ip_proto: return False |
| 654 | if self.ipv4_src != other.ipv4_src: return False |
| 655 | if self.ipv4_dst != other.ipv4_dst: return False |
| 656 | if self.tcp_src != other.tcp_src: return False |
| 657 | if self.tcp_dst != other.tcp_dst: return False |
| 658 | return True |
| 659 | |
| 660 | def pretty_print(self, q): |
| 661 | q.text("match_v1 {") |
| 662 | with q.group(): |
| 663 | with q.indent(2): |
| 664 | q.breakable() |
| 665 | q.text("wildcards = "); |
| 666 | q.text(util.pretty_wildcards(self.wildcards)) |
| 667 | q.text(","); q.breakable() |
| 668 | q.text("in_port = "); |
| 669 | q.text(util.pretty_port(self.in_port)) |
| 670 | q.text(","); q.breakable() |
| 671 | q.text("eth_src = "); |
| 672 | q.text(util.pretty_mac(self.eth_src)) |
| 673 | q.text(","); q.breakable() |
| 674 | q.text("eth_dst = "); |
| 675 | q.text(util.pretty_mac(self.eth_dst)) |
| 676 | q.text(","); q.breakable() |
| 677 | q.text("vlan_vid = "); |
| 678 | q.text("%#x" % self.vlan_vid) |
| 679 | q.text(","); q.breakable() |
| 680 | q.text("vlan_pcp = "); |
| 681 | q.text("%#x" % self.vlan_pcp) |
| 682 | q.text(","); q.breakable() |
| 683 | q.text("eth_type = "); |
| 684 | q.text("%#x" % self.eth_type) |
| 685 | q.text(","); q.breakable() |
| 686 | q.text("ip_dscp = "); |
| 687 | q.text("%#x" % self.ip_dscp) |
| 688 | q.text(","); q.breakable() |
| 689 | q.text("ip_proto = "); |
| 690 | q.text("%#x" % self.ip_proto) |
| 691 | q.text(","); q.breakable() |
| 692 | q.text("ipv4_src = "); |
| 693 | q.text(util.pretty_ipv4(self.ipv4_src)) |
| 694 | q.text(","); q.breakable() |
| 695 | q.text("ipv4_dst = "); |
| 696 | q.text(util.pretty_ipv4(self.ipv4_dst)) |
| 697 | q.text(","); q.breakable() |
| 698 | q.text("tcp_src = "); |
| 699 | q.text("%#x" % self.tcp_src) |
| 700 | q.text(","); q.breakable() |
| 701 | q.text("tcp_dst = "); |
| 702 | q.text("%#x" % self.tcp_dst) |
| 703 | q.breakable() |
| 704 | q.text('}') |
| 705 | |
| 706 | |
| 707 | class packet_queue(loxi.OFObject): |
| 708 | |
| 709 | def __init__(self, queue_id=None, properties=None): |
| 710 | if queue_id != None: |
| 711 | self.queue_id = queue_id |
| 712 | else: |
| 713 | self.queue_id = 0 |
| 714 | if properties != None: |
| 715 | self.properties = properties |
| 716 | else: |
| 717 | self.properties = [] |
| 718 | return |
| 719 | |
| 720 | def pack(self): |
| 721 | packed = [] |
| 722 | packed.append(struct.pack("!L", self.queue_id)) |
| 723 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 724 | packed.append('\x00' * 2) |
| 725 | packed.append(loxi.generic_util.pack_list(self.properties)) |
| 726 | length = sum([len(x) for x in packed]) |
| 727 | packed[1] = struct.pack("!H", length) |
| 728 | return ''.join(packed) |
| 729 | |
| 730 | @staticmethod |
| 731 | def unpack(reader): |
| 732 | obj = packet_queue() |
| 733 | obj.queue_id = reader.read("!L")[0] |
| 734 | _len = reader.read("!H")[0] |
| 735 | orig_reader = reader |
| 736 | reader = orig_reader.slice(_len, 6) |
| 737 | reader.skip(2) |
| 738 | obj.properties = loxi.generic_util.unpack_list(reader, ofp.common.queue_prop.unpack) |
| 739 | return obj |
| 740 | |
| 741 | def __eq__(self, other): |
| 742 | if type(self) != type(other): return False |
| 743 | if self.queue_id != other.queue_id: return False |
| 744 | if self.properties != other.properties: return False |
| 745 | return True |
| 746 | |
| 747 | def pretty_print(self, q): |
| 748 | q.text("packet_queue {") |
| 749 | with q.group(): |
| 750 | with q.indent(2): |
| 751 | q.breakable() |
| 752 | q.text("queue_id = "); |
| 753 | q.text("%#x" % self.queue_id) |
| 754 | q.text(","); q.breakable() |
| 755 | q.text("properties = "); |
| 756 | q.pp(self.properties) |
| 757 | q.breakable() |
| 758 | q.text('}') |
| 759 | |
| 760 | |
| 761 | class port_desc(loxi.OFObject): |
| 762 | |
| 763 | def __init__(self, port_no=None, hw_addr=None, name=None, config=None, state=None, curr=None, advertised=None, supported=None, peer=None): |
| 764 | if port_no != None: |
| 765 | self.port_no = port_no |
| 766 | else: |
| 767 | self.port_no = 0 |
| 768 | if hw_addr != None: |
| 769 | self.hw_addr = hw_addr |
| 770 | else: |
| 771 | self.hw_addr = [0,0,0,0,0,0] |
| 772 | if name != None: |
| 773 | self.name = name |
| 774 | else: |
| 775 | self.name = "" |
| 776 | if config != None: |
| 777 | self.config = config |
| 778 | else: |
| 779 | self.config = 0 |
| 780 | if state != None: |
| 781 | self.state = state |
| 782 | else: |
| 783 | self.state = 0 |
| 784 | if curr != None: |
| 785 | self.curr = curr |
| 786 | else: |
| 787 | self.curr = 0 |
| 788 | if advertised != None: |
| 789 | self.advertised = advertised |
| 790 | else: |
| 791 | self.advertised = 0 |
| 792 | if supported != None: |
| 793 | self.supported = supported |
| 794 | else: |
| 795 | self.supported = 0 |
| 796 | if peer != None: |
| 797 | self.peer = peer |
| 798 | else: |
| 799 | self.peer = 0 |
| 800 | return |
| 801 | |
| 802 | def pack(self): |
| 803 | packed = [] |
| 804 | packed.append(util.pack_port_no(self.port_no)) |
| 805 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 806 | packed.append(struct.pack("!16s", self.name)) |
| 807 | packed.append(struct.pack("!L", self.config)) |
| 808 | packed.append(struct.pack("!L", self.state)) |
| 809 | packed.append(struct.pack("!L", self.curr)) |
| 810 | packed.append(struct.pack("!L", self.advertised)) |
| 811 | packed.append(struct.pack("!L", self.supported)) |
| 812 | packed.append(struct.pack("!L", self.peer)) |
| 813 | return ''.join(packed) |
| 814 | |
| 815 | @staticmethod |
| 816 | def unpack(reader): |
| 817 | obj = port_desc() |
| 818 | obj.port_no = util.unpack_port_no(reader) |
| 819 | obj.hw_addr = list(reader.read('!6B')) |
| 820 | obj.name = reader.read("!16s")[0].rstrip("\x00") |
| 821 | obj.config = reader.read("!L")[0] |
| 822 | obj.state = reader.read("!L")[0] |
| 823 | obj.curr = reader.read("!L")[0] |
| 824 | obj.advertised = reader.read("!L")[0] |
| 825 | obj.supported = reader.read("!L")[0] |
| 826 | obj.peer = reader.read("!L")[0] |
| 827 | return obj |
| 828 | |
| 829 | def __eq__(self, other): |
| 830 | if type(self) != type(other): return False |
| 831 | if self.port_no != other.port_no: return False |
| 832 | if self.hw_addr != other.hw_addr: return False |
| 833 | if self.name != other.name: return False |
| 834 | if self.config != other.config: return False |
| 835 | if self.state != other.state: return False |
| 836 | if self.curr != other.curr: return False |
| 837 | if self.advertised != other.advertised: return False |
| 838 | if self.supported != other.supported: return False |
| 839 | if self.peer != other.peer: return False |
| 840 | return True |
| 841 | |
| 842 | def pretty_print(self, q): |
| 843 | q.text("port_desc {") |
| 844 | with q.group(): |
| 845 | with q.indent(2): |
| 846 | q.breakable() |
| 847 | q.text("port_no = "); |
| 848 | q.text(util.pretty_port(self.port_no)) |
| 849 | q.text(","); q.breakable() |
| 850 | q.text("hw_addr = "); |
| 851 | q.text(util.pretty_mac(self.hw_addr)) |
| 852 | q.text(","); q.breakable() |
| 853 | q.text("name = "); |
| 854 | q.pp(self.name) |
| 855 | q.text(","); q.breakable() |
| 856 | q.text("config = "); |
| 857 | q.text("%#x" % self.config) |
| 858 | q.text(","); q.breakable() |
| 859 | q.text("state = "); |
| 860 | q.text("%#x" % self.state) |
| 861 | q.text(","); q.breakable() |
| 862 | q.text("curr = "); |
| 863 | q.text("%#x" % self.curr) |
| 864 | q.text(","); q.breakable() |
| 865 | q.text("advertised = "); |
| 866 | q.text("%#x" % self.advertised) |
| 867 | q.text(","); q.breakable() |
| 868 | q.text("supported = "); |
| 869 | q.text("%#x" % self.supported) |
| 870 | q.text(","); q.breakable() |
| 871 | q.text("peer = "); |
| 872 | q.text("%#x" % self.peer) |
| 873 | q.breakable() |
| 874 | q.text('}') |
| 875 | |
| 876 | |
| 877 | class port_stats_entry(loxi.OFObject): |
| 878 | |
| 879 | 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): |
| 880 | if port_no != None: |
| 881 | self.port_no = port_no |
| 882 | else: |
| 883 | self.port_no = 0 |
| 884 | if rx_packets != None: |
| 885 | self.rx_packets = rx_packets |
| 886 | else: |
| 887 | self.rx_packets = 0 |
| 888 | if tx_packets != None: |
| 889 | self.tx_packets = tx_packets |
| 890 | else: |
| 891 | self.tx_packets = 0 |
| 892 | if rx_bytes != None: |
| 893 | self.rx_bytes = rx_bytes |
| 894 | else: |
| 895 | self.rx_bytes = 0 |
| 896 | if tx_bytes != None: |
| 897 | self.tx_bytes = tx_bytes |
| 898 | else: |
| 899 | self.tx_bytes = 0 |
| 900 | if rx_dropped != None: |
| 901 | self.rx_dropped = rx_dropped |
| 902 | else: |
| 903 | self.rx_dropped = 0 |
| 904 | if tx_dropped != None: |
| 905 | self.tx_dropped = tx_dropped |
| 906 | else: |
| 907 | self.tx_dropped = 0 |
| 908 | if rx_errors != None: |
| 909 | self.rx_errors = rx_errors |
| 910 | else: |
| 911 | self.rx_errors = 0 |
| 912 | if tx_errors != None: |
| 913 | self.tx_errors = tx_errors |
| 914 | else: |
| 915 | self.tx_errors = 0 |
| 916 | if rx_frame_err != None: |
| 917 | self.rx_frame_err = rx_frame_err |
| 918 | else: |
| 919 | self.rx_frame_err = 0 |
| 920 | if rx_over_err != None: |
| 921 | self.rx_over_err = rx_over_err |
| 922 | else: |
| 923 | self.rx_over_err = 0 |
| 924 | if rx_crc_err != None: |
| 925 | self.rx_crc_err = rx_crc_err |
| 926 | else: |
| 927 | self.rx_crc_err = 0 |
| 928 | if collisions != None: |
| 929 | self.collisions = collisions |
| 930 | else: |
| 931 | self.collisions = 0 |
| 932 | return |
| 933 | |
| 934 | def pack(self): |
| 935 | packed = [] |
| 936 | packed.append(util.pack_port_no(self.port_no)) |
| 937 | packed.append('\x00' * 6) |
| 938 | packed.append(struct.pack("!Q", self.rx_packets)) |
| 939 | packed.append(struct.pack("!Q", self.tx_packets)) |
| 940 | packed.append(struct.pack("!Q", self.rx_bytes)) |
| 941 | packed.append(struct.pack("!Q", self.tx_bytes)) |
| 942 | packed.append(struct.pack("!Q", self.rx_dropped)) |
| 943 | packed.append(struct.pack("!Q", self.tx_dropped)) |
| 944 | packed.append(struct.pack("!Q", self.rx_errors)) |
| 945 | packed.append(struct.pack("!Q", self.tx_errors)) |
| 946 | packed.append(struct.pack("!Q", self.rx_frame_err)) |
| 947 | packed.append(struct.pack("!Q", self.rx_over_err)) |
| 948 | packed.append(struct.pack("!Q", self.rx_crc_err)) |
| 949 | packed.append(struct.pack("!Q", self.collisions)) |
| 950 | return ''.join(packed) |
| 951 | |
| 952 | @staticmethod |
| 953 | def unpack(reader): |
| 954 | obj = port_stats_entry() |
| 955 | obj.port_no = util.unpack_port_no(reader) |
| 956 | reader.skip(6) |
| 957 | obj.rx_packets = reader.read("!Q")[0] |
| 958 | obj.tx_packets = reader.read("!Q")[0] |
| 959 | obj.rx_bytes = reader.read("!Q")[0] |
| 960 | obj.tx_bytes = reader.read("!Q")[0] |
| 961 | obj.rx_dropped = reader.read("!Q")[0] |
| 962 | obj.tx_dropped = reader.read("!Q")[0] |
| 963 | obj.rx_errors = reader.read("!Q")[0] |
| 964 | obj.tx_errors = reader.read("!Q")[0] |
| 965 | obj.rx_frame_err = reader.read("!Q")[0] |
| 966 | obj.rx_over_err = reader.read("!Q")[0] |
| 967 | obj.rx_crc_err = reader.read("!Q")[0] |
| 968 | obj.collisions = reader.read("!Q")[0] |
| 969 | return obj |
| 970 | |
| 971 | def __eq__(self, other): |
| 972 | if type(self) != type(other): return False |
| 973 | if self.port_no != other.port_no: return False |
| 974 | if self.rx_packets != other.rx_packets: return False |
| 975 | if self.tx_packets != other.tx_packets: return False |
| 976 | if self.rx_bytes != other.rx_bytes: return False |
| 977 | if self.tx_bytes != other.tx_bytes: return False |
| 978 | if self.rx_dropped != other.rx_dropped: return False |
| 979 | if self.tx_dropped != other.tx_dropped: return False |
| 980 | if self.rx_errors != other.rx_errors: return False |
| 981 | if self.tx_errors != other.tx_errors: return False |
| 982 | if self.rx_frame_err != other.rx_frame_err: return False |
| 983 | if self.rx_over_err != other.rx_over_err: return False |
| 984 | if self.rx_crc_err != other.rx_crc_err: return False |
| 985 | if self.collisions != other.collisions: return False |
| 986 | return True |
| 987 | |
| 988 | def pretty_print(self, q): |
| 989 | q.text("port_stats_entry {") |
| 990 | with q.group(): |
| 991 | with q.indent(2): |
| 992 | q.breakable() |
| 993 | q.text("port_no = "); |
| 994 | q.text(util.pretty_port(self.port_no)) |
| 995 | q.text(","); q.breakable() |
| 996 | q.text("rx_packets = "); |
| 997 | q.text("%#x" % self.rx_packets) |
| 998 | q.text(","); q.breakable() |
| 999 | q.text("tx_packets = "); |
| 1000 | q.text("%#x" % self.tx_packets) |
| 1001 | q.text(","); q.breakable() |
| 1002 | q.text("rx_bytes = "); |
| 1003 | q.text("%#x" % self.rx_bytes) |
| 1004 | q.text(","); q.breakable() |
| 1005 | q.text("tx_bytes = "); |
| 1006 | q.text("%#x" % self.tx_bytes) |
| 1007 | q.text(","); q.breakable() |
| 1008 | q.text("rx_dropped = "); |
| 1009 | q.text("%#x" % self.rx_dropped) |
| 1010 | q.text(","); q.breakable() |
| 1011 | q.text("tx_dropped = "); |
| 1012 | q.text("%#x" % self.tx_dropped) |
| 1013 | q.text(","); q.breakable() |
| 1014 | q.text("rx_errors = "); |
| 1015 | q.text("%#x" % self.rx_errors) |
| 1016 | q.text(","); q.breakable() |
| 1017 | q.text("tx_errors = "); |
| 1018 | q.text("%#x" % self.tx_errors) |
| 1019 | q.text(","); q.breakable() |
| 1020 | q.text("rx_frame_err = "); |
| 1021 | q.text("%#x" % self.rx_frame_err) |
| 1022 | q.text(","); q.breakable() |
| 1023 | q.text("rx_over_err = "); |
| 1024 | q.text("%#x" % self.rx_over_err) |
| 1025 | q.text(","); q.breakable() |
| 1026 | q.text("rx_crc_err = "); |
| 1027 | q.text("%#x" % self.rx_crc_err) |
| 1028 | q.text(","); q.breakable() |
| 1029 | q.text("collisions = "); |
| 1030 | q.text("%#x" % self.collisions) |
| 1031 | q.breakable() |
| 1032 | q.text('}') |
| 1033 | |
| 1034 | |
| 1035 | class queue_prop(loxi.OFObject): |
| 1036 | subtypes = {} |
| 1037 | |
| 1038 | |
| 1039 | def __init__(self, type=None): |
| 1040 | if type != None: |
| 1041 | self.type = type |
| 1042 | else: |
| 1043 | self.type = 0 |
| 1044 | return |
| 1045 | |
| 1046 | def pack(self): |
| 1047 | packed = [] |
| 1048 | packed.append(struct.pack("!H", self.type)) |
| 1049 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1050 | packed.append('\x00' * 4) |
| 1051 | length = sum([len(x) for x in packed]) |
| 1052 | packed[1] = struct.pack("!H", length) |
| 1053 | return ''.join(packed) |
| 1054 | |
| 1055 | @staticmethod |
| 1056 | def unpack(reader): |
| 1057 | subtype, = reader.peek('!H', 0) |
| 1058 | subclass = queue_prop.subtypes.get(subtype) |
| 1059 | if subclass: |
| 1060 | return subclass.unpack(reader) |
| 1061 | |
| 1062 | obj = queue_prop() |
| 1063 | obj.type = reader.read("!H")[0] |
| 1064 | _len = reader.read("!H")[0] |
| 1065 | orig_reader = reader |
| 1066 | reader = orig_reader.slice(_len, 4) |
| 1067 | reader.skip(4) |
| 1068 | return obj |
| 1069 | |
| 1070 | def __eq__(self, other): |
| 1071 | if type(self) != type(other): return False |
| 1072 | if self.type != other.type: return False |
| 1073 | return True |
| 1074 | |
| 1075 | def pretty_print(self, q): |
| 1076 | q.text("queue_prop {") |
| 1077 | with q.group(): |
| 1078 | with q.indent(2): |
| 1079 | q.breakable() |
| 1080 | q.breakable() |
| 1081 | q.text('}') |
| 1082 | |
| 1083 | |
| 1084 | class queue_prop_min_rate(queue_prop): |
| 1085 | type = 1 |
| 1086 | |
| 1087 | def __init__(self, rate=None): |
| 1088 | if rate != None: |
| 1089 | self.rate = rate |
| 1090 | else: |
| 1091 | self.rate = 0 |
| 1092 | return |
| 1093 | |
| 1094 | def pack(self): |
| 1095 | packed = [] |
| 1096 | packed.append(struct.pack("!H", self.type)) |
| 1097 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1098 | packed.append('\x00' * 4) |
| 1099 | packed.append(struct.pack("!H", self.rate)) |
| 1100 | packed.append('\x00' * 6) |
| 1101 | length = sum([len(x) for x in packed]) |
| 1102 | packed[1] = struct.pack("!H", length) |
| 1103 | return ''.join(packed) |
| 1104 | |
| 1105 | @staticmethod |
| 1106 | def unpack(reader): |
| 1107 | obj = queue_prop_min_rate() |
| 1108 | _type = reader.read("!H")[0] |
| 1109 | assert(_type == 1) |
| 1110 | _len = reader.read("!H")[0] |
| 1111 | orig_reader = reader |
| 1112 | reader = orig_reader.slice(_len, 4) |
| 1113 | reader.skip(4) |
| 1114 | obj.rate = reader.read("!H")[0] |
| 1115 | reader.skip(6) |
| 1116 | return obj |
| 1117 | |
| 1118 | def __eq__(self, other): |
| 1119 | if type(self) != type(other): return False |
| 1120 | if self.rate != other.rate: return False |
| 1121 | return True |
| 1122 | |
| 1123 | def pretty_print(self, q): |
| 1124 | q.text("queue_prop_min_rate {") |
| 1125 | with q.group(): |
| 1126 | with q.indent(2): |
| 1127 | q.breakable() |
| 1128 | q.text("rate = "); |
| 1129 | q.text("%#x" % self.rate) |
| 1130 | q.breakable() |
| 1131 | q.text('}') |
| 1132 | |
| 1133 | queue_prop.subtypes[1] = queue_prop_min_rate |
| 1134 | |
| 1135 | class queue_stats_entry(loxi.OFObject): |
| 1136 | |
| 1137 | def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None): |
| 1138 | if port_no != None: |
| 1139 | self.port_no = port_no |
| 1140 | else: |
| 1141 | self.port_no = 0 |
| 1142 | if queue_id != None: |
| 1143 | self.queue_id = queue_id |
| 1144 | else: |
| 1145 | self.queue_id = 0 |
| 1146 | if tx_bytes != None: |
| 1147 | self.tx_bytes = tx_bytes |
| 1148 | else: |
| 1149 | self.tx_bytes = 0 |
| 1150 | if tx_packets != None: |
| 1151 | self.tx_packets = tx_packets |
| 1152 | else: |
| 1153 | self.tx_packets = 0 |
| 1154 | if tx_errors != None: |
| 1155 | self.tx_errors = tx_errors |
| 1156 | else: |
| 1157 | self.tx_errors = 0 |
| 1158 | return |
| 1159 | |
| 1160 | def pack(self): |
| 1161 | packed = [] |
| 1162 | packed.append(util.pack_port_no(self.port_no)) |
| 1163 | packed.append('\x00' * 2) |
| 1164 | packed.append(struct.pack("!L", self.queue_id)) |
| 1165 | packed.append(struct.pack("!Q", self.tx_bytes)) |
| 1166 | packed.append(struct.pack("!Q", self.tx_packets)) |
| 1167 | packed.append(struct.pack("!Q", self.tx_errors)) |
| 1168 | return ''.join(packed) |
| 1169 | |
| 1170 | @staticmethod |
| 1171 | def unpack(reader): |
| 1172 | obj = queue_stats_entry() |
| 1173 | obj.port_no = util.unpack_port_no(reader) |
| 1174 | reader.skip(2) |
| 1175 | obj.queue_id = reader.read("!L")[0] |
| 1176 | obj.tx_bytes = reader.read("!Q")[0] |
| 1177 | obj.tx_packets = reader.read("!Q")[0] |
| 1178 | obj.tx_errors = reader.read("!Q")[0] |
| 1179 | return obj |
| 1180 | |
| 1181 | def __eq__(self, other): |
| 1182 | if type(self) != type(other): return False |
| 1183 | if self.port_no != other.port_no: return False |
| 1184 | if self.queue_id != other.queue_id: return False |
| 1185 | if self.tx_bytes != other.tx_bytes: return False |
| 1186 | if self.tx_packets != other.tx_packets: return False |
| 1187 | if self.tx_errors != other.tx_errors: return False |
| 1188 | return True |
| 1189 | |
| 1190 | def pretty_print(self, q): |
| 1191 | q.text("queue_stats_entry {") |
| 1192 | with q.group(): |
| 1193 | with q.indent(2): |
| 1194 | q.breakable() |
| 1195 | q.text("port_no = "); |
| 1196 | q.text(util.pretty_port(self.port_no)) |
| 1197 | q.text(","); q.breakable() |
| 1198 | q.text("queue_id = "); |
| 1199 | q.text("%#x" % self.queue_id) |
| 1200 | q.text(","); q.breakable() |
| 1201 | q.text("tx_bytes = "); |
| 1202 | q.text("%#x" % self.tx_bytes) |
| 1203 | q.text(","); q.breakable() |
| 1204 | q.text("tx_packets = "); |
| 1205 | q.text("%#x" % self.tx_packets) |
| 1206 | q.text(","); q.breakable() |
| 1207 | q.text("tx_errors = "); |
| 1208 | q.text("%#x" % self.tx_errors) |
| 1209 | q.breakable() |
| 1210 | q.text('}') |
| 1211 | |
| 1212 | |
| 1213 | class table_stats_entry(loxi.OFObject): |
| 1214 | |
| 1215 | def __init__(self, table_id=None, name=None, wildcards=None, max_entries=None, active_count=None, lookup_count=None, matched_count=None): |
| 1216 | if table_id != None: |
| 1217 | self.table_id = table_id |
| 1218 | else: |
| 1219 | self.table_id = 0 |
| 1220 | if name != None: |
| 1221 | self.name = name |
| 1222 | else: |
| 1223 | self.name = "" |
| 1224 | if wildcards != None: |
| 1225 | self.wildcards = wildcards |
| 1226 | else: |
| 1227 | self.wildcards = util.init_wc_bmap() |
| 1228 | if max_entries != None: |
| 1229 | self.max_entries = max_entries |
| 1230 | else: |
| 1231 | self.max_entries = 0 |
| 1232 | if active_count != None: |
| 1233 | self.active_count = active_count |
| 1234 | else: |
| 1235 | self.active_count = 0 |
| 1236 | if lookup_count != None: |
| 1237 | self.lookup_count = lookup_count |
| 1238 | else: |
| 1239 | self.lookup_count = 0 |
| 1240 | if matched_count != None: |
| 1241 | self.matched_count = matched_count |
| 1242 | else: |
| 1243 | self.matched_count = 0 |
| 1244 | return |
| 1245 | |
| 1246 | def pack(self): |
| 1247 | packed = [] |
| 1248 | packed.append(struct.pack("!B", self.table_id)) |
| 1249 | packed.append('\x00' * 3) |
| 1250 | packed.append(struct.pack("!32s", self.name)) |
| 1251 | packed.append(util.pack_wc_bmap(self.wildcards)) |
| 1252 | packed.append(struct.pack("!L", self.max_entries)) |
| 1253 | packed.append(struct.pack("!L", self.active_count)) |
| 1254 | packed.append(struct.pack("!Q", self.lookup_count)) |
| 1255 | packed.append(struct.pack("!Q", self.matched_count)) |
| 1256 | return ''.join(packed) |
| 1257 | |
| 1258 | @staticmethod |
| 1259 | def unpack(reader): |
| 1260 | obj = table_stats_entry() |
| 1261 | obj.table_id = reader.read("!B")[0] |
| 1262 | reader.skip(3) |
| 1263 | obj.name = reader.read("!32s")[0].rstrip("\x00") |
| 1264 | obj.wildcards = util.unpack_wc_bmap(reader) |
| 1265 | obj.max_entries = reader.read("!L")[0] |
| 1266 | obj.active_count = reader.read("!L")[0] |
| 1267 | obj.lookup_count = reader.read("!Q")[0] |
| 1268 | obj.matched_count = reader.read("!Q")[0] |
| 1269 | return obj |
| 1270 | |
| 1271 | def __eq__(self, other): |
| 1272 | if type(self) != type(other): return False |
| 1273 | if self.table_id != other.table_id: return False |
| 1274 | if self.name != other.name: return False |
| 1275 | if self.wildcards != other.wildcards: return False |
| 1276 | if self.max_entries != other.max_entries: return False |
| 1277 | if self.active_count != other.active_count: return False |
| 1278 | if self.lookup_count != other.lookup_count: return False |
| 1279 | if self.matched_count != other.matched_count: return False |
| 1280 | return True |
| 1281 | |
| 1282 | def pretty_print(self, q): |
| 1283 | q.text("table_stats_entry {") |
| 1284 | with q.group(): |
| 1285 | with q.indent(2): |
| 1286 | q.breakable() |
| 1287 | q.text("table_id = "); |
| 1288 | q.text("%#x" % self.table_id) |
| 1289 | q.text(","); q.breakable() |
| 1290 | q.text("name = "); |
| 1291 | q.pp(self.name) |
| 1292 | q.text(","); q.breakable() |
| 1293 | q.text("wildcards = "); |
| 1294 | q.text(util.pretty_wildcards(self.wildcards)) |
| 1295 | q.text(","); q.breakable() |
| 1296 | q.text("max_entries = "); |
| 1297 | q.text("%#x" % self.max_entries) |
| 1298 | q.text(","); q.breakable() |
| 1299 | q.text("active_count = "); |
| 1300 | q.text("%#x" % self.active_count) |
| 1301 | q.text(","); q.breakable() |
| 1302 | q.text("lookup_count = "); |
| 1303 | q.text("%#x" % self.lookup_count) |
| 1304 | q.text(","); q.breakable() |
| 1305 | q.text("matched_count = "); |
| 1306 | q.text("%#x" % self.matched_count) |
| 1307 | q.breakable() |
| 1308 | q.text('}') |
| 1309 | |
| 1310 | |
| 1311 | |
| 1312 | match = match_v1 |