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