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