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