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