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