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