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