blob: 5b451fa187a2b1228b1dc74886e5e65fdb8dd4d1 [file] [log] [blame]
Rich Lane2e079da2014-10-29 15:30:24 -07001# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2# Copyright (c) 2011, 2012 Open Networking Foundation
3# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4# See the file LICENSE.pyloxi which should have been included in the source distribution
5
6# Automatically generated by LOXI from template module.py
7# Do not modify
8
9import struct
10import loxi
11import const
12import port_desc_prop
Rich Laneccd32ed2014-11-10 17:48:24 -080013import bsn_tlv
Rich Lane2e079da2014-10-29 15:30:24 -070014import meter_band
15import table_mod_prop
16import instruction
17import queue_desc_prop
18import oxm
19import bundle_prop
20import common
21import instruction_id
22import action
23import role_prop
24import message
25import queue_stats_prop
26import port_stats_prop
27import port_mod_prop
28import async_config_prop
29import action_id
30import util
31import loxi.generic_util
32
33class instruction(loxi.OFObject):
34 subtypes = {}
35
36
37 def __init__(self, type=None):
38 if type != None:
39 self.type = type
40 else:
41 self.type = 0
42 return
43
44 def pack(self):
45 packed = []
46 packed.append(struct.pack("!H", self.type))
47 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
48 length = sum([len(x) for x in packed])
49 packed[1] = struct.pack("!H", length)
50 return ''.join(packed)
51
52 @staticmethod
53 def unpack(reader):
54 subtype, = reader.peek('!H', 0)
55 subclass = instruction.subtypes.get(subtype)
56 if subclass:
57 return subclass.unpack(reader)
58
59 obj = instruction()
60 obj.type = reader.read("!H")[0]
61 _len = reader.read("!H")[0]
62 orig_reader = reader
63 reader = orig_reader.slice(_len - (2 + 2))
64 return obj
65
66 def __eq__(self, other):
67 if type(self) != type(other): return False
68 if self.type != other.type: return False
69 return True
70
71 def pretty_print(self, q):
72 q.text("instruction {")
73 with q.group():
74 with q.indent(2):
75 q.breakable()
76 q.breakable()
77 q.text('}')
78
79
80class apply_actions(instruction):
81 type = 4
82
83 def __init__(self, actions=None):
84 if actions != None:
85 self.actions = actions
86 else:
87 self.actions = []
88 return
89
90 def pack(self):
91 packed = []
92 packed.append(struct.pack("!H", self.type))
93 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
94 packed.append('\x00' * 4)
95 packed.append(loxi.generic_util.pack_list(self.actions))
96 length = sum([len(x) for x in packed])
97 packed[1] = struct.pack("!H", length)
98 return ''.join(packed)
99
100 @staticmethod
101 def unpack(reader):
102 obj = apply_actions()
103 _type = reader.read("!H")[0]
104 assert(_type == 4)
105 _len = reader.read("!H")[0]
106 orig_reader = reader
107 reader = orig_reader.slice(_len - (2 + 2))
108 reader.skip(4)
109 obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
110 return obj
111
112 def __eq__(self, other):
113 if type(self) != type(other): return False
114 if self.actions != other.actions: return False
115 return True
116
117 def pretty_print(self, q):
118 q.text("apply_actions {")
119 with q.group():
120 with q.indent(2):
121 q.breakable()
122 q.text("actions = ");
123 q.pp(self.actions)
124 q.breakable()
125 q.text('}')
126
127instruction.subtypes[4] = apply_actions
128
Rich Lane2e079da2014-10-29 15:30:24 -0700129class experimenter(instruction):
130 subtypes = {}
131
132 type = 65535
133
134 def __init__(self, experimenter=None, data=None):
135 if experimenter != None:
136 self.experimenter = experimenter
137 else:
138 self.experimenter = 0
139 if data != None:
140 self.data = data
141 else:
142 self.data = ''
143 return
144
145 def pack(self):
146 packed = []
147 packed.append(struct.pack("!H", self.type))
148 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
149 packed.append(struct.pack("!L", self.experimenter))
150 packed.append(self.data)
151 length = sum([len(x) for x in packed])
152 packed[1] = struct.pack("!H", length)
153 return ''.join(packed)
154
155 @staticmethod
156 def unpack(reader):
157 subtype, = reader.peek('!L', 4)
158 subclass = experimenter.subtypes.get(subtype)
159 if subclass:
160 return subclass.unpack(reader)
161
162 obj = experimenter()
163 _type = reader.read("!H")[0]
164 assert(_type == 65535)
165 _len = reader.read("!H")[0]
166 orig_reader = reader
167 reader = orig_reader.slice(_len - (2 + 2))
168 obj.experimenter = reader.read("!L")[0]
169 obj.data = str(reader.read_all())
170 return obj
171
172 def __eq__(self, other):
173 if type(self) != type(other): return False
174 if self.experimenter != other.experimenter: return False
175 if self.data != other.data: return False
176 return True
177
178 def pretty_print(self, q):
179 q.text("experimenter {")
180 with q.group():
181 with q.indent(2):
182 q.breakable()
183 q.text("data = ");
184 q.pp(self.data)
185 q.breakable()
186 q.text('}')
187
188instruction.subtypes[65535] = experimenter
189
Rich Laneccd32ed2014-11-10 17:48:24 -0800190class bsn(experimenter):
191 subtypes = {}
192
193 type = 65535
194 experimenter = 6035143
195
196 def __init__(self, subtype=None):
197 if subtype != None:
198 self.subtype = subtype
199 else:
200 self.subtype = 0
201 return
202
203 def pack(self):
204 packed = []
205 packed.append(struct.pack("!H", self.type))
206 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
207 packed.append(struct.pack("!L", self.experimenter))
208 packed.append(struct.pack("!L", self.subtype))
209 packed.append('\x00' * 4)
210 length = sum([len(x) for x in packed])
211 packed[1] = struct.pack("!H", length)
212 return ''.join(packed)
213
214 @staticmethod
215 def unpack(reader):
216 subtype, = reader.peek('!L', 8)
217 subclass = bsn.subtypes.get(subtype)
218 if subclass:
219 return subclass.unpack(reader)
220
221 obj = bsn()
222 _type = reader.read("!H")[0]
223 assert(_type == 65535)
224 _len = reader.read("!H")[0]
225 orig_reader = reader
226 reader = orig_reader.slice(_len - (2 + 2))
227 _experimenter = reader.read("!L")[0]
228 assert(_experimenter == 6035143)
229 obj.subtype = reader.read("!L")[0]
230 reader.skip(4)
231 return obj
232
233 def __eq__(self, other):
234 if type(self) != type(other): return False
235 if self.subtype != other.subtype: return False
236 return True
237
238 def pretty_print(self, q):
239 q.text("bsn {")
240 with q.group():
241 with q.indent(2):
242 q.breakable()
243 q.breakable()
244 q.text('}')
245
246experimenter.subtypes[6035143] = bsn
247
248class bsn_arp_offload(bsn):
249 type = 65535
250 experimenter = 6035143
251 subtype = 1
252
253 def __init__(self):
254 return
255
256 def pack(self):
257 packed = []
258 packed.append(struct.pack("!H", self.type))
259 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
260 packed.append(struct.pack("!L", self.experimenter))
261 packed.append(struct.pack("!L", self.subtype))
262 packed.append('\x00' * 4)
263 length = sum([len(x) for x in packed])
264 packed[1] = struct.pack("!H", length)
265 return ''.join(packed)
266
267 @staticmethod
268 def unpack(reader):
269 obj = bsn_arp_offload()
270 _type = reader.read("!H")[0]
271 assert(_type == 65535)
272 _len = reader.read("!H")[0]
273 orig_reader = reader
274 reader = orig_reader.slice(_len - (2 + 2))
275 _experimenter = reader.read("!L")[0]
276 assert(_experimenter == 6035143)
277 _subtype = reader.read("!L")[0]
278 assert(_subtype == 1)
279 reader.skip(4)
280 return obj
281
282 def __eq__(self, other):
283 if type(self) != type(other): return False
284 return True
285
286 def pretty_print(self, q):
287 q.text("bsn_arp_offload {")
288 with q.group():
289 with q.indent(2):
290 q.breakable()
291 q.breakable()
292 q.text('}')
293
294bsn.subtypes[1] = bsn_arp_offload
295
Harshmeet Singh301f7172014-12-08 13:07:29 -0800296class bsn_auto_negotiation(bsn):
297 type = 65535
298 experimenter = 6035143
299 subtype = 11
300
301 def __init__(self):
302 return
303
304 def pack(self):
305 packed = []
306 packed.append(struct.pack("!H", self.type))
307 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
308 packed.append(struct.pack("!L", self.experimenter))
309 packed.append(struct.pack("!L", self.subtype))
310 packed.append('\x00' * 4)
311 length = sum([len(x) for x in packed])
312 packed[1] = struct.pack("!H", length)
313 return ''.join(packed)
314
315 @staticmethod
316 def unpack(reader):
317 obj = bsn_auto_negotiation()
318 _type = reader.read("!H")[0]
319 assert(_type == 65535)
320 _len = reader.read("!H")[0]
321 orig_reader = reader
322 reader = orig_reader.slice(_len - (2 + 2))
323 _experimenter = reader.read("!L")[0]
324 assert(_experimenter == 6035143)
325 _subtype = reader.read("!L")[0]
326 assert(_subtype == 11)
327 reader.skip(4)
328 return obj
329
330 def __eq__(self, other):
331 if type(self) != type(other): return False
332 return True
333
334 def pretty_print(self, q):
335 q.text("bsn_auto_negotiation {")
336 with q.group():
337 with q.indent(2):
338 q.breakable()
339 q.breakable()
340 q.text('}')
341
342bsn.subtypes[11] = bsn_auto_negotiation
343
Rich Laneccd32ed2014-11-10 17:48:24 -0800344class bsn_deny(bsn):
345 type = 65535
346 experimenter = 6035143
347 subtype = 5
348
349 def __init__(self):
350 return
351
352 def pack(self):
353 packed = []
354 packed.append(struct.pack("!H", self.type))
355 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
356 packed.append(struct.pack("!L", self.experimenter))
357 packed.append(struct.pack("!L", self.subtype))
358 packed.append('\x00' * 4)
359 length = sum([len(x) for x in packed])
360 packed[1] = struct.pack("!H", length)
361 return ''.join(packed)
362
363 @staticmethod
364 def unpack(reader):
365 obj = bsn_deny()
366 _type = reader.read("!H")[0]
367 assert(_type == 65535)
368 _len = reader.read("!H")[0]
369 orig_reader = reader
370 reader = orig_reader.slice(_len - (2 + 2))
371 _experimenter = reader.read("!L")[0]
372 assert(_experimenter == 6035143)
373 _subtype = reader.read("!L")[0]
374 assert(_subtype == 5)
375 reader.skip(4)
376 return obj
377
378 def __eq__(self, other):
379 if type(self) != type(other): return False
380 return True
381
382 def pretty_print(self, q):
383 q.text("bsn_deny {")
384 with q.group():
385 with q.indent(2):
386 q.breakable()
387 q.breakable()
388 q.text('}')
389
390bsn.subtypes[5] = bsn_deny
391
392class bsn_dhcp_offload(bsn):
393 type = 65535
394 experimenter = 6035143
395 subtype = 2
396
397 def __init__(self):
398 return
399
400 def pack(self):
401 packed = []
402 packed.append(struct.pack("!H", self.type))
403 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
404 packed.append(struct.pack("!L", self.experimenter))
405 packed.append(struct.pack("!L", self.subtype))
406 packed.append('\x00' * 4)
407 length = sum([len(x) for x in packed])
408 packed[1] = struct.pack("!H", length)
409 return ''.join(packed)
410
411 @staticmethod
412 def unpack(reader):
413 obj = bsn_dhcp_offload()
414 _type = reader.read("!H")[0]
415 assert(_type == 65535)
416 _len = reader.read("!H")[0]
417 orig_reader = reader
418 reader = orig_reader.slice(_len - (2 + 2))
419 _experimenter = reader.read("!L")[0]
420 assert(_experimenter == 6035143)
421 _subtype = reader.read("!L")[0]
422 assert(_subtype == 2)
423 reader.skip(4)
424 return obj
425
426 def __eq__(self, other):
427 if type(self) != type(other): return False
428 return True
429
430 def pretty_print(self, q):
431 q.text("bsn_dhcp_offload {")
432 with q.group():
433 with q.indent(2):
434 q.breakable()
435 q.breakable()
436 q.text('}')
437
438bsn.subtypes[2] = bsn_dhcp_offload
439
440class bsn_disable_src_mac_check(bsn):
441 type = 65535
442 experimenter = 6035143
443 subtype = 0
444
445 def __init__(self):
446 return
447
448 def pack(self):
449 packed = []
450 packed.append(struct.pack("!H", self.type))
451 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
452 packed.append(struct.pack("!L", self.experimenter))
453 packed.append(struct.pack("!L", self.subtype))
454 packed.append('\x00' * 4)
455 length = sum([len(x) for x in packed])
456 packed[1] = struct.pack("!H", length)
457 return ''.join(packed)
458
459 @staticmethod
460 def unpack(reader):
461 obj = bsn_disable_src_mac_check()
462 _type = reader.read("!H")[0]
463 assert(_type == 65535)
464 _len = reader.read("!H")[0]
465 orig_reader = reader
466 reader = orig_reader.slice(_len - (2 + 2))
467 _experimenter = reader.read("!L")[0]
468 assert(_experimenter == 6035143)
469 _subtype = reader.read("!L")[0]
470 assert(_subtype == 0)
471 reader.skip(4)
472 return obj
473
474 def __eq__(self, other):
475 if type(self) != type(other): return False
476 return True
477
478 def pretty_print(self, q):
479 q.text("bsn_disable_src_mac_check {")
480 with q.group():
481 with q.indent(2):
482 q.breakable()
483 q.breakable()
484 q.text('}')
485
486bsn.subtypes[0] = bsn_disable_src_mac_check
487
488class bsn_disable_vlan_counters(bsn):
489 type = 65535
490 experimenter = 6035143
491 subtype = 9
492
493 def __init__(self):
494 return
495
496 def pack(self):
497 packed = []
498 packed.append(struct.pack("!H", self.type))
499 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
500 packed.append(struct.pack("!L", self.experimenter))
501 packed.append(struct.pack("!L", self.subtype))
502 packed.append('\x00' * 4)
503 length = sum([len(x) for x in packed])
504 packed[1] = struct.pack("!H", length)
505 return ''.join(packed)
506
507 @staticmethod
508 def unpack(reader):
509 obj = bsn_disable_vlan_counters()
510 _type = reader.read("!H")[0]
511 assert(_type == 65535)
512 _len = reader.read("!H")[0]
513 orig_reader = reader
514 reader = orig_reader.slice(_len - (2 + 2))
515 _experimenter = reader.read("!L")[0]
516 assert(_experimenter == 6035143)
517 _subtype = reader.read("!L")[0]
518 assert(_subtype == 9)
519 reader.skip(4)
520 return obj
521
522 def __eq__(self, other):
523 if type(self) != type(other): return False
524 return True
525
526 def pretty_print(self, q):
527 q.text("bsn_disable_vlan_counters {")
528 with q.group():
529 with q.indent(2):
530 q.breakable()
531 q.breakable()
532 q.text('}')
533
534bsn.subtypes[9] = bsn_disable_vlan_counters
535
536class bsn_packet_of_death(bsn):
537 type = 65535
538 experimenter = 6035143
539 subtype = 6
540
541 def __init__(self):
542 return
543
544 def pack(self):
545 packed = []
546 packed.append(struct.pack("!H", self.type))
547 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
548 packed.append(struct.pack("!L", self.experimenter))
549 packed.append(struct.pack("!L", self.subtype))
550 packed.append('\x00' * 4)
551 length = sum([len(x) for x in packed])
552 packed[1] = struct.pack("!H", length)
553 return ''.join(packed)
554
555 @staticmethod
556 def unpack(reader):
557 obj = bsn_packet_of_death()
558 _type = reader.read("!H")[0]
559 assert(_type == 65535)
560 _len = reader.read("!H")[0]
561 orig_reader = reader
562 reader = orig_reader.slice(_len - (2 + 2))
563 _experimenter = reader.read("!L")[0]
564 assert(_experimenter == 6035143)
565 _subtype = reader.read("!L")[0]
566 assert(_subtype == 6)
567 reader.skip(4)
568 return obj
569
570 def __eq__(self, other):
571 if type(self) != type(other): return False
572 return True
573
574 def pretty_print(self, q):
575 q.text("bsn_packet_of_death {")
576 with q.group():
577 with q.indent(2):
578 q.breakable()
579 q.breakable()
580 q.text('}')
581
582bsn.subtypes[6] = bsn_packet_of_death
583
584class bsn_permit(bsn):
585 type = 65535
586 experimenter = 6035143
587 subtype = 4
588
589 def __init__(self):
590 return
591
592 def pack(self):
593 packed = []
594 packed.append(struct.pack("!H", self.type))
595 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
596 packed.append(struct.pack("!L", self.experimenter))
597 packed.append(struct.pack("!L", self.subtype))
598 packed.append('\x00' * 4)
599 length = sum([len(x) for x in packed])
600 packed[1] = struct.pack("!H", length)
601 return ''.join(packed)
602
603 @staticmethod
604 def unpack(reader):
605 obj = bsn_permit()
606 _type = reader.read("!H")[0]
607 assert(_type == 65535)
608 _len = reader.read("!H")[0]
609 orig_reader = reader
610 reader = orig_reader.slice(_len - (2 + 2))
611 _experimenter = reader.read("!L")[0]
612 assert(_experimenter == 6035143)
613 _subtype = reader.read("!L")[0]
614 assert(_subtype == 4)
615 reader.skip(4)
616 return obj
617
618 def __eq__(self, other):
619 if type(self) != type(other): return False
620 return True
621
622 def pretty_print(self, q):
623 q.text("bsn_permit {")
624 with q.group():
625 with q.indent(2):
626 q.breakable()
627 q.breakable()
628 q.text('}')
629
630bsn.subtypes[4] = bsn_permit
631
632class bsn_prioritize_pdus(bsn):
633 type = 65535
634 experimenter = 6035143
635 subtype = 7
636
637 def __init__(self):
638 return
639
640 def pack(self):
641 packed = []
642 packed.append(struct.pack("!H", self.type))
643 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
644 packed.append(struct.pack("!L", self.experimenter))
645 packed.append(struct.pack("!L", self.subtype))
646 packed.append('\x00' * 4)
647 length = sum([len(x) for x in packed])
648 packed[1] = struct.pack("!H", length)
649 return ''.join(packed)
650
651 @staticmethod
652 def unpack(reader):
653 obj = bsn_prioritize_pdus()
654 _type = reader.read("!H")[0]
655 assert(_type == 65535)
656 _len = reader.read("!H")[0]
657 orig_reader = reader
658 reader = orig_reader.slice(_len - (2 + 2))
659 _experimenter = reader.read("!L")[0]
660 assert(_experimenter == 6035143)
661 _subtype = reader.read("!L")[0]
662 assert(_subtype == 7)
663 reader.skip(4)
664 return obj
665
666 def __eq__(self, other):
667 if type(self) != type(other): return False
668 return True
669
670 def pretty_print(self, q):
671 q.text("bsn_prioritize_pdus {")
672 with q.group():
673 with q.indent(2):
674 q.breakable()
675 q.breakable()
676 q.text('}')
677
678bsn.subtypes[7] = bsn_prioritize_pdus
679
680class bsn_require_vlan_xlate(bsn):
681 type = 65535
682 experimenter = 6035143
683 subtype = 8
684
685 def __init__(self):
686 return
687
688 def pack(self):
689 packed = []
690 packed.append(struct.pack("!H", self.type))
691 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
692 packed.append(struct.pack("!L", self.experimenter))
693 packed.append(struct.pack("!L", self.subtype))
694 packed.append('\x00' * 4)
695 length = sum([len(x) for x in packed])
696 packed[1] = struct.pack("!H", length)
697 return ''.join(packed)
698
699 @staticmethod
700 def unpack(reader):
701 obj = bsn_require_vlan_xlate()
702 _type = reader.read("!H")[0]
703 assert(_type == 65535)
704 _len = reader.read("!H")[0]
705 orig_reader = reader
706 reader = orig_reader.slice(_len - (2 + 2))
707 _experimenter = reader.read("!L")[0]
708 assert(_experimenter == 6035143)
709 _subtype = reader.read("!L")[0]
710 assert(_subtype == 8)
711 reader.skip(4)
712 return obj
713
714 def __eq__(self, other):
715 if type(self) != type(other): return False
716 return True
717
718 def pretty_print(self, q):
719 q.text("bsn_require_vlan_xlate {")
720 with q.group():
721 with q.indent(2):
722 q.breakable()
723 q.breakable()
724 q.text('}')
725
726bsn.subtypes[8] = bsn_require_vlan_xlate
727
728class bsn_span_destination(bsn):
729 type = 65535
730 experimenter = 6035143
731 subtype = 10
732
733 def __init__(self):
734 return
735
736 def pack(self):
737 packed = []
738 packed.append(struct.pack("!H", self.type))
739 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
740 packed.append(struct.pack("!L", self.experimenter))
741 packed.append(struct.pack("!L", self.subtype))
742 packed.append('\x00' * 4)
743 length = sum([len(x) for x in packed])
744 packed[1] = struct.pack("!H", length)
745 return ''.join(packed)
746
747 @staticmethod
748 def unpack(reader):
749 obj = bsn_span_destination()
750 _type = reader.read("!H")[0]
751 assert(_type == 65535)
752 _len = reader.read("!H")[0]
753 orig_reader = reader
754 reader = orig_reader.slice(_len - (2 + 2))
755 _experimenter = reader.read("!L")[0]
756 assert(_experimenter == 6035143)
757 _subtype = reader.read("!L")[0]
758 assert(_subtype == 10)
759 reader.skip(4)
760 return obj
761
762 def __eq__(self, other):
763 if type(self) != type(other): return False
764 return True
765
766 def pretty_print(self, q):
767 q.text("bsn_span_destination {")
768 with q.group():
769 with q.indent(2):
770 q.breakable()
771 q.breakable()
772 q.text('}')
773
774bsn.subtypes[10] = bsn_span_destination
775
776class clear_actions(instruction):
777 type = 5
778
779 def __init__(self):
780 return
781
782 def pack(self):
783 packed = []
784 packed.append(struct.pack("!H", self.type))
785 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
786 packed.append('\x00' * 4)
787 length = sum([len(x) for x in packed])
788 packed[1] = struct.pack("!H", length)
789 return ''.join(packed)
790
791 @staticmethod
792 def unpack(reader):
793 obj = clear_actions()
794 _type = reader.read("!H")[0]
795 assert(_type == 5)
796 _len = reader.read("!H")[0]
797 orig_reader = reader
798 reader = orig_reader.slice(_len - (2 + 2))
799 reader.skip(4)
800 return obj
801
802 def __eq__(self, other):
803 if type(self) != type(other): return False
804 return True
805
806 def pretty_print(self, q):
807 q.text("clear_actions {")
808 with q.group():
809 with q.indent(2):
810 q.breakable()
811 q.breakable()
812 q.text('}')
813
814instruction.subtypes[5] = clear_actions
815
Rich Lane2e079da2014-10-29 15:30:24 -0700816class goto_table(instruction):
817 type = 1
818
819 def __init__(self, table_id=None):
820 if table_id != None:
821 self.table_id = table_id
822 else:
823 self.table_id = 0
824 return
825
826 def pack(self):
827 packed = []
828 packed.append(struct.pack("!H", self.type))
829 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
830 packed.append(struct.pack("!B", self.table_id))
831 packed.append('\x00' * 3)
832 length = sum([len(x) for x in packed])
833 packed[1] = struct.pack("!H", length)
834 return ''.join(packed)
835
836 @staticmethod
837 def unpack(reader):
838 obj = goto_table()
839 _type = reader.read("!H")[0]
840 assert(_type == 1)
841 _len = reader.read("!H")[0]
842 orig_reader = reader
843 reader = orig_reader.slice(_len - (2 + 2))
844 obj.table_id = reader.read("!B")[0]
845 reader.skip(3)
846 return obj
847
848 def __eq__(self, other):
849 if type(self) != type(other): return False
850 if self.table_id != other.table_id: return False
851 return True
852
853 def pretty_print(self, q):
854 q.text("goto_table {")
855 with q.group():
856 with q.indent(2):
857 q.breakable()
858 q.text("table_id = ");
859 q.text("%#x" % self.table_id)
860 q.breakable()
861 q.text('}')
862
863instruction.subtypes[1] = goto_table
864
865class meter(instruction):
866 type = 6
867
868 def __init__(self, meter_id=None):
869 if meter_id != None:
870 self.meter_id = meter_id
871 else:
872 self.meter_id = 0
873 return
874
875 def pack(self):
876 packed = []
877 packed.append(struct.pack("!H", self.type))
878 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
879 packed.append(struct.pack("!L", self.meter_id))
880 length = sum([len(x) for x in packed])
881 packed[1] = struct.pack("!H", length)
882 return ''.join(packed)
883
884 @staticmethod
885 def unpack(reader):
886 obj = meter()
887 _type = reader.read("!H")[0]
888 assert(_type == 6)
889 _len = reader.read("!H")[0]
890 orig_reader = reader
891 reader = orig_reader.slice(_len - (2 + 2))
892 obj.meter_id = reader.read("!L")[0]
893 return obj
894
895 def __eq__(self, other):
896 if type(self) != type(other): return False
897 if self.meter_id != other.meter_id: return False
898 return True
899
900 def pretty_print(self, q):
901 q.text("meter {")
902 with q.group():
903 with q.indent(2):
904 q.breakable()
905 q.text("meter_id = ");
906 q.text("%#x" % self.meter_id)
907 q.breakable()
908 q.text('}')
909
910instruction.subtypes[6] = meter
911
912class write_actions(instruction):
913 type = 3
914
915 def __init__(self, actions=None):
916 if actions != None:
917 self.actions = actions
918 else:
919 self.actions = []
920 return
921
922 def pack(self):
923 packed = []
924 packed.append(struct.pack("!H", self.type))
925 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
926 packed.append('\x00' * 4)
927 packed.append(loxi.generic_util.pack_list(self.actions))
928 length = sum([len(x) for x in packed])
929 packed[1] = struct.pack("!H", length)
930 return ''.join(packed)
931
932 @staticmethod
933 def unpack(reader):
934 obj = write_actions()
935 _type = reader.read("!H")[0]
936 assert(_type == 3)
937 _len = reader.read("!H")[0]
938 orig_reader = reader
939 reader = orig_reader.slice(_len - (2 + 2))
940 reader.skip(4)
941 obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
942 return obj
943
944 def __eq__(self, other):
945 if type(self) != type(other): return False
946 if self.actions != other.actions: return False
947 return True
948
949 def pretty_print(self, q):
950 q.text("write_actions {")
951 with q.group():
952 with q.indent(2):
953 q.breakable()
954 q.text("actions = ");
955 q.pp(self.actions)
956 q.breakable()
957 q.text('}')
958
959instruction.subtypes[3] = write_actions
960
961class write_metadata(instruction):
962 type = 2
963
964 def __init__(self, metadata=None, metadata_mask=None):
965 if metadata != None:
966 self.metadata = metadata
967 else:
968 self.metadata = 0
969 if metadata_mask != None:
970 self.metadata_mask = metadata_mask
971 else:
972 self.metadata_mask = 0
973 return
974
975 def pack(self):
976 packed = []
977 packed.append(struct.pack("!H", self.type))
978 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
979 packed.append('\x00' * 4)
980 packed.append(struct.pack("!Q", self.metadata))
981 packed.append(struct.pack("!Q", self.metadata_mask))
982 length = sum([len(x) for x in packed])
983 packed[1] = struct.pack("!H", length)
984 return ''.join(packed)
985
986 @staticmethod
987 def unpack(reader):
988 obj = write_metadata()
989 _type = reader.read("!H")[0]
990 assert(_type == 2)
991 _len = reader.read("!H")[0]
992 orig_reader = reader
993 reader = orig_reader.slice(_len - (2 + 2))
994 reader.skip(4)
995 obj.metadata = reader.read("!Q")[0]
996 obj.metadata_mask = reader.read("!Q")[0]
997 return obj
998
999 def __eq__(self, other):
1000 if type(self) != type(other): return False
1001 if self.metadata != other.metadata: return False
1002 if self.metadata_mask != other.metadata_mask: return False
1003 return True
1004
1005 def pretty_print(self, q):
1006 q.text("write_metadata {")
1007 with q.group():
1008 with q.indent(2):
1009 q.breakable()
1010 q.text("metadata = ");
1011 q.text("%#x" % self.metadata)
1012 q.text(","); q.breakable()
1013 q.text("metadata_mask = ");
1014 q.text("%#x" % self.metadata_mask)
1015 q.breakable()
1016 q.text('}')
1017
1018instruction.subtypes[2] = write_metadata
1019
1020