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