blob: 79fc2ffd0950a9a7332f55fe03084d23bb6926b1 [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.of11']
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[1] = struct.pack("!H", length)
103 return ''.join(packed)
104
105 @staticmethod
106 def unpack(reader):
107 subtype, = reader.peek('!L', 4)
108 subclass = experimenter.subtypes.get(subtype)
109 if subclass:
110 return subclass.unpack(reader)
111
112 obj = experimenter()
113 _type = reader.read("!H")[0]
114 assert(_type == 65535)
115 _len = reader.read("!H")[0]
116 orig_reader = reader
117 reader = orig_reader.slice(_len, 4)
118 obj.experimenter = reader.read("!L")[0]
119 obj.data = str(reader.read_all())
120 return obj
121
122 def __eq__(self, other):
123 if type(self) != type(other): return False
124 if self.experimenter != other.experimenter: return False
125 if self.data != other.data: return False
126 return True
127
128 def pretty_print(self, q):
129 q.text("experimenter {")
130 with q.group():
131 with q.indent(2):
132 q.breakable()
133 q.text("data = ");
134 q.pp(self.data)
135 q.breakable()
136 q.text('}')
137
138action.subtypes[65535] = experimenter
139
140class bsn(experimenter):
141 subtypes = {}
142
143 type = 65535
144 experimenter = 6035143
145
146 def __init__(self, subtype=None):
147 if subtype != None:
148 self.subtype = subtype
149 else:
150 self.subtype = 0
151 return
152
153 def pack(self):
154 packed = []
155 packed.append(struct.pack("!H", self.type))
156 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
157 packed.append(struct.pack("!L", self.experimenter))
158 packed.append(struct.pack("!L", self.subtype))
159 packed.append('\x00' * 4)
160 length = sum([len(x) for x in packed])
161 packed[1] = struct.pack("!H", length)
162 return ''.join(packed)
163
164 @staticmethod
165 def unpack(reader):
166 subtype, = reader.peek('!L', 8)
167 subclass = bsn.subtypes.get(subtype)
168 if subclass:
169 return subclass.unpack(reader)
170
171 obj = bsn()
172 _type = reader.read("!H")[0]
173 assert(_type == 65535)
174 _len = reader.read("!H")[0]
175 orig_reader = reader
176 reader = orig_reader.slice(_len, 4)
177 _experimenter = reader.read("!L")[0]
178 assert(_experimenter == 6035143)
179 obj.subtype = reader.read("!L")[0]
180 reader.skip(4)
181 return obj
182
183 def __eq__(self, other):
184 if type(self) != type(other): return False
185 if self.subtype != other.subtype: return False
186 return True
187
188 def pretty_print(self, q):
189 q.text("bsn {")
190 with q.group():
191 with q.indent(2):
192 q.breakable()
193 q.breakable()
194 q.text('}')
195
196experimenter.subtypes[6035143] = bsn
197
198class bsn_checksum(bsn):
199 type = 65535
200 experimenter = 6035143
201 subtype = 4
202
203 def __init__(self, checksum=None):
204 if checksum != None:
205 self.checksum = checksum
206 else:
207 self.checksum = 0
208 return
209
210 def pack(self):
211 packed = []
212 packed.append(struct.pack("!H", self.type))
213 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
214 packed.append(struct.pack("!L", self.experimenter))
215 packed.append(struct.pack("!L", self.subtype))
216 packed.append(util.pack_checksum_128(self.checksum))
217 length = sum([len(x) for x in packed])
218 packed[1] = struct.pack("!H", length)
219 return ''.join(packed)
220
221 @staticmethod
222 def unpack(reader):
223 obj = bsn_checksum()
224 _type = reader.read("!H")[0]
225 assert(_type == 65535)
226 _len = reader.read("!H")[0]
227 orig_reader = reader
228 reader = orig_reader.slice(_len, 4)
229 _experimenter = reader.read("!L")[0]
230 assert(_experimenter == 6035143)
231 _subtype = reader.read("!L")[0]
232 assert(_subtype == 4)
233 obj.checksum = util.unpack_checksum_128(reader)
234 return obj
235
236 def __eq__(self, other):
237 if type(self) != type(other): return False
238 if self.checksum != other.checksum: return False
239 return True
240
241 def pretty_print(self, q):
242 q.text("bsn_checksum {")
243 with q.group():
244 with q.indent(2):
245 q.breakable()
246 q.text("checksum = ");
247 q.pp(self.checksum)
248 q.breakable()
249 q.text('}')
250
251bsn.subtypes[4] = bsn_checksum
252
253class bsn_mirror(bsn):
254 type = 65535
255 experimenter = 6035143
256 subtype = 1
257
258 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
259 if dest_port != None:
260 self.dest_port = dest_port
261 else:
262 self.dest_port = 0
263 if vlan_tag != None:
264 self.vlan_tag = vlan_tag
265 else:
266 self.vlan_tag = 0
267 if copy_stage != None:
268 self.copy_stage = copy_stage
269 else:
270 self.copy_stage = 0
271 return
272
273 def pack(self):
274 packed = []
275 packed.append(struct.pack("!H", self.type))
276 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
277 packed.append(struct.pack("!L", self.experimenter))
278 packed.append(struct.pack("!L", self.subtype))
279 packed.append(struct.pack("!L", self.dest_port))
280 packed.append(struct.pack("!L", self.vlan_tag))
281 packed.append(struct.pack("!B", self.copy_stage))
282 packed.append('\x00' * 3)
283 length = sum([len(x) for x in packed])
284 packed[1] = struct.pack("!H", length)
285 return ''.join(packed)
286
287 @staticmethod
288 def unpack(reader):
289 obj = bsn_mirror()
290 _type = reader.read("!H")[0]
291 assert(_type == 65535)
292 _len = reader.read("!H")[0]
293 orig_reader = reader
294 reader = orig_reader.slice(_len, 4)
295 _experimenter = reader.read("!L")[0]
296 assert(_experimenter == 6035143)
297 _subtype = reader.read("!L")[0]
298 assert(_subtype == 1)
299 obj.dest_port = reader.read("!L")[0]
300 obj.vlan_tag = reader.read("!L")[0]
301 obj.copy_stage = reader.read("!B")[0]
302 reader.skip(3)
303 return obj
304
305 def __eq__(self, other):
306 if type(self) != type(other): return False
307 if self.dest_port != other.dest_port: return False
308 if self.vlan_tag != other.vlan_tag: return False
309 if self.copy_stage != other.copy_stage: return False
310 return True
311
312 def pretty_print(self, q):
313 q.text("bsn_mirror {")
314 with q.group():
315 with q.indent(2):
316 q.breakable()
317 q.text("dest_port = ");
318 q.text("%#x" % self.dest_port)
319 q.text(","); q.breakable()
320 q.text("vlan_tag = ");
321 q.text("%#x" % self.vlan_tag)
322 q.text(","); q.breakable()
323 q.text("copy_stage = ");
324 q.text("%#x" % self.copy_stage)
325 q.breakable()
326 q.text('}')
327
328bsn.subtypes[1] = bsn_mirror
329
330class bsn_set_tunnel_dst(bsn):
331 type = 65535
332 experimenter = 6035143
333 subtype = 2
334
335 def __init__(self, dst=None):
336 if dst != None:
337 self.dst = dst
338 else:
339 self.dst = 0
340 return
341
342 def pack(self):
343 packed = []
344 packed.append(struct.pack("!H", self.type))
345 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
346 packed.append(struct.pack("!L", self.experimenter))
347 packed.append(struct.pack("!L", self.subtype))
348 packed.append(struct.pack("!L", self.dst))
349 length = sum([len(x) for x in packed])
350 packed[1] = struct.pack("!H", length)
351 return ''.join(packed)
352
353 @staticmethod
354 def unpack(reader):
355 obj = bsn_set_tunnel_dst()
356 _type = reader.read("!H")[0]
357 assert(_type == 65535)
358 _len = reader.read("!H")[0]
359 orig_reader = reader
360 reader = orig_reader.slice(_len, 4)
361 _experimenter = reader.read("!L")[0]
362 assert(_experimenter == 6035143)
363 _subtype = reader.read("!L")[0]
364 assert(_subtype == 2)
365 obj.dst = reader.read("!L")[0]
366 return obj
367
368 def __eq__(self, other):
369 if type(self) != type(other): return False
370 if self.dst != other.dst: return False
371 return True
372
373 def pretty_print(self, q):
374 q.text("bsn_set_tunnel_dst {")
375 with q.group():
376 with q.indent(2):
377 q.breakable()
378 q.text("dst = ");
379 q.text("%#x" % self.dst)
380 q.breakable()
381 q.text('}')
382
383bsn.subtypes[2] = bsn_set_tunnel_dst
384
385class copy_ttl_in(action):
386 type = 12
387
388 def __init__(self):
389 return
390
391 def pack(self):
392 packed = []
393 packed.append(struct.pack("!H", self.type))
394 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
395 packed.append('\x00' * 4)
396 length = sum([len(x) for x in packed])
397 packed[1] = struct.pack("!H", length)
398 return ''.join(packed)
399
400 @staticmethod
401 def unpack(reader):
402 obj = copy_ttl_in()
403 _type = reader.read("!H")[0]
404 assert(_type == 12)
405 _len = reader.read("!H")[0]
406 orig_reader = reader
407 reader = orig_reader.slice(_len, 4)
408 reader.skip(4)
409 return obj
410
411 def __eq__(self, other):
412 if type(self) != type(other): return False
413 return True
414
415 def pretty_print(self, q):
416 q.text("copy_ttl_in {")
417 with q.group():
418 with q.indent(2):
419 q.breakable()
420 q.breakable()
421 q.text('}')
422
423action.subtypes[12] = copy_ttl_in
424
425class copy_ttl_out(action):
426 type = 11
427
428 def __init__(self):
429 return
430
431 def pack(self):
432 packed = []
433 packed.append(struct.pack("!H", self.type))
434 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
435 packed.append('\x00' * 4)
436 length = sum([len(x) for x in packed])
437 packed[1] = struct.pack("!H", length)
438 return ''.join(packed)
439
440 @staticmethod
441 def unpack(reader):
442 obj = copy_ttl_out()
443 _type = reader.read("!H")[0]
444 assert(_type == 11)
445 _len = reader.read("!H")[0]
446 orig_reader = reader
447 reader = orig_reader.slice(_len, 4)
448 reader.skip(4)
449 return obj
450
451 def __eq__(self, other):
452 if type(self) != type(other): return False
453 return True
454
455 def pretty_print(self, q):
456 q.text("copy_ttl_out {")
457 with q.group():
458 with q.indent(2):
459 q.breakable()
460 q.breakable()
461 q.text('}')
462
463action.subtypes[11] = copy_ttl_out
464
465class dec_mpls_ttl(action):
466 type = 16
467
468 def __init__(self):
469 return
470
471 def pack(self):
472 packed = []
473 packed.append(struct.pack("!H", self.type))
474 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
475 packed.append('\x00' * 4)
476 length = sum([len(x) for x in packed])
477 packed[1] = struct.pack("!H", length)
478 return ''.join(packed)
479
480 @staticmethod
481 def unpack(reader):
482 obj = dec_mpls_ttl()
483 _type = reader.read("!H")[0]
484 assert(_type == 16)
485 _len = reader.read("!H")[0]
486 orig_reader = reader
487 reader = orig_reader.slice(_len, 4)
488 reader.skip(4)
489 return obj
490
491 def __eq__(self, other):
492 if type(self) != type(other): return False
493 return True
494
495 def pretty_print(self, q):
496 q.text("dec_mpls_ttl {")
497 with q.group():
498 with q.indent(2):
499 q.breakable()
500 q.breakable()
501 q.text('}')
502
503action.subtypes[16] = dec_mpls_ttl
504
505class dec_nw_ttl(action):
506 type = 24
507
508 def __init__(self):
509 return
510
511 def pack(self):
512 packed = []
513 packed.append(struct.pack("!H", self.type))
514 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
515 packed.append('\x00' * 4)
516 length = sum([len(x) for x in packed])
517 packed[1] = struct.pack("!H", length)
518 return ''.join(packed)
519
520 @staticmethod
521 def unpack(reader):
522 obj = dec_nw_ttl()
523 _type = reader.read("!H")[0]
524 assert(_type == 24)
525 _len = reader.read("!H")[0]
526 orig_reader = reader
527 reader = orig_reader.slice(_len, 4)
528 reader.skip(4)
529 return obj
530
531 def __eq__(self, other):
532 if type(self) != type(other): return False
533 return True
534
535 def pretty_print(self, q):
536 q.text("dec_nw_ttl {")
537 with q.group():
538 with q.indent(2):
539 q.breakable()
540 q.breakable()
541 q.text('}')
542
543action.subtypes[24] = dec_nw_ttl
544
545class group(action):
546 type = 22
547
548 def __init__(self, group_id=None):
549 if group_id != None:
550 self.group_id = group_id
551 else:
552 self.group_id = 0
553 return
554
555 def pack(self):
556 packed = []
557 packed.append(struct.pack("!H", self.type))
558 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
559 packed.append(struct.pack("!L", self.group_id))
560 length = sum([len(x) for x in packed])
561 packed[1] = struct.pack("!H", length)
562 return ''.join(packed)
563
564 @staticmethod
565 def unpack(reader):
566 obj = group()
567 _type = reader.read("!H")[0]
568 assert(_type == 22)
569 _len = reader.read("!H")[0]
570 orig_reader = reader
571 reader = orig_reader.slice(_len, 4)
572 obj.group_id = reader.read("!L")[0]
573 return obj
574
575 def __eq__(self, other):
576 if type(self) != type(other): return False
577 if self.group_id != other.group_id: return False
578 return True
579
580 def pretty_print(self, q):
581 q.text("group {")
582 with q.group():
583 with q.indent(2):
584 q.breakable()
585 q.text("group_id = ");
586 q.text("%#x" % self.group_id)
587 q.breakable()
588 q.text('}')
589
590action.subtypes[22] = group
591
592class nicira(experimenter):
593 subtypes = {}
594
595 type = 65535
596 experimenter = 8992
597
598 def __init__(self, subtype=None):
599 if subtype != None:
600 self.subtype = subtype
601 else:
602 self.subtype = 0
603 return
604
605 def pack(self):
606 packed = []
607 packed.append(struct.pack("!H", self.type))
608 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
609 packed.append(struct.pack("!L", self.experimenter))
610 packed.append(struct.pack("!H", self.subtype))
611 packed.append('\x00' * 2)
612 packed.append('\x00' * 4)
613 length = sum([len(x) for x in packed])
614 packed[1] = struct.pack("!H", length)
615 return ''.join(packed)
616
617 @staticmethod
618 def unpack(reader):
619 subtype, = reader.peek('!H', 8)
620 subclass = nicira.subtypes.get(subtype)
621 if subclass:
622 return subclass.unpack(reader)
623
624 obj = nicira()
625 _type = reader.read("!H")[0]
626 assert(_type == 65535)
627 _len = reader.read("!H")[0]
628 orig_reader = reader
629 reader = orig_reader.slice(_len, 4)
630 _experimenter = reader.read("!L")[0]
631 assert(_experimenter == 8992)
632 obj.subtype = reader.read("!H")[0]
633 reader.skip(2)
634 reader.skip(4)
635 return obj
636
637 def __eq__(self, other):
638 if type(self) != type(other): return False
639 if self.subtype != other.subtype: return False
640 return True
641
642 def pretty_print(self, q):
643 q.text("nicira {")
644 with q.group():
645 with q.indent(2):
646 q.breakable()
647 q.breakable()
648 q.text('}')
649
650experimenter.subtypes[8992] = nicira
651
652class nicira_dec_ttl(nicira):
653 type = 65535
654 experimenter = 8992
655 subtype = 18
656
657 def __init__(self):
658 return
659
660 def pack(self):
661 packed = []
662 packed.append(struct.pack("!H", self.type))
663 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
664 packed.append(struct.pack("!L", self.experimenter))
665 packed.append(struct.pack("!H", self.subtype))
666 packed.append('\x00' * 2)
667 packed.append('\x00' * 4)
668 length = sum([len(x) for x in packed])
669 packed[1] = struct.pack("!H", length)
670 return ''.join(packed)
671
672 @staticmethod
673 def unpack(reader):
674 obj = nicira_dec_ttl()
675 _type = reader.read("!H")[0]
676 assert(_type == 65535)
677 _len = reader.read("!H")[0]
678 orig_reader = reader
679 reader = orig_reader.slice(_len, 4)
680 _experimenter = reader.read("!L")[0]
681 assert(_experimenter == 8992)
682 _subtype = reader.read("!H")[0]
683 assert(_subtype == 18)
684 reader.skip(2)
685 reader.skip(4)
686 return obj
687
688 def __eq__(self, other):
689 if type(self) != type(other): return False
690 return True
691
692 def pretty_print(self, q):
693 q.text("nicira_dec_ttl {")
694 with q.group():
695 with q.indent(2):
696 q.breakable()
697 q.breakable()
698 q.text('}')
699
700nicira.subtypes[18] = nicira_dec_ttl
701
702class output(action):
703 type = 0
704
705 def __init__(self, port=None, max_len=None):
706 if port != None:
707 self.port = port
708 else:
709 self.port = 0
710 if max_len != None:
711 self.max_len = max_len
712 else:
713 self.max_len = 0
714 return
715
716 def pack(self):
717 packed = []
718 packed.append(struct.pack("!H", self.type))
719 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
720 packed.append(util.pack_port_no(self.port))
721 packed.append(struct.pack("!H", self.max_len))
722 packed.append('\x00' * 6)
723 length = sum([len(x) for x in packed])
724 packed[1] = struct.pack("!H", length)
725 return ''.join(packed)
726
727 @staticmethod
728 def unpack(reader):
729 obj = output()
730 _type = reader.read("!H")[0]
731 assert(_type == 0)
732 _len = reader.read("!H")[0]
733 orig_reader = reader
734 reader = orig_reader.slice(_len, 4)
735 obj.port = util.unpack_port_no(reader)
736 obj.max_len = reader.read("!H")[0]
737 reader.skip(6)
738 return obj
739
740 def __eq__(self, other):
741 if type(self) != type(other): return False
742 if self.port != other.port: return False
743 if self.max_len != other.max_len: return False
744 return True
745
746 def pretty_print(self, q):
747 q.text("output {")
748 with q.group():
749 with q.indent(2):
750 q.breakable()
751 q.text("port = ");
752 q.text(util.pretty_port(self.port))
753 q.text(","); q.breakable()
754 q.text("max_len = ");
755 q.text("%#x" % self.max_len)
756 q.breakable()
757 q.text('}')
758
759action.subtypes[0] = output
760
761class pop_mpls(action):
762 type = 20
763
764 def __init__(self, ethertype=None):
765 if ethertype != None:
766 self.ethertype = ethertype
767 else:
768 self.ethertype = 0
769 return
770
771 def pack(self):
772 packed = []
773 packed.append(struct.pack("!H", self.type))
774 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
775 packed.append(struct.pack("!H", self.ethertype))
776 packed.append('\x00' * 2)
777 length = sum([len(x) for x in packed])
778 packed[1] = struct.pack("!H", length)
779 return ''.join(packed)
780
781 @staticmethod
782 def unpack(reader):
783 obj = pop_mpls()
784 _type = reader.read("!H")[0]
785 assert(_type == 20)
786 _len = reader.read("!H")[0]
787 orig_reader = reader
788 reader = orig_reader.slice(_len, 4)
789 obj.ethertype = reader.read("!H")[0]
790 reader.skip(2)
791 return obj
792
793 def __eq__(self, other):
794 if type(self) != type(other): return False
795 if self.ethertype != other.ethertype: return False
796 return True
797
798 def pretty_print(self, q):
799 q.text("pop_mpls {")
800 with q.group():
801 with q.indent(2):
802 q.breakable()
803 q.text("ethertype = ");
804 q.text("%#x" % self.ethertype)
805 q.breakable()
806 q.text('}')
807
808action.subtypes[20] = pop_mpls
809
810class pop_vlan(action):
811 type = 18
812
813 def __init__(self):
814 return
815
816 def pack(self):
817 packed = []
818 packed.append(struct.pack("!H", self.type))
819 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
820 packed.append('\x00' * 4)
821 length = sum([len(x) for x in packed])
822 packed[1] = struct.pack("!H", length)
823 return ''.join(packed)
824
825 @staticmethod
826 def unpack(reader):
827 obj = pop_vlan()
828 _type = reader.read("!H")[0]
829 assert(_type == 18)
830 _len = reader.read("!H")[0]
831 orig_reader = reader
832 reader = orig_reader.slice(_len, 4)
833 reader.skip(4)
834 return obj
835
836 def __eq__(self, other):
837 if type(self) != type(other): return False
838 return True
839
840 def pretty_print(self, q):
841 q.text("pop_vlan {")
842 with q.group():
843 with q.indent(2):
844 q.breakable()
845 q.breakable()
846 q.text('}')
847
848action.subtypes[18] = pop_vlan
849
850class push_mpls(action):
851 type = 19
852
853 def __init__(self, ethertype=None):
854 if ethertype != None:
855 self.ethertype = ethertype
856 else:
857 self.ethertype = 0
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(struct.pack("!H", self.ethertype))
865 packed.append('\x00' * 2)
866 length = sum([len(x) for x in packed])
867 packed[1] = struct.pack("!H", length)
868 return ''.join(packed)
869
870 @staticmethod
871 def unpack(reader):
872 obj = push_mpls()
873 _type = reader.read("!H")[0]
874 assert(_type == 19)
875 _len = reader.read("!H")[0]
876 orig_reader = reader
877 reader = orig_reader.slice(_len, 4)
878 obj.ethertype = reader.read("!H")[0]
879 reader.skip(2)
880 return obj
881
882 def __eq__(self, other):
883 if type(self) != type(other): return False
884 if self.ethertype != other.ethertype: return False
885 return True
886
887 def pretty_print(self, q):
888 q.text("push_mpls {")
889 with q.group():
890 with q.indent(2):
891 q.breakable()
892 q.text("ethertype = ");
893 q.text("%#x" % self.ethertype)
894 q.breakable()
895 q.text('}')
896
897action.subtypes[19] = push_mpls
898
899class push_vlan(action):
900 type = 17
901
902 def __init__(self, ethertype=None):
903 if ethertype != None:
904 self.ethertype = ethertype
905 else:
906 self.ethertype = 0
907 return
908
909 def pack(self):
910 packed = []
911 packed.append(struct.pack("!H", self.type))
912 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
913 packed.append(struct.pack("!H", self.ethertype))
914 packed.append('\x00' * 2)
915 length = sum([len(x) for x in packed])
916 packed[1] = struct.pack("!H", length)
917 return ''.join(packed)
918
919 @staticmethod
920 def unpack(reader):
921 obj = push_vlan()
922 _type = reader.read("!H")[0]
923 assert(_type == 17)
924 _len = reader.read("!H")[0]
925 orig_reader = reader
926 reader = orig_reader.slice(_len, 4)
927 obj.ethertype = reader.read("!H")[0]
928 reader.skip(2)
929 return obj
930
931 def __eq__(self, other):
932 if type(self) != type(other): return False
933 if self.ethertype != other.ethertype: return False
934 return True
935
936 def pretty_print(self, q):
937 q.text("push_vlan {")
938 with q.group():
939 with q.indent(2):
940 q.breakable()
941 q.text("ethertype = ");
942 q.text("%#x" % self.ethertype)
943 q.breakable()
944 q.text('}')
945
946action.subtypes[17] = push_vlan
947
948class set_dl_dst(action):
949 type = 4
950
951 def __init__(self, dl_addr=None):
952 if dl_addr != None:
953 self.dl_addr = dl_addr
954 else:
955 self.dl_addr = [0,0,0,0,0,0]
956 return
957
958 def pack(self):
959 packed = []
960 packed.append(struct.pack("!H", self.type))
961 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
962 packed.append(struct.pack("!6B", *self.dl_addr))
963 packed.append('\x00' * 6)
964 length = sum([len(x) for x in packed])
965 packed[1] = struct.pack("!H", length)
966 return ''.join(packed)
967
968 @staticmethod
969 def unpack(reader):
970 obj = set_dl_dst()
971 _type = reader.read("!H")[0]
972 assert(_type == 4)
973 _len = reader.read("!H")[0]
974 orig_reader = reader
975 reader = orig_reader.slice(_len, 4)
976 obj.dl_addr = list(reader.read('!6B'))
977 reader.skip(6)
978 return obj
979
980 def __eq__(self, other):
981 if type(self) != type(other): return False
982 if self.dl_addr != other.dl_addr: return False
983 return True
984
985 def pretty_print(self, q):
986 q.text("set_dl_dst {")
987 with q.group():
988 with q.indent(2):
989 q.breakable()
990 q.text("dl_addr = ");
991 q.text(util.pretty_mac(self.dl_addr))
992 q.breakable()
993 q.text('}')
994
995action.subtypes[4] = set_dl_dst
996
997class set_dl_src(action):
998 type = 3
999
1000 def __init__(self, dl_addr=None):
1001 if dl_addr != None:
1002 self.dl_addr = dl_addr
1003 else:
1004 self.dl_addr = [0,0,0,0,0,0]
1005 return
1006
1007 def pack(self):
1008 packed = []
1009 packed.append(struct.pack("!H", self.type))
1010 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1011 packed.append(struct.pack("!6B", *self.dl_addr))
1012 packed.append('\x00' * 6)
1013 length = sum([len(x) for x in packed])
1014 packed[1] = struct.pack("!H", length)
1015 return ''.join(packed)
1016
1017 @staticmethod
1018 def unpack(reader):
1019 obj = set_dl_src()
1020 _type = reader.read("!H")[0]
1021 assert(_type == 3)
1022 _len = reader.read("!H")[0]
1023 orig_reader = reader
1024 reader = orig_reader.slice(_len, 4)
1025 obj.dl_addr = list(reader.read('!6B'))
1026 reader.skip(6)
1027 return obj
1028
1029 def __eq__(self, other):
1030 if type(self) != type(other): return False
1031 if self.dl_addr != other.dl_addr: return False
1032 return True
1033
1034 def pretty_print(self, q):
1035 q.text("set_dl_src {")
1036 with q.group():
1037 with q.indent(2):
1038 q.breakable()
1039 q.text("dl_addr = ");
1040 q.text(util.pretty_mac(self.dl_addr))
1041 q.breakable()
1042 q.text('}')
1043
1044action.subtypes[3] = set_dl_src
1045
1046class set_mpls_label(action):
1047 type = 13
1048
1049 def __init__(self, mpls_label=None):
1050 if mpls_label != None:
1051 self.mpls_label = mpls_label
1052 else:
1053 self.mpls_label = 0
1054 return
1055
1056 def pack(self):
1057 packed = []
1058 packed.append(struct.pack("!H", self.type))
1059 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1060 packed.append(struct.pack("!L", self.mpls_label))
1061 length = sum([len(x) for x in packed])
1062 packed[1] = struct.pack("!H", length)
1063 return ''.join(packed)
1064
1065 @staticmethod
1066 def unpack(reader):
1067 obj = set_mpls_label()
1068 _type = reader.read("!H")[0]
1069 assert(_type == 13)
1070 _len = reader.read("!H")[0]
1071 orig_reader = reader
1072 reader = orig_reader.slice(_len, 4)
1073 obj.mpls_label = reader.read("!L")[0]
1074 return obj
1075
1076 def __eq__(self, other):
1077 if type(self) != type(other): return False
1078 if self.mpls_label != other.mpls_label: return False
1079 return True
1080
1081 def pretty_print(self, q):
1082 q.text("set_mpls_label {")
1083 with q.group():
1084 with q.indent(2):
1085 q.breakable()
1086 q.text("mpls_label = ");
1087 q.text("%#x" % self.mpls_label)
1088 q.breakable()
1089 q.text('}')
1090
1091action.subtypes[13] = set_mpls_label
1092
1093class set_mpls_tc(action):
1094 type = 14
1095
1096 def __init__(self, mpls_tc=None):
1097 if mpls_tc != None:
1098 self.mpls_tc = mpls_tc
1099 else:
1100 self.mpls_tc = 0
1101 return
1102
1103 def pack(self):
1104 packed = []
1105 packed.append(struct.pack("!H", self.type))
1106 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1107 packed.append(struct.pack("!B", self.mpls_tc))
1108 packed.append('\x00' * 3)
1109 length = sum([len(x) for x in packed])
1110 packed[1] = struct.pack("!H", length)
1111 return ''.join(packed)
1112
1113 @staticmethod
1114 def unpack(reader):
1115 obj = set_mpls_tc()
1116 _type = reader.read("!H")[0]
1117 assert(_type == 14)
1118 _len = reader.read("!H")[0]
1119 orig_reader = reader
1120 reader = orig_reader.slice(_len, 4)
1121 obj.mpls_tc = reader.read("!B")[0]
1122 reader.skip(3)
1123 return obj
1124
1125 def __eq__(self, other):
1126 if type(self) != type(other): return False
1127 if self.mpls_tc != other.mpls_tc: return False
1128 return True
1129
1130 def pretty_print(self, q):
1131 q.text("set_mpls_tc {")
1132 with q.group():
1133 with q.indent(2):
1134 q.breakable()
1135 q.text("mpls_tc = ");
1136 q.text("%#x" % self.mpls_tc)
1137 q.breakable()
1138 q.text('}')
1139
1140action.subtypes[14] = set_mpls_tc
1141
1142class set_mpls_ttl(action):
1143 type = 15
1144
1145 def __init__(self, mpls_ttl=None):
1146 if mpls_ttl != None:
1147 self.mpls_ttl = mpls_ttl
1148 else:
1149 self.mpls_ttl = 0
1150 return
1151
1152 def pack(self):
1153 packed = []
1154 packed.append(struct.pack("!H", self.type))
1155 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1156 packed.append(struct.pack("!B", self.mpls_ttl))
1157 packed.append('\x00' * 3)
1158 length = sum([len(x) for x in packed])
1159 packed[1] = struct.pack("!H", length)
1160 return ''.join(packed)
1161
1162 @staticmethod
1163 def unpack(reader):
1164 obj = set_mpls_ttl()
1165 _type = reader.read("!H")[0]
1166 assert(_type == 15)
1167 _len = reader.read("!H")[0]
1168 orig_reader = reader
1169 reader = orig_reader.slice(_len, 4)
1170 obj.mpls_ttl = reader.read("!B")[0]
1171 reader.skip(3)
1172 return obj
1173
1174 def __eq__(self, other):
1175 if type(self) != type(other): return False
1176 if self.mpls_ttl != other.mpls_ttl: return False
1177 return True
1178
1179 def pretty_print(self, q):
1180 q.text("set_mpls_ttl {")
1181 with q.group():
1182 with q.indent(2):
1183 q.breakable()
1184 q.text("mpls_ttl = ");
1185 q.text("%#x" % self.mpls_ttl)
1186 q.breakable()
1187 q.text('}')
1188
1189action.subtypes[15] = set_mpls_ttl
1190
1191class set_nw_dst(action):
1192 type = 6
1193
1194 def __init__(self, nw_addr=None):
1195 if nw_addr != None:
1196 self.nw_addr = nw_addr
1197 else:
1198 self.nw_addr = 0
1199 return
1200
1201 def pack(self):
1202 packed = []
1203 packed.append(struct.pack("!H", self.type))
1204 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1205 packed.append(struct.pack("!L", self.nw_addr))
1206 length = sum([len(x) for x in packed])
1207 packed[1] = struct.pack("!H", length)
1208 return ''.join(packed)
1209
1210 @staticmethod
1211 def unpack(reader):
1212 obj = set_nw_dst()
1213 _type = reader.read("!H")[0]
1214 assert(_type == 6)
1215 _len = reader.read("!H")[0]
1216 orig_reader = reader
1217 reader = orig_reader.slice(_len, 4)
1218 obj.nw_addr = reader.read("!L")[0]
1219 return obj
1220
1221 def __eq__(self, other):
1222 if type(self) != type(other): return False
1223 if self.nw_addr != other.nw_addr: return False
1224 return True
1225
1226 def pretty_print(self, q):
1227 q.text("set_nw_dst {")
1228 with q.group():
1229 with q.indent(2):
1230 q.breakable()
1231 q.text("nw_addr = ");
1232 q.text("%#x" % self.nw_addr)
1233 q.breakable()
1234 q.text('}')
1235
1236action.subtypes[6] = set_nw_dst
1237
1238class set_nw_ecn(action):
1239 type = 8
1240
1241 def __init__(self, nw_ecn=None):
1242 if nw_ecn != None:
1243 self.nw_ecn = nw_ecn
1244 else:
1245 self.nw_ecn = 0
1246 return
1247
1248 def pack(self):
1249 packed = []
1250 packed.append(struct.pack("!H", self.type))
1251 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1252 packed.append(struct.pack("!B", self.nw_ecn))
1253 packed.append('\x00' * 3)
1254 length = sum([len(x) for x in packed])
1255 packed[1] = struct.pack("!H", length)
1256 return ''.join(packed)
1257
1258 @staticmethod
1259 def unpack(reader):
1260 obj = set_nw_ecn()
1261 _type = reader.read("!H")[0]
1262 assert(_type == 8)
1263 _len = reader.read("!H")[0]
1264 orig_reader = reader
1265 reader = orig_reader.slice(_len, 4)
1266 obj.nw_ecn = reader.read("!B")[0]
1267 reader.skip(3)
1268 return obj
1269
1270 def __eq__(self, other):
1271 if type(self) != type(other): return False
1272 if self.nw_ecn != other.nw_ecn: return False
1273 return True
1274
1275 def pretty_print(self, q):
1276 q.text("set_nw_ecn {")
1277 with q.group():
1278 with q.indent(2):
1279 q.breakable()
1280 q.text("nw_ecn = ");
1281 q.text("%#x" % self.nw_ecn)
1282 q.breakable()
1283 q.text('}')
1284
1285action.subtypes[8] = set_nw_ecn
1286
1287class set_nw_src(action):
1288 type = 5
1289
1290 def __init__(self, nw_addr=None):
1291 if nw_addr != None:
1292 self.nw_addr = nw_addr
1293 else:
1294 self.nw_addr = 0
1295 return
1296
1297 def pack(self):
1298 packed = []
1299 packed.append(struct.pack("!H", self.type))
1300 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1301 packed.append(struct.pack("!L", self.nw_addr))
1302 length = sum([len(x) for x in packed])
1303 packed[1] = struct.pack("!H", length)
1304 return ''.join(packed)
1305
1306 @staticmethod
1307 def unpack(reader):
1308 obj = set_nw_src()
1309 _type = reader.read("!H")[0]
1310 assert(_type == 5)
1311 _len = reader.read("!H")[0]
1312 orig_reader = reader
1313 reader = orig_reader.slice(_len, 4)
1314 obj.nw_addr = reader.read("!L")[0]
1315 return obj
1316
1317 def __eq__(self, other):
1318 if type(self) != type(other): return False
1319 if self.nw_addr != other.nw_addr: return False
1320 return True
1321
1322 def pretty_print(self, q):
1323 q.text("set_nw_src {")
1324 with q.group():
1325 with q.indent(2):
1326 q.breakable()
1327 q.text("nw_addr = ");
1328 q.text("%#x" % self.nw_addr)
1329 q.breakable()
1330 q.text('}')
1331
1332action.subtypes[5] = set_nw_src
1333
1334class set_nw_tos(action):
1335 type = 7
1336
1337 def __init__(self, nw_tos=None):
1338 if nw_tos != None:
1339 self.nw_tos = nw_tos
1340 else:
1341 self.nw_tos = 0
1342 return
1343
1344 def pack(self):
1345 packed = []
1346 packed.append(struct.pack("!H", self.type))
1347 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1348 packed.append(struct.pack("!B", self.nw_tos))
1349 packed.append('\x00' * 3)
1350 length = sum([len(x) for x in packed])
1351 packed[1] = struct.pack("!H", length)
1352 return ''.join(packed)
1353
1354 @staticmethod
1355 def unpack(reader):
1356 obj = set_nw_tos()
1357 _type = reader.read("!H")[0]
1358 assert(_type == 7)
1359 _len = reader.read("!H")[0]
1360 orig_reader = reader
1361 reader = orig_reader.slice(_len, 4)
1362 obj.nw_tos = reader.read("!B")[0]
1363 reader.skip(3)
1364 return obj
1365
1366 def __eq__(self, other):
1367 if type(self) != type(other): return False
1368 if self.nw_tos != other.nw_tos: return False
1369 return True
1370
1371 def pretty_print(self, q):
1372 q.text("set_nw_tos {")
1373 with q.group():
1374 with q.indent(2):
1375 q.breakable()
1376 q.text("nw_tos = ");
1377 q.text("%#x" % self.nw_tos)
1378 q.breakable()
1379 q.text('}')
1380
1381action.subtypes[7] = set_nw_tos
1382
1383class set_nw_ttl(action):
1384 type = 23
1385
1386 def __init__(self, nw_ttl=None):
1387 if nw_ttl != None:
1388 self.nw_ttl = nw_ttl
1389 else:
1390 self.nw_ttl = 0
1391 return
1392
1393 def pack(self):
1394 packed = []
1395 packed.append(struct.pack("!H", self.type))
1396 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1397 packed.append(struct.pack("!B", self.nw_ttl))
1398 packed.append('\x00' * 3)
1399 length = sum([len(x) for x in packed])
1400 packed[1] = struct.pack("!H", length)
1401 return ''.join(packed)
1402
1403 @staticmethod
1404 def unpack(reader):
1405 obj = set_nw_ttl()
1406 _type = reader.read("!H")[0]
1407 assert(_type == 23)
1408 _len = reader.read("!H")[0]
1409 orig_reader = reader
1410 reader = orig_reader.slice(_len, 4)
1411 obj.nw_ttl = reader.read("!B")[0]
1412 reader.skip(3)
1413 return obj
1414
1415 def __eq__(self, other):
1416 if type(self) != type(other): return False
1417 if self.nw_ttl != other.nw_ttl: return False
1418 return True
1419
1420 def pretty_print(self, q):
1421 q.text("set_nw_ttl {")
1422 with q.group():
1423 with q.indent(2):
1424 q.breakable()
1425 q.text("nw_ttl = ");
1426 q.text("%#x" % self.nw_ttl)
1427 q.breakable()
1428 q.text('}')
1429
1430action.subtypes[23] = set_nw_ttl
1431
1432class set_queue(action):
1433 type = 21
1434
1435 def __init__(self, queue_id=None):
1436 if queue_id != None:
1437 self.queue_id = queue_id
1438 else:
1439 self.queue_id = 0
1440 return
1441
1442 def pack(self):
1443 packed = []
1444 packed.append(struct.pack("!H", self.type))
1445 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1446 packed.append(struct.pack("!L", self.queue_id))
1447 length = sum([len(x) for x in packed])
1448 packed[1] = struct.pack("!H", length)
1449 return ''.join(packed)
1450
1451 @staticmethod
1452 def unpack(reader):
1453 obj = set_queue()
1454 _type = reader.read("!H")[0]
1455 assert(_type == 21)
1456 _len = reader.read("!H")[0]
1457 orig_reader = reader
1458 reader = orig_reader.slice(_len, 4)
1459 obj.queue_id = reader.read("!L")[0]
1460 return obj
1461
1462 def __eq__(self, other):
1463 if type(self) != type(other): return False
1464 if self.queue_id != other.queue_id: return False
1465 return True
1466
1467 def pretty_print(self, q):
1468 q.text("set_queue {")
1469 with q.group():
1470 with q.indent(2):
1471 q.breakable()
1472 q.text("queue_id = ");
1473 q.text("%#x" % self.queue_id)
1474 q.breakable()
1475 q.text('}')
1476
1477action.subtypes[21] = set_queue
1478
1479class set_tp_dst(action):
1480 type = 10
1481
1482 def __init__(self, tp_port=None):
1483 if tp_port != None:
1484 self.tp_port = tp_port
1485 else:
1486 self.tp_port = 0
1487 return
1488
1489 def pack(self):
1490 packed = []
1491 packed.append(struct.pack("!H", self.type))
1492 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1493 packed.append(struct.pack("!H", self.tp_port))
1494 packed.append('\x00' * 2)
1495 length = sum([len(x) for x in packed])
1496 packed[1] = struct.pack("!H", length)
1497 return ''.join(packed)
1498
1499 @staticmethod
1500 def unpack(reader):
1501 obj = set_tp_dst()
1502 _type = reader.read("!H")[0]
1503 assert(_type == 10)
1504 _len = reader.read("!H")[0]
1505 orig_reader = reader
1506 reader = orig_reader.slice(_len, 4)
1507 obj.tp_port = reader.read("!H")[0]
1508 reader.skip(2)
1509 return obj
1510
1511 def __eq__(self, other):
1512 if type(self) != type(other): return False
1513 if self.tp_port != other.tp_port: return False
1514 return True
1515
1516 def pretty_print(self, q):
1517 q.text("set_tp_dst {")
1518 with q.group():
1519 with q.indent(2):
1520 q.breakable()
1521 q.text("tp_port = ");
1522 q.text("%#x" % self.tp_port)
1523 q.breakable()
1524 q.text('}')
1525
1526action.subtypes[10] = set_tp_dst
1527
1528class set_tp_src(action):
1529 type = 9
1530
1531 def __init__(self, tp_port=None):
1532 if tp_port != None:
1533 self.tp_port = tp_port
1534 else:
1535 self.tp_port = 0
1536 return
1537
1538 def pack(self):
1539 packed = []
1540 packed.append(struct.pack("!H", self.type))
1541 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1542 packed.append(struct.pack("!H", self.tp_port))
1543 packed.append('\x00' * 2)
1544 length = sum([len(x) for x in packed])
1545 packed[1] = struct.pack("!H", length)
1546 return ''.join(packed)
1547
1548 @staticmethod
1549 def unpack(reader):
1550 obj = set_tp_src()
1551 _type = reader.read("!H")[0]
1552 assert(_type == 9)
1553 _len = reader.read("!H")[0]
1554 orig_reader = reader
1555 reader = orig_reader.slice(_len, 4)
1556 obj.tp_port = reader.read("!H")[0]
1557 reader.skip(2)
1558 return obj
1559
1560 def __eq__(self, other):
1561 if type(self) != type(other): return False
1562 if self.tp_port != other.tp_port: return False
1563 return True
1564
1565 def pretty_print(self, q):
1566 q.text("set_tp_src {")
1567 with q.group():
1568 with q.indent(2):
1569 q.breakable()
1570 q.text("tp_port = ");
1571 q.text("%#x" % self.tp_port)
1572 q.breakable()
1573 q.text('}')
1574
1575action.subtypes[9] = set_tp_src
1576
1577class set_vlan_pcp(action):
1578 type = 2
1579
1580 def __init__(self, vlan_pcp=None):
1581 if vlan_pcp != None:
1582 self.vlan_pcp = vlan_pcp
1583 else:
1584 self.vlan_pcp = 0
1585 return
1586
1587 def pack(self):
1588 packed = []
1589 packed.append(struct.pack("!H", self.type))
1590 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1591 packed.append(struct.pack("!B", self.vlan_pcp))
1592 packed.append('\x00' * 3)
1593 length = sum([len(x) for x in packed])
1594 packed[1] = struct.pack("!H", length)
1595 return ''.join(packed)
1596
1597 @staticmethod
1598 def unpack(reader):
1599 obj = set_vlan_pcp()
1600 _type = reader.read("!H")[0]
1601 assert(_type == 2)
1602 _len = reader.read("!H")[0]
1603 orig_reader = reader
1604 reader = orig_reader.slice(_len, 4)
1605 obj.vlan_pcp = reader.read("!B")[0]
1606 reader.skip(3)
1607 return obj
1608
1609 def __eq__(self, other):
1610 if type(self) != type(other): return False
1611 if self.vlan_pcp != other.vlan_pcp: return False
1612 return True
1613
1614 def pretty_print(self, q):
1615 q.text("set_vlan_pcp {")
1616 with q.group():
1617 with q.indent(2):
1618 q.breakable()
1619 q.text("vlan_pcp = ");
1620 q.text("%#x" % self.vlan_pcp)
1621 q.breakable()
1622 q.text('}')
1623
1624action.subtypes[2] = set_vlan_pcp
1625
1626class set_vlan_vid(action):
1627 type = 1
1628
1629 def __init__(self, vlan_vid=None):
1630 if vlan_vid != None:
1631 self.vlan_vid = vlan_vid
1632 else:
1633 self.vlan_vid = 0
1634 return
1635
1636 def pack(self):
1637 packed = []
1638 packed.append(struct.pack("!H", self.type))
1639 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1640 packed.append(struct.pack("!H", self.vlan_vid))
1641 packed.append('\x00' * 2)
1642 length = sum([len(x) for x in packed])
1643 packed[1] = struct.pack("!H", length)
1644 return ''.join(packed)
1645
1646 @staticmethod
1647 def unpack(reader):
1648 obj = set_vlan_vid()
1649 _type = reader.read("!H")[0]
1650 assert(_type == 1)
1651 _len = reader.read("!H")[0]
1652 orig_reader = reader
1653 reader = orig_reader.slice(_len, 4)
1654 obj.vlan_vid = reader.read("!H")[0]
1655 reader.skip(2)
1656 return obj
1657
1658 def __eq__(self, other):
1659 if type(self) != type(other): return False
1660 if self.vlan_vid != other.vlan_vid: return False
1661 return True
1662
1663 def pretty_print(self, q):
1664 q.text("set_vlan_vid {")
1665 with q.group():
1666 with q.indent(2):
1667 q.breakable()
1668 q.text("vlan_vid = ");
1669 q.text("%#x" % self.vlan_vid)
1670 q.breakable()
1671 q.text('}')
1672
1673action.subtypes[1] = set_vlan_vid
1674
1675