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