blob: 4ed79ee0d60f9c541812198ff943d7a948220826 [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
Rich Lane6f4978c2013-10-20 21:33:52 -0700240class bad_action_error_msg(Message):
241 version = 1
242 type = 1
243 err_type = 2
244
245 def __init__(self, xid=None, code=None, data=None):
246 self.xid = xid
247 if code != None:
248 self.code = code
249 else:
250 self.code = 0
251 if data != None:
252 self.data = data
253 else:
254 self.data = ''
255
256 def pack(self):
257 packed = []
258 packed.append(struct.pack("!B", self.version))
259 packed.append(struct.pack("!B", self.type))
260 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
261 packed.append(struct.pack("!L", self.xid))
262 packed.append(struct.pack("!H", self.err_type))
263 packed.append(struct.pack("!H", self.code))
264 packed.append(self.data)
265 length = sum([len(x) for x in packed])
266 packed[2] = struct.pack("!H", length)
267 return ''.join(packed)
268
269 @staticmethod
270 def unpack(buf):
271 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
272 obj = bad_action_error_msg()
273 if type(buf) == loxi.generic_util.OFReader:
274 reader = buf
275 else:
276 reader = loxi.generic_util.OFReader(buf)
277 _version = reader.read("!B")[0]
278 assert(_version == 1)
279 _type = reader.read("!B")[0]
280 assert(_type == 1)
281 _length = reader.read("!H")[0]
282 obj.xid = reader.read("!L")[0]
283 _err_type = reader.read("!H")[0]
284 assert(_err_type == 2)
285 obj.code = reader.read("!H")[0]
286 obj.data = str(reader.read_all())
287 return obj
288
289 def __eq__(self, other):
290 if type(self) != type(other): return False
291 if self.version != other.version: return False
292 if self.type != other.type: return False
293 if self.xid != other.xid: return False
294 if self.code != other.code: return False
295 if self.data != other.data: return False
296 return True
297
298 def __ne__(self, other):
299 return not self.__eq__(other)
300
301 def __str__(self):
302 return self.show()
303
304 def show(self):
305 import loxi.pp
306 return loxi.pp.pp(self)
307
308 def pretty_print(self, q):
309 q.text("bad_action_error_msg {")
310 with q.group():
311 with q.indent(2):
312 q.breakable()
313 q.text("xid = ");
314 if self.xid != None:
315 q.text("%#x" % self.xid)
316 else:
317 q.text('None')
318 q.text(","); q.breakable()
319 q.text("code = ");
320 q.text("%#x" % self.code)
321 q.text(","); q.breakable()
322 q.text("data = ");
323 q.pp(self.data)
324 q.breakable()
325 q.text('}')
326
327class bad_request_error_msg(Message):
328 version = 1
329 type = 1
330 err_type = 1
331
332 def __init__(self, xid=None, code=None, data=None):
333 self.xid = xid
334 if code != None:
335 self.code = code
336 else:
337 self.code = 0
338 if data != None:
339 self.data = data
340 else:
341 self.data = ''
342
343 def pack(self):
344 packed = []
345 packed.append(struct.pack("!B", self.version))
346 packed.append(struct.pack("!B", self.type))
347 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
348 packed.append(struct.pack("!L", self.xid))
349 packed.append(struct.pack("!H", self.err_type))
350 packed.append(struct.pack("!H", self.code))
351 packed.append(self.data)
352 length = sum([len(x) for x in packed])
353 packed[2] = struct.pack("!H", length)
354 return ''.join(packed)
355
356 @staticmethod
357 def unpack(buf):
358 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
359 obj = bad_request_error_msg()
360 if type(buf) == loxi.generic_util.OFReader:
361 reader = buf
362 else:
363 reader = loxi.generic_util.OFReader(buf)
364 _version = reader.read("!B")[0]
365 assert(_version == 1)
366 _type = reader.read("!B")[0]
367 assert(_type == 1)
368 _length = reader.read("!H")[0]
369 obj.xid = reader.read("!L")[0]
370 _err_type = reader.read("!H")[0]
371 assert(_err_type == 1)
372 obj.code = reader.read("!H")[0]
373 obj.data = str(reader.read_all())
374 return obj
375
376 def __eq__(self, other):
377 if type(self) != type(other): return False
378 if self.version != other.version: return False
379 if self.type != other.type: return False
380 if self.xid != other.xid: return False
381 if self.code != other.code: return False
382 if self.data != other.data: return False
383 return True
384
385 def __ne__(self, other):
386 return not self.__eq__(other)
387
388 def __str__(self):
389 return self.show()
390
391 def show(self):
392 import loxi.pp
393 return loxi.pp.pp(self)
394
395 def pretty_print(self, q):
396 q.text("bad_request_error_msg {")
397 with q.group():
398 with q.indent(2):
399 q.breakable()
400 q.text("xid = ");
401 if self.xid != None:
402 q.text("%#x" % self.xid)
403 else:
404 q.text('None')
405 q.text(","); q.breakable()
406 q.text("code = ");
407 q.text("%#x" % self.code)
408 q.text(","); q.breakable()
409 q.text("data = ");
410 q.pp(self.data)
411 q.breakable()
412 q.text('}')
413
Rich Laneb658ddd2013-03-12 10:15:10 -0700414class barrier_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -0700415 version = 1
416 type = 19
Rich Laneb658ddd2013-03-12 10:15:10 -0700417
418 def __init__(self, xid=None):
419 self.xid = xid
420
421 def pack(self):
422 packed = []
423 packed.append(struct.pack("!B", self.version))
424 packed.append(struct.pack("!B", self.type))
425 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
426 packed.append(struct.pack("!L", self.xid))
427 length = sum([len(x) for x in packed])
428 packed[2] = struct.pack("!H", length)
429 return ''.join(packed)
430
431 @staticmethod
432 def unpack(buf):
433 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
434 obj = barrier_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700435 if type(buf) == loxi.generic_util.OFReader:
436 reader = buf
437 else:
438 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700439 _version = reader.read("!B")[0]
440 assert(_version == 1)
441 _type = reader.read("!B")[0]
442 assert(_type == 19)
443 _length = reader.read("!H")[0]
444 obj.xid = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700445 return obj
446
447 def __eq__(self, other):
448 if type(self) != type(other): return False
449 if self.version != other.version: return False
450 if self.type != other.type: return False
451 if self.xid != other.xid: return False
452 return True
453
454 def __ne__(self, other):
455 return not self.__eq__(other)
456
457 def __str__(self):
458 return self.show()
459
460 def show(self):
461 import loxi.pp
462 return loxi.pp.pp(self)
463
464 def pretty_print(self, q):
465 q.text("barrier_reply {")
466 with q.group():
467 with q.indent(2):
468 q.breakable()
469 q.text("xid = ");
470 if self.xid != None:
471 q.text("%#x" % self.xid)
472 else:
473 q.text('None')
474 q.breakable()
475 q.text('}')
476
477class barrier_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -0700478 version = 1
479 type = 18
Rich Laneb658ddd2013-03-12 10:15:10 -0700480
481 def __init__(self, xid=None):
482 self.xid = xid
483
484 def pack(self):
485 packed = []
486 packed.append(struct.pack("!B", self.version))
487 packed.append(struct.pack("!B", self.type))
488 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
489 packed.append(struct.pack("!L", self.xid))
490 length = sum([len(x) for x in packed])
491 packed[2] = struct.pack("!H", length)
492 return ''.join(packed)
493
494 @staticmethod
495 def unpack(buf):
496 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
497 obj = barrier_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700498 if type(buf) == loxi.generic_util.OFReader:
499 reader = buf
500 else:
501 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700502 _version = reader.read("!B")[0]
503 assert(_version == 1)
504 _type = reader.read("!B")[0]
505 assert(_type == 18)
506 _length = reader.read("!H")[0]
507 obj.xid = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700508 return obj
509
510 def __eq__(self, other):
511 if type(self) != type(other): return False
512 if self.version != other.version: return False
513 if self.type != other.type: return False
514 if self.xid != other.xid: return False
515 return True
516
517 def __ne__(self, other):
518 return not self.__eq__(other)
519
520 def __str__(self):
521 return self.show()
522
523 def show(self):
524 import loxi.pp
525 return loxi.pp.pp(self)
526
527 def pretty_print(self, q):
528 q.text("barrier_request {")
529 with q.group():
530 with q.indent(2):
531 q.breakable()
532 q.text("xid = ");
533 if self.xid != None:
534 q.text("%#x" % self.xid)
535 else:
536 q.text('None')
537 q.breakable()
538 q.text('}')
539
Dan Talaycof6202252013-07-02 01:00:29 -0700540class bsn_bw_clear_data_reply(Message):
541 version = 1
542 type = 4
543 experimenter = 6035143
544 subtype = 22
545
546 def __init__(self, xid=None, status=None):
547 self.xid = xid
548 if status != None:
549 self.status = status
550 else:
551 self.status = 0
552
553 def pack(self):
554 packed = []
555 packed.append(struct.pack("!B", self.version))
556 packed.append(struct.pack("!B", self.type))
557 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
558 packed.append(struct.pack("!L", self.xid))
559 packed.append(struct.pack("!L", self.experimenter))
560 packed.append(struct.pack("!L", self.subtype))
561 packed.append(struct.pack("!L", self.status))
562 length = sum([len(x) for x in packed])
563 packed[2] = struct.pack("!H", length)
564 return ''.join(packed)
565
566 @staticmethod
567 def unpack(buf):
568 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
569 obj = bsn_bw_clear_data_reply()
570 if type(buf) == loxi.generic_util.OFReader:
571 reader = buf
572 else:
573 reader = loxi.generic_util.OFReader(buf)
574 _version = reader.read("!B")[0]
575 assert(_version == 1)
576 _type = reader.read("!B")[0]
577 assert(_type == 4)
578 _length = reader.read("!H")[0]
579 obj.xid = reader.read("!L")[0]
580 _experimenter = reader.read("!L")[0]
581 assert(_experimenter == 6035143)
582 _subtype = reader.read("!L")[0]
583 assert(_subtype == 22)
584 obj.status = reader.read("!L")[0]
585 return obj
586
587 def __eq__(self, other):
588 if type(self) != type(other): return False
589 if self.version != other.version: return False
590 if self.type != other.type: return False
591 if self.xid != other.xid: return False
592 if self.status != other.status: return False
593 return True
594
595 def __ne__(self, other):
596 return not self.__eq__(other)
597
598 def __str__(self):
599 return self.show()
600
601 def show(self):
602 import loxi.pp
603 return loxi.pp.pp(self)
604
605 def pretty_print(self, q):
606 q.text("bsn_bw_clear_data_reply {")
607 with q.group():
608 with q.indent(2):
609 q.breakable()
610 q.text("xid = ");
611 if self.xid != None:
612 q.text("%#x" % self.xid)
613 else:
614 q.text('None')
615 q.text(","); q.breakable()
616 q.text("status = ");
617 q.text("%#x" % self.status)
618 q.breakable()
619 q.text('}')
620
621class bsn_bw_clear_data_request(Message):
622 version = 1
623 type = 4
624 experimenter = 6035143
625 subtype = 21
626
627 def __init__(self, xid=None):
628 self.xid = xid
629
630 def pack(self):
631 packed = []
632 packed.append(struct.pack("!B", self.version))
633 packed.append(struct.pack("!B", self.type))
634 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
635 packed.append(struct.pack("!L", self.xid))
636 packed.append(struct.pack("!L", self.experimenter))
637 packed.append(struct.pack("!L", self.subtype))
638 length = sum([len(x) for x in packed])
639 packed[2] = struct.pack("!H", length)
640 return ''.join(packed)
641
642 @staticmethod
643 def unpack(buf):
644 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
645 obj = bsn_bw_clear_data_request()
646 if type(buf) == loxi.generic_util.OFReader:
647 reader = buf
648 else:
649 reader = loxi.generic_util.OFReader(buf)
650 _version = reader.read("!B")[0]
651 assert(_version == 1)
652 _type = reader.read("!B")[0]
653 assert(_type == 4)
654 _length = reader.read("!H")[0]
655 obj.xid = reader.read("!L")[0]
656 _experimenter = reader.read("!L")[0]
657 assert(_experimenter == 6035143)
658 _subtype = reader.read("!L")[0]
659 assert(_subtype == 21)
660 return obj
661
662 def __eq__(self, other):
663 if type(self) != type(other): return False
664 if self.version != other.version: return False
665 if self.type != other.type: return False
666 if self.xid != other.xid: return False
667 return True
668
669 def __ne__(self, other):
670 return not self.__eq__(other)
671
672 def __str__(self):
673 return self.show()
674
675 def show(self):
676 import loxi.pp
677 return loxi.pp.pp(self)
678
679 def pretty_print(self, q):
680 q.text("bsn_bw_clear_data_request {")
681 with q.group():
682 with q.indent(2):
683 q.breakable()
684 q.text("xid = ");
685 if self.xid != None:
686 q.text("%#x" % self.xid)
687 else:
688 q.text('None')
689 q.breakable()
690 q.text('}')
691
692class bsn_bw_enable_get_reply(Message):
693 version = 1
694 type = 4
695 experimenter = 6035143
696 subtype = 20
697
698 def __init__(self, xid=None, enabled=None):
699 self.xid = xid
700 if enabled != None:
701 self.enabled = enabled
702 else:
703 self.enabled = 0
704
705 def pack(self):
706 packed = []
707 packed.append(struct.pack("!B", self.version))
708 packed.append(struct.pack("!B", self.type))
709 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
710 packed.append(struct.pack("!L", self.xid))
711 packed.append(struct.pack("!L", self.experimenter))
712 packed.append(struct.pack("!L", self.subtype))
713 packed.append(struct.pack("!L", self.enabled))
714 length = sum([len(x) for x in packed])
715 packed[2] = struct.pack("!H", length)
716 return ''.join(packed)
717
718 @staticmethod
719 def unpack(buf):
720 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
721 obj = bsn_bw_enable_get_reply()
722 if type(buf) == loxi.generic_util.OFReader:
723 reader = buf
724 else:
725 reader = loxi.generic_util.OFReader(buf)
726 _version = reader.read("!B")[0]
727 assert(_version == 1)
728 _type = reader.read("!B")[0]
729 assert(_type == 4)
730 _length = reader.read("!H")[0]
731 obj.xid = reader.read("!L")[0]
732 _experimenter = reader.read("!L")[0]
733 assert(_experimenter == 6035143)
734 _subtype = reader.read("!L")[0]
735 assert(_subtype == 20)
736 obj.enabled = reader.read("!L")[0]
737 return obj
738
739 def __eq__(self, other):
740 if type(self) != type(other): return False
741 if self.version != other.version: return False
742 if self.type != other.type: return False
743 if self.xid != other.xid: return False
744 if self.enabled != other.enabled: return False
745 return True
746
747 def __ne__(self, other):
748 return not self.__eq__(other)
749
750 def __str__(self):
751 return self.show()
752
753 def show(self):
754 import loxi.pp
755 return loxi.pp.pp(self)
756
757 def pretty_print(self, q):
758 q.text("bsn_bw_enable_get_reply {")
759 with q.group():
760 with q.indent(2):
761 q.breakable()
762 q.text("xid = ");
763 if self.xid != None:
764 q.text("%#x" % self.xid)
765 else:
766 q.text('None')
767 q.text(","); q.breakable()
768 q.text("enabled = ");
769 q.text("%#x" % self.enabled)
770 q.breakable()
771 q.text('}')
772
773class bsn_bw_enable_get_request(Message):
774 version = 1
775 type = 4
776 experimenter = 6035143
777 subtype = 19
778
779 def __init__(self, xid=None):
780 self.xid = xid
781
782 def pack(self):
783 packed = []
784 packed.append(struct.pack("!B", self.version))
785 packed.append(struct.pack("!B", self.type))
786 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
787 packed.append(struct.pack("!L", self.xid))
788 packed.append(struct.pack("!L", self.experimenter))
789 packed.append(struct.pack("!L", self.subtype))
790 length = sum([len(x) for x in packed])
791 packed[2] = struct.pack("!H", length)
792 return ''.join(packed)
793
794 @staticmethod
795 def unpack(buf):
796 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
797 obj = bsn_bw_enable_get_request()
798 if type(buf) == loxi.generic_util.OFReader:
799 reader = buf
800 else:
801 reader = loxi.generic_util.OFReader(buf)
802 _version = reader.read("!B")[0]
803 assert(_version == 1)
804 _type = reader.read("!B")[0]
805 assert(_type == 4)
806 _length = reader.read("!H")[0]
807 obj.xid = reader.read("!L")[0]
808 _experimenter = reader.read("!L")[0]
809 assert(_experimenter == 6035143)
810 _subtype = reader.read("!L")[0]
811 assert(_subtype == 19)
812 return obj
813
814 def __eq__(self, other):
815 if type(self) != type(other): return False
816 if self.version != other.version: return False
817 if self.type != other.type: return False
818 if self.xid != other.xid: return False
819 return True
820
821 def __ne__(self, other):
822 return not self.__eq__(other)
823
824 def __str__(self):
825 return self.show()
826
827 def show(self):
828 import loxi.pp
829 return loxi.pp.pp(self)
830
831 def pretty_print(self, q):
832 q.text("bsn_bw_enable_get_request {")
833 with q.group():
834 with q.indent(2):
835 q.breakable()
836 q.text("xid = ");
837 if self.xid != None:
838 q.text("%#x" % self.xid)
839 else:
840 q.text('None')
841 q.breakable()
842 q.text('}')
843
844class bsn_bw_enable_set_reply(Message):
845 version = 1
846 type = 4
847 experimenter = 6035143
848 subtype = 23
849
850 def __init__(self, xid=None, enable=None, status=None):
851 self.xid = xid
852 if enable != None:
853 self.enable = enable
854 else:
855 self.enable = 0
856 if status != None:
857 self.status = status
858 else:
859 self.status = 0
860
861 def pack(self):
862 packed = []
863 packed.append(struct.pack("!B", self.version))
864 packed.append(struct.pack("!B", self.type))
865 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
866 packed.append(struct.pack("!L", self.xid))
867 packed.append(struct.pack("!L", self.experimenter))
868 packed.append(struct.pack("!L", self.subtype))
869 packed.append(struct.pack("!L", self.enable))
870 packed.append(struct.pack("!L", self.status))
871 length = sum([len(x) for x in packed])
872 packed[2] = struct.pack("!H", length)
873 return ''.join(packed)
874
875 @staticmethod
876 def unpack(buf):
877 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
878 obj = bsn_bw_enable_set_reply()
879 if type(buf) == loxi.generic_util.OFReader:
880 reader = buf
881 else:
882 reader = loxi.generic_util.OFReader(buf)
883 _version = reader.read("!B")[0]
884 assert(_version == 1)
885 _type = reader.read("!B")[0]
886 assert(_type == 4)
887 _length = reader.read("!H")[0]
888 obj.xid = reader.read("!L")[0]
889 _experimenter = reader.read("!L")[0]
890 assert(_experimenter == 6035143)
891 _subtype = reader.read("!L")[0]
892 assert(_subtype == 23)
893 obj.enable = reader.read("!L")[0]
894 obj.status = reader.read("!L")[0]
895 return obj
896
897 def __eq__(self, other):
898 if type(self) != type(other): return False
899 if self.version != other.version: return False
900 if self.type != other.type: return False
901 if self.xid != other.xid: return False
902 if self.enable != other.enable: return False
903 if self.status != other.status: return False
904 return True
905
906 def __ne__(self, other):
907 return not self.__eq__(other)
908
909 def __str__(self):
910 return self.show()
911
912 def show(self):
913 import loxi.pp
914 return loxi.pp.pp(self)
915
916 def pretty_print(self, q):
917 q.text("bsn_bw_enable_set_reply {")
918 with q.group():
919 with q.indent(2):
920 q.breakable()
921 q.text("xid = ");
922 if self.xid != None:
923 q.text("%#x" % self.xid)
924 else:
925 q.text('None')
926 q.text(","); q.breakable()
927 q.text("enable = ");
928 q.text("%#x" % self.enable)
929 q.text(","); q.breakable()
930 q.text("status = ");
931 q.text("%#x" % self.status)
932 q.breakable()
933 q.text('}')
934
935class bsn_bw_enable_set_request(Message):
936 version = 1
937 type = 4
938 experimenter = 6035143
939 subtype = 18
940
941 def __init__(self, xid=None, enable=None):
942 self.xid = xid
943 if enable != None:
944 self.enable = enable
945 else:
946 self.enable = 0
947
948 def pack(self):
949 packed = []
950 packed.append(struct.pack("!B", self.version))
951 packed.append(struct.pack("!B", self.type))
952 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
953 packed.append(struct.pack("!L", self.xid))
954 packed.append(struct.pack("!L", self.experimenter))
955 packed.append(struct.pack("!L", self.subtype))
956 packed.append(struct.pack("!L", self.enable))
957 length = sum([len(x) for x in packed])
958 packed[2] = struct.pack("!H", length)
959 return ''.join(packed)
960
961 @staticmethod
962 def unpack(buf):
963 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
964 obj = bsn_bw_enable_set_request()
965 if type(buf) == loxi.generic_util.OFReader:
966 reader = buf
967 else:
968 reader = loxi.generic_util.OFReader(buf)
969 _version = reader.read("!B")[0]
970 assert(_version == 1)
971 _type = reader.read("!B")[0]
972 assert(_type == 4)
973 _length = reader.read("!H")[0]
974 obj.xid = reader.read("!L")[0]
975 _experimenter = reader.read("!L")[0]
976 assert(_experimenter == 6035143)
977 _subtype = reader.read("!L")[0]
978 assert(_subtype == 18)
979 obj.enable = reader.read("!L")[0]
980 return obj
981
982 def __eq__(self, other):
983 if type(self) != type(other): return False
984 if self.version != other.version: return False
985 if self.type != other.type: return False
986 if self.xid != other.xid: return False
987 if self.enable != other.enable: return False
988 return True
989
990 def __ne__(self, other):
991 return not self.__eq__(other)
992
993 def __str__(self):
994 return self.show()
995
996 def show(self):
997 import loxi.pp
998 return loxi.pp.pp(self)
999
1000 def pretty_print(self, q):
1001 q.text("bsn_bw_enable_set_request {")
1002 with q.group():
1003 with q.indent(2):
1004 q.breakable()
1005 q.text("xid = ");
1006 if self.xid != None:
1007 q.text("%#x" % self.xid)
1008 else:
1009 q.text('None')
1010 q.text(","); q.breakable()
1011 q.text("enable = ");
1012 q.text("%#x" % self.enable)
1013 q.breakable()
1014 q.text('}')
1015
Rich Laneb658ddd2013-03-12 10:15:10 -07001016class bsn_get_interfaces_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07001017 version = 1
1018 type = 4
1019 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07001020 subtype = 10
1021
1022 def __init__(self, xid=None, interfaces=None):
1023 self.xid = xid
1024 if interfaces != None:
1025 self.interfaces = interfaces
1026 else:
1027 self.interfaces = []
1028
1029 def pack(self):
1030 packed = []
1031 packed.append(struct.pack("!B", self.version))
1032 packed.append(struct.pack("!B", self.type))
1033 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1034 packed.append(struct.pack("!L", self.xid))
1035 packed.append(struct.pack("!L", self.experimenter))
1036 packed.append(struct.pack("!L", self.subtype))
Dan Talaycof6202252013-07-02 01:00:29 -07001037 packed.append(util.pack_list(self.interfaces))
Rich Laneb658ddd2013-03-12 10:15:10 -07001038 length = sum([len(x) for x in packed])
1039 packed[2] = struct.pack("!H", length)
1040 return ''.join(packed)
1041
1042 @staticmethod
1043 def unpack(buf):
1044 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1045 obj = bsn_get_interfaces_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001046 if type(buf) == loxi.generic_util.OFReader:
1047 reader = buf
1048 else:
1049 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001050 _version = reader.read("!B")[0]
1051 assert(_version == 1)
1052 _type = reader.read("!B")[0]
1053 assert(_type == 4)
1054 _length = reader.read("!H")[0]
1055 obj.xid = reader.read("!L")[0]
1056 _experimenter = reader.read("!L")[0]
1057 assert(_experimenter == 6035143)
1058 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001059 assert(_subtype == 10)
1060 obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack)
Rich Laneb658ddd2013-03-12 10:15:10 -07001061 return obj
1062
1063 def __eq__(self, other):
1064 if type(self) != type(other): return False
1065 if self.version != other.version: return False
1066 if self.type != other.type: return False
1067 if self.xid != other.xid: return False
1068 if self.interfaces != other.interfaces: return False
1069 return True
1070
1071 def __ne__(self, other):
1072 return not self.__eq__(other)
1073
1074 def __str__(self):
1075 return self.show()
1076
1077 def show(self):
1078 import loxi.pp
1079 return loxi.pp.pp(self)
1080
1081 def pretty_print(self, q):
1082 q.text("bsn_get_interfaces_reply {")
1083 with q.group():
1084 with q.indent(2):
1085 q.breakable()
1086 q.text("xid = ");
1087 if self.xid != None:
1088 q.text("%#x" % self.xid)
1089 else:
1090 q.text('None')
1091 q.text(","); q.breakable()
1092 q.text("interfaces = ");
1093 q.pp(self.interfaces)
1094 q.breakable()
1095 q.text('}')
1096
1097class bsn_get_interfaces_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07001098 version = 1
1099 type = 4
1100 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07001101 subtype = 9
1102
1103 def __init__(self, xid=None):
1104 self.xid = xid
1105
1106 def pack(self):
1107 packed = []
1108 packed.append(struct.pack("!B", self.version))
1109 packed.append(struct.pack("!B", self.type))
1110 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1111 packed.append(struct.pack("!L", self.xid))
1112 packed.append(struct.pack("!L", self.experimenter))
1113 packed.append(struct.pack("!L", self.subtype))
1114 length = sum([len(x) for x in packed])
1115 packed[2] = struct.pack("!H", length)
1116 return ''.join(packed)
1117
1118 @staticmethod
1119 def unpack(buf):
1120 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1121 obj = bsn_get_interfaces_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001122 if type(buf) == loxi.generic_util.OFReader:
1123 reader = buf
1124 else:
1125 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001126 _version = reader.read("!B")[0]
1127 assert(_version == 1)
1128 _type = reader.read("!B")[0]
1129 assert(_type == 4)
1130 _length = reader.read("!H")[0]
1131 obj.xid = reader.read("!L")[0]
1132 _experimenter = reader.read("!L")[0]
1133 assert(_experimenter == 6035143)
1134 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001135 assert(_subtype == 9)
Rich Laneb658ddd2013-03-12 10:15:10 -07001136 return obj
1137
1138 def __eq__(self, other):
1139 if type(self) != type(other): return False
1140 if self.version != other.version: return False
1141 if self.type != other.type: return False
1142 if self.xid != other.xid: return False
1143 return True
1144
1145 def __ne__(self, other):
1146 return not self.__eq__(other)
1147
1148 def __str__(self):
1149 return self.show()
1150
1151 def show(self):
1152 import loxi.pp
1153 return loxi.pp.pp(self)
1154
1155 def pretty_print(self, q):
1156 q.text("bsn_get_interfaces_request {")
1157 with q.group():
1158 with q.indent(2):
1159 q.breakable()
1160 q.text("xid = ");
1161 if self.xid != None:
1162 q.text("%#x" % self.xid)
1163 else:
1164 q.text('None')
1165 q.breakable()
1166 q.text('}')
1167
1168class bsn_get_ip_mask_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07001169 version = 1
1170 type = 4
1171 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07001172 subtype = 2
1173
Rich Lanec2ee4b82013-04-24 17:12:38 -07001174 def __init__(self, xid=None, index=None, mask=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07001175 self.xid = xid
1176 if index != None:
1177 self.index = index
1178 else:
1179 self.index = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07001180 if mask != None:
1181 self.mask = mask
1182 else:
1183 self.mask = 0
1184
1185 def pack(self):
1186 packed = []
1187 packed.append(struct.pack("!B", self.version))
1188 packed.append(struct.pack("!B", self.type))
1189 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1190 packed.append(struct.pack("!L", self.xid))
1191 packed.append(struct.pack("!L", self.experimenter))
1192 packed.append(struct.pack("!L", self.subtype))
1193 packed.append(struct.pack("!B", self.index))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001194 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07001195 packed.append(struct.pack("!L", self.mask))
1196 length = sum([len(x) for x in packed])
1197 packed[2] = struct.pack("!H", length)
1198 return ''.join(packed)
1199
1200 @staticmethod
1201 def unpack(buf):
1202 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1203 obj = bsn_get_ip_mask_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001204 if type(buf) == loxi.generic_util.OFReader:
1205 reader = buf
1206 else:
1207 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001208 _version = reader.read("!B")[0]
1209 assert(_version == 1)
1210 _type = reader.read("!B")[0]
1211 assert(_type == 4)
1212 _length = reader.read("!H")[0]
1213 obj.xid = reader.read("!L")[0]
1214 _experimenter = reader.read("!L")[0]
1215 assert(_experimenter == 6035143)
1216 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001217 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -07001218 obj.index = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001219 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07001220 obj.mask = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07001221 return obj
1222
1223 def __eq__(self, other):
1224 if type(self) != type(other): return False
1225 if self.version != other.version: return False
1226 if self.type != other.type: return False
1227 if self.xid != other.xid: return False
1228 if self.index != other.index: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001229 if self.mask != other.mask: return False
1230 return True
1231
1232 def __ne__(self, other):
1233 return not self.__eq__(other)
1234
1235 def __str__(self):
1236 return self.show()
1237
1238 def show(self):
1239 import loxi.pp
1240 return loxi.pp.pp(self)
1241
1242 def pretty_print(self, q):
1243 q.text("bsn_get_ip_mask_reply {")
1244 with q.group():
1245 with q.indent(2):
1246 q.breakable()
1247 q.text("xid = ");
1248 if self.xid != None:
1249 q.text("%#x" % self.xid)
1250 else:
1251 q.text('None')
1252 q.text(","); q.breakable()
1253 q.text("index = ");
1254 q.text("%#x" % self.index)
1255 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07001256 q.text("mask = ");
1257 q.text("%#x" % self.mask)
1258 q.breakable()
1259 q.text('}')
1260
1261class bsn_get_ip_mask_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07001262 version = 1
1263 type = 4
1264 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07001265 subtype = 1
1266
Rich Lanec2ee4b82013-04-24 17:12:38 -07001267 def __init__(self, xid=None, index=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07001268 self.xid = xid
1269 if index != None:
1270 self.index = index
1271 else:
1272 self.index = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07001273
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 packed.append(struct.pack("!B", self.index))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001283 packed.append('\x00' * 7)
Rich Laneb658ddd2013-03-12 10:15:10 -07001284 length = sum([len(x) for x in packed])
1285 packed[2] = struct.pack("!H", length)
1286 return ''.join(packed)
1287
1288 @staticmethod
1289 def unpack(buf):
1290 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1291 obj = bsn_get_ip_mask_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001292 if type(buf) == loxi.generic_util.OFReader:
1293 reader = buf
1294 else:
1295 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001296 _version = reader.read("!B")[0]
1297 assert(_version == 1)
1298 _type = reader.read("!B")[0]
1299 assert(_type == 4)
1300 _length = reader.read("!H")[0]
1301 obj.xid = reader.read("!L")[0]
1302 _experimenter = reader.read("!L")[0]
1303 assert(_experimenter == 6035143)
1304 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001305 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -07001306 obj.index = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001307 reader.skip(7)
Rich Laneb658ddd2013-03-12 10:15:10 -07001308 return obj
1309
1310 def __eq__(self, other):
1311 if type(self) != type(other): return False
1312 if self.version != other.version: return False
1313 if self.type != other.type: return False
1314 if self.xid != other.xid: return False
1315 if self.index != other.index: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001316 return True
1317
1318 def __ne__(self, other):
1319 return not self.__eq__(other)
1320
1321 def __str__(self):
1322 return self.show()
1323
1324 def show(self):
1325 import loxi.pp
1326 return loxi.pp.pp(self)
1327
1328 def pretty_print(self, q):
1329 q.text("bsn_get_ip_mask_request {")
1330 with q.group():
1331 with q.indent(2):
1332 q.breakable()
1333 q.text("xid = ");
1334 if self.xid != None:
1335 q.text("%#x" % self.xid)
1336 else:
1337 q.text('None')
1338 q.text(","); q.breakable()
1339 q.text("index = ");
1340 q.text("%#x" % self.index)
Rich Laneb658ddd2013-03-12 10:15:10 -07001341 q.breakable()
1342 q.text('}')
1343
Rich Lane90c961c2013-05-14 09:26:50 -07001344class bsn_get_l2_table_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07001345 version = 1
1346 type = 4
1347 experimenter = 6035143
Rich Lane90c961c2013-05-14 09:26:50 -07001348 subtype = 14
1349
1350 def __init__(self, xid=None, l2_table_enable=None, l2_table_priority=None):
1351 self.xid = xid
1352 if l2_table_enable != None:
1353 self.l2_table_enable = l2_table_enable
1354 else:
1355 self.l2_table_enable = 0
1356 if l2_table_priority != None:
1357 self.l2_table_priority = l2_table_priority
1358 else:
1359 self.l2_table_priority = 0
1360
1361 def pack(self):
1362 packed = []
1363 packed.append(struct.pack("!B", self.version))
1364 packed.append(struct.pack("!B", self.type))
1365 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1366 packed.append(struct.pack("!L", self.xid))
1367 packed.append(struct.pack("!L", self.experimenter))
1368 packed.append(struct.pack("!L", self.subtype))
1369 packed.append(struct.pack("!B", self.l2_table_enable))
1370 packed.append('\x00' * 1)
1371 packed.append(struct.pack("!H", self.l2_table_priority))
1372 packed.append('\x00' * 4)
1373 length = sum([len(x) for x in packed])
1374 packed[2] = struct.pack("!H", length)
1375 return ''.join(packed)
1376
1377 @staticmethod
1378 def unpack(buf):
1379 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1380 obj = bsn_get_l2_table_reply()
1381 if type(buf) == loxi.generic_util.OFReader:
1382 reader = buf
1383 else:
1384 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001385 _version = reader.read("!B")[0]
1386 assert(_version == 1)
1387 _type = reader.read("!B")[0]
1388 assert(_type == 4)
1389 _length = reader.read("!H")[0]
1390 obj.xid = reader.read("!L")[0]
1391 _experimenter = reader.read("!L")[0]
1392 assert(_experimenter == 6035143)
1393 _subtype = reader.read("!L")[0]
Rich Lane90c961c2013-05-14 09:26:50 -07001394 assert(_subtype == 14)
Dan Talaycof6202252013-07-02 01:00:29 -07001395 obj.l2_table_enable = reader.read("!B")[0]
Rich Lane90c961c2013-05-14 09:26:50 -07001396 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001397 obj.l2_table_priority = reader.read("!H")[0]
Rich Lane90c961c2013-05-14 09:26:50 -07001398 reader.skip(4)
1399 return obj
1400
1401 def __eq__(self, other):
1402 if type(self) != type(other): return False
1403 if self.version != other.version: return False
1404 if self.type != other.type: return False
1405 if self.xid != other.xid: return False
1406 if self.l2_table_enable != other.l2_table_enable: return False
1407 if self.l2_table_priority != other.l2_table_priority: return False
1408 return True
1409
1410 def __ne__(self, other):
1411 return not self.__eq__(other)
1412
1413 def __str__(self):
1414 return self.show()
1415
1416 def show(self):
1417 import loxi.pp
1418 return loxi.pp.pp(self)
1419
1420 def pretty_print(self, q):
1421 q.text("bsn_get_l2_table_reply {")
1422 with q.group():
1423 with q.indent(2):
1424 q.breakable()
1425 q.text("xid = ");
1426 if self.xid != None:
1427 q.text("%#x" % self.xid)
1428 else:
1429 q.text('None')
1430 q.text(","); q.breakable()
1431 q.text("l2_table_enable = ");
1432 q.text("%#x" % self.l2_table_enable)
1433 q.text(","); q.breakable()
1434 q.text("l2_table_priority = ");
1435 q.text("%#x" % self.l2_table_priority)
1436 q.breakable()
1437 q.text('}')
1438
1439class bsn_get_l2_table_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07001440 version = 1
1441 type = 4
1442 experimenter = 6035143
Rich Lane90c961c2013-05-14 09:26:50 -07001443 subtype = 13
1444
1445 def __init__(self, xid=None):
1446 self.xid = xid
1447
1448 def pack(self):
1449 packed = []
1450 packed.append(struct.pack("!B", self.version))
1451 packed.append(struct.pack("!B", self.type))
1452 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1453 packed.append(struct.pack("!L", self.xid))
1454 packed.append(struct.pack("!L", self.experimenter))
1455 packed.append(struct.pack("!L", self.subtype))
1456 length = sum([len(x) for x in packed])
1457 packed[2] = struct.pack("!H", length)
1458 return ''.join(packed)
1459
1460 @staticmethod
1461 def unpack(buf):
1462 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1463 obj = bsn_get_l2_table_request()
1464 if type(buf) == loxi.generic_util.OFReader:
1465 reader = buf
1466 else:
1467 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001468 _version = reader.read("!B")[0]
1469 assert(_version == 1)
1470 _type = reader.read("!B")[0]
1471 assert(_type == 4)
1472 _length = reader.read("!H")[0]
1473 obj.xid = reader.read("!L")[0]
1474 _experimenter = reader.read("!L")[0]
1475 assert(_experimenter == 6035143)
1476 _subtype = reader.read("!L")[0]
Rich Lane90c961c2013-05-14 09:26:50 -07001477 assert(_subtype == 13)
1478 return obj
1479
1480 def __eq__(self, other):
1481 if type(self) != type(other): return False
1482 if self.version != other.version: return False
1483 if self.type != other.type: return False
1484 if self.xid != other.xid: return False
1485 return True
1486
1487 def __ne__(self, other):
1488 return not self.__eq__(other)
1489
1490 def __str__(self):
1491 return self.show()
1492
1493 def show(self):
1494 import loxi.pp
1495 return loxi.pp.pp(self)
1496
1497 def pretty_print(self, q):
1498 q.text("bsn_get_l2_table_request {")
1499 with q.group():
1500 with q.indent(2):
1501 q.breakable()
1502 q.text("xid = ");
1503 if self.xid != None:
1504 q.text("%#x" % self.xid)
1505 else:
1506 q.text('None')
1507 q.breakable()
1508 q.text('}')
1509
Rich Laneb658ddd2013-03-12 10:15:10 -07001510class bsn_get_mirroring_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07001511 version = 1
1512 type = 4
1513 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07001514 subtype = 5
1515
Rich Lanec2ee4b82013-04-24 17:12:38 -07001516 def __init__(self, xid=None, report_mirror_ports=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07001517 self.xid = xid
1518 if report_mirror_ports != None:
1519 self.report_mirror_ports = report_mirror_ports
1520 else:
1521 self.report_mirror_ports = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07001522
1523 def pack(self):
1524 packed = []
1525 packed.append(struct.pack("!B", self.version))
1526 packed.append(struct.pack("!B", self.type))
1527 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1528 packed.append(struct.pack("!L", self.xid))
1529 packed.append(struct.pack("!L", self.experimenter))
1530 packed.append(struct.pack("!L", self.subtype))
1531 packed.append(struct.pack("!B", self.report_mirror_ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001532 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07001533 length = sum([len(x) for x in packed])
1534 packed[2] = struct.pack("!H", length)
1535 return ''.join(packed)
1536
1537 @staticmethod
1538 def unpack(buf):
1539 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1540 obj = bsn_get_mirroring_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001541 if type(buf) == loxi.generic_util.OFReader:
1542 reader = buf
1543 else:
1544 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001545 _version = reader.read("!B")[0]
1546 assert(_version == 1)
1547 _type = reader.read("!B")[0]
1548 assert(_type == 4)
1549 _length = reader.read("!H")[0]
1550 obj.xid = reader.read("!L")[0]
1551 _experimenter = reader.read("!L")[0]
1552 assert(_experimenter == 6035143)
1553 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001554 assert(_subtype == 5)
Dan Talaycof6202252013-07-02 01:00:29 -07001555 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001556 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -07001557 return obj
1558
1559 def __eq__(self, other):
1560 if type(self) != type(other): return False
1561 if self.version != other.version: return False
1562 if self.type != other.type: return False
1563 if self.xid != other.xid: return False
1564 if self.report_mirror_ports != other.report_mirror_ports: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001565 return True
1566
1567 def __ne__(self, other):
1568 return not self.__eq__(other)
1569
1570 def __str__(self):
1571 return self.show()
1572
1573 def show(self):
1574 import loxi.pp
1575 return loxi.pp.pp(self)
1576
1577 def pretty_print(self, q):
1578 q.text("bsn_get_mirroring_reply {")
1579 with q.group():
1580 with q.indent(2):
1581 q.breakable()
1582 q.text("xid = ");
1583 if self.xid != None:
1584 q.text("%#x" % self.xid)
1585 else:
1586 q.text('None')
1587 q.text(","); q.breakable()
1588 q.text("report_mirror_ports = ");
1589 q.text("%#x" % self.report_mirror_ports)
Rich Laneb658ddd2013-03-12 10:15:10 -07001590 q.breakable()
1591 q.text('}')
1592
1593class bsn_get_mirroring_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07001594 version = 1
1595 type = 4
1596 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07001597 subtype = 4
1598
Rich Lanec2ee4b82013-04-24 17:12:38 -07001599 def __init__(self, xid=None, report_mirror_ports=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07001600 self.xid = xid
1601 if report_mirror_ports != None:
1602 self.report_mirror_ports = report_mirror_ports
1603 else:
1604 self.report_mirror_ports = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07001605
1606 def pack(self):
1607 packed = []
1608 packed.append(struct.pack("!B", self.version))
1609 packed.append(struct.pack("!B", self.type))
1610 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1611 packed.append(struct.pack("!L", self.xid))
1612 packed.append(struct.pack("!L", self.experimenter))
1613 packed.append(struct.pack("!L", self.subtype))
1614 packed.append(struct.pack("!B", self.report_mirror_ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001615 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07001616 length = sum([len(x) for x in packed])
1617 packed[2] = struct.pack("!H", length)
1618 return ''.join(packed)
1619
1620 @staticmethod
1621 def unpack(buf):
1622 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1623 obj = bsn_get_mirroring_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001624 if type(buf) == loxi.generic_util.OFReader:
1625 reader = buf
1626 else:
1627 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001628 _version = reader.read("!B")[0]
1629 assert(_version == 1)
1630 _type = reader.read("!B")[0]
1631 assert(_type == 4)
1632 _length = reader.read("!H")[0]
1633 obj.xid = reader.read("!L")[0]
1634 _experimenter = reader.read("!L")[0]
1635 assert(_experimenter == 6035143)
1636 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001637 assert(_subtype == 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001638 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001639 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -07001640 return obj
1641
1642 def __eq__(self, other):
1643 if type(self) != type(other): return False
1644 if self.version != other.version: return False
1645 if self.type != other.type: return False
1646 if self.xid != other.xid: return False
1647 if self.report_mirror_ports != other.report_mirror_ports: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001648 return True
1649
1650 def __ne__(self, other):
1651 return not self.__eq__(other)
1652
1653 def __str__(self):
1654 return self.show()
1655
1656 def show(self):
1657 import loxi.pp
1658 return loxi.pp.pp(self)
1659
1660 def pretty_print(self, q):
1661 q.text("bsn_get_mirroring_request {")
1662 with q.group():
1663 with q.indent(2):
1664 q.breakable()
1665 q.text("xid = ");
1666 if self.xid != None:
1667 q.text("%#x" % self.xid)
1668 else:
1669 q.text('None')
1670 q.text(","); q.breakable()
1671 q.text("report_mirror_ports = ");
1672 q.text("%#x" % self.report_mirror_ports)
Rich Laneb658ddd2013-03-12 10:15:10 -07001673 q.breakable()
1674 q.text('}')
1675
Rich Lane6f4978c2013-10-20 21:33:52 -07001676class bsn_hybrid_get_reply(Message):
1677 version = 1
1678 type = 4
1679 experimenter = 6035143
1680 subtype = 28
1681
1682 def __init__(self, xid=None, hybrid_enable=None, hybrid_version=None):
1683 self.xid = xid
1684 if hybrid_enable != None:
1685 self.hybrid_enable = hybrid_enable
1686 else:
1687 self.hybrid_enable = 0
1688 if hybrid_version != None:
1689 self.hybrid_version = hybrid_version
1690 else:
1691 self.hybrid_version = 0
1692
1693 def pack(self):
1694 packed = []
1695 packed.append(struct.pack("!B", self.version))
1696 packed.append(struct.pack("!B", self.type))
1697 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1698 packed.append(struct.pack("!L", self.xid))
1699 packed.append(struct.pack("!L", self.experimenter))
1700 packed.append(struct.pack("!L", self.subtype))
1701 packed.append(struct.pack("!B", self.hybrid_enable))
1702 packed.append('\x00' * 1)
1703 packed.append(struct.pack("!H", self.hybrid_version))
1704 packed.append('\x00' * 4)
1705 length = sum([len(x) for x in packed])
1706 packed[2] = struct.pack("!H", length)
1707 return ''.join(packed)
1708
1709 @staticmethod
1710 def unpack(buf):
1711 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1712 obj = bsn_hybrid_get_reply()
1713 if type(buf) == loxi.generic_util.OFReader:
1714 reader = buf
1715 else:
1716 reader = loxi.generic_util.OFReader(buf)
1717 _version = reader.read("!B")[0]
1718 assert(_version == 1)
1719 _type = reader.read("!B")[0]
1720 assert(_type == 4)
1721 _length = reader.read("!H")[0]
1722 obj.xid = reader.read("!L")[0]
1723 _experimenter = reader.read("!L")[0]
1724 assert(_experimenter == 6035143)
1725 _subtype = reader.read("!L")[0]
1726 assert(_subtype == 28)
1727 obj.hybrid_enable = reader.read("!B")[0]
1728 reader.skip(1)
1729 obj.hybrid_version = reader.read("!H")[0]
1730 reader.skip(4)
1731 return obj
1732
1733 def __eq__(self, other):
1734 if type(self) != type(other): return False
1735 if self.version != other.version: return False
1736 if self.type != other.type: return False
1737 if self.xid != other.xid: return False
1738 if self.hybrid_enable != other.hybrid_enable: return False
1739 if self.hybrid_version != other.hybrid_version: return False
1740 return True
1741
1742 def __ne__(self, other):
1743 return not self.__eq__(other)
1744
1745 def __str__(self):
1746 return self.show()
1747
1748 def show(self):
1749 import loxi.pp
1750 return loxi.pp.pp(self)
1751
1752 def pretty_print(self, q):
1753 q.text("bsn_hybrid_get_reply {")
1754 with q.group():
1755 with q.indent(2):
1756 q.breakable()
1757 q.text("xid = ");
1758 if self.xid != None:
1759 q.text("%#x" % self.xid)
1760 else:
1761 q.text('None')
1762 q.text(","); q.breakable()
1763 q.text("hybrid_enable = ");
1764 q.text("%#x" % self.hybrid_enable)
1765 q.text(","); q.breakable()
1766 q.text("hybrid_version = ");
1767 q.text("%#x" % self.hybrid_version)
1768 q.breakable()
1769 q.text('}')
1770
1771class bsn_hybrid_get_request(Message):
1772 version = 1
1773 type = 4
1774 experimenter = 6035143
1775 subtype = 27
1776
1777 def __init__(self, xid=None):
1778 self.xid = xid
1779
1780 def pack(self):
1781 packed = []
1782 packed.append(struct.pack("!B", self.version))
1783 packed.append(struct.pack("!B", self.type))
1784 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1785 packed.append(struct.pack("!L", self.xid))
1786 packed.append(struct.pack("!L", self.experimenter))
1787 packed.append(struct.pack("!L", self.subtype))
1788 length = sum([len(x) for x in packed])
1789 packed[2] = struct.pack("!H", length)
1790 return ''.join(packed)
1791
1792 @staticmethod
1793 def unpack(buf):
1794 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1795 obj = bsn_hybrid_get_request()
1796 if type(buf) == loxi.generic_util.OFReader:
1797 reader = buf
1798 else:
1799 reader = loxi.generic_util.OFReader(buf)
1800 _version = reader.read("!B")[0]
1801 assert(_version == 1)
1802 _type = reader.read("!B")[0]
1803 assert(_type == 4)
1804 _length = reader.read("!H")[0]
1805 obj.xid = reader.read("!L")[0]
1806 _experimenter = reader.read("!L")[0]
1807 assert(_experimenter == 6035143)
1808 _subtype = reader.read("!L")[0]
1809 assert(_subtype == 27)
1810 return obj
1811
1812 def __eq__(self, other):
1813 if type(self) != type(other): return False
1814 if self.version != other.version: return False
1815 if self.type != other.type: return False
1816 if self.xid != other.xid: return False
1817 return True
1818
1819 def __ne__(self, other):
1820 return not self.__eq__(other)
1821
1822 def __str__(self):
1823 return self.show()
1824
1825 def show(self):
1826 import loxi.pp
1827 return loxi.pp.pp(self)
1828
1829 def pretty_print(self, q):
1830 q.text("bsn_hybrid_get_request {")
1831 with q.group():
1832 with q.indent(2):
1833 q.breakable()
1834 q.text("xid = ");
1835 if self.xid != None:
1836 q.text("%#x" % self.xid)
1837 else:
1838 q.text('None')
1839 q.breakable()
1840 q.text('}')
1841
1842class bsn_pdu_rx_reply(Message):
1843 version = 1
1844 type = 4
1845 experimenter = 6035143
1846 subtype = 34
1847
1848 def __init__(self, xid=None, status=None):
1849 self.xid = xid
1850 if status != None:
1851 self.status = status
1852 else:
1853 self.status = 0
1854
1855 def pack(self):
1856 packed = []
1857 packed.append(struct.pack("!B", self.version))
1858 packed.append(struct.pack("!B", self.type))
1859 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1860 packed.append(struct.pack("!L", self.xid))
1861 packed.append(struct.pack("!L", self.experimenter))
1862 packed.append(struct.pack("!L", self.subtype))
1863 packed.append(struct.pack("!L", self.status))
1864 length = sum([len(x) for x in packed])
1865 packed[2] = struct.pack("!H", length)
1866 return ''.join(packed)
1867
1868 @staticmethod
1869 def unpack(buf):
1870 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1871 obj = bsn_pdu_rx_reply()
1872 if type(buf) == loxi.generic_util.OFReader:
1873 reader = buf
1874 else:
1875 reader = loxi.generic_util.OFReader(buf)
1876 _version = reader.read("!B")[0]
1877 assert(_version == 1)
1878 _type = reader.read("!B")[0]
1879 assert(_type == 4)
1880 _length = reader.read("!H")[0]
1881 obj.xid = reader.read("!L")[0]
1882 _experimenter = reader.read("!L")[0]
1883 assert(_experimenter == 6035143)
1884 _subtype = reader.read("!L")[0]
1885 assert(_subtype == 34)
1886 obj.status = reader.read("!L")[0]
1887 return obj
1888
1889 def __eq__(self, other):
1890 if type(self) != type(other): return False
1891 if self.version != other.version: return False
1892 if self.type != other.type: return False
1893 if self.xid != other.xid: return False
1894 if self.status != other.status: return False
1895 return True
1896
1897 def __ne__(self, other):
1898 return not self.__eq__(other)
1899
1900 def __str__(self):
1901 return self.show()
1902
1903 def show(self):
1904 import loxi.pp
1905 return loxi.pp.pp(self)
1906
1907 def pretty_print(self, q):
1908 q.text("bsn_pdu_rx_reply {")
1909 with q.group():
1910 with q.indent(2):
1911 q.breakable()
1912 q.text("xid = ");
1913 if self.xid != None:
1914 q.text("%#x" % self.xid)
1915 else:
1916 q.text('None')
1917 q.text(","); q.breakable()
1918 q.text("status = ");
1919 q.text("%#x" % self.status)
1920 q.breakable()
1921 q.text('}')
1922
1923class bsn_pdu_rx_request(Message):
1924 version = 1
1925 type = 4
1926 experimenter = 6035143
1927 subtype = 33
1928
1929 def __init__(self, xid=None, timeout_ms=None, port_no=None, slot_num=None, data=None):
1930 self.xid = xid
1931 if timeout_ms != None:
1932 self.timeout_ms = timeout_ms
1933 else:
1934 self.timeout_ms = 0
1935 if port_no != None:
1936 self.port_no = port_no
1937 else:
1938 self.port_no = 0
1939 if slot_num != None:
1940 self.slot_num = slot_num
1941 else:
1942 self.slot_num = 0
1943 if data != None:
1944 self.data = data
1945 else:
1946 self.data = ''
1947
1948 def pack(self):
1949 packed = []
1950 packed.append(struct.pack("!B", self.version))
1951 packed.append(struct.pack("!B", self.type))
1952 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1953 packed.append(struct.pack("!L", self.xid))
1954 packed.append(struct.pack("!L", self.experimenter))
1955 packed.append(struct.pack("!L", self.subtype))
1956 packed.append(struct.pack("!L", self.timeout_ms))
1957 packed.append(util.pack_port_no(self.port_no))
1958 packed.append(struct.pack("!B", self.slot_num))
1959 packed.append('\x00' * 3)
1960 packed.append(self.data)
1961 length = sum([len(x) for x in packed])
1962 packed[2] = struct.pack("!H", length)
1963 return ''.join(packed)
1964
1965 @staticmethod
1966 def unpack(buf):
1967 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1968 obj = bsn_pdu_rx_request()
1969 if type(buf) == loxi.generic_util.OFReader:
1970 reader = buf
1971 else:
1972 reader = loxi.generic_util.OFReader(buf)
1973 _version = reader.read("!B")[0]
1974 assert(_version == 1)
1975 _type = reader.read("!B")[0]
1976 assert(_type == 4)
1977 _length = reader.read("!H")[0]
1978 obj.xid = reader.read("!L")[0]
1979 _experimenter = reader.read("!L")[0]
1980 assert(_experimenter == 6035143)
1981 _subtype = reader.read("!L")[0]
1982 assert(_subtype == 33)
1983 obj.timeout_ms = reader.read("!L")[0]
1984 obj.port_no = util.unpack_port_no(reader)
1985 obj.slot_num = reader.read("!B")[0]
1986 reader.skip(3)
1987 obj.data = str(reader.read_all())
1988 return obj
1989
1990 def __eq__(self, other):
1991 if type(self) != type(other): return False
1992 if self.version != other.version: return False
1993 if self.type != other.type: return False
1994 if self.xid != other.xid: return False
1995 if self.timeout_ms != other.timeout_ms: return False
1996 if self.port_no != other.port_no: return False
1997 if self.slot_num != other.slot_num: return False
1998 if self.data != other.data: return False
1999 return True
2000
2001 def __ne__(self, other):
2002 return not self.__eq__(other)
2003
2004 def __str__(self):
2005 return self.show()
2006
2007 def show(self):
2008 import loxi.pp
2009 return loxi.pp.pp(self)
2010
2011 def pretty_print(self, q):
2012 q.text("bsn_pdu_rx_request {")
2013 with q.group():
2014 with q.indent(2):
2015 q.breakable()
2016 q.text("xid = ");
2017 if self.xid != None:
2018 q.text("%#x" % self.xid)
2019 else:
2020 q.text('None')
2021 q.text(","); q.breakable()
2022 q.text("timeout_ms = ");
2023 q.text("%#x" % self.timeout_ms)
2024 q.text(","); q.breakable()
2025 q.text("port_no = ");
2026 q.text(util.pretty_port(self.port_no))
2027 q.text(","); q.breakable()
2028 q.text("slot_num = ");
2029 q.text("%#x" % self.slot_num)
2030 q.text(","); q.breakable()
2031 q.text("data = ");
2032 q.pp(self.data)
2033 q.breakable()
2034 q.text('}')
2035
2036class bsn_pdu_rx_timeout(Message):
2037 version = 1
2038 type = 4
2039 experimenter = 6035143
2040 subtype = 35
2041
2042 def __init__(self, xid=None, port_no=None, slot_num=None):
2043 self.xid = xid
2044 if port_no != None:
2045 self.port_no = port_no
2046 else:
2047 self.port_no = 0
2048 if slot_num != None:
2049 self.slot_num = slot_num
2050 else:
2051 self.slot_num = 0
2052
2053 def pack(self):
2054 packed = []
2055 packed.append(struct.pack("!B", self.version))
2056 packed.append(struct.pack("!B", self.type))
2057 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2058 packed.append(struct.pack("!L", self.xid))
2059 packed.append(struct.pack("!L", self.experimenter))
2060 packed.append(struct.pack("!L", self.subtype))
2061 packed.append(util.pack_port_no(self.port_no))
2062 packed.append(struct.pack("!B", self.slot_num))
2063 length = sum([len(x) for x in packed])
2064 packed[2] = struct.pack("!H", length)
2065 return ''.join(packed)
2066
2067 @staticmethod
2068 def unpack(buf):
2069 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2070 obj = bsn_pdu_rx_timeout()
2071 if type(buf) == loxi.generic_util.OFReader:
2072 reader = buf
2073 else:
2074 reader = loxi.generic_util.OFReader(buf)
2075 _version = reader.read("!B")[0]
2076 assert(_version == 1)
2077 _type = reader.read("!B")[0]
2078 assert(_type == 4)
2079 _length = reader.read("!H")[0]
2080 obj.xid = reader.read("!L")[0]
2081 _experimenter = reader.read("!L")[0]
2082 assert(_experimenter == 6035143)
2083 _subtype = reader.read("!L")[0]
2084 assert(_subtype == 35)
2085 obj.port_no = util.unpack_port_no(reader)
2086 obj.slot_num = reader.read("!B")[0]
2087 return obj
2088
2089 def __eq__(self, other):
2090 if type(self) != type(other): return False
2091 if self.version != other.version: return False
2092 if self.type != other.type: return False
2093 if self.xid != other.xid: return False
2094 if self.port_no != other.port_no: return False
2095 if self.slot_num != other.slot_num: return False
2096 return True
2097
2098 def __ne__(self, other):
2099 return not self.__eq__(other)
2100
2101 def __str__(self):
2102 return self.show()
2103
2104 def show(self):
2105 import loxi.pp
2106 return loxi.pp.pp(self)
2107
2108 def pretty_print(self, q):
2109 q.text("bsn_pdu_rx_timeout {")
2110 with q.group():
2111 with q.indent(2):
2112 q.breakable()
2113 q.text("xid = ");
2114 if self.xid != None:
2115 q.text("%#x" % self.xid)
2116 else:
2117 q.text('None')
2118 q.text(","); q.breakable()
2119 q.text("port_no = ");
2120 q.text(util.pretty_port(self.port_no))
2121 q.text(","); q.breakable()
2122 q.text("slot_num = ");
2123 q.text("%#x" % self.slot_num)
2124 q.breakable()
2125 q.text('}')
2126
2127class bsn_pdu_tx_reply(Message):
2128 version = 1
2129 type = 4
2130 experimenter = 6035143
2131 subtype = 32
2132
2133 def __init__(self, xid=None, status=None):
2134 self.xid = xid
2135 if status != None:
2136 self.status = status
2137 else:
2138 self.status = 0
2139
2140 def pack(self):
2141 packed = []
2142 packed.append(struct.pack("!B", self.version))
2143 packed.append(struct.pack("!B", self.type))
2144 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2145 packed.append(struct.pack("!L", self.xid))
2146 packed.append(struct.pack("!L", self.experimenter))
2147 packed.append(struct.pack("!L", self.subtype))
2148 packed.append(struct.pack("!L", self.status))
2149 length = sum([len(x) for x in packed])
2150 packed[2] = struct.pack("!H", length)
2151 return ''.join(packed)
2152
2153 @staticmethod
2154 def unpack(buf):
2155 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2156 obj = bsn_pdu_tx_reply()
2157 if type(buf) == loxi.generic_util.OFReader:
2158 reader = buf
2159 else:
2160 reader = loxi.generic_util.OFReader(buf)
2161 _version = reader.read("!B")[0]
2162 assert(_version == 1)
2163 _type = reader.read("!B")[0]
2164 assert(_type == 4)
2165 _length = reader.read("!H")[0]
2166 obj.xid = reader.read("!L")[0]
2167 _experimenter = reader.read("!L")[0]
2168 assert(_experimenter == 6035143)
2169 _subtype = reader.read("!L")[0]
2170 assert(_subtype == 32)
2171 obj.status = reader.read("!L")[0]
2172 return obj
2173
2174 def __eq__(self, other):
2175 if type(self) != type(other): return False
2176 if self.version != other.version: return False
2177 if self.type != other.type: return False
2178 if self.xid != other.xid: return False
2179 if self.status != other.status: return False
2180 return True
2181
2182 def __ne__(self, other):
2183 return not self.__eq__(other)
2184
2185 def __str__(self):
2186 return self.show()
2187
2188 def show(self):
2189 import loxi.pp
2190 return loxi.pp.pp(self)
2191
2192 def pretty_print(self, q):
2193 q.text("bsn_pdu_tx_reply {")
2194 with q.group():
2195 with q.indent(2):
2196 q.breakable()
2197 q.text("xid = ");
2198 if self.xid != None:
2199 q.text("%#x" % self.xid)
2200 else:
2201 q.text('None')
2202 q.text(","); q.breakable()
2203 q.text("status = ");
2204 q.text("%#x" % self.status)
2205 q.breakable()
2206 q.text('}')
2207
2208class bsn_pdu_tx_request(Message):
2209 version = 1
2210 type = 4
2211 experimenter = 6035143
2212 subtype = 31
2213
2214 def __init__(self, xid=None, tx_interval_ms=None, port_no=None, slot_num=None, data=None):
2215 self.xid = xid
2216 if tx_interval_ms != None:
2217 self.tx_interval_ms = tx_interval_ms
2218 else:
2219 self.tx_interval_ms = 0
2220 if port_no != None:
2221 self.port_no = port_no
2222 else:
2223 self.port_no = 0
2224 if slot_num != None:
2225 self.slot_num = slot_num
2226 else:
2227 self.slot_num = 0
2228 if data != None:
2229 self.data = data
2230 else:
2231 self.data = ''
2232
2233 def pack(self):
2234 packed = []
2235 packed.append(struct.pack("!B", self.version))
2236 packed.append(struct.pack("!B", self.type))
2237 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2238 packed.append(struct.pack("!L", self.xid))
2239 packed.append(struct.pack("!L", self.experimenter))
2240 packed.append(struct.pack("!L", self.subtype))
2241 packed.append(struct.pack("!L", self.tx_interval_ms))
2242 packed.append(util.pack_port_no(self.port_no))
2243 packed.append(struct.pack("!B", self.slot_num))
2244 packed.append('\x00' * 3)
2245 packed.append(self.data)
2246 length = sum([len(x) for x in packed])
2247 packed[2] = struct.pack("!H", length)
2248 return ''.join(packed)
2249
2250 @staticmethod
2251 def unpack(buf):
2252 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2253 obj = bsn_pdu_tx_request()
2254 if type(buf) == loxi.generic_util.OFReader:
2255 reader = buf
2256 else:
2257 reader = loxi.generic_util.OFReader(buf)
2258 _version = reader.read("!B")[0]
2259 assert(_version == 1)
2260 _type = reader.read("!B")[0]
2261 assert(_type == 4)
2262 _length = reader.read("!H")[0]
2263 obj.xid = reader.read("!L")[0]
2264 _experimenter = reader.read("!L")[0]
2265 assert(_experimenter == 6035143)
2266 _subtype = reader.read("!L")[0]
2267 assert(_subtype == 31)
2268 obj.tx_interval_ms = reader.read("!L")[0]
2269 obj.port_no = util.unpack_port_no(reader)
2270 obj.slot_num = reader.read("!B")[0]
2271 reader.skip(3)
2272 obj.data = str(reader.read_all())
2273 return obj
2274
2275 def __eq__(self, other):
2276 if type(self) != type(other): return False
2277 if self.version != other.version: return False
2278 if self.type != other.type: return False
2279 if self.xid != other.xid: return False
2280 if self.tx_interval_ms != other.tx_interval_ms: return False
2281 if self.port_no != other.port_no: return False
2282 if self.slot_num != other.slot_num: return False
2283 if self.data != other.data: return False
2284 return True
2285
2286 def __ne__(self, other):
2287 return not self.__eq__(other)
2288
2289 def __str__(self):
2290 return self.show()
2291
2292 def show(self):
2293 import loxi.pp
2294 return loxi.pp.pp(self)
2295
2296 def pretty_print(self, q):
2297 q.text("bsn_pdu_tx_request {")
2298 with q.group():
2299 with q.indent(2):
2300 q.breakable()
2301 q.text("xid = ");
2302 if self.xid != None:
2303 q.text("%#x" % self.xid)
2304 else:
2305 q.text('None')
2306 q.text(","); q.breakable()
2307 q.text("tx_interval_ms = ");
2308 q.text("%#x" % self.tx_interval_ms)
2309 q.text(","); q.breakable()
2310 q.text("port_no = ");
2311 q.text(util.pretty_port(self.port_no))
2312 q.text(","); q.breakable()
2313 q.text("slot_num = ");
2314 q.text("%#x" % self.slot_num)
2315 q.text(","); q.breakable()
2316 q.text("data = ");
2317 q.pp(self.data)
2318 q.breakable()
2319 q.text('}')
2320
Rich Laneb658ddd2013-03-12 10:15:10 -07002321class bsn_set_ip_mask(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07002322 version = 1
2323 type = 4
2324 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07002325 subtype = 0
2326
Rich Lanec2ee4b82013-04-24 17:12:38 -07002327 def __init__(self, xid=None, index=None, mask=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07002328 self.xid = xid
2329 if index != None:
2330 self.index = index
2331 else:
2332 self.index = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07002333 if mask != None:
2334 self.mask = mask
2335 else:
2336 self.mask = 0
2337
2338 def pack(self):
2339 packed = []
2340 packed.append(struct.pack("!B", self.version))
2341 packed.append(struct.pack("!B", self.type))
2342 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2343 packed.append(struct.pack("!L", self.xid))
2344 packed.append(struct.pack("!L", self.experimenter))
2345 packed.append(struct.pack("!L", self.subtype))
2346 packed.append(struct.pack("!B", self.index))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002347 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07002348 packed.append(struct.pack("!L", self.mask))
2349 length = sum([len(x) for x in packed])
2350 packed[2] = struct.pack("!H", length)
2351 return ''.join(packed)
2352
2353 @staticmethod
2354 def unpack(buf):
2355 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2356 obj = bsn_set_ip_mask()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002357 if type(buf) == loxi.generic_util.OFReader:
2358 reader = buf
2359 else:
2360 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002361 _version = reader.read("!B")[0]
2362 assert(_version == 1)
2363 _type = reader.read("!B")[0]
2364 assert(_type == 4)
2365 _length = reader.read("!H")[0]
2366 obj.xid = reader.read("!L")[0]
2367 _experimenter = reader.read("!L")[0]
2368 assert(_experimenter == 6035143)
2369 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002370 assert(_subtype == 0)
Dan Talaycof6202252013-07-02 01:00:29 -07002371 obj.index = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002372 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07002373 obj.mask = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07002374 return obj
2375
2376 def __eq__(self, other):
2377 if type(self) != type(other): return False
2378 if self.version != other.version: return False
2379 if self.type != other.type: return False
2380 if self.xid != other.xid: return False
2381 if self.index != other.index: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07002382 if self.mask != other.mask: return False
2383 return True
2384
2385 def __ne__(self, other):
2386 return not self.__eq__(other)
2387
2388 def __str__(self):
2389 return self.show()
2390
2391 def show(self):
2392 import loxi.pp
2393 return loxi.pp.pp(self)
2394
2395 def pretty_print(self, q):
2396 q.text("bsn_set_ip_mask {")
2397 with q.group():
2398 with q.indent(2):
2399 q.breakable()
2400 q.text("xid = ");
2401 if self.xid != None:
2402 q.text("%#x" % self.xid)
2403 else:
2404 q.text('None')
2405 q.text(","); q.breakable()
2406 q.text("index = ");
2407 q.text("%#x" % self.index)
2408 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07002409 q.text("mask = ");
2410 q.text("%#x" % self.mask)
2411 q.breakable()
2412 q.text('}')
2413
Dan Talaycof6202252013-07-02 01:00:29 -07002414class bsn_set_l2_table_reply(Message):
2415 version = 1
2416 type = 4
2417 experimenter = 6035143
2418 subtype = 24
2419
2420 def __init__(self, xid=None, l2_table_enable=None, l2_table_priority=None, status=None):
2421 self.xid = xid
2422 if l2_table_enable != None:
2423 self.l2_table_enable = l2_table_enable
2424 else:
2425 self.l2_table_enable = 0
2426 if l2_table_priority != None:
2427 self.l2_table_priority = l2_table_priority
2428 else:
2429 self.l2_table_priority = 0
2430 if status != None:
2431 self.status = status
2432 else:
2433 self.status = 0
2434
2435 def pack(self):
2436 packed = []
2437 packed.append(struct.pack("!B", self.version))
2438 packed.append(struct.pack("!B", self.type))
2439 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2440 packed.append(struct.pack("!L", self.xid))
2441 packed.append(struct.pack("!L", self.experimenter))
2442 packed.append(struct.pack("!L", self.subtype))
2443 packed.append(struct.pack("!B", self.l2_table_enable))
2444 packed.append('\x00' * 1)
2445 packed.append(struct.pack("!H", self.l2_table_priority))
2446 packed.append(struct.pack("!L", self.status))
2447 length = sum([len(x) for x in packed])
2448 packed[2] = struct.pack("!H", length)
2449 return ''.join(packed)
2450
2451 @staticmethod
2452 def unpack(buf):
2453 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2454 obj = bsn_set_l2_table_reply()
2455 if type(buf) == loxi.generic_util.OFReader:
2456 reader = buf
2457 else:
2458 reader = loxi.generic_util.OFReader(buf)
2459 _version = reader.read("!B")[0]
2460 assert(_version == 1)
2461 _type = reader.read("!B")[0]
2462 assert(_type == 4)
2463 _length = reader.read("!H")[0]
2464 obj.xid = reader.read("!L")[0]
2465 _experimenter = reader.read("!L")[0]
2466 assert(_experimenter == 6035143)
2467 _subtype = reader.read("!L")[0]
2468 assert(_subtype == 24)
2469 obj.l2_table_enable = reader.read("!B")[0]
2470 reader.skip(1)
2471 obj.l2_table_priority = reader.read("!H")[0]
2472 obj.status = reader.read("!L")[0]
2473 return obj
2474
2475 def __eq__(self, other):
2476 if type(self) != type(other): return False
2477 if self.version != other.version: return False
2478 if self.type != other.type: return False
2479 if self.xid != other.xid: return False
2480 if self.l2_table_enable != other.l2_table_enable: return False
2481 if self.l2_table_priority != other.l2_table_priority: return False
2482 if self.status != other.status: return False
2483 return True
2484
2485 def __ne__(self, other):
2486 return not self.__eq__(other)
2487
2488 def __str__(self):
2489 return self.show()
2490
2491 def show(self):
2492 import loxi.pp
2493 return loxi.pp.pp(self)
2494
2495 def pretty_print(self, q):
2496 q.text("bsn_set_l2_table_reply {")
2497 with q.group():
2498 with q.indent(2):
2499 q.breakable()
2500 q.text("xid = ");
2501 if self.xid != None:
2502 q.text("%#x" % self.xid)
2503 else:
2504 q.text('None')
2505 q.text(","); q.breakable()
2506 q.text("l2_table_enable = ");
2507 q.text("%#x" % self.l2_table_enable)
2508 q.text(","); q.breakable()
2509 q.text("l2_table_priority = ");
2510 q.text("%#x" % self.l2_table_priority)
2511 q.text(","); q.breakable()
2512 q.text("status = ");
2513 q.text("%#x" % self.status)
2514 q.breakable()
2515 q.text('}')
2516
2517class bsn_set_l2_table_request(Message):
2518 version = 1
2519 type = 4
2520 experimenter = 6035143
Rich Lane90c961c2013-05-14 09:26:50 -07002521 subtype = 12
2522
2523 def __init__(self, xid=None, l2_table_enable=None, l2_table_priority=None):
2524 self.xid = xid
2525 if l2_table_enable != None:
2526 self.l2_table_enable = l2_table_enable
2527 else:
2528 self.l2_table_enable = 0
2529 if l2_table_priority != None:
2530 self.l2_table_priority = l2_table_priority
2531 else:
2532 self.l2_table_priority = 0
2533
2534 def pack(self):
2535 packed = []
2536 packed.append(struct.pack("!B", self.version))
2537 packed.append(struct.pack("!B", self.type))
2538 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2539 packed.append(struct.pack("!L", self.xid))
2540 packed.append(struct.pack("!L", self.experimenter))
2541 packed.append(struct.pack("!L", self.subtype))
2542 packed.append(struct.pack("!B", self.l2_table_enable))
2543 packed.append('\x00' * 1)
2544 packed.append(struct.pack("!H", self.l2_table_priority))
2545 packed.append('\x00' * 4)
2546 length = sum([len(x) for x in packed])
2547 packed[2] = struct.pack("!H", length)
2548 return ''.join(packed)
2549
2550 @staticmethod
2551 def unpack(buf):
2552 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
Dan Talaycof6202252013-07-02 01:00:29 -07002553 obj = bsn_set_l2_table_request()
Rich Lane90c961c2013-05-14 09:26:50 -07002554 if type(buf) == loxi.generic_util.OFReader:
2555 reader = buf
2556 else:
2557 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002558 _version = reader.read("!B")[0]
2559 assert(_version == 1)
2560 _type = reader.read("!B")[0]
2561 assert(_type == 4)
2562 _length = reader.read("!H")[0]
2563 obj.xid = reader.read("!L")[0]
2564 _experimenter = reader.read("!L")[0]
2565 assert(_experimenter == 6035143)
2566 _subtype = reader.read("!L")[0]
Rich Lane90c961c2013-05-14 09:26:50 -07002567 assert(_subtype == 12)
Dan Talaycof6202252013-07-02 01:00:29 -07002568 obj.l2_table_enable = reader.read("!B")[0]
Rich Lane90c961c2013-05-14 09:26:50 -07002569 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07002570 obj.l2_table_priority = reader.read("!H")[0]
Rich Lane90c961c2013-05-14 09:26:50 -07002571 reader.skip(4)
2572 return obj
2573
2574 def __eq__(self, other):
2575 if type(self) != type(other): return False
2576 if self.version != other.version: return False
2577 if self.type != other.type: return False
2578 if self.xid != other.xid: return False
2579 if self.l2_table_enable != other.l2_table_enable: return False
2580 if self.l2_table_priority != other.l2_table_priority: return False
2581 return True
2582
2583 def __ne__(self, other):
2584 return not self.__eq__(other)
2585
2586 def __str__(self):
2587 return self.show()
2588
2589 def show(self):
2590 import loxi.pp
2591 return loxi.pp.pp(self)
2592
2593 def pretty_print(self, q):
Dan Talaycof6202252013-07-02 01:00:29 -07002594 q.text("bsn_set_l2_table_request {")
Rich Lane90c961c2013-05-14 09:26:50 -07002595 with q.group():
2596 with q.indent(2):
2597 q.breakable()
2598 q.text("xid = ");
2599 if self.xid != None:
2600 q.text("%#x" % self.xid)
2601 else:
2602 q.text('None')
2603 q.text(","); q.breakable()
2604 q.text("l2_table_enable = ");
2605 q.text("%#x" % self.l2_table_enable)
2606 q.text(","); q.breakable()
2607 q.text("l2_table_priority = ");
2608 q.text("%#x" % self.l2_table_priority)
2609 q.breakable()
2610 q.text('}')
2611
Rich Laneb658ddd2013-03-12 10:15:10 -07002612class bsn_set_mirroring(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07002613 version = 1
2614 type = 4
2615 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07002616 subtype = 3
2617
Rich Lanec2ee4b82013-04-24 17:12:38 -07002618 def __init__(self, xid=None, report_mirror_ports=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07002619 self.xid = xid
2620 if report_mirror_ports != None:
2621 self.report_mirror_ports = report_mirror_ports
2622 else:
2623 self.report_mirror_ports = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07002624
2625 def pack(self):
2626 packed = []
2627 packed.append(struct.pack("!B", self.version))
2628 packed.append(struct.pack("!B", self.type))
2629 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2630 packed.append(struct.pack("!L", self.xid))
2631 packed.append(struct.pack("!L", self.experimenter))
2632 packed.append(struct.pack("!L", self.subtype))
2633 packed.append(struct.pack("!B", self.report_mirror_ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002634 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07002635 length = sum([len(x) for x in packed])
2636 packed[2] = struct.pack("!H", length)
2637 return ''.join(packed)
2638
2639 @staticmethod
2640 def unpack(buf):
2641 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2642 obj = bsn_set_mirroring()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002643 if type(buf) == loxi.generic_util.OFReader:
2644 reader = buf
2645 else:
2646 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002647 _version = reader.read("!B")[0]
2648 assert(_version == 1)
2649 _type = reader.read("!B")[0]
2650 assert(_type == 4)
2651 _length = reader.read("!H")[0]
2652 obj.xid = reader.read("!L")[0]
2653 _experimenter = reader.read("!L")[0]
2654 assert(_experimenter == 6035143)
2655 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002656 assert(_subtype == 3)
Dan Talaycof6202252013-07-02 01:00:29 -07002657 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002658 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -07002659 return obj
2660
2661 def __eq__(self, other):
2662 if type(self) != type(other): return False
2663 if self.version != other.version: return False
2664 if self.type != other.type: return False
2665 if self.xid != other.xid: return False
2666 if self.report_mirror_ports != other.report_mirror_ports: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07002667 return True
2668
2669 def __ne__(self, other):
2670 return not self.__eq__(other)
2671
2672 def __str__(self):
2673 return self.show()
2674
2675 def show(self):
2676 import loxi.pp
2677 return loxi.pp.pp(self)
2678
2679 def pretty_print(self, q):
2680 q.text("bsn_set_mirroring {")
2681 with q.group():
2682 with q.indent(2):
2683 q.breakable()
2684 q.text("xid = ");
2685 if self.xid != None:
2686 q.text("%#x" % self.xid)
2687 else:
2688 q.text('None')
2689 q.text(","); q.breakable()
2690 q.text("report_mirror_ports = ");
2691 q.text("%#x" % self.report_mirror_ports)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002692 q.breakable()
2693 q.text('}')
2694
Dan Talaycof6202252013-07-02 01:00:29 -07002695class bsn_set_pktin_suppression_reply(Message):
2696 version = 1
2697 type = 4
2698 experimenter = 6035143
2699 subtype = 25
2700
2701 def __init__(self, xid=None, status=None):
2702 self.xid = xid
2703 if status != None:
2704 self.status = status
2705 else:
2706 self.status = 0
2707
2708 def pack(self):
2709 packed = []
2710 packed.append(struct.pack("!B", self.version))
2711 packed.append(struct.pack("!B", self.type))
2712 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2713 packed.append(struct.pack("!L", self.xid))
2714 packed.append(struct.pack("!L", self.experimenter))
2715 packed.append(struct.pack("!L", self.subtype))
2716 packed.append(struct.pack("!L", self.status))
2717 length = sum([len(x) for x in packed])
2718 packed[2] = struct.pack("!H", length)
2719 return ''.join(packed)
2720
2721 @staticmethod
2722 def unpack(buf):
2723 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2724 obj = bsn_set_pktin_suppression_reply()
2725 if type(buf) == loxi.generic_util.OFReader:
2726 reader = buf
2727 else:
2728 reader = loxi.generic_util.OFReader(buf)
2729 _version = reader.read("!B")[0]
2730 assert(_version == 1)
2731 _type = reader.read("!B")[0]
2732 assert(_type == 4)
2733 _length = reader.read("!H")[0]
2734 obj.xid = reader.read("!L")[0]
2735 _experimenter = reader.read("!L")[0]
2736 assert(_experimenter == 6035143)
2737 _subtype = reader.read("!L")[0]
2738 assert(_subtype == 25)
2739 obj.status = reader.read("!L")[0]
2740 return obj
2741
2742 def __eq__(self, other):
2743 if type(self) != type(other): return False
2744 if self.version != other.version: return False
2745 if self.type != other.type: return False
2746 if self.xid != other.xid: return False
2747 if self.status != other.status: return False
2748 return True
2749
2750 def __ne__(self, other):
2751 return not self.__eq__(other)
2752
2753 def __str__(self):
2754 return self.show()
2755
2756 def show(self):
2757 import loxi.pp
2758 return loxi.pp.pp(self)
2759
2760 def pretty_print(self, q):
2761 q.text("bsn_set_pktin_suppression_reply {")
2762 with q.group():
2763 with q.indent(2):
2764 q.breakable()
2765 q.text("xid = ");
2766 if self.xid != None:
2767 q.text("%#x" % self.xid)
2768 else:
2769 q.text('None')
2770 q.text(","); q.breakable()
2771 q.text("status = ");
2772 q.text("%#x" % self.status)
2773 q.breakable()
2774 q.text('}')
2775
2776class bsn_set_pktin_suppression_request(Message):
2777 version = 1
2778 type = 4
2779 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07002780 subtype = 11
2781
2782 def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None):
2783 self.xid = xid
2784 if enabled != None:
2785 self.enabled = enabled
2786 else:
2787 self.enabled = 0
2788 if idle_timeout != None:
2789 self.idle_timeout = idle_timeout
2790 else:
2791 self.idle_timeout = 0
2792 if hard_timeout != None:
2793 self.hard_timeout = hard_timeout
2794 else:
2795 self.hard_timeout = 0
2796 if priority != None:
2797 self.priority = priority
2798 else:
2799 self.priority = 0
2800 if cookie != None:
2801 self.cookie = cookie
2802 else:
2803 self.cookie = 0
2804
2805 def pack(self):
2806 packed = []
2807 packed.append(struct.pack("!B", self.version))
2808 packed.append(struct.pack("!B", self.type))
2809 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2810 packed.append(struct.pack("!L", self.xid))
2811 packed.append(struct.pack("!L", self.experimenter))
2812 packed.append(struct.pack("!L", self.subtype))
2813 packed.append(struct.pack("!B", self.enabled))
2814 packed.append('\x00' * 1)
2815 packed.append(struct.pack("!H", self.idle_timeout))
2816 packed.append(struct.pack("!H", self.hard_timeout))
2817 packed.append(struct.pack("!H", self.priority))
2818 packed.append(struct.pack("!Q", self.cookie))
2819 length = sum([len(x) for x in packed])
2820 packed[2] = struct.pack("!H", length)
2821 return ''.join(packed)
2822
2823 @staticmethod
2824 def unpack(buf):
2825 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
Dan Talaycof6202252013-07-02 01:00:29 -07002826 obj = bsn_set_pktin_suppression_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002827 if type(buf) == loxi.generic_util.OFReader:
2828 reader = buf
2829 else:
2830 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002831 _version = reader.read("!B")[0]
2832 assert(_version == 1)
2833 _type = reader.read("!B")[0]
2834 assert(_type == 4)
2835 _length = reader.read("!H")[0]
2836 obj.xid = reader.read("!L")[0]
2837 _experimenter = reader.read("!L")[0]
2838 assert(_experimenter == 6035143)
2839 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002840 assert(_subtype == 11)
Dan Talaycof6202252013-07-02 01:00:29 -07002841 obj.enabled = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002842 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07002843 obj.idle_timeout = reader.read("!H")[0]
2844 obj.hard_timeout = reader.read("!H")[0]
2845 obj.priority = reader.read("!H")[0]
2846 obj.cookie = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002847 return obj
2848
2849 def __eq__(self, other):
2850 if type(self) != type(other): return False
2851 if self.version != other.version: return False
2852 if self.type != other.type: return False
2853 if self.xid != other.xid: return False
2854 if self.enabled != other.enabled: return False
2855 if self.idle_timeout != other.idle_timeout: return False
2856 if self.hard_timeout != other.hard_timeout: return False
2857 if self.priority != other.priority: return False
2858 if self.cookie != other.cookie: return False
2859 return True
2860
2861 def __ne__(self, other):
2862 return not self.__eq__(other)
2863
2864 def __str__(self):
2865 return self.show()
2866
2867 def show(self):
2868 import loxi.pp
2869 return loxi.pp.pp(self)
2870
2871 def pretty_print(self, q):
Dan Talaycof6202252013-07-02 01:00:29 -07002872 q.text("bsn_set_pktin_suppression_request {")
Rich Lanec2ee4b82013-04-24 17:12:38 -07002873 with q.group():
2874 with q.indent(2):
2875 q.breakable()
2876 q.text("xid = ");
2877 if self.xid != None:
2878 q.text("%#x" % self.xid)
2879 else:
2880 q.text('None')
Rich Laneb658ddd2013-03-12 10:15:10 -07002881 q.text(","); q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002882 q.text("enabled = ");
2883 q.text("%#x" % self.enabled)
2884 q.text(","); q.breakable()
2885 q.text("idle_timeout = ");
2886 q.text("%#x" % self.idle_timeout)
2887 q.text(","); q.breakable()
2888 q.text("hard_timeout = ");
2889 q.text("%#x" % self.hard_timeout)
2890 q.text(","); q.breakable()
2891 q.text("priority = ");
2892 q.text("%#x" % self.priority)
2893 q.text(","); q.breakable()
2894 q.text("cookie = ");
2895 q.text("%#x" % self.cookie)
Rich Laneb658ddd2013-03-12 10:15:10 -07002896 q.breakable()
2897 q.text('}')
2898
2899class bsn_shell_command(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07002900 version = 1
2901 type = 4
2902 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07002903 subtype = 6
2904
2905 def __init__(self, xid=None, service=None, data=None):
2906 self.xid = xid
2907 if service != None:
2908 self.service = service
2909 else:
2910 self.service = 0
2911 if data != None:
2912 self.data = data
2913 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002914 self.data = ''
Rich Laneb658ddd2013-03-12 10:15:10 -07002915
2916 def pack(self):
2917 packed = []
2918 packed.append(struct.pack("!B", self.version))
2919 packed.append(struct.pack("!B", self.type))
2920 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2921 packed.append(struct.pack("!L", self.xid))
2922 packed.append(struct.pack("!L", self.experimenter))
2923 packed.append(struct.pack("!L", self.subtype))
2924 packed.append(struct.pack("!L", self.service))
2925 packed.append(self.data)
2926 length = sum([len(x) for x in packed])
2927 packed[2] = struct.pack("!H", length)
2928 return ''.join(packed)
2929
2930 @staticmethod
2931 def unpack(buf):
2932 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2933 obj = bsn_shell_command()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002934 if type(buf) == loxi.generic_util.OFReader:
2935 reader = buf
2936 else:
2937 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002938 _version = reader.read("!B")[0]
2939 assert(_version == 1)
2940 _type = reader.read("!B")[0]
2941 assert(_type == 4)
2942 _length = reader.read("!H")[0]
2943 obj.xid = reader.read("!L")[0]
2944 _experimenter = reader.read("!L")[0]
2945 assert(_experimenter == 6035143)
2946 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002947 assert(_subtype == 6)
Dan Talaycof6202252013-07-02 01:00:29 -07002948 obj.service = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002949 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07002950 return obj
2951
2952 def __eq__(self, other):
2953 if type(self) != type(other): return False
2954 if self.version != other.version: return False
2955 if self.type != other.type: return False
2956 if self.xid != other.xid: return False
2957 if self.service != other.service: return False
2958 if self.data != other.data: return False
2959 return True
2960
2961 def __ne__(self, other):
2962 return not self.__eq__(other)
2963
2964 def __str__(self):
2965 return self.show()
2966
2967 def show(self):
2968 import loxi.pp
2969 return loxi.pp.pp(self)
2970
2971 def pretty_print(self, q):
2972 q.text("bsn_shell_command {")
2973 with q.group():
2974 with q.indent(2):
2975 q.breakable()
2976 q.text("xid = ");
2977 if self.xid != None:
2978 q.text("%#x" % self.xid)
2979 else:
2980 q.text('None')
2981 q.text(","); q.breakable()
2982 q.text("service = ");
2983 q.text("%#x" % self.service)
2984 q.text(","); q.breakable()
2985 q.text("data = ");
2986 q.pp(self.data)
2987 q.breakable()
2988 q.text('}')
2989
2990class bsn_shell_output(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07002991 version = 1
2992 type = 4
2993 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07002994 subtype = 7
2995
2996 def __init__(self, xid=None, data=None):
2997 self.xid = xid
2998 if data != None:
2999 self.data = data
3000 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003001 self.data = ''
Rich Laneb658ddd2013-03-12 10:15:10 -07003002
3003 def pack(self):
3004 packed = []
3005 packed.append(struct.pack("!B", self.version))
3006 packed.append(struct.pack("!B", self.type))
3007 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3008 packed.append(struct.pack("!L", self.xid))
3009 packed.append(struct.pack("!L", self.experimenter))
3010 packed.append(struct.pack("!L", self.subtype))
3011 packed.append(self.data)
3012 length = sum([len(x) for x in packed])
3013 packed[2] = struct.pack("!H", length)
3014 return ''.join(packed)
3015
3016 @staticmethod
3017 def unpack(buf):
3018 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3019 obj = bsn_shell_output()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003020 if type(buf) == loxi.generic_util.OFReader:
3021 reader = buf
3022 else:
3023 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003024 _version = reader.read("!B")[0]
3025 assert(_version == 1)
3026 _type = reader.read("!B")[0]
3027 assert(_type == 4)
3028 _length = reader.read("!H")[0]
3029 obj.xid = reader.read("!L")[0]
3030 _experimenter = reader.read("!L")[0]
3031 assert(_experimenter == 6035143)
3032 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003033 assert(_subtype == 7)
3034 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07003035 return obj
3036
3037 def __eq__(self, other):
3038 if type(self) != type(other): return False
3039 if self.version != other.version: return False
3040 if self.type != other.type: return False
3041 if self.xid != other.xid: return False
3042 if self.data != other.data: return False
3043 return True
3044
3045 def __ne__(self, other):
3046 return not self.__eq__(other)
3047
3048 def __str__(self):
3049 return self.show()
3050
3051 def show(self):
3052 import loxi.pp
3053 return loxi.pp.pp(self)
3054
3055 def pretty_print(self, q):
3056 q.text("bsn_shell_output {")
3057 with q.group():
3058 with q.indent(2):
3059 q.breakable()
3060 q.text("xid = ");
3061 if self.xid != None:
3062 q.text("%#x" % self.xid)
3063 else:
3064 q.text('None')
3065 q.text(","); q.breakable()
3066 q.text("data = ");
3067 q.pp(self.data)
3068 q.breakable()
3069 q.text('}')
3070
3071class bsn_shell_status(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003072 version = 1
3073 type = 4
3074 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -07003075 subtype = 8
3076
3077 def __init__(self, xid=None, status=None):
3078 self.xid = xid
3079 if status != None:
3080 self.status = status
3081 else:
3082 self.status = 0
3083
3084 def pack(self):
3085 packed = []
3086 packed.append(struct.pack("!B", self.version))
3087 packed.append(struct.pack("!B", self.type))
3088 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3089 packed.append(struct.pack("!L", self.xid))
3090 packed.append(struct.pack("!L", self.experimenter))
3091 packed.append(struct.pack("!L", self.subtype))
3092 packed.append(struct.pack("!L", self.status))
3093 length = sum([len(x) for x in packed])
3094 packed[2] = struct.pack("!H", length)
3095 return ''.join(packed)
3096
3097 @staticmethod
3098 def unpack(buf):
3099 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3100 obj = bsn_shell_status()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003101 if type(buf) == loxi.generic_util.OFReader:
3102 reader = buf
3103 else:
3104 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003105 _version = reader.read("!B")[0]
3106 assert(_version == 1)
3107 _type = reader.read("!B")[0]
3108 assert(_type == 4)
3109 _length = reader.read("!H")[0]
3110 obj.xid = reader.read("!L")[0]
3111 _experimenter = reader.read("!L")[0]
3112 assert(_experimenter == 6035143)
3113 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003114 assert(_subtype == 8)
Dan Talaycof6202252013-07-02 01:00:29 -07003115 obj.status = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07003116 return obj
3117
3118 def __eq__(self, other):
3119 if type(self) != type(other): return False
3120 if self.version != other.version: return False
3121 if self.type != other.type: return False
3122 if self.xid != other.xid: return False
3123 if self.status != other.status: return False
3124 return True
3125
3126 def __ne__(self, other):
3127 return not self.__eq__(other)
3128
3129 def __str__(self):
3130 return self.show()
3131
3132 def show(self):
3133 import loxi.pp
3134 return loxi.pp.pp(self)
3135
3136 def pretty_print(self, q):
3137 q.text("bsn_shell_status {")
3138 with q.group():
3139 with q.indent(2):
3140 q.breakable()
3141 q.text("xid = ");
3142 if self.xid != None:
3143 q.text("%#x" % self.xid)
3144 else:
3145 q.text('None')
3146 q.text(","); q.breakable()
3147 q.text("status = ");
3148 q.text("%#x" % self.status)
3149 q.breakable()
3150 q.text('}')
3151
Dan Talaycof6202252013-07-02 01:00:29 -07003152class bsn_virtual_port_create_reply(Message):
3153 version = 1
3154 type = 4
3155 experimenter = 6035143
3156 subtype = 16
3157
3158 def __init__(self, xid=None, status=None, vport_no=None):
3159 self.xid = xid
3160 if status != None:
3161 self.status = status
3162 else:
3163 self.status = 0
3164 if vport_no != None:
3165 self.vport_no = vport_no
3166 else:
3167 self.vport_no = 0
3168
3169 def pack(self):
3170 packed = []
3171 packed.append(struct.pack("!B", self.version))
3172 packed.append(struct.pack("!B", self.type))
3173 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3174 packed.append(struct.pack("!L", self.xid))
3175 packed.append(struct.pack("!L", self.experimenter))
3176 packed.append(struct.pack("!L", self.subtype))
3177 packed.append(struct.pack("!L", self.status))
3178 packed.append(struct.pack("!L", self.vport_no))
3179 length = sum([len(x) for x in packed])
3180 packed[2] = struct.pack("!H", length)
3181 return ''.join(packed)
3182
3183 @staticmethod
3184 def unpack(buf):
3185 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3186 obj = bsn_virtual_port_create_reply()
3187 if type(buf) == loxi.generic_util.OFReader:
3188 reader = buf
3189 else:
3190 reader = loxi.generic_util.OFReader(buf)
3191 _version = reader.read("!B")[0]
3192 assert(_version == 1)
3193 _type = reader.read("!B")[0]
3194 assert(_type == 4)
3195 _length = reader.read("!H")[0]
3196 obj.xid = reader.read("!L")[0]
3197 _experimenter = reader.read("!L")[0]
3198 assert(_experimenter == 6035143)
3199 _subtype = reader.read("!L")[0]
3200 assert(_subtype == 16)
3201 obj.status = reader.read("!L")[0]
3202 obj.vport_no = reader.read("!L")[0]
3203 return obj
3204
3205 def __eq__(self, other):
3206 if type(self) != type(other): return False
3207 if self.version != other.version: return False
3208 if self.type != other.type: return False
3209 if self.xid != other.xid: return False
3210 if self.status != other.status: return False
3211 if self.vport_no != other.vport_no: return False
3212 return True
3213
3214 def __ne__(self, other):
3215 return not self.__eq__(other)
3216
3217 def __str__(self):
3218 return self.show()
3219
3220 def show(self):
3221 import loxi.pp
3222 return loxi.pp.pp(self)
3223
3224 def pretty_print(self, q):
3225 q.text("bsn_virtual_port_create_reply {")
3226 with q.group():
3227 with q.indent(2):
3228 q.breakable()
3229 q.text("xid = ");
3230 if self.xid != None:
3231 q.text("%#x" % self.xid)
3232 else:
3233 q.text('None')
3234 q.text(","); q.breakable()
3235 q.text("status = ");
3236 q.text("%#x" % self.status)
3237 q.text(","); q.breakable()
3238 q.text("vport_no = ");
3239 q.text("%#x" % self.vport_no)
3240 q.breakable()
3241 q.text('}')
3242
3243class bsn_virtual_port_create_request(Message):
3244 version = 1
3245 type = 4
3246 experimenter = 6035143
3247 subtype = 15
3248
3249 def __init__(self, xid=None, vport=None):
3250 self.xid = xid
3251 if vport != None:
3252 self.vport = vport
3253 else:
3254 self.vport = common.bsn_vport_q_in_q()
3255
3256 def pack(self):
3257 packed = []
3258 packed.append(struct.pack("!B", self.version))
3259 packed.append(struct.pack("!B", self.type))
3260 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3261 packed.append(struct.pack("!L", self.xid))
3262 packed.append(struct.pack("!L", self.experimenter))
3263 packed.append(struct.pack("!L", self.subtype))
3264 packed.append(self.vport.pack())
3265 length = sum([len(x) for x in packed])
3266 packed[2] = struct.pack("!H", length)
3267 return ''.join(packed)
3268
3269 @staticmethod
3270 def unpack(buf):
3271 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3272 obj = bsn_virtual_port_create_request()
3273 if type(buf) == loxi.generic_util.OFReader:
3274 reader = buf
3275 else:
3276 reader = loxi.generic_util.OFReader(buf)
3277 _version = reader.read("!B")[0]
3278 assert(_version == 1)
3279 _type = reader.read("!B")[0]
3280 assert(_type == 4)
3281 _length = reader.read("!H")[0]
3282 obj.xid = reader.read("!L")[0]
3283 _experimenter = reader.read("!L")[0]
3284 assert(_experimenter == 6035143)
3285 _subtype = reader.read("!L")[0]
3286 assert(_subtype == 15)
3287 obj.vport = common.bsn_vport_q_in_q.unpack(reader)
3288 return obj
3289
3290 def __eq__(self, other):
3291 if type(self) != type(other): return False
3292 if self.version != other.version: return False
3293 if self.type != other.type: return False
3294 if self.xid != other.xid: return False
3295 if self.vport != other.vport: return False
3296 return True
3297
3298 def __ne__(self, other):
3299 return not self.__eq__(other)
3300
3301 def __str__(self):
3302 return self.show()
3303
3304 def show(self):
3305 import loxi.pp
3306 return loxi.pp.pp(self)
3307
3308 def pretty_print(self, q):
3309 q.text("bsn_virtual_port_create_request {")
3310 with q.group():
3311 with q.indent(2):
3312 q.breakable()
3313 q.text("xid = ");
3314 if self.xid != None:
3315 q.text("%#x" % self.xid)
3316 else:
3317 q.text('None')
3318 q.text(","); q.breakable()
3319 q.text("vport = ");
3320 q.pp(self.vport)
3321 q.breakable()
3322 q.text('}')
3323
3324class bsn_virtual_port_remove_reply(Message):
3325 version = 1
3326 type = 4
3327 experimenter = 6035143
3328 subtype = 26
3329
3330 def __init__(self, xid=None, status=None):
3331 self.xid = xid
3332 if status != None:
3333 self.status = status
3334 else:
3335 self.status = 0
3336
3337 def pack(self):
3338 packed = []
3339 packed.append(struct.pack("!B", self.version))
3340 packed.append(struct.pack("!B", self.type))
3341 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3342 packed.append(struct.pack("!L", self.xid))
3343 packed.append(struct.pack("!L", self.experimenter))
3344 packed.append(struct.pack("!L", self.subtype))
3345 packed.append(struct.pack("!L", self.status))
3346 length = sum([len(x) for x in packed])
3347 packed[2] = struct.pack("!H", length)
3348 return ''.join(packed)
3349
3350 @staticmethod
3351 def unpack(buf):
3352 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3353 obj = bsn_virtual_port_remove_reply()
3354 if type(buf) == loxi.generic_util.OFReader:
3355 reader = buf
3356 else:
3357 reader = loxi.generic_util.OFReader(buf)
3358 _version = reader.read("!B")[0]
3359 assert(_version == 1)
3360 _type = reader.read("!B")[0]
3361 assert(_type == 4)
3362 _length = reader.read("!H")[0]
3363 obj.xid = reader.read("!L")[0]
3364 _experimenter = reader.read("!L")[0]
3365 assert(_experimenter == 6035143)
3366 _subtype = reader.read("!L")[0]
3367 assert(_subtype == 26)
3368 obj.status = reader.read("!L")[0]
3369 return obj
3370
3371 def __eq__(self, other):
3372 if type(self) != type(other): return False
3373 if self.version != other.version: return False
3374 if self.type != other.type: return False
3375 if self.xid != other.xid: return False
3376 if self.status != other.status: return False
3377 return True
3378
3379 def __ne__(self, other):
3380 return not self.__eq__(other)
3381
3382 def __str__(self):
3383 return self.show()
3384
3385 def show(self):
3386 import loxi.pp
3387 return loxi.pp.pp(self)
3388
3389 def pretty_print(self, q):
3390 q.text("bsn_virtual_port_remove_reply {")
3391 with q.group():
3392 with q.indent(2):
3393 q.breakable()
3394 q.text("xid = ");
3395 if self.xid != None:
3396 q.text("%#x" % self.xid)
3397 else:
3398 q.text('None')
3399 q.text(","); q.breakable()
3400 q.text("status = ");
3401 q.text("%#x" % self.status)
3402 q.breakable()
3403 q.text('}')
3404
3405class bsn_virtual_port_remove_request(Message):
3406 version = 1
3407 type = 4
3408 experimenter = 6035143
3409 subtype = 17
3410
3411 def __init__(self, xid=None, vport_no=None):
3412 self.xid = xid
3413 if vport_no != None:
3414 self.vport_no = vport_no
3415 else:
3416 self.vport_no = 0
3417
3418 def pack(self):
3419 packed = []
3420 packed.append(struct.pack("!B", self.version))
3421 packed.append(struct.pack("!B", self.type))
3422 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3423 packed.append(struct.pack("!L", self.xid))
3424 packed.append(struct.pack("!L", self.experimenter))
3425 packed.append(struct.pack("!L", self.subtype))
3426 packed.append(struct.pack("!L", self.vport_no))
3427 length = sum([len(x) for x in packed])
3428 packed[2] = struct.pack("!H", length)
3429 return ''.join(packed)
3430
3431 @staticmethod
3432 def unpack(buf):
3433 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3434 obj = bsn_virtual_port_remove_request()
3435 if type(buf) == loxi.generic_util.OFReader:
3436 reader = buf
3437 else:
3438 reader = loxi.generic_util.OFReader(buf)
3439 _version = reader.read("!B")[0]
3440 assert(_version == 1)
3441 _type = reader.read("!B")[0]
3442 assert(_type == 4)
3443 _length = reader.read("!H")[0]
3444 obj.xid = reader.read("!L")[0]
3445 _experimenter = reader.read("!L")[0]
3446 assert(_experimenter == 6035143)
3447 _subtype = reader.read("!L")[0]
3448 assert(_subtype == 17)
3449 obj.vport_no = reader.read("!L")[0]
3450 return obj
3451
3452 def __eq__(self, other):
3453 if type(self) != type(other): return False
3454 if self.version != other.version: return False
3455 if self.type != other.type: return False
3456 if self.xid != other.xid: return False
3457 if self.vport_no != other.vport_no: return False
3458 return True
3459
3460 def __ne__(self, other):
3461 return not self.__eq__(other)
3462
3463 def __str__(self):
3464 return self.show()
3465
3466 def show(self):
3467 import loxi.pp
3468 return loxi.pp.pp(self)
3469
3470 def pretty_print(self, q):
3471 q.text("bsn_virtual_port_remove_request {")
3472 with q.group():
3473 with q.indent(2):
3474 q.breakable()
3475 q.text("xid = ");
3476 if self.xid != None:
3477 q.text("%#x" % self.xid)
3478 else:
3479 q.text('None')
3480 q.text(","); q.breakable()
3481 q.text("vport_no = ");
3482 q.text("%#x" % self.vport_no)
3483 q.breakable()
3484 q.text('}')
3485
Rich Laneb658ddd2013-03-12 10:15:10 -07003486class desc_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003487 version = 1
3488 type = 17
3489 stats_type = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07003490
3491 def __init__(self, xid=None, flags=None, mfr_desc=None, hw_desc=None, sw_desc=None, serial_num=None, dp_desc=None):
3492 self.xid = xid
3493 if flags != None:
3494 self.flags = flags
3495 else:
3496 self.flags = 0
3497 if mfr_desc != None:
3498 self.mfr_desc = mfr_desc
3499 else:
3500 self.mfr_desc = ""
3501 if hw_desc != None:
3502 self.hw_desc = hw_desc
3503 else:
3504 self.hw_desc = ""
3505 if sw_desc != None:
3506 self.sw_desc = sw_desc
3507 else:
3508 self.sw_desc = ""
3509 if serial_num != None:
3510 self.serial_num = serial_num
3511 else:
3512 self.serial_num = ""
3513 if dp_desc != None:
3514 self.dp_desc = dp_desc
3515 else:
3516 self.dp_desc = ""
3517
3518 def pack(self):
3519 packed = []
3520 packed.append(struct.pack("!B", self.version))
3521 packed.append(struct.pack("!B", self.type))
3522 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3523 packed.append(struct.pack("!L", self.xid))
3524 packed.append(struct.pack("!H", self.stats_type))
3525 packed.append(struct.pack("!H", self.flags))
3526 packed.append(struct.pack("!256s", self.mfr_desc))
3527 packed.append(struct.pack("!256s", self.hw_desc))
3528 packed.append(struct.pack("!256s", self.sw_desc))
3529 packed.append(struct.pack("!32s", self.serial_num))
3530 packed.append(struct.pack("!256s", self.dp_desc))
3531 length = sum([len(x) for x in packed])
3532 packed[2] = struct.pack("!H", length)
3533 return ''.join(packed)
3534
3535 @staticmethod
3536 def unpack(buf):
3537 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3538 obj = desc_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003539 if type(buf) == loxi.generic_util.OFReader:
3540 reader = buf
3541 else:
3542 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003543 _version = reader.read("!B")[0]
3544 assert(_version == 1)
3545 _type = reader.read("!B")[0]
3546 assert(_type == 17)
3547 _length = reader.read("!H")[0]
3548 obj.xid = reader.read("!L")[0]
3549 _stats_type = reader.read("!H")[0]
3550 assert(_stats_type == 0)
3551 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003552 obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00")
3553 obj.hw_desc = reader.read("!256s")[0].rstrip("\x00")
3554 obj.sw_desc = reader.read("!256s")[0].rstrip("\x00")
3555 obj.serial_num = reader.read("!32s")[0].rstrip("\x00")
3556 obj.dp_desc = reader.read("!256s")[0].rstrip("\x00")
Rich Laneb658ddd2013-03-12 10:15:10 -07003557 return obj
3558
3559 def __eq__(self, other):
3560 if type(self) != type(other): return False
3561 if self.version != other.version: return False
3562 if self.type != other.type: return False
3563 if self.xid != other.xid: return False
3564 if self.flags != other.flags: return False
3565 if self.mfr_desc != other.mfr_desc: return False
3566 if self.hw_desc != other.hw_desc: return False
3567 if self.sw_desc != other.sw_desc: return False
3568 if self.serial_num != other.serial_num: return False
3569 if self.dp_desc != other.dp_desc: return False
3570 return True
3571
3572 def __ne__(self, other):
3573 return not self.__eq__(other)
3574
3575 def __str__(self):
3576 return self.show()
3577
3578 def show(self):
3579 import loxi.pp
3580 return loxi.pp.pp(self)
3581
3582 def pretty_print(self, q):
3583 q.text("desc_stats_reply {")
3584 with q.group():
3585 with q.indent(2):
3586 q.breakable()
3587 q.text("xid = ");
3588 if self.xid != None:
3589 q.text("%#x" % self.xid)
3590 else:
3591 q.text('None')
3592 q.text(","); q.breakable()
3593 q.text("flags = ");
3594 q.text("%#x" % self.flags)
3595 q.text(","); q.breakable()
3596 q.text("mfr_desc = ");
3597 q.pp(self.mfr_desc)
3598 q.text(","); q.breakable()
3599 q.text("hw_desc = ");
3600 q.pp(self.hw_desc)
3601 q.text(","); q.breakable()
3602 q.text("sw_desc = ");
3603 q.pp(self.sw_desc)
3604 q.text(","); q.breakable()
3605 q.text("serial_num = ");
3606 q.pp(self.serial_num)
3607 q.text(","); q.breakable()
3608 q.text("dp_desc = ");
3609 q.pp(self.dp_desc)
3610 q.breakable()
3611 q.text('}')
3612
3613class desc_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003614 version = 1
3615 type = 16
3616 stats_type = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07003617
3618 def __init__(self, xid=None, flags=None):
3619 self.xid = xid
3620 if flags != None:
3621 self.flags = flags
3622 else:
3623 self.flags = 0
3624
3625 def pack(self):
3626 packed = []
3627 packed.append(struct.pack("!B", self.version))
3628 packed.append(struct.pack("!B", self.type))
3629 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3630 packed.append(struct.pack("!L", self.xid))
3631 packed.append(struct.pack("!H", self.stats_type))
3632 packed.append(struct.pack("!H", self.flags))
3633 length = sum([len(x) for x in packed])
3634 packed[2] = struct.pack("!H", length)
3635 return ''.join(packed)
3636
3637 @staticmethod
3638 def unpack(buf):
3639 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3640 obj = desc_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003641 if type(buf) == loxi.generic_util.OFReader:
3642 reader = buf
3643 else:
3644 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003645 _version = reader.read("!B")[0]
3646 assert(_version == 1)
3647 _type = reader.read("!B")[0]
3648 assert(_type == 16)
3649 _length = reader.read("!H")[0]
3650 obj.xid = reader.read("!L")[0]
3651 _stats_type = reader.read("!H")[0]
3652 assert(_stats_type == 0)
3653 obj.flags = reader.read("!H")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07003654 return obj
3655
3656 def __eq__(self, other):
3657 if type(self) != type(other): return False
3658 if self.version != other.version: return False
3659 if self.type != other.type: return False
3660 if self.xid != other.xid: return False
3661 if self.flags != other.flags: return False
3662 return True
3663
3664 def __ne__(self, other):
3665 return not self.__eq__(other)
3666
3667 def __str__(self):
3668 return self.show()
3669
3670 def show(self):
3671 import loxi.pp
3672 return loxi.pp.pp(self)
3673
3674 def pretty_print(self, q):
3675 q.text("desc_stats_request {")
3676 with q.group():
3677 with q.indent(2):
3678 q.breakable()
3679 q.text("xid = ");
3680 if self.xid != None:
3681 q.text("%#x" % self.xid)
3682 else:
3683 q.text('None')
3684 q.text(","); q.breakable()
3685 q.text("flags = ");
3686 q.text("%#x" % self.flags)
3687 q.breakable()
3688 q.text('}')
3689
3690class echo_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003691 version = 1
3692 type = 3
Rich Laneb658ddd2013-03-12 10:15:10 -07003693
3694 def __init__(self, xid=None, data=None):
3695 self.xid = xid
3696 if data != None:
3697 self.data = data
3698 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003699 self.data = ''
Rich Laneb658ddd2013-03-12 10:15:10 -07003700
3701 def pack(self):
3702 packed = []
3703 packed.append(struct.pack("!B", self.version))
3704 packed.append(struct.pack("!B", self.type))
3705 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3706 packed.append(struct.pack("!L", self.xid))
3707 packed.append(self.data)
3708 length = sum([len(x) for x in packed])
3709 packed[2] = struct.pack("!H", length)
3710 return ''.join(packed)
3711
3712 @staticmethod
3713 def unpack(buf):
3714 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3715 obj = echo_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003716 if type(buf) == loxi.generic_util.OFReader:
3717 reader = buf
3718 else:
3719 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003720 _version = reader.read("!B")[0]
3721 assert(_version == 1)
3722 _type = reader.read("!B")[0]
3723 assert(_type == 3)
3724 _length = reader.read("!H")[0]
3725 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003726 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07003727 return obj
3728
3729 def __eq__(self, other):
3730 if type(self) != type(other): return False
3731 if self.version != other.version: return False
3732 if self.type != other.type: return False
3733 if self.xid != other.xid: return False
3734 if self.data != other.data: return False
3735 return True
3736
3737 def __ne__(self, other):
3738 return not self.__eq__(other)
3739
3740 def __str__(self):
3741 return self.show()
3742
3743 def show(self):
3744 import loxi.pp
3745 return loxi.pp.pp(self)
3746
3747 def pretty_print(self, q):
3748 q.text("echo_reply {")
3749 with q.group():
3750 with q.indent(2):
3751 q.breakable()
3752 q.text("xid = ");
3753 if self.xid != None:
3754 q.text("%#x" % self.xid)
3755 else:
3756 q.text('None')
3757 q.text(","); q.breakable()
3758 q.text("data = ");
3759 q.pp(self.data)
3760 q.breakable()
3761 q.text('}')
3762
3763class echo_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003764 version = 1
3765 type = 2
Rich Laneb658ddd2013-03-12 10:15:10 -07003766
3767 def __init__(self, xid=None, data=None):
3768 self.xid = xid
3769 if data != None:
3770 self.data = data
3771 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003772 self.data = ''
Rich Laneb658ddd2013-03-12 10:15:10 -07003773
3774 def pack(self):
3775 packed = []
3776 packed.append(struct.pack("!B", self.version))
3777 packed.append(struct.pack("!B", self.type))
3778 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3779 packed.append(struct.pack("!L", self.xid))
3780 packed.append(self.data)
3781 length = sum([len(x) for x in packed])
3782 packed[2] = struct.pack("!H", length)
3783 return ''.join(packed)
3784
3785 @staticmethod
3786 def unpack(buf):
3787 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3788 obj = echo_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003789 if type(buf) == loxi.generic_util.OFReader:
3790 reader = buf
3791 else:
3792 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003793 _version = reader.read("!B")[0]
3794 assert(_version == 1)
3795 _type = reader.read("!B")[0]
3796 assert(_type == 2)
3797 _length = reader.read("!H")[0]
3798 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003799 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07003800 return obj
3801
3802 def __eq__(self, other):
3803 if type(self) != type(other): return False
3804 if self.version != other.version: return False
3805 if self.type != other.type: return False
3806 if self.xid != other.xid: return False
3807 if self.data != other.data: return False
3808 return True
3809
3810 def __ne__(self, other):
3811 return not self.__eq__(other)
3812
3813 def __str__(self):
3814 return self.show()
3815
3816 def show(self):
3817 import loxi.pp
3818 return loxi.pp.pp(self)
3819
3820 def pretty_print(self, q):
3821 q.text("echo_request {")
3822 with q.group():
3823 with q.indent(2):
3824 q.breakable()
3825 q.text("xid = ");
3826 if self.xid != None:
3827 q.text("%#x" % self.xid)
3828 else:
3829 q.text('None')
3830 q.text(","); q.breakable()
3831 q.text("data = ");
3832 q.pp(self.data)
3833 q.breakable()
3834 q.text('}')
3835
Rich Laneb658ddd2013-03-12 10:15:10 -07003836class features_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003837 version = 1
3838 type = 6
Rich Laneb658ddd2013-03-12 10:15:10 -07003839
Rich Lanec2ee4b82013-04-24 17:12:38 -07003840 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 -07003841 self.xid = xid
3842 if datapath_id != None:
3843 self.datapath_id = datapath_id
3844 else:
3845 self.datapath_id = 0
3846 if n_buffers != None:
3847 self.n_buffers = n_buffers
3848 else:
3849 self.n_buffers = 0
3850 if n_tables != None:
3851 self.n_tables = n_tables
3852 else:
3853 self.n_tables = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07003854 if capabilities != None:
3855 self.capabilities = capabilities
3856 else:
3857 self.capabilities = 0
3858 if actions != None:
3859 self.actions = actions
3860 else:
3861 self.actions = 0
3862 if ports != None:
3863 self.ports = ports
3864 else:
3865 self.ports = []
3866
3867 def pack(self):
3868 packed = []
3869 packed.append(struct.pack("!B", self.version))
3870 packed.append(struct.pack("!B", self.type))
3871 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3872 packed.append(struct.pack("!L", self.xid))
3873 packed.append(struct.pack("!Q", self.datapath_id))
3874 packed.append(struct.pack("!L", self.n_buffers))
3875 packed.append(struct.pack("!B", self.n_tables))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003876 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07003877 packed.append(struct.pack("!L", self.capabilities))
3878 packed.append(struct.pack("!L", self.actions))
Dan Talaycof6202252013-07-02 01:00:29 -07003879 packed.append(util.pack_list(self.ports))
Rich Laneb658ddd2013-03-12 10:15:10 -07003880 length = sum([len(x) for x in packed])
3881 packed[2] = struct.pack("!H", length)
3882 return ''.join(packed)
3883
3884 @staticmethod
3885 def unpack(buf):
3886 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3887 obj = features_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003888 if type(buf) == loxi.generic_util.OFReader:
3889 reader = buf
3890 else:
3891 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003892 _version = reader.read("!B")[0]
3893 assert(_version == 1)
3894 _type = reader.read("!B")[0]
3895 assert(_type == 6)
3896 _length = reader.read("!H")[0]
3897 obj.xid = reader.read("!L")[0]
3898 obj.datapath_id = reader.read("!Q")[0]
3899 obj.n_buffers = reader.read("!L")[0]
3900 obj.n_tables = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003901 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07003902 obj.capabilities = reader.read("!L")[0]
3903 obj.actions = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003904 obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack)
Rich Laneb658ddd2013-03-12 10:15:10 -07003905 return obj
3906
3907 def __eq__(self, other):
3908 if type(self) != type(other): return False
3909 if self.version != other.version: return False
3910 if self.type != other.type: return False
3911 if self.xid != other.xid: return False
3912 if self.datapath_id != other.datapath_id: return False
3913 if self.n_buffers != other.n_buffers: return False
3914 if self.n_tables != other.n_tables: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07003915 if self.capabilities != other.capabilities: return False
3916 if self.actions != other.actions: return False
3917 if self.ports != other.ports: return False
3918 return True
3919
3920 def __ne__(self, other):
3921 return not self.__eq__(other)
3922
3923 def __str__(self):
3924 return self.show()
3925
3926 def show(self):
3927 import loxi.pp
3928 return loxi.pp.pp(self)
3929
3930 def pretty_print(self, q):
3931 q.text("features_reply {")
3932 with q.group():
3933 with q.indent(2):
3934 q.breakable()
3935 q.text("xid = ");
3936 if self.xid != None:
3937 q.text("%#x" % self.xid)
3938 else:
3939 q.text('None')
3940 q.text(","); q.breakable()
3941 q.text("datapath_id = ");
3942 q.text("%#x" % self.datapath_id)
3943 q.text(","); q.breakable()
3944 q.text("n_buffers = ");
3945 q.text("%#x" % self.n_buffers)
3946 q.text(","); q.breakable()
3947 q.text("n_tables = ");
3948 q.text("%#x" % self.n_tables)
3949 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07003950 q.text("capabilities = ");
3951 q.text("%#x" % self.capabilities)
3952 q.text(","); q.breakable()
3953 q.text("actions = ");
3954 q.text("%#x" % self.actions)
3955 q.text(","); q.breakable()
3956 q.text("ports = ");
3957 q.pp(self.ports)
3958 q.breakable()
3959 q.text('}')
3960
3961class features_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07003962 version = 1
3963 type = 5
Rich Laneb658ddd2013-03-12 10:15:10 -07003964
3965 def __init__(self, xid=None):
3966 self.xid = xid
3967
3968 def pack(self):
3969 packed = []
3970 packed.append(struct.pack("!B", self.version))
3971 packed.append(struct.pack("!B", self.type))
3972 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3973 packed.append(struct.pack("!L", self.xid))
3974 length = sum([len(x) for x in packed])
3975 packed[2] = struct.pack("!H", length)
3976 return ''.join(packed)
3977
3978 @staticmethod
3979 def unpack(buf):
3980 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3981 obj = features_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003982 if type(buf) == loxi.generic_util.OFReader:
3983 reader = buf
3984 else:
3985 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07003986 _version = reader.read("!B")[0]
3987 assert(_version == 1)
3988 _type = reader.read("!B")[0]
3989 assert(_type == 5)
3990 _length = reader.read("!H")[0]
3991 obj.xid = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07003992 return obj
3993
3994 def __eq__(self, other):
3995 if type(self) != type(other): return False
3996 if self.version != other.version: return False
3997 if self.type != other.type: return False
3998 if self.xid != other.xid: return False
3999 return True
4000
4001 def __ne__(self, other):
4002 return not self.__eq__(other)
4003
4004 def __str__(self):
4005 return self.show()
4006
4007 def show(self):
4008 import loxi.pp
4009 return loxi.pp.pp(self)
4010
4011 def pretty_print(self, q):
4012 q.text("features_request {")
4013 with q.group():
4014 with q.indent(2):
4015 q.breakable()
4016 q.text("xid = ");
4017 if self.xid != None:
4018 q.text("%#x" % self.xid)
4019 else:
4020 q.text('None')
4021 q.breakable()
4022 q.text('}')
4023
4024class flow_add(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004025 version = 1
4026 type = 14
4027 _command = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07004028
4029 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):
4030 self.xid = xid
4031 if match != None:
4032 self.match = match
4033 else:
4034 self.match = common.match()
4035 if cookie != None:
4036 self.cookie = cookie
4037 else:
4038 self.cookie = 0
4039 if idle_timeout != None:
4040 self.idle_timeout = idle_timeout
4041 else:
4042 self.idle_timeout = 0
4043 if hard_timeout != None:
4044 self.hard_timeout = hard_timeout
4045 else:
4046 self.hard_timeout = 0
4047 if priority != None:
4048 self.priority = priority
4049 else:
4050 self.priority = 0
4051 if buffer_id != None:
4052 self.buffer_id = buffer_id
4053 else:
4054 self.buffer_id = 0
4055 if out_port != None:
4056 self.out_port = out_port
4057 else:
4058 self.out_port = 0
4059 if flags != None:
4060 self.flags = flags
4061 else:
4062 self.flags = 0
4063 if actions != None:
4064 self.actions = actions
4065 else:
4066 self.actions = []
4067
4068 def pack(self):
4069 packed = []
4070 packed.append(struct.pack("!B", self.version))
4071 packed.append(struct.pack("!B", self.type))
4072 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4073 packed.append(struct.pack("!L", self.xid))
4074 packed.append(self.match.pack())
4075 packed.append(struct.pack("!Q", self.cookie))
Dan Talaycof6202252013-07-02 01:00:29 -07004076 packed.append(util.pack_fm_cmd(self._command))
Rich Laneb658ddd2013-03-12 10:15:10 -07004077 packed.append(struct.pack("!H", self.idle_timeout))
4078 packed.append(struct.pack("!H", self.hard_timeout))
4079 packed.append(struct.pack("!H", self.priority))
4080 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004081 packed.append(util.pack_port_no(self.out_port))
Rich Laneb658ddd2013-03-12 10:15:10 -07004082 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07004083 packed.append(util.pack_list(self.actions))
Rich Laneb658ddd2013-03-12 10:15:10 -07004084 length = sum([len(x) for x in packed])
4085 packed[2] = struct.pack("!H", length)
4086 return ''.join(packed)
4087
4088 @staticmethod
4089 def unpack(buf):
4090 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4091 obj = flow_add()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004092 if type(buf) == loxi.generic_util.OFReader:
4093 reader = buf
4094 else:
4095 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004096 _version = reader.read("!B")[0]
4097 assert(_version == 1)
4098 _type = reader.read("!B")[0]
4099 assert(_type == 14)
4100 _length = reader.read("!H")[0]
4101 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004102 obj.match = common.match.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07004103 obj.cookie = reader.read("!Q")[0]
4104 __command = util.unpack_fm_cmd(reader)
4105 assert(__command == 0)
4106 obj.idle_timeout = reader.read("!H")[0]
4107 obj.hard_timeout = reader.read("!H")[0]
4108 obj.priority = reader.read("!H")[0]
4109 obj.buffer_id = reader.read("!L")[0]
4110 obj.out_port = util.unpack_port_no(reader)
4111 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004112 obj.actions = action.unpack_list(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07004113 return obj
4114
4115 def __eq__(self, other):
4116 if type(self) != type(other): return False
4117 if self.version != other.version: return False
4118 if self.type != other.type: return False
4119 if self.xid != other.xid: return False
4120 if self.match != other.match: return False
4121 if self.cookie != other.cookie: return False
4122 if self.idle_timeout != other.idle_timeout: return False
4123 if self.hard_timeout != other.hard_timeout: return False
4124 if self.priority != other.priority: return False
4125 if self.buffer_id != other.buffer_id: return False
4126 if self.out_port != other.out_port: return False
4127 if self.flags != other.flags: return False
4128 if self.actions != other.actions: return False
4129 return True
4130
4131 def __ne__(self, other):
4132 return not self.__eq__(other)
4133
4134 def __str__(self):
4135 return self.show()
4136
4137 def show(self):
4138 import loxi.pp
4139 return loxi.pp.pp(self)
4140
4141 def pretty_print(self, q):
4142 q.text("flow_add {")
4143 with q.group():
4144 with q.indent(2):
4145 q.breakable()
4146 q.text("xid = ");
4147 if self.xid != None:
4148 q.text("%#x" % self.xid)
4149 else:
4150 q.text('None')
4151 q.text(","); q.breakable()
4152 q.text("match = ");
4153 q.pp(self.match)
4154 q.text(","); q.breakable()
4155 q.text("cookie = ");
4156 q.text("%#x" % self.cookie)
4157 q.text(","); q.breakable()
4158 q.text("idle_timeout = ");
4159 q.text("%#x" % self.idle_timeout)
4160 q.text(","); q.breakable()
4161 q.text("hard_timeout = ");
4162 q.text("%#x" % self.hard_timeout)
4163 q.text(","); q.breakable()
4164 q.text("priority = ");
4165 q.text("%#x" % self.priority)
4166 q.text(","); q.breakable()
4167 q.text("buffer_id = ");
4168 q.text("%#x" % self.buffer_id)
4169 q.text(","); q.breakable()
4170 q.text("out_port = ");
4171 q.text(util.pretty_port(self.out_port))
4172 q.text(","); q.breakable()
4173 q.text("flags = ");
4174 q.text("%#x" % self.flags)
4175 q.text(","); q.breakable()
4176 q.text("actions = ");
4177 q.pp(self.actions)
4178 q.breakable()
4179 q.text('}')
4180
4181class flow_delete(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004182 version = 1
4183 type = 14
4184 _command = 3
Rich Laneb658ddd2013-03-12 10:15:10 -07004185
4186 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):
4187 self.xid = xid
4188 if match != None:
4189 self.match = match
4190 else:
4191 self.match = common.match()
4192 if cookie != None:
4193 self.cookie = cookie
4194 else:
4195 self.cookie = 0
4196 if idle_timeout != None:
4197 self.idle_timeout = idle_timeout
4198 else:
4199 self.idle_timeout = 0
4200 if hard_timeout != None:
4201 self.hard_timeout = hard_timeout
4202 else:
4203 self.hard_timeout = 0
4204 if priority != None:
4205 self.priority = priority
4206 else:
4207 self.priority = 0
4208 if buffer_id != None:
4209 self.buffer_id = buffer_id
4210 else:
4211 self.buffer_id = 0
4212 if out_port != None:
4213 self.out_port = out_port
4214 else:
4215 self.out_port = 0
4216 if flags != None:
4217 self.flags = flags
4218 else:
4219 self.flags = 0
4220 if actions != None:
4221 self.actions = actions
4222 else:
4223 self.actions = []
4224
4225 def pack(self):
4226 packed = []
4227 packed.append(struct.pack("!B", self.version))
4228 packed.append(struct.pack("!B", self.type))
4229 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4230 packed.append(struct.pack("!L", self.xid))
4231 packed.append(self.match.pack())
4232 packed.append(struct.pack("!Q", self.cookie))
Dan Talaycof6202252013-07-02 01:00:29 -07004233 packed.append(util.pack_fm_cmd(self._command))
Rich Laneb658ddd2013-03-12 10:15:10 -07004234 packed.append(struct.pack("!H", self.idle_timeout))
4235 packed.append(struct.pack("!H", self.hard_timeout))
4236 packed.append(struct.pack("!H", self.priority))
4237 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004238 packed.append(util.pack_port_no(self.out_port))
Rich Laneb658ddd2013-03-12 10:15:10 -07004239 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07004240 packed.append(util.pack_list(self.actions))
Rich Laneb658ddd2013-03-12 10:15:10 -07004241 length = sum([len(x) for x in packed])
4242 packed[2] = struct.pack("!H", length)
4243 return ''.join(packed)
4244
4245 @staticmethod
4246 def unpack(buf):
4247 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4248 obj = flow_delete()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004249 if type(buf) == loxi.generic_util.OFReader:
4250 reader = buf
4251 else:
4252 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004253 _version = reader.read("!B")[0]
4254 assert(_version == 1)
4255 _type = reader.read("!B")[0]
4256 assert(_type == 14)
4257 _length = reader.read("!H")[0]
4258 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004259 obj.match = common.match.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07004260 obj.cookie = reader.read("!Q")[0]
4261 __command = util.unpack_fm_cmd(reader)
4262 assert(__command == 3)
4263 obj.idle_timeout = reader.read("!H")[0]
4264 obj.hard_timeout = reader.read("!H")[0]
4265 obj.priority = reader.read("!H")[0]
4266 obj.buffer_id = reader.read("!L")[0]
4267 obj.out_port = util.unpack_port_no(reader)
4268 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004269 obj.actions = action.unpack_list(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07004270 return obj
4271
4272 def __eq__(self, other):
4273 if type(self) != type(other): return False
4274 if self.version != other.version: return False
4275 if self.type != other.type: return False
4276 if self.xid != other.xid: return False
4277 if self.match != other.match: return False
4278 if self.cookie != other.cookie: return False
4279 if self.idle_timeout != other.idle_timeout: return False
4280 if self.hard_timeout != other.hard_timeout: return False
4281 if self.priority != other.priority: return False
4282 if self.buffer_id != other.buffer_id: return False
4283 if self.out_port != other.out_port: return False
4284 if self.flags != other.flags: return False
4285 if self.actions != other.actions: return False
4286 return True
4287
4288 def __ne__(self, other):
4289 return not self.__eq__(other)
4290
4291 def __str__(self):
4292 return self.show()
4293
4294 def show(self):
4295 import loxi.pp
4296 return loxi.pp.pp(self)
4297
4298 def pretty_print(self, q):
4299 q.text("flow_delete {")
4300 with q.group():
4301 with q.indent(2):
4302 q.breakable()
4303 q.text("xid = ");
4304 if self.xid != None:
4305 q.text("%#x" % self.xid)
4306 else:
4307 q.text('None')
4308 q.text(","); q.breakable()
4309 q.text("match = ");
4310 q.pp(self.match)
4311 q.text(","); q.breakable()
4312 q.text("cookie = ");
4313 q.text("%#x" % self.cookie)
4314 q.text(","); q.breakable()
4315 q.text("idle_timeout = ");
4316 q.text("%#x" % self.idle_timeout)
4317 q.text(","); q.breakable()
4318 q.text("hard_timeout = ");
4319 q.text("%#x" % self.hard_timeout)
4320 q.text(","); q.breakable()
4321 q.text("priority = ");
4322 q.text("%#x" % self.priority)
4323 q.text(","); q.breakable()
4324 q.text("buffer_id = ");
4325 q.text("%#x" % self.buffer_id)
4326 q.text(","); q.breakable()
4327 q.text("out_port = ");
4328 q.text(util.pretty_port(self.out_port))
4329 q.text(","); q.breakable()
4330 q.text("flags = ");
4331 q.text("%#x" % self.flags)
4332 q.text(","); q.breakable()
4333 q.text("actions = ");
4334 q.pp(self.actions)
4335 q.breakable()
4336 q.text('}')
4337
4338class flow_delete_strict(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004339 version = 1
4340 type = 14
4341 _command = 4
Rich Laneb658ddd2013-03-12 10:15:10 -07004342
4343 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):
4344 self.xid = xid
4345 if match != None:
4346 self.match = match
4347 else:
4348 self.match = common.match()
4349 if cookie != None:
4350 self.cookie = cookie
4351 else:
4352 self.cookie = 0
4353 if idle_timeout != None:
4354 self.idle_timeout = idle_timeout
4355 else:
4356 self.idle_timeout = 0
4357 if hard_timeout != None:
4358 self.hard_timeout = hard_timeout
4359 else:
4360 self.hard_timeout = 0
4361 if priority != None:
4362 self.priority = priority
4363 else:
4364 self.priority = 0
4365 if buffer_id != None:
4366 self.buffer_id = buffer_id
4367 else:
4368 self.buffer_id = 0
4369 if out_port != None:
4370 self.out_port = out_port
4371 else:
4372 self.out_port = 0
4373 if flags != None:
4374 self.flags = flags
4375 else:
4376 self.flags = 0
4377 if actions != None:
4378 self.actions = actions
4379 else:
4380 self.actions = []
4381
4382 def pack(self):
4383 packed = []
4384 packed.append(struct.pack("!B", self.version))
4385 packed.append(struct.pack("!B", self.type))
4386 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4387 packed.append(struct.pack("!L", self.xid))
4388 packed.append(self.match.pack())
4389 packed.append(struct.pack("!Q", self.cookie))
Dan Talaycof6202252013-07-02 01:00:29 -07004390 packed.append(util.pack_fm_cmd(self._command))
Rich Laneb658ddd2013-03-12 10:15:10 -07004391 packed.append(struct.pack("!H", self.idle_timeout))
4392 packed.append(struct.pack("!H", self.hard_timeout))
4393 packed.append(struct.pack("!H", self.priority))
4394 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004395 packed.append(util.pack_port_no(self.out_port))
Rich Laneb658ddd2013-03-12 10:15:10 -07004396 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07004397 packed.append(util.pack_list(self.actions))
Rich Laneb658ddd2013-03-12 10:15:10 -07004398 length = sum([len(x) for x in packed])
4399 packed[2] = struct.pack("!H", length)
4400 return ''.join(packed)
4401
4402 @staticmethod
4403 def unpack(buf):
4404 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4405 obj = flow_delete_strict()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004406 if type(buf) == loxi.generic_util.OFReader:
4407 reader = buf
4408 else:
4409 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004410 _version = reader.read("!B")[0]
4411 assert(_version == 1)
4412 _type = reader.read("!B")[0]
4413 assert(_type == 14)
4414 _length = reader.read("!H")[0]
4415 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004416 obj.match = common.match.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07004417 obj.cookie = reader.read("!Q")[0]
4418 __command = util.unpack_fm_cmd(reader)
4419 assert(__command == 4)
4420 obj.idle_timeout = reader.read("!H")[0]
4421 obj.hard_timeout = reader.read("!H")[0]
4422 obj.priority = reader.read("!H")[0]
4423 obj.buffer_id = reader.read("!L")[0]
4424 obj.out_port = util.unpack_port_no(reader)
4425 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004426 obj.actions = action.unpack_list(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07004427 return obj
4428
4429 def __eq__(self, other):
4430 if type(self) != type(other): return False
4431 if self.version != other.version: return False
4432 if self.type != other.type: return False
4433 if self.xid != other.xid: return False
4434 if self.match != other.match: return False
4435 if self.cookie != other.cookie: return False
4436 if self.idle_timeout != other.idle_timeout: return False
4437 if self.hard_timeout != other.hard_timeout: return False
4438 if self.priority != other.priority: return False
4439 if self.buffer_id != other.buffer_id: return False
4440 if self.out_port != other.out_port: return False
4441 if self.flags != other.flags: return False
4442 if self.actions != other.actions: return False
4443 return True
4444
4445 def __ne__(self, other):
4446 return not self.__eq__(other)
4447
4448 def __str__(self):
4449 return self.show()
4450
4451 def show(self):
4452 import loxi.pp
4453 return loxi.pp.pp(self)
4454
4455 def pretty_print(self, q):
4456 q.text("flow_delete_strict {")
4457 with q.group():
4458 with q.indent(2):
4459 q.breakable()
4460 q.text("xid = ");
4461 if self.xid != None:
4462 q.text("%#x" % self.xid)
4463 else:
4464 q.text('None')
4465 q.text(","); q.breakable()
4466 q.text("match = ");
4467 q.pp(self.match)
4468 q.text(","); q.breakable()
4469 q.text("cookie = ");
4470 q.text("%#x" % self.cookie)
4471 q.text(","); q.breakable()
4472 q.text("idle_timeout = ");
4473 q.text("%#x" % self.idle_timeout)
4474 q.text(","); q.breakable()
4475 q.text("hard_timeout = ");
4476 q.text("%#x" % self.hard_timeout)
4477 q.text(","); q.breakable()
4478 q.text("priority = ");
4479 q.text("%#x" % self.priority)
4480 q.text(","); q.breakable()
4481 q.text("buffer_id = ");
4482 q.text("%#x" % self.buffer_id)
4483 q.text(","); q.breakable()
4484 q.text("out_port = ");
4485 q.text(util.pretty_port(self.out_port))
4486 q.text(","); q.breakable()
4487 q.text("flags = ");
4488 q.text("%#x" % self.flags)
4489 q.text(","); q.breakable()
4490 q.text("actions = ");
4491 q.pp(self.actions)
4492 q.breakable()
4493 q.text('}')
4494
Rich Lane6f4978c2013-10-20 21:33:52 -07004495class flow_mod_failed_error_msg(Message):
4496 version = 1
4497 type = 1
4498 err_type = 3
4499
4500 def __init__(self, xid=None, code=None, data=None):
4501 self.xid = xid
4502 if code != None:
4503 self.code = code
4504 else:
4505 self.code = 0
4506 if data != None:
4507 self.data = data
4508 else:
4509 self.data = ''
4510
4511 def pack(self):
4512 packed = []
4513 packed.append(struct.pack("!B", self.version))
4514 packed.append(struct.pack("!B", self.type))
4515 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4516 packed.append(struct.pack("!L", self.xid))
4517 packed.append(struct.pack("!H", self.err_type))
4518 packed.append(struct.pack("!H", self.code))
4519 packed.append(self.data)
4520 length = sum([len(x) for x in packed])
4521 packed[2] = struct.pack("!H", length)
4522 return ''.join(packed)
4523
4524 @staticmethod
4525 def unpack(buf):
4526 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4527 obj = flow_mod_failed_error_msg()
4528 if type(buf) == loxi.generic_util.OFReader:
4529 reader = buf
4530 else:
4531 reader = loxi.generic_util.OFReader(buf)
4532 _version = reader.read("!B")[0]
4533 assert(_version == 1)
4534 _type = reader.read("!B")[0]
4535 assert(_type == 1)
4536 _length = reader.read("!H")[0]
4537 obj.xid = reader.read("!L")[0]
4538 _err_type = reader.read("!H")[0]
4539 assert(_err_type == 3)
4540 obj.code = reader.read("!H")[0]
4541 obj.data = str(reader.read_all())
4542 return obj
4543
4544 def __eq__(self, other):
4545 if type(self) != type(other): return False
4546 if self.version != other.version: return False
4547 if self.type != other.type: return False
4548 if self.xid != other.xid: return False
4549 if self.code != other.code: return False
4550 if self.data != other.data: return False
4551 return True
4552
4553 def __ne__(self, other):
4554 return not self.__eq__(other)
4555
4556 def __str__(self):
4557 return self.show()
4558
4559 def show(self):
4560 import loxi.pp
4561 return loxi.pp.pp(self)
4562
4563 def pretty_print(self, q):
4564 q.text("flow_mod_failed_error_msg {")
4565 with q.group():
4566 with q.indent(2):
4567 q.breakable()
4568 q.text("xid = ");
4569 if self.xid != None:
4570 q.text("%#x" % self.xid)
4571 else:
4572 q.text('None')
4573 q.text(","); q.breakable()
4574 q.text("code = ");
4575 q.text("%#x" % self.code)
4576 q.text(","); q.breakable()
4577 q.text("data = ");
4578 q.pp(self.data)
4579 q.breakable()
4580 q.text('}')
4581
Rich Laneb658ddd2013-03-12 10:15:10 -07004582class flow_modify(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004583 version = 1
4584 type = 14
4585 _command = 1
Rich Laneb658ddd2013-03-12 10:15:10 -07004586
4587 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):
4588 self.xid = xid
4589 if match != None:
4590 self.match = match
4591 else:
4592 self.match = common.match()
4593 if cookie != None:
4594 self.cookie = cookie
4595 else:
4596 self.cookie = 0
4597 if idle_timeout != None:
4598 self.idle_timeout = idle_timeout
4599 else:
4600 self.idle_timeout = 0
4601 if hard_timeout != None:
4602 self.hard_timeout = hard_timeout
4603 else:
4604 self.hard_timeout = 0
4605 if priority != None:
4606 self.priority = priority
4607 else:
4608 self.priority = 0
4609 if buffer_id != None:
4610 self.buffer_id = buffer_id
4611 else:
4612 self.buffer_id = 0
4613 if out_port != None:
4614 self.out_port = out_port
4615 else:
4616 self.out_port = 0
4617 if flags != None:
4618 self.flags = flags
4619 else:
4620 self.flags = 0
4621 if actions != None:
4622 self.actions = actions
4623 else:
4624 self.actions = []
4625
4626 def pack(self):
4627 packed = []
4628 packed.append(struct.pack("!B", self.version))
4629 packed.append(struct.pack("!B", self.type))
4630 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4631 packed.append(struct.pack("!L", self.xid))
4632 packed.append(self.match.pack())
4633 packed.append(struct.pack("!Q", self.cookie))
Dan Talaycof6202252013-07-02 01:00:29 -07004634 packed.append(util.pack_fm_cmd(self._command))
Rich Laneb658ddd2013-03-12 10:15:10 -07004635 packed.append(struct.pack("!H", self.idle_timeout))
4636 packed.append(struct.pack("!H", self.hard_timeout))
4637 packed.append(struct.pack("!H", self.priority))
4638 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004639 packed.append(util.pack_port_no(self.out_port))
Rich Laneb658ddd2013-03-12 10:15:10 -07004640 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07004641 packed.append(util.pack_list(self.actions))
Rich Laneb658ddd2013-03-12 10:15:10 -07004642 length = sum([len(x) for x in packed])
4643 packed[2] = struct.pack("!H", length)
4644 return ''.join(packed)
4645
4646 @staticmethod
4647 def unpack(buf):
4648 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4649 obj = flow_modify()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004650 if type(buf) == loxi.generic_util.OFReader:
4651 reader = buf
4652 else:
4653 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004654 _version = reader.read("!B")[0]
4655 assert(_version == 1)
4656 _type = reader.read("!B")[0]
4657 assert(_type == 14)
4658 _length = reader.read("!H")[0]
4659 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004660 obj.match = common.match.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07004661 obj.cookie = reader.read("!Q")[0]
4662 __command = util.unpack_fm_cmd(reader)
4663 assert(__command == 1)
4664 obj.idle_timeout = reader.read("!H")[0]
4665 obj.hard_timeout = reader.read("!H")[0]
4666 obj.priority = reader.read("!H")[0]
4667 obj.buffer_id = reader.read("!L")[0]
4668 obj.out_port = util.unpack_port_no(reader)
4669 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004670 obj.actions = action.unpack_list(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07004671 return obj
4672
4673 def __eq__(self, other):
4674 if type(self) != type(other): return False
4675 if self.version != other.version: return False
4676 if self.type != other.type: return False
4677 if self.xid != other.xid: return False
4678 if self.match != other.match: return False
4679 if self.cookie != other.cookie: return False
4680 if self.idle_timeout != other.idle_timeout: return False
4681 if self.hard_timeout != other.hard_timeout: return False
4682 if self.priority != other.priority: return False
4683 if self.buffer_id != other.buffer_id: return False
4684 if self.out_port != other.out_port: return False
4685 if self.flags != other.flags: return False
4686 if self.actions != other.actions: return False
4687 return True
4688
4689 def __ne__(self, other):
4690 return not self.__eq__(other)
4691
4692 def __str__(self):
4693 return self.show()
4694
4695 def show(self):
4696 import loxi.pp
4697 return loxi.pp.pp(self)
4698
4699 def pretty_print(self, q):
4700 q.text("flow_modify {")
4701 with q.group():
4702 with q.indent(2):
4703 q.breakable()
4704 q.text("xid = ");
4705 if self.xid != None:
4706 q.text("%#x" % self.xid)
4707 else:
4708 q.text('None')
4709 q.text(","); q.breakable()
4710 q.text("match = ");
4711 q.pp(self.match)
4712 q.text(","); q.breakable()
4713 q.text("cookie = ");
4714 q.text("%#x" % self.cookie)
4715 q.text(","); q.breakable()
4716 q.text("idle_timeout = ");
4717 q.text("%#x" % self.idle_timeout)
4718 q.text(","); q.breakable()
4719 q.text("hard_timeout = ");
4720 q.text("%#x" % self.hard_timeout)
4721 q.text(","); q.breakable()
4722 q.text("priority = ");
4723 q.text("%#x" % self.priority)
4724 q.text(","); q.breakable()
4725 q.text("buffer_id = ");
4726 q.text("%#x" % self.buffer_id)
4727 q.text(","); q.breakable()
4728 q.text("out_port = ");
4729 q.text(util.pretty_port(self.out_port))
4730 q.text(","); q.breakable()
4731 q.text("flags = ");
4732 q.text("%#x" % self.flags)
4733 q.text(","); q.breakable()
4734 q.text("actions = ");
4735 q.pp(self.actions)
4736 q.breakable()
4737 q.text('}')
4738
4739class flow_modify_strict(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004740 version = 1
4741 type = 14
4742 _command = 2
Rich Laneb658ddd2013-03-12 10:15:10 -07004743
4744 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):
4745 self.xid = xid
4746 if match != None:
4747 self.match = match
4748 else:
4749 self.match = common.match()
4750 if cookie != None:
4751 self.cookie = cookie
4752 else:
4753 self.cookie = 0
4754 if idle_timeout != None:
4755 self.idle_timeout = idle_timeout
4756 else:
4757 self.idle_timeout = 0
4758 if hard_timeout != None:
4759 self.hard_timeout = hard_timeout
4760 else:
4761 self.hard_timeout = 0
4762 if priority != None:
4763 self.priority = priority
4764 else:
4765 self.priority = 0
4766 if buffer_id != None:
4767 self.buffer_id = buffer_id
4768 else:
4769 self.buffer_id = 0
4770 if out_port != None:
4771 self.out_port = out_port
4772 else:
4773 self.out_port = 0
4774 if flags != None:
4775 self.flags = flags
4776 else:
4777 self.flags = 0
4778 if actions != None:
4779 self.actions = actions
4780 else:
4781 self.actions = []
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 packed.append(self.match.pack())
4790 packed.append(struct.pack("!Q", self.cookie))
Dan Talaycof6202252013-07-02 01:00:29 -07004791 packed.append(util.pack_fm_cmd(self._command))
Rich Laneb658ddd2013-03-12 10:15:10 -07004792 packed.append(struct.pack("!H", self.idle_timeout))
4793 packed.append(struct.pack("!H", self.hard_timeout))
4794 packed.append(struct.pack("!H", self.priority))
4795 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004796 packed.append(util.pack_port_no(self.out_port))
Rich Laneb658ddd2013-03-12 10:15:10 -07004797 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07004798 packed.append(util.pack_list(self.actions))
Rich Laneb658ddd2013-03-12 10:15:10 -07004799 length = sum([len(x) for x in packed])
4800 packed[2] = struct.pack("!H", length)
4801 return ''.join(packed)
4802
4803 @staticmethod
4804 def unpack(buf):
4805 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4806 obj = flow_modify_strict()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004807 if type(buf) == loxi.generic_util.OFReader:
4808 reader = buf
4809 else:
4810 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004811 _version = reader.read("!B")[0]
4812 assert(_version == 1)
4813 _type = reader.read("!B")[0]
4814 assert(_type == 14)
4815 _length = reader.read("!H")[0]
4816 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004817 obj.match = common.match.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07004818 obj.cookie = reader.read("!Q")[0]
4819 __command = util.unpack_fm_cmd(reader)
4820 assert(__command == 2)
4821 obj.idle_timeout = reader.read("!H")[0]
4822 obj.hard_timeout = reader.read("!H")[0]
4823 obj.priority = reader.read("!H")[0]
4824 obj.buffer_id = reader.read("!L")[0]
4825 obj.out_port = util.unpack_port_no(reader)
4826 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004827 obj.actions = action.unpack_list(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07004828 return obj
4829
4830 def __eq__(self, other):
4831 if type(self) != type(other): return False
4832 if self.version != other.version: return False
4833 if self.type != other.type: return False
4834 if self.xid != other.xid: return False
4835 if self.match != other.match: return False
4836 if self.cookie != other.cookie: return False
4837 if self.idle_timeout != other.idle_timeout: return False
4838 if self.hard_timeout != other.hard_timeout: return False
4839 if self.priority != other.priority: return False
4840 if self.buffer_id != other.buffer_id: return False
4841 if self.out_port != other.out_port: return False
4842 if self.flags != other.flags: return False
4843 if self.actions != other.actions: return False
4844 return True
4845
4846 def __ne__(self, other):
4847 return not self.__eq__(other)
4848
4849 def __str__(self):
4850 return self.show()
4851
4852 def show(self):
4853 import loxi.pp
4854 return loxi.pp.pp(self)
4855
4856 def pretty_print(self, q):
4857 q.text("flow_modify_strict {")
4858 with q.group():
4859 with q.indent(2):
4860 q.breakable()
4861 q.text("xid = ");
4862 if self.xid != None:
4863 q.text("%#x" % self.xid)
4864 else:
4865 q.text('None')
4866 q.text(","); q.breakable()
4867 q.text("match = ");
4868 q.pp(self.match)
4869 q.text(","); q.breakable()
4870 q.text("cookie = ");
4871 q.text("%#x" % self.cookie)
4872 q.text(","); q.breakable()
4873 q.text("idle_timeout = ");
4874 q.text("%#x" % self.idle_timeout)
4875 q.text(","); q.breakable()
4876 q.text("hard_timeout = ");
4877 q.text("%#x" % self.hard_timeout)
4878 q.text(","); q.breakable()
4879 q.text("priority = ");
4880 q.text("%#x" % self.priority)
4881 q.text(","); q.breakable()
4882 q.text("buffer_id = ");
4883 q.text("%#x" % self.buffer_id)
4884 q.text(","); q.breakable()
4885 q.text("out_port = ");
4886 q.text(util.pretty_port(self.out_port))
4887 q.text(","); q.breakable()
4888 q.text("flags = ");
4889 q.text("%#x" % self.flags)
4890 q.text(","); q.breakable()
4891 q.text("actions = ");
4892 q.pp(self.actions)
4893 q.breakable()
4894 q.text('}')
4895
4896class flow_removed(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07004897 version = 1
4898 type = 11
Rich Laneb658ddd2013-03-12 10:15:10 -07004899
Rich Lanec2ee4b82013-04-24 17:12:38 -07004900 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 -07004901 self.xid = xid
4902 if match != None:
4903 self.match = match
4904 else:
4905 self.match = common.match()
4906 if cookie != None:
4907 self.cookie = cookie
4908 else:
4909 self.cookie = 0
4910 if priority != None:
4911 self.priority = priority
4912 else:
4913 self.priority = 0
4914 if reason != None:
4915 self.reason = reason
4916 else:
4917 self.reason = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07004918 if duration_sec != None:
4919 self.duration_sec = duration_sec
4920 else:
4921 self.duration_sec = 0
4922 if duration_nsec != None:
4923 self.duration_nsec = duration_nsec
4924 else:
4925 self.duration_nsec = 0
4926 if idle_timeout != None:
4927 self.idle_timeout = idle_timeout
4928 else:
4929 self.idle_timeout = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07004930 if packet_count != None:
4931 self.packet_count = packet_count
4932 else:
4933 self.packet_count = 0
4934 if byte_count != None:
4935 self.byte_count = byte_count
4936 else:
4937 self.byte_count = 0
4938
4939 def pack(self):
4940 packed = []
4941 packed.append(struct.pack("!B", self.version))
4942 packed.append(struct.pack("!B", self.type))
4943 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4944 packed.append(struct.pack("!L", self.xid))
4945 packed.append(self.match.pack())
4946 packed.append(struct.pack("!Q", self.cookie))
4947 packed.append(struct.pack("!H", self.priority))
4948 packed.append(struct.pack("!B", self.reason))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004949 packed.append('\x00' * 1)
Rich Laneb658ddd2013-03-12 10:15:10 -07004950 packed.append(struct.pack("!L", self.duration_sec))
4951 packed.append(struct.pack("!L", self.duration_nsec))
4952 packed.append(struct.pack("!H", self.idle_timeout))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004953 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -07004954 packed.append(struct.pack("!Q", self.packet_count))
4955 packed.append(struct.pack("!Q", self.byte_count))
4956 length = sum([len(x) for x in packed])
4957 packed[2] = struct.pack("!H", length)
4958 return ''.join(packed)
4959
4960 @staticmethod
4961 def unpack(buf):
4962 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4963 obj = flow_removed()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004964 if type(buf) == loxi.generic_util.OFReader:
4965 reader = buf
4966 else:
4967 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07004968 _version = reader.read("!B")[0]
4969 assert(_version == 1)
4970 _type = reader.read("!B")[0]
4971 assert(_type == 11)
4972 _length = reader.read("!H")[0]
4973 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004974 obj.match = common.match.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07004975 obj.cookie = reader.read("!Q")[0]
4976 obj.priority = reader.read("!H")[0]
4977 obj.reason = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004978 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07004979 obj.duration_sec = reader.read("!L")[0]
4980 obj.duration_nsec = reader.read("!L")[0]
4981 obj.idle_timeout = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004982 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07004983 obj.packet_count = reader.read("!Q")[0]
4984 obj.byte_count = reader.read("!Q")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07004985 return obj
4986
4987 def __eq__(self, other):
4988 if type(self) != type(other): return False
4989 if self.version != other.version: return False
4990 if self.type != other.type: return False
4991 if self.xid != other.xid: return False
4992 if self.match != other.match: return False
4993 if self.cookie != other.cookie: return False
4994 if self.priority != other.priority: return False
4995 if self.reason != other.reason: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07004996 if self.duration_sec != other.duration_sec: return False
4997 if self.duration_nsec != other.duration_nsec: return False
4998 if self.idle_timeout != other.idle_timeout: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07004999 if self.packet_count != other.packet_count: return False
5000 if self.byte_count != other.byte_count: return False
5001 return True
5002
5003 def __ne__(self, other):
5004 return not self.__eq__(other)
5005
5006 def __str__(self):
5007 return self.show()
5008
5009 def show(self):
5010 import loxi.pp
5011 return loxi.pp.pp(self)
5012
5013 def pretty_print(self, q):
5014 q.text("flow_removed {")
5015 with q.group():
5016 with q.indent(2):
5017 q.breakable()
5018 q.text("xid = ");
5019 if self.xid != None:
5020 q.text("%#x" % self.xid)
5021 else:
5022 q.text('None')
5023 q.text(","); q.breakable()
5024 q.text("match = ");
5025 q.pp(self.match)
5026 q.text(","); q.breakable()
5027 q.text("cookie = ");
5028 q.text("%#x" % self.cookie)
5029 q.text(","); q.breakable()
5030 q.text("priority = ");
5031 q.text("%#x" % self.priority)
5032 q.text(","); q.breakable()
5033 q.text("reason = ");
5034 q.text("%#x" % self.reason)
5035 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07005036 q.text("duration_sec = ");
5037 q.text("%#x" % self.duration_sec)
5038 q.text(","); q.breakable()
5039 q.text("duration_nsec = ");
5040 q.text("%#x" % self.duration_nsec)
5041 q.text(","); q.breakable()
5042 q.text("idle_timeout = ");
5043 q.text("%#x" % self.idle_timeout)
5044 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07005045 q.text("packet_count = ");
5046 q.text("%#x" % self.packet_count)
5047 q.text(","); q.breakable()
5048 q.text("byte_count = ");
5049 q.text("%#x" % self.byte_count)
5050 q.breakable()
5051 q.text('}')
5052
5053class flow_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005054 version = 1
5055 type = 17
5056 stats_type = 1
Rich Laneb658ddd2013-03-12 10:15:10 -07005057
5058 def __init__(self, xid=None, flags=None, entries=None):
5059 self.xid = xid
5060 if flags != None:
5061 self.flags = flags
5062 else:
5063 self.flags = 0
5064 if entries != None:
5065 self.entries = entries
5066 else:
5067 self.entries = []
5068
5069 def pack(self):
5070 packed = []
5071 packed.append(struct.pack("!B", self.version))
5072 packed.append(struct.pack("!B", self.type))
5073 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5074 packed.append(struct.pack("!L", self.xid))
5075 packed.append(struct.pack("!H", self.stats_type))
5076 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07005077 packed.append(util.pack_list(self.entries))
Rich Laneb658ddd2013-03-12 10:15:10 -07005078 length = sum([len(x) for x in packed])
5079 packed[2] = struct.pack("!H", length)
5080 return ''.join(packed)
5081
5082 @staticmethod
5083 def unpack(buf):
5084 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5085 obj = flow_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005086 if type(buf) == loxi.generic_util.OFReader:
5087 reader = buf
5088 else:
5089 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005090 _version = reader.read("!B")[0]
5091 assert(_version == 1)
5092 _type = reader.read("!B")[0]
5093 assert(_type == 17)
5094 _length = reader.read("!H")[0]
5095 obj.xid = reader.read("!L")[0]
5096 _stats_type = reader.read("!H")[0]
5097 assert(_stats_type == 1)
5098 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005099 obj.entries = common.unpack_list_flow_stats_entry(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07005100 return obj
5101
5102 def __eq__(self, other):
5103 if type(self) != type(other): return False
5104 if self.version != other.version: return False
5105 if self.type != other.type: return False
5106 if self.xid != other.xid: return False
5107 if self.flags != other.flags: return False
5108 if self.entries != other.entries: return False
5109 return True
5110
5111 def __ne__(self, other):
5112 return not self.__eq__(other)
5113
5114 def __str__(self):
5115 return self.show()
5116
5117 def show(self):
5118 import loxi.pp
5119 return loxi.pp.pp(self)
5120
5121 def pretty_print(self, q):
5122 q.text("flow_stats_reply {")
5123 with q.group():
5124 with q.indent(2):
5125 q.breakable()
5126 q.text("xid = ");
5127 if self.xid != None:
5128 q.text("%#x" % self.xid)
5129 else:
5130 q.text('None')
5131 q.text(","); q.breakable()
5132 q.text("flags = ");
5133 q.text("%#x" % self.flags)
5134 q.text(","); q.breakable()
5135 q.text("entries = ");
5136 q.pp(self.entries)
5137 q.breakable()
5138 q.text('}')
5139
5140class flow_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005141 version = 1
5142 type = 16
5143 stats_type = 1
Rich Laneb658ddd2013-03-12 10:15:10 -07005144
Rich Lanec2ee4b82013-04-24 17:12:38 -07005145 def __init__(self, xid=None, flags=None, match=None, table_id=None, out_port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07005146 self.xid = xid
5147 if flags != None:
5148 self.flags = flags
5149 else:
5150 self.flags = 0
5151 if match != None:
5152 self.match = match
5153 else:
5154 self.match = common.match()
5155 if table_id != None:
5156 self.table_id = table_id
5157 else:
5158 self.table_id = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07005159 if out_port != None:
5160 self.out_port = out_port
5161 else:
5162 self.out_port = 0
5163
5164 def pack(self):
5165 packed = []
5166 packed.append(struct.pack("!B", self.version))
5167 packed.append(struct.pack("!B", self.type))
5168 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5169 packed.append(struct.pack("!L", self.xid))
5170 packed.append(struct.pack("!H", self.stats_type))
5171 packed.append(struct.pack("!H", self.flags))
5172 packed.append(self.match.pack())
5173 packed.append(struct.pack("!B", self.table_id))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005174 packed.append('\x00' * 1)
Dan Talaycof6202252013-07-02 01:00:29 -07005175 packed.append(util.pack_port_no(self.out_port))
Rich Laneb658ddd2013-03-12 10:15:10 -07005176 length = sum([len(x) for x in packed])
5177 packed[2] = struct.pack("!H", length)
5178 return ''.join(packed)
5179
5180 @staticmethod
5181 def unpack(buf):
5182 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5183 obj = flow_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005184 if type(buf) == loxi.generic_util.OFReader:
5185 reader = buf
5186 else:
5187 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005188 _version = reader.read("!B")[0]
5189 assert(_version == 1)
5190 _type = reader.read("!B")[0]
5191 assert(_type == 16)
5192 _length = reader.read("!H")[0]
5193 obj.xid = reader.read("!L")[0]
5194 _stats_type = reader.read("!H")[0]
5195 assert(_stats_type == 1)
5196 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005197 obj.match = common.match.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07005198 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005199 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07005200 obj.out_port = util.unpack_port_no(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07005201 return obj
5202
5203 def __eq__(self, other):
5204 if type(self) != type(other): return False
5205 if self.version != other.version: return False
5206 if self.type != other.type: return False
5207 if self.xid != other.xid: return False
5208 if self.flags != other.flags: return False
5209 if self.match != other.match: return False
5210 if self.table_id != other.table_id: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07005211 if self.out_port != other.out_port: return False
5212 return True
5213
5214 def __ne__(self, other):
5215 return not self.__eq__(other)
5216
5217 def __str__(self):
5218 return self.show()
5219
5220 def show(self):
5221 import loxi.pp
5222 return loxi.pp.pp(self)
5223
5224 def pretty_print(self, q):
5225 q.text("flow_stats_request {")
5226 with q.group():
5227 with q.indent(2):
5228 q.breakable()
5229 q.text("xid = ");
5230 if self.xid != None:
5231 q.text("%#x" % self.xid)
5232 else:
5233 q.text('None')
5234 q.text(","); q.breakable()
5235 q.text("flags = ");
5236 q.text("%#x" % self.flags)
5237 q.text(","); q.breakable()
5238 q.text("match = ");
5239 q.pp(self.match)
5240 q.text(","); q.breakable()
5241 q.text("table_id = ");
5242 q.text("%#x" % self.table_id)
5243 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07005244 q.text("out_port = ");
5245 q.text(util.pretty_port(self.out_port))
5246 q.breakable()
5247 q.text('}')
5248
5249class get_config_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005250 version = 1
5251 type = 8
Rich Laneb658ddd2013-03-12 10:15:10 -07005252
5253 def __init__(self, xid=None, flags=None, miss_send_len=None):
5254 self.xid = xid
5255 if flags != None:
5256 self.flags = flags
5257 else:
5258 self.flags = 0
5259 if miss_send_len != None:
5260 self.miss_send_len = miss_send_len
5261 else:
5262 self.miss_send_len = 0
5263
5264 def pack(self):
5265 packed = []
5266 packed.append(struct.pack("!B", self.version))
5267 packed.append(struct.pack("!B", self.type))
5268 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5269 packed.append(struct.pack("!L", self.xid))
5270 packed.append(struct.pack("!H", self.flags))
5271 packed.append(struct.pack("!H", self.miss_send_len))
5272 length = sum([len(x) for x in packed])
5273 packed[2] = struct.pack("!H", length)
5274 return ''.join(packed)
5275
5276 @staticmethod
5277 def unpack(buf):
5278 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5279 obj = get_config_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005280 if type(buf) == loxi.generic_util.OFReader:
5281 reader = buf
5282 else:
5283 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005284 _version = reader.read("!B")[0]
5285 assert(_version == 1)
5286 _type = reader.read("!B")[0]
5287 assert(_type == 8)
5288 _length = reader.read("!H")[0]
5289 obj.xid = reader.read("!L")[0]
5290 obj.flags = reader.read("!H")[0]
5291 obj.miss_send_len = reader.read("!H")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07005292 return obj
5293
5294 def __eq__(self, other):
5295 if type(self) != type(other): return False
5296 if self.version != other.version: return False
5297 if self.type != other.type: return False
5298 if self.xid != other.xid: return False
5299 if self.flags != other.flags: return False
5300 if self.miss_send_len != other.miss_send_len: return False
5301 return True
5302
5303 def __ne__(self, other):
5304 return not self.__eq__(other)
5305
5306 def __str__(self):
5307 return self.show()
5308
5309 def show(self):
5310 import loxi.pp
5311 return loxi.pp.pp(self)
5312
5313 def pretty_print(self, q):
5314 q.text("get_config_reply {")
5315 with q.group():
5316 with q.indent(2):
5317 q.breakable()
5318 q.text("xid = ");
5319 if self.xid != None:
5320 q.text("%#x" % self.xid)
5321 else:
5322 q.text('None')
5323 q.text(","); q.breakable()
5324 q.text("flags = ");
5325 q.text("%#x" % self.flags)
5326 q.text(","); q.breakable()
5327 q.text("miss_send_len = ");
5328 q.text("%#x" % self.miss_send_len)
5329 q.breakable()
5330 q.text('}')
5331
5332class get_config_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005333 version = 1
5334 type = 7
Rich Laneb658ddd2013-03-12 10:15:10 -07005335
5336 def __init__(self, xid=None):
5337 self.xid = xid
5338
5339 def pack(self):
5340 packed = []
5341 packed.append(struct.pack("!B", self.version))
5342 packed.append(struct.pack("!B", self.type))
5343 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5344 packed.append(struct.pack("!L", self.xid))
5345 length = sum([len(x) for x in packed])
5346 packed[2] = struct.pack("!H", length)
5347 return ''.join(packed)
5348
5349 @staticmethod
5350 def unpack(buf):
5351 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5352 obj = get_config_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005353 if type(buf) == loxi.generic_util.OFReader:
5354 reader = buf
5355 else:
5356 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005357 _version = reader.read("!B")[0]
5358 assert(_version == 1)
5359 _type = reader.read("!B")[0]
5360 assert(_type == 7)
5361 _length = reader.read("!H")[0]
5362 obj.xid = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07005363 return obj
5364
5365 def __eq__(self, other):
5366 if type(self) != type(other): return False
5367 if self.version != other.version: return False
5368 if self.type != other.type: return False
5369 if self.xid != other.xid: return False
5370 return True
5371
5372 def __ne__(self, other):
5373 return not self.__eq__(other)
5374
5375 def __str__(self):
5376 return self.show()
5377
5378 def show(self):
5379 import loxi.pp
5380 return loxi.pp.pp(self)
5381
5382 def pretty_print(self, q):
5383 q.text("get_config_request {")
5384 with q.group():
5385 with q.indent(2):
5386 q.breakable()
5387 q.text("xid = ");
5388 if self.xid != None:
5389 q.text("%#x" % self.xid)
5390 else:
5391 q.text('None')
5392 q.breakable()
5393 q.text('}')
5394
5395class hello(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005396 version = 1
5397 type = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07005398
5399 def __init__(self, xid=None):
5400 self.xid = xid
5401
5402 def pack(self):
5403 packed = []
5404 packed.append(struct.pack("!B", self.version))
5405 packed.append(struct.pack("!B", self.type))
5406 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5407 packed.append(struct.pack("!L", self.xid))
5408 length = sum([len(x) for x in packed])
5409 packed[2] = struct.pack("!H", length)
5410 return ''.join(packed)
5411
5412 @staticmethod
5413 def unpack(buf):
5414 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5415 obj = hello()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005416 if type(buf) == loxi.generic_util.OFReader:
5417 reader = buf
5418 else:
5419 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005420 _version = reader.read("!B")[0]
5421 assert(_version == 1)
5422 _type = reader.read("!B")[0]
5423 assert(_type == 0)
5424 _length = reader.read("!H")[0]
5425 obj.xid = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07005426 return obj
5427
5428 def __eq__(self, other):
5429 if type(self) != type(other): return False
5430 if self.version != other.version: return False
5431 if self.type != other.type: return False
5432 if self.xid != other.xid: return False
5433 return True
5434
5435 def __ne__(self, other):
5436 return not self.__eq__(other)
5437
5438 def __str__(self):
5439 return self.show()
5440
5441 def show(self):
5442 import loxi.pp
5443 return loxi.pp.pp(self)
5444
5445 def pretty_print(self, q):
5446 q.text("hello {")
5447 with q.group():
5448 with q.indent(2):
5449 q.breakable()
5450 q.text("xid = ");
5451 if self.xid != None:
5452 q.text("%#x" % self.xid)
5453 else:
5454 q.text('None')
5455 q.breakable()
5456 q.text('}')
5457
Rich Lane6f4978c2013-10-20 21:33:52 -07005458class hello_failed_error_msg(Message):
5459 version = 1
5460 type = 1
5461 err_type = 0
5462
5463 def __init__(self, xid=None, code=None, data=None):
5464 self.xid = xid
5465 if code != None:
5466 self.code = code
5467 else:
5468 self.code = 0
5469 if data != None:
5470 self.data = data
5471 else:
5472 self.data = ''
5473
5474 def pack(self):
5475 packed = []
5476 packed.append(struct.pack("!B", self.version))
5477 packed.append(struct.pack("!B", self.type))
5478 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5479 packed.append(struct.pack("!L", self.xid))
5480 packed.append(struct.pack("!H", self.err_type))
5481 packed.append(struct.pack("!H", self.code))
5482 packed.append(self.data)
5483 length = sum([len(x) for x in packed])
5484 packed[2] = struct.pack("!H", length)
5485 return ''.join(packed)
5486
5487 @staticmethod
5488 def unpack(buf):
5489 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5490 obj = hello_failed_error_msg()
5491 if type(buf) == loxi.generic_util.OFReader:
5492 reader = buf
5493 else:
5494 reader = loxi.generic_util.OFReader(buf)
5495 _version = reader.read("!B")[0]
5496 assert(_version == 1)
5497 _type = reader.read("!B")[0]
5498 assert(_type == 1)
5499 _length = reader.read("!H")[0]
5500 obj.xid = reader.read("!L")[0]
5501 _err_type = reader.read("!H")[0]
5502 assert(_err_type == 0)
5503 obj.code = reader.read("!H")[0]
5504 obj.data = str(reader.read_all())
5505 return obj
5506
5507 def __eq__(self, other):
5508 if type(self) != type(other): return False
5509 if self.version != other.version: return False
5510 if self.type != other.type: return False
5511 if self.xid != other.xid: return False
5512 if self.code != other.code: return False
5513 if self.data != other.data: return False
5514 return True
5515
5516 def __ne__(self, other):
5517 return not self.__eq__(other)
5518
5519 def __str__(self):
5520 return self.show()
5521
5522 def show(self):
5523 import loxi.pp
5524 return loxi.pp.pp(self)
5525
5526 def pretty_print(self, q):
5527 q.text("hello_failed_error_msg {")
5528 with q.group():
5529 with q.indent(2):
5530 q.breakable()
5531 q.text("xid = ");
5532 if self.xid != None:
5533 q.text("%#x" % self.xid)
5534 else:
5535 q.text('None')
5536 q.text(","); q.breakable()
5537 q.text("code = ");
5538 q.text("%#x" % self.code)
5539 q.text(","); q.breakable()
5540 q.text("data = ");
5541 q.pp(self.data)
5542 q.breakable()
5543 q.text('}')
5544
Rich Laneb658ddd2013-03-12 10:15:10 -07005545class nicira_controller_role_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005546 version = 1
5547 type = 4
5548 experimenter = 8992
Rich Laneb658ddd2013-03-12 10:15:10 -07005549 subtype = 11
5550
5551 def __init__(self, xid=None, role=None):
5552 self.xid = xid
5553 if role != None:
5554 self.role = role
5555 else:
5556 self.role = 0
5557
5558 def pack(self):
5559 packed = []
5560 packed.append(struct.pack("!B", self.version))
5561 packed.append(struct.pack("!B", self.type))
5562 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5563 packed.append(struct.pack("!L", self.xid))
5564 packed.append(struct.pack("!L", self.experimenter))
5565 packed.append(struct.pack("!L", self.subtype))
5566 packed.append(struct.pack("!L", self.role))
5567 length = sum([len(x) for x in packed])
5568 packed[2] = struct.pack("!H", length)
5569 return ''.join(packed)
5570
5571 @staticmethod
5572 def unpack(buf):
5573 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5574 obj = nicira_controller_role_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005575 if type(buf) == loxi.generic_util.OFReader:
5576 reader = buf
5577 else:
5578 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005579 _version = reader.read("!B")[0]
5580 assert(_version == 1)
5581 _type = reader.read("!B")[0]
5582 assert(_type == 4)
5583 _length = reader.read("!H")[0]
5584 obj.xid = reader.read("!L")[0]
5585 _experimenter = reader.read("!L")[0]
5586 assert(_experimenter == 8992)
5587 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005588 assert(_subtype == 11)
Dan Talaycof6202252013-07-02 01:00:29 -07005589 obj.role = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07005590 return obj
5591
5592 def __eq__(self, other):
5593 if type(self) != type(other): return False
5594 if self.version != other.version: return False
5595 if self.type != other.type: return False
5596 if self.xid != other.xid: return False
5597 if self.role != other.role: return False
5598 return True
5599
5600 def __ne__(self, other):
5601 return not self.__eq__(other)
5602
5603 def __str__(self):
5604 return self.show()
5605
5606 def show(self):
5607 import loxi.pp
5608 return loxi.pp.pp(self)
5609
5610 def pretty_print(self, q):
5611 q.text("nicira_controller_role_reply {")
5612 with q.group():
5613 with q.indent(2):
5614 q.breakable()
5615 q.text("xid = ");
5616 if self.xid != None:
5617 q.text("%#x" % self.xid)
5618 else:
5619 q.text('None')
5620 q.text(","); q.breakable()
5621 q.text("role = ");
5622 q.text("%#x" % self.role)
5623 q.breakable()
5624 q.text('}')
5625
5626class nicira_controller_role_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005627 version = 1
5628 type = 4
5629 experimenter = 8992
Rich Laneb658ddd2013-03-12 10:15:10 -07005630 subtype = 10
5631
5632 def __init__(self, xid=None, role=None):
5633 self.xid = xid
5634 if role != None:
5635 self.role = role
5636 else:
5637 self.role = 0
5638
5639 def pack(self):
5640 packed = []
5641 packed.append(struct.pack("!B", self.version))
5642 packed.append(struct.pack("!B", self.type))
5643 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5644 packed.append(struct.pack("!L", self.xid))
5645 packed.append(struct.pack("!L", self.experimenter))
5646 packed.append(struct.pack("!L", self.subtype))
5647 packed.append(struct.pack("!L", self.role))
5648 length = sum([len(x) for x in packed])
5649 packed[2] = struct.pack("!H", length)
5650 return ''.join(packed)
5651
5652 @staticmethod
5653 def unpack(buf):
5654 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5655 obj = nicira_controller_role_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005656 if type(buf) == loxi.generic_util.OFReader:
5657 reader = buf
5658 else:
5659 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005660 _version = reader.read("!B")[0]
5661 assert(_version == 1)
5662 _type = reader.read("!B")[0]
5663 assert(_type == 4)
5664 _length = reader.read("!H")[0]
5665 obj.xid = reader.read("!L")[0]
5666 _experimenter = reader.read("!L")[0]
5667 assert(_experimenter == 8992)
5668 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005669 assert(_subtype == 10)
Dan Talaycof6202252013-07-02 01:00:29 -07005670 obj.role = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07005671 return obj
5672
5673 def __eq__(self, other):
5674 if type(self) != type(other): return False
5675 if self.version != other.version: return False
5676 if self.type != other.type: return False
5677 if self.xid != other.xid: return False
5678 if self.role != other.role: return False
5679 return True
5680
5681 def __ne__(self, other):
5682 return not self.__eq__(other)
5683
5684 def __str__(self):
5685 return self.show()
5686
5687 def show(self):
5688 import loxi.pp
5689 return loxi.pp.pp(self)
5690
5691 def pretty_print(self, q):
5692 q.text("nicira_controller_role_request {")
5693 with q.group():
5694 with q.indent(2):
5695 q.breakable()
5696 q.text("xid = ");
5697 if self.xid != None:
5698 q.text("%#x" % self.xid)
5699 else:
5700 q.text('None')
5701 q.text(","); q.breakable()
5702 q.text("role = ");
5703 q.text("%#x" % self.role)
5704 q.breakable()
5705 q.text('}')
5706
5707class packet_in(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005708 version = 1
5709 type = 10
Rich Laneb658ddd2013-03-12 10:15:10 -07005710
Rich Lanec2ee4b82013-04-24 17:12:38 -07005711 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 -07005712 self.xid = xid
5713 if buffer_id != None:
5714 self.buffer_id = buffer_id
5715 else:
5716 self.buffer_id = 0
5717 if total_len != None:
5718 self.total_len = total_len
5719 else:
5720 self.total_len = 0
5721 if in_port != None:
5722 self.in_port = in_port
5723 else:
5724 self.in_port = 0
5725 if reason != None:
5726 self.reason = reason
5727 else:
5728 self.reason = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07005729 if data != None:
5730 self.data = data
5731 else:
Dan Talaycof6202252013-07-02 01:00:29 -07005732 self.data = ''
Rich Laneb658ddd2013-03-12 10:15:10 -07005733
5734 def pack(self):
5735 packed = []
5736 packed.append(struct.pack("!B", self.version))
5737 packed.append(struct.pack("!B", self.type))
5738 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5739 packed.append(struct.pack("!L", self.xid))
5740 packed.append(struct.pack("!L", self.buffer_id))
5741 packed.append(struct.pack("!H", self.total_len))
Dan Talaycof6202252013-07-02 01:00:29 -07005742 packed.append(util.pack_port_no(self.in_port))
Rich Laneb658ddd2013-03-12 10:15:10 -07005743 packed.append(struct.pack("!B", self.reason))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005744 packed.append('\x00' * 1)
Rich Laneb658ddd2013-03-12 10:15:10 -07005745 packed.append(self.data)
5746 length = sum([len(x) for x in packed])
5747 packed[2] = struct.pack("!H", length)
5748 return ''.join(packed)
5749
5750 @staticmethod
5751 def unpack(buf):
5752 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5753 obj = packet_in()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005754 if type(buf) == loxi.generic_util.OFReader:
5755 reader = buf
5756 else:
5757 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005758 _version = reader.read("!B")[0]
5759 assert(_version == 1)
5760 _type = reader.read("!B")[0]
5761 assert(_type == 10)
5762 _length = reader.read("!H")[0]
5763 obj.xid = reader.read("!L")[0]
5764 obj.buffer_id = reader.read("!L")[0]
5765 obj.total_len = reader.read("!H")[0]
5766 obj.in_port = util.unpack_port_no(reader)
5767 obj.reason = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005768 reader.skip(1)
5769 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07005770 return obj
5771
5772 def __eq__(self, other):
5773 if type(self) != type(other): return False
5774 if self.version != other.version: return False
5775 if self.type != other.type: return False
5776 if self.xid != other.xid: return False
5777 if self.buffer_id != other.buffer_id: return False
5778 if self.total_len != other.total_len: return False
5779 if self.in_port != other.in_port: return False
5780 if self.reason != other.reason: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07005781 if self.data != other.data: return False
5782 return True
5783
5784 def __ne__(self, other):
5785 return not self.__eq__(other)
5786
5787 def __str__(self):
5788 return self.show()
5789
5790 def show(self):
5791 import loxi.pp
5792 return loxi.pp.pp(self)
5793
5794 def pretty_print(self, q):
5795 q.text("packet_in {")
5796 with q.group():
5797 with q.indent(2):
5798 q.breakable()
5799 q.text("xid = ");
5800 if self.xid != None:
5801 q.text("%#x" % self.xid)
5802 else:
5803 q.text('None')
5804 q.text(","); q.breakable()
5805 q.text("buffer_id = ");
5806 q.text("%#x" % self.buffer_id)
5807 q.text(","); q.breakable()
5808 q.text("total_len = ");
5809 q.text("%#x" % self.total_len)
5810 q.text(","); q.breakable()
5811 q.text("in_port = ");
5812 q.text(util.pretty_port(self.in_port))
5813 q.text(","); q.breakable()
5814 q.text("reason = ");
5815 q.text("%#x" % self.reason)
5816 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07005817 q.text("data = ");
5818 q.pp(self.data)
5819 q.breakable()
5820 q.text('}')
5821
5822class packet_out(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005823 version = 1
5824 type = 13
Rich Laneb658ddd2013-03-12 10:15:10 -07005825
5826 def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None):
5827 self.xid = xid
5828 if buffer_id != None:
5829 self.buffer_id = buffer_id
5830 else:
Rich Laneff637c92013-04-04 13:57:09 -07005831 self.buffer_id = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07005832 if in_port != None:
5833 self.in_port = in_port
5834 else:
5835 self.in_port = 0
5836 if actions != None:
5837 self.actions = actions
5838 else:
5839 self.actions = []
5840 if data != None:
5841 self.data = data
5842 else:
Dan Talaycof6202252013-07-02 01:00:29 -07005843 self.data = ''
Rich Laneb658ddd2013-03-12 10:15:10 -07005844
5845 def pack(self):
5846 packed = []
5847 packed.append(struct.pack("!B", self.version))
5848 packed.append(struct.pack("!B", self.type))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005849 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
Rich Laneb658ddd2013-03-12 10:15:10 -07005850 packed.append(struct.pack("!L", self.xid))
5851 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07005852 packed.append(util.pack_port_no(self.in_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005853 packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6
Dan Talaycof6202252013-07-02 01:00:29 -07005854 packed.append(util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005855 packed[6] = struct.pack("!H", len(packed[-1]))
Rich Laneb658ddd2013-03-12 10:15:10 -07005856 packed.append(self.data)
5857 length = sum([len(x) for x in packed])
5858 packed[2] = struct.pack("!H", length)
5859 return ''.join(packed)
5860
5861 @staticmethod
5862 def unpack(buf):
5863 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
5864 obj = packet_out()
Rich Lanec2ee4b82013-04-24 17:12:38 -07005865 if type(buf) == loxi.generic_util.OFReader:
5866 reader = buf
5867 else:
5868 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07005869 _version = reader.read("!B")[0]
5870 assert(_version == 1)
5871 _type = reader.read("!B")[0]
5872 assert(_type == 13)
5873 _length = reader.read("!H")[0]
5874 obj.xid = reader.read("!L")[0]
5875 obj.buffer_id = reader.read("!L")[0]
5876 obj.in_port = util.unpack_port_no(reader)
5877 _actions_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005878 obj.actions = action.unpack_list(reader.slice(_actions_len))
5879 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07005880 return obj
5881
5882 def __eq__(self, other):
5883 if type(self) != type(other): return False
5884 if self.version != other.version: return False
5885 if self.type != other.type: return False
5886 if self.xid != other.xid: return False
5887 if self.buffer_id != other.buffer_id: return False
5888 if self.in_port != other.in_port: return False
5889 if self.actions != other.actions: return False
5890 if self.data != other.data: return False
5891 return True
5892
5893 def __ne__(self, other):
5894 return not self.__eq__(other)
5895
5896 def __str__(self):
5897 return self.show()
5898
5899 def show(self):
5900 import loxi.pp
5901 return loxi.pp.pp(self)
5902
5903 def pretty_print(self, q):
5904 q.text("packet_out {")
5905 with q.group():
5906 with q.indent(2):
5907 q.breakable()
5908 q.text("xid = ");
5909 if self.xid != None:
5910 q.text("%#x" % self.xid)
5911 else:
5912 q.text('None')
5913 q.text(","); q.breakable()
5914 q.text("buffer_id = ");
5915 q.text("%#x" % self.buffer_id)
5916 q.text(","); q.breakable()
5917 q.text("in_port = ");
5918 q.text(util.pretty_port(self.in_port))
5919 q.text(","); q.breakable()
5920 q.text("actions = ");
5921 q.pp(self.actions)
5922 q.text(","); q.breakable()
5923 q.text("data = ");
5924 q.pp(self.data)
5925 q.breakable()
5926 q.text('}')
5927
5928class port_mod(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07005929 version = 1
5930 type = 15
Rich Laneb658ddd2013-03-12 10:15:10 -07005931
Rich Lanec2ee4b82013-04-24 17:12:38 -07005932 def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07005933 self.xid = xid
5934 if port_no != None:
5935 self.port_no = port_no
5936 else:
5937 self.port_no = 0
5938 if hw_addr != None:
5939 self.hw_addr = hw_addr
5940 else:
5941 self.hw_addr = [0,0,0,0,0,0]
5942 if config != None:
5943 self.config = config
5944 else:
5945 self.config = 0
5946 if mask != None:
5947 self.mask = mask
5948 else:
5949 self.mask = 0
5950 if advertise != None:
5951 self.advertise = advertise
5952 else:
5953 self.advertise = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07005954
5955 def pack(self):
5956 packed = []
5957 packed.append(struct.pack("!B", self.version))
5958 packed.append(struct.pack("!B", self.type))
5959 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5960 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07005961 packed.append(util.pack_port_no(self.port_no))
Rich Laneb658ddd2013-03-12 10:15:10 -07005962 packed.append(struct.pack("!6B", *self.hw_addr))
5963 packed.append(struct.pack("!L", self.config))
5964 packed.append(struct.pack("!L", self.mask))
5965 packed.append(struct.pack("!L", self.advertise))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005966 packed.append('\x00' * 4)
Rich Laneb658ddd2013-03-12 10:15:10 -07005967 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 = port_mod()
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 == 15)
5983 _length = reader.read("!H")[0]
5984 obj.xid = reader.read("!L")[0]
5985 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005986 obj.hw_addr = list(reader.read('!6B'))
Dan Talaycof6202252013-07-02 01:00:29 -07005987 obj.config = reader.read("!L")[0]
5988 obj.mask = reader.read("!L")[0]
5989 obj.advertise = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005990 reader.skip(4)
Rich Laneb658ddd2013-03-12 10:15:10 -07005991 return obj
5992
5993 def __eq__(self, other):
5994 if type(self) != type(other): return False
5995 if self.version != other.version: return False
5996 if self.type != other.type: return False
5997 if self.xid != other.xid: return False
5998 if self.port_no != other.port_no: return False
5999 if self.hw_addr != other.hw_addr: return False
6000 if self.config != other.config: return False
6001 if self.mask != other.mask: return False
6002 if self.advertise != other.advertise: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07006003 return True
6004
6005 def __ne__(self, other):
6006 return not self.__eq__(other)
6007
6008 def __str__(self):
6009 return self.show()
6010
6011 def show(self):
6012 import loxi.pp
6013 return loxi.pp.pp(self)
6014
6015 def pretty_print(self, q):
6016 q.text("port_mod {")
6017 with q.group():
6018 with q.indent(2):
6019 q.breakable()
6020 q.text("xid = ");
6021 if self.xid != None:
6022 q.text("%#x" % self.xid)
6023 else:
6024 q.text('None')
6025 q.text(","); q.breakable()
6026 q.text("port_no = ");
6027 q.text(util.pretty_port(self.port_no))
6028 q.text(","); q.breakable()
6029 q.text("hw_addr = ");
6030 q.text(util.pretty_mac(self.hw_addr))
6031 q.text(","); q.breakable()
6032 q.text("config = ");
6033 q.text("%#x" % self.config)
6034 q.text(","); q.breakable()
6035 q.text("mask = ");
6036 q.text("%#x" % self.mask)
6037 q.text(","); q.breakable()
6038 q.text("advertise = ");
6039 q.text("%#x" % self.advertise)
Rich Laneb658ddd2013-03-12 10:15:10 -07006040 q.breakable()
6041 q.text('}')
6042
Rich Lane6f4978c2013-10-20 21:33:52 -07006043class port_mod_failed_error_msg(Message):
6044 version = 1
6045 type = 1
6046 err_type = 4
6047
6048 def __init__(self, xid=None, code=None, data=None):
6049 self.xid = xid
6050 if code != None:
6051 self.code = code
6052 else:
6053 self.code = 0
6054 if data != None:
6055 self.data = data
6056 else:
6057 self.data = ''
6058
6059 def pack(self):
6060 packed = []
6061 packed.append(struct.pack("!B", self.version))
6062 packed.append(struct.pack("!B", self.type))
6063 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6064 packed.append(struct.pack("!L", self.xid))
6065 packed.append(struct.pack("!H", self.err_type))
6066 packed.append(struct.pack("!H", self.code))
6067 packed.append(self.data)
6068 length = sum([len(x) for x in packed])
6069 packed[2] = struct.pack("!H", length)
6070 return ''.join(packed)
6071
6072 @staticmethod
6073 def unpack(buf):
6074 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6075 obj = port_mod_failed_error_msg()
6076 if type(buf) == loxi.generic_util.OFReader:
6077 reader = buf
6078 else:
6079 reader = loxi.generic_util.OFReader(buf)
6080 _version = reader.read("!B")[0]
6081 assert(_version == 1)
6082 _type = reader.read("!B")[0]
6083 assert(_type == 1)
6084 _length = reader.read("!H")[0]
6085 obj.xid = reader.read("!L")[0]
6086 _err_type = reader.read("!H")[0]
6087 assert(_err_type == 4)
6088 obj.code = reader.read("!H")[0]
6089 obj.data = str(reader.read_all())
6090 return obj
6091
6092 def __eq__(self, other):
6093 if type(self) != type(other): return False
6094 if self.version != other.version: return False
6095 if self.type != other.type: return False
6096 if self.xid != other.xid: return False
6097 if self.code != other.code: return False
6098 if self.data != other.data: return False
6099 return True
6100
6101 def __ne__(self, other):
6102 return not self.__eq__(other)
6103
6104 def __str__(self):
6105 return self.show()
6106
6107 def show(self):
6108 import loxi.pp
6109 return loxi.pp.pp(self)
6110
6111 def pretty_print(self, q):
6112 q.text("port_mod_failed_error_msg {")
6113 with q.group():
6114 with q.indent(2):
6115 q.breakable()
6116 q.text("xid = ");
6117 if self.xid != None:
6118 q.text("%#x" % self.xid)
6119 else:
6120 q.text('None')
6121 q.text(","); q.breakable()
6122 q.text("code = ");
6123 q.text("%#x" % self.code)
6124 q.text(","); q.breakable()
6125 q.text("data = ");
6126 q.pp(self.data)
6127 q.breakable()
6128 q.text('}')
6129
Rich Laneb658ddd2013-03-12 10:15:10 -07006130class port_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006131 version = 1
6132 type = 17
6133 stats_type = 4
Rich Laneb658ddd2013-03-12 10:15:10 -07006134
6135 def __init__(self, xid=None, flags=None, entries=None):
6136 self.xid = xid
6137 if flags != None:
6138 self.flags = flags
6139 else:
6140 self.flags = 0
6141 if entries != None:
6142 self.entries = entries
6143 else:
6144 self.entries = []
6145
6146 def pack(self):
6147 packed = []
6148 packed.append(struct.pack("!B", self.version))
6149 packed.append(struct.pack("!B", self.type))
6150 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6151 packed.append(struct.pack("!L", self.xid))
6152 packed.append(struct.pack("!H", self.stats_type))
6153 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07006154 packed.append(util.pack_list(self.entries))
Rich Laneb658ddd2013-03-12 10:15:10 -07006155 length = sum([len(x) for x in packed])
6156 packed[2] = struct.pack("!H", length)
6157 return ''.join(packed)
6158
6159 @staticmethod
6160 def unpack(buf):
6161 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6162 obj = port_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07006163 if type(buf) == loxi.generic_util.OFReader:
6164 reader = buf
6165 else:
6166 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006167 _version = reader.read("!B")[0]
6168 assert(_version == 1)
6169 _type = reader.read("!B")[0]
6170 assert(_type == 17)
6171 _length = reader.read("!H")[0]
6172 obj.xid = reader.read("!L")[0]
6173 _stats_type = reader.read("!H")[0]
6174 assert(_stats_type == 4)
6175 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006176 obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack)
Rich Laneb658ddd2013-03-12 10:15:10 -07006177 return obj
6178
6179 def __eq__(self, other):
6180 if type(self) != type(other): return False
6181 if self.version != other.version: return False
6182 if self.type != other.type: return False
6183 if self.xid != other.xid: return False
6184 if self.flags != other.flags: return False
6185 if self.entries != other.entries: return False
6186 return True
6187
6188 def __ne__(self, other):
6189 return not self.__eq__(other)
6190
6191 def __str__(self):
6192 return self.show()
6193
6194 def show(self):
6195 import loxi.pp
6196 return loxi.pp.pp(self)
6197
6198 def pretty_print(self, q):
6199 q.text("port_stats_reply {")
6200 with q.group():
6201 with q.indent(2):
6202 q.breakable()
6203 q.text("xid = ");
6204 if self.xid != None:
6205 q.text("%#x" % self.xid)
6206 else:
6207 q.text('None')
6208 q.text(","); q.breakable()
6209 q.text("flags = ");
6210 q.text("%#x" % self.flags)
6211 q.text(","); q.breakable()
6212 q.text("entries = ");
6213 q.pp(self.entries)
6214 q.breakable()
6215 q.text('}')
6216
6217class port_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006218 version = 1
6219 type = 16
6220 stats_type = 4
Rich Laneb658ddd2013-03-12 10:15:10 -07006221
Rich Lanec2ee4b82013-04-24 17:12:38 -07006222 def __init__(self, xid=None, flags=None, port_no=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07006223 self.xid = xid
6224 if flags != None:
6225 self.flags = flags
6226 else:
6227 self.flags = 0
6228 if port_no != None:
6229 self.port_no = port_no
6230 else:
6231 self.port_no = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07006232
6233 def pack(self):
6234 packed = []
6235 packed.append(struct.pack("!B", self.version))
6236 packed.append(struct.pack("!B", self.type))
6237 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6238 packed.append(struct.pack("!L", self.xid))
6239 packed.append(struct.pack("!H", self.stats_type))
6240 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07006241 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006242 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -07006243 length = sum([len(x) for x in packed])
6244 packed[2] = struct.pack("!H", length)
6245 return ''.join(packed)
6246
6247 @staticmethod
6248 def unpack(buf):
6249 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6250 obj = port_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07006251 if type(buf) == loxi.generic_util.OFReader:
6252 reader = buf
6253 else:
6254 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006255 _version = reader.read("!B")[0]
6256 assert(_version == 1)
6257 _type = reader.read("!B")[0]
6258 assert(_type == 16)
6259 _length = reader.read("!H")[0]
6260 obj.xid = reader.read("!L")[0]
6261 _stats_type = reader.read("!H")[0]
6262 assert(_stats_type == 4)
6263 obj.flags = reader.read("!H")[0]
6264 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006265 reader.skip(6)
Rich Laneb658ddd2013-03-12 10:15:10 -07006266 return obj
6267
6268 def __eq__(self, other):
6269 if type(self) != type(other): return False
6270 if self.version != other.version: return False
6271 if self.type != other.type: return False
6272 if self.xid != other.xid: return False
6273 if self.flags != other.flags: return False
6274 if self.port_no != other.port_no: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07006275 return True
6276
6277 def __ne__(self, other):
6278 return not self.__eq__(other)
6279
6280 def __str__(self):
6281 return self.show()
6282
6283 def show(self):
6284 import loxi.pp
6285 return loxi.pp.pp(self)
6286
6287 def pretty_print(self, q):
6288 q.text("port_stats_request {")
6289 with q.group():
6290 with q.indent(2):
6291 q.breakable()
6292 q.text("xid = ");
6293 if self.xid != None:
6294 q.text("%#x" % self.xid)
6295 else:
6296 q.text('None')
6297 q.text(","); q.breakable()
6298 q.text("flags = ");
6299 q.text("%#x" % self.flags)
6300 q.text(","); q.breakable()
6301 q.text("port_no = ");
6302 q.text(util.pretty_port(self.port_no))
Rich Laneb658ddd2013-03-12 10:15:10 -07006303 q.breakable()
6304 q.text('}')
6305
6306class port_status(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006307 version = 1
6308 type = 12
Rich Laneb658ddd2013-03-12 10:15:10 -07006309
Rich Lanec2ee4b82013-04-24 17:12:38 -07006310 def __init__(self, xid=None, reason=None, desc=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07006311 self.xid = xid
6312 if reason != None:
6313 self.reason = reason
6314 else:
6315 self.reason = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07006316 if desc != None:
6317 self.desc = desc
6318 else:
6319 self.desc = common.port_desc()
6320
6321 def pack(self):
6322 packed = []
6323 packed.append(struct.pack("!B", self.version))
6324 packed.append(struct.pack("!B", self.type))
6325 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6326 packed.append(struct.pack("!L", self.xid))
6327 packed.append(struct.pack("!B", self.reason))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006328 packed.append('\x00' * 7)
Rich Laneb658ddd2013-03-12 10:15:10 -07006329 packed.append(self.desc.pack())
6330 length = sum([len(x) for x in packed])
6331 packed[2] = struct.pack("!H", length)
6332 return ''.join(packed)
6333
6334 @staticmethod
6335 def unpack(buf):
6336 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6337 obj = port_status()
Rich Lanec2ee4b82013-04-24 17:12:38 -07006338 if type(buf) == loxi.generic_util.OFReader:
6339 reader = buf
6340 else:
6341 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006342 _version = reader.read("!B")[0]
6343 assert(_version == 1)
6344 _type = reader.read("!B")[0]
6345 assert(_type == 12)
6346 _length = reader.read("!H")[0]
6347 obj.xid = reader.read("!L")[0]
6348 obj.reason = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006349 reader.skip(7)
6350 obj.desc = common.port_desc.unpack(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07006351 return obj
6352
6353 def __eq__(self, other):
6354 if type(self) != type(other): return False
6355 if self.version != other.version: return False
6356 if self.type != other.type: return False
6357 if self.xid != other.xid: return False
6358 if self.reason != other.reason: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07006359 if self.desc != other.desc: return False
6360 return True
6361
6362 def __ne__(self, other):
6363 return not self.__eq__(other)
6364
6365 def __str__(self):
6366 return self.show()
6367
6368 def show(self):
6369 import loxi.pp
6370 return loxi.pp.pp(self)
6371
6372 def pretty_print(self, q):
6373 q.text("port_status {")
6374 with q.group():
6375 with q.indent(2):
6376 q.breakable()
6377 q.text("xid = ");
6378 if self.xid != None:
6379 q.text("%#x" % self.xid)
6380 else:
6381 q.text('None')
6382 q.text(","); q.breakable()
6383 q.text("reason = ");
6384 q.text("%#x" % self.reason)
6385 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07006386 q.text("desc = ");
6387 q.pp(self.desc)
6388 q.breakable()
6389 q.text('}')
6390
6391class queue_get_config_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006392 version = 1
6393 type = 21
Rich Laneb658ddd2013-03-12 10:15:10 -07006394
Rich Lanec2ee4b82013-04-24 17:12:38 -07006395 def __init__(self, xid=None, port=None, queues=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07006396 self.xid = xid
6397 if port != None:
6398 self.port = port
6399 else:
6400 self.port = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07006401 if queues != None:
6402 self.queues = queues
6403 else:
6404 self.queues = []
6405
6406 def pack(self):
6407 packed = []
6408 packed.append(struct.pack("!B", self.version))
6409 packed.append(struct.pack("!B", self.type))
6410 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6411 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07006412 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006413 packed.append('\x00' * 6)
Dan Talaycof6202252013-07-02 01:00:29 -07006414 packed.append(util.pack_list(self.queues))
Rich Laneb658ddd2013-03-12 10:15:10 -07006415 length = sum([len(x) for x in packed])
6416 packed[2] = struct.pack("!H", length)
6417 return ''.join(packed)
6418
6419 @staticmethod
6420 def unpack(buf):
6421 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6422 obj = queue_get_config_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07006423 if type(buf) == loxi.generic_util.OFReader:
6424 reader = buf
6425 else:
6426 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006427 _version = reader.read("!B")[0]
6428 assert(_version == 1)
6429 _type = reader.read("!B")[0]
6430 assert(_type == 21)
6431 _length = reader.read("!H")[0]
6432 obj.xid = reader.read("!L")[0]
6433 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006434 reader.skip(6)
6435 obj.queues = common.unpack_list_packet_queue(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07006436 return obj
6437
6438 def __eq__(self, other):
6439 if type(self) != type(other): return False
6440 if self.version != other.version: return False
6441 if self.type != other.type: return False
6442 if self.xid != other.xid: return False
6443 if self.port != other.port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07006444 if self.queues != other.queues: return False
6445 return True
6446
6447 def __ne__(self, other):
6448 return not self.__eq__(other)
6449
6450 def __str__(self):
6451 return self.show()
6452
6453 def show(self):
6454 import loxi.pp
6455 return loxi.pp.pp(self)
6456
6457 def pretty_print(self, q):
6458 q.text("queue_get_config_reply {")
6459 with q.group():
6460 with q.indent(2):
6461 q.breakable()
6462 q.text("xid = ");
6463 if self.xid != None:
6464 q.text("%#x" % self.xid)
6465 else:
6466 q.text('None')
6467 q.text(","); q.breakable()
6468 q.text("port = ");
6469 q.text(util.pretty_port(self.port))
6470 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07006471 q.text("queues = ");
6472 q.pp(self.queues)
6473 q.breakable()
6474 q.text('}')
6475
6476class queue_get_config_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006477 version = 1
6478 type = 20
Rich Laneb658ddd2013-03-12 10:15:10 -07006479
Rich Lanec2ee4b82013-04-24 17:12:38 -07006480 def __init__(self, xid=None, port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07006481 self.xid = xid
6482 if port != None:
6483 self.port = port
6484 else:
6485 self.port = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07006486
6487 def pack(self):
6488 packed = []
6489 packed.append(struct.pack("!B", self.version))
6490 packed.append(struct.pack("!B", self.type))
6491 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6492 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07006493 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006494 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -07006495 length = sum([len(x) for x in packed])
6496 packed[2] = struct.pack("!H", length)
6497 return ''.join(packed)
6498
6499 @staticmethod
6500 def unpack(buf):
6501 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6502 obj = queue_get_config_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07006503 if type(buf) == loxi.generic_util.OFReader:
6504 reader = buf
6505 else:
6506 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006507 _version = reader.read("!B")[0]
6508 assert(_version == 1)
6509 _type = reader.read("!B")[0]
6510 assert(_type == 20)
6511 _length = reader.read("!H")[0]
6512 obj.xid = reader.read("!L")[0]
6513 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006514 reader.skip(2)
Rich Laneb658ddd2013-03-12 10:15:10 -07006515 return obj
6516
6517 def __eq__(self, other):
6518 if type(self) != type(other): return False
6519 if self.version != other.version: return False
6520 if self.type != other.type: return False
6521 if self.xid != other.xid: return False
6522 if self.port != other.port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07006523 return True
6524
6525 def __ne__(self, other):
6526 return not self.__eq__(other)
6527
6528 def __str__(self):
6529 return self.show()
6530
6531 def show(self):
6532 import loxi.pp
6533 return loxi.pp.pp(self)
6534
6535 def pretty_print(self, q):
6536 q.text("queue_get_config_request {")
6537 with q.group():
6538 with q.indent(2):
6539 q.breakable()
6540 q.text("xid = ");
6541 if self.xid != None:
6542 q.text("%#x" % self.xid)
6543 else:
6544 q.text('None')
6545 q.text(","); q.breakable()
6546 q.text("port = ");
6547 q.text(util.pretty_port(self.port))
Rich Laneb658ddd2013-03-12 10:15:10 -07006548 q.breakable()
6549 q.text('}')
6550
Rich Lane6f4978c2013-10-20 21:33:52 -07006551class queue_op_failed_error_msg(Message):
6552 version = 1
6553 type = 1
6554 err_type = 5
6555
6556 def __init__(self, xid=None, code=None, data=None):
6557 self.xid = xid
6558 if code != None:
6559 self.code = code
6560 else:
6561 self.code = 0
6562 if data != None:
6563 self.data = data
6564 else:
6565 self.data = ''
6566
6567 def pack(self):
6568 packed = []
6569 packed.append(struct.pack("!B", self.version))
6570 packed.append(struct.pack("!B", self.type))
6571 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6572 packed.append(struct.pack("!L", self.xid))
6573 packed.append(struct.pack("!H", self.err_type))
6574 packed.append(struct.pack("!H", self.code))
6575 packed.append(self.data)
6576 length = sum([len(x) for x in packed])
6577 packed[2] = struct.pack("!H", length)
6578 return ''.join(packed)
6579
6580 @staticmethod
6581 def unpack(buf):
6582 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6583 obj = queue_op_failed_error_msg()
6584 if type(buf) == loxi.generic_util.OFReader:
6585 reader = buf
6586 else:
6587 reader = loxi.generic_util.OFReader(buf)
6588 _version = reader.read("!B")[0]
6589 assert(_version == 1)
6590 _type = reader.read("!B")[0]
6591 assert(_type == 1)
6592 _length = reader.read("!H")[0]
6593 obj.xid = reader.read("!L")[0]
6594 _err_type = reader.read("!H")[0]
6595 assert(_err_type == 5)
6596 obj.code = reader.read("!H")[0]
6597 obj.data = str(reader.read_all())
6598 return obj
6599
6600 def __eq__(self, other):
6601 if type(self) != type(other): return False
6602 if self.version != other.version: return False
6603 if self.type != other.type: return False
6604 if self.xid != other.xid: return False
6605 if self.code != other.code: return False
6606 if self.data != other.data: return False
6607 return True
6608
6609 def __ne__(self, other):
6610 return not self.__eq__(other)
6611
6612 def __str__(self):
6613 return self.show()
6614
6615 def show(self):
6616 import loxi.pp
6617 return loxi.pp.pp(self)
6618
6619 def pretty_print(self, q):
6620 q.text("queue_op_failed_error_msg {")
6621 with q.group():
6622 with q.indent(2):
6623 q.breakable()
6624 q.text("xid = ");
6625 if self.xid != None:
6626 q.text("%#x" % self.xid)
6627 else:
6628 q.text('None')
6629 q.text(","); q.breakable()
6630 q.text("code = ");
6631 q.text("%#x" % self.code)
6632 q.text(","); q.breakable()
6633 q.text("data = ");
6634 q.pp(self.data)
6635 q.breakable()
6636 q.text('}')
6637
Rich Laneb658ddd2013-03-12 10:15:10 -07006638class queue_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006639 version = 1
6640 type = 17
6641 stats_type = 5
Rich Laneb658ddd2013-03-12 10:15:10 -07006642
6643 def __init__(self, xid=None, flags=None, entries=None):
6644 self.xid = xid
6645 if flags != None:
6646 self.flags = flags
6647 else:
6648 self.flags = 0
6649 if entries != None:
6650 self.entries = entries
6651 else:
6652 self.entries = []
6653
6654 def pack(self):
6655 packed = []
6656 packed.append(struct.pack("!B", self.version))
6657 packed.append(struct.pack("!B", self.type))
6658 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6659 packed.append(struct.pack("!L", self.xid))
6660 packed.append(struct.pack("!H", self.stats_type))
6661 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07006662 packed.append(util.pack_list(self.entries))
Rich Laneb658ddd2013-03-12 10:15:10 -07006663 length = sum([len(x) for x in packed])
6664 packed[2] = struct.pack("!H", length)
6665 return ''.join(packed)
6666
6667 @staticmethod
6668 def unpack(buf):
6669 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6670 obj = queue_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07006671 if type(buf) == loxi.generic_util.OFReader:
6672 reader = buf
6673 else:
6674 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006675 _version = reader.read("!B")[0]
6676 assert(_version == 1)
6677 _type = reader.read("!B")[0]
6678 assert(_type == 17)
6679 _length = reader.read("!H")[0]
6680 obj.xid = reader.read("!L")[0]
6681 _stats_type = reader.read("!H")[0]
6682 assert(_stats_type == 5)
6683 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006684 obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack)
Rich Laneb658ddd2013-03-12 10:15:10 -07006685 return obj
6686
6687 def __eq__(self, other):
6688 if type(self) != type(other): return False
6689 if self.version != other.version: return False
6690 if self.type != other.type: return False
6691 if self.xid != other.xid: return False
6692 if self.flags != other.flags: return False
6693 if self.entries != other.entries: return False
6694 return True
6695
6696 def __ne__(self, other):
6697 return not self.__eq__(other)
6698
6699 def __str__(self):
6700 return self.show()
6701
6702 def show(self):
6703 import loxi.pp
6704 return loxi.pp.pp(self)
6705
6706 def pretty_print(self, q):
6707 q.text("queue_stats_reply {")
6708 with q.group():
6709 with q.indent(2):
6710 q.breakable()
6711 q.text("xid = ");
6712 if self.xid != None:
6713 q.text("%#x" % self.xid)
6714 else:
6715 q.text('None')
6716 q.text(","); q.breakable()
6717 q.text("flags = ");
6718 q.text("%#x" % self.flags)
6719 q.text(","); q.breakable()
6720 q.text("entries = ");
6721 q.pp(self.entries)
6722 q.breakable()
6723 q.text('}')
6724
6725class queue_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006726 version = 1
6727 type = 16
6728 stats_type = 5
Rich Laneb658ddd2013-03-12 10:15:10 -07006729
Rich Lanec2ee4b82013-04-24 17:12:38 -07006730 def __init__(self, xid=None, flags=None, port_no=None, queue_id=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07006731 self.xid = xid
6732 if flags != None:
6733 self.flags = flags
6734 else:
6735 self.flags = 0
6736 if port_no != None:
6737 self.port_no = port_no
6738 else:
6739 self.port_no = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07006740 if queue_id != None:
6741 self.queue_id = queue_id
6742 else:
6743 self.queue_id = 0
6744
6745 def pack(self):
6746 packed = []
6747 packed.append(struct.pack("!B", self.version))
6748 packed.append(struct.pack("!B", self.type))
6749 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6750 packed.append(struct.pack("!L", self.xid))
6751 packed.append(struct.pack("!H", self.stats_type))
6752 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07006753 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006754 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -07006755 packed.append(struct.pack("!L", self.queue_id))
6756 length = sum([len(x) for x in packed])
6757 packed[2] = struct.pack("!H", length)
6758 return ''.join(packed)
6759
6760 @staticmethod
6761 def unpack(buf):
6762 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6763 obj = queue_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07006764 if type(buf) == loxi.generic_util.OFReader:
6765 reader = buf
6766 else:
6767 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006768 _version = reader.read("!B")[0]
6769 assert(_version == 1)
6770 _type = reader.read("!B")[0]
6771 assert(_type == 16)
6772 _length = reader.read("!H")[0]
6773 obj.xid = reader.read("!L")[0]
6774 _stats_type = reader.read("!H")[0]
6775 assert(_stats_type == 5)
6776 obj.flags = reader.read("!H")[0]
6777 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006778 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07006779 obj.queue_id = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07006780 return obj
6781
6782 def __eq__(self, other):
6783 if type(self) != type(other): return False
6784 if self.version != other.version: return False
6785 if self.type != other.type: return False
6786 if self.xid != other.xid: return False
6787 if self.flags != other.flags: return False
6788 if self.port_no != other.port_no: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07006789 if self.queue_id != other.queue_id: return False
6790 return True
6791
6792 def __ne__(self, other):
6793 return not self.__eq__(other)
6794
6795 def __str__(self):
6796 return self.show()
6797
6798 def show(self):
6799 import loxi.pp
6800 return loxi.pp.pp(self)
6801
6802 def pretty_print(self, q):
6803 q.text("queue_stats_request {")
6804 with q.group():
6805 with q.indent(2):
6806 q.breakable()
6807 q.text("xid = ");
6808 if self.xid != None:
6809 q.text("%#x" % self.xid)
6810 else:
6811 q.text('None')
6812 q.text(","); q.breakable()
6813 q.text("flags = ");
6814 q.text("%#x" % self.flags)
6815 q.text(","); q.breakable()
6816 q.text("port_no = ");
6817 q.text(util.pretty_port(self.port_no))
6818 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07006819 q.text("queue_id = ");
6820 q.text("%#x" % self.queue_id)
6821 q.breakable()
6822 q.text('}')
6823
6824class set_config(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006825 version = 1
6826 type = 9
Rich Laneb658ddd2013-03-12 10:15:10 -07006827
6828 def __init__(self, xid=None, flags=None, miss_send_len=None):
6829 self.xid = xid
6830 if flags != None:
6831 self.flags = flags
6832 else:
6833 self.flags = 0
6834 if miss_send_len != None:
6835 self.miss_send_len = miss_send_len
6836 else:
6837 self.miss_send_len = 0
6838
6839 def pack(self):
6840 packed = []
6841 packed.append(struct.pack("!B", self.version))
6842 packed.append(struct.pack("!B", self.type))
6843 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6844 packed.append(struct.pack("!L", self.xid))
6845 packed.append(struct.pack("!H", self.flags))
6846 packed.append(struct.pack("!H", self.miss_send_len))
6847 length = sum([len(x) for x in packed])
6848 packed[2] = struct.pack("!H", length)
6849 return ''.join(packed)
6850
6851 @staticmethod
6852 def unpack(buf):
6853 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6854 obj = set_config()
Rich Lanec2ee4b82013-04-24 17:12:38 -07006855 if type(buf) == loxi.generic_util.OFReader:
6856 reader = buf
6857 else:
6858 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006859 _version = reader.read("!B")[0]
6860 assert(_version == 1)
6861 _type = reader.read("!B")[0]
6862 assert(_type == 9)
6863 _length = reader.read("!H")[0]
6864 obj.xid = reader.read("!L")[0]
6865 obj.flags = reader.read("!H")[0]
6866 obj.miss_send_len = reader.read("!H")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07006867 return obj
6868
6869 def __eq__(self, other):
6870 if type(self) != type(other): return False
6871 if self.version != other.version: return False
6872 if self.type != other.type: return False
6873 if self.xid != other.xid: return False
6874 if self.flags != other.flags: return False
6875 if self.miss_send_len != other.miss_send_len: return False
6876 return True
6877
6878 def __ne__(self, other):
6879 return not self.__eq__(other)
6880
6881 def __str__(self):
6882 return self.show()
6883
6884 def show(self):
6885 import loxi.pp
6886 return loxi.pp.pp(self)
6887
6888 def pretty_print(self, q):
6889 q.text("set_config {")
6890 with q.group():
6891 with q.indent(2):
6892 q.breakable()
6893 q.text("xid = ");
6894 if self.xid != None:
6895 q.text("%#x" % self.xid)
6896 else:
6897 q.text('None')
6898 q.text(","); q.breakable()
6899 q.text("flags = ");
6900 q.text("%#x" % self.flags)
6901 q.text(","); q.breakable()
6902 q.text("miss_send_len = ");
6903 q.text("%#x" % self.miss_send_len)
6904 q.breakable()
6905 q.text('}')
6906
6907class table_mod(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006908 version = 1
Rich Laneb658ddd2013-03-12 10:15:10 -07006909 type = 22
6910
Rich Lanec2ee4b82013-04-24 17:12:38 -07006911 def __init__(self, xid=None, table_id=None, config=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07006912 self.xid = xid
6913 if table_id != None:
6914 self.table_id = table_id
6915 else:
6916 self.table_id = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07006917 if config != None:
6918 self.config = config
6919 else:
6920 self.config = 0
6921
6922 def pack(self):
6923 packed = []
6924 packed.append(struct.pack("!B", self.version))
6925 packed.append(struct.pack("!B", self.type))
6926 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6927 packed.append(struct.pack("!L", self.xid))
6928 packed.append(struct.pack("!B", self.table_id))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006929 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07006930 packed.append(struct.pack("!L", self.config))
6931 length = sum([len(x) for x in packed])
6932 packed[2] = struct.pack("!H", length)
6933 return ''.join(packed)
6934
6935 @staticmethod
6936 def unpack(buf):
6937 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
6938 obj = table_mod()
Rich Lanec2ee4b82013-04-24 17:12:38 -07006939 if type(buf) == loxi.generic_util.OFReader:
6940 reader = buf
6941 else:
6942 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07006943 _version = reader.read("!B")[0]
6944 assert(_version == 1)
6945 _type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006946 assert(_type == 22)
Dan Talaycof6202252013-07-02 01:00:29 -07006947 _length = reader.read("!H")[0]
6948 obj.xid = reader.read("!L")[0]
6949 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006950 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07006951 obj.config = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07006952 return obj
6953
6954 def __eq__(self, other):
6955 if type(self) != type(other): return False
6956 if self.version != other.version: return False
6957 if self.type != other.type: return False
6958 if self.xid != other.xid: return False
6959 if self.table_id != other.table_id: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07006960 if self.config != other.config: return False
6961 return True
6962
6963 def __ne__(self, other):
6964 return not self.__eq__(other)
6965
6966 def __str__(self):
6967 return self.show()
6968
6969 def show(self):
6970 import loxi.pp
6971 return loxi.pp.pp(self)
6972
6973 def pretty_print(self, q):
6974 q.text("table_mod {")
6975 with q.group():
6976 with q.indent(2):
6977 q.breakable()
6978 q.text("xid = ");
6979 if self.xid != None:
6980 q.text("%#x" % self.xid)
6981 else:
6982 q.text('None')
6983 q.text(","); q.breakable()
6984 q.text("table_id = ");
6985 q.text("%#x" % self.table_id)
6986 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07006987 q.text("config = ");
6988 q.text("%#x" % self.config)
6989 q.breakable()
6990 q.text('}')
6991
6992class table_stats_reply(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07006993 version = 1
6994 type = 17
6995 stats_type = 3
Rich Laneb658ddd2013-03-12 10:15:10 -07006996
6997 def __init__(self, xid=None, flags=None, entries=None):
6998 self.xid = xid
6999 if flags != None:
7000 self.flags = flags
7001 else:
7002 self.flags = 0
7003 if entries != None:
7004 self.entries = entries
7005 else:
7006 self.entries = []
7007
7008 def pack(self):
7009 packed = []
7010 packed.append(struct.pack("!B", self.version))
7011 packed.append(struct.pack("!B", self.type))
7012 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7013 packed.append(struct.pack("!L", self.xid))
7014 packed.append(struct.pack("!H", self.stats_type))
7015 packed.append(struct.pack("!H", self.flags))
Dan Talaycof6202252013-07-02 01:00:29 -07007016 packed.append(util.pack_list(self.entries))
Rich Laneb658ddd2013-03-12 10:15:10 -07007017 length = sum([len(x) for x in packed])
7018 packed[2] = struct.pack("!H", length)
7019 return ''.join(packed)
7020
7021 @staticmethod
7022 def unpack(buf):
7023 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
7024 obj = table_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07007025 if type(buf) == loxi.generic_util.OFReader:
7026 reader = buf
7027 else:
7028 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07007029 _version = reader.read("!B")[0]
7030 assert(_version == 1)
7031 _type = reader.read("!B")[0]
7032 assert(_type == 17)
7033 _length = reader.read("!H")[0]
7034 obj.xid = reader.read("!L")[0]
7035 _stats_type = reader.read("!H")[0]
7036 assert(_stats_type == 3)
7037 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007038 obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack)
Rich Laneb658ddd2013-03-12 10:15:10 -07007039 return obj
7040
7041 def __eq__(self, other):
7042 if type(self) != type(other): return False
7043 if self.version != other.version: return False
7044 if self.type != other.type: return False
7045 if self.xid != other.xid: return False
7046 if self.flags != other.flags: return False
7047 if self.entries != other.entries: return False
7048 return True
7049
7050 def __ne__(self, other):
7051 return not self.__eq__(other)
7052
7053 def __str__(self):
7054 return self.show()
7055
7056 def show(self):
7057 import loxi.pp
7058 return loxi.pp.pp(self)
7059
7060 def pretty_print(self, q):
7061 q.text("table_stats_reply {")
7062 with q.group():
7063 with q.indent(2):
7064 q.breakable()
7065 q.text("xid = ");
7066 if self.xid != None:
7067 q.text("%#x" % self.xid)
7068 else:
7069 q.text('None')
7070 q.text(","); q.breakable()
7071 q.text("flags = ");
7072 q.text("%#x" % self.flags)
7073 q.text(","); q.breakable()
7074 q.text("entries = ");
7075 q.pp(self.entries)
7076 q.breakable()
7077 q.text('}')
7078
7079class table_stats_request(Message):
Dan Talaycof6202252013-07-02 01:00:29 -07007080 version = 1
7081 type = 16
7082 stats_type = 3
Rich Laneb658ddd2013-03-12 10:15:10 -07007083
7084 def __init__(self, xid=None, flags=None):
7085 self.xid = xid
7086 if flags != None:
7087 self.flags = flags
7088 else:
7089 self.flags = 0
7090
7091 def pack(self):
7092 packed = []
7093 packed.append(struct.pack("!B", self.version))
7094 packed.append(struct.pack("!B", self.type))
7095 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7096 packed.append(struct.pack("!L", self.xid))
7097 packed.append(struct.pack("!H", self.stats_type))
7098 packed.append(struct.pack("!H", self.flags))
7099 length = sum([len(x) for x in packed])
7100 packed[2] = struct.pack("!H", length)
7101 return ''.join(packed)
7102
7103 @staticmethod
7104 def unpack(buf):
7105 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
7106 obj = table_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07007107 if type(buf) == loxi.generic_util.OFReader:
7108 reader = buf
7109 else:
7110 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07007111 _version = reader.read("!B")[0]
7112 assert(_version == 1)
7113 _type = reader.read("!B")[0]
7114 assert(_type == 16)
7115 _length = reader.read("!H")[0]
7116 obj.xid = reader.read("!L")[0]
7117 _stats_type = reader.read("!H")[0]
7118 assert(_stats_type == 3)
7119 obj.flags = reader.read("!H")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07007120 return obj
7121
7122 def __eq__(self, other):
7123 if type(self) != type(other): return False
7124 if self.version != other.version: return False
7125 if self.type != other.type: return False
7126 if self.xid != other.xid: return False
7127 if self.flags != other.flags: return False
7128 return True
7129
7130 def __ne__(self, other):
7131 return not self.__eq__(other)
7132
7133 def __str__(self):
7134 return self.show()
7135
7136 def show(self):
7137 import loxi.pp
7138 return loxi.pp.pp(self)
7139
7140 def pretty_print(self, q):
7141 q.text("table_stats_request {")
7142 with q.group():
7143 with q.indent(2):
7144 q.breakable()
7145 q.text("xid = ");
7146 if self.xid != None:
7147 q.text("%#x" % self.xid)
7148 else:
7149 q.text('None')
7150 q.text(","); q.breakable()
7151 q.text("flags = ");
7152 q.text("%#x" % self.flags)
7153 q.breakable()
7154 q.text('}')
7155
7156
7157def parse_header(buf):
7158 if len(buf) < 8:
7159 raise loxi.ProtocolError("too short to be an OpenFlow message")
7160 return struct.unpack_from("!BBHL", buf)
7161
7162def parse_message(buf):
7163 msg_ver, msg_type, msg_len, msg_xid = parse_header(buf)
Rich Lanefe600f52013-07-09 13:22:32 -07007164 if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO:
7165 raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (const.OFP_VERSION, msg_ver))
Rich Laneb658ddd2013-03-12 10:15:10 -07007166 if len(buf) != msg_len:
7167 raise loxi.ProtocolError("incorrect message size")
7168 if msg_type in parsers:
7169 return parsers[msg_type](buf)
7170 else:
7171 raise loxi.ProtocolError("unexpected message type")
7172
Rich Lane6f4978c2013-10-20 21:33:52 -07007173def parse_error(buf):
7174 if len(buf) < 8 + 2:
7175 raise loxi.ProtocolError("message too short")
7176 err_type, = struct.unpack_from("!H", buf, 8)
7177 if err_type in error_msg_parsers:
7178 return error_msg_parsers[err_type](buf)
7179 else:
7180 raise loxi.ProtocolError("unexpected error type %u" % err_type)
7181
Rich Laneb658ddd2013-03-12 10:15:10 -07007182def parse_flow_mod(buf):
Rich Lanefe600f52013-07-09 13:22:32 -07007183 if len(buf) < 57 + 1:
Rich Laneb658ddd2013-03-12 10:15:10 -07007184 raise loxi.ProtocolError("message too short")
Rich Lanefe600f52013-07-09 13:22:32 -07007185 # Technically uint16_t for OF 1.0
7186 cmd, = struct.unpack_from("!B", buf, 57)
Rich Laneb658ddd2013-03-12 10:15:10 -07007187 if cmd in flow_mod_parsers:
7188 return flow_mod_parsers[cmd](buf)
7189 else:
7190 raise loxi.ProtocolError("unexpected flow mod cmd %u" % cmd)
7191
7192def parse_stats_reply(buf):
7193 if len(buf) < 8 + 2:
7194 raise loxi.ProtocolError("message too short")
7195 stats_type, = struct.unpack_from("!H", buf, 8)
7196 if stats_type in stats_reply_parsers:
7197 return stats_reply_parsers[stats_type](buf)
7198 else:
7199 raise loxi.ProtocolError("unexpected stats type %u" % stats_type)
7200
7201def parse_stats_request(buf):
7202 if len(buf) < 8 + 2:
7203 raise loxi.ProtocolError("message too short")
7204 stats_type, = struct.unpack_from("!H", buf, 8)
7205 if stats_type in stats_request_parsers:
7206 return stats_request_parsers[stats_type](buf)
7207 else:
7208 raise loxi.ProtocolError("unexpected stats type %u" % stats_type)
7209
Rich Lane6f4978c2013-10-20 21:33:52 -07007210def parse_experimenter(buf):
Rich Laneb658ddd2013-03-12 10:15:10 -07007211 if len(buf) < 16:
7212 raise loxi.ProtocolError("experimenter message too short")
7213
7214 experimenter, = struct.unpack_from("!L", buf, 8)
7215 if experimenter == 0x005c16c7: # Big Switch Networks
7216 subtype, = struct.unpack_from("!L", buf, 12)
7217 elif experimenter == 0x00002320: # Nicira
7218 subtype, = struct.unpack_from("!L", buf, 12)
7219 else:
7220 raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter)
7221
7222 if subtype in experimenter_parsers[experimenter]:
7223 return experimenter_parsers[experimenter][subtype](buf)
7224 else:
7225 raise loxi.ProtocolError("unexpected experimenter %#x subtype %#x" % (experimenter, subtype))
7226
7227parsers = {
Rich Laneb658ddd2013-03-12 10:15:10 -07007228 const.OFPT_HELLO : hello.unpack,
Rich Lane6f4978c2013-10-20 21:33:52 -07007229 const.OFPT_ERROR : parse_error,
Dan Talaycof6202252013-07-02 01:00:29 -07007230 const.OFPT_ECHO_REQUEST : echo_request.unpack,
7231 const.OFPT_ECHO_REPLY : echo_reply.unpack,
Rich Lane6f4978c2013-10-20 21:33:52 -07007232 const.OFPT_EXPERIMENTER : parse_experimenter,
Dan Talaycof6202252013-07-02 01:00:29 -07007233 const.OFPT_FEATURES_REQUEST : features_request.unpack,
7234 const.OFPT_FEATURES_REPLY : features_reply.unpack,
7235 const.OFPT_GET_CONFIG_REQUEST : get_config_request.unpack,
7236 const.OFPT_GET_CONFIG_REPLY : get_config_reply.unpack,
7237 const.OFPT_SET_CONFIG : set_config.unpack,
7238 const.OFPT_PACKET_IN : packet_in.unpack,
7239 const.OFPT_FLOW_REMOVED : flow_removed.unpack,
7240 const.OFPT_PORT_STATUS : port_status.unpack,
7241 const.OFPT_PACKET_OUT : packet_out.unpack,
7242 const.OFPT_FLOW_MOD : parse_flow_mod,
7243 const.OFPT_PORT_MOD : port_mod.unpack,
7244 const.OFPT_STATS_REQUEST : parse_stats_request,
7245 const.OFPT_STATS_REPLY : parse_stats_reply,
7246 const.OFPT_BARRIER_REQUEST : barrier_request.unpack,
7247 const.OFPT_BARRIER_REPLY : barrier_reply.unpack,
7248 const.OFPT_QUEUE_GET_CONFIG_REQUEST : queue_get_config_request.unpack,
7249 const.OFPT_QUEUE_GET_CONFIG_REPLY : queue_get_config_reply.unpack,
7250 22 : table_mod.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07007251}
7252
Rich Lane6f4978c2013-10-20 21:33:52 -07007253error_msg_parsers = {
7254 const.OFPET_HELLO_FAILED : hello_failed_error_msg.unpack,
7255 const.OFPET_BAD_REQUEST : bad_request_error_msg.unpack,
7256 const.OFPET_BAD_ACTION : bad_action_error_msg.unpack,
7257 const.OFPET_FLOW_MOD_FAILED : flow_mod_failed_error_msg.unpack,
7258 const.OFPET_PORT_MOD_FAILED : port_mod_failed_error_msg.unpack,
7259 const.OFPET_QUEUE_OP_FAILED : queue_op_failed_error_msg.unpack,
7260}
7261
Rich Laneb658ddd2013-03-12 10:15:10 -07007262flow_mod_parsers = {
7263 const.OFPFC_ADD : flow_add.unpack,
7264 const.OFPFC_MODIFY : flow_modify.unpack,
7265 const.OFPFC_MODIFY_STRICT : flow_modify_strict.unpack,
7266 const.OFPFC_DELETE : flow_delete.unpack,
7267 const.OFPFC_DELETE_STRICT : flow_delete_strict.unpack,
7268}
7269
7270stats_reply_parsers = {
7271 const.OFPST_DESC : desc_stats_reply.unpack,
7272 const.OFPST_FLOW : flow_stats_reply.unpack,
7273 const.OFPST_AGGREGATE : aggregate_stats_reply.unpack,
7274 const.OFPST_TABLE : table_stats_reply.unpack,
7275 const.OFPST_PORT : port_stats_reply.unpack,
7276 const.OFPST_QUEUE : queue_stats_reply.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07007277}
7278
7279stats_request_parsers = {
7280 const.OFPST_DESC : desc_stats_request.unpack,
7281 const.OFPST_FLOW : flow_stats_request.unpack,
7282 const.OFPST_AGGREGATE : aggregate_stats_request.unpack,
7283 const.OFPST_TABLE : table_stats_request.unpack,
7284 const.OFPST_PORT : port_stats_request.unpack,
7285 const.OFPST_QUEUE : queue_stats_request.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07007286}
7287
7288experimenter_parsers = {
Dan Talaycof6202252013-07-02 01:00:29 -07007289 8992 : {
Rich Laneb658ddd2013-03-12 10:15:10 -07007290 11: nicira_controller_role_reply.unpack,
7291 10: nicira_controller_role_request.unpack,
7292 },
Dan Talaycof6202252013-07-02 01:00:29 -07007293 6035143 : {
7294 22: bsn_bw_clear_data_reply.unpack,
7295 21: bsn_bw_clear_data_request.unpack,
7296 20: bsn_bw_enable_get_reply.unpack,
7297 19: bsn_bw_enable_get_request.unpack,
7298 23: bsn_bw_enable_set_reply.unpack,
7299 18: bsn_bw_enable_set_request.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07007300 10: bsn_get_interfaces_reply.unpack,
7301 9: bsn_get_interfaces_request.unpack,
7302 2: bsn_get_ip_mask_reply.unpack,
7303 1: bsn_get_ip_mask_request.unpack,
Rich Lane90c961c2013-05-14 09:26:50 -07007304 14: bsn_get_l2_table_reply.unpack,
7305 13: bsn_get_l2_table_request.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07007306 5: bsn_get_mirroring_reply.unpack,
7307 4: bsn_get_mirroring_request.unpack,
Rich Lane6f4978c2013-10-20 21:33:52 -07007308 28: bsn_hybrid_get_reply.unpack,
7309 27: bsn_hybrid_get_request.unpack,
7310 34: bsn_pdu_rx_reply.unpack,
7311 33: bsn_pdu_rx_request.unpack,
7312 35: bsn_pdu_rx_timeout.unpack,
7313 32: bsn_pdu_tx_reply.unpack,
7314 31: bsn_pdu_tx_request.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07007315 0: bsn_set_ip_mask.unpack,
Dan Talaycof6202252013-07-02 01:00:29 -07007316 24: bsn_set_l2_table_reply.unpack,
7317 12: bsn_set_l2_table_request.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07007318 3: bsn_set_mirroring.unpack,
Dan Talaycof6202252013-07-02 01:00:29 -07007319 25: bsn_set_pktin_suppression_reply.unpack,
7320 11: bsn_set_pktin_suppression_request.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07007321 6: bsn_shell_command.unpack,
7322 7: bsn_shell_output.unpack,
7323 8: bsn_shell_status.unpack,
Dan Talaycof6202252013-07-02 01:00:29 -07007324 16: bsn_virtual_port_create_reply.unpack,
7325 15: bsn_virtual_port_create_request.unpack,
7326 26: bsn_virtual_port_remove_reply.unpack,
7327 17: bsn_virtual_port_remove_request.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07007328 },
7329}