blob: f12fe1d3b2fd8575fd328888e9ed3668a3c97981 [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.
Rich Laneb658ddd2013-03-12 10:15:10 -07004
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 util
Rich Lanec2ee4b82013-04-24 17:12:38 -070014import loxi.generic_util
Rich Laneb658ddd2013-03-12 10:15:10 -070015
16class Message(object):
17 version = const.OFP_VERSION
18 type = None # override in subclass
19 xid = None
20
21class aggregate_stats_reply(Message):
22 version = const.OFP_VERSION
23 type = const.OFPT_STATS_REPLY
24 stats_type = const.OFPST_AGGREGATE
25
Rich Lanec2ee4b82013-04-24 17:12:38 -070026 def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None):
Rich Laneb658ddd2013-03-12 10:15:10 -070027 self.xid = xid
28 if flags != None:
29 self.flags = flags
30 else:
31 self.flags = 0
32 if packet_count != None:
33 self.packet_count = packet_count
34 else:
35 self.packet_count = 0
36 if byte_count != None:
37 self.byte_count = byte_count
38 else:
39 self.byte_count = 0
40 if flow_count != None:
41 self.flow_count = flow_count
42 else:
43 self.flow_count = 0
Rich Laneb658ddd2013-03-12 10:15:10 -070044
45 def pack(self):
46 packed = []
47 packed.append(struct.pack("!B", self.version))
48 packed.append(struct.pack("!B", self.type))
49 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
50 packed.append(struct.pack("!L", self.xid))
51 packed.append(struct.pack("!H", self.stats_type))
52 packed.append(struct.pack("!H", self.flags))
53 packed.append(struct.pack("!Q", self.packet_count))
54 packed.append(struct.pack("!Q", self.byte_count))
55 packed.append(struct.pack("!L", self.flow_count))
Rich Lanec2ee4b82013-04-24 17:12:38 -070056 packed.append('\x00' * 4)
Rich Laneb658ddd2013-03-12 10:15:10 -070057 length = sum([len(x) for x in packed])
58 packed[2] = struct.pack("!H", length)
59 return ''.join(packed)
60
61 @staticmethod
62 def unpack(buf):
63 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
64 obj = aggregate_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -070065 if type(buf) == loxi.generic_util.OFReader:
66 reader = buf
67 else:
68 reader = loxi.generic_util.OFReader(buf)
69 _version = reader.read('!B')[0]
70 assert(_version == const.OFP_VERSION)
71 _type = reader.read('!B')[0]
72 assert(_type == const.OFPT_STATS_REPLY)
73 _length = reader.read('!H')[0]
74 obj.xid = reader.read('!L')[0]
75 _stats_type = reader.read('!H')[0]
76 assert(_stats_type == const.OFPST_AGGREGATE)
77 obj.flags = reader.read('!H')[0]
78 obj.packet_count = reader.read('!Q')[0]
79 obj.byte_count = reader.read('!Q')[0]
80 obj.flow_count = reader.read('!L')[0]
81 reader.skip(4)
Rich Laneb658ddd2013-03-12 10:15:10 -070082 return obj
83
84 def __eq__(self, other):
85 if type(self) != type(other): return False
86 if self.version != other.version: return False
87 if self.type != other.type: return False
88 if self.xid != other.xid: return False
89 if self.flags != other.flags: return False
90 if self.packet_count != other.packet_count: return False
91 if self.byte_count != other.byte_count: return False
92 if self.flow_count != other.flow_count: return False
Rich Laneb658ddd2013-03-12 10:15:10 -070093 return True
94
95 def __ne__(self, other):
96 return not self.__eq__(other)
97
98 def __str__(self):
99 return self.show()
100
101 def show(self):
102 import loxi.pp
103 return loxi.pp.pp(self)
104
105 def pretty_print(self, q):
106 q.text("aggregate_stats_reply {")
107 with q.group():
108 with q.indent(2):
109 q.breakable()
110 q.text("xid = ");
111 if self.xid != None:
112 q.text("%#x" % self.xid)
113 else:
114 q.text('None')
115 q.text(","); q.breakable()
116 q.text("flags = ");
117 q.text("%#x" % self.flags)
118 q.text(","); q.breakable()
119 q.text("packet_count = ");
120 q.text("%#x" % self.packet_count)
121 q.text(","); q.breakable()
122 q.text("byte_count = ");
123 q.text("%#x" % self.byte_count)
124 q.text(","); q.breakable()
125 q.text("flow_count = ");
126 q.text("%#x" % self.flow_count)
Rich Laneb658ddd2013-03-12 10:15:10 -0700127 q.breakable()
128 q.text('}')
129
130class aggregate_stats_request(Message):
131 version = const.OFP_VERSION
132 type = const.OFPT_STATS_REQUEST
133 stats_type = const.OFPST_AGGREGATE
134
Rich Lanec2ee4b82013-04-24 17:12:38 -0700135 def __init__(self, xid=None, flags=None, match=None, table_id=None, out_port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700136 self.xid = xid
137 if flags != None:
138 self.flags = flags
139 else:
140 self.flags = 0
141 if match != None:
142 self.match = match
143 else:
144 self.match = common.match()
145 if table_id != None:
146 self.table_id = table_id
147 else:
148 self.table_id = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700149 if out_port != None:
150 self.out_port = out_port
151 else:
152 self.out_port = 0
153
154 def pack(self):
155 packed = []
156 packed.append(struct.pack("!B", self.version))
157 packed.append(struct.pack("!B", self.type))
158 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
159 packed.append(struct.pack("!L", self.xid))
160 packed.append(struct.pack("!H", self.stats_type))
161 packed.append(struct.pack("!H", self.flags))
162 packed.append(self.match.pack())
163 packed.append(struct.pack("!B", self.table_id))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700164 packed.append('\x00' * 1)
Rich Laneb658ddd2013-03-12 10:15:10 -0700165 packed.append(struct.pack("!H", self.out_port))
166 length = sum([len(x) for x in packed])
167 packed[2] = struct.pack("!H", length)
168 return ''.join(packed)
169
170 @staticmethod
171 def unpack(buf):
172 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
173 obj = aggregate_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700174 if type(buf) == loxi.generic_util.OFReader:
175 reader = buf
176 else:
177 reader = loxi.generic_util.OFReader(buf)
178 _version = reader.read('!B')[0]
179 assert(_version == const.OFP_VERSION)
180 _type = reader.read('!B')[0]
181 assert(_type == const.OFPT_STATS_REQUEST)
182 _length = reader.read('!H')[0]
183 obj.xid = reader.read('!L')[0]
184 _stats_type = reader.read('!H')[0]
185 assert(_stats_type == const.OFPST_AGGREGATE)
186 obj.flags = reader.read('!H')[0]
187 obj.match = common.match.unpack(reader)
188 obj.table_id = reader.read('!B')[0]
189 reader.skip(1)
190 obj.out_port = reader.read('!H')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700191 return obj
192
193 def __eq__(self, other):
194 if type(self) != type(other): return False
195 if self.version != other.version: return False
196 if self.type != other.type: return False
197 if self.xid != other.xid: return False
198 if self.flags != other.flags: return False
199 if self.match != other.match: return False
200 if self.table_id != other.table_id: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700201 if self.out_port != other.out_port: return False
202 return True
203
204 def __ne__(self, other):
205 return not self.__eq__(other)
206
207 def __str__(self):
208 return self.show()
209
210 def show(self):
211 import loxi.pp
212 return loxi.pp.pp(self)
213
214 def pretty_print(self, q):
215 q.text("aggregate_stats_request {")
216 with q.group():
217 with q.indent(2):
218 q.breakable()
219 q.text("xid = ");
220 if self.xid != None:
221 q.text("%#x" % self.xid)
222 else:
223 q.text('None')
224 q.text(","); q.breakable()
225 q.text("flags = ");
226 q.text("%#x" % self.flags)
227 q.text(","); q.breakable()
228 q.text("match = ");
229 q.pp(self.match)
230 q.text(","); q.breakable()
231 q.text("table_id = ");
232 q.text("%#x" % self.table_id)
233 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -0700234 q.text("out_port = ");
235 q.text(util.pretty_port(self.out_port))
236 q.breakable()
237 q.text('}')
238
239class barrier_reply(Message):
240 version = const.OFP_VERSION
241 type = const.OFPT_BARRIER_REPLY
242
243 def __init__(self, xid=None):
244 self.xid = xid
245
246 def pack(self):
247 packed = []
248 packed.append(struct.pack("!B", self.version))
249 packed.append(struct.pack("!B", self.type))
250 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
251 packed.append(struct.pack("!L", self.xid))
252 length = sum([len(x) for x in packed])
253 packed[2] = struct.pack("!H", length)
254 return ''.join(packed)
255
256 @staticmethod
257 def unpack(buf):
258 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
259 obj = barrier_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700260 if type(buf) == loxi.generic_util.OFReader:
261 reader = buf
262 else:
263 reader = loxi.generic_util.OFReader(buf)
264 _version = reader.read('!B')[0]
265 assert(_version == const.OFP_VERSION)
266 _type = reader.read('!B')[0]
267 assert(_type == const.OFPT_BARRIER_REPLY)
268 _length = reader.read('!H')[0]
269 obj.xid = reader.read('!L')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700270 return obj
271
272 def __eq__(self, other):
273 if type(self) != type(other): return False
274 if self.version != other.version: return False
275 if self.type != other.type: return False
276 if self.xid != other.xid: return False
277 return True
278
279 def __ne__(self, other):
280 return not self.__eq__(other)
281
282 def __str__(self):
283 return self.show()
284
285 def show(self):
286 import loxi.pp
287 return loxi.pp.pp(self)
288
289 def pretty_print(self, q):
290 q.text("barrier_reply {")
291 with q.group():
292 with q.indent(2):
293 q.breakable()
294 q.text("xid = ");
295 if self.xid != None:
296 q.text("%#x" % self.xid)
297 else:
298 q.text('None')
299 q.breakable()
300 q.text('}')
301
302class barrier_request(Message):
303 version = const.OFP_VERSION
304 type = const.OFPT_BARRIER_REQUEST
305
306 def __init__(self, xid=None):
307 self.xid = xid
308
309 def pack(self):
310 packed = []
311 packed.append(struct.pack("!B", self.version))
312 packed.append(struct.pack("!B", self.type))
313 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
314 packed.append(struct.pack("!L", self.xid))
315 length = sum([len(x) for x in packed])
316 packed[2] = struct.pack("!H", length)
317 return ''.join(packed)
318
319 @staticmethod
320 def unpack(buf):
321 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
322 obj = barrier_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700323 if type(buf) == loxi.generic_util.OFReader:
324 reader = buf
325 else:
326 reader = loxi.generic_util.OFReader(buf)
327 _version = reader.read('!B')[0]
328 assert(_version == const.OFP_VERSION)
329 _type = reader.read('!B')[0]
330 assert(_type == const.OFPT_BARRIER_REQUEST)
331 _length = reader.read('!H')[0]
332 obj.xid = reader.read('!L')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700333 return obj
334
335 def __eq__(self, other):
336 if type(self) != type(other): return False
337 if self.version != other.version: return False
338 if self.type != other.type: return False
339 if self.xid != other.xid: return False
340 return True
341
342 def __ne__(self, other):
343 return not self.__eq__(other)
344
345 def __str__(self):
346 return self.show()
347
348 def show(self):
349 import loxi.pp
350 return loxi.pp.pp(self)
351
352 def pretty_print(self, q):
353 q.text("barrier_request {")
354 with q.group():
355 with q.indent(2):
356 q.breakable()
357 q.text("xid = ");
358 if self.xid != None:
359 q.text("%#x" % self.xid)
360 else:
361 q.text('None')
362 q.breakable()
363 q.text('}')
364
365class bsn_get_interfaces_reply(Message):
366 version = const.OFP_VERSION
367 type = const.OFPT_VENDOR
368 experimenter = 0x5c16c7
369 subtype = 10
370
371 def __init__(self, xid=None, interfaces=None):
372 self.xid = xid
373 if interfaces != None:
374 self.interfaces = interfaces
375 else:
376 self.interfaces = []
377
378 def pack(self):
379 packed = []
380 packed.append(struct.pack("!B", self.version))
381 packed.append(struct.pack("!B", self.type))
382 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
383 packed.append(struct.pack("!L", self.xid))
384 packed.append(struct.pack("!L", self.experimenter))
385 packed.append(struct.pack("!L", self.subtype))
386 packed.append("".join([x.pack() for x in self.interfaces]))
387 length = sum([len(x) for x in packed])
388 packed[2] = struct.pack("!H", length)
389 return ''.join(packed)
390
391 @staticmethod
392 def unpack(buf):
393 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
394 obj = bsn_get_interfaces_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700395 if type(buf) == loxi.generic_util.OFReader:
396 reader = buf
397 else:
398 reader = loxi.generic_util.OFReader(buf)
399 _version = reader.read('!B')[0]
400 assert(_version == const.OFP_VERSION)
401 _type = reader.read('!B')[0]
402 assert(_type == const.OFPT_VENDOR)
403 _length = reader.read('!H')[0]
404 obj.xid = reader.read('!L')[0]
405 _experimenter = reader.read('!L')[0]
406 assert(_experimenter == 0x5c16c7)
407 _subtype = reader.read('!L')[0]
408 assert(_subtype == 10)
409 obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack)
Rich Laneb658ddd2013-03-12 10:15:10 -0700410 return obj
411
412 def __eq__(self, other):
413 if type(self) != type(other): return False
414 if self.version != other.version: return False
415 if self.type != other.type: return False
416 if self.xid != other.xid: return False
417 if self.interfaces != other.interfaces: return False
418 return True
419
420 def __ne__(self, other):
421 return not self.__eq__(other)
422
423 def __str__(self):
424 return self.show()
425
426 def show(self):
427 import loxi.pp
428 return loxi.pp.pp(self)
429
430 def pretty_print(self, q):
431 q.text("bsn_get_interfaces_reply {")
432 with q.group():
433 with q.indent(2):
434 q.breakable()
435 q.text("xid = ");
436 if self.xid != None:
437 q.text("%#x" % self.xid)
438 else:
439 q.text('None')
440 q.text(","); q.breakable()
441 q.text("interfaces = ");
442 q.pp(self.interfaces)
443 q.breakable()
444 q.text('}')
445
446class bsn_get_interfaces_request(Message):
447 version = const.OFP_VERSION
448 type = const.OFPT_VENDOR
449 experimenter = 0x5c16c7
450 subtype = 9
451
452 def __init__(self, xid=None):
453 self.xid = xid
454
455 def pack(self):
456 packed = []
457 packed.append(struct.pack("!B", self.version))
458 packed.append(struct.pack("!B", self.type))
459 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
460 packed.append(struct.pack("!L", self.xid))
461 packed.append(struct.pack("!L", self.experimenter))
462 packed.append(struct.pack("!L", self.subtype))
463 length = sum([len(x) for x in packed])
464 packed[2] = struct.pack("!H", length)
465 return ''.join(packed)
466
467 @staticmethod
468 def unpack(buf):
469 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
470 obj = bsn_get_interfaces_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700471 if type(buf) == loxi.generic_util.OFReader:
472 reader = buf
473 else:
474 reader = loxi.generic_util.OFReader(buf)
475 _version = reader.read('!B')[0]
476 assert(_version == const.OFP_VERSION)
477 _type = reader.read('!B')[0]
478 assert(_type == const.OFPT_VENDOR)
479 _length = reader.read('!H')[0]
480 obj.xid = reader.read('!L')[0]
481 _experimenter = reader.read('!L')[0]
482 assert(_experimenter == 0x5c16c7)
483 _subtype = reader.read('!L')[0]
484 assert(_subtype == 9)
Rich Laneb658ddd2013-03-12 10:15:10 -0700485 return obj
486
487 def __eq__(self, other):
488 if type(self) != type(other): return False
489 if self.version != other.version: return False
490 if self.type != other.type: return False
491 if self.xid != other.xid: return False
492 return True
493
494 def __ne__(self, other):
495 return not self.__eq__(other)
496
497 def __str__(self):
498 return self.show()
499
500 def show(self):
501 import loxi.pp
502 return loxi.pp.pp(self)
503
504 def pretty_print(self, q):
505 q.text("bsn_get_interfaces_request {")
506 with q.group():
507 with q.indent(2):
508 q.breakable()
509 q.text("xid = ");
510 if self.xid != None:
511 q.text("%#x" % self.xid)
512 else:
513 q.text('None')
514 q.breakable()
515 q.text('}')
516
517class bsn_get_ip_mask_reply(Message):
518 version = const.OFP_VERSION
519 type = const.OFPT_VENDOR
520 experimenter = 0x5c16c7
521 subtype = 2
522
Rich Lanec2ee4b82013-04-24 17:12:38 -0700523 def __init__(self, xid=None, index=None, mask=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700524 self.xid = xid
525 if index != None:
526 self.index = index
527 else:
528 self.index = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700529 if mask != None:
530 self.mask = mask
531 else:
532 self.mask = 0
533
534 def pack(self):
535 packed = []
536 packed.append(struct.pack("!B", self.version))
537 packed.append(struct.pack("!B", self.type))
538 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
539 packed.append(struct.pack("!L", self.xid))
540 packed.append(struct.pack("!L", self.experimenter))
541 packed.append(struct.pack("!L", self.subtype))
542 packed.append(struct.pack("!B", self.index))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700543 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700544 packed.append(struct.pack("!L", self.mask))
545 length = sum([len(x) for x in packed])
546 packed[2] = struct.pack("!H", length)
547 return ''.join(packed)
548
549 @staticmethod
550 def unpack(buf):
551 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
552 obj = bsn_get_ip_mask_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700553 if type(buf) == loxi.generic_util.OFReader:
554 reader = buf
555 else:
556 reader = loxi.generic_util.OFReader(buf)
557 _version = reader.read('!B')[0]
558 assert(_version == const.OFP_VERSION)
559 _type = reader.read('!B')[0]
560 assert(_type == const.OFPT_VENDOR)
561 _length = reader.read('!H')[0]
562 obj.xid = reader.read('!L')[0]
563 _experimenter = reader.read('!L')[0]
564 assert(_experimenter == 0x5c16c7)
565 _subtype = reader.read('!L')[0]
566 assert(_subtype == 2)
567 obj.index = reader.read('!B')[0]
568 reader.skip(3)
569 obj.mask = reader.read('!L')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700570 return obj
571
572 def __eq__(self, other):
573 if type(self) != type(other): return False
574 if self.version != other.version: return False
575 if self.type != other.type: return False
576 if self.xid != other.xid: return False
577 if self.index != other.index: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700578 if self.mask != other.mask: return False
579 return True
580
581 def __ne__(self, other):
582 return not self.__eq__(other)
583
584 def __str__(self):
585 return self.show()
586
587 def show(self):
588 import loxi.pp
589 return loxi.pp.pp(self)
590
591 def pretty_print(self, q):
592 q.text("bsn_get_ip_mask_reply {")
593 with q.group():
594 with q.indent(2):
595 q.breakable()
596 q.text("xid = ");
597 if self.xid != None:
598 q.text("%#x" % self.xid)
599 else:
600 q.text('None')
601 q.text(","); q.breakable()
602 q.text("index = ");
603 q.text("%#x" % self.index)
604 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -0700605 q.text("mask = ");
606 q.text("%#x" % self.mask)
607 q.breakable()
608 q.text('}')
609
610class bsn_get_ip_mask_request(Message):
611 version = const.OFP_VERSION
612 type = const.OFPT_VENDOR
613 experimenter = 0x5c16c7
614 subtype = 1
615
Rich Lanec2ee4b82013-04-24 17:12:38 -0700616 def __init__(self, xid=None, index=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700617 self.xid = xid
618 if index != None:
619 self.index = index
620 else:
621 self.index = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700622
623 def pack(self):
624 packed = []
625 packed.append(struct.pack("!B", self.version))
626 packed.append(struct.pack("!B", self.type))
627 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
628 packed.append(struct.pack("!L", self.xid))
629 packed.append(struct.pack("!L", self.experimenter))
630 packed.append(struct.pack("!L", self.subtype))
631 packed.append(struct.pack("!B", self.index))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700632 packed.append('\x00' * 7)
Rich Laneb658ddd2013-03-12 10:15:10 -0700633 length = sum([len(x) for x in packed])
634 packed[2] = struct.pack("!H", length)
635 return ''.join(packed)
636
637 @staticmethod
638 def unpack(buf):
639 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
640 obj = bsn_get_ip_mask_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700641 if type(buf) == loxi.generic_util.OFReader:
642 reader = buf
643 else:
644 reader = loxi.generic_util.OFReader(buf)
645 _version = reader.read('!B')[0]
646 assert(_version == const.OFP_VERSION)
647 _type = reader.read('!B')[0]
648 assert(_type == const.OFPT_VENDOR)
649 _length = reader.read('!H')[0]
650 obj.xid = reader.read('!L')[0]
651 _experimenter = reader.read('!L')[0]
652 assert(_experimenter == 0x5c16c7)
653 _subtype = reader.read('!L')[0]
654 assert(_subtype == 1)
655 obj.index = reader.read('!B')[0]
656 reader.skip(7)
Rich Laneb658ddd2013-03-12 10:15:10 -0700657 return obj
658
659 def __eq__(self, other):
660 if type(self) != type(other): return False
661 if self.version != other.version: return False
662 if self.type != other.type: return False
663 if self.xid != other.xid: return False
664 if self.index != other.index: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700665 return True
666
667 def __ne__(self, other):
668 return not self.__eq__(other)
669
670 def __str__(self):
671 return self.show()
672
673 def show(self):
674 import loxi.pp
675 return loxi.pp.pp(self)
676
677 def pretty_print(self, q):
678 q.text("bsn_get_ip_mask_request {")
679 with q.group():
680 with q.indent(2):
681 q.breakable()
682 q.text("xid = ");
683 if self.xid != None:
684 q.text("%#x" % self.xid)
685 else:
686 q.text('None')
687 q.text(","); q.breakable()
688 q.text("index = ");
689 q.text("%#x" % self.index)
Rich Laneb658ddd2013-03-12 10:15:10 -0700690 q.breakable()
691 q.text('}')
692
693class bsn_get_mirroring_reply(Message):
694 version = const.OFP_VERSION
695 type = const.OFPT_VENDOR
696 experimenter = 0x5c16c7
697 subtype = 5
698
Rich Lanec2ee4b82013-04-24 17:12:38 -0700699 def __init__(self, xid=None, report_mirror_ports=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700700 self.xid = xid
701 if report_mirror_ports != None:
702 self.report_mirror_ports = report_mirror_ports
703 else:
704 self.report_mirror_ports = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700705
706 def pack(self):
707 packed = []
708 packed.append(struct.pack("!B", self.version))
709 packed.append(struct.pack("!B", self.type))
710 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
711 packed.append(struct.pack("!L", self.xid))
712 packed.append(struct.pack("!L", self.experimenter))
713 packed.append(struct.pack("!L", self.subtype))
714 packed.append(struct.pack("!B", self.report_mirror_ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700715 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700716 length = sum([len(x) for x in packed])
717 packed[2] = struct.pack("!H", length)
718 return ''.join(packed)
719
720 @staticmethod
721 def unpack(buf):
722 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
723 obj = bsn_get_mirroring_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700724 if type(buf) == loxi.generic_util.OFReader:
725 reader = buf
726 else:
727 reader = loxi.generic_util.OFReader(buf)
728 _version = reader.read('!B')[0]
729 assert(_version == const.OFP_VERSION)
730 _type = reader.read('!B')[0]
731 assert(_type == const.OFPT_VENDOR)
732 _length = reader.read('!H')[0]
733 obj.xid = reader.read('!L')[0]
734 _experimenter = reader.read('!L')[0]
735 assert(_experimenter == 0x5c16c7)
736 _subtype = reader.read('!L')[0]
737 assert(_subtype == 5)
738 obj.report_mirror_ports = reader.read('!B')[0]
739 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700740 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 if self.report_mirror_ports != other.report_mirror_ports: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700748 return True
749
750 def __ne__(self, other):
751 return not self.__eq__(other)
752
753 def __str__(self):
754 return self.show()
755
756 def show(self):
757 import loxi.pp
758 return loxi.pp.pp(self)
759
760 def pretty_print(self, q):
761 q.text("bsn_get_mirroring_reply {")
762 with q.group():
763 with q.indent(2):
764 q.breakable()
765 q.text("xid = ");
766 if self.xid != None:
767 q.text("%#x" % self.xid)
768 else:
769 q.text('None')
770 q.text(","); q.breakable()
771 q.text("report_mirror_ports = ");
772 q.text("%#x" % self.report_mirror_ports)
Rich Laneb658ddd2013-03-12 10:15:10 -0700773 q.breakable()
774 q.text('}')
775
776class bsn_get_mirroring_request(Message):
777 version = const.OFP_VERSION
778 type = const.OFPT_VENDOR
779 experimenter = 0x5c16c7
780 subtype = 4
781
Rich Lanec2ee4b82013-04-24 17:12:38 -0700782 def __init__(self, xid=None, report_mirror_ports=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700783 self.xid = xid
784 if report_mirror_ports != None:
785 self.report_mirror_ports = report_mirror_ports
786 else:
787 self.report_mirror_ports = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700788
789 def pack(self):
790 packed = []
791 packed.append(struct.pack("!B", self.version))
792 packed.append(struct.pack("!B", self.type))
793 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
794 packed.append(struct.pack("!L", self.xid))
795 packed.append(struct.pack("!L", self.experimenter))
796 packed.append(struct.pack("!L", self.subtype))
797 packed.append(struct.pack("!B", self.report_mirror_ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700798 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700799 length = sum([len(x) for x in packed])
800 packed[2] = struct.pack("!H", length)
801 return ''.join(packed)
802
803 @staticmethod
804 def unpack(buf):
805 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
806 obj = bsn_get_mirroring_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700807 if type(buf) == loxi.generic_util.OFReader:
808 reader = buf
809 else:
810 reader = loxi.generic_util.OFReader(buf)
811 _version = reader.read('!B')[0]
812 assert(_version == const.OFP_VERSION)
813 _type = reader.read('!B')[0]
814 assert(_type == const.OFPT_VENDOR)
815 _length = reader.read('!H')[0]
816 obj.xid = reader.read('!L')[0]
817 _experimenter = reader.read('!L')[0]
818 assert(_experimenter == 0x5c16c7)
819 _subtype = reader.read('!L')[0]
820 assert(_subtype == 4)
821 obj.report_mirror_ports = reader.read('!B')[0]
822 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700823 return obj
824
825 def __eq__(self, other):
826 if type(self) != type(other): return False
827 if self.version != other.version: return False
828 if self.type != other.type: return False
829 if self.xid != other.xid: return False
830 if self.report_mirror_ports != other.report_mirror_ports: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700831 return True
832
833 def __ne__(self, other):
834 return not self.__eq__(other)
835
836 def __str__(self):
837 return self.show()
838
839 def show(self):
840 import loxi.pp
841 return loxi.pp.pp(self)
842
843 def pretty_print(self, q):
844 q.text("bsn_get_mirroring_request {")
845 with q.group():
846 with q.indent(2):
847 q.breakable()
848 q.text("xid = ");
849 if self.xid != None:
850 q.text("%#x" % self.xid)
851 else:
852 q.text('None')
853 q.text(","); q.breakable()
854 q.text("report_mirror_ports = ");
855 q.text("%#x" % self.report_mirror_ports)
Rich Laneb658ddd2013-03-12 10:15:10 -0700856 q.breakable()
857 q.text('}')
858
859class bsn_set_ip_mask(Message):
860 version = const.OFP_VERSION
861 type = const.OFPT_VENDOR
862 experimenter = 0x5c16c7
863 subtype = 0
864
Rich Lanec2ee4b82013-04-24 17:12:38 -0700865 def __init__(self, xid=None, index=None, mask=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700866 self.xid = xid
867 if index != None:
868 self.index = index
869 else:
870 self.index = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700871 if mask != None:
872 self.mask = mask
873 else:
874 self.mask = 0
875
876 def pack(self):
877 packed = []
878 packed.append(struct.pack("!B", self.version))
879 packed.append(struct.pack("!B", self.type))
880 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
881 packed.append(struct.pack("!L", self.xid))
882 packed.append(struct.pack("!L", self.experimenter))
883 packed.append(struct.pack("!L", self.subtype))
884 packed.append(struct.pack("!B", self.index))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700885 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700886 packed.append(struct.pack("!L", self.mask))
887 length = sum([len(x) for x in packed])
888 packed[2] = struct.pack("!H", length)
889 return ''.join(packed)
890
891 @staticmethod
892 def unpack(buf):
893 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
894 obj = bsn_set_ip_mask()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700895 if type(buf) == loxi.generic_util.OFReader:
896 reader = buf
897 else:
898 reader = loxi.generic_util.OFReader(buf)
899 _version = reader.read('!B')[0]
900 assert(_version == const.OFP_VERSION)
901 _type = reader.read('!B')[0]
902 assert(_type == const.OFPT_VENDOR)
903 _length = reader.read('!H')[0]
904 obj.xid = reader.read('!L')[0]
905 _experimenter = reader.read('!L')[0]
906 assert(_experimenter == 0x5c16c7)
907 _subtype = reader.read('!L')[0]
908 assert(_subtype == 0)
909 obj.index = reader.read('!B')[0]
910 reader.skip(3)
911 obj.mask = reader.read('!L')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700912 return obj
913
914 def __eq__(self, other):
915 if type(self) != type(other): return False
916 if self.version != other.version: return False
917 if self.type != other.type: return False
918 if self.xid != other.xid: return False
919 if self.index != other.index: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700920 if self.mask != other.mask: return False
921 return True
922
923 def __ne__(self, other):
924 return not self.__eq__(other)
925
926 def __str__(self):
927 return self.show()
928
929 def show(self):
930 import loxi.pp
931 return loxi.pp.pp(self)
932
933 def pretty_print(self, q):
934 q.text("bsn_set_ip_mask {")
935 with q.group():
936 with q.indent(2):
937 q.breakable()
938 q.text("xid = ");
939 if self.xid != None:
940 q.text("%#x" % self.xid)
941 else:
942 q.text('None')
943 q.text(","); q.breakable()
944 q.text("index = ");
945 q.text("%#x" % self.index)
946 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -0700947 q.text("mask = ");
948 q.text("%#x" % self.mask)
949 q.breakable()
950 q.text('}')
951
952class bsn_set_mirroring(Message):
953 version = const.OFP_VERSION
954 type = const.OFPT_VENDOR
955 experimenter = 0x5c16c7
956 subtype = 3
957
Rich Lanec2ee4b82013-04-24 17:12:38 -0700958 def __init__(self, xid=None, report_mirror_ports=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700959 self.xid = xid
960 if report_mirror_ports != None:
961 self.report_mirror_ports = report_mirror_ports
962 else:
963 self.report_mirror_ports = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700964
965 def pack(self):
966 packed = []
967 packed.append(struct.pack("!B", self.version))
968 packed.append(struct.pack("!B", self.type))
969 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
970 packed.append(struct.pack("!L", self.xid))
971 packed.append(struct.pack("!L", self.experimenter))
972 packed.append(struct.pack("!L", self.subtype))
973 packed.append(struct.pack("!B", self.report_mirror_ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700974 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700975 length = sum([len(x) for x in packed])
976 packed[2] = struct.pack("!H", length)
977 return ''.join(packed)
978
979 @staticmethod
980 def unpack(buf):
981 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
982 obj = bsn_set_mirroring()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700983 if type(buf) == loxi.generic_util.OFReader:
984 reader = buf
985 else:
986 reader = loxi.generic_util.OFReader(buf)
987 _version = reader.read('!B')[0]
988 assert(_version == const.OFP_VERSION)
989 _type = reader.read('!B')[0]
990 assert(_type == const.OFPT_VENDOR)
991 _length = reader.read('!H')[0]
992 obj.xid = reader.read('!L')[0]
993 _experimenter = reader.read('!L')[0]
994 assert(_experimenter == 0x5c16c7)
995 _subtype = reader.read('!L')[0]
996 assert(_subtype == 3)
997 obj.report_mirror_ports = reader.read('!B')[0]
998 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700999 return obj
1000
1001 def __eq__(self, other):
1002 if type(self) != type(other): return False
1003 if self.version != other.version: return False
1004 if self.type != other.type: return False
1005 if self.xid != other.xid: return False
1006 if self.report_mirror_ports != other.report_mirror_ports: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001007 return True
1008
1009 def __ne__(self, other):
1010 return not self.__eq__(other)
1011
1012 def __str__(self):
1013 return self.show()
1014
1015 def show(self):
1016 import loxi.pp
1017 return loxi.pp.pp(self)
1018
1019 def pretty_print(self, q):
1020 q.text("bsn_set_mirroring {")
1021 with q.group():
1022 with q.indent(2):
1023 q.breakable()
1024 q.text("xid = ");
1025 if self.xid != None:
1026 q.text("%#x" % self.xid)
1027 else:
1028 q.text('None')
1029 q.text(","); q.breakable()
1030 q.text("report_mirror_ports = ");
1031 q.text("%#x" % self.report_mirror_ports)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001032 q.breakable()
1033 q.text('}')
1034
1035class bsn_set_pktin_suppression(Message):
1036 version = const.OFP_VERSION
1037 type = const.OFPT_VENDOR
1038 experimenter = 0x5c16c7
1039 subtype = 11
1040
1041 def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None):
1042 self.xid = xid
1043 if enabled != None:
1044 self.enabled = enabled
1045 else:
1046 self.enabled = 0
1047 if idle_timeout != None:
1048 self.idle_timeout = idle_timeout
1049 else:
1050 self.idle_timeout = 0
1051 if hard_timeout != None:
1052 self.hard_timeout = hard_timeout
1053 else:
1054 self.hard_timeout = 0
1055 if priority != None:
1056 self.priority = priority
1057 else:
1058 self.priority = 0
1059 if cookie != None:
1060 self.cookie = cookie
1061 else:
1062 self.cookie = 0
1063
1064 def pack(self):
1065 packed = []
1066 packed.append(struct.pack("!B", self.version))
1067 packed.append(struct.pack("!B", self.type))
1068 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1069 packed.append(struct.pack("!L", self.xid))
1070 packed.append(struct.pack("!L", self.experimenter))
1071 packed.append(struct.pack("!L", self.subtype))
1072 packed.append(struct.pack("!B", self.enabled))
1073 packed.append('\x00' * 1)
1074 packed.append(struct.pack("!H", self.idle_timeout))
1075 packed.append(struct.pack("!H", self.hard_timeout))
1076 packed.append(struct.pack("!H", self.priority))
1077 packed.append(struct.pack("!Q", self.cookie))
1078 length = sum([len(x) for x in packed])
1079 packed[2] = struct.pack("!H", length)
1080 return ''.join(packed)
1081
1082 @staticmethod
1083 def unpack(buf):
1084 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1085 obj = bsn_set_pktin_suppression()
1086 if type(buf) == loxi.generic_util.OFReader:
1087 reader = buf
1088 else:
1089 reader = loxi.generic_util.OFReader(buf)
1090 _version = reader.read('!B')[0]
1091 assert(_version == const.OFP_VERSION)
1092 _type = reader.read('!B')[0]
1093 assert(_type == const.OFPT_VENDOR)
1094 _length = reader.read('!H')[0]
1095 obj.xid = reader.read('!L')[0]
1096 _experimenter = reader.read('!L')[0]
1097 assert(_experimenter == 0x5c16c7)
1098 _subtype = reader.read('!L')[0]
1099 assert(_subtype == 11)
1100 obj.enabled = reader.read('!B')[0]
1101 reader.skip(1)
1102 obj.idle_timeout = reader.read('!H')[0]
1103 obj.hard_timeout = reader.read('!H')[0]
1104 obj.priority = reader.read('!H')[0]
1105 obj.cookie = reader.read('!Q')[0]
1106 return obj
1107
1108 def __eq__(self, other):
1109 if type(self) != type(other): return False
1110 if self.version != other.version: return False
1111 if self.type != other.type: return False
1112 if self.xid != other.xid: return False
1113 if self.enabled != other.enabled: return False
1114 if self.idle_timeout != other.idle_timeout: return False
1115 if self.hard_timeout != other.hard_timeout: return False
1116 if self.priority != other.priority: return False
1117 if self.cookie != other.cookie: return False
1118 return True
1119
1120 def __ne__(self, other):
1121 return not self.__eq__(other)
1122
1123 def __str__(self):
1124 return self.show()
1125
1126 def show(self):
1127 import loxi.pp
1128 return loxi.pp.pp(self)
1129
1130 def pretty_print(self, q):
1131 q.text("bsn_set_pktin_suppression {")
1132 with q.group():
1133 with q.indent(2):
1134 q.breakable()
1135 q.text("xid = ");
1136 if self.xid != None:
1137 q.text("%#x" % self.xid)
1138 else:
1139 q.text('None')
Rich Laneb658ddd2013-03-12 10:15:10 -07001140 q.text(","); q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001141 q.text("enabled = ");
1142 q.text("%#x" % self.enabled)
1143 q.text(","); q.breakable()
1144 q.text("idle_timeout = ");
1145 q.text("%#x" % self.idle_timeout)
1146 q.text(","); q.breakable()
1147 q.text("hard_timeout = ");
1148 q.text("%#x" % self.hard_timeout)
1149 q.text(","); q.breakable()
1150 q.text("priority = ");
1151 q.text("%#x" % self.priority)
1152 q.text(","); q.breakable()
1153 q.text("cookie = ");
1154 q.text("%#x" % self.cookie)
Rich Laneb658ddd2013-03-12 10:15:10 -07001155 q.breakable()
1156 q.text('}')
1157
1158class bsn_shell_command(Message):
1159 version = const.OFP_VERSION
1160 type = const.OFPT_VENDOR
1161 experimenter = 0x5c16c7
1162 subtype = 6
1163
1164 def __init__(self, xid=None, service=None, data=None):
1165 self.xid = xid
1166 if service != None:
1167 self.service = service
1168 else:
1169 self.service = 0
1170 if data != None:
1171 self.data = data
1172 else:
1173 self.data = ""
1174
1175 def pack(self):
1176 packed = []
1177 packed.append(struct.pack("!B", self.version))
1178 packed.append(struct.pack("!B", self.type))
1179 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1180 packed.append(struct.pack("!L", self.xid))
1181 packed.append(struct.pack("!L", self.experimenter))
1182 packed.append(struct.pack("!L", self.subtype))
1183 packed.append(struct.pack("!L", self.service))
1184 packed.append(self.data)
1185 length = sum([len(x) for x in packed])
1186 packed[2] = struct.pack("!H", length)
1187 return ''.join(packed)
1188
1189 @staticmethod
1190 def unpack(buf):
1191 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1192 obj = bsn_shell_command()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001193 if type(buf) == loxi.generic_util.OFReader:
1194 reader = buf
1195 else:
1196 reader = loxi.generic_util.OFReader(buf)
1197 _version = reader.read('!B')[0]
1198 assert(_version == const.OFP_VERSION)
1199 _type = reader.read('!B')[0]
1200 assert(_type == const.OFPT_VENDOR)
1201 _length = reader.read('!H')[0]
1202 obj.xid = reader.read('!L')[0]
1203 _experimenter = reader.read('!L')[0]
1204 assert(_experimenter == 0x5c16c7)
1205 _subtype = reader.read('!L')[0]
1206 assert(_subtype == 6)
1207 obj.service = reader.read('!L')[0]
1208 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07001209 return obj
1210
1211 def __eq__(self, other):
1212 if type(self) != type(other): return False
1213 if self.version != other.version: return False
1214 if self.type != other.type: return False
1215 if self.xid != other.xid: return False
1216 if self.service != other.service: return False
1217 if self.data != other.data: return False
1218 return True
1219
1220 def __ne__(self, other):
1221 return not self.__eq__(other)
1222
1223 def __str__(self):
1224 return self.show()
1225
1226 def show(self):
1227 import loxi.pp
1228 return loxi.pp.pp(self)
1229
1230 def pretty_print(self, q):
1231 q.text("bsn_shell_command {")
1232 with q.group():
1233 with q.indent(2):
1234 q.breakable()
1235 q.text("xid = ");
1236 if self.xid != None:
1237 q.text("%#x" % self.xid)
1238 else:
1239 q.text('None')
1240 q.text(","); q.breakable()
1241 q.text("service = ");
1242 q.text("%#x" % self.service)
1243 q.text(","); q.breakable()
1244 q.text("data = ");
1245 q.pp(self.data)
1246 q.breakable()
1247 q.text('}')
1248
1249class bsn_shell_output(Message):
1250 version = const.OFP_VERSION
1251 type = const.OFPT_VENDOR
1252 experimenter = 0x5c16c7
1253 subtype = 7
1254
1255 def __init__(self, xid=None, data=None):
1256 self.xid = xid
1257 if data != None:
1258 self.data = data
1259 else:
1260 self.data = ""
1261
1262 def pack(self):
1263 packed = []
1264 packed.append(struct.pack("!B", self.version))
1265 packed.append(struct.pack("!B", self.type))
1266 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1267 packed.append(struct.pack("!L", self.xid))
1268 packed.append(struct.pack("!L", self.experimenter))
1269 packed.append(struct.pack("!L", self.subtype))
1270 packed.append(self.data)
1271 length = sum([len(x) for x in packed])
1272 packed[2] = struct.pack("!H", length)
1273 return ''.join(packed)
1274
1275 @staticmethod
1276 def unpack(buf):
1277 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1278 obj = bsn_shell_output()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001279 if type(buf) == loxi.generic_util.OFReader:
1280 reader = buf
1281 else:
1282 reader = loxi.generic_util.OFReader(buf)
1283 _version = reader.read('!B')[0]
1284 assert(_version == const.OFP_VERSION)
1285 _type = reader.read('!B')[0]
1286 assert(_type == const.OFPT_VENDOR)
1287 _length = reader.read('!H')[0]
1288 obj.xid = reader.read('!L')[0]
1289 _experimenter = reader.read('!L')[0]
1290 assert(_experimenter == 0x5c16c7)
1291 _subtype = reader.read('!L')[0]
1292 assert(_subtype == 7)
1293 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07001294 return obj
1295
1296 def __eq__(self, other):
1297 if type(self) != type(other): return False
1298 if self.version != other.version: return False
1299 if self.type != other.type: return False
1300 if self.xid != other.xid: return False
1301 if self.data != other.data: return False
1302 return True
1303
1304 def __ne__(self, other):
1305 return not self.__eq__(other)
1306
1307 def __str__(self):
1308 return self.show()
1309
1310 def show(self):
1311 import loxi.pp
1312 return loxi.pp.pp(self)
1313
1314 def pretty_print(self, q):
1315 q.text("bsn_shell_output {")
1316 with q.group():
1317 with q.indent(2):
1318 q.breakable()
1319 q.text("xid = ");
1320 if self.xid != None:
1321 q.text("%#x" % self.xid)
1322 else:
1323 q.text('None')
1324 q.text(","); q.breakable()
1325 q.text("data = ");
1326 q.pp(self.data)
1327 q.breakable()
1328 q.text('}')
1329
1330class bsn_shell_status(Message):
1331 version = const.OFP_VERSION
1332 type = const.OFPT_VENDOR
1333 experimenter = 0x5c16c7
1334 subtype = 8
1335
1336 def __init__(self, xid=None, status=None):
1337 self.xid = xid
1338 if status != None:
1339 self.status = status
1340 else:
1341 self.status = 0
1342
1343 def pack(self):
1344 packed = []
1345 packed.append(struct.pack("!B", self.version))
1346 packed.append(struct.pack("!B", self.type))
1347 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1348 packed.append(struct.pack("!L", self.xid))
1349 packed.append(struct.pack("!L", self.experimenter))
1350 packed.append(struct.pack("!L", self.subtype))
1351 packed.append(struct.pack("!L", self.status))
1352 length = sum([len(x) for x in packed])
1353 packed[2] = struct.pack("!H", length)
1354 return ''.join(packed)
1355
1356 @staticmethod
1357 def unpack(buf):
1358 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1359 obj = bsn_shell_status()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001360 if type(buf) == loxi.generic_util.OFReader:
1361 reader = buf
1362 else:
1363 reader = loxi.generic_util.OFReader(buf)
1364 _version = reader.read('!B')[0]
1365 assert(_version == const.OFP_VERSION)
1366 _type = reader.read('!B')[0]
1367 assert(_type == const.OFPT_VENDOR)
1368 _length = reader.read('!H')[0]
1369 obj.xid = reader.read('!L')[0]
1370 _experimenter = reader.read('!L')[0]
1371 assert(_experimenter == 0x5c16c7)
1372 _subtype = reader.read('!L')[0]
1373 assert(_subtype == 8)
1374 obj.status = reader.read('!L')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07001375 return obj
1376
1377 def __eq__(self, other):
1378 if type(self) != type(other): return False
1379 if self.version != other.version: return False
1380 if self.type != other.type: return False
1381 if self.xid != other.xid: return False
1382 if self.status != other.status: return False
1383 return True
1384
1385 def __ne__(self, other):
1386 return not self.__eq__(other)
1387
1388 def __str__(self):
1389 return self.show()
1390
1391 def show(self):
1392 import loxi.pp
1393 return loxi.pp.pp(self)
1394
1395 def pretty_print(self, q):
1396 q.text("bsn_shell_status {")
1397 with q.group():
1398 with q.indent(2):
1399 q.breakable()
1400 q.text("xid = ");
1401 if self.xid != None:
1402 q.text("%#x" % self.xid)
1403 else:
1404 q.text('None')
1405 q.text(","); q.breakable()
1406 q.text("status = ");
1407 q.text("%#x" % self.status)
1408 q.breakable()
1409 q.text('}')
1410
1411class desc_stats_reply(Message):
1412 version = const.OFP_VERSION
1413 type = const.OFPT_STATS_REPLY
1414 stats_type = const.OFPST_DESC
1415
1416 def __init__(self, xid=None, flags=None, mfr_desc=None, hw_desc=None, sw_desc=None, serial_num=None, dp_desc=None):
1417 self.xid = xid
1418 if flags != None:
1419 self.flags = flags
1420 else:
1421 self.flags = 0
1422 if mfr_desc != None:
1423 self.mfr_desc = mfr_desc
1424 else:
1425 self.mfr_desc = ""
1426 if hw_desc != None:
1427 self.hw_desc = hw_desc
1428 else:
1429 self.hw_desc = ""
1430 if sw_desc != None:
1431 self.sw_desc = sw_desc
1432 else:
1433 self.sw_desc = ""
1434 if serial_num != None:
1435 self.serial_num = serial_num
1436 else:
1437 self.serial_num = ""
1438 if dp_desc != None:
1439 self.dp_desc = dp_desc
1440 else:
1441 self.dp_desc = ""
1442
1443 def pack(self):
1444 packed = []
1445 packed.append(struct.pack("!B", self.version))
1446 packed.append(struct.pack("!B", self.type))
1447 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1448 packed.append(struct.pack("!L", self.xid))
1449 packed.append(struct.pack("!H", self.stats_type))
1450 packed.append(struct.pack("!H", self.flags))
1451 packed.append(struct.pack("!256s", self.mfr_desc))
1452 packed.append(struct.pack("!256s", self.hw_desc))
1453 packed.append(struct.pack("!256s", self.sw_desc))
1454 packed.append(struct.pack("!32s", self.serial_num))
1455 packed.append(struct.pack("!256s", self.dp_desc))
1456 length = sum([len(x) for x in packed])
1457 packed[2] = struct.pack("!H", length)
1458 return ''.join(packed)
1459
1460 @staticmethod
1461 def unpack(buf):
1462 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1463 obj = desc_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001464 if type(buf) == loxi.generic_util.OFReader:
1465 reader = buf
1466 else:
1467 reader = loxi.generic_util.OFReader(buf)
1468 _version = reader.read('!B')[0]
1469 assert(_version == const.OFP_VERSION)
1470 _type = reader.read('!B')[0]
1471 assert(_type == const.OFPT_STATS_REPLY)
1472 _length = reader.read('!H')[0]
1473 obj.xid = reader.read('!L')[0]
1474 _stats_type = reader.read('!H')[0]
1475 assert(_stats_type == const.OFPST_DESC)
1476 obj.flags = reader.read('!H')[0]
1477 obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00")
1478 obj.hw_desc = reader.read("!256s")[0].rstrip("\x00")
1479 obj.sw_desc = reader.read("!256s")[0].rstrip("\x00")
1480 obj.serial_num = reader.read("!32s")[0].rstrip("\x00")
1481 obj.dp_desc = reader.read("!256s")[0].rstrip("\x00")
Rich Laneb658ddd2013-03-12 10:15:10 -07001482 return obj
1483
1484 def __eq__(self, other):
1485 if type(self) != type(other): return False
1486 if self.version != other.version: return False
1487 if self.type != other.type: return False
1488 if self.xid != other.xid: return False
1489 if self.flags != other.flags: return False
1490 if self.mfr_desc != other.mfr_desc: return False
1491 if self.hw_desc != other.hw_desc: return False
1492 if self.sw_desc != other.sw_desc: return False
1493 if self.serial_num != other.serial_num: return False
1494 if self.dp_desc != other.dp_desc: return False
1495 return True
1496
1497 def __ne__(self, other):
1498 return not self.__eq__(other)
1499
1500 def __str__(self):
1501 return self.show()
1502
1503 def show(self):
1504 import loxi.pp
1505 return loxi.pp.pp(self)
1506
1507 def pretty_print(self, q):
1508 q.text("desc_stats_reply {")
1509 with q.group():
1510 with q.indent(2):
1511 q.breakable()
1512 q.text("xid = ");
1513 if self.xid != None:
1514 q.text("%#x" % self.xid)
1515 else:
1516 q.text('None')
1517 q.text(","); q.breakable()
1518 q.text("flags = ");
1519 q.text("%#x" % self.flags)
1520 q.text(","); q.breakable()
1521 q.text("mfr_desc = ");
1522 q.pp(self.mfr_desc)
1523 q.text(","); q.breakable()
1524 q.text("hw_desc = ");
1525 q.pp(self.hw_desc)
1526 q.text(","); q.breakable()
1527 q.text("sw_desc = ");
1528 q.pp(self.sw_desc)
1529 q.text(","); q.breakable()
1530 q.text("serial_num = ");
1531 q.pp(self.serial_num)
1532 q.text(","); q.breakable()
1533 q.text("dp_desc = ");
1534 q.pp(self.dp_desc)
1535 q.breakable()
1536 q.text('}')
1537
1538class desc_stats_request(Message):
1539 version = const.OFP_VERSION
1540 type = const.OFPT_STATS_REQUEST
1541 stats_type = const.OFPST_DESC
1542
1543 def __init__(self, xid=None, flags=None):
1544 self.xid = xid
1545 if flags != None:
1546 self.flags = flags
1547 else:
1548 self.flags = 0
1549
1550 def pack(self):
1551 packed = []
1552 packed.append(struct.pack("!B", self.version))
1553 packed.append(struct.pack("!B", self.type))
1554 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1555 packed.append(struct.pack("!L", self.xid))
1556 packed.append(struct.pack("!H", self.stats_type))
1557 packed.append(struct.pack("!H", self.flags))
1558 length = sum([len(x) for x in packed])
1559 packed[2] = struct.pack("!H", length)
1560 return ''.join(packed)
1561
1562 @staticmethod
1563 def unpack(buf):
1564 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1565 obj = desc_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001566 if type(buf) == loxi.generic_util.OFReader:
1567 reader = buf
1568 else:
1569 reader = loxi.generic_util.OFReader(buf)
1570 _version = reader.read('!B')[0]
1571 assert(_version == const.OFP_VERSION)
1572 _type = reader.read('!B')[0]
1573 assert(_type == const.OFPT_STATS_REQUEST)
1574 _length = reader.read('!H')[0]
1575 obj.xid = reader.read('!L')[0]
1576 _stats_type = reader.read('!H')[0]
1577 assert(_stats_type == const.OFPST_DESC)
1578 obj.flags = reader.read('!H')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07001579 return obj
1580
1581 def __eq__(self, other):
1582 if type(self) != type(other): return False
1583 if self.version != other.version: return False
1584 if self.type != other.type: return False
1585 if self.xid != other.xid: return False
1586 if self.flags != other.flags: return False
1587 return True
1588
1589 def __ne__(self, other):
1590 return not self.__eq__(other)
1591
1592 def __str__(self):
1593 return self.show()
1594
1595 def show(self):
1596 import loxi.pp
1597 return loxi.pp.pp(self)
1598
1599 def pretty_print(self, q):
1600 q.text("desc_stats_request {")
1601 with q.group():
1602 with q.indent(2):
1603 q.breakable()
1604 q.text("xid = ");
1605 if self.xid != None:
1606 q.text("%#x" % self.xid)
1607 else:
1608 q.text('None')
1609 q.text(","); q.breakable()
1610 q.text("flags = ");
1611 q.text("%#x" % self.flags)
1612 q.breakable()
1613 q.text('}')
1614
1615class echo_reply(Message):
1616 version = const.OFP_VERSION
1617 type = const.OFPT_ECHO_REPLY
1618
1619 def __init__(self, xid=None, data=None):
1620 self.xid = xid
1621 if data != None:
1622 self.data = data
1623 else:
1624 self.data = ""
1625
1626 def pack(self):
1627 packed = []
1628 packed.append(struct.pack("!B", self.version))
1629 packed.append(struct.pack("!B", self.type))
1630 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1631 packed.append(struct.pack("!L", self.xid))
1632 packed.append(self.data)
1633 length = sum([len(x) for x in packed])
1634 packed[2] = struct.pack("!H", length)
1635 return ''.join(packed)
1636
1637 @staticmethod
1638 def unpack(buf):
1639 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1640 obj = echo_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001641 if type(buf) == loxi.generic_util.OFReader:
1642 reader = buf
1643 else:
1644 reader = loxi.generic_util.OFReader(buf)
1645 _version = reader.read('!B')[0]
1646 assert(_version == const.OFP_VERSION)
1647 _type = reader.read('!B')[0]
1648 assert(_type == const.OFPT_ECHO_REPLY)
1649 _length = reader.read('!H')[0]
1650 obj.xid = reader.read('!L')[0]
1651 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07001652 return obj
1653
1654 def __eq__(self, other):
1655 if type(self) != type(other): return False
1656 if self.version != other.version: return False
1657 if self.type != other.type: return False
1658 if self.xid != other.xid: return False
1659 if self.data != other.data: return False
1660 return True
1661
1662 def __ne__(self, other):
1663 return not self.__eq__(other)
1664
1665 def __str__(self):
1666 return self.show()
1667
1668 def show(self):
1669 import loxi.pp
1670 return loxi.pp.pp(self)
1671
1672 def pretty_print(self, q):
1673 q.text("echo_reply {")
1674 with q.group():
1675 with q.indent(2):
1676 q.breakable()
1677 q.text("xid = ");
1678 if self.xid != None:
1679 q.text("%#x" % self.xid)
1680 else:
1681 q.text('None')
1682 q.text(","); q.breakable()
1683 q.text("data = ");
1684 q.pp(self.data)
1685 q.breakable()
1686 q.text('}')
1687
1688class echo_request(Message):
1689 version = const.OFP_VERSION
1690 type = const.OFPT_ECHO_REQUEST
1691
1692 def __init__(self, xid=None, data=None):
1693 self.xid = xid
1694 if data != None:
1695 self.data = data
1696 else:
1697 self.data = ""
1698
1699 def pack(self):
1700 packed = []
1701 packed.append(struct.pack("!B", self.version))
1702 packed.append(struct.pack("!B", self.type))
1703 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1704 packed.append(struct.pack("!L", self.xid))
1705 packed.append(self.data)
1706 length = sum([len(x) for x in packed])
1707 packed[2] = struct.pack("!H", length)
1708 return ''.join(packed)
1709
1710 @staticmethod
1711 def unpack(buf):
1712 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1713 obj = echo_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001714 if type(buf) == loxi.generic_util.OFReader:
1715 reader = buf
1716 else:
1717 reader = loxi.generic_util.OFReader(buf)
1718 _version = reader.read('!B')[0]
1719 assert(_version == const.OFP_VERSION)
1720 _type = reader.read('!B')[0]
1721 assert(_type == const.OFPT_ECHO_REQUEST)
1722 _length = reader.read('!H')[0]
1723 obj.xid = reader.read('!L')[0]
1724 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07001725 return obj
1726
1727 def __eq__(self, other):
1728 if type(self) != type(other): return False
1729 if self.version != other.version: return False
1730 if self.type != other.type: return False
1731 if self.xid != other.xid: return False
1732 if self.data != other.data: return False
1733 return True
1734
1735 def __ne__(self, other):
1736 return not self.__eq__(other)
1737
1738 def __str__(self):
1739 return self.show()
1740
1741 def show(self):
1742 import loxi.pp
1743 return loxi.pp.pp(self)
1744
1745 def pretty_print(self, q):
1746 q.text("echo_request {")
1747 with q.group():
1748 with q.indent(2):
1749 q.breakable()
1750 q.text("xid = ");
1751 if self.xid != None:
1752 q.text("%#x" % self.xid)
1753 else:
1754 q.text('None')
1755 q.text(","); q.breakable()
1756 q.text("data = ");
1757 q.pp(self.data)
1758 q.breakable()
1759 q.text('}')
1760
1761class error_msg(Message):
1762 version = const.OFP_VERSION
1763 type = const.OFPT_ERROR
1764
1765 def __init__(self, xid=None, err_type=None, code=None, data=None):
1766 self.xid = xid
1767 if err_type != None:
1768 self.err_type = err_type
1769 else:
1770 self.err_type = 0
1771 if code != None:
1772 self.code = code
1773 else:
1774 self.code = 0
1775 if data != None:
1776 self.data = data
1777 else:
1778 self.data = ""
1779
1780 def pack(self):
1781 packed = []
1782 packed.append(struct.pack("!B", self.version))
1783 packed.append(struct.pack("!B", self.type))
1784 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1785 packed.append(struct.pack("!L", self.xid))
1786 packed.append(struct.pack("!H", self.err_type))
1787 packed.append(struct.pack("!H", self.code))
1788 packed.append(self.data)
1789 length = sum([len(x) for x in packed])
1790 packed[2] = struct.pack("!H", length)
1791 return ''.join(packed)
1792
1793 @staticmethod
1794 def unpack(buf):
1795 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1796 obj = error_msg()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001797 if type(buf) == loxi.generic_util.OFReader:
1798 reader = buf
1799 else:
1800 reader = loxi.generic_util.OFReader(buf)
1801 _version = reader.read('!B')[0]
1802 assert(_version == const.OFP_VERSION)
1803 _type = reader.read('!B')[0]
1804 assert(_type == const.OFPT_ERROR)
1805 _length = reader.read('!H')[0]
1806 obj.xid = reader.read('!L')[0]
1807 obj.err_type = reader.read('!H')[0]
1808 obj.code = reader.read('!H')[0]
1809 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07001810 return obj
1811
1812 def __eq__(self, other):
1813 if type(self) != type(other): return False
1814 if self.version != other.version: return False
1815 if self.type != other.type: return False
1816 if self.xid != other.xid: return False
1817 if self.err_type != other.err_type: return False
1818 if self.code != other.code: return False
1819 if self.data != other.data: return False
1820 return True
1821
1822 def __ne__(self, other):
1823 return not self.__eq__(other)
1824
1825 def __str__(self):
1826 return self.show()
1827
1828 def show(self):
1829 import loxi.pp
1830 return loxi.pp.pp(self)
1831
1832 def pretty_print(self, q):
1833 q.text("error_msg {")
1834 with q.group():
1835 with q.indent(2):
1836 q.breakable()
1837 q.text("xid = ");
1838 if self.xid != None:
1839 q.text("%#x" % self.xid)
1840 else:
1841 q.text('None')
1842 q.text(","); q.breakable()
1843 q.text("err_type = ");
1844 q.text("%#x" % self.err_type)
1845 q.text(","); q.breakable()
1846 q.text("code = ");
1847 q.text("%#x" % self.code)
1848 q.text(","); q.breakable()
1849 q.text("data = ");
1850 q.pp(self.data)
1851 q.breakable()
1852 q.text('}')
1853
1854class experimenter_stats_reply(Message):
1855 version = const.OFP_VERSION
1856 type = const.OFPT_STATS_REPLY
1857 stats_type = const.OFPST_VENDOR
1858
1859 def __init__(self, xid=None, flags=None, experimenter=None, data=None):
1860 self.xid = xid
1861 if flags != None:
1862 self.flags = flags
1863 else:
1864 self.flags = 0
1865 if experimenter != None:
1866 self.experimenter = experimenter
1867 else:
1868 self.experimenter = 0
1869 if data != None:
1870 self.data = data
1871 else:
1872 self.data = ""
1873
1874 def pack(self):
1875 packed = []
1876 packed.append(struct.pack("!B", self.version))
1877 packed.append(struct.pack("!B", self.type))
1878 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1879 packed.append(struct.pack("!L", self.xid))
1880 packed.append(struct.pack("!H", self.stats_type))
1881 packed.append(struct.pack("!H", self.flags))
1882 packed.append(struct.pack("!L", self.experimenter))
1883 packed.append(self.data)
1884 length = sum([len(x) for x in packed])
1885 packed[2] = struct.pack("!H", length)
1886 return ''.join(packed)
1887
1888 @staticmethod
1889 def unpack(buf):
1890 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1891 obj = experimenter_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001892 if type(buf) == loxi.generic_util.OFReader:
1893 reader = buf
1894 else:
1895 reader = loxi.generic_util.OFReader(buf)
1896 _version = reader.read('!B')[0]
1897 assert(_version == const.OFP_VERSION)
1898 _type = reader.read('!B')[0]
1899 assert(_type == const.OFPT_STATS_REPLY)
1900 _length = reader.read('!H')[0]
1901 obj.xid = reader.read('!L')[0]
1902 _stats_type = reader.read('!H')[0]
1903 assert(_stats_type == const.OFPST_VENDOR)
1904 obj.flags = reader.read('!H')[0]
1905 obj.experimenter = reader.read('!L')[0]
1906 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07001907 return obj
1908
1909 def __eq__(self, other):
1910 if type(self) != type(other): return False
1911 if self.version != other.version: return False
1912 if self.type != other.type: return False
1913 if self.xid != other.xid: return False
1914 if self.flags != other.flags: return False
1915 if self.experimenter != other.experimenter: return False
1916 if self.data != other.data: return False
1917 return True
1918
1919 def __ne__(self, other):
1920 return not self.__eq__(other)
1921
1922 def __str__(self):
1923 return self.show()
1924
1925 def show(self):
1926 import loxi.pp
1927 return loxi.pp.pp(self)
1928
1929 def pretty_print(self, q):
1930 q.text("experimenter_stats_reply {")
1931 with q.group():
1932 with q.indent(2):
1933 q.breakable()
1934 q.text("xid = ");
1935 if self.xid != None:
1936 q.text("%#x" % self.xid)
1937 else:
1938 q.text('None')
1939 q.text(","); q.breakable()
1940 q.text("flags = ");
1941 q.text("%#x" % self.flags)
1942 q.text(","); q.breakable()
1943 q.text("experimenter = ");
1944 q.text("%#x" % self.experimenter)
1945 q.text(","); q.breakable()
1946 q.text("data = ");
1947 q.pp(self.data)
1948 q.breakable()
1949 q.text('}')
1950
1951class experimenter_stats_request(Message):
1952 version = const.OFP_VERSION
1953 type = const.OFPT_STATS_REQUEST
1954 stats_type = const.OFPST_VENDOR
1955
1956 def __init__(self, xid=None, flags=None, experimenter=None, data=None):
1957 self.xid = xid
1958 if flags != None:
1959 self.flags = flags
1960 else:
1961 self.flags = 0
1962 if experimenter != None:
1963 self.experimenter = experimenter
1964 else:
1965 self.experimenter = 0
1966 if data != None:
1967 self.data = data
1968 else:
1969 self.data = ""
1970
1971 def pack(self):
1972 packed = []
1973 packed.append(struct.pack("!B", self.version))
1974 packed.append(struct.pack("!B", self.type))
1975 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1976 packed.append(struct.pack("!L", self.xid))
1977 packed.append(struct.pack("!H", self.stats_type))
1978 packed.append(struct.pack("!H", self.flags))
1979 packed.append(struct.pack("!L", self.experimenter))
1980 packed.append(self.data)
1981 length = sum([len(x) for x in packed])
1982 packed[2] = struct.pack("!H", length)
1983 return ''.join(packed)
1984
1985 @staticmethod
1986 def unpack(buf):
1987 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
1988 obj = experimenter_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001989 if type(buf) == loxi.generic_util.OFReader:
1990 reader = buf
1991 else:
1992 reader = loxi.generic_util.OFReader(buf)
1993 _version = reader.read('!B')[0]
1994 assert(_version == const.OFP_VERSION)
1995 _type = reader.read('!B')[0]
1996 assert(_type == const.OFPT_STATS_REQUEST)
1997 _length = reader.read('!H')[0]
1998 obj.xid = reader.read('!L')[0]
1999 _stats_type = reader.read('!H')[0]
2000 assert(_stats_type == const.OFPST_VENDOR)
2001 obj.flags = reader.read('!H')[0]
2002 obj.experimenter = reader.read('!L')[0]
2003 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07002004 return obj
2005
2006 def __eq__(self, other):
2007 if type(self) != type(other): return False
2008 if self.version != other.version: return False
2009 if self.type != other.type: return False
2010 if self.xid != other.xid: return False
2011 if self.flags != other.flags: return False
2012 if self.experimenter != other.experimenter: return False
2013 if self.data != other.data: return False
2014 return True
2015
2016 def __ne__(self, other):
2017 return not self.__eq__(other)
2018
2019 def __str__(self):
2020 return self.show()
2021
2022 def show(self):
2023 import loxi.pp
2024 return loxi.pp.pp(self)
2025
2026 def pretty_print(self, q):
2027 q.text("experimenter_stats_request {")
2028 with q.group():
2029 with q.indent(2):
2030 q.breakable()
2031 q.text("xid = ");
2032 if self.xid != None:
2033 q.text("%#x" % self.xid)
2034 else:
2035 q.text('None')
2036 q.text(","); q.breakable()
2037 q.text("flags = ");
2038 q.text("%#x" % self.flags)
2039 q.text(","); q.breakable()
2040 q.text("experimenter = ");
2041 q.text("%#x" % self.experimenter)
2042 q.text(","); q.breakable()
2043 q.text("data = ");
2044 q.pp(self.data)
2045 q.breakable()
2046 q.text('}')
2047
2048class features_reply(Message):
2049 version = const.OFP_VERSION
2050 type = const.OFPT_FEATURES_REPLY
2051
Rich Lanec2ee4b82013-04-24 17:12:38 -07002052 def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, capabilities=None, actions=None, ports=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07002053 self.xid = xid
2054 if datapath_id != None:
2055 self.datapath_id = datapath_id
2056 else:
2057 self.datapath_id = 0
2058 if n_buffers != None:
2059 self.n_buffers = n_buffers
2060 else:
2061 self.n_buffers = 0
2062 if n_tables != None:
2063 self.n_tables = n_tables
2064 else:
2065 self.n_tables = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07002066 if capabilities != None:
2067 self.capabilities = capabilities
2068 else:
2069 self.capabilities = 0
2070 if actions != None:
2071 self.actions = actions
2072 else:
2073 self.actions = 0
2074 if ports != None:
2075 self.ports = ports
2076 else:
2077 self.ports = []
2078
2079 def pack(self):
2080 packed = []
2081 packed.append(struct.pack("!B", self.version))
2082 packed.append(struct.pack("!B", self.type))
2083 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2084 packed.append(struct.pack("!L", self.xid))
2085 packed.append(struct.pack("!Q", self.datapath_id))
2086 packed.append(struct.pack("!L", self.n_buffers))
2087 packed.append(struct.pack("!B", self.n_tables))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002088 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07002089 packed.append(struct.pack("!L", self.capabilities))
2090 packed.append(struct.pack("!L", self.actions))
2091 packed.append("".join([x.pack() for x in self.ports]))
2092 length = sum([len(x) for x in packed])
2093 packed[2] = struct.pack("!H", length)
2094 return ''.join(packed)
2095
2096 @staticmethod
2097 def unpack(buf):
2098 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2099 obj = features_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002100 if type(buf) == loxi.generic_util.OFReader:
2101 reader = buf
2102 else:
2103 reader = loxi.generic_util.OFReader(buf)
2104 _version = reader.read('!B')[0]
2105 assert(_version == const.OFP_VERSION)
2106 _type = reader.read('!B')[0]
2107 assert(_type == const.OFPT_FEATURES_REPLY)
2108 _length = reader.read('!H')[0]
2109 obj.xid = reader.read('!L')[0]
2110 obj.datapath_id = reader.read('!Q')[0]
2111 obj.n_buffers = reader.read('!L')[0]
2112 obj.n_tables = reader.read('!B')[0]
2113 reader.skip(3)
2114 obj.capabilities = reader.read('!L')[0]
2115 obj.actions = reader.read('!L')[0]
2116 obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack)
Rich Laneb658ddd2013-03-12 10:15:10 -07002117 return obj
2118
2119 def __eq__(self, other):
2120 if type(self) != type(other): return False
2121 if self.version != other.version: return False
2122 if self.type != other.type: return False
2123 if self.xid != other.xid: return False
2124 if self.datapath_id != other.datapath_id: return False
2125 if self.n_buffers != other.n_buffers: return False
2126 if self.n_tables != other.n_tables: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07002127 if self.capabilities != other.capabilities: return False
2128 if self.actions != other.actions: return False
2129 if self.ports != other.ports: return False
2130 return True
2131
2132 def __ne__(self, other):
2133 return not self.__eq__(other)
2134
2135 def __str__(self):
2136 return self.show()
2137
2138 def show(self):
2139 import loxi.pp
2140 return loxi.pp.pp(self)
2141
2142 def pretty_print(self, q):
2143 q.text("features_reply {")
2144 with q.group():
2145 with q.indent(2):
2146 q.breakable()
2147 q.text("xid = ");
2148 if self.xid != None:
2149 q.text("%#x" % self.xid)
2150 else:
2151 q.text('None')
2152 q.text(","); q.breakable()
2153 q.text("datapath_id = ");
2154 q.text("%#x" % self.datapath_id)
2155 q.text(","); q.breakable()
2156 q.text("n_buffers = ");
2157 q.text("%#x" % self.n_buffers)
2158 q.text(","); q.breakable()
2159 q.text("n_tables = ");
2160 q.text("%#x" % self.n_tables)
2161 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07002162 q.text("capabilities = ");
2163 q.text("%#x" % self.capabilities)
2164 q.text(","); q.breakable()
2165 q.text("actions = ");
2166 q.text("%#x" % self.actions)
2167 q.text(","); q.breakable()
2168 q.text("ports = ");
2169 q.pp(self.ports)
2170 q.breakable()
2171 q.text('}')
2172
2173class features_request(Message):
2174 version = const.OFP_VERSION
2175 type = const.OFPT_FEATURES_REQUEST
2176
2177 def __init__(self, xid=None):
2178 self.xid = xid
2179
2180 def pack(self):
2181 packed = []
2182 packed.append(struct.pack("!B", self.version))
2183 packed.append(struct.pack("!B", self.type))
2184 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2185 packed.append(struct.pack("!L", self.xid))
2186 length = sum([len(x) for x in packed])
2187 packed[2] = struct.pack("!H", length)
2188 return ''.join(packed)
2189
2190 @staticmethod
2191 def unpack(buf):
2192 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2193 obj = features_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002194 if type(buf) == loxi.generic_util.OFReader:
2195 reader = buf
2196 else:
2197 reader = loxi.generic_util.OFReader(buf)
2198 _version = reader.read('!B')[0]
2199 assert(_version == const.OFP_VERSION)
2200 _type = reader.read('!B')[0]
2201 assert(_type == const.OFPT_FEATURES_REQUEST)
2202 _length = reader.read('!H')[0]
2203 obj.xid = reader.read('!L')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07002204 return obj
2205
2206 def __eq__(self, other):
2207 if type(self) != type(other): return False
2208 if self.version != other.version: return False
2209 if self.type != other.type: return False
2210 if self.xid != other.xid: return False
2211 return True
2212
2213 def __ne__(self, other):
2214 return not self.__eq__(other)
2215
2216 def __str__(self):
2217 return self.show()
2218
2219 def show(self):
2220 import loxi.pp
2221 return loxi.pp.pp(self)
2222
2223 def pretty_print(self, q):
2224 q.text("features_request {")
2225 with q.group():
2226 with q.indent(2):
2227 q.breakable()
2228 q.text("xid = ");
2229 if self.xid != None:
2230 q.text("%#x" % self.xid)
2231 else:
2232 q.text('None')
2233 q.breakable()
2234 q.text('}')
2235
2236class flow_add(Message):
2237 version = const.OFP_VERSION
2238 type = const.OFPT_FLOW_MOD
2239 _command = const.OFPFC_ADD
2240
2241 def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
2242 self.xid = xid
2243 if match != None:
2244 self.match = match
2245 else:
2246 self.match = common.match()
2247 if cookie != None:
2248 self.cookie = cookie
2249 else:
2250 self.cookie = 0
2251 if idle_timeout != None:
2252 self.idle_timeout = idle_timeout
2253 else:
2254 self.idle_timeout = 0
2255 if hard_timeout != None:
2256 self.hard_timeout = hard_timeout
2257 else:
2258 self.hard_timeout = 0
2259 if priority != None:
2260 self.priority = priority
2261 else:
2262 self.priority = 0
2263 if buffer_id != None:
2264 self.buffer_id = buffer_id
2265 else:
2266 self.buffer_id = 0
2267 if out_port != None:
2268 self.out_port = out_port
2269 else:
2270 self.out_port = 0
2271 if flags != None:
2272 self.flags = flags
2273 else:
2274 self.flags = 0
2275 if actions != None:
2276 self.actions = actions
2277 else:
2278 self.actions = []
2279
2280 def pack(self):
2281 packed = []
2282 packed.append(struct.pack("!B", self.version))
2283 packed.append(struct.pack("!B", self.type))
2284 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2285 packed.append(struct.pack("!L", self.xid))
2286 packed.append(self.match.pack())
2287 packed.append(struct.pack("!Q", self.cookie))
2288 packed.append(struct.pack("!H", self._command))
2289 packed.append(struct.pack("!H", self.idle_timeout))
2290 packed.append(struct.pack("!H", self.hard_timeout))
2291 packed.append(struct.pack("!H", self.priority))
2292 packed.append(struct.pack("!L", self.buffer_id))
2293 packed.append(struct.pack("!H", self.out_port))
2294 packed.append(struct.pack("!H", self.flags))
2295 packed.append("".join([x.pack() for x in self.actions]))
2296 length = sum([len(x) for x in packed])
2297 packed[2] = struct.pack("!H", length)
2298 return ''.join(packed)
2299
2300 @staticmethod
2301 def unpack(buf):
2302 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2303 obj = flow_add()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002304 if type(buf) == loxi.generic_util.OFReader:
2305 reader = buf
2306 else:
2307 reader = loxi.generic_util.OFReader(buf)
2308 _version = reader.read('!B')[0]
2309 assert(_version == const.OFP_VERSION)
2310 _type = reader.read('!B')[0]
2311 assert(_type == const.OFPT_FLOW_MOD)
2312 _length = reader.read('!H')[0]
2313 obj.xid = reader.read('!L')[0]
2314 obj.match = common.match.unpack(reader)
2315 obj.cookie = reader.read('!Q')[0]
2316 __command = reader.read('!H')[0]
2317 assert(__command == const.OFPFC_ADD)
2318 obj.idle_timeout = reader.read('!H')[0]
2319 obj.hard_timeout = reader.read('!H')[0]
2320 obj.priority = reader.read('!H')[0]
2321 obj.buffer_id = reader.read('!L')[0]
2322 obj.out_port = reader.read('!H')[0]
2323 obj.flags = reader.read('!H')[0]
2324 obj.actions = action.unpack_list(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07002325 return obj
2326
2327 def __eq__(self, other):
2328 if type(self) != type(other): return False
2329 if self.version != other.version: return False
2330 if self.type != other.type: return False
2331 if self.xid != other.xid: return False
2332 if self.match != other.match: return False
2333 if self.cookie != other.cookie: return False
2334 if self.idle_timeout != other.idle_timeout: return False
2335 if self.hard_timeout != other.hard_timeout: return False
2336 if self.priority != other.priority: return False
2337 if self.buffer_id != other.buffer_id: return False
2338 if self.out_port != other.out_port: return False
2339 if self.flags != other.flags: return False
2340 if self.actions != other.actions: return False
2341 return True
2342
2343 def __ne__(self, other):
2344 return not self.__eq__(other)
2345
2346 def __str__(self):
2347 return self.show()
2348
2349 def show(self):
2350 import loxi.pp
2351 return loxi.pp.pp(self)
2352
2353 def pretty_print(self, q):
2354 q.text("flow_add {")
2355 with q.group():
2356 with q.indent(2):
2357 q.breakable()
2358 q.text("xid = ");
2359 if self.xid != None:
2360 q.text("%#x" % self.xid)
2361 else:
2362 q.text('None')
2363 q.text(","); q.breakable()
2364 q.text("match = ");
2365 q.pp(self.match)
2366 q.text(","); q.breakable()
2367 q.text("cookie = ");
2368 q.text("%#x" % self.cookie)
2369 q.text(","); q.breakable()
2370 q.text("idle_timeout = ");
2371 q.text("%#x" % self.idle_timeout)
2372 q.text(","); q.breakable()
2373 q.text("hard_timeout = ");
2374 q.text("%#x" % self.hard_timeout)
2375 q.text(","); q.breakable()
2376 q.text("priority = ");
2377 q.text("%#x" % self.priority)
2378 q.text(","); q.breakable()
2379 q.text("buffer_id = ");
2380 q.text("%#x" % self.buffer_id)
2381 q.text(","); q.breakable()
2382 q.text("out_port = ");
2383 q.text(util.pretty_port(self.out_port))
2384 q.text(","); q.breakable()
2385 q.text("flags = ");
2386 q.text("%#x" % self.flags)
2387 q.text(","); q.breakable()
2388 q.text("actions = ");
2389 q.pp(self.actions)
2390 q.breakable()
2391 q.text('}')
2392
2393class flow_delete(Message):
2394 version = const.OFP_VERSION
2395 type = const.OFPT_FLOW_MOD
2396 _command = const.OFPFC_DELETE
2397
2398 def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
2399 self.xid = xid
2400 if match != None:
2401 self.match = match
2402 else:
2403 self.match = common.match()
2404 if cookie != None:
2405 self.cookie = cookie
2406 else:
2407 self.cookie = 0
2408 if idle_timeout != None:
2409 self.idle_timeout = idle_timeout
2410 else:
2411 self.idle_timeout = 0
2412 if hard_timeout != None:
2413 self.hard_timeout = hard_timeout
2414 else:
2415 self.hard_timeout = 0
2416 if priority != None:
2417 self.priority = priority
2418 else:
2419 self.priority = 0
2420 if buffer_id != None:
2421 self.buffer_id = buffer_id
2422 else:
2423 self.buffer_id = 0
2424 if out_port != None:
2425 self.out_port = out_port
2426 else:
2427 self.out_port = 0
2428 if flags != None:
2429 self.flags = flags
2430 else:
2431 self.flags = 0
2432 if actions != None:
2433 self.actions = actions
2434 else:
2435 self.actions = []
2436
2437 def pack(self):
2438 packed = []
2439 packed.append(struct.pack("!B", self.version))
2440 packed.append(struct.pack("!B", self.type))
2441 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2442 packed.append(struct.pack("!L", self.xid))
2443 packed.append(self.match.pack())
2444 packed.append(struct.pack("!Q", self.cookie))
2445 packed.append(struct.pack("!H", self._command))
2446 packed.append(struct.pack("!H", self.idle_timeout))
2447 packed.append(struct.pack("!H", self.hard_timeout))
2448 packed.append(struct.pack("!H", self.priority))
2449 packed.append(struct.pack("!L", self.buffer_id))
2450 packed.append(struct.pack("!H", self.out_port))
2451 packed.append(struct.pack("!H", self.flags))
2452 packed.append("".join([x.pack() for x in self.actions]))
2453 length = sum([len(x) for x in packed])
2454 packed[2] = struct.pack("!H", length)
2455 return ''.join(packed)
2456
2457 @staticmethod
2458 def unpack(buf):
2459 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2460 obj = flow_delete()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002461 if type(buf) == loxi.generic_util.OFReader:
2462 reader = buf
2463 else:
2464 reader = loxi.generic_util.OFReader(buf)
2465 _version = reader.read('!B')[0]
2466 assert(_version == const.OFP_VERSION)
2467 _type = reader.read('!B')[0]
2468 assert(_type == const.OFPT_FLOW_MOD)
2469 _length = reader.read('!H')[0]
2470 obj.xid = reader.read('!L')[0]
2471 obj.match = common.match.unpack(reader)
2472 obj.cookie = reader.read('!Q')[0]
2473 __command = reader.read('!H')[0]
2474 assert(__command == const.OFPFC_DELETE)
2475 obj.idle_timeout = reader.read('!H')[0]
2476 obj.hard_timeout = reader.read('!H')[0]
2477 obj.priority = reader.read('!H')[0]
2478 obj.buffer_id = reader.read('!L')[0]
2479 obj.out_port = reader.read('!H')[0]
2480 obj.flags = reader.read('!H')[0]
2481 obj.actions = action.unpack_list(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07002482 return obj
2483
2484 def __eq__(self, other):
2485 if type(self) != type(other): return False
2486 if self.version != other.version: return False
2487 if self.type != other.type: return False
2488 if self.xid != other.xid: return False
2489 if self.match != other.match: return False
2490 if self.cookie != other.cookie: return False
2491 if self.idle_timeout != other.idle_timeout: return False
2492 if self.hard_timeout != other.hard_timeout: return False
2493 if self.priority != other.priority: return False
2494 if self.buffer_id != other.buffer_id: return False
2495 if self.out_port != other.out_port: return False
2496 if self.flags != other.flags: return False
2497 if self.actions != other.actions: return False
2498 return True
2499
2500 def __ne__(self, other):
2501 return not self.__eq__(other)
2502
2503 def __str__(self):
2504 return self.show()
2505
2506 def show(self):
2507 import loxi.pp
2508 return loxi.pp.pp(self)
2509
2510 def pretty_print(self, q):
2511 q.text("flow_delete {")
2512 with q.group():
2513 with q.indent(2):
2514 q.breakable()
2515 q.text("xid = ");
2516 if self.xid != None:
2517 q.text("%#x" % self.xid)
2518 else:
2519 q.text('None')
2520 q.text(","); q.breakable()
2521 q.text("match = ");
2522 q.pp(self.match)
2523 q.text(","); q.breakable()
2524 q.text("cookie = ");
2525 q.text("%#x" % self.cookie)
2526 q.text(","); q.breakable()
2527 q.text("idle_timeout = ");
2528 q.text("%#x" % self.idle_timeout)
2529 q.text(","); q.breakable()
2530 q.text("hard_timeout = ");
2531 q.text("%#x" % self.hard_timeout)
2532 q.text(","); q.breakable()
2533 q.text("priority = ");
2534 q.text("%#x" % self.priority)
2535 q.text(","); q.breakable()
2536 q.text("buffer_id = ");
2537 q.text("%#x" % self.buffer_id)
2538 q.text(","); q.breakable()
2539 q.text("out_port = ");
2540 q.text(util.pretty_port(self.out_port))
2541 q.text(","); q.breakable()
2542 q.text("flags = ");
2543 q.text("%#x" % self.flags)
2544 q.text(","); q.breakable()
2545 q.text("actions = ");
2546 q.pp(self.actions)
2547 q.breakable()
2548 q.text('}')
2549
2550class flow_delete_strict(Message):
2551 version = const.OFP_VERSION
2552 type = const.OFPT_FLOW_MOD
2553 _command = const.OFPFC_DELETE_STRICT
2554
2555 def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
2556 self.xid = xid
2557 if match != None:
2558 self.match = match
2559 else:
2560 self.match = common.match()
2561 if cookie != None:
2562 self.cookie = cookie
2563 else:
2564 self.cookie = 0
2565 if idle_timeout != None:
2566 self.idle_timeout = idle_timeout
2567 else:
2568 self.idle_timeout = 0
2569 if hard_timeout != None:
2570 self.hard_timeout = hard_timeout
2571 else:
2572 self.hard_timeout = 0
2573 if priority != None:
2574 self.priority = priority
2575 else:
2576 self.priority = 0
2577 if buffer_id != None:
2578 self.buffer_id = buffer_id
2579 else:
2580 self.buffer_id = 0
2581 if out_port != None:
2582 self.out_port = out_port
2583 else:
2584 self.out_port = 0
2585 if flags != None:
2586 self.flags = flags
2587 else:
2588 self.flags = 0
2589 if actions != None:
2590 self.actions = actions
2591 else:
2592 self.actions = []
2593
2594 def pack(self):
2595 packed = []
2596 packed.append(struct.pack("!B", self.version))
2597 packed.append(struct.pack("!B", self.type))
2598 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2599 packed.append(struct.pack("!L", self.xid))
2600 packed.append(self.match.pack())
2601 packed.append(struct.pack("!Q", self.cookie))
2602 packed.append(struct.pack("!H", self._command))
2603 packed.append(struct.pack("!H", self.idle_timeout))
2604 packed.append(struct.pack("!H", self.hard_timeout))
2605 packed.append(struct.pack("!H", self.priority))
2606 packed.append(struct.pack("!L", self.buffer_id))
2607 packed.append(struct.pack("!H", self.out_port))
2608 packed.append(struct.pack("!H", self.flags))
2609 packed.append("".join([x.pack() for x in self.actions]))
2610 length = sum([len(x) for x in packed])
2611 packed[2] = struct.pack("!H", length)
2612 return ''.join(packed)
2613
2614 @staticmethod
2615 def unpack(buf):
2616 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2617 obj = flow_delete_strict()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002618 if type(buf) == loxi.generic_util.OFReader:
2619 reader = buf
2620 else:
2621 reader = loxi.generic_util.OFReader(buf)
2622 _version = reader.read('!B')[0]
2623 assert(_version == const.OFP_VERSION)
2624 _type = reader.read('!B')[0]
2625 assert(_type == const.OFPT_FLOW_MOD)
2626 _length = reader.read('!H')[0]
2627 obj.xid = reader.read('!L')[0]
2628 obj.match = common.match.unpack(reader)
2629 obj.cookie = reader.read('!Q')[0]
2630 __command = reader.read('!H')[0]
2631 assert(__command == const.OFPFC_DELETE_STRICT)
2632 obj.idle_timeout = reader.read('!H')[0]
2633 obj.hard_timeout = reader.read('!H')[0]
2634 obj.priority = reader.read('!H')[0]
2635 obj.buffer_id = reader.read('!L')[0]
2636 obj.out_port = reader.read('!H')[0]
2637 obj.flags = reader.read('!H')[0]
2638 obj.actions = action.unpack_list(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07002639 return obj
2640
2641 def __eq__(self, other):
2642 if type(self) != type(other): return False
2643 if self.version != other.version: return False
2644 if self.type != other.type: return False
2645 if self.xid != other.xid: return False
2646 if self.match != other.match: return False
2647 if self.cookie != other.cookie: return False
2648 if self.idle_timeout != other.idle_timeout: return False
2649 if self.hard_timeout != other.hard_timeout: return False
2650 if self.priority != other.priority: return False
2651 if self.buffer_id != other.buffer_id: return False
2652 if self.out_port != other.out_port: return False
2653 if self.flags != other.flags: return False
2654 if self.actions != other.actions: return False
2655 return True
2656
2657 def __ne__(self, other):
2658 return not self.__eq__(other)
2659
2660 def __str__(self):
2661 return self.show()
2662
2663 def show(self):
2664 import loxi.pp
2665 return loxi.pp.pp(self)
2666
2667 def pretty_print(self, q):
2668 q.text("flow_delete_strict {")
2669 with q.group():
2670 with q.indent(2):
2671 q.breakable()
2672 q.text("xid = ");
2673 if self.xid != None:
2674 q.text("%#x" % self.xid)
2675 else:
2676 q.text('None')
2677 q.text(","); q.breakable()
2678 q.text("match = ");
2679 q.pp(self.match)
2680 q.text(","); q.breakable()
2681 q.text("cookie = ");
2682 q.text("%#x" % self.cookie)
2683 q.text(","); q.breakable()
2684 q.text("idle_timeout = ");
2685 q.text("%#x" % self.idle_timeout)
2686 q.text(","); q.breakable()
2687 q.text("hard_timeout = ");
2688 q.text("%#x" % self.hard_timeout)
2689 q.text(","); q.breakable()
2690 q.text("priority = ");
2691 q.text("%#x" % self.priority)
2692 q.text(","); q.breakable()
2693 q.text("buffer_id = ");
2694 q.text("%#x" % self.buffer_id)
2695 q.text(","); q.breakable()
2696 q.text("out_port = ");
2697 q.text(util.pretty_port(self.out_port))
2698 q.text(","); q.breakable()
2699 q.text("flags = ");
2700 q.text("%#x" % self.flags)
2701 q.text(","); q.breakable()
2702 q.text("actions = ");
2703 q.pp(self.actions)
2704 q.breakable()
2705 q.text('}')
2706
2707class flow_modify(Message):
2708 version = const.OFP_VERSION
2709 type = const.OFPT_FLOW_MOD
2710 _command = const.OFPFC_MODIFY
2711
2712 def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
2713 self.xid = xid
2714 if match != None:
2715 self.match = match
2716 else:
2717 self.match = common.match()
2718 if cookie != None:
2719 self.cookie = cookie
2720 else:
2721 self.cookie = 0
2722 if idle_timeout != None:
2723 self.idle_timeout = idle_timeout
2724 else:
2725 self.idle_timeout = 0
2726 if hard_timeout != None:
2727 self.hard_timeout = hard_timeout
2728 else:
2729 self.hard_timeout = 0
2730 if priority != None:
2731 self.priority = priority
2732 else:
2733 self.priority = 0
2734 if buffer_id != None:
2735 self.buffer_id = buffer_id
2736 else:
2737 self.buffer_id = 0
2738 if out_port != None:
2739 self.out_port = out_port
2740 else:
2741 self.out_port = 0
2742 if flags != None:
2743 self.flags = flags
2744 else:
2745 self.flags = 0
2746 if actions != None:
2747 self.actions = actions
2748 else:
2749 self.actions = []
2750
2751 def pack(self):
2752 packed = []
2753 packed.append(struct.pack("!B", self.version))
2754 packed.append(struct.pack("!B", self.type))
2755 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2756 packed.append(struct.pack("!L", self.xid))
2757 packed.append(self.match.pack())
2758 packed.append(struct.pack("!Q", self.cookie))
2759 packed.append(struct.pack("!H", self._command))
2760 packed.append(struct.pack("!H", self.idle_timeout))
2761 packed.append(struct.pack("!H", self.hard_timeout))
2762 packed.append(struct.pack("!H", self.priority))
2763 packed.append(struct.pack("!L", self.buffer_id))
2764 packed.append(struct.pack("!H", self.out_port))
2765 packed.append(struct.pack("!H", self.flags))
2766 packed.append("".join([x.pack() for x in self.actions]))
2767 length = sum([len(x) for x in packed])
2768 packed[2] = struct.pack("!H", length)
2769 return ''.join(packed)
2770
2771 @staticmethod
2772 def unpack(buf):
2773 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2774 obj = flow_modify()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002775 if type(buf) == loxi.generic_util.OFReader:
2776 reader = buf
2777 else:
2778 reader = loxi.generic_util.OFReader(buf)
2779 _version = reader.read('!B')[0]
2780 assert(_version == const.OFP_VERSION)
2781 _type = reader.read('!B')[0]
2782 assert(_type == const.OFPT_FLOW_MOD)
2783 _length = reader.read('!H')[0]
2784 obj.xid = reader.read('!L')[0]
2785 obj.match = common.match.unpack(reader)
2786 obj.cookie = reader.read('!Q')[0]
2787 __command = reader.read('!H')[0]
2788 assert(__command == const.OFPFC_MODIFY)
2789 obj.idle_timeout = reader.read('!H')[0]
2790 obj.hard_timeout = reader.read('!H')[0]
2791 obj.priority = reader.read('!H')[0]
2792 obj.buffer_id = reader.read('!L')[0]
2793 obj.out_port = reader.read('!H')[0]
2794 obj.flags = reader.read('!H')[0]
2795 obj.actions = action.unpack_list(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07002796 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.match != other.match: return False
2804 if self.cookie != other.cookie: return False
2805 if self.idle_timeout != other.idle_timeout: return False
2806 if self.hard_timeout != other.hard_timeout: return False
2807 if self.priority != other.priority: return False
2808 if self.buffer_id != other.buffer_id: return False
2809 if self.out_port != other.out_port: return False
2810 if self.flags != other.flags: return False
2811 if self.actions != other.actions: return False
2812 return True
2813
2814 def __ne__(self, other):
2815 return not self.__eq__(other)
2816
2817 def __str__(self):
2818 return self.show()
2819
2820 def show(self):
2821 import loxi.pp
2822 return loxi.pp.pp(self)
2823
2824 def pretty_print(self, q):
2825 q.text("flow_modify {")
2826 with q.group():
2827 with q.indent(2):
2828 q.breakable()
2829 q.text("xid = ");
2830 if self.xid != None:
2831 q.text("%#x" % self.xid)
2832 else:
2833 q.text('None')
2834 q.text(","); q.breakable()
2835 q.text("match = ");
2836 q.pp(self.match)
2837 q.text(","); q.breakable()
2838 q.text("cookie = ");
2839 q.text("%#x" % self.cookie)
2840 q.text(","); q.breakable()
2841 q.text("idle_timeout = ");
2842 q.text("%#x" % self.idle_timeout)
2843 q.text(","); q.breakable()
2844 q.text("hard_timeout = ");
2845 q.text("%#x" % self.hard_timeout)
2846 q.text(","); q.breakable()
2847 q.text("priority = ");
2848 q.text("%#x" % self.priority)
2849 q.text(","); q.breakable()
2850 q.text("buffer_id = ");
2851 q.text("%#x" % self.buffer_id)
2852 q.text(","); q.breakable()
2853 q.text("out_port = ");
2854 q.text(util.pretty_port(self.out_port))
2855 q.text(","); q.breakable()
2856 q.text("flags = ");
2857 q.text("%#x" % self.flags)
2858 q.text(","); q.breakable()
2859 q.text("actions = ");
2860 q.pp(self.actions)
2861 q.breakable()
2862 q.text('}')
2863
2864class flow_modify_strict(Message):
2865 version = const.OFP_VERSION
2866 type = const.OFPT_FLOW_MOD
2867 _command = const.OFPFC_MODIFY_STRICT
2868
2869 def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
2870 self.xid = xid
2871 if match != None:
2872 self.match = match
2873 else:
2874 self.match = common.match()
2875 if cookie != None:
2876 self.cookie = cookie
2877 else:
2878 self.cookie = 0
2879 if idle_timeout != None:
2880 self.idle_timeout = idle_timeout
2881 else:
2882 self.idle_timeout = 0
2883 if hard_timeout != None:
2884 self.hard_timeout = hard_timeout
2885 else:
2886 self.hard_timeout = 0
2887 if priority != None:
2888 self.priority = priority
2889 else:
2890 self.priority = 0
2891 if buffer_id != None:
2892 self.buffer_id = buffer_id
2893 else:
2894 self.buffer_id = 0
2895 if out_port != None:
2896 self.out_port = out_port
2897 else:
2898 self.out_port = 0
2899 if flags != None:
2900 self.flags = flags
2901 else:
2902 self.flags = 0
2903 if actions != None:
2904 self.actions = actions
2905 else:
2906 self.actions = []
2907
2908 def pack(self):
2909 packed = []
2910 packed.append(struct.pack("!B", self.version))
2911 packed.append(struct.pack("!B", self.type))
2912 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2913 packed.append(struct.pack("!L", self.xid))
2914 packed.append(self.match.pack())
2915 packed.append(struct.pack("!Q", self.cookie))
2916 packed.append(struct.pack("!H", self._command))
2917 packed.append(struct.pack("!H", self.idle_timeout))
2918 packed.append(struct.pack("!H", self.hard_timeout))
2919 packed.append(struct.pack("!H", self.priority))
2920 packed.append(struct.pack("!L", self.buffer_id))
2921 packed.append(struct.pack("!H", self.out_port))
2922 packed.append(struct.pack("!H", self.flags))
2923 packed.append("".join([x.pack() for x in self.actions]))
2924 length = sum([len(x) for x in packed])
2925 packed[2] = struct.pack("!H", length)
2926 return ''.join(packed)
2927
2928 @staticmethod
2929 def unpack(buf):
2930 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
2931 obj = flow_modify_strict()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002932 if type(buf) == loxi.generic_util.OFReader:
2933 reader = buf
2934 else:
2935 reader = loxi.generic_util.OFReader(buf)
2936 _version = reader.read('!B')[0]
2937 assert(_version == const.OFP_VERSION)
2938 _type = reader.read('!B')[0]
2939 assert(_type == const.OFPT_FLOW_MOD)
2940 _length = reader.read('!H')[0]
2941 obj.xid = reader.read('!L')[0]
2942 obj.match = common.match.unpack(reader)
2943 obj.cookie = reader.read('!Q')[0]
2944 __command = reader.read('!H')[0]
2945 assert(__command == const.OFPFC_MODIFY_STRICT)
2946 obj.idle_timeout = reader.read('!H')[0]
2947 obj.hard_timeout = reader.read('!H')[0]
2948 obj.priority = reader.read('!H')[0]
2949 obj.buffer_id = reader.read('!L')[0]
2950 obj.out_port = reader.read('!H')[0]
2951 obj.flags = reader.read('!H')[0]
2952 obj.actions = action.unpack_list(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07002953 return obj
2954
2955 def __eq__(self, other):
2956 if type(self) != type(other): return False
2957 if self.version != other.version: return False
2958 if self.type != other.type: return False
2959 if self.xid != other.xid: return False
2960 if self.match != other.match: return False
2961 if self.cookie != other.cookie: return False
2962 if self.idle_timeout != other.idle_timeout: return False
2963 if self.hard_timeout != other.hard_timeout: return False
2964 if self.priority != other.priority: return False
2965 if self.buffer_id != other.buffer_id: return False
2966 if self.out_port != other.out_port: return False
2967 if self.flags != other.flags: return False
2968 if self.actions != other.actions: return False
2969 return True
2970
2971 def __ne__(self, other):
2972 return not self.__eq__(other)
2973
2974 def __str__(self):
2975 return self.show()
2976
2977 def show(self):
2978 import loxi.pp
2979 return loxi.pp.pp(self)
2980
2981 def pretty_print(self, q):
2982 q.text("flow_modify_strict {")
2983 with q.group():
2984 with q.indent(2):
2985 q.breakable()
2986 q.text("xid = ");
2987 if self.xid != None:
2988 q.text("%#x" % self.xid)
2989 else:
2990 q.text('None')
2991 q.text(","); q.breakable()
2992 q.text("match = ");
2993 q.pp(self.match)
2994 q.text(","); q.breakable()
2995 q.text("cookie = ");
2996 q.text("%#x" % self.cookie)
2997 q.text(","); q.breakable()
2998 q.text("idle_timeout = ");
2999 q.text("%#x" % self.idle_timeout)
3000 q.text(","); q.breakable()
3001 q.text("hard_timeout = ");
3002 q.text("%#x" % self.hard_timeout)
3003 q.text(","); q.breakable()
3004 q.text("priority = ");
3005 q.text("%#x" % self.priority)
3006 q.text(","); q.breakable()
3007 q.text("buffer_id = ");
3008 q.text("%#x" % self.buffer_id)
3009 q.text(","); q.breakable()
3010 q.text("out_port = ");
3011 q.text(util.pretty_port(self.out_port))
3012 q.text(","); q.breakable()
3013 q.text("flags = ");
3014 q.text("%#x" % self.flags)
3015 q.text(","); q.breakable()
3016 q.text("actions = ");
3017 q.pp(self.actions)
3018 q.breakable()
3019 q.text('}')
3020
3021class flow_removed(Message):
3022 version = const.OFP_VERSION
3023 type = const.OFPT_FLOW_REMOVED
3024
Rich Lanec2ee4b82013-04-24 17:12:38 -07003025 def __init__(self, xid=None, match=None, cookie=None, priority=None, reason=None, duration_sec=None, duration_nsec=None, idle_timeout=None, packet_count=None, byte_count=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07003026 self.xid = xid
3027 if match != None:
3028 self.match = match
3029 else:
3030 self.match = common.match()
3031 if cookie != None:
3032 self.cookie = cookie
3033 else:
3034 self.cookie = 0
3035 if priority != None:
3036 self.priority = priority
3037 else:
3038 self.priority = 0
3039 if reason != None:
3040 self.reason = reason
3041 else:
3042 self.reason = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07003043 if duration_sec != None:
3044 self.duration_sec = duration_sec
3045 else:
3046 self.duration_sec = 0
3047 if duration_nsec != None:
3048 self.duration_nsec = duration_nsec
3049 else:
3050 self.duration_nsec = 0
3051 if idle_timeout != None:
3052 self.idle_timeout = idle_timeout
3053 else:
3054 self.idle_timeout = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07003055 if packet_count != None:
3056 self.packet_count = packet_count
3057 else:
3058 self.packet_count = 0
3059 if byte_count != None:
3060 self.byte_count = byte_count
3061 else:
3062 self.byte_count = 0
3063
3064 def pack(self):
3065 packed = []
3066 packed.append(struct.pack("!B", self.version))
3067 packed.append(struct.pack("!B", self.type))
3068 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3069 packed.append(struct.pack("!L", self.xid))
3070 packed.append(self.match.pack())
3071 packed.append(struct.pack("!Q", self.cookie))
3072 packed.append(struct.pack("!H", self.priority))
3073 packed.append(struct.pack("!B", self.reason))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003074 packed.append('\x00' * 1)
Rich Laneb658ddd2013-03-12 10:15:10 -07003075 packed.append(struct.pack("!L", self.duration_sec))
3076 packed.append(struct.pack("!L", self.duration_nsec))
3077 packed.append(struct.pack("!H", self.idle_timeout))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003078 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -07003079 packed.append(struct.pack("!Q", self.packet_count))
3080 packed.append(struct.pack("!Q", self.byte_count))
3081 length = sum([len(x) for x in packed])
3082 packed[2] = struct.pack("!H", length)
3083 return ''.join(packed)
3084
3085 @staticmethod
3086 def unpack(buf):
3087 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3088 obj = flow_removed()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003089 if type(buf) == loxi.generic_util.OFReader:
3090 reader = buf
3091 else:
3092 reader = loxi.generic_util.OFReader(buf)
3093 _version = reader.read('!B')[0]
3094 assert(_version == const.OFP_VERSION)
3095 _type = reader.read('!B')[0]
3096 assert(_type == const.OFPT_FLOW_REMOVED)
3097 _length = reader.read('!H')[0]
3098 obj.xid = reader.read('!L')[0]
3099 obj.match = common.match.unpack(reader)
3100 obj.cookie = reader.read('!Q')[0]
3101 obj.priority = reader.read('!H')[0]
3102 obj.reason = reader.read('!B')[0]
3103 reader.skip(1)
3104 obj.duration_sec = reader.read('!L')[0]
3105 obj.duration_nsec = reader.read('!L')[0]
3106 obj.idle_timeout = reader.read('!H')[0]
3107 reader.skip(2)
3108 obj.packet_count = reader.read('!Q')[0]
3109 obj.byte_count = reader.read('!Q')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07003110 return obj
3111
3112 def __eq__(self, other):
3113 if type(self) != type(other): return False
3114 if self.version != other.version: return False
3115 if self.type != other.type: return False
3116 if self.xid != other.xid: return False
3117 if self.match != other.match: return False
3118 if self.cookie != other.cookie: return False
3119 if self.priority != other.priority: return False
3120 if self.reason != other.reason: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07003121 if self.duration_sec != other.duration_sec: return False
3122 if self.duration_nsec != other.duration_nsec: return False
3123 if self.idle_timeout != other.idle_timeout: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07003124 if self.packet_count != other.packet_count: return False
3125 if self.byte_count != other.byte_count: return False
3126 return True
3127
3128 def __ne__(self, other):
3129 return not self.__eq__(other)
3130
3131 def __str__(self):
3132 return self.show()
3133
3134 def show(self):
3135 import loxi.pp
3136 return loxi.pp.pp(self)
3137
3138 def pretty_print(self, q):
3139 q.text("flow_removed {")
3140 with q.group():
3141 with q.indent(2):
3142 q.breakable()
3143 q.text("xid = ");
3144 if self.xid != None:
3145 q.text("%#x" % self.xid)
3146 else:
3147 q.text('None')
3148 q.text(","); q.breakable()
3149 q.text("match = ");
3150 q.pp(self.match)
3151 q.text(","); q.breakable()
3152 q.text("cookie = ");
3153 q.text("%#x" % self.cookie)
3154 q.text(","); q.breakable()
3155 q.text("priority = ");
3156 q.text("%#x" % self.priority)
3157 q.text(","); q.breakable()
3158 q.text("reason = ");
3159 q.text("%#x" % self.reason)
3160 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07003161 q.text("duration_sec = ");
3162 q.text("%#x" % self.duration_sec)
3163 q.text(","); q.breakable()
3164 q.text("duration_nsec = ");
3165 q.text("%#x" % self.duration_nsec)
3166 q.text(","); q.breakable()
3167 q.text("idle_timeout = ");
3168 q.text("%#x" % self.idle_timeout)
3169 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07003170 q.text("packet_count = ");
3171 q.text("%#x" % self.packet_count)
3172 q.text(","); q.breakable()
3173 q.text("byte_count = ");
3174 q.text("%#x" % self.byte_count)
3175 q.breakable()
3176 q.text('}')
3177
3178class flow_stats_reply(Message):
3179 version = const.OFP_VERSION
3180 type = const.OFPT_STATS_REPLY
3181 stats_type = const.OFPST_FLOW
3182
3183 def __init__(self, xid=None, flags=None, entries=None):
3184 self.xid = xid
3185 if flags != None:
3186 self.flags = flags
3187 else:
3188 self.flags = 0
3189 if entries != None:
3190 self.entries = entries
3191 else:
3192 self.entries = []
3193
3194 def pack(self):
3195 packed = []
3196 packed.append(struct.pack("!B", self.version))
3197 packed.append(struct.pack("!B", self.type))
3198 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3199 packed.append(struct.pack("!L", self.xid))
3200 packed.append(struct.pack("!H", self.stats_type))
3201 packed.append(struct.pack("!H", self.flags))
3202 packed.append("".join([x.pack() for x in self.entries]))
3203 length = sum([len(x) for x in packed])
3204 packed[2] = struct.pack("!H", length)
3205 return ''.join(packed)
3206
3207 @staticmethod
3208 def unpack(buf):
3209 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3210 obj = flow_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003211 if type(buf) == loxi.generic_util.OFReader:
3212 reader = buf
3213 else:
3214 reader = loxi.generic_util.OFReader(buf)
3215 _version = reader.read('!B')[0]
3216 assert(_version == const.OFP_VERSION)
3217 _type = reader.read('!B')[0]
3218 assert(_type == const.OFPT_STATS_REPLY)
3219 _length = reader.read('!H')[0]
3220 obj.xid = reader.read('!L')[0]
3221 _stats_type = reader.read('!H')[0]
3222 assert(_stats_type == const.OFPST_FLOW)
3223 obj.flags = reader.read('!H')[0]
3224 obj.entries = common.unpack_list_flow_stats_entry(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07003225 return obj
3226
3227 def __eq__(self, other):
3228 if type(self) != type(other): return False
3229 if self.version != other.version: return False
3230 if self.type != other.type: return False
3231 if self.xid != other.xid: return False
3232 if self.flags != other.flags: return False
3233 if self.entries != other.entries: return False
3234 return True
3235
3236 def __ne__(self, other):
3237 return not self.__eq__(other)
3238
3239 def __str__(self):
3240 return self.show()
3241
3242 def show(self):
3243 import loxi.pp
3244 return loxi.pp.pp(self)
3245
3246 def pretty_print(self, q):
3247 q.text("flow_stats_reply {")
3248 with q.group():
3249 with q.indent(2):
3250 q.breakable()
3251 q.text("xid = ");
3252 if self.xid != None:
3253 q.text("%#x" % self.xid)
3254 else:
3255 q.text('None')
3256 q.text(","); q.breakable()
3257 q.text("flags = ");
3258 q.text("%#x" % self.flags)
3259 q.text(","); q.breakable()
3260 q.text("entries = ");
3261 q.pp(self.entries)
3262 q.breakable()
3263 q.text('}')
3264
3265class flow_stats_request(Message):
3266 version = const.OFP_VERSION
3267 type = const.OFPT_STATS_REQUEST
3268 stats_type = const.OFPST_FLOW
3269
Rich Lanec2ee4b82013-04-24 17:12:38 -07003270 def __init__(self, xid=None, flags=None, match=None, table_id=None, out_port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07003271 self.xid = xid
3272 if flags != None:
3273 self.flags = flags
3274 else:
3275 self.flags = 0
3276 if match != None:
3277 self.match = match
3278 else:
3279 self.match = common.match()
3280 if table_id != None:
3281 self.table_id = table_id
3282 else:
3283 self.table_id = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07003284 if out_port != None:
3285 self.out_port = out_port
3286 else:
3287 self.out_port = 0
3288
3289 def pack(self):
3290 packed = []
3291 packed.append(struct.pack("!B", self.version))
3292 packed.append(struct.pack("!B", self.type))
3293 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3294 packed.append(struct.pack("!L", self.xid))
3295 packed.append(struct.pack("!H", self.stats_type))
3296 packed.append(struct.pack("!H", self.flags))
3297 packed.append(self.match.pack())
3298 packed.append(struct.pack("!B", self.table_id))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003299 packed.append('\x00' * 1)
Rich Laneb658ddd2013-03-12 10:15:10 -07003300 packed.append(struct.pack("!H", self.out_port))
3301 length = sum([len(x) for x in packed])
3302 packed[2] = struct.pack("!H", length)
3303 return ''.join(packed)
3304
3305 @staticmethod
3306 def unpack(buf):
3307 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3308 obj = flow_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003309 if type(buf) == loxi.generic_util.OFReader:
3310 reader = buf
3311 else:
3312 reader = loxi.generic_util.OFReader(buf)
3313 _version = reader.read('!B')[0]
3314 assert(_version == const.OFP_VERSION)
3315 _type = reader.read('!B')[0]
3316 assert(_type == const.OFPT_STATS_REQUEST)
3317 _length = reader.read('!H')[0]
3318 obj.xid = reader.read('!L')[0]
3319 _stats_type = reader.read('!H')[0]
3320 assert(_stats_type == const.OFPST_FLOW)
3321 obj.flags = reader.read('!H')[0]
3322 obj.match = common.match.unpack(reader)
3323 obj.table_id = reader.read('!B')[0]
3324 reader.skip(1)
3325 obj.out_port = reader.read('!H')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07003326 return obj
3327
3328 def __eq__(self, other):
3329 if type(self) != type(other): return False
3330 if self.version != other.version: return False
3331 if self.type != other.type: return False
3332 if self.xid != other.xid: return False
3333 if self.flags != other.flags: return False
3334 if self.match != other.match: return False
3335 if self.table_id != other.table_id: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07003336 if self.out_port != other.out_port: return False
3337 return True
3338
3339 def __ne__(self, other):
3340 return not self.__eq__(other)
3341
3342 def __str__(self):
3343 return self.show()
3344
3345 def show(self):
3346 import loxi.pp
3347 return loxi.pp.pp(self)
3348
3349 def pretty_print(self, q):
3350 q.text("flow_stats_request {")
3351 with q.group():
3352 with q.indent(2):
3353 q.breakable()
3354 q.text("xid = ");
3355 if self.xid != None:
3356 q.text("%#x" % self.xid)
3357 else:
3358 q.text('None')
3359 q.text(","); q.breakable()
3360 q.text("flags = ");
3361 q.text("%#x" % self.flags)
3362 q.text(","); q.breakable()
3363 q.text("match = ");
3364 q.pp(self.match)
3365 q.text(","); q.breakable()
3366 q.text("table_id = ");
3367 q.text("%#x" % self.table_id)
3368 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07003369 q.text("out_port = ");
3370 q.text(util.pretty_port(self.out_port))
3371 q.breakable()
3372 q.text('}')
3373
3374class get_config_reply(Message):
3375 version = const.OFP_VERSION
3376 type = const.OFPT_GET_CONFIG_REPLY
3377
3378 def __init__(self, xid=None, flags=None, miss_send_len=None):
3379 self.xid = xid
3380 if flags != None:
3381 self.flags = flags
3382 else:
3383 self.flags = 0
3384 if miss_send_len != None:
3385 self.miss_send_len = miss_send_len
3386 else:
3387 self.miss_send_len = 0
3388
3389 def pack(self):
3390 packed = []
3391 packed.append(struct.pack("!B", self.version))
3392 packed.append(struct.pack("!B", self.type))
3393 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3394 packed.append(struct.pack("!L", self.xid))
3395 packed.append(struct.pack("!H", self.flags))
3396 packed.append(struct.pack("!H", self.miss_send_len))
3397 length = sum([len(x) for x in packed])
3398 packed[2] = struct.pack("!H", length)
3399 return ''.join(packed)
3400
3401 @staticmethod
3402 def unpack(buf):
3403 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3404 obj = get_config_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003405 if type(buf) == loxi.generic_util.OFReader:
3406 reader = buf
3407 else:
3408 reader = loxi.generic_util.OFReader(buf)
3409 _version = reader.read('!B')[0]
3410 assert(_version == const.OFP_VERSION)
3411 _type = reader.read('!B')[0]
3412 assert(_type == const.OFPT_GET_CONFIG_REPLY)
3413 _length = reader.read('!H')[0]
3414 obj.xid = reader.read('!L')[0]
3415 obj.flags = reader.read('!H')[0]
3416 obj.miss_send_len = reader.read('!H')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07003417 return obj
3418
3419 def __eq__(self, other):
3420 if type(self) != type(other): return False
3421 if self.version != other.version: return False
3422 if self.type != other.type: return False
3423 if self.xid != other.xid: return False
3424 if self.flags != other.flags: return False
3425 if self.miss_send_len != other.miss_send_len: return False
3426 return True
3427
3428 def __ne__(self, other):
3429 return not self.__eq__(other)
3430
3431 def __str__(self):
3432 return self.show()
3433
3434 def show(self):
3435 import loxi.pp
3436 return loxi.pp.pp(self)
3437
3438 def pretty_print(self, q):
3439 q.text("get_config_reply {")
3440 with q.group():
3441 with q.indent(2):
3442 q.breakable()
3443 q.text("xid = ");
3444 if self.xid != None:
3445 q.text("%#x" % self.xid)
3446 else:
3447 q.text('None')
3448 q.text(","); q.breakable()
3449 q.text("flags = ");
3450 q.text("%#x" % self.flags)
3451 q.text(","); q.breakable()
3452 q.text("miss_send_len = ");
3453 q.text("%#x" % self.miss_send_len)
3454 q.breakable()
3455 q.text('}')
3456
3457class get_config_request(Message):
3458 version = const.OFP_VERSION
3459 type = const.OFPT_GET_CONFIG_REQUEST
3460
3461 def __init__(self, xid=None):
3462 self.xid = xid
3463
3464 def pack(self):
3465 packed = []
3466 packed.append(struct.pack("!B", self.version))
3467 packed.append(struct.pack("!B", self.type))
3468 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3469 packed.append(struct.pack("!L", self.xid))
3470 length = sum([len(x) for x in packed])
3471 packed[2] = struct.pack("!H", length)
3472 return ''.join(packed)
3473
3474 @staticmethod
3475 def unpack(buf):
3476 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3477 obj = get_config_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003478 if type(buf) == loxi.generic_util.OFReader:
3479 reader = buf
3480 else:
3481 reader = loxi.generic_util.OFReader(buf)
3482 _version = reader.read('!B')[0]
3483 assert(_version == const.OFP_VERSION)
3484 _type = reader.read('!B')[0]
3485 assert(_type == const.OFPT_GET_CONFIG_REQUEST)
3486 _length = reader.read('!H')[0]
3487 obj.xid = reader.read('!L')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07003488 return obj
3489
3490 def __eq__(self, other):
3491 if type(self) != type(other): return False
3492 if self.version != other.version: return False
3493 if self.type != other.type: return False
3494 if self.xid != other.xid: return False
3495 return True
3496
3497 def __ne__(self, other):
3498 return not self.__eq__(other)
3499
3500 def __str__(self):
3501 return self.show()
3502
3503 def show(self):
3504 import loxi.pp
3505 return loxi.pp.pp(self)
3506
3507 def pretty_print(self, q):
3508 q.text("get_config_request {")
3509 with q.group():
3510 with q.indent(2):
3511 q.breakable()
3512 q.text("xid = ");
3513 if self.xid != None:
3514 q.text("%#x" % self.xid)
3515 else:
3516 q.text('None')
3517 q.breakable()
3518 q.text('}')
3519
3520class hello(Message):
3521 version = const.OFP_VERSION
3522 type = const.OFPT_HELLO
3523
3524 def __init__(self, xid=None):
3525 self.xid = xid
3526
3527 def pack(self):
3528 packed = []
3529 packed.append(struct.pack("!B", self.version))
3530 packed.append(struct.pack("!B", self.type))
3531 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3532 packed.append(struct.pack("!L", self.xid))
3533 length = sum([len(x) for x in packed])
3534 packed[2] = struct.pack("!H", length)
3535 return ''.join(packed)
3536
3537 @staticmethod
3538 def unpack(buf):
3539 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3540 obj = hello()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003541 if type(buf) == loxi.generic_util.OFReader:
3542 reader = buf
3543 else:
3544 reader = loxi.generic_util.OFReader(buf)
3545 _version = reader.read('!B')[0]
3546 assert(_version == const.OFP_VERSION)
3547 _type = reader.read('!B')[0]
3548 assert(_type == const.OFPT_HELLO)
3549 _length = reader.read('!H')[0]
3550 obj.xid = reader.read('!L')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07003551 return obj
3552
3553 def __eq__(self, other):
3554 if type(self) != type(other): return False
3555 if self.version != other.version: return False
3556 if self.type != other.type: return False
3557 if self.xid != other.xid: return False
3558 return True
3559
3560 def __ne__(self, other):
3561 return not self.__eq__(other)
3562
3563 def __str__(self):
3564 return self.show()
3565
3566 def show(self):
3567 import loxi.pp
3568 return loxi.pp.pp(self)
3569
3570 def pretty_print(self, q):
3571 q.text("hello {")
3572 with q.group():
3573 with q.indent(2):
3574 q.breakable()
3575 q.text("xid = ");
3576 if self.xid != None:
3577 q.text("%#x" % self.xid)
3578 else:
3579 q.text('None')
3580 q.breakable()
3581 q.text('}')
3582
3583class nicira_controller_role_reply(Message):
3584 version = const.OFP_VERSION
3585 type = const.OFPT_VENDOR
3586 experimenter = 0x2320
3587 subtype = 11
3588
3589 def __init__(self, xid=None, role=None):
3590 self.xid = xid
3591 if role != None:
3592 self.role = role
3593 else:
3594 self.role = 0
3595
3596 def pack(self):
3597 packed = []
3598 packed.append(struct.pack("!B", self.version))
3599 packed.append(struct.pack("!B", self.type))
3600 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3601 packed.append(struct.pack("!L", self.xid))
3602 packed.append(struct.pack("!L", self.experimenter))
3603 packed.append(struct.pack("!L", self.subtype))
3604 packed.append(struct.pack("!L", self.role))
3605 length = sum([len(x) for x in packed])
3606 packed[2] = struct.pack("!H", length)
3607 return ''.join(packed)
3608
3609 @staticmethod
3610 def unpack(buf):
3611 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3612 obj = nicira_controller_role_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003613 if type(buf) == loxi.generic_util.OFReader:
3614 reader = buf
3615 else:
3616 reader = loxi.generic_util.OFReader(buf)
3617 _version = reader.read('!B')[0]
3618 assert(_version == const.OFP_VERSION)
3619 _type = reader.read('!B')[0]
3620 assert(_type == const.OFPT_VENDOR)
3621 _length = reader.read('!H')[0]
3622 obj.xid = reader.read('!L')[0]
3623 _experimenter = reader.read('!L')[0]
3624 assert(_experimenter == 0x2320)
3625 _subtype = reader.read('!L')[0]
3626 assert(_subtype == 11)
3627 obj.role = reader.read('!L')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07003628 return obj
3629
3630 def __eq__(self, other):
3631 if type(self) != type(other): return False
3632 if self.version != other.version: return False
3633 if self.type != other.type: return False
3634 if self.xid != other.xid: return False
3635 if self.role != other.role: return False
3636 return True
3637
3638 def __ne__(self, other):
3639 return not self.__eq__(other)
3640
3641 def __str__(self):
3642 return self.show()
3643
3644 def show(self):
3645 import loxi.pp
3646 return loxi.pp.pp(self)
3647
3648 def pretty_print(self, q):
3649 q.text("nicira_controller_role_reply {")
3650 with q.group():
3651 with q.indent(2):
3652 q.breakable()
3653 q.text("xid = ");
3654 if self.xid != None:
3655 q.text("%#x" % self.xid)
3656 else:
3657 q.text('None')
3658 q.text(","); q.breakable()
3659 q.text("role = ");
3660 q.text("%#x" % self.role)
3661 q.breakable()
3662 q.text('}')
3663
3664class nicira_controller_role_request(Message):
3665 version = const.OFP_VERSION
3666 type = const.OFPT_VENDOR
3667 experimenter = 0x2320
3668 subtype = 10
3669
3670 def __init__(self, xid=None, role=None):
3671 self.xid = xid
3672 if role != None:
3673 self.role = role
3674 else:
3675 self.role = 0
3676
3677 def pack(self):
3678 packed = []
3679 packed.append(struct.pack("!B", self.version))
3680 packed.append(struct.pack("!B", self.type))
3681 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3682 packed.append(struct.pack("!L", self.xid))
3683 packed.append(struct.pack("!L", self.experimenter))
3684 packed.append(struct.pack("!L", self.subtype))
3685 packed.append(struct.pack("!L", self.role))
3686 length = sum([len(x) for x in packed])
3687 packed[2] = struct.pack("!H", length)
3688 return ''.join(packed)
3689
3690 @staticmethod
3691 def unpack(buf):
3692 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3693 obj = nicira_controller_role_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003694 if type(buf) == loxi.generic_util.OFReader:
3695 reader = buf
3696 else:
3697 reader = loxi.generic_util.OFReader(buf)
3698 _version = reader.read('!B')[0]
3699 assert(_version == const.OFP_VERSION)
3700 _type = reader.read('!B')[0]
3701 assert(_type == const.OFPT_VENDOR)
3702 _length = reader.read('!H')[0]
3703 obj.xid = reader.read('!L')[0]
3704 _experimenter = reader.read('!L')[0]
3705 assert(_experimenter == 0x2320)
3706 _subtype = reader.read('!L')[0]
3707 assert(_subtype == 10)
3708 obj.role = reader.read('!L')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07003709 return obj
3710
3711 def __eq__(self, other):
3712 if type(self) != type(other): return False
3713 if self.version != other.version: return False
3714 if self.type != other.type: return False
3715 if self.xid != other.xid: return False
3716 if self.role != other.role: return False
3717 return True
3718
3719 def __ne__(self, other):
3720 return not self.__eq__(other)
3721
3722 def __str__(self):
3723 return self.show()
3724
3725 def show(self):
3726 import loxi.pp
3727 return loxi.pp.pp(self)
3728
3729 def pretty_print(self, q):
3730 q.text("nicira_controller_role_request {")
3731 with q.group():
3732 with q.indent(2):
3733 q.breakable()
3734 q.text("xid = ");
3735 if self.xid != None:
3736 q.text("%#x" % self.xid)
3737 else:
3738 q.text('None')
3739 q.text(","); q.breakable()
3740 q.text("role = ");
3741 q.text("%#x" % self.role)
3742 q.breakable()
3743 q.text('}')
3744
3745class packet_in(Message):
3746 version = const.OFP_VERSION
3747 type = const.OFPT_PACKET_IN
3748
Rich Lanec2ee4b82013-04-24 17:12:38 -07003749 def __init__(self, xid=None, buffer_id=None, total_len=None, in_port=None, reason=None, data=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07003750 self.xid = xid
3751 if buffer_id != None:
3752 self.buffer_id = buffer_id
3753 else:
3754 self.buffer_id = 0
3755 if total_len != None:
3756 self.total_len = total_len
3757 else:
3758 self.total_len = 0
3759 if in_port != None:
3760 self.in_port = in_port
3761 else:
3762 self.in_port = 0
3763 if reason != None:
3764 self.reason = reason
3765 else:
3766 self.reason = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07003767 if data != None:
3768 self.data = data
3769 else:
3770 self.data = ""
3771
3772 def pack(self):
3773 packed = []
3774 packed.append(struct.pack("!B", self.version))
3775 packed.append(struct.pack("!B", self.type))
3776 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3777 packed.append(struct.pack("!L", self.xid))
3778 packed.append(struct.pack("!L", self.buffer_id))
3779 packed.append(struct.pack("!H", self.total_len))
3780 packed.append(struct.pack("!H", self.in_port))
3781 packed.append(struct.pack("!B", self.reason))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003782 packed.append('\x00' * 1)
Rich Laneb658ddd2013-03-12 10:15:10 -07003783 packed.append(self.data)
3784 length = sum([len(x) for x in packed])
3785 packed[2] = struct.pack("!H", length)
3786 return ''.join(packed)
3787
3788 @staticmethod
3789 def unpack(buf):
3790 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3791 obj = packet_in()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003792 if type(buf) == loxi.generic_util.OFReader:
3793 reader = buf
3794 else:
3795 reader = loxi.generic_util.OFReader(buf)
3796 _version = reader.read('!B')[0]
3797 assert(_version == const.OFP_VERSION)
3798 _type = reader.read('!B')[0]
3799 assert(_type == const.OFPT_PACKET_IN)
3800 _length = reader.read('!H')[0]
3801 obj.xid = reader.read('!L')[0]
3802 obj.buffer_id = reader.read('!L')[0]
3803 obj.total_len = reader.read('!H')[0]
3804 obj.in_port = reader.read('!H')[0]
3805 obj.reason = reader.read('!B')[0]
3806 reader.skip(1)
3807 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07003808 return obj
3809
3810 def __eq__(self, other):
3811 if type(self) != type(other): return False
3812 if self.version != other.version: return False
3813 if self.type != other.type: return False
3814 if self.xid != other.xid: return False
3815 if self.buffer_id != other.buffer_id: return False
3816 if self.total_len != other.total_len: return False
3817 if self.in_port != other.in_port: return False
3818 if self.reason != other.reason: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07003819 if self.data != other.data: return False
3820 return True
3821
3822 def __ne__(self, other):
3823 return not self.__eq__(other)
3824
3825 def __str__(self):
3826 return self.show()
3827
3828 def show(self):
3829 import loxi.pp
3830 return loxi.pp.pp(self)
3831
3832 def pretty_print(self, q):
3833 q.text("packet_in {")
3834 with q.group():
3835 with q.indent(2):
3836 q.breakable()
3837 q.text("xid = ");
3838 if self.xid != None:
3839 q.text("%#x" % self.xid)
3840 else:
3841 q.text('None')
3842 q.text(","); q.breakable()
3843 q.text("buffer_id = ");
3844 q.text("%#x" % self.buffer_id)
3845 q.text(","); q.breakable()
3846 q.text("total_len = ");
3847 q.text("%#x" % self.total_len)
3848 q.text(","); q.breakable()
3849 q.text("in_port = ");
3850 q.text(util.pretty_port(self.in_port))
3851 q.text(","); q.breakable()
3852 q.text("reason = ");
3853 q.text("%#x" % self.reason)
3854 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07003855 q.text("data = ");
3856 q.pp(self.data)
3857 q.breakable()
3858 q.text('}')
3859
3860class packet_out(Message):
3861 version = const.OFP_VERSION
3862 type = const.OFPT_PACKET_OUT
3863
3864 def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None):
3865 self.xid = xid
3866 if buffer_id != None:
3867 self.buffer_id = buffer_id
3868 else:
Rich Laneff637c92013-04-04 13:57:09 -07003869 self.buffer_id = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07003870 if in_port != None:
3871 self.in_port = in_port
3872 else:
3873 self.in_port = 0
3874 if actions != None:
3875 self.actions = actions
3876 else:
3877 self.actions = []
3878 if data != None:
3879 self.data = data
3880 else:
3881 self.data = ""
3882
3883 def pack(self):
3884 packed = []
3885 packed.append(struct.pack("!B", self.version))
3886 packed.append(struct.pack("!B", self.type))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003887 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
Rich Laneb658ddd2013-03-12 10:15:10 -07003888 packed.append(struct.pack("!L", self.xid))
3889 packed.append(struct.pack("!L", self.buffer_id))
3890 packed.append(struct.pack("!H", self.in_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003891 packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6
3892 packed.append("".join([x.pack() for x in self.actions]))
3893 packed[6] = struct.pack("!H", len(packed[-1]))
Rich Laneb658ddd2013-03-12 10:15:10 -07003894 packed.append(self.data)
3895 length = sum([len(x) for x in packed])
3896 packed[2] = struct.pack("!H", length)
3897 return ''.join(packed)
3898
3899 @staticmethod
3900 def unpack(buf):
3901 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
3902 obj = packet_out()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003903 if type(buf) == loxi.generic_util.OFReader:
3904 reader = buf
3905 else:
3906 reader = loxi.generic_util.OFReader(buf)
3907 _version = reader.read('!B')[0]
3908 assert(_version == const.OFP_VERSION)
3909 _type = reader.read('!B')[0]
3910 assert(_type == const.OFPT_PACKET_OUT)
3911 _length = reader.read('!H')[0]
3912 obj.xid = reader.read('!L')[0]
3913 obj.buffer_id = reader.read('!L')[0]
3914 obj.in_port = reader.read('!H')[0]
3915 _actions_len = reader.read('!H')[0]
3916 obj.actions = action.unpack_list(reader.slice(_actions_len))
3917 obj.data = str(reader.read_all())
Rich Laneb658ddd2013-03-12 10:15:10 -07003918 return obj
3919
3920 def __eq__(self, other):
3921 if type(self) != type(other): return False
3922 if self.version != other.version: return False
3923 if self.type != other.type: return False
3924 if self.xid != other.xid: return False
3925 if self.buffer_id != other.buffer_id: return False
3926 if self.in_port != other.in_port: return False
3927 if self.actions != other.actions: return False
3928 if self.data != other.data: return False
3929 return True
3930
3931 def __ne__(self, other):
3932 return not self.__eq__(other)
3933
3934 def __str__(self):
3935 return self.show()
3936
3937 def show(self):
3938 import loxi.pp
3939 return loxi.pp.pp(self)
3940
3941 def pretty_print(self, q):
3942 q.text("packet_out {")
3943 with q.group():
3944 with q.indent(2):
3945 q.breakable()
3946 q.text("xid = ");
3947 if self.xid != None:
3948 q.text("%#x" % self.xid)
3949 else:
3950 q.text('None')
3951 q.text(","); q.breakable()
3952 q.text("buffer_id = ");
3953 q.text("%#x" % self.buffer_id)
3954 q.text(","); q.breakable()
3955 q.text("in_port = ");
3956 q.text(util.pretty_port(self.in_port))
3957 q.text(","); q.breakable()
3958 q.text("actions = ");
3959 q.pp(self.actions)
3960 q.text(","); q.breakable()
3961 q.text("data = ");
3962 q.pp(self.data)
3963 q.breakable()
3964 q.text('}')
3965
3966class port_mod(Message):
3967 version = const.OFP_VERSION
3968 type = const.OFPT_PORT_MOD
3969
Rich Lanec2ee4b82013-04-24 17:12:38 -07003970 def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07003971 self.xid = xid
3972 if port_no != None:
3973 self.port_no = port_no
3974 else:
3975 self.port_no = 0
3976 if hw_addr != None:
3977 self.hw_addr = hw_addr
3978 else:
3979 self.hw_addr = [0,0,0,0,0,0]
3980 if config != None:
3981 self.config = config
3982 else:
3983 self.config = 0
3984 if mask != None:
3985 self.mask = mask
3986 else:
3987 self.mask = 0
3988 if advertise != None:
3989 self.advertise = advertise
3990 else:
3991 self.advertise = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07003992
3993 def pack(self):
3994 packed = []
3995 packed.append(struct.pack("!B", self.version))
3996 packed.append(struct.pack("!B", self.type))
3997 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3998 packed.append(struct.pack("!L", self.xid))
3999 packed.append(struct.pack("!H", self.port_no))
4000 packed.append(struct.pack("!6B", *self.hw_addr))
4001 packed.append(struct.pack("!L", self.config))
4002 packed.append(struct.pack("!L", self.mask))
4003 packed.append(struct.pack("!L", self.advertise))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004004 packed.append('\x00' * 4)
Rich Laneb658ddd2013-03-12 10:15:10 -07004005 length = sum([len(x) for x in packed])
4006 packed[2] = struct.pack("!H", length)
4007 return ''.join(packed)
4008
4009 @staticmethod
4010 def unpack(buf):
4011 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4012 obj = port_mod()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004013 if type(buf) == loxi.generic_util.OFReader:
4014 reader = buf
4015 else:
4016 reader = loxi.generic_util.OFReader(buf)
4017 _version = reader.read('!B')[0]
4018 assert(_version == const.OFP_VERSION)
4019 _type = reader.read('!B')[0]
4020 assert(_type == const.OFPT_PORT_MOD)
4021 _length = reader.read('!H')[0]
4022 obj.xid = reader.read('!L')[0]
4023 obj.port_no = reader.read('!H')[0]
4024 obj.hw_addr = list(reader.read('!6B'))
4025 obj.config = reader.read('!L')[0]
4026 obj.mask = reader.read('!L')[0]
4027 obj.advertise = reader.read('!L')[0]
4028 reader.skip(4)
Rich Laneb658ddd2013-03-12 10:15:10 -07004029 return obj
4030
4031 def __eq__(self, other):
4032 if type(self) != type(other): return False
4033 if self.version != other.version: return False
4034 if self.type != other.type: return False
4035 if self.xid != other.xid: return False
4036 if self.port_no != other.port_no: return False
4037 if self.hw_addr != other.hw_addr: return False
4038 if self.config != other.config: return False
4039 if self.mask != other.mask: return False
4040 if self.advertise != other.advertise: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07004041 return True
4042
4043 def __ne__(self, other):
4044 return not self.__eq__(other)
4045
4046 def __str__(self):
4047 return self.show()
4048
4049 def show(self):
4050 import loxi.pp
4051 return loxi.pp.pp(self)
4052
4053 def pretty_print(self, q):
4054 q.text("port_mod {")
4055 with q.group():
4056 with q.indent(2):
4057 q.breakable()
4058 q.text("xid = ");
4059 if self.xid != None:
4060 q.text("%#x" % self.xid)
4061 else:
4062 q.text('None')
4063 q.text(","); q.breakable()
4064 q.text("port_no = ");
4065 q.text(util.pretty_port(self.port_no))
4066 q.text(","); q.breakable()
4067 q.text("hw_addr = ");
4068 q.text(util.pretty_mac(self.hw_addr))
4069 q.text(","); q.breakable()
4070 q.text("config = ");
4071 q.text("%#x" % self.config)
4072 q.text(","); q.breakable()
4073 q.text("mask = ");
4074 q.text("%#x" % self.mask)
4075 q.text(","); q.breakable()
4076 q.text("advertise = ");
4077 q.text("%#x" % self.advertise)
Rich Laneb658ddd2013-03-12 10:15:10 -07004078 q.breakable()
4079 q.text('}')
4080
4081class port_stats_reply(Message):
4082 version = const.OFP_VERSION
4083 type = const.OFPT_STATS_REPLY
4084 stats_type = const.OFPST_PORT
4085
4086 def __init__(self, xid=None, flags=None, entries=None):
4087 self.xid = xid
4088 if flags != None:
4089 self.flags = flags
4090 else:
4091 self.flags = 0
4092 if entries != None:
4093 self.entries = entries
4094 else:
4095 self.entries = []
4096
4097 def pack(self):
4098 packed = []
4099 packed.append(struct.pack("!B", self.version))
4100 packed.append(struct.pack("!B", self.type))
4101 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4102 packed.append(struct.pack("!L", self.xid))
4103 packed.append(struct.pack("!H", self.stats_type))
4104 packed.append(struct.pack("!H", self.flags))
4105 packed.append("".join([x.pack() for x in self.entries]))
4106 length = sum([len(x) for x in packed])
4107 packed[2] = struct.pack("!H", length)
4108 return ''.join(packed)
4109
4110 @staticmethod
4111 def unpack(buf):
4112 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4113 obj = port_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004114 if type(buf) == loxi.generic_util.OFReader:
4115 reader = buf
4116 else:
4117 reader = loxi.generic_util.OFReader(buf)
4118 _version = reader.read('!B')[0]
4119 assert(_version == const.OFP_VERSION)
4120 _type = reader.read('!B')[0]
4121 assert(_type == const.OFPT_STATS_REPLY)
4122 _length = reader.read('!H')[0]
4123 obj.xid = reader.read('!L')[0]
4124 _stats_type = reader.read('!H')[0]
4125 assert(_stats_type == const.OFPST_PORT)
4126 obj.flags = reader.read('!H')[0]
4127 obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack)
Rich Laneb658ddd2013-03-12 10:15:10 -07004128 return obj
4129
4130 def __eq__(self, other):
4131 if type(self) != type(other): return False
4132 if self.version != other.version: return False
4133 if self.type != other.type: return False
4134 if self.xid != other.xid: return False
4135 if self.flags != other.flags: return False
4136 if self.entries != other.entries: return False
4137 return True
4138
4139 def __ne__(self, other):
4140 return not self.__eq__(other)
4141
4142 def __str__(self):
4143 return self.show()
4144
4145 def show(self):
4146 import loxi.pp
4147 return loxi.pp.pp(self)
4148
4149 def pretty_print(self, q):
4150 q.text("port_stats_reply {")
4151 with q.group():
4152 with q.indent(2):
4153 q.breakable()
4154 q.text("xid = ");
4155 if self.xid != None:
4156 q.text("%#x" % self.xid)
4157 else:
4158 q.text('None')
4159 q.text(","); q.breakable()
4160 q.text("flags = ");
4161 q.text("%#x" % self.flags)
4162 q.text(","); q.breakable()
4163 q.text("entries = ");
4164 q.pp(self.entries)
4165 q.breakable()
4166 q.text('}')
4167
4168class port_stats_request(Message):
4169 version = const.OFP_VERSION
4170 type = const.OFPT_STATS_REQUEST
4171 stats_type = const.OFPST_PORT
4172
Rich Lanec2ee4b82013-04-24 17:12:38 -07004173 def __init__(self, xid=None, flags=None, port_no=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07004174 self.xid = xid
4175 if flags != None:
4176 self.flags = flags
4177 else:
4178 self.flags = 0
4179 if port_no != None:
4180 self.port_no = port_no
4181 else:
4182 self.port_no = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07004183
4184 def pack(self):
4185 packed = []
4186 packed.append(struct.pack("!B", self.version))
4187 packed.append(struct.pack("!B", self.type))
4188 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4189 packed.append(struct.pack("!L", self.xid))
4190 packed.append(struct.pack("!H", self.stats_type))
4191 packed.append(struct.pack("!H", self.flags))
4192 packed.append(struct.pack("!H", self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004193 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -07004194 length = sum([len(x) for x in packed])
4195 packed[2] = struct.pack("!H", length)
4196 return ''.join(packed)
4197
4198 @staticmethod
4199 def unpack(buf):
4200 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4201 obj = port_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004202 if type(buf) == loxi.generic_util.OFReader:
4203 reader = buf
4204 else:
4205 reader = loxi.generic_util.OFReader(buf)
4206 _version = reader.read('!B')[0]
4207 assert(_version == const.OFP_VERSION)
4208 _type = reader.read('!B')[0]
4209 assert(_type == const.OFPT_STATS_REQUEST)
4210 _length = reader.read('!H')[0]
4211 obj.xid = reader.read('!L')[0]
4212 _stats_type = reader.read('!H')[0]
4213 assert(_stats_type == const.OFPST_PORT)
4214 obj.flags = reader.read('!H')[0]
4215 obj.port_no = reader.read('!H')[0]
4216 reader.skip(6)
Rich Laneb658ddd2013-03-12 10:15:10 -07004217 return obj
4218
4219 def __eq__(self, other):
4220 if type(self) != type(other): return False
4221 if self.version != other.version: return False
4222 if self.type != other.type: return False
4223 if self.xid != other.xid: return False
4224 if self.flags != other.flags: return False
4225 if self.port_no != other.port_no: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07004226 return True
4227
4228 def __ne__(self, other):
4229 return not self.__eq__(other)
4230
4231 def __str__(self):
4232 return self.show()
4233
4234 def show(self):
4235 import loxi.pp
4236 return loxi.pp.pp(self)
4237
4238 def pretty_print(self, q):
4239 q.text("port_stats_request {")
4240 with q.group():
4241 with q.indent(2):
4242 q.breakable()
4243 q.text("xid = ");
4244 if self.xid != None:
4245 q.text("%#x" % self.xid)
4246 else:
4247 q.text('None')
4248 q.text(","); q.breakable()
4249 q.text("flags = ");
4250 q.text("%#x" % self.flags)
4251 q.text(","); q.breakable()
4252 q.text("port_no = ");
4253 q.text(util.pretty_port(self.port_no))
Rich Laneb658ddd2013-03-12 10:15:10 -07004254 q.breakable()
4255 q.text('}')
4256
4257class port_status(Message):
4258 version = const.OFP_VERSION
4259 type = const.OFPT_PORT_STATUS
4260
Rich Lanec2ee4b82013-04-24 17:12:38 -07004261 def __init__(self, xid=None, reason=None, desc=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07004262 self.xid = xid
4263 if reason != None:
4264 self.reason = reason
4265 else:
4266 self.reason = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07004267 if desc != None:
4268 self.desc = desc
4269 else:
4270 self.desc = common.port_desc()
4271
4272 def pack(self):
4273 packed = []
4274 packed.append(struct.pack("!B", self.version))
4275 packed.append(struct.pack("!B", self.type))
4276 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4277 packed.append(struct.pack("!L", self.xid))
4278 packed.append(struct.pack("!B", self.reason))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004279 packed.append('\x00' * 7)
Rich Laneb658ddd2013-03-12 10:15:10 -07004280 packed.append(self.desc.pack())
4281 length = sum([len(x) for x in packed])
4282 packed[2] = struct.pack("!H", length)
4283 return ''.join(packed)
4284
4285 @staticmethod
4286 def unpack(buf):
4287 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4288 obj = port_status()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004289 if type(buf) == loxi.generic_util.OFReader:
4290 reader = buf
4291 else:
4292 reader = loxi.generic_util.OFReader(buf)
4293 _version = reader.read('!B')[0]
4294 assert(_version == const.OFP_VERSION)
4295 _type = reader.read('!B')[0]
4296 assert(_type == const.OFPT_PORT_STATUS)
4297 _length = reader.read('!H')[0]
4298 obj.xid = reader.read('!L')[0]
4299 obj.reason = reader.read('!B')[0]
4300 reader.skip(7)
4301 obj.desc = common.port_desc.unpack(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07004302 return obj
4303
4304 def __eq__(self, other):
4305 if type(self) != type(other): return False
4306 if self.version != other.version: return False
4307 if self.type != other.type: return False
4308 if self.xid != other.xid: return False
4309 if self.reason != other.reason: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07004310 if self.desc != other.desc: return False
4311 return True
4312
4313 def __ne__(self, other):
4314 return not self.__eq__(other)
4315
4316 def __str__(self):
4317 return self.show()
4318
4319 def show(self):
4320 import loxi.pp
4321 return loxi.pp.pp(self)
4322
4323 def pretty_print(self, q):
4324 q.text("port_status {")
4325 with q.group():
4326 with q.indent(2):
4327 q.breakable()
4328 q.text("xid = ");
4329 if self.xid != None:
4330 q.text("%#x" % self.xid)
4331 else:
4332 q.text('None')
4333 q.text(","); q.breakable()
4334 q.text("reason = ");
4335 q.text("%#x" % self.reason)
4336 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07004337 q.text("desc = ");
4338 q.pp(self.desc)
4339 q.breakable()
4340 q.text('}')
4341
4342class queue_get_config_reply(Message):
4343 version = const.OFP_VERSION
4344 type = const.OFPT_QUEUE_GET_CONFIG_REPLY
4345
Rich Lanec2ee4b82013-04-24 17:12:38 -07004346 def __init__(self, xid=None, port=None, queues=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07004347 self.xid = xid
4348 if port != None:
4349 self.port = port
4350 else:
4351 self.port = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07004352 if queues != None:
4353 self.queues = queues
4354 else:
4355 self.queues = []
4356
4357 def pack(self):
4358 packed = []
4359 packed.append(struct.pack("!B", self.version))
4360 packed.append(struct.pack("!B", self.type))
4361 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4362 packed.append(struct.pack("!L", self.xid))
4363 packed.append(struct.pack("!H", self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004364 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -07004365 packed.append("".join([x.pack() for x in self.queues]))
4366 length = sum([len(x) for x in packed])
4367 packed[2] = struct.pack("!H", length)
4368 return ''.join(packed)
4369
4370 @staticmethod
4371 def unpack(buf):
4372 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4373 obj = queue_get_config_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004374 if type(buf) == loxi.generic_util.OFReader:
4375 reader = buf
4376 else:
4377 reader = loxi.generic_util.OFReader(buf)
4378 _version = reader.read('!B')[0]
4379 assert(_version == const.OFP_VERSION)
4380 _type = reader.read('!B')[0]
4381 assert(_type == const.OFPT_QUEUE_GET_CONFIG_REPLY)
4382 _length = reader.read('!H')[0]
4383 obj.xid = reader.read('!L')[0]
4384 obj.port = reader.read('!H')[0]
4385 reader.skip(6)
4386 obj.queues = common.unpack_list_packet_queue(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -07004387 return obj
4388
4389 def __eq__(self, other):
4390 if type(self) != type(other): return False
4391 if self.version != other.version: return False
4392 if self.type != other.type: return False
4393 if self.xid != other.xid: return False
4394 if self.port != other.port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07004395 if self.queues != other.queues: return False
4396 return True
4397
4398 def __ne__(self, other):
4399 return not self.__eq__(other)
4400
4401 def __str__(self):
4402 return self.show()
4403
4404 def show(self):
4405 import loxi.pp
4406 return loxi.pp.pp(self)
4407
4408 def pretty_print(self, q):
4409 q.text("queue_get_config_reply {")
4410 with q.group():
4411 with q.indent(2):
4412 q.breakable()
4413 q.text("xid = ");
4414 if self.xid != None:
4415 q.text("%#x" % self.xid)
4416 else:
4417 q.text('None')
4418 q.text(","); q.breakable()
4419 q.text("port = ");
4420 q.text(util.pretty_port(self.port))
4421 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07004422 q.text("queues = ");
4423 q.pp(self.queues)
4424 q.breakable()
4425 q.text('}')
4426
4427class queue_get_config_request(Message):
4428 version = const.OFP_VERSION
4429 type = const.OFPT_QUEUE_GET_CONFIG_REQUEST
4430
Rich Lanec2ee4b82013-04-24 17:12:38 -07004431 def __init__(self, xid=None, port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07004432 self.xid = xid
4433 if port != None:
4434 self.port = port
4435 else:
4436 self.port = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07004437
4438 def pack(self):
4439 packed = []
4440 packed.append(struct.pack("!B", self.version))
4441 packed.append(struct.pack("!B", self.type))
4442 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4443 packed.append(struct.pack("!L", self.xid))
4444 packed.append(struct.pack("!H", self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004445 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -07004446 length = sum([len(x) for x in packed])
4447 packed[2] = struct.pack("!H", length)
4448 return ''.join(packed)
4449
4450 @staticmethod
4451 def unpack(buf):
4452 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4453 obj = queue_get_config_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004454 if type(buf) == loxi.generic_util.OFReader:
4455 reader = buf
4456 else:
4457 reader = loxi.generic_util.OFReader(buf)
4458 _version = reader.read('!B')[0]
4459 assert(_version == const.OFP_VERSION)
4460 _type = reader.read('!B')[0]
4461 assert(_type == const.OFPT_QUEUE_GET_CONFIG_REQUEST)
4462 _length = reader.read('!H')[0]
4463 obj.xid = reader.read('!L')[0]
4464 obj.port = reader.read('!H')[0]
4465 reader.skip(2)
Rich Laneb658ddd2013-03-12 10:15:10 -07004466 return obj
4467
4468 def __eq__(self, other):
4469 if type(self) != type(other): return False
4470 if self.version != other.version: return False
4471 if self.type != other.type: return False
4472 if self.xid != other.xid: return False
4473 if self.port != other.port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07004474 return True
4475
4476 def __ne__(self, other):
4477 return not self.__eq__(other)
4478
4479 def __str__(self):
4480 return self.show()
4481
4482 def show(self):
4483 import loxi.pp
4484 return loxi.pp.pp(self)
4485
4486 def pretty_print(self, q):
4487 q.text("queue_get_config_request {")
4488 with q.group():
4489 with q.indent(2):
4490 q.breakable()
4491 q.text("xid = ");
4492 if self.xid != None:
4493 q.text("%#x" % self.xid)
4494 else:
4495 q.text('None')
4496 q.text(","); q.breakable()
4497 q.text("port = ");
4498 q.text(util.pretty_port(self.port))
Rich Laneb658ddd2013-03-12 10:15:10 -07004499 q.breakable()
4500 q.text('}')
4501
4502class queue_stats_reply(Message):
4503 version = const.OFP_VERSION
4504 type = const.OFPT_STATS_REPLY
4505 stats_type = const.OFPST_QUEUE
4506
4507 def __init__(self, xid=None, flags=None, entries=None):
4508 self.xid = xid
4509 if flags != None:
4510 self.flags = flags
4511 else:
4512 self.flags = 0
4513 if entries != None:
4514 self.entries = entries
4515 else:
4516 self.entries = []
4517
4518 def pack(self):
4519 packed = []
4520 packed.append(struct.pack("!B", self.version))
4521 packed.append(struct.pack("!B", self.type))
4522 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4523 packed.append(struct.pack("!L", self.xid))
4524 packed.append(struct.pack("!H", self.stats_type))
4525 packed.append(struct.pack("!H", self.flags))
4526 packed.append("".join([x.pack() for x in self.entries]))
4527 length = sum([len(x) for x in packed])
4528 packed[2] = struct.pack("!H", length)
4529 return ''.join(packed)
4530
4531 @staticmethod
4532 def unpack(buf):
4533 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4534 obj = queue_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004535 if type(buf) == loxi.generic_util.OFReader:
4536 reader = buf
4537 else:
4538 reader = loxi.generic_util.OFReader(buf)
4539 _version = reader.read('!B')[0]
4540 assert(_version == const.OFP_VERSION)
4541 _type = reader.read('!B')[0]
4542 assert(_type == const.OFPT_STATS_REPLY)
4543 _length = reader.read('!H')[0]
4544 obj.xid = reader.read('!L')[0]
4545 _stats_type = reader.read('!H')[0]
4546 assert(_stats_type == const.OFPST_QUEUE)
4547 obj.flags = reader.read('!H')[0]
4548 obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack)
Rich Laneb658ddd2013-03-12 10:15:10 -07004549 return obj
4550
4551 def __eq__(self, other):
4552 if type(self) != type(other): return False
4553 if self.version != other.version: return False
4554 if self.type != other.type: return False
4555 if self.xid != other.xid: return False
4556 if self.flags != other.flags: return False
4557 if self.entries != other.entries: return False
4558 return True
4559
4560 def __ne__(self, other):
4561 return not self.__eq__(other)
4562
4563 def __str__(self):
4564 return self.show()
4565
4566 def show(self):
4567 import loxi.pp
4568 return loxi.pp.pp(self)
4569
4570 def pretty_print(self, q):
4571 q.text("queue_stats_reply {")
4572 with q.group():
4573 with q.indent(2):
4574 q.breakable()
4575 q.text("xid = ");
4576 if self.xid != None:
4577 q.text("%#x" % self.xid)
4578 else:
4579 q.text('None')
4580 q.text(","); q.breakable()
4581 q.text("flags = ");
4582 q.text("%#x" % self.flags)
4583 q.text(","); q.breakable()
4584 q.text("entries = ");
4585 q.pp(self.entries)
4586 q.breakable()
4587 q.text('}')
4588
4589class queue_stats_request(Message):
4590 version = const.OFP_VERSION
4591 type = const.OFPT_STATS_REQUEST
4592 stats_type = const.OFPST_QUEUE
4593
Rich Lanec2ee4b82013-04-24 17:12:38 -07004594 def __init__(self, xid=None, flags=None, port_no=None, queue_id=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07004595 self.xid = xid
4596 if flags != None:
4597 self.flags = flags
4598 else:
4599 self.flags = 0
4600 if port_no != None:
4601 self.port_no = port_no
4602 else:
4603 self.port_no = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07004604 if queue_id != None:
4605 self.queue_id = queue_id
4606 else:
4607 self.queue_id = 0
4608
4609 def pack(self):
4610 packed = []
4611 packed.append(struct.pack("!B", self.version))
4612 packed.append(struct.pack("!B", self.type))
4613 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4614 packed.append(struct.pack("!L", self.xid))
4615 packed.append(struct.pack("!H", self.stats_type))
4616 packed.append(struct.pack("!H", self.flags))
4617 packed.append(struct.pack("!H", self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004618 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -07004619 packed.append(struct.pack("!L", self.queue_id))
4620 length = sum([len(x) for x in packed])
4621 packed[2] = struct.pack("!H", length)
4622 return ''.join(packed)
4623
4624 @staticmethod
4625 def unpack(buf):
4626 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4627 obj = queue_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004628 if type(buf) == loxi.generic_util.OFReader:
4629 reader = buf
4630 else:
4631 reader = loxi.generic_util.OFReader(buf)
4632 _version = reader.read('!B')[0]
4633 assert(_version == const.OFP_VERSION)
4634 _type = reader.read('!B')[0]
4635 assert(_type == const.OFPT_STATS_REQUEST)
4636 _length = reader.read('!H')[0]
4637 obj.xid = reader.read('!L')[0]
4638 _stats_type = reader.read('!H')[0]
4639 assert(_stats_type == const.OFPST_QUEUE)
4640 obj.flags = reader.read('!H')[0]
4641 obj.port_no = reader.read('!H')[0]
4642 reader.skip(2)
4643 obj.queue_id = reader.read('!L')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07004644 return obj
4645
4646 def __eq__(self, other):
4647 if type(self) != type(other): return False
4648 if self.version != other.version: return False
4649 if self.type != other.type: return False
4650 if self.xid != other.xid: return False
4651 if self.flags != other.flags: return False
4652 if self.port_no != other.port_no: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07004653 if self.queue_id != other.queue_id: return False
4654 return True
4655
4656 def __ne__(self, other):
4657 return not self.__eq__(other)
4658
4659 def __str__(self):
4660 return self.show()
4661
4662 def show(self):
4663 import loxi.pp
4664 return loxi.pp.pp(self)
4665
4666 def pretty_print(self, q):
4667 q.text("queue_stats_request {")
4668 with q.group():
4669 with q.indent(2):
4670 q.breakable()
4671 q.text("xid = ");
4672 if self.xid != None:
4673 q.text("%#x" % self.xid)
4674 else:
4675 q.text('None')
4676 q.text(","); q.breakable()
4677 q.text("flags = ");
4678 q.text("%#x" % self.flags)
4679 q.text(","); q.breakable()
4680 q.text("port_no = ");
4681 q.text(util.pretty_port(self.port_no))
4682 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07004683 q.text("queue_id = ");
4684 q.text("%#x" % self.queue_id)
4685 q.breakable()
4686 q.text('}')
4687
4688class set_config(Message):
4689 version = const.OFP_VERSION
4690 type = const.OFPT_SET_CONFIG
4691
4692 def __init__(self, xid=None, flags=None, miss_send_len=None):
4693 self.xid = xid
4694 if flags != None:
4695 self.flags = flags
4696 else:
4697 self.flags = 0
4698 if miss_send_len != None:
4699 self.miss_send_len = miss_send_len
4700 else:
4701 self.miss_send_len = 0
4702
4703 def pack(self):
4704 packed = []
4705 packed.append(struct.pack("!B", self.version))
4706 packed.append(struct.pack("!B", self.type))
4707 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4708 packed.append(struct.pack("!L", self.xid))
4709 packed.append(struct.pack("!H", self.flags))
4710 packed.append(struct.pack("!H", self.miss_send_len))
4711 length = sum([len(x) for x in packed])
4712 packed[2] = struct.pack("!H", length)
4713 return ''.join(packed)
4714
4715 @staticmethod
4716 def unpack(buf):
4717 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4718 obj = set_config()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004719 if type(buf) == loxi.generic_util.OFReader:
4720 reader = buf
4721 else:
4722 reader = loxi.generic_util.OFReader(buf)
4723 _version = reader.read('!B')[0]
4724 assert(_version == const.OFP_VERSION)
4725 _type = reader.read('!B')[0]
4726 assert(_type == const.OFPT_SET_CONFIG)
4727 _length = reader.read('!H')[0]
4728 obj.xid = reader.read('!L')[0]
4729 obj.flags = reader.read('!H')[0]
4730 obj.miss_send_len = reader.read('!H')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07004731 return obj
4732
4733 def __eq__(self, other):
4734 if type(self) != type(other): return False
4735 if self.version != other.version: return False
4736 if self.type != other.type: return False
4737 if self.xid != other.xid: return False
4738 if self.flags != other.flags: return False
4739 if self.miss_send_len != other.miss_send_len: return False
4740 return True
4741
4742 def __ne__(self, other):
4743 return not self.__eq__(other)
4744
4745 def __str__(self):
4746 return self.show()
4747
4748 def show(self):
4749 import loxi.pp
4750 return loxi.pp.pp(self)
4751
4752 def pretty_print(self, q):
4753 q.text("set_config {")
4754 with q.group():
4755 with q.indent(2):
4756 q.breakable()
4757 q.text("xid = ");
4758 if self.xid != None:
4759 q.text("%#x" % self.xid)
4760 else:
4761 q.text('None')
4762 q.text(","); q.breakable()
4763 q.text("flags = ");
4764 q.text("%#x" % self.flags)
4765 q.text(","); q.breakable()
4766 q.text("miss_send_len = ");
4767 q.text("%#x" % self.miss_send_len)
4768 q.breakable()
4769 q.text('}')
4770
4771class table_mod(Message):
4772 version = const.OFP_VERSION
4773 type = 22
4774
Rich Lanec2ee4b82013-04-24 17:12:38 -07004775 def __init__(self, xid=None, table_id=None, config=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07004776 self.xid = xid
4777 if table_id != None:
4778 self.table_id = table_id
4779 else:
4780 self.table_id = 0
Rich Laneb658ddd2013-03-12 10:15:10 -07004781 if config != None:
4782 self.config = config
4783 else:
4784 self.config = 0
4785
4786 def pack(self):
4787 packed = []
4788 packed.append(struct.pack("!B", self.version))
4789 packed.append(struct.pack("!B", self.type))
4790 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4791 packed.append(struct.pack("!L", self.xid))
4792 packed.append(struct.pack("!B", self.table_id))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004793 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -07004794 packed.append(struct.pack("!L", self.config))
4795 length = sum([len(x) for x in packed])
4796 packed[2] = struct.pack("!H", length)
4797 return ''.join(packed)
4798
4799 @staticmethod
4800 def unpack(buf):
4801 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4802 obj = table_mod()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004803 if type(buf) == loxi.generic_util.OFReader:
4804 reader = buf
4805 else:
4806 reader = loxi.generic_util.OFReader(buf)
4807 _version = reader.read('!B')[0]
4808 assert(_version == const.OFP_VERSION)
4809 _type = reader.read('!B')[0]
4810 assert(_type == 22)
4811 _length = reader.read('!H')[0]
4812 obj.xid = reader.read('!L')[0]
4813 obj.table_id = reader.read('!B')[0]
4814 reader.skip(3)
4815 obj.config = reader.read('!L')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07004816 return obj
4817
4818 def __eq__(self, other):
4819 if type(self) != type(other): return False
4820 if self.version != other.version: return False
4821 if self.type != other.type: return False
4822 if self.xid != other.xid: return False
4823 if self.table_id != other.table_id: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07004824 if self.config != other.config: return False
4825 return True
4826
4827 def __ne__(self, other):
4828 return not self.__eq__(other)
4829
4830 def __str__(self):
4831 return self.show()
4832
4833 def show(self):
4834 import loxi.pp
4835 return loxi.pp.pp(self)
4836
4837 def pretty_print(self, q):
4838 q.text("table_mod {")
4839 with q.group():
4840 with q.indent(2):
4841 q.breakable()
4842 q.text("xid = ");
4843 if self.xid != None:
4844 q.text("%#x" % self.xid)
4845 else:
4846 q.text('None')
4847 q.text(","); q.breakable()
4848 q.text("table_id = ");
4849 q.text("%#x" % self.table_id)
4850 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07004851 q.text("config = ");
4852 q.text("%#x" % self.config)
4853 q.breakable()
4854 q.text('}')
4855
4856class table_stats_reply(Message):
4857 version = const.OFP_VERSION
4858 type = const.OFPT_STATS_REPLY
4859 stats_type = const.OFPST_TABLE
4860
4861 def __init__(self, xid=None, flags=None, entries=None):
4862 self.xid = xid
4863 if flags != None:
4864 self.flags = flags
4865 else:
4866 self.flags = 0
4867 if entries != None:
4868 self.entries = entries
4869 else:
4870 self.entries = []
4871
4872 def pack(self):
4873 packed = []
4874 packed.append(struct.pack("!B", self.version))
4875 packed.append(struct.pack("!B", self.type))
4876 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4877 packed.append(struct.pack("!L", self.xid))
4878 packed.append(struct.pack("!H", self.stats_type))
4879 packed.append(struct.pack("!H", self.flags))
4880 packed.append("".join([x.pack() for x in self.entries]))
4881 length = sum([len(x) for x in packed])
4882 packed[2] = struct.pack("!H", length)
4883 return ''.join(packed)
4884
4885 @staticmethod
4886 def unpack(buf):
4887 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4888 obj = table_stats_reply()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004889 if type(buf) == loxi.generic_util.OFReader:
4890 reader = buf
4891 else:
4892 reader = loxi.generic_util.OFReader(buf)
4893 _version = reader.read('!B')[0]
4894 assert(_version == const.OFP_VERSION)
4895 _type = reader.read('!B')[0]
4896 assert(_type == const.OFPT_STATS_REPLY)
4897 _length = reader.read('!H')[0]
4898 obj.xid = reader.read('!L')[0]
4899 _stats_type = reader.read('!H')[0]
4900 assert(_stats_type == const.OFPST_TABLE)
4901 obj.flags = reader.read('!H')[0]
4902 obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack)
Rich Laneb658ddd2013-03-12 10:15:10 -07004903 return obj
4904
4905 def __eq__(self, other):
4906 if type(self) != type(other): return False
4907 if self.version != other.version: return False
4908 if self.type != other.type: return False
4909 if self.xid != other.xid: return False
4910 if self.flags != other.flags: return False
4911 if self.entries != other.entries: return False
4912 return True
4913
4914 def __ne__(self, other):
4915 return not self.__eq__(other)
4916
4917 def __str__(self):
4918 return self.show()
4919
4920 def show(self):
4921 import loxi.pp
4922 return loxi.pp.pp(self)
4923
4924 def pretty_print(self, q):
4925 q.text("table_stats_reply {")
4926 with q.group():
4927 with q.indent(2):
4928 q.breakable()
4929 q.text("xid = ");
4930 if self.xid != None:
4931 q.text("%#x" % self.xid)
4932 else:
4933 q.text('None')
4934 q.text(","); q.breakable()
4935 q.text("flags = ");
4936 q.text("%#x" % self.flags)
4937 q.text(","); q.breakable()
4938 q.text("entries = ");
4939 q.pp(self.entries)
4940 q.breakable()
4941 q.text('}')
4942
4943class table_stats_request(Message):
4944 version = const.OFP_VERSION
4945 type = const.OFPT_STATS_REQUEST
4946 stats_type = const.OFPST_TABLE
4947
4948 def __init__(self, xid=None, flags=None):
4949 self.xid = xid
4950 if flags != None:
4951 self.flags = flags
4952 else:
4953 self.flags = 0
4954
4955 def pack(self):
4956 packed = []
4957 packed.append(struct.pack("!B", self.version))
4958 packed.append(struct.pack("!B", self.type))
4959 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4960 packed.append(struct.pack("!L", self.xid))
4961 packed.append(struct.pack("!H", self.stats_type))
4962 packed.append(struct.pack("!H", self.flags))
4963 length = sum([len(x) for x in packed])
4964 packed[2] = struct.pack("!H", length)
4965 return ''.join(packed)
4966
4967 @staticmethod
4968 def unpack(buf):
4969 if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
4970 obj = table_stats_request()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004971 if type(buf) == loxi.generic_util.OFReader:
4972 reader = buf
4973 else:
4974 reader = loxi.generic_util.OFReader(buf)
4975 _version = reader.read('!B')[0]
4976 assert(_version == const.OFP_VERSION)
4977 _type = reader.read('!B')[0]
4978 assert(_type == const.OFPT_STATS_REQUEST)
4979 _length = reader.read('!H')[0]
4980 obj.xid = reader.read('!L')[0]
4981 _stats_type = reader.read('!H')[0]
4982 assert(_stats_type == const.OFPST_TABLE)
4983 obj.flags = reader.read('!H')[0]
Rich Laneb658ddd2013-03-12 10:15:10 -07004984 return obj
4985
4986 def __eq__(self, other):
4987 if type(self) != type(other): return False
4988 if self.version != other.version: return False
4989 if self.type != other.type: return False
4990 if self.xid != other.xid: return False
4991 if self.flags != other.flags: return False
4992 return True
4993
4994 def __ne__(self, other):
4995 return not self.__eq__(other)
4996
4997 def __str__(self):
4998 return self.show()
4999
5000 def show(self):
5001 import loxi.pp
5002 return loxi.pp.pp(self)
5003
5004 def pretty_print(self, q):
5005 q.text("table_stats_request {")
5006 with q.group():
5007 with q.indent(2):
5008 q.breakable()
5009 q.text("xid = ");
5010 if self.xid != None:
5011 q.text("%#x" % self.xid)
5012 else:
5013 q.text('None')
5014 q.text(","); q.breakable()
5015 q.text("flags = ");
5016 q.text("%#x" % self.flags)
5017 q.breakable()
5018 q.text('}')
5019
5020
5021def parse_header(buf):
5022 if len(buf) < 8:
5023 raise loxi.ProtocolError("too short to be an OpenFlow message")
5024 return struct.unpack_from("!BBHL", buf)
5025
5026def parse_message(buf):
5027 msg_ver, msg_type, msg_len, msg_xid = parse_header(buf)
5028 if msg_ver != const.OFP_VERSION and msg_type != ofp.OFPT_HELLO:
5029 raise loxi.ProtocolError("wrong OpenFlow version")
5030 if len(buf) != msg_len:
5031 raise loxi.ProtocolError("incorrect message size")
5032 if msg_type in parsers:
5033 return parsers[msg_type](buf)
5034 else:
5035 raise loxi.ProtocolError("unexpected message type")
5036
5037def parse_flow_mod(buf):
5038 if len(buf) < 56 + 2:
5039 raise loxi.ProtocolError("message too short")
5040 cmd, = struct.unpack_from("!H", buf, 56)
5041 if cmd in flow_mod_parsers:
5042 return flow_mod_parsers[cmd](buf)
5043 else:
5044 raise loxi.ProtocolError("unexpected flow mod cmd %u" % cmd)
5045
5046def parse_stats_reply(buf):
5047 if len(buf) < 8 + 2:
5048 raise loxi.ProtocolError("message too short")
5049 stats_type, = struct.unpack_from("!H", buf, 8)
5050 if stats_type in stats_reply_parsers:
5051 return stats_reply_parsers[stats_type](buf)
5052 else:
5053 raise loxi.ProtocolError("unexpected stats type %u" % stats_type)
5054
5055def parse_stats_request(buf):
5056 if len(buf) < 8 + 2:
5057 raise loxi.ProtocolError("message too short")
5058 stats_type, = struct.unpack_from("!H", buf, 8)
5059 if stats_type in stats_request_parsers:
5060 return stats_request_parsers[stats_type](buf)
5061 else:
5062 raise loxi.ProtocolError("unexpected stats type %u" % stats_type)
5063
5064def parse_vendor(buf):
5065 if len(buf) < 16:
5066 raise loxi.ProtocolError("experimenter message too short")
5067
5068 experimenter, = struct.unpack_from("!L", buf, 8)
5069 if experimenter == 0x005c16c7: # Big Switch Networks
5070 subtype, = struct.unpack_from("!L", buf, 12)
5071 elif experimenter == 0x00002320: # Nicira
5072 subtype, = struct.unpack_from("!L", buf, 12)
5073 else:
5074 raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter)
5075
5076 if subtype in experimenter_parsers[experimenter]:
5077 return experimenter_parsers[experimenter][subtype](buf)
5078 else:
5079 raise loxi.ProtocolError("unexpected experimenter %#x subtype %#x" % (experimenter, subtype))
5080
5081parsers = {
5082 22 : table_mod.unpack,
5083 const.OFPT_BARRIER_REPLY : barrier_reply.unpack,
5084 const.OFPT_BARRIER_REQUEST : barrier_request.unpack,
5085 const.OFPT_ECHO_REPLY : echo_reply.unpack,
5086 const.OFPT_ECHO_REQUEST : echo_request.unpack,
5087 const.OFPT_ERROR : error_msg.unpack,
5088 const.OFPT_FEATURES_REPLY : features_reply.unpack,
5089 const.OFPT_FEATURES_REQUEST : features_request.unpack,
5090 const.OFPT_FLOW_MOD : parse_flow_mod,
5091 const.OFPT_FLOW_REMOVED : flow_removed.unpack,
5092 const.OFPT_GET_CONFIG_REPLY : get_config_reply.unpack,
5093 const.OFPT_GET_CONFIG_REQUEST : get_config_request.unpack,
5094 const.OFPT_HELLO : hello.unpack,
5095 const.OFPT_PACKET_IN : packet_in.unpack,
5096 const.OFPT_PACKET_OUT : packet_out.unpack,
5097 const.OFPT_PORT_MOD : port_mod.unpack,
5098 const.OFPT_PORT_STATUS : port_status.unpack,
5099 const.OFPT_QUEUE_GET_CONFIG_REPLY : queue_get_config_reply.unpack,
5100 const.OFPT_QUEUE_GET_CONFIG_REQUEST : queue_get_config_request.unpack,
5101 const.OFPT_SET_CONFIG : set_config.unpack,
5102 const.OFPT_STATS_REPLY : parse_stats_reply,
5103 const.OFPT_STATS_REQUEST : parse_stats_request,
5104 const.OFPT_VENDOR : parse_vendor,
5105}
5106
5107flow_mod_parsers = {
5108 const.OFPFC_ADD : flow_add.unpack,
5109 const.OFPFC_MODIFY : flow_modify.unpack,
5110 const.OFPFC_MODIFY_STRICT : flow_modify_strict.unpack,
5111 const.OFPFC_DELETE : flow_delete.unpack,
5112 const.OFPFC_DELETE_STRICT : flow_delete_strict.unpack,
5113}
5114
5115stats_reply_parsers = {
5116 const.OFPST_DESC : desc_stats_reply.unpack,
5117 const.OFPST_FLOW : flow_stats_reply.unpack,
5118 const.OFPST_AGGREGATE : aggregate_stats_reply.unpack,
5119 const.OFPST_TABLE : table_stats_reply.unpack,
5120 const.OFPST_PORT : port_stats_reply.unpack,
5121 const.OFPST_QUEUE : queue_stats_reply.unpack,
5122 const.OFPST_VENDOR : experimenter_stats_reply.unpack,
5123}
5124
5125stats_request_parsers = {
5126 const.OFPST_DESC : desc_stats_request.unpack,
5127 const.OFPST_FLOW : flow_stats_request.unpack,
5128 const.OFPST_AGGREGATE : aggregate_stats_request.unpack,
5129 const.OFPST_TABLE : table_stats_request.unpack,
5130 const.OFPST_PORT : port_stats_request.unpack,
5131 const.OFPST_QUEUE : queue_stats_request.unpack,
5132 const.OFPST_VENDOR : experimenter_stats_request.unpack,
5133}
5134
5135experimenter_parsers = {
5136 0x2320 : {
5137 11: nicira_controller_role_reply.unpack,
5138 10: nicira_controller_role_request.unpack,
5139 },
5140 0x5c16c7 : {
5141 10: bsn_get_interfaces_reply.unpack,
5142 9: bsn_get_interfaces_request.unpack,
5143 2: bsn_get_ip_mask_reply.unpack,
5144 1: bsn_get_ip_mask_request.unpack,
5145 5: bsn_get_mirroring_reply.unpack,
5146 4: bsn_get_mirroring_request.unpack,
5147 0: bsn_set_ip_mask.unpack,
5148 3: bsn_set_mirroring.unpack,
Rich Lanec2ee4b82013-04-24 17:12:38 -07005149 11: bsn_set_pktin_suppression.unpack,
Rich Laneb658ddd2013-03-12 10:15:10 -07005150 6: bsn_shell_command.unpack,
5151 7: bsn_shell_output.unpack,
5152 8: bsn_shell_status.unpack,
5153 },
5154}