blob: 84572eb04b110219126c102550d96bfd22e88e82 [file] [log] [blame]
Rich Lanec2ee4b82013-04-24 17:12:38 -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
5# Automatically generated by LOXI from template common.py
6# Do not modify
7
8import sys
9import struct
10import action
11import instruction # for unpack_list
12import meter_band # for unpack_list
13import const
14import util
15import loxi.generic_util
16
17import oxm
18
19# HACK make this module visible as 'common' to simplify code generation
20common = sys.modules[__name__]
21
22def unpack_list_flow_stats_entry(reader):
23 return loxi.generic_util.unpack_list_lv16(reader, flow_stats_entry.unpack)
24
25def unpack_list_queue_prop(reader):
26 def deserializer(reader, typ):
27 if typ == const.OFPQT_MIN_RATE:
28 return queue_prop_min_rate.unpack(reader)
29 else:
30 raise loxi.ProtocolError("unknown queue prop %d" % typ)
31 return loxi.generic_util.unpack_list_tlv16(reader, deserializer)
32
33def unpack_list_packet_queue(reader):
34 def wrapper(reader):
35 length, = reader.peek('!4xH')
36 return packet_queue.unpack(reader.slice(length))
37 return loxi.generic_util.unpack_list(reader, wrapper)
38
39def unpack_list_hello_elem(reader):
40 def deserializer(reader, typ):
41 if typ == const.OFPHET_VERSIONBITMAP:
42 return hello_elem_versionbitmap.unpack(reader)
43 else:
44 return None
45 return [x for x in loxi.generic_util.unpack_list_tlv16(reader, deserializer) if x != None]
46
47def unpack_list_bucket(reader):
48 return loxi.generic_util.unpack_list_lv16(reader, bucket.unpack)
49
50def unpack_list_group_desc_stats_entry(reader):
51 return loxi.generic_util.unpack_list_lv16(reader, group_desc_stats_entry.unpack)
52
53def unpack_list_group_stats_entry(reader):
54 return loxi.generic_util.unpack_list_lv16(reader, group_stats_entry.unpack)
55
56def unpack_list_meter_stats(reader):
57 def wrapper(reader):
58 length, = reader.peek('!4xH')
59 return meter_stats.unpack(reader.slice(length))
60 return loxi.generic_util.unpack_list(reader, wrapper)
61
62class action_id_bsn_mirror(object):
63
64 def __init__(self, type=None, experimenter=None, subtype=None):
65 if type != None:
66 self.type = type
67 else:
68 self.type = 0
69 if experimenter != None:
70 self.experimenter = experimenter
71 else:
72 self.experimenter = 0
73 if subtype != None:
74 self.subtype = subtype
75 else:
76 self.subtype = 0
77 return
78
79 def pack(self):
80 packed = []
81 packed.append(struct.pack("!H", self.type))
82 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
83 packed.append(struct.pack("!L", self.experimenter))
84 packed.append(struct.pack("!L", self.subtype))
85 length = sum([len(x) for x in packed])
86 packed[1] = struct.pack("!H", length)
87 return ''.join(packed)
88
89 @staticmethod
90 def unpack(buf):
91 obj = action_id_bsn_mirror()
92 if type(buf) == loxi.generic_util.OFReader:
93 reader = buf
94 else:
95 reader = loxi.generic_util.OFReader(buf)
96 obj.type = reader.read('!H')[0]
97 _len = reader.read('!H')[0]
98 obj.experimenter = reader.read('!L')[0]
99 obj.subtype = reader.read('!L')[0]
100 return obj
101
102 def __eq__(self, other):
103 if type(self) != type(other): return False
104 if self.type != other.type: return False
105 if self.experimenter != other.experimenter: return False
106 if self.subtype != other.subtype: return False
107 return True
108
109 def __ne__(self, other):
110 return not self.__eq__(other)
111
112 def show(self):
113 import loxi.pp
114 return loxi.pp.pp(self)
115
116 def pretty_print(self, q):
117 q.text("action_id_bsn_mirror {")
118 with q.group():
119 with q.indent(2):
120 q.breakable()
121 q.text("type = ");
122 q.text("%#x" % self.type)
123 q.text(","); q.breakable()
124 q.text("experimenter = ");
125 q.text("%#x" % self.experimenter)
126 q.text(","); q.breakable()
127 q.text("subtype = ");
128 q.text("%#x" % self.subtype)
129 q.breakable()
130 q.text('}')
131
132class action_id_bsn_set_tunnel_dst(object):
133
134 def __init__(self, type=None, experimenter=None, subtype=None):
135 if type != None:
136 self.type = type
137 else:
138 self.type = 0
139 if experimenter != None:
140 self.experimenter = experimenter
141 else:
142 self.experimenter = 0
143 if subtype != None:
144 self.subtype = subtype
145 else:
146 self.subtype = 0
147 return
148
149 def pack(self):
150 packed = []
151 packed.append(struct.pack("!H", self.type))
152 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
153 packed.append(struct.pack("!L", self.experimenter))
154 packed.append(struct.pack("!L", self.subtype))
155 length = sum([len(x) for x in packed])
156 packed[1] = struct.pack("!H", length)
157 return ''.join(packed)
158
159 @staticmethod
160 def unpack(buf):
161 obj = action_id_bsn_set_tunnel_dst()
162 if type(buf) == loxi.generic_util.OFReader:
163 reader = buf
164 else:
165 reader = loxi.generic_util.OFReader(buf)
166 obj.type = reader.read('!H')[0]
167 _len = reader.read('!H')[0]
168 obj.experimenter = reader.read('!L')[0]
169 obj.subtype = reader.read('!L')[0]
170 return obj
171
172 def __eq__(self, other):
173 if type(self) != type(other): return False
174 if self.type != other.type: return False
175 if self.experimenter != other.experimenter: return False
176 if self.subtype != other.subtype: return False
177 return True
178
179 def __ne__(self, other):
180 return not self.__eq__(other)
181
182 def show(self):
183 import loxi.pp
184 return loxi.pp.pp(self)
185
186 def pretty_print(self, q):
187 q.text("action_id_bsn_set_tunnel_dst {")
188 with q.group():
189 with q.indent(2):
190 q.breakable()
191 q.text("type = ");
192 q.text("%#x" % self.type)
193 q.text(","); q.breakable()
194 q.text("experimenter = ");
195 q.text("%#x" % self.experimenter)
196 q.text(","); q.breakable()
197 q.text("subtype = ");
198 q.text("%#x" % self.subtype)
199 q.breakable()
200 q.text('}')
201
202class action_id_copy_ttl_in(object):
203
204 def __init__(self, type=None):
205 if type != None:
206 self.type = type
207 else:
208 self.type = 0
209 return
210
211 def pack(self):
212 packed = []
213 packed.append(struct.pack("!H", self.type))
214 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
215 packed.append('\x00' * 4)
216 length = sum([len(x) for x in packed])
217 packed[1] = struct.pack("!H", length)
218 return ''.join(packed)
219
220 @staticmethod
221 def unpack(buf):
222 obj = action_id_copy_ttl_in()
223 if type(buf) == loxi.generic_util.OFReader:
224 reader = buf
225 else:
226 reader = loxi.generic_util.OFReader(buf)
227 obj.type = reader.read('!H')[0]
228 _len = reader.read('!H')[0]
229 reader.skip(4)
230 return obj
231
232 def __eq__(self, other):
233 if type(self) != type(other): return False
234 if self.type != other.type: return False
235 return True
236
237 def __ne__(self, other):
238 return not self.__eq__(other)
239
240 def show(self):
241 import loxi.pp
242 return loxi.pp.pp(self)
243
244 def pretty_print(self, q):
245 q.text("action_id_copy_ttl_in {")
246 with q.group():
247 with q.indent(2):
248 q.breakable()
249 q.text("type = ");
250 q.text("%#x" % self.type)
251 q.breakable()
252 q.text('}')
253
254class action_id_copy_ttl_out(object):
255
256 def __init__(self, type=None):
257 if type != None:
258 self.type = type
259 else:
260 self.type = 0
261 return
262
263 def pack(self):
264 packed = []
265 packed.append(struct.pack("!H", self.type))
266 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
267 packed.append('\x00' * 4)
268 length = sum([len(x) for x in packed])
269 packed[1] = struct.pack("!H", length)
270 return ''.join(packed)
271
272 @staticmethod
273 def unpack(buf):
274 obj = action_id_copy_ttl_out()
275 if type(buf) == loxi.generic_util.OFReader:
276 reader = buf
277 else:
278 reader = loxi.generic_util.OFReader(buf)
279 obj.type = reader.read('!H')[0]
280 _len = reader.read('!H')[0]
281 reader.skip(4)
282 return obj
283
284 def __eq__(self, other):
285 if type(self) != type(other): return False
286 if self.type != other.type: return False
287 return True
288
289 def __ne__(self, other):
290 return not self.__eq__(other)
291
292 def show(self):
293 import loxi.pp
294 return loxi.pp.pp(self)
295
296 def pretty_print(self, q):
297 q.text("action_id_copy_ttl_out {")
298 with q.group():
299 with q.indent(2):
300 q.breakable()
301 q.text("type = ");
302 q.text("%#x" % self.type)
303 q.breakable()
304 q.text('}')
305
306class action_id_dec_mpls_ttl(object):
307
308 def __init__(self, type=None):
309 if type != None:
310 self.type = type
311 else:
312 self.type = 0
313 return
314
315 def pack(self):
316 packed = []
317 packed.append(struct.pack("!H", self.type))
318 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
319 packed.append('\x00' * 4)
320 length = sum([len(x) for x in packed])
321 packed[1] = struct.pack("!H", length)
322 return ''.join(packed)
323
324 @staticmethod
325 def unpack(buf):
326 obj = action_id_dec_mpls_ttl()
327 if type(buf) == loxi.generic_util.OFReader:
328 reader = buf
329 else:
330 reader = loxi.generic_util.OFReader(buf)
331 obj.type = reader.read('!H')[0]
332 _len = reader.read('!H')[0]
333 reader.skip(4)
334 return obj
335
336 def __eq__(self, other):
337 if type(self) != type(other): return False
338 if self.type != other.type: return False
339 return True
340
341 def __ne__(self, other):
342 return not self.__eq__(other)
343
344 def show(self):
345 import loxi.pp
346 return loxi.pp.pp(self)
347
348 def pretty_print(self, q):
349 q.text("action_id_dec_mpls_ttl {")
350 with q.group():
351 with q.indent(2):
352 q.breakable()
353 q.text("type = ");
354 q.text("%#x" % self.type)
355 q.breakable()
356 q.text('}')
357
358class action_id_dec_nw_ttl(object):
359
360 def __init__(self, type=None):
361 if type != None:
362 self.type = type
363 else:
364 self.type = 0
365 return
366
367 def pack(self):
368 packed = []
369 packed.append(struct.pack("!H", self.type))
370 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
371 packed.append('\x00' * 4)
372 length = sum([len(x) for x in packed])
373 packed[1] = struct.pack("!H", length)
374 return ''.join(packed)
375
376 @staticmethod
377 def unpack(buf):
378 obj = action_id_dec_nw_ttl()
379 if type(buf) == loxi.generic_util.OFReader:
380 reader = buf
381 else:
382 reader = loxi.generic_util.OFReader(buf)
383 obj.type = reader.read('!H')[0]
384 _len = reader.read('!H')[0]
385 reader.skip(4)
386 return obj
387
388 def __eq__(self, other):
389 if type(self) != type(other): return False
390 if self.type != other.type: return False
391 return True
392
393 def __ne__(self, other):
394 return not self.__eq__(other)
395
396 def show(self):
397 import loxi.pp
398 return loxi.pp.pp(self)
399
400 def pretty_print(self, q):
401 q.text("action_id_dec_nw_ttl {")
402 with q.group():
403 with q.indent(2):
404 q.breakable()
405 q.text("type = ");
406 q.text("%#x" % self.type)
407 q.breakable()
408 q.text('}')
409
410class action_id_experimenter(object):
411
412 def __init__(self, type=None):
413 if type != None:
414 self.type = type
415 else:
416 self.type = 0
417 return
418
419 def pack(self):
420 packed = []
421 packed.append(struct.pack("!H", self.type))
422 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
423 packed.append('\x00' * 4)
424 length = sum([len(x) for x in packed])
425 packed[1] = struct.pack("!H", length)
426 return ''.join(packed)
427
428 @staticmethod
429 def unpack(buf):
430 obj = action_id_experimenter()
431 if type(buf) == loxi.generic_util.OFReader:
432 reader = buf
433 else:
434 reader = loxi.generic_util.OFReader(buf)
435 obj.type = reader.read('!H')[0]
436 _len = reader.read('!H')[0]
437 reader.skip(4)
438 return obj
439
440 def __eq__(self, other):
441 if type(self) != type(other): return False
442 if self.type != other.type: return False
443 return True
444
445 def __ne__(self, other):
446 return not self.__eq__(other)
447
448 def show(self):
449 import loxi.pp
450 return loxi.pp.pp(self)
451
452 def pretty_print(self, q):
453 q.text("action_id_experimenter {")
454 with q.group():
455 with q.indent(2):
456 q.breakable()
457 q.text("type = ");
458 q.text("%#x" % self.type)
459 q.breakable()
460 q.text('}')
461
462class action_id_group(object):
463
464 def __init__(self, type=None):
465 if type != None:
466 self.type = type
467 else:
468 self.type = 0
469 return
470
471 def pack(self):
472 packed = []
473 packed.append(struct.pack("!H", self.type))
474 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
475 packed.append('\x00' * 4)
476 length = sum([len(x) for x in packed])
477 packed[1] = struct.pack("!H", length)
478 return ''.join(packed)
479
480 @staticmethod
481 def unpack(buf):
482 obj = action_id_group()
483 if type(buf) == loxi.generic_util.OFReader:
484 reader = buf
485 else:
486 reader = loxi.generic_util.OFReader(buf)
487 obj.type = reader.read('!H')[0]
488 _len = reader.read('!H')[0]
489 reader.skip(4)
490 return obj
491
492 def __eq__(self, other):
493 if type(self) != type(other): return False
494 if self.type != other.type: return False
495 return True
496
497 def __ne__(self, other):
498 return not self.__eq__(other)
499
500 def show(self):
501 import loxi.pp
502 return loxi.pp.pp(self)
503
504 def pretty_print(self, q):
505 q.text("action_id_group {")
506 with q.group():
507 with q.indent(2):
508 q.breakable()
509 q.text("type = ");
510 q.text("%#x" % self.type)
511 q.breakable()
512 q.text('}')
513
514class action_id_nicira_dec_ttl(object):
515
516 def __init__(self, type=None, experimenter=None, subtype=None):
517 if type != None:
518 self.type = type
519 else:
520 self.type = 0
521 if experimenter != None:
522 self.experimenter = experimenter
523 else:
524 self.experimenter = 0
525 if subtype != None:
526 self.subtype = subtype
527 else:
528 self.subtype = 0
529 return
530
531 def pack(self):
532 packed = []
533 packed.append(struct.pack("!H", self.type))
534 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
535 packed.append(struct.pack("!L", self.experimenter))
536 packed.append(struct.pack("!H", self.subtype))
537 length = sum([len(x) for x in packed])
538 packed[1] = struct.pack("!H", length)
539 return ''.join(packed)
540
541 @staticmethod
542 def unpack(buf):
543 obj = action_id_nicira_dec_ttl()
544 if type(buf) == loxi.generic_util.OFReader:
545 reader = buf
546 else:
547 reader = loxi.generic_util.OFReader(buf)
548 obj.type = reader.read('!H')[0]
549 _len = reader.read('!H')[0]
550 obj.experimenter = reader.read('!L')[0]
551 obj.subtype = reader.read('!H')[0]
552 return obj
553
554 def __eq__(self, other):
555 if type(self) != type(other): return False
556 if self.type != other.type: return False
557 if self.experimenter != other.experimenter: return False
558 if self.subtype != other.subtype: return False
559 return True
560
561 def __ne__(self, other):
562 return not self.__eq__(other)
563
564 def show(self):
565 import loxi.pp
566 return loxi.pp.pp(self)
567
568 def pretty_print(self, q):
569 q.text("action_id_nicira_dec_ttl {")
570 with q.group():
571 with q.indent(2):
572 q.breakable()
573 q.text("type = ");
574 q.text("%#x" % self.type)
575 q.text(","); q.breakable()
576 q.text("experimenter = ");
577 q.text("%#x" % self.experimenter)
578 q.text(","); q.breakable()
579 q.text("subtype = ");
580 q.text("%#x" % self.subtype)
581 q.breakable()
582 q.text('}')
583
584class action_id_output(object):
585
586 def __init__(self, type=None):
587 if type != None:
588 self.type = type
589 else:
590 self.type = 0
591 return
592
593 def pack(self):
594 packed = []
595 packed.append(struct.pack("!H", self.type))
596 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
597 packed.append('\x00' * 4)
598 length = sum([len(x) for x in packed])
599 packed[1] = struct.pack("!H", length)
600 return ''.join(packed)
601
602 @staticmethod
603 def unpack(buf):
604 obj = action_id_output()
605 if type(buf) == loxi.generic_util.OFReader:
606 reader = buf
607 else:
608 reader = loxi.generic_util.OFReader(buf)
609 obj.type = reader.read('!H')[0]
610 _len = reader.read('!H')[0]
611 reader.skip(4)
612 return obj
613
614 def __eq__(self, other):
615 if type(self) != type(other): return False
616 if self.type != other.type: return False
617 return True
618
619 def __ne__(self, other):
620 return not self.__eq__(other)
621
622 def show(self):
623 import loxi.pp
624 return loxi.pp.pp(self)
625
626 def pretty_print(self, q):
627 q.text("action_id_output {")
628 with q.group():
629 with q.indent(2):
630 q.breakable()
631 q.text("type = ");
632 q.text("%#x" % self.type)
633 q.breakable()
634 q.text('}')
635
636class action_id_pop_mpls(object):
637
638 def __init__(self, type=None):
639 if type != None:
640 self.type = type
641 else:
642 self.type = 0
643 return
644
645 def pack(self):
646 packed = []
647 packed.append(struct.pack("!H", self.type))
648 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
649 packed.append('\x00' * 4)
650 length = sum([len(x) for x in packed])
651 packed[1] = struct.pack("!H", length)
652 return ''.join(packed)
653
654 @staticmethod
655 def unpack(buf):
656 obj = action_id_pop_mpls()
657 if type(buf) == loxi.generic_util.OFReader:
658 reader = buf
659 else:
660 reader = loxi.generic_util.OFReader(buf)
661 obj.type = reader.read('!H')[0]
662 _len = reader.read('!H')[0]
663 reader.skip(4)
664 return obj
665
666 def __eq__(self, other):
667 if type(self) != type(other): return False
668 if self.type != other.type: return False
669 return True
670
671 def __ne__(self, other):
672 return not self.__eq__(other)
673
674 def show(self):
675 import loxi.pp
676 return loxi.pp.pp(self)
677
678 def pretty_print(self, q):
679 q.text("action_id_pop_mpls {")
680 with q.group():
681 with q.indent(2):
682 q.breakable()
683 q.text("type = ");
684 q.text("%#x" % self.type)
685 q.breakable()
686 q.text('}')
687
688class action_id_pop_pbb(object):
689
690 def __init__(self, type=None):
691 if type != None:
692 self.type = type
693 else:
694 self.type = 0
695 return
696
697 def pack(self):
698 packed = []
699 packed.append(struct.pack("!H", self.type))
700 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
701 packed.append('\x00' * 4)
702 length = sum([len(x) for x in packed])
703 packed[1] = struct.pack("!H", length)
704 return ''.join(packed)
705
706 @staticmethod
707 def unpack(buf):
708 obj = action_id_pop_pbb()
709 if type(buf) == loxi.generic_util.OFReader:
710 reader = buf
711 else:
712 reader = loxi.generic_util.OFReader(buf)
713 obj.type = reader.read('!H')[0]
714 _len = reader.read('!H')[0]
715 reader.skip(4)
716 return obj
717
718 def __eq__(self, other):
719 if type(self) != type(other): return False
720 if self.type != other.type: return False
721 return True
722
723 def __ne__(self, other):
724 return not self.__eq__(other)
725
726 def show(self):
727 import loxi.pp
728 return loxi.pp.pp(self)
729
730 def pretty_print(self, q):
731 q.text("action_id_pop_pbb {")
732 with q.group():
733 with q.indent(2):
734 q.breakable()
735 q.text("type = ");
736 q.text("%#x" % self.type)
737 q.breakable()
738 q.text('}')
739
740class action_id_pop_vlan(object):
741
742 def __init__(self, type=None):
743 if type != None:
744 self.type = type
745 else:
746 self.type = 0
747 return
748
749 def pack(self):
750 packed = []
751 packed.append(struct.pack("!H", self.type))
752 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
753 packed.append('\x00' * 4)
754 length = sum([len(x) for x in packed])
755 packed[1] = struct.pack("!H", length)
756 return ''.join(packed)
757
758 @staticmethod
759 def unpack(buf):
760 obj = action_id_pop_vlan()
761 if type(buf) == loxi.generic_util.OFReader:
762 reader = buf
763 else:
764 reader = loxi.generic_util.OFReader(buf)
765 obj.type = reader.read('!H')[0]
766 _len = reader.read('!H')[0]
767 reader.skip(4)
768 return obj
769
770 def __eq__(self, other):
771 if type(self) != type(other): return False
772 if self.type != other.type: return False
773 return True
774
775 def __ne__(self, other):
776 return not self.__eq__(other)
777
778 def show(self):
779 import loxi.pp
780 return loxi.pp.pp(self)
781
782 def pretty_print(self, q):
783 q.text("action_id_pop_vlan {")
784 with q.group():
785 with q.indent(2):
786 q.breakable()
787 q.text("type = ");
788 q.text("%#x" % self.type)
789 q.breakable()
790 q.text('}')
791
792class action_id_push_mpls(object):
793
794 def __init__(self, type=None):
795 if type != None:
796 self.type = type
797 else:
798 self.type = 0
799 return
800
801 def pack(self):
802 packed = []
803 packed.append(struct.pack("!H", self.type))
804 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
805 packed.append('\x00' * 4)
806 length = sum([len(x) for x in packed])
807 packed[1] = struct.pack("!H", length)
808 return ''.join(packed)
809
810 @staticmethod
811 def unpack(buf):
812 obj = action_id_push_mpls()
813 if type(buf) == loxi.generic_util.OFReader:
814 reader = buf
815 else:
816 reader = loxi.generic_util.OFReader(buf)
817 obj.type = reader.read('!H')[0]
818 _len = reader.read('!H')[0]
819 reader.skip(4)
820 return obj
821
822 def __eq__(self, other):
823 if type(self) != type(other): return False
824 if self.type != other.type: return False
825 return True
826
827 def __ne__(self, other):
828 return not self.__eq__(other)
829
830 def show(self):
831 import loxi.pp
832 return loxi.pp.pp(self)
833
834 def pretty_print(self, q):
835 q.text("action_id_push_mpls {")
836 with q.group():
837 with q.indent(2):
838 q.breakable()
839 q.text("type = ");
840 q.text("%#x" % self.type)
841 q.breakable()
842 q.text('}')
843
844class action_id_push_pbb(object):
845
846 def __init__(self, type=None):
847 if type != None:
848 self.type = type
849 else:
850 self.type = 0
851 return
852
853 def pack(self):
854 packed = []
855 packed.append(struct.pack("!H", self.type))
856 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
857 packed.append('\x00' * 4)
858 length = sum([len(x) for x in packed])
859 packed[1] = struct.pack("!H", length)
860 return ''.join(packed)
861
862 @staticmethod
863 def unpack(buf):
864 obj = action_id_push_pbb()
865 if type(buf) == loxi.generic_util.OFReader:
866 reader = buf
867 else:
868 reader = loxi.generic_util.OFReader(buf)
869 obj.type = reader.read('!H')[0]
870 _len = reader.read('!H')[0]
871 reader.skip(4)
872 return obj
873
874 def __eq__(self, other):
875 if type(self) != type(other): return False
876 if self.type != other.type: return False
877 return True
878
879 def __ne__(self, other):
880 return not self.__eq__(other)
881
882 def show(self):
883 import loxi.pp
884 return loxi.pp.pp(self)
885
886 def pretty_print(self, q):
887 q.text("action_id_push_pbb {")
888 with q.group():
889 with q.indent(2):
890 q.breakable()
891 q.text("type = ");
892 q.text("%#x" % self.type)
893 q.breakable()
894 q.text('}')
895
896class action_id_push_vlan(object):
897
898 def __init__(self, type=None):
899 if type != None:
900 self.type = type
901 else:
902 self.type = 0
903 return
904
905 def pack(self):
906 packed = []
907 packed.append(struct.pack("!H", self.type))
908 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
909 packed.append('\x00' * 4)
910 length = sum([len(x) for x in packed])
911 packed[1] = struct.pack("!H", length)
912 return ''.join(packed)
913
914 @staticmethod
915 def unpack(buf):
916 obj = action_id_push_vlan()
917 if type(buf) == loxi.generic_util.OFReader:
918 reader = buf
919 else:
920 reader = loxi.generic_util.OFReader(buf)
921 obj.type = reader.read('!H')[0]
922 _len = reader.read('!H')[0]
923 reader.skip(4)
924 return obj
925
926 def __eq__(self, other):
927 if type(self) != type(other): return False
928 if self.type != other.type: return False
929 return True
930
931 def __ne__(self, other):
932 return not self.__eq__(other)
933
934 def show(self):
935 import loxi.pp
936 return loxi.pp.pp(self)
937
938 def pretty_print(self, q):
939 q.text("action_id_push_vlan {")
940 with q.group():
941 with q.indent(2):
942 q.breakable()
943 q.text("type = ");
944 q.text("%#x" % self.type)
945 q.breakable()
946 q.text('}')
947
948class action_id_set_field(object):
949
950 def __init__(self, type=None):
951 if type != None:
952 self.type = type
953 else:
954 self.type = 0
955 return
956
957 def pack(self):
958 packed = []
959 packed.append(struct.pack("!H", self.type))
960 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
961 packed.append('\x00' * 4)
962 length = sum([len(x) for x in packed])
963 packed[1] = struct.pack("!H", length)
964 return ''.join(packed)
965
966 @staticmethod
967 def unpack(buf):
968 obj = action_id_set_field()
969 if type(buf) == loxi.generic_util.OFReader:
970 reader = buf
971 else:
972 reader = loxi.generic_util.OFReader(buf)
973 obj.type = reader.read('!H')[0]
974 _len = reader.read('!H')[0]
975 reader.skip(4)
976 return obj
977
978 def __eq__(self, other):
979 if type(self) != type(other): return False
980 if self.type != other.type: return False
981 return True
982
983 def __ne__(self, other):
984 return not self.__eq__(other)
985
986 def show(self):
987 import loxi.pp
988 return loxi.pp.pp(self)
989
990 def pretty_print(self, q):
991 q.text("action_id_set_field {")
992 with q.group():
993 with q.indent(2):
994 q.breakable()
995 q.text("type = ");
996 q.text("%#x" % self.type)
997 q.breakable()
998 q.text('}')
999
1000class action_id_set_mpls_ttl(object):
1001
1002 def __init__(self, type=None):
1003 if type != None:
1004 self.type = type
1005 else:
1006 self.type = 0
1007 return
1008
1009 def pack(self):
1010 packed = []
1011 packed.append(struct.pack("!H", self.type))
1012 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1013 packed.append('\x00' * 4)
1014 length = sum([len(x) for x in packed])
1015 packed[1] = struct.pack("!H", length)
1016 return ''.join(packed)
1017
1018 @staticmethod
1019 def unpack(buf):
1020 obj = action_id_set_mpls_ttl()
1021 if type(buf) == loxi.generic_util.OFReader:
1022 reader = buf
1023 else:
1024 reader = loxi.generic_util.OFReader(buf)
1025 obj.type = reader.read('!H')[0]
1026 _len = reader.read('!H')[0]
1027 reader.skip(4)
1028 return obj
1029
1030 def __eq__(self, other):
1031 if type(self) != type(other): return False
1032 if self.type != other.type: return False
1033 return True
1034
1035 def __ne__(self, other):
1036 return not self.__eq__(other)
1037
1038 def show(self):
1039 import loxi.pp
1040 return loxi.pp.pp(self)
1041
1042 def pretty_print(self, q):
1043 q.text("action_id_set_mpls_ttl {")
1044 with q.group():
1045 with q.indent(2):
1046 q.breakable()
1047 q.text("type = ");
1048 q.text("%#x" % self.type)
1049 q.breakable()
1050 q.text('}')
1051
1052class action_id_set_nw_ttl(object):
1053
1054 def __init__(self, type=None):
1055 if type != None:
1056 self.type = type
1057 else:
1058 self.type = 0
1059 return
1060
1061 def pack(self):
1062 packed = []
1063 packed.append(struct.pack("!H", self.type))
1064 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1065 packed.append('\x00' * 4)
1066 length = sum([len(x) for x in packed])
1067 packed[1] = struct.pack("!H", length)
1068 return ''.join(packed)
1069
1070 @staticmethod
1071 def unpack(buf):
1072 obj = action_id_set_nw_ttl()
1073 if type(buf) == loxi.generic_util.OFReader:
1074 reader = buf
1075 else:
1076 reader = loxi.generic_util.OFReader(buf)
1077 obj.type = reader.read('!H')[0]
1078 _len = reader.read('!H')[0]
1079 reader.skip(4)
1080 return obj
1081
1082 def __eq__(self, other):
1083 if type(self) != type(other): return False
1084 if self.type != other.type: return False
1085 return True
1086
1087 def __ne__(self, other):
1088 return not self.__eq__(other)
1089
1090 def show(self):
1091 import loxi.pp
1092 return loxi.pp.pp(self)
1093
1094 def pretty_print(self, q):
1095 q.text("action_id_set_nw_ttl {")
1096 with q.group():
1097 with q.indent(2):
1098 q.breakable()
1099 q.text("type = ");
1100 q.text("%#x" % self.type)
1101 q.breakable()
1102 q.text('}')
1103
1104class action_id_set_queue(object):
1105
1106 def __init__(self, type=None):
1107 if type != None:
1108 self.type = type
1109 else:
1110 self.type = 0
1111 return
1112
1113 def pack(self):
1114 packed = []
1115 packed.append(struct.pack("!H", self.type))
1116 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1117 packed.append('\x00' * 4)
1118 length = sum([len(x) for x in packed])
1119 packed[1] = struct.pack("!H", length)
1120 return ''.join(packed)
1121
1122 @staticmethod
1123 def unpack(buf):
1124 obj = action_id_set_queue()
1125 if type(buf) == loxi.generic_util.OFReader:
1126 reader = buf
1127 else:
1128 reader = loxi.generic_util.OFReader(buf)
1129 obj.type = reader.read('!H')[0]
1130 _len = reader.read('!H')[0]
1131 reader.skip(4)
1132 return obj
1133
1134 def __eq__(self, other):
1135 if type(self) != type(other): return False
1136 if self.type != other.type: return False
1137 return True
1138
1139 def __ne__(self, other):
1140 return not self.__eq__(other)
1141
1142 def show(self):
1143 import loxi.pp
1144 return loxi.pp.pp(self)
1145
1146 def pretty_print(self, q):
1147 q.text("action_id_set_queue {")
1148 with q.group():
1149 with q.indent(2):
1150 q.breakable()
1151 q.text("type = ");
1152 q.text("%#x" % self.type)
1153 q.breakable()
1154 q.text('}')
1155
1156class bsn_interface(object):
1157
1158 def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
1159 if hw_addr != None:
1160 self.hw_addr = hw_addr
1161 else:
1162 self.hw_addr = [0,0,0,0,0,0]
1163 if name != None:
1164 self.name = name
1165 else:
1166 self.name = ""
1167 if ipv4_addr != None:
1168 self.ipv4_addr = ipv4_addr
1169 else:
1170 self.ipv4_addr = 0
1171 if ipv4_netmask != None:
1172 self.ipv4_netmask = ipv4_netmask
1173 else:
1174 self.ipv4_netmask = 0
1175 return
1176
1177 def pack(self):
1178 packed = []
1179 packed.append(struct.pack("!6B", *self.hw_addr))
1180 packed.append('\x00' * 2)
1181 packed.append(struct.pack("!16s", self.name))
1182 packed.append(struct.pack("!L", self.ipv4_addr))
1183 packed.append(struct.pack("!L", self.ipv4_netmask))
1184 return ''.join(packed)
1185
1186 @staticmethod
1187 def unpack(buf):
1188 obj = bsn_interface()
1189 if type(buf) == loxi.generic_util.OFReader:
1190 reader = buf
1191 else:
1192 reader = loxi.generic_util.OFReader(buf)
1193 obj.hw_addr = list(reader.read('!6B'))
1194 reader.skip(2)
1195 obj.name = reader.read("!16s")[0].rstrip("\x00")
1196 obj.ipv4_addr = reader.read('!L')[0]
1197 obj.ipv4_netmask = reader.read('!L')[0]
1198 return obj
1199
1200 def __eq__(self, other):
1201 if type(self) != type(other): return False
1202 if self.hw_addr != other.hw_addr: return False
1203 if self.name != other.name: return False
1204 if self.ipv4_addr != other.ipv4_addr: return False
1205 if self.ipv4_netmask != other.ipv4_netmask: return False
1206 return True
1207
1208 def __ne__(self, other):
1209 return not self.__eq__(other)
1210
1211 def show(self):
1212 import loxi.pp
1213 return loxi.pp.pp(self)
1214
1215 def pretty_print(self, q):
1216 q.text("bsn_interface {")
1217 with q.group():
1218 with q.indent(2):
1219 q.breakable()
1220 q.text("hw_addr = ");
1221 q.text(util.pretty_mac(self.hw_addr))
1222 q.text(","); q.breakable()
1223 q.text("name = ");
1224 q.pp(self.name)
1225 q.text(","); q.breakable()
1226 q.text("ipv4_addr = ");
1227 q.text(util.pretty_ipv4(self.ipv4_addr))
1228 q.text(","); q.breakable()
1229 q.text("ipv4_netmask = ");
1230 q.text(util.pretty_ipv4(self.ipv4_netmask))
1231 q.breakable()
1232 q.text('}')
1233
1234class bucket(object):
1235
1236 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
1237 if weight != None:
1238 self.weight = weight
1239 else:
1240 self.weight = 0
1241 if watch_port != None:
1242 self.watch_port = watch_port
1243 else:
1244 self.watch_port = 0
1245 if watch_group != None:
1246 self.watch_group = watch_group
1247 else:
1248 self.watch_group = 0
1249 if actions != None:
1250 self.actions = actions
1251 else:
1252 self.actions = []
1253 return
1254
1255 def pack(self):
1256 packed = []
1257 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
1258 packed.append(struct.pack("!H", self.weight))
1259 packed.append(struct.pack("!L", self.watch_port))
1260 packed.append(struct.pack("!L", self.watch_group))
1261 packed.append('\x00' * 4)
1262 packed.append("".join([x.pack() for x in self.actions]))
1263 length = sum([len(x) for x in packed])
1264 packed[0] = struct.pack("!H", length)
1265 return ''.join(packed)
1266
1267 @staticmethod
1268 def unpack(buf):
1269 obj = bucket()
1270 if type(buf) == loxi.generic_util.OFReader:
1271 reader = buf
1272 else:
1273 reader = loxi.generic_util.OFReader(buf)
1274 _len = reader.read('!H')[0]
1275 obj.weight = reader.read('!H')[0]
1276 obj.watch_port = reader.read('!L')[0]
1277 obj.watch_group = reader.read('!L')[0]
1278 reader.skip(4)
1279 obj.actions = action.unpack_list(reader)
1280 return obj
1281
1282 def __eq__(self, other):
1283 if type(self) != type(other): return False
1284 if self.weight != other.weight: return False
1285 if self.watch_port != other.watch_port: return False
1286 if self.watch_group != other.watch_group: return False
1287 if self.actions != other.actions: return False
1288 return True
1289
1290 def __ne__(self, other):
1291 return not self.__eq__(other)
1292
1293 def show(self):
1294 import loxi.pp
1295 return loxi.pp.pp(self)
1296
1297 def pretty_print(self, q):
1298 q.text("bucket {")
1299 with q.group():
1300 with q.indent(2):
1301 q.breakable()
1302 q.text("weight = ");
1303 q.text("%#x" % self.weight)
1304 q.text(","); q.breakable()
1305 q.text("watch_port = ");
1306 q.text(util.pretty_port(self.watch_port))
1307 q.text(","); q.breakable()
1308 q.text("watch_group = ");
1309 q.text("%#x" % self.watch_group)
1310 q.text(","); q.breakable()
1311 q.text("actions = ");
1312 q.pp(self.actions)
1313 q.breakable()
1314 q.text('}')
1315
1316class bucket_counter(object):
1317
1318 def __init__(self, packet_count=None, byte_count=None):
1319 if packet_count != None:
1320 self.packet_count = packet_count
1321 else:
1322 self.packet_count = 0
1323 if byte_count != None:
1324 self.byte_count = byte_count
1325 else:
1326 self.byte_count = 0
1327 return
1328
1329 def pack(self):
1330 packed = []
1331 packed.append(struct.pack("!Q", self.packet_count))
1332 packed.append(struct.pack("!Q", self.byte_count))
1333 return ''.join(packed)
1334
1335 @staticmethod
1336 def unpack(buf):
1337 obj = bucket_counter()
1338 if type(buf) == loxi.generic_util.OFReader:
1339 reader = buf
1340 else:
1341 reader = loxi.generic_util.OFReader(buf)
1342 obj.packet_count = reader.read('!Q')[0]
1343 obj.byte_count = reader.read('!Q')[0]
1344 return obj
1345
1346 def __eq__(self, other):
1347 if type(self) != type(other): return False
1348 if self.packet_count != other.packet_count: return False
1349 if self.byte_count != other.byte_count: return False
1350 return True
1351
1352 def __ne__(self, other):
1353 return not self.__eq__(other)
1354
1355 def show(self):
1356 import loxi.pp
1357 return loxi.pp.pp(self)
1358
1359 def pretty_print(self, q):
1360 q.text("bucket_counter {")
1361 with q.group():
1362 with q.indent(2):
1363 q.breakable()
1364 q.text("packet_count = ");
1365 q.text("%#x" % self.packet_count)
1366 q.text(","); q.breakable()
1367 q.text("byte_count = ");
1368 q.text("%#x" % self.byte_count)
1369 q.breakable()
1370 q.text('}')
1371
1372class flow_stats_entry(object):
1373
1374 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):
1375 if table_id != None:
1376 self.table_id = table_id
1377 else:
1378 self.table_id = 0
1379 if duration_sec != None:
1380 self.duration_sec = duration_sec
1381 else:
1382 self.duration_sec = 0
1383 if duration_nsec != None:
1384 self.duration_nsec = duration_nsec
1385 else:
1386 self.duration_nsec = 0
1387 if priority != None:
1388 self.priority = priority
1389 else:
1390 self.priority = 0
1391 if idle_timeout != None:
1392 self.idle_timeout = idle_timeout
1393 else:
1394 self.idle_timeout = 0
1395 if hard_timeout != None:
1396 self.hard_timeout = hard_timeout
1397 else:
1398 self.hard_timeout = 0
1399 if cookie != None:
1400 self.cookie = cookie
1401 else:
1402 self.cookie = 0
1403 if packet_count != None:
1404 self.packet_count = packet_count
1405 else:
1406 self.packet_count = 0
1407 if byte_count != None:
1408 self.byte_count = byte_count
1409 else:
1410 self.byte_count = 0
1411 if match != None:
1412 self.match = match
1413 else:
1414 self.match = common.match()
1415 if instructions != None:
1416 self.instructions = instructions
1417 else:
1418 self.instructions = []
1419 return
1420
1421 def pack(self):
1422 packed = []
1423 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1424 packed.append(struct.pack("!B", self.table_id))
1425 packed.append('\x00' * 1)
1426 packed.append(struct.pack("!L", self.duration_sec))
1427 packed.append(struct.pack("!L", self.duration_nsec))
1428 packed.append(struct.pack("!H", self.priority))
1429 packed.append(struct.pack("!H", self.idle_timeout))
1430 packed.append(struct.pack("!H", self.hard_timeout))
1431 packed.append('\x00' * 6)
1432 packed.append(struct.pack("!Q", self.cookie))
1433 packed.append(struct.pack("!Q", self.packet_count))
1434 packed.append(struct.pack("!Q", self.byte_count))
1435 packed.append(self.match.pack())
1436 packed.append("".join([x.pack() for x in self.instructions]))
1437 length = sum([len(x) for x in packed])
1438 packed[0] = struct.pack("!H", length)
1439 return ''.join(packed)
1440
1441 @staticmethod
1442 def unpack(buf):
1443 obj = flow_stats_entry()
1444 if type(buf) == loxi.generic_util.OFReader:
1445 reader = buf
1446 else:
1447 reader = loxi.generic_util.OFReader(buf)
1448 _length = reader.read('!H')[0]
1449 obj.table_id = reader.read('!B')[0]
1450 reader.skip(1)
1451 obj.duration_sec = reader.read('!L')[0]
1452 obj.duration_nsec = reader.read('!L')[0]
1453 obj.priority = reader.read('!H')[0]
1454 obj.idle_timeout = reader.read('!H')[0]
1455 obj.hard_timeout = reader.read('!H')[0]
1456 reader.skip(6)
1457 obj.cookie = reader.read('!Q')[0]
1458 obj.packet_count = reader.read('!Q')[0]
1459 obj.byte_count = reader.read('!Q')[0]
1460 obj.match = common.match.unpack(reader)
1461 obj.instructions = instruction.unpack_list(reader)
1462 return obj
1463
1464 def __eq__(self, other):
1465 if type(self) != type(other): return False
1466 if self.table_id != other.table_id: return False
1467 if self.duration_sec != other.duration_sec: return False
1468 if self.duration_nsec != other.duration_nsec: return False
1469 if self.priority != other.priority: return False
1470 if self.idle_timeout != other.idle_timeout: return False
1471 if self.hard_timeout != other.hard_timeout: return False
1472 if self.cookie != other.cookie: return False
1473 if self.packet_count != other.packet_count: return False
1474 if self.byte_count != other.byte_count: return False
1475 if self.match != other.match: return False
1476 if self.instructions != other.instructions: return False
1477 return True
1478
1479 def __ne__(self, other):
1480 return not self.__eq__(other)
1481
1482 def show(self):
1483 import loxi.pp
1484 return loxi.pp.pp(self)
1485
1486 def pretty_print(self, q):
1487 q.text("flow_stats_entry {")
1488 with q.group():
1489 with q.indent(2):
1490 q.breakable()
1491 q.text("table_id = ");
1492 q.text("%#x" % self.table_id)
1493 q.text(","); q.breakable()
1494 q.text("duration_sec = ");
1495 q.text("%#x" % self.duration_sec)
1496 q.text(","); q.breakable()
1497 q.text("duration_nsec = ");
1498 q.text("%#x" % self.duration_nsec)
1499 q.text(","); q.breakable()
1500 q.text("priority = ");
1501 q.text("%#x" % self.priority)
1502 q.text(","); q.breakable()
1503 q.text("idle_timeout = ");
1504 q.text("%#x" % self.idle_timeout)
1505 q.text(","); q.breakable()
1506 q.text("hard_timeout = ");
1507 q.text("%#x" % self.hard_timeout)
1508 q.text(","); q.breakable()
1509 q.text("cookie = ");
1510 q.text("%#x" % self.cookie)
1511 q.text(","); q.breakable()
1512 q.text("packet_count = ");
1513 q.text("%#x" % self.packet_count)
1514 q.text(","); q.breakable()
1515 q.text("byte_count = ");
1516 q.text("%#x" % self.byte_count)
1517 q.text(","); q.breakable()
1518 q.text("match = ");
1519 q.pp(self.match)
1520 q.text(","); q.breakable()
1521 q.text("instructions = ");
1522 q.pp(self.instructions)
1523 q.breakable()
1524 q.text('}')
1525
1526class group_desc_stats_entry(object):
1527
1528 def __init__(self, type=None, group_id=None, buckets=None):
1529 if type != None:
1530 self.type = type
1531 else:
1532 self.type = 0
1533 if group_id != None:
1534 self.group_id = group_id
1535 else:
1536 self.group_id = 0
1537 if buckets != None:
1538 self.buckets = buckets
1539 else:
1540 self.buckets = []
1541 return
1542
1543 def pack(self):
1544 packed = []
1545 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1546 packed.append(struct.pack("!B", self.type))
1547 packed.append('\x00' * 1)
1548 packed.append(struct.pack("!L", self.group_id))
1549 packed.append("".join([x.pack() for x in self.buckets]))
1550 length = sum([len(x) for x in packed])
1551 packed[0] = struct.pack("!H", length)
1552 return ''.join(packed)
1553
1554 @staticmethod
1555 def unpack(buf):
1556 obj = group_desc_stats_entry()
1557 if type(buf) == loxi.generic_util.OFReader:
1558 reader = buf
1559 else:
1560 reader = loxi.generic_util.OFReader(buf)
1561 _length = reader.read('!H')[0]
1562 obj.type = reader.read('!B')[0]
1563 reader.skip(1)
1564 obj.group_id = reader.read('!L')[0]
1565 obj.buckets = common.unpack_list_bucket(reader)
1566 return obj
1567
1568 def __eq__(self, other):
1569 if type(self) != type(other): return False
1570 if self.type != other.type: return False
1571 if self.group_id != other.group_id: return False
1572 if self.buckets != other.buckets: return False
1573 return True
1574
1575 def __ne__(self, other):
1576 return not self.__eq__(other)
1577
1578 def show(self):
1579 import loxi.pp
1580 return loxi.pp.pp(self)
1581
1582 def pretty_print(self, q):
1583 q.text("group_desc_stats_entry {")
1584 with q.group():
1585 with q.indent(2):
1586 q.breakable()
1587 q.text("type = ");
1588 q.text("%#x" % self.type)
1589 q.text(","); q.breakable()
1590 q.text("group_id = ");
1591 q.text("%#x" % self.group_id)
1592 q.text(","); q.breakable()
1593 q.text("buckets = ");
1594 q.pp(self.buckets)
1595 q.breakable()
1596 q.text('}')
1597
1598class group_stats_entry(object):
1599
1600 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, duration_sec=None, duration_nsec=None, bucket_stats=None):
1601 if group_id != None:
1602 self.group_id = group_id
1603 else:
1604 self.group_id = 0
1605 if ref_count != None:
1606 self.ref_count = ref_count
1607 else:
1608 self.ref_count = 0
1609 if packet_count != None:
1610 self.packet_count = packet_count
1611 else:
1612 self.packet_count = 0
1613 if byte_count != None:
1614 self.byte_count = byte_count
1615 else:
1616 self.byte_count = 0
1617 if duration_sec != None:
1618 self.duration_sec = duration_sec
1619 else:
1620 self.duration_sec = 0
1621 if duration_nsec != None:
1622 self.duration_nsec = duration_nsec
1623 else:
1624 self.duration_nsec = 0
1625 if bucket_stats != None:
1626 self.bucket_stats = bucket_stats
1627 else:
1628 self.bucket_stats = []
1629 return
1630
1631 def pack(self):
1632 packed = []
1633 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1634 packed.append('\x00' * 2)
1635 packed.append(struct.pack("!L", self.group_id))
1636 packed.append(struct.pack("!L", self.ref_count))
1637 packed.append('\x00' * 4)
1638 packed.append(struct.pack("!Q", self.packet_count))
1639 packed.append(struct.pack("!Q", self.byte_count))
1640 packed.append(struct.pack("!L", self.duration_sec))
1641 packed.append(struct.pack("!L", self.duration_nsec))
1642 packed.append("".join([x.pack() for x in self.bucket_stats]))
1643 length = sum([len(x) for x in packed])
1644 packed[0] = struct.pack("!H", length)
1645 return ''.join(packed)
1646
1647 @staticmethod
1648 def unpack(buf):
1649 obj = group_stats_entry()
1650 if type(buf) == loxi.generic_util.OFReader:
1651 reader = buf
1652 else:
1653 reader = loxi.generic_util.OFReader(buf)
1654 _length = reader.read('!H')[0]
1655 reader.skip(2)
1656 obj.group_id = reader.read('!L')[0]
1657 obj.ref_count = reader.read('!L')[0]
1658 reader.skip(4)
1659 obj.packet_count = reader.read('!Q')[0]
1660 obj.byte_count = reader.read('!Q')[0]
1661 obj.duration_sec = reader.read('!L')[0]
1662 obj.duration_nsec = reader.read('!L')[0]
1663 obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack)
1664 return obj
1665
1666 def __eq__(self, other):
1667 if type(self) != type(other): return False
1668 if self.group_id != other.group_id: return False
1669 if self.ref_count != other.ref_count: return False
1670 if self.packet_count != other.packet_count: return False
1671 if self.byte_count != other.byte_count: return False
1672 if self.duration_sec != other.duration_sec: return False
1673 if self.duration_nsec != other.duration_nsec: return False
1674 if self.bucket_stats != other.bucket_stats: return False
1675 return True
1676
1677 def __ne__(self, other):
1678 return not self.__eq__(other)
1679
1680 def show(self):
1681 import loxi.pp
1682 return loxi.pp.pp(self)
1683
1684 def pretty_print(self, q):
1685 q.text("group_stats_entry {")
1686 with q.group():
1687 with q.indent(2):
1688 q.breakable()
1689 q.text("group_id = ");
1690 q.text("%#x" % self.group_id)
1691 q.text(","); q.breakable()
1692 q.text("ref_count = ");
1693 q.text("%#x" % self.ref_count)
1694 q.text(","); q.breakable()
1695 q.text("packet_count = ");
1696 q.text("%#x" % self.packet_count)
1697 q.text(","); q.breakable()
1698 q.text("byte_count = ");
1699 q.text("%#x" % self.byte_count)
1700 q.text(","); q.breakable()
1701 q.text("duration_sec = ");
1702 q.text("%#x" % self.duration_sec)
1703 q.text(","); q.breakable()
1704 q.text("duration_nsec = ");
1705 q.text("%#x" % self.duration_nsec)
1706 q.text(","); q.breakable()
1707 q.text("bucket_stats = ");
1708 q.pp(self.bucket_stats)
1709 q.breakable()
1710 q.text('}')
1711
1712class hello_elem_versionbitmap(object):
1713 type = const.OFPHET_VERSIONBITMAP
1714
1715 def __init__(self, bitmaps=None):
1716 if bitmaps != None:
1717 self.bitmaps = bitmaps
1718 else:
1719 self.bitmaps = []
1720 return
1721
1722 def pack(self):
1723 packed = []
1724 packed.append(struct.pack("!H", self.type))
1725 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
1726 packed.append("".join([x.pack() for x in self.bitmaps]))
1727 length = sum([len(x) for x in packed])
1728 packed[1] = struct.pack("!H", length)
1729 return ''.join(packed)
1730
1731 @staticmethod
1732 def unpack(buf):
1733 obj = hello_elem_versionbitmap()
1734 if type(buf) == loxi.generic_util.OFReader:
1735 reader = buf
1736 else:
1737 reader = loxi.generic_util.OFReader(buf)
1738 _type = reader.read('!H')[0]
1739 assert(_type == const.OFPHET_VERSIONBITMAP)
1740 _length = reader.read('!H')[0]
1741 obj.bitmaps = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
1742 return obj
1743
1744 def __eq__(self, other):
1745 if type(self) != type(other): return False
1746 if self.bitmaps != other.bitmaps: return False
1747 return True
1748
1749 def __ne__(self, other):
1750 return not self.__eq__(other)
1751
1752 def show(self):
1753 import loxi.pp
1754 return loxi.pp.pp(self)
1755
1756 def pretty_print(self, q):
1757 q.text("hello_elem_versionbitmap {")
1758 with q.group():
1759 with q.indent(2):
1760 q.breakable()
1761 q.text("bitmaps = ");
1762 q.pp(self.bitmaps)
1763 q.breakable()
1764 q.text('}')
1765
1766class match_v3(object):
1767 type = 1
1768
1769 def __init__(self, oxm_list=None):
1770 if oxm_list != None:
1771 self.oxm_list = oxm_list
1772 else:
1773 self.oxm_list = []
1774 return
1775
1776 def pack(self):
1777 packed = []
1778 packed.append(struct.pack("!H", self.type))
1779 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
1780 packed.append("".join([x.pack() for x in self.oxm_list]))
1781 length = sum([len(x) for x in packed])
1782 packed[1] = struct.pack("!H", length)
1783 packed.append('\x00' * ((length + 7)/8*8 - length))
1784 return ''.join(packed)
1785
1786 @staticmethod
1787 def unpack(buf):
1788 obj = match_v3()
1789 if type(buf) == loxi.generic_util.OFReader:
1790 reader = buf
1791 else:
1792 reader = loxi.generic_util.OFReader(buf)
1793 _type = reader.read('!H')[0]
1794 assert(_type == 1)
1795 _length = reader.read('!H')[0]
1796 obj.oxm_list = oxm.unpack_list(reader.slice(_length-4))
1797 reader.skip((_length + 7)/8*8 - _length)
1798 return obj
1799
1800 def __eq__(self, other):
1801 if type(self) != type(other): return False
1802 if self.oxm_list != other.oxm_list: return False
1803 return True
1804
1805 def __ne__(self, other):
1806 return not self.__eq__(other)
1807
1808 def show(self):
1809 import loxi.pp
1810 return loxi.pp.pp(self)
1811
1812 def pretty_print(self, q):
1813 q.text("match_v3 {")
1814 with q.group():
1815 with q.indent(2):
1816 q.breakable()
1817 q.text("oxm_list = ");
1818 q.pp(self.oxm_list)
1819 q.breakable()
1820 q.text('}')
1821
1822class meter_band_stats(object):
1823
1824 def __init__(self, packet_band_count=None, byte_band_count=None):
1825 if packet_band_count != None:
1826 self.packet_band_count = packet_band_count
1827 else:
1828 self.packet_band_count = 0
1829 if byte_band_count != None:
1830 self.byte_band_count = byte_band_count
1831 else:
1832 self.byte_band_count = 0
1833 return
1834
1835 def pack(self):
1836 packed = []
1837 packed.append(struct.pack("!Q", self.packet_band_count))
1838 packed.append(struct.pack("!Q", self.byte_band_count))
1839 return ''.join(packed)
1840
1841 @staticmethod
1842 def unpack(buf):
1843 obj = meter_band_stats()
1844 if type(buf) == loxi.generic_util.OFReader:
1845 reader = buf
1846 else:
1847 reader = loxi.generic_util.OFReader(buf)
1848 obj.packet_band_count = reader.read('!Q')[0]
1849 obj.byte_band_count = reader.read('!Q')[0]
1850 return obj
1851
1852 def __eq__(self, other):
1853 if type(self) != type(other): return False
1854 if self.packet_band_count != other.packet_band_count: return False
1855 if self.byte_band_count != other.byte_band_count: return False
1856 return True
1857
1858 def __ne__(self, other):
1859 return not self.__eq__(other)
1860
1861 def show(self):
1862 import loxi.pp
1863 return loxi.pp.pp(self)
1864
1865 def pretty_print(self, q):
1866 q.text("meter_band_stats {")
1867 with q.group():
1868 with q.indent(2):
1869 q.breakable()
1870 q.text("packet_band_count = ");
1871 q.text("%#x" % self.packet_band_count)
1872 q.text(","); q.breakable()
1873 q.text("byte_band_count = ");
1874 q.text("%#x" % self.byte_band_count)
1875 q.breakable()
1876 q.text('}')
1877
1878class meter_config(object):
1879
1880 def __init__(self, flags=None, meter_id=None, entries=None):
1881 if flags != None:
1882 self.flags = flags
1883 else:
1884 self.flags = 0
1885 if meter_id != None:
1886 self.meter_id = meter_id
1887 else:
1888 self.meter_id = 0
1889 if entries != None:
1890 self.entries = entries
1891 else:
1892 self.entries = []
1893 return
1894
1895 def pack(self):
1896 packed = []
1897 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1898 packed.append(struct.pack("!H", self.flags))
1899 packed.append(struct.pack("!L", self.meter_id))
1900 packed.append("".join([x.pack() for x in self.entries]))
1901 length = sum([len(x) for x in packed])
1902 packed[0] = struct.pack("!H", length)
1903 return ''.join(packed)
1904
1905 @staticmethod
1906 def unpack(buf):
1907 obj = meter_config()
1908 if type(buf) == loxi.generic_util.OFReader:
1909 reader = buf
1910 else:
1911 reader = loxi.generic_util.OFReader(buf)
1912 _length = reader.read('!H')[0]
1913 obj.flags = reader.read('!H')[0]
1914 obj.meter_id = reader.read('!L')[0]
1915 obj.entries = meter_band.unpack_list(reader)
1916 return obj
1917
1918 def __eq__(self, other):
1919 if type(self) != type(other): return False
1920 if self.flags != other.flags: return False
1921 if self.meter_id != other.meter_id: return False
1922 if self.entries != other.entries: return False
1923 return True
1924
1925 def __ne__(self, other):
1926 return not self.__eq__(other)
1927
1928 def show(self):
1929 import loxi.pp
1930 return loxi.pp.pp(self)
1931
1932 def pretty_print(self, q):
1933 q.text("meter_config {")
1934 with q.group():
1935 with q.indent(2):
1936 q.breakable()
1937 q.text("flags = ");
1938 q.text("%#x" % self.flags)
1939 q.text(","); q.breakable()
1940 q.text("meter_id = ");
1941 q.text("%#x" % self.meter_id)
1942 q.text(","); q.breakable()
1943 q.text("entries = ");
1944 q.pp(self.entries)
1945 q.breakable()
1946 q.text('}')
1947
1948class meter_features(object):
1949
1950 def __init__(self, max_meter=None, band_types=None, capabilities=None, max_bands=None, max_color=None):
1951 if max_meter != None:
1952 self.max_meter = max_meter
1953 else:
1954 self.max_meter = 0
1955 if band_types != None:
1956 self.band_types = band_types
1957 else:
1958 self.band_types = 0
1959 if capabilities != None:
1960 self.capabilities = capabilities
1961 else:
1962 self.capabilities = 0
1963 if max_bands != None:
1964 self.max_bands = max_bands
1965 else:
1966 self.max_bands = 0
1967 if max_color != None:
1968 self.max_color = max_color
1969 else:
1970 self.max_color = 0
1971 return
1972
1973 def pack(self):
1974 packed = []
1975 packed.append(struct.pack("!L", self.max_meter))
1976 packed.append(struct.pack("!L", self.band_types))
1977 packed.append(struct.pack("!L", self.capabilities))
1978 packed.append(struct.pack("!B", self.max_bands))
1979 packed.append(struct.pack("!B", self.max_color))
1980 packed.append('\x00' * 2)
1981 return ''.join(packed)
1982
1983 @staticmethod
1984 def unpack(buf):
1985 obj = meter_features()
1986 if type(buf) == loxi.generic_util.OFReader:
1987 reader = buf
1988 else:
1989 reader = loxi.generic_util.OFReader(buf)
1990 obj.max_meter = reader.read('!L')[0]
1991 obj.band_types = reader.read('!L')[0]
1992 obj.capabilities = reader.read('!L')[0]
1993 obj.max_bands = reader.read('!B')[0]
1994 obj.max_color = reader.read('!B')[0]
1995 reader.skip(2)
1996 return obj
1997
1998 def __eq__(self, other):
1999 if type(self) != type(other): return False
2000 if self.max_meter != other.max_meter: return False
2001 if self.band_types != other.band_types: return False
2002 if self.capabilities != other.capabilities: return False
2003 if self.max_bands != other.max_bands: return False
2004 if self.max_color != other.max_color: return False
2005 return True
2006
2007 def __ne__(self, other):
2008 return not self.__eq__(other)
2009
2010 def show(self):
2011 import loxi.pp
2012 return loxi.pp.pp(self)
2013
2014 def pretty_print(self, q):
2015 q.text("meter_features {")
2016 with q.group():
2017 with q.indent(2):
2018 q.breakable()
2019 q.text("max_meter = ");
2020 q.text("%#x" % self.max_meter)
2021 q.text(","); q.breakable()
2022 q.text("band_types = ");
2023 q.text("%#x" % self.band_types)
2024 q.text(","); q.breakable()
2025 q.text("capabilities = ");
2026 q.text("%#x" % self.capabilities)
2027 q.text(","); q.breakable()
2028 q.text("max_bands = ");
2029 q.text("%#x" % self.max_bands)
2030 q.text(","); q.breakable()
2031 q.text("max_color = ");
2032 q.text("%#x" % self.max_color)
2033 q.breakable()
2034 q.text('}')
2035
2036class meter_stats(object):
2037
2038 def __init__(self, meter_id=None, flow_count=None, packet_in_count=None, byte_in_count=None, duration_sec=None, duration_nsec=None, band_stats=None):
2039 if meter_id != None:
2040 self.meter_id = meter_id
2041 else:
2042 self.meter_id = 0
2043 if flow_count != None:
2044 self.flow_count = flow_count
2045 else:
2046 self.flow_count = 0
2047 if packet_in_count != None:
2048 self.packet_in_count = packet_in_count
2049 else:
2050 self.packet_in_count = 0
2051 if byte_in_count != None:
2052 self.byte_in_count = byte_in_count
2053 else:
2054 self.byte_in_count = 0
2055 if duration_sec != None:
2056 self.duration_sec = duration_sec
2057 else:
2058 self.duration_sec = 0
2059 if duration_nsec != None:
2060 self.duration_nsec = duration_nsec
2061 else:
2062 self.duration_nsec = 0
2063 if band_stats != None:
2064 self.band_stats = band_stats
2065 else:
2066 self.band_stats = []
2067 return
2068
2069 def pack(self):
2070 packed = []
2071 packed.append(struct.pack("!L", self.meter_id))
2072 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2073 packed.append('\x00' * 6)
2074 packed.append(struct.pack("!L", self.flow_count))
2075 packed.append(struct.pack("!Q", self.packet_in_count))
2076 packed.append(struct.pack("!Q", self.byte_in_count))
2077 packed.append(struct.pack("!L", self.duration_sec))
2078 packed.append(struct.pack("!L", self.duration_nsec))
2079 packed.append("".join([x.pack() for x in self.band_stats]))
2080 length = sum([len(x) for x in packed])
2081 packed[1] = struct.pack("!H", length)
2082 return ''.join(packed)
2083
2084 @staticmethod
2085 def unpack(buf):
2086 obj = meter_stats()
2087 if type(buf) == loxi.generic_util.OFReader:
2088 reader = buf
2089 else:
2090 reader = loxi.generic_util.OFReader(buf)
2091 obj.meter_id = reader.read('!L')[0]
2092 _len = reader.read('!H')[0]
2093 reader.skip(6)
2094 obj.flow_count = reader.read('!L')[0]
2095 obj.packet_in_count = reader.read('!Q')[0]
2096 obj.byte_in_count = reader.read('!Q')[0]
2097 obj.duration_sec = reader.read('!L')[0]
2098 obj.duration_nsec = reader.read('!L')[0]
2099 obj.band_stats = loxi.generic_util.unpack_list(reader, common.meter_band_stats.unpack)
2100 return obj
2101
2102 def __eq__(self, other):
2103 if type(self) != type(other): return False
2104 if self.meter_id != other.meter_id: return False
2105 if self.flow_count != other.flow_count: return False
2106 if self.packet_in_count != other.packet_in_count: return False
2107 if self.byte_in_count != other.byte_in_count: return False
2108 if self.duration_sec != other.duration_sec: return False
2109 if self.duration_nsec != other.duration_nsec: return False
2110 if self.band_stats != other.band_stats: return False
2111 return True
2112
2113 def __ne__(self, other):
2114 return not self.__eq__(other)
2115
2116 def show(self):
2117 import loxi.pp
2118 return loxi.pp.pp(self)
2119
2120 def pretty_print(self, q):
2121 q.text("meter_stats {")
2122 with q.group():
2123 with q.indent(2):
2124 q.breakable()
2125 q.text("meter_id = ");
2126 q.text("%#x" % self.meter_id)
2127 q.text(","); q.breakable()
2128 q.text("flow_count = ");
2129 q.text("%#x" % self.flow_count)
2130 q.text(","); q.breakable()
2131 q.text("packet_in_count = ");
2132 q.text("%#x" % self.packet_in_count)
2133 q.text(","); q.breakable()
2134 q.text("byte_in_count = ");
2135 q.text("%#x" % self.byte_in_count)
2136 q.text(","); q.breakable()
2137 q.text("duration_sec = ");
2138 q.text("%#x" % self.duration_sec)
2139 q.text(","); q.breakable()
2140 q.text("duration_nsec = ");
2141 q.text("%#x" % self.duration_nsec)
2142 q.text(","); q.breakable()
2143 q.text("band_stats = ");
2144 q.pp(self.band_stats)
2145 q.breakable()
2146 q.text('}')
2147
2148class packet_queue(object):
2149
2150 def __init__(self, queue_id=None, port=None, properties=None):
2151 if queue_id != None:
2152 self.queue_id = queue_id
2153 else:
2154 self.queue_id = 0
2155 if port != None:
2156 self.port = port
2157 else:
2158 self.port = 0
2159 if properties != None:
2160 self.properties = properties
2161 else:
2162 self.properties = []
2163 return
2164
2165 def pack(self):
2166 packed = []
2167 packed.append(struct.pack("!L", self.queue_id))
2168 packed.append(struct.pack("!L", self.port))
2169 packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
2170 packed.append('\x00' * 6)
2171 packed.append("".join([x.pack() for x in self.properties]))
2172 length = sum([len(x) for x in packed])
2173 packed[2] = struct.pack("!H", length)
2174 return ''.join(packed)
2175
2176 @staticmethod
2177 def unpack(buf):
2178 obj = packet_queue()
2179 if type(buf) == loxi.generic_util.OFReader:
2180 reader = buf
2181 else:
2182 reader = loxi.generic_util.OFReader(buf)
2183 obj.queue_id = reader.read('!L')[0]
2184 obj.port = reader.read('!L')[0]
2185 _len = reader.read('!H')[0]
2186 reader.skip(6)
2187 obj.properties = common.unpack_list_queue_prop(reader)
2188 return obj
2189
2190 def __eq__(self, other):
2191 if type(self) != type(other): return False
2192 if self.queue_id != other.queue_id: return False
2193 if self.port != other.port: return False
2194 if self.properties != other.properties: return False
2195 return True
2196
2197 def __ne__(self, other):
2198 return not self.__eq__(other)
2199
2200 def show(self):
2201 import loxi.pp
2202 return loxi.pp.pp(self)
2203
2204 def pretty_print(self, q):
2205 q.text("packet_queue {")
2206 with q.group():
2207 with q.indent(2):
2208 q.breakable()
2209 q.text("queue_id = ");
2210 q.text("%#x" % self.queue_id)
2211 q.text(","); q.breakable()
2212 q.text("port = ");
2213 q.text(util.pretty_port(self.port))
2214 q.text(","); q.breakable()
2215 q.text("properties = ");
2216 q.pp(self.properties)
2217 q.breakable()
2218 q.text('}')
2219
2220class port_desc(object):
2221
2222 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):
2223 if port_no != None:
2224 self.port_no = port_no
2225 else:
2226 self.port_no = 0
2227 if hw_addr != None:
2228 self.hw_addr = hw_addr
2229 else:
2230 self.hw_addr = [0,0,0,0,0,0]
2231 if name != None:
2232 self.name = name
2233 else:
2234 self.name = ""
2235 if config != None:
2236 self.config = config
2237 else:
2238 self.config = 0
2239 if state != None:
2240 self.state = state
2241 else:
2242 self.state = 0
2243 if curr != None:
2244 self.curr = curr
2245 else:
2246 self.curr = 0
2247 if advertised != None:
2248 self.advertised = advertised
2249 else:
2250 self.advertised = 0
2251 if supported != None:
2252 self.supported = supported
2253 else:
2254 self.supported = 0
2255 if peer != None:
2256 self.peer = peer
2257 else:
2258 self.peer = 0
2259 if curr_speed != None:
2260 self.curr_speed = curr_speed
2261 else:
2262 self.curr_speed = 0
2263 if max_speed != None:
2264 self.max_speed = max_speed
2265 else:
2266 self.max_speed = 0
2267 return
2268
2269 def pack(self):
2270 packed = []
2271 packed.append(struct.pack("!L", self.port_no))
2272 packed.append('\x00' * 4)
2273 packed.append(struct.pack("!6B", *self.hw_addr))
2274 packed.append('\x00' * 2)
2275 packed.append(struct.pack("!16s", self.name))
2276 packed.append(struct.pack("!L", self.config))
2277 packed.append(struct.pack("!L", self.state))
2278 packed.append(struct.pack("!L", self.curr))
2279 packed.append(struct.pack("!L", self.advertised))
2280 packed.append(struct.pack("!L", self.supported))
2281 packed.append(struct.pack("!L", self.peer))
2282 packed.append(struct.pack("!L", self.curr_speed))
2283 packed.append(struct.pack("!L", self.max_speed))
2284 return ''.join(packed)
2285
2286 @staticmethod
2287 def unpack(buf):
2288 obj = port_desc()
2289 if type(buf) == loxi.generic_util.OFReader:
2290 reader = buf
2291 else:
2292 reader = loxi.generic_util.OFReader(buf)
2293 obj.port_no = reader.read('!L')[0]
2294 reader.skip(4)
2295 obj.hw_addr = list(reader.read('!6B'))
2296 reader.skip(2)
2297 obj.name = reader.read("!16s")[0].rstrip("\x00")
2298 obj.config = reader.read('!L')[0]
2299 obj.state = reader.read('!L')[0]
2300 obj.curr = reader.read('!L')[0]
2301 obj.advertised = reader.read('!L')[0]
2302 obj.supported = reader.read('!L')[0]
2303 obj.peer = reader.read('!L')[0]
2304 obj.curr_speed = reader.read('!L')[0]
2305 obj.max_speed = reader.read('!L')[0]
2306 return obj
2307
2308 def __eq__(self, other):
2309 if type(self) != type(other): return False
2310 if self.port_no != other.port_no: return False
2311 if self.hw_addr != other.hw_addr: return False
2312 if self.name != other.name: return False
2313 if self.config != other.config: return False
2314 if self.state != other.state: return False
2315 if self.curr != other.curr: return False
2316 if self.advertised != other.advertised: return False
2317 if self.supported != other.supported: return False
2318 if self.peer != other.peer: return False
2319 if self.curr_speed != other.curr_speed: return False
2320 if self.max_speed != other.max_speed: return False
2321 return True
2322
2323 def __ne__(self, other):
2324 return not self.__eq__(other)
2325
2326 def show(self):
2327 import loxi.pp
2328 return loxi.pp.pp(self)
2329
2330 def pretty_print(self, q):
2331 q.text("port_desc {")
2332 with q.group():
2333 with q.indent(2):
2334 q.breakable()
2335 q.text("port_no = ");
2336 q.text(util.pretty_port(self.port_no))
2337 q.text(","); q.breakable()
2338 q.text("hw_addr = ");
2339 q.text(util.pretty_mac(self.hw_addr))
2340 q.text(","); q.breakable()
2341 q.text("name = ");
2342 q.pp(self.name)
2343 q.text(","); q.breakable()
2344 q.text("config = ");
2345 q.text("%#x" % self.config)
2346 q.text(","); q.breakable()
2347 q.text("state = ");
2348 q.text("%#x" % self.state)
2349 q.text(","); q.breakable()
2350 q.text("curr = ");
2351 q.text("%#x" % self.curr)
2352 q.text(","); q.breakable()
2353 q.text("advertised = ");
2354 q.text("%#x" % self.advertised)
2355 q.text(","); q.breakable()
2356 q.text("supported = ");
2357 q.text("%#x" % self.supported)
2358 q.text(","); q.breakable()
2359 q.text("peer = ");
2360 q.text("%#x" % self.peer)
2361 q.text(","); q.breakable()
2362 q.text("curr_speed = ");
2363 q.text("%#x" % self.curr_speed)
2364 q.text(","); q.breakable()
2365 q.text("max_speed = ");
2366 q.text("%#x" % self.max_speed)
2367 q.breakable()
2368 q.text('}')
2369
2370class port_stats_entry(object):
2371
2372 def __init__(self, port_no=None, rx_packets=None, tx_packets=None, rx_bytes=None, tx_bytes=None, rx_dropped=None, tx_dropped=None, rx_errors=None, tx_errors=None, rx_frame_err=None, rx_over_err=None, rx_crc_err=None, collisions=None, duration_sec=None, duration_nsec=None):
2373 if port_no != None:
2374 self.port_no = port_no
2375 else:
2376 self.port_no = 0
2377 if rx_packets != None:
2378 self.rx_packets = rx_packets
2379 else:
2380 self.rx_packets = 0
2381 if tx_packets != None:
2382 self.tx_packets = tx_packets
2383 else:
2384 self.tx_packets = 0
2385 if rx_bytes != None:
2386 self.rx_bytes = rx_bytes
2387 else:
2388 self.rx_bytes = 0
2389 if tx_bytes != None:
2390 self.tx_bytes = tx_bytes
2391 else:
2392 self.tx_bytes = 0
2393 if rx_dropped != None:
2394 self.rx_dropped = rx_dropped
2395 else:
2396 self.rx_dropped = 0
2397 if tx_dropped != None:
2398 self.tx_dropped = tx_dropped
2399 else:
2400 self.tx_dropped = 0
2401 if rx_errors != None:
2402 self.rx_errors = rx_errors
2403 else:
2404 self.rx_errors = 0
2405 if tx_errors != None:
2406 self.tx_errors = tx_errors
2407 else:
2408 self.tx_errors = 0
2409 if rx_frame_err != None:
2410 self.rx_frame_err = rx_frame_err
2411 else:
2412 self.rx_frame_err = 0
2413 if rx_over_err != None:
2414 self.rx_over_err = rx_over_err
2415 else:
2416 self.rx_over_err = 0
2417 if rx_crc_err != None:
2418 self.rx_crc_err = rx_crc_err
2419 else:
2420 self.rx_crc_err = 0
2421 if collisions != None:
2422 self.collisions = collisions
2423 else:
2424 self.collisions = 0
2425 if duration_sec != None:
2426 self.duration_sec = duration_sec
2427 else:
2428 self.duration_sec = 0
2429 if duration_nsec != None:
2430 self.duration_nsec = duration_nsec
2431 else:
2432 self.duration_nsec = 0
2433 return
2434
2435 def pack(self):
2436 packed = []
2437 packed.append(struct.pack("!L", self.port_no))
2438 packed.append('\x00' * 4)
2439 packed.append(struct.pack("!Q", self.rx_packets))
2440 packed.append(struct.pack("!Q", self.tx_packets))
2441 packed.append(struct.pack("!Q", self.rx_bytes))
2442 packed.append(struct.pack("!Q", self.tx_bytes))
2443 packed.append(struct.pack("!Q", self.rx_dropped))
2444 packed.append(struct.pack("!Q", self.tx_dropped))
2445 packed.append(struct.pack("!Q", self.rx_errors))
2446 packed.append(struct.pack("!Q", self.tx_errors))
2447 packed.append(struct.pack("!Q", self.rx_frame_err))
2448 packed.append(struct.pack("!Q", self.rx_over_err))
2449 packed.append(struct.pack("!Q", self.rx_crc_err))
2450 packed.append(struct.pack("!Q", self.collisions))
2451 packed.append(struct.pack("!L", self.duration_sec))
2452 packed.append(struct.pack("!L", self.duration_nsec))
2453 return ''.join(packed)
2454
2455 @staticmethod
2456 def unpack(buf):
2457 obj = port_stats_entry()
2458 if type(buf) == loxi.generic_util.OFReader:
2459 reader = buf
2460 else:
2461 reader = loxi.generic_util.OFReader(buf)
2462 obj.port_no = reader.read('!L')[0]
2463 reader.skip(4)
2464 obj.rx_packets = reader.read('!Q')[0]
2465 obj.tx_packets = reader.read('!Q')[0]
2466 obj.rx_bytes = reader.read('!Q')[0]
2467 obj.tx_bytes = reader.read('!Q')[0]
2468 obj.rx_dropped = reader.read('!Q')[0]
2469 obj.tx_dropped = reader.read('!Q')[0]
2470 obj.rx_errors = reader.read('!Q')[0]
2471 obj.tx_errors = reader.read('!Q')[0]
2472 obj.rx_frame_err = reader.read('!Q')[0]
2473 obj.rx_over_err = reader.read('!Q')[0]
2474 obj.rx_crc_err = reader.read('!Q')[0]
2475 obj.collisions = reader.read('!Q')[0]
2476 obj.duration_sec = reader.read('!L')[0]
2477 obj.duration_nsec = reader.read('!L')[0]
2478 return obj
2479
2480 def __eq__(self, other):
2481 if type(self) != type(other): return False
2482 if self.port_no != other.port_no: return False
2483 if self.rx_packets != other.rx_packets: return False
2484 if self.tx_packets != other.tx_packets: return False
2485 if self.rx_bytes != other.rx_bytes: return False
2486 if self.tx_bytes != other.tx_bytes: return False
2487 if self.rx_dropped != other.rx_dropped: return False
2488 if self.tx_dropped != other.tx_dropped: return False
2489 if self.rx_errors != other.rx_errors: return False
2490 if self.tx_errors != other.tx_errors: return False
2491 if self.rx_frame_err != other.rx_frame_err: return False
2492 if self.rx_over_err != other.rx_over_err: return False
2493 if self.rx_crc_err != other.rx_crc_err: return False
2494 if self.collisions != other.collisions: return False
2495 if self.duration_sec != other.duration_sec: return False
2496 if self.duration_nsec != other.duration_nsec: return False
2497 return True
2498
2499 def __ne__(self, other):
2500 return not self.__eq__(other)
2501
2502 def show(self):
2503 import loxi.pp
2504 return loxi.pp.pp(self)
2505
2506 def pretty_print(self, q):
2507 q.text("port_stats_entry {")
2508 with q.group():
2509 with q.indent(2):
2510 q.breakable()
2511 q.text("port_no = ");
2512 q.text(util.pretty_port(self.port_no))
2513 q.text(","); q.breakable()
2514 q.text("rx_packets = ");
2515 q.text("%#x" % self.rx_packets)
2516 q.text(","); q.breakable()
2517 q.text("tx_packets = ");
2518 q.text("%#x" % self.tx_packets)
2519 q.text(","); q.breakable()
2520 q.text("rx_bytes = ");
2521 q.text("%#x" % self.rx_bytes)
2522 q.text(","); q.breakable()
2523 q.text("tx_bytes = ");
2524 q.text("%#x" % self.tx_bytes)
2525 q.text(","); q.breakable()
2526 q.text("rx_dropped = ");
2527 q.text("%#x" % self.rx_dropped)
2528 q.text(","); q.breakable()
2529 q.text("tx_dropped = ");
2530 q.text("%#x" % self.tx_dropped)
2531 q.text(","); q.breakable()
2532 q.text("rx_errors = ");
2533 q.text("%#x" % self.rx_errors)
2534 q.text(","); q.breakable()
2535 q.text("tx_errors = ");
2536 q.text("%#x" % self.tx_errors)
2537 q.text(","); q.breakable()
2538 q.text("rx_frame_err = ");
2539 q.text("%#x" % self.rx_frame_err)
2540 q.text(","); q.breakable()
2541 q.text("rx_over_err = ");
2542 q.text("%#x" % self.rx_over_err)
2543 q.text(","); q.breakable()
2544 q.text("rx_crc_err = ");
2545 q.text("%#x" % self.rx_crc_err)
2546 q.text(","); q.breakable()
2547 q.text("collisions = ");
2548 q.text("%#x" % self.collisions)
2549 q.text(","); q.breakable()
2550 q.text("duration_sec = ");
2551 q.text("%#x" % self.duration_sec)
2552 q.text(","); q.breakable()
2553 q.text("duration_nsec = ");
2554 q.text("%#x" % self.duration_nsec)
2555 q.breakable()
2556 q.text('}')
2557
2558class queue_prop_experimenter(object):
2559 type = const.OFPQT_EXPERIMENTER
2560
2561 def __init__(self, experimenter=None, data=None):
2562 if experimenter != None:
2563 self.experimenter = experimenter
2564 else:
2565 self.experimenter = 0
2566 if data != None:
2567 self.data = data
2568 else:
2569 self.data = ""
2570 return
2571
2572 def pack(self):
2573 packed = []
2574 packed.append(struct.pack("!H", self.type))
2575 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2576 packed.append('\x00' * 4)
2577 packed.append(struct.pack("!L", self.experimenter))
2578 packed.append('\x00' * 4)
2579 packed.append(self.data)
2580 length = sum([len(x) for x in packed])
2581 packed[1] = struct.pack("!H", length)
2582 return ''.join(packed)
2583
2584 @staticmethod
2585 def unpack(buf):
2586 obj = queue_prop_experimenter()
2587 if type(buf) == loxi.generic_util.OFReader:
2588 reader = buf
2589 else:
2590 reader = loxi.generic_util.OFReader(buf)
2591 _type = reader.read('!H')[0]
2592 assert(_type == const.OFPQT_EXPERIMENTER)
2593 _len = reader.read('!H')[0]
2594 reader.skip(4)
2595 obj.experimenter = reader.read('!L')[0]
2596 reader.skip(4)
2597 obj.data = str(reader.read_all())
2598 return obj
2599
2600 def __eq__(self, other):
2601 if type(self) != type(other): return False
2602 if self.experimenter != other.experimenter: return False
2603 if self.data != other.data: return False
2604 return True
2605
2606 def __ne__(self, other):
2607 return not self.__eq__(other)
2608
2609 def show(self):
2610 import loxi.pp
2611 return loxi.pp.pp(self)
2612
2613 def pretty_print(self, q):
2614 q.text("queue_prop_experimenter {")
2615 with q.group():
2616 with q.indent(2):
2617 q.breakable()
2618 q.text("experimenter = ");
2619 q.text("%#x" % self.experimenter)
2620 q.text(","); q.breakable()
2621 q.text("data = ");
2622 q.pp(self.data)
2623 q.breakable()
2624 q.text('}')
2625
2626class queue_prop_max_rate(object):
2627 type = const.OFPQT_MAX_RATE
2628
2629 def __init__(self, rate=None):
2630 if rate != None:
2631 self.rate = rate
2632 else:
2633 self.rate = 0
2634 return
2635
2636 def pack(self):
2637 packed = []
2638 packed.append(struct.pack("!H", self.type))
2639 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2640 packed.append('\x00' * 4)
2641 packed.append(struct.pack("!H", self.rate))
2642 packed.append('\x00' * 6)
2643 length = sum([len(x) for x in packed])
2644 packed[1] = struct.pack("!H", length)
2645 return ''.join(packed)
2646
2647 @staticmethod
2648 def unpack(buf):
2649 obj = queue_prop_max_rate()
2650 if type(buf) == loxi.generic_util.OFReader:
2651 reader = buf
2652 else:
2653 reader = loxi.generic_util.OFReader(buf)
2654 _type = reader.read('!H')[0]
2655 assert(_type == const.OFPQT_MAX_RATE)
2656 _len = reader.read('!H')[0]
2657 reader.skip(4)
2658 obj.rate = reader.read('!H')[0]
2659 reader.skip(6)
2660 return obj
2661
2662 def __eq__(self, other):
2663 if type(self) != type(other): return False
2664 if self.rate != other.rate: return False
2665 return True
2666
2667 def __ne__(self, other):
2668 return not self.__eq__(other)
2669
2670 def show(self):
2671 import loxi.pp
2672 return loxi.pp.pp(self)
2673
2674 def pretty_print(self, q):
2675 q.text("queue_prop_max_rate {")
2676 with q.group():
2677 with q.indent(2):
2678 q.breakable()
2679 q.text("rate = ");
2680 q.text("%#x" % self.rate)
2681 q.breakable()
2682 q.text('}')
2683
2684class queue_prop_min_rate(object):
2685 type = const.OFPQT_MIN_RATE
2686
2687 def __init__(self, rate=None):
2688 if rate != None:
2689 self.rate = rate
2690 else:
2691 self.rate = 0
2692 return
2693
2694 def pack(self):
2695 packed = []
2696 packed.append(struct.pack("!H", self.type))
2697 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2698 packed.append('\x00' * 4)
2699 packed.append(struct.pack("!H", self.rate))
2700 packed.append('\x00' * 6)
2701 length = sum([len(x) for x in packed])
2702 packed[1] = struct.pack("!H", length)
2703 return ''.join(packed)
2704
2705 @staticmethod
2706 def unpack(buf):
2707 obj = queue_prop_min_rate()
2708 if type(buf) == loxi.generic_util.OFReader:
2709 reader = buf
2710 else:
2711 reader = loxi.generic_util.OFReader(buf)
2712 _type = reader.read('!H')[0]
2713 assert(_type == const.OFPQT_MIN_RATE)
2714 _len = reader.read('!H')[0]
2715 reader.skip(4)
2716 obj.rate = reader.read('!H')[0]
2717 reader.skip(6)
2718 return obj
2719
2720 def __eq__(self, other):
2721 if type(self) != type(other): return False
2722 if self.rate != other.rate: return False
2723 return True
2724
2725 def __ne__(self, other):
2726 return not self.__eq__(other)
2727
2728 def show(self):
2729 import loxi.pp
2730 return loxi.pp.pp(self)
2731
2732 def pretty_print(self, q):
2733 q.text("queue_prop_min_rate {")
2734 with q.group():
2735 with q.indent(2):
2736 q.breakable()
2737 q.text("rate = ");
2738 q.text("%#x" % self.rate)
2739 q.breakable()
2740 q.text('}')
2741
2742class queue_stats_entry(object):
2743
2744 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None, duration_sec=None, duration_nsec=None):
2745 if port_no != None:
2746 self.port_no = port_no
2747 else:
2748 self.port_no = 0
2749 if queue_id != None:
2750 self.queue_id = queue_id
2751 else:
2752 self.queue_id = 0
2753 if tx_bytes != None:
2754 self.tx_bytes = tx_bytes
2755 else:
2756 self.tx_bytes = 0
2757 if tx_packets != None:
2758 self.tx_packets = tx_packets
2759 else:
2760 self.tx_packets = 0
2761 if tx_errors != None:
2762 self.tx_errors = tx_errors
2763 else:
2764 self.tx_errors = 0
2765 if duration_sec != None:
2766 self.duration_sec = duration_sec
2767 else:
2768 self.duration_sec = 0
2769 if duration_nsec != None:
2770 self.duration_nsec = duration_nsec
2771 else:
2772 self.duration_nsec = 0
2773 return
2774
2775 def pack(self):
2776 packed = []
2777 packed.append(struct.pack("!L", self.port_no))
2778 packed.append(struct.pack("!L", self.queue_id))
2779 packed.append(struct.pack("!Q", self.tx_bytes))
2780 packed.append(struct.pack("!Q", self.tx_packets))
2781 packed.append(struct.pack("!Q", self.tx_errors))
2782 packed.append(struct.pack("!L", self.duration_sec))
2783 packed.append(struct.pack("!L", self.duration_nsec))
2784 return ''.join(packed)
2785
2786 @staticmethod
2787 def unpack(buf):
2788 obj = queue_stats_entry()
2789 if type(buf) == loxi.generic_util.OFReader:
2790 reader = buf
2791 else:
2792 reader = loxi.generic_util.OFReader(buf)
2793 obj.port_no = reader.read('!L')[0]
2794 obj.queue_id = reader.read('!L')[0]
2795 obj.tx_bytes = reader.read('!Q')[0]
2796 obj.tx_packets = reader.read('!Q')[0]
2797 obj.tx_errors = reader.read('!Q')[0]
2798 obj.duration_sec = reader.read('!L')[0]
2799 obj.duration_nsec = reader.read('!L')[0]
2800 return obj
2801
2802 def __eq__(self, other):
2803 if type(self) != type(other): return False
2804 if self.port_no != other.port_no: return False
2805 if self.queue_id != other.queue_id: return False
2806 if self.tx_bytes != other.tx_bytes: return False
2807 if self.tx_packets != other.tx_packets: return False
2808 if self.tx_errors != other.tx_errors: return False
2809 if self.duration_sec != other.duration_sec: return False
2810 if self.duration_nsec != other.duration_nsec: return False
2811 return True
2812
2813 def __ne__(self, other):
2814 return not self.__eq__(other)
2815
2816 def show(self):
2817 import loxi.pp
2818 return loxi.pp.pp(self)
2819
2820 def pretty_print(self, q):
2821 q.text("queue_stats_entry {")
2822 with q.group():
2823 with q.indent(2):
2824 q.breakable()
2825 q.text("port_no = ");
2826 q.text(util.pretty_port(self.port_no))
2827 q.text(","); q.breakable()
2828 q.text("queue_id = ");
2829 q.text("%#x" % self.queue_id)
2830 q.text(","); q.breakable()
2831 q.text("tx_bytes = ");
2832 q.text("%#x" % self.tx_bytes)
2833 q.text(","); q.breakable()
2834 q.text("tx_packets = ");
2835 q.text("%#x" % self.tx_packets)
2836 q.text(","); q.breakable()
2837 q.text("tx_errors = ");
2838 q.text("%#x" % self.tx_errors)
2839 q.text(","); q.breakable()
2840 q.text("duration_sec = ");
2841 q.text("%#x" % self.duration_sec)
2842 q.text(","); q.breakable()
2843 q.text("duration_nsec = ");
2844 q.text("%#x" % self.duration_nsec)
2845 q.breakable()
2846 q.text('}')
2847
2848class table_feature_prop_apply_actions(object):
2849
2850 def __init__(self, type=None, action_ids=None):
2851 if type != None:
2852 self.type = type
2853 else:
2854 self.type = 0
2855 if action_ids != None:
2856 self.action_ids = action_ids
2857 else:
2858 self.action_ids = []
2859 return
2860
2861 def pack(self):
2862 packed = []
2863 packed.append(struct.pack("!H", self.type))
2864 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2865 packed.append("".join([x.pack() for x in self.action_ids]))
2866 length = sum([len(x) for x in packed])
2867 packed[1] = struct.pack("!H", length)
2868 return ''.join(packed)
2869
2870 @staticmethod
2871 def unpack(buf):
2872 obj = table_feature_prop_apply_actions()
2873 if type(buf) == loxi.generic_util.OFReader:
2874 reader = buf
2875 else:
2876 reader = loxi.generic_util.OFReader(buf)
2877 obj.type = reader.read('!H')[0]
2878 _length = reader.read('!H')[0]
2879 obj.action_ids = loxi.unimplemented('unpack list of_list_action_id_t')
2880 return obj
2881
2882 def __eq__(self, other):
2883 if type(self) != type(other): return False
2884 if self.type != other.type: return False
2885 if self.action_ids != other.action_ids: return False
2886 return True
2887
2888 def __ne__(self, other):
2889 return not self.__eq__(other)
2890
2891 def show(self):
2892 import loxi.pp
2893 return loxi.pp.pp(self)
2894
2895 def pretty_print(self, q):
2896 q.text("table_feature_prop_apply_actions {")
2897 with q.group():
2898 with q.indent(2):
2899 q.breakable()
2900 q.text("type = ");
2901 q.text("%#x" % self.type)
2902 q.text(","); q.breakable()
2903 q.text("action_ids = ");
2904 q.pp(self.action_ids)
2905 q.breakable()
2906 q.text('}')
2907
2908class table_feature_prop_apply_actions_miss(object):
2909
2910 def __init__(self, type=None, action_ids=None):
2911 if type != None:
2912 self.type = type
2913 else:
2914 self.type = 0
2915 if action_ids != None:
2916 self.action_ids = action_ids
2917 else:
2918 self.action_ids = []
2919 return
2920
2921 def pack(self):
2922 packed = []
2923 packed.append(struct.pack("!H", self.type))
2924 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2925 packed.append("".join([x.pack() for x in self.action_ids]))
2926 length = sum([len(x) for x in packed])
2927 packed[1] = struct.pack("!H", length)
2928 return ''.join(packed)
2929
2930 @staticmethod
2931 def unpack(buf):
2932 obj = table_feature_prop_apply_actions_miss()
2933 if type(buf) == loxi.generic_util.OFReader:
2934 reader = buf
2935 else:
2936 reader = loxi.generic_util.OFReader(buf)
2937 obj.type = reader.read('!H')[0]
2938 _length = reader.read('!H')[0]
2939 obj.action_ids = loxi.unimplemented('unpack list of_list_action_id_t')
2940 return obj
2941
2942 def __eq__(self, other):
2943 if type(self) != type(other): return False
2944 if self.type != other.type: return False
2945 if self.action_ids != other.action_ids: return False
2946 return True
2947
2948 def __ne__(self, other):
2949 return not self.__eq__(other)
2950
2951 def show(self):
2952 import loxi.pp
2953 return loxi.pp.pp(self)
2954
2955 def pretty_print(self, q):
2956 q.text("table_feature_prop_apply_actions_miss {")
2957 with q.group():
2958 with q.indent(2):
2959 q.breakable()
2960 q.text("type = ");
2961 q.text("%#x" % self.type)
2962 q.text(","); q.breakable()
2963 q.text("action_ids = ");
2964 q.pp(self.action_ids)
2965 q.breakable()
2966 q.text('}')
2967
2968class table_feature_prop_apply_setfield(object):
2969
2970 def __init__(self, type=None, oxm_ids=None):
2971 if type != None:
2972 self.type = type
2973 else:
2974 self.type = 0
2975 if oxm_ids != None:
2976 self.oxm_ids = oxm_ids
2977 else:
2978 self.oxm_ids = []
2979 return
2980
2981 def pack(self):
2982 packed = []
2983 packed.append(struct.pack("!H", self.type))
2984 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2985 packed.append("".join([x.pack() for x in self.oxm_ids]))
2986 length = sum([len(x) for x in packed])
2987 packed[1] = struct.pack("!H", length)
2988 return ''.join(packed)
2989
2990 @staticmethod
2991 def unpack(buf):
2992 obj = table_feature_prop_apply_setfield()
2993 if type(buf) == loxi.generic_util.OFReader:
2994 reader = buf
2995 else:
2996 reader = loxi.generic_util.OFReader(buf)
2997 obj.type = reader.read('!H')[0]
2998 _length = reader.read('!H')[0]
2999 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3000 return obj
3001
3002 def __eq__(self, other):
3003 if type(self) != type(other): return False
3004 if self.type != other.type: return False
3005 if self.oxm_ids != other.oxm_ids: return False
3006 return True
3007
3008 def __ne__(self, other):
3009 return not self.__eq__(other)
3010
3011 def show(self):
3012 import loxi.pp
3013 return loxi.pp.pp(self)
3014
3015 def pretty_print(self, q):
3016 q.text("table_feature_prop_apply_setfield {")
3017 with q.group():
3018 with q.indent(2):
3019 q.breakable()
3020 q.text("type = ");
3021 q.text("%#x" % self.type)
3022 q.text(","); q.breakable()
3023 q.text("oxm_ids = ");
3024 q.pp(self.oxm_ids)
3025 q.breakable()
3026 q.text('}')
3027
3028class table_feature_prop_apply_setfield_miss(object):
3029
3030 def __init__(self, type=None, oxm_ids=None):
3031 if type != None:
3032 self.type = type
3033 else:
3034 self.type = 0
3035 if oxm_ids != None:
3036 self.oxm_ids = oxm_ids
3037 else:
3038 self.oxm_ids = []
3039 return
3040
3041 def pack(self):
3042 packed = []
3043 packed.append(struct.pack("!H", self.type))
3044 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3045 packed.append("".join([x.pack() for x in self.oxm_ids]))
3046 length = sum([len(x) for x in packed])
3047 packed[1] = struct.pack("!H", length)
3048 return ''.join(packed)
3049
3050 @staticmethod
3051 def unpack(buf):
3052 obj = table_feature_prop_apply_setfield_miss()
3053 if type(buf) == loxi.generic_util.OFReader:
3054 reader = buf
3055 else:
3056 reader = loxi.generic_util.OFReader(buf)
3057 obj.type = reader.read('!H')[0]
3058 _length = reader.read('!H')[0]
3059 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3060 return obj
3061
3062 def __eq__(self, other):
3063 if type(self) != type(other): return False
3064 if self.type != other.type: return False
3065 if self.oxm_ids != other.oxm_ids: return False
3066 return True
3067
3068 def __ne__(self, other):
3069 return not self.__eq__(other)
3070
3071 def show(self):
3072 import loxi.pp
3073 return loxi.pp.pp(self)
3074
3075 def pretty_print(self, q):
3076 q.text("table_feature_prop_apply_setfield_miss {")
3077 with q.group():
3078 with q.indent(2):
3079 q.breakable()
3080 q.text("type = ");
3081 q.text("%#x" % self.type)
3082 q.text(","); q.breakable()
3083 q.text("oxm_ids = ");
3084 q.pp(self.oxm_ids)
3085 q.breakable()
3086 q.text('}')
3087
3088class table_feature_prop_experimenter(object):
3089
3090 def __init__(self, type=None, experimenter=None, subtype=None, experimenter_data=None):
3091 if type != None:
3092 self.type = type
3093 else:
3094 self.type = 0
3095 if experimenter != None:
3096 self.experimenter = experimenter
3097 else:
3098 self.experimenter = 0
3099 if subtype != None:
3100 self.subtype = subtype
3101 else:
3102 self.subtype = 0
3103 if experimenter_data != None:
3104 self.experimenter_data = experimenter_data
3105 else:
3106 self.experimenter_data = ""
3107 return
3108
3109 def pack(self):
3110 packed = []
3111 packed.append(struct.pack("!H", self.type))
3112 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3113 packed.append(struct.pack("!L", self.experimenter))
3114 packed.append(struct.pack("!L", self.subtype))
3115 packed.append(self.experimenter_data)
3116 length = sum([len(x) for x in packed])
3117 packed[1] = struct.pack("!H", length)
3118 return ''.join(packed)
3119
3120 @staticmethod
3121 def unpack(buf):
3122 obj = table_feature_prop_experimenter()
3123 if type(buf) == loxi.generic_util.OFReader:
3124 reader = buf
3125 else:
3126 reader = loxi.generic_util.OFReader(buf)
3127 obj.type = reader.read('!H')[0]
3128 _length = reader.read('!H')[0]
3129 obj.experimenter = reader.read('!L')[0]
3130 obj.subtype = reader.read('!L')[0]
3131 obj.experimenter_data = str(reader.read_all())
3132 return obj
3133
3134 def __eq__(self, other):
3135 if type(self) != type(other): return False
3136 if self.type != other.type: return False
3137 if self.experimenter != other.experimenter: return False
3138 if self.subtype != other.subtype: return False
3139 if self.experimenter_data != other.experimenter_data: return False
3140 return True
3141
3142 def __ne__(self, other):
3143 return not self.__eq__(other)
3144
3145 def show(self):
3146 import loxi.pp
3147 return loxi.pp.pp(self)
3148
3149 def pretty_print(self, q):
3150 q.text("table_feature_prop_experimenter {")
3151 with q.group():
3152 with q.indent(2):
3153 q.breakable()
3154 q.text("type = ");
3155 q.text("%#x" % self.type)
3156 q.text(","); q.breakable()
3157 q.text("experimenter = ");
3158 q.text("%#x" % self.experimenter)
3159 q.text(","); q.breakable()
3160 q.text("subtype = ");
3161 q.text("%#x" % self.subtype)
3162 q.text(","); q.breakable()
3163 q.text("experimenter_data = ");
3164 q.pp(self.experimenter_data)
3165 q.breakable()
3166 q.text('}')
3167
3168class table_feature_prop_instructions(object):
3169
3170 def __init__(self, type=None, instruction_ids=None):
3171 if type != None:
3172 self.type = type
3173 else:
3174 self.type = 0
3175 if instruction_ids != None:
3176 self.instruction_ids = instruction_ids
3177 else:
3178 self.instruction_ids = []
3179 return
3180
3181 def pack(self):
3182 packed = []
3183 packed.append(struct.pack("!H", self.type))
3184 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3185 packed.append("".join([x.pack() for x in self.instruction_ids]))
3186 length = sum([len(x) for x in packed])
3187 packed[1] = struct.pack("!H", length)
3188 return ''.join(packed)
3189
3190 @staticmethod
3191 def unpack(buf):
3192 obj = table_feature_prop_instructions()
3193 if type(buf) == loxi.generic_util.OFReader:
3194 reader = buf
3195 else:
3196 reader = loxi.generic_util.OFReader(buf)
3197 obj.type = reader.read('!H')[0]
3198 _length = reader.read('!H')[0]
3199 obj.instruction_ids = instruction.unpack_list(reader)
3200 return obj
3201
3202 def __eq__(self, other):
3203 if type(self) != type(other): return False
3204 if self.type != other.type: return False
3205 if self.instruction_ids != other.instruction_ids: return False
3206 return True
3207
3208 def __ne__(self, other):
3209 return not self.__eq__(other)
3210
3211 def show(self):
3212 import loxi.pp
3213 return loxi.pp.pp(self)
3214
3215 def pretty_print(self, q):
3216 q.text("table_feature_prop_instructions {")
3217 with q.group():
3218 with q.indent(2):
3219 q.breakable()
3220 q.text("type = ");
3221 q.text("%#x" % self.type)
3222 q.text(","); q.breakable()
3223 q.text("instruction_ids = ");
3224 q.pp(self.instruction_ids)
3225 q.breakable()
3226 q.text('}')
3227
3228class table_feature_prop_instructions_miss(object):
3229
3230 def __init__(self, type=None, instruction_ids=None):
3231 if type != None:
3232 self.type = type
3233 else:
3234 self.type = 0
3235 if instruction_ids != None:
3236 self.instruction_ids = instruction_ids
3237 else:
3238 self.instruction_ids = []
3239 return
3240
3241 def pack(self):
3242 packed = []
3243 packed.append(struct.pack("!H", self.type))
3244 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3245 packed.append("".join([x.pack() for x in self.instruction_ids]))
3246 length = sum([len(x) for x in packed])
3247 packed[1] = struct.pack("!H", length)
3248 return ''.join(packed)
3249
3250 @staticmethod
3251 def unpack(buf):
3252 obj = table_feature_prop_instructions_miss()
3253 if type(buf) == loxi.generic_util.OFReader:
3254 reader = buf
3255 else:
3256 reader = loxi.generic_util.OFReader(buf)
3257 obj.type = reader.read('!H')[0]
3258 _length = reader.read('!H')[0]
3259 obj.instruction_ids = instruction.unpack_list(reader)
3260 return obj
3261
3262 def __eq__(self, other):
3263 if type(self) != type(other): return False
3264 if self.type != other.type: return False
3265 if self.instruction_ids != other.instruction_ids: return False
3266 return True
3267
3268 def __ne__(self, other):
3269 return not self.__eq__(other)
3270
3271 def show(self):
3272 import loxi.pp
3273 return loxi.pp.pp(self)
3274
3275 def pretty_print(self, q):
3276 q.text("table_feature_prop_instructions_miss {")
3277 with q.group():
3278 with q.indent(2):
3279 q.breakable()
3280 q.text("type = ");
3281 q.text("%#x" % self.type)
3282 q.text(","); q.breakable()
3283 q.text("instruction_ids = ");
3284 q.pp(self.instruction_ids)
3285 q.breakable()
3286 q.text('}')
3287
3288class table_feature_prop_match(object):
3289
3290 def __init__(self, type=None, oxm_ids=None):
3291 if type != None:
3292 self.type = type
3293 else:
3294 self.type = 0
3295 if oxm_ids != None:
3296 self.oxm_ids = oxm_ids
3297 else:
3298 self.oxm_ids = []
3299 return
3300
3301 def pack(self):
3302 packed = []
3303 packed.append(struct.pack("!H", self.type))
3304 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3305 packed.append("".join([x.pack() for x in self.oxm_ids]))
3306 length = sum([len(x) for x in packed])
3307 packed[1] = struct.pack("!H", length)
3308 return ''.join(packed)
3309
3310 @staticmethod
3311 def unpack(buf):
3312 obj = table_feature_prop_match()
3313 if type(buf) == loxi.generic_util.OFReader:
3314 reader = buf
3315 else:
3316 reader = loxi.generic_util.OFReader(buf)
3317 obj.type = reader.read('!H')[0]
3318 _length = reader.read('!H')[0]
3319 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3320 return obj
3321
3322 def __eq__(self, other):
3323 if type(self) != type(other): return False
3324 if self.type != other.type: return False
3325 if self.oxm_ids != other.oxm_ids: return False
3326 return True
3327
3328 def __ne__(self, other):
3329 return not self.__eq__(other)
3330
3331 def show(self):
3332 import loxi.pp
3333 return loxi.pp.pp(self)
3334
3335 def pretty_print(self, q):
3336 q.text("table_feature_prop_match {")
3337 with q.group():
3338 with q.indent(2):
3339 q.breakable()
3340 q.text("type = ");
3341 q.text("%#x" % self.type)
3342 q.text(","); q.breakable()
3343 q.text("oxm_ids = ");
3344 q.pp(self.oxm_ids)
3345 q.breakable()
3346 q.text('}')
3347
3348class table_feature_prop_next_tables(object):
3349
3350 def __init__(self, type=None, next_table_ids=None):
3351 if type != None:
3352 self.type = type
3353 else:
3354 self.type = 0
3355 if next_table_ids != None:
3356 self.next_table_ids = next_table_ids
3357 else:
3358 self.next_table_ids = []
3359 return
3360
3361 def pack(self):
3362 packed = []
3363 packed.append(struct.pack("!H", self.type))
3364 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3365 packed.append("".join([x.pack() for x in self.next_table_ids]))
3366 length = sum([len(x) for x in packed])
3367 packed[1] = struct.pack("!H", length)
3368 return ''.join(packed)
3369
3370 @staticmethod
3371 def unpack(buf):
3372 obj = table_feature_prop_next_tables()
3373 if type(buf) == loxi.generic_util.OFReader:
3374 reader = buf
3375 else:
3376 reader = loxi.generic_util.OFReader(buf)
3377 obj.type = reader.read('!H')[0]
3378 _length = reader.read('!H')[0]
3379 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
3380 return obj
3381
3382 def __eq__(self, other):
3383 if type(self) != type(other): return False
3384 if self.type != other.type: return False
3385 if self.next_table_ids != other.next_table_ids: return False
3386 return True
3387
3388 def __ne__(self, other):
3389 return not self.__eq__(other)
3390
3391 def show(self):
3392 import loxi.pp
3393 return loxi.pp.pp(self)
3394
3395 def pretty_print(self, q):
3396 q.text("table_feature_prop_next_tables {")
3397 with q.group():
3398 with q.indent(2):
3399 q.breakable()
3400 q.text("type = ");
3401 q.text("%#x" % self.type)
3402 q.text(","); q.breakable()
3403 q.text("next_table_ids = ");
3404 q.pp(self.next_table_ids)
3405 q.breakable()
3406 q.text('}')
3407
3408class table_feature_prop_next_tables_miss(object):
3409
3410 def __init__(self, type=None, next_table_ids=None):
3411 if type != None:
3412 self.type = type
3413 else:
3414 self.type = 0
3415 if next_table_ids != None:
3416 self.next_table_ids = next_table_ids
3417 else:
3418 self.next_table_ids = []
3419 return
3420
3421 def pack(self):
3422 packed = []
3423 packed.append(struct.pack("!H", self.type))
3424 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3425 packed.append("".join([x.pack() for x in self.next_table_ids]))
3426 length = sum([len(x) for x in packed])
3427 packed[1] = struct.pack("!H", length)
3428 return ''.join(packed)
3429
3430 @staticmethod
3431 def unpack(buf):
3432 obj = table_feature_prop_next_tables_miss()
3433 if type(buf) == loxi.generic_util.OFReader:
3434 reader = buf
3435 else:
3436 reader = loxi.generic_util.OFReader(buf)
3437 obj.type = reader.read('!H')[0]
3438 _length = reader.read('!H')[0]
3439 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
3440 return obj
3441
3442 def __eq__(self, other):
3443 if type(self) != type(other): return False
3444 if self.type != other.type: return False
3445 if self.next_table_ids != other.next_table_ids: return False
3446 return True
3447
3448 def __ne__(self, other):
3449 return not self.__eq__(other)
3450
3451 def show(self):
3452 import loxi.pp
3453 return loxi.pp.pp(self)
3454
3455 def pretty_print(self, q):
3456 q.text("table_feature_prop_next_tables_miss {")
3457 with q.group():
3458 with q.indent(2):
3459 q.breakable()
3460 q.text("type = ");
3461 q.text("%#x" % self.type)
3462 q.text(","); q.breakable()
3463 q.text("next_table_ids = ");
3464 q.pp(self.next_table_ids)
3465 q.breakable()
3466 q.text('}')
3467
3468class table_feature_prop_wildcards(object):
3469
3470 def __init__(self, type=None, oxm_ids=None):
3471 if type != None:
3472 self.type = type
3473 else:
3474 self.type = 0
3475 if oxm_ids != None:
3476 self.oxm_ids = oxm_ids
3477 else:
3478 self.oxm_ids = []
3479 return
3480
3481 def pack(self):
3482 packed = []
3483 packed.append(struct.pack("!H", self.type))
3484 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3485 packed.append("".join([x.pack() for x in self.oxm_ids]))
3486 length = sum([len(x) for x in packed])
3487 packed[1] = struct.pack("!H", length)
3488 return ''.join(packed)
3489
3490 @staticmethod
3491 def unpack(buf):
3492 obj = table_feature_prop_wildcards()
3493 if type(buf) == loxi.generic_util.OFReader:
3494 reader = buf
3495 else:
3496 reader = loxi.generic_util.OFReader(buf)
3497 obj.type = reader.read('!H')[0]
3498 _length = reader.read('!H')[0]
3499 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3500 return obj
3501
3502 def __eq__(self, other):
3503 if type(self) != type(other): return False
3504 if self.type != other.type: return False
3505 if self.oxm_ids != other.oxm_ids: return False
3506 return True
3507
3508 def __ne__(self, other):
3509 return not self.__eq__(other)
3510
3511 def show(self):
3512 import loxi.pp
3513 return loxi.pp.pp(self)
3514
3515 def pretty_print(self, q):
3516 q.text("table_feature_prop_wildcards {")
3517 with q.group():
3518 with q.indent(2):
3519 q.breakable()
3520 q.text("type = ");
3521 q.text("%#x" % self.type)
3522 q.text(","); q.breakable()
3523 q.text("oxm_ids = ");
3524 q.pp(self.oxm_ids)
3525 q.breakable()
3526 q.text('}')
3527
3528class table_feature_prop_write_actions(object):
3529
3530 def __init__(self, type=None, action_ids=None):
3531 if type != None:
3532 self.type = type
3533 else:
3534 self.type = 0
3535 if action_ids != None:
3536 self.action_ids = action_ids
3537 else:
3538 self.action_ids = []
3539 return
3540
3541 def pack(self):
3542 packed = []
3543 packed.append(struct.pack("!H", self.type))
3544 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3545 packed.append("".join([x.pack() for x in self.action_ids]))
3546 length = sum([len(x) for x in packed])
3547 packed[1] = struct.pack("!H", length)
3548 return ''.join(packed)
3549
3550 @staticmethod
3551 def unpack(buf):
3552 obj = table_feature_prop_write_actions()
3553 if type(buf) == loxi.generic_util.OFReader:
3554 reader = buf
3555 else:
3556 reader = loxi.generic_util.OFReader(buf)
3557 obj.type = reader.read('!H')[0]
3558 _length = reader.read('!H')[0]
3559 obj.action_ids = loxi.unimplemented('unpack list of_list_action_id_t')
3560 return obj
3561
3562 def __eq__(self, other):
3563 if type(self) != type(other): return False
3564 if self.type != other.type: return False
3565 if self.action_ids != other.action_ids: return False
3566 return True
3567
3568 def __ne__(self, other):
3569 return not self.__eq__(other)
3570
3571 def show(self):
3572 import loxi.pp
3573 return loxi.pp.pp(self)
3574
3575 def pretty_print(self, q):
3576 q.text("table_feature_prop_write_actions {")
3577 with q.group():
3578 with q.indent(2):
3579 q.breakable()
3580 q.text("type = ");
3581 q.text("%#x" % self.type)
3582 q.text(","); q.breakable()
3583 q.text("action_ids = ");
3584 q.pp(self.action_ids)
3585 q.breakable()
3586 q.text('}')
3587
3588class table_feature_prop_write_actions_miss(object):
3589
3590 def __init__(self, type=None, action_ids=None):
3591 if type != None:
3592 self.type = type
3593 else:
3594 self.type = 0
3595 if action_ids != None:
3596 self.action_ids = action_ids
3597 else:
3598 self.action_ids = []
3599 return
3600
3601 def pack(self):
3602 packed = []
3603 packed.append(struct.pack("!H", self.type))
3604 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3605 packed.append("".join([x.pack() for x in self.action_ids]))
3606 length = sum([len(x) for x in packed])
3607 packed[1] = struct.pack("!H", length)
3608 return ''.join(packed)
3609
3610 @staticmethod
3611 def unpack(buf):
3612 obj = table_feature_prop_write_actions_miss()
3613 if type(buf) == loxi.generic_util.OFReader:
3614 reader = buf
3615 else:
3616 reader = loxi.generic_util.OFReader(buf)
3617 obj.type = reader.read('!H')[0]
3618 _length = reader.read('!H')[0]
3619 obj.action_ids = loxi.unimplemented('unpack list of_list_action_id_t')
3620 return obj
3621
3622 def __eq__(self, other):
3623 if type(self) != type(other): return False
3624 if self.type != other.type: return False
3625 if self.action_ids != other.action_ids: return False
3626 return True
3627
3628 def __ne__(self, other):
3629 return not self.__eq__(other)
3630
3631 def show(self):
3632 import loxi.pp
3633 return loxi.pp.pp(self)
3634
3635 def pretty_print(self, q):
3636 q.text("table_feature_prop_write_actions_miss {")
3637 with q.group():
3638 with q.indent(2):
3639 q.breakable()
3640 q.text("type = ");
3641 q.text("%#x" % self.type)
3642 q.text(","); q.breakable()
3643 q.text("action_ids = ");
3644 q.pp(self.action_ids)
3645 q.breakable()
3646 q.text('}')
3647
3648class table_feature_prop_write_setfield(object):
3649
3650 def __init__(self, type=None, oxm_ids=None):
3651 if type != None:
3652 self.type = type
3653 else:
3654 self.type = 0
3655 if oxm_ids != None:
3656 self.oxm_ids = oxm_ids
3657 else:
3658 self.oxm_ids = []
3659 return
3660
3661 def pack(self):
3662 packed = []
3663 packed.append(struct.pack("!H", self.type))
3664 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3665 packed.append("".join([x.pack() for x in self.oxm_ids]))
3666 length = sum([len(x) for x in packed])
3667 packed[1] = struct.pack("!H", length)
3668 return ''.join(packed)
3669
3670 @staticmethod
3671 def unpack(buf):
3672 obj = table_feature_prop_write_setfield()
3673 if type(buf) == loxi.generic_util.OFReader:
3674 reader = buf
3675 else:
3676 reader = loxi.generic_util.OFReader(buf)
3677 obj.type = reader.read('!H')[0]
3678 _length = reader.read('!H')[0]
3679 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3680 return obj
3681
3682 def __eq__(self, other):
3683 if type(self) != type(other): return False
3684 if self.type != other.type: return False
3685 if self.oxm_ids != other.oxm_ids: return False
3686 return True
3687
3688 def __ne__(self, other):
3689 return not self.__eq__(other)
3690
3691 def show(self):
3692 import loxi.pp
3693 return loxi.pp.pp(self)
3694
3695 def pretty_print(self, q):
3696 q.text("table_feature_prop_write_setfield {")
3697 with q.group():
3698 with q.indent(2):
3699 q.breakable()
3700 q.text("type = ");
3701 q.text("%#x" % self.type)
3702 q.text(","); q.breakable()
3703 q.text("oxm_ids = ");
3704 q.pp(self.oxm_ids)
3705 q.breakable()
3706 q.text('}')
3707
3708class table_feature_prop_write_setfield_miss(object):
3709
3710 def __init__(self, type=None, oxm_ids=None):
3711 if type != None:
3712 self.type = type
3713 else:
3714 self.type = 0
3715 if oxm_ids != None:
3716 self.oxm_ids = oxm_ids
3717 else:
3718 self.oxm_ids = []
3719 return
3720
3721 def pack(self):
3722 packed = []
3723 packed.append(struct.pack("!H", self.type))
3724 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3725 packed.append("".join([x.pack() for x in self.oxm_ids]))
3726 length = sum([len(x) for x in packed])
3727 packed[1] = struct.pack("!H", length)
3728 return ''.join(packed)
3729
3730 @staticmethod
3731 def unpack(buf):
3732 obj = table_feature_prop_write_setfield_miss()
3733 if type(buf) == loxi.generic_util.OFReader:
3734 reader = buf
3735 else:
3736 reader = loxi.generic_util.OFReader(buf)
3737 obj.type = reader.read('!H')[0]
3738 _length = reader.read('!H')[0]
3739 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3740 return obj
3741
3742 def __eq__(self, other):
3743 if type(self) != type(other): return False
3744 if self.type != other.type: return False
3745 if self.oxm_ids != other.oxm_ids: return False
3746 return True
3747
3748 def __ne__(self, other):
3749 return not self.__eq__(other)
3750
3751 def show(self):
3752 import loxi.pp
3753 return loxi.pp.pp(self)
3754
3755 def pretty_print(self, q):
3756 q.text("table_feature_prop_write_setfield_miss {")
3757 with q.group():
3758 with q.indent(2):
3759 q.breakable()
3760 q.text("type = ");
3761 q.text("%#x" % self.type)
3762 q.text(","); q.breakable()
3763 q.text("oxm_ids = ");
3764 q.pp(self.oxm_ids)
3765 q.breakable()
3766 q.text('}')
3767
3768class table_features(object):
3769
3770 def __init__(self, table_id=None, name=None, metadata_match=None, metadata_write=None, config=None, max_entries=None, properties=None):
3771 if table_id != None:
3772 self.table_id = table_id
3773 else:
3774 self.table_id = 0
3775 if name != None:
3776 self.name = name
3777 else:
3778 self.name = ""
3779 if metadata_match != None:
3780 self.metadata_match = metadata_match
3781 else:
3782 self.metadata_match = 0
3783 if metadata_write != None:
3784 self.metadata_write = metadata_write
3785 else:
3786 self.metadata_write = 0
3787 if config != None:
3788 self.config = config
3789 else:
3790 self.config = 0
3791 if max_entries != None:
3792 self.max_entries = max_entries
3793 else:
3794 self.max_entries = 0
3795 if properties != None:
3796 self.properties = properties
3797 else:
3798 self.properties = []
3799 return
3800
3801 def pack(self):
3802 packed = []
3803 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
3804 packed.append(struct.pack("!B", self.table_id))
3805 packed.append('\x00' * 5)
3806 packed.append(struct.pack("!32s", self.name))
3807 packed.append(struct.pack("!Q", self.metadata_match))
3808 packed.append(struct.pack("!Q", self.metadata_write))
3809 packed.append(struct.pack("!L", self.config))
3810 packed.append(struct.pack("!L", self.max_entries))
3811 packed.append("".join([x.pack() for x in self.properties]))
3812 length = sum([len(x) for x in packed])
3813 packed[0] = struct.pack("!H", length)
3814 return ''.join(packed)
3815
3816 @staticmethod
3817 def unpack(buf):
3818 obj = table_features()
3819 if type(buf) == loxi.generic_util.OFReader:
3820 reader = buf
3821 else:
3822 reader = loxi.generic_util.OFReader(buf)
3823 _length = reader.read('!H')[0]
3824 obj.table_id = reader.read('!B')[0]
3825 reader.skip(5)
3826 obj.name = reader.read("!32s")[0].rstrip("\x00")
3827 obj.metadata_match = reader.read('!Q')[0]
3828 obj.metadata_write = reader.read('!Q')[0]
3829 obj.config = reader.read('!L')[0]
3830 obj.max_entries = reader.read('!L')[0]
3831 obj.properties = loxi.unimplemented('unpack list of_list_table_feature_prop_t')
3832 return obj
3833
3834 def __eq__(self, other):
3835 if type(self) != type(other): return False
3836 if self.table_id != other.table_id: return False
3837 if self.name != other.name: return False
3838 if self.metadata_match != other.metadata_match: return False
3839 if self.metadata_write != other.metadata_write: return False
3840 if self.config != other.config: return False
3841 if self.max_entries != other.max_entries: return False
3842 if self.properties != other.properties: return False
3843 return True
3844
3845 def __ne__(self, other):
3846 return not self.__eq__(other)
3847
3848 def show(self):
3849 import loxi.pp
3850 return loxi.pp.pp(self)
3851
3852 def pretty_print(self, q):
3853 q.text("table_features {")
3854 with q.group():
3855 with q.indent(2):
3856 q.breakable()
3857 q.text("table_id = ");
3858 q.text("%#x" % self.table_id)
3859 q.text(","); q.breakable()
3860 q.text("name = ");
3861 q.pp(self.name)
3862 q.text(","); q.breakable()
3863 q.text("metadata_match = ");
3864 q.text("%#x" % self.metadata_match)
3865 q.text(","); q.breakable()
3866 q.text("metadata_write = ");
3867 q.text("%#x" % self.metadata_write)
3868 q.text(","); q.breakable()
3869 q.text("config = ");
3870 q.text("%#x" % self.config)
3871 q.text(","); q.breakable()
3872 q.text("max_entries = ");
3873 q.text("%#x" % self.max_entries)
3874 q.text(","); q.breakable()
3875 q.text("properties = ");
3876 q.pp(self.properties)
3877 q.breakable()
3878 q.text('}')
3879
3880class table_stats_entry(object):
3881
3882 def __init__(self, table_id=None, active_count=None, lookup_count=None, matched_count=None):
3883 if table_id != None:
3884 self.table_id = table_id
3885 else:
3886 self.table_id = 0
3887 if active_count != None:
3888 self.active_count = active_count
3889 else:
3890 self.active_count = 0
3891 if lookup_count != None:
3892 self.lookup_count = lookup_count
3893 else:
3894 self.lookup_count = 0
3895 if matched_count != None:
3896 self.matched_count = matched_count
3897 else:
3898 self.matched_count = 0
3899 return
3900
3901 def pack(self):
3902 packed = []
3903 packed.append(struct.pack("!B", self.table_id))
3904 packed.append('\x00' * 3)
3905 packed.append(struct.pack("!L", self.active_count))
3906 packed.append(struct.pack("!Q", self.lookup_count))
3907 packed.append(struct.pack("!Q", self.matched_count))
3908 return ''.join(packed)
3909
3910 @staticmethod
3911 def unpack(buf):
3912 obj = table_stats_entry()
3913 if type(buf) == loxi.generic_util.OFReader:
3914 reader = buf
3915 else:
3916 reader = loxi.generic_util.OFReader(buf)
3917 obj.table_id = reader.read('!B')[0]
3918 reader.skip(3)
3919 obj.active_count = reader.read('!L')[0]
3920 obj.lookup_count = reader.read('!Q')[0]
3921 obj.matched_count = reader.read('!Q')[0]
3922 return obj
3923
3924 def __eq__(self, other):
3925 if type(self) != type(other): return False
3926 if self.table_id != other.table_id: return False
3927 if self.active_count != other.active_count: return False
3928 if self.lookup_count != other.lookup_count: return False
3929 if self.matched_count != other.matched_count: return False
3930 return True
3931
3932 def __ne__(self, other):
3933 return not self.__eq__(other)
3934
3935 def show(self):
3936 import loxi.pp
3937 return loxi.pp.pp(self)
3938
3939 def pretty_print(self, q):
3940 q.text("table_stats_entry {")
3941 with q.group():
3942 with q.indent(2):
3943 q.breakable()
3944 q.text("table_id = ");
3945 q.text("%#x" % self.table_id)
3946 q.text(","); q.breakable()
3947 q.text("active_count = ");
3948 q.text("%#x" % self.active_count)
3949 q.text(","); q.breakable()
3950 q.text("lookup_count = ");
3951 q.text("%#x" % self.lookup_count)
3952 q.text(","); q.breakable()
3953 q.text("matched_count = ");
3954 q.text("%#x" % self.matched_count)
3955 q.breakable()
3956 q.text('}')
3957
3958class uint32(object):
3959
3960 def __init__(self, value=None):
3961 if value != None:
3962 self.value = value
3963 else:
3964 self.value = 0
3965 return
3966
3967 def pack(self):
3968 packed = []
3969 packed.append(struct.pack("!L", self.value))
3970 return ''.join(packed)
3971
3972 @staticmethod
3973 def unpack(buf):
3974 obj = uint32()
3975 if type(buf) == loxi.generic_util.OFReader:
3976 reader = buf
3977 else:
3978 reader = loxi.generic_util.OFReader(buf)
3979 obj.value = reader.read('!L')[0]
3980 return obj
3981
3982 def __eq__(self, other):
3983 if type(self) != type(other): return False
3984 if self.value != other.value: return False
3985 return True
3986
3987 def __ne__(self, other):
3988 return not self.__eq__(other)
3989
3990 def show(self):
3991 import loxi.pp
3992 return loxi.pp.pp(self)
3993
3994 def pretty_print(self, q):
3995 q.text("uint32 {")
3996 with q.group():
3997 with q.indent(2):
3998 q.breakable()
3999 q.text("value = ");
4000 q.text("%#x" % self.value)
4001 q.breakable()
4002 q.text('}')
4003
4004class uint8(object):
4005
4006 def __init__(self, value=None):
4007 if value != None:
4008 self.value = value
4009 else:
4010 self.value = 0
4011 return
4012
4013 def pack(self):
4014 packed = []
4015 packed.append(struct.pack("!B", self.value))
4016 return ''.join(packed)
4017
4018 @staticmethod
4019 def unpack(buf):
4020 obj = uint8()
4021 if type(buf) == loxi.generic_util.OFReader:
4022 reader = buf
4023 else:
4024 reader = loxi.generic_util.OFReader(buf)
4025 obj.value = reader.read('!B')[0]
4026 return obj
4027
4028 def __eq__(self, other):
4029 if type(self) != type(other): return False
4030 if self.value != other.value: return False
4031 return True
4032
4033 def __ne__(self, other):
4034 return not self.__eq__(other)
4035
4036 def show(self):
4037 import loxi.pp
4038 return loxi.pp.pp(self)
4039
4040 def pretty_print(self, q):
4041 q.text("uint8 {")
4042 with q.group():
4043 with q.indent(2):
4044 q.breakable()
4045 q.text("value = ");
4046 q.text("%#x" % self.value)
4047 q.breakable()
4048 q.text('}')
4049
4050
4051match = match_v3