blob: 6e6649eb04d74ba49759c618ba62c78766c32fc0 [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 Laneb658ddd2013-03-12 10:15:10 -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 util
Rich Lanec2ee4b82013-04-24 17:12:38 -070015import loxi.generic_util
Rich Laneb658ddd2013-03-12 10:15:10 -070016
17class Message(object):
18 version = const.OFP_VERSION
19 type = None # override in subclass
20 xid = None
21
22class aggregate_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -070023 version = 1
24 type = 17
25 stats_type = 2
Rich Laneb658ddd2013-03-12 10:15:10 -070026
Rich Lanec2ee4b82013-04-24 17:12:38 -070027 def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None):
Rich Laneb658ddd2013-03-12 10:15:10 -070028 self.xid = xid
29 if flags != None:
30 self.flags = flags
31 else:
32 self.flags = 0
33 if packet_count != None:
34 self.packet_count = packet_count
35 else:
36 self.packet_count = 0
37 if byte_count != None:
38 self.byte_count = byte_count
39 else:
40 self.byte_count = 0
41 if flow_count != None:
42 self.flow_count = flow_count
43 else:
44 self.flow_count = 0
Rich Laneb658ddd2013-03-12 10:15:10 -070045
46 def pack(self):
47 packed = []
48 packed.append(struct.pack("!B", self.version))
49 packed.append(struct.pack("!B", self.type))
50 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
51 packed.append(struct.pack("!L", self.xid))
52 packed.append(struct.pack("!H", self.stats_type))
53 packed.append(struct.pack("!H", self.flags))
54 packed.append(struct.pack("!Q", self.packet_count))
55 packed.append(struct.pack("!Q", self.byte_count))
56 packed.append(struct.pack("!L", self.flow_count))
Rich Lanec2ee4b82013-04-24 17:12:38 -070057 packed.append('\x00' * 4)
Rich Laneb658ddd2013-03-12 10:15:10 -070058 length = sum([len(x) for x in packed])
59 packed[2] = struct.pack("!H", length)
60 return ''.join(packed)
61
62 @staticmethod
63 def unpack(buf):
64 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
65 obj = aggregate_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -070066 if type(buf) == loxi.generic_util.OFReader:
67 reader = buf
68 else:
69 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -070070 _version = reader.read("!B")[0]
71 assert(_version == 1)
72 _type = reader.read("!B")[0]
73 assert(_type == 17)
74 _length = reader.read("!H")[0]
75 obj.xid = reader.read("!L")[0]
76 _stats_type = reader.read("!H")[0]
77 assert(_stats_type == 2)
78 obj.flags = reader.read("!H")[0]
79 obj.packet_count = reader.read("!Q")[0]
80 obj.byte_count = reader.read("!Q")[0]
81 obj.flow_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -070082 reader.skip(4)
Rich Laneb658ddd2013-03-12 10:15:10 -070083 return obj
84
85 def __eq__(self, other):
86 if type(self) != type(other): return False
87 if self.version != other.version: return False
88 if self.type != other.type: return False
89 if self.xid != other.xid: return False
90 if self.flags != other.flags: return False
91 if self.packet_count != other.packet_count: return False
92 if self.byte_count != other.byte_count: return False
93 if self.flow_count != other.flow_count: return False
Rich Laneb658ddd2013-03-12 10:15:10 -070094 return True
95
96 def __ne__(self, other):
97 return not self.__eq__(other)
98
99 def __str__(self):
100 return self.show()
101
102 def show(self):
103 import loxi.pp
104 return loxi.pp.pp(self)
105
106 def pretty_print(self, q):
107 q.text("aggregate_stats_reply {")
108 with q.group():
109 with q.indent(2):
110 q.breakable()
111 q.text("xid = ");
112 if self.xid != None:
113 q.text("%#x" % self.xid)
114 else:
115 q.text('None')
116 q.text(","); q.breakable()
117 q.text("flags = ");
118 q.text("%#x" % self.flags)
119 q.text(","); q.breakable()
120 q.text("packet_count = ");
121 q.text("%#x" % self.packet_count)
122 q.text(","); q.breakable()
123 q.text("byte_count = ");
124 q.text("%#x" % self.byte_count)
125 q.text(","); q.breakable()
126 q.text("flow_count = ");
127 q.text("%#x" % self.flow_count)
Rich Laneb658ddd2013-03-12 10:15:10 -0700128 q.breakable()
129 q.text('}')
130
131class aggregate_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -0700132 version = 1
133 type = 16
134 stats_type = 2
Rich Laneb658ddd2013-03-12 10:15:10 -0700135
Rich Lanec2ee4b82013-04-24 17:12:38 -0700136 def __init__(self, xid=None, flags=None, match=None, table_id=None, out_port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700137 self.xid = xid
138 if flags != None:
139 self.flags = flags
140 else:
141 self.flags = 0
142 if match != None:
143 self.match = match
144 else:
145 self.match = common.match()
146 if table_id != None:
147 self.table_id = table_id
148 else:
149 self.table_id = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700150 if out_port != None:
151 self.out_port = out_port
152 else:
153 self.out_port = 0
154
155 def pack(self):
156 packed = []
157 packed.append(struct.pack("!B", self.version))
158 packed.append(struct.pack("!B", self.type))
159 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
160 packed.append(struct.pack("!L", self.xid))
161 packed.append(struct.pack("!H", self.stats_type))
162 packed.append(struct.pack("!H", self.flags))
163 packed.append(self.match.pack())
164 packed.append(struct.pack("!B", self.table_id))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700165 packed.append('\x00' * 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700166 packed.append(util.pack_port_no(self.out_port))
Rich Laneb658ddd2013-03-12 10:15:10 -0700167 length = sum([len(x) for x in packed])
168 packed[2] = struct.pack("!H", length)
169 return ''.join(packed)
170
171 @staticmethod
172 def unpack(buf):
173 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
174 obj = aggregate_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700175 if type(buf) == loxi.generic_util.OFReader:
176 reader = buf
177 else:
178 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700179 _version = reader.read("!B")[0]
180 assert(_version == 1)
181 _type = reader.read("!B")[0]
182 assert(_type == 16)
183 _length = reader.read("!H")[0]
184 obj.xid = reader.read("!L")[0]
185 _stats_type = reader.read("!H")[0]
186 assert(_stats_type == 2)
187 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700188 obj.match = common.match.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -0700189 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700190 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700191 obj.out_port = util.unpack_port_no(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -0700192 return obj
193
194 def __eq__(self, other):
195 if type(self) != type(other): return False
196 if self.version != other.version: return False
197 if self.type != other.type: return False
198 if self.xid != other.xid: return False
199 if self.flags != other.flags: return False
200 if self.match != other.match: return False
201 if self.table_id != other.table_id: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700202 if self.out_port != other.out_port: return False
203 return True
204
205 def __ne__(self, other):
206 return not self.__eq__(other)
207
208 def __str__(self):
209 return self.show()
210
211 def show(self):
212 import loxi.pp
213 return loxi.pp.pp(self)
214
215 def pretty_print(self, q):
216 q.text("aggregate_stats_request {")
217 with q.group():
218 with q.indent(2):
219 q.breakable()
220 q.text("xid = ");
221 if self.xid != None:
222 q.text("%#x" % self.xid)
223 else:
224 q.text('None')
225 q.text(","); q.breakable()
226 q.text("flags = ");
227 q.text("%#x" % self.flags)
228 q.text(","); q.breakable()
229 q.text("match = ");
230 q.pp(self.match)
231 q.text(","); q.breakable()
232 q.text("table_id = ");
233 q.text("%#x" % self.table_id)
234 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -0700235 q.text("out_port = ");
236 q.text(util.pretty_port(self.out_port))
237 q.breakable()
238 q.text('}')
239
240class barrier_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -0700241 version = 1
242 type = 19
Rich Laneb658ddd2013-03-12 10:15:10 -0700243
244 def __init__(self, xid=None):
245 self.xid = xid
246
247 def pack(self):
248 packed = []
249 packed.append(struct.pack("!B", self.version))
250 packed.append(struct.pack("!B", self.type))
251 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
252 packed.append(struct.pack("!L", self.xid))
253 length = sum([len(x) for x in packed])
254 packed[2] = struct.pack("!H", length)
255 return ''.join(packed)
256
257 @staticmethod
258 def unpack(buf):
259 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
260 obj = barrier_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700261 if type(buf) == loxi.generic_util.OFReader:
262 reader = buf
263 else:
264 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700265 _version = reader.read("!B")[0]
266 assert(_version == 1)
267 _type = reader.read("!B")[0]
268 assert(_type == 19)
269 _length = reader.read("!H")[0]
270 obj.xid = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700271 return obj
272
273 def __eq__(self, other):
274 if type(self) != type(other): return False
275 if self.version != other.version: return False
276 if self.type != other.type: return False
277 if self.xid != other.xid: return False
278 return True
279
280 def __ne__(self, other):
281 return not self.__eq__(other)
282
283 def __str__(self):
284 return self.show()
285
286 def show(self):
287 import loxi.pp
288 return loxi.pp.pp(self)
289
290 def pretty_print(self, q):
291 q.text("barrier_reply {")
292 with q.group():
293 with q.indent(2):
294 q.breakable()
295 q.text("xid = ");
296 if self.xid != None:
297 q.text("%#x" % self.xid)
298 else:
299 q.text('None')
300 q.breakable()
301 q.text('}')
302
303class barrier_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -0700304 version = 1
305 type = 18
Rich Laneb658ddd2013-03-12 10:15:10 -0700306
307 def __init__(self, xid=None):
308 self.xid = xid
309
310 def pack(self):
311 packed = []
312 packed.append(struct.pack("!B", self.version))
313 packed.append(struct.pack("!B", self.type))
314 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
315 packed.append(struct.pack("!L", self.xid))
316 length = sum([len(x) for x in packed])
317 packed[2] = struct.pack("!H", length)
318 return ''.join(packed)
319
320 @staticmethod
321 def unpack(buf):
322 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
323 obj = barrier_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700324 if type(buf) == loxi.generic_util.OFReader:
325 reader = buf
326 else:
327 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700328 _version = reader.read("!B")[0]
329 assert(_version == 1)
330 _type = reader.read("!B")[0]
331 assert(_type == 18)
332 _length = reader.read("!H")[0]
333 obj.xid = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700334 return obj
335
336 def __eq__(self, other):
337 if type(self) != type(other): return False
338 if self.version != other.version: return False
339 if self.type != other.type: return False
340 if self.xid != other.xid: return False
341 return True
342
343 def __ne__(self, other):
344 return not self.__eq__(other)
345
346 def __str__(self):
347 return self.show()
348
349 def show(self):
350 import loxi.pp
351 return loxi.pp.pp(self)
352
353 def pretty_print(self, q):
354 q.text("barrier_request {")
355 with q.group():
356 with q.indent(2):
357 q.breakable()
358 q.text("xid = ");
359 if self.xid != None:
360 q.text("%#x" % self.xid)
361 else:
362 q.text('None')
363 q.breakable()
364 q.text('}')
365
Dan Talaycof6202252013-07-02 01:00:29 -0700366class bsn_bw_clear_data_reply(Message):
367 version = 1
368 type = 4
369 experimenter = 6035143
370 subtype = 22
371
372 def __init__(self, xid=None, status=None):
373 self.xid = xid
374 if status != None:
375 self.status = status
376 else:
377 self.status = 0
378
379 def pack(self):
380 packed = []
381 packed.append(struct.pack("!B", self.version))
382 packed.append(struct.pack("!B", self.type))
383 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
384 packed.append(struct.pack("!L", self.xid))
385 packed.append(struct.pack("!L", self.experimenter))
386 packed.append(struct.pack("!L", self.subtype))
387 packed.append(struct.pack("!L", self.status))
388 length = sum([len(x) for x in packed])
389 packed[2] = struct.pack("!H", length)
390 return ''.join(packed)
391
392 @staticmethod
393 def unpack(buf):
394 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
395 obj = bsn_bw_clear_data_reply()
396 if type(buf) == loxi.generic_util.OFReader:
397 reader = buf
398 else:
399 reader = loxi.generic_util.OFReader(buf)
400 _version = reader.read("!B")[0]
401 assert(_version == 1)
402 _type = reader.read("!B")[0]
403 assert(_type == 4)
404 _length = reader.read("!H")[0]
405 obj.xid = reader.read("!L")[0]
406 _experimenter = reader.read("!L")[0]
407 assert(_experimenter == 6035143)
408 _subtype = reader.read("!L")[0]
409 assert(_subtype == 22)
410 obj.status = reader.read("!L")[0]
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.status != other.status: return False
419 return True
420
421 def __ne__(self, other):
422 return not self.__eq__(other)
423
424 def __str__(self):
425 return self.show()
426
427 def show(self):
428 import loxi.pp
429 return loxi.pp.pp(self)
430
431 def pretty_print(self, q):
432 q.text("bsn_bw_clear_data_reply {")
433 with q.group():
434 with q.indent(2):
435 q.breakable()
436 q.text("xid = ");
437 if self.xid != None:
438 q.text("%#x" % self.xid)
439 else:
440 q.text('None')
441 q.text(","); q.breakable()
442 q.text("status = ");
443 q.text("%#x" % self.status)
444 q.breakable()
445 q.text('}')
446
447class bsn_bw_clear_data_request(Message):
448 version = 1
449 type = 4
450 experimenter = 6035143
451 subtype = 21
452
453 def __init__(self, xid=None):
454 self.xid = xid
455
456 def pack(self):
457 packed = []
458 packed.append(struct.pack("!B", self.version))
459 packed.append(struct.pack("!B", self.type))
460 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
461 packed.append(struct.pack("!L", self.xid))
462 packed.append(struct.pack("!L", self.experimenter))
463 packed.append(struct.pack("!L", self.subtype))
464 length = sum([len(x) for x in packed])
465 packed[2] = struct.pack("!H", length)
466 return ''.join(packed)
467
468 @staticmethod
469 def unpack(buf):
470 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
471 obj = bsn_bw_clear_data_request()
472 if type(buf) == loxi.generic_util.OFReader:
473 reader = buf
474 else:
475 reader = loxi.generic_util.OFReader(buf)
476 _version = reader.read("!B")[0]
477 assert(_version == 1)
478 _type = reader.read("!B")[0]
479 assert(_type == 4)
480 _length = reader.read("!H")[0]
481 obj.xid = reader.read("!L")[0]
482 _experimenter = reader.read("!L")[0]
483 assert(_experimenter == 6035143)
484 _subtype = reader.read("!L")[0]
485 assert(_subtype == 21)
486 return obj
487
488 def __eq__(self, other):
489 if type(self) != type(other): return False
490 if self.version != other.version: return False
491 if self.type != other.type: return False
492 if self.xid != other.xid: return False
493 return True
494
495 def __ne__(self, other):
496 return not self.__eq__(other)
497
498 def __str__(self):
499 return self.show()
500
501 def show(self):
502 import loxi.pp
503 return loxi.pp.pp(self)
504
505 def pretty_print(self, q):
506 q.text("bsn_bw_clear_data_request {")
507 with q.group():
508 with q.indent(2):
509 q.breakable()
510 q.text("xid = ");
511 if self.xid != None:
512 q.text("%#x" % self.xid)
513 else:
514 q.text('None')
515 q.breakable()
516 q.text('}')
517
518class bsn_bw_enable_get_reply(Message):
519 version = 1
520 type = 4
521 experimenter = 6035143
522 subtype = 20
523
524 def __init__(self, xid=None, enabled=None):
525 self.xid = xid
526 if enabled != None:
527 self.enabled = enabled
528 else:
529 self.enabled = 0
530
531 def pack(self):
532 packed = []
533 packed.append(struct.pack("!B", self.version))
534 packed.append(struct.pack("!B", self.type))
535 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
536 packed.append(struct.pack("!L", self.xid))
537 packed.append(struct.pack("!L", self.experimenter))
538 packed.append(struct.pack("!L", self.subtype))
539 packed.append(struct.pack("!L", self.enabled))
540 length = sum([len(x) for x in packed])
541 packed[2] = struct.pack("!H", length)
542 return ''.join(packed)
543
544 @staticmethod
545 def unpack(buf):
546 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
547 obj = bsn_bw_enable_get_reply()
548 if type(buf) == loxi.generic_util.OFReader:
549 reader = buf
550 else:
551 reader = loxi.generic_util.OFReader(buf)
552 _version = reader.read("!B")[0]
553 assert(_version == 1)
554 _type = reader.read("!B")[0]
555 assert(_type == 4)
556 _length = reader.read("!H")[0]
557 obj.xid = reader.read("!L")[0]
558 _experimenter = reader.read("!L")[0]
559 assert(_experimenter == 6035143)
560 _subtype = reader.read("!L")[0]
561 assert(_subtype == 20)
562 obj.enabled = reader.read("!L")[0]
563 return obj
564
565 def __eq__(self, other):
566 if type(self) != type(other): return False
567 if self.version != other.version: return False
568 if self.type != other.type: return False
569 if self.xid != other.xid: return False
570 if self.enabled != other.enabled: return False
571 return True
572
573 def __ne__(self, other):
574 return not self.__eq__(other)
575
576 def __str__(self):
577 return self.show()
578
579 def show(self):
580 import loxi.pp
581 return loxi.pp.pp(self)
582
583 def pretty_print(self, q):
584 q.text("bsn_bw_enable_get_reply {")
585 with q.group():
586 with q.indent(2):
587 q.breakable()
588 q.text("xid = ");
589 if self.xid != None:
590 q.text("%#x" % self.xid)
591 else:
592 q.text('None')
593 q.text(","); q.breakable()
594 q.text("enabled = ");
595 q.text("%#x" % self.enabled)
596 q.breakable()
597 q.text('}')
598
599class bsn_bw_enable_get_request(Message):
600 version = 1
601 type = 4
602 experimenter = 6035143
603 subtype = 19
604
605 def __init__(self, xid=None):
606 self.xid = xid
607
608 def pack(self):
609 packed = []
610 packed.append(struct.pack("!B", self.version))
611 packed.append(struct.pack("!B", self.type))
612 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
613 packed.append(struct.pack("!L", self.xid))
614 packed.append(struct.pack("!L", self.experimenter))
615 packed.append(struct.pack("!L", self.subtype))
616 length = sum([len(x) for x in packed])
617 packed[2] = struct.pack("!H", length)
618 return ''.join(packed)
619
620 @staticmethod
621 def unpack(buf):
622 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
623 obj = bsn_bw_enable_get_request()
624 if type(buf) == loxi.generic_util.OFReader:
625 reader = buf
626 else:
627 reader = loxi.generic_util.OFReader(buf)
628 _version = reader.read("!B")[0]
629 assert(_version == 1)
630 _type = reader.read("!B")[0]
631 assert(_type == 4)
632 _length = reader.read("!H")[0]
633 obj.xid = reader.read("!L")[0]
634 _experimenter = reader.read("!L")[0]
635 assert(_experimenter == 6035143)
636 _subtype = reader.read("!L")[0]
637 assert(_subtype == 19)
638 return obj
639
640 def __eq__(self, other):
641 if type(self) != type(other): return False
642 if self.version != other.version: return False
643 if self.type != other.type: return False
644 if self.xid != other.xid: return False
645 return True
646
647 def __ne__(self, other):
648 return not self.__eq__(other)
649
650 def __str__(self):
651 return self.show()
652
653 def show(self):
654 import loxi.pp
655 return loxi.pp.pp(self)
656
657 def pretty_print(self, q):
658 q.text("bsn_bw_enable_get_request {")
659 with q.group():
660 with q.indent(2):
661 q.breakable()
662 q.text("xid = ");
663 if self.xid != None:
664 q.text("%#x" % self.xid)
665 else:
666 q.text('None')
667 q.breakable()
668 q.text('}')
669
670class bsn_bw_enable_set_reply(Message):
671 version = 1
672 type = 4
673 experimenter = 6035143
674 subtype = 23
675
676 def __init__(self, xid=None, enable=None, status=None):
677 self.xid = xid
678 if enable != None:
679 self.enable = enable
680 else:
681 self.enable = 0
682 if status != None:
683 self.status = status
684 else:
685 self.status = 0
686
687 def pack(self):
688 packed = []
689 packed.append(struct.pack("!B", self.version))
690 packed.append(struct.pack("!B", self.type))
691 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
692 packed.append(struct.pack("!L", self.xid))
693 packed.append(struct.pack("!L", self.experimenter))
694 packed.append(struct.pack("!L", self.subtype))
695 packed.append(struct.pack("!L", self.enable))
696 packed.append(struct.pack("!L", self.status))
697 length = sum([len(x) for x in packed])
698 packed[2] = struct.pack("!H", length)
699 return ''.join(packed)
700
701 @staticmethod
702 def unpack(buf):
703 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
704 obj = bsn_bw_enable_set_reply()
705 if type(buf) == loxi.generic_util.OFReader:
706 reader = buf
707 else:
708 reader = loxi.generic_util.OFReader(buf)
709 _version = reader.read("!B")[0]
710 assert(_version == 1)
711 _type = reader.read("!B")[0]
712 assert(_type == 4)
713 _length = reader.read("!H")[0]
714 obj.xid = reader.read("!L")[0]
715 _experimenter = reader.read("!L")[0]
716 assert(_experimenter == 6035143)
717 _subtype = reader.read("!L")[0]
718 assert(_subtype == 23)
719 obj.enable = reader.read("!L")[0]
720 obj.status = reader.read("!L")[0]
721 return obj
722
723 def __eq__(self, other):
724 if type(self) != type(other): return False
725 if self.version != other.version: return False
726 if self.type != other.type: return False
727 if self.xid != other.xid: return False
728 if self.enable != other.enable: return False
729 if self.status != other.status: return False
730 return True
731
732 def __ne__(self, other):
733 return not self.__eq__(other)
734
735 def __str__(self):
736 return self.show()
737
738 def show(self):
739 import loxi.pp
740 return loxi.pp.pp(self)
741
742 def pretty_print(self, q):
743 q.text("bsn_bw_enable_set_reply {")
744 with q.group():
745 with q.indent(2):
746 q.breakable()
747 q.text("xid = ");
748 if self.xid != None:
749 q.text("%#x" % self.xid)
750 else:
751 q.text('None')
752 q.text(","); q.breakable()
753 q.text("enable = ");
754 q.text("%#x" % self.enable)
755 q.text(","); q.breakable()
756 q.text("status = ");
757 q.text("%#x" % self.status)
758 q.breakable()
759 q.text('}')
760
761class bsn_bw_enable_set_request(Message):
762 version = 1
763 type = 4
764 experimenter = 6035143
765 subtype = 18
766
767 def __init__(self, xid=None, enable=None):
768 self.xid = xid
769 if enable != None:
770 self.enable = enable
771 else:
772 self.enable = 0
773
774 def pack(self):
775 packed = []
776 packed.append(struct.pack("!B", self.version))
777 packed.append(struct.pack("!B", self.type))
778 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
779 packed.append(struct.pack("!L", self.xid))
780 packed.append(struct.pack("!L", self.experimenter))
781 packed.append(struct.pack("!L", self.subtype))
782 packed.append(struct.pack("!L", self.enable))
783 length = sum([len(x) for x in packed])
784 packed[2] = struct.pack("!H", length)
785 return ''.join(packed)
786
787 @staticmethod
788 def unpack(buf):
789 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
790 obj = bsn_bw_enable_set_request()
791 if type(buf) == loxi.generic_util.OFReader:
792 reader = buf
793 else:
794 reader = loxi.generic_util.OFReader(buf)
795 _version = reader.read("!B")[0]
796 assert(_version == 1)
797 _type = reader.read("!B")[0]
798 assert(_type == 4)
799 _length = reader.read("!H")[0]
800 obj.xid = reader.read("!L")[0]
801 _experimenter = reader.read("!L")[0]
802 assert(_experimenter == 6035143)
803 _subtype = reader.read("!L")[0]
804 assert(_subtype == 18)
805 obj.enable = reader.read("!L")[0]
806 return obj
807
808 def __eq__(self, other):
809 if type(self) != type(other): return False
810 if self.version != other.version: return False
811 if self.type != other.type: return False
812 if self.xid != other.xid: return False
813 if self.enable != other.enable: return False
814 return True
815
816 def __ne__(self, other):
817 return not self.__eq__(other)
818
819 def __str__(self):
820 return self.show()
821
822 def show(self):
823 import loxi.pp
824 return loxi.pp.pp(self)
825
826 def pretty_print(self, q):
827 q.text("bsn_bw_enable_set_request {")
828 with q.group():
829 with q.indent(2):
830 q.breakable()
831 q.text("xid = ");
832 if self.xid != None:
833 q.text("%#x" % self.xid)
834 else:
835 q.text('None')
836 q.text(","); q.breakable()
837 q.text("enable = ");
838 q.text("%#x" % self.enable)
839 q.breakable()
840 q.text('}')
841
Rich Laneb658ddd2013-03-12 10:15:10 -0700842class bsn_get_interfaces_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -0700843 version = 1
844 type = 4
845 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -0700846 subtype = 10
847
848 def __init__(self, xid=None, interfaces=None):
849 self.xid = xid
850 if interfaces != None:
851 self.interfaces = interfaces
852 else:
853 self.interfaces = []
854
855 def pack(self):
856 packed = []
857 packed.append(struct.pack("!B", self.version))
858 packed.append(struct.pack("!B", self.type))
859 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
860 packed.append(struct.pack("!L", self.xid))
861 packed.append(struct.pack("!L", self.experimenter))
862 packed.append(struct.pack("!L", self.subtype))
Dan Talaycof6202252013-07-02 01:00:29 -0700863 packed.append(util.pack_list(self.interfaces))
Rich Laneb658ddd2013-03-12 10:15:10 -0700864 length = sum([len(x) for x in packed])
865 packed[2] = struct.pack("!H", length)
866 return ''.join(packed)
867
868 @staticmethod
869 def unpack(buf):
870 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
871 obj = bsn_get_interfaces_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700872 if type(buf) == loxi.generic_util.OFReader:
873 reader = buf
874 else:
875 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700876 _version = reader.read("!B")[0]
877 assert(_version == 1)
878 _type = reader.read("!B")[0]
879 assert(_type == 4)
880 _length = reader.read("!H")[0]
881 obj.xid = reader.read("!L")[0]
882 _experimenter = reader.read("!L")[0]
883 assert(_experimenter == 6035143)
884 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700885 assert(_subtype == 10)
886 obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack)
Rich Laneb658ddd2013-03-12 10:15:10 -0700887 return obj
888
889 def __eq__(self, other):
890 if type(self) != type(other): return False
891 if self.version != other.version: return False
892 if self.type != other.type: return False
893 if self.xid != other.xid: return False
894 if self.interfaces != other.interfaces: return False
895 return True
896
897 def __ne__(self, other):
898 return not self.__eq__(other)
899
900 def __str__(self):
901 return self.show()
902
903 def show(self):
904 import loxi.pp
905 return loxi.pp.pp(self)
906
907 def pretty_print(self, q):
908 q.text("bsn_get_interfaces_reply {")
909 with q.group():
910 with q.indent(2):
911 q.breakable()
912 q.text("xid = ");
913 if self.xid != None:
914 q.text("%#x" % self.xid)
915 else:
916 q.text('None')
917 q.text(","); q.breakable()
918 q.text("interfaces = ");
919 q.pp(self.interfaces)
920 q.breakable()
921 q.text('}')
922
923class bsn_get_interfaces_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -0700924 version = 1
925 type = 4
926 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -0700927 subtype = 9
928
929 def __init__(self, xid=None):
930 self.xid = xid
931
932 def pack(self):
933 packed = []
934 packed.append(struct.pack("!B", self.version))
935 packed.append(struct.pack("!B", self.type))
936 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
937 packed.append(struct.pack("!L", self.xid))
938 packed.append(struct.pack("!L", self.experimenter))
939 packed.append(struct.pack("!L", self.subtype))
940 length = sum([len(x) for x in packed])
941 packed[2] = struct.pack("!H", length)
942 return ''.join(packed)
943
944 @staticmethod
945 def unpack(buf):
946 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
947 obj = bsn_get_interfaces_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700948 if type(buf) == loxi.generic_util.OFReader:
949 reader = buf
950 else:
951 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700952 _version = reader.read("!B")[0]
953 assert(_version == 1)
954 _type = reader.read("!B")[0]
955 assert(_type == 4)
956 _length = reader.read("!H")[0]
957 obj.xid = reader.read("!L")[0]
958 _experimenter = reader.read("!L")[0]
959 assert(_experimenter == 6035143)
960 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700961 assert(_subtype == 9)
Rich Laneb658ddd2013-03-12 10:15:10 -0700962 return obj
963
964 def __eq__(self, other):
965 if type(self) != type(other): return False
966 if self.version != other.version: return False
967 if self.type != other.type: return False
968 if self.xid != other.xid: return False
969 return True
970
971 def __ne__(self, other):
972 return not self.__eq__(other)
973
974 def __str__(self):
975 return self.show()
976
977 def show(self):
978 import loxi.pp
979 return loxi.pp.pp(self)
980
981 def pretty_print(self, q):
982 q.text("bsn_get_interfaces_request {")
983 with q.group():
984 with q.indent(2):
985 q.breakable()
986 q.text("xid = ");
987 if self.xid != None:
988 q.text("%#x" % self.xid)
989 else:
990 q.text('None')
991 q.breakable()
992 q.text('}')
993
994class bsn_get_ip_mask_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -0700995 version = 1
996 type = 4
997 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -0700998 subtype = 2
999
Rich Lanec2ee4b82013-04-24 17:12:38 -07001000 def __init__(self, xid=None, index=None, mask=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07001001 self.xid = xid
1002 if index != None:
1003 self.index = index
1004 else:
1005 self.index = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07001006 if mask != None:
1007 self.mask = mask
1008 else:
1009 self.mask = 0
1010
1011 def pack(self):
1012 packed = []
1013 packed.append(struct.pack("!B", self.version))
1014 packed.append(struct.pack("!B", self.type))
1015 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1016 packed.append(struct.pack("!L", self.xid))
1017 packed.append(struct.pack("!L", self.experimenter))
1018 packed.append(struct.pack("!L", self.subtype))
1019 packed.append(struct.pack("!B", self.index))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001020 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07001021 packed.append(struct.pack("!L", self.mask))
1022 length = sum([len(x) for x in packed])
1023 packed[2] = struct.pack("!H", length)
1024 return ''.join(packed)
1025
1026 @staticmethod
1027 def unpack(buf):
1028 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1029 obj = bsn_get_ip_mask_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001030 if type(buf) == loxi.generic_util.OFReader:
1031 reader = buf
1032 else:
1033 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001034 _version = reader.read("!B")[0]
1035 assert(_version == 1)
1036 _type = reader.read("!B")[0]
1037 assert(_type == 4)
1038 _length = reader.read("!H")[0]
1039 obj.xid = reader.read("!L")[0]
1040 _experimenter = reader.read("!L")[0]
1041 assert(_experimenter == 6035143)
1042 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001043 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -07001044 obj.index = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001045 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07001046 obj.mask = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07001047 return obj
1048
1049 def __eq__(self, other):
1050 if type(self) != type(other): return False
1051 if self.version != other.version: return False
1052 if self.type != other.type: return False
1053 if self.xid != other.xid: return False
1054 if self.index != other.index: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001055 if self.mask != other.mask: return False
1056 return True
1057
1058 def __ne__(self, other):
1059 return not self.__eq__(other)
1060
1061 def __str__(self):
1062 return self.show()
1063
1064 def show(self):
1065 import loxi.pp
1066 return loxi.pp.pp(self)
1067
1068 def pretty_print(self, q):
1069 q.text("bsn_get_ip_mask_reply {")
1070 with q.group():
1071 with q.indent(2):
1072 q.breakable()
1073 q.text("xid = ");
1074 if self.xid != None:
1075 q.text("%#x" % self.xid)
1076 else:
1077 q.text('None')
1078 q.text(","); q.breakable()
1079 q.text("index = ");
1080 q.text("%#x" % self.index)
1081 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07001082 q.text("mask = ");
1083 q.text("%#x" % self.mask)
1084 q.breakable()
1085 q.text('}')
1086
1087class bsn_get_ip_mask_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07001088 version = 1
1089 type = 4
1090 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07001091 subtype = 1
1092
Rich Lanec2ee4b82013-04-24 17:12:38 -07001093 def __init__(self, xid=None, index=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07001094 self.xid = xid
1095 if index != None:
1096 self.index = index
1097 else:
1098 self.index = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07001099
1100 def pack(self):
1101 packed = []
1102 packed.append(struct.pack("!B", self.version))
1103 packed.append(struct.pack("!B", self.type))
1104 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1105 packed.append(struct.pack("!L", self.xid))
1106 packed.append(struct.pack("!L", self.experimenter))
1107 packed.append(struct.pack("!L", self.subtype))
1108 packed.append(struct.pack("!B", self.index))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001109 packed.append('\x00' * 7)
Rich Laneb658ddd2013-03-12 10:15:10 -07001110 length = sum([len(x) for x in packed])
1111 packed[2] = struct.pack("!H", length)
1112 return ''.join(packed)
1113
1114 @staticmethod
1115 def unpack(buf):
1116 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1117 obj = bsn_get_ip_mask_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001118 if type(buf) == loxi.generic_util.OFReader:
1119 reader = buf
1120 else:
1121 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001122 _version = reader.read("!B")[0]
1123 assert(_version == 1)
1124 _type = reader.read("!B")[0]
1125 assert(_type == 4)
1126 _length = reader.read("!H")[0]
1127 obj.xid = reader.read("!L")[0]
1128 _experimenter = reader.read("!L")[0]
1129 assert(_experimenter == 6035143)
1130 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001131 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -07001132 obj.index = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001133 reader.skip(7)
Rich Laneb658ddd2013-03-12 10:15:10 -07001134 return obj
1135
1136 def __eq__(self, other):
1137 if type(self) != type(other): return False
1138 if self.version != other.version: return False
1139 if self.type != other.type: return False
1140 if self.xid != other.xid: return False
1141 if self.index != other.index: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001142 return True
1143
1144 def __ne__(self, other):
1145 return not self.__eq__(other)
1146
1147 def __str__(self):
1148 return self.show()
1149
1150 def show(self):
1151 import loxi.pp
1152 return loxi.pp.pp(self)
1153
1154 def pretty_print(self, q):
1155 q.text("bsn_get_ip_mask_request {")
1156 with q.group():
1157 with q.indent(2):
1158 q.breakable()
1159 q.text("xid = ");
1160 if self.xid != None:
1161 q.text("%#x" % self.xid)
1162 else:
1163 q.text('None')
1164 q.text(","); q.breakable()
1165 q.text("index = ");
1166 q.text("%#x" % self.index)
Rich Laneb658ddd2013-03-12 10:15:10 -07001167 q.breakable()
1168 q.text('}')
1169
Rich Lane90c961c2013-05-14 09:26:50 -07001170class bsn_get_l2_table_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07001171 version = 1
1172 type = 4
1173 experimenter = 6035143
Rich Lane90c961c2013-05-14 09:26:50 -07001174 subtype = 14
1175
1176 def __init__(self, xid=None, l2_table_enable=None, l2_table_priority=None):
1177 self.xid = xid
1178 if l2_table_enable != None:
1179 self.l2_table_enable = l2_table_enable
1180 else:
1181 self.l2_table_enable = 0
1182 if l2_table_priority != None:
1183 self.l2_table_priority = l2_table_priority
1184 else:
1185 self.l2_table_priority = 0
1186
1187 def pack(self):
1188 packed = []
1189 packed.append(struct.pack("!B", self.version))
1190 packed.append(struct.pack("!B", self.type))
1191 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1192 packed.append(struct.pack("!L", self.xid))
1193 packed.append(struct.pack("!L", self.experimenter))
1194 packed.append(struct.pack("!L", self.subtype))
1195 packed.append(struct.pack("!B", self.l2_table_enable))
1196 packed.append('\x00' * 1)
1197 packed.append(struct.pack("!H", self.l2_table_priority))
1198 packed.append('\x00' * 4)
1199 length = sum([len(x) for x in packed])
1200 packed[2] = struct.pack("!H", length)
1201 return ''.join(packed)
1202
1203 @staticmethod
1204 def unpack(buf):
1205 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1206 obj = bsn_get_l2_table_reply()
1207 if type(buf) == loxi.generic_util.OFReader:
1208 reader = buf
1209 else:
1210 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001211 _version = reader.read("!B")[0]
1212 assert(_version == 1)
1213 _type = reader.read("!B")[0]
1214 assert(_type == 4)
1215 _length = reader.read("!H")[0]
1216 obj.xid = reader.read("!L")[0]
1217 _experimenter = reader.read("!L")[0]
1218 assert(_experimenter == 6035143)
1219 _subtype = reader.read("!L")[0]
Rich Lane90c961c2013-05-14 09:26:50 -07001220 assert(_subtype == 14)
Dan Talaycof6202252013-07-02 01:00:29 -07001221 obj.l2_table_enable = reader.read("!B")[0]
Rich Lane90c961c2013-05-14 09:26:50 -07001222 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001223 obj.l2_table_priority = reader.read("!H")[0]
Rich Lane90c961c2013-05-14 09:26:50 -07001224 reader.skip(4)
1225 return obj
1226
1227 def __eq__(self, other):
1228 if type(self) != type(other): return False
1229 if self.version != other.version: return False
1230 if self.type != other.type: return False
1231 if self.xid != other.xid: return False
1232 if self.l2_table_enable != other.l2_table_enable: return False
1233 if self.l2_table_priority != other.l2_table_priority: return False
1234 return True
1235
1236 def __ne__(self, other):
1237 return not self.__eq__(other)
1238
1239 def __str__(self):
1240 return self.show()
1241
1242 def show(self):
1243 import loxi.pp
1244 return loxi.pp.pp(self)
1245
1246 def pretty_print(self, q):
1247 q.text("bsn_get_l2_table_reply {")
1248 with q.group():
1249 with q.indent(2):
1250 q.breakable()
1251 q.text("xid = ");
1252 if self.xid != None:
1253 q.text("%#x" % self.xid)
1254 else:
1255 q.text('None')
1256 q.text(","); q.breakable()
1257 q.text("l2_table_enable = ");
1258 q.text("%#x" % self.l2_table_enable)
1259 q.text(","); q.breakable()
1260 q.text("l2_table_priority = ");
1261 q.text("%#x" % self.l2_table_priority)
1262 q.breakable()
1263 q.text('}')
1264
1265class bsn_get_l2_table_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07001266 version = 1
1267 type = 4
1268 experimenter = 6035143
Rich Lane90c961c2013-05-14 09:26:50 -07001269 subtype = 13
1270
1271 def __init__(self, xid=None):
1272 self.xid = xid
1273
1274 def pack(self):
1275 packed = []
1276 packed.append(struct.pack("!B", self.version))
1277 packed.append(struct.pack("!B", self.type))
1278 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1279 packed.append(struct.pack("!L", self.xid))
1280 packed.append(struct.pack("!L", self.experimenter))
1281 packed.append(struct.pack("!L", self.subtype))
1282 length = sum([len(x) for x in packed])
1283 packed[2] = struct.pack("!H", length)
1284 return ''.join(packed)
1285
1286 @staticmethod
1287 def unpack(buf):
1288 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1289 obj = bsn_get_l2_table_request()
1290 if type(buf) == loxi.generic_util.OFReader:
1291 reader = buf
1292 else:
1293 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001294 _version = reader.read("!B")[0]
1295 assert(_version == 1)
1296 _type = reader.read("!B")[0]
1297 assert(_type == 4)
1298 _length = reader.read("!H")[0]
1299 obj.xid = reader.read("!L")[0]
1300 _experimenter = reader.read("!L")[0]
1301 assert(_experimenter == 6035143)
1302 _subtype = reader.read("!L")[0]
Rich Lane90c961c2013-05-14 09:26:50 -07001303 assert(_subtype == 13)
1304 return obj
1305
1306 def __eq__(self, other):
1307 if type(self) != type(other): return False
1308 if self.version != other.version: return False
1309 if self.type != other.type: return False
1310 if self.xid != other.xid: return False
1311 return True
1312
1313 def __ne__(self, other):
1314 return not self.__eq__(other)
1315
1316 def __str__(self):
1317 return self.show()
1318
1319 def show(self):
1320 import loxi.pp
1321 return loxi.pp.pp(self)
1322
1323 def pretty_print(self, q):
1324 q.text("bsn_get_l2_table_request {")
1325 with q.group():
1326 with q.indent(2):
1327 q.breakable()
1328 q.text("xid = ");
1329 if self.xid != None:
1330 q.text("%#x" % self.xid)
1331 else:
1332 q.text('None')
1333 q.breakable()
1334 q.text('}')
1335
Rich Laneb658ddd2013-03-12 10:15:10 -07001336class bsn_get_mirroring_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07001337 version = 1
1338 type = 4
1339 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07001340 subtype = 5
1341
Rich Lanec2ee4b82013-04-24 17:12:38 -07001342 def __init__(self, xid=None, report_mirror_ports=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07001343 self.xid = xid
1344 if report_mirror_ports != None:
1345 self.report_mirror_ports = report_mirror_ports
1346 else:
1347 self.report_mirror_ports = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07001348
1349 def pack(self):
1350 packed = []
1351 packed.append(struct.pack("!B", self.version))
1352 packed.append(struct.pack("!B", self.type))
1353 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1354 packed.append(struct.pack("!L", self.xid))
1355 packed.append(struct.pack("!L", self.experimenter))
1356 packed.append(struct.pack("!L", self.subtype))
1357 packed.append(struct.pack("!B", self.report_mirror_ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001358 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07001359 length = sum([len(x) for x in packed])
1360 packed[2] = struct.pack("!H", length)
1361 return ''.join(packed)
1362
1363 @staticmethod
1364 def unpack(buf):
1365 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1366 obj = bsn_get_mirroring_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001367 if type(buf) == loxi.generic_util.OFReader:
1368 reader = buf
1369 else:
1370 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001371 _version = reader.read("!B")[0]
1372 assert(_version == 1)
1373 _type = reader.read("!B")[0]
1374 assert(_type == 4)
1375 _length = reader.read("!H")[0]
1376 obj.xid = reader.read("!L")[0]
1377 _experimenter = reader.read("!L")[0]
1378 assert(_experimenter == 6035143)
1379 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001380 assert(_subtype == 5)
Dan Talaycof6202252013-07-02 01:00:29 -07001381 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001382 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -07001383 return obj
1384
1385 def __eq__(self, other):
1386 if type(self) != type(other): return False
1387 if self.version != other.version: return False
1388 if self.type != other.type: return False
1389 if self.xid != other.xid: return False
1390 if self.report_mirror_ports != other.report_mirror_ports: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001391 return True
1392
1393 def __ne__(self, other):
1394 return not self.__eq__(other)
1395
1396 def __str__(self):
1397 return self.show()
1398
1399 def show(self):
1400 import loxi.pp
1401 return loxi.pp.pp(self)
1402
1403 def pretty_print(self, q):
1404 q.text("bsn_get_mirroring_reply {")
1405 with q.group():
1406 with q.indent(2):
1407 q.breakable()
1408 q.text("xid = ");
1409 if self.xid != None:
1410 q.text("%#x" % self.xid)
1411 else:
1412 q.text('None')
1413 q.text(","); q.breakable()
1414 q.text("report_mirror_ports = ");
1415 q.text("%#x" % self.report_mirror_ports)
Rich Laneb658ddd2013-03-12 10:15:10 -07001416 q.breakable()
1417 q.text('}')
1418
1419class bsn_get_mirroring_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07001420 version = 1
1421 type = 4
1422 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07001423 subtype = 4
1424
Rich Lanec2ee4b82013-04-24 17:12:38 -07001425 def __init__(self, xid=None, report_mirror_ports=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07001426 self.xid = xid
1427 if report_mirror_ports != None:
1428 self.report_mirror_ports = report_mirror_ports
1429 else:
1430 self.report_mirror_ports = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07001431
1432 def pack(self):
1433 packed = []
1434 packed.append(struct.pack("!B", self.version))
1435 packed.append(struct.pack("!B", self.type))
1436 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1437 packed.append(struct.pack("!L", self.xid))
1438 packed.append(struct.pack("!L", self.experimenter))
1439 packed.append(struct.pack("!L", self.subtype))
1440 packed.append(struct.pack("!B", self.report_mirror_ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001441 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07001442 length = sum([len(x) for x in packed])
1443 packed[2] = struct.pack("!H", length)
1444 return ''.join(packed)
1445
1446 @staticmethod
1447 def unpack(buf):
1448 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1449 obj = bsn_get_mirroring_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001450 if type(buf) == loxi.generic_util.OFReader:
1451 reader = buf
1452 else:
1453 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001454 _version = reader.read("!B")[0]
1455 assert(_version == 1)
1456 _type = reader.read("!B")[0]
1457 assert(_type == 4)
1458 _length = reader.read("!H")[0]
1459 obj.xid = reader.read("!L")[0]
1460 _experimenter = reader.read("!L")[0]
1461 assert(_experimenter == 6035143)
1462 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001463 assert(_subtype == 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001464 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001465 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -07001466 return obj
1467
1468 def __eq__(self, other):
1469 if type(self) != type(other): return False
1470 if self.version != other.version: return False
1471 if self.type != other.type: return False
1472 if self.xid != other.xid: return False
1473 if self.report_mirror_ports != other.report_mirror_ports: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001474 return True
1475
1476 def __ne__(self, other):
1477 return not self.__eq__(other)
1478
1479 def __str__(self):
1480 return self.show()
1481
1482 def show(self):
1483 import loxi.pp
1484 return loxi.pp.pp(self)
1485
1486 def pretty_print(self, q):
1487 q.text("bsn_get_mirroring_request {")
1488 with q.group():
1489 with q.indent(2):
1490 q.breakable()
1491 q.text("xid = ");
1492 if self.xid != None:
1493 q.text("%#x" % self.xid)
1494 else:
1495 q.text('None')
1496 q.text(","); q.breakable()
1497 q.text("report_mirror_ports = ");
1498 q.text("%#x" % self.report_mirror_ports)
Rich Laneb658ddd2013-03-12 10:15:10 -07001499 q.breakable()
1500 q.text('}')
1501
1502class bsn_set_ip_mask(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07001503 version = 1
1504 type = 4
1505 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07001506 subtype = 0
1507
Rich Lanec2ee4b82013-04-24 17:12:38 -07001508 def __init__(self, xid=None, index=None, mask=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07001509 self.xid = xid
1510 if index != None:
1511 self.index = index
1512 else:
1513 self.index = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07001514 if mask != None:
1515 self.mask = mask
1516 else:
1517 self.mask = 0
1518
1519 def pack(self):
1520 packed = []
1521 packed.append(struct.pack("!B", self.version))
1522 packed.append(struct.pack("!B", self.type))
1523 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1524 packed.append(struct.pack("!L", self.xid))
1525 packed.append(struct.pack("!L", self.experimenter))
1526 packed.append(struct.pack("!L", self.subtype))
1527 packed.append(struct.pack("!B", self.index))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001528 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07001529 packed.append(struct.pack("!L", self.mask))
1530 length = sum([len(x) for x in packed])
1531 packed[2] = struct.pack("!H", length)
1532 return ''.join(packed)
1533
1534 @staticmethod
1535 def unpack(buf):
1536 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1537 obj = bsn_set_ip_mask()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001538 if type(buf) == loxi.generic_util.OFReader:
1539 reader = buf
1540 else:
1541 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001542 _version = reader.read("!B")[0]
1543 assert(_version == 1)
1544 _type = reader.read("!B")[0]
1545 assert(_type == 4)
1546 _length = reader.read("!H")[0]
1547 obj.xid = reader.read("!L")[0]
1548 _experimenter = reader.read("!L")[0]
1549 assert(_experimenter == 6035143)
1550 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001551 assert(_subtype == 0)
Dan Talaycof6202252013-07-02 01:00:29 -07001552 obj.index = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001553 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07001554 obj.mask = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07001555 return obj
1556
1557 def __eq__(self, other):
1558 if type(self) != type(other): return False
1559 if self.version != other.version: return False
1560 if self.type != other.type: return False
1561 if self.xid != other.xid: return False
1562 if self.index != other.index: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001563 if self.mask != other.mask: return False
1564 return True
1565
1566 def __ne__(self, other):
1567 return not self.__eq__(other)
1568
1569 def __str__(self):
1570 return self.show()
1571
1572 def show(self):
1573 import loxi.pp
1574 return loxi.pp.pp(self)
1575
1576 def pretty_print(self, q):
1577 q.text("bsn_set_ip_mask {")
1578 with q.group():
1579 with q.indent(2):
1580 q.breakable()
1581 q.text("xid = ");
1582 if self.xid != None:
1583 q.text("%#x" % self.xid)
1584 else:
1585 q.text('None')
1586 q.text(","); q.breakable()
1587 q.text("index = ");
1588 q.text("%#x" % self.index)
1589 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07001590 q.text("mask = ");
1591 q.text("%#x" % self.mask)
1592 q.breakable()
1593 q.text('}')
1594
Dan Talaycof6202252013-07-02 01:00:29 -07001595class bsn_set_l2_table_reply(Message):
1596 version = 1
1597 type = 4
1598 experimenter = 6035143
1599 subtype = 24
1600
1601 def __init__(self, xid=None, l2_table_enable=None, l2_table_priority=None, status=None):
1602 self.xid = xid
1603 if l2_table_enable != None:
1604 self.l2_table_enable = l2_table_enable
1605 else:
1606 self.l2_table_enable = 0
1607 if l2_table_priority != None:
1608 self.l2_table_priority = l2_table_priority
1609 else:
1610 self.l2_table_priority = 0
1611 if status != None:
1612 self.status = status
1613 else:
1614 self.status = 0
1615
1616 def pack(self):
1617 packed = []
1618 packed.append(struct.pack("!B", self.version))
1619 packed.append(struct.pack("!B", self.type))
1620 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1621 packed.append(struct.pack("!L", self.xid))
1622 packed.append(struct.pack("!L", self.experimenter))
1623 packed.append(struct.pack("!L", self.subtype))
1624 packed.append(struct.pack("!B", self.l2_table_enable))
1625 packed.append('\x00' * 1)
1626 packed.append(struct.pack("!H", self.l2_table_priority))
1627 packed.append(struct.pack("!L", self.status))
1628 length = sum([len(x) for x in packed])
1629 packed[2] = struct.pack("!H", length)
1630 return ''.join(packed)
1631
1632 @staticmethod
1633 def unpack(buf):
1634 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1635 obj = bsn_set_l2_table_reply()
1636 if type(buf) == loxi.generic_util.OFReader:
1637 reader = buf
1638 else:
1639 reader = loxi.generic_util.OFReader(buf)
1640 _version = reader.read("!B")[0]
1641 assert(_version == 1)
1642 _type = reader.read("!B")[0]
1643 assert(_type == 4)
1644 _length = reader.read("!H")[0]
1645 obj.xid = reader.read("!L")[0]
1646 _experimenter = reader.read("!L")[0]
1647 assert(_experimenter == 6035143)
1648 _subtype = reader.read("!L")[0]
1649 assert(_subtype == 24)
1650 obj.l2_table_enable = reader.read("!B")[0]
1651 reader.skip(1)
1652 obj.l2_table_priority = reader.read("!H")[0]
1653 obj.status = reader.read("!L")[0]
1654 return obj
1655
1656 def __eq__(self, other):
1657 if type(self) != type(other): return False
1658 if self.version != other.version: return False
1659 if self.type != other.type: return False
1660 if self.xid != other.xid: return False
1661 if self.l2_table_enable != other.l2_table_enable: return False
1662 if self.l2_table_priority != other.l2_table_priority: return False
1663 if self.status != other.status: return False
1664 return True
1665
1666 def __ne__(self, other):
1667 return not self.__eq__(other)
1668
1669 def __str__(self):
1670 return self.show()
1671
1672 def show(self):
1673 import loxi.pp
1674 return loxi.pp.pp(self)
1675
1676 def pretty_print(self, q):
1677 q.text("bsn_set_l2_table_reply {")
1678 with q.group():
1679 with q.indent(2):
1680 q.breakable()
1681 q.text("xid = ");
1682 if self.xid != None:
1683 q.text("%#x" % self.xid)
1684 else:
1685 q.text('None')
1686 q.text(","); q.breakable()
1687 q.text("l2_table_enable = ");
1688 q.text("%#x" % self.l2_table_enable)
1689 q.text(","); q.breakable()
1690 q.text("l2_table_priority = ");
1691 q.text("%#x" % self.l2_table_priority)
1692 q.text(","); q.breakable()
1693 q.text("status = ");
1694 q.text("%#x" % self.status)
1695 q.breakable()
1696 q.text('}')
1697
1698class bsn_set_l2_table_request(Message):
1699 version = 1
1700 type = 4
1701 experimenter = 6035143
Rich Lane90c961c2013-05-14 09:26:50 -07001702 subtype = 12
1703
1704 def __init__(self, xid=None, l2_table_enable=None, l2_table_priority=None):
1705 self.xid = xid
1706 if l2_table_enable != None:
1707 self.l2_table_enable = l2_table_enable
1708 else:
1709 self.l2_table_enable = 0
1710 if l2_table_priority != None:
1711 self.l2_table_priority = l2_table_priority
1712 else:
1713 self.l2_table_priority = 0
1714
1715 def pack(self):
1716 packed = []
1717 packed.append(struct.pack("!B", self.version))
1718 packed.append(struct.pack("!B", self.type))
1719 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1720 packed.append(struct.pack("!L", self.xid))
1721 packed.append(struct.pack("!L", self.experimenter))
1722 packed.append(struct.pack("!L", self.subtype))
1723 packed.append(struct.pack("!B", self.l2_table_enable))
1724 packed.append('\x00' * 1)
1725 packed.append(struct.pack("!H", self.l2_table_priority))
1726 packed.append('\x00' * 4)
1727 length = sum([len(x) for x in packed])
1728 packed[2] = struct.pack("!H", length)
1729 return ''.join(packed)
1730
1731 @staticmethod
1732 def unpack(buf):
1733 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
Dan Talaycof6202252013-07-02 01:00:29 -07001734 obj = bsn_set_l2_table_request()
Rich Lane90c961c2013-05-14 09:26:50 -07001735 if type(buf) == loxi.generic_util.OFReader:
1736 reader = buf
1737 else:
1738 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001739 _version = reader.read("!B")[0]
1740 assert(_version == 1)
1741 _type = reader.read("!B")[0]
1742 assert(_type == 4)
1743 _length = reader.read("!H")[0]
1744 obj.xid = reader.read("!L")[0]
1745 _experimenter = reader.read("!L")[0]
1746 assert(_experimenter == 6035143)
1747 _subtype = reader.read("!L")[0]
Rich Lane90c961c2013-05-14 09:26:50 -07001748 assert(_subtype == 12)
Dan Talaycof6202252013-07-02 01:00:29 -07001749 obj.l2_table_enable = reader.read("!B")[0]
Rich Lane90c961c2013-05-14 09:26:50 -07001750 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001751 obj.l2_table_priority = reader.read("!H")[0]
Rich Lane90c961c2013-05-14 09:26:50 -07001752 reader.skip(4)
1753 return obj
1754
1755 def __eq__(self, other):
1756 if type(self) != type(other): return False
1757 if self.version != other.version: return False
1758 if self.type != other.type: return False
1759 if self.xid != other.xid: return False
1760 if self.l2_table_enable != other.l2_table_enable: return False
1761 if self.l2_table_priority != other.l2_table_priority: return False
1762 return True
1763
1764 def __ne__(self, other):
1765 return not self.__eq__(other)
1766
1767 def __str__(self):
1768 return self.show()
1769
1770 def show(self):
1771 import loxi.pp
1772 return loxi.pp.pp(self)
1773
1774 def pretty_print(self, q):
Dan Talaycof6202252013-07-02 01:00:29 -07001775 q.text("bsn_set_l2_table_request {")
Rich Lane90c961c2013-05-14 09:26:50 -07001776 with q.group():
1777 with q.indent(2):
1778 q.breakable()
1779 q.text("xid = ");
1780 if self.xid != None:
1781 q.text("%#x" % self.xid)
1782 else:
1783 q.text('None')
1784 q.text(","); q.breakable()
1785 q.text("l2_table_enable = ");
1786 q.text("%#x" % self.l2_table_enable)
1787 q.text(","); q.breakable()
1788 q.text("l2_table_priority = ");
1789 q.text("%#x" % self.l2_table_priority)
1790 q.breakable()
1791 q.text('}')
1792
Rich Laneb658ddd2013-03-12 10:15:10 -07001793class bsn_set_mirroring(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07001794 version = 1
1795 type = 4
1796 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07001797 subtype = 3
1798
Rich Lanec2ee4b82013-04-24 17:12:38 -07001799 def __init__(self, xid=None, report_mirror_ports=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07001800 self.xid = xid
1801 if report_mirror_ports != None:
1802 self.report_mirror_ports = report_mirror_ports
1803 else:
1804 self.report_mirror_ports = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07001805
1806 def pack(self):
1807 packed = []
1808 packed.append(struct.pack("!B", self.version))
1809 packed.append(struct.pack("!B", self.type))
1810 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1811 packed.append(struct.pack("!L", self.xid))
1812 packed.append(struct.pack("!L", self.experimenter))
1813 packed.append(struct.pack("!L", self.subtype))
1814 packed.append(struct.pack("!B", self.report_mirror_ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001815 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07001816 length = sum([len(x) for x in packed])
1817 packed[2] = struct.pack("!H", length)
1818 return ''.join(packed)
1819
1820 @staticmethod
1821 def unpack(buf):
1822 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1823 obj = bsn_set_mirroring()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001824 if type(buf) == loxi.generic_util.OFReader:
1825 reader = buf
1826 else:
1827 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001828 _version = reader.read("!B")[0]
1829 assert(_version == 1)
1830 _type = reader.read("!B")[0]
1831 assert(_type == 4)
1832 _length = reader.read("!H")[0]
1833 obj.xid = reader.read("!L")[0]
1834 _experimenter = reader.read("!L")[0]
1835 assert(_experimenter == 6035143)
1836 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001837 assert(_subtype == 3)
Dan Talaycof6202252013-07-02 01:00:29 -07001838 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001839 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -07001840 return obj
1841
1842 def __eq__(self, other):
1843 if type(self) != type(other): return False
1844 if self.version != other.version: return False
1845 if self.type != other.type: return False
1846 if self.xid != other.xid: return False
1847 if self.report_mirror_ports != other.report_mirror_ports: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001848 return True
1849
1850 def __ne__(self, other):
1851 return not self.__eq__(other)
1852
1853 def __str__(self):
1854 return self.show()
1855
1856 def show(self):
1857 import loxi.pp
1858 return loxi.pp.pp(self)
1859
1860 def pretty_print(self, q):
1861 q.text("bsn_set_mirroring {")
1862 with q.group():
1863 with q.indent(2):
1864 q.breakable()
1865 q.text("xid = ");
1866 if self.xid != None:
1867 q.text("%#x" % self.xid)
1868 else:
1869 q.text('None')
1870 q.text(","); q.breakable()
1871 q.text("report_mirror_ports = ");
1872 q.text("%#x" % self.report_mirror_ports)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001873 q.breakable()
1874 q.text('}')
1875
Dan Talaycof6202252013-07-02 01:00:29 -07001876class bsn_set_pktin_suppression_reply(Message):
1877 version = 1
1878 type = 4
1879 experimenter = 6035143
1880 subtype = 25
1881
1882 def __init__(self, xid=None, status=None):
1883 self.xid = xid
1884 if status != None:
1885 self.status = status
1886 else:
1887 self.status = 0
1888
1889 def pack(self):
1890 packed = []
1891 packed.append(struct.pack("!B", self.version))
1892 packed.append(struct.pack("!B", self.type))
1893 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1894 packed.append(struct.pack("!L", self.xid))
1895 packed.append(struct.pack("!L", self.experimenter))
1896 packed.append(struct.pack("!L", self.subtype))
1897 packed.append(struct.pack("!L", self.status))
1898 length = sum([len(x) for x in packed])
1899 packed[2] = struct.pack("!H", length)
1900 return ''.join(packed)
1901
1902 @staticmethod
1903 def unpack(buf):
1904 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1905 obj = bsn_set_pktin_suppression_reply()
1906 if type(buf) == loxi.generic_util.OFReader:
1907 reader = buf
1908 else:
1909 reader = loxi.generic_util.OFReader(buf)
1910 _version = reader.read("!B")[0]
1911 assert(_version == 1)
1912 _type = reader.read("!B")[0]
1913 assert(_type == 4)
1914 _length = reader.read("!H")[0]
1915 obj.xid = reader.read("!L")[0]
1916 _experimenter = reader.read("!L")[0]
1917 assert(_experimenter == 6035143)
1918 _subtype = reader.read("!L")[0]
1919 assert(_subtype == 25)
1920 obj.status = reader.read("!L")[0]
1921 return obj
1922
1923 def __eq__(self, other):
1924 if type(self) != type(other): return False
1925 if self.version != other.version: return False
1926 if self.type != other.type: return False
1927 if self.xid != other.xid: return False
1928 if self.status != other.status: return False
1929 return True
1930
1931 def __ne__(self, other):
1932 return not self.__eq__(other)
1933
1934 def __str__(self):
1935 return self.show()
1936
1937 def show(self):
1938 import loxi.pp
1939 return loxi.pp.pp(self)
1940
1941 def pretty_print(self, q):
1942 q.text("bsn_set_pktin_suppression_reply {")
1943 with q.group():
1944 with q.indent(2):
1945 q.breakable()
1946 q.text("xid = ");
1947 if self.xid != None:
1948 q.text("%#x" % self.xid)
1949 else:
1950 q.text('None')
1951 q.text(","); q.breakable()
1952 q.text("status = ");
1953 q.text("%#x" % self.status)
1954 q.breakable()
1955 q.text('}')
1956
1957class bsn_set_pktin_suppression_request(Message):
1958 version = 1
1959 type = 4
1960 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001961 subtype = 11
1962
1963 def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None):
1964 self.xid = xid
1965 if enabled != None:
1966 self.enabled = enabled
1967 else:
1968 self.enabled = 0
1969 if idle_timeout != None:
1970 self.idle_timeout = idle_timeout
1971 else:
1972 self.idle_timeout = 0
1973 if hard_timeout != None:
1974 self.hard_timeout = hard_timeout
1975 else:
1976 self.hard_timeout = 0
1977 if priority != None:
1978 self.priority = priority
1979 else:
1980 self.priority = 0
1981 if cookie != None:
1982 self.cookie = cookie
1983 else:
1984 self.cookie = 0
1985
1986 def pack(self):
1987 packed = []
1988 packed.append(struct.pack("!B", self.version))
1989 packed.append(struct.pack("!B", self.type))
1990 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1991 packed.append(struct.pack("!L", self.xid))
1992 packed.append(struct.pack("!L", self.experimenter))
1993 packed.append(struct.pack("!L", self.subtype))
1994 packed.append(struct.pack("!B", self.enabled))
1995 packed.append('\x00' * 1)
1996 packed.append(struct.pack("!H", self.idle_timeout))
1997 packed.append(struct.pack("!H", self.hard_timeout))
1998 packed.append(struct.pack("!H", self.priority))
1999 packed.append(struct.pack("!Q", self.cookie))
2000 length = sum([len(x) for x in packed])
2001 packed[2] = struct.pack("!H", length)
2002 return ''.join(packed)
2003
2004 @staticmethod
2005 def unpack(buf):
2006 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
Dan Talaycof6202252013-07-02 01:00:29 -07002007 obj = bsn_set_pktin_suppression_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002008 if type(buf) == loxi.generic_util.OFReader:
2009 reader = buf
2010 else:
2011 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002012 _version = reader.read("!B")[0]
2013 assert(_version == 1)
2014 _type = reader.read("!B")[0]
2015 assert(_type == 4)
2016 _length = reader.read("!H")[0]
2017 obj.xid = reader.read("!L")[0]
2018 _experimenter = reader.read("!L")[0]
2019 assert(_experimenter == 6035143)
2020 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002021 assert(_subtype == 11)
Dan Talaycof6202252013-07-02 01:00:29 -07002022 obj.enabled = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002023 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07002024 obj.idle_timeout = reader.read("!H")[0]
2025 obj.hard_timeout = reader.read("!H")[0]
2026 obj.priority = reader.read("!H")[0]
2027 obj.cookie = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002028 return obj
2029
2030 def __eq__(self, other):
2031 if type(self) != type(other): return False
2032 if self.version != other.version: return False
2033 if self.type != other.type: return False
2034 if self.xid != other.xid: return False
2035 if self.enabled != other.enabled: return False
2036 if self.idle_timeout != other.idle_timeout: return False
2037 if self.hard_timeout != other.hard_timeout: return False
2038 if self.priority != other.priority: return False
2039 if self.cookie != other.cookie: return False
2040 return True
2041
2042 def __ne__(self, other):
2043 return not self.__eq__(other)
2044
2045 def __str__(self):
2046 return self.show()
2047
2048 def show(self):
2049 import loxi.pp
2050 return loxi.pp.pp(self)
2051
2052 def pretty_print(self, q):
Dan Talaycof6202252013-07-02 01:00:29 -07002053 q.text("bsn_set_pktin_suppression_request {")
Rich Lanec2ee4b82013-04-24 17:12:38 -07002054 with q.group():
2055 with q.indent(2):
2056 q.breakable()
2057 q.text("xid = ");
2058 if self.xid != None:
2059 q.text("%#x" % self.xid)
2060 else:
2061 q.text('None')
Rich Laneb658ddd2013-03-12 10:15:10 -07002062 q.text(","); q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002063 q.text("enabled = ");
2064 q.text("%#x" % self.enabled)
2065 q.text(","); q.breakable()
2066 q.text("idle_timeout = ");
2067 q.text("%#x" % self.idle_timeout)
2068 q.text(","); q.breakable()
2069 q.text("hard_timeout = ");
2070 q.text("%#x" % self.hard_timeout)
2071 q.text(","); q.breakable()
2072 q.text("priority = ");
2073 q.text("%#x" % self.priority)
2074 q.text(","); q.breakable()
2075 q.text("cookie = ");
2076 q.text("%#x" % self.cookie)
Rich Laneb658ddd2013-03-12 10:15:10 -07002077 q.breakable()
2078 q.text('}')
2079
2080class bsn_shell_command(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07002081 version = 1
2082 type = 4
2083 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07002084 subtype = 6
2085
2086 def __init__(self, xid=None, service=None, data=None):
2087 self.xid = xid
2088 if service != None:
2089 self.service = service
2090 else:
2091 self.service = 0
2092 if data != None:
2093 self.data = data
2094 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002095 self.data = ''
Rich Laneb658ddd2013-03-12 10:15:10 -07002096
2097 def pack(self):
2098 packed = []
2099 packed.append(struct.pack("!B", self.version))
2100 packed.append(struct.pack("!B", self.type))
2101 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2102 packed.append(struct.pack("!L", self.xid))
2103 packed.append(struct.pack("!L", self.experimenter))
2104 packed.append(struct.pack("!L", self.subtype))
2105 packed.append(struct.pack("!L", self.service))
2106 packed.append(self.data)
2107 length = sum([len(x) for x in packed])
2108 packed[2] = struct.pack("!H", length)
2109 return ''.join(packed)
2110
2111 @staticmethod
2112 def unpack(buf):
2113 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2114 obj = bsn_shell_command()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002115 if type(buf) == loxi.generic_util.OFReader:
2116 reader = buf
2117 else:
2118 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002119 _version = reader.read("!B")[0]
2120 assert(_version == 1)
2121 _type = reader.read("!B")[0]
2122 assert(_type == 4)
2123 _length = reader.read("!H")[0]
2124 obj.xid = reader.read("!L")[0]
2125 _experimenter = reader.read("!L")[0]
2126 assert(_experimenter == 6035143)
2127 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002128 assert(_subtype == 6)
Dan Talaycof6202252013-07-02 01:00:29 -07002129 obj.service = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002130 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07002131 return obj
2132
2133 def __eq__(self, other):
2134 if type(self) != type(other): return False
2135 if self.version != other.version: return False
2136 if self.type != other.type: return False
2137 if self.xid != other.xid: return False
2138 if self.service != other.service: return False
2139 if self.data != other.data: return False
2140 return True
2141
2142 def __ne__(self, other):
2143 return not self.__eq__(other)
2144
2145 def __str__(self):
2146 return self.show()
2147
2148 def show(self):
2149 import loxi.pp
2150 return loxi.pp.pp(self)
2151
2152 def pretty_print(self, q):
2153 q.text("bsn_shell_command {")
2154 with q.group():
2155 with q.indent(2):
2156 q.breakable()
2157 q.text("xid = ");
2158 if self.xid != None:
2159 q.text("%#x" % self.xid)
2160 else:
2161 q.text('None')
2162 q.text(","); q.breakable()
2163 q.text("service = ");
2164 q.text("%#x" % self.service)
2165 q.text(","); q.breakable()
2166 q.text("data = ");
2167 q.pp(self.data)
2168 q.breakable()
2169 q.text('}')
2170
2171class bsn_shell_output(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07002172 version = 1
2173 type = 4
2174 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07002175 subtype = 7
2176
2177 def __init__(self, xid=None, data=None):
2178 self.xid = xid
2179 if data != None:
2180 self.data = data
2181 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002182 self.data = ''
Rich Laneb658ddd2013-03-12 10:15:10 -07002183
2184 def pack(self):
2185 packed = []
2186 packed.append(struct.pack("!B", self.version))
2187 packed.append(struct.pack("!B", self.type))
2188 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2189 packed.append(struct.pack("!L", self.xid))
2190 packed.append(struct.pack("!L", self.experimenter))
2191 packed.append(struct.pack("!L", self.subtype))
2192 packed.append(self.data)
2193 length = sum([len(x) for x in packed])
2194 packed[2] = struct.pack("!H", length)
2195 return ''.join(packed)
2196
2197 @staticmethod
2198 def unpack(buf):
2199 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2200 obj = bsn_shell_output()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002201 if type(buf) == loxi.generic_util.OFReader:
2202 reader = buf
2203 else:
2204 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002205 _version = reader.read("!B")[0]
2206 assert(_version == 1)
2207 _type = reader.read("!B")[0]
2208 assert(_type == 4)
2209 _length = reader.read("!H")[0]
2210 obj.xid = reader.read("!L")[0]
2211 _experimenter = reader.read("!L")[0]
2212 assert(_experimenter == 6035143)
2213 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002214 assert(_subtype == 7)
2215 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07002216 return obj
2217
2218 def __eq__(self, other):
2219 if type(self) != type(other): return False
2220 if self.version != other.version: return False
2221 if self.type != other.type: return False
2222 if self.xid != other.xid: return False
2223 if self.data != other.data: return False
2224 return True
2225
2226 def __ne__(self, other):
2227 return not self.__eq__(other)
2228
2229 def __str__(self):
2230 return self.show()
2231
2232 def show(self):
2233 import loxi.pp
2234 return loxi.pp.pp(self)
2235
2236 def pretty_print(self, q):
2237 q.text("bsn_shell_output {")
2238 with q.group():
2239 with q.indent(2):
2240 q.breakable()
2241 q.text("xid = ");
2242 if self.xid != None:
2243 q.text("%#x" % self.xid)
2244 else:
2245 q.text('None')
2246 q.text(","); q.breakable()
2247 q.text("data = ");
2248 q.pp(self.data)
2249 q.breakable()
2250 q.text('}')
2251
2252class bsn_shell_status(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07002253 version = 1
2254 type = 4
2255 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07002256 subtype = 8
2257
2258 def __init__(self, xid=None, status=None):
2259 self.xid = xid
2260 if status != None:
2261 self.status = status
2262 else:
2263 self.status = 0
2264
2265 def pack(self):
2266 packed = []
2267 packed.append(struct.pack("!B", self.version))
2268 packed.append(struct.pack("!B", self.type))
2269 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2270 packed.append(struct.pack("!L", self.xid))
2271 packed.append(struct.pack("!L", self.experimenter))
2272 packed.append(struct.pack("!L", self.subtype))
2273 packed.append(struct.pack("!L", self.status))
2274 length = sum([len(x) for x in packed])
2275 packed[2] = struct.pack("!H", length)
2276 return ''.join(packed)
2277
2278 @staticmethod
2279 def unpack(buf):
2280 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2281 obj = bsn_shell_status()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002282 if type(buf) == loxi.generic_util.OFReader:
2283 reader = buf
2284 else:
2285 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002286 _version = reader.read("!B")[0]
2287 assert(_version == 1)
2288 _type = reader.read("!B")[0]
2289 assert(_type == 4)
2290 _length = reader.read("!H")[0]
2291 obj.xid = reader.read("!L")[0]
2292 _experimenter = reader.read("!L")[0]
2293 assert(_experimenter == 6035143)
2294 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002295 assert(_subtype == 8)
Dan Talaycof6202252013-07-02 01:00:29 -07002296 obj.status = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07002297 return obj
2298
2299 def __eq__(self, other):
2300 if type(self) != type(other): return False
2301 if self.version != other.version: return False
2302 if self.type != other.type: return False
2303 if self.xid != other.xid: return False
2304 if self.status != other.status: return False
2305 return True
2306
2307 def __ne__(self, other):
2308 return not self.__eq__(other)
2309
2310 def __str__(self):
2311 return self.show()
2312
2313 def show(self):
2314 import loxi.pp
2315 return loxi.pp.pp(self)
2316
2317 def pretty_print(self, q):
2318 q.text("bsn_shell_status {")
2319 with q.group():
2320 with q.indent(2):
2321 q.breakable()
2322 q.text("xid = ");
2323 if self.xid != None:
2324 q.text("%#x" % self.xid)
2325 else:
2326 q.text('None')
2327 q.text(","); q.breakable()
2328 q.text("status = ");
2329 q.text("%#x" % self.status)
2330 q.breakable()
2331 q.text('}')
2332
Dan Talaycof6202252013-07-02 01:00:29 -07002333class bsn_virtual_port_create_reply(Message):
2334 version = 1
2335 type = 4
2336 experimenter = 6035143
2337 subtype = 16
2338
2339 def __init__(self, xid=None, status=None, vport_no=None):
2340 self.xid = xid
2341 if status != None:
2342 self.status = status
2343 else:
2344 self.status = 0
2345 if vport_no != None:
2346 self.vport_no = vport_no
2347 else:
2348 self.vport_no = 0
2349
2350 def pack(self):
2351 packed = []
2352 packed.append(struct.pack("!B", self.version))
2353 packed.append(struct.pack("!B", self.type))
2354 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2355 packed.append(struct.pack("!L", self.xid))
2356 packed.append(struct.pack("!L", self.experimenter))
2357 packed.append(struct.pack("!L", self.subtype))
2358 packed.append(struct.pack("!L", self.status))
2359 packed.append(struct.pack("!L", self.vport_no))
2360 length = sum([len(x) for x in packed])
2361 packed[2] = struct.pack("!H", length)
2362 return ''.join(packed)
2363
2364 @staticmethod
2365 def unpack(buf):
2366 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2367 obj = bsn_virtual_port_create_reply()
2368 if type(buf) == loxi.generic_util.OFReader:
2369 reader = buf
2370 else:
2371 reader = loxi.generic_util.OFReader(buf)
2372 _version = reader.read("!B")[0]
2373 assert(_version == 1)
2374 _type = reader.read("!B")[0]
2375 assert(_type == 4)
2376 _length = reader.read("!H")[0]
2377 obj.xid = reader.read("!L")[0]
2378 _experimenter = reader.read("!L")[0]
2379 assert(_experimenter == 6035143)
2380 _subtype = reader.read("!L")[0]
2381 assert(_subtype == 16)
2382 obj.status = reader.read("!L")[0]
2383 obj.vport_no = reader.read("!L")[0]
2384 return obj
2385
2386 def __eq__(self, other):
2387 if type(self) != type(other): return False
2388 if self.version != other.version: return False
2389 if self.type != other.type: return False
2390 if self.xid != other.xid: return False
2391 if self.status != other.status: return False
2392 if self.vport_no != other.vport_no: return False
2393 return True
2394
2395 def __ne__(self, other):
2396 return not self.__eq__(other)
2397
2398 def __str__(self):
2399 return self.show()
2400
2401 def show(self):
2402 import loxi.pp
2403 return loxi.pp.pp(self)
2404
2405 def pretty_print(self, q):
2406 q.text("bsn_virtual_port_create_reply {")
2407 with q.group():
2408 with q.indent(2):
2409 q.breakable()
2410 q.text("xid = ");
2411 if self.xid != None:
2412 q.text("%#x" % self.xid)
2413 else:
2414 q.text('None')
2415 q.text(","); q.breakable()
2416 q.text("status = ");
2417 q.text("%#x" % self.status)
2418 q.text(","); q.breakable()
2419 q.text("vport_no = ");
2420 q.text("%#x" % self.vport_no)
2421 q.breakable()
2422 q.text('}')
2423
2424class bsn_virtual_port_create_request(Message):
2425 version = 1
2426 type = 4
2427 experimenter = 6035143
2428 subtype = 15
2429
2430 def __init__(self, xid=None, vport=None):
2431 self.xid = xid
2432 if vport != None:
2433 self.vport = vport
2434 else:
2435 self.vport = common.bsn_vport_q_in_q()
2436
2437 def pack(self):
2438 packed = []
2439 packed.append(struct.pack("!B", self.version))
2440 packed.append(struct.pack("!B", self.type))
2441 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2442 packed.append(struct.pack("!L", self.xid))
2443 packed.append(struct.pack("!L", self.experimenter))
2444 packed.append(struct.pack("!L", self.subtype))
2445 packed.append(self.vport.pack())
2446 length = sum([len(x) for x in packed])
2447 packed[2] = struct.pack("!H", length)
2448 return ''.join(packed)
2449
2450 @staticmethod
2451 def unpack(buf):
2452 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2453 obj = bsn_virtual_port_create_request()
2454 if type(buf) == loxi.generic_util.OFReader:
2455 reader = buf
2456 else:
2457 reader = loxi.generic_util.OFReader(buf)
2458 _version = reader.read("!B")[0]
2459 assert(_version == 1)
2460 _type = reader.read("!B")[0]
2461 assert(_type == 4)
2462 _length = reader.read("!H")[0]
2463 obj.xid = reader.read("!L")[0]
2464 _experimenter = reader.read("!L")[0]
2465 assert(_experimenter == 6035143)
2466 _subtype = reader.read("!L")[0]
2467 assert(_subtype == 15)
2468 obj.vport = common.bsn_vport_q_in_q.unpack(reader)
2469 return obj
2470
2471 def __eq__(self, other):
2472 if type(self) != type(other): return False
2473 if self.version != other.version: return False
2474 if self.type != other.type: return False
2475 if self.xid != other.xid: return False
2476 if self.vport != other.vport: return False
2477 return True
2478
2479 def __ne__(self, other):
2480 return not self.__eq__(other)
2481
2482 def __str__(self):
2483 return self.show()
2484
2485 def show(self):
2486 import loxi.pp
2487 return loxi.pp.pp(self)
2488
2489 def pretty_print(self, q):
2490 q.text("bsn_virtual_port_create_request {")
2491 with q.group():
2492 with q.indent(2):
2493 q.breakable()
2494 q.text("xid = ");
2495 if self.xid != None:
2496 q.text("%#x" % self.xid)
2497 else:
2498 q.text('None')
2499 q.text(","); q.breakable()
2500 q.text("vport = ");
2501 q.pp(self.vport)
2502 q.breakable()
2503 q.text('}')
2504
2505class bsn_virtual_port_remove_reply(Message):
2506 version = 1
2507 type = 4
2508 experimenter = 6035143
2509 subtype = 26
2510
2511 def __init__(self, xid=None, status=None):
2512 self.xid = xid
2513 if status != None:
2514 self.status = status
2515 else:
2516 self.status = 0
2517
2518 def pack(self):
2519 packed = []
2520 packed.append(struct.pack("!B", self.version))
2521 packed.append(struct.pack("!B", self.type))
2522 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2523 packed.append(struct.pack("!L", self.xid))
2524 packed.append(struct.pack("!L", self.experimenter))
2525 packed.append(struct.pack("!L", self.subtype))
2526 packed.append(struct.pack("!L", self.status))
2527 length = sum([len(x) for x in packed])
2528 packed[2] = struct.pack("!H", length)
2529 return ''.join(packed)
2530
2531 @staticmethod
2532 def unpack(buf):
2533 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2534 obj = bsn_virtual_port_remove_reply()
2535 if type(buf) == loxi.generic_util.OFReader:
2536 reader = buf
2537 else:
2538 reader = loxi.generic_util.OFReader(buf)
2539 _version = reader.read("!B")[0]
2540 assert(_version == 1)
2541 _type = reader.read("!B")[0]
2542 assert(_type == 4)
2543 _length = reader.read("!H")[0]
2544 obj.xid = reader.read("!L")[0]
2545 _experimenter = reader.read("!L")[0]
2546 assert(_experimenter == 6035143)
2547 _subtype = reader.read("!L")[0]
2548 assert(_subtype == 26)
2549 obj.status = reader.read("!L")[0]
2550 return obj
2551
2552 def __eq__(self, other):
2553 if type(self) != type(other): return False
2554 if self.version != other.version: return False
2555 if self.type != other.type: return False
2556 if self.xid != other.xid: return False
2557 if self.status != other.status: return False
2558 return True
2559
2560 def __ne__(self, other):
2561 return not self.__eq__(other)
2562
2563 def __str__(self):
2564 return self.show()
2565
2566 def show(self):
2567 import loxi.pp
2568 return loxi.pp.pp(self)
2569
2570 def pretty_print(self, q):
2571 q.text("bsn_virtual_port_remove_reply {")
2572 with q.group():
2573 with q.indent(2):
2574 q.breakable()
2575 q.text("xid = ");
2576 if self.xid != None:
2577 q.text("%#x" % self.xid)
2578 else:
2579 q.text('None')
2580 q.text(","); q.breakable()
2581 q.text("status = ");
2582 q.text("%#x" % self.status)
2583 q.breakable()
2584 q.text('}')
2585
2586class bsn_virtual_port_remove_request(Message):
2587 version = 1
2588 type = 4
2589 experimenter = 6035143
2590 subtype = 17
2591
2592 def __init__(self, xid=None, vport_no=None):
2593 self.xid = xid
2594 if vport_no != None:
2595 self.vport_no = vport_no
2596 else:
2597 self.vport_no = 0
2598
2599 def pack(self):
2600 packed = []
2601 packed.append(struct.pack("!B", self.version))
2602 packed.append(struct.pack("!B", self.type))
2603 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2604 packed.append(struct.pack("!L", self.xid))
2605 packed.append(struct.pack("!L", self.experimenter))
2606 packed.append(struct.pack("!L", self.subtype))
2607 packed.append(struct.pack("!L", self.vport_no))
2608 length = sum([len(x) for x in packed])
2609 packed[2] = struct.pack("!H", length)
2610 return ''.join(packed)
2611
2612 @staticmethod
2613 def unpack(buf):
2614 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2615 obj = bsn_virtual_port_remove_request()
2616 if type(buf) == loxi.generic_util.OFReader:
2617 reader = buf
2618 else:
2619 reader = loxi.generic_util.OFReader(buf)
2620 _version = reader.read("!B")[0]
2621 assert(_version == 1)
2622 _type = reader.read("!B")[0]
2623 assert(_type == 4)
2624 _length = reader.read("!H")[0]
2625 obj.xid = reader.read("!L")[0]
2626 _experimenter = reader.read("!L")[0]
2627 assert(_experimenter == 6035143)
2628 _subtype = reader.read("!L")[0]
2629 assert(_subtype == 17)
2630 obj.vport_no = reader.read("!L")[0]
2631 return obj
2632
2633 def __eq__(self, other):
2634 if type(self) != type(other): return False
2635 if self.version != other.version: return False
2636 if self.type != other.type: return False
2637 if self.xid != other.xid: return False
2638 if self.vport_no != other.vport_no: return False
2639 return True
2640
2641 def __ne__(self, other):
2642 return not self.__eq__(other)
2643
2644 def __str__(self):
2645 return self.show()
2646
2647 def show(self):
2648 import loxi.pp
2649 return loxi.pp.pp(self)
2650
2651 def pretty_print(self, q):
2652 q.text("bsn_virtual_port_remove_request {")
2653 with q.group():
2654 with q.indent(2):
2655 q.breakable()
2656 q.text("xid = ");
2657 if self.xid != None:
2658 q.text("%#x" % self.xid)
2659 else:
2660 q.text('None')
2661 q.text(","); q.breakable()
2662 q.text("vport_no = ");
2663 q.text("%#x" % self.vport_no)
2664 q.breakable()
2665 q.text('}')
2666
Rich Laneb658ddd2013-03-12 10:15:10 -07002667class desc_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07002668 version = 1
2669 type = 17
2670 stats_type = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07002671
2672 def __init__(self, xid=None, flags=None, mfr_desc=None, hw_desc=None, sw_desc=None, serial_num=None, dp_desc=None):
2673 self.xid = xid
2674 if flags != None:
2675 self.flags = flags
2676 else:
2677 self.flags = 0
2678 if mfr_desc != None:
2679 self.mfr_desc = mfr_desc
2680 else:
2681 self.mfr_desc = ""
2682 if hw_desc != None:
2683 self.hw_desc = hw_desc
2684 else:
2685 self.hw_desc = ""
2686 if sw_desc != None:
2687 self.sw_desc = sw_desc
2688 else:
2689 self.sw_desc = ""
2690 if serial_num != None:
2691 self.serial_num = serial_num
2692 else:
2693 self.serial_num = ""
2694 if dp_desc != None:
2695 self.dp_desc = dp_desc
2696 else:
2697 self.dp_desc = ""
2698
2699 def pack(self):
2700 packed = []
2701 packed.append(struct.pack("!B", self.version))
2702 packed.append(struct.pack("!B", self.type))
2703 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2704 packed.append(struct.pack("!L", self.xid))
2705 packed.append(struct.pack("!H", self.stats_type))
2706 packed.append(struct.pack("!H", self.flags))
2707 packed.append(struct.pack("!256s", self.mfr_desc))
2708 packed.append(struct.pack("!256s", self.hw_desc))
2709 packed.append(struct.pack("!256s", self.sw_desc))
2710 packed.append(struct.pack("!32s", self.serial_num))
2711 packed.append(struct.pack("!256s", self.dp_desc))
2712 length = sum([len(x) for x in packed])
2713 packed[2] = struct.pack("!H", length)
2714 return ''.join(packed)
2715
2716 @staticmethod
2717 def unpack(buf):
2718 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2719 obj = desc_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002720 if type(buf) == loxi.generic_util.OFReader:
2721 reader = buf
2722 else:
2723 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002724 _version = reader.read("!B")[0]
2725 assert(_version == 1)
2726 _type = reader.read("!B")[0]
2727 assert(_type == 17)
2728 _length = reader.read("!H")[0]
2729 obj.xid = reader.read("!L")[0]
2730 _stats_type = reader.read("!H")[0]
2731 assert(_stats_type == 0)
2732 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002733 obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00")
2734 obj.hw_desc = reader.read("!256s")[0].rstrip("\x00")
2735 obj.sw_desc = reader.read("!256s")[0].rstrip("\x00")
2736 obj.serial_num = reader.read("!32s")[0].rstrip("\x00")
2737 obj.dp_desc = reader.read("!256s")[0].rstrip("\x00")
Rich Laneb658ddd2013-03-12 10:15:10 -07002738 return obj
2739
2740 def __eq__(self, other):
2741 if type(self) != type(other): return False
2742 if self.version != other.version: return False
2743 if self.type != other.type: return False
2744 if self.xid != other.xid: return False
2745 if self.flags != other.flags: return False
2746 if self.mfr_desc != other.mfr_desc: return False
2747 if self.hw_desc != other.hw_desc: return False
2748 if self.sw_desc != other.sw_desc: return False
2749 if self.serial_num != other.serial_num: return False
2750 if self.dp_desc != other.dp_desc: return False
2751 return True
2752
2753 def __ne__(self, other):
2754 return not self.__eq__(other)
2755
2756 def __str__(self):
2757 return self.show()
2758
2759 def show(self):
2760 import loxi.pp
2761 return loxi.pp.pp(self)
2762
2763 def pretty_print(self, q):
2764 q.text("desc_stats_reply {")
2765 with q.group():
2766 with q.indent(2):
2767 q.breakable()
2768 q.text("xid = ");
2769 if self.xid != None:
2770 q.text("%#x" % self.xid)
2771 else:
2772 q.text('None')
2773 q.text(","); q.breakable()
2774 q.text("flags = ");
2775 q.text("%#x" % self.flags)
2776 q.text(","); q.breakable()
2777 q.text("mfr_desc = ");
2778 q.pp(self.mfr_desc)
2779 q.text(","); q.breakable()
2780 q.text("hw_desc = ");
2781 q.pp(self.hw_desc)
2782 q.text(","); q.breakable()
2783 q.text("sw_desc = ");
2784 q.pp(self.sw_desc)
2785 q.text(","); q.breakable()
2786 q.text("serial_num = ");
2787 q.pp(self.serial_num)
2788 q.text(","); q.breakable()
2789 q.text("dp_desc = ");
2790 q.pp(self.dp_desc)
2791 q.breakable()
2792 q.text('}')
2793
2794class desc_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07002795 version = 1
2796 type = 16
2797 stats_type = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07002798
2799 def __init__(self, xid=None, flags=None):
2800 self.xid = xid
2801 if flags != None:
2802 self.flags = flags
2803 else:
2804 self.flags = 0
2805
2806 def pack(self):
2807 packed = []
2808 packed.append(struct.pack("!B", self.version))
2809 packed.append(struct.pack("!B", self.type))
2810 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2811 packed.append(struct.pack("!L", self.xid))
2812 packed.append(struct.pack("!H", self.stats_type))
2813 packed.append(struct.pack("!H", self.flags))
2814 length = sum([len(x) for x in packed])
2815 packed[2] = struct.pack("!H", length)
2816 return ''.join(packed)
2817
2818 @staticmethod
2819 def unpack(buf):
2820 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2821 obj = desc_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002822 if type(buf) == loxi.generic_util.OFReader:
2823 reader = buf
2824 else:
2825 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002826 _version = reader.read("!B")[0]
2827 assert(_version == 1)
2828 _type = reader.read("!B")[0]
2829 assert(_type == 16)
2830 _length = reader.read("!H")[0]
2831 obj.xid = reader.read("!L")[0]
2832 _stats_type = reader.read("!H")[0]
2833 assert(_stats_type == 0)
2834 obj.flags = reader.read("!H")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07002835 return obj
2836
2837 def __eq__(self, other):
2838 if type(self) != type(other): return False
2839 if self.version != other.version: return False
2840 if self.type != other.type: return False
2841 if self.xid != other.xid: return False
2842 if self.flags != other.flags: return False
2843 return True
2844
2845 def __ne__(self, other):
2846 return not self.__eq__(other)
2847
2848 def __str__(self):
2849 return self.show()
2850
2851 def show(self):
2852 import loxi.pp
2853 return loxi.pp.pp(self)
2854
2855 def pretty_print(self, q):
2856 q.text("desc_stats_request {")
2857 with q.group():
2858 with q.indent(2):
2859 q.breakable()
2860 q.text("xid = ");
2861 if self.xid != None:
2862 q.text("%#x" % self.xid)
2863 else:
2864 q.text('None')
2865 q.text(","); q.breakable()
2866 q.text("flags = ");
2867 q.text("%#x" % self.flags)
2868 q.breakable()
2869 q.text('}')
2870
2871class echo_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07002872 version = 1
2873 type = 3
Rich Laneb658ddd2013-03-12 10:15:10 -07002874
2875 def __init__(self, xid=None, data=None):
2876 self.xid = xid
2877 if data != None:
2878 self.data = data
2879 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002880 self.data = ''
Rich Laneb658ddd2013-03-12 10:15:10 -07002881
2882 def pack(self):
2883 packed = []
2884 packed.append(struct.pack("!B", self.version))
2885 packed.append(struct.pack("!B", self.type))
2886 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2887 packed.append(struct.pack("!L", self.xid))
2888 packed.append(self.data)
2889 length = sum([len(x) for x in packed])
2890 packed[2] = struct.pack("!H", length)
2891 return ''.join(packed)
2892
2893 @staticmethod
2894 def unpack(buf):
2895 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2896 obj = echo_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002897 if type(buf) == loxi.generic_util.OFReader:
2898 reader = buf
2899 else:
2900 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002901 _version = reader.read("!B")[0]
2902 assert(_version == 1)
2903 _type = reader.read("!B")[0]
2904 assert(_type == 3)
2905 _length = reader.read("!H")[0]
2906 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002907 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07002908 return obj
2909
2910 def __eq__(self, other):
2911 if type(self) != type(other): return False
2912 if self.version != other.version: return False
2913 if self.type != other.type: return False
2914 if self.xid != other.xid: return False
2915 if self.data != other.data: return False
2916 return True
2917
2918 def __ne__(self, other):
2919 return not self.__eq__(other)
2920
2921 def __str__(self):
2922 return self.show()
2923
2924 def show(self):
2925 import loxi.pp
2926 return loxi.pp.pp(self)
2927
2928 def pretty_print(self, q):
2929 q.text("echo_reply {")
2930 with q.group():
2931 with q.indent(2):
2932 q.breakable()
2933 q.text("xid = ");
2934 if self.xid != None:
2935 q.text("%#x" % self.xid)
2936 else:
2937 q.text('None')
2938 q.text(","); q.breakable()
2939 q.text("data = ");
2940 q.pp(self.data)
2941 q.breakable()
2942 q.text('}')
2943
2944class echo_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07002945 version = 1
2946 type = 2
Rich Laneb658ddd2013-03-12 10:15:10 -07002947
2948 def __init__(self, xid=None, data=None):
2949 self.xid = xid
2950 if data != None:
2951 self.data = data
2952 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002953 self.data = ''
Rich Laneb658ddd2013-03-12 10:15:10 -07002954
2955 def pack(self):
2956 packed = []
2957 packed.append(struct.pack("!B", self.version))
2958 packed.append(struct.pack("!B", self.type))
2959 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2960 packed.append(struct.pack("!L", self.xid))
2961 packed.append(self.data)
2962 length = sum([len(x) for x in packed])
2963 packed[2] = struct.pack("!H", length)
2964 return ''.join(packed)
2965
2966 @staticmethod
2967 def unpack(buf):
2968 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2969 obj = echo_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002970 if type(buf) == loxi.generic_util.OFReader:
2971 reader = buf
2972 else:
2973 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002974 _version = reader.read("!B")[0]
2975 assert(_version == 1)
2976 _type = reader.read("!B")[0]
2977 assert(_type == 2)
2978 _length = reader.read("!H")[0]
2979 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002980 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07002981 return obj
2982
2983 def __eq__(self, other):
2984 if type(self) != type(other): return False
2985 if self.version != other.version: return False
2986 if self.type != other.type: return False
2987 if self.xid != other.xid: return False
2988 if self.data != other.data: return False
2989 return True
2990
2991 def __ne__(self, other):
2992 return not self.__eq__(other)
2993
2994 def __str__(self):
2995 return self.show()
2996
2997 def show(self):
2998 import loxi.pp
2999 return loxi.pp.pp(self)
3000
3001 def pretty_print(self, q):
3002 q.text("echo_request {")
3003 with q.group():
3004 with q.indent(2):
3005 q.breakable()
3006 q.text("xid = ");
3007 if self.xid != None:
3008 q.text("%#x" % self.xid)
3009 else:
3010 q.text('None')
3011 q.text(","); q.breakable()
3012 q.text("data = ");
3013 q.pp(self.data)
3014 q.breakable()
3015 q.text('}')
3016
3017class error_msg(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003018 version = 1
3019 type = 1
Rich Laneb658ddd2013-03-12 10:15:10 -07003020
3021 def __init__(self, xid=None, err_type=None, code=None, data=None):
3022 self.xid = xid
3023 if err_type != None:
3024 self.err_type = err_type
3025 else:
3026 self.err_type = 0
3027 if code != None:
3028 self.code = code
3029 else:
3030 self.code = 0
3031 if data != None:
3032 self.data = data
3033 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003034 self.data = ''
Rich Laneb658ddd2013-03-12 10:15:10 -07003035
3036 def pack(self):
3037 packed = []
3038 packed.append(struct.pack("!B", self.version))
3039 packed.append(struct.pack("!B", self.type))
3040 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3041 packed.append(struct.pack("!L", self.xid))
3042 packed.append(struct.pack("!H", self.err_type))
3043 packed.append(struct.pack("!H", self.code))
3044 packed.append(self.data)
3045 length = sum([len(x) for x in packed])
3046 packed[2] = struct.pack("!H", length)
3047 return ''.join(packed)
3048
3049 @staticmethod
3050 def unpack(buf):
3051 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3052 obj = error_msg()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003053 if type(buf) == loxi.generic_util.OFReader:
3054 reader = buf
3055 else:
3056 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003057 _version = reader.read("!B")[0]
3058 assert(_version == 1)
3059 _type = reader.read("!B")[0]
3060 assert(_type == 1)
3061 _length = reader.read("!H")[0]
3062 obj.xid = reader.read("!L")[0]
3063 obj.err_type = reader.read("!H")[0]
3064 obj.code = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003065 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07003066 return obj
3067
3068 def __eq__(self, other):
3069 if type(self) != type(other): return False
3070 if self.version != other.version: return False
3071 if self.type != other.type: return False
3072 if self.xid != other.xid: return False
3073 if self.err_type != other.err_type: return False
3074 if self.code != other.code: return False
3075 if self.data != other.data: return False
3076 return True
3077
3078 def __ne__(self, other):
3079 return not self.__eq__(other)
3080
3081 def __str__(self):
3082 return self.show()
3083
3084 def show(self):
3085 import loxi.pp
3086 return loxi.pp.pp(self)
3087
3088 def pretty_print(self, q):
3089 q.text("error_msg {")
3090 with q.group():
3091 with q.indent(2):
3092 q.breakable()
3093 q.text("xid = ");
3094 if self.xid != None:
3095 q.text("%#x" % self.xid)
3096 else:
3097 q.text('None')
3098 q.text(","); q.breakable()
3099 q.text("err_type = ");
3100 q.text("%#x" % self.err_type)
3101 q.text(","); q.breakable()
3102 q.text("code = ");
3103 q.text("%#x" % self.code)
3104 q.text(","); q.breakable()
3105 q.text("data = ");
3106 q.pp(self.data)
3107 q.breakable()
3108 q.text('}')
3109
3110class experimenter_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003111 version = 1
3112 type = 17
3113 stats_type = 65535
Rich Laneb658ddd2013-03-12 10:15:10 -07003114
3115 def __init__(self, xid=None, flags=None, experimenter=None, data=None):
3116 self.xid = xid
3117 if flags != None:
3118 self.flags = flags
3119 else:
3120 self.flags = 0
3121 if experimenter != None:
3122 self.experimenter = experimenter
3123 else:
3124 self.experimenter = 0
3125 if data != None:
3126 self.data = data
3127 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003128 self.data = ''
Rich Laneb658ddd2013-03-12 10:15:10 -07003129
3130 def pack(self):
3131 packed = []
3132 packed.append(struct.pack("!B", self.version))
3133 packed.append(struct.pack("!B", self.type))
3134 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3135 packed.append(struct.pack("!L", self.xid))
3136 packed.append(struct.pack("!H", self.stats_type))
3137 packed.append(struct.pack("!H", self.flags))
3138 packed.append(struct.pack("!L", self.experimenter))
3139 packed.append(self.data)
3140 length = sum([len(x) for x in packed])
3141 packed[2] = struct.pack("!H", length)
3142 return ''.join(packed)
3143
3144 @staticmethod
3145 def unpack(buf):
3146 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3147 obj = experimenter_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003148 if type(buf) == loxi.generic_util.OFReader:
3149 reader = buf
3150 else:
3151 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003152 _version = reader.read("!B")[0]
3153 assert(_version == 1)
3154 _type = reader.read("!B")[0]
3155 assert(_type == 17)
3156 _length = reader.read("!H")[0]
3157 obj.xid = reader.read("!L")[0]
3158 _stats_type = reader.read("!H")[0]
3159 assert(_stats_type == 65535)
3160 obj.flags = reader.read("!H")[0]
3161 obj.experimenter = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003162 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07003163 return obj
3164
3165 def __eq__(self, other):
3166 if type(self) != type(other): return False
3167 if self.version != other.version: return False
3168 if self.type != other.type: return False
3169 if self.xid != other.xid: return False
3170 if self.flags != other.flags: return False
3171 if self.experimenter != other.experimenter: return False
3172 if self.data != other.data: return False
3173 return True
3174
3175 def __ne__(self, other):
3176 return not self.__eq__(other)
3177
3178 def __str__(self):
3179 return self.show()
3180
3181 def show(self):
3182 import loxi.pp
3183 return loxi.pp.pp(self)
3184
3185 def pretty_print(self, q):
3186 q.text("experimenter_stats_reply {")
3187 with q.group():
3188 with q.indent(2):
3189 q.breakable()
3190 q.text("xid = ");
3191 if self.xid != None:
3192 q.text("%#x" % self.xid)
3193 else:
3194 q.text('None')
3195 q.text(","); q.breakable()
3196 q.text("flags = ");
3197 q.text("%#x" % self.flags)
3198 q.text(","); q.breakable()
3199 q.text("experimenter = ");
3200 q.text("%#x" % self.experimenter)
3201 q.text(","); q.breakable()
3202 q.text("data = ");
3203 q.pp(self.data)
3204 q.breakable()
3205 q.text('}')
3206
3207class experimenter_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003208 version = 1
3209 type = 16
3210 stats_type = 65535
Rich Laneb658ddd2013-03-12 10:15:10 -07003211
3212 def __init__(self, xid=None, flags=None, experimenter=None, data=None):
3213 self.xid = xid
3214 if flags != None:
3215 self.flags = flags
3216 else:
3217 self.flags = 0
3218 if experimenter != None:
3219 self.experimenter = experimenter
3220 else:
3221 self.experimenter = 0
3222 if data != None:
3223 self.data = data
3224 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003225 self.data = ''
Rich Laneb658ddd2013-03-12 10:15:10 -07003226
3227 def pack(self):
3228 packed = []
3229 packed.append(struct.pack("!B", self.version))
3230 packed.append(struct.pack("!B", self.type))
3231 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3232 packed.append(struct.pack("!L", self.xid))
3233 packed.append(struct.pack("!H", self.stats_type))
3234 packed.append(struct.pack("!H", self.flags))
3235 packed.append(struct.pack("!L", self.experimenter))
3236 packed.append(self.data)
3237 length = sum([len(x) for x in packed])
3238 packed[2] = struct.pack("!H", length)
3239 return ''.join(packed)
3240
3241 @staticmethod
3242 def unpack(buf):
3243 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3244 obj = experimenter_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003245 if type(buf) == loxi.generic_util.OFReader:
3246 reader = buf
3247 else:
3248 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003249 _version = reader.read("!B")[0]
3250 assert(_version == 1)
3251 _type = reader.read("!B")[0]
3252 assert(_type == 16)
3253 _length = reader.read("!H")[0]
3254 obj.xid = reader.read("!L")[0]
3255 _stats_type = reader.read("!H")[0]
3256 assert(_stats_type == 65535)
3257 obj.flags = reader.read("!H")[0]
3258 obj.experimenter = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003259 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07003260 return obj
3261
3262 def __eq__(self, other):
3263 if type(self) != type(other): return False
3264 if self.version != other.version: return False
3265 if self.type != other.type: return False
3266 if self.xid != other.xid: return False
3267 if self.flags != other.flags: return False
3268 if self.experimenter != other.experimenter: return False
3269 if self.data != other.data: return False
3270 return True
3271
3272 def __ne__(self, other):
3273 return not self.__eq__(other)
3274
3275 def __str__(self):
3276 return self.show()
3277
3278 def show(self):
3279 import loxi.pp
3280 return loxi.pp.pp(self)
3281
3282 def pretty_print(self, q):
3283 q.text("experimenter_stats_request {")
3284 with q.group():
3285 with q.indent(2):
3286 q.breakable()
3287 q.text("xid = ");
3288 if self.xid != None:
3289 q.text("%#x" % self.xid)
3290 else:
3291 q.text('None')
3292 q.text(","); q.breakable()
3293 q.text("flags = ");
3294 q.text("%#x" % self.flags)
3295 q.text(","); q.breakable()
3296 q.text("experimenter = ");
3297 q.text("%#x" % self.experimenter)
3298 q.text(","); q.breakable()
3299 q.text("data = ");
3300 q.pp(self.data)
3301 q.breakable()
3302 q.text('}')
3303
3304class features_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003305 version = 1
3306 type = 6
Rich Laneb658ddd2013-03-12 10:15:10 -07003307
Rich Lanec2ee4b82013-04-24 17:12:38 -07003308 def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, capabilities=None, actions=None, ports=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07003309 self.xid = xid
3310 if datapath_id != None:
3311 self.datapath_id = datapath_id
3312 else:
3313 self.datapath_id = 0
3314 if n_buffers != None:
3315 self.n_buffers = n_buffers
3316 else:
3317 self.n_buffers = 0
3318 if n_tables != None:
3319 self.n_tables = n_tables
3320 else:
3321 self.n_tables = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07003322 if capabilities != None:
3323 self.capabilities = capabilities
3324 else:
3325 self.capabilities = 0
3326 if actions != None:
3327 self.actions = actions
3328 else:
3329 self.actions = 0
3330 if ports != None:
3331 self.ports = ports
3332 else:
3333 self.ports = []
3334
3335 def pack(self):
3336 packed = []
3337 packed.append(struct.pack("!B", self.version))
3338 packed.append(struct.pack("!B", self.type))
3339 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3340 packed.append(struct.pack("!L", self.xid))
3341 packed.append(struct.pack("!Q", self.datapath_id))
3342 packed.append(struct.pack("!L", self.n_buffers))
3343 packed.append(struct.pack("!B", self.n_tables))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003344 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07003345 packed.append(struct.pack("!L", self.capabilities))
3346 packed.append(struct.pack("!L", self.actions))
Dan Talaycof6202252013-07-02 01:00:29 -07003347 packed.append(util.pack_list(self.ports))
Rich Laneb658ddd2013-03-12 10:15:10 -07003348 length = sum([len(x) for x in packed])
3349 packed[2] = struct.pack("!H", length)
3350 return ''.join(packed)
3351
3352 @staticmethod
3353 def unpack(buf):
3354 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3355 obj = features_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003356 if type(buf) == loxi.generic_util.OFReader:
3357 reader = buf
3358 else:
3359 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003360 _version = reader.read("!B")[0]
3361 assert(_version == 1)
3362 _type = reader.read("!B")[0]
3363 assert(_type == 6)
3364 _length = reader.read("!H")[0]
3365 obj.xid = reader.read("!L")[0]
3366 obj.datapath_id = reader.read("!Q")[0]
3367 obj.n_buffers = reader.read("!L")[0]
3368 obj.n_tables = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003369 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07003370 obj.capabilities = reader.read("!L")[0]
3371 obj.actions = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003372 obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack)
Rich Laneb658ddd2013-03-12 10:15:10 -07003373 return obj
3374
3375 def __eq__(self, other):
3376 if type(self) != type(other): return False
3377 if self.version != other.version: return False
3378 if self.type != other.type: return False
3379 if self.xid != other.xid: return False
3380 if self.datapath_id != other.datapath_id: return False
3381 if self.n_buffers != other.n_buffers: return False
3382 if self.n_tables != other.n_tables: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07003383 if self.capabilities != other.capabilities: return False
3384 if self.actions != other.actions: return False
3385 if self.ports != other.ports: return False
3386 return True
3387
3388 def __ne__(self, other):
3389 return not self.__eq__(other)
3390
3391 def __str__(self):
3392 return self.show()
3393
3394 def show(self):
3395 import loxi.pp
3396 return loxi.pp.pp(self)
3397
3398 def pretty_print(self, q):
3399 q.text("features_reply {")
3400 with q.group():
3401 with q.indent(2):
3402 q.breakable()
3403 q.text("xid = ");
3404 if self.xid != None:
3405 q.text("%#x" % self.xid)
3406 else:
3407 q.text('None')
3408 q.text(","); q.breakable()
3409 q.text("datapath_id = ");
3410 q.text("%#x" % self.datapath_id)
3411 q.text(","); q.breakable()
3412 q.text("n_buffers = ");
3413 q.text("%#x" % self.n_buffers)
3414 q.text(","); q.breakable()
3415 q.text("n_tables = ");
3416 q.text("%#x" % self.n_tables)
3417 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07003418 q.text("capabilities = ");
3419 q.text("%#x" % self.capabilities)
3420 q.text(","); q.breakable()
3421 q.text("actions = ");
3422 q.text("%#x" % self.actions)
3423 q.text(","); q.breakable()
3424 q.text("ports = ");
3425 q.pp(self.ports)
3426 q.breakable()
3427 q.text('}')
3428
3429class features_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003430 version = 1
3431 type = 5
Rich Laneb658ddd2013-03-12 10:15:10 -07003432
3433 def __init__(self, xid=None):
3434 self.xid = xid
3435
3436 def pack(self):
3437 packed = []
3438 packed.append(struct.pack("!B", self.version))
3439 packed.append(struct.pack("!B", self.type))
3440 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3441 packed.append(struct.pack("!L", self.xid))
3442 length = sum([len(x) for x in packed])
3443 packed[2] = struct.pack("!H", length)
3444 return ''.join(packed)
3445
3446 @staticmethod
3447 def unpack(buf):
3448 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3449 obj = features_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003450 if type(buf) == loxi.generic_util.OFReader:
3451 reader = buf
3452 else:
3453 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003454 _version = reader.read("!B")[0]
3455 assert(_version == 1)
3456 _type = reader.read("!B")[0]
3457 assert(_type == 5)
3458 _length = reader.read("!H")[0]
3459 obj.xid = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07003460 return obj
3461
3462 def __eq__(self, other):
3463 if type(self) != type(other): return False
3464 if self.version != other.version: return False
3465 if self.type != other.type: return False
3466 if self.xid != other.xid: return False
3467 return True
3468
3469 def __ne__(self, other):
3470 return not self.__eq__(other)
3471
3472 def __str__(self):
3473 return self.show()
3474
3475 def show(self):
3476 import loxi.pp
3477 return loxi.pp.pp(self)
3478
3479 def pretty_print(self, q):
3480 q.text("features_request {")
3481 with q.group():
3482 with q.indent(2):
3483 q.breakable()
3484 q.text("xid = ");
3485 if self.xid != None:
3486 q.text("%#x" % self.xid)
3487 else:
3488 q.text('None')
3489 q.breakable()
3490 q.text('}')
3491
3492class flow_add(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003493 version = 1
3494 type = 14
3495 _command = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07003496
3497 def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
3498 self.xid = xid
3499 if match != None:
3500 self.match = match
3501 else:
3502 self.match = common.match()
3503 if cookie != None:
3504 self.cookie = cookie
3505 else:
3506 self.cookie = 0
3507 if idle_timeout != None:
3508 self.idle_timeout = idle_timeout
3509 else:
3510 self.idle_timeout = 0
3511 if hard_timeout != None:
3512 self.hard_timeout = hard_timeout
3513 else:
3514 self.hard_timeout = 0
3515 if priority != None:
3516 self.priority = priority
3517 else:
3518 self.priority = 0
3519 if buffer_id != None:
3520 self.buffer_id = buffer_id
3521 else:
3522 self.buffer_id = 0
3523 if out_port != None:
3524 self.out_port = out_port
3525 else:
3526 self.out_port = 0
3527 if flags != None:
3528 self.flags = flags
3529 else:
3530 self.flags = 0
3531 if actions != None:
3532 self.actions = actions
3533 else:
3534 self.actions = []
3535
3536 def pack(self):
3537 packed = []
3538 packed.append(struct.pack("!B", self.version))
3539 packed.append(struct.pack("!B", self.type))
3540 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3541 packed.append(struct.pack("!L", self.xid))
3542 packed.append(self.match.pack())
3543 packed.append(struct.pack("!Q", self.cookie))
Dan Talaycof6202252013-07-02 01:00:29 -07003544 packed.append(util.pack_fm_cmd(self._command))
Rich Laneb658ddd2013-03-12 10:15:10 -07003545 packed.append(struct.pack("!H", self.idle_timeout))
3546 packed.append(struct.pack("!H", self.hard_timeout))
3547 packed.append(struct.pack("!H", self.priority))
3548 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003549 packed.append(util.pack_port_no(self.out_port))
Rich Laneb658ddd2013-03-12 10:15:10 -07003550 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07003551 packed.append(util.pack_list(self.actions))
Rich Laneb658ddd2013-03-12 10:15:10 -07003552 length = sum([len(x) for x in packed])
3553 packed[2] = struct.pack("!H", length)
3554 return ''.join(packed)
3555
3556 @staticmethod
3557 def unpack(buf):
3558 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3559 obj = flow_add()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003560 if type(buf) == loxi.generic_util.OFReader:
3561 reader = buf
3562 else:
3563 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003564 _version = reader.read("!B")[0]
3565 assert(_version == 1)
3566 _type = reader.read("!B")[0]
3567 assert(_type == 14)
3568 _length = reader.read("!H")[0]
3569 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003570 obj.match = common.match.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07003571 obj.cookie = reader.read("!Q")[0]
3572 __command = util.unpack_fm_cmd(reader)
3573 assert(__command == 0)
3574 obj.idle_timeout = reader.read("!H")[0]
3575 obj.hard_timeout = reader.read("!H")[0]
3576 obj.priority = reader.read("!H")[0]
3577 obj.buffer_id = reader.read("!L")[0]
3578 obj.out_port = util.unpack_port_no(reader)
3579 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003580 obj.actions = action.unpack_list(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07003581 return obj
3582
3583 def __eq__(self, other):
3584 if type(self) != type(other): return False
3585 if self.version != other.version: return False
3586 if self.type != other.type: return False
3587 if self.xid != other.xid: return False
3588 if self.match != other.match: return False
3589 if self.cookie != other.cookie: return False
3590 if self.idle_timeout != other.idle_timeout: return False
3591 if self.hard_timeout != other.hard_timeout: return False
3592 if self.priority != other.priority: return False
3593 if self.buffer_id != other.buffer_id: return False
3594 if self.out_port != other.out_port: return False
3595 if self.flags != other.flags: return False
3596 if self.actions != other.actions: return False
3597 return True
3598
3599 def __ne__(self, other):
3600 return not self.__eq__(other)
3601
3602 def __str__(self):
3603 return self.show()
3604
3605 def show(self):
3606 import loxi.pp
3607 return loxi.pp.pp(self)
3608
3609 def pretty_print(self, q):
3610 q.text("flow_add {")
3611 with q.group():
3612 with q.indent(2):
3613 q.breakable()
3614 q.text("xid = ");
3615 if self.xid != None:
3616 q.text("%#x" % self.xid)
3617 else:
3618 q.text('None')
3619 q.text(","); q.breakable()
3620 q.text("match = ");
3621 q.pp(self.match)
3622 q.text(","); q.breakable()
3623 q.text("cookie = ");
3624 q.text("%#x" % self.cookie)
3625 q.text(","); q.breakable()
3626 q.text("idle_timeout = ");
3627 q.text("%#x" % self.idle_timeout)
3628 q.text(","); q.breakable()
3629 q.text("hard_timeout = ");
3630 q.text("%#x" % self.hard_timeout)
3631 q.text(","); q.breakable()
3632 q.text("priority = ");
3633 q.text("%#x" % self.priority)
3634 q.text(","); q.breakable()
3635 q.text("buffer_id = ");
3636 q.text("%#x" % self.buffer_id)
3637 q.text(","); q.breakable()
3638 q.text("out_port = ");
3639 q.text(util.pretty_port(self.out_port))
3640 q.text(","); q.breakable()
3641 q.text("flags = ");
3642 q.text("%#x" % self.flags)
3643 q.text(","); q.breakable()
3644 q.text("actions = ");
3645 q.pp(self.actions)
3646 q.breakable()
3647 q.text('}')
3648
3649class flow_delete(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003650 version = 1
3651 type = 14
3652 _command = 3
Rich Laneb658ddd2013-03-12 10:15:10 -07003653
3654 def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
3655 self.xid = xid
3656 if match != None:
3657 self.match = match
3658 else:
3659 self.match = common.match()
3660 if cookie != None:
3661 self.cookie = cookie
3662 else:
3663 self.cookie = 0
3664 if idle_timeout != None:
3665 self.idle_timeout = idle_timeout
3666 else:
3667 self.idle_timeout = 0
3668 if hard_timeout != None:
3669 self.hard_timeout = hard_timeout
3670 else:
3671 self.hard_timeout = 0
3672 if priority != None:
3673 self.priority = priority
3674 else:
3675 self.priority = 0
3676 if buffer_id != None:
3677 self.buffer_id = buffer_id
3678 else:
3679 self.buffer_id = 0
3680 if out_port != None:
3681 self.out_port = out_port
3682 else:
3683 self.out_port = 0
3684 if flags != None:
3685 self.flags = flags
3686 else:
3687 self.flags = 0
3688 if actions != None:
3689 self.actions = actions
3690 else:
3691 self.actions = []
3692
3693 def pack(self):
3694 packed = []
3695 packed.append(struct.pack("!B", self.version))
3696 packed.append(struct.pack("!B", self.type))
3697 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3698 packed.append(struct.pack("!L", self.xid))
3699 packed.append(self.match.pack())
3700 packed.append(struct.pack("!Q", self.cookie))
Dan Talaycof6202252013-07-02 01:00:29 -07003701 packed.append(util.pack_fm_cmd(self._command))
Rich Laneb658ddd2013-03-12 10:15:10 -07003702 packed.append(struct.pack("!H", self.idle_timeout))
3703 packed.append(struct.pack("!H", self.hard_timeout))
3704 packed.append(struct.pack("!H", self.priority))
3705 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003706 packed.append(util.pack_port_no(self.out_port))
Rich Laneb658ddd2013-03-12 10:15:10 -07003707 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07003708 packed.append(util.pack_list(self.actions))
Rich Laneb658ddd2013-03-12 10:15:10 -07003709 length = sum([len(x) for x in packed])
3710 packed[2] = struct.pack("!H", length)
3711 return ''.join(packed)
3712
3713 @staticmethod
3714 def unpack(buf):
3715 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3716 obj = flow_delete()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003717 if type(buf) == loxi.generic_util.OFReader:
3718 reader = buf
3719 else:
3720 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003721 _version = reader.read("!B")[0]
3722 assert(_version == 1)
3723 _type = reader.read("!B")[0]
3724 assert(_type == 14)
3725 _length = reader.read("!H")[0]
3726 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003727 obj.match = common.match.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07003728 obj.cookie = reader.read("!Q")[0]
3729 __command = util.unpack_fm_cmd(reader)
3730 assert(__command == 3)
3731 obj.idle_timeout = reader.read("!H")[0]
3732 obj.hard_timeout = reader.read("!H")[0]
3733 obj.priority = reader.read("!H")[0]
3734 obj.buffer_id = reader.read("!L")[0]
3735 obj.out_port = util.unpack_port_no(reader)
3736 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003737 obj.actions = action.unpack_list(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07003738 return obj
3739
3740 def __eq__(self, other):
3741 if type(self) != type(other): return False
3742 if self.version != other.version: return False
3743 if self.type != other.type: return False
3744 if self.xid != other.xid: return False
3745 if self.match != other.match: return False
3746 if self.cookie != other.cookie: return False
3747 if self.idle_timeout != other.idle_timeout: return False
3748 if self.hard_timeout != other.hard_timeout: return False
3749 if self.priority != other.priority: return False
3750 if self.buffer_id != other.buffer_id: return False
3751 if self.out_port != other.out_port: return False
3752 if self.flags != other.flags: return False
3753 if self.actions != other.actions: return False
3754 return True
3755
3756 def __ne__(self, other):
3757 return not self.__eq__(other)
3758
3759 def __str__(self):
3760 return self.show()
3761
3762 def show(self):
3763 import loxi.pp
3764 return loxi.pp.pp(self)
3765
3766 def pretty_print(self, q):
3767 q.text("flow_delete {")
3768 with q.group():
3769 with q.indent(2):
3770 q.breakable()
3771 q.text("xid = ");
3772 if self.xid != None:
3773 q.text("%#x" % self.xid)
3774 else:
3775 q.text('None')
3776 q.text(","); q.breakable()
3777 q.text("match = ");
3778 q.pp(self.match)
3779 q.text(","); q.breakable()
3780 q.text("cookie = ");
3781 q.text("%#x" % self.cookie)
3782 q.text(","); q.breakable()
3783 q.text("idle_timeout = ");
3784 q.text("%#x" % self.idle_timeout)
3785 q.text(","); q.breakable()
3786 q.text("hard_timeout = ");
3787 q.text("%#x" % self.hard_timeout)
3788 q.text(","); q.breakable()
3789 q.text("priority = ");
3790 q.text("%#x" % self.priority)
3791 q.text(","); q.breakable()
3792 q.text("buffer_id = ");
3793 q.text("%#x" % self.buffer_id)
3794 q.text(","); q.breakable()
3795 q.text("out_port = ");
3796 q.text(util.pretty_port(self.out_port))
3797 q.text(","); q.breakable()
3798 q.text("flags = ");
3799 q.text("%#x" % self.flags)
3800 q.text(","); q.breakable()
3801 q.text("actions = ");
3802 q.pp(self.actions)
3803 q.breakable()
3804 q.text('}')
3805
3806class flow_delete_strict(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003807 version = 1
3808 type = 14
3809 _command = 4
Rich Laneb658ddd2013-03-12 10:15:10 -07003810
3811 def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
3812 self.xid = xid
3813 if match != None:
3814 self.match = match
3815 else:
3816 self.match = common.match()
3817 if cookie != None:
3818 self.cookie = cookie
3819 else:
3820 self.cookie = 0
3821 if idle_timeout != None:
3822 self.idle_timeout = idle_timeout
3823 else:
3824 self.idle_timeout = 0
3825 if hard_timeout != None:
3826 self.hard_timeout = hard_timeout
3827 else:
3828 self.hard_timeout = 0
3829 if priority != None:
3830 self.priority = priority
3831 else:
3832 self.priority = 0
3833 if buffer_id != None:
3834 self.buffer_id = buffer_id
3835 else:
3836 self.buffer_id = 0
3837 if out_port != None:
3838 self.out_port = out_port
3839 else:
3840 self.out_port = 0
3841 if flags != None:
3842 self.flags = flags
3843 else:
3844 self.flags = 0
3845 if actions != None:
3846 self.actions = actions
3847 else:
3848 self.actions = []
3849
3850 def pack(self):
3851 packed = []
3852 packed.append(struct.pack("!B", self.version))
3853 packed.append(struct.pack("!B", self.type))
3854 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3855 packed.append(struct.pack("!L", self.xid))
3856 packed.append(self.match.pack())
3857 packed.append(struct.pack("!Q", self.cookie))
Dan Talaycof6202252013-07-02 01:00:29 -07003858 packed.append(util.pack_fm_cmd(self._command))
Rich Laneb658ddd2013-03-12 10:15:10 -07003859 packed.append(struct.pack("!H", self.idle_timeout))
3860 packed.append(struct.pack("!H", self.hard_timeout))
3861 packed.append(struct.pack("!H", self.priority))
3862 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003863 packed.append(util.pack_port_no(self.out_port))
Rich Laneb658ddd2013-03-12 10:15:10 -07003864 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07003865 packed.append(util.pack_list(self.actions))
Rich Laneb658ddd2013-03-12 10:15:10 -07003866 length = sum([len(x) for x in packed])
3867 packed[2] = struct.pack("!H", length)
3868 return ''.join(packed)
3869
3870 @staticmethod
3871 def unpack(buf):
3872 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3873 obj = flow_delete_strict()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003874 if type(buf) == loxi.generic_util.OFReader:
3875 reader = buf
3876 else:
3877 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003878 _version = reader.read("!B")[0]
3879 assert(_version == 1)
3880 _type = reader.read("!B")[0]
3881 assert(_type == 14)
3882 _length = reader.read("!H")[0]
3883 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003884 obj.match = common.match.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07003885 obj.cookie = reader.read("!Q")[0]
3886 __command = util.unpack_fm_cmd(reader)
3887 assert(__command == 4)
3888 obj.idle_timeout = reader.read("!H")[0]
3889 obj.hard_timeout = reader.read("!H")[0]
3890 obj.priority = reader.read("!H")[0]
3891 obj.buffer_id = reader.read("!L")[0]
3892 obj.out_port = util.unpack_port_no(reader)
3893 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003894 obj.actions = action.unpack_list(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07003895 return obj
3896
3897 def __eq__(self, other):
3898 if type(self) != type(other): return False
3899 if self.version != other.version: return False
3900 if self.type != other.type: return False
3901 if self.xid != other.xid: return False
3902 if self.match != other.match: return False
3903 if self.cookie != other.cookie: return False
3904 if self.idle_timeout != other.idle_timeout: return False
3905 if self.hard_timeout != other.hard_timeout: return False
3906 if self.priority != other.priority: return False
3907 if self.buffer_id != other.buffer_id: return False
3908 if self.out_port != other.out_port: return False
3909 if self.flags != other.flags: return False
3910 if self.actions != other.actions: return False
3911 return True
3912
3913 def __ne__(self, other):
3914 return not self.__eq__(other)
3915
3916 def __str__(self):
3917 return self.show()
3918
3919 def show(self):
3920 import loxi.pp
3921 return loxi.pp.pp(self)
3922
3923 def pretty_print(self, q):
3924 q.text("flow_delete_strict {")
3925 with q.group():
3926 with q.indent(2):
3927 q.breakable()
3928 q.text("xid = ");
3929 if self.xid != None:
3930 q.text("%#x" % self.xid)
3931 else:
3932 q.text('None')
3933 q.text(","); q.breakable()
3934 q.text("match = ");
3935 q.pp(self.match)
3936 q.text(","); q.breakable()
3937 q.text("cookie = ");
3938 q.text("%#x" % self.cookie)
3939 q.text(","); q.breakable()
3940 q.text("idle_timeout = ");
3941 q.text("%#x" % self.idle_timeout)
3942 q.text(","); q.breakable()
3943 q.text("hard_timeout = ");
3944 q.text("%#x" % self.hard_timeout)
3945 q.text(","); q.breakable()
3946 q.text("priority = ");
3947 q.text("%#x" % self.priority)
3948 q.text(","); q.breakable()
3949 q.text("buffer_id = ");
3950 q.text("%#x" % self.buffer_id)
3951 q.text(","); q.breakable()
3952 q.text("out_port = ");
3953 q.text(util.pretty_port(self.out_port))
3954 q.text(","); q.breakable()
3955 q.text("flags = ");
3956 q.text("%#x" % self.flags)
3957 q.text(","); q.breakable()
3958 q.text("actions = ");
3959 q.pp(self.actions)
3960 q.breakable()
3961 q.text('}')
3962
3963class flow_modify(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003964 version = 1
3965 type = 14
3966 _command = 1
Rich Laneb658ddd2013-03-12 10:15:10 -07003967
3968 def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
3969 self.xid = xid
3970 if match != None:
3971 self.match = match
3972 else:
3973 self.match = common.match()
3974 if cookie != None:
3975 self.cookie = cookie
3976 else:
3977 self.cookie = 0
3978 if idle_timeout != None:
3979 self.idle_timeout = idle_timeout
3980 else:
3981 self.idle_timeout = 0
3982 if hard_timeout != None:
3983 self.hard_timeout = hard_timeout
3984 else:
3985 self.hard_timeout = 0
3986 if priority != None:
3987 self.priority = priority
3988 else:
3989 self.priority = 0
3990 if buffer_id != None:
3991 self.buffer_id = buffer_id
3992 else:
3993 self.buffer_id = 0
3994 if out_port != None:
3995 self.out_port = out_port
3996 else:
3997 self.out_port = 0
3998 if flags != None:
3999 self.flags = flags
4000 else:
4001 self.flags = 0
4002 if actions != None:
4003 self.actions = actions
4004 else:
4005 self.actions = []
4006
4007 def pack(self):
4008 packed = []
4009 packed.append(struct.pack("!B", self.version))
4010 packed.append(struct.pack("!B", self.type))
4011 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4012 packed.append(struct.pack("!L", self.xid))
4013 packed.append(self.match.pack())
4014 packed.append(struct.pack("!Q", self.cookie))
Dan Talaycof6202252013-07-02 01:00:29 -07004015 packed.append(util.pack_fm_cmd(self._command))
Rich Laneb658ddd2013-03-12 10:15:10 -07004016 packed.append(struct.pack("!H", self.idle_timeout))
4017 packed.append(struct.pack("!H", self.hard_timeout))
4018 packed.append(struct.pack("!H", self.priority))
4019 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004020 packed.append(util.pack_port_no(self.out_port))
Rich Laneb658ddd2013-03-12 10:15:10 -07004021 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07004022 packed.append(util.pack_list(self.actions))
Rich Laneb658ddd2013-03-12 10:15:10 -07004023 length = sum([len(x) for x in packed])
4024 packed[2] = struct.pack("!H", length)
4025 return ''.join(packed)
4026
4027 @staticmethod
4028 def unpack(buf):
4029 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4030 obj = flow_modify()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004031 if type(buf) == loxi.generic_util.OFReader:
4032 reader = buf
4033 else:
4034 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004035 _version = reader.read("!B")[0]
4036 assert(_version == 1)
4037 _type = reader.read("!B")[0]
4038 assert(_type == 14)
4039 _length = reader.read("!H")[0]
4040 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004041 obj.match = common.match.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07004042 obj.cookie = reader.read("!Q")[0]
4043 __command = util.unpack_fm_cmd(reader)
4044 assert(__command == 1)
4045 obj.idle_timeout = reader.read("!H")[0]
4046 obj.hard_timeout = reader.read("!H")[0]
4047 obj.priority = reader.read("!H")[0]
4048 obj.buffer_id = reader.read("!L")[0]
4049 obj.out_port = util.unpack_port_no(reader)
4050 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004051 obj.actions = action.unpack_list(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07004052 return obj
4053
4054 def __eq__(self, other):
4055 if type(self) != type(other): return False
4056 if self.version != other.version: return False
4057 if self.type != other.type: return False
4058 if self.xid != other.xid: return False
4059 if self.match != other.match: return False
4060 if self.cookie != other.cookie: return False
4061 if self.idle_timeout != other.idle_timeout: return False
4062 if self.hard_timeout != other.hard_timeout: return False
4063 if self.priority != other.priority: return False
4064 if self.buffer_id != other.buffer_id: return False
4065 if self.out_port != other.out_port: return False
4066 if self.flags != other.flags: return False
4067 if self.actions != other.actions: return False
4068 return True
4069
4070 def __ne__(self, other):
4071 return not self.__eq__(other)
4072
4073 def __str__(self):
4074 return self.show()
4075
4076 def show(self):
4077 import loxi.pp
4078 return loxi.pp.pp(self)
4079
4080 def pretty_print(self, q):
4081 q.text("flow_modify {")
4082 with q.group():
4083 with q.indent(2):
4084 q.breakable()
4085 q.text("xid = ");
4086 if self.xid != None:
4087 q.text("%#x" % self.xid)
4088 else:
4089 q.text('None')
4090 q.text(","); q.breakable()
4091 q.text("match = ");
4092 q.pp(self.match)
4093 q.text(","); q.breakable()
4094 q.text("cookie = ");
4095 q.text("%#x" % self.cookie)
4096 q.text(","); q.breakable()
4097 q.text("idle_timeout = ");
4098 q.text("%#x" % self.idle_timeout)
4099 q.text(","); q.breakable()
4100 q.text("hard_timeout = ");
4101 q.text("%#x" % self.hard_timeout)
4102 q.text(","); q.breakable()
4103 q.text("priority = ");
4104 q.text("%#x" % self.priority)
4105 q.text(","); q.breakable()
4106 q.text("buffer_id = ");
4107 q.text("%#x" % self.buffer_id)
4108 q.text(","); q.breakable()
4109 q.text("out_port = ");
4110 q.text(util.pretty_port(self.out_port))
4111 q.text(","); q.breakable()
4112 q.text("flags = ");
4113 q.text("%#x" % self.flags)
4114 q.text(","); q.breakable()
4115 q.text("actions = ");
4116 q.pp(self.actions)
4117 q.breakable()
4118 q.text('}')
4119
4120class flow_modify_strict(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004121 version = 1
4122 type = 14
4123 _command = 2
Rich Laneb658ddd2013-03-12 10:15:10 -07004124
4125 def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
4126 self.xid = xid
4127 if match != None:
4128 self.match = match
4129 else:
4130 self.match = common.match()
4131 if cookie != None:
4132 self.cookie = cookie
4133 else:
4134 self.cookie = 0
4135 if idle_timeout != None:
4136 self.idle_timeout = idle_timeout
4137 else:
4138 self.idle_timeout = 0
4139 if hard_timeout != None:
4140 self.hard_timeout = hard_timeout
4141 else:
4142 self.hard_timeout = 0
4143 if priority != None:
4144 self.priority = priority
4145 else:
4146 self.priority = 0
4147 if buffer_id != None:
4148 self.buffer_id = buffer_id
4149 else:
4150 self.buffer_id = 0
4151 if out_port != None:
4152 self.out_port = out_port
4153 else:
4154 self.out_port = 0
4155 if flags != None:
4156 self.flags = flags
4157 else:
4158 self.flags = 0
4159 if actions != None:
4160 self.actions = actions
4161 else:
4162 self.actions = []
4163
4164 def pack(self):
4165 packed = []
4166 packed.append(struct.pack("!B", self.version))
4167 packed.append(struct.pack("!B", self.type))
4168 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4169 packed.append(struct.pack("!L", self.xid))
4170 packed.append(self.match.pack())
4171 packed.append(struct.pack("!Q", self.cookie))
Dan Talaycof6202252013-07-02 01:00:29 -07004172 packed.append(util.pack_fm_cmd(self._command))
Rich Laneb658ddd2013-03-12 10:15:10 -07004173 packed.append(struct.pack("!H", self.idle_timeout))
4174 packed.append(struct.pack("!H", self.hard_timeout))
4175 packed.append(struct.pack("!H", self.priority))
4176 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004177 packed.append(util.pack_port_no(self.out_port))
Rich Laneb658ddd2013-03-12 10:15:10 -07004178 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07004179 packed.append(util.pack_list(self.actions))
Rich Laneb658ddd2013-03-12 10:15:10 -07004180 length = sum([len(x) for x in packed])
4181 packed[2] = struct.pack("!H", length)
4182 return ''.join(packed)
4183
4184 @staticmethod
4185 def unpack(buf):
4186 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4187 obj = flow_modify_strict()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004188 if type(buf) == loxi.generic_util.OFReader:
4189 reader = buf
4190 else:
4191 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004192 _version = reader.read("!B")[0]
4193 assert(_version == 1)
4194 _type = reader.read("!B")[0]
4195 assert(_type == 14)
4196 _length = reader.read("!H")[0]
4197 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004198 obj.match = common.match.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07004199 obj.cookie = reader.read("!Q")[0]
4200 __command = util.unpack_fm_cmd(reader)
4201 assert(__command == 2)
4202 obj.idle_timeout = reader.read("!H")[0]
4203 obj.hard_timeout = reader.read("!H")[0]
4204 obj.priority = reader.read("!H")[0]
4205 obj.buffer_id = reader.read("!L")[0]
4206 obj.out_port = util.unpack_port_no(reader)
4207 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004208 obj.actions = action.unpack_list(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07004209 return obj
4210
4211 def __eq__(self, other):
4212 if type(self) != type(other): return False
4213 if self.version != other.version: return False
4214 if self.type != other.type: return False
4215 if self.xid != other.xid: return False
4216 if self.match != other.match: return False
4217 if self.cookie != other.cookie: return False
4218 if self.idle_timeout != other.idle_timeout: return False
4219 if self.hard_timeout != other.hard_timeout: return False
4220 if self.priority != other.priority: return False
4221 if self.buffer_id != other.buffer_id: return False
4222 if self.out_port != other.out_port: return False
4223 if self.flags != other.flags: return False
4224 if self.actions != other.actions: return False
4225 return True
4226
4227 def __ne__(self, other):
4228 return not self.__eq__(other)
4229
4230 def __str__(self):
4231 return self.show()
4232
4233 def show(self):
4234 import loxi.pp
4235 return loxi.pp.pp(self)
4236
4237 def pretty_print(self, q):
4238 q.text("flow_modify_strict {")
4239 with q.group():
4240 with q.indent(2):
4241 q.breakable()
4242 q.text("xid = ");
4243 if self.xid != None:
4244 q.text("%#x" % self.xid)
4245 else:
4246 q.text('None')
4247 q.text(","); q.breakable()
4248 q.text("match = ");
4249 q.pp(self.match)
4250 q.text(","); q.breakable()
4251 q.text("cookie = ");
4252 q.text("%#x" % self.cookie)
4253 q.text(","); q.breakable()
4254 q.text("idle_timeout = ");
4255 q.text("%#x" % self.idle_timeout)
4256 q.text(","); q.breakable()
4257 q.text("hard_timeout = ");
4258 q.text("%#x" % self.hard_timeout)
4259 q.text(","); q.breakable()
4260 q.text("priority = ");
4261 q.text("%#x" % self.priority)
4262 q.text(","); q.breakable()
4263 q.text("buffer_id = ");
4264 q.text("%#x" % self.buffer_id)
4265 q.text(","); q.breakable()
4266 q.text("out_port = ");
4267 q.text(util.pretty_port(self.out_port))
4268 q.text(","); q.breakable()
4269 q.text("flags = ");
4270 q.text("%#x" % self.flags)
4271 q.text(","); q.breakable()
4272 q.text("actions = ");
4273 q.pp(self.actions)
4274 q.breakable()
4275 q.text('}')
4276
4277class flow_removed(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004278 version = 1
4279 type = 11
Rich Laneb658ddd2013-03-12 10:15:10 -07004280
Rich Lanec2ee4b82013-04-24 17:12:38 -07004281 def __init__(self, xid=None, match=None, cookie=None, priority=None, reason=None, duration_sec=None, duration_nsec=None, idle_timeout=None, packet_count=None, byte_count=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07004282 self.xid = xid
4283 if match != None:
4284 self.match = match
4285 else:
4286 self.match = common.match()
4287 if cookie != None:
4288 self.cookie = cookie
4289 else:
4290 self.cookie = 0
4291 if priority != None:
4292 self.priority = priority
4293 else:
4294 self.priority = 0
4295 if reason != None:
4296 self.reason = reason
4297 else:
4298 self.reason = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07004299 if duration_sec != None:
4300 self.duration_sec = duration_sec
4301 else:
4302 self.duration_sec = 0
4303 if duration_nsec != None:
4304 self.duration_nsec = duration_nsec
4305 else:
4306 self.duration_nsec = 0
4307 if idle_timeout != None:
4308 self.idle_timeout = idle_timeout
4309 else:
4310 self.idle_timeout = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07004311 if packet_count != None:
4312 self.packet_count = packet_count
4313 else:
4314 self.packet_count = 0
4315 if byte_count != None:
4316 self.byte_count = byte_count
4317 else:
4318 self.byte_count = 0
4319
4320 def pack(self):
4321 packed = []
4322 packed.append(struct.pack("!B", self.version))
4323 packed.append(struct.pack("!B", self.type))
4324 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4325 packed.append(struct.pack("!L", self.xid))
4326 packed.append(self.match.pack())
4327 packed.append(struct.pack("!Q", self.cookie))
4328 packed.append(struct.pack("!H", self.priority))
4329 packed.append(struct.pack("!B", self.reason))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004330 packed.append('\x00' * 1)
Rich Laneb658ddd2013-03-12 10:15:10 -07004331 packed.append(struct.pack("!L", self.duration_sec))
4332 packed.append(struct.pack("!L", self.duration_nsec))
4333 packed.append(struct.pack("!H", self.idle_timeout))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004334 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -07004335 packed.append(struct.pack("!Q", self.packet_count))
4336 packed.append(struct.pack("!Q", self.byte_count))
4337 length = sum([len(x) for x in packed])
4338 packed[2] = struct.pack("!H", length)
4339 return ''.join(packed)
4340
4341 @staticmethod
4342 def unpack(buf):
4343 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4344 obj = flow_removed()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004345 if type(buf) == loxi.generic_util.OFReader:
4346 reader = buf
4347 else:
4348 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004349 _version = reader.read("!B")[0]
4350 assert(_version == 1)
4351 _type = reader.read("!B")[0]
4352 assert(_type == 11)
4353 _length = reader.read("!H")[0]
4354 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004355 obj.match = common.match.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07004356 obj.cookie = reader.read("!Q")[0]
4357 obj.priority = reader.read("!H")[0]
4358 obj.reason = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004359 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07004360 obj.duration_sec = reader.read("!L")[0]
4361 obj.duration_nsec = reader.read("!L")[0]
4362 obj.idle_timeout = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004363 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07004364 obj.packet_count = reader.read("!Q")[0]
4365 obj.byte_count = reader.read("!Q")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07004366 return obj
4367
4368 def __eq__(self, other):
4369 if type(self) != type(other): return False
4370 if self.version != other.version: return False
4371 if self.type != other.type: return False
4372 if self.xid != other.xid: return False
4373 if self.match != other.match: return False
4374 if self.cookie != other.cookie: return False
4375 if self.priority != other.priority: return False
4376 if self.reason != other.reason: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07004377 if self.duration_sec != other.duration_sec: return False
4378 if self.duration_nsec != other.duration_nsec: return False
4379 if self.idle_timeout != other.idle_timeout: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07004380 if self.packet_count != other.packet_count: return False
4381 if self.byte_count != other.byte_count: return False
4382 return True
4383
4384 def __ne__(self, other):
4385 return not self.__eq__(other)
4386
4387 def __str__(self):
4388 return self.show()
4389
4390 def show(self):
4391 import loxi.pp
4392 return loxi.pp.pp(self)
4393
4394 def pretty_print(self, q):
4395 q.text("flow_removed {")
4396 with q.group():
4397 with q.indent(2):
4398 q.breakable()
4399 q.text("xid = ");
4400 if self.xid != None:
4401 q.text("%#x" % self.xid)
4402 else:
4403 q.text('None')
4404 q.text(","); q.breakable()
4405 q.text("match = ");
4406 q.pp(self.match)
4407 q.text(","); q.breakable()
4408 q.text("cookie = ");
4409 q.text("%#x" % self.cookie)
4410 q.text(","); q.breakable()
4411 q.text("priority = ");
4412 q.text("%#x" % self.priority)
4413 q.text(","); q.breakable()
4414 q.text("reason = ");
4415 q.text("%#x" % self.reason)
4416 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07004417 q.text("duration_sec = ");
4418 q.text("%#x" % self.duration_sec)
4419 q.text(","); q.breakable()
4420 q.text("duration_nsec = ");
4421 q.text("%#x" % self.duration_nsec)
4422 q.text(","); q.breakable()
4423 q.text("idle_timeout = ");
4424 q.text("%#x" % self.idle_timeout)
4425 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07004426 q.text("packet_count = ");
4427 q.text("%#x" % self.packet_count)
4428 q.text(","); q.breakable()
4429 q.text("byte_count = ");
4430 q.text("%#x" % self.byte_count)
4431 q.breakable()
4432 q.text('}')
4433
4434class flow_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004435 version = 1
4436 type = 17
4437 stats_type = 1
Rich Laneb658ddd2013-03-12 10:15:10 -07004438
4439 def __init__(self, xid=None, flags=None, entries=None):
4440 self.xid = xid
4441 if flags != None:
4442 self.flags = flags
4443 else:
4444 self.flags = 0
4445 if entries != None:
4446 self.entries = entries
4447 else:
4448 self.entries = []
4449
4450 def pack(self):
4451 packed = []
4452 packed.append(struct.pack("!B", self.version))
4453 packed.append(struct.pack("!B", self.type))
4454 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4455 packed.append(struct.pack("!L", self.xid))
4456 packed.append(struct.pack("!H", self.stats_type))
4457 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07004458 packed.append(util.pack_list(self.entries))
Rich Laneb658ddd2013-03-12 10:15:10 -07004459 length = sum([len(x) for x in packed])
4460 packed[2] = struct.pack("!H", length)
4461 return ''.join(packed)
4462
4463 @staticmethod
4464 def unpack(buf):
4465 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4466 obj = flow_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004467 if type(buf) == loxi.generic_util.OFReader:
4468 reader = buf
4469 else:
4470 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004471 _version = reader.read("!B")[0]
4472 assert(_version == 1)
4473 _type = reader.read("!B")[0]
4474 assert(_type == 17)
4475 _length = reader.read("!H")[0]
4476 obj.xid = reader.read("!L")[0]
4477 _stats_type = reader.read("!H")[0]
4478 assert(_stats_type == 1)
4479 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004480 obj.entries = common.unpack_list_flow_stats_entry(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07004481 return obj
4482
4483 def __eq__(self, other):
4484 if type(self) != type(other): return False
4485 if self.version != other.version: return False
4486 if self.type != other.type: return False
4487 if self.xid != other.xid: return False
4488 if self.flags != other.flags: return False
4489 if self.entries != other.entries: return False
4490 return True
4491
4492 def __ne__(self, other):
4493 return not self.__eq__(other)
4494
4495 def __str__(self):
4496 return self.show()
4497
4498 def show(self):
4499 import loxi.pp
4500 return loxi.pp.pp(self)
4501
4502 def pretty_print(self, q):
4503 q.text("flow_stats_reply {")
4504 with q.group():
4505 with q.indent(2):
4506 q.breakable()
4507 q.text("xid = ");
4508 if self.xid != None:
4509 q.text("%#x" % self.xid)
4510 else:
4511 q.text('None')
4512 q.text(","); q.breakable()
4513 q.text("flags = ");
4514 q.text("%#x" % self.flags)
4515 q.text(","); q.breakable()
4516 q.text("entries = ");
4517 q.pp(self.entries)
4518 q.breakable()
4519 q.text('}')
4520
4521class flow_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004522 version = 1
4523 type = 16
4524 stats_type = 1
Rich Laneb658ddd2013-03-12 10:15:10 -07004525
Rich Lanec2ee4b82013-04-24 17:12:38 -07004526 def __init__(self, xid=None, flags=None, match=None, table_id=None, out_port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07004527 self.xid = xid
4528 if flags != None:
4529 self.flags = flags
4530 else:
4531 self.flags = 0
4532 if match != None:
4533 self.match = match
4534 else:
4535 self.match = common.match()
4536 if table_id != None:
4537 self.table_id = table_id
4538 else:
4539 self.table_id = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07004540 if out_port != None:
4541 self.out_port = out_port
4542 else:
4543 self.out_port = 0
4544
4545 def pack(self):
4546 packed = []
4547 packed.append(struct.pack("!B", self.version))
4548 packed.append(struct.pack("!B", self.type))
4549 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4550 packed.append(struct.pack("!L", self.xid))
4551 packed.append(struct.pack("!H", self.stats_type))
4552 packed.append(struct.pack("!H", self.flags))
4553 packed.append(self.match.pack())
4554 packed.append(struct.pack("!B", self.table_id))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004555 packed.append('\x00' * 1)
Dan Talaycof6202252013-07-02 01:00:29 -07004556 packed.append(util.pack_port_no(self.out_port))
Rich Laneb658ddd2013-03-12 10:15:10 -07004557 length = sum([len(x) for x in packed])
4558 packed[2] = struct.pack("!H", length)
4559 return ''.join(packed)
4560
4561 @staticmethod
4562 def unpack(buf):
4563 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4564 obj = flow_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004565 if type(buf) == loxi.generic_util.OFReader:
4566 reader = buf
4567 else:
4568 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004569 _version = reader.read("!B")[0]
4570 assert(_version == 1)
4571 _type = reader.read("!B")[0]
4572 assert(_type == 16)
4573 _length = reader.read("!H")[0]
4574 obj.xid = reader.read("!L")[0]
4575 _stats_type = reader.read("!H")[0]
4576 assert(_stats_type == 1)
4577 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004578 obj.match = common.match.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07004579 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004580 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07004581 obj.out_port = util.unpack_port_no(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07004582 return obj
4583
4584 def __eq__(self, other):
4585 if type(self) != type(other): return False
4586 if self.version != other.version: return False
4587 if self.type != other.type: return False
4588 if self.xid != other.xid: return False
4589 if self.flags != other.flags: return False
4590 if self.match != other.match: return False
4591 if self.table_id != other.table_id: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07004592 if self.out_port != other.out_port: return False
4593 return True
4594
4595 def __ne__(self, other):
4596 return not self.__eq__(other)
4597
4598 def __str__(self):
4599 return self.show()
4600
4601 def show(self):
4602 import loxi.pp
4603 return loxi.pp.pp(self)
4604
4605 def pretty_print(self, q):
4606 q.text("flow_stats_request {")
4607 with q.group():
4608 with q.indent(2):
4609 q.breakable()
4610 q.text("xid = ");
4611 if self.xid != None:
4612 q.text("%#x" % self.xid)
4613 else:
4614 q.text('None')
4615 q.text(","); q.breakable()
4616 q.text("flags = ");
4617 q.text("%#x" % self.flags)
4618 q.text(","); q.breakable()
4619 q.text("match = ");
4620 q.pp(self.match)
4621 q.text(","); q.breakable()
4622 q.text("table_id = ");
4623 q.text("%#x" % self.table_id)
4624 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07004625 q.text("out_port = ");
4626 q.text(util.pretty_port(self.out_port))
4627 q.breakable()
4628 q.text('}')
4629
4630class get_config_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004631 version = 1
4632 type = 8
Rich Laneb658ddd2013-03-12 10:15:10 -07004633
4634 def __init__(self, xid=None, flags=None, miss_send_len=None):
4635 self.xid = xid
4636 if flags != None:
4637 self.flags = flags
4638 else:
4639 self.flags = 0
4640 if miss_send_len != None:
4641 self.miss_send_len = miss_send_len
4642 else:
4643 self.miss_send_len = 0
4644
4645 def pack(self):
4646 packed = []
4647 packed.append(struct.pack("!B", self.version))
4648 packed.append(struct.pack("!B", self.type))
4649 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4650 packed.append(struct.pack("!L", self.xid))
4651 packed.append(struct.pack("!H", self.flags))
4652 packed.append(struct.pack("!H", self.miss_send_len))
4653 length = sum([len(x) for x in packed])
4654 packed[2] = struct.pack("!H", length)
4655 return ''.join(packed)
4656
4657 @staticmethod
4658 def unpack(buf):
4659 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4660 obj = get_config_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004661 if type(buf) == loxi.generic_util.OFReader:
4662 reader = buf
4663 else:
4664 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004665 _version = reader.read("!B")[0]
4666 assert(_version == 1)
4667 _type = reader.read("!B")[0]
4668 assert(_type == 8)
4669 _length = reader.read("!H")[0]
4670 obj.xid = reader.read("!L")[0]
4671 obj.flags = reader.read("!H")[0]
4672 obj.miss_send_len = reader.read("!H")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07004673 return obj
4674
4675 def __eq__(self, other):
4676 if type(self) != type(other): return False
4677 if self.version != other.version: return False
4678 if self.type != other.type: return False
4679 if self.xid != other.xid: return False
4680 if self.flags != other.flags: return False
4681 if self.miss_send_len != other.miss_send_len: return False
4682 return True
4683
4684 def __ne__(self, other):
4685 return not self.__eq__(other)
4686
4687 def __str__(self):
4688 return self.show()
4689
4690 def show(self):
4691 import loxi.pp
4692 return loxi.pp.pp(self)
4693
4694 def pretty_print(self, q):
4695 q.text("get_config_reply {")
4696 with q.group():
4697 with q.indent(2):
4698 q.breakable()
4699 q.text("xid = ");
4700 if self.xid != None:
4701 q.text("%#x" % self.xid)
4702 else:
4703 q.text('None')
4704 q.text(","); q.breakable()
4705 q.text("flags = ");
4706 q.text("%#x" % self.flags)
4707 q.text(","); q.breakable()
4708 q.text("miss_send_len = ");
4709 q.text("%#x" % self.miss_send_len)
4710 q.breakable()
4711 q.text('}')
4712
4713class get_config_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004714 version = 1
4715 type = 7
Rich Laneb658ddd2013-03-12 10:15:10 -07004716
4717 def __init__(self, xid=None):
4718 self.xid = xid
4719
4720 def pack(self):
4721 packed = []
4722 packed.append(struct.pack("!B", self.version))
4723 packed.append(struct.pack("!B", self.type))
4724 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4725 packed.append(struct.pack("!L", self.xid))
4726 length = sum([len(x) for x in packed])
4727 packed[2] = struct.pack("!H", length)
4728 return ''.join(packed)
4729
4730 @staticmethod
4731 def unpack(buf):
4732 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4733 obj = get_config_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004734 if type(buf) == loxi.generic_util.OFReader:
4735 reader = buf
4736 else:
4737 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004738 _version = reader.read("!B")[0]
4739 assert(_version == 1)
4740 _type = reader.read("!B")[0]
4741 assert(_type == 7)
4742 _length = reader.read("!H")[0]
4743 obj.xid = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07004744 return obj
4745
4746 def __eq__(self, other):
4747 if type(self) != type(other): return False
4748 if self.version != other.version: return False
4749 if self.type != other.type: return False
4750 if self.xid != other.xid: return False
4751 return True
4752
4753 def __ne__(self, other):
4754 return not self.__eq__(other)
4755
4756 def __str__(self):
4757 return self.show()
4758
4759 def show(self):
4760 import loxi.pp
4761 return loxi.pp.pp(self)
4762
4763 def pretty_print(self, q):
4764 q.text("get_config_request {")
4765 with q.group():
4766 with q.indent(2):
4767 q.breakable()
4768 q.text("xid = ");
4769 if self.xid != None:
4770 q.text("%#x" % self.xid)
4771 else:
4772 q.text('None')
4773 q.breakable()
4774 q.text('}')
4775
4776class hello(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004777 version = 1
4778 type = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07004779
4780 def __init__(self, xid=None):
4781 self.xid = xid
4782
4783 def pack(self):
4784 packed = []
4785 packed.append(struct.pack("!B", self.version))
4786 packed.append(struct.pack("!B", self.type))
4787 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4788 packed.append(struct.pack("!L", self.xid))
4789 length = sum([len(x) for x in packed])
4790 packed[2] = struct.pack("!H", length)
4791 return ''.join(packed)
4792
4793 @staticmethod
4794 def unpack(buf):
4795 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4796 obj = hello()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004797 if type(buf) == loxi.generic_util.OFReader:
4798 reader = buf
4799 else:
4800 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004801 _version = reader.read("!B")[0]
4802 assert(_version == 1)
4803 _type = reader.read("!B")[0]
4804 assert(_type == 0)
4805 _length = reader.read("!H")[0]
4806 obj.xid = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07004807 return obj
4808
4809 def __eq__(self, other):
4810 if type(self) != type(other): return False
4811 if self.version != other.version: return False
4812 if self.type != other.type: return False
4813 if self.xid != other.xid: return False
4814 return True
4815
4816 def __ne__(self, other):
4817 return not self.__eq__(other)
4818
4819 def __str__(self):
4820 return self.show()
4821
4822 def show(self):
4823 import loxi.pp
4824 return loxi.pp.pp(self)
4825
4826 def pretty_print(self, q):
4827 q.text("hello {")
4828 with q.group():
4829 with q.indent(2):
4830 q.breakable()
4831 q.text("xid = ");
4832 if self.xid != None:
4833 q.text("%#x" % self.xid)
4834 else:
4835 q.text('None')
4836 q.breakable()
4837 q.text('}')
4838
4839class nicira_controller_role_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004840 version = 1
4841 type = 4
4842 experimenter = 8992
Rich Laneb658ddd2013-03-12 10:15:10 -07004843 subtype = 11
4844
4845 def __init__(self, xid=None, role=None):
4846 self.xid = xid
4847 if role != None:
4848 self.role = role
4849 else:
4850 self.role = 0
4851
4852 def pack(self):
4853 packed = []
4854 packed.append(struct.pack("!B", self.version))
4855 packed.append(struct.pack("!B", self.type))
4856 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4857 packed.append(struct.pack("!L", self.xid))
4858 packed.append(struct.pack("!L", self.experimenter))
4859 packed.append(struct.pack("!L", self.subtype))
4860 packed.append(struct.pack("!L", self.role))
4861 length = sum([len(x) for x in packed])
4862 packed[2] = struct.pack("!H", length)
4863 return ''.join(packed)
4864
4865 @staticmethod
4866 def unpack(buf):
4867 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4868 obj = nicira_controller_role_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004869 if type(buf) == loxi.generic_util.OFReader:
4870 reader = buf
4871 else:
4872 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004873 _version = reader.read("!B")[0]
4874 assert(_version == 1)
4875 _type = reader.read("!B")[0]
4876 assert(_type == 4)
4877 _length = reader.read("!H")[0]
4878 obj.xid = reader.read("!L")[0]
4879 _experimenter = reader.read("!L")[0]
4880 assert(_experimenter == 8992)
4881 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004882 assert(_subtype == 11)
Dan Talaycof6202252013-07-02 01:00:29 -07004883 obj.role = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07004884 return obj
4885
4886 def __eq__(self, other):
4887 if type(self) != type(other): return False
4888 if self.version != other.version: return False
4889 if self.type != other.type: return False
4890 if self.xid != other.xid: return False
4891 if self.role != other.role: return False
4892 return True
4893
4894 def __ne__(self, other):
4895 return not self.__eq__(other)
4896
4897 def __str__(self):
4898 return self.show()
4899
4900 def show(self):
4901 import loxi.pp
4902 return loxi.pp.pp(self)
4903
4904 def pretty_print(self, q):
4905 q.text("nicira_controller_role_reply {")
4906 with q.group():
4907 with q.indent(2):
4908 q.breakable()
4909 q.text("xid = ");
4910 if self.xid != None:
4911 q.text("%#x" % self.xid)
4912 else:
4913 q.text('None')
4914 q.text(","); q.breakable()
4915 q.text("role = ");
4916 q.text("%#x" % self.role)
4917 q.breakable()
4918 q.text('}')
4919
4920class nicira_controller_role_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004921 version = 1
4922 type = 4
4923 experimenter = 8992
Rich Laneb658ddd2013-03-12 10:15:10 -07004924 subtype = 10
4925
4926 def __init__(self, xid=None, role=None):
4927 self.xid = xid
4928 if role != None:
4929 self.role = role
4930 else:
4931 self.role = 0
4932
4933 def pack(self):
4934 packed = []
4935 packed.append(struct.pack("!B", self.version))
4936 packed.append(struct.pack("!B", self.type))
4937 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4938 packed.append(struct.pack("!L", self.xid))
4939 packed.append(struct.pack("!L", self.experimenter))
4940 packed.append(struct.pack("!L", self.subtype))
4941 packed.append(struct.pack("!L", self.role))
4942 length = sum([len(x) for x in packed])
4943 packed[2] = struct.pack("!H", length)
4944 return ''.join(packed)
4945
4946 @staticmethod
4947 def unpack(buf):
4948 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4949 obj = nicira_controller_role_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004950 if type(buf) == loxi.generic_util.OFReader:
4951 reader = buf
4952 else:
4953 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004954 _version = reader.read("!B")[0]
4955 assert(_version == 1)
4956 _type = reader.read("!B")[0]
4957 assert(_type == 4)
4958 _length = reader.read("!H")[0]
4959 obj.xid = reader.read("!L")[0]
4960 _experimenter = reader.read("!L")[0]
4961 assert(_experimenter == 8992)
4962 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004963 assert(_subtype == 10)
Dan Talaycof6202252013-07-02 01:00:29 -07004964 obj.role = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07004965 return obj
4966
4967 def __eq__(self, other):
4968 if type(self) != type(other): return False
4969 if self.version != other.version: return False
4970 if self.type != other.type: return False
4971 if self.xid != other.xid: return False
4972 if self.role != other.role: return False
4973 return True
4974
4975 def __ne__(self, other):
4976 return not self.__eq__(other)
4977
4978 def __str__(self):
4979 return self.show()
4980
4981 def show(self):
4982 import loxi.pp
4983 return loxi.pp.pp(self)
4984
4985 def pretty_print(self, q):
4986 q.text("nicira_controller_role_request {")
4987 with q.group():
4988 with q.indent(2):
4989 q.breakable()
4990 q.text("xid = ");
4991 if self.xid != None:
4992 q.text("%#x" % self.xid)
4993 else:
4994 q.text('None')
4995 q.text(","); q.breakable()
4996 q.text("role = ");
4997 q.text("%#x" % self.role)
4998 q.breakable()
4999 q.text('}')
5000
5001class packet_in(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005002 version = 1
5003 type = 10
Rich Laneb658ddd2013-03-12 10:15:10 -07005004
Rich Lanec2ee4b82013-04-24 17:12:38 -07005005 def __init__(self, xid=None, buffer_id=None, total_len=None, in_port=None, reason=None, data=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07005006 self.xid = xid
5007 if buffer_id != None:
5008 self.buffer_id = buffer_id
5009 else:
5010 self.buffer_id = 0
5011 if total_len != None:
5012 self.total_len = total_len
5013 else:
5014 self.total_len = 0
5015 if in_port != None:
5016 self.in_port = in_port
5017 else:
5018 self.in_port = 0
5019 if reason != None:
5020 self.reason = reason
5021 else:
5022 self.reason = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07005023 if data != None:
5024 self.data = data
5025 else:
Dan Talaycof6202252013-07-02 01:00:29 -07005026 self.data = ''
Rich Laneb658ddd2013-03-12 10:15:10 -07005027
5028 def pack(self):
5029 packed = []
5030 packed.append(struct.pack("!B", self.version))
5031 packed.append(struct.pack("!B", self.type))
5032 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5033 packed.append(struct.pack("!L", self.xid))
5034 packed.append(struct.pack("!L", self.buffer_id))
5035 packed.append(struct.pack("!H", self.total_len))
Dan Talaycof6202252013-07-02 01:00:29 -07005036 packed.append(util.pack_port_no(self.in_port))
Rich Laneb658ddd2013-03-12 10:15:10 -07005037 packed.append(struct.pack("!B", self.reason))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005038 packed.append('\x00' * 1)
Rich Laneb658ddd2013-03-12 10:15:10 -07005039 packed.append(self.data)
5040 length = sum([len(x) for x in packed])
5041 packed[2] = struct.pack("!H", length)
5042 return ''.join(packed)
5043
5044 @staticmethod
5045 def unpack(buf):
5046 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5047 obj = packet_in()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005048 if type(buf) == loxi.generic_util.OFReader:
5049 reader = buf
5050 else:
5051 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005052 _version = reader.read("!B")[0]
5053 assert(_version == 1)
5054 _type = reader.read("!B")[0]
5055 assert(_type == 10)
5056 _length = reader.read("!H")[0]
5057 obj.xid = reader.read("!L")[0]
5058 obj.buffer_id = reader.read("!L")[0]
5059 obj.total_len = reader.read("!H")[0]
5060 obj.in_port = util.unpack_port_no(reader)
5061 obj.reason = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005062 reader.skip(1)
5063 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07005064 return obj
5065
5066 def __eq__(self, other):
5067 if type(self) != type(other): return False
5068 if self.version != other.version: return False
5069 if self.type != other.type: return False
5070 if self.xid != other.xid: return False
5071 if self.buffer_id != other.buffer_id: return False
5072 if self.total_len != other.total_len: return False
5073 if self.in_port != other.in_port: return False
5074 if self.reason != other.reason: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07005075 if self.data != other.data: return False
5076 return True
5077
5078 def __ne__(self, other):
5079 return not self.__eq__(other)
5080
5081 def __str__(self):
5082 return self.show()
5083
5084 def show(self):
5085 import loxi.pp
5086 return loxi.pp.pp(self)
5087
5088 def pretty_print(self, q):
5089 q.text("packet_in {")
5090 with q.group():
5091 with q.indent(2):
5092 q.breakable()
5093 q.text("xid = ");
5094 if self.xid != None:
5095 q.text("%#x" % self.xid)
5096 else:
5097 q.text('None')
5098 q.text(","); q.breakable()
5099 q.text("buffer_id = ");
5100 q.text("%#x" % self.buffer_id)
5101 q.text(","); q.breakable()
5102 q.text("total_len = ");
5103 q.text("%#x" % self.total_len)
5104 q.text(","); q.breakable()
5105 q.text("in_port = ");
5106 q.text(util.pretty_port(self.in_port))
5107 q.text(","); q.breakable()
5108 q.text("reason = ");
5109 q.text("%#x" % self.reason)
5110 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07005111 q.text("data = ");
5112 q.pp(self.data)
5113 q.breakable()
5114 q.text('}')
5115
5116class packet_out(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005117 version = 1
5118 type = 13
Rich Laneb658ddd2013-03-12 10:15:10 -07005119
5120 def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None):
5121 self.xid = xid
5122 if buffer_id != None:
5123 self.buffer_id = buffer_id
5124 else:
Rich Laneff637c92013-04-04 13:57:09 -07005125 self.buffer_id = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07005126 if in_port != None:
5127 self.in_port = in_port
5128 else:
5129 self.in_port = 0
5130 if actions != None:
5131 self.actions = actions
5132 else:
5133 self.actions = []
5134 if data != None:
5135 self.data = data
5136 else:
Dan Talaycof6202252013-07-02 01:00:29 -07005137 self.data = ''
Rich Laneb658ddd2013-03-12 10:15:10 -07005138
5139 def pack(self):
5140 packed = []
5141 packed.append(struct.pack("!B", self.version))
5142 packed.append(struct.pack("!B", self.type))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005143 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
Rich Laneb658ddd2013-03-12 10:15:10 -07005144 packed.append(struct.pack("!L", self.xid))
5145 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07005146 packed.append(util.pack_port_no(self.in_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005147 packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6
Dan Talaycof6202252013-07-02 01:00:29 -07005148 packed.append(util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005149 packed[6] = struct.pack("!H", len(packed[-1]))
Rich Laneb658ddd2013-03-12 10:15:10 -07005150 packed.append(self.data)
5151 length = sum([len(x) for x in packed])
5152 packed[2] = struct.pack("!H", length)
5153 return ''.join(packed)
5154
5155 @staticmethod
5156 def unpack(buf):
5157 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5158 obj = packet_out()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005159 if type(buf) == loxi.generic_util.OFReader:
5160 reader = buf
5161 else:
5162 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005163 _version = reader.read("!B")[0]
5164 assert(_version == 1)
5165 _type = reader.read("!B")[0]
5166 assert(_type == 13)
5167 _length = reader.read("!H")[0]
5168 obj.xid = reader.read("!L")[0]
5169 obj.buffer_id = reader.read("!L")[0]
5170 obj.in_port = util.unpack_port_no(reader)
5171 _actions_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005172 obj.actions = action.unpack_list(reader.slice(_actions_len))
5173 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07005174 return obj
5175
5176 def __eq__(self, other):
5177 if type(self) != type(other): return False
5178 if self.version != other.version: return False
5179 if self.type != other.type: return False
5180 if self.xid != other.xid: return False
5181 if self.buffer_id != other.buffer_id: return False
5182 if self.in_port != other.in_port: return False
5183 if self.actions != other.actions: return False
5184 if self.data != other.data: return False
5185 return True
5186
5187 def __ne__(self, other):
5188 return not self.__eq__(other)
5189
5190 def __str__(self):
5191 return self.show()
5192
5193 def show(self):
5194 import loxi.pp
5195 return loxi.pp.pp(self)
5196
5197 def pretty_print(self, q):
5198 q.text("packet_out {")
5199 with q.group():
5200 with q.indent(2):
5201 q.breakable()
5202 q.text("xid = ");
5203 if self.xid != None:
5204 q.text("%#x" % self.xid)
5205 else:
5206 q.text('None')
5207 q.text(","); q.breakable()
5208 q.text("buffer_id = ");
5209 q.text("%#x" % self.buffer_id)
5210 q.text(","); q.breakable()
5211 q.text("in_port = ");
5212 q.text(util.pretty_port(self.in_port))
5213 q.text(","); q.breakable()
5214 q.text("actions = ");
5215 q.pp(self.actions)
5216 q.text(","); q.breakable()
5217 q.text("data = ");
5218 q.pp(self.data)
5219 q.breakable()
5220 q.text('}')
5221
5222class port_mod(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005223 version = 1
5224 type = 15
Rich Laneb658ddd2013-03-12 10:15:10 -07005225
Rich Lanec2ee4b82013-04-24 17:12:38 -07005226 def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07005227 self.xid = xid
5228 if port_no != None:
5229 self.port_no = port_no
5230 else:
5231 self.port_no = 0
5232 if hw_addr != None:
5233 self.hw_addr = hw_addr
5234 else:
5235 self.hw_addr = [0,0,0,0,0,0]
5236 if config != None:
5237 self.config = config
5238 else:
5239 self.config = 0
5240 if mask != None:
5241 self.mask = mask
5242 else:
5243 self.mask = 0
5244 if advertise != None:
5245 self.advertise = advertise
5246 else:
5247 self.advertise = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07005248
5249 def pack(self):
5250 packed = []
5251 packed.append(struct.pack("!B", self.version))
5252 packed.append(struct.pack("!B", self.type))
5253 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5254 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07005255 packed.append(util.pack_port_no(self.port_no))
Rich Laneb658ddd2013-03-12 10:15:10 -07005256 packed.append(struct.pack("!6B", *self.hw_addr))
5257 packed.append(struct.pack("!L", self.config))
5258 packed.append(struct.pack("!L", self.mask))
5259 packed.append(struct.pack("!L", self.advertise))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005260 packed.append('\x00' * 4)
Rich Laneb658ddd2013-03-12 10:15:10 -07005261 length = sum([len(x) for x in packed])
5262 packed[2] = struct.pack("!H", length)
5263 return ''.join(packed)
5264
5265 @staticmethod
5266 def unpack(buf):
5267 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5268 obj = port_mod()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005269 if type(buf) == loxi.generic_util.OFReader:
5270 reader = buf
5271 else:
5272 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005273 _version = reader.read("!B")[0]
5274 assert(_version == 1)
5275 _type = reader.read("!B")[0]
5276 assert(_type == 15)
5277 _length = reader.read("!H")[0]
5278 obj.xid = reader.read("!L")[0]
5279 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005280 obj.hw_addr = list(reader.read('!6B'))
Dan Talaycof6202252013-07-02 01:00:29 -07005281 obj.config = reader.read("!L")[0]
5282 obj.mask = reader.read("!L")[0]
5283 obj.advertise = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005284 reader.skip(4)
Rich Laneb658ddd2013-03-12 10:15:10 -07005285 return obj
5286
5287 def __eq__(self, other):
5288 if type(self) != type(other): return False
5289 if self.version != other.version: return False
5290 if self.type != other.type: return False
5291 if self.xid != other.xid: return False
5292 if self.port_no != other.port_no: return False
5293 if self.hw_addr != other.hw_addr: return False
5294 if self.config != other.config: return False
5295 if self.mask != other.mask: return False
5296 if self.advertise != other.advertise: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07005297 return True
5298
5299 def __ne__(self, other):
5300 return not self.__eq__(other)
5301
5302 def __str__(self):
5303 return self.show()
5304
5305 def show(self):
5306 import loxi.pp
5307 return loxi.pp.pp(self)
5308
5309 def pretty_print(self, q):
5310 q.text("port_mod {")
5311 with q.group():
5312 with q.indent(2):
5313 q.breakable()
5314 q.text("xid = ");
5315 if self.xid != None:
5316 q.text("%#x" % self.xid)
5317 else:
5318 q.text('None')
5319 q.text(","); q.breakable()
5320 q.text("port_no = ");
5321 q.text(util.pretty_port(self.port_no))
5322 q.text(","); q.breakable()
5323 q.text("hw_addr = ");
5324 q.text(util.pretty_mac(self.hw_addr))
5325 q.text(","); q.breakable()
5326 q.text("config = ");
5327 q.text("%#x" % self.config)
5328 q.text(","); q.breakable()
5329 q.text("mask = ");
5330 q.text("%#x" % self.mask)
5331 q.text(","); q.breakable()
5332 q.text("advertise = ");
5333 q.text("%#x" % self.advertise)
Rich Laneb658ddd2013-03-12 10:15:10 -07005334 q.breakable()
5335 q.text('}')
5336
5337class port_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005338 version = 1
5339 type = 17
5340 stats_type = 4
Rich Laneb658ddd2013-03-12 10:15:10 -07005341
5342 def __init__(self, xid=None, flags=None, entries=None):
5343 self.xid = xid
5344 if flags != None:
5345 self.flags = flags
5346 else:
5347 self.flags = 0
5348 if entries != None:
5349 self.entries = entries
5350 else:
5351 self.entries = []
5352
5353 def pack(self):
5354 packed = []
5355 packed.append(struct.pack("!B", self.version))
5356 packed.append(struct.pack("!B", self.type))
5357 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5358 packed.append(struct.pack("!L", self.xid))
5359 packed.append(struct.pack("!H", self.stats_type))
5360 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07005361 packed.append(util.pack_list(self.entries))
Rich Laneb658ddd2013-03-12 10:15:10 -07005362 length = sum([len(x) for x in packed])
5363 packed[2] = struct.pack("!H", length)
5364 return ''.join(packed)
5365
5366 @staticmethod
5367 def unpack(buf):
5368 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5369 obj = port_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005370 if type(buf) == loxi.generic_util.OFReader:
5371 reader = buf
5372 else:
5373 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005374 _version = reader.read("!B")[0]
5375 assert(_version == 1)
5376 _type = reader.read("!B")[0]
5377 assert(_type == 17)
5378 _length = reader.read("!H")[0]
5379 obj.xid = reader.read("!L")[0]
5380 _stats_type = reader.read("!H")[0]
5381 assert(_stats_type == 4)
5382 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005383 obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack)
Rich Laneb658ddd2013-03-12 10:15:10 -07005384 return obj
5385
5386 def __eq__(self, other):
5387 if type(self) != type(other): return False
5388 if self.version != other.version: return False
5389 if self.type != other.type: return False
5390 if self.xid != other.xid: return False
5391 if self.flags != other.flags: return False
5392 if self.entries != other.entries: return False
5393 return True
5394
5395 def __ne__(self, other):
5396 return not self.__eq__(other)
5397
5398 def __str__(self):
5399 return self.show()
5400
5401 def show(self):
5402 import loxi.pp
5403 return loxi.pp.pp(self)
5404
5405 def pretty_print(self, q):
5406 q.text("port_stats_reply {")
5407 with q.group():
5408 with q.indent(2):
5409 q.breakable()
5410 q.text("xid = ");
5411 if self.xid != None:
5412 q.text("%#x" % self.xid)
5413 else:
5414 q.text('None')
5415 q.text(","); q.breakable()
5416 q.text("flags = ");
5417 q.text("%#x" % self.flags)
5418 q.text(","); q.breakable()
5419 q.text("entries = ");
5420 q.pp(self.entries)
5421 q.breakable()
5422 q.text('}')
5423
5424class port_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005425 version = 1
5426 type = 16
5427 stats_type = 4
Rich Laneb658ddd2013-03-12 10:15:10 -07005428
Rich Lanec2ee4b82013-04-24 17:12:38 -07005429 def __init__(self, xid=None, flags=None, port_no=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07005430 self.xid = xid
5431 if flags != None:
5432 self.flags = flags
5433 else:
5434 self.flags = 0
5435 if port_no != None:
5436 self.port_no = port_no
5437 else:
5438 self.port_no = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07005439
5440 def pack(self):
5441 packed = []
5442 packed.append(struct.pack("!B", self.version))
5443 packed.append(struct.pack("!B", self.type))
5444 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5445 packed.append(struct.pack("!L", self.xid))
5446 packed.append(struct.pack("!H", self.stats_type))
5447 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07005448 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005449 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -07005450 length = sum([len(x) for x in packed])
5451 packed[2] = struct.pack("!H", length)
5452 return ''.join(packed)
5453
5454 @staticmethod
5455 def unpack(buf):
5456 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5457 obj = port_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005458 if type(buf) == loxi.generic_util.OFReader:
5459 reader = buf
5460 else:
5461 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005462 _version = reader.read("!B")[0]
5463 assert(_version == 1)
5464 _type = reader.read("!B")[0]
5465 assert(_type == 16)
5466 _length = reader.read("!H")[0]
5467 obj.xid = reader.read("!L")[0]
5468 _stats_type = reader.read("!H")[0]
5469 assert(_stats_type == 4)
5470 obj.flags = reader.read("!H")[0]
5471 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005472 reader.skip(6)
Rich Laneb658ddd2013-03-12 10:15:10 -07005473 return obj
5474
5475 def __eq__(self, other):
5476 if type(self) != type(other): return False
5477 if self.version != other.version: return False
5478 if self.type != other.type: return False
5479 if self.xid != other.xid: return False
5480 if self.flags != other.flags: return False
5481 if self.port_no != other.port_no: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07005482 return True
5483
5484 def __ne__(self, other):
5485 return not self.__eq__(other)
5486
5487 def __str__(self):
5488 return self.show()
5489
5490 def show(self):
5491 import loxi.pp
5492 return loxi.pp.pp(self)
5493
5494 def pretty_print(self, q):
5495 q.text("port_stats_request {")
5496 with q.group():
5497 with q.indent(2):
5498 q.breakable()
5499 q.text("xid = ");
5500 if self.xid != None:
5501 q.text("%#x" % self.xid)
5502 else:
5503 q.text('None')
5504 q.text(","); q.breakable()
5505 q.text("flags = ");
5506 q.text("%#x" % self.flags)
5507 q.text(","); q.breakable()
5508 q.text("port_no = ");
5509 q.text(util.pretty_port(self.port_no))
Rich Laneb658ddd2013-03-12 10:15:10 -07005510 q.breakable()
5511 q.text('}')
5512
5513class port_status(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005514 version = 1
5515 type = 12
Rich Laneb658ddd2013-03-12 10:15:10 -07005516
Rich Lanec2ee4b82013-04-24 17:12:38 -07005517 def __init__(self, xid=None, reason=None, desc=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07005518 self.xid = xid
5519 if reason != None:
5520 self.reason = reason
5521 else:
5522 self.reason = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07005523 if desc != None:
5524 self.desc = desc
5525 else:
5526 self.desc = common.port_desc()
5527
5528 def pack(self):
5529 packed = []
5530 packed.append(struct.pack("!B", self.version))
5531 packed.append(struct.pack("!B", self.type))
5532 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5533 packed.append(struct.pack("!L", self.xid))
5534 packed.append(struct.pack("!B", self.reason))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005535 packed.append('\x00' * 7)
Rich Laneb658ddd2013-03-12 10:15:10 -07005536 packed.append(self.desc.pack())
5537 length = sum([len(x) for x in packed])
5538 packed[2] = struct.pack("!H", length)
5539 return ''.join(packed)
5540
5541 @staticmethod
5542 def unpack(buf):
5543 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5544 obj = port_status()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005545 if type(buf) == loxi.generic_util.OFReader:
5546 reader = buf
5547 else:
5548 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005549 _version = reader.read("!B")[0]
5550 assert(_version == 1)
5551 _type = reader.read("!B")[0]
5552 assert(_type == 12)
5553 _length = reader.read("!H")[0]
5554 obj.xid = reader.read("!L")[0]
5555 obj.reason = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005556 reader.skip(7)
5557 obj.desc = common.port_desc.unpack(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07005558 return obj
5559
5560 def __eq__(self, other):
5561 if type(self) != type(other): return False
5562 if self.version != other.version: return False
5563 if self.type != other.type: return False
5564 if self.xid != other.xid: return False
5565 if self.reason != other.reason: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07005566 if self.desc != other.desc: return False
5567 return True
5568
5569 def __ne__(self, other):
5570 return not self.__eq__(other)
5571
5572 def __str__(self):
5573 return self.show()
5574
5575 def show(self):
5576 import loxi.pp
5577 return loxi.pp.pp(self)
5578
5579 def pretty_print(self, q):
5580 q.text("port_status {")
5581 with q.group():
5582 with q.indent(2):
5583 q.breakable()
5584 q.text("xid = ");
5585 if self.xid != None:
5586 q.text("%#x" % self.xid)
5587 else:
5588 q.text('None')
5589 q.text(","); q.breakable()
5590 q.text("reason = ");
5591 q.text("%#x" % self.reason)
5592 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07005593 q.text("desc = ");
5594 q.pp(self.desc)
5595 q.breakable()
5596 q.text('}')
5597
5598class queue_get_config_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005599 version = 1
5600 type = 21
Rich Laneb658ddd2013-03-12 10:15:10 -07005601
Rich Lanec2ee4b82013-04-24 17:12:38 -07005602 def __init__(self, xid=None, port=None, queues=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07005603 self.xid = xid
5604 if port != None:
5605 self.port = port
5606 else:
5607 self.port = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07005608 if queues != None:
5609 self.queues = queues
5610 else:
5611 self.queues = []
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))
Dan Talaycof6202252013-07-02 01:00:29 -07005619 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005620 packed.append('\x00' * 6)
Dan Talaycof6202252013-07-02 01:00:29 -07005621 packed.append(util.pack_list(self.queues))
Rich Laneb658ddd2013-03-12 10:15:10 -07005622 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 = queue_get_config_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005630 if type(buf) == loxi.generic_util.OFReader:
5631 reader = buf
5632 else:
5633 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005634 _version = reader.read("!B")[0]
5635 assert(_version == 1)
5636 _type = reader.read("!B")[0]
5637 assert(_type == 21)
5638 _length = reader.read("!H")[0]
5639 obj.xid = reader.read("!L")[0]
5640 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005641 reader.skip(6)
5642 obj.queues = common.unpack_list_packet_queue(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07005643 return obj
5644
5645 def __eq__(self, other):
5646 if type(self) != type(other): return False
5647 if self.version != other.version: return False
5648 if self.type != other.type: return False
5649 if self.xid != other.xid: return False
5650 if self.port != other.port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07005651 if self.queues != other.queues: return False
5652 return True
5653
5654 def __ne__(self, other):
5655 return not self.__eq__(other)
5656
5657 def __str__(self):
5658 return self.show()
5659
5660 def show(self):
5661 import loxi.pp
5662 return loxi.pp.pp(self)
5663
5664 def pretty_print(self, q):
5665 q.text("queue_get_config_reply {")
5666 with q.group():
5667 with q.indent(2):
5668 q.breakable()
5669 q.text("xid = ");
5670 if self.xid != None:
5671 q.text("%#x" % self.xid)
5672 else:
5673 q.text('None')
5674 q.text(","); q.breakable()
5675 q.text("port = ");
5676 q.text(util.pretty_port(self.port))
5677 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07005678 q.text("queues = ");
5679 q.pp(self.queues)
5680 q.breakable()
5681 q.text('}')
5682
5683class queue_get_config_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005684 version = 1
5685 type = 20
Rich Laneb658ddd2013-03-12 10:15:10 -07005686
Rich Lanec2ee4b82013-04-24 17:12:38 -07005687 def __init__(self, xid=None, port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07005688 self.xid = xid
5689 if port != None:
5690 self.port = port
5691 else:
5692 self.port = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07005693
5694 def pack(self):
5695 packed = []
5696 packed.append(struct.pack("!B", self.version))
5697 packed.append(struct.pack("!B", self.type))
5698 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5699 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07005700 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005701 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -07005702 length = sum([len(x) for x in packed])
5703 packed[2] = struct.pack("!H", length)
5704 return ''.join(packed)
5705
5706 @staticmethod
5707 def unpack(buf):
5708 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5709 obj = queue_get_config_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005710 if type(buf) == loxi.generic_util.OFReader:
5711 reader = buf
5712 else:
5713 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005714 _version = reader.read("!B")[0]
5715 assert(_version == 1)
5716 _type = reader.read("!B")[0]
5717 assert(_type == 20)
5718 _length = reader.read("!H")[0]
5719 obj.xid = reader.read("!L")[0]
5720 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005721 reader.skip(2)
Rich Laneb658ddd2013-03-12 10:15:10 -07005722 return obj
5723
5724 def __eq__(self, other):
5725 if type(self) != type(other): return False
5726 if self.version != other.version: return False
5727 if self.type != other.type: return False
5728 if self.xid != other.xid: return False
5729 if self.port != other.port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07005730 return True
5731
5732 def __ne__(self, other):
5733 return not self.__eq__(other)
5734
5735 def __str__(self):
5736 return self.show()
5737
5738 def show(self):
5739 import loxi.pp
5740 return loxi.pp.pp(self)
5741
5742 def pretty_print(self, q):
5743 q.text("queue_get_config_request {")
5744 with q.group():
5745 with q.indent(2):
5746 q.breakable()
5747 q.text("xid = ");
5748 if self.xid != None:
5749 q.text("%#x" % self.xid)
5750 else:
5751 q.text('None')
5752 q.text(","); q.breakable()
5753 q.text("port = ");
5754 q.text(util.pretty_port(self.port))
Rich Laneb658ddd2013-03-12 10:15:10 -07005755 q.breakable()
5756 q.text('}')
5757
5758class queue_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005759 version = 1
5760 type = 17
5761 stats_type = 5
Rich Laneb658ddd2013-03-12 10:15:10 -07005762
5763 def __init__(self, xid=None, flags=None, entries=None):
5764 self.xid = xid
5765 if flags != None:
5766 self.flags = flags
5767 else:
5768 self.flags = 0
5769 if entries != None:
5770 self.entries = entries
5771 else:
5772 self.entries = []
5773
5774 def pack(self):
5775 packed = []
5776 packed.append(struct.pack("!B", self.version))
5777 packed.append(struct.pack("!B", self.type))
5778 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5779 packed.append(struct.pack("!L", self.xid))
5780 packed.append(struct.pack("!H", self.stats_type))
5781 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07005782 packed.append(util.pack_list(self.entries))
Rich Laneb658ddd2013-03-12 10:15:10 -07005783 length = sum([len(x) for x in packed])
5784 packed[2] = struct.pack("!H", length)
5785 return ''.join(packed)
5786
5787 @staticmethod
5788 def unpack(buf):
5789 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5790 obj = queue_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005791 if type(buf) == loxi.generic_util.OFReader:
5792 reader = buf
5793 else:
5794 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005795 _version = reader.read("!B")[0]
5796 assert(_version == 1)
5797 _type = reader.read("!B")[0]
5798 assert(_type == 17)
5799 _length = reader.read("!H")[0]
5800 obj.xid = reader.read("!L")[0]
5801 _stats_type = reader.read("!H")[0]
5802 assert(_stats_type == 5)
5803 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005804 obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack)
Rich Laneb658ddd2013-03-12 10:15:10 -07005805 return obj
5806
5807 def __eq__(self, other):
5808 if type(self) != type(other): return False
5809 if self.version != other.version: return False
5810 if self.type != other.type: return False
5811 if self.xid != other.xid: return False
5812 if self.flags != other.flags: return False
5813 if self.entries != other.entries: return False
5814 return True
5815
5816 def __ne__(self, other):
5817 return not self.__eq__(other)
5818
5819 def __str__(self):
5820 return self.show()
5821
5822 def show(self):
5823 import loxi.pp
5824 return loxi.pp.pp(self)
5825
5826 def pretty_print(self, q):
5827 q.text("queue_stats_reply {")
5828 with q.group():
5829 with q.indent(2):
5830 q.breakable()
5831 q.text("xid = ");
5832 if self.xid != None:
5833 q.text("%#x" % self.xid)
5834 else:
5835 q.text('None')
5836 q.text(","); q.breakable()
5837 q.text("flags = ");
5838 q.text("%#x" % self.flags)
5839 q.text(","); q.breakable()
5840 q.text("entries = ");
5841 q.pp(self.entries)
5842 q.breakable()
5843 q.text('}')
5844
5845class queue_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005846 version = 1
5847 type = 16
5848 stats_type = 5
Rich Laneb658ddd2013-03-12 10:15:10 -07005849
Rich Lanec2ee4b82013-04-24 17:12:38 -07005850 def __init__(self, xid=None, flags=None, port_no=None, queue_id=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07005851 self.xid = xid
5852 if flags != None:
5853 self.flags = flags
5854 else:
5855 self.flags = 0
5856 if port_no != None:
5857 self.port_no = port_no
5858 else:
5859 self.port_no = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07005860 if queue_id != None:
5861 self.queue_id = queue_id
5862 else:
5863 self.queue_id = 0
5864
5865 def pack(self):
5866 packed = []
5867 packed.append(struct.pack("!B", self.version))
5868 packed.append(struct.pack("!B", self.type))
5869 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5870 packed.append(struct.pack("!L", self.xid))
5871 packed.append(struct.pack("!H", self.stats_type))
5872 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07005873 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005874 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -07005875 packed.append(struct.pack("!L", self.queue_id))
5876 length = sum([len(x) for x in packed])
5877 packed[2] = struct.pack("!H", length)
5878 return ''.join(packed)
5879
5880 @staticmethod
5881 def unpack(buf):
5882 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5883 obj = queue_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005884 if type(buf) == loxi.generic_util.OFReader:
5885 reader = buf
5886 else:
5887 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005888 _version = reader.read("!B")[0]
5889 assert(_version == 1)
5890 _type = reader.read("!B")[0]
5891 assert(_type == 16)
5892 _length = reader.read("!H")[0]
5893 obj.xid = reader.read("!L")[0]
5894 _stats_type = reader.read("!H")[0]
5895 assert(_stats_type == 5)
5896 obj.flags = reader.read("!H")[0]
5897 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005898 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07005899 obj.queue_id = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07005900 return obj
5901
5902 def __eq__(self, other):
5903 if type(self) != type(other): return False
5904 if self.version != other.version: return False
5905 if self.type != other.type: return False
5906 if self.xid != other.xid: return False
5907 if self.flags != other.flags: return False
5908 if self.port_no != other.port_no: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07005909 if self.queue_id != other.queue_id: return False
5910 return True
5911
5912 def __ne__(self, other):
5913 return not self.__eq__(other)
5914
5915 def __str__(self):
5916 return self.show()
5917
5918 def show(self):
5919 import loxi.pp
5920 return loxi.pp.pp(self)
5921
5922 def pretty_print(self, q):
5923 q.text("queue_stats_request {")
5924 with q.group():
5925 with q.indent(2):
5926 q.breakable()
5927 q.text("xid = ");
5928 if self.xid != None:
5929 q.text("%#x" % self.xid)
5930 else:
5931 q.text('None')
5932 q.text(","); q.breakable()
5933 q.text("flags = ");
5934 q.text("%#x" % self.flags)
5935 q.text(","); q.breakable()
5936 q.text("port_no = ");
5937 q.text(util.pretty_port(self.port_no))
5938 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07005939 q.text("queue_id = ");
5940 q.text("%#x" % self.queue_id)
5941 q.breakable()
5942 q.text('}')
5943
5944class set_config(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005945 version = 1
5946 type = 9
Rich Laneb658ddd2013-03-12 10:15:10 -07005947
5948 def __init__(self, xid=None, flags=None, miss_send_len=None):
5949 self.xid = xid
5950 if flags != None:
5951 self.flags = flags
5952 else:
5953 self.flags = 0
5954 if miss_send_len != None:
5955 self.miss_send_len = miss_send_len
5956 else:
5957 self.miss_send_len = 0
5958
5959 def pack(self):
5960 packed = []
5961 packed.append(struct.pack("!B", self.version))
5962 packed.append(struct.pack("!B", self.type))
5963 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5964 packed.append(struct.pack("!L", self.xid))
5965 packed.append(struct.pack("!H", self.flags))
5966 packed.append(struct.pack("!H", self.miss_send_len))
5967 length = sum([len(x) for x in packed])
5968 packed[2] = struct.pack("!H", length)
5969 return ''.join(packed)
5970
5971 @staticmethod
5972 def unpack(buf):
5973 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5974 obj = set_config()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005975 if type(buf) == loxi.generic_util.OFReader:
5976 reader = buf
5977 else:
5978 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005979 _version = reader.read("!B")[0]
5980 assert(_version == 1)
5981 _type = reader.read("!B")[0]
5982 assert(_type == 9)
5983 _length = reader.read("!H")[0]
5984 obj.xid = reader.read("!L")[0]
5985 obj.flags = reader.read("!H")[0]
5986 obj.miss_send_len = reader.read("!H")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07005987 return obj
5988
5989 def __eq__(self, other):
5990 if type(self) != type(other): return False
5991 if self.version != other.version: return False
5992 if self.type != other.type: return False
5993 if self.xid != other.xid: return False
5994 if self.flags != other.flags: return False
5995 if self.miss_send_len != other.miss_send_len: return False
5996 return True
5997
5998 def __ne__(self, other):
5999 return not self.__eq__(other)
6000
6001 def __str__(self):
6002 return self.show()
6003
6004 def show(self):
6005 import loxi.pp
6006 return loxi.pp.pp(self)
6007
6008 def pretty_print(self, q):
6009 q.text("set_config {")
6010 with q.group():
6011 with q.indent(2):
6012 q.breakable()
6013 q.text("xid = ");
6014 if self.xid != None:
6015 q.text("%#x" % self.xid)
6016 else:
6017 q.text('None')
6018 q.text(","); q.breakable()
6019 q.text("flags = ");
6020 q.text("%#x" % self.flags)
6021 q.text(","); q.breakable()
6022 q.text("miss_send_len = ");
6023 q.text("%#x" % self.miss_send_len)
6024 q.breakable()
6025 q.text('}')
6026
6027class table_mod(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006028 version = 1
Rich Laneb658ddd2013-03-12 10:15:10 -07006029 type = 22
6030
Rich Lanec2ee4b82013-04-24 17:12:38 -07006031 def __init__(self, xid=None, table_id=None, config=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07006032 self.xid = xid
6033 if table_id != None:
6034 self.table_id = table_id
6035 else:
6036 self.table_id = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07006037 if config != None:
6038 self.config = config
6039 else:
6040 self.config = 0
6041
6042 def pack(self):
6043 packed = []
6044 packed.append(struct.pack("!B", self.version))
6045 packed.append(struct.pack("!B", self.type))
6046 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6047 packed.append(struct.pack("!L", self.xid))
6048 packed.append(struct.pack("!B", self.table_id))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006049 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07006050 packed.append(struct.pack("!L", self.config))
6051 length = sum([len(x) for x in packed])
6052 packed[2] = struct.pack("!H", length)
6053 return ''.join(packed)
6054
6055 @staticmethod
6056 def unpack(buf):
6057 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6058 obj = table_mod()
Rich Lanec2ee4b82013-04-24 17:12:38 -07006059 if type(buf) == loxi.generic_util.OFReader:
6060 reader = buf
6061 else:
6062 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006063 _version = reader.read("!B")[0]
6064 assert(_version == 1)
6065 _type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006066 assert(_type == 22)
Dan Talaycof6202252013-07-02 01:00:29 -07006067 _length = reader.read("!H")[0]
6068 obj.xid = reader.read("!L")[0]
6069 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006070 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07006071 obj.config = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07006072 return obj
6073
6074 def __eq__(self, other):
6075 if type(self) != type(other): return False
6076 if self.version != other.version: return False
6077 if self.type != other.type: return False
6078 if self.xid != other.xid: return False
6079 if self.table_id != other.table_id: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07006080 if self.config != other.config: return False
6081 return True
6082
6083 def __ne__(self, other):
6084 return not self.__eq__(other)
6085
6086 def __str__(self):
6087 return self.show()
6088
6089 def show(self):
6090 import loxi.pp
6091 return loxi.pp.pp(self)
6092
6093 def pretty_print(self, q):
6094 q.text("table_mod {")
6095 with q.group():
6096 with q.indent(2):
6097 q.breakable()
6098 q.text("xid = ");
6099 if self.xid != None:
6100 q.text("%#x" % self.xid)
6101 else:
6102 q.text('None')
6103 q.text(","); q.breakable()
6104 q.text("table_id = ");
6105 q.text("%#x" % self.table_id)
6106 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07006107 q.text("config = ");
6108 q.text("%#x" % self.config)
6109 q.breakable()
6110 q.text('}')
6111
6112class table_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006113 version = 1
6114 type = 17
6115 stats_type = 3
Rich Laneb658ddd2013-03-12 10:15:10 -07006116
6117 def __init__(self, xid=None, flags=None, entries=None):
6118 self.xid = xid
6119 if flags != None:
6120 self.flags = flags
6121 else:
6122 self.flags = 0
6123 if entries != None:
6124 self.entries = entries
6125 else:
6126 self.entries = []
6127
6128 def pack(self):
6129 packed = []
6130 packed.append(struct.pack("!B", self.version))
6131 packed.append(struct.pack("!B", self.type))
6132 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6133 packed.append(struct.pack("!L", self.xid))
6134 packed.append(struct.pack("!H", self.stats_type))
6135 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07006136 packed.append(util.pack_list(self.entries))
Rich Laneb658ddd2013-03-12 10:15:10 -07006137 length = sum([len(x) for x in packed])
6138 packed[2] = struct.pack("!H", length)
6139 return ''.join(packed)
6140
6141 @staticmethod
6142 def unpack(buf):
6143 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6144 obj = table_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07006145 if type(buf) == loxi.generic_util.OFReader:
6146 reader = buf
6147 else:
6148 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006149 _version = reader.read("!B")[0]
6150 assert(_version == 1)
6151 _type = reader.read("!B")[0]
6152 assert(_type == 17)
6153 _length = reader.read("!H")[0]
6154 obj.xid = reader.read("!L")[0]
6155 _stats_type = reader.read("!H")[0]
6156 assert(_stats_type == 3)
6157 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006158 obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack)
Rich Laneb658ddd2013-03-12 10:15:10 -07006159 return obj
6160
6161 def __eq__(self, other):
6162 if type(self) != type(other): return False
6163 if self.version != other.version: return False
6164 if self.type != other.type: return False
6165 if self.xid != other.xid: return False
6166 if self.flags != other.flags: return False
6167 if self.entries != other.entries: return False
6168 return True
6169
6170 def __ne__(self, other):
6171 return not self.__eq__(other)
6172
6173 def __str__(self):
6174 return self.show()
6175
6176 def show(self):
6177 import loxi.pp
6178 return loxi.pp.pp(self)
6179
6180 def pretty_print(self, q):
6181 q.text("table_stats_reply {")
6182 with q.group():
6183 with q.indent(2):
6184 q.breakable()
6185 q.text("xid = ");
6186 if self.xid != None:
6187 q.text("%#x" % self.xid)
6188 else:
6189 q.text('None')
6190 q.text(","); q.breakable()
6191 q.text("flags = ");
6192 q.text("%#x" % self.flags)
6193 q.text(","); q.breakable()
6194 q.text("entries = ");
6195 q.pp(self.entries)
6196 q.breakable()
6197 q.text('}')
6198
6199class table_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006200 version = 1
6201 type = 16
6202 stats_type = 3
Rich Laneb658ddd2013-03-12 10:15:10 -07006203
6204 def __init__(self, xid=None, flags=None):
6205 self.xid = xid
6206 if flags != None:
6207 self.flags = flags
6208 else:
6209 self.flags = 0
6210
6211 def pack(self):
6212 packed = []
6213 packed.append(struct.pack("!B", self.version))
6214 packed.append(struct.pack("!B", self.type))
6215 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6216 packed.append(struct.pack("!L", self.xid))
6217 packed.append(struct.pack("!H", self.stats_type))
6218 packed.append(struct.pack("!H", self.flags))
6219 length = sum([len(x) for x in packed])
6220 packed[2] = struct.pack("!H", length)
6221 return ''.join(packed)
6222
6223 @staticmethod
6224 def unpack(buf):
6225 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6226 obj = table_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07006227 if type(buf) == loxi.generic_util.OFReader:
6228 reader = buf
6229 else:
6230 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006231 _version = reader.read("!B")[0]
6232 assert(_version == 1)
6233 _type = reader.read("!B")[0]
6234 assert(_type == 16)
6235 _length = reader.read("!H")[0]
6236 obj.xid = reader.read("!L")[0]
6237 _stats_type = reader.read("!H")[0]
6238 assert(_stats_type == 3)
6239 obj.flags = reader.read("!H")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07006240 return obj
6241
6242 def __eq__(self, other):
6243 if type(self) != type(other): return False
6244 if self.version != other.version: return False
6245 if self.type != other.type: return False
6246 if self.xid != other.xid: return False
6247 if self.flags != other.flags: return False
6248 return True
6249
6250 def __ne__(self, other):
6251 return not self.__eq__(other)
6252
6253 def __str__(self):
6254 return self.show()
6255
6256 def show(self):
6257 import loxi.pp
6258 return loxi.pp.pp(self)
6259
6260 def pretty_print(self, q):
6261 q.text("table_stats_request {")
6262 with q.group():
6263 with q.indent(2):
6264 q.breakable()
6265 q.text("xid = ");
6266 if self.xid != None:
6267 q.text("%#x" % self.xid)
6268 else:
6269 q.text('None')
6270 q.text(","); q.breakable()
6271 q.text("flags = ");
6272 q.text("%#x" % self.flags)
6273 q.breakable()
6274 q.text('}')
6275
6276
6277def parse_header(buf):
6278 if len(buf) < 8:
6279 raise loxi.ProtocolError("too short to be an OpenFlow message")
6280 return struct.unpack_from("!BBHL", buf)
6281
6282def parse_message(buf):
6283 msg_ver, msg_type, msg_len, msg_xid = parse_header(buf)
Rich Lanefe600f52013-07-09 13:22:32 -07006284 if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO:
6285 raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (const.OFP_VERSION, msg_ver))
Rich Laneb658ddd2013-03-12 10:15:10 -07006286 if len(buf) != msg_len:
6287 raise loxi.ProtocolError("incorrect message size")
6288 if msg_type in parsers:
6289 return parsers[msg_type](buf)
6290 else:
6291 raise loxi.ProtocolError("unexpected message type")
6292
6293def parse_flow_mod(buf):
Rich Lanefe600f52013-07-09 13:22:32 -07006294 if len(buf) < 57 + 1:
Rich Laneb658ddd2013-03-12 10:15:10 -07006295 raise loxi.ProtocolError("message too short")
Rich Lanefe600f52013-07-09 13:22:32 -07006296 # Technically uint16_t for OF 1.0
6297 cmd, = struct.unpack_from("!B", buf, 57)
Rich Laneb658ddd2013-03-12 10:15:10 -07006298 if cmd in flow_mod_parsers:
6299 return flow_mod_parsers[cmd](buf)
6300 else:
6301 raise loxi.ProtocolError("unexpected flow mod cmd %u" % cmd)
6302
6303def parse_stats_reply(buf):
6304 if len(buf) < 8 + 2:
6305 raise loxi.ProtocolError("message too short")
6306 stats_type, = struct.unpack_from("!H", buf, 8)
6307 if stats_type in stats_reply_parsers:
6308 return stats_reply_parsers[stats_type](buf)
6309 else:
6310 raise loxi.ProtocolError("unexpected stats type %u" % stats_type)
6311
6312def parse_stats_request(buf):
6313 if len(buf) < 8 + 2:
6314 raise loxi.ProtocolError("message too short")
6315 stats_type, = struct.unpack_from("!H", buf, 8)
6316 if stats_type in stats_request_parsers:
6317 return stats_request_parsers[stats_type](buf)
6318 else:
6319 raise loxi.ProtocolError("unexpected stats type %u" % stats_type)
6320
6321def parse_vendor(buf):
6322 if len(buf) < 16:
6323 raise loxi.ProtocolError("experimenter message too short")
6324
6325 experimenter, = struct.unpack_from("!L", buf, 8)
6326 if experimenter == 0x005c16c7: # Big Switch Networks
6327 subtype, = struct.unpack_from("!L", buf, 12)
6328 elif experimenter == 0x00002320: # Nicira
6329 subtype, = struct.unpack_from("!L", buf, 12)
6330 else:
6331 raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter)
6332
6333 if subtype in experimenter_parsers[experimenter]:
6334 return experimenter_parsers[experimenter][subtype](buf)
6335 else:
6336 raise loxi.ProtocolError("unexpected experimenter %#x subtype %#x" % (experimenter, subtype))
6337
6338parsers = {
Rich Laneb658ddd2013-03-12 10:15:10 -07006339 const.OFPT_HELLO : hello.unpack,
Dan Talaycof6202252013-07-02 01:00:29 -07006340 const.OFPT_ERROR : error_msg.unpack,
6341 const.OFPT_ECHO_REQUEST : echo_request.unpack,
6342 const.OFPT_ECHO_REPLY : echo_reply.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07006343 const.OFPT_VENDOR : parse_vendor,
Dan Talaycof6202252013-07-02 01:00:29 -07006344 const.OFPT_FEATURES_REQUEST : features_request.unpack,
6345 const.OFPT_FEATURES_REPLY : features_reply.unpack,
6346 const.OFPT_GET_CONFIG_REQUEST : get_config_request.unpack,
6347 const.OFPT_GET_CONFIG_REPLY : get_config_reply.unpack,
6348 const.OFPT_SET_CONFIG : set_config.unpack,
6349 const.OFPT_PACKET_IN : packet_in.unpack,
6350 const.OFPT_FLOW_REMOVED : flow_removed.unpack,
6351 const.OFPT_PORT_STATUS : port_status.unpack,
6352 const.OFPT_PACKET_OUT : packet_out.unpack,
6353 const.OFPT_FLOW_MOD : parse_flow_mod,
6354 const.OFPT_PORT_MOD : port_mod.unpack,
6355 const.OFPT_STATS_REQUEST : parse_stats_request,
6356 const.OFPT_STATS_REPLY : parse_stats_reply,
6357 const.OFPT_BARRIER_REQUEST : barrier_request.unpack,
6358 const.OFPT_BARRIER_REPLY : barrier_reply.unpack,
6359 const.OFPT_QUEUE_GET_CONFIG_REQUEST : queue_get_config_request.unpack,
6360 const.OFPT_QUEUE_GET_CONFIG_REPLY : queue_get_config_reply.unpack,
6361 22 : table_mod.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07006362}
6363
6364flow_mod_parsers = {
6365 const.OFPFC_ADD : flow_add.unpack,
6366 const.OFPFC_MODIFY : flow_modify.unpack,
6367 const.OFPFC_MODIFY_STRICT : flow_modify_strict.unpack,
6368 const.OFPFC_DELETE : flow_delete.unpack,
6369 const.OFPFC_DELETE_STRICT : flow_delete_strict.unpack,
6370}
6371
6372stats_reply_parsers = {
6373 const.OFPST_DESC : desc_stats_reply.unpack,
6374 const.OFPST_FLOW : flow_stats_reply.unpack,
6375 const.OFPST_AGGREGATE : aggregate_stats_reply.unpack,
6376 const.OFPST_TABLE : table_stats_reply.unpack,
6377 const.OFPST_PORT : port_stats_reply.unpack,
6378 const.OFPST_QUEUE : queue_stats_reply.unpack,
6379 const.OFPST_VENDOR : experimenter_stats_reply.unpack,
6380}
6381
6382stats_request_parsers = {
6383 const.OFPST_DESC : desc_stats_request.unpack,
6384 const.OFPST_FLOW : flow_stats_request.unpack,
6385 const.OFPST_AGGREGATE : aggregate_stats_request.unpack,
6386 const.OFPST_TABLE : table_stats_request.unpack,
6387 const.OFPST_PORT : port_stats_request.unpack,
6388 const.OFPST_QUEUE : queue_stats_request.unpack,
6389 const.OFPST_VENDOR : experimenter_stats_request.unpack,
6390}
6391
6392experimenter_parsers = {
Dan Talaycof6202252013-07-02 01:00:29 -07006393 8992 : {
Rich Laneb658ddd2013-03-12 10:15:10 -07006394 11: nicira_controller_role_reply.unpack,
6395 10: nicira_controller_role_request.unpack,
6396 },
Dan Talaycof6202252013-07-02 01:00:29 -07006397 6035143 : {
6398 22: bsn_bw_clear_data_reply.unpack,
6399 21: bsn_bw_clear_data_request.unpack,
6400 20: bsn_bw_enable_get_reply.unpack,
6401 19: bsn_bw_enable_get_request.unpack,
6402 23: bsn_bw_enable_set_reply.unpack,
6403 18: bsn_bw_enable_set_request.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07006404 10: bsn_get_interfaces_reply.unpack,
6405 9: bsn_get_interfaces_request.unpack,
6406 2: bsn_get_ip_mask_reply.unpack,
6407 1: bsn_get_ip_mask_request.unpack,
Rich Lane90c961c2013-05-14 09:26:50 -07006408 14: bsn_get_l2_table_reply.unpack,
6409 13: bsn_get_l2_table_request.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07006410 5: bsn_get_mirroring_reply.unpack,
6411 4: bsn_get_mirroring_request.unpack,
6412 0: bsn_set_ip_mask.unpack,
Dan Talaycof6202252013-07-02 01:00:29 -07006413 24: bsn_set_l2_table_reply.unpack,
6414 12: bsn_set_l2_table_request.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07006415 3: bsn_set_mirroring.unpack,
Dan Talaycof6202252013-07-02 01:00:29 -07006416 25: bsn_set_pktin_suppression_reply.unpack,
6417 11: bsn_set_pktin_suppression_request.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07006418 6: bsn_shell_command.unpack,
6419 7: bsn_shell_output.unpack,
6420 8: bsn_shell_status.unpack,
Dan Talaycof6202252013-07-02 01:00:29 -07006421 16: bsn_virtual_port_create_reply.unpack,
6422 15: bsn_virtual_port_create_request.unpack,
6423 26: bsn_virtual_port_remove_reply.unpack,
6424 17: bsn_virtual_port_remove_request.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07006425 },
6426}