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