blob: f169a6d5ccfa2592f5ffa92e8974a8bbe9645c65 [file] [log] [blame]
Rich Lane5454b682014-01-14 17:07:36 -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
19import bsn_tlv
20import util
21import loxi.generic_util
22
23class bsn_tlv(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 length 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 Lane5454b682014-01-14 17:07:36 -080042 @staticmethod
43 def unpack(reader):
44 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -080045 subclass = bsn_tlv.subtypes.get(subtype)
46 if subclass:
47 return subclass.unpack(reader)
Rich Lane5454b682014-01-14 17:07:36 -080048
Rich Lane95f7fc92014-01-27 17:08:16 -080049 obj = bsn_tlv()
50 obj.type = reader.read("!H")[0]
51 _length = reader.read("!H")[0]
52 orig_reader = reader
53 reader = orig_reader.slice(_length - (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("bsn_tlv {")
63 with q.group():
64 with q.indent(2):
65 q.breakable()
66 q.breakable()
67 q.text('}')
68
69
70class broadcast_query_timeout(bsn_tlv):
71 type = 10
72
73 def __init__(self, value=None):
74 if value != None:
75 self.value = value
76 else:
77 self.value = 0
78 return
79
80 def pack(self):
81 packed = []
82 packed.append(struct.pack("!H", self.type))
83 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
84 packed.append(struct.pack("!L", self.value))
85 length = sum([len(x) for x in packed])
86 packed[1] = struct.pack("!H", length)
87 return ''.join(packed)
88
89 @staticmethod
90 def unpack(reader):
91 obj = broadcast_query_timeout()
92 _type = reader.read("!H")[0]
93 assert(_type == 10)
94 _length = reader.read("!H")[0]
95 orig_reader = reader
96 reader = orig_reader.slice(_length - (2 + 2))
97 obj.value = reader.read("!L")[0]
98 return obj
99
100 def __eq__(self, other):
101 if type(self) != type(other): return False
102 if self.value != other.value: return False
103 return True
104
105 def pretty_print(self, q):
106 q.text("broadcast_query_timeout {")
107 with q.group():
108 with q.indent(2):
109 q.breakable()
110 q.text("value = ");
111 q.text("%#x" % self.value)
112 q.breakable()
113 q.text('}')
114
115bsn_tlv.subtypes[10] = broadcast_query_timeout
Rich Lane5454b682014-01-14 17:07:36 -0800116
Rich Lane1b75abf2014-02-05 11:23:20 -0800117class circuit_id(bsn_tlv):
118 type = 14
119
120 def __init__(self, value=None):
121 if value != None:
122 self.value = value
123 else:
124 self.value = ''
125 return
126
127 def pack(self):
128 packed = []
129 packed.append(struct.pack("!H", self.type))
130 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
131 packed.append(self.value)
132 length = sum([len(x) for x in packed])
133 packed[1] = struct.pack("!H", length)
134 return ''.join(packed)
135
136 @staticmethod
137 def unpack(reader):
138 obj = circuit_id()
139 _type = reader.read("!H")[0]
140 assert(_type == 14)
141 _length = reader.read("!H")[0]
142 orig_reader = reader
143 reader = orig_reader.slice(_length - (2 + 2))
144 obj.value = str(reader.read_all())
145 return obj
146
147 def __eq__(self, other):
148 if type(self) != type(other): return False
149 if self.value != other.value: return False
150 return True
151
152 def pretty_print(self, q):
153 q.text("circuit_id {")
154 with q.group():
155 with q.indent(2):
156 q.breakable()
157 q.text("value = ");
158 q.pp(self.value)
159 q.breakable()
160 q.text('}')
161
162bsn_tlv.subtypes[14] = circuit_id
163
Rich Lane5454b682014-01-14 17:07:36 -0800164class idle_notification(bsn_tlv):
165 type = 7
166
167 def __init__(self):
168 return
169
170 def pack(self):
171 packed = []
172 packed.append(struct.pack("!H", self.type))
173 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
174 length = sum([len(x) for x in packed])
175 packed[1] = struct.pack("!H", length)
176 return ''.join(packed)
177
178 @staticmethod
179 def unpack(reader):
180 obj = idle_notification()
181 _type = reader.read("!H")[0]
182 assert(_type == 7)
183 _length = reader.read("!H")[0]
184 orig_reader = reader
185 reader = orig_reader.slice(_length - (2 + 2))
186 return obj
187
188 def __eq__(self, other):
189 if type(self) != type(other): return False
190 return True
191
192 def pretty_print(self, q):
193 q.text("idle_notification {")
194 with q.group():
195 with q.indent(2):
196 q.breakable()
197 q.breakable()
198 q.text('}')
199
200bsn_tlv.subtypes[7] = idle_notification
201
202class idle_time(bsn_tlv):
203 type = 5
204
205 def __init__(self, value=None):
206 if value != None:
207 self.value = value
208 else:
209 self.value = 0
210 return
211
212 def pack(self):
213 packed = []
214 packed.append(struct.pack("!H", self.type))
215 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
216 packed.append(struct.pack("!Q", self.value))
217 length = sum([len(x) for x in packed])
218 packed[1] = struct.pack("!H", length)
219 return ''.join(packed)
220
221 @staticmethod
222 def unpack(reader):
223 obj = idle_time()
224 _type = reader.read("!H")[0]
225 assert(_type == 5)
226 _length = reader.read("!H")[0]
227 orig_reader = reader
228 reader = orig_reader.slice(_length - (2 + 2))
229 obj.value = reader.read("!Q")[0]
230 return obj
231
232 def __eq__(self, other):
233 if type(self) != type(other): return False
234 if self.value != other.value: return False
235 return True
236
237 def pretty_print(self, q):
238 q.text("idle_time {")
239 with q.group():
240 with q.indent(2):
241 q.breakable()
242 q.text("value = ");
243 q.text("%#x" % self.value)
244 q.breakable()
245 q.text('}')
246
247bsn_tlv.subtypes[5] = idle_time
248
Rich Lane95f7fc92014-01-27 17:08:16 -0800249class idle_timeout(bsn_tlv):
250 type = 8
251
252 def __init__(self, value=None):
253 if value != None:
254 self.value = value
255 else:
256 self.value = 0
257 return
258
259 def pack(self):
260 packed = []
261 packed.append(struct.pack("!H", self.type))
262 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
263 packed.append(struct.pack("!L", self.value))
264 length = sum([len(x) for x in packed])
265 packed[1] = struct.pack("!H", length)
266 return ''.join(packed)
267
268 @staticmethod
269 def unpack(reader):
270 obj = idle_timeout()
271 _type = reader.read("!H")[0]
272 assert(_type == 8)
273 _length = reader.read("!H")[0]
274 orig_reader = reader
275 reader = orig_reader.slice(_length - (2 + 2))
276 obj.value = reader.read("!L")[0]
277 return obj
278
279 def __eq__(self, other):
280 if type(self) != type(other): return False
281 if self.value != other.value: return False
282 return True
283
284 def pretty_print(self, q):
285 q.text("idle_timeout {")
286 with q.group():
287 with q.indent(2):
288 q.breakable()
289 q.text("value = ");
290 q.text("%#x" % self.value)
291 q.breakable()
292 q.text('}')
293
294bsn_tlv.subtypes[8] = idle_timeout
295
Rich Lane5454b682014-01-14 17:07:36 -0800296class ipv4(bsn_tlv):
297 type = 4
298
299 def __init__(self, value=None):
300 if value != None:
301 self.value = value
302 else:
303 self.value = 0
304 return
305
306 def pack(self):
307 packed = []
308 packed.append(struct.pack("!H", self.type))
309 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
310 packed.append(struct.pack("!L", self.value))
311 length = sum([len(x) for x in packed])
312 packed[1] = struct.pack("!H", length)
313 return ''.join(packed)
314
315 @staticmethod
316 def unpack(reader):
317 obj = ipv4()
318 _type = reader.read("!H")[0]
319 assert(_type == 4)
320 _length = reader.read("!H")[0]
321 orig_reader = reader
322 reader = orig_reader.slice(_length - (2 + 2))
323 obj.value = reader.read("!L")[0]
324 return obj
325
326 def __eq__(self, other):
327 if type(self) != type(other): return False
328 if self.value != other.value: return False
329 return True
330
331 def pretty_print(self, q):
332 q.text("ipv4 {")
333 with q.group():
334 with q.indent(2):
335 q.breakable()
336 q.text("value = ");
337 q.text(util.pretty_ipv4(self.value))
338 q.breakable()
339 q.text('}')
340
341bsn_tlv.subtypes[4] = ipv4
342
343class mac(bsn_tlv):
344 type = 1
345
346 def __init__(self, value=None):
347 if value != None:
348 self.value = value
349 else:
350 self.value = [0,0,0,0,0,0]
351 return
352
353 def pack(self):
354 packed = []
355 packed.append(struct.pack("!H", self.type))
356 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
357 packed.append(struct.pack("!6B", *self.value))
358 length = sum([len(x) for x in packed])
359 packed[1] = struct.pack("!H", length)
360 return ''.join(packed)
361
362 @staticmethod
363 def unpack(reader):
364 obj = mac()
365 _type = reader.read("!H")[0]
366 assert(_type == 1)
367 _length = reader.read("!H")[0]
368 orig_reader = reader
369 reader = orig_reader.slice(_length - (2 + 2))
370 obj.value = list(reader.read('!6B'))
371 return obj
372
373 def __eq__(self, other):
374 if type(self) != type(other): return False
375 if self.value != other.value: return False
376 return True
377
378 def pretty_print(self, q):
379 q.text("mac {")
380 with q.group():
381 with q.indent(2):
382 q.breakable()
383 q.text("value = ");
384 q.text(util.pretty_mac(self.value))
385 q.breakable()
386 q.text('}')
387
388bsn_tlv.subtypes[1] = mac
389
Rich Lane95f7fc92014-01-27 17:08:16 -0800390class miss_packets(bsn_tlv):
391 type = 13
392
393 def __init__(self, value=None):
394 if value != None:
395 self.value = value
396 else:
397 self.value = 0
398 return
399
400 def pack(self):
401 packed = []
402 packed.append(struct.pack("!H", self.type))
403 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
404 packed.append(struct.pack("!Q", self.value))
405 length = sum([len(x) for x in packed])
406 packed[1] = struct.pack("!H", length)
407 return ''.join(packed)
408
409 @staticmethod
410 def unpack(reader):
411 obj = miss_packets()
412 _type = reader.read("!H")[0]
413 assert(_type == 13)
414 _length = reader.read("!H")[0]
415 orig_reader = reader
416 reader = orig_reader.slice(_length - (2 + 2))
417 obj.value = reader.read("!Q")[0]
418 return obj
419
420 def __eq__(self, other):
421 if type(self) != type(other): return False
422 if self.value != other.value: return False
423 return True
424
425 def pretty_print(self, q):
426 q.text("miss_packets {")
427 with q.group():
428 with q.indent(2):
429 q.breakable()
430 q.text("value = ");
431 q.text("%#x" % self.value)
432 q.breakable()
433 q.text('}')
434
435bsn_tlv.subtypes[13] = miss_packets
436
Rich Lane5454b682014-01-14 17:07:36 -0800437class port(bsn_tlv):
438 type = 0
439
440 def __init__(self, value=None):
441 if value != None:
442 self.value = value
443 else:
444 self.value = 0
445 return
446
447 def pack(self):
448 packed = []
449 packed.append(struct.pack("!H", self.type))
450 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
451 packed.append(util.pack_port_no(self.value))
452 length = sum([len(x) for x in packed])
453 packed[1] = struct.pack("!H", length)
454 return ''.join(packed)
455
456 @staticmethod
457 def unpack(reader):
458 obj = port()
459 _type = reader.read("!H")[0]
460 assert(_type == 0)
461 _length = reader.read("!H")[0]
462 orig_reader = reader
463 reader = orig_reader.slice(_length - (2 + 2))
464 obj.value = util.unpack_port_no(reader)
465 return obj
466
467 def __eq__(self, other):
468 if type(self) != type(other): return False
469 if self.value != other.value: return False
470 return True
471
472 def pretty_print(self, q):
473 q.text("port {")
474 with q.group():
475 with q.indent(2):
476 q.breakable()
477 q.text("value = ");
478 q.text(util.pretty_port(self.value))
479 q.breakable()
480 q.text('}')
481
482bsn_tlv.subtypes[0] = port
483
Rich Lane95f7fc92014-01-27 17:08:16 -0800484class reply_packets(bsn_tlv):
485 type = 12
486
487 def __init__(self, value=None):
488 if value != None:
489 self.value = value
490 else:
491 self.value = 0
492 return
493
494 def pack(self):
495 packed = []
496 packed.append(struct.pack("!H", self.type))
497 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
498 packed.append(struct.pack("!Q", self.value))
499 length = sum([len(x) for x in packed])
500 packed[1] = struct.pack("!H", length)
501 return ''.join(packed)
502
503 @staticmethod
504 def unpack(reader):
505 obj = reply_packets()
506 _type = reader.read("!H")[0]
507 assert(_type == 12)
508 _length = reader.read("!H")[0]
509 orig_reader = reader
510 reader = orig_reader.slice(_length - (2 + 2))
511 obj.value = reader.read("!Q")[0]
512 return obj
513
514 def __eq__(self, other):
515 if type(self) != type(other): return False
516 if self.value != other.value: return False
517 return True
518
519 def pretty_print(self, q):
520 q.text("reply_packets {")
521 with q.group():
522 with q.indent(2):
523 q.breakable()
524 q.text("value = ");
525 q.text("%#x" % self.value)
526 q.breakable()
527 q.text('}')
528
529bsn_tlv.subtypes[12] = reply_packets
530
531class request_packets(bsn_tlv):
532 type = 11
533
534 def __init__(self, value=None):
535 if value != None:
536 self.value = value
537 else:
538 self.value = 0
539 return
540
541 def pack(self):
542 packed = []
543 packed.append(struct.pack("!H", self.type))
544 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
545 packed.append(struct.pack("!Q", self.value))
546 length = sum([len(x) for x in packed])
547 packed[1] = struct.pack("!H", length)
548 return ''.join(packed)
549
550 @staticmethod
551 def unpack(reader):
552 obj = request_packets()
553 _type = reader.read("!H")[0]
554 assert(_type == 11)
555 _length = reader.read("!H")[0]
556 orig_reader = reader
557 reader = orig_reader.slice(_length - (2 + 2))
558 obj.value = reader.read("!Q")[0]
559 return obj
560
561 def __eq__(self, other):
562 if type(self) != type(other): return False
563 if self.value != other.value: return False
564 return True
565
566 def pretty_print(self, q):
567 q.text("request_packets {")
568 with q.group():
569 with q.indent(2):
570 q.breakable()
571 q.text("value = ");
572 q.text("%#x" % self.value)
573 q.breakable()
574 q.text('}')
575
576bsn_tlv.subtypes[11] = request_packets
577
Rich Lane5454b682014-01-14 17:07:36 -0800578class rx_packets(bsn_tlv):
579 type = 2
580
581 def __init__(self, value=None):
582 if value != None:
583 self.value = value
584 else:
585 self.value = 0
586 return
587
588 def pack(self):
589 packed = []
590 packed.append(struct.pack("!H", self.type))
591 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
592 packed.append(struct.pack("!Q", self.value))
593 length = sum([len(x) for x in packed])
594 packed[1] = struct.pack("!H", length)
595 return ''.join(packed)
596
597 @staticmethod
598 def unpack(reader):
599 obj = rx_packets()
600 _type = reader.read("!H")[0]
601 assert(_type == 2)
602 _length = reader.read("!H")[0]
603 orig_reader = reader
604 reader = orig_reader.slice(_length - (2 + 2))
605 obj.value = reader.read("!Q")[0]
606 return obj
607
608 def __eq__(self, other):
609 if type(self) != type(other): return False
610 if self.value != other.value: return False
611 return True
612
613 def pretty_print(self, q):
614 q.text("rx_packets {")
615 with q.group():
616 with q.indent(2):
617 q.breakable()
618 q.text("value = ");
619 q.text("%#x" % self.value)
620 q.breakable()
621 q.text('}')
622
623bsn_tlv.subtypes[2] = rx_packets
624
625class tx_packets(bsn_tlv):
626 type = 3
627
628 def __init__(self, value=None):
629 if value != None:
630 self.value = value
631 else:
632 self.value = 0
633 return
634
635 def pack(self):
636 packed = []
637 packed.append(struct.pack("!H", self.type))
638 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
639 packed.append(struct.pack("!Q", self.value))
640 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 = tx_packets()
647 _type = reader.read("!H")[0]
648 assert(_type == 3)
649 _length = reader.read("!H")[0]
650 orig_reader = reader
651 reader = orig_reader.slice(_length - (2 + 2))
652 obj.value = reader.read("!Q")[0]
653 return obj
654
655 def __eq__(self, other):
656 if type(self) != type(other): return False
657 if self.value != other.value: return False
658 return True
659
660 def pretty_print(self, q):
661 q.text("tx_packets {")
662 with q.group():
663 with q.indent(2):
664 q.breakable()
665 q.text("value = ");
666 q.text("%#x" % self.value)
667 q.breakable()
668 q.text('}')
669
670bsn_tlv.subtypes[3] = tx_packets
671
Rich Lane95f7fc92014-01-27 17:08:16 -0800672class unicast_query_timeout(bsn_tlv):
673 type = 9
674
675 def __init__(self, value=None):
676 if value != None:
677 self.value = value
678 else:
679 self.value = 0
680 return
681
682 def pack(self):
683 packed = []
684 packed.append(struct.pack("!H", self.type))
685 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
686 packed.append(struct.pack("!L", self.value))
687 length = sum([len(x) for x in packed])
688 packed[1] = struct.pack("!H", length)
689 return ''.join(packed)
690
691 @staticmethod
692 def unpack(reader):
693 obj = unicast_query_timeout()
694 _type = reader.read("!H")[0]
695 assert(_type == 9)
696 _length = reader.read("!H")[0]
697 orig_reader = reader
698 reader = orig_reader.slice(_length - (2 + 2))
699 obj.value = reader.read("!L")[0]
700 return obj
701
702 def __eq__(self, other):
703 if type(self) != type(other): return False
704 if self.value != other.value: return False
705 return True
706
707 def pretty_print(self, q):
708 q.text("unicast_query_timeout {")
709 with q.group():
710 with q.indent(2):
711 q.breakable()
712 q.text("value = ");
713 q.text("%#x" % self.value)
714 q.breakable()
715 q.text('}')
716
717bsn_tlv.subtypes[9] = unicast_query_timeout
718
Rich Lane5454b682014-01-14 17:07:36 -0800719class vlan_vid(bsn_tlv):
720 type = 6
721
722 def __init__(self, value=None):
723 if value != None:
724 self.value = value
725 else:
726 self.value = 0
727 return
728
729 def pack(self):
730 packed = []
731 packed.append(struct.pack("!H", self.type))
732 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
733 packed.append(struct.pack("!H", self.value))
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 = vlan_vid()
741 _type = reader.read("!H")[0]
742 assert(_type == 6)
743 _length = reader.read("!H")[0]
744 orig_reader = reader
745 reader = orig_reader.slice(_length - (2 + 2))
746 obj.value = reader.read("!H")[0]
747 return obj
748
749 def __eq__(self, other):
750 if type(self) != type(other): return False
751 if self.value != other.value: return False
752 return True
753
754 def pretty_print(self, q):
755 q.text("vlan_vid {")
756 with q.group():
757 with q.indent(2):
758 q.breakable()
759 q.text("value = ");
760 q.text("%#x" % self.value)
761 q.breakable()
762 q.text('}')
763
764bsn_tlv.subtypes[6] = vlan_vid
765
766