blob: dd3eced2d3064c71d4a03202469cf9ca1c7189bb [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
117class idle_notification(bsn_tlv):
118 type = 7
119
120 def __init__(self):
121 return
122
123 def pack(self):
124 packed = []
125 packed.append(struct.pack("!H", self.type))
126 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
127 length = sum([len(x) for x in packed])
128 packed[1] = struct.pack("!H", length)
129 return ''.join(packed)
130
131 @staticmethod
132 def unpack(reader):
133 obj = idle_notification()
134 _type = reader.read("!H")[0]
135 assert(_type == 7)
136 _length = reader.read("!H")[0]
137 orig_reader = reader
138 reader = orig_reader.slice(_length - (2 + 2))
139 return obj
140
141 def __eq__(self, other):
142 if type(self) != type(other): return False
143 return True
144
145 def pretty_print(self, q):
146 q.text("idle_notification {")
147 with q.group():
148 with q.indent(2):
149 q.breakable()
150 q.breakable()
151 q.text('}')
152
153bsn_tlv.subtypes[7] = idle_notification
154
155class idle_time(bsn_tlv):
156 type = 5
157
158 def __init__(self, value=None):
159 if value != None:
160 self.value = value
161 else:
162 self.value = 0
163 return
164
165 def pack(self):
166 packed = []
167 packed.append(struct.pack("!H", self.type))
168 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
169 packed.append(struct.pack("!Q", self.value))
170 length = sum([len(x) for x in packed])
171 packed[1] = struct.pack("!H", length)
172 return ''.join(packed)
173
174 @staticmethod
175 def unpack(reader):
176 obj = idle_time()
177 _type = reader.read("!H")[0]
178 assert(_type == 5)
179 _length = reader.read("!H")[0]
180 orig_reader = reader
181 reader = orig_reader.slice(_length - (2 + 2))
182 obj.value = reader.read("!Q")[0]
183 return obj
184
185 def __eq__(self, other):
186 if type(self) != type(other): return False
187 if self.value != other.value: return False
188 return True
189
190 def pretty_print(self, q):
191 q.text("idle_time {")
192 with q.group():
193 with q.indent(2):
194 q.breakable()
195 q.text("value = ");
196 q.text("%#x" % self.value)
197 q.breakable()
198 q.text('}')
199
200bsn_tlv.subtypes[5] = idle_time
201
Rich Lane95f7fc92014-01-27 17:08:16 -0800202class idle_timeout(bsn_tlv):
203 type = 8
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("!L", 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_timeout()
224 _type = reader.read("!H")[0]
225 assert(_type == 8)
226 _length = reader.read("!H")[0]
227 orig_reader = reader
228 reader = orig_reader.slice(_length - (2 + 2))
229 obj.value = reader.read("!L")[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_timeout {")
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[8] = idle_timeout
248
Rich Lane5454b682014-01-14 17:07:36 -0800249class ipv4(bsn_tlv):
250 type = 4
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 = ipv4()
271 _type = reader.read("!H")[0]
272 assert(_type == 4)
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("ipv4 {")
286 with q.group():
287 with q.indent(2):
288 q.breakable()
289 q.text("value = ");
290 q.text(util.pretty_ipv4(self.value))
291 q.breakable()
292 q.text('}')
293
294bsn_tlv.subtypes[4] = ipv4
295
296class mac(bsn_tlv):
297 type = 1
298
299 def __init__(self, value=None):
300 if value != None:
301 self.value = value
302 else:
303 self.value = [0,0,0,0,0,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("!6B", *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 = mac()
318 _type = reader.read("!H")[0]
319 assert(_type == 1)
320 _length = reader.read("!H")[0]
321 orig_reader = reader
322 reader = orig_reader.slice(_length - (2 + 2))
323 obj.value = list(reader.read('!6B'))
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("mac {")
333 with q.group():
334 with q.indent(2):
335 q.breakable()
336 q.text("value = ");
337 q.text(util.pretty_mac(self.value))
338 q.breakable()
339 q.text('}')
340
341bsn_tlv.subtypes[1] = mac
342
Rich Lane95f7fc92014-01-27 17:08:16 -0800343class miss_packets(bsn_tlv):
344 type = 13
345
346 def __init__(self, value=None):
347 if value != None:
348 self.value = value
349 else:
350 self.value = 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("!Q", 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 = miss_packets()
365 _type = reader.read("!H")[0]
366 assert(_type == 13)
367 _length = reader.read("!H")[0]
368 orig_reader = reader
369 reader = orig_reader.slice(_length - (2 + 2))
370 obj.value = reader.read("!Q")[0]
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("miss_packets {")
380 with q.group():
381 with q.indent(2):
382 q.breakable()
383 q.text("value = ");
384 q.text("%#x" % self.value)
385 q.breakable()
386 q.text('}')
387
388bsn_tlv.subtypes[13] = miss_packets
389
Rich Lane5454b682014-01-14 17:07:36 -0800390class port(bsn_tlv):
391 type = 0
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(util.pack_port_no(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 = port()
412 _type = reader.read("!H")[0]
413 assert(_type == 0)
414 _length = reader.read("!H")[0]
415 orig_reader = reader
416 reader = orig_reader.slice(_length - (2 + 2))
417 obj.value = util.unpack_port_no(reader)
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("port {")
427 with q.group():
428 with q.indent(2):
429 q.breakable()
430 q.text("value = ");
431 q.text(util.pretty_port(self.value))
432 q.breakable()
433 q.text('}')
434
435bsn_tlv.subtypes[0] = port
436
Rich Lane95f7fc92014-01-27 17:08:16 -0800437class reply_packets(bsn_tlv):
438 type = 12
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(struct.pack("!Q", 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 = reply_packets()
459 _type = reader.read("!H")[0]
460 assert(_type == 12)
461 _length = reader.read("!H")[0]
462 orig_reader = reader
463 reader = orig_reader.slice(_length - (2 + 2))
464 obj.value = reader.read("!Q")[0]
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("reply_packets {")
474 with q.group():
475 with q.indent(2):
476 q.breakable()
477 q.text("value = ");
478 q.text("%#x" % self.value)
479 q.breakable()
480 q.text('}')
481
482bsn_tlv.subtypes[12] = reply_packets
483
484class request_packets(bsn_tlv):
485 type = 11
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 = request_packets()
506 _type = reader.read("!H")[0]
507 assert(_type == 11)
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("request_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[11] = request_packets
530
Rich Lane5454b682014-01-14 17:07:36 -0800531class rx_packets(bsn_tlv):
532 type = 2
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 = rx_packets()
553 _type = reader.read("!H")[0]
554 assert(_type == 2)
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("rx_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[2] = rx_packets
577
578class tx_packets(bsn_tlv):
579 type = 3
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 = tx_packets()
600 _type = reader.read("!H")[0]
601 assert(_type == 3)
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("tx_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[3] = tx_packets
624
Rich Lane95f7fc92014-01-27 17:08:16 -0800625class unicast_query_timeout(bsn_tlv):
626 type = 9
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("!L", 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 = unicast_query_timeout()
647 _type = reader.read("!H")[0]
648 assert(_type == 9)
649 _length = reader.read("!H")[0]
650 orig_reader = reader
651 reader = orig_reader.slice(_length - (2 + 2))
652 obj.value = reader.read("!L")[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("unicast_query_timeout {")
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[9] = unicast_query_timeout
671
Rich Lane5454b682014-01-14 17:07:36 -0800672class vlan_vid(bsn_tlv):
673 type = 6
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("!H", 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 = vlan_vid()
694 _type = reader.read("!H")[0]
695 assert(_type == 6)
696 _length = reader.read("!H")[0]
697 orig_reader = reader
698 reader = orig_reader.slice(_length - (2 + 2))
699 obj.value = reader.read("!H")[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("vlan_vid {")
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[6] = vlan_vid
718
719