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