blob: cdc35fe55378303dadfe48c149cdeaa6ed7ba4f8 [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 Lane78d9bcb2014-05-12 13:27:44 -0700538class bsn_prioritize_pdus(bsn):
539 type = 65535
540 experimenter = 6035143
541 subtype = 7
542
543 def __init__(self):
544 return
545
546 def pack(self):
547 packed = []
548 packed.append(struct.pack("!H", self.type))
549 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
550 packed.append(struct.pack("!L", self.experimenter))
551 packed.append(struct.pack("!L", self.subtype))
552 length = sum([len(x) for x in packed])
553 packed[1] = struct.pack("!H", length)
554 return ''.join(packed)
555
556 @staticmethod
557 def unpack(reader):
558 obj = bsn_prioritize_pdus()
559 _type = reader.read("!H")[0]
560 assert(_type == 65535)
561 _len = reader.read("!H")[0]
562 orig_reader = reader
563 reader = orig_reader.slice(_len - (2 + 2))
564 _experimenter = reader.read("!L")[0]
565 assert(_experimenter == 6035143)
566 _subtype = reader.read("!L")[0]
567 assert(_subtype == 7)
568 return obj
569
570 def __eq__(self, other):
571 if type(self) != type(other): return False
572 return True
573
574 def pretty_print(self, q):
575 q.text("bsn_prioritize_pdus {")
576 with q.group():
577 with q.indent(2):
578 q.breakable()
579 q.breakable()
580 q.text('}')
581
582bsn.subtypes[7] = bsn_prioritize_pdus
583
Rich Lane5587ab12014-06-30 11:19:09 -0700584class bsn_require_vlan_xlate(bsn):
585 type = 65535
586 experimenter = 6035143
587 subtype = 8
588
589 def __init__(self):
590 return
591
592 def pack(self):
593 packed = []
594 packed.append(struct.pack("!H", self.type))
595 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
596 packed.append(struct.pack("!L", self.experimenter))
597 packed.append(struct.pack("!L", self.subtype))
598 length = sum([len(x) for x in packed])
599 packed[1] = struct.pack("!H", length)
600 return ''.join(packed)
601
602 @staticmethod
603 def unpack(reader):
604 obj = bsn_require_vlan_xlate()
605 _type = reader.read("!H")[0]
606 assert(_type == 65535)
607 _len = reader.read("!H")[0]
608 orig_reader = reader
609 reader = orig_reader.slice(_len - (2 + 2))
610 _experimenter = reader.read("!L")[0]
611 assert(_experimenter == 6035143)
612 _subtype = reader.read("!L")[0]
613 assert(_subtype == 8)
614 return obj
615
616 def __eq__(self, other):
617 if type(self) != type(other): return False
618 return True
619
620 def pretty_print(self, q):
621 q.text("bsn_require_vlan_xlate {")
622 with q.group():
623 with q.indent(2):
624 q.breakable()
625 q.breakable()
626 q.text('}')
627
628bsn.subtypes[8] = bsn_require_vlan_xlate
629
Rich Lane7dcdf022013-12-11 14:45:27 -0800630class clear_actions(instruction_id):
631 type = 5
632
633 def __init__(self):
634 return
635
636 def pack(self):
637 packed = []
638 packed.append(struct.pack("!H", self.type))
639 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -0800640 length = sum([len(x) for x in packed])
641 packed[1] = struct.pack("!H", length)
642 return ''.join(packed)
643
644 @staticmethod
645 def unpack(reader):
646 obj = clear_actions()
647 _type = reader.read("!H")[0]
648 assert(_type == 5)
649 _len = reader.read("!H")[0]
650 orig_reader = reader
651 reader = orig_reader.slice(_len - (2 + 2))
Rich Lane7dcdf022013-12-11 14:45:27 -0800652 return obj
653
654 def __eq__(self, other):
655 if type(self) != type(other): return False
656 return True
657
658 def pretty_print(self, q):
659 q.text("clear_actions {")
660 with q.group():
661 with q.indent(2):
662 q.breakable()
663 q.breakable()
664 q.text('}')
665
666instruction_id.subtypes[5] = clear_actions
667
668class goto_table(instruction_id):
669 type = 1
670
671 def __init__(self):
672 return
673
674 def pack(self):
675 packed = []
676 packed.append(struct.pack("!H", self.type))
677 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -0800678 length = sum([len(x) for x in packed])
679 packed[1] = struct.pack("!H", length)
680 return ''.join(packed)
681
682 @staticmethod
683 def unpack(reader):
684 obj = goto_table()
685 _type = reader.read("!H")[0]
686 assert(_type == 1)
687 _len = reader.read("!H")[0]
688 orig_reader = reader
689 reader = orig_reader.slice(_len - (2 + 2))
Rich Lane7dcdf022013-12-11 14:45:27 -0800690 return obj
691
692 def __eq__(self, other):
693 if type(self) != type(other): return False
694 return True
695
696 def pretty_print(self, q):
697 q.text("goto_table {")
698 with q.group():
699 with q.indent(2):
700 q.breakable()
701 q.breakable()
702 q.text('}')
703
704instruction_id.subtypes[1] = goto_table
705
706class meter(instruction_id):
707 type = 6
708
709 def __init__(self):
710 return
711
712 def pack(self):
713 packed = []
714 packed.append(struct.pack("!H", self.type))
715 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
716 length = sum([len(x) for x in packed])
717 packed[1] = struct.pack("!H", length)
718 return ''.join(packed)
719
720 @staticmethod
721 def unpack(reader):
722 obj = meter()
723 _type = reader.read("!H")[0]
724 assert(_type == 6)
725 _len = reader.read("!H")[0]
726 orig_reader = reader
727 reader = orig_reader.slice(_len - (2 + 2))
728 return obj
729
730 def __eq__(self, other):
731 if type(self) != type(other): return False
732 return True
733
734 def pretty_print(self, q):
735 q.text("meter {")
736 with q.group():
737 with q.indent(2):
738 q.breakable()
739 q.breakable()
740 q.text('}')
741
742instruction_id.subtypes[6] = meter
743
744class write_actions(instruction_id):
745 type = 3
746
747 def __init__(self):
748 return
749
750 def pack(self):
751 packed = []
752 packed.append(struct.pack("!H", self.type))
753 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -0800754 length = sum([len(x) for x in packed])
755 packed[1] = struct.pack("!H", length)
756 return ''.join(packed)
757
758 @staticmethod
759 def unpack(reader):
760 obj = write_actions()
761 _type = reader.read("!H")[0]
762 assert(_type == 3)
763 _len = reader.read("!H")[0]
764 orig_reader = reader
765 reader = orig_reader.slice(_len - (2 + 2))
Rich Lane7dcdf022013-12-11 14:45:27 -0800766 return obj
767
768 def __eq__(self, other):
769 if type(self) != type(other): return False
770 return True
771
772 def pretty_print(self, q):
773 q.text("write_actions {")
774 with q.group():
775 with q.indent(2):
776 q.breakable()
777 q.breakable()
778 q.text('}')
779
780instruction_id.subtypes[3] = write_actions
781
782class write_metadata(instruction_id):
783 type = 2
784
785 def __init__(self):
786 return
787
788 def pack(self):
789 packed = []
790 packed.append(struct.pack("!H", self.type))
791 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -0800792 length = sum([len(x) for x in packed])
793 packed[1] = struct.pack("!H", length)
794 return ''.join(packed)
795
796 @staticmethod
797 def unpack(reader):
798 obj = write_metadata()
799 _type = reader.read("!H")[0]
800 assert(_type == 2)
801 _len = reader.read("!H")[0]
802 orig_reader = reader
803 reader = orig_reader.slice(_len - (2 + 2))
Rich Lane7dcdf022013-12-11 14:45:27 -0800804 return obj
805
806 def __eq__(self, other):
807 if type(self) != type(other): return False
808 return True
809
810 def pretty_print(self, q):
811 q.text("write_metadata {")
812 with q.group():
813 with q.indent(2):
814 q.breakable()
815 q.breakable()
816 q.text('}')
817
818instruction_id.subtypes[2] = write_metadata
819
820