blob: 670d7ec5ab6ae1d209d277a21862626127058d46 [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 instruction(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 length = sum([len(x) for x in packed])
33 packed[1] = struct.pack("!H", length)
34 return ''.join(packed)
35
36 @staticmethod
37 def unpack(reader):
38 subtype, = reader.peek('!H', 0)
39 subclass = instruction.subtypes.get(subtype)
40 if subclass:
41 return subclass.unpack(reader)
42
43 obj = instruction()
44 obj.type = reader.read("!H")[0]
45 _len = reader.read("!H")[0]
46 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -080047 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -070048 return obj
49
50 def __eq__(self, other):
51 if type(self) != type(other): return False
52 if self.type != other.type: return False
53 return True
54
55 def pretty_print(self, q):
56 q.text("instruction {")
57 with q.group():
58 with q.indent(2):
59 q.breakable()
60 q.breakable()
61 q.text('}')
62
63
64class apply_actions(instruction):
65 type = 4
66
67 def __init__(self, actions=None):
68 if actions != None:
69 self.actions = actions
70 else:
71 self.actions = []
72 return
73
74 def pack(self):
75 packed = []
76 packed.append(struct.pack("!H", self.type))
77 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
78 packed.append('\x00' * 4)
79 packed.append(loxi.generic_util.pack_list(self.actions))
80 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
Rich Lanecb18dbd2014-12-18 10:02:29 -080091 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -070092 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -080093 obj.actions = loxi.generic_util.unpack_list(reader, ofp.action.action.unpack)
Rich Lane2e079da2014-10-29 15:30:24 -070094 return obj
95
96 def __eq__(self, other):
97 if type(self) != type(other): return False
98 if self.actions != other.actions: return False
99 return True
100
101 def pretty_print(self, q):
102 q.text("apply_actions {")
103 with q.group():
104 with q.indent(2):
105 q.breakable()
106 q.text("actions = ");
107 q.pp(self.actions)
108 q.breakable()
109 q.text('}')
110
111instruction.subtypes[4] = apply_actions
112
Rich Lane2e079da2014-10-29 15:30:24 -0700113class experimenter(instruction):
114 subtypes = {}
115
116 type = 65535
117
118 def __init__(self, experimenter=None, data=None):
119 if experimenter != None:
120 self.experimenter = experimenter
121 else:
122 self.experimenter = 0
123 if data != None:
124 self.data = data
125 else:
126 self.data = ''
127 return
128
129 def pack(self):
130 packed = []
131 packed.append(struct.pack("!H", self.type))
132 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
133 packed.append(struct.pack("!L", self.experimenter))
134 packed.append(self.data)
135 length = sum([len(x) for x in packed])
136 packed[1] = struct.pack("!H", length)
137 return ''.join(packed)
138
139 @staticmethod
140 def unpack(reader):
141 subtype, = reader.peek('!L', 4)
142 subclass = experimenter.subtypes.get(subtype)
143 if subclass:
144 return subclass.unpack(reader)
145
146 obj = experimenter()
147 _type = reader.read("!H")[0]
148 assert(_type == 65535)
149 _len = reader.read("!H")[0]
150 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800151 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700152 obj.experimenter = reader.read("!L")[0]
153 obj.data = str(reader.read_all())
154 return obj
155
156 def __eq__(self, other):
157 if type(self) != type(other): return False
158 if self.experimenter != other.experimenter: return False
159 if self.data != other.data: return False
160 return True
161
162 def pretty_print(self, q):
163 q.text("experimenter {")
164 with q.group():
165 with q.indent(2):
166 q.breakable()
167 q.text("data = ");
168 q.pp(self.data)
169 q.breakable()
170 q.text('}')
171
172instruction.subtypes[65535] = experimenter
173
Rich Laneccd32ed2014-11-10 17:48:24 -0800174class bsn(experimenter):
175 subtypes = {}
176
177 type = 65535
178 experimenter = 6035143
179
180 def __init__(self, subtype=None):
181 if subtype != None:
182 self.subtype = subtype
183 else:
184 self.subtype = 0
185 return
186
187 def pack(self):
188 packed = []
189 packed.append(struct.pack("!H", self.type))
190 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
191 packed.append(struct.pack("!L", self.experimenter))
192 packed.append(struct.pack("!L", self.subtype))
193 packed.append('\x00' * 4)
194 length = sum([len(x) for x in packed])
195 packed[1] = struct.pack("!H", length)
196 return ''.join(packed)
197
198 @staticmethod
199 def unpack(reader):
200 subtype, = reader.peek('!L', 8)
201 subclass = bsn.subtypes.get(subtype)
202 if subclass:
203 return subclass.unpack(reader)
204
205 obj = bsn()
206 _type = reader.read("!H")[0]
207 assert(_type == 65535)
208 _len = reader.read("!H")[0]
209 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800210 reader = orig_reader.slice(_len, 4)
Rich Laneccd32ed2014-11-10 17:48:24 -0800211 _experimenter = reader.read("!L")[0]
212 assert(_experimenter == 6035143)
213 obj.subtype = reader.read("!L")[0]
214 reader.skip(4)
215 return obj
216
217 def __eq__(self, other):
218 if type(self) != type(other): return False
219 if self.subtype != other.subtype: return False
220 return True
221
222 def pretty_print(self, q):
223 q.text("bsn {")
224 with q.group():
225 with q.indent(2):
226 q.breakable()
227 q.breakable()
228 q.text('}')
229
230experimenter.subtypes[6035143] = bsn
231
232class bsn_arp_offload(bsn):
233 type = 65535
234 experimenter = 6035143
235 subtype = 1
236
237 def __init__(self):
238 return
239
240 def pack(self):
241 packed = []
242 packed.append(struct.pack("!H", self.type))
243 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
244 packed.append(struct.pack("!L", self.experimenter))
245 packed.append(struct.pack("!L", self.subtype))
246 packed.append('\x00' * 4)
247 length = sum([len(x) for x in packed])
248 packed[1] = struct.pack("!H", length)
249 return ''.join(packed)
250
251 @staticmethod
252 def unpack(reader):
253 obj = bsn_arp_offload()
254 _type = reader.read("!H")[0]
255 assert(_type == 65535)
256 _len = reader.read("!H")[0]
257 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800258 reader = orig_reader.slice(_len, 4)
Rich Laneccd32ed2014-11-10 17:48:24 -0800259 _experimenter = reader.read("!L")[0]
260 assert(_experimenter == 6035143)
261 _subtype = reader.read("!L")[0]
262 assert(_subtype == 1)
263 reader.skip(4)
264 return obj
265
266 def __eq__(self, other):
267 if type(self) != type(other): return False
268 return True
269
270 def pretty_print(self, q):
271 q.text("bsn_arp_offload {")
272 with q.group():
273 with q.indent(2):
274 q.breakable()
275 q.breakable()
276 q.text('}')
277
278bsn.subtypes[1] = bsn_arp_offload
279
Harshmeet Singh301f7172014-12-08 13:07:29 -0800280class bsn_auto_negotiation(bsn):
281 type = 65535
282 experimenter = 6035143
283 subtype = 11
284
285 def __init__(self):
286 return
287
288 def pack(self):
289 packed = []
290 packed.append(struct.pack("!H", self.type))
291 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
292 packed.append(struct.pack("!L", self.experimenter))
293 packed.append(struct.pack("!L", self.subtype))
294 packed.append('\x00' * 4)
295 length = sum([len(x) for x in packed])
296 packed[1] = struct.pack("!H", length)
297 return ''.join(packed)
298
299 @staticmethod
300 def unpack(reader):
301 obj = bsn_auto_negotiation()
302 _type = reader.read("!H")[0]
303 assert(_type == 65535)
304 _len = reader.read("!H")[0]
305 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800306 reader = orig_reader.slice(_len, 4)
Harshmeet Singh301f7172014-12-08 13:07:29 -0800307 _experimenter = reader.read("!L")[0]
308 assert(_experimenter == 6035143)
309 _subtype = reader.read("!L")[0]
310 assert(_subtype == 11)
311 reader.skip(4)
312 return obj
313
314 def __eq__(self, other):
315 if type(self) != type(other): return False
316 return True
317
318 def pretty_print(self, q):
319 q.text("bsn_auto_negotiation {")
320 with q.group():
321 with q.indent(2):
322 q.breakable()
323 q.breakable()
324 q.text('}')
325
326bsn.subtypes[11] = bsn_auto_negotiation
327
Rich Laneccd32ed2014-11-10 17:48:24 -0800328class bsn_deny(bsn):
329 type = 65535
330 experimenter = 6035143
331 subtype = 5
332
333 def __init__(self):
334 return
335
336 def pack(self):
337 packed = []
338 packed.append(struct.pack("!H", self.type))
339 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
340 packed.append(struct.pack("!L", self.experimenter))
341 packed.append(struct.pack("!L", self.subtype))
342 packed.append('\x00' * 4)
343 length = sum([len(x) for x in packed])
344 packed[1] = struct.pack("!H", length)
345 return ''.join(packed)
346
347 @staticmethod
348 def unpack(reader):
349 obj = bsn_deny()
350 _type = reader.read("!H")[0]
351 assert(_type == 65535)
352 _len = reader.read("!H")[0]
353 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800354 reader = orig_reader.slice(_len, 4)
Rich Laneccd32ed2014-11-10 17:48:24 -0800355 _experimenter = reader.read("!L")[0]
356 assert(_experimenter == 6035143)
357 _subtype = reader.read("!L")[0]
358 assert(_subtype == 5)
359 reader.skip(4)
360 return obj
361
362 def __eq__(self, other):
363 if type(self) != type(other): return False
364 return True
365
366 def pretty_print(self, q):
367 q.text("bsn_deny {")
368 with q.group():
369 with q.indent(2):
370 q.breakable()
371 q.breakable()
372 q.text('}')
373
374bsn.subtypes[5] = bsn_deny
375
376class bsn_dhcp_offload(bsn):
377 type = 65535
378 experimenter = 6035143
379 subtype = 2
380
381 def __init__(self):
382 return
383
384 def pack(self):
385 packed = []
386 packed.append(struct.pack("!H", self.type))
387 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
388 packed.append(struct.pack("!L", self.experimenter))
389 packed.append(struct.pack("!L", self.subtype))
390 packed.append('\x00' * 4)
391 length = sum([len(x) for x in packed])
392 packed[1] = struct.pack("!H", length)
393 return ''.join(packed)
394
395 @staticmethod
396 def unpack(reader):
397 obj = bsn_dhcp_offload()
398 _type = reader.read("!H")[0]
399 assert(_type == 65535)
400 _len = reader.read("!H")[0]
401 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800402 reader = orig_reader.slice(_len, 4)
Rich Laneccd32ed2014-11-10 17:48:24 -0800403 _experimenter = reader.read("!L")[0]
404 assert(_experimenter == 6035143)
405 _subtype = reader.read("!L")[0]
406 assert(_subtype == 2)
407 reader.skip(4)
408 return obj
409
410 def __eq__(self, other):
411 if type(self) != type(other): return False
412 return True
413
414 def pretty_print(self, q):
415 q.text("bsn_dhcp_offload {")
416 with q.group():
417 with q.indent(2):
418 q.breakable()
419 q.breakable()
420 q.text('}')
421
422bsn.subtypes[2] = bsn_dhcp_offload
423
424class bsn_disable_src_mac_check(bsn):
425 type = 65535
426 experimenter = 6035143
427 subtype = 0
428
429 def __init__(self):
430 return
431
432 def pack(self):
433 packed = []
434 packed.append(struct.pack("!H", self.type))
435 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
436 packed.append(struct.pack("!L", self.experimenter))
437 packed.append(struct.pack("!L", self.subtype))
438 packed.append('\x00' * 4)
439 length = sum([len(x) for x in packed])
440 packed[1] = struct.pack("!H", length)
441 return ''.join(packed)
442
443 @staticmethod
444 def unpack(reader):
445 obj = bsn_disable_src_mac_check()
446 _type = reader.read("!H")[0]
447 assert(_type == 65535)
448 _len = reader.read("!H")[0]
449 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800450 reader = orig_reader.slice(_len, 4)
Rich Laneccd32ed2014-11-10 17:48:24 -0800451 _experimenter = reader.read("!L")[0]
452 assert(_experimenter == 6035143)
453 _subtype = reader.read("!L")[0]
454 assert(_subtype == 0)
455 reader.skip(4)
456 return obj
457
458 def __eq__(self, other):
459 if type(self) != type(other): return False
460 return True
461
462 def pretty_print(self, q):
463 q.text("bsn_disable_src_mac_check {")
464 with q.group():
465 with q.indent(2):
466 q.breakable()
467 q.breakable()
468 q.text('}')
469
470bsn.subtypes[0] = bsn_disable_src_mac_check
471
472class bsn_disable_vlan_counters(bsn):
473 type = 65535
474 experimenter = 6035143
475 subtype = 9
476
477 def __init__(self):
478 return
479
480 def pack(self):
481 packed = []
482 packed.append(struct.pack("!H", self.type))
483 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
484 packed.append(struct.pack("!L", self.experimenter))
485 packed.append(struct.pack("!L", self.subtype))
486 packed.append('\x00' * 4)
487 length = sum([len(x) for x in packed])
488 packed[1] = struct.pack("!H", length)
489 return ''.join(packed)
490
491 @staticmethod
492 def unpack(reader):
493 obj = bsn_disable_vlan_counters()
494 _type = reader.read("!H")[0]
495 assert(_type == 65535)
496 _len = reader.read("!H")[0]
497 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800498 reader = orig_reader.slice(_len, 4)
Rich Laneccd32ed2014-11-10 17:48:24 -0800499 _experimenter = reader.read("!L")[0]
500 assert(_experimenter == 6035143)
501 _subtype = reader.read("!L")[0]
502 assert(_subtype == 9)
503 reader.skip(4)
504 return obj
505
506 def __eq__(self, other):
507 if type(self) != type(other): return False
508 return True
509
510 def pretty_print(self, q):
511 q.text("bsn_disable_vlan_counters {")
512 with q.group():
513 with q.indent(2):
514 q.breakable()
515 q.breakable()
516 q.text('}')
517
518bsn.subtypes[9] = bsn_disable_vlan_counters
519
Rich Lane7b69e792015-03-31 11:12:50 -0700520class bsn_internal_priority(bsn):
521 type = 65535
522 experimenter = 6035143
523 subtype = 12
524
525 def __init__(self, value=None):
526 if value != None:
527 self.value = value
528 else:
529 self.value = 0
530 return
531
532 def pack(self):
533 packed = []
534 packed.append(struct.pack("!H", self.type))
535 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
536 packed.append(struct.pack("!L", self.experimenter))
537 packed.append(struct.pack("!L", self.subtype))
538 packed.append(struct.pack("!L", self.value))
539 length = sum([len(x) for x in packed])
540 packed[1] = struct.pack("!H", length)
541 return ''.join(packed)
542
543 @staticmethod
544 def unpack(reader):
545 obj = bsn_internal_priority()
546 _type = reader.read("!H")[0]
547 assert(_type == 65535)
548 _len = reader.read("!H")[0]
549 orig_reader = reader
550 reader = orig_reader.slice(_len, 4)
551 _experimenter = reader.read("!L")[0]
552 assert(_experimenter == 6035143)
553 _subtype = reader.read("!L")[0]
554 assert(_subtype == 12)
555 obj.value = reader.read("!L")[0]
556 return obj
557
558 def __eq__(self, other):
559 if type(self) != type(other): return False
560 if self.value != other.value: return False
561 return True
562
563 def pretty_print(self, q):
564 q.text("bsn_internal_priority {")
565 with q.group():
566 with q.indent(2):
567 q.breakable()
568 q.text("value = ");
569 q.text("%#x" % self.value)
570 q.breakable()
571 q.text('}')
572
573bsn.subtypes[12] = bsn_internal_priority
574
Rich Laneccd32ed2014-11-10 17:48:24 -0800575class bsn_packet_of_death(bsn):
576 type = 65535
577 experimenter = 6035143
578 subtype = 6
579
580 def __init__(self):
581 return
582
583 def pack(self):
584 packed = []
585 packed.append(struct.pack("!H", self.type))
586 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
587 packed.append(struct.pack("!L", self.experimenter))
588 packed.append(struct.pack("!L", self.subtype))
589 packed.append('\x00' * 4)
590 length = sum([len(x) for x in packed])
591 packed[1] = struct.pack("!H", length)
592 return ''.join(packed)
593
594 @staticmethod
595 def unpack(reader):
596 obj = bsn_packet_of_death()
597 _type = reader.read("!H")[0]
598 assert(_type == 65535)
599 _len = reader.read("!H")[0]
600 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800601 reader = orig_reader.slice(_len, 4)
Rich Laneccd32ed2014-11-10 17:48:24 -0800602 _experimenter = reader.read("!L")[0]
603 assert(_experimenter == 6035143)
604 _subtype = reader.read("!L")[0]
605 assert(_subtype == 6)
606 reader.skip(4)
607 return obj
608
609 def __eq__(self, other):
610 if type(self) != type(other): return False
611 return True
612
613 def pretty_print(self, q):
614 q.text("bsn_packet_of_death {")
615 with q.group():
616 with q.indent(2):
617 q.breakable()
618 q.breakable()
619 q.text('}')
620
621bsn.subtypes[6] = bsn_packet_of_death
622
623class bsn_permit(bsn):
624 type = 65535
625 experimenter = 6035143
626 subtype = 4
627
628 def __init__(self):
629 return
630
631 def pack(self):
632 packed = []
633 packed.append(struct.pack("!H", self.type))
634 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
635 packed.append(struct.pack("!L", self.experimenter))
636 packed.append(struct.pack("!L", self.subtype))
637 packed.append('\x00' * 4)
638 length = sum([len(x) for x in packed])
639 packed[1] = struct.pack("!H", length)
640 return ''.join(packed)
641
642 @staticmethod
643 def unpack(reader):
644 obj = bsn_permit()
645 _type = reader.read("!H")[0]
646 assert(_type == 65535)
647 _len = reader.read("!H")[0]
648 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800649 reader = orig_reader.slice(_len, 4)
Rich Laneccd32ed2014-11-10 17:48:24 -0800650 _experimenter = reader.read("!L")[0]
651 assert(_experimenter == 6035143)
652 _subtype = reader.read("!L")[0]
653 assert(_subtype == 4)
654 reader.skip(4)
655 return obj
656
657 def __eq__(self, other):
658 if type(self) != type(other): return False
659 return True
660
661 def pretty_print(self, q):
662 q.text("bsn_permit {")
663 with q.group():
664 with q.indent(2):
665 q.breakable()
666 q.breakable()
667 q.text('}')
668
669bsn.subtypes[4] = bsn_permit
670
671class bsn_prioritize_pdus(bsn):
672 type = 65535
673 experimenter = 6035143
674 subtype = 7
675
676 def __init__(self):
677 return
678
679 def pack(self):
680 packed = []
681 packed.append(struct.pack("!H", self.type))
682 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
683 packed.append(struct.pack("!L", self.experimenter))
684 packed.append(struct.pack("!L", self.subtype))
685 packed.append('\x00' * 4)
686 length = sum([len(x) for x in packed])
687 packed[1] = struct.pack("!H", length)
688 return ''.join(packed)
689
690 @staticmethod
691 def unpack(reader):
692 obj = bsn_prioritize_pdus()
693 _type = reader.read("!H")[0]
694 assert(_type == 65535)
695 _len = reader.read("!H")[0]
696 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800697 reader = orig_reader.slice(_len, 4)
Rich Laneccd32ed2014-11-10 17:48:24 -0800698 _experimenter = reader.read("!L")[0]
699 assert(_experimenter == 6035143)
700 _subtype = reader.read("!L")[0]
701 assert(_subtype == 7)
702 reader.skip(4)
703 return obj
704
705 def __eq__(self, other):
706 if type(self) != type(other): return False
707 return True
708
709 def pretty_print(self, q):
710 q.text("bsn_prioritize_pdus {")
711 with q.group():
712 with q.indent(2):
713 q.breakable()
714 q.breakable()
715 q.text('}')
716
717bsn.subtypes[7] = bsn_prioritize_pdus
718
719class bsn_require_vlan_xlate(bsn):
720 type = 65535
721 experimenter = 6035143
722 subtype = 8
723
724 def __init__(self):
725 return
726
727 def pack(self):
728 packed = []
729 packed.append(struct.pack("!H", self.type))
730 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
731 packed.append(struct.pack("!L", self.experimenter))
732 packed.append(struct.pack("!L", self.subtype))
733 packed.append('\x00' * 4)
734 length = sum([len(x) for x in packed])
735 packed[1] = struct.pack("!H", length)
736 return ''.join(packed)
737
738 @staticmethod
739 def unpack(reader):
740 obj = bsn_require_vlan_xlate()
741 _type = reader.read("!H")[0]
742 assert(_type == 65535)
743 _len = reader.read("!H")[0]
744 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800745 reader = orig_reader.slice(_len, 4)
Rich Laneccd32ed2014-11-10 17:48:24 -0800746 _experimenter = reader.read("!L")[0]
747 assert(_experimenter == 6035143)
748 _subtype = reader.read("!L")[0]
749 assert(_subtype == 8)
750 reader.skip(4)
751 return obj
752
753 def __eq__(self, other):
754 if type(self) != type(other): return False
755 return True
756
757 def pretty_print(self, q):
758 q.text("bsn_require_vlan_xlate {")
759 with q.group():
760 with q.indent(2):
761 q.breakable()
762 q.breakable()
763 q.text('}')
764
765bsn.subtypes[8] = bsn_require_vlan_xlate
766
767class bsn_span_destination(bsn):
768 type = 65535
769 experimenter = 6035143
770 subtype = 10
771
772 def __init__(self):
773 return
774
775 def pack(self):
776 packed = []
777 packed.append(struct.pack("!H", self.type))
778 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
779 packed.append(struct.pack("!L", self.experimenter))
780 packed.append(struct.pack("!L", self.subtype))
781 packed.append('\x00' * 4)
782 length = sum([len(x) for x in packed])
783 packed[1] = struct.pack("!H", length)
784 return ''.join(packed)
785
786 @staticmethod
787 def unpack(reader):
788 obj = bsn_span_destination()
789 _type = reader.read("!H")[0]
790 assert(_type == 65535)
791 _len = reader.read("!H")[0]
792 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800793 reader = orig_reader.slice(_len, 4)
Rich Laneccd32ed2014-11-10 17:48:24 -0800794 _experimenter = reader.read("!L")[0]
795 assert(_experimenter == 6035143)
796 _subtype = reader.read("!L")[0]
797 assert(_subtype == 10)
798 reader.skip(4)
799 return obj
800
801 def __eq__(self, other):
802 if type(self) != type(other): return False
803 return True
804
805 def pretty_print(self, q):
806 q.text("bsn_span_destination {")
807 with q.group():
808 with q.indent(2):
809 q.breakable()
810 q.breakable()
811 q.text('}')
812
813bsn.subtypes[10] = bsn_span_destination
814
815class clear_actions(instruction):
816 type = 5
817
818 def __init__(self):
819 return
820
821 def pack(self):
822 packed = []
823 packed.append(struct.pack("!H", self.type))
824 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
825 packed.append('\x00' * 4)
826 length = sum([len(x) for x in packed])
827 packed[1] = struct.pack("!H", length)
828 return ''.join(packed)
829
830 @staticmethod
831 def unpack(reader):
832 obj = clear_actions()
833 _type = reader.read("!H")[0]
834 assert(_type == 5)
835 _len = reader.read("!H")[0]
836 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800837 reader = orig_reader.slice(_len, 4)
Rich Laneccd32ed2014-11-10 17:48:24 -0800838 reader.skip(4)
839 return obj
840
841 def __eq__(self, other):
842 if type(self) != type(other): return False
843 return True
844
845 def pretty_print(self, q):
846 q.text("clear_actions {")
847 with q.group():
848 with q.indent(2):
849 q.breakable()
850 q.breakable()
851 q.text('}')
852
853instruction.subtypes[5] = clear_actions
854
Rich Lane2e079da2014-10-29 15:30:24 -0700855class goto_table(instruction):
856 type = 1
857
858 def __init__(self, table_id=None):
859 if table_id != None:
860 self.table_id = table_id
861 else:
862 self.table_id = 0
863 return
864
865 def pack(self):
866 packed = []
867 packed.append(struct.pack("!H", self.type))
868 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
869 packed.append(struct.pack("!B", self.table_id))
870 packed.append('\x00' * 3)
871 length = sum([len(x) for x in packed])
872 packed[1] = struct.pack("!H", length)
873 return ''.join(packed)
874
875 @staticmethod
876 def unpack(reader):
877 obj = goto_table()
878 _type = reader.read("!H")[0]
879 assert(_type == 1)
880 _len = reader.read("!H")[0]
881 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800882 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700883 obj.table_id = reader.read("!B")[0]
884 reader.skip(3)
885 return obj
886
887 def __eq__(self, other):
888 if type(self) != type(other): return False
889 if self.table_id != other.table_id: return False
890 return True
891
892 def pretty_print(self, q):
893 q.text("goto_table {")
894 with q.group():
895 with q.indent(2):
896 q.breakable()
897 q.text("table_id = ");
898 q.text("%#x" % self.table_id)
899 q.breakable()
900 q.text('}')
901
902instruction.subtypes[1] = goto_table
903
904class meter(instruction):
905 type = 6
906
907 def __init__(self, meter_id=None):
908 if meter_id != None:
909 self.meter_id = meter_id
910 else:
911 self.meter_id = 0
912 return
913
914 def pack(self):
915 packed = []
916 packed.append(struct.pack("!H", self.type))
917 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
918 packed.append(struct.pack("!L", self.meter_id))
919 length = sum([len(x) for x in packed])
920 packed[1] = struct.pack("!H", length)
921 return ''.join(packed)
922
923 @staticmethod
924 def unpack(reader):
925 obj = meter()
926 _type = reader.read("!H")[0]
927 assert(_type == 6)
928 _len = reader.read("!H")[0]
929 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800930 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700931 obj.meter_id = reader.read("!L")[0]
932 return obj
933
934 def __eq__(self, other):
935 if type(self) != type(other): return False
936 if self.meter_id != other.meter_id: return False
937 return True
938
939 def pretty_print(self, q):
940 q.text("meter {")
941 with q.group():
942 with q.indent(2):
943 q.breakable()
944 q.text("meter_id = ");
945 q.text("%#x" % self.meter_id)
946 q.breakable()
947 q.text('}')
948
949instruction.subtypes[6] = meter
950
951class write_actions(instruction):
952 type = 3
953
954 def __init__(self, actions=None):
955 if actions != None:
956 self.actions = actions
957 else:
958 self.actions = []
959 return
960
961 def pack(self):
962 packed = []
963 packed.append(struct.pack("!H", self.type))
964 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
965 packed.append('\x00' * 4)
966 packed.append(loxi.generic_util.pack_list(self.actions))
967 length = sum([len(x) for x in packed])
968 packed[1] = struct.pack("!H", length)
969 return ''.join(packed)
970
971 @staticmethod
972 def unpack(reader):
973 obj = write_actions()
974 _type = reader.read("!H")[0]
975 assert(_type == 3)
976 _len = reader.read("!H")[0]
977 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800978 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700979 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -0800980 obj.actions = loxi.generic_util.unpack_list(reader, ofp.action.action.unpack)
Rich Lane2e079da2014-10-29 15:30:24 -0700981 return obj
982
983 def __eq__(self, other):
984 if type(self) != type(other): return False
985 if self.actions != other.actions: return False
986 return True
987
988 def pretty_print(self, q):
989 q.text("write_actions {")
990 with q.group():
991 with q.indent(2):
992 q.breakable()
993 q.text("actions = ");
994 q.pp(self.actions)
995 q.breakable()
996 q.text('}')
997
998instruction.subtypes[3] = write_actions
999
1000class write_metadata(instruction):
1001 type = 2
1002
1003 def __init__(self, metadata=None, metadata_mask=None):
1004 if metadata != None:
1005 self.metadata = metadata
1006 else:
1007 self.metadata = 0
1008 if metadata_mask != None:
1009 self.metadata_mask = metadata_mask
1010 else:
1011 self.metadata_mask = 0
1012 return
1013
1014 def pack(self):
1015 packed = []
1016 packed.append(struct.pack("!H", self.type))
1017 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1018 packed.append('\x00' * 4)
1019 packed.append(struct.pack("!Q", self.metadata))
1020 packed.append(struct.pack("!Q", self.metadata_mask))
1021 length = sum([len(x) for x in packed])
1022 packed[1] = struct.pack("!H", length)
1023 return ''.join(packed)
1024
1025 @staticmethod
1026 def unpack(reader):
1027 obj = write_metadata()
1028 _type = reader.read("!H")[0]
1029 assert(_type == 2)
1030 _len = reader.read("!H")[0]
1031 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001032 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -07001033 reader.skip(4)
1034 obj.metadata = reader.read("!Q")[0]
1035 obj.metadata_mask = reader.read("!Q")[0]
1036 return obj
1037
1038 def __eq__(self, other):
1039 if type(self) != type(other): return False
1040 if self.metadata != other.metadata: return False
1041 if self.metadata_mask != other.metadata_mask: return False
1042 return True
1043
1044 def pretty_print(self, q):
1045 q.text("write_metadata {")
1046 with q.group():
1047 with q.indent(2):
1048 q.breakable()
1049 q.text("metadata = ");
1050 q.text("%#x" % self.metadata)
1051 q.text(","); q.breakable()
1052 q.text("metadata_mask = ");
1053 q.text("%#x" % self.metadata_mask)
1054 q.breakable()
1055 q.text('}')
1056
1057instruction.subtypes[2] = write_metadata
1058
1059