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