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