blob: 7d64a9a595cfe603bbd57f48c74355ab93ba113b [file] [log] [blame]
Rich Lane7dcdf022013-12-11 14:45:27 -08001# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2# Copyright (c) 2011, 2012 Open Networking Foundation
3# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4# See the file LICENSE.pyloxi which should have been included in the source distribution
5
6# Automatically generated by LOXI from template module.py
7# Do not modify
8
9import struct
10import loxi
11import const
12import common
13import action
14import instruction
15import oxm
16import action_id
17import instruction_id
18import meter_band
Rich Lane5454b682014-01-14 17:07:36 -080019import bsn_tlv
Rich Lane7dcdf022013-12-11 14:45:27 -080020import util
21import loxi.generic_util
22
23class instruction_id(loxi.OFObject):
24 subtypes = {}
25
Rich Lane95f7fc92014-01-27 17:08:16 -080026
27 def __init__(self, type=None):
28 if type != None:
29 self.type = type
30 else:
31 self.type = 0
32 return
33
34 def pack(self):
35 packed = []
36 packed.append(struct.pack("!H", self.type))
37 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
38 length = sum([len(x) for x in packed])
39 packed[1] = struct.pack("!H", length)
40 return ''.join(packed)
41
Rich Lane7dcdf022013-12-11 14:45:27 -080042 @staticmethod
43 def unpack(reader):
44 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -080045 subclass = instruction_id.subtypes.get(subtype)
46 if subclass:
47 return subclass.unpack(reader)
48
49 obj = instruction_id()
50 obj.type = reader.read("!H")[0]
51 _len = reader.read("!H")[0]
52 orig_reader = reader
53 reader = orig_reader.slice(_len - (2 + 2))
54 return obj
55
56 def __eq__(self, other):
57 if type(self) != type(other): return False
58 if self.type != other.type: return False
59 return True
60
61 def pretty_print(self, q):
62 q.text("instruction_id {")
63 with q.group():
64 with q.indent(2):
65 q.breakable()
66 q.breakable()
67 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -080068
69
70class apply_actions(instruction_id):
71 type = 4
72
73 def __init__(self):
74 return
75
76 def pack(self):
77 packed = []
78 packed.append(struct.pack("!H", self.type))
79 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -080080 length = sum([len(x) for x in packed])
81 packed[1] = struct.pack("!H", length)
82 return ''.join(packed)
83
84 @staticmethod
85 def unpack(reader):
86 obj = apply_actions()
87 _type = reader.read("!H")[0]
88 assert(_type == 4)
89 _len = reader.read("!H")[0]
90 orig_reader = reader
91 reader = orig_reader.slice(_len - (2 + 2))
Rich Lane7dcdf022013-12-11 14:45:27 -080092 return obj
93
94 def __eq__(self, other):
95 if type(self) != type(other): return False
96 return True
97
98 def pretty_print(self, q):
99 q.text("apply_actions {")
100 with q.group():
101 with q.indent(2):
102 q.breakable()
103 q.breakable()
104 q.text('}')
105
106instruction_id.subtypes[4] = apply_actions
107
108class experimenter(instruction_id):
109 subtypes = {}
110
Rich Lane95f7fc92014-01-27 17:08:16 -0800111 type = 65535
112
113 def __init__(self, experimenter=None):
114 if experimenter != None:
115 self.experimenter = experimenter
116 else:
117 self.experimenter = 0
118 return
119
120 def pack(self):
121 packed = []
122 packed.append(struct.pack("!H", self.type))
123 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
124 packed.append(struct.pack("!L", self.experimenter))
125 length = sum([len(x) for x in packed])
126 packed[1] = struct.pack("!H", length)
127 return ''.join(packed)
128
Rich Lane7dcdf022013-12-11 14:45:27 -0800129 @staticmethod
130 def unpack(reader):
131 subtype, = reader.peek('!L', 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800132 subclass = experimenter.subtypes.get(subtype)
133 if subclass:
134 return subclass.unpack(reader)
135
136 obj = experimenter()
137 _type = reader.read("!H")[0]
138 assert(_type == 65535)
139 _len = reader.read("!H")[0]
140 orig_reader = reader
141 reader = orig_reader.slice(_len - (2 + 2))
142 obj.experimenter = reader.read("!L")[0]
143 return obj
144
145 def __eq__(self, other):
146 if type(self) != type(other): return False
147 if self.experimenter != other.experimenter: return False
148 return True
149
150 def pretty_print(self, q):
151 q.text("experimenter {")
152 with q.group():
153 with q.indent(2):
154 q.breakable()
155 q.breakable()
156 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800157
158instruction_id.subtypes[65535] = experimenter
159
160class bsn(experimenter):
161 subtypes = {}
162
Rich Lane95f7fc92014-01-27 17:08:16 -0800163 type = 65535
164 experimenter = 6035143
165
166 def __init__(self, subtype=None):
167 if subtype != None:
168 self.subtype = subtype
169 else:
170 self.subtype = 0
171 return
172
173 def pack(self):
174 packed = []
175 packed.append(struct.pack("!H", self.type))
176 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
177 packed.append(struct.pack("!L", self.experimenter))
178 packed.append(struct.pack("!L", self.subtype))
Rich Lane95f7fc92014-01-27 17:08:16 -0800179 length = sum([len(x) for x in packed])
180 packed[1] = struct.pack("!H", length)
181 return ''.join(packed)
182
Rich Lane7dcdf022013-12-11 14:45:27 -0800183 @staticmethod
184 def unpack(reader):
185 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800186 subclass = bsn.subtypes.get(subtype)
187 if subclass:
188 return subclass.unpack(reader)
189
190 obj = bsn()
191 _type = reader.read("!H")[0]
192 assert(_type == 65535)
193 _len = reader.read("!H")[0]
194 orig_reader = reader
195 reader = orig_reader.slice(_len - (2 + 2))
196 _experimenter = reader.read("!L")[0]
197 assert(_experimenter == 6035143)
198 obj.subtype = reader.read("!L")[0]
Rich Lane95f7fc92014-01-27 17:08:16 -0800199 return obj
200
201 def __eq__(self, other):
202 if type(self) != type(other): return False
203 if self.subtype != other.subtype: return False
204 return True
205
206 def pretty_print(self, q):
207 q.text("bsn {")
208 with q.group():
209 with q.indent(2):
210 q.breakable()
211 q.breakable()
212 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800213
214experimenter.subtypes[6035143] = bsn
215
Rich Lane5454b682014-01-14 17:07:36 -0800216class bsn_arp_offload(bsn):
217 type = 65535
218 experimenter = 6035143
219 subtype = 1
220
221 def __init__(self):
222 return
223
224 def pack(self):
225 packed = []
226 packed.append(struct.pack("!H", self.type))
227 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
228 packed.append(struct.pack("!L", self.experimenter))
229 packed.append(struct.pack("!L", self.subtype))
Rich Lane5454b682014-01-14 17:07:36 -0800230 length = sum([len(x) for x in packed])
231 packed[1] = struct.pack("!H", length)
232 return ''.join(packed)
233
234 @staticmethod
235 def unpack(reader):
236 obj = bsn_arp_offload()
237 _type = reader.read("!H")[0]
238 assert(_type == 65535)
239 _len = reader.read("!H")[0]
240 orig_reader = reader
241 reader = orig_reader.slice(_len - (2 + 2))
242 _experimenter = reader.read("!L")[0]
243 assert(_experimenter == 6035143)
244 _subtype = reader.read("!L")[0]
245 assert(_subtype == 1)
Rich Lane5454b682014-01-14 17:07:36 -0800246 return obj
247
248 def __eq__(self, other):
249 if type(self) != type(other): return False
250 return True
251
252 def pretty_print(self, q):
253 q.text("bsn_arp_offload {")
254 with q.group():
255 with q.indent(2):
256 q.breakable()
257 q.breakable()
258 q.text('}')
259
260bsn.subtypes[1] = bsn_arp_offload
261
Rich Lane9ec3fca2014-02-26 16:22:56 -0800262class bsn_deny(bsn):
263 type = 65535
264 experimenter = 6035143
265 subtype = 5
266
267 def __init__(self):
268 return
269
270 def pack(self):
271 packed = []
272 packed.append(struct.pack("!H", self.type))
273 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
274 packed.append(struct.pack("!L", self.experimenter))
275 packed.append(struct.pack("!L", self.subtype))
276 length = sum([len(x) for x in packed])
277 packed[1] = struct.pack("!H", length)
278 return ''.join(packed)
279
280 @staticmethod
281 def unpack(reader):
282 obj = bsn_deny()
283 _type = reader.read("!H")[0]
284 assert(_type == 65535)
285 _len = reader.read("!H")[0]
286 orig_reader = reader
287 reader = orig_reader.slice(_len - (2 + 2))
288 _experimenter = reader.read("!L")[0]
289 assert(_experimenter == 6035143)
290 _subtype = reader.read("!L")[0]
291 assert(_subtype == 5)
292 return obj
293
294 def __eq__(self, other):
295 if type(self) != type(other): return False
296 return True
297
298 def pretty_print(self, q):
299 q.text("bsn_deny {")
300 with q.group():
301 with q.indent(2):
302 q.breakable()
303 q.breakable()
304 q.text('}')
305
306bsn.subtypes[5] = bsn_deny
307
Rich Lane1b75abf2014-02-05 11:23:20 -0800308class bsn_dhcp_offload(bsn):
309 type = 65535
310 experimenter = 6035143
311 subtype = 2
312
313 def __init__(self):
314 return
315
316 def pack(self):
317 packed = []
318 packed.append(struct.pack("!H", self.type))
319 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
320 packed.append(struct.pack("!L", self.experimenter))
321 packed.append(struct.pack("!L", self.subtype))
Rich Lane1b75abf2014-02-05 11:23:20 -0800322 length = sum([len(x) for x in packed])
323 packed[1] = struct.pack("!H", length)
324 return ''.join(packed)
325
326 @staticmethod
327 def unpack(reader):
328 obj = bsn_dhcp_offload()
329 _type = reader.read("!H")[0]
330 assert(_type == 65535)
331 _len = reader.read("!H")[0]
332 orig_reader = reader
333 reader = orig_reader.slice(_len - (2 + 2))
334 _experimenter = reader.read("!L")[0]
335 assert(_experimenter == 6035143)
336 _subtype = reader.read("!L")[0]
337 assert(_subtype == 2)
Rich Lane1b75abf2014-02-05 11:23:20 -0800338 return obj
339
340 def __eq__(self, other):
341 if type(self) != type(other): return False
342 return True
343
344 def pretty_print(self, q):
345 q.text("bsn_dhcp_offload {")
346 with q.group():
347 with q.indent(2):
348 q.breakable()
349 q.breakable()
350 q.text('}')
351
352bsn.subtypes[2] = bsn_dhcp_offload
353
Rich Lane9ec3fca2014-02-26 16:22:56 -0800354class bsn_disable_split_horizon_check(bsn):
355 type = 65535
356 experimenter = 6035143
357 subtype = 3
358
359 def __init__(self):
360 return
361
362 def pack(self):
363 packed = []
364 packed.append(struct.pack("!H", self.type))
365 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
366 packed.append(struct.pack("!L", self.experimenter))
367 packed.append(struct.pack("!L", self.subtype))
368 length = sum([len(x) for x in packed])
369 packed[1] = struct.pack("!H", length)
370 return ''.join(packed)
371
372 @staticmethod
373 def unpack(reader):
374 obj = bsn_disable_split_horizon_check()
375 _type = reader.read("!H")[0]
376 assert(_type == 65535)
377 _len = reader.read("!H")[0]
378 orig_reader = reader
379 reader = orig_reader.slice(_len - (2 + 2))
380 _experimenter = reader.read("!L")[0]
381 assert(_experimenter == 6035143)
382 _subtype = reader.read("!L")[0]
383 assert(_subtype == 3)
384 return obj
385
386 def __eq__(self, other):
387 if type(self) != type(other): return False
388 return True
389
390 def pretty_print(self, q):
391 q.text("bsn_disable_split_horizon_check {")
392 with q.group():
393 with q.indent(2):
394 q.breakable()
395 q.breakable()
396 q.text('}')
397
398bsn.subtypes[3] = bsn_disable_split_horizon_check
399
Rich Lane7dcdf022013-12-11 14:45:27 -0800400class bsn_disable_src_mac_check(bsn):
401 type = 65535
402 experimenter = 6035143
403 subtype = 0
404
405 def __init__(self):
406 return
407
408 def pack(self):
409 packed = []
410 packed.append(struct.pack("!H", self.type))
411 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
412 packed.append(struct.pack("!L", self.experimenter))
413 packed.append(struct.pack("!L", self.subtype))
Rich Lane7dcdf022013-12-11 14:45:27 -0800414 length = sum([len(x) for x in packed])
415 packed[1] = struct.pack("!H", length)
416 return ''.join(packed)
417
418 @staticmethod
419 def unpack(reader):
420 obj = bsn_disable_src_mac_check()
421 _type = reader.read("!H")[0]
422 assert(_type == 65535)
423 _len = reader.read("!H")[0]
424 orig_reader = reader
425 reader = orig_reader.slice(_len - (2 + 2))
426 _experimenter = reader.read("!L")[0]
427 assert(_experimenter == 6035143)
428 _subtype = reader.read("!L")[0]
429 assert(_subtype == 0)
Rich Lane7dcdf022013-12-11 14:45:27 -0800430 return obj
431
432 def __eq__(self, other):
433 if type(self) != type(other): return False
434 return True
435
436 def pretty_print(self, q):
437 q.text("bsn_disable_src_mac_check {")
438 with q.group():
439 with q.indent(2):
440 q.breakable()
441 q.breakable()
442 q.text('}')
443
444bsn.subtypes[0] = bsn_disable_src_mac_check
445
Rich Lanef50b7c32014-03-20 11:38:02 -0700446class bsn_packet_of_death(bsn):
447 type = 65535
448 experimenter = 6035143
449 subtype = 6
450
451 def __init__(self):
452 return
453
454 def pack(self):
455 packed = []
456 packed.append(struct.pack("!H", self.type))
457 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
458 packed.append(struct.pack("!L", self.experimenter))
459 packed.append(struct.pack("!L", self.subtype))
460 length = sum([len(x) for x in packed])
461 packed[1] = struct.pack("!H", length)
462 return ''.join(packed)
463
464 @staticmethod
465 def unpack(reader):
466 obj = bsn_packet_of_death()
467 _type = reader.read("!H")[0]
468 assert(_type == 65535)
469 _len = reader.read("!H")[0]
470 orig_reader = reader
471 reader = orig_reader.slice(_len - (2 + 2))
472 _experimenter = reader.read("!L")[0]
473 assert(_experimenter == 6035143)
474 _subtype = reader.read("!L")[0]
475 assert(_subtype == 6)
476 return obj
477
478 def __eq__(self, other):
479 if type(self) != type(other): return False
480 return True
481
482 def pretty_print(self, q):
483 q.text("bsn_packet_of_death {")
484 with q.group():
485 with q.indent(2):
486 q.breakable()
487 q.breakable()
488 q.text('}')
489
490bsn.subtypes[6] = bsn_packet_of_death
491
Rich Lane9ec3fca2014-02-26 16:22:56 -0800492class bsn_permit(bsn):
493 type = 65535
494 experimenter = 6035143
495 subtype = 4
496
497 def __init__(self):
498 return
499
500 def pack(self):
501 packed = []
502 packed.append(struct.pack("!H", self.type))
503 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
504 packed.append(struct.pack("!L", self.experimenter))
505 packed.append(struct.pack("!L", self.subtype))
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 = bsn_permit()
513 _type = reader.read("!H")[0]
514 assert(_type == 65535)
515 _len = reader.read("!H")[0]
516 orig_reader = reader
517 reader = orig_reader.slice(_len - (2 + 2))
518 _experimenter = reader.read("!L")[0]
519 assert(_experimenter == 6035143)
520 _subtype = reader.read("!L")[0]
521 assert(_subtype == 4)
522 return obj
523
524 def __eq__(self, other):
525 if type(self) != type(other): return False
526 return True
527
528 def pretty_print(self, q):
529 q.text("bsn_permit {")
530 with q.group():
531 with q.indent(2):
532 q.breakable()
533 q.breakable()
534 q.text('}')
535
536bsn.subtypes[4] = bsn_permit
537
Rich Lane7dcdf022013-12-11 14:45:27 -0800538class clear_actions(instruction_id):
539 type = 5
540
541 def __init__(self):
542 return
543
544 def pack(self):
545 packed = []
546 packed.append(struct.pack("!H", self.type))
547 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -0800548 length = sum([len(x) for x in packed])
549 packed[1] = struct.pack("!H", length)
550 return ''.join(packed)
551
552 @staticmethod
553 def unpack(reader):
554 obj = clear_actions()
555 _type = reader.read("!H")[0]
556 assert(_type == 5)
557 _len = reader.read("!H")[0]
558 orig_reader = reader
559 reader = orig_reader.slice(_len - (2 + 2))
Rich Lane7dcdf022013-12-11 14:45:27 -0800560 return obj
561
562 def __eq__(self, other):
563 if type(self) != type(other): return False
564 return True
565
566 def pretty_print(self, q):
567 q.text("clear_actions {")
568 with q.group():
569 with q.indent(2):
570 q.breakable()
571 q.breakable()
572 q.text('}')
573
574instruction_id.subtypes[5] = clear_actions
575
576class goto_table(instruction_id):
577 type = 1
578
579 def __init__(self):
580 return
581
582 def pack(self):
583 packed = []
584 packed.append(struct.pack("!H", self.type))
585 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -0800586 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 = goto_table()
593 _type = reader.read("!H")[0]
594 assert(_type == 1)
595 _len = reader.read("!H")[0]
596 orig_reader = reader
597 reader = orig_reader.slice(_len - (2 + 2))
Rich Lane7dcdf022013-12-11 14:45:27 -0800598 return obj
599
600 def __eq__(self, other):
601 if type(self) != type(other): return False
602 return True
603
604 def pretty_print(self, q):
605 q.text("goto_table {")
606 with q.group():
607 with q.indent(2):
608 q.breakable()
609 q.breakable()
610 q.text('}')
611
612instruction_id.subtypes[1] = goto_table
613
614class meter(instruction_id):
615 type = 6
616
617 def __init__(self):
618 return
619
620 def pack(self):
621 packed = []
622 packed.append(struct.pack("!H", self.type))
623 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
624 length = sum([len(x) for x in packed])
625 packed[1] = struct.pack("!H", length)
626 return ''.join(packed)
627
628 @staticmethod
629 def unpack(reader):
630 obj = meter()
631 _type = reader.read("!H")[0]
632 assert(_type == 6)
633 _len = reader.read("!H")[0]
634 orig_reader = reader
635 reader = orig_reader.slice(_len - (2 + 2))
636 return obj
637
638 def __eq__(self, other):
639 if type(self) != type(other): return False
640 return True
641
642 def pretty_print(self, q):
643 q.text("meter {")
644 with q.group():
645 with q.indent(2):
646 q.breakable()
647 q.breakable()
648 q.text('}')
649
650instruction_id.subtypes[6] = meter
651
652class write_actions(instruction_id):
653 type = 3
654
655 def __init__(self):
656 return
657
658 def pack(self):
659 packed = []
660 packed.append(struct.pack("!H", self.type))
661 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -0800662 length = sum([len(x) for x in packed])
663 packed[1] = struct.pack("!H", length)
664 return ''.join(packed)
665
666 @staticmethod
667 def unpack(reader):
668 obj = write_actions()
669 _type = reader.read("!H")[0]
670 assert(_type == 3)
671 _len = reader.read("!H")[0]
672 orig_reader = reader
673 reader = orig_reader.slice(_len - (2 + 2))
Rich Lane7dcdf022013-12-11 14:45:27 -0800674 return obj
675
676 def __eq__(self, other):
677 if type(self) != type(other): return False
678 return True
679
680 def pretty_print(self, q):
681 q.text("write_actions {")
682 with q.group():
683 with q.indent(2):
684 q.breakable()
685 q.breakable()
686 q.text('}')
687
688instruction_id.subtypes[3] = write_actions
689
690class write_metadata(instruction_id):
691 type = 2
692
693 def __init__(self):
694 return
695
696 def pack(self):
697 packed = []
698 packed.append(struct.pack("!H", self.type))
699 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -0800700 length = sum([len(x) for x in packed])
701 packed[1] = struct.pack("!H", length)
702 return ''.join(packed)
703
704 @staticmethod
705 def unpack(reader):
706 obj = write_metadata()
707 _type = reader.read("!H")[0]
708 assert(_type == 2)
709 _len = reader.read("!H")[0]
710 orig_reader = reader
711 reader = orig_reader.slice(_len - (2 + 2))
Rich Lane7dcdf022013-12-11 14:45:27 -0800712 return obj
713
714 def __eq__(self, other):
715 if type(self) != type(other): return False
716 return True
717
718 def pretty_print(self, q):
719 q.text("write_metadata {")
720 with q.group():
721 with q.indent(2):
722 q.breakable()
723 q.breakable()
724 q.text('}')
725
726instruction_id.subtypes[2] = write_metadata
727
728