blob: 93dd3dcb61b9b673a8e00e2aab3bab73dcac0e44 [file] [log] [blame]
Matteo Scandoloa229eca2017-08-08 13:05:28 -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
Rich Lane2e079da2014-10-29 15:30:24 -070017# 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
Rich Lane2e079da2014-10-29 15:30:24 -070027import util
28import loxi.generic_util
29
Rich Lanee2567702015-01-26 15:04:35 -080030import sys
31ofp = sys.modules['loxi.of14']
32
Rich Lane2e079da2014-10-29 15:30:24 -070033class 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
Rich Lanecb18dbd2014-12-18 10:02:29 -080064 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -070065 reader.skip(4)
66 return obj
67
68 def __eq__(self, other):
69 if type(self) != type(other): return False
70 if self.type != other.type: return False
71 return True
72
73 def pretty_print(self, q):
74 q.text("action {")
75 with q.group():
76 with q.indent(2):
77 q.breakable()
78 q.breakable()
79 q.text('}')
80
81
82class experimenter(action):
83 subtypes = {}
84
85 type = 65535
86
87 def __init__(self, experimenter=None, data=None):
88 if experimenter != None:
89 self.experimenter = experimenter
90 else:
91 self.experimenter = 0
92 if data != None:
93 self.data = data
94 else:
95 self.data = ''
96 return
97
98 def pack(self):
99 packed = []
100 packed.append(struct.pack("!H", self.type))
101 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
102 packed.append(struct.pack("!L", self.experimenter))
103 packed.append(self.data)
104 length = sum([len(x) for x in packed])
105 packed.append(loxi.generic_util.pad_to(8, length))
106 length += len(packed[-1])
107 packed[1] = struct.pack("!H", length)
108 return ''.join(packed)
109
110 @staticmethod
111 def unpack(reader):
112 subtype, = reader.peek('!L', 4)
113 subclass = experimenter.subtypes.get(subtype)
114 if subclass:
115 return subclass.unpack(reader)
116
117 obj = experimenter()
118 _type = reader.read("!H")[0]
119 assert(_type == 65535)
120 _len = reader.read("!H")[0]
121 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800122 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700123 obj.experimenter = reader.read("!L")[0]
124 obj.data = str(reader.read_all())
125 return obj
126
127 def __eq__(self, other):
128 if type(self) != type(other): return False
129 if self.experimenter != other.experimenter: return False
130 if self.data != other.data: return False
131 return True
132
133 def pretty_print(self, q):
134 q.text("experimenter {")
135 with q.group():
136 with q.indent(2):
137 q.breakable()
138 q.text("data = ");
139 q.pp(self.data)
140 q.breakable()
141 q.text('}')
142
143action.subtypes[65535] = experimenter
144
145class bsn(experimenter):
146 subtypes = {}
147
148 type = 65535
149 experimenter = 6035143
150
151 def __init__(self, subtype=None):
152 if subtype != None:
153 self.subtype = subtype
154 else:
155 self.subtype = 0
156 return
157
158 def pack(self):
159 packed = []
160 packed.append(struct.pack("!H", self.type))
161 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
162 packed.append(struct.pack("!L", self.experimenter))
163 packed.append(struct.pack("!L", self.subtype))
164 packed.append('\x00' * 4)
165 length = sum([len(x) for x in packed])
166 packed[1] = struct.pack("!H", length)
167 return ''.join(packed)
168
169 @staticmethod
170 def unpack(reader):
171 subtype, = reader.peek('!L', 8)
172 subclass = bsn.subtypes.get(subtype)
173 if subclass:
174 return subclass.unpack(reader)
175
176 obj = bsn()
177 _type = reader.read("!H")[0]
178 assert(_type == 65535)
179 _len = reader.read("!H")[0]
180 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800181 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700182 _experimenter = reader.read("!L")[0]
183 assert(_experimenter == 6035143)
184 obj.subtype = reader.read("!L")[0]
185 reader.skip(4)
186 return obj
187
188 def __eq__(self, other):
189 if type(self) != type(other): return False
190 if self.subtype != other.subtype: return False
191 return True
192
193 def pretty_print(self, q):
194 q.text("bsn {")
195 with q.group():
196 with q.indent(2):
197 q.breakable()
198 q.breakable()
199 q.text('}')
200
201experimenter.subtypes[6035143] = bsn
202
203class bsn_checksum(bsn):
204 type = 65535
205 experimenter = 6035143
206 subtype = 4
207
208 def __init__(self, checksum=None):
209 if checksum != None:
210 self.checksum = checksum
211 else:
212 self.checksum = 0
213 return
214
215 def pack(self):
216 packed = []
217 packed.append(struct.pack("!H", self.type))
218 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
219 packed.append(struct.pack("!L", self.experimenter))
220 packed.append(struct.pack("!L", self.subtype))
221 packed.append(util.pack_checksum_128(self.checksum))
222 length = sum([len(x) for x in packed])
223 packed[1] = struct.pack("!H", length)
224 return ''.join(packed)
225
226 @staticmethod
227 def unpack(reader):
228 obj = bsn_checksum()
229 _type = reader.read("!H")[0]
230 assert(_type == 65535)
231 _len = reader.read("!H")[0]
232 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800233 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700234 _experimenter = reader.read("!L")[0]
235 assert(_experimenter == 6035143)
236 _subtype = reader.read("!L")[0]
237 assert(_subtype == 4)
238 obj.checksum = util.unpack_checksum_128(reader)
239 return obj
240
241 def __eq__(self, other):
242 if type(self) != type(other): return False
243 if self.checksum != other.checksum: return False
244 return True
245
246 def pretty_print(self, q):
247 q.text("bsn_checksum {")
248 with q.group():
249 with q.indent(2):
250 q.breakable()
251 q.text("checksum = ");
252 q.pp(self.checksum)
253 q.breakable()
254 q.text('}')
255
256bsn.subtypes[4] = bsn_checksum
257
Rich Laneccd32ed2014-11-10 17:48:24 -0800258class bsn_gentable(bsn):
259 type = 65535
260 experimenter = 6035143
261 subtype = 5
262
263 def __init__(self, table_id=None, key=None):
264 if table_id != None:
265 self.table_id = table_id
266 else:
267 self.table_id = 0
268 if key != None:
269 self.key = key
270 else:
271 self.key = []
272 return
273
274 def pack(self):
275 packed = []
276 packed.append(struct.pack("!H", self.type))
277 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
278 packed.append(struct.pack("!L", self.experimenter))
279 packed.append(struct.pack("!L", self.subtype))
280 packed.append(struct.pack("!L", self.table_id))
281 packed.append(loxi.generic_util.pack_list(self.key))
282 length = sum([len(x) for x in packed])
283 packed[1] = struct.pack("!H", length)
284 return ''.join(packed)
285
286 @staticmethod
287 def unpack(reader):
288 obj = bsn_gentable()
289 _type = reader.read("!H")[0]
290 assert(_type == 65535)
291 _len = reader.read("!H")[0]
292 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800293 reader = orig_reader.slice(_len, 4)
Rich Laneccd32ed2014-11-10 17:48:24 -0800294 _experimenter = reader.read("!L")[0]
295 assert(_experimenter == 6035143)
296 _subtype = reader.read("!L")[0]
297 assert(_subtype == 5)
298 obj.table_id = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -0800299 obj.key = loxi.generic_util.unpack_list(reader, ofp.bsn_tlv.bsn_tlv.unpack)
Rich Laneccd32ed2014-11-10 17:48:24 -0800300 return obj
301
302 def __eq__(self, other):
303 if type(self) != type(other): return False
304 if self.table_id != other.table_id: return False
305 if self.key != other.key: return False
306 return True
307
308 def pretty_print(self, q):
309 q.text("bsn_gentable {")
310 with q.group():
311 with q.indent(2):
312 q.breakable()
313 q.text("table_id = ");
314 q.text("%#x" % self.table_id)
315 q.text(","); q.breakable()
316 q.text("key = ");
317 q.pp(self.key)
318 q.breakable()
319 q.text('}')
320
321bsn.subtypes[5] = bsn_gentable
322
Rich Lane2e079da2014-10-29 15:30:24 -0700323class bsn_mirror(bsn):
324 type = 65535
325 experimenter = 6035143
326 subtype = 1
327
328 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
329 if dest_port != None:
330 self.dest_port = dest_port
331 else:
332 self.dest_port = 0
333 if vlan_tag != None:
334 self.vlan_tag = vlan_tag
335 else:
336 self.vlan_tag = 0
337 if copy_stage != None:
338 self.copy_stage = copy_stage
339 else:
340 self.copy_stage = 0
341 return
342
343 def pack(self):
344 packed = []
345 packed.append(struct.pack("!H", self.type))
346 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
347 packed.append(struct.pack("!L", self.experimenter))
348 packed.append(struct.pack("!L", self.subtype))
349 packed.append(struct.pack("!L", self.dest_port))
350 packed.append(struct.pack("!L", self.vlan_tag))
351 packed.append(struct.pack("!B", self.copy_stage))
352 packed.append('\x00' * 3)
353 length = sum([len(x) for x in packed])
354 packed[1] = struct.pack("!H", length)
355 return ''.join(packed)
356
357 @staticmethod
358 def unpack(reader):
359 obj = bsn_mirror()
360 _type = reader.read("!H")[0]
361 assert(_type == 65535)
362 _len = reader.read("!H")[0]
363 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800364 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700365 _experimenter = reader.read("!L")[0]
366 assert(_experimenter == 6035143)
367 _subtype = reader.read("!L")[0]
368 assert(_subtype == 1)
369 obj.dest_port = reader.read("!L")[0]
370 obj.vlan_tag = reader.read("!L")[0]
371 obj.copy_stage = reader.read("!B")[0]
372 reader.skip(3)
373 return obj
374
375 def __eq__(self, other):
376 if type(self) != type(other): return False
377 if self.dest_port != other.dest_port: return False
378 if self.vlan_tag != other.vlan_tag: return False
379 if self.copy_stage != other.copy_stage: return False
380 return True
381
382 def pretty_print(self, q):
383 q.text("bsn_mirror {")
384 with q.group():
385 with q.indent(2):
386 q.breakable()
387 q.text("dest_port = ");
388 q.text("%#x" % self.dest_port)
389 q.text(","); q.breakable()
390 q.text("vlan_tag = ");
391 q.text("%#x" % self.vlan_tag)
392 q.text(","); q.breakable()
393 q.text("copy_stage = ");
394 q.text("%#x" % self.copy_stage)
395 q.breakable()
396 q.text('}')
397
398bsn.subtypes[1] = bsn_mirror
399
400class bsn_set_tunnel_dst(bsn):
401 type = 65535
402 experimenter = 6035143
403 subtype = 2
404
405 def __init__(self, dst=None):
406 if dst != None:
407 self.dst = dst
408 else:
409 self.dst = 0
410 return
411
412 def pack(self):
413 packed = []
414 packed.append(struct.pack("!H", self.type))
415 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
416 packed.append(struct.pack("!L", self.experimenter))
417 packed.append(struct.pack("!L", self.subtype))
418 packed.append(struct.pack("!L", self.dst))
419 length = sum([len(x) for x in packed])
420 packed[1] = struct.pack("!H", length)
421 return ''.join(packed)
422
423 @staticmethod
424 def unpack(reader):
425 obj = bsn_set_tunnel_dst()
426 _type = reader.read("!H")[0]
427 assert(_type == 65535)
428 _len = reader.read("!H")[0]
429 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800430 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700431 _experimenter = reader.read("!L")[0]
432 assert(_experimenter == 6035143)
433 _subtype = reader.read("!L")[0]
434 assert(_subtype == 2)
435 obj.dst = reader.read("!L")[0]
436 return obj
437
438 def __eq__(self, other):
439 if type(self) != type(other): return False
440 if self.dst != other.dst: return False
441 return True
442
443 def pretty_print(self, q):
444 q.text("bsn_set_tunnel_dst {")
445 with q.group():
446 with q.indent(2):
447 q.breakable()
448 q.text("dst = ");
449 q.text("%#x" % self.dst)
450 q.breakable()
451 q.text('}')
452
453bsn.subtypes[2] = bsn_set_tunnel_dst
454
455class copy_ttl_in(action):
456 type = 12
457
458 def __init__(self):
459 return
460
461 def pack(self):
462 packed = []
463 packed.append(struct.pack("!H", self.type))
464 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
465 packed.append('\x00' * 4)
466 length = sum([len(x) for x in packed])
467 packed[1] = struct.pack("!H", length)
468 return ''.join(packed)
469
470 @staticmethod
471 def unpack(reader):
472 obj = copy_ttl_in()
473 _type = reader.read("!H")[0]
474 assert(_type == 12)
475 _len = reader.read("!H")[0]
476 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800477 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700478 reader.skip(4)
479 return obj
480
481 def __eq__(self, other):
482 if type(self) != type(other): return False
483 return True
484
485 def pretty_print(self, q):
486 q.text("copy_ttl_in {")
487 with q.group():
488 with q.indent(2):
489 q.breakable()
490 q.breakable()
491 q.text('}')
492
493action.subtypes[12] = copy_ttl_in
494
495class copy_ttl_out(action):
496 type = 11
497
498 def __init__(self):
499 return
500
501 def pack(self):
502 packed = []
503 packed.append(struct.pack("!H", self.type))
504 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
505 packed.append('\x00' * 4)
506 length = sum([len(x) for x in packed])
507 packed[1] = struct.pack("!H", length)
508 return ''.join(packed)
509
510 @staticmethod
511 def unpack(reader):
512 obj = copy_ttl_out()
513 _type = reader.read("!H")[0]
514 assert(_type == 11)
515 _len = reader.read("!H")[0]
516 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800517 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700518 reader.skip(4)
519 return obj
520
521 def __eq__(self, other):
522 if type(self) != type(other): return False
523 return True
524
525 def pretty_print(self, q):
526 q.text("copy_ttl_out {")
527 with q.group():
528 with q.indent(2):
529 q.breakable()
530 q.breakable()
531 q.text('}')
532
533action.subtypes[11] = copy_ttl_out
534
535class dec_mpls_ttl(action):
536 type = 16
537
538 def __init__(self):
539 return
540
541 def pack(self):
542 packed = []
543 packed.append(struct.pack("!H", self.type))
544 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
545 packed.append('\x00' * 4)
546 length = sum([len(x) for x in packed])
547 packed[1] = struct.pack("!H", length)
548 return ''.join(packed)
549
550 @staticmethod
551 def unpack(reader):
552 obj = dec_mpls_ttl()
553 _type = reader.read("!H")[0]
554 assert(_type == 16)
555 _len = reader.read("!H")[0]
556 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800557 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700558 reader.skip(4)
559 return obj
560
561 def __eq__(self, other):
562 if type(self) != type(other): return False
563 return True
564
565 def pretty_print(self, q):
566 q.text("dec_mpls_ttl {")
567 with q.group():
568 with q.indent(2):
569 q.breakable()
570 q.breakable()
571 q.text('}')
572
573action.subtypes[16] = dec_mpls_ttl
574
575class dec_nw_ttl(action):
576 type = 24
577
578 def __init__(self):
579 return
580
581 def pack(self):
582 packed = []
583 packed.append(struct.pack("!H", self.type))
584 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
585 packed.append('\x00' * 4)
586 length = sum([len(x) for x in packed])
587 packed[1] = struct.pack("!H", length)
588 return ''.join(packed)
589
590 @staticmethod
591 def unpack(reader):
592 obj = dec_nw_ttl()
593 _type = reader.read("!H")[0]
594 assert(_type == 24)
595 _len = reader.read("!H")[0]
596 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800597 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700598 reader.skip(4)
599 return obj
600
601 def __eq__(self, other):
602 if type(self) != type(other): return False
603 return True
604
605 def pretty_print(self, q):
606 q.text("dec_nw_ttl {")
607 with q.group():
608 with q.indent(2):
609 q.breakable()
610 q.breakable()
611 q.text('}')
612
613action.subtypes[24] = dec_nw_ttl
614
615class group(action):
616 type = 22
617
618 def __init__(self, group_id=None):
619 if group_id != None:
620 self.group_id = group_id
621 else:
622 self.group_id = 0
623 return
624
625 def pack(self):
626 packed = []
627 packed.append(struct.pack("!H", self.type))
628 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
629 packed.append(struct.pack("!L", self.group_id))
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 = group()
637 _type = reader.read("!H")[0]
638 assert(_type == 22)
639 _len = reader.read("!H")[0]
640 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800641 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700642 obj.group_id = reader.read("!L")[0]
643 return obj
644
645 def __eq__(self, other):
646 if type(self) != type(other): return False
647 if self.group_id != other.group_id: return False
648 return True
649
650 def pretty_print(self, q):
651 q.text("group {")
652 with q.group():
653 with q.indent(2):
654 q.breakable()
655 q.text("group_id = ");
656 q.text("%#x" % self.group_id)
657 q.breakable()
658 q.text('}')
659
660action.subtypes[22] = group
661
662class nicira(experimenter):
663 subtypes = {}
664
665 type = 65535
666 experimenter = 8992
667
668 def __init__(self, subtype=None):
669 if subtype != None:
670 self.subtype = subtype
671 else:
672 self.subtype = 0
673 return
674
675 def pack(self):
676 packed = []
677 packed.append(struct.pack("!H", self.type))
678 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
679 packed.append(struct.pack("!L", self.experimenter))
680 packed.append(struct.pack("!H", self.subtype))
681 packed.append('\x00' * 2)
682 packed.append('\x00' * 4)
683 length = sum([len(x) for x in packed])
684 packed[1] = struct.pack("!H", length)
685 return ''.join(packed)
686
687 @staticmethod
688 def unpack(reader):
689 subtype, = reader.peek('!H', 8)
690 subclass = nicira.subtypes.get(subtype)
691 if subclass:
692 return subclass.unpack(reader)
693
694 obj = nicira()
695 _type = reader.read("!H")[0]
696 assert(_type == 65535)
697 _len = reader.read("!H")[0]
698 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800699 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700700 _experimenter = reader.read("!L")[0]
701 assert(_experimenter == 8992)
702 obj.subtype = reader.read("!H")[0]
703 reader.skip(2)
704 reader.skip(4)
705 return obj
706
707 def __eq__(self, other):
708 if type(self) != type(other): return False
709 if self.subtype != other.subtype: return False
710 return True
711
712 def pretty_print(self, q):
713 q.text("nicira {")
714 with q.group():
715 with q.indent(2):
716 q.breakable()
717 q.breakable()
718 q.text('}')
719
720experimenter.subtypes[8992] = nicira
721
722class nicira_dec_ttl(nicira):
723 type = 65535
724 experimenter = 8992
725 subtype = 18
726
727 def __init__(self):
728 return
729
730 def pack(self):
731 packed = []
732 packed.append(struct.pack("!H", self.type))
733 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
734 packed.append(struct.pack("!L", self.experimenter))
735 packed.append(struct.pack("!H", self.subtype))
736 packed.append('\x00' * 2)
737 packed.append('\x00' * 4)
738 length = sum([len(x) for x in packed])
739 packed[1] = struct.pack("!H", length)
740 return ''.join(packed)
741
742 @staticmethod
743 def unpack(reader):
744 obj = nicira_dec_ttl()
745 _type = reader.read("!H")[0]
746 assert(_type == 65535)
747 _len = reader.read("!H")[0]
748 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800749 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700750 _experimenter = reader.read("!L")[0]
751 assert(_experimenter == 8992)
752 _subtype = reader.read("!H")[0]
753 assert(_subtype == 18)
754 reader.skip(2)
755 reader.skip(4)
756 return obj
757
758 def __eq__(self, other):
759 if type(self) != type(other): return False
760 return True
761
762 def pretty_print(self, q):
763 q.text("nicira_dec_ttl {")
764 with q.group():
765 with q.indent(2):
766 q.breakable()
767 q.breakable()
768 q.text('}')
769
770nicira.subtypes[18] = nicira_dec_ttl
771
772class output(action):
773 type = 0
774
775 def __init__(self, port=None, max_len=None):
776 if port != None:
777 self.port = port
778 else:
779 self.port = 0
780 if max_len != None:
781 self.max_len = max_len
782 else:
783 self.max_len = 0
784 return
785
786 def pack(self):
787 packed = []
788 packed.append(struct.pack("!H", self.type))
789 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
790 packed.append(util.pack_port_no(self.port))
791 packed.append(struct.pack("!H", self.max_len))
792 packed.append('\x00' * 6)
793 length = sum([len(x) for x in packed])
794 packed[1] = struct.pack("!H", length)
795 return ''.join(packed)
796
797 @staticmethod
798 def unpack(reader):
799 obj = output()
800 _type = reader.read("!H")[0]
801 assert(_type == 0)
802 _len = reader.read("!H")[0]
803 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800804 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700805 obj.port = util.unpack_port_no(reader)
806 obj.max_len = reader.read("!H")[0]
807 reader.skip(6)
808 return obj
809
810 def __eq__(self, other):
811 if type(self) != type(other): return False
812 if self.port != other.port: return False
813 if self.max_len != other.max_len: return False
814 return True
815
816 def pretty_print(self, q):
817 q.text("output {")
818 with q.group():
819 with q.indent(2):
820 q.breakable()
821 q.text("port = ");
822 q.text(util.pretty_port(self.port))
823 q.text(","); q.breakable()
824 q.text("max_len = ");
825 q.text("%#x" % self.max_len)
826 q.breakable()
827 q.text('}')
828
829action.subtypes[0] = output
830
831class pop_mpls(action):
832 type = 20
833
834 def __init__(self, ethertype=None):
835 if ethertype != None:
836 self.ethertype = ethertype
837 else:
838 self.ethertype = 0
839 return
840
841 def pack(self):
842 packed = []
843 packed.append(struct.pack("!H", self.type))
844 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
845 packed.append(struct.pack("!H", self.ethertype))
846 packed.append('\x00' * 2)
847 length = sum([len(x) for x in packed])
848 packed[1] = struct.pack("!H", length)
849 return ''.join(packed)
850
851 @staticmethod
852 def unpack(reader):
853 obj = pop_mpls()
854 _type = reader.read("!H")[0]
855 assert(_type == 20)
856 _len = reader.read("!H")[0]
857 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800858 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700859 obj.ethertype = reader.read("!H")[0]
860 reader.skip(2)
861 return obj
862
863 def __eq__(self, other):
864 if type(self) != type(other): return False
865 if self.ethertype != other.ethertype: return False
866 return True
867
868 def pretty_print(self, q):
869 q.text("pop_mpls {")
870 with q.group():
871 with q.indent(2):
872 q.breakable()
873 q.text("ethertype = ");
874 q.text("%#x" % self.ethertype)
875 q.breakable()
876 q.text('}')
877
878action.subtypes[20] = pop_mpls
879
880class pop_pbb(action):
881 type = 27
882
883 def __init__(self):
884 return
885
886 def pack(self):
887 packed = []
888 packed.append(struct.pack("!H", self.type))
889 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
890 packed.append('\x00' * 4)
891 length = sum([len(x) for x in packed])
892 packed[1] = struct.pack("!H", length)
893 return ''.join(packed)
894
895 @staticmethod
896 def unpack(reader):
897 obj = pop_pbb()
898 _type = reader.read("!H")[0]
899 assert(_type == 27)
900 _len = reader.read("!H")[0]
901 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800902 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700903 reader.skip(4)
904 return obj
905
906 def __eq__(self, other):
907 if type(self) != type(other): return False
908 return True
909
910 def pretty_print(self, q):
911 q.text("pop_pbb {")
912 with q.group():
913 with q.indent(2):
914 q.breakable()
915 q.breakable()
916 q.text('}')
917
918action.subtypes[27] = pop_pbb
919
920class pop_vlan(action):
921 type = 18
922
923 def __init__(self):
924 return
925
926 def pack(self):
927 packed = []
928 packed.append(struct.pack("!H", self.type))
929 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
930 packed.append('\x00' * 4)
931 length = sum([len(x) for x in packed])
932 packed[1] = struct.pack("!H", length)
933 return ''.join(packed)
934
935 @staticmethod
936 def unpack(reader):
937 obj = pop_vlan()
938 _type = reader.read("!H")[0]
939 assert(_type == 18)
940 _len = reader.read("!H")[0]
941 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800942 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700943 reader.skip(4)
944 return obj
945
946 def __eq__(self, other):
947 if type(self) != type(other): return False
948 return True
949
950 def pretty_print(self, q):
951 q.text("pop_vlan {")
952 with q.group():
953 with q.indent(2):
954 q.breakable()
955 q.breakable()
956 q.text('}')
957
958action.subtypes[18] = pop_vlan
959
960class push_mpls(action):
961 type = 19
962
963 def __init__(self, ethertype=None):
964 if ethertype != None:
965 self.ethertype = ethertype
966 else:
967 self.ethertype = 0
968 return
969
970 def pack(self):
971 packed = []
972 packed.append(struct.pack("!H", self.type))
973 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
974 packed.append(struct.pack("!H", self.ethertype))
975 packed.append('\x00' * 2)
976 length = sum([len(x) for x in packed])
977 packed[1] = struct.pack("!H", length)
978 return ''.join(packed)
979
980 @staticmethod
981 def unpack(reader):
982 obj = push_mpls()
983 _type = reader.read("!H")[0]
984 assert(_type == 19)
985 _len = reader.read("!H")[0]
986 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800987 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700988 obj.ethertype = reader.read("!H")[0]
989 reader.skip(2)
990 return obj
991
992 def __eq__(self, other):
993 if type(self) != type(other): return False
994 if self.ethertype != other.ethertype: return False
995 return True
996
997 def pretty_print(self, q):
998 q.text("push_mpls {")
999 with q.group():
1000 with q.indent(2):
1001 q.breakable()
1002 q.text("ethertype = ");
1003 q.text("%#x" % self.ethertype)
1004 q.breakable()
1005 q.text('}')
1006
1007action.subtypes[19] = push_mpls
1008
1009class push_pbb(action):
1010 type = 26
1011
1012 def __init__(self, ethertype=None):
1013 if ethertype != None:
1014 self.ethertype = ethertype
1015 else:
1016 self.ethertype = 0
1017 return
1018
1019 def pack(self):
1020 packed = []
1021 packed.append(struct.pack("!H", self.type))
1022 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1023 packed.append(struct.pack("!H", self.ethertype))
1024 packed.append('\x00' * 2)
1025 length = sum([len(x) for x in packed])
1026 packed[1] = struct.pack("!H", length)
1027 return ''.join(packed)
1028
1029 @staticmethod
1030 def unpack(reader):
1031 obj = push_pbb()
1032 _type = reader.read("!H")[0]
1033 assert(_type == 26)
1034 _len = reader.read("!H")[0]
1035 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001036 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -07001037 obj.ethertype = reader.read("!H")[0]
1038 reader.skip(2)
1039 return obj
1040
1041 def __eq__(self, other):
1042 if type(self) != type(other): return False
1043 if self.ethertype != other.ethertype: return False
1044 return True
1045
1046 def pretty_print(self, q):
1047 q.text("push_pbb {")
1048 with q.group():
1049 with q.indent(2):
1050 q.breakable()
1051 q.text("ethertype = ");
1052 q.text("%#x" % self.ethertype)
1053 q.breakable()
1054 q.text('}')
1055
1056action.subtypes[26] = push_pbb
1057
1058class push_vlan(action):
1059 type = 17
1060
1061 def __init__(self, ethertype=None):
1062 if ethertype != None:
1063 self.ethertype = ethertype
1064 else:
1065 self.ethertype = 0
1066 return
1067
1068 def pack(self):
1069 packed = []
1070 packed.append(struct.pack("!H", self.type))
1071 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1072 packed.append(struct.pack("!H", self.ethertype))
1073 packed.append('\x00' * 2)
1074 length = sum([len(x) for x in packed])
1075 packed[1] = struct.pack("!H", length)
1076 return ''.join(packed)
1077
1078 @staticmethod
1079 def unpack(reader):
1080 obj = push_vlan()
1081 _type = reader.read("!H")[0]
1082 assert(_type == 17)
1083 _len = reader.read("!H")[0]
1084 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001085 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -07001086 obj.ethertype = reader.read("!H")[0]
1087 reader.skip(2)
1088 return obj
1089
1090 def __eq__(self, other):
1091 if type(self) != type(other): return False
1092 if self.ethertype != other.ethertype: return False
1093 return True
1094
1095 def pretty_print(self, q):
1096 q.text("push_vlan {")
1097 with q.group():
1098 with q.indent(2):
1099 q.breakable()
1100 q.text("ethertype = ");
1101 q.text("%#x" % self.ethertype)
1102 q.breakable()
1103 q.text('}')
1104
1105action.subtypes[17] = push_vlan
1106
1107class set_field(action):
1108 type = 25
1109
1110 def __init__(self, field=None):
1111 if field != None:
1112 self.field = field
1113 else:
1114 self.field = None
1115 return
1116
1117 def pack(self):
1118 packed = []
1119 packed.append(struct.pack("!H", self.type))
1120 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1121 packed.append(self.field.pack())
1122 length = sum([len(x) for x in packed])
1123 packed.append(loxi.generic_util.pad_to(8, length))
1124 length += len(packed[-1])
1125 packed[1] = struct.pack("!H", length)
1126 return ''.join(packed)
1127
1128 @staticmethod
1129 def unpack(reader):
1130 obj = set_field()
1131 _type = reader.read("!H")[0]
1132 assert(_type == 25)
1133 _len = reader.read("!H")[0]
1134 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001135 reader = orig_reader.slice(_len, 4)
Rich Lanee2567702015-01-26 15:04:35 -08001136 obj.field = ofp.oxm.oxm.unpack(reader)
Rich Lane2e079da2014-10-29 15:30:24 -07001137 return obj
1138
1139 def __eq__(self, other):
1140 if type(self) != type(other): return False
1141 if self.field != other.field: return False
1142 return True
1143
1144 def pretty_print(self, q):
1145 q.text("set_field {")
1146 with q.group():
1147 with q.indent(2):
1148 q.breakable()
1149 q.text("field = ");
1150 q.pp(self.field)
1151 q.breakable()
1152 q.text('}')
1153
1154action.subtypes[25] = set_field
1155
1156class set_mpls_ttl(action):
1157 type = 15
1158
1159 def __init__(self, mpls_ttl=None):
1160 if mpls_ttl != None:
1161 self.mpls_ttl = mpls_ttl
1162 else:
1163 self.mpls_ttl = 0
1164 return
1165
1166 def pack(self):
1167 packed = []
1168 packed.append(struct.pack("!H", self.type))
1169 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1170 packed.append(struct.pack("!B", self.mpls_ttl))
1171 packed.append('\x00' * 3)
1172 length = sum([len(x) for x in packed])
1173 packed[1] = struct.pack("!H", length)
1174 return ''.join(packed)
1175
1176 @staticmethod
1177 def unpack(reader):
1178 obj = set_mpls_ttl()
1179 _type = reader.read("!H")[0]
1180 assert(_type == 15)
1181 _len = reader.read("!H")[0]
1182 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001183 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -07001184 obj.mpls_ttl = reader.read("!B")[0]
1185 reader.skip(3)
1186 return obj
1187
1188 def __eq__(self, other):
1189 if type(self) != type(other): return False
1190 if self.mpls_ttl != other.mpls_ttl: return False
1191 return True
1192
1193 def pretty_print(self, q):
1194 q.text("set_mpls_ttl {")
1195 with q.group():
1196 with q.indent(2):
1197 q.breakable()
1198 q.text("mpls_ttl = ");
1199 q.text("%#x" % self.mpls_ttl)
1200 q.breakable()
1201 q.text('}')
1202
1203action.subtypes[15] = set_mpls_ttl
1204
1205class set_nw_ttl(action):
1206 type = 23
1207
1208 def __init__(self, nw_ttl=None):
1209 if nw_ttl != None:
1210 self.nw_ttl = nw_ttl
1211 else:
1212 self.nw_ttl = 0
1213 return
1214
1215 def pack(self):
1216 packed = []
1217 packed.append(struct.pack("!H", self.type))
1218 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1219 packed.append(struct.pack("!B", self.nw_ttl))
1220 packed.append('\x00' * 3)
1221 length = sum([len(x) for x in packed])
1222 packed[1] = struct.pack("!H", length)
1223 return ''.join(packed)
1224
1225 @staticmethod
1226 def unpack(reader):
1227 obj = set_nw_ttl()
1228 _type = reader.read("!H")[0]
1229 assert(_type == 23)
1230 _len = reader.read("!H")[0]
1231 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001232 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -07001233 obj.nw_ttl = reader.read("!B")[0]
1234 reader.skip(3)
1235 return obj
1236
1237 def __eq__(self, other):
1238 if type(self) != type(other): return False
1239 if self.nw_ttl != other.nw_ttl: return False
1240 return True
1241
1242 def pretty_print(self, q):
1243 q.text("set_nw_ttl {")
1244 with q.group():
1245 with q.indent(2):
1246 q.breakable()
1247 q.text("nw_ttl = ");
1248 q.text("%#x" % self.nw_ttl)
1249 q.breakable()
1250 q.text('}')
1251
1252action.subtypes[23] = set_nw_ttl
1253
1254class set_queue(action):
1255 type = 21
1256
1257 def __init__(self, queue_id=None):
1258 if queue_id != None:
1259 self.queue_id = queue_id
1260 else:
1261 self.queue_id = 0
1262 return
1263
1264 def pack(self):
1265 packed = []
1266 packed.append(struct.pack("!H", self.type))
1267 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1268 packed.append(struct.pack("!L", self.queue_id))
1269 length = sum([len(x) for x in packed])
1270 packed[1] = struct.pack("!H", length)
1271 return ''.join(packed)
1272
1273 @staticmethod
1274 def unpack(reader):
1275 obj = set_queue()
1276 _type = reader.read("!H")[0]
1277 assert(_type == 21)
1278 _len = reader.read("!H")[0]
1279 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001280 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -07001281 obj.queue_id = reader.read("!L")[0]
1282 return obj
1283
1284 def __eq__(self, other):
1285 if type(self) != type(other): return False
1286 if self.queue_id != other.queue_id: return False
1287 return True
1288
1289 def pretty_print(self, q):
1290 q.text("set_queue {")
1291 with q.group():
1292 with q.indent(2):
1293 q.breakable()
1294 q.text("queue_id = ");
1295 q.text("%#x" % self.queue_id)
1296 q.breakable()
1297 q.text('}')
1298
1299action.subtypes[21] = set_queue
1300
1301