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