blob: f9586f7ec024e8d6942dbb6f716af0ba7f31863f [file] [log] [blame]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2# Copyright (c) 2011, 2012 Open Networking Foundation
3# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
Dan Talaycof6202252013-07-02 01:00:29 -07004# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Lanec2ee4b82013-04-24 17:12:38 -07005
Rich Lane7dcdf022013-12-11 14:45:27 -08006# Automatically generated by LOXI from template module.py
Rich Lanec2ee4b82013-04-24 17:12:38 -07007# Do not modify
8
9import struct
10import loxi
Rich Lanec2ee4b82013-04-24 17:12:38 -070011import util
12import loxi.generic_util
13
Rich Lanee2567702015-01-26 15:04:35 -080014import sys
15ofp = sys.modules['loxi.of11']
16
Rich Lane7dcdf022013-12-11 14:45:27 -080017class message(loxi.OFObject):
18 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070019
Rich Lane95f7fc92014-01-27 17:08:16 -080020 version = 2
21
22 def __init__(self, type=None, xid=None):
23 if type != None:
24 self.type = type
25 else:
26 self.type = 0
27 if xid != None:
28 self.xid = xid
29 else:
30 self.xid = None
31 return
32
33 def pack(self):
34 packed = []
35 packed.append(struct.pack("!B", self.version))
36 packed.append(struct.pack("!B", self.type))
37 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
38 packed.append(struct.pack("!L", self.xid))
39 length = sum([len(x) for x in packed])
40 packed[2] = struct.pack("!H", length)
41 return ''.join(packed)
42
Rich Lane7dcdf022013-12-11 14:45:27 -080043 @staticmethod
44 def unpack(reader):
45 subtype, = reader.peek('B', 1)
Rich Lane95f7fc92014-01-27 17:08:16 -080046 subclass = message.subtypes.get(subtype)
47 if subclass:
48 return subclass.unpack(reader)
49
50 obj = message()
51 _version = reader.read("!B")[0]
52 assert(_version == 2)
53 obj.type = reader.read("!B")[0]
54 _length = reader.read("!H")[0]
55 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -080056 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080057 obj.xid = reader.read("!L")[0]
58 return obj
59
60 def __eq__(self, other):
61 if type(self) != type(other): return False
62 if self.type != other.type: return False
63 if self.xid != other.xid: return False
64 return True
65
66 def pretty_print(self, q):
67 q.text("message {")
68 with q.group():
69 with q.indent(2):
70 q.breakable()
71 q.text("xid = ");
72 if self.xid != None:
73 q.text("%#x" % self.xid)
74 else:
75 q.text('None')
76 q.breakable()
77 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -080078
79
80class stats_reply(message):
81 subtypes = {}
82
Rich Lane95f7fc92014-01-27 17:08:16 -080083 version = 2
84 type = 19
85
86 def __init__(self, xid=None, stats_type=None, flags=None):
87 if xid != None:
88 self.xid = xid
89 else:
90 self.xid = None
91 if stats_type != None:
92 self.stats_type = stats_type
93 else:
94 self.stats_type = 0
95 if flags != None:
96 self.flags = flags
97 else:
98 self.flags = 0
99 return
100
101 def pack(self):
102 packed = []
103 packed.append(struct.pack("!B", self.version))
104 packed.append(struct.pack("!B", self.type))
105 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
106 packed.append(struct.pack("!L", self.xid))
107 packed.append(struct.pack("!H", self.stats_type))
108 packed.append(struct.pack("!H", self.flags))
109 packed.append('\x00' * 4)
110 length = sum([len(x) for x in packed])
111 packed[2] = struct.pack("!H", length)
112 return ''.join(packed)
113
Rich Lane7dcdf022013-12-11 14:45:27 -0800114 @staticmethod
115 def unpack(reader):
116 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800117 subclass = stats_reply.subtypes.get(subtype)
118 if subclass:
119 return subclass.unpack(reader)
120
121 obj = stats_reply()
122 _version = reader.read("!B")[0]
123 assert(_version == 2)
124 _type = reader.read("!B")[0]
125 assert(_type == 19)
126 _length = reader.read("!H")[0]
127 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800128 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800129 obj.xid = reader.read("!L")[0]
130 obj.stats_type = reader.read("!H")[0]
131 obj.flags = reader.read("!H")[0]
132 reader.skip(4)
133 return obj
134
135 def __eq__(self, other):
136 if type(self) != type(other): return False
137 if self.xid != other.xid: return False
138 if self.stats_type != other.stats_type: return False
139 if self.flags != other.flags: return False
140 return True
141
142 def pretty_print(self, q):
143 q.text("stats_reply {")
144 with q.group():
145 with q.indent(2):
146 q.breakable()
147 q.text("xid = ");
148 if self.xid != None:
149 q.text("%#x" % self.xid)
150 else:
151 q.text('None')
152 q.text(","); q.breakable()
153 q.text("flags = ");
154 q.text("%#x" % self.flags)
155 q.breakable()
156 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800157
158message.subtypes[19] = stats_reply
159
160class aggregate_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -0700161 version = 2
162 type = 19
163 stats_type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -0700164
165 def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800166 if xid != None:
167 self.xid = xid
168 else:
169 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -0700170 if flags != None:
171 self.flags = flags
172 else:
173 self.flags = 0
174 if packet_count != None:
175 self.packet_count = packet_count
176 else:
177 self.packet_count = 0
178 if byte_count != None:
179 self.byte_count = byte_count
180 else:
181 self.byte_count = 0
182 if flow_count != None:
183 self.flow_count = flow_count
184 else:
185 self.flow_count = 0
Rich Lane7dcdf022013-12-11 14:45:27 -0800186 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700187
188 def pack(self):
189 packed = []
190 packed.append(struct.pack("!B", self.version))
191 packed.append(struct.pack("!B", self.type))
192 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
193 packed.append(struct.pack("!L", self.xid))
194 packed.append(struct.pack("!H", self.stats_type))
195 packed.append(struct.pack("!H", self.flags))
196 packed.append('\x00' * 4)
197 packed.append(struct.pack("!Q", self.packet_count))
198 packed.append(struct.pack("!Q", self.byte_count))
199 packed.append(struct.pack("!L", self.flow_count))
200 packed.append('\x00' * 4)
201 length = sum([len(x) for x in packed])
202 packed[2] = struct.pack("!H", length)
203 return ''.join(packed)
204
205 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800206 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700207 obj = aggregate_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -0700208 _version = reader.read("!B")[0]
209 assert(_version == 2)
210 _type = reader.read("!B")[0]
211 assert(_type == 19)
212 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800213 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800214 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700215 obj.xid = reader.read("!L")[0]
216 _stats_type = reader.read("!H")[0]
217 assert(_stats_type == 2)
218 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700219 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700220 obj.packet_count = reader.read("!Q")[0]
221 obj.byte_count = reader.read("!Q")[0]
222 obj.flow_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700223 reader.skip(4)
224 return obj
225
226 def __eq__(self, other):
227 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700228 if self.xid != other.xid: return False
229 if self.flags != other.flags: return False
230 if self.packet_count != other.packet_count: return False
231 if self.byte_count != other.byte_count: return False
232 if self.flow_count != other.flow_count: return False
233 return True
234
Rich Lanec2ee4b82013-04-24 17:12:38 -0700235 def pretty_print(self, q):
236 q.text("aggregate_stats_reply {")
237 with q.group():
238 with q.indent(2):
239 q.breakable()
240 q.text("xid = ");
241 if self.xid != None:
242 q.text("%#x" % self.xid)
243 else:
244 q.text('None')
245 q.text(","); q.breakable()
246 q.text("flags = ");
247 q.text("%#x" % self.flags)
248 q.text(","); q.breakable()
249 q.text("packet_count = ");
250 q.text("%#x" % self.packet_count)
251 q.text(","); q.breakable()
252 q.text("byte_count = ");
253 q.text("%#x" % self.byte_count)
254 q.text(","); q.breakable()
255 q.text("flow_count = ");
256 q.text("%#x" % self.flow_count)
257 q.breakable()
258 q.text('}')
259
Rich Lane7dcdf022013-12-11 14:45:27 -0800260stats_reply.subtypes[2] = aggregate_stats_reply
261
262class stats_request(message):
263 subtypes = {}
264
Rich Lane95f7fc92014-01-27 17:08:16 -0800265 version = 2
266 type = 18
267
268 def __init__(self, xid=None, stats_type=None, flags=None):
269 if xid != None:
270 self.xid = xid
271 else:
272 self.xid = None
273 if stats_type != None:
274 self.stats_type = stats_type
275 else:
276 self.stats_type = 0
277 if flags != None:
278 self.flags = flags
279 else:
280 self.flags = 0
281 return
282
283 def pack(self):
284 packed = []
285 packed.append(struct.pack("!B", self.version))
286 packed.append(struct.pack("!B", self.type))
287 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
288 packed.append(struct.pack("!L", self.xid))
289 packed.append(struct.pack("!H", self.stats_type))
290 packed.append(struct.pack("!H", self.flags))
291 packed.append('\x00' * 4)
292 length = sum([len(x) for x in packed])
293 packed[2] = struct.pack("!H", length)
294 return ''.join(packed)
295
Rich Lane7dcdf022013-12-11 14:45:27 -0800296 @staticmethod
297 def unpack(reader):
298 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800299 subclass = stats_request.subtypes.get(subtype)
300 if subclass:
301 return subclass.unpack(reader)
302
303 obj = stats_request()
304 _version = reader.read("!B")[0]
305 assert(_version == 2)
306 _type = reader.read("!B")[0]
307 assert(_type == 18)
308 _length = reader.read("!H")[0]
309 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800310 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800311 obj.xid = reader.read("!L")[0]
312 obj.stats_type = reader.read("!H")[0]
313 obj.flags = reader.read("!H")[0]
314 reader.skip(4)
315 return obj
316
317 def __eq__(self, other):
318 if type(self) != type(other): return False
319 if self.xid != other.xid: return False
320 if self.stats_type != other.stats_type: return False
321 if self.flags != other.flags: return False
322 return True
323
324 def pretty_print(self, q):
325 q.text("stats_request {")
326 with q.group():
327 with q.indent(2):
328 q.breakable()
329 q.text("xid = ");
330 if self.xid != None:
331 q.text("%#x" % self.xid)
332 else:
333 q.text('None')
334 q.text(","); q.breakable()
335 q.text("flags = ");
336 q.text("%#x" % self.flags)
337 q.breakable()
338 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800339
340message.subtypes[18] = stats_request
341
342class aggregate_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -0700343 version = 2
344 type = 18
345 stats_type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -0700346
347 def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800348 if xid != None:
349 self.xid = xid
350 else:
351 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -0700352 if flags != None:
353 self.flags = flags
354 else:
355 self.flags = 0
356 if table_id != None:
357 self.table_id = table_id
358 else:
359 self.table_id = 0
360 if out_port != None:
361 self.out_port = out_port
362 else:
363 self.out_port = 0
364 if out_group != None:
365 self.out_group = out_group
366 else:
367 self.out_group = 0
368 if cookie != None:
369 self.cookie = cookie
370 else:
371 self.cookie = 0
372 if cookie_mask != None:
373 self.cookie_mask = cookie_mask
374 else:
375 self.cookie_mask = 0
376 if match != None:
377 self.match = match
378 else:
Rich Lanee2567702015-01-26 15:04:35 -0800379 self.match = ofp.match()
Rich Lane7dcdf022013-12-11 14:45:27 -0800380 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700381
382 def pack(self):
383 packed = []
384 packed.append(struct.pack("!B", self.version))
385 packed.append(struct.pack("!B", self.type))
386 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
387 packed.append(struct.pack("!L", self.xid))
388 packed.append(struct.pack("!H", self.stats_type))
389 packed.append(struct.pack("!H", self.flags))
390 packed.append('\x00' * 4)
391 packed.append(struct.pack("!B", self.table_id))
392 packed.append('\x00' * 3)
Dan Talaycof6202252013-07-02 01:00:29 -0700393 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700394 packed.append(struct.pack("!L", self.out_group))
395 packed.append('\x00' * 4)
396 packed.append(struct.pack("!Q", self.cookie))
397 packed.append(struct.pack("!Q", self.cookie_mask))
398 packed.append(self.match.pack())
399 length = sum([len(x) for x in packed])
400 packed[2] = struct.pack("!H", length)
401 return ''.join(packed)
402
403 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800404 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700405 obj = aggregate_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700406 _version = reader.read("!B")[0]
407 assert(_version == 2)
408 _type = reader.read("!B")[0]
409 assert(_type == 18)
410 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800411 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800412 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700413 obj.xid = reader.read("!L")[0]
414 _stats_type = reader.read("!H")[0]
415 assert(_stats_type == 2)
416 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700417 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700418 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700419 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -0700420 obj.out_port = util.unpack_port_no(reader)
421 obj.out_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700422 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700423 obj.cookie = reader.read("!Q")[0]
424 obj.cookie_mask = reader.read("!Q")[0]
Rich Lanee2567702015-01-26 15:04:35 -0800425 obj.match = ofp.match.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700426 return obj
427
428 def __eq__(self, other):
429 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700430 if self.xid != other.xid: return False
431 if self.flags != other.flags: return False
432 if self.table_id != other.table_id: return False
433 if self.out_port != other.out_port: return False
434 if self.out_group != other.out_group: return False
435 if self.cookie != other.cookie: return False
436 if self.cookie_mask != other.cookie_mask: return False
437 if self.match != other.match: return False
438 return True
439
Rich Lanec2ee4b82013-04-24 17:12:38 -0700440 def pretty_print(self, q):
441 q.text("aggregate_stats_request {")
442 with q.group():
443 with q.indent(2):
444 q.breakable()
445 q.text("xid = ");
446 if self.xid != None:
447 q.text("%#x" % self.xid)
448 else:
449 q.text('None')
450 q.text(","); q.breakable()
451 q.text("flags = ");
452 q.text("%#x" % self.flags)
453 q.text(","); q.breakable()
454 q.text("table_id = ");
455 q.text("%#x" % self.table_id)
456 q.text(","); q.breakable()
457 q.text("out_port = ");
458 q.text(util.pretty_port(self.out_port))
459 q.text(","); q.breakable()
460 q.text("out_group = ");
461 q.text("%#x" % self.out_group)
462 q.text(","); q.breakable()
463 q.text("cookie = ");
464 q.text("%#x" % self.cookie)
465 q.text(","); q.breakable()
466 q.text("cookie_mask = ");
467 q.text("%#x" % self.cookie_mask)
468 q.text(","); q.breakable()
469 q.text("match = ");
470 q.pp(self.match)
471 q.breakable()
472 q.text('}')
473
Rich Lane7dcdf022013-12-11 14:45:27 -0800474stats_request.subtypes[2] = aggregate_stats_request
475
476class error_msg(message):
477 subtypes = {}
478
Rich Lane95f7fc92014-01-27 17:08:16 -0800479 version = 2
480 type = 1
481
482 def __init__(self, xid=None, err_type=None):
483 if xid != None:
484 self.xid = xid
485 else:
486 self.xid = None
487 if err_type != None:
488 self.err_type = err_type
489 else:
490 self.err_type = 0
491 return
492
493 def pack(self):
494 packed = []
495 packed.append(struct.pack("!B", self.version))
496 packed.append(struct.pack("!B", self.type))
497 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
498 packed.append(struct.pack("!L", self.xid))
499 packed.append(struct.pack("!H", self.err_type))
500 length = sum([len(x) for x in packed])
501 packed[2] = struct.pack("!H", length)
502 return ''.join(packed)
503
Rich Lane7dcdf022013-12-11 14:45:27 -0800504 @staticmethod
505 def unpack(reader):
506 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800507 subclass = error_msg.subtypes.get(subtype)
508 if subclass:
509 return subclass.unpack(reader)
510
511 obj = error_msg()
512 _version = reader.read("!B")[0]
513 assert(_version == 2)
514 _type = reader.read("!B")[0]
515 assert(_type == 1)
516 _length = reader.read("!H")[0]
517 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800518 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800519 obj.xid = reader.read("!L")[0]
520 obj.err_type = reader.read("!H")[0]
521 return obj
522
523 def __eq__(self, other):
524 if type(self) != type(other): return False
525 if self.xid != other.xid: return False
526 if self.err_type != other.err_type: return False
527 return True
528
529 def pretty_print(self, q):
530 q.text("error_msg {")
531 with q.group():
532 with q.indent(2):
533 q.breakable()
534 q.text("xid = ");
535 if self.xid != None:
536 q.text("%#x" % self.xid)
537 else:
538 q.text('None')
539 q.breakable()
540 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800541
542message.subtypes[1] = error_msg
543
544class bad_action_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700545 version = 2
546 type = 1
547 err_type = 2
548
549 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800550 if xid != None:
551 self.xid = xid
552 else:
553 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700554 if code != None:
555 self.code = code
556 else:
557 self.code = 0
558 if data != None:
559 self.data = data
560 else:
561 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800562 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700563
564 def pack(self):
565 packed = []
566 packed.append(struct.pack("!B", self.version))
567 packed.append(struct.pack("!B", self.type))
568 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
569 packed.append(struct.pack("!L", self.xid))
570 packed.append(struct.pack("!H", self.err_type))
571 packed.append(struct.pack("!H", self.code))
572 packed.append(self.data)
573 length = sum([len(x) for x in packed])
574 packed[2] = struct.pack("!H", length)
575 return ''.join(packed)
576
577 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800578 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700579 obj = bad_action_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700580 _version = reader.read("!B")[0]
581 assert(_version == 2)
582 _type = reader.read("!B")[0]
583 assert(_type == 1)
584 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800585 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800586 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -0700587 obj.xid = reader.read("!L")[0]
588 _err_type = reader.read("!H")[0]
589 assert(_err_type == 2)
590 obj.code = reader.read("!H")[0]
591 obj.data = str(reader.read_all())
592 return obj
593
594 def __eq__(self, other):
595 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700596 if self.xid != other.xid: return False
597 if self.code != other.code: return False
598 if self.data != other.data: return False
599 return True
600
Rich Lane6f4978c2013-10-20 21:33:52 -0700601 def pretty_print(self, q):
602 q.text("bad_action_error_msg {")
603 with q.group():
604 with q.indent(2):
605 q.breakable()
606 q.text("xid = ");
607 if self.xid != None:
608 q.text("%#x" % self.xid)
609 else:
610 q.text('None')
611 q.text(","); q.breakable()
612 q.text("code = ");
613 q.text("%#x" % self.code)
614 q.text(","); q.breakable()
615 q.text("data = ");
616 q.pp(self.data)
617 q.breakable()
618 q.text('}')
619
Rich Lane7dcdf022013-12-11 14:45:27 -0800620error_msg.subtypes[2] = bad_action_error_msg
621
622class bad_instruction_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700623 version = 2
624 type = 1
625 err_type = 3
626
627 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800628 if xid != None:
629 self.xid = xid
630 else:
631 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700632 if code != None:
633 self.code = code
634 else:
635 self.code = 0
636 if data != None:
637 self.data = data
638 else:
639 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800640 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700641
642 def pack(self):
643 packed = []
644 packed.append(struct.pack("!B", self.version))
645 packed.append(struct.pack("!B", self.type))
646 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
647 packed.append(struct.pack("!L", self.xid))
648 packed.append(struct.pack("!H", self.err_type))
649 packed.append(struct.pack("!H", self.code))
650 packed.append(self.data)
651 length = sum([len(x) for x in packed])
652 packed[2] = struct.pack("!H", length)
653 return ''.join(packed)
654
655 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800656 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700657 obj = bad_instruction_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700658 _version = reader.read("!B")[0]
659 assert(_version == 2)
660 _type = reader.read("!B")[0]
661 assert(_type == 1)
662 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800663 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800664 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -0700665 obj.xid = reader.read("!L")[0]
666 _err_type = reader.read("!H")[0]
667 assert(_err_type == 3)
668 obj.code = reader.read("!H")[0]
669 obj.data = str(reader.read_all())
670 return obj
671
672 def __eq__(self, other):
673 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700674 if self.xid != other.xid: return False
675 if self.code != other.code: return False
676 if self.data != other.data: return False
677 return True
678
Rich Lane6f4978c2013-10-20 21:33:52 -0700679 def pretty_print(self, q):
680 q.text("bad_instruction_error_msg {")
681 with q.group():
682 with q.indent(2):
683 q.breakable()
684 q.text("xid = ");
685 if self.xid != None:
686 q.text("%#x" % self.xid)
687 else:
688 q.text('None')
689 q.text(","); q.breakable()
690 q.text("code = ");
691 q.text("%#x" % self.code)
692 q.text(","); q.breakable()
693 q.text("data = ");
694 q.pp(self.data)
695 q.breakable()
696 q.text('}')
697
Rich Lane7dcdf022013-12-11 14:45:27 -0800698error_msg.subtypes[3] = bad_instruction_error_msg
699
700class bad_match_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700701 version = 2
702 type = 1
703 err_type = 4
704
705 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800706 if xid != None:
707 self.xid = xid
708 else:
709 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700710 if code != None:
711 self.code = code
712 else:
713 self.code = 0
714 if data != None:
715 self.data = data
716 else:
717 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800718 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700719
720 def pack(self):
721 packed = []
722 packed.append(struct.pack("!B", self.version))
723 packed.append(struct.pack("!B", self.type))
724 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
725 packed.append(struct.pack("!L", self.xid))
726 packed.append(struct.pack("!H", self.err_type))
727 packed.append(struct.pack("!H", self.code))
728 packed.append(self.data)
729 length = sum([len(x) for x in packed])
730 packed[2] = struct.pack("!H", length)
731 return ''.join(packed)
732
733 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800734 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700735 obj = bad_match_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700736 _version = reader.read("!B")[0]
737 assert(_version == 2)
738 _type = reader.read("!B")[0]
739 assert(_type == 1)
740 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800741 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800742 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -0700743 obj.xid = reader.read("!L")[0]
744 _err_type = reader.read("!H")[0]
745 assert(_err_type == 4)
746 obj.code = reader.read("!H")[0]
747 obj.data = str(reader.read_all())
748 return obj
749
750 def __eq__(self, other):
751 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700752 if self.xid != other.xid: return False
753 if self.code != other.code: return False
754 if self.data != other.data: return False
755 return True
756
Rich Lane6f4978c2013-10-20 21:33:52 -0700757 def pretty_print(self, q):
758 q.text("bad_match_error_msg {")
759 with q.group():
760 with q.indent(2):
761 q.breakable()
762 q.text("xid = ");
763 if self.xid != None:
764 q.text("%#x" % self.xid)
765 else:
766 q.text('None')
767 q.text(","); q.breakable()
768 q.text("code = ");
769 q.text("%#x" % self.code)
770 q.text(","); q.breakable()
771 q.text("data = ");
772 q.pp(self.data)
773 q.breakable()
774 q.text('}')
775
Rich Lane7dcdf022013-12-11 14:45:27 -0800776error_msg.subtypes[4] = bad_match_error_msg
777
778class bad_request_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700779 version = 2
780 type = 1
781 err_type = 1
782
783 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800784 if xid != None:
785 self.xid = xid
786 else:
787 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700788 if code != None:
789 self.code = code
790 else:
791 self.code = 0
792 if data != None:
793 self.data = data
794 else:
795 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800796 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700797
798 def pack(self):
799 packed = []
800 packed.append(struct.pack("!B", self.version))
801 packed.append(struct.pack("!B", self.type))
802 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
803 packed.append(struct.pack("!L", self.xid))
804 packed.append(struct.pack("!H", self.err_type))
805 packed.append(struct.pack("!H", self.code))
806 packed.append(self.data)
807 length = sum([len(x) for x in packed])
808 packed[2] = struct.pack("!H", length)
809 return ''.join(packed)
810
811 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800812 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700813 obj = bad_request_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700814 _version = reader.read("!B")[0]
815 assert(_version == 2)
816 _type = reader.read("!B")[0]
817 assert(_type == 1)
818 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800819 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800820 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -0700821 obj.xid = reader.read("!L")[0]
822 _err_type = reader.read("!H")[0]
823 assert(_err_type == 1)
824 obj.code = reader.read("!H")[0]
825 obj.data = str(reader.read_all())
826 return obj
827
828 def __eq__(self, other):
829 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700830 if self.xid != other.xid: return False
831 if self.code != other.code: return False
832 if self.data != other.data: return False
833 return True
834
Rich Lane6f4978c2013-10-20 21:33:52 -0700835 def pretty_print(self, q):
836 q.text("bad_request_error_msg {")
837 with q.group():
838 with q.indent(2):
839 q.breakable()
840 q.text("xid = ");
841 if self.xid != None:
842 q.text("%#x" % self.xid)
843 else:
844 q.text('None')
845 q.text(","); q.breakable()
846 q.text("code = ");
847 q.text("%#x" % self.code)
848 q.text(","); q.breakable()
849 q.text("data = ");
850 q.pp(self.data)
851 q.breakable()
852 q.text('}')
853
Rich Lane7dcdf022013-12-11 14:45:27 -0800854error_msg.subtypes[1] = bad_request_error_msg
855
856class barrier_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -0700857 version = 2
858 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -0700859
860 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800861 if xid != None:
862 self.xid = xid
863 else:
864 self.xid = None
865 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700866
867 def pack(self):
868 packed = []
869 packed.append(struct.pack("!B", self.version))
870 packed.append(struct.pack("!B", self.type))
871 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
872 packed.append(struct.pack("!L", self.xid))
873 length = sum([len(x) for x in packed])
874 packed[2] = struct.pack("!H", length)
875 return ''.join(packed)
876
877 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800878 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700879 obj = barrier_reply()
Dan Talaycof6202252013-07-02 01:00:29 -0700880 _version = reader.read("!B")[0]
881 assert(_version == 2)
882 _type = reader.read("!B")[0]
883 assert(_type == 21)
884 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800885 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800886 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700887 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700888 return obj
889
890 def __eq__(self, other):
891 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700892 if self.xid != other.xid: return False
893 return True
894
Rich Lanec2ee4b82013-04-24 17:12:38 -0700895 def pretty_print(self, q):
896 q.text("barrier_reply {")
897 with q.group():
898 with q.indent(2):
899 q.breakable()
900 q.text("xid = ");
901 if self.xid != None:
902 q.text("%#x" % self.xid)
903 else:
904 q.text('None')
905 q.breakable()
906 q.text('}')
907
Rich Lane7dcdf022013-12-11 14:45:27 -0800908message.subtypes[21] = barrier_reply
909
910class barrier_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -0700911 version = 2
912 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700913
914 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800915 if xid != None:
916 self.xid = xid
917 else:
918 self.xid = None
919 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700920
921 def pack(self):
922 packed = []
923 packed.append(struct.pack("!B", self.version))
924 packed.append(struct.pack("!B", self.type))
925 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
926 packed.append(struct.pack("!L", self.xid))
927 length = sum([len(x) for x in packed])
928 packed[2] = struct.pack("!H", length)
929 return ''.join(packed)
930
931 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800932 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700933 obj = barrier_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700934 _version = reader.read("!B")[0]
935 assert(_version == 2)
936 _type = reader.read("!B")[0]
937 assert(_type == 20)
938 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800939 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800940 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700941 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700942 return obj
943
944 def __eq__(self, other):
945 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700946 if self.xid != other.xid: return False
947 return True
948
Rich Lanec2ee4b82013-04-24 17:12:38 -0700949 def pretty_print(self, q):
950 q.text("barrier_request {")
951 with q.group():
952 with q.indent(2):
953 q.breakable()
954 q.text("xid = ");
955 if self.xid != None:
956 q.text("%#x" % self.xid)
957 else:
958 q.text('None')
959 q.breakable()
960 q.text('}')
961
Rich Lane7dcdf022013-12-11 14:45:27 -0800962message.subtypes[20] = barrier_request
963
964class experimenter(message):
965 subtypes = {}
966
Rich Lane95f7fc92014-01-27 17:08:16 -0800967 version = 2
968 type = 4
969
Harshmeet Singhc0378a92014-07-22 17:09:36 -0700970 def __init__(self, xid=None, experimenter=None, data=None):
Rich Lane95f7fc92014-01-27 17:08:16 -0800971 if xid != None:
972 self.xid = xid
973 else:
974 self.xid = None
975 if experimenter != None:
976 self.experimenter = experimenter
977 else:
978 self.experimenter = 0
Rich Lane95f7fc92014-01-27 17:08:16 -0800979 if data != None:
980 self.data = data
981 else:
982 self.data = ''
983 return
984
985 def pack(self):
986 packed = []
987 packed.append(struct.pack("!B", self.version))
988 packed.append(struct.pack("!B", self.type))
989 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
990 packed.append(struct.pack("!L", self.xid))
991 packed.append(struct.pack("!L", self.experimenter))
Rich Lane95f7fc92014-01-27 17:08:16 -0800992 packed.append(self.data)
993 length = sum([len(x) for x in packed])
994 packed[2] = struct.pack("!H", length)
995 return ''.join(packed)
996
Rich Lane7dcdf022013-12-11 14:45:27 -0800997 @staticmethod
998 def unpack(reader):
999 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08001000 subclass = experimenter.subtypes.get(subtype)
1001 if subclass:
1002 return subclass.unpack(reader)
1003
1004 obj = experimenter()
1005 _version = reader.read("!B")[0]
1006 assert(_version == 2)
1007 _type = reader.read("!B")[0]
1008 assert(_type == 4)
1009 _length = reader.read("!H")[0]
1010 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001011 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08001012 obj.xid = reader.read("!L")[0]
1013 obj.experimenter = reader.read("!L")[0]
Rich Lane95f7fc92014-01-27 17:08:16 -08001014 obj.data = str(reader.read_all())
1015 return obj
1016
1017 def __eq__(self, other):
1018 if type(self) != type(other): return False
1019 if self.xid != other.xid: return False
1020 if self.experimenter != other.experimenter: return False
Rich Lane95f7fc92014-01-27 17:08:16 -08001021 if self.data != other.data: return False
1022 return True
1023
1024 def pretty_print(self, q):
1025 q.text("experimenter {")
1026 with q.group():
1027 with q.indent(2):
1028 q.breakable()
1029 q.text("xid = ");
1030 if self.xid != None:
1031 q.text("%#x" % self.xid)
1032 else:
1033 q.text('None')
1034 q.text(","); q.breakable()
Rich Lane95f7fc92014-01-27 17:08:16 -08001035 q.text("data = ");
1036 q.pp(self.data)
1037 q.breakable()
1038 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001039
1040message.subtypes[4] = experimenter
1041
1042class bsn_header(experimenter):
1043 subtypes = {}
1044
Rich Lane95f7fc92014-01-27 17:08:16 -08001045 version = 2
1046 type = 4
1047 experimenter = 6035143
1048
1049 def __init__(self, xid=None, subtype=None):
1050 if xid != None:
1051 self.xid = xid
1052 else:
1053 self.xid = None
1054 if subtype != None:
1055 self.subtype = subtype
1056 else:
1057 self.subtype = 0
1058 return
1059
1060 def pack(self):
1061 packed = []
1062 packed.append(struct.pack("!B", self.version))
1063 packed.append(struct.pack("!B", self.type))
1064 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1065 packed.append(struct.pack("!L", self.xid))
1066 packed.append(struct.pack("!L", self.experimenter))
1067 packed.append(struct.pack("!L", self.subtype))
1068 length = sum([len(x) for x in packed])
1069 packed[2] = struct.pack("!H", length)
1070 return ''.join(packed)
1071
Rich Lane7dcdf022013-12-11 14:45:27 -08001072 @staticmethod
1073 def unpack(reader):
1074 subtype, = reader.peek('!L', 12)
Rich Lane95f7fc92014-01-27 17:08:16 -08001075 subclass = bsn_header.subtypes.get(subtype)
1076 if subclass:
1077 return subclass.unpack(reader)
1078
1079 obj = bsn_header()
1080 _version = reader.read("!B")[0]
1081 assert(_version == 2)
1082 _type = reader.read("!B")[0]
1083 assert(_type == 4)
1084 _length = reader.read("!H")[0]
1085 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001086 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08001087 obj.xid = reader.read("!L")[0]
1088 _experimenter = reader.read("!L")[0]
1089 assert(_experimenter == 6035143)
1090 obj.subtype = reader.read("!L")[0]
1091 return obj
1092
1093 def __eq__(self, other):
1094 if type(self) != type(other): return False
1095 if self.xid != other.xid: return False
1096 if self.subtype != other.subtype: return False
1097 return True
1098
1099 def pretty_print(self, q):
1100 q.text("bsn_header {")
1101 with q.group():
1102 with q.indent(2):
1103 q.breakable()
1104 q.text("xid = ");
1105 if self.xid != None:
1106 q.text("%#x" % self.xid)
1107 else:
1108 q.text('None')
1109 q.breakable()
1110 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001111
1112experimenter.subtypes[6035143] = bsn_header
1113
1114class bsn_bw_clear_data_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001115 version = 2
1116 type = 4
1117 experimenter = 6035143
1118 subtype = 22
1119
1120 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001121 if xid != None:
1122 self.xid = xid
1123 else:
1124 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001125 if status != None:
1126 self.status = status
1127 else:
1128 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001129 return
Dan Talaycof6202252013-07-02 01:00:29 -07001130
1131 def pack(self):
1132 packed = []
1133 packed.append(struct.pack("!B", self.version))
1134 packed.append(struct.pack("!B", self.type))
1135 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1136 packed.append(struct.pack("!L", self.xid))
1137 packed.append(struct.pack("!L", self.experimenter))
1138 packed.append(struct.pack("!L", self.subtype))
1139 packed.append(struct.pack("!L", self.status))
1140 length = sum([len(x) for x in packed])
1141 packed[2] = struct.pack("!H", length)
1142 return ''.join(packed)
1143
1144 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001145 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001146 obj = bsn_bw_clear_data_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001147 _version = reader.read("!B")[0]
1148 assert(_version == 2)
1149 _type = reader.read("!B")[0]
1150 assert(_type == 4)
1151 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001152 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001153 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001154 obj.xid = reader.read("!L")[0]
1155 _experimenter = reader.read("!L")[0]
1156 assert(_experimenter == 6035143)
1157 _subtype = reader.read("!L")[0]
1158 assert(_subtype == 22)
1159 obj.status = reader.read("!L")[0]
1160 return obj
1161
1162 def __eq__(self, other):
1163 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001164 if self.xid != other.xid: return False
1165 if self.status != other.status: return False
1166 return True
1167
Dan Talaycof6202252013-07-02 01:00:29 -07001168 def pretty_print(self, q):
1169 q.text("bsn_bw_clear_data_reply {")
1170 with q.group():
1171 with q.indent(2):
1172 q.breakable()
1173 q.text("xid = ");
1174 if self.xid != None:
1175 q.text("%#x" % self.xid)
1176 else:
1177 q.text('None')
1178 q.text(","); q.breakable()
1179 q.text("status = ");
1180 q.text("%#x" % self.status)
1181 q.breakable()
1182 q.text('}')
1183
Rich Lane7dcdf022013-12-11 14:45:27 -08001184bsn_header.subtypes[22] = bsn_bw_clear_data_reply
1185
1186class bsn_bw_clear_data_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001187 version = 2
1188 type = 4
1189 experimenter = 6035143
1190 subtype = 21
1191
1192 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001193 if xid != None:
1194 self.xid = xid
1195 else:
1196 self.xid = None
1197 return
Dan Talaycof6202252013-07-02 01:00:29 -07001198
1199 def pack(self):
1200 packed = []
1201 packed.append(struct.pack("!B", self.version))
1202 packed.append(struct.pack("!B", self.type))
1203 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1204 packed.append(struct.pack("!L", self.xid))
1205 packed.append(struct.pack("!L", self.experimenter))
1206 packed.append(struct.pack("!L", self.subtype))
1207 length = sum([len(x) for x in packed])
1208 packed[2] = struct.pack("!H", length)
1209 return ''.join(packed)
1210
1211 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001212 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001213 obj = bsn_bw_clear_data_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001214 _version = reader.read("!B")[0]
1215 assert(_version == 2)
1216 _type = reader.read("!B")[0]
1217 assert(_type == 4)
1218 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001219 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001220 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001221 obj.xid = reader.read("!L")[0]
1222 _experimenter = reader.read("!L")[0]
1223 assert(_experimenter == 6035143)
1224 _subtype = reader.read("!L")[0]
1225 assert(_subtype == 21)
1226 return obj
1227
1228 def __eq__(self, other):
1229 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001230 if self.xid != other.xid: return False
1231 return True
1232
Dan Talaycof6202252013-07-02 01:00:29 -07001233 def pretty_print(self, q):
1234 q.text("bsn_bw_clear_data_request {")
1235 with q.group():
1236 with q.indent(2):
1237 q.breakable()
1238 q.text("xid = ");
1239 if self.xid != None:
1240 q.text("%#x" % self.xid)
1241 else:
1242 q.text('None')
1243 q.breakable()
1244 q.text('}')
1245
Rich Lane7dcdf022013-12-11 14:45:27 -08001246bsn_header.subtypes[21] = bsn_bw_clear_data_request
1247
1248class bsn_bw_enable_get_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001249 version = 2
1250 type = 4
1251 experimenter = 6035143
1252 subtype = 20
1253
1254 def __init__(self, xid=None, enabled=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001255 if xid != None:
1256 self.xid = xid
1257 else:
1258 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001259 if enabled != None:
1260 self.enabled = enabled
1261 else:
1262 self.enabled = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001263 return
Dan Talaycof6202252013-07-02 01:00:29 -07001264
1265 def pack(self):
1266 packed = []
1267 packed.append(struct.pack("!B", self.version))
1268 packed.append(struct.pack("!B", self.type))
1269 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1270 packed.append(struct.pack("!L", self.xid))
1271 packed.append(struct.pack("!L", self.experimenter))
1272 packed.append(struct.pack("!L", self.subtype))
1273 packed.append(struct.pack("!L", self.enabled))
1274 length = sum([len(x) for x in packed])
1275 packed[2] = struct.pack("!H", length)
1276 return ''.join(packed)
1277
1278 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001279 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001280 obj = bsn_bw_enable_get_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001281 _version = reader.read("!B")[0]
1282 assert(_version == 2)
1283 _type = reader.read("!B")[0]
1284 assert(_type == 4)
1285 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001286 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001287 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001288 obj.xid = reader.read("!L")[0]
1289 _experimenter = reader.read("!L")[0]
1290 assert(_experimenter == 6035143)
1291 _subtype = reader.read("!L")[0]
1292 assert(_subtype == 20)
1293 obj.enabled = reader.read("!L")[0]
1294 return obj
1295
1296 def __eq__(self, other):
1297 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001298 if self.xid != other.xid: return False
1299 if self.enabled != other.enabled: return False
1300 return True
1301
Dan Talaycof6202252013-07-02 01:00:29 -07001302 def pretty_print(self, q):
1303 q.text("bsn_bw_enable_get_reply {")
1304 with q.group():
1305 with q.indent(2):
1306 q.breakable()
1307 q.text("xid = ");
1308 if self.xid != None:
1309 q.text("%#x" % self.xid)
1310 else:
1311 q.text('None')
1312 q.text(","); q.breakable()
1313 q.text("enabled = ");
1314 q.text("%#x" % self.enabled)
1315 q.breakable()
1316 q.text('}')
1317
Rich Lane7dcdf022013-12-11 14:45:27 -08001318bsn_header.subtypes[20] = bsn_bw_enable_get_reply
1319
1320class bsn_bw_enable_get_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001321 version = 2
1322 type = 4
1323 experimenter = 6035143
1324 subtype = 19
1325
1326 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001327 if xid != None:
1328 self.xid = xid
1329 else:
1330 self.xid = None
1331 return
Dan Talaycof6202252013-07-02 01:00:29 -07001332
1333 def pack(self):
1334 packed = []
1335 packed.append(struct.pack("!B", self.version))
1336 packed.append(struct.pack("!B", self.type))
1337 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1338 packed.append(struct.pack("!L", self.xid))
1339 packed.append(struct.pack("!L", self.experimenter))
1340 packed.append(struct.pack("!L", self.subtype))
1341 length = sum([len(x) for x in packed])
1342 packed[2] = struct.pack("!H", length)
1343 return ''.join(packed)
1344
1345 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001346 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001347 obj = bsn_bw_enable_get_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001348 _version = reader.read("!B")[0]
1349 assert(_version == 2)
1350 _type = reader.read("!B")[0]
1351 assert(_type == 4)
1352 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001353 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001354 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001355 obj.xid = reader.read("!L")[0]
1356 _experimenter = reader.read("!L")[0]
1357 assert(_experimenter == 6035143)
1358 _subtype = reader.read("!L")[0]
1359 assert(_subtype == 19)
1360 return obj
1361
1362 def __eq__(self, other):
1363 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001364 if self.xid != other.xid: return False
1365 return True
1366
Dan Talaycof6202252013-07-02 01:00:29 -07001367 def pretty_print(self, q):
1368 q.text("bsn_bw_enable_get_request {")
1369 with q.group():
1370 with q.indent(2):
1371 q.breakable()
1372 q.text("xid = ");
1373 if self.xid != None:
1374 q.text("%#x" % self.xid)
1375 else:
1376 q.text('None')
1377 q.breakable()
1378 q.text('}')
1379
Rich Lane7dcdf022013-12-11 14:45:27 -08001380bsn_header.subtypes[19] = bsn_bw_enable_get_request
1381
1382class bsn_bw_enable_set_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001383 version = 2
1384 type = 4
1385 experimenter = 6035143
1386 subtype = 23
1387
1388 def __init__(self, xid=None, enable=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001389 if xid != None:
1390 self.xid = xid
1391 else:
1392 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001393 if enable != None:
1394 self.enable = enable
1395 else:
1396 self.enable = 0
1397 if status != None:
1398 self.status = status
1399 else:
1400 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001401 return
Dan Talaycof6202252013-07-02 01:00:29 -07001402
1403 def pack(self):
1404 packed = []
1405 packed.append(struct.pack("!B", self.version))
1406 packed.append(struct.pack("!B", self.type))
1407 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1408 packed.append(struct.pack("!L", self.xid))
1409 packed.append(struct.pack("!L", self.experimenter))
1410 packed.append(struct.pack("!L", self.subtype))
1411 packed.append(struct.pack("!L", self.enable))
1412 packed.append(struct.pack("!L", self.status))
1413 length = sum([len(x) for x in packed])
1414 packed[2] = struct.pack("!H", length)
1415 return ''.join(packed)
1416
1417 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001418 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001419 obj = bsn_bw_enable_set_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001420 _version = reader.read("!B")[0]
1421 assert(_version == 2)
1422 _type = reader.read("!B")[0]
1423 assert(_type == 4)
1424 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001425 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001426 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001427 obj.xid = reader.read("!L")[0]
1428 _experimenter = reader.read("!L")[0]
1429 assert(_experimenter == 6035143)
1430 _subtype = reader.read("!L")[0]
1431 assert(_subtype == 23)
1432 obj.enable = reader.read("!L")[0]
1433 obj.status = reader.read("!L")[0]
1434 return obj
1435
1436 def __eq__(self, other):
1437 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001438 if self.xid != other.xid: return False
1439 if self.enable != other.enable: return False
1440 if self.status != other.status: return False
1441 return True
1442
Dan Talaycof6202252013-07-02 01:00:29 -07001443 def pretty_print(self, q):
1444 q.text("bsn_bw_enable_set_reply {")
1445 with q.group():
1446 with q.indent(2):
1447 q.breakable()
1448 q.text("xid = ");
1449 if self.xid != None:
1450 q.text("%#x" % self.xid)
1451 else:
1452 q.text('None')
1453 q.text(","); q.breakable()
1454 q.text("enable = ");
1455 q.text("%#x" % self.enable)
1456 q.text(","); q.breakable()
1457 q.text("status = ");
1458 q.text("%#x" % self.status)
1459 q.breakable()
1460 q.text('}')
1461
Rich Lane7dcdf022013-12-11 14:45:27 -08001462bsn_header.subtypes[23] = bsn_bw_enable_set_reply
1463
1464class bsn_bw_enable_set_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001465 version = 2
1466 type = 4
1467 experimenter = 6035143
1468 subtype = 18
1469
1470 def __init__(self, xid=None, enable=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001471 if xid != None:
1472 self.xid = xid
1473 else:
1474 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001475 if enable != None:
1476 self.enable = enable
1477 else:
1478 self.enable = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001479 return
Dan Talaycof6202252013-07-02 01:00:29 -07001480
1481 def pack(self):
1482 packed = []
1483 packed.append(struct.pack("!B", self.version))
1484 packed.append(struct.pack("!B", self.type))
1485 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1486 packed.append(struct.pack("!L", self.xid))
1487 packed.append(struct.pack("!L", self.experimenter))
1488 packed.append(struct.pack("!L", self.subtype))
1489 packed.append(struct.pack("!L", self.enable))
1490 length = sum([len(x) for x in packed])
1491 packed[2] = struct.pack("!H", length)
1492 return ''.join(packed)
1493
1494 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001495 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001496 obj = bsn_bw_enable_set_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001497 _version = reader.read("!B")[0]
1498 assert(_version == 2)
1499 _type = reader.read("!B")[0]
1500 assert(_type == 4)
1501 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001502 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001503 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001504 obj.xid = reader.read("!L")[0]
1505 _experimenter = reader.read("!L")[0]
1506 assert(_experimenter == 6035143)
1507 _subtype = reader.read("!L")[0]
1508 assert(_subtype == 18)
1509 obj.enable = reader.read("!L")[0]
1510 return obj
1511
1512 def __eq__(self, other):
1513 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001514 if self.xid != other.xid: return False
1515 if self.enable != other.enable: return False
1516 return True
1517
Dan Talaycof6202252013-07-02 01:00:29 -07001518 def pretty_print(self, q):
1519 q.text("bsn_bw_enable_set_request {")
1520 with q.group():
1521 with q.indent(2):
1522 q.breakable()
1523 q.text("xid = ");
1524 if self.xid != None:
1525 q.text("%#x" % self.xid)
1526 else:
1527 q.text('None')
1528 q.text(","); q.breakable()
1529 q.text("enable = ");
1530 q.text("%#x" % self.enable)
1531 q.breakable()
1532 q.text('}')
1533
Rich Lane7dcdf022013-12-11 14:45:27 -08001534bsn_header.subtypes[18] = bsn_bw_enable_set_request
1535
1536class bsn_get_interfaces_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001537 version = 2
1538 type = 4
1539 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001540 subtype = 10
1541
1542 def __init__(self, xid=None, interfaces=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001543 if xid != None:
1544 self.xid = xid
1545 else:
1546 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001547 if interfaces != None:
1548 self.interfaces = interfaces
1549 else:
1550 self.interfaces = []
Rich Lane7dcdf022013-12-11 14:45:27 -08001551 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001552
1553 def pack(self):
1554 packed = []
1555 packed.append(struct.pack("!B", self.version))
1556 packed.append(struct.pack("!B", self.type))
1557 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1558 packed.append(struct.pack("!L", self.xid))
1559 packed.append(struct.pack("!L", self.experimenter))
1560 packed.append(struct.pack("!L", self.subtype))
Rich Lane7dcdf022013-12-11 14:45:27 -08001561 packed.append(loxi.generic_util.pack_list(self.interfaces))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001562 length = sum([len(x) for x in packed])
1563 packed[2] = struct.pack("!H", length)
1564 return ''.join(packed)
1565
1566 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001567 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001568 obj = bsn_get_interfaces_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001569 _version = reader.read("!B")[0]
1570 assert(_version == 2)
1571 _type = reader.read("!B")[0]
1572 assert(_type == 4)
1573 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001574 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001575 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001576 obj.xid = reader.read("!L")[0]
1577 _experimenter = reader.read("!L")[0]
1578 assert(_experimenter == 6035143)
1579 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001580 assert(_subtype == 10)
Rich Lanee2567702015-01-26 15:04:35 -08001581 obj.interfaces = loxi.generic_util.unpack_list(reader, ofp.common.bsn_interface.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001582 return obj
1583
1584 def __eq__(self, other):
1585 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001586 if self.xid != other.xid: return False
1587 if self.interfaces != other.interfaces: return False
1588 return True
1589
Rich Lanec2ee4b82013-04-24 17:12:38 -07001590 def pretty_print(self, q):
1591 q.text("bsn_get_interfaces_reply {")
1592 with q.group():
1593 with q.indent(2):
1594 q.breakable()
1595 q.text("xid = ");
1596 if self.xid != None:
1597 q.text("%#x" % self.xid)
1598 else:
1599 q.text('None')
1600 q.text(","); q.breakable()
1601 q.text("interfaces = ");
1602 q.pp(self.interfaces)
1603 q.breakable()
1604 q.text('}')
1605
Rich Lane7dcdf022013-12-11 14:45:27 -08001606bsn_header.subtypes[10] = bsn_get_interfaces_reply
1607
1608class bsn_get_interfaces_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001609 version = 2
1610 type = 4
1611 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001612 subtype = 9
1613
1614 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001615 if xid != None:
1616 self.xid = xid
1617 else:
1618 self.xid = None
1619 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001620
1621 def pack(self):
1622 packed = []
1623 packed.append(struct.pack("!B", self.version))
1624 packed.append(struct.pack("!B", self.type))
1625 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1626 packed.append(struct.pack("!L", self.xid))
1627 packed.append(struct.pack("!L", self.experimenter))
1628 packed.append(struct.pack("!L", self.subtype))
1629 length = sum([len(x) for x in packed])
1630 packed[2] = struct.pack("!H", length)
1631 return ''.join(packed)
1632
1633 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001634 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001635 obj = bsn_get_interfaces_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001636 _version = reader.read("!B")[0]
1637 assert(_version == 2)
1638 _type = reader.read("!B")[0]
1639 assert(_type == 4)
1640 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001641 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001642 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001643 obj.xid = reader.read("!L")[0]
1644 _experimenter = reader.read("!L")[0]
1645 assert(_experimenter == 6035143)
1646 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001647 assert(_subtype == 9)
1648 return obj
1649
1650 def __eq__(self, other):
1651 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001652 if self.xid != other.xid: return False
1653 return True
1654
Rich Lanec2ee4b82013-04-24 17:12:38 -07001655 def pretty_print(self, q):
1656 q.text("bsn_get_interfaces_request {")
1657 with q.group():
1658 with q.indent(2):
1659 q.breakable()
1660 q.text("xid = ");
1661 if self.xid != None:
1662 q.text("%#x" % self.xid)
1663 else:
1664 q.text('None')
1665 q.breakable()
1666 q.text('}')
1667
Rich Lane7dcdf022013-12-11 14:45:27 -08001668bsn_header.subtypes[9] = bsn_get_interfaces_request
1669
1670class bsn_get_mirroring_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001671 version = 2
1672 type = 4
1673 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001674 subtype = 5
1675
1676 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001677 if xid != None:
1678 self.xid = xid
1679 else:
1680 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001681 if report_mirror_ports != None:
1682 self.report_mirror_ports = report_mirror_ports
1683 else:
1684 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001685 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001686
1687 def pack(self):
1688 packed = []
1689 packed.append(struct.pack("!B", self.version))
1690 packed.append(struct.pack("!B", self.type))
1691 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1692 packed.append(struct.pack("!L", self.xid))
1693 packed.append(struct.pack("!L", self.experimenter))
1694 packed.append(struct.pack("!L", self.subtype))
1695 packed.append(struct.pack("!B", self.report_mirror_ports))
1696 packed.append('\x00' * 3)
1697 length = sum([len(x) for x in packed])
1698 packed[2] = struct.pack("!H", length)
1699 return ''.join(packed)
1700
1701 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001702 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001703 obj = bsn_get_mirroring_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001704 _version = reader.read("!B")[0]
1705 assert(_version == 2)
1706 _type = reader.read("!B")[0]
1707 assert(_type == 4)
1708 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001709 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001710 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001711 obj.xid = reader.read("!L")[0]
1712 _experimenter = reader.read("!L")[0]
1713 assert(_experimenter == 6035143)
1714 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001715 assert(_subtype == 5)
Dan Talaycof6202252013-07-02 01:00:29 -07001716 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001717 reader.skip(3)
1718 return obj
1719
1720 def __eq__(self, other):
1721 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001722 if self.xid != other.xid: return False
1723 if self.report_mirror_ports != other.report_mirror_ports: return False
1724 return True
1725
Rich Lanec2ee4b82013-04-24 17:12:38 -07001726 def pretty_print(self, q):
1727 q.text("bsn_get_mirroring_reply {")
1728 with q.group():
1729 with q.indent(2):
1730 q.breakable()
1731 q.text("xid = ");
1732 if self.xid != None:
1733 q.text("%#x" % self.xid)
1734 else:
1735 q.text('None')
1736 q.text(","); q.breakable()
1737 q.text("report_mirror_ports = ");
1738 q.text("%#x" % self.report_mirror_ports)
1739 q.breakable()
1740 q.text('}')
1741
Rich Lane7dcdf022013-12-11 14:45:27 -08001742bsn_header.subtypes[5] = bsn_get_mirroring_reply
1743
1744class bsn_get_mirroring_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001745 version = 2
1746 type = 4
1747 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001748 subtype = 4
1749
1750 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001751 if xid != None:
1752 self.xid = xid
1753 else:
1754 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001755 if report_mirror_ports != None:
1756 self.report_mirror_ports = report_mirror_ports
1757 else:
1758 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001759 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001760
1761 def pack(self):
1762 packed = []
1763 packed.append(struct.pack("!B", self.version))
1764 packed.append(struct.pack("!B", self.type))
1765 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1766 packed.append(struct.pack("!L", self.xid))
1767 packed.append(struct.pack("!L", self.experimenter))
1768 packed.append(struct.pack("!L", self.subtype))
1769 packed.append(struct.pack("!B", self.report_mirror_ports))
1770 packed.append('\x00' * 3)
1771 length = sum([len(x) for x in packed])
1772 packed[2] = struct.pack("!H", length)
1773 return ''.join(packed)
1774
1775 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001776 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001777 obj = bsn_get_mirroring_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001778 _version = reader.read("!B")[0]
1779 assert(_version == 2)
1780 _type = reader.read("!B")[0]
1781 assert(_type == 4)
1782 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001783 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001784 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001785 obj.xid = reader.read("!L")[0]
1786 _experimenter = reader.read("!L")[0]
1787 assert(_experimenter == 6035143)
1788 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001789 assert(_subtype == 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001790 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001791 reader.skip(3)
1792 return obj
1793
1794 def __eq__(self, other):
1795 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001796 if self.xid != other.xid: return False
1797 if self.report_mirror_ports != other.report_mirror_ports: return False
1798 return True
1799
Rich Lanec2ee4b82013-04-24 17:12:38 -07001800 def pretty_print(self, q):
1801 q.text("bsn_get_mirroring_request {")
1802 with q.group():
1803 with q.indent(2):
1804 q.breakable()
1805 q.text("xid = ");
1806 if self.xid != None:
1807 q.text("%#x" % self.xid)
1808 else:
1809 q.text('None')
1810 q.text(","); q.breakable()
1811 q.text("report_mirror_ports = ");
1812 q.text("%#x" % self.report_mirror_ports)
1813 q.breakable()
1814 q.text('}')
1815
Rich Lane7dcdf022013-12-11 14:45:27 -08001816bsn_header.subtypes[4] = bsn_get_mirroring_request
1817
1818class bsn_pdu_rx_reply(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001819 version = 2
1820 type = 4
1821 experimenter = 6035143
1822 subtype = 34
1823
Rich Lane7b0f2012013-11-22 14:15:26 -08001824 def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001825 if xid != None:
1826 self.xid = xid
1827 else:
1828 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001829 if status != None:
1830 self.status = status
1831 else:
1832 self.status = 0
Rich Lane7b0f2012013-11-22 14:15:26 -08001833 if port_no != None:
1834 self.port_no = port_no
1835 else:
1836 self.port_no = 0
1837 if slot_num != None:
1838 self.slot_num = slot_num
1839 else:
1840 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001841 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001842
1843 def pack(self):
1844 packed = []
1845 packed.append(struct.pack("!B", self.version))
1846 packed.append(struct.pack("!B", self.type))
1847 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1848 packed.append(struct.pack("!L", self.xid))
1849 packed.append(struct.pack("!L", self.experimenter))
1850 packed.append(struct.pack("!L", self.subtype))
1851 packed.append(struct.pack("!L", self.status))
Rich Lane7b0f2012013-11-22 14:15:26 -08001852 packed.append(util.pack_port_no(self.port_no))
1853 packed.append(struct.pack("!B", self.slot_num))
Rich Lane6f4978c2013-10-20 21:33:52 -07001854 length = sum([len(x) for x in packed])
1855 packed[2] = struct.pack("!H", length)
1856 return ''.join(packed)
1857
1858 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001859 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001860 obj = bsn_pdu_rx_reply()
Rich Lane6f4978c2013-10-20 21:33:52 -07001861 _version = reader.read("!B")[0]
1862 assert(_version == 2)
1863 _type = reader.read("!B")[0]
1864 assert(_type == 4)
1865 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001866 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001867 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07001868 obj.xid = reader.read("!L")[0]
1869 _experimenter = reader.read("!L")[0]
1870 assert(_experimenter == 6035143)
1871 _subtype = reader.read("!L")[0]
1872 assert(_subtype == 34)
1873 obj.status = reader.read("!L")[0]
Rich Lane7b0f2012013-11-22 14:15:26 -08001874 obj.port_no = util.unpack_port_no(reader)
1875 obj.slot_num = reader.read("!B")[0]
Rich Lane6f4978c2013-10-20 21:33:52 -07001876 return obj
1877
1878 def __eq__(self, other):
1879 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001880 if self.xid != other.xid: return False
1881 if self.status != other.status: return False
Rich Lane7b0f2012013-11-22 14:15:26 -08001882 if self.port_no != other.port_no: return False
1883 if self.slot_num != other.slot_num: return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001884 return True
1885
Rich Lane6f4978c2013-10-20 21:33:52 -07001886 def pretty_print(self, q):
1887 q.text("bsn_pdu_rx_reply {")
1888 with q.group():
1889 with q.indent(2):
1890 q.breakable()
1891 q.text("xid = ");
1892 if self.xid != None:
1893 q.text("%#x" % self.xid)
1894 else:
1895 q.text('None')
1896 q.text(","); q.breakable()
1897 q.text("status = ");
1898 q.text("%#x" % self.status)
Rich Lane7b0f2012013-11-22 14:15:26 -08001899 q.text(","); q.breakable()
1900 q.text("port_no = ");
1901 q.text(util.pretty_port(self.port_no))
1902 q.text(","); q.breakable()
1903 q.text("slot_num = ");
1904 q.text("%#x" % self.slot_num)
Rich Lane6f4978c2013-10-20 21:33:52 -07001905 q.breakable()
1906 q.text('}')
1907
Rich Lane7dcdf022013-12-11 14:45:27 -08001908bsn_header.subtypes[34] = bsn_pdu_rx_reply
1909
1910class bsn_pdu_rx_request(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001911 version = 2
1912 type = 4
1913 experimenter = 6035143
1914 subtype = 33
1915
1916 def __init__(self, xid=None, timeout_ms=None, port_no=None, slot_num=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001917 if xid != None:
1918 self.xid = xid
1919 else:
1920 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001921 if timeout_ms != None:
1922 self.timeout_ms = timeout_ms
1923 else:
1924 self.timeout_ms = 0
1925 if port_no != None:
1926 self.port_no = port_no
1927 else:
1928 self.port_no = 0
1929 if slot_num != None:
1930 self.slot_num = slot_num
1931 else:
1932 self.slot_num = 0
1933 if data != None:
1934 self.data = data
1935 else:
1936 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08001937 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001938
1939 def pack(self):
1940 packed = []
1941 packed.append(struct.pack("!B", self.version))
1942 packed.append(struct.pack("!B", self.type))
1943 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1944 packed.append(struct.pack("!L", self.xid))
1945 packed.append(struct.pack("!L", self.experimenter))
1946 packed.append(struct.pack("!L", self.subtype))
1947 packed.append(struct.pack("!L", self.timeout_ms))
1948 packed.append(util.pack_port_no(self.port_no))
1949 packed.append(struct.pack("!B", self.slot_num))
1950 packed.append('\x00' * 3)
1951 packed.append(self.data)
1952 length = sum([len(x) for x in packed])
1953 packed[2] = struct.pack("!H", length)
1954 return ''.join(packed)
1955
1956 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001957 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001958 obj = bsn_pdu_rx_request()
Rich Lane6f4978c2013-10-20 21:33:52 -07001959 _version = reader.read("!B")[0]
1960 assert(_version == 2)
1961 _type = reader.read("!B")[0]
1962 assert(_type == 4)
1963 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001964 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001965 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07001966 obj.xid = reader.read("!L")[0]
1967 _experimenter = reader.read("!L")[0]
1968 assert(_experimenter == 6035143)
1969 _subtype = reader.read("!L")[0]
1970 assert(_subtype == 33)
1971 obj.timeout_ms = reader.read("!L")[0]
1972 obj.port_no = util.unpack_port_no(reader)
1973 obj.slot_num = reader.read("!B")[0]
1974 reader.skip(3)
1975 obj.data = str(reader.read_all())
1976 return obj
1977
1978 def __eq__(self, other):
1979 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001980 if self.xid != other.xid: return False
1981 if self.timeout_ms != other.timeout_ms: return False
1982 if self.port_no != other.port_no: return False
1983 if self.slot_num != other.slot_num: return False
1984 if self.data != other.data: return False
1985 return True
1986
Rich Lane6f4978c2013-10-20 21:33:52 -07001987 def pretty_print(self, q):
1988 q.text("bsn_pdu_rx_request {")
1989 with q.group():
1990 with q.indent(2):
1991 q.breakable()
1992 q.text("xid = ");
1993 if self.xid != None:
1994 q.text("%#x" % self.xid)
1995 else:
1996 q.text('None')
1997 q.text(","); q.breakable()
1998 q.text("timeout_ms = ");
1999 q.text("%#x" % self.timeout_ms)
2000 q.text(","); q.breakable()
2001 q.text("port_no = ");
2002 q.text(util.pretty_port(self.port_no))
2003 q.text(","); q.breakable()
2004 q.text("slot_num = ");
2005 q.text("%#x" % self.slot_num)
2006 q.text(","); q.breakable()
2007 q.text("data = ");
2008 q.pp(self.data)
2009 q.breakable()
2010 q.text('}')
2011
Rich Lane7dcdf022013-12-11 14:45:27 -08002012bsn_header.subtypes[33] = bsn_pdu_rx_request
2013
2014class bsn_pdu_rx_timeout(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07002015 version = 2
2016 type = 4
2017 experimenter = 6035143
2018 subtype = 35
2019
2020 def __init__(self, xid=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002021 if xid != None:
2022 self.xid = xid
2023 else:
2024 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07002025 if port_no != None:
2026 self.port_no = port_no
2027 else:
2028 self.port_no = 0
2029 if slot_num != None:
2030 self.slot_num = slot_num
2031 else:
2032 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002033 return
Rich Lane6f4978c2013-10-20 21:33:52 -07002034
2035 def pack(self):
2036 packed = []
2037 packed.append(struct.pack("!B", self.version))
2038 packed.append(struct.pack("!B", self.type))
2039 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2040 packed.append(struct.pack("!L", self.xid))
2041 packed.append(struct.pack("!L", self.experimenter))
2042 packed.append(struct.pack("!L", self.subtype))
2043 packed.append(util.pack_port_no(self.port_no))
2044 packed.append(struct.pack("!B", self.slot_num))
2045 length = sum([len(x) for x in packed])
2046 packed[2] = struct.pack("!H", length)
2047 return ''.join(packed)
2048
2049 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002050 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07002051 obj = bsn_pdu_rx_timeout()
Rich Lane6f4978c2013-10-20 21:33:52 -07002052 _version = reader.read("!B")[0]
2053 assert(_version == 2)
2054 _type = reader.read("!B")[0]
2055 assert(_type == 4)
2056 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002057 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002058 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07002059 obj.xid = reader.read("!L")[0]
2060 _experimenter = reader.read("!L")[0]
2061 assert(_experimenter == 6035143)
2062 _subtype = reader.read("!L")[0]
2063 assert(_subtype == 35)
2064 obj.port_no = util.unpack_port_no(reader)
2065 obj.slot_num = reader.read("!B")[0]
2066 return obj
2067
2068 def __eq__(self, other):
2069 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002070 if self.xid != other.xid: return False
2071 if self.port_no != other.port_no: return False
2072 if self.slot_num != other.slot_num: return False
2073 return True
2074
Rich Lane6f4978c2013-10-20 21:33:52 -07002075 def pretty_print(self, q):
2076 q.text("bsn_pdu_rx_timeout {")
2077 with q.group():
2078 with q.indent(2):
2079 q.breakable()
2080 q.text("xid = ");
2081 if self.xid != None:
2082 q.text("%#x" % self.xid)
2083 else:
2084 q.text('None')
2085 q.text(","); q.breakable()
2086 q.text("port_no = ");
2087 q.text(util.pretty_port(self.port_no))
2088 q.text(","); q.breakable()
2089 q.text("slot_num = ");
2090 q.text("%#x" % self.slot_num)
2091 q.breakable()
2092 q.text('}')
2093
Rich Lane7dcdf022013-12-11 14:45:27 -08002094bsn_header.subtypes[35] = bsn_pdu_rx_timeout
2095
2096class bsn_pdu_tx_reply(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07002097 version = 2
2098 type = 4
2099 experimenter = 6035143
2100 subtype = 32
2101
Rich Lane7b0f2012013-11-22 14:15:26 -08002102 def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002103 if xid != None:
2104 self.xid = xid
2105 else:
2106 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07002107 if status != None:
2108 self.status = status
2109 else:
2110 self.status = 0
Rich Lane7b0f2012013-11-22 14:15:26 -08002111 if port_no != None:
2112 self.port_no = port_no
2113 else:
2114 self.port_no = 0
2115 if slot_num != None:
2116 self.slot_num = slot_num
2117 else:
2118 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002119 return
Rich Lane6f4978c2013-10-20 21:33:52 -07002120
2121 def pack(self):
2122 packed = []
2123 packed.append(struct.pack("!B", self.version))
2124 packed.append(struct.pack("!B", self.type))
2125 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2126 packed.append(struct.pack("!L", self.xid))
2127 packed.append(struct.pack("!L", self.experimenter))
2128 packed.append(struct.pack("!L", self.subtype))
2129 packed.append(struct.pack("!L", self.status))
Rich Lane7b0f2012013-11-22 14:15:26 -08002130 packed.append(util.pack_port_no(self.port_no))
2131 packed.append(struct.pack("!B", self.slot_num))
Rich Lane6f4978c2013-10-20 21:33:52 -07002132 length = sum([len(x) for x in packed])
2133 packed[2] = struct.pack("!H", length)
2134 return ''.join(packed)
2135
2136 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002137 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07002138 obj = bsn_pdu_tx_reply()
Rich Lane6f4978c2013-10-20 21:33:52 -07002139 _version = reader.read("!B")[0]
2140 assert(_version == 2)
2141 _type = reader.read("!B")[0]
2142 assert(_type == 4)
2143 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002144 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002145 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07002146 obj.xid = reader.read("!L")[0]
2147 _experimenter = reader.read("!L")[0]
2148 assert(_experimenter == 6035143)
2149 _subtype = reader.read("!L")[0]
2150 assert(_subtype == 32)
2151 obj.status = reader.read("!L")[0]
Rich Lane7b0f2012013-11-22 14:15:26 -08002152 obj.port_no = util.unpack_port_no(reader)
2153 obj.slot_num = reader.read("!B")[0]
Rich Lane6f4978c2013-10-20 21:33:52 -07002154 return obj
2155
2156 def __eq__(self, other):
2157 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002158 if self.xid != other.xid: return False
2159 if self.status != other.status: return False
Rich Lane7b0f2012013-11-22 14:15:26 -08002160 if self.port_no != other.port_no: return False
2161 if self.slot_num != other.slot_num: return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002162 return True
2163
Rich Lane6f4978c2013-10-20 21:33:52 -07002164 def pretty_print(self, q):
2165 q.text("bsn_pdu_tx_reply {")
2166 with q.group():
2167 with q.indent(2):
2168 q.breakable()
2169 q.text("xid = ");
2170 if self.xid != None:
2171 q.text("%#x" % self.xid)
2172 else:
2173 q.text('None')
2174 q.text(","); q.breakable()
2175 q.text("status = ");
2176 q.text("%#x" % self.status)
Rich Lane7b0f2012013-11-22 14:15:26 -08002177 q.text(","); q.breakable()
2178 q.text("port_no = ");
2179 q.text(util.pretty_port(self.port_no))
2180 q.text(","); q.breakable()
2181 q.text("slot_num = ");
2182 q.text("%#x" % self.slot_num)
Rich Lane6f4978c2013-10-20 21:33:52 -07002183 q.breakable()
2184 q.text('}')
2185
Rich Lane7dcdf022013-12-11 14:45:27 -08002186bsn_header.subtypes[32] = bsn_pdu_tx_reply
2187
2188class bsn_pdu_tx_request(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07002189 version = 2
2190 type = 4
2191 experimenter = 6035143
2192 subtype = 31
2193
2194 def __init__(self, xid=None, tx_interval_ms=None, port_no=None, slot_num=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002195 if xid != None:
2196 self.xid = xid
2197 else:
2198 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07002199 if tx_interval_ms != None:
2200 self.tx_interval_ms = tx_interval_ms
2201 else:
2202 self.tx_interval_ms = 0
2203 if port_no != None:
2204 self.port_no = port_no
2205 else:
2206 self.port_no = 0
2207 if slot_num != None:
2208 self.slot_num = slot_num
2209 else:
2210 self.slot_num = 0
2211 if data != None:
2212 self.data = data
2213 else:
2214 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08002215 return
Rich Lane6f4978c2013-10-20 21:33:52 -07002216
2217 def pack(self):
2218 packed = []
2219 packed.append(struct.pack("!B", self.version))
2220 packed.append(struct.pack("!B", self.type))
2221 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2222 packed.append(struct.pack("!L", self.xid))
2223 packed.append(struct.pack("!L", self.experimenter))
2224 packed.append(struct.pack("!L", self.subtype))
2225 packed.append(struct.pack("!L", self.tx_interval_ms))
2226 packed.append(util.pack_port_no(self.port_no))
2227 packed.append(struct.pack("!B", self.slot_num))
2228 packed.append('\x00' * 3)
2229 packed.append(self.data)
2230 length = sum([len(x) for x in packed])
2231 packed[2] = struct.pack("!H", length)
2232 return ''.join(packed)
2233
2234 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002235 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07002236 obj = bsn_pdu_tx_request()
Rich Lane6f4978c2013-10-20 21:33:52 -07002237 _version = reader.read("!B")[0]
2238 assert(_version == 2)
2239 _type = reader.read("!B")[0]
2240 assert(_type == 4)
2241 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002242 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002243 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07002244 obj.xid = reader.read("!L")[0]
2245 _experimenter = reader.read("!L")[0]
2246 assert(_experimenter == 6035143)
2247 _subtype = reader.read("!L")[0]
2248 assert(_subtype == 31)
2249 obj.tx_interval_ms = reader.read("!L")[0]
2250 obj.port_no = util.unpack_port_no(reader)
2251 obj.slot_num = reader.read("!B")[0]
2252 reader.skip(3)
2253 obj.data = str(reader.read_all())
2254 return obj
2255
2256 def __eq__(self, other):
2257 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002258 if self.xid != other.xid: return False
2259 if self.tx_interval_ms != other.tx_interval_ms: return False
2260 if self.port_no != other.port_no: return False
2261 if self.slot_num != other.slot_num: return False
2262 if self.data != other.data: return False
2263 return True
2264
Rich Lane6f4978c2013-10-20 21:33:52 -07002265 def pretty_print(self, q):
2266 q.text("bsn_pdu_tx_request {")
2267 with q.group():
2268 with q.indent(2):
2269 q.breakable()
2270 q.text("xid = ");
2271 if self.xid != None:
2272 q.text("%#x" % self.xid)
2273 else:
2274 q.text('None')
2275 q.text(","); q.breakable()
2276 q.text("tx_interval_ms = ");
2277 q.text("%#x" % self.tx_interval_ms)
2278 q.text(","); q.breakable()
2279 q.text("port_no = ");
2280 q.text(util.pretty_port(self.port_no))
2281 q.text(","); q.breakable()
2282 q.text("slot_num = ");
2283 q.text("%#x" % self.slot_num)
2284 q.text(","); q.breakable()
2285 q.text("data = ");
2286 q.pp(self.data)
2287 q.breakable()
2288 q.text('}')
2289
Rich Lane7dcdf022013-12-11 14:45:27 -08002290bsn_header.subtypes[31] = bsn_pdu_tx_request
2291
2292class bsn_set_mirroring(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002293 version = 2
2294 type = 4
2295 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07002296 subtype = 3
2297
2298 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002299 if xid != None:
2300 self.xid = xid
2301 else:
2302 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002303 if report_mirror_ports != None:
2304 self.report_mirror_ports = report_mirror_ports
2305 else:
2306 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002307 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002308
2309 def pack(self):
2310 packed = []
2311 packed.append(struct.pack("!B", self.version))
2312 packed.append(struct.pack("!B", self.type))
2313 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2314 packed.append(struct.pack("!L", self.xid))
2315 packed.append(struct.pack("!L", self.experimenter))
2316 packed.append(struct.pack("!L", self.subtype))
2317 packed.append(struct.pack("!B", self.report_mirror_ports))
2318 packed.append('\x00' * 3)
2319 length = sum([len(x) for x in packed])
2320 packed[2] = struct.pack("!H", length)
2321 return ''.join(packed)
2322
2323 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002324 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002325 obj = bsn_set_mirroring()
Dan Talaycof6202252013-07-02 01:00:29 -07002326 _version = reader.read("!B")[0]
2327 assert(_version == 2)
2328 _type = reader.read("!B")[0]
2329 assert(_type == 4)
2330 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002331 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002332 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07002333 obj.xid = reader.read("!L")[0]
2334 _experimenter = reader.read("!L")[0]
2335 assert(_experimenter == 6035143)
2336 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002337 assert(_subtype == 3)
Dan Talaycof6202252013-07-02 01:00:29 -07002338 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002339 reader.skip(3)
2340 return obj
2341
2342 def __eq__(self, other):
2343 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002344 if self.xid != other.xid: return False
2345 if self.report_mirror_ports != other.report_mirror_ports: return False
2346 return True
2347
Rich Lanec2ee4b82013-04-24 17:12:38 -07002348 def pretty_print(self, q):
2349 q.text("bsn_set_mirroring {")
2350 with q.group():
2351 with q.indent(2):
2352 q.breakable()
2353 q.text("xid = ");
2354 if self.xid != None:
2355 q.text("%#x" % self.xid)
2356 else:
2357 q.text('None')
2358 q.text(","); q.breakable()
2359 q.text("report_mirror_ports = ");
2360 q.text("%#x" % self.report_mirror_ports)
2361 q.breakable()
2362 q.text('}')
2363
Rich Lane7dcdf022013-12-11 14:45:27 -08002364bsn_header.subtypes[3] = bsn_set_mirroring
2365
2366class bsn_set_pktin_suppression_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002367 version = 2
2368 type = 4
2369 experimenter = 6035143
2370 subtype = 25
2371
2372 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002373 if xid != None:
2374 self.xid = xid
2375 else:
2376 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002377 if status != None:
2378 self.status = status
2379 else:
2380 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002381 return
Dan Talaycof6202252013-07-02 01:00:29 -07002382
2383 def pack(self):
2384 packed = []
2385 packed.append(struct.pack("!B", self.version))
2386 packed.append(struct.pack("!B", self.type))
2387 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2388 packed.append(struct.pack("!L", self.xid))
2389 packed.append(struct.pack("!L", self.experimenter))
2390 packed.append(struct.pack("!L", self.subtype))
2391 packed.append(struct.pack("!L", self.status))
2392 length = sum([len(x) for x in packed])
2393 packed[2] = struct.pack("!H", length)
2394 return ''.join(packed)
2395
2396 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002397 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002398 obj = bsn_set_pktin_suppression_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002399 _version = reader.read("!B")[0]
2400 assert(_version == 2)
2401 _type = reader.read("!B")[0]
2402 assert(_type == 4)
2403 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002404 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002405 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07002406 obj.xid = reader.read("!L")[0]
2407 _experimenter = reader.read("!L")[0]
2408 assert(_experimenter == 6035143)
2409 _subtype = reader.read("!L")[0]
2410 assert(_subtype == 25)
2411 obj.status = reader.read("!L")[0]
2412 return obj
2413
2414 def __eq__(self, other):
2415 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002416 if self.xid != other.xid: return False
2417 if self.status != other.status: return False
2418 return True
2419
Dan Talaycof6202252013-07-02 01:00:29 -07002420 def pretty_print(self, q):
2421 q.text("bsn_set_pktin_suppression_reply {")
2422 with q.group():
2423 with q.indent(2):
2424 q.breakable()
2425 q.text("xid = ");
2426 if self.xid != None:
2427 q.text("%#x" % self.xid)
2428 else:
2429 q.text('None')
2430 q.text(","); q.breakable()
2431 q.text("status = ");
2432 q.text("%#x" % self.status)
2433 q.breakable()
2434 q.text('}')
2435
Rich Lane7dcdf022013-12-11 14:45:27 -08002436bsn_header.subtypes[25] = bsn_set_pktin_suppression_reply
2437
2438class bsn_set_pktin_suppression_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002439 version = 2
2440 type = 4
2441 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07002442 subtype = 11
2443
2444 def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002445 if xid != None:
2446 self.xid = xid
2447 else:
2448 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002449 if enabled != None:
2450 self.enabled = enabled
2451 else:
2452 self.enabled = 0
2453 if idle_timeout != None:
2454 self.idle_timeout = idle_timeout
2455 else:
2456 self.idle_timeout = 0
2457 if hard_timeout != None:
2458 self.hard_timeout = hard_timeout
2459 else:
2460 self.hard_timeout = 0
2461 if priority != None:
2462 self.priority = priority
2463 else:
2464 self.priority = 0
2465 if cookie != None:
2466 self.cookie = cookie
2467 else:
2468 self.cookie = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002469 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002470
2471 def pack(self):
2472 packed = []
2473 packed.append(struct.pack("!B", self.version))
2474 packed.append(struct.pack("!B", self.type))
2475 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2476 packed.append(struct.pack("!L", self.xid))
2477 packed.append(struct.pack("!L", self.experimenter))
2478 packed.append(struct.pack("!L", self.subtype))
2479 packed.append(struct.pack("!B", self.enabled))
2480 packed.append('\x00' * 1)
2481 packed.append(struct.pack("!H", self.idle_timeout))
2482 packed.append(struct.pack("!H", self.hard_timeout))
2483 packed.append(struct.pack("!H", self.priority))
2484 packed.append(struct.pack("!Q", self.cookie))
2485 length = sum([len(x) for x in packed])
2486 packed[2] = struct.pack("!H", length)
2487 return ''.join(packed)
2488
2489 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002490 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002491 obj = bsn_set_pktin_suppression_request()
Dan Talaycof6202252013-07-02 01:00:29 -07002492 _version = reader.read("!B")[0]
2493 assert(_version == 2)
2494 _type = reader.read("!B")[0]
2495 assert(_type == 4)
2496 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002497 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002498 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07002499 obj.xid = reader.read("!L")[0]
2500 _experimenter = reader.read("!L")[0]
2501 assert(_experimenter == 6035143)
2502 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002503 assert(_subtype == 11)
Dan Talaycof6202252013-07-02 01:00:29 -07002504 obj.enabled = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002505 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07002506 obj.idle_timeout = reader.read("!H")[0]
2507 obj.hard_timeout = reader.read("!H")[0]
2508 obj.priority = reader.read("!H")[0]
2509 obj.cookie = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002510 return obj
2511
2512 def __eq__(self, other):
2513 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002514 if self.xid != other.xid: return False
2515 if self.enabled != other.enabled: return False
2516 if self.idle_timeout != other.idle_timeout: return False
2517 if self.hard_timeout != other.hard_timeout: return False
2518 if self.priority != other.priority: return False
2519 if self.cookie != other.cookie: return False
2520 return True
2521
Rich Lanec2ee4b82013-04-24 17:12:38 -07002522 def pretty_print(self, q):
Dan Talaycof6202252013-07-02 01:00:29 -07002523 q.text("bsn_set_pktin_suppression_request {")
Rich Lanec2ee4b82013-04-24 17:12:38 -07002524 with q.group():
2525 with q.indent(2):
2526 q.breakable()
2527 q.text("xid = ");
2528 if self.xid != None:
2529 q.text("%#x" % self.xid)
2530 else:
2531 q.text('None')
2532 q.text(","); q.breakable()
2533 q.text("enabled = ");
2534 q.text("%#x" % self.enabled)
2535 q.text(","); q.breakable()
2536 q.text("idle_timeout = ");
2537 q.text("%#x" % self.idle_timeout)
2538 q.text(","); q.breakable()
2539 q.text("hard_timeout = ");
2540 q.text("%#x" % self.hard_timeout)
2541 q.text(","); q.breakable()
2542 q.text("priority = ");
2543 q.text("%#x" % self.priority)
2544 q.text(","); q.breakable()
2545 q.text("cookie = ");
2546 q.text("%#x" % self.cookie)
2547 q.breakable()
2548 q.text('}')
2549
Rich Lane7dcdf022013-12-11 14:45:27 -08002550bsn_header.subtypes[11] = bsn_set_pktin_suppression_request
2551
2552class experimenter_stats_reply(stats_reply):
2553 subtypes = {}
2554
Rich Lane95f7fc92014-01-27 17:08:16 -08002555 version = 2
2556 type = 19
2557 stats_type = 65535
2558
2559 def __init__(self, xid=None, flags=None, experimenter=None, data=None):
2560 if xid != None:
2561 self.xid = xid
2562 else:
2563 self.xid = None
2564 if flags != None:
2565 self.flags = flags
2566 else:
2567 self.flags = 0
2568 if experimenter != None:
2569 self.experimenter = experimenter
2570 else:
2571 self.experimenter = 0
2572 if data != None:
2573 self.data = data
2574 else:
2575 self.data = ''
2576 return
2577
2578 def pack(self):
2579 packed = []
2580 packed.append(struct.pack("!B", self.version))
2581 packed.append(struct.pack("!B", self.type))
2582 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2583 packed.append(struct.pack("!L", self.xid))
2584 packed.append(struct.pack("!H", self.stats_type))
2585 packed.append(struct.pack("!H", self.flags))
2586 packed.append('\x00' * 4)
2587 packed.append(struct.pack("!L", self.experimenter))
2588 packed.append('\x00' * 4)
2589 packed.append(self.data)
2590 length = sum([len(x) for x in packed])
2591 packed[2] = struct.pack("!H", length)
2592 return ''.join(packed)
2593
Rich Lane7dcdf022013-12-11 14:45:27 -08002594 @staticmethod
2595 def unpack(reader):
2596 subtype, = reader.peek('!L', 16)
Rich Lane95f7fc92014-01-27 17:08:16 -08002597 subclass = experimenter_stats_reply.subtypes.get(subtype)
2598 if subclass:
2599 return subclass.unpack(reader)
2600
2601 obj = experimenter_stats_reply()
2602 _version = reader.read("!B")[0]
2603 assert(_version == 2)
2604 _type = reader.read("!B")[0]
2605 assert(_type == 19)
2606 _length = reader.read("!H")[0]
2607 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002608 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08002609 obj.xid = reader.read("!L")[0]
2610 _stats_type = reader.read("!H")[0]
2611 assert(_stats_type == 65535)
2612 obj.flags = reader.read("!H")[0]
2613 reader.skip(4)
2614 obj.experimenter = reader.read("!L")[0]
2615 reader.skip(4)
2616 obj.data = str(reader.read_all())
2617 return obj
2618
2619 def __eq__(self, other):
2620 if type(self) != type(other): return False
2621 if self.xid != other.xid: return False
2622 if self.flags != other.flags: return False
2623 if self.experimenter != other.experimenter: return False
2624 if self.data != other.data: return False
2625 return True
2626
2627 def pretty_print(self, q):
2628 q.text("experimenter_stats_reply {")
2629 with q.group():
2630 with q.indent(2):
2631 q.breakable()
2632 q.text("xid = ");
2633 if self.xid != None:
2634 q.text("%#x" % self.xid)
2635 else:
2636 q.text('None')
2637 q.text(","); q.breakable()
2638 q.text("flags = ");
2639 q.text("%#x" % self.flags)
2640 q.text(","); q.breakable()
2641 q.text("data = ");
2642 q.pp(self.data)
2643 q.breakable()
2644 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002645
2646stats_reply.subtypes[65535] = experimenter_stats_reply
2647
2648class bsn_stats_reply(experimenter_stats_reply):
2649 subtypes = {}
2650
Rich Lane95f7fc92014-01-27 17:08:16 -08002651 version = 2
2652 type = 19
2653 stats_type = 65535
2654 experimenter = 6035143
2655
2656 def __init__(self, xid=None, flags=None, subtype=None):
2657 if xid != None:
2658 self.xid = xid
2659 else:
2660 self.xid = None
2661 if flags != None:
2662 self.flags = flags
2663 else:
2664 self.flags = 0
2665 if subtype != None:
2666 self.subtype = subtype
2667 else:
2668 self.subtype = 0
2669 return
2670
2671 def pack(self):
2672 packed = []
2673 packed.append(struct.pack("!B", self.version))
2674 packed.append(struct.pack("!B", self.type))
2675 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2676 packed.append(struct.pack("!L", self.xid))
2677 packed.append(struct.pack("!H", self.stats_type))
2678 packed.append(struct.pack("!H", self.flags))
2679 packed.append('\x00' * 4)
2680 packed.append(struct.pack("!L", self.experimenter))
2681 packed.append(struct.pack("!L", self.subtype))
2682 length = sum([len(x) for x in packed])
2683 packed[2] = struct.pack("!H", length)
2684 return ''.join(packed)
2685
Rich Lane7dcdf022013-12-11 14:45:27 -08002686 @staticmethod
2687 def unpack(reader):
2688 subtype, = reader.peek('!L', 20)
Rich Lane95f7fc92014-01-27 17:08:16 -08002689 subclass = bsn_stats_reply.subtypes.get(subtype)
2690 if subclass:
2691 return subclass.unpack(reader)
2692
2693 obj = bsn_stats_reply()
2694 _version = reader.read("!B")[0]
2695 assert(_version == 2)
2696 _type = reader.read("!B")[0]
2697 assert(_type == 19)
2698 _length = reader.read("!H")[0]
2699 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002700 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08002701 obj.xid = reader.read("!L")[0]
2702 _stats_type = reader.read("!H")[0]
2703 assert(_stats_type == 65535)
2704 obj.flags = reader.read("!H")[0]
2705 reader.skip(4)
2706 _experimenter = reader.read("!L")[0]
2707 assert(_experimenter == 6035143)
2708 obj.subtype = reader.read("!L")[0]
2709 return obj
2710
2711 def __eq__(self, other):
2712 if type(self) != type(other): return False
2713 if self.xid != other.xid: return False
2714 if self.flags != other.flags: return False
2715 if self.subtype != other.subtype: return False
2716 return True
2717
2718 def pretty_print(self, q):
2719 q.text("bsn_stats_reply {")
2720 with q.group():
2721 with q.indent(2):
2722 q.breakable()
2723 q.text("xid = ");
2724 if self.xid != None:
2725 q.text("%#x" % self.xid)
2726 else:
2727 q.text('None')
2728 q.text(","); q.breakable()
2729 q.text("flags = ");
2730 q.text("%#x" % self.flags)
2731 q.breakable()
2732 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002733
2734experimenter_stats_reply.subtypes[6035143] = bsn_stats_reply
2735
2736class experimenter_stats_request(stats_request):
2737 subtypes = {}
2738
Rich Lane95f7fc92014-01-27 17:08:16 -08002739 version = 2
2740 type = 18
2741 stats_type = 65535
2742
2743 def __init__(self, xid=None, flags=None, experimenter=None, data=None):
2744 if xid != None:
2745 self.xid = xid
2746 else:
2747 self.xid = None
2748 if flags != None:
2749 self.flags = flags
2750 else:
2751 self.flags = 0
2752 if experimenter != None:
2753 self.experimenter = experimenter
2754 else:
2755 self.experimenter = 0
2756 if data != None:
2757 self.data = data
2758 else:
2759 self.data = ''
2760 return
2761
2762 def pack(self):
2763 packed = []
2764 packed.append(struct.pack("!B", self.version))
2765 packed.append(struct.pack("!B", self.type))
2766 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2767 packed.append(struct.pack("!L", self.xid))
2768 packed.append(struct.pack("!H", self.stats_type))
2769 packed.append(struct.pack("!H", self.flags))
2770 packed.append('\x00' * 4)
2771 packed.append(struct.pack("!L", self.experimenter))
2772 packed.append('\x00' * 4)
2773 packed.append(self.data)
2774 length = sum([len(x) for x in packed])
2775 packed[2] = struct.pack("!H", length)
2776 return ''.join(packed)
2777
Rich Lane7dcdf022013-12-11 14:45:27 -08002778 @staticmethod
2779 def unpack(reader):
2780 subtype, = reader.peek('!L', 16)
Rich Lane95f7fc92014-01-27 17:08:16 -08002781 subclass = experimenter_stats_request.subtypes.get(subtype)
2782 if subclass:
2783 return subclass.unpack(reader)
2784
2785 obj = experimenter_stats_request()
2786 _version = reader.read("!B")[0]
2787 assert(_version == 2)
2788 _type = reader.read("!B")[0]
2789 assert(_type == 18)
2790 _length = reader.read("!H")[0]
2791 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002792 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08002793 obj.xid = reader.read("!L")[0]
2794 _stats_type = reader.read("!H")[0]
2795 assert(_stats_type == 65535)
2796 obj.flags = reader.read("!H")[0]
2797 reader.skip(4)
2798 obj.experimenter = reader.read("!L")[0]
2799 reader.skip(4)
2800 obj.data = str(reader.read_all())
2801 return obj
2802
2803 def __eq__(self, other):
2804 if type(self) != type(other): return False
2805 if self.xid != other.xid: return False
2806 if self.flags != other.flags: return False
2807 if self.experimenter != other.experimenter: return False
2808 if self.data != other.data: return False
2809 return True
2810
2811 def pretty_print(self, q):
2812 q.text("experimenter_stats_request {")
2813 with q.group():
2814 with q.indent(2):
2815 q.breakable()
2816 q.text("xid = ");
2817 if self.xid != None:
2818 q.text("%#x" % self.xid)
2819 else:
2820 q.text('None')
2821 q.text(","); q.breakable()
2822 q.text("flags = ");
2823 q.text("%#x" % self.flags)
2824 q.text(","); q.breakable()
2825 q.text("data = ");
2826 q.pp(self.data)
2827 q.breakable()
2828 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002829
2830stats_request.subtypes[65535] = experimenter_stats_request
2831
2832class bsn_stats_request(experimenter_stats_request):
2833 subtypes = {}
2834
Rich Lane95f7fc92014-01-27 17:08:16 -08002835 version = 2
2836 type = 18
2837 stats_type = 65535
2838 experimenter = 6035143
2839
2840 def __init__(self, xid=None, flags=None, subtype=None):
2841 if xid != None:
2842 self.xid = xid
2843 else:
2844 self.xid = None
2845 if flags != None:
2846 self.flags = flags
2847 else:
2848 self.flags = 0
2849 if subtype != None:
2850 self.subtype = subtype
2851 else:
2852 self.subtype = 0
2853 return
2854
2855 def pack(self):
2856 packed = []
2857 packed.append(struct.pack("!B", self.version))
2858 packed.append(struct.pack("!B", self.type))
2859 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2860 packed.append(struct.pack("!L", self.xid))
2861 packed.append(struct.pack("!H", self.stats_type))
2862 packed.append(struct.pack("!H", self.flags))
2863 packed.append('\x00' * 4)
2864 packed.append(struct.pack("!L", self.experimenter))
2865 packed.append(struct.pack("!L", self.subtype))
2866 length = sum([len(x) for x in packed])
2867 packed[2] = struct.pack("!H", length)
2868 return ''.join(packed)
2869
Rich Lane7dcdf022013-12-11 14:45:27 -08002870 @staticmethod
2871 def unpack(reader):
2872 subtype, = reader.peek('!L', 20)
Rich Lane95f7fc92014-01-27 17:08:16 -08002873 subclass = bsn_stats_request.subtypes.get(subtype)
2874 if subclass:
2875 return subclass.unpack(reader)
2876
2877 obj = bsn_stats_request()
2878 _version = reader.read("!B")[0]
2879 assert(_version == 2)
2880 _type = reader.read("!B")[0]
2881 assert(_type == 18)
2882 _length = reader.read("!H")[0]
2883 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002884 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08002885 obj.xid = reader.read("!L")[0]
2886 _stats_type = reader.read("!H")[0]
2887 assert(_stats_type == 65535)
2888 obj.flags = reader.read("!H")[0]
2889 reader.skip(4)
2890 _experimenter = reader.read("!L")[0]
2891 assert(_experimenter == 6035143)
2892 obj.subtype = reader.read("!L")[0]
2893 return obj
2894
2895 def __eq__(self, other):
2896 if type(self) != type(other): return False
2897 if self.xid != other.xid: return False
2898 if self.flags != other.flags: return False
2899 if self.subtype != other.subtype: return False
2900 return True
2901
2902 def pretty_print(self, q):
2903 q.text("bsn_stats_request {")
2904 with q.group():
2905 with q.indent(2):
2906 q.breakable()
2907 q.text("xid = ");
2908 if self.xid != None:
2909 q.text("%#x" % self.xid)
2910 else:
2911 q.text('None')
2912 q.text(","); q.breakable()
2913 q.text("flags = ");
2914 q.text("%#x" % self.flags)
2915 q.breakable()
2916 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002917
2918experimenter_stats_request.subtypes[6035143] = bsn_stats_request
2919
2920class bsn_virtual_port_create_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002921 version = 2
2922 type = 4
2923 experimenter = 6035143
2924 subtype = 16
2925
2926 def __init__(self, xid=None, status=None, vport_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002927 if xid != None:
2928 self.xid = xid
2929 else:
2930 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002931 if status != None:
2932 self.status = status
2933 else:
2934 self.status = 0
2935 if vport_no != None:
2936 self.vport_no = vport_no
2937 else:
2938 self.vport_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002939 return
Dan Talaycof6202252013-07-02 01:00:29 -07002940
2941 def pack(self):
2942 packed = []
2943 packed.append(struct.pack("!B", self.version))
2944 packed.append(struct.pack("!B", self.type))
2945 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2946 packed.append(struct.pack("!L", self.xid))
2947 packed.append(struct.pack("!L", self.experimenter))
2948 packed.append(struct.pack("!L", self.subtype))
2949 packed.append(struct.pack("!L", self.status))
2950 packed.append(struct.pack("!L", self.vport_no))
2951 length = sum([len(x) for x in packed])
2952 packed[2] = struct.pack("!H", length)
2953 return ''.join(packed)
2954
2955 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002956 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002957 obj = bsn_virtual_port_create_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002958 _version = reader.read("!B")[0]
2959 assert(_version == 2)
2960 _type = reader.read("!B")[0]
2961 assert(_type == 4)
2962 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002963 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002964 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07002965 obj.xid = reader.read("!L")[0]
2966 _experimenter = reader.read("!L")[0]
2967 assert(_experimenter == 6035143)
2968 _subtype = reader.read("!L")[0]
2969 assert(_subtype == 16)
2970 obj.status = reader.read("!L")[0]
2971 obj.vport_no = reader.read("!L")[0]
2972 return obj
2973
2974 def __eq__(self, other):
2975 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002976 if self.xid != other.xid: return False
2977 if self.status != other.status: return False
2978 if self.vport_no != other.vport_no: return False
2979 return True
2980
Dan Talaycof6202252013-07-02 01:00:29 -07002981 def pretty_print(self, q):
2982 q.text("bsn_virtual_port_create_reply {")
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("status = ");
2993 q.text("%#x" % self.status)
2994 q.text(","); q.breakable()
2995 q.text("vport_no = ");
2996 q.text("%#x" % self.vport_no)
2997 q.breakable()
2998 q.text('}')
2999
Rich Lane7dcdf022013-12-11 14:45:27 -08003000bsn_header.subtypes[16] = bsn_virtual_port_create_reply
3001
3002class bsn_virtual_port_create_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07003003 version = 2
3004 type = 4
3005 experimenter = 6035143
3006 subtype = 15
3007
3008 def __init__(self, xid=None, vport=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003009 if xid != None:
3010 self.xid = xid
3011 else:
3012 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07003013 if vport != None:
3014 self.vport = vport
3015 else:
Rich Lanee2567702015-01-26 15:04:35 -08003016 self.vport = ofp.bsn_vport()
Rich Lane7dcdf022013-12-11 14:45:27 -08003017 return
Dan Talaycof6202252013-07-02 01:00:29 -07003018
3019 def pack(self):
3020 packed = []
3021 packed.append(struct.pack("!B", self.version))
3022 packed.append(struct.pack("!B", self.type))
3023 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3024 packed.append(struct.pack("!L", self.xid))
3025 packed.append(struct.pack("!L", self.experimenter))
3026 packed.append(struct.pack("!L", self.subtype))
3027 packed.append(self.vport.pack())
3028 length = sum([len(x) for x in packed])
3029 packed[2] = struct.pack("!H", length)
3030 return ''.join(packed)
3031
3032 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003033 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07003034 obj = bsn_virtual_port_create_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003035 _version = reader.read("!B")[0]
3036 assert(_version == 2)
3037 _type = reader.read("!B")[0]
3038 assert(_type == 4)
3039 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003040 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003041 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003042 obj.xid = reader.read("!L")[0]
3043 _experimenter = reader.read("!L")[0]
3044 assert(_experimenter == 6035143)
3045 _subtype = reader.read("!L")[0]
3046 assert(_subtype == 15)
Rich Lanee2567702015-01-26 15:04:35 -08003047 obj.vport = ofp.bsn_vport.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07003048 return obj
3049
3050 def __eq__(self, other):
3051 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07003052 if self.xid != other.xid: return False
3053 if self.vport != other.vport: return False
3054 return True
3055
Dan Talaycof6202252013-07-02 01:00:29 -07003056 def pretty_print(self, q):
3057 q.text("bsn_virtual_port_create_request {")
3058 with q.group():
3059 with q.indent(2):
3060 q.breakable()
3061 q.text("xid = ");
3062 if self.xid != None:
3063 q.text("%#x" % self.xid)
3064 else:
3065 q.text('None')
3066 q.text(","); q.breakable()
3067 q.text("vport = ");
3068 q.pp(self.vport)
3069 q.breakable()
3070 q.text('}')
3071
Rich Lane7dcdf022013-12-11 14:45:27 -08003072bsn_header.subtypes[15] = bsn_virtual_port_create_request
3073
3074class bsn_virtual_port_remove_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07003075 version = 2
3076 type = 4
3077 experimenter = 6035143
3078 subtype = 26
3079
3080 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003081 if xid != None:
3082 self.xid = xid
3083 else:
3084 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07003085 if status != None:
3086 self.status = status
3087 else:
3088 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08003089 return
Dan Talaycof6202252013-07-02 01:00:29 -07003090
3091 def pack(self):
3092 packed = []
3093 packed.append(struct.pack("!B", self.version))
3094 packed.append(struct.pack("!B", self.type))
3095 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3096 packed.append(struct.pack("!L", self.xid))
3097 packed.append(struct.pack("!L", self.experimenter))
3098 packed.append(struct.pack("!L", self.subtype))
3099 packed.append(struct.pack("!L", self.status))
3100 length = sum([len(x) for x in packed])
3101 packed[2] = struct.pack("!H", length)
3102 return ''.join(packed)
3103
3104 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003105 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07003106 obj = bsn_virtual_port_remove_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003107 _version = reader.read("!B")[0]
3108 assert(_version == 2)
3109 _type = reader.read("!B")[0]
3110 assert(_type == 4)
3111 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003112 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003113 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003114 obj.xid = reader.read("!L")[0]
3115 _experimenter = reader.read("!L")[0]
3116 assert(_experimenter == 6035143)
3117 _subtype = reader.read("!L")[0]
3118 assert(_subtype == 26)
3119 obj.status = reader.read("!L")[0]
3120 return obj
3121
3122 def __eq__(self, other):
3123 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07003124 if self.xid != other.xid: return False
3125 if self.status != other.status: return False
3126 return True
3127
Dan Talaycof6202252013-07-02 01:00:29 -07003128 def pretty_print(self, q):
3129 q.text("bsn_virtual_port_remove_reply {")
3130 with q.group():
3131 with q.indent(2):
3132 q.breakable()
3133 q.text("xid = ");
3134 if self.xid != None:
3135 q.text("%#x" % self.xid)
3136 else:
3137 q.text('None')
3138 q.text(","); q.breakable()
3139 q.text("status = ");
3140 q.text("%#x" % self.status)
3141 q.breakable()
3142 q.text('}')
3143
Rich Lane7dcdf022013-12-11 14:45:27 -08003144bsn_header.subtypes[26] = bsn_virtual_port_remove_reply
3145
3146class bsn_virtual_port_remove_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07003147 version = 2
3148 type = 4
3149 experimenter = 6035143
3150 subtype = 17
3151
3152 def __init__(self, xid=None, vport_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003153 if xid != None:
3154 self.xid = xid
3155 else:
3156 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07003157 if vport_no != None:
3158 self.vport_no = vport_no
3159 else:
3160 self.vport_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08003161 return
Dan Talaycof6202252013-07-02 01:00:29 -07003162
3163 def pack(self):
3164 packed = []
3165 packed.append(struct.pack("!B", self.version))
3166 packed.append(struct.pack("!B", self.type))
3167 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3168 packed.append(struct.pack("!L", self.xid))
3169 packed.append(struct.pack("!L", self.experimenter))
3170 packed.append(struct.pack("!L", self.subtype))
3171 packed.append(struct.pack("!L", self.vport_no))
3172 length = sum([len(x) for x in packed])
3173 packed[2] = struct.pack("!H", length)
3174 return ''.join(packed)
3175
3176 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003177 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07003178 obj = bsn_virtual_port_remove_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003179 _version = reader.read("!B")[0]
3180 assert(_version == 2)
3181 _type = reader.read("!B")[0]
3182 assert(_type == 4)
3183 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003184 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003185 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003186 obj.xid = reader.read("!L")[0]
3187 _experimenter = reader.read("!L")[0]
3188 assert(_experimenter == 6035143)
3189 _subtype = reader.read("!L")[0]
3190 assert(_subtype == 17)
3191 obj.vport_no = reader.read("!L")[0]
3192 return obj
3193
3194 def __eq__(self, other):
3195 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07003196 if self.xid != other.xid: return False
3197 if self.vport_no != other.vport_no: return False
3198 return True
3199
Dan Talaycof6202252013-07-02 01:00:29 -07003200 def pretty_print(self, q):
3201 q.text("bsn_virtual_port_remove_request {")
3202 with q.group():
3203 with q.indent(2):
3204 q.breakable()
3205 q.text("xid = ");
3206 if self.xid != None:
3207 q.text("%#x" % self.xid)
3208 else:
3209 q.text('None')
3210 q.text(","); q.breakable()
3211 q.text("vport_no = ");
3212 q.text("%#x" % self.vport_no)
3213 q.breakable()
3214 q.text('}')
3215
Rich Lane7dcdf022013-12-11 14:45:27 -08003216bsn_header.subtypes[17] = bsn_virtual_port_remove_request
3217
3218class desc_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07003219 version = 2
3220 type = 19
3221 stats_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003222
3223 def __init__(self, xid=None, flags=None, mfr_desc=None, hw_desc=None, sw_desc=None, serial_num=None, dp_desc=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003224 if xid != None:
3225 self.xid = xid
3226 else:
3227 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003228 if flags != None:
3229 self.flags = flags
3230 else:
3231 self.flags = 0
3232 if mfr_desc != None:
3233 self.mfr_desc = mfr_desc
3234 else:
3235 self.mfr_desc = ""
3236 if hw_desc != None:
3237 self.hw_desc = hw_desc
3238 else:
3239 self.hw_desc = ""
3240 if sw_desc != None:
3241 self.sw_desc = sw_desc
3242 else:
3243 self.sw_desc = ""
3244 if serial_num != None:
3245 self.serial_num = serial_num
3246 else:
3247 self.serial_num = ""
3248 if dp_desc != None:
3249 self.dp_desc = dp_desc
3250 else:
3251 self.dp_desc = ""
Rich Lane7dcdf022013-12-11 14:45:27 -08003252 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003253
3254 def pack(self):
3255 packed = []
3256 packed.append(struct.pack("!B", self.version))
3257 packed.append(struct.pack("!B", self.type))
3258 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3259 packed.append(struct.pack("!L", self.xid))
3260 packed.append(struct.pack("!H", self.stats_type))
3261 packed.append(struct.pack("!H", self.flags))
3262 packed.append('\x00' * 4)
3263 packed.append(struct.pack("!256s", self.mfr_desc))
3264 packed.append(struct.pack("!256s", self.hw_desc))
3265 packed.append(struct.pack("!256s", self.sw_desc))
3266 packed.append(struct.pack("!32s", self.serial_num))
3267 packed.append(struct.pack("!256s", self.dp_desc))
3268 length = sum([len(x) for x in packed])
3269 packed[2] = struct.pack("!H", length)
3270 return ''.join(packed)
3271
3272 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003273 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003274 obj = desc_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003275 _version = reader.read("!B")[0]
3276 assert(_version == 2)
3277 _type = reader.read("!B")[0]
3278 assert(_type == 19)
3279 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003280 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003281 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003282 obj.xid = reader.read("!L")[0]
3283 _stats_type = reader.read("!H")[0]
3284 assert(_stats_type == 0)
3285 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003286 reader.skip(4)
3287 obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00")
3288 obj.hw_desc = reader.read("!256s")[0].rstrip("\x00")
3289 obj.sw_desc = reader.read("!256s")[0].rstrip("\x00")
3290 obj.serial_num = reader.read("!32s")[0].rstrip("\x00")
3291 obj.dp_desc = reader.read("!256s")[0].rstrip("\x00")
3292 return obj
3293
3294 def __eq__(self, other):
3295 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003296 if self.xid != other.xid: return False
3297 if self.flags != other.flags: return False
3298 if self.mfr_desc != other.mfr_desc: return False
3299 if self.hw_desc != other.hw_desc: return False
3300 if self.sw_desc != other.sw_desc: return False
3301 if self.serial_num != other.serial_num: return False
3302 if self.dp_desc != other.dp_desc: return False
3303 return True
3304
Rich Lanec2ee4b82013-04-24 17:12:38 -07003305 def pretty_print(self, q):
3306 q.text("desc_stats_reply {")
3307 with q.group():
3308 with q.indent(2):
3309 q.breakable()
3310 q.text("xid = ");
3311 if self.xid != None:
3312 q.text("%#x" % self.xid)
3313 else:
3314 q.text('None')
3315 q.text(","); q.breakable()
3316 q.text("flags = ");
3317 q.text("%#x" % self.flags)
3318 q.text(","); q.breakable()
3319 q.text("mfr_desc = ");
3320 q.pp(self.mfr_desc)
3321 q.text(","); q.breakable()
3322 q.text("hw_desc = ");
3323 q.pp(self.hw_desc)
3324 q.text(","); q.breakable()
3325 q.text("sw_desc = ");
3326 q.pp(self.sw_desc)
3327 q.text(","); q.breakable()
3328 q.text("serial_num = ");
3329 q.pp(self.serial_num)
3330 q.text(","); q.breakable()
3331 q.text("dp_desc = ");
3332 q.pp(self.dp_desc)
3333 q.breakable()
3334 q.text('}')
3335
Rich Lane7dcdf022013-12-11 14:45:27 -08003336stats_reply.subtypes[0] = desc_stats_reply
3337
3338class desc_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07003339 version = 2
3340 type = 18
3341 stats_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003342
3343 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003344 if xid != None:
3345 self.xid = xid
3346 else:
3347 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003348 if flags != None:
3349 self.flags = flags
3350 else:
3351 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08003352 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003353
3354 def pack(self):
3355 packed = []
3356 packed.append(struct.pack("!B", self.version))
3357 packed.append(struct.pack("!B", self.type))
3358 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3359 packed.append(struct.pack("!L", self.xid))
3360 packed.append(struct.pack("!H", self.stats_type))
3361 packed.append(struct.pack("!H", self.flags))
3362 packed.append('\x00' * 4)
3363 length = sum([len(x) for x in packed])
3364 packed[2] = struct.pack("!H", length)
3365 return ''.join(packed)
3366
3367 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003368 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003369 obj = desc_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003370 _version = reader.read("!B")[0]
3371 assert(_version == 2)
3372 _type = reader.read("!B")[0]
3373 assert(_type == 18)
3374 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003375 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003376 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003377 obj.xid = reader.read("!L")[0]
3378 _stats_type = reader.read("!H")[0]
3379 assert(_stats_type == 0)
3380 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003381 reader.skip(4)
3382 return obj
3383
3384 def __eq__(self, other):
3385 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003386 if self.xid != other.xid: return False
3387 if self.flags != other.flags: return False
3388 return True
3389
Rich Lanec2ee4b82013-04-24 17:12:38 -07003390 def pretty_print(self, q):
3391 q.text("desc_stats_request {")
3392 with q.group():
3393 with q.indent(2):
3394 q.breakable()
3395 q.text("xid = ");
3396 if self.xid != None:
3397 q.text("%#x" % self.xid)
3398 else:
3399 q.text('None')
3400 q.text(","); q.breakable()
3401 q.text("flags = ");
3402 q.text("%#x" % self.flags)
3403 q.breakable()
3404 q.text('}')
3405
Rich Lane7dcdf022013-12-11 14:45:27 -08003406stats_request.subtypes[0] = desc_stats_request
3407
3408class echo_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003409 version = 2
3410 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07003411
3412 def __init__(self, xid=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003413 if xid != None:
3414 self.xid = xid
3415 else:
3416 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003417 if data != None:
3418 self.data = data
3419 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003420 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08003421 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003422
3423 def pack(self):
3424 packed = []
3425 packed.append(struct.pack("!B", self.version))
3426 packed.append(struct.pack("!B", self.type))
3427 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3428 packed.append(struct.pack("!L", self.xid))
3429 packed.append(self.data)
3430 length = sum([len(x) for x in packed])
3431 packed[2] = struct.pack("!H", length)
3432 return ''.join(packed)
3433
3434 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003435 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003436 obj = echo_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003437 _version = reader.read("!B")[0]
3438 assert(_version == 2)
3439 _type = reader.read("!B")[0]
3440 assert(_type == 3)
3441 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003442 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003443 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003444 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003445 obj.data = str(reader.read_all())
3446 return obj
3447
3448 def __eq__(self, other):
3449 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003450 if self.xid != other.xid: return False
3451 if self.data != other.data: return False
3452 return True
3453
Rich Lanec2ee4b82013-04-24 17:12:38 -07003454 def pretty_print(self, q):
3455 q.text("echo_reply {")
3456 with q.group():
3457 with q.indent(2):
3458 q.breakable()
3459 q.text("xid = ");
3460 if self.xid != None:
3461 q.text("%#x" % self.xid)
3462 else:
3463 q.text('None')
3464 q.text(","); q.breakable()
3465 q.text("data = ");
3466 q.pp(self.data)
3467 q.breakable()
3468 q.text('}')
3469
Rich Lane7dcdf022013-12-11 14:45:27 -08003470message.subtypes[3] = echo_reply
3471
3472class echo_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003473 version = 2
3474 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07003475
3476 def __init__(self, xid=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003477 if xid != None:
3478 self.xid = xid
3479 else:
3480 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003481 if data != None:
3482 self.data = data
3483 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003484 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08003485 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003486
3487 def pack(self):
3488 packed = []
3489 packed.append(struct.pack("!B", self.version))
3490 packed.append(struct.pack("!B", self.type))
3491 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3492 packed.append(struct.pack("!L", self.xid))
3493 packed.append(self.data)
3494 length = sum([len(x) for x in packed])
3495 packed[2] = struct.pack("!H", length)
3496 return ''.join(packed)
3497
3498 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003499 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003500 obj = echo_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003501 _version = reader.read("!B")[0]
3502 assert(_version == 2)
3503 _type = reader.read("!B")[0]
3504 assert(_type == 2)
3505 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003506 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003507 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003508 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003509 obj.data = str(reader.read_all())
3510 return obj
3511
3512 def __eq__(self, other):
3513 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003514 if self.xid != other.xid: return False
3515 if self.data != other.data: return False
3516 return True
3517
Rich Lanec2ee4b82013-04-24 17:12:38 -07003518 def pretty_print(self, q):
3519 q.text("echo_request {")
3520 with q.group():
3521 with q.indent(2):
3522 q.breakable()
3523 q.text("xid = ");
3524 if self.xid != None:
3525 q.text("%#x" % self.xid)
3526 else:
3527 q.text('None')
3528 q.text(","); q.breakable()
3529 q.text("data = ");
3530 q.pp(self.data)
3531 q.breakable()
3532 q.text('}')
3533
Rich Lane7dcdf022013-12-11 14:45:27 -08003534message.subtypes[2] = echo_request
3535
3536class features_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003537 version = 2
3538 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07003539
3540 def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, capabilities=None, reserved=None, ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003541 if xid != None:
3542 self.xid = xid
3543 else:
3544 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003545 if datapath_id != None:
3546 self.datapath_id = datapath_id
3547 else:
3548 self.datapath_id = 0
3549 if n_buffers != None:
3550 self.n_buffers = n_buffers
3551 else:
3552 self.n_buffers = 0
3553 if n_tables != None:
3554 self.n_tables = n_tables
3555 else:
3556 self.n_tables = 0
3557 if capabilities != None:
3558 self.capabilities = capabilities
3559 else:
3560 self.capabilities = 0
3561 if reserved != None:
3562 self.reserved = reserved
3563 else:
3564 self.reserved = 0
3565 if ports != None:
3566 self.ports = ports
3567 else:
3568 self.ports = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003569 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003570
3571 def pack(self):
3572 packed = []
3573 packed.append(struct.pack("!B", self.version))
3574 packed.append(struct.pack("!B", self.type))
3575 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3576 packed.append(struct.pack("!L", self.xid))
3577 packed.append(struct.pack("!Q", self.datapath_id))
3578 packed.append(struct.pack("!L", self.n_buffers))
3579 packed.append(struct.pack("!B", self.n_tables))
3580 packed.append('\x00' * 3)
3581 packed.append(struct.pack("!L", self.capabilities))
3582 packed.append(struct.pack("!L", self.reserved))
Rich Lane7dcdf022013-12-11 14:45:27 -08003583 packed.append(loxi.generic_util.pack_list(self.ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003584 length = sum([len(x) for x in packed])
3585 packed[2] = struct.pack("!H", length)
3586 return ''.join(packed)
3587
3588 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003589 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003590 obj = features_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003591 _version = reader.read("!B")[0]
3592 assert(_version == 2)
3593 _type = reader.read("!B")[0]
3594 assert(_type == 6)
3595 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003596 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003597 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003598 obj.xid = reader.read("!L")[0]
3599 obj.datapath_id = reader.read("!Q")[0]
3600 obj.n_buffers = reader.read("!L")[0]
3601 obj.n_tables = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003602 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07003603 obj.capabilities = reader.read("!L")[0]
3604 obj.reserved = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08003605 obj.ports = loxi.generic_util.unpack_list(reader, ofp.common.port_desc.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003606 return obj
3607
3608 def __eq__(self, other):
3609 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003610 if self.xid != other.xid: return False
3611 if self.datapath_id != other.datapath_id: return False
3612 if self.n_buffers != other.n_buffers: return False
3613 if self.n_tables != other.n_tables: return False
3614 if self.capabilities != other.capabilities: return False
3615 if self.reserved != other.reserved: return False
3616 if self.ports != other.ports: return False
3617 return True
3618
Rich Lanec2ee4b82013-04-24 17:12:38 -07003619 def pretty_print(self, q):
3620 q.text("features_reply {")
3621 with q.group():
3622 with q.indent(2):
3623 q.breakable()
3624 q.text("xid = ");
3625 if self.xid != None:
3626 q.text("%#x" % self.xid)
3627 else:
3628 q.text('None')
3629 q.text(","); q.breakable()
3630 q.text("datapath_id = ");
3631 q.text("%#x" % self.datapath_id)
3632 q.text(","); q.breakable()
3633 q.text("n_buffers = ");
3634 q.text("%#x" % self.n_buffers)
3635 q.text(","); q.breakable()
3636 q.text("n_tables = ");
3637 q.text("%#x" % self.n_tables)
3638 q.text(","); q.breakable()
3639 q.text("capabilities = ");
3640 q.text("%#x" % self.capabilities)
3641 q.text(","); q.breakable()
3642 q.text("reserved = ");
3643 q.text("%#x" % self.reserved)
3644 q.text(","); q.breakable()
3645 q.text("ports = ");
3646 q.pp(self.ports)
3647 q.breakable()
3648 q.text('}')
3649
Rich Lane7dcdf022013-12-11 14:45:27 -08003650message.subtypes[6] = features_reply
3651
3652class features_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003653 version = 2
3654 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07003655
3656 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003657 if xid != None:
3658 self.xid = xid
3659 else:
3660 self.xid = None
3661 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003662
3663 def pack(self):
3664 packed = []
3665 packed.append(struct.pack("!B", self.version))
3666 packed.append(struct.pack("!B", self.type))
3667 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3668 packed.append(struct.pack("!L", self.xid))
3669 length = sum([len(x) for x in packed])
3670 packed[2] = struct.pack("!H", length)
3671 return ''.join(packed)
3672
3673 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003674 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003675 obj = features_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003676 _version = reader.read("!B")[0]
3677 assert(_version == 2)
3678 _type = reader.read("!B")[0]
3679 assert(_type == 5)
3680 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003681 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003682 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003683 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003684 return obj
3685
3686 def __eq__(self, other):
3687 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003688 if self.xid != other.xid: return False
3689 return True
3690
Rich Lanec2ee4b82013-04-24 17:12:38 -07003691 def pretty_print(self, q):
3692 q.text("features_request {")
3693 with q.group():
3694 with q.indent(2):
3695 q.breakable()
3696 q.text("xid = ");
3697 if self.xid != None:
3698 q.text("%#x" % self.xid)
3699 else:
3700 q.text('None')
3701 q.breakable()
3702 q.text('}')
3703
Rich Lane7dcdf022013-12-11 14:45:27 -08003704message.subtypes[5] = features_request
3705
3706class flow_mod(message):
3707 subtypes = {}
3708
Rich Lane95f7fc92014-01-27 17:08:16 -08003709 version = 2
3710 type = 14
3711
3712 def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, _command=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None):
3713 if xid != None:
3714 self.xid = xid
3715 else:
3716 self.xid = None
3717 if cookie != None:
3718 self.cookie = cookie
3719 else:
3720 self.cookie = 0
3721 if cookie_mask != None:
3722 self.cookie_mask = cookie_mask
3723 else:
3724 self.cookie_mask = 0
3725 if table_id != None:
3726 self.table_id = table_id
3727 else:
3728 self.table_id = 0
3729 if _command != None:
3730 self._command = _command
3731 else:
3732 self._command = 0
3733 if idle_timeout != None:
3734 self.idle_timeout = idle_timeout
3735 else:
3736 self.idle_timeout = 0
3737 if hard_timeout != None:
3738 self.hard_timeout = hard_timeout
3739 else:
3740 self.hard_timeout = 0
3741 if priority != None:
3742 self.priority = priority
3743 else:
3744 self.priority = 0
3745 if buffer_id != None:
3746 self.buffer_id = buffer_id
3747 else:
3748 self.buffer_id = 0
3749 if out_port != None:
3750 self.out_port = out_port
3751 else:
3752 self.out_port = 0
3753 if out_group != None:
3754 self.out_group = out_group
3755 else:
3756 self.out_group = 0
3757 if flags != None:
3758 self.flags = flags
3759 else:
3760 self.flags = 0
3761 if match != None:
3762 self.match = match
3763 else:
Rich Lanee2567702015-01-26 15:04:35 -08003764 self.match = ofp.match()
Rich Lane95f7fc92014-01-27 17:08:16 -08003765 if instructions != None:
3766 self.instructions = instructions
3767 else:
3768 self.instructions = []
3769 return
3770
3771 def pack(self):
3772 packed = []
3773 packed.append(struct.pack("!B", self.version))
3774 packed.append(struct.pack("!B", self.type))
3775 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3776 packed.append(struct.pack("!L", self.xid))
3777 packed.append(struct.pack("!Q", self.cookie))
3778 packed.append(struct.pack("!Q", self.cookie_mask))
3779 packed.append(struct.pack("!B", self.table_id))
3780 packed.append(util.pack_fm_cmd(self._command))
3781 packed.append(struct.pack("!H", self.idle_timeout))
3782 packed.append(struct.pack("!H", self.hard_timeout))
3783 packed.append(struct.pack("!H", self.priority))
3784 packed.append(struct.pack("!L", self.buffer_id))
3785 packed.append(util.pack_port_no(self.out_port))
3786 packed.append(struct.pack("!L", self.out_group))
3787 packed.append(struct.pack("!H", self.flags))
3788 packed.append('\x00' * 2)
3789 packed.append(self.match.pack())
3790 packed.append(loxi.generic_util.pack_list(self.instructions))
3791 length = sum([len(x) for x in packed])
3792 packed[2] = struct.pack("!H", length)
3793 return ''.join(packed)
3794
Rich Lane7dcdf022013-12-11 14:45:27 -08003795 @staticmethod
3796 def unpack(reader):
3797 subtype, = reader.peek('B', 25)
Rich Lane95f7fc92014-01-27 17:08:16 -08003798 subclass = flow_mod.subtypes.get(subtype)
3799 if subclass:
3800 return subclass.unpack(reader)
3801
3802 obj = flow_mod()
3803 _version = reader.read("!B")[0]
3804 assert(_version == 2)
3805 _type = reader.read("!B")[0]
3806 assert(_type == 14)
3807 _length = reader.read("!H")[0]
3808 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003809 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08003810 obj.xid = reader.read("!L")[0]
3811 obj.cookie = reader.read("!Q")[0]
3812 obj.cookie_mask = reader.read("!Q")[0]
3813 obj.table_id = reader.read("!B")[0]
3814 obj._command = util.unpack_fm_cmd(reader)
3815 obj.idle_timeout = reader.read("!H")[0]
3816 obj.hard_timeout = reader.read("!H")[0]
3817 obj.priority = reader.read("!H")[0]
3818 obj.buffer_id = reader.read("!L")[0]
3819 obj.out_port = util.unpack_port_no(reader)
3820 obj.out_group = reader.read("!L")[0]
3821 obj.flags = reader.read("!H")[0]
3822 reader.skip(2)
Rich Lanee2567702015-01-26 15:04:35 -08003823 obj.match = ofp.match.unpack(reader)
3824 obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack)
Rich Lane95f7fc92014-01-27 17:08:16 -08003825 return obj
3826
3827 def __eq__(self, other):
3828 if type(self) != type(other): return False
3829 if self.xid != other.xid: return False
3830 if self.cookie != other.cookie: return False
3831 if self.cookie_mask != other.cookie_mask: return False
3832 if self.table_id != other.table_id: return False
3833 if self._command != other._command: return False
3834 if self.idle_timeout != other.idle_timeout: return False
3835 if self.hard_timeout != other.hard_timeout: return False
3836 if self.priority != other.priority: return False
3837 if self.buffer_id != other.buffer_id: return False
3838 if self.out_port != other.out_port: return False
3839 if self.out_group != other.out_group: return False
3840 if self.flags != other.flags: return False
3841 if self.match != other.match: return False
3842 if self.instructions != other.instructions: return False
3843 return True
3844
3845 def pretty_print(self, q):
3846 q.text("flow_mod {")
3847 with q.group():
3848 with q.indent(2):
3849 q.breakable()
3850 q.text("xid = ");
3851 if self.xid != None:
3852 q.text("%#x" % self.xid)
3853 else:
3854 q.text('None')
3855 q.text(","); q.breakable()
3856 q.text("cookie = ");
3857 q.text("%#x" % self.cookie)
3858 q.text(","); q.breakable()
3859 q.text("cookie_mask = ");
3860 q.text("%#x" % self.cookie_mask)
3861 q.text(","); q.breakable()
3862 q.text("table_id = ");
3863 q.text("%#x" % self.table_id)
3864 q.text(","); q.breakable()
3865 q.text("idle_timeout = ");
3866 q.text("%#x" % self.idle_timeout)
3867 q.text(","); q.breakable()
3868 q.text("hard_timeout = ");
3869 q.text("%#x" % self.hard_timeout)
3870 q.text(","); q.breakable()
3871 q.text("priority = ");
3872 q.text("%#x" % self.priority)
3873 q.text(","); q.breakable()
3874 q.text("buffer_id = ");
3875 q.text("%#x" % self.buffer_id)
3876 q.text(","); q.breakable()
3877 q.text("out_port = ");
3878 q.text(util.pretty_port(self.out_port))
3879 q.text(","); q.breakable()
3880 q.text("out_group = ");
3881 q.text("%#x" % self.out_group)
3882 q.text(","); q.breakable()
3883 q.text("flags = ");
3884 q.text("%#x" % self.flags)
3885 q.text(","); q.breakable()
3886 q.text("match = ");
3887 q.pp(self.match)
3888 q.text(","); q.breakable()
3889 q.text("instructions = ");
3890 q.pp(self.instructions)
3891 q.breakable()
3892 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08003893
3894message.subtypes[14] = flow_mod
3895
3896class flow_add(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07003897 version = 2
3898 type = 14
3899 _command = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003900
3901 def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003902 if xid != None:
3903 self.xid = xid
3904 else:
3905 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003906 if cookie != None:
3907 self.cookie = cookie
3908 else:
3909 self.cookie = 0
3910 if cookie_mask != None:
3911 self.cookie_mask = cookie_mask
3912 else:
3913 self.cookie_mask = 0
3914 if table_id != None:
3915 self.table_id = table_id
3916 else:
3917 self.table_id = 0
3918 if idle_timeout != None:
3919 self.idle_timeout = idle_timeout
3920 else:
3921 self.idle_timeout = 0
3922 if hard_timeout != None:
3923 self.hard_timeout = hard_timeout
3924 else:
3925 self.hard_timeout = 0
3926 if priority != None:
3927 self.priority = priority
3928 else:
3929 self.priority = 0
3930 if buffer_id != None:
3931 self.buffer_id = buffer_id
3932 else:
3933 self.buffer_id = 0
3934 if out_port != None:
3935 self.out_port = out_port
3936 else:
3937 self.out_port = 0
3938 if out_group != None:
3939 self.out_group = out_group
3940 else:
3941 self.out_group = 0
3942 if flags != None:
3943 self.flags = flags
3944 else:
3945 self.flags = 0
3946 if match != None:
3947 self.match = match
3948 else:
Rich Lanee2567702015-01-26 15:04:35 -08003949 self.match = ofp.match()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003950 if instructions != None:
3951 self.instructions = instructions
3952 else:
3953 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003954 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003955
3956 def pack(self):
3957 packed = []
3958 packed.append(struct.pack("!B", self.version))
3959 packed.append(struct.pack("!B", self.type))
3960 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3961 packed.append(struct.pack("!L", self.xid))
3962 packed.append(struct.pack("!Q", self.cookie))
3963 packed.append(struct.pack("!Q", self.cookie_mask))
3964 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003965 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003966 packed.append(struct.pack("!H", self.idle_timeout))
3967 packed.append(struct.pack("!H", self.hard_timeout))
3968 packed.append(struct.pack("!H", self.priority))
3969 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003970 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003971 packed.append(struct.pack("!L", self.out_group))
3972 packed.append(struct.pack("!H", self.flags))
3973 packed.append('\x00' * 2)
3974 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08003975 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003976 length = sum([len(x) for x in packed])
3977 packed[2] = struct.pack("!H", length)
3978 return ''.join(packed)
3979
3980 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003981 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003982 obj = flow_add()
Dan Talaycof6202252013-07-02 01:00:29 -07003983 _version = reader.read("!B")[0]
3984 assert(_version == 2)
3985 _type = reader.read("!B")[0]
3986 assert(_type == 14)
3987 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003988 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003989 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003990 obj.xid = reader.read("!L")[0]
3991 obj.cookie = reader.read("!Q")[0]
3992 obj.cookie_mask = reader.read("!Q")[0]
3993 obj.table_id = reader.read("!B")[0]
3994 __command = util.unpack_fm_cmd(reader)
3995 assert(__command == 0)
3996 obj.idle_timeout = reader.read("!H")[0]
3997 obj.hard_timeout = reader.read("!H")[0]
3998 obj.priority = reader.read("!H")[0]
3999 obj.buffer_id = reader.read("!L")[0]
4000 obj.out_port = util.unpack_port_no(reader)
4001 obj.out_group = reader.read("!L")[0]
4002 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004003 reader.skip(2)
Rich Lanee2567702015-01-26 15:04:35 -08004004 obj.match = ofp.match.unpack(reader)
4005 obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004006 return obj
4007
4008 def __eq__(self, other):
4009 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004010 if self.xid != other.xid: return False
4011 if self.cookie != other.cookie: return False
4012 if self.cookie_mask != other.cookie_mask: return False
4013 if self.table_id != other.table_id: return False
4014 if self.idle_timeout != other.idle_timeout: return False
4015 if self.hard_timeout != other.hard_timeout: return False
4016 if self.priority != other.priority: return False
4017 if self.buffer_id != other.buffer_id: return False
4018 if self.out_port != other.out_port: return False
4019 if self.out_group != other.out_group: return False
4020 if self.flags != other.flags: return False
4021 if self.match != other.match: return False
4022 if self.instructions != other.instructions: return False
4023 return True
4024
Rich Lanec2ee4b82013-04-24 17:12:38 -07004025 def pretty_print(self, q):
4026 q.text("flow_add {")
4027 with q.group():
4028 with q.indent(2):
4029 q.breakable()
4030 q.text("xid = ");
4031 if self.xid != None:
4032 q.text("%#x" % self.xid)
4033 else:
4034 q.text('None')
4035 q.text(","); q.breakable()
4036 q.text("cookie = ");
4037 q.text("%#x" % self.cookie)
4038 q.text(","); q.breakable()
4039 q.text("cookie_mask = ");
4040 q.text("%#x" % self.cookie_mask)
4041 q.text(","); q.breakable()
4042 q.text("table_id = ");
4043 q.text("%#x" % self.table_id)
4044 q.text(","); q.breakable()
4045 q.text("idle_timeout = ");
4046 q.text("%#x" % self.idle_timeout)
4047 q.text(","); q.breakable()
4048 q.text("hard_timeout = ");
4049 q.text("%#x" % self.hard_timeout)
4050 q.text(","); q.breakable()
4051 q.text("priority = ");
4052 q.text("%#x" % self.priority)
4053 q.text(","); q.breakable()
4054 q.text("buffer_id = ");
4055 q.text("%#x" % self.buffer_id)
4056 q.text(","); q.breakable()
4057 q.text("out_port = ");
4058 q.text(util.pretty_port(self.out_port))
4059 q.text(","); q.breakable()
4060 q.text("out_group = ");
4061 q.text("%#x" % self.out_group)
4062 q.text(","); q.breakable()
4063 q.text("flags = ");
4064 q.text("%#x" % self.flags)
4065 q.text(","); q.breakable()
4066 q.text("match = ");
4067 q.pp(self.match)
4068 q.text(","); q.breakable()
4069 q.text("instructions = ");
4070 q.pp(self.instructions)
4071 q.breakable()
4072 q.text('}')
4073
Rich Lane7dcdf022013-12-11 14:45:27 -08004074flow_mod.subtypes[0] = flow_add
4075
4076class flow_delete(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004077 version = 2
4078 type = 14
4079 _command = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07004080
4081 def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004082 if xid != None:
4083 self.xid = xid
4084 else:
4085 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004086 if cookie != None:
4087 self.cookie = cookie
4088 else:
4089 self.cookie = 0
4090 if cookie_mask != None:
4091 self.cookie_mask = cookie_mask
4092 else:
4093 self.cookie_mask = 0
4094 if table_id != None:
4095 self.table_id = table_id
4096 else:
4097 self.table_id = 0
4098 if idle_timeout != None:
4099 self.idle_timeout = idle_timeout
4100 else:
4101 self.idle_timeout = 0
4102 if hard_timeout != None:
4103 self.hard_timeout = hard_timeout
4104 else:
4105 self.hard_timeout = 0
4106 if priority != None:
4107 self.priority = priority
4108 else:
4109 self.priority = 0
4110 if buffer_id != None:
4111 self.buffer_id = buffer_id
4112 else:
4113 self.buffer_id = 0
4114 if out_port != None:
4115 self.out_port = out_port
4116 else:
4117 self.out_port = 0
4118 if out_group != None:
4119 self.out_group = out_group
4120 else:
4121 self.out_group = 0
4122 if flags != None:
4123 self.flags = flags
4124 else:
4125 self.flags = 0
4126 if match != None:
4127 self.match = match
4128 else:
Rich Lanee2567702015-01-26 15:04:35 -08004129 self.match = ofp.match()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004130 if instructions != None:
4131 self.instructions = instructions
4132 else:
4133 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004134 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004135
4136 def pack(self):
4137 packed = []
4138 packed.append(struct.pack("!B", self.version))
4139 packed.append(struct.pack("!B", self.type))
4140 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4141 packed.append(struct.pack("!L", self.xid))
4142 packed.append(struct.pack("!Q", self.cookie))
4143 packed.append(struct.pack("!Q", self.cookie_mask))
4144 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004145 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004146 packed.append(struct.pack("!H", self.idle_timeout))
4147 packed.append(struct.pack("!H", self.hard_timeout))
4148 packed.append(struct.pack("!H", self.priority))
4149 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004150 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004151 packed.append(struct.pack("!L", self.out_group))
4152 packed.append(struct.pack("!H", self.flags))
4153 packed.append('\x00' * 2)
4154 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004155 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004156 length = sum([len(x) for x in packed])
4157 packed[2] = struct.pack("!H", length)
4158 return ''.join(packed)
4159
4160 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004161 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004162 obj = flow_delete()
Dan Talaycof6202252013-07-02 01:00:29 -07004163 _version = reader.read("!B")[0]
4164 assert(_version == 2)
4165 _type = reader.read("!B")[0]
4166 assert(_type == 14)
4167 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004168 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08004169 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07004170 obj.xid = reader.read("!L")[0]
4171 obj.cookie = reader.read("!Q")[0]
4172 obj.cookie_mask = reader.read("!Q")[0]
4173 obj.table_id = reader.read("!B")[0]
4174 __command = util.unpack_fm_cmd(reader)
4175 assert(__command == 3)
4176 obj.idle_timeout = reader.read("!H")[0]
4177 obj.hard_timeout = reader.read("!H")[0]
4178 obj.priority = reader.read("!H")[0]
4179 obj.buffer_id = reader.read("!L")[0]
4180 obj.out_port = util.unpack_port_no(reader)
4181 obj.out_group = reader.read("!L")[0]
4182 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004183 reader.skip(2)
Rich Lanee2567702015-01-26 15:04:35 -08004184 obj.match = ofp.match.unpack(reader)
4185 obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004186 return obj
4187
4188 def __eq__(self, other):
4189 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004190 if self.xid != other.xid: return False
4191 if self.cookie != other.cookie: return False
4192 if self.cookie_mask != other.cookie_mask: return False
4193 if self.table_id != other.table_id: return False
4194 if self.idle_timeout != other.idle_timeout: return False
4195 if self.hard_timeout != other.hard_timeout: return False
4196 if self.priority != other.priority: return False
4197 if self.buffer_id != other.buffer_id: return False
4198 if self.out_port != other.out_port: return False
4199 if self.out_group != other.out_group: return False
4200 if self.flags != other.flags: return False
4201 if self.match != other.match: return False
4202 if self.instructions != other.instructions: return False
4203 return True
4204
Rich Lanec2ee4b82013-04-24 17:12:38 -07004205 def pretty_print(self, q):
4206 q.text("flow_delete {")
4207 with q.group():
4208 with q.indent(2):
4209 q.breakable()
4210 q.text("xid = ");
4211 if self.xid != None:
4212 q.text("%#x" % self.xid)
4213 else:
4214 q.text('None')
4215 q.text(","); q.breakable()
4216 q.text("cookie = ");
4217 q.text("%#x" % self.cookie)
4218 q.text(","); q.breakable()
4219 q.text("cookie_mask = ");
4220 q.text("%#x" % self.cookie_mask)
4221 q.text(","); q.breakable()
4222 q.text("table_id = ");
4223 q.text("%#x" % self.table_id)
4224 q.text(","); q.breakable()
4225 q.text("idle_timeout = ");
4226 q.text("%#x" % self.idle_timeout)
4227 q.text(","); q.breakable()
4228 q.text("hard_timeout = ");
4229 q.text("%#x" % self.hard_timeout)
4230 q.text(","); q.breakable()
4231 q.text("priority = ");
4232 q.text("%#x" % self.priority)
4233 q.text(","); q.breakable()
4234 q.text("buffer_id = ");
4235 q.text("%#x" % self.buffer_id)
4236 q.text(","); q.breakable()
4237 q.text("out_port = ");
4238 q.text(util.pretty_port(self.out_port))
4239 q.text(","); q.breakable()
4240 q.text("out_group = ");
4241 q.text("%#x" % self.out_group)
4242 q.text(","); q.breakable()
4243 q.text("flags = ");
4244 q.text("%#x" % self.flags)
4245 q.text(","); q.breakable()
4246 q.text("match = ");
4247 q.pp(self.match)
4248 q.text(","); q.breakable()
4249 q.text("instructions = ");
4250 q.pp(self.instructions)
4251 q.breakable()
4252 q.text('}')
4253
Rich Lane7dcdf022013-12-11 14:45:27 -08004254flow_mod.subtypes[3] = flow_delete
4255
4256class flow_delete_strict(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004257 version = 2
4258 type = 14
4259 _command = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07004260
4261 def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004262 if xid != None:
4263 self.xid = xid
4264 else:
4265 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004266 if cookie != None:
4267 self.cookie = cookie
4268 else:
4269 self.cookie = 0
4270 if cookie_mask != None:
4271 self.cookie_mask = cookie_mask
4272 else:
4273 self.cookie_mask = 0
4274 if table_id != None:
4275 self.table_id = table_id
4276 else:
4277 self.table_id = 0
4278 if idle_timeout != None:
4279 self.idle_timeout = idle_timeout
4280 else:
4281 self.idle_timeout = 0
4282 if hard_timeout != None:
4283 self.hard_timeout = hard_timeout
4284 else:
4285 self.hard_timeout = 0
4286 if priority != None:
4287 self.priority = priority
4288 else:
4289 self.priority = 0
4290 if buffer_id != None:
4291 self.buffer_id = buffer_id
4292 else:
4293 self.buffer_id = 0
4294 if out_port != None:
4295 self.out_port = out_port
4296 else:
4297 self.out_port = 0
4298 if out_group != None:
4299 self.out_group = out_group
4300 else:
4301 self.out_group = 0
4302 if flags != None:
4303 self.flags = flags
4304 else:
4305 self.flags = 0
4306 if match != None:
4307 self.match = match
4308 else:
Rich Lanee2567702015-01-26 15:04:35 -08004309 self.match = ofp.match()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004310 if instructions != None:
4311 self.instructions = instructions
4312 else:
4313 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004314 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004315
4316 def pack(self):
4317 packed = []
4318 packed.append(struct.pack("!B", self.version))
4319 packed.append(struct.pack("!B", self.type))
4320 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4321 packed.append(struct.pack("!L", self.xid))
4322 packed.append(struct.pack("!Q", self.cookie))
4323 packed.append(struct.pack("!Q", self.cookie_mask))
4324 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004325 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004326 packed.append(struct.pack("!H", self.idle_timeout))
4327 packed.append(struct.pack("!H", self.hard_timeout))
4328 packed.append(struct.pack("!H", self.priority))
4329 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004330 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004331 packed.append(struct.pack("!L", self.out_group))
4332 packed.append(struct.pack("!H", self.flags))
4333 packed.append('\x00' * 2)
4334 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004335 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004336 length = sum([len(x) for x in packed])
4337 packed[2] = struct.pack("!H", length)
4338 return ''.join(packed)
4339
4340 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004341 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004342 obj = flow_delete_strict()
Dan Talaycof6202252013-07-02 01:00:29 -07004343 _version = reader.read("!B")[0]
4344 assert(_version == 2)
4345 _type = reader.read("!B")[0]
4346 assert(_type == 14)
4347 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004348 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08004349 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07004350 obj.xid = reader.read("!L")[0]
4351 obj.cookie = reader.read("!Q")[0]
4352 obj.cookie_mask = reader.read("!Q")[0]
4353 obj.table_id = reader.read("!B")[0]
4354 __command = util.unpack_fm_cmd(reader)
4355 assert(__command == 4)
4356 obj.idle_timeout = reader.read("!H")[0]
4357 obj.hard_timeout = reader.read("!H")[0]
4358 obj.priority = reader.read("!H")[0]
4359 obj.buffer_id = reader.read("!L")[0]
4360 obj.out_port = util.unpack_port_no(reader)
4361 obj.out_group = reader.read("!L")[0]
4362 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004363 reader.skip(2)
Rich Lanee2567702015-01-26 15:04:35 -08004364 obj.match = ofp.match.unpack(reader)
4365 obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004366 return obj
4367
4368 def __eq__(self, other):
4369 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004370 if self.xid != other.xid: return False
4371 if self.cookie != other.cookie: return False
4372 if self.cookie_mask != other.cookie_mask: return False
4373 if self.table_id != other.table_id: return False
4374 if self.idle_timeout != other.idle_timeout: return False
4375 if self.hard_timeout != other.hard_timeout: return False
4376 if self.priority != other.priority: return False
4377 if self.buffer_id != other.buffer_id: return False
4378 if self.out_port != other.out_port: return False
4379 if self.out_group != other.out_group: return False
4380 if self.flags != other.flags: return False
4381 if self.match != other.match: return False
4382 if self.instructions != other.instructions: return False
4383 return True
4384
Rich Lanec2ee4b82013-04-24 17:12:38 -07004385 def pretty_print(self, q):
4386 q.text("flow_delete_strict {")
4387 with q.group():
4388 with q.indent(2):
4389 q.breakable()
4390 q.text("xid = ");
4391 if self.xid != None:
4392 q.text("%#x" % self.xid)
4393 else:
4394 q.text('None')
4395 q.text(","); q.breakable()
4396 q.text("cookie = ");
4397 q.text("%#x" % self.cookie)
4398 q.text(","); q.breakable()
4399 q.text("cookie_mask = ");
4400 q.text("%#x" % self.cookie_mask)
4401 q.text(","); q.breakable()
4402 q.text("table_id = ");
4403 q.text("%#x" % self.table_id)
4404 q.text(","); q.breakable()
4405 q.text("idle_timeout = ");
4406 q.text("%#x" % self.idle_timeout)
4407 q.text(","); q.breakable()
4408 q.text("hard_timeout = ");
4409 q.text("%#x" % self.hard_timeout)
4410 q.text(","); q.breakable()
4411 q.text("priority = ");
4412 q.text("%#x" % self.priority)
4413 q.text(","); q.breakable()
4414 q.text("buffer_id = ");
4415 q.text("%#x" % self.buffer_id)
4416 q.text(","); q.breakable()
4417 q.text("out_port = ");
4418 q.text(util.pretty_port(self.out_port))
4419 q.text(","); q.breakable()
4420 q.text("out_group = ");
4421 q.text("%#x" % self.out_group)
4422 q.text(","); q.breakable()
4423 q.text("flags = ");
4424 q.text("%#x" % self.flags)
4425 q.text(","); q.breakable()
4426 q.text("match = ");
4427 q.pp(self.match)
4428 q.text(","); q.breakable()
4429 q.text("instructions = ");
4430 q.pp(self.instructions)
4431 q.breakable()
4432 q.text('}')
4433
Rich Lane7dcdf022013-12-11 14:45:27 -08004434flow_mod.subtypes[4] = flow_delete_strict
4435
4436class flow_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07004437 version = 2
4438 type = 1
4439 err_type = 5
4440
4441 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004442 if xid != None:
4443 self.xid = xid
4444 else:
4445 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07004446 if code != None:
4447 self.code = code
4448 else:
4449 self.code = 0
4450 if data != None:
4451 self.data = data
4452 else:
4453 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08004454 return
Rich Lane6f4978c2013-10-20 21:33:52 -07004455
4456 def pack(self):
4457 packed = []
4458 packed.append(struct.pack("!B", self.version))
4459 packed.append(struct.pack("!B", self.type))
4460 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4461 packed.append(struct.pack("!L", self.xid))
4462 packed.append(struct.pack("!H", self.err_type))
4463 packed.append(struct.pack("!H", self.code))
4464 packed.append(self.data)
4465 length = sum([len(x) for x in packed])
4466 packed[2] = struct.pack("!H", length)
4467 return ''.join(packed)
4468
4469 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004470 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07004471 obj = flow_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07004472 _version = reader.read("!B")[0]
4473 assert(_version == 2)
4474 _type = reader.read("!B")[0]
4475 assert(_type == 1)
4476 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004477 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08004478 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07004479 obj.xid = reader.read("!L")[0]
4480 _err_type = reader.read("!H")[0]
4481 assert(_err_type == 5)
4482 obj.code = reader.read("!H")[0]
4483 obj.data = str(reader.read_all())
4484 return obj
4485
4486 def __eq__(self, other):
4487 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07004488 if self.xid != other.xid: return False
4489 if self.code != other.code: return False
4490 if self.data != other.data: return False
4491 return True
4492
Rich Lane6f4978c2013-10-20 21:33:52 -07004493 def pretty_print(self, q):
4494 q.text("flow_mod_failed_error_msg {")
4495 with q.group():
4496 with q.indent(2):
4497 q.breakable()
4498 q.text("xid = ");
4499 if self.xid != None:
4500 q.text("%#x" % self.xid)
4501 else:
4502 q.text('None')
4503 q.text(","); q.breakable()
4504 q.text("code = ");
4505 q.text("%#x" % self.code)
4506 q.text(","); q.breakable()
4507 q.text("data = ");
4508 q.pp(self.data)
4509 q.breakable()
4510 q.text('}')
4511
Rich Lane7dcdf022013-12-11 14:45:27 -08004512error_msg.subtypes[5] = flow_mod_failed_error_msg
4513
4514class flow_modify(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004515 version = 2
4516 type = 14
4517 _command = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07004518
4519 def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004520 if xid != None:
4521 self.xid = xid
4522 else:
4523 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004524 if cookie != None:
4525 self.cookie = cookie
4526 else:
4527 self.cookie = 0
4528 if cookie_mask != None:
4529 self.cookie_mask = cookie_mask
4530 else:
4531 self.cookie_mask = 0
4532 if table_id != None:
4533 self.table_id = table_id
4534 else:
4535 self.table_id = 0
4536 if idle_timeout != None:
4537 self.idle_timeout = idle_timeout
4538 else:
4539 self.idle_timeout = 0
4540 if hard_timeout != None:
4541 self.hard_timeout = hard_timeout
4542 else:
4543 self.hard_timeout = 0
4544 if priority != None:
4545 self.priority = priority
4546 else:
4547 self.priority = 0
4548 if buffer_id != None:
4549 self.buffer_id = buffer_id
4550 else:
4551 self.buffer_id = 0
4552 if out_port != None:
4553 self.out_port = out_port
4554 else:
4555 self.out_port = 0
4556 if out_group != None:
4557 self.out_group = out_group
4558 else:
4559 self.out_group = 0
4560 if flags != None:
4561 self.flags = flags
4562 else:
4563 self.flags = 0
4564 if match != None:
4565 self.match = match
4566 else:
Rich Lanee2567702015-01-26 15:04:35 -08004567 self.match = ofp.match()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004568 if instructions != None:
4569 self.instructions = instructions
4570 else:
4571 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004572 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004573
4574 def pack(self):
4575 packed = []
4576 packed.append(struct.pack("!B", self.version))
4577 packed.append(struct.pack("!B", self.type))
4578 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4579 packed.append(struct.pack("!L", self.xid))
4580 packed.append(struct.pack("!Q", self.cookie))
4581 packed.append(struct.pack("!Q", self.cookie_mask))
4582 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004583 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004584 packed.append(struct.pack("!H", self.idle_timeout))
4585 packed.append(struct.pack("!H", self.hard_timeout))
4586 packed.append(struct.pack("!H", self.priority))
4587 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004588 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004589 packed.append(struct.pack("!L", self.out_group))
4590 packed.append(struct.pack("!H", self.flags))
4591 packed.append('\x00' * 2)
4592 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004593 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004594 length = sum([len(x) for x in packed])
4595 packed[2] = struct.pack("!H", length)
4596 return ''.join(packed)
4597
4598 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004599 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004600 obj = flow_modify()
Dan Talaycof6202252013-07-02 01:00:29 -07004601 _version = reader.read("!B")[0]
4602 assert(_version == 2)
4603 _type = reader.read("!B")[0]
4604 assert(_type == 14)
4605 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004606 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08004607 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07004608 obj.xid = reader.read("!L")[0]
4609 obj.cookie = reader.read("!Q")[0]
4610 obj.cookie_mask = reader.read("!Q")[0]
4611 obj.table_id = reader.read("!B")[0]
4612 __command = util.unpack_fm_cmd(reader)
4613 assert(__command == 1)
4614 obj.idle_timeout = reader.read("!H")[0]
4615 obj.hard_timeout = reader.read("!H")[0]
4616 obj.priority = reader.read("!H")[0]
4617 obj.buffer_id = reader.read("!L")[0]
4618 obj.out_port = util.unpack_port_no(reader)
4619 obj.out_group = reader.read("!L")[0]
4620 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004621 reader.skip(2)
Rich Lanee2567702015-01-26 15:04:35 -08004622 obj.match = ofp.match.unpack(reader)
4623 obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004624 return obj
4625
4626 def __eq__(self, other):
4627 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004628 if self.xid != other.xid: return False
4629 if self.cookie != other.cookie: return False
4630 if self.cookie_mask != other.cookie_mask: return False
4631 if self.table_id != other.table_id: return False
4632 if self.idle_timeout != other.idle_timeout: return False
4633 if self.hard_timeout != other.hard_timeout: return False
4634 if self.priority != other.priority: return False
4635 if self.buffer_id != other.buffer_id: return False
4636 if self.out_port != other.out_port: return False
4637 if self.out_group != other.out_group: return False
4638 if self.flags != other.flags: return False
4639 if self.match != other.match: return False
4640 if self.instructions != other.instructions: return False
4641 return True
4642
Rich Lanec2ee4b82013-04-24 17:12:38 -07004643 def pretty_print(self, q):
4644 q.text("flow_modify {")
4645 with q.group():
4646 with q.indent(2):
4647 q.breakable()
4648 q.text("xid = ");
4649 if self.xid != None:
4650 q.text("%#x" % self.xid)
4651 else:
4652 q.text('None')
4653 q.text(","); q.breakable()
4654 q.text("cookie = ");
4655 q.text("%#x" % self.cookie)
4656 q.text(","); q.breakable()
4657 q.text("cookie_mask = ");
4658 q.text("%#x" % self.cookie_mask)
4659 q.text(","); q.breakable()
4660 q.text("table_id = ");
4661 q.text("%#x" % self.table_id)
4662 q.text(","); q.breakable()
4663 q.text("idle_timeout = ");
4664 q.text("%#x" % self.idle_timeout)
4665 q.text(","); q.breakable()
4666 q.text("hard_timeout = ");
4667 q.text("%#x" % self.hard_timeout)
4668 q.text(","); q.breakable()
4669 q.text("priority = ");
4670 q.text("%#x" % self.priority)
4671 q.text(","); q.breakable()
4672 q.text("buffer_id = ");
4673 q.text("%#x" % self.buffer_id)
4674 q.text(","); q.breakable()
4675 q.text("out_port = ");
4676 q.text(util.pretty_port(self.out_port))
4677 q.text(","); q.breakable()
4678 q.text("out_group = ");
4679 q.text("%#x" % self.out_group)
4680 q.text(","); q.breakable()
4681 q.text("flags = ");
4682 q.text("%#x" % self.flags)
4683 q.text(","); q.breakable()
4684 q.text("match = ");
4685 q.pp(self.match)
4686 q.text(","); q.breakable()
4687 q.text("instructions = ");
4688 q.pp(self.instructions)
4689 q.breakable()
4690 q.text('}')
4691
Rich Lane7dcdf022013-12-11 14:45:27 -08004692flow_mod.subtypes[1] = flow_modify
4693
4694class flow_modify_strict(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004695 version = 2
4696 type = 14
4697 _command = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07004698
4699 def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004700 if xid != None:
4701 self.xid = xid
4702 else:
4703 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004704 if cookie != None:
4705 self.cookie = cookie
4706 else:
4707 self.cookie = 0
4708 if cookie_mask != None:
4709 self.cookie_mask = cookie_mask
4710 else:
4711 self.cookie_mask = 0
4712 if table_id != None:
4713 self.table_id = table_id
4714 else:
4715 self.table_id = 0
4716 if idle_timeout != None:
4717 self.idle_timeout = idle_timeout
4718 else:
4719 self.idle_timeout = 0
4720 if hard_timeout != None:
4721 self.hard_timeout = hard_timeout
4722 else:
4723 self.hard_timeout = 0
4724 if priority != None:
4725 self.priority = priority
4726 else:
4727 self.priority = 0
4728 if buffer_id != None:
4729 self.buffer_id = buffer_id
4730 else:
4731 self.buffer_id = 0
4732 if out_port != None:
4733 self.out_port = out_port
4734 else:
4735 self.out_port = 0
4736 if out_group != None:
4737 self.out_group = out_group
4738 else:
4739 self.out_group = 0
4740 if flags != None:
4741 self.flags = flags
4742 else:
4743 self.flags = 0
4744 if match != None:
4745 self.match = match
4746 else:
Rich Lanee2567702015-01-26 15:04:35 -08004747 self.match = ofp.match()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004748 if instructions != None:
4749 self.instructions = instructions
4750 else:
4751 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004752 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004753
4754 def pack(self):
4755 packed = []
4756 packed.append(struct.pack("!B", self.version))
4757 packed.append(struct.pack("!B", self.type))
4758 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4759 packed.append(struct.pack("!L", self.xid))
4760 packed.append(struct.pack("!Q", self.cookie))
4761 packed.append(struct.pack("!Q", self.cookie_mask))
4762 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004763 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004764 packed.append(struct.pack("!H", self.idle_timeout))
4765 packed.append(struct.pack("!H", self.hard_timeout))
4766 packed.append(struct.pack("!H", self.priority))
4767 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004768 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004769 packed.append(struct.pack("!L", self.out_group))
4770 packed.append(struct.pack("!H", self.flags))
4771 packed.append('\x00' * 2)
4772 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004773 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004774 length = sum([len(x) for x in packed])
4775 packed[2] = struct.pack("!H", length)
4776 return ''.join(packed)
4777
4778 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004779 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004780 obj = flow_modify_strict()
Dan Talaycof6202252013-07-02 01:00:29 -07004781 _version = reader.read("!B")[0]
4782 assert(_version == 2)
4783 _type = reader.read("!B")[0]
4784 assert(_type == 14)
4785 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004786 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08004787 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07004788 obj.xid = reader.read("!L")[0]
4789 obj.cookie = reader.read("!Q")[0]
4790 obj.cookie_mask = reader.read("!Q")[0]
4791 obj.table_id = reader.read("!B")[0]
4792 __command = util.unpack_fm_cmd(reader)
4793 assert(__command == 2)
4794 obj.idle_timeout = reader.read("!H")[0]
4795 obj.hard_timeout = reader.read("!H")[0]
4796 obj.priority = reader.read("!H")[0]
4797 obj.buffer_id = reader.read("!L")[0]
4798 obj.out_port = util.unpack_port_no(reader)
4799 obj.out_group = reader.read("!L")[0]
4800 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004801 reader.skip(2)
Rich Lanee2567702015-01-26 15:04:35 -08004802 obj.match = ofp.match.unpack(reader)
4803 obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004804 return obj
4805
4806 def __eq__(self, other):
4807 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004808 if self.xid != other.xid: return False
4809 if self.cookie != other.cookie: return False
4810 if self.cookie_mask != other.cookie_mask: return False
4811 if self.table_id != other.table_id: return False
4812 if self.idle_timeout != other.idle_timeout: return False
4813 if self.hard_timeout != other.hard_timeout: return False
4814 if self.priority != other.priority: return False
4815 if self.buffer_id != other.buffer_id: return False
4816 if self.out_port != other.out_port: return False
4817 if self.out_group != other.out_group: return False
4818 if self.flags != other.flags: return False
4819 if self.match != other.match: return False
4820 if self.instructions != other.instructions: return False
4821 return True
4822
Rich Lanec2ee4b82013-04-24 17:12:38 -07004823 def pretty_print(self, q):
4824 q.text("flow_modify_strict {")
4825 with q.group():
4826 with q.indent(2):
4827 q.breakable()
4828 q.text("xid = ");
4829 if self.xid != None:
4830 q.text("%#x" % self.xid)
4831 else:
4832 q.text('None')
4833 q.text(","); q.breakable()
4834 q.text("cookie = ");
4835 q.text("%#x" % self.cookie)
4836 q.text(","); q.breakable()
4837 q.text("cookie_mask = ");
4838 q.text("%#x" % self.cookie_mask)
4839 q.text(","); q.breakable()
4840 q.text("table_id = ");
4841 q.text("%#x" % self.table_id)
4842 q.text(","); q.breakable()
4843 q.text("idle_timeout = ");
4844 q.text("%#x" % self.idle_timeout)
4845 q.text(","); q.breakable()
4846 q.text("hard_timeout = ");
4847 q.text("%#x" % self.hard_timeout)
4848 q.text(","); q.breakable()
4849 q.text("priority = ");
4850 q.text("%#x" % self.priority)
4851 q.text(","); q.breakable()
4852 q.text("buffer_id = ");
4853 q.text("%#x" % self.buffer_id)
4854 q.text(","); q.breakable()
4855 q.text("out_port = ");
4856 q.text(util.pretty_port(self.out_port))
4857 q.text(","); q.breakable()
4858 q.text("out_group = ");
4859 q.text("%#x" % self.out_group)
4860 q.text(","); q.breakable()
4861 q.text("flags = ");
4862 q.text("%#x" % self.flags)
4863 q.text(","); q.breakable()
4864 q.text("match = ");
4865 q.pp(self.match)
4866 q.text(","); q.breakable()
4867 q.text("instructions = ");
4868 q.pp(self.instructions)
4869 q.breakable()
4870 q.text('}')
4871
Rich Lane7dcdf022013-12-11 14:45:27 -08004872flow_mod.subtypes[2] = flow_modify_strict
4873
4874class flow_removed(message):
Dan Talaycof6202252013-07-02 01:00:29 -07004875 version = 2
4876 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -07004877
4878 def __init__(self, xid=None, cookie=None, priority=None, reason=None, table_id=None, duration_sec=None, duration_nsec=None, idle_timeout=None, packet_count=None, byte_count=None, match=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004879 if xid != None:
4880 self.xid = xid
4881 else:
4882 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004883 if cookie != None:
4884 self.cookie = cookie
4885 else:
4886 self.cookie = 0
4887 if priority != None:
4888 self.priority = priority
4889 else:
4890 self.priority = 0
4891 if reason != None:
4892 self.reason = reason
4893 else:
4894 self.reason = 0
4895 if table_id != None:
4896 self.table_id = table_id
4897 else:
4898 self.table_id = 0
4899 if duration_sec != None:
4900 self.duration_sec = duration_sec
4901 else:
4902 self.duration_sec = 0
4903 if duration_nsec != None:
4904 self.duration_nsec = duration_nsec
4905 else:
4906 self.duration_nsec = 0
4907 if idle_timeout != None:
4908 self.idle_timeout = idle_timeout
4909 else:
4910 self.idle_timeout = 0
4911 if packet_count != None:
4912 self.packet_count = packet_count
4913 else:
4914 self.packet_count = 0
4915 if byte_count != None:
4916 self.byte_count = byte_count
4917 else:
4918 self.byte_count = 0
4919 if match != None:
4920 self.match = match
4921 else:
Rich Lanee2567702015-01-26 15:04:35 -08004922 self.match = ofp.match()
Rich Lane7dcdf022013-12-11 14:45:27 -08004923 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004924
4925 def pack(self):
4926 packed = []
4927 packed.append(struct.pack("!B", self.version))
4928 packed.append(struct.pack("!B", self.type))
4929 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4930 packed.append(struct.pack("!L", self.xid))
4931 packed.append(struct.pack("!Q", self.cookie))
4932 packed.append(struct.pack("!H", self.priority))
4933 packed.append(struct.pack("!B", self.reason))
4934 packed.append(struct.pack("!B", self.table_id))
4935 packed.append(struct.pack("!L", self.duration_sec))
4936 packed.append(struct.pack("!L", self.duration_nsec))
4937 packed.append(struct.pack("!H", self.idle_timeout))
4938 packed.append('\x00' * 2)
4939 packed.append(struct.pack("!Q", self.packet_count))
4940 packed.append(struct.pack("!Q", self.byte_count))
4941 packed.append(self.match.pack())
4942 length = sum([len(x) for x in packed])
4943 packed[2] = struct.pack("!H", length)
4944 return ''.join(packed)
4945
4946 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004947 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004948 obj = flow_removed()
Dan Talaycof6202252013-07-02 01:00:29 -07004949 _version = reader.read("!B")[0]
4950 assert(_version == 2)
4951 _type = reader.read("!B")[0]
4952 assert(_type == 11)
4953 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004954 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08004955 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07004956 obj.xid = reader.read("!L")[0]
4957 obj.cookie = reader.read("!Q")[0]
4958 obj.priority = reader.read("!H")[0]
4959 obj.reason = reader.read("!B")[0]
4960 obj.table_id = reader.read("!B")[0]
4961 obj.duration_sec = reader.read("!L")[0]
4962 obj.duration_nsec = reader.read("!L")[0]
4963 obj.idle_timeout = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004964 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07004965 obj.packet_count = reader.read("!Q")[0]
4966 obj.byte_count = reader.read("!Q")[0]
Rich Lanee2567702015-01-26 15:04:35 -08004967 obj.match = ofp.match.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004968 return obj
4969
4970 def __eq__(self, other):
4971 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004972 if self.xid != other.xid: return False
4973 if self.cookie != other.cookie: return False
4974 if self.priority != other.priority: return False
4975 if self.reason != other.reason: return False
4976 if self.table_id != other.table_id: return False
4977 if self.duration_sec != other.duration_sec: return False
4978 if self.duration_nsec != other.duration_nsec: return False
4979 if self.idle_timeout != other.idle_timeout: return False
4980 if self.packet_count != other.packet_count: return False
4981 if self.byte_count != other.byte_count: return False
4982 if self.match != other.match: return False
4983 return True
4984
Rich Lanec2ee4b82013-04-24 17:12:38 -07004985 def pretty_print(self, q):
4986 q.text("flow_removed {")
4987 with q.group():
4988 with q.indent(2):
4989 q.breakable()
4990 q.text("xid = ");
4991 if self.xid != None:
4992 q.text("%#x" % self.xid)
4993 else:
4994 q.text('None')
4995 q.text(","); q.breakable()
4996 q.text("cookie = ");
4997 q.text("%#x" % self.cookie)
4998 q.text(","); q.breakable()
4999 q.text("priority = ");
5000 q.text("%#x" % self.priority)
5001 q.text(","); q.breakable()
5002 q.text("reason = ");
5003 q.text("%#x" % self.reason)
5004 q.text(","); q.breakable()
5005 q.text("table_id = ");
5006 q.text("%#x" % self.table_id)
5007 q.text(","); q.breakable()
5008 q.text("duration_sec = ");
5009 q.text("%#x" % self.duration_sec)
5010 q.text(","); q.breakable()
5011 q.text("duration_nsec = ");
5012 q.text("%#x" % self.duration_nsec)
5013 q.text(","); q.breakable()
5014 q.text("idle_timeout = ");
5015 q.text("%#x" % self.idle_timeout)
5016 q.text(","); q.breakable()
5017 q.text("packet_count = ");
5018 q.text("%#x" % self.packet_count)
5019 q.text(","); q.breakable()
5020 q.text("byte_count = ");
5021 q.text("%#x" % self.byte_count)
5022 q.text(","); q.breakable()
5023 q.text("match = ");
5024 q.pp(self.match)
5025 q.breakable()
5026 q.text('}')
5027
Rich Lane7dcdf022013-12-11 14:45:27 -08005028message.subtypes[11] = flow_removed
5029
5030class flow_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07005031 version = 2
5032 type = 19
5033 stats_type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07005034
5035 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005036 if xid != None:
5037 self.xid = xid
5038 else:
5039 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005040 if flags != None:
5041 self.flags = flags
5042 else:
5043 self.flags = 0
5044 if entries != None:
5045 self.entries = entries
5046 else:
5047 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005048 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005049
5050 def pack(self):
5051 packed = []
5052 packed.append(struct.pack("!B", self.version))
5053 packed.append(struct.pack("!B", self.type))
5054 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5055 packed.append(struct.pack("!L", self.xid))
5056 packed.append(struct.pack("!H", self.stats_type))
5057 packed.append(struct.pack("!H", self.flags))
5058 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005059 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005060 length = sum([len(x) for x in packed])
5061 packed[2] = struct.pack("!H", length)
5062 return ''.join(packed)
5063
5064 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005065 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005066 obj = flow_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005067 _version = reader.read("!B")[0]
5068 assert(_version == 2)
5069 _type = reader.read("!B")[0]
5070 assert(_type == 19)
5071 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005072 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005073 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07005074 obj.xid = reader.read("!L")[0]
5075 _stats_type = reader.read("!H")[0]
5076 assert(_stats_type == 1)
5077 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005078 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08005079 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.flow_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005080 return obj
5081
5082 def __eq__(self, other):
5083 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005084 if self.xid != other.xid: return False
5085 if self.flags != other.flags: return False
5086 if self.entries != other.entries: return False
5087 return True
5088
Rich Lanec2ee4b82013-04-24 17:12:38 -07005089 def pretty_print(self, q):
5090 q.text("flow_stats_reply {")
5091 with q.group():
5092 with q.indent(2):
5093 q.breakable()
5094 q.text("xid = ");
5095 if self.xid != None:
5096 q.text("%#x" % self.xid)
5097 else:
5098 q.text('None')
5099 q.text(","); q.breakable()
5100 q.text("flags = ");
5101 q.text("%#x" % self.flags)
5102 q.text(","); q.breakable()
5103 q.text("entries = ");
5104 q.pp(self.entries)
5105 q.breakable()
5106 q.text('}')
5107
Rich Lane7dcdf022013-12-11 14:45:27 -08005108stats_reply.subtypes[1] = flow_stats_reply
5109
5110class flow_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07005111 version = 2
5112 type = 18
5113 stats_type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07005114
5115 def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005116 if xid != None:
5117 self.xid = xid
5118 else:
5119 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005120 if flags != None:
5121 self.flags = flags
5122 else:
5123 self.flags = 0
5124 if table_id != None:
5125 self.table_id = table_id
5126 else:
5127 self.table_id = 0
5128 if out_port != None:
5129 self.out_port = out_port
5130 else:
5131 self.out_port = 0
5132 if out_group != None:
5133 self.out_group = out_group
5134 else:
5135 self.out_group = 0
5136 if cookie != None:
5137 self.cookie = cookie
5138 else:
5139 self.cookie = 0
5140 if cookie_mask != None:
5141 self.cookie_mask = cookie_mask
5142 else:
5143 self.cookie_mask = 0
5144 if match != None:
5145 self.match = match
5146 else:
Rich Lanee2567702015-01-26 15:04:35 -08005147 self.match = ofp.match()
Rich Lane7dcdf022013-12-11 14:45:27 -08005148 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005149
5150 def pack(self):
5151 packed = []
5152 packed.append(struct.pack("!B", self.version))
5153 packed.append(struct.pack("!B", self.type))
5154 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5155 packed.append(struct.pack("!L", self.xid))
5156 packed.append(struct.pack("!H", self.stats_type))
5157 packed.append(struct.pack("!H", self.flags))
5158 packed.append('\x00' * 4)
5159 packed.append(struct.pack("!B", self.table_id))
5160 packed.append('\x00' * 3)
Dan Talaycof6202252013-07-02 01:00:29 -07005161 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005162 packed.append(struct.pack("!L", self.out_group))
5163 packed.append('\x00' * 4)
5164 packed.append(struct.pack("!Q", self.cookie))
5165 packed.append(struct.pack("!Q", self.cookie_mask))
5166 packed.append(self.match.pack())
5167 length = sum([len(x) for x in packed])
5168 packed[2] = struct.pack("!H", length)
5169 return ''.join(packed)
5170
5171 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005172 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005173 obj = flow_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005174 _version = reader.read("!B")[0]
5175 assert(_version == 2)
5176 _type = reader.read("!B")[0]
5177 assert(_type == 18)
5178 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005179 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005180 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07005181 obj.xid = reader.read("!L")[0]
5182 _stats_type = reader.read("!H")[0]
5183 assert(_stats_type == 1)
5184 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005185 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07005186 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005187 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07005188 obj.out_port = util.unpack_port_no(reader)
5189 obj.out_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005190 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07005191 obj.cookie = reader.read("!Q")[0]
5192 obj.cookie_mask = reader.read("!Q")[0]
Rich Lanee2567702015-01-26 15:04:35 -08005193 obj.match = ofp.match.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005194 return obj
5195
5196 def __eq__(self, other):
5197 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005198 if self.xid != other.xid: return False
5199 if self.flags != other.flags: return False
5200 if self.table_id != other.table_id: return False
5201 if self.out_port != other.out_port: return False
5202 if self.out_group != other.out_group: return False
5203 if self.cookie != other.cookie: return False
5204 if self.cookie_mask != other.cookie_mask: return False
5205 if self.match != other.match: return False
5206 return True
5207
Rich Lanec2ee4b82013-04-24 17:12:38 -07005208 def pretty_print(self, q):
5209 q.text("flow_stats_request {")
5210 with q.group():
5211 with q.indent(2):
5212 q.breakable()
5213 q.text("xid = ");
5214 if self.xid != None:
5215 q.text("%#x" % self.xid)
5216 else:
5217 q.text('None')
5218 q.text(","); q.breakable()
5219 q.text("flags = ");
5220 q.text("%#x" % self.flags)
5221 q.text(","); q.breakable()
5222 q.text("table_id = ");
5223 q.text("%#x" % self.table_id)
5224 q.text(","); q.breakable()
5225 q.text("out_port = ");
5226 q.text(util.pretty_port(self.out_port))
5227 q.text(","); q.breakable()
5228 q.text("out_group = ");
5229 q.text("%#x" % self.out_group)
5230 q.text(","); q.breakable()
5231 q.text("cookie = ");
5232 q.text("%#x" % self.cookie)
5233 q.text(","); q.breakable()
5234 q.text("cookie_mask = ");
5235 q.text("%#x" % self.cookie_mask)
5236 q.text(","); q.breakable()
5237 q.text("match = ");
5238 q.pp(self.match)
5239 q.breakable()
5240 q.text('}')
5241
Rich Lane7dcdf022013-12-11 14:45:27 -08005242stats_request.subtypes[1] = flow_stats_request
5243
5244class get_config_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005245 version = 2
5246 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07005247
5248 def __init__(self, xid=None, flags=None, miss_send_len=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005249 if xid != None:
5250 self.xid = xid
5251 else:
5252 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005253 if flags != None:
5254 self.flags = flags
5255 else:
5256 self.flags = 0
5257 if miss_send_len != None:
5258 self.miss_send_len = miss_send_len
5259 else:
5260 self.miss_send_len = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005261 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005262
5263 def pack(self):
5264 packed = []
5265 packed.append(struct.pack("!B", self.version))
5266 packed.append(struct.pack("!B", self.type))
5267 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5268 packed.append(struct.pack("!L", self.xid))
5269 packed.append(struct.pack("!H", self.flags))
5270 packed.append(struct.pack("!H", self.miss_send_len))
5271 length = sum([len(x) for x in packed])
5272 packed[2] = struct.pack("!H", length)
5273 return ''.join(packed)
5274
5275 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005276 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005277 obj = get_config_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005278 _version = reader.read("!B")[0]
5279 assert(_version == 2)
5280 _type = reader.read("!B")[0]
5281 assert(_type == 8)
5282 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005283 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005284 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07005285 obj.xid = reader.read("!L")[0]
5286 obj.flags = reader.read("!H")[0]
5287 obj.miss_send_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005288 return obj
5289
5290 def __eq__(self, other):
5291 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005292 if self.xid != other.xid: return False
5293 if self.flags != other.flags: return False
5294 if self.miss_send_len != other.miss_send_len: return False
5295 return True
5296
Rich Lanec2ee4b82013-04-24 17:12:38 -07005297 def pretty_print(self, q):
5298 q.text("get_config_reply {")
5299 with q.group():
5300 with q.indent(2):
5301 q.breakable()
5302 q.text("xid = ");
5303 if self.xid != None:
5304 q.text("%#x" % self.xid)
5305 else:
5306 q.text('None')
5307 q.text(","); q.breakable()
5308 q.text("flags = ");
5309 q.text("%#x" % self.flags)
5310 q.text(","); q.breakable()
5311 q.text("miss_send_len = ");
5312 q.text("%#x" % self.miss_send_len)
5313 q.breakable()
5314 q.text('}')
5315
Rich Lane7dcdf022013-12-11 14:45:27 -08005316message.subtypes[8] = get_config_reply
5317
5318class get_config_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005319 version = 2
5320 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07005321
5322 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005323 if xid != None:
5324 self.xid = xid
5325 else:
5326 self.xid = None
5327 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005328
5329 def pack(self):
5330 packed = []
5331 packed.append(struct.pack("!B", self.version))
5332 packed.append(struct.pack("!B", self.type))
5333 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5334 packed.append(struct.pack("!L", self.xid))
5335 length = sum([len(x) for x in packed])
5336 packed[2] = struct.pack("!H", length)
5337 return ''.join(packed)
5338
5339 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005340 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005341 obj = get_config_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005342 _version = reader.read("!B")[0]
5343 assert(_version == 2)
5344 _type = reader.read("!B")[0]
5345 assert(_type == 7)
5346 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005347 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005348 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07005349 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005350 return obj
5351
5352 def __eq__(self, other):
5353 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005354 if self.xid != other.xid: return False
5355 return True
5356
Rich Lanec2ee4b82013-04-24 17:12:38 -07005357 def pretty_print(self, q):
5358 q.text("get_config_request {")
5359 with q.group():
5360 with q.indent(2):
5361 q.breakable()
5362 q.text("xid = ");
5363 if self.xid != None:
5364 q.text("%#x" % self.xid)
5365 else:
5366 q.text('None')
5367 q.breakable()
5368 q.text('}')
5369
Rich Lane7dcdf022013-12-11 14:45:27 -08005370message.subtypes[7] = get_config_request
5371
5372class group_mod(message):
5373 subtypes = {}
5374
Rich Lane95f7fc92014-01-27 17:08:16 -08005375 version = 2
5376 type = 15
5377
5378 def __init__(self, xid=None, command=None, group_type=None, group_id=None, buckets=None):
5379 if xid != None:
5380 self.xid = xid
5381 else:
5382 self.xid = None
5383 if command != None:
5384 self.command = command
5385 else:
5386 self.command = 0
5387 if group_type != None:
5388 self.group_type = group_type
5389 else:
5390 self.group_type = 0
5391 if group_id != None:
5392 self.group_id = group_id
5393 else:
5394 self.group_id = 0
5395 if buckets != None:
5396 self.buckets = buckets
5397 else:
5398 self.buckets = []
5399 return
5400
5401 def pack(self):
5402 packed = []
5403 packed.append(struct.pack("!B", self.version))
5404 packed.append(struct.pack("!B", self.type))
5405 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5406 packed.append(struct.pack("!L", self.xid))
5407 packed.append(struct.pack("!H", self.command))
5408 packed.append(struct.pack("!B", self.group_type))
5409 packed.append('\x00' * 1)
5410 packed.append(struct.pack("!L", self.group_id))
5411 packed.append(loxi.generic_util.pack_list(self.buckets))
5412 length = sum([len(x) for x in packed])
5413 packed[2] = struct.pack("!H", length)
5414 return ''.join(packed)
5415
Rich Lane7dcdf022013-12-11 14:45:27 -08005416 @staticmethod
5417 def unpack(reader):
5418 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08005419 subclass = group_mod.subtypes.get(subtype)
5420 if subclass:
5421 return subclass.unpack(reader)
5422
5423 obj = group_mod()
5424 _version = reader.read("!B")[0]
5425 assert(_version == 2)
5426 _type = reader.read("!B")[0]
5427 assert(_type == 15)
5428 _length = reader.read("!H")[0]
5429 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005430 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08005431 obj.xid = reader.read("!L")[0]
5432 obj.command = reader.read("!H")[0]
5433 obj.group_type = reader.read("!B")[0]
5434 reader.skip(1)
5435 obj.group_id = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08005436 obj.buckets = loxi.generic_util.unpack_list(reader, ofp.common.bucket.unpack)
Rich Lane95f7fc92014-01-27 17:08:16 -08005437 return obj
5438
5439 def __eq__(self, other):
5440 if type(self) != type(other): return False
5441 if self.xid != other.xid: return False
5442 if self.command != other.command: return False
5443 if self.group_type != other.group_type: return False
5444 if self.group_id != other.group_id: return False
5445 if self.buckets != other.buckets: return False
5446 return True
5447
5448 def pretty_print(self, q):
5449 q.text("group_mod {")
5450 with q.group():
5451 with q.indent(2):
5452 q.breakable()
5453 q.text("xid = ");
5454 if self.xid != None:
5455 q.text("%#x" % self.xid)
5456 else:
5457 q.text('None')
5458 q.text(","); q.breakable()
5459 q.text("group_type = ");
5460 q.text("%#x" % self.group_type)
5461 q.text(","); q.breakable()
5462 q.text("group_id = ");
5463 q.text("%#x" % self.group_id)
5464 q.text(","); q.breakable()
5465 q.text("buckets = ");
5466 q.pp(self.buckets)
5467 q.breakable()
5468 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08005469
5470message.subtypes[15] = group_mod
5471
5472class group_add(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08005473 version = 2
5474 type = 15
5475 command = 0
5476
5477 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005478 if xid != None:
5479 self.xid = xid
5480 else:
5481 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08005482 if group_type != None:
5483 self.group_type = group_type
5484 else:
5485 self.group_type = 0
5486 if group_id != None:
5487 self.group_id = group_id
5488 else:
5489 self.group_id = 0
5490 if buckets != None:
5491 self.buckets = buckets
5492 else:
5493 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005494 return
Rich Lane7b0f2012013-11-22 14:15:26 -08005495
5496 def pack(self):
5497 packed = []
5498 packed.append(struct.pack("!B", self.version))
5499 packed.append(struct.pack("!B", self.type))
5500 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5501 packed.append(struct.pack("!L", self.xid))
5502 packed.append(struct.pack("!H", self.command))
5503 packed.append(struct.pack("!B", self.group_type))
5504 packed.append('\x00' * 1)
5505 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08005506 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08005507 length = sum([len(x) for x in packed])
5508 packed[2] = struct.pack("!H", length)
5509 return ''.join(packed)
5510
5511 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005512 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08005513 obj = group_add()
Rich Lane7b0f2012013-11-22 14:15:26 -08005514 _version = reader.read("!B")[0]
5515 assert(_version == 2)
5516 _type = reader.read("!B")[0]
5517 assert(_type == 15)
5518 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005519 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005520 reader = orig_reader.slice(_length, 4)
Rich Lane7b0f2012013-11-22 14:15:26 -08005521 obj.xid = reader.read("!L")[0]
5522 _command = reader.read("!H")[0]
5523 assert(_command == 0)
5524 obj.group_type = reader.read("!B")[0]
5525 reader.skip(1)
5526 obj.group_id = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08005527 obj.buckets = loxi.generic_util.unpack_list(reader, ofp.common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08005528 return obj
5529
5530 def __eq__(self, other):
5531 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08005532 if self.xid != other.xid: return False
5533 if self.group_type != other.group_type: return False
5534 if self.group_id != other.group_id: return False
5535 if self.buckets != other.buckets: return False
5536 return True
5537
Rich Lane7b0f2012013-11-22 14:15:26 -08005538 def pretty_print(self, q):
5539 q.text("group_add {")
5540 with q.group():
5541 with q.indent(2):
5542 q.breakable()
5543 q.text("xid = ");
5544 if self.xid != None:
5545 q.text("%#x" % self.xid)
5546 else:
5547 q.text('None')
5548 q.text(","); q.breakable()
5549 q.text("group_type = ");
5550 q.text("%#x" % self.group_type)
5551 q.text(","); q.breakable()
5552 q.text("group_id = ");
5553 q.text("%#x" % self.group_id)
5554 q.text(","); q.breakable()
5555 q.text("buckets = ");
5556 q.pp(self.buckets)
5557 q.breakable()
5558 q.text('}')
5559
Rich Lane7dcdf022013-12-11 14:45:27 -08005560group_mod.subtypes[0] = group_add
5561
5562class group_delete(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08005563 version = 2
5564 type = 15
5565 command = 2
5566
5567 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005568 if xid != None:
5569 self.xid = xid
5570 else:
5571 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08005572 if group_type != None:
5573 self.group_type = group_type
5574 else:
5575 self.group_type = 0
5576 if group_id != None:
5577 self.group_id = group_id
5578 else:
5579 self.group_id = 0
5580 if buckets != None:
5581 self.buckets = buckets
5582 else:
5583 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005584 return
Rich Lane7b0f2012013-11-22 14:15:26 -08005585
5586 def pack(self):
5587 packed = []
5588 packed.append(struct.pack("!B", self.version))
5589 packed.append(struct.pack("!B", self.type))
5590 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5591 packed.append(struct.pack("!L", self.xid))
5592 packed.append(struct.pack("!H", self.command))
5593 packed.append(struct.pack("!B", self.group_type))
5594 packed.append('\x00' * 1)
5595 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08005596 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08005597 length = sum([len(x) for x in packed])
5598 packed[2] = struct.pack("!H", length)
5599 return ''.join(packed)
5600
5601 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005602 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08005603 obj = group_delete()
Rich Lane7b0f2012013-11-22 14:15:26 -08005604 _version = reader.read("!B")[0]
5605 assert(_version == 2)
5606 _type = reader.read("!B")[0]
5607 assert(_type == 15)
5608 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005609 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005610 reader = orig_reader.slice(_length, 4)
Rich Lane7b0f2012013-11-22 14:15:26 -08005611 obj.xid = reader.read("!L")[0]
5612 _command = reader.read("!H")[0]
5613 assert(_command == 2)
5614 obj.group_type = reader.read("!B")[0]
5615 reader.skip(1)
5616 obj.group_id = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08005617 obj.buckets = loxi.generic_util.unpack_list(reader, ofp.common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08005618 return obj
5619
5620 def __eq__(self, other):
5621 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08005622 if self.xid != other.xid: return False
5623 if self.group_type != other.group_type: return False
5624 if self.group_id != other.group_id: return False
5625 if self.buckets != other.buckets: return False
5626 return True
5627
Rich Lane7b0f2012013-11-22 14:15:26 -08005628 def pretty_print(self, q):
5629 q.text("group_delete {")
5630 with q.group():
5631 with q.indent(2):
5632 q.breakable()
5633 q.text("xid = ");
5634 if self.xid != None:
5635 q.text("%#x" % self.xid)
5636 else:
5637 q.text('None')
5638 q.text(","); q.breakable()
5639 q.text("group_type = ");
5640 q.text("%#x" % self.group_type)
5641 q.text(","); q.breakable()
5642 q.text("group_id = ");
5643 q.text("%#x" % self.group_id)
5644 q.text(","); q.breakable()
5645 q.text("buckets = ");
5646 q.pp(self.buckets)
5647 q.breakable()
5648 q.text('}')
5649
Rich Lane7dcdf022013-12-11 14:45:27 -08005650group_mod.subtypes[2] = group_delete
5651
5652class group_desc_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07005653 version = 2
5654 type = 19
5655 stats_type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07005656
5657 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005658 if xid != None:
5659 self.xid = xid
5660 else:
5661 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005662 if flags != None:
5663 self.flags = flags
5664 else:
5665 self.flags = 0
5666 if entries != None:
5667 self.entries = entries
5668 else:
5669 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005670 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005671
5672 def pack(self):
5673 packed = []
5674 packed.append(struct.pack("!B", self.version))
5675 packed.append(struct.pack("!B", self.type))
5676 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5677 packed.append(struct.pack("!L", self.xid))
5678 packed.append(struct.pack("!H", self.stats_type))
5679 packed.append(struct.pack("!H", self.flags))
5680 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005681 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005682 length = sum([len(x) for x in packed])
5683 packed[2] = struct.pack("!H", length)
5684 return ''.join(packed)
5685
5686 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005687 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005688 obj = group_desc_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005689 _version = reader.read("!B")[0]
5690 assert(_version == 2)
5691 _type = reader.read("!B")[0]
5692 assert(_type == 19)
5693 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005694 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005695 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07005696 obj.xid = reader.read("!L")[0]
5697 _stats_type = reader.read("!H")[0]
5698 assert(_stats_type == 7)
5699 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005700 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08005701 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.group_desc_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005702 return obj
5703
5704 def __eq__(self, other):
5705 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005706 if self.xid != other.xid: return False
5707 if self.flags != other.flags: return False
5708 if self.entries != other.entries: return False
5709 return True
5710
Rich Lanec2ee4b82013-04-24 17:12:38 -07005711 def pretty_print(self, q):
5712 q.text("group_desc_stats_reply {")
5713 with q.group():
5714 with q.indent(2):
5715 q.breakable()
5716 q.text("xid = ");
5717 if self.xid != None:
5718 q.text("%#x" % self.xid)
5719 else:
5720 q.text('None')
5721 q.text(","); q.breakable()
5722 q.text("flags = ");
5723 q.text("%#x" % self.flags)
5724 q.text(","); q.breakable()
5725 q.text("entries = ");
5726 q.pp(self.entries)
5727 q.breakable()
5728 q.text('}')
5729
Rich Lane7dcdf022013-12-11 14:45:27 -08005730stats_reply.subtypes[7] = group_desc_stats_reply
5731
5732class group_desc_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07005733 version = 2
5734 type = 18
5735 stats_type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07005736
5737 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005738 if xid != None:
5739 self.xid = xid
5740 else:
5741 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005742 if flags != None:
5743 self.flags = flags
5744 else:
5745 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005746 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005747
5748 def pack(self):
5749 packed = []
5750 packed.append(struct.pack("!B", self.version))
5751 packed.append(struct.pack("!B", self.type))
5752 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5753 packed.append(struct.pack("!L", self.xid))
5754 packed.append(struct.pack("!H", self.stats_type))
5755 packed.append(struct.pack("!H", self.flags))
5756 packed.append('\x00' * 4)
5757 length = sum([len(x) for x in packed])
5758 packed[2] = struct.pack("!H", length)
5759 return ''.join(packed)
5760
5761 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005762 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005763 obj = group_desc_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005764 _version = reader.read("!B")[0]
5765 assert(_version == 2)
5766 _type = reader.read("!B")[0]
5767 assert(_type == 18)
5768 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005769 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005770 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07005771 obj.xid = reader.read("!L")[0]
5772 _stats_type = reader.read("!H")[0]
5773 assert(_stats_type == 7)
5774 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005775 reader.skip(4)
5776 return obj
5777
5778 def __eq__(self, other):
5779 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005780 if self.xid != other.xid: return False
5781 if self.flags != other.flags: return False
5782 return True
5783
Rich Lanec2ee4b82013-04-24 17:12:38 -07005784 def pretty_print(self, q):
5785 q.text("group_desc_stats_request {")
5786 with q.group():
5787 with q.indent(2):
5788 q.breakable()
5789 q.text("xid = ");
5790 if self.xid != None:
5791 q.text("%#x" % self.xid)
5792 else:
5793 q.text('None')
5794 q.text(","); q.breakable()
5795 q.text("flags = ");
5796 q.text("%#x" % self.flags)
5797 q.breakable()
5798 q.text('}')
5799
Rich Lane7dcdf022013-12-11 14:45:27 -08005800stats_request.subtypes[7] = group_desc_stats_request
5801
5802class group_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07005803 version = 2
5804 type = 1
5805 err_type = 6
5806
5807 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005808 if xid != None:
5809 self.xid = xid
5810 else:
5811 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07005812 if code != None:
5813 self.code = code
5814 else:
5815 self.code = 0
5816 if data != None:
5817 self.data = data
5818 else:
5819 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08005820 return
Rich Lane6f4978c2013-10-20 21:33:52 -07005821
5822 def pack(self):
5823 packed = []
5824 packed.append(struct.pack("!B", self.version))
5825 packed.append(struct.pack("!B", self.type))
5826 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5827 packed.append(struct.pack("!L", self.xid))
5828 packed.append(struct.pack("!H", self.err_type))
5829 packed.append(struct.pack("!H", self.code))
5830 packed.append(self.data)
5831 length = sum([len(x) for x in packed])
5832 packed[2] = struct.pack("!H", length)
5833 return ''.join(packed)
5834
5835 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005836 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07005837 obj = group_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07005838 _version = reader.read("!B")[0]
5839 assert(_version == 2)
5840 _type = reader.read("!B")[0]
5841 assert(_type == 1)
5842 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005843 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005844 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07005845 obj.xid = reader.read("!L")[0]
5846 _err_type = reader.read("!H")[0]
5847 assert(_err_type == 6)
5848 obj.code = reader.read("!H")[0]
5849 obj.data = str(reader.read_all())
5850 return obj
5851
5852 def __eq__(self, other):
5853 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07005854 if self.xid != other.xid: return False
5855 if self.code != other.code: return False
5856 if self.data != other.data: return False
5857 return True
5858
Rich Lane6f4978c2013-10-20 21:33:52 -07005859 def pretty_print(self, q):
5860 q.text("group_mod_failed_error_msg {")
5861 with q.group():
5862 with q.indent(2):
5863 q.breakable()
5864 q.text("xid = ");
5865 if self.xid != None:
5866 q.text("%#x" % self.xid)
5867 else:
5868 q.text('None')
5869 q.text(","); q.breakable()
5870 q.text("code = ");
5871 q.text("%#x" % self.code)
5872 q.text(","); q.breakable()
5873 q.text("data = ");
5874 q.pp(self.data)
5875 q.breakable()
5876 q.text('}')
5877
Rich Lane7dcdf022013-12-11 14:45:27 -08005878error_msg.subtypes[6] = group_mod_failed_error_msg
5879
5880class group_modify(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08005881 version = 2
5882 type = 15
5883 command = 1
5884
5885 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005886 if xid != None:
5887 self.xid = xid
5888 else:
5889 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08005890 if group_type != None:
5891 self.group_type = group_type
5892 else:
5893 self.group_type = 0
5894 if group_id != None:
5895 self.group_id = group_id
5896 else:
5897 self.group_id = 0
5898 if buckets != None:
5899 self.buckets = buckets
5900 else:
5901 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005902 return
Rich Lane7b0f2012013-11-22 14:15:26 -08005903
5904 def pack(self):
5905 packed = []
5906 packed.append(struct.pack("!B", self.version))
5907 packed.append(struct.pack("!B", self.type))
5908 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5909 packed.append(struct.pack("!L", self.xid))
5910 packed.append(struct.pack("!H", self.command))
5911 packed.append(struct.pack("!B", self.group_type))
5912 packed.append('\x00' * 1)
5913 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08005914 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08005915 length = sum([len(x) for x in packed])
5916 packed[2] = struct.pack("!H", length)
5917 return ''.join(packed)
5918
5919 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005920 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08005921 obj = group_modify()
Rich Lane7b0f2012013-11-22 14:15:26 -08005922 _version = reader.read("!B")[0]
5923 assert(_version == 2)
5924 _type = reader.read("!B")[0]
5925 assert(_type == 15)
5926 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005927 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005928 reader = orig_reader.slice(_length, 4)
Rich Lane7b0f2012013-11-22 14:15:26 -08005929 obj.xid = reader.read("!L")[0]
5930 _command = reader.read("!H")[0]
5931 assert(_command == 1)
5932 obj.group_type = reader.read("!B")[0]
5933 reader.skip(1)
5934 obj.group_id = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08005935 obj.buckets = loxi.generic_util.unpack_list(reader, ofp.common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08005936 return obj
5937
5938 def __eq__(self, other):
5939 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08005940 if self.xid != other.xid: return False
5941 if self.group_type != other.group_type: return False
5942 if self.group_id != other.group_id: return False
5943 if self.buckets != other.buckets: return False
5944 return True
5945
Rich Lane7b0f2012013-11-22 14:15:26 -08005946 def pretty_print(self, q):
5947 q.text("group_modify {")
5948 with q.group():
5949 with q.indent(2):
5950 q.breakable()
5951 q.text("xid = ");
5952 if self.xid != None:
5953 q.text("%#x" % self.xid)
5954 else:
5955 q.text('None')
5956 q.text(","); q.breakable()
5957 q.text("group_type = ");
5958 q.text("%#x" % self.group_type)
5959 q.text(","); q.breakable()
5960 q.text("group_id = ");
5961 q.text("%#x" % self.group_id)
5962 q.text(","); q.breakable()
5963 q.text("buckets = ");
5964 q.pp(self.buckets)
5965 q.breakable()
5966 q.text('}')
5967
Rich Lane7dcdf022013-12-11 14:45:27 -08005968group_mod.subtypes[1] = group_modify
5969
5970class group_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07005971 version = 2
5972 type = 19
5973 stats_type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07005974
5975 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005976 if xid != None:
5977 self.xid = xid
5978 else:
5979 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005980 if flags != None:
5981 self.flags = flags
5982 else:
5983 self.flags = 0
5984 if entries != None:
5985 self.entries = entries
5986 else:
5987 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005988 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005989
5990 def pack(self):
5991 packed = []
5992 packed.append(struct.pack("!B", self.version))
5993 packed.append(struct.pack("!B", self.type))
5994 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5995 packed.append(struct.pack("!L", self.xid))
5996 packed.append(struct.pack("!H", self.stats_type))
5997 packed.append(struct.pack("!H", self.flags))
5998 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005999 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006000 length = sum([len(x) for x in packed])
6001 packed[2] = struct.pack("!H", length)
6002 return ''.join(packed)
6003
6004 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006005 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006006 obj = group_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07006007 _version = reader.read("!B")[0]
6008 assert(_version == 2)
6009 _type = reader.read("!B")[0]
6010 assert(_type == 19)
6011 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006012 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006013 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006014 obj.xid = reader.read("!L")[0]
6015 _stats_type = reader.read("!H")[0]
6016 assert(_stats_type == 6)
6017 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006018 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08006019 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.group_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006020 return obj
6021
6022 def __eq__(self, other):
6023 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006024 if self.xid != other.xid: return False
6025 if self.flags != other.flags: return False
6026 if self.entries != other.entries: return False
6027 return True
6028
Rich Lanec2ee4b82013-04-24 17:12:38 -07006029 def pretty_print(self, q):
6030 q.text("group_stats_reply {")
6031 with q.group():
6032 with q.indent(2):
6033 q.breakable()
6034 q.text("xid = ");
6035 if self.xid != None:
6036 q.text("%#x" % self.xid)
6037 else:
6038 q.text('None')
6039 q.text(","); q.breakable()
6040 q.text("flags = ");
6041 q.text("%#x" % self.flags)
6042 q.text(","); q.breakable()
6043 q.text("entries = ");
6044 q.pp(self.entries)
6045 q.breakable()
6046 q.text('}')
6047
Rich Lane7dcdf022013-12-11 14:45:27 -08006048stats_reply.subtypes[6] = group_stats_reply
6049
6050class group_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07006051 version = 2
6052 type = 18
6053 stats_type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07006054
6055 def __init__(self, xid=None, flags=None, group_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006056 if xid != None:
6057 self.xid = xid
6058 else:
6059 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006060 if flags != None:
6061 self.flags = flags
6062 else:
6063 self.flags = 0
6064 if group_id != None:
6065 self.group_id = group_id
6066 else:
6067 self.group_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006068 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006069
6070 def pack(self):
6071 packed = []
6072 packed.append(struct.pack("!B", self.version))
6073 packed.append(struct.pack("!B", self.type))
6074 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6075 packed.append(struct.pack("!L", self.xid))
6076 packed.append(struct.pack("!H", self.stats_type))
6077 packed.append(struct.pack("!H", self.flags))
6078 packed.append('\x00' * 4)
6079 packed.append(struct.pack("!L", self.group_id))
6080 packed.append('\x00' * 4)
6081 length = sum([len(x) for x in packed])
6082 packed[2] = struct.pack("!H", length)
6083 return ''.join(packed)
6084
6085 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006086 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006087 obj = group_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07006088 _version = reader.read("!B")[0]
6089 assert(_version == 2)
6090 _type = reader.read("!B")[0]
6091 assert(_type == 18)
6092 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006093 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006094 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006095 obj.xid = reader.read("!L")[0]
6096 _stats_type = reader.read("!H")[0]
6097 assert(_stats_type == 6)
6098 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006099 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07006100 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006101 reader.skip(4)
6102 return obj
6103
6104 def __eq__(self, other):
6105 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006106 if self.xid != other.xid: return False
6107 if self.flags != other.flags: return False
6108 if self.group_id != other.group_id: return False
6109 return True
6110
Rich Lanec2ee4b82013-04-24 17:12:38 -07006111 def pretty_print(self, q):
6112 q.text("group_stats_request {")
6113 with q.group():
6114 with q.indent(2):
6115 q.breakable()
6116 q.text("xid = ");
6117 if self.xid != None:
6118 q.text("%#x" % self.xid)
6119 else:
6120 q.text('None')
6121 q.text(","); q.breakable()
6122 q.text("flags = ");
6123 q.text("%#x" % self.flags)
6124 q.text(","); q.breakable()
6125 q.text("group_id = ");
6126 q.text("%#x" % self.group_id)
6127 q.breakable()
6128 q.text('}')
6129
Rich Lane7dcdf022013-12-11 14:45:27 -08006130stats_request.subtypes[6] = group_stats_request
6131
6132class hello(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006133 version = 2
6134 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07006135
6136 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006137 if xid != None:
6138 self.xid = xid
6139 else:
6140 self.xid = None
6141 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006142
6143 def pack(self):
6144 packed = []
6145 packed.append(struct.pack("!B", self.version))
6146 packed.append(struct.pack("!B", self.type))
6147 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6148 packed.append(struct.pack("!L", self.xid))
6149 length = sum([len(x) for x in packed])
6150 packed[2] = struct.pack("!H", length)
6151 return ''.join(packed)
6152
6153 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006154 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006155 obj = hello()
Dan Talaycof6202252013-07-02 01:00:29 -07006156 _version = reader.read("!B")[0]
6157 assert(_version == 2)
6158 _type = reader.read("!B")[0]
6159 assert(_type == 0)
6160 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006161 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006162 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006163 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006164 return obj
6165
6166 def __eq__(self, other):
6167 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006168 if self.xid != other.xid: return False
6169 return True
6170
Rich Lanec2ee4b82013-04-24 17:12:38 -07006171 def pretty_print(self, q):
6172 q.text("hello {")
6173 with q.group():
6174 with q.indent(2):
6175 q.breakable()
6176 q.text("xid = ");
6177 if self.xid != None:
6178 q.text("%#x" % self.xid)
6179 else:
6180 q.text('None')
6181 q.breakable()
6182 q.text('}')
6183
Rich Lane7dcdf022013-12-11 14:45:27 -08006184message.subtypes[0] = hello
6185
6186class hello_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07006187 version = 2
6188 type = 1
6189 err_type = 0
6190
6191 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006192 if xid != None:
6193 self.xid = xid
6194 else:
6195 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07006196 if code != None:
6197 self.code = code
6198 else:
6199 self.code = 0
6200 if data != None:
6201 self.data = data
6202 else:
6203 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006204 return
Rich Lane6f4978c2013-10-20 21:33:52 -07006205
6206 def pack(self):
6207 packed = []
6208 packed.append(struct.pack("!B", self.version))
6209 packed.append(struct.pack("!B", self.type))
6210 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6211 packed.append(struct.pack("!L", self.xid))
6212 packed.append(struct.pack("!H", self.err_type))
6213 packed.append(struct.pack("!H", self.code))
6214 packed.append(self.data)
6215 length = sum([len(x) for x in packed])
6216 packed[2] = struct.pack("!H", length)
6217 return ''.join(packed)
6218
6219 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006220 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07006221 obj = hello_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07006222 _version = reader.read("!B")[0]
6223 assert(_version == 2)
6224 _type = reader.read("!B")[0]
6225 assert(_type == 1)
6226 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006227 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006228 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07006229 obj.xid = reader.read("!L")[0]
6230 _err_type = reader.read("!H")[0]
6231 assert(_err_type == 0)
6232 obj.code = reader.read("!H")[0]
6233 obj.data = str(reader.read_all())
6234 return obj
6235
6236 def __eq__(self, other):
6237 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07006238 if self.xid != other.xid: return False
6239 if self.code != other.code: return False
6240 if self.data != other.data: return False
6241 return True
6242
Rich Lane6f4978c2013-10-20 21:33:52 -07006243 def pretty_print(self, q):
6244 q.text("hello_failed_error_msg {")
6245 with q.group():
6246 with q.indent(2):
6247 q.breakable()
6248 q.text("xid = ");
6249 if self.xid != None:
6250 q.text("%#x" % self.xid)
6251 else:
6252 q.text('None')
6253 q.text(","); q.breakable()
6254 q.text("code = ");
6255 q.text("%#x" % self.code)
6256 q.text(","); q.breakable()
6257 q.text("data = ");
6258 q.pp(self.data)
6259 q.breakable()
6260 q.text('}')
6261
Rich Lane7dcdf022013-12-11 14:45:27 -08006262error_msg.subtypes[0] = hello_failed_error_msg
6263
6264class nicira_header(experimenter):
6265 subtypes = {}
6266
Rich Lane95f7fc92014-01-27 17:08:16 -08006267 version = 2
6268 type = 4
6269 experimenter = 8992
6270
6271 def __init__(self, xid=None, subtype=None):
6272 if xid != None:
6273 self.xid = xid
6274 else:
6275 self.xid = None
6276 if subtype != None:
6277 self.subtype = subtype
6278 else:
6279 self.subtype = 0
6280 return
6281
6282 def pack(self):
6283 packed = []
6284 packed.append(struct.pack("!B", self.version))
6285 packed.append(struct.pack("!B", self.type))
6286 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6287 packed.append(struct.pack("!L", self.xid))
6288 packed.append(struct.pack("!L", self.experimenter))
6289 packed.append(struct.pack("!L", self.subtype))
6290 length = sum([len(x) for x in packed])
6291 packed[2] = struct.pack("!H", length)
6292 return ''.join(packed)
6293
Rich Lane7dcdf022013-12-11 14:45:27 -08006294 @staticmethod
6295 def unpack(reader):
6296 subtype, = reader.peek('!L', 12)
Rich Lane95f7fc92014-01-27 17:08:16 -08006297 subclass = nicira_header.subtypes.get(subtype)
6298 if subclass:
6299 return subclass.unpack(reader)
6300
6301 obj = nicira_header()
6302 _version = reader.read("!B")[0]
6303 assert(_version == 2)
6304 _type = reader.read("!B")[0]
6305 assert(_type == 4)
6306 _length = reader.read("!H")[0]
6307 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006308 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08006309 obj.xid = reader.read("!L")[0]
6310 _experimenter = reader.read("!L")[0]
6311 assert(_experimenter == 8992)
6312 obj.subtype = reader.read("!L")[0]
6313 return obj
6314
6315 def __eq__(self, other):
6316 if type(self) != type(other): return False
6317 if self.xid != other.xid: return False
6318 if self.subtype != other.subtype: return False
6319 return True
6320
6321 def pretty_print(self, q):
6322 q.text("nicira_header {")
6323 with q.group():
6324 with q.indent(2):
6325 q.breakable()
6326 q.text("xid = ");
6327 if self.xid != None:
6328 q.text("%#x" % self.xid)
6329 else:
6330 q.text('None')
6331 q.breakable()
6332 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08006333
6334experimenter.subtypes[8992] = nicira_header
6335
6336class packet_in(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006337 version = 2
6338 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07006339
6340 def __init__(self, xid=None, buffer_id=None, in_port=None, in_phy_port=None, total_len=None, reason=None, table_id=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006341 if xid != None:
6342 self.xid = xid
6343 else:
6344 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006345 if buffer_id != None:
6346 self.buffer_id = buffer_id
6347 else:
6348 self.buffer_id = 0
6349 if in_port != None:
6350 self.in_port = in_port
6351 else:
6352 self.in_port = 0
6353 if in_phy_port != None:
6354 self.in_phy_port = in_phy_port
6355 else:
6356 self.in_phy_port = 0
6357 if total_len != None:
6358 self.total_len = total_len
6359 else:
6360 self.total_len = 0
6361 if reason != None:
6362 self.reason = reason
6363 else:
6364 self.reason = 0
6365 if table_id != None:
6366 self.table_id = table_id
6367 else:
6368 self.table_id = 0
6369 if data != None:
6370 self.data = data
6371 else:
Dan Talaycof6202252013-07-02 01:00:29 -07006372 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006373 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006374
6375 def pack(self):
6376 packed = []
6377 packed.append(struct.pack("!B", self.version))
6378 packed.append(struct.pack("!B", self.type))
6379 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6380 packed.append(struct.pack("!L", self.xid))
6381 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07006382 packed.append(util.pack_port_no(self.in_port))
6383 packed.append(util.pack_port_no(self.in_phy_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006384 packed.append(struct.pack("!H", self.total_len))
6385 packed.append(struct.pack("!B", self.reason))
6386 packed.append(struct.pack("!B", self.table_id))
6387 packed.append(self.data)
6388 length = sum([len(x) for x in packed])
6389 packed[2] = struct.pack("!H", length)
6390 return ''.join(packed)
6391
6392 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006393 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006394 obj = packet_in()
Dan Talaycof6202252013-07-02 01:00:29 -07006395 _version = reader.read("!B")[0]
6396 assert(_version == 2)
6397 _type = reader.read("!B")[0]
6398 assert(_type == 10)
6399 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006400 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006401 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006402 obj.xid = reader.read("!L")[0]
6403 obj.buffer_id = reader.read("!L")[0]
6404 obj.in_port = util.unpack_port_no(reader)
6405 obj.in_phy_port = util.unpack_port_no(reader)
6406 obj.total_len = reader.read("!H")[0]
6407 obj.reason = reader.read("!B")[0]
6408 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006409 obj.data = str(reader.read_all())
6410 return obj
6411
6412 def __eq__(self, other):
6413 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006414 if self.xid != other.xid: return False
6415 if self.buffer_id != other.buffer_id: return False
6416 if self.in_port != other.in_port: return False
6417 if self.in_phy_port != other.in_phy_port: return False
6418 if self.total_len != other.total_len: return False
6419 if self.reason != other.reason: return False
6420 if self.table_id != other.table_id: return False
6421 if self.data != other.data: return False
6422 return True
6423
Rich Lanec2ee4b82013-04-24 17:12:38 -07006424 def pretty_print(self, q):
6425 q.text("packet_in {")
6426 with q.group():
6427 with q.indent(2):
6428 q.breakable()
6429 q.text("xid = ");
6430 if self.xid != None:
6431 q.text("%#x" % self.xid)
6432 else:
6433 q.text('None')
6434 q.text(","); q.breakable()
6435 q.text("buffer_id = ");
6436 q.text("%#x" % self.buffer_id)
6437 q.text(","); q.breakable()
6438 q.text("in_port = ");
6439 q.text(util.pretty_port(self.in_port))
6440 q.text(","); q.breakable()
6441 q.text("in_phy_port = ");
6442 q.text(util.pretty_port(self.in_phy_port))
6443 q.text(","); q.breakable()
6444 q.text("total_len = ");
6445 q.text("%#x" % self.total_len)
6446 q.text(","); q.breakable()
6447 q.text("reason = ");
6448 q.text("%#x" % self.reason)
6449 q.text(","); q.breakable()
6450 q.text("table_id = ");
6451 q.text("%#x" % self.table_id)
6452 q.text(","); q.breakable()
6453 q.text("data = ");
6454 q.pp(self.data)
6455 q.breakable()
6456 q.text('}')
6457
Rich Lane7dcdf022013-12-11 14:45:27 -08006458message.subtypes[10] = packet_in
6459
6460class packet_out(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006461 version = 2
6462 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07006463
6464 def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006465 if xid != None:
6466 self.xid = xid
6467 else:
6468 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006469 if buffer_id != None:
6470 self.buffer_id = buffer_id
6471 else:
6472 self.buffer_id = 0
6473 if in_port != None:
6474 self.in_port = in_port
6475 else:
6476 self.in_port = 0
6477 if actions != None:
6478 self.actions = actions
6479 else:
6480 self.actions = []
6481 if data != None:
6482 self.data = data
6483 else:
Dan Talaycof6202252013-07-02 01:00:29 -07006484 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006485 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006486
6487 def pack(self):
6488 packed = []
6489 packed.append(struct.pack("!B", self.version))
6490 packed.append(struct.pack("!B", self.type))
6491 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6492 packed.append(struct.pack("!L", self.xid))
6493 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07006494 packed.append(util.pack_port_no(self.in_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006495 packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6
6496 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -08006497 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006498 packed[6] = struct.pack("!H", len(packed[-1]))
6499 packed.append(self.data)
6500 length = sum([len(x) for x in packed])
6501 packed[2] = struct.pack("!H", length)
6502 return ''.join(packed)
6503
6504 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006505 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006506 obj = packet_out()
Dan Talaycof6202252013-07-02 01:00:29 -07006507 _version = reader.read("!B")[0]
6508 assert(_version == 2)
6509 _type = reader.read("!B")[0]
6510 assert(_type == 13)
6511 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006512 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006513 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006514 obj.xid = reader.read("!L")[0]
6515 obj.buffer_id = reader.read("!L")[0]
6516 obj.in_port = util.unpack_port_no(reader)
6517 _actions_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006518 reader.skip(6)
Rich Lanee2567702015-01-26 15:04:35 -08006519 obj.actions = loxi.generic_util.unpack_list(reader.slice(_actions_len), ofp.action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006520 obj.data = str(reader.read_all())
6521 return obj
6522
6523 def __eq__(self, other):
6524 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006525 if self.xid != other.xid: return False
6526 if self.buffer_id != other.buffer_id: return False
6527 if self.in_port != other.in_port: return False
6528 if self.actions != other.actions: return False
6529 if self.data != other.data: return False
6530 return True
6531
Rich Lanec2ee4b82013-04-24 17:12:38 -07006532 def pretty_print(self, q):
6533 q.text("packet_out {")
6534 with q.group():
6535 with q.indent(2):
6536 q.breakable()
6537 q.text("xid = ");
6538 if self.xid != None:
6539 q.text("%#x" % self.xid)
6540 else:
6541 q.text('None')
6542 q.text(","); q.breakable()
6543 q.text("buffer_id = ");
6544 q.text("%#x" % self.buffer_id)
6545 q.text(","); q.breakable()
6546 q.text("in_port = ");
6547 q.text(util.pretty_port(self.in_port))
6548 q.text(","); q.breakable()
6549 q.text("actions = ");
6550 q.pp(self.actions)
6551 q.text(","); q.breakable()
6552 q.text("data = ");
6553 q.pp(self.data)
6554 q.breakable()
6555 q.text('}')
6556
Rich Lane7dcdf022013-12-11 14:45:27 -08006557message.subtypes[13] = packet_out
6558
6559class port_mod(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006560 version = 2
6561 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -07006562
6563 def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006564 if xid != None:
6565 self.xid = xid
6566 else:
6567 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006568 if port_no != None:
6569 self.port_no = port_no
6570 else:
6571 self.port_no = 0
6572 if hw_addr != None:
6573 self.hw_addr = hw_addr
6574 else:
6575 self.hw_addr = [0,0,0,0,0,0]
6576 if config != None:
6577 self.config = config
6578 else:
6579 self.config = 0
6580 if mask != None:
6581 self.mask = mask
6582 else:
6583 self.mask = 0
6584 if advertise != None:
6585 self.advertise = advertise
6586 else:
6587 self.advertise = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006588 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006589
6590 def pack(self):
6591 packed = []
6592 packed.append(struct.pack("!B", self.version))
6593 packed.append(struct.pack("!B", self.type))
6594 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6595 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07006596 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006597 packed.append('\x00' * 4)
6598 packed.append(struct.pack("!6B", *self.hw_addr))
6599 packed.append('\x00' * 2)
6600 packed.append(struct.pack("!L", self.config))
6601 packed.append(struct.pack("!L", self.mask))
6602 packed.append(struct.pack("!L", self.advertise))
6603 packed.append('\x00' * 4)
6604 length = sum([len(x) for x in packed])
6605 packed[2] = struct.pack("!H", length)
6606 return ''.join(packed)
6607
6608 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006609 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006610 obj = port_mod()
Dan Talaycof6202252013-07-02 01:00:29 -07006611 _version = reader.read("!B")[0]
6612 assert(_version == 2)
6613 _type = reader.read("!B")[0]
6614 assert(_type == 16)
6615 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006616 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006617 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006618 obj.xid = reader.read("!L")[0]
6619 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006620 reader.skip(4)
6621 obj.hw_addr = list(reader.read('!6B'))
6622 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07006623 obj.config = reader.read("!L")[0]
6624 obj.mask = reader.read("!L")[0]
6625 obj.advertise = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006626 reader.skip(4)
6627 return obj
6628
6629 def __eq__(self, other):
6630 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006631 if self.xid != other.xid: return False
6632 if self.port_no != other.port_no: return False
6633 if self.hw_addr != other.hw_addr: return False
6634 if self.config != other.config: return False
6635 if self.mask != other.mask: return False
6636 if self.advertise != other.advertise: return False
6637 return True
6638
Rich Lanec2ee4b82013-04-24 17:12:38 -07006639 def pretty_print(self, q):
6640 q.text("port_mod {")
6641 with q.group():
6642 with q.indent(2):
6643 q.breakable()
6644 q.text("xid = ");
6645 if self.xid != None:
6646 q.text("%#x" % self.xid)
6647 else:
6648 q.text('None')
6649 q.text(","); q.breakable()
6650 q.text("port_no = ");
6651 q.text(util.pretty_port(self.port_no))
6652 q.text(","); q.breakable()
6653 q.text("hw_addr = ");
6654 q.text(util.pretty_mac(self.hw_addr))
6655 q.text(","); q.breakable()
6656 q.text("config = ");
6657 q.text("%#x" % self.config)
6658 q.text(","); q.breakable()
6659 q.text("mask = ");
6660 q.text("%#x" % self.mask)
6661 q.text(","); q.breakable()
6662 q.text("advertise = ");
6663 q.text("%#x" % self.advertise)
6664 q.breakable()
6665 q.text('}')
6666
Rich Lane7dcdf022013-12-11 14:45:27 -08006667message.subtypes[16] = port_mod
6668
6669class port_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07006670 version = 2
6671 type = 1
6672 err_type = 7
6673
6674 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006675 if xid != None:
6676 self.xid = xid
6677 else:
6678 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07006679 if code != None:
6680 self.code = code
6681 else:
6682 self.code = 0
6683 if data != None:
6684 self.data = data
6685 else:
6686 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006687 return
Rich Lane6f4978c2013-10-20 21:33:52 -07006688
6689 def pack(self):
6690 packed = []
6691 packed.append(struct.pack("!B", self.version))
6692 packed.append(struct.pack("!B", self.type))
6693 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6694 packed.append(struct.pack("!L", self.xid))
6695 packed.append(struct.pack("!H", self.err_type))
6696 packed.append(struct.pack("!H", self.code))
6697 packed.append(self.data)
6698 length = sum([len(x) for x in packed])
6699 packed[2] = struct.pack("!H", length)
6700 return ''.join(packed)
6701
6702 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006703 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07006704 obj = port_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07006705 _version = reader.read("!B")[0]
6706 assert(_version == 2)
6707 _type = reader.read("!B")[0]
6708 assert(_type == 1)
6709 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006710 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006711 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07006712 obj.xid = reader.read("!L")[0]
6713 _err_type = reader.read("!H")[0]
6714 assert(_err_type == 7)
6715 obj.code = reader.read("!H")[0]
6716 obj.data = str(reader.read_all())
6717 return obj
6718
6719 def __eq__(self, other):
6720 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07006721 if self.xid != other.xid: return False
6722 if self.code != other.code: return False
6723 if self.data != other.data: return False
6724 return True
6725
Rich Lane6f4978c2013-10-20 21:33:52 -07006726 def pretty_print(self, q):
6727 q.text("port_mod_failed_error_msg {")
6728 with q.group():
6729 with q.indent(2):
6730 q.breakable()
6731 q.text("xid = ");
6732 if self.xid != None:
6733 q.text("%#x" % self.xid)
6734 else:
6735 q.text('None')
6736 q.text(","); q.breakable()
6737 q.text("code = ");
6738 q.text("%#x" % self.code)
6739 q.text(","); q.breakable()
6740 q.text("data = ");
6741 q.pp(self.data)
6742 q.breakable()
6743 q.text('}')
6744
Rich Lane7dcdf022013-12-11 14:45:27 -08006745error_msg.subtypes[7] = port_mod_failed_error_msg
6746
6747class port_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07006748 version = 2
6749 type = 19
6750 stats_type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07006751
6752 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006753 if xid != None:
6754 self.xid = xid
6755 else:
6756 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006757 if flags != None:
6758 self.flags = flags
6759 else:
6760 self.flags = 0
6761 if entries != None:
6762 self.entries = entries
6763 else:
6764 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08006765 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006766
6767 def pack(self):
6768 packed = []
6769 packed.append(struct.pack("!B", self.version))
6770 packed.append(struct.pack("!B", self.type))
6771 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6772 packed.append(struct.pack("!L", self.xid))
6773 packed.append(struct.pack("!H", self.stats_type))
6774 packed.append(struct.pack("!H", self.flags))
6775 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08006776 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006777 length = sum([len(x) for x in packed])
6778 packed[2] = struct.pack("!H", length)
6779 return ''.join(packed)
6780
6781 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006782 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006783 obj = port_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07006784 _version = reader.read("!B")[0]
6785 assert(_version == 2)
6786 _type = reader.read("!B")[0]
6787 assert(_type == 19)
6788 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006789 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006790 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006791 obj.xid = reader.read("!L")[0]
6792 _stats_type = reader.read("!H")[0]
6793 assert(_stats_type == 4)
6794 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006795 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08006796 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.port_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006797 return obj
6798
6799 def __eq__(self, other):
6800 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006801 if self.xid != other.xid: return False
6802 if self.flags != other.flags: return False
6803 if self.entries != other.entries: return False
6804 return True
6805
Rich Lanec2ee4b82013-04-24 17:12:38 -07006806 def pretty_print(self, q):
6807 q.text("port_stats_reply {")
6808 with q.group():
6809 with q.indent(2):
6810 q.breakable()
6811 q.text("xid = ");
6812 if self.xid != None:
6813 q.text("%#x" % self.xid)
6814 else:
6815 q.text('None')
6816 q.text(","); q.breakable()
6817 q.text("flags = ");
6818 q.text("%#x" % self.flags)
6819 q.text(","); q.breakable()
6820 q.text("entries = ");
6821 q.pp(self.entries)
6822 q.breakable()
6823 q.text('}')
6824
Rich Lane7dcdf022013-12-11 14:45:27 -08006825stats_reply.subtypes[4] = port_stats_reply
6826
6827class port_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07006828 version = 2
6829 type = 18
6830 stats_type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07006831
6832 def __init__(self, xid=None, flags=None, port_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006833 if xid != None:
6834 self.xid = xid
6835 else:
6836 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006837 if flags != None:
6838 self.flags = flags
6839 else:
6840 self.flags = 0
6841 if port_no != None:
6842 self.port_no = port_no
6843 else:
6844 self.port_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006845 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006846
6847 def pack(self):
6848 packed = []
6849 packed.append(struct.pack("!B", self.version))
6850 packed.append(struct.pack("!B", self.type))
6851 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6852 packed.append(struct.pack("!L", self.xid))
6853 packed.append(struct.pack("!H", self.stats_type))
6854 packed.append(struct.pack("!H", self.flags))
6855 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006856 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006857 packed.append('\x00' * 4)
6858 length = sum([len(x) for x in packed])
6859 packed[2] = struct.pack("!H", length)
6860 return ''.join(packed)
6861
6862 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006863 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006864 obj = port_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07006865 _version = reader.read("!B")[0]
6866 assert(_version == 2)
6867 _type = reader.read("!B")[0]
6868 assert(_type == 18)
6869 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006870 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006871 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006872 obj.xid = reader.read("!L")[0]
6873 _stats_type = reader.read("!H")[0]
6874 assert(_stats_type == 4)
6875 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006876 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07006877 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006878 reader.skip(4)
6879 return obj
6880
6881 def __eq__(self, other):
6882 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006883 if self.xid != other.xid: return False
6884 if self.flags != other.flags: return False
6885 if self.port_no != other.port_no: return False
6886 return True
6887
Rich Lanec2ee4b82013-04-24 17:12:38 -07006888 def pretty_print(self, q):
6889 q.text("port_stats_request {")
6890 with q.group():
6891 with q.indent(2):
6892 q.breakable()
6893 q.text("xid = ");
6894 if self.xid != None:
6895 q.text("%#x" % self.xid)
6896 else:
6897 q.text('None')
6898 q.text(","); q.breakable()
6899 q.text("flags = ");
6900 q.text("%#x" % self.flags)
6901 q.text(","); q.breakable()
6902 q.text("port_no = ");
6903 q.text(util.pretty_port(self.port_no))
6904 q.breakable()
6905 q.text('}')
6906
Rich Lane7dcdf022013-12-11 14:45:27 -08006907stats_request.subtypes[4] = port_stats_request
6908
6909class port_status(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006910 version = 2
6911 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07006912
6913 def __init__(self, xid=None, reason=None, desc=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006914 if xid != None:
6915 self.xid = xid
6916 else:
6917 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006918 if reason != None:
6919 self.reason = reason
6920 else:
6921 self.reason = 0
6922 if desc != None:
6923 self.desc = desc
6924 else:
Rich Lanee2567702015-01-26 15:04:35 -08006925 self.desc = ofp.port_desc()
Rich Lane7dcdf022013-12-11 14:45:27 -08006926 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006927
6928 def pack(self):
6929 packed = []
6930 packed.append(struct.pack("!B", self.version))
6931 packed.append(struct.pack("!B", self.type))
6932 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6933 packed.append(struct.pack("!L", self.xid))
6934 packed.append(struct.pack("!B", self.reason))
6935 packed.append('\x00' * 7)
6936 packed.append(self.desc.pack())
6937 length = sum([len(x) for x in packed])
6938 packed[2] = struct.pack("!H", length)
6939 return ''.join(packed)
6940
6941 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006942 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006943 obj = port_status()
Dan Talaycof6202252013-07-02 01:00:29 -07006944 _version = reader.read("!B")[0]
6945 assert(_version == 2)
6946 _type = reader.read("!B")[0]
6947 assert(_type == 12)
6948 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006949 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006950 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006951 obj.xid = reader.read("!L")[0]
6952 obj.reason = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006953 reader.skip(7)
Rich Lanee2567702015-01-26 15:04:35 -08006954 obj.desc = ofp.port_desc.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006955 return obj
6956
6957 def __eq__(self, other):
6958 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006959 if self.xid != other.xid: return False
6960 if self.reason != other.reason: return False
6961 if self.desc != other.desc: return False
6962 return True
6963
Rich Lanec2ee4b82013-04-24 17:12:38 -07006964 def pretty_print(self, q):
6965 q.text("port_status {")
6966 with q.group():
6967 with q.indent(2):
6968 q.breakable()
6969 q.text("xid = ");
6970 if self.xid != None:
6971 q.text("%#x" % self.xid)
6972 else:
6973 q.text('None')
6974 q.text(","); q.breakable()
6975 q.text("reason = ");
6976 q.text("%#x" % self.reason)
6977 q.text(","); q.breakable()
6978 q.text("desc = ");
6979 q.pp(self.desc)
6980 q.breakable()
6981 q.text('}')
6982
Rich Lane7dcdf022013-12-11 14:45:27 -08006983message.subtypes[12] = port_status
6984
6985class queue_get_config_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006986 version = 2
6987 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07006988
6989 def __init__(self, xid=None, port=None, queues=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006990 if xid != None:
6991 self.xid = xid
6992 else:
6993 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006994 if port != None:
6995 self.port = port
6996 else:
6997 self.port = 0
6998 if queues != None:
6999 self.queues = queues
7000 else:
7001 self.queues = []
Rich Lane7dcdf022013-12-11 14:45:27 -08007002 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007003
7004 def pack(self):
7005 packed = []
7006 packed.append(struct.pack("!B", self.version))
7007 packed.append(struct.pack("!B", self.type))
7008 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7009 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07007010 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007011 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08007012 packed.append(loxi.generic_util.pack_list(self.queues))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007013 length = sum([len(x) for x in packed])
7014 packed[2] = struct.pack("!H", length)
7015 return ''.join(packed)
7016
7017 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007018 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007019 obj = queue_get_config_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07007020 _version = reader.read("!B")[0]
7021 assert(_version == 2)
7022 _type = reader.read("!B")[0]
7023 assert(_type == 23)
7024 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007025 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007026 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007027 obj.xid = reader.read("!L")[0]
7028 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007029 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08007030 obj.queues = loxi.generic_util.unpack_list(reader, ofp.common.packet_queue.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007031 return obj
7032
7033 def __eq__(self, other):
7034 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007035 if self.xid != other.xid: return False
7036 if self.port != other.port: return False
7037 if self.queues != other.queues: return False
7038 return True
7039
Rich Lanec2ee4b82013-04-24 17:12:38 -07007040 def pretty_print(self, q):
7041 q.text("queue_get_config_reply {")
7042 with q.group():
7043 with q.indent(2):
7044 q.breakable()
7045 q.text("xid = ");
7046 if self.xid != None:
7047 q.text("%#x" % self.xid)
7048 else:
7049 q.text('None')
7050 q.text(","); q.breakable()
7051 q.text("port = ");
7052 q.text(util.pretty_port(self.port))
7053 q.text(","); q.breakable()
7054 q.text("queues = ");
7055 q.pp(self.queues)
7056 q.breakable()
7057 q.text('}')
7058
Rich Lane7dcdf022013-12-11 14:45:27 -08007059message.subtypes[23] = queue_get_config_reply
7060
7061class queue_get_config_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007062 version = 2
7063 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -07007064
7065 def __init__(self, xid=None, port=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007066 if xid != None:
7067 self.xid = xid
7068 else:
7069 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007070 if port != None:
7071 self.port = port
7072 else:
7073 self.port = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007074 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007075
7076 def pack(self):
7077 packed = []
7078 packed.append(struct.pack("!B", self.version))
7079 packed.append(struct.pack("!B", self.type))
7080 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7081 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07007082 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007083 packed.append('\x00' * 4)
7084 length = sum([len(x) for x in packed])
7085 packed[2] = struct.pack("!H", length)
7086 return ''.join(packed)
7087
7088 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007089 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007090 obj = queue_get_config_request()
Dan Talaycof6202252013-07-02 01:00:29 -07007091 _version = reader.read("!B")[0]
7092 assert(_version == 2)
7093 _type = reader.read("!B")[0]
7094 assert(_type == 22)
7095 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007096 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007097 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007098 obj.xid = reader.read("!L")[0]
7099 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007100 reader.skip(4)
7101 return obj
7102
7103 def __eq__(self, other):
7104 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007105 if self.xid != other.xid: return False
7106 if self.port != other.port: return False
7107 return True
7108
Rich Lanec2ee4b82013-04-24 17:12:38 -07007109 def pretty_print(self, q):
7110 q.text("queue_get_config_request {")
7111 with q.group():
7112 with q.indent(2):
7113 q.breakable()
7114 q.text("xid = ");
7115 if self.xid != None:
7116 q.text("%#x" % self.xid)
7117 else:
7118 q.text('None')
7119 q.text(","); q.breakable()
7120 q.text("port = ");
7121 q.text(util.pretty_port(self.port))
7122 q.breakable()
7123 q.text('}')
7124
Rich Lane7dcdf022013-12-11 14:45:27 -08007125message.subtypes[22] = queue_get_config_request
7126
7127class queue_op_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07007128 version = 2
7129 type = 1
7130 err_type = 9
7131
7132 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007133 if xid != None:
7134 self.xid = xid
7135 else:
7136 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07007137 if code != None:
7138 self.code = code
7139 else:
7140 self.code = 0
7141 if data != None:
7142 self.data = data
7143 else:
7144 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08007145 return
Rich Lane6f4978c2013-10-20 21:33:52 -07007146
7147 def pack(self):
7148 packed = []
7149 packed.append(struct.pack("!B", self.version))
7150 packed.append(struct.pack("!B", self.type))
7151 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7152 packed.append(struct.pack("!L", self.xid))
7153 packed.append(struct.pack("!H", self.err_type))
7154 packed.append(struct.pack("!H", self.code))
7155 packed.append(self.data)
7156 length = sum([len(x) for x in packed])
7157 packed[2] = struct.pack("!H", length)
7158 return ''.join(packed)
7159
7160 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007161 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07007162 obj = queue_op_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07007163 _version = reader.read("!B")[0]
7164 assert(_version == 2)
7165 _type = reader.read("!B")[0]
7166 assert(_type == 1)
7167 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007168 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007169 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07007170 obj.xid = reader.read("!L")[0]
7171 _err_type = reader.read("!H")[0]
7172 assert(_err_type == 9)
7173 obj.code = reader.read("!H")[0]
7174 obj.data = str(reader.read_all())
7175 return obj
7176
7177 def __eq__(self, other):
7178 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07007179 if self.xid != other.xid: return False
7180 if self.code != other.code: return False
7181 if self.data != other.data: return False
7182 return True
7183
Rich Lane6f4978c2013-10-20 21:33:52 -07007184 def pretty_print(self, q):
7185 q.text("queue_op_failed_error_msg {")
7186 with q.group():
7187 with q.indent(2):
7188 q.breakable()
7189 q.text("xid = ");
7190 if self.xid != None:
7191 q.text("%#x" % self.xid)
7192 else:
7193 q.text('None')
7194 q.text(","); q.breakable()
7195 q.text("code = ");
7196 q.text("%#x" % self.code)
7197 q.text(","); q.breakable()
7198 q.text("data = ");
7199 q.pp(self.data)
7200 q.breakable()
7201 q.text('}')
7202
Rich Lane7dcdf022013-12-11 14:45:27 -08007203error_msg.subtypes[9] = queue_op_failed_error_msg
7204
7205class queue_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07007206 version = 2
7207 type = 19
7208 stats_type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07007209
7210 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007211 if xid != None:
7212 self.xid = xid
7213 else:
7214 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007215 if flags != None:
7216 self.flags = flags
7217 else:
7218 self.flags = 0
7219 if entries != None:
7220 self.entries = entries
7221 else:
7222 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08007223 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007224
7225 def pack(self):
7226 packed = []
7227 packed.append(struct.pack("!B", self.version))
7228 packed.append(struct.pack("!B", self.type))
7229 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7230 packed.append(struct.pack("!L", self.xid))
7231 packed.append(struct.pack("!H", self.stats_type))
7232 packed.append(struct.pack("!H", self.flags))
7233 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08007234 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007235 length = sum([len(x) for x in packed])
7236 packed[2] = struct.pack("!H", length)
7237 return ''.join(packed)
7238
7239 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007240 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007241 obj = queue_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07007242 _version = reader.read("!B")[0]
7243 assert(_version == 2)
7244 _type = reader.read("!B")[0]
7245 assert(_type == 19)
7246 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007247 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007248 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007249 obj.xid = reader.read("!L")[0]
7250 _stats_type = reader.read("!H")[0]
7251 assert(_stats_type == 5)
7252 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007253 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08007254 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.queue_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007255 return obj
7256
7257 def __eq__(self, other):
7258 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007259 if self.xid != other.xid: return False
7260 if self.flags != other.flags: return False
7261 if self.entries != other.entries: return False
7262 return True
7263
Rich Lanec2ee4b82013-04-24 17:12:38 -07007264 def pretty_print(self, q):
7265 q.text("queue_stats_reply {")
7266 with q.group():
7267 with q.indent(2):
7268 q.breakable()
7269 q.text("xid = ");
7270 if self.xid != None:
7271 q.text("%#x" % self.xid)
7272 else:
7273 q.text('None')
7274 q.text(","); q.breakable()
7275 q.text("flags = ");
7276 q.text("%#x" % self.flags)
7277 q.text(","); q.breakable()
7278 q.text("entries = ");
7279 q.pp(self.entries)
7280 q.breakable()
7281 q.text('}')
7282
Rich Lane7dcdf022013-12-11 14:45:27 -08007283stats_reply.subtypes[5] = queue_stats_reply
7284
7285class queue_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07007286 version = 2
7287 type = 18
7288 stats_type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07007289
7290 def __init__(self, xid=None, flags=None, port_no=None, queue_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007291 if xid != None:
7292 self.xid = xid
7293 else:
7294 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007295 if flags != None:
7296 self.flags = flags
7297 else:
7298 self.flags = 0
7299 if port_no != None:
7300 self.port_no = port_no
7301 else:
7302 self.port_no = 0
7303 if queue_id != None:
7304 self.queue_id = queue_id
7305 else:
7306 self.queue_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007307 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007308
7309 def pack(self):
7310 packed = []
7311 packed.append(struct.pack("!B", self.version))
7312 packed.append(struct.pack("!B", self.type))
7313 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7314 packed.append(struct.pack("!L", self.xid))
7315 packed.append(struct.pack("!H", self.stats_type))
7316 packed.append(struct.pack("!H", self.flags))
7317 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007318 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007319 packed.append(struct.pack("!L", self.queue_id))
7320 length = sum([len(x) for x in packed])
7321 packed[2] = struct.pack("!H", length)
7322 return ''.join(packed)
7323
7324 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007325 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007326 obj = queue_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07007327 _version = reader.read("!B")[0]
7328 assert(_version == 2)
7329 _type = reader.read("!B")[0]
7330 assert(_type == 18)
7331 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007332 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007333 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007334 obj.xid = reader.read("!L")[0]
7335 _stats_type = reader.read("!H")[0]
7336 assert(_stats_type == 5)
7337 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007338 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07007339 obj.port_no = util.unpack_port_no(reader)
7340 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007341 return obj
7342
7343 def __eq__(self, other):
7344 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007345 if self.xid != other.xid: return False
7346 if self.flags != other.flags: return False
7347 if self.port_no != other.port_no: return False
7348 if self.queue_id != other.queue_id: return False
7349 return True
7350
Rich Lanec2ee4b82013-04-24 17:12:38 -07007351 def pretty_print(self, q):
7352 q.text("queue_stats_request {")
7353 with q.group():
7354 with q.indent(2):
7355 q.breakable()
7356 q.text("xid = ");
7357 if self.xid != None:
7358 q.text("%#x" % self.xid)
7359 else:
7360 q.text('None')
7361 q.text(","); q.breakable()
7362 q.text("flags = ");
7363 q.text("%#x" % self.flags)
7364 q.text(","); q.breakable()
7365 q.text("port_no = ");
7366 q.text(util.pretty_port(self.port_no))
7367 q.text(","); q.breakable()
7368 q.text("queue_id = ");
7369 q.text("%#x" % self.queue_id)
7370 q.breakable()
7371 q.text('}')
7372
Rich Lane7dcdf022013-12-11 14:45:27 -08007373stats_request.subtypes[5] = queue_stats_request
7374
7375class set_config(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007376 version = 2
7377 type = 9
Rich Lanec2ee4b82013-04-24 17:12:38 -07007378
7379 def __init__(self, xid=None, flags=None, miss_send_len=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007380 if xid != None:
7381 self.xid = xid
7382 else:
7383 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007384 if flags != None:
7385 self.flags = flags
7386 else:
7387 self.flags = 0
7388 if miss_send_len != None:
7389 self.miss_send_len = miss_send_len
7390 else:
7391 self.miss_send_len = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007392 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007393
7394 def pack(self):
7395 packed = []
7396 packed.append(struct.pack("!B", self.version))
7397 packed.append(struct.pack("!B", self.type))
7398 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7399 packed.append(struct.pack("!L", self.xid))
7400 packed.append(struct.pack("!H", self.flags))
7401 packed.append(struct.pack("!H", self.miss_send_len))
7402 length = sum([len(x) for x in packed])
7403 packed[2] = struct.pack("!H", length)
7404 return ''.join(packed)
7405
7406 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007407 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007408 obj = set_config()
Dan Talaycof6202252013-07-02 01:00:29 -07007409 _version = reader.read("!B")[0]
7410 assert(_version == 2)
7411 _type = reader.read("!B")[0]
7412 assert(_type == 9)
7413 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007414 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007415 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007416 obj.xid = reader.read("!L")[0]
7417 obj.flags = reader.read("!H")[0]
7418 obj.miss_send_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007419 return obj
7420
7421 def __eq__(self, other):
7422 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007423 if self.xid != other.xid: return False
7424 if self.flags != other.flags: return False
7425 if self.miss_send_len != other.miss_send_len: return False
7426 return True
7427
Rich Lanec2ee4b82013-04-24 17:12:38 -07007428 def pretty_print(self, q):
7429 q.text("set_config {")
7430 with q.group():
7431 with q.indent(2):
7432 q.breakable()
7433 q.text("xid = ");
7434 if self.xid != None:
7435 q.text("%#x" % self.xid)
7436 else:
7437 q.text('None')
7438 q.text(","); q.breakable()
7439 q.text("flags = ");
7440 q.text("%#x" % self.flags)
7441 q.text(","); q.breakable()
7442 q.text("miss_send_len = ");
7443 q.text("%#x" % self.miss_send_len)
7444 q.breakable()
7445 q.text('}')
7446
Rich Lane7dcdf022013-12-11 14:45:27 -08007447message.subtypes[9] = set_config
7448
7449class switch_config_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07007450 version = 2
7451 type = 1
7452 err_type = 10
7453
7454 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007455 if xid != None:
7456 self.xid = xid
7457 else:
7458 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07007459 if code != None:
7460 self.code = code
7461 else:
7462 self.code = 0
7463 if data != None:
7464 self.data = data
7465 else:
7466 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08007467 return
Rich Lane6f4978c2013-10-20 21:33:52 -07007468
7469 def pack(self):
7470 packed = []
7471 packed.append(struct.pack("!B", self.version))
7472 packed.append(struct.pack("!B", self.type))
7473 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7474 packed.append(struct.pack("!L", self.xid))
7475 packed.append(struct.pack("!H", self.err_type))
7476 packed.append(struct.pack("!H", self.code))
7477 packed.append(self.data)
7478 length = sum([len(x) for x in packed])
7479 packed[2] = struct.pack("!H", length)
7480 return ''.join(packed)
7481
7482 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007483 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07007484 obj = switch_config_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07007485 _version = reader.read("!B")[0]
7486 assert(_version == 2)
7487 _type = reader.read("!B")[0]
7488 assert(_type == 1)
7489 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007490 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007491 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07007492 obj.xid = reader.read("!L")[0]
7493 _err_type = reader.read("!H")[0]
7494 assert(_err_type == 10)
7495 obj.code = reader.read("!H")[0]
7496 obj.data = str(reader.read_all())
7497 return obj
7498
7499 def __eq__(self, other):
7500 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07007501 if self.xid != other.xid: return False
7502 if self.code != other.code: return False
7503 if self.data != other.data: return False
7504 return True
7505
Rich Lane6f4978c2013-10-20 21:33:52 -07007506 def pretty_print(self, q):
7507 q.text("switch_config_failed_error_msg {")
7508 with q.group():
7509 with q.indent(2):
7510 q.breakable()
7511 q.text("xid = ");
7512 if self.xid != None:
7513 q.text("%#x" % self.xid)
7514 else:
7515 q.text('None')
7516 q.text(","); q.breakable()
7517 q.text("code = ");
7518 q.text("%#x" % self.code)
7519 q.text(","); q.breakable()
7520 q.text("data = ");
7521 q.pp(self.data)
7522 q.breakable()
7523 q.text('}')
7524
Rich Lane7dcdf022013-12-11 14:45:27 -08007525error_msg.subtypes[10] = switch_config_failed_error_msg
7526
7527class table_mod(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007528 version = 2
7529 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -07007530
7531 def __init__(self, xid=None, table_id=None, config=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007532 if xid != None:
7533 self.xid = xid
7534 else:
7535 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007536 if table_id != None:
7537 self.table_id = table_id
7538 else:
7539 self.table_id = 0
7540 if config != None:
7541 self.config = config
7542 else:
7543 self.config = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007544 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007545
7546 def pack(self):
7547 packed = []
7548 packed.append(struct.pack("!B", self.version))
7549 packed.append(struct.pack("!B", self.type))
7550 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7551 packed.append(struct.pack("!L", self.xid))
7552 packed.append(struct.pack("!B", self.table_id))
7553 packed.append('\x00' * 3)
7554 packed.append(struct.pack("!L", self.config))
7555 length = sum([len(x) for x in packed])
7556 packed[2] = struct.pack("!H", length)
7557 return ''.join(packed)
7558
7559 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007560 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007561 obj = table_mod()
Dan Talaycof6202252013-07-02 01:00:29 -07007562 _version = reader.read("!B")[0]
7563 assert(_version == 2)
7564 _type = reader.read("!B")[0]
7565 assert(_type == 17)
7566 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007567 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007568 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007569 obj.xid = reader.read("!L")[0]
7570 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007571 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07007572 obj.config = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007573 return obj
7574
7575 def __eq__(self, other):
7576 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007577 if self.xid != other.xid: return False
7578 if self.table_id != other.table_id: return False
7579 if self.config != other.config: return False
7580 return True
7581
Rich Lanec2ee4b82013-04-24 17:12:38 -07007582 def pretty_print(self, q):
7583 q.text("table_mod {")
7584 with q.group():
7585 with q.indent(2):
7586 q.breakable()
7587 q.text("xid = ");
7588 if self.xid != None:
7589 q.text("%#x" % self.xid)
7590 else:
7591 q.text('None')
7592 q.text(","); q.breakable()
7593 q.text("table_id = ");
7594 q.text("%#x" % self.table_id)
7595 q.text(","); q.breakable()
7596 q.text("config = ");
7597 q.text("%#x" % self.config)
7598 q.breakable()
7599 q.text('}')
7600
Rich Lane7dcdf022013-12-11 14:45:27 -08007601message.subtypes[17] = table_mod
7602
7603class table_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07007604 version = 2
7605 type = 1
7606 err_type = 8
7607
7608 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007609 if xid != None:
7610 self.xid = xid
7611 else:
7612 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07007613 if code != None:
7614 self.code = code
7615 else:
7616 self.code = 0
7617 if data != None:
7618 self.data = data
7619 else:
7620 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08007621 return
Rich Lane6f4978c2013-10-20 21:33:52 -07007622
7623 def pack(self):
7624 packed = []
7625 packed.append(struct.pack("!B", self.version))
7626 packed.append(struct.pack("!B", self.type))
7627 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7628 packed.append(struct.pack("!L", self.xid))
7629 packed.append(struct.pack("!H", self.err_type))
7630 packed.append(struct.pack("!H", self.code))
7631 packed.append(self.data)
7632 length = sum([len(x) for x in packed])
7633 packed[2] = struct.pack("!H", length)
7634 return ''.join(packed)
7635
7636 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007637 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07007638 obj = table_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07007639 _version = reader.read("!B")[0]
7640 assert(_version == 2)
7641 _type = reader.read("!B")[0]
7642 assert(_type == 1)
7643 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007644 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007645 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07007646 obj.xid = reader.read("!L")[0]
7647 _err_type = reader.read("!H")[0]
7648 assert(_err_type == 8)
7649 obj.code = reader.read("!H")[0]
7650 obj.data = str(reader.read_all())
7651 return obj
7652
7653 def __eq__(self, other):
7654 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07007655 if self.xid != other.xid: return False
7656 if self.code != other.code: return False
7657 if self.data != other.data: return False
7658 return True
7659
Rich Lane6f4978c2013-10-20 21:33:52 -07007660 def pretty_print(self, q):
7661 q.text("table_mod_failed_error_msg {")
7662 with q.group():
7663 with q.indent(2):
7664 q.breakable()
7665 q.text("xid = ");
7666 if self.xid != None:
7667 q.text("%#x" % self.xid)
7668 else:
7669 q.text('None')
7670 q.text(","); q.breakable()
7671 q.text("code = ");
7672 q.text("%#x" % self.code)
7673 q.text(","); q.breakable()
7674 q.text("data = ");
7675 q.pp(self.data)
7676 q.breakable()
7677 q.text('}')
7678
Rich Lane7dcdf022013-12-11 14:45:27 -08007679error_msg.subtypes[8] = table_mod_failed_error_msg
7680
7681class table_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07007682 version = 2
7683 type = 19
7684 stats_type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07007685
7686 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007687 if xid != None:
7688 self.xid = xid
7689 else:
7690 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007691 if flags != None:
7692 self.flags = flags
7693 else:
7694 self.flags = 0
7695 if entries != None:
7696 self.entries = entries
7697 else:
7698 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08007699 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007700
7701 def pack(self):
7702 packed = []
7703 packed.append(struct.pack("!B", self.version))
7704 packed.append(struct.pack("!B", self.type))
7705 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7706 packed.append(struct.pack("!L", self.xid))
7707 packed.append(struct.pack("!H", self.stats_type))
7708 packed.append(struct.pack("!H", self.flags))
7709 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08007710 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007711 length = sum([len(x) for x in packed])
7712 packed[2] = struct.pack("!H", length)
7713 return ''.join(packed)
7714
7715 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007716 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007717 obj = table_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07007718 _version = reader.read("!B")[0]
7719 assert(_version == 2)
7720 _type = reader.read("!B")[0]
7721 assert(_type == 19)
7722 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007723 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007724 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007725 obj.xid = reader.read("!L")[0]
7726 _stats_type = reader.read("!H")[0]
7727 assert(_stats_type == 3)
7728 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007729 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08007730 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.table_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007731 return obj
7732
7733 def __eq__(self, other):
7734 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007735 if self.xid != other.xid: return False
7736 if self.flags != other.flags: return False
7737 if self.entries != other.entries: return False
7738 return True
7739
Rich Lanec2ee4b82013-04-24 17:12:38 -07007740 def pretty_print(self, q):
7741 q.text("table_stats_reply {")
7742 with q.group():
7743 with q.indent(2):
7744 q.breakable()
7745 q.text("xid = ");
7746 if self.xid != None:
7747 q.text("%#x" % self.xid)
7748 else:
7749 q.text('None')
7750 q.text(","); q.breakable()
7751 q.text("flags = ");
7752 q.text("%#x" % self.flags)
7753 q.text(","); q.breakable()
7754 q.text("entries = ");
7755 q.pp(self.entries)
7756 q.breakable()
7757 q.text('}')
7758
Rich Lane7dcdf022013-12-11 14:45:27 -08007759stats_reply.subtypes[3] = table_stats_reply
7760
7761class table_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07007762 version = 2
7763 type = 18
7764 stats_type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07007765
7766 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007767 if xid != None:
7768 self.xid = xid
7769 else:
7770 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007771 if flags != None:
7772 self.flags = flags
7773 else:
7774 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007775 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007776
7777 def pack(self):
7778 packed = []
7779 packed.append(struct.pack("!B", self.version))
7780 packed.append(struct.pack("!B", self.type))
7781 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7782 packed.append(struct.pack("!L", self.xid))
7783 packed.append(struct.pack("!H", self.stats_type))
7784 packed.append(struct.pack("!H", self.flags))
7785 packed.append('\x00' * 4)
7786 length = sum([len(x) for x in packed])
7787 packed[2] = struct.pack("!H", length)
7788 return ''.join(packed)
7789
7790 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007791 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007792 obj = table_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07007793 _version = reader.read("!B")[0]
7794 assert(_version == 2)
7795 _type = reader.read("!B")[0]
7796 assert(_type == 18)
7797 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007798 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007799 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007800 obj.xid = reader.read("!L")[0]
7801 _stats_type = reader.read("!H")[0]
7802 assert(_stats_type == 3)
7803 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007804 reader.skip(4)
7805 return obj
7806
7807 def __eq__(self, other):
7808 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007809 if self.xid != other.xid: return False
7810 if self.flags != other.flags: return False
7811 return True
7812
Rich Lanec2ee4b82013-04-24 17:12:38 -07007813 def pretty_print(self, q):
7814 q.text("table_stats_request {")
7815 with q.group():
7816 with q.indent(2):
7817 q.breakable()
7818 q.text("xid = ");
7819 if self.xid != None:
7820 q.text("%#x" % self.xid)
7821 else:
7822 q.text('None')
7823 q.text(","); q.breakable()
7824 q.text("flags = ");
7825 q.text("%#x" % self.flags)
7826 q.breakable()
7827 q.text('}')
7828
Rich Lane7dcdf022013-12-11 14:45:27 -08007829stats_request.subtypes[3] = table_stats_request
7830
Rich Lanec2ee4b82013-04-24 17:12:38 -07007831
7832def parse_header(buf):
7833 if len(buf) < 8:
7834 raise loxi.ProtocolError("too short to be an OpenFlow message")
7835 return struct.unpack_from("!BBHL", buf)
7836
7837def parse_message(buf):
7838 msg_ver, msg_type, msg_len, msg_xid = parse_header(buf)
Rich Lanee2567702015-01-26 15:04:35 -08007839 if msg_ver != ofp.OFP_VERSION and msg_type != ofp.OFPT_HELLO:
7840 raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (ofp.OFP_VERSION, msg_ver))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007841 if len(buf) != msg_len:
7842 raise loxi.ProtocolError("incorrect message size")
Rich Lane7dcdf022013-12-11 14:45:27 -08007843 return message.unpack(loxi.generic_util.OFReader(buf))