blob: 2f8063e2c5eb608a4085fc69e7d5f50e7151f50b [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.of13']
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_split_horizon_check(bsn):
473 type = 65535
474 experimenter = 6035143
475 subtype = 3
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_split_horizon_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 == 3)
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_split_horizon_check {")
512 with q.group():
513 with q.indent(2):
514 q.breakable()
515 q.breakable()
516 q.text('}')
517
518bsn.subtypes[3] = bsn_disable_split_horizon_check
519
520class bsn_disable_src_mac_check(bsn):
521 type = 65535
522 experimenter = 6035143
523 subtype = 0
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_src_mac_check()
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 == 0)
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_src_mac_check {")
560 with q.group():
561 with q.indent(2):
562 q.breakable()
563 q.breakable()
564 q.text('}')
565
566bsn.subtypes[0] = bsn_disable_src_mac_check
567
568class bsn_disable_vlan_counters(bsn):
569 type = 65535
570 experimenter = 6035143
571 subtype = 9
572
573 def __init__(self):
574 return
575
576 def pack(self):
577 packed = []
578 packed.append(struct.pack("!H", self.type))
579 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
580 packed.append(struct.pack("!L", self.experimenter))
581 packed.append(struct.pack("!L", self.subtype))
582 packed.append('\x00' * 4)
583 length = sum([len(x) for x in packed])
584 packed[1] = struct.pack("!H", length)
585 return ''.join(packed)
586
587 @staticmethod
588 def unpack(reader):
589 obj = bsn_disable_vlan_counters()
590 _type = reader.read("!H")[0]
591 assert(_type == 65535)
592 _len = reader.read("!H")[0]
593 orig_reader = reader
594 reader = orig_reader.slice(_len, 4)
595 _experimenter = reader.read("!L")[0]
596 assert(_experimenter == 6035143)
597 _subtype = reader.read("!L")[0]
598 assert(_subtype == 9)
599 reader.skip(4)
600 return obj
601
602 def __eq__(self, other):
603 if type(self) != type(other): return False
604 return True
605
606 def pretty_print(self, q):
607 q.text("bsn_disable_vlan_counters {")
608 with q.group():
609 with q.indent(2):
610 q.breakable()
611 q.breakable()
612 q.text('}')
613
614bsn.subtypes[9] = bsn_disable_vlan_counters
615
616class bsn_internal_priority(bsn):
617 type = 65535
618 experimenter = 6035143
619 subtype = 12
620
621 def __init__(self, value=None):
622 if value != None:
623 self.value = value
624 else:
625 self.value = 0
626 return
627
628 def pack(self):
629 packed = []
630 packed.append(struct.pack("!H", self.type))
631 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
632 packed.append(struct.pack("!L", self.experimenter))
633 packed.append(struct.pack("!L", self.subtype))
634 packed.append(struct.pack("!L", self.value))
635 length = sum([len(x) for x in packed])
636 packed[1] = struct.pack("!H", length)
637 return ''.join(packed)
638
639 @staticmethod
640 def unpack(reader):
641 obj = bsn_internal_priority()
642 _type = reader.read("!H")[0]
643 assert(_type == 65535)
644 _len = reader.read("!H")[0]
645 orig_reader = reader
646 reader = orig_reader.slice(_len, 4)
647 _experimenter = reader.read("!L")[0]
648 assert(_experimenter == 6035143)
649 _subtype = reader.read("!L")[0]
650 assert(_subtype == 12)
651 obj.value = reader.read("!L")[0]
652 return obj
653
654 def __eq__(self, other):
655 if type(self) != type(other): return False
656 if self.value != other.value: return False
657 return True
658
659 def pretty_print(self, q):
660 q.text("bsn_internal_priority {")
661 with q.group():
662 with q.indent(2):
663 q.breakable()
664 q.text("value = ");
665 q.text("%#x" % self.value)
666 q.breakable()
667 q.text('}')
668
669bsn.subtypes[12] = bsn_internal_priority
670
671class bsn_packet_of_death(bsn):
672 type = 65535
673 experimenter = 6035143
674 subtype = 6
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_packet_of_death()
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 == 6)
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_packet_of_death {")
711 with q.group():
712 with q.indent(2):
713 q.breakable()
714 q.breakable()
715 q.text('}')
716
717bsn.subtypes[6] = bsn_packet_of_death
718
719class bsn_permit(bsn):
720 type = 65535
721 experimenter = 6035143
722 subtype = 4
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_permit()
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 == 4)
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_permit {")
759 with q.group():
760 with q.indent(2):
761 q.breakable()
762 q.breakable()
763 q.text('}')
764
765bsn.subtypes[4] = bsn_permit
766
767class bsn_prioritize_pdus(bsn):
768 type = 65535
769 experimenter = 6035143
770 subtype = 7
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_prioritize_pdus()
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 == 7)
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_prioritize_pdus {")
807 with q.group():
808 with q.indent(2):
809 q.breakable()
810 q.breakable()
811 q.text('}')
812
813bsn.subtypes[7] = bsn_prioritize_pdus
814
815class bsn_require_vlan_xlate(bsn):
816 type = 65535
817 experimenter = 6035143
818 subtype = 8
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_require_vlan_xlate()
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 == 8)
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_require_vlan_xlate {")
855 with q.group():
856 with q.indent(2):
857 q.breakable()
858 q.breakable()
859 q.text('}')
860
861bsn.subtypes[8] = bsn_require_vlan_xlate
862
863class bsn_span_destination(bsn):
864 type = 65535
865 experimenter = 6035143
866 subtype = 10
867
868 def __init__(self):
869 return
870
871 def pack(self):
872 packed = []
873 packed.append(struct.pack("!H", self.type))
874 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
875 packed.append(struct.pack("!L", self.experimenter))
876 packed.append(struct.pack("!L", self.subtype))
877 packed.append('\x00' * 4)
878 length = sum([len(x) for x in packed])
879 packed[1] = struct.pack("!H", length)
880 return ''.join(packed)
881
882 @staticmethod
883 def unpack(reader):
884 obj = bsn_span_destination()
885 _type = reader.read("!H")[0]
886 assert(_type == 65535)
887 _len = reader.read("!H")[0]
888 orig_reader = reader
889 reader = orig_reader.slice(_len, 4)
890 _experimenter = reader.read("!L")[0]
891 assert(_experimenter == 6035143)
892 _subtype = reader.read("!L")[0]
893 assert(_subtype == 10)
894 reader.skip(4)
895 return obj
896
897 def __eq__(self, other):
898 if type(self) != type(other): return False
899 return True
900
901 def pretty_print(self, q):
902 q.text("bsn_span_destination {")
903 with q.group():
904 with q.indent(2):
905 q.breakable()
906 q.breakable()
907 q.text('}')
908
909bsn.subtypes[10] = bsn_span_destination
910
911class clear_actions(instruction):
912 type = 5
913
914 def __init__(self):
915 return
916
917 def pack(self):
918 packed = []
919 packed.append(struct.pack("!H", self.type))
920 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
921 packed.append('\x00' * 4)
922 length = sum([len(x) for x in packed])
923 packed[1] = struct.pack("!H", length)
924 return ''.join(packed)
925
926 @staticmethod
927 def unpack(reader):
928 obj = clear_actions()
929 _type = reader.read("!H")[0]
930 assert(_type == 5)
931 _len = reader.read("!H")[0]
932 orig_reader = reader
933 reader = orig_reader.slice(_len, 4)
934 reader.skip(4)
935 return obj
936
937 def __eq__(self, other):
938 if type(self) != type(other): return False
939 return True
940
941 def pretty_print(self, q):
942 q.text("clear_actions {")
943 with q.group():
944 with q.indent(2):
945 q.breakable()
946 q.breakable()
947 q.text('}')
948
949instruction.subtypes[5] = clear_actions
950
951class goto_table(instruction):
952 type = 1
953
954 def __init__(self, table_id=None):
955 if table_id != None:
956 self.table_id = table_id
957 else:
958 self.table_id = 0
959 return
960
961 def pack(self):
962 packed = []
963 packed.append(struct.pack("!H", self.type))
964 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
965 packed.append(struct.pack("!B", self.table_id))
966 packed.append('\x00' * 3)
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 = goto_table()
974 _type = reader.read("!H")[0]
975 assert(_type == 1)
976 _len = reader.read("!H")[0]
977 orig_reader = reader
978 reader = orig_reader.slice(_len, 4)
979 obj.table_id = reader.read("!B")[0]
980 reader.skip(3)
981 return obj
982
983 def __eq__(self, other):
984 if type(self) != type(other): return False
985 if self.table_id != other.table_id: return False
986 return True
987
988 def pretty_print(self, q):
989 q.text("goto_table {")
990 with q.group():
991 with q.indent(2):
992 q.breakable()
993 q.text("table_id = ");
994 q.text("%#x" % self.table_id)
995 q.breakable()
996 q.text('}')
997
998instruction.subtypes[1] = goto_table
999
1000class meter(instruction):
1001 type = 6
1002
1003 def __init__(self, meter_id=None):
1004 if meter_id != None:
1005 self.meter_id = meter_id
1006 else:
1007 self.meter_id = 0
1008 return
1009
1010 def pack(self):
1011 packed = []
1012 packed.append(struct.pack("!H", self.type))
1013 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1014 packed.append(struct.pack("!L", self.meter_id))
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 = meter()
1022 _type = reader.read("!H")[0]
1023 assert(_type == 6)
1024 _len = reader.read("!H")[0]
1025 orig_reader = reader
1026 reader = orig_reader.slice(_len, 4)
1027 obj.meter_id = reader.read("!L")[0]
1028 return obj
1029
1030 def __eq__(self, other):
1031 if type(self) != type(other): return False
1032 if self.meter_id != other.meter_id: return False
1033 return True
1034
1035 def pretty_print(self, q):
1036 q.text("meter {")
1037 with q.group():
1038 with q.indent(2):
1039 q.breakable()
1040 q.text("meter_id = ");
1041 q.text("%#x" % self.meter_id)
1042 q.breakable()
1043 q.text('}')
1044
1045instruction.subtypes[6] = meter
1046
1047class write_actions(instruction):
1048 type = 3
1049
1050 def __init__(self, actions=None):
1051 if actions != None:
1052 self.actions = actions
1053 else:
1054 self.actions = []
1055 return
1056
1057 def pack(self):
1058 packed = []
1059 packed.append(struct.pack("!H", self.type))
1060 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1061 packed.append('\x00' * 4)
1062 packed.append(loxi.generic_util.pack_list(self.actions))
1063 length = sum([len(x) for x in packed])
1064 packed[1] = struct.pack("!H", length)
1065 return ''.join(packed)
1066
1067 @staticmethod
1068 def unpack(reader):
1069 obj = write_actions()
1070 _type = reader.read("!H")[0]
1071 assert(_type == 3)
1072 _len = reader.read("!H")[0]
1073 orig_reader = reader
1074 reader = orig_reader.slice(_len, 4)
1075 reader.skip(4)
1076 obj.actions = loxi.generic_util.unpack_list(reader, ofp.action.action.unpack)
1077 return obj
1078
1079 def __eq__(self, other):
1080 if type(self) != type(other): return False
1081 if self.actions != other.actions: return False
1082 return True
1083
1084 def pretty_print(self, q):
1085 q.text("write_actions {")
1086 with q.group():
1087 with q.indent(2):
1088 q.breakable()
1089 q.text("actions = ");
1090 q.pp(self.actions)
1091 q.breakable()
1092 q.text('}')
1093
1094instruction.subtypes[3] = write_actions
1095
1096class write_metadata(instruction):
1097 type = 2
1098
1099 def __init__(self, metadata=None, metadata_mask=None):
1100 if metadata != None:
1101 self.metadata = metadata
1102 else:
1103 self.metadata = 0
1104 if metadata_mask != None:
1105 self.metadata_mask = metadata_mask
1106 else:
1107 self.metadata_mask = 0
1108 return
1109
1110 def pack(self):
1111 packed = []
1112 packed.append(struct.pack("!H", self.type))
1113 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1114 packed.append('\x00' * 4)
1115 packed.append(struct.pack("!Q", self.metadata))
1116 packed.append(struct.pack("!Q", self.metadata_mask))
1117 length = sum([len(x) for x in packed])
1118 packed[1] = struct.pack("!H", length)
1119 return ''.join(packed)
1120
1121 @staticmethod
1122 def unpack(reader):
1123 obj = write_metadata()
1124 _type = reader.read("!H")[0]
1125 assert(_type == 2)
1126 _len = reader.read("!H")[0]
1127 orig_reader = reader
1128 reader = orig_reader.slice(_len, 4)
1129 reader.skip(4)
1130 obj.metadata = reader.read("!Q")[0]
1131 obj.metadata_mask = reader.read("!Q")[0]
1132 return obj
1133
1134 def __eq__(self, other):
1135 if type(self) != type(other): return False
1136 if self.metadata != other.metadata: return False
1137 if self.metadata_mask != other.metadata_mask: return False
1138 return True
1139
1140 def pretty_print(self, q):
1141 q.text("write_metadata {")
1142 with q.group():
1143 with q.indent(2):
1144 q.breakable()
1145 q.text("metadata = ");
1146 q.text("%#x" % self.metadata)
1147 q.text(","); q.breakable()
1148 q.text("metadata_mask = ");
1149 q.text("%#x" % self.metadata_mask)
1150 q.breakable()
1151 q.text('}')
1152
1153instruction.subtypes[2] = write_metadata
1154
1155