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