blob: 039891c76e0beb6fc91202a761ad9a94af4e42f8 [file] [log] [blame]
Nathan Knuth418fdc82016-09-16 22:51:15 -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
11import util
12import loxi.generic_util
13
14import sys
15ofp = sys.modules['loxi.of10']
16
17class message(loxi.OFObject):
18 subtypes = {}
19
20 version = 1
21
22 def __init__(self, type=None, xid=None):
23 if type != None:
24 self.type = type
25 else:
26 self.type = 0
27 if xid != None:
28 self.xid = xid
29 else:
30 self.xid = None
31 return
32
33 def pack(self):
34 packed = []
35 packed.append(struct.pack("!B", self.version))
36 packed.append(struct.pack("!B", self.type))
37 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
38 packed.append(struct.pack("!L", self.xid))
39 length = sum([len(x) for x in packed])
40 packed[2] = struct.pack("!H", length)
41 return ''.join(packed)
42
43 @staticmethod
44 def unpack(reader):
45 subtype, = reader.peek('B', 1)
46 subclass = message.subtypes.get(subtype)
47 if subclass:
48 return subclass.unpack(reader)
49
50 obj = message()
51 _version = reader.read("!B")[0]
52 assert(_version == 1)
53 obj.type = reader.read("!B")[0]
54 _length = reader.read("!H")[0]
55 orig_reader = reader
56 reader = orig_reader.slice(_length, 4)
57 obj.xid = reader.read("!L")[0]
58 return obj
59
60 def __eq__(self, other):
61 if type(self) != type(other): return False
62 if self.type != other.type: return False
63 if self.xid != other.xid: return False
64 return True
65
66 def pretty_print(self, q):
67 q.text("message {")
68 with q.group():
69 with q.indent(2):
70 q.breakable()
71 q.text("xid = ");
72 if self.xid != None:
73 q.text("%#x" % self.xid)
74 else:
75 q.text('None')
76 q.breakable()
77 q.text('}')
78
79
80class stats_reply(message):
81 subtypes = {}
82
83 version = 1
84 type = 17
85
86 def __init__(self, xid=None, stats_type=None, flags=None):
87 if xid != None:
88 self.xid = xid
89 else:
90 self.xid = None
91 if stats_type != None:
92 self.stats_type = stats_type
93 else:
94 self.stats_type = 0
95 if flags != None:
96 self.flags = flags
97 else:
98 self.flags = 0
99 return
100
101 def pack(self):
102 packed = []
103 packed.append(struct.pack("!B", self.version))
104 packed.append(struct.pack("!B", self.type))
105 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
106 packed.append(struct.pack("!L", self.xid))
107 packed.append(struct.pack("!H", self.stats_type))
108 packed.append(struct.pack("!H", self.flags))
109 length = sum([len(x) for x in packed])
110 packed[2] = struct.pack("!H", length)
111 return ''.join(packed)
112
113 @staticmethod
114 def unpack(reader):
115 subtype, = reader.peek('!H', 8)
116 subclass = stats_reply.subtypes.get(subtype)
117 if subclass:
118 return subclass.unpack(reader)
119
120 obj = stats_reply()
121 _version = reader.read("!B")[0]
122 assert(_version == 1)
123 _type = reader.read("!B")[0]
124 assert(_type == 17)
125 _length = reader.read("!H")[0]
126 orig_reader = reader
127 reader = orig_reader.slice(_length, 4)
128 obj.xid = reader.read("!L")[0]
129 obj.stats_type = reader.read("!H")[0]
130 obj.flags = reader.read("!H")[0]
131 return obj
132
133 def __eq__(self, other):
134 if type(self) != type(other): return False
135 if self.xid != other.xid: return False
136 if self.stats_type != other.stats_type: return False
137 if self.flags != other.flags: return False
138 return True
139
140 def pretty_print(self, q):
141 q.text("stats_reply {")
142 with q.group():
143 with q.indent(2):
144 q.breakable()
145 q.text("xid = ");
146 if self.xid != None:
147 q.text("%#x" % self.xid)
148 else:
149 q.text('None')
150 q.text(","); q.breakable()
151 q.text("flags = ");
152 q.text("%#x" % self.flags)
153 q.breakable()
154 q.text('}')
155
156message.subtypes[17] = stats_reply
157
158class aggregate_stats_reply(stats_reply):
159 version = 1
160 type = 17
161 stats_type = 2
162
163 def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None):
164 if xid != None:
165 self.xid = xid
166 else:
167 self.xid = None
168 if flags != None:
169 self.flags = flags
170 else:
171 self.flags = 0
172 if packet_count != None:
173 self.packet_count = packet_count
174 else:
175 self.packet_count = 0
176 if byte_count != None:
177 self.byte_count = byte_count
178 else:
179 self.byte_count = 0
180 if flow_count != None:
181 self.flow_count = flow_count
182 else:
183 self.flow_count = 0
184 return
185
186 def pack(self):
187 packed = []
188 packed.append(struct.pack("!B", self.version))
189 packed.append(struct.pack("!B", self.type))
190 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
191 packed.append(struct.pack("!L", self.xid))
192 packed.append(struct.pack("!H", self.stats_type))
193 packed.append(struct.pack("!H", self.flags))
194 packed.append(struct.pack("!Q", self.packet_count))
195 packed.append(struct.pack("!Q", self.byte_count))
196 packed.append(struct.pack("!L", self.flow_count))
197 packed.append('\x00' * 4)
198 length = sum([len(x) for x in packed])
199 packed[2] = struct.pack("!H", length)
200 return ''.join(packed)
201
202 @staticmethod
203 def unpack(reader):
204 obj = aggregate_stats_reply()
205 _version = reader.read("!B")[0]
206 assert(_version == 1)
207 _type = reader.read("!B")[0]
208 assert(_type == 17)
209 _length = reader.read("!H")[0]
210 orig_reader = reader
211 reader = orig_reader.slice(_length, 4)
212 obj.xid = reader.read("!L")[0]
213 _stats_type = reader.read("!H")[0]
214 assert(_stats_type == 2)
215 obj.flags = reader.read("!H")[0]
216 obj.packet_count = reader.read("!Q")[0]
217 obj.byte_count = reader.read("!Q")[0]
218 obj.flow_count = reader.read("!L")[0]
219 reader.skip(4)
220 return obj
221
222 def __eq__(self, other):
223 if type(self) != type(other): return False
224 if self.xid != other.xid: return False
225 if self.flags != other.flags: return False
226 if self.packet_count != other.packet_count: return False
227 if self.byte_count != other.byte_count: return False
228 if self.flow_count != other.flow_count: return False
229 return True
230
231 def pretty_print(self, q):
232 q.text("aggregate_stats_reply {")
233 with q.group():
234 with q.indent(2):
235 q.breakable()
236 q.text("xid = ");
237 if self.xid != None:
238 q.text("%#x" % self.xid)
239 else:
240 q.text('None')
241 q.text(","); q.breakable()
242 q.text("flags = ");
243 q.text("%#x" % self.flags)
244 q.text(","); q.breakable()
245 q.text("packet_count = ");
246 q.text("%#x" % self.packet_count)
247 q.text(","); q.breakable()
248 q.text("byte_count = ");
249 q.text("%#x" % self.byte_count)
250 q.text(","); q.breakable()
251 q.text("flow_count = ");
252 q.text("%#x" % self.flow_count)
253 q.breakable()
254 q.text('}')
255
256stats_reply.subtypes[2] = aggregate_stats_reply
257
258class stats_request(message):
259 subtypes = {}
260
261 version = 1
262 type = 16
263
264 def __init__(self, xid=None, stats_type=None, flags=None):
265 if xid != None:
266 self.xid = xid
267 else:
268 self.xid = None
269 if stats_type != None:
270 self.stats_type = stats_type
271 else:
272 self.stats_type = 0
273 if flags != None:
274 self.flags = flags
275 else:
276 self.flags = 0
277 return
278
279 def pack(self):
280 packed = []
281 packed.append(struct.pack("!B", self.version))
282 packed.append(struct.pack("!B", self.type))
283 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
284 packed.append(struct.pack("!L", self.xid))
285 packed.append(struct.pack("!H", self.stats_type))
286 packed.append(struct.pack("!H", self.flags))
287 length = sum([len(x) for x in packed])
288 packed[2] = struct.pack("!H", length)
289 return ''.join(packed)
290
291 @staticmethod
292 def unpack(reader):
293 subtype, = reader.peek('!H', 8)
294 subclass = stats_request.subtypes.get(subtype)
295 if subclass:
296 return subclass.unpack(reader)
297
298 obj = stats_request()
299 _version = reader.read("!B")[0]
300 assert(_version == 1)
301 _type = reader.read("!B")[0]
302 assert(_type == 16)
303 _length = reader.read("!H")[0]
304 orig_reader = reader
305 reader = orig_reader.slice(_length, 4)
306 obj.xid = reader.read("!L")[0]
307 obj.stats_type = reader.read("!H")[0]
308 obj.flags = reader.read("!H")[0]
309 return obj
310
311 def __eq__(self, other):
312 if type(self) != type(other): return False
313 if self.xid != other.xid: return False
314 if self.stats_type != other.stats_type: return False
315 if self.flags != other.flags: return False
316 return True
317
318 def pretty_print(self, q):
319 q.text("stats_request {")
320 with q.group():
321 with q.indent(2):
322 q.breakable()
323 q.text("xid = ");
324 if self.xid != None:
325 q.text("%#x" % self.xid)
326 else:
327 q.text('None')
328 q.text(","); q.breakable()
329 q.text("flags = ");
330 q.text("%#x" % self.flags)
331 q.breakable()
332 q.text('}')
333
334message.subtypes[16] = stats_request
335
336class aggregate_stats_request(stats_request):
337 version = 1
338 type = 16
339 stats_type = 2
340
341 def __init__(self, xid=None, flags=None, match=None, table_id=None, out_port=None):
342 if xid != None:
343 self.xid = xid
344 else:
345 self.xid = None
346 if flags != None:
347 self.flags = flags
348 else:
349 self.flags = 0
350 if match != None:
351 self.match = match
352 else:
353 self.match = ofp.match()
354 if table_id != None:
355 self.table_id = table_id
356 else:
357 self.table_id = 0
358 if out_port != None:
359 self.out_port = out_port
360 else:
361 self.out_port = 0
362 return
363
364 def pack(self):
365 packed = []
366 packed.append(struct.pack("!B", self.version))
367 packed.append(struct.pack("!B", self.type))
368 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
369 packed.append(struct.pack("!L", self.xid))
370 packed.append(struct.pack("!H", self.stats_type))
371 packed.append(struct.pack("!H", self.flags))
372 packed.append(self.match.pack())
373 packed.append(struct.pack("!B", self.table_id))
374 packed.append('\x00' * 1)
375 packed.append(util.pack_port_no(self.out_port))
376 length = sum([len(x) for x in packed])
377 packed[2] = struct.pack("!H", length)
378 return ''.join(packed)
379
380 @staticmethod
381 def unpack(reader):
382 obj = aggregate_stats_request()
383 _version = reader.read("!B")[0]
384 assert(_version == 1)
385 _type = reader.read("!B")[0]
386 assert(_type == 16)
387 _length = reader.read("!H")[0]
388 orig_reader = reader
389 reader = orig_reader.slice(_length, 4)
390 obj.xid = reader.read("!L")[0]
391 _stats_type = reader.read("!H")[0]
392 assert(_stats_type == 2)
393 obj.flags = reader.read("!H")[0]
394 obj.match = ofp.match.unpack(reader)
395 obj.table_id = reader.read("!B")[0]
396 reader.skip(1)
397 obj.out_port = util.unpack_port_no(reader)
398 return obj
399
400 def __eq__(self, other):
401 if type(self) != type(other): return False
402 if self.xid != other.xid: return False
403 if self.flags != other.flags: return False
404 if self.match != other.match: return False
405 if self.table_id != other.table_id: return False
406 if self.out_port != other.out_port: return False
407 return True
408
409 def pretty_print(self, q):
410 q.text("aggregate_stats_request {")
411 with q.group():
412 with q.indent(2):
413 q.breakable()
414 q.text("xid = ");
415 if self.xid != None:
416 q.text("%#x" % self.xid)
417 else:
418 q.text('None')
419 q.text(","); q.breakable()
420 q.text("flags = ");
421 q.text("%#x" % self.flags)
422 q.text(","); q.breakable()
423 q.text("match = ");
424 q.pp(self.match)
425 q.text(","); q.breakable()
426 q.text("table_id = ");
427 q.text("%#x" % self.table_id)
428 q.text(","); q.breakable()
429 q.text("out_port = ");
430 q.text(util.pretty_port(self.out_port))
431 q.breakable()
432 q.text('}')
433
434stats_request.subtypes[2] = aggregate_stats_request
435
436class error_msg(message):
437 subtypes = {}
438
439 version = 1
440 type = 1
441
442 def __init__(self, xid=None, err_type=None):
443 if xid != None:
444 self.xid = xid
445 else:
446 self.xid = None
447 if err_type != None:
448 self.err_type = err_type
449 else:
450 self.err_type = 0
451 return
452
453 def pack(self):
454 packed = []
455 packed.append(struct.pack("!B", self.version))
456 packed.append(struct.pack("!B", self.type))
457 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
458 packed.append(struct.pack("!L", self.xid))
459 packed.append(struct.pack("!H", self.err_type))
460 length = sum([len(x) for x in packed])
461 packed[2] = struct.pack("!H", length)
462 return ''.join(packed)
463
464 @staticmethod
465 def unpack(reader):
466 subtype, = reader.peek('!H', 8)
467 subclass = error_msg.subtypes.get(subtype)
468 if subclass:
469 return subclass.unpack(reader)
470
471 obj = error_msg()
472 _version = reader.read("!B")[0]
473 assert(_version == 1)
474 _type = reader.read("!B")[0]
475 assert(_type == 1)
476 _length = reader.read("!H")[0]
477 orig_reader = reader
478 reader = orig_reader.slice(_length, 4)
479 obj.xid = reader.read("!L")[0]
480 obj.err_type = reader.read("!H")[0]
481 return obj
482
483 def __eq__(self, other):
484 if type(self) != type(other): return False
485 if self.xid != other.xid: return False
486 if self.err_type != other.err_type: return False
487 return True
488
489 def pretty_print(self, q):
490 q.text("error_msg {")
491 with q.group():
492 with q.indent(2):
493 q.breakable()
494 q.text("xid = ");
495 if self.xid != None:
496 q.text("%#x" % self.xid)
497 else:
498 q.text('None')
499 q.breakable()
500 q.text('}')
501
502message.subtypes[1] = error_msg
503
504class bad_action_error_msg(error_msg):
505 version = 1
506 type = 1
507 err_type = 2
508
509 def __init__(self, xid=None, code=None, data=None):
510 if xid != None:
511 self.xid = xid
512 else:
513 self.xid = None
514 if code != None:
515 self.code = code
516 else:
517 self.code = 0
518 if data != None:
519 self.data = data
520 else:
521 self.data = ''
522 return
523
524 def pack(self):
525 packed = []
526 packed.append(struct.pack("!B", self.version))
527 packed.append(struct.pack("!B", self.type))
528 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
529 packed.append(struct.pack("!L", self.xid))
530 packed.append(struct.pack("!H", self.err_type))
531 packed.append(struct.pack("!H", self.code))
532 packed.append(self.data)
533 length = sum([len(x) for x in packed])
534 packed[2] = struct.pack("!H", length)
535 return ''.join(packed)
536
537 @staticmethod
538 def unpack(reader):
539 obj = bad_action_error_msg()
540 _version = reader.read("!B")[0]
541 assert(_version == 1)
542 _type = reader.read("!B")[0]
543 assert(_type == 1)
544 _length = reader.read("!H")[0]
545 orig_reader = reader
546 reader = orig_reader.slice(_length, 4)
547 obj.xid = reader.read("!L")[0]
548 _err_type = reader.read("!H")[0]
549 assert(_err_type == 2)
550 obj.code = reader.read("!H")[0]
551 obj.data = str(reader.read_all())
552 return obj
553
554 def __eq__(self, other):
555 if type(self) != type(other): return False
556 if self.xid != other.xid: return False
557 if self.code != other.code: return False
558 if self.data != other.data: return False
559 return True
560
561 def pretty_print(self, q):
562 q.text("bad_action_error_msg {")
563 with q.group():
564 with q.indent(2):
565 q.breakable()
566 q.text("xid = ");
567 if self.xid != None:
568 q.text("%#x" % self.xid)
569 else:
570 q.text('None')
571 q.text(","); q.breakable()
572 q.text("code = ");
573 q.text("%#x" % self.code)
574 q.text(","); q.breakable()
575 q.text("data = ");
576 q.pp(self.data)
577 q.breakable()
578 q.text('}')
579
580error_msg.subtypes[2] = bad_action_error_msg
581
582class bad_request_error_msg(error_msg):
583 version = 1
584 type = 1
585 err_type = 1
586
587 def __init__(self, xid=None, code=None, data=None):
588 if xid != None:
589 self.xid = xid
590 else:
591 self.xid = None
592 if code != None:
593 self.code = code
594 else:
595 self.code = 0
596 if data != None:
597 self.data = data
598 else:
599 self.data = ''
600 return
601
602 def pack(self):
603 packed = []
604 packed.append(struct.pack("!B", self.version))
605 packed.append(struct.pack("!B", self.type))
606 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
607 packed.append(struct.pack("!L", self.xid))
608 packed.append(struct.pack("!H", self.err_type))
609 packed.append(struct.pack("!H", self.code))
610 packed.append(self.data)
611 length = sum([len(x) for x in packed])
612 packed[2] = struct.pack("!H", length)
613 return ''.join(packed)
614
615 @staticmethod
616 def unpack(reader):
617 obj = bad_request_error_msg()
618 _version = reader.read("!B")[0]
619 assert(_version == 1)
620 _type = reader.read("!B")[0]
621 assert(_type == 1)
622 _length = reader.read("!H")[0]
623 orig_reader = reader
624 reader = orig_reader.slice(_length, 4)
625 obj.xid = reader.read("!L")[0]
626 _err_type = reader.read("!H")[0]
627 assert(_err_type == 1)
628 obj.code = reader.read("!H")[0]
629 obj.data = str(reader.read_all())
630 return obj
631
632 def __eq__(self, other):
633 if type(self) != type(other): return False
634 if self.xid != other.xid: return False
635 if self.code != other.code: return False
636 if self.data != other.data: return False
637 return True
638
639 def pretty_print(self, q):
640 q.text("bad_request_error_msg {")
641 with q.group():
642 with q.indent(2):
643 q.breakable()
644 q.text("xid = ");
645 if self.xid != None:
646 q.text("%#x" % self.xid)
647 else:
648 q.text('None')
649 q.text(","); q.breakable()
650 q.text("code = ");
651 q.text("%#x" % self.code)
652 q.text(","); q.breakable()
653 q.text("data = ");
654 q.pp(self.data)
655 q.breakable()
656 q.text('}')
657
658error_msg.subtypes[1] = bad_request_error_msg
659
660class barrier_reply(message):
661 version = 1
662 type = 19
663
664 def __init__(self, xid=None):
665 if xid != None:
666 self.xid = xid
667 else:
668 self.xid = None
669 return
670
671 def pack(self):
672 packed = []
673 packed.append(struct.pack("!B", self.version))
674 packed.append(struct.pack("!B", self.type))
675 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
676 packed.append(struct.pack("!L", self.xid))
677 length = sum([len(x) for x in packed])
678 packed[2] = struct.pack("!H", length)
679 return ''.join(packed)
680
681 @staticmethod
682 def unpack(reader):
683 obj = barrier_reply()
684 _version = reader.read("!B")[0]
685 assert(_version == 1)
686 _type = reader.read("!B")[0]
687 assert(_type == 19)
688 _length = reader.read("!H")[0]
689 orig_reader = reader
690 reader = orig_reader.slice(_length, 4)
691 obj.xid = reader.read("!L")[0]
692 return obj
693
694 def __eq__(self, other):
695 if type(self) != type(other): return False
696 if self.xid != other.xid: return False
697 return True
698
699 def pretty_print(self, q):
700 q.text("barrier_reply {")
701 with q.group():
702 with q.indent(2):
703 q.breakable()
704 q.text("xid = ");
705 if self.xid != None:
706 q.text("%#x" % self.xid)
707 else:
708 q.text('None')
709 q.breakable()
710 q.text('}')
711
712message.subtypes[19] = barrier_reply
713
714class barrier_request(message):
715 version = 1
716 type = 18
717
718 def __init__(self, xid=None):
719 if xid != None:
720 self.xid = xid
721 else:
722 self.xid = None
723 return
724
725 def pack(self):
726 packed = []
727 packed.append(struct.pack("!B", self.version))
728 packed.append(struct.pack("!B", self.type))
729 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
730 packed.append(struct.pack("!L", self.xid))
731 length = sum([len(x) for x in packed])
732 packed[2] = struct.pack("!H", length)
733 return ''.join(packed)
734
735 @staticmethod
736 def unpack(reader):
737 obj = barrier_request()
738 _version = reader.read("!B")[0]
739 assert(_version == 1)
740 _type = reader.read("!B")[0]
741 assert(_type == 18)
742 _length = reader.read("!H")[0]
743 orig_reader = reader
744 reader = orig_reader.slice(_length, 4)
745 obj.xid = reader.read("!L")[0]
746 return obj
747
748 def __eq__(self, other):
749 if type(self) != type(other): return False
750 if self.xid != other.xid: return False
751 return True
752
753 def pretty_print(self, q):
754 q.text("barrier_request {")
755 with q.group():
756 with q.indent(2):
757 q.breakable()
758 q.text("xid = ");
759 if self.xid != None:
760 q.text("%#x" % self.xid)
761 else:
762 q.text('None')
763 q.breakable()
764 q.text('}')
765
766message.subtypes[18] = barrier_request
767
768class experimenter(message):
769 subtypes = {}
770
771 version = 1
772 type = 4
773
774 def __init__(self, xid=None, experimenter=None, data=None):
775 if xid != None:
776 self.xid = xid
777 else:
778 self.xid = None
779 if experimenter != None:
780 self.experimenter = experimenter
781 else:
782 self.experimenter = 0
783 if data != None:
784 self.data = data
785 else:
786 self.data = ''
787 return
788
789 def pack(self):
790 packed = []
791 packed.append(struct.pack("!B", self.version))
792 packed.append(struct.pack("!B", self.type))
793 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
794 packed.append(struct.pack("!L", self.xid))
795 packed.append(struct.pack("!L", self.experimenter))
796 packed.append(self.data)
797 length = sum([len(x) for x in packed])
798 packed[2] = struct.pack("!H", length)
799 return ''.join(packed)
800
801 @staticmethod
802 def unpack(reader):
803 subtype, = reader.peek('!L', 8)
804 subclass = experimenter.subtypes.get(subtype)
805 if subclass:
806 return subclass.unpack(reader)
807
808 obj = experimenter()
809 _version = reader.read("!B")[0]
810 assert(_version == 1)
811 _type = reader.read("!B")[0]
812 assert(_type == 4)
813 _length = reader.read("!H")[0]
814 orig_reader = reader
815 reader = orig_reader.slice(_length, 4)
816 obj.xid = reader.read("!L")[0]
817 obj.experimenter = reader.read("!L")[0]
818 obj.data = str(reader.read_all())
819 return obj
820
821 def __eq__(self, other):
822 if type(self) != type(other): return False
823 if self.xid != other.xid: return False
824 if self.experimenter != other.experimenter: return False
825 if self.data != other.data: return False
826 return True
827
828 def pretty_print(self, q):
829 q.text("experimenter {")
830 with q.group():
831 with q.indent(2):
832 q.breakable()
833 q.text("xid = ");
834 if self.xid != None:
835 q.text("%#x" % self.xid)
836 else:
837 q.text('None')
838 q.text(","); q.breakable()
839 q.text("data = ");
840 q.pp(self.data)
841 q.breakable()
842 q.text('}')
843
844message.subtypes[4] = experimenter
845
846class bsn_header(experimenter):
847 subtypes = {}
848
849 version = 1
850 type = 4
851 experimenter = 6035143
852
853 def __init__(self, xid=None, subtype=None):
854 if xid != None:
855 self.xid = xid
856 else:
857 self.xid = None
858 if subtype != None:
859 self.subtype = subtype
860 else:
861 self.subtype = 0
862 return
863
864 def pack(self):
865 packed = []
866 packed.append(struct.pack("!B", self.version))
867 packed.append(struct.pack("!B", self.type))
868 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
869 packed.append(struct.pack("!L", self.xid))
870 packed.append(struct.pack("!L", self.experimenter))
871 packed.append(struct.pack("!L", self.subtype))
872 length = sum([len(x) for x in packed])
873 packed[2] = struct.pack("!H", length)
874 return ''.join(packed)
875
876 @staticmethod
877 def unpack(reader):
878 subtype, = reader.peek('!L', 12)
879 subclass = bsn_header.subtypes.get(subtype)
880 if subclass:
881 return subclass.unpack(reader)
882
883 obj = bsn_header()
884 _version = reader.read("!B")[0]
885 assert(_version == 1)
886 _type = reader.read("!B")[0]
887 assert(_type == 4)
888 _length = reader.read("!H")[0]
889 orig_reader = reader
890 reader = orig_reader.slice(_length, 4)
891 obj.xid = reader.read("!L")[0]
892 _experimenter = reader.read("!L")[0]
893 assert(_experimenter == 6035143)
894 obj.subtype = reader.read("!L")[0]
895 return obj
896
897 def __eq__(self, other):
898 if type(self) != type(other): return False
899 if self.xid != other.xid: return False
900 if self.subtype != other.subtype: return False
901 return True
902
903 def pretty_print(self, q):
904 q.text("bsn_header {")
905 with q.group():
906 with q.indent(2):
907 q.breakable()
908 q.text("xid = ");
909 if self.xid != None:
910 q.text("%#x" % self.xid)
911 else:
912 q.text('None')
913 q.breakable()
914 q.text('}')
915
916experimenter.subtypes[6035143] = bsn_header
917
918class bsn_bw_clear_data_reply(bsn_header):
919 version = 1
920 type = 4
921 experimenter = 6035143
922 subtype = 22
923
924 def __init__(self, xid=None, status=None):
925 if xid != None:
926 self.xid = xid
927 else:
928 self.xid = None
929 if status != None:
930 self.status = status
931 else:
932 self.status = 0
933 return
934
935 def pack(self):
936 packed = []
937 packed.append(struct.pack("!B", self.version))
938 packed.append(struct.pack("!B", self.type))
939 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
940 packed.append(struct.pack("!L", self.xid))
941 packed.append(struct.pack("!L", self.experimenter))
942 packed.append(struct.pack("!L", self.subtype))
943 packed.append(struct.pack("!L", self.status))
944 length = sum([len(x) for x in packed])
945 packed[2] = struct.pack("!H", length)
946 return ''.join(packed)
947
948 @staticmethod
949 def unpack(reader):
950 obj = bsn_bw_clear_data_reply()
951 _version = reader.read("!B")[0]
952 assert(_version == 1)
953 _type = reader.read("!B")[0]
954 assert(_type == 4)
955 _length = reader.read("!H")[0]
956 orig_reader = reader
957 reader = orig_reader.slice(_length, 4)
958 obj.xid = reader.read("!L")[0]
959 _experimenter = reader.read("!L")[0]
960 assert(_experimenter == 6035143)
961 _subtype = reader.read("!L")[0]
962 assert(_subtype == 22)
963 obj.status = reader.read("!L")[0]
964 return obj
965
966 def __eq__(self, other):
967 if type(self) != type(other): return False
968 if self.xid != other.xid: return False
969 if self.status != other.status: return False
970 return True
971
972 def pretty_print(self, q):
973 q.text("bsn_bw_clear_data_reply {")
974 with q.group():
975 with q.indent(2):
976 q.breakable()
977 q.text("xid = ");
978 if self.xid != None:
979 q.text("%#x" % self.xid)
980 else:
981 q.text('None')
982 q.text(","); q.breakable()
983 q.text("status = ");
984 q.text("%#x" % self.status)
985 q.breakable()
986 q.text('}')
987
988bsn_header.subtypes[22] = bsn_bw_clear_data_reply
989
990class bsn_bw_clear_data_request(bsn_header):
991 version = 1
992 type = 4
993 experimenter = 6035143
994 subtype = 21
995
996 def __init__(self, xid=None):
997 if xid != None:
998 self.xid = xid
999 else:
1000 self.xid = None
1001 return
1002
1003 def pack(self):
1004 packed = []
1005 packed.append(struct.pack("!B", self.version))
1006 packed.append(struct.pack("!B", self.type))
1007 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1008 packed.append(struct.pack("!L", self.xid))
1009 packed.append(struct.pack("!L", self.experimenter))
1010 packed.append(struct.pack("!L", self.subtype))
1011 length = sum([len(x) for x in packed])
1012 packed[2] = struct.pack("!H", length)
1013 return ''.join(packed)
1014
1015 @staticmethod
1016 def unpack(reader):
1017 obj = bsn_bw_clear_data_request()
1018 _version = reader.read("!B")[0]
1019 assert(_version == 1)
1020 _type = reader.read("!B")[0]
1021 assert(_type == 4)
1022 _length = reader.read("!H")[0]
1023 orig_reader = reader
1024 reader = orig_reader.slice(_length, 4)
1025 obj.xid = reader.read("!L")[0]
1026 _experimenter = reader.read("!L")[0]
1027 assert(_experimenter == 6035143)
1028 _subtype = reader.read("!L")[0]
1029 assert(_subtype == 21)
1030 return obj
1031
1032 def __eq__(self, other):
1033 if type(self) != type(other): return False
1034 if self.xid != other.xid: return False
1035 return True
1036
1037 def pretty_print(self, q):
1038 q.text("bsn_bw_clear_data_request {")
1039 with q.group():
1040 with q.indent(2):
1041 q.breakable()
1042 q.text("xid = ");
1043 if self.xid != None:
1044 q.text("%#x" % self.xid)
1045 else:
1046 q.text('None')
1047 q.breakable()
1048 q.text('}')
1049
1050bsn_header.subtypes[21] = bsn_bw_clear_data_request
1051
1052class bsn_bw_enable_get_reply(bsn_header):
1053 version = 1
1054 type = 4
1055 experimenter = 6035143
1056 subtype = 20
1057
1058 def __init__(self, xid=None, enabled=None):
1059 if xid != None:
1060 self.xid = xid
1061 else:
1062 self.xid = None
1063 if enabled != None:
1064 self.enabled = enabled
1065 else:
1066 self.enabled = 0
1067 return
1068
1069 def pack(self):
1070 packed = []
1071 packed.append(struct.pack("!B", self.version))
1072 packed.append(struct.pack("!B", self.type))
1073 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1074 packed.append(struct.pack("!L", self.xid))
1075 packed.append(struct.pack("!L", self.experimenter))
1076 packed.append(struct.pack("!L", self.subtype))
1077 packed.append(struct.pack("!L", self.enabled))
1078 length = sum([len(x) for x in packed])
1079 packed[2] = struct.pack("!H", length)
1080 return ''.join(packed)
1081
1082 @staticmethod
1083 def unpack(reader):
1084 obj = bsn_bw_enable_get_reply()
1085 _version = reader.read("!B")[0]
1086 assert(_version == 1)
1087 _type = reader.read("!B")[0]
1088 assert(_type == 4)
1089 _length = reader.read("!H")[0]
1090 orig_reader = reader
1091 reader = orig_reader.slice(_length, 4)
1092 obj.xid = reader.read("!L")[0]
1093 _experimenter = reader.read("!L")[0]
1094 assert(_experimenter == 6035143)
1095 _subtype = reader.read("!L")[0]
1096 assert(_subtype == 20)
1097 obj.enabled = reader.read("!L")[0]
1098 return obj
1099
1100 def __eq__(self, other):
1101 if type(self) != type(other): return False
1102 if self.xid != other.xid: return False
1103 if self.enabled != other.enabled: return False
1104 return True
1105
1106 def pretty_print(self, q):
1107 q.text("bsn_bw_enable_get_reply {")
1108 with q.group():
1109 with q.indent(2):
1110 q.breakable()
1111 q.text("xid = ");
1112 if self.xid != None:
1113 q.text("%#x" % self.xid)
1114 else:
1115 q.text('None')
1116 q.text(","); q.breakable()
1117 q.text("enabled = ");
1118 q.text("%#x" % self.enabled)
1119 q.breakable()
1120 q.text('}')
1121
1122bsn_header.subtypes[20] = bsn_bw_enable_get_reply
1123
1124class bsn_bw_enable_get_request(bsn_header):
1125 version = 1
1126 type = 4
1127 experimenter = 6035143
1128 subtype = 19
1129
1130 def __init__(self, xid=None):
1131 if xid != None:
1132 self.xid = xid
1133 else:
1134 self.xid = None
1135 return
1136
1137 def pack(self):
1138 packed = []
1139 packed.append(struct.pack("!B", self.version))
1140 packed.append(struct.pack("!B", self.type))
1141 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1142 packed.append(struct.pack("!L", self.xid))
1143 packed.append(struct.pack("!L", self.experimenter))
1144 packed.append(struct.pack("!L", self.subtype))
1145 length = sum([len(x) for x in packed])
1146 packed[2] = struct.pack("!H", length)
1147 return ''.join(packed)
1148
1149 @staticmethod
1150 def unpack(reader):
1151 obj = bsn_bw_enable_get_request()
1152 _version = reader.read("!B")[0]
1153 assert(_version == 1)
1154 _type = reader.read("!B")[0]
1155 assert(_type == 4)
1156 _length = reader.read("!H")[0]
1157 orig_reader = reader
1158 reader = orig_reader.slice(_length, 4)
1159 obj.xid = reader.read("!L")[0]
1160 _experimenter = reader.read("!L")[0]
1161 assert(_experimenter == 6035143)
1162 _subtype = reader.read("!L")[0]
1163 assert(_subtype == 19)
1164 return obj
1165
1166 def __eq__(self, other):
1167 if type(self) != type(other): return False
1168 if self.xid != other.xid: return False
1169 return True
1170
1171 def pretty_print(self, q):
1172 q.text("bsn_bw_enable_get_request {")
1173 with q.group():
1174 with q.indent(2):
1175 q.breakable()
1176 q.text("xid = ");
1177 if self.xid != None:
1178 q.text("%#x" % self.xid)
1179 else:
1180 q.text('None')
1181 q.breakable()
1182 q.text('}')
1183
1184bsn_header.subtypes[19] = bsn_bw_enable_get_request
1185
1186class bsn_bw_enable_set_reply(bsn_header):
1187 version = 1
1188 type = 4
1189 experimenter = 6035143
1190 subtype = 23
1191
1192 def __init__(self, xid=None, enable=None, status=None):
1193 if xid != None:
1194 self.xid = xid
1195 else:
1196 self.xid = None
1197 if enable != None:
1198 self.enable = enable
1199 else:
1200 self.enable = 0
1201 if status != None:
1202 self.status = status
1203 else:
1204 self.status = 0
1205 return
1206
1207 def pack(self):
1208 packed = []
1209 packed.append(struct.pack("!B", self.version))
1210 packed.append(struct.pack("!B", self.type))
1211 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1212 packed.append(struct.pack("!L", self.xid))
1213 packed.append(struct.pack("!L", self.experimenter))
1214 packed.append(struct.pack("!L", self.subtype))
1215 packed.append(struct.pack("!L", self.enable))
1216 packed.append(struct.pack("!L", self.status))
1217 length = sum([len(x) for x in packed])
1218 packed[2] = struct.pack("!H", length)
1219 return ''.join(packed)
1220
1221 @staticmethod
1222 def unpack(reader):
1223 obj = bsn_bw_enable_set_reply()
1224 _version = reader.read("!B")[0]
1225 assert(_version == 1)
1226 _type = reader.read("!B")[0]
1227 assert(_type == 4)
1228 _length = reader.read("!H")[0]
1229 orig_reader = reader
1230 reader = orig_reader.slice(_length, 4)
1231 obj.xid = reader.read("!L")[0]
1232 _experimenter = reader.read("!L")[0]
1233 assert(_experimenter == 6035143)
1234 _subtype = reader.read("!L")[0]
1235 assert(_subtype == 23)
1236 obj.enable = reader.read("!L")[0]
1237 obj.status = reader.read("!L")[0]
1238 return obj
1239
1240 def __eq__(self, other):
1241 if type(self) != type(other): return False
1242 if self.xid != other.xid: return False
1243 if self.enable != other.enable: return False
1244 if self.status != other.status: return False
1245 return True
1246
1247 def pretty_print(self, q):
1248 q.text("bsn_bw_enable_set_reply {")
1249 with q.group():
1250 with q.indent(2):
1251 q.breakable()
1252 q.text("xid = ");
1253 if self.xid != None:
1254 q.text("%#x" % self.xid)
1255 else:
1256 q.text('None')
1257 q.text(","); q.breakable()
1258 q.text("enable = ");
1259 q.text("%#x" % self.enable)
1260 q.text(","); q.breakable()
1261 q.text("status = ");
1262 q.text("%#x" % self.status)
1263 q.breakable()
1264 q.text('}')
1265
1266bsn_header.subtypes[23] = bsn_bw_enable_set_reply
1267
1268class bsn_bw_enable_set_request(bsn_header):
1269 version = 1
1270 type = 4
1271 experimenter = 6035143
1272 subtype = 18
1273
1274 def __init__(self, xid=None, enable=None):
1275 if xid != None:
1276 self.xid = xid
1277 else:
1278 self.xid = None
1279 if enable != None:
1280 self.enable = enable
1281 else:
1282 self.enable = 0
1283 return
1284
1285 def pack(self):
1286 packed = []
1287 packed.append(struct.pack("!B", self.version))
1288 packed.append(struct.pack("!B", self.type))
1289 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1290 packed.append(struct.pack("!L", self.xid))
1291 packed.append(struct.pack("!L", self.experimenter))
1292 packed.append(struct.pack("!L", self.subtype))
1293 packed.append(struct.pack("!L", self.enable))
1294 length = sum([len(x) for x in packed])
1295 packed[2] = struct.pack("!H", length)
1296 return ''.join(packed)
1297
1298 @staticmethod
1299 def unpack(reader):
1300 obj = bsn_bw_enable_set_request()
1301 _version = reader.read("!B")[0]
1302 assert(_version == 1)
1303 _type = reader.read("!B")[0]
1304 assert(_type == 4)
1305 _length = reader.read("!H")[0]
1306 orig_reader = reader
1307 reader = orig_reader.slice(_length, 4)
1308 obj.xid = reader.read("!L")[0]
1309 _experimenter = reader.read("!L")[0]
1310 assert(_experimenter == 6035143)
1311 _subtype = reader.read("!L")[0]
1312 assert(_subtype == 18)
1313 obj.enable = reader.read("!L")[0]
1314 return obj
1315
1316 def __eq__(self, other):
1317 if type(self) != type(other): return False
1318 if self.xid != other.xid: return False
1319 if self.enable != other.enable: return False
1320 return True
1321
1322 def pretty_print(self, q):
1323 q.text("bsn_bw_enable_set_request {")
1324 with q.group():
1325 with q.indent(2):
1326 q.breakable()
1327 q.text("xid = ");
1328 if self.xid != None:
1329 q.text("%#x" % self.xid)
1330 else:
1331 q.text('None')
1332 q.text(","); q.breakable()
1333 q.text("enable = ");
1334 q.text("%#x" % self.enable)
1335 q.breakable()
1336 q.text('}')
1337
1338bsn_header.subtypes[18] = bsn_bw_enable_set_request
1339
1340class bsn_get_interfaces_reply(bsn_header):
1341 version = 1
1342 type = 4
1343 experimenter = 6035143
1344 subtype = 10
1345
1346 def __init__(self, xid=None, interfaces=None):
1347 if xid != None:
1348 self.xid = xid
1349 else:
1350 self.xid = None
1351 if interfaces != None:
1352 self.interfaces = interfaces
1353 else:
1354 self.interfaces = []
1355 return
1356
1357 def pack(self):
1358 packed = []
1359 packed.append(struct.pack("!B", self.version))
1360 packed.append(struct.pack("!B", self.type))
1361 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1362 packed.append(struct.pack("!L", self.xid))
1363 packed.append(struct.pack("!L", self.experimenter))
1364 packed.append(struct.pack("!L", self.subtype))
1365 packed.append(loxi.generic_util.pack_list(self.interfaces))
1366 length = sum([len(x) for x in packed])
1367 packed[2] = struct.pack("!H", length)
1368 return ''.join(packed)
1369
1370 @staticmethod
1371 def unpack(reader):
1372 obj = bsn_get_interfaces_reply()
1373 _version = reader.read("!B")[0]
1374 assert(_version == 1)
1375 _type = reader.read("!B")[0]
1376 assert(_type == 4)
1377 _length = reader.read("!H")[0]
1378 orig_reader = reader
1379 reader = orig_reader.slice(_length, 4)
1380 obj.xid = reader.read("!L")[0]
1381 _experimenter = reader.read("!L")[0]
1382 assert(_experimenter == 6035143)
1383 _subtype = reader.read("!L")[0]
1384 assert(_subtype == 10)
1385 obj.interfaces = loxi.generic_util.unpack_list(reader, ofp.common.bsn_interface.unpack)
1386 return obj
1387
1388 def __eq__(self, other):
1389 if type(self) != type(other): return False
1390 if self.xid != other.xid: return False
1391 if self.interfaces != other.interfaces: return False
1392 return True
1393
1394 def pretty_print(self, q):
1395 q.text("bsn_get_interfaces_reply {")
1396 with q.group():
1397 with q.indent(2):
1398 q.breakable()
1399 q.text("xid = ");
1400 if self.xid != None:
1401 q.text("%#x" % self.xid)
1402 else:
1403 q.text('None')
1404 q.text(","); q.breakable()
1405 q.text("interfaces = ");
1406 q.pp(self.interfaces)
1407 q.breakable()
1408 q.text('}')
1409
1410bsn_header.subtypes[10] = bsn_get_interfaces_reply
1411
1412class bsn_get_interfaces_request(bsn_header):
1413 version = 1
1414 type = 4
1415 experimenter = 6035143
1416 subtype = 9
1417
1418 def __init__(self, xid=None):
1419 if xid != None:
1420 self.xid = xid
1421 else:
1422 self.xid = None
1423 return
1424
1425 def pack(self):
1426 packed = []
1427 packed.append(struct.pack("!B", self.version))
1428 packed.append(struct.pack("!B", self.type))
1429 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1430 packed.append(struct.pack("!L", self.xid))
1431 packed.append(struct.pack("!L", self.experimenter))
1432 packed.append(struct.pack("!L", self.subtype))
1433 length = sum([len(x) for x in packed])
1434 packed[2] = struct.pack("!H", length)
1435 return ''.join(packed)
1436
1437 @staticmethod
1438 def unpack(reader):
1439 obj = bsn_get_interfaces_request()
1440 _version = reader.read("!B")[0]
1441 assert(_version == 1)
1442 _type = reader.read("!B")[0]
1443 assert(_type == 4)
1444 _length = reader.read("!H")[0]
1445 orig_reader = reader
1446 reader = orig_reader.slice(_length, 4)
1447 obj.xid = reader.read("!L")[0]
1448 _experimenter = reader.read("!L")[0]
1449 assert(_experimenter == 6035143)
1450 _subtype = reader.read("!L")[0]
1451 assert(_subtype == 9)
1452 return obj
1453
1454 def __eq__(self, other):
1455 if type(self) != type(other): return False
1456 if self.xid != other.xid: return False
1457 return True
1458
1459 def pretty_print(self, q):
1460 q.text("bsn_get_interfaces_request {")
1461 with q.group():
1462 with q.indent(2):
1463 q.breakable()
1464 q.text("xid = ");
1465 if self.xid != None:
1466 q.text("%#x" % self.xid)
1467 else:
1468 q.text('None')
1469 q.breakable()
1470 q.text('}')
1471
1472bsn_header.subtypes[9] = bsn_get_interfaces_request
1473
1474class bsn_get_ip_mask_reply(bsn_header):
1475 version = 1
1476 type = 4
1477 experimenter = 6035143
1478 subtype = 2
1479
1480 def __init__(self, xid=None, index=None, mask=None):
1481 if xid != None:
1482 self.xid = xid
1483 else:
1484 self.xid = None
1485 if index != None:
1486 self.index = index
1487 else:
1488 self.index = 0
1489 if mask != None:
1490 self.mask = mask
1491 else:
1492 self.mask = 0
1493 return
1494
1495 def pack(self):
1496 packed = []
1497 packed.append(struct.pack("!B", self.version))
1498 packed.append(struct.pack("!B", self.type))
1499 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1500 packed.append(struct.pack("!L", self.xid))
1501 packed.append(struct.pack("!L", self.experimenter))
1502 packed.append(struct.pack("!L", self.subtype))
1503 packed.append(struct.pack("!B", self.index))
1504 packed.append('\x00' * 3)
1505 packed.append(struct.pack("!L", self.mask))
1506 length = sum([len(x) for x in packed])
1507 packed[2] = struct.pack("!H", length)
1508 return ''.join(packed)
1509
1510 @staticmethod
1511 def unpack(reader):
1512 obj = bsn_get_ip_mask_reply()
1513 _version = reader.read("!B")[0]
1514 assert(_version == 1)
1515 _type = reader.read("!B")[0]
1516 assert(_type == 4)
1517 _length = reader.read("!H")[0]
1518 orig_reader = reader
1519 reader = orig_reader.slice(_length, 4)
1520 obj.xid = reader.read("!L")[0]
1521 _experimenter = reader.read("!L")[0]
1522 assert(_experimenter == 6035143)
1523 _subtype = reader.read("!L")[0]
1524 assert(_subtype == 2)
1525 obj.index = reader.read("!B")[0]
1526 reader.skip(3)
1527 obj.mask = reader.read("!L")[0]
1528 return obj
1529
1530 def __eq__(self, other):
1531 if type(self) != type(other): return False
1532 if self.xid != other.xid: return False
1533 if self.index != other.index: return False
1534 if self.mask != other.mask: return False
1535 return True
1536
1537 def pretty_print(self, q):
1538 q.text("bsn_get_ip_mask_reply {")
1539 with q.group():
1540 with q.indent(2):
1541 q.breakable()
1542 q.text("xid = ");
1543 if self.xid != None:
1544 q.text("%#x" % self.xid)
1545 else:
1546 q.text('None')
1547 q.text(","); q.breakable()
1548 q.text("index = ");
1549 q.text("%#x" % self.index)
1550 q.text(","); q.breakable()
1551 q.text("mask = ");
1552 q.text("%#x" % self.mask)
1553 q.breakable()
1554 q.text('}')
1555
1556bsn_header.subtypes[2] = bsn_get_ip_mask_reply
1557
1558class bsn_get_ip_mask_request(bsn_header):
1559 version = 1
1560 type = 4
1561 experimenter = 6035143
1562 subtype = 1
1563
1564 def __init__(self, xid=None, index=None):
1565 if xid != None:
1566 self.xid = xid
1567 else:
1568 self.xid = None
1569 if index != None:
1570 self.index = index
1571 else:
1572 self.index = 0
1573 return
1574
1575 def pack(self):
1576 packed = []
1577 packed.append(struct.pack("!B", self.version))
1578 packed.append(struct.pack("!B", self.type))
1579 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1580 packed.append(struct.pack("!L", self.xid))
1581 packed.append(struct.pack("!L", self.experimenter))
1582 packed.append(struct.pack("!L", self.subtype))
1583 packed.append(struct.pack("!B", self.index))
1584 packed.append('\x00' * 7)
1585 length = sum([len(x) for x in packed])
1586 packed[2] = struct.pack("!H", length)
1587 return ''.join(packed)
1588
1589 @staticmethod
1590 def unpack(reader):
1591 obj = bsn_get_ip_mask_request()
1592 _version = reader.read("!B")[0]
1593 assert(_version == 1)
1594 _type = reader.read("!B")[0]
1595 assert(_type == 4)
1596 _length = reader.read("!H")[0]
1597 orig_reader = reader
1598 reader = orig_reader.slice(_length, 4)
1599 obj.xid = reader.read("!L")[0]
1600 _experimenter = reader.read("!L")[0]
1601 assert(_experimenter == 6035143)
1602 _subtype = reader.read("!L")[0]
1603 assert(_subtype == 1)
1604 obj.index = reader.read("!B")[0]
1605 reader.skip(7)
1606 return obj
1607
1608 def __eq__(self, other):
1609 if type(self) != type(other): return False
1610 if self.xid != other.xid: return False
1611 if self.index != other.index: return False
1612 return True
1613
1614 def pretty_print(self, q):
1615 q.text("bsn_get_ip_mask_request {")
1616 with q.group():
1617 with q.indent(2):
1618 q.breakable()
1619 q.text("xid = ");
1620 if self.xid != None:
1621 q.text("%#x" % self.xid)
1622 else:
1623 q.text('None')
1624 q.text(","); q.breakable()
1625 q.text("index = ");
1626 q.text("%#x" % self.index)
1627 q.breakable()
1628 q.text('}')
1629
1630bsn_header.subtypes[1] = bsn_get_ip_mask_request
1631
1632class bsn_get_l2_table_reply(bsn_header):
1633 version = 1
1634 type = 4
1635 experimenter = 6035143
1636 subtype = 14
1637
1638 def __init__(self, xid=None, l2_table_enable=None, l2_table_priority=None):
1639 if xid != None:
1640 self.xid = xid
1641 else:
1642 self.xid = None
1643 if l2_table_enable != None:
1644 self.l2_table_enable = l2_table_enable
1645 else:
1646 self.l2_table_enable = 0
1647 if l2_table_priority != None:
1648 self.l2_table_priority = l2_table_priority
1649 else:
1650 self.l2_table_priority = 0
1651 return
1652
1653 def pack(self):
1654 packed = []
1655 packed.append(struct.pack("!B", self.version))
1656 packed.append(struct.pack("!B", self.type))
1657 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1658 packed.append(struct.pack("!L", self.xid))
1659 packed.append(struct.pack("!L", self.experimenter))
1660 packed.append(struct.pack("!L", self.subtype))
1661 packed.append(struct.pack("!B", self.l2_table_enable))
1662 packed.append('\x00' * 1)
1663 packed.append(struct.pack("!H", self.l2_table_priority))
1664 packed.append('\x00' * 4)
1665 length = sum([len(x) for x in packed])
1666 packed[2] = struct.pack("!H", length)
1667 return ''.join(packed)
1668
1669 @staticmethod
1670 def unpack(reader):
1671 obj = bsn_get_l2_table_reply()
1672 _version = reader.read("!B")[0]
1673 assert(_version == 1)
1674 _type = reader.read("!B")[0]
1675 assert(_type == 4)
1676 _length = reader.read("!H")[0]
1677 orig_reader = reader
1678 reader = orig_reader.slice(_length, 4)
1679 obj.xid = reader.read("!L")[0]
1680 _experimenter = reader.read("!L")[0]
1681 assert(_experimenter == 6035143)
1682 _subtype = reader.read("!L")[0]
1683 assert(_subtype == 14)
1684 obj.l2_table_enable = reader.read("!B")[0]
1685 reader.skip(1)
1686 obj.l2_table_priority = reader.read("!H")[0]
1687 reader.skip(4)
1688 return obj
1689
1690 def __eq__(self, other):
1691 if type(self) != type(other): return False
1692 if self.xid != other.xid: return False
1693 if self.l2_table_enable != other.l2_table_enable: return False
1694 if self.l2_table_priority != other.l2_table_priority: return False
1695 return True
1696
1697 def pretty_print(self, q):
1698 q.text("bsn_get_l2_table_reply {")
1699 with q.group():
1700 with q.indent(2):
1701 q.breakable()
1702 q.text("xid = ");
1703 if self.xid != None:
1704 q.text("%#x" % self.xid)
1705 else:
1706 q.text('None')
1707 q.text(","); q.breakable()
1708 q.text("l2_table_enable = ");
1709 q.text("%#x" % self.l2_table_enable)
1710 q.text(","); q.breakable()
1711 q.text("l2_table_priority = ");
1712 q.text("%#x" % self.l2_table_priority)
1713 q.breakable()
1714 q.text('}')
1715
1716bsn_header.subtypes[14] = bsn_get_l2_table_reply
1717
1718class bsn_get_l2_table_request(bsn_header):
1719 version = 1
1720 type = 4
1721 experimenter = 6035143
1722 subtype = 13
1723
1724 def __init__(self, xid=None):
1725 if xid != None:
1726 self.xid = xid
1727 else:
1728 self.xid = None
1729 return
1730
1731 def pack(self):
1732 packed = []
1733 packed.append(struct.pack("!B", self.version))
1734 packed.append(struct.pack("!B", self.type))
1735 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1736 packed.append(struct.pack("!L", self.xid))
1737 packed.append(struct.pack("!L", self.experimenter))
1738 packed.append(struct.pack("!L", self.subtype))
1739 length = sum([len(x) for x in packed])
1740 packed[2] = struct.pack("!H", length)
1741 return ''.join(packed)
1742
1743 @staticmethod
1744 def unpack(reader):
1745 obj = bsn_get_l2_table_request()
1746 _version = reader.read("!B")[0]
1747 assert(_version == 1)
1748 _type = reader.read("!B")[0]
1749 assert(_type == 4)
1750 _length = reader.read("!H")[0]
1751 orig_reader = reader
1752 reader = orig_reader.slice(_length, 4)
1753 obj.xid = reader.read("!L")[0]
1754 _experimenter = reader.read("!L")[0]
1755 assert(_experimenter == 6035143)
1756 _subtype = reader.read("!L")[0]
1757 assert(_subtype == 13)
1758 return obj
1759
1760 def __eq__(self, other):
1761 if type(self) != type(other): return False
1762 if self.xid != other.xid: return False
1763 return True
1764
1765 def pretty_print(self, q):
1766 q.text("bsn_get_l2_table_request {")
1767 with q.group():
1768 with q.indent(2):
1769 q.breakable()
1770 q.text("xid = ");
1771 if self.xid != None:
1772 q.text("%#x" % self.xid)
1773 else:
1774 q.text('None')
1775 q.breakable()
1776 q.text('}')
1777
1778bsn_header.subtypes[13] = bsn_get_l2_table_request
1779
1780class bsn_get_mirroring_reply(bsn_header):
1781 version = 1
1782 type = 4
1783 experimenter = 6035143
1784 subtype = 5
1785
1786 def __init__(self, xid=None, report_mirror_ports=None):
1787 if xid != None:
1788 self.xid = xid
1789 else:
1790 self.xid = None
1791 if report_mirror_ports != None:
1792 self.report_mirror_ports = report_mirror_ports
1793 else:
1794 self.report_mirror_ports = 0
1795 return
1796
1797 def pack(self):
1798 packed = []
1799 packed.append(struct.pack("!B", self.version))
1800 packed.append(struct.pack("!B", self.type))
1801 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1802 packed.append(struct.pack("!L", self.xid))
1803 packed.append(struct.pack("!L", self.experimenter))
1804 packed.append(struct.pack("!L", self.subtype))
1805 packed.append(struct.pack("!B", self.report_mirror_ports))
1806 packed.append('\x00' * 3)
1807 length = sum([len(x) for x in packed])
1808 packed[2] = struct.pack("!H", length)
1809 return ''.join(packed)
1810
1811 @staticmethod
1812 def unpack(reader):
1813 obj = bsn_get_mirroring_reply()
1814 _version = reader.read("!B")[0]
1815 assert(_version == 1)
1816 _type = reader.read("!B")[0]
1817 assert(_type == 4)
1818 _length = reader.read("!H")[0]
1819 orig_reader = reader
1820 reader = orig_reader.slice(_length, 4)
1821 obj.xid = reader.read("!L")[0]
1822 _experimenter = reader.read("!L")[0]
1823 assert(_experimenter == 6035143)
1824 _subtype = reader.read("!L")[0]
1825 assert(_subtype == 5)
1826 obj.report_mirror_ports = reader.read("!B")[0]
1827 reader.skip(3)
1828 return obj
1829
1830 def __eq__(self, other):
1831 if type(self) != type(other): return False
1832 if self.xid != other.xid: return False
1833 if self.report_mirror_ports != other.report_mirror_ports: return False
1834 return True
1835
1836 def pretty_print(self, q):
1837 q.text("bsn_get_mirroring_reply {")
1838 with q.group():
1839 with q.indent(2):
1840 q.breakable()
1841 q.text("xid = ");
1842 if self.xid != None:
1843 q.text("%#x" % self.xid)
1844 else:
1845 q.text('None')
1846 q.text(","); q.breakable()
1847 q.text("report_mirror_ports = ");
1848 q.text("%#x" % self.report_mirror_ports)
1849 q.breakable()
1850 q.text('}')
1851
1852bsn_header.subtypes[5] = bsn_get_mirroring_reply
1853
1854class bsn_get_mirroring_request(bsn_header):
1855 version = 1
1856 type = 4
1857 experimenter = 6035143
1858 subtype = 4
1859
1860 def __init__(self, xid=None, report_mirror_ports=None):
1861 if xid != None:
1862 self.xid = xid
1863 else:
1864 self.xid = None
1865 if report_mirror_ports != None:
1866 self.report_mirror_ports = report_mirror_ports
1867 else:
1868 self.report_mirror_ports = 0
1869 return
1870
1871 def pack(self):
1872 packed = []
1873 packed.append(struct.pack("!B", self.version))
1874 packed.append(struct.pack("!B", self.type))
1875 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1876 packed.append(struct.pack("!L", self.xid))
1877 packed.append(struct.pack("!L", self.experimenter))
1878 packed.append(struct.pack("!L", self.subtype))
1879 packed.append(struct.pack("!B", self.report_mirror_ports))
1880 packed.append('\x00' * 3)
1881 length = sum([len(x) for x in packed])
1882 packed[2] = struct.pack("!H", length)
1883 return ''.join(packed)
1884
1885 @staticmethod
1886 def unpack(reader):
1887 obj = bsn_get_mirroring_request()
1888 _version = reader.read("!B")[0]
1889 assert(_version == 1)
1890 _type = reader.read("!B")[0]
1891 assert(_type == 4)
1892 _length = reader.read("!H")[0]
1893 orig_reader = reader
1894 reader = orig_reader.slice(_length, 4)
1895 obj.xid = reader.read("!L")[0]
1896 _experimenter = reader.read("!L")[0]
1897 assert(_experimenter == 6035143)
1898 _subtype = reader.read("!L")[0]
1899 assert(_subtype == 4)
1900 obj.report_mirror_ports = reader.read("!B")[0]
1901 reader.skip(3)
1902 return obj
1903
1904 def __eq__(self, other):
1905 if type(self) != type(other): return False
1906 if self.xid != other.xid: return False
1907 if self.report_mirror_ports != other.report_mirror_ports: return False
1908 return True
1909
1910 def pretty_print(self, q):
1911 q.text("bsn_get_mirroring_request {")
1912 with q.group():
1913 with q.indent(2):
1914 q.breakable()
1915 q.text("xid = ");
1916 if self.xid != None:
1917 q.text("%#x" % self.xid)
1918 else:
1919 q.text('None')
1920 q.text(","); q.breakable()
1921 q.text("report_mirror_ports = ");
1922 q.text("%#x" % self.report_mirror_ports)
1923 q.breakable()
1924 q.text('}')
1925
1926bsn_header.subtypes[4] = bsn_get_mirroring_request
1927
1928class bsn_hybrid_get_reply(bsn_header):
1929 version = 1
1930 type = 4
1931 experimenter = 6035143
1932 subtype = 28
1933
1934 def __init__(self, xid=None, hybrid_enable=None, hybrid_version=None):
1935 if xid != None:
1936 self.xid = xid
1937 else:
1938 self.xid = None
1939 if hybrid_enable != None:
1940 self.hybrid_enable = hybrid_enable
1941 else:
1942 self.hybrid_enable = 0
1943 if hybrid_version != None:
1944 self.hybrid_version = hybrid_version
1945 else:
1946 self.hybrid_version = 0
1947 return
1948
1949 def pack(self):
1950 packed = []
1951 packed.append(struct.pack("!B", self.version))
1952 packed.append(struct.pack("!B", self.type))
1953 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1954 packed.append(struct.pack("!L", self.xid))
1955 packed.append(struct.pack("!L", self.experimenter))
1956 packed.append(struct.pack("!L", self.subtype))
1957 packed.append(struct.pack("!B", self.hybrid_enable))
1958 packed.append('\x00' * 1)
1959 packed.append(struct.pack("!H", self.hybrid_version))
1960 packed.append('\x00' * 4)
1961 length = sum([len(x) for x in packed])
1962 packed[2] = struct.pack("!H", length)
1963 return ''.join(packed)
1964
1965 @staticmethod
1966 def unpack(reader):
1967 obj = bsn_hybrid_get_reply()
1968 _version = reader.read("!B")[0]
1969 assert(_version == 1)
1970 _type = reader.read("!B")[0]
1971 assert(_type == 4)
1972 _length = reader.read("!H")[0]
1973 orig_reader = reader
1974 reader = orig_reader.slice(_length, 4)
1975 obj.xid = reader.read("!L")[0]
1976 _experimenter = reader.read("!L")[0]
1977 assert(_experimenter == 6035143)
1978 _subtype = reader.read("!L")[0]
1979 assert(_subtype == 28)
1980 obj.hybrid_enable = reader.read("!B")[0]
1981 reader.skip(1)
1982 obj.hybrid_version = reader.read("!H")[0]
1983 reader.skip(4)
1984 return obj
1985
1986 def __eq__(self, other):
1987 if type(self) != type(other): return False
1988 if self.xid != other.xid: return False
1989 if self.hybrid_enable != other.hybrid_enable: return False
1990 if self.hybrid_version != other.hybrid_version: return False
1991 return True
1992
1993 def pretty_print(self, q):
1994 q.text("bsn_hybrid_get_reply {")
1995 with q.group():
1996 with q.indent(2):
1997 q.breakable()
1998 q.text("xid = ");
1999 if self.xid != None:
2000 q.text("%#x" % self.xid)
2001 else:
2002 q.text('None')
2003 q.text(","); q.breakable()
2004 q.text("hybrid_enable = ");
2005 q.text("%#x" % self.hybrid_enable)
2006 q.text(","); q.breakable()
2007 q.text("hybrid_version = ");
2008 q.text("%#x" % self.hybrid_version)
2009 q.breakable()
2010 q.text('}')
2011
2012bsn_header.subtypes[28] = bsn_hybrid_get_reply
2013
2014class bsn_hybrid_get_request(bsn_header):
2015 version = 1
2016 type = 4
2017 experimenter = 6035143
2018 subtype = 27
2019
2020 def __init__(self, xid=None):
2021 if xid != None:
2022 self.xid = xid
2023 else:
2024 self.xid = None
2025 return
2026
2027 def pack(self):
2028 packed = []
2029 packed.append(struct.pack("!B", self.version))
2030 packed.append(struct.pack("!B", self.type))
2031 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2032 packed.append(struct.pack("!L", self.xid))
2033 packed.append(struct.pack("!L", self.experimenter))
2034 packed.append(struct.pack("!L", self.subtype))
2035 length = sum([len(x) for x in packed])
2036 packed[2] = struct.pack("!H", length)
2037 return ''.join(packed)
2038
2039 @staticmethod
2040 def unpack(reader):
2041 obj = bsn_hybrid_get_request()
2042 _version = reader.read("!B")[0]
2043 assert(_version == 1)
2044 _type = reader.read("!B")[0]
2045 assert(_type == 4)
2046 _length = reader.read("!H")[0]
2047 orig_reader = reader
2048 reader = orig_reader.slice(_length, 4)
2049 obj.xid = reader.read("!L")[0]
2050 _experimenter = reader.read("!L")[0]
2051 assert(_experimenter == 6035143)
2052 _subtype = reader.read("!L")[0]
2053 assert(_subtype == 27)
2054 return obj
2055
2056 def __eq__(self, other):
2057 if type(self) != type(other): return False
2058 if self.xid != other.xid: return False
2059 return True
2060
2061 def pretty_print(self, q):
2062 q.text("bsn_hybrid_get_request {")
2063 with q.group():
2064 with q.indent(2):
2065 q.breakable()
2066 q.text("xid = ");
2067 if self.xid != None:
2068 q.text("%#x" % self.xid)
2069 else:
2070 q.text('None')
2071 q.breakable()
2072 q.text('}')
2073
2074bsn_header.subtypes[27] = bsn_hybrid_get_request
2075
2076class bsn_pdu_rx_reply(bsn_header):
2077 version = 1
2078 type = 4
2079 experimenter = 6035143
2080 subtype = 34
2081
2082 def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
2083 if xid != None:
2084 self.xid = xid
2085 else:
2086 self.xid = None
2087 if status != None:
2088 self.status = status
2089 else:
2090 self.status = 0
2091 if port_no != None:
2092 self.port_no = port_no
2093 else:
2094 self.port_no = 0
2095 if slot_num != None:
2096 self.slot_num = slot_num
2097 else:
2098 self.slot_num = 0
2099 return
2100
2101 def pack(self):
2102 packed = []
2103 packed.append(struct.pack("!B", self.version))
2104 packed.append(struct.pack("!B", self.type))
2105 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2106 packed.append(struct.pack("!L", self.xid))
2107 packed.append(struct.pack("!L", self.experimenter))
2108 packed.append(struct.pack("!L", self.subtype))
2109 packed.append(struct.pack("!L", self.status))
2110 packed.append(util.pack_port_no(self.port_no))
2111 packed.append(struct.pack("!B", self.slot_num))
2112 length = sum([len(x) for x in packed])
2113 packed[2] = struct.pack("!H", length)
2114 return ''.join(packed)
2115
2116 @staticmethod
2117 def unpack(reader):
2118 obj = bsn_pdu_rx_reply()
2119 _version = reader.read("!B")[0]
2120 assert(_version == 1)
2121 _type = reader.read("!B")[0]
2122 assert(_type == 4)
2123 _length = reader.read("!H")[0]
2124 orig_reader = reader
2125 reader = orig_reader.slice(_length, 4)
2126 obj.xid = reader.read("!L")[0]
2127 _experimenter = reader.read("!L")[0]
2128 assert(_experimenter == 6035143)
2129 _subtype = reader.read("!L")[0]
2130 assert(_subtype == 34)
2131 obj.status = reader.read("!L")[0]
2132 obj.port_no = util.unpack_port_no(reader)
2133 obj.slot_num = reader.read("!B")[0]
2134 return obj
2135
2136 def __eq__(self, other):
2137 if type(self) != type(other): return False
2138 if self.xid != other.xid: return False
2139 if self.status != other.status: return False
2140 if self.port_no != other.port_no: return False
2141 if self.slot_num != other.slot_num: return False
2142 return True
2143
2144 def pretty_print(self, q):
2145 q.text("bsn_pdu_rx_reply {")
2146 with q.group():
2147 with q.indent(2):
2148 q.breakable()
2149 q.text("xid = ");
2150 if self.xid != None:
2151 q.text("%#x" % self.xid)
2152 else:
2153 q.text('None')
2154 q.text(","); q.breakable()
2155 q.text("status = ");
2156 q.text("%#x" % self.status)
2157 q.text(","); q.breakable()
2158 q.text("port_no = ");
2159 q.text(util.pretty_port(self.port_no))
2160 q.text(","); q.breakable()
2161 q.text("slot_num = ");
2162 q.text("%#x" % self.slot_num)
2163 q.breakable()
2164 q.text('}')
2165
2166bsn_header.subtypes[34] = bsn_pdu_rx_reply
2167
2168class bsn_pdu_rx_request(bsn_header):
2169 version = 1
2170 type = 4
2171 experimenter = 6035143
2172 subtype = 33
2173
2174 def __init__(self, xid=None, timeout_ms=None, port_no=None, slot_num=None, data=None):
2175 if xid != None:
2176 self.xid = xid
2177 else:
2178 self.xid = None
2179 if timeout_ms != None:
2180 self.timeout_ms = timeout_ms
2181 else:
2182 self.timeout_ms = 0
2183 if port_no != None:
2184 self.port_no = port_no
2185 else:
2186 self.port_no = 0
2187 if slot_num != None:
2188 self.slot_num = slot_num
2189 else:
2190 self.slot_num = 0
2191 if data != None:
2192 self.data = data
2193 else:
2194 self.data = ''
2195 return
2196
2197 def pack(self):
2198 packed = []
2199 packed.append(struct.pack("!B", self.version))
2200 packed.append(struct.pack("!B", self.type))
2201 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2202 packed.append(struct.pack("!L", self.xid))
2203 packed.append(struct.pack("!L", self.experimenter))
2204 packed.append(struct.pack("!L", self.subtype))
2205 packed.append(struct.pack("!L", self.timeout_ms))
2206 packed.append(util.pack_port_no(self.port_no))
2207 packed.append(struct.pack("!B", self.slot_num))
2208 packed.append('\x00' * 3)
2209 packed.append(self.data)
2210 length = sum([len(x) for x in packed])
2211 packed[2] = struct.pack("!H", length)
2212 return ''.join(packed)
2213
2214 @staticmethod
2215 def unpack(reader):
2216 obj = bsn_pdu_rx_request()
2217 _version = reader.read("!B")[0]
2218 assert(_version == 1)
2219 _type = reader.read("!B")[0]
2220 assert(_type == 4)
2221 _length = reader.read("!H")[0]
2222 orig_reader = reader
2223 reader = orig_reader.slice(_length, 4)
2224 obj.xid = reader.read("!L")[0]
2225 _experimenter = reader.read("!L")[0]
2226 assert(_experimenter == 6035143)
2227 _subtype = reader.read("!L")[0]
2228 assert(_subtype == 33)
2229 obj.timeout_ms = reader.read("!L")[0]
2230 obj.port_no = util.unpack_port_no(reader)
2231 obj.slot_num = reader.read("!B")[0]
2232 reader.skip(3)
2233 obj.data = str(reader.read_all())
2234 return obj
2235
2236 def __eq__(self, other):
2237 if type(self) != type(other): return False
2238 if self.xid != other.xid: return False
2239 if self.timeout_ms != other.timeout_ms: return False
2240 if self.port_no != other.port_no: return False
2241 if self.slot_num != other.slot_num: return False
2242 if self.data != other.data: return False
2243 return True
2244
2245 def pretty_print(self, q):
2246 q.text("bsn_pdu_rx_request {")
2247 with q.group():
2248 with q.indent(2):
2249 q.breakable()
2250 q.text("xid = ");
2251 if self.xid != None:
2252 q.text("%#x" % self.xid)
2253 else:
2254 q.text('None')
2255 q.text(","); q.breakable()
2256 q.text("timeout_ms = ");
2257 q.text("%#x" % self.timeout_ms)
2258 q.text(","); q.breakable()
2259 q.text("port_no = ");
2260 q.text(util.pretty_port(self.port_no))
2261 q.text(","); q.breakable()
2262 q.text("slot_num = ");
2263 q.text("%#x" % self.slot_num)
2264 q.text(","); q.breakable()
2265 q.text("data = ");
2266 q.pp(self.data)
2267 q.breakable()
2268 q.text('}')
2269
2270bsn_header.subtypes[33] = bsn_pdu_rx_request
2271
2272class bsn_pdu_rx_timeout(bsn_header):
2273 version = 1
2274 type = 4
2275 experimenter = 6035143
2276 subtype = 35
2277
2278 def __init__(self, xid=None, port_no=None, slot_num=None):
2279 if xid != None:
2280 self.xid = xid
2281 else:
2282 self.xid = None
2283 if port_no != None:
2284 self.port_no = port_no
2285 else:
2286 self.port_no = 0
2287 if slot_num != None:
2288 self.slot_num = slot_num
2289 else:
2290 self.slot_num = 0
2291 return
2292
2293 def pack(self):
2294 packed = []
2295 packed.append(struct.pack("!B", self.version))
2296 packed.append(struct.pack("!B", self.type))
2297 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2298 packed.append(struct.pack("!L", self.xid))
2299 packed.append(struct.pack("!L", self.experimenter))
2300 packed.append(struct.pack("!L", self.subtype))
2301 packed.append(util.pack_port_no(self.port_no))
2302 packed.append(struct.pack("!B", self.slot_num))
2303 length = sum([len(x) for x in packed])
2304 packed[2] = struct.pack("!H", length)
2305 return ''.join(packed)
2306
2307 @staticmethod
2308 def unpack(reader):
2309 obj = bsn_pdu_rx_timeout()
2310 _version = reader.read("!B")[0]
2311 assert(_version == 1)
2312 _type = reader.read("!B")[0]
2313 assert(_type == 4)
2314 _length = reader.read("!H")[0]
2315 orig_reader = reader
2316 reader = orig_reader.slice(_length, 4)
2317 obj.xid = reader.read("!L")[0]
2318 _experimenter = reader.read("!L")[0]
2319 assert(_experimenter == 6035143)
2320 _subtype = reader.read("!L")[0]
2321 assert(_subtype == 35)
2322 obj.port_no = util.unpack_port_no(reader)
2323 obj.slot_num = reader.read("!B")[0]
2324 return obj
2325
2326 def __eq__(self, other):
2327 if type(self) != type(other): return False
2328 if self.xid != other.xid: return False
2329 if self.port_no != other.port_no: return False
2330 if self.slot_num != other.slot_num: return False
2331 return True
2332
2333 def pretty_print(self, q):
2334 q.text("bsn_pdu_rx_timeout {")
2335 with q.group():
2336 with q.indent(2):
2337 q.breakable()
2338 q.text("xid = ");
2339 if self.xid != None:
2340 q.text("%#x" % self.xid)
2341 else:
2342 q.text('None')
2343 q.text(","); q.breakable()
2344 q.text("port_no = ");
2345 q.text(util.pretty_port(self.port_no))
2346 q.text(","); q.breakable()
2347 q.text("slot_num = ");
2348 q.text("%#x" % self.slot_num)
2349 q.breakable()
2350 q.text('}')
2351
2352bsn_header.subtypes[35] = bsn_pdu_rx_timeout
2353
2354class bsn_pdu_tx_reply(bsn_header):
2355 version = 1
2356 type = 4
2357 experimenter = 6035143
2358 subtype = 32
2359
2360 def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
2361 if xid != None:
2362 self.xid = xid
2363 else:
2364 self.xid = None
2365 if status != None:
2366 self.status = status
2367 else:
2368 self.status = 0
2369 if port_no != None:
2370 self.port_no = port_no
2371 else:
2372 self.port_no = 0
2373 if slot_num != None:
2374 self.slot_num = slot_num
2375 else:
2376 self.slot_num = 0
2377 return
2378
2379 def pack(self):
2380 packed = []
2381 packed.append(struct.pack("!B", self.version))
2382 packed.append(struct.pack("!B", self.type))
2383 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2384 packed.append(struct.pack("!L", self.xid))
2385 packed.append(struct.pack("!L", self.experimenter))
2386 packed.append(struct.pack("!L", self.subtype))
2387 packed.append(struct.pack("!L", self.status))
2388 packed.append(util.pack_port_no(self.port_no))
2389 packed.append(struct.pack("!B", self.slot_num))
2390 length = sum([len(x) for x in packed])
2391 packed[2] = struct.pack("!H", length)
2392 return ''.join(packed)
2393
2394 @staticmethod
2395 def unpack(reader):
2396 obj = bsn_pdu_tx_reply()
2397 _version = reader.read("!B")[0]
2398 assert(_version == 1)
2399 _type = reader.read("!B")[0]
2400 assert(_type == 4)
2401 _length = reader.read("!H")[0]
2402 orig_reader = reader
2403 reader = orig_reader.slice(_length, 4)
2404 obj.xid = reader.read("!L")[0]
2405 _experimenter = reader.read("!L")[0]
2406 assert(_experimenter == 6035143)
2407 _subtype = reader.read("!L")[0]
2408 assert(_subtype == 32)
2409 obj.status = reader.read("!L")[0]
2410 obj.port_no = util.unpack_port_no(reader)
2411 obj.slot_num = reader.read("!B")[0]
2412 return obj
2413
2414 def __eq__(self, other):
2415 if type(self) != type(other): return False
2416 if self.xid != other.xid: return False
2417 if self.status != other.status: return False
2418 if self.port_no != other.port_no: return False
2419 if self.slot_num != other.slot_num: return False
2420 return True
2421
2422 def pretty_print(self, q):
2423 q.text("bsn_pdu_tx_reply {")
2424 with q.group():
2425 with q.indent(2):
2426 q.breakable()
2427 q.text("xid = ");
2428 if self.xid != None:
2429 q.text("%#x" % self.xid)
2430 else:
2431 q.text('None')
2432 q.text(","); q.breakable()
2433 q.text("status = ");
2434 q.text("%#x" % self.status)
2435 q.text(","); q.breakable()
2436 q.text("port_no = ");
2437 q.text(util.pretty_port(self.port_no))
2438 q.text(","); q.breakable()
2439 q.text("slot_num = ");
2440 q.text("%#x" % self.slot_num)
2441 q.breakable()
2442 q.text('}')
2443
2444bsn_header.subtypes[32] = bsn_pdu_tx_reply
2445
2446class bsn_pdu_tx_request(bsn_header):
2447 version = 1
2448 type = 4
2449 experimenter = 6035143
2450 subtype = 31
2451
2452 def __init__(self, xid=None, tx_interval_ms=None, port_no=None, slot_num=None, data=None):
2453 if xid != None:
2454 self.xid = xid
2455 else:
2456 self.xid = None
2457 if tx_interval_ms != None:
2458 self.tx_interval_ms = tx_interval_ms
2459 else:
2460 self.tx_interval_ms = 0
2461 if port_no != None:
2462 self.port_no = port_no
2463 else:
2464 self.port_no = 0
2465 if slot_num != None:
2466 self.slot_num = slot_num
2467 else:
2468 self.slot_num = 0
2469 if data != None:
2470 self.data = data
2471 else:
2472 self.data = ''
2473 return
2474
2475 def pack(self):
2476 packed = []
2477 packed.append(struct.pack("!B", self.version))
2478 packed.append(struct.pack("!B", self.type))
2479 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2480 packed.append(struct.pack("!L", self.xid))
2481 packed.append(struct.pack("!L", self.experimenter))
2482 packed.append(struct.pack("!L", self.subtype))
2483 packed.append(struct.pack("!L", self.tx_interval_ms))
2484 packed.append(util.pack_port_no(self.port_no))
2485 packed.append(struct.pack("!B", self.slot_num))
2486 packed.append('\x00' * 3)
2487 packed.append(self.data)
2488 length = sum([len(x) for x in packed])
2489 packed[2] = struct.pack("!H", length)
2490 return ''.join(packed)
2491
2492 @staticmethod
2493 def unpack(reader):
2494 obj = bsn_pdu_tx_request()
2495 _version = reader.read("!B")[0]
2496 assert(_version == 1)
2497 _type = reader.read("!B")[0]
2498 assert(_type == 4)
2499 _length = reader.read("!H")[0]
2500 orig_reader = reader
2501 reader = orig_reader.slice(_length, 4)
2502 obj.xid = reader.read("!L")[0]
2503 _experimenter = reader.read("!L")[0]
2504 assert(_experimenter == 6035143)
2505 _subtype = reader.read("!L")[0]
2506 assert(_subtype == 31)
2507 obj.tx_interval_ms = reader.read("!L")[0]
2508 obj.port_no = util.unpack_port_no(reader)
2509 obj.slot_num = reader.read("!B")[0]
2510 reader.skip(3)
2511 obj.data = str(reader.read_all())
2512 return obj
2513
2514 def __eq__(self, other):
2515 if type(self) != type(other): return False
2516 if self.xid != other.xid: return False
2517 if self.tx_interval_ms != other.tx_interval_ms: return False
2518 if self.port_no != other.port_no: return False
2519 if self.slot_num != other.slot_num: return False
2520 if self.data != other.data: return False
2521 return True
2522
2523 def pretty_print(self, q):
2524 q.text("bsn_pdu_tx_request {")
2525 with q.group():
2526 with q.indent(2):
2527 q.breakable()
2528 q.text("xid = ");
2529 if self.xid != None:
2530 q.text("%#x" % self.xid)
2531 else:
2532 q.text('None')
2533 q.text(","); q.breakable()
2534 q.text("tx_interval_ms = ");
2535 q.text("%#x" % self.tx_interval_ms)
2536 q.text(","); q.breakable()
2537 q.text("port_no = ");
2538 q.text(util.pretty_port(self.port_no))
2539 q.text(","); q.breakable()
2540 q.text("slot_num = ");
2541 q.text("%#x" % self.slot_num)
2542 q.text(","); q.breakable()
2543 q.text("data = ");
2544 q.pp(self.data)
2545 q.breakable()
2546 q.text('}')
2547
2548bsn_header.subtypes[31] = bsn_pdu_tx_request
2549
2550class bsn_set_ip_mask(bsn_header):
2551 version = 1
2552 type = 4
2553 experimenter = 6035143
2554 subtype = 0
2555
2556 def __init__(self, xid=None, index=None, mask=None):
2557 if xid != None:
2558 self.xid = xid
2559 else:
2560 self.xid = None
2561 if index != None:
2562 self.index = index
2563 else:
2564 self.index = 0
2565 if mask != None:
2566 self.mask = mask
2567 else:
2568 self.mask = 0
2569 return
2570
2571 def pack(self):
2572 packed = []
2573 packed.append(struct.pack("!B", self.version))
2574 packed.append(struct.pack("!B", self.type))
2575 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2576 packed.append(struct.pack("!L", self.xid))
2577 packed.append(struct.pack("!L", self.experimenter))
2578 packed.append(struct.pack("!L", self.subtype))
2579 packed.append(struct.pack("!B", self.index))
2580 packed.append('\x00' * 3)
2581 packed.append(struct.pack("!L", self.mask))
2582 length = sum([len(x) for x in packed])
2583 packed[2] = struct.pack("!H", length)
2584 return ''.join(packed)
2585
2586 @staticmethod
2587 def unpack(reader):
2588 obj = bsn_set_ip_mask()
2589 _version = reader.read("!B")[0]
2590 assert(_version == 1)
2591 _type = reader.read("!B")[0]
2592 assert(_type == 4)
2593 _length = reader.read("!H")[0]
2594 orig_reader = reader
2595 reader = orig_reader.slice(_length, 4)
2596 obj.xid = reader.read("!L")[0]
2597 _experimenter = reader.read("!L")[0]
2598 assert(_experimenter == 6035143)
2599 _subtype = reader.read("!L")[0]
2600 assert(_subtype == 0)
2601 obj.index = reader.read("!B")[0]
2602 reader.skip(3)
2603 obj.mask = reader.read("!L")[0]
2604 return obj
2605
2606 def __eq__(self, other):
2607 if type(self) != type(other): return False
2608 if self.xid != other.xid: return False
2609 if self.index != other.index: return False
2610 if self.mask != other.mask: return False
2611 return True
2612
2613 def pretty_print(self, q):
2614 q.text("bsn_set_ip_mask {")
2615 with q.group():
2616 with q.indent(2):
2617 q.breakable()
2618 q.text("xid = ");
2619 if self.xid != None:
2620 q.text("%#x" % self.xid)
2621 else:
2622 q.text('None')
2623 q.text(","); q.breakable()
2624 q.text("index = ");
2625 q.text("%#x" % self.index)
2626 q.text(","); q.breakable()
2627 q.text("mask = ");
2628 q.text("%#x" % self.mask)
2629 q.breakable()
2630 q.text('}')
2631
2632bsn_header.subtypes[0] = bsn_set_ip_mask
2633
2634class bsn_set_l2_table_reply(bsn_header):
2635 version = 1
2636 type = 4
2637 experimenter = 6035143
2638 subtype = 24
2639
2640 def __init__(self, xid=None, l2_table_enable=None, l2_table_priority=None, status=None):
2641 if xid != None:
2642 self.xid = xid
2643 else:
2644 self.xid = None
2645 if l2_table_enable != None:
2646 self.l2_table_enable = l2_table_enable
2647 else:
2648 self.l2_table_enable = 0
2649 if l2_table_priority != None:
2650 self.l2_table_priority = l2_table_priority
2651 else:
2652 self.l2_table_priority = 0
2653 if status != None:
2654 self.status = status
2655 else:
2656 self.status = 0
2657 return
2658
2659 def pack(self):
2660 packed = []
2661 packed.append(struct.pack("!B", self.version))
2662 packed.append(struct.pack("!B", self.type))
2663 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2664 packed.append(struct.pack("!L", self.xid))
2665 packed.append(struct.pack("!L", self.experimenter))
2666 packed.append(struct.pack("!L", self.subtype))
2667 packed.append(struct.pack("!B", self.l2_table_enable))
2668 packed.append('\x00' * 1)
2669 packed.append(struct.pack("!H", self.l2_table_priority))
2670 packed.append(struct.pack("!L", self.status))
2671 length = sum([len(x) for x in packed])
2672 packed[2] = struct.pack("!H", length)
2673 return ''.join(packed)
2674
2675 @staticmethod
2676 def unpack(reader):
2677 obj = bsn_set_l2_table_reply()
2678 _version = reader.read("!B")[0]
2679 assert(_version == 1)
2680 _type = reader.read("!B")[0]
2681 assert(_type == 4)
2682 _length = reader.read("!H")[0]
2683 orig_reader = reader
2684 reader = orig_reader.slice(_length, 4)
2685 obj.xid = reader.read("!L")[0]
2686 _experimenter = reader.read("!L")[0]
2687 assert(_experimenter == 6035143)
2688 _subtype = reader.read("!L")[0]
2689 assert(_subtype == 24)
2690 obj.l2_table_enable = reader.read("!B")[0]
2691 reader.skip(1)
2692 obj.l2_table_priority = reader.read("!H")[0]
2693 obj.status = reader.read("!L")[0]
2694 return obj
2695
2696 def __eq__(self, other):
2697 if type(self) != type(other): return False
2698 if self.xid != other.xid: return False
2699 if self.l2_table_enable != other.l2_table_enable: return False
2700 if self.l2_table_priority != other.l2_table_priority: return False
2701 if self.status != other.status: return False
2702 return True
2703
2704 def pretty_print(self, q):
2705 q.text("bsn_set_l2_table_reply {")
2706 with q.group():
2707 with q.indent(2):
2708 q.breakable()
2709 q.text("xid = ");
2710 if self.xid != None:
2711 q.text("%#x" % self.xid)
2712 else:
2713 q.text('None')
2714 q.text(","); q.breakable()
2715 q.text("l2_table_enable = ");
2716 q.text("%#x" % self.l2_table_enable)
2717 q.text(","); q.breakable()
2718 q.text("l2_table_priority = ");
2719 q.text("%#x" % self.l2_table_priority)
2720 q.text(","); q.breakable()
2721 q.text("status = ");
2722 q.text("%#x" % self.status)
2723 q.breakable()
2724 q.text('}')
2725
2726bsn_header.subtypes[24] = bsn_set_l2_table_reply
2727
2728class bsn_set_l2_table_request(bsn_header):
2729 version = 1
2730 type = 4
2731 experimenter = 6035143
2732 subtype = 12
2733
2734 def __init__(self, xid=None, l2_table_enable=None, l2_table_priority=None):
2735 if xid != None:
2736 self.xid = xid
2737 else:
2738 self.xid = None
2739 if l2_table_enable != None:
2740 self.l2_table_enable = l2_table_enable
2741 else:
2742 self.l2_table_enable = 0
2743 if l2_table_priority != None:
2744 self.l2_table_priority = l2_table_priority
2745 else:
2746 self.l2_table_priority = 0
2747 return
2748
2749 def pack(self):
2750 packed = []
2751 packed.append(struct.pack("!B", self.version))
2752 packed.append(struct.pack("!B", self.type))
2753 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2754 packed.append(struct.pack("!L", self.xid))
2755 packed.append(struct.pack("!L", self.experimenter))
2756 packed.append(struct.pack("!L", self.subtype))
2757 packed.append(struct.pack("!B", self.l2_table_enable))
2758 packed.append('\x00' * 1)
2759 packed.append(struct.pack("!H", self.l2_table_priority))
2760 packed.append('\x00' * 4)
2761 length = sum([len(x) for x in packed])
2762 packed[2] = struct.pack("!H", length)
2763 return ''.join(packed)
2764
2765 @staticmethod
2766 def unpack(reader):
2767 obj = bsn_set_l2_table_request()
2768 _version = reader.read("!B")[0]
2769 assert(_version == 1)
2770 _type = reader.read("!B")[0]
2771 assert(_type == 4)
2772 _length = reader.read("!H")[0]
2773 orig_reader = reader
2774 reader = orig_reader.slice(_length, 4)
2775 obj.xid = reader.read("!L")[0]
2776 _experimenter = reader.read("!L")[0]
2777 assert(_experimenter == 6035143)
2778 _subtype = reader.read("!L")[0]
2779 assert(_subtype == 12)
2780 obj.l2_table_enable = reader.read("!B")[0]
2781 reader.skip(1)
2782 obj.l2_table_priority = reader.read("!H")[0]
2783 reader.skip(4)
2784 return obj
2785
2786 def __eq__(self, other):
2787 if type(self) != type(other): return False
2788 if self.xid != other.xid: return False
2789 if self.l2_table_enable != other.l2_table_enable: return False
2790 if self.l2_table_priority != other.l2_table_priority: return False
2791 return True
2792
2793 def pretty_print(self, q):
2794 q.text("bsn_set_l2_table_request {")
2795 with q.group():
2796 with q.indent(2):
2797 q.breakable()
2798 q.text("xid = ");
2799 if self.xid != None:
2800 q.text("%#x" % self.xid)
2801 else:
2802 q.text('None')
2803 q.text(","); q.breakable()
2804 q.text("l2_table_enable = ");
2805 q.text("%#x" % self.l2_table_enable)
2806 q.text(","); q.breakable()
2807 q.text("l2_table_priority = ");
2808 q.text("%#x" % self.l2_table_priority)
2809 q.breakable()
2810 q.text('}')
2811
2812bsn_header.subtypes[12] = bsn_set_l2_table_request
2813
2814class bsn_set_mirroring(bsn_header):
2815 version = 1
2816 type = 4
2817 experimenter = 6035143
2818 subtype = 3
2819
2820 def __init__(self, xid=None, report_mirror_ports=None):
2821 if xid != None:
2822 self.xid = xid
2823 else:
2824 self.xid = None
2825 if report_mirror_ports != None:
2826 self.report_mirror_ports = report_mirror_ports
2827 else:
2828 self.report_mirror_ports = 0
2829 return
2830
2831 def pack(self):
2832 packed = []
2833 packed.append(struct.pack("!B", self.version))
2834 packed.append(struct.pack("!B", self.type))
2835 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2836 packed.append(struct.pack("!L", self.xid))
2837 packed.append(struct.pack("!L", self.experimenter))
2838 packed.append(struct.pack("!L", self.subtype))
2839 packed.append(struct.pack("!B", self.report_mirror_ports))
2840 packed.append('\x00' * 3)
2841 length = sum([len(x) for x in packed])
2842 packed[2] = struct.pack("!H", length)
2843 return ''.join(packed)
2844
2845 @staticmethod
2846 def unpack(reader):
2847 obj = bsn_set_mirroring()
2848 _version = reader.read("!B")[0]
2849 assert(_version == 1)
2850 _type = reader.read("!B")[0]
2851 assert(_type == 4)
2852 _length = reader.read("!H")[0]
2853 orig_reader = reader
2854 reader = orig_reader.slice(_length, 4)
2855 obj.xid = reader.read("!L")[0]
2856 _experimenter = reader.read("!L")[0]
2857 assert(_experimenter == 6035143)
2858 _subtype = reader.read("!L")[0]
2859 assert(_subtype == 3)
2860 obj.report_mirror_ports = reader.read("!B")[0]
2861 reader.skip(3)
2862 return obj
2863
2864 def __eq__(self, other):
2865 if type(self) != type(other): return False
2866 if self.xid != other.xid: return False
2867 if self.report_mirror_ports != other.report_mirror_ports: return False
2868 return True
2869
2870 def pretty_print(self, q):
2871 q.text("bsn_set_mirroring {")
2872 with q.group():
2873 with q.indent(2):
2874 q.breakable()
2875 q.text("xid = ");
2876 if self.xid != None:
2877 q.text("%#x" % self.xid)
2878 else:
2879 q.text('None')
2880 q.text(","); q.breakable()
2881 q.text("report_mirror_ports = ");
2882 q.text("%#x" % self.report_mirror_ports)
2883 q.breakable()
2884 q.text('}')
2885
2886bsn_header.subtypes[3] = bsn_set_mirroring
2887
2888class bsn_set_pktin_suppression_reply(bsn_header):
2889 version = 1
2890 type = 4
2891 experimenter = 6035143
2892 subtype = 25
2893
2894 def __init__(self, xid=None, status=None):
2895 if xid != None:
2896 self.xid = xid
2897 else:
2898 self.xid = None
2899 if status != None:
2900 self.status = status
2901 else:
2902 self.status = 0
2903 return
2904
2905 def pack(self):
2906 packed = []
2907 packed.append(struct.pack("!B", self.version))
2908 packed.append(struct.pack("!B", self.type))
2909 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2910 packed.append(struct.pack("!L", self.xid))
2911 packed.append(struct.pack("!L", self.experimenter))
2912 packed.append(struct.pack("!L", self.subtype))
2913 packed.append(struct.pack("!L", self.status))
2914 length = sum([len(x) for x in packed])
2915 packed[2] = struct.pack("!H", length)
2916 return ''.join(packed)
2917
2918 @staticmethod
2919 def unpack(reader):
2920 obj = bsn_set_pktin_suppression_reply()
2921 _version = reader.read("!B")[0]
2922 assert(_version == 1)
2923 _type = reader.read("!B")[0]
2924 assert(_type == 4)
2925 _length = reader.read("!H")[0]
2926 orig_reader = reader
2927 reader = orig_reader.slice(_length, 4)
2928 obj.xid = reader.read("!L")[0]
2929 _experimenter = reader.read("!L")[0]
2930 assert(_experimenter == 6035143)
2931 _subtype = reader.read("!L")[0]
2932 assert(_subtype == 25)
2933 obj.status = reader.read("!L")[0]
2934 return obj
2935
2936 def __eq__(self, other):
2937 if type(self) != type(other): return False
2938 if self.xid != other.xid: return False
2939 if self.status != other.status: return False
2940 return True
2941
2942 def pretty_print(self, q):
2943 q.text("bsn_set_pktin_suppression_reply {")
2944 with q.group():
2945 with q.indent(2):
2946 q.breakable()
2947 q.text("xid = ");
2948 if self.xid != None:
2949 q.text("%#x" % self.xid)
2950 else:
2951 q.text('None')
2952 q.text(","); q.breakable()
2953 q.text("status = ");
2954 q.text("%#x" % self.status)
2955 q.breakable()
2956 q.text('}')
2957
2958bsn_header.subtypes[25] = bsn_set_pktin_suppression_reply
2959
2960class bsn_set_pktin_suppression_request(bsn_header):
2961 version = 1
2962 type = 4
2963 experimenter = 6035143
2964 subtype = 11
2965
2966 def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None):
2967 if xid != None:
2968 self.xid = xid
2969 else:
2970 self.xid = None
2971 if enabled != None:
2972 self.enabled = enabled
2973 else:
2974 self.enabled = 0
2975 if idle_timeout != None:
2976 self.idle_timeout = idle_timeout
2977 else:
2978 self.idle_timeout = 0
2979 if hard_timeout != None:
2980 self.hard_timeout = hard_timeout
2981 else:
2982 self.hard_timeout = 0
2983 if priority != None:
2984 self.priority = priority
2985 else:
2986 self.priority = 0
2987 if cookie != None:
2988 self.cookie = cookie
2989 else:
2990 self.cookie = 0
2991 return
2992
2993 def pack(self):
2994 packed = []
2995 packed.append(struct.pack("!B", self.version))
2996 packed.append(struct.pack("!B", self.type))
2997 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2998 packed.append(struct.pack("!L", self.xid))
2999 packed.append(struct.pack("!L", self.experimenter))
3000 packed.append(struct.pack("!L", self.subtype))
3001 packed.append(struct.pack("!B", self.enabled))
3002 packed.append('\x00' * 1)
3003 packed.append(struct.pack("!H", self.idle_timeout))
3004 packed.append(struct.pack("!H", self.hard_timeout))
3005 packed.append(struct.pack("!H", self.priority))
3006 packed.append(struct.pack("!Q", self.cookie))
3007 length = sum([len(x) for x in packed])
3008 packed[2] = struct.pack("!H", length)
3009 return ''.join(packed)
3010
3011 @staticmethod
3012 def unpack(reader):
3013 obj = bsn_set_pktin_suppression_request()
3014 _version = reader.read("!B")[0]
3015 assert(_version == 1)
3016 _type = reader.read("!B")[0]
3017 assert(_type == 4)
3018 _length = reader.read("!H")[0]
3019 orig_reader = reader
3020 reader = orig_reader.slice(_length, 4)
3021 obj.xid = reader.read("!L")[0]
3022 _experimenter = reader.read("!L")[0]
3023 assert(_experimenter == 6035143)
3024 _subtype = reader.read("!L")[0]
3025 assert(_subtype == 11)
3026 obj.enabled = reader.read("!B")[0]
3027 reader.skip(1)
3028 obj.idle_timeout = reader.read("!H")[0]
3029 obj.hard_timeout = reader.read("!H")[0]
3030 obj.priority = reader.read("!H")[0]
3031 obj.cookie = reader.read("!Q")[0]
3032 return obj
3033
3034 def __eq__(self, other):
3035 if type(self) != type(other): return False
3036 if self.xid != other.xid: return False
3037 if self.enabled != other.enabled: return False
3038 if self.idle_timeout != other.idle_timeout: return False
3039 if self.hard_timeout != other.hard_timeout: return False
3040 if self.priority != other.priority: return False
3041 if self.cookie != other.cookie: return False
3042 return True
3043
3044 def pretty_print(self, q):
3045 q.text("bsn_set_pktin_suppression_request {")
3046 with q.group():
3047 with q.indent(2):
3048 q.breakable()
3049 q.text("xid = ");
3050 if self.xid != None:
3051 q.text("%#x" % self.xid)
3052 else:
3053 q.text('None')
3054 q.text(","); q.breakable()
3055 q.text("enabled = ");
3056 q.text("%#x" % self.enabled)
3057 q.text(","); q.breakable()
3058 q.text("idle_timeout = ");
3059 q.text("%#x" % self.idle_timeout)
3060 q.text(","); q.breakable()
3061 q.text("hard_timeout = ");
3062 q.text("%#x" % self.hard_timeout)
3063 q.text(","); q.breakable()
3064 q.text("priority = ");
3065 q.text("%#x" % self.priority)
3066 q.text(","); q.breakable()
3067 q.text("cookie = ");
3068 q.text("%#x" % self.cookie)
3069 q.breakable()
3070 q.text('}')
3071
3072bsn_header.subtypes[11] = bsn_set_pktin_suppression_request
3073
3074class bsn_shell_command(bsn_header):
3075 version = 1
3076 type = 4
3077 experimenter = 6035143
3078 subtype = 6
3079
3080 def __init__(self, xid=None, service=None, data=None):
3081 if xid != None:
3082 self.xid = xid
3083 else:
3084 self.xid = None
3085 if service != None:
3086 self.service = service
3087 else:
3088 self.service = 0
3089 if data != None:
3090 self.data = data
3091 else:
3092 self.data = ''
3093 return
3094
3095 def pack(self):
3096 packed = []
3097 packed.append(struct.pack("!B", self.version))
3098 packed.append(struct.pack("!B", self.type))
3099 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3100 packed.append(struct.pack("!L", self.xid))
3101 packed.append(struct.pack("!L", self.experimenter))
3102 packed.append(struct.pack("!L", self.subtype))
3103 packed.append(struct.pack("!L", self.service))
3104 packed.append(self.data)
3105 length = sum([len(x) for x in packed])
3106 packed[2] = struct.pack("!H", length)
3107 return ''.join(packed)
3108
3109 @staticmethod
3110 def unpack(reader):
3111 obj = bsn_shell_command()
3112 _version = reader.read("!B")[0]
3113 assert(_version == 1)
3114 _type = reader.read("!B")[0]
3115 assert(_type == 4)
3116 _length = reader.read("!H")[0]
3117 orig_reader = reader
3118 reader = orig_reader.slice(_length, 4)
3119 obj.xid = reader.read("!L")[0]
3120 _experimenter = reader.read("!L")[0]
3121 assert(_experimenter == 6035143)
3122 _subtype = reader.read("!L")[0]
3123 assert(_subtype == 6)
3124 obj.service = reader.read("!L")[0]
3125 obj.data = str(reader.read_all())
3126 return obj
3127
3128 def __eq__(self, other):
3129 if type(self) != type(other): return False
3130 if self.xid != other.xid: return False
3131 if self.service != other.service: return False
3132 if self.data != other.data: return False
3133 return True
3134
3135 def pretty_print(self, q):
3136 q.text("bsn_shell_command {")
3137 with q.group():
3138 with q.indent(2):
3139 q.breakable()
3140 q.text("xid = ");
3141 if self.xid != None:
3142 q.text("%#x" % self.xid)
3143 else:
3144 q.text('None')
3145 q.text(","); q.breakable()
3146 q.text("service = ");
3147 q.text("%#x" % self.service)
3148 q.text(","); q.breakable()
3149 q.text("data = ");
3150 q.pp(self.data)
3151 q.breakable()
3152 q.text('}')
3153
3154bsn_header.subtypes[6] = bsn_shell_command
3155
3156class bsn_shell_output(bsn_header):
3157 version = 1
3158 type = 4
3159 experimenter = 6035143
3160 subtype = 7
3161
3162 def __init__(self, xid=None, data=None):
3163 if xid != None:
3164 self.xid = xid
3165 else:
3166 self.xid = None
3167 if data != None:
3168 self.data = data
3169 else:
3170 self.data = ''
3171 return
3172
3173 def pack(self):
3174 packed = []
3175 packed.append(struct.pack("!B", self.version))
3176 packed.append(struct.pack("!B", self.type))
3177 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3178 packed.append(struct.pack("!L", self.xid))
3179 packed.append(struct.pack("!L", self.experimenter))
3180 packed.append(struct.pack("!L", self.subtype))
3181 packed.append(self.data)
3182 length = sum([len(x) for x in packed])
3183 packed[2] = struct.pack("!H", length)
3184 return ''.join(packed)
3185
3186 @staticmethod
3187 def unpack(reader):
3188 obj = bsn_shell_output()
3189 _version = reader.read("!B")[0]
3190 assert(_version == 1)
3191 _type = reader.read("!B")[0]
3192 assert(_type == 4)
3193 _length = reader.read("!H")[0]
3194 orig_reader = reader
3195 reader = orig_reader.slice(_length, 4)
3196 obj.xid = reader.read("!L")[0]
3197 _experimenter = reader.read("!L")[0]
3198 assert(_experimenter == 6035143)
3199 _subtype = reader.read("!L")[0]
3200 assert(_subtype == 7)
3201 obj.data = str(reader.read_all())
3202 return obj
3203
3204 def __eq__(self, other):
3205 if type(self) != type(other): return False
3206 if self.xid != other.xid: return False
3207 if self.data != other.data: return False
3208 return True
3209
3210 def pretty_print(self, q):
3211 q.text("bsn_shell_output {")
3212 with q.group():
3213 with q.indent(2):
3214 q.breakable()
3215 q.text("xid = ");
3216 if self.xid != None:
3217 q.text("%#x" % self.xid)
3218 else:
3219 q.text('None')
3220 q.text(","); q.breakable()
3221 q.text("data = ");
3222 q.pp(self.data)
3223 q.breakable()
3224 q.text('}')
3225
3226bsn_header.subtypes[7] = bsn_shell_output
3227
3228class bsn_shell_status(bsn_header):
3229 version = 1
3230 type = 4
3231 experimenter = 6035143
3232 subtype = 8
3233
3234 def __init__(self, xid=None, status=None):
3235 if xid != None:
3236 self.xid = xid
3237 else:
3238 self.xid = None
3239 if status != None:
3240 self.status = status
3241 else:
3242 self.status = 0
3243 return
3244
3245 def pack(self):
3246 packed = []
3247 packed.append(struct.pack("!B", self.version))
3248 packed.append(struct.pack("!B", self.type))
3249 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3250 packed.append(struct.pack("!L", self.xid))
3251 packed.append(struct.pack("!L", self.experimenter))
3252 packed.append(struct.pack("!L", self.subtype))
3253 packed.append(struct.pack("!L", self.status))
3254 length = sum([len(x) for x in packed])
3255 packed[2] = struct.pack("!H", length)
3256 return ''.join(packed)
3257
3258 @staticmethod
3259 def unpack(reader):
3260 obj = bsn_shell_status()
3261 _version = reader.read("!B")[0]
3262 assert(_version == 1)
3263 _type = reader.read("!B")[0]
3264 assert(_type == 4)
3265 _length = reader.read("!H")[0]
3266 orig_reader = reader
3267 reader = orig_reader.slice(_length, 4)
3268 obj.xid = reader.read("!L")[0]
3269 _experimenter = reader.read("!L")[0]
3270 assert(_experimenter == 6035143)
3271 _subtype = reader.read("!L")[0]
3272 assert(_subtype == 8)
3273 obj.status = reader.read("!L")[0]
3274 return obj
3275
3276 def __eq__(self, other):
3277 if type(self) != type(other): return False
3278 if self.xid != other.xid: return False
3279 if self.status != other.status: return False
3280 return True
3281
3282 def pretty_print(self, q):
3283 q.text("bsn_shell_status {")
3284 with q.group():
3285 with q.indent(2):
3286 q.breakable()
3287 q.text("xid = ");
3288 if self.xid != None:
3289 q.text("%#x" % self.xid)
3290 else:
3291 q.text('None')
3292 q.text(","); q.breakable()
3293 q.text("status = ");
3294 q.text("%#x" % self.status)
3295 q.breakable()
3296 q.text('}')
3297
3298bsn_header.subtypes[8] = bsn_shell_status
3299
3300class experimenter_stats_reply(stats_reply):
3301 subtypes = {}
3302
3303 version = 1
3304 type = 17
3305 stats_type = 65535
3306
3307 def __init__(self, xid=None, flags=None, experimenter=None, data=None):
3308 if xid != None:
3309 self.xid = xid
3310 else:
3311 self.xid = None
3312 if flags != None:
3313 self.flags = flags
3314 else:
3315 self.flags = 0
3316 if experimenter != None:
3317 self.experimenter = experimenter
3318 else:
3319 self.experimenter = 0
3320 if data != None:
3321 self.data = data
3322 else:
3323 self.data = ''
3324 return
3325
3326 def pack(self):
3327 packed = []
3328 packed.append(struct.pack("!B", self.version))
3329 packed.append(struct.pack("!B", self.type))
3330 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3331 packed.append(struct.pack("!L", self.xid))
3332 packed.append(struct.pack("!H", self.stats_type))
3333 packed.append(struct.pack("!H", self.flags))
3334 packed.append(struct.pack("!L", self.experimenter))
3335 packed.append(self.data)
3336 length = sum([len(x) for x in packed])
3337 packed[2] = struct.pack("!H", length)
3338 return ''.join(packed)
3339
3340 @staticmethod
3341 def unpack(reader):
3342 subtype, = reader.peek('!L', 12)
3343 subclass = experimenter_stats_reply.subtypes.get(subtype)
3344 if subclass:
3345 return subclass.unpack(reader)
3346
3347 obj = experimenter_stats_reply()
3348 _version = reader.read("!B")[0]
3349 assert(_version == 1)
3350 _type = reader.read("!B")[0]
3351 assert(_type == 17)
3352 _length = reader.read("!H")[0]
3353 orig_reader = reader
3354 reader = orig_reader.slice(_length, 4)
3355 obj.xid = reader.read("!L")[0]
3356 _stats_type = reader.read("!H")[0]
3357 assert(_stats_type == 65535)
3358 obj.flags = reader.read("!H")[0]
3359 obj.experimenter = reader.read("!L")[0]
3360 obj.data = str(reader.read_all())
3361 return obj
3362
3363 def __eq__(self, other):
3364 if type(self) != type(other): return False
3365 if self.xid != other.xid: return False
3366 if self.flags != other.flags: return False
3367 if self.experimenter != other.experimenter: return False
3368 if self.data != other.data: return False
3369 return True
3370
3371 def pretty_print(self, q):
3372 q.text("experimenter_stats_reply {")
3373 with q.group():
3374 with q.indent(2):
3375 q.breakable()
3376 q.text("xid = ");
3377 if self.xid != None:
3378 q.text("%#x" % self.xid)
3379 else:
3380 q.text('None')
3381 q.text(","); q.breakable()
3382 q.text("flags = ");
3383 q.text("%#x" % self.flags)
3384 q.text(","); q.breakable()
3385 q.text("data = ");
3386 q.pp(self.data)
3387 q.breakable()
3388 q.text('}')
3389
3390stats_reply.subtypes[65535] = experimenter_stats_reply
3391
3392class bsn_stats_reply(experimenter_stats_reply):
3393 subtypes = {}
3394
3395 version = 1
3396 type = 19
3397 stats_type = 65535
3398 experimenter = 6035143
3399
3400 def __init__(self, xid=None, flags=None, subtype=None):
3401 if xid != None:
3402 self.xid = xid
3403 else:
3404 self.xid = None
3405 if flags != None:
3406 self.flags = flags
3407 else:
3408 self.flags = 0
3409 if subtype != None:
3410 self.subtype = subtype
3411 else:
3412 self.subtype = 0
3413 return
3414
3415 def pack(self):
3416 packed = []
3417 packed.append(struct.pack("!B", self.version))
3418 packed.append(struct.pack("!B", self.type))
3419 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3420 packed.append(struct.pack("!L", self.xid))
3421 packed.append(struct.pack("!H", self.stats_type))
3422 packed.append(struct.pack("!H", self.flags))
3423 packed.append('\x00' * 4)
3424 packed.append(struct.pack("!L", self.experimenter))
3425 packed.append(struct.pack("!L", self.subtype))
3426 length = sum([len(x) for x in packed])
3427 packed[2] = struct.pack("!H", length)
3428 return ''.join(packed)
3429
3430 @staticmethod
3431 def unpack(reader):
3432 subtype, = reader.peek('!L', 20)
3433 subclass = bsn_stats_reply.subtypes.get(subtype)
3434 if subclass:
3435 return subclass.unpack(reader)
3436
3437 obj = bsn_stats_reply()
3438 _version = reader.read("!B")[0]
3439 assert(_version == 1)
3440 _type = reader.read("!B")[0]
3441 assert(_type == 19)
3442 _length = reader.read("!H")[0]
3443 orig_reader = reader
3444 reader = orig_reader.slice(_length, 4)
3445 obj.xid = reader.read("!L")[0]
3446 _stats_type = reader.read("!H")[0]
3447 assert(_stats_type == 65535)
3448 obj.flags = reader.read("!H")[0]
3449 reader.skip(4)
3450 _experimenter = reader.read("!L")[0]
3451 assert(_experimenter == 6035143)
3452 obj.subtype = reader.read("!L")[0]
3453 return obj
3454
3455 def __eq__(self, other):
3456 if type(self) != type(other): return False
3457 if self.xid != other.xid: return False
3458 if self.flags != other.flags: return False
3459 if self.subtype != other.subtype: return False
3460 return True
3461
3462 def pretty_print(self, q):
3463 q.text("bsn_stats_reply {")
3464 with q.group():
3465 with q.indent(2):
3466 q.breakable()
3467 q.text("xid = ");
3468 if self.xid != None:
3469 q.text("%#x" % self.xid)
3470 else:
3471 q.text('None')
3472 q.text(","); q.breakable()
3473 q.text("flags = ");
3474 q.text("%#x" % self.flags)
3475 q.breakable()
3476 q.text('}')
3477
3478experimenter_stats_reply.subtypes[6035143] = bsn_stats_reply
3479
3480class experimenter_stats_request(stats_request):
3481 subtypes = {}
3482
3483 version = 1
3484 type = 16
3485 stats_type = 65535
3486
3487 def __init__(self, xid=None, flags=None, experimenter=None, data=None):
3488 if xid != None:
3489 self.xid = xid
3490 else:
3491 self.xid = None
3492 if flags != None:
3493 self.flags = flags
3494 else:
3495 self.flags = 0
3496 if experimenter != None:
3497 self.experimenter = experimenter
3498 else:
3499 self.experimenter = 0
3500 if data != None:
3501 self.data = data
3502 else:
3503 self.data = ''
3504 return
3505
3506 def pack(self):
3507 packed = []
3508 packed.append(struct.pack("!B", self.version))
3509 packed.append(struct.pack("!B", self.type))
3510 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3511 packed.append(struct.pack("!L", self.xid))
3512 packed.append(struct.pack("!H", self.stats_type))
3513 packed.append(struct.pack("!H", self.flags))
3514 packed.append(struct.pack("!L", self.experimenter))
3515 packed.append(self.data)
3516 length = sum([len(x) for x in packed])
3517 packed[2] = struct.pack("!H", length)
3518 return ''.join(packed)
3519
3520 @staticmethod
3521 def unpack(reader):
3522 subtype, = reader.peek('!L', 12)
3523 subclass = experimenter_stats_request.subtypes.get(subtype)
3524 if subclass:
3525 return subclass.unpack(reader)
3526
3527 obj = experimenter_stats_request()
3528 _version = reader.read("!B")[0]
3529 assert(_version == 1)
3530 _type = reader.read("!B")[0]
3531 assert(_type == 16)
3532 _length = reader.read("!H")[0]
3533 orig_reader = reader
3534 reader = orig_reader.slice(_length, 4)
3535 obj.xid = reader.read("!L")[0]
3536 _stats_type = reader.read("!H")[0]
3537 assert(_stats_type == 65535)
3538 obj.flags = reader.read("!H")[0]
3539 obj.experimenter = reader.read("!L")[0]
3540 obj.data = str(reader.read_all())
3541 return obj
3542
3543 def __eq__(self, other):
3544 if type(self) != type(other): return False
3545 if self.xid != other.xid: return False
3546 if self.flags != other.flags: return False
3547 if self.experimenter != other.experimenter: return False
3548 if self.data != other.data: return False
3549 return True
3550
3551 def pretty_print(self, q):
3552 q.text("experimenter_stats_request {")
3553 with q.group():
3554 with q.indent(2):
3555 q.breakable()
3556 q.text("xid = ");
3557 if self.xid != None:
3558 q.text("%#x" % self.xid)
3559 else:
3560 q.text('None')
3561 q.text(","); q.breakable()
3562 q.text("flags = ");
3563 q.text("%#x" % self.flags)
3564 q.text(","); q.breakable()
3565 q.text("data = ");
3566 q.pp(self.data)
3567 q.breakable()
3568 q.text('}')
3569
3570stats_request.subtypes[65535] = experimenter_stats_request
3571
3572class bsn_stats_request(experimenter_stats_request):
3573 subtypes = {}
3574
3575 version = 1
3576 type = 18
3577 stats_type = 65535
3578 experimenter = 6035143
3579
3580 def __init__(self, xid=None, flags=None, subtype=None):
3581 if xid != None:
3582 self.xid = xid
3583 else:
3584 self.xid = None
3585 if flags != None:
3586 self.flags = flags
3587 else:
3588 self.flags = 0
3589 if subtype != None:
3590 self.subtype = subtype
3591 else:
3592 self.subtype = 0
3593 return
3594
3595 def pack(self):
3596 packed = []
3597 packed.append(struct.pack("!B", self.version))
3598 packed.append(struct.pack("!B", self.type))
3599 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3600 packed.append(struct.pack("!L", self.xid))
3601 packed.append(struct.pack("!H", self.stats_type))
3602 packed.append(struct.pack("!H", self.flags))
3603 packed.append('\x00' * 4)
3604 packed.append(struct.pack("!L", self.experimenter))
3605 packed.append(struct.pack("!L", self.subtype))
3606 length = sum([len(x) for x in packed])
3607 packed[2] = struct.pack("!H", length)
3608 return ''.join(packed)
3609
3610 @staticmethod
3611 def unpack(reader):
3612 subtype, = reader.peek('!L', 20)
3613 subclass = bsn_stats_request.subtypes.get(subtype)
3614 if subclass:
3615 return subclass.unpack(reader)
3616
3617 obj = bsn_stats_request()
3618 _version = reader.read("!B")[0]
3619 assert(_version == 1)
3620 _type = reader.read("!B")[0]
3621 assert(_type == 18)
3622 _length = reader.read("!H")[0]
3623 orig_reader = reader
3624 reader = orig_reader.slice(_length, 4)
3625 obj.xid = reader.read("!L")[0]
3626 _stats_type = reader.read("!H")[0]
3627 assert(_stats_type == 65535)
3628 obj.flags = reader.read("!H")[0]
3629 reader.skip(4)
3630 _experimenter = reader.read("!L")[0]
3631 assert(_experimenter == 6035143)
3632 obj.subtype = reader.read("!L")[0]
3633 return obj
3634
3635 def __eq__(self, other):
3636 if type(self) != type(other): return False
3637 if self.xid != other.xid: return False
3638 if self.flags != other.flags: return False
3639 if self.subtype != other.subtype: return False
3640 return True
3641
3642 def pretty_print(self, q):
3643 q.text("bsn_stats_request {")
3644 with q.group():
3645 with q.indent(2):
3646 q.breakable()
3647 q.text("xid = ");
3648 if self.xid != None:
3649 q.text("%#x" % self.xid)
3650 else:
3651 q.text('None')
3652 q.text(","); q.breakable()
3653 q.text("flags = ");
3654 q.text("%#x" % self.flags)
3655 q.breakable()
3656 q.text('}')
3657
3658experimenter_stats_request.subtypes[6035143] = bsn_stats_request
3659
3660class bsn_virtual_port_create_reply(bsn_header):
3661 version = 1
3662 type = 4
3663 experimenter = 6035143
3664 subtype = 16
3665
3666 def __init__(self, xid=None, status=None, vport_no=None):
3667 if xid != None:
3668 self.xid = xid
3669 else:
3670 self.xid = None
3671 if status != None:
3672 self.status = status
3673 else:
3674 self.status = 0
3675 if vport_no != None:
3676 self.vport_no = vport_no
3677 else:
3678 self.vport_no = 0
3679 return
3680
3681 def pack(self):
3682 packed = []
3683 packed.append(struct.pack("!B", self.version))
3684 packed.append(struct.pack("!B", self.type))
3685 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3686 packed.append(struct.pack("!L", self.xid))
3687 packed.append(struct.pack("!L", self.experimenter))
3688 packed.append(struct.pack("!L", self.subtype))
3689 packed.append(struct.pack("!L", self.status))
3690 packed.append(struct.pack("!L", self.vport_no))
3691 length = sum([len(x) for x in packed])
3692 packed[2] = struct.pack("!H", length)
3693 return ''.join(packed)
3694
3695 @staticmethod
3696 def unpack(reader):
3697 obj = bsn_virtual_port_create_reply()
3698 _version = reader.read("!B")[0]
3699 assert(_version == 1)
3700 _type = reader.read("!B")[0]
3701 assert(_type == 4)
3702 _length = reader.read("!H")[0]
3703 orig_reader = reader
3704 reader = orig_reader.slice(_length, 4)
3705 obj.xid = reader.read("!L")[0]
3706 _experimenter = reader.read("!L")[0]
3707 assert(_experimenter == 6035143)
3708 _subtype = reader.read("!L")[0]
3709 assert(_subtype == 16)
3710 obj.status = reader.read("!L")[0]
3711 obj.vport_no = reader.read("!L")[0]
3712 return obj
3713
3714 def __eq__(self, other):
3715 if type(self) != type(other): return False
3716 if self.xid != other.xid: return False
3717 if self.status != other.status: return False
3718 if self.vport_no != other.vport_no: return False
3719 return True
3720
3721 def pretty_print(self, q):
3722 q.text("bsn_virtual_port_create_reply {")
3723 with q.group():
3724 with q.indent(2):
3725 q.breakable()
3726 q.text("xid = ");
3727 if self.xid != None:
3728 q.text("%#x" % self.xid)
3729 else:
3730 q.text('None')
3731 q.text(","); q.breakable()
3732 q.text("status = ");
3733 q.text("%#x" % self.status)
3734 q.text(","); q.breakable()
3735 q.text("vport_no = ");
3736 q.text("%#x" % self.vport_no)
3737 q.breakable()
3738 q.text('}')
3739
3740bsn_header.subtypes[16] = bsn_virtual_port_create_reply
3741
3742class bsn_virtual_port_create_request(bsn_header):
3743 version = 1
3744 type = 4
3745 experimenter = 6035143
3746 subtype = 15
3747
3748 def __init__(self, xid=None, vport=None):
3749 if xid != None:
3750 self.xid = xid
3751 else:
3752 self.xid = None
3753 if vport != None:
3754 self.vport = vport
3755 else:
3756 self.vport = ofp.bsn_vport()
3757 return
3758
3759 def pack(self):
3760 packed = []
3761 packed.append(struct.pack("!B", self.version))
3762 packed.append(struct.pack("!B", self.type))
3763 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3764 packed.append(struct.pack("!L", self.xid))
3765 packed.append(struct.pack("!L", self.experimenter))
3766 packed.append(struct.pack("!L", self.subtype))
3767 packed.append(self.vport.pack())
3768 length = sum([len(x) for x in packed])
3769 packed[2] = struct.pack("!H", length)
3770 return ''.join(packed)
3771
3772 @staticmethod
3773 def unpack(reader):
3774 obj = bsn_virtual_port_create_request()
3775 _version = reader.read("!B")[0]
3776 assert(_version == 1)
3777 _type = reader.read("!B")[0]
3778 assert(_type == 4)
3779 _length = reader.read("!H")[0]
3780 orig_reader = reader
3781 reader = orig_reader.slice(_length, 4)
3782 obj.xid = reader.read("!L")[0]
3783 _experimenter = reader.read("!L")[0]
3784 assert(_experimenter == 6035143)
3785 _subtype = reader.read("!L")[0]
3786 assert(_subtype == 15)
3787 obj.vport = ofp.bsn_vport.unpack(reader)
3788 return obj
3789
3790 def __eq__(self, other):
3791 if type(self) != type(other): return False
3792 if self.xid != other.xid: return False
3793 if self.vport != other.vport: return False
3794 return True
3795
3796 def pretty_print(self, q):
3797 q.text("bsn_virtual_port_create_request {")
3798 with q.group():
3799 with q.indent(2):
3800 q.breakable()
3801 q.text("xid = ");
3802 if self.xid != None:
3803 q.text("%#x" % self.xid)
3804 else:
3805 q.text('None')
3806 q.text(","); q.breakable()
3807 q.text("vport = ");
3808 q.pp(self.vport)
3809 q.breakable()
3810 q.text('}')
3811
3812bsn_header.subtypes[15] = bsn_virtual_port_create_request
3813
3814class bsn_virtual_port_remove_reply(bsn_header):
3815 version = 1
3816 type = 4
3817 experimenter = 6035143
3818 subtype = 26
3819
3820 def __init__(self, xid=None, status=None):
3821 if xid != None:
3822 self.xid = xid
3823 else:
3824 self.xid = None
3825 if status != None:
3826 self.status = status
3827 else:
3828 self.status = 0
3829 return
3830
3831 def pack(self):
3832 packed = []
3833 packed.append(struct.pack("!B", self.version))
3834 packed.append(struct.pack("!B", self.type))
3835 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3836 packed.append(struct.pack("!L", self.xid))
3837 packed.append(struct.pack("!L", self.experimenter))
3838 packed.append(struct.pack("!L", self.subtype))
3839 packed.append(struct.pack("!L", self.status))
3840 length = sum([len(x) for x in packed])
3841 packed[2] = struct.pack("!H", length)
3842 return ''.join(packed)
3843
3844 @staticmethod
3845 def unpack(reader):
3846 obj = bsn_virtual_port_remove_reply()
3847 _version = reader.read("!B")[0]
3848 assert(_version == 1)
3849 _type = reader.read("!B")[0]
3850 assert(_type == 4)
3851 _length = reader.read("!H")[0]
3852 orig_reader = reader
3853 reader = orig_reader.slice(_length, 4)
3854 obj.xid = reader.read("!L")[0]
3855 _experimenter = reader.read("!L")[0]
3856 assert(_experimenter == 6035143)
3857 _subtype = reader.read("!L")[0]
3858 assert(_subtype == 26)
3859 obj.status = reader.read("!L")[0]
3860 return obj
3861
3862 def __eq__(self, other):
3863 if type(self) != type(other): return False
3864 if self.xid != other.xid: return False
3865 if self.status != other.status: return False
3866 return True
3867
3868 def pretty_print(self, q):
3869 q.text("bsn_virtual_port_remove_reply {")
3870 with q.group():
3871 with q.indent(2):
3872 q.breakable()
3873 q.text("xid = ");
3874 if self.xid != None:
3875 q.text("%#x" % self.xid)
3876 else:
3877 q.text('None')
3878 q.text(","); q.breakable()
3879 q.text("status = ");
3880 q.text("%#x" % self.status)
3881 q.breakable()
3882 q.text('}')
3883
3884bsn_header.subtypes[26] = bsn_virtual_port_remove_reply
3885
3886class bsn_virtual_port_remove_request(bsn_header):
3887 version = 1
3888 type = 4
3889 experimenter = 6035143
3890 subtype = 17
3891
3892 def __init__(self, xid=None, vport_no=None):
3893 if xid != None:
3894 self.xid = xid
3895 else:
3896 self.xid = None
3897 if vport_no != None:
3898 self.vport_no = vport_no
3899 else:
3900 self.vport_no = 0
3901 return
3902
3903 def pack(self):
3904 packed = []
3905 packed.append(struct.pack("!B", self.version))
3906 packed.append(struct.pack("!B", self.type))
3907 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3908 packed.append(struct.pack("!L", self.xid))
3909 packed.append(struct.pack("!L", self.experimenter))
3910 packed.append(struct.pack("!L", self.subtype))
3911 packed.append(struct.pack("!L", self.vport_no))
3912 length = sum([len(x) for x in packed])
3913 packed[2] = struct.pack("!H", length)
3914 return ''.join(packed)
3915
3916 @staticmethod
3917 def unpack(reader):
3918 obj = bsn_virtual_port_remove_request()
3919 _version = reader.read("!B")[0]
3920 assert(_version == 1)
3921 _type = reader.read("!B")[0]
3922 assert(_type == 4)
3923 _length = reader.read("!H")[0]
3924 orig_reader = reader
3925 reader = orig_reader.slice(_length, 4)
3926 obj.xid = reader.read("!L")[0]
3927 _experimenter = reader.read("!L")[0]
3928 assert(_experimenter == 6035143)
3929 _subtype = reader.read("!L")[0]
3930 assert(_subtype == 17)
3931 obj.vport_no = reader.read("!L")[0]
3932 return obj
3933
3934 def __eq__(self, other):
3935 if type(self) != type(other): return False
3936 if self.xid != other.xid: return False
3937 if self.vport_no != other.vport_no: return False
3938 return True
3939
3940 def pretty_print(self, q):
3941 q.text("bsn_virtual_port_remove_request {")
3942 with q.group():
3943 with q.indent(2):
3944 q.breakable()
3945 q.text("xid = ");
3946 if self.xid != None:
3947 q.text("%#x" % self.xid)
3948 else:
3949 q.text('None')
3950 q.text(","); q.breakable()
3951 q.text("vport_no = ");
3952 q.text("%#x" % self.vport_no)
3953 q.breakable()
3954 q.text('}')
3955
3956bsn_header.subtypes[17] = bsn_virtual_port_remove_request
3957
3958class desc_stats_reply(stats_reply):
3959 version = 1
3960 type = 17
3961 stats_type = 0
3962
3963 def __init__(self, xid=None, flags=None, mfr_desc=None, hw_desc=None, sw_desc=None, serial_num=None, dp_desc=None):
3964 if xid != None:
3965 self.xid = xid
3966 else:
3967 self.xid = None
3968 if flags != None:
3969 self.flags = flags
3970 else:
3971 self.flags = 0
3972 if mfr_desc != None:
3973 self.mfr_desc = mfr_desc
3974 else:
3975 self.mfr_desc = ""
3976 if hw_desc != None:
3977 self.hw_desc = hw_desc
3978 else:
3979 self.hw_desc = ""
3980 if sw_desc != None:
3981 self.sw_desc = sw_desc
3982 else:
3983 self.sw_desc = ""
3984 if serial_num != None:
3985 self.serial_num = serial_num
3986 else:
3987 self.serial_num = ""
3988 if dp_desc != None:
3989 self.dp_desc = dp_desc
3990 else:
3991 self.dp_desc = ""
3992 return
3993
3994 def pack(self):
3995 packed = []
3996 packed.append(struct.pack("!B", self.version))
3997 packed.append(struct.pack("!B", self.type))
3998 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3999 packed.append(struct.pack("!L", self.xid))
4000 packed.append(struct.pack("!H", self.stats_type))
4001 packed.append(struct.pack("!H", self.flags))
4002 packed.append(struct.pack("!256s", self.mfr_desc))
4003 packed.append(struct.pack("!256s", self.hw_desc))
4004 packed.append(struct.pack("!256s", self.sw_desc))
4005 packed.append(struct.pack("!32s", self.serial_num))
4006 packed.append(struct.pack("!256s", self.dp_desc))
4007 length = sum([len(x) for x in packed])
4008 packed[2] = struct.pack("!H", length)
4009 return ''.join(packed)
4010
4011 @staticmethod
4012 def unpack(reader):
4013 obj = desc_stats_reply()
4014 _version = reader.read("!B")[0]
4015 assert(_version == 1)
4016 _type = reader.read("!B")[0]
4017 assert(_type == 17)
4018 _length = reader.read("!H")[0]
4019 orig_reader = reader
4020 reader = orig_reader.slice(_length, 4)
4021 obj.xid = reader.read("!L")[0]
4022 _stats_type = reader.read("!H")[0]
4023 assert(_stats_type == 0)
4024 obj.flags = reader.read("!H")[0]
4025 obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00")
4026 obj.hw_desc = reader.read("!256s")[0].rstrip("\x00")
4027 obj.sw_desc = reader.read("!256s")[0].rstrip("\x00")
4028 obj.serial_num = reader.read("!32s")[0].rstrip("\x00")
4029 obj.dp_desc = reader.read("!256s")[0].rstrip("\x00")
4030 return obj
4031
4032 def __eq__(self, other):
4033 if type(self) != type(other): return False
4034 if self.xid != other.xid: return False
4035 if self.flags != other.flags: return False
4036 if self.mfr_desc != other.mfr_desc: return False
4037 if self.hw_desc != other.hw_desc: return False
4038 if self.sw_desc != other.sw_desc: return False
4039 if self.serial_num != other.serial_num: return False
4040 if self.dp_desc != other.dp_desc: return False
4041 return True
4042
4043 def pretty_print(self, q):
4044 q.text("desc_stats_reply {")
4045 with q.group():
4046 with q.indent(2):
4047 q.breakable()
4048 q.text("xid = ");
4049 if self.xid != None:
4050 q.text("%#x" % self.xid)
4051 else:
4052 q.text('None')
4053 q.text(","); q.breakable()
4054 q.text("flags = ");
4055 q.text("%#x" % self.flags)
4056 q.text(","); q.breakable()
4057 q.text("mfr_desc = ");
4058 q.pp(self.mfr_desc)
4059 q.text(","); q.breakable()
4060 q.text("hw_desc = ");
4061 q.pp(self.hw_desc)
4062 q.text(","); q.breakable()
4063 q.text("sw_desc = ");
4064 q.pp(self.sw_desc)
4065 q.text(","); q.breakable()
4066 q.text("serial_num = ");
4067 q.pp(self.serial_num)
4068 q.text(","); q.breakable()
4069 q.text("dp_desc = ");
4070 q.pp(self.dp_desc)
4071 q.breakable()
4072 q.text('}')
4073
4074stats_reply.subtypes[0] = desc_stats_reply
4075
4076class desc_stats_request(stats_request):
4077 version = 1
4078 type = 16
4079 stats_type = 0
4080
4081 def __init__(self, xid=None, flags=None):
4082 if xid != None:
4083 self.xid = xid
4084 else:
4085 self.xid = None
4086 if flags != None:
4087 self.flags = flags
4088 else:
4089 self.flags = 0
4090 return
4091
4092 def pack(self):
4093 packed = []
4094 packed.append(struct.pack("!B", self.version))
4095 packed.append(struct.pack("!B", self.type))
4096 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4097 packed.append(struct.pack("!L", self.xid))
4098 packed.append(struct.pack("!H", self.stats_type))
4099 packed.append(struct.pack("!H", self.flags))
4100 length = sum([len(x) for x in packed])
4101 packed[2] = struct.pack("!H", length)
4102 return ''.join(packed)
4103
4104 @staticmethod
4105 def unpack(reader):
4106 obj = desc_stats_request()
4107 _version = reader.read("!B")[0]
4108 assert(_version == 1)
4109 _type = reader.read("!B")[0]
4110 assert(_type == 16)
4111 _length = reader.read("!H")[0]
4112 orig_reader = reader
4113 reader = orig_reader.slice(_length, 4)
4114 obj.xid = reader.read("!L")[0]
4115 _stats_type = reader.read("!H")[0]
4116 assert(_stats_type == 0)
4117 obj.flags = reader.read("!H")[0]
4118 return obj
4119
4120 def __eq__(self, other):
4121 if type(self) != type(other): return False
4122 if self.xid != other.xid: return False
4123 if self.flags != other.flags: return False
4124 return True
4125
4126 def pretty_print(self, q):
4127 q.text("desc_stats_request {")
4128 with q.group():
4129 with q.indent(2):
4130 q.breakable()
4131 q.text("xid = ");
4132 if self.xid != None:
4133 q.text("%#x" % self.xid)
4134 else:
4135 q.text('None')
4136 q.text(","); q.breakable()
4137 q.text("flags = ");
4138 q.text("%#x" % self.flags)
4139 q.breakable()
4140 q.text('}')
4141
4142stats_request.subtypes[0] = desc_stats_request
4143
4144class echo_reply(message):
4145 version = 1
4146 type = 3
4147
4148 def __init__(self, xid=None, data=None):
4149 if xid != None:
4150 self.xid = xid
4151 else:
4152 self.xid = None
4153 if data != None:
4154 self.data = data
4155 else:
4156 self.data = ''
4157 return
4158
4159 def pack(self):
4160 packed = []
4161 packed.append(struct.pack("!B", self.version))
4162 packed.append(struct.pack("!B", self.type))
4163 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4164 packed.append(struct.pack("!L", self.xid))
4165 packed.append(self.data)
4166 length = sum([len(x) for x in packed])
4167 packed[2] = struct.pack("!H", length)
4168 return ''.join(packed)
4169
4170 @staticmethod
4171 def unpack(reader):
4172 obj = echo_reply()
4173 _version = reader.read("!B")[0]
4174 assert(_version == 1)
4175 _type = reader.read("!B")[0]
4176 assert(_type == 3)
4177 _length = reader.read("!H")[0]
4178 orig_reader = reader
4179 reader = orig_reader.slice(_length, 4)
4180 obj.xid = reader.read("!L")[0]
4181 obj.data = str(reader.read_all())
4182 return obj
4183
4184 def __eq__(self, other):
4185 if type(self) != type(other): return False
4186 if self.xid != other.xid: return False
4187 if self.data != other.data: return False
4188 return True
4189
4190 def pretty_print(self, q):
4191 q.text("echo_reply {")
4192 with q.group():
4193 with q.indent(2):
4194 q.breakable()
4195 q.text("xid = ");
4196 if self.xid != None:
4197 q.text("%#x" % self.xid)
4198 else:
4199 q.text('None')
4200 q.text(","); q.breakable()
4201 q.text("data = ");
4202 q.pp(self.data)
4203 q.breakable()
4204 q.text('}')
4205
4206message.subtypes[3] = echo_reply
4207
4208class echo_request(message):
4209 version = 1
4210 type = 2
4211
4212 def __init__(self, xid=None, data=None):
4213 if xid != None:
4214 self.xid = xid
4215 else:
4216 self.xid = None
4217 if data != None:
4218 self.data = data
4219 else:
4220 self.data = ''
4221 return
4222
4223 def pack(self):
4224 packed = []
4225 packed.append(struct.pack("!B", self.version))
4226 packed.append(struct.pack("!B", self.type))
4227 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4228 packed.append(struct.pack("!L", self.xid))
4229 packed.append(self.data)
4230 length = sum([len(x) for x in packed])
4231 packed[2] = struct.pack("!H", length)
4232 return ''.join(packed)
4233
4234 @staticmethod
4235 def unpack(reader):
4236 obj = echo_request()
4237 _version = reader.read("!B")[0]
4238 assert(_version == 1)
4239 _type = reader.read("!B")[0]
4240 assert(_type == 2)
4241 _length = reader.read("!H")[0]
4242 orig_reader = reader
4243 reader = orig_reader.slice(_length, 4)
4244 obj.xid = reader.read("!L")[0]
4245 obj.data = str(reader.read_all())
4246 return obj
4247
4248 def __eq__(self, other):
4249 if type(self) != type(other): return False
4250 if self.xid != other.xid: return False
4251 if self.data != other.data: return False
4252 return True
4253
4254 def pretty_print(self, q):
4255 q.text("echo_request {")
4256 with q.group():
4257 with q.indent(2):
4258 q.breakable()
4259 q.text("xid = ");
4260 if self.xid != None:
4261 q.text("%#x" % self.xid)
4262 else:
4263 q.text('None')
4264 q.text(","); q.breakable()
4265 q.text("data = ");
4266 q.pp(self.data)
4267 q.breakable()
4268 q.text('}')
4269
4270message.subtypes[2] = echo_request
4271
4272class features_reply(message):
4273 version = 1
4274 type = 6
4275
4276 def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, capabilities=None, actions=None, ports=None):
4277 if xid != None:
4278 self.xid = xid
4279 else:
4280 self.xid = None
4281 if datapath_id != None:
4282 self.datapath_id = datapath_id
4283 else:
4284 self.datapath_id = 0
4285 if n_buffers != None:
4286 self.n_buffers = n_buffers
4287 else:
4288 self.n_buffers = 0
4289 if n_tables != None:
4290 self.n_tables = n_tables
4291 else:
4292 self.n_tables = 0
4293 if capabilities != None:
4294 self.capabilities = capabilities
4295 else:
4296 self.capabilities = 0
4297 if actions != None:
4298 self.actions = actions
4299 else:
4300 self.actions = 0
4301 if ports != None:
4302 self.ports = ports
4303 else:
4304 self.ports = []
4305 return
4306
4307 def pack(self):
4308 packed = []
4309 packed.append(struct.pack("!B", self.version))
4310 packed.append(struct.pack("!B", self.type))
4311 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4312 packed.append(struct.pack("!L", self.xid))
4313 packed.append(struct.pack("!Q", self.datapath_id))
4314 packed.append(struct.pack("!L", self.n_buffers))
4315 packed.append(struct.pack("!B", self.n_tables))
4316 packed.append('\x00' * 3)
4317 packed.append(struct.pack("!L", self.capabilities))
4318 packed.append(struct.pack("!L", self.actions))
4319 packed.append(loxi.generic_util.pack_list(self.ports))
4320 length = sum([len(x) for x in packed])
4321 packed[2] = struct.pack("!H", length)
4322 return ''.join(packed)
4323
4324 @staticmethod
4325 def unpack(reader):
4326 obj = features_reply()
4327 _version = reader.read("!B")[0]
4328 assert(_version == 1)
4329 _type = reader.read("!B")[0]
4330 assert(_type == 6)
4331 _length = reader.read("!H")[0]
4332 orig_reader = reader
4333 reader = orig_reader.slice(_length, 4)
4334 obj.xid = reader.read("!L")[0]
4335 obj.datapath_id = reader.read("!Q")[0]
4336 obj.n_buffers = reader.read("!L")[0]
4337 obj.n_tables = reader.read("!B")[0]
4338 reader.skip(3)
4339 obj.capabilities = reader.read("!L")[0]
4340 obj.actions = reader.read("!L")[0]
4341 obj.ports = loxi.generic_util.unpack_list(reader, ofp.common.port_desc.unpack)
4342 return obj
4343
4344 def __eq__(self, other):
4345 if type(self) != type(other): return False
4346 if self.xid != other.xid: return False
4347 if self.datapath_id != other.datapath_id: return False
4348 if self.n_buffers != other.n_buffers: return False
4349 if self.n_tables != other.n_tables: return False
4350 if self.capabilities != other.capabilities: return False
4351 if self.actions != other.actions: return False
4352 if self.ports != other.ports: return False
4353 return True
4354
4355 def pretty_print(self, q):
4356 q.text("features_reply {")
4357 with q.group():
4358 with q.indent(2):
4359 q.breakable()
4360 q.text("xid = ");
4361 if self.xid != None:
4362 q.text("%#x" % self.xid)
4363 else:
4364 q.text('None')
4365 q.text(","); q.breakable()
4366 q.text("datapath_id = ");
4367 q.text("%#x" % self.datapath_id)
4368 q.text(","); q.breakable()
4369 q.text("n_buffers = ");
4370 q.text("%#x" % self.n_buffers)
4371 q.text(","); q.breakable()
4372 q.text("n_tables = ");
4373 q.text("%#x" % self.n_tables)
4374 q.text(","); q.breakable()
4375 q.text("capabilities = ");
4376 q.text("%#x" % self.capabilities)
4377 q.text(","); q.breakable()
4378 q.text("actions = ");
4379 q.text("%#x" % self.actions)
4380 q.text(","); q.breakable()
4381 q.text("ports = ");
4382 q.pp(self.ports)
4383 q.breakable()
4384 q.text('}')
4385
4386message.subtypes[6] = features_reply
4387
4388class features_request(message):
4389 version = 1
4390 type = 5
4391
4392 def __init__(self, xid=None):
4393 if xid != None:
4394 self.xid = xid
4395 else:
4396 self.xid = None
4397 return
4398
4399 def pack(self):
4400 packed = []
4401 packed.append(struct.pack("!B", self.version))
4402 packed.append(struct.pack("!B", self.type))
4403 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4404 packed.append(struct.pack("!L", self.xid))
4405 length = sum([len(x) for x in packed])
4406 packed[2] = struct.pack("!H", length)
4407 return ''.join(packed)
4408
4409 @staticmethod
4410 def unpack(reader):
4411 obj = features_request()
4412 _version = reader.read("!B")[0]
4413 assert(_version == 1)
4414 _type = reader.read("!B")[0]
4415 assert(_type == 5)
4416 _length = reader.read("!H")[0]
4417 orig_reader = reader
4418 reader = orig_reader.slice(_length, 4)
4419 obj.xid = reader.read("!L")[0]
4420 return obj
4421
4422 def __eq__(self, other):
4423 if type(self) != type(other): return False
4424 if self.xid != other.xid: return False
4425 return True
4426
4427 def pretty_print(self, q):
4428 q.text("features_request {")
4429 with q.group():
4430 with q.indent(2):
4431 q.breakable()
4432 q.text("xid = ");
4433 if self.xid != None:
4434 q.text("%#x" % self.xid)
4435 else:
4436 q.text('None')
4437 q.breakable()
4438 q.text('}')
4439
4440message.subtypes[5] = features_request
4441
4442class flow_mod(message):
4443 subtypes = {}
4444
4445 version = 1
4446 type = 14
4447
4448 def __init__(self, xid=None, match=None, cookie=None, _command=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
4449 if xid != None:
4450 self.xid = xid
4451 else:
4452 self.xid = None
4453 if match != None:
4454 self.match = match
4455 else:
4456 self.match = ofp.match()
4457 if cookie != None:
4458 self.cookie = cookie
4459 else:
4460 self.cookie = 0
4461 if _command != None:
4462 self._command = _command
4463 else:
4464 self._command = 0
4465 if idle_timeout != None:
4466 self.idle_timeout = idle_timeout
4467 else:
4468 self.idle_timeout = 0
4469 if hard_timeout != None:
4470 self.hard_timeout = hard_timeout
4471 else:
4472 self.hard_timeout = 0
4473 if priority != None:
4474 self.priority = priority
4475 else:
4476 self.priority = 0
4477 if buffer_id != None:
4478 self.buffer_id = buffer_id
4479 else:
4480 self.buffer_id = 0
4481 if out_port != None:
4482 self.out_port = out_port
4483 else:
4484 self.out_port = 0
4485 if flags != None:
4486 self.flags = flags
4487 else:
4488 self.flags = 0
4489 if actions != None:
4490 self.actions = actions
4491 else:
4492 self.actions = []
4493 return
4494
4495 def pack(self):
4496 packed = []
4497 packed.append(struct.pack("!B", self.version))
4498 packed.append(struct.pack("!B", self.type))
4499 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4500 packed.append(struct.pack("!L", self.xid))
4501 packed.append(self.match.pack())
4502 packed.append(struct.pack("!Q", self.cookie))
4503 packed.append(util.pack_fm_cmd(self._command))
4504 packed.append(struct.pack("!H", self.idle_timeout))
4505 packed.append(struct.pack("!H", self.hard_timeout))
4506 packed.append(struct.pack("!H", self.priority))
4507 packed.append(struct.pack("!L", self.buffer_id))
4508 packed.append(util.pack_port_no(self.out_port))
4509 packed.append(struct.pack("!H", self.flags))
4510 packed.append(loxi.generic_util.pack_list(self.actions))
4511 length = sum([len(x) for x in packed])
4512 packed[2] = struct.pack("!H", length)
4513 return ''.join(packed)
4514
4515 @staticmethod
4516 def unpack(reader):
4517 subtype, = reader.peek('!H', 56)
4518 subclass = flow_mod.subtypes.get(subtype)
4519 if subclass:
4520 return subclass.unpack(reader)
4521
4522 obj = flow_mod()
4523 _version = reader.read("!B")[0]
4524 assert(_version == 1)
4525 _type = reader.read("!B")[0]
4526 assert(_type == 14)
4527 _length = reader.read("!H")[0]
4528 orig_reader = reader
4529 reader = orig_reader.slice(_length, 4)
4530 obj.xid = reader.read("!L")[0]
4531 obj.match = ofp.match.unpack(reader)
4532 obj.cookie = reader.read("!Q")[0]
4533 obj._command = util.unpack_fm_cmd(reader)
4534 obj.idle_timeout = reader.read("!H")[0]
4535 obj.hard_timeout = reader.read("!H")[0]
4536 obj.priority = reader.read("!H")[0]
4537 obj.buffer_id = reader.read("!L")[0]
4538 obj.out_port = util.unpack_port_no(reader)
4539 obj.flags = reader.read("!H")[0]
4540 obj.actions = loxi.generic_util.unpack_list(reader, ofp.action.action.unpack)
4541 return obj
4542
4543 def __eq__(self, other):
4544 if type(self) != type(other): return False
4545 if self.xid != other.xid: return False
4546 if self.match != other.match: return False
4547 if self.cookie != other.cookie: return False
4548 if self._command != other._command: return False
4549 if self.idle_timeout != other.idle_timeout: return False
4550 if self.hard_timeout != other.hard_timeout: return False
4551 if self.priority != other.priority: return False
4552 if self.buffer_id != other.buffer_id: return False
4553 if self.out_port != other.out_port: return False
4554 if self.flags != other.flags: return False
4555 if self.actions != other.actions: return False
4556 return True
4557
4558 def pretty_print(self, q):
4559 q.text("flow_mod {")
4560 with q.group():
4561 with q.indent(2):
4562 q.breakable()
4563 q.text("xid = ");
4564 if self.xid != None:
4565 q.text("%#x" % self.xid)
4566 else:
4567 q.text('None')
4568 q.text(","); q.breakable()
4569 q.text("match = ");
4570 q.pp(self.match)
4571 q.text(","); q.breakable()
4572 q.text("cookie = ");
4573 q.text("%#x" % self.cookie)
4574 q.text(","); q.breakable()
4575 q.text("idle_timeout = ");
4576 q.text("%#x" % self.idle_timeout)
4577 q.text(","); q.breakable()
4578 q.text("hard_timeout = ");
4579 q.text("%#x" % self.hard_timeout)
4580 q.text(","); q.breakable()
4581 q.text("priority = ");
4582 q.text("%#x" % self.priority)
4583 q.text(","); q.breakable()
4584 q.text("buffer_id = ");
4585 q.text("%#x" % self.buffer_id)
4586 q.text(","); q.breakable()
4587 q.text("out_port = ");
4588 q.text(util.pretty_port(self.out_port))
4589 q.text(","); q.breakable()
4590 q.text("flags = ");
4591 q.text("%#x" % self.flags)
4592 q.text(","); q.breakable()
4593 q.text("actions = ");
4594 q.pp(self.actions)
4595 q.breakable()
4596 q.text('}')
4597
4598message.subtypes[14] = flow_mod
4599
4600class flow_add(flow_mod):
4601 version = 1
4602 type = 14
4603 _command = 0
4604
4605 def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
4606 if xid != None:
4607 self.xid = xid
4608 else:
4609 self.xid = None
4610 if match != None:
4611 self.match = match
4612 else:
4613 self.match = ofp.match()
4614 if cookie != None:
4615 self.cookie = cookie
4616 else:
4617 self.cookie = 0
4618 if idle_timeout != None:
4619 self.idle_timeout = idle_timeout
4620 else:
4621 self.idle_timeout = 0
4622 if hard_timeout != None:
4623 self.hard_timeout = hard_timeout
4624 else:
4625 self.hard_timeout = 0
4626 if priority != None:
4627 self.priority = priority
4628 else:
4629 self.priority = 0
4630 if buffer_id != None:
4631 self.buffer_id = buffer_id
4632 else:
4633 self.buffer_id = 0
4634 if out_port != None:
4635 self.out_port = out_port
4636 else:
4637 self.out_port = 0
4638 if flags != None:
4639 self.flags = flags
4640 else:
4641 self.flags = 0
4642 if actions != None:
4643 self.actions = actions
4644 else:
4645 self.actions = []
4646 return
4647
4648 def pack(self):
4649 packed = []
4650 packed.append(struct.pack("!B", self.version))
4651 packed.append(struct.pack("!B", self.type))
4652 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4653 packed.append(struct.pack("!L", self.xid))
4654 packed.append(self.match.pack())
4655 packed.append(struct.pack("!Q", self.cookie))
4656 packed.append(util.pack_fm_cmd(self._command))
4657 packed.append(struct.pack("!H", self.idle_timeout))
4658 packed.append(struct.pack("!H", self.hard_timeout))
4659 packed.append(struct.pack("!H", self.priority))
4660 packed.append(struct.pack("!L", self.buffer_id))
4661 packed.append(util.pack_port_no(self.out_port))
4662 packed.append(struct.pack("!H", self.flags))
4663 packed.append(loxi.generic_util.pack_list(self.actions))
4664 length = sum([len(x) for x in packed])
4665 packed[2] = struct.pack("!H", length)
4666 return ''.join(packed)
4667
4668 @staticmethod
4669 def unpack(reader):
4670 obj = flow_add()
4671 _version = reader.read("!B")[0]
4672 assert(_version == 1)
4673 _type = reader.read("!B")[0]
4674 assert(_type == 14)
4675 _length = reader.read("!H")[0]
4676 orig_reader = reader
4677 reader = orig_reader.slice(_length, 4)
4678 obj.xid = reader.read("!L")[0]
4679 obj.match = ofp.match.unpack(reader)
4680 obj.cookie = reader.read("!Q")[0]
4681 __command = util.unpack_fm_cmd(reader)
4682 assert(__command == 0)
4683 obj.idle_timeout = reader.read("!H")[0]
4684 obj.hard_timeout = reader.read("!H")[0]
4685 obj.priority = reader.read("!H")[0]
4686 obj.buffer_id = reader.read("!L")[0]
4687 obj.out_port = util.unpack_port_no(reader)
4688 obj.flags = reader.read("!H")[0]
4689 obj.actions = loxi.generic_util.unpack_list(reader, ofp.action.action.unpack)
4690 return obj
4691
4692 def __eq__(self, other):
4693 if type(self) != type(other): return False
4694 if self.xid != other.xid: return False
4695 if self.match != other.match: return False
4696 if self.cookie != other.cookie: return False
4697 if self.idle_timeout != other.idle_timeout: return False
4698 if self.hard_timeout != other.hard_timeout: return False
4699 if self.priority != other.priority: return False
4700 if self.buffer_id != other.buffer_id: return False
4701 if self.out_port != other.out_port: return False
4702 if self.flags != other.flags: return False
4703 if self.actions != other.actions: return False
4704 return True
4705
4706 def pretty_print(self, q):
4707 q.text("flow_add {")
4708 with q.group():
4709 with q.indent(2):
4710 q.breakable()
4711 q.text("xid = ");
4712 if self.xid != None:
4713 q.text("%#x" % self.xid)
4714 else:
4715 q.text('None')
4716 q.text(","); q.breakable()
4717 q.text("match = ");
4718 q.pp(self.match)
4719 q.text(","); q.breakable()
4720 q.text("cookie = ");
4721 q.text("%#x" % self.cookie)
4722 q.text(","); q.breakable()
4723 q.text("idle_timeout = ");
4724 q.text("%#x" % self.idle_timeout)
4725 q.text(","); q.breakable()
4726 q.text("hard_timeout = ");
4727 q.text("%#x" % self.hard_timeout)
4728 q.text(","); q.breakable()
4729 q.text("priority = ");
4730 q.text("%#x" % self.priority)
4731 q.text(","); q.breakable()
4732 q.text("buffer_id = ");
4733 q.text("%#x" % self.buffer_id)
4734 q.text(","); q.breakable()
4735 q.text("out_port = ");
4736 q.text(util.pretty_port(self.out_port))
4737 q.text(","); q.breakable()
4738 q.text("flags = ");
4739 q.text("%#x" % self.flags)
4740 q.text(","); q.breakable()
4741 q.text("actions = ");
4742 q.pp(self.actions)
4743 q.breakable()
4744 q.text('}')
4745
4746flow_mod.subtypes[0] = flow_add
4747
4748class flow_delete(flow_mod):
4749 version = 1
4750 type = 14
4751 _command = 3
4752
4753 def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
4754 if xid != None:
4755 self.xid = xid
4756 else:
4757 self.xid = None
4758 if match != None:
4759 self.match = match
4760 else:
4761 self.match = ofp.match()
4762 if cookie != None:
4763 self.cookie = cookie
4764 else:
4765 self.cookie = 0
4766 if idle_timeout != None:
4767 self.idle_timeout = idle_timeout
4768 else:
4769 self.idle_timeout = 0
4770 if hard_timeout != None:
4771 self.hard_timeout = hard_timeout
4772 else:
4773 self.hard_timeout = 0
4774 if priority != None:
4775 self.priority = priority
4776 else:
4777 self.priority = 0
4778 if buffer_id != None:
4779 self.buffer_id = buffer_id
4780 else:
4781 self.buffer_id = 0
4782 if out_port != None:
4783 self.out_port = out_port
4784 else:
4785 self.out_port = 0
4786 if flags != None:
4787 self.flags = flags
4788 else:
4789 self.flags = 0
4790 if actions != None:
4791 self.actions = actions
4792 else:
4793 self.actions = []
4794 return
4795
4796 def pack(self):
4797 packed = []
4798 packed.append(struct.pack("!B", self.version))
4799 packed.append(struct.pack("!B", self.type))
4800 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4801 packed.append(struct.pack("!L", self.xid))
4802 packed.append(self.match.pack())
4803 packed.append(struct.pack("!Q", self.cookie))
4804 packed.append(util.pack_fm_cmd(self._command))
4805 packed.append(struct.pack("!H", self.idle_timeout))
4806 packed.append(struct.pack("!H", self.hard_timeout))
4807 packed.append(struct.pack("!H", self.priority))
4808 packed.append(struct.pack("!L", self.buffer_id))
4809 packed.append(util.pack_port_no(self.out_port))
4810 packed.append(struct.pack("!H", self.flags))
4811 packed.append(loxi.generic_util.pack_list(self.actions))
4812 length = sum([len(x) for x in packed])
4813 packed[2] = struct.pack("!H", length)
4814 return ''.join(packed)
4815
4816 @staticmethod
4817 def unpack(reader):
4818 obj = flow_delete()
4819 _version = reader.read("!B")[0]
4820 assert(_version == 1)
4821 _type = reader.read("!B")[0]
4822 assert(_type == 14)
4823 _length = reader.read("!H")[0]
4824 orig_reader = reader
4825 reader = orig_reader.slice(_length, 4)
4826 obj.xid = reader.read("!L")[0]
4827 obj.match = ofp.match.unpack(reader)
4828 obj.cookie = reader.read("!Q")[0]
4829 __command = util.unpack_fm_cmd(reader)
4830 assert(__command == 3)
4831 obj.idle_timeout = reader.read("!H")[0]
4832 obj.hard_timeout = reader.read("!H")[0]
4833 obj.priority = reader.read("!H")[0]
4834 obj.buffer_id = reader.read("!L")[0]
4835 obj.out_port = util.unpack_port_no(reader)
4836 obj.flags = reader.read("!H")[0]
4837 obj.actions = loxi.generic_util.unpack_list(reader, ofp.action.action.unpack)
4838 return obj
4839
4840 def __eq__(self, other):
4841 if type(self) != type(other): return False
4842 if self.xid != other.xid: return False
4843 if self.match != other.match: return False
4844 if self.cookie != other.cookie: return False
4845 if self.idle_timeout != other.idle_timeout: return False
4846 if self.hard_timeout != other.hard_timeout: return False
4847 if self.priority != other.priority: return False
4848 if self.buffer_id != other.buffer_id: return False
4849 if self.out_port != other.out_port: return False
4850 if self.flags != other.flags: return False
4851 if self.actions != other.actions: return False
4852 return True
4853
4854 def pretty_print(self, q):
4855 q.text("flow_delete {")
4856 with q.group():
4857 with q.indent(2):
4858 q.breakable()
4859 q.text("xid = ");
4860 if self.xid != None:
4861 q.text("%#x" % self.xid)
4862 else:
4863 q.text('None')
4864 q.text(","); q.breakable()
4865 q.text("match = ");
4866 q.pp(self.match)
4867 q.text(","); q.breakable()
4868 q.text("cookie = ");
4869 q.text("%#x" % self.cookie)
4870 q.text(","); q.breakable()
4871 q.text("idle_timeout = ");
4872 q.text("%#x" % self.idle_timeout)
4873 q.text(","); q.breakable()
4874 q.text("hard_timeout = ");
4875 q.text("%#x" % self.hard_timeout)
4876 q.text(","); q.breakable()
4877 q.text("priority = ");
4878 q.text("%#x" % self.priority)
4879 q.text(","); q.breakable()
4880 q.text("buffer_id = ");
4881 q.text("%#x" % self.buffer_id)
4882 q.text(","); q.breakable()
4883 q.text("out_port = ");
4884 q.text(util.pretty_port(self.out_port))
4885 q.text(","); q.breakable()
4886 q.text("flags = ");
4887 q.text("%#x" % self.flags)
4888 q.text(","); q.breakable()
4889 q.text("actions = ");
4890 q.pp(self.actions)
4891 q.breakable()
4892 q.text('}')
4893
4894flow_mod.subtypes[3] = flow_delete
4895
4896class flow_delete_strict(flow_mod):
4897 version = 1
4898 type = 14
4899 _command = 4
4900
4901 def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
4902 if xid != None:
4903 self.xid = xid
4904 else:
4905 self.xid = None
4906 if match != None:
4907 self.match = match
4908 else:
4909 self.match = ofp.match()
4910 if cookie != None:
4911 self.cookie = cookie
4912 else:
4913 self.cookie = 0
4914 if idle_timeout != None:
4915 self.idle_timeout = idle_timeout
4916 else:
4917 self.idle_timeout = 0
4918 if hard_timeout != None:
4919 self.hard_timeout = hard_timeout
4920 else:
4921 self.hard_timeout = 0
4922 if priority != None:
4923 self.priority = priority
4924 else:
4925 self.priority = 0
4926 if buffer_id != None:
4927 self.buffer_id = buffer_id
4928 else:
4929 self.buffer_id = 0
4930 if out_port != None:
4931 self.out_port = out_port
4932 else:
4933 self.out_port = 0
4934 if flags != None:
4935 self.flags = flags
4936 else:
4937 self.flags = 0
4938 if actions != None:
4939 self.actions = actions
4940 else:
4941 self.actions = []
4942 return
4943
4944 def pack(self):
4945 packed = []
4946 packed.append(struct.pack("!B", self.version))
4947 packed.append(struct.pack("!B", self.type))
4948 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4949 packed.append(struct.pack("!L", self.xid))
4950 packed.append(self.match.pack())
4951 packed.append(struct.pack("!Q", self.cookie))
4952 packed.append(util.pack_fm_cmd(self._command))
4953 packed.append(struct.pack("!H", self.idle_timeout))
4954 packed.append(struct.pack("!H", self.hard_timeout))
4955 packed.append(struct.pack("!H", self.priority))
4956 packed.append(struct.pack("!L", self.buffer_id))
4957 packed.append(util.pack_port_no(self.out_port))
4958 packed.append(struct.pack("!H", self.flags))
4959 packed.append(loxi.generic_util.pack_list(self.actions))
4960 length = sum([len(x) for x in packed])
4961 packed[2] = struct.pack("!H", length)
4962 return ''.join(packed)
4963
4964 @staticmethod
4965 def unpack(reader):
4966 obj = flow_delete_strict()
4967 _version = reader.read("!B")[0]
4968 assert(_version == 1)
4969 _type = reader.read("!B")[0]
4970 assert(_type == 14)
4971 _length = reader.read("!H")[0]
4972 orig_reader = reader
4973 reader = orig_reader.slice(_length, 4)
4974 obj.xid = reader.read("!L")[0]
4975 obj.match = ofp.match.unpack(reader)
4976 obj.cookie = reader.read("!Q")[0]
4977 __command = util.unpack_fm_cmd(reader)
4978 assert(__command == 4)
4979 obj.idle_timeout = reader.read("!H")[0]
4980 obj.hard_timeout = reader.read("!H")[0]
4981 obj.priority = reader.read("!H")[0]
4982 obj.buffer_id = reader.read("!L")[0]
4983 obj.out_port = util.unpack_port_no(reader)
4984 obj.flags = reader.read("!H")[0]
4985 obj.actions = loxi.generic_util.unpack_list(reader, ofp.action.action.unpack)
4986 return obj
4987
4988 def __eq__(self, other):
4989 if type(self) != type(other): return False
4990 if self.xid != other.xid: return False
4991 if self.match != other.match: return False
4992 if self.cookie != other.cookie: return False
4993 if self.idle_timeout != other.idle_timeout: return False
4994 if self.hard_timeout != other.hard_timeout: return False
4995 if self.priority != other.priority: return False
4996 if self.buffer_id != other.buffer_id: return False
4997 if self.out_port != other.out_port: return False
4998 if self.flags != other.flags: return False
4999 if self.actions != other.actions: return False
5000 return True
5001
5002 def pretty_print(self, q):
5003 q.text("flow_delete_strict {")
5004 with q.group():
5005 with q.indent(2):
5006 q.breakable()
5007 q.text("xid = ");
5008 if self.xid != None:
5009 q.text("%#x" % self.xid)
5010 else:
5011 q.text('None')
5012 q.text(","); q.breakable()
5013 q.text("match = ");
5014 q.pp(self.match)
5015 q.text(","); q.breakable()
5016 q.text("cookie = ");
5017 q.text("%#x" % self.cookie)
5018 q.text(","); q.breakable()
5019 q.text("idle_timeout = ");
5020 q.text("%#x" % self.idle_timeout)
5021 q.text(","); q.breakable()
5022 q.text("hard_timeout = ");
5023 q.text("%#x" % self.hard_timeout)
5024 q.text(","); q.breakable()
5025 q.text("priority = ");
5026 q.text("%#x" % self.priority)
5027 q.text(","); q.breakable()
5028 q.text("buffer_id = ");
5029 q.text("%#x" % self.buffer_id)
5030 q.text(","); q.breakable()
5031 q.text("out_port = ");
5032 q.text(util.pretty_port(self.out_port))
5033 q.text(","); q.breakable()
5034 q.text("flags = ");
5035 q.text("%#x" % self.flags)
5036 q.text(","); q.breakable()
5037 q.text("actions = ");
5038 q.pp(self.actions)
5039 q.breakable()
5040 q.text('}')
5041
5042flow_mod.subtypes[4] = flow_delete_strict
5043
5044class flow_mod_failed_error_msg(error_msg):
5045 version = 1
5046 type = 1
5047 err_type = 3
5048
5049 def __init__(self, xid=None, code=None, data=None):
5050 if xid != None:
5051 self.xid = xid
5052 else:
5053 self.xid = None
5054 if code != None:
5055 self.code = code
5056 else:
5057 self.code = 0
5058 if data != None:
5059 self.data = data
5060 else:
5061 self.data = ''
5062 return
5063
5064 def pack(self):
5065 packed = []
5066 packed.append(struct.pack("!B", self.version))
5067 packed.append(struct.pack("!B", self.type))
5068 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5069 packed.append(struct.pack("!L", self.xid))
5070 packed.append(struct.pack("!H", self.err_type))
5071 packed.append(struct.pack("!H", self.code))
5072 packed.append(self.data)
5073 length = sum([len(x) for x in packed])
5074 packed[2] = struct.pack("!H", length)
5075 return ''.join(packed)
5076
5077 @staticmethod
5078 def unpack(reader):
5079 obj = flow_mod_failed_error_msg()
5080 _version = reader.read("!B")[0]
5081 assert(_version == 1)
5082 _type = reader.read("!B")[0]
5083 assert(_type == 1)
5084 _length = reader.read("!H")[0]
5085 orig_reader = reader
5086 reader = orig_reader.slice(_length, 4)
5087 obj.xid = reader.read("!L")[0]
5088 _err_type = reader.read("!H")[0]
5089 assert(_err_type == 3)
5090 obj.code = reader.read("!H")[0]
5091 obj.data = str(reader.read_all())
5092 return obj
5093
5094 def __eq__(self, other):
5095 if type(self) != type(other): return False
5096 if self.xid != other.xid: return False
5097 if self.code != other.code: return False
5098 if self.data != other.data: return False
5099 return True
5100
5101 def pretty_print(self, q):
5102 q.text("flow_mod_failed_error_msg {")
5103 with q.group():
5104 with q.indent(2):
5105 q.breakable()
5106 q.text("xid = ");
5107 if self.xid != None:
5108 q.text("%#x" % self.xid)
5109 else:
5110 q.text('None')
5111 q.text(","); q.breakable()
5112 q.text("code = ");
5113 q.text("%#x" % self.code)
5114 q.text(","); q.breakable()
5115 q.text("data = ");
5116 q.pp(self.data)
5117 q.breakable()
5118 q.text('}')
5119
5120error_msg.subtypes[3] = flow_mod_failed_error_msg
5121
5122class flow_modify(flow_mod):
5123 version = 1
5124 type = 14
5125 _command = 1
5126
5127 def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
5128 if xid != None:
5129 self.xid = xid
5130 else:
5131 self.xid = None
5132 if match != None:
5133 self.match = match
5134 else:
5135 self.match = ofp.match()
5136 if cookie != None:
5137 self.cookie = cookie
5138 else:
5139 self.cookie = 0
5140 if idle_timeout != None:
5141 self.idle_timeout = idle_timeout
5142 else:
5143 self.idle_timeout = 0
5144 if hard_timeout != None:
5145 self.hard_timeout = hard_timeout
5146 else:
5147 self.hard_timeout = 0
5148 if priority != None:
5149 self.priority = priority
5150 else:
5151 self.priority = 0
5152 if buffer_id != None:
5153 self.buffer_id = buffer_id
5154 else:
5155 self.buffer_id = 0
5156 if out_port != None:
5157 self.out_port = out_port
5158 else:
5159 self.out_port = 0
5160 if flags != None:
5161 self.flags = flags
5162 else:
5163 self.flags = 0
5164 if actions != None:
5165 self.actions = actions
5166 else:
5167 self.actions = []
5168 return
5169
5170 def pack(self):
5171 packed = []
5172 packed.append(struct.pack("!B", self.version))
5173 packed.append(struct.pack("!B", self.type))
5174 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5175 packed.append(struct.pack("!L", self.xid))
5176 packed.append(self.match.pack())
5177 packed.append(struct.pack("!Q", self.cookie))
5178 packed.append(util.pack_fm_cmd(self._command))
5179 packed.append(struct.pack("!H", self.idle_timeout))
5180 packed.append(struct.pack("!H", self.hard_timeout))
5181 packed.append(struct.pack("!H", self.priority))
5182 packed.append(struct.pack("!L", self.buffer_id))
5183 packed.append(util.pack_port_no(self.out_port))
5184 packed.append(struct.pack("!H", self.flags))
5185 packed.append(loxi.generic_util.pack_list(self.actions))
5186 length = sum([len(x) for x in packed])
5187 packed[2] = struct.pack("!H", length)
5188 return ''.join(packed)
5189
5190 @staticmethod
5191 def unpack(reader):
5192 obj = flow_modify()
5193 _version = reader.read("!B")[0]
5194 assert(_version == 1)
5195 _type = reader.read("!B")[0]
5196 assert(_type == 14)
5197 _length = reader.read("!H")[0]
5198 orig_reader = reader
5199 reader = orig_reader.slice(_length, 4)
5200 obj.xid = reader.read("!L")[0]
5201 obj.match = ofp.match.unpack(reader)
5202 obj.cookie = reader.read("!Q")[0]
5203 __command = util.unpack_fm_cmd(reader)
5204 assert(__command == 1)
5205 obj.idle_timeout = reader.read("!H")[0]
5206 obj.hard_timeout = reader.read("!H")[0]
5207 obj.priority = reader.read("!H")[0]
5208 obj.buffer_id = reader.read("!L")[0]
5209 obj.out_port = util.unpack_port_no(reader)
5210 obj.flags = reader.read("!H")[0]
5211 obj.actions = loxi.generic_util.unpack_list(reader, ofp.action.action.unpack)
5212 return obj
5213
5214 def __eq__(self, other):
5215 if type(self) != type(other): return False
5216 if self.xid != other.xid: return False
5217 if self.match != other.match: return False
5218 if self.cookie != other.cookie: return False
5219 if self.idle_timeout != other.idle_timeout: return False
5220 if self.hard_timeout != other.hard_timeout: return False
5221 if self.priority != other.priority: return False
5222 if self.buffer_id != other.buffer_id: return False
5223 if self.out_port != other.out_port: return False
5224 if self.flags != other.flags: return False
5225 if self.actions != other.actions: return False
5226 return True
5227
5228 def pretty_print(self, q):
5229 q.text("flow_modify {")
5230 with q.group():
5231 with q.indent(2):
5232 q.breakable()
5233 q.text("xid = ");
5234 if self.xid != None:
5235 q.text("%#x" % self.xid)
5236 else:
5237 q.text('None')
5238 q.text(","); q.breakable()
5239 q.text("match = ");
5240 q.pp(self.match)
5241 q.text(","); q.breakable()
5242 q.text("cookie = ");
5243 q.text("%#x" % self.cookie)
5244 q.text(","); q.breakable()
5245 q.text("idle_timeout = ");
5246 q.text("%#x" % self.idle_timeout)
5247 q.text(","); q.breakable()
5248 q.text("hard_timeout = ");
5249 q.text("%#x" % self.hard_timeout)
5250 q.text(","); q.breakable()
5251 q.text("priority = ");
5252 q.text("%#x" % self.priority)
5253 q.text(","); q.breakable()
5254 q.text("buffer_id = ");
5255 q.text("%#x" % self.buffer_id)
5256 q.text(","); q.breakable()
5257 q.text("out_port = ");
5258 q.text(util.pretty_port(self.out_port))
5259 q.text(","); q.breakable()
5260 q.text("flags = ");
5261 q.text("%#x" % self.flags)
5262 q.text(","); q.breakable()
5263 q.text("actions = ");
5264 q.pp(self.actions)
5265 q.breakable()
5266 q.text('}')
5267
5268flow_mod.subtypes[1] = flow_modify
5269
5270class flow_modify_strict(flow_mod):
5271 version = 1
5272 type = 14
5273 _command = 2
5274
5275 def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
5276 if xid != None:
5277 self.xid = xid
5278 else:
5279 self.xid = None
5280 if match != None:
5281 self.match = match
5282 else:
5283 self.match = ofp.match()
5284 if cookie != None:
5285 self.cookie = cookie
5286 else:
5287 self.cookie = 0
5288 if idle_timeout != None:
5289 self.idle_timeout = idle_timeout
5290 else:
5291 self.idle_timeout = 0
5292 if hard_timeout != None:
5293 self.hard_timeout = hard_timeout
5294 else:
5295 self.hard_timeout = 0
5296 if priority != None:
5297 self.priority = priority
5298 else:
5299 self.priority = 0
5300 if buffer_id != None:
5301 self.buffer_id = buffer_id
5302 else:
5303 self.buffer_id = 0
5304 if out_port != None:
5305 self.out_port = out_port
5306 else:
5307 self.out_port = 0
5308 if flags != None:
5309 self.flags = flags
5310 else:
5311 self.flags = 0
5312 if actions != None:
5313 self.actions = actions
5314 else:
5315 self.actions = []
5316 return
5317
5318 def pack(self):
5319 packed = []
5320 packed.append(struct.pack("!B", self.version))
5321 packed.append(struct.pack("!B", self.type))
5322 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5323 packed.append(struct.pack("!L", self.xid))
5324 packed.append(self.match.pack())
5325 packed.append(struct.pack("!Q", self.cookie))
5326 packed.append(util.pack_fm_cmd(self._command))
5327 packed.append(struct.pack("!H", self.idle_timeout))
5328 packed.append(struct.pack("!H", self.hard_timeout))
5329 packed.append(struct.pack("!H", self.priority))
5330 packed.append(struct.pack("!L", self.buffer_id))
5331 packed.append(util.pack_port_no(self.out_port))
5332 packed.append(struct.pack("!H", self.flags))
5333 packed.append(loxi.generic_util.pack_list(self.actions))
5334 length = sum([len(x) for x in packed])
5335 packed[2] = struct.pack("!H", length)
5336 return ''.join(packed)
5337
5338 @staticmethod
5339 def unpack(reader):
5340 obj = flow_modify_strict()
5341 _version = reader.read("!B")[0]
5342 assert(_version == 1)
5343 _type = reader.read("!B")[0]
5344 assert(_type == 14)
5345 _length = reader.read("!H")[0]
5346 orig_reader = reader
5347 reader = orig_reader.slice(_length, 4)
5348 obj.xid = reader.read("!L")[0]
5349 obj.match = ofp.match.unpack(reader)
5350 obj.cookie = reader.read("!Q")[0]
5351 __command = util.unpack_fm_cmd(reader)
5352 assert(__command == 2)
5353 obj.idle_timeout = reader.read("!H")[0]
5354 obj.hard_timeout = reader.read("!H")[0]
5355 obj.priority = reader.read("!H")[0]
5356 obj.buffer_id = reader.read("!L")[0]
5357 obj.out_port = util.unpack_port_no(reader)
5358 obj.flags = reader.read("!H")[0]
5359 obj.actions = loxi.generic_util.unpack_list(reader, ofp.action.action.unpack)
5360 return obj
5361
5362 def __eq__(self, other):
5363 if type(self) != type(other): return False
5364 if self.xid != other.xid: return False
5365 if self.match != other.match: return False
5366 if self.cookie != other.cookie: return False
5367 if self.idle_timeout != other.idle_timeout: return False
5368 if self.hard_timeout != other.hard_timeout: return False
5369 if self.priority != other.priority: return False
5370 if self.buffer_id != other.buffer_id: return False
5371 if self.out_port != other.out_port: return False
5372 if self.flags != other.flags: return False
5373 if self.actions != other.actions: return False
5374 return True
5375
5376 def pretty_print(self, q):
5377 q.text("flow_modify_strict {")
5378 with q.group():
5379 with q.indent(2):
5380 q.breakable()
5381 q.text("xid = ");
5382 if self.xid != None:
5383 q.text("%#x" % self.xid)
5384 else:
5385 q.text('None')
5386 q.text(","); q.breakable()
5387 q.text("match = ");
5388 q.pp(self.match)
5389 q.text(","); q.breakable()
5390 q.text("cookie = ");
5391 q.text("%#x" % self.cookie)
5392 q.text(","); q.breakable()
5393 q.text("idle_timeout = ");
5394 q.text("%#x" % self.idle_timeout)
5395 q.text(","); q.breakable()
5396 q.text("hard_timeout = ");
5397 q.text("%#x" % self.hard_timeout)
5398 q.text(","); q.breakable()
5399 q.text("priority = ");
5400 q.text("%#x" % self.priority)
5401 q.text(","); q.breakable()
5402 q.text("buffer_id = ");
5403 q.text("%#x" % self.buffer_id)
5404 q.text(","); q.breakable()
5405 q.text("out_port = ");
5406 q.text(util.pretty_port(self.out_port))
5407 q.text(","); q.breakable()
5408 q.text("flags = ");
5409 q.text("%#x" % self.flags)
5410 q.text(","); q.breakable()
5411 q.text("actions = ");
5412 q.pp(self.actions)
5413 q.breakable()
5414 q.text('}')
5415
5416flow_mod.subtypes[2] = flow_modify_strict
5417
5418class flow_removed(message):
5419 version = 1
5420 type = 11
5421
5422 def __init__(self, xid=None, match=None, cookie=None, priority=None, reason=None, duration_sec=None, duration_nsec=None, idle_timeout=None, packet_count=None, byte_count=None):
5423 if xid != None:
5424 self.xid = xid
5425 else:
5426 self.xid = None
5427 if match != None:
5428 self.match = match
5429 else:
5430 self.match = ofp.match()
5431 if cookie != None:
5432 self.cookie = cookie
5433 else:
5434 self.cookie = 0
5435 if priority != None:
5436 self.priority = priority
5437 else:
5438 self.priority = 0
5439 if reason != None:
5440 self.reason = reason
5441 else:
5442 self.reason = 0
5443 if duration_sec != None:
5444 self.duration_sec = duration_sec
5445 else:
5446 self.duration_sec = 0
5447 if duration_nsec != None:
5448 self.duration_nsec = duration_nsec
5449 else:
5450 self.duration_nsec = 0
5451 if idle_timeout != None:
5452 self.idle_timeout = idle_timeout
5453 else:
5454 self.idle_timeout = 0
5455 if packet_count != None:
5456 self.packet_count = packet_count
5457 else:
5458 self.packet_count = 0
5459 if byte_count != None:
5460 self.byte_count = byte_count
5461 else:
5462 self.byte_count = 0
5463 return
5464
5465 def pack(self):
5466 packed = []
5467 packed.append(struct.pack("!B", self.version))
5468 packed.append(struct.pack("!B", self.type))
5469 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5470 packed.append(struct.pack("!L", self.xid))
5471 packed.append(self.match.pack())
5472 packed.append(struct.pack("!Q", self.cookie))
5473 packed.append(struct.pack("!H", self.priority))
5474 packed.append(struct.pack("!B", self.reason))
5475 packed.append('\x00' * 1)
5476 packed.append(struct.pack("!L", self.duration_sec))
5477 packed.append(struct.pack("!L", self.duration_nsec))
5478 packed.append(struct.pack("!H", self.idle_timeout))
5479 packed.append('\x00' * 2)
5480 packed.append(struct.pack("!Q", self.packet_count))
5481 packed.append(struct.pack("!Q", self.byte_count))
5482 length = sum([len(x) for x in packed])
5483 packed[2] = struct.pack("!H", length)
5484 return ''.join(packed)
5485
5486 @staticmethod
5487 def unpack(reader):
5488 obj = flow_removed()
5489 _version = reader.read("!B")[0]
5490 assert(_version == 1)
5491 _type = reader.read("!B")[0]
5492 assert(_type == 11)
5493 _length = reader.read("!H")[0]
5494 orig_reader = reader
5495 reader = orig_reader.slice(_length, 4)
5496 obj.xid = reader.read("!L")[0]
5497 obj.match = ofp.match.unpack(reader)
5498 obj.cookie = reader.read("!Q")[0]
5499 obj.priority = reader.read("!H")[0]
5500 obj.reason = reader.read("!B")[0]
5501 reader.skip(1)
5502 obj.duration_sec = reader.read("!L")[0]
5503 obj.duration_nsec = reader.read("!L")[0]
5504 obj.idle_timeout = reader.read("!H")[0]
5505 reader.skip(2)
5506 obj.packet_count = reader.read("!Q")[0]
5507 obj.byte_count = reader.read("!Q")[0]
5508 return obj
5509
5510 def __eq__(self, other):
5511 if type(self) != type(other): return False
5512 if self.xid != other.xid: return False
5513 if self.match != other.match: return False
5514 if self.cookie != other.cookie: return False
5515 if self.priority != other.priority: return False
5516 if self.reason != other.reason: return False
5517 if self.duration_sec != other.duration_sec: return False
5518 if self.duration_nsec != other.duration_nsec: return False
5519 if self.idle_timeout != other.idle_timeout: return False
5520 if self.packet_count != other.packet_count: return False
5521 if self.byte_count != other.byte_count: return False
5522 return True
5523
5524 def pretty_print(self, q):
5525 q.text("flow_removed {")
5526 with q.group():
5527 with q.indent(2):
5528 q.breakable()
5529 q.text("xid = ");
5530 if self.xid != None:
5531 q.text("%#x" % self.xid)
5532 else:
5533 q.text('None')
5534 q.text(","); q.breakable()
5535 q.text("match = ");
5536 q.pp(self.match)
5537 q.text(","); q.breakable()
5538 q.text("cookie = ");
5539 q.text("%#x" % self.cookie)
5540 q.text(","); q.breakable()
5541 q.text("priority = ");
5542 q.text("%#x" % self.priority)
5543 q.text(","); q.breakable()
5544 q.text("reason = ");
5545 q.text("%#x" % self.reason)
5546 q.text(","); q.breakable()
5547 q.text("duration_sec = ");
5548 q.text("%#x" % self.duration_sec)
5549 q.text(","); q.breakable()
5550 q.text("duration_nsec = ");
5551 q.text("%#x" % self.duration_nsec)
5552 q.text(","); q.breakable()
5553 q.text("idle_timeout = ");
5554 q.text("%#x" % self.idle_timeout)
5555 q.text(","); q.breakable()
5556 q.text("packet_count = ");
5557 q.text("%#x" % self.packet_count)
5558 q.text(","); q.breakable()
5559 q.text("byte_count = ");
5560 q.text("%#x" % self.byte_count)
5561 q.breakable()
5562 q.text('}')
5563
5564message.subtypes[11] = flow_removed
5565
5566class flow_stats_reply(stats_reply):
5567 version = 1
5568 type = 17
5569 stats_type = 1
5570
5571 def __init__(self, xid=None, flags=None, entries=None):
5572 if xid != None:
5573 self.xid = xid
5574 else:
5575 self.xid = None
5576 if flags != None:
5577 self.flags = flags
5578 else:
5579 self.flags = 0
5580 if entries != None:
5581 self.entries = entries
5582 else:
5583 self.entries = []
5584 return
5585
5586 def pack(self):
5587 packed = []
5588 packed.append(struct.pack("!B", self.version))
5589 packed.append(struct.pack("!B", self.type))
5590 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5591 packed.append(struct.pack("!L", self.xid))
5592 packed.append(struct.pack("!H", self.stats_type))
5593 packed.append(struct.pack("!H", self.flags))
5594 packed.append(loxi.generic_util.pack_list(self.entries))
5595 length = sum([len(x) for x in packed])
5596 packed[2] = struct.pack("!H", length)
5597 return ''.join(packed)
5598
5599 @staticmethod
5600 def unpack(reader):
5601 obj = flow_stats_reply()
5602 _version = reader.read("!B")[0]
5603 assert(_version == 1)
5604 _type = reader.read("!B")[0]
5605 assert(_type == 17)
5606 _length = reader.read("!H")[0]
5607 orig_reader = reader
5608 reader = orig_reader.slice(_length, 4)
5609 obj.xid = reader.read("!L")[0]
5610 _stats_type = reader.read("!H")[0]
5611 assert(_stats_type == 1)
5612 obj.flags = reader.read("!H")[0]
5613 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.flow_stats_entry.unpack)
5614 return obj
5615
5616 def __eq__(self, other):
5617 if type(self) != type(other): return False
5618 if self.xid != other.xid: return False
5619 if self.flags != other.flags: return False
5620 if self.entries != other.entries: return False
5621 return True
5622
5623 def pretty_print(self, q):
5624 q.text("flow_stats_reply {")
5625 with q.group():
5626 with q.indent(2):
5627 q.breakable()
5628 q.text("xid = ");
5629 if self.xid != None:
5630 q.text("%#x" % self.xid)
5631 else:
5632 q.text('None')
5633 q.text(","); q.breakable()
5634 q.text("flags = ");
5635 q.text("%#x" % self.flags)
5636 q.text(","); q.breakable()
5637 q.text("entries = ");
5638 q.pp(self.entries)
5639 q.breakable()
5640 q.text('}')
5641
5642stats_reply.subtypes[1] = flow_stats_reply
5643
5644class flow_stats_request(stats_request):
5645 version = 1
5646 type = 16
5647 stats_type = 1
5648
5649 def __init__(self, xid=None, flags=None, match=None, table_id=None, out_port=None):
5650 if xid != None:
5651 self.xid = xid
5652 else:
5653 self.xid = None
5654 if flags != None:
5655 self.flags = flags
5656 else:
5657 self.flags = 0
5658 if match != None:
5659 self.match = match
5660 else:
5661 self.match = ofp.match()
5662 if table_id != None:
5663 self.table_id = table_id
5664 else:
5665 self.table_id = 0
5666 if out_port != None:
5667 self.out_port = out_port
5668 else:
5669 self.out_port = 0
5670 return
5671
5672 def pack(self):
5673 packed = []
5674 packed.append(struct.pack("!B", self.version))
5675 packed.append(struct.pack("!B", self.type))
5676 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5677 packed.append(struct.pack("!L", self.xid))
5678 packed.append(struct.pack("!H", self.stats_type))
5679 packed.append(struct.pack("!H", self.flags))
5680 packed.append(self.match.pack())
5681 packed.append(struct.pack("!B", self.table_id))
5682 packed.append('\x00' * 1)
5683 packed.append(util.pack_port_no(self.out_port))
5684 length = sum([len(x) for x in packed])
5685 packed[2] = struct.pack("!H", length)
5686 return ''.join(packed)
5687
5688 @staticmethod
5689 def unpack(reader):
5690 obj = flow_stats_request()
5691 _version = reader.read("!B")[0]
5692 assert(_version == 1)
5693 _type = reader.read("!B")[0]
5694 assert(_type == 16)
5695 _length = reader.read("!H")[0]
5696 orig_reader = reader
5697 reader = orig_reader.slice(_length, 4)
5698 obj.xid = reader.read("!L")[0]
5699 _stats_type = reader.read("!H")[0]
5700 assert(_stats_type == 1)
5701 obj.flags = reader.read("!H")[0]
5702 obj.match = ofp.match.unpack(reader)
5703 obj.table_id = reader.read("!B")[0]
5704 reader.skip(1)
5705 obj.out_port = util.unpack_port_no(reader)
5706 return obj
5707
5708 def __eq__(self, other):
5709 if type(self) != type(other): return False
5710 if self.xid != other.xid: return False
5711 if self.flags != other.flags: return False
5712 if self.match != other.match: return False
5713 if self.table_id != other.table_id: return False
5714 if self.out_port != other.out_port: return False
5715 return True
5716
5717 def pretty_print(self, q):
5718 q.text("flow_stats_request {")
5719 with q.group():
5720 with q.indent(2):
5721 q.breakable()
5722 q.text("xid = ");
5723 if self.xid != None:
5724 q.text("%#x" % self.xid)
5725 else:
5726 q.text('None')
5727 q.text(","); q.breakable()
5728 q.text("flags = ");
5729 q.text("%#x" % self.flags)
5730 q.text(","); q.breakable()
5731 q.text("match = ");
5732 q.pp(self.match)
5733 q.text(","); q.breakable()
5734 q.text("table_id = ");
5735 q.text("%#x" % self.table_id)
5736 q.text(","); q.breakable()
5737 q.text("out_port = ");
5738 q.text(util.pretty_port(self.out_port))
5739 q.breakable()
5740 q.text('}')
5741
5742stats_request.subtypes[1] = flow_stats_request
5743
5744class get_config_reply(message):
5745 version = 1
5746 type = 8
5747
5748 def __init__(self, xid=None, flags=None, miss_send_len=None):
5749 if xid != None:
5750 self.xid = xid
5751 else:
5752 self.xid = None
5753 if flags != None:
5754 self.flags = flags
5755 else:
5756 self.flags = 0
5757 if miss_send_len != None:
5758 self.miss_send_len = miss_send_len
5759 else:
5760 self.miss_send_len = 0
5761 return
5762
5763 def pack(self):
5764 packed = []
5765 packed.append(struct.pack("!B", self.version))
5766 packed.append(struct.pack("!B", self.type))
5767 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5768 packed.append(struct.pack("!L", self.xid))
5769 packed.append(struct.pack("!H", self.flags))
5770 packed.append(struct.pack("!H", self.miss_send_len))
5771 length = sum([len(x) for x in packed])
5772 packed[2] = struct.pack("!H", length)
5773 return ''.join(packed)
5774
5775 @staticmethod
5776 def unpack(reader):
5777 obj = get_config_reply()
5778 _version = reader.read("!B")[0]
5779 assert(_version == 1)
5780 _type = reader.read("!B")[0]
5781 assert(_type == 8)
5782 _length = reader.read("!H")[0]
5783 orig_reader = reader
5784 reader = orig_reader.slice(_length, 4)
5785 obj.xid = reader.read("!L")[0]
5786 obj.flags = reader.read("!H")[0]
5787 obj.miss_send_len = reader.read("!H")[0]
5788 return obj
5789
5790 def __eq__(self, other):
5791 if type(self) != type(other): return False
5792 if self.xid != other.xid: return False
5793 if self.flags != other.flags: return False
5794 if self.miss_send_len != other.miss_send_len: return False
5795 return True
5796
5797 def pretty_print(self, q):
5798 q.text("get_config_reply {")
5799 with q.group():
5800 with q.indent(2):
5801 q.breakable()
5802 q.text("xid = ");
5803 if self.xid != None:
5804 q.text("%#x" % self.xid)
5805 else:
5806 q.text('None')
5807 q.text(","); q.breakable()
5808 q.text("flags = ");
5809 q.text("%#x" % self.flags)
5810 q.text(","); q.breakable()
5811 q.text("miss_send_len = ");
5812 q.text("%#x" % self.miss_send_len)
5813 q.breakable()
5814 q.text('}')
5815
5816message.subtypes[8] = get_config_reply
5817
5818class get_config_request(message):
5819 version = 1
5820 type = 7
5821
5822 def __init__(self, xid=None):
5823 if xid != None:
5824 self.xid = xid
5825 else:
5826 self.xid = None
5827 return
5828
5829 def pack(self):
5830 packed = []
5831 packed.append(struct.pack("!B", self.version))
5832 packed.append(struct.pack("!B", self.type))
5833 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5834 packed.append(struct.pack("!L", self.xid))
5835 length = sum([len(x) for x in packed])
5836 packed[2] = struct.pack("!H", length)
5837 return ''.join(packed)
5838
5839 @staticmethod
5840 def unpack(reader):
5841 obj = get_config_request()
5842 _version = reader.read("!B")[0]
5843 assert(_version == 1)
5844 _type = reader.read("!B")[0]
5845 assert(_type == 7)
5846 _length = reader.read("!H")[0]
5847 orig_reader = reader
5848 reader = orig_reader.slice(_length, 4)
5849 obj.xid = reader.read("!L")[0]
5850 return obj
5851
5852 def __eq__(self, other):
5853 if type(self) != type(other): return False
5854 if self.xid != other.xid: return False
5855 return True
5856
5857 def pretty_print(self, q):
5858 q.text("get_config_request {")
5859 with q.group():
5860 with q.indent(2):
5861 q.breakable()
5862 q.text("xid = ");
5863 if self.xid != None:
5864 q.text("%#x" % self.xid)
5865 else:
5866 q.text('None')
5867 q.breakable()
5868 q.text('}')
5869
5870message.subtypes[7] = get_config_request
5871
5872class hello(message):
5873 version = 1
5874 type = 0
5875
5876 def __init__(self, xid=None):
5877 if xid != None:
5878 self.xid = xid
5879 else:
5880 self.xid = None
5881 return
5882
5883 def pack(self):
5884 packed = []
5885 packed.append(struct.pack("!B", self.version))
5886 packed.append(struct.pack("!B", self.type))
5887 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5888 packed.append(struct.pack("!L", self.xid))
5889 length = sum([len(x) for x in packed])
5890 packed[2] = struct.pack("!H", length)
5891 return ''.join(packed)
5892
5893 @staticmethod
5894 def unpack(reader):
5895 obj = hello()
5896 _version = reader.read("!B")[0]
5897 assert(_version == 1)
5898 _type = reader.read("!B")[0]
5899 assert(_type == 0)
5900 _length = reader.read("!H")[0]
5901 orig_reader = reader
5902 reader = orig_reader.slice(_length, 4)
5903 obj.xid = reader.read("!L")[0]
5904 return obj
5905
5906 def __eq__(self, other):
5907 if type(self) != type(other): return False
5908 if self.xid != other.xid: return False
5909 return True
5910
5911 def pretty_print(self, q):
5912 q.text("hello {")
5913 with q.group():
5914 with q.indent(2):
5915 q.breakable()
5916 q.text("xid = ");
5917 if self.xid != None:
5918 q.text("%#x" % self.xid)
5919 else:
5920 q.text('None')
5921 q.breakable()
5922 q.text('}')
5923
5924message.subtypes[0] = hello
5925
5926class hello_failed_error_msg(error_msg):
5927 version = 1
5928 type = 1
5929 err_type = 0
5930
5931 def __init__(self, xid=None, code=None, data=None):
5932 if xid != None:
5933 self.xid = xid
5934 else:
5935 self.xid = None
5936 if code != None:
5937 self.code = code
5938 else:
5939 self.code = 0
5940 if data != None:
5941 self.data = data
5942 else:
5943 self.data = ''
5944 return
5945
5946 def pack(self):
5947 packed = []
5948 packed.append(struct.pack("!B", self.version))
5949 packed.append(struct.pack("!B", self.type))
5950 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5951 packed.append(struct.pack("!L", self.xid))
5952 packed.append(struct.pack("!H", self.err_type))
5953 packed.append(struct.pack("!H", self.code))
5954 packed.append(self.data)
5955 length = sum([len(x) for x in packed])
5956 packed[2] = struct.pack("!H", length)
5957 return ''.join(packed)
5958
5959 @staticmethod
5960 def unpack(reader):
5961 obj = hello_failed_error_msg()
5962 _version = reader.read("!B")[0]
5963 assert(_version == 1)
5964 _type = reader.read("!B")[0]
5965 assert(_type == 1)
5966 _length = reader.read("!H")[0]
5967 orig_reader = reader
5968 reader = orig_reader.slice(_length, 4)
5969 obj.xid = reader.read("!L")[0]
5970 _err_type = reader.read("!H")[0]
5971 assert(_err_type == 0)
5972 obj.code = reader.read("!H")[0]
5973 obj.data = str(reader.read_all())
5974 return obj
5975
5976 def __eq__(self, other):
5977 if type(self) != type(other): return False
5978 if self.xid != other.xid: return False
5979 if self.code != other.code: return False
5980 if self.data != other.data: return False
5981 return True
5982
5983 def pretty_print(self, q):
5984 q.text("hello_failed_error_msg {")
5985 with q.group():
5986 with q.indent(2):
5987 q.breakable()
5988 q.text("xid = ");
5989 if self.xid != None:
5990 q.text("%#x" % self.xid)
5991 else:
5992 q.text('None')
5993 q.text(","); q.breakable()
5994 q.text("code = ");
5995 q.text("%#x" % self.code)
5996 q.text(","); q.breakable()
5997 q.text("data = ");
5998 q.pp(self.data)
5999 q.breakable()
6000 q.text('}')
6001
6002error_msg.subtypes[0] = hello_failed_error_msg
6003
6004class nicira_header(experimenter):
6005 subtypes = {}
6006
6007 version = 1
6008 type = 4
6009 experimenter = 8992
6010
6011 def __init__(self, xid=None, subtype=None):
6012 if xid != None:
6013 self.xid = xid
6014 else:
6015 self.xid = None
6016 if subtype != None:
6017 self.subtype = subtype
6018 else:
6019 self.subtype = 0
6020 return
6021
6022 def pack(self):
6023 packed = []
6024 packed.append(struct.pack("!B", self.version))
6025 packed.append(struct.pack("!B", self.type))
6026 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6027 packed.append(struct.pack("!L", self.xid))
6028 packed.append(struct.pack("!L", self.experimenter))
6029 packed.append(struct.pack("!L", self.subtype))
6030 length = sum([len(x) for x in packed])
6031 packed[2] = struct.pack("!H", length)
6032 return ''.join(packed)
6033
6034 @staticmethod
6035 def unpack(reader):
6036 subtype, = reader.peek('!L', 12)
6037 subclass = nicira_header.subtypes.get(subtype)
6038 if subclass:
6039 return subclass.unpack(reader)
6040
6041 obj = nicira_header()
6042 _version = reader.read("!B")[0]
6043 assert(_version == 1)
6044 _type = reader.read("!B")[0]
6045 assert(_type == 4)
6046 _length = reader.read("!H")[0]
6047 orig_reader = reader
6048 reader = orig_reader.slice(_length, 4)
6049 obj.xid = reader.read("!L")[0]
6050 _experimenter = reader.read("!L")[0]
6051 assert(_experimenter == 8992)
6052 obj.subtype = reader.read("!L")[0]
6053 return obj
6054
6055 def __eq__(self, other):
6056 if type(self) != type(other): return False
6057 if self.xid != other.xid: return False
6058 if self.subtype != other.subtype: return False
6059 return True
6060
6061 def pretty_print(self, q):
6062 q.text("nicira_header {")
6063 with q.group():
6064 with q.indent(2):
6065 q.breakable()
6066 q.text("xid = ");
6067 if self.xid != None:
6068 q.text("%#x" % self.xid)
6069 else:
6070 q.text('None')
6071 q.breakable()
6072 q.text('}')
6073
6074experimenter.subtypes[8992] = nicira_header
6075
6076class nicira_controller_role_reply(nicira_header):
6077 version = 1
6078 type = 4
6079 experimenter = 8992
6080 subtype = 11
6081
6082 def __init__(self, xid=None, role=None):
6083 if xid != None:
6084 self.xid = xid
6085 else:
6086 self.xid = None
6087 if role != None:
6088 self.role = role
6089 else:
6090 self.role = 0
6091 return
6092
6093 def pack(self):
6094 packed = []
6095 packed.append(struct.pack("!B", self.version))
6096 packed.append(struct.pack("!B", self.type))
6097 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6098 packed.append(struct.pack("!L", self.xid))
6099 packed.append(struct.pack("!L", self.experimenter))
6100 packed.append(struct.pack("!L", self.subtype))
6101 packed.append(struct.pack("!L", self.role))
6102 length = sum([len(x) for x in packed])
6103 packed[2] = struct.pack("!H", length)
6104 return ''.join(packed)
6105
6106 @staticmethod
6107 def unpack(reader):
6108 obj = nicira_controller_role_reply()
6109 _version = reader.read("!B")[0]
6110 assert(_version == 1)
6111 _type = reader.read("!B")[0]
6112 assert(_type == 4)
6113 _length = reader.read("!H")[0]
6114 orig_reader = reader
6115 reader = orig_reader.slice(_length, 4)
6116 obj.xid = reader.read("!L")[0]
6117 _experimenter = reader.read("!L")[0]
6118 assert(_experimenter == 8992)
6119 _subtype = reader.read("!L")[0]
6120 assert(_subtype == 11)
6121 obj.role = reader.read("!L")[0]
6122 return obj
6123
6124 def __eq__(self, other):
6125 if type(self) != type(other): return False
6126 if self.xid != other.xid: return False
6127 if self.role != other.role: return False
6128 return True
6129
6130 def pretty_print(self, q):
6131 q.text("nicira_controller_role_reply {")
6132 with q.group():
6133 with q.indent(2):
6134 q.breakable()
6135 q.text("xid = ");
6136 if self.xid != None:
6137 q.text("%#x" % self.xid)
6138 else:
6139 q.text('None')
6140 q.text(","); q.breakable()
6141 q.text("role = ");
6142 q.text("%#x" % self.role)
6143 q.breakable()
6144 q.text('}')
6145
6146nicira_header.subtypes[11] = nicira_controller_role_reply
6147
6148class nicira_controller_role_request(nicira_header):
6149 version = 1
6150 type = 4
6151 experimenter = 8992
6152 subtype = 10
6153
6154 def __init__(self, xid=None, role=None):
6155 if xid != None:
6156 self.xid = xid
6157 else:
6158 self.xid = None
6159 if role != None:
6160 self.role = role
6161 else:
6162 self.role = 0
6163 return
6164
6165 def pack(self):
6166 packed = []
6167 packed.append(struct.pack("!B", self.version))
6168 packed.append(struct.pack("!B", self.type))
6169 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6170 packed.append(struct.pack("!L", self.xid))
6171 packed.append(struct.pack("!L", self.experimenter))
6172 packed.append(struct.pack("!L", self.subtype))
6173 packed.append(struct.pack("!L", self.role))
6174 length = sum([len(x) for x in packed])
6175 packed[2] = struct.pack("!H", length)
6176 return ''.join(packed)
6177
6178 @staticmethod
6179 def unpack(reader):
6180 obj = nicira_controller_role_request()
6181 _version = reader.read("!B")[0]
6182 assert(_version == 1)
6183 _type = reader.read("!B")[0]
6184 assert(_type == 4)
6185 _length = reader.read("!H")[0]
6186 orig_reader = reader
6187 reader = orig_reader.slice(_length, 4)
6188 obj.xid = reader.read("!L")[0]
6189 _experimenter = reader.read("!L")[0]
6190 assert(_experimenter == 8992)
6191 _subtype = reader.read("!L")[0]
6192 assert(_subtype == 10)
6193 obj.role = reader.read("!L")[0]
6194 return obj
6195
6196 def __eq__(self, other):
6197 if type(self) != type(other): return False
6198 if self.xid != other.xid: return False
6199 if self.role != other.role: return False
6200 return True
6201
6202 def pretty_print(self, q):
6203 q.text("nicira_controller_role_request {")
6204 with q.group():
6205 with q.indent(2):
6206 q.breakable()
6207 q.text("xid = ");
6208 if self.xid != None:
6209 q.text("%#x" % self.xid)
6210 else:
6211 q.text('None')
6212 q.text(","); q.breakable()
6213 q.text("role = ");
6214 q.text("%#x" % self.role)
6215 q.breakable()
6216 q.text('}')
6217
6218nicira_header.subtypes[10] = nicira_controller_role_request
6219
6220class packet_in(message):
6221 version = 1
6222 type = 10
6223
6224 def __init__(self, xid=None, buffer_id=None, total_len=None, in_port=None, reason=None, data=None):
6225 if xid != None:
6226 self.xid = xid
6227 else:
6228 self.xid = None
6229 if buffer_id != None:
6230 self.buffer_id = buffer_id
6231 else:
6232 self.buffer_id = 0
6233 if total_len != None:
6234 self.total_len = total_len
6235 else:
6236 self.total_len = 0
6237 if in_port != None:
6238 self.in_port = in_port
6239 else:
6240 self.in_port = 0
6241 if reason != None:
6242 self.reason = reason
6243 else:
6244 self.reason = 0
6245 if data != None:
6246 self.data = data
6247 else:
6248 self.data = ''
6249 return
6250
6251 def pack(self):
6252 packed = []
6253 packed.append(struct.pack("!B", self.version))
6254 packed.append(struct.pack("!B", self.type))
6255 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6256 packed.append(struct.pack("!L", self.xid))
6257 packed.append(struct.pack("!L", self.buffer_id))
6258 packed.append(struct.pack("!H", self.total_len))
6259 packed.append(util.pack_port_no(self.in_port))
6260 packed.append(struct.pack("!B", self.reason))
6261 packed.append('\x00' * 1)
6262 packed.append(self.data)
6263 length = sum([len(x) for x in packed])
6264 packed[2] = struct.pack("!H", length)
6265 return ''.join(packed)
6266
6267 @staticmethod
6268 def unpack(reader):
6269 obj = packet_in()
6270 _version = reader.read("!B")[0]
6271 assert(_version == 1)
6272 _type = reader.read("!B")[0]
6273 assert(_type == 10)
6274 _length = reader.read("!H")[0]
6275 orig_reader = reader
6276 reader = orig_reader.slice(_length, 4)
6277 obj.xid = reader.read("!L")[0]
6278 obj.buffer_id = reader.read("!L")[0]
6279 obj.total_len = reader.read("!H")[0]
6280 obj.in_port = util.unpack_port_no(reader)
6281 obj.reason = reader.read("!B")[0]
6282 reader.skip(1)
6283 obj.data = str(reader.read_all())
6284 return obj
6285
6286 def __eq__(self, other):
6287 if type(self) != type(other): return False
6288 if self.xid != other.xid: return False
6289 if self.buffer_id != other.buffer_id: return False
6290 if self.total_len != other.total_len: return False
6291 if self.in_port != other.in_port: return False
6292 if self.reason != other.reason: return False
6293 if self.data != other.data: return False
6294 return True
6295
6296 def pretty_print(self, q):
6297 q.text("packet_in {")
6298 with q.group():
6299 with q.indent(2):
6300 q.breakable()
6301 q.text("xid = ");
6302 if self.xid != None:
6303 q.text("%#x" % self.xid)
6304 else:
6305 q.text('None')
6306 q.text(","); q.breakable()
6307 q.text("buffer_id = ");
6308 q.text("%#x" % self.buffer_id)
6309 q.text(","); q.breakable()
6310 q.text("total_len = ");
6311 q.text("%#x" % self.total_len)
6312 q.text(","); q.breakable()
6313 q.text("in_port = ");
6314 q.text(util.pretty_port(self.in_port))
6315 q.text(","); q.breakable()
6316 q.text("reason = ");
6317 q.text("%#x" % self.reason)
6318 q.text(","); q.breakable()
6319 q.text("data = ");
6320 q.pp(self.data)
6321 q.breakable()
6322 q.text('}')
6323
6324message.subtypes[10] = packet_in
6325
6326class packet_out(message):
6327 version = 1
6328 type = 13
6329
6330 def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None):
6331 if xid != None:
6332 self.xid = xid
6333 else:
6334 self.xid = None
6335 if buffer_id != None:
6336 self.buffer_id = buffer_id
6337 else:
6338 self.buffer_id = 0
6339 if in_port != None:
6340 self.in_port = in_port
6341 else:
6342 self.in_port = 0
6343 if actions != None:
6344 self.actions = actions
6345 else:
6346 self.actions = []
6347 if data != None:
6348 self.data = data
6349 else:
6350 self.data = ''
6351 return
6352
6353 def pack(self):
6354 packed = []
6355 packed.append(struct.pack("!B", self.version))
6356 packed.append(struct.pack("!B", self.type))
6357 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6358 packed.append(struct.pack("!L", self.xid))
6359 packed.append(struct.pack("!L", self.buffer_id))
6360 packed.append(util.pack_port_no(self.in_port))
6361 packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6
6362 packed.append(loxi.generic_util.pack_list(self.actions))
6363 packed[6] = struct.pack("!H", len(packed[-1]))
6364 packed.append(self.data)
6365 length = sum([len(x) for x in packed])
6366 packed[2] = struct.pack("!H", length)
6367 return ''.join(packed)
6368
6369 @staticmethod
6370 def unpack(reader):
6371 obj = packet_out()
6372 _version = reader.read("!B")[0]
6373 assert(_version == 1)
6374 _type = reader.read("!B")[0]
6375 assert(_type == 13)
6376 _length = reader.read("!H")[0]
6377 orig_reader = reader
6378 reader = orig_reader.slice(_length, 4)
6379 obj.xid = reader.read("!L")[0]
6380 obj.buffer_id = reader.read("!L")[0]
6381 obj.in_port = util.unpack_port_no(reader)
6382 _actions_len = reader.read("!H")[0]
6383 obj.actions = loxi.generic_util.unpack_list(reader.slice(_actions_len), ofp.action.action.unpack)
6384 obj.data = str(reader.read_all())
6385 return obj
6386
6387 def __eq__(self, other):
6388 if type(self) != type(other): return False
6389 if self.xid != other.xid: return False
6390 if self.buffer_id != other.buffer_id: return False
6391 if self.in_port != other.in_port: return False
6392 if self.actions != other.actions: return False
6393 if self.data != other.data: return False
6394 return True
6395
6396 def pretty_print(self, q):
6397 q.text("packet_out {")
6398 with q.group():
6399 with q.indent(2):
6400 q.breakable()
6401 q.text("xid = ");
6402 if self.xid != None:
6403 q.text("%#x" % self.xid)
6404 else:
6405 q.text('None')
6406 q.text(","); q.breakable()
6407 q.text("buffer_id = ");
6408 q.text("%#x" % self.buffer_id)
6409 q.text(","); q.breakable()
6410 q.text("in_port = ");
6411 q.text(util.pretty_port(self.in_port))
6412 q.text(","); q.breakable()
6413 q.text("actions = ");
6414 q.pp(self.actions)
6415 q.text(","); q.breakable()
6416 q.text("data = ");
6417 q.pp(self.data)
6418 q.breakable()
6419 q.text('}')
6420
6421message.subtypes[13] = packet_out
6422
6423class port_mod(message):
6424 version = 1
6425 type = 15
6426
6427 def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None):
6428 if xid != None:
6429 self.xid = xid
6430 else:
6431 self.xid = None
6432 if port_no != None:
6433 self.port_no = port_no
6434 else:
6435 self.port_no = 0
6436 if hw_addr != None:
6437 self.hw_addr = hw_addr
6438 else:
6439 self.hw_addr = [0,0,0,0,0,0]
6440 if config != None:
6441 self.config = config
6442 else:
6443 self.config = 0
6444 if mask != None:
6445 self.mask = mask
6446 else:
6447 self.mask = 0
6448 if advertise != None:
6449 self.advertise = advertise
6450 else:
6451 self.advertise = 0
6452 return
6453
6454 def pack(self):
6455 packed = []
6456 packed.append(struct.pack("!B", self.version))
6457 packed.append(struct.pack("!B", self.type))
6458 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6459 packed.append(struct.pack("!L", self.xid))
6460 packed.append(util.pack_port_no(self.port_no))
6461 packed.append(struct.pack("!6B", *self.hw_addr))
6462 packed.append(struct.pack("!L", self.config))
6463 packed.append(struct.pack("!L", self.mask))
6464 packed.append(struct.pack("!L", self.advertise))
6465 packed.append('\x00' * 4)
6466 length = sum([len(x) for x in packed])
6467 packed[2] = struct.pack("!H", length)
6468 return ''.join(packed)
6469
6470 @staticmethod
6471 def unpack(reader):
6472 obj = port_mod()
6473 _version = reader.read("!B")[0]
6474 assert(_version == 1)
6475 _type = reader.read("!B")[0]
6476 assert(_type == 15)
6477 _length = reader.read("!H")[0]
6478 orig_reader = reader
6479 reader = orig_reader.slice(_length, 4)
6480 obj.xid = reader.read("!L")[0]
6481 obj.port_no = util.unpack_port_no(reader)
6482 obj.hw_addr = list(reader.read('!6B'))
6483 obj.config = reader.read("!L")[0]
6484 obj.mask = reader.read("!L")[0]
6485 obj.advertise = reader.read("!L")[0]
6486 reader.skip(4)
6487 return obj
6488
6489 def __eq__(self, other):
6490 if type(self) != type(other): return False
6491 if self.xid != other.xid: return False
6492 if self.port_no != other.port_no: return False
6493 if self.hw_addr != other.hw_addr: return False
6494 if self.config != other.config: return False
6495 if self.mask != other.mask: return False
6496 if self.advertise != other.advertise: return False
6497 return True
6498
6499 def pretty_print(self, q):
6500 q.text("port_mod {")
6501 with q.group():
6502 with q.indent(2):
6503 q.breakable()
6504 q.text("xid = ");
6505 if self.xid != None:
6506 q.text("%#x" % self.xid)
6507 else:
6508 q.text('None')
6509 q.text(","); q.breakable()
6510 q.text("port_no = ");
6511 q.text(util.pretty_port(self.port_no))
6512 q.text(","); q.breakable()
6513 q.text("hw_addr = ");
6514 q.text(util.pretty_mac(self.hw_addr))
6515 q.text(","); q.breakable()
6516 q.text("config = ");
6517 q.text("%#x" % self.config)
6518 q.text(","); q.breakable()
6519 q.text("mask = ");
6520 q.text("%#x" % self.mask)
6521 q.text(","); q.breakable()
6522 q.text("advertise = ");
6523 q.text("%#x" % self.advertise)
6524 q.breakable()
6525 q.text('}')
6526
6527message.subtypes[15] = port_mod
6528
6529class port_mod_failed_error_msg(error_msg):
6530 version = 1
6531 type = 1
6532 err_type = 4
6533
6534 def __init__(self, xid=None, code=None, data=None):
6535 if xid != None:
6536 self.xid = xid
6537 else:
6538 self.xid = None
6539 if code != None:
6540 self.code = code
6541 else:
6542 self.code = 0
6543 if data != None:
6544 self.data = data
6545 else:
6546 self.data = ''
6547 return
6548
6549 def pack(self):
6550 packed = []
6551 packed.append(struct.pack("!B", self.version))
6552 packed.append(struct.pack("!B", self.type))
6553 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6554 packed.append(struct.pack("!L", self.xid))
6555 packed.append(struct.pack("!H", self.err_type))
6556 packed.append(struct.pack("!H", self.code))
6557 packed.append(self.data)
6558 length = sum([len(x) for x in packed])
6559 packed[2] = struct.pack("!H", length)
6560 return ''.join(packed)
6561
6562 @staticmethod
6563 def unpack(reader):
6564 obj = port_mod_failed_error_msg()
6565 _version = reader.read("!B")[0]
6566 assert(_version == 1)
6567 _type = reader.read("!B")[0]
6568 assert(_type == 1)
6569 _length = reader.read("!H")[0]
6570 orig_reader = reader
6571 reader = orig_reader.slice(_length, 4)
6572 obj.xid = reader.read("!L")[0]
6573 _err_type = reader.read("!H")[0]
6574 assert(_err_type == 4)
6575 obj.code = reader.read("!H")[0]
6576 obj.data = str(reader.read_all())
6577 return obj
6578
6579 def __eq__(self, other):
6580 if type(self) != type(other): return False
6581 if self.xid != other.xid: return False
6582 if self.code != other.code: return False
6583 if self.data != other.data: return False
6584 return True
6585
6586 def pretty_print(self, q):
6587 q.text("port_mod_failed_error_msg {")
6588 with q.group():
6589 with q.indent(2):
6590 q.breakable()
6591 q.text("xid = ");
6592 if self.xid != None:
6593 q.text("%#x" % self.xid)
6594 else:
6595 q.text('None')
6596 q.text(","); q.breakable()
6597 q.text("code = ");
6598 q.text("%#x" % self.code)
6599 q.text(","); q.breakable()
6600 q.text("data = ");
6601 q.pp(self.data)
6602 q.breakable()
6603 q.text('}')
6604
6605error_msg.subtypes[4] = port_mod_failed_error_msg
6606
6607class port_stats_reply(stats_reply):
6608 version = 1
6609 type = 17
6610 stats_type = 4
6611
6612 def __init__(self, xid=None, flags=None, entries=None):
6613 if xid != None:
6614 self.xid = xid
6615 else:
6616 self.xid = None
6617 if flags != None:
6618 self.flags = flags
6619 else:
6620 self.flags = 0
6621 if entries != None:
6622 self.entries = entries
6623 else:
6624 self.entries = []
6625 return
6626
6627 def pack(self):
6628 packed = []
6629 packed.append(struct.pack("!B", self.version))
6630 packed.append(struct.pack("!B", self.type))
6631 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6632 packed.append(struct.pack("!L", self.xid))
6633 packed.append(struct.pack("!H", self.stats_type))
6634 packed.append(struct.pack("!H", self.flags))
6635 packed.append(loxi.generic_util.pack_list(self.entries))
6636 length = sum([len(x) for x in packed])
6637 packed[2] = struct.pack("!H", length)
6638 return ''.join(packed)
6639
6640 @staticmethod
6641 def unpack(reader):
6642 obj = port_stats_reply()
6643 _version = reader.read("!B")[0]
6644 assert(_version == 1)
6645 _type = reader.read("!B")[0]
6646 assert(_type == 17)
6647 _length = reader.read("!H")[0]
6648 orig_reader = reader
6649 reader = orig_reader.slice(_length, 4)
6650 obj.xid = reader.read("!L")[0]
6651 _stats_type = reader.read("!H")[0]
6652 assert(_stats_type == 4)
6653 obj.flags = reader.read("!H")[0]
6654 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.port_stats_entry.unpack)
6655 return obj
6656
6657 def __eq__(self, other):
6658 if type(self) != type(other): return False
6659 if self.xid != other.xid: return False
6660 if self.flags != other.flags: return False
6661 if self.entries != other.entries: return False
6662 return True
6663
6664 def pretty_print(self, q):
6665 q.text("port_stats_reply {")
6666 with q.group():
6667 with q.indent(2):
6668 q.breakable()
6669 q.text("xid = ");
6670 if self.xid != None:
6671 q.text("%#x" % self.xid)
6672 else:
6673 q.text('None')
6674 q.text(","); q.breakable()
6675 q.text("flags = ");
6676 q.text("%#x" % self.flags)
6677 q.text(","); q.breakable()
6678 q.text("entries = ");
6679 q.pp(self.entries)
6680 q.breakable()
6681 q.text('}')
6682
6683stats_reply.subtypes[4] = port_stats_reply
6684
6685class port_stats_request(stats_request):
6686 version = 1
6687 type = 16
6688 stats_type = 4
6689
6690 def __init__(self, xid=None, flags=None, port_no=None):
6691 if xid != None:
6692 self.xid = xid
6693 else:
6694 self.xid = None
6695 if flags != None:
6696 self.flags = flags
6697 else:
6698 self.flags = 0
6699 if port_no != None:
6700 self.port_no = port_no
6701 else:
6702 self.port_no = 0
6703 return
6704
6705 def pack(self):
6706 packed = []
6707 packed.append(struct.pack("!B", self.version))
6708 packed.append(struct.pack("!B", self.type))
6709 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6710 packed.append(struct.pack("!L", self.xid))
6711 packed.append(struct.pack("!H", self.stats_type))
6712 packed.append(struct.pack("!H", self.flags))
6713 packed.append(util.pack_port_no(self.port_no))
6714 packed.append('\x00' * 6)
6715 length = sum([len(x) for x in packed])
6716 packed[2] = struct.pack("!H", length)
6717 return ''.join(packed)
6718
6719 @staticmethod
6720 def unpack(reader):
6721 obj = port_stats_request()
6722 _version = reader.read("!B")[0]
6723 assert(_version == 1)
6724 _type = reader.read("!B")[0]
6725 assert(_type == 16)
6726 _length = reader.read("!H")[0]
6727 orig_reader = reader
6728 reader = orig_reader.slice(_length, 4)
6729 obj.xid = reader.read("!L")[0]
6730 _stats_type = reader.read("!H")[0]
6731 assert(_stats_type == 4)
6732 obj.flags = reader.read("!H")[0]
6733 obj.port_no = util.unpack_port_no(reader)
6734 reader.skip(6)
6735 return obj
6736
6737 def __eq__(self, other):
6738 if type(self) != type(other): return False
6739 if self.xid != other.xid: return False
6740 if self.flags != other.flags: return False
6741 if self.port_no != other.port_no: return False
6742 return True
6743
6744 def pretty_print(self, q):
6745 q.text("port_stats_request {")
6746 with q.group():
6747 with q.indent(2):
6748 q.breakable()
6749 q.text("xid = ");
6750 if self.xid != None:
6751 q.text("%#x" % self.xid)
6752 else:
6753 q.text('None')
6754 q.text(","); q.breakable()
6755 q.text("flags = ");
6756 q.text("%#x" % self.flags)
6757 q.text(","); q.breakable()
6758 q.text("port_no = ");
6759 q.text(util.pretty_port(self.port_no))
6760 q.breakable()
6761 q.text('}')
6762
6763stats_request.subtypes[4] = port_stats_request
6764
6765class port_status(message):
6766 version = 1
6767 type = 12
6768
6769 def __init__(self, xid=None, reason=None, desc=None):
6770 if xid != None:
6771 self.xid = xid
6772 else:
6773 self.xid = None
6774 if reason != None:
6775 self.reason = reason
6776 else:
6777 self.reason = 0
6778 if desc != None:
6779 self.desc = desc
6780 else:
6781 self.desc = ofp.port_desc()
6782 return
6783
6784 def pack(self):
6785 packed = []
6786 packed.append(struct.pack("!B", self.version))
6787 packed.append(struct.pack("!B", self.type))
6788 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6789 packed.append(struct.pack("!L", self.xid))
6790 packed.append(struct.pack("!B", self.reason))
6791 packed.append('\x00' * 7)
6792 packed.append(self.desc.pack())
6793 length = sum([len(x) for x in packed])
6794 packed[2] = struct.pack("!H", length)
6795 return ''.join(packed)
6796
6797 @staticmethod
6798 def unpack(reader):
6799 obj = port_status()
6800 _version = reader.read("!B")[0]
6801 assert(_version == 1)
6802 _type = reader.read("!B")[0]
6803 assert(_type == 12)
6804 _length = reader.read("!H")[0]
6805 orig_reader = reader
6806 reader = orig_reader.slice(_length, 4)
6807 obj.xid = reader.read("!L")[0]
6808 obj.reason = reader.read("!B")[0]
6809 reader.skip(7)
6810 obj.desc = ofp.port_desc.unpack(reader)
6811 return obj
6812
6813 def __eq__(self, other):
6814 if type(self) != type(other): return False
6815 if self.xid != other.xid: return False
6816 if self.reason != other.reason: return False
6817 if self.desc != other.desc: return False
6818 return True
6819
6820 def pretty_print(self, q):
6821 q.text("port_status {")
6822 with q.group():
6823 with q.indent(2):
6824 q.breakable()
6825 q.text("xid = ");
6826 if self.xid != None:
6827 q.text("%#x" % self.xid)
6828 else:
6829 q.text('None')
6830 q.text(","); q.breakable()
6831 q.text("reason = ");
6832 q.text("%#x" % self.reason)
6833 q.text(","); q.breakable()
6834 q.text("desc = ");
6835 q.pp(self.desc)
6836 q.breakable()
6837 q.text('}')
6838
6839message.subtypes[12] = port_status
6840
6841class queue_get_config_reply(message):
6842 version = 1
6843 type = 21
6844
6845 def __init__(self, xid=None, port=None, queues=None):
6846 if xid != None:
6847 self.xid = xid
6848 else:
6849 self.xid = None
6850 if port != None:
6851 self.port = port
6852 else:
6853 self.port = 0
6854 if queues != None:
6855 self.queues = queues
6856 else:
6857 self.queues = []
6858 return
6859
6860 def pack(self):
6861 packed = []
6862 packed.append(struct.pack("!B", self.version))
6863 packed.append(struct.pack("!B", self.type))
6864 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6865 packed.append(struct.pack("!L", self.xid))
6866 packed.append(util.pack_port_no(self.port))
6867 packed.append('\x00' * 6)
6868 packed.append(loxi.generic_util.pack_list(self.queues))
6869 length = sum([len(x) for x in packed])
6870 packed[2] = struct.pack("!H", length)
6871 return ''.join(packed)
6872
6873 @staticmethod
6874 def unpack(reader):
6875 obj = queue_get_config_reply()
6876 _version = reader.read("!B")[0]
6877 assert(_version == 1)
6878 _type = reader.read("!B")[0]
6879 assert(_type == 21)
6880 _length = reader.read("!H")[0]
6881 orig_reader = reader
6882 reader = orig_reader.slice(_length, 4)
6883 obj.xid = reader.read("!L")[0]
6884 obj.port = util.unpack_port_no(reader)
6885 reader.skip(6)
6886 obj.queues = loxi.generic_util.unpack_list(reader, ofp.common.packet_queue.unpack)
6887 return obj
6888
6889 def __eq__(self, other):
6890 if type(self) != type(other): return False
6891 if self.xid != other.xid: return False
6892 if self.port != other.port: return False
6893 if self.queues != other.queues: return False
6894 return True
6895
6896 def pretty_print(self, q):
6897 q.text("queue_get_config_reply {")
6898 with q.group():
6899 with q.indent(2):
6900 q.breakable()
6901 q.text("xid = ");
6902 if self.xid != None:
6903 q.text("%#x" % self.xid)
6904 else:
6905 q.text('None')
6906 q.text(","); q.breakable()
6907 q.text("port = ");
6908 q.text(util.pretty_port(self.port))
6909 q.text(","); q.breakable()
6910 q.text("queues = ");
6911 q.pp(self.queues)
6912 q.breakable()
6913 q.text('}')
6914
6915message.subtypes[21] = queue_get_config_reply
6916
6917class queue_get_config_request(message):
6918 version = 1
6919 type = 20
6920
6921 def __init__(self, xid=None, port=None):
6922 if xid != None:
6923 self.xid = xid
6924 else:
6925 self.xid = None
6926 if port != None:
6927 self.port = port
6928 else:
6929 self.port = 0
6930 return
6931
6932 def pack(self):
6933 packed = []
6934 packed.append(struct.pack("!B", self.version))
6935 packed.append(struct.pack("!B", self.type))
6936 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6937 packed.append(struct.pack("!L", self.xid))
6938 packed.append(util.pack_port_no(self.port))
6939 packed.append('\x00' * 2)
6940 length = sum([len(x) for x in packed])
6941 packed[2] = struct.pack("!H", length)
6942 return ''.join(packed)
6943
6944 @staticmethod
6945 def unpack(reader):
6946 obj = queue_get_config_request()
6947 _version = reader.read("!B")[0]
6948 assert(_version == 1)
6949 _type = reader.read("!B")[0]
6950 assert(_type == 20)
6951 _length = reader.read("!H")[0]
6952 orig_reader = reader
6953 reader = orig_reader.slice(_length, 4)
6954 obj.xid = reader.read("!L")[0]
6955 obj.port = util.unpack_port_no(reader)
6956 reader.skip(2)
6957 return obj
6958
6959 def __eq__(self, other):
6960 if type(self) != type(other): return False
6961 if self.xid != other.xid: return False
6962 if self.port != other.port: return False
6963 return True
6964
6965 def pretty_print(self, q):
6966 q.text("queue_get_config_request {")
6967 with q.group():
6968 with q.indent(2):
6969 q.breakable()
6970 q.text("xid = ");
6971 if self.xid != None:
6972 q.text("%#x" % self.xid)
6973 else:
6974 q.text('None')
6975 q.text(","); q.breakable()
6976 q.text("port = ");
6977 q.text(util.pretty_port(self.port))
6978 q.breakable()
6979 q.text('}')
6980
6981message.subtypes[20] = queue_get_config_request
6982
6983class queue_op_failed_error_msg(error_msg):
6984 version = 1
6985 type = 1
6986 err_type = 5
6987
6988 def __init__(self, xid=None, code=None, data=None):
6989 if xid != None:
6990 self.xid = xid
6991 else:
6992 self.xid = None
6993 if code != None:
6994 self.code = code
6995 else:
6996 self.code = 0
6997 if data != None:
6998 self.data = data
6999 else:
7000 self.data = ''
7001 return
7002
7003 def pack(self):
7004 packed = []
7005 packed.append(struct.pack("!B", self.version))
7006 packed.append(struct.pack("!B", self.type))
7007 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7008 packed.append(struct.pack("!L", self.xid))
7009 packed.append(struct.pack("!H", self.err_type))
7010 packed.append(struct.pack("!H", self.code))
7011 packed.append(self.data)
7012 length = sum([len(x) for x in packed])
7013 packed[2] = struct.pack("!H", length)
7014 return ''.join(packed)
7015
7016 @staticmethod
7017 def unpack(reader):
7018 obj = queue_op_failed_error_msg()
7019 _version = reader.read("!B")[0]
7020 assert(_version == 1)
7021 _type = reader.read("!B")[0]
7022 assert(_type == 1)
7023 _length = reader.read("!H")[0]
7024 orig_reader = reader
7025 reader = orig_reader.slice(_length, 4)
7026 obj.xid = reader.read("!L")[0]
7027 _err_type = reader.read("!H")[0]
7028 assert(_err_type == 5)
7029 obj.code = reader.read("!H")[0]
7030 obj.data = str(reader.read_all())
7031 return obj
7032
7033 def __eq__(self, other):
7034 if type(self) != type(other): return False
7035 if self.xid != other.xid: return False
7036 if self.code != other.code: return False
7037 if self.data != other.data: return False
7038 return True
7039
7040 def pretty_print(self, q):
7041 q.text("queue_op_failed_error_msg {")
7042 with q.group():
7043 with q.indent(2):
7044 q.breakable()
7045 q.text("xid = ");
7046 if self.xid != None:
7047 q.text("%#x" % self.xid)
7048 else:
7049 q.text('None')
7050 q.text(","); q.breakable()
7051 q.text("code = ");
7052 q.text("%#x" % self.code)
7053 q.text(","); q.breakable()
7054 q.text("data = ");
7055 q.pp(self.data)
7056 q.breakable()
7057 q.text('}')
7058
7059error_msg.subtypes[5] = queue_op_failed_error_msg
7060
7061class queue_stats_reply(stats_reply):
7062 version = 1
7063 type = 17
7064 stats_type = 5
7065
7066 def __init__(self, xid=None, flags=None, entries=None):
7067 if xid != None:
7068 self.xid = xid
7069 else:
7070 self.xid = None
7071 if flags != None:
7072 self.flags = flags
7073 else:
7074 self.flags = 0
7075 if entries != None:
7076 self.entries = entries
7077 else:
7078 self.entries = []
7079 return
7080
7081 def pack(self):
7082 packed = []
7083 packed.append(struct.pack("!B", self.version))
7084 packed.append(struct.pack("!B", self.type))
7085 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7086 packed.append(struct.pack("!L", self.xid))
7087 packed.append(struct.pack("!H", self.stats_type))
7088 packed.append(struct.pack("!H", self.flags))
7089 packed.append(loxi.generic_util.pack_list(self.entries))
7090 length = sum([len(x) for x in packed])
7091 packed[2] = struct.pack("!H", length)
7092 return ''.join(packed)
7093
7094 @staticmethod
7095 def unpack(reader):
7096 obj = queue_stats_reply()
7097 _version = reader.read("!B")[0]
7098 assert(_version == 1)
7099 _type = reader.read("!B")[0]
7100 assert(_type == 17)
7101 _length = reader.read("!H")[0]
7102 orig_reader = reader
7103 reader = orig_reader.slice(_length, 4)
7104 obj.xid = reader.read("!L")[0]
7105 _stats_type = reader.read("!H")[0]
7106 assert(_stats_type == 5)
7107 obj.flags = reader.read("!H")[0]
7108 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.queue_stats_entry.unpack)
7109 return obj
7110
7111 def __eq__(self, other):
7112 if type(self) != type(other): return False
7113 if self.xid != other.xid: return False
7114 if self.flags != other.flags: return False
7115 if self.entries != other.entries: return False
7116 return True
7117
7118 def pretty_print(self, q):
7119 q.text("queue_stats_reply {")
7120 with q.group():
7121 with q.indent(2):
7122 q.breakable()
7123 q.text("xid = ");
7124 if self.xid != None:
7125 q.text("%#x" % self.xid)
7126 else:
7127 q.text('None')
7128 q.text(","); q.breakable()
7129 q.text("flags = ");
7130 q.text("%#x" % self.flags)
7131 q.text(","); q.breakable()
7132 q.text("entries = ");
7133 q.pp(self.entries)
7134 q.breakable()
7135 q.text('}')
7136
7137stats_reply.subtypes[5] = queue_stats_reply
7138
7139class queue_stats_request(stats_request):
7140 version = 1
7141 type = 16
7142 stats_type = 5
7143
7144 def __init__(self, xid=None, flags=None, port_no=None, queue_id=None):
7145 if xid != None:
7146 self.xid = xid
7147 else:
7148 self.xid = None
7149 if flags != None:
7150 self.flags = flags
7151 else:
7152 self.flags = 0
7153 if port_no != None:
7154 self.port_no = port_no
7155 else:
7156 self.port_no = 0
7157 if queue_id != None:
7158 self.queue_id = queue_id
7159 else:
7160 self.queue_id = 0
7161 return
7162
7163 def pack(self):
7164 packed = []
7165 packed.append(struct.pack("!B", self.version))
7166 packed.append(struct.pack("!B", self.type))
7167 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7168 packed.append(struct.pack("!L", self.xid))
7169 packed.append(struct.pack("!H", self.stats_type))
7170 packed.append(struct.pack("!H", self.flags))
7171 packed.append(util.pack_port_no(self.port_no))
7172 packed.append('\x00' * 2)
7173 packed.append(struct.pack("!L", self.queue_id))
7174 length = sum([len(x) for x in packed])
7175 packed[2] = struct.pack("!H", length)
7176 return ''.join(packed)
7177
7178 @staticmethod
7179 def unpack(reader):
7180 obj = queue_stats_request()
7181 _version = reader.read("!B")[0]
7182 assert(_version == 1)
7183 _type = reader.read("!B")[0]
7184 assert(_type == 16)
7185 _length = reader.read("!H")[0]
7186 orig_reader = reader
7187 reader = orig_reader.slice(_length, 4)
7188 obj.xid = reader.read("!L")[0]
7189 _stats_type = reader.read("!H")[0]
7190 assert(_stats_type == 5)
7191 obj.flags = reader.read("!H")[0]
7192 obj.port_no = util.unpack_port_no(reader)
7193 reader.skip(2)
7194 obj.queue_id = reader.read("!L")[0]
7195 return obj
7196
7197 def __eq__(self, other):
7198 if type(self) != type(other): return False
7199 if self.xid != other.xid: return False
7200 if self.flags != other.flags: return False
7201 if self.port_no != other.port_no: return False
7202 if self.queue_id != other.queue_id: return False
7203 return True
7204
7205 def pretty_print(self, q):
7206 q.text("queue_stats_request {")
7207 with q.group():
7208 with q.indent(2):
7209 q.breakable()
7210 q.text("xid = ");
7211 if self.xid != None:
7212 q.text("%#x" % self.xid)
7213 else:
7214 q.text('None')
7215 q.text(","); q.breakable()
7216 q.text("flags = ");
7217 q.text("%#x" % self.flags)
7218 q.text(","); q.breakable()
7219 q.text("port_no = ");
7220 q.text(util.pretty_port(self.port_no))
7221 q.text(","); q.breakable()
7222 q.text("queue_id = ");
7223 q.text("%#x" % self.queue_id)
7224 q.breakable()
7225 q.text('}')
7226
7227stats_request.subtypes[5] = queue_stats_request
7228
7229class set_config(message):
7230 version = 1
7231 type = 9
7232
7233 def __init__(self, xid=None, flags=None, miss_send_len=None):
7234 if xid != None:
7235 self.xid = xid
7236 else:
7237 self.xid = None
7238 if flags != None:
7239 self.flags = flags
7240 else:
7241 self.flags = 0
7242 if miss_send_len != None:
7243 self.miss_send_len = miss_send_len
7244 else:
7245 self.miss_send_len = 0
7246 return
7247
7248 def pack(self):
7249 packed = []
7250 packed.append(struct.pack("!B", self.version))
7251 packed.append(struct.pack("!B", self.type))
7252 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7253 packed.append(struct.pack("!L", self.xid))
7254 packed.append(struct.pack("!H", self.flags))
7255 packed.append(struct.pack("!H", self.miss_send_len))
7256 length = sum([len(x) for x in packed])
7257 packed[2] = struct.pack("!H", length)
7258 return ''.join(packed)
7259
7260 @staticmethod
7261 def unpack(reader):
7262 obj = set_config()
7263 _version = reader.read("!B")[0]
7264 assert(_version == 1)
7265 _type = reader.read("!B")[0]
7266 assert(_type == 9)
7267 _length = reader.read("!H")[0]
7268 orig_reader = reader
7269 reader = orig_reader.slice(_length, 4)
7270 obj.xid = reader.read("!L")[0]
7271 obj.flags = reader.read("!H")[0]
7272 obj.miss_send_len = reader.read("!H")[0]
7273 return obj
7274
7275 def __eq__(self, other):
7276 if type(self) != type(other): return False
7277 if self.xid != other.xid: return False
7278 if self.flags != other.flags: return False
7279 if self.miss_send_len != other.miss_send_len: return False
7280 return True
7281
7282 def pretty_print(self, q):
7283 q.text("set_config {")
7284 with q.group():
7285 with q.indent(2):
7286 q.breakable()
7287 q.text("xid = ");
7288 if self.xid != None:
7289 q.text("%#x" % self.xid)
7290 else:
7291 q.text('None')
7292 q.text(","); q.breakable()
7293 q.text("flags = ");
7294 q.text("%#x" % self.flags)
7295 q.text(","); q.breakable()
7296 q.text("miss_send_len = ");
7297 q.text("%#x" % self.miss_send_len)
7298 q.breakable()
7299 q.text('}')
7300
7301message.subtypes[9] = set_config
7302
7303class table_mod(message):
7304 version = 1
7305 type = 22
7306
7307 def __init__(self, xid=None, table_id=None, config=None):
7308 if xid != None:
7309 self.xid = xid
7310 else:
7311 self.xid = None
7312 if table_id != None:
7313 self.table_id = table_id
7314 else:
7315 self.table_id = 0
7316 if config != None:
7317 self.config = config
7318 else:
7319 self.config = 0
7320 return
7321
7322 def pack(self):
7323 packed = []
7324 packed.append(struct.pack("!B", self.version))
7325 packed.append(struct.pack("!B", self.type))
7326 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7327 packed.append(struct.pack("!L", self.xid))
7328 packed.append(struct.pack("!B", self.table_id))
7329 packed.append('\x00' * 3)
7330 packed.append(struct.pack("!L", self.config))
7331 length = sum([len(x) for x in packed])
7332 packed[2] = struct.pack("!H", length)
7333 return ''.join(packed)
7334
7335 @staticmethod
7336 def unpack(reader):
7337 obj = table_mod()
7338 _version = reader.read("!B")[0]
7339 assert(_version == 1)
7340 _type = reader.read("!B")[0]
7341 assert(_type == 22)
7342 _length = reader.read("!H")[0]
7343 orig_reader = reader
7344 reader = orig_reader.slice(_length, 4)
7345 obj.xid = reader.read("!L")[0]
7346 obj.table_id = reader.read("!B")[0]
7347 reader.skip(3)
7348 obj.config = reader.read("!L")[0]
7349 return obj
7350
7351 def __eq__(self, other):
7352 if type(self) != type(other): return False
7353 if self.xid != other.xid: return False
7354 if self.table_id != other.table_id: return False
7355 if self.config != other.config: return False
7356 return True
7357
7358 def pretty_print(self, q):
7359 q.text("table_mod {")
7360 with q.group():
7361 with q.indent(2):
7362 q.breakable()
7363 q.text("xid = ");
7364 if self.xid != None:
7365 q.text("%#x" % self.xid)
7366 else:
7367 q.text('None')
7368 q.text(","); q.breakable()
7369 q.text("table_id = ");
7370 q.text("%#x" % self.table_id)
7371 q.text(","); q.breakable()
7372 q.text("config = ");
7373 q.text("%#x" % self.config)
7374 q.breakable()
7375 q.text('}')
7376
7377message.subtypes[22] = table_mod
7378
7379class table_stats_reply(stats_reply):
7380 version = 1
7381 type = 17
7382 stats_type = 3
7383
7384 def __init__(self, xid=None, flags=None, entries=None):
7385 if xid != None:
7386 self.xid = xid
7387 else:
7388 self.xid = None
7389 if flags != None:
7390 self.flags = flags
7391 else:
7392 self.flags = 0
7393 if entries != None:
7394 self.entries = entries
7395 else:
7396 self.entries = []
7397 return
7398
7399 def pack(self):
7400 packed = []
7401 packed.append(struct.pack("!B", self.version))
7402 packed.append(struct.pack("!B", self.type))
7403 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7404 packed.append(struct.pack("!L", self.xid))
7405 packed.append(struct.pack("!H", self.stats_type))
7406 packed.append(struct.pack("!H", self.flags))
7407 packed.append(loxi.generic_util.pack_list(self.entries))
7408 length = sum([len(x) for x in packed])
7409 packed[2] = struct.pack("!H", length)
7410 return ''.join(packed)
7411
7412 @staticmethod
7413 def unpack(reader):
7414 obj = table_stats_reply()
7415 _version = reader.read("!B")[0]
7416 assert(_version == 1)
7417 _type = reader.read("!B")[0]
7418 assert(_type == 17)
7419 _length = reader.read("!H")[0]
7420 orig_reader = reader
7421 reader = orig_reader.slice(_length, 4)
7422 obj.xid = reader.read("!L")[0]
7423 _stats_type = reader.read("!H")[0]
7424 assert(_stats_type == 3)
7425 obj.flags = reader.read("!H")[0]
7426 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.table_stats_entry.unpack)
7427 return obj
7428
7429 def __eq__(self, other):
7430 if type(self) != type(other): return False
7431 if self.xid != other.xid: return False
7432 if self.flags != other.flags: return False
7433 if self.entries != other.entries: return False
7434 return True
7435
7436 def pretty_print(self, q):
7437 q.text("table_stats_reply {")
7438 with q.group():
7439 with q.indent(2):
7440 q.breakable()
7441 q.text("xid = ");
7442 if self.xid != None:
7443 q.text("%#x" % self.xid)
7444 else:
7445 q.text('None')
7446 q.text(","); q.breakable()
7447 q.text("flags = ");
7448 q.text("%#x" % self.flags)
7449 q.text(","); q.breakable()
7450 q.text("entries = ");
7451 q.pp(self.entries)
7452 q.breakable()
7453 q.text('}')
7454
7455stats_reply.subtypes[3] = table_stats_reply
7456
7457class table_stats_request(stats_request):
7458 version = 1
7459 type = 16
7460 stats_type = 3
7461
7462 def __init__(self, xid=None, flags=None):
7463 if xid != None:
7464 self.xid = xid
7465 else:
7466 self.xid = None
7467 if flags != None:
7468 self.flags = flags
7469 else:
7470 self.flags = 0
7471 return
7472
7473 def pack(self):
7474 packed = []
7475 packed.append(struct.pack("!B", self.version))
7476 packed.append(struct.pack("!B", self.type))
7477 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7478 packed.append(struct.pack("!L", self.xid))
7479 packed.append(struct.pack("!H", self.stats_type))
7480 packed.append(struct.pack("!H", self.flags))
7481 length = sum([len(x) for x in packed])
7482 packed[2] = struct.pack("!H", length)
7483 return ''.join(packed)
7484
7485 @staticmethod
7486 def unpack(reader):
7487 obj = table_stats_request()
7488 _version = reader.read("!B")[0]
7489 assert(_version == 1)
7490 _type = reader.read("!B")[0]
7491 assert(_type == 16)
7492 _length = reader.read("!H")[0]
7493 orig_reader = reader
7494 reader = orig_reader.slice(_length, 4)
7495 obj.xid = reader.read("!L")[0]
7496 _stats_type = reader.read("!H")[0]
7497 assert(_stats_type == 3)
7498 obj.flags = reader.read("!H")[0]
7499 return obj
7500
7501 def __eq__(self, other):
7502 if type(self) != type(other): return False
7503 if self.xid != other.xid: return False
7504 if self.flags != other.flags: return False
7505 return True
7506
7507 def pretty_print(self, q):
7508 q.text("table_stats_request {")
7509 with q.group():
7510 with q.indent(2):
7511 q.breakable()
7512 q.text("xid = ");
7513 if self.xid != None:
7514 q.text("%#x" % self.xid)
7515 else:
7516 q.text('None')
7517 q.text(","); q.breakable()
7518 q.text("flags = ");
7519 q.text("%#x" % self.flags)
7520 q.breakable()
7521 q.text('}')
7522
7523stats_request.subtypes[3] = table_stats_request
7524
7525
7526def parse_header(buf):
7527 if len(buf) < 8:
7528 raise loxi.ProtocolError("too short to be an OpenFlow message")
7529 return struct.unpack_from("!BBHL", buf)
7530
7531def parse_message(buf):
7532 msg_ver, msg_type, msg_len, msg_xid = parse_header(buf)
7533 if msg_ver != ofp.OFP_VERSION and msg_type != ofp.OFPT_HELLO:
7534 raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (ofp.OFP_VERSION, msg_ver))
7535 if len(buf) != msg_len:
7536 raise loxi.ProtocolError("incorrect message size")
7537 return message.unpack(loxi.generic_util.OFReader(buf))