blob: 0566f03887b59efc9b25fb9e23e5337a9ff32f43 [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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 = 2
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 == 2)
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 Lanec2ee4b82013-04-24 17:12:38 -07003039class features_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003040 version = 2
3041 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07003042
3043 def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, capabilities=None, reserved=None, ports=None):
3044 self.xid = xid
3045 if datapath_id != None:
3046 self.datapath_id = datapath_id
3047 else:
3048 self.datapath_id = 0
3049 if n_buffers != None:
3050 self.n_buffers = n_buffers
3051 else:
3052 self.n_buffers = 0
3053 if n_tables != None:
3054 self.n_tables = n_tables
3055 else:
3056 self.n_tables = 0
3057 if capabilities != None:
3058 self.capabilities = capabilities
3059 else:
3060 self.capabilities = 0
3061 if reserved != None:
3062 self.reserved = reserved
3063 else:
3064 self.reserved = 0
3065 if ports != None:
3066 self.ports = ports
3067 else:
3068 self.ports = []
3069
3070 def pack(self):
3071 packed = []
3072 packed.append(struct.pack("!B", self.version))
3073 packed.append(struct.pack("!B", self.type))
3074 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3075 packed.append(struct.pack("!L", self.xid))
3076 packed.append(struct.pack("!Q", self.datapath_id))
3077 packed.append(struct.pack("!L", self.n_buffers))
3078 packed.append(struct.pack("!B", self.n_tables))
3079 packed.append('\x00' * 3)
3080 packed.append(struct.pack("!L", self.capabilities))
3081 packed.append(struct.pack("!L", self.reserved))
Dan Talaycof6202252013-07-02 01:00:29 -07003082 packed.append(util.pack_list(self.ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003083 length = sum([len(x) for x in packed])
3084 packed[2] = struct.pack("!H", length)
3085 return ''.join(packed)
3086
3087 @staticmethod
3088 def unpack(buf):
3089 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3090 obj = features_reply()
3091 if type(buf) == loxi.generic_util.OFReader:
3092 reader = buf
3093 else:
3094 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003095 _version = reader.read("!B")[0]
3096 assert(_version == 2)
3097 _type = reader.read("!B")[0]
3098 assert(_type == 6)
3099 _length = reader.read("!H")[0]
3100 obj.xid = reader.read("!L")[0]
3101 obj.datapath_id = reader.read("!Q")[0]
3102 obj.n_buffers = reader.read("!L")[0]
3103 obj.n_tables = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003104 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07003105 obj.capabilities = reader.read("!L")[0]
3106 obj.reserved = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003107 obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack)
3108 return obj
3109
3110 def __eq__(self, other):
3111 if type(self) != type(other): return False
3112 if self.version != other.version: return False
3113 if self.type != other.type: return False
3114 if self.xid != other.xid: return False
3115 if self.datapath_id != other.datapath_id: return False
3116 if self.n_buffers != other.n_buffers: return False
3117 if self.n_tables != other.n_tables: return False
3118 if self.capabilities != other.capabilities: return False
3119 if self.reserved != other.reserved: return False
3120 if self.ports != other.ports: return False
3121 return True
3122
3123 def __ne__(self, other):
3124 return not self.__eq__(other)
3125
3126 def __str__(self):
3127 return self.show()
3128
3129 def show(self):
3130 import loxi.pp
3131 return loxi.pp.pp(self)
3132
3133 def pretty_print(self, q):
3134 q.text("features_reply {")
3135 with q.group():
3136 with q.indent(2):
3137 q.breakable()
3138 q.text("xid = ");
3139 if self.xid != None:
3140 q.text("%#x" % self.xid)
3141 else:
3142 q.text('None')
3143 q.text(","); q.breakable()
3144 q.text("datapath_id = ");
3145 q.text("%#x" % self.datapath_id)
3146 q.text(","); q.breakable()
3147 q.text("n_buffers = ");
3148 q.text("%#x" % self.n_buffers)
3149 q.text(","); q.breakable()
3150 q.text("n_tables = ");
3151 q.text("%#x" % self.n_tables)
3152 q.text(","); q.breakable()
3153 q.text("capabilities = ");
3154 q.text("%#x" % self.capabilities)
3155 q.text(","); q.breakable()
3156 q.text("reserved = ");
3157 q.text("%#x" % self.reserved)
3158 q.text(","); q.breakable()
3159 q.text("ports = ");
3160 q.pp(self.ports)
3161 q.breakable()
3162 q.text('}')
3163
3164class features_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003165 version = 2
3166 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07003167
3168 def __init__(self, xid=None):
3169 self.xid = xid
3170
3171 def pack(self):
3172 packed = []
3173 packed.append(struct.pack("!B", self.version))
3174 packed.append(struct.pack("!B", self.type))
3175 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3176 packed.append(struct.pack("!L", self.xid))
3177 length = sum([len(x) for x in packed])
3178 packed[2] = struct.pack("!H", length)
3179 return ''.join(packed)
3180
3181 @staticmethod
3182 def unpack(buf):
3183 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3184 obj = features_request()
3185 if type(buf) == loxi.generic_util.OFReader:
3186 reader = buf
3187 else:
3188 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003189 _version = reader.read("!B")[0]
3190 assert(_version == 2)
3191 _type = reader.read("!B")[0]
3192 assert(_type == 5)
3193 _length = reader.read("!H")[0]
3194 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003195 return obj
3196
3197 def __eq__(self, other):
3198 if type(self) != type(other): return False
3199 if self.version != other.version: return False
3200 if self.type != other.type: return False
3201 if self.xid != other.xid: return False
3202 return True
3203
3204 def __ne__(self, other):
3205 return not self.__eq__(other)
3206
3207 def __str__(self):
3208 return self.show()
3209
3210 def show(self):
3211 import loxi.pp
3212 return loxi.pp.pp(self)
3213
3214 def pretty_print(self, q):
3215 q.text("features_request {")
3216 with q.group():
3217 with q.indent(2):
3218 q.breakable()
3219 q.text("xid = ");
3220 if self.xid != None:
3221 q.text("%#x" % self.xid)
3222 else:
3223 q.text('None')
3224 q.breakable()
3225 q.text('}')
3226
3227class flow_add(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003228 version = 2
3229 type = 14
3230 _command = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003231
3232 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):
3233 self.xid = xid
3234 if cookie != None:
3235 self.cookie = cookie
3236 else:
3237 self.cookie = 0
3238 if cookie_mask != None:
3239 self.cookie_mask = cookie_mask
3240 else:
3241 self.cookie_mask = 0
3242 if table_id != None:
3243 self.table_id = table_id
3244 else:
3245 self.table_id = 0
3246 if idle_timeout != None:
3247 self.idle_timeout = idle_timeout
3248 else:
3249 self.idle_timeout = 0
3250 if hard_timeout != None:
3251 self.hard_timeout = hard_timeout
3252 else:
3253 self.hard_timeout = 0
3254 if priority != None:
3255 self.priority = priority
3256 else:
3257 self.priority = 0
3258 if buffer_id != None:
3259 self.buffer_id = buffer_id
3260 else:
3261 self.buffer_id = 0
3262 if out_port != None:
3263 self.out_port = out_port
3264 else:
3265 self.out_port = 0
3266 if out_group != None:
3267 self.out_group = out_group
3268 else:
3269 self.out_group = 0
3270 if flags != None:
3271 self.flags = flags
3272 else:
3273 self.flags = 0
3274 if match != None:
3275 self.match = match
3276 else:
3277 self.match = common.match()
3278 if instructions != None:
3279 self.instructions = instructions
3280 else:
3281 self.instructions = []
3282
3283 def pack(self):
3284 packed = []
3285 packed.append(struct.pack("!B", self.version))
3286 packed.append(struct.pack("!B", self.type))
3287 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3288 packed.append(struct.pack("!L", self.xid))
3289 packed.append(struct.pack("!Q", self.cookie))
3290 packed.append(struct.pack("!Q", self.cookie_mask))
3291 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003292 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003293 packed.append(struct.pack("!H", self.idle_timeout))
3294 packed.append(struct.pack("!H", self.hard_timeout))
3295 packed.append(struct.pack("!H", self.priority))
3296 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003297 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003298 packed.append(struct.pack("!L", self.out_group))
3299 packed.append(struct.pack("!H", self.flags))
3300 packed.append('\x00' * 2)
3301 packed.append(self.match.pack())
Dan Talaycof6202252013-07-02 01:00:29 -07003302 packed.append(util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003303 length = sum([len(x) for x in packed])
3304 packed[2] = struct.pack("!H", length)
3305 return ''.join(packed)
3306
3307 @staticmethod
3308 def unpack(buf):
3309 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3310 obj = flow_add()
3311 if type(buf) == loxi.generic_util.OFReader:
3312 reader = buf
3313 else:
3314 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003315 _version = reader.read("!B")[0]
3316 assert(_version == 2)
3317 _type = reader.read("!B")[0]
3318 assert(_type == 14)
3319 _length = reader.read("!H")[0]
3320 obj.xid = reader.read("!L")[0]
3321 obj.cookie = reader.read("!Q")[0]
3322 obj.cookie_mask = reader.read("!Q")[0]
3323 obj.table_id = reader.read("!B")[0]
3324 __command = util.unpack_fm_cmd(reader)
3325 assert(__command == 0)
3326 obj.idle_timeout = reader.read("!H")[0]
3327 obj.hard_timeout = reader.read("!H")[0]
3328 obj.priority = reader.read("!H")[0]
3329 obj.buffer_id = reader.read("!L")[0]
3330 obj.out_port = util.unpack_port_no(reader)
3331 obj.out_group = reader.read("!L")[0]
3332 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003333 reader.skip(2)
3334 obj.match = common.match.unpack(reader)
3335 obj.instructions = instruction.unpack_list(reader)
3336 return obj
3337
3338 def __eq__(self, other):
3339 if type(self) != type(other): return False
3340 if self.version != other.version: return False
3341 if self.type != other.type: return False
3342 if self.xid != other.xid: return False
3343 if self.cookie != other.cookie: return False
3344 if self.cookie_mask != other.cookie_mask: return False
3345 if self.table_id != other.table_id: return False
3346 if self.idle_timeout != other.idle_timeout: return False
3347 if self.hard_timeout != other.hard_timeout: return False
3348 if self.priority != other.priority: return False
3349 if self.buffer_id != other.buffer_id: return False
3350 if self.out_port != other.out_port: return False
3351 if self.out_group != other.out_group: return False
3352 if self.flags != other.flags: return False
3353 if self.match != other.match: return False
3354 if self.instructions != other.instructions: return False
3355 return True
3356
3357 def __ne__(self, other):
3358 return not self.__eq__(other)
3359
3360 def __str__(self):
3361 return self.show()
3362
3363 def show(self):
3364 import loxi.pp
3365 return loxi.pp.pp(self)
3366
3367 def pretty_print(self, q):
3368 q.text("flow_add {")
3369 with q.group():
3370 with q.indent(2):
3371 q.breakable()
3372 q.text("xid = ");
3373 if self.xid != None:
3374 q.text("%#x" % self.xid)
3375 else:
3376 q.text('None')
3377 q.text(","); q.breakable()
3378 q.text("cookie = ");
3379 q.text("%#x" % self.cookie)
3380 q.text(","); q.breakable()
3381 q.text("cookie_mask = ");
3382 q.text("%#x" % self.cookie_mask)
3383 q.text(","); q.breakable()
3384 q.text("table_id = ");
3385 q.text("%#x" % self.table_id)
3386 q.text(","); q.breakable()
3387 q.text("idle_timeout = ");
3388 q.text("%#x" % self.idle_timeout)
3389 q.text(","); q.breakable()
3390 q.text("hard_timeout = ");
3391 q.text("%#x" % self.hard_timeout)
3392 q.text(","); q.breakable()
3393 q.text("priority = ");
3394 q.text("%#x" % self.priority)
3395 q.text(","); q.breakable()
3396 q.text("buffer_id = ");
3397 q.text("%#x" % self.buffer_id)
3398 q.text(","); q.breakable()
3399 q.text("out_port = ");
3400 q.text(util.pretty_port(self.out_port))
3401 q.text(","); q.breakable()
3402 q.text("out_group = ");
3403 q.text("%#x" % self.out_group)
3404 q.text(","); q.breakable()
3405 q.text("flags = ");
3406 q.text("%#x" % self.flags)
3407 q.text(","); q.breakable()
3408 q.text("match = ");
3409 q.pp(self.match)
3410 q.text(","); q.breakable()
3411 q.text("instructions = ");
3412 q.pp(self.instructions)
3413 q.breakable()
3414 q.text('}')
3415
3416class flow_delete(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003417 version = 2
3418 type = 14
3419 _command = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07003420
3421 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):
3422 self.xid = xid
3423 if cookie != None:
3424 self.cookie = cookie
3425 else:
3426 self.cookie = 0
3427 if cookie_mask != None:
3428 self.cookie_mask = cookie_mask
3429 else:
3430 self.cookie_mask = 0
3431 if table_id != None:
3432 self.table_id = table_id
3433 else:
3434 self.table_id = 0
3435 if idle_timeout != None:
3436 self.idle_timeout = idle_timeout
3437 else:
3438 self.idle_timeout = 0
3439 if hard_timeout != None:
3440 self.hard_timeout = hard_timeout
3441 else:
3442 self.hard_timeout = 0
3443 if priority != None:
3444 self.priority = priority
3445 else:
3446 self.priority = 0
3447 if buffer_id != None:
3448 self.buffer_id = buffer_id
3449 else:
3450 self.buffer_id = 0
3451 if out_port != None:
3452 self.out_port = out_port
3453 else:
3454 self.out_port = 0
3455 if out_group != None:
3456 self.out_group = out_group
3457 else:
3458 self.out_group = 0
3459 if flags != None:
3460 self.flags = flags
3461 else:
3462 self.flags = 0
3463 if match != None:
3464 self.match = match
3465 else:
3466 self.match = common.match()
3467 if instructions != None:
3468 self.instructions = instructions
3469 else:
3470 self.instructions = []
3471
3472 def pack(self):
3473 packed = []
3474 packed.append(struct.pack("!B", self.version))
3475 packed.append(struct.pack("!B", self.type))
3476 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3477 packed.append(struct.pack("!L", self.xid))
3478 packed.append(struct.pack("!Q", self.cookie))
3479 packed.append(struct.pack("!Q", self.cookie_mask))
3480 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003481 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003482 packed.append(struct.pack("!H", self.idle_timeout))
3483 packed.append(struct.pack("!H", self.hard_timeout))
3484 packed.append(struct.pack("!H", self.priority))
3485 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003486 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003487 packed.append(struct.pack("!L", self.out_group))
3488 packed.append(struct.pack("!H", self.flags))
3489 packed.append('\x00' * 2)
3490 packed.append(self.match.pack())
Dan Talaycof6202252013-07-02 01:00:29 -07003491 packed.append(util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003492 length = sum([len(x) for x in packed])
3493 packed[2] = struct.pack("!H", length)
3494 return ''.join(packed)
3495
3496 @staticmethod
3497 def unpack(buf):
3498 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3499 obj = flow_delete()
3500 if type(buf) == loxi.generic_util.OFReader:
3501 reader = buf
3502 else:
3503 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003504 _version = reader.read("!B")[0]
3505 assert(_version == 2)
3506 _type = reader.read("!B")[0]
3507 assert(_type == 14)
3508 _length = reader.read("!H")[0]
3509 obj.xid = reader.read("!L")[0]
3510 obj.cookie = reader.read("!Q")[0]
3511 obj.cookie_mask = reader.read("!Q")[0]
3512 obj.table_id = reader.read("!B")[0]
3513 __command = util.unpack_fm_cmd(reader)
3514 assert(__command == 3)
3515 obj.idle_timeout = reader.read("!H")[0]
3516 obj.hard_timeout = reader.read("!H")[0]
3517 obj.priority = reader.read("!H")[0]
3518 obj.buffer_id = reader.read("!L")[0]
3519 obj.out_port = util.unpack_port_no(reader)
3520 obj.out_group = reader.read("!L")[0]
3521 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003522 reader.skip(2)
3523 obj.match = common.match.unpack(reader)
3524 obj.instructions = instruction.unpack_list(reader)
3525 return obj
3526
3527 def __eq__(self, other):
3528 if type(self) != type(other): return False
3529 if self.version != other.version: return False
3530 if self.type != other.type: return False
3531 if self.xid != other.xid: return False
3532 if self.cookie != other.cookie: return False
3533 if self.cookie_mask != other.cookie_mask: return False
3534 if self.table_id != other.table_id: return False
3535 if self.idle_timeout != other.idle_timeout: return False
3536 if self.hard_timeout != other.hard_timeout: return False
3537 if self.priority != other.priority: return False
3538 if self.buffer_id != other.buffer_id: return False
3539 if self.out_port != other.out_port: return False
3540 if self.out_group != other.out_group: return False
3541 if self.flags != other.flags: return False
3542 if self.match != other.match: return False
3543 if self.instructions != other.instructions: return False
3544 return True
3545
3546 def __ne__(self, other):
3547 return not self.__eq__(other)
3548
3549 def __str__(self):
3550 return self.show()
3551
3552 def show(self):
3553 import loxi.pp
3554 return loxi.pp.pp(self)
3555
3556 def pretty_print(self, q):
3557 q.text("flow_delete {")
3558 with q.group():
3559 with q.indent(2):
3560 q.breakable()
3561 q.text("xid = ");
3562 if self.xid != None:
3563 q.text("%#x" % self.xid)
3564 else:
3565 q.text('None')
3566 q.text(","); q.breakable()
3567 q.text("cookie = ");
3568 q.text("%#x" % self.cookie)
3569 q.text(","); q.breakable()
3570 q.text("cookie_mask = ");
3571 q.text("%#x" % self.cookie_mask)
3572 q.text(","); q.breakable()
3573 q.text("table_id = ");
3574 q.text("%#x" % self.table_id)
3575 q.text(","); q.breakable()
3576 q.text("idle_timeout = ");
3577 q.text("%#x" % self.idle_timeout)
3578 q.text(","); q.breakable()
3579 q.text("hard_timeout = ");
3580 q.text("%#x" % self.hard_timeout)
3581 q.text(","); q.breakable()
3582 q.text("priority = ");
3583 q.text("%#x" % self.priority)
3584 q.text(","); q.breakable()
3585 q.text("buffer_id = ");
3586 q.text("%#x" % self.buffer_id)
3587 q.text(","); q.breakable()
3588 q.text("out_port = ");
3589 q.text(util.pretty_port(self.out_port))
3590 q.text(","); q.breakable()
3591 q.text("out_group = ");
3592 q.text("%#x" % self.out_group)
3593 q.text(","); q.breakable()
3594 q.text("flags = ");
3595 q.text("%#x" % self.flags)
3596 q.text(","); q.breakable()
3597 q.text("match = ");
3598 q.pp(self.match)
3599 q.text(","); q.breakable()
3600 q.text("instructions = ");
3601 q.pp(self.instructions)
3602 q.breakable()
3603 q.text('}')
3604
3605class flow_delete_strict(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003606 version = 2
3607 type = 14
3608 _command = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07003609
3610 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):
3611 self.xid = xid
3612 if cookie != None:
3613 self.cookie = cookie
3614 else:
3615 self.cookie = 0
3616 if cookie_mask != None:
3617 self.cookie_mask = cookie_mask
3618 else:
3619 self.cookie_mask = 0
3620 if table_id != None:
3621 self.table_id = table_id
3622 else:
3623 self.table_id = 0
3624 if idle_timeout != None:
3625 self.idle_timeout = idle_timeout
3626 else:
3627 self.idle_timeout = 0
3628 if hard_timeout != None:
3629 self.hard_timeout = hard_timeout
3630 else:
3631 self.hard_timeout = 0
3632 if priority != None:
3633 self.priority = priority
3634 else:
3635 self.priority = 0
3636 if buffer_id != None:
3637 self.buffer_id = buffer_id
3638 else:
3639 self.buffer_id = 0
3640 if out_port != None:
3641 self.out_port = out_port
3642 else:
3643 self.out_port = 0
3644 if out_group != None:
3645 self.out_group = out_group
3646 else:
3647 self.out_group = 0
3648 if flags != None:
3649 self.flags = flags
3650 else:
3651 self.flags = 0
3652 if match != None:
3653 self.match = match
3654 else:
3655 self.match = common.match()
3656 if instructions != None:
3657 self.instructions = instructions
3658 else:
3659 self.instructions = []
3660
3661 def pack(self):
3662 packed = []
3663 packed.append(struct.pack("!B", self.version))
3664 packed.append(struct.pack("!B", self.type))
3665 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3666 packed.append(struct.pack("!L", self.xid))
3667 packed.append(struct.pack("!Q", self.cookie))
3668 packed.append(struct.pack("!Q", self.cookie_mask))
3669 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003670 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003671 packed.append(struct.pack("!H", self.idle_timeout))
3672 packed.append(struct.pack("!H", self.hard_timeout))
3673 packed.append(struct.pack("!H", self.priority))
3674 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003675 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003676 packed.append(struct.pack("!L", self.out_group))
3677 packed.append(struct.pack("!H", self.flags))
3678 packed.append('\x00' * 2)
3679 packed.append(self.match.pack())
Dan Talaycof6202252013-07-02 01:00:29 -07003680 packed.append(util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003681 length = sum([len(x) for x in packed])
3682 packed[2] = struct.pack("!H", length)
3683 return ''.join(packed)
3684
3685 @staticmethod
3686 def unpack(buf):
3687 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3688 obj = flow_delete_strict()
3689 if type(buf) == loxi.generic_util.OFReader:
3690 reader = buf
3691 else:
3692 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003693 _version = reader.read("!B")[0]
3694 assert(_version == 2)
3695 _type = reader.read("!B")[0]
3696 assert(_type == 14)
3697 _length = reader.read("!H")[0]
3698 obj.xid = reader.read("!L")[0]
3699 obj.cookie = reader.read("!Q")[0]
3700 obj.cookie_mask = reader.read("!Q")[0]
3701 obj.table_id = reader.read("!B")[0]
3702 __command = util.unpack_fm_cmd(reader)
3703 assert(__command == 4)
3704 obj.idle_timeout = reader.read("!H")[0]
3705 obj.hard_timeout = reader.read("!H")[0]
3706 obj.priority = reader.read("!H")[0]
3707 obj.buffer_id = reader.read("!L")[0]
3708 obj.out_port = util.unpack_port_no(reader)
3709 obj.out_group = reader.read("!L")[0]
3710 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003711 reader.skip(2)
3712 obj.match = common.match.unpack(reader)
3713 obj.instructions = instruction.unpack_list(reader)
3714 return obj
3715
3716 def __eq__(self, other):
3717 if type(self) != type(other): return False
3718 if self.version != other.version: return False
3719 if self.type != other.type: return False
3720 if self.xid != other.xid: return False
3721 if self.cookie != other.cookie: return False
3722 if self.cookie_mask != other.cookie_mask: return False
3723 if self.table_id != other.table_id: return False
3724 if self.idle_timeout != other.idle_timeout: return False
3725 if self.hard_timeout != other.hard_timeout: return False
3726 if self.priority != other.priority: return False
3727 if self.buffer_id != other.buffer_id: return False
3728 if self.out_port != other.out_port: return False
3729 if self.out_group != other.out_group: return False
3730 if self.flags != other.flags: return False
3731 if self.match != other.match: return False
3732 if self.instructions != other.instructions: return False
3733 return True
3734
3735 def __ne__(self, other):
3736 return not self.__eq__(other)
3737
3738 def __str__(self):
3739 return self.show()
3740
3741 def show(self):
3742 import loxi.pp
3743 return loxi.pp.pp(self)
3744
3745 def pretty_print(self, q):
3746 q.text("flow_delete_strict {")
3747 with q.group():
3748 with q.indent(2):
3749 q.breakable()
3750 q.text("xid = ");
3751 if self.xid != None:
3752 q.text("%#x" % self.xid)
3753 else:
3754 q.text('None')
3755 q.text(","); q.breakable()
3756 q.text("cookie = ");
3757 q.text("%#x" % self.cookie)
3758 q.text(","); q.breakable()
3759 q.text("cookie_mask = ");
3760 q.text("%#x" % self.cookie_mask)
3761 q.text(","); q.breakable()
3762 q.text("table_id = ");
3763 q.text("%#x" % self.table_id)
3764 q.text(","); q.breakable()
3765 q.text("idle_timeout = ");
3766 q.text("%#x" % self.idle_timeout)
3767 q.text(","); q.breakable()
3768 q.text("hard_timeout = ");
3769 q.text("%#x" % self.hard_timeout)
3770 q.text(","); q.breakable()
3771 q.text("priority = ");
3772 q.text("%#x" % self.priority)
3773 q.text(","); q.breakable()
3774 q.text("buffer_id = ");
3775 q.text("%#x" % self.buffer_id)
3776 q.text(","); q.breakable()
3777 q.text("out_port = ");
3778 q.text(util.pretty_port(self.out_port))
3779 q.text(","); q.breakable()
3780 q.text("out_group = ");
3781 q.text("%#x" % self.out_group)
3782 q.text(","); q.breakable()
3783 q.text("flags = ");
3784 q.text("%#x" % self.flags)
3785 q.text(","); q.breakable()
3786 q.text("match = ");
3787 q.pp(self.match)
3788 q.text(","); q.breakable()
3789 q.text("instructions = ");
3790 q.pp(self.instructions)
3791 q.breakable()
3792 q.text('}')
3793
Rich Lane6f4978c2013-10-20 21:33:52 -07003794class flow_mod_failed_error_msg(Message):
3795 version = 2
3796 type = 1
3797 err_type = 5
3798
3799 def __init__(self, xid=None, code=None, data=None):
3800 self.xid = xid
3801 if code != None:
3802 self.code = code
3803 else:
3804 self.code = 0
3805 if data != None:
3806 self.data = data
3807 else:
3808 self.data = ''
3809
3810 def pack(self):
3811 packed = []
3812 packed.append(struct.pack("!B", self.version))
3813 packed.append(struct.pack("!B", self.type))
3814 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3815 packed.append(struct.pack("!L", self.xid))
3816 packed.append(struct.pack("!H", self.err_type))
3817 packed.append(struct.pack("!H", self.code))
3818 packed.append(self.data)
3819 length = sum([len(x) for x in packed])
3820 packed[2] = struct.pack("!H", length)
3821 return ''.join(packed)
3822
3823 @staticmethod
3824 def unpack(buf):
3825 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3826 obj = flow_mod_failed_error_msg()
3827 if type(buf) == loxi.generic_util.OFReader:
3828 reader = buf
3829 else:
3830 reader = loxi.generic_util.OFReader(buf)
3831 _version = reader.read("!B")[0]
3832 assert(_version == 2)
3833 _type = reader.read("!B")[0]
3834 assert(_type == 1)
3835 _length = reader.read("!H")[0]
3836 obj.xid = reader.read("!L")[0]
3837 _err_type = reader.read("!H")[0]
3838 assert(_err_type == 5)
3839 obj.code = reader.read("!H")[0]
3840 obj.data = str(reader.read_all())
3841 return obj
3842
3843 def __eq__(self, other):
3844 if type(self) != type(other): return False
3845 if self.version != other.version: return False
3846 if self.type != other.type: return False
3847 if self.xid != other.xid: return False
3848 if self.code != other.code: return False
3849 if self.data != other.data: return False
3850 return True
3851
3852 def __ne__(self, other):
3853 return not self.__eq__(other)
3854
3855 def __str__(self):
3856 return self.show()
3857
3858 def show(self):
3859 import loxi.pp
3860 return loxi.pp.pp(self)
3861
3862 def pretty_print(self, q):
3863 q.text("flow_mod_failed_error_msg {")
3864 with q.group():
3865 with q.indent(2):
3866 q.breakable()
3867 q.text("xid = ");
3868 if self.xid != None:
3869 q.text("%#x" % self.xid)
3870 else:
3871 q.text('None')
3872 q.text(","); q.breakable()
3873 q.text("code = ");
3874 q.text("%#x" % self.code)
3875 q.text(","); q.breakable()
3876 q.text("data = ");
3877 q.pp(self.data)
3878 q.breakable()
3879 q.text('}')
3880
Rich Lanec2ee4b82013-04-24 17:12:38 -07003881class flow_modify(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003882 version = 2
3883 type = 14
3884 _command = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07003885
3886 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):
3887 self.xid = xid
3888 if cookie != None:
3889 self.cookie = cookie
3890 else:
3891 self.cookie = 0
3892 if cookie_mask != None:
3893 self.cookie_mask = cookie_mask
3894 else:
3895 self.cookie_mask = 0
3896 if table_id != None:
3897 self.table_id = table_id
3898 else:
3899 self.table_id = 0
3900 if idle_timeout != None:
3901 self.idle_timeout = idle_timeout
3902 else:
3903 self.idle_timeout = 0
3904 if hard_timeout != None:
3905 self.hard_timeout = hard_timeout
3906 else:
3907 self.hard_timeout = 0
3908 if priority != None:
3909 self.priority = priority
3910 else:
3911 self.priority = 0
3912 if buffer_id != None:
3913 self.buffer_id = buffer_id
3914 else:
3915 self.buffer_id = 0
3916 if out_port != None:
3917 self.out_port = out_port
3918 else:
3919 self.out_port = 0
3920 if out_group != None:
3921 self.out_group = out_group
3922 else:
3923 self.out_group = 0
3924 if flags != None:
3925 self.flags = flags
3926 else:
3927 self.flags = 0
3928 if match != None:
3929 self.match = match
3930 else:
3931 self.match = common.match()
3932 if instructions != None:
3933 self.instructions = instructions
3934 else:
3935 self.instructions = []
3936
3937 def pack(self):
3938 packed = []
3939 packed.append(struct.pack("!B", self.version))
3940 packed.append(struct.pack("!B", self.type))
3941 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3942 packed.append(struct.pack("!L", self.xid))
3943 packed.append(struct.pack("!Q", self.cookie))
3944 packed.append(struct.pack("!Q", self.cookie_mask))
3945 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003946 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003947 packed.append(struct.pack("!H", self.idle_timeout))
3948 packed.append(struct.pack("!H", self.hard_timeout))
3949 packed.append(struct.pack("!H", self.priority))
3950 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003951 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003952 packed.append(struct.pack("!L", self.out_group))
3953 packed.append(struct.pack("!H", self.flags))
3954 packed.append('\x00' * 2)
3955 packed.append(self.match.pack())
Dan Talaycof6202252013-07-02 01:00:29 -07003956 packed.append(util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003957 length = sum([len(x) for x in packed])
3958 packed[2] = struct.pack("!H", length)
3959 return ''.join(packed)
3960
3961 @staticmethod
3962 def unpack(buf):
3963 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3964 obj = flow_modify()
3965 if type(buf) == loxi.generic_util.OFReader:
3966 reader = buf
3967 else:
3968 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003969 _version = reader.read("!B")[0]
3970 assert(_version == 2)
3971 _type = reader.read("!B")[0]
3972 assert(_type == 14)
3973 _length = reader.read("!H")[0]
3974 obj.xid = reader.read("!L")[0]
3975 obj.cookie = reader.read("!Q")[0]
3976 obj.cookie_mask = reader.read("!Q")[0]
3977 obj.table_id = reader.read("!B")[0]
3978 __command = util.unpack_fm_cmd(reader)
3979 assert(__command == 1)
3980 obj.idle_timeout = reader.read("!H")[0]
3981 obj.hard_timeout = reader.read("!H")[0]
3982 obj.priority = reader.read("!H")[0]
3983 obj.buffer_id = reader.read("!L")[0]
3984 obj.out_port = util.unpack_port_no(reader)
3985 obj.out_group = reader.read("!L")[0]
3986 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003987 reader.skip(2)
3988 obj.match = common.match.unpack(reader)
3989 obj.instructions = instruction.unpack_list(reader)
3990 return obj
3991
3992 def __eq__(self, other):
3993 if type(self) != type(other): return False
3994 if self.version != other.version: return False
3995 if self.type != other.type: return False
3996 if self.xid != other.xid: return False
3997 if self.cookie != other.cookie: return False
3998 if self.cookie_mask != other.cookie_mask: return False
3999 if self.table_id != other.table_id: return False
4000 if self.idle_timeout != other.idle_timeout: return False
4001 if self.hard_timeout != other.hard_timeout: return False
4002 if self.priority != other.priority: return False
4003 if self.buffer_id != other.buffer_id: return False
4004 if self.out_port != other.out_port: return False
4005 if self.out_group != other.out_group: return False
4006 if self.flags != other.flags: return False
4007 if self.match != other.match: return False
4008 if self.instructions != other.instructions: return False
4009 return True
4010
4011 def __ne__(self, other):
4012 return not self.__eq__(other)
4013
4014 def __str__(self):
4015 return self.show()
4016
4017 def show(self):
4018 import loxi.pp
4019 return loxi.pp.pp(self)
4020
4021 def pretty_print(self, q):
4022 q.text("flow_modify {")
4023 with q.group():
4024 with q.indent(2):
4025 q.breakable()
4026 q.text("xid = ");
4027 if self.xid != None:
4028 q.text("%#x" % self.xid)
4029 else:
4030 q.text('None')
4031 q.text(","); q.breakable()
4032 q.text("cookie = ");
4033 q.text("%#x" % self.cookie)
4034 q.text(","); q.breakable()
4035 q.text("cookie_mask = ");
4036 q.text("%#x" % self.cookie_mask)
4037 q.text(","); q.breakable()
4038 q.text("table_id = ");
4039 q.text("%#x" % self.table_id)
4040 q.text(","); q.breakable()
4041 q.text("idle_timeout = ");
4042 q.text("%#x" % self.idle_timeout)
4043 q.text(","); q.breakable()
4044 q.text("hard_timeout = ");
4045 q.text("%#x" % self.hard_timeout)
4046 q.text(","); q.breakable()
4047 q.text("priority = ");
4048 q.text("%#x" % self.priority)
4049 q.text(","); q.breakable()
4050 q.text("buffer_id = ");
4051 q.text("%#x" % self.buffer_id)
4052 q.text(","); q.breakable()
4053 q.text("out_port = ");
4054 q.text(util.pretty_port(self.out_port))
4055 q.text(","); q.breakable()
4056 q.text("out_group = ");
4057 q.text("%#x" % self.out_group)
4058 q.text(","); q.breakable()
4059 q.text("flags = ");
4060 q.text("%#x" % self.flags)
4061 q.text(","); q.breakable()
4062 q.text("match = ");
4063 q.pp(self.match)
4064 q.text(","); q.breakable()
4065 q.text("instructions = ");
4066 q.pp(self.instructions)
4067 q.breakable()
4068 q.text('}')
4069
4070class flow_modify_strict(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004071 version = 2
4072 type = 14
4073 _command = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07004074
4075 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):
4076 self.xid = xid
4077 if cookie != None:
4078 self.cookie = cookie
4079 else:
4080 self.cookie = 0
4081 if cookie_mask != None:
4082 self.cookie_mask = cookie_mask
4083 else:
4084 self.cookie_mask = 0
4085 if table_id != None:
4086 self.table_id = table_id
4087 else:
4088 self.table_id = 0
4089 if idle_timeout != None:
4090 self.idle_timeout = idle_timeout
4091 else:
4092 self.idle_timeout = 0
4093 if hard_timeout != None:
4094 self.hard_timeout = hard_timeout
4095 else:
4096 self.hard_timeout = 0
4097 if priority != None:
4098 self.priority = priority
4099 else:
4100 self.priority = 0
4101 if buffer_id != None:
4102 self.buffer_id = buffer_id
4103 else:
4104 self.buffer_id = 0
4105 if out_port != None:
4106 self.out_port = out_port
4107 else:
4108 self.out_port = 0
4109 if out_group != None:
4110 self.out_group = out_group
4111 else:
4112 self.out_group = 0
4113 if flags != None:
4114 self.flags = flags
4115 else:
4116 self.flags = 0
4117 if match != None:
4118 self.match = match
4119 else:
4120 self.match = common.match()
4121 if instructions != None:
4122 self.instructions = instructions
4123 else:
4124 self.instructions = []
4125
4126 def pack(self):
4127 packed = []
4128 packed.append(struct.pack("!B", self.version))
4129 packed.append(struct.pack("!B", self.type))
4130 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4131 packed.append(struct.pack("!L", self.xid))
4132 packed.append(struct.pack("!Q", self.cookie))
4133 packed.append(struct.pack("!Q", self.cookie_mask))
4134 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004135 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004136 packed.append(struct.pack("!H", self.idle_timeout))
4137 packed.append(struct.pack("!H", self.hard_timeout))
4138 packed.append(struct.pack("!H", self.priority))
4139 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004140 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004141 packed.append(struct.pack("!L", self.out_group))
4142 packed.append(struct.pack("!H", self.flags))
4143 packed.append('\x00' * 2)
4144 packed.append(self.match.pack())
Dan Talaycof6202252013-07-02 01:00:29 -07004145 packed.append(util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004146 length = sum([len(x) for x in packed])
4147 packed[2] = struct.pack("!H", length)
4148 return ''.join(packed)
4149
4150 @staticmethod
4151 def unpack(buf):
4152 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4153 obj = flow_modify_strict()
4154 if type(buf) == loxi.generic_util.OFReader:
4155 reader = buf
4156 else:
4157 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004158 _version = reader.read("!B")[0]
4159 assert(_version == 2)
4160 _type = reader.read("!B")[0]
4161 assert(_type == 14)
4162 _length = reader.read("!H")[0]
4163 obj.xid = reader.read("!L")[0]
4164 obj.cookie = reader.read("!Q")[0]
4165 obj.cookie_mask = reader.read("!Q")[0]
4166 obj.table_id = reader.read("!B")[0]
4167 __command = util.unpack_fm_cmd(reader)
4168 assert(__command == 2)
4169 obj.idle_timeout = reader.read("!H")[0]
4170 obj.hard_timeout = reader.read("!H")[0]
4171 obj.priority = reader.read("!H")[0]
4172 obj.buffer_id = reader.read("!L")[0]
4173 obj.out_port = util.unpack_port_no(reader)
4174 obj.out_group = reader.read("!L")[0]
4175 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004176 reader.skip(2)
4177 obj.match = common.match.unpack(reader)
4178 obj.instructions = instruction.unpack_list(reader)
4179 return obj
4180
4181 def __eq__(self, other):
4182 if type(self) != type(other): return False
4183 if self.version != other.version: return False
4184 if self.type != other.type: return False
4185 if self.xid != other.xid: return False
4186 if self.cookie != other.cookie: return False
4187 if self.cookie_mask != other.cookie_mask: return False
4188 if self.table_id != other.table_id: return False
4189 if self.idle_timeout != other.idle_timeout: return False
4190 if self.hard_timeout != other.hard_timeout: return False
4191 if self.priority != other.priority: return False
4192 if self.buffer_id != other.buffer_id: return False
4193 if self.out_port != other.out_port: return False
4194 if self.out_group != other.out_group: return False
4195 if self.flags != other.flags: return False
4196 if self.match != other.match: return False
4197 if self.instructions != other.instructions: return False
4198 return True
4199
4200 def __ne__(self, other):
4201 return not self.__eq__(other)
4202
4203 def __str__(self):
4204 return self.show()
4205
4206 def show(self):
4207 import loxi.pp
4208 return loxi.pp.pp(self)
4209
4210 def pretty_print(self, q):
4211 q.text("flow_modify_strict {")
4212 with q.group():
4213 with q.indent(2):
4214 q.breakable()
4215 q.text("xid = ");
4216 if self.xid != None:
4217 q.text("%#x" % self.xid)
4218 else:
4219 q.text('None')
4220 q.text(","); q.breakable()
4221 q.text("cookie = ");
4222 q.text("%#x" % self.cookie)
4223 q.text(","); q.breakable()
4224 q.text("cookie_mask = ");
4225 q.text("%#x" % self.cookie_mask)
4226 q.text(","); q.breakable()
4227 q.text("table_id = ");
4228 q.text("%#x" % self.table_id)
4229 q.text(","); q.breakable()
4230 q.text("idle_timeout = ");
4231 q.text("%#x" % self.idle_timeout)
4232 q.text(","); q.breakable()
4233 q.text("hard_timeout = ");
4234 q.text("%#x" % self.hard_timeout)
4235 q.text(","); q.breakable()
4236 q.text("priority = ");
4237 q.text("%#x" % self.priority)
4238 q.text(","); q.breakable()
4239 q.text("buffer_id = ");
4240 q.text("%#x" % self.buffer_id)
4241 q.text(","); q.breakable()
4242 q.text("out_port = ");
4243 q.text(util.pretty_port(self.out_port))
4244 q.text(","); q.breakable()
4245 q.text("out_group = ");
4246 q.text("%#x" % self.out_group)
4247 q.text(","); q.breakable()
4248 q.text("flags = ");
4249 q.text("%#x" % self.flags)
4250 q.text(","); q.breakable()
4251 q.text("match = ");
4252 q.pp(self.match)
4253 q.text(","); q.breakable()
4254 q.text("instructions = ");
4255 q.pp(self.instructions)
4256 q.breakable()
4257 q.text('}')
4258
4259class flow_removed(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004260 version = 2
4261 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -07004262
4263 def __init__(self, xid=None, cookie=None, priority=None, reason=None, table_id=None, duration_sec=None, duration_nsec=None, idle_timeout=None, packet_count=None, byte_count=None, match=None):
4264 self.xid = xid
4265 if cookie != None:
4266 self.cookie = cookie
4267 else:
4268 self.cookie = 0
4269 if priority != None:
4270 self.priority = priority
4271 else:
4272 self.priority = 0
4273 if reason != None:
4274 self.reason = reason
4275 else:
4276 self.reason = 0
4277 if table_id != None:
4278 self.table_id = table_id
4279 else:
4280 self.table_id = 0
4281 if duration_sec != None:
4282 self.duration_sec = duration_sec
4283 else:
4284 self.duration_sec = 0
4285 if duration_nsec != None:
4286 self.duration_nsec = duration_nsec
4287 else:
4288 self.duration_nsec = 0
4289 if idle_timeout != None:
4290 self.idle_timeout = idle_timeout
4291 else:
4292 self.idle_timeout = 0
4293 if packet_count != None:
4294 self.packet_count = packet_count
4295 else:
4296 self.packet_count = 0
4297 if byte_count != None:
4298 self.byte_count = byte_count
4299 else:
4300 self.byte_count = 0
4301 if match != None:
4302 self.match = match
4303 else:
4304 self.match = common.match()
4305
4306 def pack(self):
4307 packed = []
4308 packed.append(struct.pack("!B", self.version))
4309 packed.append(struct.pack("!B", self.type))
4310 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4311 packed.append(struct.pack("!L", self.xid))
4312 packed.append(struct.pack("!Q", self.cookie))
4313 packed.append(struct.pack("!H", self.priority))
4314 packed.append(struct.pack("!B", self.reason))
4315 packed.append(struct.pack("!B", self.table_id))
4316 packed.append(struct.pack("!L", self.duration_sec))
4317 packed.append(struct.pack("!L", self.duration_nsec))
4318 packed.append(struct.pack("!H", self.idle_timeout))
4319 packed.append('\x00' * 2)
4320 packed.append(struct.pack("!Q", self.packet_count))
4321 packed.append(struct.pack("!Q", self.byte_count))
4322 packed.append(self.match.pack())
4323 length = sum([len(x) for x in packed])
4324 packed[2] = struct.pack("!H", length)
4325 return ''.join(packed)
4326
4327 @staticmethod
4328 def unpack(buf):
4329 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4330 obj = flow_removed()
4331 if type(buf) == loxi.generic_util.OFReader:
4332 reader = buf
4333 else:
4334 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004335 _version = reader.read("!B")[0]
4336 assert(_version == 2)
4337 _type = reader.read("!B")[0]
4338 assert(_type == 11)
4339 _length = reader.read("!H")[0]
4340 obj.xid = reader.read("!L")[0]
4341 obj.cookie = reader.read("!Q")[0]
4342 obj.priority = reader.read("!H")[0]
4343 obj.reason = reader.read("!B")[0]
4344 obj.table_id = reader.read("!B")[0]
4345 obj.duration_sec = reader.read("!L")[0]
4346 obj.duration_nsec = reader.read("!L")[0]
4347 obj.idle_timeout = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004348 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07004349 obj.packet_count = reader.read("!Q")[0]
4350 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004351 obj.match = common.match.unpack(reader)
4352 return obj
4353
4354 def __eq__(self, other):
4355 if type(self) != type(other): return False
4356 if self.version != other.version: return False
4357 if self.type != other.type: return False
4358 if self.xid != other.xid: return False
4359 if self.cookie != other.cookie: return False
4360 if self.priority != other.priority: return False
4361 if self.reason != other.reason: return False
4362 if self.table_id != other.table_id: return False
4363 if self.duration_sec != other.duration_sec: return False
4364 if self.duration_nsec != other.duration_nsec: return False
4365 if self.idle_timeout != other.idle_timeout: return False
4366 if self.packet_count != other.packet_count: return False
4367 if self.byte_count != other.byte_count: return False
4368 if self.match != other.match: return False
4369 return True
4370
4371 def __ne__(self, other):
4372 return not self.__eq__(other)
4373
4374 def __str__(self):
4375 return self.show()
4376
4377 def show(self):
4378 import loxi.pp
4379 return loxi.pp.pp(self)
4380
4381 def pretty_print(self, q):
4382 q.text("flow_removed {")
4383 with q.group():
4384 with q.indent(2):
4385 q.breakable()
4386 q.text("xid = ");
4387 if self.xid != None:
4388 q.text("%#x" % self.xid)
4389 else:
4390 q.text('None')
4391 q.text(","); q.breakable()
4392 q.text("cookie = ");
4393 q.text("%#x" % self.cookie)
4394 q.text(","); q.breakable()
4395 q.text("priority = ");
4396 q.text("%#x" % self.priority)
4397 q.text(","); q.breakable()
4398 q.text("reason = ");
4399 q.text("%#x" % self.reason)
4400 q.text(","); q.breakable()
4401 q.text("table_id = ");
4402 q.text("%#x" % self.table_id)
4403 q.text(","); q.breakable()
4404 q.text("duration_sec = ");
4405 q.text("%#x" % self.duration_sec)
4406 q.text(","); q.breakable()
4407 q.text("duration_nsec = ");
4408 q.text("%#x" % self.duration_nsec)
4409 q.text(","); q.breakable()
4410 q.text("idle_timeout = ");
4411 q.text("%#x" % self.idle_timeout)
4412 q.text(","); q.breakable()
4413 q.text("packet_count = ");
4414 q.text("%#x" % self.packet_count)
4415 q.text(","); q.breakable()
4416 q.text("byte_count = ");
4417 q.text("%#x" % self.byte_count)
4418 q.text(","); q.breakable()
4419 q.text("match = ");
4420 q.pp(self.match)
4421 q.breakable()
4422 q.text('}')
4423
4424class flow_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004425 version = 2
4426 type = 19
4427 stats_type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07004428
4429 def __init__(self, xid=None, flags=None, entries=None):
4430 self.xid = xid
4431 if flags != None:
4432 self.flags = flags
4433 else:
4434 self.flags = 0
4435 if entries != None:
4436 self.entries = entries
4437 else:
4438 self.entries = []
4439
4440 def pack(self):
4441 packed = []
4442 packed.append(struct.pack("!B", self.version))
4443 packed.append(struct.pack("!B", self.type))
4444 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4445 packed.append(struct.pack("!L", self.xid))
4446 packed.append(struct.pack("!H", self.stats_type))
4447 packed.append(struct.pack("!H", self.flags))
4448 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07004449 packed.append(util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004450 length = sum([len(x) for x in packed])
4451 packed[2] = struct.pack("!H", length)
4452 return ''.join(packed)
4453
4454 @staticmethod
4455 def unpack(buf):
4456 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4457 obj = flow_stats_reply()
4458 if type(buf) == loxi.generic_util.OFReader:
4459 reader = buf
4460 else:
4461 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004462 _version = reader.read("!B")[0]
4463 assert(_version == 2)
4464 _type = reader.read("!B")[0]
4465 assert(_type == 19)
4466 _length = reader.read("!H")[0]
4467 obj.xid = reader.read("!L")[0]
4468 _stats_type = reader.read("!H")[0]
4469 assert(_stats_type == 1)
4470 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004471 reader.skip(4)
4472 obj.entries = common.unpack_list_flow_stats_entry(reader)
4473 return obj
4474
4475 def __eq__(self, other):
4476 if type(self) != type(other): return False
4477 if self.version != other.version: return False
4478 if self.type != other.type: return False
4479 if self.xid != other.xid: return False
4480 if self.flags != other.flags: return False
4481 if self.entries != other.entries: return False
4482 return True
4483
4484 def __ne__(self, other):
4485 return not self.__eq__(other)
4486
4487 def __str__(self):
4488 return self.show()
4489
4490 def show(self):
4491 import loxi.pp
4492 return loxi.pp.pp(self)
4493
4494 def pretty_print(self, q):
4495 q.text("flow_stats_reply {")
4496 with q.group():
4497 with q.indent(2):
4498 q.breakable()
4499 q.text("xid = ");
4500 if self.xid != None:
4501 q.text("%#x" % self.xid)
4502 else:
4503 q.text('None')
4504 q.text(","); q.breakable()
4505 q.text("flags = ");
4506 q.text("%#x" % self.flags)
4507 q.text(","); q.breakable()
4508 q.text("entries = ");
4509 q.pp(self.entries)
4510 q.breakable()
4511 q.text('}')
4512
4513class flow_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004514 version = 2
4515 type = 18
4516 stats_type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07004517
4518 def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None):
4519 self.xid = xid
4520 if flags != None:
4521 self.flags = flags
4522 else:
4523 self.flags = 0
4524 if table_id != None:
4525 self.table_id = table_id
4526 else:
4527 self.table_id = 0
4528 if out_port != None:
4529 self.out_port = out_port
4530 else:
4531 self.out_port = 0
4532 if out_group != None:
4533 self.out_group = out_group
4534 else:
4535 self.out_group = 0
4536 if cookie != None:
4537 self.cookie = cookie
4538 else:
4539 self.cookie = 0
4540 if cookie_mask != None:
4541 self.cookie_mask = cookie_mask
4542 else:
4543 self.cookie_mask = 0
4544 if match != None:
4545 self.match = match
4546 else:
4547 self.match = common.match()
4548
4549 def pack(self):
4550 packed = []
4551 packed.append(struct.pack("!B", self.version))
4552 packed.append(struct.pack("!B", self.type))
4553 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4554 packed.append(struct.pack("!L", self.xid))
4555 packed.append(struct.pack("!H", self.stats_type))
4556 packed.append(struct.pack("!H", self.flags))
4557 packed.append('\x00' * 4)
4558 packed.append(struct.pack("!B", self.table_id))
4559 packed.append('\x00' * 3)
Dan Talaycof6202252013-07-02 01:00:29 -07004560 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004561 packed.append(struct.pack("!L", self.out_group))
4562 packed.append('\x00' * 4)
4563 packed.append(struct.pack("!Q", self.cookie))
4564 packed.append(struct.pack("!Q", self.cookie_mask))
4565 packed.append(self.match.pack())
4566 length = sum([len(x) for x in packed])
4567 packed[2] = struct.pack("!H", length)
4568 return ''.join(packed)
4569
4570 @staticmethod
4571 def unpack(buf):
4572 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4573 obj = flow_stats_request()
4574 if type(buf) == loxi.generic_util.OFReader:
4575 reader = buf
4576 else:
4577 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004578 _version = reader.read("!B")[0]
4579 assert(_version == 2)
4580 _type = reader.read("!B")[0]
4581 assert(_type == 18)
4582 _length = reader.read("!H")[0]
4583 obj.xid = reader.read("!L")[0]
4584 _stats_type = reader.read("!H")[0]
4585 assert(_stats_type == 1)
4586 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004587 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07004588 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004589 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07004590 obj.out_port = util.unpack_port_no(reader)
4591 obj.out_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004592 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07004593 obj.cookie = reader.read("!Q")[0]
4594 obj.cookie_mask = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004595 obj.match = common.match.unpack(reader)
4596 return obj
4597
4598 def __eq__(self, other):
4599 if type(self) != type(other): return False
4600 if self.version != other.version: return False
4601 if self.type != other.type: return False
4602 if self.xid != other.xid: return False
4603 if self.flags != other.flags: return False
4604 if self.table_id != other.table_id: return False
4605 if self.out_port != other.out_port: return False
4606 if self.out_group != other.out_group: return False
4607 if self.cookie != other.cookie: return False
4608 if self.cookie_mask != other.cookie_mask: return False
4609 if self.match != other.match: return False
4610 return True
4611
4612 def __ne__(self, other):
4613 return not self.__eq__(other)
4614
4615 def __str__(self):
4616 return self.show()
4617
4618 def show(self):
4619 import loxi.pp
4620 return loxi.pp.pp(self)
4621
4622 def pretty_print(self, q):
4623 q.text("flow_stats_request {")
4624 with q.group():
4625 with q.indent(2):
4626 q.breakable()
4627 q.text("xid = ");
4628 if self.xid != None:
4629 q.text("%#x" % self.xid)
4630 else:
4631 q.text('None')
4632 q.text(","); q.breakable()
4633 q.text("flags = ");
4634 q.text("%#x" % self.flags)
4635 q.text(","); q.breakable()
4636 q.text("table_id = ");
4637 q.text("%#x" % self.table_id)
4638 q.text(","); q.breakable()
4639 q.text("out_port = ");
4640 q.text(util.pretty_port(self.out_port))
4641 q.text(","); q.breakable()
4642 q.text("out_group = ");
4643 q.text("%#x" % self.out_group)
4644 q.text(","); q.breakable()
4645 q.text("cookie = ");
4646 q.text("%#x" % self.cookie)
4647 q.text(","); q.breakable()
4648 q.text("cookie_mask = ");
4649 q.text("%#x" % self.cookie_mask)
4650 q.text(","); q.breakable()
4651 q.text("match = ");
4652 q.pp(self.match)
4653 q.breakable()
4654 q.text('}')
4655
4656class get_config_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004657 version = 2
4658 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07004659
4660 def __init__(self, xid=None, flags=None, miss_send_len=None):
4661 self.xid = xid
4662 if flags != None:
4663 self.flags = flags
4664 else:
4665 self.flags = 0
4666 if miss_send_len != None:
4667 self.miss_send_len = miss_send_len
4668 else:
4669 self.miss_send_len = 0
4670
4671 def pack(self):
4672 packed = []
4673 packed.append(struct.pack("!B", self.version))
4674 packed.append(struct.pack("!B", self.type))
4675 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4676 packed.append(struct.pack("!L", self.xid))
4677 packed.append(struct.pack("!H", self.flags))
4678 packed.append(struct.pack("!H", self.miss_send_len))
4679 length = sum([len(x) for x in packed])
4680 packed[2] = struct.pack("!H", length)
4681 return ''.join(packed)
4682
4683 @staticmethod
4684 def unpack(buf):
4685 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4686 obj = get_config_reply()
4687 if type(buf) == loxi.generic_util.OFReader:
4688 reader = buf
4689 else:
4690 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004691 _version = reader.read("!B")[0]
4692 assert(_version == 2)
4693 _type = reader.read("!B")[0]
4694 assert(_type == 8)
4695 _length = reader.read("!H")[0]
4696 obj.xid = reader.read("!L")[0]
4697 obj.flags = reader.read("!H")[0]
4698 obj.miss_send_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004699 return obj
4700
4701 def __eq__(self, other):
4702 if type(self) != type(other): return False
4703 if self.version != other.version: return False
4704 if self.type != other.type: return False
4705 if self.xid != other.xid: return False
4706 if self.flags != other.flags: return False
4707 if self.miss_send_len != other.miss_send_len: return False
4708 return True
4709
4710 def __ne__(self, other):
4711 return not self.__eq__(other)
4712
4713 def __str__(self):
4714 return self.show()
4715
4716 def show(self):
4717 import loxi.pp
4718 return loxi.pp.pp(self)
4719
4720 def pretty_print(self, q):
4721 q.text("get_config_reply {")
4722 with q.group():
4723 with q.indent(2):
4724 q.breakable()
4725 q.text("xid = ");
4726 if self.xid != None:
4727 q.text("%#x" % self.xid)
4728 else:
4729 q.text('None')
4730 q.text(","); q.breakable()
4731 q.text("flags = ");
4732 q.text("%#x" % self.flags)
4733 q.text(","); q.breakable()
4734 q.text("miss_send_len = ");
4735 q.text("%#x" % self.miss_send_len)
4736 q.breakable()
4737 q.text('}')
4738
4739class get_config_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004740 version = 2
4741 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07004742
4743 def __init__(self, xid=None):
4744 self.xid = xid
4745
4746 def pack(self):
4747 packed = []
4748 packed.append(struct.pack("!B", self.version))
4749 packed.append(struct.pack("!B", self.type))
4750 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4751 packed.append(struct.pack("!L", self.xid))
4752 length = sum([len(x) for x in packed])
4753 packed[2] = struct.pack("!H", length)
4754 return ''.join(packed)
4755
4756 @staticmethod
4757 def unpack(buf):
4758 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4759 obj = get_config_request()
4760 if type(buf) == loxi.generic_util.OFReader:
4761 reader = buf
4762 else:
4763 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004764 _version = reader.read("!B")[0]
4765 assert(_version == 2)
4766 _type = reader.read("!B")[0]
4767 assert(_type == 7)
4768 _length = reader.read("!H")[0]
4769 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004770 return obj
4771
4772 def __eq__(self, other):
4773 if type(self) != type(other): return False
4774 if self.version != other.version: return False
4775 if self.type != other.type: return False
4776 if self.xid != other.xid: return False
4777 return True
4778
4779 def __ne__(self, other):
4780 return not self.__eq__(other)
4781
4782 def __str__(self):
4783 return self.show()
4784
4785 def show(self):
4786 import loxi.pp
4787 return loxi.pp.pp(self)
4788
4789 def pretty_print(self, q):
4790 q.text("get_config_request {")
4791 with q.group():
4792 with q.indent(2):
4793 q.breakable()
4794 q.text("xid = ");
4795 if self.xid != None:
4796 q.text("%#x" % self.xid)
4797 else:
4798 q.text('None')
4799 q.breakable()
4800 q.text('}')
4801
Rich Lane7b0f2012013-11-22 14:15:26 -08004802class group_add(Message):
4803 version = 2
4804 type = 15
4805 command = 0
4806
4807 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
4808 self.xid = xid
4809 if group_type != None:
4810 self.group_type = group_type
4811 else:
4812 self.group_type = 0
4813 if group_id != None:
4814 self.group_id = group_id
4815 else:
4816 self.group_id = 0
4817 if buckets != None:
4818 self.buckets = buckets
4819 else:
4820 self.buckets = []
4821
4822 def pack(self):
4823 packed = []
4824 packed.append(struct.pack("!B", self.version))
4825 packed.append(struct.pack("!B", self.type))
4826 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4827 packed.append(struct.pack("!L", self.xid))
4828 packed.append(struct.pack("!H", self.command))
4829 packed.append(struct.pack("!B", self.group_type))
4830 packed.append('\x00' * 1)
4831 packed.append(struct.pack("!L", self.group_id))
4832 packed.append(util.pack_list(self.buckets))
4833 length = sum([len(x) for x in packed])
4834 packed[2] = struct.pack("!H", length)
4835 return ''.join(packed)
4836
4837 @staticmethod
4838 def unpack(buf):
4839 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4840 obj = group_add()
4841 if type(buf) == loxi.generic_util.OFReader:
4842 reader = buf
4843 else:
4844 reader = loxi.generic_util.OFReader(buf)
4845 _version = reader.read("!B")[0]
4846 assert(_version == 2)
4847 _type = reader.read("!B")[0]
4848 assert(_type == 15)
4849 _length = reader.read("!H")[0]
4850 obj.xid = reader.read("!L")[0]
4851 _command = reader.read("!H")[0]
4852 assert(_command == 0)
4853 obj.group_type = reader.read("!B")[0]
4854 reader.skip(1)
4855 obj.group_id = reader.read("!L")[0]
4856 obj.buckets = common.unpack_list_bucket(reader)
4857 return obj
4858
4859 def __eq__(self, other):
4860 if type(self) != type(other): return False
4861 if self.version != other.version: return False
4862 if self.type != other.type: return False
4863 if self.xid != other.xid: return False
4864 if self.group_type != other.group_type: return False
4865 if self.group_id != other.group_id: return False
4866 if self.buckets != other.buckets: return False
4867 return True
4868
4869 def __ne__(self, other):
4870 return not self.__eq__(other)
4871
4872 def __str__(self):
4873 return self.show()
4874
4875 def show(self):
4876 import loxi.pp
4877 return loxi.pp.pp(self)
4878
4879 def pretty_print(self, q):
4880 q.text("group_add {")
4881 with q.group():
4882 with q.indent(2):
4883 q.breakable()
4884 q.text("xid = ");
4885 if self.xid != None:
4886 q.text("%#x" % self.xid)
4887 else:
4888 q.text('None')
4889 q.text(","); q.breakable()
4890 q.text("group_type = ");
4891 q.text("%#x" % self.group_type)
4892 q.text(","); q.breakable()
4893 q.text("group_id = ");
4894 q.text("%#x" % self.group_id)
4895 q.text(","); q.breakable()
4896 q.text("buckets = ");
4897 q.pp(self.buckets)
4898 q.breakable()
4899 q.text('}')
4900
4901class group_delete(Message):
4902 version = 2
4903 type = 15
4904 command = 2
4905
4906 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
4907 self.xid = xid
4908 if group_type != None:
4909 self.group_type = group_type
4910 else:
4911 self.group_type = 0
4912 if group_id != None:
4913 self.group_id = group_id
4914 else:
4915 self.group_id = 0
4916 if buckets != None:
4917 self.buckets = buckets
4918 else:
4919 self.buckets = []
4920
4921 def pack(self):
4922 packed = []
4923 packed.append(struct.pack("!B", self.version))
4924 packed.append(struct.pack("!B", self.type))
4925 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4926 packed.append(struct.pack("!L", self.xid))
4927 packed.append(struct.pack("!H", self.command))
4928 packed.append(struct.pack("!B", self.group_type))
4929 packed.append('\x00' * 1)
4930 packed.append(struct.pack("!L", self.group_id))
4931 packed.append(util.pack_list(self.buckets))
4932 length = sum([len(x) for x in packed])
4933 packed[2] = struct.pack("!H", length)
4934 return ''.join(packed)
4935
4936 @staticmethod
4937 def unpack(buf):
4938 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4939 obj = group_delete()
4940 if type(buf) == loxi.generic_util.OFReader:
4941 reader = buf
4942 else:
4943 reader = loxi.generic_util.OFReader(buf)
4944 _version = reader.read("!B")[0]
4945 assert(_version == 2)
4946 _type = reader.read("!B")[0]
4947 assert(_type == 15)
4948 _length = reader.read("!H")[0]
4949 obj.xid = reader.read("!L")[0]
4950 _command = reader.read("!H")[0]
4951 assert(_command == 2)
4952 obj.group_type = reader.read("!B")[0]
4953 reader.skip(1)
4954 obj.group_id = reader.read("!L")[0]
4955 obj.buckets = common.unpack_list_bucket(reader)
4956 return obj
4957
4958 def __eq__(self, other):
4959 if type(self) != type(other): return False
4960 if self.version != other.version: return False
4961 if self.type != other.type: return False
4962 if self.xid != other.xid: return False
4963 if self.group_type != other.group_type: return False
4964 if self.group_id != other.group_id: return False
4965 if self.buckets != other.buckets: return False
4966 return True
4967
4968 def __ne__(self, other):
4969 return not self.__eq__(other)
4970
4971 def __str__(self):
4972 return self.show()
4973
4974 def show(self):
4975 import loxi.pp
4976 return loxi.pp.pp(self)
4977
4978 def pretty_print(self, q):
4979 q.text("group_delete {")
4980 with q.group():
4981 with q.indent(2):
4982 q.breakable()
4983 q.text("xid = ");
4984 if self.xid != None:
4985 q.text("%#x" % self.xid)
4986 else:
4987 q.text('None')
4988 q.text(","); q.breakable()
4989 q.text("group_type = ");
4990 q.text("%#x" % self.group_type)
4991 q.text(","); q.breakable()
4992 q.text("group_id = ");
4993 q.text("%#x" % self.group_id)
4994 q.text(","); q.breakable()
4995 q.text("buckets = ");
4996 q.pp(self.buckets)
4997 q.breakable()
4998 q.text('}')
4999
Rich Lanec2ee4b82013-04-24 17:12:38 -07005000class group_desc_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005001 version = 2
5002 type = 19
5003 stats_type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07005004
5005 def __init__(self, xid=None, flags=None, entries=None):
5006 self.xid = xid
5007 if flags != None:
5008 self.flags = flags
5009 else:
5010 self.flags = 0
5011 if entries != None:
5012 self.entries = entries
5013 else:
5014 self.entries = []
5015
5016 def pack(self):
5017 packed = []
5018 packed.append(struct.pack("!B", self.version))
5019 packed.append(struct.pack("!B", self.type))
5020 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5021 packed.append(struct.pack("!L", self.xid))
5022 packed.append(struct.pack("!H", self.stats_type))
5023 packed.append(struct.pack("!H", self.flags))
5024 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07005025 packed.append(util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005026 length = sum([len(x) for x in packed])
5027 packed[2] = struct.pack("!H", length)
5028 return ''.join(packed)
5029
5030 @staticmethod
5031 def unpack(buf):
5032 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5033 obj = group_desc_stats_reply()
5034 if type(buf) == loxi.generic_util.OFReader:
5035 reader = buf
5036 else:
5037 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005038 _version = reader.read("!B")[0]
5039 assert(_version == 2)
5040 _type = reader.read("!B")[0]
5041 assert(_type == 19)
5042 _length = reader.read("!H")[0]
5043 obj.xid = reader.read("!L")[0]
5044 _stats_type = reader.read("!H")[0]
5045 assert(_stats_type == 7)
5046 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005047 reader.skip(4)
5048 obj.entries = common.unpack_list_group_desc_stats_entry(reader)
5049 return obj
5050
5051 def __eq__(self, other):
5052 if type(self) != type(other): return False
5053 if self.version != other.version: return False
5054 if self.type != other.type: return False
5055 if self.xid != other.xid: return False
5056 if self.flags != other.flags: return False
5057 if self.entries != other.entries: return False
5058 return True
5059
5060 def __ne__(self, other):
5061 return not self.__eq__(other)
5062
5063 def __str__(self):
5064 return self.show()
5065
5066 def show(self):
5067 import loxi.pp
5068 return loxi.pp.pp(self)
5069
5070 def pretty_print(self, q):
5071 q.text("group_desc_stats_reply {")
5072 with q.group():
5073 with q.indent(2):
5074 q.breakable()
5075 q.text("xid = ");
5076 if self.xid != None:
5077 q.text("%#x" % self.xid)
5078 else:
5079 q.text('None')
5080 q.text(","); q.breakable()
5081 q.text("flags = ");
5082 q.text("%#x" % self.flags)
5083 q.text(","); q.breakable()
5084 q.text("entries = ");
5085 q.pp(self.entries)
5086 q.breakable()
5087 q.text('}')
5088
5089class group_desc_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005090 version = 2
5091 type = 18
5092 stats_type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07005093
5094 def __init__(self, xid=None, flags=None):
5095 self.xid = xid
5096 if flags != None:
5097 self.flags = flags
5098 else:
5099 self.flags = 0
5100
5101 def pack(self):
5102 packed = []
5103 packed.append(struct.pack("!B", self.version))
5104 packed.append(struct.pack("!B", self.type))
5105 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5106 packed.append(struct.pack("!L", self.xid))
5107 packed.append(struct.pack("!H", self.stats_type))
5108 packed.append(struct.pack("!H", self.flags))
5109 packed.append('\x00' * 4)
5110 length = sum([len(x) for x in packed])
5111 packed[2] = struct.pack("!H", length)
5112 return ''.join(packed)
5113
5114 @staticmethod
5115 def unpack(buf):
5116 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5117 obj = group_desc_stats_request()
5118 if type(buf) == loxi.generic_util.OFReader:
5119 reader = buf
5120 else:
5121 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005122 _version = reader.read("!B")[0]
5123 assert(_version == 2)
5124 _type = reader.read("!B")[0]
5125 assert(_type == 18)
5126 _length = reader.read("!H")[0]
5127 obj.xid = reader.read("!L")[0]
5128 _stats_type = reader.read("!H")[0]
5129 assert(_stats_type == 7)
5130 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005131 reader.skip(4)
5132 return obj
5133
5134 def __eq__(self, other):
5135 if type(self) != type(other): return False
5136 if self.version != other.version: return False
5137 if self.type != other.type: return False
5138 if self.xid != other.xid: return False
5139 if self.flags != other.flags: return False
5140 return True
5141
5142 def __ne__(self, other):
5143 return not self.__eq__(other)
5144
5145 def __str__(self):
5146 return self.show()
5147
5148 def show(self):
5149 import loxi.pp
5150 return loxi.pp.pp(self)
5151
5152 def pretty_print(self, q):
5153 q.text("group_desc_stats_request {")
5154 with q.group():
5155 with q.indent(2):
5156 q.breakable()
5157 q.text("xid = ");
5158 if self.xid != None:
5159 q.text("%#x" % self.xid)
5160 else:
5161 q.text('None')
5162 q.text(","); q.breakable()
5163 q.text("flags = ");
5164 q.text("%#x" % self.flags)
5165 q.breakable()
5166 q.text('}')
5167
Rich Lane6f4978c2013-10-20 21:33:52 -07005168class group_mod_failed_error_msg(Message):
5169 version = 2
5170 type = 1
5171 err_type = 6
5172
5173 def __init__(self, xid=None, code=None, data=None):
5174 self.xid = xid
5175 if code != None:
5176 self.code = code
5177 else:
5178 self.code = 0
5179 if data != None:
5180 self.data = data
5181 else:
5182 self.data = ''
5183
5184 def pack(self):
5185 packed = []
5186 packed.append(struct.pack("!B", self.version))
5187 packed.append(struct.pack("!B", self.type))
5188 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5189 packed.append(struct.pack("!L", self.xid))
5190 packed.append(struct.pack("!H", self.err_type))
5191 packed.append(struct.pack("!H", self.code))
5192 packed.append(self.data)
5193 length = sum([len(x) for x in packed])
5194 packed[2] = struct.pack("!H", length)
5195 return ''.join(packed)
5196
5197 @staticmethod
5198 def unpack(buf):
5199 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5200 obj = group_mod_failed_error_msg()
5201 if type(buf) == loxi.generic_util.OFReader:
5202 reader = buf
5203 else:
5204 reader = loxi.generic_util.OFReader(buf)
5205 _version = reader.read("!B")[0]
5206 assert(_version == 2)
5207 _type = reader.read("!B")[0]
5208 assert(_type == 1)
5209 _length = reader.read("!H")[0]
5210 obj.xid = reader.read("!L")[0]
5211 _err_type = reader.read("!H")[0]
5212 assert(_err_type == 6)
5213 obj.code = reader.read("!H")[0]
5214 obj.data = str(reader.read_all())
5215 return obj
5216
5217 def __eq__(self, other):
5218 if type(self) != type(other): return False
5219 if self.version != other.version: return False
5220 if self.type != other.type: return False
5221 if self.xid != other.xid: return False
5222 if self.code != other.code: return False
5223 if self.data != other.data: return False
5224 return True
5225
5226 def __ne__(self, other):
5227 return not self.__eq__(other)
5228
5229 def __str__(self):
5230 return self.show()
5231
5232 def show(self):
5233 import loxi.pp
5234 return loxi.pp.pp(self)
5235
5236 def pretty_print(self, q):
5237 q.text("group_mod_failed_error_msg {")
5238 with q.group():
5239 with q.indent(2):
5240 q.breakable()
5241 q.text("xid = ");
5242 if self.xid != None:
5243 q.text("%#x" % self.xid)
5244 else:
5245 q.text('None')
5246 q.text(","); q.breakable()
5247 q.text("code = ");
5248 q.text("%#x" % self.code)
5249 q.text(","); q.breakable()
5250 q.text("data = ");
5251 q.pp(self.data)
5252 q.breakable()
5253 q.text('}')
5254
Rich Lane7b0f2012013-11-22 14:15:26 -08005255class group_modify(Message):
5256 version = 2
5257 type = 15
5258 command = 1
5259
5260 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
5261 self.xid = xid
5262 if group_type != None:
5263 self.group_type = group_type
5264 else:
5265 self.group_type = 0
5266 if group_id != None:
5267 self.group_id = group_id
5268 else:
5269 self.group_id = 0
5270 if buckets != None:
5271 self.buckets = buckets
5272 else:
5273 self.buckets = []
5274
5275 def pack(self):
5276 packed = []
5277 packed.append(struct.pack("!B", self.version))
5278 packed.append(struct.pack("!B", self.type))
5279 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5280 packed.append(struct.pack("!L", self.xid))
5281 packed.append(struct.pack("!H", self.command))
5282 packed.append(struct.pack("!B", self.group_type))
5283 packed.append('\x00' * 1)
5284 packed.append(struct.pack("!L", self.group_id))
5285 packed.append(util.pack_list(self.buckets))
5286 length = sum([len(x) for x in packed])
5287 packed[2] = struct.pack("!H", length)
5288 return ''.join(packed)
5289
5290 @staticmethod
5291 def unpack(buf):
5292 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5293 obj = group_modify()
5294 if type(buf) == loxi.generic_util.OFReader:
5295 reader = buf
5296 else:
5297 reader = loxi.generic_util.OFReader(buf)
5298 _version = reader.read("!B")[0]
5299 assert(_version == 2)
5300 _type = reader.read("!B")[0]
5301 assert(_type == 15)
5302 _length = reader.read("!H")[0]
5303 obj.xid = reader.read("!L")[0]
5304 _command = reader.read("!H")[0]
5305 assert(_command == 1)
5306 obj.group_type = reader.read("!B")[0]
5307 reader.skip(1)
5308 obj.group_id = reader.read("!L")[0]
5309 obj.buckets = common.unpack_list_bucket(reader)
5310 return obj
5311
5312 def __eq__(self, other):
5313 if type(self) != type(other): return False
5314 if self.version != other.version: return False
5315 if self.type != other.type: return False
5316 if self.xid != other.xid: return False
5317 if self.group_type != other.group_type: return False
5318 if self.group_id != other.group_id: return False
5319 if self.buckets != other.buckets: return False
5320 return True
5321
5322 def __ne__(self, other):
5323 return not self.__eq__(other)
5324
5325 def __str__(self):
5326 return self.show()
5327
5328 def show(self):
5329 import loxi.pp
5330 return loxi.pp.pp(self)
5331
5332 def pretty_print(self, q):
5333 q.text("group_modify {")
5334 with q.group():
5335 with q.indent(2):
5336 q.breakable()
5337 q.text("xid = ");
5338 if self.xid != None:
5339 q.text("%#x" % self.xid)
5340 else:
5341 q.text('None')
5342 q.text(","); q.breakable()
5343 q.text("group_type = ");
5344 q.text("%#x" % self.group_type)
5345 q.text(","); q.breakable()
5346 q.text("group_id = ");
5347 q.text("%#x" % self.group_id)
5348 q.text(","); q.breakable()
5349 q.text("buckets = ");
5350 q.pp(self.buckets)
5351 q.breakable()
5352 q.text('}')
5353
Rich Lanec2ee4b82013-04-24 17:12:38 -07005354class group_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005355 version = 2
5356 type = 19
5357 stats_type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07005358
5359 def __init__(self, xid=None, flags=None, entries=None):
5360 self.xid = xid
5361 if flags != None:
5362 self.flags = flags
5363 else:
5364 self.flags = 0
5365 if entries != None:
5366 self.entries = entries
5367 else:
5368 self.entries = []
5369
5370 def pack(self):
5371 packed = []
5372 packed.append(struct.pack("!B", self.version))
5373 packed.append(struct.pack("!B", self.type))
5374 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5375 packed.append(struct.pack("!L", self.xid))
5376 packed.append(struct.pack("!H", self.stats_type))
5377 packed.append(struct.pack("!H", self.flags))
5378 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07005379 packed.append(util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005380 length = sum([len(x) for x in packed])
5381 packed[2] = struct.pack("!H", length)
5382 return ''.join(packed)
5383
5384 @staticmethod
5385 def unpack(buf):
5386 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5387 obj = group_stats_reply()
5388 if type(buf) == loxi.generic_util.OFReader:
5389 reader = buf
5390 else:
5391 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005392 _version = reader.read("!B")[0]
5393 assert(_version == 2)
5394 _type = reader.read("!B")[0]
5395 assert(_type == 19)
5396 _length = reader.read("!H")[0]
5397 obj.xid = reader.read("!L")[0]
5398 _stats_type = reader.read("!H")[0]
5399 assert(_stats_type == 6)
5400 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005401 reader.skip(4)
5402 obj.entries = common.unpack_list_group_stats_entry(reader)
5403 return obj
5404
5405 def __eq__(self, other):
5406 if type(self) != type(other): return False
5407 if self.version != other.version: return False
5408 if self.type != other.type: return False
5409 if self.xid != other.xid: return False
5410 if self.flags != other.flags: return False
5411 if self.entries != other.entries: return False
5412 return True
5413
5414 def __ne__(self, other):
5415 return not self.__eq__(other)
5416
5417 def __str__(self):
5418 return self.show()
5419
5420 def show(self):
5421 import loxi.pp
5422 return loxi.pp.pp(self)
5423
5424 def pretty_print(self, q):
5425 q.text("group_stats_reply {")
5426 with q.group():
5427 with q.indent(2):
5428 q.breakable()
5429 q.text("xid = ");
5430 if self.xid != None:
5431 q.text("%#x" % self.xid)
5432 else:
5433 q.text('None')
5434 q.text(","); q.breakable()
5435 q.text("flags = ");
5436 q.text("%#x" % self.flags)
5437 q.text(","); q.breakable()
5438 q.text("entries = ");
5439 q.pp(self.entries)
5440 q.breakable()
5441 q.text('}')
5442
5443class group_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005444 version = 2
5445 type = 18
5446 stats_type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07005447
5448 def __init__(self, xid=None, flags=None, group_id=None):
5449 self.xid = xid
5450 if flags != None:
5451 self.flags = flags
5452 else:
5453 self.flags = 0
5454 if group_id != None:
5455 self.group_id = group_id
5456 else:
5457 self.group_id = 0
5458
5459 def pack(self):
5460 packed = []
5461 packed.append(struct.pack("!B", self.version))
5462 packed.append(struct.pack("!B", self.type))
5463 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5464 packed.append(struct.pack("!L", self.xid))
5465 packed.append(struct.pack("!H", self.stats_type))
5466 packed.append(struct.pack("!H", self.flags))
5467 packed.append('\x00' * 4)
5468 packed.append(struct.pack("!L", self.group_id))
5469 packed.append('\x00' * 4)
5470 length = sum([len(x) for x in packed])
5471 packed[2] = struct.pack("!H", length)
5472 return ''.join(packed)
5473
5474 @staticmethod
5475 def unpack(buf):
5476 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5477 obj = group_stats_request()
5478 if type(buf) == loxi.generic_util.OFReader:
5479 reader = buf
5480 else:
5481 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005482 _version = reader.read("!B")[0]
5483 assert(_version == 2)
5484 _type = reader.read("!B")[0]
5485 assert(_type == 18)
5486 _length = reader.read("!H")[0]
5487 obj.xid = reader.read("!L")[0]
5488 _stats_type = reader.read("!H")[0]
5489 assert(_stats_type == 6)
5490 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005491 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07005492 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005493 reader.skip(4)
5494 return obj
5495
5496 def __eq__(self, other):
5497 if type(self) != type(other): return False
5498 if self.version != other.version: return False
5499 if self.type != other.type: return False
5500 if self.xid != other.xid: return False
5501 if self.flags != other.flags: return False
5502 if self.group_id != other.group_id: 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_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.text(","); q.breakable()
5529 q.text("group_id = ");
5530 q.text("%#x" % self.group_id)
5531 q.breakable()
5532 q.text('}')
5533
5534class hello(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005535 version = 2
5536 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07005537
5538 def __init__(self, xid=None):
5539 self.xid = xid
5540
5541 def pack(self):
5542 packed = []
5543 packed.append(struct.pack("!B", self.version))
5544 packed.append(struct.pack("!B", self.type))
5545 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5546 packed.append(struct.pack("!L", self.xid))
5547 length = sum([len(x) for x in packed])
5548 packed[2] = struct.pack("!H", length)
5549 return ''.join(packed)
5550
5551 @staticmethod
5552 def unpack(buf):
5553 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5554 obj = hello()
5555 if type(buf) == loxi.generic_util.OFReader:
5556 reader = buf
5557 else:
5558 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005559 _version = reader.read("!B")[0]
5560 assert(_version == 2)
5561 _type = reader.read("!B")[0]
5562 assert(_type == 0)
5563 _length = reader.read("!H")[0]
5564 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005565 return obj
5566
5567 def __eq__(self, other):
5568 if type(self) != type(other): return False
5569 if self.version != other.version: return False
5570 if self.type != other.type: return False
5571 if self.xid != other.xid: return False
5572 return True
5573
5574 def __ne__(self, other):
5575 return not self.__eq__(other)
5576
5577 def __str__(self):
5578 return self.show()
5579
5580 def show(self):
5581 import loxi.pp
5582 return loxi.pp.pp(self)
5583
5584 def pretty_print(self, q):
5585 q.text("hello {")
5586 with q.group():
5587 with q.indent(2):
5588 q.breakable()
5589 q.text("xid = ");
5590 if self.xid != None:
5591 q.text("%#x" % self.xid)
5592 else:
5593 q.text('None')
5594 q.breakable()
5595 q.text('}')
5596
Rich Lane6f4978c2013-10-20 21:33:52 -07005597class hello_failed_error_msg(Message):
5598 version = 2
5599 type = 1
5600 err_type = 0
5601
5602 def __init__(self, xid=None, code=None, data=None):
5603 self.xid = xid
5604 if code != None:
5605 self.code = code
5606 else:
5607 self.code = 0
5608 if data != None:
5609 self.data = data
5610 else:
5611 self.data = ''
5612
5613 def pack(self):
5614 packed = []
5615 packed.append(struct.pack("!B", self.version))
5616 packed.append(struct.pack("!B", self.type))
5617 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5618 packed.append(struct.pack("!L", self.xid))
5619 packed.append(struct.pack("!H", self.err_type))
5620 packed.append(struct.pack("!H", self.code))
5621 packed.append(self.data)
5622 length = sum([len(x) for x in packed])
5623 packed[2] = struct.pack("!H", length)
5624 return ''.join(packed)
5625
5626 @staticmethod
5627 def unpack(buf):
5628 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5629 obj = hello_failed_error_msg()
5630 if type(buf) == loxi.generic_util.OFReader:
5631 reader = buf
5632 else:
5633 reader = loxi.generic_util.OFReader(buf)
5634 _version = reader.read("!B")[0]
5635 assert(_version == 2)
5636 _type = reader.read("!B")[0]
5637 assert(_type == 1)
5638 _length = reader.read("!H")[0]
5639 obj.xid = reader.read("!L")[0]
5640 _err_type = reader.read("!H")[0]
5641 assert(_err_type == 0)
5642 obj.code = reader.read("!H")[0]
5643 obj.data = str(reader.read_all())
5644 return obj
5645
5646 def __eq__(self, other):
5647 if type(self) != type(other): return False
5648 if self.version != other.version: return False
5649 if self.type != other.type: return False
5650 if self.xid != other.xid: return False
5651 if self.code != other.code: return False
5652 if self.data != other.data: return False
5653 return True
5654
5655 def __ne__(self, other):
5656 return not self.__eq__(other)
5657
5658 def __str__(self):
5659 return self.show()
5660
5661 def show(self):
5662 import loxi.pp
5663 return loxi.pp.pp(self)
5664
5665 def pretty_print(self, q):
5666 q.text("hello_failed_error_msg {")
5667 with q.group():
5668 with q.indent(2):
5669 q.breakable()
5670 q.text("xid = ");
5671 if self.xid != None:
5672 q.text("%#x" % self.xid)
5673 else:
5674 q.text('None')
5675 q.text(","); q.breakable()
5676 q.text("code = ");
5677 q.text("%#x" % self.code)
5678 q.text(","); q.breakable()
5679 q.text("data = ");
5680 q.pp(self.data)
5681 q.breakable()
5682 q.text('}')
5683
Rich Lanec2ee4b82013-04-24 17:12:38 -07005684class packet_in(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005685 version = 2
5686 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07005687
5688 def __init__(self, xid=None, buffer_id=None, in_port=None, in_phy_port=None, total_len=None, reason=None, table_id=None, data=None):
5689 self.xid = xid
5690 if buffer_id != None:
5691 self.buffer_id = buffer_id
5692 else:
5693 self.buffer_id = 0
5694 if in_port != None:
5695 self.in_port = in_port
5696 else:
5697 self.in_port = 0
5698 if in_phy_port != None:
5699 self.in_phy_port = in_phy_port
5700 else:
5701 self.in_phy_port = 0
5702 if total_len != None:
5703 self.total_len = total_len
5704 else:
5705 self.total_len = 0
5706 if reason != None:
5707 self.reason = reason
5708 else:
5709 self.reason = 0
5710 if table_id != None:
5711 self.table_id = table_id
5712 else:
5713 self.table_id = 0
5714 if data != None:
5715 self.data = data
5716 else:
Dan Talaycof6202252013-07-02 01:00:29 -07005717 self.data = ''
Rich Lanec2ee4b82013-04-24 17:12:38 -07005718
5719 def pack(self):
5720 packed = []
5721 packed.append(struct.pack("!B", self.version))
5722 packed.append(struct.pack("!B", self.type))
5723 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5724 packed.append(struct.pack("!L", self.xid))
5725 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07005726 packed.append(util.pack_port_no(self.in_port))
5727 packed.append(util.pack_port_no(self.in_phy_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005728 packed.append(struct.pack("!H", self.total_len))
5729 packed.append(struct.pack("!B", self.reason))
5730 packed.append(struct.pack("!B", self.table_id))
5731 packed.append(self.data)
5732 length = sum([len(x) for x in packed])
5733 packed[2] = struct.pack("!H", length)
5734 return ''.join(packed)
5735
5736 @staticmethod
5737 def unpack(buf):
5738 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5739 obj = packet_in()
5740 if type(buf) == loxi.generic_util.OFReader:
5741 reader = buf
5742 else:
5743 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005744 _version = reader.read("!B")[0]
5745 assert(_version == 2)
5746 _type = reader.read("!B")[0]
5747 assert(_type == 10)
5748 _length = reader.read("!H")[0]
5749 obj.xid = reader.read("!L")[0]
5750 obj.buffer_id = reader.read("!L")[0]
5751 obj.in_port = util.unpack_port_no(reader)
5752 obj.in_phy_port = util.unpack_port_no(reader)
5753 obj.total_len = reader.read("!H")[0]
5754 obj.reason = reader.read("!B")[0]
5755 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005756 obj.data = str(reader.read_all())
5757 return obj
5758
5759 def __eq__(self, other):
5760 if type(self) != type(other): return False
5761 if self.version != other.version: return False
5762 if self.type != other.type: return False
5763 if self.xid != other.xid: return False
5764 if self.buffer_id != other.buffer_id: return False
5765 if self.in_port != other.in_port: return False
5766 if self.in_phy_port != other.in_phy_port: return False
5767 if self.total_len != other.total_len: return False
5768 if self.reason != other.reason: return False
5769 if self.table_id != other.table_id: return False
5770 if self.data != other.data: return False
5771 return True
5772
5773 def __ne__(self, other):
5774 return not self.__eq__(other)
5775
5776 def __str__(self):
5777 return self.show()
5778
5779 def show(self):
5780 import loxi.pp
5781 return loxi.pp.pp(self)
5782
5783 def pretty_print(self, q):
5784 q.text("packet_in {")
5785 with q.group():
5786 with q.indent(2):
5787 q.breakable()
5788 q.text("xid = ");
5789 if self.xid != None:
5790 q.text("%#x" % self.xid)
5791 else:
5792 q.text('None')
5793 q.text(","); q.breakable()
5794 q.text("buffer_id = ");
5795 q.text("%#x" % self.buffer_id)
5796 q.text(","); q.breakable()
5797 q.text("in_port = ");
5798 q.text(util.pretty_port(self.in_port))
5799 q.text(","); q.breakable()
5800 q.text("in_phy_port = ");
5801 q.text(util.pretty_port(self.in_phy_port))
5802 q.text(","); q.breakable()
5803 q.text("total_len = ");
5804 q.text("%#x" % self.total_len)
5805 q.text(","); q.breakable()
5806 q.text("reason = ");
5807 q.text("%#x" % self.reason)
5808 q.text(","); q.breakable()
5809 q.text("table_id = ");
5810 q.text("%#x" % self.table_id)
5811 q.text(","); q.breakable()
5812 q.text("data = ");
5813 q.pp(self.data)
5814 q.breakable()
5815 q.text('}')
5816
5817class packet_out(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005818 version = 2
5819 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07005820
5821 def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None):
5822 self.xid = xid
5823 if buffer_id != None:
5824 self.buffer_id = buffer_id
5825 else:
5826 self.buffer_id = 0
5827 if in_port != None:
5828 self.in_port = in_port
5829 else:
5830 self.in_port = 0
5831 if actions != None:
5832 self.actions = actions
5833 else:
5834 self.actions = []
5835 if data != None:
5836 self.data = data
5837 else:
Dan Talaycof6202252013-07-02 01:00:29 -07005838 self.data = ''
Rich Lanec2ee4b82013-04-24 17:12:38 -07005839
5840 def pack(self):
5841 packed = []
5842 packed.append(struct.pack("!B", self.version))
5843 packed.append(struct.pack("!B", self.type))
5844 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5845 packed.append(struct.pack("!L", self.xid))
5846 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07005847 packed.append(util.pack_port_no(self.in_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005848 packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6
5849 packed.append('\x00' * 6)
Dan Talaycof6202252013-07-02 01:00:29 -07005850 packed.append(util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005851 packed[6] = struct.pack("!H", len(packed[-1]))
5852 packed.append(self.data)
5853 length = sum([len(x) for x in packed])
5854 packed[2] = struct.pack("!H", length)
5855 return ''.join(packed)
5856
5857 @staticmethod
5858 def unpack(buf):
5859 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5860 obj = packet_out()
5861 if type(buf) == loxi.generic_util.OFReader:
5862 reader = buf
5863 else:
5864 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005865 _version = reader.read("!B")[0]
5866 assert(_version == 2)
5867 _type = reader.read("!B")[0]
5868 assert(_type == 13)
5869 _length = reader.read("!H")[0]
5870 obj.xid = reader.read("!L")[0]
5871 obj.buffer_id = reader.read("!L")[0]
5872 obj.in_port = util.unpack_port_no(reader)
5873 _actions_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005874 reader.skip(6)
5875 obj.actions = action.unpack_list(reader.slice(_actions_len))
5876 obj.data = str(reader.read_all())
5877 return obj
5878
5879 def __eq__(self, other):
5880 if type(self) != type(other): return False
5881 if self.version != other.version: return False
5882 if self.type != other.type: return False
5883 if self.xid != other.xid: return False
5884 if self.buffer_id != other.buffer_id: return False
5885 if self.in_port != other.in_port: return False
5886 if self.actions != other.actions: return False
5887 if self.data != other.data: return False
5888 return True
5889
5890 def __ne__(self, other):
5891 return not self.__eq__(other)
5892
5893 def __str__(self):
5894 return self.show()
5895
5896 def show(self):
5897 import loxi.pp
5898 return loxi.pp.pp(self)
5899
5900 def pretty_print(self, q):
5901 q.text("packet_out {")
5902 with q.group():
5903 with q.indent(2):
5904 q.breakable()
5905 q.text("xid = ");
5906 if self.xid != None:
5907 q.text("%#x" % self.xid)
5908 else:
5909 q.text('None')
5910 q.text(","); q.breakable()
5911 q.text("buffer_id = ");
5912 q.text("%#x" % self.buffer_id)
5913 q.text(","); q.breakable()
5914 q.text("in_port = ");
5915 q.text(util.pretty_port(self.in_port))
5916 q.text(","); q.breakable()
5917 q.text("actions = ");
5918 q.pp(self.actions)
5919 q.text(","); q.breakable()
5920 q.text("data = ");
5921 q.pp(self.data)
5922 q.breakable()
5923 q.text('}')
5924
5925class port_mod(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005926 version = 2
5927 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -07005928
5929 def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None):
5930 self.xid = xid
5931 if port_no != None:
5932 self.port_no = port_no
5933 else:
5934 self.port_no = 0
5935 if hw_addr != None:
5936 self.hw_addr = hw_addr
5937 else:
5938 self.hw_addr = [0,0,0,0,0,0]
5939 if config != None:
5940 self.config = config
5941 else:
5942 self.config = 0
5943 if mask != None:
5944 self.mask = mask
5945 else:
5946 self.mask = 0
5947 if advertise != None:
5948 self.advertise = advertise
5949 else:
5950 self.advertise = 0
5951
5952 def pack(self):
5953 packed = []
5954 packed.append(struct.pack("!B", self.version))
5955 packed.append(struct.pack("!B", self.type))
5956 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5957 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07005958 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005959 packed.append('\x00' * 4)
5960 packed.append(struct.pack("!6B", *self.hw_addr))
5961 packed.append('\x00' * 2)
5962 packed.append(struct.pack("!L", self.config))
5963 packed.append(struct.pack("!L", self.mask))
5964 packed.append(struct.pack("!L", self.advertise))
5965 packed.append('\x00' * 4)
5966 length = sum([len(x) for x in packed])
5967 packed[2] = struct.pack("!H", length)
5968 return ''.join(packed)
5969
5970 @staticmethod
5971 def unpack(buf):
5972 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5973 obj = port_mod()
5974 if type(buf) == loxi.generic_util.OFReader:
5975 reader = buf
5976 else:
5977 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005978 _version = reader.read("!B")[0]
5979 assert(_version == 2)
5980 _type = reader.read("!B")[0]
5981 assert(_type == 16)
5982 _length = reader.read("!H")[0]
5983 obj.xid = reader.read("!L")[0]
5984 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005985 reader.skip(4)
5986 obj.hw_addr = list(reader.read('!6B'))
5987 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07005988 obj.config = reader.read("!L")[0]
5989 obj.mask = reader.read("!L")[0]
5990 obj.advertise = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005991 reader.skip(4)
5992 return obj
5993
5994 def __eq__(self, other):
5995 if type(self) != type(other): return False
5996 if self.version != other.version: return False
5997 if self.type != other.type: return False
5998 if self.xid != other.xid: return False
5999 if self.port_no != other.port_no: return False
6000 if self.hw_addr != other.hw_addr: return False
6001 if self.config != other.config: return False
6002 if self.mask != other.mask: return False
6003 if self.advertise != other.advertise: return False
6004 return True
6005
6006 def __ne__(self, other):
6007 return not self.__eq__(other)
6008
6009 def __str__(self):
6010 return self.show()
6011
6012 def show(self):
6013 import loxi.pp
6014 return loxi.pp.pp(self)
6015
6016 def pretty_print(self, q):
6017 q.text("port_mod {")
6018 with q.group():
6019 with q.indent(2):
6020 q.breakable()
6021 q.text("xid = ");
6022 if self.xid != None:
6023 q.text("%#x" % self.xid)
6024 else:
6025 q.text('None')
6026 q.text(","); q.breakable()
6027 q.text("port_no = ");
6028 q.text(util.pretty_port(self.port_no))
6029 q.text(","); q.breakable()
6030 q.text("hw_addr = ");
6031 q.text(util.pretty_mac(self.hw_addr))
6032 q.text(","); q.breakable()
6033 q.text("config = ");
6034 q.text("%#x" % self.config)
6035 q.text(","); q.breakable()
6036 q.text("mask = ");
6037 q.text("%#x" % self.mask)
6038 q.text(","); q.breakable()
6039 q.text("advertise = ");
6040 q.text("%#x" % self.advertise)
6041 q.breakable()
6042 q.text('}')
6043
Rich Lane6f4978c2013-10-20 21:33:52 -07006044class port_mod_failed_error_msg(Message):
6045 version = 2
6046 type = 1
6047 err_type = 7
6048
6049 def __init__(self, xid=None, code=None, data=None):
6050 self.xid = xid
6051 if code != None:
6052 self.code = code
6053 else:
6054 self.code = 0
6055 if data != None:
6056 self.data = data
6057 else:
6058 self.data = ''
6059
6060 def pack(self):
6061 packed = []
6062 packed.append(struct.pack("!B", self.version))
6063 packed.append(struct.pack("!B", self.type))
6064 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6065 packed.append(struct.pack("!L", self.xid))
6066 packed.append(struct.pack("!H", self.err_type))
6067 packed.append(struct.pack("!H", self.code))
6068 packed.append(self.data)
6069 length = sum([len(x) for x in packed])
6070 packed[2] = struct.pack("!H", length)
6071 return ''.join(packed)
6072
6073 @staticmethod
6074 def unpack(buf):
6075 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6076 obj = port_mod_failed_error_msg()
6077 if type(buf) == loxi.generic_util.OFReader:
6078 reader = buf
6079 else:
6080 reader = loxi.generic_util.OFReader(buf)
6081 _version = reader.read("!B")[0]
6082 assert(_version == 2)
6083 _type = reader.read("!B")[0]
6084 assert(_type == 1)
6085 _length = reader.read("!H")[0]
6086 obj.xid = reader.read("!L")[0]
6087 _err_type = reader.read("!H")[0]
6088 assert(_err_type == 7)
6089 obj.code = reader.read("!H")[0]
6090 obj.data = str(reader.read_all())
6091 return obj
6092
6093 def __eq__(self, other):
6094 if type(self) != type(other): return False
6095 if self.version != other.version: return False
6096 if self.type != other.type: return False
6097 if self.xid != other.xid: return False
6098 if self.code != other.code: return False
6099 if self.data != other.data: return False
6100 return True
6101
6102 def __ne__(self, other):
6103 return not self.__eq__(other)
6104
6105 def __str__(self):
6106 return self.show()
6107
6108 def show(self):
6109 import loxi.pp
6110 return loxi.pp.pp(self)
6111
6112 def pretty_print(self, q):
6113 q.text("port_mod_failed_error_msg {")
6114 with q.group():
6115 with q.indent(2):
6116 q.breakable()
6117 q.text("xid = ");
6118 if self.xid != None:
6119 q.text("%#x" % self.xid)
6120 else:
6121 q.text('None')
6122 q.text(","); q.breakable()
6123 q.text("code = ");
6124 q.text("%#x" % self.code)
6125 q.text(","); q.breakable()
6126 q.text("data = ");
6127 q.pp(self.data)
6128 q.breakable()
6129 q.text('}')
6130
Rich Lanec2ee4b82013-04-24 17:12:38 -07006131class port_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006132 version = 2
6133 type = 19
6134 stats_type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07006135
6136 def __init__(self, xid=None, flags=None, entries=None):
6137 self.xid = xid
6138 if flags != None:
6139 self.flags = flags
6140 else:
6141 self.flags = 0
6142 if entries != None:
6143 self.entries = entries
6144 else:
6145 self.entries = []
6146
6147 def pack(self):
6148 packed = []
6149 packed.append(struct.pack("!B", self.version))
6150 packed.append(struct.pack("!B", self.type))
6151 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6152 packed.append(struct.pack("!L", self.xid))
6153 packed.append(struct.pack("!H", self.stats_type))
6154 packed.append(struct.pack("!H", self.flags))
6155 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006156 packed.append(util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006157 length = sum([len(x) for x in packed])
6158 packed[2] = struct.pack("!H", length)
6159 return ''.join(packed)
6160
6161 @staticmethod
6162 def unpack(buf):
6163 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6164 obj = port_stats_reply()
6165 if type(buf) == loxi.generic_util.OFReader:
6166 reader = buf
6167 else:
6168 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006169 _version = reader.read("!B")[0]
6170 assert(_version == 2)
6171 _type = reader.read("!B")[0]
6172 assert(_type == 19)
6173 _length = reader.read("!H")[0]
6174 obj.xid = reader.read("!L")[0]
6175 _stats_type = reader.read("!H")[0]
6176 assert(_stats_type == 4)
6177 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006178 reader.skip(4)
6179 obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack)
6180 return obj
6181
6182 def __eq__(self, other):
6183 if type(self) != type(other): return False
6184 if self.version != other.version: return False
6185 if self.type != other.type: return False
6186 if self.xid != other.xid: return False
6187 if self.flags != other.flags: return False
6188 if self.entries != other.entries: return False
6189 return True
6190
6191 def __ne__(self, other):
6192 return not self.__eq__(other)
6193
6194 def __str__(self):
6195 return self.show()
6196
6197 def show(self):
6198 import loxi.pp
6199 return loxi.pp.pp(self)
6200
6201 def pretty_print(self, q):
6202 q.text("port_stats_reply {")
6203 with q.group():
6204 with q.indent(2):
6205 q.breakable()
6206 q.text("xid = ");
6207 if self.xid != None:
6208 q.text("%#x" % self.xid)
6209 else:
6210 q.text('None')
6211 q.text(","); q.breakable()
6212 q.text("flags = ");
6213 q.text("%#x" % self.flags)
6214 q.text(","); q.breakable()
6215 q.text("entries = ");
6216 q.pp(self.entries)
6217 q.breakable()
6218 q.text('}')
6219
6220class port_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006221 version = 2
6222 type = 18
6223 stats_type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07006224
6225 def __init__(self, xid=None, flags=None, port_no=None):
6226 self.xid = xid
6227 if flags != None:
6228 self.flags = flags
6229 else:
6230 self.flags = 0
6231 if port_no != None:
6232 self.port_no = port_no
6233 else:
6234 self.port_no = 0
6235
6236 def pack(self):
6237 packed = []
6238 packed.append(struct.pack("!B", self.version))
6239 packed.append(struct.pack("!B", self.type))
6240 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6241 packed.append(struct.pack("!L", self.xid))
6242 packed.append(struct.pack("!H", self.stats_type))
6243 packed.append(struct.pack("!H", self.flags))
6244 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006245 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006246 packed.append('\x00' * 4)
6247 length = sum([len(x) for x in packed])
6248 packed[2] = struct.pack("!H", length)
6249 return ''.join(packed)
6250
6251 @staticmethod
6252 def unpack(buf):
6253 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6254 obj = port_stats_request()
6255 if type(buf) == loxi.generic_util.OFReader:
6256 reader = buf
6257 else:
6258 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006259 _version = reader.read("!B")[0]
6260 assert(_version == 2)
6261 _type = reader.read("!B")[0]
6262 assert(_type == 18)
6263 _length = reader.read("!H")[0]
6264 obj.xid = reader.read("!L")[0]
6265 _stats_type = reader.read("!H")[0]
6266 assert(_stats_type == 4)
6267 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006268 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07006269 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006270 reader.skip(4)
6271 return obj
6272
6273 def __eq__(self, other):
6274 if type(self) != type(other): return False
6275 if self.version != other.version: return False
6276 if self.type != other.type: return False
6277 if self.xid != other.xid: return False
6278 if self.flags != other.flags: return False
6279 if self.port_no != other.port_no: return False
6280 return True
6281
6282 def __ne__(self, other):
6283 return not self.__eq__(other)
6284
6285 def __str__(self):
6286 return self.show()
6287
6288 def show(self):
6289 import loxi.pp
6290 return loxi.pp.pp(self)
6291
6292 def pretty_print(self, q):
6293 q.text("port_stats_request {")
6294 with q.group():
6295 with q.indent(2):
6296 q.breakable()
6297 q.text("xid = ");
6298 if self.xid != None:
6299 q.text("%#x" % self.xid)
6300 else:
6301 q.text('None')
6302 q.text(","); q.breakable()
6303 q.text("flags = ");
6304 q.text("%#x" % self.flags)
6305 q.text(","); q.breakable()
6306 q.text("port_no = ");
6307 q.text(util.pretty_port(self.port_no))
6308 q.breakable()
6309 q.text('}')
6310
6311class port_status(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006312 version = 2
6313 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07006314
6315 def __init__(self, xid=None, reason=None, desc=None):
6316 self.xid = xid
6317 if reason != None:
6318 self.reason = reason
6319 else:
6320 self.reason = 0
6321 if desc != None:
6322 self.desc = desc
6323 else:
6324 self.desc = common.port_desc()
6325
6326 def pack(self):
6327 packed = []
6328 packed.append(struct.pack("!B", self.version))
6329 packed.append(struct.pack("!B", self.type))
6330 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6331 packed.append(struct.pack("!L", self.xid))
6332 packed.append(struct.pack("!B", self.reason))
6333 packed.append('\x00' * 7)
6334 packed.append(self.desc.pack())
6335 length = sum([len(x) for x in packed])
6336 packed[2] = struct.pack("!H", length)
6337 return ''.join(packed)
6338
6339 @staticmethod
6340 def unpack(buf):
6341 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6342 obj = port_status()
6343 if type(buf) == loxi.generic_util.OFReader:
6344 reader = buf
6345 else:
6346 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006347 _version = reader.read("!B")[0]
6348 assert(_version == 2)
6349 _type = reader.read("!B")[0]
6350 assert(_type == 12)
6351 _length = reader.read("!H")[0]
6352 obj.xid = reader.read("!L")[0]
6353 obj.reason = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006354 reader.skip(7)
6355 obj.desc = common.port_desc.unpack(reader)
6356 return obj
6357
6358 def __eq__(self, other):
6359 if type(self) != type(other): return False
6360 if self.version != other.version: return False
6361 if self.type != other.type: return False
6362 if self.xid != other.xid: return False
6363 if self.reason != other.reason: return False
6364 if self.desc != other.desc: return False
6365 return True
6366
6367 def __ne__(self, other):
6368 return not self.__eq__(other)
6369
6370 def __str__(self):
6371 return self.show()
6372
6373 def show(self):
6374 import loxi.pp
6375 return loxi.pp.pp(self)
6376
6377 def pretty_print(self, q):
6378 q.text("port_status {")
6379 with q.group():
6380 with q.indent(2):
6381 q.breakable()
6382 q.text("xid = ");
6383 if self.xid != None:
6384 q.text("%#x" % self.xid)
6385 else:
6386 q.text('None')
6387 q.text(","); q.breakable()
6388 q.text("reason = ");
6389 q.text("%#x" % self.reason)
6390 q.text(","); q.breakable()
6391 q.text("desc = ");
6392 q.pp(self.desc)
6393 q.breakable()
6394 q.text('}')
6395
6396class queue_get_config_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006397 version = 2
6398 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07006399
6400 def __init__(self, xid=None, port=None, queues=None):
6401 self.xid = xid
6402 if port != None:
6403 self.port = port
6404 else:
6405 self.port = 0
6406 if queues != None:
6407 self.queues = queues
6408 else:
6409 self.queues = []
6410
6411 def pack(self):
6412 packed = []
6413 packed.append(struct.pack("!B", self.version))
6414 packed.append(struct.pack("!B", self.type))
6415 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6416 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07006417 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006418 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006419 packed.append(util.pack_list(self.queues))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006420 length = sum([len(x) for x in packed])
6421 packed[2] = struct.pack("!H", length)
6422 return ''.join(packed)
6423
6424 @staticmethod
6425 def unpack(buf):
6426 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6427 obj = queue_get_config_reply()
6428 if type(buf) == loxi.generic_util.OFReader:
6429 reader = buf
6430 else:
6431 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006432 _version = reader.read("!B")[0]
6433 assert(_version == 2)
6434 _type = reader.read("!B")[0]
6435 assert(_type == 23)
6436 _length = reader.read("!H")[0]
6437 obj.xid = reader.read("!L")[0]
6438 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006439 reader.skip(4)
6440 obj.queues = common.unpack_list_packet_queue(reader)
6441 return obj
6442
6443 def __eq__(self, other):
6444 if type(self) != type(other): return False
6445 if self.version != other.version: return False
6446 if self.type != other.type: return False
6447 if self.xid != other.xid: return False
6448 if self.port != other.port: return False
6449 if self.queues != other.queues: return False
6450 return True
6451
6452 def __ne__(self, other):
6453 return not self.__eq__(other)
6454
6455 def __str__(self):
6456 return self.show()
6457
6458 def show(self):
6459 import loxi.pp
6460 return loxi.pp.pp(self)
6461
6462 def pretty_print(self, q):
6463 q.text("queue_get_config_reply {")
6464 with q.group():
6465 with q.indent(2):
6466 q.breakable()
6467 q.text("xid = ");
6468 if self.xid != None:
6469 q.text("%#x" % self.xid)
6470 else:
6471 q.text('None')
6472 q.text(","); q.breakable()
6473 q.text("port = ");
6474 q.text(util.pretty_port(self.port))
6475 q.text(","); q.breakable()
6476 q.text("queues = ");
6477 q.pp(self.queues)
6478 q.breakable()
6479 q.text('}')
6480
6481class queue_get_config_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006482 version = 2
6483 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -07006484
6485 def __init__(self, xid=None, port=None):
6486 self.xid = xid
6487 if port != None:
6488 self.port = port
6489 else:
6490 self.port = 0
6491
6492 def pack(self):
6493 packed = []
6494 packed.append(struct.pack("!B", self.version))
6495 packed.append(struct.pack("!B", self.type))
6496 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6497 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07006498 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006499 packed.append('\x00' * 4)
6500 length = sum([len(x) for x in packed])
6501 packed[2] = struct.pack("!H", length)
6502 return ''.join(packed)
6503
6504 @staticmethod
6505 def unpack(buf):
6506 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6507 obj = queue_get_config_request()
6508 if type(buf) == loxi.generic_util.OFReader:
6509 reader = buf
6510 else:
6511 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006512 _version = reader.read("!B")[0]
6513 assert(_version == 2)
6514 _type = reader.read("!B")[0]
6515 assert(_type == 22)
6516 _length = reader.read("!H")[0]
6517 obj.xid = reader.read("!L")[0]
6518 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006519 reader.skip(4)
6520 return obj
6521
6522 def __eq__(self, other):
6523 if type(self) != type(other): return False
6524 if self.version != other.version: return False
6525 if self.type != other.type: return False
6526 if self.xid != other.xid: return False
6527 if self.port != other.port: return False
6528 return True
6529
6530 def __ne__(self, other):
6531 return not self.__eq__(other)
6532
6533 def __str__(self):
6534 return self.show()
6535
6536 def show(self):
6537 import loxi.pp
6538 return loxi.pp.pp(self)
6539
6540 def pretty_print(self, q):
6541 q.text("queue_get_config_request {")
6542 with q.group():
6543 with q.indent(2):
6544 q.breakable()
6545 q.text("xid = ");
6546 if self.xid != None:
6547 q.text("%#x" % self.xid)
6548 else:
6549 q.text('None')
6550 q.text(","); q.breakable()
6551 q.text("port = ");
6552 q.text(util.pretty_port(self.port))
6553 q.breakable()
6554 q.text('}')
6555
Rich Lane6f4978c2013-10-20 21:33:52 -07006556class queue_op_failed_error_msg(Message):
6557 version = 2
6558 type = 1
6559 err_type = 9
6560
6561 def __init__(self, xid=None, code=None, data=None):
6562 self.xid = xid
6563 if code != None:
6564 self.code = code
6565 else:
6566 self.code = 0
6567 if data != None:
6568 self.data = data
6569 else:
6570 self.data = ''
6571
6572 def pack(self):
6573 packed = []
6574 packed.append(struct.pack("!B", self.version))
6575 packed.append(struct.pack("!B", self.type))
6576 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6577 packed.append(struct.pack("!L", self.xid))
6578 packed.append(struct.pack("!H", self.err_type))
6579 packed.append(struct.pack("!H", self.code))
6580 packed.append(self.data)
6581 length = sum([len(x) for x in packed])
6582 packed[2] = struct.pack("!H", length)
6583 return ''.join(packed)
6584
6585 @staticmethod
6586 def unpack(buf):
6587 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6588 obj = queue_op_failed_error_msg()
6589 if type(buf) == loxi.generic_util.OFReader:
6590 reader = buf
6591 else:
6592 reader = loxi.generic_util.OFReader(buf)
6593 _version = reader.read("!B")[0]
6594 assert(_version == 2)
6595 _type = reader.read("!B")[0]
6596 assert(_type == 1)
6597 _length = reader.read("!H")[0]
6598 obj.xid = reader.read("!L")[0]
6599 _err_type = reader.read("!H")[0]
6600 assert(_err_type == 9)
6601 obj.code = reader.read("!H")[0]
6602 obj.data = str(reader.read_all())
6603 return obj
6604
6605 def __eq__(self, other):
6606 if type(self) != type(other): return False
6607 if self.version != other.version: return False
6608 if self.type != other.type: return False
6609 if self.xid != other.xid: return False
6610 if self.code != other.code: return False
6611 if self.data != other.data: return False
6612 return True
6613
6614 def __ne__(self, other):
6615 return not self.__eq__(other)
6616
6617 def __str__(self):
6618 return self.show()
6619
6620 def show(self):
6621 import loxi.pp
6622 return loxi.pp.pp(self)
6623
6624 def pretty_print(self, q):
6625 q.text("queue_op_failed_error_msg {")
6626 with q.group():
6627 with q.indent(2):
6628 q.breakable()
6629 q.text("xid = ");
6630 if self.xid != None:
6631 q.text("%#x" % self.xid)
6632 else:
6633 q.text('None')
6634 q.text(","); q.breakable()
6635 q.text("code = ");
6636 q.text("%#x" % self.code)
6637 q.text(","); q.breakable()
6638 q.text("data = ");
6639 q.pp(self.data)
6640 q.breakable()
6641 q.text('}')
6642
Rich Lanec2ee4b82013-04-24 17:12:38 -07006643class queue_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006644 version = 2
6645 type = 19
6646 stats_type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07006647
6648 def __init__(self, xid=None, flags=None, entries=None):
6649 self.xid = xid
6650 if flags != None:
6651 self.flags = flags
6652 else:
6653 self.flags = 0
6654 if entries != None:
6655 self.entries = entries
6656 else:
6657 self.entries = []
6658
6659 def pack(self):
6660 packed = []
6661 packed.append(struct.pack("!B", self.version))
6662 packed.append(struct.pack("!B", self.type))
6663 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6664 packed.append(struct.pack("!L", self.xid))
6665 packed.append(struct.pack("!H", self.stats_type))
6666 packed.append(struct.pack("!H", self.flags))
6667 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006668 packed.append(util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006669 length = sum([len(x) for x in packed])
6670 packed[2] = struct.pack("!H", length)
6671 return ''.join(packed)
6672
6673 @staticmethod
6674 def unpack(buf):
6675 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6676 obj = queue_stats_reply()
6677 if type(buf) == loxi.generic_util.OFReader:
6678 reader = buf
6679 else:
6680 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006681 _version = reader.read("!B")[0]
6682 assert(_version == 2)
6683 _type = reader.read("!B")[0]
6684 assert(_type == 19)
6685 _length = reader.read("!H")[0]
6686 obj.xid = reader.read("!L")[0]
6687 _stats_type = reader.read("!H")[0]
6688 assert(_stats_type == 5)
6689 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006690 reader.skip(4)
6691 obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack)
6692 return obj
6693
6694 def __eq__(self, other):
6695 if type(self) != type(other): return False
6696 if self.version != other.version: return False
6697 if self.type != other.type: return False
6698 if self.xid != other.xid: return False
6699 if self.flags != other.flags: return False
6700 if self.entries != other.entries: return False
6701 return True
6702
6703 def __ne__(self, other):
6704 return not self.__eq__(other)
6705
6706 def __str__(self):
6707 return self.show()
6708
6709 def show(self):
6710 import loxi.pp
6711 return loxi.pp.pp(self)
6712
6713 def pretty_print(self, q):
6714 q.text("queue_stats_reply {")
6715 with q.group():
6716 with q.indent(2):
6717 q.breakable()
6718 q.text("xid = ");
6719 if self.xid != None:
6720 q.text("%#x" % self.xid)
6721 else:
6722 q.text('None')
6723 q.text(","); q.breakable()
6724 q.text("flags = ");
6725 q.text("%#x" % self.flags)
6726 q.text(","); q.breakable()
6727 q.text("entries = ");
6728 q.pp(self.entries)
6729 q.breakable()
6730 q.text('}')
6731
6732class queue_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006733 version = 2
6734 type = 18
6735 stats_type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07006736
6737 def __init__(self, xid=None, flags=None, port_no=None, queue_id=None):
6738 self.xid = xid
6739 if flags != None:
6740 self.flags = flags
6741 else:
6742 self.flags = 0
6743 if port_no != None:
6744 self.port_no = port_no
6745 else:
6746 self.port_no = 0
6747 if queue_id != None:
6748 self.queue_id = queue_id
6749 else:
6750 self.queue_id = 0
6751
6752 def pack(self):
6753 packed = []
6754 packed.append(struct.pack("!B", self.version))
6755 packed.append(struct.pack("!B", self.type))
6756 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6757 packed.append(struct.pack("!L", self.xid))
6758 packed.append(struct.pack("!H", self.stats_type))
6759 packed.append(struct.pack("!H", self.flags))
6760 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006761 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006762 packed.append(struct.pack("!L", self.queue_id))
6763 length = sum([len(x) for x in packed])
6764 packed[2] = struct.pack("!H", length)
6765 return ''.join(packed)
6766
6767 @staticmethod
6768 def unpack(buf):
6769 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6770 obj = queue_stats_request()
6771 if type(buf) == loxi.generic_util.OFReader:
6772 reader = buf
6773 else:
6774 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006775 _version = reader.read("!B")[0]
6776 assert(_version == 2)
6777 _type = reader.read("!B")[0]
6778 assert(_type == 18)
6779 _length = reader.read("!H")[0]
6780 obj.xid = reader.read("!L")[0]
6781 _stats_type = reader.read("!H")[0]
6782 assert(_stats_type == 5)
6783 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006784 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07006785 obj.port_no = util.unpack_port_no(reader)
6786 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006787 return obj
6788
6789 def __eq__(self, other):
6790 if type(self) != type(other): return False
6791 if self.version != other.version: return False
6792 if self.type != other.type: return False
6793 if self.xid != other.xid: return False
6794 if self.flags != other.flags: return False
6795 if self.port_no != other.port_no: return False
6796 if self.queue_id != other.queue_id: return False
6797 return True
6798
6799 def __ne__(self, other):
6800 return not self.__eq__(other)
6801
6802 def __str__(self):
6803 return self.show()
6804
6805 def show(self):
6806 import loxi.pp
6807 return loxi.pp.pp(self)
6808
6809 def pretty_print(self, q):
6810 q.text("queue_stats_request {")
6811 with q.group():
6812 with q.indent(2):
6813 q.breakable()
6814 q.text("xid = ");
6815 if self.xid != None:
6816 q.text("%#x" % self.xid)
6817 else:
6818 q.text('None')
6819 q.text(","); q.breakable()
6820 q.text("flags = ");
6821 q.text("%#x" % self.flags)
6822 q.text(","); q.breakable()
6823 q.text("port_no = ");
6824 q.text(util.pretty_port(self.port_no))
6825 q.text(","); q.breakable()
6826 q.text("queue_id = ");
6827 q.text("%#x" % self.queue_id)
6828 q.breakable()
6829 q.text('}')
6830
6831class set_config(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006832 version = 2
6833 type = 9
Rich Lanec2ee4b82013-04-24 17:12:38 -07006834
6835 def __init__(self, xid=None, flags=None, miss_send_len=None):
6836 self.xid = xid
6837 if flags != None:
6838 self.flags = flags
6839 else:
6840 self.flags = 0
6841 if miss_send_len != None:
6842 self.miss_send_len = miss_send_len
6843 else:
6844 self.miss_send_len = 0
6845
6846 def pack(self):
6847 packed = []
6848 packed.append(struct.pack("!B", self.version))
6849 packed.append(struct.pack("!B", self.type))
6850 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6851 packed.append(struct.pack("!L", self.xid))
6852 packed.append(struct.pack("!H", self.flags))
6853 packed.append(struct.pack("!H", self.miss_send_len))
6854 length = sum([len(x) for x in packed])
6855 packed[2] = struct.pack("!H", length)
6856 return ''.join(packed)
6857
6858 @staticmethod
6859 def unpack(buf):
6860 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6861 obj = set_config()
6862 if type(buf) == loxi.generic_util.OFReader:
6863 reader = buf
6864 else:
6865 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006866 _version = reader.read("!B")[0]
6867 assert(_version == 2)
6868 _type = reader.read("!B")[0]
6869 assert(_type == 9)
6870 _length = reader.read("!H")[0]
6871 obj.xid = reader.read("!L")[0]
6872 obj.flags = reader.read("!H")[0]
6873 obj.miss_send_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006874 return obj
6875
6876 def __eq__(self, other):
6877 if type(self) != type(other): return False
6878 if self.version != other.version: return False
6879 if self.type != other.type: return False
6880 if self.xid != other.xid: return False
6881 if self.flags != other.flags: return False
6882 if self.miss_send_len != other.miss_send_len: 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("set_config {")
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("flags = ");
6907 q.text("%#x" % self.flags)
6908 q.text(","); q.breakable()
6909 q.text("miss_send_len = ");
6910 q.text("%#x" % self.miss_send_len)
6911 q.breakable()
6912 q.text('}')
6913
Rich Lane6f4978c2013-10-20 21:33:52 -07006914class switch_config_failed_error_msg(Message):
6915 version = 2
6916 type = 1
6917 err_type = 10
6918
6919 def __init__(self, xid=None, code=None, data=None):
6920 self.xid = xid
6921 if code != None:
6922 self.code = code
6923 else:
6924 self.code = 0
6925 if data != None:
6926 self.data = data
6927 else:
6928 self.data = ''
6929
6930 def pack(self):
6931 packed = []
6932 packed.append(struct.pack("!B", self.version))
6933 packed.append(struct.pack("!B", self.type))
6934 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6935 packed.append(struct.pack("!L", self.xid))
6936 packed.append(struct.pack("!H", self.err_type))
6937 packed.append(struct.pack("!H", self.code))
6938 packed.append(self.data)
6939 length = sum([len(x) for x in packed])
6940 packed[2] = struct.pack("!H", length)
6941 return ''.join(packed)
6942
6943 @staticmethod
6944 def unpack(buf):
6945 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6946 obj = switch_config_failed_error_msg()
6947 if type(buf) == loxi.generic_util.OFReader:
6948 reader = buf
6949 else:
6950 reader = loxi.generic_util.OFReader(buf)
6951 _version = reader.read("!B")[0]
6952 assert(_version == 2)
6953 _type = reader.read("!B")[0]
6954 assert(_type == 1)
6955 _length = reader.read("!H")[0]
6956 obj.xid = reader.read("!L")[0]
6957 _err_type = reader.read("!H")[0]
6958 assert(_err_type == 10)
6959 obj.code = reader.read("!H")[0]
6960 obj.data = str(reader.read_all())
6961 return obj
6962
6963 def __eq__(self, other):
6964 if type(self) != type(other): return False
6965 if self.version != other.version: return False
6966 if self.type != other.type: return False
6967 if self.xid != other.xid: return False
6968 if self.code != other.code: return False
6969 if self.data != other.data: return False
6970 return True
6971
6972 def __ne__(self, other):
6973 return not self.__eq__(other)
6974
6975 def __str__(self):
6976 return self.show()
6977
6978 def show(self):
6979 import loxi.pp
6980 return loxi.pp.pp(self)
6981
6982 def pretty_print(self, q):
6983 q.text("switch_config_failed_error_msg {")
6984 with q.group():
6985 with q.indent(2):
6986 q.breakable()
6987 q.text("xid = ");
6988 if self.xid != None:
6989 q.text("%#x" % self.xid)
6990 else:
6991 q.text('None')
6992 q.text(","); q.breakable()
6993 q.text("code = ");
6994 q.text("%#x" % self.code)
6995 q.text(","); q.breakable()
6996 q.text("data = ");
6997 q.pp(self.data)
6998 q.breakable()
6999 q.text('}')
7000
Rich Lanec2ee4b82013-04-24 17:12:38 -07007001class table_mod(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07007002 version = 2
7003 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -07007004
7005 def __init__(self, xid=None, table_id=None, config=None):
7006 self.xid = xid
7007 if table_id != None:
7008 self.table_id = table_id
7009 else:
7010 self.table_id = 0
7011 if config != None:
7012 self.config = config
7013 else:
7014 self.config = 0
7015
7016 def pack(self):
7017 packed = []
7018 packed.append(struct.pack("!B", self.version))
7019 packed.append(struct.pack("!B", self.type))
7020 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7021 packed.append(struct.pack("!L", self.xid))
7022 packed.append(struct.pack("!B", self.table_id))
7023 packed.append('\x00' * 3)
7024 packed.append(struct.pack("!L", self.config))
7025 length = sum([len(x) for x in packed])
7026 packed[2] = struct.pack("!H", length)
7027 return ''.join(packed)
7028
7029 @staticmethod
7030 def unpack(buf):
7031 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
7032 obj = table_mod()
7033 if type(buf) == loxi.generic_util.OFReader:
7034 reader = buf
7035 else:
7036 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07007037 _version = reader.read("!B")[0]
7038 assert(_version == 2)
7039 _type = reader.read("!B")[0]
7040 assert(_type == 17)
7041 _length = reader.read("!H")[0]
7042 obj.xid = reader.read("!L")[0]
7043 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007044 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07007045 obj.config = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007046 return obj
7047
7048 def __eq__(self, other):
7049 if type(self) != type(other): return False
7050 if self.version != other.version: return False
7051 if self.type != other.type: return False
7052 if self.xid != other.xid: return False
7053 if self.table_id != other.table_id: return False
7054 if self.config != other.config: return False
7055 return True
7056
7057 def __ne__(self, other):
7058 return not self.__eq__(other)
7059
7060 def __str__(self):
7061 return self.show()
7062
7063 def show(self):
7064 import loxi.pp
7065 return loxi.pp.pp(self)
7066
7067 def pretty_print(self, q):
7068 q.text("table_mod {")
7069 with q.group():
7070 with q.indent(2):
7071 q.breakable()
7072 q.text("xid = ");
7073 if self.xid != None:
7074 q.text("%#x" % self.xid)
7075 else:
7076 q.text('None')
7077 q.text(","); q.breakable()
7078 q.text("table_id = ");
7079 q.text("%#x" % self.table_id)
7080 q.text(","); q.breakable()
7081 q.text("config = ");
7082 q.text("%#x" % self.config)
7083 q.breakable()
7084 q.text('}')
7085
Rich Lane6f4978c2013-10-20 21:33:52 -07007086class table_mod_failed_error_msg(Message):
7087 version = 2
7088 type = 1
7089 err_type = 8
7090
7091 def __init__(self, xid=None, code=None, data=None):
7092 self.xid = xid
7093 if code != None:
7094 self.code = code
7095 else:
7096 self.code = 0
7097 if data != None:
7098 self.data = data
7099 else:
7100 self.data = ''
7101
7102 def pack(self):
7103 packed = []
7104 packed.append(struct.pack("!B", self.version))
7105 packed.append(struct.pack("!B", self.type))
7106 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7107 packed.append(struct.pack("!L", self.xid))
7108 packed.append(struct.pack("!H", self.err_type))
7109 packed.append(struct.pack("!H", self.code))
7110 packed.append(self.data)
7111 length = sum([len(x) for x in packed])
7112 packed[2] = struct.pack("!H", length)
7113 return ''.join(packed)
7114
7115 @staticmethod
7116 def unpack(buf):
7117 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
7118 obj = table_mod_failed_error_msg()
7119 if type(buf) == loxi.generic_util.OFReader:
7120 reader = buf
7121 else:
7122 reader = loxi.generic_util.OFReader(buf)
7123 _version = reader.read("!B")[0]
7124 assert(_version == 2)
7125 _type = reader.read("!B")[0]
7126 assert(_type == 1)
7127 _length = reader.read("!H")[0]
7128 obj.xid = reader.read("!L")[0]
7129 _err_type = reader.read("!H")[0]
7130 assert(_err_type == 8)
7131 obj.code = reader.read("!H")[0]
7132 obj.data = str(reader.read_all())
7133 return obj
7134
7135 def __eq__(self, other):
7136 if type(self) != type(other): return False
7137 if self.version != other.version: return False
7138 if self.type != other.type: return False
7139 if self.xid != other.xid: return False
7140 if self.code != other.code: return False
7141 if self.data != other.data: return False
7142 return True
7143
7144 def __ne__(self, other):
7145 return not self.__eq__(other)
7146
7147 def __str__(self):
7148 return self.show()
7149
7150 def show(self):
7151 import loxi.pp
7152 return loxi.pp.pp(self)
7153
7154 def pretty_print(self, q):
7155 q.text("table_mod_failed_error_msg {")
7156 with q.group():
7157 with q.indent(2):
7158 q.breakable()
7159 q.text("xid = ");
7160 if self.xid != None:
7161 q.text("%#x" % self.xid)
7162 else:
7163 q.text('None')
7164 q.text(","); q.breakable()
7165 q.text("code = ");
7166 q.text("%#x" % self.code)
7167 q.text(","); q.breakable()
7168 q.text("data = ");
7169 q.pp(self.data)
7170 q.breakable()
7171 q.text('}')
7172
Rich Lanec2ee4b82013-04-24 17:12:38 -07007173class table_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07007174 version = 2
7175 type = 19
7176 stats_type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07007177
7178 def __init__(self, xid=None, flags=None, entries=None):
7179 self.xid = xid
7180 if flags != None:
7181 self.flags = flags
7182 else:
7183 self.flags = 0
7184 if entries != None:
7185 self.entries = entries
7186 else:
7187 self.entries = []
7188
7189 def pack(self):
7190 packed = []
7191 packed.append(struct.pack("!B", self.version))
7192 packed.append(struct.pack("!B", self.type))
7193 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7194 packed.append(struct.pack("!L", self.xid))
7195 packed.append(struct.pack("!H", self.stats_type))
7196 packed.append(struct.pack("!H", self.flags))
7197 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007198 packed.append(util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007199 length = sum([len(x) for x in packed])
7200 packed[2] = struct.pack("!H", length)
7201 return ''.join(packed)
7202
7203 @staticmethod
7204 def unpack(buf):
7205 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
7206 obj = table_stats_reply()
7207 if type(buf) == loxi.generic_util.OFReader:
7208 reader = buf
7209 else:
7210 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07007211 _version = reader.read("!B")[0]
7212 assert(_version == 2)
7213 _type = reader.read("!B")[0]
7214 assert(_type == 19)
7215 _length = reader.read("!H")[0]
7216 obj.xid = reader.read("!L")[0]
7217 _stats_type = reader.read("!H")[0]
7218 assert(_stats_type == 3)
7219 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007220 reader.skip(4)
7221 obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack)
7222 return obj
7223
7224 def __eq__(self, other):
7225 if type(self) != type(other): return False
7226 if self.version != other.version: return False
7227 if self.type != other.type: return False
7228 if self.xid != other.xid: return False
7229 if self.flags != other.flags: return False
7230 if self.entries != other.entries: return False
7231 return True
7232
7233 def __ne__(self, other):
7234 return not self.__eq__(other)
7235
7236 def __str__(self):
7237 return self.show()
7238
7239 def show(self):
7240 import loxi.pp
7241 return loxi.pp.pp(self)
7242
7243 def pretty_print(self, q):
7244 q.text("table_stats_reply {")
7245 with q.group():
7246 with q.indent(2):
7247 q.breakable()
7248 q.text("xid = ");
7249 if self.xid != None:
7250 q.text("%#x" % self.xid)
7251 else:
7252 q.text('None')
7253 q.text(","); q.breakable()
7254 q.text("flags = ");
7255 q.text("%#x" % self.flags)
7256 q.text(","); q.breakable()
7257 q.text("entries = ");
7258 q.pp(self.entries)
7259 q.breakable()
7260 q.text('}')
7261
7262class table_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07007263 version = 2
7264 type = 18
7265 stats_type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07007266
7267 def __init__(self, xid=None, flags=None):
7268 self.xid = xid
7269 if flags != None:
7270 self.flags = flags
7271 else:
7272 self.flags = 0
7273
7274 def pack(self):
7275 packed = []
7276 packed.append(struct.pack("!B", self.version))
7277 packed.append(struct.pack("!B", self.type))
7278 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7279 packed.append(struct.pack("!L", self.xid))
7280 packed.append(struct.pack("!H", self.stats_type))
7281 packed.append(struct.pack("!H", self.flags))
7282 packed.append('\x00' * 4)
7283 length = sum([len(x) for x in packed])
7284 packed[2] = struct.pack("!H", length)
7285 return ''.join(packed)
7286
7287 @staticmethod
7288 def unpack(buf):
7289 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
7290 obj = table_stats_request()
7291 if type(buf) == loxi.generic_util.OFReader:
7292 reader = buf
7293 else:
7294 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07007295 _version = reader.read("!B")[0]
7296 assert(_version == 2)
7297 _type = reader.read("!B")[0]
7298 assert(_type == 18)
7299 _length = reader.read("!H")[0]
7300 obj.xid = reader.read("!L")[0]
7301 _stats_type = reader.read("!H")[0]
7302 assert(_stats_type == 3)
7303 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007304 reader.skip(4)
7305 return obj
7306
7307 def __eq__(self, other):
7308 if type(self) != type(other): return False
7309 if self.version != other.version: return False
7310 if self.type != other.type: return False
7311 if self.xid != other.xid: return False
7312 if self.flags != other.flags: return False
7313 return True
7314
7315 def __ne__(self, other):
7316 return not self.__eq__(other)
7317
7318 def __str__(self):
7319 return self.show()
7320
7321 def show(self):
7322 import loxi.pp
7323 return loxi.pp.pp(self)
7324
7325 def pretty_print(self, q):
7326 q.text("table_stats_request {")
7327 with q.group():
7328 with q.indent(2):
7329 q.breakable()
7330 q.text("xid = ");
7331 if self.xid != None:
7332 q.text("%#x" % self.xid)
7333 else:
7334 q.text('None')
7335 q.text(","); q.breakable()
7336 q.text("flags = ");
7337 q.text("%#x" % self.flags)
7338 q.breakable()
7339 q.text('}')
7340
7341
7342def parse_header(buf):
7343 if len(buf) < 8:
7344 raise loxi.ProtocolError("too short to be an OpenFlow message")
7345 return struct.unpack_from("!BBHL", buf)
7346
7347def parse_message(buf):
7348 msg_ver, msg_type, msg_len, msg_xid = parse_header(buf)
Rich Lanefe600f52013-07-09 13:22:32 -07007349 if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO:
7350 raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (const.OFP_VERSION, msg_ver))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007351 if len(buf) != msg_len:
7352 raise loxi.ProtocolError("incorrect message size")
7353 if msg_type in parsers:
7354 return parsers[msg_type](buf)
7355 else:
7356 raise loxi.ProtocolError("unexpected message type")
7357
Rich Lane6f4978c2013-10-20 21:33:52 -07007358def parse_error(buf):
7359 if len(buf) < 8 + 2:
7360 raise loxi.ProtocolError("message too short")
7361 err_type, = struct.unpack_from("!H", buf, 8)
7362 if err_type in error_msg_parsers:
7363 return error_msg_parsers[err_type](buf)
7364 else:
7365 raise loxi.ProtocolError("unexpected error type %u" % err_type)
7366
Rich Lanec2ee4b82013-04-24 17:12:38 -07007367def parse_flow_mod(buf):
Rich Lanefe600f52013-07-09 13:22:32 -07007368 if len(buf) < 25 + 1:
Rich Lanec2ee4b82013-04-24 17:12:38 -07007369 raise loxi.ProtocolError("message too short")
Rich Lanefe600f52013-07-09 13:22:32 -07007370 # Technically uint16_t for OF 1.0
7371 cmd, = struct.unpack_from("!B", buf, 25)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007372 if cmd in flow_mod_parsers:
7373 return flow_mod_parsers[cmd](buf)
7374 else:
7375 raise loxi.ProtocolError("unexpected flow mod cmd %u" % cmd)
7376
Rich Lane7b0f2012013-11-22 14:15:26 -08007377def parse_group_mod(buf):
7378 if len(buf) < 8 + 2:
7379 raise loxi.ProtocolError("message too short")
7380 cmd, = struct.unpack_from("!H", buf, 8)
7381 if cmd in flow_mod_parsers:
7382 return group_mod_parsers[cmd](buf)
7383 else:
7384 raise loxi.ProtocolError("unexpected group mod cmd %u" % cmd)
7385
Rich Lanec2ee4b82013-04-24 17:12:38 -07007386def parse_stats_reply(buf):
7387 if len(buf) < 8 + 2:
7388 raise loxi.ProtocolError("message too short")
7389 stats_type, = struct.unpack_from("!H", buf, 8)
7390 if stats_type in stats_reply_parsers:
7391 return stats_reply_parsers[stats_type](buf)
7392 else:
7393 raise loxi.ProtocolError("unexpected stats type %u" % stats_type)
7394
7395def parse_stats_request(buf):
7396 if len(buf) < 8 + 2:
7397 raise loxi.ProtocolError("message too short")
7398 stats_type, = struct.unpack_from("!H", buf, 8)
7399 if stats_type in stats_request_parsers:
7400 return stats_request_parsers[stats_type](buf)
7401 else:
7402 raise loxi.ProtocolError("unexpected stats type %u" % stats_type)
7403
Rich Lane7b0f2012013-11-22 14:15:26 -08007404def parse_experimenter_stats_request(buf):
7405 if len(buf) < 24:
7406 raise loxi.ProtocolError("experimenter stats request message too short")
7407
7408 experimenter, exp_type = struct.unpack_from("!LL", buf, 16)
7409
7410 if experimenter in experimenter_stats_request_parsers and \
7411 exp_type in experimenter_stats_request_parsers[experimenter]:
7412 return experimenter_stats_request_parsers[experimenter][exp_type](buf)
7413 else:
7414 raise loxi.ProtocolError("unexpected stats request experimenter %#x exp_type %#x" % (experimenter, exp_type))
7415
7416def parse_experimenter_stats_reply(buf):
7417 if len(buf) < 24:
7418 raise loxi.ProtocolError("experimenter stats reply message too short")
7419
7420 experimenter, exp_type = struct.unpack_from("!LL", buf, 16)
7421
7422 if experimenter in experimenter_stats_reply_parsers and \
7423 exp_type in experimenter_stats_reply_parsers[experimenter]:
7424 return experimenter_stats_reply_parsers[experimenter][exp_type](buf)
7425 else:
7426 raise loxi.ProtocolError("unexpected stats reply experimenter %#x exp_type %#x" % (experimenter, exp_type))
7427
Rich Lanec2ee4b82013-04-24 17:12:38 -07007428def parse_experimenter(buf):
7429 if len(buf) < 16:
7430 raise loxi.ProtocolError("experimenter message too short")
7431
7432 experimenter, = struct.unpack_from("!L", buf, 8)
7433 if experimenter == 0x005c16c7: # Big Switch Networks
7434 subtype, = struct.unpack_from("!L", buf, 12)
7435 elif experimenter == 0x00002320: # Nicira
7436 subtype, = struct.unpack_from("!L", buf, 12)
7437 else:
7438 raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter)
7439
7440 if subtype in experimenter_parsers[experimenter]:
7441 return experimenter_parsers[experimenter][subtype](buf)
7442 else:
7443 raise loxi.ProtocolError("unexpected experimenter %#x subtype %#x" % (experimenter, subtype))
7444
7445parsers = {
Rich Lanec2ee4b82013-04-24 17:12:38 -07007446 const.OFPT_HELLO : hello.unpack,
Rich Lane6f4978c2013-10-20 21:33:52 -07007447 const.OFPT_ERROR : parse_error,
Dan Talaycof6202252013-07-02 01:00:29 -07007448 const.OFPT_ECHO_REQUEST : echo_request.unpack,
7449 const.OFPT_ECHO_REPLY : echo_reply.unpack,
7450 const.OFPT_EXPERIMENTER : parse_experimenter,
7451 const.OFPT_FEATURES_REQUEST : features_request.unpack,
7452 const.OFPT_FEATURES_REPLY : features_reply.unpack,
7453 const.OFPT_GET_CONFIG_REQUEST : get_config_request.unpack,
7454 const.OFPT_GET_CONFIG_REPLY : get_config_reply.unpack,
Rich Lanec2ee4b82013-04-24 17:12:38 -07007455 const.OFPT_SET_CONFIG : set_config.unpack,
Dan Talaycof6202252013-07-02 01:00:29 -07007456 const.OFPT_PACKET_IN : packet_in.unpack,
7457 const.OFPT_FLOW_REMOVED : flow_removed.unpack,
7458 const.OFPT_PORT_STATUS : port_status.unpack,
7459 const.OFPT_PACKET_OUT : packet_out.unpack,
7460 const.OFPT_FLOW_MOD : parse_flow_mod,
Rich Lane7b0f2012013-11-22 14:15:26 -08007461 const.OFPT_GROUP_MOD : parse_group_mod,
Dan Talaycof6202252013-07-02 01:00:29 -07007462 const.OFPT_PORT_MOD : port_mod.unpack,
Rich Lanec2ee4b82013-04-24 17:12:38 -07007463 const.OFPT_TABLE_MOD : table_mod.unpack,
Dan Talaycof6202252013-07-02 01:00:29 -07007464 const.OFPT_STATS_REQUEST : parse_stats_request,
7465 const.OFPT_STATS_REPLY : parse_stats_reply,
7466 const.OFPT_BARRIER_REQUEST : barrier_request.unpack,
7467 const.OFPT_BARRIER_REPLY : barrier_reply.unpack,
7468 const.OFPT_QUEUE_GET_CONFIG_REQUEST : queue_get_config_request.unpack,
7469 const.OFPT_QUEUE_GET_CONFIG_REPLY : queue_get_config_reply.unpack,
Rich Lanec2ee4b82013-04-24 17:12:38 -07007470}
7471
Rich Lane6f4978c2013-10-20 21:33:52 -07007472error_msg_parsers = {
7473 const.OFPET_HELLO_FAILED : hello_failed_error_msg.unpack,
7474 const.OFPET_BAD_REQUEST : bad_request_error_msg.unpack,
7475 const.OFPET_BAD_ACTION : bad_action_error_msg.unpack,
7476 const.OFPET_FLOW_MOD_FAILED : flow_mod_failed_error_msg.unpack,
7477 const.OFPET_PORT_MOD_FAILED : port_mod_failed_error_msg.unpack,
7478 const.OFPET_QUEUE_OP_FAILED : queue_op_failed_error_msg.unpack,
7479 const.OFPET_BAD_INSTRUCTION : bad_instruction_error_msg.unpack,
7480 const.OFPET_BAD_MATCH : bad_match_error_msg.unpack,
7481 const.OFPET_GROUP_MOD_FAILED : group_mod_failed_error_msg.unpack,
7482 const.OFPET_TABLE_MOD_FAILED : table_mod_failed_error_msg.unpack,
7483 const.OFPET_SWITCH_CONFIG_FAILED : switch_config_failed_error_msg.unpack,
7484}
7485
Rich Lanec2ee4b82013-04-24 17:12:38 -07007486flow_mod_parsers = {
7487 const.OFPFC_ADD : flow_add.unpack,
7488 const.OFPFC_MODIFY : flow_modify.unpack,
7489 const.OFPFC_MODIFY_STRICT : flow_modify_strict.unpack,
7490 const.OFPFC_DELETE : flow_delete.unpack,
7491 const.OFPFC_DELETE_STRICT : flow_delete_strict.unpack,
7492}
7493
Rich Lane7b0f2012013-11-22 14:15:26 -08007494group_mod_parsers = {
7495 const.OFPGC_ADD : group_add.unpack,
7496 const.OFPGC_MODIFY : group_modify.unpack,
7497 const.OFPGC_DELETE : group_delete.unpack,
7498}
7499
Rich Lanec2ee4b82013-04-24 17:12:38 -07007500stats_reply_parsers = {
7501 const.OFPST_DESC : desc_stats_reply.unpack,
7502 const.OFPST_FLOW : flow_stats_reply.unpack,
7503 const.OFPST_AGGREGATE : aggregate_stats_reply.unpack,
7504 const.OFPST_TABLE : table_stats_reply.unpack,
7505 const.OFPST_PORT : port_stats_reply.unpack,
7506 const.OFPST_QUEUE : queue_stats_reply.unpack,
Rich Lane7b0f2012013-11-22 14:15:26 -08007507 const.OFPST_EXPERIMENTER : parse_experimenter_stats_reply,
Rich Lane90c961c2013-05-14 09:26:50 -07007508 const.OFPST_GROUP : group_stats_reply.unpack,
7509 const.OFPST_GROUP_DESC : group_desc_stats_reply.unpack,
Rich Lanec2ee4b82013-04-24 17:12:38 -07007510}
7511
7512stats_request_parsers = {
7513 const.OFPST_DESC : desc_stats_request.unpack,
7514 const.OFPST_FLOW : flow_stats_request.unpack,
7515 const.OFPST_AGGREGATE : aggregate_stats_request.unpack,
7516 const.OFPST_TABLE : table_stats_request.unpack,
7517 const.OFPST_PORT : port_stats_request.unpack,
7518 const.OFPST_QUEUE : queue_stats_request.unpack,
Rich Lane7b0f2012013-11-22 14:15:26 -08007519 const.OFPST_EXPERIMENTER : parse_experimenter_stats_request,
Rich Lane90c961c2013-05-14 09:26:50 -07007520 const.OFPST_GROUP : group_stats_request.unpack,
7521 const.OFPST_GROUP_DESC : group_desc_stats_request.unpack,
Rich Lanec2ee4b82013-04-24 17:12:38 -07007522}
7523
7524experimenter_parsers = {
Dan Talaycof6202252013-07-02 01:00:29 -07007525 6035143 : {
7526 22: bsn_bw_clear_data_reply.unpack,
7527 21: bsn_bw_clear_data_request.unpack,
7528 20: bsn_bw_enable_get_reply.unpack,
7529 19: bsn_bw_enable_get_request.unpack,
7530 23: bsn_bw_enable_set_reply.unpack,
7531 18: bsn_bw_enable_set_request.unpack,
7532 10: bsn_get_interfaces_reply.unpack,
7533 9: bsn_get_interfaces_request.unpack,
7534 5: bsn_get_mirroring_reply.unpack,
7535 4: bsn_get_mirroring_request.unpack,
Rich Lane6f4978c2013-10-20 21:33:52 -07007536 34: bsn_pdu_rx_reply.unpack,
7537 33: bsn_pdu_rx_request.unpack,
7538 35: bsn_pdu_rx_timeout.unpack,
7539 32: bsn_pdu_tx_reply.unpack,
7540 31: bsn_pdu_tx_request.unpack,
Dan Talaycof6202252013-07-02 01:00:29 -07007541 3: bsn_set_mirroring.unpack,
7542 25: bsn_set_pktin_suppression_reply.unpack,
7543 11: bsn_set_pktin_suppression_request.unpack,
7544 16: bsn_virtual_port_create_reply.unpack,
7545 15: bsn_virtual_port_create_request.unpack,
7546 26: bsn_virtual_port_remove_reply.unpack,
7547 17: bsn_virtual_port_remove_request.unpack,
7548 },
Rich Lanec2ee4b82013-04-24 17:12:38 -07007549}
Rich Lane7b0f2012013-11-22 14:15:26 -08007550
7551experimenter_stats_request_parsers = {
7552 0x005c16c7: {
7553 },
7554}
7555
7556experimenter_stats_reply_parsers = {
7557 0x005c16c7: {
7558 },
7559}