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